From 301ac48ccdea44e9527d3b5467f14c8799796cc3 Mon Sep 17 00:00:00 2001 From: terminx Date: Thu, 18 Apr 2019 17:25:24 +0000 Subject: [PATCH] Utilize the types added in the previous commit This patch is a bit large. git-svn-id: https://svn.eduke32.com/eduke32@7603 1a8010ca-5511-0410-912e-c29ae57300e0 # Conflicts: # source/build/include/mdsprite.h # source/build/src/build.cpp # source/build/src/polymer.cpp # source/build/src/polymost.cpp # source/build/src/voxmodel.cpp --- source/build/include/build.h | 26 ++--- source/build/include/clip.h | 4 +- source/build/include/mdsprite.h | 8 +- source/build/include/polymost.h | 4 +- source/build/src/clip.cpp | 96 ++++++++++--------- source/build/src/engine.cpp | 137 ++++++++++++++------------- source/build/src/engine_priv.h | 8 +- source/build/src/mdsprite.cpp | 8 +- source/build/src/voxmodel.cpp | 2 +- source/duke3d/src/actors.cpp | 45 ++++----- source/duke3d/src/actors.h | 4 +- source/duke3d/src/game.cpp | 24 ++--- source/duke3d/src/game.h | 6 +- source/duke3d/src/gameexec.cpp | 32 +++---- source/duke3d/src/gamestructures.cpp | 2 +- source/duke3d/src/m32def.h | 2 +- source/duke3d/src/m32exec.cpp | 4 +- source/duke3d/src/player.cpp | 18 ++-- source/duke3d/src/player.h | 6 +- source/duke3d/src/screens.cpp | 12 +-- source/duke3d/src/sector.cpp | 2 +- 21 files changed, 227 insertions(+), 223 deletions(-) diff --git a/source/build/include/build.h b/source/build/include/build.h index 44bfc80c1..052d0cd36 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -592,7 +592,7 @@ EXTERN wallext_t *wallext; EXTERN sectortype *sector; EXTERN walltype *wall; EXTERN spritetype *sprite; -EXTERN uspritetype *tsprite; +EXTERN tspriteptr_t tsprite; #else EXTERN spriteext_t spriteext[MAXSPRITES+MAXUNIQHUDID]; EXTERN spritesmooth_t spritesmooth[MAXSPRITES+MAXUNIQHUDID]; @@ -673,7 +673,7 @@ static FORCE_INLINE void sprite_tracker_hook(uintptr_t const address) EXTERN int16_t maskwall[MAXWALLSB], maskwallcnt; EXTERN int16_t thewall[MAXWALLSB]; -EXTERN uspritetype *tspriteptr[MAXSPRITESONSCREEN + 1]; +EXTERN tspriteptr_t tspriteptr[MAXSPRITESONSCREEN + 1]; EXTERN int32_t wx1, wy1, wx2, wy2; EXTERN int32_t xdim, ydim, numpages, upscalefactor; @@ -1170,7 +1170,7 @@ void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t * int32_t inside(int32_t x, int32_t y, int16_t sectnum); void dragpoint(int16_t pointhighlight, int32_t dax, int32_t day, uint8_t flags); void setfirstwall(int16_t sectnum, int16_t newfirstwall); -int32_t try_facespr_intersect(uspritetype const * const spr, const vec3_t *refpos, +int32_t try_facespr_intersect(uspriteptr_t const spr, const vec3_t *refpos, int32_t vx, int32_t vy, int32_t vz, vec3_t *intp, int32_t strictly_smaller_than_p); @@ -1210,29 +1210,29 @@ void rotatepoint(vec2_t const pivot, vec2_t p, int16_t const daang, vec2_t * con int32_t lastwall(int16_t point); int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, int16_t direction); -int32_t getceilzofslopeptr(const usectortype *sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1))); -int32_t getflorzofslopeptr(const usectortype *sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1))); -void getzsofslopeptr(const usectortype *sec, int32_t dax, int32_t day, +int32_t getceilzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1))); +int32_t getflorzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day) ATTRIBUTE((nonnull(1))); +void getzsofslopeptr(usectorptr_t sec, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) ATTRIBUTE((nonnull(1,4,5))); static FORCE_INLINE int32_t getceilzofslope(int16_t sectnum, int32_t dax, int32_t day) { - return getceilzofslopeptr((usectortype *)§or[sectnum], dax, day); + return getceilzofslopeptr((usectorptr_t)§or[sectnum], dax, day); } static FORCE_INLINE int32_t getflorzofslope(int16_t sectnum, int32_t dax, int32_t day) { - return getflorzofslopeptr((usectortype *)§or[sectnum], dax, day); + return getflorzofslopeptr((usectorptr_t)§or[sectnum], dax, day); } static FORCE_INLINE void getzsofslope(int16_t sectnum, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) { - getzsofslopeptr((usectortype *)§or[sectnum], dax, day, ceilz, florz); + getzsofslopeptr((usectorptr_t)§or[sectnum], dax, day, ceilz, florz); } // Is a red wall in a safe fashion, i.e. only if consistency invariant // ".nextsector >= 0 iff .nextwall >= 0" holds. -static FORCE_INLINE CONSTEXPR int32_t redwallp(const uwalltype *wal) +static FORCE_INLINE CONSTEXPR int32_t redwallp(uwallptr_t wal) { return (wal->nextwall >= 0 && wal->nextsector >= 0); } @@ -1242,7 +1242,7 @@ static FORCE_INLINE CONSTEXPR int32_t E_SpriteIsValid(const int32_t i) return ((unsigned)i < MAXSPRITES && sprite[i].statnum != MAXSTATUS); } -int clipshape_idx_for_sprite(uspritetype const * curspr, int curidx); +int clipshape_idx_for_sprite(uspriteptr_t curspr, int curidx); void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z); void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z); @@ -1273,10 +1273,10 @@ int32_t changespritestat(int16_t spritenum, int16_t newstatnum); int32_t setsprite(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2))); int32_t setspritez(int16_t spritenum, const vec3_t *) ATTRIBUTE((nonnull(2))); -int32_t spriteheightofsptr(const uspritetype *spr, int32_t *height, int32_t alsotileyofs); +int32_t spriteheightofsptr(uspriteptr_t spr, int32_t *height, int32_t alsotileyofs); static FORCE_INLINE int32_t spriteheightofs(int16_t i, int32_t *height, int32_t alsotileyofs) { - return spriteheightofsptr((uspritetype *)&sprite[i], height, alsotileyofs); + return spriteheightofsptr((uspriteptr_t)&sprite[i], height, alsotileyofs); } int videoCaptureScreen(const char *filename, char inverseit) ATTRIBUTE((nonnull(1))); diff --git a/source/build/include/clip.h b/source/build/include/clip.h index 579f03f71..696a43bf2 100644 --- a/source/build/include/clip.h +++ b/source/build/include/clip.h @@ -56,8 +56,8 @@ typedef struct typedef struct { int16_t numsectors, numwalls; - usectortype *sector; - uwalltype *wall; + usectorptr_t sector; + uwallptr_t wall; } mapinfo_t; extern int32_t quickloadboard; diff --git a/source/build/include/mdsprite.h b/source/build/include/mdsprite.h index 20ad8f3b1..e2aa8ed9c 100644 --- a/source/build/include/mdsprite.h +++ b/source/build/include/mdsprite.h @@ -207,13 +207,13 @@ typedef struct EXTERN mdmodel_t **models; -void updateanimation(md2model_t *m, const uspritetype *tspr, uint8_t lpal); +void updateanimation(md2model_t *m, tspriteptr_t tspr, uint8_t lpal); FHardwareTexture *mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t surf); void mdinit(void); void freeallmodels(void); void clearskins(int32_t type); -int32_t polymost_mddraw(const uspritetype *tspr); -EXTERN void md3_vox_calcmat_common(const uspritetype *tspr, const vec3f_t *a0, float f, float mat[16]); +int32_t polymost_mddraw(tspriteptr_t tspr); +EXTERN void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float mat[16]); EXTERN int32_t mdpause; EXTERN int32_t nextmodelid; @@ -221,7 +221,7 @@ EXTERN voxmodel_t *voxmodels[MAXVOXELS]; void voxfree(voxmodel_t *m); voxmodel_t *voxload(const char *filnam); -int32_t polymost_voxdraw(voxmodel_t *m, const uspritetype *tspr); +int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr); int md3postload_polymer(md3model_t* m); //int32_t md_thinoutmodel(int32_t modelid, uint8_t *usedframebitmap); diff --git a/source/build/include/polymost.h b/source/build/include/polymost.h index 9bd50c91d..ca1fd0181 100644 --- a/source/build/include/polymost.h +++ b/source/build/include/polymost.h @@ -112,11 +112,11 @@ static inline float getshadefactor(int32_t const shade) #define POLYMOST_CHOOSE_FOG_PAL(fogpal, pal) \ ((fogpal) ? (fogpal) : (pal)) -static FORCE_INLINE int32_t get_floor_fogpal(usectortype const * const sec) +static FORCE_INLINE int32_t get_floor_fogpal(usectorptr_t const sec) { return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->floorpal); } -static FORCE_INLINE int32_t get_ceiling_fogpal(usectortype const * const sec) +static FORCE_INLINE int32_t get_ceiling_fogpal(usectorptr_t const sec) { return POLYMOST_CHOOSE_FOG_PAL(sec->fogpal, sec->ceilingpal); } diff --git a/source/build/src/clip.cpp b/source/build/src/clip.cpp index 768333503..6d1316697 100644 --- a/source/build/src/clip.cpp +++ b/source/build/src/clip.cpp @@ -40,8 +40,8 @@ void engineSetClipMap(mapinfo_t *bak, mapinfo_t *newmap) { numsectors = newmap->numsectors; numwalls = newmap->numwalls; - sector = (sectortype *) newmap->sector; - wall = (walltype *) newmap->wall; + sector = const_cast((sectortype const *)newmap->sector); + wall = const_cast((walltype const *)newmap->wall); } } @@ -524,7 +524,7 @@ int32_t engineLoadClipMaps(void) } -int clipshape_idx_for_sprite(uspritetype const * const curspr, int curidx) +int clipshape_idx_for_sprite(uspriteptr_t const curspr, int curidx) { // per-sprite init curidx = (curidx < 0) ? pictoidx[curspr->picnum] : clipinfo[curidx].next; @@ -535,7 +535,7 @@ int clipshape_idx_for_sprite(uspritetype const * const curspr, int curidx) return curidx; } #else -int32_t clipshape_idx_for_sprite(uspritetype const * const curspr, int32_t curidx) +int32_t clipshape_idx_for_sprite(uspriteptr_t const curspr, int32_t curidx) { (void)curspr; UNREFERENCED_PARAMETER(curidx); @@ -553,11 +553,13 @@ int32_t clipmoveboxtracenum = 3; // int clipinsidebox(vec2_t *vect, int wallnum, int walldist) { - int const r = walldist << 1; - auto const * wal = (uwalltype *)&wall[wallnum]; - vec2_t const v1 = { wal->x + walldist - vect->x, wal->y + walldist - vect->y }; - wal = (uwalltype *)&wall[wal->point2]; - vec2_t v2 = { wal->x + walldist - vect->x, wal->y + walldist - vect->y }; + int const r = walldist << 1; + + auto const wal1 = (uwallptr_t)&wall[wallnum]; + auto const wal2 = (uwallptr_t)&wall[wal1->point2]; + + vec2_t const v1 = { wal1->x + walldist - vect->x, wal1->y + walldist - vect->y }; + vec2_t v2 = { wal2->x + walldist - vect->x, wal2->y + walldist - vect->y }; if (((v1.x < 0) && (v2.x < 0)) || ((v1.y < 0) && (v2.y < 0)) || ((v1.x >= r) && (v2.x >= r)) || ((v1.y >= r) && (v2.y >= r))) return 0; @@ -625,7 +627,7 @@ static inline void addclipsect(int const sectnum) } #ifdef HAVE_CLIPSHAPE_FEATURE -int32_t clipsprite_try(uspritetype const * const spr, int32_t xmin, int32_t ymin, int32_t xmax, int32_t ymax) +int32_t clipsprite_try(uspriteptr_t const spr, int32_t xmin, int32_t ymin, int32_t xmax, int32_t ymax) { // try and see whether this sprite's picnum has sector-like clipping data int32_t i = pictoidx[spr->picnum]; @@ -667,7 +669,7 @@ int32_t clipsprite_try(uspritetype const * const spr, int32_t xmin, int32_t ymin } // return: -1 if curspr has x-flip xor y-flip (in the horizontal map plane!), 1 else -int32_t clipsprite_initindex(int32_t curidx, uspritetype const * const curspr, int32_t *clipsectcnt, const vec3_t *vect) +int32_t clipsprite_initindex(int32_t curidx, uspriteptr_t const curspr, int32_t *clipsectcnt, const vec3_t *vect) { int32_t k, daz = curspr->z; int32_t scalex, scaley, scalez, flipx, flipy; @@ -713,7 +715,7 @@ int32_t clipsprite_initindex(int32_t curidx, uspritetype const * const curspr, i for (k=clipinfo[curidx].qbeg; k<=clipinfo[curidx].qend; k++) { int32_t const j = sectq[k]; - auto const sec = (usectortype *)§or[j]; + auto const sec = §or[j]; int32_t const startwall = sec->wallptr, endwall = startwall+sec->wallnum; @@ -779,7 +781,7 @@ static FORCE_INLINE void clipmove_tweak_pos(const vec3_t *pos, int32_t gx, int32 static int32_t check_floor_curb(int32_t dasect, int32_t nextsect, int32_t flordist, int32_t posz, int32_t dax, int32_t day) { - auto const sec2 = (usectortype *)§or[nextsect]; + auto const sec2 = (usectorptr_t)§or[nextsect]; int32_t const daz2 = getflorzofslope(nextsect, dax, day); return ((sec2->floorstat&1) == 0 && // parallaxed floor curbs don't clip @@ -929,7 +931,7 @@ static void clipupdatesector(vec2_t const &pos, int16_t * const sectnum, int con auto const sec = §or[listsectnum]; int const startwall = sec->wallptr; int const endwall = sec->wallptr + sec->wallnum; - auto uwal = (uwalltype *)&wall[startwall]; + auto uwal = (uwallptr_t)&wall[startwall]; for (int j = startwall; j < endwall; j++, uwal++) if (uwal->nextsector >= 0 && bitmap_test(clipsectormap, uwal->nextsector)) @@ -953,7 +955,7 @@ static void clipupdatesector(vec2_t const &pos, int16_t * const sectnum, int con auto const sec = §or[listsectnum]; int const startwall = sec->wallptr; int const endwall = sec->wallptr + sec->wallnum; - auto uwal = (uwalltype *)&wall[startwall]; + auto uwal = (uwallptr_t)&wall[startwall]; // check floor curbs here? @@ -974,7 +976,7 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int if ((xvect|yvect) == 0 || *sectnum < 0) return 0; - uspritetype const * curspr=NULL; // non-NULL when handling sprite with sector-like clipping + uspriteptr_t curspr=NULL; // non-NULL when handling sprite with sector-like clipping int32_t const dawalclipmask = (cliptype & 65535); // CLIPMASK0 = 0x00010001 int32_t const dasprclipmask = (cliptype >> 16); // CLIPMASK1 = 0x01000040 @@ -1024,7 +1026,7 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int engineSetClipMap(&origmapinfo, &clipmapinfo); } - curspr = (uspritetype *)&sprite[clipspritelist[clipspritecnt]]; + curspr = (uspriteptr_t)&sprite[clipspritelist[clipspritecnt]]; clipshapeidx = clipshape_idx_for_sprite(curspr, clipshapeidx); if (clipshapeidx < 0) @@ -1043,14 +1045,14 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int ////////// Walls ////////// - auto const sec = (usectortype *)§or[dasect]; + auto const sec = (usectorptr_t)§or[dasect]; int const startwall = sec->wallptr; int const endwall = startwall + sec->wallnum; - auto wal = (uwalltype *)&wall[startwall]; + auto wal = (uwallptr_t)&wall[startwall]; for (native_t j=startwall; jpoint2]; + auto const wal2 = (uwallptr_t)&wall[wal->point2]; if ((wal->x < clipMin.x && wal2->x < clipMin.x) || (wal->x > clipMax.x && wal2->x > clipMax.x) || (wal->y < clipMin.y && wal2->y < clipMin.y) || (wal->y > clipMax.y && wal2->y > clipMax.y)) @@ -1076,7 +1078,7 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int { if (wal->nextsector>=0) { - auto const sec2 = (usectortype *)§or[wal->nextsector]; + auto const sec2 = (usectorptr_t)§or[wal->nextsector]; clipmove_tweak_pos(pos, diff.x, diff.y, p1.x, p1.y, p2.x, p2.y, &v.x, &v.y); @@ -1129,7 +1131,7 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int if (clipyou == 0) { - auto const sec2 = (usectortype *)§or[wal->nextsector]; + auto const sec2 = (usectorptr_t)§or[wal->nextsector]; int32_t daz2 = getceilzofslope(wal->nextsector, v.x, v.y); clipyou = ((sec2->ceilingstat&1) == 0 && @@ -1181,7 +1183,7 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int #endif for (int j=headspritesect[dasect]; j>=0; j=nextspritesect[j]) { - auto const spr = (uspritetype *)&sprite[j]; + auto const spr = (uspriteptr_t)&sprite[j]; const int32_t cstat = spr->cstat; if ((cstat&dasprclipmask) == 0) @@ -1257,7 +1259,7 @@ int32_t clipmove(vec3_t * const pos, int16_t * const sectnum, int32_t xvect, int rxi[0] = p1.x; ryi[0] = p1.y; - get_floorspr_points((uspritetype const *) spr, 0, 0, &rxi[0], &rxi[1], &rxi[2], &rxi[3], + get_floorspr_points((uspriteptr_t) spr, 0, 0, &rxi[0], &rxi[1], &rxi[2], &rxi[3], &ryi[0], &ryi[1], &ryi[2], &ryi[3]); vec2_t v = { mulscale14(sintable[(spr->ang-256+512)&2047], walldist), @@ -1398,8 +1400,8 @@ int32_t pushmove(vec3_t * const vect, int16_t * const sectnum, do { - const uwalltype *wal; - const usectortype *sec; + uwallptr_t wal; + usectorptr_t sec; int32_t startwall, endwall; #if 0 // Push FACE sprites @@ -1434,13 +1436,13 @@ int32_t pushmove(vec3_t * const vect, int16_t * const sectnum, } } #endif - sec = (usectortype *)§or[clipsectorlist[clipsectcnt]]; + sec = (usectorptr_t)§or[clipsectorlist[clipsectcnt]]; if (dir > 0) startwall = sec->wallptr, endwall = startwall + sec->wallnum; else endwall = sec->wallptr, startwall = endwall + sec->wallnum; - for (i=startwall, wal=(uwalltype *)&wall[startwall]; i!=endwall; i+=dir, wal+=dir) + for (i=startwall, wal=(uwallptr_t)&wall[startwall]; i!=endwall; i+=dir, wal+=dir) if (clipinsidebox((vec2_t *)vect, i, walldist-4) == 1) { j = 0; @@ -1448,7 +1450,7 @@ int32_t pushmove(vec3_t * const vect, int16_t * const sectnum, if (wal->cstat&dawalclipmask) j = 1; if (j == 0) { - auto const sec2 = (usectortype *)§or[wal->nextsector]; + auto const sec2 = (usectorptr_t)§or[wal->nextsector]; int32_t daz2; //Find closest point on wall (dax, day) to (vect->x, vect->y) @@ -1526,7 +1528,7 @@ void getzrange(const vec3_t *pos, int16_t sectnum, int32_t mcf=-1; #endif - uspritetype *curspr=NULL; // non-NULL when handling sprite with sector-like clipping + uspriteptr_t curspr=NULL; // non-NULL when handling sprite with sector-like clipping int32_t curidx=-1, clipspritecnt = 0; //Extra walldist for sprites on sector lines @@ -1570,7 +1572,7 @@ restart_grand: { // one set of clip-sprite sectors completed, prepare the next - curspr = (uspritetype *)&sprite[clipspritelist[clipspritecnt]]; + curspr = (uspriteptr_t)&sprite[clipspritelist[clipspritecnt]]; curidx = clipshape_idx_for_sprite(curspr, curidx); if (curidx < 0) @@ -1610,7 +1612,7 @@ restart_grand: #endif ////////// Walls ////////// - auto const startsec = (usectortype *)§or[clipsectorlist[clipsectcnt]]; + auto const startsec = (usectorptr_t)§or[clipsectorlist[clipsectcnt]]; const int startwall = startsec->wallptr; const int endwall = startwall + startsec->wallnum; @@ -1637,7 +1639,7 @@ restart_grand: continue; if (wall[j].cstat&dawalclipmask) continue; // XXX? - auto const sec = (usectortype *)§or[k]; + auto const sec = (usectorptr_t)§or[k]; #ifdef HAVE_CLIPSHAPE_FEATURE if (curspr) @@ -1741,7 +1743,7 @@ restart_grand: int32_t clipyou = 0; #ifdef HAVE_CLIPSHAPE_FEATURE - if (clipsprite_try((uspritetype *)&sprite[j], xmin,ymin, xmax,ymax)) + if (clipsprite_try((uspriteptr_t)&sprite[j], xmin,ymin, xmax,ymax)) continue; #endif vec2_t v1 = *(vec2_t *)&sprite[j]; @@ -1763,7 +1765,7 @@ restart_grand: case CSTAT_SPRITE_ALIGNMENT_WALL: { vec2_t v2; - get_wallspr_points((uspritetype *)&sprite[j], &v1.x, &v2.x, &v1.y, &v2.y); + get_wallspr_points((uspriteptr_t)&sprite[j], &v1.x, &v2.x, &v1.y, &v2.y); if (clipinsideboxline(pos->x,pos->y,v1.x,v1.y,v2.x,v2.y,walldist+1) != 0) { @@ -1783,7 +1785,7 @@ restart_grand: continue; vec2_t v2, v3, v4; - get_floorspr_points((uspritetype const *) &sprite[j], pos->x, pos->y, &v1.x, &v2.x, &v3.x, &v4.x, + get_floorspr_points((uspriteptr_t) &sprite[j], pos->x, pos->y, &v1.x, &v2.x, &v3.x, &v4.x, &v1.y, &v2.y, &v3.y, &v4.y); vec2_t const da = { mulscale14(sintable[(sprite[j].ang - 256 + 512) & 2047], walldist + 4), @@ -1921,7 +1923,7 @@ restart_grand: // intp: point of currently best (closest) intersection -int32_t try_facespr_intersect(uspritetype const * const spr, const vec3_t *refpos, +int32_t try_facespr_intersect(uspriteptr_t const spr, const vec3_t *refpos, int32_t vx, int32_t vy, int32_t vz, vec3_t *intp, int32_t strictly_smaller_than_p) { @@ -1983,7 +1985,7 @@ static int32_t hitscan_hitsectcf=-1; // stat, heinum, z: either ceiling- or floor- // how: -1: behave like ceiling, 1: behave like floor -static int32_t hitscan_trysector(const vec3_t *sv, const usectortype *sec, hitdata_t *hit, +static int32_t hitscan_trysector(const vec3_t *sv, usectorptr_t sec, hitdata_t *hit, int32_t vx, int32_t vy, int32_t vz, uint16_t stat, int16_t heinum, int32_t z, int32_t how, const intptr_t *tmp) { @@ -1992,8 +1994,8 @@ static int32_t hitscan_trysector(const vec3_t *sv, const usectortype *sec, hitda if (stat&2) { - auto const wal = (uwalltype *)&wall[sec->wallptr]; - auto const wal2 = (uwalltype *)&wall[wal->point2]; + auto const wal = (uwallptr_t)&wall[sec->wallptr]; + auto const wal2 = (uwallptr_t)&wall[wal->point2]; int32_t j, dax=wal2->x-wal->x, day=wal2->y-wal->y; i = nsqrtasm(uhypsq(dax,day)); if (i == 0) return 1; //continue; @@ -2074,7 +2076,7 @@ int32_t hitscan(const vec3_t *sv, int16_t sectnum, int32_t vx, int32_t vy, int32 int32_t i, k, daz; int16_t tempshortcnt, tempshortnum; - uspritetype *curspr = NULL; + uspriteptr_t curspr = NULL; int32_t clipspritecnt, curidx=-1; // tmp: { (int32_t)curidx, (spritetype *)curspr, (!=0 if outer sector) } intptr_t tmp[3], *tmpptr=NULL; @@ -2110,7 +2112,7 @@ restart_grand: if (!curspr) engineSetClipMap(&origmapinfo, &clipmapinfo); // replace sector and wall with clip map - curspr = (uspritetype *)&sprite[clipspritelist[clipspritecnt]]; + curspr = (uspriteptr_t)&sprite[clipspritelist[clipspritecnt]]; curidx = clipshape_idx_for_sprite(curspr, curidx); if (curidx < 0) @@ -2129,7 +2131,7 @@ restart_grand: } #endif dasector = clipsectorlist[tempshortcnt]; - auto const sec = (usectortype *)§or[dasector]; + auto const sec = (usectorptr_t)§or[dasector]; i = 1; #ifdef HAVE_CLIPSHAPE_FEATURE @@ -2153,8 +2155,8 @@ restart_grand: startwall = sec->wallptr; endwall = startwall + sec->wallnum; for (z=startwall; zpoint2]; + auto const wal = (uwallptr_t)&wall[z]; + auto const wal2 = (uwallptr_t)&wall[wal->point2]; int const nextsector = wal->nextsector; @@ -2221,7 +2223,7 @@ restart_grand: #endif for (z=headspritesect[dasector]; z>=0; z=nextspritesect[z]) { - auto const spr = (uspritetype *)&sprite[z]; + auto const spr = (uspriteptr_t)&sprite[z]; const int32_t cstat = spr->cstat; #ifdef USE_OPENGL if (!hitallsprites) @@ -2325,7 +2327,7 @@ restart_grand: if (klabs(intx-sv->x)+klabs(inty-sv->y) > klabs((hit->pos.x)-sv->x)+klabs((hit->pos.y)-sv->y)) continue; - get_floorspr_points((uspritetype const *)spr, intx, inty, &x1, &x2, &x3, &x4, + get_floorspr_points((uspriteptr_t)spr, intx, inty, &x1, &x2, &x3, &x4, &y1, &y2, &y3, &y4); if (get_floorspr_clipyou(x1, x2, x3, x4, y1, y2, y3, y4)) diff --git a/source/build/src/engine.cpp b/source/build/src/engine.cpp index 08c26326c..852a07a1d 100644 --- a/source/build/src/engine.cpp +++ b/source/build/src/engine.cpp @@ -779,7 +779,7 @@ static void yax_copytsprites() { int32_t i, spritenum, gotthrough, sectnum; int32_t sortcnt = yax_spritesortcnt[yax_globallev]; - const uspritetype *spr; + uspriteptr_t spr; for (i=0; isectnum; if (gotthrough == (MAXSPRITES|(MAXSPRITES<<1))) @@ -1478,7 +1478,7 @@ char apptitle[256] = "Build Engine"; // 1=break out of sprite collecting; int32_t renderAddTsprite(int16_t z, int16_t sectnum) { - auto const spr = (uspritetype *)&sprite[z]; + auto const spr = (uspriteptr_t)&sprite[z]; #ifdef YAX_ENABLE if (g_nodraw==0) { @@ -1663,7 +1663,7 @@ static void classicScanSector(int16_t startsectnum) #endif for (bssize_t i=headspritesect[sectnum]; i>=0; i=nextspritesect[i]) { - auto const spr = (uspritetype *)&sprite[i]; + auto const spr = (uspriteptr_t)&sprite[i]; if (((spr->cstat & 0x8000) && !showinvisibility) || spr->xrepeat == 0 || spr->yrepeat == 0) continue; @@ -1689,9 +1689,9 @@ static void classicScanSector(int16_t startsectnum) for (bssize_t w=startwall; wnextsector; - auto const wal2 = (uwalltype *)&wall[wal->point2]; + auto const wal2 = (uwallptr_t)&wall[wal->point2]; const int32_t x1 = wal->x-globalposx, y1 = wal->y-globalposy; const int32_t x2 = wal2->x-globalposx, y2 = wal2->y-globalposy; @@ -2077,10 +2077,10 @@ int32_t wallfront(int32_t l1, int32_t l2) // // spritewallfront (internal) // -static inline int32_t spritewallfront(const uspritetype *s, int32_t w) +static inline int32_t spritewallfront(uspriteptr_t s, int32_t w) { - auto const wal = (uwalltype *)&wall[w]; - auto const wal2 = (uwalltype *)&wall[wal->point2]; + auto const wal = (uwallptr_t)&wall[w]; + auto const wal2 = (uwallptr_t)&wall[wal->point2]; const vec2_t v = { wal->x, wal->y }; return dmulscale32(wal2->x - v.x, s->y - v.y, -(s->x - v.x), wal2->y - v.y) >= 0; @@ -2210,7 +2210,7 @@ static inline void slowhline(int32_t xr, int32_t yp) // // prepwall (internal) // -static void prepwall(int32_t z, const uwalltype *wal) +static void prepwall(int32_t z, uwallptr_t wal) { int32_t l=0, ol=0, x; @@ -2487,7 +2487,7 @@ static int32_t wallmost(int16_t *mostbuf, int32_t w, int32_t sectnum, char dasta if (wi == sector[sectnum].wallptr) return owallmost(mostbuf,w,z); - auto const wal = (uwalltype *)&wall[wi]; + auto const wal = (uwallptr_t)&wall[wi]; const int32_t x1 = wal->x, x2 = wall[wal->point2].x-x1; const int32_t y1 = wal->y, y2 = wall[wal->point2].y-y1; @@ -2614,7 +2614,7 @@ static void calc_globalshifts(void) if (globalyshift > 31) globalyshift=0; } -static int32_t setup_globals_cf1(const usectortype *sec, int32_t pal, int32_t zd, +static int32_t setup_globals_cf1(usectorptr_t sec, int32_t pal, int32_t zd, int32_t picnum, int32_t shade, int32_t stat, int32_t xpanning, int32_t ypanning, int32_t x1) { @@ -2709,7 +2709,7 @@ static int32_t setup_globals_cf1(const usectortype *sec, int32_t pal, int32_t zd static void ceilscan(int32_t x1, int32_t x2, int32_t sectnum) { int32_t x, y1, y2; - auto const sec = (usectortype *)§or[sectnum]; + auto const sec = (usectorptr_t)§or[sectnum]; if (setup_globals_cf1(sec, sec->ceilingpal, sec->ceilingz-globalposz, sec->ceilingpicnum, sec->ceilingshade, sec->ceilingstat, @@ -2807,7 +2807,7 @@ static void ceilscan(int32_t x1, int32_t x2, int32_t sectnum) static void florscan(int32_t x1, int32_t x2, int32_t sectnum) { int32_t x, y1, y2; - auto const sec = (usectortype *)§or[sectnum]; + auto const sec = (usectorptr_t)§or[sectnum]; if (setup_globals_cf1(sec, sec->floorpal, globalposz-sec->floorz, sec->floorpicnum, sec->floorshade, sec->floorstat, @@ -3429,8 +3429,8 @@ static void grouscan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat) // Er, yes, they're not global anymore: int32_t globalx, globaly, globalz, globalzx; - auto const sec = (usectortype *)§or[sectnum]; - const uwalltype *wal; + auto const sec = (usectorptr_t)§or[sectnum]; + uwallptr_t wal; if (dastat == 0) { @@ -3460,7 +3460,7 @@ static void grouscan(int32_t dax1, int32_t dax2, int32_t sectnum, char dastat) if ((tilesiz[globalpicnum].x <= 0) || (tilesiz[globalpicnum].y <= 0)) return; if (waloff[globalpicnum] == 0) tileLoad(globalpicnum); - wal = (uwalltype *)&wall[sec->wallptr]; + wal = (uwallptr_t)&wall[sec->wallptr]; wx = wall[wal->point2].x - wal->x; wy = wall[wal->point2].y - wal->y; dasqr = krecipasm(nsqrtasm(uhypsq(wx,wy))); @@ -3614,7 +3614,7 @@ static void parascan(char dastat, int32_t bunch) int32_t logtilesizy, tsizy; int32_t sectnum = thesector[bunchfirst[bunch]]; - auto const sec = (usectortype *)§or[sectnum]; + auto const sec = (usectorptr_t)§or[sectnum]; globalhorizbak = globalhoriz; globvis = globalpisibility; @@ -3793,7 +3793,7 @@ static void parascan(char dastat, int32_t bunch) // set orientation, panning, shade, pal; picnum -static void setup_globals_wall1(const uwalltype *wal, int32_t dapicnum) +static void setup_globals_wall1(uwallptr_t wal, int32_t dapicnum) { globalorientation = wal->cstat; @@ -3809,7 +3809,7 @@ static void setup_globals_wall1(const uwalltype *wal, int32_t dapicnum) if (palookup[globalpal] == NULL) globalpal = 0; // JBF: fixes crash } -static void setup_globals_wall2(const uwalltype *wal, uint8_t secvisibility, int32_t topzref, int32_t botzref) +static void setup_globals_wall2(uwallptr_t wal, uint8_t secvisibility, int32_t topzref, int32_t botzref) { const int32_t logtilesizy = (picsiz[globalpicnum]>>4); const int32_t tsizy = tilesiz[globalpicnum].y; @@ -3913,7 +3913,7 @@ static void classicDrawBunches(int32_t bunch) int32_t z = bunchfirst[bunch]; const int32_t sectnum = thesector[z]; - auto const sec = (usectortype *)§or[sectnum]; + auto const sec = (usectorptr_t)§or[sectnum]; uint8_t andwstat1 = 0xff, andwstat2 = 0xff; @@ -4040,10 +4040,10 @@ static void classicDrawBunches(int32_t bunch) } const int32_t wallnum = thewall[z]; - auto const wal = (uwalltype *)&wall[wallnum]; + auto const wal = (uwallptr_t)&wall[wallnum]; const int32_t nextsectnum = wal->nextsector; - auto const nextsec = nextsectnum>=0 ? (usectortype *)§or[nextsectnum] : NULL; + auto const nextsec = nextsectnum>=0 ? (usectorptr_t)§or[nextsectnum] : NULL; int32_t gotswall = 0; @@ -4214,7 +4214,7 @@ static void classicDrawBunches(int32_t bunch) searchstat = 0; searchit = 1; } - auto const twal = (wal->cstat&2) ? (uwalltype *)&wall[wal->nextwall] : wal; + auto const twal = (wal->cstat&2) ? (uwallptr_t)&wall[wal->nextwall] : wal; setup_globals_wall1(twal, twal->picnum); setup_globals_wall2(wal, sec->visibility, nextsec->floorz, sec->ceilingz); @@ -4694,7 +4694,7 @@ static void classicDrawVoxel(int32_t dasprx, int32_t daspry, int32_t dasprz, int } -static void setup_globals_sprite1(const uspritetype *tspr, const usectortype *sec, +static void setup_globals_sprite1(tspriteptr_t tspr, usectorptr_t sec, int32_t yspan, int32_t yoff, int32_t tilenum, int32_t cstat, int32_t *z1ptr, int32_t *z2ptr) { @@ -4808,7 +4808,7 @@ static void classicDrawSprite(int32_t snum) const int32_t spritenum = tspr->owner; const float alpha = spriteext[spritenum].alpha; - auto const sec = (usectortype *)§or[sectnum]; + auto const sec = (usectorptr_t)§or[sectnum]; int32_t cstat=tspr->cstat, tilenum; @@ -5880,10 +5880,10 @@ static void renderDrawMaskedWall(int16_t damaskwallcnt) //============================================================================= //POLYMOST ENDS int32_t z = maskwall[damaskwallcnt]; - auto wal = (uwalltype *)&wall[thewall[z]]; + auto wal = (uwallptr_t)&wall[thewall[z]]; int32_t sectnum = thesector[z]; - auto sec = (usectortype *)§or[sectnum]; - auto nsec = (usectortype *)§or[wal->nextsector]; + auto sec = (usectorptr_t)§or[sectnum]; + auto nsec = (usectorptr_t)§or[wal->nextsector]; int32_t z1 = max(nsec->ceilingz,sec->ceilingz); int32_t z2 = min(nsec->floorz,sec->floorz); @@ -7669,7 +7669,7 @@ static walltype wall_s[MAXWALLS + M32_FIXME_WALLS]; static wallext_t wallext_s[MAXWALLS]; #endif static spritetype sprite_s[MAXSPRITES]; -static uspritetype tsprite_s[MAXSPRITESONSCREEN]; +static tspritetype tsprite_s[MAXSPRITESONSCREEN]; #endif int32_t enginePreInit(void) @@ -8306,8 +8306,8 @@ static inline _equation equation(float const x1, float const y1, float const x2, int32_t wallvisible(int32_t const x, int32_t const y, int16_t const wallnum) { // 1 if wall is in front of player 0 otherwise - auto w1 = (uwalltype *)&wall[wallnum]; - auto w2 = (uwalltype *)&wall[w1->point2]; + auto w1 = (uwallptr_t)&wall[wallnum]; + auto w2 = (uwallptr_t)&wall[w1->point2]; int32_t const a1 = getangle(w1->x - x, w1->y - y); int32_t const a2 = getangle(w2->x - x, w2->y - y); @@ -8634,7 +8634,7 @@ killsprite: if ((tspr->cstat & 48) != 16) tspriteptr[i]->ang = globalang; - get_wallspr_points((const uspritetype *)tspr, &xx[0], &xx[1], &yy[0], &yy[1]); + get_wallspr_points((uspriteptr_t)tspr, &xx[0], &xx[1], &yy[0], &yy[1]); if ((tspr->cstat & 48) == 0) tspriteptr[i]->ang = oang; @@ -8779,9 +8779,9 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang) videoBeginDrawing(); //{{{ - usectortype *sec; + usectorptr_t sec; - for (s=0,sec=(usectortype *)§or[s]; s>3]&pow2char[s&7]) { #ifdef YAX_ENABLE @@ -8804,9 +8804,9 @@ void renderDrawMapView(int32_t dax, int32_t day, int32_t zoome, int16_t ang) } #else j = startwall; l = 0; - uwalltype *wal; + uwallptr_t wal; int32_t w; - for (w=sec->wallnum,wal=(uwalltype *)&wall[startwall]; w>0; w--,wal++,j++) + for (w=sec->wallnum,wal=(uwallptr_t)&wall[startwall]; w>0; w--,wal++,j++) { k = lastwall(j); if ((k > j) && (npoints > 0)) { xb1[npoints-1] = l; l = npoints; } //overwrite point2 @@ -10215,15 +10215,16 @@ int32_t inside(int32_t x, int32_t y, int16_t sectnum) if ((unsigned)sectnum < (unsigned)numsectors) { uint32_t cnt1 = 0, cnt2 = 0; - auto wal = (uwalltype *) &wall[sector[sectnum].wallptr]; - int wallsleft = sector[sectnum].wallnum; + + auto wal = (uwallptr_t)&wall[sector[sectnum].wallptr]; + int wallsleft = sector[sectnum].wallnum; do { // Get the x and y components of the [tested point]-->[wall // point{1,2}] vectors. vec2_t v1 = { wal->x - x, wal->y - y }; - auto const &wal2 = *(uwalltype *)&wall[wal->point2]; + auto const &wal2 = *(uwallptr_t)&wall[wal->point2]; vec2_t v2 = { wal2.x - x, wal2.y - y }; // First, test if the point is EXACTLY_ON_WALL_POINT. @@ -10304,7 +10305,7 @@ int32_t Mulscale(int32_t a, int32_t b, int32_t sh) // Gets the BUILD unit height and z offset of a sprite. // Returns the z offset, 'height' may be NULL. -int32_t spriteheightofsptr(const uspritetype *spr, int32_t *height, int32_t alsotileyofs) +int32_t spriteheightofsptr(uspriteptr_t spr, int32_t *height, int32_t alsotileyofs) { int32_t hei, zofs=0; const int32_t picnum=spr->picnum, yrepeat=spr->yrepeat; @@ -10372,7 +10373,7 @@ int32_t nextsectorneighborz(int16_t sectnum, int32_t refz, int16_t topbottom, in int32_t nextz = (direction==1) ? INT32_MAX : INT32_MIN; int32_t sectortouse = -1; - auto wal = (uwalltype *)&wall[sector[sectnum].wallptr]; + auto wal = (uwallptr_t)&wall[sector[sectnum].wallptr]; int32_t i = sector[sectnum].wallnum; do @@ -10441,8 +10442,8 @@ restart_grand: for (dacnt=0; dacntwallnum,wal=(uwalltype *)&wall[sec->wallptr]; cnt>0; cnt--,wal++) + for (cnt=sec->wallnum,wal=(uwallptr_t)&wall[sec->wallptr]; cnt>0; cnt--,wal++) { - auto const wal2 = (uwalltype *)&wall[wal->point2]; + auto const wal2 = (uwallptr_t)&wall[wal->point2]; const int32_t x31 = wal->x-x1, x34 = wal->x-wal2->x; const int32_t y31 = wal->y-y1, y34 = wal->y-wal2->y; @@ -10587,7 +10588,7 @@ add_nextsector: // x1, y1: in/out // rest x/y: out -void get_wallspr_points(uspritetype const * const spr, int32_t *x1, int32_t *x2, +void get_wallspr_points(uspriteptr_t const spr, int32_t *x1, int32_t *x2, int32_t *y1, int32_t *y2) { //These lines get the 2 points of the rotated sprite @@ -10616,7 +10617,7 @@ void get_wallspr_points(uspritetype const * const spr, int32_t *x1, int32_t *x2, // x1, y1: in/out // rest x/y: out -void get_floorspr_points(uspritetype const * const spr, int32_t px, int32_t py, +void get_floorspr_points(uspriteptr_t const spr, int32_t px, int32_t py, int32_t *x1, int32_t *x2, int32_t *x3, int32_t *x4, int32_t *y1, int32_t *y2, int32_t *y3, int32_t *y4) { @@ -10679,12 +10680,12 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, const int32_t startwall = sector[dasector].wallptr; const int32_t endwall = startwall + sector[dasector].wallnum - 1; - const uwalltype *wal; + uwallptr_t wal; int32_t z; - for (z=startwall,wal=(uwalltype *)&wall[startwall]; z<=endwall; z++,wal++) + for (z=startwall,wal=(uwallptr_t)&wall[startwall]; z<=endwall; z++,wal++) { - auto const wal2 = (uwalltype *)&wall[wal->point2]; + auto const wal2 = (uwallptr_t)&wall[wal->point2]; const int32_t nextsector = wal->nextsector; const int32_t x1=wal->x, y1=wal->y, x2=wal2->x, y2=wal2->y; @@ -10729,7 +10730,7 @@ void neartag(int32_t xs, int32_t ys, int32_t zs, int16_t sectnum, int16_t ange, for (z=headspritesect[dasector]; z>=0; z=nextspritesect[z]) { - auto const spr = (uspritetype *)&sprite[z]; + auto const spr = (uspriteptr_t)&sprite[z]; if (blacklist_sprite_func && blacklist_sprite_func(z)) continue; @@ -10981,10 +10982,10 @@ int32_t getsectordist(vec2_t const &pos, int const sectnum) int32_t distance = INT32_MAX; - auto const sec = (usectortype *)§or[sectnum]; + auto const sec = (usectorptr_t)§or[sectnum]; int const startwall = sec->wallptr; int const endwall = sec->wallptr + sec->wallnum; - auto uwal = (uwalltype *)&wall[startwall]; + auto uwal = (uwallptr_t)&wall[startwall]; for (int j = startwall; j < endwall; j++, uwal++) { @@ -11038,7 +11039,7 @@ void updatesector(int32_t const x, int32_t const y, int16_t * const sectnum) auto const sec = §or[listsectnum]; int const startwall = sec->wallptr; int const endwall = sec->wallptr + sec->wallnum; - auto uwal = (uwalltype *)&wall[startwall]; + auto uwal = (uwallptr_t)&wall[startwall]; for (int j=startwall; jnextsector >= 0 && getsectordist({x, y}, uwal->nextsector) < MAXUPDATESECTORDIST) @@ -11062,7 +11063,7 @@ void updatesectorexclude(int32_t const x, int32_t const y, int16_t * const sectn if (*sectnum >= 0 && *sectnum < numsectors) { - auto wal = (uwalltype *)&wall[sector[*sectnum].wallptr]; + auto wal = (uwallptr_t)&wall[sector[*sectnum].wallptr]; int wallsleft = sector[*sectnum].wallnum; do @@ -11140,7 +11141,7 @@ void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int16_t * auto const sec = §or[listsectnum]; int const startwall = sec->wallptr; int const endwall = sec->wallptr + sec->wallnum; - auto uwal = (uwalltype *)&wall[startwall]; + auto uwal = (uwallptr_t)&wall[startwall]; for (int j=startwall; jnextsector >= 0 && getsectordist({x, y}, uwal->nextsector) < MAXUPDATESECTORDIST) @@ -11750,13 +11751,13 @@ int32_t sectorofwall_noquick(int16_t wallNum) } -int32_t getceilzofslopeptr(const usectortype *sec, int32_t dax, int32_t day) +int32_t getceilzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day) { if (!(sec->ceilingstat&2)) return sec->ceilingz; - auto const wal = (uwalltype *)&wall[sec->wallptr]; - auto const wal2 = (uwalltype *)&wall[wal->point2]; + auto const wal = (uwallptr_t)&wall[sec->wallptr]; + auto const wal2 = (uwallptr_t)&wall[wal->point2]; vec2_t const w = *(vec2_t const *)wal; vec2_t const d = { wal2->x - w.x, wal2->y - w.y }; @@ -11768,13 +11769,13 @@ int32_t getceilzofslopeptr(const usectortype *sec, int32_t dax, int32_t day) return sec->ceilingz + (scale(sec->ceilingheinum,j>>1,i)<<1); } -int32_t getflorzofslopeptr(const usectortype *sec, int32_t dax, int32_t day) +int32_t getflorzofslopeptr(usectorptr_t sec, int32_t dax, int32_t day) { if (!(sec->floorstat&2)) return sec->floorz; - auto const wal = (uwalltype *)&wall[sec->wallptr]; - auto const wal2 = (uwalltype *)&wall[wal->point2]; + auto const wal = (uwallptr_t)&wall[sec->wallptr]; + auto const wal2 = (uwallptr_t)&wall[wal->point2]; vec2_t const w = *(vec2_t const *)wal; vec2_t const d = { wal2->x - w.x, wal2->y - w.y }; @@ -11786,15 +11787,15 @@ int32_t getflorzofslopeptr(const usectortype *sec, int32_t dax, int32_t day) return sec->floorz + (scale(sec->floorheinum,j>>1,i)<<1); } -void getzsofslopeptr(const usectortype *sec, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) +void getzsofslopeptr(usectorptr_t sec, int32_t dax, int32_t day, int32_t *ceilz, int32_t *florz) { *ceilz = sec->ceilingz; *florz = sec->floorz; if (((sec->ceilingstat|sec->floorstat)&2) != 2) return; - auto const wal = (uwalltype *)&wall[sec->wallptr]; - auto const wal2 = (uwalltype *)&wall[wal->point2]; + auto const wal = (uwallptr_t)&wall[sec->wallptr]; + auto const wal2 = (uwallptr_t)&wall[wal->point2]; vec2_t const d = { wal2->x - wal->x, wal2->y - wal->y }; @@ -11814,7 +11815,7 @@ void getzsofslopeptr(const usectortype *sec, int32_t dax, int32_t day, int32_t * // void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z) { - auto const wal = (uwalltype *)&wall[sector[dasect].wallptr]; + auto const wal = (uwallptr_t)&wall[sector[dasect].wallptr]; const int32_t dax = wall[wal->point2].x-wal->x; const int32_t day = wall[wal->point2].y-wal->y; @@ -11835,7 +11836,7 @@ void alignceilslope(int16_t dasect, int32_t x, int32_t y, int32_t z) // void alignflorslope(int16_t dasect, int32_t x, int32_t y, int32_t z) { - auto const wal = (uwalltype *)&wall[sector[dasect].wallptr]; + auto const wal = (uwallptr_t)&wall[sector[dasect].wallptr]; const int32_t dax = wall[wal->point2].x-wal->x; const int32_t day = wall[wal->point2].y-wal->y; diff --git a/source/build/src/engine_priv.h b/source/build/src/engine_priv.h index 3eebaa97d..604d4e047 100644 --- a/source/build/src/engine_priv.h +++ b/source/build/src/engine_priv.h @@ -208,7 +208,7 @@ extern uint16_t ATTRIBUTE((used)) sqrtable[4096], ATTRIBUTE((used)) shlookup[409 extern int16_t thesector[MAXWALLSB], thewall[MAXWALLSB]; extern int16_t bunchfirst[MAXWALLSB], bunchlast[MAXWALLSB]; extern int16_t maskwall[MAXWALLSB], maskwallcnt; -extern uspritetype *tspriteptr[MAXSPRITESONSCREEN + 1]; +extern tspriteptr_t tspriteptr[MAXSPRITESONSCREEN + 1]; extern int32_t xdimen, xdimenrecip, halfxdimen, xdimenscale, xdimscale, ydimen; extern float fxdimen; extern intptr_t frameoffset; @@ -258,9 +258,9 @@ void calc_and_apply_fog(int32_t shade, int32_t vis, int32_t pal); void calc_and_apply_fog_factor(int32_t shade, int32_t vis, int32_t pal, float factor); #endif -extern void get_wallspr_points(uspritetype const * spr, int32_t *x1, int32_t *x2, +extern void get_wallspr_points(uspriteptr_t spr, int32_t *x1, int32_t *x2, int32_t *y1, int32_t *y2); -extern void get_floorspr_points(uspritetype const * spr, int32_t px, int32_t py, +extern void get_floorspr_points(uspriteptr_t spr, int32_t px, int32_t py, int32_t *x1, int32_t *x2, int32_t *x3, int32_t *x4, int32_t *y1, int32_t *y2, int32_t *y3, int32_t *y4); @@ -276,7 +276,7 @@ int32_t animateoffs(int tilenum); if ((((Fakevar) & 16384) == 16384) && (globalorientation & CSTAT_WALL_ROTATE_90) && rottile[Picnum].newtile != -1) Picnum = rottile[Picnum].newtile; \ } while (0) -static FORCE_INLINE int32_t bad_tspr(const uspritetype *tspr) +static FORCE_INLINE int32_t bad_tspr(tspriteptr_t tspr) { // NOTE: tspr->owner >= MAXSPRITES (could be model) has to be handled by // caller. diff --git a/source/build/src/mdsprite.cpp b/source/build/src/mdsprite.cpp index 971ea5495..f1a0c7dc7 100644 --- a/source/build/src/mdsprite.cpp +++ b/source/build/src/mdsprite.cpp @@ -913,7 +913,7 @@ FHardwareTexture *mdloadskin(md2model_t *m, int32_t number, int32_t pal, int32_t } //Note: even though it says md2model, it works for both md2model&md3model -void updateanimation(md2model_t *m, const uspritetype *tspr, uint8_t lpal) +void updateanimation(md2model_t *m, tspriteptr_t tspr, uint8_t lpal) { if (m->numframes < 2) { @@ -1845,7 +1845,7 @@ int md3postload_polymer(md3model_t *m) } -void md3_vox_calcmat_common(const uspritetype *tspr, const vec3f_t *a0, float f, float mat[16]) +void md3_vox_calcmat_common(tspriteptr_t tspr, const vec3f_t *a0, float f, float mat[16]) { float g; float k0, k1, k2, k3, k4, k5, k6, k7; @@ -1899,7 +1899,7 @@ static void md3draw_handle_triangles(const md3surf_t *s, uint16_t *indexhandle, #endif } -static int32_t polymost_md3draw(md3model_t *m, const uspritetype *tspr) +static int32_t polymost_md3draw(md3model_t *m, tspriteptr_t tspr) { vec3f_t m0, m1, a0; md3xyzn_t *v0, *v1; @@ -2364,7 +2364,7 @@ mdmodel_t *mdload(const char *filnam) } -int32_t polymost_mddraw(const uspritetype *tspr) +int32_t polymost_mddraw(tspriteptr_t tspr) { if (maxmodelverts > allocmodelverts) { diff --git a/source/build/src/voxmodel.cpp b/source/build/src/voxmodel.cpp index 4a37a15e9..443db0d8e 100644 --- a/source/build/src/voxmodel.cpp +++ b/source/build/src/voxmodel.cpp @@ -897,7 +897,7 @@ voxmodel_t *voxload(const char *filnam) //Draw voxel model as perfect cubes // Note: This is a hopeless mess that totally forfeits any chance of using a vertex buffer with its messy coordinate adjustments. :( -int32_t polymost_voxdraw(voxmodel_t *m, const uspritetype *tspr) +int32_t polymost_voxdraw(voxmodel_t *m, tspriteptr_t const tspr) { // float clut[6] = {1.02,1.02,0.94,1.06,0.98,0.98}; float f, g, k0; diff --git a/source/duke3d/src/actors.cpp b/source/duke3d/src/actors.cpp index bdef1ac3e..9f1ab52be 100644 --- a/source/duke3d/src/actors.cpp +++ b/source/duke3d/src/actors.cpp @@ -94,7 +94,7 @@ void G_ClearCameraView(DukePlayer_t *ps) } // Manhattan distance between wall-point and sprite. -static FORCE_INLINE int32_t G_WallSpriteDist(uwalltype const * const wal, uspritetype const * const spr) +static FORCE_INLINE int32_t G_WallSpriteDist(uwallptr_t const wal, uspriteptr_t const spr) { return klabs(wal->x - spr->x) + klabs(wal->y - spr->y); } @@ -107,7 +107,7 @@ void A_RadiusDamage(int spriteNum, int blastRadius, int dmg1, int dmg2, int dmg3 ud.returnvar[3] = dmg3; ud.returnvar[4] = dmg4; - uspritetype const *const pSprite = (uspritetype *)&sprite[spriteNum]; + auto const pSprite = (uspriteptr_t)&sprite[spriteNum]; int32_t sectorCount = 0; int32_t numSectors = 1; @@ -127,8 +127,8 @@ void A_RadiusDamage(int spriteNum, int blastRadius, int dmg1, int dmg2, int dmg3 // Check if "hit" 1st or 3rd wall-point. This mainly makes sense // for rectangular "ceiling light"-style sectors. - if (G_WallSpriteDist((uwalltype *)&wall[startWall], pSprite) < blastRadius || - G_WallSpriteDist((uwalltype *)&wall[wall[w2].point2], pSprite) < blastRadius) + if (G_WallSpriteDist((uwallptr_t)&wall[startWall], pSprite) < blastRadius || + G_WallSpriteDist((uwallptr_t)&wall[wall[w2].point2], pSprite) < blastRadius) { if (((sector[sectorNum].ceilingz-pSprite->z)>>8) < blastRadius) Sect_DamageCeiling_Internal(spriteNum, sectorNum); @@ -138,7 +138,7 @@ void A_RadiusDamage(int spriteNum, int blastRadius, int dmg1, int dmg2, int dmg3 native_t w = startWall; - for (uwalltype const *pWall = (uwalltype *)&wall[startWall]; w < endWall; w++, pWall++) + for (auto pWall = (uwallptr_t)&wall[startWall]; w < endWall; w++, pWall++) { if (G_WallSpriteDist(pWall, pSprite) >= blastRadius) continue; @@ -324,14 +324,15 @@ next_sprite: // : the projectile // : the SE7 // : below->above change? -static int32_t Proj_MaybeDoTransport(int32_t spriteNum, const uspritetype * const pSEffector, int32_t fromunderp, int32_t daz) +static int32_t Proj_MaybeDoTransport(int32_t spriteNum, uspriteptr_t const pSEffector, int32_t fromunderp, int32_t daz) { if ((totalclock & UINT8_MAX) == actor[spriteNum].lasttransport) return 0; - spritetype *const pSprite = &sprite[spriteNum]; - const uspritetype *const otherse = (uspritetype *)&sprite[pSEffector->owner]; - actor[spriteNum].lasttransport = (totalclock & UINT8_MAX); + auto const pSprite = &sprite[spriteNum]; + auto const otherse = (uspriteptr_t)&sprite[pSEffector->owner]; + + actor[spriteNum].lasttransport = (totalclock & UINT8_MAX); pSprite->x += (otherse->x - pSEffector->x); pSprite->y += (otherse->y - pSEffector->y); @@ -349,7 +350,7 @@ static int32_t Proj_MaybeDoTransport(int32_t spriteNum, const uspritetype * cons // Check whether sprite is on/in a non-SE7 water sector. // : if not NULL, the sector on the other side. -int A_CheckNoSE7Water(uspritetype const * const pSprite, int sectNum, int sectLotag, int32_t *pOther) +int A_CheckNoSE7Water(uspriteptr_t const pSprite, int sectNum, int sectLotag, int32_t *pOther) { if (sectLotag == ST_1_ABOVE_WATER || sectLotag == ST_2_UNDERWATER) { @@ -383,8 +384,8 @@ static int32_t A_CheckNeedZUpdate(int32_t spriteNum, int32_t zChange, int32_t *p if (zChange == 0) return 0; - uspritetype const *const pSprite = (uspritetype *)&sprite[spriteNum]; - int const newZ = pSprite->z + (zChange >> 1); + auto const pSprite = (uspriteptr_t)&sprite[spriteNum]; + int const newZ = pSprite->z + (zChange >> 1); *pZcoord = newZ; @@ -598,11 +599,11 @@ int32_t A_MoveSpriteClipdist(int32_t spriteNum, vec3_t const * const change, uin int const sectLotag = sector[newSectnum].lotag; if (sectLotag == ST_1_ABOVE_WATER && newZ >= actor[spriteNum].floorz) - if (Proj_MaybeDoTransport(spriteNum, (uspritetype *)&sprite[otherSpriteNum], 0, newZ)) + if (Proj_MaybeDoTransport(spriteNum, (uspriteptr_t)&sprite[otherSpriteNum], 0, newZ)) return 0; if (sectLotag == ST_2_UNDERWATER && newZ <= actor[spriteNum].ceilingz) - if (Proj_MaybeDoTransport(spriteNum, (uspritetype *)&sprite[otherSpriteNum], 1, newZ)) + if (Proj_MaybeDoTransport(spriteNum, (uspriteptr_t)&sprite[otherSpriteNum], 1, newZ)) return 0; } } @@ -697,8 +698,8 @@ void A_SpawnMultiple(int spriteNum, int tileNum, int spawnCnt) #ifndef EDUKE32_STANDALONE void A_DoGuts(int spriteNum, int tileNum, int spawnCnt) { - uspritetype const *const pSprite = (uspritetype *)&sprite[spriteNum]; - vec2_t repeat = { 32, 32 }; + auto const pSprite = (uspriteptr_t)&sprite[spriteNum]; + vec2_t repeat = { 32, 32 }; if (A_CheckEnemySprite(pSprite) && pSprite->xrepeat < 16) repeat.x = repeat.y = 8; @@ -730,8 +731,8 @@ void A_DoGuts(int spriteNum, int tileNum, int spawnCnt) void A_DoGutsDir(int spriteNum, int tileNum, int spawnCnt) { - uspritetype const * const s = (uspritetype *)&sprite[spriteNum]; - vec2_t repeat = { 32, 32 }; + auto const s = (uspriteptr_t)&sprite[spriteNum]; + vec2_t repeat = { 32, 32 }; if (A_CheckEnemySprite(s) && s->xrepeat < 16) repeat.x = repeat.y = 8; @@ -917,7 +918,7 @@ ACTOR_STATIC void A_MaybeAwakenBadGuys(int const spriteNum) if (A_CheckSpriteFlags(spriteNum, SFLAG_WAKEUPBADGUYS)) { - uspritetype *const pSprite = (uspritetype *)&sprite[spriteNum]; + auto const pSprite = (uspriteptr_t)&sprite[spriteNum]; for (bssize_t nextSprite, SPRITES_OF_STAT_SAFE(STAT_ZOMBIEACTOR, spriteNum, nextSprite)) { @@ -1274,7 +1275,7 @@ ACTOR_STATIC void G_MovePlayers(void) int const sectorLotag = sector[playerSectnum].lotag; int32_t otherSector; - if (A_CheckNoSE7Water((uspritetype const *)pSprite, playerSectnum, sectorLotag, &otherSector)) + if (A_CheckNoSE7Water((uspriteptr_t)pSprite, playerSectnum, sectorLotag, &otherSector)) { // NOTE: Compare with G_MoveTransports(). pPlayer->on_warping_sector = 1; @@ -2775,7 +2776,7 @@ static void Proj_BounceOffWall(spritetype *s, int j) // NOTE: Compare with Proj_MaybeDamageCF2() in sector.c static int Proj_MaybeDamageCF(int spriteNum) { - uspritetype const * const s = (uspritetype const *)&sprite[spriteNum]; + auto const s = (uspriteptr_t)&sprite[spriteNum]; if (s->zvel < 0) { @@ -7886,7 +7887,7 @@ next_sprite: if (s->lotag == SE_29_WAVES) { - usectortype const *const sc = (usectortype *)§or[s->sectnum]; + auto const sc = (usectorptr_t)§or[s->sectnum]; if (sc->wallnum == 4) { diff --git a/source/duke3d/src/actors.h b/source/duke3d/src/actors.h index b6f2645cb..0f9c51334 100644 --- a/source/duke3d/src/actors.h +++ b/source/duke3d/src/actors.h @@ -436,7 +436,7 @@ extern int32_t ticrandomseed; extern projectile_t SpriteProjectile[MAXSPRITES]; -int A_CheckNoSE7Water(uspritetype const *pSprite, int sectNum, int sectLotag, int32_t *pOther); +int A_CheckNoSE7Water(uspriteptr_t pSprite, int sectNum, int sectLotag, int32_t *pOther); int A_CheckSwitchTile(int spriteNum); int A_IncurDamage(int spriteNum); void A_AddToDeleteQueue(int spriteNum); @@ -536,7 +536,7 @@ EXTERN_INLINE int G_CheckForSpaceFloor(int const sectnum) EXTERN_INLINE int A_CheckEnemySprite(void const * const pSprite) { - return A_CheckEnemyTile(((uspritetype const *) pSprite)->picnum); + return A_CheckEnemyTile(((uspriteptr_t) pSprite)->picnum); } #endif diff --git a/source/duke3d/src/game.cpp b/source/duke3d/src/game.cpp index d74379cd7..269cab196 100644 --- a/source/duke3d/src/game.cpp +++ b/source/duke3d/src/game.cpp @@ -3414,7 +3414,7 @@ SPAWN_END: return newSprite; } -static int G_MaybeTakeOnFloorPal(uspritetype *pSprite, int sectNum) +static int G_MaybeTakeOnFloorPal(tspriteptr_t pSprite, int sectNum) { int const floorPal = sector[sectNum].floorpal; @@ -3555,7 +3555,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo #endif for (j=spritesortcnt-1; j>=0; j--) { - uspritetype *const t = &tsprite[j]; + auto const t = &tsprite[j]; const int32_t i = t->owner; const spritetype *const s = &sprite[i]; @@ -3584,9 +3584,9 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo for (j=spritesortcnt-1; j>=0; j--) { - uspritetype *const t = &tsprite[j]; + auto const t = &tsprite[j]; const int32_t i = t->owner; - const spritetype *const s = &sprite[i]; + auto const s = (uspriteptr_t)&sprite[i]; if (t->picnum < GREENSLIME || t->picnum > GREENSLIME+7) switch (DYNAMICTILEMAP(t->picnum)) @@ -3675,11 +3675,11 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo int32_t startframe, viewtype; #endif //is the perfect time to animate sprites - uspritetype *const t = &tsprite[j]; + auto const t = &tsprite[j]; const int32_t i = t->owner; // XXX: what's up with the (i < 0) check? // NOTE: not const spritetype because set at SET_SPRITE_NOT_TSPRITE (see below). - uspritetype *const pSprite = (i < 0) ? &tsprite[j] : (uspritetype *)&sprite[i]; + auto const pSprite = (i < 0) ? (uspriteptr_t)&tsprite[j] : (uspriteptr_t)&sprite[i]; #ifndef EDUKE32_STANDALONE if (ud.lockout && G_CheckAdultTile(DYNAMICTILEMAP(pSprite->picnum))) @@ -3921,8 +3921,8 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo if (ud.showweapons && sprite[g_player[playerNum].ps->i].extra > 0 && g_player[playerNum].ps->curr_weapon > 0 && spritesortcnt < maxspritesonscreen) { - uspritetype *const newTspr = &tsprite[spritesortcnt]; - int const currentWeapon = g_player[playerNum].ps->curr_weapon; + auto const newTspr = &tsprite[spritesortcnt]; + int const currentWeapon = g_player[playerNum].ps->curr_weapon; *newTspr = *t; newTspr->statnum = TSPR_TEMP; @@ -3938,7 +3938,7 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo if (g_player[playerNum].inputBits->extbits & (1 << 7) && !ud.pause_on && spritesortcnt < maxspritesonscreen) { - uspritetype *const playerTyping = t; + auto const playerTyping = t; playerTyping->statnum = TSPR_TEMP; playerTyping->cstat = 0; @@ -3978,8 +3978,8 @@ void G_DoSpriteAnimations(int32_t ourx, int32_t oury, int32_t oura, int32_t smoo l = pSprite->z-actor[g_player[playerNum].ps->i].floorz+(3<<8); // SET_SPRITE_NOT_TSPRITE if (l > 1024 && pSprite->yrepeat > 32 && pSprite->extra > 0) - pSprite->yoffset = (int8_t)tabledivide32_noinline(l, pSprite->yrepeat<<2); - else pSprite->yoffset=0; + t->yoffset = (int8_t)tabledivide32_noinline(l, pSprite->yrepeat<<2); + else t->yoffset=0; } if (g_player[playerNum].ps->newowner > -1) @@ -4216,7 +4216,7 @@ skip: if ((pSprite->z-shadowZ) < ZOFFSET3 && g_player[screenpeek].ps->pos.z < shadowZ) { - uspritetype *const tsprShadow = &tsprite[spritesortcnt]; + tspriteptr_t tsprShadow = &tsprite[spritesortcnt]; *tsprShadow = *t; tsprShadow->statnum = TSPR_TEMP; diff --git a/source/duke3d/src/game.h b/source/duke3d/src/game.h index 475dd8cd7..da2444bc1 100644 --- a/source/duke3d/src/game.h +++ b/source/duke3d/src/game.h @@ -549,14 +549,14 @@ static inline int G_GetMusicIdx(const char *str) return (ep * MAXLEVELS) + lev; } -static inline int G_GetViewscreenSizeShift(const uspritetype *tspr) +static inline int G_GetViewscreenSizeShift(uspriteptr_t const spr) { #if VIEWSCREENFACTOR == 0 - UNREFERENCED_PARAMETER(tspr); + UNREFERENCED_PARAMETER(spr); return VIEWSCREENFACTOR; #else static const int mask = (1<xrepeat & mask) | (tspr->yrepeat & mask); + const int rem = (spr->xrepeat & mask) | (spr->yrepeat & mask); for (int i=0; i < VIEWSCREENFACTOR; i++) if (rem & (1<sectnum]; + auto const pSector = (usectorptr_t)§or[vm.pSprite->sectnum]; if (pSector->lotag == ST_23_SWINGING_DOOR || (vm.pSprite->picnum == APLAYER && ud.noclip) || (pSector->lotag == ST_1_ABOVE_WATER && !A_CheckNoSE7Water(vm.pUSprite, vm.pSprite->sectnum, pSector->lotag, NULL))) @@ -316,7 +316,7 @@ bool A_Dodge(spritetype * const pSprite) int A_GetFurthestAngle(int spriteNum, int angDiv) { - auto const pSprite = (uspritetype *)&sprite[spriteNum]; + auto const pSprite = (uspriteptr_t)&sprite[spriteNum]; if (pSprite->picnum != APLAYER && (AC_COUNT(actor[spriteNum].t_data)&63) > 2) return pSprite->ang + 1024; @@ -328,9 +328,9 @@ int A_GetFurthestAngle(int spriteNum, int angDiv) for (native_t j = pSprite->ang; j < (2048 + pSprite->ang); j += angIncs) { - pSprite->z -= ZOFFSET3; - hitscan((const vec3_t *)pSprite, pSprite->sectnum, sintable[(j + 512) & 2047], sintable[j & 2047], 0, &hit, CLIPMASK1); - pSprite->z += ZOFFSET3; + vec3_t origin = *(const vec3_t *)pSprite; + origin.z -= ZOFFSET3; + hitscan(&origin, pSprite->sectnum, sintable[(j + 512) & 2047], sintable[j & 2047], 0, &hit, CLIPMASK1); int const hitDist = klabs(hit.pos.x-pSprite->x) + klabs(hit.pos.y-pSprite->y); @@ -344,12 +344,12 @@ int A_GetFurthestAngle(int spriteNum, int angDiv) return furthestAngle & 2047; } -int A_FurthestVisiblePoint(int const spriteNum, uspritetype * const ts, vec2_t * const vect) +int A_FurthestVisiblePoint(int const spriteNum, uspriteptr_t const ts, vec2_t * const vect) { if (AC_COUNT(actor[spriteNum].t_data)&63) return -1; - const uspritetype *const pnSprite = (uspritetype *)&sprite[spriteNum]; + auto const pnSprite = (uspriteptr_t)&sprite[spriteNum]; hitdata_t hit; int const angincs = 128; @@ -357,9 +357,9 @@ int A_FurthestVisiblePoint(int const spriteNum, uspritetype * const ts, vec2_t * for (native_t j = ts->ang; j < (2048 + ts->ang); j += (angincs /*-(krand()&511)*/)) { - ts->z -= ZOFFSET2; - hitscan((const vec3_t *)ts, ts->sectnum, sintable[(j + 512) & 2047], sintable[j & 2047], 16384 - (krand() & 32767), &hit, CLIPMASK1); - ts->z += ZOFFSET2; + vec3_t origin = *(const vec3_t *)ts; + origin.z -= ZOFFSET2; + hitscan(&origin, ts->sectnum, sintable[(j + 512) & 2047], sintable[j & 2047], 16384 - (krand() & 32767), &hit, CLIPMASK1); if (hit.sect < 0) continue; @@ -383,7 +383,7 @@ int A_FurthestVisiblePoint(int const spriteNum, uspritetype * const ts, vec2_t * static void VM_GetZRange(int const spriteNum, int32_t * const ceilhit, int32_t * const florhit, int const wallDist) { - uspritetype *const pSprite = (uspritetype *)&sprite[spriteNum]; + auto const pSprite = &sprite[spriteNum]; int const ocstat = pSprite->cstat; pSprite->cstat = 0; @@ -406,7 +406,7 @@ void A_GetZLimits(int const spriteNum) if ((florhit&49152) == 49152 && (sprite[florhit&(MAXSPRITES-1)].cstat&48) == 0) { - auto const hitspr = (uspritetype *)&sprite[florhit&(MAXSPRITES-1)]; + auto const hitspr = (uspriteptr_t)&sprite[florhit&(MAXSPRITES-1)]; florhit &= (MAXSPRITES-1); @@ -968,7 +968,7 @@ static int A_GetVerticalVel(actor_t const * const pActor) static int32_t A_GetWaterZOffset(int const spriteNum) { - auto const pSprite = (uspritetype *)&sprite[spriteNum]; + auto const pSprite = (uspriteptr_t)&sprite[spriteNum]; auto const pActor = &actor[spriteNum]; if (sector[pSprite->sectnum].lotag == ST_1_ABOVE_WATER) @@ -3063,7 +3063,7 @@ badindex: vInstruction(CON_IFCANSEE): { - auto pSprite = (uspritetype *)&sprite[vm.pPlayer->i]; + auto pSprite = (uspriteptr_t)&sprite[vm.pPlayer->i]; // select sprite for monster to target // if holoduke is on, let them target holoduke first. @@ -3071,7 +3071,7 @@ badindex: #ifndef EDUKE32_STANDALONE if (vm.pPlayer->holoduke_on >= 0) { - pSprite = (uspritetype *)&sprite[vm.pPlayer->holoduke_on]; + pSprite = (uspriteptr_t)&sprite[vm.pPlayer->holoduke_on]; tw = cansee(vm.pSprite->x, vm.pSprite->y, vm.pSprite->z - (krand() & (ZOFFSET5 - 1)), vm.pSprite->sectnum, pSprite->x, pSprite->y, pSprite->z, pSprite->sectnum); @@ -3079,7 +3079,7 @@ badindex: { // they can't see player's holoduke // check for player... - pSprite = (uspritetype *)&sprite[vm.pPlayer->i]; + pSprite = (uspriteptr_t)&sprite[vm.pPlayer->i]; } } #endif diff --git a/source/duke3d/src/gamestructures.cpp b/source/duke3d/src/gamestructures.cpp index 9754e1e9c..94a7eb383 100644 --- a/source/duke3d/src/gamestructures.cpp +++ b/source/duke3d/src/gamestructures.cpp @@ -104,7 +104,7 @@ int32_t __fastcall VM_GetSector(int const sectNum, int32_t labelNum) return -1; } - auto const &s = *(usectortype *)§or[sectNum]; + auto const &s = *(usectorptr_t)§or[sectNum]; switch (labelNum) { diff --git a/source/duke3d/src/m32def.h b/source/duke3d/src/m32def.h index 86a4259b8..eb5d1716e 100644 --- a/source/duke3d/src/m32def.h +++ b/source/duke3d/src/m32def.h @@ -113,7 +113,7 @@ typedef struct { int32_t g_st; union { spritetype * pSprite; - uspritetype *pUSprite; + uspritetype const * pUSprite; }; uint32_t flags; // g_errorFlag, g_returnFlag; diff --git a/source/duke3d/src/m32exec.cpp b/source/duke3d/src/m32exec.cpp index 8c1691227..fc2797cc0 100644 --- a/source/duke3d/src/m32exec.cpp +++ b/source/duke3d/src/m32exec.cpp @@ -1327,7 +1327,7 @@ skip_check: const int32_t parm2 = how<=ITER_DRAWNSPRITES ? 0 : Gv_GetVarX(*insptr++); instype *const end = insptr + *insptr, *const beg = ++insptr; const int32_t vm_i_bak = vm.spriteNum; - uspritetype *const vm_sp_bak = vm.pUSprite; + auto const vm_sp_bak = vm.pUSprite; if (vm.flags&VMFLAG_ERROR) continue; @@ -1416,7 +1416,7 @@ skip_check: case ITER_DRAWNSPRITES: { uspritetype lastSpriteBackup; - uspritetype *const lastSpritePtr = (uspritetype *)&sprite[MAXSPRITES-1]; + auto const lastSpritePtr = (uspritetype *)&sprite[MAXSPRITES-1]; // Back up sprite MAXSPRITES-1. Bmemcpy(&lastSpriteBackup, lastSpritePtr, sizeof(uspritetype)); diff --git a/source/duke3d/src/player.cpp b/source/duke3d/src/player.cpp index d9f7eb968..9e22d23bf 100644 --- a/source/duke3d/src/player.cpp +++ b/source/duke3d/src/player.cpp @@ -373,8 +373,8 @@ static int GetAutoAimAng(int spriteNum, int playerNum, int projecTile, int zAdju if (returnSprite >= 0) { - const uspritetype *const pSprite = (uspritetype *)&sprite[returnSprite]; - int zCenter = 2 * (pSprite->yrepeat * tilesiz[pSprite->picnum].y) + zAdjust; + auto const pSprite = (uspriteptr_t)&sprite[returnSprite]; + int zCenter = 2 * (pSprite->yrepeat * tilesiz[pSprite->picnum].y) + zAdjust; #ifndef EDUKE32_STANDALONE if (!IONMAIDEN && aimFlags && @@ -590,7 +590,7 @@ static int SectorContainsSE13(int const sectNum) // (in that case walltype *hitwal may be stale) static inline void HandleHitWall(hitdata_t *hitData) { - uwalltype const * const hitWall = (uwalltype *)&wall[hitData->wall]; + auto const hitWall = (uwallptr_t)&wall[hitData->wall]; if ((hitWall->cstat & 2) && redwallp(hitWall) && (hitData->pos.z >= sector[hitWall->nextsector].floorz)) hitData->wall = hitWall->nextwall; @@ -684,7 +684,7 @@ static int P_PostFireHitscan(int playerNum, int const spriteNum, hitdata_t *cons } else if (hitData->wall >= 0) { - uwalltype const * const hitWall = (uwalltype *)&wall[hitData->wall]; + auto const hitWall = (uwallptr_t)&wall[hitData->wall]; Proj_MaybeSpawn(spriteNum, spawnTile, hitData); @@ -790,7 +790,7 @@ static int Proj_CheckBlood(vec3_t const *const srcVect, hitdata_t const *const h if (hitData->wall < 0 || hitData->sect < 0) return 0; - uwalltype const *const hitWall = (uwalltype *)&wall[hitData->wall]; + auto const hitWall = (uwallptr_t)&wall[hitData->wall]; if ((FindDistance2D(srcVect->x - hitData->pos.x, srcVect->y - hitData->pos.y) < bloodRange) && (hitWall->overpicnum != BIGFORCE && (hitWall->cstat & 16) == 0) @@ -1042,7 +1042,7 @@ static int A_ShootCustom(int const spriteNum, int const projecTile, int shootAng if (Proj_CheckBlood(startPos, &hitData, pProj->range, mulscale3(pProj->yrepeat, tilesiz[pProj->decal].y) << 8)) { - const uwalltype *const hitWall = (uwalltype *)&wall[hitData.wall]; + uwallptr_t const hitWall = (uwallptr_t)&wall[hitData.wall]; if (FindDistance2D(hitWall->x - wall[hitWall->point2].x, hitWall->y - wall[hitWall->point2].y) > (mulscale3(pProj->xrepeat + 8, tilesiz[pProj->decal].x))) @@ -1139,7 +1139,7 @@ static int32_t A_ShootHardcoded(int spriteNum, int projecTile, int shootAng, vec { if (Proj_CheckBlood(&startPos, &hitData, 1024, 16 << 8)) { - const uwalltype *const hitwal = (uwalltype *)&wall[hitData.wall]; + uwallptr_t const hitwal = (uwallptr_t)&wall[hitData.wall]; if (SectorContainsSE13(hitwal->nextsector)) return -1; @@ -4771,7 +4771,7 @@ void P_ProcessInput(int playerNum) int spriteNum = lowZhit&(MAXSPRITES-1); if ((sprite[spriteNum].cstat&33) == 33 || (sprite[spriteNum].cstat&17) == 17 || - clipshape_idx_for_sprite((uspritetype *)&sprite[spriteNum], -1) >= 0) + clipshape_idx_for_sprite((uspriteptr_t)&sprite[spriteNum], -1) >= 0) { // EDuke32 extension: xvel of 1 makes a sprite be never regarded as a bridge. @@ -5416,7 +5416,7 @@ HORIZONLY:; // ST_2_UNDERWATER if (pPlayer->cursectnum >= 0 && sectorLotag < 3) { - usectortype const *pSector = (usectortype *)§or[pPlayer->cursectnum]; + auto const pSector = (usectorptr_t)§or[pPlayer->cursectnum]; // TRAIN_SECTOR_TO_SE_INDEX if ((!ud.noclip && pSector->lotag == ST_31_TWO_WAY_TRAIN) && diff --git a/source/duke3d/src/player.h b/source/duke3d/src/player.h index 97d230f65..aa7b64347 100644 --- a/source/duke3d/src/player.h +++ b/source/duke3d/src/player.h @@ -397,10 +397,10 @@ static inline int P_GetP(const void *pSprite) // NOTE: In the no-netcode build, there's no point to pass player indices // at all since there is ever only one player. However, merely returning 0 // would mean making this build less strict than the normal one. - Bassert(((const uspritetype *)pSprite)->yvel == 0); + Bassert(((uspriteptr_t)pSprite)->yvel == 0); return 0; #else - int playerNum = ((const uspritetype *)pSprite)->yvel; + int playerNum = ((uspriteptr_t)pSprite)->yvel; // [JM] Check against MAXPLAYERS as opposed to g_mostConcurrentPlayers // to prevent CON for disconnected/fake players from executing as playernum 0. if ((unsigned)playerNum >= MAXPLAYERS) @@ -410,7 +410,7 @@ static inline int P_GetP(const void *pSprite) } // Get the player index given an APLAYER sprite index. -static inline int P_Get(int32_t spriteNum) { return P_GetP((const uspritetype *)&sprite[spriteNum]); } +static inline int P_Get(int32_t spriteNum) { return P_GetP((uspriteptr_t)&sprite[spriteNum]); } #ifdef __cplusplus } diff --git a/source/duke3d/src/screens.cpp b/source/duke3d/src/screens.cpp index 0cdb6174e..f4b7e1472 100644 --- a/source/duke3d/src/screens.cpp +++ b/source/duke3d/src/screens.cpp @@ -322,7 +322,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 int32_t xvect, yvect, xvect2, yvect2; int16_t p; char col; - uwalltype *wal, *wal2; + uwallptr_t wal, wal2; spritetype *spr; int32_t tmpydim = (xdim*5)/8; @@ -347,7 +347,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 z1 = sector[i].ceilingz; z2 = sector[i].floorz; - for (j=startwall, wal=(uwalltype *)&wall[startwall]; jnextwall; if (k < 0) continue; @@ -364,7 +364,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 x1 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11); y1 = dmulscale16(oy, xvect2, ox, yvect2)+(ydim<<11); - wal2 = (uwalltype *)&wall[wal->point2]; + wal2 = (uwallptr_t)&wall[wal->point2]; ox = wal2->x-cposx; oy = wal2->y-cposy; x2 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11); @@ -532,7 +532,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 endwall = sector[i].wallptr + sector[i].wallnum; k = -1; - for (j=startwall, wal=(uwalltype *)&wall[startwall]; jnextwall >= 0) continue; @@ -553,7 +553,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 } k = wal->point2; - wal2 = (uwalltype *)&wall[k]; + wal2 = (uwallptr_t)&wall[k]; ox = wal2->x-cposx; oy = wal2->y-cposy; x2 = dmulscale16(ox, xvect, -oy, yvect)+(xdim<<11); @@ -572,7 +572,7 @@ static void G_DrawOverheadMap(int32_t cposx, int32_t cposy, int32_t czoom, int16 if (ud.scrollmode && p == screenpeek) continue; DukePlayer_t const * const pPlayer = g_player[p].ps; - uspritetype const * const pSprite = (uspritetype const *)&sprite[pPlayer->i]; + auto const pSprite = (uspriteptr_t)&sprite[pPlayer->i]; ox = pSprite->x - cposx; oy = pSprite->y - cposy; diff --git a/source/duke3d/src/sector.cpp b/source/duke3d/src/sector.cpp index ab2e44a7a..581781fa0 100644 --- a/source/duke3d/src/sector.cpp +++ b/source/duke3d/src/sector.cpp @@ -427,7 +427,7 @@ void G_AnimateCamSprite(int smoothRatio) if (OW(spriteNum) >= 0 && dist(&sprite[pPlayer->i], &sprite[spriteNum]) < VIEWSCREEN_ACTIVE_DISTANCE) { - int const viewscrShift = G_GetViewscreenSizeShift((const uspritetype *)&sprite[spriteNum]); + int const viewscrShift = G_GetViewscreenSizeShift((uspriteptr_t)&sprite[spriteNum]); int const viewscrTile = TILE_VIEWSCR - viewscrShift; if (waloff[viewscrTile] == 0)