Skip to content

Fix crash on assigning military equip without current goal#89

Open
queria wants to merge 1 commit into
rossturner:masterfrom
queria:fix-military-no-goal-crash
Open

Fix crash on assigning military equip without current goal#89
queria wants to merge 1 commit into
rossturner:masterfrom
queria:fix-military-no-goal-crash

Conversation

@queria

@queria queria commented Aug 8, 2025

Copy link
Copy Markdown

When Settler does not have current goal (like hauling something), when switched to military and assigning equipment (armor/weapon...), game would crash when attempting to compare if current goal is not already to fetch the equipment due to the settler not having any goal.

(Not sure if it can happen normally, but easy to reproduce
using debug menu, when in paused state, by spawning settler,
switching to military and assigning from available equip).

Trace (part, and from Steam version) looks as:

  ERROR: java.lang.NullPointerException: Cannot invoke "technology.rocketjump.mountaincore.entities.ai.goap.AssignedGoal.getAssignedHaulingAllocation()"
  because the return value of "technology.rocketjump.mountaincore.entities.behaviour.creature.CreatureBehaviour.getCurrentGoal()" is null
    at technology.rocketjump.mountaincore.entities.components.creature.MilitaryComponent.getCurrentHaulingAllocation(MilitaryComponent.java:180)
    at technology.rocketjump.mountaincore.entities.components.creature.MilitaryComponent.createHaulingAllocationIfRequired(MilitaryComponent.java:161)
    at technology.rocketjump.mountaincore.entities.components.creature.MilitaryComponent.infrequentUpdate(MilitaryComponent.java:104)
    at technology.rocketjump.mountaincore.screens.SettlerManagementScreen.lambda$weaponSelection$10(SettlerManagementScreen.java:575)
    at technology.rocketjump.mountaincore.screens.SettlerManagementScreen$9.lambda$clicked$2(SettlerManagementScreen.java:605)
    at technology.rocketjump.mountaincore.screens.SettlerManagementScreen$SelectItemOption.onSelect(SettlerManagementScreen.java:806)
    at technology.rocketjump.mountaincore.ui.widgets.SelectItemDialog$1.clicked(SelectItemDialog.java:68)

When Settler does not have current goal (like hauling something),
when switched to military and assigning equipment (armor/weapon...),
game would crash when attempting to compare if current goal is not
already to fetch the equipment due to the settler not having any goal.

(Not sure if it can happen normally, but easy to reproduce
 using debug menu, when in paused state, by spawning settler,
 switching to military and assigning from available equip).

Trace (part, and from Steam version) looks as:

```
  ERROR: java.lang.NullPointerException: Cannot invoke "technology.rocketjump.mountaincore.entities.ai.goap.AssignedGoal.getAssignedHaulingAllocation()"
  because the return value of "technology.rocketjump.mountaincore.entities.behaviour.creature.CreatureBehaviour.getCurrentGoal()" is null
    at technology.rocketjump.mountaincore.entities.components.creature.MilitaryComponent.getCurrentHaulingAllocation(MilitaryComponent.java:180)
    at technology.rocketjump.mountaincore.entities.components.creature.MilitaryComponent.createHaulingAllocationIfRequired(MilitaryComponent.java:161)
    at technology.rocketjump.mountaincore.entities.components.creature.MilitaryComponent.infrequentUpdate(MilitaryComponent.java:104)
    at technology.rocketjump.mountaincore.screens.SettlerManagementScreen.lambda$weaponSelection$10(SettlerManagementScreen.java:575)
    at technology.rocketjump.mountaincore.screens.SettlerManagementScreen$9.lambda$clicked$2(SettlerManagementScreen.java:605)
    at technology.rocketjump.mountaincore.screens.SettlerManagementScreen$SelectItemOption.onSelect(SettlerManagementScreen.java:806)
    at technology.rocketjump.mountaincore.ui.widgets.SelectItemDialog$1.clicked(SelectItemDialog.java:68)
```
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant