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....
This commit is contained in:
nethack.rankin
2012-01-24 04:26:33 +00:00
parent 9721470635
commit a871ad06e9
19 changed files with 80 additions and 172 deletions

10
include/.gitignore vendored
View File

@@ -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

View File

@@ -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:

View File

@@ -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 *));

View File

@@ -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

View File

@@ -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

View File

@@ -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

View File

@@ -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;

View File

@@ -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<YEAR_LINE; line++)
@@ -255,7 +227,8 @@ int how;
}
/* Put year on stone */
Sprintf(buf, "%4d", getyear());
year = yyyymmdd(when) / 10000L;
Sprintf(buf, "%4ld", year);
tomb_text(buf);
#ifdef NH320_DEDICATION
@@ -316,7 +289,7 @@ cleanup:
if(tbmp[0])FreeImageFiles(load_list, tbmp);
if(just_return) return;
/* fall back to the straight-ASCII version */
genl_outrip(tmpwin, how);
genl_outrip(tmpwin, how, when);
}
static void tomb_text(p)

View File

@@ -1,5 +1,4 @@
/* NetHack 3.5 winproto.h $Date$ $Revision$ */
/* SCCS Id: @(#)winproto.h 3.5 1996/01/15 */
/* Copyright (c) Gregg Wonderly, Naperville, Illinois, 1991,1992,1993. */
/* NetHack may be freely redistributed. See license for details. */
@@ -140,7 +139,7 @@ void Abort ( long rc );
#endif
/* amirip.c */
void FDECL(amii_outrip, ( winid tmpwin, int how ));
void FDECL(amii_outrip, ( winid tmpwin, int how, time_t when ));
/* winchar.c */
void SetMazeType(MazeType);

View File

@@ -1564,21 +1564,20 @@ void mswin_end_screen()
}
/*
outrip(winid, int)
outrip(winid, int, when)
-- The tombstone code. If you want the traditional code use
genl_outrip for the value and check the #if in rip.c.
*/
void mswin_outrip(winid wid, int how)
void mswin_outrip(winid wid, int how, time_t when)
{
logDebug("mswin_outrip(%d)\n", wid, how);
logDebug("mswin_outrip(%d, %d, %ld)\n", wid, how, (long)when);
if ((wid >= 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 */

View File

@@ -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 */

View File

@@ -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; line<YEAR_LINE; line++) {
@@ -3346,7 +3332,8 @@ static char** rip_line=0;
}
/* Put year on stone */
Sprintf(rip_line[YEAR_LINE], "%4d", getyear());
year = yyyymmdd(when) / 10000L;
Sprintf(rip_line[YEAR_LINE], "%4ld", year);
rip.setLines(rip_line,YEAR_LINE+1);
@@ -5156,11 +5143,11 @@ void NetHackQtBind::qt_end_screen()
// Ignore.
}
void NetHackQtBind::qt_outrip(winid wid, int how)
void NetHackQtBind::qt_outrip(winid wid, int how, time_t when)
{
NetHackQtWindow* window=id_to_window[wid];
window->UseRIP(how);
window->UseRIP(how, when);
}
bool NetHackQtBind::notify(QObject *receiver, QEvent *event)

View File

@@ -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

View File

@@ -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<YEAR_LINE; line++) {
@@ -511,7 +497,8 @@ calculate_rip_text(int how)
}
/* Put year on stone */
Sprintf(rip_line[YEAR_LINE], "%4d", getyear());
year = yyyymmdd(when) / 10000L;
Sprintf(rip_line[YEAR_LINE], "%4ld", year);
}

View File

@@ -33,7 +33,7 @@ extern void mar_set_tiley(int);
extern short glyph2tile[MAX_GLYPH]; /* from tile.c */
extern void mar_display_nhwindow(winid); /* from wingem1.c */
void Gem_outrip(winid,int);
void Gem_outrip(winid,int,time_t);
void Gem_preference_update(const char *);
/* Interface definition, for windows.c */
struct window_procs Gem_procs = {
@@ -1063,11 +1063,12 @@ char *posbar;
/** Gem_outrip **/
void mar_set_text_to_rip(winid);
char** rip_line=0;
extern const char *killed_by_prefix[];
void
Gem_outrip(w, how)
Gem_outrip(w, how, when)
winid w;
int how;
time_t when;
{
/* Code from X11 windowport */
#define STONE_LINE_LEN 15 /* # chars that fit on one line */
@@ -1078,6 +1079,8 @@ int how;
char buf[BUFSZ];
char *dpx;
int line;
long year;
if (!rip_line) {
int i;
rip_line= (char **)malloc((YEAR_LINE+1)*sizeof(char *));
@@ -1096,20 +1099,8 @@ 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<YEAR_LINE; line++) {
register int i,i0;
@@ -1129,7 +1120,9 @@ int how;
} else dpx= &dpx[i0+1];
}
/* Put year on stone */
Sprintf(rip_line[YEAR_LINE], "%4d", getyear());
year = yyyymmdd(when) / 10000L;
Sprintf(rip_line[YEAR_LINE], "%4ld", year);
mar_set_text_to_rip(w);
for(line=0;line<13;line++)
putstr(w, 0, "");

View File

@@ -1166,16 +1166,16 @@ void gnome_end_screen()
}
/*
outrip(winid, int)
outrip(winid, int, when)
-- The tombstone code. If you want the traditional code use
genl_outrip for the value and check the #if in rip.c.
*/
void gnome_outrip(winid wid, int how)
void gnome_outrip(winid wid, int how, time_t when)
{
/* Follows roughly the same algorithm as genl_outrip() */
char buf[BUFSZ];
char ripString[BUFSZ]="\0";
extern const char *killed_by_prefix[];
long year;
/* Put name on stone */
Sprintf(buf, "%s\n", plname);
@@ -1191,26 +1191,15 @@ void gnome_outrip(winid wid, int how)
Strcat(ripString, 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 */
Strcat(ripString, buf);
Strcat(ripString, "\n");
/* Put year on stone */
Sprintf(buf, "%4d\n", getyear());
year = yyyymmdd(when) / 10000L;
Sprintf(buf, "%4ld\n", year);
Strcat(ripString, buf);
ghack_text_window_rip_string( ripString);

View File

@@ -86,7 +86,7 @@ void gnome_number_pad(int state);
void gnome_delay_output(void);
void gnome_start_screen(void);
void gnome_end_screen(void);
void gnome_outrip(winid wid, int how);
void gnome_outrip(winid wid, int how, time_t when);
void gnome_delete_nhwindow_by_reference( GtkWidget *menuWin);

View File

@@ -28,7 +28,6 @@
#define LLEN 128
extern const char *killed_by_prefix[];
extern winid WIN_STATUS;
#ifdef _DEBUG
@@ -1774,16 +1773,17 @@ void mswin_end_screen()
}
/*
outrip(winid, int)
outrip(winid, int, when)
-- The tombstone code. If you want the traditional code use
genl_outrip for the value and check the #if in rip.c.
*/
#define STONE_LINE_LEN 16
void mswin_outrip(winid wid, int how)
void mswin_outrip(winid wid, int how, time_t when)
{
char buf[BUFSZ];
long year;
logDebug("mswin_outrip(%d)\n", wid, how);
logDebug("mswin_outrip(%d, %d, %ld)\n", wid, how, (long)when);
if ((wid >= 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);
}

View File

@@ -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);