feat: close server when game finished
This commit is contained in:
@@ -19,16 +19,16 @@ class Client {
|
||||
private:
|
||||
render::Renderer* m_Renderer;
|
||||
ClientConnexion m_Connexion;
|
||||
ClientGame m_Game;
|
||||
std::unique_ptr<ClientGame> m_Game;
|
||||
bool m_Connected;
|
||||
public:
|
||||
Client(render::Renderer* renderer) : m_Renderer(renderer), m_Game(this), m_Connected(false) {}
|
||||
Client(render::Renderer* renderer) : m_Renderer(renderer), m_Game(std::make_unique<ClientGame>(this)), m_Connected(false) {}
|
||||
|
||||
const ClientGame& getGame() const { return m_Game; }
|
||||
const ClientGame& getGame() const { return *m_Game; }
|
||||
const ClientConnexion& getConnexion() const { return m_Connexion; }
|
||||
render::Renderer* getRenderer() const { return m_Renderer; }
|
||||
|
||||
ClientGame& getGame() { return m_Game; }
|
||||
ClientGame& getGame() { return *m_Game; }
|
||||
ClientConnexion& getConnexion() { return m_Connexion; }
|
||||
|
||||
void tick(std::uint64_t delta);
|
||||
@@ -45,6 +45,8 @@ public:
|
||||
void placeTower(game::TowerType type, const glm::vec2& position);
|
||||
void upgradeTower(game::TowerID tower, game::TowerLevel level);
|
||||
void removeTower(game::TowerID tower);
|
||||
private:
|
||||
void reset();
|
||||
};
|
||||
|
||||
} // namespace client
|
||||
|
||||
@@ -61,12 +61,11 @@ private:
|
||||
bool m_ServerRunning;
|
||||
public:
|
||||
Server(const std::string& worldFilePath);
|
||||
virtual ~Server() {}
|
||||
virtual ~Server();
|
||||
|
||||
bool start(std::uint16_t port);
|
||||
void stop();
|
||||
|
||||
void lauchGame();
|
||||
void stop(); // force the server to stop
|
||||
void close(); // at the end of a game
|
||||
|
||||
void removeConnexion(std::uint8_t connexionID);
|
||||
|
||||
@@ -74,6 +73,8 @@ public:
|
||||
|
||||
float getTPS() const { return m_TickCounter.getTPS(); }
|
||||
|
||||
bool isRunning() { return m_ServerRunning; }
|
||||
|
||||
const ServerGame& getGame() const { return m_Game; }
|
||||
ServerGame& getGame() { return m_Game; }
|
||||
|
||||
@@ -88,6 +89,7 @@ private:
|
||||
void accept();
|
||||
void updateSockets();
|
||||
|
||||
void clean();
|
||||
void startThread();
|
||||
void stopThread();
|
||||
void tick(std::uint64_t delta);
|
||||
|
||||
Reference in New Issue
Block a user