- SW: Replace PLAYERstruct yvect with vect.Y calls.

This commit is contained in:
Mitchell Richters 2021-12-30 23:49:24 +11:00
parent f2497d7d08
commit 5515830e2b
8 changed files with 58 additions and 60 deletions

View file

@ -632,7 +632,6 @@ struct PLAYERstruct
int16_t siang;
vec2_t vect;
int yvect;
int oxvect, oyvect;
int friction;
int slide_xvect, slide_yvect;
@ -2140,7 +2139,7 @@ inline bool SpriteInUnderwaterArea(DSWActor* a)
// just determine if the player is moving
inline bool PLAYER_MOVING(PLAYERp pp)
{
return (pp->vect.X | pp->yvect);
return (pp->vect.X | pp->vect.Y);
}
inline void PlaySound(int num, DSWActor* actor, Voc3D_Flags flags, int channel = 8, EChanFlags sndflags = CHANF_NONE)

View file

@ -1296,7 +1296,7 @@ int PlayerInitChemBomb(PLAYERp pp)
// adjust xvel according to player velocity
actorNew->user.xchange += pp->vect.X >> 14;
actorNew->user.ychange += pp->yvect >> 14;
actorNew->user.ychange += pp->vect.Y >> 14;
// Smoke will come out for this many seconds
actorNew->user.WaitTics = CHEMTICS;
@ -1668,7 +1668,7 @@ int PlayerInitCaltrops(PLAYERp pp)
// adjust xvel according to player velocity
actorNew->user.xchange += pp->vect.X >> 14;
actorNew->user.ychange += pp->yvect >> 14;
actorNew->user.ychange += pp->vect.Y >> 14;
SetupSpriteForBreak(actorNew); // Put Caltrops in the break queue
return 0;

View file

