Open kilobyte opened 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.
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.
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.
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.