From: nethack.rankin Date: Tue, 24 Jan 2012 04:26:33 +0000 (+0000) Subject: outrip() updating (trunk only) X-Git-Tag: MOVE2GIT~69 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=a871ad06e96bec4ad2dd24dd2fa3ea5ed9c08137;p=nethack outrip() updating (trunk only) Part II of the bones tracking patch. Change umpteen different outrip() routines to handle its new time_t argument, and use formatkiller() instead of directly accessing killer.{format,name} and killed_by_prefix[]. The latter is now static within formatkiller(). The many sys/* and win/* changes are untested.... --- diff --git a/include/.gitignore b/include/.gitignore index fa846a3ac..5bae20a5f 100644 --- a/include/.gitignore +++ b/include/.gitignore @@ -1,7 +1,3 @@ -pm.h -vis_tab.h -onames.h -date.h -dgn_comp.h -tile.h -lev_comp.h +.cvsignore +date.h onames.h pm.h vis_tab.h +dgn_comp.h lev_comp.h diff --git a/include/qt_win.h b/include/qt_win.h index 58085745d..f430ff25b 100644 --- a/include/qt_win.h +++ b/include/qt_win.h @@ -1,5 +1,4 @@ // NetHack 3.5 qt_win.h $Date$ $Revision$ -// SCCS Id: @(#)qt_win.h 3.5 1999/11/19 // Copyright (c) Warwick Allison, 1999. // NetHack may be freely redistributed. See license for details. // @@ -256,7 +255,7 @@ public: virtual int SelectMenu(int how, MENU_ITEM_P **menu_list); virtual void ClipAround(int x,int y); virtual void PrintGlyph(int x,int y,int glyph); - virtual void UseRIP(int how); + virtual void UseRIP(int how, time_t when); int nhid; }; @@ -621,7 +620,7 @@ public: virtual bool Destroy(); virtual void Display(bool block); virtual void PutStr(int attr, const char* text); - virtual void UseRIP(int how); + virtual void UseRIP(int how, time_t when); public slots: void Search(); @@ -839,7 +838,7 @@ public: static void qt_start_screen(); static void qt_end_screen(); - static void qt_outrip(winid wid, int how); + static void qt_outrip(winid wid, int how, time_t when); static int qt_kbhit(); private: diff --git a/include/winX.h b/include/winX.h index 0dc6034be..9ceea5fee 100644 --- a/include/winX.h +++ b/include/winX.h @@ -349,7 +349,7 @@ E void FDECL(init_text_buffer,(struct text_buffer*)); E void FDECL(clear_text_buffer,(struct text_buffer*)); E void FDECL(free_text_buffer,(struct text_buffer*)); #ifdef GRAPHIC_TOMBSTONE -E void FDECL(calculate_rip_text, (int)); +E void FDECL(calculate_rip_text, (int,time_t)); #endif @@ -408,9 +408,9 @@ E void NDECL(X11_start_screen); E void NDECL(X11_end_screen); #ifdef GRAPHIC_TOMBSTONE -E void FDECL(X11_outrip, (winid,int)); +E void FDECL(X11_outrip, (winid,int,time_t)); #else -E void FDECL(genl_outrip, (winid,int)); +E void FDECL(genl_outrip, (winid,int,time_t)); #endif E void FDECL(X11_preference_update, (const char *)); diff --git a/include/wingem.h b/include/wingem.h index 616f38826..7eb57b6ff 100644 --- a/include/wingem.h +++ b/include/wingem.h @@ -105,7 +105,7 @@ E char * NDECL(Gem_get_color_string); E void NDECL(Gem_start_screen); E void NDECL(Gem_end_screen); -E void FDECL(genl_outrip, (winid,int)); +E void FDECL(genl_outrip, (winid,int,time_t)); #undef E diff --git a/src/end.c b/src/end.c index f6487cb84..332a6277a 100644 --- a/src/end.c +++ b/src/end.c @@ -283,8 +283,6 @@ static NEARDATA const char *ends[] = { /* "when you..." */ static boolean Schroedingers_cat = FALSE; -extern const char * const killed_by_prefix[]; /* from topten.c */ - /*ARGSUSED*/ void done1(sig_unused) /* called as signal() handler, so sent at least one arg */ @@ -956,12 +954,9 @@ die: urace.femalenum : urace.malenum; } corpse = mk_named_object(CORPSE, &mons[mnum], - u.ux, u.uy, plname); - Sprintf(pbuf, "%s, %s%s", plname, - killer.format == NO_KILLER_PREFIX ? "" : - killed_by_prefix[how], - killer.format == KILLED_BY_AN ? an(killer.name) : - killer.name); + u.ux, u.uy, plname); + Sprintf(pbuf, "%s, ", plname); + formatkiller(eos(pbuf), sizeof pbuf - strlen(pbuf), how); make_grave(u.ux, u.uy, pbuf); } /* if pets will contribute to score, populate mydogs list now diff --git a/src/rip.c b/src/rip.c index 1fe094d84..1e39b2377 100644 --- a/src/rip.c +++ b/src/rip.c @@ -6,8 +6,6 @@ STATIC_DCL void FDECL(center, (int, char *)); -extern const char * const killed_by_prefix[]; /* from topten.c */ - #if defined(TTY_GRAPHICS) || defined(X11_GRAPHICS) || defined(GEM_GRAPHICS) || defined(MSWIN_GRAPHICS) # define TEXT_TOMBSTONE #endif diff --git a/src/topten.c b/src/topten.c index 3d0f56668..a2d205803 100644 --- a/src/topten.c +++ b/src/topten.c @@ -73,12 +73,6 @@ STATIC_DCL void FDECL(nsb_mung_line,(char*)); STATIC_DCL void FDECL(nsb_unmung_line,(char*)); #endif -/* must fit with end.c; used in rip.c */ -NEARDATA const char * const killed_by_prefix[] = { - "killed by ", "choked on ", "poisoned by ", "died of ", "drowned in ", - "burned by ", "dissolved in ", "crushed to death by ", "petrified by ", - "turned to slime by ", "killed by ", "", "", "", "", "" -}; static winid toptenwin = WIN_ERR; @@ -89,6 +83,16 @@ char *buf; unsigned siz; int how; { + static NEARDATA const char * const killed_by_prefix[] = { + /* DIED, CHOKING, POISONING, STARVING, */ + "killed by ", "choked on ", "poisoned by ", "died of ", + /* DROWNING, BURNING, DISSOLVED, CRUSHING, */ + "drowned in ", "burned by ", "dissolved in ", "crushed to death by ", + /* STONING, TURNED_SLIME, GENOCIDED, */ + "petrified by ", "turned to slime by ", "killed by ", + /* PANICKED, TRICKED, QUIT, ESCAPED, ASCENDED */ + "", "", "", "", "" + }; unsigned l; char *kname = killer.name; diff --git a/sys/amiga/amirip.c b/sys/amiga/amirip.c index 41875dd38..a7460258d 100644 --- a/sys/amiga/amirip.c +++ b/sys/amiga/amirip.c @@ -1,5 +1,4 @@ /* NetHack 3.5 amirip.c $Date$ $Revision$ */ -/* SCCS Id: @(#)amirip.c 3.5 1996/02/04 */ /* Copyright (c) Kenneth Lorber, Bethesda, Maryland 1991,1992,1993,1995,1996. */ /* NetHack may be freely redistributed. See license for details. */ @@ -68,7 +67,6 @@ static xoff, yoff; /* image centering */ # endif #endif /* AZTEC_C */ -extern char *killed_by_prefix[]; static struct Window *ripwin=0; static void tomb_text(char*); static void dofade(int,int,int); @@ -101,9 +99,10 @@ int wh; /* was local in outrip, but needed for SCALE macro */ int cmap_white, cmap_black; void -amii_outrip( tmpwin, how ) +amii_outrip( tmpwin, how, when ) winid tmpwin; int how; +time_t when; { int just_return = 0; int done, rtxth; @@ -113,6 +112,7 @@ int how; char buf[ 200 ]; int line, tw, ww; char *errstr = NULL; + long year; if(!WINVERS_AMIV || HackScreen->RastPort.BitMap->Depth < 4)goto cleanup; @@ -153,21 +153,7 @@ int how; BltBitMap(*tbmp, 0, 0, rp->BitMap, xoff, yoff, tomb_bmhd.w, tomb_bmhd.h, 0xc0, 0xff, NULL); /* Put together death description */ - switch (killer.format) { - default: - impossible("bad killer format?"); - case KILLED_BY_AN: - Strcpy(buf, killed_by_prefix[how]); - Strcat(buf, an(killer.name)); - break; - case KILLED_BY: - Strcpy(buf, killed_by_prefix[how]); - Strcat(buf, killer.name); - break; - case NO_KILLER_PREFIX: - Strcpy(buf, killer.name); - break; - } + formatkiller(buf, sizeof buf, how); tw = TextLength(rp,buf,STONE_LINE_LEN) + 40; @@ -206,21 +192,7 @@ int how; tomb_text(buf); /* Put together death description */ - switch (killer.format) { - default: - impossible("bad killer format?"); - case KILLED_BY_AN: - Strcpy(buf, killed_by_prefix[how]); - Strcat(buf, an(killer.name)); - break; - case KILLED_BY: - Strcpy(buf, killed_by_prefix[how]); - Strcat(buf, killer.name); - break; - case NO_KILLER_PREFIX: - Strcpy(buf, killer.name); - break; - } + formatkiller(buf, sizeof buf, how); /* Put death type on stone */ for (line=DEATH_LINE, dpx = buf; line= 0) && (wid < MAXWINDOWS) ) { DestroyWindow(GetNHApp()->windowlist[wid].win); GetNHApp()->windowlist[wid].win = mswin_init_RIP_window(); GetNHApp()->windowlist[wid].type = NHW_RIP; GetNHApp()->windowlist[wid].dead = 0; } - - genl_outrip(wid, how); + genl_outrip(wid, how, when); } /* handle options updates here */ diff --git a/sys/wince/winMS.h b/sys/wince/winMS.h index 4d85c4467..c8df31219 100644 --- a/sys/wince/winMS.h +++ b/sys/wince/winMS.h @@ -154,7 +154,7 @@ void mswin_change_color(void); char *mswin_get_color_string(void); void mswin_start_screen(void); void mswin_end_screen(void); -void mswin_outrip(winid wid, int how); +void mswin_outrip(winid wid, int how, time_t when); void mswin_preference_update(const char *pref); /* helper function */ diff --git a/win/Qt/qt_win.cpp b/win/Qt/qt_win.cpp index 4de493903..8a4b6ee83 100644 --- a/win/Qt/qt_win.cpp +++ b/win/Qt/qt_win.cpp @@ -1,5 +1,4 @@ // NetHack 3.5 qt_win.cpp $Date$ $Revision$ -// SCCS Id: @(#)qt_win.cpp 3.5 2005/11/19 // Copyright (c) Warwick Allison, 1999. // NetHack may be freely redistributed. See license for details. @@ -205,7 +204,6 @@ int qt_compact_mode = 0; #endif extern const char *enc_stat[]; /* from botl.c */ extern const char *hu_stat[]; /* from eat.c */ -extern const char *killed_by_prefix[]; extern int total_tiles_used; // from tile.c extern short glyph2tile[]; // from tile.c } @@ -1453,7 +1451,7 @@ int NetHackQtWindow::SelectMenu(int how, MENU_ITEM_P **menu_list) { puts("unexpe void NetHackQtWindow::ClipAround(int x,int y) { puts("unexpected ClipAround"); } void NetHackQtWindow::PrintGlyph(int x,int y,int glyph) { puts("unexpected PrintGlyph"); } //void NetHackQtWindow::PrintGlyphCompose(int x,int y,int,int) { puts("unexpected PrintGlyphCompose"); } -void NetHackQtWindow::UseRIP(int how) { puts("unexpected UseRIP"); } +void NetHackQtWindow::UseRIP(int how, time_t when) { puts("unexpected UseRIP"); } @@ -3276,7 +3274,7 @@ bool NetHackQtTextWindow::Destroy() return !isVisible(); } -void NetHackQtTextWindow::UseRIP(int how) +void NetHackQtTextWindow::UseRIP(int how, time_t when) { // Code from X11 windowport #define STONE_LINE_LEN 16 /* # chars that fit on one line */ @@ -3298,6 +3296,7 @@ static char** rip_line=0; char buf[BUFSZ]; char *dpx; int line; + long year; /* Put name on stone */ Sprintf(rip_line[NAME_LINE], "%s", plname); @@ -3310,20 +3309,7 @@ static char** rip_line=0; #endif /* Put together death description */ - switch (killer.format) { - default: impossible("bad killer format?"); - case KILLED_BY_AN: - Strcpy(buf, killed_by_prefix[how]); - Strcat(buf, an(killer.name)); - break; - case KILLED_BY: - Strcpy(buf, killed_by_prefix[how]); - Strcat(buf, killer.name); - break; - case NO_KILLER_PREFIX: - Strcpy(buf, killer.name); - break; - } + formatkiller(buf, sizeof buf, how); /* Put death type on stone */ for (line=DEATH_LINE, dpx = buf; lineUseRIP(how); + window->UseRIP(how, when); } bool NetHackQtBind::notify(QObject *receiver, QEvent *event) diff --git a/win/X11/winX.c b/win/X11/winX.c index dbc8d9f98..b3425f1e9 100644 --- a/win/X11/winX.c +++ b/win/X11/winX.c @@ -896,9 +896,10 @@ void X11_start_screen() { return; } /* called from setftty() in unixtty.c */ void X11_end_screen() { return; } /* called from settty() in unixtty.c */ #ifdef GRAPHIC_TOMBSTONE -void X11_outrip(window, how) +void X11_outrip(window, how, when) winid window; int how; + time_t when; { struct xwindow *wp; @@ -911,7 +912,7 @@ void X11_outrip(window, how) panic("ripout on non-text window (window type [%d])", wp->type); } - calculate_rip_text(how); + calculate_rip_text(how, when); } #endif diff --git a/win/X11/wintext.c b/win/X11/wintext.c index 0d74f960f..1af4e3d57 100644 --- a/win/X11/wintext.c +++ b/win/X11/wintext.c @@ -453,16 +453,15 @@ static XImage* rip_image=0; static char rip_line[YEAR_LINE+1][STONE_LINE_LEN+1]; -extern const char *killed_by_prefix[]; - void -calculate_rip_text(int how) +calculate_rip_text(int how, time_t when) { /* Follows same algorithm as genl_outrip() */ char buf[BUFSZ]; char *dpx; int line; + long year; /* Put name on stone */ Sprintf(rip_line[NAME_LINE], "%s", plname); @@ -475,20 +474,7 @@ calculate_rip_text(int how) done_money); #endif /* Put together death description */ - switch (killer.format) { - default: impossible("bad killer format?"); - case KILLED_BY_AN: - Strcpy(buf, killed_by_prefix[how]); - Strcat(buf, an(killer.name)); - break; - case KILLED_BY: - Strcpy(buf, killed_by_prefix[how]); - Strcat(buf, killer.name); - break; - case NO_KILLER_PREFIX: - Strcpy(buf, killer.name); - break; - } + formatkiller(buf, sizeof buf, how); /* Put death type on stone */ for (line=DEATH_LINE, dpx = buf; line= 0) && (wid < MAXWINDOWS) ) { DestroyWindow(GetNHApp()->windowlist[wid].win); GetNHApp()->windowlist[wid].win = mswin_init_RIP_window(); @@ -1806,26 +1806,14 @@ void mswin_outrip(winid wid, int how) putstr(wid, 0, buf); /* Put together death description */ - switch (killer.format) { - default: impossible("bad killer format?"); - case KILLED_BY_AN: - Strcpy(buf, killed_by_prefix[how]); - Strcat(buf, an(killer.name)); - break; - case KILLED_BY: - Strcpy(buf, killed_by_prefix[how]); - Strcat(buf, killer.name); - break; - case NO_KILLER_PREFIX: - Strcpy(buf, killer.name); - break; - } + formatkiller(buf, sizeof buf, how); /* Put death type on stone */ putstr(wid, 0, buf); /* Put year on stone */ - Sprintf(buf, "%4d", getyear()); + year = yyyymmdd(when) / 10000L; + Sprintf(buf, "%4ld", year); putstr(wid, 0, buf); mswin_finish_rip_text(wid); } diff --git a/win/win32/winMS.h b/win/win32/winMS.h index 50295afb5..1e1352670 100644 --- a/win/win32/winMS.h +++ b/win/win32/winMS.h @@ -158,7 +158,7 @@ void mswin_change_color(void); char *mswin_get_color_string(void); void mswin_start_screen(void); void mswin_end_screen(void); -void mswin_outrip(winid wid, int how); +void mswin_outrip(winid wid, int how, time_t when); void mswin_preference_update(const char *pref); char *mswin_getmsghistory(BOOLEAN_P init); void mswin_putmsghistory(const char * msg,BOOLEAN_P);