From 52272e19cd0b1af6f417c6d3b2f52c5bb15e98b2 Mon Sep 17 00:00:00 2001 From: Leon Friedrich <60421075+ElectroJr@users.noreply.github.com> Date: Tue, 3 Jan 2023 19:43:35 +1300 Subject: [PATCH] Fix damage mispredict (#13304) Fixes https://github.com/space-wizards/space-station-14/issues/13147 --- Content.Shared/Damage/Systems/DamageableSystem.cs | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Content.Shared/Damage/Systems/DamageableSystem.cs b/Content.Shared/Damage/Systems/DamageableSystem.cs index bd6b0c1da7..3e33d113d6 100644 --- a/Content.Shared/Damage/Systems/DamageableSystem.cs +++ b/Content.Shared/Damage/Systems/DamageableSystem.cs @@ -7,6 +7,7 @@ using Content.Shared.MobState.Components; using Content.Shared.Radiation.Events; using Content.Shared.Rejuvenate; using Robust.Shared.GameStates; +using Robust.Shared.Network; using Robust.Shared.Prototypes; using Robust.Shared.Utility; @@ -16,6 +17,7 @@ namespace Content.Shared.Damage { [Dependency] private readonly IPrototypeManager _prototypeManager = default!; [Dependency] private readonly SharedAppearanceSystem _appearance = default!; + [Dependency] private readonly INetManager _netMan = default!; public override void Initialize() { @@ -231,7 +233,15 @@ namespace Content.Shared.Damage private void DamageableGetState(EntityUid uid, DamageableComponent component, ref ComponentGetState args) { - args.State = new DamageableComponentState(component.Damage.DamageDict, component.DamageModifierSetId); + if (_netMan.IsServer) + { + args.State = new DamageableComponentState(component.Damage.DamageDict, component.DamageModifierSetId); + } + else + { + // avoid mispredicting damage on newly spawned entities. + args.State = new DamageableComponentState(component.Damage.DamageDict.ShallowClone(), component.DamageModifierSetId); + } } private void OnIrradiated(EntityUid uid, DamageableComponent component, OnIrradiatedEvent args)