uDebug
authorunc0rr
Sun, 21 Nov 2010 19:41:19 +0300
changeset 4403 0dfe26f48ec1
parent 4402 54a78ec6aac4
child 4404 6bae4e9461aa
uDebug
hedgewars/CMakeLists.txt
hedgewars/hwengine.pas
hedgewars/uAI.pas
hedgewars/uAIActions.pas
hedgewars/uAIMisc.pas
hedgewars/uAmmos.pas
hedgewars/uCollisions.pas
hedgewars/uCommands.pas
hedgewars/uDebug.pas
hedgewars/uGears.pas
hedgewars/uIO.pas
hedgewars/uKeys.pas
hedgewars/uLand.pas
hedgewars/uLandGraphics.pas
hedgewars/uLandObjects.pas
hedgewars/uLandTexture.pas
hedgewars/uLocale.pas
hedgewars/uRenderUtils.pas
hedgewars/uScript.pas
hedgewars/uSound.pas
hedgewars/uStats.pas
hedgewars/uStore.pas
hedgewars/uTeams.pas
hedgewars/uTextures.pas
hedgewars/uUtils.pas
--- a/hedgewars/CMakeLists.txt	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/CMakeLists.txt	Sun Nov 21 19:41:19 2010 +0300
@@ -49,6 +49,7 @@
     uCommands.pas
     uConsole.pas
     uConsts.pas
+    uDebug.pas
     uFloat.pas
     uGame.pas
     uGears.pas
--- a/hedgewars/hwengine.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/hwengine.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -31,7 +31,7 @@
 
 uses SDLh, uMisc, uConsole, uGame, uConsts, uLand, uAmmos, uVisualGears, uGears, uStore, uWorld, uKeys, uSound,
      uScript, uTeams, uStats, uIO, uLocale, uChat, uAI, uAIMisc, uRandom, uLandTexture, uCollisions, uMobile,
-     sysutils, uTypes, uVariables, uCommands, uUtils, uCaptions;
+     sysutils, uTypes, uVariables, uCommands, uUtils, uCaptions, uDebug;
 
 var isTerminated: boolean = false;
     alsoShutdownFrontend: boolean = false;
--- a/hedgewars/uAI.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uAI.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -31,7 +31,7 @@
 implementation
 uses uConsts, SDLh, uAIMisc, uAIAmmoTests, uAIActions,
      uAmmos, SysUtils{$IFDEF UNIX}, cthreads{$ENDIF}, uTypes,
-     uVariables, uCommands, uUtils, uIO;
+     uVariables, uCommands, uUtils, uDebug;
 
 var BestActions: TActions;
     CanUseAmmo: array [TAmmoType] of boolean;
--- a/hedgewars/uAIActions.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uAIActions.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -62,7 +62,7 @@
 procedure ProcessAction(var Actions: TActions; Me: PGear);
 
 implementation
-uses uAIMisc, uAI, uAmmos, uVariables, uCommands, uUtils, uIO;
+uses uAIMisc, uAI, uAmmos, uVariables, uCommands, uUtils, uDebug;
 
 const ActionIdToStr: array[0..6] of string[16] = (
 {aia_none}           '',
--- a/hedgewars/uAIMisc.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uAIMisc.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -68,7 +68,7 @@
              end;
 
 implementation
-uses uCollisions, uVariables, uUtils, uIO;
+uses uCollisions, uVariables, uUtils, uDebug;
 
 const KillScore = 200;
 
--- a/hedgewars/uAmmos.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uAmmos.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -47,7 +47,7 @@
 var StoreCnt: Longword;
 
 implementation
-uses uLocale, uMobile, uVariables, uCommands, uUtils, uIO, uCaptions;
+uses uLocale, uMobile, uVariables, uCommands, uUtils, uCaptions, uDebug;
 
 type TAmmoCounts = array[TAmmoType] of Longword;
 var StoresList: array[0..Pred(cMaxHHs)] of PHHAmmo;
--- a/hedgewars/uCollisions.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uCollisions.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -52,7 +52,7 @@
 function  calcSlopeTangent(Gear: PGear; collisionX, collisionY: LongInt; var outDeltaX, outDeltaY: LongInt; TestWord: LongWord): Boolean;
 
 implementation
-uses uConsts, uLandGraphics, uVariables, uIO;
+uses uConsts, uLandGraphics, uVariables, uDebug;
 
 type TCollisionEntry = record
             X, Y, Radius: LongInt;
--- a/hedgewars/uCommands.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uCommands.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -18,7 +18,7 @@
 implementation
 uses Types, uConsts, uIO, uMobile,
      uRandom, SDLh, uScript, uTypes,
-     uVariables, uConsole, uUtils;
+     uVariables, uConsole, uUtils, uDebug;
 
 type  PVariable = ^TVariable;
       TVariable = record
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/hedgewars/uDebug.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -0,0 +1,35 @@
+{$INCLUDE "options.inc"}
+
+unit uDebug;
+
+interface
+
+procedure OutError(Msg: shortstring; isFatalError: boolean);
+procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); inline;
+procedure SDLTry(Assert: boolean; isFatal: boolean);
+
+implementation
+uses SDLh, uConsole, uCommands;
+
+procedure OutError(Msg: shortstring; isFatalError: boolean);
+begin
+WriteLnToConsole(Msg);
+if isFatalError then
+    begin
+    ParseCommand('fatal ' + GetLastConsoleLine, true);
+    SDL_Quit;
+    halt(1)
+    end
+end;
+
+procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean);
+begin
+if not Assert then OutError(Msg, isFatal)
+end;
+
+procedure SDLTry(Assert: boolean; isFatal: boolean);
+begin
+if not Assert then OutError(SDL_GetError, isFatal)
+end;
+
+end.
\ No newline at end of file
--- a/hedgewars/uGears.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uGears.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -46,7 +46,7 @@
 implementation
 uses uStore, uSound, uTeams, uRandom, uCollisions, uIO, uLandGraphics,
      uAIMisc, uLocale, uAI, uAmmos, uStats, uVisualGears, uScript, GLunit, uMobile, uVariables,
