- SW: Replace SECTOR_OBJECT xmid with pmid.X calls.

This commit is contained in:
Mitchell Richters 2022-01-01 09:32:40 +11:00
parent 1c0ba71c69
commit 5e2bbb12b5
10 changed files with 56 additions and 56 deletions

View file

@ -1464,7 +1464,7 @@ void drawscreen(PLAYER* pp, double smoothratio)
if (TEST_BOOL1(ractor))
tang = buildang(ractor->spr.ang);
else
tang = bvectangbam(pp->sop_remote->xmid - tx, pp->sop_remote->ymid - ty);
tang = bvectangbam(pp->sop_remote->pmid.X - tx, pp->sop_remote->ymid - ty);
}
if (pp->Flags & (PF_VIEW_FROM_OUTSIDE))

View file

@ -1414,7 +1414,7 @@ struct SECTOR_OBJECT
union
{
struct { int xmid, ymid, zmid; }; // midpoints of the sector object
struct { int BLAHBLAHX, ymid, zmid; }; // midpoints of the sector object
vec3_t pmid;
};
@ -1570,7 +1570,7 @@ enum
MAXSO = INT32_MAX
};
inline bool SO_EMPTY(SECTOR_OBJECT* sop) { return (sop->xmid == INT32_MAX); }
inline bool SO_EMPTY(SECTOR_OBJECT* sop) { return (sop->pmid.X == INT32_MAX); }
extern SECTOR_OBJECT SectorObject[MAX_SECTOR_OBJECTS];

View file

@ -106,7 +106,7 @@ static int &getvalue(so_interp::interp_data& element, bool write)
case soi_floor:
return *sector[index].floorzptr(!write);
case soi_sox:
return SectorObject[index].xmid;
return SectorObject[index].pmid.X;
case soi_soy:
return SectorObject[index].ymid;
case soi_soz:

View file

@ -310,7 +310,7 @@ void MorphTornado(SECTOR_OBJECT* sop)
return;
// place at correct x,y offset from center
x = sop->xmid - sop->morph_xoff;
x = sop->pmid.X - sop->morph_xoff;
y = sop->ymid - sop->morph_yoff;
sx = x;
@ -321,10 +321,10 @@ void MorphTornado(SECTOR_OBJECT* sop)
my = y + MulScale(sop->morph_speed, bsin(sop->morph_ang), 14);
// bound check radius
if (ksqrt(SQ(sop->xmid - mx) + SQ(sop->ymid - my)) > sop->morph_dist_max + sop->scale_dist)
if (ksqrt(SQ(sop->pmid.X - mx) + SQ(sop->ymid - my)) > sop->morph_dist_max + sop->scale_dist)
{
// find angle
sop->morph_ang = NORM_ANGLE(getangle(mx - sop->xmid, my - sop->ymid));
sop->morph_ang = NORM_ANGLE(getangle(mx - sop->pmid.X, my - sop->ymid));
// reverse angle
sop->morph_ang = NORM_ANGLE(sop->morph_ang + 1024);
@ -332,12 +332,12 @@ void MorphTornado(SECTOR_OBJECT* sop)
mx = sx + MulScale(sop->morph_speed << 1, bcos(sop->morph_ang), 14);
my = sy + MulScale(sop->morph_speed << 1, bsin(sop->morph_ang), 14);
sop->morph_xoff = sop->xmid - mx;
sop->morph_xoff = sop->pmid.X - mx;
sop->morph_yoff = sop->ymid - my;
}
// save x,y back as offset info
sop->morph_xoff = sop->xmid - mx;
sop->morph_xoff = sop->pmid.X - mx;
sop->morph_yoff = sop->ymid - my;
if ((RANDOM_P2(1024<<4)>>4) < sop->morph_rand_freq)
@ -390,7 +390,7 @@ void MorphFloor(SECTOR_OBJECT* sop)
return;
// place at correct x,y offset from center
x = sop->xmid - sop->morph_xoff;
x = sop->pmid.X - sop->morph_xoff;
y = sop->ymid - sop->morph_yoff;
// move it from last x,y
@ -398,11 +398,11 @@ void MorphFloor(SECTOR_OBJECT* sop)
my = y + MulScale(sop->morph_speed, bsin(sop->morph_ang), 14);
// save x,y back as offset info
sop->morph_xoff = sop->xmid - mx;
sop->morph_xoff = sop->pmid.X - mx;
sop->morph_yoff = sop->ymid - my;
// bound check radius
if (Distance(sop->xmid, sop->ymid, mx, my) > sop->morph_dist_max)
if (Distance(sop->pmid.X, sop->ymid, mx, my) > sop->morph_dist_max)
{
// go in the other direction
//sop->morph_speed *= -1;
@ -411,7 +411,7 @@ void MorphFloor(SECTOR_OBJECT* sop)
// back it up and save it off
mx = x + MulScale(sop->morph_speed, bcos(sop->morph_ang), 14);
my = y + MulScale(sop->morph_speed, bsin(sop->morph_ang), 14);
sop->morph_xoff = sop->xmid - mx;
sop->morph_xoff = sop->pmid.X - mx;
sop->morph_yoff = sop->ymid - my;
// turn it all the way around and then do a random -512 to 512 from there
@ -514,7 +514,7 @@ void SpikeFloor(SECTOR_OBJECT* sop)
return;
// place at correct x,y offset from center
x = sop->xmid - sop->morph_xoff;
x = sop->pmid.X - sop->morph_xoff;
y = sop->ymid - sop->morph_yoff;
// move it from last x,y

View file

@ -1562,7 +1562,7 @@ void DoPlayerTurnTurret(PLAYER* pp, float avel)
pp->actor->spr.ang = pp->angle.ang.asbuild();
}
OperateSectorObject(pp->sop, pp->angle.ang.asbuild(), pp->sop->xmid, pp->sop->ymid);
OperateSectorObject(pp->sop, pp->angle.ang.asbuild(), pp->sop->pmid.X, pp->sop->ymid);
}
void SlipSlope(PLAYER* pp)
@ -2576,7 +2576,7 @@ void DoPlayerMoveVehicle(PLAYER* pp)
x[count] = wal.pos.X;
y[count] = wal.pos.Y;
ox[count] = sop->xmid - sop->xorig[wallcount];
ox[count] = sop->pmid.X - sop->xorig[wallcount];
oy[count] = sop->ymid - sop->yorig[wallcount];
count++;
@ -4826,7 +4826,7 @@ void FindMainSector(SECTOR_OBJECT* sop)
// find the main sector - only do this once for each sector object
if (sop->op_main_sector == nullptr)
{
int sx = sop->xmid;
int sx = sop->pmid.X;
int sy = sop->ymid;
PlaceSectorObject(sop, MAXSO, MAXSO);
@ -4907,7 +4907,7 @@ void DoPlayerBeginOperate(PLAYER* pp)
sop->controller = pp->actor;
pp->angle.oang = pp->angle.ang = buildang(sop->ang);
pp->pos.X = sop->xmid;
pp->pos.X = sop->pmid.X;
pp->pos.Y = sop->ymid;
updatesector(pp->pos.X, pp->pos.Y, &pp->cursector);
getzsofslopeptr(pp->cursector, pp->pos.X, pp->pos.Y, &cz, &fz);
@ -4992,7 +4992,7 @@ void DoPlayerBeginRemoteOperate(PLAYER* pp, SECTOR_OBJECT* sop)
auto save_sect = pp->cursector;
pp->angle.oang = pp->angle.ang = buildang(sop->ang);
pp->pos.X = sop->xmid;
pp->pos.X = sop->pmid.X;
pp->pos.Y = sop->ymid;
updatesector(pp->pos.X, pp->pos.Y, &pp->cursector);
getzsofslopeptr(pp->cursector, pp->pos.X, pp->pos.Y, &cz, &fz);
@ -5116,7 +5116,7 @@ void DoPlayerStopOperate(PLAYER* pp)
if (TEST_BOOL1(rsp))
pp->angle.ang = pp->angle.oang = buildang(rsp->spr.ang);
else
pp->angle.ang = pp->angle.oang = bvectangbam(pp->sop_remote->xmid - pp->pos.X, pp->sop_remote->ymid - pp->pos.Y);
pp->angle.ang = pp->angle.oang = bvectangbam(pp->sop_remote->pmid.X - pp->pos.X, pp->sop_remote->ymid - pp->pos.Y);
}
if (pp->sop_control)

