]> granicus.if.org Git - nethack/commitdiff
Moved read.c globals to instance_globals.
authorBart House <bart@barthouse.com>
Fri, 23 Nov 2018 18:47:52 +0000 (10:47 -0800)
committerBart House <bart@barthouse.com>
Fri, 23 Nov 2018 18:47:52 +0000 (10:47 -0800)
include/decl.h
src/decl.c
src/detect.c
src/read.c

index 18d30daeacbbbe3f6f650079d385f2e0c2ee03d9..97ded9560dafde911fa330c9cc0eef7cf74a17d5 100644 (file)
@@ -464,6 +464,9 @@ struct instance_globals {
     /* pickup.c */
     int oldcap; /* last encumberance */
 
+    /* read.c */
+    boolean known;
+
     /* restore.c */
     int n_ids_mapped;
     struct bucket *id_map;
index c006cc71588db112cd40a00d67d3e17aa25aef88..f9dceec88664f43e171c77971b8d717fe61facb1 100644 (file)
@@ -348,6 +348,9 @@ const struct instance_globals g_init = {
     /* pickup.c */
     0,  /* oldcap */
 
+    /* read.c */
+    UNDEFINED_VALUE, /* known */
+
     /* restore.c */
     0, /* n_ids_mapped */
     0, /* id_map */
index 416c2611fff4f90fc976fea58bfe3678f18c40ad..79161aea751a1957df8f50f882842a378e0e5f1b 100644 (file)
@@ -11,8 +11,6 @@
 #include "hack.h"
 #include "artifact.h"
 
-extern boolean known; /* from read.c */
-
 STATIC_DCL boolean NDECL(unconstrain_map);
 STATIC_DCL void NDECL(reconstrain_map);
 STATIC_DCL void FDECL(browse_map, (int, const char *));
@@ -307,7 +305,7 @@ register struct obj *sobj;
     boolean stale, ugold = FALSE, steedgold = FALSE;
     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));
 
     /* look for gold carried by monsters (might be in a container) */
@@ -318,7 +316,7 @@ register struct obj *sobj;
             if (mtmp == u.usteed) {
                 steedgold = TRUE;
             } else {
-                known = TRUE;
+                g.known = TRUE;
                 goto outgoldmap; /* skip further searching */
             }
         } else {
@@ -328,7 +326,7 @@ register struct obj *sobj;
                     if (mtmp == u.usteed) {
                         steedgold = TRUE;
                     } else {
-                        known = TRUE;
+                        g.known = TRUE;
                         goto outgoldmap; /* skip further searching */
                     }
                 }
@@ -338,17 +336,17 @@ register struct obj *sobj;
     /* look for gold objects */
     for (obj = fobj; obj; obj = obj->nobj) {
         if (sobj->blessed && o_material(obj, GOLD)) {
-            known = TRUE;
+            g.known = TRUE;
             if (obj->ox != u.ux || obj->oy != u.uy)
                 goto outgoldmap;
         } else if (o_in(obj, COIN_CLASS)) {
-            known = TRUE;
+            g.known = TRUE;
             if (obj->ox != u.ux || obj->oy != u.uy)
                 goto outgoldmap;
         }
     }
 
