Moved more globals to instance_globals.

This commit is contained in:
Bart House
2018-11-24 02:13:54 -08:00
parent 471224ea70
commit 40b682ecf6
37 changed files with 987 additions and 869 deletions

View File

@@ -37,8 +37,6 @@ E NEARDATA int nroom;
E NEARDATA int nsubroom;
E NEARDATA int occtime;
#define WARNCOUNT 6 /* number of different warning levels */
E nhsym warnsyms[WARNCOUNT];
E NEARDATA int warn_obj_cnt; /* count of monsters meeting criteria */
E int x_maze_max, y_maze_max;
@@ -514,12 +512,47 @@ struct cmd {
char spkeys[NUM_NHKF];
};
#define ENTITIES 2
struct entity {
struct monst *emon; /* youmonst for the player */
struct permonst *edata; /* must be non-zero for record to be valid */
int ex, ey;
};
/* these probably ought to be generated by makedefs, like LAST_GEM */
#define FIRST_GEM DILITHIUM_CRYSTAL
#define FIRST_AMULET AMULET_OF_ESP
#define LAST_AMULET AMULET_OF_YENDOR
struct valuable_data {
long count;
int typ;
};
struct val_list {
struct valuable_data *list;
int size;
};
/* at most one of `door' and `box' should be non-null at any given time */
struct xlock_s {
struct rm *door;
struct obj *box;
int picktyp, /* key|pick|card for unlock, sharp vs blunt for #force */
chance, usedtime;
boolean magic_key;
};
/* instance_globals holds engine state that does not need to be
* persisted upon game exit. The initialization state is well defined
* an set in decl.c during early early engine initialization.
*
* unlike instance_flags, values in the structure can be of any type. */
#define BSIZE 20
struct instance_globals {
/* apply.c */
@@ -540,9 +573,85 @@ struct instance_globals {
/* cmd.c */
struct cmd Cmd; /* flag.h */
/* Provide a means to redo the last command. The flag `in_doagain' is set
* to true while redoing the command. This flag is tested in commands that
* require additional input (like `throw' which requires a thing and a
* direction), and the input prompt is not shown. Also, while in_doagain is
* TRUE, no keystrokes can be saved into the saveq.
*/
char pushq[BSIZE];
char saveq[BSIZE];
int phead;
int ptail;
int shead;
int stail;
coord clicklook_cc;
winid en_win;
boolean en_via_menu;
/* dbridge.c */
struct entity occupants[ENTITIES];
/* dig.c */
boolean did_dig_msg;
/* do.c */
boolean at_ladder;
char *dfr_pre_msg; /* pline() before level change */
char *dfr_post_msg; /* pline() after level change */
d_level save_dlevel;
/* do_name.c */
struct opvar *gloc_filter_map;
int gloc_filter_floodfill_match_glyph;
int via_naming;
/* dog.c */
int petname_used; /* user preferred pet name has been used */
xchar gtyp; /* type of dog's current goal */
xchar gx; /* x position of dog's current goal */
char gy; /* y position of dog's current goal */
/* dokick.c */
struct rm *maploc;
struct rm nowhere;
const char *gate_str;
/* drawing */
struct symsetentry symset[NUM_GRAPHICS];
int currentgraphics;
nhsym showsyms[SYM_MAX]; /* symbols to be displayed */
nhsym l_syms[SYM_MAX]; /* loaded symbols */
nhsym r_syms[SYM_MAX]; /* rogue symbols */
nhsym warnsyms[WARNCOUNT]; /* the current warning display symbols */
/* dungeon.c */
int n_dgns; /* number of dungeons (also used in mklev.c and do.c) */
branch *branches; /* dungeon branch list */
mapseen *mapseenchn; /*DUNGEON_OVERVIEW*/
/* eat.c */
boolean force_save_hs;
/* end.c */
struct valuable_data gems[LAST_GEM + 1 - FIRST_GEM + 1]; /* +1 for glass */
struct valuable_data amulets[LAST_AMULET + 1 - FIRST_AMULET];
struct val_list valuables[3];
/* hack.c */
anything tmp_anything;
int wc; /* current weight_cap(); valid after call to inv_weight() */
/* invent.c */
int lastinvnr; /* 0 ... 51 (never saved&restored) */
unsigned sortlootmode; /* set by sortloot() for use by sortloot_cmp();
* reset by sortloot when done */
char *invbuf;
unsigned invbufsiz;
/* lock.c */
struct xlock_s xlock;
/* makemon.c */
struct {
@@ -550,6 +659,38 @@ struct instance_globals {
char mchoices[SPECIAL_PM]; /* value range is 0..127 */
} rndmonst_state;
/* mhitm.c */
boolean vis;
boolean far_noise;
long noisetime;
struct obj *otmp;
int dieroll; /* Needed for the special case of monsters wielding vorpal
* blades (rare). If we use this a lot it should probably
* be a parameter to mdamagem() instead of a global variable.
*/
/* mhitu.c */
int mhitu_dieroll;
/* mklev.c */
xchar vault_x;
xchar vault_y;
boolean made_branch; /* used only during level creation */
/* mkmap.c */
char *new_locations;
int min_rx; /* rectangle bounds for regions */
int max_rx;
int min_ry;
int max_ry;
int n_loc_filled;
/* mkmaze.c */
lev_region bughack; /* for preserving the insect legs when wallifying
* baalz level */
boolean was_waterlevel; /* ugh... this shouldn't be needed */
/* muse.c */
boolean m_using; /* kludge to use mondided instead of killed */
int trapx;
@@ -630,6 +771,11 @@ struct instance_globals {
unsigned ustuck_id; /* need to preserve during save */
unsigned usteed_id; /* need to preserve during save */
/* sp_lev.c */
char *lev_message;
lev_region *lregions;
int num_lregions;
/* trap.c */
int force_mintrap; /* mintrap() should take a flags argument, but for time
being we use this */

View File

@@ -167,6 +167,27 @@ typedef struct strbuf {
char buf[256];
} strbuf_t;
/* str_or_len from sp_lev.h */
typedef union str_or_len {
char *str;
int len;
} Str_or_Len;
/* values for rtype are defined in dungeon.h */
/* lev_region from sp_lev.h */
typedef struct {
struct {
xchar x1, y1, x2, y2;
} inarea;
struct {
xchar x1, y1, x2, y2;
} delarea;
boolean in_islev, del_islev;
xchar rtype, padding;
Str_or_Len rname;
} lev_region;
#include "align.h"
#include "dungeon.h"
#include "monsym.h"
@@ -175,6 +196,16 @@ typedef struct strbuf {
#include "youprop.h"
#include "wintype.h"
#include "context.h"
#include "rm.h"
/* Symbol offsets */
#define SYM_OFF_P (0)
#define SYM_OFF_O (SYM_OFF_P + MAXPCHARS) /* MAXPCHARS from rm.h */
#define SYM_OFF_M (SYM_OFF_O + MAXOCLASSES) /* MAXOCLASSES from objclass.h */
#define SYM_OFF_W (SYM_OFF_M + MAXMCLASSES) /* MAXMCLASSES from monsym.h*/
#define SYM_OFF_X (SYM_OFF_W + WARNCOUNT)
#define SYM_MAX (SYM_OFF_X + MAXOTHER)
#include "decl.h"
#include "timeout.h"
@@ -221,21 +252,12 @@ typedef struct sortloot_item Loot;
#include "trap.h"
#include "flag.h"
#include "rm.h"
#include "vision.h"
#include "display.h"
#include "engrave.h"
#include "rect.h"
#include "region.h"
/* Symbol offsets */
#define SYM_OFF_P (0)
#define SYM_OFF_O (SYM_OFF_P + MAXPCHARS)
#define SYM_OFF_M (SYM_OFF_O + MAXOCLASSES)
#define SYM_OFF_W (SYM_OFF_M + MAXMCLASSES)
#define SYM_OFF_X (SYM_OFF_W + WARNCOUNT)
#define SYM_MAX (SYM_OFF_X + MAXOTHER)
#ifdef USE_TRAMPOLI /* this doesn't belong here, but we have little choice */
#undef NDECL
#define NDECL(f) f()

View File

@@ -300,14 +300,9 @@ struct symsetentry {
#define H_CURS 3
extern const struct symdef defsyms[MAXPCHARS]; /* defaults */
#define WARNCOUNT 6 /* number of different warning levels */
extern const struct symdef def_warnsyms[WARNCOUNT];
extern int currentgraphics; /* from drawing.c */
extern nhsym showsyms[];
extern nhsym l_syms[];
extern nhsym r_syms[];
extern struct symsetentry symset[NUM_GRAPHICS]; /* from drawing.c */
#define SYMHANDLING(ht) (symset[currentgraphics].handling == (ht))
#define SYMHANDLING(ht) (g.symset[g.currentgraphics].handling == (ht))
/*
* The 5 possible states of doors

View File

@@ -327,11 +327,6 @@ typedef struct {
long jmp_target;
} opjmp;
typedef union str_or_len {
char *str;
int len;
} Str_or_Len;
typedef struct {
xchar init_style; /* one of LVLINIT_foo */
long flags;
@@ -400,19 +395,6 @@ typedef struct {
xchar fromter, toter, tolit;
} replaceterrain;
/* values for rtype are defined in dungeon.h */
typedef struct {
struct {
xchar x1, y1, x2, y2;
} inarea;
struct {
xchar x1, y1, x2, y2;
} delarea;
boolean in_islev, del_islev;
xchar rtype, padding;
Str_or_Len rname;
} lev_region;
typedef struct {
struct {
xchar room;