Refactor overmapbuffer::get_om_global #32594
Merged
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
SUMMARY: Bugfixes "Fix overmap reveal code when used on non-zero z-levels"
Purpose of change
Continuing the changes of #32300.
There were previously eight member functions for fetching the
overmap
corresponding to a particular global omt. They had subtly different semantics, and refactoring involving them was bug-prone (as seen e.g. in my changes that introduced the bug fixed in #32346).Describe the solution
Reduce to just four overloads, all with the same return type. That return type is a tweaked version of
overmap_with_local_coordinates
, now renamed toovermap_with_local_coords
, and with shorter member names for easier use. I also addedbool
conversions so it can be tested for validity (thus subsuming the requirement forcata::optional
that led to a lot of verbosity).Refactor all the code using any of these functions to the new interface. Mostly this is a simplification, although it does involve a lot of
om_loc.om
code.Some minor semantic changes which I believe to be bugfixes:
overmapbuffer::reveal
was filtering on terrain at z-level zero rather than the z-level being revealed.overmapbuffer::reveal_route
used to reveal the wrong tiles when used on non-zero z-levels.Describe alternatives you've considered
I'm not a huge fan of the name
overmap_with_local_coords
. I considered changing it toomt_and_overmap
or something like that, but that's also kind of ambiguous.I should probably have added tests for the two functions I'm claiming to have fixed bugs in.
Additional context
Working towards being able to meaningfully test #32017.
As with #32300, this is refactoring with broad impact which is hard to test. Hopefully most of the changes are fairly obvious.