@ -96,7 +96,7 @@ Collision MultiClipMove(PLAYERp pp, int z, int floor_dist)
pos[i].Z = z;
// move the box
clipmove(pos[i], &pp->cursector, pp->vect.X, pp->yvect, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER, coll);
clipmove(pos[i], &pp->cursector, pp->vect.X, pp->vect.Y, (int)sop->clipbox_dist[i], Z(4), floor_dist, CLIPMASK_PLAYER, coll);
// save the dist moved
dist = ksqrt(SQ(pos[i].X - opos[i].X) + SQ(pos[i].Y - opos[i].Y));
@ -195,14 +195,14 @@ int RectClipMove(PLAYERp pp, int *qx, int *qy)
for (i = 0; i < 4; i++)
{
xy[i].X = qx[i] + (pp->vect.X>>14);
xy[i].Y = qy[i] + (pp->yvect>>14);
xy[i].Y = qy[i] + (pp->vect.Y>>14);
}
//Given the 4 points: x[4], y[4]
if (testquadinsect(&point_num, xy, pp->cursector))
{
pp->pos.X += (pp->vect.X>>14);
pp->pos.Y += (pp->yvect>>14);
pp->pos.Y += (pp->vect.Y>>14);
return true;
}
@ -213,12 +213,12 @@ int RectClipMove(PLAYERp pp, int *qx, int *qy)
{
for (i = 0; i < 4; i++)
{
xy[i].X = qx[i] - (pp->yvect>>15);
xy[i].X = qx[i] - (pp->vect.Y>>15);
xy[i].Y = qy[i] + (pp->vect.X>>15);
}
if (testquadinsect(&point_num, xy, pp->cursector))
{
pp->pos.X -= (pp->yvect>>15);
pp->pos.X -= (pp->vect.Y>>15);
pp->pos.Y += (pp->vect.X>>15);
}
@ -229,12 +229,12 @@ int RectClipMove(PLAYERp pp, int *qx, int *qy)
{
for (i = 0; i < 4; i++)
{
xy[i].X = qx[i] + (pp->yvect>>15);
xy[i].X = qx[i] + (pp->vect.Y>>15);
xy[i].Y = qy[i] - (pp->vect.X>>15);
}
if (testquadinsect(&point_num, xy, pp->cursector))
{
pp->pos.X += (pp->yvect>>15);
pp->pos.X += (pp->vect.Y>>15);
pp->pos.Y -= (pp->vect.X>>15);
}

View file

@ -6312,7 +6312,7 @@ void pWeaponBob(PANEL_SPRITEp psp, short condition)
{
double xdiff = 0, ydiff = 0;
double bobvel = fFindDistance2D(psp->PlayerP->vect.X, psp->PlayerP->yvect) * (1. / 32768.);
double bobvel = fFindDistance2D(psp->PlayerP->vect.X, psp->PlayerP->vect.Y) * (1. / 32768.);
bobvel = bobvel + (bobvel * (1. / 4.));
bobvel = min(bobvel, 128.);

View file

@ -1244,7 +1244,7 @@ DSWActor* DoPickTarget(DSWActor* actor, uint32_t max_delta_ang, int skip_targets
void DoPlayerResetMovement(PLAYERp pp)
{
pp->vect.X = pp->oxvect = 0;
pp->yvect = pp->oxvect = 0;
pp->vect.Y = pp->oxvect = 0;
pp->slide_xvect = 0;
pp->slide_yvect = 0;
pp->drive_avel = 0;
@ -1582,7 +1582,7 @@ void SlipSlope(PLAYERp pp)
ang = NORM_ANGLE(ang + 512);
pp->vect.X += MulScale(bcos(ang), pp->cursector->floorheinum, sectu->speed);
pp->yvect += MulScale(bsin(ang), pp->cursector->floorheinum, sectu->speed);
pp->vect.Y += MulScale(bsin(ang), pp->cursector->floorheinum, sectu->speed);
}
void DoPlayerHorizon(PLAYERp pp, float const horz, double const scaleAdjust)
@ -2012,10 +2012,10 @@ void DoPlayerMove(PLAYERp pp)
DoPlayerSlide(pp);
pp->oxvect = pp->vect.X;
pp->oyvect = pp->yvect;
pp->oyvect = pp->vect.Y;
pp->vect.X += ((pp->input.fvel*synctics*2)<<6);
pp->yvect += ((pp->input.svel*synctics*2)<<6);
pp->vect.Y += ((pp->input.svel*synctics*2)<<6);
friction = pp->friction;
if (!(pp->Flags & PF_SWIMMING) && pp->WadeDepth)
@ -2024,25 +2024,25 @@ void DoPlayerMove(PLAYERp pp)
}
pp->vect.X = MulScale(pp->vect.X, friction, 16);
pp->yvect = MulScale(pp->yvect, friction, 16);
pp->vect.Y = MulScale(pp->vect.Y, friction, 16);
if (pp->Flags & (PF_FLYING))
{
// do a bit of weighted averaging
pp->vect.X = (pp->vect.X + (pp->oxvect*1))/2;
pp->yvect = (pp->yvect + (pp->oyvect*1))/2;
pp->vect.Y = (pp->vect.Y + (pp->oyvect*1))/2;
}
else if (pp->Flags & (PF_DIVING))
{
// do a bit of weighted averaging
pp->vect.X = (pp->vect.X + (pp->oxvect*2))/3;
pp->yvect = (pp->yvect + (pp->oyvect*2))/3;
pp->vect.Y = (pp->vect.Y + (pp->oyvect*2))/3;
}
if (labs(pp->vect.X) < 12800 && labs(pp->yvect) < 12800)
pp->vect.X = pp->yvect = 0;
if (labs(pp->vect.X) < 12800 && labs(pp->vect.Y) < 12800)
pp->vect.X = pp->vect.Y = 0;
actor->spr.xvel = FindDistance2D(pp->vect.X,pp->yvect)>>14;
actor->spr.xvel = FindDistance2D(pp->vect.X,pp->vect.Y)>>14;
if (pp->Flags & (PF_CLIP_CHEAT))
{
@ -2053,7 +2053,7 @@ void DoPlayerMove(PLAYERp pp)
pp->opos.Y = pp->pos.Y;
}
pp->pos.X += pp->vect.X >> 14;
pp->pos.Y += pp->yvect >> 14;
pp->pos.Y += pp->vect.Y >> 14;
updatesector(pp->pos.X, pp->pos.Y, &sect);
if (sect != nullptr)
pp->cursector = sect;
@ -2084,7 +2084,7 @@ void DoPlayerMove(PLAYERp pp)
actor->spr.cstat &= ~(CSTAT_SPRITE_BLOCK);
Collision coll;
updatesector(pp->pos.X, pp->pos.Y, &pp->cursector);
clipmove(pp->pos, &pp->cursector, pp->vect.X, pp->yvect, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER, coll);
clipmove(pp->pos, &pp->cursector, pp->vect.X, pp->vect.Y, ((int)actor->spr.clipdist<<2), pp->ceiling_dist, pp->floor_dist, CLIPMASK_PLAYER, coll);
actor->spr.cstat = save_cstat;
PlayerCheckValidMove(pp);
@ -2255,8 +2255,8 @@ void DoTankTreads(PLAYERp pp)
if (Prediction)
return;
vel = FindDistance2D(pp->vect.X>>8, pp->yvect>>8);
dot = DOT_PRODUCT_2D(pp->vect.X, pp->yvect, pp->angle.ang.bcos(), pp->angle.ang.bsin());
vel = FindDistance2D(pp->vect.X>>8, pp->vect.Y>>8);
dot = DOT_PRODUCT_2D(pp->vect.X, pp->vect.Y, pp->angle.ang.bcos(), pp->angle.ang.bsin());
if (dot < 0)
reverse = true;
@ -2367,7 +2367,7 @@ void DriveCrush(PLAYERp pp, int *x, int *y)
return;
// not moving - don't crush
if ((pp->vect.X|pp->yvect) == 0 && pp->input.avel == 0)
if ((pp->vect.X|pp->vect.Y) == 0 && pp->input.avel == 0)
return;
// main sector
@ -2415,10 +2415,10 @@ void DriveCrush(PLAYERp pp, int *x, int *y)
if (actor->spr.pos.Z < sop->crush_z)
continue;
int32_t const vel = FindDistance2D(pp->vect.X>>8, pp->yvect>>8);
int32_t const vel = FindDistance2D(pp->vect.X>>8, pp->vect.Y>>8);
if (vel < 9000)
{
DoActorBeginSlide(actor, getangle(pp->vect.X, pp->yvect), vel/8, 5);
DoActorBeginSlide(actor, getangle(pp->vect.X, pp->vect.Y), vel/8, 5);
if (DoActorSlide(actor))
continue;
}
@ -2537,31 +2537,31 @@ void DoPlayerMoveVehicle(PLAYERp pp)
pp->Flags |= (PF_PLAYER_MOVED);
pp->oxvect = pp->vect.X;
pp->oyvect = pp->yvect;
pp->oyvect = pp->vect.Y;
if (sop->drive_speed)
{
pp->vect.X = MulScale(pp->input.fvel, sop->drive_speed, 6);
pp->yvect = MulScale(pp->input.svel, sop->drive_speed, 6);
pp->vect.Y = MulScale(pp->input.svel, sop->drive_speed, 6);
// does sliding/momentum
pp->vect.X = (pp->vect.X + (pp->oxvect*(sop->drive_slide-1)))/sop->drive_slide;
pp->yvect = (pp->yvect + (pp->oyvect*(sop->drive_slide-1)))/sop->drive_slide;
pp->vect.Y = (pp->vect.Y + (pp->oyvect*(sop->drive_slide-1)))/sop->drive_slide;
}
else
{
pp->vect.X += ((pp->input.fvel*synctics*2)<<6);
pp->yvect += ((pp->input.svel*synctics*2)<<6);
pp->vect.Y += ((pp->input.svel*synctics*2)<<6);
pp->vect.X = MulScale(pp->vect.X, TANK_FRICTION, 16);
pp->yvect = MulScale(pp->yvect, TANK_FRICTION, 16);
pp->vect.Y = MulScale(pp->vect.Y, TANK_FRICTION, 16);
pp->vect.X = (pp->vect.X + (pp->oxvect*1))/2;
pp->yvect = (pp->yvect + (pp->oyvect*1))/2;
pp->vect.Y = (pp->vect.Y + (pp->oyvect*1))/2;
}
if (labs(pp->vect.X) < 12800 && labs(pp->yvect) < 12800)
pp->vect.X = pp->yvect = 0;
if (labs(pp->vect.X) < 12800 && labs(pp->vect.Y) < 12800)
pp->vect.X = pp->vect.Y = 0;
pp->lastcursector = pp->cursector;
z = pp->pos.Z + Z(10);
@ -2613,7 +2613,7 @@ void DoPlayerMoveVehicle(PLAYERp pp)
if (!ret)
{
vel = FindDistance2D(pp->vect.X>>8, pp->yvect>>8);
vel = FindDistance2D(pp->vect.X>>8, pp->vect.Y>>8);
if (vel > 13000)
{
@ -2643,7 +2643,7 @@ void DoPlayerMoveVehicle(PLAYERp pp)
if (vel > 12000)
{
pp->vect.X = pp->yvect = pp->oxvect = pp->oyvect = 0;
pp->vect.X = pp->vect.Y = pp->oxvect = pp->oyvect = 0;
}
}
}
@ -2664,7 +2664,7 @@ void DoPlayerMoveVehicle(PLAYERp pp)
{
vec3_t clippos = { pp->pos.X, pp->pos.Y, z };
Collision coll;
clipmove(clippos, &pp->cursector, pp->vect.X, pp->yvect, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER, actor->user.coll);
clipmove(clippos, &pp->cursector, pp->vect.X, pp->vect.Y, (int)pp->sop->clipdist, Z(4), floor_dist, CLIPMASK_PLAYER, actor->user.coll);
pp->pos.vec2 = clippos.vec2;
}
@ -2678,20 +2678,20 @@ void DoPlayerMoveVehicle(PLAYERp pp)
{
int vel;
vel = FindDistance2D(pp->vect.X>>8, pp->yvect>>8);
vel = FindDistance2D(pp->vect.X>>8, pp->vect.Y>>8);
if (vel > 13000)
{
VehicleMoveHit(actor);
pp->slide_xvect = -pp->vect.X<<1;
pp->slide_yvect = -pp->yvect<<1;
pp->slide_yvect = -pp->vect.Y<<1;
if (!(sop->flags & SOBJ_NO_QUAKE))
SetPlayerQuake(pp);
}
if (vel > 12000)
{
pp->vect.X = pp->yvect = pp->oxvect = pp->oyvect = 0;
pp->vect.X = pp->vect.Y = pp->oxvect = pp->oyvect = 0;
}
}
}
@ -3142,14 +3142,14 @@ void DoPlayerClimb(PLAYERp pp)
return;
pp->vect.X += ((pp->input.fvel*synctics*2)<<6);
pp->yvect += ((pp->input.svel*synctics*2)<<6);
pp->vect.Y += ((pp->input.svel*synctics*2)<<6);
pp->vect.X = MulScale(pp->vect.X, PLAYER_CLIMB_FRICTION, 16);
pp->yvect = MulScale(pp->yvect, PLAYER_CLIMB_FRICTION, 16);
if (labs(pp->vect.X) < 12800 && labs(pp->yvect) < 12800)
pp->vect.X = pp->yvect = 0;
pp->vect.Y = MulScale(pp->vect.Y, PLAYER_CLIMB_FRICTION, 16);
if (labs(pp->vect.X) < 12800 && labs(pp->vect.Y) < 12800)
pp->vect.X = pp->vect.Y = 0;
climbvel = FindDistance2D(pp->vect.X, pp->yvect)>>9;
dot = DOT_PRODUCT_2D(pp->vect.X, pp->yvect, pp->angle.ang.bcos(), pp->angle.ang.bsin());
climbvel = FindDistance2D(pp->vect.X, pp->vect.Y)>>9;
dot = DOT_PRODUCT_2D(pp->vect.X, pp->vect.Y, pp->angle.ang.bcos(), pp->angle.ang.bsin());
if (dot < 0)
climbvel = -climbvel;
@ -3670,7 +3670,7 @@ bool PlayerOnLadder(PLAYERp pp)
neartag(pp->pos, pp->cursector, pp->angle.ang.asbuild(), near, 1024 + 768, NTAG_SEARCH_LO_HI);
dir = DOT_PRODUCT_2D(pp->vect.X, pp->yvect, pp->angle.ang.bcos(), pp->angle.ang.bsin());
dir = DOT_PRODUCT_2D(pp->vect.X, pp->vect.Y, pp->angle.ang.bcos(), pp->angle.ang.bsin());
if (dir < 0)
return false;
@ -5054,7 +5054,7 @@ void PlayerToRemote(PLAYERp pp)
pp->remote.posz = pp->pos.Z;
pp->remote.xvect = pp->vect.X;
pp->remote.yvect = pp->yvect;
pp->remote.yvect = pp->vect.Y;
pp->remote.oxvect = pp->oxvect;
pp->remote.oyvect = pp->oyvect;
pp->remote.slide_xvect = pp->slide_xvect;
@ -5071,7 +5071,7 @@ void RemoteToPlayer(PLAYERp pp)
pp->pos.Z = pp->remote.posz;
pp->vect.X = pp->remote.xvect;
pp->yvect = pp->remote.yvect;
pp->vect.Y = pp->remote.yvect;
pp->oxvect = pp->remote.oxvect;
pp->oyvect = pp->remote.oyvect;
pp->slide_xvect = pp->remote.slide_xvect;
@ -5088,7 +5088,7 @@ void PlayerRemoteReset(PLAYERp pp, sectortype* sect)
pp->pos.Y = rsp->spr.pos.Y;
pp->pos.Z = sect->floorz - PLAYER_HEIGHT;
pp->vect.X = pp->yvect = pp->oxvect = pp->oyvect = pp->slide_xvect = pp->slide_yvect = 0;
pp->vect.X = pp->vect.Y = pp->oxvect = pp->oyvect = pp->slide_xvect = pp->slide_yvect = 0;
UpdatePlayerSprite(pp);
}
@ -7087,7 +7087,7 @@ DEFINE_FIELD_X(SWPlayer, PLAYERstruct, circle_camera_dist)
//DEFINE_FIELD_X(SWPlayer, PLAYERstruct, siz)
DEFINE_FIELD_X(SWPlayer, PLAYERstruct, siang)
//DEFINE_FIELD_X(SWPlayer, PLAYERstruct, xvect)
DEFINE_FIELD_X(SWPlayer, PLAYERstruct, yvect)
//DEFINE_FIELD_X(SWPlayer, PLAYERstruct, yvect)
DEFINE_FIELD_X(SWPlayer, PLAYERstruct, oxvect)
DEFINE_FIELD_X(SWPlayer, PLAYERstruct, oyvect)
DEFINE_FIELD_X(SWPlayer, PLAYERstruct, friction)

View file

@ -466,7 +466,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERstruct& w, P
("siz", w.si.Z)
("siang", w.siang)
("xvect", w.vect.X)
("yvect", w.yvect)
("yvect", w.vect.Y)
("friction", w.friction)
("slide_xvect", w.slide_xvect)
("slide_yvect", w.slide_yvect)
@ -584,7 +584,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, PLAYERstruct& w, P
w.opos.Z = w.pos.X;
w.oz_speed = w.z_speed;
w.oxvect = w.vect.X;
w.oyvect = w.yvect;
w.oyvect = w.vect.Y;
w.obob_z = w.bob_z;
w.input = {};
w.lastinput = {};

View file

@ -16449,7 +16449,7 @@ int InitGrenade(PLAYERp pp)
{
// adjust xvel according to player velocity
actorNew->user.xchange += pp->vect.X>>14;
actorNew->user.ychange += pp->yvect>>14;
actorNew->user.ychange += pp->vect.Y>>14;
}
actorNew->user.Counter2 = true; // Phosphorus Grenade
@ -16560,14 +16560,14 @@ int InitMine(PLAYERp pp)
actorNew->user.xchange = MOVEx(actorNew->spr.xvel, actorNew->spr.ang);
actorNew->user.ychange = MOVEy(actorNew->spr.xvel, actorNew->spr.ang);
dot = DOT_PRODUCT_2D(pp->vect.X, pp->yvect, pp->angle.ang.bcos(), pp->angle.ang.bsin());
dot = DOT_PRODUCT_2D(pp->vect.X, pp->vect.Y, pp->angle.ang.bcos(), pp->angle.ang.bsin());
// don't adjust for strafing
if (labs(dot) > 10000)
{
// adjust xvel according to player velocity
actorNew->user.xchange += pp->vect.X>>13;
actorNew->user.ychange += pp->yvect>>13;
actorNew->user.ychange += pp->vect.Y>>13;
}
return 0;

View file

@ -196,7 +196,6 @@ struct SWPlayer native
native int circle_camera_dist;
native int16 siang;
native int yvect;
native int oxvect, oyvect;
native int friction;
native int slide_xvect, slide_yvect;