addfilelog <3 debugfile
authorkoda
Tue, 01 Feb 2011 15:30:08 +0100
changeset 4900 8ad0e23e6d63
parent 4899 8163c9aaad0c
child 4901 d1e2d82d9ccc
addfilelog <3 debugfile
hedgewars/hwengine.pas
hedgewars/uAI.pas
hedgewars/uCommandHandlers.pas
hedgewars/uCommands.pas
hedgewars/uConsole.pas
hedgewars/uDebug.pas
hedgewars/uFloat.pas
hedgewars/uGears.pas
hedgewars/uIO.pas
hedgewars/uLand.pas
hedgewars/uLandPainted.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
hedgewars/uUtils.pas
--- a/hedgewars/hwengine.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/hwengine.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -201,9 +201,7 @@
 {$ENDIF}
 var p: TPathType;
     s: shortstring;
-{$IFDEF DEBUGFILE}
     i: LongInt;
-{$ENDIF}
 begin
 {$IFDEF HWLIBRARY}
     cBits:= 32;
@@ -233,11 +231,9 @@
     initEverything(true);
 
     WriteLnToConsole('Hedgewars ' + cVersionString + ' engine (network protocol: ' + inttostr(cNetProtoVersion) + ')');
-{$IFDEF DEBUGFILE}
     AddFileLog('Prefix: "' + PathPrefix +'"');
     for i:= 0 to ParamCount do
         AddFileLog(inttostr(i) + ': ' + ParamStr(i));
-{$ENDIF}
 
     for p:= Succ(Low(TPathType)) to High(TPathType) do
         if p <> ptMapCurrent then Pathz[p]:= PathPrefix + '/' + Pathz[p];
--- a/hedgewars/uAI.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uAI.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -41,10 +41,10 @@
 
 procedure FreeActionsList;
 begin
-{$IFDEF DEBUGFILE}AddFileLog('FreeActionsList called');{$ENDIF}
+AddFileLog('FreeActionsList called');
 if hasThread <> 0 then
    begin
-   {$IFDEF DEBUGFILE}AddFileLog('Waiting AI thread to finish');{$ENDIF}
+   AddFileLog('Waiting AI thread to finish');
    StopThinking:= true;
    repeat
      SDL_Delay(10)
@@ -323,7 +323,7 @@
 FillBonuses((Me^.State and gstAttacked) <> 0);
 for a:= Low(TAmmoType) to High(TAmmoType) do
     CanUseAmmo[a]:= Assigned(AmmoTests[a].proc) and HHHasAmmo(Me^.Hedgehog^, a);
-{$IFDEF DEBUGFILE}AddFileLog('Enter Think Thread');{$ENDIF}
+AddFileLog('Enter Think Thread');
 BeginThread(@Think, Me, ThinkThread)
 end;
 
--- a/hedgewars/uCommandHandlers.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uCommandHandlers.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -306,7 +306,7 @@
 bShowFinger:= false;
 with CurrentHedgehog^.Gear^ do
     begin
-    {$IFDEF DEBUGFILE}AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));{$ENDIF}
+    AddFileLog('/+attack: hedgehog''s Gear^.State = '+inttostr(State));
     if ((State and gstHHDriven) <> 0) then
         begin
         FollowGear:= CurrentHedgehog^.Gear;
@@ -347,9 +347,7 @@
     TryDo(AllInactive, '/nextturn called when not all gears are inactive', true);
 
     if not CurrentTeam^.ExtDriven then SendIPC('N');
-{$IFDEF DEBUGFILE}
     AddFileLog('Doing SwitchHedgehog: time '+inttostr(GameTicks));
-{$ENDIF}
 end;
 
 procedure chTimer(var s: shortstring);
--- a/hedgewars/uCommands.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uCommands.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -60,7 +60,7 @@
 if c in ['/', '$'] then Delete(CmdStr, 1, 1) else c:= '/';
 s:= '';
 SplitBySpace(CmdStr, s);
