- Fix crash in AI
authorunc0rr
Thu, 14 Sep 2006 17:20:50 +0000
changeset 145 e593d5266e01
parent 144 e6084b0c9316
child 146 458f4f58c1b6
- Fix crash in AI - Dont allow to add more than 5 teams
hedgewars/CCHandlers.inc
hedgewars/uGears.pas
--- a/hedgewars/CCHandlers.inc	Wed Sep 13 19:26:16 2006 +0000
+++ b/hedgewars/CCHandlers.inc	Thu Sep 14 17:20:50 2006 +0000
@@ -47,8 +47,15 @@
 end;
 
 procedure chAddTeam(var s: shortstring);
+const TeamsCount: Longword = 0;
 begin
-if isDeveloperMode then AddTeam;
+if isDeveloperMode then
+   begin
+   inc(TeamsCount);
+   TryDo(TeamsCount <= 5, 'Too many teams', true);
+   AddTeam
+   end;
+   
 if GameType in [gmtDemo, gmtSave] then CurrentTeam.ExtDriven:= true
 end;
 
--- a/hedgewars/uGears.pas	Wed Sep 13 19:26:16 2006 +0000
+++ b/hedgewars/uGears.pas	Thu Sep 14 17:20:50 2006 +0000
@@ -79,7 +79,7 @@
 
 implementation
 uses uWorld, uMisc, uStore, uConsole, uSound, uTeams, uRandom, uCollisions,
-     uLand, uIO, uLandGraphics, uAIMisc, uLocale;
+     uLand, uIO, uLandGraphics, uAIMisc, uLocale, uAI;
 var RopePoints: record
                 Count: Longword;
                 HookAngle: integer;
@@ -207,7 +207,7 @@
                 end;
         gtCase: begin
                 Result.Radius:= 16;
-                Result.Elasticity:= 0.6
+                Result.Elasticity:= 0.4
                 end;
   gtDEagleShot: begin
                 Result.Radius:= 1;
@@ -263,6 +263,8 @@
       begin
       team:= PHedgehog(Gear.Hedgehog).Team;
       PHedgehog(Gear.Hedgehog).Gear:= nil;
+      if CurrentTeam.Hedgehogs[CurrentTeam.CurrHedgehog].Gear = Gear then
+         FreeActionsList; // to avoid ThinkThread on drawned gear
       RecountTeamHealth(team);
       end;
 {$IFDEF DEBUGFILE}AddFileLog('DeleteGear: handle = '+inttostr(integer(Gear)));{$ENDIF}