Use SetTurnTimeLeft and SetReadyTimeLeft in all scripts
authorWuzzy <Wuzzy2@mail.ru>
Sun, 02 Sep 2018 21:26:44 +0200
changeset 13742 2bb7141496a9
parent 13741 b3b55b03d499
child 13743 e8f26bc793d9
Use SetTurnTimeLeft and SetReadyTimeLeft in all scripts
share/hedgewars/Data/Maps/Control/map.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/dragon.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/epil.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/queen.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua
share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/united.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua
share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua
share/hedgewars/Data/Missions/Challenge/Basic_Training_-_Sniper_Rifle.lua
share/hedgewars/Data/Missions/Challenge/User_Mission_-_RCPlane_Challenge.lua
share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua
share/hedgewars/Data/Missions/Scenario/User_Mission_-_Dangerous_Ducklings.lua
share/hedgewars/Data/Missions/Scenario/User_Mission_-_Spooky_Tree.lua
share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork.lua
share/hedgewars/Data/Missions/Training/Basic_Training_-_Flying_Saucer.lua
share/hedgewars/Data/Scripts/Animate.lua
share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua
share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua
share/hedgewars/Data/Scripts/Multiplayer/WxW.lua
share/hedgewars/Data/Scripts/SpeedShoppa.lua
share/hedgewars/Data/Scripts/TargetPractice.lua
--- a/share/hedgewars/Data/Maps/Control/map.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Maps/Control/map.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -424,7 +424,7 @@
 					end
 				end			
 			end
-			TurnTimeLeft = 1
+			SetTurnTimeLeft(1)
 		end
 
 	end
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/backstab.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -576,7 +576,7 @@
 
 function AfterHogDeadAnim()
   freshDead = nil
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
 end
 
 --------------------------Anim skip functions--------------------------
@@ -587,7 +587,7 @@
   AddAmmo(speakerHog, amSwitch, 100)
   SetGearMessage(speakerHog, 0)
   SetState(speakerHog, 0)
-  TurnTimeLeft = -1
+  SetTurnTimeLeft(cMaxTurnTime)
   ShowMission(loc("Backstab"), loc("The food bites back"), loc("Defeat the cannibals"), 1, 4000)
   SpawnCrates()
 end
@@ -602,7 +602,7 @@
   SetGearMessage(CurrentHedgehog, 0)
   SetState(CurrentHedgehog, 0)
   SpawnCrates()
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
 end
 
 function SkipWave2DeadAnim()
@@ -1106,7 +1106,7 @@
 function onNewTurn()
   tmpVar = 0
   if AnimInProgress() then
-    TurnTimeLeft = -1
+    SetTurnTimeLeft(cMaxTurnTime)
     return
   end
 
@@ -1131,7 +1131,7 @@
     else
       SetGearMessage(CurrentHedgehog, 0)
       --AnimSwitchHog(natives[leaksNum])
