avoid crash for X11 tombstone

If nethack is built to use graphical tombstone but file rip.xpm is
missing from the playground, there would be a crash if the rip output
was shown.  My first attempt to fix it prevented the crash but didn't
display any tombstone, just the last couple of lines of output which
follow the tombstone.  This keeps that in case of some other Xpm
failure, but checks for rip.xpm via stdio and reverts to genl_outrip
for text tombstone if it can't be opened.
This commit is contained in:
PatR
2019-03-12 13:31:00 -07:00
parent 44639ab1e8
commit 8e7fe38dae
3 changed files with 30 additions and 14 deletions
+11 -1
View File
@@ -1,4 +1,4 @@
/* NetHack 3.6 winX.c $NHDT-Date: 1546081304 2018/12/29 11:01:44 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.71 $ */
/* NetHack 3.6 winX.c $NHDT-Date: 1552422652 2019/03/12 20:30:52 $ $NHDT-Branch: NetHack-3.6.2-beta01 $:$NHDT-Revision: 1.72 $ */
/* Copyright (c) Dean Luick, 1992 */
/* NetHack may be freely redistributed. See license for details. */
@@ -1355,10 +1355,20 @@ int how;
time_t when;
{
struct xwindow *wp;
FILE *rip_fp;
check_winid(window);
wp = &window_list[window];
/* make sure the graphic_tombstone is available; it's not easy to
revert to ordinary text tombstone once we're past this point... */
rip_fp = fopen(appResources.tombstone, "r"); /* "rip.xpm" */
if (!rip_fp) {
genl_outrip(window, how, when);
return;
}
(void) fclose(rip_fp);
if (wp->type == NHW_TEXT) {
wp->text_information->is_rip = TRUE;
} else {