If you store a not-in-economy market as a variable anywhere, it gets "cloned" on save, so now there are two markets with the same ID.
To see this:
- Start new game
- Go to Duzahk, interact with Druj
- With interaction dialog open, enter in console:
runcode Global.getSector().getPersistentData().put("random_string_123", Global.getSector().getCampaignUI().getCurrentInteractionDialog().getInteractionTarget().getMarket());
- Save copy
The first save's descriptor.xml has one <market> with id market_duzahk2, the second has two. The new entry is 69 lines log (while the original one is 15 lines), containing additional tags like market size, demandPriceMod, supplyPriceMod, isPlanetConditionMarketOnly, playerOwned, ...
I encountered this bug while making an NPC colonization fleet event; if the player saves the game after the event starts but before it completes, when the colonization occurs the planet will still appear to be uncolonized when the player interacts with it (because the "cloned" market was added to the economy while the original was not).
I'm currently trying to work around this by not storing any references to the target not-in-economy market in the intel class, instead getting it from the planet entity each time using SectorEntityToken.getMarket().