gurrhack / NetHack-Android

Android port of NetHack
128 stars 23 forks source link

Recover saves with recovery binary #58

Open BlueDrink9 opened 4 years ago

BlueDrink9 commented 4 years ago

I mentioned in a comment on another issue that I had lost a save, however it seems all of the BlueDrink9.0 files still exist. Is there a way to recover these using the official nethack recovery binaries?

BlueDrink9 commented 4 years ago

I made some progress by copying all the game data directory files to an OS X computer, compiling unnethack on there, binary editing BlueDrink9.0 to remove the save/ before the <uid><playername> at the start of the file, then running the recovery binary I had compiled. However, copying the resultant file back to unnethack's saves directory does nothing; the file is not recognised at startup. Renaming the file to use the uid that new saves were generating with did not fix this, but deletes the file that was renamed.

Vahlin commented 4 years ago

Experiencing a similar issue. Went to boot up my game today, and it had some error messages that I wish I had written down, and had the new character creation screen over top of my game in the background.

I force closed the app hoping it was just a glitch and would recover. Now when I type my characters name in, I get:

Checkpointing was not in effect for 1Ansem.0 -- Recovery impossible.

And the new character creation screen comes up with a black background.

Super distraught, was by far the furthest I've ever gotten in this game. Many hours lost. Hoping someone knows a way to recover it.

BlueDrink9 commented 4 years ago

That sounds like it might be a different issue. In my case I don't think the backup files were corrupted at all. But an answer on whether checkpointing is used by gurrhack ports would be nice.

BlueDrink9 commented 4 years ago

AH! Fixed! It seems that, in my case, renaming the save files to use the new user ID that UnNetHack is using has restored my files.

Getting this issue answered would probably still be useful from a documentation standpoint, at least, and for similar/future cases, or cases where root access is unavailable.

gurrhack commented 4 years ago

@BlueDrink9 Checkpointing is on by default. You can turn it off with the checkpoint option in defaults.unh. The Android port has the recover utility built-in so you shouldn't have to run it manually like that. What error did you get?

@Vahlin The "Checkpointing was not in effect" error only happens if the file is corrupt and I doubt it's possible to recover from that. I think it can happen if the nethack process is killed by Android while the game is trying to save its state.

BlueDrink9 commented 4 years ago

I see. I think that's consistent with what I experienced. How is the user id (prefixed to save files) generated? I think my issue was that it had changed, meaning the checkpoint files weren't recognized by the automatic recovery. After looking at new saves to find the new uid, renaming my checkpoints let recovery recognise and restore them.

gurrhack commented 4 years ago

Newer versions of the nethack port is hard coded to user id 1. The unnethack port uses the real uid as reported by the OS which makes it a bit trickier to copy unnethack saves between phones. I guess it's possible for Android to change the uid between OS updates as well but I haven't experienced that.

Vahlin commented 4 years ago

@gurrhack thanks for the reply! Sour... Is there anything I can do to avoid that happening in the future?

Also, unrelated question... I switched to the unnethack port following the save file for NetHack becoming corrupted, but it seems outdated in comparison (mostly small things like for example blessed/uncursed/cursed aren't highlighted in green/yellow/red, etc and I get a notification that the app was designed for an older version of Android and may not work properly). Are there plans to bring the unnethack port up to date?

BlueDrink9 commented 4 years ago

Newer versions of the nethack port is hard coded to user id 1. The unnethack port uses the real uid as reported by the OS which makes it a bit trickier to copy unnethack saves between phones. I guess it's possible for Android to change the uid between OS updates as well but I haven't experienced that.

That's bizare, my uid changes every time I install a different unnethack. Is the android containerisation system creating a new user for each app? (Actually yeah, isn't that how they get unique permissions for app folders?)

BlueDrink9 commented 4 years ago

@Vahlin settings might not be configured right. The play store version had menucolors working for me.

The app has been updated but not put on the store. The apk is available from the github releases

Vahlin commented 4 years ago

Oh that's great. Thank you!