When running a server, don't load minimap previews into memory.
This commit is contained in:
committed by
Pavel Penev
parent
8ee6957e6a
commit
ad122c8e32
@@ -28,6 +28,7 @@ namespace OpenRA
|
|||||||
public static readonly MapPreview UnknownMap = new MapPreview(null, null, MapGridType.Rectangular, null);
|
public static readonly MapPreview UnknownMap = new MapPreview(null, null, MapGridType.Rectangular, null);
|
||||||
public IReadOnlyDictionary<IReadOnlyPackage, MapClassification> MapLocations => mapLocations;
|
public IReadOnlyDictionary<IReadOnlyPackage, MapClassification> MapLocations => mapLocations;
|
||||||
readonly Dictionary<IReadOnlyPackage, MapClassification> mapLocations = new Dictionary<IReadOnlyPackage, MapClassification>();
|
readonly Dictionary<IReadOnlyPackage, MapClassification> mapLocations = new Dictionary<IReadOnlyPackage, MapClassification>();
|
||||||
|
public bool LoadPreviewImages = true;
|
||||||
|
|
||||||
readonly Cache<string, MapPreview> previews;
|
readonly Cache<string, MapPreview> previews;
|
||||||
readonly ModData modData;
|
readonly ModData modData;
|
||||||
|
|||||||
@@ -393,7 +393,7 @@ namespace OpenRA
|
|||||||
|
|
||||||
newData.SetCustomRules(modData, this, yaml);
|
newData.SetCustomRules(modData, this, yaml);
|
||||||
|
|
||||||
if (p.Contains("map.png"))
|
if (cache.LoadPreviewImages && p.Contains("map.png"))
|
||||||
using (var dataStream = p.GetStream("map.png"))
|
using (var dataStream = p.GetStream("map.png"))
|
||||||
newData.Preview = new Png(dataStream);
|
newData.Preview = new Png(dataStream);
|
||||||
|
|
||||||
@@ -435,6 +435,8 @@ namespace OpenRA
|
|||||||
spawns[j / 2] = new CPos(r.spawnpoints[j], r.spawnpoints[j + 1]);
|
spawns[j / 2] = new CPos(r.spawnpoints[j], r.spawnpoints[j + 1]);
|
||||||
newData.SpawnPoints = spawns;
|
newData.SpawnPoints = spawns;
|
||||||
newData.GridType = r.map_grid_type;
|
newData.GridType = r.map_grid_type;
|
||||||
|
if (cache.LoadPreviewImages)
|
||||||
|
{
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
newData.Preview = new Png(new MemoryStream(Convert.FromBase64String(r.minimap)));
|
newData.Preview = new Png(new MemoryStream(Convert.FromBase64String(r.minimap)));
|
||||||
@@ -444,6 +446,7 @@ namespace OpenRA
|
|||||||
Log.Write("debug", "Failed parsing mapserver minimap response: {0}", e);
|
Log.Write("debug", "Failed parsing mapserver minimap response: {0}", e);
|
||||||
newData.Preview = null;
|
newData.Preview = null;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
var playersString = Encoding.UTF8.GetString(Convert.FromBase64String(r.players_block));
|
var playersString = Encoding.UTF8.GetString(Convert.FromBase64String(r.players_block));
|
||||||
newData.Players = new MapPlayers(MiniYaml.FromString(playersString));
|
newData.Players = new MapPlayers(MiniYaml.FromString(playersString));
|
||||||
|
|||||||
@@ -83,6 +83,7 @@ namespace OpenRA.Server
|
|||||||
{
|
{
|
||||||
// HACK: The engine code *still* assumes that Game.ModData is set
|
// HACK: The engine code *still* assumes that Game.ModData is set
|
||||||
var modData = Game.ModData = new ModData(mods[modID], mods);
|
var modData = Game.ModData = new ModData(mods[modID], mods);
|
||||||
|
modData.MapCache.LoadPreviewImages = false; // PERF: Server doesn't need previews, save memory by not loading them.
|
||||||
modData.MapCache.LoadMaps();
|
modData.MapCache.LoadMaps();
|
||||||
|
|
||||||
settings.Map = modData.MapCache.ChooseInitialMap(settings.Map, new MersenneTwister());
|
settings.Map = modData.MapCache.ChooseInitialMap(settings.Map, new MersenneTwister());
|
||||||
|
|||||||
Reference in New Issue
Block a user