LibItemCache-2.0

LibItemCache-2.0

936 Downloads

Lib:GetPlayerAddress issue

dethanyel opened this issue ยท 0 comments

commented

In the function Lib:GetPlayerAddress(address), the capture pattern used to retrieve the realm name from the address string, (%S+), does not seem to return the full realm name if the realm contains a whitespace.

This will cause issues for players on Connected Realms featuring realms that have whitespaces in their names (e.g., Kirin Tor and Steamwheedle Cartel). For example, when logged into a character on Kirin Tor, mousing over the money frame in Bagnon will generate a lua error if there is cached data for characters on Steamwheedle Cartel. The calls made to Lib:GetPlayerAddress return just "Steamwheedle", resulting in a lua error when BrotherBags[realm][player].money is referenced later on.

A simple fix is to use (.+) for the realm capture instead of (%S+):
local player, realm = strmatch(address or '', '(%S+) %- (.+)')

Also, below is the original error I got when mousing over the money frame:

Message: ...s\Bagnon\libs\LibItemCache-1.1\Caches\BagBrother.lua:112: attempt to index field '?' (a nil value)
Time: 07/22/16 13:56:12
Count: 1
Stack: [C]: ?
...s\Bagnon\libs\LibItemCache-1.1\Caches\BagBrother.lua:112: in function <...s\Bagnon\libs\LibItemCache-1.1\Caches\BagBrother.lua:111>
(tail call): ?
...terface\AddOns\Bagnon\libs\LibItemCache-1.1\Core.lua:57: in function `GetPlayerMoney'
Interface\AddOns\Bagnon\components\moneyFrame.lua:63: in function `OnEnter'
Interface\AddOns\Bagnon\components\moneyFrame.lua:23: in function <Interface\AddOns\Bagnon\components\moneyFrame.lua:23>

Locals: