]> git.localhorst.tv Git - blank.git/blobdiff - src/client/net.cpp
send updates less frequently on bad connections
[blank.git] / src / client / net.cpp
index 6677f5143d3647d9bd3bc7e24ad1a6ec4beca9b3..18f593ac5831d218f0019723c511ff977a7e2ffe 100644 (file)
@@ -321,10 +321,16 @@ NetworkedInput::NetworkedInput(World &world, Player &player, Client &client)
 : PlayerController(world, player)
 , client(client)
 , player_hist()
+, old_movement(0.0f)
+, old_actions(0)
 , actions(0) {
 
 }
 
+bool NetworkedInput::UpdateImportant() const noexcept {
+       return old_actions != actions || !iszero(old_movement - GetMovement());
+}
+
 void NetworkedInput::Update(Entity &, float dt) {
        Invalidate();
        UpdatePlayer();
@@ -351,6 +357,8 @@ void NetworkedInput::PushPlayerUpdate(int dt) {
                entry->packet = packet;
                player_hist.splice(player_hist.end(), player_hist, entry);
        }
+       old_movement = GetMovement();
+       old_actions = actions;
 }
 
 void NetworkedInput::MergePlayerCorrection(uint16_t seq, const EntityState &corrected_state) {