-    if (!known) {
+    if (!g.known) {
         /* no gold found on floor or monster's inventory.
            adjust message if you have gold in your inventory */
         if (sobj) {
@@ -484,7 +482,7 @@ register struct obj *sobj;
     }
 
     if (!ct && !ctu) {
-        known = stale && !confused;
+        g.known = stale && !confused;
         if (stale) {
             docrt();
             You("sense a lack of %s nearby.", what);
@@ -512,7 +510,7 @@ register struct obj *sobj;
         }
         return !stale;
     } else if (!ct) {
-        known = TRUE;
+        g.known = TRUE;
         You("%s %s nearby.", sobj ? "smell" : "sense", what);
         if (sobj && sobj->blessed) {
             if (!u.uedibility)
@@ -523,7 +521,7 @@ register struct obj *sobj;
         struct obj *temp;
         int ter_typ = TER_DETECT | TER_OBJ;
 
-        known = TRUE;
+        g.known = TRUE;
         cls();
         (void) unconstrain_map();
         for (obj = fobj; obj; obj = obj->nobj)
index f6b2c3092047facbe27d28f5b1cc147224f83a54..8db74ba52660c002c22f012b919255d9fe64a277 100644 (file)
@@ -12,8 +12,6 @@
     ((mndx) == urace.malenum \
      || (urace.femalenum != NON_PM && (mndx) == urace.femalenum))
 
-boolean known;
-
 static NEARDATA const char readable[] = { ALL_CLASSES, SCROLL_CLASS,
                                           SPBOOK_CLASS, 0 };
 static const char all_count[] = { ALLOW_COUNT, ALL_CLASSES, 0 };
@@ -189,7 +187,7 @@ doread()
     register struct obj *scroll;
     boolean confused, nodisappear;
 
-    known = FALSE;
+    g.known = FALSE;
     if (check_capacity((char *) 0))
         return 0;
     scroll = getobj(readable, "read");
@@ -396,7 +394,7 @@ doread()
     }
     if (!seffects(scroll)) {
         if (!objects[scroll->otyp].oc_name_known) {
-            if (known)
+            if (g.known)
                 learnscroll(scroll);
             else if (!objects[scroll->otyp].oc_uname)
                 docall(scroll);
@@ -801,7 +799,7 @@ int howmuch;
     if (Sokoban)
         return;
 
-    known = TRUE;
+    g.known = TRUE;
     for (zx = 0; zx < COLNO; zx++)
         for (zy = 0; zy < ROWNO; zy++)
             if (howmuch & ALL_MAP || rn2(7)) {
@@ -1013,7 +1011,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
     switch (otyp) {
 #ifdef MAIL
     case SCR_MAIL:
-        known = TRUE;
+        g.known = TRUE;
         if (sobj->spe == 2)
             /* "stamped scroll" created via magic marker--without a stamp */
             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) {
             otmp->spe += s;
             adj_abon(otmp, s);
-            known = otmp->known;
+            g.known = otmp->known;
             /* update shop bill to reflect new higher price */
             if (s > 0 && otmp->unpaid)
                 alter_cost(otmp, 0L);
@@ -1184,7 +1182,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
                 exercise(A_CON, FALSE);
                 break;
             } else
-                known = TRUE;
+                g.known = TRUE;
         } else { /* armor and scroll both cursed */
             pline("%s.", Yobjnam2(otmp, "vibrate"));
             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.");
         else
             pline("This scroll seems to be blank.");
-        known = TRUE;
+        g.known = TRUE;
         break;
     case SCR_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]
                                      : (struct permonst *) 0,
                             FALSE))
-            known = TRUE;
+            g.known = TRUE;
         /* no need to flush monsters; we ask for identification only if the
          * monsters are not visible
          */
@@ -1430,14 +1428,14 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
                       vis_results ? "is" : "seems",
                       (results < 0) ? "un" : "");
             if (vis_results > 0)
-                known = TRUE;
+                g.known = TRUE;
         }
         break;
     }
     case SCR_GENOCIDE:
         if (!already_known)
             You("have found a scroll of genocide!");
-        known = TRUE;
+        g.known = TRUE;
         if (sblessed)
             do_class_genocide();
         else
@@ -1446,11 +1444,11 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
     case SCR_LIGHT:
         if (!confused || rn2(5)) {
             if (!Blind)
-                known = TRUE;
+                g.known = TRUE;
             litroom(!confused && !scursed, sobj);
             if (!confused && !scursed) {
                 if (lightdamage(sobj, TRUE, 5))
-                    known = TRUE;
+                    g.known = TRUE;
             }
         } else {
             /* 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) {
             level_tele();
         } else {
-            known = scrolltele(sobj);
+            g.known = scrolltele(sobj);
         }
         break;
     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]);
             /* do_mapping() already reveals secret passages */
         }
-        known = TRUE;
+        g.known = TRUE;
         /*FALLTHRU*/
     case SPE_MAGIC_MAPPING:
         if (level.flags.nommap) {
@@ -1576,7 +1574,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
         }
         break;
     case SCR_AMNESIA:
-        known = TRUE;
+        g.known = TRUE;
         forget((!sblessed ? ALL_SPELLS : 0)
                | (!confused || scursed ? ALL_MAP : 0));
         if (Hallucination) /* Ommmmmm! */
@@ -1657,7 +1655,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
             else
                 pline_The("%s rumbles %s you!", ceiling(u.ux, u.uy),
                           sblessed ? "around" : "above");
-            known = 1;
+            g.known = 1;
             sokoban_guilt();
 
             /* Loop through the surrounding squares */
@@ -1682,7 +1680,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
         }
         break;
     case SCR_PUNISHMENT:
-        known = TRUE;
+        g.known = TRUE;
         if (confused || sblessed) {
             You_feel("guilty.");
             break;
@@ -1694,7 +1692,7 @@ struct obj *sobj; /* scroll, or fake spellbook object for scroll-like spell */
 
         if (!already_known)
             You("have found a scroll of stinking cloud!");
-        known = TRUE;
+        g.known = TRUE;
         pline("Where do you want to center the %scloud?",
               already_known ? "stinking " : "");
         cc.x = u.ux;