From 7dfccab05d8b2ee0f2006407d1d20aa4bd9147d6 Mon Sep 17 00:00:00 2001 From: Evil Factory <36804725+evilfactory@users.noreply.github.com> Date: Sat, 19 Mar 2022 11:05:26 -0300 Subject: [PATCH] better distinguish better client and server Lua and fixed crash when force stopping the game via alt f4 --- .../SharedSource/Lua/LuaSetup.cs | 21 ++++++++++++------- 1 file changed, 13 insertions(+), 8 deletions(-) diff --git a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaSetup.cs b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaSetup.cs index bde3a0290..742f46439 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaSetup.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaSetup.cs @@ -56,7 +56,11 @@ namespace Barotrauma string errorMsg = subStr; if (i == 0) - errorMsg = "[LUA ERROR] " + errorMsg; +#if SERVER + errorMsg = "[SV LUA ERROR] " + errorMsg; +#else + errorMsg = "[CL LUA ERROR] " + errorMsg; +#endif DebugConsole.ThrowError(errorMsg); @@ -95,11 +99,13 @@ namespace Barotrauma GameServer.Log("[LUA] " + subStr, ServerLog.MessageType.ServerMessage); } #endif - - DebugConsole.NewMessage(message.ToString(), Color.MediumPurple); - } +#if SERVER + DebugConsole.NewMessage(message.ToString(), Color.MediumPurple); +#else + DebugConsole.NewMessage(message.ToString(), Color.Purple); +#endif } public DynValue DoString(string code, Table globalContext = null, string codeStringFriendly = null) @@ -202,11 +208,10 @@ namespace Barotrauma public void Stop() { - if (harmony != null) - harmony.UnpatchAll(); + harmony?.UnpatchAll(); - game.Stop(); - hook.Call("stop", new object[] { }); + game?.Stop(); + hook?.Call("stop", new object[] { }); hook = null; game = null;