From bda602f4b0a214d860653754df8c616c081df347 Mon Sep 17 00:00:00 2001 From: Bouke Haarsma Date: Tue, 27 Sep 2022 17:34:55 +0200 Subject: [PATCH] Fix: reduce framerate overhead on train ticks Tick() is a noop for all but front-engine / crashed vehicles. Starting a framerate is rather cheap, but not free, and introduces a lot of overhead for such close loops. --- src/train_cmd.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/train_cmd.cpp b/src/train_cmd.cpp index 983b5ccd1c..e84ac6b8ea 100644 --- a/src/train_cmd.cpp +++ b/src/train_cmd.cpp @@ -3910,11 +3910,11 @@ Money Train::GetRunningCost() const */ bool Train::Tick() { - PerformanceAccumulator framerate(PFE_GL_TRAINS); - this->tick_counter++; if (this->IsFrontEngine()) { + PerformanceAccumulator framerate(PFE_GL_TRAINS); + if (!(this->vehstatus & VS_STOPPED) || this->cur_speed > 0) this->running_ticks++; this->current_order_time++;