refactor: create MainMenu and GameMenu classes

This commit is contained in:
2021-11-04 11:01:46 +01:00
parent 1186e5ee9c
commit 2fc0f28b27
9 changed files with 303 additions and 205 deletions

View File

@@ -25,6 +25,9 @@ public:
void sendTimeRemaining();
void tick();
//static constexpr int LobbyWaitingTime = 2 * 60 * 1000; // in millis
static constexpr int LobbyWaitingTime = 5 * 1000; // in millis
};
} // namespace server

View File

@@ -2,6 +2,7 @@
#include <cstdint>
#include <map>
#include <thread>
#include "network/TCPListener.h"
#include "protocol/Protocol.h"
@@ -11,9 +12,6 @@
#include "ServerConnexion.h"
#include "Lobby.h"
//#define LOBBY_WAITING_TIME 2 * 60 * 1000
#define LOBBY_WAITING_TIME 5 * 1000
#define SERVER_TPS 20
#define SERVER_TICK 1000 / SERVER_TPS
@@ -58,12 +56,14 @@ private:
ServerGame m_Game{ this };
Lobby m_Lobby{ this };
TickCounter m_TickCounter;
std::thread m_Thread;
bool m_ServerRunning;
public:
Server(const std::string& worldFilePath);
virtual ~Server() {}
bool start(std::uint16_t port);
void tick(std::uint64_t delta);
void stop();
void lauchGame();
@@ -88,6 +88,10 @@ private:
void accept();
void updateSockets();
void startThread();
void stopThread();
void tick(std::uint64_t delta);
void OnPlayerJoin(std::uint8_t id);
void OnPlayerLeave(std::uint8_t id);
};