From a65ff3987238aa8e3da63e707ffb8eb7bb750c37 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Jan 2016 22:13:17 +0100 Subject: [PATCH 01/18] - more coordinate refactoring in p_enemy.cpp. --- src/p_effect.cpp | 2 +- src/p_enemy.cpp | 97 +++++++++++++++++++++++------------------------- src/p_lnspec.cpp | 2 +- 3 files changed, 48 insertions(+), 53 deletions(-) diff --git a/src/p_effect.cpp b/src/p_effect.cpp index fa1fd5413..0cd6d5c51 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -429,7 +429,7 @@ void P_RunEffect (AActor *actor, int effects) fixedvec3 pos = actor->Vec3Offset( backx - FixedMul(actor->velx, pathdist), backy - FixedMul(actor->vely, pathdist), - backz - FixedMul(actor->velz, pathdist) + (M_Random() << 10); + backz - FixedMul(actor->velz, pathdist) + (M_Random() << 10)); particle->x = pos.x; particle->y = pos.y; particle->z = pos.z; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 165ac35a1..77999c06e 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -243,9 +243,9 @@ bool AActor::CheckMeleeRange () // [RH] Don't melee things too far above or below actor. if (!(flags5 & MF5_NOVERTICALMELEERANGE)) { - if (pl->Z() > z + height) + if (pl->Z() > Z() + height) return false; - if (pl->Z() + pl->height < z) + if (pl->Z() + pl->height < Z()) return false; } @@ -473,8 +473,8 @@ bool P_Move (AActor *actor) } } - tryx = (origx = actor->x) + (deltax = FixedMul (speed, xspeed[actor->movedir])); - tryy = (origy = actor->y) + (deltay = FixedMul (speed, yspeed[actor->movedir])); + tryx = (origx = actor->X()) + (deltax = FixedMul (speed, xspeed[actor->movedir])); + tryy = (origy = actor->Y()) + (deltay = FixedMul (speed, yspeed[actor->movedir])); // Like P_XYMovement this should do multiple moves if the step size is too large @@ -519,15 +519,14 @@ bool P_Move (AActor *actor) // so make it switchable if (nomonsterinterpolation) { - actor->PrevX = actor->x; - actor->PrevY = actor->y; - actor->PrevZ = actor->z; + actor->PrevX = actor->X(); + actor->PrevY = actor->Y(); + actor->PrevZ = actor->Z(); } if (try_ok && friction > ORIG_FRICTION) { - actor->x = origx; - actor->y = origy; + actor->SetOrigin(origx, origy, actor->Z(), false); movefactor *= FRACUNIT / ORIG_FRICTION_FACTOR / 4; actor->velx += FixedMul (deltax, movefactor); actor->vely += FixedMul (deltay, movefactor); @@ -543,12 +542,12 @@ bool P_Move (AActor *actor) if (actor->Y() <= actor->floorz + actor->MaxStepHeight) { fixed_t savedz = actor->Z(); - actor->z = actor->floorz; + actor->SetZ(actor->floorz); // Make sure that there isn't some other actor between us and // the floor we could get stuck in. The old code did not do this. if (!P_TestMobjZ(actor)) { - actor->z = savedz; + actor->SetZ(savedz); } else { // The monster just hit the floor, so trigger any actions. @@ -568,10 +567,10 @@ bool P_Move (AActor *actor) { // must adjust height fixed_t savedz = actor->Z(); - if (actor->z < tm.floorz) - actor->z += actor->FloatSpeed; + if (actor->Z() < tm.floorz) + actor->SetZ(actor->Z() + actor->FloatSpeed); else - actor->z -= actor->FloatSpeed; + actor->SetZ(actor->Z() - actor->FloatSpeed); // [RH] Check to make sure there's nothing in the way of the float @@ -580,7 +579,7 @@ bool P_Move (AActor *actor) actor->flags |= MF_INFLOAT; return true; } - actor->z = savedz; + actor->SetZ(savedz); } if (!spechit.Size ()) @@ -812,28 +811,25 @@ void P_DoNewChaseDir (AActor *actor, fixed_t deltax, fixed_t deltay) void P_NewChaseDir(AActor * actor) { - fixed_t deltax; - fixed_t deltay; + fixedvec2 delta; actor->strafecount = 0; if ((actor->flags5&MF5_CHASEGOAL || actor->goal == actor->target) && actor->goal!=NULL) { - deltax = actor->goal->x - actor->x; - deltay = actor->goal->y - actor->y; + delta = actor->Vec2To(actor->goal); } else if (actor->target != NULL) { - deltax = actor->target->x - actor->x; - deltay = actor->target->y - actor->y; + delta = actor->Vec2To(actor->target); if (!(actor->flags6 & MF6_NOFEAR)) { if ((actor->target->player != NULL && (actor->target->player->cheats & CF_FRIGHTENING)) || (actor->flags4 & MF4_FRIGHTENED)) { - deltax = -deltax; - deltay = -deltay; + delta.x = -delta.x; + delta.y = -delta.y; } } } @@ -877,7 +873,7 @@ void P_NewChaseDir(AActor * actor) { angle = R_PointToAngle2(0,0,line->dx,line->dy); // front side dropoff } - else if (front == actor->z && back < actor->z - actor->MaxDropOffHeight) + else if (front == actor->Z() && back < actor->Z() - actor->MaxDropOffHeight) { angle = R_PointToAngle2(line->dx,line->dy,0,0); // back side dropoff } @@ -946,12 +942,12 @@ void P_NewChaseDir(AActor * actor) if (ismeleeattacker) { actor->strafecount = pr_enemystrafe() & 15; - deltax = -deltax, deltay = -deltay; + delta.x = -delta.x, delta.y = -delta.y; } } } - P_DoNewChaseDir(actor, deltax, deltay); + P_DoNewChaseDir(actor, delta.x, delta.y); // If strafing, set movecount to strafecount so that old Doom // logic still works the same, except in the strafing part @@ -983,7 +979,7 @@ void P_RandomChaseDir (AActor *actor) if (actor->flags & MF_FRIENDLY) { AActor *player; - fixed_t deltax, deltay; + fixedvec2 delta; dirtype_t d[3]; if (actor->FriendPlayer != 0) @@ -1005,19 +1001,18 @@ void P_RandomChaseDir (AActor *actor) { if (pr_newchasedir() & 1 || !P_CheckSight (actor, player)) { - deltax = player->x - actor->x; - deltay = player->y - actor->y; + delta = actor->Vec2To(player); - if (deltax>128*FRACUNIT) + if (delta.x>128*FRACUNIT) d[1]= DI_EAST; - else if (deltax<-128*FRACUNIT) + else if (delta.x<-128*FRACUNIT) d[1]= DI_WEST; else d[1]=DI_NODIR; - if (deltay<-128*FRACUNIT) + if (delta.y<-128*FRACUNIT) d[2]= DI_SOUTH; - else if (deltay>128*FRACUNIT) + else if (delta.y>128*FRACUNIT) d[2]= DI_NORTH; else d[2]=DI_NODIR; @@ -1025,13 +1020,13 @@ void P_RandomChaseDir (AActor *actor) // try direct route if (d[1] != DI_NODIR && d[2] != DI_NODIR) { - actor->movedir = diags[((deltay<0)<<1) + (deltax>0)]; + actor->movedir = diags[((delta.y<0)<<1) + (delta.x>0)]; if (actor->movedir != turnaround && P_TryWalk(actor)) return; } // try other directions - if (pr_newchasedir() > 200 || abs(deltay) > abs(deltax)) + if (pr_newchasedir() > 200 || abs(delta.y) > abs(delta.x)) { swapvalues (d[1], d[2]); } @@ -2474,8 +2469,8 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi if ((!fastchase || !actor->FastChaseStrafeCount) && !dontmove) { // CANTLEAVEFLOORPIC handling was completely missing in the non-serpent functions. - fixed_t oldX = actor->x; - fixed_t oldY = actor->y; + fixed_t oldX = actor->X(); + fixed_t oldY = actor->Y(); FTextureID oldFloor = actor->floorpic; // chase towards player @@ -2526,11 +2521,12 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) if (self->movedir != DI_NODIR) { const fixed_t absSpeed = abs (self->Speed); - fixed_t viletryx = self->x + FixedMul (absSpeed, xspeed[self->movedir]); - fixed_t viletryy = self->y + FixedMul (absSpeed, yspeed[self->movedir]); + fixedvec2 viletry = self->Vec2Offset( + FixedMul (absSpeed, xspeed[self->movedir]), + FixedMul (absSpeed, yspeed[self->movedir]), true); AActor *corpsehit; - FBlockThingsIterator it(FBoundingBox(viletryx, viletryy, 32*FRACUNIT)); + FBlockThingsIterator it(FBoundingBox(viletry.x, viletry.y, 32*FRACUNIT)); while ((corpsehit = it.Next())) { FState *raisestate = corpsehit->GetRaiseState(); @@ -2539,8 +2535,8 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) // use the current actor's radius instead of the Arch Vile's default. fixed_t maxdist = corpsehit->GetDefault()->radius + self->radius; - if (abs(corpsehit->x - viletryx) > maxdist || - abs(corpsehit->y - viletryy) > maxdist) + if (abs(corpsehit->X() - viletry.x) > maxdist || + abs(corpsehit->Y() - viletry.y) > maxdist) continue; // not actually touching // Let's check if there are floors in between the archvile and its target sector_t *vilesec = self->Sector; @@ -2783,12 +2779,11 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a { // [DH] Don't need to do proper fixed->double conversion, since the // result is only used in a ratio. - double dist_x = other->x - self->x; - double dist_y = other->y - self->y; + fixedvec2 dist = self->Vec2To(other); // Positioning ala missile spawning, 32 units above foot level - fixed_t source_z = self->z + 32*FRACUNIT + self->GetBobOffset(); - fixed_t target_z = other->z + 32*FRACUNIT + other->GetBobOffset(); + fixed_t source_z = self->Z() + 32*FRACUNIT + self->GetBobOffset(); + fixed_t target_z = other->Z() + 32*FRACUNIT + other->GetBobOffset(); // If the target z is above the target's head, reposition to the middle of // its body. @@ -2809,8 +2804,8 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a target_z += pitch_offset; double dist_z = target_z - source_z; - double dist = sqrt(dist_x*dist_x + dist_y*dist_y + dist_z*dist_z); - int other_pitch = (int)rad2bam(asin(dist_z / dist)); + double ddist = sqrt(dist.x*dist.x + dist.y*dist.y + dist_z*dist_z); + int other_pitch = (int)rad2bam(asin(dist_z / ddist)); if (max_pitch != 0) { @@ -2922,9 +2917,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail) if (linetarget == NULL) { // We probably won't hit the target, but aim at it anyway so we don't look stupid. - TVector2 xydiff(self->target->x - self->x, self->target->y - self->y); - double zdiff = (self->target->z + (self->target->height>>1)) - - (self->z + (self->height>>1) - self->floorclip); + TVector2 xydiff = self->Vec2To(self->target); + double zdiff = (self->target->Z() + (self->target->height>>1)) - + (self->Z() + (self->height>>1) - self->floorclip); self->pitch = int(atan2(zdiff, xydiff.Length()) * ANGLE_180 / -M_PI); } diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 22e901c73..2592c930f 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -3107,7 +3107,7 @@ FUNC(LS_GlassBreak) { glass = Spawn("GlassJunk", x, y, ONFLOORZ, ALLOW_REPLACE); - glass->z += 24 * FRACUNIT; + glass->SetZ(glass->z + 24 * FRACUNIT); glass->SetState (glass->SpawnState + (pr_glass() % glass->health)); an = pr_glass() << (32-8); glass->angle = an; From b735138332bbbb09db4a81ff243bd550362e0b9c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Jan 2016 22:56:16 +0100 Subject: [PATCH 02/18] - forgot the changes to actor.h. --- src/actor.h | 51 +++++++++++++++++++++++++++------------------------ 1 file changed, 27 insertions(+), 24 deletions(-) diff --git a/src/actor.h b/src/actor.h index 22bea9e08..f58d48f9a 100644 --- a/src/actor.h +++ b/src/actor.h @@ -847,7 +847,7 @@ public: bool intersects(AActor *other) const { fixed_t blockdist = radius + other->radius; - return ( abs(x - other->x) < blockdist && abs(y - other->y) < blockdist); + return ( abs(pos.x - other->pos.x) < blockdist && abs(pos.y - other->pos.y) < blockdist); } PalEntry GetBloodColor() const @@ -888,84 +888,84 @@ public: // to distinguish between portal-aware and portal-unaware distance calculation. fixed_t AproxDistance(AActor *other, bool absolute = false) { - return P_AproxDistance(x - other->x, y - other->y); + return P_AproxDistance(pos.x - other->pos.x, pos.y - other->pos.y); } // same with 'ref' here. fixed_t AproxDistance(fixed_t otherx, fixed_t othery, AActor *ref = NULL) { - return P_AproxDistance(x - otherx, y - othery); + return P_AproxDistance(pos.x - otherx, pos.y - othery); } fixed_t AproxDistance(AActor *other, fixed_t xadd, fixed_t yadd, bool absolute = false) { - return P_AproxDistance(x - other->x + xadd, y - other->y + yadd); + return P_AproxDistance(pos.x - other->pos.x + xadd, pos.y - other->pos.y + yadd); } fixed_t AproxDistance3D(AActor *other, bool absolute = false) { - return P_AproxDistance(AproxDistance(other), z - other->z); + return P_AproxDistance(AproxDistance(other), pos.z - other->pos.z); } // more precise, but slower version, being used in a few places fixed_t Distance2D(AActor *other, bool absolute = false) { - return xs_RoundToInt(FVector2(x - other->x, y - other->y).Length()); + return xs_RoundToInt(FVector2(pos.x - other->pos.x, pos.y - other->pos.y).Length()); } // a full 3D version of the above fixed_t Distance3D(AActor *other, bool absolute = false) { - return xs_RoundToInt(FVector3(x - other->x, y - other->y, z - other->z).Length()); + return xs_RoundToInt(FVector3(pos.x - other->pos.x, pos.y - other->pos.y, pos.z - other->pos.z).Length()); } angle_t AngleTo(AActor *other, bool absolute = false) const { - return R_PointToAngle2(x, y, other->x, other->y); + return R_PointToAngle2(pos.x, pos.y, other->pos.x, other->pos.y); } angle_t AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const { - return R_PointToAngle2(x, y, other->x + oxofs, other->y + oyofs); + return R_PointToAngle2(pos.x, pos.y, other->pos.x + oxofs, other->pos.y + oyofs); } fixed_t AngleTo(fixed_t otherx, fixed_t othery, AActor *ref = NULL) { - return R_PointToAngle2(x, y, otherx, othery); + return R_PointToAngle2(pos.x, pos.y, otherx, othery); } fixed_t AngleXYTo(fixed_t myx, fixed_t myy, AActor *other, bool absolute = false) { - return R_PointToAngle2(myx, myy, other->x, other->y); + return R_PointToAngle2(myx, myy, other->pos.x, other->pos.y); } fixedvec2 Vec2To(AActor *other) const { - fixedvec2 ret = { other->x - x, other->y - y }; + fixedvec2 ret = { other->pos.x - pos.x, other->pos.y - pos.y }; return ret; } fixedvec3 Vec3To(AActor *other) const { - fixedvec3 ret = { other->x - x, other->y - y, other->z - z }; + fixedvec3 ret = { other->pos.x - pos.x, other->pos.y - pos.y, other->pos.z - pos.z }; return ret; } - fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy) const + fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false) const { - fixedvec2 ret = { x + dx, y + dy }; + fixedvec2 ret = { pos.x + dx, pos.y + dy }; return ret; } - fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz) const + fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) const { - fixedvec3 ret = { x + dx, y + dy, z + dz }; + fixedvec3 ret = { pos.x + dx, pos.y + dy, pos.z + dz }; return ret; } void Move(fixed_t dx, fixed_t dy, fixed_t dz) { - SetOrigin(x + dx, y + dy, z + dz, true); + SetOrigin(pos.x + dx, pos.y + dy, pos.z + dz, true); } inline void SetFriendPlayer(player_t *player); @@ -987,7 +987,10 @@ public: // info for drawing // NOTE: The first member variable *must* be x. - fixed_t x,y,z; +private: + fixedvec3 pos; +public: + //fixed_t x,y,z; AActor *snext, **sprev; // links in sector (if needed) angle_t angle; WORD sprite; // used to find patch_t and flip value @@ -1185,7 +1188,7 @@ public: void LinkToWorld (sector_t *sector); void UnlinkFromWorld (); void AdjustFloorClip (); - void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving = false); + void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving); bool InStateSequence(FState * newstate, FState * basestate); int GetTics(FState * newstate); bool SetState (FState *newstate, bool nofunction=false); @@ -1217,19 +1220,19 @@ public: fixed_t X() const { - return x; + return pos.x; } fixed_t Y() const { - return y; + return pos.y; } fixed_t Z() const { - return z; + return pos.z; } void SetZ(fixed_t newz) { - z = newz; + pos.z = newz; } }; From 43314f0c0df262f3063455b24a500b67f231f68b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jan 2016 00:59:16 +0100 Subject: [PATCH 03/18] - started refactoring p_map.cpp - added AActor::Top function to replace the frequent occurences of actor->z + actor->height. --- src/actor.h | 53 +++++++++++++++++++++++----------------------- src/d_net.cpp | 2 +- src/p_3dfloors.cpp | 2 +- src/p_acs.cpp | 2 +- src/p_enemy.cpp | 10 ++++----- src/p_lnspec.cpp | 2 +- src/p_map.cpp | 30 +++++++++++++------------- 7 files changed, 51 insertions(+), 50 deletions(-) diff --git a/src/actor.h b/src/actor.h index f58d48f9a..f17af7bc2 100644 --- a/src/actor.h +++ b/src/actor.h @@ -847,7 +847,7 @@ public: bool intersects(AActor *other) const { fixed_t blockdist = radius + other->radius; - return ( abs(pos.x - other->pos.x) < blockdist && abs(pos.y - other->pos.y) < blockdist); + return ( abs(x - other->x) < blockdist && abs(y - other->y) < blockdist); } PalEntry GetBloodColor() const @@ -888,84 +888,84 @@ public: // to distinguish between portal-aware and portal-unaware distance calculation. fixed_t AproxDistance(AActor *other, bool absolute = false) { - return P_AproxDistance(pos.x - other->pos.x, pos.y - other->pos.y); + return P_AproxDistance(x - other->x, y - other->y); } // same with 'ref' here. fixed_t AproxDistance(fixed_t otherx, fixed_t othery, AActor *ref = NULL) { - return P_AproxDistance(pos.x - otherx, pos.y - othery); + return P_AproxDistance(x - otherx, y - othery); } fixed_t AproxDistance(AActor *other, fixed_t xadd, fixed_t yadd, bool absolute = false) { - return P_AproxDistance(pos.x - other->pos.x + xadd, pos.y - other->pos.y + yadd); + return P_AproxDistance(x - other->x + xadd, y - other->y + yadd); } fixed_t AproxDistance3D(AActor *other, bool absolute = false) { - return P_AproxDistance(AproxDistance(other), pos.z - other->pos.z); + return P_AproxDistance(AproxDistance(other), z - other->z); } // more precise, but slower version, being used in a few places fixed_t Distance2D(AActor *other, bool absolute = false) { - return xs_RoundToInt(FVector2(pos.x - other->pos.x, pos.y - other->pos.y).Length()); + return xs_RoundToInt(FVector2(x - other->x, y - other->y).Length()); } // a full 3D version of the above fixed_t Distance3D(AActor *other, bool absolute = false) { - return xs_RoundToInt(FVector3(pos.x - other->pos.x, pos.y - other->pos.y, pos.z - other->pos.z).Length()); + return xs_RoundToInt(FVector3(x - other->x, y - other->y, z - other->z).Length()); } angle_t AngleTo(AActor *other, bool absolute = false) const { - return R_PointToAngle2(pos.x, pos.y, other->pos.x, other->pos.y); + return R_PointToAngle2(x, y, other->x, other->y); } angle_t AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const { - return R_PointToAngle2(pos.x, pos.y, other->pos.x + oxofs, other->pos.y + oyofs); + return R_PointToAngle2(x, y, other->x + oxofs, other->y + oyofs); } fixed_t AngleTo(fixed_t otherx, fixed_t othery, AActor *ref = NULL) { - return R_PointToAngle2(pos.x, pos.y, otherx, othery); + return R_PointToAngle2(x, y, otherx, othery); } fixed_t AngleXYTo(fixed_t myx, fixed_t myy, AActor *other, bool absolute = false) { - return R_PointToAngle2(myx, myy, other->pos.x, other->pos.y); + return R_PointToAngle2(myx, myy, other->x, other->y); } fixedvec2 Vec2To(AActor *other) const { - fixedvec2 ret = { other->pos.x - pos.x, other->pos.y - pos.y }; + fixedvec2 ret = { other->x - x, other->y - y }; return ret; } fixedvec3 Vec3To(AActor *other) const { - fixedvec3 ret = { other->pos.x - pos.x, other->pos.y - pos.y, other->pos.z - pos.z }; + fixedvec3 ret = { other->x - x, other->y - y, other->z - z }; return ret; } fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false) const { - fixedvec2 ret = { pos.x + dx, pos.y + dy }; + fixedvec2 ret = { x + dx, y + dy }; return ret; } fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) const { - fixedvec3 ret = { pos.x + dx, pos.y + dy, pos.z + dz }; + fixedvec3 ret = { x + dx, y + dy, z + dz }; return ret; } void Move(fixed_t dx, fixed_t dy, fixed_t dz) { - SetOrigin(pos.x + dx, pos.y + dy, pos.z + dz, true); + SetOrigin(x + dx, y + dy, z + dz, true); } inline void SetFriendPlayer(player_t *player); @@ -987,10 +987,7 @@ public: // info for drawing // NOTE: The first member variable *must* be x. -private: - fixedvec3 pos; -public: - //fixed_t x,y,z; + fixed_t x,y,z; AActor *snext, **sprev; // links in sector (if needed) angle_t angle; WORD sprite; // used to find patch_t and flip value @@ -1188,7 +1185,7 @@ public: void LinkToWorld (sector_t *sector); void UnlinkFromWorld (); void AdjustFloorClip (); - void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving); + void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving = false); bool InStateSequence(FState * newstate, FState * basestate); int GetTics(FState * newstate); bool SetState (FState *newstate, bool nofunction=false); @@ -1220,19 +1217,23 @@ public: fixed_t X() const { - return pos.x; + return x; } fixed_t Y() const { - return pos.y; + return y; } fixed_t Z() const { - return pos.z; + return z; } - void SetZ(fixed_t newz) + fixed_t Top() const { - pos.z = newz; + return z + height; + } + void SetZ(fixed_t newz, bool moving = true) + { + z = newz; } }; diff --git a/src/d_net.cpp b/src/d_net.cpp index 95061d0e1..29303fa04 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2376,7 +2376,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) s = ReadString (stream); if (Trace (players[player].mo->X(), players[player].mo->Y(), - players[player].mo->Z() + players[player].mo->height - (players[player].mo->height>>2), + players[player].mo->Top() - (players[player].mo->height>>2), players[player].mo->Sector, vx, vy, vz, 172*FRACUNIT, 0, ML_BLOCKEVERYTHING, players[player].mo, trace, TRACE_NoSky)) diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index abc4d5c59..e294dec69 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -337,7 +337,7 @@ void P_PlayerOnSpecial3DFloor(player_t* player) { //Water and DEATH FOG!!! heh if (player->mo->Z() > rover->top.plane->ZatPoint(player->mo) || - (player->mo->Z() + player->mo->height) < rover->bottom.plane->ZatPoint(player->mo)) + player->mo->Top() < rover->bottom.plane->ZatPoint(player->mo)) continue; } diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 6ce1cfd55..81420b73a 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -4158,7 +4158,7 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b } else { - fixed_t z = actor->Z() + actor->height; + fixed_t z = actor->Top(); // Looking through planes from bottom to top for (i = numff-1; i >= 0; --i) { diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 77999c06e..15861f79e 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -243,9 +243,9 @@ bool AActor::CheckMeleeRange () // [RH] Don't melee things too far above or below actor. if (!(flags5 & MF5_NOVERTICALMELEERANGE)) { - if (pl->Z() > Z() + height) + if (pl->Z() > Top()) return false; - if (pl->Z() + pl->height < Z()) + if (pl->Top() < Z()) return false; } @@ -280,11 +280,11 @@ bool P_CheckMeleeRange2 (AActor *actor) { return false; } - if (mo->Z() > actor->Z()+actor->height) + if (mo->Z() > actor->Top()) { // Target is higher than the attacker return false; } - else if (actor->Z() > mo->Z()+mo->height) + else if (actor->Z() > mo->Top()) { // Attacker is higher return false; } @@ -2787,7 +2787,7 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a // If the target z is above the target's head, reposition to the middle of // its body. - if (target_z >= other->Z() + other->height) + if (target_z >= other->Top()) { target_z = other->Z() + (other->height / 2); } diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 2592c930f..06e2f5f21 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -3107,7 +3107,7 @@ FUNC(LS_GlassBreak) { glass = Spawn("GlassJunk", x, y, ONFLOORZ, ALLOW_REPLACE); - glass->SetZ(glass->z + 24 * FRACUNIT); + glass->SetZ(glass->Z() + 24 * FRACUNIT); glass->SetState (glass->SpawnState + (pr_glass() % glass->health)); an = pr_glass() << (32-8); glass->angle = an; diff --git a/src/p_map.cpp b/src/p_map.cpp index 78a17df10..69f8b6c5b 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -190,7 +190,7 @@ static bool PIT_FindFloorCeiling(line_t *ld, const FBoundingBox &box, FCheckPosi } else if (r >= (1 << 24)) { - P_LineOpening(open, tmf.thing, ld, sx = ld->v2->x, sy = ld->v2->y, tmf.thing->x, tmf.thing->y, flags); + P_LineOpening(open, tmf.thing, ld, sx = ld->v2->x, sy = ld->v2->y, tmf.thing->X(), tmf.thing->Y(), flags); } else { @@ -288,9 +288,9 @@ void P_FindFloorCeiling(AActor *actor, int flags) FCheckPosition tmf; tmf.thing = actor; - tmf.x = actor->x; - tmf.y = actor->y; - tmf.z = actor->z; + tmf.x = actor->X(); + tmf.y = actor->Y(); + tmf.z = actor->Z(); if (flags & FFCF_ONLYSPAWNPOS) { @@ -336,7 +336,7 @@ void P_FindFloorCeiling(AActor *actor, int flags) if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; - if (!(flags & FFCF_ONLYSPAWNPOS) || (tmf.abovemidtex && (tmf.floorz <= actor->z))) + if (!(flags & FFCF_ONLYSPAWNPOS) || (tmf.abovemidtex && (tmf.floorz <= actor->Z()))) { actor->floorz = tmf.floorz; actor->dropoffz = tmf.dropoffz; @@ -404,13 +404,13 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra line_t *ld; // P_LineOpening requires the thing's z to be the destination z in order to work. - fixed_t savedz = thing->z; - thing->z = z; + fixed_t savedz = thing->Z(); + thing->SetZ(z); while ((ld = it.Next())) { PIT_FindFloorCeiling(ld, box, tmf, 0); } - thing->z = savedz; + thing->SetZ(savedz); if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; @@ -427,7 +427,7 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra continue; fixed_t blockdist = th->radius + tmf.thing->radius; - if (abs(th->x - tmf.x) >= blockdist || abs(th->y - tmf.y) >= blockdist) + if (abs(th->X() - tmf.x) >= blockdist || abs(th->Y() - tmf.y) >= blockdist) continue; // [RH] Z-Check @@ -437,8 +437,8 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra { if (!(th->flags3 & thing->flags3 & MF3_DONTOVERLAP)) { - if (z > th->z + th->height || // overhead - z + thing->height < th->z) // underneath + if (z > th->Top() || // overhead + z + thing->height < th->Z()) // underneath continue; } } @@ -459,7 +459,7 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra if (modifyactor) { // the move is ok, so link the thing into its new position - thing->SetOrigin(x, y, z); + thing->SetOrigin(x, y, z, false); thing->floorz = tmf.floorz; thing->ceilingz = tmf.ceilingz; thing->floorsector = tmf.floorsector; @@ -507,7 +507,7 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra void P_PlayerStartStomp(AActor *actor) { AActor *th; - FBlockThingsIterator it(FBoundingBox(actor->x, actor->y, actor->radius)); + FBlockThingsIterator it(FBoundingBox(actor->X(), actor->Y(), actor->radius)); while ((th = it.Next())) { @@ -525,9 +525,9 @@ void P_PlayerStartStomp(AActor *actor) if (th->player == NULL && !(th->flags3 & MF3_ISMONSTER)) continue; - if (actor->z > th->z + th->height) + if (actor->Z() > th->Top()) continue; // overhead - if (actor->z + actor->height < th->z) + if (actor->Top() < th->Z()) continue; // underneath P_DamageMobj(th, actor, actor, TELEFRAG_DAMAGE, NAME_Telefrag); From e8ee8c5c976c3d9cb964f959d0c697af9575ae08 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jan 2016 01:21:20 +0100 Subject: [PATCH 04/18] - fixed: secspecial_t was left uninitialized, causing its damage type being an invalid name. --- src/r_defs.h | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/r_defs.h b/src/r_defs.h index 6f69a26a0..dd8496e4d 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -455,6 +455,11 @@ struct secspecial_t short leakydamage; // chance of leaking through radiation suit int Flags; + secspecial_t() + { + Clear(); + } + void Clear() { memset(this, 0, sizeof(*this)); From b63eb391f763acfa65931a58472c081f6bec2c56 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jan 2016 12:37:39 +0100 Subject: [PATCH 05/18] - refactored two mire files. - fixed: FraggleScript's SetObjPosition function did not properly set the moved actor's properties. Better use SetOrigin for changing the position. --- src/actor.h | 20 +++++++++++++++ src/fragglescript/t_func.cpp | 50 +++++++++++++++++------------------- src/g_doom/a_archvile.cpp | 19 +++++--------- src/p_enemy.cpp | 3 +-- 4 files changed, 50 insertions(+), 42 deletions(-) diff --git a/src/actor.h b/src/actor.h index f17af7bc2..4deb349a7 100644 --- a/src/actor.h +++ b/src/actor.h @@ -957,17 +957,37 @@ public: return ret; } + + fixedvec2 Vec2Angle(fixed_t length, angle_t angle, bool absolute = false) const + { + fixedvec2 ret = { x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), + y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) }; + return ret; + } + fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) const { fixedvec3 ret = { x + dx, y + dy, z + dz }; return ret; } + fixedvec3 Vec3Angle(fixed_t length, angle_t angle, fixed_t dz, bool absolute = false) const + { + fixedvec3 ret = { x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), + y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), z + dz }; + return ret; + } + void Move(fixed_t dx, fixed_t dy, fixed_t dz) { SetOrigin(x + dx, y + dy, z + dz, true); } + void SetOrigin(const fixedvec3 & npos, bool moving) + { + SetOrigin(npos.x, npos.y, npos.z, moving); + } + inline void SetFriendPlayer(player_t *player); bool IsVisibleToPlayer() const; diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index ceabc9ce5..2381ad381 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -982,7 +982,7 @@ void FParser::SF_ObjX(void) } t_return.type = svt_fixed; // haleyjd: SoM's fixed-point fix - t_return.value.f = mo ? mo->x : 0; // null ptr check + t_return.value.f = mo ? mo->X() : 0; // null ptr check } //========================================================================== @@ -1005,7 +1005,7 @@ void FParser::SF_ObjY(void) } t_return.type = svt_fixed; // haleyjd - t_return.value.f = mo ? mo->y : 0; // null ptr check + t_return.value.f = mo ? mo->Y() : 0; // null ptr check } //========================================================================== @@ -1028,7 +1028,7 @@ void FParser::SF_ObjZ(void) } t_return.type = svt_fixed; // haleyjd - t_return.value.f = mo ? mo->z : 0; // null ptr check + t_return.value.f = mo ? mo->Z() : 0; // null ptr check } @@ -1466,8 +1466,8 @@ void FParser::SF_SetCamera(void) angle = t_argc < 2 ? newcamera->angle : (fixed_t)FixedToAngle(fixedvalue(t_argv[1])); newcamera->special1=newcamera->angle; - newcamera->special2=newcamera->z; - newcamera->z = t_argc < 3 ? (newcamera->z + (41 << FRACBITS)) : (intvalue(t_argv[2]) << FRACBITS); + newcamera->special2=newcamera->Z(); + newcamera->SetZ(t_argc < 3 ? (newcamera->Z() + (41 << FRACBITS)) : (intvalue(t_argv[2]) << FRACBITS)); newcamera->angle = angle; if(t_argc < 4) newcamera->pitch = 0; else @@ -1498,7 +1498,7 @@ void FParser::SF_ClearCamera(void) { player->camera=player->mo; cam->angle=cam->special1; - cam->z=cam->special2; + cam->SetZ(cam->special2); } } @@ -3065,7 +3065,7 @@ void FParser::SF_SetWeapon() void FParser::SF_MoveCamera(void) { fixed_t x, y, z; - fixed_t xdist, ydist, zdist, xydist, movespeed; + fixed_t zdist, xydist, movespeed; fixed_t xstep, ystep, zstep, targetheight; angle_t anglespeed, anglestep, angledist, targetangle, mobjangle, bigangle, smallangle; @@ -3097,9 +3097,8 @@ void FParser::SF_MoveCamera(void) anglespeed = (angle_t)FixedToAngle(fixedvalue(t_argv[5])); // figure out how big one step will be - xdist = target->x - cam->x; - ydist = target->y - cam->y; - zdist = targetheight - cam->z; + fixedvec2 dist = cam->Vec2To(target); + zdist = targetheight - cam->Z(); // Angle checking... // 90 @@ -3170,19 +3169,19 @@ void FParser::SF_MoveCamera(void) else anglestep = anglespeed; - if(abs(xstep) >= (abs(xdist) - 1)) - x = target->x; + if(abs(xstep) >= (abs(dist.x) - 1)) + x = cam->X() + dist.x; else { - x = cam->x + xstep; + x = cam->X() + xstep; moved = 1; } - if(abs(ystep) >= (abs(ydist) - 1)) - y = target->y; + if(abs(ystep) >= (abs(dist.y) - 1)) + y = cam->Y() + dist.y; else { - y = cam->y + ystep; + y = cam->Y() + ystep; moved = 1; } @@ -3190,7 +3189,7 @@ void FParser::SF_MoveCamera(void) z = targetheight; else { - z = cam->z + zstep; + z = cam->Z() + zstep; moved = 1; } @@ -3212,12 +3211,12 @@ void FParser::SF_MoveCamera(void) cam->radius=8; cam->height=8; - if ((x != cam->x || y != cam->y) && !P_TryMove(cam, x, y, true)) + if ((x != cam->X() || y != cam->Y()) && !P_TryMove(cam, x, y, true)) { Printf("Illegal camera move to (%f, %f)\n", x/65536.f, y/65536.f); return; } - cam->z = z; + cam->SetZ(z); t_return.type = svt_int; t_return.value.i = moved; @@ -3410,13 +3409,10 @@ void FParser::SF_SetObjPosition() if (!mobj) return; - mobj->UnlinkFromWorld(); - - mobj->x = intvalue(t_argv[1]) << FRACBITS; - if(t_argc >= 3) mobj->y = intvalue(t_argv[2]) << FRACBITS; - if(t_argc == 4) mobj->z = intvalue(t_argv[3]) << FRACBITS; - - mobj->LinkToWorld(); + mobj->SetOrigin( + fixedvalue(t_argv[1]), + (t_argc >= 3)? fixedvalue(t_argv[2]) : mobj->Y(), + (t_argc >= 4)? fixedvalue(t_argv[3]) : mobj->Z(), false); } } @@ -4285,7 +4281,7 @@ void FParser::SF_SpawnShot2(void) t_return.type = svt_mobj; - AActor *mo = Spawn (PClass, source->x, source->y, source->z+z, ALLOW_REPLACE); + AActor *mo = Spawn (PClass, source->X(), source->Y(), source->Z()+z, ALLOW_REPLACE); if (mo) { S_Sound (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_NORM); diff --git a/src/g_doom/a_archvile.cpp b/src/g_doom/a_archvile.cpp index f24ff146e..9d2e5db0c 100644 --- a/src/g_doom/a_archvile.cpp +++ b/src/g_doom/a_archvile.cpp @@ -52,7 +52,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Fire) void A_Fire(AActor *self, int height) { AActor *dest; - angle_t an; dest = self->tracer; if (dest == NULL || self->target == NULL) @@ -62,11 +61,8 @@ void A_Fire(AActor *self, int height) if (!P_CheckSight (self->target, dest, 0) ) return; - an = dest->angle >> ANGLETOFINESHIFT; - - self->SetOrigin (dest->x + FixedMul (24*FRACUNIT, finecosine[an]), - dest->y + FixedMul (24*FRACUNIT, finesine[an]), - dest->z + height); + fixedvec3 newpos = dest->Vec3Angle(24 * FRACUNIT, dest->angle, height); + self->SetOrigin(newpos, true); } @@ -86,8 +82,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileTarget) A_FaceTarget (self); - fog = Spawn (fire, self->target->x, self->target->y, - self->target->z, ALLOW_REPLACE); + fog = Spawn (fire, self->target->X(), self->target->Y(), + self->target->Z(), ALLOW_REPLACE); self->tracer = fog; fog->target = self; @@ -117,7 +113,6 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileAttack) ACTION_PARAM_INT(flags,6); AActor *fire, *target; - angle_t an; if (NULL == (target = self->target)) return; @@ -139,15 +134,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileAttack) P_TraceBleed (newdam > 0 ? newdam : dmg, target); - an = self->angle >> ANGLETOFINESHIFT; fire = self->tracer; if (fire != NULL) { // move the fire between the vile and the player - fire->SetOrigin (target->x - FixedMul (24*FRACUNIT, finecosine[an]), - target->y - FixedMul (24*FRACUNIT, finesine[an]), - target->z); + fixedvec3 pos = target->Vec3Angle(-24 * FRACUNIT, self->angle, target->Z()); + fire->SetOrigin (pos, true); P_RadiusAttack (fire, self, blastdmg, blastrad, dmgtype, 0); } diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 15861f79e..d8230a031 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2918,8 +2918,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MonsterRail) { // We probably won't hit the target, but aim at it anyway so we don't look stupid. TVector2 xydiff = self->Vec2To(self->target); - double zdiff = (self->target->Z() + (self->target->height>>1)) - - (self->Z() + (self->height>>1) - self->floorclip); + double zdiff = FIXED2DBL((self->target->Z() + (self->target->height>>1)) - (self->Z() + (self->height>>1) - self->floorclip)); self->pitch = int(atan2(zdiff, xydiff.Length()) * ANGLE_180 / -M_PI); } From 2b5e5b6bc3c299480bb6f10a19c05d0c0bc8370b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jan 2016 16:49:24 +0100 Subject: [PATCH 06/18] - next round of refactoring. This contains some advance work for handling line-to-line portals in A_PainShootSkull. This function is special because it performs a map check itself instead of using one of the common functions from p_map.cpp, like most of the rest of the game code. --- src/actor.h | 8 ++++ src/g_doom/a_bossbrain.cpp | 18 ++++---- src/g_doom/a_doomweaps.cpp | 4 +- src/g_doom/a_fatso.cpp | 8 ++-- src/g_doom/a_lostsoul.cpp | 2 +- src/g_doom/a_painelemental.cpp | 79 +++++++++++++++++++++------------- src/g_heretic/a_dsparil.cpp | 6 +-- src/r_defs.h | 16 +++++++ 8 files changed, 91 insertions(+), 50 deletions(-) diff --git a/src/actor.h b/src/actor.h index 4deb349a7..96e424863 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1360,6 +1360,14 @@ inline T *Spawn (const fixedvec3 &pos, replace_t allowreplacement) return static_cast(AActor::StaticSpawn (RUNTIME_CLASS(T), pos.x, pos.y, pos.z, allowreplacement)); } +inline fixedvec2 Vec2Angle(fixed_t length, angle_t angle) +{ + fixedvec2 ret = { FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) }; + return ret; +} + + void PrintMiscActorInfo(AActor * query); #define S_FREETARGMOBJ 1 diff --git a/src/g_doom/a_bossbrain.cpp b/src/g_doom/a_bossbrain.cpp index a99ef9323..65d9d08b4 100644 --- a/src/g_doom/a_bossbrain.cpp +++ b/src/g_doom/a_bossbrain.cpp @@ -55,9 +55,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_BrainScream) { fixed_t x; - for (x = self->x - 196*FRACUNIT; x < self->x + 320*FRACUNIT; x += 8*FRACUNIT) + for (x = self->X() - 196*FRACUNIT; x < self->X() + 320*FRACUNIT; x += 8*FRACUNIT) { - BrainishExplosion (x, self->y - 320*FRACUNIT, + BrainishExplosion (x, self->Y() - 320*FRACUNIT, 128 + (pr_brainscream() << (FRACBITS + 1))); } S_Sound (self, CHAN_VOICE, "brain/death", 1, ATTN_NONE); @@ -65,9 +65,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_BrainScream) DEFINE_ACTION_FUNCTION(AActor, A_BrainExplode) { - fixed_t x = self->x + pr_brainexplode.Random2()*2048; + fixed_t x = self->X() + pr_brainexplode.Random2()*2048; fixed_t z = 128 + pr_brainexplode()*2*FRACUNIT; - BrainishExplosion (x, self->y, z); + BrainishExplosion (x, self->Y(), z); } DEFINE_ACTION_FUNCTION(AActor, A_BrainDie) @@ -140,11 +140,11 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BrainSpit) } else if (abs(spit->vely) > abs(spit->velx)) { - spit->special2 = (targ->y - self->y) / spit->vely; + spit->special2 = (targ->Y() - self->Y()) / spit->vely; } else { - spit->special2 = (targ->x - self->x) / spit->velx; + spit->special2 = (targ->X() - self->X()) / spit->velx; } // [GZ] Calculates when the projectile will have reached destination spit->special2 += level.maptime; @@ -185,7 +185,7 @@ static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound) if (spawntype != NULL) { - fog = Spawn (spawntype, targ->x, targ->y, targ->z, ALLOW_REPLACE); + fog = Spawn (spawntype, targ->X(), targ->Y(), targ->Z(), ALLOW_REPLACE); if (fog != NULL) S_Sound (fog, CHAN_BODY, sound, 1, ATTN_NORM); } @@ -256,7 +256,7 @@ static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound) spawntype = PClass::FindClass(SpawnName); if (spawntype != NULL) { - newmobj = Spawn (spawntype, targ->x, targ->y, targ->z, ALLOW_REPLACE); + newmobj = Spawn (spawntype, targ->X(), targ->Y(), targ->Z(), ALLOW_REPLACE); if (newmobj != NULL) { // Make the new monster hate what the boss eye hates @@ -275,7 +275,7 @@ static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound) if (!(newmobj->ObjectFlags & OF_EuthanizeMe)) { // telefrag anything in this spot - P_TeleportMove (newmobj, newmobj->x, newmobj->y, newmobj->z, true); + P_TeleportMove (newmobj, newmobj->X(), newmobj->Y(), newmobj->Z(), true); } newmobj->flags4 |= MF4_BOSSSPAWNED; } diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 79dd6253f..85335587e 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -612,8 +612,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) if (linetarget != NULL) { - AActor *spray = Spawn(spraytype, linetarget->x, linetarget->y, - linetarget->z + (linetarget->height >> 2), ALLOW_REPLACE); + AActor *spray = Spawn(spraytype, linetarget->X(), linetarget->Y(), + linetarget->Z() + (linetarget->height >> 2), ALLOW_REPLACE); int dmgFlags = 0; FName dmgType = NAME_BFGSplash; diff --git a/src/g_doom/a_fatso.cpp b/src/g_doom/a_fatso.cpp index 066e60468..c9f53d9d3 100644 --- a/src/g_doom/a_fatso.cpp +++ b/src/g_doom/a_fatso.cpp @@ -145,7 +145,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Mushroom) P_CheckSplash(self, 128<X(), self->Y(), self->Z(), NO_REPLACE); // We need something to aim at. AActor *master = (flags & MSF_DontHurt) ? (AActor*)(self->target) : self; target->height = self->height; for (i = -n; i <= n; i += 8) @@ -153,9 +153,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Mushroom) for (j = -n; j <= n; j += 8) { AActor *mo; - target->x = self->x + (i << FRACBITS); // Aim in many directions from source - target->y = self->y + (j << FRACBITS); - target->z = self->z + (P_AproxDistance(i,j) * vrange); // Aim up fairly high + target->x = self->X() + (i << FRACBITS); // Aim in many directions from source + target->y = self->Y() + (j << FRACBITS); + target->z = self->Z() + (P_AproxDistance(i,j) * vrange); // Aim up fairly high if ((flags & MSF_Classic) || // Flag explicitely set, or no flags and compat options (flags == 0 && (self->state->DefineFlags & SDF_DEHACKED) && (i_compatflags & COMPATF_MUSHROOM))) { // Use old function for MBF compatibility diff --git a/src/g_doom/a_lostsoul.cpp b/src/g_doom/a_lostsoul.cpp index 1182292e0..7dc9a1b8f 100644 --- a/src/g_doom/a_lostsoul.cpp +++ b/src/g_doom/a_lostsoul.cpp @@ -41,7 +41,7 @@ void A_SkullAttack(AActor *self, fixed_t speed) if (dist < 1) dist = 1; - self->velz = (dest->z + (dest->height>>1) - self->z) / dist; + self->velz = (dest->Z() + (dest->height>>1) - self->Z()) / dist; } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SkullAttack) diff --git a/src/g_doom/a_painelemental.cpp b/src/g_doom/a_painelemental.cpp index f361fb78d..cb5205a76 100644 --- a/src/g_doom/a_painelemental.cpp +++ b/src/g_doom/a_painelemental.cpp @@ -35,17 +35,14 @@ enum PA_Flags // void A_PainShootSkull (AActor *self, angle_t angle, const PClass *spawntype, int flags = 0, int limit = -1) { - fixed_t x, y, z; - AActor *other; - angle_t an; int prestep; if (spawntype == NULL) return; if (self->DamageType==NAME_Massacre) return; // [RH] check to make sure it's not too close to the ceiling - if (self->z + self->height + 8*FRACUNIT > self->ceilingz) + if (self->Top() + 8*FRACUNIT > self->ceilingz) { if (self->flags & MF_FLOAT) { @@ -76,47 +73,67 @@ void A_PainShootSkull (AActor *self, angle_t angle, const PClass *spawntype, int } // okay, there's room for another one - an = angle >> ANGLETOFINESHIFT; - prestep = 4*FRACUNIT + 3*(self->radius + GetDefaultByType(spawntype)->radius)/2; - - x = self->x + FixedMul (prestep, finecosine[an]); - y = self->y + FixedMul (prestep, finesine[an]); - z = self->z + 8*FRACUNIT; - - // Check whether the Lost Soul is being fired through a 1-sided // phares - // wall or an impassible line, or a "monsters can't cross" line.// | - // If it is, then we don't allow the spawn. // V - FBoundingBox box(MIN(self->x, x), MIN(self->y, y), MAX(self->x, x), MAX(self->y, y)); - FBlockLinesIterator it(box); - line_t *ld; + // NOTE: The following code contains some advance work for line-to-line portals which is currenty inactive. - while ((ld = it.Next())) + fixedvec2 dist = Vec2Angle(prestep, angle); + fixedvec3 pos = self->Vec3Offset(dist.x, dist.y, 8 * FRACUNIT, true); + fixedvec3 src = { self->X(), self->Y(), self->Z() }; + + for (int i = 0; i < 2; i++) { - if (!(ld->flags & ML_TWOSIDED) || - (ld->flags & (ML_BLOCKING|ML_BLOCKMONSTERS|ML_BLOCKEVERYTHING))) + // Check whether the Lost Soul is being fired through a 1-sided // phares + // wall or an impassible line, or a "monsters can't cross" line.// | + // If it is, then we don't allow the spawn. // V + + FBoundingBox box(MIN(src.x, pos.x), MIN(src.y, pos.y), MAX(src.x, pos.x), MAX(src.y, pos.y)); + FBlockLinesIterator it(box); + line_t *ld; + bool inportal = false; + + while ((ld = it.Next())) { - if (!(box.Left() > ld->bbox[BOXRIGHT] || - box.Right() < ld->bbox[BOXLEFT] || - box.Top() < ld->bbox[BOXBOTTOM] || - box.Bottom() > ld->bbox[BOXTOP])) + if (ld->isLinePortal() && i == 0) { - if (P_PointOnLineSidePrecise(self->x,self->y,ld) != P_PointOnLineSidePrecise(x,y,ld)) - return; // line blocks trajectory // ^ + if (P_PointOnLineSidePrecise(src.x, src.y, ld) == 0 && + P_PointOnLineSidePrecise(pos.x, pos.y, ld) == 1) + { + // crossed a portal line from front to back, we need to repeat the check on the other side as well. + inportal = true; + } + } + else if (!(ld->flags & ML_TWOSIDED) || + (ld->flags & (ML_BLOCKING | ML_BLOCKMONSTERS | ML_BLOCKEVERYTHING))) + { + if (!(box.Left() > ld->bbox[BOXRIGHT] || + box.Right() < ld->bbox[BOXLEFT] || + box.Top() < ld->bbox[BOXBOTTOM] || + box.Bottom() > ld->bbox[BOXTOP])) + { + if (P_PointOnLineSidePrecise(src.x, src.y, ld) != P_PointOnLineSidePrecise(pos.x, pos.y, ld)) + return; // line blocks trajectory // ^ + } } } + if (!inportal) break; + + // recalculate position and redo the check on the other side of the portal + pos = self->Vec3Offset(dist.x, dist.y, 8 * FRACUNIT, false); + src.x = pos.x - dist.x; + src.y = pos.y - dist.y; + } - other = Spawn (spawntype, x, y, z, ALLOW_REPLACE); + other = Spawn (spawntype, pos.x, pos.y, pos.z, ALLOW_REPLACE); // Check to see if the new Lost Soul's z value is above the // ceiling of its new sector, or below the floor. If so, kill it. - if ((other->z > - (other->Sector->ceilingplane.ZatPoint (other->x, other->y) - other->height)) || - (other->z < other->Sector->floorplane.ZatPoint (other->x, other->y))) + if ((other->Z() > + (other->Sector->HighestCeiling(other) - other->height)) || + (other->Z() < other->Sector->LowestFloor(other))) { // kill it immediately P_DamageMobj (other, self, self, TELEFRAG_DAMAGE, NAME_None);// ^ @@ -125,7 +142,7 @@ void A_PainShootSkull (AActor *self, angle_t angle, const PClass *spawntype, int // Check for movements. - if (!P_CheckPosition (other, other->x, other->y)) + if (!P_CheckPosition (other, other->X(), other->Y())) { // kill it immediately P_DamageMobj (other, self, self, TELEFRAG_DAMAGE, NAME_None); diff --git a/src/g_heretic/a_dsparil.cpp b/src/g_heretic/a_dsparil.cpp index e4d86c83a..b12be8081 100644 --- a/src/g_heretic/a_dsparil.cpp +++ b/src/g_heretic/a_dsparil.cpp @@ -254,10 +254,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenWizard) { AActor *mo; - mo = Spawn("Wizard", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn("Wizard", self->X(), self->Y(), self->Z(), ALLOW_REPLACE); if (mo != NULL) { - mo->z -= mo->GetDefault()->height/2; + mo->SetZ(mo->Z() - mo->GetDefault()->height / 2, false); if (!P_TestMobjLocation (mo)) { // Didn't fit mo->ClearCounters(); @@ -272,7 +272,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenWizard) self->flags &= ~MF_MISSILE; mo->master = self->target; // Heretic did not offset it by TELEFOGHEIGHT, so I won't either. - Spawn (self->x, self->y, self->z, ALLOW_REPLACE); + Spawn (self->X(), self->Y(), self->Z(), ALLOW_REPLACE); } } } diff --git a/src/r_defs.h b/src/r_defs.h index dd8496e4d..4f0b5ed01 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -683,6 +683,17 @@ struct sector_t return pos == floor? floorplane:ceilingplane; } + fixed_t HighestCeiling(AActor *a) const + { + return ceilingplane.ZatPoint(a); + } + + fixed_t LowestFloor(AActor *a) const + { + return floorplane.ZatPoint(a); + } + + bool isSecret() const { return !!(Flags & SECF_SECRET); @@ -977,6 +988,11 @@ struct line_t sector_t *frontsector, *backsector; int validcount; // if == validcount, already checked int locknumber; // [Dusk] lock number for special + + bool isLinePortal() const + { + return false; + } }; // phares 3/14/98 From 57ab1387f2bf43006714f89071c95c9283557d98 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jan 2016 18:52:24 +0100 Subject: [PATCH 07/18] - yet more refactoring. Note about A_SkelMissile: The direct change of the missile's position was changed to use SetOrigin. If this is later supposed to be portal-aware, such direct coordinate changes are a no-go to ensure that everything is properly maintained. --- src/actor.h | 18 +++++++++++++++++ src/d_net.cpp | 5 +---- src/g_doom/a_archvile.cpp | 3 +-- src/g_doom/a_bossbrain.cpp | 4 ++-- src/g_doom/a_fatso.cpp | 7 ++++--- src/g_doom/a_revenant.cpp | 14 ++++++-------- src/g_heretic/a_dsparil.cpp | 14 +++++++------- src/g_heretic/a_hereticartifacts.cpp | 8 +++----- src/g_level.cpp | 4 +--- src/p_effect.cpp | 4 +--- src/p_things.cpp | 29 ++++++++++++++-------------- 11 files changed, 59 insertions(+), 51 deletions(-) diff --git a/src/actor.h b/src/actor.h index 96e424863..c8bcdc19f 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1247,6 +1247,11 @@ public: { return z; } + fixedvec3 Pos() const + { + fixedvec3 ret = { X(), Y(), Z() }; + return ret; + } fixed_t Top() const { return z + height; @@ -1256,6 +1261,19 @@ public: z = newz; } + // These are not for general use as they do not link the actor into the world! + void SetXY(fixed_t xx, fixed_t yy) + { + x = xx; + y = yy; + } + void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz) + { + x = xx; + y = yy; + z = zz; + } + }; class FActorIterator diff --git a/src/d_net.cpp b/src/d_net.cpp index 29303fa04..5e8a635d5 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2319,10 +2319,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) else { const AActor *def = GetDefaultByType (typeinfo); - fixedvec3 spawnpos = source->Vec3Offset( - FixedMul (def->radius * 2 + source->radius, finecosine[source->angle>>ANGLETOFINESHIFT]), - FixedMul (def->radius * 2 + source->radius, finesine[source->angle>>ANGLETOFINESHIFT]), - 8 * FRACUNIT); + fixedvec3 spawnpos = source->Vec3Angle(def->radius * 2 + source->radius, source->angle, 8 * FRACUNIT); AActor *spawned = Spawn (typeinfo, spawnpos, ALLOW_REPLACE); if (spawned != NULL) diff --git a/src/g_doom/a_archvile.cpp b/src/g_doom/a_archvile.cpp index 9d2e5db0c..304bb271a 100644 --- a/src/g_doom/a_archvile.cpp +++ b/src/g_doom/a_archvile.cpp @@ -82,8 +82,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_VileTarget) A_FaceTarget (self); - fog = Spawn (fire, self->target->X(), self->target->Y(), - self->target->Z(), ALLOW_REPLACE); + fog = Spawn (fire, self->target->Pos(), ALLOW_REPLACE); self->tracer = fog; fog->target = self; diff --git a/src/g_doom/a_bossbrain.cpp b/src/g_doom/a_bossbrain.cpp index 65d9d08b4..f69acd789 100644 --- a/src/g_doom/a_bossbrain.cpp +++ b/src/g_doom/a_bossbrain.cpp @@ -185,7 +185,7 @@ static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound) if (spawntype != NULL) { - fog = Spawn (spawntype, targ->X(), targ->Y(), targ->Z(), ALLOW_REPLACE); + fog = Spawn (spawntype, targ->Pos(), ALLOW_REPLACE); if (fog != NULL) S_Sound (fog, CHAN_BODY, sound, 1, ATTN_NORM); } @@ -256,7 +256,7 @@ static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound) spawntype = PClass::FindClass(SpawnName); if (spawntype != NULL) { - newmobj = Spawn (spawntype, targ->X(), targ->Y(), targ->Z(), ALLOW_REPLACE); + newmobj = Spawn (spawntype, targ->Pos(), ALLOW_REPLACE); if (newmobj != NULL) { // Make the new monster hate what the boss eye hates diff --git a/src/g_doom/a_fatso.cpp b/src/g_doom/a_fatso.cpp index c9f53d9d3..370e3fc69 100644 --- a/src/g_doom/a_fatso.cpp +++ b/src/g_doom/a_fatso.cpp @@ -153,9 +153,10 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Mushroom) for (j = -n; j <= n; j += 8) { AActor *mo; - target->x = self->X() + (i << FRACBITS); // Aim in many directions from source - target->y = self->Y() + (j << FRACBITS); - target->z = self->Z() + (P_AproxDistance(i,j) * vrange); // Aim up fairly high + target->SetXYZ( + self->X() + (i << FRACBITS), // Aim in many directions from source + self->Y() + (j << FRACBITS), + self->Z() + (P_AproxDistance(i,j) * vrange)); // Aim up fairly high if ((flags & MSF_Classic) || // Flag explicitely set, or no flags and compat options (flags == 0 && (self->state->DefineFlags & SDF_DEHACKED) && (i_compatflags & COMPATF_MUSHROOM))) { // Use old function for MBF compatibility diff --git a/src/g_doom/a_revenant.cpp b/src/g_doom/a_revenant.cpp index 06fdfa6aa..162cfd5fa 100644 --- a/src/g_doom/a_revenant.cpp +++ b/src/g_doom/a_revenant.cpp @@ -26,13 +26,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkelMissile) return; A_FaceTarget (self); - missile = P_SpawnMissileZ (self, self->z + 48*FRACUNIT, + missile = P_SpawnMissileZ (self, self->Z() + 48*FRACUNIT, self->target, PClass::FindClass("RevenantTracer")); if (missile != NULL) { - missile->x += missile->velx; - missile->y += missile->vely; + missile->SetOrigin(missile->X() + missile->velx, missile->Y() + missile->vely, missile->Z(), false); missile->tracer = self->target; } } @@ -60,10 +59,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer) return; // spawn a puff of smoke behind the rocket - P_SpawnPuff (self, PClass::FindClass(NAME_BulletPuff), self->x, self->y, self->z, 0, 3); + P_SpawnPuff (self, PClass::FindClass(NAME_BulletPuff), self->X(), self->Y(), self->Z(), 0, 3); - smoke = Spawn ("RevenantTracerSmoke", self->x - self->velx, - self->y - self->vely, self->z, ALLOW_REPLACE); + smoke = Spawn ("RevenantTracerSmoke", self->Vec3Offset(-self->velx, -self->vely, 0), ALLOW_REPLACE); smoke->velz = FRACUNIT; smoke->tics -= pr_tracer()&3; @@ -109,11 +107,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer) if (dest->height >= 56*FRACUNIT) { - slope = (dest->z+40*FRACUNIT - self->z) / dist; + slope = (dest->Z()+40*FRACUNIT - self->Z()) / dist; } else { - slope = (dest->z + self->height*2/3 - self->z) / dist; + slope = (dest->Z() + self->height*2/3 - self->Z()) / dist; } if (slope < self->velz) diff --git a/src/g_heretic/a_dsparil.cpp b/src/g_heretic/a_dsparil.cpp index b12be8081..d7e976d99 100644 --- a/src/g_heretic/a_dsparil.cpp +++ b/src/g_heretic/a_dsparil.cpp @@ -140,20 +140,20 @@ void P_DSparilTeleport (AActor *actor) DSpotState *state = DSpotState::GetSpotState(); if (state == NULL) return; - spot = state->GetSpotWithMinMaxDistance(PClass::FindClass("BossSpot"), actor->x, actor->y, 128*FRACUNIT, 0); + spot = state->GetSpotWithMinMaxDistance(PClass::FindClass("BossSpot"), actor->X(), actor->Y(), 128*FRACUNIT, 0); if (spot == NULL) return; - prevX = actor->x; - prevY = actor->y; - prevZ = actor->z; - if (P_TeleportMove (actor, spot->x, spot->y, spot->z, false)) + prevX = actor->X(); + prevY = actor->Y(); + prevZ = actor->Z(); + if (P_TeleportMove (actor, spot->X(), spot->Y(), spot->Z(), false)) { mo = Spawn("Sorcerer2Telefade", prevX, prevY, prevZ, ALLOW_REPLACE); if (mo) mo->Translation = actor->Translation; S_Sound (mo, CHAN_BODY, "misc/teleport", 1, ATTN_NORM); actor->SetState (actor->FindState("Teleport")); S_Sound (actor, CHAN_BODY, "misc/teleport", 1, ATTN_NORM); - actor->z = actor->floorz; + actor->SetZ(actor->floorz, false); actor->angle = spot->angle; actor->velx = actor->vely = actor->velz = 0; } @@ -237,7 +237,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BlueSpark) for (i = 0; i < 2; i++) { - mo = Spawn("Sorcerer2FXSpark", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn("Sorcerer2FXSpark", self->Pos(), ALLOW_REPLACE); mo->velx = pr_bluespark.Random2() << 9; mo->vely = pr_bluespark.Random2() << 9; mo->velz = FRACUNIT + (pr_bluespark()<<8); diff --git a/src/g_heretic/a_hereticartifacts.cpp b/src/g_heretic/a_hereticartifacts.cpp index 651e3609c..86416038f 100644 --- a/src/g_heretic/a_hereticartifacts.cpp +++ b/src/g_heretic/a_hereticartifacts.cpp @@ -47,8 +47,8 @@ bool AArtiTomeOfPower::Use (bool pickup) DEFINE_ACTION_FUNCTION(AActor, A_TimeBomb) { - self->z += 32*FRACUNIT; - self->PrevZ = self->z; // no interpolation! + self->SetZ(self->Z() + 32*FRACUNIT, false); + self->PrevZ = self->Z(); // no interpolation! self->RenderStyle = STYLE_Add; self->alpha = FRACUNIT; P_RadiusAttack (self, self->target, 128, 128, self->DamageType, RADF_HURTSOURCE); @@ -69,9 +69,7 @@ bool AArtiTimeBomb::Use (bool pickup) { angle_t angle = Owner->angle >> ANGLETOFINESHIFT; AActor *mo = Spawn("ActivatedTimeBomb", - Owner->x + 24*finecosine[angle], - Owner->y + 24*finesine[angle], - Owner->z - Owner->floorclip, ALLOW_REPLACE); + Vec3Angle(24*FRACUNIT, Owner->angle, - Owner->floorclip), ALLOW_REPLACE); mo->target = Owner; return true; } diff --git a/src/g_level.cpp b/src/g_level.cpp index 03474a5b7..43a07a475 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1220,9 +1220,7 @@ void G_FinishTravel () pawn->angle = pawndup->angle; pawn->pitch = pawndup->pitch; } - pawn->x = pawndup->x; - pawn->y = pawndup->y; - pawn->z = pawndup->z; + pawn->SetXYZ(pawndup->X(), pawndup->Y(), pawndup->Z()); pawn->velx = pawndup->velx; pawn->vely = pawndup->vely; pawn->velz = pawndup->velz; diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 0cd6d5c51..2907b0d37 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -451,9 +451,7 @@ void P_RunEffect (AActor *actor, int effects) { // Grenade trail - fixedvec3 pos = actor->Vec3Offset( - -FixedMul(finecosine[(moveangle) >> ANGLETOFINESHIFT], actor->radius * 2), - -FixedMul(finesine[(moveangle) >> ANGLETOFINESHIFT], actor->radius * 2), + fixedvec3 pos = actor->Vec3Angle(-actor->radius * 2, moveangle, -(actor->height >> 3) * (actor->velz >> 16) + (2 * actor->height) / 3); P_DrawSplash2 (6, pos.x, pos.y, pos.z, diff --git a/src/p_things.cpp b/src/p_things.cpp index e8f9d6011..80ce3a5cf 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -82,7 +82,7 @@ bool P_Thing_Spawn (int tid, AActor *source, int type, angle_t angle, bool fog, } while (spot != NULL) { - mobj = Spawn (kind, spot->X(), spot->Y(), spot->Z(), ALLOW_REPLACE); + mobj = Spawn (kind, spot->Pos(), ALLOW_REPLACE); if (mobj != NULL) { @@ -123,11 +123,11 @@ bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog) { fixed_t oldx, oldy, oldz; - oldx = source->x; - oldy = source->y; - oldz = source->z; + oldx = source->X(); + oldy = source->Y(); + oldz = source->Z(); - source->SetOrigin (x, y, z); + source->SetOrigin (x, y, z, false); if (P_TestMobjLocation (source)) { if (fog) @@ -146,7 +146,7 @@ bool P_MoveThing(AActor *source, fixed_t x, fixed_t y, fixed_t z, bool fog) } else { - source->SetOrigin (oldx, oldy, oldz); + source->SetOrigin (oldx, oldy, oldz, false); return false; } } @@ -218,7 +218,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam { do { - fixed_t z = spot->z; + fixed_t z = spot->Z(); if (defflags3 & MF3_FLOORHUGGER) { z = ONFLOORZ; @@ -231,7 +231,7 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam { z -= spot->floorclip; } - mobj = Spawn (kind, spot->x, spot->y, z, ALLOW_REPLACE); + mobj = Spawn (kind, spot->X(), spot->Y(), z, ALLOW_REPLACE); if (mobj) { @@ -254,8 +254,9 @@ bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_nam if (targ != NULL) { - fixed_t spot[3] = { targ->x, targ->y, targ->z+targ->height/2 }; - FVector3 aim(float(spot[0] - mobj->x), float(spot[1] - mobj->y), float(spot[2] - mobj->z)); + fixedvec3 vect = mobj->Vec3To(targ); + vect.z += targ->height / 2; + FVector3 aim = vect; if (leadTarget && speed > 0 && (targ->velx | targ->vely | targ->velz)) { @@ -435,7 +436,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser) thing->flags |= MF_SOLID; thing->height = info->height; // [RH] Use real height thing->radius = info->radius; // [RH] Use real radius - if (!P_CheckPosition (thing, thing->x, thing->y)) + if (!P_CheckPosition (thing, thing->X(), thing->Y())) { thing->flags = oldflags; thing->radius = oldradius; @@ -477,7 +478,7 @@ bool P_Thing_CanRaise(AActor *thing) thing->height = info->height; thing->radius = info->radius; - bool check = P_CheckPosition (thing, thing->x, thing->y); + bool check = P_CheckPosition (thing, thing->X(), thing->Y()); // Restore checked properties thing->flags = oldflags; @@ -690,8 +691,8 @@ int P_Thing_Warp(AActor *caller, AActor *reference, fixed_t xofs, fixed_t yofs, caller = temp; } - fixed_t oldx = caller->x; - fixed_t oldy = caller->y; + fixed_t oldx = caller->X(); + fixed_t oldy = caller->Y(); fixed_t oldz = caller->z; zofs += FixedMul(reference->height, heightoffset); From 460751653db590c3e945faf8c7b6ba468b844aa4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jan 2016 20:13:20 +0100 Subject: [PATCH 08/18] - refactored most of Heretic's game code. --- src/actor.h | 71 +++++++++++++++++--------------- src/g_heretic/a_chicken.cpp | 4 +- src/g_heretic/a_dsparil.cpp | 10 ++--- src/g_heretic/a_hereticimp.cpp | 4 +- src/g_heretic/a_hereticmisc.cpp | 2 +- src/g_heretic/a_hereticweaps.cpp | 69 ++++++++++++++++--------------- src/g_heretic/a_ironlich.cpp | 9 ++-- src/g_heretic/a_knight.cpp | 11 ++--- 8 files changed, 93 insertions(+), 87 deletions(-) diff --git a/src/actor.h b/src/actor.h index c8bcdc19f..b12699558 100644 --- a/src/actor.h +++ b/src/actor.h @@ -847,7 +847,7 @@ public: bool intersects(AActor *other) const { fixed_t blockdist = radius + other->radius; - return ( abs(x - other->x) < blockdist && abs(y - other->y) < blockdist); + return ( abs(pos.x - other->pos.x) < blockdist && abs(pos.y - other->pos.y) < blockdist); } PalEntry GetBloodColor() const @@ -888,99 +888,99 @@ public: // to distinguish between portal-aware and portal-unaware distance calculation. fixed_t AproxDistance(AActor *other, bool absolute = false) { - return P_AproxDistance(x - other->x, y - other->y); + return P_AproxDistance(pos.x - other->pos.x, pos.y - other->pos.y); } // same with 'ref' here. fixed_t AproxDistance(fixed_t otherx, fixed_t othery, AActor *ref = NULL) { - return P_AproxDistance(x - otherx, y - othery); + return P_AproxDistance(pos.x - otherx, pos.y - othery); } fixed_t AproxDistance(AActor *other, fixed_t xadd, fixed_t yadd, bool absolute = false) { - return P_AproxDistance(x - other->x + xadd, y - other->y + yadd); + return P_AproxDistance(pos.x - other->pos.x + xadd, pos.y - other->pos.y + yadd); } fixed_t AproxDistance3D(AActor *other, bool absolute = false) { - return P_AproxDistance(AproxDistance(other), z - other->z); + return P_AproxDistance(AproxDistance(other), pos.z - other->pos.z); } // more precise, but slower version, being used in a few places fixed_t Distance2D(AActor *other, bool absolute = false) { - return xs_RoundToInt(FVector2(x - other->x, y - other->y).Length()); + return xs_RoundToInt(FVector2(pos.x - other->pos.x, pos.y - other->pos.y).Length()); } // a full 3D version of the above fixed_t Distance3D(AActor *other, bool absolute = false) { - return xs_RoundToInt(FVector3(x - other->x, y - other->y, z - other->z).Length()); + return xs_RoundToInt(FVector3(pos.x - other->pos.x, pos.y - other->pos.y, pos.z - other->pos.z).Length()); } angle_t AngleTo(AActor *other, bool absolute = false) const { - return R_PointToAngle2(x, y, other->x, other->y); + return R_PointToAngle2(pos.x, pos.y, other->pos.x, other->pos.y); } angle_t AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const { - return R_PointToAngle2(x, y, other->x + oxofs, other->y + oyofs); + return R_PointToAngle2(pos.x, pos.y, other->pos.x + oxofs, other->pos.y + oyofs); } fixed_t AngleTo(fixed_t otherx, fixed_t othery, AActor *ref = NULL) { - return R_PointToAngle2(x, y, otherx, othery); + return R_PointToAngle2(pos.x, pos.y, otherx, othery); } fixed_t AngleXYTo(fixed_t myx, fixed_t myy, AActor *other, bool absolute = false) { - return R_PointToAngle2(myx, myy, other->x, other->y); + return R_PointToAngle2(myx, myy, other->pos.x, other->pos.y); } fixedvec2 Vec2To(AActor *other) const { - fixedvec2 ret = { other->x - x, other->y - y }; + fixedvec2 ret = { other->pos.x - pos.x, other->pos.y - pos.y }; return ret; } fixedvec3 Vec3To(AActor *other) const { - fixedvec3 ret = { other->x - x, other->y - y, other->z - z }; + fixedvec3 ret = { other->pos.x - pos.x, other->pos.y - pos.y, other->pos.z - pos.z }; return ret; } fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false) const { - fixedvec2 ret = { x + dx, y + dy }; + fixedvec2 ret = { pos.x + dx, pos.y + dy }; return ret; } fixedvec2 Vec2Angle(fixed_t length, angle_t angle, bool absolute = false) const { - fixedvec2 ret = { x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), - y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) }; + fixedvec2 ret = { pos.x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), + pos.y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) }; return ret; } fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) const { - fixedvec3 ret = { x + dx, y + dy, z + dz }; + fixedvec3 ret = { pos.x + dx, pos.y + dy, pos.z + dz }; return ret; } fixedvec3 Vec3Angle(fixed_t length, angle_t angle, fixed_t dz, bool absolute = false) const { - fixedvec3 ret = { x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), - y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), z + dz }; + fixedvec3 ret = { pos.x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), + pos.y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), pos.z + dz }; return ret; } void Move(fixed_t dx, fixed_t dy, fixed_t dz) { - SetOrigin(x + dx, y + dy, z + dz, true); + SetOrigin(pos.x + dx, pos.y + dy, pos.z + dz, true); } void SetOrigin(const fixedvec3 & npos, bool moving) @@ -1007,7 +1007,10 @@ public: // info for drawing // NOTE: The first member variable *must* be x. - fixed_t x,y,z; +private: + fixedvec3 pos; +public: + //fixed_t x,y,z; AActor *snext, **sprev; // links in sector (if needed) angle_t angle; WORD sprite; // used to find patch_t and flip value @@ -1205,7 +1208,7 @@ public: void LinkToWorld (sector_t *sector); void UnlinkFromWorld (); void AdjustFloorClip (); - void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving = false); + void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving); bool InStateSequence(FState * newstate, FState * basestate); int GetTics(FState * newstate); bool SetState (FState *newstate, bool nofunction=false); @@ -1237,15 +1240,15 @@ public: fixed_t X() const { - return x; + return pos.x; } fixed_t Y() const { - return y; + return pos.y; } fixed_t Z() const { - return z; + return pos.z; } fixedvec3 Pos() const { @@ -1254,24 +1257,24 @@ public: } fixed_t Top() const { - return z + height; + return pos.z + height; } void SetZ(fixed_t newz, bool moving = true) { - z = newz; + pos.z = newz; } // These are not for general use as they do not link the actor into the world! - void SetXY(fixed_t xx, fixed_t yy) + void SetXY(fixed_t x, fixed_t y) { - x = xx; - y = yy; + pos.x = x; + pos.y = y; } - void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz) + void SetXYZ(fixed_t x, fixed_t y, fixed_t z) { - x = xx; - y = yy; - z = zz; + pos.x = x; + pos.y = y; + pos.z = z; } }; diff --git a/src/g_heretic/a_chicken.cpp b/src/g_heretic/a_chicken.cpp index f4ad4c211..3fcb15380 100644 --- a/src/g_heretic/a_chicken.cpp +++ b/src/g_heretic/a_chicken.cpp @@ -45,7 +45,7 @@ void AChickenPlayer::MorphPlayerThink () { // Twitch view angle angle += pr_chickenplayerthink.Random2 () << 19; } - if ((z <= floorz) && (pr_chickenplayerthink() < 32)) + if ((Z() <= floorz) && (pr_chickenplayerthink() < 32)) { // Jump and noise velz += JumpZ; @@ -100,7 +100,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Feathers) } for (i = 0; i < count; i++) { - mo = Spawn("Feather", self->x, self->y, self->z+20*FRACUNIT, NO_REPLACE); + mo = Spawn("Feather", self->X(), self->Y(), self->Z()+20*FRACUNIT, NO_REPLACE); mo->target = self; mo->velx = pr_feathers.Random2() << 8; mo->vely = pr_feathers.Random2() << 8; diff --git a/src/g_heretic/a_dsparil.cpp b/src/g_heretic/a_dsparil.cpp index d7e976d99..ba90335a7 100644 --- a/src/g_heretic/a_dsparil.cpp +++ b/src/g_heretic/a_dsparil.cpp @@ -78,17 +78,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_Srcr1Attack) const PClass *fx = PClass::FindClass("SorcererFX1"); if (self->health > (self->SpawnHealth()/3)*2) { // Spit one fireball - P_SpawnMissileZ (self, self->z + 48*FRACUNIT, self->target, fx ); + P_SpawnMissileZ (self, self->Z() + 48*FRACUNIT, self->target, fx ); } else { // Spit three fireballs - mo = P_SpawnMissileZ (self, self->z + 48*FRACUNIT, self->target, fx); + mo = P_SpawnMissileZ (self, self->Z() + 48*FRACUNIT, self->target, fx); if (mo != NULL) { velz = mo->velz; angle = mo->angle; - P_SpawnMissileAngleZ (self, self->z + 48*FRACUNIT, fx, angle-ANGLE_1*3, velz); - P_SpawnMissileAngleZ (self, self->z + 48*FRACUNIT, fx, angle+ANGLE_1*3, velz); + P_SpawnMissileAngleZ (self, self->Z() + 48*FRACUNIT, fx, angle-ANGLE_1*3, velz); + P_SpawnMissileAngleZ (self, self->Z() + 48*FRACUNIT, fx, angle+ANGLE_1*3, velz); } if (self->health < self->SpawnHealth()/3) { // Maybe attack again @@ -116,7 +116,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcererRise) AActor *mo; self->flags &= ~MF_SOLID; - mo = Spawn("Sorcerer2", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn("Sorcerer2", self->Pos(), ALLOW_REPLACE); mo->Translation = self->Translation; mo->SetState (mo->FindState("Rise")); mo->angle = self->angle; diff --git a/src/g_heretic/a_hereticimp.cpp b/src/g_heretic/a_hereticimp.cpp index 221fe49fb..71c9debc4 100644 --- a/src/g_heretic/a_hereticimp.cpp +++ b/src/g_heretic/a_hereticimp.cpp @@ -41,12 +41,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_ImpExplode) self->flags &= ~MF_NOGRAVITY; - chunk = Spawn("HereticImpChunk1", self->x, self->y, self->z, ALLOW_REPLACE); + chunk = Spawn("HereticImpChunk1", self->Pos(), ALLOW_REPLACE); chunk->velx = pr_imp.Random2 () << 10; chunk->vely = pr_imp.Random2 () << 10; chunk->velz = 9*FRACUNIT; - chunk = Spawn("HereticImpChunk2", self->x, self->y, self->z, ALLOW_REPLACE); + chunk = Spawn("HereticImpChunk2", self->Pos(), ALLOW_REPLACE); chunk->velx = pr_imp.Random2 () << 10; chunk->vely = pr_imp.Random2 () << 10; chunk->velz = 9*FRACUNIT; diff --git a/src/g_heretic/a_hereticmisc.cpp b/src/g_heretic/a_hereticmisc.cpp index 279635482..b495545a2 100644 --- a/src/g_heretic/a_hereticmisc.cpp +++ b/src/g_heretic/a_hereticmisc.cpp @@ -57,7 +57,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PodPain) } for (count = chance > 240 ? 2 : 1; count; count--) { - goo = Spawn(gootype, self->x, self->y, self->z + 48*FRACUNIT, ALLOW_REPLACE); + goo = Spawn(gootype, self->X(), self->Y(), self->Z() + 48*FRACUNIT, ALLOW_REPLACE); goo->target = self; goo->velx = pr_podpain.Random2() << 9; goo->vely = pr_podpain.Random2() << 9; diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index 247ccb03f..997efe212 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -382,14 +382,13 @@ void FireMacePL1B (AActor *actor) if (!weapon->DepleteAmmo (weapon->bAltFire)) return; } - ball = Spawn("MaceFX2", actor->x, actor->y, actor->z + 28*FRACUNIT - - actor->floorclip, ALLOW_REPLACE); + ball = Spawn("MaceFX2", actor->X(), actor->Y(), actor->Z() + 28*FRACUNIT - actor->floorclip, ALLOW_REPLACE); ball->velz = 2*FRACUNIT+/*((player->lookdir)<<(FRACBITS-5))*/ finetangent[FINEANGLES/4-(actor->pitch>>ANGLETOFINESHIFT)]; angle = actor->angle; ball->target = actor; ball->angle = angle; - ball->z += 2*finetangent[FINEANGLES/4-(actor->pitch>>ANGLETOFINESHIFT)]; + ball->SetZ(ball->Z() + 2*finetangent[FINEANGLES/4-(actor->pitch>>ANGLETOFINESHIFT)]); angle >>= ANGLETOFINESHIFT; ball->velx = (actor->velx>>1) + FixedMul(ball->Speed, finecosine[angle]); ball->vely = (actor->vely>>1) + FixedMul(ball->Speed, finesine[angle]); @@ -508,10 +507,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaceBallImpact2) if (self->flags & MF_INBOUNCE) { - fixed_t floordist = self->z - self->floorz; - fixed_t ceildist = self->ceilingz - self->z; + fixed_t floordist = self->Z() - self->floorz; + fixed_t ceildist = self->ceilingz - self->Z(); fixed_t vel; + // NOTE: The assumptions being made here about the plane to use for bouncing off are dead wrong. + // http://forum.zdoom.org/viewtopic.php?f=2&t=50449 if (floordist <= ceildist) { vel = MulScale32 (self->velz, self->Sector->floorplane.c); @@ -529,7 +530,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaceBallImpact2) self->velz = (self->velz * 192) >> 8; self->SetState (self->SpawnState); - tiny = Spawn("MaceFX3", self->x, self->y, self->z, ALLOW_REPLACE); + tiny = Spawn("MaceFX3", self->Pos(), ALLOW_REPLACE); angle = self->angle+ANG90; tiny->target = self->target; tiny->angle = angle; @@ -539,7 +540,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaceBallImpact2) tiny->velz = self->velz; P_CheckMissileSpawn (tiny, self->radius); - tiny = Spawn("MaceFX3", self->x, self->y, self->z, ALLOW_REPLACE); + tiny = Spawn("MaceFX3", self->Pos(), ALLOW_REPLACE); angle = self->angle-ANG90; tiny->target = self->target; tiny->angle = angle; @@ -611,17 +612,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_DeathBallImpact) bool newAngle; AActor *linetarget; - if ((self->z <= self->floorz) && P_HitFloor (self)) + if ((self->Z() <= self->floorz) && P_HitFloor (self)) { // Landed in some sort of liquid self->Destroy (); return; } if (self->flags & MF_INBOUNCE) { - fixed_t floordist = self->z - self->floorz; - fixed_t ceildist = self->ceilingz - self->z; + fixed_t floordist = self->Z() - self->floorz; + fixed_t ceildist = self->ceilingz - self->Z(); fixed_t vel; + // NOTE: The assumptions being made here about the plane to use for bouncing off are dead wrong. + // http://forum.zdoom.org/viewtopic.php?f=2&t=50449 if (floordist <= ceildist) { vel = MulScale32 (self->velz, self->Sector->floorplane.c); @@ -720,7 +723,7 @@ void ABlasterFX1::Effect () { if (pr_bfx1t() < 64) { - Spawn("BlasterSmoke", x, y, MAX (z - 8 * FRACUNIT, floorz), ALLOW_REPLACE); + Spawn("BlasterSmoke", X(), Y(), MAX (Z() - 8 * FRACUNIT, floorz), ALLOW_REPLACE); } } @@ -799,7 +802,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnRippers) for(i = 0; i < 8; i++) { - ripper = Spawn (self->x, self->y, self->z, ALLOW_REPLACE); + ripper = Spawn (self->Pos(), ALLOW_REPLACE); angle = i*ANG45; ripper->target = self->target; ripper->angle = angle; @@ -1007,8 +1010,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_AddPlayerRain) DEFINE_ACTION_FUNCTION(AActor, A_SkullRodStorm) { - fixed_t x; - fixed_t y; AActor *mo; ARainTracker *tracker; @@ -1039,20 +1040,21 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullRodStorm) { // Fudge rain frequency return; } - x = self->x + ((pr_storm()&127) - 64) * FRACUNIT; - y = self->y + ((pr_storm()&127) - 64) * FRACUNIT; - mo = Spawn (x, y, ONCEILINGZ, ALLOW_REPLACE); + fixedvec2 pos = self->Vec2Offset( + ((pr_storm()&127) - 64) * FRACUNIT, + ((pr_storm()&127) - 64) * FRACUNIT); + mo = Spawn (pos.x, pos.y, ONCEILINGZ, ALLOW_REPLACE); // We used bouncecount to store the 3D floor index in A_HideInCeiling if (!mo) return; fixed_t newz; if (self->bouncecount >= 0 && (unsigned)self->bouncecount < self->Sector->e->XFloor.ffloors.Size()) - newz = self->Sector->e->XFloor.ffloors[self->bouncecount]->bottom.plane->ZatPoint(x, y);// - 40 * FRACUNIT; + newz = self->Sector->e->XFloor.ffloors[self->bouncecount]->bottom.plane->ZatPoint(pos.x, pos.y);// - 40 * FRACUNIT; else - newz = self->Sector->ceilingplane.ZatPoint(x, y); - int moceiling = P_Find3DFloor(NULL, x, y, newz, false, false, newz); + newz = self->Sector->ceilingplane.ZatPoint(pos.x, pos.y); + int moceiling = P_Find3DFloor(NULL, pos.x, pos.y, newz, false, false, newz); if (moceiling >= 0) - mo->z = newz - mo->height; + mo->SetZ(newz - mo->height, false); mo->Translation = multiplayer ? TRANSLATION(TRANSLATION_PlayersExtra,self->special2) : 0; mo->target = self->target; @@ -1074,7 +1076,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkullRodStorm) DEFINE_ACTION_FUNCTION(AActor, A_RainImpact) { - if (self->z > self->floorz) + if (self->Z() > self->floorz) { self->SetState (self->FindState("NotFloor")); } @@ -1099,15 +1101,15 @@ DEFINE_ACTION_FUNCTION(AActor, A_HideInCeiling) F3DFloor * rover = self->Sector->e->XFloor.ffloors[i]; if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - if ((foo = rover->bottom.plane->ZatPoint(self)) >= (self->z + self->height)) + if ((foo = rover->bottom.plane->ZatPoint(self)) >= (self->Top())) { - self->z = foo + 4*FRACUNIT; + self->SetZ(foo + 4*FRACUNIT, false); self->bouncecount = i; return; } } self->bouncecount = -1; - self->z = self->ceilingz + 4*FRACUNIT; + self->SetZ(self->ceilingz + 4*FRACUNIT, false); } // --- Phoenix Rod ---------------------------------------------------------- @@ -1225,13 +1227,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_PhoenixPuff) //[RH] Heretic never sets the target for seeking //P_SeekerMissile (self, ANGLE_1*5, ANGLE_1*10); - puff = Spawn("PhoenixPuff", self->x, self->y, self->z, ALLOW_REPLACE); + puff = Spawn("PhoenixPuff", self->Pos(), ALLOW_REPLACE); angle = self->angle + ANG90; angle >>= ANGLETOFINESHIFT; puff->velx = FixedMul (FRACUNIT*13/10, finecosine[angle]); puff->vely = FixedMul (FRACUNIT*13/10, finesine[angle]); puff->velz = 0; - puff = Spawn("PhoenixPuff", self->x, self->y, self->z, ALLOW_REPLACE); + puff = Spawn("PhoenixPuff", self->Pos(), ALLOW_REPLACE); angle = self->angle - ANG90; angle >>= ANGLETOFINESHIFT; puff->velx = FixedMul (FRACUNIT*13/10, finecosine[angle]); @@ -1269,7 +1271,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2) { AActor *mo; angle_t angle; - fixed_t x, y, z; fixed_t slope; FSoundID soundid; @@ -1292,12 +1293,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_FirePhoenixPL2) return; } angle = self->angle; - x = self->x + (pr_fp2.Random2() << 9); - y = self->y + (pr_fp2.Random2() << 9); - z = self->z + 26*FRACUNIT + finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)]; - z -= self->floorclip; + + fixedvec3 pos = self->Vec3Offset( + (pr_fp2.Random2() << 9), + (pr_fp2.Random2() << 9), + 26*FRACUNIT + finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)] - self->floorclip); + slope = finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)] + (FRACUNIT/10); - mo = Spawn("PhoenixFX2", x, y, z, ALLOW_REPLACE); + mo = Spawn("PhoenixFX2", pos, ALLOW_REPLACE); mo->target = self; mo->angle = angle; mo->velx = self->velx + FixedMul (mo->Speed, finecosine[angle>>ANGLETOFINESHIFT]); diff --git a/src/g_heretic/a_ironlich.cpp b/src/g_heretic/a_ironlich.cpp index 75c05bf2b..dd8122318 100644 --- a/src/g_heretic/a_ironlich.cpp +++ b/src/g_heretic/a_ironlich.cpp @@ -106,8 +106,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack) baseFire->SetState (baseFire->FindState("NoGrow")); for (i = 0; i < 5; i++) { - fire = Spawn("HeadFX3", baseFire->x, baseFire->y, - baseFire->z, ALLOW_REPLACE); + fire = Spawn("HeadFX3", baseFire->Pos(), ALLOW_REPLACE); if (i == 0) { S_Sound (self, CHAN_BODY, "ironlich/attack1", 1, ATTN_NORM); @@ -128,7 +127,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack) mo = P_SpawnMissile (self, target, RUNTIME_CLASS(AWhirlwind)); if (mo != NULL) { - mo->z -= 32*FRACUNIT; + mo->SetZ(mo->Z() - 32*FRACUNIT, false); mo->tracer = target; mo->special1 = 60; mo->special2 = 50; // Timer for active sound @@ -180,7 +179,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichIceImpact) for (i = 0; i < 8; i++) { - shard = Spawn("HeadFX2", self->x, self->y, self->z, ALLOW_REPLACE); + shard = Spawn("HeadFX2", self->Pos(), ALLOW_REPLACE); angle = i*ANG45; shard->target = self->target; shard->angle = angle; @@ -201,7 +200,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichIceImpact) DEFINE_ACTION_FUNCTION(AActor, A_LichFireGrow) { self->health--; - self->z += 9*FRACUNIT; + self->SetZ(self->Z + 9*FRACUNIT); if (self->health == 0) { self->Damage = self->GetDefault()->Damage; diff --git a/src/g_heretic/a_knight.cpp b/src/g_heretic/a_knight.cpp index 18280326a..a12dc658e 100644 --- a/src/g_heretic/a_knight.cpp +++ b/src/g_heretic/a_knight.cpp @@ -24,9 +24,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_DripBlood) AActor *mo; fixed_t x, y; - x = self->x + (pr_dripblood.Random2 () << 11); - y = self->y + (pr_dripblood.Random2 () << 11); - mo = Spawn ("Blood", x, y, self->z, ALLOW_REPLACE); + fixedvec3 pos = self->Vec3Offset( + (pr_dripblood.Random2 () << 11), + (pr_dripblood.Random2 () << 11), 0); + mo = Spawn ("Blood", pos, ALLOW_REPLACE); mo->velx = pr_dripblood.Random2 () << 10; mo->vely = pr_dripblood.Random2 () << 10; mo->gravity = FRACUNIT/8; @@ -56,10 +57,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_KnightAttack) S_Sound (self, CHAN_BODY, self->AttackSound, 1, ATTN_NORM); if (self->flags & MF_SHADOW || pr_knightatk () < 40) { // Red axe - P_SpawnMissileZ (self, self->z + 36*FRACUNIT, self->target, PClass::FindClass("RedAxe")); + P_SpawnMissileZ (self, self->Z() + 36*FRACUNIT, self->target, PClass::FindClass("RedAxe")); return; } // Green axe - P_SpawnMissileZ (self, self->z + 36*FRACUNIT, self->target, PClass::FindClass("KnightAxe")); + P_SpawnMissileZ (self, self->Z() + 36*FRACUNIT, self->target, PClass::FindClass("KnightAxe")); } From c1b44a56943a37f363f0028587abac68111537e1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jan 2016 21:01:52 +0100 Subject: [PATCH 09/18] - let's make some use of AActor::Pos and get rid of some of those X() and Y() calls... - restore proper actor.h file. --- src/actor.h | 76 ++++++++++++++++---------------- src/b_func.cpp | 2 +- src/d_dehacked.cpp | 2 +- src/fragglescript/t_func.cpp | 2 +- src/g_doom/a_bossbrain.cpp | 2 +- src/g_doom/a_doomweaps.cpp | 3 +- src/g_doom/a_fatso.cpp | 2 +- src/g_doom/a_painelemental.cpp | 4 +- src/g_doom/a_revenant.cpp | 2 +- src/g_heretic/a_chicken.cpp | 2 +- src/g_heretic/a_dsparil.cpp | 6 +-- src/g_heretic/a_hereticmisc.cpp | 14 +++--- src/g_heretic/a_hereticweaps.cpp | 2 +- src/g_heretic/a_ironlich.cpp | 2 +- src/p_3dfloors.h | 4 ++ src/p_enemy.cpp | 6 +-- src/p_local.h | 12 +++++ src/p_things.cpp | 4 +- 18 files changed, 81 insertions(+), 66 deletions(-) diff --git a/src/actor.h b/src/actor.h index b12699558..46d9ae046 100644 --- a/src/actor.h +++ b/src/actor.h @@ -847,7 +847,7 @@ public: bool intersects(AActor *other) const { fixed_t blockdist = radius + other->radius; - return ( abs(pos.x - other->pos.x) < blockdist && abs(pos.y - other->pos.y) < blockdist); + return ( abs(x - other->x) < blockdist && abs(y - other->y) < blockdist); } PalEntry GetBloodColor() const @@ -888,99 +888,99 @@ public: // to distinguish between portal-aware and portal-unaware distance calculation. fixed_t AproxDistance(AActor *other, bool absolute = false) { - return P_AproxDistance(pos.x - other->pos.x, pos.y - other->pos.y); + return P_AproxDistance(x - other->x, y - other->y); } // same with 'ref' here. fixed_t AproxDistance(fixed_t otherx, fixed_t othery, AActor *ref = NULL) { - return P_AproxDistance(pos.x - otherx, pos.y - othery); + return P_AproxDistance(x - otherx, y - othery); } fixed_t AproxDistance(AActor *other, fixed_t xadd, fixed_t yadd, bool absolute = false) { - return P_AproxDistance(pos.x - other->pos.x + xadd, pos.y - other->pos.y + yadd); + return P_AproxDistance(x - other->x + xadd, y - other->y + yadd); } fixed_t AproxDistance3D(AActor *other, bool absolute = false) { - return P_AproxDistance(AproxDistance(other), pos.z - other->pos.z); + return P_AproxDistance(AproxDistance(other), z - other->z); } // more precise, but slower version, being used in a few places fixed_t Distance2D(AActor *other, bool absolute = false) { - return xs_RoundToInt(FVector2(pos.x - other->pos.x, pos.y - other->pos.y).Length()); + return xs_RoundToInt(FVector2(x - other->x, y - other->y).Length()); } // a full 3D version of the above fixed_t Distance3D(AActor *other, bool absolute = false) { - return xs_RoundToInt(FVector3(pos.x - other->pos.x, pos.y - other->pos.y, pos.z - other->pos.z).Length()); + return xs_RoundToInt(FVector3(x - other->x, y - other->y, z - other->z).Length()); } angle_t AngleTo(AActor *other, bool absolute = false) const { - return R_PointToAngle2(pos.x, pos.y, other->pos.x, other->pos.y); + return R_PointToAngle2(x, y, other->x, other->y); } angle_t AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const { - return R_PointToAngle2(pos.x, pos.y, other->pos.x + oxofs, other->pos.y + oyofs); + return R_PointToAngle2(x, y, other->x + oxofs, other->y + oyofs); } fixed_t AngleTo(fixed_t otherx, fixed_t othery, AActor *ref = NULL) { - return R_PointToAngle2(pos.x, pos.y, otherx, othery); + return R_PointToAngle2(x, y, otherx, othery); } fixed_t AngleXYTo(fixed_t myx, fixed_t myy, AActor *other, bool absolute = false) { - return R_PointToAngle2(myx, myy, other->pos.x, other->pos.y); + return R_PointToAngle2(myx, myy, other->x, other->y); } fixedvec2 Vec2To(AActor *other) const { - fixedvec2 ret = { other->pos.x - pos.x, other->pos.y - pos.y }; + fixedvec2 ret = { other->x - x, other->y - y }; return ret; } fixedvec3 Vec3To(AActor *other) const { - fixedvec3 ret = { other->pos.x - pos.x, other->pos.y - pos.y, other->pos.z - pos.z }; + fixedvec3 ret = { other->x - x, other->y - y, other->z - z }; return ret; } fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false) const { - fixedvec2 ret = { pos.x + dx, pos.y + dy }; + fixedvec2 ret = { x + dx, y + dy }; return ret; } fixedvec2 Vec2Angle(fixed_t length, angle_t angle, bool absolute = false) const { - fixedvec2 ret = { pos.x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), - pos.y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) }; + fixedvec2 ret = { x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), + y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) }; return ret; } fixedvec3 Vec3Offset(fixed_t dx, fixed_t dy, fixed_t dz, bool absolute = false) const { - fixedvec3 ret = { pos.x + dx, pos.y + dy, pos.z + dz }; + fixedvec3 ret = { x + dx, y + dy, z + dz }; return ret; } fixedvec3 Vec3Angle(fixed_t length, angle_t angle, fixed_t dz, bool absolute = false) const { - fixedvec3 ret = { pos.x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), - pos.y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), pos.z + dz }; + fixedvec3 ret = { x + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), + y + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), z + dz }; return ret; } void Move(fixed_t dx, fixed_t dy, fixed_t dz) { - SetOrigin(pos.x + dx, pos.y + dy, pos.z + dz, true); + SetOrigin(x + dx, y + dy, z + dz, true); } void SetOrigin(const fixedvec3 & npos, bool moving) @@ -1007,10 +1007,7 @@ public: // info for drawing // NOTE: The first member variable *must* be x. -private: - fixedvec3 pos; -public: - //fixed_t x,y,z; + fixed_t x,y,z; AActor *snext, **sprev; // links in sector (if needed) angle_t angle; WORD sprite; // used to find patch_t and flip value @@ -1208,7 +1205,7 @@ public: void LinkToWorld (sector_t *sector); void UnlinkFromWorld (); void AdjustFloorClip (); - void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving); + void SetOrigin (fixed_t x, fixed_t y, fixed_t z, bool moving = false); bool InStateSequence(FState * newstate, FState * basestate); int GetTics(FState * newstate); bool SetState (FState *newstate, bool nofunction=false); @@ -1240,41 +1237,46 @@ public: fixed_t X() const { - return pos.x; + return x; } fixed_t Y() const { - return pos.y; + return y; } fixed_t Z() const { - return pos.z; + return z; } fixedvec3 Pos() const { fixedvec3 ret = { X(), Y(), Z() }; return ret; } + fixedvec3 PosPlusZ(fixed_t zadd) const + { + fixedvec3 ret = { X(), Y(), Z() + zadd }; + return ret; + } fixed_t Top() const { - return pos.z + height; + return z + height; } void SetZ(fixed_t newz, bool moving = true) { - pos.z = newz; + z = newz; } // These are not for general use as they do not link the actor into the world! - void SetXY(fixed_t x, fixed_t y) + void SetXY(fixed_t xx, fixed_t yy) { - pos.x = x; - pos.y = y; + x = xx; + y = yy; } - void SetXYZ(fixed_t x, fixed_t y, fixed_t z) + void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz) { - pos.x = x; - pos.y = y; - pos.z = z; + x = xx; + y = yy; + z = zz; } }; diff --git a/src/b_func.cpp b/src/b_func.cpp index cc8d9808a..eb86beba8 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -459,7 +459,7 @@ void FCajunMaster::SetBodyAt (fixed_t x, fixed_t y, fixed_t z, int hostnum) //Emulates missile travel. Returns distance travelled. fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd) { - AActor *th = Spawn ("CajunTrace", source->X(), source->Y(), source->Z() + 4*8*FRACUNIT, NO_REPLACE); + AActor *th = Spawn ("CajunTrace", source->PosPlusZ(4*8*FRACUNIT), NO_REPLACE); th->target = source; // where it came from diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 31ff05b64..35abd13a8 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -3056,7 +3056,7 @@ bool ADehackedPickup::TryPickup (AActor *&toucher) { return false; } - RealPickup = static_cast(Spawn (type, X(), Y(), Z(), NO_REPLACE)); + RealPickup = static_cast(Spawn (type, Pos(), NO_REPLACE)); if (RealPickup != NULL) { // The internally spawned item should never count towards statistics. diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 2381ad381..0945b1b4f 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -4281,7 +4281,7 @@ void FParser::SF_SpawnShot2(void) t_return.type = svt_mobj; - AActor *mo = Spawn (PClass, source->X(), source->Y(), source->Z()+z, ALLOW_REPLACE); + AActor *mo = Spawn (PClass, source->PosPlusZ(z), ALLOW_REPLACE); if (mo) { S_Sound (mo, CHAN_VOICE, mo->SeeSound, 1, ATTN_NORM); diff --git a/src/g_doom/a_bossbrain.cpp b/src/g_doom/a_bossbrain.cpp index f69acd789..29bdd2be1 100644 --- a/src/g_doom/a_bossbrain.cpp +++ b/src/g_doom/a_bossbrain.cpp @@ -275,7 +275,7 @@ static void SpawnFly(AActor *self, const PClass *spawntype, FSoundID sound) if (!(newmobj->ObjectFlags & OF_EuthanizeMe)) { // telefrag anything in this spot - P_TeleportMove (newmobj, newmobj->X(), newmobj->Y(), newmobj->Z(), true); + P_TeleportMove (newmobj, newmobj->Pos(), true); } newmobj->flags4 |= MF4_BOSSSPAWNED; } diff --git a/src/g_doom/a_doomweaps.cpp b/src/g_doom/a_doomweaps.cpp index 85335587e..4021ad206 100644 --- a/src/g_doom/a_doomweaps.cpp +++ b/src/g_doom/a_doomweaps.cpp @@ -612,8 +612,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BFGSpray) if (linetarget != NULL) { - AActor *spray = Spawn(spraytype, linetarget->X(), linetarget->Y(), - linetarget->Z() + (linetarget->height >> 2), ALLOW_REPLACE); + AActor *spray = Spawn(spraytype, linetarget->PosPlusZ(linetarget->height >> 2), ALLOW_REPLACE); int dmgFlags = 0; FName dmgType = NAME_BFGSplash; diff --git a/src/g_doom/a_fatso.cpp b/src/g_doom/a_fatso.cpp index 370e3fc69..9273febda 100644 --- a/src/g_doom/a_fatso.cpp +++ b/src/g_doom/a_fatso.cpp @@ -145,7 +145,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Mushroom) P_CheckSplash(self, 128<X(), self->Y(), self->Z(), NO_REPLACE); // We need something to aim at. + AActor *target = Spawn("Mapspot", self->Pos(), NO_REPLACE); // We need something to aim at. AActor *master = (flags & MSF_DontHurt) ? (AActor*)(self->target) : self; target->height = self->height; for (i = -n; i <= n; i += 8) diff --git a/src/g_doom/a_painelemental.cpp b/src/g_doom/a_painelemental.cpp index cb5205a76..69d6ef448 100644 --- a/src/g_doom/a_painelemental.cpp +++ b/src/g_doom/a_painelemental.cpp @@ -80,7 +80,7 @@ void A_PainShootSkull (AActor *self, angle_t angle, const PClass *spawntype, int fixedvec2 dist = Vec2Angle(prestep, angle); fixedvec3 pos = self->Vec3Offset(dist.x, dist.y, 8 * FRACUNIT, true); - fixedvec3 src = { self->X(), self->Y(), self->Z() }; + fixedvec3 src = self->Pos(); for (int i = 0; i < 2; i++) { @@ -142,7 +142,7 @@ void A_PainShootSkull (AActor *self, angle_t angle, const PClass *spawntype, int // Check for movements. - if (!P_CheckPosition (other, other->X(), other->Y())) + if (!P_CheckPosition (other, other->Pos())) { // kill it immediately P_DamageMobj (other, self, self, TELEFRAG_DAMAGE, NAME_None); diff --git a/src/g_doom/a_revenant.cpp b/src/g_doom/a_revenant.cpp index 162cfd5fa..9b8821fb4 100644 --- a/src/g_doom/a_revenant.cpp +++ b/src/g_doom/a_revenant.cpp @@ -31,7 +31,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SkelMissile) if (missile != NULL) { - missile->SetOrigin(missile->X() + missile->velx, missile->Y() + missile->vely, missile->Z(), false); + missile->SetOrigin(missile->Vec3Offset(missile->velx, missile->vely, 0), false); missile->tracer = self->target; } } diff --git a/src/g_heretic/a_chicken.cpp b/src/g_heretic/a_chicken.cpp index 3fcb15380..329b4d264 100644 --- a/src/g_heretic/a_chicken.cpp +++ b/src/g_heretic/a_chicken.cpp @@ -100,7 +100,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Feathers) } for (i = 0; i < count; i++) { - mo = Spawn("Feather", self->X(), self->Y(), self->Z()+20*FRACUNIT, NO_REPLACE); + mo = Spawn("Feather", self->PosPlusZ(20*FRACUNIT), NO_REPLACE); mo->target = self; mo->velx = pr_feathers.Random2() << 8; mo->vely = pr_feathers.Random2() << 8; diff --git a/src/g_heretic/a_dsparil.cpp b/src/g_heretic/a_dsparil.cpp index ba90335a7..d2bed5b68 100644 --- a/src/g_heretic/a_dsparil.cpp +++ b/src/g_heretic/a_dsparil.cpp @@ -146,7 +146,7 @@ void P_DSparilTeleport (AActor *actor) prevX = actor->X(); prevY = actor->Y(); prevZ = actor->Z(); - if (P_TeleportMove (actor, spot->X(), spot->Y(), spot->Z(), false)) + if (P_TeleportMove (actor, spot->Pos(), false)) { mo = Spawn("Sorcerer2Telefade", prevX, prevY, prevZ, ALLOW_REPLACE); if (mo) mo->Translation = actor->Translation; @@ -254,7 +254,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenWizard) { AActor *mo; - mo = Spawn("Wizard", self->X(), self->Y(), self->Z(), ALLOW_REPLACE); + mo = Spawn("Wizard", self->Pos(), ALLOW_REPLACE); if (mo != NULL) { mo->SetZ(mo->Z() - mo->GetDefault()->height / 2, false); @@ -272,7 +272,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenWizard) self->flags &= ~MF_MISSILE; mo->master = self->target; // Heretic did not offset it by TELEFOGHEIGHT, so I won't either. - Spawn (self->X(), self->Y(), self->Z(), ALLOW_REPLACE); + Spawn (self->Pos(), ALLOW_REPLACE); } } } diff --git a/src/g_heretic/a_hereticmisc.cpp b/src/g_heretic/a_hereticmisc.cpp index b495545a2..5a2b8dbec 100644 --- a/src/g_heretic/a_hereticmisc.cpp +++ b/src/g_heretic/a_hereticmisc.cpp @@ -57,7 +57,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_PodPain) } for (count = chance > 240 ? 2 : 1; count; count--) { - goo = Spawn(gootype, self->X(), self->Y(), self->Z() + 48*FRACUNIT, ALLOW_REPLACE); + goo = Spawn(gootype, self->PosPlusZ(48*FRACUNIT), ALLOW_REPLACE); goo->target = self; goo->velx = pr_podpain.Random2() << 9; goo->vely = pr_podpain.Random2() << 9; @@ -100,15 +100,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_MakePod) AActor *mo; fixed_t x; fixed_t y; - fixed_t z; if (self->special1 == MAX_GEN_PODS) { // Too many generated pods return; } - x = self->x; - y = self->y; - z = self->z; + x = self->X(); + y = self->Y(); mo = Spawn(podtype, x, y, ONFLOORZ, ALLOW_REPLACE); if (!P_CheckPosition (mo, x, y)) { // Didn't fit @@ -191,17 +189,17 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact) AActor *tiny; angle_t angle; - if (self->z <= self->floorz) + if (self->Z() <= self->floorz) { self->flags |= MF_NOGRAVITY; self->gravity = FRACUNIT; - self->z += 28*FRACUNIT; + self->SetZ(self->Z() + 28*FRACUNIT); //self->velz = 3*FRACUNIT; } P_RadiusAttack (self, self->target, 25, 25, NAME_Fire, RADF_HURTSOURCE); for (i = 0; i < 4; i++) { - tiny = Spawn("VolcanoTBlast", self->x, self->y, self->z, ALLOW_REPLACE); + tiny = Spawn("VolcanoTBlast", self->Pos(), ALLOW_REPLACE); tiny->target = self; angle = i*ANG90; tiny->angle = angle; diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index 997efe212..2121bf5a2 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -382,7 +382,7 @@ void FireMacePL1B (AActor *actor) if (!weapon->DepleteAmmo (weapon->bAltFire)) return; } - ball = Spawn("MaceFX2", actor->X(), actor->Y(), actor->Z() + 28*FRACUNIT - actor->floorclip, ALLOW_REPLACE); + ball = Spawn("MaceFX2", actor->PosPlusZ(28*FRACUNIT - actor->floorclip), ALLOW_REPLACE); ball->velz = 2*FRACUNIT+/*((player->lookdir)<<(FRACBITS-5))*/ finetangent[FINEANGLES/4-(actor->pitch>>ANGLETOFINESHIFT)]; angle = actor->angle; diff --git a/src/g_heretic/a_ironlich.cpp b/src/g_heretic/a_ironlich.cpp index dd8122318..b09864bd0 100644 --- a/src/g_heretic/a_ironlich.cpp +++ b/src/g_heretic/a_ironlich.cpp @@ -200,7 +200,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichIceImpact) DEFINE_ACTION_FUNCTION(AActor, A_LichFireGrow) { self->health--; - self->SetZ(self->Z + 9*FRACUNIT); + self->SetZ(self->Z() + 9*FRACUNIT); if (self->health == 0) { self->Damage = self->GetDefault()->Damage; diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index 8abd23f03..0dfdf872c 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -144,6 +144,10 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li secplane_t P_FindFloorPlane(sector_t * sector, fixed_t x, fixed_t y, fixed_t z); int P_Find3DFloor(sector_t * sec, fixed_t x, fixed_t y, fixed_t z, bool above, bool floor, fixed_t &cmpz); +inline int P_Find3DFloor(sector_t * sec, const fixedvec3 &pos, bool above, bool floor, fixed_t &cmpz) +{ + return P_Find3DFloor(sec, pos.x, pos.y, pos.z, above, floor, cmpz); +} #endif \ No newline at end of file diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index d8230a031..14d417679 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2547,8 +2547,8 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) if (testsec) { fixed_t zdist1, zdist2; - if (P_Find3DFloor(testsec, corpsehit->X(), corpsehit->Y(), corpsehit->Z(), false, true, zdist1) - != P_Find3DFloor(testsec, self->X(), self->Y(), self->Z(), false, true, zdist2)) + if (P_Find3DFloor(testsec, corpsehit->Pos(), false, true, zdist1) + != P_Find3DFloor(testsec, self->Pos(), false, true, zdist2)) { // Not on same floor if (vilesec == corpsec || abs(zdist1 - self->Z()) > self->height) @@ -2565,7 +2565,7 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) corpsehit->flags |= MF_SOLID; corpsehit->height = corpsehit->GetDefault()->height; - bool check = P_CheckPosition(corpsehit, corpsehit->X(), corpsehit->Y()); + bool check = P_CheckPosition(corpsehit, corpsehit->Pos()); corpsehit->flags = oldflags; corpsehit->radius = oldradius; corpsehit->height = oldheight; diff --git a/src/p_local.h b/src/p_local.h index 7e00276bd..8c4a94bfc 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -134,6 +134,10 @@ enum EPuffFlags }; AActor *P_SpawnPuff (AActor *source, const PClass *pufftype, fixed_t x, fixed_t y, fixed_t z, angle_t dir, int updown, int flags = 0, AActor *vict = NULL); +inline AActor *P_SpawnPuff(AActor *source, const PClass *pufftype, const fixedvec3 &pos, angle_t dir, int updown, int flags = 0, AActor *vict = NULL) +{ + return P_SpawnPuff(source, pufftype, pos.x, pos.y, pos.z, dir, updown, flags, vict); +} void P_SpawnBlood (fixed_t x, fixed_t y, fixed_t z, angle_t dir, int damage, AActor *originator); void P_BloodSplatter (fixed_t x, fixed_t y, fixed_t z, AActor *originator); void P_BloodSplatter2 (fixed_t x, fixed_t y, fixed_t z, AActor *originator); @@ -458,6 +462,10 @@ bool P_TestMobjLocation (AActor *mobj); bool P_TestMobjZ (AActor *mobj, bool quick=true, AActor **pOnmobj = NULL); bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bool actorsonly=false); bool P_CheckPosition (AActor *thing, fixed_t x, fixed_t y, bool actorsonly=false); +inline bool P_CheckPosition(AActor *thing, const fixedvec3 &pos, bool actorsonly = false) +{ + return P_CheckPosition(thing, pos.x, pos.y, actorsonly); +} AActor *P_CheckOnmobj (AActor *thing); void P_FakeZMovement (AActor *mo); bool P_TryMove (AActor* thing, fixed_t x, fixed_t y, int dropoff, const secplane_t * onfloor, FCheckPosition &tm, bool missileCheck = false); @@ -465,6 +473,10 @@ bool P_TryMove (AActor* thing, fixed_t x, fixed_t y, int dropoff, const secplane bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y); void P_ApplyTorque(AActor *mo); bool P_TeleportMove (AActor* thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag, bool modifyactor = true); // [RH] Added z and telefrag parameters +inline bool P_TeleportMove(AActor* thing, const fixedvec3 &pos, bool telefrag, bool modifyactor = true) +{ + return P_TeleportMove(thing, pos.x, pos.y, pos.z, telefrag, modifyactor); +} void P_PlayerStartStomp (AActor *actor); // [RH] Stomp on things for a newly spawned player void P_SlideMove (AActor* mo, fixed_t tryx, fixed_t tryy, int numsteps); bool P_BounceWall (AActor *mo); diff --git a/src/p_things.cpp b/src/p_things.cpp index 80ce3a5cf..f487128e8 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -436,7 +436,7 @@ bool P_Thing_Raise(AActor *thing, AActor *raiser) thing->flags |= MF_SOLID; thing->height = info->height; // [RH] Use real height thing->radius = info->radius; // [RH] Use real radius - if (!P_CheckPosition (thing, thing->X(), thing->Y())) + if (!P_CheckPosition (thing, thing->Pos())) { thing->flags = oldflags; thing->radius = oldradius; @@ -478,7 +478,7 @@ bool P_Thing_CanRaise(AActor *thing) thing->height = info->height; thing->radius = info->radius; - bool check = P_CheckPosition (thing, thing->X(), thing->Y()); + bool check = P_CheckPosition (thing, thing->Pos()); // Restore checked properties thing->flags = oldflags; From ca5ac723645e991ef3a2a8ced189f28dfb027b13 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jan 2016 21:17:11 +0100 Subject: [PATCH 10/18] - added missing FIXED2DBL call in A_Face. --- src/p_enemy.cpp | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 14d417679..ef2e15955 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2777,9 +2777,7 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a // disabled and is so by default. if (max_pitch <= ANGLE_180) { - // [DH] Don't need to do proper fixed->double conversion, since the - // result is only used in a ratio. - fixedvec2 dist = self->Vec2To(other); + TVector2 dist = self->Vec2To(other); // Positioning ala missile spawning, 32 units above foot level fixed_t source_z = self->Z() + 32*FRACUNIT + self->GetBobOffset(); @@ -2803,8 +2801,8 @@ void A_Face (AActor *self, AActor *other, angle_t max_turn, angle_t max_pitch, a if (!(flags & FAF_NODISTFACTOR)) target_z += pitch_offset; - double dist_z = target_z - source_z; - double ddist = sqrt(dist.x*dist.x + dist.y*dist.y + dist_z*dist_z); + double dist_z = FIXED2DBL(target_z - source_z); + double ddist = sqrt(dist.X*dist.X + dist.Y*dist.Y + dist_z*dist_z); int other_pitch = (int)rad2bam(asin(dist_z / ddist)); if (max_pitch != 0) From 7358817975c4df4bbf34dec4fc963ac22c638239 Mon Sep 17 00:00:00 2001 From: Kyle Evans Date: Mon, 18 Jan 2016 14:45:23 -0600 Subject: [PATCH 11/18] *BinPack fixes -- disjointRects only defined #ifdef _DEBUG --- src/GuillotineBinPack.cpp | 11 ++++++++++- src/SkylineBinPack.cpp | 18 ++++++++++++++++-- 2 files changed, 26 insertions(+), 3 deletions(-) diff --git a/src/GuillotineBinPack.cpp b/src/GuillotineBinPack.cpp index 5efbbf8a1..57dce4501 100644 --- a/src/GuillotineBinPack.cpp +++ b/src/GuillotineBinPack.cpp @@ -144,7 +144,9 @@ void GuillotineBinPack::Insert(TArray &rects, TArray &dst, bool usedRectangles.Push(newNode); // Check that we're really producing correct packings here. +#ifdef _DEBUG assert(disjointRects.Add(newNode) == true); +#endif } } @@ -355,8 +357,9 @@ Rect GuillotineBinPack::Insert(int width, int height, bool merge, FreeRectChoice usedRectangles.Push(newRect); // Check that we're really producing correct packings here. +#ifdef _DEBUG assert(disjointRects.Add(newRect) == true); - +#endif return newRect; } @@ -442,7 +445,9 @@ Rect GuillotineBinPack::FindPositionForNewNode(int width, int height, FreeRectCh bestNode.height = height; bestScore = INT_MIN; *nodeIndex = i; +#ifdef _DEBUG assert(disjointRects.Disjoint(bestNode)); +#endif break; } // If this is a perfect fit sideways, choose it. @@ -470,7 +475,9 @@ Rect GuillotineBinPack::FindPositionForNewNode(int width, int height, FreeRectCh bestNode.height = height; bestScore = score; *nodeIndex = i; +#ifdef _DEBUG assert(disjointRects.Disjoint(bestNode)); +#endif } } // Does the rectangle fit sideways? @@ -575,8 +582,10 @@ void GuillotineBinPack::SplitFreeRectAlongAxis(const Rect &freeRect, const Rect if (right.width > 0 && right.height > 0) freeRectangles.Push(right); +#ifdef _DEBUG assert(disjointRects.Disjoint(bottom)); assert(disjointRects.Disjoint(right)); +#endif } void GuillotineBinPack::MergeFreeList() diff --git a/src/SkylineBinPack.cpp b/src/SkylineBinPack.cpp index cb0be54e1..d63610370 100644 --- a/src/SkylineBinPack.cpp +++ b/src/SkylineBinPack.cpp @@ -69,7 +69,9 @@ void SkylineBinPack::Insert(TArray &rects, TArray &dst) int score2; int index; newNode = FindPositionForNewNodeMinWaste(rects[i].width, rects[i].height, score2, score1, index); +#ifdef _DEBUG assert(disjointRects.Disjoint(newNode)); +#endif if (newNode.height != 0) { if (score1 < bestScore1 || (score1 == bestScore1 && score2 < bestScore2)) @@ -87,8 +89,8 @@ void SkylineBinPack::Insert(TArray &rects, TArray &dst) return; // Perform the actual packing. - assert(disjointRects.Disjoint(bestNode)); #ifdef _DEBUG + assert(disjointRects.Disjoint(bestNode)); disjointRects.Add(bestNode); #endif AddSkylineLevel(bestSkylineIndex, bestNode); @@ -103,7 +105,9 @@ Rect SkylineBinPack::Insert(int width, int height) // First try to pack this rectangle into the waste map, if it fits. Rect node = wasteMap.Insert(width, height, true, GuillotineBinPack::RectBestShortSideFit, GuillotineBinPack::SplitMaximizeArea); +#ifdef _DEBUG assert(disjointRects.Disjoint(node)); +#endif if (node.height != 0) { @@ -113,8 +117,8 @@ Rect SkylineBinPack::Insert(int width, int height) newNode.width = node.width; newNode.height = node.height; usedSurfaceArea += width * height; - assert(disjointRects.Disjoint(newNode)); #ifdef _DEBUG + assert(disjointRects.Disjoint(newNode)); disjointRects.Add(newNode); #endif return newNode; @@ -190,7 +194,9 @@ void SkylineBinPack::AddWasteMapArea(int skylineNodeIndex, int width, int height waste.width = rightSide - leftSide; waste.height = y - skyLine[skylineNodeIndex].y; +#ifdef _DEBUG assert(disjointRects.Disjoint(waste)); +#endif wasteMap.GetFreeRectangles().Push(waste); } } @@ -264,7 +270,9 @@ Rect SkylineBinPack::InsertBottomLeft(int width, int height) if (bestIndex != -1) { +#ifdef _DEBUG assert(disjointRects.Disjoint(newNode)); +#endif // Perform the actual packing. AddSkylineLevel(bestIndex, newNode); @@ -300,7 +308,9 @@ Rect SkylineBinPack::FindPositionForNewNodeBottomLeft(int width, int height, int newNode.y = y; newNode.width = width; newNode.height = height; +#ifdef _DEBUG assert(disjointRects.Disjoint(newNode)); +#endif } } /* if (RectangleFits(i, height, width, y)) @@ -331,7 +341,9 @@ Rect SkylineBinPack::InsertMinWaste(int width, int height) if (bestIndex != -1) { +#ifdef _DEBUG assert(disjointRects.Disjoint(newNode)); +#endif // Perform the actual packing. AddSkylineLevel(bestIndex, newNode); @@ -369,7 +381,9 @@ Rect SkylineBinPack::FindPositionForNewNodeMinWaste(int width, int height, int & newNode.y = y; newNode.width = width; newNode.height = height; +#ifdef _DEBUG assert(disjointRects.Disjoint(newNode)); +#endif } } /* if (RectangleFits(i, height, width, y, wastedArea)) From d94aaf1fcf01abeb3c205a4ad42417d6d80fdf22 Mon Sep 17 00:00:00 2001 From: Braden Obrzut Date: Mon, 18 Jan 2016 16:03:37 -0500 Subject: [PATCH 12/18] - Fixed: Undefined negative double to unsigned int conversion in FNodeBuilder::PointToAngle. --- src/nodebuild_utility.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/nodebuild_utility.cpp b/src/nodebuild_utility.cpp index 14ab7be58..5eba8b7be 100644 --- a/src/nodebuild_utility.cpp +++ b/src/nodebuild_utility.cpp @@ -76,7 +76,8 @@ angle_t FNodeBuilder::PointToAngle (fixed_t x, fixed_t y) #else // !__APPLE__ || __llvm__ double ang = atan2 (double(y), double(x)); #endif // __APPLE__ && !__llvm__ - return angle_t(ang * rad2bam) << 1; + // Convert to signed first since negative double to unsigned is undefined. + return angle_t(int(ang * rad2bam)) << 1; } void FNodeBuilder::FindUsedVertices (vertex_t *oldverts, int max) From 61b66904da6bf43a4c834248073a977963544feb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jan 2016 22:11:18 +0100 Subject: [PATCH 13/18] - more Heretic and Hexen refactoring. --- src/g_heretic/a_hereticmisc.cpp | 3 +- src/g_heretic/a_knight.cpp | 1 - src/g_hexen/a_bats.cpp | 2 +- src/g_hexen/a_bishop.cpp | 18 ++++++------ src/g_hexen/a_blastradius.cpp | 11 ++++---- src/g_hexen/a_clericflame.cpp | 18 ++++++------ src/g_hexen/a_clericholy.cpp | 50 +++++++++++++++++---------------- 7 files changed, 54 insertions(+), 49 deletions(-) diff --git a/src/g_heretic/a_hereticmisc.cpp b/src/g_heretic/a_hereticmisc.cpp index 5a2b8dbec..5d324ff77 100644 --- a/src/g_heretic/a_hereticmisc.cpp +++ b/src/g_heretic/a_hereticmisc.cpp @@ -163,8 +163,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcanoBlast) count = 1 + (pr_blast() % 3); for (i = 0; i < count; i++) { - blast = Spawn("VolcanoBlast", self->x, self->y, - self->z + 44*FRACUNIT, ALLOW_REPLACE); + blast = Spawn("VolcanoBlast", self->PosPlusZ(44*FRACUNIT), ALLOW_REPLACE); blast->target = self; angle = pr_blast () << 24; blast->angle = angle; diff --git a/src/g_heretic/a_knight.cpp b/src/g_heretic/a_knight.cpp index a12dc658e..d845920f9 100644 --- a/src/g_heretic/a_knight.cpp +++ b/src/g_heretic/a_knight.cpp @@ -22,7 +22,6 @@ static FRandom pr_knightatk ("KnightAttack"); DEFINE_ACTION_FUNCTION(AActor, A_DripBlood) { AActor *mo; - fixed_t x, y; fixedvec3 pos = self->Vec3Offset( (pr_dripblood.Random2 () << 11), diff --git a/src/g_hexen/a_bats.cpp b/src/g_hexen/a_bats.cpp index eda5692ae..8edb68cee 100644 --- a/src/g_hexen/a_bats.cpp +++ b/src/g_hexen/a_bats.cpp @@ -84,6 +84,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_BatMove) } // Handle Z movement - self->z = self->target->z + 16*finesine[self->args[0] << BOBTOFINESHIFT]; + self->SetZ(self->target->Z() + 16*finesine[self->args[0] << BOBTOFINESHIFT]); self->args[0] = (self->args[0]+3)&63; } diff --git a/src/g_hexen/a_bishop.cpp b/src/g_hexen/a_bishop.cpp index 08faee955..8b252e63a 100644 --- a/src/g_hexen/a_bishop.cpp +++ b/src/g_hexen/a_bishop.cpp @@ -140,7 +140,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopSpawnBlur) self->SetState (self->MissileState); } } - mo = Spawn ("BishopBlur", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn ("BishopBlur", self->Pos(), ALLOW_REPLACE); if (mo) { mo->angle = self->angle; @@ -155,9 +155,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopSpawnBlur) DEFINE_ACTION_FUNCTION(AActor, A_BishopChase) { - self->z -= finesine[self->special2 << BOBTOFINESHIFT] * 4; + fixed_t newz = self->Z() - finesine[self->special2 << BOBTOFINESHIFT] * 4; self->special2 = (self->special2 + 4) & 63; - self->z += finesine[self->special2 << BOBTOFINESHIFT] * 4; + newz += finesine[self->special2 << BOBTOFINESHIFT] * 4; + self->SetZ(newz); } //============================================================================ @@ -170,7 +171,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopPuff) { AActor *mo; - mo = Spawn ("BishopPuff", self->x, self->y, self->z + 40*FRACUNIT, ALLOW_REPLACE); + mo = Spawn ("BishopPuff", self->PosPlusZ(40*FRACUNIT), ALLOW_REPLACE); if (mo) { mo->velz = FRACUNIT/2; @@ -192,10 +193,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_BishopPainBlur) self->SetState (self->FindState ("Blur")); return; } - fixed_t x = self->x + (pr_pain.Random2()<<12); - fixed_t y = self->y + (pr_pain.Random2()<<12); - fixed_t z = self->z + (pr_pain.Random2()<<11); - mo = Spawn ("BishopPainBlur", x, y, z, ALLOW_REPLACE); + fixedvec3 pos = self->Vec3Offset( + (pr_pain.Random2()<<12), + (pr_pain.Random2()<<12), + (pr_pain.Random2()<<11)); + mo = Spawn ("BishopPainBlur", pos, ALLOW_REPLACE); if (mo) { mo->angle = self->angle; diff --git a/src/g_hexen/a_blastradius.cpp b/src/g_hexen/a_blastradius.cpp index c7fb17fef..c7d962e12 100644 --- a/src/g_hexen/a_blastradius.cpp +++ b/src/g_hexen/a_blastradius.cpp @@ -26,7 +26,7 @@ void BlastActor (AActor *victim, fixed_t strength, fixed_t speed, AActor * Owner { angle_t angle,ang; AActor *mo; - fixed_t x,y,z; + fixedvec3 pos; if (!victim->SpecialBlastHandling (Owner, strength)) { @@ -41,10 +41,11 @@ void BlastActor (AActor *victim, fixed_t strength, fixed_t speed, AActor * Owner // Spawn blast puff ang = victim->AngleTo(Owner); ang >>= ANGLETOFINESHIFT; - x = victim->x + FixedMul (victim->radius+FRACUNIT, finecosine[ang]); - y = victim->y + FixedMul (victim->radius+FRACUNIT, finesine[ang]); - z = victim->z - victim->floorclip + (victim->height>>1); - mo = Spawn (blasteffect, x, y, z, ALLOW_REPLACE); + pos = victim->Vec3Offset( + FixedMul (victim->radius+FRACUNIT, finecosine[ang]), + FixedMul (victim->radius+FRACUNIT, finesine[ang]), + -victim->floorclip + (victim->height>>1)); + mo = Spawn (blasteffect, pos, ALLOW_REPLACE); if (mo) { mo->velx = victim->velx; diff --git a/src/g_hexen/a_clericflame.cpp b/src/g_hexen/a_clericflame.cpp index 0fe482ede..d2bc98329 100644 --- a/src/g_hexen/a_clericflame.cpp +++ b/src/g_hexen/a_clericflame.cpp @@ -48,12 +48,12 @@ void ACFlameMissile::Effect () if (!--special1) { special1 = 4; - newz = z-12*FRACUNIT; + newz = Z()-12*FRACUNIT; if (newz < floorz) { newz = floorz; } - AActor *mo = Spawn ("CFlameFloor", x, y, newz, ALLOW_REPLACE); + AActor *mo = Spawn ("CFlameFloor", X(), Y(), newz, ALLOW_REPLACE); if (mo) { mo->angle = angle; @@ -123,9 +123,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CFlameMissile) { an = (i*ANG45)>>ANGLETOFINESHIFT; an90 = (i*ANG45+ANG90)>>ANGLETOFINESHIFT; - mo = Spawn ("CircleFlame", BlockingMobj->x+FixedMul(dist, finecosine[an]), - BlockingMobj->y+FixedMul(dist, finesine[an]), - BlockingMobj->z+5*FRACUNIT, ALLOW_REPLACE); + mo = Spawn ("CircleFlame", BlockingMobj->Vec3Offset( + FixedMul(dist, finecosine[an]), + FixedMul(dist, finesine[an]), + 5*FRACUNIT), ALLOW_REPLACE); if (mo) { mo->angle = an<vely = mo->special2 = FixedMul(FLAMESPEED, finesine[an]); mo->tics -= pr_missile()&3; } - mo = Spawn ("CircleFlame", BlockingMobj->x-FixedMul(dist, finecosine[an]), - BlockingMobj->y-FixedMul(dist, finesine[an]), - BlockingMobj->z+5*FRACUNIT, ALLOW_REPLACE); + mo = Spawn ("CircleFlame", BlockingMobj->Vec3Offset( + -FixedMul(dist, finecosine[an]), + -FixedMul(dist, finesine[an]), + 5*FRACUNIT), ALLOW_REPLACE); if(mo) { mo->angle = ANG180+(an<flags3&MF3_ISMONSTER && pr_spiritslam() < 128) { @@ -136,7 +136,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack2) for (j = 0; j < 4; j++) { - mo = Spawn (self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn (self->Pos(), ALLOW_REPLACE); if (!mo) { continue; @@ -157,7 +157,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyAttack2) mo->special2 = ((FINEANGLES/2 + i) << 16) + FINEANGLES/2 + pr_holyatk2(8 << BOBTOFINESHIFT); break; } - mo->z = self->z; + mo->SetZ(self->Z()); mo->angle = self->angle+(ANGLE_45+ANGLE_45/2)-ANGLE_45*j; P_ThrustMobj(mo, mo->angle, mo->Speed); mo->target = self->target; @@ -188,11 +188,11 @@ void SpawnSpiritTail (AActor *spirit) AActor *tail, *next; int i; - tail = Spawn ("HolyTail", spirit->x, spirit->y, spirit->z, ALLOW_REPLACE); + tail = Spawn ("HolyTail", spirit->Pos(), ALLOW_REPLACE); tail->target = spirit; // parent for (i = 1; i < 3; i++) { - next = Spawn ("HolyTailTrail", spirit->x, spirit->y, spirit->z, ALLOW_REPLACE); + next = Spawn ("HolyTailTrail", spirit->Pos(), ALLOW_REPLACE); tail->tracer = next; tail = next; } @@ -264,24 +264,24 @@ static void CHolyTailFollow (AActor *actor, fixed_t dist) { an = actor->AngleTo(child) >> ANGLETOFINESHIFT; oldDistance = child->AproxDistance (actor); - if (P_TryMove (child, actor->x+FixedMul(dist, finecosine[an]), - actor->y+FixedMul(dist, finesine[an]), true)) + if (P_TryMove (child, actor->X()+FixedMul(dist, finecosine[an]), + actor->Y()+FixedMul(dist, finesine[an]), true)) { newDistance = child->AproxDistance (actor)-FRACUNIT; if (oldDistance < FRACUNIT) { - if (child->z < actor->z) + if (child->Z() < actor->Z()) { - child->z = actor->z-dist; + child->SetZ(actor->Z()-dist); } else { - child->z = actor->z+dist; + child->SetZ(actor->Z()+dist); } } else { - child->z = actor->z + Scale (newDistance, child->z-actor->z, oldDistance); + child->SetZ(actor->Z() + Scale (newDistance, child->Z()-actor->Z(), oldDistance)); } } } @@ -328,10 +328,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_CHolyTail) else { if (P_TryMove (self, - parent->x - 14*finecosine[parent->angle>>ANGLETOFINESHIFT], - parent->y - 14*finesine[parent->angle>>ANGLETOFINESHIFT], true)) + parent->X() - 14*finecosine[parent->angle>>ANGLETOFINESHIFT], + parent->Y() - 14*finesine[parent->angle>>ANGLETOFINESHIFT], true)) { - self->z = parent->z-5*FRACUNIT; + self->SetZ(parent->Z()-5*FRACUNIT); } CHolyTailFollow (self, 10*FRACUNIT); } @@ -407,11 +407,11 @@ static void CHolySeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax) actor->velx = FixedMul (actor->Speed, finecosine[angle]); actor->vely = FixedMul (actor->Speed, finesine[angle]); if (!(level.time&15) - || actor->z > target->z+(target->height) - || actor->z+actor->height < target->z) + || actor->Z() > target->Top() + || actor->Top() < target->Z()) { - newZ = target->z+((pr_holyseeker()*target->height)>>8); - deltaZ = newZ-actor->z; + newZ = target->Z()+((pr_holyseeker()*target->height)>>8); + deltaZ = newZ - actor->Z(); if (abs(deltaZ) > 15*FRACUNIT) { if (deltaZ > 0) @@ -442,22 +442,24 @@ static void CHolySeekerMissile (AActor *actor, angle_t thresh, angle_t turnMax) void CHolyWeave (AActor *actor, FRandom &pr_random) { - fixed_t newX, newY; + fixed_t newX, newY, newZ; int weaveXY, weaveZ; int angle; weaveXY = actor->special2 >> 16; weaveZ = actor->special2 & FINEMASK; angle = (actor->angle + ANG90) >> ANGLETOFINESHIFT; - newX = actor->x - FixedMul(finecosine[angle], finesine[weaveXY] * 32); - newY = actor->y - FixedMul(finesine[angle], finesine[weaveXY] * 32); + newX = actor->X() - FixedMul(finecosine[angle], finesine[weaveXY] * 32); + newY = actor->Y() - FixedMul(finesine[angle], finesine[weaveXY] * 32); weaveXY = (weaveXY + pr_random(5 << BOBTOFINESHIFT)) & FINEMASK; newX += FixedMul(finecosine[angle], finesine[weaveXY] * 32); newY += FixedMul(finesine[angle], finesine[weaveXY] * 32); P_TryMove(actor, newX, newY, true); - actor->z -= finesine[weaveZ] * 16; + newZ = actor->Z(); + newZ -= finesine[weaveZ] * 16; weaveZ = (weaveZ + pr_random(5 << BOBTOFINESHIFT)) & FINEMASK; - actor->z += finesine[weaveZ] * 16; + newZ += finesine[weaveZ] * 16; + actor->SetZ(newZ); actor->special2 = weaveZ + (weaveXY << 16); } @@ -521,7 +523,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ClericAttack) { if (!self->target) return; - AActor * missile = P_SpawnMissileZ (self, self->z + 40*FRACUNIT, self->target, PClass::FindClass ("HolyMissile")); + AActor * missile = P_SpawnMissileZ (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindClass ("HolyMissile")); if (missile != NULL) missile->tracer = NULL; // No initial target S_Sound (self, CHAN_WEAPON, "HolySymbolFire", 1, ATTN_NORM); } From c8052ce1b8db11924e4dcfc218b2a4f8b1a50cf6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jan 2016 22:26:02 +0100 Subject: [PATCH 14/18] - 4 more Hexen files processed. --- src/g_hexen/a_dragon.cpp | 17 +++++++++-------- src/g_hexen/a_fighterquietus.cpp | 11 ++++++----- src/g_hexen/a_firedemon.cpp | 22 +++++++++++----------- src/g_hexen/a_flechette.cpp | 29 ++++++++++++++--------------- 4 files changed, 40 insertions(+), 39 deletions(-) diff --git a/src/g_hexen/a_dragon.cpp b/src/g_hexen/a_dragon.cpp index d33e7b07b..7b160a689 100644 --- a/src/g_hexen/a_dragon.cpp +++ b/src/g_hexen/a_dragon.cpp @@ -60,14 +60,14 @@ static void DragonSeek (AActor *actor, angle_t thresh, angle_t turnMax) actor->velx = FixedMul (actor->Speed, finecosine[angle]); actor->vely = FixedMul (actor->Speed, finesine[angle]); dist = actor->AproxDistance (target) / actor->Speed; - if (actor->z+actor->height < target->z || - target->z+target->height < actor->z) + if (actor->Top() < target->Z() || + target->Top() < actor->Z()) { if (dist < 1) { dist = 1; } - actor->velz = (target->z - actor->z)/dist; + actor->velz = (target->Z() - actor->Z())/dist; } if (target->flags&MF_SHOOTABLE && pr_dragonseek() < 64) { // attack the destination mobj if it's attackable @@ -252,11 +252,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonFX2) delay = 16+(pr_dragonfx2()>>3); for (i = 1+(pr_dragonfx2()&3); i; i--) { - fixed_t x = self->x+((pr_dragonfx2()-128)<<14); - fixed_t y = self->y+((pr_dragonfx2()-128)<<14); - fixed_t z = self->z+((pr_dragonfx2()-128)<<12); + fixedvec3 pos = self->Vec3Offset( + ((pr_dragonfx2()-128)<<14), + ((pr_dragonfx2()-128)<<14), + ((pr_dragonfx2()-128)<<12)); - mo = Spawn ("DragonExplosion", x, y, z, ALLOW_REPLACE); + mo = Spawn ("DragonExplosion", pos, ALLOW_REPLACE); if (mo) { mo->tics = delay+(pr_dragonfx2()&3)*i*2; @@ -288,7 +289,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DragonPain) DEFINE_ACTION_FUNCTION(AActor, A_DragonCheckCrash) { - if (self->z <= self->floorz) + if (self->Z() <= self->floorz) { self->SetState (self->FindState ("Crash")); } diff --git a/src/g_hexen/a_fighterquietus.cpp b/src/g_hexen/a_fighterquietus.cpp index 846b30281..ae6df183c 100644 --- a/src/g_hexen/a_fighterquietus.cpp +++ b/src/g_hexen/a_fighterquietus.cpp @@ -36,7 +36,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_DropWeaponPieces) const PClass *cls = j==0? p1 : j==1? p2 : p3; if (cls) { - AActor *piece = Spawn (cls, self->x, self->y, self->z, ALLOW_REPLACE); + AActor *piece = Spawn (cls, self->Pos(), ALLOW_REPLACE); if (piece != NULL) { piece->velx = self->velx + finecosine[fineang]; @@ -112,10 +112,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_FSwordFlames) for (i = 1+(pr_fswordflame()&3); i; i--) { - fixed_t x = self->x+((pr_fswordflame()-128)<<12); - fixed_t y = self->y+((pr_fswordflame()-128)<<12); - fixed_t z = self->z+((pr_fswordflame()-128)<<11); - Spawn ("FSwordFlame", x, y, z, ALLOW_REPLACE); + fixedvec3 pos = self->Vec3Offset( + ((pr_fswordflame()-128)<<12), + ((pr_fswordflame()-128)<<12), + ((pr_fswordflame()-128)<<11)); + Spawn ("FSwordFlame", pos, ALLOW_REPLACE); } } diff --git a/src/g_hexen/a_firedemon.cpp b/src/g_hexen/a_firedemon.cpp index c003dc21d..72981df97 100644 --- a/src/g_hexen/a_firedemon.cpp +++ b/src/g_hexen/a_firedemon.cpp @@ -32,7 +32,6 @@ static FRandom pr_firedemonsplotch ("FiredSplotch"); void A_FiredSpawnRock (AActor *actor) { AActor *mo; - int x,y,z; const PClass *rtype; switch (pr_firedemonrock() % 5) @@ -55,10 +54,11 @@ void A_FiredSpawnRock (AActor *actor) break; } - x = actor->x + ((pr_firedemonrock() - 128) << 12); - y = actor->y + ((pr_firedemonrock() - 128) << 12); - z = actor->z + ( pr_firedemonrock() << 11); - mo = Spawn (rtype, x, y, z, ALLOW_REPLACE); + fixedvec3 pos = actor->Vec3Offset( + ((pr_firedemonrock() - 128) << 12), + ((pr_firedemonrock() - 128) << 12), + ( pr_firedemonrock() << 11)); + mo = Spawn (rtype, pos, ALLOW_REPLACE); if (mo) { mo->target = actor; @@ -97,7 +97,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredRocks) DEFINE_ACTION_FUNCTION(AActor, A_SmBounce) { // give some more velocity (x,y,&z) - self->z = self->floorz + FRACUNIT; + self->SetZ(self->floorz + FRACUNIT); self->velz = (2*FRACUNIT) + (pr_smbounce() << 10); self->velx = pr_smbounce()%3<vely = pr_smbounce()%3<threshold) self->threshold--; // Float up and down - self->z += finesine[weaveindex << BOBTOFINESHIFT] * 8; + self->SetZ(self->Z() + finesine[weaveindex << BOBTOFINESHIFT] * 8); self->special1 = (weaveindex + 2) & 63; // Ensure it stays above certain height - if (self->z < self->floorz + (64*FRACUNIT)) + if (self->Z() < self->floorz + (64*FRACUNIT)) { - self->z += 2*FRACUNIT; + self->SetZ(self->Z() + 2*FRACUNIT); } if(!self->target || !(self->target->flags&MF_SHOOTABLE)) @@ -219,14 +219,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredSplotch) { AActor *mo; - mo = Spawn ("FireDemonSplotch1", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn ("FireDemonSplotch1", self->Pos(), ALLOW_REPLACE); if (mo) { mo->velx = (pr_firedemonsplotch() - 128) << 11; mo->vely = (pr_firedemonsplotch() - 128) << 11; mo->velz = (pr_firedemonsplotch() << 10) + FRACUNIT*3; } - mo = Spawn ("FireDemonSplotch2", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn ("FireDemonSplotch2", self->Pos(), ALLOW_REPLACE); if (mo) { mo->velx = (pr_firedemonsplotch() - 128) << 11; diff --git a/src/g_hexen/a_flechette.cpp b/src/g_hexen/a_flechette.cpp index 1a9461ae8..47869c48a 100644 --- a/src/g_hexen/a_flechette.cpp +++ b/src/g_hexen/a_flechette.cpp @@ -51,10 +51,10 @@ bool AArtiPoisonBag1::Use (bool pickup) angle_t angle = Owner->angle >> ANGLETOFINESHIFT; AActor *mo; - mo = Spawn ("PoisonBag", - Owner->x+16*finecosine[angle], - Owner->y+24*finesine[angle], Owner->z- - Owner->floorclip+8*FRACUNIT, ALLOW_REPLACE); + mo = Spawn ("PoisonBag", Owner->Vec3Offset( + 16*finecosine[angle], + 24*finesine[angle], + -Owner->floorclip+8*FRACUNIT), ALLOW_REPLACE); if (mo) { mo->target = Owner; @@ -79,10 +79,10 @@ bool AArtiPoisonBag2::Use (bool pickup) angle_t angle = Owner->angle >> ANGLETOFINESHIFT; AActor *mo; - mo = Spawn ("FireBomb", - Owner->x+16*finecosine[angle], - Owner->y+24*finesine[angle], Owner->z- - Owner->floorclip+8*FRACUNIT, ALLOW_REPLACE); + mo = Spawn ("FireBomb", Owner->Vec3Offset( + 16*finecosine[angle], + 24*finesine[angle], + -Owner->floorclip+8*FRACUNIT), ALLOW_REPLACE); if (mo) { mo->target = Owner; @@ -106,8 +106,7 @@ bool AArtiPoisonBag3::Use (bool pickup) { AActor *mo; - mo = Spawn("ThrowingBomb", Owner->x, Owner->y, - Owner->z-Owner->floorclip+35*FRACUNIT + (Owner->player? Owner->player->crouchoffset : 0), ALLOW_REPLACE); + mo = Spawn("ThrowingBomb", Owner->PosPlusZ(-Owner->floorclip+35*FRACUNIT + (Owner->player? Owner->player->crouchoffset : 0)), ALLOW_REPLACE); if (mo) { mo->angle = Owner->angle + (((pr_poisonbag()&7) - 4) << 24); @@ -133,7 +132,7 @@ bool AArtiPoisonBag3::Use (bool pickup) mo->velz = FixedMul(speed, finesine[modpitch]); mo->velx = FixedMul(xyscale, finecosine[angle]) + (Owner->velx >> 1); mo->vely = FixedMul(xyscale, finesine[angle]) + (Owner->vely >> 1); - mo->z += FixedMul(mo->Speed, finesine[orgpitch]); + mo->SetZ(mo->Z() + FixedMul(mo->Speed, finesine[orgpitch])); mo->target = Owner; mo->tics -= pr_poisonbag()&3; @@ -159,7 +158,7 @@ bool AArtiPoisonBagGiver::Use (bool pickup) const PClass *MissileType = PClass::FindClass((ENamedName) this->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None)); if (MissileType != NULL) { - AActor *mo = Spawn (MissileType, Owner->x, Owner->y, Owner->z, ALLOW_REPLACE); + AActor *mo = Spawn (MissileType, Owner->Pos(), ALLOW_REPLACE); if (mo != NULL) { if (mo->IsKindOf(RUNTIME_CLASS(AInventory))) @@ -385,7 +384,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PoisonBagInit) { AActor *mo; - mo = Spawn (self->x, self->y, self->z+28*FRACUNIT, ALLOW_REPLACE); + mo = Spawn (self->PosPlusZ(28*FRACUNIT), ALLOW_REPLACE); if (mo) { mo->target = self->target; @@ -422,7 +421,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PoisonBagDamage) P_RadiusAttack (self, self->target, 4, 40, self->DamageType, RADF_HURTSOURCE); bobIndex = self->special2; - self->z += finesine[bobIndex << BOBTOFINESHIFT] >> 1; + self->SetZ(self->Z() + finesine[bobIndex << BOBTOFINESHIFT] >> 1); self->special2 = (bobIndex + 1) & 63; } @@ -456,7 +455,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckThrowBomb2) < (3*3)/(2*2)) { self->SetState (self->SpawnState + 6); - self->z = self->floorz; + self->SetZ(self->floorz); self->velz = 0; self->BounceFlags = BOUNCE_None; self->flags &= ~MF_MISSILE; From ef7be016c482b3de2efbb9dc34a0a8724ba77ac5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 18 Jan 2016 22:32:36 +0100 Subject: [PATCH 15/18] - all those 'actor->SetZ(actor->Z() +...) calls weren't pretty so now there's an AddZ method, too. --- src/g_heretic/a_dsparil.cpp | 2 +- src/g_heretic/a_hereticartifacts.cpp | 2 +- src/g_heretic/a_hereticmisc.cpp | 2 +- src/g_heretic/a_hereticweaps.cpp | 2 +- src/g_heretic/a_ironlich.cpp | 4 ++-- src/g_hexen/a_firedemon.cpp | 4 ++-- src/g_hexen/a_flechette.cpp | 4 ++-- src/p_enemy.cpp | 4 ++-- src/p_lnspec.cpp | 2 +- 9 files changed, 13 insertions(+), 13 deletions(-) diff --git a/src/g_heretic/a_dsparil.cpp b/src/g_heretic/a_dsparil.cpp index d2bed5b68..bb3cfb0c5 100644 --- a/src/g_heretic/a_dsparil.cpp +++ b/src/g_heretic/a_dsparil.cpp @@ -257,7 +257,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_GenWizard) mo = Spawn("Wizard", self->Pos(), ALLOW_REPLACE); if (mo != NULL) { - mo->SetZ(mo->Z() - mo->GetDefault()->height / 2, false); + mo->AddZ(-mo->GetDefault()->height / 2, false); if (!P_TestMobjLocation (mo)) { // Didn't fit mo->ClearCounters(); diff --git a/src/g_heretic/a_hereticartifacts.cpp b/src/g_heretic/a_hereticartifacts.cpp index 86416038f..322869f19 100644 --- a/src/g_heretic/a_hereticartifacts.cpp +++ b/src/g_heretic/a_hereticartifacts.cpp @@ -47,7 +47,7 @@ bool AArtiTomeOfPower::Use (bool pickup) DEFINE_ACTION_FUNCTION(AActor, A_TimeBomb) { - self->SetZ(self->Z() + 32*FRACUNIT, false); + self->AddZ(32*FRACUNIT, false); self->PrevZ = self->Z(); // no interpolation! self->RenderStyle = STYLE_Add; self->alpha = FRACUNIT; diff --git a/src/g_heretic/a_hereticmisc.cpp b/src/g_heretic/a_hereticmisc.cpp index 5d324ff77..09c3d4253 100644 --- a/src/g_heretic/a_hereticmisc.cpp +++ b/src/g_heretic/a_hereticmisc.cpp @@ -192,7 +192,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_VolcBallImpact) { self->flags |= MF_NOGRAVITY; self->gravity = FRACUNIT; - self->SetZ(self->Z() + 28*FRACUNIT); + self->AddZ(28*FRACUNIT); //self->velz = 3*FRACUNIT; } P_RadiusAttack (self, self->target, 25, 25, NAME_Fire, RADF_HURTSOURCE); diff --git a/src/g_heretic/a_hereticweaps.cpp b/src/g_heretic/a_hereticweaps.cpp index 2121bf5a2..8ec05b75e 100644 --- a/src/g_heretic/a_hereticweaps.cpp +++ b/src/g_heretic/a_hereticweaps.cpp @@ -388,7 +388,7 @@ void FireMacePL1B (AActor *actor) angle = actor->angle; ball->target = actor; ball->angle = angle; - ball->SetZ(ball->Z() + 2*finetangent[FINEANGLES/4-(actor->pitch>>ANGLETOFINESHIFT)]); + ball->AddZ(2*finetangent[FINEANGLES/4-(actor->pitch>>ANGLETOFINESHIFT)]); angle >>= ANGLETOFINESHIFT; ball->velx = (actor->velx>>1) + FixedMul(ball->Speed, finecosine[angle]); ball->vely = (actor->vely>>1) + FixedMul(ball->Speed, finesine[angle]); diff --git a/src/g_heretic/a_ironlich.cpp b/src/g_heretic/a_ironlich.cpp index b09864bd0..206ba5e8b 100644 --- a/src/g_heretic/a_ironlich.cpp +++ b/src/g_heretic/a_ironlich.cpp @@ -127,7 +127,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichAttack) mo = P_SpawnMissile (self, target, RUNTIME_CLASS(AWhirlwind)); if (mo != NULL) { - mo->SetZ(mo->Z() - 32*FRACUNIT, false); + mo->AddZ(-32*FRACUNIT, false); mo->tracer = target; mo->special1 = 60; mo->special2 = 50; // Timer for active sound @@ -200,7 +200,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LichIceImpact) DEFINE_ACTION_FUNCTION(AActor, A_LichFireGrow) { self->health--; - self->SetZ(self->Z() + 9*FRACUNIT); + self->AddZ(9*FRACUNIT); if (self->health == 0) { self->Damage = self->GetDefault()->Damage; diff --git a/src/g_hexen/a_firedemon.cpp b/src/g_hexen/a_firedemon.cpp index 72981df97..e33c83896 100644 --- a/src/g_hexen/a_firedemon.cpp +++ b/src/g_hexen/a_firedemon.cpp @@ -134,13 +134,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_FiredChase) if (self->threshold) self->threshold--; // Float up and down - self->SetZ(self->Z() + finesine[weaveindex << BOBTOFINESHIFT] * 8); + self->AddZ(finesine[weaveindex << BOBTOFINESHIFT] * 8); self->special1 = (weaveindex + 2) & 63; // Ensure it stays above certain height if (self->Z() < self->floorz + (64*FRACUNIT)) { - self->SetZ(self->Z() + 2*FRACUNIT); + self->AddZ(2*FRACUNIT); } if(!self->target || !(self->target->flags&MF_SHOOTABLE)) diff --git a/src/g_hexen/a_flechette.cpp b/src/g_hexen/a_flechette.cpp index 47869c48a..ef8e27ca1 100644 --- a/src/g_hexen/a_flechette.cpp +++ b/src/g_hexen/a_flechette.cpp @@ -132,7 +132,7 @@ bool AArtiPoisonBag3::Use (bool pickup) mo->velz = FixedMul(speed, finesine[modpitch]); mo->velx = FixedMul(xyscale, finecosine[angle]) + (Owner->velx >> 1); mo->vely = FixedMul(xyscale, finesine[angle]) + (Owner->vely >> 1); - mo->SetZ(mo->Z() + FixedMul(mo->Speed, finesine[orgpitch])); + mo->AddZ(FixedMul(mo->Speed, finesine[orgpitch])); mo->target = Owner; mo->tics -= pr_poisonbag()&3; @@ -421,7 +421,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PoisonBagDamage) P_RadiusAttack (self, self->target, 4, 40, self->DamageType, RADF_HURTSOURCE); bobIndex = self->special2; - self->SetZ(self->Z() + finesine[bobIndex << BOBTOFINESHIFT] >> 1); + self->AddZ(finesine[bobIndex << BOBTOFINESHIFT] >> 1); self->special2 = (bobIndex + 1) & 63; } diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index ef2e15955..90a7a5f5c 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -568,9 +568,9 @@ bool P_Move (AActor *actor) fixed_t savedz = actor->Z(); if (actor->Z() < tm.floorz) - actor->SetZ(actor->Z() + actor->FloatSpeed); + actor->AddZ(actor->FloatSpeed); else - actor->SetZ(actor->Z() - actor->FloatSpeed); + actor->AddZ(-actor->FloatSpeed); // [RH] Check to make sure there's nothing in the way of the float diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 06e2f5f21..05259ba3e 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -3107,7 +3107,7 @@ FUNC(LS_GlassBreak) { glass = Spawn("GlassJunk", x, y, ONFLOORZ, ALLOW_REPLACE); - glass->SetZ(glass->Z() + 24 * FRACUNIT); + glass->AddZ(24 * FRACUNIT); glass->SetState (glass->SpawnState + (pr_glass() % glass->health)); an = pr_glass() << (32-8); glass->angle = an; From 2326928ff7ca6a1d64a1ea1faf32a2c237f5708c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Jan 2016 01:10:57 +0100 Subject: [PATCH 16/18] - the last bits of Hexen refactored This also fixes a problem with some of Hexen's Wraith's effects which did some repositioning without properly linking them into the blockmap. --- src/actor.h | 4 ++ src/g_hexen/a_flies.cpp | 4 +- src/g_hexen/a_fog.cpp | 4 +- src/g_hexen/a_heresiarch.cpp | 69 +++++++++++++++--------------- src/g_hexen/a_hexenspecialdecs.cpp | 28 ++++++------ src/g_hexen/a_iceguy.cpp | 32 +++++--------- src/g_hexen/a_korax.cpp | 41 +++++++++--------- src/g_hexen/a_magecone.cpp | 8 ++-- src/g_hexen/a_magelightning.cpp | 14 +++--- src/g_hexen/a_magestaff.cpp | 8 ++-- src/g_hexen/a_pig.cpp | 2 +- src/g_hexen/a_serpent.cpp | 10 +++-- src/g_hexen/a_spike.cpp | 4 +- src/g_hexen/a_summon.cpp | 6 +-- src/g_hexen/a_teleportother.cpp | 2 +- src/g_hexen/a_wraith.cpp | 46 ++++++++++++-------- src/g_raven/a_minotaur.cpp | 19 ++++---- src/p_local.h | 4 ++ 18 files changed, 160 insertions(+), 145 deletions(-) diff --git a/src/actor.h b/src/actor.h index 46d9ae046..b371fdaee 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1265,6 +1265,10 @@ public: { z = newz; } + void AddZ(fixed_t newz, bool moving = true) + { + z += newz; + } // These are not for general use as they do not link the actor into the world! void SetXY(fixed_t xx, fixed_t yy) diff --git a/src/g_hexen/a_flies.cpp b/src/g_hexen/a_flies.cpp index 683cbebe1..05c4ef94c 100644 --- a/src/g_hexen/a_flies.cpp +++ b/src/g_hexen/a_flies.cpp @@ -83,7 +83,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FlyBuzz) self->angle = ang; self->args[0]++; ang >>= ANGLETOFINESHIFT; - if (!P_TryMove(self, self->x + 6 * finecosine[ang], self->y + 6 * finesine[ang], true)) + if (!P_TryMove(self, self->X() + 6 * finecosine[ang], self->Y() + 6 * finesine[ang], true)) { self->SetIdle(true); return; @@ -94,7 +94,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FlyBuzz) self->vely += (pr_fly() - 128) << BOBTOFINESHIFT; } int zrand = pr_fly(); - if (targ->z + 5*FRACUNIT < self->z && zrand > 150) + if (targ->Z() + 5*FRACUNIT < self->Z() && zrand > 150) { zrand = -zrand; } diff --git a/src/g_hexen/a_fog.cpp b/src/g_hexen/a_fog.cpp index 6bafd383c..a427daa47 100644 --- a/src/g_hexen/a_fog.cpp +++ b/src/g_hexen/a_fog.cpp @@ -41,7 +41,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogSpawn) self->special1 = self->args[2]; // Reset frequency count - mo = Spawn (fogs[pr_fogspawn()%3], self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn (fogs[pr_fogspawn()%3], self->Pos(), ALLOW_REPLACE); if (mo) { @@ -80,7 +80,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FogMove) if ((self->args[3] % 4) == 0) { weaveindex = self->special2; - self->z += finesine[weaveindex << BOBTOFINESHIFT] * 4; + self->AddZ(finesine[weaveindex << BOBTOFINESHIFT] * 4); self->special2 = (weaveindex + 1) & 63; } diff --git a/src/g_hexen/a_heresiarch.cpp b/src/g_hexen/a_heresiarch.cpp index 498b4e955..e2b8c9ed2 100644 --- a/src/g_hexen/a_heresiarch.cpp +++ b/src/g_hexen/a_heresiarch.cpp @@ -232,7 +232,6 @@ void ASorcBall1::DoFireSpell () DEFINE_ACTION_FUNCTION(AActor, A_SorcSpinBalls) { AActor *mo; - fixed_t z; self->SpawnState += 2; // [RH] Don't spawn balls again A_SlowBalls(self); @@ -240,17 +239,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcSpinBalls) self->args[3] = SORC_NORMAL; self->args[4] = SORCBALL_INITIAL_SPEED; // Initial orbit speed self->special1 = ANGLE_1; - z = self->z - self->floorclip + self->height; + + fixedvec3 pos = self->PosPlusZ(-self->floorclip + self->height); - mo = Spawn("SorcBall1", self->x, self->y, z, NO_REPLACE); + mo = Spawn("SorcBall1", pos, NO_REPLACE); if (mo) { mo->target = self; mo->special2 = SORCFX4_RAPIDFIRE_TIME; } - mo = Spawn("SorcBall2", self->x, self->y, z, NO_REPLACE); + mo = Spawn("SorcBall2", pos, NO_REPLACE); if (mo) mo->target = self; - mo = Spawn("SorcBall3", self->x, self->y, z, NO_REPLACE); + mo = Spawn("SorcBall3", pos, NO_REPLACE); if (mo) mo->target = self; } @@ -271,7 +271,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallOrbit) } ASorcBall *actor; - int x,y; angle_t angle, baseangle; int mode = self->target->args[3]; AHeresiarch *parent = barrier_cast(self->target); @@ -370,9 +369,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBallOrbit) S_Sound (actor, CHAN_BODY, "SorcererBallWoosh", 1, ATTN_NORM); } actor->special1 = angle; // Set previous angle - x = parent->x + FixedMul(dist, finecosine[angle]); - y = parent->y + FixedMul(dist, finesine[angle]); - actor->SetOrigin (x, y, parent->z - parent->floorclip + parent->height); + + fixedvec3 pos = parent->Vec3Offset( + FixedMul(dist, finecosine[angle]), + FixedMul(dist, finesine[angle]), + -parent->floorclip + parent->height); + actor->SetOrigin (pos, true); actor->floorz = parent->floorz; actor->ceilingz = parent->ceilingz; } @@ -540,8 +542,7 @@ void ASorcBall2::CastSorcererSpell () AActor *parent = target; AActor *mo; - fixed_t z = parent->z - parent->floorclip + SORC_DEFENSE_HEIGHT*FRACUNIT; - mo = Spawn("SorcFX2", x, y, z, ALLOW_REPLACE); + mo = Spawn("SorcFX2", PosPlusZ(-parent->floorclip + SORC_DEFENSE_HEIGHT*FRACUNIT), ALLOW_REPLACE); parent->flags2 |= MF2_REFLECTIVE|MF2_INVULNERABLE; parent->args[0] = SORC_DEFENSE_TIME; if (mo) mo->target = parent; @@ -667,7 +668,7 @@ void A_SorcOffense2(AActor *actor) mo->special2 = 35*5/2; // 5 seconds dist = mo->AproxDistance(dest) / mo->Speed; if(dist < 1) dist = 1; - mo->velz = (dest->z - mo->z) / dist; + mo->velz = (dest->Z() - mo->Z()) / dist; } } @@ -695,23 +696,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcBossAttack) DEFINE_ACTION_FUNCTION(AActor, A_SpawnFizzle) { - fixed_t x,y,z; fixed_t dist = 5*FRACUNIT; - angle_t angle = self->angle >> ANGLETOFINESHIFT; fixed_t speed = self->Speed; angle_t rangle; AActor *mo; int ix; - x = self->x + FixedMul(dist,finecosine[angle]); - y = self->y + FixedMul(dist,finesine[angle]); - z = self->z - self->floorclip + (self->height>>1); + fixedvec3 pos = self->Vec3Angle(dist, self->angle, -self->floorclip + (self->height >> 1)); for (ix=0; ix<5; ix++) { - mo = Spawn("SorcSpark1", x, y, z, ALLOW_REPLACE); + mo = Spawn("SorcSpark1", pos, ALLOW_REPLACE); if (mo) { - rangle = angle + ((pr_heresiarch()%5) << 1); + rangle = (self->angle >> ANGLETOFINESHIFT) + ((pr_heresiarch()%5) << 1); mo->velx = FixedMul(pr_heresiarch()%speed, finecosine[rangle]); mo->vely = FixedMul(pr_heresiarch()%speed, finesine[rangle]); mo->velz = FRACUNIT*2; @@ -755,7 +752,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Split) { AActor *mo; - mo = Spawn(self->GetClass(), self->x, self->y, self->z, NO_REPLACE); + mo = Spawn(self->GetClass(), self->Pos(), NO_REPLACE); if (mo) { mo->target = self->target; @@ -763,7 +760,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Split) mo->special1 = self->angle; // Set angle mo->SetState (mo->FindState("Orbit")); } - mo = Spawn(self->GetClass(), self->x, self->y, self->z, NO_REPLACE); + mo = Spawn(self->GetClass(), self->Pos(), NO_REPLACE); if (mo) { mo->target = self->target; @@ -785,7 +782,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Split) DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Orbit) { angle_t angle; - fixed_t x,y,z; + fixedvec3 pos; AActor *parent = self->target; // [RH] If no parent, then disappear @@ -818,26 +815,28 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Orbit) { self->special1 += ANGLE_1*10; angle = ((angle_t)self->special1) >> ANGLETOFINESHIFT; - x = parent->x + FixedMul(dist, finecosine[angle]); - y = parent->y + FixedMul(dist, finesine[angle]); - z = parent->z - parent->floorclip + SORC_DEFENSE_HEIGHT*FRACUNIT; - z += FixedMul(15*FRACUNIT,finecosine[angle]); + pos = parent->Vec3Offset( + FixedMul(dist, finecosine[angle]), + FixedMul(dist, finesine[angle]), + parent->floorclip + SORC_DEFENSE_HEIGHT*FRACUNIT); + pos.z += FixedMul(15*FRACUNIT,finecosine[angle]); // Spawn trailer - Spawn("SorcFX2T1", x, y, z, ALLOW_REPLACE); + Spawn("SorcFX2T1", pos, ALLOW_REPLACE); } else // Clock wise { self->special1 -= ANGLE_1*10; angle = ((angle_t)self->special1) >> ANGLETOFINESHIFT; - x = parent->x + FixedMul(dist, finecosine[angle]); - y = parent->y + FixedMul(dist, finesine[angle]); - z = parent->z - parent->floorclip + SORC_DEFENSE_HEIGHT*FRACUNIT; - z += FixedMul(20*FRACUNIT,finesine[angle]); + pos = parent->Vec3Offset( + FixedMul(dist, finecosine[angle]), + FixedMul(dist, finesine[angle]), + parent->floorclip + SORC_DEFENSE_HEIGHT*FRACUNIT); + pos.z += FixedMul(20*FRACUNIT,finesine[angle]); // Spawn trailer - Spawn("SorcFX2T1", x, y, z, ALLOW_REPLACE); + Spawn("SorcFX2T1", pos, ALLOW_REPLACE); } - self->SetOrigin (x, y, z); + self->SetOrigin (pos, true); self->floorz = parent->floorz; self->ceilingz = parent->ceilingz; } @@ -853,7 +852,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SorcFX2Orbit) DEFINE_ACTION_FUNCTION(AActor, A_SpawnBishop) { AActor *mo; - mo = Spawn("Bishop", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn("Bishop", self->Pos(), ALLOW_REPLACE); if (mo) { if (!P_TestMobjLocation(mo)) @@ -878,7 +877,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpawnBishop) DEFINE_ACTION_FUNCTION(AActor, A_SorcererBishopEntry) { - Spawn("SorcFX3Explosion", self->x, self->y, self->z, ALLOW_REPLACE); + Spawn("SorcFX3Explosion", self->Pos(), ALLOW_REPLACE); S_Sound (self, CHAN_VOICE, self->SeeSound, 1, ATTN_NORM); } diff --git a/src/g_hexen/a_hexenspecialdecs.cpp b/src/g_hexen/a_hexenspecialdecs.cpp index ad10a464c..19cb4f752 100644 --- a/src/g_hexen/a_hexenspecialdecs.cpp +++ b/src/g_hexen/a_hexenspecialdecs.cpp @@ -60,7 +60,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryExplode) for(i = (pr_pottery()&3)+3; i; i--) { - mo = Spawn ("PotteryBit", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn ("PotteryBit", self->Pos(), ALLOW_REPLACE); if (mo) { mo->SetState (mo->SpawnState + (pr_pottery()%5)); @@ -77,7 +77,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_PotteryExplode) if (!((level.flags2 & LEVEL2_NOMONSTERS) || (dmflags & DF_NO_MONSTERS)) || !(GetDefaultByType (type)->flags3 & MF3_ISMONSTER)) { // Only spawn monsters if not -nomonsters - Spawn (type, self->x, self->y, self->z, ALLOW_REPLACE); + Spawn (type, self->Pos(), ALLOW_REPLACE); } } } @@ -132,7 +132,7 @@ IMPLEMENT_CLASS (AZCorpseLynchedNoHeart) void AZCorpseLynchedNoHeart::PostBeginPlay () { Super::PostBeginPlay (); - Spawn ("BloodPool", x, y, floorz, ALLOW_REPLACE); + Spawn ("BloodPool", X(), Y(), floorz, ALLOW_REPLACE); } //============================================================================ @@ -145,7 +145,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CorpseBloodDrip) { if (pr_drip() <= 128) { - Spawn ("CorpseBloodDrip", self->x, self->y, self->z + self->height/2, ALLOW_REPLACE); + Spawn ("CorpseBloodDrip", self->PosPlusZ(self->height/2), ALLOW_REPLACE); } } @@ -162,7 +162,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CorpseExplode) for (i = (pr_foo()&3)+3; i; i--) { - mo = Spawn ("CorpseBit", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn ("CorpseBit", self->Pos(), ALLOW_REPLACE); if (mo) { mo->SetState (mo->SpawnState + (pr_foo()%3)); @@ -172,7 +172,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CorpseExplode) } } // Spawn a skull - mo = Spawn ("CorpseBit", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn ("CorpseBit", self->Pos(), ALLOW_REPLACE); if (mo) { mo->SetState (mo->SpawnState + 3); @@ -198,9 +198,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_LeafSpawn) for (i = (pr_leaf()&3)+1; i; i--) { mo = Spawn (pr_leaf()&1 ? PClass::FindClass ("Leaf1") : PClass::FindClass ("Leaf2"), - self->x + (pr_leaf.Random2()<<14), - self->y + (pr_leaf.Random2()<<14), - self->z + (pr_leaf()<<14), ALLOW_REPLACE); + self->Vec3Offset( + (pr_leaf.Random2()<<14), + (pr_leaf.Random2()<<14), + (pr_leaf()<<14)), ALLOW_REPLACE); if (mo) { P_ThrustMobj (mo, self->angle, (pr_leaf()<<9)+3*FRACUNIT); @@ -277,9 +278,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_SoAExplode) for (i = 0; i < 10; i++) { - mo = Spawn ("ZArmorChunk", self->x+((pr_soaexplode()-128)<<12), - self->y+((pr_soaexplode()-128)<<12), - self->z+(pr_soaexplode()*self->height/256), ALLOW_REPLACE); + mo = Spawn ("ZArmorChunk", self->Vec3Offset( + ((pr_soaexplode()-128)<<12), + ((pr_soaexplode()-128)<<12), + (pr_soaexplode()*self->height/256)), ALLOW_REPLACE); if (mo) { mo->SetState (mo->SpawnState + i); @@ -295,7 +297,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SoAExplode) if (!((level.flags2 & LEVEL2_NOMONSTERS) || (dmflags & DF_NO_MONSTERS)) || !(GetDefaultByType (type)->flags3 & MF3_ISMONSTER)) { // Only spawn monsters if not -nomonsters - Spawn (type, self->x, self->y, self->z, ALLOW_REPLACE); + Spawn (type, self->Pos(), ALLOW_REPLACE); } } S_Sound (self, CHAN_BODY, self->DeathSound, 1, ATTN_NORM); diff --git a/src/g_hexen/a_iceguy.cpp b/src/g_hexen/a_iceguy.cpp index 9d8360d4d..75be577bf 100644 --- a/src/g_hexen/a_iceguy.cpp +++ b/src/g_hexen/a_iceguy.cpp @@ -35,10 +35,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyLook) dist = ((pr_iceguylook()-128)*self->radius)>>7; an = (self->angle+ANG90)>>ANGLETOFINESHIFT; - Spawn (WispTypes[pr_iceguylook()&1], - self->x+FixedMul(dist, finecosine[an]), - self->y+FixedMul(dist, finesine[an]), - self->z+60*FRACUNIT, ALLOW_REPLACE); + Spawn(WispTypes[pr_iceguylook() & 1], self->Vec3Offset( + FixedMul(dist, finecosine[an]), + FixedMul(dist, finesine[an]), + 60 * FRACUNIT), ALLOW_REPLACE); } } @@ -60,10 +60,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyChase) dist = ((pr_iceguychase()-128)*self->radius)>>7; an = (self->angle+ANG90)>>ANGLETOFINESHIFT; - mo = Spawn (WispTypes[pr_iceguychase()&1], - self->x+FixedMul(dist, finecosine[an]), - self->y+FixedMul(dist, finesine[an]), - self->z+60*FRACUNIT, ALLOW_REPLACE); + mo = Spawn(WispTypes[pr_iceguychase() & 1], self->Vec3Offset( + FixedMul(dist, finecosine[an]), + FixedMul(dist, finesine[an]), + 60 * FRACUNIT), ALLOW_REPLACE); if (mo) { mo->velx = self->velx; @@ -82,22 +82,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyChase) DEFINE_ACTION_FUNCTION(AActor, A_IceGuyAttack) { - fixed_t an; - if(!self->target) { return; } - an = (self->angle+ANG90)>>ANGLETOFINESHIFT; - P_SpawnMissileXYZ(self->x+FixedMul(self->radius>>1, - finecosine[an]), self->y+FixedMul(self->radius>>1, - finesine[an]), self->z+40*FRACUNIT, self, self->target, - PClass::FindClass ("IceGuyFX")); - an = (self->angle-ANG90)>>ANGLETOFINESHIFT; - P_SpawnMissileXYZ(self->x+FixedMul(self->radius>>1, - finecosine[an]), self->y+FixedMul(self->radius>>1, - finesine[an]), self->z+40*FRACUNIT, self, self->target, - PClass::FindClass ("IceGuyFX")); + P_SpawnMissileXYZ(self->Vec3Angle(self->radius>>1, self->angle+ANG90, 40*FRACUNIT), self, self->target, PClass::FindClass ("IceGuyFX")); + P_SpawnMissileXYZ(self->Vec3Angle(self->radius>>1, self->angle-ANG90, 40*FRACUNIT), self, self->target, PClass::FindClass ("IceGuyFX")); S_Sound (self, CHAN_WEAPON, self->AttackSound, 1, ATTN_NORM); } @@ -129,7 +119,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_IceGuyMissileExplode) for (i = 0; i < 8; i++) { - mo = P_SpawnMissileAngleZ (self, self->z+3*FRACUNIT, + mo = P_SpawnMissileAngleZ (self, self->Z()+3*FRACUNIT, PClass::FindClass("IceGuyFX2"), i*ANG45, (fixed_t)(-0.3*FRACUNIT)); if (mo) { diff --git a/src/g_hexen/a_korax.cpp b/src/g_hexen/a_korax.cpp index a941f1a65..fb833fded 100644 --- a/src/g_hexen/a_korax.cpp +++ b/src/g_hexen/a_korax.cpp @@ -97,7 +97,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase) spot = iterator.Next (); if (spot != NULL) { - P_Teleport (self, spot->x, spot->y, ONFLOORZ, spot->angle, true, true, false); + P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->angle, true, true, false); } P_StartScript (self, NULL, 249, NULL, NULL, 0, 0); @@ -136,7 +136,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase) self->tracer = spot; if (spot) { - P_Teleport (self, spot->x, spot->y, ONFLOORZ, spot->angle, true, true, false); + P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->angle, true, true, false); } } } @@ -248,7 +248,6 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxMissile) DEFINE_ACTION_FUNCTION(AActor, A_KoraxCommand) { - fixed_t x,y,z; angle_t ang; int numcommands; @@ -256,10 +255,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxCommand) // Shoot stream of lightning to ceiling ang = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; - x = self->x + KORAX_COMMAND_OFFSET * finecosine[ang]; - y = self->y + KORAX_COMMAND_OFFSET * finesine[ang]; - z = self->z + KORAX_COMMAND_HEIGHT*FRACUNIT; - Spawn("KoraxBolt", x, y, z, ALLOW_REPLACE); + fixedvec3 pos = self->Vec3Offset( + KORAX_COMMAND_OFFSET * finecosine[ang], + KORAX_COMMAND_OFFSET * finesine[ang], + KORAX_COMMAND_HEIGHT*FRACUNIT); + Spawn("KoraxBolt", pos, ALLOW_REPLACE); if (self->health <= (self->SpawnHealth() >> 1)) { @@ -310,14 +310,13 @@ void KoraxFire (AActor *actor, const PClass *type, int arm) }; angle_t ang; - fixed_t x,y,z; - ang = (actor->angle + (arm < 3 ? -KORAX_DELTAANGLE : KORAX_DELTAANGLE)) - >> ANGLETOFINESHIFT; - x = actor->x + extension[arm] * finecosine[ang]; - y = actor->y + extension[arm] * finesine[ang]; - z = actor->z - actor->floorclip + armheight[arm]; - P_SpawnKoraxMissile (x, y, z, actor, actor->target, type); + ang = (actor->angle + (arm < 3 ? -KORAX_DELTAANGLE : KORAX_DELTAANGLE)) >> ANGLETOFINESHIFT; + fixedvec3 pos = actor->Vec3Offset( + extension[arm] * finecosine[ang], + extension[arm] * finesine[ang], + -actor->floorclip + armheight[arm]); + P_SpawnKoraxMissile (pos.x, pos.y, pos.z, actor, actor->target, type); } //============================================================================ @@ -372,11 +371,11 @@ void A_KSpiritSeeker (AActor *actor, angle_t thresh, angle_t turnMax) actor->vely = FixedMul (actor->Speed, finesine[angle]); if (!(level.time&15) - || actor->z > target->z+(target->GetDefault()->height) - || actor->z+actor->height < target->z) + || actor->Z() > target->Z()+(target->GetDefault()->height) + || actor->Top() < target->Z()) { - newZ = target->z+((pr_kspiritseek()*target->GetDefault()->height)>>8); - deltaZ = newZ-actor->z; + newZ = target->Z()+((pr_kspiritseek()*target->GetDefault()->height)>>8); + deltaZ = newZ-actor->Z(); if (abs(deltaZ) > 15*FRACUNIT) { if(deltaZ > 0) @@ -453,11 +452,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_KBoltRaise) fixed_t z; // Spawn a child upward - z = self->z + KORAX_BOLT_HEIGHT; + z = self->Z() + KORAX_BOLT_HEIGHT; if ((z + KORAX_BOLT_HEIGHT) < self->ceilingz) { - mo = Spawn("KoraxBolt", self->x, self->y, z, ALLOW_REPLACE); + mo = Spawn("KoraxBolt", self->X(), self->Y(), z, ALLOW_REPLACE); if (mo) { mo->special1 = KORAX_BOLT_LIFETIME; @@ -499,6 +498,6 @@ AActor *P_SpawnKoraxMissile (fixed_t x, fixed_t y, fixed_t z, { dist = 1; } - th->velz = (dest->z-z+(30*FRACUNIT))/dist; + th->velz = (dest->Z()-z+(30*FRACUNIT))/dist; return (P_CheckMissileSpawn(th, source->radius) ? th : NULL); } diff --git a/src/g_hexen/a_magecone.cpp b/src/g_hexen/a_magecone.cpp index 6356fbb2f..f9d98c78f 100644 --- a/src/g_hexen/a_magecone.cpp +++ b/src/g_hexen/a_magecone.cpp @@ -120,7 +120,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) // every so many calls, spawn a new missile in its set directions if (spawndir & SHARDSPAWN_LEFT) { - mo = P_SpawnMissileAngleZSpeed (self, self->z, RUNTIME_CLASS(AFrostMissile), self->angle+(ANG45/9), + mo = P_SpawnMissileAngleZSpeed (self, self->Z(), RUNTIME_CLASS(AFrostMissile), self->angle+(ANG45/9), 0, (20+2*spermcount)<target); if (mo) { @@ -132,7 +132,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) } if (spawndir & SHARDSPAWN_RIGHT) { - mo = P_SpawnMissileAngleZSpeed (self, self->z, RUNTIME_CLASS(AFrostMissile), self->angle-(ANG45/9), + mo = P_SpawnMissileAngleZSpeed (self, self->Z(), RUNTIME_CLASS(AFrostMissile), self->angle-(ANG45/9), 0, (20+2*spermcount)<target); if (mo) { @@ -144,7 +144,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) } if (spawndir & SHARDSPAWN_UP) { - mo = P_SpawnMissileAngleZSpeed (self, self->z+8*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->angle, + mo = P_SpawnMissileAngleZSpeed (self, self->Z()+8*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->angle, 0, (15+2*spermcount)<target); if (mo) { @@ -159,7 +159,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ShedShard) } if (spawndir & SHARDSPAWN_DOWN) { - mo = P_SpawnMissileAngleZSpeed (self, self->z-4*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->angle, + mo = P_SpawnMissileAngleZSpeed (self, self->Z()-4*FRACUNIT, RUNTIME_CLASS(AFrostMissile), self->angle, 0, (15+2*spermcount)<target); if (mo) { diff --git a/src/g_hexen/a_magelightning.cpp b/src/g_hexen/a_magelightning.cpp index a13e3a274..88c6dba8b 100644 --- a/src/g_hexen/a_magelightning.cpp +++ b/src/g_hexen/a_magelightning.cpp @@ -151,12 +151,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningClip) { return; } - self->z = self->floorz; + self->SetZ(self->floorz); target = self->lastenemy->tracer; } else if (self->flags3 & MF3_CEILINGHUGGER) { - self->z = self->ceilingz-self->height; + self->SetZ(self->ceilingz-self->height); target = self->tracer; } if (self->flags3 & MF3_FLOORHUGGER) @@ -228,9 +228,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightningZap) { deltaZ = -10*FRACUNIT; } - mo = Spawn(lightning, self->x+((pr_zap()-128)*self->radius/256), - self->y+((pr_zap()-128)*self->radius/256), - self->z+deltaZ, ALLOW_REPLACE); + mo = Spawn(lightning, + self->Vec3Offset( + ((pr_zap() - 128)*self->radius / 256), + ((pr_zap() - 128)*self->radius / 256), + deltaZ), ALLOW_REPLACE); if (mo) { mo->lastenemy = self; @@ -329,7 +331,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LastZap) AActor *mo; - mo = Spawn(lightning, self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn(lightning, self->Pos(), ALLOW_REPLACE); if (mo) { mo->SetState (mo->FindState (NAME_Death)); diff --git a/src/g_hexen/a_magestaff.cpp b/src/g_hexen/a_magestaff.cpp index 97a658a15..4df037fc2 100644 --- a/src/g_hexen/a_magestaff.cpp +++ b/src/g_hexen/a_magestaff.cpp @@ -140,8 +140,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MStaffAttack) P_AimLineAttack (self, angle, PLAYERMISSILERANGE, &linetarget, ANGLE_1*32); if (linetarget == NULL) { - BlockCheckLine.x = self->x; - BlockCheckLine.y = self->y; + BlockCheckLine.x = self->X(); + BlockCheckLine.y = self->Y(); BlockCheckLine.dx = -finesine[angle >> ANGLETOFINESHIFT]; BlockCheckLine.dy = -finecosine[angle >> ANGLETOFINESHIFT]; linetarget = P_BlockmapSearch (self, 10, FrontBlockCheck); @@ -202,7 +202,7 @@ static AActor *FrontBlockCheck (AActor *mo, int index, void *) { if (link->Me != mo) { - if (P_PointOnDivlineSide (link->Me->x, link->Me->y, &BlockCheckLine) == 0 && + if (P_PointOnDivlineSide (link->Me->X(), link->Me->Y(), &BlockCheckLine) == 0 && mo->IsOkayToAttack (link->Me)) { return link->Me; @@ -222,7 +222,7 @@ void MStaffSpawn2 (AActor *actor, angle_t angle) { AActor *mo; - mo = P_SpawnMissileAngleZ (actor, actor->z+40*FRACUNIT, + mo = P_SpawnMissileAngleZ (actor, actor->Z()+40*FRACUNIT, RUNTIME_CLASS(AMageStaffFX2), angle, 0); if (mo) { diff --git a/src/g_hexen/a_pig.cpp b/src/g_hexen/a_pig.cpp index 437a336a3..21d141b0c 100644 --- a/src/g_hexen/a_pig.cpp +++ b/src/g_hexen/a_pig.cpp @@ -96,7 +96,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SnoutAttack) DEFINE_ACTION_FUNCTION(AActor, A_PigPain) { CALL_ACTION(A_Pain, self); - if (self->z <= self->floorz) + if (self->Z() <= self->floorz) { self->velz = FRACUNIT*7/2; } diff --git a/src/g_hexen/a_serpent.cpp b/src/g_hexen/a_serpent.cpp index cf552897f..39b4382e3 100644 --- a/src/g_hexen/a_serpent.cpp +++ b/src/g_hexen/a_serpent.cpp @@ -202,9 +202,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_SerpentSpawnGibs) for (int i = countof(GibTypes)-1; i >= 0; --i) { - mo = Spawn (GibTypes[i], - self->x+((pr_serpentgibs()-128)<<12), - self->y+((pr_serpentgibs()-128)<<12), + fixedvec2 pos = self->Vec2Offset( + ((pr_serpentgibs() - 128) << 12), + ((pr_serpentgibs() - 128) << 12)); + + mo = Spawn (GibTypes[i], pos.x, pos.y, self->floorz+FRACUNIT, ALLOW_REPLACE); if (mo) { @@ -256,7 +258,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_DelayGib) DEFINE_ACTION_FUNCTION(AActor, A_SerpentHeadCheck) { - if (self->z <= self->floorz) + if (self->Z() <= self->floorz) { if (Terrains[P_GetThingFloorType(self)].IsLiquid) { diff --git a/src/g_hexen/a_spike.cpp b/src/g_hexen/a_spike.cpp index 9c9f9ab20..90729a77d 100644 --- a/src/g_hexen/a_spike.cpp +++ b/src/g_hexen/a_spike.cpp @@ -95,7 +95,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrustInitDn) self->flags2 = MF2_NOTELEPORT|MF2_FLOORCLIP; self->renderflags = RF_INVISIBLE; static_cast(self)->DirtClump = - Spawn("DirtClump", self->x, self->y, self->z, ALLOW_REPLACE); + Spawn("DirtClump", self->Pos(), ALLOW_REPLACE); } @@ -140,7 +140,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ThrustLower) DEFINE_ACTION_FUNCTION(AActor, A_ThrustImpale) { AActor *thing; - FBlockThingsIterator it(FBoundingBox(self->x, self->y, self->radius)); + FBlockThingsIterator it(FBoundingBox(self->X(), self->Y(), self->radius)); while ((thing = it.Next())) { if (!thing->intersects(self)) diff --git a/src/g_hexen/a_summon.cpp b/src/g_hexen/a_summon.cpp index cbb8a3854..0fffb6e4c 100644 --- a/src/g_hexen/a_summon.cpp +++ b/src/g_hexen/a_summon.cpp @@ -51,13 +51,13 @@ DEFINE_ACTION_FUNCTION(AActor, A_Summon) { AMinotaurFriend *mo; - mo = Spawn (self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn (self->Pos(), ALLOW_REPLACE); if (mo) { if (P_TestMobjLocation(mo) == false || !self->tracer) { // Didn't fit - change back to artifact mo->Destroy (); - AActor *arti = Spawn (self->x, self->y, self->z, ALLOW_REPLACE); + AActor *arti = Spawn (self->Pos(), ALLOW_REPLACE); if (arti) arti->flags |= MF_DROPPED; return; } @@ -76,7 +76,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Summon) } // Make smoke puff - Spawn ("MinotaurSmoke", self->x, self->y, self->z, ALLOW_REPLACE); + Spawn ("MinotaurSmoke", self->Pos(), ALLOW_REPLACE); S_Sound (self, CHAN_VOICE, mo->ActiveSound, 1, ATTN_NORM); } } diff --git a/src/g_hexen/a_teleportother.cpp b/src/g_hexen/a_teleportother.cpp index 2bf99640b..14edd7519 100644 --- a/src/g_hexen/a_teleportother.cpp +++ b/src/g_hexen/a_teleportother.cpp @@ -51,7 +51,7 @@ static void TeloSpawn (AActor *source, const char *type) { AActor *fx; - fx = Spawn (type, source->x, source->y, source->z, ALLOW_REPLACE); + fx = Spawn (type, source->Pos(), ALLOW_REPLACE); if (fx) { fx->special1 = TELEPORT_LIFE; // Lifetime countdown diff --git a/src/g_hexen/a_wraith.cpp b/src/g_hexen/a_wraith.cpp index b339f14be..312585cdf 100644 --- a/src/g_hexen/a_wraith.cpp +++ b/src/g_hexen/a_wraith.cpp @@ -29,12 +29,12 @@ static FRandom pr_wraithfx4 ("WraithFX4"); DEFINE_ACTION_FUNCTION(AActor, A_WraithInit) { - self->z += 48<AddZ(48<z + self->height > self->ceilingz) + if (self->Top() > self->ceilingz) { - self->z = self->ceilingz - self->height; + self->SetZ(self->ceilingz - self->height); } self->special1 = 0; // index into floatbob @@ -110,7 +110,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithFX2) for (i = 2; i; --i) { - mo = Spawn ("WraithFX2", self->x, self->y, self->z, ALLOW_REPLACE); + mo = Spawn ("WraithFX2", self->Pos(), ALLOW_REPLACE); if(mo) { if (pr_wraithfx2 ()<128) @@ -147,12 +147,16 @@ DEFINE_ACTION_FUNCTION(AActor, A_WraithFX3) while (numdropped-- > 0) { - mo = Spawn ("WraithFX3", self->x, self->y, self->z, ALLOW_REPLACE); + fixedvec3 pos = self->Vec3Offset( + (pr_wraithfx3()-128)<<11, + (pr_wraithfx3()-128)<<11, + (pr_wraithfx3()<<10)); + + mo = Spawn ("WraithFX3", pos, ALLOW_REPLACE); if (mo) { - mo->x += (pr_wraithfx3()-128)<<11; - mo->y += (pr_wraithfx3()-128)<<11; - mo->z += (pr_wraithfx3()<<10); + mo->floorz = self->floorz; + mo->ceilingz = self->ceilingz; mo->target = self; } } @@ -195,23 +199,31 @@ void A_WraithFX4 (AActor *self) if (spawn4) { - mo = Spawn ("WraithFX4", self->x, self->y, self->z, ALLOW_REPLACE); + fixedvec3 pos = self->Vec3Offset( + (pr_wraithfx4()-128)<<12, + (pr_wraithfx4()-128)<<12, + (pr_wraithfx4()<<10)); + + mo = Spawn ("WraithFX4", pos, ALLOW_REPLACE); if (mo) { - mo->x += (pr_wraithfx4()-128)<<12; - mo->y += (pr_wraithfx4()-128)<<12; - mo->z += (pr_wraithfx4()<<10); + mo->floorz = self->floorz; + mo->ceilingz = self->ceilingz; mo->target = self; } } if (spawn5) { - mo = Spawn ("WraithFX5", self->x, self->y, self->z, ALLOW_REPLACE); + fixedvec3 pos = self->Vec3Offset( + (pr_wraithfx4()-128)<<12, + (pr_wraithfx4()-128)<<12, + (pr_wraithfx4()<<10)); + + mo = Spawn ("WraithFX5", pos, ALLOW_REPLACE); if (mo) { - mo->x += (pr_wraithfx4()-128)<<11; - mo->y += (pr_wraithfx4()-128)<<11; - mo->z += (pr_wraithfx4()<<10); + mo->floorz = self->floorz; + mo->ceilingz = self->ceilingz; mo->target = self; } } @@ -226,7 +238,7 @@ void A_WraithFX4 (AActor *self) DEFINE_ACTION_FUNCTION(AActor, A_WraithChase) { int weaveindex = self->special1; - self->z += finesine[weaveindex << BOBTOFINESHIFT] * 8; + self->AddZ(finesine[weaveindex << BOBTOFINESHIFT] * 8); self->special1 = (weaveindex + 2) & 63; // if (self->floorclip > 0) // { diff --git a/src/g_raven/a_minotaur.cpp b/src/g_raven/a_minotaur.cpp index c2348a9e3..bf795fb33 100644 --- a/src/g_raven/a_minotaur.cpp +++ b/src/g_raven/a_minotaur.cpp @@ -186,8 +186,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide) S_Sound (self, CHAN_WEAPON, "minotaur/sight", 1, ATTN_NORM); } dist = self->AproxDistance (target); - if (target->z+target->height > self->z - && target->z+target->height < self->z+self->height + if (target->Top() > self->Z() + && target->Top() < self->Top() && dist < (friendly ? 16*64*FRACUNIT : 8*64*FRACUNIT) && dist > 1*64*FRACUNIT && pr_minotaurdecide() < 150) @@ -205,7 +205,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurDecide) self->vely = FixedMul (MNTR_CHARGE_SPEED, finesine[angle]); self->special1 = TICRATE/2; // Charge duration } - else if (target->z == target->floorz + else if (target->Z() == target->floorz && dist < 9*64*FRACUNIT && pr_minotaurdecide() < (friendly ? 100 : 220)) { // Floor fire attack @@ -244,7 +244,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurCharge) { type = PClass::FindClass ("PunchPuff"); } - puff = Spawn (type, self->x, self->y, self->z, ALLOW_REPLACE); + puff = Spawn (type, self->Pos(), ALLOW_REPLACE); puff->velz = 2*FRACUNIT; self->special1--; } @@ -285,7 +285,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_MinotaurAtk2) P_TraceBleed (newdam > 0 ? newdam : damage, self->target, self); return; } - z = self->z + 40*FRACUNIT; + z = self->Z() + 40*FRACUNIT; const PClass *fx = PClass::FindClass("MinotaurFX1"); if (fx) { @@ -369,10 +369,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_MntrFloorFire) AActor *mo; fixed_t x, y; - self->z = self->floorz; - x = self->x + (pr_fire.Random2 () << 10); - y = self->y + (pr_fire.Random2 () << 10); - mo = Spawn("MinotaurFX3", x, y, self->floorz, ALLOW_REPLACE); + self->SetZ(self->floorz); + fixedvec2 pos = self->Vec2Offset( + (pr_fire.Random2 () << 10), + (pr_fire.Random2 () << 10)); + mo = Spawn("MinotaurFX3", pos.x, pos.y, self->floorz, ALLOW_REPLACE); mo->target = self->target; mo->velx = 1; // Force block checking P_CheckMissileSpawn (mo, self->radius); diff --git a/src/p_local.h b/src/p_local.h index 8c4a94bfc..4e2172a52 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -148,6 +148,10 @@ void P_ExplodeMissile (AActor *missile, line_t *explodeline, AActor *target); AActor *P_SpawnMissile (AActor* source, AActor* dest, const PClass *type, AActor* owner = NULL); AActor *P_SpawnMissileZ (AActor* source, fixed_t z, AActor* dest, const PClass *type); AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, AActor *source, AActor *dest, const PClass *type, bool checkspawn = true, AActor *owner = NULL); +inline AActor *P_SpawnMissileXYZ(const fixedvec3 &pos, AActor *source, AActor *dest, const PClass *type, bool checkspawn = true, AActor *owner = NULL) +{ + return P_SpawnMissileXYZ(pos.x, pos.y, pos.z, source, dest, type, checkspawn, owner); +} AActor *P_SpawnMissileAngle (AActor *source, const PClass *type, angle_t angle, fixed_t velz); AActor *P_SpawnMissileAngleSpeed (AActor *source, const PClass *type, angle_t angle, fixed_t velz, fixed_t speed); AActor *P_SpawnMissileAngleZ (AActor *source, fixed_t z, const PClass *type, angle_t angle, fixed_t velz); From 9f78bcd1e6e29ca0cb32b382dd7f796b2ff25a51 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Jan 2016 11:50:07 +0100 Subject: [PATCH 17/18] - Strife game code refactored for coordinates. --- src/actor.h | 9 ++++++ src/g_shared/shared_hud.cpp | 6 ++-- src/g_shared/shared_sbar.cpp | 3 +- src/g_strife/a_alienspectres.cpp | 6 ++-- src/g_strife/a_coin.cpp | 8 ++--- src/g_strife/a_crusader.cpp | 12 +++---- src/g_strife/a_entityboss.cpp | 19 +++++------ src/g_strife/a_inquisitor.cpp | 20 ++++++------ src/g_strife/a_loremaster.cpp | 16 +++++----- src/g_strife/a_programmer.cpp | 4 +-- src/g_strife/a_rebels.cpp | 6 ++-- src/g_strife/a_sentinel.cpp | 12 +++---- src/g_strife/a_spectral.cpp | 15 ++++----- src/g_strife/a_stalker.cpp | 2 +- src/g_strife/a_strifestuff.cpp | 6 ++-- src/g_strife/a_strifeweapons.cpp | 52 +++++++++++++++++-------------- src/g_strife/a_thingstoblowup.cpp | 7 ++--- src/p_writemap.cpp | 4 +-- src/r_plane.cpp | 11 ++++--- src/r_things.cpp | 11 ++++--- src/r_utility.cpp | 10 +++--- 21 files changed, 124 insertions(+), 115 deletions(-) diff --git a/src/actor.h b/src/actor.h index b371fdaee..52b746ef8 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1252,6 +1252,15 @@ public: fixedvec3 ret = { X(), Y(), Z() }; return ret; } + fixedvec3 InterpolatedPosition(fixed_t ticFrac) const + { + fixedvec3 ret; + + ret.x = PrevX + FixedMul (ticFrac, X() - PrevX); + ret.y = PrevY + FixedMul (ticFrac, Y() - PrevY); + ret.z = PrevZ + FixedMul (ticFrac, Z() - PrevZ); + return ret; + } fixedvec3 PosPlusZ(fixed_t zadd) const { fixedvec3 ret = { X(), Y(), Z() + zadd }; diff --git a/src/g_shared/shared_hud.cpp b/src/g_shared/shared_hud.cpp index b2f1184ea..0fe8a4588 100644 --- a/src/g_shared/shared_hud.cpp +++ b/src/g_shared/shared_hud.cpp @@ -826,9 +826,9 @@ static void DrawCoordinates(player_t * CPlayer) if (!map_point_coordinates || !automapactive) { - x=CPlayer->mo->x; - y=CPlayer->mo->y; - z=CPlayer->mo->z; + x=CPlayer->mo->X(); + y=CPlayer->mo->Y(); + z=CPlayer->mo->Z(); } else { diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index b74350633..b351212d0 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -1286,7 +1286,8 @@ void DBaseStatusBar::Draw (EHudState state) y -= height * 2; } - value = &CPlayer->mo->z; + fixedvec3 pos = CPlayer->mo->Pos(); + value = &pos.z; for (i = 2, value = &CPlayer->mo->z; i >= 0; y -= height, --value, --i) { mysnprintf (line, countof(line), "%c: %d", labels[i], *value >> FRACBITS); diff --git a/src/g_strife/a_alienspectres.cpp b/src/g_strife/a_alienspectres.cpp index 2b9f499e9..c6339f33d 100644 --- a/src/g_strife/a_alienspectres.cpp +++ b/src/g_strife/a_alienspectres.cpp @@ -22,7 +22,7 @@ AActor *P_SpawnSubMissile (AActor *source, const PClass *type, AActor *target); DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkSmall) { - AActor *foo = Spawn("AlienChunkSmall", self->x, self->y, self->z + 10*FRACUNIT, ALLOW_REPLACE); + AActor *foo = Spawn("AlienChunkSmall", self->PosPlusZ(10*FRACUNIT), ALLOW_REPLACE); if (foo != NULL) { @@ -40,7 +40,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkSmall) DEFINE_ACTION_FUNCTION(AActor, A_SpectreChunkLarge) { - AActor *foo = Spawn("AlienChunkLarge", self->x, self->y, self->z + 10*FRACUNIT, ALLOW_REPLACE); + AActor *foo = Spawn("AlienChunkLarge", self->PosPlusZ(10*FRACUNIT), ALLOW_REPLACE); if (foo != NULL) { @@ -62,7 +62,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Spectre3Attack) if (self->target == NULL) return; - AActor *foo = Spawn("SpectralLightningV2", self->x, self->y, self->z + 32*FRACUNIT, ALLOW_REPLACE); + AActor *foo = Spawn("SpectralLightningV2", self->PosPlusZ(32*FRACUNIT), ALLOW_REPLACE); foo->velz = -12*FRACUNIT; foo->target = self; diff --git a/src/g_strife/a_coin.cpp b/src/g_strife/a_coin.cpp index dd3610039..36b531001 100644 --- a/src/g_strife/a_coin.cpp +++ b/src/g_strife/a_coin.cpp @@ -80,22 +80,22 @@ AInventory *ACoin::CreateTossable () if (Amount >= 50) { Amount -= 50; - tossed = static_cast(Spawn("Gold50", Owner->x, Owner->y, Owner->z, NO_REPLACE)); + tossed = static_cast(Spawn("Gold50", Owner->Pos(), NO_REPLACE)); } else if (Amount >= 25) { Amount -= 25; - tossed = static_cast(Spawn("Gold25", Owner->x, Owner->y, Owner->z, NO_REPLACE)); + tossed = static_cast(Spawn("Gold25", Owner->Pos(), NO_REPLACE)); } else if (Amount >= 10) { Amount -= 10; - tossed = static_cast(Spawn("Gold10", Owner->x, Owner->y, Owner->z, NO_REPLACE)); + tossed = static_cast(Spawn("Gold10", Owner->Pos(), NO_REPLACE)); } else if (Amount > 1 || (ItemFlags & IF_KEEPDEPLETED)) { Amount -= 1; - tossed = static_cast(Spawn("Coin", Owner->x, Owner->y, Owner->z, NO_REPLACE)); + tossed = static_cast(Spawn("Coin", Owner->Pos(), NO_REPLACE)); } else // Amount == 1 && !(ItemFlags & IF_KEEPDEPLETED) { diff --git a/src/g_strife/a_crusader.cpp b/src/g_strife/a_crusader.cpp index cf5f03a23..8655e10bc 100644 --- a/src/g_strife/a_crusader.cpp +++ b/src/g_strife/a_crusader.cpp @@ -27,18 +27,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderChoose) { A_FaceTarget (self); self->angle -= ANGLE_180/16; - P_SpawnMissileZAimed (self, self->z + 40*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile")); + P_SpawnMissileZAimed (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile")); } else { if (P_CheckMissileRange (self)) { A_FaceTarget (self); - P_SpawnMissileZAimed (self, self->z + 56*FRACUNIT, self->target, PClass::FindClass("CrusaderMissile")); + P_SpawnMissileZAimed (self, self->Z() + 56*FRACUNIT, self->target, PClass::FindClass("CrusaderMissile")); self->angle -= ANGLE_45/32; - P_SpawnMissileZAimed (self, self->z + 40*FRACUNIT, self->target, PClass::FindClass("CrusaderMissile")); + P_SpawnMissileZAimed (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindClass("CrusaderMissile")); self->angle += ANGLE_45/16; - P_SpawnMissileZAimed (self, self->z + 40*FRACUNIT, self->target, PClass::FindClass("CrusaderMissile")); + P_SpawnMissileZAimed (self, self->Z() + 40*FRACUNIT, self->target, PClass::FindClass("CrusaderMissile")); self->angle -= ANGLE_45/16; self->reactiontime += 15; } @@ -49,7 +49,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderChoose) DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepLeft) { self->angle += ANGLE_90/16; - AActor *misl = P_SpawnMissileZAimed (self, self->z + 48*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile")); + AActor *misl = P_SpawnMissileZAimed (self, self->Z() + 48*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile")); if (misl != NULL) { misl->velz += FRACUNIT; @@ -59,7 +59,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepLeft) DEFINE_ACTION_FUNCTION(AActor, A_CrusaderSweepRight) { self->angle -= ANGLE_90/16; - AActor *misl = P_SpawnMissileZAimed (self, self->z + 48*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile")); + AActor *misl = P_SpawnMissileZAimed (self, self->Z() + 48*FRACUNIT, self->target, PClass::FindClass("FastFlameMissile")); if (misl != NULL) { misl->velz += FRACUNIT; diff --git a/src/g_strife/a_entityboss.cpp b/src/g_strife/a_entityboss.cpp index fafb3b862..04b586b67 100644 --- a/src/g_strife/a_entityboss.cpp +++ b/src/g_strife/a_entityboss.cpp @@ -24,7 +24,7 @@ void A_SpectralMissile (AActor *self, const char *missilename) { if (self->target != NULL) { - AActor *missile = P_SpawnMissileXYZ (self->x, self->y, self->z + 32*FRACUNIT, + AActor *missile = P_SpawnMissileXYZ (self->PosPlusZ(32*FRACUNIT), self, self->target, PClass::FindClass(missilename), false); if (missile != NULL) { @@ -70,7 +70,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_EntityAttack) DEFINE_ACTION_FUNCTION(AActor, A_SpawnEntity) { - AActor *entity = Spawn("EntityBoss", self->x, self->y, self->z + 70*FRACUNIT, ALLOW_REPLACE); + AActor *entity = Spawn("EntityBoss", self->PosPlusZ(70*FRACUNIT), ALLOW_REPLACE); if (entity != NULL) { entity->angle = self->angle; @@ -89,13 +89,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_EntityDeath) AActor *spot = self->tracer; if (spot == NULL) spot = self; - fixed_t SpawnX = spot->x; - fixed_t SpawnY = spot->y; - fixed_t SpawnZ = spot->z + (self->tracer? 70*FRACUNIT : 0); + fixedvec3 pos = spot->Vec3Angle(secondRadius, self->angle, self->tracer? 70*FRACUNIT : 0); an = self->angle >> ANGLETOFINESHIFT; - second = Spawn("EntitySecond", SpawnX + FixedMul (secondRadius, finecosine[an]), - SpawnY + FixedMul (secondRadius, finesine[an]), SpawnZ, ALLOW_REPLACE); + second = Spawn("EntitySecond", pos, ALLOW_REPLACE); second->CopyFriendliness(self, true); //second->target = self->target; A_FaceTarget (second); @@ -103,18 +100,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_EntityDeath) second->velx += FixedMul (finecosine[an], 320000); second->vely += FixedMul (finesine[an], 320000); + pos = spot->Vec3Angle(secondRadius, self->angle + ANGLE_90, self->tracer? 70*FRACUNIT : 0); an = (self->angle + ANGLE_90) >> ANGLETOFINESHIFT; - second = Spawn("EntitySecond", SpawnX + FixedMul (secondRadius, finecosine[an]), - SpawnY + FixedMul (secondRadius, finesine[an]), SpawnZ, ALLOW_REPLACE); + second = Spawn("EntitySecond", pos, ALLOW_REPLACE); second->CopyFriendliness(self, true); //second->target = self->target; second->velx = FixedMul (secondRadius, finecosine[an]) << 2; second->vely = FixedMul (secondRadius, finesine[an]) << 2; A_FaceTarget (second); + pos = spot->Vec3Angle(secondRadius, self->angle - ANGLE_90, self->tracer? 70*FRACUNIT : 0); an = (self->angle - ANGLE_90) >> ANGLETOFINESHIFT; - second = Spawn("EntitySecond", SpawnX + FixedMul (secondRadius, finecosine[an]), - SpawnY + FixedMul (secondRadius, finesine[an]), SpawnZ, ALLOW_REPLACE); + second = Spawn("EntitySecond", pos, ALLOW_REPLACE); second->CopyFriendliness(self, true); //second->target = self->target; second->velx = FixedMul (secondRadius, finecosine[an]) << 2; diff --git a/src/g_strife/a_inquisitor.cpp b/src/g_strife/a_inquisitor.cpp index 1a0739d36..b93933422 100644 --- a/src/g_strife/a_inquisitor.cpp +++ b/src/g_strife/a_inquisitor.cpp @@ -35,9 +35,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorDecide) { self->SetState (self->FindState("Grenade")); } - if (self->target->z != self->z) + if (self->target->Z() != self->Z()) { - if (self->z + self->height + 54*FRACUNIT < self->ceilingz) + if (self->Top() + 54*FRACUNIT < self->ceilingz) { self->SetState (self->FindState("Jump")); } @@ -53,20 +53,20 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorAttack) A_FaceTarget (self); - self->z += 32*FRACUNIT; + self->AddZ(32*FRACUNIT); self->angle -= ANGLE_45/32; - proj = P_SpawnMissileZAimed (self, self->z, self->target, PClass::FindClass("InquisitorShot")); + proj = P_SpawnMissileZAimed (self, self->Z(), self->target, PClass::FindClass("InquisitorShot")); if (proj != NULL) { proj->velz += 9*FRACUNIT; } self->angle += ANGLE_45/16; - proj = P_SpawnMissileZAimed (self, self->z, self->target, PClass::FindClass("InquisitorShot")); + proj = P_SpawnMissileZAimed (self, self->Z(), self->target, PClass::FindClass("InquisitorShot")); if (proj != NULL) { proj->velz += 16*FRACUNIT; } - self->z -= 32*FRACUNIT; + self->AddZ(-32*FRACUNIT); } DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump) @@ -79,7 +79,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump) return; S_Sound (self, CHAN_ITEM|CHAN_LOOP, "inquisitor/jump", 1, ATTN_NORM); - self->z += 64*FRACUNIT; + self->AddZ(64*FRACUNIT); A_FaceTarget (self); an = self->angle >> ANGLETOFINESHIFT; speed = self->Speed * 2/3; @@ -91,7 +91,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorJump) { dist = 1; } - self->velz = (self->target->z - self->z) / dist; + self->velz = (self->target->Z() - self->Z()) / dist; self->reactiontime = 60; self->flags |= MF_NOGRAVITY; } @@ -102,7 +102,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorCheckLand) if (self->reactiontime < 0 || self->velx == 0 || self->vely == 0 || - self->z <= self->floorz) + self->Z() <= self->floorz) { self->SetState (self->SeeState); self->reactiontime = 0; @@ -119,7 +119,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_InquisitorCheckLand) DEFINE_ACTION_FUNCTION(AActor, A_TossArm) { - AActor *foo = Spawn("InquisitorArm", self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE); + AActor *foo = Spawn("InquisitorArm", self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE); foo->angle = self->angle - ANGLE_90 + (pr_inq.Random2() << 22); foo->velx = FixedMul (foo->Speed, finecosine[foo->angle >> ANGLETOFINESHIFT]) >> 3; foo->vely = FixedMul (foo->Speed, finesine[foo->angle >> ANGLETOFINESHIFT]) >> 3; diff --git a/src/g_strife/a_loremaster.cpp b/src/g_strife/a_loremaster.cpp index d984bbdd3..1b12c2436 100644 --- a/src/g_strife/a_loremaster.cpp +++ b/src/g_strife/a_loremaster.cpp @@ -21,16 +21,14 @@ IMPLEMENT_CLASS (ALoreShot) int ALoreShot::DoSpecialDamage (AActor *victim, int damage, FName damagetype) { - FVector3 thrust; if (victim != NULL && target != NULL && !(victim->flags7 & MF7_DONTTHRUST)) { - thrust.X = float(target->x - victim->x); - thrust.Y = float(target->y - victim->y); - thrust.Z = float(target->z - victim->z); - + fixedvec3 fixthrust = victim->Vec3To(target); + TVector3 thrust(fixthrust.x, fixthrust.y, fixthrust.z); + thrust.MakeUnit(); - thrust *= float((255*50*FRACUNIT) / (victim->Mass ? victim->Mass : 1)); + thrust *= double((255*50*FRACUNIT) / (victim->Mass ? victim->Mass : 1)); victim->velx += fixed_t(thrust.X); victim->vely += fixed_t(thrust.Y); @@ -42,7 +40,7 @@ int ALoreShot::DoSpecialDamage (AActor *victim, int damage, FName damagetype) DEFINE_ACTION_FUNCTION(AActor, A_LoremasterChain) { S_Sound (self, CHAN_BODY, "loremaster/active", 1, ATTN_NORM); - Spawn("LoreShot2", self->x, self->y, self->z, ALLOW_REPLACE); - Spawn("LoreShot2", self->x - (self->velx >> 1), self->y - (self->vely >> 1), self->z - (self->velz >> 1), ALLOW_REPLACE); - Spawn("LoreShot2", self->x - self->velx, self->y - self->vely, self->z - self->velz, ALLOW_REPLACE); + Spawn("LoreShot2", self->Pos(), ALLOW_REPLACE); + Spawn("LoreShot2", self->Vec3Offset(-(self->velx >> 1), -(self->vely >> 1), -(self->velz >> 1)), ALLOW_REPLACE); + Spawn("LoreShot2", self->Vec3Offset(-self->velx, -self->vely, -self->velz), ALLOW_REPLACE); } diff --git a/src/g_strife/a_programmer.cpp b/src/g_strife/a_programmer.cpp index 78689468b..5835b3566 100644 --- a/src/g_strife/a_programmer.cpp +++ b/src/g_strife/a_programmer.cpp @@ -104,7 +104,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpotLightning) if (self->target == NULL) return; - spot = Spawn("SpectralLightningSpot", self->target->x, self->target->y, self->target->floorz, ALLOW_REPLACE); + spot = Spawn("SpectralLightningSpot", self->target->X(), self->target->Y(), self->target->floorz, ALLOW_REPLACE); if (spot != NULL) { spot->threshold = 25; @@ -122,7 +122,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpotLightning) DEFINE_ACTION_FUNCTION(AActor, A_SpawnProgrammerBase) { - AActor *foo = Spawn("ProgrammerBase", self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE); + AActor *foo = Spawn("ProgrammerBase", self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE); if (foo != NULL) { foo->angle = self->angle + ANGLE_180 + (pr_prog.Random2() << 22); diff --git a/src/g_strife/a_rebels.cpp b/src/g_strife/a_rebels.cpp index 81490c361..6c8652f7c 100644 --- a/src/g_strife/a_rebels.cpp +++ b/src/g_strife/a_rebels.cpp @@ -75,8 +75,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon) AActor *rebel; angle_t an; - rebel = Spawn("Rebel1", self->x, self->y, self->floorz, ALLOW_REPLACE); - if (!P_TryMove (rebel, rebel->x, rebel->y, true)) + rebel = Spawn("Rebel1", self->X(), self->Y(), self->floorz, ALLOW_REPLACE); + if (!P_TryMove (rebel, rebel->X(), rebel->Y(), true)) { rebel->Destroy (); return; @@ -112,7 +112,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Beacon) rebel->SetState (rebel->SeeState); rebel->angle = self->angle; an = self->angle >> ANGLETOFINESHIFT; - Spawn (rebel->x + 20*finecosine[an], rebel->y + 20*finesine[an], rebel->z + TELEFOGHEIGHT, ALLOW_REPLACE); + Spawn (rebel->Vec3Offset(20*finecosine[an], 20*finesine[an], TELEFOGHEIGHT), ALLOW_REPLACE); if (--self->health < 0) { self->SetState(self->FindState(NAME_Death)); diff --git a/src/g_strife/a_sentinel.cpp b/src/g_strife/a_sentinel.cpp index 74f0e917f..550a89ff7 100644 --- a/src/g_strife/a_sentinel.cpp +++ b/src/g_strife/a_sentinel.cpp @@ -27,7 +27,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelBob) { minz = maxz; } - if (minz < self->z) + if (minz < self->Z()) { self->velz -= FRACUNIT; } @@ -35,7 +35,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelBob) { self->velz += FRACUNIT; } - self->reactiontime = (minz >= self->z) ? 4 : 0; + self->reactiontime = (minz >= self->Z()) ? 4 : 0; } DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack) @@ -48,16 +48,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack) return; } - missile = P_SpawnMissileZAimed (self, self->z + 32*FRACUNIT, self->target, PClass::FindClass("SentinelFX2")); + missile = P_SpawnMissileZAimed (self, self->Z() + 32*FRACUNIT, self->target, PClass::FindClass("SentinelFX2")); if (missile != NULL && (missile->velx | missile->vely) != 0) { for (int i = 8; i > 1; --i) { trail = Spawn("SentinelFX1", - self->x + FixedMul (missile->radius * i, finecosine[missile->angle >> ANGLETOFINESHIFT]), - self->y + FixedMul (missile->radius * i, finesine[missile->angle >> ANGLETOFINESHIFT]), - missile->z + (missile->velz / 4 * i), ALLOW_REPLACE); + self->Vec3Angle(missile->radius*i, missile->angle, (missile->velz / 4 * i)), ALLOW_REPLACE); if (trail != NULL) { trail->target = self; @@ -67,7 +65,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack) P_CheckMissileSpawn (trail, self->radius); } } - missile->z += missile->velz >> 2; + missile->AddZ(missile->velz >> 2); } } diff --git a/src/g_strife/a_spectral.cpp b/src/g_strife/a_spectral.cpp index 6f80fe42c..91e43dba9 100644 --- a/src/g_strife/a_spectral.cpp +++ b/src/g_strife/a_spectral.cpp @@ -28,7 +28,7 @@ void ASpectralMonster::Touch (AActor *toucher) DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightningTail) { - AActor *foo = Spawn("SpectralLightningHTail", self->x - self->velx, self->y - self->vely, self->z, ALLOW_REPLACE); + AActor *foo = Spawn("SpectralLightningHTail", self->Vec3Offset(-self->velx, -self->vely, 0), ALLOW_REPLACE); foo->angle = self->angle; foo->FriendPlayer = self->FriendPlayer; @@ -61,17 +61,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_SpectralLightning) self->velx += pr_zap5.Random2(3) << FRACBITS; self->vely += pr_zap5.Random2(3) << FRACBITS; - x = self->x + pr_zap5.Random2(3) * FRACUNIT * 50; - y = self->y + pr_zap5.Random2(3) * FRACUNIT * 50; + fixedvec2 pos = self->Vec2Offset( + pr_zap5.Random2(3) * FRACUNIT * 50, + pr_zap5.Random2(3) * FRACUNIT * 50); flash = Spawn (self->threshold > 25 ? PClass::FindClass(NAME_SpectralLightningV2) : - PClass::FindClass(NAME_SpectralLightningV1), x, y, ONCEILINGZ, ALLOW_REPLACE); + PClass::FindClass(NAME_SpectralLightningV1), pos.x, pos.y, ONCEILINGZ, ALLOW_REPLACE); flash->target = self->target; flash->velz = -18*FRACUNIT; flash->FriendPlayer = self->FriendPlayer; - flash = Spawn(NAME_SpectralLightningV2, self->x, self->y, ONCEILINGZ, ALLOW_REPLACE); + flash = Spawn(NAME_SpectralLightningV2, self->X(), self->Y(), ONCEILINGZ, ALLOW_REPLACE); flash->target = self->target; flash->velz = -18*FRACUNIT; @@ -128,11 +129,11 @@ DEFINE_ACTION_FUNCTION(AActor, A_Tracer2) } if (dest->height >= 56*FRACUNIT) { - slope = (dest->z+40*FRACUNIT - self->z) / dist; + slope = (dest->Z()+40*FRACUNIT - self->Z()) / dist; } else { - slope = (dest->z + self->height*2/3 - self->z) / dist; + slope = (dest->Z() + self->height*2/3 - self->Z()) / dist; } if (slope < self->velz) { diff --git a/src/g_strife/a_stalker.cpp b/src/g_strife/a_stalker.cpp index 258cbef3f..6a06bf867 100644 --- a/src/g_strife/a_stalker.cpp +++ b/src/g_strife/a_stalker.cpp @@ -17,7 +17,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_StalkerChaseDecide) { self->SetState (self->FindState("SeeFloor")); } - else if (self->ceilingz - self->height > self->z) + else if (self->ceilingz > self->Top()) { self->SetState (self->FindState("Drop")); } diff --git a/src/g_strife/a_strifestuff.cpp b/src/g_strife/a_strifestuff.cpp index 9f3ebb272..3145290ef 100644 --- a/src/g_strife/a_strifestuff.cpp +++ b/src/g_strife/a_strifestuff.cpp @@ -580,7 +580,7 @@ IMPLEMENT_CLASS (AMeat) DEFINE_ACTION_FUNCTION(AActor, A_TossGib) { const char *gibtype = (self->flags & MF_NOBLOOD) ? "Junk" : "Meat"; - AActor *gib = Spawn (gibtype, self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE); + AActor *gib = Spawn (gibtype, self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE); angle_t an; int speed; @@ -628,7 +628,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_CheckTerrain) { sector_t *sec = self->Sector; - if (self->z == sec->floorplane.ZatPoint(self)) + if (self->Z() == sec->floorplane.ZatPoint(self)) { if (sec->special == Damage_InstantDeath) { @@ -681,7 +681,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_ItBurnsItBurns) DEFINE_ACTION_FUNCTION(AActor, A_DropFire) { - AActor *drop = Spawn("FireDroplet", self->x, self->y, self->z + 24*FRACUNIT, ALLOW_REPLACE); + AActor *drop = Spawn("FireDroplet", self->PosPlusZ(24*FRACUNIT), ALLOW_REPLACE); drop->velz = -FRACUNIT; P_RadiusAttack (self, self, 64, 64, NAME_Fire, 0); } diff --git a/src/g_strife/a_strifeweapons.cpp b/src/g_strife/a_strifeweapons.cpp index f5d4a3576..a33521087 100644 --- a/src/g_strife/a_strifeweapons.cpp +++ b/src/g_strife/a_strifeweapons.cpp @@ -360,8 +360,8 @@ DEFINE_ACTION_FUNCTION(AActor, A_RocketInFlight) AActor *trail; S_Sound (self, CHAN_VOICE, "misc/missileinflight", 1, ATTN_NORM); - P_SpawnPuff (self, PClass::FindClass("MiniMissilePuff"), self->x, self->y, self->z, self->angle - ANGLE_180, 2, PF_HITTHING); - trail = Spawn("RocketTrail", self->x - self->velx, self->y - self->vely, self->z, ALLOW_REPLACE); + P_SpawnPuff (self, PClass::FindClass("MiniMissilePuff"), self->Pos(), self->angle - ANGLE_180, 2, PF_HITTHING); + trail = Spawn("RocketTrail", self->Vec3Offset(-self->velx, -self->vely, 0), ALLOW_REPLACE); if (trail != NULL) { trail->velz = FRACUNIT; @@ -516,10 +516,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaulerTorpedoWave) self->angle += ANGLE_180; // If the torpedo hit the ceiling, it should still spawn the wave - savedz = self->z; - if (wavedef && self->ceilingz - self->z < wavedef->height) + savedz = self->Z(); + if (wavedef && self->ceilingz - self->Z() < wavedef->height) { - self->z = self->ceilingz - wavedef->height; + self->SetZ(self->ceilingz - wavedef->height); } for (int i = 0; i < 80; ++i) @@ -527,12 +527,12 @@ DEFINE_ACTION_FUNCTION(AActor, A_MaulerTorpedoWave) self->angle += ANGLE_45/10; P_SpawnSubMissile (self, PClass::FindClass("MaulerTorpedoWave"), self->target); } - self->z = savedz; + self->SetZ(savedz); } AActor *P_SpawnSubMissile (AActor *source, const PClass *type, AActor *target) { - AActor *other = Spawn (type, source->x, source->y, source->z, ALLOW_REPLACE); + AActor *other = Spawn (type, source->Pos(), ALLOW_REPLACE); if (other == NULL) { @@ -619,20 +619,19 @@ DEFINE_ACTION_FUNCTION(AActor, A_Burnination) yofs = -yofs; } - fixed_t x = self->x + (xofs << FRACBITS); - fixed_t y = self->y + (yofs << FRACBITS); - sector_t * sector = P_PointInSector(x, y); + fixedvec2 pos = self->Vec2Offset(xofs << FRACBITS, yofs << FRACBITS); + sector_t * sector = P_PointInSector(pos.x, pos.y); // The sector's floor is too high so spawn the flame elsewhere. - if (sector->floorplane.ZatPoint(x, y) > self->z + self->MaxStepHeight) + if (sector->floorplane.ZatPoint(pos.x, pos.y) > self->Z() + self->MaxStepHeight) { - x = self->x; - y = self->y; + pos.x = self->X(); + pos.y = self->Y(); } AActor *drop = Spawn ( - x, y, - self->z + 4*FRACUNIT, ALLOW_REPLACE); + pos.x, pos.y, + self->Z() + 4*FRACUNIT, ALLOW_REPLACE); if (drop != NULL) { drop->velx = self->velx + ((pr_phburn.Random2 (7)) << FRACBITS); @@ -677,9 +676,9 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade) if (grenadetype != NULL) { - self->z += 32*FRACUNIT; + self->AddZ(32*FRACUNIT); grenade = P_SpawnSubMissile (self, grenadetype, self); - self->z -= 32*FRACUNIT; + self->AddZ(-32*FRACUNIT); if (grenade == NULL) return; @@ -690,15 +689,20 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireGrenade) grenade->velz = FixedMul (finetangent[FINEANGLES/4-(self->pitch>>ANGLETOFINESHIFT)], grenade->Speed) + 8*FRACUNIT; + fixedvec2 offset; + an = self->angle >> ANGLETOFINESHIFT; tworadii = self->radius + grenade->radius; - grenade->x += FixedMul (finecosine[an], tworadii); - grenade->y += FixedMul (finesine[an], tworadii); + offset.x = FixedMul (finecosine[an], tworadii); + offset.y = FixedMul (finesine[an], tworadii); an = self->angle + Angle; an >>= ANGLETOFINESHIFT; - grenade->x += FixedMul (finecosine[an], 15*FRACUNIT); - grenade->y += FixedMul (finesine[an], 15*FRACUNIT); + offset.x += FixedMul (finecosine[an], 15*FRACUNIT); + offset.y += FixedMul (finesine[an], 15*FRACUNIT); + + fixedvec2 newpos = grenade->Vec2Offset(offset.x, offset.y); + grenade->SetOrigin(newpos.x, newpos.y, grenade->Z(), false); } } @@ -923,7 +927,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1) P_BulletSlope (self, &linetarget); if (linetarget != NULL) { - spot = Spawn("SpectralLightningSpot", linetarget->x, linetarget->y, linetarget->floorz, ALLOW_REPLACE); + spot = Spawn("SpectralLightningSpot", linetarget->X(), linetarget->Y(), linetarget->floorz, ALLOW_REPLACE); if (spot != NULL) { spot->tracer = linetarget; @@ -931,7 +935,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil1) } else { - spot = Spawn("SpectralLightningSpot", self->x, self->y, self->z, ALLOW_REPLACE); + spot = Spawn("SpectralLightningSpot", self->Pos(), ALLOW_REPLACE); if (spot != NULL) { spot->velx += 28 * finecosine[self->angle >> ANGLETOFINESHIFT]; @@ -989,7 +993,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_FireSigil3) spot = P_SpawnSubMissile (self, PClass::FindClass("SpectralLightningBall1"), self); if (spot != NULL) { - spot->z = self->z + 32*FRACUNIT; + spot->SetZ(self->Z() + 32*FRACUNIT); } } self->angle -= (ANGLE_180/20)*10; diff --git a/src/g_strife/a_thingstoblowup.cpp b/src/g_strife/a_thingstoblowup.cpp index d27260451..86ae7282e 100644 --- a/src/g_strife/a_thingstoblowup.cpp +++ b/src/g_strife/a_thingstoblowup.cpp @@ -20,10 +20,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_Bang4Cloud) { fixed_t spawnx, spawny; - spawnx = self->x + (pr_bang4cloud.Random2() & 3) * 10240; - spawny = self->y + (pr_bang4cloud.Random2() & 3) * 10240; + fixedvec3 pos = self->Vec3Offset((pr_bang4cloud.Random2() & 3) * 10240, (pr_bang4cloud.Random2() & 3) * 10240, 0); - Spawn("Bang4Cloud", spawnx, spawny, self->z, ALLOW_REPLACE); + Spawn("Bang4Cloud", pos, ALLOW_REPLACE); } // ------------------------------------------------------------------- @@ -97,7 +96,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_LightGoesOut) for (int i = 0; i < 8; ++i) { - foo = Spawn("Rubble1", self->x, self->y, self->z, ALLOW_REPLACE); + foo = Spawn("Rubble1", self->Pos(), ALLOW_REPLACE); if (foo != NULL) { int t = pr_lightout() & 15; diff --git a/src/p_writemap.cpp b/src/p_writemap.cpp index e31d2c4c3..8f1a4edfa 100644 --- a/src/p_writemap.cpp +++ b/src/p_writemap.cpp @@ -98,8 +98,8 @@ static int WriteTHINGS (FILE *file) mapthinghexen_t mt = { 0, 0, 0, 0, 0, 0, 0, 0, {0} }; AActor *mo = players[consoleplayer].mo; - mt.x = LittleShort(short(mo->x >> FRACBITS)); - mt.y = LittleShort(short(mo->y >> FRACBITS)); + mt.x = LittleShort(short(mo->X() >> FRACBITS)); + mt.y = LittleShort(short(mo->Y() >> FRACBITS)); mt.angle = LittleShort(short(MulScale32 (mo->angle >> ANGLETOFINESHIFT, 360))); mt.type = LittleShort((short)1); mt.flags = LittleShort((short)(7|224|MTF_SINGLE)); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 96a77930a..84967c164 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1224,9 +1224,10 @@ void R_DrawSkyBoxes () extralight = 0; R_SetVisibility (sky->args[0] * 0.25f); - viewx = sky->PrevX + FixedMul(r_TicFrac, sky->x - sky->PrevX); - viewy = sky->PrevY + FixedMul(r_TicFrac, sky->y - sky->PrevY); - viewz = sky->PrevZ + FixedMul(r_TicFrac, sky->z - sky->PrevZ); + fixedvec3 viewpos = sky->InterpolatedPosition(r_TicFrac); + viewx = viewpos.x; + viewy = viewpos.y; + viewz = viewpos.z; viewangle = savedangle + sky->PrevAngle + FixedMul(r_TicFrac, sky->angle - sky->PrevAngle); R_CopyStackedViewParameters(); @@ -1235,8 +1236,8 @@ void R_DrawSkyBoxes () { extralight = pl->extralight; R_SetVisibility (pl->visibility); - viewx = pl->viewx - sky->Mate->x + sky->x; - viewy = pl->viewy - sky->Mate->y + sky->y; + viewx = pl->viewx - sky->Mate->X() + sky->X(); + viewy = pl->viewy - sky->Mate->Y() + sky->Y(); viewz = pl->viewz; viewangle = pl->viewangle; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 8e53fb6d1..8ad5f76a9 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -670,9 +670,10 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor } // [RH] Interpolate the sprite's position to make it look smooth - fx = thing->PrevX + FixedMul (r_TicFrac, thing->x - thing->PrevX); - fy = thing->PrevY + FixedMul (r_TicFrac, thing->y - thing->PrevY); - fz = thing->PrevZ + FixedMul (r_TicFrac, thing->z - thing->PrevZ) + thing->GetBobOffset(r_TicFrac); + fixedvec3 pos = thing->InterpolatedPosition(r_TicFrac); + fx = pos.x; + fy = pos.y; + fz = pos.z +thing->GetBobOffset(r_TicFrac); tex = NULL; voxel = NULL; @@ -1145,12 +1146,12 @@ void R_AddSprites (sector_t *sec, int lightlevel, int fakeside) { if(!(rover->top.plane->a) && !(rover->top.plane->b)) { - if(rover->top.plane->Zat0() <= thing->z) fakefloor = rover; + if(rover->top.plane->Zat0() <= thing->Z()) fakefloor = rover; } } if(!(rover->bottom.plane->a) && !(rover->bottom.plane->b)) { - if(rover->bottom.plane->Zat0() >= thing->z + thing->height) fakeceiling = rover; + if(rover->bottom.plane->Zat0() >= thing->Top()) fakeceiling = rover; } } R_ProjectSprite (thing, fakeside, fakefloor, fakeceiling); diff --git a/src/r_utility.cpp b/src/r_utility.cpp index cfe1767c7..d4d3ec97b 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -587,8 +587,8 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi player - players == consoleplayer && camera == player->mo && !demoplayback && - iview->nviewx == camera->x && - iview->nviewy == camera->y && + iview->nviewx == camera->X() && + iview->nviewy == camera->Y() && !(player->cheats & (CF_TOTALLYFROZEN|CF_FROZEN)) && player->playerstate == PST_LIVE && player->mo->reactiontime == 0 && @@ -839,9 +839,9 @@ void R_SetupFrame (AActor *actor) } else { - iview->nviewx = camera->x; - iview->nviewy = camera->y; - iview->nviewz = camera->player ? camera->player->viewz : camera->z + camera->GetClass()->Meta.GetMetaFixed(AMETA_CameraHeight); + iview->nviewx = camera->X(); + iview->nviewy = camera->Y(); + iview->nviewz = camera->player ? camera->player->viewz : camera->Z() + camera->GetClass()->Meta.GetMetaFixed(AMETA_CameraHeight); viewsector = camera->Sector; r_showviewer = false; } From 27aeb6a656958d30c5dd4dc4bcb749b7ee7a16a0 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 19 Jan 2016 13:26:05 +0100 Subject: [PATCH 18/18] - g_shared refactored --- src/g_shared/a_action.cpp | 15 ++++--- src/g_shared/a_artifacts.cpp | 6 +-- src/g_shared/a_bridge.cpp | 12 ++---- src/g_shared/a_camera.cpp | 9 ++--- src/g_shared/a_debris.cpp | 7 +--- src/g_shared/a_decals.cpp | 10 ++--- src/g_shared/a_fastprojectile.cpp | 30 +++++++------- src/g_shared/a_morph.cpp | 16 ++++---- src/g_shared/a_movingcamera.cpp | 65 ++++++++++++++++--------------- src/g_shared/a_pickups.cpp | 38 +++++++++--------- src/g_shared/a_quake.cpp | 2 +- src/g_shared/a_randomspawner.cpp | 12 +++--- src/g_shared/a_spark.cpp | 2 +- src/g_shared/a_specialspot.cpp | 6 +-- src/g_shared/shared_sbar.cpp | 3 +- 15 files changed, 111 insertions(+), 122 deletions(-) diff --git a/src/g_shared/a_action.cpp b/src/g_shared/a_action.cpp index 1149bc2c3..29f24b47e 100644 --- a/src/g_shared/a_action.cpp +++ b/src/g_shared/a_action.cpp @@ -262,14 +262,14 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) i = (pr_freeze.Random2()) % (numChunks/4); for (i = MAX (24, numChunks + i); i >= 0; i--) { - mo = Spawn("IceChunk", - self->x + (((pr_freeze()-128)*self->radius)>>7), - self->y + (((pr_freeze()-128)*self->radius)>>7), - self->z + (pr_freeze()*self->height/255), ALLOW_REPLACE); + mo = Spawn("IceChunk", self->Vec3Offset( + (((pr_freeze()-128)*self->radius)>>7), + (((pr_freeze()-128)*self->radius)>>7), + (pr_freeze()*self->height/255)), ALLOW_REPLACE); if (mo) { mo->SetState (mo->SpawnState + (pr_freeze()%3)); - mo->velz = FixedDiv(mo->z - self->z, self->height)<<2; + mo->velz = FixedDiv(mo->Z() - self->Z(), self->height)<<2; mo->velx = pr_freeze.Random2 () << (FRACBITS-7); mo->vely = pr_freeze.Random2 () << (FRACBITS-7); CALL_ACTION(A_IceSetTics, mo); // set a random tic wait @@ -279,11 +279,10 @@ DEFINE_ACTION_FUNCTION(AActor, A_FreezeDeathChunks) } if (self->player) { // attach the player's view to a chunk of ice - AActor *head = Spawn("IceChunkHead", self->x, self->y, - self->z + self->player->mo->ViewHeight, ALLOW_REPLACE); + AActor *head = Spawn("IceChunkHead", self->PosPlusZ(self->player->mo->ViewHeight), ALLOW_REPLACE); if (head != NULL) { - head->velz = FixedDiv(head->z - self->z, self->height)<<2; + head->velz = FixedDiv(head->Z() - self->Z(), self->height)<<2; head->velx = pr_freeze.Random2 () << (FRACBITS-7); head->vely = pr_freeze.Random2 () << (FRACBITS-7); head->health = self->health; diff --git a/src/g_shared/a_artifacts.cpp b/src/g_shared/a_artifacts.cpp index 2be2e179d..faa5392b7 100644 --- a/src/g_shared/a_artifacts.cpp +++ b/src/g_shared/a_artifacts.cpp @@ -965,7 +965,7 @@ void APowerFlight::InitEffect () Super::InitEffect(); Owner->flags2 |= MF2_FLY; Owner->flags |= MF_NOGRAVITY; - if (Owner->z <= Owner->floorz) + if (Owner->Z() <= Owner->floorz) { Owner->velz = 4*FRACUNIT; // thrust the player in the air a bit } @@ -1012,7 +1012,7 @@ void APowerFlight::EndEffect () if (!(Owner->flags7 & MF7_FLYCHEAT)) { - if (Owner->z != Owner->floorz) + if (Owner->Z() != Owner->floorz) { Owner->player->centering = true; } @@ -1250,7 +1250,7 @@ void APowerSpeed::DoEffect () if (P_AproxDistance (Owner->velx, Owner->vely) <= 12*FRACUNIT) return; - AActor *speedMo = Spawn (Owner->x, Owner->y, Owner->z, NO_REPLACE); + AActor *speedMo = Spawn (Owner->Pos(), NO_REPLACE); if (speedMo) { speedMo->angle = Owner->angle; diff --git a/src/g_shared/a_bridge.cpp b/src/g_shared/a_bridge.cpp index 4caa56287..eed95d8d2 100644 --- a/src/g_shared/a_bridge.cpp +++ b/src/g_shared/a_bridge.cpp @@ -110,9 +110,9 @@ DEFINE_ACTION_FUNCTION(AActor, A_BridgeOrbit) if (self->target->args[4]) rotationradius = ((self->target->args[4] * self->target->radius) / (100 * FRACUNIT)); self->angle += rotationspeed; - self->x = self->target->x + rotationradius * finecosine[self->angle >> ANGLETOFINESHIFT]; - self->y = self->target->y + rotationradius * finesine[self->angle >> ANGLETOFINESHIFT]; - self->z = self->target->z; + self->SetOrigin(self->target->Vec3Angle(rotationradius, self->angle, 0), true); + self->floorz = self->target->floorz; + self->ceilingz = self->target->ceilingz; } @@ -120,16 +120,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit) { angle_t startangle; AActor *ball; - fixed_t cx, cy, cz; ACTION_PARAM_START(1); ACTION_PARAM_CLASS(balltype, 0); if (balltype == NULL) balltype = PClass::FindClass("BridgeBall"); - cx = self->x; - cy = self->y; - cz = self->z; startangle = pr_orbit() << 24; // Spawn triad into world -- may be more than a triad now. @@ -137,7 +133,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_BridgeInit) for (int i = 0; i < ballcount; i++) { - ball = Spawn(balltype, cx, cy, cz, ALLOW_REPLACE); + ball = Spawn(balltype, self->Pos(), ALLOW_REPLACE); ball->angle = startangle + (ANGLE_45/32) * (256/ballcount) * i; ball->target = self; CALL_ACTION(A_BridgeOrbit, ball); diff --git a/src/g_shared/a_camera.cpp b/src/g_shared/a_camera.cpp index 24363851e..61a155ea7 100644 --- a/src/g_shared/a_camera.cpp +++ b/src/g_shared/a_camera.cpp @@ -176,11 +176,10 @@ void AAimingCamera::Tick () } if (MaxPitchChange) { // Aim camera's pitch; use floats for precision - float dx = FIXED2FLOAT(x - tracer->x); - float dy = FIXED2FLOAT(y - tracer->y); - float dz = FIXED2FLOAT(z - tracer->z - tracer->height/2); - float dist = (float)sqrt (dx*dx + dy*dy); - float ang = dist != 0.f ? (float)atan2 (dz, dist) : 0; + TVector2 vect = tracer->Vec2To(this); + double dz = FIXED2DBL(Z() - tracer->Z() - tracer->height/2); + double dist = vect.Length(); + double ang = dist != 0.f ? atan2 (dz, dist) : 0; int desiredpitch = (angle_t)(ang * 2147483648.f / PI); if (abs (desiredpitch - pitch) < MaxPitchChange) { diff --git a/src/g_shared/a_debris.cpp b/src/g_shared/a_debris.cpp index e6fc79b0a..3b34a0d8a 100644 --- a/src/g_shared/a_debris.cpp +++ b/src/g_shared/a_debris.cpp @@ -36,17 +36,14 @@ void P_SpawnDirt (AActor *actor, fixed_t radius) AActor *mo; angle_t angle; - angle = pr_dirt()<<5; // <<24 >>19 - x = actor->x + FixedMul(radius,finecosine[angle]); - y = actor->y + FixedMul(radius,finesine[angle]); - z = actor->z + (pr_dirt()<<9) + FRACUNIT; + fixedvec3 pos = actor->Vec3Angle(radius, pr_dirt() << 24, (pr_dirt() << 9) + FRACUNIT); char fmt[8]; mysnprintf(fmt, countof(fmt), "Dirt%d", 1 + pr_dirt()%6); dtype = PClass::FindClass(fmt); if (dtype) { - mo = Spawn (dtype, x, y, z, ALLOW_REPLACE); + mo = Spawn (dtype, pos, ALLOW_REPLACE); if (mo) { mo->velz = pr_dirt()<<10; diff --git a/src/g_shared/a_decals.cpp b/src/g_shared/a_decals.cpp index 29fcbf8cb..64921d647 100644 --- a/src/g_shared/a_decals.cpp +++ b/src/g_shared/a_decals.cpp @@ -91,7 +91,7 @@ DBaseDecal::DBaseDecal (int statnum, fixed_t z) DBaseDecal::DBaseDecal (const AActor *basis) : DThinker(STAT_DECAL), - WallNext(0), WallPrev(0), LeftDistance(0), Z(basis->z), ScaleX(basis->scaleX), ScaleY(basis->scaleY), + WallNext(0), WallPrev(0), LeftDistance(0), Z(basis->Z()), ScaleX(basis->scaleX), ScaleY(basis->scaleY), Alpha(basis->alpha), AlphaColor(basis->fillcolor), Translation(basis->Translation), PicNum(basis->picnum), RenderFlags(basis->renderflags), RenderStyle(basis->RenderStyle) { @@ -817,22 +817,22 @@ void ADecal::BeginPlay () { if (!tpl->PicNum.Exists()) { - Printf("Decal actor at (%d,%d) does not have a valid texture\n", x>>FRACBITS, y>>FRACBITS); + Printf("Decal actor at (%d,%d) does not have a valid texture\n", X()>>FRACBITS, Y()>>FRACBITS); } else { // Look for a wall within 64 units behind the actor. If none can be // found, then no decal is created, and this actor is destroyed // without effectively doing anything. - if (NULL == ShootDecal(tpl, this, Sector, x, y, z, angle + ANGLE_180, 64*FRACUNIT, true)) + if (NULL == ShootDecal(tpl, this, Sector, X(), Y(), Z(), angle + ANGLE_180, 64*FRACUNIT, true)) { - DPrintf ("Could not find a wall to stick decal to at (%d,%d)\n", x>>FRACBITS, y>>FRACBITS); + DPrintf ("Could not find a wall to stick decal to at (%d,%d)\n", X()>>FRACBITS, Y()>>FRACBITS); } } } else { - DPrintf ("Decal actor at (%d,%d) does not have a good template\n", x>>FRACBITS, y>>FRACBITS); + DPrintf ("Decal actor at (%d,%d) does not have a good template\n", X()>>FRACBITS, Y()>>FRACBITS); } // This actor doesn't need to stick around anymore. Destroy(); diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index c019fcbf6..ae7f6a58b 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -25,10 +25,10 @@ void AFastProjectile::Tick () fixed_t zfrac; int changexy; - PrevX = x; - PrevY = y; - PrevZ = z; - fixed_t oldz = z; + PrevX = X(); + PrevY = Y(); + PrevZ = Z(); + fixed_t oldz = Z(); PrevAngle = angle; if (!(flags5 & MF5_NOTIMEFREEZE)) @@ -57,7 +57,7 @@ void AFastProjectile::Tick () } // Handle movement - if (velx || vely || (z != floorz) || velz) + if (velx || vely || (Z() != floorz) || velz) { xfrac = velx >> shift; yfrac = vely >> shift; @@ -73,14 +73,14 @@ void AFastProjectile::Tick () tm.LastRipped = NULL; // [RH] Do rip damage each step, like Hexen } - if (!P_TryMove (this, x + xfrac,y + yfrac, true, NULL, tm)) + if (!P_TryMove (this, X() + xfrac,Y() + yfrac, true, NULL, tm)) { // Blocked move if (!(flags3 & MF3_SKYEXPLODE)) { if (tm.ceilingline && tm.ceilingline->backsector && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && - z >= tm.ceilingline->backsector->ceilingplane.ZatPoint (x, y)) + Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint (this)) { // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. @@ -99,10 +99,10 @@ void AFastProjectile::Tick () return; } } - z += zfrac; + AddZ(zfrac); UpdateWaterLevel (oldz); - oldz = z; - if (z <= floorz) + oldz = Z(); + if (Z() <= floorz) { // Hit the floor if (floorpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE)) @@ -113,12 +113,12 @@ void AFastProjectile::Tick () return; } - z = floorz; + SetZ(floorz); P_HitFloor (this); P_ExplodeMissile (this, NULL, NULL); return; } - if (z + height > ceilingz) + if (Top() > ceilingz) { // Hit the ceiling if (ceilingpic == skyflatnum && !(flags3 & MF3_SKYEXPLODE)) @@ -127,7 +127,7 @@ void AFastProjectile::Tick () return; } - z = ceilingz - height; + SetZ(ceilingz - height); P_ExplodeMissile (this, NULL, NULL); return; } @@ -160,7 +160,7 @@ void AFastProjectile::Effect() FName name = (ENamedName) this->GetClass()->Meta.GetMetaInt (ACMETA_MissileName, NAME_None); if (name != NAME_None) { - fixed_t hitz = z-8*FRACUNIT; + fixed_t hitz = Z()-8*FRACUNIT; if (hitz < floorz) { @@ -172,7 +172,7 @@ void AFastProjectile::Effect() const PClass *trail = PClass::FindClass(name); if (trail != NULL) { - AActor *act = Spawn (trail, x, y, hitz, ALLOW_REPLACE); + AActor *act = Spawn (trail, X(), Y(), hitz, ALLOW_REPLACE); if (act != NULL) { act->angle = this->angle; diff --git a/src/g_shared/a_morph.cpp b/src/g_shared/a_morph.cpp index 4da6eb67b..bc63f7bf0 100644 --- a/src/g_shared/a_morph.cpp +++ b/src/g_shared/a_morph.cpp @@ -77,7 +77,7 @@ bool P_MorphPlayer (player_t *activator, player_t *p, const PClass *spawntype, i return false; } - morphed = static_cast(Spawn (spawntype, actor->x, actor->y, actor->z, NO_REPLACE)); + morphed = static_cast(Spawn (spawntype, actor->Pos(), NO_REPLACE)); EndAllPowerupEffects(actor->Inventory); DObject::StaticPointerSubstitution (actor, morphed); if ((actor->tid != 0) && (style & MORPH_NEWTIDBEHAVIOUR)) @@ -105,7 +105,7 @@ bool P_MorphPlayer (player_t *activator, player_t *p, const PClass *spawntype, i morphed->flags |= actor->flags & (MF_SHADOW|MF_NOGRAVITY); morphed->flags2 |= actor->flags2 & MF2_FLY; morphed->flags3 |= actor->flags3 & MF3_GHOST; - AActor *eflash = Spawn(((enter_flash) ? enter_flash : RUNTIME_CLASS(ATeleportFog)), actor->x, actor->y, actor->z + TELEFOGHEIGHT, ALLOW_REPLACE); + AActor *eflash = Spawn(((enter_flash) ? enter_flash : RUNTIME_CLASS(ATeleportFog)), actor->PosPlusZ(TELEFOGHEIGHT), ALLOW_REPLACE); actor->player = NULL; actor->flags &= ~(MF_SOLID|MF_SHOOTABLE); actor->flags |= MF_UNMORPHED; @@ -192,7 +192,7 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag, } mo = barrier_cast(pmo->tracer); - mo->SetOrigin (pmo->x, pmo->y, pmo->z); + mo->SetOrigin (pmo->Pos(), false); mo->flags |= MF_SOLID; pmo->flags &= ~MF_SOLID; if (!force && !P_TestMobjLocation (mo)) @@ -310,7 +310,7 @@ bool P_UndoPlayerMorph (player_t *activator, player_t *player, int unmorphflag, AActor *eflash = NULL; if (exit_flash != NULL) { - eflash = Spawn(exit_flash, pmo->x + 20*finecosine[angle], pmo->y + 20*finesine[angle], pmo->z + TELEFOGHEIGHT, ALLOW_REPLACE); + eflash = Spawn(exit_flash, pmo->Vec3Offset(20*finecosine[angle], 20*finesine[angle], TELEFOGHEIGHT), ALLOW_REPLACE); if (eflash) eflash->target = mo; } mo->SetupWeaponSlots(); // Use original class's weapon slots. @@ -381,7 +381,7 @@ bool P_MorphMonster (AActor *actor, const PClass *spawntype, int duration, int s return false; } - morphed = static_cast(Spawn (spawntype, actor->x, actor->y, actor->z, NO_REPLACE)); + morphed = static_cast(Spawn (spawntype, actor->Pos(), NO_REPLACE)); DObject::StaticPointerSubstitution (actor, morphed); morphed->tid = actor->tid; morphed->angle = actor->angle; @@ -410,7 +410,7 @@ bool P_MorphMonster (AActor *actor, const PClass *spawntype, int duration, int s actor->flags &= ~(MF_SOLID|MF_SHOOTABLE); actor->flags |= MF_UNMORPHED; actor->renderflags |= RF_INVISIBLE; - AActor *eflash = Spawn(((enter_flash) ? enter_flash : RUNTIME_CLASS(ATeleportFog)), actor->x, actor->y, actor->z + TELEFOGHEIGHT, ALLOW_REPLACE); + AActor *eflash = Spawn(((enter_flash) ? enter_flash : RUNTIME_CLASS(ATeleportFog)), actor->PosPlusZ(TELEFOGHEIGHT), ALLOW_REPLACE); if (eflash) eflash->target = morphed; return true; @@ -436,7 +436,7 @@ bool P_UndoMonsterMorph (AMorphedMonster *beast, bool force) return false; } actor = beast->UnmorphedMe; - actor->SetOrigin (beast->x, beast->y, beast->z); + actor->SetOrigin (beast->Pos(), false); actor->flags |= MF_SOLID; beast->flags &= ~MF_SOLID; ActorFlags6 beastflags6 = beast->flags6; @@ -472,7 +472,7 @@ bool P_UndoMonsterMorph (AMorphedMonster *beast, bool force) DObject::StaticPointerSubstitution (beast, actor); const PClass *exit_flash = beast->MorphExitFlash; beast->Destroy (); - AActor *eflash = Spawn(exit_flash, beast->x, beast->y, beast->z + TELEFOGHEIGHT, ALLOW_REPLACE); + AActor *eflash = Spawn(exit_flash, beast->PosPlusZ(TELEFOGHEIGHT), ALLOW_REPLACE); if (eflash) eflash->target = actor; return true; diff --git a/src/g_shared/a_movingcamera.cpp b/src/g_shared/a_movingcamera.cpp index 0f847fa41..fe4526e16 100644 --- a/src/g_shared/a_movingcamera.cpp +++ b/src/g_shared/a_movingcamera.cpp @@ -282,7 +282,7 @@ void APathFollower::Activate (AActor *activator) if (CurrNode != NULL) { NewNode (); - SetOrigin (CurrNode->x, CurrNode->y, CurrNode->z); + SetOrigin (CurrNode->Pos(), false); Time = 0.f; HoldTime = 0; bJustStepped = true; @@ -302,9 +302,7 @@ void APathFollower::Tick () if (CurrNode->args[2]) { HoldTime = level.time + CurrNode->args[2] * TICRATE / 8; - x = CurrNode->x; - y = CurrNode->y; - z = CurrNode->z; + SetXYZ(CurrNode->X(), CurrNode->Y(), CurrNode->Z()); } } @@ -362,31 +360,33 @@ bool APathFollower::Interpolate () if ((args[2] & 8) && Time > 0.f) { - dx = x; - dy = y; - dz = z; + dx = X(); + dy = Y(); + dz = Z(); } if (CurrNode->Next==NULL) return false; UnlinkFromWorld (); + fixed_t x, y, z; if (args[2] & 1) { // linear - x = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->x), FIXED2FLOAT(CurrNode->Next->x))); - y = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->y), FIXED2FLOAT(CurrNode->Next->y))); - z = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->z), FIXED2FLOAT(CurrNode->Next->z))); + x = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->X()), FIXED2FLOAT(CurrNode->Next->X()))); + y = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->Y()), FIXED2FLOAT(CurrNode->Next->Y()))); + z = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->Z()), FIXED2FLOAT(CurrNode->Next->Z()))); } else { // spline if (CurrNode->Next->Next==NULL) return false; - x = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->x), FIXED2FLOAT(CurrNode->x), - FIXED2FLOAT(CurrNode->Next->x), FIXED2FLOAT(CurrNode->Next->Next->x))); - y = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->y), FIXED2FLOAT(CurrNode->y), - FIXED2FLOAT(CurrNode->Next->y), FIXED2FLOAT(CurrNode->Next->Next->y))); - z = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->z), FIXED2FLOAT(CurrNode->z), - FIXED2FLOAT(CurrNode->Next->z), FIXED2FLOAT(CurrNode->Next->Next->z))); + x = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->X()), FIXED2FLOAT(CurrNode->X()), + FIXED2FLOAT(CurrNode->Next->X()), FIXED2FLOAT(CurrNode->Next->Next->X()))); + y = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->Y()), FIXED2FLOAT(CurrNode->Y()), + FIXED2FLOAT(CurrNode->Next->Y()), FIXED2FLOAT(CurrNode->Next->Next->Y()))); + z = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->Z()), FIXED2FLOAT(CurrNode->Z()), + FIXED2FLOAT(CurrNode->Next->Z()), FIXED2FLOAT(CurrNode->Next->Next->Z()))); } + SetXYZ(x, y, z); LinkToWorld (); if (args[2] & 6) @@ -395,9 +395,9 @@ bool APathFollower::Interpolate () { if (args[2] & 1) { // linear - dx = CurrNode->Next->x - CurrNode->x; - dy = CurrNode->Next->y - CurrNode->y; - dz = CurrNode->Next->z - CurrNode->z; + dx = CurrNode->Next->X() - CurrNode->X(); + dy = CurrNode->Next->Y() - CurrNode->Y(); + dz = CurrNode->Next->Z() - CurrNode->Z(); } else if (Time > 0.f) { // spline @@ -422,6 +422,7 @@ bool APathFollower::Interpolate () x -= dx; y -= dy; z -= dz; + SetXYZ(x, y, z); } if (args[2] & 2) { // adjust yaw @@ -548,11 +549,11 @@ bool AActorMover::Interpolate () if (Super::Interpolate ()) { - fixed_t savedz = tracer->z; - tracer->z = z; - if (!P_TryMove (tracer, x, y, true)) + fixed_t savedz = tracer->Z(); + tracer->SetZ(Z()); + if (!P_TryMove (tracer, X(), Y(), true)) { - tracer->z = savedz; + tracer->SetZ(savedz); return false; } @@ -589,9 +590,9 @@ void AActorMover::Activate (AActor *activator) // Don't let the renderer interpolate between the actor's // old position and its new position. Interpolate (); - tracer->PrevX = tracer->x; - tracer->PrevY = tracer->y; - tracer->PrevZ = tracer->z; + tracer->PrevX = tracer->X(); + tracer->PrevY = tracer->Y(); + tracer->PrevZ = tracer->Z(); tracer->PrevAngle = tracer->angle; } @@ -667,15 +668,15 @@ bool AMovingCamera::Interpolate () if (Super::Interpolate ()) { - angle = R_PointToAngle2 (x, y, tracer->x, tracer->y); + angle = AngleTo(tracer, true); if (args[2] & 4) { // Also aim camera's pitch; use floats for precision - float dx = FIXED2FLOAT(x - tracer->x); - float dy = FIXED2FLOAT(y - tracer->y); - float dz = FIXED2FLOAT(z - tracer->z - tracer->height/2); - float dist = (float)sqrt (dx*dx + dy*dy); - float ang = dist != 0.f ? (float)atan2 (dz, dist) : 0; + double dx = FIXED2DBL(X() - tracer->X()); + double dy = FIXED2DBL(Y() - tracer->Y()); + double dz = FIXED2DBL(Z() - tracer->Z() - tracer->height/2); + double dist = sqrt (dx*dx + dy*dy); + double ang = dist != 0.f ? atan2 (dz, dist) : 0; pitch = (angle_t)(ang * 2147483648.f / PI); } diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index eb2831024..9fe31db22 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -331,7 +331,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialDoomThing) { self->SetState (self->SpawnState); S_Sound (self, CHAN_VOICE, "misc/spawn", 1, ATTN_IDLE); - Spawn ("ItemFog", self->x, self->y, self->z, ALLOW_REPLACE); + Spawn ("ItemFog", self->Pos(), ALLOW_REPLACE); } } @@ -351,19 +351,18 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) _y = self->SpawnPoint[1]; self->UnlinkFromWorld(); - self->x = _x; - self->y = _y; + self->SetXY(_x, _y); self->LinkToWorld(true); sec = self->Sector; - self->z = self->dropoffz = self->floorz = sec->floorplane.ZatPoint(_x, _y); self->ceilingz = sec->ceilingplane.ZatPoint(_x, _y); + self->SetZ(self->floorz); P_FindFloorCeiling(self, FFCF_ONLYSPAWNPOS); if (self->flags & MF_SPAWNCEILING) { - self->z = self->ceilingz - self->height - self->SpawnPoint[2]; + self->SetZ(self->ceilingz - self->height - self->SpawnPoint[2]); } else if (self->flags2 & MF2_SPAWNFLOAT) { @@ -371,33 +370,33 @@ DEFINE_ACTION_FUNCTION(AActor, A_RestoreSpecialPosition) if (space > 48*FRACUNIT) { space -= 40*FRACUNIT; - self->z = ((space * pr_restore())>>8) + self->floorz + 40*FRACUNIT; + self->SetZ(((space * pr_restore())>>8) + self->floorz + 40*FRACUNIT); } else { - self->z = self->floorz; + self->SetZ(self->floorz); } } else { - self->z = self->SpawnPoint[2] + self->floorz; + self->SetZ(self->SpawnPoint[2] + self->floorz); } // Redo floor/ceiling check, in case of 3D floors P_FindFloorCeiling(self, FFCF_SAMESECTOR | FFCF_ONLY3DFLOORS | FFCF_3DRESTRICT); - if (self->z < self->floorz) + if (self->Z() < self->floorz) { // Do not reappear under the floor, even if that's where we were for the // initial spawn. - self->z = self->floorz; + self->SetZ(self->floorz); } - if ((self->flags & MF_SOLID) && (self->z + self->height > self->ceilingz)) + if ((self->flags & MF_SOLID) && (self->Top() > self->ceilingz)) { // Do the same for the ceiling. - self->z = self->ceilingz - self->height; + self->SetZ(self->ceilingz - self->height); } // Do not interpolate from the position the actor was at when it was // picked up, in case that is different from where it is now. - self->PrevX = self->x; - self->PrevY = self->y; - self->PrevZ = self->z; + self->PrevX = self->X(); + self->PrevY = self->Y(); + self->PrevZ = self->Z(); } int AInventory::StaticLastMessageTic; @@ -728,8 +727,7 @@ AInventory *AInventory::CreateTossable () flags &= ~(MF_SPECIAL|MF_SOLID); return this; } - copy = static_cast(Spawn (GetClass(), Owner->x, - Owner->y, Owner->z, NO_REPLACE)); + copy = static_cast(Spawn (GetClass(), Owner->Pos(), NO_REPLACE)); if (copy != NULL) { copy->MaxAmount = MaxAmount; @@ -994,7 +992,7 @@ void AInventory::Touch (AActor *toucher) // This is the only situation when a pickup flash should ever play. if (PickupFlash != NULL && !ShouldStay()) { - Spawn(PickupFlash, x, y, z, ALLOW_REPLACE); + Spawn(PickupFlash, Pos(), ALLOW_REPLACE); } if (!(ItemFlags & IF_QUIET)) @@ -1290,8 +1288,8 @@ bool AInventory::DoRespawn () if (state != NULL) spot = state->GetRandomSpot(SpawnPointClass); if (spot != NULL) { - SetOrigin (spot->x, spot->y, spot->z); - z = floorz; + SetOrigin (spot->Pos(), false); + SetZ(floorz); } } return true; diff --git a/src/g_shared/a_quake.cpp b/src/g_shared/a_quake.cpp index 195f3ccbf..94a375d3e 100644 --- a/src/g_shared/a_quake.cpp +++ b/src/g_shared/a_quake.cpp @@ -131,7 +131,7 @@ void DEarthquake::Tick () dist = m_Spot->AproxDistance (victim, true); // Check if in damage radius - if (dist < m_DamageRadius && victim->z <= victim->floorz) + if (dist < m_DamageRadius && victim->Z() <= victim->floorz) { if (pr_quake() < 50) { diff --git a/src/g_shared/a_randomspawner.cpp b/src/g_shared/a_randomspawner.cpp index 7d000f3d4..2ba445b7b 100644 --- a/src/g_shared/a_randomspawner.cpp +++ b/src/g_shared/a_randomspawner.cpp @@ -91,7 +91,7 @@ class ARandomSpawner : public AActor // So now we can spawn the dropped item. if (di == NULL || bouncecount >= MAX_RANDOMSPAWNERS_RECURSION) // Prevents infinite recursions { - Spawn("Unknown", x, y, z, NO_REPLACE); // Show that there's a problem. + Spawn("Unknown", Pos(), NO_REPLACE); // Show that there's a problem. Destroy(); return; } @@ -144,9 +144,9 @@ class ARandomSpawner : public AActor if (this->flags & MF_MISSILE && target && target->target) // Attempting to spawn a missile. { if ((tracer == NULL) && (flags2 & MF2_SEEKERMISSILE)) tracer = target->target; - newmobj = P_SpawnMissileXYZ(x, y, z, target, target->target, cls, false); + newmobj = P_SpawnMissileXYZ(Pos(), target, target->target, cls, false); } - else newmobj = Spawn(cls, x, y, z, NO_REPLACE); + else newmobj = Spawn(cls, Pos(), NO_REPLACE); if (newmobj != NULL) { // copy everything relevant @@ -179,7 +179,7 @@ class ARandomSpawner : public AActor // Handle special altitude flags if (newmobj->flags & MF_SPAWNCEILING) { - newmobj->z = newmobj->ceilingz - newmobj->height - SpawnPoint[2]; + newmobj->SetZ(newmobj->ceilingz - newmobj->height - SpawnPoint[2]); } else if (newmobj->flags2 & MF2_SPAWNFLOAT) { @@ -187,9 +187,9 @@ class ARandomSpawner : public AActor if (space > 48*FRACUNIT) { space -= 40*FRACUNIT; - newmobj->z = MulScale8 (space, pr_randomspawn()) + newmobj->floorz + 40*FRACUNIT; + newmobj->SetZ(MulScale8 (space, pr_randomspawn()) + newmobj->floorz + 40*FRACUNIT); } - newmobj->z += SpawnPoint[2]; + newmobj->AddZ(SpawnPoint[2]); } if (newmobj->flags & MF_MISSILE) P_CheckMissileSpawn(newmobj, 0); diff --git a/src/g_shared/a_spark.cpp b/src/g_shared/a_spark.cpp index 18b27d9ff..eee842f36 100644 --- a/src/g_shared/a_spark.cpp +++ b/src/g_shared/a_spark.cpp @@ -50,6 +50,6 @@ IMPLEMENT_CLASS (ASpark) void ASpark::Activate (AActor *activator) { Super::Activate (activator); - P_DrawSplash (args[0] ? args[0] : 32, x, y, z, angle, 1); + P_DrawSplash (args[0] ? args[0] : 32, X(), Y(), Z(), angle, 1); S_Sound (this, CHAN_AUTO, "world/spark", 1, ATTN_STATIC); } diff --git a/src/g_shared/a_specialspot.cpp b/src/g_shared/a_specialspot.cpp index d3994ed84..1d2747ceb 100644 --- a/src/g_shared/a_specialspot.cpp +++ b/src/g_shared/a_specialspot.cpp @@ -423,12 +423,12 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_SpawnSingleItem) return; } - AActor *spawned = Spawn(cls, self->x, self->y, self->z, ALLOW_REPLACE); + AActor *spawned = Spawn(cls, self->Pos(), ALLOW_REPLACE); if (spawned) { - spawned->SetOrigin (spot->x, spot->y, spot->z); - spawned->z = spawned->floorz; + spawned->SetOrigin (spot->Pos(), false); + spawned->SetZ(spawned->floorz); // We want this to respawn. if (!(self->flags & MF_DROPPED)) { diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index b351212d0..bd2946f2a 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -1287,8 +1287,7 @@ void DBaseStatusBar::Draw (EHudState state) } fixedvec3 pos = CPlayer->mo->Pos(); - value = &pos.z; - for (i = 2, value = &CPlayer->mo->z; i >= 0; y -= height, --value, --i) + for (i = 2, value = &pos.z; i >= 0; y -= height, --value, --i) { mysnprintf (line, countof(line), "%c: %d", labels[i], *value >> FRACBITS); screen->DrawText (SmallFont, CR_GREEN, xpos, y, line,