1 #ifndef BLANK_SERVER_SERVER_HPP
2 #define BLANK_SERVER_SERVER_HPP
4 #include "../app/Config.hpp"
5 #include "../shared/CLI.hpp"
6 #include "../world/World.hpp"
7 #include "../world/WorldManipulator.hpp"
23 class ClientConnection;
26 : public WorldManipulator {
29 Server(const Config::Network &, World &, const World::Config &, const WorldSave &);
32 // wait for data to arrive for at most dt milliseconds
33 void Wait(int dt) noexcept;
34 // true if there's data waiting to be handled
35 bool Ready() noexcept;
40 UDPsocket &GetSocket() noexcept { return serv_sock; }
41 UDPpacket &GetPacket() noexcept { return serv_pack; }
43 World &GetWorld() noexcept { return world; }
44 const WorldSave &GetWorldSave() noexcept { return save; }
46 void SetPlayerModel(const Model &) noexcept;
47 bool HasPlayerModel() const noexcept;
48 const Model &GetPlayerModel() const noexcept;
50 Player *JoinPlayer(const std::string &name);
52 void SetBlock(Chunk &, int, const Block &) override;
54 /// for use by client connections when they receive a line from the player
55 void DispatchMessage(Player &, const std::string &);
57 /// send message to all connected clients
58 void DistributeMessage(std::uint8_t type, std::uint32_t ref, const std::string &msg);
61 void HandlePacket(const UDPpacket &);
63 ClientConnection &GetClient(const IPaddress &);
70 SDLNet_SocketSet serv_set;
71 std::list<ClientConnection> clients;
74 ChunkIndex &spawn_index;
75 const WorldSave &save;
76 const Model *player_model;