From b9ebf04a6a9a1332b07a16f13f2c78f56e777f28 Mon Sep 17 00:00:00 2001 From: Evil Factory <36804725+evilfactory@users.noreply.github.com> Date: Thu, 14 Jul 2022 20:55:39 -0300 Subject: [PATCH] fix undefined identifiers in patches overriding each other --- .../BarotraumaShared/SharedSource/LuaCs/LuaCsHook.cs | 12 ++++++++++-- .../SharedSource/LuaCs/LuaCsHookCompat.cs | 12 ++++++++++-- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHook.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHook.cs index c542a9272..0516f6344 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHook.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHook.cs @@ -327,7 +327,11 @@ namespace Barotrauma if (hookPrefixMethods.TryGetValue(funcAddr, out HashSet<(string, LuaCsFunc, ACsMod)> methodSet)) { - methodSet.RemoveWhere(tuple => tuple.Item1 == identifier); + if (identifier != "") + { + methodSet.RemoveWhere(tuple => tuple.Item1 == identifier); + } + methodSet.Add((identifier, patch, owner)); } else if (patch != null) @@ -355,7 +359,11 @@ namespace Barotrauma if (hookPostfixMethods.TryGetValue(funcAddr, out HashSet<(string, LuaCsFunc, ACsMod)> methodSet)) { - methodSet.RemoveWhere(tuple => tuple.Item1 == identifier); + if (identifier != "") + { + methodSet.RemoveWhere(tuple => tuple.Item1 == identifier); + } + methodSet.Add((identifier, patch, owner)); } else if (patch != null) diff --git a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHookCompat.cs b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHookCompat.cs index e3795e7fc..dee8089e3 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHookCompat.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/LuaCs/LuaCsHookCompat.cs @@ -185,7 +185,11 @@ namespace Barotrauma if (compatHookPrefixMethods.TryGetValue(funcAddr, out HashSet<(string, LuaCsPatch, ACsMod)> methodSet)) { - methodSet.RemoveWhere(tuple => tuple.Item1 == identifier); + if (identifier != "") + { + methodSet.RemoveWhere(tuple => tuple.Item1 == identifier); + } + methodSet.Add((identifier, patch, owner)); } else if (patch != null) @@ -213,7 +217,11 @@ namespace Barotrauma if (compatHookPostfixMethods.TryGetValue(funcAddr, out HashSet<(string, LuaCsPatch, ACsMod)> methodSet)) { - methodSet.RemoveWhere(tuple => tuple.Item1 == identifier); + if (identifier != "") + { + methodSet.RemoveWhere(tuple => tuple.Item1 == identifier); + } + methodSet.Add((identifier, patch, owner)); } else if (patch != null)