X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fserver%2FServer.hpp;h=683d36254c76523a6ba5afddd84c2607ae204292;hb=dbd214ac278019c20c883cbb76456b0b0fddc063;hp=372a947ef65fe0e14c1aa209d091036fcd47ed6b;hpb=a50aa0f2a2fea14f5f8c56209e2ecde3088ef913;p=blank.git diff --git a/src/server/Server.hpp b/src/server/Server.hpp index 372a947..683d362 100644 --- a/src/server/Server.hpp +++ b/src/server/Server.hpp @@ -2,16 +2,19 @@ #define BLANK_SERVER_SERVER_HPP #include "../app/Config.hpp" +#include "../world/World.hpp" #include "../world/WorldManipulator.hpp" +#include #include #include namespace blank { -class CompositeModel; -class World; +class ChunkIndex; +class Model; +class Player; class WorldSave; namespace server { @@ -22,7 +25,7 @@ class Server : public WorldManipulator { public: - Server(const Config::Network &, World &, const WorldSave &); + Server(const Config::Network &, World &, const World::Config &, const WorldSave &); ~Server(); void Handle(); @@ -35,25 +38,33 @@ public: World &GetWorld() noexcept { return world; } const WorldSave &GetWorldSave() noexcept { return save; } - void SetPlayerModel(const CompositeModel &) noexcept; + void SetPlayerModel(const Model &) noexcept; bool HasPlayerModel() const noexcept; - const CompositeModel &GetPlayerModel() const noexcept; + const Model &GetPlayerModel() const noexcept; + + Player *JoinPlayer(const std::string &name); void SetBlock(Chunk &, int, const Block &) override; + /// send message to all connected clients + void DistributeMessage(std::uint8_t type, std::uint32_t ref, const std::string &msg); + private: void HandlePacket(const UDPpacket &); ClientConnection &GetClient(const IPaddress &); + void SendAll(); + private: UDPsocket serv_sock; UDPpacket serv_pack; std::list clients; World &world; + ChunkIndex &spawn_index; const WorldSave &save; - const CompositeModel *player_model; + const Model *player_model; };