- 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
{
// 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
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++)
{
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
//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)
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 (!TEST(pp->Flags, PF_DEAD))
@ -2062,9 +2062,9 @@ DoPlayerSlide(PLAYERp pp)
}
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);
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 (!TEST(pp->Flags, PF_DEAD))
@ -2212,7 +2212,7 @@ DoPlayerMove(PLAYERp pp)
}
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)
{
@ -2235,11 +2235,11 @@ DoPlayerMove(PLAYERp pp)
save_cstat = pp->SpriteP->cstat;
RESET(pp->SpriteP->cstat, CSTAT_SPRITE_BLOCK);
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;
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)
{
@ -4913,7 +4913,7 @@ DoPlayerCurrent(PLAYERp pp)
xvect = sectu->speed * synctics * bcos(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 (!TEST(pp->Flags, PF_DEAD))
@ -4928,9 +4928,9 @@ DoPlayerCurrent(PLAYERp pp)
}
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);
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 (!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
changespritesect(SpriteNum, sectnum);
//setspritez(SpriteNum, (vec3_t *)sp);
//setspritez(SpriteNum, &sp->pos);
getzsofslope(sp->sectnum, sp->x, sp->y, &u->hiz, &u->loz);
// spawn explosion
@ -1154,7 +1154,7 @@ DoSpawnSpotsForKill(short match)
change_sprite_stat(sn, STAT_NO_STATE);
u->ActorActionFunc = DoSpawnSpot;
u->WaitTics = SP_TAG5(sp) * 15;
setspritez(sn, (vec3_t *)sp);
setspritez(sn, &sp->pos);
// setting for Killed
u->LastDamage = 1;
}

View file

@ -567,7 +567,7 @@ int DoSkelTeleport(short SpriteNum)
else
sp->y -= 512 + RANDOM_P2(1024);
setspritez(SpriteNum, (vec3_t *)sp);
setspritez(SpriteNum, &sp->pos);
//COVERupdatesector(sp->x, sp->y, &sp->sectnum);
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.velocity.Zero();
listener.position = GetSoundPos((vec3_t*)&pp->posx);
listener.position = GetSoundPos(&pp->pos);
listener.underwater = false;
// This should probably use a real environment instead of the pitch hacking in S_PlaySound3D.
// 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)
{
pos = (vec3_t*)&pp->posx;
pos = &pp->pos;
pp = nullptr;
}
}

View file

@ -5178,7 +5178,7 @@ DoGrating(short SpriteNum)
}
}
setspritez(SpriteNum, (vec3_t *)sp);
setspritez(SpriteNum, &sp->pos);
return 0;
}
@ -7308,7 +7308,7 @@ move_missile(short spritenum, int xchange, int ychange, int zchange, int ceildis
}
if (FAF_ConnectArea(sp->sectnum))
setspritez(spritenum, (vec3_t *)sp);
setspritez(spritenum, &sp->pos);
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);
//if (FAF_ConnectArea(sp->sectnum))
// setspritez(spritenum, (vec3_t *)sp);
// setspritez(spritenum, &sp->pos);
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
// moving across sectors
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);
@ -2058,7 +2058,7 @@ void UpdateSectorObjectSprites(SECTOR_OBJECTp sop)
{
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
// 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
bsin(sp->ang), // Y 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);
//updatesector(sp->x, sp->y);
setsprite(Weapon, (vec3_t *)sp);
setsprite(Weapon, &sp->pos);
ASSERT(sp->sectnum >= 0);
@ -12976,7 +12976,7 @@ DoSerpRing(int16_t Weapon)
sp->x += mulscale14(u->Dist, bcos(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);
@ -17773,8 +17773,7 @@ HitscanSpriteAdjust(short SpriteNum, short hit_wall)
// must have this
sectnum = sp->sectnum;
clipmove((vec3_t *)sp, &sectnum, xvect, yvect,
4L, 4L<<8, 4L<<8, CLIPMASK_MISSILE);
clipmove(&sp->pos, &sectnum, xvect, yvect, 4L, 4L<<8, 4L<<8, CLIPMASK_MISSILE);
clipmoveboxtracenum = 3;
if (sp->sectnum != sectnum)
@ -19109,7 +19108,7 @@ InitEnemyUzi(short SpriteNum)
// Make sprite shade brighter
u->Vis = 128;
setspritez(SpriteNum, (vec3_t *)sp);
setspritez(SpriteNum, &sp->pos);
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;
clipmoveboxtracenum = 1;
clipmove((vec3_t *)sp, &sectnum, nx, ny,
0L, 0L, 0L, CLIPMASK_MISSILE);
clipmove(&sp->pos, &sectnum, nx, ny, 0L, 0L, 0L, CLIPMASK_MISSILE);
clipmoveboxtracenum = 3;
if (sp->sectnum != sectnum)
@ -20954,8 +20952,7 @@ int QueueWallBlood(short hit_sprite, short ang)
sectnum = sp->sectnum;
clipmoveboxtracenum = 1;
clipmove((vec3_t *)sp, &sectnum, nx, ny,
0L, 0L, 0L, CLIPMASK_MISSILE);
clipmove(&sp->pos, &sectnum, nx, ny, 0L, 0L, 0L, CLIPMASK_MISSILE);
clipmoveboxtracenum = 3;
if (sp->sectnum != sectnum)
@ -21092,7 +21089,7 @@ int QueueGeneric(short SpriteNum, short pic)
{
// move old sprite to new sprite's place
osp = &sprite[GenericQueue[GenericQueueHead]];
//setspritez(GenericQueue[GenericQueueHead], (vec3_t *)sp);
//setspritez(GenericQueue[GenericQueueHead], &sp->pos);
osp->x = sp->x;
osp->y = sp->y;
osp->z = sp->z;
@ -21645,7 +21642,7 @@ int QueueLoWangs(short SpriteNum)
else
{
// move old sprite to new sprite's place
setspritez(LoWangsQueue[LoWangsQueueHead], (vec3_t *)sp);
setspritez(LoWangsQueue[LoWangsQueueHead], &sp->pos);
NewSprite = LoWangsQueue[LoWangsQueueHead];
ASSERT(sprite[NewSprite].statnum != MAXSTATUS);
}