Ticket #3309: t3309_cap_expected_simTime_v3_for_replays.patch

File t3309_cap_expected_simTime_v3_for_replays.patch, 2.6 KB (added by elexis, 9 years ago)

._.

  • source/network/NetTurnManager.cpp

    bool CNetTurnManager::WillUpdate(float s  
    9898        return false;
    9999
    100100    return true;
    101101}
    102102
    103 bool CNetTurnManager::Update(float simFrameLength, size_t maxTurns)
     103bool CNetTurnManager::Update(float simFrameLength, size_t maxTurns, bool isVisualReplay)
    104104{
    105105    m_DeltaSimTime += simFrameLength;
    106106
     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
    107114    // If we haven't reached the next turn yet, do nothing
    108115    if (m_DeltaSimTime < 0)
    109116        return false;
    110117
    111118    NETTURN_LOG((L"Update current=%d ready=%d\n", m_CurrentTurn, m_ReadyTurn));
  • source/network/NetTurnManager.h

    public:  
    7676     * Otherwise, nothing happens and it returns false.
    7777     *
    7878     * @param simFrameLength Length of the previous frame, in simulation seconds
    7979     * @param maxTurns Maximum number of turns to simulate at once
    8080     */
    81     bool Update(float simFrameLength, size_t maxTurns);
     81    bool Update(float simFrameLength, size_t maxTurns, bool isVisualReplay = false);
    8282
    8383    /**
    8484     * Advance the simulation by as much as possible. Intended for catching up
    8585     * over a small number of turns when rejoining a multiplayer match.
    8686     * Returns true if it advanced by at least one turn.
  • source/ps/Game.cpp

    bool CGame::Update(const double deltaRea  
    381381        // frame per simulation turn, so let maxTurns be 1. But for fast-forward
    382382        // sim rates we want to allow more, so it's not bounded by framerate,
    383383        // so just use the sim rate itself as the number of turns per frame.
    384384        size_t maxTurns = (size_t)m_SimRate;
    385385
    386         if (m_TurnManager->Update(deltaSimTime, maxTurns))
     386        if (m_TurnManager->Update(deltaSimTime, maxTurns, m_IsVisualReplay))
    387387        {
    388388            {
    389389                PROFILE3("gui sim update");
    390390                g_GUI->SendEventToAll("SimulationUpdate");
    391391            }