-{$IFDEF DEBUGFILE}AddFileLog('[Cmd] ' + c + CmdStr + ' (' + inttostr(length(s)) + ')');{$ENDIF}
+AddFileLog('[Cmd] ' + c + CmdStr + ' (' + inttostr(length(s)) + ')');
 t:= Variables;
 while t <> nil do
       begin
--- a/hedgewars/uConsole.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uConsole.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -52,7 +52,7 @@
     done: boolean;
 begin
 {$IFNDEF NOCONSOLE}
-{$IFDEF DEBUGFILE}AddFileLog('[Con] ' + s);{$ENDIF}
+AddFileLog('[Con] ' + s);
 Write(s);
 done:= false;
 
--- a/hedgewars/uDebug.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uDebug.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -32,4 +32,4 @@
 if not Assert then OutError(SDL_GetError, isFatal)
 end;
 
-end.
\ No newline at end of file
+end.
--- a/hedgewars/uFloat.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uFloat.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -352,9 +352,7 @@
 
 function AngleSin(const Angle: Longword): hwFloat;
 begin
-{$IFDEF DEBUGFILE}
 //TryDo((Angle >= 0) and (Angle <= 2048), 'Sin param exceeds limits', true);
-{$ENDIF}
 AngleSin.isNegative:= false;
 if Angle < 1024 then AngleSin.QWordValue:= SinTable[Angle]
                 else AngleSin.QWordValue:= SinTable[2048 - Angle]
@@ -362,9 +360,7 @@
 
 function AngleCos(const Angle: Longword): hwFloat;
 begin
-{$IFDEF DEBUGFILE}
 //TryDo((Angle >= 0) and (Angle <= 2048), 'Cos param exceeds limits', true);
-{$ENDIF}
 AngleCos.isNegative:= Angle > 1024;
 if Angle < 1024 then AngleCos.QWordValue:= SinTable[1024 - Angle]
                 else AngleCos.QWordValue:= SinTable[Angle - 1024]
--- a/hedgewars/uGears.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uGears.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -182,9 +182,7 @@
 var gear: PGear;
 begin
 inc(Counter);