View file

@ -636,7 +636,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, SECTOR_OBJECT& w,
.Array("yorig", w.yorig, def->yorig, w.num_walls)
("controller", w.controller, def->controller)
("child", w.sp_child, def->sp_child)
("xmid", w.xmid, def->xmid)
("xmid", w.pmid.X, def->pmid.X)
("ymid", w.ymid, def->ymid)
("zmid", w.zmid, def->zmid)
("vel", w.vel, def->vel)

View file

@ -379,7 +379,7 @@ void SectorSetup(void)
SectorObject[ndx].mid_sector = nullptr;
SectorObject[ndx].op_main_sector = nullptr;
SectorObject[ndx].morph_wall_point = nullptr;
SectorObject[ndx].xmid = INT32_MAX;
SectorObject[ndx].pmid.X = INT32_MAX;
}
memset(SineWaveFloor, 0, sizeof(SineWaveFloor));
@ -1071,7 +1071,7 @@ bool TestKillSectorObject(SECTOR_OBJECT* sop)
{
KillMatchingCrackSprites(sop->match_event);
// get new sectnums
CollapseSectorObject(sop, sop->xmid, sop->ymid);
CollapseSectorObject(sop, sop->pmid.X, sop->ymid);
DoSpawnSpotsForKill(sop->match_event);
KillSectorObjectSprites(sop);
return true;
@ -2659,7 +2659,7 @@ void DoSector(void)
}
else
{
DISTANCE(pp->pos.X, pp->pos.Y, sop->xmid, sop->ymid, dist, a, b, c);
DISTANCE(pp->pos.X, pp->pos.Y, sop->pmid.X, sop->ymid, dist, a, b, c);
if (dist < min_dist)
min_dist = dist;
}

View file

@ -601,7 +601,7 @@ void GameInterface::UpdateSounds(void)
if (TEST_BOOL1(rsp))
tang = buildang(rsp->spr.ang);
else
tang = bvectangbam(pp->sop_remote->xmid - pp->pos.X, pp->sop_remote->ymid - pp->pos.Y);
tang = bvectangbam(pp->sop_remote->pmid.X - pp->pos.X, pp->sop_remote->ymid - pp->pos.Y);
}
else tang = pp->angle.ang;

View file

