]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
Fix DamageOtherOnHit.OnDoHit when the target is terminating or deleted (#28690)
authorDrSmugleaf <10968691+DrSmugleaf@users.noreply.github.com>
Sat, 8 Jun 2024 05:53:54 +0000 (22:53 -0700)
committerGitHub <noreply@github.com>
Sat, 8 Jun 2024 05:53:54 +0000 (15:53 +1000)
Content.Server/Damage/Systems/DamageOtherOnHitSystem.cs

index 0efa534981510ed33e19e8c87ca965b17325edf1..ff4d1cabe98a9abbe0be9a6a8b12a99ad79ca7d1 100644 (file)
@@ -32,22 +32,25 @@ namespace Content.Server.Damage.Systems
 
         private void OnDoHit(EntityUid uid, DamageOtherOnHitComponent component, ThrowDoHitEvent args)
         {
-            var dmg = _damageable.TryChangeDamage(args.Target, component.Damage, component.IgnoreResistances, origin: args.Component.Thrower);
+            if (!TerminatingOrDeleted(args.Target))
+            {
+                var dmg = _damageable.TryChangeDamage(args.Target, component.Damage, component.IgnoreResistances, origin: args.Component.Thrower);
 
-            // Log damage only for mobs. Useful for when people throw spears at each other, but also avoids log-spam when explosions send glass shards flying.
-            if (dmg != null && HasComp<MobStateComponent>(args.Target))
-                _adminLogger.Add(LogType.ThrowHit, $"{ToPrettyString(args.Target):target} received {dmg.GetTotal():damage} damage from collision");
+                // Log damage only for mobs. Useful for when people throw spears at each other, but also avoids log-spam when explosions send glass shards flying.
+                if (dmg != null && HasComp<MobStateComponent>(args.Target))
+                    _adminLogger.Add(LogType.ThrowHit, $"{ToPrettyString(args.Target):target} received {dmg.GetTotal():damage} damage from collision");
 
-            if (dmg is { Empty: false })
-            {
-                _color.RaiseEffect(Color.Red, new List<EntityUid>() { args.Target }, Filter.Pvs(args.Target, entityManager: EntityManager));
-            }
+                if (dmg is { Empty: false })
+                {
+                    _color.RaiseEffect(Color.Red, new List<EntityUid>() { args.Target }, Filter.Pvs(args.Target, entityManager: EntityManager));
+                }
 
-            _guns.PlayImpactSound(args.Target, dmg, null, false);
-            if (TryComp<PhysicsComponent>(uid, out var body) && body.LinearVelocity.LengthSquared() > 0f)
-            {
-                var direction = body.LinearVelocity.Normalized();
-                _sharedCameraRecoil.KickCamera(args.Target, direction);
+                _guns.PlayImpactSound(args.Target, dmg, null, false);
+                if (TryComp<PhysicsComponent>(uid, out var body) && body.LinearVelocity.LengthSquared() > 0f)
+                {
+                    var direction = body.LinearVelocity.Normalized();
+                    _sharedCameraRecoil.KickCamera(args.Target, direction);
+                }
             }
 
             // TODO: If more stuff touches this then handle it after.