-{$IFDEF DEBUGFILE}
 AddFileLog('AddGear: #' + inttostr(Counter) + ' (' + inttostr(x) + ',' + inttostr(y) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
-{$ENDIF}
 
 New(gear);
 FillChar(gear^, sizeof(TGear), 0);
@@ -602,9 +600,8 @@
                 Team^.AIKillsTex := RenderStringTex(inttostr(Team^.stats.AIKills), Team^.Clan^.Color, fnt16);
                 end
         end;
-{$IFDEF DEBUGFILE}
-with Gear^ do AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
-{$ENDIF}
+with Gear^ do
+    AddFileLog('Delete: #' + inttostr(uid) + ' (' + inttostr(hwRound(x)) + ',' + inttostr(hwRound(y)) + '), d(' + floattostr(dX) + ',' + floattostr(dY) + ') type = ' + EnumToStr(Kind));
 
 if CurAmmoGear = Gear then CurAmmoGear:= nil;
 if FollowGear = Gear then FollowGear:= nil;
@@ -1046,9 +1043,7 @@
         end;
     end else if Gear^.Kind <> gtStructure then // not gtHedgehog nor gtStructure
         begin
-        {$IFDEF DEBUGFILE}
         AddFileLog('Assigning hedgehog ' + inttostr(LongInt(AttackerHog)) + ' to gear ' + inttostr(Gear^.uid));
-        {$ENDIF}
         Gear^.Hedgehog:= AttackerHog;
         end;
     inc(Gear^.Damage, Damage);
@@ -1170,7 +1165,7 @@
     i, cnt: LongInt;
 begin
 TargetPoint.X:= NoPointX;
-{$IFDEF DEBUGFILE}if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');{$ENDIF}
+if Radius > 4 then AddFileLog('Explosion: at (' + inttostr(x) + ',' + inttostr(y) + ')');
 if Radius > 25 then KickFlakes(Radius, X, Y);
 
 if ((Mask and EXPLNoGfx) = 0) then
@@ -1213,7 +1208,7 @@
                         if dmg > 1 then
                             begin
                             dmg:= ModifyDamage(min(dmg div 2, Radius), Gear);
-                            //{$IFDEF DEBUGFILE}AddFileLog('Damage: ' + inttostr(dmg));{$ENDIF}
+                            //AddFileLog('Damage: ' + inttostr(dmg));
                             if (Mask and EXPLNoDamage) = 0 then
                                 begin
                                 if not Gear^.Invulnerable then
@@ -1775,9 +1770,7 @@
         begin
         Gear^.X:= int2hwFloat(x);
         Gear^.Y:= int2hwFloat(y);
-        {$IFDEF DEBUGFILE}
         AddFileLog('Assigned Gear coordinates (' + inttostr(x) + ',' + inttostr(y) + ')');
-        {$ENDIF}
         end
     else
     begin
--- a/hedgewars/uIO.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uIO.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -121,7 +121,7 @@
 var loTicks: Word;
 begin
 case s[1] of
-     '!': begin {$IFDEF DEBUGFILE}AddFileLog('Ping? Pong!');{$ENDIF}isPonged:= true; end;
+     '!': begin AddFileLog('Ping? Pong!'); isPonged:= true; end;
      '?': SendIPC('!');
      'e': ParseCommand(copy(s, 2, Length(s) - 1), true);
      'E': OutError(copy(s, 2, Length(s) - 1), true);
@@ -136,7 +136,7 @@
      else
      loTicks:= SDLNet_Read16(@s[byte(s[0]) - 1]);
      AddCmd(loTicks, s);
-     {$IFDEF DEBUGFILE}AddFileLog('[IPC in] '+s[1]+' ticks '+IntToStr(lastcmd^.loTime));{$ENDIF}
+     AddFileLog('[IPC in] '+s[1]+' ticks '+IntToStr(lastcmd^.loTime));
      end
 end;
 
@@ -217,7 +217,7 @@
     SendEmptyPacketTicks:= 0;
     if s[0]>#251 then s[0]:= #251;
     SDLNet_Write16(GameTicks, @s[Succ(byte(s[0]))]);
-    {$IFDEF DEBUGFILE}AddFileLog('[IPC out] '+ s[1]);{$ENDIF}
+    AddFileLog('[IPC out] '+ s[1]);
     inc(s[0], 2);
     SDLNet_TCP_Send(IPCSock, @s, Succ(byte(s[0])))
     end
@@ -244,7 +244,7 @@
 procedure SendIPCTimeInc;
 const timeinc: shortstring = '#';
 begin
-{$IFDEF DEBUGFILE}AddFileLog('[IPC out] <time increment>');{$ENDIF}
+AddFileLog('[IPC out] <time increment>');
 SendIPCRaw(@timeinc, 2)
 end;
 
@@ -324,7 +324,7 @@
         'F': ParseCommand('teamgone ' + copy(headcmd^.str, 2, Pred(headcmd^.len)), true);
         'N': begin
             tmpflag:= false;
-            {$IFDEF DEBUGFILE}AddFileLog('got cmd "N": time '+IntToStr(hiTicks shl 16 + headcmd^.loTime)){$ENDIF}
+            AddFileLog('got cmd "N": time '+IntToStr(hiTicks shl 16 + headcmd^.loTime))
             end;
         'p': begin
             x16:= SDLNet_Read16(@(headcmd^.X));
@@ -402,7 +402,7 @@
             TargetPoint.X:= putX;
             TargetPoint.Y:= putY
             end;
-        {$IFDEF DEBUGFILE}AddFilelog('put: ' + inttostr(TargetPoint.X) + ', ' + inttostr(TargetPoint.Y));{$ENDIF}
+        AddFileLog('put: ' + inttostr(TargetPoint.X) + ', ' + inttostr(TargetPoint.Y));
         State:= State and not gstHHChooseTarget;
         if (Ammoz[CurAmmoType].Ammo.Propz and ammoprop_AttackingPut) <> 0 then
             Message:= Message or (gmAttack and InputMask);
--- a/hedgewars/uLand.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uLand.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -1189,7 +1189,7 @@
     LoadThemeConfig;
     isMap:= false;
 
-    // is this not needed any more? let's hope setlength sets also 0s
+    // is this not needed any more? lets hope setlength sets also 0s
     //if ((GameFlags and gfForts) <> 0) or (Pathz[ptMapCurrent] <> '') then
     //    FillChar(Land,SizeOf(TCollisionArray),0);*)
 
@@ -1316,9 +1316,7 @@
 
 procedure chLandCheck(var s: shortstring);
 begin
-{$IFDEF DEBUGFILE}
     AddFileLog('CheckLandDigest: ' + s + ' digest : ' + digest);
-{$ENDIF}
     if digest = '' then
         digest:= s
     else
--- a/hedgewars/uLandPainted.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uLandPainted.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -149,12 +149,12 @@
         begin
         if (pe^.point.flags and $80 <> 0) then
             begin
-            {$IFDEF DEBUGFILE}AddFileLog('[DRAW] Move to: ('+inttostr(pe^.point.X)+','+inttostr(pe^.point.Y)+')');{$ENDIF}
+            AddFileLog('[DRAW] Move to: ('+inttostr(pe^.point.X)+','+inttostr(pe^.point.Y)+')');
             FillRoundInLand(pe^.point.X, pe^.point.Y, 34, lfBasic)
             end
             else
             begin
-            {$IFDEF DEBUGFILE}AddFileLog('[DRAW] Line to: ('+inttostr(pe^.point.X)+','+inttostr(pe^.point.Y)+')');{$ENDIF}
+            AddFileLog('[DRAW] Line to: ('+inttostr(pe^.point.X)+','+inttostr(pe^.point.Y)+')');
             DrawLineOnLand(prevPoint.X, prevPoint.Y, pe^.point.X, pe^.point.Y);
             end;
 
--- a/hedgewars/uStore.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uStore.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -456,21 +456,17 @@
 function glLoadExtension(extension : shortstring) : boolean;
 begin
 {$IF GLunit = gles11}
-    // FreePascal doesn't come with OpenGL ES 1.1 Extension headers
+    // FreePascal doesnt come with OpenGL ES 1.1 Extension headers
     extension:= extension; // avoid hint
     glLoadExtension:= false;
-{$IFDEF DEBUGFILE}
     AddFileLog('OpenGL - "' + extension + '" skipped')
-{$ENDIF}
 {$ELSE}
     glLoadExtension:= glext_LoadExtension(extension);
-{$IFDEF DEBUGFILE}
     if glLoadExtension then
         AddFileLog('OpenGL - "' + extension + '" loaded')
     else
         AddFileLog('OpenGL - "' + extension + '" failed to load');
 {$ENDIF}
-{$ENDIF}
 end;
 
 procedure SetupOpenGL;
@@ -511,19 +507,15 @@
 
     glGetIntegerv(GL_MAX_TEXTURE_SIZE, @MaxTextureSize);
 
-{$IFDEF DEBUGFILE}
     AddFileLog('OpenGL-- Renderer: ' + shortstring(pchar(glGetString(GL_RENDERER))));
     AddFileLog('  |----- Vendor: ' + shortstring(pchar(glGetString(GL_VENDOR))));
     AddFileLog('  |----- Version: ' + shortstring(pchar(glGetString(GL_VERSION))));
     AddFileLog('  \----- GL_MAX_TEXTURE_SIZE: ' + inttostr(MaxTextureSize));
-{$ENDIF}
 
     if MaxTextureSize <= 0 then
     begin
         MaxTextureSize:= 1024;
-{$IFDEF DEBUGFILE}
         AddFileLog('OpenGL Warning - driver didn''t provide any valid max texture size; assuming 1024');
-{$ENDIF}
     end;
 
 {$IFDEF IPHONEOS}
@@ -579,13 +571,8 @@
     end;
 {$ENDIF}
 
-{$IFDEF DEBUGFILE}
     if cGPUVendor = gvUnknown then
         AddFileLog('OpenGL Warning - unknown hardware vendor; please report');
-{$ELSE}
-    // just avoid 'never used' compiler warning for now
-    if cGPUVendor = gvUnknown then cGPUVendor:= gvUnknown;
-{$ENDIF}
 
     // set view port to whole window
     if (rotationQt = 0) or (rotationQt = 180) then
@@ -856,18 +843,14 @@
 procedure chFullScr(var s: shortstring);
 var flags: Longword = 0;
     ico: PSDL_Surface;
-{$IFDEF DEBUGFILE}
     buf: array[byte] of char;
-{$ENDIF}
 begin
     s:= s; // avoid compiler hint
     if Length(s) = 0 then cFullScreen:= not cFullScreen
     else cFullScreen:= s = '1';
 
-{$IFDEF DEBUGFILE}
     buf[0]:= char(0); // avoid compiler hint
     AddFileLog('Prepare to change video parameters...');
-{$ENDIF}
 
     flags:= SDL_OPENGL;// or SDL_RESIZABLE;
 
@@ -896,9 +879,7 @@
 
     if SDLPrimSurface <> nil then
     begin
-{$IFDEF DEBUGFILE}
         AddFileLog('Freeing old primary surface...');
-{$ENDIF}
         SDL_FreeSurface(SDLPrimSurface);
         SDLPrimSurface:= nil;
     end;
@@ -921,10 +902,7 @@
     PixelFormat:= SDLPrimSurface^.format;
 {$ENDIF}
 
-{$IFDEF DEBUGFILE}
-    AddFileLog('Setting up OpenGL...');
-    AddFileLog('SDL video driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))));
-{$ENDIF}
+    AddFileLog('Setting up OpenGL (using driver: ' + shortstring(SDL_VideoDriverName(buf, sizeof(buf))) + ')');
     SetupOpenGL();
 end;
 
--- a/hedgewars/uTeams.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uTeams.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -216,7 +216,7 @@
         CWindSpeedf := -cWindSpeedf;
     g:= AddGear(0, 0, gtATSmoothWindCh, 0, _0, _0, 1);
     g^.Tag:= hwRound(cWindSpeed * 72 / cMaxWindSpeed);
-{$IFDEF DEBUGFILE}AddFileLog('Wind = '+FloatToStr(cWindSpeed));{$ENDIF}
+    AddFileLog('Wind = '+FloatToStr(cWindSpeed));
     end;
 
 ApplyAmmoChanges(CurrentHedgehog^);
--- a/hedgewars/uUtils.pas	Tue Feb 01 08:15:01 2011 +0100
+++ b/hedgewars/uUtils.pas	Tue Feb 01 15:30:08 2011 +0100
@@ -35,11 +35,9 @@
 
 function  CheckCJKFont(s: ansistring; font: THWFont): THWFont;
 
-{$IFDEF DEBUGFILE}
 procedure AddFileLog(s: shortstring);
-{$ENDIF}
 
-function CheckNoTeamOrHH: boolean; inline;
+function  CheckNoTeamOrHH: boolean; inline;
 
 function  GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt;
 function  GetLaunchY(at: TAmmoType; angle: LongInt): LongInt;
@@ -231,13 +229,14 @@
 end;
 
 
-{$IFDEF DEBUGFILE}
 procedure AddFileLog(s: shortstring);
 begin
+s:= s;
+{$IFDEF DEBUGFILE}
 writeln(f, GameTicks: 6, ': ', s);
 flush(f)
+{$ENDIF}
 end;
-{$ENDIF}
 
 
 function CheckCJKFont(s: ansistring; font: THWFont): THWFont;