Fractal Softworks Forum

Please login or register.

Login with username, password and session length
Advanced search  

News:

Starsector 0.97a is out! (02/02/24); New blog post: Simulator Enhancements (03/13/24)

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

Wispborne

  • Captain
  • ****
  • Posts: 400
  • Discord: wispborne
    • 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
Mod: Persean Chronicles | Mod Manager: SMOL | Tool: VRAM Estimator | Tool: Forum+Discord Mod Database | If I'm inactive for 3 months, anyone can use any of my work for anything (except selling it or its derivatives).

Alex

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

Thank you - removed the cast.
Logged