]> granicus.if.org Git - nethack/commitdiff
Revert "Instance variable work check-point."
authornhmall <nhmall@nethack.org>
Sat, 24 Nov 2018 03:17:12 +0000 (22:17 -0500)
committernhmall <nhmall@nethack.org>
Sat, 24 Nov 2018 03:17:12 +0000 (22:17 -0500)
This reverts commit 8e316df117e10f83ed93c56e95390720b4e1174c.

17 files changed:
include/config.h
include/decl.h
src/apply.c
src/artifact.c
src/botl.c
src/decl.c
src/dog.c
src/muse.c
src/pickup.c
src/restore.c
src/trap.c
src/u_init.c
src/uhitm.c
src/weapon.c
src/zap.c
sys/share/pcmain.c
win/win32/winhack.c

index d59a82af5f66ca463ff9d93605fec23fe35bacfa..82b45cad965bcbf6595e501df37213aa3ac9c9ec 100644 (file)
@@ -556,7 +556,6 @@ typedef unsigned char uchar;
 
 #endif
 
-
 /* End of Section 4 */
 
 #ifdef TTY_TILES_ESCCODES
index e0597efe34882351ec9767544f59da4fb803e180..49bd34d2ec35cfdbc9430955abbabdc05fa69daa 100644 (file)
@@ -438,51 +438,29 @@ struct early_opt {
     boolean valallowed;
 };
 
-/* instance_variables 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, variables can be of any type. */
-
-struct instance_variables {
-    /* apply.c */
-    int jumping_is_magic; /* current jump result of magic */
-    int polearm_range_min;
-    int polearm_range_max;
-    /* artifcat.c */
-    int spec_dbon_applies; /* coordinate effects from spec_dbon() with
-                              messages in artifact_hit() */
-    /* botl.c */
-    int mrank_sz; /* loaded by max_rank_sz */
-    /* dog.c */
-    int petname_used; /* user preferred pet name has been used */
-    /* muse.c */
-    boolean m_using; /* kludge to use mondided instead of killed */
-    /* pickup.c */
-    int oldcap; /* last encumberance */
-    /* trap.c */
-    int force_mintrap; /* mintrap() should take a flags argument, but for time
-                          being we use this */
-    /* u_init.c */
-    short nocreate;
-    short nocreate2;
-    short nocreate3;
-    short nocreate4;
-    /* uhitm.c */ 
-    boolean override_confirmation; /* Used to flag attacks caused by
-                                      Stormbringer's maliciousness. */
-    /* weapon.c */
-    struct obj *propellor;
-    /* zap.c */
-    int  poly_zapped;
-    boolean obj_zapped;
-
-    unsigned long magic; /* validate that structure layout is preserved */
+/* instance_context holds per game instance data that does not need to be
+ * persisted upon game exit.  This game instance data is one of the first
+ * things initialized during the initialization of the game engine.
+ * It is initialized with icontext_initial_state found in decl.c */
+
+struct instance_context {
+    int oldcap; /* encumberance - pickup.c */
+    int petname_used; /* user preferred pet name has been used - dog.c */
+    int jumping_is_magic; /* current jump result of magic - apply.c */
+    int polearm_range_min; /* apply.c */
+    int polearm_range_max; /* apply.c */
+    int spec_dbon_applies; /* coordinate effects from spec_dbon() with 
+                            * messages in artifact_hit() - artifact.c */
+    int mrank_sz; /* loaded by max_rank_sz - botl.c */
+    short nocreate; /* ini_inv() - u_init.c = STRANGE_OBJECT */
+    short nocreate2; /* ini_inv() - u_init.c = STRANGE_OBJECT */
+    short nocreate3; /* ini_inv() - u_init.c = STRANGE_OBJECT */
+    short nocreate4; /* ini_inv() - u_init.c = STRANGE_OBJECT */
 };
 
-E struct instance_variables iv;
+E struct instance_context icontext;
 
-E void instance_variable_init();
+E void icontext_init();
 
 
 #undef E
index 710891283b8b2d11c6aa0fa136d9a41e92061285..b4c0270df0f1d19f427c4a86e4e2a7438139e8ee 100644 (file)
@@ -1606,7 +1606,7 @@ int x,y;
 {
     return (isok(x, y)
             && (ACCESSIBLE(levl[x][y].typ) || Passes_walls)
-            && is_valid_jump_pos(x, y, iv.jumping_is_magic, FALSE));
+            && is_valid_jump_pos(x, y, icontext.jumping_is_magic, FALSE));
 }
 
 void
