]> granicus.if.org Git - nethack/commitdiff
WIZKIT overflow tweak (trunk only)
authornethack.rankin <nethack.rankin>
Tue, 19 Jun 2007 03:13:20 +0000 (03:13 +0000)
committernethack.rankin <nethack.rankin>
Tue, 19 Jun 2007 03:13:20 +0000 (03:13 +0000)
     Redo the $WIZKIT overflow handling from a few days ago.  Instead of
having two migration codes which both mean "with the hero", combine them
and add a mask flag to control scattering at the destination to be able to
get the alternate behavior.

include/dungeon.h
src/dog.c
src/dokick.c
src/files.c

index ed38f6e883d6486c60119e4974d6fc4379a6bde8..e7d12d7061fc07549cd01c10dd02c371b855658e 100644 (file)
@@ -141,9 +141,9 @@ typedef struct branch {
 #define MIGR_LADDER_DOWN       6
 #define MIGR_SSTAIRS           7       /* dungeon branch */
 #define MIGR_PORTAL            8       /* magic portal */
-#define MIGR_NEAR_PLAYER       9       /* mon: followers; obj: trap door */
-#define MIGR_AT_HERO          10       /* wizkit overflow */
+#define MIGR_WITH_HERO 9       /* mon: followers; obj: trap door */
 #define MIGR_NOBREAK        1024       /* bitmask: don't break on delivery */
+#define MIGR_NOSCATTER    2048 /* don't scatter on delivery */
 
 /* level information (saved via ledger number) */
 
index bdcd0be92e61dffcf3bfeafd3da62b5c474cfa1c..5fd97fb9391db5d97fef7c44a77a7fcc30172ab2 100644 (file)
--- a/src/dog.c
+++ b/src/dog.c
@@ -317,7 +317,7 @@ boolean with_you;
                break;
         case MIGR_EXACT_XY:    wander = 0;
                break;
-        case MIGR_NEAR_PLAYER: xlocale = u.ux,  ylocale = u.uy;
+        case MIGR_WITH_HERO:   xlocale = u.ux,  ylocale = u.uy;
                break;
         case MIGR_STAIRS_UP:   xlocale = xupstair,  ylocale = yupstair;
                break;
index 6f8d0c39045fc8a0b7c2f365255a5b0d43195d2b..7eb94a680c0929da8e7e52d87cac7690c3612aab 100644 (file)
@@ -1207,7 +1207,7 @@ xchar dlev;                               /* if !0 send to dlev near player */
                /* send objects next to player falling through trap door.
                 * checked in obj_delivery().
                 */
-               toloc = MIGR_NEAR_PLAYER;
+               toloc = MIGR_WITH_HERO;
                cc.y = dlev;
        }
 
@@ -1429,32 +1429,31 @@ boolean near_hero;
 {
        register struct obj *otmp, *otmp2;
        register int nx, ny;
-       long where;
-       boolean nobreak, noscatter = FALSE;
+       int where;
+       boolean nobreak, noscatter;
 
        for (otmp = migrating_objs; otmp; otmp = otmp2) {
            otmp2 = otmp->nobj;
            if (otmp->ox != u.uz.dnum || otmp->oy != u.uz.dlevel) continue;
 
-           where = otmp->owornmask;            /* destination code */
+           where = (int)(otmp->owornmask & 0x7fffL);   /* destination code */
            nobreak = (where & MIGR_NOBREAK) != 0;
-           where &= ~MIGR_NOBREAK;
+           noscatter = (where & MIGR_WITH_HERO) != 0;
+           where &= ~(MIGR_NOBREAK | MIGR_NOSCATTER);
 
-           if ((!near_hero && where == MIGR_NEAR_PLAYER) ||
-               (near_hero && where != MIGR_NEAR_PLAYER)) continue;
+           if (!near_hero ^ (where == MIGR_WITH_HERO)) continue;
 
            obj_extract_self(otmp);
            otmp->owornmask = 0L;
 
-           switch ((int)where) {
+           switch (where) {
             case MIGR_STAIRS_UP:   nx = xupstair,  ny = yupstair;
                                break;
             case MIGR_LADDER_UP:   nx = xupladder,  ny = yupladder;
                                break;
             case MIGR_SSTAIRS:     nx = sstairs.sx,  ny = sstairs.sy;
                                break;
-            case MIGR_AT_HERO:     noscatter = TRUE; /*FALLTHRU*/
-            case MIGR_NEAR_PLAYER: nx = u.ux,  ny = u.uy;
+            case MIGR_WITH_HERO:    nx = u.ux,  ny = u.uy;
                                break;
             default:
             case MIGR_RANDOM:      nx = ny = 0;
@@ -1463,7 +1462,7 @@ boolean near_hero;
            if (nx > 0) {
                place_object(otmp, nx, ny);
                if (!nobreak && !IS_SOFT(levl[nx][ny].typ)) {
-                   if (where == MIGR_NEAR_PLAYER) {
+                   if (where == MIGR_WITH_HERO) {
                        if (breaks(otmp, nx, ny)) continue;
                    } else if (breaktest(otmp)) {
                        /* assume it broke before player arrived, no messages */
index 9f4b89c88c4099b3e2e71c91ca3bbe2ed9413377..3b4ac6acb22475d9f7daa3b29e1352bf86ca09c4 100644 (file)
@@ -2428,7 +2428,7 @@ struct obj *obj;
        add_to_migration(obj);
        obj->ox = 0;    /* index of main dungeon */
        obj->oy = 1;    /* starting level number */
-       obj->owornmask = (long)(MIGR_AT_HERO|MIGR_NOBREAK);
+       obj->owornmask = (long)(MIGR_WITH_HERO | MIGR_NOBREAK|MIGR_NOSCATTER);
     } else {
        (void)addinv(obj);
     }