Line data Source code
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 : #include "precompiled.h" 19 : 20 : #include "LocalTurnManager.h" 21 : 22 : #include "lib/debug.h" 23 : #include "simulation2/system/TurnManager.h" 24 : 25 : #include <js/RootingAPI.h> 26 : 27 : class CSimulation2; 28 : class IReplayLogger; 29 : 30 3 : CLocalTurnManager::CLocalTurnManager(CSimulation2& simulation, IReplayLogger& replay) 31 3 : : CTurnManager(simulation, DEFAULT_TURN_LENGTH, COMMAND_DELAY_SP, 0, replay) 32 : { 33 3 : } 34 : 35 0 : void CLocalTurnManager::PostCommand(player_id_t playerid, JS::HandleValue data) 36 : { 37 0 : AddCommand(m_ClientId, playerid, data, m_CurrentTurn + m_CommandDelay); 38 0 : } 39 : 40 0 : void CLocalTurnManager::PostCommand(JS::HandleValue data) 41 : { 42 0 : AddCommand(m_ClientId, m_PlayerId, data, m_CurrentTurn + m_CommandDelay); 43 0 : } 44 : 45 180 : void CLocalTurnManager::NotifyFinishedOwnCommands(turn_id_t turn) 46 : { 47 180 : FinishedAllCommands(turn, m_TurnLength); 48 180 : } 49 : 50 180 : void CLocalTurnManager::NotifyFinishedUpdate(turn_id_t /*turn*/, const UpdateCallback&) 51 : { 52 : #if 0 // this hurts performance and is only useful for verifying log replays 53 : std::string hash; 54 : { 55 : PROFILE3("state hash check"); 56 : ENSURE(m_Simulation2.ComputeStateHash(hash)); 57 : } 58 : m_Replay.Hash(hash); 59 : #endif 60 180 : } 61 : 62 0 : void CLocalTurnManager::OnSimulationMessage(CSimulationMessage*) 63 : { 64 0 : debug_warn(L"This should never be called"); 65 0 : }