Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor overmapbuffer::get_om_global #32594

Merged
merged 2 commits into from
Jul 26, 2019

Conversation

jbytheway
Copy link
Contributor

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 to overmap_with_local_coords, and with shorter member names for easier use. I also added bool conversions so it can be tested for validity (thus subsuming the requirement for cata::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 to omt_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.

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.

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 to overmap_with_local_coords, and with shorter member names for
easier use.  I also added bool conversions so it can be tested for
validity (thus subsuming the requirement for cata::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.
@jbytheway
Copy link
Contributor Author

Jenkins rebuild

@ZhilkinSerg ZhilkinSerg added <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` labels Jul 25, 2019
Copy link
Contributor

@AMurkin AMurkin left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

astyle 3.0.1 wants it like this.

@ZhilkinSerg ZhilkinSerg merged commit 0fdcdc3 into CleverRaven:master Jul 26, 2019
@jbytheway jbytheway deleted the get_om_global branch July 26, 2019 14:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
<Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code`
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants