]> granicus.if.org Git - nethack/commitdiff
remove pointer to long conversions - part 2 of 3 (trunk only)
authornethack.allison <nethack.allison>
Sun, 9 Jul 2006 01:02:51 +0000 (01:02 +0000)
committernethack.allison <nethack.allison>
Sun, 9 Jul 2006 01:02:51 +0000 (01:02 +0000)
Remove some more code that forced pointers into a long int, and
vice versa where information could be lost (P64 platforms such as
WIN64 have a 64 bit pointer size, but a 32 bit long size.)

This 2nd part deals with timeout functions switching
some arguments from type genericptr_t to 'anything'.

Like part 1, this needs to increment EDITLEVEL in patchlevel.h.

include/extern.h
include/patchlevel.h
include/timeout.h
src/apply.c
src/dig.c
src/do.c
src/invent.c
src/mkobj.c
src/pickup.c
src/timeout.c
src/zap.c

index f736bea67f4474fafae146b3ffb28e7a85f055af..f7a3ccfaf8ea850d8b9cb7413dee6fbd3a629248 100644 (file)
@@ -46,7 +46,7 @@ E boolean FDECL(catch_lit, (struct obj *));
 E void FDECL(use_unicorn_horn, (struct obj *));
 E boolean FDECL(tinnable, (struct obj *));
 E void NDECL(reset_trapset);
-E void FDECL(fig_transform, (genericptr_t, long));
+E void FDECL(fig_transform, (ANY_P *, long));
 E int FDECL(unfixable_trouble_count,(BOOLEAN_P));
 
 /* ### artifact.c ### */
@@ -263,8 +263,8 @@ E void NDECL(zap_dig);
 E struct obj *FDECL(bury_an_obj, (struct obj *));
 E void FDECL(bury_objs, (int,int));
 E void FDECL(unearth_objs, (int,int));
-E void FDECL(rot_organic, (genericptr_t, long));
-E void FDECL(rot_corpse, (genericptr_t, long));
+E void FDECL(rot_organic, (ANY_P *, long));
+E void FDECL(rot_corpse, (ANY_P *, long));
 E struct obj *FDECL(buried_ball, (coord *));
 E void NDECL(buried_ball_to_punishment);
 E void NDECL(buried_ball_to_freedom);
@@ -340,7 +340,7 @@ E void FDECL(schedule_goto, (d_level *,BOOLEAN_P,BOOLEAN_P,int,
                             const char *,const char *));
 E void NDECL(deferred_goto);
 E boolean FDECL(revive_corpse, (struct obj *));
-E void FDECL(revive_mon, (genericptr_t, long));
+E void FDECL(revive_mon, (ANY_P *, long));
 E int NDECL(donull);
 E int NDECL(dowipe);
 E void FDECL(set_wounded_legs, (long,int));
@@ -2119,15 +2119,15 @@ E void FDECL(fall_asleep, (int, BOOLEAN_P));
 E void FDECL(attach_egg_hatch_timeout, (struct obj *));
 E void FDECL(attach_fig_transform_timeout, (struct obj *));
 E void FDECL(kill_egg, (struct obj *));
-E void FDECL(hatch_egg, (genericptr_t, long));
+E void FDECL(hatch_egg, (ANY_P *, long));
 E void FDECL(learn_egg_type, (int));
-E void FDECL(burn_object, (genericptr_t, long));
+E void FDECL(burn_object, (ANY_P *, long));
 E void FDECL(begin_burn, (struct obj *, BOOLEAN_P));
 E void FDECL(end_burn, (struct obj *, BOOLEAN_P));
 E void NDECL(do_storms);
-E boolean FDECL(start_timer, (long, SHORT_P, SHORT_P, genericptr_t));
-E long FDECL(stop_timer, (SHORT_P, genericptr_t));
-E long FDECL(peek_timer, (SHORT_P,genericptr_t));
+E boolean FDECL(start_timer, (long, SHORT_P, SHORT_P, ANY_P *));
+E long FDECL(stop_timer, (SHORT_P, ANY_P *));
+E long FDECL(peek_timer, (SHORT_P,ANY_P *));
 E void NDECL(run_timers);
 E void FDECL(obj_move_timers, (struct obj *, struct obj *));
 E void FDECL(obj_split_timers, (struct obj *, struct obj *));
@@ -2549,7 +2549,7 @@ E int FDECL(burn_floor_paper, (int,int,BOOLEAN_P,BOOLEAN_P));
 E void FDECL(buzz, (int,int,XCHAR_P,XCHAR_P,int,int));
 E void FDECL(melt_ice, (XCHAR_P,XCHAR_P,const char *));
 E void FDECL(start_melt_ice_timeout, (XCHAR_P,XCHAR_P));
