X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fserver%2FClientConnection.hpp;h=1a781c5dd6ad5dea7f88b033e4648bed6aee4550;hb=660c4216fc61c0d99987adbfea057af07b511a23;hp=99657de3642d262b70dbdcee5504e32efb66680b;hpb=8fdc24f0b3fb287f5d4e1c7d1f85ad85d5ed2414;p=blank.git diff --git a/src/server/ClientConnection.hpp b/src/server/ClientConnection.hpp index 99657de..1a781c5 100644 --- a/src/server/ClientConnection.hpp +++ b/src/server/ClientConnection.hpp @@ -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,13 +12,14 @@ #include #include +#include #include #include namespace blank { -class CompositeModel; +class Model; namespace server { @@ -47,17 +49,19 @@ 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; + void SetPlayerModel(const Model &) noexcept; bool HasPlayerModel() const noexcept; - const CompositeModel &GetPlayerModel() const noexcept; + const Model &GetPlayerModel() const noexcept; + + bool ChunkInRange(const glm::ivec3 &) const noexcept; private: struct SpawnStatus { @@ -79,6 +83,7 @@ private: void On(const Packet::Login &) override; void On(const Packet::Part &) override; void On(const Packet::PlayerUpdate &) override; + void On(const Packet::Message &) override; bool CanSpawn(const Entity &) const noexcept; bool CanDespawn(const Entity &) const noexcept; @@ -95,8 +100,8 @@ private: private: Server &server; Connection conn; - Player player; - const CompositeModel *player_model; + std::unique_ptr input; + const Model *player_model; std::list spawns; unsigned int confirm_wait; @@ -105,6 +110,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 chunk_queue;