# HG changeset patch # User Wuzzy # Date 1572119982 -7200 # Node ID 70aba717485a6de5487438ac87a46e822dae4ded # Parent 4cc9ec732392b1a0790b866da5597fbf98310403 Racer: Reposition and resize predefined waypoints in scaled drawn maps Previously, predefined waypoints broke when using any but the default drawn map size. diff -r 4cc9ec732392 -r 70aba717485a share/hedgewars/Data/Scripts/Multiplayer/Racer.lua --- 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()