]> granicus.if.org Git - nethack/commitdiff
remove pointer to long conversions - part 1 of 3 rev 2 (trunk only)
authornethack.allison <nethack.allison>
Sat, 8 Jul 2006 23:31:39 +0000 (23:31 +0000)
committernethack.allison <nethack.allison>
Sat, 8 Jul 2006 23:31:39 +0000 (23:31 +0000)
[the problem in the earlier rev was tracked to cleanup_burn(),
where arg was holding a (genericptr_t) timer id, and
passed directly to del_light_source() as is.]

P64 (Win64) has a 64 bit pointer size, but a 32 bit long size.
Remove some code that forced pointers into a long int, and
vice versa where information could be lost.

This part deals with light source functions and their
arguments mostly, and switches some arguments
from type genericptr_t to 'anything'.

include/extern.h
include/lev.h
include/patchlevel.h
include/wintype.h
src/hack.c
src/light.c
src/makemon.c
src/mkobj.c
src/mon.c
src/polyself.c
src/timeout.c

index db6f401f9c8cfc4a30152c2d1ab23081071a7c05..f736bea67f4474fafae146b3ffb28e7a85f055af 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)extern.h   3.5     2006/05/08      */
+/*     SCCS Id: @(#)extern.h   3.5     2006/07/08      */
 /* Copyright (c) Steve Creps, 1988.                              */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -737,6 +737,11 @@ E void NDECL(drinksink);
 
 /* ### hack.c ### */
 
+E anything *FDECL(uint_to_any, (unsigned));
+E anything *FDECL(long_to_any, (long));
+E anything *FDECL(monst_to_any, (struct monst *));
+E anything *FDECL(obj_to_any, (struct obj *));
+E void FDECL(zero_anything, (ANY_P *));
 E boolean FDECL(revive_nasty, (int,int,const char*));
 E void FDECL(movobj, (struct obj *,XCHAR_P,XCHAR_P));
 E boolean FDECL(may_dig, (XCHAR_P,XCHAR_P));
@@ -893,8 +898,8 @@ E int NDECL(dosuspend);
 
 /* ### light.c ### */
 
-E void FDECL(new_light_source, (XCHAR_P, XCHAR_P, int, int, genericptr_t));
-E void FDECL(del_light_source, (int, genericptr_t));
+E void FDECL(new_light_source, (XCHAR_P, XCHAR_P, int, int, ANY_P *));
+E void FDECL(del_light_source, (int, ANY_P *));
 E void FDECL(do_light_sources, (char **));
 E struct monst *FDECL(find_mid, (unsigned, unsigned));
 E void FDECL(save_light_sources, (int, int, int));
@@ -1818,7 +1823,6 @@ E void FDECL(getlev, (int,int,XCHAR_P,BOOLEAN_P));
 E void FDECL(get_plname_from_file, (int, char *));
 E void NDECL(minit);
 E boolean FDECL(lookup_id_mapping, (unsigned, unsigned *));
-E struct monst *FDECL(buffer_to_mon, (genericptr_t));
 E void FDECL(mread, (int,genericptr_t,unsigned int));
 #ifndef GOLDOBJ
 E void FDECL(put_gold_back, (struct obj **,long *));
index ae9cd2915e1d7e1308933e83da06b374b1634ea0..d8f5caea14c69c14fce4e1a9a76f99500f7de6d8 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)lev.h      3.5     1994/03/18      */
+/*     SCCS Id: @(#)lev.h      3.5     2006/07/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -43,7 +43,7 @@ typedef struct ls_t {
     short range;       /* source's current range */
     short flags;
     short type;                /* type of light source */
-    genericptr_t id;   /* source's identifier */
+    anything id;       /* source's identifier */
 } light_source;
 
 #endif /* LEV_H */
index a9d093f1be6f67ffb99a1200fb5cd192bd6aa721..a069886c18ded003781b209de097a9f05e679d50 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)patchlevel.h       3.5     2006/06/27      */
+/*     SCCS Id: @(#)patchlevel.h       3.5     2006/07/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -13,7 +13,7 @@
  * Incrementing EDITLEVEL can be used to force invalidation of old bones
  * and save files.
  */
