zarqon
Well-known member
Currently, mafia hits the KoL server every time shop_amount() is called. This is because the amount in your shop can change at any time, which makes sense.
However, since that number can only decrease, it makes sense for mafia to cache the existence of items in your shop. For someone who only has Knob goblin pants in their store, shop_amount(every other item) will always be 0, no matter how many of those pants someone buys.
Anytime mafia hits the shop, items in the shop would be flagged. Non-flagged items may return 0 without hitting the server. Mafia would need to update the flags when adding/removing items to/from the shop.
For scripts that mess with items, the work needed to save these server hits in the script is not something your average scripter would feel up to doing -- in a foreach of get_inventory() for example, they may check shop_amount(). I'd guess that quite a few server hits could be saved were this change implemented.
However, since that number can only decrease, it makes sense for mafia to cache the existence of items in your shop. For someone who only has Knob goblin pants in their store, shop_amount(every other item) will always be 0, no matter how many of those pants someone buys.
Anytime mafia hits the shop, items in the shop would be flagged. Non-flagged items may return 0 without hitting the server. Mafia would need to update the flags when adding/removing items to/from the shop.
For scripts that mess with items, the work needed to save these server hits in the script is not something your average scripter would feel up to doing -- in a foreach of get_inventory() for example, they may check shop_amount(). I'd guess that quite a few server hits could be saved were this change implemented.