Dispose SequenceSet when we're done with it.
Utility rules that do something on a map and exit are left without explicit disposing, as they will be cleaned up immediately anyway.
This commit is contained in:
@@ -187,13 +187,8 @@ namespace OpenRA
|
|||||||
Cursor.SetCursor(null);
|
Cursor.SetCursor(null);
|
||||||
BeforeGameStart();
|
BeforeGameStart();
|
||||||
|
|
||||||
Map map;
|
|
||||||
|
|
||||||
using (new PerfTimer("PrepareMap"))
|
|
||||||
map = ModData.PrepareMap(mapUID);
|
|
||||||
|
|
||||||
using (new PerfTimer("NewWorld"))
|
using (new PerfTimer("NewWorld"))
|
||||||
OrderManager.World = new World(ModData, map, OrderManager, type);
|
OrderManager.World = new World(mapUID, ModData, OrderManager, type);
|
||||||
|
|
||||||
OrderManager.World.GameOver += FinishBenchmark;
|
OrderManager.World.GameOver += FinishBenchmark;
|
||||||
|
|
||||||
|
|||||||
@@ -149,7 +149,7 @@ namespace OpenRA
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public class Map : IReadOnlyFileSystem
|
public class Map : IReadOnlyFileSystem, IDisposable
|
||||||
{
|
{
|
||||||
public const int SupportedMapFormat = 11;
|
public const int SupportedMapFormat = 11;
|
||||||
public const int CurrentMapFormat = 12;
|
public const int CurrentMapFormat = 12;
|
||||||
@@ -1417,5 +1417,10 @@ namespace OpenRA
|
|||||||
|
|
||||||
return modData.Translation.GetString(key, args);
|
return modData.Translation.GetString(key, args);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void Dispose()
|
||||||
|
{
|
||||||
|
Sequences.Dispose();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -214,12 +214,6 @@ namespace OpenRA
|
|||||||
yield return mapPackage;
|
yield return mapPackage;
|
||||||
}
|
}
|
||||||
|
|
||||||
public IEnumerable<Map> EnumerateMapsWithoutCaching(MapClassification classification = MapClassification.System)
|
|
||||||
{
|
|
||||||
foreach (var mapPackage in EnumerateMapPackagesWithoutCaching(classification))
|
|
||||||
yield return new Map(modData, mapPackage);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void QueryRemoteMapDetails(string repositoryUrl, IEnumerable<string> uids, Action<MapPreview> mapDetailsReceived = null, Action<MapPreview> mapQueryFailed = null)
|
public void QueryRemoteMapDetails(string repositoryUrl, IEnumerable<string> uids, Action<MapPreview> mapDetailsReceived = null, Action<MapPreview> mapQueryFailed = null)
|
||||||
{
|
{
|
||||||
var queryUids = uids.Distinct()
|
var queryUids = uids.Distinct()
|
||||||
|
|||||||
@@ -188,12 +188,13 @@ namespace OpenRA
|
|||||||
|
|
||||||
bool wasLoadingGameSave;
|
bool wasLoadingGameSave;
|
||||||
|
|
||||||
internal World(ModData modData, Map map, OrderManager orderManager, WorldType type)
|
internal World(string mapUID, ModData modData, OrderManager orderManager, WorldType type)
|
||||||
{
|
{
|
||||||
this.modData = modData;
|
this.modData = modData;
|
||||||
Type = type;
|
Type = type;
|
||||||
OrderManager = orderManager;
|
OrderManager = orderManager;
|
||||||
Map = map;
|
using (new PerfTimer("PrepareMap"))
|
||||||
|
Map = modData.PrepareMap(mapUID);
|
||||||
|
|
||||||
if (string.IsNullOrEmpty(modData.Manifest.DefaultOrderGenerator))
|
if (string.IsNullOrEmpty(modData.Manifest.DefaultOrderGenerator))
|
||||||
throw new InvalidDataException("mod.yaml must define a DefaultOrderGenerator");
|
throw new InvalidDataException("mod.yaml must define a DefaultOrderGenerator");
|
||||||
@@ -212,7 +213,7 @@ namespace OpenRA
|
|||||||
SharedRandom = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);
|
SharedRandom = new MersenneTwister(orderManager.LobbyInfo.GlobalSettings.RandomSeed);
|
||||||
LocalRandom = new MersenneTwister();
|
LocalRandom = new MersenneTwister();
|
||||||
|
|
||||||
ModelCache = modData.ModelSequenceLoader.CacheModels(map, modData, map.Rules.ModelSequences);
|
ModelCache = modData.ModelSequenceLoader.CacheModels(Map, modData, Map.Rules.ModelSequences);
|
||||||
|
|
||||||
var worldActorType = type == WorldType.Editor ? SystemActors.EditorWorld : SystemActors.World;
|
var worldActorType = type == WorldType.Editor ? SystemActors.EditorWorld : SystemActors.World;
|
||||||
WorldActor = CreateActor(worldActorType.ToString(), new TypeDictionary());
|
WorldActor = CreateActor(worldActorType.ToString(), new TypeDictionary());
|
||||||
@@ -241,7 +242,7 @@ namespace OpenRA
|
|||||||
MapTitle = Map.Title
|
MapTitle = Map.Title
|
||||||
};
|
};
|
||||||
|
|
||||||
RulesContainTemporaryBlocker = map.Rules.Actors.Any(a => a.Value.HasTraitInfo<ITemporaryBlockerInfo>());
|
RulesContainTemporaryBlocker = Map.Rules.Actors.Any(a => a.Value.HasTraitInfo<ITemporaryBlockerInfo>());
|
||||||
gameSettings = Game.Settings.Game;
|
gameSettings = Game.Settings.Game;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -612,6 +613,8 @@ namespace OpenRA
|
|||||||
if (Type == WorldType.Shellmap)
|
if (Type == WorldType.Shellmap)
|
||||||
OrderManager.Dispose();
|
OrderManager.Dispose();
|
||||||
|
|
||||||
|
Map.Dispose();
|
||||||
|
|
||||||
Game.FinishBenchmark();
|
Game.FinishBenchmark();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -97,7 +97,7 @@ namespace OpenRA.Mods.Common.UtilityCommands
|
|||||||
if (package == null)
|
if (package == null)
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
var testMap = new Map(modData, package);
|
using (var testMap = new Map(modData, package))
|
||||||
TestMap(testMap, modData);
|
TestMap(testMap, modData);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -70,6 +70,7 @@ namespace OpenRA.Mods.Common.Widgets.Logic
|
|||||||
|
|
||||||
Action<string> afterSave = uid =>
|
Action<string> afterSave = uid =>
|
||||||
{
|
{
|
||||||
|
map.Dispose();
|
||||||
Game.LoadEditor(uid);
|
Game.LoadEditor(uid);
|
||||||
|
|
||||||
Ui.CloseWindow();
|
Ui.CloseWindow();
|
||||||
|
|||||||
Reference in New Issue
Block a user