-#define EDITLEVEL      33
+#define EDITLEVEL      34
 
 #define COPYRIGHT_BANNER_A \
 "NetHack, Copyright 1985-2006"
index 7b1bcf951810ffc9afae34ab5b62172f7dc62d77..106e67361382af5ee9d203cdb80b92c41bbecadb 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)wintype.h  3.5     1996/02/18      */
+/*     SCCS Id: @(#)wintype.h  3.5     2006/07/08      */
 /* Copyright (c) David Cohrs, 1991                               */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -11,6 +11,7 @@ typedef int winid;            /* a window identifier */
 typedef union any {
     genericptr_t a_void;
     struct obj *a_obj;
+    struct monst *a_monst;
     int  a_int;
     char a_char;
     schar a_schar;
index 2ef27dcabb77c56da1d9130f80eb288e3e2dd54f..2d2474847419237f2a18ecc5a664e946965a0b59 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)hack.c     3.5     2006/06/11      */
+/*     SCCS Id: @(#)hack.c     3.5     2006/07/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -19,6 +19,51 @@ STATIC_DCL void FDECL(move_update, (BOOLEAN_P));
 
 #define IS_SHOP(x)     (rooms[x].rtype >= SHOPBASE)
 
+static anything tmp_anything;
+
+anything *
+uint_to_any(ui)
+unsigned ui;
+{
+    zero_anything(&tmp_anything);
+    tmp_anything.a_uint = ui;
+    return &tmp_anything;
+}
+
+anything *
+long_to_any(lng)
+unsigned lng;
+{
+    zero_anything(&tmp_anything);
+    tmp_anything.a_long = lng;
+    return &tmp_anything;
+}
+
+anything *
+monst_to_any(mtmp)
+struct monst *mtmp;
+{
+    zero_anything(&tmp_anything);
+    tmp_anything.a_monst = mtmp;
+    return &tmp_anything;
+}
+
+anything *
+obj_to_any(obj)
+struct obj *obj;
+{
+    zero_anything(&tmp_anything);
+    tmp_anything.a_obj = obj;
+    return &tmp_anything;
+}
+
+void
+zero_anything(any)
+anything *any;
+{
+    (void) memset((genericptr_t)any, 0, sizeof(anything));
+}
+
 boolean
 revive_nasty(x, y, msg)
 int x,y;
index b63d7aba186cebe53330ca66f2cf511831835215..2770ed20956c29b4db09133f811909b2707b0082 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)light.c    3.5     2006/07/07      */
+/*     SCCS Id: @(#)light.c    3.5     2006/07/08      */
 /* Copyright (c) Dean Luick, 1994                                      */
 /* NetHack may be freely redistributed.  See license for details.      */
 
@@ -57,7 +57,7 @@ void
 new_light_source(x, y, range, type, id)
     xchar x, y;
     int range, type;
-    genericptr_t id;
+    anything *id;
 {
     light_source *ls;
 
@@ -73,7 +73,7 @@ new_light_source(x, y, range, type, id)
     ls->y = y;
     ls->range = range;
     ls->type = type;
-    ls->id = id;
+    ls->id = *id;
     ls->flags = 0;
     light_base = ls;
 
@@ -87,26 +87,28 @@ new_light_source(x, y, range, type, id)
 void
 del_light_source(type, id)
     int type;
-    genericptr_t id;
+    anything *id;
 {
     light_source *curr, *prev;
-    genericptr_t tmp_id;
+    anything tmp_id;
+
+    zero_anything(&tmp_id);
 
     /* need to be prepared for dealing a with light source which
        has only been partially restored during a level change
        (in particular: chameleon vs prot. from shape changers) */
     switch (type) {
-    case LS_OBJECT:    tmp_id = (genericptr_t)(((struct obj *)id)->o_id);
+    case LS_OBJECT:    tmp_id.a_uint = id->a_obj->o_id;
                        break;
-    case LS_MONSTER:   tmp_id = (genericptr_t)(((struct monst *)id)->m_id);
+    case LS_MONSTER:   tmp_id.a_uint = id->a_monst->m_id;
                        break;
-    default:           tmp_id = 0;
+    default:           tmp_id.a_uint = 0;
                        break;
     }
 
     for (prev = 0, curr = light_base; curr; prev = curr, curr = curr->next) {
        if (curr->type != type) continue;
-       if (curr->id == ((curr->flags & LSF_NEEDS_FIXUP) ? tmp_id : id)) {
+       if (curr->id.a_obj == ((curr->flags & LSF_NEEDS_FIXUP) ? tmp_id.a_obj : id->a_obj)) {
            if (prev)
                prev->next = curr->next;
            else
@@ -118,7 +120,7 @@ del_light_source(type, id)
        }
     }
     impossible("del_light_source: not found type=%d, id=%s",
-             type, fmt_ptr((genericptr_t)id));
+             type, fmt_ptr((genericptr_t)id->a_obj));
 }
 
 /* Mark locations that are temporarily lit via mobile light sources. */
@@ -142,10 +144,10 @@ do_light_sources(cs_rows)
         * vision recalc.
         */
        if (ls->type == LS_OBJECT) {
-           if (get_obj_location((struct obj *) ls->id, &ls->x, &ls->y, 0))
+           if (get_obj_location(ls->id.a_obj, &ls->x, &ls->y, 0))
                ls->flags |= LSF_SHOW;
        } else if (ls->type == LS_MONSTER) {
-           if (get_mon_location((struct monst *) ls->id, &ls->x, &ls->y, 0))
+           if (get_mon_location(ls->id.a_monst, &ls->x, &ls->y, 0))
                ls->flags |= LSF_SHOW;
        }
 
@@ -244,16 +246,16 @@ save_light_sources(fd, mode, range)
 
     if (release_data(mode)) {
        for (prev = &light_base; (curr = *prev) != 0; ) {
-           if (!curr->id) {
+           if (!curr->id.a_monst) {
                impossible("save_light_sources: no id! [range=%d]", range);
                is_global = 0;
            } else
            switch (curr->type) {
            case LS_OBJECT:
-               is_global = !obj_is_local((struct obj *)curr->id);
+               is_global = !obj_is_local(curr->id.a_obj);
                break;
            case LS_MONSTER:
-               is_global = !mon_is_local((struct monst *)curr->id);
+               is_global = !mon_is_local(curr->id.a_monst);
                break;
            default:
                is_global = 0;
@@ -307,18 +309,18 @@ relink_light_sources(ghostly)
        if (ls->flags & LSF_NEEDS_FIXUP) {
            if (ls->type == LS_OBJECT || ls->type == LS_MONSTER) {
                if (ghostly) {
-                   if (!lookup_id_mapping((unsigned)ls->id, &nid))
+                   if (!lookup_id_mapping(ls->id.a_uint, &nid))
                        impossible("relink_light_sources: no id mapping");
                } else
-                   nid = (unsigned) ls->id;
+                   nid = ls->id.a_uint;
                if (ls->type == LS_OBJECT) {
                    which = 'o';
-                   ls->id = (genericptr_t) find_oid(nid);
+                   ls->id.a_obj = find_oid(nid);
                } else {
                    which = 'm';
-                   ls->id = (genericptr_t) find_mid(nid, FM_EVERYWHERE);
+                   ls->id.a_monst = find_mid(nid, FM_EVERYWHERE);
                }
-               if (!ls->id)
+               if (!ls->id.a_monst)
                    impossible("relink_light_sources: cant find %c_id %d",
                               which, nid);
            } else
@@ -343,16 +345,16 @@ maybe_write_ls(fd, range, write_it)
     light_source *ls;
 
     for (ls = light_base; ls; ls = ls->next) {
-       if (!ls->id) {
+       if (!ls->id.a_monst) {
            impossible("maybe_write_ls: no id! [range=%d]", range);
            continue;
        }
        switch (ls->type) {
        case LS_OBJECT:
-           is_global = !obj_is_local((struct obj *)ls->id);
+           is_global = !obj_is_local(ls->id.a_obj);
            break;
        case LS_MONSTER:
-           is_global = !mon_is_local((struct monst *)ls->id);
+           is_global = !mon_is_local(ls->id.a_monst);
            break;
        default:
            is_global = 0;
@@ -376,7 +378,7 @@ write_ls(fd, ls)
     int fd;
     light_source *ls;
 {
-    genericptr_t arg_save;
+    anything arg_save;
     struct obj *otmp;
     struct monst *mtmp;
 
@@ -387,18 +389,20 @@ write_ls(fd, ls)
            /* replace object pointer with id for write, then put back */
            arg_save = ls->id;
            if (ls->type == LS_OBJECT) {
-               otmp = (struct obj *)ls->id;
-               ls->id = (genericptr_t)otmp->o_id;
+               otmp = ls->id.a_obj;
+               zero_anything(&ls->id);
+               ls->id.a_uint = otmp->o_id;
 #ifdef DEBUG
                if (find_oid((unsigned)ls->id) != otmp)
-                   panic("write_ls: can't find obj #%u!", (unsigned)ls->id);
+                   panic("write_ls: can't find obj #%u!", ls->id.a_uint);
 #endif
            } else { /* ls->type == LS_MONSTER */
-               mtmp = (struct monst *)ls->id;
-               ls->id = (genericptr_t)mtmp->m_id;
+               mtmp = (struct monst *)ls->id.a_monst;
+               zero_anything(&ls->id);
+               ls->id.a_uint = mtmp->m_id;
 #ifdef DEBUG
                if (find_mid((unsigned)ls->id, FM_EVERYWHERE) != mtmp)
-                   panic("write_ls: can't find mon #%u!", (unsigned)ls->id);
+                   panic("write_ls: can't find mon #%u!", ls->x_id);
 #endif
            }
            ls->flags |= LSF_NEEDS_FIXUP;
@@ -419,8 +423,8 @@ obj_move_light_source(src, dest)
     light_source *ls;
 
     for (ls = light_base; ls; ls = ls->next)
-       if (ls->type == LS_OBJECT && ls->id == (genericptr_t) src)
-           ls->id = (genericptr_t) dest;
+       if (ls->type == LS_OBJECT && ls->id.a_obj == src)
+           ls->id.a_obj = dest;
     src->lamplit = 0;
     dest->lamplit = 1;
 }
@@ -450,7 +454,7 @@ snuff_light_source(x, y)
        updated with the last vision update?  [Is that recent enough???]
        */
        if (ls->type == LS_OBJECT && ls->x == x && ls->y == y) {
-           obj = (struct obj *) ls->id;
+           obj = ls->id.a_obj;
            if (obj_is_burning(obj)) {
                /* The only way to snuff Sunsword is to unwield it.  Darkness
                 * scrolls won't affect it.  (If we got here because it was
@@ -495,7 +499,7 @@ obj_split_light_source(src, dest)
     light_source *ls, *new_ls;
 
     for (ls = light_base; ls; ls = ls->next)
-       if (ls->type == LS_OBJECT && ls->id == (genericptr_t) src) {
+       if (ls->type == LS_OBJECT && ls->id.a_obj == src) {
            /*
             * Insert the new source at beginning of list.  This will
             * never interfere us walking down the list - we are already
@@ -509,7 +513,7 @@ obj_split_light_source(src, dest)
                new_ls->range = candle_light_range(dest);
                vision_full_recalc = 1; /* in case range changed */
            }
-           new_ls->id = (genericptr_t) dest;
+           new_ls->id.a_obj = dest;
            new_ls->next = light_base;
            light_base = new_ls;
            dest->lamplit = 1;          /* now an active light source */
@@ -528,7 +532,7 @@ struct obj *src, *dest;
     if (src != dest) end_burn(src, TRUE);              /* extinguish candles */
 
     for (ls = light_base; ls; ls = ls->next)
-       if (ls->type == LS_OBJECT && ls->id == (genericptr_t) dest) {
+       if (ls->type == LS_OBJECT && ls->id.a_obj == dest) {
            ls->range = candle_light_range(dest);
            vision_full_recalc = 1;     /* in case range changed */
            break;
@@ -600,11 +604,11 @@ wiz_light_sources()
                    ls->x, ls->y, ls->range, ls->flags,
                    (ls->type == LS_OBJECT ? "obj" :
                     ls->type == LS_MONSTER ?
-                       (mon_is_local((struct monst *)ls->id) ? "mon" :
-                        ((struct monst *)ls->id == &youmonst) ? "you" :
+                       (mon_is_local(ls->id.a_monst) ? "mon" :
+                        (ls->id.a_monst == &youmonst) ? "you" :
                         "<m>") :               /* migrating monster */
                     "???"),
-                   fmt_ptr(ls->id));
+                   fmt_ptr(ls->id.a_void));
            putstr(win, 0, buf);
        }
     } else
index 86f991a34beca5565720a8d6f25280caeb44d50f..655ee2c6c98fe418225a985b788850fc430b3350 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)makemon.c  3.5     2006/06/17      */
+/*     SCCS Id: @(#)makemon.c  3.5     2006/07/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -716,7 +716,7 @@ xchar x, y; /* clone's preferred location or 0 (near mon) */
        place_monster(m2, m2->mx, m2->my);
        if (emits_light(m2->data))
            new_light_source(m2->mx, m2->my, emits_light(m2->data),
-                            LS_MONSTER, (genericptr_t)m2);
+                            LS_MONSTER, monst_to_any(m2));
        if (has_mname(mon)) {
                m2 = christen_monst(m2, MNAME(mon));
        } else if (mon->isshk) {
@@ -1025,7 +1025,7 @@ register int      mmflags;
        }
        if ((ct = emits_light(mtmp->data)) > 0)
                new_light_source(mtmp->mx, mtmp->my, ct,
-                                LS_MONSTER, (genericptr_t)mtmp);
+                                LS_MONSTER, monst_to_any(mtmp));
        mitem = 0;      /* extra inventory item for this monster */
 
        if (mndx == PM_VLAD_THE_IMPALER)
index 6920b374c2748dd31e3abc2e28d556a29352d355..bf4c607441083695db10347ab4dac51ec7be2a85 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mkobj.c    3.5     2006/07/07      */
+/*     SCCS Id: @(#)mkobj.c    3.5     2006/07/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1760,7 +1760,7 @@ dealloc_obj(obj)
      * attached to it (and also requires lamplit to be set).
      */
     if (obj_sheds_light(obj))
-       del_light_source(LS_OBJECT, (genericptr_t) obj);
+       del_light_source(LS_OBJECT, obj_to_any(obj));
 
     if (obj == thrownobj) thrownobj = (struct obj*)0;
 
index f8f917c33b6002afe012d80d6f03e10569adda07..e4d1b1261f4f885b7356f2c0695b4ddb2f999dae 100644 (file)
--- a/src/mon.c
+++ b/src/mon.c
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)mon.c      3.5     2006/05/08      */
+/*     SCCS Id: @(#)mon.c      3.5     2006/07/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1311,9 +1311,9 @@ register struct monst *mtmp, *mtmp2;
        /* since this is so rare, we don't have any `mon_move_light_source' */
        new_light_source(mtmp2->mx, mtmp2->my,
                         emits_light(mtmp2->data),
-                        LS_MONSTER, (genericptr_t)mtmp2);
+                        LS_MONSTER, monst_to_any(mtmp2));
        /* here we rely on the fact that `mtmp' hasn't actually been deleted */
-       del_light_source(LS_MONSTER, (genericptr_t)mtmp);
+       del_light_source(LS_MONSTER, monst_to_any(mtmp));
     }
     mtmp2->nmon = fmon;
     fmon = mtmp2;
@@ -1428,7 +1428,7 @@ struct permonst *mptr;    /* reflects mtmp->data _prior_ to mtmp's death */
        relobj(mtmp, 0, FALSE);
        remove_monster(mtmp->mx, mtmp->my);
        if (emits_light(mptr))
-           del_light_source(LS_MONSTER, (genericptr_t)mtmp);
+           del_light_source(LS_MONSTER, monst_to_any(mtmp));
        newsym(mtmp->mx,mtmp->my);
        unstuck(mtmp);
        fill_pit(mtmp->mx, mtmp->my);
@@ -2620,10 +2620,10 @@ boolean msg;            /* "The oldmon turns into a newmon!" */
            /* used to give light, now doesn't, or vice versa,
               or light's range has changed */
            if (emits_light(olddata))
-               del_light_source(LS_MONSTER, (genericptr_t)mtmp);
+               del_light_source(LS_MONSTER, monst_to_any(mtmp));
            if (emits_light(mtmp->data))
                new_light_source(mtmp->mx, mtmp->my, emits_light(mtmp->data),
-                                LS_MONSTER, (genericptr_t)mtmp);
+                                LS_MONSTER, monst_to_any(mtmp));
        }
        if (!mtmp->perminvis || pm_invisible(olddata))
            mtmp->perminvis = pm_invisible(mdat);
index e8de4d48617a2e16d4d6819a08a9d100a0f110d7..59acc7e4713d51f5a3449e699de9a3c154aa3360 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)polyself.c 3.5     2006/05/26      */
+/*     SCCS Id: @(#)polyself.c 3.5     2006/07/08      */
 /*     Copyright (C) 1987, 1988, 1989 by Ken Arromdee */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -353,11 +353,11 @@ int psflags;
        new_light = emits_light(youmonst.data);
        if (old_light != new_light) {
            if (old_light)
-               del_light_source(LS_MONSTER, (genericptr_t)&youmonst);
+               del_light_source(LS_MONSTER, monst_to_any(&youmonst));
            if (new_light == 1) ++new_light;  /* otherwise it's undetectable */
            if (new_light)
                new_light_source(u.ux, u.uy, new_light,
-                                LS_MONSTER, (genericptr_t)&youmonst);
+                                LS_MONSTER, monst_to_any(&youmonst));
        }
 }
 
