- SW: removed some very dangerous type casting.

This commit is contained in:
Christoph Oelckers 2020-12-01 18:24:24 +01:00
parent b52668ecdf
commit 39b67b4086
9 changed files with 35 additions and 33 deletions

View file

@ -813,7 +813,12 @@ typedef struct
struct PLAYERstruct struct PLAYERstruct
{ {
// variable that fit in the sprite or user structure // variable that fit in the sprite or user structure
int32_t posx, posy, posz; union
{
struct { int32_t posx, posy, posz; };
vec3_t pos;
};
// interpolation // interpolation
int oposx, oposy, oposz; int oposx, oposy, oposz;

View file

@ -287,7 +287,7 @@ short RectClipTurn(PLAYERp pp, short new_ang, int *qx, int *qy, int *ox, int *oy
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
vec2_t const p = { ox[i], oy[i] }; vec2_t const p = { ox[i], oy[i] };
rotatepoint(*(vec2_t *)&pp->posx, p, rot_ang, &xy[i]); rotatepoint(pp->pos.vec2, p, rot_ang, &xy[i]);
// cannot use sop->xmid and ymid because the SO is off the map at this point // cannot use sop->xmid and ymid because the SO is off the map at this point
//rotatepoint(*(vec2_t *)&sop->xmid, p, rot_ang, &xy[i]); //rotatepoint(*(vec2_t *)&sop->xmid, p, rot_ang, &xy[i]);
} }

View file

@ -2049,7 +2049,7 @@ DoPlayerSlide(PLAYERp pp)
if (labs(pp->slide_xvect) < 12800 && labs(pp->slide_yvect) < 12800) if (labs(pp->slide_xvect) < 12800 && labs(pp->slide_yvect) < 12800)
pp->slide_xvect = pp->slide_yvect = 0; pp->slide_xvect = pp->slide_yvect = 0;
push_ret = pushmove((vec3_t *)pp, &pp->cursectnum, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER); push_ret = pushmove(&pp->pos, &pp->cursectnum, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER);
if (push_ret < 0) if (push_ret < 0)
{ {
if (!TEST(pp->Flags, PF_DEAD)) if (!TEST(pp->Flags, PF_DEAD))
@ -2062,9 +2062,9 @@ DoPlayerSlide(PLAYERp pp)
} }
return; return;
} }
clipmove((vec3_t *)pp, &pp->cursectnum, pp->slide_xvect, pp->slide_yvect, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER); clipmove(&pp->pos, &pp->cursectnum, pp->slide_xvect, pp->slide_yvect, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER);
PlayerCheckValidMove(pp); PlayerCheckValidMove(pp);
push_ret = pushmove((vec3_t *)pp, &pp->cursectnum, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER); push_ret = pushmove(&pp->pos, &pp->cursectnum, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER);
if (push_ret < 0) if (push_ret < 0)
{ {
if (!TEST(pp->Flags, PF_DEAD)) if (!TEST(pp->Flags, PF_DEAD))
@ -2212,7 +2212,7 @@ DoPlayerMove(PLAYERp pp)
} }
else else
{ {
push_ret = pushmove((vec3_t *)pp, &pp->cursectnum, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist - Z(16), CLIPMASK_PLAYER); push_ret = pushmove(&pp->pos, &pp->cursectnum, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist - Z(16), CLIPMASK_PLAYER);
if (push_ret < 0) if (push_ret < 0)
{ {
@ -2235,11 +2235,11 @@ DoPlayerMove(PLAYERp pp)
save_cstat = pp->SpriteP->cstat; save_cstat = pp->SpriteP->cstat;
RESET(pp->SpriteP->cstat, CSTAT_SPRITE_BLOCK); RESET(pp->SpriteP->cstat, CSTAT_SPRITE_BLOCK);
COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum); COVERupdatesector(pp->posx, pp->posy, &pp->cursectnum);
clipmove((vec3_t *)pp, &pp->cursectnum, pp->xvect, pp->yvect, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER); clipmove(&pp->pos, &pp->cursectnum, pp->xvect, pp->yvect, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER);
pp->SpriteP->cstat = save_cstat; pp->SpriteP->cstat = save_cstat;
PlayerCheckValidMove(pp); PlayerCheckValidMove(pp);
push_ret = pushmove((vec3_t *)pp, &pp->cursectnum, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist - Z(16), CLIPMASK_PLAYER); push_ret = pushmove(&pp->pos, &pp->cursectnum, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist - Z(16), CLIPMASK_PLAYER);
if (push_ret < 0) if (push_ret < 0)
{ {
@ -4913,7 +4913,7 @@ DoPlayerCurrent(PLAYERp pp)
xvect = sectu->speed * synctics * bcos(sectu->ang) >> 4; xvect = sectu->speed * synctics * bcos(sectu->ang) >> 4;
yvect = sectu->speed * synctics * bsin(sectu->ang) >> 4; yvect = sectu->speed * synctics * bsin(sectu->ang) >> 4;
push_ret = pushmove((vec3_t *)pp, &pp->cursectnum, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER); push_ret = pushmove(&pp->pos, &pp->cursectnum, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER);
if (push_ret < 0) if (push_ret < 0)
{ {
if (!TEST(pp->Flags, PF_DEAD)) if (!TEST(pp->Flags, PF_DEAD))
@ -4928,9 +4928,9 @@ DoPlayerCurrent(PLAYERp pp)
} }
return; return;
} }
clipmove((vec3_t *)pp, &pp->cursectnum, xvect, yvect, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER); clipmove(&pp->pos, &pp->cursectnum, xvect, yvect, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER);
PlayerCheckValidMove(pp); PlayerCheckValidMove(pp);
pushmove((vec3_t *)pp, &pp->cursectnum, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER); pushmove(&pp->pos, &pp->cursectnum, ((int)pp->SpriteP->clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER);
if (push_ret < 0) if (push_ret < 0)
{ {
if (!TEST(pp->Flags, PF_DEAD)) if (!TEST(pp->Flags, PF_DEAD))

View file

@ -1046,7 +1046,7 @@ SectorExp(short SpriteNum, short sectnum, short orig_ang, int zh)
// setup vars needed by SectorExp // setup vars needed by SectorExp
changespritesect(SpriteNum, sectnum); changespritesect(SpriteNum, sectnum);
//setspritez(SpriteNum, (vec3_t *)sp); //setspritez(SpriteNum, &sp->pos);
getzsofslope(sp->sectnum, sp->x, sp->y, &u->hiz, &u->loz); getzsofslope(sp->sectnum, sp->x, sp->y, &u->hiz, &u->loz);
// spawn explosion // spawn explosion
@ -1154,7 +1154,7 @@ DoSpawnSpotsForKill(short match)
change_sprite_stat(sn, STAT_NO_STATE); change_sprite_stat(sn, STAT_NO_STATE);
u->ActorActionFunc = DoSpawnSpot; u->ActorActionFunc = DoSpawnSpot;
u->WaitTics = SP_TAG5(sp) * 15; u->WaitTics = SP_TAG5(sp) * 15;
setspritez(sn, (vec3_t *)sp); setspritez(sn, &sp->pos);
// setting for Killed // setting for Killed
u->LastDamage = 1; u->LastDamage = 1;
} }

View file

@ -567,7 +567,7 @@ int DoSkelTeleport(short SpriteNum)
else else
sp->y -= 512 + RANDOM_P2(1024); sp->y -= 512 + RANDOM_P2(1024);
setspritez(SpriteNum, (vec3_t *)sp); setspritez(SpriteNum, &sp->pos);
//COVERupdatesector(sp->x, sp->y, &sp->sectnum); //COVERupdatesector(sp->x, sp->y, &sp->sectnum);
if (sp->sectnum != -1) if (sp->sectnum != -1)

View file

@ -599,7 +599,7 @@ void GameInterface::UpdateSounds(void)
listener.angle = -pp->angle.ang.asbuild() * BAngRadian; // Build uses a period of 2048. listener.angle = -pp->angle.ang.asbuild() * BAngRadian; // Build uses a period of 2048.
listener.velocity.Zero(); listener.velocity.Zero();
listener.position = GetSoundPos((vec3_t*)&pp->posx); listener.position = GetSoundPos(&pp->pos);
listener.underwater = false; listener.underwater = false;
// This should probably use a real environment instead of the pitch hacking in S_PlaySound3D. // This should probably use a real environment instead of the pitch hacking in S_PlaySound3D.
// listenactor->waterlevel == 3; // listenactor->waterlevel == 3;
@ -649,7 +649,7 @@ int _PlaySound(int num, SPRITEp sp, PLAYERp pp, vec3_t* pos, Voc3D_Flags flags,
} }
else if (pp && !pos) else if (pp && !pos)
{ {
pos = (vec3_t*)&pp->posx; pos = &pp->pos;
pp = nullptr; pp = nullptr;
} }
} }

View file

@ -5178,7 +5178,7 @@ DoGrating(short SpriteNum)
} }
} }
setspritez(SpriteNum, (vec3_t *)sp); setspritez(SpriteNum, &sp->pos);
return 0; return 0;
} }
@ -7308,7 +7308,7 @@ move_missile(short spritenum, int xchange, int ychange, int zchange, int ceildis
} }
if (FAF_ConnectArea(sp->sectnum)) if (FAF_ConnectArea(sp->sectnum))
setspritez(spritenum, (vec3_t *)sp); setspritez(spritenum, &sp->pos);
if (TEST(sector[sp->sectnum].extra, SECTFX_WARP_SECTOR)) if (TEST(sector[sp->sectnum].extra, SECTFX_WARP_SECTOR))
{ {
@ -7508,7 +7508,7 @@ move_ground_missile(short spritenum, int xchange, int ychange, int ceildist, int
//MissileWaterAdjust(spritenum); //MissileWaterAdjust(spritenum);
//if (FAF_ConnectArea(sp->sectnum)) //if (FAF_ConnectArea(sp->sectnum))
// setspritez(spritenum, (vec3_t *)sp); // setspritez(spritenum, &sp->pos);
if (TEST(sector[sp->sectnum].extra, SECTFX_WARP_SECTOR)) if (TEST(sector[sp->sectnum].extra, SECTFX_WARP_SECTOR))
{ {

View file

@ -1881,7 +1881,7 @@ PlayerPart:
// Does not necessarily move with the sector so must accout for // Does not necessarily move with the sector so must accout for
// moving across sectors // moving across sectors
if (sop->xmid < MAXSO) // special case for operating SO's if (sop->xmid < MAXSO) // special case for operating SO's
setspritez(sop->sp_num[i], (vec3_t *)sp); setspritez(sop->sp_num[i], &sp->pos);
} }
u->oangdiff += getincangle(oldang, sp->ang); u->oangdiff += getincangle(oldang, sp->ang);
@ -2058,7 +2058,7 @@ void UpdateSectorObjectSprites(SECTOR_OBJECTp sop)
{ {
sp = &sprite[sop->sp_num[i]]; sp = &sprite[sop->sp_num[i]];
setspritez(sop->sp_num[i], (vec3_t *)sp); setspritez(sop->sp_num[i], &sp->pos);
} }
} }

View file

@ -4681,7 +4681,7 @@ WeaponMoveHit(short SpriteNum)
// clipmove does not correctly return the sprite for WALL sprites // clipmove does not correctly return the sprite for WALL sprites
// on walls, so look with hitscan // on walls, so look with hitscan
hitscan((vec3_t *)sp, sp->sectnum, // Start position hitscan(&sp->pos, sp->sectnum, // Start position
bcos(sp->ang), // X vector of 3D ang bcos(sp->ang), // X vector of 3D ang
bsin(sp->ang), // Y vector of 3D ang bsin(sp->ang), // Y vector of 3D ang
sp->zvel, // Z vector of 3D ang sp->zvel, // Z vector of 3D ang
@ -12831,7 +12831,7 @@ DoRing(int16_t Weapon)
//sp->ang = NORM_ANGLE(sp->ang + 512); //sp->ang = NORM_ANGLE(sp->ang + 512);
//updatesector(sp->x, sp->y); //updatesector(sp->x, sp->y);
setsprite(Weapon, (vec3_t *)sp); setsprite(Weapon, &sp->pos);
ASSERT(sp->sectnum >= 0); ASSERT(sp->sectnum >= 0);
@ -12976,7 +12976,7 @@ DoSerpRing(int16_t Weapon)
sp->x += mulscale14(u->Dist, bcos(u->slide_ang)); sp->x += mulscale14(u->Dist, bcos(u->slide_ang));
sp->y += mulscale14(u->Dist, bsin(u->slide_ang)); sp->y += mulscale14(u->Dist, bsin(u->slide_ang));
setsprite(Weapon, (vec3_t *)sp); setsprite(Weapon, &sp->pos);
ASSERT(sp->sectnum >= 0); ASSERT(sp->sectnum >= 0);
@ -17773,8 +17773,7 @@ HitscanSpriteAdjust(short SpriteNum, short hit_wall)
// must have this // must have this
sectnum = sp->sectnum; sectnum = sp->sectnum;
clipmove((vec3_t *)sp, &sectnum, xvect, yvect, clipmove(&sp->pos, &sectnum, xvect, yvect, 4L, 4L<<8, 4L<<8, CLIPMASK_MISSILE);
4L, 4L<<8, 4L<<8, CLIPMASK_MISSILE);
clipmoveboxtracenum = 3; clipmoveboxtracenum = 3;
if (sp->sectnum != sectnum) if (sp->sectnum != sectnum)
@ -19109,7 +19108,7 @@ InitEnemyUzi(short SpriteNum)
// Make sprite shade brighter // Make sprite shade brighter
u->Vis = 128; u->Vis = 128;
setspritez(SpriteNum, (vec3_t *)sp); setspritez(SpriteNum, &sp->pos);
if (u->ID == ZILLA_RUN_R0) if (u->ID == ZILLA_RUN_R0)
{ {
@ -20635,8 +20634,7 @@ int QueueHole(short hit_sect, short hit_wall, int hit_x, int hit_y, int hit_z)
sectnum = sp->sectnum; sectnum = sp->sectnum;
clipmoveboxtracenum = 1; clipmoveboxtracenum = 1;
clipmove((vec3_t *)sp, &sectnum, nx, ny, clipmove(&sp->pos, &sectnum, nx, ny, 0L, 0L, 0L, CLIPMASK_MISSILE);
0L, 0L, 0L, CLIPMASK_MISSILE);
clipmoveboxtracenum = 3; clipmoveboxtracenum = 3;
if (sp->sectnum != sectnum) if (sp->sectnum != sectnum)
@ -20954,8 +20952,7 @@ int QueueWallBlood(short hit_sprite, short ang)
sectnum = sp->sectnum; sectnum = sp->sectnum;
clipmoveboxtracenum = 1; clipmoveboxtracenum = 1;
clipmove((vec3_t *)sp, &sectnum, nx, ny, clipmove(&sp->pos, &sectnum, nx, ny, 0L, 0L, 0L, CLIPMASK_MISSILE);
0L, 0L, 0L, CLIPMASK_MISSILE);
clipmoveboxtracenum = 3; clipmoveboxtracenum = 3;
if (sp->sectnum != sectnum) if (sp->sectnum != sectnum)
@ -21092,7 +21089,7 @@ int QueueGeneric(short SpriteNum, short pic)
{ {
// move old sprite to new sprite's place // move old sprite to new sprite's place
osp = &sprite[GenericQueue[GenericQueueHead]]; osp = &sprite[GenericQueue[GenericQueueHead]];
//setspritez(GenericQueue[GenericQueueHead], (vec3_t *)sp); //setspritez(GenericQueue[GenericQueueHead], &sp->pos);
osp->x = sp->x; osp->x = sp->x;
osp->y = sp->y; osp->y = sp->y;
osp->z = sp->z; osp->z = sp->z;
@ -21645,7 +21642,7 @@ int QueueLoWangs(short SpriteNum)
else else
{ {
// move old sprite to new sprite's place // move old sprite to new sprite's place
setspritez(LoWangsQueue[LoWangsQueueHead], (vec3_t *)sp); setspritez(LoWangsQueue[LoWangsQueueHead], &sp->pos);
NewSprite = LoWangsQueue[LoWangsQueueHead]; NewSprite = LoWangsQueue[LoWangsQueueHead];
ASSERT(sprite[NewSprite].statnum != MAXSTATUS); ASSERT(sprite[NewSprite].statnum != MAXSTATUS);
} }