fix charged spells vulnerability (#612)

This commit is contained in:
MJSailor
2024-08-12 10:46:30 +00:00
committed by GitHub
parent 2881df9886
commit 6073d9a87c
3 changed files with 16 additions and 6 deletions

View File

@@ -132,7 +132,7 @@ public sealed class ChargeActionSystem : SharedChargingSystem
{
if (_chargeLevel > 0 && _charging)
{
RaiseNetworkEvent(new AddWizardChargeEvent(action.ChargeProto));
RaiseNetworkEvent(new AddWizardChargeEvent(GetNetEntity(actionId)));
}
_prevChargeLevel = _chargeLevel;
}

View File

@@ -1,5 +1,7 @@
using Content.Shared._White.Wizard;
using Content.Server.Actions;
using Content.Shared._White.Wizard;
using Content.Shared._White.Wizard.Charging;
using Content.Shared.Actions;
using Content.Shared.Follower;
using Content.Shared.Mobs;
using Robust.Shared.Audio;
@@ -12,6 +14,7 @@ public sealed class ChargingSystem : SharedChargingSystem
{
[Dependency] private readonly SharedAudioSystem _audio = default!;
[Dependency] private readonly FollowerSystem _followerSystem = default!;
[Dependency] private readonly ActionsSystem _actionsSystem = default!;
private readonly Dictionary<EntityUid, List<EntityUid>> _charges = new();
@@ -132,8 +135,15 @@ public sealed class ChargingSystem : SharedChargingSystem
private void Add(AddWizardChargeEvent msg, EntitySessionEventArgs args)
{
var spell = GetEntity(msg.Spell);
if (!_actionsSystem.TryGetActionData(spell, out var baseAction) ||
baseAction is not BaseTargetActionComponent action || !action.IsChargeEnabled)
{
return;
}
if (args.SenderSession.AttachedEntity != null)
AddCharge(args.SenderSession.AttachedEntity.Value, msg.ChargeProto);
AddCharge(args.SenderSession.AttachedEntity.Value, action.ChargeProto);
}
private void Remove(RemoveWizardChargeEvent msg, EntitySessionEventArgs args)

View File

@@ -31,11 +31,11 @@ public struct BeforeCastSpellEvent
[Serializable, NetSerializable]
public sealed partial class AddWizardChargeEvent : EntityEventArgs
{
public string ChargeProto;
public NetEntity Spell;
public AddWizardChargeEvent(string chargeProto)
public AddWizardChargeEvent(NetEntity spell)
{
ChargeProto = chargeProto;
Spell = spell;
}
}