Moved read.c globals to instance_globals.

This commit is contained in:
Bart House
2018-11-23 10:47:52 -08:00
parent c91d560591
commit 43cc162cf9
4 changed files with 33 additions and 31 deletions

View File

@@ -464,6 +464,9 @@ struct instance_globals {
/* pickup.c */ /* pickup.c */
int oldcap; /* last encumberance */ int oldcap; /* last encumberance */
/* read.c */
boolean known;
/* restore.c */ /* restore.c */
int n_ids_mapped; int n_ids_mapped;
struct bucket *id_map; struct bucket *id_map;

View File

@@ -348,6 +348,9 @@ const struct instance_globals g_init = {
/* pickup.c */ /* pickup.c */
0, /* oldcap */ 0, /* oldcap */
/* read.c */
UNDEFINED_VALUE, /* known */
/* restore.c */ /* restore.c */
0, /* n_ids_mapped */ 0, /* n_ids_mapped */
0, /* id_map */ 0, /* id_map */

View File

@@ -11,8 +11,6 @@
#include "hack.h" #include "hack.h"
#include "artifact.h" #include "artifact.h"
extern boolean known; /* from read.c */
STATIC_DCL boolean NDECL(unconstrain_map); STATIC_DCL boolean NDECL(unconstrain_map);
STATIC_DCL void NDECL(reconstrain_map); STATIC_DCL void NDECL(reconstrain_map);
STATIC_DCL void FDECL(browse_map, (int, const char *)); STATIC_DCL void FDECL(browse_map, (int, const char *));
@@ -307,7 +305,7 @@ register struct obj *sobj;
boolean stale, ugold = FALSE, steedgold = FALSE; boolean stale, ugold = FALSE, steedgold = FALSE;
int ter_typ = TER_DETECT | TER_OBJ; int ter_typ = TER_DETECT | TER_OBJ;
known = stale = clear_stale_map(COIN_CLASS, g.known = stale = clear_stale_map(COIN_CLASS,
(unsigned) (sobj->blessed ? GOLD : 0)); (unsigned) (sobj->blessed ? GOLD : 0));
/* look for gold carried by monsters (might be in a container) */ /* look for gold carried by monsters (might be in a container) */
@@ -318,7 +316,7 @@ register struct obj *sobj;
if (mtmp == u.usteed) { if (mtmp == u.usteed) {
steedgold = TRUE; steedgold = TRUE;
} else { } else {
known = TRUE; g.known = TRUE;
goto outgoldmap; /* skip further searching */ goto outgoldmap; /* skip further searching */
} }
} else { } else {
@@ -328,7 +326,7 @@ register struct obj *sobj;
if (mtmp == u.usteed) { if (mtmp == u.usteed) {
steedgold = TRUE; steedgold = TRUE;
} else { } else {
known = TRUE; g.known = TRUE;
goto outgoldmap; /* skip further searching */ goto outgoldmap; /* skip further searching */
} }
} }
@@ -338,17 +336,17 @@ register struct obj *sobj;
/* look for gold objects */ /* look for gold objects */
for (obj = fobj; obj; obj = obj->nobj) { for (obj = fobj; obj; obj = obj->nobj) {
if (sobj->blessed && o_material(obj, GOLD)) { if (sobj->blessed && o_material(obj, GOLD)) {
known = TRUE; g.known = TRUE;
if (obj->ox != u.ux || obj->oy != u.uy) if (obj->ox != u.ux || obj->oy != u.uy)
goto outgoldmap; goto outgoldmap;
} else if (o_in(obj, COIN_CLASS)) { } else if (o_in(obj, COIN_CLASS)) {
known = TRUE; g.known = TRUE;
if (obj->ox != u.ux || obj->oy != u.uy) if (obj->ox != u.ux || obj->oy != u.uy)
goto outgoldmap; goto outgoldmap;
} }
} }
if (!known) { if (!g.known) {
/* no gold found on floor or monster's inventory. /* no gold found on floor or monster's inventory.
adjust message if you have gold in your inventory */ adjust message if you have gold in your inventory */
if (sobj) { if (sobj) {
@@ -484,7 +482,7 @@ register struct obj *sobj;
} }
if (!ct && !ctu) { if (!ct && !ctu) {
known = stale && !confused; g.known = stale && !confused;
if (stale) { if (stale) {
docrt(); docrt();
You("sense a lack of %s nearby.", what); You("sense a lack of %s nearby.", what);
@@ -512,7 +510,7 @@ register struct obj *sobj;
} }
return !stale; return !stale;
} else if (!ct) { } else if (!ct) {
known = TRUE; g.known = TRUE;
You("%s %s nearby.", sobj ? "smell" : "sense", what); You("%s %s nearby.", sobj ? "smell" : "sense", what);
if (sobj && sobj->blessed) { if (sobj && sobj->blessed) {
if (!u.uedibility) if (!u.uedibility)
@@ -523,7 +521,7 @@ register struct obj *sobj;
struct obj *temp; struct obj *temp;
int ter_typ = TER_DETECT | TER_OBJ; int ter_typ = TER_DETECT | TER_OBJ;
known = TRUE; g.known = TRUE;
cls(); cls();
(void) unconstrain_map(); (void) unconstrain_map();
for (obj = fobj; obj; obj = obj->nobj) for (obj = fobj; obj; obj = obj->nobj)

View File

@@ -12,8 +12,6 @@
((mndx) == urace.malenum \ ((mndx) == urace.malenum \
|| (urace.femalenum != NON_PM && (mndx) == urace.femalenum)) || (urace.femalenum != NON_PM && (mndx) == urace.femalenum))
boolean known;
static NEARDATA const char readable[] = { ALL_CLASSES, SCROLL_CLASS, static NEARDATA const char readable[] = { ALL_CLASSES, SCROLL_CLASS,
SPBOOK_CLASS, 0 }; SPBOOK_CLASS, 0 };
static const char all_count[] = { ALLOW_COUNT, ALL_CLASSES, 0 }; static const char all_count[] = { ALLOW_COUNT, ALL_CLASSES, 0 };
@@ -189,7 +187,7 @@ doread()
register struct obj *scroll; register struct obj *scroll;
boolean confused, nodisappear; boolean confused, nodisappear;
known = FALSE; g.known = FALSE;
if (check_capacity((char *) 0)) if (check_capacity((char *) 0))
return 0; return 0;
scroll = getobj(readable, "read"); scroll = getobj(readable, "read");
@@ -396,7 +394,7 @@ doread()
} }
if (!seffects(scroll)) { if (!seffects(scroll)) {
if (!objects[scroll->otyp].oc_name_known) { if (!objects[scroll->otyp].oc_name_known) {
if (known) if (g.known)
learnscroll(scroll); learnscroll(scroll);
else if (!objects[scroll->otyp].oc_uname) else if (!objects[scroll->otyp].oc_uname)
docall(scroll); docall(scroll);
@@ -801,7 +799,7 @@ int howmuch;
if (Sokoban) if (Sokoban)
return; return;
known = TRUE; g.known = TRUE;
for (zx = 0; zx < COLNO; zx++) for (zx = 0; zx < COLNO; zx++)
for (zy = 0; zy < ROWNO; zy++) for (zy = 0; zy < ROWNO; zy++)
if (howmuch & ALL_MAP || rn2(7)) { if (howmuch & ALL_MAP || rn2(7)) {
@@ -1013,7 +1011,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
switch (otyp) { switch (otyp) {
#ifdef MAIL #ifdef MAIL
case SCR_MAIL: case SCR_MAIL:
known = TRUE; g.known = TRUE;
if (sobj->spe == 2) if (sobj->spe == 2)
/* "stamped scroll" created via magic marker--without a stamp */ /* "stamped scroll" created via magic marker--without a stamp */
pline("This scroll is marked \"postage due\"."); pline("This scroll is marked \"postage due\".");
@@ -1142,7 +1140,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
if (s) { if (s) {
otmp->spe += s; otmp->spe += s;
adj_abon(otmp, s); adj_abon(otmp, s);
known = otmp->known; g.known = otmp->known;
/* update shop bill to reflect new higher price */ /* update shop bill to reflect new higher price */
if (s > 0 && otmp->unpaid) if (s > 0 && otmp->unpaid)
alter_cost(otmp, 0L); alter_cost(otmp, 0L);
@@ -1184,7 +1182,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
exercise(A_CON, FALSE); exercise(A_CON, FALSE);
break; break;
} else } else
known = TRUE; g.known = TRUE;
} else { /* armor and scroll both cursed */ } else { /* armor and scroll both cursed */
pline("%s.", Yobjnam2(otmp, "vibrate")); pline("%s.", Yobjnam2(otmp, "vibrate"));
if (otmp->spe >= -6) { if (otmp->spe >= -6) {
@@ -1264,7 +1262,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
You("don't remember there being any magic words on this scroll."); You("don't remember there being any magic words on this scroll.");
else else
pline("This scroll seems to be blank."); pline("This scroll seems to be blank.");
known = TRUE; g.known = TRUE;
break; break;
case SCR_REMOVE_CURSE: case SCR_REMOVE_CURSE:
case SPE_REMOVE_CURSE: { case SPE_REMOVE_CURSE: {
@@ -1350,7 +1348,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
confused ? &mons[PM_ACID_BLOB] confused ? &mons[PM_ACID_BLOB]
: (struct permonst *) 0, : (struct permonst *) 0,
FALSE)) FALSE))
known = TRUE; g.known = TRUE;
/* no need to flush monsters; we ask for identification only if the /* no need to flush monsters; we ask for identification only if the
* monsters are not visible * monsters are not visible
*/ */
@@ -1430,14 +1428,14 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
vis_results ? "is" : "seems", vis_results ? "is" : "seems",
(results < 0) ? "un" : ""); (results < 0) ? "un" : "");
if (vis_results > 0) if (vis_results > 0)
known = TRUE; g.known = TRUE;
} }
break; break;
} }
case SCR_GENOCIDE: case SCR_GENOCIDE:
if (!already_known) if (!already_known)
You("have found a scroll of genocide!"); You("have found a scroll of genocide!");
known = TRUE; g.known = TRUE;
if (sblessed) if (sblessed)
do_class_genocide(); do_class_genocide();
else else
@@ -1446,11 +1444,11 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
case SCR_LIGHT: case SCR_LIGHT:
if (!confused || rn2(5)) { if (!confused || rn2(5)) {
if (!Blind) if (!Blind)
known = TRUE; g.known = TRUE;
litroom(!confused && !scursed, sobj); litroom(!confused && !scursed, sobj);
if (!confused && !scursed) { if (!confused && !scursed) {
if (lightdamage(sobj, TRUE, 5)) if (lightdamage(sobj, TRUE, 5))
known = TRUE; g.known = TRUE;
} }
} else { } else {
/* could be scroll of create monster, don't set known ...*/ /* could be scroll of create monster, don't set known ...*/
@@ -1463,7 +1461,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
if (confused || scursed) { if (confused || scursed) {
level_tele(); level_tele();
} else { } else {
known = scrolltele(sobj); g.known = scrolltele(sobj);
} }
break; break;
case SCR_GOLD_DETECTION: case SCR_GOLD_DETECTION:
@@ -1556,7 +1554,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
cvt_sdoor_to_door(&levl[x][y]); cvt_sdoor_to_door(&levl[x][y]);
/* do_mapping() already reveals secret passages */ /* do_mapping() already reveals secret passages */
} }
known = TRUE; g.known = TRUE;
/*FALLTHRU*/ /*FALLTHRU*/
case SPE_MAGIC_MAPPING: case SPE_MAGIC_MAPPING:
if (level.flags.nommap) { if (level.flags.nommap) {
@@ -1576,7 +1574,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
} }
break; break;
case SCR_AMNESIA: case SCR_AMNESIA:
known = TRUE; g.known = TRUE;
forget((!sblessed ? ALL_SPELLS : 0) forget((!sblessed ? ALL_SPELLS : 0)
| (!confused || scursed ? ALL_MAP : 0)); | (!confused || scursed ? ALL_MAP : 0));
if (Hallucination) /* Ommmmmm! */ if (Hallucination) /* Ommmmmm! */
@@ -1657,7 +1655,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
else else
pline_The("%s rumbles %s you!", ceiling(u.ux, u.uy), pline_The("%s rumbles %s you!", ceiling(u.ux, u.uy),
sblessed ? "around" : "above"); sblessed ? "around" : "above");
known = 1; g.known = 1;
sokoban_guilt(); sokoban_guilt();
/* Loop through the surrounding squares */ /* Loop through the surrounding squares */
@@ -1682,7 +1680,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
} }
break; break;
case SCR_PUNISHMENT: case SCR_PUNISHMENT:
known = TRUE; g.known = TRUE;
if (confused || sblessed) { if (confused || sblessed) {
You_feel("guilty."); You_feel("guilty.");
break; break;
@@ -1694,7 +1692,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
if (!already_known) if (!already_known)
You("have found a scroll of stinking cloud!"); You("have found a scroll of stinking cloud!");
known = TRUE; g.known = TRUE;
pline("Where do you want to center the %scloud?", pline("Where do you want to center the %scloud?",
already_known ? "stinking " : ""); already_known ? "stinking " : "");
cc.x = u.ux; cc.x = u.ux;