-      TurnTimeLeft = -1
+      SetTurnTimeLeft(cMaxTurnTime)
     end
   else
     if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == loc("Natives") then
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/dragon.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/dragon.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -362,7 +362,7 @@
   end
   FollowGear(native)
   AddNewEvent(CheckGearsDead, {{crates[1], crates[2]}}, PutCrates, {2}, 0) 
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
   ShowMission(loc("Dragon's Lair"), loc("Obstacle course"), loc("In order to get to the other side, you need to get rid of the crates first.") .. "|" ..
                                                   loc("As the ammo is sparse, you might want to reuse ropes while mid-air.") .. "|" ..
                                                   loc("The enemy can't move but it might be a good idea to stay out of sight!") .. "|" ..
@@ -381,7 +381,7 @@
 function AfterKillAnim()
   if not cyborgsKilledBeforeCrates then
     PutWeaponCrates()
-    TurnTimeLeft = TurnTime
+    SetTurnTimeLeft(TurnTime)
     AddEvent(CheckCyborgsDead, {}, DoCyborgsDead, {}, 0)
     ShowMission(loc("Dragon's Lair"), loc("The Slaughter"), loc("Kill the aliens!").."|"..loc("Mines time: 5 seconds"), 1, 2000)
   end
@@ -396,7 +396,7 @@
 function AfterKilledAnim()
   -- Final mission segment with the portal gun
   HideHedge(cyborg)
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
   SetGearMessage(native, 0)
   SpawnSupplyCrate(1184, 399, amPortalGun, 100)
   SpawnSupplyCrate(2259, 755, amTeleport, 2)
@@ -745,7 +745,7 @@
       AddAmmo(CurrentHedgehog, amSniperRifle, 1)
       AddAmmo(CurrentHedgehog, amDEagle, 1)
     end
-    TurnTimeLeft = 30000
+    SetTurnTimeLeft(30000)
   elseif GetHogTeamName(CurrentHedgehog) == loc("011101001") then
     EndTurn(true)
   end
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/enemy.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -676,7 +676,7 @@
 
 function onNewTurn()
   if AnimInProgress() then
-    TurnTimeLeft = -1
+    SetTurnTimeLeft(cMaxTurnTime)
     return
   end
   if playersDeadFresh then
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/epil.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/epil.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -484,14 +484,14 @@
 
 function onNewTurn()
   if AnimInProgress() then
-    TurnTimeLeft = -1
+    SetTurnTimeLeft(cMaxTurnTime)
     return
   end
   -- Don't allow player to play with traitor, except when it is the final hog left
   if CurrentHedgehog == traitor and not IsEveryoneExceptTraitorDead() then
     EndTurn(true)
   else
-    TurnTimeLeft = -1
+    SetTurnTimeLeft(cMaxTurnTime)
   end
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/family.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -295,7 +295,7 @@
   AddNewEvent(CheckOutOfCluster, {}, DoOutOfCluster, {}, 1)
   AddNewEvent(CheckOutOfGrenade, {}, DoOutOfGrenade, {}, 1)
 --  AddNewEvent(CheckNeedToHide, {}, DoNeedToHide, {}, 1)
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
   ShowMission(loc("Family Reunion"), loc("Hostage Situation"), loc("Save the princess! All your hogs must survive!|Hint: Kill the cyborgs first! Use the ammo very carefully!|Hint: You might want to spare a girder for cover!"), 1, 7000)
 end
 
@@ -636,7 +636,7 @@
 
 function onNewTurn()
   if AnimInProgress() then
-    TurnTimeLeft = -1
+    SetTurnTimeLeft(cMaxTurnTime)
     return
   end
   if CurrentHedgehog == cyborg then
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/first_blood.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -546,7 +546,7 @@
 
 function DoCratesColled()
   RemoveEventFunc(CheckTimesUp)
-  TurnTimeLeft = -1
+  SetTurnTimeLeft(cMaxTurnTime)
   AddCaption(loc("As the challenge was completed, Leaks A Lot set foot on the ground..."))
 end
 
@@ -573,7 +573,7 @@
   challengeFailed = true
   deleteCrate = true
   DeleteGear(crates[1])
-  TurnTimeLeft = -1
+  SetTurnTimeLeft(cMaxTurnTime)
   AddCaption(loc("And so happened that Leaks A Lot failed to complete the challenge! He landed, pressured by shame ..."))
   AddEvent(CheckChallengeFailed, {}, DoChallengeFailed, {}, 0)
 end
@@ -658,7 +658,7 @@
 function StartChallenge(time)
   cratesCollected = 0
   PutCrate(1)
-  TurnTimeLeft = time
+  SetTurnTimeLeft(time)
   ShowMission(loc("First Blood"), loc("The Crate Frenzy"), loc("Collect the crates within the time limit!|If you fail, you'll have to try again."), 1, 5000)
 end
 
@@ -684,11 +684,11 @@
 end
 
 function SetTime(time)
-  TurnTimeLeft = time
+  SetTurnTimeLeft(time)
 end
 
 function ResetTurnTime()
-  TurnTimeLeft = tTime
+  SetTurnTimeLeft(tTime)
   tTime = -1
 end
 
@@ -751,7 +751,7 @@
 
 function onGameStart()
   progress = tonumber(GetCampaignVar("Progress"))
-  TurnTimeLeft = -1
+  SetTurnTimeLeft(cMaxTurnTime)
   FollowGear(youngh)
 	ShowMission(loc("A Classic Fairytale"), loc("First Blood"), loc("Finish your training|Hint: Animations can be skipped with the [Precise] key."), -amSkip, 0)
   HideHog(cannibal)
@@ -846,7 +846,7 @@
   end
   SwitchHog(youngh)
   FollowGear(youngh)
-  TurnTimeLeft = -1
+  SetTurnTimeLeft(cMaxTurnTime)
 end
 
 function onGearDamage(gear, damage)
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/journey.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -197,7 +197,7 @@
   AddEvent(CheckFailedCourse, {}, DoFailedCourse, {}, 0)
   SetGearMessage(leaks, 0)
   TurnsLeft = 12
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
   ShowMission(loc("The Journey Back"), loc("Collateral Damage"),
     loc("Save the princess by collecting the crate in under 12 turns!") .. "|" ..
     loc("Mines time: 3 seconds"), 0, 6000)
@@ -230,7 +230,7 @@
   stage = endStage
   SwitchHog(leaks)
   SetGearMessage(leaks, 0)
-  TurnTimeLeft = -1
+  SetTurnTimeLeft(cMaxTurnTime)
   ShowMission(loc("The Journey Back"), loc("Collateral Damage II"), loc("Save Fell From Heaven!"), 1, 4000)
   AddEvent(CheckLost, {}, DoLost, {}, 0)
   AddEvent(CheckWon, {}, DoWon, {}, 0)
@@ -242,7 +242,7 @@
   SwitchHog(leaks)
   SetGearMessage(leaks, 0)
   SetGearMessage(dense, 0)
-  TurnTimeLeft = -1
+  SetTurnTimeLeft(cMaxTurnTime)
   ShowMission(loc("The Journey Back"), loc("Collateral Damage II"), loc("Save Fell From Heaven!"), 1, 4000)
   AddEvent(CheckLost, {}, DoLost, {}, 0)
   AddEvent(CheckWon, {}, DoWon, {}, 0)
@@ -258,7 +258,7 @@
 
 function AfterStartAnim()
   SetGearMessage(leaks, 0)
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
   local goal = loc("Get the crate on the other side of the island.")
   local hint = loc("Hint: You might want to stay out of sight and take all the crates ...")
   local stuck = loc("If you get stuck, use your Desert Eagle or restart the mission!")
@@ -1188,15 +1188,15 @@
 
 function onNewTurn()
   if AnimInProgress() then
-    TurnTimeLeft = -1
+    SetTurnTimeLeft(cMaxTurnTime)
   elseif victory then
     EndTurn(true)
   elseif stage == endStage and CurrentHedgehog ~= leaks then
     AnimSwitchHog(leaks)
     SetGearMessage(leaks, 0)
-    TurnTimeLeft = -1
+    SetTurnTimeLeft(cMaxTurnTime)
   elseif GetHogTeamName(CurrentHedgehog) ~= loc("Natives") then
-    TurnTimeLeft = 20000
+    SetTurnTimeLeft(20000)
   else
     TurnsLeft = TurnsLeft - 1
     if TurnsLeft >= 1 then
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/queen.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/queen.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -492,7 +492,7 @@
   SetHealth(SpawnHealthCrate(519, 1519), 25)
   SetHealth(SpawnHealthCrate(826, 895), 25)
   SpawnSupplyCrate(701, 1046, amGirder, 3)
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
 end
 
 function SkipAnim(anim)
@@ -513,7 +513,7 @@
   SetGearMessage(CurrentHedgehog, 0)
   HideHedge(enemy)
   ShowMission(loc("Long Live The Queen"), loc("Coward"), loc("The leader escaped. Defeat the rest of the aliens!"), 1, 0)
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
 end
 
 function AfterLeaderDeadAnim()
@@ -858,7 +858,7 @@
 
 function onNewTurn()
   if AnimInProgress() then
-    TurnTimeLeft = -1
+    SetTurnTimeLeft(cMaxTurnTime)
     return
   end
   if GetHogTeamName(CurrentHedgehog) == loc("011101001") then
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/shadow.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -189,7 +189,7 @@
   end
   stage = spyStage
   ShowMission(loc("The Shadow Falls"), loc("Play with me!"), loc("Kill the cannibal!").."|"..loc("Both your hedgehogs must survive."), 1, 6000)
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
 end
 
 
@@ -223,7 +223,7 @@
   SwitchHog(dense)
   SetGearMessage(dense, 0)
   SetGearMessage(leaks, 0)
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
   ShowMission(loc("The Shadow Falls"), loc("Why do you not like me?"), loc("Obliterate them!|Hint: You might want to take cover...").."|"..loc("Both your hedgehogs must survive."), 1, 6000)
 end
 
@@ -330,7 +330,7 @@
   AddAmmo(cannibals[9], amFirePunch, 0)
   AddAmmo(cannibals[9], amBaseballBat, 0)
   SetGearMessage(leaks, 0)
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
   AddEvent(CheckStronglingsDead, {}, DoStronglingsDeadAttacked, {}, 0)
   SwitchHog(leaks)
   AnimWait(dense, 1)
@@ -893,7 +893,7 @@
   AddAmmo(cannibals[9], amShotgun, 2)
   SetGearMessage(leaks, 0)
   SetGearMessage(dense, 0)
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
 end
 
 function DoStronglingsDead()
@@ -1091,17 +1091,17 @@
 
 function onNewTurn()
   if AnimInProgress() then
-    TurnTimeLeft = -1
+    SetTurnTimeLeft(cMaxTurnTime)
   elseif stage == cyborgStage then
     if CurrentHedgehog ~= dense then
       EndTurn(true)
     else
-      TurnTimeLeft = -1
+      SetTurnTimeLeft(cMaxTurnTime)
     end
   elseif stage == acceptedReturnStage then
     SwitchHog(dense)
     FollowGear(dense)
-    TurnTimeLeft = -1
+    SetTurnTimeLeft(cMaxTurnTime)
   end
 end
 
--- a/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/united.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Classic_Fairytale/united.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -66,13 +66,13 @@
 --------------------------Anim skip functions--------------------------
 function AfterHogDeadAnim()
   freshDead = nil
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
 end
 
 function AfterStartAnim()
   local goal = loc("Defeat the cannibals!|")
   local chiefgoal = loc("Try to protect the chief! You won't lose if he dies, but it is advised that he survives.")
-  TurnTimeLeft = TurnTime
+  SetTurnTimeLeft(TurnTime)
   ShowMission(loc("United We Stand"), loc("Invasion"), goal .. chiefgoal, 1, 6000)
 end
 
@@ -532,7 +532,7 @@
 
 function onNewTurn()
   if AnimInProgress() then
-    TurnTimeLeft = -1
+    SetTurnTimeLeft(cMaxTurnTime)
     return
   end
   if freshDead ~= nil and GetHogTeamName(CurrentHedgehog) == loc("Natives") then
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/cosmos.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -306,7 +306,7 @@
 			getReadyForRumble = false
 		else
 			if guard1.keepTurning then
-				TurnTimeLeft = -1
+				SetTurnTimeLeft(cMaxTurnTime)
 			end
 		end
 	elseif not onHeroDeath() and CurrentHedgehog == director.gear or CurrentHedgehog == doctor.gear then
@@ -468,7 +468,7 @@
 			SaveCampaignVar("HeroHealth",GetHealth(hero.gear))
 		end
 		AnimCaption(hero.gear,loc("Welcome to the moon!"))
-		TurnTimeLeft = -1
+		SetTurnTimeLeft(cMaxTurnTime)
 		SaveCampaignVar("HeroHealth", GetHealth(hero.gear))
 		SaveCampaignVar("Planet", "moon")
 		SaveCampaignVar("UnlockedMissions", "3")
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/death02.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -108,7 +108,7 @@
 	battleStarted = true
 	if firstTurn then
 		-- Generous ready time in first turn to more time to read the mission panel
-		ReadyTimeLeft = 35000
+		SetReadyTimeLeft(35000)
 		firstTurn = false
 	end
 	if CurrentHedgehog ~= hero.gear then
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/desert01.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -213,9 +213,9 @@
 	if CurrentHedgehog ~= hero.gear and not heroIsInBattle then
 		AnimSwitchHog(hero.gear)
 		getReady(hero.gear)
-		TurnTimeLeft = -1
+		SetTurnTimeLeft(cMaxTurnTime)
 	elseif CurrentHedgehog == hero.gear and not heroIsInBattle then
-		TurnTimeLeft = -1
+		SetTurnTimeLeft(cMaxTurnTime)
 	elseif (CurrentHedgehog == smuggler2.gear or CurrentHedgehog == smuggler3.gear) and ongoingBattle == 1 then
 		AnimSwitchHog(smuggler1.gear)
 		getReady(smuggler1.gear)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit02.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -242,10 +242,10 @@
 				return
 			end
 		end
-		TurnTimeLeft = 20000
+		SetTurnTimeLeft(20000)
 		wind()
 	elseif not inBattle and CurrentHedgehog == hero.gear then
-		TurnTimeLeft = -1
+		SetTurnTimeLeft(cMaxTurnTime)
 		wind()
 	else
 		EndTurn(true)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/fruit03.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -145,14 +145,14 @@
 	if CurrentHedgehog == hero.gear then
 		if firstTurn then
 			-- Unique game rule in this mission: First turn has more time
-			TurnTimeLeft = 25000
+			SetTurnTimeLeft(25000)
 			-- Generous ready time on first turn to give more time to read
-			ReadyTimeLeft = 35000
+			SetReadyTimeLeft(35000)
 			battleStarted = true
 			firstTurn = false
 		end
 		if lastWeaponUsed == amSkip then
-			TurnTimeLeft = TurnTime + timeLeft
+			SetTurnTimeLeft(TurnTime + timeLeft)
 		end
 		timeLeft = 0
 		heroTurns = heroTurns + 1
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice01.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -240,7 +240,7 @@
 	if not heroVisitedAntiFlyArea and CurrentHedgehog ~= hero.gear then
 		EndTurn(true)
 	elseif not heroVisitedAntiFlyArea and CurrentHedgehog == hero.gear then
-		TurnTimeLeft = -1
+		SetTurnTimeLeft(cMaxTurnTime)
 	elseif not heroAtFinalStep and (CurrentHedgehog == bandit1.gear or CurrentHedgehog == bandit4.gear or CurrentHedgehog == bandit5.gear) then
 		AnimSwitchHog(hero.gear)
 		EndTurn(true)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/ice02.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -262,7 +262,7 @@
 			end
 			local message 
 			if TurnTimeLeft <= 22000 then
-				TurnTimeLeft = TurnTimeLeft + 8000
+				SetTurnTimeLeft(TurnTimeLeft + 8000)
 				totalTime = totalTime + 8000
 				PlaySound(sndExtraTime)
 				message = loc("Got 1 more saucer and 8 more seconds added to the clock")
@@ -273,7 +273,7 @@
 		else
 			SetVisualGearValues(wp.gear, wp.x,wp.y, 20, 200, 0, 0, 100, radius, 3, GREEN)
 			if TurnTimeLeft <= 16000 then
-				TurnTimeLeft = TurnTimeLeft + 6000
+				SetTurnTimeLeft(TurnTimeLeft + 6000)
 				totalTime = totalTime + 6000
 				if currentWaypoint ~= 1 then
 					PlaySound(sndExtraTime)
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon01.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -245,7 +245,7 @@
 	-- rounds start if hero got his weapons or got near the enemies
 	if CurrentHedgehog == hero.gear then
 		if not weaponsAcquired and not battleZoneReached then
-			TurnTimeLeft = -1
+			SetTurnTimeLeft(cMaxTurnTime)
 		end
 	elseif CurrentHedgehog == minion1.gear or CurrentHedgehog == minion2.gear or CurrentHedgehog == minion3.gear then
 		if not battleZoneReached then
--- a/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Campaign/A_Space_Adventure/moon02.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -115,7 +115,7 @@
 				lose()
 			end
 			SetWeapon(amRope)
-			TurnTimeLeft = runner.places[currentPosition].turnTime + previousTimeLeft
+			SetTurnTimeLeft(runner.places[currentPosition].turnTime + previousTimeLeft)
 			previousTimeLeft = 0
 		end
 	end
--- a/share/hedgewars/Data/Missions/Challenge/Basic_Training_-_Sniper_Rifle.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Challenge/Basic_Training_-_Sniper_Rifle.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -194,7 +194,7 @@
 		else
 			-- ... or just lower the timer by 1.
 			-- Reset the time left to stop the timer
-			TurnTimeLeft = time_goal
+			SetTurnTimeLeft(time_goal)
 		end
         end_timer = end_timer - 20
 	end
--- a/share/hedgewars/Data/Missions/Challenge/User_Mission_-_RCPlane_Challenge.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Challenge/User_Mission_-_RCPlane_Challenge.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -279,7 +279,7 @@
 end
 
 function onNewTurn()
-	TurnTimeLeft = -1
+	SetTurnTimeLeft(cMaxTurnTime)
 end
 
 function onGearAdd(gear)
--- a/share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Challenge/User_Mission_-_That_Sinking_Feeling.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -86,7 +86,7 @@
 
 
 function onNewTurn()
-	TurnTimeLeft = -1
+	SetTurnTimeLeft(cMaxTurnTime)
 end
 
 function onGameTick()
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Dangerous_Ducklings.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Dangerous_Ducklings.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -114,7 +114,7 @@
 		if (CurrentHedgehog ~= nil) and (CurrentHedgehog == instructor) then
 			if endTimer >= 3000 then
 				--SetHealth(instructor,0)
-				TurnTimeLeft = 1
+				SetTurnTimeLeft(1)
 				DismissTeam(loc("Bloody Rookies"))
 			end
 			ShowMission(loc("Dangerous Ducklings"), loc("MISSION FAILED"), loc("You've failed. Try again."), -amRope, 5000);
@@ -136,14 +136,14 @@
 			gameLost = true
 		elseif (gear == instructor) and (GetY(gear) > WaterLine) then
 			HogSay(player, loc("See ya!"), SAY_THINK)
-			TurnTimeLeft = 3000
+			SetTurnTimeLeft(3000)
 			awardAchievement(loc("Naughty Ninja"))
 			DismissTeam(loc("Blue Team"))
 			gameWon = true
 		elseif gear == enemy then
 			HogSay(player, loc("Enjoy the swim..."), SAY_THINK)
 			gameWon = true
-			TurnTimeLeft = 3000
+			SetTurnTimeLeft(3000)
 		end
 
 	end
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Spooky_Tree.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Spooky_Tree.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -140,11 +140,11 @@
 function onGearDelete(gear)
 
 	if gear == GirderCrate then
-		TurnTimeLeft = TurnTimeLeft + 30000
+		SetTurnTimeLeft(TurnTimeLeft + 30000)
 	end
 
 	if GetGearType(gear) == gtCase then
-		TurnTimeLeft = TurnTimeLeft + 5000
+		SetTurnTimeLeft(TurnTimeLeft + 5000)
 	end
 
 	if (gear == enemy) and (GameOver == false) then
--- a/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Scenario/User_Mission_-_Teamwork.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -104,7 +104,7 @@
 	end
 
 	if GetGearType(gear) == gtCase then
-		TurnTimeLeft = TurnTimeLeft + 5000
+		SetTurnTimeLeft(TurnTimeLeft + 5000)
 	end
 	-- Note: The victory sequence is done automatically by Hedgewars
 	if  ( ((gear == player) or (gear == p2)) and (GameOver == false)) then
--- a/share/hedgewars/Data/Missions/Training/Basic_Training_-_Flying_Saucer.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Missions/Training/Basic_Training_-_Flying_Saucer.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -198,7 +198,7 @@
 	SendStat(siCustomAchievement, loc("Good job!"))
 	SendStat(siPlayerKills, "0", loc("Hogonauts"))
 
-	TurnTimeLeft = 0
+	SetTurnTimeLeft(0)
 	EndGame()
 end,
 }