-E void FDECL(melt_ice_away, (genericptr_t, long));
+E void FDECL(melt_ice_away, (ANY_P *, long));
 E int FDECL(zap_over_floor, (XCHAR_P,XCHAR_P,int,boolean *,SHORT_P));
 E void FDECL(fracture_rock, (struct obj *));
 E boolean FDECL(break_statue, (struct obj *));
index a069886c18ded003781b209de097a9f05e679d50..21a39aa88abf7099afb99dfa1ce516f9cdb1b98d 100644 (file)
@@ -13,7 +13,7 @@
  * Incrementing EDITLEVEL can be used to force invalidation of old bones
  * and save files.
  */
-#define EDITLEVEL      34
+#define EDITLEVEL      35
 
 #define COPYRIGHT_BANNER_A \
 "NetHack, Copyright 1985-2006"
index 9ed95fa00758289c1c5e6247551797d3724d6404..85a652f1ba9fd276c7a074018b99c903843be134 100644 (file)
@@ -6,7 +6,7 @@
 #define TIMEOUT_H
 
 /* generic timeout function */
-typedef void FDECL((*timeout_proc), (genericptr_t, long));
+typedef void FDECL((*timeout_proc), (ANY_P *, long));
 
 /* kind of timer */
 #define TIMER_LEVEL    0       /* event specific to level */
@@ -38,7 +38,7 @@ typedef struct fe {
     unsigned long tid;         /* timer ID */
     short kind;                        /* kind of use */
     short func_index;          /* what to call when we time out */
-    genericptr_t arg;          /* pointer to timeout argument */
+    anything arg;              /* pointer to timeout argument */
     Bitfield (needs_fixup,1);  /* does arg need to be patched? */
 } timer_element;
 
index e61b42e91d7ca13159d7de6fa6c2ec47df2e4aad..0e4271782d98c8f18db334c8bb4d5c4356916f5c 100644 (file)
@@ -1702,10 +1702,10 @@ struct obj *obj;
  */
 void
 fig_transform(arg, timeout)
-genericptr_t arg;
+anything *arg;
 long timeout;
 {
-       struct obj *figurine = (struct obj *)arg;
+       struct obj *figurine = arg->a_obj;
        struct monst *mtmp;
        coord cc;
        boolean cansee_spot, silent, okay_spot;
@@ -1729,7 +1729,7 @@ long timeout;
            !figurine_location_checks(figurine,&cc, TRUE)) {
                /* reset the timer to try again later */
                (void) start_timer((long)rnd(5000), TIMER_OBJECT,
-                               FIG_TRANSFORM, (genericptr_t)figurine);
+                               FIG_TRANSFORM, obj_to_any(figurine));
                return;
        }
 
@@ -1880,7 +1880,7 @@ struct obj **optr;
                "toss the figurine into the air" :
                "set the figurine on the ground"));
        (void) make_familiar(obj, cc.x, cc.y, FALSE);
-       (void) stop_timer(FIG_TRANSFORM, (genericptr_t)obj);
+       (void) stop_timer(FIG_TRANSFORM, obj_to_any(obj));
        useup(obj);
        *optr = 0;
 }
index 4f529f6518e764c9e95e7f37ee5d8b726d416f13..17a161ef91d2c28836275b14d33548d817d1b6c9 100644 (file)
--- a/src/dig.c
+++ b/src/dig.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)dig.c      3.5     2006/06/25      */
+/*     SCCS Id: @(#)dig.c      3.5     2006/07/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1636,7 +1636,7 @@ buried_ball_to_punishment()
 #if 0
                /* rusting buried metallic objects is not implemented yet */
                if (ball->timed)
-                       (void) stop_timer(RUST_METAL, (genericptr_t)ball);
+                       (void) stop_timer(RUST_METAL, obj_to_any(ball));
 #endif
                punish(ball);   /* use ball as flag for unearthed buried ball */
                u.utrap = 0;
@@ -1658,7 +1658,7 @@ buried_ball_to_freedom()
 #if 0
                /* rusting buried metallic objects is not implemented yet */
                if (ball->timed)
-                       (void) stop_timer(RUST_METAL, (genericptr_t)ball);
+                       (void) stop_timer(RUST_METAL, obj_to_any(ball));
 #endif
                place_object(ball, cc.x, cc.y);
                stackobj(ball);
