Fixes for some random maps.

- Hellas_biome isn't a RM but as a JSON script it does load, and then
silently fails on mapgen. Explicitly fail.
- Fix player.js when a valid position cannot exist.
- Fix unknown.js when landscape isn't set in the settings.

Reported by: vladislavbelov
Refs #6180

Differential Revision: https://code.wildfiregames.com/D4147
This was SVN commit r25765.
This commit is contained in:
wraitii 2021-06-10 13:16:10 +00:00
parent b84e268a1f
commit 4de9c4c164
3 changed files with 10 additions and 3 deletions

View File

@ -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) ||

View File

@ -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();

View File

@ -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