In Progress General Custom colors can be selected from disabled mods and will corrupt game saves

Users who are viewing this thread

Version number
1.1.0.12734
Branch
Beta
Modded/unmodded
Modded
Summary:

The banner_icons.xml files from disabled mods are still read by the BannerManager. It'll cause:
- Empty slots are shown in the Banner Editor
- Custom colors from those XMLs are shown in the color list and can be applied
- If players select custom colors from a disabled mod and save that game, reading this saved game will crash the game because of invalid color IDs during the reading process.

Crash report ID:

2023-02-26_11.44.59_73509f88d40a0b79b5e7197ac89b8d6a

How to Reproduce:

1. Create a module containing the file "banner_icons.xml" in ModuleData directory
2. Define some custom banner colors
3. Start the game without loading this mod
4. In Banner Editor, the custom colors will show
5. Select a custom color and save the banner
6. Save the game
7. Load the saved game and it'll crash

Specific Tool: No

Media (Screenshots & Video):


Computer Specs:
OS: Windows 11 22H2 (22621.1265)
GPU: GTX 3080Ti
GPU Driver Version: 31.0.15.2756
CPU: Intel Core i7 9700K
RAM: 64G
Motherboard: ROG MAXIMUS XI HERO
Storage Device (HDD/SSD):
 
Last edited:
I can confirm this is not only true, but it's because even if you remove the module entirely the colors still load. If you create an XML file with colors and then change it, you will load lots of different colors. Also if you have multiple mods with conflicting colors so you streamline it, it gets messy.
 
I found another issue regarding the Banner color management. The method BannerManager.GetColorId seems not correctly implemented. It tries to traverse the BannerManager.ColorPalette dictionary with index from 0 to Count-1, but the dictionary's indices are not necessarily continuous.

When a mod uses custom color IDs not starting from 193, it'll crash the game when loading a saved game or creating a kingdom. I have to rewrite this method with Harmony as a workaround.
 
I found another issue regarding the Banner color management. The method BannerManager.GetColorId seems not correctly implemented. It tries to traverse the BannerManager.ColorPalette dictionary with index from 0 to Count-1, but the dictionary's indices are not necessarily continuous.

When a mod uses custom color IDs not starting from 193, it'll crash the game when loading a saved game or creating a kingdom. I have to rewrite this method with Harmony as a workaround.
I had to accommodate this in my succession mod as I wanted a specific subset of colors but they weren't being found despite being in the banner creator because I used IDs I knew weren't in other mods but then weren't continuous.
 
Back
Top Bottom