new performance improvement setting and client-side lua fixes

This commit is contained in:
Evil Factory
2021-12-30 17:26:51 -03:00
parent fee9cf4fa3
commit 036b42ca7e
6 changed files with 46 additions and 28 deletions
@@ -1761,6 +1761,8 @@ namespace Barotrauma.Networking
AddChatMessage($"ServerMessage.HowToCommunicate~[chatbutton]={GameMain.Config.KeyBindText(InputType.Chat)}~[radiobutton]={GameMain.Config.KeyBindText(InputType.RadioChat)}", ChatMessageType.Server); 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; yield return CoroutineStatus.Success;
} }
+30 -23
View File
@@ -21,11 +21,6 @@ require("DefaultHook")
-- Execute Mods -- 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 if SERVER and Game.IsDedicated then
runDisabledMods = true runDisabledMods = true
@@ -56,30 +51,42 @@ local function runFolder(folder)
end end
end end
if not runDisabledMods then if SERVER then
for _, package in pairs(enabledPackages) do if not runDisabledMods then
local d = package.path:gsub("\\", "/")
d = d:gsub("/filelist.xml", "") for _, package in pairs(enabledPackages) do
local d = package.path:gsub("\\", "/")
table.insert(modulePaths, (d .. "/Lua/?.lua")) d = d:gsub("/filelist.xml", "")
if File.DirectoryExists(d .. "/Lua/Autorun") then table.insert(modulePaths, (d .. "/Lua/?.lua"))
runFolder(d .. "/Lua/Autorun");
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 end
end
else for _, d in pairs(File.GetDirectories("Mods")) do
for _, d in pairs(File.GetDirectories("Mods")) do d = d:gsub("\\", "/")
d = d:gsub("\\", "/")
if File.DirectoryExists(d .. "/Lua/ForcedAutorun") then
table.insert(modulePaths, (d .. "/Lua/?.lua")) table.insert(modulePaths, (d .. "/Lua/?.lua"))
runFolder(d .. "/Lua/ForcedAutorun");
if File.DirectoryExists(d .. "/Lua/Autorun") then
runFolder(d .. "/Lua/Autorun");
end
end end
end end
setmodulepaths(modulePaths) setmodulepaths(modulePaths)
@@ -1921,8 +1921,8 @@ namespace Barotrauma
#if DEBUG #if DEBUG
AddWarning($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\". Executing the command anyway because this is a debug build."); AddWarning($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\". Executing the command anyway because this is a debug build.");
#else #else
ThrowError($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\"!"); //ThrowError($"You're not permitted to use the command \"{splitCommand[0].ToLowerInvariant()}\"!");
return; //return;
#endif #endif
} }
} }
@@ -116,6 +116,8 @@ namespace Barotrauma
public bool disableDisconnectCharacter = false; public bool disableDisconnectCharacter = false;
public bool enableControlHusk = false; public bool enableControlHusk = false;
public int mapEntityUpdateRate = 1;
public bool RoundStarted public bool RoundStarted
{ {
@@ -311,6 +311,9 @@ namespace Barotrauma
public void Stop() public void Stop()
{ {
if (harmony != null)
harmony.UnpatchAll();
game.Stop(); game.Stop();
hook.Call("stop", new object[] { }); hook.Call("stop", new object[] { });
@@ -83,7 +83,7 @@ namespace Barotrauma
GUI.ClearMessages(); GUI.ClearMessages();
#endif #endif
} }
int step = 0;
/// <summary> /// <summary>
/// Allows the game to run logic such as updating the world, /// Allows the game to run logic such as updating the world,
/// checking for collisions, gathering input, and playing audio. /// checking for collisions, gathering input, and playing audio.
@@ -260,11 +260,15 @@ namespace Barotrauma
} }
} }
step++;
if (step % GameMain.Lua.game.mapEntityUpdateRate == 0)
{
#if CLIENT #if CLIENT
MapEntity.UpdateAll((float)deltaTime, cam); MapEntity.UpdateAll((float)deltaTime * GameMain.Lua.game.mapEntityUpdateRate, cam);
#elif SERVER #elif SERVER
MapEntity.UpdateAll((float)deltaTime, Camera.Instance); MapEntity.UpdateAll((float)deltaTime * GameMain.Lua.game.mapEntityUpdateRate, Camera.Instance);
#endif #endif
}
#if CLIENT #if CLIENT
sw.Stop(); sw.Stop();