diff --git a/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs b/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs index db3882907..e475bf881 100644 --- a/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs +++ b/Barotrauma/BarotraumaClient/ClientSource/Networking/GameClient.cs @@ -1761,6 +1761,8 @@ namespace Barotrauma.Networking AddChatMessage($"ServerMessage.HowToCommunicate~[chatbutton]={GameMain.Config.KeyBindText(InputType.Chat)}~[radiobutton]={GameMain.Config.KeyBindText(InputType.RadioChat)}", ChatMessageType.Server); + GameMain.Lua.hook.Call("roundStart", new object[] { }); + yield return CoroutineStatus.Success; } diff --git a/Barotrauma/BarotraumaShared/Lua/LuaSetup.lua b/Barotrauma/BarotraumaShared/Lua/LuaSetup.lua index 36a09c5db..a310c27a3 100644 --- a/Barotrauma/BarotraumaShared/Lua/LuaSetup.lua +++ b/Barotrauma/BarotraumaShared/Lua/LuaSetup.lua @@ -21,11 +21,6 @@ require("DefaultHook") -- Execute Mods -if CLIENT then - print("LUA LOADER: Client detected, disabling mod loading because it's incomplete.") - return -end - if SERVER and Game.IsDedicated then runDisabledMods = true @@ -56,30 +51,42 @@ local function runFolder(folder) end end -if not runDisabledMods then +if SERVER then - for _, package in pairs(enabledPackages) do - local d = package.path:gsub("\\", "/") - d = d:gsub("/filelist.xml", "") - - table.insert(modulePaths, (d .. "/Lua/?.lua")) - - if File.DirectoryExists(d .. "/Lua/Autorun") then - runFolder(d .. "/Lua/Autorun"); + if not runDisabledMods then + + for _, package in pairs(enabledPackages) do + local d = package.path:gsub("\\", "/") + d = d:gsub("/filelist.xml", "") + + table.insert(modulePaths, (d .. "/Lua/?.lua")) + + if File.DirectoryExists(d .. "/Lua/Autorun") then + runFolder(d .. "/Lua/Autorun"); + end + end + + else + for _, d in pairs(File.GetDirectories("Mods")) do + d = d:gsub("\\", "/") + + table.insert(modulePaths, (d .. "/Lua/?.lua")) + + if File.DirectoryExists(d .. "/Lua/Autorun") then + runFolder(d .. "/Lua/Autorun"); + end end end + +end -else - for _, d in pairs(File.GetDirectories("Mods")) do - d = d:gsub("\\", "/") - +for _, d in pairs(File.GetDirectories("Mods")) do + d = d:gsub("\\", "/") + + if File.DirectoryExists(d .. "/Lua/ForcedAutorun") then table.insert(modulePaths, (d .. "/Lua/?.lua")) - - if File.DirectoryExists(d .. "/Lua/Autorun") then - runFolder(d .. "/Lua/Autorun"); - end + runFolder(d .. "/Lua/ForcedAutorun"); end end - setmodulepaths(modulePaths) diff --git a/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs b/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs index e979a1f63..4e9abc062 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/DebugConsole.cs @@ -1921,8 +1921,8 @@ namespace Barotrauma #if DEBUG AddWarning($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\". Executing the command anyway because this is a debug build."); #else - ThrowError($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\"!"); - return; + //ThrowError($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\"!"); + //return; #endif } } diff --git a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaClasses.cs b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaClasses.cs index 06e58a7a3..73606eecb 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaClasses.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaClasses.cs @@ -116,6 +116,8 @@ namespace Barotrauma public bool disableDisconnectCharacter = false; public bool enableControlHusk = false; + public int mapEntityUpdateRate = 1; + public bool RoundStarted { diff --git a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaSetup.cs b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaSetup.cs index b818dd140..1f3255f7e 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaSetup.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Lua/LuaSetup.cs @@ -311,6 +311,9 @@ namespace Barotrauma public void Stop() { + if (harmony != null) + harmony.UnpatchAll(); + game.Stop(); hook.Call("stop", new object[] { }); diff --git a/Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs b/Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs index f6ad777c5..231fd8081 100644 --- a/Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs +++ b/Barotrauma/BarotraumaShared/SharedSource/Screens/GameScreen.cs @@ -83,7 +83,7 @@ namespace Barotrauma GUI.ClearMessages(); #endif } - + int step = 0; /// /// Allows the game to run logic such as updating the world, /// checking for collisions, gathering input, and playing audio. @@ -260,11 +260,15 @@ namespace Barotrauma } } + step++; + if (step % GameMain.Lua.game.mapEntityUpdateRate == 0) + { #if CLIENT - MapEntity.UpdateAll((float)deltaTime, cam); + MapEntity.UpdateAll((float)deltaTime * GameMain.Lua.game.mapEntityUpdateRate, cam); #elif SERVER - MapEntity.UpdateAll((float)deltaTime, Camera.Instance); + MapEntity.UpdateAll((float)deltaTime * GameMain.Lua.game.mapEntityUpdateRate, Camera.Instance); #endif + } #if CLIENT sw.Stop();