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

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

View File

@@ -15,7 +15,7 @@ namespace Barotrauma
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) =>
{

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) =>
{
LuaCsInstaller.Uninstall();

View File

@@ -544,7 +544,7 @@ namespace Barotrauma
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
};

View File

@@ -1317,7 +1317,7 @@ namespace Barotrauma
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();
}));
@@ -2772,9 +2772,16 @@ namespace Barotrauma
commands.Add(new Command("ShowServerPerf", "Immediately log server performance info in ServerMessage", (string[] args) =>
{
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
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)
{
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;
}
@@ -47,13 +47,10 @@ namespace Barotrauma
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)
{
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;
}
@@ -64,7 +61,7 @@ namespace Barotrauma
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 VersionFile = "luacsversion.txt";
#if WINDOWS
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(2559634234);
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(3629459376);
#elif LINUX
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(2970628943);
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(3632586273);
#elif OSX
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(2970890020);
public static ContentPackageId LuaForBarotraumaId = new SteamWorkshopId(3672543756);
#endif
public static ContentPackageId CsForBarotraumaId = new SteamWorkshopId(2795927223);

View File

@@ -18,13 +18,10 @@ namespace Barotrauma
{
partial class GameScreen : Screen
{
private object updateLock = new object();
private double physicsTime;
// -2 here bcuz we alread have a SEEM thread there
// Use default instead. Hopefully this wont cause issues in long-running servers.
private static readonly ParallelOptions parallelOptions = new ParallelOptions
{
MaxDegreeOfParallelism = Math.Max(4, Environment.ProcessorCount - 2)
//MaxDegreeOfParallelism = Math.Max(4, Environment.ProcessorCount - 1)
};
#if CLIENT
@@ -62,13 +59,13 @@ namespace Barotrauma
#if CLIENT
if (Character.Controlled != null)
{
cam.Position = Character.Controlled.WorldPosition;
cam.UpdateTransform(true);
Cam.Position = Character.Controlled.WorldPosition;
Cam.UpdateTransform(true);
}
else if (Submarine.MainSub != null)
{
cam.Position = Submarine.MainSub.WorldPosition;
cam.UpdateTransform(true);
Cam.Position = Submarine.MainSub.WorldPosition;
Cam.UpdateTransform(true);
}
GameMain.GameSession?.CrewManager?.ResetCrewListOpenState();
ChatBox.ResetChatBoxOpenState();
@@ -108,14 +105,12 @@ namespace Barotrauma
var submarines = Submarine.Loaded.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 (GameMain.GameSession != null && !DebugConsole.IsOpen && GUI.KeyboardDispatcher.Subscriber == 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;
if (PlayerInput.KeyDown(Keys.I)) { targetMovement.Y += 1.0f; }
@@ -145,27 +140,38 @@ namespace Barotrauma
body.Update();
}
});
GameMain.GameSession?.Update((float)deltaTime);
MapEntity.ClearHighlightedEntities();
#if CLIENT
var sw = new System.Diagnostics.Stopwatch();
sw.Start();
Parallel.Invoke(parallelOptions,
() => GameMain.ParticleManager.Update((float)deltaTime),
() => { if (Level.Loaded != null) Level.Loaded.Update((float)deltaTime, cam); }
);
#endif
GameMain.GameSession?.Update((float)deltaTime);
#if CLIENT
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 (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)
{
@@ -173,7 +179,7 @@ namespace Barotrauma
{
if (controlled.HasEquippedItem(item))
{
item.UpdateHUD(cam, controlled, (float)deltaTime);
item.UpdateHUD(Cam, controlled, (float)deltaTime);
}
}
}
@@ -181,11 +187,19 @@ namespace Barotrauma
sw.Restart();
Character.UpdateAll((float)deltaTime, cam);
#endif
Character.UpdateAll((float)deltaTime, Cam);
#if CLIENT
sw.Stop();
GameMain.PerformanceCounter.AddElapsedTicks("Update:Character", sw.ElapsedTicks);
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();
GameMain.PerformanceCounter.AddElapsedTicks("Update:StatusEffects", sw.ElapsedTicks);
@@ -211,24 +225,15 @@ namespace Barotrauma
}
Vector2 screenOffset = screenTargetPos - new Vector2(GameMain.GraphicsWidth / 2, GameMain.GraphicsHeight / 2);
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);
#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);
Character.Controlled?.UpdateLocalCursor(Cam);
#endif
foreach (Submarine sub in submarines)
@@ -244,12 +249,7 @@ namespace Barotrauma
}
});
#if CLIENT
MapEntity.UpdateAll((float)deltaTime, cam, parallelOptions);
#elif SERVER
MapEntity.UpdateAll((float)deltaTime, Camera.Instance, parallelOptions);
#endif
MapEntity.UpdateAll((float)deltaTime, Cam, parallelOptions);
#if CLIENT
sw.Stop();
@@ -259,12 +259,9 @@ namespace Barotrauma
//Character.UpdateAnimAll is not thread-safe and must be executed on the main thread
Character.UpdateAnimAll((float)deltaTime);
#if CLIENT
Ragdoll.UpdateAll((float)deltaTime, cam);
#elif SERVER
Ragdoll.UpdateAll((float)deltaTime, Camera.Instance);
Ragdoll.UpdateAll((float)deltaTime, Cam);
SingleThreadWorker.GlobalWorker.RunActions();
#endif
#if CLIENT
sw.Stop();
@@ -301,20 +298,5 @@ namespace Barotrauma
}
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;
}
}
}
}
}
}