Construction Mode: Fix Lua error spam when using time box with filters on map
authorWuzzy <almikes@aol.com>
Tue, 10 Oct 2017 16:13:44 +0200
changeset 12687 b7fd7ab8ddf9
parent 12686 4e5e725f2c56
child 12688 047c5b7ec422
Construction Mode: Fix Lua error spam when using time box with filters on map
ChangeLog.txt
share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua
--- a/ChangeLog.txt	Tue Oct 10 03:08:00 2017 +0200
+++ b/ChangeLog.txt	Tue Oct 10 16:13:44 2017 +0200
@@ -77,6 +77,7 @@
  * Special tools like structure placer now have their own proper descriptions (instead of Air Attack description, etc.)
  * Costs for weapon and utility crates were all equal
  * Remove airplane cursor
+ * Fix Lua errors when hog goes to time travel while any filter is in map
  * Many other fixes and tweaks
 
 Racer and TechRacer:
--- a/share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua	Tue Oct 10 03:08:00 2017 +0200
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Construction_Mode.lua	Tue Oct 10 16:13:44 2017 +0200
@@ -625,6 +625,9 @@
 function CheckProximity(gear)
 
 	dist = GetDistFromGearToXY(gear, GetX(strucGear[tempID]), GetY(strucGear[tempID]))
+	if not dist then
+		return
+	end
 
 	-- calculate my real radius if I am an aura
 	if strucCircType[tempID] == 0 then
@@ -1080,6 +1083,9 @@
 function GetDistFromGearToXY(gear, g2X, g2Y)
 
 	g1X, g1Y = GetGearPosition(gear)
+	if not g1X then
+		return nil
+	end
 	q = g1X - g2X
 	w = g1Y - g2Y