@@ -750,7 +750,7 @@ rehumanize()
        }
 
        if (emits_light(youmonst.data))
-           del_light_source(LS_MONSTER, (genericptr_t)&youmonst);
+           del_light_source(LS_MONSTER, monst_to_any(&youmonst));
        polyman("return to %s form!", urace.adj);
 
        if (u.uhp < 1) {
index b40959078c733a07eb7b70f80c6a8589e2787496..38687de61fd23d3e914dc7a17d12a911f744f127 100644 (file)
@@ -1,4 +1,4 @@
-/*     SCCS Id: @(#)timeout.c  3.5     2006/07/07      */
+/*     SCCS Id: @(#)timeout.c  3.5     2006/07/08      */
 /* Copyright (c) Stichting Mathematisch Centrum, Amsterdam, 1985. */
 /* NetHack may be freely redistributed.  See license for details. */
 
@@ -1145,7 +1145,7 @@ begin_burn(obj, already_lit)
            xchar x, y;
 
            if (get_obj_location(obj, &x, &y, CONTAINED_TOO|BURIED_TOO))
-               new_light_source(x, y, radius, LS_OBJECT, (genericptr_t) obj);
+               new_light_source(x, y, radius, LS_OBJECT, obj_to_any(obj));
            else
                impossible("begin_burn: can't get obj position");
        }
@@ -1170,7 +1170,7 @@ end_burn(obj, timer_attached)
 
        if (!timer_attached) {
            /* [DS] Cleanup explicitly, since timer cleanup won't happen */
-           del_light_source(LS_OBJECT, (genericptr_t)obj);
+           del_light_source(LS_OBJECT, obj_to_any(obj));
            obj->lamplit = 0;
            if (obj->where == OBJ_INVENT)
                update_inventory();
@@ -1192,7 +1192,7 @@ cleanup_burn(arg, expire_time)
        return;
     }
 
-    del_light_source(LS_OBJECT, arg);
+    del_light_source(LS_OBJECT, obj_to_any(obj));
 
     /* restore unused time */
     obj->age += expire_time - monstermoves;