@@ -1723,13 +1723,13 @@ bury_an_obj(otmp)
        } else if ((under_ice ? otmp->oclass == POTION_CLASS : is_organic(otmp))
                && !obj_resists(otmp, 5, 95)) {
            (void) start_timer((under_ice ? 0L : 250L) + (long)rnd(250),
-                              TIMER_OBJECT, ROT_ORGANIC, (genericptr_t)otmp);
+                              TIMER_OBJECT, ROT_ORGANIC, obj_to_any(otmp));
        }
 #if 0
        /* rusting of buried metal not yet implemented */
        else if (is_rustprone(otmp)) {
            (void) start_timer((long)rnd(otmp->otyp == HEAVY_IRON_BALL ? 1500 : 250),
-                              TIMER_OBJECT, RUST_METAL, (genericptr_t)otmp);
+                              TIMER_OBJECT, RUST_METAL, obj_to_any(otmp));
        }
 #endif
        add_to_buried(otmp);
@@ -1775,7 +1775,7 @@ int x, y;
                    else {
                        obj_extract_self(otmp);
                        if (otmp->timed)
-                           (void) stop_timer(ROT_ORGANIC, (genericptr_t)otmp);
+                           (void) stop_timer(ROT_ORGANIC, obj_to_any(otmp));
                        place_object(otmp, x, y);
                        stackobj(otmp);
                    }
@@ -1797,10 +1797,10 @@ int x, y;
 /* ARGSUSED */
 void
 rot_organic(arg, timeout)
-genericptr_t arg;
+anything *arg;
 long timeout;  /* unused */
 {
-       struct obj *obj = (struct obj *) arg;
+       struct obj *obj = arg->a_obj;
 
        while (Has_contents(obj)) {
            /* We don't need to place contained object on the floor
@@ -1820,11 +1820,11 @@ long timeout;   /* unused */
  */
 void
 rot_corpse(arg, timeout)
-genericptr_t arg;
+anything *arg;
 long timeout;  /* unused */
 {
        xchar x = 0, y = 0;
-       struct obj *obj = (struct obj *) arg;
+       struct obj *obj = arg->a_obj;
        boolean on_floor = obj->where == OBJ_FLOOR,
                in_invent = obj->where == OBJ_INVENT;
 
index 20a576b925d6fa3d687a3241b7a8dd0e2de7a3f0..faa11fce43a23ddb6de4db003792bb9bb2b273c3 100644 (file)
--- a/src/do.c
+++ b/src/do.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)do.c       3.5     2006/06/25      */
+/*     SCCS Id: @(#)do.c       3.5     2006/07/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1585,10 +1585,10 @@ struct obj *corpse;
 /*ARGSUSED*/
 void
 revive_mon(arg, timeout)
-genericptr_t arg;
+anything *arg;
 long timeout;
 {
-    struct obj *body = (struct obj *) arg;
+    struct obj *body = arg->a_obj;
 
     /* if we succeed, the corpse is gone, otherwise, rot it away */
     if (!revive_corpse(body)) {
index 36b6de999bf682d435ecf8ff9adbf328073e2820..bb2b484d34210396202097762a317fc31bddf112 100644 (file)
@@ -517,7 +517,7 @@ struct obj *obj;
                set_moreluck();
                context.botl = 1;
        } else if (obj->otyp == FIGURINE && obj->timed) {
-               (void) stop_timer(FIG_TRANSFORM, (genericptr_t) obj);
+               (void) stop_timer(FIG_TRANSFORM, obj_to_any(obj));
        }
 }
 
index bf4c607441083695db10347ab4dac51ec7be2a85..d3cb373d99bd9d0009d013fd2aaec7622dd3180b 100644 (file)
@@ -269,8 +269,8 @@ struct obj *box;
                 */
                otmp->age = 0L;
                if (otmp->timed) {
-                   (void) stop_timer(ROT_CORPSE, (genericptr_t)otmp);
-                   (void) stop_timer(REVIVE_MON, (genericptr_t)otmp);
+                   (void) stop_timer(ROT_CORPSE, obj_to_any(otmp));
+                   (void) stop_timer(REVIVE_MON, obj_to_any(otmp));
                }
            } else {
                register int tprob;
@@ -943,7 +943,7 @@ start_corpse_timeout(body)
        }
        
        if (body->norevive) body->norevive = 0;
-       (void) start_timer(when, TIMER_OBJECT, action, (genericptr_t)body);
+       (void) start_timer(when, TIMER_OBJECT, action, obj_to_any(body));
 }
 
 void
