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.8.1a RC8] NPE – event report recursion?  (Read 1417 times)

Histidine

  • Admiral
  • *****
  • Posts: 4661
    • View Profile
    • GitHub profile
[0.8.1a RC8] NPE – event report recursion?
« on: June 07, 2017, 06:31:03 AM »

I have a crash where if an event report has a message priority DELIVER_IMMEDIATELY, and its on-delivery script causes another event to be reported with DELIVER_IMMEDIATELY, the game NPEs.

Code
ERROR com.fs.starfarer.combat.CombatMain  - java.lang.NullPointerException
java.lang.NullPointerException
at com.fs.starfarer.campaign.comms.CommSystem.deliverMessages(Unknown Source)
at com.fs.starfarer.campaign.comms.CommSystem.addMessage(Unknown Source)
at com.fs.starfarer.campaign.comms.CommSystem.addMessage(Unknown Source)
at com.fs.starfarer.campaign.CampaignEngine.reportEventStage(Unknown Source)
at com.fs.starfarer.api.impl.campaign.missions.FactionCommissionMissionEvent.startEvent(FactionCommissionMissionEvent.java:86)
at com.fs.starfarer.campaign.events.CampaignEventManager.startEvent(Unknown Source)
at com.fs.starfarer.api.impl.campaign.missions.FactionCommissionMission.playerAccept(FactionCommissionMission.java:72)
at com.fs.starfarer.ui.newui.CommDirectoryDialog.actionPerformed(Unknown Source)
at com.fs.starfarer.ui.j.o00000(Unknown Source)
at com.fs.starfarer.ui.I.processInput(Unknown Source)
at com.fs.starfarer.ui.V.o00000(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)

Steps to reproduce (don't have a minimal mod handy right now, unfortunately):
- Start a Nexerelin game with "free start" faction (in vanilla section of dialog)
- Console command: setrelationship hegemony 51
- Console command: createalliance hegemony player_npc
- Open Jangala's comm board and accept a commission

Changing the message priority here to ENSURE_DELIVERY prevents the crash.
Logged

Alex

  • Administrator
  • Admiral
  • *****
  • Posts: 23988
    • View Profile
Re: [0.8.1a RC8] NPE – event report recursion?
« Reply #1 on: June 07, 2017, 02:16:06 PM »

Is your on-delivery script doing something like:
message.setOnDelivery(null)

It's pretty difficult to see this happening otherwise...

The core code is:
Code: java
boolean deliver = true;
if (envelope.message.getOnDelivery() != null) {
envelope.message.getOnDelivery().beforeDelivery(envelope.message);

// and this is where it crashes due to envelope.message.getOnDelivery() == null
deliver = envelope.message.getOnDelivery().shouldDeliver();
envelope.message.setOnDelivery(null);
}
Logged