Changes
simplify Protection:makeProtectionCategory and update the comments
end
-- Get the expirykey fragment. local expiryFragment if self.expiry == 'indef' then expiryFragment = self.expiry if elseif type(self.expiry) == 'number' then expiry expiryFragment = 'temp' elseif expiry ~= 'indef' then expiry = nil
end
-- Get the namespace category keyfragment. local nskeynamespaceFragment
do
end
end
}
end
--[[
-- Define the attempt order. Properties Inactive subtables (subtables with no nil "value defined are moved" -- fields) are moved to the end, where they will later be given the value key -- "all". This is -- to cut down on the number of table lookups in the cats table, which -- cfg.protectionCategories, which grows exponentially with the number of properties with valid values. -- non-nil keys. We keep track of the number of active properties subtables with the noActive -- noActive parameter.
--]]
local noActive, attemptOrder
do
local active, inactive = {}, {}
for i, t in ipairs(configOrderorder) do
if t.val then
active[#active + 1] = t
--[[
-- Check increasingly generic key combinations until we find a match.If a -- If a specific category exists for the combination of propertieskey fragments we are -- we are given, that match will be found first. If not, we keeptrying different -- trying different key fragment combinations until we match using the key
-- "all-all-all-all-all".
--
-- To generate the keys, we index the property key subtables using abinary matrix -- binary matrix with indexes i and j. j is only calculated up tothe number of active -- the number of active propertiessubtables. For example, if there were threeactive subtables, the matrix -- active properties, the matrix would look like this, with 0 -- corresponding to the string key fragment "all", and 1 corresponding to the -- val field in the property table:1 corresponding to other key fragments.
--
-- j 1 2 3
-- 8 0 0 0
--
-- Values of j higher than the number of active properties subtables are set
-- to the string "all".
--
-- A key for the category table cfg.protectionCategories is constructed for each value of i. -- The correct position of the value in the key is determined by thekeypos field in -- pos field in the property tableeach subtable.
--]]
local cats = cfg.protectionCategories
for j, t in ipairs(attemptOrder) do
if j > noActive then
key[t.orderkeypos] = 'all'
else
local quotient = i / 2 ^ (j - 1)
quotient = math.ceil(quotient)
if quotient % 2 == 1 then
key[t.orderkeypos] = t.val
else
key[t.orderkeypos] = 'all'
end
end