1
1
forked from 0ad/0ad

Fix Profiler1 "time per turn".

Actually call Turn() when a turn is processed.

Fixes #6144

Differential Revision: https://code.wildfiregames.com/D3885
This was SVN commit r25394.
This commit is contained in:
wraitii 2021-05-06 16:49:34 +00:00
parent e0800bc092
commit 64b475b390
4 changed files with 6 additions and 29 deletions

View File

@ -393,11 +393,6 @@ void CGame::Update(const double deltaRealTime, bool doInterpolate)
if (deltaSimTime)
{
// To avoid confusing the profiler, we need to trigger the new turn
// while we're not nested inside any PROFILE blocks
if (m_TurnManager->WillUpdate(deltaSimTime))
g_Profiler.Turn();
// At the normal sim rate, we currently want to render at least one
// frame per simulation turn, so let maxTurns be 1. But for fast-forward
// sim rates we want to allow more, so it's not bounded by framerate,

View File

@ -1,4 +1,4 @@
/* Copyright (C) 2020 Wildfire Games.
/* Copyright (C) 2021 Wildfire Games.
* This file is part of 0 A.D.
*
* 0 A.D. is free software: you can redistribute it and/or modify
@ -31,7 +31,7 @@
#define PROFILE_AMORTIZE_FRAMES 30
#define PROFILE_AMORTIZE_TURNS 1
#define PROFILE_AMORTIZE_TURNS 5
class CProfileManager;
class CProfileNodeTable;

View File

@ -62,22 +62,6 @@ void CTurnManager::SetPlayerID(int playerId)
m_PlayerId = playerId;
}
bool CTurnManager::WillUpdate(float simFrameLength) const
{
// Keep this in sync with the return value of Update()
if (m_CurrentTurn > m_FinalTurn)
return false;
if (m_DeltaSimTime + simFrameLength < 0)
return false;
if (m_ReadyTurn <= m_CurrentTurn)
return false;
return true;
}
bool CTurnManager::Update(float simFrameLength, size_t maxTurns)
{
if (m_CurrentTurn > m_FinalTurn)
@ -124,6 +108,10 @@ bool CTurnManager::Update(float simFrameLength, size_t maxTurns)
if (m_ReadyTurn <= m_CurrentTurn && m_CommandDelay > 1)
break;
// To avoid confusing the profiler, we need to trigger the new turn
// while we're not nested inside any PROFILE blocks
g_Profiler.Turn();
NotifyFinishedOwnCommands(m_CurrentTurn + m_CommandDelay);
// Increase now, so Update can send new commands for a subsequent turn

View File

@ -111,12 +111,6 @@ public:
*/
bool UpdateFastForward();
/**
* Returns whether Update(simFrameLength, ...) will process at least one new turn.
* @param simFrameLength Length of the previous frame, in simulation seconds
*/
bool WillUpdate(float simFrameLength) const;
/**
* Advance the graphics by a certain time.
* @param simFrameLength Length of the previous frame, in simulation seconds