hedgewars/hwengine.pas
changeset 7392 bc3306c59a08
parent 7386 e82a076df09b
child 7442 9bb6abdb5675
--- a/hedgewars/hwengine.pas	Fri Jul 13 16:35:42 2012 +0400
+++ b/hedgewars/hwengine.pas	Fri Jul 13 16:39:20 2012 +0400
@@ -82,15 +82,15 @@
             end;
         gsConfirm, gsGame:
             begin
+            DrawWorld(Lag);
             DoGameTick(Lag);
             ProcessVisualGears(Lag);
-            DrawWorld(Lag);
             end;
         gsChat:
             begin
+            DrawWorld(Lag);
             DoGameTick(Lag);
             ProcessVisualGears(Lag);
-            DrawWorld(Lag);
             end;
         gsExit:
             begin
@@ -273,27 +273,32 @@
 
 {$IFDEF USE_VIDEO_RECORDING}
 procedure RecorderMainLoop;
-var CurrTime, PrevTime: LongInt;
+var oldGameTicks, oldRealTicks, newGameTicks, newRealTicks: LongInt;
 begin
     if not BeginVideoRecording() then
         exit;
     DoTimer(0); // gsLandGen -> gsStart
     DoTimer(0); // gsStart -> gsGame
 
-    CurrTime:= LoadNextCameraPosition();
+    if not LoadNextCameraPosition(newRealTicks, newGameTicks) then
+        exit;
     fastScrolling:= true;
-    DoTimer(CurrTime);
+    DoGameTick(newGameTicks);
     fastScrolling:= false;
-    while true do
+    oldRealTicks:= 0;
+    oldGameTicks:= newGameTicks;
+
+    while LoadNextCameraPosition(newRealTicks, newGameTicks) do
     begin
+        IPCCheckSock();
+        DoGameTick(newGameTicks - oldGameTicks);
+        if GameState = gsExit then
+            break;
+        ProcessVisualGears(newRealTicks - oldRealTicks);
+        DrawWorld(newRealTicks - oldRealTicks);
         EncodeFrame();
-        PrevTime:= CurrTime;
-        CurrTime:= LoadNextCameraPosition();
-        if CurrTime = -1 then
-            break;
-        if DoTimer(CurrTime - PrevTime) then
-            break;
-        IPCCheckSock();
+        oldRealTicks:= newRealTicks;
+        oldGameTicks:= newGameTicks;
     end;
     StopVideoRecording();
 end;