try to prevent panic encountering empty bones file

This commit is contained in:
nhmall
2026-04-26 08:51:33 -04:00
parent 7fc9baa851
commit c25528dafe
+6
View File
@@ -659,16 +659,19 @@ getbones(void)
return 0; return 0;
} }
restoreinfo.mread_flags = 1; /* return despite error for a bones file */
if (validate(nhfp, gb.bones, FALSE) != SF_UPTODATE) { if (validate(nhfp, gb.bones, FALSE) != SF_UPTODATE) {
if (!wizard) if (!wizard)
pline("Discarding unusable bones; no need to panic..."); pline("Discarding unusable bones; no need to panic...");
ok = FALSE; ok = FALSE;
restoreinfo.mread_flags = 0;
} else { } else {
ok = TRUE; ok = TRUE;
if (wizard) { if (wizard) {
if (y_n("Get bones?") == 'n') { if (y_n("Get bones?") == 'n') {
close_nhfile(nhfp); close_nhfile(nhfp);
compress_bonesfile(); compress_bonesfile();
restoreinfo.mread_flags = 0;
return 0; return 0;
} }
} }
@@ -684,6 +687,7 @@ getbones(void)
close_nhfile(nhfp); close_nhfile(nhfp);
compress_bonesfile(); compress_bonesfile();
/* ToDo: maybe unlink these problematic bones? */ /* ToDo: maybe unlink these problematic bones? */
restoreinfo.mread_flags = 0;
return 0; return 0;
} }
if (strcmp(bonesid, oldbonesid) != 0) { if (strcmp(bonesid, oldbonesid) != 0) {
@@ -695,6 +699,7 @@ getbones(void)
pline1(errbuf); pline1(errbuf);
ok = FALSE; /* won't die of trickery */ ok = FALSE; /* won't die of trickery */
} }
restoreinfo.mread_flags = 0;
trickery(errbuf); trickery(errbuf);
} else { } else {
struct monst *mtmp; struct monst *mtmp;
@@ -726,6 +731,7 @@ getbones(void)
fix_shop_damage(); fix_shop_damage();
} }
} }
restoreinfo.mread_flags = 0;
close_nhfile(nhfp); close_nhfile(nhfp);
sanitize_engravings(); sanitize_engravings();
u.uroleplay.numbones++; u.uroleplay.numbones++;