WIP Refactor repeated map.ter .furn .*_at calls #77109
Draft
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.
Summary
None
Purpose of change
A lot of places in the code call the same lookup functions for map data repeatedly. This makes some of those sections hard to read if the parameters are not short. It also results in lack of optimization in some cases
Describe the solution
Repeated calls to the map methods in question are replaced with one call and mostly const mostly references. A lot of existing calls that get copied to local vars are are converted to const references.
A dozen mapgen functions with identical
has_vehicle_collision
have been refactors to inherit from a new class that provides that method.Describe alternatives you've considered
Caching more results in the map classes is an option but would be much more complex.
Testing
Automated tests pass. I played for a while with the changes, and continue to do so. This will be draft until I'm more confident I've reviewed and tested as much as I can.
Additional context
I skipped a few places where the repeated calls appear in the middle of a series of conditions so it would be more complex to break them out without changing the order of execution.