Line data Source code
1 : /* Copyright (C) 2017 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_NETCLIENTTURNMANAGER
19 : #define INCLUDED_NETCLIENTTURNMANAGER
20 :
21 : #include "simulation2/system/TurnManager.h"
22 : #include "NetMessage.h"
23 :
24 : class CNetClient;
25 :
26 : /**
27 : * Implementation of CTurnManager for network clients.
28 : */
29 0 : class CNetClientTurnManager : public CTurnManager
30 : {
31 : NONCOPYABLE(CNetClientTurnManager);
32 : public:
33 : CNetClientTurnManager(CSimulation2& simulation, CNetClient& client, int clientId, IReplayLogger& replay);
34 :
35 : void OnSimulationMessage(CSimulationMessage* msg) override;
36 :
37 : void PostCommand(JS::HandleValue data) override;
38 :
39 : /**
40 : * Notify the server that all commands are sent to prepare the connection for termination.
41 : */
42 : void OnDestroyConnection();
43 :
44 : void OnSyncError(u32 turn, const CStr& expectedHash, const std::vector<CSyncErrorMessage::S_m_PlayerNames>& playerNames);
45 :
46 : private:
47 : void NotifyFinishedOwnCommands(u32 turn) override;
48 :
49 : void NotifyFinishedUpdate(u32 turn) override;
50 :
51 : CNetClient& m_NetClient;
52 : };
53 :
54 : #endif // INCLUDED_NETCLIENTTURNMANAGER
|