Feature put_shop idiotproofing

xKiv

Active member
In light of my recent escapade which cost me over 50M meat, I would like to suggest the following safeguard for (all (two) variants of) put_shop:

If price is below minimum (i.e. below 100 or 2*autosell, whichever is higher), and it isn't 0 (which converts to the unsellable 999999999), abort with an error (or at the very least don't sell at minprice; selling at 999999999 might be fine), since it probably indicates that the code in question is passing parameters in the wrong order (like calling put_shop(quantity, price, item) instead of put_shop(price, 0, quantity, item), ehm [1]).


[1] more concrete example: I called put_shop(1, 0, item) thinking that it would sell 1 at price "0" (and convert to 999999999). But for mafia, this meant "at price 1" (convert to min-price) with limit 1/day.
 

slyz

Developer
I guess we should extend the "price is less than 15% of the cheapest in the mall" check in StoreManagePanel to ASH and CLI functions.
 

xKiv

Active member
How? New api would require knowing parameters of more versions of the function, and confirmation popups are not ideologically clean.

Also, I explicitly wrote about *invalid* prices. Like 1-99 meat for any cheap stuff (100 is already valid for many things).
 

Rinn

Developer
An invalid price should be any value less than max(half of autosell, 100). I wouldn't be against the 15% check either for expensive items either.
 

Theraze

Active member
Aren't there no-autosell items that have a higher min-mall price than 100? Or do we have code that would actually handle those exceptions? If not, might be easier to just make 1-99 for price be considered abort-worthy, since they'll never work regardless of the item.
 

slyz

Developer
An invalid price should be any value less than max(half of autosell, 100). I wouldn't be against the 15% check either for expensive items either.
We already have a behavior that I think is correct for those - we place them in the mall at min mall price.

The problem is when the user causes this to happen for expensive items.
 

lostcalpolydude

Developer
Staff member
We already have a behavior that I think is correct for those - we place them in the mall at min mall price.

The problem is when the user causes this to happen for expensive items.

I think xKiv is asking for this to be changed even for cheaper items. I'm guessing he underpriced plenty of items around 1k or 10k, far too cheap to be caught by the check that currently applies to the GUI.
 

xKiv

Active member
An invalid price should be any value less than max(half of autosell, 100). I wouldn't be against the 15% check either for expensive items either.

I think you mean *twice* autosell. For example, for NPC sold items, a utosell is typically half of npc-price, and mall minimum is equal to that npc-price (or 100). Iirc.

I think xKiv is asking for this to be changed even for cheaper items.

Yes. If I want to sell for min-mall-price, I will try to use that explicitly.
When I don't remember which parameter of (int,int) is quantity (not expecting that limit is more important than quantity), and put in in the first parameter (because that's where it usually is, right? Many of the other item-manipulating functions have quanitity in first parameter ...), and put 0 in the second (assuming that the remaining int is price, and that 0 will either fail or transform to 999999999) well ...
that's when I am really telling mafia to sell 1 item at mall minimum without limit.
I am not opposed to magical values - say, 0 for "mall default: 999999999, -1 for "mall minprice".
Numbers that are otherwise invalid as price, but can actually be intended as quantity - that's what I want to be protected from.

(it might also be nice if ashref returned parameter names, not just types - but I see that would require huge edit in RuntimeLibrary, unless it could be done with some reflection)

I'm guessing he underpriced plenty of items around 1k or 10k, far too cheap to be caught by the check that currently applies to the GUI.
Nope. I actually had closet to 100% of those in my DC (or inventory/closet), and put them back at the end. I only resold items I bought ... which managed to include several high-profile things.
 
Top