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

View File

@@ -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;
}

View File

@@ -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)

View File

@@ -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
}
}

View File

@@ -116,6 +116,8 @@ namespace Barotrauma
public bool disableDisconnectCharacter = false;
public bool enableControlHusk = false;
public int mapEntityUpdateRate = 1;
public bool RoundStarted
{

View File

@@ -311,6 +311,9 @@ namespace Barotrauma
public void Stop()
{
if (harmony != null)
harmony.UnpatchAll();
game.Stop();
hook.Call("stop", new object[] { });

View File

@@ -83,7 +83,7 @@ namespace Barotrauma
GUI.ClearMessages();
#endif
}
int step = 0;
/// <summary>
/// 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();