Fractal Softworks Forum

Starsector => Bug Reports & Support => Bug Reports & Support (modded) => Topic started by: Wispborne on April 25, 2021, 03:46:37 PM

Title: [0.95 RC15] Crash when displaying loot caused by unneeded vanilla class cast
Post by: Wispborne on April 25, 2021, 03:46:37 PM
tldr;

A line in BlueprintIntel downcasts, causing a crash if a mod is using a different subclass of InteractionDialogPlugin than RuleBasedInteractionDialogPluginImpl.
It does not need to make that cast, as getMemoryMap() is a method of the InteractionDialogPlugin interface.

Where: com.fs.starfarer.api.impl.campaign.missions.BlueprintIntel.java::288 as of 0.9.5 RC15.

Code
    public void reportAboutToShowLootToPlayer(CargoAPI loot, InteractionDialogAPI dialog) {
        Iterator var4 = loot.getStacksCopy().iterator();

        while(var4.hasNext()) {
            CargoStackAPI stack = (CargoStackAPI)var4.next();
            if (this.item.equals(stack.getData())) {
                Global.getSector().getListenerManager().removeListener(this);
  --------->    this.setCurrentStage(BlueprintIntel.Stage.COMPLETED, dialog, ((RuleBasedInteractionDialogPluginImpl)dialog.getPlugin()).getMemoryMap());
                break;
            }
        }

    }

-------------

This crashes if a mod uses a subclass of InteractionDialogAPI, uses it to call visualPanel.showLoot, AND the player happens to have a hub blueprint mission with the blueprint that is being shown.
The crash is reproducing (unreliably, of course) in Persean Chronicles. Dark.Revenant has mentioned that he ran into this bug as well.
Title: Re: [0.95 RC15] Crash when displaying loot caused by unneeded vanilla class cast
Post by: Alex on April 25, 2021, 05:32:27 PM
Thank you - removed the cast.