From 1b5ec34a7a5139a554553535b46dd5cf8f594cf4 Mon Sep 17 00:00:00 2001 From: Chief-Engineer <119664036+Chief-Engineer@users.noreply.github.com> Date: Sat, 5 Aug 2023 15:53:02 -0500 Subject: [PATCH] add decal logs (#18710) --- Content.Server/Decals/DecalSystem.cs | 30 ++++++++++++++++++++++++++-- 1 file changed, 28 insertions(+), 2 deletions(-) diff --git a/Content.Server/Decals/DecalSystem.cs b/Content.Server/Decals/DecalSystem.cs index a251c1ab94..e76ca25069 100644 --- a/Content.Server/Decals/DecalSystem.cs +++ b/Content.Server/Decals/DecalSystem.cs @@ -2,9 +2,11 @@ using System.Diagnostics.CodeAnalysis; using System.Linq; using System.Numerics; using System.Threading.Tasks; +using Content.Server.Administration.Logs; using Content.Server.Administration.Managers; using Content.Shared.Administration; using Content.Shared.Chunking; +using Content.Shared.Database; using Content.Shared.Decals; using Content.Shared.Maps; using Microsoft.Extensions.ObjectPool; @@ -30,6 +32,7 @@ namespace Content.Server.Decals [Dependency] private readonly ChunkingSystem _chunking = default!; [Dependency] private readonly IConfigurationManager _conf = default!; [Dependency] private readonly IGameTiming _timing = default!; + [Dependency] private readonly IAdminLogManager _adminLogger = default!; private readonly Dictionary> _dirtyChunks = new(); private readonly Dictionary>> _previousSentChunks = new(); @@ -203,7 +206,19 @@ namespace Content.Server.Decals if (!ev.Coordinates.IsValid(EntityManager)) return; - TryAddDecal(ev.Decal, ev.Coordinates, out _); + if (!TryAddDecal(ev.Decal, ev.Coordinates, out _)) + return; + + if (eventArgs.SenderSession.AttachedEntity != null) + { + _adminLogger.Add(LogType.CrayonDraw, LogImpact.High, + $"{ToPrettyString(eventArgs.SenderSession.AttachedEntity.Value):actor} drew a {ev.Decal.Color} {ev.Decal.Id} at {ev.Coordinates}"); + } + else + { + _adminLogger.Add(LogType.CrayonDraw, LogImpact.High, + $"{eventArgs.SenderSession.Name} drew a {ev.Decal.Color} {ev.Decal.Id} at {ev.Coordinates}"); + } } private void OnDecalRemovalRequest(RequestDecalRemovalEvent ev, EntitySessionEventArgs eventArgs) @@ -224,8 +239,19 @@ namespace Content.Server.Decals return; // remove all decals on the same tile - foreach (var (decalId, _) in GetDecalsInRange(gridId.Value, ev.Coordinates.Position)) + foreach (var (decalId, decal) in GetDecalsInRange(gridId.Value, ev.Coordinates.Position)) { + if (eventArgs.SenderSession.AttachedEntity != null) + { + _adminLogger.Add(LogType.CrayonDraw, LogImpact.High, + $"{ToPrettyString(eventArgs.SenderSession.AttachedEntity.Value):actor} removed a {decal.Color} {decal.Id} at {ev.Coordinates}"); + } + else + { + _adminLogger.Add(LogType.CrayonDraw, LogImpact.High, + $"{eventArgs.SenderSession.Name} removed a {decal.Color} {decal.Id} at {ev.Coordinates}"); + } + RemoveDecal(gridId.Value, decalId); } }