From 895e5de55307fbc358b0b86a2e947da1fedc0032 Mon Sep 17 00:00:00 2001 From: DrSmugleaf Date: Fri, 1 Sep 2023 00:24:36 -0700 Subject: [PATCH] Fix BuyerJobCondition not being checked when the user has no job (#19726) --- .../Conditions/BuyerDepartmentCondition.cs | 47 +++++++++---------- .../Store/Conditions/BuyerJobCondition.cs | 23 +++++---- 2 files changed, 33 insertions(+), 37 deletions(-) diff --git a/Content.Server/Store/Conditions/BuyerDepartmentCondition.cs b/Content.Server/Store/Conditions/BuyerDepartmentCondition.cs index 43175b6a80..a71adc4e77 100644 --- a/Content.Server/Store/Conditions/BuyerDepartmentCondition.cs +++ b/Content.Server/Store/Conditions/BuyerDepartmentCondition.cs @@ -37,38 +37,35 @@ public sealed partial class BuyerDepartmentCondition : ListingCondition return true; var jobs = ent.System(); - if (jobs.MindTryGetJob(mindId, out var job, out _)) + jobs.MindTryGetJob(mindId, out var job, out _); + + if (Blacklist != null && job?.PrototypeId != null) { - if (Blacklist != null) + foreach (var department in prototypeManager.EnumeratePrototypes()) + { + if (department.Roles.Contains(job.PrototypeId) && Blacklist.Contains(department.ID)) + return false; + } + } + + if (Whitelist != null) + { + var found = false; + + if (job?.PrototypeId != null) { foreach (var department in prototypeManager.EnumeratePrototypes()) { - if (job.PrototypeId == null || - !department.Roles.Contains(job.PrototypeId) || - !Blacklist.Contains(department.ID)) - continue; - - return false; + if (department.Roles.Contains(job.PrototypeId) && Whitelist.Contains(department.ID)) + { + found = true; + break; + } } } - if (Whitelist != null) - { - var found = false; - foreach (var department in prototypeManager.EnumeratePrototypes()) - { - if (job.PrototypeId == null || - !department.Roles.Contains(job.PrototypeId) || - !Whitelist.Contains(department.ID)) - continue; - - found = true; - break; - } - - if (!found) - return false; - } + if (!found) + return false; } return true; diff --git a/Content.Server/Store/Conditions/BuyerJobCondition.cs b/Content.Server/Store/Conditions/BuyerJobCondition.cs index 47227cf79c..f5013008ab 100644 --- a/Content.Server/Store/Conditions/BuyerJobCondition.cs +++ b/Content.Server/Store/Conditions/BuyerJobCondition.cs @@ -34,19 +34,18 @@ public sealed partial class BuyerJobCondition : ListingCondition return true; var jobs = ent.System(); - if (jobs.MindTryGetJob(mindId, out var job, out _)) - { - if (Blacklist != null) - { - if (job.PrototypeId != null && Blacklist.Contains(job.PrototypeId)) - return false; - } + jobs.MindTryGetJob(mindId, out var job, out _); - if (Whitelist != null) - { - if (job.PrototypeId == null || !Whitelist.Contains(job.PrototypeId)) - return false; - } + if (Blacklist != null) + { + if (job?.PrototypeId != null && Blacklist.Contains(job.PrototypeId)) + return false; + } + + if (Whitelist != null) + { + if (job?.PrototypeId == null || !Whitelist.Contains(job.PrototypeId)) + return false; } return true;