@@ -40,7 +40,7 @@ License: MIT
40
40
-- @class file
41
41
-- @name LibRangeCheck-3.0
42
42
local MAJOR_VERSION = " LibRangeCheck-3.0"
43
- local MINOR_VERSION = 9
43
+ local MINOR_VERSION = 12
44
44
45
45
-- GLOBALS: LibStub, CreateFrame
46
46
52
52
53
53
local isRetail = WOW_PROJECT_ID == WOW_PROJECT_MAINLINE
54
54
local isWrath = WOW_PROJECT_ID == WOW_PROJECT_WRATH_CLASSIC
55
+ local isEra = WOW_PROJECT_ID == WOW_PROJECT_CLASSIC
55
56
56
57
local next = next
57
58
local type = type
@@ -86,11 +87,12 @@ local GetTime = GetTime
86
87
local HandSlotId = GetInventorySlotInfo (" HANDSSLOT" )
87
88
local math_floor = math.floor
88
89
local UnitIsVisible = UnitIsVisible
90
+ local Item = Item
89
91
90
92
local C_Timer_NewTicker = C_Timer .NewTicker
91
93
92
94
local InCombatLockdownRestriction
93
- if isRetail then
95
+ if isRetail or isEra then
94
96
InCombatLockdownRestriction = function (unit ) return InCombatLockdown () and not UnitCanAttack (" player" , unit ) end
95
97
else
96
98
InCombatLockdownRestriction = function () return false end
527
529
528
530
-- temporary stuff
529
531
530
- local pendingItemRequest
531
- local itemRequestTimeoutAt
532
+ local pendingItemRequest = {}
533
+ local itemRequestTimeoutAt = {}
532
534
local foundNewItems
533
535
local cacheAllItems
534
536
local friendItemRequests
@@ -678,7 +680,7 @@ local function createCheckerList(spellList, itemList, interactList)
678
680
for range , items in pairs (itemList ) do
679
681
for i = 1 , # items do
680
682
local item = items [i ]
681
- if GetItemInfo (item ) then
683
+ if Item : CreateFromItemID ( item ): IsItemDataCached () and GetItemInfo (item ) then
682
684
addChecker (res , range , nil , checkers_Item [item ], " item:" .. item )
683
685
break
684
686
end
@@ -1233,8 +1235,9 @@ end
1233
1235
1234
1236
function lib :GET_ITEM_INFO_RECEIVED (event , item , success )
1235
1237
-- print("### GET_ITEM_INFO_RECEIVED: " .. tostring(item) .. ", " .. tostring(success))
1236
- if item == pendingItemRequest then
1237
- pendingItemRequest = nil
1238
+ if pendingItemRequest [item ] then
1239
+ pendingItemRequest [item ] = nil
1240
+ itemRequestTimeoutAt [item ] = nil
1238
1241
if not success then
1239
1242
self .failedItemRequests [item ] = true
1240
1243
end
@@ -1253,40 +1256,37 @@ function lib:processItemRequests(itemRequests)
1253
1256
if not i then
1254
1257
itemRequests [range ] = nil
1255
1258
break
1256
- elseif self .failedItemRequests [item ] then
1259
+ elseif Item : CreateFromItemID ( item ): IsItemEmpty () or self .failedItemRequests [item ] then
1257
1260
-- print("### processItemRequests: failed: " .. tostring(item))
1258
1261
tremove (items , i )
1259
- elseif item == pendingItemRequest and GetTime () < itemRequestTimeoutAt then
1262
+ elseif pendingItemRequest [ item ] and GetTime () < itemRequestTimeoutAt [ item ] then
1260
1263
return true -- still waiting for server response
1261
1264
elseif GetItemInfo (item ) then
1262
1265
-- print("### processItemRequests: found: " .. tostring(item))
1263
- if itemRequestTimeoutAt then
1264
- -- print("### processItemRequests: new: " .. tostring(item))
1265
- foundNewItems = true
1266
- itemRequestTimeoutAt = nil
1267
- pendingItemRequest = nil
1268
- end
1266
+ foundNewItems = true
1267
+ itemRequestTimeoutAt [item ] = nil
1268
+ pendingItemRequest [item ] = nil
1269
1269
if not cacheAllItems then
1270
1270
itemRequests [range ] = nil
1271
1271
break
1272
1272
end
1273
1273
tremove (items , i )
1274
- elseif not itemRequestTimeoutAt then
1274
+ elseif not itemRequestTimeoutAt [ item ] then
1275
1275
-- print("### processItemRequests: waiting: " .. tostring(item))
1276
- itemRequestTimeoutAt = GetTime () + ItemRequestTimeout
1277
- pendingItemRequest = item
1276
+ itemRequestTimeoutAt [ item ] = GetTime () + ItemRequestTimeout
1277
+ pendingItemRequest [ item ] = true
1278
1278
if not self .frame :IsEventRegistered (" GET_ITEM_INFO_RECEIVED" ) then
1279
1279
self .frame :RegisterEvent (" GET_ITEM_INFO_RECEIVED" )
1280
1280
end
1281
1281
return true
1282
- elseif GetTime () >= itemRequestTimeoutAt then
1282
+ elseif GetTime () >= itemRequestTimeoutAt [ item ] then
1283
1283
-- print("### processItemRequests: timeout: " .. tostring(item))
1284
1284
if cacheAllItems then
1285
1285
print (MAJOR_VERSION .. " : timeout for item: " .. tostring (item ))
1286
1286
end
1287
1287
self .failedItemRequests [item ] = true
1288
- itemRequestTimeoutAt = nil
1289
- pendingItemRequest = nil
1288
+ itemRequestTimeoutAt [ item ] = nil
1289
+ pendingItemRequest [ item ] = nil
1290
1290
tremove (items , i )
1291
1291
else
1292
1292
return true -- still waiting for server response
0 commit comments