OBT/1.1.0 (#50)

Finished CL-EP
Restored early Parallelism setting
This commit is contained in:
NotAlwaysTrue
2026-02-24 15:16:41 +08:00
committed by GitHub
parent de1f1c599f
commit 679ffd380b
9 changed files with 79 additions and 82 deletions

View File

@@ -40,12 +40,10 @@ env:
windows:server:Windows/Server windows:server:Windows/Server
linux:server:Linux/Server linux:server:Linux/Server
mac:server:Mac/Server mac:server:Mac/Server
windows:client:Windows/Client
linux:client:Linux/Client
mac:client:Mac/Client/Barotrauma.app/Contents/MacOS
ARCHIVE_BASE_NAME: luacsforbarotraumaEP ARCHIVE_BASE_NAME: luacsforbarotraumaEP
# Clients are removed cuz we dont actually have one :(
# windows:client:Windows/Client
# linux:client:Linux/Client
# mac:client:Mac/Client/Barotrauma.app/Contents/MacOS
# XXX: these file names are subject to shell expansion. # XXX: these file names are subject to shell expansion.
# Be careful when using special characters. # Be careful when using special characters.
ARCHIVE_FILES_SERVER: | ARCHIVE_FILES_SERVER: |

View File

@@ -3553,6 +3553,11 @@ namespace Barotrauma
ContentPackageManager.RegularPackages.Select(p => p.Name).ToArray() ContentPackageManager.RegularPackages.Select(p => p.Name).ToArray()
})); }));
commands.Add(new Command("ShowServerPerf", "Immediately log server performance info", (string[] args) =>
{
// TODO: Not yet :)
}));
#if WINDOWS #if WINDOWS
commands.Add(new Command("startdedicatedserver", "", (string[] args) => commands.Add(new Command("startdedicatedserver", "", (string[] args) =>
{ {
@@ -3586,6 +3591,14 @@ namespace Barotrauma
} }
}));*/ }));*/
AssignOnClientExecute(
"ShowServerPerf",
(string[] args) =>
{
GameMain.Client?.SendConsoleCommand("ShowServerPerf");
}
);
AssignOnClientExecute( AssignOnClientExecute(
"giveperm", "giveperm",
(string[] args) => (string[] args) =>

View File

@@ -15,7 +15,7 @@ namespace Barotrauma
return; return;
} }
var msg = new GUIMessageBox("Confirm", "Are you sure you want to remove Client-Side LuaCs?", new LocalizedString[2] { TextManager.Get("Yes"), TextManager.Get("Cancel") }); var msg = new GUIMessageBox("Confirm", "Are you sure you want to remove Client-Side ProjectEP?", new LocalizedString[2] { TextManager.Get("Yes"), TextManager.Get("Cancel") });
msg.Buttons[0].OnClicked = (GUIButton button, object obj) => msg.Buttons[0].OnClicked = (GUIButton button, object obj) =>
{ {

View File

@@ -82,9 +82,9 @@ namespace Barotrauma
} }
}; };
new GUIButton(new RectTransform(new Vector2(1f, 0.1f), list.Content.RectTransform), $"Remove Client-Side LuaCs", style: "GUIButtonSmall") new GUIButton(new RectTransform(new Vector2(1f, 0.1f), list.Content.RectTransform), $"Remove Client-Side ProjectEP", style: "GUIButtonSmall")
{ {
ToolTip = "Remove Client-Side LuaCs.", ToolTip = "Remove Client-Side ProjectEP.",
OnClicked = (tb, userdata) => OnClicked = (tb, userdata) =>
{ {
LuaCsInstaller.Uninstall(); LuaCsInstaller.Uninstall();

View File

@@ -544,7 +544,7 @@ namespace Barotrauma
string version = File.Exists(LuaCsSetup.VersionFile) ? File.ReadAllText(LuaCsSetup.VersionFile) : "Github"; string version = File.Exists(LuaCsSetup.VersionFile) ? File.ReadAllText(LuaCsSetup.VersionFile) : "Github";
new GUITextBlock(new RectTransform(new Point(300, 30), Frame.RectTransform, Anchor.TopLeft) { AbsoluteOffset = new Point(10, 10) }, $"Using LuaCsForBarotrauma revision {AssemblyInfo.GitRevision} version {version}", Color.Red) new GUITextBlock(new RectTransform(new Point(300, 30), Frame.RectTransform, Anchor.TopLeft) { AbsoluteOffset = new Point(10, 10) }, $"Using ProjectEP revision {AssemblyInfo.GitRevision} version {version}", Color.Red)
{ {
IgnoreLayoutGroups = false IgnoreLayoutGroups = false
}; };

View File

@@ -1317,7 +1317,7 @@ namespace Barotrauma
GameMain.LuaCs.ToggleDebugger(port); GameMain.LuaCs.ToggleDebugger(port);
})); }));
commands.Add(new Command("install_cl_lua|install_cl|install_cl_cs|install_cl_luacs", "Installs Client-Side LuaCs into your client.", (string[] args) => commands.Add(new Command("install_cl_ep", "Installs Client-Side ProjectEP into your client.", (string[] args) =>
{ {
LuaCsInstaller.Install(); LuaCsInstaller.Install();
})); }));
@@ -2772,9 +2772,16 @@ namespace Barotrauma
commands.Add(new Command("ShowServerPerf", "Immediately log server performance info in ServerMessage", (string[] args) => commands.Add(new Command("ShowServerPerf", "Immediately log server performance info in ServerMessage", (string[] args) =>
{ {
GameServer.Log(PerformanceMonitor.PM.ToString(), ServerLog.MessageType.ServerMessage); GameServer.Log(PerformanceMonitor.PM.ToString(), ServerLog.MessageType.ServerMessage);
NewMessage(PerformanceMonitor.PM.ToString(), Color.Green);
})); }));
AssignOnClientRequestExecute(
"ShowServerPerf",
(senderClient, cursorWorldPos, args) =>
{
GameMain.Server.SendConsoleMessage(PerformanceMonitor.PM.ToString(), senderClient);
}
);
#if DEBUG #if DEBUG
commands.Add(new Command("spamevents", "A debug command that creates a ton of entity events.", (string[] args) => commands.Add(new Command("spamevents", "A debug command that creates a ton of entity events.", (string[] args) =>
{ {

View File

@@ -13,7 +13,7 @@ namespace Barotrauma
if (luaPackage == null) if (luaPackage == null)
{ {
GameMain.Server.SendChatMessage("Couldn't find the LuaCs For Barotrauma package.", ChatMessageType.ServerMessageBox); GameMain.Server.SendChatMessage("Couldn't find the ProjectEP package.", ChatMessageType.ServerMessageBox);
return; return;
} }
@@ -47,13 +47,10 @@ namespace Barotrauma
File.WriteAllText(LuaCsSetup.VersionFile, luaPackage.ModVersion); File.WriteAllText(LuaCsSetup.VersionFile, luaPackage.ModVersion);
#if WINDOWS
File.WriteAllText("LuaCsDedicatedServer.bat", "\"%LocalAppData%/Daedalic Entertainment GmbH/Barotrauma/WorkshopMods/Installed/2559634234/Binary/DedicatedServer.exe\"");
#endif
} }
catch (UnauthorizedAccessException e) catch (UnauthorizedAccessException e)
{ {
LuaCsLogger.LogError($"Unauthorized file access exception. This usually means you already have LuaCs installed. ${e}", LuaCsMessageOrigin.LuaCs); LuaCsLogger.LogError($"Unauthorized file access exception. This usually means you already have ProjectEP installed. ${e}", LuaCsMessageOrigin.LuaCs);
return; return;
} }
@@ -64,7 +61,7 @@ namespace Barotrauma
return; return;
} }
GameMain.Server.SendChatMessage("Client-Side LuaCs installed, restart your game to apply changes.", ChatMessageType.ServerMessageBox); GameMain.Server.SendChatMessage("Client-Side ProjectEP installed, restart your game to apply changes.", ChatMessageType.ServerMessageBox);
} }
} }
} }

View File

@@ -46,11 +46,11 @@ namespace Barotrauma
public const string LuaSetupFile = "Lua/LuaSetup.lua"; public const string LuaSetupFile = "Lua/LuaSetup.lua";
public const string VersionFile = "luacsversion.txt"; public const string VersionFile = "luacsversion.txt";
#if WINDOWS #if WINDOWS
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(2559634234); public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(3629459376);
#elif LINUX #elif LINUX
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(2970628943); public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(3632586273);
#elif OSX #elif OSX
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(2970890020); public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(3672543756);
#endif #endif
public static ContentPackageId CsForBarotraumaId = new SteamWorkshopId(2795927223); public static ContentPackageId CsForBarotraumaId = new SteamWorkshopId(2795927223);

View File

@@ -18,13 +18,10 @@ namespace Barotrauma
{ {
partial class GameScreen : Screen partial class GameScreen : Screen
{ {
private object updateLock = new object(); // Use default instead. Hopefully this wont cause issues in long-running servers.
private double physicsTime;
// -2 here bcuz we alread have a SEEM thread there
private static readonly ParallelOptions parallelOptions = new ParallelOptions private static readonly ParallelOptions parallelOptions = new ParallelOptions
{ {
MaxDegreeOfParallelism = Math.Max(4, Environment.ProcessorCount - 2) //MaxDegreeOfParallelism = Math.Max(4, Environment.ProcessorCount - 1)
}; };
#if CLIENT #if CLIENT
@@ -62,13 +59,13 @@ namespace Barotrauma
#if CLIENT #if CLIENT
if (Character.Controlled != null) if (Character.Controlled != null)
{ {
cam.Position = Character.Controlled.WorldPosition; Cam.Position = Character.Controlled.WorldPosition;
cam.UpdateTransform(true); Cam.UpdateTransform(true);
} }
else if (Submarine.MainSub != null) else if (Submarine.MainSub != null)
{ {
cam.Position = Submarine.MainSub.WorldPosition; Cam.Position = Submarine.MainSub.WorldPosition;
cam.UpdateTransform(true); Cam.UpdateTransform(true);
} }
GameMain.GameSession?.CrewManager?.ResetCrewListOpenState(); GameMain.GameSession?.CrewManager?.ResetCrewListOpenState();
ChatBox.ResetChatBoxOpenState(); ChatBox.ResetChatBoxOpenState();
@@ -108,14 +105,12 @@ namespace Barotrauma
var submarines = Submarine.Loaded.ToList(); var submarines = Submarine.Loaded.ToList();
var physicsBodies = PhysicsBody.List.ToList(); var physicsBodies = PhysicsBody.List.ToList();
#warning For now CL side performance counter is partly useless bucz multiple changes on such things. Need time to take care of it
#if DEBUG && CLIENT #if DEBUG && CLIENT
if (GameMain.GameSession != null && !DebugConsole.IsOpen && GUI.KeyboardDispatcher.Subscriber == null) if (GameMain.GameSession != null && !DebugConsole.IsOpen && GUI.KeyboardDispatcher.Subscriber == null)
{ {
if (GameMain.GameSession.Level != null && GameMain.GameSession.Submarine != null) if (GameMain.GameSession.Level != null && GameMain.GameSession.Submarine != null)
{ {
Submarine closestSub = Submarine.FindClosest(cam.WorldViewCenter) ?? GameMain.GameSession.Submarine; Submarine closestSub = Submarine.FindClosest(Cam.WorldViewCenter) ?? GameMain.GameSession.Submarine;
Vector2 targetMovement = Vector2.Zero; Vector2 targetMovement = Vector2.Zero;
if (PlayerInput.KeyDown(Keys.I)) { targetMovement.Y += 1.0f; } if (PlayerInput.KeyDown(Keys.I)) { targetMovement.Y += 1.0f; }
@@ -145,27 +140,38 @@ namespace Barotrauma
body.Update(); body.Update();
} }
}); });
GameMain.GameSession?.Update((float)deltaTime);
MapEntity.ClearHighlightedEntities(); MapEntity.ClearHighlightedEntities();
#if CLIENT #if CLIENT
var sw = new System.Diagnostics.Stopwatch(); var sw = new System.Diagnostics.Stopwatch();
sw.Start(); sw.Start();
#endif
Parallel.Invoke(parallelOptions, GameMain.GameSession?.Update((float)deltaTime);
() => GameMain.ParticleManager.Update((float)deltaTime), #if CLIENT
() => { if (Level.Loaded != null) Level.Loaded.Update((float)deltaTime, cam); }
);
sw.Stop(); sw.Stop();
GameMain.PerformanceCounter.AddElapsedTicks("Update:Particles+Level", sw.ElapsedTicks); GameMain.PerformanceCounter.AddElapsedTicks("Update:GameSession", sw.ElapsedTicks);
sw.Restart();
GameMain.ParticleManager.Update((float)deltaTime);
sw.Stop();
GameMain.PerformanceCounter.AddElapsedTicks("Update:Particle", sw.ElapsedTicks);
sw.Restart();
#endif
if (Level.Loaded != null) { Level.Loaded.Update((float)deltaTime, Cam); }
#if CLIENT
sw.Stop();
GameMain.PerformanceCounter.AddElapsedTicks("Update:Level", sw.ElapsedTicks);
if (Character.Controlled is { } controlled) if (Character.Controlled is { } controlled)
{ {
if (controlled.SelectedItem != null && controlled.CanInteractWith(controlled.SelectedItem)) if (controlled.SelectedItem != null && controlled.CanInteractWith(controlled.SelectedItem))
{ {
controlled.SelectedItem.UpdateHUD(cam, controlled, (float)deltaTime); controlled.SelectedItem.UpdateHUD(Cam, controlled, (float)deltaTime);
} }
if (controlled.Inventory != null) if (controlled.Inventory != null)
{ {
@@ -173,7 +179,7 @@ namespace Barotrauma
{ {
if (controlled.HasEquippedItem(item)) if (controlled.HasEquippedItem(item))
{ {
item.UpdateHUD(cam, controlled, (float)deltaTime); item.UpdateHUD(Cam, controlled, (float)deltaTime);
} }
} }
} }
@@ -181,11 +187,19 @@ namespace Barotrauma
sw.Restart(); sw.Restart();
Character.UpdateAll((float)deltaTime, cam); #endif
Character.UpdateAll((float)deltaTime, Cam);
#if CLIENT
sw.Stop(); sw.Stop();
GameMain.PerformanceCounter.AddElapsedTicks("Update:Character", sw.ElapsedTicks); GameMain.PerformanceCounter.AddElapsedTicks("Update:Character", sw.ElapsedTicks);
sw.Restart(); sw.Restart();
#endif
//StatusEffect.UpdateAll is not thread-safe and must be executed on the main thread
StatusEffect.UpdateAll((float)deltaTime);
#if CLIENT
sw.Stop(); sw.Stop();
GameMain.PerformanceCounter.AddElapsedTicks("Update:StatusEffects", sw.ElapsedTicks); GameMain.PerformanceCounter.AddElapsedTicks("Update:StatusEffects", sw.ElapsedTicks);
@@ -211,24 +225,15 @@ namespace Barotrauma
} }
Vector2 screenOffset = screenTargetPos - new Vector2(GameMain.GraphicsWidth / 2, GameMain.GraphicsHeight / 2); Vector2 screenOffset = screenTargetPos - new Vector2(GameMain.GraphicsWidth / 2, GameMain.GraphicsHeight / 2);
screenOffset.Y = -screenOffset.Y; screenOffset.Y = -screenOffset.Y;
targetPos -= screenOffset / cam.Zoom; targetPos -= screenOffset / Cam.Zoom;
} }
} }
cam.TargetPos = targetPos; Cam.TargetPos = targetPos;
} }
cam.MoveCamera((float)deltaTime, allowZoom: GUI.MouseOn == null && !Inventory.IsMouseOnInventory); Cam.MoveCamera((float)deltaTime, allowZoom: GUI.MouseOn == null && !Inventory.IsMouseOnInventory);
Character.Controlled?.UpdateLocalCursor(cam); Character.Controlled?.UpdateLocalCursor(Cam);
#elif SERVER
// Don't parallize these things here or the server may got stuck but why idk
if (Level.Loaded != null) { Level.Loaded.Update((float)deltaTime, Camera.Instance); }
Character.UpdateAll((float)deltaTime, Camera.Instance);
//StatusEffect.UpdateAll is not thread-safe and must be executed on the main thread
StatusEffect.UpdateAll((float)deltaTime);
#endif #endif
foreach (Submarine sub in submarines) foreach (Submarine sub in submarines)
@@ -244,12 +249,7 @@ namespace Barotrauma
} }
}); });
MapEntity.UpdateAll((float)deltaTime, Cam, parallelOptions);
#if CLIENT
MapEntity.UpdateAll((float)deltaTime, cam, parallelOptions);
#elif SERVER
MapEntity.UpdateAll((float)deltaTime, Camera.Instance, parallelOptions);
#endif
#if CLIENT #if CLIENT
sw.Stop(); sw.Stop();
@@ -259,12 +259,9 @@ namespace Barotrauma
//Character.UpdateAnimAll is not thread-safe and must be executed on the main thread //Character.UpdateAnimAll is not thread-safe and must be executed on the main thread
Character.UpdateAnimAll((float)deltaTime); Character.UpdateAnimAll((float)deltaTime);
#if CLIENT
Ragdoll.UpdateAll((float)deltaTime, cam); Ragdoll.UpdateAll((float)deltaTime, Cam);
#elif SERVER
Ragdoll.UpdateAll((float)deltaTime, Camera.Instance);
SingleThreadWorker.GlobalWorker.RunActions(); SingleThreadWorker.GlobalWorker.RunActions();
#endif
#if CLIENT #if CLIENT
sw.Stop(); sw.Stop();
@@ -301,20 +298,5 @@ namespace Barotrauma
} }
partial void UpdateProjSpecific(double deltaTime); partial void UpdateProjSpecific(double deltaTime);
private void ExecutePhysics()
{
while (true)
{
while (physicsTime >= Timing.Step)
{
lock (updateLock)
{
GameMain.World.Step((float)Timing.Step);
physicsTime -= Timing.Step;
}
}
}
}
} }
} }