diff --git a/binaries/data/mods/public/maps/random/rmgen-common/player.js b/binaries/data/mods/public/maps/random/rmgen-common/player.js index 51598391e6..38d12f50e2 100644 --- a/binaries/data/mods/public/maps/random/rmgen-common/player.js +++ b/binaries/data/mods/public/maps/random/rmgen-common/player.js @@ -689,7 +689,9 @@ function playerPlacementRandom(playerIDs, constraints = undefined) for (let i = 0; i < getNumPlayers(); ++i) { - let position = pickRandom(area.getPoints()); + const position = pickRandom(area.getPoints()); + if (!position) + return undefined; // Minimum distance between initial bases must be a quarter of the map diameter if (locations.some(loc => loc.distanceToSquared(position) < playerMinDistSquared) || diff --git a/binaries/data/mods/public/maps/random/unknown.js b/binaries/data/mods/public/maps/random/unknown.js index a6f3e54f9c..fdb581cdbf 100644 --- a/binaries/data/mods/public/maps/random/unknown.js +++ b/binaries/data/mods/public/maps/random/unknown.js @@ -107,7 +107,8 @@ var g_StartingWalls = true; function createUnknownMap() { - global["unknown" + g_MapSettings.Landscape || pickRandom([...unknownMapFunctions.land, ...unknownMapFunctions.naval])](); + const landscape = g_MapSettings.Landscape || pickRandom([...unknownMapFunctions.land, ...unknownMapFunctions.naval]); + global["unknown" + landscape](); paintUnknownMapBasedOnHeight(); diff --git a/source/ps/GameSetup/GameSetup.cpp b/source/ps/GameSetup/GameSetup.cpp index 3ac6a2af0a..f52a66c22c 100644 --- a/source/ps/GameSetup/GameSetup.cpp +++ b/source/ps/GameSetup/GameSetup.cpp @@ -1231,7 +1231,11 @@ bool Autostart(const CmdLineArgs& args) { // JSON loaded ok - copy script name over to game attributes std::wstring scriptFile; - Script::GetProperty(rq, settings, "Script", scriptFile); + if (!Script::GetProperty(rq, settings, "Script", scriptFile)) + { + LOGERROR("Autostart: random map '%s' data has no 'Script' property.", utf8_from_wstring(scriptPath)); + throw PSERROR_Game_World_MapLoadFailed("Error reading random map script.\nCheck application log for details."); + } Script::SetProperty(rq, attrs, "script", scriptFile); // RMS filename } else