GentenStudios / Phoenix-OLD

Phoenix is an open world sandbox style voxel game designed to make all content optional.
BSD 3-Clause "New" or "Revised" License
30 stars 10 forks source link

Fix segfault on re-opening escape menu #359

Closed vyomfadia closed 3 years ago

vyomfadia commented 3 years ago

Resolves: # Authors: @beeperdeeper089

Summary of changes

Caveats

Does this introduce any new bugs?

On approval

Merge.

tobyplowy commented 3 years ago

Builds and issue seems to be fixed.

apachano commented 3 years ago

@beeperdeeper089 So why don't we want to remove the escape menu from the layer stack? This seems like it defeats the purpose of having the layer stack in the first place.

vyomfadia commented 3 years ago

Yeah, use cases like this is what I overlooked during the initial revision of this. The layer stack takes control of the memory, so as soon as you push a layer to the layer stack, the stack can call delete the layer as it wants when the conditions are right, so it ended up deleting the escape menu, what we can do is remove that idea of deleting and just have the layer stack pop/push layers and work the top one.

Due to this, one of my next PRs implements a GameStateManager which is just a layer stack but without the complexity of overlays and memory management. The only thing with it is since overlays aren't a thing, each individual state has to render it's overlays (e.g. Game renders Crosshair and Escape menu as it needs within the game class rather than pushing an overlay, as annoying as that sounds it makes it a lot easier to handle the states of each).