@@ -1720,7 +1720,7 @@ int magic; /* 0=Physical, otherwise skill level */
     pline("Where do you want to jump?");
     cc.x = u.ux;
     cc.y = u.uy;
-    iv.jumping_is_magic = magic;
+    icontext.jumping_is_magic = magic;
     getpos_sethilite(display_jump_positions, get_valid_jump_position);
     if (getpos(&cc, TRUE, "the desired position") < 0)
         return 0; /* user pressed ESC */
@@ -2917,8 +2917,8 @@ get_valid_polearm_position(x, y)
 int x, y;
 {
     return (isok(x, y) && ACCESSIBLE(levl[x][y].typ)
-            && distu(x, y) >= iv.polearm_range_min
-            && distu(x, y) <= iv.polearm_range_max);
+            && distu(x, y) >= icontext.polearm_range_min
+            && distu(x, y) <= icontext.polearm_range_max);
 }
 
 void
@@ -2990,8 +2990,8 @@ struct obj *obj;
     else
         max_range = 8; /* (P_SKILL(typ) >= P_EXPERT) */
 
-    iv.polearm_range_min = min_range;
-    iv.polearm_range_max = max_range;
+    icontext.polearm_range_min = min_range;
+    icontext.polearm_range_max = max_range;
 
     /* Prompt for a location */
     pline(where_to_hit);
index 2bb4f5078212f3109997606999e6efb0000ca74d..a5d0902009ddb73b2c4f37287d69a17eb7ff2ddd 100644 (file)
@@ -844,15 +844,15 @@ int tmp;
 
     if (!weap || (weap->attk.adtyp == AD_PHYS /* check for `NO_ATTK' */
                   && weap->attk.damn == 0 && weap->attk.damd == 0))
-        iv.spec_dbon_applies = FALSE;
+        icontext.spec_dbon_applies = FALSE;
     else if (otmp->oartifact == ART_GRIMTOOTH)
         /* Grimtooth has SPFX settings to warn against elves but we want its
            damage bonus to apply to all targets, so bypass spec_applies() */
-        iv.spec_dbon_applies = TRUE;
+        icontext.spec_dbon_applies = TRUE;
     else
-        iv.spec_dbon_applies = spec_applies(weap, mon);
+        icontext.spec_dbon_applies = spec_applies(weap, mon);
 
-    if (iv.spec_dbon_applies)
+    if (icontext.spec_dbon_applies)
         return weap->attk.damd ? rnd((int) weap->attk.damd) : max(tmp, 1);
     return 0;
 }
@@ -976,14 +976,14 @@ char *hittee;              /* target's name: "you" or mon_nam(mdef) */
         scare_dieroll /= (1 << (mb->spe / 3));
     /* if target successfully resisted the artifact damage bonus,
        reduce overall likelihood of the assorted special effects */
-    if (!iv.spec_dbon_applies)
+    if (!icontext.spec_dbon_applies)
         dieroll += 1;
 
     /* might stun even when attempting a more severe effect, but
        in that case it will only happen if the other effect fails;
        extra damage will apply regardless; 3.4.1: sometimes might
        just probe even when it hasn't been enchanted */
-    do_stun = (max(mb->spe, 0) < rn2(iv.spec_dbon_applies ? 11 : 7));
+    do_stun = (max(mb->spe, 0) < rn2(icontext.spec_dbon_applies ? 11 : 7));
 
     /* the special effects also boost physical damage; increments are
        generally cumulative, but since the stun effect is based on a
@@ -1182,12 +1182,12 @@ int dieroll; /* needed for Magicbane and vorpal blades */
     if (attacks(AD_FIRE, otmp)) {
         if (realizes_damage)
             pline_The("fiery blade %s %s%c",
-                      !iv.spec_dbon_applies
+                      !icontext.spec_dbon_applies
                           ? "hits"
                           : (mdef->data == &mons[PM_WATER_ELEMENTAL])
                                 ? "vaporizes part of"
                                 : "burns",
-                      hittee, !iv.spec_dbon_applies ? '.' : '!');
+                      hittee, !icontext.spec_dbon_applies ? '.' : '!');
         if (!rn2(4))
             (void) destroy_mitem(mdef, POTION_CLASS, AD_FIRE);
         if (!rn2(4))
@@ -1201,8 +1201,8 @@ int dieroll; /* needed for Magicbane and vorpal blades */
     if (attacks(AD_COLD, otmp)) {
         if (realizes_damage)
             pline_The("ice-cold blade %s %s%c",
-                      !iv.spec_dbon_applies ? "hits" : "freezes", hittee,
-                      !iv.spec_dbon_applies ? '.' : '!');
+                      !icontext.spec_dbon_applies ? "hits" : "freezes", hittee,
+                      !icontext.spec_dbon_applies ? '.' : '!');
         if (!rn2(4))
             (void) destroy_mitem(mdef, POTION_CLASS, AD_COLD);
         return realizes_damage;
@@ -1210,9 +1210,9 @@ int dieroll; /* needed for Magicbane and vorpal blades */
     if (attacks(AD_ELEC, otmp)) {
         if (realizes_damage)
             pline_The("massive hammer hits%s %s%c",
-                      !iv.spec_dbon_applies ? "" : "!  Lightning strikes",
-                      hittee, !iv.spec_dbon_applies ? '.' : '!');
-        if (iv.spec_dbon_applies)
+                      !icontext.spec_dbon_applies ? "" : "!  Lightning strikes",
+                      hittee, !icontext.spec_dbon_applies ? '.' : '!');
+        if (icontext.spec_dbon_applies)
             wake_nearto(mdef->mx, mdef->my, 4 * 4);
         if (!rn2(5))
             (void) destroy_mitem(mdef, RING_CLASS, AD_ELEC);
@@ -1223,10 +1223,10 @@ int dieroll; /* needed for Magicbane and vorpal blades */
     if (attacks(AD_MAGM, otmp)) {
         if (realizes_damage)
             pline_The("imaginary widget hits%s %s%c",
-                      !iv.spec_dbon_applies
+                      !icontext.spec_dbon_applies
                           ? ""
                           : "!  A hail of magic missiles strikes",
-                      hittee, !iv.spec_dbon_applies ? '.' : '!');
+                      hittee, !icontext.spec_dbon_applies ? '.' : '!');
         return realizes_damage;
     }
 
@@ -1235,7 +1235,7 @@ int dieroll; /* needed for Magicbane and vorpal blades */
         return Mb_hit(magr, mdef, otmp, dmgptr, dieroll, vis, hittee);
     }
 
-    if (!iv.spec_dbon_applies) {
+    if (!icontext.spec_dbon_applies) {
         /* since damage bonus didn't apply, nothing more to do;
            no further attacks have side-effects on inventory */
         return FALSE;
index 76b8b6425760d81cec34d38a00a890eb3433b042..9256051b3e797b7d31a10340e12fcfda1ca2b61e 100644 (file)
@@ -64,7 +64,7 @@ do_statusline1()
         Strcpy(nb = eos(nb), rank());
 
     Sprintf(nb = eos(nb), "  ");
-    i = iv.mrank_sz + 15;
+    i = icontext.mrank_sz + 15;
     j = (int) ((nb + 2) - newbot1); /* strlen(newbot1) but less computation */
     if ((i - j) > 0)
         Sprintf(nb = eos(nb), "%*s", i - j, " "); /* pad with spaces */
@@ -345,7 +345,7 @@ max_rank_sz()
         if (urole.rank[i].f && (r = strlen(urole.rank[i].f)) > maxr)
             maxr = r;
     }
-    iv.mrank_sz = maxr;
+    icontext.mrank_sz = maxr;
     return;
 }
 
index a6c65196584689e3758ef1f41f8a9d5bb83290f1..2f52fc41fc3facac3fbc3f554ecc0208c3b9ca06 100644 (file)
@@ -325,51 +325,26 @@ decl_init()
     return;
 }
 
-#define UNDEFINED { 0 }         /* move to hack.h if we are keeping */
-#define UNDEFINED_PTR NULL      /* move to hack.h if we are keeping */
-#define IVMAGIC 0xdeadbeef
-
-const struct instance_variables iv_init = {
-    /* apply.c */
-    0,  /* jumping_is_magic */
-    -1, /* polearm_range_min */
-    -1, /* polearm_range_max  */
-    /* artifact.c */
-    0,  /* spec_dbon_applies */
-    /* botl.c */
-    0,  /* mrank_sz */
-    /* dog.c */
-    0,  /* petname_used */
-    /* mused.c */
-    FALSE, /* m_using */
-    /* pickup.c */
-    0,  /* oldcap */
-    /* trap.c */
-    0, /* force_mintrap */
-    /* u_init.c */
-    STRANGE_OBJECT, /* nocreate */
-    STRANGE_OBJECT, /* nocreate2 */
-    STRANGE_OBJECT, /* nocreate3 */
-    STRANGE_OBJECT, /* nocreate4 */
-    /* uhitm.c */
-    UNDEFINED, /* override_confirmation */
-    /* weapon.c */
-    UNDEFINED_PTR, /* propellor */
-    /* zap.c */
-    UNDEFINED, /* poly_zap */
-    UNDEFINED,  /* obj_zapped */
-
-    IVMAGIC  /* used to validate that structure layout has been preserved */
+const struct instance_context icontext_initial_state = {
+    0,  /* oldcap - last encumberance in pickup.c */
+    0,  /* petname_used - dog.c */
+    0,  /* jumping_is_magic - apply.c */
+    -1, /* polearm_range_min - apply.c */
+    -1, /* polearm_range_max - apply.c */
+    0,  /* spec_dbon_applies - artifact.c */
+    0,  /* mrank_sz - botl.c */
+    STRANGE_OBJECT, /* nocreate - ini_inv() in u_init.c */
+    STRANGE_OBJECT, /* nocreate2 - ini_inv() in u_init.c  */
+    STRANGE_OBJECT, /* nocreate3 - ini_inv() in u_init.c  */
+    STRANGE_OBJECT, /* nocreate4 - ini_inv() in u_init.c  */
 };
 
-struct instance_variables iv;
+struct instance_context icontext;
 
 void 
-instance_variable_init() 
+icontext_init() 
 {
-    iv = iv_init;
-
-    nhassert(iv_init.magic == IVMAGIC);
+    icontext = icontext_initial_state;
 
     sfcap = default_sfinfo;
     sfrestinfo = default_sfinfo;
index a5dadde704d750e4c9dba5743b29e211996625a3..79e6b781f4ea36f9b3c6a6e4e1009dfba967d7bd 100644 (file)
--- a/src/dog.c
+++ b/src/dog.c
@@ -197,7 +197,7 @@ makedog()
         put_saddle_on_mon(otmp, mtmp);
     }
 
-    if (!iv.petname_used++ && *petname)
+    if (!icontext.petname_used++ && *petname)
         mtmp = christen_monst(mtmp, petname);
 
     initedog(mtmp);
index 493850a1f21a7936b78486b9a6b96c8a74ab34c7..94b0350ad5c189e864a28761f63f1ccb1544d26d 100644 (file)
@@ -8,6 +8,8 @@
 
 #include "hack.h"
 
+boolean m_using = FALSE;
+
 /* Let monsters use magic items.  Arbitrary assumptions: Monsters only use
  * scrolls when they can see, monsters know when wands have 0 charges,
  * monsters cannot recognize if items are cursed are not, monsters which
@@ -668,12 +670,12 @@ struct monst *mtmp;
         zap_oseen = oseen;
         mzapmsg(mtmp, otmp, FALSE);
         otmp->spe--;
-        iv.m_using = TRUE;
+        m_using = TRUE;
         mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp);
         /* monster learns that teleportation isn't useful here */
         if (level.flags.noteleport)
             mtmp->mtrapseen |= (1 << (TELEP_TRAP - 1));
-        iv.m_using = FALSE;
+        m_using = FALSE;
         return 2;
     case MUSE_SCR_TELEPORTATION: {
         int obj_is_cursed = otmp->cursed;
@@ -1397,11 +1399,11 @@ struct monst *mtmp;
         otmp->spe--;
         if (oseen)
             makeknown(otmp->otyp);
-        iv.m_using = TRUE;
+        m_using = TRUE;
         buzz((int) (-30 - (otmp->otyp - WAN_MAGIC_MISSILE)),
              (otmp->otyp == WAN_MAGIC_MISSILE) ? 2 : 6, mtmp->mx, mtmp->my,
              sgn(mtmp->mux - mtmp->mx), sgn(mtmp->muy - mtmp->my));
-        iv.m_using = FALSE;
+        m_using = FALSE;
         return (DEADMONSTER(mtmp)) ? 1 : 2;
     case MUSE_FIRE_HORN:
     case MUSE_FROST_HORN:
@@ -1411,20 +1413,20 @@ struct monst *mtmp;
         } else
             You_hear("a horn being played.");
         otmp->spe--;
-        iv.m_using = TRUE;
+        m_using = TRUE;
         buzz(-30 - ((otmp->otyp == FROST_HORN) ? AD_COLD - 1 : AD_FIRE - 1),
              rn1(6, 6), mtmp->mx, mtmp->my, sgn(mtmp->mux - mtmp->mx),
              sgn(mtmp->muy - mtmp->my));
-        iv.m_using = FALSE;
+        m_using = FALSE;
         return (DEADMONSTER(mtmp)) ? 1 : 2;
     case MUSE_WAN_TELEPORTATION:
     case MUSE_WAN_STRIKING:
         zap_oseen = oseen;
         mzapmsg(mtmp, otmp, FALSE);
         otmp->spe--;
-        iv.m_using = TRUE;
+        m_using = TRUE;
         mbhit(mtmp, rn1(8, 6), mbhitm, bhito, otmp);
-        iv.m_using = FALSE;
+        m_using = FALSE;
         return 2;
     case MUSE_SCR_EARTH: {
         /* TODO: handle steeds */
index 42bc59256ca8f167275ddb27fb0df41df2e0f73f..83d5eb2735abc742a63d0ad037d288526fc559ec 100644 (file)
@@ -1558,7 +1558,7 @@ encumber_msg()
 {
     int newcap = near_capacity();
 
-    if (iv.oldcap < newcap) {
+    if (icontext.oldcap < newcap) {
         switch (newcap) {
         case 1:
             Your("movements are slowed slightly because of your load.");
@@ -1576,7 +1576,7 @@ encumber_msg()
             break;
         }
         context.botl = 1;
-    } else if (iv.oldcap > newcap) {
+    } else if (icontext.oldcap > newcap) {
         switch (newcap) {
         case 0:
             Your("movements are now unencumbered.");
@@ -1595,7 +1595,7 @@ encumber_msg()
         context.botl = 1;
     }
 
-    iv.oldcap = newcap;
+    icontext.oldcap = newcap;
     return newcap;
 }
 
index 35992d8e666545319713b0fca63340e5cf7f81ce..557cb3219310c84e40c5b35cc8334aebc020d38c 100644 (file)
@@ -899,7 +899,7 @@ register int fd;
 #ifdef MFLOPPY
     gameDiskPrompt();
 #endif
-    max_rank_sz(); /* to recompute iv.mrank_sz (botl.c) */
+    max_rank_sz(); /* to recompute icontext.mrank_sz (botl.c) */
     /* take care of iron ball & chain */
     for (otmp = fobj; otmp; otmp = otmp->nobj)
         if (otmp->owornmask)
index c6ba82ea0b5b9cdc45c08d0375e3aacc47103881..330fa73e27a6bd610a71c9d7c1fd4e97a6755f13 100644 (file)
@@ -39,6 +39,9 @@ STATIC_DCL boolean FDECL(thitm, (int, struct monst *, struct obj *, int,
                                  BOOLEAN_P));
 STATIC_DCL void NDECL(maybe_finish_sokoban);
 
+/* mintrap() should take a flags argument, but for time being we use this */
+STATIC_VAR int force_mintrap = 0;
+
 STATIC_VAR const char *const a_your[2] = { "a", "your" };
 STATIC_VAR const char *const A_Your[2] = { "A", "Your" };
 STATIC_VAR const char tower_of_flame[] = "tower of flame";
@@ -2160,7 +2163,7 @@ register struct monst *mtmp;
     } else {
         register int tt = trap->ttyp;
         boolean in_sight, tear_web, see_it,
-            inescapable = iv.force_mintrap || ((tt == HOLE || tt == PIT)
+            inescapable = force_mintrap || ((tt == HOLE || tt == PIT)
                                             && Sokoban && !trap->madeby_u);
         const char *fallverb;
 
@@ -2276,7 +2279,7 @@ register struct monst *mtmp;
                         || mptr == &mons[PM_BUGBEAR])
                         You_hear("the roaring of an angry bear!");
                 }
-            } else if (iv.force_mintrap) {
+            } else if (force_mintrap) {
                 if (in_sight) {
                     pline("%s evades %s bear trap!", Monnam(mtmp),
                           a_your[trap->madeby_u]);
@@ -2425,7 +2428,7 @@ register struct monst *mtmp;
             if (is_flyer(mptr) || is_floater(mptr)
                 || (mtmp->wormno && count_wsegs(mtmp) > 5)
                 || is_clinger(mptr)) {
-                if (iv.force_mintrap && !Sokoban) {
+                if (force_mintrap && !Sokoban) {
                     /* openfallingtrap; not inescapable here */
                     if (in_sight) {
                         seetrap(trap);
@@ -2462,7 +2465,7 @@ register struct monst *mtmp;
             if (is_flyer(mptr) || is_floater(mptr) || mptr == &mons[PM_WUMPUS]
                 || (mtmp->wormno && count_wsegs(mtmp) > 5)
                 || mptr->msize >= MZ_HUGE) {
-                if (iv.force_mintrap && !Sokoban) {
+                if (force_mintrap && !Sokoban) {
                     /* openfallingtrap; not inescapable here */
                     if (in_sight) {
                         seetrap(trap);
@@ -2551,7 +2554,7 @@ register struct monst *mtmp;
                           a_your[trap->madeby_u]);
                 deltrap(trap);
                 newsym(mtmp->mx, mtmp->my);
-            } else if (iv.force_mintrap && !mtmp->mtrapped) {
+            } else if (force_mintrap && !mtmp->mtrapped) {
                 if (in_sight) {
                     pline("%s avoids %s spider web!", Monnam(mtmp),
                           a_your[trap->madeby_u]);
@@ -4686,9 +4689,9 @@ boolean *noticed; /* set to true iff hero notices the effect; */
         /* dotrap calls mintrap when mounted hero encounters a web */
         if (u.usteed)
             dotrapflags |= NOWEBMSG;
-        ++iv.force_mintrap;
+        ++force_mintrap;
         dotrap(t, dotrapflags);
-        --iv.force_mintrap;
+        --force_mintrap;
         result = (u.utrap != 0);
     } else {
         if (mon->mtrapped)
@@ -4696,9 +4699,9 @@ boolean *noticed; /* set to true iff hero notices the effect; */
         /* you notice it if you see the trap close/tremble/whatever
            or if you sense the monster who becomes trapped */
         *noticed = cansee(t->tx, t->ty) || canspotmon(mon);
-        ++iv.force_mintrap;
+        ++force_mintrap;
         result = (mintrap(mon) != 0);
-        --iv.force_mintrap;
+        --force_mintrap;
     }
     return result;
 }
@@ -4739,9 +4742,9 @@ boolean *noticed; /* set to true iff hero notices the effect; */
         *noticed = cansee(t->tx, t->ty) || canspotmon(mon);
         /* monster will be angered; mintrap doesn't handle that */
         wakeup(mon, TRUE);
-        ++iv.force_mintrap;
+        ++force_mintrap;
         result = (mintrap(mon) != 0);
-        --iv.force_mintrap;
+        --force_mintrap;
         /* mon might now be on the migrating monsters list */
     }
     return result;
index a522ac0add72994c694ed539e60897194c43cf06..9d38214eda56e0acb38943791d79a850882a1733 100644 (file)
@@ -991,9 +991,9 @@ register struct trobj *trop;
              */
             obj = mkobj(trop->trclass, FALSE);
             otyp = obj->otyp;
-            while (otyp == WAN_WISHING || otyp == iv.nocreate
-                   || otyp == iv.nocreate2 || otyp == iv.nocreate3
-                   || otyp == iv.nocreate4 || otyp == RIN_LEVITATION
+            while (otyp == WAN_WISHING || otyp == icontext.nocreate
+                   || otyp == icontext.nocreate2 || otyp == icontext.nocreate3
+                   || otyp == icontext.nocreate4 || otyp == RIN_LEVITATION
                    /* 'useless' items */
                    || otyp == POT_HALLUCINATION
                    || otyp == POT_ACID
@@ -1035,16 +1035,16 @@ register struct trobj *trop;
             case WAN_POLYMORPH:
             case RIN_POLYMORPH:
             case POT_POLYMORPH:
-                iv.nocreate = RIN_POLYMORPH_CONTROL;
+                icontext.nocreate = RIN_POLYMORPH_CONTROL;
                 break;
             case RIN_POLYMORPH_CONTROL:
-                iv.nocreate = RIN_POLYMORPH;
-                iv.nocreate2 = SPE_POLYMORPH;
-                iv.nocreate3 = POT_POLYMORPH;
+                icontext.nocreate = RIN_POLYMORPH;
+                icontext.nocreate2 = SPE_POLYMORPH;
+                icontext.nocreate3 = POT_POLYMORPH;
             }
             /* Don't have 2 of the same ring or spellbook */
             if (obj->oclass == RING_CLASS || obj->oclass == SPBOOK_CLASS)
-                iv.nocreate4 = otyp;
+                icontext.nocreate4 = otyp;
         }
 
         if (urace.malenum != PM_HUMAN) {
index 4328b00ec5d9958c49a74c5d088a8b2f1ee40cac..a14218543adbb42c04ce1413b8479f600303c73f 100644 (file)
@@ -26,6 +26,9 @@ STATIC_DCL boolean FDECL(shade_aware, (struct obj *));
 
 extern boolean notonhead; /* for long worms */
 
+/* Used to flag attacks caused by Stormbringer's maliciousness. */
+static boolean override_confirmation = FALSE;
+
 #define PROJECTILE(obj) ((obj) && is_ammo(obj))
 
 void
@@ -198,7 +201,7 @@ struct obj *wep; /* uwep for attack(), null for kick_monster() */
         && !Stunned) {
         /* Intelligent chaotic weapons (Stormbringer) want blood */
         if (wep && wep->oartifact == ART_STORMBRINGER) {
-            iv.override_confirmation = TRUE;
+            override_confirmation = TRUE;
             return FALSE;
         }
         if (canspotmon(mtmp)) {
@@ -367,7 +370,7 @@ register struct monst *mtmp;
 
     /* possibly set in attack_checks;
        examined in known_hitum, called via hitum or hmonas below */
-    iv.override_confirmation = FALSE;
+    override_confirmation = FALSE;
     /* attack_checks() used to use <u.ux+u.dx,u.uy+u.dy> directly, now
        it uses bhitpos instead; it might map an invisible monster there */
     bhitpos.x = u.ux + u.dx;
@@ -448,7 +451,7 @@ int dieroll;
 {
     register boolean malive = TRUE;
 
-    if (iv.override_confirmation) {
+    if (override_confirmation) {
         /* this may need to be generalized if weapons other than
            Stormbringer acquire similar anti-social behavior... */
         if (flags.verbose)
@@ -601,7 +604,7 @@ struct attack *uattk;
     /* second attack for two-weapon combat; won't occur if Stormbringer
        overrode confirmation (assumes Stormbringer is primary weapon)
        or if the monster was killed or knocked to different location */
-    if (u.twoweap && !iv.override_confirmation && malive && m_at(x, y) == mon) {
+    if (u.twoweap && !override_confirmation && malive && m_at(x, y) == mon) {
         tmp = find_roll_to_hit(mon, uattk->aatyp, uswapwep, &attknum,
                                &armorpenalty);
         dieroll = rnd(20);
index 2bdd2e549437ca7da8336f562c9891268c85e634..a590366bb131bcfa1d3b7c55f3705c7df1cd1169 100644 (file)
@@ -387,6 +387,8 @@ static NEARDATA const int pwep[] = { HALBERD,       BARDICHE, SPETUM,
                                      BEC_DE_CORBIN, FAUCHARD, PARTISAN,
                                      LANCE };
 
+static struct obj *propellor;
+
 /* select a ranged weapon for the monster */
 struct obj *
 select_rwep(mtmp)
@@ -399,7 +401,7 @@ register struct monst *mtmp;
 
     char mlet = mtmp->data->mlet;
 
-    iv.propellor = &zeroobj;
+    propellor = &zeroobj;
     Oselect(EGG);      /* cockatrice egg */
     if (mlet == S_KOP) /* pies are first choice for Kops */
         Oselect(CREAM_PIE);
@@ -431,7 +433,7 @@ register struct monst *mtmp;
                     || !mon_hates_silver(mtmp))) {
                 if ((otmp = oselect(mtmp, pwep[i])) != 0
                     && (otmp == mwep || !mweponly)) {
-                    iv.propellor = otmp; /* force the monster to wield it */
+                    propellor = otmp; /* force the monster to wield it */
                     return otmp;
                 }
             }
@@ -452,41 +454,41 @@ register struct monst *mtmp;
             for (otmp = mtmp->minvent; otmp; otmp = otmp->nobj)
                 if (otmp->oclass == GEM_CLASS
                     && (otmp->otyp != LOADSTONE || !otmp->cursed)) {
-                    iv.propellor = m_carrying(mtmp, SLING);
+                    propellor = m_carrying(mtmp, SLING);
                     return otmp;
                 }
         }
 
         /* KMH -- This belongs here so darts will work */
-        iv.propellor = &zeroobj;
+        propellor = &zeroobj;
 
         prop = (objects[rwep[i]]).oc_skill;
         if (prop < 0) {
             switch (-prop) {
             case P_BOW:
-                iv.propellor = (oselect(mtmp, YUMI));
-                if (!iv.propellor)
-                    iv.propellor = (oselect(mtmp, ELVEN_BOW));
-                if (!iv.propellor)
-                    iv.propellor = (oselect(mtmp, BOW));
-                if (!iv.propellor)
-                    iv.propellor = (oselect(mtmp, ORCISH_BOW));
+                propellor = (oselect(mtmp, YUMI));
+                if (!propellor)
+                    propellor = (oselect(mtmp, ELVEN_BOW));
+                if (!propellor)
+                    propellor = (oselect(mtmp, BOW));
+                if (!propellor)
+                    propellor = (oselect(mtmp, ORCISH_BOW));
                 break;
             case P_SLING:
-                iv.propellor = (oselect(mtmp, SLING));
+                propellor = (oselect(mtmp, SLING));
                 break;
             case P_CROSSBOW:
-                iv.propellor = (oselect(mtmp, CROSSBOW));
+                propellor = (oselect(mtmp, CROSSBOW));
             }
-            if ((otmp = MON_WEP(mtmp)) && mwelded(otmp) && otmp != iv.propellor
+            if ((otmp = MON_WEP(mtmp)) && mwelded(otmp) && otmp != propellor
                 && mtmp->weapon_check == NO_WEAPON_WANTED)
-                iv.propellor = 0;
+                propellor = 0;
         }
         /* propellor = obj, propellor to use
          * propellor = &zeroobj, doesn't need a propellor
          * propellor = 0, needed one and didn't have one
          */
-        if (iv.propellor != 0) {
+        if (propellor != 0) {
             /* Note: cannot use m_carrying for loadstones, since it will
              * always select the first object of a type, and maybe the
              * monster is carrying two but only the first is unthrowable.
@@ -633,7 +635,7 @@ register struct monst *mon;
         break;
     case NEED_RANGED_WEAPON:
         (void) select_rwep(mon);
-        obj = iv.propellor;
+        obj = propellor;
         break;
     case NEED_PICK_AXE:
         obj = m_carrying(mon, PICK_AXE);
index f2c6f47dd12b082330d8bc6c7c3a361760d41a62..d53468fe38d2658d685d30647a4efe5a7ec541ae 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
  */
 #define MAGIC_COOKIE 1000
 
+static NEARDATA boolean obj_zapped;
+static NEARDATA int poly_zapped;
+
 extern boolean notonhead; /* for long worms */
 
+/* kludge to use mondied instead of killed */
+extern boolean m_using;
+
 STATIC_DCL void FDECL(polyuse, (struct obj *, int, int));
 STATIC_DCL void FDECL(create_polymon, (struct obj *, int));
 STATIC_DCL int FDECL(stone_to_flesh_obj, (struct obj *));
@@ -1360,13 +1366,13 @@ struct obj *obj;
     if (obj->otyp == SCR_MAIL)
         return;
 #endif
-    iv.obj_zapped = TRUE;
+    obj_zapped = TRUE;
 
-    if (iv.poly_zapped < 0) {
+    if (poly_zapped < 0) {
         /* some may metamorphosize */
         for (i = obj->quan; i; i--)
             if (!rn2(Luck + 45)) {
-                iv.poly_zapped = objects[obj->otyp].oc_material;
+                poly_zapped = objects[obj->otyp].oc_material;
                 break;
             }
     }
@@ -2065,7 +2071,7 @@ schar zz;
             learnwand(obj);
     }
 
-    iv.poly_zapped = -1;
+    poly_zapped = -1;
     for (otmp = level.objects[tx][ty]; otmp; otmp = next_obj) {
         next_obj = otmp->nexthere;
         /* for zap downwards, don't hit object poly'd hero is hiding under */
@@ -2075,8 +2081,8 @@ schar zz;
 
         hitanything += (*fhito)(otmp, obj);
     }
-    if (iv.poly_zapped >= 0)
-        create_polymon(level.objects[tx][ty], iv.poly_zapped);
+    if (poly_zapped >= 0)
+        create_polymon(level.objects[tx][ty], poly_zapped);
 
     return hitanything;
 }
@@ -2950,16 +2956,16 @@ struct obj *obj; /* wand or spell */
 void
 zapsetup()
 {
-    iv.obj_zapped = FALSE;
+    obj_zapped = FALSE;
 }
 
 void
 zapwrapup()
 {
     /* if do_osshock() set obj_zapped while polying, give a message now */
-    if (iv.obj_zapped)
+    if (obj_zapped)
         You_feel("shuddering vibrations.");
-    iv.obj_zapped = FALSE;
+    obj_zapped = FALSE;
 }
 
 /* called for various wand and spell effects - M. Stephenson */
@@ -5035,7 +5041,7 @@ int damage, tell;
     if (damage) {
         mtmp->mhp -= damage;
         if (DEADMONSTER(mtmp)) {
-            if (iv.m_using)
+            if (m_using)
                 monkilled(mtmp, "", AD_RBRE);
             else
                 killed(mtmp);
index bd7ee0a74f8463e7611e309708b4b0998e2a8649..932ec971e5aa7b48cb35e4452f904cbcebaebaf9 100644 (file)
@@ -97,7 +97,7 @@ char *argv[];
 
     nethack_enter(argc, argv);
 
-    instance_variable_init();
+    icontext_init();
     sys_early_init();
 
 #if defined(WIN32) && defined(TTY_GRAPHICS)
index 466044ec2cab9733538b8be02e3d2963f103f1ae..ef48d6b639a4df1e96957e7b9786a316b1d48ed8 100644 (file)
@@ -97,7 +97,7 @@ WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine,
 
     win10_init();
 
-    instance_variable_init();
+    icontext_init();
     sys_early_init();
 
     /* init applicatio structure */