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:
Xurkon
2026-06-12 18:35:31 -05:00
parent 76d4e6e4c8
commit 9dce126735
4 changed files with 9 additions and 9 deletions
+3 -3
View File
@@ -178,7 +178,7 @@ _GetDarkmoonFaireLocationEra = function(currentDate)
local monthOffset = (currentDate.year - baseInfo.year) * 12 + (currentDate.month - baseInfo.month)
local firstWeekday = C_Calendar.GetMonthInfo(monthOffset).firstWeekday
local eventLocation = (currentDate.month % 2) == 0 and DMF_LOCATIONS.MULGORE or DMF_LOCATIONS.ELWYNN_FOREST
local eventLocation = math.mod(currentDate.month, 2) == 0 and DMF_LOCATIONS.MULGORE or DMF_LOCATIONS.ELWYNN_FOREST
local dayOfMonth = currentDate.monthDay
if firstWeekday == 1 then
@@ -230,7 +230,7 @@ _GetDarkmoonFaireLocationSoD = function(currentDate)
local eventDuration = initialEndDate - initialStartDate
local timeSinceStart = currentDate - initialStartDate
local positionInCurrentCycle = timeSinceStart % (eventDuration * 2) -- * 2 because the event repeats every two weeks
local positionInCurrentCycle = math.mod(timeSinceStart, (eventDuration * 2)) -- * 2 because the event repeats every two weeks
local isEventActive = positionInCurrentCycle < eventDuration
@@ -240,7 +240,7 @@ _GetDarkmoonFaireLocationSoD = function(currentDate)
local weeksSinceStart = math.floor(timeSinceStart / eventDuration)
if weeksSinceStart % 4 == 0 then
if math.mod(weeksSinceStart, 4) == 0 then
return DMF_LOCATIONS.MULGORE
else
return DMF_LOCATIONS.ELWYNN_FOREST
+2 -2
View File
@@ -915,7 +915,7 @@ end
function QuestieDB.IsDailyQuest(questId)
local flags = QuestieDB.QueryQuestSingle(questId, "questFlags")
-- test a bit flag: (value % (2*flag) >= flag)
return flags and (flags % QUEST_FLAGS_DAILY_X2) >= QUEST_FLAGS_DAILY
return flags and math.mod(flags, QUEST_FLAGS_DAILY_X2) >= QUEST_FLAGS_DAILY
end
---@param questId number
@@ -923,7 +923,7 @@ end
function QuestieDB.IsWeeklyQuest(questId)
local flags = QuestieDB.QueryQuestSingle(questId, "questFlags")
-- test a bit flag: (value % (2*flag) >= flag)
return flags and (flags % QUEST_FLAGS_WEEKLY_X2) >= QUEST_FLAGS_WEEKLY
return flags and math.mod(flags, QUEST_FLAGS_WEEKLY_X2) >= QUEST_FLAGS_WEEKLY
end
---@param questId number
+2 -2
View File
@@ -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()
+2 -2
View File
@@ -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()