Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

Author Topic: [0.95 RC15] Crash when displaying loot caused by unneeded vanilla class cast  (Read 664 times)

Wispborne

  • Commander
  • ***
  • Posts: 173
  • Discord: Wisp#0302
    • View Profile

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.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 19411
    • View Profile

Thank you - removed the cast.
Logged