teleport and topten globals moved to instance globals.

This commit is contained in:
Bart House
2018-12-25 18:30:48 -08:00
parent ed096f74c3
commit deb220c7c1
5 changed files with 34 additions and 27 deletions
+6
View File
@@ -1114,6 +1114,9 @@ struct instance_globals {
int spl_sortmode; /* index into spl_sortchoices[] */ int spl_sortmode; /* index into spl_sortchoices[] */
int *spl_orderindx; /* array of g.spl_book[] indices */ int *spl_orderindx; /* array of g.spl_book[] indices */
/* teleport.c */
struct obj *telescroll; /* non-null when teleporting via this scroll */
/* timeout.c */ /* timeout.c */
/* ordered timer list */ /* ordered timer list */
struct fe *timer_base; /* "active" */ struct fe *timer_base; /* "active" */
@@ -1121,6 +1124,9 @@ struct instance_globals {
/* topten.c */ /* topten.c */
winid toptenwin; winid toptenwin;
#ifdef UPDATE_RECORD_IN_PLACE
long final_fpos;
#endif
/* trap.c */ /* trap.c */
+6
View File
@@ -635,12 +635,18 @@ const struct instance_globals g_init = {
0, /* spl_sortmode */ 0, /* spl_sortmode */
NULL, /* spl_orderindx */ NULL, /* spl_orderindx */
/* teleport.c */
NULL, /* telescroll */
/* timeout.c */ /* timeout.c */
UNDEFINED_PTR, /* timer_base */ UNDEFINED_PTR, /* timer_base */
1, /* timer_id */ 1, /* timer_id */
/* topten.c */ /* topten.c */
WIN_ERR, /* topten */ WIN_ERR, /* topten */
#ifdef UPDATE_RECORD_IN_PLACE
UNDEFINED_VALUE, /* final_fpos */
#endif
/* trap.c */ /* trap.c */
0, /* force_mintrap */ 0, /* force_mintrap */
+7 -10
View File
@@ -11,9 +11,6 @@ STATIC_DCL void NDECL(vault_tele);
STATIC_DCL boolean FDECL(rloc_pos_ok, (int, int, struct monst *)); STATIC_DCL boolean FDECL(rloc_pos_ok, (int, int, struct monst *));
STATIC_DCL void FDECL(mvault_tele, (struct monst *)); STATIC_DCL void FDECL(mvault_tele, (struct monst *));
/* non-null when teleporting via having read this scroll */
STATIC_VAR struct obj *telescroll = 0;
/* /*
* Is (x,y) a good position of mtmp? If mtmp is NULL, then is (x,y) good * Is (x,y) a good position of mtmp? If mtmp is NULL, then is (x,y) good
* for an object? * for an object?
@@ -345,14 +342,14 @@ boolean allow_drag;
been updated for new location instead of right after u_on_newpos() */ been updated for new location instead of right after u_on_newpos() */
if (levl[u.ux][u.uy].typ != levl[u.ux0][u.uy0].typ) if (levl[u.ux][u.uy].typ != levl[u.ux0][u.uy0].typ)
switch_terrain(); switch_terrain();
if (telescroll) { if (g.telescroll) {
/* when teleporting by scroll, we need to handle discovery /* when teleporting by scroll, we need to handle discovery
now before getting feedback about any objects at our now before getting feedback about any objects at our
destination since we might land on another such scroll */ destination since we might land on another such scroll */
if (distu(u.ux0, u.uy0) >= 16 || !couldsee(u.ux0, u.uy0)) if (distu(u.ux0, u.uy0) >= 16 || !couldsee(u.ux0, u.uy0))
learnscroll(telescroll); learnscroll(g.telescroll);
else else
telescroll = 0; /* no discovery by scrolltele()'s caller */ g.telescroll = 0; /* no discovery by scrolltele()'s caller */
} }
spoteffects(TRUE); spoteffects(TRUE);
invocation_message(); invocation_message();
@@ -486,13 +483,13 @@ struct obj *scroll;
result = TRUE; result = TRUE;
} }
telescroll = scroll; g.telescroll = scroll;
(void) safe_teleds(FALSE); (void) safe_teleds(FALSE);
/* teleds() will leave telescroll intact iff random destination /* teleds() will leave g.telescroll intact iff random destination
is far enough away for scroll discovery to be warranted */ is far enough away for scroll discovery to be warranted */
if (telescroll) if (g.telescroll)
result = TRUE; result = TRUE;
telescroll = 0; /* reset */ g.telescroll = 0; /* reset */
return result; return result;
} }
+2 -5
View File
@@ -23,9 +23,6 @@
* way to truncate it). The trailing junk is harmless and the code * way to truncate it). The trailing junk is harmless and the code
* which reads the scores will ignore it. * which reads the scores will ignore it.
*/ */
#ifdef UPDATE_RECORD_IN_PLACE
static long final_fpos;
#endif
#define done_stopprint g.program_state.stopprint #define done_stopprint g.program_state.stopprint
@@ -232,7 +229,7 @@ struct toptenentry *tt;
#ifdef UPDATE_RECORD_IN_PLACE #ifdef UPDATE_RECORD_IN_PLACE
/* note: input below must read the record's terminating newline */ /* note: input below must read the record's terminating newline */
final_fpos = tt->fpos = ftell(rfile); g.final_fpos = tt->fpos = ftell(rfile);
#endif #endif
#define TTFIELDS 13 #define TTFIELDS 13
if (fscanf(rfile, fmt, &tt->ver_major, &tt->ver_minor, &tt->patchlevel, if (fscanf(rfile, fmt, &tt->ver_major, &tt->ver_minor, &tt->patchlevel,
@@ -676,7 +673,7 @@ time_t when;
} }
if (flg) { /* rewrite record file */ if (flg) { /* rewrite record file */
#ifdef UPDATE_RECORD_IN_PLACE #ifdef UPDATE_RECORD_IN_PLACE
(void) fseek(rfile, (t0->fpos >= 0 ? t0->fpos : final_fpos), (void) fseek(rfile, (t0->fpos >= 0 ? t0->fpos : g.final_fpos),
SEEK_SET); SEEK_SET);
#else #else
(void) fclose(rfile); (void) fclose(rfile);
+13 -12
View File
@@ -23,7 +23,7 @@
* @...X +4 * @...X +4
* *
*/ */
char circle_data[] = { const char circle_data[] = {
/* 0*/ 1, 1, /* 0*/ 1, 1,
/* 2*/ 2, 2, 1, /* 2*/ 2, 2, 1,
/* 5*/ 3, 3, 2, 1, /* 5*/ 3, 3, 2, 1,
@@ -46,7 +46,7 @@ char circle_data[] = {
* These are the starting indexes into the circle_data[] array for a * These are the starting indexes into the circle_data[] array for a
* circle of a given radius. * circle of a given radius.
*/ */
char circle_start[] = { const char circle_start[] = {
/* */ 0, /* circles of radius zero are not used */ /* */ 0, /* circles of radius zero are not used */
/* 1*/ 0, /* 1*/ 0,
/* 2*/ 2, /* 2*/ 2,
@@ -496,7 +496,7 @@ int control;
char *old_row; /* row pointer for the old array */ char *old_row; /* row pointer for the old array */
char *next_rmin; /* min pointer for the new array */ char *next_rmin; /* min pointer for the new array */
char *next_rmax; /* max pointer for the new array */ char *next_rmax; /* max pointer for the new array */
char *ranges; /* circle ranges -- used for xray & night vision */ const char *ranges; /* circle ranges -- used for xray & night vision */
int row = 0; /* row counter (outer loop) */ int row = 0; /* row counter (outer loop) */
int start, stop; /* inner loop starting/stopping index */ int start, stop; /* inner loop starting/stopping index */
int dx, dy; /* one step from a lit door or lit wall (see below) */ int dx, dy; /* one step from a lit door or lit wall (see below) */
@@ -1602,8 +1602,9 @@ static close2d *close_dy[CLOSE_MAX_BC_DY];
static far2d *far_dy[FAR_MAX_BC_DY]; static far2d *far_dy[FAR_MAX_BC_DY];
STATIC_DCL void FDECL(right_side, (int, int, int, int, int, STATIC_DCL void FDECL(right_side, (int, int, int, int, int,
int, int, char *)); int, int, const char *));
STATIC_DCL void FDECL(left_side, (int, int, int, int, int, int, int, char *)); STATIC_DCL void FDECL(left_side, (int, int, int, int, int, int, int,
const char *));
STATIC_DCL int FDECL(close_shadow, (int, int, int, int)); STATIC_DCL int FDECL(close_shadow, (int, int, int, int));
STATIC_DCL int FDECL(far_shadow, (int, int, int, int)); STATIC_DCL int FDECL(far_shadow, (int, int, int, int));
@@ -1994,7 +1995,7 @@ int cb_row, cb_col; /* close block row and col */
int fb_row, fb_col; /* far block row and col */ int fb_row, fb_col; /* far block row and col */
int left_mark; /* left mark of previous row */ int left_mark; /* left mark of previous row */
int right; /* right mark of the previous row */ int right; /* right mark of the previous row */
char *limits; const char *limits;
{ {
register int i; register int i;
register char *rowp = NULL; register char *rowp = NULL;
@@ -2285,8 +2286,8 @@ genericptr_t arg;
/* /*
* Defines local to Algorithm C. * Defines local to Algorithm C.
*/ */
STATIC_DCL void FDECL(right_side, (int, int, int, char *)); STATIC_DCL void FDECL(right_side, (int, int, int, const char *));
STATIC_DCL void FDECL(left_side, (int, int, int, char *)); STATIC_DCL void FDECL(left_side, (int, int, int, const char *));
/* Initialize algorithm C (nothing). */ /* Initialize algorithm C (nothing). */
STATIC_OVL void STATIC_OVL void
@@ -2303,7 +2304,7 @@ right_side(row, left, right_mark, limits)
int row; /* current row */ int row; /* current row */
int left; /* first (left side) visible spot on prev row */ int left; /* first (left side) visible spot on prev row */
int right_mark; /* last (right side) visible spot on prev row */ int right_mark; /* last (right side) visible spot on prev row */
char *limits; /* points at range limit for current row, or NULL */ const char *limits; /* points at range limit for current row, or NULL */
{ {
int right; /* right limit of "could see" */ int right; /* right limit of "could see" */
int right_edge; /* right edge of an opening */ int right_edge; /* right edge of an opening */
@@ -2493,7 +2494,7 @@ char *limits; /* points at range limit for current row, or NULL */
STATIC_OVL void STATIC_OVL void
left_side(row, left_mark, right, limits) left_side(row, left_mark, right, limits)
int row, left_mark, right; int row, left_mark, right;
char *limits; const char *limits;
{ {
int left, left_edge, nrow, deeper, result; int left, left_edge, nrow, deeper, result;
register int i; register int i;
@@ -2641,7 +2642,7 @@ genericptr_t arg;
int nrow; /* the next row */ int nrow; /* the next row */
int left; /* the left-most visible column */ int left; /* the left-most visible column */
int right; /* the right-most visible column */ int right; /* the right-most visible column */
char *limits; /* range limit for next row */ const char *limits; /* range limit for next row */
/* Set globals for q?_path(), left_side(), and right_side() to use. */ /* Set globals for q?_path(), left_side(), and right_side() to use. */
start_col = scol; start_col = scol;
@@ -2745,7 +2746,7 @@ genericptr_t arg;
} else { } else {
register int x; register int x;
int y, min_x, max_x, max_y, offset; int y, min_x, max_x, max_y, offset;
char *limits; const char *limits;
boolean override_vision; boolean override_vision;
/* vision doesn't pass through water or clouds, detection should /* vision doesn't pass through water or clouds, detection should