-
Notifications
You must be signed in to change notification settings - Fork 4.2k
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
Add tracking of overmap special for placed terrain #27074
Add tracking of overmap special for placed terrain #27074
Conversation
c0b1641
to
b6d3fd3
Compare
After discussion with @ZhilkinSerg I've updated the serialization format of the [
{
"special": "Megastore",
"placements": [
{
"uniqueid": 0,
"points": [
{ "p": [ 172, 10, 0 ] },
{ "p": [ 172, 11, 0 ] },
{ "p": [ 172, 9, 0 ] },
{ "p": [ 173, 10, 0 ] },
{ "p": [ 173, 11, 0 ] },
{ "p": [ 173, 9, 0 ] },
{ "p": [ 174, 10, 0 ] },
{ "p": [ 174, 11, 0 ] },
{ "p": [ 174, 9, 0 ] }
]
},
{
"uniqueid": 1,
"points": [
{ "p": [ 21, 136, 0 ] },
{ "p": [ 21, 137, 0 ] },
{ "p": [ 21, 138, 0 ] },
{ "p": [ 22, 136, 0 ] },
{ "p": [ 22, 137, 0 ] },
{ "p": [ 22, 138, 0 ] },
{ "p": [ 23, 136, 0 ] },
{ "p": [ 23, 137, 0 ] },
{ "p": [ 23, 138, 0 ] }
]
}
]
}
] where each placement is now an object, so that data in common for the placement (e.g. the unique id) isn't repeated for each point in the placement. As noted in my original PR summary
there are no actual additional properties yet (because I don't need them yet), and so there is no unique id being assigned/saved/loaded yet, and thus all points for a given special are in a single object like this: [
{
"special": "Megastore",
"placements": [
{
"points": [
{ "p": [ 172, 10, 0 ] },
{ "p": [ 172, 11, 0 ] },
{ "p": [ 172, 9, 0 ] },
{ "p": [ 173, 10, 0 ] },
{ "p": [ 173, 11, 0 ] },
{ "p": [ 173, 9, 0 ] },
{ "p": [ 174, 10, 0 ] },
{ "p": [ 174, 11, 0 ] },
{ "p": [ 174, 9, 0 ] },
{ "p": [ 21, 136, 0 ] },
{ "p": [ 21, 137, 0 ] },
{ "p": [ 21, 138, 0 ] },
{ "p": [ 22, 136, 0 ] },
{ "p": [ 22, 137, 0 ] },
{ "p": [ 22, 138, 0 ] },
{ "p": [ 23, 136, 0 ] },
{ "p": [ 23, 137, 0 ] },
{ "p": [ 23, 138, 0 ] }
]
}
]
}
] but we can make those future enhancements without breaking this structure. |
src/overmap.cpp
Outdated
@@ -2988,6 +2988,21 @@ bool overmap::check_ot_subtype( const std::string &otype, int x, int y, int z ) | |||
return is_ot_subtype( otype.c_str(), oter ); | |||
} | |||
|
|||
bool overmap::check_overmap_special_type( const overmap_special_id &id, int x, int y, int z ) const |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
As this is a new function, please take the location as tripoint
there should be no separate x,y,z values,it's one piece of data. You're not forwarding the string id as const char *
and size_t
either, but as a single object.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Sure, no problem. I actually wrote it with a tripoint first, and then backed off to keep the API homogeneous with the other two
bool check_ot_type( const std::string &otype, int x, int y, int z ) const;
bool check_ot_subtype( const std::string &otype, int x, int y, int z ) const;
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
When updating the not-yet-PR'd changes that depend on this, I remembered the other reason I kept the API homogeneous--the overmapbuffer versions of those two functions call the corresponding versions of get_om_global that take the coordinates by reference and adjust them to be overmap local, and return the overmap, while the tripoint version of get_om_global doesn't currently return adjusted coordinates.
It's the sort of thing that it would actually probably be better (or at least less surprising) for the get_om_global functions to return a new type that has both the overmap and the adjusted coordinates, rather than changing coordinates passed by reference for the xyz version and not for the tripoint.
b6d3fd3
to
4945075
Compare
Summary
SUMMARY: Infrastructure "Add tracking of overmap special for placed terrain"
Purpose of change
This is the first in a series of changes being split off from this branch, which provides the support for checking for the existence of overmap specials (and placement of them if necessary) after overmap generation--initially used in updating missions to be "overmap special aware / capable".
This change adds the support for capturing, persisting, and later determining a given overmap location's associated overmap special.
Describe the solution
Add a new overmap member which records the overmap special id associated with a location, update the special placement to use it, add serialization and deserialization of the mapping and add a new function for checking if a given overmap location is a given overmap special.
Additional context
I'm storing this in the overmap as a
std::unordered_map<tripoint, overmap_special_id>
because the way this gets used is in conjunction with other checks that evaluate a given tripoint for other criteria, and a given tripoint can have at most one special that placed the current overmap terrain.For serialization, however, I'm storing it like this:
updated: after discussion I've revised the format for the diff'd section as described in this comment
The rationale here is:
As for how this gets used, the subsequent changes can be tracked in this branch,