Replace manual casts of sprite and wall pointers to vec2/3_t with use of the anonymous union

git-svn-id: https://svn.eduke32.com/eduke32@7697 1a8010ca-5511-0410-912e-c29ae57300e0

# Conflicts:
#	source/build/src/build.cpp
#	source/build/src/polymost.cpp
This commit is contained in:
terminx 2019-06-25 11:28:25 +00:00 committed by Christoph Oelckers
parent 8141fbd692
commit 02ef02872a
11 changed files with 130 additions and 120 deletions

View file

@ -76,7 +76,7 @@ typedef struct
{
StructTracker(Wall, int32_t) x, y;
};
vec2_t p;
vec2_t pos;
};
StructTracker(Wall, int16_t) point2, nextwall, nextsector;
StructTracker(Wall, uint16_t) cstat;
@ -168,8 +168,8 @@ typedef struct
{
StructTracker(Sprite, int32_t) x, y, z;
};
vec3_t v;
vec2_t p;
vec3_t pos;
vec2_t pos_as_vec2;
};
StructTracker(Sprite, uint16_t) cstat;
StructTracker(Sprite, int16_t) picnum;
@ -231,7 +231,7 @@ typedef struct
{
StructTracker(Wall, int32_t) x, y;
};
vec2_t const p;
vec2_t pos;
};
StructTracker(Wall, int16_t) point2, nextwall, nextsector;
StructTracker(Wall, int16_t) upwall, dnwall;

View file

@ -733,7 +733,7 @@ int32_t clipsprite_initindex(int32_t curidx, uspriteptr_t const curspr, int32_t
{
wal->x *= flipx;
wal->y *= flipy;
rotatepoint(zerovec, *(vec2_t *) wal, rotang, (vec2_t *) wal);
rotatepoint(zerovec, wal->pos, rotang, &wal->pos);
}
wal->x += curspr->x;
@ -1640,8 +1640,8 @@ restart_grand:
if (k >= 0)
{
vec2_t const v1 = *(vec2_t *)&wall[j];
vec2_t const v2 = *(vec2_t *)&wall[wall[j].point2];
vec2_t const v1 = wall[j].pos;
vec2_t const v2 = wall[wall[j].point2].pos;
if ((v1.x < xmin && (v2.x < xmin)) || (v1.x > xmax && v2.x > xmax) ||
(v1.y < ymin && (v2.y < ymin)) || (v1.y > ymax && v2.y > ymax))
@ -1764,7 +1764,7 @@ restart_grand:
if (clipsprite_try((uspriteptr_t)&sprite[j], xmin,ymin, xmax,ymax))
continue;
#endif
vec2_t v1 = *(vec2_t *)&sprite[j];
vec2_t v1 = sprite[j].pos_as_vec2;
switch (cstat & CSTAT_SPRITE_ALIGNMENT_MASK)
{

View file

@ -198,8 +198,8 @@ int32_t bloodhack = 0;
// adapted from build.c
static void getclosestpointonwall_internal(vec2_t const &p, int32_t const dawall, vec2_t *const closest)
{
vec2_t const w = *(vec2_t *)&wall[dawall];
vec2_t const w2 = *(vec2_t *)&wall[wall[dawall].point2];
vec2_t const w = wall[dawall].pos;
vec2_t const w2 = wall[wall[dawall].point2].pos;
vec2_t const d = { w2.x - w.x, w2.y - w.y };
int64_t i = d.x * ((int64_t)p.x - w.x) + d.y * ((int64_t)p.y - w.y);
@ -2059,10 +2059,10 @@ do_mvlineasm1:
//
int32_t wallfront(int32_t l1, int32_t l2)
{
vec2_t const l1vect = *(vec2_t *)&wall[thewall[l1]];
vec2_t const l1p2vect = *(vec2_t *)&wall[wall[thewall[l1]].point2];
vec2_t const l2vect = *(vec2_t *)&wall[thewall[l2]];
vec2_t const l2p2vect = *(vec2_t *)&wall[wall[thewall[l2]].point2];
vec2_t const l1vect = wall[thewall[l1]].pos;
vec2_t const l1p2vect = wall[wall[thewall[l1]].point2].pos;
vec2_t const l2vect = wall[thewall[l2]].pos;
vec2_t const l2p2vect = wall[wall[thewall[l2]].point2].pos;
vec2_t d = { l1p2vect.x - l1vect.x, l1p2vect.y - l1vect.y };
int32_t t1 = dmulscale2(l2vect.x-l1vect.x, d.y, -d.x, l2vect.y-l1vect.y); //p1(l2) vs. l1
int32_t t2 = dmulscale2(l2p2vect.x-l1vect.x, d.y, -d.x, l2p2vect.y-l1vect.y); //p2(l2) vs. l1

View file

@ -6035,7 +6035,7 @@ void polymost_drawsprite(int32_t snum)
break;
}
vec2_t pos = *(vec2_t *)tspr;
vec2_t pos = tspr->pos_as_vec2;
if (spriteext[spritenum].flags & SPREXT_AWAY1)
{

View file

@ -342,7 +342,7 @@ static int32_t Proj_MaybeDoTransport(int32_t spriteNum, uspriteptr_t const pSEff
: sector[otherse->sectnum].floorz - daz + sector[pSEffector->sectnum].ceilingz;
// below->above
actor[spriteNum].bpos = *(vec3_t *)&sprite[spriteNum];
actor[spriteNum].bpos = sprite[spriteNum].pos;
changespritesect(spriteNum, otherse->sectnum);
return 1;
@ -460,7 +460,7 @@ int32_t A_MoveSpriteClipdist(int32_t spriteNum, vec3_t const * const change, uin
{
spritetype *const pSprite = &sprite[spriteNum];
int const isEnemy = A_CheckEnemySprite(pSprite);
vec2_t const oldPos = *(vec2_t *)pSprite;
vec2_t const oldPos = pSprite->pos_as_vec2;
// check to make sure the netcode didn't leave a deleted sprite in the sprite lists.
Bassert(pSprite->sectnum < MAXSECTORS);
@ -473,13 +473,13 @@ int32_t A_MoveSpriteClipdist(int32_t spriteNum, vec3_t const * const change, uin
pSprite->z += change->z;
if (isEnemy)
setsprite(spriteNum, (vec3_t *)pSprite);
setsprite(spriteNum, &pSprite->pos);
return 0;
}
#endif
setsprite(spriteNum, (vec3_t *)pSprite);
setsprite(spriteNum, &pSprite->pos);
clipDist = A_GetClipdist(spriteNum, clipDist);
@ -500,13 +500,13 @@ int32_t A_MoveSpriteClipdist(int32_t spriteNum, vec3_t const * const change, uin
{
default:
{
returnValue = clipmove((vec3_t *)pSprite, &newSectnum, change->x << 13, change->y << 13, clipDist, ZOFFSET6, ZOFFSET6, clipType);
returnValue = clipmove(&pSprite->pos, &newSectnum, change->x << 13, change->y << 13, clipDist, ZOFFSET6, ZOFFSET6, clipType);
break;
}
case STAT_PROJECTILE:
{
returnValue = clipmovex((vec3_t *)pSprite, &newSectnum, change->x << 13, change->y << 13, clipDist, diffZ >> 1, diffZ >> 1, clipType, 1);
returnValue = clipmovex(&pSprite->pos, &newSectnum, change->x << 13, change->y << 13, clipDist, diffZ >> 1, diffZ >> 1, clipType, 1);
break;
}
}
@ -527,11 +527,11 @@ int32_t A_MoveSpriteClipdist(int32_t spriteNum, vec3_t const * const change, uin
#endif
))
{
*(vec2_t *) pSprite = oldPos;
pSprite->pos_as_vec2 = oldPos;
// NOTE: in Duke3D, LIZMAN on water takes on random angle here.
setsprite(spriteNum, (vec3_t *)pSprite);
setsprite(spriteNum, &pSprite->pos);
if (newSectnum < 0)
newSectnum = 0;
@ -582,7 +582,7 @@ int32_t A_MoveSpriteClipdist(int32_t spriteNum, vec3_t const * const change, uin
if (yax_getbunch(newSectnum, (change->z>0))>=0
&& (SECTORFLD(newSectnum,stat, (change->z>0))&yax_waltosecmask(clipType))==0)
{
setspritez(spriteNum, (vec3_t *)pSprite);
setspritez(spriteNum, &pSprite->pos);
}
#endif
}
@ -798,7 +798,7 @@ static int32_t move_rotfixed_sprite(int32_t spriteNum, int32_t pivotSpriteNum, i
A_CheckSpriteFlags(spriteNum, SFLAG_ROTFIXED))) &&
actor[spriteNum].t_data[7] == (ROTFIXSPR_MAGIC | pivotSpriteNum))
{
rotatepoint(zerovec, *(vec2_t *)&actor[spriteNum].t_data[8], pivotAngle & 2047, (vec2_t *)&sprite[spriteNum].x);
rotatepoint(zerovec, *(vec2_t *)&actor[spriteNum].t_data[8], pivotAngle & 2047, &sprite[spriteNum].pos_as_vec2);
sprite[spriteNum].x += sprite[pivotSpriteNum].x;
sprite[spriteNum].y += sprite[pivotSpriteNum].y;
return 0;
@ -1270,7 +1270,7 @@ ACTOR_STATIC void G_MovePlayers(void)
actor[spriteNum].bpos.z = pSprite->z;
pSprite->ang = fix16_to_int(pPlayer->oq16ang);
setsprite(spriteNum, (vec3_t *)pSprite);
setsprite(spriteNum, &pSprite->pos);
}
else
{
@ -1399,7 +1399,7 @@ ACTOR_STATIC void G_MovePlayers(void)
else
{
pSprite->ang = 2047-fix16_to_int(pPlayer->q16ang);
setsprite(spriteNum,(vec3_t *)pSprite);
setsprite(spriteNum,&pSprite->pos);
}
}
@ -1830,7 +1830,7 @@ ACTOR_STATIC void G_MoveStandables(void)
if (pSprite->owner >= 0)
{
setsprite(pSprite->owner,(vec3_t *)pSprite);
setsprite(pSprite->owner,&pSprite->pos);
Bmemcpy(&actor[pSprite->owner].bpos, pSprite, sizeof(vec3_t));
@ -2003,7 +2003,7 @@ ACTOR_STATIC void G_MoveStandables(void)
pSprite->y += sintable[(T6(spriteNum))&2047]>>9;
pSprite->z -= (3<<8);
setsprite(spriteNum,(vec3_t *)pSprite);
setsprite(spriteNum,&pSprite->pos);
int hitDist = A_CheckHitSprite(spriteNum, &hitSprite);
@ -2046,7 +2046,7 @@ ACTOR_STATIC void G_MoveStandables(void)
pSprite->y = T5(spriteNum);
pSprite->z += (3<<8);
setsprite(spriteNum,(vec3_t *)pSprite);
setsprite(spriteNum,&pSprite->pos);
T4(spriteNum) = T3(spriteNum) = 0;
if (hitSprite >= 0 && actor[spriteNum].t_data[6] != 1)
@ -2069,14 +2069,14 @@ ACTOR_STATIC void G_MoveStandables(void)
pSprite->y += sintable[(T6(spriteNum))&2047]>>9;
pSprite->z -= (3<<8);
setsprite(spriteNum, (vec3_t *) pSprite);
setsprite(spriteNum, &pSprite->pos);
int hitDist = A_CheckHitSprite(spriteNum, NULL);
pSprite->x = T4(spriteNum);
pSprite->y = T5(spriteNum);
pSprite->z += (3<<8);
setsprite(spriteNum, (vec3_t *) pSprite);
setsprite(spriteNum, &pSprite->pos);
// if( Actor[i].lastvx != x && lTripBombControl & TRIPBOMB_TRIPWIRE)
if (actor[spriteNum].lastv.x != hitDist && actor[spriteNum].t_data[6] != 1)
@ -2833,7 +2833,7 @@ ACTOR_STATIC void Proj_MoveCustom(int const spriteNum)
default:
case PROJECTILE_RPG:
{
davect = *(vec3_t *) pSprite;
davect = pSprite->pos;
VM_UpdateAnim(spriteNum, &actor[spriteNum].t_data[0]);
@ -3009,7 +3009,7 @@ ACTOR_STATIC void Proj_MoveCustom(int const spriteNum)
else
{
setsprite(spriteNum, &davect);
A_DamageWall(spriteNum, otherSprite, (vec3_t *)pSprite, pSprite->picnum);
A_DamageWall(spriteNum, otherSprite, &pSprite->pos, pSprite->picnum);
if (pProj->workslike & PROJECTILE_BOUNCESOFFWALLS)
{
@ -3077,7 +3077,7 @@ ACTOR_STATIC void G_MoveWeapons(void)
if (pSprite->sectnum < 0)
DELETE_SPRITE_AND_CONTINUE(spriteNum);
actor[spriteNum].bpos = *(vec3_t *)pSprite;
actor[spriteNum].bpos = pSprite->pos;
/* Custom projectiles */
if (A_CheckSpriteFlags(spriteNum, SFLAG_PROJECTILE))
@ -3134,7 +3134,7 @@ ACTOR_STATIC void G_MoveWeapons(void)
spriteZvel >>= 1;
}
vec3_t davect = *(vec3_t *) pSprite;
vec3_t davect = pSprite->pos;
A_GetZLimits(spriteNum);
@ -3233,7 +3233,7 @@ ACTOR_STATIC void G_MoveWeapons(void)
else
{
setsprite(spriteNum, &davect);
A_DamageWall(spriteNum, moveSprite, (vec3_t *)pSprite, pSprite->picnum);
A_DamageWall(spriteNum, moveSprite, &pSprite->pos, pSprite->picnum);
if (pSprite->picnum == FREEZEBLAST)
{
@ -3525,10 +3525,10 @@ ACTOR_STATIC void G_MoveTransports(void)
pPlayer->transporter_hold = 13;
}
pPlayer->pos = *(vec3_t *)&sprite[OW(spriteNum)];
pPlayer->pos = sprite[OW(spriteNum)].pos;
pPlayer->pos.z -= PHEIGHT;
pPlayer->opos = pPlayer->pos;
pPlayer->bobpos = *(vec2_t *)&pPlayer->pos;
pPlayer->bobpos = pPlayer->pos_as_vec2;
changespritesect(sectSprite, sprite[OW(spriteNum)].sectnum);
pPlayer->cursectnum = sprite[sectSprite].sectnum;
@ -3556,7 +3556,7 @@ ACTOR_STATIC void G_MoveTransports(void)
actor[pPlayer->i].bpos = pPlayer->pos;
pPlayer->opos = pPlayer->pos;
pPlayer->bobpos = *(vec2_t *)&pPlayer->pos;
pPlayer->bobpos = pPlayer->pos_as_vec2;
changespritesect(sectSprite, sprite[OW(spriteNum)].sectnum);
pPlayer->cursectnum = sprite[OW(spriteNum)].sectnum;
@ -3684,7 +3684,7 @@ ACTOR_STATIC void G_MoveTransports(void)
sprite[sectSprite].y += sprite[OW(spriteNum)].y - SY(spriteNum);
sprite[sectSprite].z = (sectLotag == ST_1_ABOVE_WATER) ? sector[osect].ceilingz : sector[osect].floorz;
actor[sectSprite].bpos = *(vec3_t *)&sprite[sectSprite];
actor[sectSprite].bpos = sprite[sectSprite].pos;
changespritesect(sectSprite, sprite[OW(spriteNum)].sectnum);
}
@ -3703,7 +3703,7 @@ ACTOR_STATIC void G_MoveTransports(void)
sprite[sectSprite].z -= SZ(spriteNum) - sector[sprite[OW(spriteNum)].sectnum].floorz;
sprite[sectSprite].ang = sprite[OW(spriteNum)].ang;
actor[sectSprite].bpos = *(vec3_t *)&sprite[sectSprite];
actor[sectSprite].bpos = sprite[sectSprite].pos;
#ifndef EDUKE32_STANDALONE
if (sprite[spriteNum].pal == 0)
{
@ -3729,7 +3729,7 @@ ACTOR_STATIC void G_MoveTransports(void)
sprite[sectSprite].y += (sprite[OW(spriteNum)].y - SY(spriteNum));
sprite[sectSprite].z = sprite[OW(spriteNum)].z + 4096;
actor[sectSprite].bpos = *(vec3_t *)&sprite[sectSprite];
actor[sectSprite].bpos = sprite[sectSprite].pos;
changespritesect(sectSprite, sprite[OW(spriteNum)].sectnum);
}
@ -3910,7 +3910,7 @@ ACTOR_STATIC void G_MoveActors(void)
if (sprite[hitObject].picnum == POCKET && ldist(&sprite[hitObject],pSprite) < 52)
DELETE_SPRITE_AND_CONTINUE(spriteNum);
int hitObject = clipmove((vec3_t *)pSprite, &pSprite->sectnum,
int hitObject = clipmove(&pSprite->pos, &pSprite->sectnum,
(((pSprite->xvel * (sintable[(pSprite->ang + 512) & 2047])) >> 14) * TICSPERFRAME) << 11,
(((pSprite->xvel * (sintable[pSprite->ang & 2047])) >> 14) * TICSPERFRAME) << 11, 24L, ZOFFSET6,
ZOFFSET6, CLIPMASK1);
@ -4352,7 +4352,7 @@ ACTOR_STATIC void G_MoveActors(void)
goto next_sprite;
}
setsprite(spriteNum,(vec3_t *)pSprite);
setsprite(spriteNum,&pSprite->pos);
pSprite->ang = fix16_to_int(pPlayer->q16ang);
@ -4771,7 +4771,7 @@ ACTOR_STATIC void G_MoveActors(void)
if ((moveSprite&49152) == 32768)
{
vec3_t davect = *(vec3_t *)pSprite;
vec3_t davect = pSprite->pos;
moveSprite &= (MAXWALLS - 1);
A_DamageWall(spriteNum, moveSprite, &davect, pSprite->picnum);
Proj_BounceOffWall(pSprite, moveSprite);
@ -5234,13 +5234,13 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
forceRepeat -= 3;
}
*(vec3_t *)pSprite = *(vec3_t *)&sprite[pSprite->owner];
pSprite->ang += actor[pSprite->owner].t_data[0];
pSprite->pos = sprite[pSprite->owner].pos;
pSprite->ang += actor[pSprite->owner].t_data[0];
forceRepeat = clamp2(forceRepeat, 1, 64);
pSprite->xrepeat = forceRepeat;
pSprite->yrepeat = forceRepeat;
pSprite->shade = (forceRepeat >> 1) - 48;
forceRepeat = clamp2(forceRepeat, 1, 64);
pSprite->xrepeat = forceRepeat;
pSprite->yrepeat = forceRepeat;
pSprite->shade = (forceRepeat >> 1) - 48;
for (int j = pData[0]; j > 0; j--)
A_SetSprite(spriteNum, CLIPMASK0);
@ -5312,7 +5312,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
A_SetSprite(spriteNum, CLIPMASK0);
if ((krand()&3) == 0)
setsprite(spriteNum, (vec3_t *) pSprite);
setsprite(spriteNum, &pSprite->pos);
if (pSprite->sectnum == -1)
DELETE_SPRITE_AND_CONTINUE(spriteNum);
@ -5361,7 +5361,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
if (pSprite->zvel > 1024 && pSprite->zvel < 1280)
{
setsprite(spriteNum, (vec3_t *) pSprite);
setsprite(spriteNum, &pSprite->pos);
sectNum = pSprite->sectnum;
}
@ -5576,7 +5576,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
pSprite->xrepeat >>= 1;
pSprite->yrepeat >>= 1;
if (rnd(96))
setsprite(spriteNum,(vec3_t *)pSprite);
setsprite(spriteNum,&pSprite->pos);
pData[0]++;//Number of bounces
}
else if (pData[0] == 3)
@ -5604,7 +5604,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
if (pSprite->zvel > 1024 && pSprite->zvel < 1280)
{
setsprite(spriteNum,(vec3_t *)pSprite);
setsprite(spriteNum,&pSprite->pos);
sectNum = pSprite->sectnum;
}
@ -5632,7 +5632,7 @@ ACTOR_STATIC void G_MoveMisc(void) // STATNUM 5
{
int32_t j = A_Spawn(spriteNum, pSprite->yvel);
setsprite(j,(vec3_t *)pSprite);
setsprite(j,&pSprite->pos);
A_GetZLimits(j);
sprite[j].hitag = sprite[j].lotag = 0;
}
@ -5717,10 +5717,10 @@ static void MaybeTrainKillPlayer(const spritetype *pSprite, int const setOPos)
if (pPlayer->cursectnum != pSprite->sectnum && (playerSectnum == -1 || playerSectnum == pSprite->sectnum))
{
*(vec2_t *)pPlayer = *(vec2_t const *)pSprite;
pPlayer->pos_as_vec2 = pSprite->pos_as_vec2;
if (setOPos)
*(vec2_t *)&pPlayer->opos = *(vec2_t *)pPlayer;
pPlayer->opos_as_vec2 = pPlayer->pos_as_vec2;
pPlayer->cursectnum = pSprite->sectnum;
@ -5897,15 +5897,15 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
pPlayer->pos.z += zchange;
vec2_t r;
rotatepoint(*(vec2_t *)&sprite[j],*(vec2_t *)&pPlayer->pos,(q*l),&r);
rotatepoint(sprite[j].pos_as_vec2,pPlayer->pos_as_vec2,(q*l),&r);
pPlayer->bobpos.x += r.x-pPlayer->pos.x;
pPlayer->bobpos.y += r.y-pPlayer->pos.y;
*(vec2_t *)&pPlayer->pos = r;
pPlayer->pos_as_vec2 = r;
if (sprite[pPlayer->i].extra <= 0)
*(vec2_t *)&sprite[pPlayer->i] = r;
sprite[pPlayer->i].pos_as_vec2 = r;
}
}
@ -5928,7 +5928,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
actor[p].bpos.y = sprite[p].y;
if (move_rotfixed_sprite(p, j, pData[2]))
rotatepoint(*(vec2_t *)&sprite[j], *(vec2_t *)&sprite[p], (q * l), (vec2_t *)&sprite[p].x);
rotatepoint(sprite[j].pos_as_vec2, sprite[p].pos_as_vec2, (q * l), &sprite[p].pos_as_vec2);
}
}
@ -6104,7 +6104,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
#endif
)
{
rotatepoint(*(vec2_t *)pSprite, *(vec2_t *)&pPlayer->pos, q, (vec2_t *)&pPlayer->pos);
rotatepoint(pSprite->pos_as_vec2, pPlayer->pos_as_vec2, q, &pPlayer->pos_as_vec2);
pPlayer->pos.x += m;
pPlayer->pos.y += x;
@ -6147,7 +6147,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
if (move_rotfixed_sprite(j, pSprite-sprite, pData[2]))
rotatepoint(*(vec2_t *)pSprite,*(vec2_t *)&sprite[j],q,(vec2_t *)&sprite[j].x);
rotatepoint(pSprite->pos_as_vec2, sprite[j].pos_as_vec2, q, &sprite[j].pos_as_vec2);
sprite[j].x+= m;
sprite[j].y+= x;
@ -6174,7 +6174,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
A_MoveSector(spriteNum);
setsprite(spriteNum,(vec3_t *)pSprite);
setsprite(spriteNum,&pSprite->pos);
if ((pSector->floorz-pSector->ceilingz) < (108<<8))
{
@ -6313,7 +6313,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
A_MoveSector(spriteNum);
setsprite(spriteNum,(vec3_t *)pSprite);
setsprite(spriteNum,&pSprite->pos);
if (pSector->floorz-pSector->ceilingz < (108<<8))
{
@ -6388,7 +6388,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
A_MoveSector(spriteNum);
setsprite(spriteNum,(vec3_t *)pSprite);
setsprite(spriteNum,&pSprite->pos);
}
break;
@ -6568,7 +6568,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
sector[pData[0]].ceilingz += pSprite->zvel;
A_MoveSector(spriteNum);
setsprite(spriteNum, (vec3_t *)pSprite);
setsprite(spriteNum, &pSprite->pos);
break;
}
@ -6694,7 +6694,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
(pSprite->sectnum == sprite[k].sectnum ||
sectoradjacent(pSprite->sectnum, sprite[k].sectnum)) &&
A_CheckEnemySprite(&sprite[k]) &&
clipinsidebox((vec2_t *)&sprite[k], j, 256) == 1)
clipinsidebox(&sprite[k].pos_as_vec2, j, 256) == 1)
goto next_sprite;
}
}
@ -6703,19 +6703,19 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
pData[2] += l;
pData[4] += l;
A_MoveSector(spriteNum);
setsprite(spriteNum, (vec3_t *)pSprite);
setsprite(spriteNum, &pSprite->pos);
for (j=pSector->wallptr; j<endWall; j++)
{
for (SPRITES_OF(STAT_PLAYER, k))
{
if (sprite[k].owner >= 0 && clipinsidebox((vec2_t *)&sprite[k], j, pPlayer->clipdist))
if (sprite[k].owner >= 0 && clipinsidebox(&sprite[k].pos_as_vec2, j, pPlayer->clipdist))
{
pData[5] = 8; // Delay
pData[2] -= l;
pData[4] -= l;
A_MoveSector(spriteNum);
setsprite(spriteNum, (vec3_t *)pSprite);
setsprite(spriteNum, &pSprite->pos);
goto next_sprite;
}
}
@ -6726,7 +6726,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
pData[4] = 0;
pData[2] &= 0xffffff00;
A_MoveSector(spriteNum);
setsprite(spriteNum, (vec3_t *) pSprite);
setsprite(spriteNum, &pSprite->pos);
break;
}
}
@ -6913,7 +6913,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
A_MoveSector(spriteNum);
setsprite(spriteNum,(vec3_t *)pSprite);
setsprite(spriteNum,&pSprite->pos);
}
break;
@ -6947,7 +6947,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
: pSector->ceilingz - 512;
A_MoveSector(spriteNum);
setsprite(spriteNum,(vec3_t *)pSprite);
setsprite(spriteNum,&pSprite->pos);
break;
@ -7030,13 +7030,13 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
pPlayer->pos.z = sector[sprite[j].sectnum].floorz - (pSector->floorz - pPlayer->pos.z);
pPlayer->opos.z += pPlayer->pos.z;
actor[k].floorz = sector[sprite[j].sectnum].floorz;
actor[k].ceilingz = sector[sprite[j].sectnum].ceilingz;
*(vec2_t *)&pPlayer->opos = *(vec2_t *)pPlayer;
*(vec2_t *)&pPlayer->bobpos = *(vec2_t *)pPlayer;
pPlayer->truefz = actor[k].floorz;
pPlayer->truecz = actor[k].ceilingz;
pPlayer->bobcounter = 0;
actor[k].floorz = sector[sprite[j].sectnum].floorz;
actor[k].ceilingz = sector[sprite[j].sectnum].ceilingz;
pPlayer->opos_as_vec2 = pPlayer->pos_as_vec2;
pPlayer->bobpos = pPlayer->pos_as_vec2;
pPlayer->truefz = actor[k].floorz;
pPlayer->truecz = actor[k].ceilingz;
pPlayer->bobcounter = 0;
changespritesect(k, sprite[j].sectnum);
pPlayer->cursectnum = sprite[j].sectnum;
@ -7553,7 +7553,7 @@ ACTOR_STATIC void G_MoveEffectors(void) //STATNUM 3
}
A_MoveSector(spriteNum);
setsprite(spriteNum,(vec3_t *)pSprite);
setsprite(spriteNum,&pSprite->pos);
break;
}

