Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: Bug: Non-economy market cloning [0.9.1a RC8]  (Read 1283 times)

Histidine

  • Admiral
  • *****
  • Posts: 4681
    • View Profile
    • GitHub profile
Bug: Non-economy market cloning [0.9.1a RC8]
« on: June 05, 2019, 04:21:33 AM »

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().
« Last Edit: June 05, 2019, 04:23:33 AM by Histidine »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24110
    • View Profile
Re: Bug: Non-economy market cloning [0.9.1a RC8]
« Reply #1 on: June 05, 2019, 10:18:31 AM »

I think if you call market.setPlanetConditionMarketOnly(false) at the start of the colonization event, that'll stop the market from getting converted into something else on save.

Markets on uncolonized planets are not persistent by default - they'd take up way too much space in the savefile, so the game creates a more light-weight PlanetConditionMarket to store in the save, and converts it into a regular market on load. (The market memory does persist, btw, so it's safe to put things there.) If a market is flagged as not being a condition-only market, the game should stop doing this for the market.

So, to sum it up: if you're making any changes to the market and need them to stick around, call setPlanetConditionMarketOnly(false), otherwise it'll get nuked on save.
Logged