@@ -960,7 +960,7 @@ register struct obj *otmp;
        else if (otmp->otyp == BAG_OF_HOLDING)
            otmp->owt = weight(otmp);
        else if (otmp->otyp == FIGURINE && otmp->timed)
-               (void) stop_timer(FIG_TRANSFORM, (genericptr_t) otmp);
+               (void) stop_timer(FIG_TRANSFORM, obj_to_any(otmp));
        return;
 }
 
@@ -1014,7 +1014,7 @@ register struct obj *otmp;
        else if (otmp->otyp == BAG_OF_HOLDING)
            otmp->owt = weight(otmp);
        else if (otmp->otyp == FIGURINE && otmp->timed)
-           (void) stop_timer(FIG_TRANSFORM, (genericptr_t) otmp);
+           (void) stop_timer(FIG_TRANSFORM, obj_to_any(otmp));
        return;
 }
 
@@ -1461,10 +1461,10 @@ int force;      /* 0 = no force so do checks, <0 = force off, >0 force on */
 
     /* Check for corpses just placed on or in ice */
     if (otmp->otyp == CORPSE && (on_floor || buried) && is_ice(x,y)) {
-       tleft = stop_timer(action, (genericptr_t)otmp);
+       tleft = stop_timer(action, obj_to_any(otmp));
        if (tleft == 0L) {
                action = REVIVE_MON;
-               tleft = stop_timer(action, (genericptr_t)otmp);
+               tleft = stop_timer(action, obj_to_any(otmp));
        } 
        if (tleft != 0L) {
            long age;
@@ -1487,10 +1487,10 @@ int force;      /* 0 = no force so do checks, <0 = force off, >0 force on */
     else if ((force < 0) ||
             (otmp->otyp == CORPSE && otmp->on_ice &&
             ((on_floor && !is_ice(x,y)) || !on_floor))) {
-       tleft = stop_timer(action, (genericptr_t)otmp);
+       tleft = stop_timer(action, obj_to_any(otmp));
        if (tleft == 0L) {
                action = REVIVE_MON;
-               tleft = stop_timer(action, (genericptr_t)otmp);
+               tleft = stop_timer(action, obj_to_any(otmp));
        }
        if (tleft != 0L) {
                long age;
@@ -1510,7 +1510,7 @@ int force;        /* 0 = no force so do checks, <0 = force off, >0 force on */
     }
     /* now re-start the timer with the appropriate modifications */ 
     if (restart_timer)
-       (void) start_timer(tleft, TIMER_OBJECT, action, (genericptr_t)otmp);
+       (void) start_timer(tleft, TIMER_OBJECT, action, obj_to_any(otmp));
 }
 
 #undef ROT_ICE_ADJUSTMENT
index db4fa6a2938e1ac12be9357b62b8c6d0e74a9e80..76e3e146344c06f99cdbe6075a1658e1571b871e 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)pickup.c   3.5     2006/06/17      */
+/*     SCCS Id: @(#)pickup.c   3.5     2006/07/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1885,8 +1885,8 @@ register struct obj *obj;
                obj->age = monstermoves - obj->age; /* actual age */
                /* stop any corpse timeouts when frozen */
                if (obj->otyp == CORPSE && obj->timed) {
-                       long rot_alarm = stop_timer(ROT_CORPSE, (genericptr_t)obj);
-                       (void) stop_timer(REVIVE_MON, (genericptr_t)obj);
+                       long rot_alarm = stop_timer(ROT_CORPSE, obj_to_any(obj));
+                       (void) stop_timer(REVIVE_MON, obj_to_any(obj));
                        /* mark a non-reviving corpse as such */
                        if (rot_alarm) obj->norevive = 1;
                }
index 38687de61fd23d3e914dc7a17d12a911f744f127..beb5c37641c81563c7e518c38da64d81db5c77a1 100644 (file)
@@ -12,7 +12,7 @@ STATIC_DCL void NDECL(slime_dialogue);
 STATIC_DCL void NDECL(slip_or_trip);
 STATIC_DCL void FDECL(see_lamp_flicker, (struct obj *, const char *));
 STATIC_DCL void FDECL(lantern_message, (struct obj *));
-STATIC_DCL void FDECL(cleanup_burn, (genericptr_t,long));
+STATIC_DCL void FDECL(cleanup_burn, (ANY_P *,long));
 
 /* He is being petrified - dialogue by inmet!tower */
 static NEARDATA const char * const stoned_texts[] = {
@@ -405,7 +405,7 @@ struct obj *egg;
        int i;
 
        /* stop previous timer, if any */
-       (void) stop_timer(HATCH_EGG, (genericptr_t) egg);
+       (void) stop_timer(HATCH_EGG, obj_to_any(egg));
 
        /*
         * Decide if and when to hatch the egg.  The old hatch_it() code tried
@@ -417,7 +417,7 @@ struct obj *egg;
            if (rnd(i) > 150) {
                /* egg will hatch */
                (void) start_timer((long)i, TIMER_OBJECT,
-                                               HATCH_EGG, (genericptr_t)egg);
+                                               HATCH_EGG, obj_to_any(egg));
                break;
            }
 }
