Skip to content

Commit

Permalink
Fixed name conflict
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
Mia75owo authored and drfiemost committed Nov 12, 2023
1 parent 14eccc4 commit 379e4bc
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Hurrican/src/Timer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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
Expand Down Expand Up @@ -69,7 +71,6 @@ class TimerClass {
// Externals
// --------------------------------------------------------------------------------------

extern float SpeedFaktor;
extern TimerClass Timer;

#endif

0 comments on commit 379e4bc

Please sign in to comment.