Fix identical omts spawning over themselves #68324
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary
Bugfixes "Fix overload of zeds and vehicles with older saves"
Purpose of change
Possibly fixes #67837. One fix led to another bug, which leads to this fix. There's a migration safety issue in mapgen where old saves serialized 'bad data' that was resolved at runtime. The runtime fixup was removed, but the saves were not migrated. This is an attempt to implement that save migration.
Describe the solution
I don't really know the exact terminology, but the laymans answer is things like roads were running mapgen 'over themselves' repeatedly. This resulted in things like dozen car pileups and hundreds of zeds in cities. The patch that introduced this (#67773) implemented logic at worldgen? mapgen? time which prevents these redundant roads being added to a 'predecessors' list. I ported that logic into the savegame deserializer to try to handle this at load time so older saves migrate forward successfully. The only thing I'm unsure of is the base condition of zero to 1 predecessors, but I'm assuming that any predecessor should be allowed compared to a base case of I'm guessing null terrain?
Describe alternatives you've considered
Testing
Created a save in a game compiled just prior to #67773. Debug map revealed and teleported to a city extremely far away. No problem.
Loaded that save on ##67773. Teleported to the same tile. Hundreds of zeds.
Applied my fix. Teleported to the tile. Not hundreds of zeds.
Roads don't have infinite predecessors anymore. A before comparison:
Created a new world. Inspected 4 way intersections in cities. Saw there are still some that have a manhole omt as a predecessor. Manholes appear to not be linear, and adding the LINEAR flag is apparently mutually exclusive with NO_ROTATE, so that's not going to change. I don't know if this means city intersections have a higher chance of double spawns of somethings or not.
Additional context
0.G didn't have this redundant manhole under crossroad stuff. But JSONizing roads is radically different than what was before. No clue how to get there.