public Map LoadMap()
{
var tempMap = Map;
if (tempMap != null)
{
return(tempMap);
}
lock (SyncRoot) {
if (Map != null)
{
return(Map);
}
if (File.Exists(MapFileName))
{
try {
Map = MapUtility.Load(MapFileName, true);
} catch (Exception ex) {
Logger.Log(LogType.Error,
"World.LoadMap: Failed to load map ({0}): {1}",
MapFileName,
ex);
}
}
// or generate a default one
if (Map == null)
{
Server.Message("&WMap file is missing for world {0}&W. A new map has been created.", ClassyName);
Logger.Log(LogType.Warning,
"World.LoadMap: Map file missing for world {0}. Generating default flatgrass map.",
Name);
Map = FlatMapGen.MakeFlatgrass(128, 128, 64).Generate();
}
if (Map == null)
{
// should never happen, theoretically, unless FlatMapGen messes up
throw new NullReferenceException("World.LoadMap failed to produce a map file!");
}
return(Map);
}
}