niatahl / tahlan-shipworks

a mod for the game Starsector
Other
12 stars 7 forks source link

Crash upon removing all combat ships #5

Closed skessler79 closed 1 year ago

skessler79 commented 1 year ago

This fatal crash occurs immediately after removing all combat ships from my fleet.

3921331 [Thread-3] ERROR com.fs.starfarer.combat.CombatMain - java.lang.IllegalArgumentException: Cannot round NaN value. java.lang.IllegalArgumentException: Cannot round NaN value. at kotlin.math.MathKt__MathJVMKt.roundToInt(MathJVM.kt:1132) at org.niatahl.tahlan.listeners.LegioFleetInflationListener$Companion.addSMods(LegioFleetInflationListener.kt:71) at org.niatahl.tahlan.hullmods.DaemonHeart.advanceInCampaign(DaemonHeart.kt:174) at com.fs.starfarer.campaign.fleet.CampaignFleet.advance(Unknown Source) at com.fs.starfarer.campaign.BaseLocation.advance(Unknown Source) at com.fs.starfarer.campaign.StarSystem.advance(Unknown Source) at com.fs.starfarer.campaign.CampaignEngine.advance(Unknown Source) at com.fs.starfarer.campaign.CampaignState.advance(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.lang.Thread.run(Unknown Source)

Could this be caused by a divide by zero error in LegioFleetInflationListener.kt:70-71? Seems like numShips will be 0 if there's only civilian ships in your fleet?

I don't know Kotlin so I'm just eyeballing it and could be wrong entirely.

niatahl commented 1 year ago

I forgot I changed it to only count combat ships, yeh. Adding a fix.