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

perf: specials placement optimizations #3729

Merged
merged 2 commits into from
Nov 21, 2023
Merged

Conversation

Vollch
Copy link
Contributor

@Vollch Vollch commented Nov 21, 2023

Purpose of change

Better performance

Describe the solution

Added two more placement overlays. River overlay prevents attempting of placing river specials on ground and vice versa. Underground overlay allows placing underground special(microlabs in vanilla game) within range of surface specials without conflicts.
Added locations check to land overlay to prevent expensive attempts of placing specials over existing cities.
Limited max amount of attempts to build connections. It could been terribly slow - i've seen minute long hangs during placing of single special, when it physically can't be connected anywhere, due to being on unreachable island, or fully surrounded by other buildings.

With all that generation speed of crowded maps with big cities will be magnitude faster than before. On default settings with plenty of empty space difference isn't that drastic.
As for result - with dedicated overlays land specials won't interfere with river and underground ones, which is nicer, but there isn't a lot of them to benefit from it, so produced overmaps looks pretty much same.

Describe alternatives you've considered

Code would look a bit more consistent with six overlays, land\lake\river plus their underground counterparts. But since we don't have any underwater specials it would just increase operational costs for nothing.
Adding "RIVER" and "UNDERGROUND" specials flags, forcing them to respective overlays. First one would allow less hacky detection of river special(but would break all river specials in old mods), second one could be useful for thing like mining mod(but don't have any use in vanilla).
It might be beneficial to skip land locations check when map generated with no cities, but this case is already fast enough to bother too much.

Testing

Maps are generating, tests are passing.

Additional context

Checklist

@github-actions github-actions bot added the src changes related to source code. label Nov 21, 2023
scarf005
scarf005 previously approved these changes Nov 21, 2023
Copy link
Member

@scarf005 scarf005 left a comment

Choose a reason for hiding this comment

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

image

built without problems, mapgen is much more snappy now.

src/overmap.cpp Show resolved Hide resolved
src/overmap.cpp Show resolved Hide resolved
src/overmap.cpp Outdated Show resolved Hide resolved
@scarf005 scarf005 added this pull request to the merge queue Nov 21, 2023
Merged via the queue into cataclysmbnteam:upload with commit 0f77009 Nov 21, 2023
13 of 15 checks passed
@Vollch Vollch deleted the perf branch November 21, 2023 14:51
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
src changes related to source code.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants