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

Overmapbuffer function refactoring #32300

Merged

Conversation

jbytheway
Copy link
Contributor

Summary

SUMMARY: Infrastructure "Use point/tripoint rather than individual coordinates in overmapbuffer functions"

Purpose of change

Working towards #32017. If we want to use type-safe points, the first step is to use point at all, rather than individual coordinates. This PR does that for the overmapbuffer member functions.

Describe the solution

Change almost all the functions and refactor all the places that call them.

I skipped get_existing_om_global and get_om_global because they require changed return type, which was more complex refactoring and this PR was already too big. I intend to deal with those in a follow-up PR.

Most of the refactoring improves to code clarity, I think.

Along the way I discovered some bugs in map extra coordinate transformations. mx_roadblock, mx_bandits_block, mx_minefield, and mx_roadworks were all using the wrong coordinate system to check adjacent terrain types, so they were probably not behaving as intended. More evidence that #32017 is needed, but I fixed these examples for now.

Describe alternatives you've considered

This is a big chunk of changes in one go. If it's too intimidating to review and I should split it up further, let me know.

Additional context

Takes advantage of the new features I added recently in #32242 and #32269.

I tested this a little bit in-game. I found (and fixed) one bug in my changes to overmap_ui, which is by far the most complex function I refactored. I suspect there are other bugs I'm introducing here; it's such a broad range of game mechanics being affected it's not practical to test thoroughly.

If you are testing this PR before merge, pay special attention to the minimap and overmap UI; those are the most likely places for bugs to have crept in.

A bunch of map / overmap functions take x, y, z coordinates.  Add
overloads to (some of) those taking a point or tripoint.

For now, those overloads just forward to the original function, but the
ultimate goal is to remove the originals and only have the new
overloads.
Remove almost all (x, y, z) APIs and replace wityh point / tripoint
APIs.

This is a first step towards making these APIs type-safe (CleverRaven#32017).

A couple of APIs remain because they're more complex to change and this
commit was already very big.
@ZhilkinSerg ZhilkinSerg added [C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Map / Mapgen Overmap, Mapgen, Map extras, Map display labels Jul 11, 2019
@ZhilkinSerg ZhilkinSerg merged commit 5355c06 into CleverRaven:master Jul 11, 2019
@jbytheway jbytheway deleted the overmapbuffer_function_refactoring branch July 11, 2019 07:51
KorGgenT pushed a commit to b0urgeoisie/Cataclysm-DDA that referenced this pull request Jul 14, 2019
* Typo

* Add some point / tripoint overloads for APIs

A bunch of map / overmap functions take x, y, z coordinates.  Add
overloads to (some of) those taking a point or tripoint.

For now, those overloads just forward to the original function, but the
ultimate goal is to remove the originals and only have the new
overloads.

* Overhaul overmapbuffer APIs

Remove almost all (x, y, z) APIs and replace wityh point / tripoint
APIs.

This is a first step towards making these APIs type-safe (CleverRaven#32017).

A couple of APIs remain because they're more complex to change and this
commit was already very big.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[C++] Changes (can be) made in C++. Previously named `Code` Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants