Moving globals to instance_globals part 10ish.

This commit is contained in:
Bart House
2018-12-19 20:01:56 -08:00
parent f312b8cfe6
commit af949cb1df
5 changed files with 29 additions and 20 deletions
+3
View File
@@ -838,6 +838,9 @@ struct instance_globals {
* remember who zapped the wand. */ * remember who zapped the wand. */
struct musable m; struct musable m;
/* o_init.c */
short disco[NUM_OBJECTS];
/* objname.c */ /* objname.c */
/* distantname used by distant_name() to pass extra information to /* distantname used by distant_name() to pass extra information to
xname_flags(); it would be much cleaner if this were a parameter, xname_flags(); it would be much cleaner if this were a parameter,
+3
View File
@@ -499,6 +499,9 @@ const struct instance_globals g_init = {
UNDEFINED_VALUE, /* zap_oseen */ UNDEFINED_VALUE, /* zap_oseen */
UNDEFINED_VALUES, /* m */ UNDEFINED_VALUES, /* m */
/* o_init.c */
DUMMY, /* disco */
/* objname.c */ /* objname.c */
0, /* distantname */ 0, /* distantname */
+15 -17
View File
@@ -12,8 +12,6 @@ STATIC_DCL void NDECL(shuffle_all);
STATIC_DCL boolean FDECL(interesting_to_discover, (int)); STATIC_DCL boolean FDECL(interesting_to_discover, (int));
STATIC_DCL char *FDECL(oclass_to_name, (CHAR_P, char *)); STATIC_DCL char *FDECL(oclass_to_name, (CHAR_P, char *));
static NEARDATA short disco[NUM_OBJECTS] = DUMMY;
#ifdef USE_TILES #ifdef USE_TILES
STATIC_DCL void NDECL(shuffle_tiles); STATIC_DCL void NDECL(shuffle_tiles);
extern short glyph2tile[]; /* from tile.c */ extern short glyph2tile[]; /* from tile.c */
@@ -296,7 +294,7 @@ int fd, mode;
if (perform_bwrite(mode)) { if (perform_bwrite(mode)) {
bwrite(fd, (genericptr_t) bases, sizeof bases); bwrite(fd, (genericptr_t) bases, sizeof bases);
bwrite(fd, (genericptr_t) disco, sizeof disco); bwrite(fd, (genericptr_t) g.disco, sizeof g.disco);
bwrite(fd, (genericptr_t) objects, bwrite(fd, (genericptr_t) objects,
sizeof(struct objclass) * NUM_OBJECTS); sizeof(struct objclass) * NUM_OBJECTS);
} }
@@ -325,7 +323,7 @@ register int fd;
unsigned int len; unsigned int len;
mread(fd, (genericptr_t) bases, sizeof bases); mread(fd, (genericptr_t) bases, sizeof bases);
mread(fd, (genericptr_t) disco, sizeof disco); mread(fd, (genericptr_t) g.disco, sizeof g.disco);
mread(fd, (genericptr_t) objects, sizeof(struct objclass) * NUM_OBJECTS); mread(fd, (genericptr_t) objects, sizeof(struct objclass) * NUM_OBJECTS);
for (i = 0; i < NUM_OBJECTS; i++) for (i = 0; i < NUM_OBJECTS; i++)
if (objects[i].oc_uname) { if (objects[i].oc_uname) {
@@ -351,10 +349,10 @@ boolean credit_hero;
uname'd) or the next open slot; one or the other will be found uname'd) or the next open slot; one or the other will be found
before we reach the next class... before we reach the next class...
*/ */
for (dindx = bases[acls]; disco[dindx] != 0; dindx++) for (dindx = bases[acls]; g.disco[dindx] != 0; dindx++)
if (disco[dindx] == oindx) if (g.disco[dindx] == oindx)
break; break;
disco[dindx] = oindx; g.disco[dindx] = oindx;
if (mark_as_known) { if (mark_as_known) {
objects[oindx].oc_name_known = 1; objects[oindx].oc_name_known = 1;
@@ -377,19 +375,19 @@ register int oindx;
register boolean found = FALSE; register boolean found = FALSE;
/* find the object; shift those behind it forward one slot */ /* find the object; shift those behind it forward one slot */
for (dindx = bases[acls]; dindx < NUM_OBJECTS && disco[dindx] != 0 for (dindx = bases[acls]; dindx < NUM_OBJECTS && g.disco[dindx] != 0
&& objects[dindx].oc_class == acls; && objects[dindx].oc_class == acls;
dindx++) dindx++)
if (found) if (found)
disco[dindx - 1] = disco[dindx]; g.disco[dindx - 1] = g.disco[dindx];
else if (disco[dindx] == oindx) else if (g.disco[dindx] == oindx)
found = TRUE; found = TRUE;
/* clear last slot */ /* clear last slot */
if (found) if (found)
disco[dindx - 1] = 0; g.disco[dindx - 1] = 0;
else else
impossible("named object not in disco"); impossible("named object not in g.disco");
update_inventory(); update_inventory();
} }
} }
@@ -405,7 +403,7 @@ register int i;
} }
/* items that should stand out once they're known */ /* items that should stand out once they're known */
static short uniq_objs[] = { static const short uniq_objs[] = {
AMULET_OF_YENDOR, SPE_BOOK_OF_THE_DEAD, CANDELABRUM_OF_INVOCATION, AMULET_OF_YENDOR, SPE_BOOK_OF_THE_DEAD, CANDELABRUM_OF_INVOCATION,
BELL_OF_OPENING, BELL_OF_OPENING,
}; };
@@ -446,7 +444,7 @@ dodiscovered() /* free after Robert Viduya */
prev_class = oclass + 1; /* forced different from oclass */ prev_class = oclass + 1; /* forced different from oclass */
for (i = bases[(int) oclass]; for (i = bases[(int) oclass];
i < NUM_OBJECTS && objects[i].oc_class == oclass; i++) { i < NUM_OBJECTS && objects[i].oc_class == oclass; i++) {
if ((dis = disco[i]) != 0 && interesting_to_discover(dis)) { if ((dis = g.disco[i]) != 0 && interesting_to_discover(dis)) {
ct++; ct++;
if (oclass != prev_class) { if (oclass != prev_class) {
putstr(tmpwin, iflags.menu_headings, putstr(tmpwin, iflags.menu_headings,
@@ -543,7 +541,7 @@ doclassdisco()
c = def_oc_syms[(int) oclass].sym; c = def_oc_syms[(int) oclass].sym;
for (i = bases[(int) oclass]; for (i = bases[(int) oclass];
i < NUM_OBJECTS && objects[i].oc_class == oclass; ++i) i < NUM_OBJECTS && objects[i].oc_class == oclass; ++i)
if ((dis = disco[i]) != 0 && interesting_to_discover(dis)) { if ((dis = g.disco[i]) != 0 && interesting_to_discover(dis)) {
if (!index(discosyms, c)) { if (!index(discosyms, c)) {
Sprintf(eos(discosyms), "%c", c); Sprintf(eos(discosyms), "%c", c);
if (!traditional) { if (!traditional) {
@@ -634,7 +632,7 @@ doclassdisco()
putstr(tmpwin, iflags.menu_headings, buf); putstr(tmpwin, iflags.menu_headings, buf);
for (i = bases[(int) oclass]; for (i = bases[(int) oclass];
i < NUM_OBJECTS && objects[i].oc_class == oclass; ++i) { i < NUM_OBJECTS && objects[i].oc_class == oclass; ++i) {
if ((dis = disco[i]) != 0 && interesting_to_discover(dis)) { if ((dis = g.disco[i]) != 0 && interesting_to_discover(dis)) {
Sprintf(buf, "%s %s", Sprintf(buf, "%s %s",
objects[dis].oc_pre_discovered ? "*" : " ", objects[dis].oc_pre_discovered ? "*" : " ",
obj_typename(dis)); obj_typename(dis));
@@ -680,7 +678,7 @@ rename_disco()
prev_class = oclass + 1; /* forced different from oclass */ prev_class = oclass + 1; /* forced different from oclass */
for (i = bases[(int) oclass]; for (i = bases[(int) oclass];
i < NUM_OBJECTS && objects[i].oc_class == oclass; i++) { i < NUM_OBJECTS && objects[i].oc_class == oclass; i++) {
dis = disco[i]; dis = g.disco[i];
if (!dis || !interesting_to_discover(dis)) if (!dis || !interesting_to_discover(dis))
continue; continue;
ct++; ct++;
+1 -1
View File
@@ -2055,7 +2055,7 @@ struct sing_plur {
/* word pairs that don't fit into formula-based transformations; /* word pairs that don't fit into formula-based transformations;
also some suffices which have very few--often one--matches or also some suffices which have very few--often one--matches or
which aren't systematically reversible (knives, staves) */ which aren't systematically reversible (knives, staves) */
static struct sing_plur one_off[] = { static const struct sing_plur one_off[] = {
{ "child", { "child",
"children" }, /* (for wise guys who give their food funny names) */ "children" }, /* (for wise guys who give their food funny names) */
{ "cubus", "cubi" }, /* in-/suc-cubus */ { "cubus", "cubi" }, /* in-/suc-cubus */
+7 -2
View File
@@ -51,11 +51,11 @@ enum window_option_types {
* option (e.g. time and timed_delay) the shorter one must come first. * option (e.g. time and timed_delay) the shorter one must come first.
*/ */
static struct Bool_Opt { static const struct Bool_Opt {
const char *name; const char *name;
boolean *addr, initvalue; boolean *addr, initvalue;
int optflags; int optflags;
} boolopt[] = { } boolopt_init[] = {
{ "acoustics", &flags.acoustics, TRUE, SET_IN_GAME }, { "acoustics", &flags.acoustics, TRUE, SET_IN_GAME },
#if defined(SYSFLAGS) && defined(AMIGA) #if defined(SYSFLAGS) && defined(AMIGA)
/* Amiga altmeta causes Alt+key to be converted into Meta+key by /* Amiga altmeta causes Alt+key to be converted into Meta+key by
@@ -449,6 +449,8 @@ static struct Comp_Opt {
{ (char *) 0, (char *) 0, 0, 0 } { (char *) 0, (char *) 0, 0, 0 }
}; };
static struct Bool_Opt boolopt[SIZE(boolopt_init)];
#ifdef OPTION_LISTS_ONLY #ifdef OPTION_LISTS_ONLY
#undef static #undef static
@@ -688,6 +690,8 @@ initoptions_init()
#endif #endif
int i; int i;
memcpy(boolopt, boolopt_init, sizeof(boolopt));
/* set up the command parsing */ /* set up the command parsing */
reset_commands(TRUE); /* init */ reset_commands(TRUE); /* init */
@@ -6720,4 +6724,5 @@ set_playmode()
#endif /* OPTION_LISTS_ONLY */ #endif /* OPTION_LISTS_ONLY */
/*options.c*/ /*options.c*/