]> git.smokeofanarchy.ru Git - space-station-14.git/commitdiff
medibot toctou gaming (#22608)
authordeltanedas <39013340+deltanedas@users.noreply.github.com>
Sat, 16 Dec 2023 22:22:19 +0000 (22:22 +0000)
committerGitHub <noreply@github.com>
Sat, 16 Dec 2023 22:22:19 +0000 (15:22 -0700)
Co-authored-by: deltanedas <@deltanedas:kde.org>
Content.Server/NPC/HTN/PrimitiveTasks/Operators/Specific/MedibotInjectOperator.cs

index c9c495cba52e2091b90ad68b923f5c1f6fa666c1..7b66cff1f8aee4a6154eca528208424a9352d88d 100644 (file)
@@ -16,8 +16,9 @@ namespace Content.Server.NPC.HTN.PrimitiveTasks.Operators.Specific;
 public sealed partial class MedibotInjectOperator : HTNOperator
 {
     [Dependency] private readonly IEntityManager _entMan = default!;
-    private SharedAudioSystem _audio = default!;
     private ChatSystem _chat = default!;
+    private MedibotSystem _medibot = default!;
+    private SharedAudioSystem _audio = default!;
     private SharedInteractionSystem _interaction = default!;
     private SharedPopupSystem _popup = default!;
     private SolutionContainerSystem _solution = default!;
@@ -31,8 +32,9 @@ public sealed partial class MedibotInjectOperator : HTNOperator
     public override void Initialize(IEntitySystemManager sysManager)
     {
         base.Initialize(sysManager);
-        _audio = sysManager.GetEntitySystem<SharedAudioSystem>();
         _chat = sysManager.GetEntitySystem<ChatSystem>();
+        _medibot = sysManager.GetEntitySystem<MedibotSystem>();
+        _audio = sysManager.GetEntitySystem<SharedAudioSystem>();
         _interaction = sysManager.GetEntitySystem<SharedInteractionSystem>();
         _popup = sysManager.GetEntitySystem<SharedPopupSystem>();
         _solution = sysManager.GetEntitySystem<SolutionContainerSystem>();
@@ -75,8 +77,7 @@ public sealed partial class MedibotInjectOperator : HTNOperator
             return HTNOperatorStatus.Failed;
 
         var state = mobState.CurrentState;
-        var treatment = botComp.Treatments[mobState.CurrentState];
-        if (!treatment.IsValid(total))
+        if (!_medibot.TryGetTreatment(botComp, mobState.CurrentState, out var treatment) || !treatment.IsValid(total))
             return HTNOperatorStatus.Failed;
 
         _entMan.EnsureComponent<NPCRecentlyInjectedComponent>(target);