Fix #106 turn list into an array before looping through hooks

This commit is contained in:
EvilFactory
2022-09-23 11:42:49 -03:00
parent 460a5f7a85
commit 245e76cd8d

View File

@@ -759,12 +759,12 @@ namespace Barotrauma
T lastResult = default;
var hooksToRemove = new List<string>();
foreach ((var key, var tuple) in hookFunctions[name])
var hooks = hookFunctions[name].ToArray();
foreach ((string key, var tuple) in hooks)
{
if (tuple.Item2 != null && tuple.Item2.IsDisposed)
{
hooksToRemove.Add(key);
hookFunctions[name].Remove(key);
continue;
}
@@ -804,10 +804,6 @@ namespace Barotrauma
luaCs.HandleException(e, LuaCsMessageOrigin.Unknown);
}
}
foreach (var key in hooksToRemove)
{
hookFunctions[name].Remove(key);
}
return lastResult;
}