From 5e3b415df77a50f97dc5cde1023f57074e4b9e19 Mon Sep 17 00:00:00 2001 From: deltanedas <@deltanedas:kde.org> Date: Mon, 10 Feb 2025 00:38:12 +0000 Subject: [PATCH] update files that wanted list added and fix stuff --- .../Systems/AdminVerbSystem.Smites.cs | 2 +- .../Systems/CriminalRecordsConsoleSystem.cs | 28 ++++-- .../Systems/CriminalRecordsSystem.cs | 95 +++++++++++++++++-- .../Silicons/Laws/SiliconLawSystem.cs | 2 +- .../Borgs/BorgSwitchableTypeSystem.Lawset.cs | 2 +- .../CriminalRecords/CriminalRecord.cs | 8 +- .../Systems/SharedCriminalRecordsSystem.cs | 22 ++++- 7 files changed, 140 insertions(+), 19 deletions(-) diff --git a/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs b/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs index 7338cf5176..8be4735e02 100644 --- a/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs +++ b/Content.Server/Administration/Systems/AdminVerbSystem.Smites.cs @@ -907,7 +907,7 @@ public sealed partial class AdminVerbSystem EnsureComp(args.Target); EnsureComp(args.Target); EnsureComp(args.Target); - EnsureComp(args.Target); + //EnsureComp(args.Target); // DeltaV EnsureComp(args.Target); EnsureComp(args.Target); EnsureComp(args.Target); diff --git a/Content.Server/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs b/Content.Server/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs index f986bb0ad4..8341c6bb07 100644 --- a/Content.Server/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs +++ b/Content.Server/CriminalRecords/Systems/CriminalRecordsConsoleSystem.cs @@ -76,6 +76,13 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS } } + private void GetOfficer(EntityUid uid, out string officer) + { + var tryGetIdentityShortInfoEvent = new TryGetIdentityShortInfoEvent(null, uid); + RaiseLocalEvent(tryGetIdentityShortInfoEvent); + officer = tryGetIdentityShortInfoEvent.Title ?? Loc.GetString("criminal-records-console-unknown-officer"); + } + private void OnChangeStatus(Entity ent, ref CriminalRecordChangeStatus msg) { // prevent malf client violating wanted/reason nullability @@ -98,17 +105,20 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS return; } + var oldStatus = record.Status; + + var name = _records.RecordName(key.Value); + GetOfficer(mob.Value, out var officer); + // when arresting someone add it to history automatically // fallback exists if the player was not set to wanted beforehand if (msg.Status == SecurityStatus.Detained) { var oldReason = record.Reason ?? Loc.GetString("criminal-records-console-unspecified-reason"); var history = Loc.GetString("criminal-records-console-auto-history", ("reason", oldReason)); - _criminalRecords.TryAddHistory(key.Value, history); + _criminalRecords.TryAddHistory(key.Value, history, officer); } - var oldStatus = record.Status; - // will probably never fail given the checks above name = _records.RecordName(key.Value); officer = Loc.GetString("criminal-records-console-unknown-officer"); @@ -142,10 +152,10 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS (_, SecurityStatus.Paroled) => "paroled", // prisoner did their time (_, SecurityStatus.Discharged) => "released", - // # DeltaV - person is subpoenaed by Justice Department - (_, SecurityStatus.Subpoenaed) => "subpoenaed", // going from any other state to wanted, AOS or prisonbreak / lazy secoff never set them to released and they reoffended (_, SecurityStatus.Wanted) => "wanted", + // DeltaV - person is subpoenaed by Justice Department + (_, SecurityStatus.Subpoenaed) => "subpoenaed", // person is no longer sus (SecurityStatus.Suspected, SecurityStatus.None) => "not-suspected", // going from wanted to none, must have been a mistake @@ -154,7 +164,7 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS (SecurityStatus.Detained, SecurityStatus.None) => "released", // criminal is no longer on parole (SecurityStatus.Paroled, SecurityStatus.None) => "not-parole", - // # DeltaV - Person is no longer subpoenaed + // DeltaV - Person is no longer subpoenaed (SecurityStatus.Subpoenaed, SecurityStatus.None) => "not-subpoenaed", // this is impossible _ => "not-wanted" @@ -167,14 +177,16 @@ public sealed class CriminalRecordsConsoleSystem : SharedCriminalRecordsConsoleS private void OnAddHistory(Entity ent, ref CriminalRecordAddHistory msg) { - if (!CheckSelected(ent, msg.Actor, out _, out var key)) + if (!CheckSelected(ent, msg.Actor, out var mob, out var key)) return; var line = msg.Line.Trim(); if (line.Length < 1 || line.Length > ent.Comp.MaxStringLength) return; - if (!_criminalRecords.TryAddHistory(key.Value, line)) + GetOfficer(mob.Value, out var officer); + + if (!_criminalRecords.TryAddHistory(key.Value, line, officer)) return; // no radio message since its not crucial to officers patrolling diff --git a/Content.Server/CriminalRecords/Systems/CriminalRecordsSystem.cs b/Content.Server/CriminalRecords/Systems/CriminalRecordsSystem.cs index a65fb0be9e..12967fb2a5 100644 --- a/Content.Server/CriminalRecords/Systems/CriminalRecordsSystem.cs +++ b/Content.Server/CriminalRecords/Systems/CriminalRecordsSystem.cs @@ -1,10 +1,15 @@ -using System.Diagnostics.CodeAnalysis; +using System.Linq; +using Content.Server.CartridgeLoader; +using Content.Server.CartridgeLoader.Cartridges; using Content.Server.StationRecords.Systems; using Content.Shared.CriminalRecords; using Content.Shared.CriminalRecords.Systems; using Content.Shared.Security; using Content.Shared.StationRecords; using Content.Server.GameTicking; +using Content.Server.Station.Systems; +using Content.Shared.CartridgeLoader; +using Content.Shared.CartridgeLoader.Cartridges; namespace Content.Server.CriminalRecords.Systems; @@ -20,12 +25,19 @@ public sealed class CriminalRecordsSystem : SharedCriminalRecordsSystem { [Dependency] private readonly GameTicker _ticker = default!; [Dependency] private readonly StationRecordsSystem _records = default!; + [Dependency] private readonly StationSystem _station = default!; + [Dependency] private readonly CartridgeLoaderSystem _cartridge = default!; public override void Initialize() { base.Initialize(); SubscribeLocalEvent(OnGeneralRecordCreated); + /* DeltaV - wanted list replaced by secwatch + SubscribeLocalEvent(OnRecordChanged); + SubscribeLocalEvent(OnCartridgeUiReady); + SubscribeLocalEvent(OnHistoryAdded); + SubscribeLocalEvent(OnHistoryRemoved); */ } private void OnGeneralRecordCreated(AfterGeneralRecordCreatedEvent ev) @@ -39,14 +51,14 @@ public sealed class CriminalRecordsSystem : SharedCriminalRecordsSystem /// Reason should only be passed if status is Wanted, nullability isn't checked. /// /// True if the status is changed, false if not - public bool TryChangeStatus(StationRecordKey key, SecurityStatus status, string? reason) + public bool TryChangeStatus(StationRecordKey key, SecurityStatus status, string? reason, string? initiatorName = null) { // don't do anything if its the same status if (!_records.TryGetRecord(key, out var record) || status == record.Status) return false; - OverwriteStatus(key, record, status, reason); + OverwriteStatus(key, record, status, reason, initiatorName); return true; } @@ -54,16 +66,25 @@ public sealed class CriminalRecordsSystem : SharedCriminalRecordsSystem /// /// Sets the status without checking previous status or reason nullability. /// - public void OverwriteStatus(StationRecordKey key, CriminalRecord record, SecurityStatus status, string? reason) + public void OverwriteStatus(StationRecordKey key, CriminalRecord record, SecurityStatus status, string? reason, string? initiatorName = null) { record.Status = status; record.Reason = reason; + record.InitiatorName = initiatorName; var name = _records.RecordName(key); if (name != string.Empty) UpdateCriminalIdentity(name, status); _records.Synchronize(key); + + /* DeltaV - wanted list replaced by secwatch + var args = new CriminalRecordChangedEvent(record); + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var readerUid, out _)) + { + RaiseLocalEvent(readerUid, ref args); + } */ } /// @@ -76,15 +97,24 @@ public sealed class CriminalRecordsSystem : SharedCriminalRecordsSystem return false; record.History.Add(entry); + + /* DeltaV - wanted list replaced by secwatch + var args = new CriminalHistoryAddedEvent(entry); + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var readerUid, out _)) + { + RaiseLocalEvent(readerUid, ref args); + } */ + return true; } /// /// Creates and tries to add a history entry using the current time. /// - public bool TryAddHistory(StationRecordKey key, string line) + public bool TryAddHistory(StationRecordKey key, string line, string? initiatorName = null) { - var entry = new CrimeHistory(_ticker.RoundDuration(), line); + var entry = new CrimeHistory(_ticker.RoundDuration(), line, initiatorName); return TryAddHistory(key, entry); } @@ -100,7 +130,60 @@ public sealed class CriminalRecordsSystem : SharedCriminalRecordsSystem if (index >= record.History.Count) return false; + var history = record.History[(int)index]; record.History.RemoveAt((int) index); + + /* DeltaV - wanted list replaced by secwatch + var args = new CriminalHistoryRemovedEvent(history); + var query = EntityQueryEnumerator(); + while (query.MoveNext(out var readerUid, out _)) + { + RaiseLocalEvent(readerUid, ref args); + } */ + return true; } + + /* DeltaV - wanted list replaced by secwatch + private void OnRecordChanged(Entity ent, ref CriminalRecordChangedEvent args) => + StateChanged(ent); + + private void OnHistoryAdded(Entity ent, ref CriminalHistoryAddedEvent args) => + StateChanged(ent); + + private void OnHistoryRemoved(Entity ent, ref CriminalHistoryRemovedEvent args) => + StateChanged(ent); + + private void StateChanged(Entity ent) + { + if (Comp(ent).LoaderUid is not { } loaderUid) + return; + + UpdateReaderUi(ent, loaderUid); + } + + private void OnCartridgeUiReady(Entity ent, ref CartridgeUiReadyEvent args) + { + UpdateReaderUi(ent, args.Loader); + } + + private void UpdateReaderUi(Entity ent, EntityUid loaderUid) + { + if (_station.GetOwningStation(ent) is not { } station) + return; + + var records = _records.GetRecordsOfType(station) + .Where(cr => cr.Item2.Status is not SecurityStatus.None || cr.Item2.History.Count > 0) + .Select(cr => + { + var (i, r) = cr; + var key = new StationRecordKey(i, station); + // Hopefully it will work smoothly..... + _records.TryGetRecord(key, out GeneralStationRecord? generalRecord); + return new WantedRecord(generalRecord!, r.Status, r.Reason, r.InitiatorName, r.History); + }); + var state = new WantedListUiState(records.ToList()); + + _cartridge.UpdateCartridgeUiState(loaderUid, state); + }*/ } diff --git a/Content.Server/Silicons/Laws/SiliconLawSystem.cs b/Content.Server/Silicons/Laws/SiliconLawSystem.cs index 40e672f1c1..4cad99334d 100644 --- a/Content.Server/Silicons/Laws/SiliconLawSystem.cs +++ b/Content.Server/Silicons/Laws/SiliconLawSystem.cs @@ -159,7 +159,7 @@ public sealed class SiliconLawSystem : SharedSiliconLawSystem component.Subverted = true; // Add the first emag law before the others - var name = CompOrNull(uid)?.OwnerName ?? Name(args.UserUid); // DeltaV: Reuse emagger name if possible + var name = CompOrNull(uid)?.OwnerName ?? Name(args.user); // DeltaV: Reuse emagger name if possible component.Lawset?.Laws.Insert(0, new SiliconLaw { LawString = Loc.GetString("law-emag-custom", ("name", name), ("title", Loc.GetString(component.Lawset.ObeysTo))), // DeltaV: pass name from variable diff --git a/Content.Server/_DV/Silicons/Borgs/BorgSwitchableTypeSystem.Lawset.cs b/Content.Server/_DV/Silicons/Borgs/BorgSwitchableTypeSystem.Lawset.cs index 28923ed21a..28676610ac 100644 --- a/Content.Server/_DV/Silicons/Borgs/BorgSwitchableTypeSystem.Lawset.cs +++ b/Content.Server/_DV/Silicons/Borgs/BorgSwitchableTypeSystem.Lawset.cs @@ -31,7 +31,7 @@ public sealed partial class BorgSwitchableTypeSystem if (CompOrNull(uid)?.OwnerName != null) { // raising the event manually to bypass re-emagging checks - var ev = new GotEmaggedEvent(uid); // user wont be used since OwnerName isnt null, safe to pass itself + var ev = new GotEmaggedEvent(uid, EmagType.Interaction); // user wont be used since OwnerName isnt null, safe to pass itself RaiseLocalEvent(uid, ref ev); } diff --git a/Content.Shared/CriminalRecords/CriminalRecord.cs b/Content.Shared/CriminalRecords/CriminalRecord.cs index 0fe23d4395..5a023a9188 100644 --- a/Content.Shared/CriminalRecords/CriminalRecord.cs +++ b/Content.Shared/CriminalRecords/CriminalRecord.cs @@ -23,6 +23,12 @@ public sealed record CriminalRecord [DataField] public string? Reason; + /// + /// The name of the person who changed the status. + /// + [DataField] + public string? InitiatorName; + /// /// Criminal history of the person. /// This should have charges and time served added after someone is detained. @@ -35,4 +41,4 @@ public sealed record CriminalRecord /// A line of criminal activity and the time it was added at. /// [Serializable, NetSerializable] -public record struct CrimeHistory(TimeSpan AddTime, string Crime); +public record struct CrimeHistory(TimeSpan AddTime, string Crime, string? InitiatorName); diff --git a/Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsSystem.cs b/Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsSystem.cs index 195ff0f746..d665d32f1e 100644 --- a/Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsSystem.cs +++ b/Content.Shared/CriminalRecords/Systems/SharedCriminalRecordsSystem.cs @@ -2,6 +2,8 @@ using Content.Shared.IdentityManagement; using Content.Shared.IdentityManagement.Components; using Content.Shared.Security; using Content.Shared.Security.Components; +using Content.Shared.StationRecords; +using Robust.Shared.Serialization; namespace Content.Shared.CriminalRecords.Systems; @@ -43,7 +45,6 @@ public abstract class SharedCriminalRecordsSystem : EntitySystem SecurityStatus.Detained => "SecurityIconIncarcerated", SecurityStatus.Discharged => "SecurityIconDischarged", SecurityStatus.Suspected => "SecurityIconSuspected", - SecurityStatus.Subpoenaed => "SecurityIconSubpoenaed", /// # DeltaV Justice Department Subpoena _ => record.StatusIcon }; @@ -51,3 +52,22 @@ public abstract class SharedCriminalRecordsSystem : EntitySystem Dirty(characterUid, record); } } + +[Serializable, NetSerializable] +public struct WantedRecord(GeneralStationRecord targetInfo, SecurityStatus status, string? reason, string? initiator, List history) +{ + public GeneralStationRecord TargetInfo = targetInfo; + public SecurityStatus Status = status; + public string? Reason = reason; + public string? Initiator = initiator; + public List History = history; +}; + +[ByRefEvent] +public record struct CriminalRecordChangedEvent(CriminalRecord Record); + +[ByRefEvent] +public record struct CriminalHistoryAddedEvent(CrimeHistory History); + +[ByRefEvent] +public record struct CriminalHistoryRemovedEvent(CrimeHistory History);