share/hedgewars/Data/Scripts/Multiplayer/Racer.lua
changeset 15488 70aba717485a
parent 15418 ca8896b9c7c6
child 15490 91c972f126b7
--- a/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua	Sat Oct 26 02:36:08 2019 +0300
+++ b/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua	Sat Oct 26 21:59:42 2019 +0200
@@ -101,6 +101,7 @@
 local wpCol = {}
 local wpActive = {}
 local wpRad = 450
+local WAYPOINT_RADIUS_MIN = 40
 local wpCount = 0
 local wpLimit = 8
 
@@ -193,7 +194,7 @@
         end
     end
     if params["waypointradius"] ~= nil then
-        wpRad = math.max(40, math.floor(tonumber(params["waypointradius"])))
+        wpRad = math.max(WAYPOINT_RADIUS_MIN, math.floor(tonumber(params["waypointradius"])))
         if type(wpRad) ~= "number" then
              wpRad = 450
         end
@@ -635,6 +636,20 @@
 end
 
 function onGameStart()
+
+	-- Adjust pre-defined waypoints in scaled drawn maps
+	if MapGen == mgDrawn and MapFeatureSize ~= 12 and specialPointsCount > 0 then
+		local landW = RightX - LeftX + 1
+		local landH = LAND_HEIGHT - TopY
+		-- Reposition pre-defined waypoints
+        	for i = 0, (specialPointsCount-1) do
+        		specialPointsX[i] = LeftX + div(specialPointsX[i] * landW, 4096)
+        		specialPointsY[i] = TopY + div(specialPointsY[i] * landH, 2048)
+		end
+		-- Scale waypoint size
+		wpRad = math.max(WAYPOINT_RADIUS_MIN, div(wpRad * landW, 4096))
+	end
+
 	if ClansCount >= 2 then
 		SendGameResultOff()
 		SendRankingStatsOff()