Clean up after LuaScript when tearing down the world.

This commit is contained in:
Paul Chote
2015-06-21 17:43:23 +01:00
parent e269a74b3e
commit f8205d3d22

View File

@@ -24,7 +24,7 @@ namespace OpenRA.Mods.Common.Scripting
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;
ScriptContext context;
@@ -46,10 +46,16 @@ namespace OpenRA.Mods.Common.Scripting
context.Tick(self);
}
public void Dispose()
bool disposed;
public void Disposing(Actor self)
{
if (disposed)
return;
if (context != null)
context.Dispose();
disposed = true;
}
public bool FatalErrorOccurred { get { return context.FatalErrorOccurred; } }