new signalReceived hook with better performance
signalReceived.YourComponent, with the checks in the lua-side this hook was being called too many times and it was using up to 10% cpu of the server
This commit is contained in:
@@ -574,21 +574,18 @@ namespace Barotrauma
|
|||||||
|
|
||||||
foreach (HookFunction hf in hookFunctions[name].Values)
|
foreach (HookFunction hf in hookFunctions[name].Values)
|
||||||
{
|
{
|
||||||
if (hf.name == name)
|
try
|
||||||
{
|
{
|
||||||
try
|
var result = env.lua.Call(hf.function, args);
|
||||||
|
if (result.IsNil() == false)
|
||||||
{
|
{
|
||||||
var result = env.lua.Call(hf.function, args);
|
return result;
|
||||||
if (result.IsNil() == false)
|
|
||||||
{
|
|
||||||
return result;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (Exception e)
|
|
||||||
{
|
|
||||||
env.HandleLuaException(e);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
catch (Exception e)
|
||||||
|
{
|
||||||
|
env.HandleLuaException(e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
|||||||
@@ -441,7 +441,9 @@ namespace Barotrauma.Items.Components
|
|||||||
#if SERVER
|
#if SERVER
|
||||||
if (!lastSignal.ContainsValue(connection.Name) || lastSignal[connection.Name] != signal.value)
|
if (!lastSignal.ContainsValue(connection.Name) || lastSignal[connection.Name] != signal.value)
|
||||||
{
|
{
|
||||||
GameMain.Lua.hook.Call("signalReceived", new object[] { signal, connection });
|
object[] obj = new object[] { signal, connection };
|
||||||
|
GameMain.Lua.hook.Call("signalReceived", obj);
|
||||||
|
GameMain.Lua.hook.Call("signalReceived." + item.prefab.Identifier, obj);
|
||||||
|
|
||||||
lastSignal[connection.Name] = signal.value;
|
lastSignal[connection.Name] = signal.value;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user