From f357a36c5cef92dd39ce7d389cdb9fcd8c33cb57 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 5 Nov 2015 13:01:44 -0600 Subject: [PATCH 01/23] - New A_Chase flags. - CHF_NORANDOMTURN: Actor will not randomly turn during chasing to pursue its target. It will only turn if it cannot keep moving forward. - CHF_DONTANGLE: Actor does not adjust its angle to match the movement direction. - CHF_NOPOSTATTACKTURN: Actor will not make its first turn after exiting its attacks. --- src/p_enemy.cpp | 43 +++++++++++++++++------------- wadsrc/static/actors/constants.txt | 3 +++ 2 files changed, 27 insertions(+), 19 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 5291101a5..669a9fbb6 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2163,7 +2163,19 @@ nosee: //============================================================================= #define CLASS_BOSS_STRAFE_RANGE 64*10*FRACUNIT -void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove) +enum ChaseFlags +{ + CHF_FASTCHASE = 1, + CHF_NOPLAYACTIVE = 2, + CHF_NIGHTMAREFAST = 4, + CHF_RESURRECT = 8, + CHF_DONTMOVE = 16, + CHF_NORANDOMTURN = 32, + CHF_DONTANGLE = 64, + CHF_NOPOSTATTACKTURN = 128, +}; + +void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove, int flags) { int delta; @@ -2225,7 +2237,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi { A_FaceTarget(actor); } - else if (actor->movedir < 8) + else if (!(flags & CHF_DONTANGLE) && actor->movedir < 8) { actor->angle &= (angle_t)(7<<29); delta = actor->angle - (actor->movedir << 29); @@ -2315,7 +2327,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi if (actor->flags & MF_JUSTATTACKED) { actor->flags &= ~MF_JUSTATTACKED; - if (!actor->isFast() && !dontmove) + if (!actor->isFast() && !dontmove && !(flags & CHF_NOPOSTATTACKTURN)) { P_NewChaseDir (actor); } @@ -2485,7 +2497,9 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi FTextureID oldFloor = actor->floorpic; // chase towards player - if (--actor->movecount < 0 || !P_Move (actor)) + if (actor->movecount >= 0) + actor->movecount--; + if (((!(flags & CHF_NORANDOMTURN)) && (actor->movecount < 0)) || !P_Move(actor)) { P_NewChaseDir (actor); } @@ -2662,15 +2676,6 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) // //========================================================================== -enum ChaseFlags -{ - CHF_FASTCHASE = 1, - CHF_NOPLAYACTIVE = 2, - CHF_NIGHTMAREFAST = 4, - CHF_RESURRECT = 8, - CHF_DONTMOVE = 16, -}; - DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Chase) { ACTION_PARAM_START(3); @@ -2683,23 +2688,23 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Chase) if (flags & CHF_RESURRECT && P_CheckForResurrection(self, false)) return; A_DoChase(self, !!(flags&CHF_FASTCHASE), melee, missile, !(flags&CHF_NOPLAYACTIVE), - !!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE)); + !!(flags&CHF_NIGHTMAREFAST), !!(flags&CHF_DONTMOVE), flags); } else // this is the old default A_Chase { - A_DoChase (self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false); + A_DoChase (self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, flags); } } DEFINE_ACTION_FUNCTION(AActor, A_FastChase) { - A_DoChase (self, true, self->MeleeState, self->MissileState, true, true, false); + A_DoChase (self, true, self->MeleeState, self->MissileState, true, true, false, 0); } DEFINE_ACTION_FUNCTION(AActor, A_VileChase) { if (!P_CheckForResurrection(self, true)) - A_DoChase (self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false); + A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0); } DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ExtChase) @@ -2713,13 +2718,13 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ExtChase) // Now that A_Chase can handle state label parameters, this function has become rather useless... A_DoChase(self, false, domelee ? self->MeleeState:NULL, domissile ? self->MissileState:NULL, - playactive, nightmarefast, false); + playactive, nightmarefast, false, 0); } // for internal use void A_Chase(AActor *self) { - A_DoChase (self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false); + A_DoChase(self, false, self->MeleeState, self->MissileState, true, gameinfo.nightmarefast, false, 0); } //============================================================================= diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 213e2109d..01d92c103 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -84,6 +84,9 @@ const int CHF_NOPLAYACTIVE = 2; const int CHF_NIGHTMAREFAST = 4; const int CHF_RESURRECT = 8; const int CHF_DONTMOVE = 16; +const int CHF_NORANDOMTURN = 32; +const int CHF_DONTANGLE = 64; +const int CHF_NOPOSTATTACKTURN = 128; // Flags for A_LookEx const int LOF_NOSIGHTCHECK = 1; From da9c3ff9d2301f35862b5a743f1f50bf512c85f7 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 5 Nov 2015 15:33:56 -0600 Subject: [PATCH 02/23] Added A_Wander Flags. - WF_NORANDOMTURN and WF_DONTANGLE do the same as their CHF_ counterparts for A_Wander. --- src/p_enemy.cpp | 44 ++++++++++++++++++++++-------- src/p_enemy.h | 2 +- wadsrc/static/actors/actor.txt | 2 +- wadsrc/static/actors/constants.txt | 7 +++++ 4 files changed, 42 insertions(+), 13 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 669a9fbb6..68de283da 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -1799,7 +1799,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_Look) } else { - CALL_ACTION(A_Wander, self); + A_Wander(self); } } else @@ -1957,7 +1957,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) } else { - CALL_ACTION(A_Wander, self); + A_Wander(self); } } } @@ -2054,7 +2054,27 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_ClearLastHeard) // A_Wander // //========================================================================== -DEFINE_ACTION_FUNCTION(AActor, A_Wander) +enum WFFlags +{ + WF_NORANDOMTURN = 1, + WF_DONTANGLE = 2, +}; + +DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Wander) +{ + ACTION_PARAM_START(1); + ACTION_PARAM_INT(flags, 0); + + A_Wander(self, flags); +} + +// [MC] I had to move this out from within A_Wander in order to allow flags to +// pass into it. That meant replacing the CALL_ACTION(A_Wander) functions with +// just straight up defining A_Wander in order to compile. Looking around though, +// actors from the games themselves just do a straight A_Chase call itself so +// I saw no harm in it. + +void A_Wander(AActor *self, int flags) { // [RH] Strife probably clears this flag somewhere, but I couldn't find where. // This seems as good a place as any. @@ -2073,28 +2093,30 @@ DEFINE_ACTION_FUNCTION(AActor, A_Wander) } // turn towards movement direction if not there yet - if (self->movedir < DI_NODIR) + if (!(flags & WF_DONTANGLE) && (self->movedir < DI_NODIR)) { - self->angle &= (angle_t)(7<<29); + self->angle &= (angle_t)(7 << 29); int delta = self->angle - (self->movedir << 29); if (delta > 0) { - self->angle -= ANG90/2; + self->angle -= ANG90 / 2; } else if (delta < 0) { - self->angle += ANG90/2; + self->angle += ANG90 / 2; } } - if (--self->movecount < 0 || !P_Move (self)) + if (self->movecount >= 0) + self->movecount--; + + if ((!(flags & WF_NORANDOMTURN) && self->movecount < 0) || !P_Move(self)) { - P_RandomChaseDir (self); + P_RandomChaseDir(self); self->movecount += 5; } } - //========================================================================== // // A_Look2 @@ -2309,7 +2331,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi //CALL_ACTION(A_Look, actor); if (actor->target == NULL) { - if (!dontmove) CALL_ACTION(A_Wander, actor); + if (!dontmove) A_Wander(actor); actor->flags &= ~MF_INCHASE; return; } diff --git a/src/p_enemy.h b/src/p_enemy.h index 799b4c0ff..15ac335e0 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -61,7 +61,6 @@ void A_Weave(AActor *self, int xyspeed, int zspeed, fixed_t xydist, fixed_t zdis void A_Unblock(AActor *self, bool drop); DECLARE_ACTION(A_Look) -DECLARE_ACTION(A_Wander) DECLARE_ACTION(A_BossDeath) DECLARE_ACTION(A_Pain) DECLARE_ACTION(A_MonsterRail) @@ -72,6 +71,7 @@ DECLARE_ACTION(A_FreezeDeathChunks) DECLARE_ACTION(A_BossDeath) void A_Chase(AActor *self); +void A_Wander(AActor *self, int flags = 0); void A_FaceTarget(AActor *actor, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270, angle_t ang_offset = 0, angle_t pitch_offset = 0, int flags = 0); void A_Face(AActor *self, AActor *other, angle_t max_turn = 0, angle_t max_pitch = ANGLE_270, angle_t ang_offset = 0, angle_t pitch_offset = 0, int flags = 0); diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 5158aa7b5..6c0fe6944 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -176,7 +176,7 @@ ACTOR Actor native //: Thinker action native A_SkullPop(class skulltype = "BloodySkull"); action native A_CheckPlayerDone(); - action native A_Wander(); + action native A_Wander(int flags = 0); action native A_Look2(); action native A_TossGib(); action native A_SentinelBob(); diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 01d92c103..143477bac 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -513,6 +513,13 @@ enum CBF_SETONPTR = 1 << 4, //Sets the pointer change on the actor doing the checking instead of self. }; +// Wander Flags +enum +{ + WF_NORANDOMTURN = 1, + WF_DONTANGLE = 2, +}; + // This is only here to provide one global variable for testing. native int testglobalvar; From bfd9e2bc1c18dbc5e9ea998135dea2be2deb5820 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Thu, 7 Jan 2016 19:20:02 -0600 Subject: [PATCH 03/23] - Added CHF_STOPIFBLOCKED and CHF_DONTTURN macro. - CHF_STOPIFBLOCKED simply prevents the actor from changing directions for movement. - CHF_DONTTURN implies NORANDOMTURN, NOPOSTATTACKTURN and STOPIFBLOCKED. --- src/p_enemy.cpp | 19 ++++++++++++++----- wadsrc/static/actors/constants.txt | 22 ++++++++++++++-------- 2 files changed, 28 insertions(+), 13 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 68de283da..8ace645d2 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2195,6 +2195,7 @@ enum ChaseFlags CHF_NORANDOMTURN = 32, CHF_DONTANGLE = 64, CHF_NOPOSTATTACKTURN = 128, + CHF_STOPIFBLOCKED = 256, }; void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove, int flags) @@ -2349,10 +2350,15 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi if (actor->flags & MF_JUSTATTACKED) { actor->flags &= ~MF_JUSTATTACKED; - if (!actor->isFast() && !dontmove && !(flags & CHF_NOPOSTATTACKTURN)) + if (!actor->isFast() && !dontmove && !(flags & CHF_NOPOSTATTACKTURN) && !(flags & CHF_STOPIFBLOCKED)) { P_NewChaseDir (actor); } + //Because P_TryWalk would never be reached if the actor is stopped by a blocking object, + //need to make sure the movecount is reset, otherwise they will just keep attacking + //over and over again. + if (flags & CHF_STOPIFBLOCKED) + actor->movecount = pr_trywalk() & 15; actor->flags &= ~MF_INCHASE; return; } @@ -2510,6 +2516,8 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi if (actor->strafecount) actor->strafecount--; + bool movecheck = P_Move(actor); + // class bosses don't do this when strafing if ((!fastchase || !actor->FastChaseStrafeCount) && !dontmove) { @@ -2521,24 +2529,25 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi // chase towards player if (actor->movecount >= 0) actor->movecount--; - if (((!(flags & CHF_NORANDOMTURN)) && (actor->movecount < 0)) || !P_Move(actor)) + if (!(flags & CHF_STOPIFBLOCKED)) { - P_NewChaseDir (actor); + if ((!(flags & CHF_NORANDOMTURN) && (actor->movecount < 0)) || !movecheck) + P_NewChaseDir(actor); } // if the move was illegal, reset it // (copied from A_SerpentChase - it applies to everything with CANTLEAVEFLOORPIC!) if (actor->flags2&MF2_CANTLEAVEFLOORPIC && actor->floorpic != oldFloor ) { - if (P_TryMove (actor, oldX, oldY, false)) + if (!(flags & CHF_STOPIFBLOCKED) && P_TryMove(actor, oldX, oldY, false)) { if (nomonsterinterpolation) { actor->PrevX = oldX; actor->PrevY = oldY; } + P_NewChaseDir(actor); } - P_NewChaseDir (actor); } } else if (dontmove && actor->movecount > 0) actor->movecount--; diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index 143477bac..0b8833806 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -79,14 +79,20 @@ const int SXF_ISMASTER = 1 << 27; const int SXF_ISTRACER = 1 << 28; // Flags for A_Chase -const int CHF_FASTCHASE = 1; -const int CHF_NOPLAYACTIVE = 2; -const int CHF_NIGHTMAREFAST = 4; -const int CHF_RESURRECT = 8; -const int CHF_DONTMOVE = 16; -const int CHF_NORANDOMTURN = 32; -const int CHF_DONTANGLE = 64; -const int CHF_NOPOSTATTACKTURN = 128; +enum +{ + CHF_FASTCHASE = 1, + CHF_NOPLAYACTIVE = 2, + CHF_NIGHTMAREFAST = 4, + CHF_RESURRECT = 8, + CHF_DONTMOVE = 16, + CHF_NORANDOMTURN = 32, + CHF_DONTANGLE = 64, + CHF_NOPOSTATTACKTURN = 128, + CHF_STOPIFBLOCKED = 256, + + CHF_DONTTURN = CHF_NORANDOMTURN|CHF_NOPOSTATTACKTURN|CHF_STOPIFBLOCKED, +}; // Flags for A_LookEx const int LOF_NOSIGHTCHECK = 1; From 6dcbc930d6351e4603073cc3891c4fc2f02e3f76 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 27 Jan 2016 09:39:46 -0600 Subject: [PATCH 04/23] NoRandomTurn, not NoDirectionTurn, inside the macro. --- wadsrc/static/actors/constants.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/wadsrc/static/actors/constants.txt b/wadsrc/static/actors/constants.txt index fa50c55ec..420ce3ec9 100644 --- a/wadsrc/static/actors/constants.txt +++ b/wadsrc/static/actors/constants.txt @@ -91,7 +91,7 @@ enum CHF_NOPOSTATTACKTURN = 128, CHF_STOPIFBLOCKED = 256, - CHF_DONTTURN = CHF_NODIRECTIONTURN | CHF_NOPOSTATTACKTURN | CHF_STOPIFBLOCKED + CHF_DONTTURN = CHF_NORANDOMTURN | CHF_NOPOSTATTACKTURN | CHF_STOPIFBLOCKED }; // Flags for A_LookEx From 7798eadb8b52357cf8119015c91a5ac2b2fd1989 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 27 Jan 2016 10:47:36 -0600 Subject: [PATCH 05/23] Moved the P_Move back inside to where it was beforehand. --- src/p_enemy.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 37ff5cfaf..4c01796d5 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2498,8 +2498,6 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi if (actor->strafecount) actor->strafecount--; - - bool movecheck = P_Move(actor); // class bosses don't do this when strafing if ((!fastchase || !actor->FastChaseStrafeCount) && !dontmove) @@ -2509,6 +2507,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi fixed_t oldY = actor->Y(); FTextureID oldFloor = actor->floorpic; + bool movecheck = P_Move(actor); // chase towards player if (actor->movecount >= 0) actor->movecount--; From f6b3b269a75defae266e56d1ea3380449174b69b Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 27 Jan 2016 10:51:51 -0600 Subject: [PATCH 06/23] Fixed missing movecount decrement with blocked actors. --- src/p_enemy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 4c01796d5..98162beb8 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2509,7 +2509,7 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi bool movecheck = P_Move(actor); // chase towards player - if (actor->movecount >= 0) + if (actor->movecount >= 0 || !movecheck) actor->movecount--; if (!(flags & CHF_STOPIFBLOCKED)) { From 9a422245f3740c7ffe7876e4232eb101f23d6e47 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 27 Jan 2016 13:11:22 -0600 Subject: [PATCH 07/23] - Fixed a couple issues with calling P_NewChaseDir from wrongful P_Move priority. --- src/p_enemy.cpp | 9 ++------- 1 file changed, 2 insertions(+), 7 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 98162beb8..5e58d9510 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2507,16 +2507,11 @@ void A_DoChase (AActor *actor, bool fastchase, FState *meleestate, FState *missi fixed_t oldY = actor->Y(); FTextureID oldFloor = actor->floorpic; - bool movecheck = P_Move(actor); // chase towards player - if (actor->movecount >= 0 || !movecheck) - actor->movecount--; - if (!(flags & CHF_STOPIFBLOCKED)) + if ((--actor->movecount < 0 && !(flags & CHF_NORANDOMTURN)) || (!P_Move(actor) && !(flags & CHF_STOPIFBLOCKED))) { - if ((!(flags & CHF_NORANDOMTURN) && (actor->movecount < 0)) || !movecheck) - P_NewChaseDir(actor); + P_NewChaseDir(actor); } - // if the move was illegal, reset it // (copied from A_SerpentChase - it applies to everything with CANTLEAVEFLOORPIC!) if (actor->flags2&MF2_CANTLEAVEFLOORPIC && actor->floorpic != oldFloor ) From 4fcc9efea09604150eaaf84d0d841e37a6700aba Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Tue, 9 Feb 2016 22:45:59 -0600 Subject: [PATCH 08/23] - Fixed A_Wander calling --movecount too soon. - Also added NORANDOMTURN flag accountability for A_Wander. --- src/p_enemy.cpp | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index e71b701ea..b83972ec5 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2111,10 +2111,7 @@ void A_Wander(AActor *self, int flags) } } - if (self->movecount >= 0) - self->movecount--; - - if ((!(flags & CHF_NORANDOMTURN) && self->movecount < 0) || !P_Move(self)) + if ((--self->movecount < 0 && !(flags & CHF_NORANDOMTURN)) || (!P_Move(self) && !(flags & CHF_STOPIFBLOCKED))) { P_RandomChaseDir(self); self->movecount += 5; From ebe6cef7cce125381afacb5185fa39759537f1b5 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Tue, 9 Feb 2016 22:57:54 -0600 Subject: [PATCH 09/23] This was a little too far in. --- src/p_enemy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index b83972ec5..7b9dd2938 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2532,8 +2532,8 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele actor->PrevX = oldX; actor->PrevY = oldY; } - P_NewChaseDir(actor); } + P_NewChaseDir(actor); } } else if (dontmove && actor->movecount > 0) actor->movecount--; From e73a7373508f2f9a2e45fcbaf16344046f637dde Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Tue, 9 Feb 2016 23:16:15 -0600 Subject: [PATCH 10/23] When about to hit a new floor, don't change the direction of the actor if STOPIFBLOCKED is up. --- src/p_enemy.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 7b9dd2938..13f0a9e47 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2533,7 +2533,8 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele actor->PrevY = oldY; } } - P_NewChaseDir(actor); + if (!(flags & CHF_STOPIFBLOCKED)) + P_NewChaseDir(actor); } } else if (dontmove && actor->movecount > 0) actor->movecount--; From e043a89f15b311f144edace819a800ea9ab3ca39 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Tue, 9 Feb 2016 23:19:28 -0600 Subject: [PATCH 11/23] Forgot to save this with the last commit. --- src/p_enemy.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 13f0a9e47..24a3a1ced 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2525,7 +2525,7 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele // (copied from A_SerpentChase - it applies to everything with CANTLEAVEFLOORPIC!) if (actor->flags2&MF2_CANTLEAVEFLOORPIC && actor->floorpic != oldFloor ) { - if (!(flags & CHF_STOPIFBLOCKED) && P_TryMove(actor, oldX, oldY, false)) + if (P_TryMove(actor, oldX, oldY, false)) { if (nomonsterinterpolation) { From 7e45c49c2f9f32358cbd0ff6cdcb0ba2aa91589c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 10 Feb 2016 21:48:28 +0100 Subject: [PATCH 12/23] - fixed: The expression evaluator must ignore the action function symbol for ACS_NamedExecuteWithResult. This is necessary because otherwise the incompatible action function will take precedence over the special handling for this inside FxFunctionCall. --- src/thingdef/thingdef_exp.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/thingdef/thingdef_exp.cpp b/src/thingdef/thingdef_exp.cpp index e8a043d31..17d97e4fa 100644 --- a/src/thingdef/thingdef_exp.cpp +++ b/src/thingdef/thingdef_exp.cpp @@ -467,7 +467,8 @@ static FxExpression *ParseExpression0 (FScanner &sc, PClassActor *cls) PFunction *func = dyn_cast(cls->Symbols.FindSymbol(identifier, true)); try { - if (func != NULL) + // There is an action function ACS_NamedExecuteWithResult which must be ignored here for this to work. + if (func != NULL && identifier != NAME_ACS_NamedExecuteWithResult) { sc.UnGet(); ParseFunctionParameters(sc, cls, *args, func, "", NULL); From d7126861223f3415a81e11a8e7a98ef64e6256ed Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 10 Feb 2016 21:56:45 +0100 Subject: [PATCH 13/23] - fixed: A_CountdownArg could no longer access the first arg. The latest bit of refactoring turned a '<0' check into '>0', while it should have been '>=0'. --- src/thingdef/thingdef_codeptr.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index a3f7c0887..1e15a5c33 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3235,7 +3235,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CountdownArg) PARAM_INT(argnum); PARAM_STATE_OPT(state) { state = self->FindState(NAME_Death); } - if (argnum > 0 && argnum < (int)countof(self->args)) + if (argnum >= 0 && argnum < (int)countof(self->args)) { if (!self->args[argnum]--) { From e04fe0622613bca435ce922765429b729f6873bc Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 10 Feb 2016 17:13:50 -0600 Subject: [PATCH 14/23] GetDistance Non-Action (Double version) - Added GetDistance(bool checkz, ptr = aaptr_target). - Returns the distance of an actor. Must be target, master or tracer. --- src/thingdef/thingdef_codeptr.cpp | 35 +++++++++++++++++++++++++++++++ wadsrc/static/actors/actor.txt | 1 + 2 files changed, 36 insertions(+) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 1e15a5c33..9a8e02468 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -250,6 +250,41 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, CountInv) return 0; } +//========================================================================== +// +// GetDistance +// +// NON-ACTION function to get the distance in double. +// +//========================================================================== +DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetDistance) +{ + if (numret > 0) + { + assert(ret != NULL); + PARAM_PROLOGUE; + PARAM_OBJECT(self, AActor); + PARAM_BOOL(checkz); + PARAM_INT_OPT(ptr) { ptr = AAPTR_TARGET; } + + AActor *target = COPY_AAPTR(self, ptr); + + if (!target || target == self) + { + ret->SetFloat(false); + } + else + { + fixedvec3 diff = self->Vec3To(target); + diff.z += (target->height - self->height) / 2; + const double lengthsquared = TVector3(diff.x, diff.y, diff.z).LengthSquared(); + ret->SetFloat(lengthsquared); + } + return 1; + } + return 0; +} + //========================================================================== // // A_RearrangePointers diff --git a/wadsrc/static/actors/actor.txt b/wadsrc/static/actors/actor.txt index 8e30693cf..48ee9f68f 100644 --- a/wadsrc/static/actors/actor.txt +++ b/wadsrc/static/actors/actor.txt @@ -41,6 +41,7 @@ ACTOR Actor native //: Thinker native bool CheckClass(class checkclass, int ptr_select = AAPTR_DEFAULT, bool match_superclass = false); native bool IsPointerEqual(int ptr_select1, int ptr_select2); native int CountInv(class itemtype, int ptr_select = AAPTR_DEFAULT); + native float GetDistance(bool checkz, int ptr = AAPTR_DEFAULT); // Action functions // Meh, MBF redundant functions. Only for DeHackEd support. From fefdb266cd048b02b676943f575d9c712c9f1593 Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 10 Feb 2016 17:48:17 -0600 Subject: [PATCH 15/23] - Fixed: The coordinates need to be converted to doubles first. Also use length instead of length squared. --- src/thingdef/thingdef_codeptr.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 9a8e02468..0949dd6a6 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -277,8 +277,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetDistance) { fixedvec3 diff = self->Vec3To(target); diff.z += (target->height - self->height) / 2; - const double lengthsquared = TVector3(diff.x, diff.y, diff.z).LengthSquared(); - ret->SetFloat(lengthsquared); + const double length = TVector3(FIXED2DBL(diff.x), FIXED2DBL(diff.y), FIXED2DBL(diff.z)).Length(); + ret->SetFloat(length); } return 1; } From dcfdb503075bcddb92df97a91d32cf10147d98ad Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Wed, 10 Feb 2016 18:04:59 -0600 Subject: [PATCH 16/23] - Fixed: checkz wasn't used. - Use 0 instead of false. --- src/thingdef/thingdef_codeptr.cpp | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 0949dd6a6..2eb53c87d 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -271,13 +271,15 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, GetDistance) if (!target || target == self) { - ret->SetFloat(false); + ret->SetFloat(0); } else { fixedvec3 diff = self->Vec3To(target); - diff.z += (target->height - self->height) / 2; - const double length = TVector3(FIXED2DBL(diff.x), FIXED2DBL(diff.y), FIXED2DBL(diff.z)).Length(); + if (checkz) + diff.z += (target->height - self->height) / 2; + + const double length = TVector3(FIXED2DBL(diff.x), FIXED2DBL(diff.y), (checkz) ? FIXED2DBL(diff.z) : 0).Length(); ret->SetFloat(length); } return 1; From 33cdb4d8161edf0965958e8c0f89e6d4a82f4864 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 11 Feb 2016 19:13:29 +0100 Subject: [PATCH 17/23] - replaced all single precision floats in p_slopes.cpp with doubles. I don't think we want to have precision and reliability issues in such a vital part of the engine... --- src/p_slopes.cpp | 94 ++++++++++++++++++++++++------------------------ src/p_user.cpp | 8 ++--- 2 files changed, 51 insertions(+), 51 deletions(-) diff --git a/src/p_slopes.cpp b/src/p_slopes.cpp index a3db26526..3e402f73a 100644 --- a/src/p_slopes.cpp +++ b/src/p_slopes.cpp @@ -75,17 +75,17 @@ static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, boo plane = &sec->floorplane; } - FVector3 p, v1, v2, cross; + TVector3 p, v1, v2, cross; - p[0] = FIXED2FLOAT (line->v1->x); - p[1] = FIXED2FLOAT (line->v1->y); - p[2] = FIXED2FLOAT (plane->ZatPoint (line->v1->x, line->v1->y)); - v1[0] = FIXED2FLOAT (line->dx); - v1[1] = FIXED2FLOAT (line->dy); - v1[2] = FIXED2FLOAT (plane->ZatPoint (line->v2->x, line->v2->y)) - p[2]; - v2[0] = FIXED2FLOAT (x - line->v1->x); - v2[1] = FIXED2FLOAT (y - line->v1->y); - v2[2] = FIXED2FLOAT (z) - p[2]; + p[0] = FIXED2DBL (line->v1->x); + p[1] = FIXED2DBL (line->v1->y); + p[2] = FIXED2DBL (plane->ZatPoint (line->v1->x, line->v1->y)); + v1[0] = FIXED2DBL (line->dx); + v1[1] = FIXED2DBL (line->dy); + v1[2] = FIXED2DBL (plane->ZatPoint (line->v2->x, line->v2->y)) - p[2]; + v2[0] = FIXED2DBL (x - line->v1->x); + v2[1] = FIXED2DBL (y - line->v1->y); + v2[2] = FIXED2DBL (z) - p[2]; cross = v1 ^ v2; double len = cross.Length(); @@ -187,23 +187,23 @@ void P_SetSlope (secplane_t *plane, bool setCeil, int xyangi, int zangi, } xyang = (angle_t)Scale (xyangi, ANGLE_90, 90 << ANGLETOFINESHIFT); - FVector3 norm; + TVector3 norm; if (ib_compatflags & BCOMPATF_SETSLOPEOVERFLOW) { - norm[0] = float(finecosine[zang] * finecosine[xyang]); - norm[1] = float(finecosine[zang] * finesine[xyang]); + norm[0] = double(finecosine[zang] * finecosine[xyang]); + norm[1] = double(finecosine[zang] * finesine[xyang]); } else { - norm[0] = float(finecosine[zang]) * float(finecosine[xyang]); - norm[1] = float(finecosine[zang]) * float(finesine[xyang]); + norm[0] = double(finecosine[zang]) * double(finecosine[xyang]); + norm[1] = double(finecosine[zang]) * double(finesine[xyang]); } - norm[2] = float(finesine[zang]) * 65536.f; + norm[2] = double(finesine[zang]) * 65536.f; norm.MakeUnit(); - plane->a = (int)(norm[0] * 65536.f); - plane->b = (int)(norm[1] * 65536.f); - plane->c = (int)(norm[2] * 65536.f); + plane->a = FLOAT2FIXED(norm[0]); + plane->b = FLOAT2FIXED(norm[1]); + plane->c = FLOAT2FIXED(norm[2]); //plane->ic = (int)(65536.f / norm[2]); plane->ic = DivScale32 (1, plane->c); plane->d = -TMulScale16 (plane->a, x, @@ -226,17 +226,17 @@ void P_VavoomSlope(sector_t * sec, int id, fixed_t x, fixed_t y, fixed_t z, int if (l->args[0]==id) { - FVector3 v1, v2, cross; + TVector3 v1, v2, cross; secplane_t *srcplane = (which == 0) ? &sec->floorplane : &sec->ceilingplane; fixed_t srcheight = (which == 0) ? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling); - v1[0] = FIXED2FLOAT (x - l->v2->x); - v1[1] = FIXED2FLOAT (y - l->v2->y); - v1[2] = FIXED2FLOAT (z - srcheight); + v1[0] = FIXED2DBL (x - l->v2->x); + v1[1] = FIXED2DBL (y - l->v2->y); + v1[2] = FIXED2DBL (z - srcheight); - v2[0] = FIXED2FLOAT (x - l->v1->x); - v2[1] = FIXED2FLOAT (y - l->v1->y); - v2[2] = FIXED2FLOAT (z - srcheight); + v2[0] = FIXED2DBL (x - l->v1->x); + v2[1] = FIXED2DBL (y - l->v1->y); + v2[2] = FIXED2DBL (z - srcheight); cross = v1 ^ v2; double len = cross.Length(); @@ -334,8 +334,8 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, sector_t *sec = §ors[i]; if (sec->linecount != 3) continue; // only works with triangular sectors - FVector3 vt1, vt2, vt3, cross; - FVector3 vec1, vec2; + TVector3 vt1, vt2, vt3, cross; + TVector3 vec1, vec2; int vi1, vi2, vi3; vi1 = int(sec->lines[0]->v1 - vertexes); @@ -343,12 +343,12 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, vi3 = (sec->lines[1]->v1 == sec->lines[0]->v1 || sec->lines[1]->v1 == sec->lines[0]->v2)? int(sec->lines[1]->v2 - vertexes) : int(sec->lines[1]->v1 - vertexes); - vt1.X = FIXED2FLOAT(vertexes[vi1].x); - vt1.Y = FIXED2FLOAT(vertexes[vi1].y); - vt2.X = FIXED2FLOAT(vertexes[vi2].x); - vt2.Y = FIXED2FLOAT(vertexes[vi2].y); - vt3.X = FIXED2FLOAT(vertexes[vi3].x); - vt3.Y = FIXED2FLOAT(vertexes[vi3].y); + vt1.X = FIXED2DBL(vertexes[vi1].x); + vt1.Y = FIXED2DBL(vertexes[vi1].y); + vt2.X = FIXED2DBL(vertexes[vi2].x); + vt2.Y = FIXED2DBL(vertexes[vi2].y); + vt3.X = FIXED2DBL(vertexes[vi3].x); + vt3.Y = FIXED2DBL(vertexes[vi3].y); for(int j=0; j<2; j++) { @@ -358,10 +358,10 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, fixed_t z3; if (h1==NULL && h2==NULL && h3==NULL) continue; - vt1.Z = FIXED2FLOAT(h1? *h1 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling)); - vt2.Z = FIXED2FLOAT(h2? *h2 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling)); + vt1.Z = FIXED2DBL(h1? *h1 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling)); + vt2.Z = FIXED2DBL(h2? *h2 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling)); z3 = h3? *h3 : j==0? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling); - vt3.Z = FIXED2FLOAT(z3); + vt3.Z = FIXED2DBL(z3); if (P_PointOnLineSidePrecise(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0) { @@ -374,7 +374,7 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, vec2 = vt2 - vt3; } - FVector3 cross = vec1 ^ vec2; + TVector3 cross = vec1 ^ vec2; double len = cross.Length(); if (len == 0) @@ -519,7 +519,7 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which) refsec = line->frontsector == sec ? line->backsector : line->frontsector; - FVector3 p, v1, v2, cross; + TVector3 p, v1, v2, cross; secplane_t *srcplane; fixed_t srcheight, destheight; @@ -528,15 +528,15 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which) srcheight = (which == 0) ? sec->GetPlaneTexZ(sector_t::floor) : sec->GetPlaneTexZ(sector_t::ceiling); destheight = (which == 0) ? refsec->GetPlaneTexZ(sector_t::floor) : refsec->GetPlaneTexZ(sector_t::ceiling); - p[0] = FIXED2FLOAT (line->v1->x); - p[1] = FIXED2FLOAT (line->v1->y); - p[2] = FIXED2FLOAT (destheight); - v1[0] = FIXED2FLOAT (line->dx); - v1[1] = FIXED2FLOAT (line->dy); + p[0] = FIXED2DBL (line->v1->x); + p[1] = FIXED2DBL(line->v1->y); + p[2] = FIXED2DBL(destheight); + v1[0] = FIXED2DBL(line->dx); + v1[1] = FIXED2DBL(line->dy); v1[2] = 0; - v2[0] = FIXED2FLOAT (refvert->x - line->v1->x); - v2[1] = FIXED2FLOAT (refvert->y - line->v1->y); - v2[2] = FIXED2FLOAT (srcheight - destheight); + v2[0] = FIXED2DBL(refvert->x - line->v1->x); + v2[1] = FIXED2DBL(refvert->y - line->v1->y); + v2[2] = FIXED2DBL(srcheight - destheight); cross = (v1 ^ v2).Unit(); diff --git a/src/p_user.cpp b/src/p_user.cpp index 59098e83a..d5f89576b 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2749,13 +2749,13 @@ void P_PredictionLerpReset() bool P_LerpCalculate(PredictPos from, PredictPos to, PredictPos &result, float scale) { - FVector3 vecFrom(FIXED2DBL(from.x), FIXED2DBL(from.y), FIXED2DBL(from.z)); - FVector3 vecTo(FIXED2DBL(to.x), FIXED2DBL(to.y), FIXED2DBL(to.z)); - FVector3 vecResult; + TVector3 vecFrom(FIXED2DBL(from.x), FIXED2DBL(from.y), FIXED2DBL(from.z)); + TVector3 vecTo(FIXED2DBL(to.x), FIXED2DBL(to.y), FIXED2DBL(to.z)); + TVector3 vecResult; vecResult = vecTo - vecFrom; vecResult *= scale; vecResult = vecResult + vecFrom; - FVector3 delta = vecResult - vecTo; + TVector3 delta = vecResult - vecTo; result.x = FLOAT2FIXED(vecResult.X); result.y = FLOAT2FIXED(vecResult.Y); From 584147b8bb26dd2fa2cb84e330d4f77536f30f01 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 11 Feb 2016 20:01:12 +0100 Subject: [PATCH 18/23] - removed all occurences of FVector2 and FVector3 from the playsim code. --- src/actor.h | 4 ++-- src/p_buildmap.cpp | 14 +++++++------- src/p_mobj.cpp | 16 ++++++++-------- src/thingdef/thingdef_codeptr.cpp | 16 ++++++++-------- 4 files changed, 25 insertions(+), 25 deletions(-) diff --git a/src/actor.h b/src/actor.h index 7cfee5500..579656ae0 100644 --- a/src/actor.h +++ b/src/actor.h @@ -865,13 +865,13 @@ public: // 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(TVector2(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(X() - other->X(), Y() - other->Y(), Z() - other->Z()).Length()); + return xs_RoundToInt(TVector3(X() - other->X(), Y() - other->Y(), Z() - other->Z()).Length()); } angle_t AngleTo(AActor *other, bool absolute = false) const diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 295dff831..6705addd6 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -804,7 +804,7 @@ static void CreateStartSpot (fixed_t *pos, FMapThing *start) static void CalcPlane (SlopeWork &slope, secplane_t &plane) { - FVector3 pt[3]; + TVector3 pt[3]; long j; slope.x[0] = slope.wal->x; slope.y[0] = slope.wal->y; @@ -823,8 +823,8 @@ static void CalcPlane (SlopeWork &slope, secplane_t &plane) -slope.dy, slope.x[2]-slope.wal->x); slope.z[2] += Scale (slope.heinum, j, slope.i); - pt[0] = FVector3(slope.dx, -slope.dy, 0); - pt[1] = FVector3(slope.x[2] - slope.x[0], slope.y[0] - slope.y[2], (slope.z[2] - slope.z[0]) / 16); + pt[0] = TVector3(slope.dx, -slope.dy, 0); + pt[1] = TVector3(slope.x[2] - slope.x[0], slope.y[0] - slope.y[2], (slope.z[2] - slope.z[0]) / 16); pt[2] = (pt[0] ^ pt[1]).Unit(); if ((pt[2][2] < 0 && plane.c > 0) || (pt[2][2] > 0 && plane.c < 0)) @@ -832,10 +832,10 @@ static void CalcPlane (SlopeWork &slope, secplane_t &plane) pt[2] = -pt[2]; } - plane.a = fixed_t(pt[2][0]*65536.f); - plane.b = fixed_t(pt[2][1]*65536.f); - plane.c = fixed_t(pt[2][2]*65536.f); - plane.ic = fixed_t(65536.f/pt[2][2]); + plane.a = FLOAT2FIXED(pt[2][0]); + plane.b = FLOAT2FIXED(pt[2][1]); + plane.c = FLOAT2FIXED(pt[2][2]); + plane.ic = DivScale32(1, plane.c); plane.d = -TMulScale8 (plane.a, slope.x[0]<<4, plane.b, (-slope.y[0])<<4, plane.c, slope.z[0]); } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index dde1c80b8..cce1ac05b 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5875,7 +5875,7 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, // Answer: No, because this way, you can set up sets of parallel missiles. fixedvec3 fixvel = source->Vec3To(dest); - FVector3 velocity(fixvel.x, fixvel.y, fixvel.z); + TVector3 velocity(fixvel.x, fixvel.y, fixvel.z); // Floor and ceiling huggers should never have a vertical component to their velocity if (th->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)) { @@ -5887,9 +5887,9 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, velocity.Z += (dest->height - z + source->Z()); } velocity.Resize (speed); - th->velx = (fixed_t)(velocity.X); - th->vely = (fixed_t)(velocity.Y); - th->velz = (fixed_t)(velocity.Z); + th->velx = xs_CRoundToInt(velocity.X); + th->vely = xs_CRoundToInt(velocity.Y); + th->velz = xs_CRoundToInt(velocity.Z); // invisible target: rotate velocity vector in 2D // [RC] Now monsters can aim at invisible player as if they were fully visible. @@ -6163,16 +6163,16 @@ AActor *P_SpawnPlayerMissile (AActor *source, fixed_t x, fixed_t y, fixed_t z, vz = -finesine[pitch>>ANGLETOFINESHIFT]; speed = MissileActor->Speed; - FVector3 vec(vx, vy, vz); + TVector3 vec(vx, vy, vz); if (MissileActor->flags3 & (MF3_FLOORHUGGER|MF3_CEILINGHUGGER)) { vec.Z = 0; } vec.Resize(speed); - MissileActor->velx = (fixed_t)vec.X; - MissileActor->vely = (fixed_t)vec.Y; - MissileActor->velz = (fixed_t)vec.Z; + MissileActor->velx = xs_CRoundToInt(vec.X); + MissileActor->vely = xs_CRoundToInt(vec.Y); + MissileActor->velz = xs_CRoundToInt(vec.Z); if (MissileActor->flags4 & MF4_SPECTRAL) { diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 2eb53c87d..e4744c8b4 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1187,8 +1187,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) { if (CMF_OFFSETPITCH & flags) { - FVector2 velocity (missile->velx, missile->vely); - pitch += R_PointToAngle2(0,0, (fixed_t)velocity.Length(), missile->velz); + TVector2 velocity (missile->velx, missile->vely); + pitch += R_PointToAngle2(0,0, xs_CRoundToInt(velocity.Length()), missile->velz); } ang = pitch >> ANGLETOFINESHIFT; missilespeed = abs(FixedMul(finecosine[ang], missile->Speed)); @@ -1196,8 +1196,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CustomMissile) } else { - FVector2 velocity (missile->velx, missile->vely); - missilespeed = (fixed_t)velocity.Length(); + TVector2 velocity (missile->velx, missile->vely); + missilespeed = xs_CRoundToInt(velocity.Length()); } if (CMF_SAVEPITCH & flags) @@ -1603,8 +1603,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) { // This original implementation is to aim straight ahead and then offset // the angle from the resulting direction. - FVector3 velocity(misl->velx, misl->vely, 0); - fixed_t missilespeed = (fixed_t)velocity.Length(); + TVector3 velocity(misl->velx, misl->vely, 0); + fixed_t missilespeed = xs_CRoundToInt(velocity.Length()); misl->angle += angle; angle_t an = misl->angle >> ANGLETOFINESHIFT; misl->velx = FixedMul (missilespeed, finecosine[an]); @@ -6751,8 +6751,8 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection) if (!(flags & FMDF_NOPITCH)) { fixed_t current = mobj->pitch; - const FVector2 velocity(mobj->velx, mobj->vely); - const fixed_t pitch = R_PointToAngle2(0, 0, (fixed_t)velocity.Length(), -mobj->velz); + const TVector2 velocity(mobj->velx, mobj->vely); + const fixed_t pitch = R_PointToAngle2(0, 0, xs_CRoundToInt(velocity.Length()), -mobj->velz); if (pitchlimit > 0) { // [MC] angle_t for pitchlimit was required because otherwise From 34255908b0ecfb036f7149ba9184944e5517b5bf Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 11 Feb 2016 20:41:04 +0100 Subject: [PATCH 19/23] - fixed: Initialization of spawn IDs from MAPINFO and DECORATE was in the wrong order. (looks like a badly resolved merging conflict) --- src/d_main.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/d_main.cpp b/src/d_main.cpp index 23c837dfa..d2120f88e 100644 --- a/src/d_main.cpp +++ b/src/d_main.cpp @@ -2481,8 +2481,9 @@ void D_DoomMain (void) FinishDehPatch(); InitActorNumsFromMapinfo(); - PClassActor::StaticSetActorNums (); InitSpawnablesFromMapinfo(); + PClassActor::StaticSetActorNums(); + //Added by MC: bglobal.getspawned.Clear(); argcount = Args->CheckParmList("-bots", &args); From 158caf78a0e67943a0ae092a6769aecec8cf3835 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 11 Feb 2016 21:33:30 +0100 Subject: [PATCH 20/23] - more float to double conversion. In particular this removes all assignments of FIXED2FLOAT to double variables because they not only lose precision but also generate unnecessary code. --- src/am_map.cpp | 4 +-- src/c_cmds.cpp | 2 +- src/g_shared/a_movingcamera.cpp | 46 +++++++++++++++--------------- src/g_shared/sbarinfo_commands.cpp | 4 +-- src/p_map.cpp | 6 ++-- src/p_maputl.cpp | 2 +- src/p_mobj.cpp | 16 +++++------ src/r_main.cpp | 14 ++++----- src/r_plane.cpp | 10 +++---- src/r_things.cpp | 4 +-- src/s_sound.cpp | 4 --- src/v_draw.cpp | 12 ++++---- 12 files changed, 60 insertions(+), 64 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 3768af858..df464e59d 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -2512,8 +2512,8 @@ void AM_rotate(fixed_t *xp, fixed_t *yp, angle_t a) cosrot = cos(rot); } - double x = FIXED2FLOAT(*xp); - double y = FIXED2FLOAT(*yp); + double x = FIXED2DBL(*xp); + double y = FIXED2DBL(*yp); double tmpx = (x * cosrot) - (y * sinrot); y = (x * sinrot) + (y * cosrot); x = tmpx; diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index ed028ab93..1d16af31f 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -1084,7 +1084,7 @@ CCMD(currentpos) if(mo) { Printf("Current player position: (%1.3f,%1.3f,%1.3f), angle: %1.3f, floorheight: %1.3f, sector:%d, lightlevel: %d\n", - FIXED2FLOAT(mo->X()), FIXED2FLOAT(mo->Y()), FIXED2FLOAT(mo->Z()), mo->angle/float(ANGLE_1), FIXED2FLOAT(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel); + FIXED2DBL(mo->X()), FIXED2DBL(mo->Y()), FIXED2DBL(mo->Z()), ANGLE2DBL(mo->angle), FIXED2DBL(mo->floorz), mo->Sector->sectornum, mo->Sector->lightlevel); } else { diff --git a/src/g_shared/a_movingcamera.cpp b/src/g_shared/a_movingcamera.cpp index c01dea497..87a6e71ec 100644 --- a/src/g_shared/a_movingcamera.cpp +++ b/src/g_shared/a_movingcamera.cpp @@ -165,8 +165,8 @@ public: void Activate (AActor *activator); void Deactivate (AActor *activator); protected: - float Splerp (float p1, float p2, float p3, float p4); - float Lerp (float p1, float p2); + double Splerp (double p1, double p2, double p3, double p4); + double Lerp (double p1, double p2); virtual bool Interpolate (); virtual void NewNode (); @@ -191,10 +191,10 @@ void APathFollower::Serialize (FArchive &arc) // Interpolate between p2 and p3 along a Catmull-Rom spline // http://research.microsoft.com/~hollasch/cgindex/curves/catmull-rom.html -float APathFollower::Splerp (float p1, float p2, float p3, float p4) +double APathFollower::Splerp (double p1, double p2, double p3, double p4) { - float t = Time; - float res = 2*p2; + double t = Time; + double res = 2*p2; res += (p3 - p1) * Time; t *= Time; res += (2*p1 - 5*p2 + 4*p3 - p4) * t; @@ -204,7 +204,7 @@ float APathFollower::Splerp (float p1, float p2, float p3, float p4) } // Linearly interpolate between p1 and p2 -float APathFollower::Lerp (float p1, float p2) +double APathFollower::Lerp (double p1, double p2) { return p1 + Time * (p2 - p1); } @@ -325,7 +325,7 @@ void APathFollower::Tick () if (Interpolate ()) { - Time += 8.f / ((float)CurrNode->args[1] * (float)TICRATE); + Time += float(8.f / ((double)CurrNode->args[1] * (double)TICRATE)); if (Time > 1.f) { Time -= 1.f; @@ -371,20 +371,20 @@ bool APathFollower::Interpolate () 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 (FIXED2DBL(CurrNode->X()), FIXED2DBL(CurrNode->Next->X()))); + y = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->Y()), FIXED2DBL(CurrNode->Next->Y()))); + z = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->Z()), FIXED2DBL(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 (FIXED2DBL(PrevNode->X()), FIXED2DBL(CurrNode->X()), + FIXED2DBL(CurrNode->Next->X()), FIXED2DBL(CurrNode->Next->Next->X()))); + y = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->Y()), FIXED2DBL(CurrNode->Y()), + FIXED2DBL(CurrNode->Next->Y()), FIXED2DBL(CurrNode->Next->Next->Y()))); + z = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->Z()), FIXED2DBL(CurrNode->Z()), + FIXED2DBL(CurrNode->Next->Z()), FIXED2DBL(CurrNode->Next->Next->Z()))); } SetXYZ(x, y, z); LinkToWorld (); @@ -442,11 +442,11 @@ bool APathFollower::Interpolate () { if (args[2] & 2) { // interpolate angle - float angle1 = (float)CurrNode->angle; - float angle2 = (float)CurrNode->Next->angle; + double angle1 = (double)CurrNode->angle; + double angle2 = (double)CurrNode->Next->angle; if (angle2 - angle1 <= -2147483648.f) { - float lerped = Lerp (angle1, angle2 + 4294967296.f); + double lerped = Lerp (angle1, angle2 + 4294967296.f); if (lerped >= 4294967296.f) { angle = xs_CRoundToUInt(lerped - 4294967296.f); @@ -458,7 +458,7 @@ bool APathFollower::Interpolate () } else if (angle2 - angle1 >= 2147483648.f) { - float lerped = Lerp (angle1, angle2 - 4294967296.f); + double lerped = Lerp (angle1, angle2 - 4294967296.f); if (lerped < 0.f) { angle = xs_CRoundToUInt(lerped + 4294967296.f); @@ -477,15 +477,15 @@ bool APathFollower::Interpolate () { // linear if (args[2] & 4) { // interpolate pitch - pitch = FLOAT2FIXED(Lerp (FIXED2FLOAT(CurrNode->pitch), FIXED2FLOAT(CurrNode->Next->pitch))); + pitch = FLOAT2FIXED(Lerp (FIXED2DBL(CurrNode->pitch), FIXED2DBL(CurrNode->Next->pitch))); } } else { // spline if (args[2] & 4) { // interpolate pitch - pitch = FLOAT2FIXED(Splerp (FIXED2FLOAT(PrevNode->pitch), FIXED2FLOAT(CurrNode->pitch), - FIXED2FLOAT(CurrNode->Next->pitch), FIXED2FLOAT(CurrNode->Next->Next->pitch))); + pitch = FLOAT2FIXED(Splerp (FIXED2DBL(PrevNode->pitch), FIXED2DBL(CurrNode->pitch), + FIXED2DBL(CurrNode->Next->pitch), FIXED2DBL(CurrNode->Next->Next->pitch))); } } } diff --git a/src/g_shared/sbarinfo_commands.cpp b/src/g_shared/sbarinfo_commands.cpp index ed2a8c29c..5e2fa816f 100644 --- a/src/g_shared/sbarinfo_commands.cpp +++ b/src/g_shared/sbarinfo_commands.cpp @@ -310,8 +310,8 @@ class CommandDrawImage : public SBarInfoCommandFlowControl if (applyscale) { - spawnScaleX = FIXED2FLOAT(item->scaleX); - spawnScaleY = FIXED2FLOAT(item->scaleY); + spawnScaleX = FIXED2DBL(item->scaleX); + spawnScaleY = FIXED2DBL(item->scaleY); } texture = TexMan[icon]; diff --git a/src/p_map.cpp b/src/p_map.cpp index 6c95fd6f8..6416e0a6e 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -4222,9 +4222,9 @@ void P_RailAttack(AActor *source, int damage, int offset_xy, fixed_t offset_z, i rail_data.Caller = source; rail_data.StopAtOne = !!(railflags & RAF_NOPIERCE); - start.X = FIXED2FLOAT(xy.x); - start.Y = FIXED2FLOAT(xy.y); - start.Z = FIXED2FLOAT(shootz); + start.X = FIXED2DBL(xy.x); + start.Y = FIXED2DBL(xy.y); + start.Z = FIXED2DBL(shootz); int flags; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 07ce97cca..e5bb2bea2 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -560,7 +560,7 @@ sector_t *AActor::LinkToWorldForMapThing () DPrintf ("%s at (%d,%d) lies on %s line %td, distance = %f\n", this->GetClass()->TypeName.GetChars(), X()>>FRACBITS, Y()>>FRACBITS, ldef->dx == 0? "vertical" : ldef->dy == 0? "horizontal" : "diagonal", - ldef-lines, FIXED2FLOAT(distance)); + ldef-lines, FIXED2DBL(distance)); angle_t finean = R_PointToAngle2 (0, 0, ldef->dx, ldef->dy); if (ldef->backsector != NULL && ldef->backsector == ssec->sector) { diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index cce1ac05b..658fcbc69 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -6507,7 +6507,7 @@ DDropItem *AActor::GetDropItems() const fixed_t AActor::GetGravity() const { if (flags & MF_NOGRAVITY) return 0; - return fixed_t(level.gravity * Sector->gravity * FIXED2FLOAT(gravity) * 81.92); + return fixed_t(level.gravity * Sector->gravity * FIXED2DBL(gravity) * 81.92); } // killough 11/98: @@ -6631,13 +6631,13 @@ void PrintMiscActorInfo(AActor *query) for (flagi = 0; flagi <= 31; flagi++) if (query->flags7 & ActorFlags7::FromInt(1<BounceFlags.GetValue(), FIXED2FLOAT(query->bouncefactor), - FIXED2FLOAT(query->wallbouncefactor)); + query->BounceFlags.GetValue(), FIXED2DBL(query->bouncefactor), + FIXED2DBL(query->wallbouncefactor)); /*for (flagi = 0; flagi < 31; flagi++) if (query->BounceFlags & 1<alpha), query->renderflags.GetValue()); + FIXED2DBL(query->alpha), query->renderflags.GetValue()); /*for (flagi = 0; flagi < 31; flagi++) if (query->renderflags & 1<args[4], query->special1, query->special2); Printf("\nTID: %d", query->tid); Printf("\nCoord= x: %f, y: %f, z:%f, floor:%f, ceiling:%f.", - FIXED2FLOAT(query->X()), FIXED2FLOAT(query->Y()), FIXED2FLOAT(query->Z()), - FIXED2FLOAT(query->floorz), FIXED2FLOAT(query->ceilingz)); + FIXED2DBL(query->X()), FIXED2DBL(query->Y()), FIXED2DBL(query->Z()), + FIXED2DBL(query->floorz), FIXED2DBL(query->ceilingz)); Printf("\nSpeed= %f, velocity= x:%f, y:%f, z:%f, combined:%f.\n", - FIXED2FLOAT(query->Speed), FIXED2FLOAT(query->velx), FIXED2FLOAT(query->vely), FIXED2FLOAT(query->velz), - sqrt(pow(FIXED2FLOAT(query->velx), 2) + pow(FIXED2FLOAT(query->vely), 2) + pow(FIXED2FLOAT(query->velz), 2))); + FIXED2DBL(query->Speed), FIXED2DBL(query->velx), FIXED2DBL(query->vely), FIXED2DBL(query->velz), + sqrt(pow(FIXED2DBL(query->velx), 2) + pow(FIXED2DBL(query->vely), 2) + pow(FIXED2DBL(query->velz), 2))); } } diff --git a/src/r_main.cpp b/src/r_main.cpp index 883ab13dc..90b8d865b 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -714,15 +714,15 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) { // any mirror--use floats to avoid integer overflow vertex_t *v2 = pds->src->v2; - float dx = FIXED2FLOAT(v2->x - v1->x); - float dy = FIXED2FLOAT(v2->y - v1->y); - float x1 = FIXED2FLOAT(v1->x); - float y1 = FIXED2FLOAT(v1->y); - float x = FIXED2FLOAT(startx); - float y = FIXED2FLOAT(starty); + double dx = FIXED2DBL(v2->x - v1->x); + double dy = FIXED2DBL(v2->y - v1->y); + double x1 = FIXED2DBL(v1->x); + double y1 = FIXED2DBL(v1->y); + double x = FIXED2DBL(startx); + double y = FIXED2DBL(starty); // the above two cases catch len == 0 - float r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy); + double r = ((x - x1)*dx + (y - y1)*dy) / (dx*dx + dy*dy); viewx = FLOAT2FIXED((x1 + r * dx)*2 - x); viewy = FLOAT2FIXED((y1 + r * dy)*2 - y); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index e53523008..f1deceb9f 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1652,12 +1652,12 @@ void R_DrawTiltedPlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske return; } - double vx = FIXED2FLOAT(viewx); - double vy = FIXED2FLOAT(viewy); - double vz = FIXED2FLOAT(viewz); + double vx = FIXED2DBL(viewx); + double vy = FIXED2DBL(viewy); + double vz = FIXED2DBL(viewz); - lxscale = FIXED2FLOAT(pl->xscale) * ifloatpow2[ds_xbits]; - lyscale = FIXED2FLOAT(pl->yscale) * ifloatpow2[ds_ybits]; + lxscale = FIXED2DBL(pl->xscale) * ifloatpow2[ds_xbits]; + lyscale = FIXED2DBL(pl->yscale) * ifloatpow2[ds_ybits]; xscale = 64.f / lxscale; yscale = 64.f / lyscale; zeroheight = pl->height.ZatPoint(vx, vy); diff --git a/src/r_things.cpp b/src/r_things.cpp index 407bf54c7..1179c7291 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -1631,8 +1631,8 @@ void R_DrawRemainingPlayerSprites() screen->DrawTexture(vis->pic, viewwindowx + VisPSpritesX1[i], viewwindowy + viewheight/2 - (vis->texturemid / 65536.0) * (vis->yscale / 65536.0) - 0.5, - DTA_DestWidthF, FIXED2FLOAT(vis->pic->GetWidth() * vis->xscale), - DTA_DestHeightF, FIXED2FLOAT(vis->pic->GetHeight() * vis->yscale), + DTA_DestWidthF, FIXED2DBL(vis->pic->GetWidth() * vis->xscale), + DTA_DestHeightF, FIXED2DBL(vis->pic->GetHeight() * vis->yscale), DTA_Translation, TranslationToTable(vis->Translation), DTA_FlipX, flip, DTA_TopOffset, 0, diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 6baaa5c65..dabed23f6 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -63,10 +63,6 @@ #define O_BINARY 0 #endif -#ifndef FIXED2FLOAT -#define FIXED2FLOAT(f) (((float)(f))/(float)65536) -#endif - #define NORM_PITCH 128 #define NORM_PRIORITY 64 #define NORM_SEP 0 diff --git a/src/v_draw.cpp b/src/v_draw.cpp index ce502c772..12e42ec0b 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -781,10 +781,10 @@ void DCanvas::VirtualToRealCoordsFixed(fixed_t &x, fixed_t &y, fixed_t &w, fixed { double dx, dy, dw, dh; - dx = FIXED2FLOAT(x); - dy = FIXED2FLOAT(y); - dw = FIXED2FLOAT(w); - dh = FIXED2FLOAT(h); + dx = FIXED2DBL(x); + dy = FIXED2DBL(y); + dw = FIXED2DBL(w); + dh = FIXED2DBL(h); VirtualToRealCoords(dx, dy, dw, dh, vwidth, vheight, vbottom, handleaspect); x = FLOAT2FIXED(dx); y = FLOAT2FIXED(dy); @@ -1184,8 +1184,8 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, return; } - scalex /= FIXED2FLOAT(tex->xScale); - scaley /= FIXED2FLOAT(tex->yScale); + scalex /= FIXED2DBL(tex->xScale); + scaley /= FIXED2DBL(tex->yScale); cosrot = cos(rot); sinrot = sin(rot); From c5c4ec83c2ac7b67dd7759a13ddacb21a37b4db5 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 11 Feb 2016 21:45:34 +0100 Subject: [PATCH 21/23] - ensure thar PRINTNAME_LEVEL always uses uppercase. --- src/p_acs.cpp | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 0ddbdf0c2..070111d7b 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -7782,8 +7782,12 @@ scriptwait: break; case PRINTNAME_LEVEL: - work += level.MapName; - break; + { + FString uppername = level.MapName; + uppername.ToUpper(); + work += uppername; + break; + } case PRINTNAME_SKILL: work += G_SkillName(); From bf03ea496e343397f732f28f4946dc3d52ce4305 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 11 Feb 2016 22:03:09 +0100 Subject: [PATCH 22/23] - fixed: instant sector movement actions must actually delete the created interpolation right away and not wait until it deletes itself. --- src/dsectoreffect.cpp | 4 ++-- src/dsectoreffect.h | 2 +- src/fragglescript/t_func.cpp | 14 +++++++++++--- src/p_ceiling.cpp | 2 +- src/p_floor.cpp | 2 +- src/r_data/r_interpolate.cpp | 17 ++--------------- src/r_data/r_interpolate.h | 2 +- src/r_defs.h | 1 - 8 files changed, 19 insertions(+), 25 deletions(-) diff --git a/src/dsectoreffect.cpp b/src/dsectoreffect.cpp index 6732a19dc..7bc9fc400 100644 --- a/src/dsectoreffect.cpp +++ b/src/dsectoreffect.cpp @@ -95,11 +95,11 @@ void DMover::Serialize (FArchive &arc) arc << interpolation; } -void DMover::StopInterpolation() +void DMover::StopInterpolation(bool force) { if (interpolation != NULL) { - interpolation->DelRef(); + interpolation->DelRef(force); interpolation = NULL; } } diff --git a/src/dsectoreffect.h b/src/dsectoreffect.h index 95e1178aa..3788c6d88 100644 --- a/src/dsectoreffect.h +++ b/src/dsectoreffect.h @@ -36,7 +36,7 @@ protected: DMover (); void Serialize (FArchive &arc); void Destroy(); - void StopInterpolation(); + void StopInterpolation(bool force = false); inline EResult MoveFloor (fixed_t speed, fixed_t dest, int crush, int direction, bool hexencrush) { return MovePlane (speed, dest, crush, 0, direction, hexencrush); diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index e5803fb3e..444750e03 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -1571,7 +1571,7 @@ public: bool res = DMover::crushed != MoveFloor(speed, dest, crush, direction, false); Destroy(); m_Sector->floordata=NULL; - StopInterpolation(); + StopInterpolation(true); m_Sector=NULL; return res; } @@ -1656,6 +1656,14 @@ public: m_Speed=movespeed; m_Direction = _m_Direction; m_FloorDestDist = moveheight; + + // Do not interpolate instant movement floors. + fixed_t movedist = abs(-sec->floorplane.d - moveheight); + if (m_Speed >= movedist) + { + StopInterpolation(true); + } + StartFloorSound(); } }; @@ -1713,7 +1721,7 @@ public: bool res = DMover::crushed != MoveCeiling(speed, dest, crush, direction, false); Destroy(); m_Sector->ceilingdata=NULL; - StopInterpolation (); + StopInterpolation (true); m_Sector=NULL; return res; } @@ -1806,7 +1814,7 @@ public: fixed_t movedist = abs(sec->ceilingplane.d - m_BottomHeight); if (m_Speed >= movedist) { - StopInterpolation (); + StopInterpolation (true); m_Silent=2; } PlayCeilingSound(); diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index 3203cf777..24ab121c4 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -412,7 +412,7 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, } if (ceiling->m_Speed >= movedist) { - ceiling->StopInterpolation(); + ceiling->StopInterpolation(true); } // set texture/type change properties diff --git a/src/p_floor.cpp b/src/p_floor.cpp index 35e527383..c632e8ba2 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -478,7 +478,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, (floor->m_Direction<0 && floor->m_FloorDestDistfloorplane.d) || // moving down but going up (floor->m_Speed >= abs(sec->floorplane.d - floor->m_FloorDestDist))) // moving in one step { - floor->StopInterpolation(); + floor->StopInterpolation(true); // [Graf Zahl] // Don't make sounds for instant movement hacks but make an exception for diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index 4ce3a3c7b..ed12cbf4e 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -344,9 +344,10 @@ int DInterpolation::AddRef() // //========================================================================== -int DInterpolation::DelRef() +int DInterpolation::DelRef(bool force) { if (refcount > 0) --refcount; + if (force && refcount == 0) Destroy(); return refcount; } @@ -943,20 +944,6 @@ DInterpolation *sector_t::SetInterpolation(int position, bool attach) // //========================================================================== -void sector_t::StopInterpolation(int position) -{ - if (interpolations[position] != NULL) - { - interpolations[position]->DelRef(); - } -} - -//========================================================================== -// -// -// -//========================================================================== - DInterpolation *FPolyObj::SetInterpolation() { if (interpolation != NULL) diff --git a/src/r_data/r_interpolate.h b/src/r_data/r_interpolate.h index 29e8a6171..92e74c3f2 100644 --- a/src/r_data/r_interpolate.h +++ b/src/r_data/r_interpolate.h @@ -25,7 +25,7 @@ protected: public: int AddRef(); - int DelRef(); + int DelRef(bool force = false); virtual void Destroy(); virtual void UpdateInterpolation() = 0; diff --git a/src/r_defs.h b/src/r_defs.h index fc9d522de..a9b09c9e6 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -504,7 +504,6 @@ struct sector_t sector_t *GetHeightSec() const; DInterpolation *SetInterpolation(int position, bool attach); - void StopInterpolation(int position); ASkyViewpoint *GetSkyBox(int which); From 73cbc59dd9ae3ef6bb154ca72618a32d14240ac2 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 11 Feb 2016 22:57:26 +0100 Subject: [PATCH 23/23] - replaced double2fixed function with FLOAT2FIXED macro. --- src/fragglescript/t_func.cpp | 27 ++++++++++----------------- 1 file changed, 10 insertions(+), 17 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 444750e03..8be7f798d 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -3825,19 +3825,12 @@ void FParser::SF_ObjType() // //========================================================================== -inline fixed_t double2fixed(double t) -{ - return (fixed_t)(t*65536.0); -} - - - void FParser::SF_Sin() { if (CheckArgs(1)) { t_return.type = svt_fixed; - t_return.value.f = double2fixed(sin(floatvalue(t_argv[0]))); + t_return.value.f = FLOAT2FIXED(sin(floatvalue(t_argv[0]))); } } @@ -3847,7 +3840,7 @@ void FParser::SF_ASin() if (CheckArgs(1)) { t_return.type = svt_fixed; - t_return.value.f = double2fixed(asin(floatvalue(t_argv[0]))); + t_return.value.f = FLOAT2FIXED(asin(floatvalue(t_argv[0]))); } } @@ -3857,7 +3850,7 @@ void FParser::SF_Cos() if (CheckArgs(1)) { t_return.type = svt_fixed; - t_return.value.f = double2fixed(cos(floatvalue(t_argv[0]))); + t_return.value.f = FLOAT2FIXED(cos(floatvalue(t_argv[0]))); } } @@ -3867,7 +3860,7 @@ void FParser::SF_ACos() if (CheckArgs(1)) { t_return.type = svt_fixed; - t_return.value.f = double2fixed(acos(floatvalue(t_argv[0]))); + t_return.value.f = FLOAT2FIXED(acos(floatvalue(t_argv[0]))); } } @@ -3877,7 +3870,7 @@ void FParser::SF_Tan() if (CheckArgs(1)) { t_return.type = svt_fixed; - t_return.value.f = double2fixed(tan(floatvalue(t_argv[0]))); + t_return.value.f = FLOAT2FIXED(tan(floatvalue(t_argv[0]))); } } @@ -3887,7 +3880,7 @@ void FParser::SF_ATan() if (CheckArgs(1)) { t_return.type = svt_fixed; - t_return.value.f = double2fixed(atan(floatvalue(t_argv[0]))); + t_return.value.f = FLOAT2FIXED(atan(floatvalue(t_argv[0]))); } } @@ -3897,7 +3890,7 @@ void FParser::SF_Exp() if (CheckArgs(1)) { t_return.type = svt_fixed; - t_return.value.f = double2fixed(exp(floatvalue(t_argv[0]))); + t_return.value.f = FLOAT2FIXED(exp(floatvalue(t_argv[0]))); } } @@ -3906,7 +3899,7 @@ void FParser::SF_Log() if (CheckArgs(1)) { t_return.type = svt_fixed; - t_return.value.f = double2fixed(log(floatvalue(t_argv[0]))); + t_return.value.f = FLOAT2FIXED(log(floatvalue(t_argv[0]))); } } @@ -3916,7 +3909,7 @@ void FParser::SF_Sqrt() if (CheckArgs(1)) { t_return.type = svt_fixed; - t_return.value.f = double2fixed(sqrt(floatvalue(t_argv[0]))); + t_return.value.f = FLOAT2FIXED(sqrt(floatvalue(t_argv[0]))); } } @@ -3936,7 +3929,7 @@ void FParser::SF_Pow() if (CheckArgs(2)) { t_return.type = svt_fixed; - t_return.value.f = double2fixed(pow(floatvalue(t_argv[0]), floatvalue(t_argv[1]))); + t_return.value.f = FLOAT2FIXED(pow(floatvalue(t_argv[0]), floatvalue(t_argv[1]))); } }