Fix BuyerJobCondition not being checked when the user has no job (#19726)
This commit is contained in:
@@ -37,17 +37,13 @@ public sealed partial class BuyerDepartmentCondition : ListingCondition
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
var jobs = ent.System<SharedJobSystem>();
|
var jobs = ent.System<SharedJobSystem>();
|
||||||
if (jobs.MindTryGetJob(mindId, out var job, out _))
|
jobs.MindTryGetJob(mindId, out var job, out _);
|
||||||
{
|
|
||||||
if (Blacklist != null)
|
if (Blacklist != null && job?.PrototypeId != null)
|
||||||
{
|
{
|
||||||
foreach (var department in prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
|
foreach (var department in prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
|
||||||
{
|
{
|
||||||
if (job.PrototypeId == null ||
|
if (department.Roles.Contains(job.PrototypeId) && Blacklist.Contains(department.ID))
|
||||||
!department.Roles.Contains(job.PrototypeId) ||
|
|
||||||
!Blacklist.Contains(department.ID))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -55,21 +51,22 @@ public sealed partial class BuyerDepartmentCondition : ListingCondition
|
|||||||
if (Whitelist != null)
|
if (Whitelist != null)
|
||||||
{
|
{
|
||||||
var found = false;
|
var found = false;
|
||||||
|
|
||||||
|
if (job?.PrototypeId != null)
|
||||||
|
{
|
||||||
foreach (var department in prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
|
foreach (var department in prototypeManager.EnumeratePrototypes<DepartmentPrototype>())
|
||||||
{
|
{
|
||||||
if (job.PrototypeId == null ||
|
if (department.Roles.Contains(job.PrototypeId) && Whitelist.Contains(department.ID))
|
||||||
!department.Roles.Contains(job.PrototypeId) ||
|
{
|
||||||
!Whitelist.Contains(department.ID))
|
|
||||||
continue;
|
|
||||||
|
|
||||||
found = true;
|
found = true;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (!found)
|
if (!found)
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -34,20 +34,19 @@ public sealed partial class BuyerJobCondition : ListingCondition
|
|||||||
return true;
|
return true;
|
||||||
|
|
||||||
var jobs = ent.System<SharedJobSystem>();
|
var jobs = ent.System<SharedJobSystem>();
|
||||||
if (jobs.MindTryGetJob(mindId, out var job, out _))
|
jobs.MindTryGetJob(mindId, out var job, out _);
|
||||||
{
|
|
||||||
if (Blacklist != null)
|
if (Blacklist != null)
|
||||||
{
|
{
|
||||||
if (job.PrototypeId != null && Blacklist.Contains(job.PrototypeId))
|
if (job?.PrototypeId != null && Blacklist.Contains(job.PrototypeId))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Whitelist != null)
|
if (Whitelist != null)
|
||||||
{
|
{
|
||||||
if (job.PrototypeId == null || !Whitelist.Contains(job.PrototypeId))
|
if (job?.PrototypeId == null || !Whitelist.Contains(job.PrototypeId))
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user