Page 1 of 1

[1.4.1] Buying one item out of a store stack is free

Posted: Wed Jan 27, 2016 2:41 am
by Zizzo
Looks like this bug got missed in the 1.4.0 beta process. I'll repeat it here for convenience: go to the Derth gem store, pick any gem that has three or more in stock, and buy one of them. The gem will be transferred to your inventory, but your money won't be decreased and you won't get the log message e.g. "Bought: zircon for 42.69 gold."

The bug appears to be in mod.class.Store:doBuy(), line 167:

Code: Select all

o, item = who:findInInventory(who:getInven("INVEN"), o:getName())
o is the store object after the transfer has been done, so o:getName() will return e.g. "2 zircon". The problem is that ActorInventory:findInInventory() passes {no_count=true} to Object:getName() internally, so the gem in inventory will be seen as just "zircon" and won't match, short-circuiting all the rest of :doBuy()'s handling.

Interestingly, selling appears to work fine. The corresponding line in doSell() [line 191] is:

Code: Select all

local o, item = self:findInInventory(self:getInven("INVEN"), o:getName()) or o
That "or o" at the end appears to be what saves us. What this means, of course, is that the player can "buy" one gem for free, sell it back for a profit, and repeat as desired for effectively infinite gold.

Re: [1.4.1] Buying one item out of a store stack is free

Posted: Wed Jan 27, 2016 10:29 am
by darkgod
woops