@@ -428,13 +428,13 @@ kill_egg(egg)
 struct obj *egg;
 {
        /* stop previous timer, if any */
-       (void) stop_timer(HATCH_EGG, (genericptr_t) egg);
+       (void) stop_timer(HATCH_EGG, obj_to_any(egg));
 }
 
 /* timer callback routine: hatch the given egg */
 void
 hatch_egg(arg, timeout)
-genericptr_t arg;
+anything *arg;
 long timeout;
 {
        struct obj *egg;
@@ -445,7 +445,7 @@ long timeout;
        boolean cansee_hatchspot = FALSE;
        int i, mnum, hatchcount = 0;
 
-       egg = (struct obj *) arg;
+       egg = arg->a_obj;
        /* sterilized while waiting */
        if (egg->corpsenm == NON_PM) return;
 
@@ -587,9 +587,9 @@ long timeout;
                attach_egg_hatch_timeout(egg);
                if (egg->timed) {
                    /* replace ordinary egg timeout with a short one */
-                   (void) stop_timer(HATCH_EGG, (genericptr_t)egg);
+                   (void) stop_timer(HATCH_EGG, obj_to_any(egg));
                    (void) start_timer((long)rnd(12), TIMER_OBJECT,
-                                       HATCH_EGG, (genericptr_t)egg);
+                                       HATCH_EGG, obj_to_any(egg));
                }
            } else if (carried(egg)) {
                useup(egg);
@@ -622,7 +622,7 @@ struct obj *figurine;
        int i;
 
        /* stop previous timer, if any */
-       (void) stop_timer(FIG_TRANSFORM, (genericptr_t) figurine);
+       (void) stop_timer(FIG_TRANSFORM, obj_to_any(figurine));
 
        /*
         * Decide when to transform the figurine.
@@ -630,7 +630,7 @@ struct obj *figurine;
        i = rnd(9000) + 200;
        /* figurine will transform */
        (void) start_timer((long)i, TIMER_OBJECT,
-                               FIG_TRANSFORM, (genericptr_t)figurine);
+                               FIG_TRANSFORM, obj_to_any(figurine));
 }
 
 /* give a fumble message */
@@ -769,10 +769,10 @@ struct obj *obj;
  */
 void
 burn_object(arg, timeout)
-genericptr_t arg;
+anything *arg;
 long timeout;
 {
-       struct obj *obj = (struct obj *) arg;
+       struct obj *obj = arg->a_obj;
        boolean canseeit, many, menorah, need_newsym;
        xchar x, y;
        char whose[BUFSZ];
@@ -1128,7 +1128,7 @@ begin_burn(obj, already_lit)
 
        if (do_timer) {
            if (start_timer(turns, TIMER_OBJECT,
-                                       BURN_OBJECT, (genericptr_t)obj)) {
+                                       BURN_OBJECT, obj_to_any(obj))) {
                obj->lamplit = 1;
                obj->age -= turns;
                if (carried(obj) && !already_lit)
@@ -1174,7 +1174,7 @@ end_burn(obj, timer_attached)
            obj->lamplit = 0;
            if (obj->where == OBJ_INVENT)
                update_inventory();
-       } else if (!stop_timer(BURN_OBJECT, (genericptr_t) obj))
+       } else if (!stop_timer(BURN_OBJECT, obj_to_any(obj)))
            impossible("end_burn: obj %s not timed!", xname(obj));
 }
 
@@ -1183,10 +1183,10 @@ end_burn(obj, timer_attached)
  */
 static void
 cleanup_burn(arg, expire_time)
-    genericptr_t arg;
+    anything *arg;
     long expire_time;
 {
-    struct obj *obj = (struct obj *)arg;
+    struct obj *obj = arg->a_obj;
     if (!obj->lamplit) {
        impossible("cleanup_burn: obj %s not lit", xname(obj));
        return;
@@ -1254,7 +1254,7 @@ do_storms()
  *
  * General:
  *     boolean start_timer(long timeout,short kind,short func_index,
- *                                                     genericptr_t arg)
+ *                                                     anything *arg)
  *             Start a timer of kind 'kind' that will expire at time
  *             monstermoves+'timeout'.  Call the function at 'func_index'
  *             in the timeout table using argument 'arg'.  Return TRUE if
@@ -1262,13 +1262,13 @@ do_storms()
  *             "sooner" to "later".  If an object, increment the object's
  *             timer count.
  *
- *     long stop_timer(short func_index, genericptr_t arg)
+ *     long stop_timer(short func_index, anything *arg)
  *             Stop a timer specified by the (func_index, arg) pair.  This
  *             assumes that such a pair is unique.  Return the time the
  *             timer would have gone off.  If no timer is found, return 0.
  *             If an object, decrement the object's timer count.
  *
- *     long peek_timer(short func_index, genericptr_t arg)
+ *     long peek_timer(short func_index, anything *arg)
  *             Return time specified timer will go off (0 if no such timer).
  *
  *     void run_timers(void)
@@ -1311,7 +1311,7 @@ STATIC_DCL void FDECL(print_queue, (winid, timer_element *));
 #endif
 STATIC_DCL void FDECL(insert_timer, (timer_element *));
 STATIC_DCL timer_element *FDECL(remove_timer, (timer_element **, SHORT_P,
-                                                               genericptr_t));
+                                                               ANY_P *));
 STATIC_DCL void FDECL(write_timer, (int, timer_element *));
 STATIC_DCL boolean FDECL(mon_is_local, (struct monst *));
 STATIC_DCL boolean FDECL(timer_is_local, (timer_element *));
@@ -1379,12 +1379,12 @@ print_queue(win, base)
            Sprintf(buf, " %4ld   %4ld  %-6s %s(%s)",
                    curr->timeout, curr->tid, kind_name(curr->kind),
                    timeout_funcs[curr->func_index].name,
-                   fmt_ptr((genericptr_t)curr->arg));
+                   fmt_ptr((genericptr_t)curr->arg.a_void));
 #else
            Sprintf(buf, " %4ld   %4ld  %-6s #%d(%s)",
                    curr->timeout, curr->tid, kind_name(curr->kind),
                    curr->func_index,
-                   fmt_ptr((genericptr_t)curr->arg));
+                   fmt_ptr((genericptr_t)curr->arg.a_void));
 #endif
            putstr(win, 0, buf);
        }
@@ -1421,7 +1421,7 @@ timer_sanity_check()
     /* this should be much more complete */
     for (curr = timer_base; curr; curr = curr->next)
        if (curr->kind == TIMER_OBJECT) {
-           struct obj *obj = (struct obj *) curr->arg;
+           struct obj *obj = curr->arg.a_obj;
            if (obj->timed == 0) {
                pline("timer sanity: untimed obj %s, timer %ld",
                      fmt_ptr((genericptr_t)obj), curr->tid);
@@ -1450,8 +1450,8 @@ run_timers()
        curr = timer_base;
        timer_base = curr->next;
 
-       if (curr->kind == TIMER_OBJECT) ((struct obj *)(curr->arg))->timed--;
-       (*timeout_funcs[curr->func_index].f)(curr->arg, curr->timeout);
+       if (curr->kind == TIMER_OBJECT) (curr->arg.a_obj)->timed--;
+       (*timeout_funcs[curr->func_index].f)(&curr->arg, curr->timeout);
        free((genericptr_t) curr);
     }
 }
@@ -1465,7 +1465,7 @@ start_timer(when, kind, func_index, arg)
 long when;
 short kind;
 short func_index;
