Skip to content

Commit

Permalink
Merge Stable 4/3/25 (#566)
Browse files Browse the repository at this point in the history
  • Loading branch information
LankLTE authored Mar 5, 2025
2 parents 1adaeda + 76cfadd commit 0bdf51b
Show file tree
Hide file tree
Showing 810 changed files with 61,091 additions and 30,700 deletions.
12 changes: 6 additions & 6 deletions Content.Benchmarks/ComponentQueryBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,14 @@
using Content.Shared.Clothing.Components;
using Content.Shared.Doors.Components;
using Content.Shared.Item;
using Robust.Server.GameObjects;
using Robust.Shared;
using Robust.Shared.Analyzers;
using Robust.Shared.EntitySerialization;
using Robust.Shared.EntitySerialization.Systems;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Map.Components;
using Robust.Shared.Random;
using Robust.Shared.Utility;

namespace Content.Benchmarks;

Expand All @@ -32,7 +33,6 @@ public class ComponentQueryBenchmark

private TestPair _pair = default!;
private IEntityManager _entMan = default!;
private MapId _mapId = new(10);
private EntityQuery<ItemComponent> _itemQuery;
private EntityQuery<ClothingComponent> _clothingQuery;
private EntityQuery<MapComponent> _mapQuery;
Expand All @@ -54,10 +54,10 @@ public void Setup()
_pair.Server.ResolveDependency<IRobustRandom>().SetSeed(42);
_pair.Server.WaitPost(() =>
{
var success = _entMan.System<MapLoaderSystem>().TryLoad(_mapId, Map, out _);
if (!success)
var map = new ResPath(Map);
var opts = DeserializationOptions.Default with {InitializeMaps = true};
if (!_entMan.System<MapLoaderSystem>().TryLoadMap(map, out _, out _, opts))
throw new Exception("Map load failed");
_pair.Server.MapMan.DoMapInitialize(_mapId);
}).GetAwaiter().GetResult();

_items = new EntityUid[_entMan.Count<ItemComponent>()];
Expand Down
19 changes: 10 additions & 9 deletions Content.Benchmarks/MapLoadBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,13 @@
using Content.IntegrationTests;
using Content.IntegrationTests.Pair;
using Content.Server.Maps;
using Robust.Server.GameObjects;
using Robust.Shared;
using Robust.Shared.Analyzers;
using Robust.Shared.EntitySerialization.Systems;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Prototypes;
using Robust.Shared.Utility;

namespace Content.Benchmarks;

Expand All @@ -20,7 +21,7 @@ public class MapLoadBenchmark
{
private TestPair _pair = default!;
private MapLoaderSystem _mapLoader = default!;
private IMapManager _mapManager = default!;
private SharedMapSystem _mapSys = default!;

[GlobalSetup]
public void Setup()
Expand All @@ -36,7 +37,7 @@ public void Setup()
.ToDictionary(x => x.ID, x => x.MapPath.ToString());

_mapLoader = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<MapLoaderSystem>();
_mapManager = server.ResolveDependency<IMapManager>();
_mapSys = server.ResolveDependency<IEntitySystemManager>().GetEntitySystem<SharedMapSystem>();
}

[GlobalCleanup]
Expand All @@ -52,27 +53,27 @@ public async Task Cleanup()
public string Map;

public Dictionary<string, string> Paths;
private MapId _mapId;

[Benchmark]
public async Task LoadMap()
{
var mapPath = Paths[Map];
var mapPath = new ResPath(Paths[Map]);
var server = _pair.Server;
await server.WaitPost(() =>
{
var success = _mapLoader.TryLoad(new MapId(10), mapPath, out _);
var success = _mapLoader.TryLoadMap(mapPath, out var map, out _);
if (!success)
throw new Exception("Map load failed");
_mapId = map.Value.Comp.MapId;
});
}

[IterationCleanup]
public void IterationCleanup()
{
var server = _pair.Server;
server.WaitPost(() =>
{
_mapManager.DeleteMap(new MapId(10));
}).Wait();
server.WaitPost(() => _mapSys.DeleteMap(_mapId))
.Wait();
}
}
11 changes: 6 additions & 5 deletions Content.Benchmarks/PvsBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,13 +7,15 @@
using Content.IntegrationTests.Pair;
using Content.Server.Mind;
using Content.Server.Warps;
using Robust.Server.GameObjects;
using Robust.Shared;
using Robust.Shared.Analyzers;
using Robust.Shared.EntitySerialization;
using Robust.Shared.EntitySerialization.Systems;
using Robust.Shared.GameObjects;
using Robust.Shared.Map;
using Robust.Shared.Player;
using Robust.Shared.Random;
using Robust.Shared.Utility;

namespace Content.Benchmarks;

Expand All @@ -34,7 +36,6 @@ public class PvsBenchmark

private TestPair _pair = default!;
private IEntityManager _entMan = default!;
private MapId _mapId = new(10);
private ICommonSession[] _players = default!;
private EntityCoordinates[] _spawns = default!;
public int _cycleOffset = 0;
Expand Down Expand Up @@ -65,10 +66,10 @@ private async Task SetupAsync()
_pair.Server.ResolveDependency<IRobustRandom>().SetSeed(42);
await _pair.Server.WaitPost(() =>
{
var success = _entMan.System<MapLoaderSystem>().TryLoad(_mapId, Map, out _);
if (!success)
var path = new ResPath(Map);
var opts = DeserializationOptions.Default with {InitializeMaps = true};
if (!_entMan.System<MapLoaderSystem>().TryLoadMap(path, out _, out _, opts))
throw new Exception("Map load failed");
_pair.Server.MapMan.DoMapInitialize(_mapId);
});

// Get list of ghost warp positions
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Administration/AdminNameOverlay.cs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ protected override void Draw(in OverlayDrawArgs args)
{
args.ScreenHandle.DrawString(_font, screenCoordinates + (lineoffset * 2), _antagLabelClassic, uiScale, _antagColorClassic);
}
else if (!classic && _filter.Contains(playerInfo.RoleProto.ID))
else if (!classic && _filter.Contains(playerInfo.RoleProto))
{
var label = Loc.GetString(playerInfo.RoleProto.Name).ToUpper();
var color = playerInfo.RoleProto.Color;
Expand Down
4 changes: 2 additions & 2 deletions Content.Client/Administration/Systems/BwoinkSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ protected override void OnBwoinkTextMessage(BwoinkTextMessage message, EntitySes
OnBwoinkTextMessageRecieved?.Invoke(this, message);
}

public void Send(NetUserId channelId, string text, bool playSound)
public void Send(NetUserId channelId, string text, bool playSound, bool adminOnly)
{
// Reuse the channel ID as the 'true sender'.
// Server will ignore this and if someone makes it not ignore this (which is bad, allows impersonation!!!), that will help.
RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound));
RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound, adminOnly: adminOnly));
SendInputTextUpdated(channelId, false);
}

Expand Down
4 changes: 3 additions & 1 deletion Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
<BoxContainer Orientation="Vertical" HorizontalExpand="True" SizeFlagsStretchRatio="2">
<BoxContainer Access="Public" Name="BwoinkArea" VerticalExpand="True" />
<BoxContainer Orientation="Horizontal" HorizontalExpand="True">
<CheckBox Visible="True" Name="PlaySound" Access="Public" Text="{Loc 'admin-bwoink-play-sound'}" Pressed="True" />
<CheckBox Name="AdminOnly" Access="Public" Text="{Loc 'admin-ahelp-admin-only'}" ToolTip="{Loc 'admin-ahelp-admin-only-tooltip'}" />
<Control HorizontalExpand="True" MinWidth="5" />
<CheckBox Name="PlaySound" Access="Public" Text="{Loc 'admin-bwoink-play-sound'}" Pressed="True" />
<Control HorizontalExpand="True" MinWidth="5" />
<Button Visible="True" Name="PopOut" Access="Public" Text="{Loc 'admin-logs-pop-out'}" StyleClasses="OpenBoth" HorizontalAlignment="Left" />
<Control HorizontalExpand="True" />
Expand Down
2 changes: 2 additions & 0 deletions Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,8 @@ public BwoinkControl()
_adminManager.AdminStatusUpdated += UpdateButtons;
UpdateButtons();

AdminOnly.OnToggled += args => PlaySound.Disabled = args.Pressed;

ChannelSelector.OnSelectionChanged += sel =>
{
_currentPlayer = sel;
Expand Down
28 changes: 2 additions & 26 deletions Content.Client/Atmos/Consoles/AtmosAlertsComputerWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -512,39 +512,15 @@ private void AutoScrollToFocus()
if (scroll == null)
return;

if (!TryGetVerticalScrollbar(scroll, out var vScrollbar))
return;

if (!TryGetNextScrollPosition(out float? nextScrollPosition))
return;

vScrollbar.ValueTarget = nextScrollPosition.Value;
scroll.VScrollTarget = nextScrollPosition.Value;

if (MathHelper.CloseToPercent(vScrollbar.Value, vScrollbar.ValueTarget))
if (MathHelper.CloseToPercent(scroll.VScroll, scroll.VScrollTarget))
_autoScrollActive = false;
}

private bool TryGetVerticalScrollbar(ScrollContainer scroll, [NotNullWhen(true)] out VScrollBar? vScrollBar)
{
vScrollBar = null;

foreach (var child in scroll.Children)
{
if (child is not VScrollBar)
continue;

var castChild = child as VScrollBar;

if (castChild != null)
{
vScrollBar = castChild;
return true;
}
}

return false;
}

private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
{
nextScrollPosition = null;
Expand Down
24 changes: 2 additions & 22 deletions Content.Client/Atmos/Consoles/AtmosMonitoringConsoleWindow.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -350,35 +350,15 @@ private void AutoScrollToFocus()
if (scroll == null)
return;

if (!TryGetVerticalScrollbar(scroll, out var vScrollbar))
return;

if (!TryGetNextScrollPosition(out float? nextScrollPosition))
return;

vScrollbar.ValueTarget = nextScrollPosition.Value;
scroll.VScrollTarget = nextScrollPosition.Value;

if (MathHelper.CloseToPercent(vScrollbar.Value, vScrollbar.ValueTarget))
if (MathHelper.CloseToPercent(scroll.VScroll, scroll.VScrollTarget))
_autoScrollActive = false;
}

private bool TryGetVerticalScrollbar(ScrollContainer scroll, [NotNullWhen(true)] out VScrollBar? vScrollBar)
{
vScrollBar = null;

foreach (var control in scroll.Children)
{
if (control is not VScrollBar)
continue;

vScrollBar = (VScrollBar)control;

return true;
}

return false;
}

private bool TryGetNextScrollPosition([NotNullWhen(true)] out float? nextScrollPosition)
{
nextScrollPosition = null;
Expand Down
5 changes: 2 additions & 3 deletions Content.Client/Atmos/UI/GasAnalyzerBoundUserInterface.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Robust.Client.GameObjects;
using Robust.Client.UserInterface;
using static Content.Shared.Atmos.Components.GasAnalyzerComponent;

namespace Content.Client.Atmos.UI
Expand All @@ -16,9 +17,7 @@ protected override void Open()
{
base.Open();

_window = new GasAnalyzerWindow();
_window.OnClose += OnClose;
_window.OpenCenteredLeft();
_window = this.CreateWindowCenteredLeft<GasAnalyzerWindow>();
}

protected override void ReceiveMessage(BoundUserInterfaceMessage message)
Expand Down
6 changes: 3 additions & 3 deletions Content.Client/Audio/ClientGlobalSoundSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ private void PlayAdminSound(AdminSoundEvent soundEvent)
{
if(!_adminAudioEnabled) return;

var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
var stream = _audio.PlayGlobal(soundEvent.Specifier, Filter.Local(), false, soundEvent.AudioParams);
_adminAudio.Add(stream?.Entity);
}

Expand All @@ -75,13 +75,13 @@ private void PlayStationEventMusic(StationEventMusicEvent soundEvent)
// Either the cvar is disabled or it's already playing
if(!_eventAudioEnabled || _eventAudio.ContainsKey(soundEvent.Type)) return;

var stream = _audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
var stream = _audio.PlayGlobal(soundEvent.Specifier, Filter.Local(), false, soundEvent.AudioParams);
_eventAudio.Add(soundEvent.Type, stream?.Entity);
}

