Fix buggy behaviour when setting TurnTimeLeft through Retreat
authorWuzzy <Wuzzy2@mail.ru>
Mon, 03 Sep 2018 00:03:06 +0200
changeset 13743 d7b72ea8d136
parent 13742 cb2857f55130
child 13744 4b79bac864be
Fix buggy behaviour when setting TurnTimeLeft through Retreat
hedgewars/uScript.pas
share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua
--- a/hedgewars/uScript.pas	Sun Sep 02 22:05:45 2018 +0200
+++ b/hedgewars/uScript.pas	Mon Sep 03 00:03:06 2018 +0200
@@ -2018,9 +2018,10 @@
         else
             respectFactor:= True;
         if respectFactor then
-            TurnTimeLeft:= (time * cGetAwayTime) div 100
+            PendingTurnTimeLeft:= (time * cGetAwayTime) div 100
         else
-            TurnTimeLeft:= time;
+            PendingTurnTimeLeft:= time;
+        isPendingTurnTimeLeft:= true;
         if ((CurrentHedgehog <> nil) and (CurrentHedgehog^.Gear <> nil)) then
             begin
             CurrentHedgehog^.Gear^.State:= CurrentHedgehog^.Gear^.State or gstAttacked;
--- a/share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua	Sun Sep 02 22:05:45 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua	Mon Sep 03 00:03:06 2018 +0200
@@ -53,9 +53,11 @@
 	-- Set attacked state to prevent “Boring” sound to be played
 	SetState(CurrentHedgehog, bor(GetState(CurrentHedgehog), gstAttacked))
 	--set escape time
-	SetTurnTimeLeft(GetAwayTime*10*seconds)
-	if TurnTimeLeft > 0 then
-		Retreat(TurnTimeLeft, false)
+	local escapeTime = GetAwayTime*10*seconds
+	if escapeTime > 0 then
+		Retreat(escapeTime, false)
+	else
+		SetTurnTimeLeft(escapeTime)
 	end
  end