PaladinWhite
Member
The function in question: int buy(int qty , item it , int price)
The problem: Currently the function treats price < 1 as infinite. (I think. Maybe it just treats it as a very large number?)
That is to say that buy(500 , item , -1) will always buy 500 of the item. buy(500 , item , 0) will do the same thing.
I discovered this when I attempted to use this function to maintain a relatively stock of an item, by calling buy(500 , item , my_max_price - item_amount(item)). What I was shooting for is "The more of this item I possess, the less I'm willing to pay. The less I possess, the more I'm willing to pay." What I actually got is buying 500 of the item every time.
As a stopgap, I'm using buy(500 , item , max(my_max_price - item_amount(item), 1))
The fix: int buy(int qty , item it , int price) should never buy if price < 1.
The problem: Currently the function treats price < 1 as infinite. (I think. Maybe it just treats it as a very large number?)
That is to say that buy(500 , item , -1) will always buy 500 of the item. buy(500 , item , 0) will do the same thing.
I discovered this when I attempted to use this function to maintain a relatively stock of an item, by calling buy(500 , item , my_max_price - item_amount(item)). What I was shooting for is "The more of this item I possess, the less I'm willing to pay. The less I possess, the more I'm willing to pay." What I actually got is buying 500 of the item every time.
As a stopgap, I'm using buy(500 , item , max(my_max_price - item_amount(item), 1))
The fix: int buy(int qty , item it , int price) should never buy if price < 1.