Ticket #3309: t3309_cap_expected_simTime_v3_for_replays.patch
File t3309_cap_expected_simTime_v3_for_replays.patch, 2.6 KB (added by , 9 years ago) |
---|
-
source/network/NetTurnManager.cpp
bool CNetTurnManager::WillUpdate(float s 98 98 return false; 99 99 100 100 return true; 101 101 } 102 102 103 bool CNetTurnManager::Update(float simFrameLength, size_t maxTurns )103 bool CNetTurnManager::Update(float simFrameLength, size_t maxTurns, bool isVisualReplay) 104 104 { 105 105 m_DeltaSimTime += simFrameLength; 106 106 107 // If the game runs slower than the game speed dictates, m_DeltaSimTime increases progressively. 108 // The engine will try to fast forward accordingly to catch up. 109 // TODO: We fix it for replays until we are certain that it works for multiplayer too. 110 // There is be no difference between singleplayer and replays. 111 if (isVisualReplay) 112 m_DeltaSimTime = std::min(m_DeltaSimTime, simFrameLength); 113 107 114 // If we haven't reached the next turn yet, do nothing 108 115 if (m_DeltaSimTime < 0) 109 116 return false; 110 117 111 118 NETTURN_LOG((L"Update current=%d ready=%d\n", m_CurrentTurn, m_ReadyTurn)); -
source/network/NetTurnManager.h
public: 76 76 * Otherwise, nothing happens and it returns false. 77 77 * 78 78 * @param simFrameLength Length of the previous frame, in simulation seconds 79 79 * @param maxTurns Maximum number of turns to simulate at once 80 80 */ 81 bool Update(float simFrameLength, size_t maxTurns );81 bool Update(float simFrameLength, size_t maxTurns, bool isVisualReplay = false); 82 82 83 83 /** 84 84 * Advance the simulation by as much as possible. Intended for catching up 85 85 * over a small number of turns when rejoining a multiplayer match. 86 86 * Returns true if it advanced by at least one turn. -
source/ps/Game.cpp
bool CGame::Update(const double deltaRea 381 381 // frame per simulation turn, so let maxTurns be 1. But for fast-forward 382 382 // sim rates we want to allow more, so it's not bounded by framerate, 383 383 // so just use the sim rate itself as the number of turns per frame. 384 384 size_t maxTurns = (size_t)m_SimRate; 385 385 386 if (m_TurnManager->Update(deltaSimTime, maxTurns ))386 if (m_TurnManager->Update(deltaSimTime, maxTurns, m_IsVisualReplay)) 387 387 { 388 388 { 389 389 PROFILE3("gui sim update"); 390 390 g_GUI->SendEventToAll("SimulationUpdate"); 391 391 }