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.
This commit is contained in:
nethack.allison
2006-07-09 01:23:26 +00:00
parent d611cd76c5
commit 98a09101b1
3 changed files with 12 additions and 10 deletions
+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 35 #define EDITLEVEL 36
#define COPYRIGHT_BANNER_A \ #define COPYRIGHT_BANNER_A \
"NetHack, Copyright 1985-2006" "NetHack, Copyright 1985-2006"
+1 -1
View File
@@ -59,7 +59,7 @@ typedef struct {
boolean visible; /* Is the region visible ? */ boolean visible; /* Is the region visible ? */
int glyph; /* Which glyph to use if 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, ...*/ force field, damage of a fire zone, ...*/
} NhRegion; } NhRegion;
+10 -8
View File
@@ -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 */ /* Copyright (c) 1996 by Jean-Christophe Collet */
/* NetHack may be freely redistributed. See license for details. */ /* NetHack may be freely redistributed. See license for details. */
@@ -131,7 +131,7 @@ int nrect;
reg->n_monst = 0; reg->n_monst = 0;
reg->max_monst = 0; reg->max_monst = 0;
reg->monsters = (unsigned int *)0; reg->monsters = (unsigned int *)0;
reg->arg = (genericptr_t)0; zero_anything(&reg->arg);
return reg; return reg;
} }
@@ -660,7 +660,7 @@ int mode;
sizeof (unsigned)); sizeof (unsigned));
bwrite(fd, (genericptr_t) &regions[i]->visible, sizeof (boolean)); bwrite(fd, (genericptr_t) &regions[i]->visible, sizeof (boolean));
bwrite(fd, (genericptr_t) &regions[i]->glyph, sizeof (int)); bwrite(fd, (genericptr_t) &regions[i]->glyph, sizeof (int));
bwrite(fd, (genericptr_t) &regions[i]->arg, sizeof (genericptr_t)); bwrite(fd, (genericptr_t) &regions[i]->arg, sizeof (anything));
} }
skip_lots: skip_lots:
@@ -745,7 +745,7 @@ boolean ghostly; /* If a bones file restore */
sizeof (unsigned)); sizeof (unsigned));
mread(fd, (genericptr_t) &regions[i]->visible, sizeof (boolean)); mread(fd, (genericptr_t) &regions[i]->visible, sizeof (boolean));
mread(fd, (genericptr_t) &regions[i]->glyph, sizeof (int)); mread(fd, (genericptr_t) &regions[i]->glyph, sizeof (int));
mread(fd, (genericptr_t) &regions[i]->arg, sizeof (genericptr_t)); mread(fd, (genericptr_t) &regions[i]->arg, sizeof (anything));
} }
/* remove expired regions, do not trigger the expire_f callback (yet!); /* remove expired regions, do not trigger the expire_f callback (yet!);
also update monster lists if this data is coming from a bones file */ also update monster lists if this data is coming from a bones file */
@@ -896,12 +896,13 @@ genericptr_t p2; /* unused here */
int damage; int damage;
reg = (NhRegion *) p1; reg = (NhRegion *) p1;
damage = (int) reg->arg; damage = reg->arg.a_int;
/* If it was a thick cloud, it dissipates a little first */ /* If it was a thick cloud, it dissipates a little first */
if (damage >= 5) { if (damage >= 5) {
damage /= 2; /* It dissipates, let's do less damage */ damage /= 2; /* It dissipates, let's do less damage */
reg->arg = (genericptr_t) damage; zero_anything(&reg->arg);
reg->arg.a_int = damage;
reg->ttl = 2L; /* Here's the trick : reset ttl */ reg->ttl = 2L; /* Here's the trick : reset ttl */
return FALSE; /* THEN return FALSE, means "still there" */ return FALSE; /* THEN return FALSE, means "still there" */
} }
@@ -918,7 +919,7 @@ genericptr_t p2;
int dam; int dam;
reg = (NhRegion *) p1; reg = (NhRegion *) p1;
dam = (int) reg->arg; dam = reg->arg.a_int;
if (p2 == (genericptr_t)0) { /* This means *YOU* Bozo! */ if (p2 == (genericptr_t)0) { /* This means *YOU* Bozo! */
if (nonliving(youmonst.data) || Breathless) if (nonliving(youmonst.data) || Breathless)
return FALSE; return FALSE;
@@ -994,7 +995,8 @@ int damage;
set_heros_fault(cloud); /* assume player has created it */ set_heros_fault(cloud); /* assume player has created it */
cloud->inside_f = INSIDE_GAS_CLOUD; cloud->inside_f = INSIDE_GAS_CLOUD;
cloud->expire_f = EXPIRE_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->visible = TRUE;
cloud->glyph = cmap_to_glyph(S_cloud); cloud->glyph = cmap_to_glyph(S_cloud);
add_region(cloud); add_region(cloud);