mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-21 23:33:12 +09: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:
1 parent
e79822b26e
commit
59a0e0be13
1 file changed
+6
-9
@@ -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