Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: prevent npe on player death by thrown spear #254

Merged
merged 6 commits into from
Dec 4, 2021

Conversation

skaldarnar
Copy link
Contributor

Combat system may assign null as instigator to some (Before)DestroyEvents which causes an NPE in the player death system.

This fixes the crash with a TODO item to find and fix the root cause. See Terasology/CombatSystem#92 for first investigation results.

In addition, this commit introduces an enum for the statistics type to update to avoid any bugs resulting from using plain string "constants" (we did not even use constants ...).

Furthermore, I've made the pre-game countdown a constant. This should make it easier to find this value and adjust it later, e.g., for local testing or tweaking.

Combat system may assign `null` as instigator to some (Before)DestroyEvents which causes an NPE in the player death system.

This fixes the crash with a `TODO` item to find and fix the root cause. See Terasology/CombatSystem#92 for first investigation results.

In addition, this commit introduces an enum for the statistics type to update to avoid any bugs resulting from using plain string "constants" (we did not even use constants ...).
This should make it easier to find this value and adjust it later, e.g., for local testing or tweaking.
@skaldarnar skaldarnar requested a review from jdrueckert December 4, 2021 13:37
Comment on lines +29 to +30
private static final int COUNTDOWN_IN_SECONDS = 30;

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should this reside with the other LAS constants in LASUtils?

* @param aliveCharacterComponent
* @param event notification event that a player entity is about to be destroyed (usually sent on death)
* @param player the player entity about to be destroyed
* @param characterComponent ensures that the entity has a character (TODO: why do we need this?)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To make sure we only fetch this event for actual players? 🤔
As we only do something here if PlayerCharacterComponent is present, maybe we want to "require" that one instead.

jdrueckert
jdrueckert previously approved these changes Dec 4, 2021
@jdrueckert jdrueckert changed the title fix/prevent npe on player death fix: prevent npe on player death by thrown spear Dec 4, 2021
@jdrueckert jdrueckert merged commit 4b29154 into develop Dec 4, 2021
@jdrueckert jdrueckert deleted the fix/prevent-npe-on-player-death branch December 4, 2021 21:12
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.

2 participants