From 9dce1267355379a48fa9e6c11b25e277d4a3eded Mon Sep 17 00:00:00 2001 From: Xurkon Date: Fri, 12 Jun 2026 18:35:31 -0500 Subject: [PATCH] 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. --- Database/Corrections/QuestieEvent.lua | 6 +++--- Database/QuestieDB.lua | 4 ++-- Modules/QuestieLearner.lua | 4 ++-- Modules/QuestiePlayer.lua | 4 ++-- 4 files changed, 9 insertions(+), 9 deletions(-) diff --git a/Database/Corrections/QuestieEvent.lua b/Database/Corrections/QuestieEvent.lua index 8c3195d..49db516 100644 --- a/Database/Corrections/QuestieEvent.lua +++ b/Database/Corrections/QuestieEvent.lua @@ -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 diff --git a/Database/QuestieDB.lua b/Database/QuestieDB.lua index d3471e0..44c475c 100644 --- a/Database/QuestieDB.lua +++ b/Database/QuestieDB.lua @@ -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 diff --git a/Modules/QuestieLearner.lua b/Modules/QuestieLearner.lua index 8bb00e2..f97c34d 100644 --- a/Modules/QuestieLearner.lua +++ b/Modules/QuestieLearner.lua @@ -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() diff --git a/Modules/QuestiePlayer.lua b/Modules/QuestiePlayer.lua index 9689051..8909379 100644 --- a/Modules/QuestiePlayer.lua +++ b/Modules/QuestiePlayer.lua @@ -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()