]> git.localhorst.tv Git - blank.git/blobdiff - src/server/ClientConnection.hpp
move serverside joining from state to server
[blank.git] / src / server / ClientConnection.hpp
index 99657de3642d262b70dbdcee5504e32efb66680b..9aaae128d4c43ead42c6fac689f0b006cae3025b 100644 (file)
@@ -4,6 +4,7 @@
 #include "ChunkTransmitter.hpp"
 #include "Server.hpp"
 #include "../app/IntervalTimer.hpp"
+#include "../ui/DirectInput.hpp"
 #include "../net/Connection.hpp"
 #include "../net/ConnectionHandler.hpp"
 #include "../world/EntityState.hpp"
@@ -11,6 +12,7 @@
 
 #include <deque>
 #include <list>
+#include <memory>
 #include <SDL_net.h>
 #include <vector>
 
@@ -47,18 +49,20 @@ 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 !!input; }
+       Entity &PlayerEntity() noexcept { return input->GetPlayer().GetEntity(); }
+       const Entity &PlayerEntity() const noexcept { return input->GetPlayer().GetEntity(); }
+       ChunkIndex &PlayerChunks() noexcept { return input->GetPlayer().GetChunks(); }
+       const ChunkIndex &PlayerChunks() const noexcept { return input->GetPlayer().GetChunks(); }
 
        void SetPlayerModel(const CompositeModel &) noexcept;
        bool HasPlayerModel() const noexcept;
        const CompositeModel &GetPlayerModel() const noexcept;
 
+       bool ChunkInRange(const glm::ivec3 &) const noexcept;
+
 private:
        struct SpawnStatus {
                // the entity in question
@@ -95,7 +99,7 @@ private:
 private:
        Server &server;
        Connection conn;
-       Player player;
+       std::unique_ptr<DirectInput> input;
        const CompositeModel *player_model;
        std::list<SpawnStatus> spawns;
        unsigned int confirm_wait;
@@ -105,6 +109,7 @@ private:
        EntityState player_update_state;
        std::uint16_t player_update_pack;
        IntervalTimer player_update_timer;
+       std::uint8_t old_actions;
 
        ChunkTransmitter transmitter;
        std::deque<glm::ivec3> chunk_queue;