From: nethack.allison Date: Sun, 9 Jul 2006 01:23:26 +0000 (+0000) Subject: remove pointer to long conversions - part 3 of 3 (trunk only) X-Git-Tag: MOVE2GIT~953 X-Git-Url: https://granicus.if.org/sourcecode?a=commitdiff_plain;h=98a09101b1f30558c891ab06ccafdf55d32a0a7b;p=nethack remove pointer to long conversions - part 3 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 3rd part deals with region functions switching some arguments from type genericptr_t to 'anything'. Like the previous 2 parts, this needs to increment EDITLEVEL in patchlevel.h. --- diff --git a/include/patchlevel.h b/include/patchlevel.h index 21a39aa88..49d58c81b 100644 --- a/include/patchlevel.h +++ b/include/patchlevel.h @@ -13,7 +13,7 @@ * Incrementing EDITLEVEL can be used to force invalidation of old bones * and save files. */ -#define EDITLEVEL 35 +#define EDITLEVEL 36 #define COPYRIGHT_BANNER_A \ "NetHack, Copyright 1985-2006" diff --git a/include/region.h b/include/region.h index f4d2a421c..9f1066ddf 100644 --- a/include/region.h +++ b/include/region.h @@ -59,7 +59,7 @@ typedef struct { boolean visible; /* Is the region visible ? */ int glyph; /* Which glyph to use if visible */ - genericptr_t arg; /* Optional user argument (Ex: strength of + anything arg; /* Optional user argument (Ex: strength of force field, damage of a fire zone, ...*/ } NhRegion; diff --git a/src/region.c b/src/region.c index 8d4e2d4d3..b719cdce4 100644 --- a/src/region.c +++ b/src/region.c @@ -1,4 +1,4 @@ -/* SCCS Id: @(#)region.c 3.5 2006/07/02 */ +/* SCCS Id: @(#)region.c 3.5 2007/07/08 */ /* Copyright (c) 1996 by Jean-Christophe Collet */ /* NetHack may be freely redistributed. See license for details. */ @@ -131,7 +131,7 @@ int nrect; reg->n_monst = 0; reg->max_monst = 0; reg->monsters = (unsigned int *)0; - reg->arg = (genericptr_t)0; + zero_anything(®->arg); return reg; } @@ -660,7 +660,7 @@ int mode; sizeof (unsigned)); bwrite(fd, (genericptr_t) ®ions[i]->visible, sizeof (boolean)); bwrite(fd, (genericptr_t) ®ions[i]->glyph, sizeof (int)); - bwrite(fd, (genericptr_t) ®ions[i]->arg, sizeof (genericptr_t)); + bwrite(fd, (genericptr_t) ®ions[i]->arg, sizeof (anything)); } skip_lots: @@ -745,7 +745,7 @@ boolean ghostly; /* If a bones file restore */ sizeof (unsigned)); mread(fd, (genericptr_t) ®ions[i]->visible, sizeof (boolean)); mread(fd, (genericptr_t) ®ions[i]->glyph, sizeof (int)); - mread(fd, (genericptr_t) ®ions[i]->arg, sizeof (genericptr_t)); + mread(fd, (genericptr_t) ®ions[i]->arg, sizeof (anything)); } /* remove expired regions, do not trigger the expire_f callback (yet!); also update monster lists if this data is coming from a bones file */ @@ -896,12 +896,13 @@ genericptr_t p2; /* unused here */ int damage; reg = (NhRegion *) p1; - damage = (int) reg->arg; + damage = reg->arg.a_int; /* If it was a thick cloud, it dissipates a little first */ if (damage >= 5) { damage /= 2; /* It dissipates, let's do less damage */ - reg->arg = (genericptr_t) damage; + zero_anything(®->arg); + reg->arg.a_int = damage; reg->ttl = 2L; /* Here's the trick : reset ttl */ return FALSE; /* THEN return FALSE, means "still there" */ } @@ -918,7 +919,7 @@ genericptr_t p2; int dam; reg = (NhRegion *) p1; - dam = (int) reg->arg; + dam = reg->arg.a_int; if (p2 == (genericptr_t)0) { /* This means *YOU* Bozo! */ if (nonliving(youmonst.data) || Breathless) return FALSE; @@ -994,7 +995,8 @@ int damage; set_heros_fault(cloud); /* assume player has created it */ cloud->inside_f = INSIDE_GAS_CLOUD; cloud->expire_f = EXPIRE_GAS_CLOUD; - cloud->arg = (genericptr_t) damage; + zero_anything(&cloud->arg); + cloud->arg.a_int = damage; cloud->visible = TRUE; cloud->glyph = cmap_to_glyph(S_cloud); add_region(cloud);