Skip to content

Commit c7b3e22

Browse files
committed
protect event registration and unregistration calls so they can't cause errors in editions of WoW which don't have them
1 parent 75131eb commit c7b3e22

File tree

1 file changed

+33
-41
lines changed

1 file changed

+33
-41
lines changed

AutoGear.lua

Lines changed: 33 additions & 41 deletions
Original file line numberDiff line numberDiff line change
@@ -1913,7 +1913,7 @@ InterfaceOptions_AddCategory(optionsMenu)
19131913
if InterfaceAddOnsList_Update then InterfaceAddOnsList_Update() end
19141914

19151915
--handle PLAYER_ENTERING_WORLD events for initialization
1916-
optionsMenu:RegisterEvent("PLAYER_ENTERING_WORLD")
1916+
pcall(optionsMenu.RegisterEvent,optionsMenu,"PLAYER_ENTERING_WORLD")
19171917
optionsMenu:SetScript("OnEvent", function (self, event, arg1, arg2, ...)
19181918
if event == "PLAYER_ENTERING_WORLD" then
19191919

@@ -2225,44 +2225,36 @@ optionsMenu:SetScript("OnEvent", function (self, event, arg1, arg2, ...)
22252225
optionsMenu:UnregisterAllEvents()
22262226
optionsMenu:SetScript("OnEvent", nil)
22272227

2228-
AutoGearFrame:RegisterEvent("PARTY_INVITE_REQUEST")
2229-
AutoGearFrame:RegisterEvent("START_LOOT_ROLL")
2230-
AutoGearFrame:RegisterEvent("CONFIRM_LOOT_ROLL")
2231-
AutoGearFrame:RegisterEvent("CHAT_MSG_LOOT")
2232-
AutoGearFrame:RegisterEvent("EQUIP_BIND_CONFIRM")
2233-
AutoGearFrame:RegisterEvent("EQUIP_BIND_TRADEABLE_CONFIRM") --Fires when the player tries to equip a soulbound item that can still be traded to eligible players
2234-
AutoGearFrame:RegisterEvent("MERCHANT_SHOW")
2235-
AutoGearFrame:RegisterEvent("PLAYER_EQUIPMENT_CHANGED") --Fires when equipment is equipped or unequipped from the player, excluding bags
2236-
AutoGearFrame:RegisterEvent("BAG_CONTAINER_UPDATE") --Fires when bags are equipped or unequipped from the player
2237-
AutoGearFrame:RegisterEvent("QUEST_ACCEPTED") --Fires when a new quest is added to the player's quest log (which is what happens after a player accepts a quest).
2238-
AutoGearFrame:RegisterEvent("QUEST_ACCEPT_CONFIRM") --Fires when certain kinds of quests (e.g. NPC escort quests) are started by another member of the player's group
2239-
AutoGearFrame:RegisterEvent("QUEST_AUTOCOMPLETE") --Fires when a quest is automatically completed (remote handin available)
2240-
AutoGearFrame:RegisterEvent("QUEST_COMPLETE") --Fires when the player is looking at the "Complete" page for a quest, at a questgiver.
2241-
AutoGearFrame:RegisterEvent("QUEST_DETAIL") --Fires when details of an available quest are presented by a questgiver
2242-
AutoGearFrame:RegisterEvent("QUEST_FINISHED") --Fires when the player ends interaction with a questgiver or ends a stage of the questgiver dialog
2243-
AutoGearFrame:RegisterEvent("QUEST_GREETING") --Fires when a questgiver presents a greeting along with a list of active or available quests
2244-
AutoGearFrame:RegisterEvent("QUEST_ITEM_UPDATE") --Fires when information about items in a questgiver dialog is updated
2245-
AutoGearFrame:RegisterEvent("QUEST_LOG_UPDATE") --Fires when the game client receives updates relating to the player's quest log (this event is not just related to the quests inside it)
2246-
AutoGearFrame:RegisterEvent("QUEST_PROGRESS") --Fires when interacting with a questgiver about an active quest
2247-
--AutoGearFrame:RegisterEvent("QUEST_QUERY_COMPLETE") --Fires when quest completion information is available from the server; deprecated and registering returns an error as of 8.x
2248-
AutoGearFrame:RegisterEvent("QUEST_WATCH_UPDATE") --Fires when the player's status regarding a quest's objectives changes, for instance picking up a required object or killing a mob for that quest. All forms of (quest objective) progress changes will trigger this event.
2249-
AutoGearFrame:RegisterEvent("GOSSIP_CLOSED") --Fires when an NPC gossip interaction ends
2250-
AutoGearFrame:RegisterEvent("GOSSIP_CONFIRM") --Fires when the player is requested to confirm a gossip choice
2251-
AutoGearFrame:RegisterEvent("GOSSIP_CONFIRM_CANCEL") --Fires when an attempt to confirm a gossip choice is canceled
2252-
AutoGearFrame:RegisterEvent("GOSSIP_ENTER_CODE") --Fires when the player attempts a gossip choice which requires entering a code
2253-
AutoGearFrame:RegisterEvent("GOSSIP_SHOW") --Fires when an NPC gossip interaction begins
2254-
AutoGearFrame:RegisterEvent("UNIT_QUEST_LOG_CHANGED") --Fires when a unit's quests change (accepted/objective progress/abandoned/completed)
2255-
2256-
if TOC_VERSION_CURRENT >= TOC_VERSION_MOP then
2257-
AutoGearFrame:RegisterEvent("PLAYER_SPECIALIZATION_CHANGED")
2258-
AutoGearFrame:RegisterEvent("CONFIRM_DISENCHANT_ROLL")
2259-
end
2260-
2261-
if TOC_VERSION_CURRENT >= TOC_VERSION_CATA then
2262-
-- "CONFIRM_DISENCHANT_ROLL" will be added to WoW Classic in a later phase of Cataclysm Classic. Source: https://youtube.com/watch?v=f8zWAPDUTkc&t=2498s
2263-
-- AutoGearFrame:RegisterEvent("CONFIRM_DISENCHANT_ROLL")
2264-
AutoGearFrame:RegisterEvent("QUEST_POI_UPDATE")
2265-
end
2228+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"PARTY_INVITE_REQUEST")
2229+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"START_LOOT_ROLL")
2230+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"CONFIRM_LOOT_ROLL")
2231+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"CHAT_MSG_LOOT")
2232+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"EQUIP_BIND_CONFIRM")
2233+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"EQUIP_BIND_TRADEABLE_CONFIRM") --Fires when the player tries to equip a soulbound item that can still be traded to eligible players
2234+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"MERCHANT_SHOW")
2235+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"PLAYER_EQUIPMENT_CHANGED") --Fires when equipment is equipped or unequipped from the player, excluding bags
2236+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"BAG_CONTAINER_UPDATE") --Fires when bags are equipped or unequipped from the player
2237+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_ACCEPTED") --Fires when a new quest is added to the player's quest log (which is what happens after a player accepts a quest).
2238+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_ACCEPT_CONFIRM") --Fires when certain kinds of quests (e.g. NPC escort quests) are started by another member of the player's group
2239+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_AUTOCOMPLETE") --Fires when a quest is automatically completed (remote handin available)
2240+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_COMPLETE") --Fires when the player is looking at the "Complete" page for a quest, at a questgiver.
2241+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_DETAIL") --Fires when details of an available quest are presented by a questgiver
2242+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_FINISHED") --Fires when the player ends interaction with a questgiver or ends a stage of the questgiver dialog
2243+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_GREETING") --Fires when a questgiver presents a greeting along with a list of active or available quests
2244+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_ITEM_UPDATE") --Fires when information about items in a questgiver dialog is updated
2245+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_LOG_UPDATE") --Fires when the game client receives updates relating to the player's quest log (this event is not just related to the quests inside it)
2246+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_PROGRESS") --Fires when interacting with a questgiver about an active quest
2247+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_QUERY_COMPLETE") --Fires when quest completion information is available from the server; deprecated and registering returns an error as of 8.x
2248+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_WATCH_UPDATE") --Fires when the player's status regarding a quest's objectives changes, for instance picking up a required object or killing a mob for that quest. All forms of (quest objective) progress changes will trigger this event.
2249+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"GOSSIP_CLOSED") --Fires when an NPC gossip interaction ends
2250+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"GOSSIP_CONFIRM") --Fires when the player is requested to confirm a gossip choice
2251+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"GOSSIP_CONFIRM_CANCEL") --Fires when an attempt to confirm a gossip choice is canceled
2252+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"GOSSIP_ENTER_CODE") --Fires when the player attempts a gossip choice which requires entering a code
2253+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"GOSSIP_SHOW") --Fires when an NPC gossip interaction begins
2254+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"UNIT_QUEST_LOG_CHANGED") --Fires when a unit's quests change (accepted/objective progress/abandoned/completed)
2255+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"PLAYER_SPECIALIZATION_CHANGED")
2256+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"CONFIRM_DISENCHANT_ROLL")
2257+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"QUEST_POI_UPDATE")
22662258

22672259
AutoGearFrame:SetScript("OnUpdate", AutoGearMain)
22682260
end
@@ -2488,10 +2480,10 @@ AutoGearFrame:SetScript("OnEvent", function (this, event, arg1, arg2, arg3, arg4
24882480
if (event == "PARTY_INVITE_REQUEST") then
24892481
AutoGearPrint("AutoGear: Automatically accepting party invite.", 1)
24902482
AcceptGroup()
2491-
AutoGearFrame:RegisterEvent("GROUP_ROSTER_UPDATE")
2483+
pcall(AutoGearFrame.RegisterEvent,AutoGearFrame,"GROUP_ROSTER_UPDATE")
24922484
elseif (event == "GROUP_ROSTER_UPDATE") then --for closing the invite window once I have joined the group
24932485
StaticPopup_Hide("PARTY_INVITE")
2494-
AutoGearFrame:UnregisterEvent("GROUP_ROSTER_UPDATE")
2486+
pcall(AutoGearFrame.UnregisterEvent,AutoGearFrame,"GROUP_ROSTER_UPDATE")
24952487
end
24962488
end
24972489

0 commit comments

Comments
 (0)