Index: ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js =================================================================== --- ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js +++ ps/trunk/binaries/data/mods/public/gui/gamesetup/gamesetup.js @@ -1713,7 +1713,7 @@ let file = g_GameAttributes.mapPath + mapFile; let mapData = loadMapData(file); - if (!mapData.settings || filterFunc && !filterFunc(mapData.settings.Keywords || [])) + if (!mapData || !mapData.settings || filterFunc && !filterFunc(mapData.settings.Keywords || [])) continue; maps.push({ Index: ps/trunk/source/graphics/MapGenerator.cpp =================================================================== --- ps/trunk/source/graphics/MapGenerator.cpp +++ ps/trunk/source/graphics/MapGenerator.cpp @@ -334,14 +334,28 @@ // See CMapReader::UnpackTerrain, CMapReader::ParseTerrain for the reordering JS::Value CMapGeneratorWorker::LoadMapTerrain(ScriptInterface::CxPrivate* pCxPrivate, const VfsPath& filename) { + CMapGeneratorWorker* self = static_cast(pCxPrivate->pCBData); + JSContext* cx = self->m_ScriptInterface->GetContext(); + JSAutoRequest rq(cx); + if (!VfsFileExists(filename)) - throw PSERROR_File_OpenFailed(); + { + self->m_ScriptInterface->ReportError( + ("Terrain file \"" + filename.string8() + "\" does not exist!").c_str()); + + return JS::UndefinedValue(); + } CFileUnpacker unpacker; unpacker.Read(filename, "PSMP"); if (unpacker.GetVersion() < CMapIO::FILE_READ_VERSION) - throw PSERROR_File_InvalidVersion(); + { + self->m_ScriptInterface->ReportError( + ("Could not load terrain file \"" + filename.string8() + "\" too old version!").c_str()); + + return JS::UndefinedValue(); + } // unpack size ssize_t patchesPerSide = (ssize_t)unpacker.UnpackSize(); @@ -384,9 +398,6 @@ } } - CMapGeneratorWorker* self = static_cast(pCxPrivate->pCBData); - JSContext* cx = self->m_ScriptInterface->GetContext(); - JSAutoRequest rq(cx); JS::RootedValue returnValue(cx, JS::ObjectValue(*JS_NewPlainObject(cx))); self->m_ScriptInterface->SetProperty(returnValue, "height", heightmap); self->m_ScriptInterface->SetProperty(returnValue, "textureNames", textureNames); Index: ps/trunk/source/graphics/MapReader.cpp =================================================================== --- ps/trunk/source/graphics/MapReader.cpp +++ ps/trunk/source/graphics/MapReader.cpp @@ -1,4 +1,4 @@ -/* Copyright (C) 2017 Wildfire Games. +/* Copyright (C) 2019 Wildfire Games. * This file is part of 0 A.D. * * 0 A.D. is free software: you can redistribute it and/or modify @@ -102,7 +102,7 @@ // check oldest supported version if (file_format_version < FILE_READ_VERSION) - throw PSERROR_File_InvalidVersion(); + throw PSERROR_Game_World_MapLoadFailed("Could not load terrain file - too old version!"); // delete all existing entities if (pSimulation2) @@ -451,7 +451,7 @@ node_idx = entity_idx = 0; if (xmb_file.Load(g_VFS, xml_filename, "scenario") != PSRETURN_OK) - throw PSERROR_File_ReadFailed(); + throw PSERROR_Game_World_MapLoadFailed("Could not read map XML file!"); // define the elements and attributes that are frequently used in the XML file, // so we don't need to do lots of string construction and comparison when