Skip to content

Commit

Permalink
Fix BuyerJobCondition not being checked when the user has no job (spa…
Browse files Browse the repository at this point in the history
  • Loading branch information
DrSmugleaf authored Sep 1, 2023
1 parent b1e2112 commit 895e5de
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 34 deletions.
41 changes: 19 additions & 22 deletions Content.Server/Store/Conditions/BuyerDepartmentCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -37,38 +37,35 @@ public override bool Condition(ListingConditionArgs args)
return true;

var jobs = ent.System<SharedJobSystem>();
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<DepartmentPrototype>())
{
foreach (var department in prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
{
if (job.PrototypeId == null ||
!department.Roles.Contains(job.PrototypeId) ||
!Blacklist.Contains(department.ID))
continue;

if (department.Roles.Contains(job.PrototypeId) && Blacklist.Contains(department.ID))
return false;
}
}
}

if (Whitelist != null)
if (Whitelist != null)
{
var found = false;

if (job?.PrototypeId != null)
{
var found = false;
foreach (var department in prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
{
if (job.PrototypeId == null ||
!department.Roles.Contains(job.PrototypeId) ||
!Whitelist.Contains(department.ID))
continue;

found = true;
break;
if (department.Roles.Contains(job.PrototypeId) && Whitelist.Contains(department.ID))
{
found = true;
break;
}
}

if (!found)
return false;
}

if (!found)
return false;
}

return true;
Expand Down
23 changes: 11 additions & 12 deletions Content.Server/Store/Conditions/BuyerJobCondition.cs
Original file line number Diff line number Diff line change
Expand Up @@ -34,19 +34,18 @@ public override bool Condition(ListingConditionArgs args)
return true;

var jobs = ent.System<SharedJobSystem>();
if (jobs.MindTryGetJob(mindId, out var job, out _))
jobs.MindTryGetJob(mindId, out var job, out _);

if (Blacklist != null)
{
if (job?.PrototypeId != null && Blacklist.Contains(job.PrototypeId))
return false;
}

if (Whitelist != null)
{
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;
}
if (job?.PrototypeId == null || !Whitelist.Contains(job.PrototypeId))
return false;
}

return true;
Expand Down

0 comments on commit 895e5de

Please sign in to comment.