From b735138332bbbb09db4a81ff243bd550362e0b9c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 17 Jan 2016 22:56:16 +0100 Subject: [PATCH 1/4] - 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 2/4] - 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 3/4] - 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 4/4] - 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); }