make stats-only mode work headless. also skip a few things to save time/memory.
authornemo
Wed, 14 Nov 2012 22:27:05 -0500
changeset 8027 e5ba3dd12531
parent 8024 1d5baba66cb6
child 8030 165aeaaaf445
make stats-only mode work headless. also skip a few things to save time/memory.
hedgewars/hwengine.pas
hedgewars/uCaptions.pas
hedgewars/uGame.pas
hedgewars/uLandTexture.pas
hedgewars/uStore.pas
hedgewars/uTextures.pas
hedgewars/uVariables.pas
--- a/hedgewars/hwengine.pas	Wed Nov 14 22:08:40 2012 -0500
+++ b/hedgewars/hwengine.pas	Wed Nov 14 22:27:05 2012 -0500
@@ -90,15 +90,15 @@
             end;
         gsConfirm, gsGame:
             begin
-            DrawWorld(Lag);
+            if not cOnlyStats then DrawWorld(Lag);
             DoGameTick(Lag);
-            ProcessVisualGears(Lag);
+            if not cOnlyStats then ProcessVisualGears(Lag);
             end;
         gsChat:
             begin
-            DrawWorld(Lag);
+            if not cOnlyStats then DrawWorld(Lag);
             DoGameTick(Lag);
-            ProcessVisualGears(Lag);
+            if not cOnlyStats then ProcessVisualGears(Lag);
             end;
         gsExit:
             begin
--- a/hedgewars/uCaptions.pas	Wed Nov 14 22:08:40 2012 -0500
+++ b/hedgewars/uCaptions.pas	Wed Nov 14 22:27:05 2012 -0500
@@ -44,6 +44,7 @@
 
 procedure AddCaption(s: shortstring; Color: Longword; Group: TCapGroup);
 begin
+    if cOnlyStats then exit;
     if Captions[Group].Text <> s then
         begin
         FreeTexture(Captions[Group].Tex);
--- a/hedgewars/uGame.pas	Wed Nov 14 22:08:40 2012 -0500
+++ b/hedgewars/uGame.pas	Wed Nov 14 22:27:05 2012 -0500
@@ -50,17 +50,16 @@
 
     if (GameType = gmtDemo) then 
         if isSpeed then
-        begin
+            begin
             i:= RealTicks-SpeedStart;
             if i < 2000 then Lag:= Lag*5
             else if i < 4000 then Lag:= Lag*10
             else if i < 6000 then Lag:= Lag*20
             else if i < 8000 then Lag:= Lag*40
             else Lag:= Lag*80;
-        end
-        else
-            if cOnlyStats then
-                Lag:= High(LongInt);
+            end
+        else if cOnlyStats then
+            Lag:= High(LongInt)
     end;
 PlayNextVoice;
 i:= 1;
--- a/hedgewars/uLandTexture.pas	Wed Nov 14 22:08:40 2012 -0500
+++ b/hedgewars/uLandTexture.pas	Wed Nov 14 22:27:05 2012 -0500
@@ -66,6 +66,7 @@
 procedure UpdateLandTexture(X, Width, Y, Height: LongInt; landAdded: boolean);
 var tx, ty: Longword;
 begin
+    if cOnlyStats then exit;
     if (Width <= 0) or (Height <= 0) then
         exit;
     TryDo((X >= 0) and (X < LAND_WIDTH), 'UpdateLandTexture: wrong X parameter', true);
@@ -93,6 +94,7 @@
 var x, y, ty, tx, lx, ly : LongWord;
     isEmpty: boolean;
 begin
+    if cOnlyStats then exit;
 (*
 if LandTextures[0, 0].tex = nil then
     for x:= 0 to LANDTEXARW -1 do
--- a/hedgewars/uStore.pas	Wed Nov 14 22:08:40 2012 -0500
+++ b/hedgewars/uStore.pas	Wed Nov 14 22:27:05 2012 -0500
@@ -146,6 +146,7 @@
     texsurf, flagsurf, iconsurf: PSDL_Surface;
     foundBot: boolean;
 begin
+    if cOnlyStats then exit;
 r.x:= 0;
 r.y:= 0;
 drY:= - 4;
@@ -873,6 +874,7 @@
 var r: TSDL_Rect;
     texsurf: PSDL_Surface;
 begin
+    if cOnlyStats then exit;
     if Step = 0 then
     begin
         WriteToConsole(msgLoading + 'progress sprite: ');
@@ -1127,10 +1129,14 @@
     {$IFNDEF DARWIN}ico: PSDL_Surface;{$ENDIF}
     {$IFDEF SDL13}x, y: LongInt;{$ENDIF}
 begin
+    if cOnlyStats then
+        begin
+        MaxTextureSize:= 1024;
+        exit
+        end;
     if Length(s) = 0 then
-        cFullScreen:= (not cFullScreen)
-    else
-        cFullScreen:= s = '1';
+         cFullScreen:= (not cFullScreen)
+    else cFullScreen:= s = '1';
 
     AddFileLog('Preparing to change video parameters...');
 {$IFDEF SDL13}
--- a/hedgewars/uTextures.pas	Wed Nov 14 22:08:40 2012 -0500
+++ b/hedgewars/uTextures.pas	Wed Nov 14 22:27:05 2012 -0500
@@ -126,6 +126,7 @@
     tmpp: pointer;
     fromP4, toP4: PLongWordArray;
 begin
+if cOnlyStats then exit(nil);
 new(Surface2Tex);
 Surface2Tex^.PrevTexture:= nil;
 Surface2Tex^.NextTexture:= nil;
--- a/hedgewars/uVariables.pas	Wed Nov 14 22:08:40 2012 -0500
+++ b/hedgewars/uVariables.pas	Wed Nov 14 22:27:05 2012 -0500
@@ -2562,6 +2562,7 @@
     GrayScale       := false;
     PathPrefix      := './';
     GameType        := gmtLocal;
+    cOnlyStats      := False;
 
 {$IFDEF USE_VIDEO_RECORDING}
     RecPrefix          := '';
@@ -2582,7 +2583,6 @@
 
     cFlattenFlakes      := false;
     cFlattenClouds      := false;
-    cOnlyStats          := False;
     lastVisualGearByUID := nil;
     lastGearByUID       := nil;
     cReadyDelay         := 5000;