This repository has been archived by the owner on Apr 16, 2021. It is now read-only.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Attempts to fix a bug where traders would not buy herb/cannabis/spawnable as herb/cannabis. This means that round start and loot-crate weed would not be able to be sold as if the items that they are.
I have tested that this bug is still the case in 2019, hopefully this fix still applies. I know that several changes have been made to traders since 2016 code.
The fix implemented here is not ideal, but i do not know enough about trader code to rewrite their New and this is a lot more slot-in-able.
Basically, what this patch does is it builds an ordered list out of goods_buy called goods_buy_sorted. The goods_buy_sorted list ensures that when the trader buys an item, they buy the most-childy items first; e.g., it will buy herb/cannabis/omega before herb/cannabis. The reason for this is that the current (N.comtype == sellitem.type) leads to unituitive results, as child items of parent items cannot be sold as the parent item. This becomes a problem when herb/cannabis/omega/spawnable, aka, the kind of omega weed spawned in loot crates, cannot be sold as herb/cannabis/omega. However, replacing this with istype(sellitem,N.comtype) means that if herb/cannabis comes first in the trader's goods_buy, it will sell herb/cannabis/omega as herb/cannabis. Basically, this sort ensures that herb/cannabis/omega gets sold before herb/cannabis. Now, this should probably go into the parent trader's New(), but the parent New() gets called in sub-traders before adding on any of the commodities for trade. This means that I would be doing the sort before the items are even added, and I don't know enough about how traders work to feel comfortable moving the ..() to the end
A direct consequence of this change means that traders who buy herb/cannabis will now also buy herb/cannabis/omega, but do so at their herb/cannabis price. This seems reasonable.
This also means that all child items will be bought as if they were the parent item if an explicit reference to the child item isn't included. This means that a trader that buys kitchen/utensil/fork will also buy kitchen/utensil/fork/plastic as if it were a regular fork. This seems slightly less reasonable, but hopefully the balancing concerns for this will be outweighed by the potential good.