-     uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions;
+     uCommands, uUtils, uTextures, uRenderUtils, uGearsRender, uCaptions, uDebug;
 
 
 procedure DeleteGear(Gear: PGear); forward;
@@ -273,7 +273,7 @@
                 end;
         gtRope: begin
                 gear^.Radius:= 3;
-                gear^.Friction:= _450 * _0_01 * cRopePercent;
+                gear^.Friction:= _450;
                 RopePoints.Count:= 0;
                 end;
         gtMine: begin
--- a/hedgewars/uIO.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uIO.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -28,10 +28,6 @@
 procedure initModule;
 procedure freeModule;
 
-procedure OutError(Msg: shortstring; isFatalError: boolean);
-procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean); inline;
-procedure SDLTry(Assert: boolean; isFatal: boolean);
-
 procedure SendIPC(s: shortstring);
 procedure SendIPCXY(cmd: char; X, Y: SmallInt);
 procedure SendIPCRaw(p: pointer; len: Longword);
@@ -47,7 +43,7 @@
 procedure NetGetNextCmd;
 
 implementation
-uses uConsole, uConsts, uChat, uTeams, uVariables, uCommands, uUtils;
+uses uConsole, uConsts, uChat, uTeams, uVariables, uCommands, uUtils, uDebug;
 
 type PCmd = ^TCmd;
      TCmd = packed record
@@ -69,28 +65,6 @@
 
     SendEmptyPacketTicks: LongWord;
 
-
-procedure OutError(Msg: shortstring; isFatalError: boolean);
-begin
-WriteLnToConsole(Msg);
-if isFatalError then
-    begin
-    SendIPC('E' + GetLastConsoleLine);
-    SDL_Quit;
-    halt(1)
-    end
-end;
-
-procedure TryDo(Assert: boolean; Msg: shortstring; isFatal: boolean);
-begin
-if not Assert then OutError(Msg, isFatal)
-end;
-
-procedure SDLTry(Assert: boolean; isFatal: boolean);
-begin
-if not Assert then OutError(SDL_GetError, isFatal)
-end;
-
 function AddCmd(Time: Word; str: shortstring): PCmd;
 var command: PCmd;
 begin
@@ -386,8 +360,15 @@
 if isInLag then fastUntilLag:= false
 end;
 
+procedure chFatalError(var s: shortstring);
+begin
+    SendIPC('E' + s);
+end;
+
 procedure initModule;
 begin
+    RegisterVariable('fatal', vtCommand, @chFatalError, true );
+
     IPCSock:= nil;
 
     headcmd:= nil;
--- a/hedgewars/uKeys.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uKeys.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -82,7 +82,7 @@
 {$ENDIF}
 {$ENDIF}
 implementation
-uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uIO;
+uses uConsole, uCommands, uMisc, uVariables, uConsts, uUtils, uDebug;
 
 var tkbd, tkbdn: TKeyboardState;
     KeyNames: array [0..cKeyMaxIndex] of string[15];
--- a/hedgewars/uLand.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uLand.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -35,7 +35,7 @@
 
 implementation
 uses uConsole, uStore, uRandom, uLandObjects, uIO, uLandTexture, sysutils,
-     uVariables, uUtils, uCommands, Adler32;
+     uVariables, uUtils, uCommands, Adler32, uDebug;
 
 operator=(const a, b: direction) c: Boolean;
 begin
--- a/hedgewars/uLandGraphics.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uLandGraphics.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -40,7 +40,7 @@
 function TryPlaceOnLand(cpX, cpY: LongInt; Obj: TSprite; Frame: LongInt; doPlace: boolean): boolean;
 
 implementation
-uses SDLh, uLandTexture, uVariables, uUtils, uIO;
+uses SDLh, uLandTexture, uVariables, uUtils, uDebug;
 
 procedure FillCircleLines(x, y, dx, dy: LongInt; Value: Longword);
 var i: LongInt;
