Fix: Vehicle list windows did not update when this year's profit changed #8715
Motivation / Problem
#8575 (update commit message when merging)
Remove caching from vehicle group object and recalculate it whenever required instead.
Was an awful lot less effort than finding all the places where vehicle profit changes and updating the relevant group object.
Might slow things down for group-heavy games. Needs further testing with a game with such properties. Perhaps @btzy would like to test?
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.
Thanks for this fix! I should be able to try it out maybe tomorrow. However, it appears that we're doing O(n log n) recalculations (because the comparator for std::sort is called that many times) when we could have done it in O(n) (by saving the calculations on each vehicle group into an auxilliary array just before doing the sort), I wonder if it is worth doing that instead?
I tried some saves with around 200-500 buses and 20-70 groups, and it doesn't appear to be any slower than normal. Unfortunately, I don't have a save with 65535 vehicles to push it to the limit... but I would be fairly surprised if it was any slower because the time complexity works out to be the same as not grouping the vehicles at all.