@ -716,7 +716,7 @@ void SectorObjectSetupBounds(SECTOR_OBJECT* sop)
BoundActor = FindBoundSprite(SECT_SO_CENTER);
if (BoundActor)
{
sop->xmid = BoundActor->spr.pos.X;
sop->pmid.X = BoundActor->spr.pos.X;
sop->ymid = BoundActor->spr.pos.Y;
sop->zmid = BoundActor->spr.pos.Z;
KillActor(BoundActor);
@ -855,12 +855,12 @@ void SectorObjectSetupBounds(SECTOR_OBJECT* sop)
short ang2;
sop->clipdist = 0;
sop->clipbox_dist[sop->clipbox_num] = itActor->spr.lotag;
sop->clipbox_xoff[sop->clipbox_num] = sop->xmid - itActor->spr.pos.X;
sop->clipbox_xoff[sop->clipbox_num] = sop->pmid.X - itActor->spr.pos.X;
sop->clipbox_yoff[sop->clipbox_num] = sop->ymid - itActor->spr.pos.Y;
sop->clipbox_vdist[sop->clipbox_num] = ksqrt(SQ(sop->xmid - itActor->spr.pos.X) + SQ(sop->ymid - itActor->spr.pos.Y));
sop->clipbox_vdist[sop->clipbox_num] = ksqrt(SQ(sop->pmid.X - itActor->spr.pos.X) + SQ(sop->ymid - itActor->spr.pos.Y));
ang2 = getangle(itActor->spr.pos.X - sop->xmid, itActor->spr.pos.Y - sop->ymid);
ang2 = getangle(itActor->spr.pos.X - sop->pmid.X, itActor->spr.pos.Y - sop->ymid);
sop->clipbox_ang[sop->clipbox_num] = getincangle(ang2, sop->ang);
sop->clipbox_num++;
@ -881,7 +881,7 @@ void SectorObjectSetupBounds(SECTOR_OBJECT* sop)
}
itActor->user.pos.X = sop->xmid - itActor->spr.pos.X;
itActor->user.pos.X = sop->pmid.X - itActor->spr.pos.X;
itActor->user.pos.Y = sop->ymid - itActor->spr.pos.Y;
itActor->user.pos.Z = sop->mid_sector->floorz - itActor->spr.pos.Z;
@ -1037,14 +1037,14 @@ void SetupSectorObject(sectortype* sectp, short tag)
case TAG_OBJECT_CENTER - 500:
sop->mid_sector = sectp;
SectorMidPoint(sectp, &sop->xmid, &sop->ymid, &sop->zmid);
SectorMidPoint(sectp, &sop->pmid.X, &sop->ymid, &sop->zmid);
sop->dir = 1;
sop->track = sectp->hitag;
// spawn a sprite to make it easier to integrate with sprite routines
auto actorNew = SpawnActor(STAT_SO_SP_CHILD, 0, nullptr, sectp,
sop->xmid, sop->ymid, sop->zmid, 0, 0);
sop->pmid.X, sop->ymid, sop->zmid, 0, 0);
sop->sp_child = actorNew;
actorNew->user.sop_parent = sop;
actorNew->user.Flags2 |= (SPR2_SPRITE_FAKE_BLOCK); // for damage test
@ -1400,7 +1400,7 @@ void PlaceSectorObjectsOnTracks(void)
// move all walls in sectors
for (auto& wal : wallsofsector(sop->sectp[j]))
{
sop->xorig[sop->num_walls] = sop->xmid - wal.pos.X;
sop->xorig[sop->num_walls] = sop->pmid.X - wal.pos.X;
sop->yorig[sop->num_walls] = sop->ymid - wal.pos.Y;
sop->num_walls++;
}
@ -1420,7 +1420,7 @@ void PlaceSectorObjectsOnTracks(void)
{
tpoint = Track[sop->track].TrackPoint;
dist = Distance((tpoint + j)->x, (tpoint + j)->y, sop->xmid, sop->ymid);
dist = Distance((tpoint + j)->x, (tpoint + j)->y, sop->pmid.X, sop->ymid);
if (dist < low_dist)
{
@ -1438,7 +1438,7 @@ void PlaceSectorObjectsOnTracks(void)
NextTrackPoint(sop);
sop->ang = getangle((tpoint + sop->point)->x - sop->xmid, (tpoint + sop->point)->y - sop->ymid);
sop->ang = getangle((tpoint + sop->point)->x - sop->pmid.X, (tpoint + sop->point)->y - sop->ymid);
sop->ang_moving = sop->ang_tgt = sop->ang;
}
@ -1591,18 +1591,18 @@ void MovePoints(SECTOR_OBJECT* sop, short delta_ang, int nx, int ny)
int i, rot_ang;
bool PlayerMove = true;
if (sop->xmid >= MAXSO)
if (sop->pmid.X >= MAXSO)
PlayerMove = false;
// move along little midpoint
sop->xmid += nx;
sop->pmid.X += nx;
sop->ymid += ny;
if (sop->xmid >= MAXSO)
if (sop->pmid.X >= MAXSO)
PlayerMove = false;
// move child sprite along also
sop->sp_child->spr.pos.X = sop->xmid;
sop->sp_child->spr.pos.X = sop->pmid.X;
sop->sp_child->spr.pos.Y = sop->ymid;
@ -1701,7 +1701,7 @@ PlayerPart:
}
}
actor->spr.pos.X = sop->xmid - actor->user.pos.X;
actor->spr.pos.X = sop->pmid.X - actor->user.pos.X;
actor->spr.pos.Y = sop->ymid - actor->user.pos.Y;
// sprites z update
@ -1761,7 +1761,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
if (sop->pmid.X < MAXSO) // special case for operating SO's
SetActorZ(sop->so_actors[i], &actor->spr.pos);
}
@ -1838,14 +1838,14 @@ void RefreshPoints(SECTOR_OBJECT* sop, int nx, int ny, bool dynamic)
{
if (!(wal.extra && (wal.extra & WALLFX_DONT_MOVE)))
{
dx = x = sop->xmid - sop->xorig[wallcount];
dx = x = sop->pmid.X - sop->xorig[wallcount];
dy = y = sop->ymid - sop->yorig[wallcount];
if (dynamic && sop->scale_type)
{
if (!(wal.extra & WALLFX_DONT_SCALE))
{
ang = NORM_ANGLE(getangle(x - sop->xmid, y - sop->ymid));
ang = NORM_ANGLE(getangle(x - sop->pmid.X, y - sop->ymid));
if (sop->scale_type == SO_SCALE_RANDOM_POINT)
{
@ -2249,7 +2249,7 @@ void DoTrack(SECTOR_OBJECT* sop, short locktics, int *nx, int *ny)
// calculate an angle to the target
if (sop->vel)
sop->ang_moving = sop->ang_tgt = getangle(tpoint->x - sop->xmid, tpoint->y - sop->ymid);
sop->ang_moving = sop->ang_tgt = getangle(tpoint->x - sop->pmid.X, tpoint->y - sop->ymid);
// NOTE: Jittery ride - try new value out here
// NOTE: Put a loop around this (locktics) to make it more acuruate
@ -2505,10 +2505,10 @@ void DoTrack(SECTOR_OBJECT* sop, short locktics, int *nx, int *ny)
tpoint = Track[sop->track].TrackPoint + sop->point;
// calculate distance to target poing
sop->target_dist = Distance(sop->xmid, sop->ymid, tpoint->x, tpoint->y);
sop->target_dist = Distance(sop->pmid.X, sop->ymid, tpoint->x, tpoint->y);
// calculate a new angle to the target
sop->ang_moving = sop->ang_tgt = getangle(tpoint->x - sop->xmid, tpoint->y - sop->ymid);
sop->ang_moving = sop->ang_tgt = getangle(tpoint->x - sop->pmid.X, tpoint->y - sop->ymid);
if ((sop->flags & SOBJ_ZDIFF_MODE))
{
@ -2520,7 +2520,7 @@ void DoTrack(SECTOR_OBJECT* sop, short locktics, int *nx, int *ny)
dz = tpoint->z - sop->zdelta;
// find the distance to the target (player)
dist = DIST(dx, dy, sop->xmid, sop->ymid);
dist = DIST(dx, dy, sop->pmid.X, sop->ymid);
// (velocity * difference between the target and the object)
// / distance
@ -2572,7 +2572,7 @@ void DoTrack(SECTOR_OBJECT* sop, short locktics, int *nx, int *ny)
*nx = ((sop->vel) >> 8) * locktics * bcos(sop->ang_moving) >> 14;
*ny = ((sop->vel) >> 8) * locktics * bsin(sop->ang_moving) >> 14;
dist = Distance(sop->xmid, sop->ymid, sop->xmid + *nx, sop->ymid + *ny);
dist = Distance(sop->pmid.X, sop->ymid, sop->pmid.X + *nx, sop->ymid + *ny);
sop->target_dist -= dist;
}
}
@ -2614,7 +2614,7 @@ void OperateSectorObjectForTics(SECTOR_OBJECT* sop, short newang, int newx, int
sop->spin_ang = 0;
sop->ang = newang;
RefreshPoints(sop, newx - sop->xmid, newy - sop->ymid, false);
RefreshPoints(sop, newx - sop->pmid.X, newy - sop->ymid, false);
}
void OperateSectorObject(SECTOR_OBJECT* sop, short newang, int newx, int newy)
@ -2625,7 +2625,7 @@ void OperateSectorObject(SECTOR_OBJECT* sop, short newang, int newx, int newy)
void PlaceSectorObject(SECTOR_OBJECT* sop, int newx, int newy)
{
so_setinterpolationtics(sop, synctics);
RefreshPoints(sop, newx - sop->xmid, newy - sop->ymid, false);
RefreshPoints(sop, newx - sop->pmid.X, newy - sop->ymid, false);
}
void VehicleSetSmoke(SECTOR_OBJECT* sop, ANIMATOR* animator)
@ -2681,7 +2681,7 @@ void KillSectorObject(SECTOR_OBJECT* sop)
sop->spin_ang = 0;
sop->ang = sop->ang_tgt;
RefreshPoints(sop, newx - sop->xmid, newy - sop->ymid, false);
RefreshPoints(sop, newx - sop->pmid.X, newy - sop->ymid, false);
}
@ -2732,7 +2732,7 @@ void DoTornadoObject(SECTOR_OBJECT* sop)
auto cursect = sop->op_main_sector; // for sop->vel
floor_dist = (abs(cursect->ceilingz - cursect->floorz)) >> 2;
pos.X = sop->xmid;
pos.X = sop->pmid.X;
pos.Y = sop->ymid;
pos.Z = floor_dist;
@ -2746,7 +2746,7 @@ void DoTornadoObject(SECTOR_OBJECT* sop)
}
TornadoSpin(sop);
RefreshPoints(sop, pos.X - sop->xmid, pos.Y - sop->ymid, true);
RefreshPoints(sop, pos.X - sop->pmid.X, pos.Y - sop->ymid, true);
}
void DoAutoTurretObject(SECTOR_OBJECT* sop)
@ -2815,7 +2815,7 @@ void DoAutoTurretObject(SECTOR_OBJECT* sop)
}
}
sop->ang_tgt = getangle(actor->user.targetActor->spr.pos.X - sop->xmid, actor->user.targetActor->spr.pos.Y - sop->ymid);
sop->ang_tgt = getangle(actor->user.targetActor->spr.pos.X - sop->pmid.X, actor->user.targetActor->spr.pos.Y - sop->ymid);
// get delta to target angle
delta_ang = getincangle(sop->ang, sop->ang_tgt);
@ -2838,7 +2838,7 @@ void DoAutoTurretObject(SECTOR_OBJECT* sop)
}
}
OperateSectorObjectForTics(sop, sop->ang, sop->xmid, sop->ymid, 2*synctics);
OperateSectorObjectForTics(sop, sop->ang, sop->pmid.X, sop->ymid, 2*synctics);
}
}

View file

@ -10215,7 +10215,7 @@ void AddSpriteToSectorObject(DSWActor* actor, SECTOR_OBJECT* sop)
actor->user.Flags |= (SPR_ON_SO_SECTOR|SPR_SO_ATTACHED);
actor->user.pos.X = sop->xmid - actor->spr.pos.X;
actor->user.pos.X = sop->pmid.X - actor->spr.pos.X;
actor->user.pos.Y = sop->ymid - actor->spr.pos.Y;
actor->user.pos.Z = sop->mid_sector->floorz - actor->spr.pos.Z;