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

Crash when using explosion spell on weapon attack. #311

Open
GianptDev opened this issue Feb 14, 2023 · 0 comments
Open

Crash when using explosion spell on weapon attack. #311

GianptDev opened this issue Feb 14, 2023 · 0 comments

Comments

@GianptDev
Copy link

Hi, I've found a bug that happen after using/spawning the SplashExplosion entity in the world and trying to save the game.

I'm making a game with a gun that create an explosion around the player, the gun simply fire that spell class, but I discovered that after the player shot at least one bullet from the gun the game crashes when the player try to save the game.

What is happening?

The crash is caused by a recursive error when serializing the explosion spell class.

The player has a reference somewhere that link to the explosion and the explosion store a reference of the player in the owner property, when the game try to save by exiting the game or entering the next level it will call the object serializer.

The object serializer will save the explosion, then go to the player, the go to the explosion again and do this cyclically until the game crashes because of an endless recursion.

Possible solution

I solved the problem by adding transient to that property, very easy.

transient private Entity owner = null;  // ez

line

Conclusion

It took a painful weekend to discover this thing, the game just started to crash and I was in panic until I finally figured out, so I think is important to be aware of this and my proposal as a solution should not be a problem to the project.

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

No branches or pull requests

1 participant