remove pointer to long conversions - part 2 of 3 (trunk only)

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