Ticket #3309: t3309_fix_very_fast_forward_v1.patch
File t3309_fix_very_fast_forward_v1.patch, 3.4 KB (added by , 9 years ago) |
---|
-
binaries/data/mods/public/simulation/data/game_speeds.json
22 22 "Speed": 1.0, 23 23 "Default": true 24 24 }, 25 25 { 26 26 "Name": "Fast (1.25x)", 27 "Speed": 1 .2527 "Speed": 10 28 28 }, 29 29 { 30 30 "Name": "Very Fast (1.5x)", 31 "Speed": 1 .531 "Speed": 15 32 32 }, 33 33 { 34 34 "Name": "Insane (2x)", 35 "Speed": 2 .035 "Speed": 20 36 36 } 37 37 ] 38 38 } -
source/network/NetTurnManager.cpp
69 69 // So they can be sending us commands scheduled for n+1, n+2, n+3. 70 70 // So we need a 3-element buffer: 71 71 m_QueuedCommands.resize(COMMAND_DELAY + 1); 72 72 } 73 73 74 void CNetTurnManager::ResetDeltaSimTime() 75 { 76 m_DeltaSimTime = 0; 77 m_ReadyTurn = m_CurrentTurn + 1; 78 } 74 79 void CNetTurnManager::ResetState(u32 newCurrentTurn, u32 newReadyTurn) 75 80 { 76 81 m_CurrentTurn = newCurrentTurn; 77 82 m_ReadyTurn = newReadyTurn; 78 83 m_DeltaSimTime = 0; -
source/network/NetTurnManager.h
60 60 */ 61 61 CNetTurnManager(CSimulation2& simulation, u32 defaultTurnLength, int clientId, IReplayLogger& replay); 62 62 63 63 virtual ~CNetTurnManager() { } 64 64 65 /** 66 * Called when changing the simulation rate. Stops the simulation from trying to keep up with 67 * too high fast forward speeds, so that the simulation rate will be changed immediately. 68 */ 69 void ResetDeltaSimTime(); 70 65 71 void ResetState(u32 newCurrentTurn, u32 newReadyTurn); 66 72 67 73 /** 68 74 * Set the current user's player ID, which will be added into command messages. 69 75 */ -
source/ps/Game.cpp
256 256 RegMemFun(this, &CGame::LoadReplayData, L"Loading replay data", 1000); 257 257 258 258 LDR_EndRegistering(); 259 259 } 260 260 261 void CGame::SetSimRate(float simRate) 262 { 263 if (isfinite(simRate)) 264 { 265 m_SimRate = std::max(simRate, 0.0f); 266 m_TurnManager->ResetDeltaSimTime(); 267 } 268 } 269 261 270 int CGame::LoadInitialState() 262 271 { 263 272 ENSURE(m_IsSavedGame); 264 273 ENSURE(!m_InitialSavedState.empty()); 265 274 -
source/ps/Game.h
137 137 * @return CSimulation2 * the value of m_Simulation2. 138 138 **/ 139 139 inline CSimulation2 *GetSimulation2() 140 140 { return m_Simulation2; } 141 141 142 143 inline float GetSimRate() 144 { return m_SimRate; } 145 142 146 /** 143 147 * Set the simulation scale multiplier. 144 148 * 145 149 * @param simRate Float value to set m_SimRate to. 146 150 * Because m_SimRate is also used to 147 151 * scale TimeSinceLastFrame it must be 148 152 * clamped to 0.0f. 149 153 **/ 150 inline void SetSimRate(float simRate) 151 { if (isfinite(simRate)) m_SimRate = std::max(simRate, 0.0f); } 152 153 inline float GetSimRate() 154 { return m_SimRate; } 154 void SetSimRate(float simRate); 155 155 156 156 /** 157 157 * Replace the current turn manager. 158 158 * This class will take ownership of the pointer. 159 159 */