Skip to content

Crash when using explosion spell on weapon attack. #311

@GianptDev

Description

@GianptDev

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions