From 64b475b3909b4b65ca8f7b94728b840ba54db7a2 Mon Sep 17 00:00:00 2001 From: wraitii Date: Thu, 6 May 2021 16:49:34 +0000 Subject: [PATCH] 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. --- source/ps/Game.cpp | 5 ----- source/ps/Profile.h | 4 ++-- source/simulation2/system/TurnManager.cpp | 20 ++++---------------- source/simulation2/system/TurnManager.h | 6 ------ 4 files changed, 6 insertions(+), 29 deletions(-) diff --git a/source/ps/Game.cpp b/source/ps/Game.cpp index d095da7699..2adf14198a 100644 --- a/source/ps/Game.cpp +++ b/source/ps/Game.cpp @@ -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, diff --git a/source/ps/Profile.h b/source/ps/Profile.h index 3779b0e779..84eb58951c 100644 --- a/source/ps/Profile.h +++ b/source/ps/Profile.h @@ -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; diff --git a/source/simulation2/system/TurnManager.cpp b/source/simulation2/system/TurnManager.cpp index b068468223..5cf67f81ae 100644 --- a/source/simulation2/system/TurnManager.cpp +++ b/source/simulation2/system/TurnManager.cpp @@ -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 diff --git a/source/simulation2/system/TurnManager.h b/source/simulation2/system/TurnManager.h index 3433f52832..1d807a1dfd 100644 --- a/source/simulation2/system/TurnManager.h +++ b/source/simulation2/system/TurnManager.h @@ -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