Fractal Softworks Forum

Please login or register.

Login with username, password and session length

Author Topic: [0.9a] "Delayed" crash when mod removes content  (Read 1141 times)

Histidine

  • Admiral
  • *****
  • Posts: 4689
    • View Profile
    • GitHub profile
[0.9a] "Delayed" crash when mod removes content
« on: February 20, 2019, 04:16:23 AM »

- Player plays a game with MyMod, which adds a fighter X (might also work with a ship or weapon)
- Later update of MyMod removes X
- Player downloads the updated mod and loads their previous save, it still runs (probably because of how inflater works?)
- ...but factions still think they know the no-longer-existent X, which causes crashes when something picks a "known" fighter and to spawn it, e.g. when docking at a market:

Example error:
Code
4200064 [Thread-4] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
    at com.fs.starfarer.api.impl.campaign.submarkets.BaseSubmarketPlugin.addFighters(BaseSubmarketPlugin.java:323)
    at exerelin.campaign.submarkets.Nex_OpenMarketPlugin.updateCargoPrePlayerInteraction(Nex_OpenMarketPlugin.java:22)
    at com.fs.starfarer.campaign.ui.o0OO.<init>(Unknown Source)
    at com.fs.starfarer.coreui.O00o.<init>(Unknown Source)
    at com.fs.starfarer.coreui.O00o.<init>(Unknown Source)
    at com.fs.starfarer.ui.newui.J$5.actionPerformed(Unknown Source)
    at com.fs.starfarer.ui.newui.J.setCurrentTab(Unknown Source)
    at com.fs.starfarer.ui.newui.J.setCurrentTab(Unknown Source)
    at com.fs.starfarer.ui.newui.U.showCoreInternal(Unknown Source)
    at com.fs.starfarer.ui.newui.U.showCore(Unknown Source)
    at com.fs.starfarer.api.impl.campaign.rulecmd.OpenCoreTab.execute(OpenCoreTab.java:40)
    at com.fs.starfarer.ui.newui.oOOO.actionPerformed(Unknown Source)
    at com.fs.starfarer.ui.OoO0.buttonPressed(Unknown Source)
    at com.fs.starfarer.ui.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.?00000(Unknown Source)
    at com.fs.starfarer.ui.oooOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOOO.processInput(Unknown Source)
    at com.fs.starfarer.ui.OoO0.processInputImpl(Unknown Source)
    at com.fs.starfarer.ui.Q.processInput(Unknown Source)
    at com.fs.starfarer.ui.donew.dispatchEventsToChildren(Unknown Source)
    at com.fs.starfarer.ui.donew.processInputImpl(Unknown Source)

Perhaps on game load Starsector should validate each faction's known blueprints and remove anything that doesn't exist in the game?
(Or return to main menu with the load game error, if we expect a different crash down the road and it's better that the player doesn't keep trying to use this save)
Logged

Wyvern

  • Admiral
  • *****
  • Posts: 3803
    • View Profile
Re: [0.9a] "Delayed" crash when mod removes content
« Reply #1 on: February 20, 2019, 11:30:18 AM »

Removing a piece of content like that is basically a no-go in general, just too many things could be referring to it.

So I don't think you're going to get removing things working in a save-compatible fashion.  Likely the best you could do is mark the fighter as built-in-only so it doesn't drop or spawn in markets, adjust its stats to mimic some analogous vanilla fighter so it looks right if you encounter an enemy fleet that's still using it, and use an on-save-load script to go through all markets & the player fleet to swap out any existing copies of the fighter for something else.
Logged
Wyvern is 100% correct about the math.

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 24140
    • View Profile
Re: [0.9a] "Delayed" crash when mod removes content
« Reply #2 on: February 20, 2019, 12:00:35 PM »

Made it crash on game load when a faction "knows" an invalid ship/fighter/weapon/hullmod/industry. Making it not crash and show a "load game" error instead is more difficult since running the checks requires being further along in the loading process than where that'd be easily doable.

I don't think trying to clean it up would be the right move - as you say, there could be other references and this feels like it'd potentially be just hiding another, later problem.
Logged