Skip to content

Cannot create market board when ship hull spec is missing #121

@Evolter

Description

@Evolter

Incompatibility with mod Nightcross Armory v1.1.9 - when loading a saved game it throws an error:

ERROR stelnet.util.StelnetHelper  - Couldn't create board for stelnet.board.query.QueryBoard
java.lang.RuntimeException: Ship hull spec [vulture] not found!
stack trace
ERROR stelnet.util.StelnetHelper  - Couldn't create board for stelnet.board.query.QueryBoard
java.lang.RuntimeException: Ship hull spec [vulture] not found!
	at com.fs.starfarer.loading.do.o00000(Unknown Source)
	at com.fs.starfarer.loading.SpecStore.super(Unknown Source)
	at com.fs.starfarer.loading.SpecStore.super(Unknown Source)
	at com.fs.starfarer.settings.StarfarerSettings$1.getHullSpec(Unknown Source)
	at stelnet.board.query.provider.FactionProvider.getAllShips(FactionProvider.java:70)
	at stelnet.board.query.provider.ShipQueryProvider.getShipHulls(ShipQueryProvider.java:119)
	at stelnet.board.query.provider.ShipQueryProvider.getManufacturers(ShipQueryProvider.java:111)
	at stelnet.board.query.view.add.ShipButtonUtils.getManufacturers(ShipButtonUtils.java:33)
	at stelnet.board.query.view.add.ShipQueryFactory.<init>(ShipQueryFactory.java:35)
	at stelnet.board.query.view.add.AddQueryFactory.createQueryTypeButtons(AddQueryFactory.java:88)
	at stelnet.board.query.view.add.AddQueryFactory.<init>(AddQueryFactory.java:30)
	at stelnet.board.query.QueryState.readResolve(QueryState.java:41)
	at stelnet.board.query.QueryState.<init>(QueryState.java:36)
	at stelnet.board.query.QueryBoard.<init>(QueryBoard.java:27)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method)
	at java.base/jdk.internal.reflect.NativeConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingConstructorAccessorImpl.newInstance(Unknown Source)
	at java.base/java.lang.reflect.Constructor.newInstanceWithCaller(Unknown Source)
	at java.base/java.lang.reflect.ReflectAccess.newInstance(Unknown Source)
	at java.base/jdk.internal.reflect.ReflectionFactory.newInstance(Unknown Source)
	at java.base/java.lang.Class.newInstance(Unknown Source)
	at stelnet.util.StelnetHelper.getInstance(StelnetHelper.java:43)
	at stelnet.SettingsListener.initMarket(SettingsListener.java:122)
	at stelnet.SettingsListener.apply(SettingsListener.java:49)
	at stelnet.StelnetMod.onGameLoad(StelnetMod.java:44)
	at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
	at com.fs.starfarer.campaign.save.CampaignGameManager.o00000(Unknown Source)
	at com.fs.starfarer.campaign.CampaignState.dialogDismissed(Unknown Source)
	at com.fs.starfarer.ui.O.dismiss(Unknown Source)
	at com.fs.starfarer.ui.impl.E.dismiss(Unknown Source)
	at com.fs.starfarer.campaign.save.LoadGameDialog.tableRowSelected(Unknown Source)
	at com.fs.starfarer.campaign.ui.UITable.select(Unknown Source)
	at com.fs.starfarer.campaign.ui.UITable.select(Unknown Source)
	at com.fs.starfarer.campaign.ui.UITable.actionPerformed(Unknown Source)
	at com.fs.starfarer.ui.n.buttonPressed(Unknown Source)
	at com.fs.starfarer.ui.OooO.Ò00000(Unknown Source)
	at com.fs.starfarer.ui.OooO.processInput(Unknown Source)
	at com.fs.starfarer.ui.V.o00000(Unknown Source)
	at com.fs.starfarer.BaseGameState.traverse(Unknown Source)
	at com.fs.state.AppDriver.begin(Unknown Source)
	at com.fs.starfarer.combat.CombatMain.main(Unknown Source)
	at com.fs.starfarer.StarfarerLauncher.o00000(Unknown Source)
	at com.fs.starfarer.StarfarerLauncher$1.run(Unknown Source)
	at java.base/java.lang.Thread.run(Unknown Source)

Depending on case, it will throw error enabling to play the game but without Market queries:
Image
or it may crash the game (when e.g. a save was made with another mod, but while loading that mod was disabled).

From my understanding that mod is trying to cover a case when optionally can be run with other mods and it's trying to add a support for some ships. from data/world/factions/nightcross.faction:

    "shipsWhenImporting":{
        "tags":["base_bp", "hightech_bp", "nightcross_bp_fast", "nightcross_bp_heavy", "nightcross_bp_rare"],
        "hulls":[
			"vulture", # SW pack
			"zenith", # SW pack
			"defiance", # Tahlan
			"kodai", # Tahlan
        ],
    },

I'm not sure if such case can repeat with other mods, but maintainers of Nightcross Armory Corporation fixed it in V1.1.10

In theory it should be simple to fix this stelnet.board.query.provider.FactionProvider#getAllShips:

    public List<ShipHullSpecAPI> getAllShips() {
        if (BooleanSettings.MARKET_CODEX_SHIPS.get()) {
            List<ShipHullSpecAPI> ships = Global.getSettings().getAllShipHullSpecs();
            CollectionUtils.reduce(ships, new ShipHullIsInCodex());
            return ships;
        }
        List<ShipHullSpecAPI> ships = new LinkedList<>();
        for (String shipId : getAllShipIds()) {
            //ships.add(Global.getSettings().getHullSpec(shipId));
            ShipHullSpecAPI hullSpec;
            try {
                hullSpec = Global.getSettings().getHullSpec(shipId);
            } catch (RuntimeException e) {
                // Starsector error message: "Ship hull variant [%s] not found!"
                log.warn("Hull spec with ship ID `" + shipId + "` missing in `/data/hulls/`. Ship hull will not be visible in the Stelnet!");
                continue;
            }
            ships.add(hullSpec);
        }
        return ships;

Probably should check if other providers beside faction one needs it.

Metadata

Metadata

Assignees

No one assigned

    Labels

    info neededFurther information is requested or idea needs fleshing outtech workTechnical change or improvement

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions