Fix noisy errors when joining hte lobby and someone is hosting a modded game.
Check for existence explicitly in the lobby GUI. It would probably be better to not trigger errors in the cache laoder/JSON code but instead print at the caller, depending, but that requires changing a lot more code. Reported by: Asger Fixes #5988 Differential Revision: https://code.wildfiregames.com/D3506 This was SVN commit r24821.
This commit is contained in:
parent
6b2f16bbc2
commit
1ae4f497e8
@ -175,7 +175,8 @@ function loadMapTypes()
|
||||
"Default": true,
|
||||
"Path": "maps/skirmishes/",
|
||||
"Suffix": ".xml",
|
||||
"GetData": Engine.LoadMapSettings
|
||||
"GetData": Engine.LoadMapSettings,
|
||||
"CheckIfExists": mapPath => Engine.FileExists(mapPath)
|
||||
},
|
||||
{
|
||||
"Name": "random",
|
||||
@ -183,7 +184,8 @@ function loadMapTypes()
|
||||
"Description": translate("Create a unique map with a different resource distribution each time. Freely select the number of players and teams."),
|
||||
"Path": "maps/random/",
|
||||
"Suffix": ".json",
|
||||
"GetData": mapPath => Engine.ReadJSONFile(mapPath + ".json")
|
||||
"GetData": mapPath => Engine.ReadJSONFile(mapPath + ".json"),
|
||||
"CheckIfExists": mapPath => Engine.FileExists(mapPath + ".json")
|
||||
},
|
||||
{
|
||||
"Name": "scenario",
|
||||
@ -191,7 +193,8 @@ function loadMapTypes()
|
||||
"Description": translate("A map with a predefined landscape and matchsettings."),
|
||||
"Path": "maps/scenarios/",
|
||||
"Suffix": ".xml",
|
||||
"GetData": Engine.LoadMapSettings
|
||||
"GetData": Engine.LoadMapSettings,
|
||||
"CheckIfExists": mapPath => Engine.FileExists(mapPath)
|
||||
}
|
||||
];
|
||||
}
|
||||
|
@ -93,8 +93,16 @@ class Game
|
||||
if (oldStanza.niceMapName != newStanza.niceMapName)
|
||||
{
|
||||
Engine.ProfileStart("niceMapName");
|
||||
displayData.mapName = escapeText(this.mapCache.translateMapName(newStanza.niceMapName));
|
||||
displayData.mapDescription = this.mapCache.getTranslatedMapDescription(newStanza.mapType, newStanza.mapName);
|
||||
if (this.mapCache.checkIfExists(newStanza.mapType, newStanza.mapName))
|
||||
{
|
||||
displayData.mapName = escapeText(this.mapCache.translateMapName(newStanza.niceMapName));
|
||||
displayData.mapDescription = this.mapCache.getTranslatedMapDescription(newStanza.mapType, newStanza.mapName);
|
||||
}
|
||||
else
|
||||
{
|
||||
displayData.mapName = escapeText(newStanza.niceMapName);
|
||||
displayData.mapDescription = "";
|
||||
}
|
||||
Engine.ProfileStop();
|
||||
}
|
||||
|
||||
|
@ -52,7 +52,10 @@ class GameDetails
|
||||
if (stanza.mapType != this.lastGame.mapType || stanza.mapName != this.lastGame.mapName)
|
||||
{
|
||||
this.sgMapName.caption = displayData.mapName;
|
||||
this.sgMapPreview.sprite = this.mapCache.getMapPreview(stanza.mapType, stanza.mapName);
|
||||
if (this.mapCache.checkIfExists(stanza.mapType, stanza.mapName))
|
||||
this.sgMapPreview.sprite = this.mapCache.getMapPreview(stanza.mapType, stanza.mapName);
|
||||
else
|
||||
this.sgMapPreview.sprite = this.mapCache.getMapPreview(stanza.mapType);
|
||||
}
|
||||
|
||||
{
|
||||
|
@ -8,6 +8,14 @@ class MapCache
|
||||
this.cache = {};
|
||||
}
|
||||
|
||||
checkIfExists(mapType, mapPath)
|
||||
{
|
||||
if (!mapPath || mapPath == "random")
|
||||
return true;
|
||||
|
||||
return g_Settings.MapTypes.find(type => type.Name == mapType).CheckIfExists(mapPath);
|
||||
}
|
||||
|
||||
getMapData(mapType, mapPath)
|
||||
{
|
||||
if (!mapPath || mapPath == "random")
|
||||
|
Loading…
Reference in New Issue
Block a user