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

Better in city check #74191

Merged
merged 12 commits into from
Oct 24, 2024
Merged

Conversation

Procyonae
Copy link
Contributor

@Procyonae Procyonae commented May 30, 2024

Summary

None

Purpose of change

Fixes #74177
Might be used for #71822 and the first commit is code from it mainly courtesy of anothersimulacrum

Describe the solution

Current checks for whether stuff is in a city or not use the difference between the test points distance from the nearest city's centre and the nearest city's size. Given that our cities are thankfully more organic than perfect circles that isn't particularly accurate.
Now every city road and building that gets placed is added to a set of point_om_omts per overmap that can be checked against to determine if you're in a city. Once all cities are placed in an overmap the result is floodfilled so random fields in the middle of cities still count as being in the city limits.
Currently only affects EOCs map_in_city and overmap_specials city_distance
Falls back on calculating distance based on city size but cuts off at 0 as < 0 isn't a useful result

Describe alternatives you've considered

Keeping track of tripoints instead of just points but that seems excessive
Adding 1 tile padding to the edges of city_tiles after it's flood filled
Adding more initial usages but this has been sitting drafted for ages

Testing

For basic city_tiles testing or map_in_city testing plop this anywhere in the JSON and walk around, also tested post save/load to check that works

  {
    "type": "effect_on_condition",
    "id": "EOC_TEST_IS_IN_CITY",
    "eoc_type": "EVENT",
    "required_event": "avatar_enters_omt",
    "condition": { "map_in_city": { "mutator": "u_loc_relative", "target": "(0,0,0)" } },
    "effect": [ { "u_message": "You are in a city OMT.", "type": "good" } ],
    "false_effect": [ { "u_message": "You are NOT in a city OMT.", "type": "bad" } ]
  },

For city_distance performance testing add this to a test cpp and run it with and without the changes, comparing the times

TEST_CASE( "overmap_generation_time", "[overmap]" )
{
    overmap_buffer.clear();
    const point_abs_om origin;
    for( const point_abs_om &overmap_point : closest_points_first( origin, 5 ) ) {
        overmap &om = overmap_buffer.get( overmap_point );
    }
}

Additional context

@Procyonae Procyonae marked this pull request as draft May 30, 2024 13:48
@github-actions github-actions bot added Map / Mapgen Overmap, Mapgen, Map extras, Map display [C++] Changes (can be) made in C++. Previously named `Code` EOC: Effects On Condition Anything concerning Effects On Condition <Bugfix> This is a fix for a bug (or closes open issue) json-styled JSON lint passed, label assigned by github actions astyled astyled PR, label is assigned by github actions labels May 30, 2024
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label May 30, 2024
@github-actions github-actions bot added <Documentation> Design documents, internal info, guides and help. [Markdown] Markdown issues and PRs labels Oct 18, 2024
@github-actions github-actions bot removed the BasicBuildPassed This PR builds correctly, label assigned by github actions label Oct 18, 2024
@Procyonae Procyonae marked this pull request as ready for review October 18, 2024 13:34
@Procyonae Procyonae marked this pull request as draft October 18, 2024 13:39
Not sure why I were checking 2 thick circles?
@Procyonae Procyonae marked this pull request as ready for review October 18, 2024 13:51
@Procyonae Procyonae marked this pull request as draft October 19, 2024 10:24
@Procyonae Procyonae marked this pull request as ready for review October 19, 2024 11:43
@github-actions github-actions bot added BasicBuildPassed This PR builds correctly, label assigned by github actions and removed BasicBuildPassed This PR builds correctly, label assigned by github actions labels Oct 19, 2024
src/condition.cpp Outdated Show resolved Hide resolved
Co-authored-by: ehughsbaird <[email protected]>
@github-actions github-actions bot added the BasicBuildPassed This PR builds correctly, label assigned by github actions label Oct 20, 2024
@Maleclypse Maleclypse merged commit 0f77443 into CleverRaven:master Oct 24, 2024
26 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
astyled astyled PR, label is assigned by github actions BasicBuildPassed This PR builds correctly, label assigned by github actions <Bugfix> This is a fix for a bug (or closes open issue) [C++] Changes (can be) made in C++. Previously named `Code` <Documentation> Design documents, internal info, guides and help. EOC: Effects On Condition Anything concerning Effects On Condition json-styled JSON lint passed, label assigned by github actions Map / Mapgen Overmap, Mapgen, Map extras, Map display [Markdown] Markdown issues and PRs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

map_in_city says you're not in a city when you very clearly are
3 participants