Skip to content
This repository has been archived by the owner on Apr 27, 2024. It is now read-only.

Commit

Permalink
Merge pull request #11 from SS14-Classic/upstream_merge
Browse files Browse the repository at this point in the history
Upstream merge 02/03/2024
  • Loading branch information
Peptide90 committed Mar 2, 2024
2 parents 44280b7 + 1ded2f9 commit 9180fa4
Show file tree
Hide file tree
Showing 2,550 changed files with 217,165 additions and 97,895 deletions.
4 changes: 2 additions & 2 deletions .envrc
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
if ! has nix_direnv_version || ! nix_direnv_version 2.3.0; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/2.3.0/direnvrc" "sha256-Dmd+j63L84wuzgyjITIfSxSD57Tx7v51DMxVZOsiUD8="
if ! has nix_direnv_version || ! nix_direnv_version 3.0.4; then
source_url "https://raw.githubusercontent.com/nix-community/nix-direnv/3.0.4/direnvrc" "sha256-DzlYZ33mWF/Gs8DDeyjr8mnVmQGx7ASYqA5WlxwvBG4="
fi
use flake
8 changes: 4 additions & 4 deletions Content.Benchmarks/ColorInterpolateBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -131,8 +131,8 @@ public static Color InterpolateSysVector4(Color a, Color b,
public static Color InterpolateSysVector4In(in Color endPoint1, in Color endPoint2,
float lambda)
{
ref var sva = ref Unsafe.As<Color, SysVector4>(ref Unsafe.AsRef(endPoint1));
ref var svb = ref Unsafe.As<Color, SysVector4>(ref Unsafe.AsRef(endPoint2));
ref var sva = ref Unsafe.As<Color, SysVector4>(ref Unsafe.AsRef(in endPoint1));
ref var svb = ref Unsafe.As<Color, SysVector4>(ref Unsafe.AsRef(in endPoint2));

var res = SysVector4.Lerp(svb, sva, lambda);

Expand All @@ -156,8 +156,8 @@ public static Color InterpolateSimd(Color a, Color b,
public static Color InterpolateSimdIn(in Color a, in Color b,
float lambda)
{
var vecA = Unsafe.As<Color, Vector128<float>>(ref Unsafe.AsRef(a));
var vecB = Unsafe.As<Color, Vector128<float>>(ref Unsafe.AsRef(b));
var vecA = Unsafe.As<Color, Vector128<float>>(ref Unsafe.AsRef(in a));
var vecB = Unsafe.As<Color, Vector128<float>>(ref Unsafe.AsRef(in b));

vecB = Fma.MultiplyAdd(Sse.Subtract(vecB, vecA), Vector128.Create(lambda), vecA);

Expand Down
2 changes: 1 addition & 1 deletion Content.Benchmarks/DeviceNetworkingBenchmark.cs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@
using Content.IntegrationTests;
using Content.IntegrationTests.Pair;
using Content.IntegrationTests.Tests.DeviceNetwork;
using Content.Server.DeviceNetwork;
using Content.Server.DeviceNetwork.Systems;
using Content.Shared.DeviceNetwork;
using Robust.Shared;
using Robust.Shared.Analyzers;
using Robust.Shared.GameObjects;
Expand Down
5 changes: 0 additions & 5 deletions Content.Benchmarks/Program.cs
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ internal static class Program

public static void Main(string[] args)
{
MainAsync(args).GetAwaiter().GetResult();
}

public static async Task MainAsync(string[] args)
{
#if DEBUG
Console.ForegroundColor = ConsoleColor.Red;
Console.WriteLine("\nWARNING: YOU ARE RUNNING A DEBUG BUILD, USE A RELEASE BUILD FOR AN ACCURATE BENCHMARK");
Expand Down
23 changes: 12 additions & 11 deletions Content.Client/Actions/ActionsSystem.cs
Original file line number Diff line number Diff line change
Expand Up @@ -78,10 +78,12 @@ private void OnWorldTargetHandleState(EntityUid uid, WorldTargetActionComponent

private void BaseHandleState<T>(EntityUid uid, BaseActionComponent component, BaseActionComponentState state) where T : BaseActionComponent
{
// TODO ACTIONS use auto comp states
component.Icon = state.Icon;
component.IconOn = state.IconOn;
component.IconColor = state.IconColor;
component.Keywords = new HashSet<string>(state.Keywords);
component.Keywords.Clear();
component.Keywords.UnionWith(state.Keywords);
component.Enabled = state.Enabled;
component.Toggled = state.Toggled;
component.Cooldown = state.Cooldown;
Expand All @@ -101,8 +103,7 @@ private void BaseHandleState<T>(EntityUid uid, BaseActionComponent component, Ba
component.ItemIconStyle = state.ItemIconStyle;
component.Sound = state.Sound;

if (_playerManager.LocalPlayer?.ControlledEntity == component.AttachedEntity)
ActionsUpdated?.Invoke();
UpdateAction(uid, component);
}

protected override void UpdateAction(EntityUid? actionId, BaseActionComponent? action = null)
Expand All @@ -111,7 +112,7 @@ protected override void UpdateAction(EntityUid? actionId, BaseActionComponent? a
return;

base.UpdateAction(actionId, action);
if (_playerManager.LocalPlayer?.ControlledEntity != action.AttachedEntity)
if (_playerManager.LocalEntity != action.AttachedEntity)
return;

ActionsUpdated?.Invoke();
Expand Down Expand Up @@ -144,7 +145,7 @@ private void HandleComponentState(EntityUid uid, ActionsComponent component, ref
_added.Add((actionId, action));
}

if (_playerManager.LocalPlayer?.ControlledEntity != uid)
if (_playerManager.LocalEntity != uid)
return;

foreach (var action in _removed)
Expand Down Expand Up @@ -177,23 +178,23 @@ public static int ActionComparer((EntityUid, BaseActionComponent?) a, (EntityUid
protected override void ActionAdded(EntityUid performer, EntityUid actionId, ActionsComponent comp,
BaseActionComponent action)
{
if (_playerManager.LocalPlayer?.ControlledEntity != performer)
if (_playerManager.LocalEntity != performer)
return;

OnActionAdded?.Invoke(actionId);
}

protected override void ActionRemoved(EntityUid performer, EntityUid actionId, ActionsComponent comp, BaseActionComponent action)
{
if (_playerManager.LocalPlayer?.ControlledEntity != performer)
if (_playerManager.LocalEntity != performer)
return;

OnActionRemoved?.Invoke(actionId);
}

public IEnumerable<(EntityUid Id, BaseActionComponent Comp)> GetClientActions()
{
if (_playerManager.LocalPlayer?.ControlledEntity is not { } user)
if (_playerManager.LocalEntity is not { } user)
return Enumerable.Empty<(EntityUid, BaseActionComponent)>();

return GetActions(user);
Expand All @@ -216,7 +217,7 @@ public void UnlinkAllActions()

public void LinkAllActions(ActionsComponent? actions = null)
{
if (_playerManager.LocalPlayer?.ControlledEntity is not { } user ||
if (_playerManager.LocalEntity is not { } user ||
!Resolve(user, ref actions, false))
{
return;
Expand All @@ -233,7 +234,7 @@ public override void Shutdown()

public void TriggerAction(EntityUid actionId, BaseActionComponent action)
{
if (_playerManager.LocalPlayer?.ControlledEntity is not { } user ||
if (_playerManager.LocalEntity is not { } user ||
!TryComp(user, out ActionsComponent? actions))
{
return;
Expand Down Expand Up @@ -261,7 +262,7 @@ public void TriggerAction(EntityUid actionId, BaseActionComponent action)
/// </summary>
public void LoadActionAssignments(string path, bool userData)
{
if (_playerManager.LocalPlayer?.ControlledEntity is not { } user)
if (_playerManager.LocalEntity is not { } user)
return;

var file = new ResPath(path).ToRootedPath();
Expand Down
17 changes: 9 additions & 8 deletions Content.Client/Administration/Managers/ClientAdminManager.cs
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,13 @@ public sealed class ClientAdminManager : IClientAdminManager, IClientConGroupImp
[Dependency] private readonly IClientNetManager _netMgr = default!;
[Dependency] private readonly IClientConGroupController _conGroup = default!;
[Dependency] private readonly IResourceManager _res = default!;
[Dependency] private readonly ILogManager _logManager = default!;

private AdminData? _adminData;
private readonly HashSet<string> _availableCommands = new();

private readonly AdminCommandPermissions _localCommandPermissions = new();
private ISawmill _sawmill = default!;

public event Action? AdminStatusUpdated;

Expand Down Expand Up @@ -92,17 +94,17 @@ private void UpdateMessageRx(MsgUpdateAdminStatus message)
}

_availableCommands.UnionWith(message.AvailableCommands);
Logger.DebugS("admin", $"Have {message.AvailableCommands.Length} commands available");
_sawmill.Debug($"Have {message.AvailableCommands.Length} commands available");

_adminData = message.Admin;
if (_adminData != null)
{
var flagsText = string.Join("|", AdminFlagsHelper.FlagsToNames(_adminData.Flags));
Logger.InfoS("admin", $"Updated admin status: {_adminData.Active}/{_adminData.Title}/{flagsText}");
_sawmill.Info($"Updated admin status: {_adminData.Active}/{_adminData.Title}/{flagsText}");
}
else
{
Logger.InfoS("admin", "Updated admin status: Not admin");
_sawmill.Info("Updated admin status: Not admin");
}

AdminStatusUpdated?.Invoke();
Expand All @@ -114,26 +116,25 @@ private void UpdateMessageRx(MsgUpdateAdminStatus message)
void IPostInjectInit.PostInject()
{
_conGroup.Implementation = this;
_sawmill = _logManager.GetSawmill("admin");
}

public AdminData? GetAdminData(EntityUid uid, bool includeDeAdmin = false)
{
return uid == _player.LocalPlayer?.ControlledEntity
? _adminData
: null;
return uid == _player.LocalEntity ? _adminData : null;
}

public AdminData? GetAdminData(ICommonSession session, bool includeDeAdmin = false)
{
if (_player.LocalPlayer?.UserId == session.UserId)
if (_player.LocalUser == session.UserId)
return _adminData;

return null;
}

public AdminData? GetAdminData(bool includeDeAdmin = false)
{
if (_player.LocalPlayer is { Session: { } session })
if (_player.LocalSession is { } session)
return GetAdminData(session, includeDeAdmin);

return null;
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)
public void Send(NetUserId channelId, string text, bool playSound)
{
// 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));
RaiseNetworkEvent(new BwoinkTextMessage(channelId, channelId, text, playSound: playSound));
SendInputTextUpdated(channelId, false);
}

Expand Down
2 changes: 2 additions & 0 deletions Content.Client/Administration/UI/Bwoink/BwoinkControl.xaml
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
<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" />
<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" />
<Button Visible="False" Name="Bans" Text="{Loc 'admin-player-actions-bans'}" StyleClasses="OpenRight" />
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public sealed partial class PlayerListControl : BoxContainer
private IEntityManager _entManager;
private IUserInterfaceManager _uiManager;

private PlayerInfo? _selectedPlayer;

public PlayerListControl()
{
_entManager = IoCManager.Resolve<IEntityManager>();
Expand All @@ -50,10 +52,14 @@ private void PlayerListItemPressed(BaseButton.ButtonEventArgs? args, ListData? d
if (args == null || data is not PlayerListData {Info: var selectedPlayer})
return;

if (selectedPlayer == _selectedPlayer)
return;

if (args.Event.Function != EngineKeyFunctions.UIClick)
return;

OnSelectionChanged?.Invoke(selectedPlayer);
_selectedPlayer = selectedPlayer;

// update label text. Only required if there is some override (e.g. unread bwoink count).
if (OverrideText != null && args.Button.Children.FirstOrDefault()?.Children?.FirstOrDefault() is Label label)
Expand Down Expand Up @@ -95,13 +101,18 @@ private void FilterList()
_sortedPlayerList.Sort((a, b) => Comparison(a, b));

PlayerListContainer.PopulateList(_sortedPlayerList.Select(info => new PlayerListData(info)).ToList());
if (_selectedPlayer != null)
PlayerListContainer.Select(new PlayerListData(_selectedPlayer));
}

public void PopulateList(IReadOnlyList<PlayerInfo>? players = null)
{
players ??= _adminSystem.PlayerList;

_playerList = players.ToList();
if (_selectedPlayer != null && !_playerList.Contains(_selectedPlayer))
_selectedPlayer = null;

FilterList();
}

Expand Down
6 changes: 3 additions & 3 deletions Content.Client/Administration/UI/Notes/AdminNotesLine.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ private void Refresh()
SeverityRect.Texture = _sprites.Frame0(new SpriteSpecifier.Texture(new ResPath(iconPath)));
}

TimeLabel.Text = Note.CreatedAt.ToString("yyyy-MM-dd HH:mm:ss");
TimeLabel.Text = Note.CreatedAt.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
ServerLabel.Text = Note.ServerName ?? "Unknown";
RoundLabel.Text = Note.Round == null ? "Unknown round" : "Round " + Note.Round;
AdminLabel.Text = Note.CreatedByName;
Expand All @@ -91,7 +91,7 @@ private void Refresh()
if (Note.ExpiryTime.Value > DateTime.UtcNow)
{
ExpiresLabel.Text = Loc.GetString("admin-note-editor-expiry-label-params",
("date", Note.ExpiryTime.Value.ToString("yyyy-MM-dd HH:mm:ss")),
("date", Note.ExpiryTime.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")),
("expiresIn", (Note.ExpiryTime.Value - DateTime.UtcNow).ToString("d'd 'hh':'mm")));
ExpiresLabel.Modulate = Color.FromHex("#86DC3D");
}
Expand All @@ -104,7 +104,7 @@ private void Refresh()

if (Note.LastEditedAt > Note.CreatedAt)
{
EditedLabel.Text = Loc.GetString("admin-notes-edited", ("author", Note.EditedByName), ("date", Note.LastEditedAt));
EditedLabel.Text = Loc.GetString("admin-notes-edited", ("author", Note.EditedByName), ("date", Note.LastEditedAt.Value.ToLocalTime()));
EditedLabel.Visible = true;
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -36,12 +36,12 @@ public AdminNotesLinePopup(SharedAdminNote note, string playerName, bool showDel
? Loc.GetString("admin-notes-round-id-unknown")
: Loc.GetString("admin-notes-round-id", ("id", note.Round));
CreatedByLabel.Text = Loc.GetString("admin-notes-created-by", ("author", note.CreatedByName));
CreatedAtLabel.Text = Loc.GetString("admin-notes-created-at", ("date", note.CreatedAt.ToString("yyyy-MM-dd HH:mm:ss")));
CreatedAtLabel.Text = Loc.GetString("admin-notes-created-at", ("date", note.CreatedAt.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")));
EditedByLabel.Text = Loc.GetString("admin-notes-last-edited-by", ("author", note.EditedByName));
EditedAtLabel.Text = Loc.GetString("admin-notes-last-edited-at", ("date", note.LastEditedAt?.ToString("yyyy-MM-dd HH:mm:ss") ?? Loc.GetString("admin-notes-edited-never")));
EditedAtLabel.Text = Loc.GetString("admin-notes-last-edited-at", ("date", note.LastEditedAt?.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss") ?? Loc.GetString("admin-notes-edited-never")));
ExpiryTimeLabel.Text = note.ExpiryTime == null
? Loc.GetString("admin-notes-expires-never")
: Loc.GetString("admin-notes-expires", ("expires", note.ExpiryTime.Value.ToString("yyyy-MM-dd HH:mm:ss")));
: Loc.GetString("admin-notes-expires", ("expires", note.ExpiryTime.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss")));
NoteTextEdit.InsertAtCursor(note.Message);

if (note.NoteType is NoteType.ServerBan or NoteType.RoleBan)
Expand Down
6 changes: 3 additions & 3 deletions Content.Client/Administration/UI/Notes/NoteEdit.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ public NoteEdit(SharedAdminNote? note, string playerName, bool canCreate, bool c
{
PermanentCheckBox.Pressed = false;
UpdatePermanentCheckboxFields();
ExpiryLineEdit.Text = ExpiryTime.Value.ToString("yyyy-MM-dd HH:mm:ss");
ExpiryLineEdit.Text = ExpiryTime.Value.ToLocalTime().ToString("yyyy-MM-dd HH:mm:ss");
}
}

Expand Down Expand Up @@ -173,7 +173,7 @@ private void UpdatePermanentCheckboxFields()
ExpiryLabel.Visible = !PermanentCheckBox.Pressed;
ExpiryLineEdit.Visible = !PermanentCheckBox.Pressed;

ExpiryLineEdit.Text = !PermanentCheckBox.Pressed ? DateTime.UtcNow.ToString("yyyy-MM-dd HH:mm:ss") : string.Empty;
ExpiryLineEdit.Text = !PermanentCheckBox.Pressed ? DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss") : string.Empty;
}

private void OnSecretPressed(BaseButton.ButtonEventArgs _)
Expand Down Expand Up @@ -269,7 +269,7 @@ private bool ParseExpiryTime()
return false;
}

ExpiryTime = result;
ExpiryTime = result.ToUniversalTime();
ExpiryLineEdit.ModulateSelfOverride = null;
return true;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -99,7 +99,7 @@ private void SetLocation()
{
UpdateMapOptions();

if (!_entMan.TryGetComponent(_playerManager.LocalPlayer?.ControlledEntity, out TransformComponent? transform))
if (!_entMan.TryGetComponent(_playerManager.LocalEntity, out TransformComponent? transform))
return;

_pausePreview = true;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ private void Reset()
var entManager = IoCManager.Resolve<IEntityManager>();
var xformSystem = entManager.System<SharedTransformSystem>();
var playerManager = IoCManager.Resolve<IPlayerManager>();
var player = playerManager.LocalPlayer?.ControlledEntity;
var player = playerManager.LocalEntity;

var currentMap = MapId.Nullspace;
var position = Vector2.Zero;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ protected override void EnteredTree()
{
_data.Clear();

var player = _players.LocalPlayer?.ControlledEntity;
var player = _players.LocalEntity;
var playerGrid = _entities.GetComponentOrNull<TransformComponent>(player)?.GridUid;
var query = IoCManager.Resolve<IEntityManager>().AllEntityQueryEnumerator<MapGridComponent>();

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ protected override void EnteredTree()
while (gridQuery.MoveNext(out var uid, out _))
{
_gridData.Add(entManager.GetNetEntity(uid));
var player = playerManager.LocalPlayer?.ControlledEntity;
var player = playerManager.LocalEntity;
var playerGrid = entManager.GetComponentOrNull<TransformComponent>(player)?.GridUid;
GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}");
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ protected override void EnteredTree()

while (gridQuery.MoveNext(out var uid, out _))
{
var player = playerManager.LocalPlayer?.ControlledEntity;
var player = playerManager.LocalEntity;
var playerGrid = entManager.GetComponentOrNull<TransformComponent>(player)?.GridUid;
GridOptions.AddItem($"{uid} {(playerGrid == uid ? " (Current)" : "")}");
_gridData.Add(entManager.GetNetEntity(uid));
Expand Down
Loading

0 comments on commit 9180fa4

Please sign in to comment.