- Check for harmful gear deletions
- Catch and fix bug in kamikaze
- TARDIS has similar bug, leave fixing to its authors
--- a/hedgewars/GSHandlers.inc Mon Jul 16 23:12:59 2012 +0400
+++ b/hedgewars/GSHandlers.inc Mon Jul 16 23:46:44 2012 +0400
@@ -2947,7 +2947,7 @@
end
end;
AfterAttack;
- DeleteGear(HHGear);
+ HHGear^.Message:= HHGear^.Message or gmDestroy;
DeleteGear(Gear);
end
else
--- a/hedgewars/uGears.pas Mon Jul 16 23:12:59 2012 +0400
+++ b/hedgewars/uGears.pas Mon Jul 16 23:46:44 2012 +0400
@@ -182,7 +182,7 @@
end;
procedure ProcessGears;
-var Gear, t: PGear;
+var t: PGear;
i, AliveCount: LongInt;
s: shortstring;
begin
@@ -203,21 +203,22 @@
t:= GearsList;
while t <> nil do
begin
- Gear:= t;
- t:= Gear^.NextGear;
+ curHandledGear:= t;
+ t:= curHandledGear^.NextGear;
- if Gear^.Active then
+ if curHandledGear^.Active then
begin
- if Gear^.RenderTimer and (Gear^.Timer > 500) and ((Gear^.Timer mod 1000) = 0) then
+ if curHandledGear^.RenderTimer and (curHandledGear^.Timer > 500) and ((curHandledGear^.Timer mod 1000) = 0) then
begin
- FreeTexture(Gear^.Tex);
- Gear^.Tex:= RenderStringTex(inttostr(Gear^.Timer div 1000), cWhiteColor, fntSmall);
+ FreeTexture(curHandledGear^.Tex);
+ curHandledGear^.Tex:= RenderStringTex(inttostr(curHandledGear^.Timer div 1000), cWhiteColor, fntSmall);
end;
- Gear^.doStep(Gear);
+ curHandledGear^.doStep(curHandledGear);
// might be useful later
//ScriptCall('onGearStep', Gear^.uid);
end
end;
+curHandledGear:= nil;
if AllInactive then
case step of
@@ -1323,6 +1324,8 @@
CurAmmoGear:= nil;
GearsList:= nil;
+ curHandledGear:= nil;
+
KilledHHs:= 0;
SuddenDeath:= false;
SuddenDeathDmg:= false;
--- a/hedgewars/uGearsList.pas Mon Jul 16 23:12:59 2012 +0400
+++ b/hedgewars/uGearsList.pas Mon Jul 16 23:46:44 2012 +0400
@@ -27,11 +27,13 @@
procedure InsertGearToList(Gear: PGear);
procedure RemoveGearFromList(Gear: PGear);
+var curHandledGear: PGear;
+
implementation
uses uRandom, uUtils, uConsts, uVariables, uAmmos, uTeams, uStats,
uTextures, uScript, uRenderUtils, uAI, uCollisions,
- uGearsRender, uGearsUtils;
+ uGearsRender, uGearsUtils, uDebug;
var GCounter: LongWord = 0; // this does not get re-initialized, but should be harmless
@@ -63,8 +65,11 @@
end;
end;
+
procedure RemoveGearFromList(Gear: PGear);
begin
+TryDo((curHandledGear = nil) or (Gear = curHandledGear), 'You''re doing it wrong', true);
+
if Gear^.NextGear <> nil then
Gear^.NextGear^.PrevGear:= Gear^.PrevGear;
if Gear^.PrevGear <> nil then
@@ -72,7 +77,8 @@
else
GearsList:= Gear^.NextGear
end;
-
+
+
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
var gear: PGear;
begin