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

Parametric mapgen part 3: Support mapgen parameters in nests #50681

Merged
merged 8 commits into from
Aug 13, 2021

Conversation

jbytheway
Copy link
Contributor

Summary

Infrastructure "Support mapgen parameters in nests"

Purpose of change

We want mapgen parameters to be usable within nested mapgen.

Allow nests to be a scope for mapgen parameters.

Have more colours of carpets in houses.

Describe the solution

The parameters needed by a particular nest must be lifted from that nest to the overmap_terrains using the nest and thence to the overmap_specials using those overmap_terrains. Do that at data finalization time.

Then, the nest's parameters are automatically chosen at mapgen time just like other mapgen parameters are.

Note that we need to extract the parameters for all possible nests, which can be quite a few within a particular overmap special.

Also, some incidental changes made along the way:

  • Fix and document nest-scope parameters.
  • Use nest-scope parameters to choose carpet colours in carpets placed in houses via nests using house_w_nest_palette.
  • Better error messages when you choose inconsistent default distributions for the same mapgen parameter in a particular scope.
  • Fix mapgen parameters for overmap specials spawned on top of other overmap specials.
  • Detect invalid nested mapgen ids used in mapgen.

On the last point, these changes discovered that fbmw_room2_metal_northeast uses an invalid id fbmw_room2_metal. An error message about this may appear in the CI for this PR, but it's not a new problem, just a newly detected one. @curstwist has kindly offered to look into the proper fix. We might want to wait for that fix before merging this PR.

Describe alternatives you've considered

I previously tried just trying to find all the parameters at mapgen time, by recursively searching through nests, but that was less practical, and it would also be slower.

Testing

I picked one particular nest which places a bedroom with a carpet and used it for testing. I forced it to always spawn on the top floor of garden_house_1.

Here are some screenshots of two different carpet colours being chosen for that nest:
carpet-colour-purple
carpet-colour

I tested the above with the carpet type parameter being of nest scope and of overmap_special scope, both worked. Currently I don't have a good example on an existing map where it makes sense to have an overmap_special-scoped parameter . @curstwist has an idea for one in the new modular labs, but it will have to wait until mapgen parameters support furniture (currently they only support terrain).

Additional context

Continuing the work from #48529 and #49980.

@actual-nh actual-nh 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 Aug 11, 2021
@jbytheway
Copy link
Contributor Author

As expected, CI fails with Unknown nested mapgen function id fbmw_room2_metal.

@actual-nh
Copy link
Contributor

As expected, CI fails with Unknown nested mapgen function id fbmw_room2_metal.

#50678 should fix it.

Allow dumping a weighted list to a string for debug purposes.
Previously when placing an overmap special on top of an existing overmap
special (e.g. via the debug menu) the parameters for the old one would
persist and the new one would lack its parameters.  Instead, overwrite
the old with the new.
We want mapgen parameters to work inside nested mapgen, at all scopes.
To make this work we lift all parameters from nests to overmap terrains
before lifting again from overmap terrains to overmap specials.

At mapgen time, the arguments chosen for these parameters cascade down
in the opposite direction.
A simple bugfix.  Previously we were generating these arguments but not
passing them.
State the two distributions so that it is easier to figure out where
each is coming from and why they are conflicting.
Use the new functionality of mapgen parameters in nests to choose a
random colour of carpet for each carpet used in a nested mapgen using
house_w_nest_palette.

Previously there was a separate symbol for each carpet colour but only 6
(red carpet) was ever used.  Remove the unused symbols and repurpose 6
to mean "random carpet".  Make the parameter of nest scope so each nest
can choose a carpet colour independently.
@jbytheway jbytheway force-pushed the mapgen_parameters_in_nests branch from ec89f03 to 87ae6fa Compare August 12, 2021 11:32
@jbytheway
Copy link
Contributor Author

Rebased to pull in that fix.

@jbytheway
Copy link
Contributor Author

Looks like another similar issue has been detected in the mods. I will investigate.

@jbytheway
Copy link
Contributor Author

Was caused by this chunk of json referring to an invalid nested id bandits_rv. Looks like it's unused, so I've deleted it.

@jbytheway
Copy link
Contributor Author

Ok, everything passed now (except the LGTM failure which I think is unrelated).

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.

3 participants