diff --git a/src/game/g_window.pas b/src/game/g_window.pas
index ef1d362bd77362b5d5045ea3ffcea44b9ed24da7..33fc80c2969914e7f43c22d84edbc8c8d9ba55fb 100644 (file)
--- a/src/game/g_window.pas
+++ b/src/game/g_window.pas
wLoadingProgress: Boolean = False;
wLoadingQuit: Boolean = False;
{wWinPause: Byte = 0;}
+ ticksOverflow: Int64 = -1;
+ lastTicks: Uint32 = 0; // to detect overflow
const
// TODO: move this to a separate file
end;
function GetTimer(): Int64;
+var
+ t: Uint32;
+ tt: Int64;
begin
- Result := SDL_GetTicks() * 1000; // TODO: do we really need microseconds here?
+ t := SDL_GetTicks() {* 1000}; // TODO: do we really need microseconds here? k8: NOPE!
+ if ticksOverflow = -1 then
+ begin
+ ticksOverflow := 0;
+ lastTicks := t;
+ end
+ else
+ begin
+ if lastTicks > t then
+ begin
+ // overflow, increment overflow ;-)
+ ticksOverflow := ticksOverflow+(Int64($ffffffff)+Int64(1));
+ tt := (Int64($ffffffff)+Int64(1))+Int64(t);
+ t := Uint32(tt-lastTicks);
+ end;
+ end;
+ lastTicks := t;
+ result := ticksOverflow+Int64(t);
end;
procedure ResetTimer();
if wNeedTimeReset then
begin
- Time_Delta := 27777;
+ Time_Delta := (27777 div 1000);
wNeedTimeReset := False;
end;
- t := Time_Delta div 27777;
+ t := Time_Delta div (27777 div 1000);
if t > 0 then
begin
flag := True;
// Âðåìÿ ïðåäûäóùåãî îáíîâëåíèÿ:
if flag then
begin
- Time_Old := Time - (Time_Delta mod 27777);
+ Time_Old := Time - (Time_Delta mod (27777 div 1000));
if (not wMinimized) then
begin
Draw();