From 379e4bcaf92c61343f7bb0d25e2f6e840d8411d9 Mon Sep 17 00:00:00 2001 From: Mia Date: Fri, 10 Nov 2023 19:06:41 +0100 Subject: [PATCH] Fixed name conflict The TimerClass had a local `SpeedFaktor` variable, which is used by the sync function. This leads to a desync between the local and the global variable and can cause the game speed to be calculated wrong. Example: The game speeds up when it runs with a low framerate (the speed factor is changed to have more accurate calculations, but the sync function still uses the "old" variable) This can be easily repuduced by starting the game in debug mode and typing ``` maxfps 10 ``` in the console to limit the framerate. --- Hurrican/src/Timer.hpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Hurrican/src/Timer.hpp b/Hurrican/src/Timer.hpp index 5c86ffe3..771da940 100644 --- a/Hurrican/src/Timer.hpp +++ b/Hurrican/src/Timer.hpp @@ -26,6 +26,9 @@ // Klassen Deklaration // -------------------------------------------------------------------------------------- +// The Timer class needs the global SpeedFactor variable +extern float SpeedFaktor; + class TimerClass { private: std::int64_t vergangeneFrames; // Vergangene Frames seit Beginn (für Schnitt) @@ -40,7 +43,6 @@ class TimerClass { double vergangeneZeit; // Zeit seit dem vorherigen Frame double aktuelleFramerate; // Aktuelle Framerate int maxFPS; // Maximum Framerate (Framebremse) - float SpeedFaktor; // Faktor, mit dem alle Werte verrechnet werden public: TimerClass(); // Konstruktor @@ -69,7 +71,6 @@ class TimerClass { // Externals // -------------------------------------------------------------------------------------- -extern float SpeedFaktor; extern TimerClass Timer; #endif