Commit b1882c5f authored by Evan Ramos's avatar Evan Ramos
Browse files

SW: Vectorize struct variables where casts to vector types are used

parent 88ebb323
......@@ -171,7 +171,7 @@ static int32_t currentlist=0;
static int32_t fillist[640];
// used for fillsector, batch point insertion, backup_highlighted_map
static int32_t tempxyar[MAXWALLS][2];
static vec2_t tempxyar[MAXWALLS];
static int32_t mousx, mousy;
int16_t prefixtiles[10] = { 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 };
......@@ -7731,7 +7731,7 @@ end_space_handling:
if (newnumwalls > numwalls) // batch insert points
{
const int32_t numdrawnwalls = newnumwalls-numwalls;
vec2_t *point = (vec2_t *)tempxyar; // [MAXWALLS][2]
vec2_t * point = tempxyar;
int32_t insdpoints = 0;
// back up the points of the line strip
......@@ -10198,8 +10198,8 @@ int32_t fillsector_maybetrans(int16_t sectnum, int32_t fillcolor, uint8_t dotran
if (m32_sideview)
{
tempxyar[z][0] = x1;
tempxyar[z][1] = y1;
tempxyar[z].x = x1;
tempxyar[z].y = y1;
}
miny = min(miny, y1);
......@@ -10223,10 +10223,10 @@ int32_t fillsector_maybetrans(int16_t sectnum, int32_t fillcolor, uint8_t dotran
{
if (m32_sideview)
{
x1 = tempxyar[z][0];
y1 = tempxyar[z][1];
x2 = tempxyar[wall[z].point2][0];
y2 = tempxyar[wall[z].point2][1];
x1 = tempxyar[z].x;
y1 = tempxyar[z].y;
x2 = tempxyar[wall[z].point2].x;
y2 = tempxyar[wall[z].point2].y;
if (y1 > y2)
{
......
......@@ -244,7 +244,7 @@ void EveryCheatToggle(PLAYERp pp, char *cheat_string)
void SaveCheat(PLAYERp pp, char *UNUSED(cheat_string))
{
saveboard("swsave.map", (vec3_t *)pp,
saveboard("swsave.map", &pp->pos,
fix16_to_int(pp->q16ang), pp->cursectnum);
}
......
......@@ -510,7 +510,7 @@ DemoPlayBack(void)
{
KEY_PRESSED(KEYSC_ALT) = KEY_PRESSED(KEYSC_CTRL) = KEY_PRESSED(KEYSC_S) = 0;
int16_t ang = fix16_to_int(Player->pang);
saveboard("demosave.map", (vec3_t *)Player, ang, &Player->cursectnum);
saveboard("demosave.map", &Player->pos, ang, &Player->cursectnum);
}
#endif
......
......@@ -691,7 +691,7 @@ void
LoadLevel(const char *filename)
{
int16_t ang;
if (engineLoadBoard(filename, SW_SHAREWARE ? 1 : 0, (vec3_t *)&Player[0], &ang, &Player[0].cursectnum) == -1)
if (engineLoadBoard(filename, SW_SHAREWARE ? 1 : 0, &Player[0].pos, &ang, &Player[0].cursectnum) == -1)
{
TerminateGame();
#if 1 /* defined RENDERTYPEWIN */
......
......@@ -1044,7 +1044,13 @@ 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;
......@@ -1106,7 +1112,7 @@ struct PLAYERstruct
short recoil_horizoff;
int oldposx,oldposy,oldposz;
int RevolveX, RevolveY;
vec2_t RevolvePos;
short RevolveDeltaAng;
fix16_t RevolveQ16Ang;
......@@ -1936,8 +1942,16 @@ struct SECTOR_OBJECTstruct
SPRITEp sp_child; // child sprite that holds info for the sector object
int xmid,ymid,zmid, // midpoints of the sector object
vel, // velocity
// midpoints of the sector object
union {
struct
{
int32_t xmid, ymid, zmid;
};
vec3_t mid;
};
int vel, // velocity
vel_tgt, // target velocity
player_xoff, // player x offset from the xmid
player_yoff, // player y offset from the ymid
......
......@@ -529,9 +529,9 @@ 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]);
//rotatepoint(sop->mid.pos2, p, rot_ang, &xy[i]);
}
//Given the 4 points: x[4], y[4]
......
......@@ -2409,7 +2409,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))
......@@ -2422,9 +2422,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))
......@@ -2744,7 +2744,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)
{
......@@ -2767,11 +2767,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)
{
......@@ -5592,7 +5592,7 @@ DoPlayerCurrent(PLAYERp pp)
xvect = sectu->speed * synctics * (int) sintable[NORM_ANGLE(sectu->ang + 512)] >> 4;
yvect = sectu->speed * synctics * (int) sintable[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))
......@@ -5607,9 +5607,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))
......
......@@ -783,8 +783,7 @@ SectorObjectSetupBounds(SECTOR_OBJECTp sop)
if (pp->posx > xlow && pp->posx < xhigh && pp->posy > ylow && pp->posy < yhigh)
{
pp->RevolveQ16Ang = pp->q16ang;
pp->RevolveX = pp->posx;
pp->RevolveY = pp->posy;
pp->RevolvePos = pp->pos.vec2;
pp->RevolveDeltaAng = 0;
SET(pp->Flags, PF_PLAYER_RIDING);
......@@ -1619,8 +1618,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
SET(pp->Flags, PF_PLAYER_RIDING);
pp->RevolveQ16Ang = pp->q16ang;
pp->RevolveX = pp->posx;
pp->RevolveY = pp->posy;
pp->RevolvePos = pp->pos.vec2;
// set the delta angle to 0 when moving
pp->RevolveDeltaAng = 0;
......@@ -1643,8 +1641,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
// moving then you
// know where he was last
pp->RevolveQ16Ang = pp->q16ang;
pp->RevolveX = pp->posx;
pp->RevolveY = pp->posy;
pp->RevolvePos = pp->pos.vec2;
// set the delta angle to 0 when moving
pp->RevolveDeltaAng = 0;
......@@ -1654,8 +1651,8 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
// Player is NOT moving
// Move saved x&y variables
pp->RevolveX += BOUND_4PIX(nx);
pp->RevolveY += BOUND_4PIX(ny);
pp->RevolvePos.x += BOUND_4PIX(nx);
pp->RevolvePos.y += BOUND_4PIX(ny);
// Last known angle is now adjusted by the delta angle
pp->RevolveQ16Ang = NORM_Q16ANGLE(pp->q16ang - fix16_from_int(pp->RevolveDeltaAng));
......@@ -1664,7 +1661,7 @@ MovePlayer(PLAYERp pp, SECTOR_OBJECTp sop, int nx, int ny)
// increment Players delta angle
pp->RevolveDeltaAng = NORM_ANGLE(pp->RevolveDeltaAng + GlobSpeedSO);
rotatepoint(*(vec2_t *)&sop->xmid, *(vec2_t *)&pp->RevolveX, pp->RevolveDeltaAng, (vec2_t *)&pp->posx);
rotatepoint(sop->mid.vec2, pp->RevolvePos, pp->RevolveDeltaAng, &pp->pos.vec2);
// THIS WAS CAUSING PROLEMS!!!!
// Sectors are still being manipulated so you can end up in a void (-1) sector
......@@ -1749,7 +1746,7 @@ MovePoints(SECTOR_OBJECTp sop, short delta_ang, int nx, int ny)
if (TEST(wp->extra, WALLFX_LOOP_SPIN_4X))
rot_ang = NORM_ANGLE(rot_ang * 4);
rotatepoint(*(vec2_t *)&sop->xmid, wp->pos, rot_ang, &rxy);
rotatepoint(sop->mid.vec2, wp->pos, rot_ang, &rxy);
if (wp->extra && TEST(wp->extra, WALLFX_LOOP_OUTER))
{
......@@ -1862,12 +1859,12 @@ PlayerPart:
if (TEST(wall[sector[sp->sectnum].wallptr].extra, WALLFX_LOOP_REVERSE_SPIN))
{
rotatepoint(*(vec2_t *)&sop->xmid, sp->pos.vec2, -delta_ang, &sp->pos.vec2);
rotatepoint(sop->mid.vec2, sp->pos.vec2, -delta_ang, &sp->pos.vec2);
sp->ang = NORM_ANGLE(sp->ang - delta_ang);
}
else
{
rotatepoint(*(vec2_t *)&sop->xmid, sp->pos.vec2, delta_ang, &sp->pos.vec2);
rotatepoint(sop->mid.vec2, sp->pos.vec2, delta_ang, &sp->pos.vec2);
sp->ang = NORM_ANGLE(sp->ang + delta_ang);
}
......@@ -1877,7 +1874,7 @@ PlayerPart:
if (!TEST(sop->flags, SOBJ_DONT_ROTATE))
{
// NOT part of a sector - independant of any sector
rotatepoint(*(vec2_t *)&sop->xmid, sp->pos.vec2, delta_ang, &sp->pos.vec2);
rotatepoint(sop->mid.vec2, sp->pos.vec2, delta_ang, &sp->pos.vec2);
sp->ang = NORM_ANGLE(sp->ang + delta_ang);
}
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment