Pyrogenesis HEAD
Pyrogenesis, a RTS Engine
LocalTurnManager.h
Go to the documentation of this file.
1/* Copyright (C) 2026 Wildfire Games.
2 * This file is part of 0 A.D.
3 *
4 * 0 A.D. is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 2 of the License, or
7 * (at your option) any later version.
8 *
9 * 0 A.D. is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
13 *
14 * You should have received a copy of the GNU General Public License
15 * along with 0 A.D. If not, see <http://www.gnu.org/licenses/>.
16 */
17
18#ifndef INCLUDED_LOCALTURNMANAGER
19#define INCLUDED_LOCALTURNMANAGER
20
23
24#include <js/TypeDecls.h>
25
26class CSimulation2;
27class IReplayLogger;
28
29/**
30 * Implementation of CTurnManager for offline games.
31 */
33{
34public:
35 CLocalTurnManager(CSimulation2& simulation, IReplayLogger& replay);
36
37 void OnSimulationMessage(CSimulationMessage* msg) override;
38
39 void PostCommand(JS::HandleValue data) override;
40 void PostCommand(player_id_t playerid, JS::HandleValue data);
41
42protected:
43 void NotifyFinishedOwnCommands(turn_id_t turn) override;
44
45 void NotifyFinishedUpdate(turn_id_t turn, const UpdateCallback& sendEventToAll) override;
46};
47
48#endif // INCLUDED_LOCALTURNMANAGER
int32_t player_id_t
valid player IDs are non-negative (see ICmpOwnership)
Definition: Player.h:26
std::int32_t turn_id_t
At 1000 turns/second, a 32-bit counter would overflow in ~49 days.
Definition: SimulationCommand.h:31
Implementation of CTurnManager for offline games.
Definition: LocalTurnManager.h:33
void PostCommand(JS::HandleValue data) override
Called by simulation code, to add a new command to be distributed to all clients and executed soon.
Definition: LocalTurnManager.cpp:40
void NotifyFinishedOwnCommands(turn_id_t turn) override
Called when this client has finished sending all its commands scheduled for the given turn.
Definition: LocalTurnManager.cpp:45
CLocalTurnManager(CSimulation2 &simulation, IReplayLogger &replay)
Definition: LocalTurnManager.cpp:30
void OnSimulationMessage(CSimulationMessage *msg) override
Called by networking code when a simulation message is received.
Definition: LocalTurnManager.cpp:62
void NotifyFinishedUpdate(turn_id_t turn, const UpdateCallback &sendEventToAll) override
Called when this client has finished a simulation update.
Definition: LocalTurnManager.cpp:50
Public API for simulation system.
Definition: Simulation2.h:57
Special message type for simulation commands.
Definition: NetMessage.h:123
Common turn system (used by clients and offline games).
Definition: TurnManager.h:88
std::function< void(const std::string &, const std::optional< JS::HandleValueArray >)> UpdateCallback
Definition: TurnManager.h:92
Replay log recorder interface.
Definition: Replay.h:40