RimWorldCCLTeam / CommunityCoreLibrary

For full details see the official Ludeon Forums thread.
https://ludeon.com/forums/index.php?topic=16599.0
The Unlicense
60 stars 27 forks source link

Minimap overlay settings don't load from XML #149

Open LockdownX7 opened 7 years ago

LockdownX7 commented 7 years ago

For a few people, some of the minimap overlay settings are not loaded from XML after a game restart, with the minimap defaulting to their originally defined color/radius. As I have this bug myself, I've done some troubleshooting to try and figure out the root cause for it:

From what I understand, the issue with the overlay color/radius settings being ignored lies with a few specific calls of the Scribe_Values.LookValue method. I used the MiniMapOverlay_Colonists class for the purposes of debugging, but all MiniMapOverlay subclasses likely suffer from the same issue, as their colors reset too.

For the test, I used this XML (setting colonists to show as orange in the minimap) and changed the ExposeData method of MiniMapOverlay_Colonists to look like this. The resulting console output makes it clear the intended orange color for the colonist overlay is not loaded from the XML: the color field maintains its default green color, and my custom colorScribeTest variable maintains its default "empty?!?!" value, so the Scribe_Values.LookValue calls aren't doing anything.

However, there are some instances where the XML scribing is working as intended, such as when fetching the 'ccl_version' or 'visible' elements, so it's definitely not an access problem to the XML file itself, or the use of the Scribe_Values.LookValue method. Rather, the problem seems to be that the scribe mode is set to ResolvingCrossRefs at the time ExposeData is called (as the console ouput shows), which makes the LookValue method calls not do anything, because they only run any code at all if the mode is LoadSaveMode.Saving or LoadSaveMode.LoadingVars.

If you have any ideas on how to help identify the root cause for this, I'll gladly try them out.