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:
@@ -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)
|
||||
|
||||
@@ -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
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@@ -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, "");
|
||||
|
||||
@@ -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);
|
||||
|
||||
@@ -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);
|
||||
|
||||
|
||||
|
||||
@@ -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);
|
||||
}
|
||||
|
||||
@@ -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);
|
||||
|
||||
Reference in New Issue
Block a user