@@ -504,7 +504,7 @@
 
 function onGameTick20()
 	if (TurnTimeLeft < 1500000 and not Objective) then
-		TurnTimeLeft = TurnTime
+		SetTurnTimeLeft(TurnTime)
 	end
 	if Check then
 		CheckTimer = CheckTimer - 20
--- a/share/hedgewars/Data/Scripts/Animate.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Animate.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -310,7 +310,7 @@
     skipping = false
     return true
   else
-    TurnTimeLeft = -1
+    SetTurnTimeLeft(cMaxTurnTime)
     if Animate(AnimList[1]) == true then
       RemoveAnim()
     end
--- a/share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Continental_supplies.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -53,7 +53,7 @@
 	-- Set attacked state to prevent “Boring” sound to be played
 	SetState(CurrentHedgehog, bor(GetState(CurrentHedgehog), gstAttacked))
 	--set escape time
-	TurnTimeLeft = GetAwayTime*10*seconds
+	SetTurnTimeLeft(GetAwayTime*10*seconds)
 	if TurnTimeLeft > 0 then
 		Retreat(TurnTimeLeft, false)
 	end
@@ -1212,7 +1212,7 @@
 				CS.HOG_HEALTH=GetHealth(CurrentHedgehog)
 			end
 
-			TurnTimeLeft=100000
+			SetTurnTimeLeft(100000)
 
 			AddCaption(string.format(CS.SELECT_WEP_INFORMATION_SHORT, GetHogTeamName(CurrentHedgehog)), capcolDefault, capgrpGameState)
 			AddCaption(loc("No continent selected"), GetClanColor(GetHogClan(CurrentHedgehog)), capgrpAmmoinfo)
--- a/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/HedgeEditor.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -3785,7 +3785,7 @@
 	-- regardless of our other ammo, give stuff that is useful for editing
 	SetEditingWeps(100)
 	if GetHogLevel(CurrentHedgehog) == 0 then
-		TurnTimeLeft = cMaxTurnTime
+		SetTurnTimeLeft(cMaxTurnTime)
 	else
 		SkipTurn() -- skip the computer's turn
 	end
--- a/share/hedgewars/Data/Scripts/Multiplayer/WxW.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/WxW.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -962,7 +962,7 @@
 		SetInputMask(0xFFFFFFFF)
 		AddCaption(loc("Configuration accepted."), msgColorTech, capgrpMessage)
 		if GetGameFlag(gfPlaceHog) then
-			TurnTimeLeft = PlacementTime
+			SetTurnTimeLeft(PlacementTime)
 			AddAmmo(CurrentHedgehog, amTeleport, 100)
 			SetWeapon(amTeleport)
 			AddCaption(
@@ -972,7 +972,7 @@
 			)
 			roundN = 2
 		else
-			TurnTimeLeft = TurnTime
+			SetTurnTimeLeft(TurnTime)
 			AddCaption(string.format(loc("Let's go, %s!"), GetHogTeamName(CurrentHedgehog)), capcolDefault, capgrpMessage2)
 			roundN = 100
 			wallsLeft = #wTouched
