--- a/hedgewars/uGearsList.pas Mon Dec 08 23:00:13 2014 +0300
+++ b/hedgewars/uGearsList.pas Mon Dec 08 15:02:43 2014 -0500
@@ -23,7 +23,8 @@
uses uFloat, uTypes, SDLh;
function AddGear(X, Y: LongInt; Kind: TGearType; State: Longword; dX, dY: hwFloat; Timer: LongWord): PGear;
-procedure DeleteGear(Gear: PGear);
+procedure DeleteGear(Gear: PGear); inline;
+procedure DeleteGearStage(Gear: PGear; cleanup: boolean);
procedure InsertGearToList(Gear: PGear);
procedure RemoveGearFromList(Gear: PGear);
@@ -629,7 +630,12 @@
ScriptCall('onGearAdd', gear^.uid);
end;
-procedure DeleteGear(Gear: PGear);
+procedure DeleteGear(Gear: PGear); inline;
+begin
+DeleteGearStage(Gear, false)
+end;
+
+procedure DeleteGearStage(Gear: PGear; cleanup: boolean);
var team: PTeam;
t,i: Longword;
k: boolean;
@@ -660,17 +666,39 @@
end
else*)
begin
- if ((CurrentHedgehog = nil) or (Gear <> CurrentHedgehog^.Gear)) or (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtKamikaze) then
- Gear^.Hedgehog^.Team^.Clan^.Flawless:= false;
- if CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
+ team:= Gear^.Hedgehog^.Team;
+ if not cleanup then
begin
- t:= max(Gear^.Damage, Gear^.Health);
- Gear^.Damage:= t;
- if (((not SuddenDeathDmg) and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF))) then
- spawnHealthTagForHH(Gear, t);
+ if ((CurrentHedgehog = nil) or (Gear <> CurrentHedgehog^.Gear)) or (CurAmmoGear = nil) or (CurAmmoGear^.Kind <> gtKamikaze) then
+ Gear^.Hedgehog^.Team^.Clan^.Flawless:= false;
+ if not CheckCoordInWater(hwRound(Gear^.X), hwRound(Gear^.Y)) then
+ begin
+ t:= max(Gear^.Damage, Gear^.Health);
+ Gear^.Damage:= t;
+ if (((not SuddenDeathDmg) and (WaterOpacity < $FF)) or (SuddenDeathDmg and (SDWaterOpacity < $FF))) then
+ spawnHealthTagForHH(Gear, t);
+ end;
+
+ // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
+ // same stand for CheckHHDamage
+ if (Gear^.LastDamage <> nil) and (CurrentHedgehog <> nil) then
+ uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true)
+ else if CurrentHedgehog <> nil then
+ uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true);
+
+ inc(KilledHHs);
+ RecountTeamHealth(team);
+ if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0) and
+ //(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then
+ (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then
+ with CurrentHedgehog^ do
+ begin
+ inc(Team^.stats.AIKills);
+ FreeAndNilTexture(Team^.AIKillsTex);
+ Team^.AIKillsTex := RenderStringTex(ansistring(inttostr(Team^.stats.AIKills)), Team^.Clan^.Color, fnt16);
+ end
end;
- team:= Gear^.Hedgehog^.Team;
if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear = Gear) then
begin
AttackBar:= 0;
@@ -695,25 +723,6 @@
TeamGoneEffect(team^.Clan^.Teams[i]^)
end
end;
-
- // should be not CurrentHedgehog, but hedgehog of the last gear which caused damage to this hog
- // same stand for CheckHHDamage
- if (Gear^.LastDamage <> nil) and (CurrentHedgehog <> nil) then
- uStats.HedgehogDamaged(Gear, Gear^.LastDamage, 0, true)
- else if CurrentHedgehog <> nil then
- uStats.HedgehogDamaged(Gear, CurrentHedgehog, 0, true);
-
- inc(KilledHHs);
- RecountTeamHealth(team);
- if (CurrentHedgehog <> nil) and (CurrentHedgehog^.Effects[heResurrectable] <> 0) and
- //(Gear^.Hedgehog^.Effects[heResurrectable] = 0) then
- (Gear^.Hedgehog^.Team^.Clan <> CurrentHedgehog^.Team^.Clan) then
- with CurrentHedgehog^ do
- begin
- inc(Team^.stats.AIKills);
- FreeAndNilTexture(Team^.AIKillsTex);
- Team^.AIKillsTex := RenderStringTex(ansistring(inttostr(Team^.stats.AIKills)), Team^.Clan^.Color, fnt16);
- end
end;
with Gear^ do
begin
--- a/hedgewars/uTeams.pas Mon Dec 08 23:00:13 2014 +0300
+++ b/hedgewars/uTeams.pas Mon Dec 08 15:02:43 2014 -0500
@@ -854,9 +854,9 @@
with TeamsArray[i]^.Hedgehogs[h] do
begin
if Gear <> nil then
- DeleteGear(Gear);
+ DeleteGearStage(Gear, true);
if GearHidden <> nil then
- DeleteGear(GearHidden);
+ DeleteGearStage(GearHidden, true);
FreeAndNilTexture(NameTagTex);
FreeAndNilTexture(HealthTagTex);