-genericptr_t arg;
+anything *arg;
 {
     timer_element *gnu;
 
@@ -1479,11 +1479,11 @@ genericptr_t arg;
     gnu->kind = kind;
     gnu->needs_fixup = 0;
     gnu->func_index = func_index;
-    gnu->arg = arg;
+    gnu->arg = *arg;
     insert_timer(gnu);
 
     if (kind == TIMER_OBJECT)  /* increment object's timed count */
-       ((struct obj *)arg)->timed++;
+       (arg->a_obj)->timed++;
 
     /* should check for duplicates and fail if any */
     return TRUE;
@@ -1497,7 +1497,7 @@ genericptr_t arg;
 long
 stop_timer(func_index, arg)
 short func_index;
-genericptr_t arg;
+anything *arg;
 {
     timer_element *doomed;
     long timeout;
@@ -1507,7 +1507,7 @@ genericptr_t arg;
     if (doomed) {
        timeout = doomed->timeout;
        if (doomed->kind == TIMER_OBJECT)
-           ((struct obj *)arg)->timed--;
+           (arg->a_obj)->timed--;
        if (timeout_funcs[doomed->func_index].cleanup)
            (*timeout_funcs[doomed->func_index].cleanup)(arg, timeout);
        free((genericptr_t) doomed);
@@ -1522,12 +1522,12 @@ genericptr_t arg;
 long
 peek_timer(type, arg)
     short type;
-    genericptr_t arg;
+    anything *arg;
 {
     timer_element *curr;
 
     for (curr = timer_base; curr; curr = curr->next) {
-       if (curr->func_index == type && curr->arg == arg)
+       if (curr->func_index == type && curr->arg.a_void == arg->a_void)
            return curr->timeout;
     }
     return 0L;
@@ -1545,8 +1545,8 @@ obj_move_timers(src, dest)
     timer_element *curr;
 
     for (count = 0, curr = timer_base; curr; curr = curr->next)
-       if (curr->kind == TIMER_OBJECT && curr->arg == (genericptr_t)src) {
-           curr->arg = (genericptr_t) dest;
+       if (curr->kind == TIMER_OBJECT && curr->arg.a_obj == src) {
+           curr->arg.a_obj = dest;
            dest->timed++;
            count++;
        }
@@ -1567,9 +1567,9 @@ obj_split_timers(src, dest)
 
     for (curr = timer_base; curr; curr = next_timer) {
        next_timer = curr->next;        /* things may be inserted */
-       if (curr->kind == TIMER_OBJECT && curr->arg == (genericptr_t)src) {
+       if (curr->kind == TIMER_OBJECT && curr->arg.a_obj == src) {
            (void) start_timer(curr->timeout-monstermoves, TIMER_OBJECT,
-                                       curr->func_index, (genericptr_t)dest);
+                                       curr->func_index, obj_to_any(dest));
        }
     }
 }
@@ -1587,13 +1587,13 @@ obj_stop_timers(obj)
 
     for (prev = 0, curr = timer_base; curr; curr = next_timer) {
        next_timer = curr->next;
-       if (curr->kind == TIMER_OBJECT && curr->arg == (genericptr_t)obj) {
+       if (curr->kind == TIMER_OBJECT && curr->arg.a_obj == obj) {
            if (prev)
                prev->next = curr->next;
            else
                timer_base = curr->next;
            if (timeout_funcs[curr->func_index].cleanup)
-               (*timeout_funcs[curr->func_index].cleanup)(curr->arg,
+               (*timeout_funcs[curr->func_index].cleanup)(&curr->arg,
                        curr->timeout);
            free((genericptr_t) curr);
        } else {
@@ -1611,7 +1611,7 @@ obj_has_timer(object, timer_type)
     struct obj *object;
     short timer_type;
 {
-    long timeout = peek_timer(timer_type, (genericptr_t)object);
+    long timeout = peek_timer(timer_type, obj_to_any(object));
 
     return (boolean)(timeout != 0L);
 }
@@ -1632,13 +1632,13 @@ short func_index;
     for (prev = 0, curr = timer_base; curr; curr = next_timer) {
        next_timer = curr->next;
        if (curr->kind == TIMER_LEVEL &&
-           curr->func_index == func_index && curr->arg == (genericptr_t)where) {
+           curr->func_index == func_index && curr->arg.a_long == where) {
            if (prev)
                prev->next = curr->next;
            else
                timer_base = curr->next;
            if (timeout_funcs[curr->func_index].cleanup)
-               (*timeout_funcs[curr->func_index].cleanup)(curr->arg,
+               (*timeout_funcs[curr->func_index].cleanup)(&curr->arg,
                        curr->timeout);
            free((genericptr_t) curr);
        } else {
@@ -1661,7 +1661,7 @@ short func_index;
 
     for (curr = timer_base; curr; curr = curr->next) {
        if (curr->kind == TIMER_LEVEL &&
-           curr->func_index == func_index && curr->arg == (genericptr_t)where)
+           curr->func_index == func_index && curr->arg.a_long == where)
                return curr->timeout;
     }
     return 0L;
@@ -1698,12 +1698,12 @@ STATIC_OVL timer_element *
 remove_timer(base, func_index, arg)
 timer_element **base;
 short func_index;
-genericptr_t arg;
+anything *arg;
 {
     timer_element *prev, *curr;
 
     for (prev = 0, curr = *base; curr; prev = curr, curr = curr->next)
-       if (curr->func_index == func_index && curr->arg == arg) break;
+       if (curr->func_index == func_index && curr->arg.a_void == arg->a_void) break;
 
     if (curr) {
        if (prev)
@@ -1721,7 +1721,9 @@ write_timer(fd, timer)
     int fd;
     timer_element *timer;
 {
-    genericptr_t arg_save;
+    anything arg_save;
+
+    zero_anything(&arg_save);
 
     switch (timer->kind) {
        case TIMER_GLOBAL:
@@ -1735,11 +1737,12 @@ write_timer(fd, timer)
                bwrite(fd, (genericptr_t)timer, sizeof(timer_element));
            else {
                /* replace object pointer with id */
-               arg_save = timer->arg;
-               timer->arg = (genericptr_t)((struct obj *)timer->arg)->o_id;
+               arg_save.a_obj = timer->arg.a_obj;
+               zero_anything(&timer->arg);
+               timer->arg.a_uint = (arg_save.a_obj)->o_id;
                timer->needs_fixup = 1;
                bwrite(fd, (genericptr_t)timer, sizeof(timer_element));
-               timer->arg = arg_save;
+               timer->arg.a_obj = arg_save.a_obj;
                timer->needs_fixup = 0;
            }
            break;
@@ -1749,11 +1752,12 @@ write_timer(fd, timer)
                bwrite(fd, (genericptr_t)timer, sizeof(timer_element));
            else {
                /* replace monster pointer with id */
-               arg_save = timer->arg;
-               timer->arg = (genericptr_t)((struct monst *)timer->arg)->m_id;
+               arg_save.a_monst = timer->arg.a_monst;
+               zero_anything(&timer->arg);
+               timer->arg.a_uint = (arg_save.a_monst)->m_id;
                timer->needs_fixup = 1;
                bwrite(fd, (genericptr_t)timer, sizeof(timer_element));
-               timer->arg = arg_save;
+               timer->arg.a_monst = arg_save.a_monst;
                timer->needs_fixup = 0;
            }
            break;
@@ -1816,8 +1820,8 @@ timer_is_local(timer)
     switch (timer->kind) {
        case TIMER_LEVEL:       return TRUE;
        case TIMER_GLOBAL:      return FALSE;
-       case TIMER_OBJECT:      return obj_is_local((struct obj *)timer->arg);
-       case TIMER_MONSTER:     return mon_is_local((struct monst *)timer->arg);
+       case TIMER_OBJECT:      return obj_is_local(timer->arg.a_obj);
+       case TIMER_MONSTER:     return mon_is_local(timer->arg.a_monst);
     }
     panic("timer_is_local");
     return FALSE;
@@ -1948,12 +1952,12 @@ relink_timers(ghostly)
        if (curr->needs_fixup) {
            if (curr->kind == TIMER_OBJECT) {
                if (ghostly) {
-                   if (!lookup_id_mapping((unsigned)curr->arg, &nid))
+                   if (!lookup_id_mapping(curr->arg.a_uint, &nid))
                        panic("relink_timers 1");
                } else
-                   nid = (unsigned) curr->arg;
-               curr->arg = (genericptr_t) find_oid(nid);
-               if (!curr->arg) panic("cant find o_id %d", nid);
+                   nid = curr->arg.a_uint;
+               curr->arg.a_obj = find_oid(nid);
+               if (!curr->arg.a_obj) panic("cant find o_id %d", nid);
                curr->needs_fixup = 0;
            } else if (curr->kind == TIMER_MONSTER) {
                panic("relink_timers: no monster timer implemented");
index b47cf7211a2f48c546139f1c9f82d1d416bca582..b4843b7aca9a75e79712bad47a57fe31fefcc9d5 100644 (file)
--- a/src/zap.c
+++ b/src/zap.c
@@ -3766,7 +3766,7 @@ xchar x,y;
        for (when = MIN_ICE_TIME; when < (MAX_ICE_TIME + MIN_ICE_TIME); when++)
                if (!rn2((MAX_ICE_TIME - when) + MIN_ICE_TIME)) break;
        where = (((long)x << 16) | ((long)y));
-       (void) start_timer((long)when, TIMER_LEVEL, action, (genericptr_t)where);
+       (void) start_timer((long)when, TIMER_LEVEL, action, long_to_any(where));
 }
 #undef MIN_ICE_TIME
 #undef MAX_ICE_TIME
@@ -3776,11 +3776,11 @@ xchar x,y;
  */
 void
 melt_ice_away(arg, timeout)
-genericptr_t arg;
+anything *arg;
 long timeout;  /* unused */
 {
        xchar x,y;
-       long where = (long)arg;
+       long where = arg->a_long;
 
        y = (xchar)(where & 0xFFFF);
        x = (xchar)((where >> 16) & 0xFFFF);