Fix turn reaction not working properly after turn
authorWuzzy <Wuzzy2@mail.ru>
Tue, 04 Sep 2018 17:57:48 +0200
changeset 13763 6fd56a26e8b8
parent 13762 72a8c0d63d80
child 13764 f5eea79da795
Fix turn reaction not working properly after turn
hedgewars/uGears.pas
hedgewars/uStats.pas
hedgewars/uTeams.pas
--- a/hedgewars/uGears.pas	Tue Sep 04 16:52:51 2018 +0200
+++ b/hedgewars/uGears.pas	Tue Sep 04 17:57:48 2018 +0200
@@ -63,8 +63,8 @@
 var delay: LongWord;
     delay2: LongWord;
     step: (stInit, stDelay, stChDmg, stSweep, stTurnStats, stChWin1,
-    stTurnReact, stAfterDelay, stChWin2, stWater, stChWin3, stHealth,
-    stSpawn, stNTurn);
+    stTurnReact, stAfterDelay, stChWin2, stWater, stChWin3,
+    stHealth, stSpawn, stNTurn);
     NewTurnTick: LongWord;
     //SDMusic: shortstring;
 
@@ -307,6 +307,7 @@
         if (not bBetweenTurns) and (not isInMultiShoot) then
             begin
             uStats.TurnReaction;
+            uStats.TurnStatsReset;
             inc(step)
             end
         else
--- a/hedgewars/uStats.pas	Tue Sep 04 16:52:51 2018 +0200
+++ b/hedgewars/uStats.pas	Tue Sep 04 17:57:48 2018 +0200
@@ -42,6 +42,7 @@
 procedure Skipped;
 procedure TurnStats;
 procedure TurnReaction;
+procedure TurnStatsReset;
 procedure SendStats;
 procedure hedgehogFlight(Gear: PGear; time: Longword);
 procedure declareAchievement(id, teamname, location: shortstring; value: LongInt);
@@ -157,11 +158,6 @@
                     MaxStepDamageGiven:= StepDamageGiven;
                 if StepKills > MaxStepKills then
                     MaxStepKills:= StepKills;
-                StepKills:= 0;
-                StepDamageRecv:= 0;
-                StepDamageGiven:= 0;
-                StepPoisoned:= false;
-                StepDied:= false;
                 end;
 
 // Write into the death log which clans died in this turn,
@@ -198,16 +194,6 @@
     ClanDeathLog:= newEntry;
     end;
 
-Kills:= 0;
-KillsClan:= 0;
-DamageClan:= 0;
-DamageTurn:= 0;
-HitTargets:= 0;
-PoisonClan:= 0;
-PoisonTurn:= 0;
-AmmoUsedCount:= 0;
-AmmoDamagingUsed:= false;
-isTurnSkipped:= false;
 end;
 
 procedure TurnReaction;
@@ -284,6 +270,33 @@
     end;
 end;
 
+procedure TurnStatsReset;
+var t, i: LongInt;
+begin
+for t:= 0 to Pred(TeamsCount) do // send even on zero turn
+    with TeamsArray[t]^ do
+        for i:= 0 to cMaxHHIndex do
+            with Hedgehogs[i].stats do
+                begin
+                StepKills:= 0;
+                StepDamageRecv:= 0;
+                StepDamageGiven:= 0;
+                StepPoisoned:= false;
+                StepDied:= false;
+                end;
+
+Kills:= 0;
+KillsClan:= 0;
+DamageClan:= 0;
+DamageTurn:= 0;
+HitTargets:= 0;
+PoisonClan:= 0;
+PoisonTurn:= 0;
+AmmoUsedCount:= 0;
+AmmoDamagingUsed:= false;
+isTurnSkipped:= false;
+end;
+
 procedure AmmoUsed(am: TAmmoType);
 begin
 inc(AmmoUsedCount);
--- a/hedgewars/uTeams.pas	Tue Sep 04 16:52:51 2018 +0200
+++ b/hedgewars/uTeams.pas	Tue Sep 04 17:57:48 2018 +0200
@@ -80,6 +80,7 @@
     begin
     TurnStats();
     TurnReaction();
+    TurnStatsReset();
     end;
 
 if not TeamsGameOver then