7#include <unordered_map>
33 void dispatch(
int connectionId,
const std::string& line);
44 std::optional<GameClock::Stamp>
teamJoin(
const std::string& team)
const;
47 void _dispatchAi(
int connectionId,
const std::string& line);
48 void _dispatchGui(
int connectionId,
const std::string& line);
61 void _handleBct(
int connectionId,
int x,
int y);
64 void _handlePpo(
int connectionId,
int playerId);
65 void _handlePlv(
int connectionId,
int playerId);
66 void _handlePin(
int connectionId,
int playerId);
93 std::unordered_map<int, std::deque<Ai::Command>>
_queues;
ResourceType
Enumerate the different types of resources in the game.
Owns every client socket and runs the poll() loop.
Sends each client line to the right handler.
void _handleMct(int connectionId)
void _handleFork(int connectionId)
std::chrono::microseconds gameElapsed() const
Wall-clock time since server start (single source for stu and the win banner).
void _handleSst(int freq)
void _handlePlv(int connectionId, int playerId)
void _dispatchGui(int connectionId, const std::string &line)
void _startStarvationTimer(int connectionId, int playerId)
HandshakeHandler _handshakeHandler
static constexpr int STARVATION_INTERVAL_MS
one food is consumed every 126 time units (1 unit = 1/freq seconds)
double gameTicks() const
Total game ticks elapsed (freq integrated over time). For the win banner.
void onNewConnection(int connectionId)
New socket connected: start its handshake.
void _onAiJoined(int connectionId, int playerId)
Fired on AI promotion: stamp team join, then start its food timer.
void _handleIncantation(int connectionId)
const ServerConfig & _config
void _handleTake(int connectionId, ResourceType resource)
void _handlePin(int connectionId, int playerId)
void _handleLeft(int connectionId)
void _handleLook(int connectionId)
void _handleStu(int connectionId)
void _handleSgt(int connectionId)
void _handleMsz(int connectionId)
void onDisconnect(int connectionId)
Socket dropped: clean up its queue and player.
void _executeNext(int connectionId)
Run the next queued AI command (or go idle if none left).
void dispatch(int connectionId, const std::string &line)
Route one line from a client.
void _handleBct(int connectionId, int x, int y)
std::unordered_map< int, bool > _hasActive
std::optional< GameClock::Stamp > teamJoin(const std::string &team) const
When team's first player joined, or nullopt if it never did.
void _handleForward(int connectionId)
void _dispatchAi(int connectionId, const std::string &line)
void _handleConnectNbr(int connectionId)
void _handleInventory(int connectionId)
std::vector< int > _pendingDisconnects
std::vector< int > drainPendingDisconnects()
Take the list of ids the server should disconnect this cycle.
std::unordered_map< int, std::deque< Ai::Command > > _queues
void _handleTna(int connectionId)
void _handleBroadcast(int connectionId, const std::string &msg)
void _handleRight(int connectionId)
void _handlePpo(int connectionId, int playerId)
void _handleSet(int connectionId, ResourceType resource)
void _handleEject(int connectionId)
Single owner of game frequency and elapsed game time.
Handles the first exchange with a new socket.
Priority queue of timed callbacks. Drives all game timing.
Pure game state - no networking, no scheduling.
Represents the configuration for the server application, described by: