View Single Post
03/11/15, 03:54 PM   #8
thifi
 
thifi's Avatar
AddOn Author - Click to view addons
Join Date: Apr 2014
Posts: 10
Originally Posted by merlight View Post
I asked because I was curious what was happening in your handler. I peeked into RB2 and have a few suggestions.

You're scanning the whole inventory (and bank, too?) on every slot update, right? I'd say don't, but from what I understood it'd be really hard. You gather some info about items in inventory, and to do a true single slot update, you'd need to remember what was where during the last scan, so that you can remove it from the appropriate tables when it disappears from the slot. Right?

How about building one more table in InventoryContainer:refresh() to remember what you saw, SeenLinks = {[slotIndex] = itemLink}

Then you could add a function InventoryContainer:refreshSlot(slotIndex), in which you'd first compare the new itemLink with oldLink = SeenLinks[slotIndex] -- if they're equal, you're good, return -- otherwise you can get oldKey = ItemLinks[oldLink] and delete oldLink from ResearchKeys[oldKey]. If I undestand it correctly, you can't remove ItemLinks[oldLink] until ResearchKeys[oldKey] is empty. Then add the new itemLink in the same manner it is done now. It will probably be more difficult to make this work than I'm picturing it, but I think it's not unreal.
Yup, correct. I'm not particularly happy with the way it currently works. An item instance ID based solution would much more optimal but i was young i needed the money.

Originally Posted by merlight View Post
By the way, inventory slots are indexed from 0 to bagSize-1, you're 1 off
Darn, it was that way in the old one but forgot about it during the rewrite.

Thanks for the feedback.

Regards,
  Reply With Quote