TechRacer: Fix gears not spawning on turn start when player pressed control right at start
authorWuzzy <Wuzzy2@mail.ru>
Thu, 26 Jul 2018 18:01:32 +0200
changeset 13558 af92481415ef
parent 13555 43b72629d453
child 13559 3c562f52609c
TechRacer: Fix gears not spawning on turn start when player pressed control right at start The activationStage was horribly programmed and heavily relied on timer. There was a sweet spot at turn start that if you managed to push a key right at the start of turn, you skip the Ready phase and the activationStage would advance, causing the gear spawning code to be skipped. This fix greatly simplies the spawning phase.
ChangeLog.txt
share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua
--- a/ChangeLog.txt	Thu Jul 26 13:03:35 2018 +0200
+++ b/ChangeLog.txt	Thu Jul 26 18:01:32 2018 +0200
@@ -22,6 +22,9 @@
 Highlander:
  * Fix all hogs getting teleport after hog placement phase
 
+TechRacer:
+ * Fix rare bug causing crates and other objects not appearing on start of turn
+
 Continental supplies:
  + Continents are now selected before the game starts
  + Continents give hog different start health
--- a/share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua	Thu Jul 26 13:03:35 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua	Thu Jul 26 18:01:32 2018 +0200
@@ -710,50 +710,46 @@
 
 function HandleFreshMapCreation()
 
-	-- the boom stage, boom girders, reset ammo, and delete other map objects
-	if activationStage == 1 then
+	if activationStage ~= 1 then
+		return
+	end
 
-		ClearMap()
-		activationStage = activationStage + 1
+	-- the boom stage, boom girders, reset ammo, and delete other map objects
+	ClearMap()
 
 	-- the creation stage, place girders and needed gears, grant ammo
-	elseif activationStage == 2 then
-
-		InterpretPoints()
+	InterpretPoints()
 
-		-- these are from onParameters()
-		if (mapID == nil) or (mapID == 0) then
-			LoadMap(2000)
-		else
-			LoadMap(mapID)
+	-- these are from onParameters()
+	if (mapID == nil) or (mapID == 0) then
+		LoadMap(2000)
+	else
+		LoadMap(mapID)
+	end
+
+	if gameOver then
+		for i = 0,(wpCount-1) do
+			SetVisualGearValues(wpCirc[wpCount], wpX[wpCount], wpY[wpCount], 164, 224, 1, 10, 0, wpRad, 5, wpCol[wpCount])
 		end
 
-                if gameOver then
-		        for i = 0,(wpCount-1) do
-                                SetVisualGearValues(wpCirc[wpCount], wpX[wpCount], wpY[wpCount], 164, 224, 1, 10, 0, wpRad, 5, wpCol[wpCount])
-                        end
-
-                else
-		        for i = 0,(wpCount-1) do
-		        	DeleteVisualGear(wpCirc[i])
-		        end
-		        wpCount = 0
+        else
+		for i = 0,(wpCount-1) do
+			DeleteVisualGear(wpCirc[i])
+		end
+		wpCount = 0
 
-		        for i = 1, techCount-1 do
-			        CallBob(techX[i],techY[i])
-		        end
-                end
-
-		activationStage = 200
-		--runOnHogs(RestoreHog)
+		for i = 1, techCount-1 do
+			CallBob(techX[i],techY[i])
+		end
+	end
 
-		if ufoFuel == 2000 then
-			SetAmmoDescriptionAppendix(amJetpack, loc("On this map you get infinite fuel."))
-		elseif ufoFuel ~= nil and ufoFuel ~= 0 then
-			SetAmmoDescriptionAppendix(amJetpack, string.format(loc("On this map you get %d%% fuel."), div(ufoFuel, 20)))
-		end
+	if ufoFuel == 2000 then
+		SetAmmoDescriptionAppendix(amJetpack, loc("On this map you get infinite fuel."))
+	elseif ufoFuel ~= nil and ufoFuel ~= 0 then
+		SetAmmoDescriptionAppendix(amJetpack, string.format(loc("On this map you get %d%% fuel."), div(ufoFuel, 20)))
+	end
 
-	end
+	activationStage = 200
 
 end
 
@@ -1054,7 +1050,7 @@
 
         TryRepositionHogs()
 
-		activationStage = 2
+		activationStage = 1
 		HandleFreshMapCreation()
 
 end
@@ -1158,7 +1154,7 @@
         end
 
 
-	if activationStage < 10 then
+	if activationStage < 200 then
 		HandleFreshMapCreation()
 
                 if not gameOver and gameBegun and not racerActive then
@@ -1182,8 +1178,7 @@
 
                         -- if the gamehas started put the player in the middle of the first
                         --waypoint that was placed
-                        --if activationStage == 200 then
-						if gameBegun == true then
+                        if gameBegun == true then
                                 AddCaption(loc("Good to go!"))
                                 racerActive = true
                                 trackTime = 0