anaseto / boohu

Break Out Of Hareka's Underground, a roguelike game.
https://codeberg.org/anaseto/boohu
ISC License
128 stars 8 forks source link

starting another instance of the game duplicates the character #19

Open kilobyte opened 6 years ago

kilobyte commented 6 years ago

If you have a game in progress (running) then start another one on a different terminal, the new session will continue from the last stairs taken, leaving the first one running with the same character.

anaseto commented 6 years ago

Yeah, that's a limitation from the coffee-break menu-less approach. Not sure I'll do something about it, because games are very short and one goes through it in one session most of the time, so implementing stuff to check if other instances are already running seems a little overkill to me, but I'll keep this in mind.

kilobyte commented 6 years ago

What about placing a flock() on the save file — or possibly on a separate lock file? If the lock fails, you can write a message then exit. Such locks go away automatically when the game ends/crashes/the computer crashes, so there's no need to handle stale locks, etc.

No real need to allow multiple sessions on the same machine for the same user.

anaseto commented 6 years ago

I'm a little affraid of calling flock via the syscall package, because it's probably not portable on windows, and as I cannot test this platform myself, I prefer keeping to the portable part of the standard library, because there are some players on this platform.