]> git.localhorst.tv Git - blank.git/blobdiff - src/client/MasterState.hpp
second attempt at "nice" client state correction
[blank.git] / src / client / MasterState.hpp
index 6bdb671836a9193a54068b67132a1284dad0e4c4..aaea6a99b442aa152b209d0f6953261746025b50 100644 (file)
@@ -7,6 +7,7 @@
 #include "../net/Client.hpp"
 #include "../net/ConnectionHandler.hpp"
 
+#include <map>
 #include <memory>
 
 
@@ -51,6 +52,17 @@ public:
 
        void On(const Packet::Join &) override;
        void On(const Packet::Part &) override;
+       void On(const Packet::SpawnEntity &) override;
+       void On(const Packet::DespawnEntity &) override;
+       void On(const Packet::EntityUpdate &) override;
+       void On(const Packet::PlayerCorrection &) override;
+
+private:
+       /// flag entity as updated by given packet
+       /// returns false if the update should be ignored
+       bool UpdateEntity(std::uint32_t id, std::uint16_t seq);
+       /// drop update information or given entity
+       void ClearEntity(std::uint32_t id);
 
 private:
        Environment &env;
@@ -64,6 +76,13 @@ private:
 
        int login_packet;
 
+       struct UpdateStatus {
+               std::uint16_t last_packet;
+               int last_update;
+       };
+       std::map<std::uint32_t, UpdateStatus> update_status;
+       IntervalTimer update_timer;
+
 };
 
 }