Change: Reduce real sprite groups if possible. #9344
Motivation / Problem
Many NewGRF features using Act 3/2/1 chains don't require loading/loaded stages (which are determined by the
For features that do use loading/loaded stages, it is also fairly common for the same sprite or callback result to be returned.
This change skips creating a RealSpriteGroup if there is only one result, or if all results are the same.
The deduplication does not take account of the order of checking loading/loaded results which was previously inconsistent, therefore it's possible that if loading/loaded stages were supplied for a feature that does not expect it, a different result will now be used. But if this is the case then I think NewGRF is out-of-spec anyway.
Checklist for review
Some things are not automated, and forgotten often. This list is a reminder for the reviewers.
…al sprite groups. This may change behaviour when multiple loading/loaded stages are provided, as the various copies checked in different orders, however only one result is expected in these cases anyway.
This avoids checking RSG for empty sets every time they are evaluated. This might alter behaviour in cases of a malformed NewGRF file.
In theory this can also affect callback results as a plain action 2 can return callback results (at least our code supports it, whether the spec intends that is another matter)... but:
In fact after checking the NewGRF spec it seems we did it wrong for railtypes and roadtypes (which is fun, because it is our spec) as the code tested loading first then loaded, when the spec says loaded must be 1 and loading must be 0.