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

Allow JSON linear terrain and unhardcode anthill mapgen #51474

Merged
merged 4 commits into from
Sep 13, 2021

Conversation

jbytheway
Copy link
Contributor

@jbytheway jbytheway commented Sep 8, 2021

Summary

Infrastructure "Allow JSON-defined linear terrain and unhardcode anthills"

Purpose of change

We want to move more mapgen from hardcoded to JSON.

One major obstacle to that was linear terrain, which previously only supported hardcoded mapgen.

Linear terrain is used for things like roads and tunnels that must connect from one OMT to the next.

Describe the solution

This is a PR built on top of #51317 and includes the changes therefrom. It fixes the biggest issue with #51317 in that now ants spawn properly in the tunnels as they should.

The additional changes are:

  • Remove all the code related to old hardcoded ant mapgen, both at the overmap and tile level.
  • JSON-defined mapgen for linear terrain will now be correctly rotated. This fixes the problem that previously existed with JSON linear terrain.
  • Use that capability to define JSON versions of the ant tunnel terrain.
  • Also define all the other ant terrains in JSON (this could have been done at any time, but it makes sense to do it in this PR).
  • Make all the ant terrains rotatable. This is needed to get e.g. the openings for the food, larva, and queen chambers to line up.
  • Add migration for the old ant terrains to the new ones. This is pretty simplistic and will cause some chambers to become disconnected in existing anthills, but it's just a temporary problem.
  • Add documentation.

Describe alternatives you've considered

My ant tunnel definitions are pretty simplistic. For example, all chambers are exactly the same layout. There's plenty of room for improvement, but they're roughly as interesting as the old ones, so I think it's sufficient for now.

Currently I've completely removed all acid anthills. I want to re-add those but it requires either (a) duplicating everything to define a bunch of nearly identical terrains or (b) adding new mapgen parameter features to allow them to be used in overmap special and overmap terrain definition. I want to do (b) but it is a major new feature, so it would be too much for this PR.

The bug of not being able to escape from anthills is also still present. The fix I have planned for that also requires a new feature.

Testing

Loaded old games and verified migration works. Teleported to new overmap and verified that new anthills are generated.

Additional context

Some screenshots follow. The ones with no ants were because I did some testing before I added the ant spawns to these new terrains.
ant-tunnels-new-with-ants
anthill-new
ant-ends-new
ant-tunnels-new

@Venera3
Copy link
Member

Venera3 commented Sep 8, 2021

Is this limited to mutable specias, or can one straight up define a new connection type with JSON mapgen?

@jbytheway
Copy link
Contributor Author

Is this limited to mutable specials, or can one straight up define a new connection type with JSON mapgen?

You can define a new linear terrain type and use it in fixed or mutable overmap specials, but it won't be a connection, in the sense that connections can be defined for roads and subways. Those connect different specials together. That is yet to be JSONized. This was an important step in that direction, but we're not there yet.

@jbytheway jbytheway force-pushed the unhardcode_anthill_mapgen branch from 242691a to 5bf23ad Compare September 8, 2021 17:09
@actual-nh actual-nh added <Enhancement / Feature> New features, or enhancements on existing [C++] Changes (can be) made in C++. Previously named `Code` [JSON] Changes (can be) made in JSON Code: Infrastructure / Style / Static Analysis Code internal infrastructure and style Map / Mapgen Overmap, Mapgen, Map extras, Map display labels Sep 8, 2021
@jbytheway jbytheway force-pushed the unhardcode_anthill_mapgen branch 2 times, most recently from ef4ed6c to 3d681b6 Compare September 10, 2021 15:26
Previously this would fail with an error which didn't explain where the
problem was.
Linear terrain (roads, ant tunnels, sewers, etc.) was not previously
possible to define in JSON.  This was because the rotation wasn't
correctly calculated for linear terrain.  Make it be.
We already jsonized the overmap generation for anthills.  This further
jsonizes the regular (tile) mapgen, and completely rips out the old
hardcoded overmap generation.

As part of this process, all the overmap terrains became rotatable, and
so needed to be migrated.

This fixes the issue where ants were not spawning in the tunnels for the
new-style anthills.

However, for the time being only regular anthills are being generated,
not acid anthills.  I plan to re-add acid anthills later.
@jbytheway jbytheway force-pushed the unhardcode_anthill_mapgen branch from 3d681b6 to 824ceba Compare September 10, 2021 23:23
@jbytheway
Copy link
Contributor Author

CI looks clean except for LGTM, and I can't tell what went wrong there; maybe just a timeout.

@Night-Pryanik
Copy link
Contributor

Should this close #24628?

@jbytheway
Copy link
Contributor Author

Should this close #24628?

No, the monster spawning is using the same mechanism, so I'd expect that issue to be the same.

(That said, in the future I want to make it so that ant tunnels connect with other underground stuff like the basement, so perhaps we can fix that bug by making the tunnels penetrate the basement, rather than by stopping the spawning ;)).

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 <Enhancement / Feature> New features, or enhancements on existing [JSON] Changes (can be) made in JSON Map / Mapgen Overmap, Mapgen, Map extras, Map display
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants