I hit a null error with this code under certain conditions (namely, starting a new game, seeing the Newbie Guide dialog, then exiting
without saving). It's not something players run into, since they usually save pretty early, but I can consistently make the game crash with this.
It crashes on this line:
UI.showInteractionDialog(newbieGuide, blah);Can't be reproduced in Vanilla, since there's nothing like that atm, and I suspect I've found an engine bug here, because I'm testing for any of those elements to return null, and they obviously aren't.
Relevant code section:
if (!Global.getSector().getPersistentData().containsKey(runThisOnce)) {
Global.getSector().getPersistentData().put(runThisOnce, "false");
}
if(Global.getSector().getPersistentData().get(runThisOnce).equals("false")){
Global.getSector().getPersistentData().put(runThisOnce,"true");
CampaignUIAPI UI = Global.getSector().getCampaignUI();
SectorEntityToken blah = Global.getSector().getCurrentLocation().createToken(0,0);
if(blah != null && UI != null)
{
InteractionDialogPlugin newbieGuide = new NewbieGuideDialogPlugin();
if(newbieGuide == null || blah == null || UI == null) return;
UI.showInteractionDialog(newbieGuide, blah);
//Sets up the player's ship in a way that doesn't suck too much.
CargoAPI cargo = Global.getSector().getPlayerFleet().getCargo();
int currentCrew = cargo.getCrew(CargoAPI.CrewXPLevel.REGULAR);
cargo.removeCrew(CargoAPI.CrewXPLevel.REGULAR, currentCrew);
cargo.addCrew(CargoAPI.CrewXPLevel.REGULAR, (int) cargo.getMaxPersonnel() / 10 * 7 - 5);
cargo.addMarines(5);
}
}