Merge pull request #8529 from pchote/fix-mission-quit-desync

Use INotifyActorDisposing to dispose LuaScript as part of the world disposal.
This commit is contained in:
abcdefg30
2015-06-21 21:35:02 +02:00

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Scripting
public object Create(ActorInitializer init) { return new LuaScript(this); } public object Create(ActorInitializer init) { return new LuaScript(this); }
} }
public sealed class LuaScript : ITick, IWorldLoaded, IDisposable public class LuaScript : ITick, IWorldLoaded, INotifyActorDisposing
{ {
readonly LuaScriptInfo info; readonly LuaScriptInfo info;
ScriptContext context; ScriptContext context;
@@ -46,10 +46,16 @@ namespace OpenRA.Mods.Common.Scripting
context.Tick(self); context.Tick(self);
} }
public void Dispose() bool disposed;
public void Disposing(Actor self)
{ {
if (disposed)
return;
if (context != null) if (context != null)
context.Dispose(); context.Dispose();
disposed = true;
} }
public bool FatalErrorOccurred { get { return context.FatalErrorOccurred; } } public bool FatalErrorOccurred { get { return context.FatalErrorOccurred; } }