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

Where bugs go to lie down and rest

Moderator: Moderator

Post Reply
Message
Author
Zizzo
Sher'Tul Godslayer
Posts: 2525
Joined: Thu Jan 23, 2003 8:13 pm
Location: A shallow water area south of Bree
Contact:

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

#1 Post 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.
"Blessed are the yeeks, for they shall inherit Arda..."

darkgod
Master of Eyal
Posts: 10751
Joined: Wed Jul 24, 2002 9:26 pm
Location: Angolwen
Contact:

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

#2 Post by darkgod »

woops
[tome] joylove: You can't just release an expansion like one would release a Kraken XD
--
[tome] phantomfrettchen: your ability not to tease anyone is simply stunning ;)

Post Reply