X-Git-Url: http://deadsoftware.ru/gitweb?a=blobdiff_plain;f=src%2Fgame%2Fg_window.pas;h=33fc80c2969914e7f43c22d84edbc8c8d9ba55fb;hb=cd0c726308c335c662384b41d9e23af0457290f7;hp=ef1d362bd77362b5d5045ea3ffcea44b9ed24da7;hpb=3bedb8ac6ca3fe3a45921bb840b7b6be3171d6a9;p=d2df-sdl.git diff --git a/src/game/g_window.pas b/src/game/g_window.pas index ef1d362..33fc80c 100644 --- a/src/game/g_window.pas +++ b/src/game/g_window.pas @@ -42,6 +42,8 @@ var 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 @@ -424,8 +426,28 @@ begin 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(); @@ -506,11 +528,11 @@ begin 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; @@ -542,7 +564,7 @@ begin // Âðåìÿ ïðåäûäóùåãî îáíîâëåíèÿ: 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();