Ticket #4095: rename_CNetTurnManager.patch
File rename_CNetTurnManager.patch, 9.0 KB (added by , 8 years ago) |
---|
-
source/network/NetTurnManager.cpp
58 58 return str.str(); 59 59 } 60 60 61 C NetTurnManager::CNetTurnManager(CSimulation2& simulation, u32 defaultTurnLength, int clientId, IReplayLogger& replay) :61 CTurnManager::CTurnManager(CSimulation2& simulation, u32 defaultTurnLength, int clientId, IReplayLogger& replay) : 62 62 m_Simulation2(simulation), m_CurrentTurn(0), m_ReadyTurn(1), m_TurnLength(defaultTurnLength), m_DeltaSimTime(0), 63 63 m_PlayerId(-1), m_ClientId(clientId), m_HasSyncError(false), m_Replay(replay), 64 64 m_TimeWarpNumTurns(0), m_FinalTurn(std::numeric_limits<u32>::max()) … … 72 72 m_QueuedCommands.resize(COMMAND_DELAY + 1); 73 73 } 74 74 75 void C NetTurnManager::ResetState(u32 newCurrentTurn, u32 newReadyTurn)75 void CTurnManager::ResetState(u32 newCurrentTurn, u32 newReadyTurn) 76 76 { 77 77 m_CurrentTurn = newCurrentTurn; 78 78 m_ReadyTurn = newReadyTurn; … … 82 82 m_QueuedCommands.resize(queuedCommandsSize); 83 83 } 84 84 85 void C NetTurnManager::SetPlayerID(int playerId)85 void CTurnManager::SetPlayerID(int playerId) 86 86 { 87 87 m_PlayerId = playerId; 88 88 } 89 89 90 bool C NetTurnManager::WillUpdate(float simFrameLength)90 bool CTurnManager::WillUpdate(float simFrameLength) 91 91 { 92 92 // Keep this in sync with the return value of Update() 93 93 … … 103 103 return true; 104 104 } 105 105 106 bool C NetTurnManager::Update(float simFrameLength, size_t maxTurns)106 bool CTurnManager::Update(float simFrameLength, size_t maxTurns) 107 107 { 108 108 if (m_CurrentTurn > m_FinalTurn) 109 109 return false; … … 191 191 return true; 192 192 } 193 193 194 bool C NetTurnManager::UpdateFastForward()194 bool CTurnManager::UpdateFastForward() 195 195 { 196 196 m_DeltaSimTime = 0; 197 197 … … 229 229 return true; 230 230 } 231 231 232 void C NetTurnManager::OnSyncError(u32 turn, const CStr& expectedHash, std::vector<CSyncErrorMessage::S_m_PlayerNames>& playerNames)232 void CTurnManager::OnSyncError(u32 turn, const CStr& expectedHash, std::vector<CSyncErrorMessage::S_m_PlayerNames>& playerNames) 233 233 { 234 234 NETTURN_LOG((L"OnSyncError(%d, %hs)\n", turn, Hexify(expectedHash).c_str())); 235 235 … … 252 252 DisplayOOSError(turn, hash, expectedHashHex, false, &playerNames, &path); 253 253 } 254 254 255 void C NetTurnManager::DisplayOOSError(u32 turn, const CStr& hash, const CStr& expectedHash, bool isReplay, std::vector<CSyncErrorMessage::S_m_PlayerNames>* playerNames = NULL, OsPath* path = NULL)255 void CTurnManager::DisplayOOSError(u32 turn, const CStr& hash, const CStr& expectedHash, bool isReplay, std::vector<CSyncErrorMessage::S_m_PlayerNames>* playerNames = NULL, OsPath* path = NULL) 256 256 { 257 257 m_HasSyncError = true; 258 258 … … 277 277 g_GUI->DisplayMessageBox(600, 350, L"Sync error", wstring_from_utf8(msg.str())); 278 278 } 279 279 280 void C NetTurnManager::Interpolate(float simFrameLength, float realFrameLength)280 void CTurnManager::Interpolate(float simFrameLength, float realFrameLength) 281 281 { 282 282 // TODO: using m_TurnLength might be a bit dodgy when length changes - maybe 283 283 // we need to save the previous turn length? … … 291 291 m_Simulation2.Interpolate(simFrameLength, offset, realFrameLength); 292 292 } 293 293 294 void C NetTurnManager::AddCommand(int client, int player, JS::HandleValue data, u32 turn)294 void CTurnManager::AddCommand(int client, int player, JS::HandleValue data, u32 turn) 295 295 { 296 296 NETTURN_LOG((L"AddCommand(client=%d player=%d turn=%d)\n", client, player, turn)); 297 297 … … 305 305 m_QueuedCommands[turn - (m_CurrentTurn+1)][client].emplace_back(player, m_Simulation2.GetScriptInterface().GetContext(), data); 306 306 } 307 307 308 void C NetTurnManager::FinishedAllCommands(u32 turn, u32 turnLength)308 void CTurnManager::FinishedAllCommands(u32 turn, u32 turnLength) 309 309 { 310 310 NETTURN_LOG((L"FinishedAllCommands(%d, %d)\n", turn, turnLength)); 311 311 … … 314 314 m_TurnLength = turnLength; 315 315 } 316 316 317 bool C NetTurnManager::TurnNeedsFullHash(u32 turn)317 bool CTurnManager::TurnNeedsFullHash(u32 turn) 318 318 { 319 319 // Check immediately for errors caused by e.g. inconsistent game versions 320 320 // (The hash is computed after the first sim update, so we start at turn == 1) … … 330 330 return false; 331 331 } 332 332 333 void C NetTurnManager::EnableTimeWarpRecording(size_t numTurns)333 void CTurnManager::EnableTimeWarpRecording(size_t numTurns) 334 334 { 335 335 m_TimeWarpStates.clear(); 336 336 m_TimeWarpNumTurns = numTurns; 337 337 } 338 338 339 void C NetTurnManager::RewindTimeWarp()339 void CTurnManager::RewindTimeWarp() 340 340 { 341 341 if (m_TimeWarpStates.empty()) 342 342 return; … … 352 352 ResetState(0, 1); 353 353 } 354 354 355 void C NetTurnManager::QuickSave()355 void CTurnManager::QuickSave() 356 356 { 357 357 TIMER(L"QuickSave"); 358 358 … … 373 373 374 374 } 375 375 376 void C NetTurnManager::QuickLoad()376 void CTurnManager::QuickLoad() 377 377 { 378 378 TIMER(L"QuickLoad"); 379 379 … … 401 401 402 402 403 403 CNetClientTurnManager::CNetClientTurnManager(CSimulation2& simulation, CNetClient& client, int clientId, IReplayLogger& replay) : 404 C NetTurnManager(simulation, DEFAULT_TURN_LENGTH_MP, clientId, replay), m_NetClient(client)404 CTurnManager(simulation, DEFAULT_TURN_LENGTH_MP, clientId, replay), m_NetClient(client) 405 405 { 406 406 } 407 407 … … 471 471 472 472 473 473 CNetLocalTurnManager::CNetLocalTurnManager(CSimulation2& simulation, IReplayLogger& replay) : 474 C NetTurnManager(simulation, DEFAULT_TURN_LENGTH_SP, 0, replay)474 CTurnManager(simulation, DEFAULT_TURN_LENGTH_SP, 0, replay) 475 475 { 476 476 } 477 477 -
source/network/NetTurnManager.h
36 36 class IReplayLogger; 37 37 38 38 /* 39 * This file deals with the logic of the networkturn system. The basic idea is as in39 * This file deals with the logic of the turn system. The basic idea is as in 40 40 * http://www.gamasutra.com/view/feature/3094/1500_archers_on_a_288_network_.php?print=1 41 41 * 42 42 * Each player performs the simulation for turn N. … … 55 55 /** 56 56 * Common network turn system (used by clients and offline games). 57 57 */ 58 class C NetTurnManager58 class CTurnManager 59 59 { 60 NONCOPYABLE(C NetTurnManager);60 NONCOPYABLE(CTurnManager); 61 61 public: 62 62 /** 63 63 * Construct for a given network session ID. 64 64 */ 65 C NetTurnManager(CSimulation2& simulation, u32 defaultTurnLength, int clientId, IReplayLogger& replay);65 CTurnManager(CSimulation2& simulation, u32 defaultTurnLength, int clientId, IReplayLogger& replay); 66 66 67 virtual ~C NetTurnManager() { }67 virtual ~CTurnManager() { } 68 68 69 69 void ResetState(u32 newCurrentTurn, u32 newReadyTurn); 70 70 … … 205 205 206 206 207 207 /** 208 * Implementation of C NetTurnManager for network clients.208 * Implementation of CTurnManager for network clients. 209 209 */ 210 class CNetClientTurnManager : public C NetTurnManager210 class CNetClientTurnManager : public CTurnManager 211 211 { 212 212 public: 213 213 CNetClientTurnManager(CSimulation2& simulation, CNetClient& client, int clientId, IReplayLogger& replay); … … 230 230 }; 231 231 232 232 /** 233 * Implementation of C NetTurnManager for offline games.233 * Implementation of CTurnManager for offline games. 234 234 */ 235 class CNetLocalTurnManager : public C NetTurnManager235 class CNetLocalTurnManager : public CTurnManager 236 236 { 237 237 public: 238 238 CNetLocalTurnManager(CSimulation2& simulation, IReplayLogger& replay); … … 250 250 251 251 252 252 /** 253 * Implementation of C NetTurnManager for replay games.253 * Implementation of CTurnManager for replay games. 254 254 */ 255 255 class CNetReplayTurnManager : public CNetLocalTurnManager 256 256 { -
source/network/tests/test_Net.h
310 310 wait(clients, 100); 311 311 312 312 // (This SetTurnLength thing doesn't actually detect errors unless you change 313 // C NetTurnManager::TurnNeedsFullHash to always return true)313 // CTurnManager::TurnNeedsFullHash to always return true) 314 314 315 315 { 316 316 JS::RootedValue cmd(cx); -
source/ps/Game.cpp
110 110 delete m_ReplayStream; 111 111 } 112 112 113 void CGame::SetTurnManager(C NetTurnManager* turnManager)113 void CGame::SetTurnManager(CTurnManager* turnManager) 114 114 { 115 115 if (m_TurnManager) 116 116 delete m_TurnManager; -
source/ps/Game.h
27 27 class CWorld; 28 28 class CSimulation2; 29 29 class CGameView; 30 class C NetTurnManager;30 class CTurnManager; 31 31 class IReplayLogger; 32 32 struct CColor; 33 33 … … 77 77 */ 78 78 player_id_t m_ViewedPlayerID; 79 79 80 C NetTurnManager* m_TurnManager;80 CTurnManager* m_TurnManager; 81 81 82 82 public: 83 83 CGame(bool disableGraphics = false, bool replayLog = true); … … 185 185 * Replace the current turn manager. 186 186 * This class will take ownership of the pointer. 187 187 */ 188 void SetTurnManager(C NetTurnManager* turnManager);188 void SetTurnManager(CTurnManager* turnManager); 189 189 190 C NetTurnManager* GetTurnManager() const190 CTurnManager* GetTurnManager() const 191 191 { return m_TurnManager; } 192 192 193 193 IReplayLogger& GetReplayLogger() const