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.8a RC19-mod1] Planet-specific crash at game start  (Read 1433 times)

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
[0.8a RC19-mod1] Planet-specific crash at game start
« on: May 14, 2017, 04:02:53 AM »

Setting the starting system (ngcSkipTutorialPicked in rules.csv) to Hybrasil and calling the following script from onNewGameAfterTimePass() causes the game to throw an NPE after the initial save:

Code: java
package data.scripts.world;

import com.fs.starfarer.api.Global;
import com.fs.starfarer.api.campaign.CampaignFleetAPI;
import com.fs.starfarer.api.campaign.SectorAPI;
import com.fs.starfarer.api.campaign.SectorEntityToken;
import org.lwjgl.util.vector.Vector2f;

public class StartingSystem {

public static void execute()
{
SectorAPI sector = Global.getSector();
if (Global.getSector().isInNewGameAdvance()) return;

// teleport player to start on top of the planet
SectorEntityToken entity = sector.getEntityById("culann");
CampaignFleetAPI playerFleet = sector.getPlayerFleet();
Vector2f loc = entity.getLocation();
playerFleet.setLocation(loc.x, loc.y);
}
}

Code
54447 [Thread-5] ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.CustomCampaignEntity.render(Unknown Source)
at com.fs.starfarer.campaign.BaseCampaignEntity.render(Unknown Source)
at com.fs.graphics.LayeredRenderer.render(Unknown Source)
at com.fs.starfarer.campaign.BaseLocation.render(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.render(Unknown Source)
at com.fs.starfarer.campaign.CampaignState.render(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$1.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)
After restarting the application, the save can be loaded and played as normal.

The issue appears oddly specific to some planets. Among the ones I tried: it doesn't happen with Tartessus, Daedalon, Kazeron, Barad, Jangala or Gilead. It occurs with the Interstellar Imperium mod's Byzantium (a terran planet).
It also doesn't happen if the setLocation line is commented out.
« Last Edit: May 14, 2017, 04:30:22 AM by Histidine »
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23987
    • View Profile
Re: [0.8a RC19-mod1] Planet-specific crash at game start
« Reply #1 on: May 14, 2017, 01:43:40 PM »

Thank you - reproduced and fixed. Turns out the CustomCampaignEntity class had a member variable with the same name as a base class, and was checking that one for not being null while using the getter for the base class variable to actually do stuff with. One of those "surprised it worked at all" things.
Logged