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

Use weighted list for nested mapgen with same id #39511

Merged

Conversation

ralreegorganon
Copy link
Contributor

Summary

SUMMARY: None

Purpose of change

Nested mapgen were stored in a vector and if multiple entries had the same id, they all had an equal chance of being selected--the weight attribute was being ignored.

This changes it so that nested mapgen are stored in a weighted list, and consequently behave the same way as normal mapgen: given multiple entries with the same id, those with a higher weight are more likely to be selected.

Describe the solution

Replace the std::vector used with a weighted_int_list, and then update all the usages of it accordingly.

Testing

Created some nested mapgen and tested spawning them via the debug menu, both with weights defined and omitted (which then falls back to the default weight of 1000 as documented in MAPGEN.md), and verified that the results were as expected.

@ralreegorganon ralreegorganon added the Map / Mapgen Overmap, Mapgen, Map extras, Map display label Apr 12, 2020
@ralreegorganon ralreegorganon force-pushed the weighted-nested-mapgen branch from 6252593 to 65f816c Compare April 13, 2020 05:00
@ZhilkinSerg ZhilkinSerg merged commit 2325558 into CleverRaven:master Apr 13, 2020
@ralreegorganon ralreegorganon deleted the weighted-nested-mapgen branch April 13, 2020 20:58
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants