From 0a8208ae7853c65dd2b0c34f7d65066bb1a05cde Mon Sep 17 00:00:00 2001 From: "L.J. Lim" Date: Sat, 17 Jun 2023 10:19:41 +0800 Subject: [PATCH] Own faction bonus: Fix crash from not explicitly specifying industry upgrade target --- .../world/factionsetup/AddOrUpgradeIndustry.java | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/jars/sources/ExerelinCore/exerelin/world/factionsetup/AddOrUpgradeIndustry.java b/jars/sources/ExerelinCore/exerelin/world/factionsetup/AddOrUpgradeIndustry.java index 672f7bb43..eb10f2ffc 100644 --- a/jars/sources/ExerelinCore/exerelin/world/factionsetup/AddOrUpgradeIndustry.java +++ b/jars/sources/ExerelinCore/exerelin/world/factionsetup/AddOrUpgradeIndustry.java @@ -3,12 +3,14 @@ import com.fs.starfarer.api.Global; import com.fs.starfarer.api.campaign.CargoTransferHandlerAPI; import com.fs.starfarer.api.campaign.SpecialItemPlugin; +import com.fs.starfarer.api.campaign.econ.Industry; import com.fs.starfarer.api.campaign.econ.MarketAPI; import com.fs.starfarer.api.graphics.SpriteAPI; import com.fs.starfarer.api.ui.TooltipMakerAPI; import com.fs.starfarer.api.util.Misc; import exerelin.utilities.NexUtilsMarket; import exerelin.world.factionsetup.FactionSetupHandler.FactionSetupItemDef; + import java.util.HashMap; import java.util.List; import java.util.Map; @@ -25,8 +27,13 @@ public void apply() { String toUpgrade = (String)def.params.get("upgrade"); if (home.hasIndustry(toUpgrade)) { + Industry ind = home.getIndustry(toUpgrade); String target = (String)def.params.get("upgradeTo"); - NexUtilsMarket.upgradeIndustryToTarget(home.getIndustry(toUpgrade), target, true, true); + if (target == null) target = ind.getSpec().getUpgrade(); + if (target == null) { + Global.getLogger(this.getClass()).error("No upgrade target for industry " + ind.getCurrentName()); + } + NexUtilsMarket.upgradeIndustryToTarget(ind, target, true, true); return; }