# HG changeset patch # User Wuzzy # Date 1687946503 -7200 # Node ID d18261ddac4a9a1fa98debbeee6c442b406ec08e # Parent cf5c7fa711343cad9bfcce76fdeb134a99d7d2e4 Fix errors if passing bad script param to [Tech]Racer diff -r cf5c7fa71134 -r d18261ddac4a share/hedgewars/Data/Scripts/Multiplayer/Racer.lua --- a/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua Wed Jun 28 07:28:52 2023 +0200 +++ b/share/hedgewars/Data/Scripts/Multiplayer/Racer.lua Wed Jun 28 12:01:43 2023 +0200 @@ -191,22 +191,25 @@ TeamRope = true end if params["rounds"] ~= nil then - roundLimit = math.max(1, math.floor(tonumber(params["rounds"]))) + roundLimit = tonumber(params["rounds"]) if type(roundLimit) ~= "number" then roundLimit = 3 end + roundLimit = math.max(1, math.floor(roundLimit)) end if params["waypointradius"] ~= nil then - wpRad = math.max(WAYPOINT_RADIUS_MIN, math.floor(tonumber(params["waypointradius"]))) + wpRad = tonumber(params["waypointradius"]) if type(wpRad) ~= "number" then wpRad = 450 end + wpRad = math.max(WAYPOINT_RADIUS_MIN, math.floor(wpRad)) end if params["maxwaypoints"] ~= nil then - wpLimit = math.max(2, math.floor(tonumber(params["maxwaypoints"]))) + wpLimit = tonumber(params["maxwaypoints"]) if type(wpLimit) ~= "number" then wpLimit = 8 end + wpLimit = math.max(2, math.floor(wpLimit)) end end diff -r cf5c7fa71134 -r d18261ddac4a share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua --- a/share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua Wed Jun 28 07:28:52 2023 +0200 +++ b/share/hedgewars/Data/Scripts/Multiplayer/TechRacer.lua Wed Jun 28 12:01:43 2023 +0200 @@ -682,9 +682,10 @@ roundLimit = tonumber(params["rounds"]) - if (roundLimit == 0) or (roundLimit == nil) then + if roundLimit == nil then roundLimit = 3 end + roundLimit = math.max(1, math.floor(roundLimit)) if mapID == nil then mapID = 2 + GetRandom(7)