View file

@ -1673,7 +1673,7 @@ int A_Spawn(int spriteNum, int tileNum)
pSprite->xvel = 128;
changespritestat(newSprite, STAT_MISC);
A_SetSprite(newSprite,CLIPMASK0);
setsprite(newSprite,(vec3_t *)pSprite);
setsprite(newSprite,&pSprite->pos);
break;
case FEMMAG1__STATIC:
case FEMMAG2__STATIC:
@ -1880,7 +1880,7 @@ int A_Spawn(int spriteNum, int tileNum)
pSprite->z = sector[sectNum].ceilingz+(48<<8);
T5(newSprite) = tempwallptr;
g_origins[tempwallptr] = *(vec2_t *) pSprite;
g_origins[tempwallptr] = pSprite->pos_as_vec2;
g_origins[tempwallptr+2].x = pSprite->z;
@ -1899,9 +1899,9 @@ int A_Spawn(int spriteNum, int tileNum)
sprite[findSprite].xrepeat = 48;
sprite[findSprite].yrepeat = 128;
g_origins[tempwallptr + 1] = *(vec2_t *) &sprite[findSprite];
*(vec3_t *) &sprite[findSprite] = *(vec3_t *) pSprite;
sprite[findSprite].shade = pSprite->shade;
g_origins[tempwallptr + 1] = sprite[findSprite].pos_as_vec2;
sprite[findSprite].pos = pSprite->pos;
sprite[findSprite].shade = pSprite->shade;
setsprite(findSprite, (vec3_t *) &sprite[findSprite]);
break;
@ -6893,7 +6893,7 @@ int G_DoMoveThings(void)
if (g_player[i].ps->holoduke_on != -1)
sprite[g_player[i].ps->holoduke_on].cstat ^= 256;
hitscan((vec3_t *)pPlayer, pPlayer->cursectnum, sintable[(fix16_to_int(pPlayer->q16ang) + 512) & 2047],
hitscan(&pPlayer->pos, pPlayer->cursectnum, sintable[(fix16_to_int(pPlayer->q16ang) + 512) & 2047],
sintable[fix16_to_int(pPlayer->q16ang) & 2047], fix16_to_int(F16(100) - pPlayer->q16horiz - pPlayer->q16horizoff) << 11, &hitData,
0xffff0030);

View file

@ -388,7 +388,7 @@ void VM_GetZRange(int const spriteNum, int32_t * const ceilhit, int32_t * const
pSprite->cstat = 0;
pSprite->z -= ZOFFSET;
getzrange((vec3_t *)pSprite, pSprite->sectnum, &actor[spriteNum].ceilingz, ceilhit, &actor[spriteNum].floorz, florhit, wallDist, CLIPMASK0);
getzrange(&pSprite->pos, pSprite->sectnum, &actor[spriteNum].ceilingz, ceilhit, &actor[spriteNum].floorz, florhit, wallDist, CLIPMASK0);
pSprite->z += ZOFFSET;
pSprite->cstat = ocstat;
@ -464,7 +464,7 @@ void A_Fall(int const spriteNum)
#ifdef YAX_ENABLE
if (fbunch >= 0)
setspritez(spriteNum, (vec3_t *)pSprite);
setspritez(spriteNum, &pSprite->pos);
else
#endif
if (pSprite->z >= actor[spriteNum].floorz-ZOFFSET)
@ -599,7 +599,7 @@ static inline void VM_FacePlayer(int const shift)
static int32_t VM_GetCeilZOfSlope(void)
{
vec2_t const vect = *(vec2_t *)vm.pSprite;
vec2_t const vect = vm.pSprite->pos_as_vec2;
int const sectnum = vm.pSprite->sectnum;
#ifdef YAX_ENABLE
@ -616,7 +616,7 @@ static int32_t VM_GetCeilZOfSlope(void)
#ifndef EDUKE32_STANDALONE
static int32_t VM_GetFlorZOfSlope(void)
{
vec2_t const vect = *(vec2_t *)vm.pSprite;
vec2_t const vect = vm.pSprite->pos_as_vec2;
int const sectnum = vm.pSprite->sectnum;
#ifdef YAX_ENABLE
@ -1011,7 +1011,7 @@ static void VM_Fall(int const spriteNum, spritetype * const pSprite)
#ifdef YAX_ENABLE
if (yax_getbunch(pSprite->sectnum, YAX_FLOOR) >= 0 && (sector[pSprite->sectnum].floorstat & 512) == 0)
setspritez(spriteNum, (vec3_t *)pSprite);
setspritez(spriteNum, &pSprite->pos);
else
#endif
if (newZ > actor[spriteNum].floorz - ZOFFSET)
@ -1046,7 +1046,7 @@ static void VM_Fall(int const spriteNum, spritetype * const pSprite)
{
int16_t newsect = pSprite->sectnum;
pushmove((vec3_t *)pSprite, &newsect, 128, 4<<8, 4<<8, CLIPMASK0);
pushmove(&pSprite->pos, &newsect, 128, 4<<8, 4<<8, CLIPMASK0);
if ((unsigned)newsect < MAXSECTORS)
changespritesect(spriteNum, newsect);

View file

@ -1588,15 +1588,16 @@ int A_ShootWithZvel(int const spriteNum, int const projecTile, int const forceZv
if (pPlayer != NULL)
{
startPos = *(vec3_t *)pPlayer;
startPos.z += pPlayer->pyoff + ZOFFSET6;
shootAng = fix16_to_int(pPlayer->q16ang);
startPos = pPlayer->pos;
startPos.z += pPlayer->pyoff + ZOFFSET6;
shootAng = fix16_to_int(pPlayer->q16ang);
pPlayer->crack_time = PCRACKTIME;
}
else
{
shootAng = pSprite->ang;
startPos = *(vec3_t *)pSprite;
startPos = pSprite->pos;
startPos.z -= (((pSprite->yrepeat * tilesiz[pSprite->picnum].y)<<1) - ZOFFSET6);
if (pSprite->picnum != ROTATEGUN)
@ -4447,8 +4448,8 @@ static void getzsofslope_player(int sectNum, int playerX, int playerY, int32_t *
void P_UpdatePosWhenViewingCam(DukePlayer_t *pPlayer)
{
int const newOwner = pPlayer->newowner;
pPlayer->pos = *(vec3_t *)&sprite[newOwner];
pPlayer->q16ang = fix16_from_int(SA(newOwner));
pPlayer->pos = sprite[newOwner].pos;
pPlayer->q16ang = fix16_from_int(SA(newOwner));
pPlayer->vel.x = 0;
pPlayer->vel.y = 0;
sprite[pPlayer->i].xvel = 0;
@ -4597,7 +4598,7 @@ static void P_Dead(int const playerNum, int const sectorLotag, int const floorZ,
pSprite->zvel = -348;
}
clipmove((vec3_t *) pPlayer, &pPlayer->cursectnum,
clipmove(&pPlayer->pos, &pPlayer->cursectnum,
0, 0, pPlayer->clipdist, (4L<<8), (4L<<8), CLIPMASK0);
// p->bobcounter += 32;
}
@ -4611,7 +4612,7 @@ static void P_Dead(int const playerNum, int const sectorLotag, int const floorZ,
updatesector(pPlayer->pos.x, pPlayer->pos.y, &pPlayer->cursectnum);
pushmove((vec3_t *) pPlayer, &pPlayer->cursectnum, 128L, (4L<<8), (20L<<8), CLIPMASK0);
pushmove(&pPlayer->pos, &pPlayer->cursectnum, 128L, (4L<<8), (20L<<8), CLIPMASK0);
if (floorZ > ceilZ + ZOFFSET2 && pSprite->pal != 1)
pPlayer->rotscrnang = (pPlayer->dead_flag + ((floorZ+pPlayer->pos.z)>>7))&2047;
@ -4702,11 +4703,11 @@ void P_ProcessInput(int playerNum)
}
pPlayer->pos.z += stepHeight;
getzrange((vec3_t *)pPlayer, pPlayer->cursectnum, &ceilZ, &highZhit, &floorZ, &lowZhit, pPlayer->clipdist - 16, CLIPMASK0);
getzrange(&pPlayer->pos, pPlayer->cursectnum, &ceilZ, &highZhit, &floorZ, &lowZhit, pPlayer->clipdist - 16, CLIPMASK0);
pPlayer->pos.z -= stepHeight;
int32_t ceilZ2 = ceilZ;
getzrange((vec3_t *)pPlayer, pPlayer->cursectnum, &ceilZ, &highZhit, &dummy, &dummy, pPlayer->clipdist - 16, CSTAT_SPRITE_ALIGNMENT_FLOOR << 16);
getzrange(&pPlayer->pos, pPlayer->cursectnum, &ceilZ, &highZhit, &dummy, &dummy, pPlayer->clipdist - 16, CSTAT_SPRITE_ALIGNMENT_FLOOR << 16);
if ((highZhit & 49152) == 49152 && (sprite[highZhit & (MAXSPRITES - 1)].cstat & CSTAT_SPRITE_BLOCK) != CSTAT_SPRITE_BLOCK)
ceilZ = ceilZ2;
@ -5143,7 +5144,7 @@ void P_ProcessInput(int playerNum)
pPlayer->jumping_toggle--;
else if (TEST_SYNC_KEY(playerBits, SK_JUMP) && pPlayer->jumping_toggle == 0)
{
getzrange((vec3_t *)pPlayer, pPlayer->cursectnum, &ceilZ, &dummy, &dummy, &dummy, pPlayer->clipdist - 16, CLIPMASK0);
getzrange(&pPlayer->pos, pPlayer->cursectnum, &ceilZ, &dummy, &dummy, &dummy, pPlayer->clipdist - 16, CLIPMASK0);
if ((floorZ-ceilZ) > (48<<8))
{
@ -5378,9 +5379,9 @@ HORIZONLY:;
P_ClampZ(pPlayer, sectorLotag, ceilZ, floorZ);
int const touchObject = IONMAIDEN ? clipmove((vec3_t *)pPlayer, &pPlayer->cursectnum, pPlayer->vel.x + (pPlayer->fric.x << 9),
int const touchObject = IONMAIDEN ? clipmove(&pPlayer->pos, &pPlayer->cursectnum, pPlayer->vel.x + (pPlayer->fric.x << 9),
pPlayer->vel.y + (pPlayer->fric.y << 9), pPlayer->clipdist, (4L << 8), stepHeight, CLIPMASK0)
: clipmove((vec3_t *)pPlayer, &pPlayer->cursectnum, pPlayer->vel.x, pPlayer->vel.y, pPlayer->clipdist,
: clipmove(&pPlayer->pos, &pPlayer->cursectnum, pPlayer->vel.x, pPlayer->vel.y, pPlayer->clipdist,
(4L << 8), stepHeight, CLIPMASK0);
if (touchObject)
@ -5443,7 +5444,7 @@ HORIZONLY:;
if (pPlayer->cursectnum >= 0 && ud.noclip == 0)
{
int const pushResult = pushmove((vec3_t *)pPlayer, &pPlayer->cursectnum, pPlayer->clipdist - 1, (4L << 8), (4L << 8), CLIPMASK0);
int const pushResult = pushmove(&pPlayer->pos, &pPlayer->cursectnum, pPlayer->clipdist - 1, (4L << 8), (4L << 8), CLIPMASK0);
int const furthestAngle = A_GetFurthestAngle(pPlayer->i, 32);
int const angleDelta = G_GetAngleDelta(fix16_to_int(pPlayer->q16ang), furthestAngle);
bool const squishPlayer = pushResult < 0 && !angleDelta;

View file

@ -138,7 +138,17 @@ typedef struct {
// TODO: rearrange this if the opportunity arises!
// KEEPINSYNC lunatic/_defs_game.lua
typedef struct {
vec3_t pos, opos, vel, npos;
union {
vec3_t pos;
vec2_t pos_as_vec2;
};
union {
vec3_t opos;
vec2_t opos_as_vec2;
};
vec3_t vel, npos;
vec2_t bobpos, fric;
fix16_t q16horiz, q16horizoff, oq16horiz, oq16horizoff;

View file

@ -646,7 +646,7 @@ void P_MoveToRandomSpawnPoint(int playerNum)
p.opos = p.pos = g_playerSpawnPoints[i].pos;
p.bobpos = *(vec2_t *)&p.pos;
p.bobpos = p.pos_as_vec2;
p.cursectnum = g_playerSpawnPoints[i].sect;
p.q16ang = fix16_from_int(g_playerSpawnPoints[i].ang);
@ -677,7 +677,7 @@ void P_ResetMultiPlayer(int playerNum)
P_MoveToRandomSpawnPoint(playerNum);
a.bpos = p.opos = p.pos;
p.bobpos = *(vec2_t *)&p.pos;
p.bobpos = p.pos_as_vec2;
*(vec3_t *)&s = p.pos;
@ -1480,7 +1480,7 @@ static void G_CollectSpawnPoints(int gameMode)
auto &s = sprite[i];
auto &spawn = g_playerSpawnPoints[g_playerSpawnCnt];
spawn.pos = *(vec3_t *)&s.x;
spawn.pos = s.pos;
spawn.ang = s.ang;
spawn.sect = s.sectnum;
@ -1555,8 +1555,8 @@ static void G_CollectSpawnPoints(int gameMode)
p.frag_ps = pindex;
actor[i].owner = p.i = i;
actor[i].bpos = p.opos = p.pos = *(vec3_t *)&s.x;
p.bobpos = *(vec2_t *)&s.x;
actor[i].bpos = p.opos = p.pos = s.pos;
p.bobpos = s.pos_as_vec2;
p.oq16ang = p.q16ang = fix16_from_int(s.ang);

View file

@ -1214,7 +1214,7 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType)
lotag = sprite[wallOrSprite].lotag;
hitag = sprite[wallOrSprite].hitag;
davector = *(vec3_t *)&sprite[wallOrSprite];
davector = sprite[wallOrSprite].pos;
nSwitchPicnum = sprite[wallOrSprite].picnum;
nSwitchPal = sprite[wallOrSprite].pal;
}
@ -1225,8 +1225,7 @@ int P_ActivateSwitch(int playerNum, int wallOrSprite, int switchType)
lotag = wall[wallOrSprite].lotag;
hitag = wall[wallOrSprite].hitag;
davector = *(vec3_t *)&wall[wallOrSprite];
davector.z = g_player[playerNum].ps->pos.z;
davector = { wall[wallOrSprite].x, wall[wallOrSprite].y, g_player[playerNum].ps->pos.z };
nSwitchPicnum = wall[wallOrSprite].picnum;
nSwitchPal = wall[wallOrSprite].pal;
}
@ -2345,7 +2344,7 @@ void A_DamageObject_Internal(int spriteNum, int const dmgSrc)
SA(spriteNum) = (sprite[dmgSrc].ang + 1024) & 2047;
sprite[spriteNum].xvel = -(sprite[dmgSrc].extra << 2);
int16_t sectNum = SECT(spriteNum);
pushmove((vec3_t *)&sprite[spriteNum], &sectNum, 128L, (4L << 8), (4L << 8), CLIPMASK0);
pushmove(&sprite[spriteNum].pos, &sectNum, 128L, (4L << 8), (4L << 8), CLIPMASK0);
if (sectNum != SECT(spriteNum) && (unsigned)sectNum < MAXSECTORS)
changespritesect(spriteNum, sectNum);
}