Skip to content

Commit

Permalink
More 3.4.1 fixes to restore trading functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
Anonomit committed Jan 19, 2023
1 parent f2070f9 commit 68098c6
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 11 deletions.
6 changes: 5 additions & 1 deletion ItemConditions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -268,9 +268,13 @@ local usableCacheHooked = nil;
local function IsItemUsableByMe(itemID)
if not usableCacheHooked then
usableCacheHooked = true;
LootReserve:RegisterEvent("QUEST_ACCEPTED", "QUEST_TURNED_IN", "BAG_UPDATE_DELAYED", "CHAT_MSG_SKILL", function()
LootReserve:RegisterEvent("QUEST_ACCEPTED", "QUEST_TURNED_IN", "CHAT_MSG_SKILL", function()
usableCache = { };
end);
LootReserve:RegisterEvent("BAG_UPDATE", function() -- Return to hooking BAG_UPDATED_DELAYED when blizzard fixes it
usableCache = { };
C_Timer.After(0, function() usableCache = { }; end);
end);
end
if not usableCache[itemID] then
local usable, unloaded = IsItemUsable(itemID, select(2, LootReserve:UnitClass(LootReserve:Me())), true);
Expand Down
7 changes: 4 additions & 3 deletions LootReserve.lua
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ function LootReserve:OnEnable()
-- Load client and server after WoW client restart
-- Server session should not normally exist when the player is outside of any raid groups, so restarting it upon regular group join shouldn't break anything
-- With a delay, due to possible name cache issues
C_Timer.After(1, Startup);
C_Timer.After(1, function() Startup(); end); -- Wrap in anonymous function just in case of blizzard bug
end);

-- Load client and server after UI reload
Expand Down Expand Up @@ -680,8 +680,9 @@ local bagCacheHooked = nil;
local function CheckBagCache(self)
if not bagCacheHooked then
bagCacheHooked = true;
self:RegisterEvent("BAG_UPDATE_DELAYED", function()
LootReserve:RegisterEvent("BAG_UPDATE", function() -- Return to hooking BAG_UPDATED_DELAYED when blizzard fixes it
LootReserve:WipeBagCache();
C_Timer.After(0, function() LootReserve:WipeBagCache(); end);
end);
self:RegisterEvent("ITEM_LOCK_CHANGED", function(bag, slot)
if not slot then return; end
Expand Down Expand Up @@ -813,7 +814,7 @@ end
function LootReserve:PutItemInTrade(bag, slot)
for i = 1, 6 do
if not GetTradePlayerItemInfo(i) then
PickupContainerItem(bag, slot);
C_Container.PickupContainerItem(bag, slot);
ClickTradeButton(i);
return true;
end
Expand Down
4 changes: 2 additions & 2 deletions Server.lua
Original file line number Diff line number Diff line change
Expand Up @@ -3466,7 +3466,7 @@ function LootReserve.Server:RequestRoll(item, duration, phases, allowedPlayers)

local _, myReserves = LootReserve:GetReservesData(players, player);
if roll == LootReserve.Constants.RollType.NotRolled and LootReserve:IsPlayerOnline(player) and not sentToPlayer[player] then
self.ExtraRollRequestNag[player] = C_Timer.NewTimer(self:IsAddonUser(player) and 5 or 7, WhisperPlayer);
self.ExtraRollRequestNag[player] = C_Timer.NewTimer(self:IsAddonUser(player) and 5 or 7, function() WhisperPlayer(); end); -- Wrap in anonymous function just in case of blizzard bug
sentToPlayer[player] = true;
end
end
Expand Down Expand Up @@ -3549,7 +3549,7 @@ function LootReserve.Server:RequestCustomRoll(item, duration, phases, allowedPla

local _, myReserves = LootReserve:GetReservesData(players, player);
if roll == LootReserve.Constants.RollType.NotRolled and LootReserve:IsPlayerOnline(player) and not sentToPlayer[player] then
self.ExtraRollRequestNag[player] = C_Timer.NewTimer(self:IsAddonUser(player) and 5 or 7, WhisperPlayer);
self.ExtraRollRequestNag[player] = C_Timer.NewTimer(self:IsAddonUser(player) and 5 or 7, function() WhisperPlayer(); end); -- Wrap in anonymous function just in case of blizzard bug
sentToPlayer[player] = true;
end
end
Expand Down
12 changes: 11 additions & 1 deletion Windows/ServerWindow.lua
Original file line number Diff line number Diff line change
Expand Up @@ -908,10 +908,20 @@ function LootReserve.Server:OnWindowLoad(window)
self:UpdateReserveList();
self:UpdateRollList();
end);
LootReserve:RegisterEvent("TRADE_SHOW", "TRADE_CLOSED", "TRADE_PLAYER_ITEM_CHANGED", "TRADE_ACCEPT_UPDATE", "BAG_UPDATE_DELAYED", "PLAYER_TARGET_CHANGED", "GROUP_JOINED", "GROUP_LEFT", "GROUP_ROSTER_UPDATE", function()
LootReserve:RegisterEvent("TRADE_SHOW", "TRADE_CLOSED", "TRADE_PLAYER_ITEM_CHANGED", "TRADE_ACCEPT_UPDATE", "PLAYER_TARGET_CHANGED", "GROUP_JOINED", "GROUP_LEFT", "GROUP_ROSTER_UPDATE", function()
LootReserve:WipeBagCache();
LootReserve.Server:UpdateRollList();
end);
local tempBagFix;
LootReserve:RegisterEvent("BAG_UPDATE", function() -- Return to hooking BAG_UPDATED_DELAYED when blizzard fixes it
if not tempBagFix then
tempBagFix = C_Timer.NewTicker(0, function()
LootReserve:WipeBagCache();
LootReserve.Server:UpdateRollList();
tempBagFix = nil;
end, 1);
end
end);
end

local activeSessionChanges =
Expand Down
8 changes: 4 additions & 4 deletions Windows/ServerWindow.xml
Original file line number Diff line number Diff line change
Expand Up @@ -793,7 +793,7 @@
if self.Lootable then
LootReserve.Server:MasterLootItem(item, LootReserve:Player(UnitName(unit)));
elseif self.Tradeable then
local bag, slot = LootReserve:GetBagSlot(item);
local bag, slot = LootReserve:GetBagSlot(item, true);
if bag and slot then
if TradeFrame:IsShown() then
if UnitIsUnit(unit, "npc") then
Expand All @@ -804,9 +804,9 @@
end
end
elseif CheckInteractDistance(unit, 2) then
PickupContainerItem(bag, slot);
C_Container.PickupContainerItem(bag, slot);
DropItemOnUnit(unit);
C_Timer.After(1, ClearCursor);
C_Timer.After(1, function() ClearCursor(); end);
elseif LootReserve:CanUseDBMLocator(unit) then
self:DMBLocate(unit);
end
Expand Down Expand Up @@ -1107,7 +1107,7 @@
end
local bag, slot = LootReserve:GetBagSlot(item);
if bag and slot then
PickupContainerItem(bag, slot);
C_Container.PickupContainerItem(bag, slot);
ClickTradeButton(i);
i = i + 1;
end
Expand Down

0 comments on commit 68098c6

Please sign in to comment.