--- a/hedgewars/uLandObjects.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uLandObjects.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -30,7 +30,7 @@
 
 implementation
 uses uStore, uConsts, uConsole, uRandom, uVisualGears, uSound, GLunit,
-     uTypes, uVariables, uUtils, uIO;
+     uTypes, uVariables, uUtils, uDebug;
 
 const MaxRects = 512;
       MAXOBJECTRECTS = 16;
--- a/hedgewars/uLandTexture.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uLandTexture.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -28,7 +28,7 @@
 procedure DrawLand(dX, dY: LongInt);
 
 implementation
-uses uConsts, GLunit, uTypes, uVariables, uTextures, uIO, uRender;
+uses uConsts, GLunit, uTypes, uVariables, uTextures, uDebug, uRender;
 
 const TEXSIZE = 256;
 
--- a/hedgewars/uLocale.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uLocale.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -30,7 +30,7 @@
 function  GetEventString(e: TEventId): ansistring;
 
 implementation
-uses uRandom, uUtils, uIO, uVariables;
+uses uRandom, uUtils, uVariables, uDebug;
 
 var trevt: array[TEventId] of array [0..Pred(MAX_EVENT_STRINGS)] of ansistring;
     trevt_n: array[TEventId] of integer;
--- a/hedgewars/uRenderUtils.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uRenderUtils.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -12,7 +12,7 @@
 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
 
 implementation
-uses uIO, uUtils, uVariables, uConsts, uTextures, sysutils;
+uses uIO, uUtils, uVariables, uConsts, uTextures, sysutils, uDebug;
 
 procedure DrawRoundRect(rect: PSDL_Rect; BorderColor, FillColor: Longword; Surface: PSDL_Surface; Clear: boolean);
 var r: TSDL_Rect;
--- a/hedgewars/uScript.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uScript.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -55,9 +55,9 @@
     uVariables,
     uCommands,
     uUtils,
-    uIO,
     uKeys,
-    uCaptions;
+    uCaptions,
+    uDebug;
 
 var luaState : Plua_State;
     ScriptAmmoLoadout : shortstring;
--- a/hedgewars/uSound.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uSound.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -46,7 +46,7 @@
 
 
 implementation
-uses uMisc, uVariables, uConsole, uUtils, uIO, uCommands;
+uses uMisc, uVariables, uConsole, uUtils, uIO, uCommands, uDebug;
 
 const chanTPU = 32;
 var Volume: LongInt;
--- a/hedgewars/uStats.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uStats.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -35,7 +35,7 @@
 procedure SendStats;
 
 implementation
-uses uTeams, uSound, uLocale, uVariables, uUtils, uIO, uCaptions;
+uses uTeams, uSound, uLocale, uVariables, uUtils, uIO, uCaptions, uDebug;
 
 var DamageGiven : Longword = 0;
     DamageClan  : Longword = 0;
--- a/hedgewars/uStore.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uStore.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -39,7 +39,7 @@
 procedure FreeWeaponTooltip;
 
 implementation
-uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uIO, uRender, uRenderUtils, uCommands;
+uses uMisc, uConsole, uMobile, uVariables, uUtils, uTextures, uIO, uRender, uRenderUtils, uCommands, uDebug;
 
 type TGPUVendor = (gvUnknown, gvNVIDIA, gvATI, gvIntel, gvApple);
 
--- a/hedgewars/uTeams.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uTeams.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -38,7 +38,7 @@
 function  GetTeamStatString(p: PTeam): shortstring;
 
 implementation
-uses uLocale, uAmmos, uChat, uMobile, uVariables, uUtils, uIO, uCaptions, uCommands;
+uses uLocale, uAmmos, uChat, uMobile, uVariables, uUtils, uIO, uCaptions, uCommands, uDebug;
 
 const MaxTeamHealth: LongInt = 0;
 
--- a/hedgewars/uTextures.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uTextures.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -12,7 +12,7 @@
 procedure freeModule;
 
 implementation
-uses GLunit, uUtils, uVariables, uConsts, uIO;
+uses GLunit, uUtils, uVariables, uConsts, uDebug;
 
 var TextureList: PTexture;
 
--- a/hedgewars/uUtils.pas	Sun Nov 21 19:14:45 2010 +0300
+++ b/hedgewars/uUtils.pas	Sun Nov 21 19:41:19 2010 +0300
@@ -40,11 +40,12 @@
 
 function CheckNoTeamOrHH: boolean; inline;
 
+function  GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt;
+function  GetLaunchY(at: TAmmoType; angle: LongInt): LongInt;
+
 procedure initModule;
 procedure freeModule;
 
-function  GetLaunchX(at: TAmmoType; dir: LongInt; angle: LongInt): LongInt;
-function  GetLaunchY(at: TAmmoType; angle: LongInt): LongInt;
 
 implementation
 uses typinfo, Math, uConsts, uVariables, SysUtils;
@@ -287,7 +288,6 @@
 end;
 
 function CheckNoTeamOrHH: boolean;
-var bRes: boolean;
 begin
 CheckNoTeamOrHH:= (CurrentTeam = nil) or (CurrentHedgehog^.Gear = nil);
 end;