debug mode #wizrumorcheck
Provide a command to easily verify that the rumor true/false boundary offsets are correct for the rumors file. If the boundary is pointing mid-line, the rumor at the boundary won't decrypt properly.
This commit is contained in:
@@ -1877,6 +1877,9 @@ E void FDECL(outoracle, (BOOLEAN_P, BOOLEAN_P));
|
|||||||
E void FDECL(save_oracles, (int,int));
|
E void FDECL(save_oracles, (int,int));
|
||||||
E void FDECL(restore_oracles, (int));
|
E void FDECL(restore_oracles, (int));
|
||||||
E int FDECL(doconsult, (struct monst *));
|
E int FDECL(doconsult, (struct monst *));
|
||||||
|
#ifdef WIZARD
|
||||||
|
E void NDECL(rumor_check);
|
||||||
|
#endif
|
||||||
|
|
||||||
/* ### save.c ### */
|
/* ### save.c ### */
|
||||||
|
|
||||||
|
|||||||
@@ -149,6 +149,7 @@ STATIC_PTR int NDECL(wiz_show_stats);
|
|||||||
# ifdef PORT_DEBUG
|
# ifdef PORT_DEBUG
|
||||||
STATIC_DCL int NDECL(wiz_port_debug);
|
STATIC_DCL int NDECL(wiz_port_debug);
|
||||||
# endif
|
# endif
|
||||||
|
STATIC_PTR int NDECL(wiz_rumor_check);
|
||||||
# endif
|
# endif
|
||||||
STATIC_PTR int NDECL(enter_explore_mode);
|
STATIC_PTR int NDECL(enter_explore_mode);
|
||||||
STATIC_PTR int NDECL(doattributes);
|
STATIC_PTR int NDECL(doattributes);
|
||||||
@@ -942,6 +943,14 @@ wiz_smell()
|
|||||||
} while (TRUE);
|
} while (TRUE);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* #wizrumorcheck command - verify each rumor access */
|
||||||
|
STATIC_PTR int
|
||||||
|
wiz_rumor_check()
|
||||||
|
{
|
||||||
|
rumor_check();
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
#endif /* WIZARD */
|
#endif /* WIZARD */
|
||||||
|
|
||||||
|
|
||||||
@@ -1754,6 +1763,7 @@ struct ext_func_tab extcmdlist[] = {
|
|||||||
{(char *)0, (char *)0, donull, TRUE},
|
{(char *)0, (char *)0, donull, TRUE},
|
||||||
#endif
|
#endif
|
||||||
{(char *)0, (char *)0, donull, TRUE},
|
{(char *)0, (char *)0, donull, TRUE},
|
||||||
|
{(char *)0, (char *)0, donull, TRUE},
|
||||||
#endif
|
#endif
|
||||||
{(char *)0, (char *)0, donull, TRUE} /* sentinel */
|
{(char *)0, (char *)0, donull, TRUE} /* sentinel */
|
||||||
};
|
};
|
||||||
@@ -1780,6 +1790,7 @@ static const struct ext_func_tab debug_extcmdlist[] = {
|
|||||||
#ifdef DEBUG
|
#ifdef DEBUG
|
||||||
{"wizdebug", "wizard debug command", wiz_debug_cmd, TRUE},
|
{"wizdebug", "wizard debug command", wiz_debug_cmd, TRUE},
|
||||||
#endif
|
#endif
|
||||||
|
{"wizrumorcheck", "verify rumor boundaries", wiz_rumor_check, TRUE},
|
||||||
{"wmode", "show wall modes", wiz_show_wmodes, TRUE},
|
{"wmode", "show wall modes", wiz_show_wmodes, TRUE},
|
||||||
{(char *)0, (char *)0, donull, TRUE}
|
{(char *)0, (char *)0, donull, TRUE}
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -134,6 +134,66 @@ boolean exclude_cookie;
|
|||||||
return rumor_buf;
|
return rumor_buf;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#ifdef WIZARD
|
||||||
|
/*
|
||||||
|
* test that the true/false rumor boundaries are valid.
|
||||||
|
*/
|
||||||
|
void
|
||||||
|
rumor_check()
|
||||||
|
{
|
||||||
|
dlb *rumors;
|
||||||
|
winid tmpwin;
|
||||||
|
char *endp, line[BUFSZ], xbuf[BUFSZ], rumor_buf[BUFSZ];
|
||||||
|
|
||||||
|
if (true_rumor_size < 0L) /* we couldn't open RUMORFILE */
|
||||||
|
return;
|
||||||
|
|
||||||
|
rumors = dlb_fopen(RUMORFILE, "r");
|
||||||
|
|
||||||
|
if (rumors) {
|
||||||
|
long rumor_start = 0L;
|
||||||
|
rumor_buf[0] = '\0';
|
||||||
|
if (true_rumor_size == 0L) { /* if this is 1st outrumor() */
|
||||||
|
init_rumors(rumors);
|
||||||
|
if (true_rumor_size < 0L) /* init failed */
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
tmpwin = create_nhwindow(NHW_TEXT);
|
||||||
|
/*
|
||||||
|
* check the first rumor (start of true rumors) by
|
||||||
|
* skipping the first two lines.
|
||||||
|
*
|
||||||
|
* Then seek to the start of the false rumors (based on
|
||||||
|
* the value read in rumors, and display it.
|
||||||
|
*/
|
||||||
|
rumor_buf[0] = '\0';
|
||||||
|
(void) dlb_fseek(rumors, true_rumor_start, SEEK_SET);
|
||||||
|
rumor_start = dlb_ftell(rumors);
|
||||||
|
(void) dlb_fgets(line, sizeof line, rumors);
|
||||||
|
if ((endp = index(line, '\n')) != 0) *endp = 0;
|
||||||
|
Sprintf(rumor_buf, "T %06ld %s", rumor_start,
|
||||||
|
xcrypt(line, xbuf));
|
||||||
|
putstr(tmpwin, 0, rumor_buf);
|
||||||
|
|
||||||
|
rumor_buf[0] = '\0';
|
||||||
|
(void) dlb_fseek(rumors, false_rumor_start, SEEK_SET);
|
||||||
|
rumor_start = dlb_ftell(rumors);
|
||||||
|
(void) dlb_fgets(line, sizeof line, rumors);
|
||||||
|
if ((endp = index(line, '\n')) != 0) *endp = 0;
|
||||||
|
Sprintf(rumor_buf, "F %06ld %s", rumor_start,
|
||||||
|
xcrypt(line, xbuf));
|
||||||
|
putstr(tmpwin, 0, rumor_buf);
|
||||||
|
|
||||||
|
(void) dlb_fclose(rumors);
|
||||||
|
display_nhwindow(tmpwin, TRUE);
|
||||||
|
destroy_nhwindow(tmpwin);
|
||||||
|
} else {
|
||||||
|
impossible("Can't open rumors file!");
|
||||||
|
true_rumor_size = -1; /* don't try to open it again */
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
void
|
void
|
||||||
outrumor(truth, mechanism)
|
outrumor(truth, mechanism)
|
||||||
int truth; /* 1=true, -1=false, 0=either */
|
int truth; /* 1=true, -1=false, 0=either */
|
||||||
|
|||||||
Reference in New Issue
Block a user