private void PlayGameSound(GameGlobalSoundEvent soundEvent)
{
_audio.PlayGlobal(soundEvent.Filename, Filter.Local(), false, soundEvent.AudioParams);
_audio.PlayGlobal(soundEvent.Specifier, Filter.Local(), false, soundEvent.AudioParams);
}

private void StopStationEventMusic(StopStationEventMusic soundEvent)
Expand Down
2 changes: 1 addition & 1 deletion Content.Client/Audio/ContentAudioSystem.LobbyMusic.cs
Original file line number Diff line number Diff line change
Expand Up @@ -218,7 +218,7 @@ private void PlayRestartSound(RoundRestartCleanupEvent ev)
return;

var file = _gameTicker.RestartSound;
if (string.IsNullOrEmpty(file))
if (ResolvedSoundSpecifier.IsNullOrEmpty(file))
{
return;
}
Expand Down
14 changes: 11 additions & 3 deletions Content.Client/CartridgeLoader/Cartridges/LogProbeUi.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using Content.Client.UserInterface.Fragments;
using Content.Shared.CartridgeLoader;
using Content.Shared.CartridgeLoader.Cartridges;
using Robust.Client.UserInterface;

Expand All @@ -13,16 +14,23 @@ public override Control GetUIFragmentRoot()
return _fragment!;
}

public override void Setup(BoundUserInterface userInterface, EntityUid? fragmentOwner)
public override void Setup(BoundUserInterface ui, EntityUid? fragmentOwner)
{
_fragment = new LogProbeUiFragment();

_fragment.OnPrintPressed += () =>
{
var ev = new LogProbePrintMessage();
var message = new CartridgeUiMessage(ev);
ui.SendMessage(message);
};
}

public override void UpdateState(BoundUserInterfaceState state)
{
if (state is not LogProbeUiState logProbeUiState)
if (state is not LogProbeUiState cast)
return;

_fragment?.UpdateState(logProbeUiState.PulledLogs);
_fragment?.UpdateState(cast.EntityName, cast.PulledLogs);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,9 @@
<ScrollContainer VerticalExpand="True" HScrollEnabled="True">
<BoxContainer Orientation="Vertical" Name="ProbedDeviceContainer"/>
</ScrollContainer>
<BoxContainer Orientation="Horizontal" Margin="4 8">
<Button Name="PrintButton" HorizontalAlignment="Left" Text="{Loc 'log-probe-print-button'}" Disabled="True"/>
<BoxContainer HorizontalExpand="True"/>
<Label Name="EntityName" Align="Right"/>
</BoxContainer>
</cartridges:LogProbeUiFragment>
Original file line number Diff line number Diff line change
Expand Up @@ -8,17 +8,24 @@ namespace Content.Client.CartridgeLoader.Cartridges;
[GenerateTypedNameReferences]
public sealed partial class LogProbeUiFragment : BoxContainer
{
/// <summary>
/// Action invoked when the print button gets pressed.
/// </summary>
public Action? OnPrintPressed;

public LogProbeUiFragment()
{
RobustXamlLoader.Load(this);

PrintButton.OnPressed += _ => OnPrintPressed?.Invoke();
}

public void UpdateState(List<PulledAccessLog> logs)
public void UpdateState(string name, List<PulledAccessLog> logs)
{
ProbedDeviceContainer.RemoveAllChildren();
EntityName.Text = name;
PrintButton.Disabled = string.IsNullOrEmpty(name);

//Reverse the list so the oldest entries appear at the bottom
logs.Reverse();
ProbedDeviceContainer.RemoveAllChildren();

var count = 1;
foreach (var log in logs)
Expand Down
Loading

0 comments on commit 0bdf51b

Please sign in to comment.