@@ -1280,7 +1280,7 @@
 		if roundN < 2 then
 			SetWeapon(amSkip)
 			AddAmmo(CurrentHedgehog, amTeleport, 0)
-			TurnTimeLeft = -1
+			SetTurnTimeLeft(cMaxTurnTime)
 			SetInputMask(0)
 		end
 		if roundN == 2 then
@@ -1337,7 +1337,7 @@
 	end
 
 	if roundN == 1 then
-		TurnTimeLeft = -1
+		SetTurnTimeLeft(cMaxTurnTime)
 		SetInputMask(0)
 		allowCrate = false
 		UpdateMenu()
--- a/share/hedgewars/Data/Scripts/SpeedShoppa.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Scripts/SpeedShoppa.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -175,7 +175,7 @@
 				local time = startTime - endTime
 				SendStat(siPlayerKills, tostring(time), params.teamName)
 				SendStat(siCustomAchievement, string.format(loc("You have finished the challenge in %.3f s."), (time/1000)))
-				TurnTimeLeft = 0
+				SetTurnTimeLeft(0)
 			else
 				SendStat(siGameResult, loc("Challenge failed!"))
 				SendStat(siPointType, loc("crate(s)"))
--- a/share/hedgewars/Data/Scripts/TargetPractice.lua	Sun Sep 02 20:57:33 2018 +0200
+++ b/share/hedgewars/Data/Scripts/TargetPractice.lua	Sun Sep 02 21:26:44 2018 +0200
@@ -208,7 +208,7 @@
 				generateStats()
 				EndGame()
 			else
-				TurnTimeLeft = time_goal
+				SetTurnTimeLeft(time_goal)
 			end
 	   	     end_timer = end_timer - 20
 		end