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 4: Support mapgen parameters for most mapgen ids #50853

Merged
merged 5 commits into from
Aug 18, 2021

Conversation

jbytheway
Copy link
Contributor

@jbytheway jbytheway commented Aug 17, 2021

Summary

Infrastructure "Support mapgen parameters for most mapgen ids"

Purpose of change

Prior to this PR mapgen parameters only worked for terrain. This was simply a limitation to simplify the initial implementation. We want them to work for all the other things in mapgen also.

Continuing the work from #48529, #49980, #50681.

Describe the solution

Extend mapgen parameter support to most other mapgen ids. The few things that are not supported are:

  • jmapgen_gaspump's fuel type
  • jmapgen_item_group's item group
  • jmapgen_loot's result_group
  • jmapgen_monster's monster ids
  • jmapgen_sealed_item's furniture id

Those are trickier cases which will need more careful attention, so I have left them for now.

Other changes that come along in this PR:

  • More types for cata_variant (for each of the ids we are parametrizing).
  • Migrate some zone definitions to JSON (because when they are hardcoded in the way that they were, their ids were invalid and couldn't be used in mapgen due to the sanity checks I added).
  • Improve checks on parameter definitions. In particular, check that all values used are valid.
  • Test the newly extended functionality by tweaking the definition of vents in the new modular labs by @curstwist. Previously the vents always blew cold air. Now they choose randomly between hot and cold, but the same across any specific lab. (In my mind you get hot air if the air conditioner has broken)

Describe alternatives you've considered

Trying to cover more of the awkward cases I chose to leave out.

Testing

Unit tests verify that the JSON still loads OK.

Some walking around in-world suggests that I haven't broken mapgen too comprehensively. I certainly haven't tested all the code I've changed, but I'm hoping the changes were similar enough that they should all behave similarly.

Debug-spawned the lab_mutagen_6_floor and verified that the vents seem to be behaving as desired.

Additional context

The way errors are reported for JSON mapgen will have changed as a result of this. Some errors should be improved while others have probably become worse (in particular, some now won't provide the nice line and column number with an extract of the problematic JSON), but overall I hope it's a net win. I'd like to figure out how to restore the previous error experience, but it's not obvious to me how, so I'm not attempting to do it in this PR.

We need lots more types so that they can be used as mapgen_value types
for parametric mapgen.
Previously, parametric mapgen could only be used for terrain.  Extend
that to all other json mapgen pieces for which is is straightforward to
do so.

A few of trickier cases remain without support:
* jmapgen_gaspump's fuel type
* jmapgen_item_group's item group
* jmapgen_loot's result_group
* jmapgen_monster's monster ids
* jmapgen_sealed_item's furniture id
Postponing those to the future for now.
For these zone types' ids to be deemed valid we must have JSON
definitions of them so that they are defined within the zone_factory.
There was previously no way to detect an invalid id in a mapgen
parameter definition.  Check for those.
Update the mutagen lab mapgen to select either hot or cool vents rather
than always using cool vents.  The intention is that the vents should be
the same throughout a lab, but potentially different between labs.
@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 17, 2021
@kevingranade kevingranade merged commit 13146bd into CleverRaven:master Aug 18, 2021
@jbytheway jbytheway deleted the more_mapgen_values branch August 19, 2021 00:48
@jbytheway jbytheway changed the title Parametric mapgen part 4: Support mapgen parameters in for most mapgen ids Parametric mapgen part 4: Support mapgen parameters for most mapgen ids Aug 25, 2021
@Maleclypse
Copy link
Member

I don't know what to put where "roof_type" is.

  {
    "type": "overmap_terrain",
    "id": "microlab_generic",
    "name": "science lab",
    "sym": "L",
    "color": "light_blue",
    "parameters": {
      "roof_type": {
        "type": "mongroup_id",
        "default": { "distribution": [ [ "group": "GROUP_MICROLAB", "population": [ 12, 25 ], "chance": 80 ], [ "group": "GROUP_RATKIN_EVOLVED", "population": [ 12, 25 ], "chance": 80 ] ] }
      }
    },
    "see_cost": 5,
    "flags": [ "NO_ROTATE", "RISK_HIGH", "SOURCE_CHEMISTRY", "SOURCE_MEDICINE" ]
  },

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.

4 participants