Skip to content

Conversation

@OrenAudeles
Copy link
Collaborator

Purpose of change (The Why)

In mods it's pretty common to add in new locations. Sometimes they're variants of existing locations and have a modified palette. The problem is that while the location definition becomes a variant, palettes are unilaterally overwritten if they redefine an existing one and will be used as the palette for all locations that use it. Redefinition of palettes has in the past caused various loading errors that were hard to diagnose because there was a disconnect between how the error was reported and where the error actually was.

Describe the solution (The How)

Force named palettes to be unique by using map::try_emplace( key, val ) instead of map[key] = val and make it a fatal json loading error so that it's very obviously not allowed.

Describe alternatives you've considered

Could have not made it a fatal error, or had some way to define in the palette that it's intended to be a redefinition and is not incidental.

Testing

Duplicated the palette in ./data/json/mapgen_palettes/abandoned_textile_mill.json to force a redefinition.
Tried to load a character.
Got the expected error at the expected location and was kicked out to the main menu.

Checklist

Mandatory

Optional

  • This is a C++ PR that modifies JSON loading or behavior.
    • I have documented the changes in the appropriate location in the doc/ folder.
    • If documentation for this feature does not exist, please write it or at least note its lack in PR description.

@github-actions github-actions bot added docs PRs releated to docs page src changes related to source code. labels Apr 24, 2025
@OrenAudeles OrenAudeles force-pushed the mapgen-palette-unique-only branch from a7abe43 to ddc9373 Compare April 24, 2025 09:15
@RoyalFox2140
Copy link
Collaborator

Looks like this is going to brick the Kenan pack.

This will also brick 2200 until I find a way to overwrite distributions in the steel mill into a collection, since you can't forcibly overwrite item groups.

More conversations in dev chat about this.

@OrenAudeles OrenAudeles marked this pull request as draft April 24, 2025 09:21
@OrenAudeles
Copy link
Collaborator Author

Made this a draft so it can't get accidentally merged. Need to change a number of things and add functionality.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

docs PRs releated to docs page src changes related to source code.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants