From 30ada263157895cbbbff200e638a7d94ace6b421 Mon Sep 17 00:00:00 2001
From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com>
Date: Mon, 14 Oct 2024 17:05:40 +1300
Subject: [PATCH] Remove inaccurate admin log when moving a held item (#32525)
Remove inaccurate admin log when switching held item
---
Content.Client/Hands/Systems/HandsSystem.cs | 4 ++--
.../Hands/EntitySystems/SharedHandsSystem.Drop.cs | 10 +++++++---
.../EntitySystems/SharedHandsSystem.Interactions.cs | 4 ++--
.../Hands/EntitySystems/SharedHandsSystem.Pickup.cs | 5 +++--
Content.Shared/Interaction/SharedInteractionSystem.cs | 2 --
5 files changed, 14 insertions(+), 11 deletions(-)
diff --git a/Content.Client/Hands/Systems/HandsSystem.cs b/Content.Client/Hands/Systems/HandsSystem.cs
index ffa6dfd29d..68800a2afe 100644
--- a/Content.Client/Hands/Systems/HandsSystem.cs
+++ b/Content.Client/Hands/Systems/HandsSystem.cs
@@ -130,9 +130,9 @@ namespace Content.Client.Hands.Systems
OnPlayerHandsAdded?.Invoke(hands);
}
- public override void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, HandsComponent? hands = null)
+ public override void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, HandsComponent? hands = null, bool log = true)
{
- base.DoDrop(uid, hand, doDropInteraction, hands);
+ base.DoDrop(uid, hand, doDropInteraction, hands, log);
if (TryComp(hand.HeldEntity, out SpriteComponent? sprite))
sprite.RenderOrder = EntityManager.CurrentTick.Value;
diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs
index 76575df2fd..223c2d4a37 100644
--- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs
+++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Drop.cs
@@ -1,4 +1,5 @@
using System.Numerics;
+using Content.Shared.Database;
using Content.Shared.Hands.Components;
using Content.Shared.Interaction;
using Content.Shared.Inventory.VirtualItem;
@@ -130,7 +131,7 @@ public abstract partial class SharedHandsSystem
TransformSystem.DropNextTo((entity, itemXform), (uid, userXform));
return true;
}
-
+
// drop the item with heavy calculations from their hands and place it at the calculated interaction range position
// The DoDrop is handle if there's no drop target
DoDrop(uid, hand, doDropInteraction: doDropInteraction, handsComp);
@@ -138,7 +139,7 @@ public abstract partial class SharedHandsSystem
// if there's no drop location stop here
if (targetDropLocation == null)
return true;
-
+
// otherwise, also move dropped item and rotate it properly according to grid/map
var (itemPos, itemRot) = TransformSystem.GetWorldPositionRotation(entity);
var origin = new MapCoordinates(itemPos, itemXform.MapID);
@@ -197,7 +198,7 @@ public abstract partial class SharedHandsSystem
///
/// Removes the contents of a hand from its container. Assumes that the removal is allowed. In general, you should not be calling this directly.
///
- public virtual void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, HandsComponent? handsComp = null)
+ public virtual void DoDrop(EntityUid uid, Hand hand, bool doDropInteraction = true, HandsComponent? handsComp = null, bool log = true)
{
if (!Resolve(uid, ref handsComp))
return;
@@ -221,6 +222,9 @@ public abstract partial class SharedHandsSystem
if (doDropInteraction)
_interactionSystem.DroppedInteraction(uid, entity);
+ if (log)
+ _adminLogger.Add(LogType.Drop, LogImpact.Low, $"{ToPrettyString(uid):user} dropped {ToPrettyString(entity):entity}");
+
if (hand == handsComp.ActiveHand)
RaiseLocalEvent(entity, new HandDeselectedEvent(uid));
}
diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs
index ae22efcd6a..fc5adfaf15 100644
--- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs
+++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Interactions.cs
@@ -178,8 +178,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
if (!CanPickupToHand(uid, entity, handsComp.ActiveHand, checkActionBlocker, handsComp))
return false;
- DoDrop(uid, hand, false, handsComp);
- DoPickup(uid, handsComp.ActiveHand, entity, handsComp);
+ DoDrop(uid, hand, false, handsComp, log:false);
+ DoPickup(uid, handsComp.ActiveHand, entity, handsComp, log: false);
return true;
}
diff --git a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs
index 6d619460f4..7bc0a8025f 100644
--- a/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs
+++ b/Content.Shared/Hands/EntitySystems/SharedHandsSystem.Pickup.cs
@@ -220,7 +220,7 @@ public abstract partial class SharedHandsSystem : EntitySystem
///
/// Puts an entity into the player's hand, assumes that the insertion is allowed. In general, you should not be calling this function directly.
///
- public virtual void DoPickup(EntityUid uid, Hand hand, EntityUid entity, HandsComponent? hands = null)
+ public virtual void DoPickup(EntityUid uid, Hand hand, EntityUid entity, HandsComponent? hands = null, bool log = true)
{
if (!Resolve(uid, ref hands))
return;
@@ -235,7 +235,8 @@ public abstract partial class SharedHandsSystem : EntitySystem
return;
}
- _adminLogger.Add(LogType.Pickup, LogImpact.Low, $"{ToPrettyString(uid):user} picked up {ToPrettyString(entity):entity}");
+ if (log)
+ _adminLogger.Add(LogType.Pickup, LogImpact.Low, $"{ToPrettyString(uid):user} picked up {ToPrettyString(entity):entity}");
Dirty(uid, hands);
diff --git a/Content.Shared/Interaction/SharedInteractionSystem.cs b/Content.Shared/Interaction/SharedInteractionSystem.cs
index 43dd97762c..ddbf3ee572 100644
--- a/Content.Shared/Interaction/SharedInteractionSystem.cs
+++ b/Content.Shared/Interaction/SharedInteractionSystem.cs
@@ -1166,8 +1166,6 @@ namespace Content.Shared.Interaction
{
var dropMsg = new DroppedEvent(user);
RaiseLocalEvent(item, dropMsg, true);
- if (dropMsg.Handled)
- _adminLogger.Add(LogType.Drop, LogImpact.Low, $"{ToPrettyString(user):user} dropped {ToPrettyString(item):entity}");
// If the dropper is rotated then use their targetrelativerotation as the drop rotation
var rotation = Angle.Zero;
--
2.52.0