From: nethack.rankin Date: Sat, 28 Jan 2012 02:52:14 +0000 (+0000) Subject: wizard bones bug (trunk only) X-Git-Tag: MOVE2GIT~67 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=7dd8600e17b71b495c3bb13500416539a87a6b06;p=nethack wizard bones bug (trunk only) The wizard mode sequence load bones? y, unlink bones? y, die, save bones? y works, but load bones? y, unlink bones? n, die, save bones? y, replace old bones? y fails if/when external compression is in use. The file gets uncompressed before being opened to check its existence, then immediately closed, and re-compressed, changing the file's name, before the deletion attempt takes place. Then delete_bonesfile() can't find it via the uncompressed name and the bones saving code reports "cannot unlink old bones". The code involved doesn't seem to have changed since the current cvs repository was set up, so this bug has gone unnoticed for a long time. There's no reason this fix shouldn't go into the branch too, other than the fact that I don't have that checked out on this machine. If someone wants to apply it there, be my guest (and move the fixes entry to fixes34.4). --- diff --git a/doc/fixes35.0 b/doc/fixes35.0 index e3d5965cb..f558c3c66 100644 --- a/doc/fixes35.0 +++ b/doc/fixes35.0 @@ -402,6 +402,8 @@ hangup save made during magic mapping or detection performed while underwater could put hero on top of the water after restore items conferring life drain resistance were affected by drain life spell 'a'pply command could be used to recogniize undiscovered potions of oil +fix replacing an existing bones file in wizard mode [load?y, unlink?n, die?y, + save?y, replace?y] for configurations using external file compression Platform- and/or Interface-Specific Fixes diff --git a/src/bones.c b/src/bones.c index 8358490cf..b762e5a00 100644 --- a/src/bones.c +++ b/src/bones.c @@ -293,7 +293,6 @@ struct obj *corpse; fd = open_bonesfile(&u.uz, &bonesid); if (fd >= 0) { (void) close(fd); - compress_bonesfile(); #ifdef WIZARD if (wizard) { if (yn("Bones file already exists. Replace it?") == 'y') { @@ -302,6 +301,9 @@ struct obj *corpse; } } #endif + /* compression can change the file's name, so must + wait until after any attempt to delete this file */ + compress_bonesfile(); return; }