ignore reservations being collected in worlds other than the one the OM is attached to.

This commit is contained in:
Chris Forbes
2011-03-05 11:09:56 +13:00
parent 7c6d35e318
commit 85fe83d608
2 changed files with 16 additions and 7 deletions

View File

@@ -364,6 +364,11 @@ namespace OpenRA
{ {
server = new Server.Server(modData, settings, map); server = new Server.Server(modData, settings, map);
JoinServer(IPAddress.Loopback.ToString(), settings.Server.ListenPort); JoinServer(IPAddress.Loopback.ToString(), settings.Server.ListenPort);
} }
public static bool IsCurrentWorld(World world)
{
return orderManager != null && orderManager.world == world;
}
} }
} }

View File

@@ -30,13 +30,17 @@ namespace OpenRA.Mods.RA
public IDisposable Reserve(Actor self, Actor forActor) public IDisposable Reserve(Actor self, Actor forActor)
{ {
reservedFor = forActor; reservedFor = forActor;
// NOTE: we really dont care about the GC eating DisposableActions that apply to a world *other* than
// the one we're playing in.
return new DisposableAction(() => reservedFor = null, return new DisposableAction(
() => Game.RunAfterTick(() => () => reservedFor = null,
{throw new InvalidOperationException("Attempted to finalize an undisposed DisposableAction. {0} ({1}) reserved {2} ({3})" () => Game.RunAfterTick(
.F(forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID));}) () => { if (Game.IsCurrentWorld( self.World )) throw new InvalidOperationException(
); "Attempted to finalize an undisposed DisposableAction. {0} ({1}) reserved {2} ({3})"
.F(forActor.Info.Name, forActor.ActorID, self.Info.Name, self.ActorID)); }));
} }
public static bool IsReserved(Actor a) public static bool IsReserved(Actor a)