X-Git-Url: http://git.localhorst.tv/?a=blobdiff_plain;f=src%2Fserver%2FServer.hpp;h=683d36254c76523a6ba5afddd84c2607ae204292;hb=dbd214ac278019c20c883cbb76456b0b0fddc063;hp=8bbb778a91b358a51cbb3d836cf64423fd4952a5;hpb=8ae45b6555d55f301f83daf8c1337d332d8305ab;p=blank.git diff --git a/src/server/Server.hpp b/src/server/Server.hpp index 8bbb778..683d362 100644 --- a/src/server/Server.hpp +++ b/src/server/Server.hpp @@ -1,27 +1,31 @@ #ifndef BLANK_SERVER_SERVER_HPP #define BLANK_SERVER_SERVER_HPP +#include "../app/Config.hpp" +#include "../world/World.hpp" +#include "../world/WorldManipulator.hpp" + +#include #include #include namespace blank { -class World; +class ChunkIndex; +class Model; +class Player; +class WorldSave; namespace server { class ClientConnection; -class Server { - -public: - struct Config { - Uint16 port = 12354; - }; +class Server +: public WorldManipulator { public: - Server(const Config &, World &); + Server(const Config::Network &, World &, const World::Config &, const WorldSave &); ~Server(); void Handle(); @@ -32,18 +36,35 @@ public: UDPpacket &GetPacket() noexcept { return serv_pack; } World &GetWorld() noexcept { return world; } + const WorldSave &GetWorldSave() noexcept { return save; } + + void SetPlayerModel(const Model &) noexcept; + bool HasPlayerModel() 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 Model *player_model; };