-
Notifications
You must be signed in to change notification settings - Fork 6
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: NPE in EconomySystem
#26
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I can confirm that the game no longer crashes with this PR. I wasn't able to see the visitor gooey, though (probably fixed by #27 ?)
economyComponent.playerWalletCredit += baseEntranceFee; | ||
player.saveComponent(economyComponent); | ||
public void payEntranceFee(VisitorComponent visitorComponent) { | ||
if (visitorComponent.visitorEntranceBlock.hasComponent(VisitorEntranceComponent.class)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Should we log something in case the component is not there?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good idea, I'll take care of it and re-request review afterwards 👍
src/main/java/org/terasology/gookeeper/system/EconomySystem.java
Outdated
Show resolved
Hide resolved
src/main/java/org/terasology/gookeeper/system/EconomySystem.java
Outdated
Show resolved
Hide resolved
Co-authored-by: Tobias Nett <skaldarnar@googlemail.com>
Co-authored-by: Tobias Nett <skaldarnar@googlemail.com>
|
||
VisitBlockComponent visitBlockComponent = visitBlock.getComponent(VisitBlockComponent.class); | ||
|
||
Prefab gooeyPrefab = prefabManager.getPrefab("GooKeeper:" + visitBlockComponent.type); | ||
|
||
if (economyComponent != null && gooeyPrefab != null && gooeyPrefab.hasComponent(GooeyComponent.class)) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why did you remove the checks for gooeyPrefab != null
and gooeyPrefab.hasComponent(GooeyComponent.class)
?
This might still be breaking - is this such that it fails hard if these dependencies within the same module break?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
good catch... that wasn't on purpose tbh... and yes I think if the getComponent
returns null
and that is left unchecked, the resulting NPE would crash the game hard.
I believe that's fixed by #27 |
Spawning a
I think this warning is added in this PR. Was our assumption correct that this component should always be there? Is it added if the visitor is spawned "by the game"? Should we remove the warning again? And why is that checked so often... so many questions 🙈 |
Don't think so. We should consider how to make it clearer that it's expected when spawning using the debugging command
Good question, I don't think it should be checked that often 🤔 |
Fixed the gigantic visitor model in #29 |
How to test
GooKeeper
game without this PRspawnPrefab visitor