Skip to content
This repository has been archived by the owner on Jul 2, 2019. It is now read-only.

Save your inventory when you QUIT #91

Closed
scionaltera opened this issue Aug 13, 2018 · 1 comment
Closed

Save your inventory when you QUIT #91

scionaltera opened this issue Aug 13, 2018 · 1 comment
Assignees
Labels
enhancement New feature or request

Comments

@scionaltera
Copy link
Owner

As a player I want the items in my inventory to be there after I quit and return to the game so I don't lose my stuff.

The game currently makes you drop all the items in your inventory on the floor before you leave the game, because the GameMap that represents your inventory is cascade-deleted from the database when your Actor is deleted. Instead, it would be great to be able to keep your inventory around and reattach it when you come back to the game.

@scionaltera scionaltera added the enhancement New feature or request label Aug 13, 2018
@scionaltera
Copy link
Owner Author

There are a few ways this could happen.

One way would be to reexamine the idea of deleting the Actor and instead just flag it as inactive. That way we could leave all the associated database entries alone and simply remove the flag when the player connects again. A downside to this strategy is that we would have to be very careful that all the code in the game filters Actors based on that flag. If we missed one we could accidentally affect a player that's supposed to be logged out.

A way to mitigate the need for all the filtering might be to create a special GameMap specifically for logged out players, and move the Actor onto that map. You'd need to store their original location somewhere so you could move them back there when they reconnect.

Another idea would be to flag the inventory itself and store the ID on the PlayerActorTemplate so it could be reattached to the new Actor when it is created. Inactive GameMaps are much less likely to be accidentally touched than inactive Actors so this seems less risky to me, but more complicated.

@scionaltera scionaltera self-assigned this Aug 13, 2018
scionaltera added a commit that referenced this issue Aug 13, 2018
When you leave the game we now just set your GameMap to null, effectively sending you to "the void". When you reconnect we bring you back to (0, 0) on the default map. That lets us keep your inventory and your Actor in the database without deleting anything, so your inventory is preserved and there's no complicated process to "reconnect" it. We shouldn't have any more problems with broken foreign key constraints preventing cleanup and people now get to keep their stuff. Win win!

* Closes #91
* Fixes #92
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

1 participant