Fix rare Lua error message spam in Space Invasion
authorWuzzy <Wuzzy2@mail.ru>
Sat, 07 Jul 2018 18:37:21 +0200
changeset 13448 93ba1826b8c2
parent 13446 dd2e51f7303d
child 13449 6aca4f45ab0a
Fix rare Lua error message spam in Space Invasion
ChangeLog.txt
share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua
--- a/ChangeLog.txt	Fri Jul 06 17:16:01 2018 +0200
+++ b/ChangeLog.txt	Sat Jul 07 18:37:21 2018 +0200
@@ -22,6 +22,9 @@
  * Don't play “Missed” and “Laugh” taunt when those don't make sense
  * Fix retreat timer not turning red for some weapons
 
+Space Invation:
+ * Fix rare Lua error message spam at end of game
+
 Lua API:
  + New call: Retreat(time [, respectGetAwayTimeFactor): Force current turn into retreating mode
  + New call: GetAmmoTimer(gearUid, ammoType): Returns current set timer for given ammoType and hog gear in ms. Returns nil for non-timerable ammo
--- a/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua	Fri Jul 06 17:16:01 2018 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Space_Invasion.lua	Sat Jul 07 18:37:21 2018 +0200
@@ -2183,7 +2183,7 @@
 		end
 
 	-- if player is hit by circle bazooka
-	elseif (GetGearType(gear) == gtShell) then
+	elseif (GetGearType(gear) == gtShell) and (CurrentHedgehog ~= nil) then
 
 		dist = GetDistFromGearToGear(gear, CurrentHedgehog)
 
@@ -2223,6 +2223,9 @@
 -- collision detection for player entering a circle
 function CheckDistances()
 
+	if not CurrentHedgehog then
+		return
+	end
 	--nw WriteLnToConsole("Start of CheckDistances()")
 
 	for i = 0,(vCCount-1) do