compat(lua50): replace % modulo operator with math.mod shim
Lua 5.0 (Vanilla 1.12) has no % operator outside string formatting; it is a parse error. Route the 9 arithmetic modulo sites through the existing math.mod shim (Compat/Compat.lua) so the addon parses on 5.0 through Retail. Sites: QuestieDB daily/weekly flag tests, QuestieEvent DMF cycle math, QuestieLearner GUID/flag math, QuestiePlayer race/class flag tests.
This commit is contained in:
@@ -3348,7 +3348,7 @@ local function GetIdAndTypeFromGUID(guid)
|
||||
if t then
|
||||
local low32 = tonumber(string.sub(guid, 11, 18), 16)
|
||||
if low32 then
|
||||
local nid = low32 % 8388608
|
||||
local nid = math.mod(low32, 8388608)
|
||||
if nid > 0 then return nid, t end
|
||||
end
|
||||
end
|
||||
@@ -3460,7 +3460,7 @@ end
|
||||
local function NpcFlagsHasQuestGiver(flags)
|
||||
if not flags then return false end
|
||||
-- bitwise AND for Lua 5.1 (no bit library guaranteed)
|
||||
return math.floor(flags / NPC_FLAG_QUESTGIVER) % 2 == 1
|
||||
return math.mod(math.floor(flags / NPC_FLAG_QUESTGIVER), 2) == 1
|
||||
end
|
||||
|
||||
function QuestieLearner:OnMouseoverUnit()
|
||||
|
||||
@@ -100,13 +100,13 @@ end
|
||||
---@return boolean
|
||||
function QuestiePlayer.HasRequiredRace(requiredRaces)
|
||||
-- test a bit flag: (value % (2*flag) >= flag)
|
||||
return (not requiredRaces) or (requiredRaces == 0) or ((requiredRaces % playerRaceFlagX2) >= playerRaceFlag)
|
||||
return (not requiredRaces) or (requiredRaces == 0) or (math.mod(requiredRaces, playerRaceFlagX2) >= playerRaceFlag)
|
||||
end
|
||||
|
||||
---@return boolean
|
||||
function QuestiePlayer.HasRequiredClass(requiredClasses)
|
||||
-- test a bit flag: (value % (2*flag) >= flag)
|
||||
return (not requiredClasses) or (requiredClasses == 0) or ((requiredClasses % playerClassFlagX2) >= playerClassFlag)
|
||||
return (not requiredClasses) or (requiredClasses == 0) or (math.mod(requiredClasses, playerClassFlagX2) >= playerClassFlag)
|
||||
end
|
||||
|
||||
function QuestiePlayer:GetCurrentZoneId()
|
||||
|
||||
Reference in New Issue
Block a user