From b561ee792192aa9b8adb28971587ef69a897e34c Mon Sep 17 00:00:00 2001 From: MascaraSnake Date: Wed, 13 May 2020 14:40:07 +0200 Subject: [PATCH] Remove diffx/y/z from polywaypoint_t, since they're always 0 anyway --- src/p_polyobj.c | 37 +++++++++++++++---------------------- src/p_polyobj.h | 5 ----- src/p_saveg.c | 6 ------ 3 files changed, 15 insertions(+), 33 deletions(-) diff --git a/src/p_polyobj.c b/src/p_polyobj.c index b1da51462..e2c4ff519 100644 --- a/src/p_polyobj.c +++ b/src/p_polyobj.c @@ -1573,7 +1573,7 @@ void T_PolyObjWaypoint(polywaypoint_t *th) { mobj_t *target = NULL; mobj_t *waypoint = NULL; - fixed_t adjustx, adjusty, adjustz; + fixed_t pox, poy, poz; fixed_t momx, momy, momz, dist; INT32 start; polyobj_t *po = Polyobj_GetForNum(th->polyObjNum); @@ -1602,32 +1602,31 @@ void T_PolyObjWaypoint(polywaypoint_t *th) return; } - // Compensate for position offset - adjustx = po->centerPt.x + th->diffx; - adjusty = po->centerPt.y + th->diffy; - adjustz = po->lines[0]->backsector->floorheight + (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2 + th->diffz; + pox = po->centerPt.x; + poy = po->centerPt.y; + poz = (po->lines[0]->backsector->floorheight + po->lines[0]->backsector->ceilingheight)/2; - dist = P_AproxDistance(P_AproxDistance(target->x - adjustx, target->y - adjusty), target->z - adjustz); + dist = P_AproxDistance(P_AproxDistance(target->x - pox, target->y - poy), target->z - poz); if (dist < 1) dist = 1; - momx = FixedMul(FixedDiv(target->x - adjustx, dist), (th->speed)); - momy = FixedMul(FixedDiv(target->y - adjusty, dist), (th->speed)); - momz = FixedMul(FixedDiv(target->z - adjustz, dist), (th->speed)); + momx = FixedMul(FixedDiv(target->x - pox, dist), th->speed); + momy = FixedMul(FixedDiv(target->y - poy, dist), th->speed); + momz = FixedMul(FixedDiv(target->z - poz, dist), th->speed); // Calculate the distance between the polyobject and the waypoint // 'dist' already equals this. // Will the polyobject be FURTHER away if the momx/momy/momz is added to // its current coordinates, or closer? (shift down to fracunits to avoid approximation errors) - if (dist>>FRACBITS <= P_AproxDistance(P_AproxDistance(target->x - adjustx - momx, target->y - adjusty - momy), target->z - adjustz - momz)>>FRACBITS) + if (dist>>FRACBITS <= P_AproxDistance(P_AproxDistance(target->x - pox - momx, target->y - poy - momy), target->z - poz - momz)>>FRACBITS) { // If further away, set XYZ of polyobject to waypoint location fixed_t amtx, amty, amtz; fixed_t diffz; - amtx = (target->x - th->diffx) - po->centerPt.x; - amty = (target->y - th->diffy) - po->centerPt.y; + amtx = target->x - po->centerPt.x; + amty = target->y - po->centerPt.y; Polyobj_moveXY(po, amtx, amty, true); // TODO: use T_MovePlane amtz = (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2; @@ -1694,14 +1693,14 @@ void T_PolyObjWaypoint(polywaypoint_t *th) // calculate MOMX/MOMY/MOMZ for next waypoint // change slope - dist = P_AproxDistance(P_AproxDistance(target->x - adjustx, target->y - adjusty), target->z - adjustz); + dist = P_AproxDistance(P_AproxDistance(target->x - pox, target->y - poy), target->z - poz); if (dist < 1) dist = 1; - momx = FixedMul(FixedDiv(target->x - adjustx, dist), (th->speed)); - momy = FixedMul(FixedDiv(target->y - adjusty, dist), (th->speed)); - momz = FixedMul(FixedDiv(target->z - adjustz, dist), (th->speed)); + momx = FixedMul(FixedDiv(target->x - pox, dist), th->speed); + momy = FixedMul(FixedDiv(target->y - poy, dist), th->speed); + momz = FixedMul(FixedDiv(target->z - poz, dist), th->speed); } else { @@ -2215,12 +2214,6 @@ boolean EV_DoPolyObjWaypoint(polywaypointdata_t *pwdata) if (!last) last = first; - // Set diffx, diffy, diffz - // Put these at 0 for now...might not be needed after all. - th->diffx = 0;//first->x - po->centerPt.x; - th->diffy = 0;//first->y - po->centerPt.y; - th->diffz = 0;//first->z - (po->lines[0]->backsector->floorheight + (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2); - if (last->x == po->centerPt.x && last->y == po->centerPt.y && last->z == (po->lines[0]->backsector->floorheight + (po->lines[0]->backsector->ceilingheight - po->lines[0]->backsector->floorheight)/2)) diff --git a/src/p_polyobj.h b/src/p_polyobj.h index 68aff4bf1..b2331449f 100644 --- a/src/p_polyobj.h +++ b/src/p_polyobj.h @@ -154,11 +154,6 @@ typedef struct polywaypoint_s UINT8 continuous; // continuously move - used with COMEBACK or WRAP UINT8 stophere; // Will stop after it reaches the next waypoint - // Difference between location of PO and location of waypoint (offset) - fixed_t diffx; - fixed_t diffy; - fixed_t diffz; - mobj_t *target; // next waypoint mobj } polywaypoint_t; diff --git a/src/p_saveg.c b/src/p_saveg.c index 34bd3724b..5e5e82453 100644 --- a/src/p_saveg.c +++ b/src/p_saveg.c @@ -2023,9 +2023,6 @@ static void SavePolywaypointThinker(const thinker_t *th, UINT8 type) WRITEUINT8(save_p, ht->wrap); WRITEUINT8(save_p, ht->continuous); WRITEUINT8(save_p, ht->stophere); - WRITEFIXED(save_p, ht->diffx); - WRITEFIXED(save_p, ht->diffy); - WRITEFIXED(save_p, ht->diffz); WRITEUINT32(save_p, SaveMobjnum(ht->target)); } @@ -3168,9 +3165,6 @@ static inline thinker_t* LoadPolywaypointThinker(actionf_p1 thinker) ht->wrap = READUINT8(save_p); ht->continuous = READUINT8(save_p); ht->stophere = READUINT8(save_p); - ht->diffx = READFIXED(save_p); - ht->diffy = READFIXED(save_p); - ht->diffz = READFIXED(save_p); ht->target = LoadMobj(READUINT32(save_p)); return &ht->thinker; }