Fixed error "Attempt to perform operations with resources owned by different script" that would sometimes happen when reloading lua
This commit is contained in:
@@ -21,22 +21,40 @@ namespace Barotrauma
|
|||||||
RegisterFunc<Fixture, Vector2, Vector2, float, float>();
|
RegisterFunc<Fixture, Vector2, Vector2, float, float>();
|
||||||
RegisterFunc<AIObjective, bool>();
|
RegisterFunc<AIObjective, bool>();
|
||||||
|
|
||||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(LuaCsAction), v => (LuaCsAction)(args =>
|
||||||
DataType.Function,
|
{
|
||||||
typeof(LuaCsAction),
|
if (v.Function.OwnerScript == Lua)
|
||||||
v => (LuaCsAction)(args => CallLuaFunction(v.Function, args)));
|
{
|
||||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(
|
CallLuaFunction(v.Function, args);
|
||||||
DataType.Function,
|
}
|
||||||
typeof(LuaCsFunc),
|
}));
|
||||||
v => (LuaCsFunc)(args => CallLuaFunction(v.Function, args)));
|
|
||||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(LuaCsFunc), v => (LuaCsFunc)(args =>
|
||||||
DataType.Function,
|
{
|
||||||
typeof(LuaCsCompatPatchFunc),
|
if (v.Function.OwnerScript == Lua)
|
||||||
v => (LuaCsCompatPatchFunc)((self, args) => CallLuaFunction(v.Function, self, args)));
|
{
|
||||||
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(
|
return CallLuaFunction(v.Function, args);
|
||||||
DataType.Function,
|
}
|
||||||
typeof(LuaCsPatchFunc),
|
return default;
|
||||||
v => (LuaCsPatchFunc)((self, args) => CallLuaFunction(v.Function, self, args)));
|
}));
|
||||||
|
|
||||||
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(LuaCsCompatPatchFunc), v => (LuaCsCompatPatchFunc)((self, args) =>
|
||||||
|
{
|
||||||
|
if (v.Function.OwnerScript == Lua)
|
||||||
|
{
|
||||||
|
return CallLuaFunction(v.Function, self, args);
|
||||||
|
}
|
||||||
|
return default;
|
||||||
|
}));
|
||||||
|
|
||||||
|
Script.GlobalOptions.CustomConverters.SetScriptToClrCustomConversion(DataType.Function, typeof(LuaCsPatchFunc), v => (LuaCsPatchFunc)((self, args) =>
|
||||||
|
{
|
||||||
|
if (v.Function.OwnerScript == Lua)
|
||||||
|
{
|
||||||
|
return CallLuaFunction(v.Function, self, args);
|
||||||
|
}
|
||||||
|
return default;
|
||||||
|
}));
|
||||||
|
|
||||||
#if CLIENT
|
#if CLIENT
|
||||||
RegisterAction<Microsoft.Xna.Framework.Graphics.SpriteBatch, GUICustomComponent>();
|
RegisterAction<Microsoft.Xna.Framework.Graphics.SpriteBatch, GUICustomComponent>();
|
||||||
|
|||||||
@@ -178,7 +178,7 @@ namespace Barotrauma
|
|||||||
{
|
{
|
||||||
// XXX: `lua` might be null if `LuaCsSetup.Stop()` is called while
|
// XXX: `lua` might be null if `LuaCsSetup.Stop()` is called while
|
||||||
// a patched function is still running.
|
// a patched function is still running.
|
||||||
if (Lua == null) return null;
|
if (Lua == null) { return null; }
|
||||||
|
|
||||||
lock (Lua)
|
lock (Lua)
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user