]> git.localhorst.tv Git - blank.git/blobdiff - src/server/ClientConnection.hpp
split input handling
[blank.git] / src / server / ClientConnection.hpp
index c5efb51bbd412d7d9aeffbe7e5b29803b83f4a2d..2089dd17c8eec85a7acf7e6e7d3d930f03946a5f 100644 (file)
 #include <deque>
 #include <list>
 #include <SDL_net.h>
+#include <vector>
 
 
 namespace blank {
+
+class CompositeModel;
+
 namespace server {
 
 class Server;
@@ -43,13 +47,17 @@ public:
        /// send the previously prepared packet of non-default length
        std::uint16_t Send(std::size_t len);
 
-       void AttachPlayer(const Player &);
+       void AttachPlayer(Player &);
        void DetachPlayer();
-       bool HasPlayer() const noexcept { return player.entity; }
-       Entity &PlayerEntity() noexcept { return *player.entity; }
-       const Entity &PlayerEntity() const noexcept { return *player.entity; }
-       ChunkIndex &PlayerChunks() noexcept { return *player.chunks; }
-       const ChunkIndex &PlayerChunks() const noexcept { return *player.chunks; }
+       bool HasPlayer() const noexcept { return player; }
+       Entity &PlayerEntity() noexcept { return player->GetEntity(); }
+       const Entity &PlayerEntity() const noexcept { return player->GetEntity(); }
+       ChunkIndex &PlayerChunks() noexcept { return player->GetChunks(); }
+       const ChunkIndex &PlayerChunks() const noexcept { return player->GetChunks(); }
+
+       void SetPlayerModel(const CompositeModel &) noexcept;
+       bool HasPlayerModel() const noexcept;
+       const CompositeModel &GetPlayerModel() const noexcept;
 
 private:
        struct SpawnStatus {
@@ -77,7 +85,8 @@ private:
 
        void SendSpawn(SpawnStatus &);
        void SendDespawn(SpawnStatus &);
-       void SendUpdate(SpawnStatus &);
+       void QueueUpdate(SpawnStatus &);
+       void SendUpdates();
 
        void CheckPlayerFix();
 
@@ -86,10 +95,13 @@ private:
 private:
        Server &server;
        Connection conn;
-       Player player;
+       Player *player;
+       const CompositeModel *player_model;
        std::list<SpawnStatus> spawns;
        unsigned int confirm_wait;
 
+       std::vector<SpawnStatus *> entity_updates;
+
        EntityState player_update_state;
        std::uint16_t player_update_pack;
        IntervalTimer player_update_timer;