Fix ScriptContext crashing without a Tick function
This commit is contained in:
committed by
Matthias Mailänder
parent
6af14c16c9
commit
f2b3a9f837
@@ -176,10 +176,8 @@ namespace OpenRA.Scripting
|
|||||||
};
|
};
|
||||||
|
|
||||||
foreach (var fieldName in runtime.Globals.Keys)
|
foreach (var fieldName in runtime.Globals.Keys)
|
||||||
{
|
|
||||||
if (!allowedGlobals.Contains(fieldName.ToString()))
|
if (!allowedGlobals.Contains(fieldName.ToString()))
|
||||||
runtime.Globals[fieldName] = null;
|
runtime.Globals[fieldName] = null;
|
||||||
}
|
|
||||||
|
|
||||||
var forbiddenMath = new string[]
|
var forbiddenMath = new string[]
|
||||||
{
|
{
|
||||||
@@ -189,10 +187,8 @@ namespace OpenRA.Scripting
|
|||||||
|
|
||||||
var mathGlobal = (LuaTable)runtime.Globals["math"];
|
var mathGlobal = (LuaTable)runtime.Globals["math"];
|
||||||
foreach (var mathFunction in mathGlobal.Keys)
|
foreach (var mathFunction in mathGlobal.Keys)
|
||||||
{
|
|
||||||
if (forbiddenMath.Contains(mathFunction.ToString()))
|
if (forbiddenMath.Contains(mathFunction.ToString()))
|
||||||
mathGlobal[mathFunction] = null;
|
mathGlobal[mathFunction] = null;
|
||||||
}
|
|
||||||
|
|
||||||
// Register globals
|
// Register globals
|
||||||
runtime.Globals["EngineDir"] = Platform.EngineDir;
|
runtime.Globals["EngineDir"] = Platform.EngineDir;
|
||||||
@@ -237,7 +233,7 @@ namespace OpenRA.Scripting
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
tick = (LuaFunction)runtime.Globals["Tick"];
|
tick = runtime.Globals["Tick"] as LuaFunction;
|
||||||
}
|
}
|
||||||
|
|
||||||
void LogDebugMessage(string message)
|
void LogDebugMessage(string message)
|
||||||
@@ -304,7 +300,7 @@ namespace OpenRA.Scripting
|
|||||||
|
|
||||||
public void Tick()
|
public void Tick()
|
||||||
{
|
{
|
||||||
if (FatalErrorOccurred || disposed)
|
if (FatalErrorOccurred || disposed || tick == null)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
try
|
try
|
||||||
|
|||||||
Reference in New Issue
Block a user