mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-09-21 17:04:00 +00:00
Build the effective roles in a single pass
The list restarts whenever a higher priority is found, rather than collecting every role and filtering afterwards. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Fable 5
parent
e79822b26e
commit
59a0e0be13
@@ -168,23 +168,20 @@ local function get_effective_roles(player_name)
|
|||||||
role_ids[#role_ids + 1] = script_data.default_role_id
|
role_ids[#role_ids + 1] = script_data.default_role_id
|
||||||
end
|
end
|
||||||
|
|
||||||
local roles, highest_priority = {}, nil
|
-- Only the roles with the highest priority apply, so the list restarts
|
||||||
|
-- whenever a higher priority is found
|
||||||
|
local rtn, highest_priority = {}, nil
|
||||||
for _, role_id in pairs(role_ids) do
|
for _, role_id in pairs(role_ids) do
|
||||||
local role = script_data.roles[role_id]
|
local role = script_data.roles[role_id]
|
||||||
if role then
|
if role then
|
||||||
roles[#roles + 1] = role
|
|
||||||
if highest_priority == nil or role.priority > highest_priority then
|
if highest_priority == nil or role.priority > highest_priority then
|
||||||
highest_priority = role.priority
|
highest_priority = role.priority
|
||||||
|
rtn = { role }
|
||||||
|
elseif role.priority == highest_priority then
|
||||||
|
rtn[#rtn + 1] = role
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
local rtn = {}
|
|
||||||
for _, role in pairs(roles) do
|
|
||||||
if role.priority == highest_priority then
|
|
||||||
rtn[#rtn + 1] = role
|
|
||||||
end
|
|
||||||
end
|
|
||||||
return rtn
|
return rtn
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user