minor code review
authorunc0rr
Mon, 12 Sep 2005 21:16:57 +0000
changeset 17 a6bed8d31444
parent 16 b6f4b413dd41
child 18 d49c23eba8ba
minor code review
hedgewars/uAI.pas
hedgewars/uAIActions.pas
hedgewars/uConsole.pas
hedgewars/uConsts.pas
hedgewars/uGears.pas
hedgewars/uIO.pas
hedgewars/uMisc.pas
hedgewars/uTeams.pas
--- a/hedgewars/uAI.pas	Sun Sep 11 21:02:11 2005 +0000
+++ b/hedgewars/uAI.pas	Mon Sep 12 21:16:57 2005 +0000
@@ -39,11 +39,6 @@
 implementation
 uses uAIActions, uAIMisc, uMisc, uTeams, uConsts, uAIAmmoTests, uGears, SDLh;
 
-function Go(Gear: PGear; Times: Longword): boolean;
-begin
-Result:= false
-end;
-
 procedure Think;
 var Targets: TTargets;
     Angle, Power: integer;
--- a/hedgewars/uAIActions.pas	Sun Sep 11 21:02:11 2005 +0000
+++ b/hedgewars/uAIActions.pas	Mon Sep 12 21:16:57 2005 +0000
@@ -86,7 +86,7 @@
 function AddAction(Action, Param, TimeDelta: Longword): PAction;
 begin
 New(Result);
-TryDo(Result <> nil, errmsgDynamicVar, true);
+TryDo(Result <> nil, 'AddAction: Result = nil', true);
 FillChar(Result^, sizeof(TAction), 0);
 Result.Action:= Action;
 Result.Param:= Param;
--- a/hedgewars/uConsole.pas	Sun Sep 11 21:02:11 2005 +0000
+++ b/hedgewars/uConsole.pas	Mon Sep 12 21:16:57 2005 +0000
@@ -67,9 +67,8 @@
 
 function RegisterVariable(Name: string; VType: TVariableType; p: pointer): PVariable;
 begin
-try
-   New(Result);
-except Result:= nil; OutError(errmsgDynamicVar, true) end;
+New(Result);
+TryDo(Result <> nil, 'RegisterVariable: Result = nil', true);
 FillChar(Result^, sizeof(TVariable), 0);
 Result.Name:= Name;
 Result.VType:= VType;
@@ -90,9 +89,7 @@
       begin
       t:= tt;
       tt:= tt.Next;
-      try
       Dispose(t)
-      except OutError(errmsgDynamicVar) end;
       end;
 end;
 
--- a/hedgewars/uConsts.pas	Sun Sep 11 21:02:11 2005 +0000
+++ b/hedgewars/uConsts.pas	Mon Sep 12 21:16:57 2005 +0000
@@ -72,7 +72,6 @@
       errmsgCreateSurface   = 'Error creating DirectDraw7 surface';
       errmsgNoDesc          = 'Unknown error';
       errmsgTransparentSet  = 'Error setting transparent color';
-      errmsgDynamicVar      = 'Error working with dynamic memory';
       errmsgUnknownCommand  = 'Unknown command';
       errmsgUnknownVariable = 'Unknown variable';
       errmsgIncorrectUse    = 'Incorrect use';
--- a/hedgewars/uGears.pas	Sun Sep 11 21:02:11 2005 +0000
+++ b/hedgewars/uGears.pas	Mon Sep 12 21:16:57 2005 +0000
@@ -62,7 +62,7 @@
              Tag: integer;
              end;
 
-function AddGear(X, Y: integer; Kind: TGearType; State: Cardinal; const dX: real=0.0; dY: real=0.0; Timer: LongWord=0): PGear;
+function  AddGear(X, Y: integer; Kind: TGearType; State: Cardinal; const dX: real=0.0; dY: real=0.0; Timer: LongWord=0): PGear;
 procedure ProcessGears;
 procedure SetAllToActive;
 procedure SetAllHHToActive;
@@ -88,7 +88,7 @@
 
 procedure DeleteGear(Gear: PGear); forward;
 procedure doMakeExplosion(X, Y, Radius: integer; Mask: LongWord); forward;
-function CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: integer): PGear; forward;
+function  CheckGearNear(Gear: PGear; Kind: TGearType; rX, rY: integer): PGear; forward;
 procedure SpawnBoxOfSmth; forward;
 
 {$INCLUDE GSHandlers.inc}
@@ -478,9 +478,7 @@
       begin
       t:= tt;
       tt:= tt.NextGear;
-      try
       Dispose(t)
-      except OutError(errmsgDynamicVar) end;
       end;
 end;
 
--- a/hedgewars/uIO.pas	Sun Sep 11 21:02:11 2005 +0000
+++ b/hedgewars/uIO.pas	Mon Sep 12 21:16:57 2005 +0000
@@ -231,7 +231,7 @@
 {$I+}
 TryDo(IOResult = 0, msgFailed, true);
 WriteLnToConsole(msgOK);
-TryDo(Count < cnt, 'Fort doesn''t contain needed spawn points', true);
+TryDo(Count < cnt, 'Fort doesn''t contain needed amount of spawn points', true);
 for i:= 0 to Pred(cnt) do
     begin
     t:= GetRandom(cnt);
--- a/hedgewars/uMisc.pas	Sun Sep 11 21:02:11 2005 +0000
+++ b/hedgewars/uMisc.pas	Mon Sep 12 21:16:57 2005 +0000
@@ -202,6 +202,7 @@
 initialization
 assignfile(f, 'debug.txt');
 rewrite(f);
+
 finalization
 writeln(f, '-= halt at ',GameTicks,' ticks =-');
 Flush(f);
--- a/hedgewars/uTeams.pas	Sun Sep 11 21:02:11 2005 +0000
+++ b/hedgewars/uTeams.pas	Mon Sep 12 21:16:57 2005 +0000
@@ -140,9 +140,8 @@
 
 function AddTeam: PTeam;
 begin
-try
-   New(Result);
-except Result:= nil; OutError(errmsgDynamicVar, true) end;
+New(Result);
+TryDo(Result <> nil, 'AddTean: Result = nil', true);
 FillChar(Result^, sizeof(TTeam), 0);
 Result.AttackBar:= 1;
 if TeamsList = nil then TeamsList:= Result
@@ -162,9 +161,7 @@
       begin
       t:= tt;
       tt:= tt.Next;
-      try
       Dispose(t)
-      except OutError(errmsgDynamicVar) end;
       end;
 end;