From 8add60ed3855787ed29af07097d62e0ff019142a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 24 Mar 2016 19:24:33 +0100 Subject: [PATCH 01/44] - fixed: Getting the nearest ceiling height failed for height-less actors. --- src/p_sectors.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 27c8493ea..25cd0ead8 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -952,7 +952,7 @@ fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fi fixed_t delta1 = bottomz - (ff_bottom + ((ff_top - ff_bottom) / 2)); fixed_t delta2 = topz - (ff_bottom + ((ff_top - ff_bottom) / 2)); - if (ff_bottom < realceil && abs(delta1) >= abs(delta2)) + if (ff_bottom < realceil && abs(delta1) > abs(delta2)) { if (resultsec) *resultsec = sec; if (resultffloor) *resultffloor = rover; From b70fee8ed88351ef714e1c92fc9658e962d11f9e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Mar 2016 02:08:22 +0100 Subject: [PATCH 02/44] - changed the means how to control the slowdown of crushing ceilings encountering an obstacle and corrected a few mistakes in the implementation * there is a new crushing mode 3, which means that the crusher will always slow down if it hits an obstacle. * crushing mode 1 (Doom mode) will never slow down. * crushing mode 0 (compatibility) will only slow down for the specials that did so before, and only if both up and downspeed are 8 and the game is not Hexen. The following specials are affected: * Ceiling_LowerAndCrush * Ceiling_LowerAndCrushDist * Ceiling_CrushAndRaise * Ceiling_CrushAndRaiseA * Ceiling_CrushAndRaiseDist * Ceiling_CrushAndRaiseSilentA * Ceiling_CrushAndRaiseSilentDist * Generic_Crusher was fixed to act like in Boom: Not only a speed value of 8 will cause slowdown, but all speed values up to 24. * Hexen crushing mode will never cause slowdowns because Hexen never did this. (which also makes no real sense, considering that the crusher waits for the obstacle to die.) --- src/p_ceiling.cpp | 22 +++++++++---- src/p_lnspec.cpp | 82 +++++++++++++++++++++++++++-------------------- src/p_spec.h | 14 ++++++-- 3 files changed, 73 insertions(+), 45 deletions(-) diff --git a/src/p_ceiling.cpp b/src/p_ceiling.cpp index 7b4fb2118..95be8f7bc 100644 --- a/src/p_ceiling.cpp +++ b/src/p_ceiling.cpp @@ -46,6 +46,14 @@ inline FArchive &operator<< (FArchive &arc, DCeiling::ECeiling &type) return arc; } +inline FArchive &operator<< (FArchive &arc, DCeiling::ECrushMode &type) +{ + BYTE val = (BYTE)type; + arc << val; + type = (DCeiling::ECrushMode)val; + return arc; +} + //============================================================================ // // CEILINGS @@ -80,7 +88,7 @@ void DCeiling::Serialize (FArchive &arc) << m_NewSpecial << m_Tag << m_OldDirection - << m_Hexencrush; + << m_CrushMode; } //============================================================================ @@ -159,7 +167,7 @@ void DCeiling::Tick () case -1: // DOWN - res = MoveCeiling (m_Speed, m_BottomHeight, m_Crush, m_Direction, m_Hexencrush); + res = MoveCeiling (m_Speed, m_BottomHeight, m_Crush, m_Direction, m_CrushMode == ECrushMode::crushHexen); if (res == pastdest) { @@ -196,7 +204,7 @@ void DCeiling::Tick () { case ceilCrushAndRaise: case ceilLowerAndCrush: - if (m_Speed1 == FRACUNIT && m_Speed2 == FRACUNIT) + if (m_CrushMode == ECrushMode::crushSlowdown) m_Speed = FRACUNIT / 8; break; @@ -224,7 +232,7 @@ DCeiling::DCeiling (sector_t *sec, fixed_t speed1, fixed_t speed2, int silent) : DMovingCeiling (sec) { m_Crush = -1; - m_Hexencrush = false; + m_CrushMode = ECrushMode::crushDoom; m_Speed = m_Speed1 = speed1; m_Speed2 = speed2; m_Silent = silent; @@ -238,7 +246,7 @@ DCeiling::DCeiling (sector_t *sec, fixed_t speed1, fixed_t speed2, int silent) DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag, fixed_t speed, fixed_t speed2, fixed_t height, - int crush, int silent, int change, bool hexencrush) + int crush, int silent, int change, ECrushMode hexencrush) { fixed_t targheight = 0; // Silence, GCC @@ -387,7 +395,7 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, ceiling->m_Tag = tag; ceiling->m_Type = type; ceiling->m_Crush = crush; - ceiling->m_Hexencrush = hexencrush; + ceiling->m_CrushMode = hexencrush; // Do not interpolate instant movement ceilings. // Note for ZDoomGL: Check to make sure that you update the sector @@ -476,7 +484,7 @@ DCeiling *DCeiling::Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, int tag, fixed_t speed, fixed_t speed2, fixed_t height, - int crush, int silent, int change, bool hexencrush) + int crush, int silent, int change, DCeiling::ECrushMode hexencrush) { int secnum; bool rtn; diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 7c6f05b29..bc70388ae 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -84,9 +84,21 @@ static const BYTE ChangeMap[8] = { 0, 1, 5, 3, 7, 2, 6, 0 }; #define OCTICS(a) (((a)*TICRATE)/8) #define BYTEANGLE(a) ((angle_t)((a)<<24)) #define CRUSH(a) ((a) > 0? (a) : -1) -#define CRUSHTYPE(a) ((a)==1? false : (a)==2? true : gameinfo.gametype == GAME_Hexen) #define CHANGE(a) (((a) >= 0 && (a)<=7)? ChangeMap[a]:0) +static bool CRUSHTYPE(int a) +{ + return ((a) == 1 ? false : (a) == 2 ? true : gameinfo.gametype == GAME_Hexen); +} + +static DCeiling::ECrushMode CRUSHTYPE(int a, bool withslowdown) +{ + static DCeiling::ECrushMode map[] = { DCeiling::ECrushMode::crushDoom, DCeiling::ECrushMode::crushHexen, DCeiling::ECrushMode::crushSlowdown }; + if (a >= 1 && a <= 3) return map[a - 1]; + if (gameinfo.gametype == GAME_Hexen) return DCeiling::ECrushMode::crushHexen; + return withslowdown? DCeiling::ECrushMode::crushSlowdown : DCeiling::ECrushMode::crushDoom; +} + static FRandom pr_glass ("GlassBreak"); // There are aliases for the ACS specials that take names instead of numbers. @@ -628,43 +640,43 @@ FUNC(LS_Pillar_Open) FUNC(LS_Ceiling_LowerByValue) // Ceiling_LowerByValue (tag, speed, height, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3)); } FUNC(LS_Ceiling_RaiseByValue) // Ceiling_RaiseByValue (tag, speed, height, change) { - return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3)); } FUNC(LS_Ceiling_LowerByValueTimes8) // Ceiling_LowerByValueTimes8 (tag, speed, height, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3)); } FUNC(LS_Ceiling_RaiseByValueTimes8) // Ceiling_RaiseByValueTimes8 (tag, speed, height, change) { - return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3)); } FUNC(LS_Ceiling_CrushAndRaise) // Ceiling_CrushAndRaise (tag, speed, crush, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3, false)); } FUNC(LS_Ceiling_LowerAndCrush) // Ceiling_LowerAndCrush (tag, speed, crush, crushtype) { - return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); + return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3, arg1 == 8)); } FUNC(LS_Ceiling_LowerAndCrushDist) // Ceiling_LowerAndCrush (tag, speed, crush, dist, crushtype) { - return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), arg3*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), arg3*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg4, arg1 == 8)); } FUNC(LS_Ceiling_CrushStop) @@ -676,141 +688,141 @@ FUNC(LS_Ceiling_CrushStop) FUNC(LS_Ceiling_CrushRaiseAndStay) // Ceiling_CrushRaiseAndStay (tag, speed, crush, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); + return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3, false)); } FUNC(LS_Ceiling_MoveToValueTimes8) // Ceiling_MoveToValueTimes8 (tag, speed, height, negative, change) { return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, SPEED(arg1), 0, - arg2*FRACUNIT*8*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4), false); + arg2*FRACUNIT*8*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4)); } FUNC(LS_Ceiling_MoveToValue) // Ceiling_MoveToValue (tag, speed, height, negative, change) { return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, SPEED(arg1), 0, - arg2*FRACUNIT*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4), false); + arg2*FRACUNIT*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4)); } FUNC(LS_Ceiling_LowerToHighestFloor) // Ceiling_LowerToHighestFloor (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToHighestFloor, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); + return EV_DoCeiling (DCeiling::ceilLowerToHighestFloor, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2)); } FUNC(LS_Ceiling_LowerInstant) // Ceiling_LowerInstant (tag, unused, height, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerInstant, ln, arg0, 0, 0, arg2*FRACUNIT*8, CRUSH(arg4), 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilLowerInstant, ln, arg0, 0, 0, arg2*FRACUNIT*8, CRUSH(arg4), 0, CHANGE(arg3)); } FUNC(LS_Ceiling_RaiseInstant) // Ceiling_RaiseInstant (tag, unused, height, change) { - return EV_DoCeiling (DCeiling::ceilRaiseInstant, ln, arg0, 0, 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilRaiseInstant, ln, arg0, 0, 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3)); } FUNC(LS_Ceiling_CrushRaiseAndStayA) // Ceiling_CrushRaiseAndStayA (tag, dnspeed, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4, false)); } FUNC(LS_Ceiling_CrushRaiseAndStaySilA) // Ceiling_CrushRaiseAndStaySilA (tag, dnspeed, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4, false)); } FUNC(LS_Ceiling_CrushAndRaiseA) // Ceiling_CrushAndRaiseA (tag, dnspeed, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4, arg1 == 8 && arg2 == 8)); } FUNC(LS_Ceiling_CrushAndRaiseDist) // Ceiling_CrushAndRaiseDist (tag, dist, speed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 0, 0, CRUSHTYPE(arg4, arg2 == 8)); } FUNC(LS_Ceiling_CrushAndRaiseSilentA) // Ceiling_CrushAndRaiseSilentA (tag, dnspeed, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4, arg1 == 8 && arg2 == 8)); } FUNC(LS_Ceiling_CrushAndRaiseSilentDist) // Ceiling_CrushAndRaiseSilentDist (tag, dist, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 1, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 1, 0, CRUSHTYPE(arg4, arg2 == 8)); } FUNC(LS_Ceiling_RaiseToNearest) // Ceiling_RaiseToNearest (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseToNearest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseToNearest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0); } FUNC(LS_Ceiling_RaiseToHighest) // Ceiling_RaiseToHighest (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0); } FUNC(LS_Ceiling_RaiseToLowest) // Ceiling_RaiseToLowest (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseToLowest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseToLowest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0); } FUNC(LS_Ceiling_RaiseToHighestFloor) // Ceiling_RaiseToHighestFloor (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseToHighestFloor, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseToHighestFloor, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0); } FUNC(LS_Ceiling_RaiseByTexture) // Ceiling_RaiseByTexture (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseByTexture, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseByTexture, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0); } FUNC(LS_Ceiling_LowerToLowest) // Ceiling_LowerToLowest (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToLowest, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); + return EV_DoCeiling (DCeiling::ceilLowerToLowest, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2)); } FUNC(LS_Ceiling_LowerToNearest) // Ceiling_LowerToNearest (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToNearest, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); + return EV_DoCeiling (DCeiling::ceilLowerToNearest, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2)); } FUNC(LS_Ceiling_ToHighestInstant) // Ceiling_ToHighestInstant (tag, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToHighest, ln, arg0, FRACUNIT*2, 0, 0, CRUSH(arg2), 0, CHANGE(arg1), false); + return EV_DoCeiling (DCeiling::ceilLowerToHighest, ln, arg0, FRACUNIT*2, 0, 0, CRUSH(arg2), 0, CHANGE(arg1)); } FUNC(LS_Ceiling_ToFloorInstant) // Ceiling_ToFloorInstant (tag, change, crush) { - return EV_DoCeiling (DCeiling::ceilRaiseToFloor, ln, arg0, FRACUNIT*2, 0, 0, CRUSH(arg2), 0, CHANGE(arg1), false); + return EV_DoCeiling (DCeiling::ceilRaiseToFloor, ln, arg0, FRACUNIT*2, 0, 0, CRUSH(arg2), 0, CHANGE(arg1)); } FUNC(LS_Ceiling_LowerToFloor) // Ceiling_LowerToFloor (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToFloor, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false); + return EV_DoCeiling (DCeiling::ceilLowerToFloor, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4)); } FUNC(LS_Ceiling_LowerByTexture) // Ceiling_LowerByTexture (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerByTexture, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false); + return EV_DoCeiling (DCeiling::ceilLowerByTexture, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4)); } FUNC(LS_Generic_Ceiling) @@ -841,14 +853,14 @@ FUNC(LS_Generic_Ceiling) } return EV_DoCeiling (type, ln, arg0, SPEED(arg1), SPEED(arg1), arg2*FRACUNIT, - (arg4 & 16) ? 20 : -1, 0, arg4 & 7, false); + (arg4 & 16) ? 20 : -1, 0, arg4 & 7); } FUNC(LS_Generic_Crusher) // Generic_Crusher (tag, dnspeed, upspeed, silent, damage) { return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), - SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, false); + SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, (arg1 <= 24 && arg2 <= 24)? DCeiling::ECrushMode::crushSlowdown : DCeiling::ECrushMode::crushDoom); } FUNC(LS_Generic_Crusher2) @@ -856,7 +868,7 @@ FUNC(LS_Generic_Crusher2) { // same as above but uses Hexen's crushing method. return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), - SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, true); + SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, DCeiling::ECrushMode::crushHexen); } FUNC(LS_Plat_PerpetualRaise) @@ -1944,7 +1956,7 @@ FUNC(LS_FloorAndCeiling_RaiseByValue) FUNC(LS_FloorAndCeiling_LowerRaise) // FloorAndCeiling_LowerRaise (tag, fspeed, cspeed, boomemu) { - bool res = EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, SPEED(arg2), 0, 0, 0, 0, 0, false); + bool res = EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, SPEED(arg2), 0, 0, 0, 0, 0); // The switch based Boom equivalents of FloorandCeiling_LowerRaise do incorrect checks // which cause the floor only to move when the ceiling fails to do so. // To avoid problems with maps that have incorrect args this only uses a diff --git a/src/p_spec.h b/src/p_spec.h index d40fb3da7..b0baaa1ea 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -647,6 +647,14 @@ public: genCeilingChg }; + enum class ECrushMode + { + crushDoom = 0, + crushHexen = 1, + crushSlowdown = 2 + }; + + DCeiling (sector_t *sec); DCeiling (sector_t *sec, fixed_t speed1, fixed_t speed2, int silent); @@ -655,7 +663,7 @@ public: static DCeiling *Create(sector_t *sec, DCeiling::ECeiling type, line_t *line, int tag, fixed_t speed, fixed_t speed2, fixed_t height, - int crush, int silent, int change, bool hexencrush); + int crush, int silent, int change, ECrushMode hexencrush); protected: ECeiling m_Type; @@ -665,7 +673,7 @@ protected: fixed_t m_Speed1; // [RH] dnspeed of crushers fixed_t m_Speed2; // [RH] upspeed of crushers int m_Crush; - bool m_Hexencrush; + ECrushMode m_CrushMode; int m_Silent; int m_Direction; // 1 = up, 0 = waiting, -1 = down @@ -688,7 +696,7 @@ private: bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, int tag, fixed_t speed, fixed_t speed2, fixed_t height, - int crush, int silent, int change, bool hexencrush); + int crush, int silent, int change, DCeiling::ECrushMode hexencrush = DCeiling::ECrushMode::crushDoom); bool EV_CeilingCrushStop (int tag); void P_ActivateInStasisCeiling (int tag); From 8cdfbeea01c91416ae9436213dc5a2663bd90502 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Mar 2016 15:43:20 +0100 Subject: [PATCH 03/44] - made AActor::__pos a genuine float vatiable. --- src/actor.h | 60 ++++++++++++++++------------------ src/p_mobj.cpp | 4 +-- src/r_defs.h | 8 ++--- src/thingdef/thingdef_data.cpp | 6 ++-- 4 files changed, 36 insertions(+), 42 deletions(-) diff --git a/src/actor.h b/src/actor.h index 843e928dc..943f137ef 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1089,7 +1089,7 @@ public: // info for drawing // NOTE: The first member variable *must* be snext. AActor *snext, **sprev; // links in sector (if needed) - fixedvec3 __pos; // double underscores so that it won't get used by accident. Access to this should be exclusively through the designated access functions. + DVector3 __Pos; // double underscores so that it won't get used by accident. Access to this should be exclusively through the designated access functions. /* angle_t angle; @@ -1382,36 +1382,36 @@ public: fixed_t _f_X() const { - return __pos.x; + return FLOAT2FIXED(__Pos.X); } fixed_t _f_Y() const { - return __pos.y; + return FLOAT2FIXED(__Pos.Y); } fixed_t _f_Z() const { - return __pos.z; + return FLOAT2FIXED(__Pos.Z); } fixedvec3 _f_Pos() const { - return __pos; + return{ _f_X(), _f_Y(), _f_Z() }; } double X() const { - return FIXED2DBL(__pos.x); + return __Pos.X; } double Y() const { - return FIXED2DBL(__pos.y); + return __Pos.Y; } double Z() const { - return FIXED2DBL(__pos.z); + return __Pos.Z; } DVector3 Pos() const { - return DVector3(X(), Y(), Z()); + return __Pos; } fixedvec3 _f_PosRelative(int grp) const; @@ -1459,11 +1459,11 @@ public: } void _f_SetZ(fixed_t newz, bool moving = true) { - __pos.z = newz; + __Pos.Z = FIXED2DBL(newz); } void _f_AddZ(fixed_t newz, bool moving = true) { - __pos.z += newz; + __Pos.Z += FIXED2DBL(newz); } double Top() const { @@ -1475,53 +1475,49 @@ public: } void SetZ(double newz, bool moving = true) { - __pos.z = FLOAT2FIXED(newz); + __Pos.Z = newz; } void AddZ(double newz, bool moving = true) { - __pos.z += FLOAT2FIXED(newz); - if (!moving) PrevZ = __pos.z; + __Pos.Z += newz; + if (!moving) PrevZ = _f_Z(); } // These are not for general use as they do not link the actor into the world! void SetXY(fixed_t xx, fixed_t yy) { - __pos.x = xx; - __pos.y = yy; + __Pos.X = FIXED2DBL(xx); + __Pos.Y = FIXED2DBL(yy); } void SetXY(const fixedvec2 &npos) { - __pos.x = npos.x; - __pos.y = npos.y; + __Pos.X = FIXED2DBL(npos.x); + __Pos.Y = FIXED2DBL(npos.y); } void SetXY(const DVector2 &npos) { - __pos.x = FLOAT2FIXED(npos.X); - __pos.y = FLOAT2FIXED(npos.Y); + __Pos.X = npos.X; + __Pos.Y = npos.Y; } void SetXYZ(fixed_t xx, fixed_t yy, fixed_t zz) { - __pos.x = xx; - __pos.y = yy; - __pos.z = zz; + __Pos.X = FIXED2DBL(xx); + __Pos.Y = FIXED2DBL(yy); + __Pos.Z = FIXED2DBL(zz); } void SetXYZ(double xx, double yy, double zz) { - __pos.x = FLOAT2FIXED(xx); - __pos.y = FLOAT2FIXED(yy); - __pos.z = FLOAT2FIXED(zz); + __Pos = { xx,yy,zz }; } void SetXYZ(const fixedvec3 &npos) { - __pos.x = npos.x; - __pos.y = npos.y; - __pos.z = npos.z; + __Pos.X = FIXED2DBL(npos.x); + __Pos.Y = FIXED2DBL(npos.y); + __Pos.Z = FIXED2DBL(npos.z); } void SetXYZ(const DVector3 &npos) { - __pos.x = FLOAT2FIXED(npos.X); - __pos.y = FLOAT2FIXED(npos.Y); - __pos.z = FLOAT2FIXED(npos.Z); + __Pos = npos; } double VelXYToSpeed() const diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 17b529ca9..f13d6f395 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -235,9 +235,7 @@ void AActor::Serialize(FArchive &arc) sprite = arc.ReadSprite(); } - arc << __pos.x - << __pos.y - << __pos.z + arc << __Pos << Angles.Yaw << Angles.Pitch << Angles.Roll diff --git a/src/r_defs.h b/src/r_defs.h index f8260996b..db4a3161f 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -1336,22 +1336,22 @@ inline sector_t *P_PointInSector(const DVector2 &pos) inline fixedvec3 AActor::_f_PosRelative(int portalgroup) const { - return __pos + Displacements.getOffset(Sector->PortalGroup, portalgroup); + return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, portalgroup); } inline fixedvec3 AActor::_f_PosRelative(const AActor *other) const { - return __pos + Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup); + return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup); } inline fixedvec3 AActor::_f_PosRelative(sector_t *sec) const { - return __pos + Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup); + return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup); } inline fixedvec3 AActor::_f_PosRelative(line_t *line) const { - return __pos + Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup); + return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup); } inline fixedvec3 _f_PosRelative(const fixedvec3 &pos, line_t *line, sector_t *refsec = NULL) diff --git a/src/thingdef/thingdef_data.cpp b/src/thingdef/thingdef_data.cpp index 1531b46f7..16fcc9a55 100644 --- a/src/thingdef/thingdef_data.cpp +++ b/src/thingdef/thingdef_data.cpp @@ -632,9 +632,9 @@ void InitThingdef() symt.AddSymbol(new PField(NAME_TID, TypeSInt32, VARF_Native, myoffsetof(AActor,tid))); symt.AddSymbol(new PField(NAME_TIDtoHate, TypeSInt32, VARF_Native, myoffsetof(AActor,TIDtoHate))); symt.AddSymbol(new PField(NAME_WaterLevel, TypeSInt32, VARF_Native, myoffsetof(AActor,waterlevel))); - symt.AddSymbol(new PField(NAME_X, TypeFixed, VARF_Native, myoffsetof(AActor,__pos.x))); // must remain read-only! - symt.AddSymbol(new PField(NAME_Y, TypeFixed, VARF_Native, myoffsetof(AActor,__pos.y))); // must remain read-only! - symt.AddSymbol(new PField(NAME_Z, TypeFixed, VARF_Native, myoffsetof(AActor,__pos.z))); // must remain read-only! + symt.AddSymbol(new PField(NAME_X, TypeFloat64, VARF_Native, myoffsetof(AActor,__Pos.X))); // must remain read-only! + symt.AddSymbol(new PField(NAME_Y, TypeFloat64, VARF_Native, myoffsetof(AActor,__Pos.Y))); // must remain read-only! + symt.AddSymbol(new PField(NAME_Z, TypeFloat64, VARF_Native, myoffsetof(AActor,__Pos.Z))); // must remain read-only! symt.AddSymbol(new PField(NAME_VelX, TypeFloat64, VARF_Native, myoffsetof(AActor,Vel.X))); symt.AddSymbol(new PField(NAME_VelY, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.Y))); symt.AddSymbol(new PField(NAME_VelZ, TypeFloat64, VARF_Native, myoffsetof(AActor, Vel.Z))); From 2b33601d00cde63b6353525a9c73d9de77df4f1a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Mar 2016 15:50:39 +0100 Subject: [PATCH 04/44] - The fixed_t type for the VM also is not needed any longer and was removed. --- src/dobjtype.cpp | 67 +-------------------------------- src/dobjtype.h | 16 -------- src/sc_man_scanner.re | 1 - src/sc_man_tokens.h | 1 - src/thingdef/thingdef_parse.cpp | 4 -- src/zscript/vmexec.h | 20 ---------- src/zscript/vmops.h | 4 -- 7 files changed, 1 insertion(+), 112 deletions(-) diff --git a/src/dobjtype.cpp b/src/dobjtype.cpp index 1e9a1c655..d65473b36 100644 --- a/src/dobjtype.cpp +++ b/src/dobjtype.cpp @@ -79,7 +79,6 @@ PName *TypeName; PSound *TypeSound; PColor *TypeColor; PStatePointer *TypeState; -PFixed *TypeFixed; // PRIVATE DATA DEFINITIONS ------------------------------------------------ @@ -505,8 +504,7 @@ void PType::StaticInit() RUNTIME_CLASS(PPrototype)->TypeTableType = RUNTIME_CLASS(PPrototype); RUNTIME_CLASS(PClass)->TypeTableType = RUNTIME_CLASS(PClass); RUNTIME_CLASS(PStatePointer)->TypeTableType = RUNTIME_CLASS(PStatePointer); - RUNTIME_CLASS(PFixed)->TypeTableType = RUNTIME_CLASS(PFixed); - + // Create types and add them type the type table. TypeTable.AddType(TypeError = new PErrorType); TypeTable.AddType(TypeVoid = new PVoidType); @@ -524,7 +522,6 @@ void PType::StaticInit() TypeTable.AddType(TypeSound = new PSound); TypeTable.AddType(TypeColor = new PColor); TypeTable.AddType(TypeState = new PStatePointer); - TypeTable.AddType(TypeFixed = new PFixed); GlobalSymbols.AddSymbol(new PSymbolType(NAME_sByte, TypeSInt8)); GlobalSymbols.AddSymbol(new PSymbolType(NAME_Byte, TypeUInt8)); @@ -542,7 +539,6 @@ void PType::StaticInit() GlobalSymbols.AddSymbol(new PSymbolType(NAME_Sound, TypeSound)); GlobalSymbols.AddSymbol(new PSymbolType(NAME_Color, TypeColor)); GlobalSymbols.AddSymbol(new PSymbolType(NAME_State, TypeState)); - GlobalSymbols.AddSymbol(new PSymbolType(NAME_Fixed, TypeFixed)); } @@ -1081,67 +1077,6 @@ PColor::PColor() assert(sizeof(PalEntry) == __alignof(PalEntry)); } -/* PFixed *****************************************************************/ - -IMPLEMENT_CLASS(PFixed) - -//========================================================================== -// -// PFixed Default Constructor -// -//========================================================================== - -PFixed::PFixed() -: PFloat(sizeof(fixed_t)) -{ -} - -//========================================================================== -// -// PFixed :: SetValue -// -//========================================================================== - -void PFixed::SetValue(void *addr, int val) -{ - assert(((intptr_t)addr & (Align - 1)) == 0 && "unaligned address"); - *(fixed_t *)addr = val << FRACBITS; -} - -//========================================================================== -// -// PFixed :: GetValueInt -// -//========================================================================== - -int PFixed::GetValueInt(void *addr) const -{ - assert(((intptr_t)addr & (Align - 1)) == 0 && "unaligned address"); - return *(fixed_t *)addr >> FRACBITS; -} - -//========================================================================== -// -// PFixed :: GetStoreOp -// -//========================================================================== - -int PFixed::GetStoreOp() const -{ - return OP_SX; -} - -//========================================================================== -// -// PFixed :: GetLoadOp -// -//========================================================================== - -int PFixed::GetLoadOp() const -{ - return OP_LX; -} - /* PStatePointer **********************************************************/ IMPLEMENT_CLASS(PStatePointer) diff --git a/src/dobjtype.h b/src/dobjtype.h index 6c25d4a2c..50998509b 100644 --- a/src/dobjtype.h +++ b/src/dobjtype.h @@ -400,21 +400,6 @@ public: PColor(); }; -// Variations of floating point types --------------------------------------- -// These get converted to floats when they're loaded from memory. - -class PFixed : public PFloat -{ - DECLARE_CLASS(PFixed, PFloat); -public: - PFixed(); - - virtual void SetValue(void *addr, int val); - virtual int GetValueInt(void *addr) const; - virtual int GetStoreOp() const; - virtual int GetLoadOp() const; -}; - // Pointers ----------------------------------------------------------------- class PStatePointer : public PBasicType @@ -771,7 +756,6 @@ extern PName *TypeName; extern PSound *TypeSound; extern PColor *TypeColor; extern PStatePointer *TypeState; -extern PFixed *TypeFixed; // A constant value --------------------------------------------------------- diff --git a/src/sc_man_scanner.re b/src/sc_man_scanner.re index 3b05c5b72..92702f918 100644 --- a/src/sc_man_scanner.re +++ b/src/sc_man_scanner.re @@ -192,7 +192,6 @@ std2: /* other DECORATE top level keywords */ '#include' { RET(TK_Include); } - 'fixed_t' { RET(TK_Fixed_t); } L (L|D)* { RET(TK_Identifier); } diff --git a/src/sc_man_tokens.h b/src/sc_man_tokens.h index ac69c153e..246462940 100644 --- a/src/sc_man_tokens.h +++ b/src/sc_man_tokens.h @@ -111,7 +111,6 @@ xx(TK_Global, "'global'") xx(TK_Self, "'self'") xx(TK_Stop, "'stop'") xx(TK_Include, "'include'") -xx(TK_Fixed_t, "'fixed_t'") xx(TK_Is, "'is'") xx(TK_Replaces, "'replaces'") diff --git a/src/thingdef/thingdef_parse.cpp b/src/thingdef/thingdef_parse.cpp index d68ab6fdb..9673fba87 100644 --- a/src/thingdef/thingdef_parse.cpp +++ b/src/thingdef/thingdef_parse.cpp @@ -486,10 +486,6 @@ static void ParseNativeFunction(FScanner &sc, PClassActor *cls) rets.Push(TypeFloat64); break; - case TK_Fixed_t: - rets.Push(TypeFixed); - break; - case TK_State: rets.Push(TypeState); break; diff --git a/src/zscript/vmexec.h b/src/zscript/vmexec.h index e75e7a9eb..1804d4c36 100644 --- a/src/zscript/vmexec.h +++ b/src/zscript/vmexec.h @@ -210,16 +210,6 @@ begin: reg.f[a+2] = v[2]; } NEXTOP; - OP(LX): - ASSERTF(a); ASSERTA(B); ASSERTKD(C); - GETADDR(PB,KC,X_READ_NIL); - reg.f[a] = *(VM_SWORD *)ptr / 65536.0; - NEXTOP; - OP(LX_R): - ASSERTF(a); ASSERTA(B); ASSERTD(C); - GETADDR(PB,RC,X_READ_NIL); - reg.f[a] = *(VM_SWORD *)ptr / 65536.0; - NEXTOP; OP(LBIT): ASSERTD(a); ASSERTA(B); GETADDR(PB,0,X_READ_NIL); @@ -316,16 +306,6 @@ begin: v[2] = (float)reg.f[B+2]; } NEXTOP; - OP(SX): - ASSERTA(a); ASSERTF(B); ASSERTKD(C); - GETADDR(PA,KC,X_WRITE_NIL); - *(VM_SWORD *)ptr = (VM_SWORD)(reg.f[B] * 65536.0); - NEXTOP; - OP(SX_R): - ASSERTA(a); ASSERTF(B); ASSERTD(C); - GETADDR(PA,RC,X_WRITE_NIL); - *(VM_SWORD *)ptr = (VM_SWORD)(reg.f[B] * 65536.0); - NEXTOP; OP(SBIT): ASSERTA(a); ASSERTD(B); GETADDR(PA,0,X_WRITE_NIL); diff --git a/src/zscript/vmops.h b/src/zscript/vmops.h index e1b230984..bb4c034c7 100644 --- a/src/zscript/vmops.h +++ b/src/zscript/vmops.h @@ -35,8 +35,6 @@ xx(LP, lp, RPRPKI), // load pointer xx(LP_R, lp, RPRPRI), xx(LV, lv, RVRPKI), // load vector xx(LV_R, lv, RVRPRI), -xx(LX, lx, RFRPKI), // load fixed point -xx(LX_R, lx, RFRPRI), xx(LBIT, lbit, RIRPI8), // rA = !!(*rB & C) -- *rB is a byte @@ -57,8 +55,6 @@ xx(SP, sp, RPRPKI), // store pointer xx(SP_R, sp, RPRPRI), xx(SV, sv, RPRVKI), // store vector xx(SV_R, sv, RPRVRI), -xx(SX, sx, RPRFKI), // store fixed point -xx(SX_R, sx, RPRFRI), xx(SBIT, sbit, RPRII8), // *rA |= C if rB is true, *rA &= ~C otherwise From 1125101b37ced04c2d5236631bc30f36bbb684e9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Mar 2016 16:25:25 +0100 Subject: [PATCH 05/44] - floatified AActor::Prev plus the stuff using it. - rewrote some coordinate functions in AActor to use real float math instead of converting back and forth between float and fixed. --- src/actor.h | 57 ++++++++++++++++++++--------------------------- src/am_map.cpp | 2 +- src/p_enemy.cpp | 9 ++++---- src/p_map.cpp | 4 ++-- src/p_maputl.cpp | 6 ++--- src/p_mobj.cpp | 22 ++++++++---------- src/p_things.cpp | 16 +++++-------- src/portal.cpp | 6 ++--- src/portal.h | 14 +++++++++++- src/r_defs.h | 42 ++++++++++++++++++++++++++-------- src/r_plane.cpp | 12 +++++----- src/r_things.cpp | 8 +++---- src/r_utility.cpp | 2 +- 13 files changed, 108 insertions(+), 92 deletions(-) diff --git a/src/actor.h b/src/actor.h index 943f137ef..5d3e85bc8 100644 --- a/src/actor.h +++ b/src/actor.h @@ -742,13 +742,13 @@ public: // What species am I? virtual FName GetSpecies(); - double GetBobOffset(fixed_t ticfrac = 0) const + double GetBobOffset(double ticfrac = 0) const { if (!(flags2 & MF2_FLOATBOB)) { return 0; } - return BobSin(FloatBobPhase + level.maptime + FIXED2FLOAT(ticfrac)); + return BobSin(FloatBobPhase + level.maptime + ticfrac); } @@ -850,8 +850,8 @@ public: // more precise, but slower version, being used in a few places double Distance2D(AActor *other, bool absolute = false) { - fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this); - return (DVector2(_f_X() - otherpos.x, _f_Y() - otherpos.y).Length())/FRACUNIT; + DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this); + return (Pos().XY() - otherpos).Length(); } double Distance2D(double x, double y) const @@ -860,10 +860,10 @@ public: } // a full 3D version of the above - fixed_t Distance3D(AActor *other, bool absolute = false) + double Distance3D(AActor *other, bool absolute = false) { - fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this); - return xs_RoundToInt(DVector3(_f_X() - otherpos.x, _f_Y() - otherpos.y, _f_Z() - otherpos.z).Length()); + DVector3 otherpos = absolute ? other->Pos() : other->PosRelative(this); + return (Pos() - otherpos).Length(); } angle_t __f_AngleTo(AActor *other, bool absolute = false) @@ -879,19 +879,20 @@ public: DAngle AngleTo(AActor *other, bool absolute = false) { - fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this); - return VecToAngle(otherpos.x - _f_X(), otherpos.y - _f_Y()); + DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this); + return VecToAngle(otherpos - Pos().XY()); } DAngle AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const { fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this); - return VecToAngle(otherpos.y + oxofs - _f_Y(), otherpos.x + oyofs - _f_X()); + return VecToAngle(otherpos.x + oxofs - _f_X(), otherpos.y + oyofs - _f_Y()); } DAngle AngleTo(AActor *other, double oxofs, double oyofs, bool absolute = false) const { - return FIXED2DBL(AngleTo(other, FLOAT2FIXED(oxofs), FLOAT2FIXED(oyofs), absolute)); + DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this); + return VecToAngle(otherpos - Pos() + DVector2(oxofs, oyofs)); } fixedvec2 _f_Vec2To(AActor *other) const @@ -910,14 +911,12 @@ public: DVector2 Vec2To(AActor *other) const { - fixedvec3 otherpos = other->_f_PosRelative(this); - return{ FIXED2DBL(otherpos.x - _f_X()), FIXED2DBL(otherpos.y - _f_Y()) }; + return other->PosRelative(this) - Pos(); } DVector3 Vec3To(AActor *other) const { - fixedvec3 otherpos = other->_f_PosRelative(this); - return { FIXED2DBL(otherpos.x - _f_X()), FIXED2DBL(otherpos.y - _f_Y()), FIXED2DBL(otherpos.z - _f_Z()) }; + return other->PosRelative(this) - Pos(); } fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false) @@ -1089,14 +1088,7 @@ public: // info for drawing // NOTE: The first member variable *must* be snext. AActor *snext, **sprev; // links in sector (if needed) - DVector3 __Pos; // double underscores so that it won't get used by accident. Access to this should be exclusively through the designated access functions. - - /* - angle_t angle; - fixed_t pitch; - angle_t roll; // This was fixed_t before, which is probably wrong - fixedvec3 vel; - */ + DVector3 __Pos; // double underscores so that it won't get used by accident. Access to this should be exclusively through the designated access functions. DRotator Angles; DVector3 Vel; @@ -1321,8 +1313,7 @@ public: FDecalBase *DecalGenerator; // [RH] Used to interpolate the view to get >35 FPS - fixed_t PrevX, PrevY, PrevZ; - //angle_t PrevAngle; + DVector3 Prev; DRotator PrevAngles; int PrevPortalGroup; @@ -1419,6 +1410,11 @@ public: fixedvec3 _f_PosRelative(sector_t *sec) const; fixedvec3 _f_PosRelative(line_t *line) const; + DVector3 PosRelative(int grp) const; + DVector3 PosRelative(const AActor *other) const; + DVector3 PosRelative(sector_t *sec) const; + DVector3 PosRelative(line_t *line) const; + fixed_t SoundX() const { return _f_X(); @@ -1431,14 +1427,9 @@ public: { return _f_Z(); } - fixedvec3 InterpolatedPosition(fixed_t ticFrac) const + DVector3 InterpolatedPosition(double ticFrac) const { - fixedvec3 ret; - - ret.x = PrevX + FixedMul (ticFrac, _f_X() - PrevX); - ret.y = PrevY + FixedMul (ticFrac, _f_Y() - PrevY); - ret.z = PrevZ + FixedMul (ticFrac, _f_Z() - PrevZ); - return ret; + return Prev + (ticFrac * (Pos() - Prev)); } fixedvec3 PosPlusZ(fixed_t zadd) const { @@ -1480,7 +1471,7 @@ public: void AddZ(double newz, bool moving = true) { __Pos.Z += newz; - if (!moving) PrevZ = _f_Z(); + if (!moving) Prev.Z = Z(); } // These are not for general use as they do not link the actor into the world! diff --git a/src/am_map.cpp b/src/am_map.cpp index 65cc1c583..48fbe1817 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -2429,7 +2429,7 @@ void AM_drawWalls (bool allmap) bool portalmode = numportalgroups > 0 && pg != MapPortalGroup; if (pg == p) { - offset = Displacements.getOffset(pg, MapPortalGroup); + offset = Displacements._f_getOffset(pg, MapPortalGroup); } else if (p == -1 && (pg == MapPortalGroup || !am_portaloverlay)) { diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 904b41bf9..811d8748a 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2545,8 +2545,7 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele if ((!fastchase || !actor->FastChaseStrafeCount) && !dontmove) { // CANTLEAVEFLOORPIC handling was completely missing in the non-serpent functions. - fixed_t oldX = actor->_f_X(); - fixed_t oldY = actor->_f_Y(); + DVector2 old = actor->Pos(); int oldgroup = actor->PrevPortalGroup; FTextureID oldFloor = actor->floorpic; @@ -2559,12 +2558,12 @@ 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 (P_TryMove(actor, oldX, oldY, false)) + if (P_TryMove(actor, old, false)) { if (nomonsterinterpolation) { - actor->PrevX = oldX; - actor->PrevY = oldY; + actor->Prev.X = old.X; + actor->Prev.Y = old.Y; actor->PrevPortalGroup = oldgroup; } } diff --git a/src/p_map.cpp b/src/p_map.cpp index 77fceae4e..c261d1e4c 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2299,8 +2299,8 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, { thing->UnlinkFromWorld(); thing->SetXY(tm.x + port->mXDisplacement, tm.y + port->mYDisplacement); - thing->PrevX += port->mXDisplacement; - thing->PrevY += port->mYDisplacement; + thing->Prev.X += FIXED2DBL(port->mXDisplacement); + thing->Prev.Y += FIXED2DBL(port->mYDisplacement); thing->LinkToWorld(); P_FindFloorCeiling(thing); portalcrossed = true; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 488260a7f..4a3687083 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -870,7 +870,7 @@ bool FMultiBlockLinesIterator::Next(FMultiBlockLinesIterator::CheckResult *item) void FMultiBlockLinesIterator::startIteratorForGroup(int group) { - offset = Displacements.getOffset(basegroup, group); + offset = Displacements._f_getOffset(basegroup, group); offset.x += checkpoint.x; offset.y += checkpoint.y; cursector = group == startsector->PortalGroup ? startsector : P_PointInSector(offset.x, offset.y); @@ -1104,7 +1104,7 @@ bool FMultiBlockThingsIterator::Next(FMultiBlockThingsIterator::CheckResult *ite if (thing != NULL) { item->thing = thing; - item->position = checkpoint + Displacements.getOffset(basegroup, thing->Sector->PortalGroup); + item->position = checkpoint + Displacements._f_getOffset(basegroup, thing->Sector->PortalGroup); item->portalflags = portalflags; // same as above in floating point. This is here so that this stuff can be converted piece by piece. @@ -1146,7 +1146,7 @@ bool FMultiBlockThingsIterator::Next(FMultiBlockThingsIterator::CheckResult *ite void FMultiBlockThingsIterator::startIteratorForGroup(int group) { - fixedvec2 offset = Displacements.getOffset(basegroup, group); + fixedvec2 offset = Displacements._f_getOffset(basegroup, group); offset.x += checkpoint.x; offset.y += checkpoint.y; bbox.setBox(offset.x, offset.y, checkpoint.z); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index f13d6f395..8b6c3f4ad 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -2816,7 +2816,7 @@ void P_NightmareRespawn (AActor *mobj) mo->skillrespawncount = mobj->skillrespawncount; - mo->PrevZ = FLOAT2FIXED(z); // Do not interpolate Z position if we changed it since spawning. + mo->Prev.Z = z; // Do not interpolate Z position if we changed it since spawning. // spawn a teleport fog at old spot because of removal of the body? P_SpawnTeleportFog(mobj, mobj->PosPlusZ(TELEFOGHEIGHT), true, true); @@ -3294,13 +3294,11 @@ void AActor::CheckPortalTransition(bool islinked) AActor *port = Sector->SkyBoxes[sector_t::ceiling]; if (Z() > port->specialf1) { - fixedvec3 oldpos = _f_Pos(); + DVector3 oldpos = Pos(); if (islinked && !moved) UnlinkFromWorld(); - SetXYZ(_f_PosRelative(port->Sector)); - PrevX += _f_X() - oldpos.x; - PrevY += _f_Y() - oldpos.y; - PrevZ += _f_Z() - oldpos.z; - Sector = P_PointInSector(_f_X(), _f_Y()); + SetXYZ(PosRelative(port->Sector)); + Prev = Pos() - oldpos; + Sector = P_PointInSector(Pos()); PrevPortalGroup = Sector->PortalGroup; moved = true; } @@ -3313,13 +3311,11 @@ void AActor::CheckPortalTransition(bool islinked) AActor *port = Sector->SkyBoxes[sector_t::floor]; if (Z() < port->specialf1 && floorz < port->specialf1) { - fixedvec3 oldpos = _f_Pos(); + DVector3 oldpos = Pos(); if (islinked && !moved) UnlinkFromWorld(); - SetXYZ(_f_PosRelative(port->Sector)); - PrevX += _f_X() - oldpos.x; - PrevY += _f_Y() - oldpos.y; - PrevZ += _f_Z() - oldpos.z; - Sector = P_PointInSector(_f_X(), _f_Y()); + SetXYZ(PosRelative(port->Sector)); + Prev = Pos() - oldpos; + Sector = P_PointInSector(Pos()); PrevPortalGroup = Sector->PortalGroup; moved = true; } diff --git a/src/p_things.cpp b/src/p_things.cpp index 1fa0905b1..3e37135f3 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -757,32 +757,26 @@ int P_Thing_Warp(AActor *caller, AActor *reference, double xofs, double yofs, do caller->Vel.Zero(); } -#if 0 // needs fixing // this is no fun with line portals if (flags & WARPF_WARPINTERPOLATION) { // This just translates the movement but doesn't change the vector - fixedvec3 displacedold = old + Displacements.getOffset(oldpgroup, caller->Sector->PortalGroup); - caller->PrevX += caller->_f_X() - displacedold.x; - caller->PrevY += caller->_f_Y() - displacedold.y; - caller->PrevZ += caller->_f_Z() - displacedold.z; + DVector3 displacedold = old + Displacements.getOffset(oldpgroup, caller->Sector->PortalGroup); + caller->Prev += caller->Pos() - displacedold; caller->PrevPortalGroup = caller->Sector->PortalGroup; } else if (flags & WARPF_COPYINTERPOLATION) { // Map both positions of the reference actor to the current portal group - fixedvec3 displacedold = old + Displacements.getOffset(reference->PrevPortalGroup, caller->Sector->PortalGroup); - fixedvec3 displacedref = old + Displacements.getOffset(reference->Sector->PortalGroup, caller->Sector->PortalGroup); - caller->PrevX = caller->_f_X() + displacedold.x - displacedref.x; - caller->PrevY = caller->_f_Y() + displacedold.y - displacedref.y; - caller->PrevZ = caller->_f_Z() + displacedold.z - displacedref.z; + DVector3 displacedold = old + Displacements.getOffset(reference->PrevPortalGroup, caller->Sector->PortalGroup); + DVector3 displacedref = old + Displacements.getOffset(reference->Sector->PortalGroup, caller->Sector->PortalGroup); + caller->Prev = caller->Pos() + displacedold - displacedref; caller->PrevPortalGroup = caller->Sector->PortalGroup; } else if (!(flags & WARPF_INTERPOLATE)) { caller->ClearInterpolation(); } -#endif if ((flags & WARPF_BOB) && (reference->flags2 & MF2_FLOATBOB)) { diff --git a/src/portal.cpp b/src/portal.cpp index 91a24e2e3..1d7419b66 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -1209,7 +1209,7 @@ bool P_CollectConnectedGroups(int startgroup, const fixedvec3 &position, fixed_t while (!wsec->PortalBlocksMovement(sector_t::ceiling) && upperz > FLOAT2FIXED(wsec->SkyBoxes[sector_t::ceiling]->specialf1)) { sector_t *othersec = wsec->SkyBoxes[sector_t::ceiling]->Sector; - fixedvec2 pos = Displacements.getOffset(startgroup, othersec->PortalGroup); + fixedvec2 pos = Displacements._f_getOffset(startgroup, othersec->PortalGroup); fixed_t dx = position.x + pos.x; fixed_t dy = position.y + pos.y; processMask.setBit(othersec->PortalGroup); @@ -1221,7 +1221,7 @@ bool P_CollectConnectedGroups(int startgroup, const fixedvec3 &position, fixed_t while (!wsec->PortalBlocksMovement(sector_t::floor) && position.z < FLOAT2FIXED(wsec->SkyBoxes[sector_t::floor]->specialf1)) { sector_t *othersec = wsec->SkyBoxes[sector_t::floor]->Sector; - fixedvec2 pos = Displacements.getOffset(startgroup, othersec->PortalGroup); + fixedvec2 pos = Displacements._f_getOffset(startgroup, othersec->PortalGroup); fixed_t dx = position.x + pos.x; fixed_t dy = position.y + pos.y; processMask.setBit(othersec->PortalGroup | FPortalGroupArray::LOWER); @@ -1236,7 +1236,7 @@ bool P_CollectConnectedGroups(int startgroup, const fixedvec3 &position, fixed_t int thisgroup = startgroup; for (unsigned i = 0; i < groupsToCheck.Size();i++) { - fixedvec2 disp = Displacements.getOffset(startgroup, thisgroup & ~FPortalGroupArray::FLAT); + fixedvec2 disp = Displacements._f_getOffset(startgroup, thisgroup & ~FPortalGroupArray::FLAT); FBoundingBox box(position.x + disp.x, position.y + disp.y, checkradius); FBlockLinesIterator it(box); line_t *ld; diff --git a/src/portal.h b/src/portal.h index 582695f06..95fc57a93 100644 --- a/src/portal.h +++ b/src/portal.h @@ -54,7 +54,7 @@ struct FDisplacementTable return data[x + size*y]; } - fixedvec2 getOffset(int x, int y) const + fixedvec2 _f_getOffset(int x, int y) const { if (x == y) { @@ -63,6 +63,18 @@ struct FDisplacementTable } return data[x + size*y].pos; } + + DVector2 getOffset(int x, int y) const + { + if (x == y) + { + DVector2 nulvec = { 0,0 }; + return nulvec; // shortcut for the most common case + } + fixedvec2 &p = data[x + size*y].pos; + return{ FIXED2DBL(p.x), FIXED2DBL(p.y) }; + } + }; extern FDisplacementTable Displacements; diff --git a/src/r_defs.h b/src/r_defs.h index db4a3161f..a467ba6ee 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -838,12 +838,12 @@ struct sector_t // These may only be called if the portal has been validated fixedvec2 FloorDisplacement() { - return Displacements.getOffset(PortalGroup, SkyBoxes[sector_t::floor]->Sector->PortalGroup); + return Displacements._f_getOffset(PortalGroup, SkyBoxes[sector_t::floor]->Sector->PortalGroup); } fixedvec2 CeilingDisplacement() { - return Displacements.getOffset(PortalGroup, SkyBoxes[sector_t::ceiling]->Sector->PortalGroup); + return Displacements._f_getOffset(PortalGroup, SkyBoxes[sector_t::ceiling]->Sector->PortalGroup); } int GetTerrain(int pos) const; @@ -1336,34 +1336,58 @@ inline sector_t *P_PointInSector(const DVector2 &pos) inline fixedvec3 AActor::_f_PosRelative(int portalgroup) const { - return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, portalgroup); + return _f_Pos() + Displacements._f_getOffset(Sector->PortalGroup, portalgroup); } inline fixedvec3 AActor::_f_PosRelative(const AActor *other) const { - return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup); + return _f_Pos() + Displacements._f_getOffset(Sector->PortalGroup, other->Sector->PortalGroup); } inline fixedvec3 AActor::_f_PosRelative(sector_t *sec) const { - return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup); + return _f_Pos() + Displacements._f_getOffset(Sector->PortalGroup, sec->PortalGroup); } inline fixedvec3 AActor::_f_PosRelative(line_t *line) const { - return _f_Pos() + Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup); + return _f_Pos() + Displacements._f_getOffset(Sector->PortalGroup, line->frontsector->PortalGroup); } inline fixedvec3 _f_PosRelative(const fixedvec3 &pos, line_t *line, sector_t *refsec = NULL) +{ + return pos + Displacements._f_getOffset(refsec->PortalGroup, line->frontsector->PortalGroup); +} + +inline DVector3 AActor::PosRelative(int portalgroup) const +{ + return Pos() + Displacements.getOffset(Sector->PortalGroup, portalgroup); +} + +inline DVector3 AActor::PosRelative(const AActor *other) const +{ + return Pos() + Displacements.getOffset(Sector->PortalGroup, other->Sector->PortalGroup); +} + +inline DVector3 AActor::PosRelative(sector_t *sec) const +{ + return Pos() + Displacements.getOffset(Sector->PortalGroup, sec->PortalGroup); +} + +inline DVector3 AActor::PosRelative(line_t *line) const +{ + return Pos() + Displacements.getOffset(Sector->PortalGroup, line->frontsector->PortalGroup); +} + +inline DVector3 PosRelative(const DVector3 &pos, line_t *line, sector_t *refsec = NULL) { return pos + Displacements.getOffset(refsec->PortalGroup, line->frontsector->PortalGroup); } + inline void AActor::ClearInterpolation() { - PrevX = _f_X(); - PrevY = _f_Y(); - PrevZ = _f_Z(); + Prev = Pos(); PrevAngles = Angles; if (Sector) PrevPortalGroup = Sector->PortalGroup; else PrevPortalGroup = 0; diff --git a/src/r_plane.cpp b/src/r_plane.cpp index c62647355..e46dfa5fe 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1239,10 +1239,10 @@ void R_DrawSkyBoxes () extralight = 0; R_SetVisibility (sky->args[0] * 0.25f); - fixedvec3 viewpos = sky->InterpolatedPosition(r_TicFrac); - viewx = viewpos.x; - viewy = viewpos.y; - viewz = viewpos.z; + DVector3 viewpos = sky->InterpolatedPosition(r_TicFracF); + viewx = FLOAT2FIXED(viewpos.X); + viewy = FLOAT2FIXED(viewpos.Y); + viewz = FLOAT2FIXED(viewpos.Z); viewangle = savedangle + (sky->PrevAngles.Yaw + (sky->Angles.Yaw * r_TicFracF) - sky->PrevAngles.Yaw).BAMs(); R_CopyStackedViewParameters(); @@ -1251,8 +1251,8 @@ void R_DrawSkyBoxes () { extralight = pl->extralight; R_SetVisibility (pl->visibility); - viewx = pl->viewx - sky->Mate->_f_X() + sky->_f_X(); - viewy = pl->viewy - sky->Mate->_f_Y() + sky->_f_Y(); + viewx = pl->viewx - FLOAT2FIXED(sky->Mate->X() + sky->X()); + viewy = pl->viewy - FLOAT2FIXED(sky->Mate->Y() + sky->Y()); viewz = pl->viewz; viewangle = pl->viewangle; } diff --git a/src/r_things.cpp b/src/r_things.cpp index 6313e0cab..6f99a3790 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -767,10 +767,10 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor return; // [RH] Interpolate the sprite's position to make it look smooth - fixedvec3 pos = thing->InterpolatedPosition(r_TicFrac); - fx = pos.x; - fy = pos.y; - fz = pos.z + thing->_f_GetBobOffset(r_TicFrac); + DVector3 pos = thing->InterpolatedPosition(r_TicFracF); + fx = FLOAT2FIXED(pos.X); + fy = FLOAT2FIXED(pos.Y); + fz = FLOAT2FIXED(pos.Z + thing->GetBobOffset(r_TicFracF)); tex = NULL; voxel = NULL; diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 224648770..810410e08 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -652,7 +652,7 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi } else { - fixedvec2 disp = Displacements.getOffset(oldgroup, newgroup); + fixedvec2 disp = Displacements._f_getOffset(oldgroup, newgroup); viewx = iview->oviewx + FixedMul(frac, iview->nviewx - iview->oviewx - disp.x); viewy = iview->oviewy + FixedMul(frac, iview->nviewy - iview->oviewy - disp.y); viewz = iview->oviewz + FixedMul(frac, iview->nviewz - iview->oviewz); From 2cf3b20ea8c4850621d81bdf9e0e0d88c3fd3a1d Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Mar 2016 16:30:31 +0100 Subject: [PATCH 06/44] - floatified the last remaining AActor member variable 'damagemultiply'. --- src/actor.h | 2 +- src/p_acs.cpp | 4 ++-- src/p_interaction.cpp | 2 +- src/p_mobj.cpp | 4 ++-- 4 files changed, 6 insertions(+), 6 deletions(-) diff --git a/src/actor.h b/src/actor.h index 5d3e85bc8..aa5e48429 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1290,7 +1290,7 @@ public: FNameNoInit DamageType; FNameNoInit DamageTypeReceived; double DamageFactor; - fixed_t DamageMultiply; + double DamageMultiply; FNameNoInit PainType; FNameNoInit DeathType; diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 1f28ed636..3ea923542 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -3964,7 +3964,7 @@ void DLevelScript::DoSetActorProperty (AActor *actor, int property, int value) break; case APROP_DamageMultiplier: - actor->DamageMultiply = value; + actor->DamageMultiply = ACSToDouble(value); break; case APROP_MasterTID: @@ -4044,7 +4044,7 @@ int DLevelScript::GetActorProperty (int tid, int property) case APROP_Speed: return DoubleToACS(actor->Speed); case APROP_Damage: return actor->GetMissileDamage(0,1); case APROP_DamageFactor:return DoubleToACS(actor->DamageFactor); - case APROP_DamageMultiplier: return actor->DamageMultiply; + case APROP_DamageMultiplier: return DoubleToACS(actor->DamageMultiply); case APROP_Alpha: return DoubleToACS(actor->Alpha); case APROP_RenderStyle: for (int style = STYLE_None; style < STYLE_Count; ++style) { // Check for a legacy render style that matches. diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 6d047e6f3..35209a9f9 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -1076,7 +1076,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, if (damage > 0 && source != NULL) { - damage = FixedMul(damage, source->DamageMultiply); + damage = int(damage * source->DamageMultiply); // Handle active damage modifiers (e.g. PowerDamage) if (damage > 0 && source->Inventory != NULL) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 8b6c3f4ad..478ec3a9e 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -410,7 +410,7 @@ void AActor::Serialize(FArchive &arc) } else { - DamageMultiply = FRACUNIT; + DamageMultiply = 1.; } arc << WeaveIndexXY << WeaveIndexZ << PoisonDamageReceived << PoisonDurationReceived << PoisonPeriodReceived << Poisoner @@ -4180,7 +4180,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a actor->touching_sectorlist = NULL; // NULL head of sector list // phares 3/13/98 if (G_SkillProperty(SKILLP_FastMonsters) && actor->GetClass()->FastSpeed >= 0) actor->Speed = actor->GetClass()->FastSpeed; - actor->DamageMultiply = FRACUNIT; + actor->DamageMultiply = 1.; // set subsector and/or block links actor->LinkToWorld (SpawningMapThing); From fb8e03d5eb3c2bcf3606c87fc1e4a62168dcc40b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Mar 2016 18:19:54 +0100 Subject: [PATCH 07/44] - floatified FLineOpening. - some smaller fixes. --- src/actor.h | 13 +--- src/am_map.cpp | 2 +- src/b_func.cpp | 2 +- src/c_cmds.cpp | 2 +- src/g_shared/a_fastprojectile.cpp | 2 +- src/g_strife/a_sentinel.cpp | 2 +- src/p_3dfloors.cpp | 29 ++++----- src/p_3dfloors.h | 2 +- src/p_3dmidtex.cpp | 26 ++++++-- src/p_map.cpp | 101 +++++++++++++++--------------- src/p_maputl.cpp | 45 +++++++------ src/p_maputl.h | 33 +++++++--- src/p_spec.h | 2 +- src/p_switch.cpp | 6 +- src/p_things.cpp | 2 +- src/p_writemap.cpp | 2 +- src/po_man.cpp | 8 +-- src/posix/sdl/sdlvideo.cpp | 2 +- src/r_defs.h | 10 +++ src/r_plane.cpp | 2 - src/s_sound.cpp | 36 +++++------ src/thingdef/thingdef_codeptr.cpp | 4 +- 22 files changed, 182 insertions(+), 151 deletions(-) diff --git a/src/actor.h b/src/actor.h index aa5e48429..07e1f94a5 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1415,17 +1415,10 @@ public: DVector3 PosRelative(sector_t *sec) const; DVector3 PosRelative(line_t *line) const; - fixed_t SoundX() const + FVector3 SoundPos() const { - return _f_X(); - } - fixed_t SoundY() const - { - return _f_Y(); - } - fixed_t SoundZ() const - { - return _f_Z(); + // fixme: This still needs portal handling + return{ float(X()), float(Y()), float(Z()) }; } DVector3 InterpolatedPosition(double ticFrac) const { diff --git a/src/am_map.cpp b/src/am_map.cpp index 48fbe1817..9bdf61c2f 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -648,7 +648,7 @@ CUSTOM_CVAR (Int, am_cheat, 0, 0) #define AM_NUMMARKPOINTS 10 -// player _f_radius() for automap checking +// player radius for automap checking #define PLAYERRADIUS 16*MAPUNIT // how much the automap moves window per tic in frame-buffer coordinates diff --git a/src/b_func.cpp b/src/b_func.cpp index e088f70ac..803643cea 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -458,7 +458,7 @@ void FCajunMaster::SetBodyAt (const DVector3 &pos, int hostnum) // //Returns NULL if shouldn't fire //else an angle (in degrees) are given -//This function assumes actor->player->_f_angle() +//This function assumes actor->player->angle //has been set an is the main aiming angle. diff --git a/src/c_cmds.cpp b/src/c_cmds.cpp index 44c37336f..2ebaca1f6 100644 --- a/src/c_cmds.cpp +++ b/src/c_cmds.cpp @@ -903,7 +903,7 @@ CCMD(info) PrintMiscActorInfo(t.linetarget); } else Printf("No target found. Info cannot find actors that have " - "the NOBLOCKMAP flag or have height/_f_radius() of 0.\n"); + "the NOBLOCKMAP flag or have height/radius of 0.\n"); } typedef bool (*ActorTypeChecker) (AActor *); diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index c82e0874b..55489cdcf 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -73,7 +73,7 @@ void AFastProjectile::Tick () if (tm.ceilingline && tm.ceilingline->backsector && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && - Z() >= tm.ceilingline->backsector->ceilingplane.ZatPointF(_f_PosRelative(tm.ceilingline))) + Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(PosRelative(tm.ceilingline))) { // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. diff --git a/src/g_strife/a_sentinel.cpp b/src/g_strife/a_sentinel.cpp index 977098df4..fa99c827f 100644 --- a/src/g_strife/a_sentinel.cpp +++ b/src/g_strife/a_sentinel.cpp @@ -68,7 +68,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_SentinelAttack) P_CheckMissileSpawn (trail, self->radius); } } - missile->_f_AddZ(missile->_f_velz() >> 2); + missile->AddZ(missile->Vel.Z / 4); } return 0; } diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index db98330ee..bb74986cc 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -753,23 +753,24 @@ lightlist_t * P_GetPlaneLight(sector_t * sector, secplane_t * plane, bool unders //========================================================================== void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *linedef, - fixed_t x, fixed_t y, fixed_t refx, fixed_t refy, bool restrict) + double x, double y, bool restrict) { if(thing) { - fixed_t thingbot, thingtop; + double thingbot, thingtop; + + thingbot = thing->Z(); + thingtop = thing->Top(); - thingbot = thing->_f_Z(); - thingtop = thingbot + (thing->_f_height()==0? 1:thing->_f_height()); extsector_t::xfloor *xf[2] = {&linedef->frontsector->e->XFloor, &linedef->backsector->e->XFloor}; // Check for 3D-floors in the sector (mostly identical to what Legacy does here) if(xf[0]->ffloors.Size() || xf[1]->ffloors.Size()) { - fixed_t lowestceiling = open.top; - fixed_t highestfloor = open.bottom; - fixed_t lowestfloor[2] = { + double lowestceiling = open.top; + double highestfloor = open.bottom; + double lowestfloor[2] = { linedef->frontsector->floorplane.ZatPoint(x, y), linedef->backsector->floorplane.ZatPoint(x, y) }; FTextureID highestfloorpic; @@ -790,20 +791,20 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_SOLID)) continue; - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(x, y); - fixed_t ff_top=rover->top.plane->ZatPoint(x, y); + double ff_bottom=rover->bottom.plane->ZatPoint(x, y); + double ff_top=rover->top.plane->ZatPoint(x, y); - fixed_t delta1 = abs(thingbot - ((ff_bottom + ff_top) / 2)); - fixed_t delta2 = abs(thingtop - ((ff_bottom + ff_top) / 2)); + double delta1 = fabs(thingbot - ((ff_bottom + ff_top) / 2)); + double delta2 = fabs(thingtop - ((ff_bottom + ff_top) / 2)); - if(ff_bottom < lowestceiling && delta1 >= delta2) + if(ff_bottom < lowestceiling && delta1 > delta2) { lowestceiling = ff_bottom; lowestceilingpic = *rover->bottom.texture; lowestceilingsec = j == 0 ? linedef->frontsector : linedef->backsector; } - if(ff_top > highestfloor && delta1 < delta2 && (!restrict || thing->_f_Z() >= ff_top)) + if(ff_top > highestfloor && delta1 < delta2 && (!restrict || thing->Z() >= ff_top)) { highestfloor = ff_top; highestfloorpic = *rover->top.texture; @@ -811,7 +812,7 @@ void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *li highestfloorsec = j == 0 ? linedef->frontsector : linedef->backsector; highestfloorplanes[j] = rover->top.plane; } - if(ff_top > lowestfloor[j] && ff_top <= thing->_f_Z() + thing->_f_MaxStepHeight()) lowestfloor[j] = ff_top; + if(ff_top > lowestfloor[j] && ff_top <= thing->Z() + thing->MaxStepHeight) lowestfloor[j] = ff_top; } } diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index baf7dd130..3ec2ab202 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -139,7 +139,7 @@ void P_Spawn3DFloors( void ); struct FLineOpening; void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *linedef, - fixed_t x, fixed_t y, fixed_t refx, fixed_t refy, bool restrict); + double x, double y, bool restrict); 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); diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index b86e46e2d..8b1e5aabb 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -36,6 +36,7 @@ #include "templates.h" +#include "p_3dmidtex.h" #include "p_local.h" #include "p_terrain.h" #include "p_maputl.h" @@ -256,6 +257,19 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, f } +bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, double *ptexbot) +{ + fixed_t t, b; + if (P_GetMidTexturePosition(line, sideno, &t, &b)) + { + *ptextop = FIXED2DBL(t); + *ptexbot = FIXED2DBL(b); + return true; + } + return false; +} + + //============================================================================ // // P_LineOpening_3dMidtex @@ -273,12 +287,12 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening & return false; } - fixed_t tt, tb; + double tt, tb; open.abovemidtex = false; if (P_GetMidTexturePosition(linedef, 0, &tt, &tb)) { - if (thing->_f_Z() + (thing->_f_height()/2) < (tt + tb)/2) + if (thing->Center() < (tt + tb)/2) { if (tb < open.top) { @@ -288,18 +302,18 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening & } else { - if (tt > open.bottom && (!restrict || thing->_f_Z() >= tt)) + if (tt > open.bottom && (!restrict || thing->Z() >= tt)) { open.bottom = tt; open.abovemidtex = true; open.floorpic = linedef->sidedef[0]->GetTexture(side_t::mid); open.floorterrain = TerrainTypes[open.floorpic]; - open.frontfloorplane.SetAtHeight(tt, sector_t::floor); - open.backfloorplane.SetAtHeight(tt, sector_t::floor); + open.frontfloorplane.SetAtHeight(FLOAT2FIXED(tt), sector_t::floor); + open.backfloorplane.SetAtHeight(FLOAT2FIXED(tt), sector_t::floor); } // returns true if it touches the midtexture - return (abs(thing->_f_Z() - tt) <= thing->_f_MaxStepHeight()); + return (fabs(thing->Z() - tt) <= thing->MaxStepHeight); } } return false; diff --git a/src/p_map.cpp b/src/p_map.cpp index c261d1e4c..b5857dad6 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -242,36 +242,36 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLines // adjust floor / ceiling heights if (!(flags & FFCF_NOCEILING)) { - if (open.top < tmf._f_ceilingz()) + if (open.top < tmf.ceilingz) { tmf.ceilingz = open.top; if (open.topsec != NULL) tmf.ceilingsector = open.topsec; - if (ffcf_verbose) Printf(" Adjust ceilingz to %f\n", FIXED2FLOAT(open.top)); + if (ffcf_verbose) Printf(" Adjust ceilingz to %f\n", open.top); mit.StopUp(); } } if (!(flags & FFCF_NOFLOOR)) { - if (open.bottom > tmf._f_floorz()) + if (open.bottom > tmf.floorz) { - tmf.floorz = FIXED2DBL(open.bottom); + tmf.floorz = open.bottom; if (open.bottomsec != NULL) tmf.floorsector = open.bottomsec; tmf.touchmidtex = open.touchmidtex; tmf.abovemidtex = open.abovemidtex; - if (ffcf_verbose) Printf(" Adjust floorz to %f\n", FIXED2FLOAT(open.bottom)); + if (ffcf_verbose) Printf(" Adjust floorz to %f\n", open.bottom); if (tmf.floorz > tmf.dropoffz + tmf.thing->MaxDropOffHeight) mit.StopDown(); } - else if (open.bottom == tmf._f_floorz()) + else if (open.bottom == tmf.floorz) { tmf.touchmidtex |= open.touchmidtex; tmf.abovemidtex |= open.abovemidtex; } - if (open.lowfloor < tmf._f_dropoffz() && open.lowfloor > FIXED_MIN) + if (open.lowfloor < tmf.dropoffz && open.lowfloor > LINEOPEN_MIN) { - tmf.dropoffz = FIXED2DBL(open.lowfloor); - if (ffcf_verbose) Printf(" Adjust dropoffz to %f\n", FIXED2FLOAT(open.bottom)); + tmf.dropoffz = open.lowfloor; + if (ffcf_verbose) Printf(" Adjust dropoffz to %f\n", open.bottom); if (tmf.floorz > tmf.dropoffz + tmf.thing->MaxDropOffHeight) mit.StopDown(); } } @@ -915,9 +915,9 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec // If the floor planes on both sides match we should recalculate open.bottom at the actual position we are checking // This is to avoid bumpy movement when crossing a linedef with the same slope on both sides. - if (open.frontfloorplane == open.backfloorplane && open.bottom > FIXED_MIN) + if (open.frontfloorplane == open.backfloorplane && open.bottom > LINEOPEN_MIN) { - open.bottom = open.frontfloorplane.ZatPoint(cres.position.x, cres.position.y); + open.bottom = open.frontfloorplane._f_ZatPointF(cres.position.x, cres.position.y); } if (rail && @@ -929,17 +929,17 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec // from either side. How long until somebody reports this as a bug and I'm // forced to say, "It's not a bug. It's a feature?" Ugh. (!(level.flags2 & LEVEL2_RAILINGHACK) || - open.bottom == tm.thing->Sector->floorplane.ZatPoint(ref.x, ref.y))) + open.bottom == tm.thing->Sector->floorplane._f_ZatPointF(ref.x, ref.y))) { - open.bottom += 32 * FRACUNIT; + open.bottom += 32; } // adjust floor / ceiling heights if (!(cres.portalflags & FFCF_NOCEILING)) { - if (open.top < tm._f_ceilingz()) + if (open.top < tm.ceilingz) { - tm.ceilingz = FIXED2DBL(open.top); + tm.ceilingz = open.top; tm.ceilingsector = open.topsec; tm.ceilingpic = open.ceilingpic; tm.ceilingline = ld; @@ -949,9 +949,9 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec if (!(cres.portalflags & FFCF_NOFLOOR)) { - if (open.bottom > tm._f_floorz()) + if (open.bottom > tm.floorz) { - tm.floorz = FIXED2DBL(open.bottom); + tm.floorz = open.bottom; tm.floorsector = open.bottomsec; tm.floorpic = open.floorpic; tm.floorterrain = open.floorterrain; @@ -959,15 +959,15 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec tm.abovemidtex = open.abovemidtex; tm.thing->BlockingLine = ld; } - else if (open.bottom == tm._f_floorz()) + else if (open.bottom == tm.floorz) { tm.touchmidtex |= open.touchmidtex; tm.abovemidtex |= open.abovemidtex; } - if (open.lowfloor < tm._f_dropoffz()) + if (open.lowfloor < tm.dropoffz) { - tm.dropoffz = FIXED2FLOAT(open.lowfloor); + tm.dropoffz = open.lowfloor; } } @@ -1022,15 +1022,16 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera return false; line_t *lp = cres.line->getPortalDestination(); - fixed_t zofs = 0; + fixed_t _zofs = 0; P_TranslatePortalXY(cres.line, cres.position.x, cres.position.y); - P_TranslatePortalZ(cres.line, zofs); + P_TranslatePortalZ(cres.line, _zofs); + double zofs = FIXED2DBL(_zofs); // fudge a bit with the portal line so that this gets included in the checks that normally only get run on two-sided lines sector_t *sec = lp->backsector; if (lp->backsector == NULL) lp->backsector = lp->frontsector; - tm.thing->_f_AddZ(zofs); + tm.thing->AddZ(zofs); FBoundingBox pbox(cres.position.x, cres.position.y, tm.thing->_f_radius()); FBlockLinesIterator it(pbox); @@ -1058,9 +1059,9 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera P_LineOpening(open, tm.thing, ld, ref.x, ref.y, cres.position.x, cres.position.y, 0); // adjust floor / ceiling heights - if (open.top - zofs < tm._f_ceilingz()) + if (open.top - zofs < tm.ceilingz) { - tm.ceilingz = FIXED2FLOAT(open.top - zofs); + tm.ceilingz = open.top - zofs; tm.ceilingpic = open.ceilingpic; /* tm.ceilingsector = open.topsec; @@ -1070,9 +1071,9 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera ret = true; } - if (open.bottom - zofs > tm._f_floorz()) + if (open.bottom - zofs > tm.floorz) { - tm.floorz = FIXED2DBL(open.bottom - zofs); + tm.floorz = open.bottom - zofs; tm.floorpic = open.floorpic; tm.floorterrain = open.floorterrain; /* @@ -1084,10 +1085,10 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera ret = true; } - if (open.lowfloor - zofs < tm._f_dropoffz()) - tm.dropoffz = FIXED2FLOAT(open.lowfloor - zofs); + if (open.lowfloor - zofs < tm.dropoffz) + tm.dropoffz = open.lowfloor - zofs; } - tm.thing->_f_AddZ(-zofs); + tm.thing->AddZ(-zofs); lp->backsector = sec; return ret; @@ -2829,22 +2830,22 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t // set openrange, opentop, openbottom P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); - if (open.range < slidemo->_f_height()) + if (open.range < slidemo->Height) goto isblocking; // doesn't fit - if (open.top - slidemo->_f_Z() < slidemo->_f_height()) + if (open.top < slidemo->Top()) goto isblocking; // mobj is too high - if (open.bottom - slidemo->_f_Z() > slidemo->MaxStepHeight) + if (open.bottom - slidemo->Z() > slidemo->MaxStepHeight) { goto isblocking; // too big a step up } - else if (slidemo->_f_Z() < open.bottom) + else if (slidemo->Z() < open.bottom) { // [RH] Check to make sure there's nothing in the way for the step up - fixed_t savedz = slidemo->_f_Z(); - slidemo->_f_SetZ(open.bottom); + double savedz = slidemo->Z(); + slidemo->SetZ(open.bottom); bool good = P_TestMobjZ(slidemo); - slidemo->_f_SetZ(savedz); + slidemo->SetZ(savedz); if (!good) { goto isblocking; @@ -3184,13 +3185,13 @@ bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_ P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); // set openrange, opentop, openbottom - if (open.range < slidemo->_f_height()) + if (open.range < slidemo->Height) goto bounceblocking; // doesn't fit - if (open.top - slidemo->_f_Z() < slidemo->_f_height()) + if (open.top < slidemo->Top()) goto bounceblocking; // mobj is too high - if (open.bottom > slidemo->_f_Z()) + if (open.bottom > slidemo->Z()) goto bounceblocking; // mobj is too low continue; // this line doesn't block movement @@ -3809,20 +3810,20 @@ struct aim_t // The following code assumes that portals on the front of the line have already been processed. - if (open.range <= 0 || open.bottom >= open.top) + if (open.range <= 0 || open.bottom >= open.top) return; dist = FixedMul(attackrange, in->frac); - if (open.bottom != FIXED_MIN) + if (open.bottom != LINEOPEN_MIN) { - pitch = -(int)R_PointToAngle2(0, shootz, dist, open.bottom); + pitch = -(int)R_PointToAngle2(0, shootz, dist, FLOAT2FIXED(open.bottom)); if (pitch < bottompitch) bottompitch = pitch; } - if (open.top != FIXED_MAX) + if (open.top != LINEOPEN_MAX) { - pitch = -(int)R_PointToAngle2(0, shootz, dist, open.top); + pitch = -(int)R_PointToAngle2(0, shootz, dist, FLOAT2FIXED(open.top)); if (pitch > toppitch) toppitch = pitch; } @@ -3840,11 +3841,11 @@ struct aim_t sector_t *exitsec = frontflag ? li->backsector : li->frontsector; lastsector = entersec; // check portal in backsector when aiming up/downward is possible, the line doesn't have portals on both sides and there's actually a portal in the backsector - if ((planestocheck & aim_up) && toppitch < 0 && open.top != FIXED_MAX && !entersec->PortalBlocksMovement(sector_t::ceiling)) + if ((planestocheck & aim_up) && toppitch < 0 && open.top != LINEOPEN_MAX && !entersec->PortalBlocksMovement(sector_t::ceiling)) { EnterSectorPortal(sector_t::ceiling, in->frac, entersec, toppitch, MIN(0, bottompitch)); } - if ((planestocheck & aim_down) && bottompitch > 0 && open.bottom != FIXED_MIN && !entersec->PortalBlocksMovement(sector_t::floor)) + if ((planestocheck & aim_down) && bottompitch > 0 && open.bottom != LINEOPEN_MIN && !entersec->PortalBlocksMovement(sector_t::floor)) { EnterSectorPortal(sector_t::floor, in->frac, entersec, MAX(0, toppitch), bottompitch); } @@ -5067,8 +5068,8 @@ bool P_NoWayTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t e if (ld->flags&(ML_BLOCKING | ML_BLOCKEVERYTHING | ML_BLOCK_PLAYERS)) return true; P_LineOpening(open, NULL, ld, it.InterceptPoint(in)); if (open.range <= 0 || - open.bottom > usething->_f_Z() + usething->_f_MaxStepHeight() || - open.top < usething->_f_Top()) return true; + open.bottom > usething->Z() + usething->MaxStepHeight || + open.top < usething->Top()) return true; } return false; } @@ -6345,7 +6346,7 @@ void P_CreateSecNodeList(AActor *thing, fixed_t x, fixed_t y) sector_list = P_AddSecnode(ld->frontsector, thing, sector_list); // Don't assume all lines are 2-sided, since some Things - // like MT_TFOG are allowed regardless of whether their _f_radius() takes + // like MT_TFOG are allowed regardless of whether their radius takes // them beyond an impassable linedef. // killough 3/27/98, 4/4/98: diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 4a3687083..91b45a373 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -144,13 +144,12 @@ fixed_t P_InterceptVector (const fdivline_t *v2, const fdivline_t *v1) // //========================================================================== -void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, - fixed_t x, fixed_t y, fixed_t refx, fixed_t refy, int flags) +void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, const DVector2 &pos, const DVector2 *ref, int flags) { if (!(flags & FFCF_ONLY3DFLOORS)) { sector_t *front, *back; - fixed_t fc = 0, ff = 0, bc = 0, bf = 0; + double fc = 0, ff = 0, bc = 0, bf = 0; if (linedef->backsector == NULL) { @@ -164,16 +163,16 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, if (!(flags & FFCF_NOPORTALS) && (linedef->flags & ML_PORTALCONNECT)) { - if (!linedef->frontsector->PortalBlocksMovement(sector_t::ceiling)) fc = FIXED_MAX; - if (!linedef->backsector->PortalBlocksMovement(sector_t::ceiling)) bc = FIXED_MAX; - if (!linedef->frontsector->PortalBlocksMovement(sector_t::floor)) ff = FIXED_MIN; - if (!linedef->backsector->PortalBlocksMovement(sector_t::floor)) bf = FIXED_MIN; + if (!linedef->frontsector->PortalBlocksMovement(sector_t::ceiling)) fc = LINEOPEN_MAX; + if (!linedef->backsector->PortalBlocksMovement(sector_t::ceiling)) bc = LINEOPEN_MAX; + if (!linedef->frontsector->PortalBlocksMovement(sector_t::floor)) ff = LINEOPEN_MIN; + if (!linedef->backsector->PortalBlocksMovement(sector_t::floor)) bf = LINEOPEN_MIN; } - if (fc == 0) fc = front->ceilingplane.ZatPoint(x, y); - if (bc == 0) bc = back->ceilingplane.ZatPoint(x, y); - if (ff == 0) ff = front->floorplane.ZatPoint(x, y); - if (bf == 0) bf = back->floorplane.ZatPoint(x, y); + if (fc == 0) fc = front->ceilingplane.ZatPoint(pos); + if (bc == 0) bc = back->ceilingplane.ZatPoint(pos); + if (ff == 0) ff = front->floorplane.ZatPoint(pos); + if (bf == 0) bf = back->floorplane.ZatPoint(pos); /*Printf ("]]]]]] %d %d\n", ff, bf);*/ @@ -189,7 +188,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, // that imprecisions in the plane equation mean there is a // good chance that even if a slope and non-slope look like // they line up, they won't be perfectly aligned. - if (ff == FIXED_MIN || bf == FIXED_MIN || (refx == FIXED_MIN || abs (ff-bf) > 256)) + if (ff == -FLT_MIN || bf == -FLT_MIN || ref == NULL || fabs (ff-bf) > 1./256) { usefront = (ff > bf); } @@ -200,7 +199,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, else if ((back->floorplane.a | front->floorplane.b) == 0) usefront = false; else - usefront = !P_PointOnLineSide (refx, refy, linedef); + usefront = !P_PointOnLineSide (*ref, linedef); } if (usefront) @@ -209,12 +208,12 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, open.bottomsec = front; open.floorpic = front->GetTexture(sector_t::floor); open.floorterrain = front->GetTerrain(sector_t::floor); - if (bf != FIXED_MIN) open.lowfloor = bf; + if (bf != -FLT_MIN) open.lowfloor = bf; else if (!(flags & FFCF_NODROPOFF)) { // We must check through the portal for the actual dropoff. // If there's no lines in the lower sections we'd never get a usable value otherwise. - open.lowfloor = back->NextLowestFloorAt(refx, refy, FLOAT2FIXED(back->SkyBoxes[sector_t::floor]->specialf1)-1); + open.lowfloor = back->NextLowestFloorAt(pos.X, pos.Y, back->SkyBoxes[sector_t::floor]->specialf1-1); } } else @@ -223,12 +222,12 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, open.bottomsec = back; open.floorpic = back->GetTexture(sector_t::floor); open.floorterrain = back->GetTerrain(sector_t::floor); - if (ff != FIXED_MIN) open.lowfloor = ff; + if (ff != -FLT_MIN) open.lowfloor = ff; else if (!(flags & FFCF_NODROPOFF)) { // We must check through the portal for the actual dropoff. // If there's no lines in the lower sections we'd never get a usable value otherwise. - open.lowfloor = front->NextLowestFloorAt(refx, refy, FLOAT2FIXED(front->SkyBoxes[sector_t::floor]->specialf1) - 1); + open.lowfloor = front->NextLowestFloorAt(pos.X, pos.Y, front->SkyBoxes[sector_t::floor]->specialf1 - 1); } } open.frontfloorplane = front->floorplane; @@ -238,12 +237,12 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, { // Dummy stuff to have some sort of opening for the 3D checks to modify open.topsec = NULL; open.ceilingpic.SetInvalid(); - open.top = FIXED_MAX; + open.top = LINEOPEN_MAX; open.bottomsec = NULL; open.floorpic.SetInvalid(); open.floorterrain = -1; - open.bottom = FIXED_MIN; - open.lowfloor = FIXED_MAX; + open.bottom = LINEOPEN_MIN; + open.lowfloor = LINEOPEN_MAX; open.frontfloorplane.SetAtHeight(FIXED_MIN, sector_t::floor); open.backfloorplane.SetAtHeight(FIXED_MIN, sector_t::floor); } @@ -251,7 +250,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, // Check 3D floors if (actor != NULL) { - P_LineOpening_XFloors(open, actor, linedef, x, y, refx, refy, !!(flags & FFCF_3DRESTRICT)); + P_LineOpening_XFloors(open, actor, linedef, pos.X, pos.Y, !!(flags & FFCF_3DRESTRICT)); } if (actor != NULL && linedef->frontsector != NULL && linedef->backsector != NULL && @@ -265,7 +264,7 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, } // avoid overflows in the opening. - open.range = (fixed_t)MIN((SQWORD)open.top - open.bottom, FIXED_MAX); + open.range = clamp(open.top - open.bottom, LINEOPEN_MIN, LINEOPEN_MAX); } @@ -446,7 +445,7 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector) { if (!spawningmapthing || numgamenodes == 0) { - sector = P_PointInSector(_f_X(), _f_Y()); + sector = P_PointInSector(Pos()); } else { diff --git a/src/p_maputl.h b/src/p_maputl.h index 96053dc90..727b56c2b 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -57,6 +57,16 @@ inline int P_PointOnLineSidePrecise (fixed_t x, fixed_t y, const line_t *line) return DMulScale32 (y-line->v1->y, line->dx, line->v1->x-x, line->dy) > 0; } +inline int P_PointOnLineSide(double x, double y, const line_t *line) +{ + return P_PointOnLineSide(FLOAT2FIXED(x), FLOAT2FIXED(y), line); +} + +inline int P_PointOnLineSide(const DVector2 & p, const line_t *line) +{ + return P_PointOnLineSide(FLOAT2FIXED(p.X), FLOAT2FIXED(p.Y), line); +} + inline int P_PointOnLineSidePrecise(double x, double y, const line_t *line) { return DMulScale32(FLOAT2FIXED(y) - line->v1->y, line->dx, line->v1->x - FLOAT2FIXED(x), line->dy) > 0; @@ -67,10 +77,6 @@ inline int P_PointOnLineSidePrecise(const DVector2 &pt, const line_t *line) return DMulScale32(FLOAT2FIXED(pt.Y) - line->v1->y, line->dx, line->v1->x - FLOAT2FIXED(pt.X), line->dy) > 0; } -inline int P_PointOnLineSidePrecise(const DVector3 &pt, const line_t *line) -{ - return DMulScale32(FLOAT2FIXED(pt.Y) - line->v1->y, line->dx, line->v1->x - FLOAT2FIXED(pt.X), line->dy) > 0; -} //========================================================================== // @@ -117,10 +123,10 @@ inline void P_MakeDivline (const line_t *li, fdivline_t *dl) struct FLineOpening { - fixed_t top; - fixed_t bottom; - fixed_t range; - fixed_t lowfloor; + double top; + double bottom; + double range; + double lowfloor; sector_t *bottomsec; sector_t *topsec; FTextureID ceilingpic; @@ -132,11 +138,20 @@ struct FLineOpening bool abovemidtex; }; -void P_LineOpening (FLineOpening &open, AActor *thing, const line_t *linedef, fixed_t x, fixed_t y, fixed_t refx=FIXED_MIN, fixed_t refy=0, int flags=0); +static const double LINEOPEN_MIN = -FLT_MAX; +static const double LINEOPEN_MAX = FLT_MAX; + +void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, const DVector2 &xy, const DVector2 *ref = NULL, int flags = 0); + +inline void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, fixed_t x, fixed_t y, fixed_t refx = FIXED_MIN, fixed_t refy = 0, int flags = 0) +{ + P_LineOpening(open, thing, linedef, DVector2(FIXED2DBL(x), FIXED2DBL(y)), &DVector2(FIXED2DBL(refx), FIXED2DBL(refy)), flags); +} inline void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, fixedvec2 xy, fixed_t refx = FIXED_MIN, fixed_t refy = 0, int flags = 0) { P_LineOpening(open, thing, linedef, xy.x, xy.y, refx, refy, flags); } +void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, const DVector2 &xy, fixed_t refx = FIXED_MIN, const DVector2 *ref = NULL, int flags = 0); class FBoundingBox; struct polyblock_t; diff --git a/src/p_spec.h b/src/p_spec.h index cfdbd5241..78965581e 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -131,7 +131,7 @@ protected: TObjPtr m_Source;// Point source if point pusher DVector2 m_PushVec; double m_Magnitude; // Vector strength for point pusher - double m_Radius; // Effective _f_radius() for point pusher + double m_Radius; // Effective radius for point pusher int m_Affectee; // Number of affected sector friend bool PIT_PushThing (AActor *thing); diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 2e5649d8e..91f579250 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -199,7 +199,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo } } - return (user->_f_Top() > open.top); + return (user->Top() > open.top); } else if ((TexMan.FindSwitch(side->GetTexture(side_t::bottom))) != NULL) { @@ -221,7 +221,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo } } - return (user->_f_Z() < open.bottom); + return (user->Z() < open.bottom); } else if ((flags & ML_3DMIDTEX) || (TexMan.FindSwitch(side->GetTexture(side_t::mid))) != NULL) { @@ -234,7 +234,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo else { // no switch found. Check whether the player can touch either top or bottom texture - return (user->_f_Top() > open.top) || (user->_f_Z() < open.bottom); + return (user->Top() > open.top) || (user->Z() < open.bottom); } } diff --git a/src/p_things.cpp b/src/p_things.cpp index 3e37135f3..929f07482 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -427,7 +427,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->_f_Pos())) + if (!P_CheckPosition (thing, thing->Pos())) { thing->flags = oldflags; thing->radius = oldradius; diff --git a/src/p_writemap.cpp b/src/p_writemap.cpp index a9ae49f12..ab3290619 100644 --- a/src/p_writemap.cpp +++ b/src/p_writemap.cpp @@ -102,7 +102,7 @@ static int WriteTHINGS (FILE *file) mt.x = LittleShort(short(mo->X())); mt.y = LittleShort(short(mo->Y())); - mt.angle = LittleShort(short(MulScale32 (mo->_f_angle() >> ANGLETOFINESHIFT, 360))); + mt.angle = LittleShort(short(mo->Angles.Yaw.Degrees)); mt.type = LittleShort((short)1); mt.flags = LittleShort((short)(7|224|MTF_SINGLE)); fwrite (&mt, sizeof(mt), 1, file); diff --git a/src/po_man.cpp b/src/po_man.cpp index fa94c198a..91d4218ef 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -1191,8 +1191,8 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) if ((mobj->flags&MF_SOLID) && !(mobj->flags&MF_NOCLIP)) { FLineOpening open; - open.top = INT_MAX; - open.bottom = -INT_MAX; + open.top = LINEOPEN_MAX; + open.bottom = LINEOPEN_MIN; // [TN] Check wether this actor gets blocked by the line. if (ld->backsector != NULL && !(ld->flags & (ML_BLOCKING|ML_BLOCKEVERYTHING)) @@ -1201,7 +1201,7 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) && !((mobj->flags & MF_FLOAT) && (ld->flags & ML_BLOCK_FLOATERS)) && (!(ld->flags & ML_3DMIDTEX) || (!P_LineOpening_3dMidtex(mobj, ld, open) && - (mobj->_f_Top() < open.top) + (mobj->Top() < open.top) ) || (open.abovemidtex && mobj->Z() > mobj->floorz)) ) { @@ -1233,7 +1233,7 @@ bool FPolyObj::CheckMobjBlocking (side_t *sd) // Best use the one facing the player and ignore the back side. if (ld->sidedef[1] != NULL) { - int side = P_PointOnLineSidePrecise(mobj->_f_X(), mobj->_f_Y(), ld); + int side = P_PointOnLineSidePrecise(mobj->Pos(), ld); if (ld->sidedef[side] != sd) { continue; diff --git a/src/posix/sdl/sdlvideo.cpp b/src/posix/sdl/sdlvideo.cpp index 90bc42663..04c3a3f2e 100644 --- a/src/posix/sdl/sdlvideo.cpp +++ b/src/posix/sdl/sdlvideo.cpp @@ -491,7 +491,7 @@ void SDLFB::Update () return; pixels = Surface->pixels; - pitch = Surface->_f_pitch(); + pitch = Surface->pitch; } if (NotPaletted) diff --git a/src/r_defs.h b/src/r_defs.h index a467ba6ee..8cadafb93 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -880,6 +880,16 @@ struct sector_t fixed_t NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fixed_t topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL); fixed_t NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags = 0, fixed_t steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL); + inline double NextHighestCeilingAt(double x, double y, double bottomz, double topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL) + { + return FIXED2DBL(NextHighestCeilingAt(FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(bottomz), FLOAT2FIXED(topz), flags, resultsec, resultffloor)); + } + + double NextLowestFloorAt(double x, double y, double z, int flags = 0, double steph = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL) + { + return FIXED2DBL(NextLowestFloorAt(FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(z), flags, FLOAT2FIXED(steph), resultsec, resultffloor)); + } + // Member variables fixed_t CenterFloor () const { return floorplane.ZatPoint (centerspot); } fixed_t CenterCeiling () const { return ceilingplane.ZatPoint (centerspot); } diff --git a/src/r_plane.cpp b/src/r_plane.cpp index e46dfa5fe..6a3aa803f 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -1106,8 +1106,6 @@ void R_DrawHeightPlanes(fixed_t height) void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool masked) { -// pl->_f_angle() = pa<left >= pl->right) return; diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 76d8e4956..e04542a5b 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -173,9 +173,7 @@ void S_NoiseDebug (void) } - listener.X = FIXED2FLOAT(players[consoleplayer].camera->SoundX()); - listener.Y = FIXED2FLOAT(players[consoleplayer].camera->SoundZ()); - listener.Z = FIXED2FLOAT(players[consoleplayer].camera->SoundY()); + listener = players[consoleplayer].camera->SoundPos(); // Display the oldest channel first. for (chan = Channels; chan->NextChan != NULL; chan = chan->NextChan) @@ -664,9 +662,10 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, if (players[consoleplayer].camera != NULL) { - x = players[consoleplayer].camera->SoundX(); - y = players[consoleplayer].camera->SoundZ(); - z = players[consoleplayer].camera->SoundY(); + FVector3 v = players[consoleplayer].camera->SoundPos(); + x = FLOAT2FIXED(v.X); + y = FLOAT2FIXED(v.Y); + z = FLOAT2FIXED(v.Z); } else { @@ -693,9 +692,10 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, //assert(actor != NULL); if (actor != NULL) { - x = actor->SoundX(); - y = actor->SoundZ(); - z = actor->SoundY(); + FVector3 v = actor->SoundPos(); + x = FLOAT2FIXED(v.X); + y = FLOAT2FIXED(v.Y); + z = FLOAT2FIXED(v.Z); } break; @@ -764,8 +764,9 @@ static void CalcSectorSoundOrg(const sector_t *sec, int channum, fixed_t *x, fix // Are we inside the sector? If yes, the closest point is the one we're on. if (P_PointInSector(*x, *y) == sec) { - *x = players[consoleplayer].camera->SoundX(); - *y = players[consoleplayer].camera->SoundY(); + FVector3 p = players[consoleplayer].camera->SoundPos(); + *x = FLOAT2FIXED(p.X); + *y = FLOAT2FIXED(p.Y); } else { @@ -1568,9 +1569,10 @@ void S_RelinkSound (AActor *from, AActor *to) { chan->Actor = NULL; chan->SourceType = SOURCE_Unattached; - chan->Point[0] = FIXED2FLOAT(from->SoundX()); - chan->Point[1] = FIXED2FLOAT(from->SoundZ()); - chan->Point[2] = FIXED2FLOAT(from->SoundY()); + FVector3 p = from->SoundPos(); + chan->Point[0] = p.X; + chan->Point[1] = p.Y; + chan->Point[2] = p.Z; } else { @@ -1950,16 +1952,14 @@ static void S_SetListener(SoundListener &listener, AActor *listenactor) { if (listenactor != NULL) { - listener.angle = ANGLE2RADF(listenactor->_f_angle()); + listener.angle = ToRadians(listenactor->Angles.Yaw); /* listener.velocity.X = listenactor->vel.x * (TICRATE/65536.f); listener.velocity.Y = listenactor->vel.z * (TICRATE/65536.f); listener.velocity.Z = listenactor->vel.y * (TICRATE/65536.f); */ listener.velocity.Zero(); - listener.position.X = FIXED2FLOAT(listenactor->SoundX()); - listener.position.Y = FIXED2FLOAT(listenactor->SoundZ()); - listener.position.Z = FIXED2FLOAT(listenactor->SoundY()); + listener.position = listenactor->SoundPos(); listener.underwater = listenactor->waterlevel == 3; assert(zones != NULL); listener.Environment = zones[listenactor->Sector->ZoneNumber].Environment; diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 6591525af..c79b2e6db 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -3297,7 +3297,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_Burst) // with no relation to the size of the self shattering. I think it should // base the number of shards on the size of the dead thing, so bigger // things break up into more shards than smaller things. - // An self with _f_radius() 20 and height 64 creates ~40 chunks. + // An self with radius 20 and height 64 creates ~40 chunks. numChunks = MAX (4, int(self->radius * self->Height)/32); i = (pr_burst.Random2()) % (numChunks/4); for (i = MAX (24, numChunks + i); i >= 0; i--) @@ -3713,7 +3713,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckLOF) if (!(flags & CLOFF_FROMBASE)) { // default to hitscan origin - // Synced with hitscan: self->_f_height() is strangely NON-conscientious about getting the right actor for player + // Synced with hitscan: self->Height is strangely NON-conscientious about getting the right actor for player pos.Z += self->Height *0.5; if (self->player != NULL) { From 8e13d13916ed9a99b792e54aae02bd108cf30c48 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 25 Mar 2016 21:54:59 +0100 Subject: [PATCH 08/44] - floatified the automap. --- src/actor.h | 7 +- src/am_map.cpp | 490 ++++++++++++++++++++++-------------------------- src/p_map.cpp | 2 +- src/p_mobj.cpp | 2 +- src/r_defs.h | 44 +++++ src/s_sound.cpp | 4 +- 6 files changed, 283 insertions(+), 266 deletions(-) diff --git a/src/actor.h b/src/actor.h index 07e1f94a5..e0043aaa2 100644 --- a/src/actor.h +++ b/src/actor.h @@ -737,7 +737,12 @@ public: inline bool IsNoClip2() const; void CheckPortalTransition(bool islinked); - fixedvec3 GetPortalTransition(fixed_t byoffset, sector_t **pSec = NULL); + fixedvec3 _f_GetPortalTransition(fixed_t byoffset, sector_t **pSec = NULL); + DVector3 GetPortalTransition(double byoffset, sector_t **pSec = NULL) + { + fixedvec3 pos = _f_GetPortalTransition(FLOAT2FIXED(byoffset), pSec); + return{ FIXED2FLOAT(pos.x), FIXED2FLOAT(pos.y),FIXED2FLOAT(pos.z) }; + } // What species am I? virtual FName GetSpecies(); diff --git a/src/am_map.cpp b/src/am_map.cpp index 9bdf61c2f..ca1d3fc2b 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -558,32 +558,24 @@ void FMapInfoParser::ParseAMColors(bool overlay) // //============================================================================= -#define MAPBITS 12 -#define MapDiv SafeDivScale12 -#define MapMul MulScale12 -#define MAPUNIT (1< CheatMapArrow; static TArray CheatKey; static TArray EasyKey; -#define R (MAPUNIT) -// [RH] Avoid lots of warnings without compiler-specific #pragmas -#define L(a,b,c,d) { {(fixed_t)((a)*R),(fixed_t)((b)*R)}, {(fixed_t)((c)*R),(fixed_t)((d)*R)} } +#define L(a,b,c,d) { {(a), (b)}, {(c), (d)} } static mline_t triangle_guy[] = { L (-.867,-.5, .867,-.5), L (.867,-.5, 0,1), @@ -730,10 +720,6 @@ static mline_t square_guy[] = { }; #define NUMSQUAREGUYLINES (sizeof(square_guy)/sizeof(mline_t)) -#undef R - - - //============================================================================= // // @@ -756,35 +742,35 @@ static int f_p; // [RH] # of bytes from start of a line to start of next static int amclock; static mpoint_t m_paninc; // how far the window pans each tic (map coords) -static fixed_t mtof_zoommul; // how far the window zooms in each tic (map coords) -static float am_zoomdir; +static double mtof_zoommul; // how far the window zooms in each tic (map coords) +static double am_zoomdir; -static fixed_t m_x, m_y; // LL x,y where the window is on the map (map coords) -static fixed_t m_x2, m_y2; // UR x,y where the window is on the map (map coords) +static double m_x, m_y; // LL x,y where the window is on the map (map coords) +static double m_x2, m_y2; // UR x,y where the window is on the map (map coords) // // width/height of window on map (map coords) // -static fixed_t m_w; -static fixed_t m_h; +static double m_w; +static double m_h; // based on level size -static fixed_t min_x, min_y, max_x, max_y; +static double min_x, min_y, max_x, max_y; -static fixed_t max_w; // max_x-min_x, -static fixed_t max_h; // max_y-min_y +static double max_w; // max_x-min_x, +static double max_h; // max_y-min_y // based on player size -static fixed_t min_w; -static fixed_t min_h; +static double min_w; +static double min_h; -static fixed_t min_scale_mtof; // used to tell when to stop zooming out -static fixed_t max_scale_mtof; // used to tell when to stop zooming in +static double min_scale_mtof; // used to tell when to stop zooming out +static double max_scale_mtof; // used to tell when to stop zooming in // old stuff for recovery later -static fixed_t old_m_w, old_m_h; -static fixed_t old_m_x, old_m_y; +static double old_m_w, old_m_h; +static double old_m_x, old_m_y; // old location used by the Follower routine static mpoint_t f_oldloc; @@ -794,18 +780,18 @@ static mpoint_t markpoints[AM_NUMMARKPOINTS]; // where the points are static int markpointnum = 0; // next point to be assigned static FTextureID mapback; // the automap background -static fixed_t mapystart=0; // y-value for the start of the map bitmap...used in the parallax stuff. -static fixed_t mapxstart=0; //x-value for the bitmap. +static double mapystart=0; // y-value for the start of the map bitmap...used in the parallax stuff. +static double mapxstart=0; //x-value for the bitmap. static bool stopped = true; static void AM_calcMinMaxMtoF(); -static void DrawMarker (FTexture *tex, fixed_t x, fixed_t y, int yadjust, - INTBOOL flip, fixed_t xscale, fixed_t yscale, int translation, double alpha, DWORD fillcolor, FRenderStyle renderstyle); +static void DrawMarker (FTexture *tex, double x, double y, int yadjust, + INTBOOL flip, double xscale, double yscale, int translation, double alpha, DWORD fillcolor, FRenderStyle renderstyle); -void AM_rotatePoint (fixed_t *x, fixed_t *y); -void AM_rotate (fixed_t *x, fixed_t *y, angle_t an); +void AM_rotatePoint (double *x, double *y); +void AM_rotate (double *x, double *y, DAngle an); void AM_doFollowPlayer (); @@ -814,6 +800,7 @@ void AM_doFollowPlayer (); // map functions // //============================================================================= + bool AM_addMark (); bool AM_clearMarks (); void AM_saveScaleAndLoc (); @@ -875,29 +862,15 @@ CCMD(am_gobig) AM_restoreScaleAndLoc(); } -// Calculates the slope and slope according to the x-axis of a line -// segment in map coordinates (with the upright y-axis n' all) so -// that it can be used with the brain-dead drawing stuff. - -// Ripped out for Heretic -/* -void AM_getIslope (mline_t *ml, islope_t *is) -{ - int dx, dy; - - dy = ml->a.y - ml->b.y; - dx = ml->b.x - ml->a.x; - if (!dy) is->islp = (dx<0?-MAXINT:MAXINT); - else is->islp = FixedDiv(dx, dy); - if (!dx) is->slp = (dy<0?-MAXINT:MAXINT); - else is->slp = FixedDiv(dy, dx); -} -*/ - +//============================================================================= +// +// vector graphics +// +//============================================================================= void AM_ParseArrow(TArray &Arrow, const char *lumpname) { - const int R = ((8*PLAYERRADIUS)/7); + const int R = int((8*PLAYERRADIUS)/7); FScanner sc; int lump = Wads.CheckNumForFullName(lumpname, true); if (lump >= 0) @@ -909,18 +882,18 @@ void AM_ParseArrow(TArray &Arrow, const char *lumpname) mline_t line; sc.TokenMustBe('('); sc.MustGetFloat(); - line.a.x = xs_RoundToInt(sc.Float*R); + line.a.x = sc.Float*R; sc.MustGetToken(','); sc.MustGetFloat(); - line.a.y = xs_RoundToInt(sc.Float*R); + line.a.y = sc.Float*R; sc.MustGetToken(')'); sc.MustGetToken(','); sc.MustGetToken('('); sc.MustGetFloat(); - line.b.x = xs_RoundToInt(sc.Float*R); + line.b.x = sc.Float*R; sc.MustGetToken(','); sc.MustGetFloat(); - line.b.y = xs_RoundToInt(sc.Float*R); + line.b.y = sc.Float*R; sc.MustGetToken(')'); Arrow.Push(line); } @@ -959,7 +932,7 @@ void AM_StaticInit() DVector2 AM_GetPosition() { - return DVector2((m_x + m_w / 2) / MAPUNIT, (m_y + m_h / 2) / MAPUNIT); + return DVector2((m_x + m_w / 2), (m_y + m_h / 2)); } //============================================================================= @@ -1011,15 +984,15 @@ void AM_restoreScaleAndLoc () } else { - m_x = (players[consoleplayer].camera->_f_X() >> FRACTOMAPBITS) - m_w/2; - m_y = (players[consoleplayer].camera->_f_Y() >> FRACTOMAPBITS)- m_h/2; + m_x = players[consoleplayer].camera->X() - m_w/2; + m_y = players[consoleplayer].camera->Y() - m_h/2; } m_x2 = m_x + m_w; m_y2 = m_y + m_h; // Change the scaling multipliers - scale_mtof = MapDiv(f_w< max_x) - max_x = vertexes[i].x; + if (vertexes[i].fX() < min_x) + min_x = vertexes[i].fX(); + else if (vertexes[i].fX() > max_x) + max_x = vertexes[i].fX(); - if (vertexes[i].y < min_y) - min_y = vertexes[i].y; - else if (vertexes[i].y > max_y) - max_y = vertexes[i].y; + if (vertexes[i].fY() < min_y) + min_y = vertexes[i].fY(); + else if (vertexes[i].fY() > max_y) + max_y = vertexes[i].fY(); } - max_w = (max_x >>= FRACTOMAPBITS) - (min_x >>= FRACTOMAPBITS); - max_h = (max_y >>= FRACTOMAPBITS) - (min_y >>= FRACTOMAPBITS); + max_w = max_x - min_x; + max_h = max_y - min_y; min_w = 2*PLAYERRADIUS; // const? never changed? min_h = 2*PLAYERRADIUS; @@ -1082,11 +1055,11 @@ static void AM_findMinMaxBoundaries () static void AM_calcMinMaxMtoF() { - fixed_t a = MapDiv (SCREENWIDTH << MAPBITS, max_w); - fixed_t b = MapDiv (::ST_Y << MAPBITS, max_h); + double a = SCREENWIDTH / max_w; + double b = ::ST_Y / max_h; min_scale_mtof = a < b ? a : b; - max_scale_mtof = MapDiv (SCREENHEIGHT << MAPBITS, 2*PLAYERRADIUS); + max_scale_mtof = SCREENHEIGHT / (2*PLAYERRADIUS); } //============================================================================= @@ -1095,7 +1068,7 @@ static void AM_calcMinMaxMtoF() // //============================================================================= -static void AM_ClipRotatedExtents (fixed_t pivotx, fixed_t pivoty) +static void AM_ClipRotatedExtents (double pivotx, double pivoty) { if (am_rotate == 0 || (am_rotate == 2 && !viewactive)) { @@ -1112,8 +1085,8 @@ static void AM_ClipRotatedExtents (fixed_t pivotx, fixed_t pivoty) else { #if 0 - fixed_t rmin_x, rmin_y, rmax_x, rmax_y; - fixed_t xs[5], ys[5]; + double rmin_x, rmin_y, rmax_x, rmax_y; + double xs[5], ys[5]; int i; xs[0] = min_x; ys[0] = min_y; @@ -1128,7 +1101,7 @@ static void AM_ClipRotatedExtents (fixed_t pivotx, fixed_t pivoty) { xs[i] -= pivotx; ys[i] -= pivoty; - AM_rotate (&xs[i], &ys[i], ANG90 - players[consoleplayer].camera->_f_angle()); + AM_rotate (&xs[i], &ys[i], 90. - players[consoleplayer].camera->Angles.Yaw); if (i == 5) break; @@ -1149,7 +1122,7 @@ static void AM_ClipRotatedExtents (fixed_t pivotx, fixed_t pivoty) // ys[4] = rmax_y; // else if (ys[4] < rmin_y) // ys[4] = rmin_y; - AM_rotate (&xs[4], &ys[4], ANG270 - players[consoleplayer].camera->_f_angle()); + AM_rotate (&xs[4], &ys[4], 270. - players[consoleplayer].camera->Angles.Yaw); m_x = xs[4] + pivotx - m_w/2; m_y = ys[4] + pivoty - m_h/2; #endif @@ -1165,10 +1138,10 @@ static void AM_ClipRotatedExtents (fixed_t pivotx, fixed_t pivoty) // //============================================================================= -static void AM_ScrollParchment (fixed_t dmapx, fixed_t dmapy) +static void AM_ScrollParchment (double dmapx, double dmapy) { - mapxstart -= MulScale12 (dmapx, scale_mtof); - mapystart -= MulScale12 (dmapy, scale_mtof); + mapxstart = mapxstart - dmapx * scale_mtof; + mapystart = mapystart - dmapy * scale_mtof; if (mapback.isValid()) { @@ -1176,8 +1149,8 @@ static void AM_ScrollParchment (fixed_t dmapx, fixed_t dmapy) if (backtex != NULL) { - int pwidth = backtex->GetWidth() << MAPBITS; - int pheight = backtex->GetHeight() << MAPBITS; + int pwidth = backtex->GetWidth(); + int pheight = backtex->GetHeight(); while(mapxstart > 0) mapxstart -= pwidth; @@ -1199,23 +1172,23 @@ static void AM_ScrollParchment (fixed_t dmapx, fixed_t dmapy) void AM_changeWindowLoc () { - if (0 != (m_paninc.x | m_paninc.y)) + if (m_paninc.x || m_paninc.y) { am_followplayer = false; f_oldloc.x = FIXED_MAX; } - int oldmx = m_x, oldmy = m_y; - fixed_t incx, incy, oincx, oincy; + double oldmx = m_x, oldmy = m_y; + double incx, incy, oincx, oincy; incx = m_paninc.x; incy = m_paninc.y; - oincx = incx = Scale(m_paninc.x, SCREENWIDTH, 320); - oincy = incy = Scale(m_paninc.y, SCREENHEIGHT, 200); + oincx = incx = m_paninc.x * SCREENWIDTH / 320; + oincy = incy = m_paninc.y * SCREENHEIGHT / 200; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - AM_rotate(&incx, &incy, players[consoleplayer].camera->_f_angle() - ANG90); + AM_rotate(&incx, &incy, players[consoleplayer].camera->Angles.Yaw - 90.); } m_x += incx; @@ -1251,7 +1224,7 @@ void AM_initVariables () amclock = 0; m_paninc.x = m_paninc.y = 0; - mtof_zoommul = MAPUNIT; + mtof_zoommul = 1.; m_w = FTOM(SCREENWIDTH); m_h = FTOM(SCREENHEIGHT); @@ -1262,8 +1235,8 @@ void AM_initVariables () if (playeringame[pnum]) break; assert(pnum >= 0 && pnum < MAXPLAYERS); - m_x = (players[pnum].camera->_f_X() >> FRACTOMAPBITS) - m_w/2; - m_y = (players[pnum].camera->_f_Y() >> FRACTOMAPBITS) - m_h/2; + m_x = players[pnum].camera->X() - m_w/2; + m_y = players[pnum].camera->Y() - m_h/2; AM_changeWindowLoc(); // for saving & restoring @@ -1355,10 +1328,10 @@ void AM_LevelInit () AM_clearMarks(); AM_findMinMaxBoundaries(); - scale_mtof = MapDiv(min_scale_mtof, (int) (0.7*MAPUNIT)); + scale_mtof = min_scale_mtof / 0.7; if (scale_mtof > max_scale_mtof) scale_mtof = min_scale_mtof; - scale_ftom = MapDiv(MAPUNIT, scale_mtof); + scale_ftom = 1 / scale_mtof; am_showalllines.Callback(); } @@ -1401,7 +1374,7 @@ void AM_Start () void AM_minOutWindowScale () { scale_mtof = min_scale_mtof; - scale_ftom = MapDiv(MAPUNIT, scale_mtof); + scale_ftom = 1/ scale_mtof; } //============================================================================= @@ -1413,7 +1386,7 @@ void AM_minOutWindowScale () void AM_maxOutWindowScale () { scale_mtof = max_scale_mtof; - scale_ftom = MapDiv(MAPUNIT, scale_mtof); + scale_ftom = 1 / scale_mtof; } //============================================================================= @@ -1424,15 +1397,15 @@ void AM_maxOutWindowScale () void AM_NewResolution() { - fixed_t oldmin = min_scale_mtof; + double oldmin = min_scale_mtof; if ( oldmin == 0 ) { return; // [SP] Not in a game, exit! } AM_calcMinMaxMtoF(); - scale_mtof = Scale(scale_mtof, min_scale_mtof, oldmin); - scale_ftom = MapDiv(MAPUNIT, scale_mtof); + scale_mtof = scale_mtof * min_scale_mtof / oldmin; + scale_ftom = 1 / scale_mtof; if (scale_mtof < min_scale_mtof) AM_minOutWindowScale(); else if (scale_mtof > max_scale_mtof) @@ -1531,33 +1504,33 @@ bool AM_Responder (event_t *ev, bool last) void AM_changeWindowScale () { - int mtof_zoommul; + double mtof_zoommul; if (am_zoomdir > 0) { - mtof_zoommul = int(M_ZOOMIN * am_zoomdir); + mtof_zoommul = M_ZOOMIN * am_zoomdir; } else if (am_zoomdir < 0) { - mtof_zoommul = int(M_ZOOMOUT / -am_zoomdir); + mtof_zoommul = M_ZOOMOUT / -am_zoomdir; } else if (Button_AM_ZoomIn.bDown) { - mtof_zoommul = int(M_ZOOMIN); + mtof_zoommul = M_ZOOMIN; } else if (Button_AM_ZoomOut.bDown) { - mtof_zoommul = int(M_ZOOMOUT); + mtof_zoommul = M_ZOOMOUT; } else { - mtof_zoommul = MAPUNIT; + mtof_zoommul = 1; } am_zoomdir = 0; // Change the scaling multipliers - scale_mtof = MapMul(scale_mtof, mtof_zoommul); - scale_ftom = MapDiv(MAPUNIT, scale_mtof); + scale_mtof = scale_mtof * mtof_zoommul; + scale_ftom = 1 / scale_mtof; if (scale_mtof < min_scale_mtof) AM_minOutWindowScale(); @@ -1569,7 +1542,7 @@ CCMD(am_zoom) { if (argv.argc() >= 2) { - am_zoomdir = (float)atof(argv[1]); + am_zoomdir = atof(argv[1]); } } @@ -1581,28 +1554,28 @@ CCMD(am_zoom) void AM_doFollowPlayer () { - fixed_t sx, sy; + double sx, sy; if (players[consoleplayer].camera != NULL && - (f_oldloc.x != players[consoleplayer].camera->_f_X() || - f_oldloc.y != players[consoleplayer].camera->_f_Y())) + (f_oldloc.x != players[consoleplayer].camera->X() || + f_oldloc.y != players[consoleplayer].camera->Y())) { - m_x = (players[consoleplayer].camera->_f_X() >> FRACTOMAPBITS) - m_w/2; - m_y = (players[consoleplayer].camera->_f_Y() >> FRACTOMAPBITS) - m_h/2; + m_x = players[consoleplayer].camera->X() - m_w/2; + m_y = players[consoleplayer].camera->Y() - m_h/2; m_x2 = m_x + m_w; m_y2 = m_y + m_h; // do the parallax parchment scrolling. - sx = (players[consoleplayer].camera->_f_X() - f_oldloc.x) >> FRACTOMAPBITS; - sy = (f_oldloc.y - players[consoleplayer].camera->_f_Y()) >> FRACTOMAPBITS; + sx = (players[consoleplayer].camera->X() - f_oldloc.x); + sy = (f_oldloc.y - players[consoleplayer].camera->Y()); if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - AM_rotate (&sx, &sy, players[consoleplayer].camera->_f_angle() - ANG90); + AM_rotate (&sx, &sy, players[consoleplayer].camera->Angles.Yaw - 90); } AM_ScrollParchment (sx, sy); - f_oldloc.x = players[consoleplayer].camera->_f_X(); - f_oldloc.y = players[consoleplayer].camera->_f_Y(); + f_oldloc.x = players[consoleplayer].camera->X(); + f_oldloc.y = players[consoleplayer].camera->Y(); } } @@ -1674,9 +1647,9 @@ void AM_clearFB (const AMColor &color) int x, y; //blit the automap background to the screen. - for (y = mapystart >> MAPBITS; y < f_h; y += pheight) + for (y = int(mapystart); y < f_h; y += pheight) { - for (x = mapxstart >> MAPBITS; x < f_w; x += pwidth) + for (x = int(mapxstart); x < f_w; x += pwidth) { screen->DrawTexture (backtex, x, y, DTA_ClipBottom, f_h, DTA_TopOffset, 0, DTA_LeftOffset, 0, TAG_DONE); } @@ -1846,15 +1819,15 @@ inline void AM_drawMline (mline_t *ml, int colorindex) void AM_drawGrid (int color) { - fixed_t x, y; - fixed_t start, end; + double x, y; + double start, end; mline_t ml; - fixed_t minlen, extx, exty; - fixed_t minx, miny; + double minlen, extx, exty; + double minx, miny; // [RH] Calculate a minimum for how long the grid lines should be so that // they cover the screen at any rotation. - minlen = (fixed_t)sqrt ((double)m_w*(double)m_w + (double)m_h*(double)m_h); + minlen = sqrt (m_w*m_w + m_h*m_h); extx = (minlen - m_w) / 2; exty = (minlen - m_h) / 2; @@ -1863,13 +1836,13 @@ void AM_drawGrid (int color) // Figure out start of vertical gridlines start = minx - extx; - if ((start-bmaporgx)%(MAPBLOCKUNITS< points; - float scale = float(scale_mtof); - angle_t rotation; + double scale = scale_mtof; + DAngle rotation; sector_t tempsec; int floorlight, ceilinglight; - fixed_t scalex, scaley; + double scalex, scaley; double originx, originy; FDynamicColormap *colormap; mpoint_t originpt; @@ -1945,28 +1917,28 @@ void AM_drawSubsectors() points.Resize(subsectors[i].numlines); for (DWORD j = 0; j < subsectors[i].numlines; ++j) { - mpoint_t pt = { subsectors[i].firstline[j].v1->x >> FRACTOMAPBITS, - subsectors[i].firstline[j].v1->y >> FRACTOMAPBITS }; + mpoint_t pt = { subsectors[i].firstline[j].v1->fX(), + subsectors[i].firstline[j].v1->fY() }; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { AM_rotatePoint(&pt.x, &pt.y); } - points[j].X = f_x + ((pt.x - m_x) * scale / float(1 << 24)); - points[j].Y = f_y + (f_h - (pt.y - m_y) * scale / float(1 << 24)); + points[j].X = float(f_x + ((pt.x - m_x) * scale)); + points[j].Y = float(f_y + (f_h - (pt.y - m_y) * scale)); } // For lighting and texture determination sector_t *sec = Renderer->FakeFlat (subsectors[i].render_sector, &tempsec, &floorlight, &ceilinglight, false); // Find texture origin. - originpt.x = -sec->GetXOffset(sector_t::floor) >> FRACTOMAPBITS; - originpt.y = sec->GetYOffset(sector_t::floor) >> FRACTOMAPBITS; - rotation = 0 - sec->GetAngle(sector_t::floor); + originpt.x = -sec->GetXOffsetF(sector_t::floor); + originpt.y = sec->GetYOffset(sector_t::floor); + rotation = -sec->GetAngleF(sector_t::floor); // Coloring for the polygon colormap = sec->ColorMap; FTextureID maptex = sec->GetTexture(sector_t::floor); - scalex = sec->GetXScale(sector_t::floor); - scaley = sec->GetYScale(sector_t::floor); + scalex = sec->GetXScaleF(sector_t::floor); + scaley = sec->GetYScaleF(sector_t::floor); if (sec->e->XFloor.ffloors.Size()) { @@ -2015,11 +1987,11 @@ void AM_drawSubsectors() floorplane = rover->top.plane; sector_t *model = rover->top.model; int selector = (rover->flags & FF_INVERTPLANES) ? sector_t::floor : sector_t::ceiling; - rotation = 0 - model->GetAngle(selector); - scalex = model->GetXScale(selector); - scaley = model->GetYScale(selector); - originpt.x = -model->GetXOffset(selector) >> FRACTOMAPBITS; - originpt.y = model->GetYOffset(selector) >> FRACTOMAPBITS; + rotation = -model->GetAngleF(selector); + scalex = model->GetXScaleF(selector); + scaley = model->GetYScaleF(selector); + originpt.x = -model->GetXOffsetF(selector); + originpt.y = model->GetYOffsetF(selector); break; } } @@ -2041,11 +2013,11 @@ void AM_drawSubsectors() // Apply the automap's rotation to the texture origin. if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - rotation += ANG90 - players[consoleplayer].camera->_f_angle(); + rotation = rotation + 90. - players[consoleplayer].camera->Angles.Yaw; AM_rotatePoint(&originpt.x, &originpt.y); } - originx = f_x + ((originpt.x - m_x) * scale / float(1 << 24)); - originy = f_y + (f_h - (originpt.y - m_y) * scale / float(1 << 24)); + originx = f_x + ((originpt.x - m_x) * scale); + originy = f_y + (f_h - (originpt.y - m_y) * scale); // If this subsector has not actually been seen yet (because you are cheating // to see it on the map), tint and desaturate it. @@ -2068,9 +2040,9 @@ void AM_drawSubsectors() screen->FillSimplePoly(TexMan(maptex), &points[0], points.Size(), originx, originy, - scale / (FIXED2DBL(scalex) * float(1 << MAPBITS)), - scale / (FIXED2DBL(scaley) * float(1 << MAPBITS)), - ANGLE2DBL(rotation), + scale / scalex, + scale / scaley, + rotation, colormap, floorlight ); @@ -2118,10 +2090,10 @@ static bool AM_CheckSecret(line_t *line) void AM_drawSeg(seg_t *seg, const AMColor &color) { mline_t l; - l.a.x = seg->v1->x >> FRACTOMAPBITS; - l.a.y = seg->v1->y >> FRACTOMAPBITS; - l.b.x = seg->v2->x >> FRACTOMAPBITS; - l.b.y = seg->v2->y >> FRACTOMAPBITS; + l.a.x = seg->v1->fX(); + l.a.y = seg->v1->fY(); + l.b.x = seg->v2->fX(); + l.b.y = seg->v2->fY(); if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { @@ -2134,10 +2106,10 @@ void AM_drawSeg(seg_t *seg, const AMColor &color) void AM_drawPolySeg(FPolySeg *seg, const AMColor &color) { mline_t l; - l.a.x = seg->v1.x >> FRACTOMAPBITS; - l.a.y = seg->v1.y >> FRACTOMAPBITS; - l.b.x = seg->v2.x >> FRACTOMAPBITS; - l.b.y = seg->v2.y >> FRACTOMAPBITS; + l.a.x = seg->v1.x; + l.a.y = seg->v1.y; + l.b.x = seg->v2.x; + l.b.y = seg->v2.y; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { @@ -2419,17 +2391,17 @@ void AM_drawWalls (bool allmap) if (lines[i].sidedef[0]->Flags & WALLF_POLYOBJ) { // For polyobjects we must test the surrounding sector to get the proper group. - pg = P_PointInSector(lines[i].v1->x + lines[i].dx / 2, lines[i].v1->y + lines[i].dy / 2)->PortalGroup; + pg = P_PointInSector(lines[i].v1->fX() + lines[i].Delta().X / 2, lines[i].v1->fY() + lines[i].Delta().Y / 2)->PortalGroup; } else { pg = lines[i].frontsector->PortalGroup; } - fixedvec2 offset; + DVector2 offset; bool portalmode = numportalgroups > 0 && pg != MapPortalGroup; if (pg == p) { - offset = Displacements._f_getOffset(pg, MapPortalGroup); + offset = Displacements.getOffset(pg, MapPortalGroup); } else if (p == -1 && (pg == MapPortalGroup || !am_portaloverlay)) { @@ -2437,10 +2409,10 @@ void AM_drawWalls (bool allmap) } else continue; - l.a.x = (lines[i].v1->x + offset.x) >> FRACTOMAPBITS; - l.a.y = (lines[i].v1->y + offset.y) >> FRACTOMAPBITS; - l.b.x = (lines[i].v2->x + offset.x) >> FRACTOMAPBITS; - l.b.y = (lines[i].v2->y + offset.y) >> FRACTOMAPBITS; + l.a.x = (lines[i].v1->fX() + offset.X); + l.a.y = (lines[i].v1->fY() + offset.Y); + l.b.x = (lines[i].v2->fX() + offset.X); + l.b.y = (lines[i].v2->fY() + offset.Y); if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { @@ -2552,27 +2524,26 @@ void AM_drawWalls (bool allmap) // //============================================================================= -void AM_rotate(fixed_t *xp, fixed_t *yp, angle_t a) +void AM_rotate(double *xp, double *yp, DAngle a) { - static angle_t angle_saved = 0; + static DAngle angle_saved = 0.; static double sinrot = 0; static double cosrot = 1; if (angle_saved != a) { angle_saved = a; - double rot = (double)a / (double)(1u << 31) * (double)M_PI; - sinrot = sin(rot); - cosrot = cos(rot); + sinrot = sin(ToRadians(a)); + cosrot = cos(ToRadians(a)); } - double x = FIXED2DBL(*xp); - double y = FIXED2DBL(*yp); + double x = *xp; + double y = *yp; double tmpx = (x * cosrot) - (y * sinrot); y = (x * sinrot) + (y * cosrot); x = tmpx; - *xp = FLOAT2FIXED(x); - *yp = FLOAT2FIXED(y); + *xp = x; + *yp = y; } //============================================================================= @@ -2581,13 +2552,13 @@ void AM_rotate(fixed_t *xp, fixed_t *yp, angle_t a) // //============================================================================= -void AM_rotatePoint (fixed_t *x, fixed_t *y) +void AM_rotatePoint (double *x, double *y) { - fixed_t pivotx = m_x + m_w/2; - fixed_t pivoty = m_y + m_h/2; + double pivotx = m_x + m_w/2; + double pivoty = m_y + m_h/2; *x -= pivotx; *y -= pivoty; - AM_rotate (x, y, ANG90 - players[consoleplayer].camera->_f_angle()); + AM_rotate (x, y, -players[consoleplayer].camera->Angles.Yaw - 90.); *x += pivotx; *y += pivoty; } @@ -2602,11 +2573,11 @@ void AM_drawLineCharacter ( const mline_t *lineguy, int lineguylines, - fixed_t scale, - angle_t angle, + double scale, + DAngle angle, const AMColor &color, - fixed_t x, - fixed_t y ) + double x, + double y ) { int i; mline_t l; @@ -2616,11 +2587,11 @@ AM_drawLineCharacter l.a.y = lineguy[i].a.y; if (scale) { - l.a.x = MapMul(scale, l.a.x); - l.a.y = MapMul(scale, l.a.y); + l.a.x *= scale; + l.a.y *= scale; } - if (angle) + if (angle != 0) AM_rotate(&l.a.x, &l.a.y, angle); l.a.x += x; @@ -2630,11 +2601,11 @@ AM_drawLineCharacter l.b.y = lineguy[i].b.y; if (scale) { - l.b.x = MapMul(scale, l.b.x); - l.b.y = MapMul(scale, l.b.y); + l.b.x *= scale; + l.b.y *= scale; } - if (angle) + if (angle != 0) AM_rotate(&l.b.x, &l.b.y, angle); l.b.x += x; @@ -2659,7 +2630,7 @@ void AM_drawPlayers () } mpoint_t pt; - angle_t angle; + DAngle angle; int i; if (!multiplayer) @@ -2667,18 +2638,18 @@ void AM_drawPlayers () mline_t *arrow; int numarrowlines; - fixed_t vh = FLOAT2FIXED(players[consoleplayer].viewheight); - fixedvec2 pos = am_portaloverlay? players[consoleplayer].camera->GetPortalTransition(vh) : (fixedvec2)players[consoleplayer].camera->_f_Pos(); - pt.x = pos.x >> FRACTOMAPBITS; - pt.y = pos.y >> FRACTOMAPBITS; + double vh = players[consoleplayer].viewheight; + DVector2 pos = am_portaloverlay? players[consoleplayer].camera->GetPortalTransition(vh) : players[consoleplayer].camera->Pos(); + pt.x = pos.X; + pt.y = pos.Y; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - angle = ANG90; + angle = 90.; AM_rotatePoint (&pt.x, &pt.y); } else { - angle = players[consoleplayer].camera->_f_angle(); + angle = players[consoleplayer].camera->Angles.Yaw; } if (am_cheat != 0 && CheatMapArrow.Size() > 0) @@ -2732,16 +2703,16 @@ void AM_drawPlayers () if (p->mo != NULL) { - fixedvec3 pos = p->mo->_f_PosRelative(MapPortalGroup); - pt.x = pos.x >> FRACTOMAPBITS; - pt.y = pos.y >> FRACTOMAPBITS; + DVector3 pos = p->mo->PosRelative(MapPortalGroup); + pt.x = pos.X; + pt.y = pos.Y; - angle = p->mo->_f_angle(); + angle = p->mo->Angles.Yaw; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { AM_rotatePoint (&pt.x, &pt.y); - angle -= players[consoleplayer].camera->_f_angle() - ANG90; + angle -= players[consoleplayer].camera->Angles.Yaw - 90.; } AM_drawLineCharacter(&MapArrow[0], MapArrow.Size(), 0, angle, color, pt.x, pt.y); @@ -2759,23 +2730,23 @@ void AM_drawKeys () { AMColor color; mpoint_t p; - angle_t angle; + DAngle angle; TThinkerIterator it; AKey *key; while ((key = it.Next()) != NULL) { - fixedvec3 pos = key->_f_PosRelative(MapPortalGroup); - p.x = pos.x >> FRACTOMAPBITS; - p.y = pos.y >> FRACTOMAPBITS; + DVector3 pos = key->PosRelative(MapPortalGroup); + p.x = pos.X; + p.y = pos.Y; - angle = key->_f_angle(); + angle = key->Angles.Yaw; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { AM_rotatePoint (&p.x, &p.y); - angle += ANG90 - players[consoleplayer].camera->_f_angle(); + angle += -players[consoleplayer].camera->Angles.Yaw + 90.; } if (key->flags & MF_SPECIAL) @@ -2788,7 +2759,7 @@ void AM_drawKeys () if (c >= 0) color.FromRGB(RPART(c), GPART(c), BPART(c)); else color = AMColors[AMColors.ThingColor_CountItem]; - AM_drawLineCharacter(&EasyKey[0], EasyKey.Size(), 0, 0, color, p.x, p.y); + AM_drawLineCharacter(&EasyKey[0], EasyKey.Size(), 0, 0., color, p.x, p.y); } } } @@ -2804,7 +2775,7 @@ void AM_drawThings () int i; AActor* t; mpoint_t p; - angle_t angle; + DAngle angle; for (i=0;i 0 || !(t->flags6 & MF6_NOTONAUTOMAP)) { - fixedvec3 pos = t->_f_PosRelative(MapPortalGroup); - p.x = pos.x >> FRACTOMAPBITS; - p.y = pos.y >> FRACTOMAPBITS; + DVector3 pos = t->PosRelative(MapPortalGroup); + p.x = pos.X; + p.y = pos.Y; if (am_showthingsprites > 0 && t->sprite > 0) { FTexture *texture = NULL; spriteframe_t *frame; - angle_t rotation = 0; + int rotation = 0; // try all modes backwards until a valid texture has been found. for(int show = am_showthingsprites; show > 0 && texture == NULL; show--) @@ -2830,13 +2801,13 @@ void AM_drawThings () const size_t spriteIndex = sprite.spriteframes + (show > 1 ? t->frame : 0); frame = &SpriteFrames[spriteIndex]; - angle_t angle = ANGLE_270 - t->_f_angle(); - if (frame->Texture[0] != frame->Texture[1]) angle += (ANGLE_180 / 16); + DAngle angle = -t->Angles.Yaw + 270.; + if (frame->Texture[0] != frame->Texture[1]) angle += 180. / 16; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { - angle += players[consoleplayer].camera->_f_angle() - ANGLE_90; + angle += players[consoleplayer].camera->Angles.Yaw - 90.; } - rotation = angle >> 28; + rotation = int((angle.Normalized360() * (16. / 360.)).Degrees); const FTextureID textureID = frame->Texture[show > 2 ? rotation : 0]; texture = TexMan(textureID); @@ -2844,8 +2815,8 @@ void AM_drawThings () if (texture == NULL) goto drawTriangle; // fall back to standard display if no sprite can be found. - const fixed_t spriteXScale = fixed_t(t->Scale.X * 10 * scale_mtof); - const fixed_t spriteYScale = fixed_t(t->Scale.Y * 10 * scale_mtof); + const double spriteXScale = (t->Scale.X * 10 * scale_mtof); + const double spriteYScale = (t->Scale.Y * 10 * scale_mtof); DrawMarker (texture, p.x, p.y, 0, !!(frame->Flip & (1 << rotation)), spriteXScale, spriteYScale, t->Translation, 1., 0, LegacyRenderStyles[STYLE_Normal]); @@ -2853,12 +2824,12 @@ void AM_drawThings () else { drawTriangle: - angle = t->_f_angle(); + angle = t->Angles.Yaw; if (am_rotate == 1 || (am_rotate == 2 && viewactive)) { AM_rotatePoint (&p.x, &p.y); - angle += ANG90 - players[consoleplayer].camera->_f_angle(); + angle += -players[consoleplayer].camera->Angles.Yaw + 90.; } color = AMColors[AMColors.ThingColor]; @@ -2889,7 +2860,7 @@ void AM_drawThings () if (c >= 0) color.FromRGB(RPART(c), GPART(c), BPART(c)); else color = AMColors[AMColors.ThingColor_CountItem]; - AM_drawLineCharacter(&CheatKey[0], CheatKey.Size(), 0, 0, color, p.x, p.y); + AM_drawLineCharacter(&CheatKey[0], CheatKey.Size(), 0, 0., color, p.x, p.y); color.Index = -1; } else @@ -2905,22 +2876,20 @@ void AM_drawThings () if (color.Index != -1) { - AM_drawLineCharacter - (thintriangle_guy, NUMTHINTRIANGLEGUYLINES, - 16<_f_radius() >> FRACTOMAPBITS, angle - t->_f_angle(), color, p.x, p.y); + AM_drawLineCharacter (box, 4, t->radius, angle - t->Angles.Yaw, color, p.x, p.y); } } } @@ -2935,8 +2904,8 @@ void AM_drawThings () // //============================================================================= -static void DrawMarker (FTexture *tex, fixed_t x, fixed_t y, int yadjust, - INTBOOL flip, fixed_t xscale, fixed_t yscale, int translation, double alpha, DWORD fillcolor, FRenderStyle renderstyle) +static void DrawMarker (FTexture *tex, double x, double y, int yadjust, + INTBOOL flip, double xscale, double yscale, int translation, double alpha, DWORD fillcolor, FRenderStyle renderstyle) { if (tex == NULL || tex->UseType == FTexture::TEX_Null) { @@ -2947,8 +2916,8 @@ static void DrawMarker (FTexture *tex, fixed_t x, fixed_t y, int yadjust, AM_rotatePoint (&x, &y); } screen->DrawTexture (tex, CXMTOF(x) + f_x, CYMTOF(y) + yadjust + f_y, - DTA_DestWidth, MulScale16 (tex->GetScaledWidth() * CleanXfac, xscale), - DTA_DestHeight, MulScale16 (tex->GetScaledHeight() * CleanYfac, yscale), + DTA_DestWidthF, tex->GetScaledWidthDouble() * CleanXfac * xscale / 16, + DTA_DestHeightF, tex->GetScaledHeightDouble() * CleanYfac * yscale / 16, DTA_ClipTop, f_y, DTA_ClipBottom, f_y + f_h, DTA_ClipLeft, f_x, @@ -2974,7 +2943,7 @@ void AM_drawMarks () if (markpoints[i].x != -1) { DrawMarker (TexMan(marknums[i]), markpoints[i].x, markpoints[i].y, -3, 0, - FRACUNIT, FRACUNIT, 0, FRACUNIT, 0, LegacyRenderStyles[STYLE_Normal]); + 1, 1, 0, 1, 0, LegacyRenderStyles[STYLE_Normal]); } } } @@ -3041,8 +3010,7 @@ void AM_drawAuthorMarkers () marked->subsector->flags & SSECF_DRAWN : marked->Sector->MoreFlags & SECF_DRAWN))) { - DrawMarker (tex, marked->_f_X() >> FRACTOMAPBITS, marked->_f_Y() >> FRACTOMAPBITS, 0, - flip, FLOAT2FIXED(mark->Scale.X), FLOAT2FIXED(mark->Scale.Y), mark->Translation, + DrawMarker (tex, marked->X(), marked->Y(), 0, flip, mark->Scale.X, mark->Scale.Y, mark->Translation, mark->Alpha, mark->fillcolor, mark->RenderStyle); } marked = mark->args[0] != 0 ? it.Next() : NULL; @@ -3078,7 +3046,7 @@ void AM_Drawer () if (am_portaloverlay) { sector_t *sec; - fixed_t vh = FLOAT2FIXED(players[consoleplayer].viewheight); + double vh = players[consoleplayer].viewheight; players[consoleplayer].camera->GetPortalTransition(vh, &sec); MapPortalGroup = sec->PortalGroup; } diff --git a/src/p_map.cpp b/src/p_map.cpp index b5857dad6..3a2b66500 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -5087,7 +5087,7 @@ void P_UseLines(player_t *player) bool foundline = false; // If the player is transitioning a portal, use the group that is at its vertical center. - fixedvec2 start = player->mo->GetPortalTransition(player->mo->_f_height() / 2); + fixedvec2 start = player->mo->_f_GetPortalTransition(player->mo->_f_height() / 2); // [NS] Now queries the Player's UseRange. fixedvec2 end = start + Vec2Angle(FLOAT2FIXED(player->mo->UseRange), player->mo->_f_angle()); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 478ec3a9e..c10ff482d 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3249,7 +3249,7 @@ void AActor::SetRoll(DAngle r, bool interpolate) } -fixedvec3 AActor::GetPortalTransition(fixed_t byoffset, sector_t **pSec) +fixedvec3 AActor::_f_GetPortalTransition(fixed_t byoffset, sector_t **pSec) { bool moved = false; sector_t *sec = Sector; diff --git a/src/r_defs.h b/src/r_defs.h index 8cadafb93..a183e78af 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -626,6 +626,11 @@ struct sector_t return planes[pos].xform.xoffs; } + double GetXOffsetF(int pos) const + { + return FIXED2DBL(planes[pos].xform.xoffs); + } + void SetYOffset(int pos, fixed_t o) { planes[pos].xform.yoffs = o; @@ -648,6 +653,18 @@ struct sector_t } } + double GetYOffsetF(int pos, bool addbase = true) const + { + if (!addbase) + { + return FIXED2DBL(planes[pos].xform.yoffs); + } + else + { + return FIXED2DBL(planes[pos].xform.yoffs + planes[pos].xform.base_yoffs); + } + } + void SetXScale(int pos, fixed_t o) { planes[pos].xform.xscale = o; @@ -658,6 +675,11 @@ struct sector_t return planes[pos].xform.xscale; } + double GetXScaleF(int pos) const + { + return FIXED2DBL(planes[pos].xform.xscale); + } + void SetYScale(int pos, fixed_t o) { planes[pos].xform.yscale = o; @@ -668,6 +690,11 @@ struct sector_t return planes[pos].xform.yscale; } + double GetYScaleF(int pos) const + { + return FIXED2DBL(planes[pos].xform.yscale); + } + void SetAngle(int pos, angle_t o) { planes[pos].xform.angle = o; @@ -685,6 +712,18 @@ struct sector_t } } + DAngle GetAngleF(int pos, bool addbase = true) const + { + if (!addbase) + { + return ANGLE2DBL(planes[pos].xform.angle); + } + else + { + return ANGLE2DBL(planes[pos].xform.angle + planes[pos].xform.base_angle); + } + } + void SetBase(int pos, fixed_t y, angle_t o) { planes[pos].xform.base_yoffs = y; @@ -1344,6 +1383,11 @@ inline sector_t *P_PointInSector(const DVector2 &pos) return P_PointInSubsector(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y))->sector; } +inline sector_t *P_PointInSector(double X, double Y) +{ + return P_PointInSubsector(FLOAT2FIXED(X), FLOAT2FIXED(Y))->sector; +} + inline fixedvec3 AActor::_f_PosRelative(int portalgroup) const { return _f_Pos() + Displacements._f_getOffset(Sector->PortalGroup, portalgroup); diff --git a/src/s_sound.cpp b/src/s_sound.cpp index e04542a5b..a7e289152 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -724,7 +724,7 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, if ((chanflags & CHAN_LISTENERZ) && players[consoleplayer].camera != NULL) { - y = players[consoleplayer].camera != NULL ? players[consoleplayer].camera->SoundZ() : 0; + y = players[consoleplayer].camera != NULL ? FLOAT2FIXED(players[consoleplayer].camera->SoundPos().Z) : 0; } pos->X = FIXED2FLOAT(x); pos->Y = FIXED2FLOAT(y); @@ -1952,7 +1952,7 @@ static void S_SetListener(SoundListener &listener, AActor *listenactor) { if (listenactor != NULL) { - listener.angle = ToRadians(listenactor->Angles.Yaw); + listener.angle = (float)ToRadians(listenactor->Angles.Yaw); /* listener.velocity.X = listenactor->vel.x * (TICRATE/65536.f); listener.velocity.Y = listenactor->vel.z * (TICRATE/65536.f); From e42b0171b31337f1f73d5e8f397e6fb9dd50efab Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Mar 2016 00:34:56 +0100 Subject: [PATCH 09/44] - floatification of bot code. --- src/actor.h | 35 +++++--------- src/am_map.cpp | 10 ++-- src/b_bot.cpp | 23 ++------- src/b_bot.h | 35 +++++++------- src/b_func.cpp | 122 +++++++++++++++++++++++------------------------ src/b_move.cpp | 62 ++++++++++++------------ src/b_think.cpp | 30 ++++++------ src/doomdef.h | 2 +- src/p_enemy.cpp | 13 ++--- src/p_enemy.h | 2 +- src/p_local.h | 6 ++- src/p_map.cpp | 26 +++++----- src/p_maputl.cpp | 5 ++ src/p_maputl.h | 19 +++++++- src/p_mobj.cpp | 7 ++- src/p_user.cpp | 31 ------------ src/portal.cpp | 2 +- 17 files changed, 198 insertions(+), 232 deletions(-) diff --git a/src/actor.h b/src/actor.h index e0043aaa2..dc7013865 100644 --- a/src/actor.h +++ b/src/actor.h @@ -828,16 +828,6 @@ public: return P_AproxDistance(_f_X() - otherx, _f_Y() - othery); } - fixed_t __f_AngleTo(fixed_t otherx, fixed_t othery) - { - return R_PointToAngle2(_f_X(), _f_Y(), otherx, othery); - } - - fixed_t __f_AngleTo(fixedvec2 other) - { - return R_PointToAngle2(_f_X(), _f_Y(), other.x, other.y); - } - // 'absolute' is reserved for a linked portal implementation which needs // to distinguish between portal-aware and portal-unaware distance calculation. fixed_t AproxDistance(AActor *other, bool absolute = false) @@ -846,13 +836,14 @@ public: return P_AproxDistance(_f_X() - otherpos.x, _f_Y() - otherpos.y); } + /* fixed_t AproxDistance(AActor *other, fixed_t xadd, fixed_t yadd, bool absolute = false) { fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this); return P_AproxDistance(_f_X() - otherpos.x + xadd, _f_Y() - otherpos.y + yadd); } + */ - // more precise, but slower version, being used in a few places double Distance2D(AActor *other, bool absolute = false) { DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this); @@ -864,6 +855,13 @@ public: return DVector2(X() - x, Y() - y).Length(); } + double Distance2D(AActor *other, double xadd, double yadd, bool absolute = false) + { + DVector3 otherpos = absolute ? other->Pos() : other->PosRelative(this); + return DVector2(X() - otherpos.X + xadd, Y() - otherpos.Y + yadd).Length(); + } + + // a full 3D version of the above double Distance3D(AActor *other, bool absolute = false) { @@ -871,17 +869,6 @@ public: return (Pos() - otherpos).Length(); } - angle_t __f_AngleTo(AActor *other, bool absolute = false) - { - fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this); - return R_PointToAngle2(_f_X(), _f_Y(), otherpos.x, otherpos.y); - } - - angle_t __f_AngleTo(AActor *other, fixed_t oxofs, fixed_t oyofs, bool absolute = false) const - { - return R_PointToAngle2(_f_X(), _f_Y(), other->_f_X() + oxofs, other->_f_Y() + oyofs); - } - DAngle AngleTo(AActor *other, bool absolute = false) { DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this); @@ -1064,6 +1051,10 @@ public: SetOrigin(npos.x, npos.y, npos.z, moving); } + void Move(const DVector3 &vel) + { + SetOrigin(Pos() + vel, true); + } void SetOrigin(double x, double y, double z, bool moving) { SetOrigin(FLOAT2FIXED(x), FLOAT2FIXED(y), FLOAT2FIXED(z), moving); diff --git a/src/am_map.cpp b/src/am_map.cpp index ca1d3fc2b..1189ec3a7 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -815,7 +815,7 @@ CVAR(Bool, am_portaloverlay, true, CVAR_ARCHIVE) CCMD(am_togglefollow) { am_followplayer = !am_followplayer; - f_oldloc.x = FIXED_MAX; + f_oldloc.x = FLT_MAX; Printf ("%s\n", GStrings(am_followplayer ? "AMSTR_FOLLOWON" : "AMSTR_FOLLOWOFF")); } @@ -1022,7 +1022,7 @@ bool AM_addMark () static void AM_findMinMaxBoundaries () { - min_x = min_y = FIXED_MAX; + min_x = min_y = FLT_MAX; max_x = max_y = FIXED_MIN; for (int i = 0; i < numvertexes; i++) @@ -1094,7 +1094,7 @@ static void AM_ClipRotatedExtents (double pivotx, double pivoty) xs[2] = max_x; ys[2] = max_y; xs[3] = min_x; ys[3] = max_y; xs[4] = m_x + m_w/2; ys[4] = m_y + m_h/2; - rmin_x = rmin_y = FIXED_MAX; + rmin_x = rmin_y = FLT_MAX; rmax_x = rmax_y = FIXED_MIN; for (i = 0; i < 5; ++i) @@ -1175,7 +1175,7 @@ void AM_changeWindowLoc () if (m_paninc.x || m_paninc.y) { am_followplayer = false; - f_oldloc.x = FIXED_MAX; + f_oldloc.x = FLT_MAX; } double oldmx = m_x, oldmy = m_y; @@ -1220,7 +1220,7 @@ void AM_initVariables () Button_AM_ZoomOut.Reset(); - f_oldloc.x = FIXED_MAX; + f_oldloc.x = FLT_MAX; amclock = 0; m_paninc.x = m_paninc.y = 0; diff --git a/src/b_bot.cpp b/src/b_bot.cpp index 3d6c916c6..a4160b92c 100644 --- a/src/b_bot.cpp +++ b/src/b_bot.cpp @@ -33,7 +33,7 @@ DBot::DBot () void DBot::Clear () { player = NULL; - angle = 0; + Angle = 0.; dest = NULL; prev = NULL; enemy = NULL; @@ -52,27 +52,15 @@ void DBot::Clear () sleft = false; allround = false; increase = false; - oldx = 0; - oldy = 0; + old = { 0, 0 }; } void DBot::Serialize (FArchive &arc) { Super::Serialize (arc); - if (SaveVersion < 4515) - { - angle_t savedyaw; - int savedpitch; - arc << savedyaw - << savedpitch; - } - else - { - arc << player; - } - - arc << angle + arc << player + << Angle << dest << prev << enemy @@ -91,8 +79,7 @@ void DBot::Serialize (FArchive &arc) << sleft << allround << increase - << oldx - << oldy; + << old; } void DBot::Tick () diff --git a/src/b_bot.h b/src/b_bot.h index 5b8e48c8f..e56b03f00 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -31,18 +31,18 @@ #define BOTFILENAME "bots.cfg" -#define MAX_TRAVERSE_DIST 100000000 //10 meters, used within b_func.c -#define AVOID_DIST 45000000 //Try avoid incoming missiles once they reached this close -#define SAFE_SELF_MISDIST (140*FRACUNIT) //Distance from self to target where it's safe to pull a rocket. -#define FRIEND_DIST 15000000 //To friend. -#define DARK_DIST 5000000 //Distance that bot can see enemies in the dark from. +#define MAX_TRAVERSE_DIST (100000000/65536.) //10 meters, used within b_func.c +#define AVOID_DIST (45000000/65536.) //Try avoid incoming missiles once they reached this close +#define SAFE_SELF_MISDIST (140.) //Distance from self to target where it's safe to pull a rocket. +#define FRIEND_DIST (15000000/65536.) //To friend. +#define DARK_DIST (5000000/65536.) //Distance that bot can see enemies in the dark from. #define WHATS_DARK 50 //light value thats classed as dark. -#define MAX_MONSTER_TARGET_DIST 50000000 //Too high can slow down the performance, see P_mobj.c -#define ENEMY_SCAN_FOV (120*ANGLE_1) +#define MAX_MONSTER_TARGET_DIST (50000000/65536.) //Too high can slow down the performance, see P_mobj.c +#define ENEMY_SCAN_FOV (120.) #define THINGTRYTICK 1000 -#define MAXMOVEHEIGHT (32*FRACUNIT) //MAXSTEPMOVE but with jumping counted in. -#define GETINCOMBAT 35000000 //Max distance to item. if it's due to be icked up in a combat situation. -#define SHOOTFOV (60*ANGLE_1) +#define MAXMOVEHEIGHT (32) //MAXSTEPMOVE but with jumping counted in. +#define GETINCOMBAT (35000000/65536.) //Max distance to item. if it's due to be icked up in a combat situation. +#define SHOOTFOV (60.) #define AFTERTICS (2*TICRATE) //Seconds that bot will be alert on an recent enemy. Ie not looking the other way #define MAXROAM (4*TICRATE) //When this time is elapsed the bot will roam after something else. //monster mod @@ -104,11 +104,11 @@ public: void FinishTravel (); bool IsLeader (player_t *player); void SetBodyAt (const DVector3 &pos, int hostnum); - fixed_t FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd); - bool SafeCheckPosition (AActor *actor, fixed_t x, fixed_t y, FCheckPosition &tm); + double FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd); + bool SafeCheckPosition (AActor *actor, double x, double y, FCheckPosition &tm); //(b_move.cpp) - bool CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cmd); + bool CleanAhead (AActor *thing, double x, double y, ticcmd_t *cmd); bool IsDangerous (sector_t *sec); TArray getspawned; //Array of bots (their names) which should be spawned when starting a game. @@ -149,10 +149,10 @@ public: void WhatToGet (AActor *item); //(b_func.cpp) - bool Check_LOS (AActor *to, angle_t vangle); + bool Check_LOS (AActor *to, DAngle vangle); player_t *player; - angle_t angle; // The wanted angle that the bot try to get every tic. + DAngle Angle; // The wanted angle that the bot try to get every tic. // (used to get a smooth view movement) TObjPtr dest; // Move Destination. TObjPtr prev; // Previous move destination. @@ -183,8 +183,7 @@ public: bool allround; bool increase; - fixed_t oldx; - fixed_t oldy; + DVector2 old; private: //(b_think.cpp) @@ -197,7 +196,7 @@ private: void Dofire (ticcmd_t *cmd); AActor *Choose_Mate (); AActor *Find_enemy (); - angle_t FireRox (AActor *enemy, ticcmd_t *cmd); + DAngle FireRox (AActor *enemy, ticcmd_t *cmd); //(b_move.cpp) void Roam (ticcmd_t *cmd); diff --git a/src/b_func.cpp b/src/b_func.cpp index 803643cea..0e36d93d6 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -34,32 +34,32 @@ bool DBot::Reachable (AActor *rtarget) if (player->mo == rtarget) return false; - if ((rtarget->Sector->ceilingplane.ZatPoint (rtarget) - - rtarget->Sector->floorplane.ZatPoint (rtarget)) - < player->mo->_f_height()) //Where rtarget is, player->mo can't be. + if ((rtarget->Sector->ceilingplane.ZatPointF (rtarget) - + rtarget->Sector->floorplane.ZatPointF (rtarget)) + < player->mo->Height) //Where rtarget is, player->mo can't be. return false; sector_t *last_s = player->mo->Sector; - fixed_t last_z = last_s->floorplane.ZatPoint (player->mo); - fixed_t estimated_dist = player->mo->AproxDistance(rtarget); + double last_z = last_s->floorplane.ZatPointF (player->mo); + double estimated_dist = player->mo->Distance2D(rtarget); bool reachable = true; - FPathTraverse it(player->mo->_f_X()+player->mo->_f_velx(), player->mo->_f_Y()+player->mo->_f_vely(), rtarget->_f_X(), rtarget->_f_Y(), PT_ADDLINES|PT_ADDTHINGS); + FPathTraverse it(player->mo->X()+player->mo->Vel.X, player->mo->Y()+player->mo->Vel.Y, rtarget->X(), rtarget->Y(), PT_ADDLINES|PT_ADDTHINGS); intercept_t *in; while ((in = it.Next())) { - fixed_t hitx, hity; - fixed_t frac; + double hitx, hity; + double frac; line_t *line; AActor *thing; - fixed_t dist; + double dist; sector_t *s; - frac = in->frac - FixedDiv (4*FRACUNIT, MAX_TRAVERSE_DIST); - dist = FixedMul (frac, MAX_TRAVERSE_DIST); + frac = in->Frac - 4 /MAX_TRAVERSE_DIST; + dist = frac * MAX_TRAVERSE_DIST; - hitx = it.Trace().x + FixedMul (player->mo->_f_velx(), frac); - hity = it.Trace().y + FixedMul (player->mo->_f_vely(), frac); + hitx = it.Trace().x + player->mo->Vel.X * frac; + hity = it.Trace().y + player->mo->Vel.Y * frac; if (in->isaline) { @@ -73,13 +73,13 @@ bool DBot::Reachable (AActor *rtarget) { //Determine if going to use backsector/frontsector. s = (line->backsector == last_s) ? line->frontsector : line->backsector; - fixed_t ceilingheight = s->ceilingplane.ZatPoint (hitx, hity); - fixed_t floorheight = s->floorplane.ZatPoint (hitx, hity); + double ceilingheight = s->ceilingplane.ZatPoint (hitx, hity); + double floorheight = s->floorplane.ZatPoint (hitx, hity); if (!bglobal.IsDangerous (s) && //Any nukage/lava? (floorheight <= (last_z+MAXMOVEHEIGHT) && ((ceilingheight == floorheight && line->special) - || (ceilingheight - floorheight) >= player->mo->_f_height()))) //Does it fit? + || (ceilingheight - floorheight) >= player->mo->Height))) //Does it fit? { last_z = floorheight; last_s = s; @@ -100,7 +100,7 @@ bool DBot::Reachable (AActor *rtarget) thing = in->d.thing; if (thing == player->mo) //Can't reach self in this case. continue; - if (thing == rtarget && (rtarget->Sector->floorplane.ZatPoint (rtarget) <= (last_z+MAXMOVEHEIGHT))) + if (thing == rtarget && (rtarget->Sector->floorplane.ZatPointF (rtarget) <= (last_z+MAXMOVEHEIGHT))) { return true; } @@ -118,16 +118,16 @@ bool DBot::Reachable (AActor *rtarget) //if these conditions are true, the function returns true. //GOOD TO KNOW is that the player's view angle //in doom is 90 degrees infront. -bool DBot::Check_LOS (AActor *to, angle_t vangle) +bool DBot::Check_LOS (AActor *to, DAngle vangle) { if (!P_CheckSight (player->mo, to, SF_SEEPASTBLOCKEVERYTHING)) return false; // out of sight - if (vangle == ANGLE_MAX) + if (vangle >= 360.) return true; if (vangle == 0) return false; //Looker seems to be blind. - return absangle(player->mo->AngleTo(to), player->mo->Angles.Yaw) <= ANGLE2FLOAT(vangle/2); + return absangle(player->mo->AngleTo(to), player->mo->Angles.Yaw) <= (vangle/2); } //------------------------------------- @@ -140,10 +140,9 @@ void DBot::Dofire (ticcmd_t *cmd) bool no_fire; //used to prevent bot from pumping rockets into nearby walls. int aiming_penalty=0; //For shooting at shading target, if screen is red, MAKEME: When screen red. int aiming_value; //The final aiming value. - fixed_t dist; - double fdist; - angle_t an; - int m; + double Dist; + DAngle an; + DAngle m; double fm; if (!enemy || !(enemy->flags & MF_SHOOTABLE) || enemy->health <= 0) @@ -172,7 +171,7 @@ void DBot::Dofire (ticcmd_t *cmd) no_fire = true; //Distance to enemy. - dist = player->mo->AproxDistance(enemy, player->mo->_f_velx() - enemy->_f_velx(), player->mo->_f_vely() - enemy->_f_vely()); + Dist = player->mo->Distance2D(enemy, player->mo->Vel.X - enemy->Vel.X, player->mo->Vel.Y - enemy->Vel.Y); //FIRE EACH TYPE OF WEAPON DIFFERENT: Here should all the different weapons go. if (player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON) @@ -194,7 +193,7 @@ void DBot::Dofire (ticcmd_t *cmd) else { //*4 is for atmosphere, the chainsaws sounding and all.. - no_fire = (dist > (FLOAT2FIXED(MELEERANGE)*4)); + no_fire = (Dist > MELEERANGE*4); } } else if (player->ReadyWeapon->WeaponFlags & WIF_BOT_BFG) @@ -210,11 +209,11 @@ void DBot::Dofire (ticcmd_t *cmd) { //Special rules for RL an = FireRox (enemy, cmd); - if(an) + if(an != 0) { - angle = an; + Angle = an; //have to be somewhat precise. to avoid suicide. - if (absangle(angle - player->mo->_f_angle()) < 12*ANGLE_1) + if (absangle(an, player->mo->Angles.Yaw) < 12.) { t_rocket = 9; no_fire = false; @@ -223,17 +222,17 @@ void DBot::Dofire (ticcmd_t *cmd) } // prediction aiming shootmissile: - fdist = player->mo->Distance2D(enemy); - fm = fdist / GetDefaultByType (player->ReadyWeapon->ProjectileType)->Speed; + Dist = player->mo->Distance2D(enemy); + fm = Dist / GetDefaultByType (player->ReadyWeapon->ProjectileType)->Speed; bglobal.SetBodyAt(enemy->Pos() + enemy->Vel.XY() * fm * 2, 1); - angle = player->mo->__f_AngleTo(bglobal.body1); + Angle = player->mo->AngleTo(bglobal.body1); if (Check_LOS (enemy, SHOOTFOV)) no_fire = false; } else { //Other weapons, mostly instant hit stuff. - angle = player->mo->__f_AngleTo(enemy); + Angle = player->mo->AngleTo(enemy); aiming_penalty = 0; if (enemy->flags & MF_SHADOW) aiming_penalty += (pr_botdofire()%25)+10; @@ -246,17 +245,17 @@ shootmissile: aiming_value = 1; m = ((SHOOTFOV/2)-(aiming_value*SHOOTFOV/200)); //Higher skill is more accurate if (m <= 0) - m = 1; //Prevents lock. + m = 1.; //Prevents lock. - if (m) + if (m != 0) { if (increase) - angle += m; + Angle += m; else - angle -= m; + Angle -= m; } - if (absangle(angle - player->mo->_f_angle()) < 4*ANGLE_1) + if (absangle(Angle, player->mo->Angles.Yaw) < 4.) { increase = !increase; } @@ -291,7 +290,7 @@ bool FCajunMaster::IsLeader (player_t *player) AActor *DBot::Choose_Mate () { int count; - fixed_t closest_dist, test; + double closest_dist, test; AActor *target; AActor *observer; @@ -312,7 +311,7 @@ AActor *DBot::Choose_Mate () last_mate = NULL; target = NULL; - closest_dist = FIXED_MAX; + closest_dist = FLT_MAX; if (bot_observer) observer = players[consoleplayer].mo; else @@ -334,7 +333,7 @@ AActor *DBot::Choose_Mate () { if (P_CheckSight (player->mo, client->mo, SF_IGNOREVISIBILITY)) { - test = client->mo->AproxDistance(player->mo); + test = client->mo->Distance2D(player->mo); if (test < closest_dist) { @@ -368,9 +367,9 @@ AActor *DBot::Choose_Mate () AActor *DBot::Find_enemy () { int count; - fixed_t closest_dist, temp; //To target. + double closest_dist, temp; //To target. AActor *target; - angle_t vangle; + DAngle vangle; AActor *observer; if (!deathmatch) @@ -380,13 +379,13 @@ AActor *DBot::Find_enemy () //Note: It's hard to ambush a bot who is not alone if (allround || mate) - vangle = ANGLE_MAX; + vangle = 360.; else vangle = ENEMY_SCAN_FOV; allround = false; target = NULL; - closest_dist = FIXED_MAX; + closest_dist = FLT_MAX; if (bot_observer) observer = players[consoleplayer].mo; else @@ -404,7 +403,7 @@ AActor *DBot::Find_enemy () if (Check_LOS (client->mo, vangle)) //Here's a strange one, when bot is standing still, the P_CheckSight within Check_LOS almost always returns false. tought it should be the same checksight as below but.. (below works) something must be fuckin wierd screded up. //if(P_CheckSight(player->mo, players[count].mo)) { - temp = client->mo->AproxDistance(player->mo); + temp = client->mo->Distance2D(player->mo); //Too dark? if (temp > DARK_DIST && @@ -463,7 +462,7 @@ void FCajunMaster::SetBodyAt (const DVector3 &pos, int hostnum) //Emulates missile travel. Returns distance travelled. -fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd) +double FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd) { AActor *th = Spawn ("CajunTrace", source->PosPlusZ(4*8.), NO_REPLACE); @@ -472,23 +471,22 @@ fixed_t FCajunMaster::FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd) th->Vel = source->Vec3To(dest).Resized(th->Speed); - fixed_t dist = 0; + double dist = 0; while (dist < SAFE_SELF_MISDIST) { - dist += th->_f_speed(); - th->Move(th->_f_velx(), th->_f_vely(), th->_f_velz()); - if (!CleanAhead (th, th->_f_X(), th->_f_Y(), cmd)) + dist += th->Speed; + th->Move(th->Vel); + if (!CleanAhead (th, th->X(), th->Y(), cmd)) break; } th->Destroy (); return dist; } -angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd) +DAngle DBot::FireRox (AActor *enemy, ticcmd_t *cmd) { double dist; - angle_t ang; AActor *actor; double m; @@ -497,8 +495,8 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd) actor = bglobal.body2; dist = actor->Distance2D (enemy); - if (dist < SAFE_SELF_MISDIST/FRACUNIT) - return 0; + if (dist < SAFE_SELF_MISDIST) + return 0.; //Predict. m = ((dist+1) / GetDefaultByName("Rocket")->Speed); @@ -508,12 +506,11 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd) if (P_CheckSight (actor, bglobal.body1, SF_IGNOREVISIBILITY)) //See the predicted location, so give a test missile { FCheckPosition tm; - if (bglobal.SafeCheckPosition (player->mo, actor->_f_X(), actor->_f_Y(), tm)) + if (bglobal.SafeCheckPosition (player->mo, actor->X(), actor->Y(), tm)) { if (bglobal.FakeFire (actor, bglobal.body1, cmd) >= SAFE_SELF_MISDIST) { - ang = actor->__f_AngleTo(bglobal.body1); - return ang; + return actor->AngleTo(bglobal.body1); } } } @@ -522,21 +519,20 @@ angle_t DBot::FireRox (AActor *enemy, ticcmd_t *cmd) { if (bglobal.FakeFire (player->mo, enemy, cmd) >= SAFE_SELF_MISDIST) { - ang = player->mo->__f_AngleTo(enemy); - return ang; + return player->mo->AngleTo(enemy); } } - return 0; + return 0.; } // [RH] We absolutely do not want to pick things up here. The bot code is // executed apart from all the other simulation code, so we don't want it // creating side-effects during gameplay. -bool FCajunMaster::SafeCheckPosition (AActor *actor, fixed_t x, fixed_t y, FCheckPosition &tm) +bool FCajunMaster::SafeCheckPosition (AActor *actor, double x, double y, FCheckPosition &tm) { ActorFlags savedFlags = actor->flags; actor->flags &= ~MF_PICKUP; - bool res = P_CheckPosition (actor, x, y, tm); + bool res = P_CheckPosition (actor, DVector2(x, y), tm); actor->flags = savedFlags; return res; } diff --git a/src/b_move.cpp b/src/b_move.cpp index a879ef3d2..643002968 100644 --- a/src/b_move.cpp +++ b/src/b_move.cpp @@ -35,21 +35,21 @@ extern dirtype_t diags[4]; //which can be a weapon/enemy/item whatever. void DBot::Roam (ticcmd_t *cmd) { - int delta; if (Reachable(dest)) { // Straight towards it. - angle = player->mo->__f_AngleTo(dest); + Angle = player->mo->AngleTo(dest); } else if (player->mo->movedir < 8) // turn towards movement direction if not there yet { - angle &= (angle_t)(7<<29); - delta = angle - (player->mo->movedir << 29); + // no point doing this with floating point angles... + unsigned angle = Angle.BAMs() & (unsigned)(7 << 29); + int delta = angle - (player->mo->movedir << 29); if (delta > 0) - angle -= ANG45; + Angle -= 45; else if (delta < 0) - angle += ANG45; + Angle += 45; } // chase towards destination. @@ -61,7 +61,7 @@ void DBot::Roam (ticcmd_t *cmd) bool DBot::Move (ticcmd_t *cmd) { - fixed_t tryx, tryy; + double tryx, tryy; bool try_ok; int good; @@ -71,8 +71,8 @@ bool DBot::Move (ticcmd_t *cmd) if ((unsigned)player->mo->movedir >= 8) I_Error ("Weird bot movedir!"); - tryx = player->mo->_f_X() + 8*xspeed[player->mo->movedir]; - tryy = player->mo->_f_Y() + 8*yspeed[player->mo->movedir]; + tryx = player->mo->X() + 8*xspeed[player->mo->movedir]; + tryy = player->mo->Y() + 8*yspeed[player->mo->movedir]; try_ok = bglobal.CleanAhead (player->mo, tryx, tryy, cmd); @@ -148,18 +148,18 @@ void DBot::NewChaseDir (ticcmd_t *cmd) olddir = (dirtype_t)player->mo->movedir; turnaround = opposite[olddir]; - fixedvec2 delta = player->mo->_f_Vec2To(dest); + DVector2 delta = player->mo->Vec2To(dest); - if (delta.x > 10*FRACUNIT) + if (delta.X > 10) d[1] = DI_EAST; - else if (delta.x < -10*FRACUNIT) + else if (delta.X < -10) d[1] = DI_WEST; else d[1] = DI_NODIR; - if (delta.y < -10*FRACUNIT) + if (delta.Y < -10) d[2] = DI_SOUTH; - else if (delta.y > 10*FRACUNIT) + else if (delta.Y > 10) d[2] = DI_NORTH; else d[2] = DI_NODIR; @@ -167,19 +167,19 @@ void DBot::NewChaseDir (ticcmd_t *cmd) // try direct route if (d[1] != DI_NODIR && d[2] != DI_NODIR) { - player->mo->movedir = diags[((delta.y<0)<<1)+(delta.x>0)]; + player->mo->movedir = diags[((delta.Y < 0) << 1) + (delta.X > 0)]; if (player->mo->movedir != turnaround && TryWalk(cmd)) return; } // try other directions - if (pr_botnewchasedir() > 200 - || abs(delta.y)>abs(delta.x)) - { - tdir=d[1]; - d[1]=d[2]; - d[2]=(dirtype_t)tdir; - } + if (pr_botnewchasedir() > 200 + || fabs(delta.Y) > fabs(delta.X)) + { + tdir = d[1]; + d[1] = d[2]; + d[2] = (dirtype_t)tdir; + } if (d[1]==turnaround) d[1]=DI_NODIR; @@ -260,7 +260,7 @@ void DBot::NewChaseDir (ticcmd_t *cmd) // This is also a traverse function for // bots pre-rocket fire (preventing suicide) // -bool FCajunMaster::CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cmd) +bool FCajunMaster::CleanAhead (AActor *thing, double x, double y, ticcmd_t *cmd) { FCheckPosition tm; @@ -272,14 +272,14 @@ bool FCajunMaster::CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cm if (tm.ceilingz - tm.floorz < thing->Height) return false; // doesn't fit - double maxmove = FIXED2FLOAT(MAXMOVEHEIGHT); + double maxmove = MAXMOVEHEIGHT; if (!(thing->flags&MF_MISSILE)) { - if(tm.floorz > (thing->Sector->floorplane._f_ZatPointF(x, y)+maxmove)) //Too high wall + if(tm.floorz > (thing->Sector->floorplane.ZatPoint(x, y)+maxmove)) //Too high wall return false; //Jumpable - if(tm.floorz > (thing->Sector->floorplane._f_ZatPointF(x, y)+thing->MaxStepHeight)) + if(tm.floorz > (thing->Sector->floorplane.ZatPoint(x, y)+thing->MaxStepHeight)) cmd->ucmd.buttons |= BT_JUMP; @@ -289,7 +289,7 @@ bool FCajunMaster::CleanAhead (AActor *thing, fixed_t x, fixed_t y, ticcmd_t *cm // jump out of water // if((thing->eflags & (MF_UNDERWATER|MF_TOUCHWATER))==(MF_UNDERWATER|MF_TOUCHWATER)) -// maxstep=37*FRACUNIT; +// maxstep=37; if ( !(thing->flags & MF_TELEPORT) && (tm.floorz - thing->Z() > thing->MaxStepHeight) ) @@ -327,11 +327,11 @@ void DBot::TurnToAng () if(enemy) if(!dest) //happens when running after item in combat situations, or normal, prevents weak turns if(player->ReadyWeapon->ProjectileType == NULL && !(player->ReadyWeapon->WeaponFlags & WIF_MELEEWEAPON)) - if(Check_LOS(enemy, SHOOTFOV+5*ANGLE_1)) + if(Check_LOS(enemy, SHOOTFOV+5)) maxturn = 3; } - DAngle distance = deltaangle(player->mo->Angles.Yaw, ANGLE2DBL(angle)); + DAngle distance = deltaangle(player->mo->Angles.Yaw, Angle); if (fabs (distance) < OKAYRANGE && !enemy) return; @@ -348,8 +348,8 @@ void DBot::Pitch (AActor *target) double aim; double diff; - diff = target->_f_Z() - player->mo->_f_Z(); - aim = g_atan(diff / (double)player->mo->AproxDistance(target)); + diff = target->Z() - player->mo->Z(); + aim = g_atan(diff / player->mo->Distance2D(target)); player->mo->Angles.Pitch = ToDegrees(aim); } diff --git a/src/b_think.cpp b/src/b_think.cpp index dd6ce49aa..0ff75722a 100644 --- a/src/b_think.cpp +++ b/src/b_think.cpp @@ -75,38 +75,41 @@ void DBot::Think () } } +#define THINKDISTSQ (50000.*50000./(65536.*65536.)) //how the bot moves. //MAIN movement function. void DBot::ThinkForMove (ticcmd_t *cmd) { - fixed_t dist; + double dist; bool stuck; int r; stuck = false; - dist = dest ? player->mo->AproxDistance(dest) : 0; + dist = dest ? player->mo->Distance2D(dest) : 0; if (missile && - ((!missile->_f_velx() || !missile->_f_vely()) || !Check_LOS(missile, SHOOTFOV*3/2))) + (!missile->Vel.X || !missile->Vel.Y || !Check_LOS(missile, SHOOTFOV*3/2))) { sleft = !sleft; missile = NULL; //Probably ended its travel. } +#if 0 // this has always been broken and without any reference it cannot be fixed. if (player->mo->Angles.Pitch > 0) player->mo->Angles.Pitch -= 80; else if (player->mo->Angles.Pitch <= -60) player->mo->Angles.Pitch += 80; +#endif //HOW TO MOVE: - if (missile && (player->mo->AproxDistance(missile)mo->Distance2D(missile)mo->__f_AngleTo(missile); + Angle = player->mo->AngleTo(missile); cmd->ucmd.sidemove = sleft ? -SIDERUN : SIDERUN; cmd->ucmd.forwardmove = -FORWARDRUN; //Back IS best. - if ((player->mo->AproxDistance(oldx, oldy)<50000) + if ((player->mo->Pos() - old).LengthSquared() < THINKDISTSQ && t_strafe<=0) { t_strafe = 5; @@ -159,7 +162,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd) t_fight = AFTERTICS; if (t_strafe <= 0 && - (player->mo->AproxDistance(oldx, oldy)<50000 + ((player->mo->Pos() - old).LengthSquared() < THINKDISTSQ || ((pr_botmove()%30)==10)) ) { @@ -168,7 +171,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd) sleft = !sleft; } - angle = player->mo->__f_AngleTo(enemy); + Angle = player->mo->AngleTo(enemy); if (player->ReadyWeapon == NULL || player->mo->Distance2D(enemy) > @@ -196,7 +199,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd) } else if (mate && !enemy && (!dest || dest==mate)) //Follow mate move. { - fixed_t matedist; + double matedist; Pitch (mate); @@ -209,9 +212,9 @@ void DBot::ThinkForMove (ticcmd_t *cmd) goto roam; } - angle = player->mo->__f_AngleTo(mate); + Angle = player->mo->AngleTo(mate); - matedist = player->mo->AproxDistance(mate); + matedist = player->mo->Distance2D(mate); if (matedist > (FRIEND_DIST*2)) cmd->ucmd.forwardmove = FORWARDRUN; else if (matedist > FRIEND_DIST) @@ -244,7 +247,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd) (pr_botmove()%100)>skill.isp) && player->ReadyWeapon != NULL && !(player->ReadyWeapon->WeaponFlags & WIF_WIMPY_WEAPON)) dest = enemy;//Dont let enemy kill the bot by supressive fire. So charge enemy. else //hide while t_fight, but keep view at enemy. - angle = player->mo->__f_AngleTo(enemy); + Angle = player->mo->AngleTo(enemy); } //Just a monster, so kill it. else dest = enemy; @@ -306,8 +309,7 @@ void DBot::ThinkForMove (ticcmd_t *cmd) if (t_fight<(AFTERTICS/2)) player->mo->flags |= MF_DROPOFF; - oldx = player->mo->_f_X(); - oldy = player->mo->_f_Y(); + old = player->mo->Pos(); } //BOT_WhatToGet diff --git a/src/doomdef.h b/src/doomdef.h index 67c43787c..89d7ba673 100644 --- a/src/doomdef.h +++ b/src/doomdef.h @@ -350,7 +350,7 @@ enum { BCOMPATF_SETSLOPEOVERFLOW = 1 << 0, // SetSlope things can overflow BCOMPATF_RESETPLAYERSPEED = 1 << 1, // Set player speed to 1.0 when changing maps - BCOMPATF_VILEGHOSTS = 1 << 2, // Monsters' _f_radius() and height aren't restored properly when resurrected. + BCOMPATF_VILEGHOSTS = 1 << 2, // Monsters' radius and height aren't restored properly when resurrected. BCOMPATF_BADTELEPORTERS = 1 << 3, // Ignore tags on Teleport specials BCOMPATF_BADPORTALS = 1 << 4, // Restores the old unstable portal behavior BCOMPATF_REBUILDNODES = 1 << 5, // Force node rebuild diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 811d8748a..76aecea8c 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -99,8 +99,9 @@ dirtype_t diags[4] = DI_NORTHWEST, DI_NORTHEAST, DI_SOUTHWEST, DI_SOUTHEAST }; -fixed_t xspeed[8] = {FRACUNIT,46341,0,-46341,-FRACUNIT,-46341,0,46341}; -fixed_t yspeed[8] = {0,46341,FRACUNIT,46341,0,-46341,-FRACUNIT,-46341}; +#define SQRTHALF 0.7071075439453125 +double xspeed[8] = {1,SQRTHALF,0,-SQRTHALF,-1,-SQRTHALF,0,SQRTHALF}; +double yspeed[8] = {0,SQRTHALF,1,SQRTHALF,0,-SQRTHALF,-1,-SQRTHALF}; void P_RandomChaseDir (AActor *actor); @@ -511,8 +512,8 @@ bool P_Move (AActor *actor) } } - tryx = (origx = actor->_f_X()) + (deltax = FixedMul (speed, xspeed[actor->movedir])); - tryy = (origy = actor->_f_Y()) + (deltay = FixedMul (speed, yspeed[actor->movedir])); + tryx = (origx = actor->_f_X()) + (deltax = fixed_t (speed * xspeed[actor->movedir])); + tryy = (origy = actor->_f_Y()) + (deltay = fixed_t (speed * yspeed[actor->movedir])); // Like P_XYMovement this should do multiple moves if the step size is too large @@ -2599,8 +2600,8 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) { const fixed_t absSpeed = abs (self->_f_speed()); fixedvec2 viletry = self->Vec2Offset( - FixedMul (absSpeed, xspeed[self->movedir]), - FixedMul (absSpeed, yspeed[self->movedir]), true); + int (absSpeed * xspeed[self->movedir]), + int (absSpeed * yspeed[self->movedir]), true); FPortalGroupArray check(FPortalGroupArray::PGA_Full3d); diff --git a/src/p_enemy.h b/src/p_enemy.h index 2912f847f..ee091ce25 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -24,7 +24,7 @@ enum dirtype_t NUMDIRS }; -extern fixed_t xspeed[8], yspeed[8]; +extern double xspeed[8], yspeed[8]; enum LO_Flags { diff --git a/src/p_local.h b/src/p_local.h index 367f54b3a..47be75835 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -281,10 +281,14 @@ inline bool P_CheckPosition(AActor *thing, const fixedvec3 &pos, bool actorsonly { return P_CheckPosition(thing, pos.x, pos.y, actorsonly); } -inline bool P_CheckPosition(AActor *thing, const DVector3 &pos, bool actorsonly = false) +inline bool P_CheckPosition(AActor *thing, const DVector2 &pos, bool actorsonly = false) { return P_CheckPosition(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), actorsonly); } +inline bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, bool actorsonly = false) +{ + return P_CheckPosition(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), tm, 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); diff --git a/src/p_map.cpp b/src/p_map.cpp index 3a2b66500..247dda65f 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2828,7 +2828,7 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t } // set openrange, opentop, openbottom - P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); + P_LineOpening(open, slidemo, li, it._f_InterceptPoint(in)); if (open.range < slidemo->Height) goto isblocking; // doesn't fit @@ -3184,7 +3184,7 @@ bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_ } - P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); // set openrange, opentop, openbottom + P_LineOpening(open, slidemo, li, it._f_InterceptPoint(in)); // set openrange, opentop, openbottom if (open.range < slidemo->Height) goto bounceblocking; // doesn't fit @@ -3806,7 +3806,7 @@ struct aim_t // Crosses a two sided line. // A two sided line will restrict the possible target ranges. FLineOpening open; - P_LineOpening(open, NULL, li, it.InterceptPoint(in), FIXED_MIN, 0, FFCF_NODROPOFF); + P_LineOpening(open, NULL, li, it._f_InterceptPoint(in), FIXED_MIN, 0, FFCF_NODROPOFF); // The following code assumes that portals on the front of the line have already been processed. @@ -3831,7 +3831,7 @@ struct aim_t return; int planestocheck; - if (!AimTraverse3DFloors(it.Trace(), in, frontflag, &planestocheck)) + if (!AimTraverse3DFloors(it._f_Trace(), in, frontflag, &planestocheck)) return; if (aimdebug) @@ -3961,7 +3961,7 @@ struct aim_t fixed_t cosine = finecosine[thingpitch >> ANGLETOFINESHIFT]; if (cosine != 0) { - fixed_t d3 = FixedDiv(FixedMul(P_AproxDistance(it.Trace().dx, it.Trace().dy), in->frac), cosine); + fixed_t d3 = FixedDiv(FixedMul(P_AproxDistance(it._f_Trace().dx, it._f_Trace().dy), in->frac), cosine); if (d3 > attackrange) { return; @@ -4560,7 +4560,7 @@ void P_TraceBleed(int damage, AActor *target, angle_t angle, int pitch) void P_TraceBleed(int damage, AActor *target, AActor *missile) { - int pitch; + DAngle pitch; if (target == NULL || missile->flags3 & MF3_BLOODLESSIMPACT) { @@ -4572,15 +4572,13 @@ void P_TraceBleed(int damage, AActor *target, AActor *missile) double aim; aim = g_atan((double)missile->_f_velz() / (double)target->AproxDistance(missile)); - pitch = -(int)(aim * ANGLE_180 / PI); + pitch = -ToDegrees(aim); } else { - pitch = 0; + pitch = 0.; } - P_TraceBleed(damage, target->_f_X(), target->_f_Y(), target->_f_Z() + target->_f_height() / 2, - target, missile->__f_AngleTo(target), - pitch); + P_TraceBleed(damage, target->PosPlusZ(target->Height/2), target, missile->AngleTo(target), pitch); } //========================================================================== @@ -4958,7 +4956,7 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end } else { - P_LineOpening(open, NULL, in->d.line, it.InterceptPoint(in)); + P_LineOpening(open, NULL, in->d.line, it._f_InterceptPoint(in)); } if (open.range <= 0 || (in->d.line->special != 0 && (i_compatflags & COMPATF_USEBLOCKING))) @@ -5066,7 +5064,7 @@ bool P_NoWayTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t e if (ld->special) continue; if (ld->isLinePortal()) return false; if (ld->flags&(ML_BLOCKING | ML_BLOCKEVERYTHING | ML_BLOCK_PLAYERS)) return true; - P_LineOpening(open, NULL, ld, it.InterceptPoint(in)); + P_LineOpening(open, NULL, ld, it._f_InterceptPoint(in)); if (open.range <= 0 || open.bottom > usething->Z() + usething->MaxStepHeight || open.top < usething->Top()) return true; @@ -5148,7 +5146,7 @@ bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) { // Check line if (in->d.line->special != UsePuzzleItem) { - P_LineOpening(open, NULL, in->d.line, it.InterceptPoint(in)); + P_LineOpening(open, NULL, in->d.line, it._f_InterceptPoint(in)); if (open.range <= 0) { return false; // can't use through a wall diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 91b45a373..b4d6dc8fe 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -1425,6 +1425,7 @@ intercept_t *FPathTraverse::Next() { dist = scan->frac; in = scan; + in->Frac = FIXED2FLOAT(in->frac); } } @@ -1658,6 +1659,10 @@ void FPathTraverse::init (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int fl break; } } + ftrace.dx = FIXED2DBL(trace.dx); + ftrace.dy = FIXED2DBL(trace.dy); + ftrace.x = FIXED2DBL(trace.x); + ftrace.y = FIXED2DBL(trace.y); } //=========================================================================== diff --git a/src/p_maputl.h b/src/p_maputl.h index 727b56c2b..f2442d2bb 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -25,6 +25,7 @@ struct divline_t struct intercept_t { + double Frac; fixed_t frac; // along trace line bool isaline; bool done; @@ -390,6 +391,7 @@ class FPathTraverse protected: static TArray intercepts; + divline_t ftrace; fdivline_t trace; fixed_t startfrac; unsigned int intercept_index; @@ -407,12 +409,17 @@ public: { init(x1, y1, x2, y2, flags, startfrac); } + FPathTraverse(double x1, double y1, double x2, double y2, int flags, double startfrac = 0) + { + init(FLOAT2FIXED(x1), FLOAT2FIXED(y1), FLOAT2FIXED(x2), FLOAT2FIXED(y2), flags, FLOAT2FIXED(startfrac)); + } void init(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags, fixed_t startfrac = 0); int PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos = NULL); virtual ~FPathTraverse(); - const fdivline_t &Trace() const { return trace; } + const fdivline_t &_f_Trace() const { return trace; } + const divline_t &Trace() const { return ftrace; } - inline fixedvec2 InterceptPoint(const intercept_t *in) + inline fixedvec2 _f_InterceptPoint(const intercept_t *in) { return { @@ -420,6 +427,14 @@ public: trace.y + FixedMul(trace.dy, in->frac) }; } + inline DVector2 InterceptPoint(const intercept_t *in) + { + return + { + FIXED2DBL(trace.x + FixedMul(trace.dx, in->frac)), + FIXED2DBL(trace.y + FixedMul(trace.dy, in->frac)) + }; + } }; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index c10ff482d..b59ae30aa 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3171,9 +3171,8 @@ bool AActor::IsOkayToAttack (AActor *link) // to only allow the check to succeed if the enemy was in a ~84� FOV of the player if (flags3 & MF3_SCREENSEEKER) { - angle_t angle = Friend->__f_AngleTo(link) - Friend->_f_angle(); - angle >>= 24; - if (angle>226 || angle<30) + DAngle angle = absangle(Friend->AngleTo(link), Friend->Angles.Yaw); + if (angle < 30 * (256./360.)) { return true; } @@ -3562,7 +3561,7 @@ void AActor::Tick () { if (!players[i].Bot->missile && (flags3 & MF3_WARNBOT)) { //warn for incoming missiles. - if (target != players[i].mo && players[i].Bot->Check_LOS (this, ANGLE_90)) + if (target != players[i].mo && players[i].Bot->Check_LOS (this, 90.)) players[i].Bot->missile = this; } } diff --git a/src/p_user.cpp b/src/p_user.cpp index 8783bac99..c81fe10af 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -3183,37 +3183,6 @@ void player_t::Serialize (FArchive &arc) onground = (mo->Z() <= mo->floorz) || (mo->flags2 & MF2_ONMOBJ) || (mo->BounceFlags & BOUNCE_MBF) || (cheats & CF_NOCLIP2); } - if (SaveVersion < 4514 && IsBot) - { - Bot = new DBot; - - arc << Bot->angle - << Bot->dest - << Bot->prev - << Bot->enemy - << Bot->missile - << Bot->mate - << Bot->last_mate - << Bot->skill - << Bot->t_active - << Bot->t_respawn - << Bot->t_strafe - << Bot->t_react - << Bot->t_fight - << Bot->t_roam - << Bot->t_rocket - << Bot->first_shot - << Bot->sleft - << Bot->allround - << Bot->oldx - << Bot->oldy; - } - - if (SaveVersion < 4516 && Bot != NULL) - { - Bot->player = this; - } - if (arc.IsLoading ()) { // If the player reloaded because they pressed +use after dying, we diff --git a/src/portal.cpp b/src/portal.cpp index 1d7419b66..81a8e4467 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -716,7 +716,7 @@ fixedvec2 P_GetOffsetPosition(fixed_t x, fixed_t y, fixed_t dx, fixed_t dy) // Teleport portals are intentionally ignored since skipping this stuff is their entire reason for existence. if (port->mFlags & PORTF_INTERACTIVE) { - fixedvec2 hit = it.InterceptPoint(in); + fixedvec2 hit = it._f_InterceptPoint(in); if (port->mType == PORTT_LINKED) { From 558e04cb9919de16857b8b7358bb325e6a2fcd24 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Mar 2016 01:03:02 +0100 Subject: [PATCH 10/44] - safety commit. --- src/c_console.cpp | 20 ++++++++++---------- src/d_dehacked.cpp | 2 +- src/d_net.cpp | 16 ++++++---------- src/d_netinfo.cpp | 2 +- 4 files changed, 18 insertions(+), 22 deletions(-) diff --git a/src/c_console.cpp b/src/c_console.cpp index 5c4b6e441..b86ea0b2c 100644 --- a/src/c_console.cpp +++ b/src/c_console.cpp @@ -732,15 +732,15 @@ static void C_DrawNotifyText () if (!show_messages && NotifyStrings[i].PrintLevel != 128) continue; - fixed_t alpha; + double alpha; if (j < NOTIFYFADETIME) { - alpha = OPAQUE * j / NOTIFYFADETIME; + alpha = 1. * j / NOTIFYFADETIME; } else { - alpha = OPAQUE; + alpha = 1; } if (NotifyStrings[i].PrintLevel >= PRINTLEVELS) @@ -752,23 +752,23 @@ static void C_DrawNotifyText () { if (!center) screen->DrawText (SmallFont, color, 0, line, NotifyStrings[i].Text, - DTA_CleanNoMove, true, DTA_Alpha, alpha, TAG_DONE); + DTA_CleanNoMove, true, DTA_AlphaF, alpha, TAG_DONE); else screen->DrawText (SmallFont, color, (SCREENWIDTH - SmallFont->StringWidth (NotifyStrings[i].Text)*CleanXfac)/2, line, NotifyStrings[i].Text, DTA_CleanNoMove, true, - DTA_Alpha, alpha, TAG_DONE); + DTA_AlphaF, alpha, TAG_DONE); } else if (con_scaletext == 0) { if (!center) screen->DrawText (SmallFont, color, 0, line, NotifyStrings[i].Text, - DTA_Alpha, alpha, TAG_DONE); + DTA_AlphaF, alpha, TAG_DONE); else screen->DrawText (SmallFont, color, (SCREENWIDTH - SmallFont->StringWidth (NotifyStrings[i].Text))/2, line, NotifyStrings[i].Text, - DTA_Alpha, alpha, TAG_DONE); + DTA_AlphaF, alpha, TAG_DONE); } else { @@ -777,7 +777,7 @@ static void C_DrawNotifyText () DTA_VirtualWidth, screen->GetWidth() / 2, DTA_VirtualHeight, screen->GetHeight() / 2, DTA_KeepRatio, true, - DTA_Alpha, alpha, TAG_DONE); + DTA_AlphaF, alpha, TAG_DONE); else screen->DrawText (SmallFont, color, (screen->GetWidth() / 2 - SmallFont->StringWidth (NotifyStrings[i].Text))/2, @@ -785,7 +785,7 @@ static void C_DrawNotifyText () DTA_VirtualWidth, screen->GetWidth() / 2, DTA_VirtualHeight, screen->GetHeight() / 2, DTA_KeepRatio, true, - DTA_Alpha, alpha, TAG_DONE); + DTA_AlphaF, alpha, TAG_DONE); } line += lineadv; canskip = false; @@ -865,7 +865,7 @@ void C_DrawConsole (bool hw2d) DTA_DestWidth, screen->GetWidth(), DTA_DestHeight, screen->GetHeight(), DTA_ColorOverlay, conshade, - DTA_Alpha, (hw2d && gamestate != GS_FULLCONSOLE) ? FLOAT2FIXED(con_alpha) : FRACUNIT, + DTA_AlphaF, (hw2d && gamestate != GS_FULLCONSOLE) ? (double)con_alpha : 1., DTA_Masked, false, TAG_DONE); if (conline && visheight < screen->GetHeight()) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 02237944e..5c84532c4 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -1340,7 +1340,7 @@ static int PatchSound (int soundNum) else CHECKKEY ("Zero/One", info->singularity) else CHECKKEY ("Value", info->priority) else CHECKKEY ("Zero 1", info->link) - else CHECKKEY ("Neg. One 1", info->_f_pitch()) + else CHECKKEY ("Neg. One 1", info->pitch) else CHECKKEY ("Neg. One 2", info->volume) else CHECKKEY ("Zero 2", info->data) else CHECKKEY ("Zero 3", info->usefulness) diff --git a/src/d_net.cpp b/src/d_net.cpp index 763b09f22..89f6a28b6 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2366,19 +2366,15 @@ void Net_DoCommand (int type, BYTE **stream, int player) { FTraceResults trace; - angle_t ang = players[player].mo->_f_angle() >> ANGLETOFINESHIFT; - angle_t pitch = (angle_t)(players[player].mo->_f_pitch()) >> ANGLETOFINESHIFT; - fixed_t vx = FixedMul (finecosine[pitch], finecosine[ang]); - fixed_t vy = FixedMul (finecosine[pitch], finesine[ang]); - fixed_t vz = -finesine[pitch]; + DAngle ang = players[player].mo->Angles.Yaw; + DAngle pitch = players[player].mo->Angles.Pitch; + double c = pitch.Cos(); + DVector3 vec(c * ang.Cos(), c * ang.Sin(), -pitch.Sin); s = ReadString (stream); - if (Trace (players[player].mo->_f_X(), players[player].mo->_f_Y(), - players[player].mo->_f_Top() - (players[player].mo->_f_height()>>2), - players[player].mo->Sector, - vx, vy, vz, 172*FRACUNIT, 0, ML_BLOCKEVERYTHING, players[player].mo, - trace, TRACE_NoSky)) + if (Trace (players[player].mo->PosPlusZ(players[player].mo->Height/2), players[player].mo->Sector, + vec, 172., 0, ML_BLOCKEVERYTHING, players[player].mo, trace, TRACE_NoSky)) { if (trace.HitType == TRACE_HitWall) { diff --git a/src/d_netinfo.cpp b/src/d_netinfo.cpp index 3cf40e932..012dea399 100644 --- a/src/d_netinfo.cpp +++ b/src/d_netinfo.cpp @@ -884,7 +884,7 @@ void ReadCompatibleUserInfo(FArchive &arc, userinfo_t &info) BYTE team; int aimdist, color, colorset, skin, gender; bool neverswitch; - //fixed_t movebob, stillbob; These were never serialized! + //fxed_t movebob, stillbob; These were never serialized! //int playerclass; " info.Reset(); From c2e7858e053476faf42f755eeb07c89c905c0c66 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Mar 2016 01:13:36 +0100 Subject: [PATCH 11/44] - looks like the oldz parameter in UpdateWaterLevel is not needed at all... --- src/actor.h | 6 +----- src/d_dehacked.cpp | 15 ++++++++++----- src/d_net.cpp | 2 +- src/d_player.h | 2 +- src/d_protocol.h | 3 --- src/g_shared/a_fastprojectile.cpp | 2 +- src/p_map.cpp | 2 +- src/p_mobj.cpp | 16 +++++++--------- src/p_user.cpp | 4 ++-- 9 files changed, 24 insertions(+), 28 deletions(-) diff --git a/src/actor.h b/src/actor.h index dc7013865..863c0a496 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1337,11 +1337,7 @@ public: bool InStateSequence(FState * newstate, FState * basestate); int GetTics(FState * newstate); bool SetState (FState *newstate, bool nofunction=false); - virtual bool UpdateWaterLevel (fixed_t oldz, bool splash=true); - bool UpdateWaterLevel(double oldz, bool splash = true) - { - return UpdateWaterLevel(FLOAT2FIXED(oldz), splash); - } + virtual bool UpdateWaterLevel (bool splash=true); bool isFast(); bool isSlow(); void SetIdle(bool nofunction=false); diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index 5c84532c4..eeaa12729 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -353,6 +353,11 @@ static bool ReadChars (char **stuff, int size); static char *igets (void); static int GetLine (void); +inline double DEHToDouble(int acsval) +{ + return acsval / 65536.; +} + static void PushTouchedActor(PClassActor *cls) { for(unsigned i = 0; i < TouchedActors.Size(); i++) @@ -647,7 +652,7 @@ static int CreateMushroomFunc(VMFunctionBuilder &buildit, int value1, int value2 } else { - buildit.Emit(OP_PARAM, 0, REGT_FLOAT | REGT_KONST, buildit.GetConstantFloat(FIXED2DBL(value1))); + buildit.Emit(OP_PARAM, 0, REGT_FLOAT | REGT_KONST, buildit.GetConstantFloat(DEHToDouble(value1))); } // hrange if (value2 == 0) @@ -656,7 +661,7 @@ static int CreateMushroomFunc(VMFunctionBuilder &buildit, int value1, int value2 } else { - buildit.Emit(OP_PARAM, 0, REGT_FLOAT | REGT_KONST, buildit.GetConstantFloat(FIXED2DBL(value2))); + buildit.Emit(OP_PARAM, 0, REGT_FLOAT | REGT_KONST, buildit.GetConstantFloat(DEHToDouble(value2))); } return 5; } @@ -896,14 +901,14 @@ static int PatchThing (int thingy) } else if (linelen == 12 && stricmp (Line1, "Translucency") == 0) { - info->Alpha = FIXED2DBL(val); + info->Alpha = DEHToDouble(val); info->RenderStyle = STYLE_Translucent; hadTranslucency = true; hadStyle = true; } else if (linelen == 6 && stricmp (Line1, "Height") == 0) { - info->Height = FIXED2DBL(val); + info->Height = DEHToDouble(val); info->projectilepassheight = 0; // needs to be disabled hadHeight = true; } @@ -919,7 +924,7 @@ static int PatchThing (int thingy) } else if (stricmp (Line1, "Width") == 0) { - info->radius = FIXED2FLOAT(val); + info->radius = DEHToDouble(val); } else if (stricmp (Line1, "Alpha") == 0) { diff --git a/src/d_net.cpp b/src/d_net.cpp index 89f6a28b6..4fe85f239 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2369,7 +2369,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) DAngle ang = players[player].mo->Angles.Yaw; DAngle pitch = players[player].mo->Angles.Pitch; double c = pitch.Cos(); - DVector3 vec(c * ang.Cos(), c * ang.Sin(), -pitch.Sin); + DVector3 vec(c * ang.Cos(), c * ang.Sin(), -pitch.Sin()); s = ReadString (stream); diff --git a/src/d_player.h b/src/d_player.h index 598ccdd48..40178dac1 100644 --- a/src/d_player.h +++ b/src/d_player.h @@ -167,7 +167,7 @@ public: // [CW] Fades for when you are being damaged. PalEntry DamageFade; - bool UpdateWaterLevel (fixed_t oldz, bool splash); + bool UpdateWaterLevel (bool splash); bool ResetAirSupply (bool playgasp = true); int GetMaxHealth() const; diff --git a/src/d_protocol.h b/src/d_protocol.h index 02212efe7..61f7377e3 100644 --- a/src/d_protocol.h +++ b/src/d_protocol.h @@ -50,9 +50,6 @@ #define NETD_ID BIGE_ID('N','E','T','D') #define WEAP_ID BIGE_ID('W','E','A','P') -#define ANGLE2SHORT(x) ((((x)/360) & 65535) -#define SHORT2ANGLE(x) ((x)*360) - struct zdemoheader_s { BYTE demovermajor; diff --git a/src/g_shared/a_fastprojectile.cpp b/src/g_shared/a_fastprojectile.cpp index 55489cdcf..8c7d63b74 100644 --- a/src/g_shared/a_fastprojectile.cpp +++ b/src/g_shared/a_fastprojectile.cpp @@ -93,7 +93,7 @@ void AFastProjectile::Tick () } } AddZ(frac.Z); - UpdateWaterLevel (oldz); + UpdateWaterLevel (); oldz = Z(); if (oldz <= floorz) { // Hit the floor diff --git a/src/p_map.cpp b/src/p_map.cpp index 247dda65f..82eb9360a 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -6098,7 +6098,7 @@ bool P_ChangeSector(sector_t *sector, int crunch, int amt, int floorOrCeil, bool { n->visited = true; // mark thing as processed - n->m_thing->UpdateWaterLevel(n->m_thing->_f_Z(), false); + n->m_thing->UpdateWaterLevel(false); P_CheckFakeFloorTriggers(n->m_thing, n->m_thing->_f_Z() - amt); } } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b59ae30aa..56f741494 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -472,7 +472,7 @@ void AActor::Serialize(FArchive &arc) } } ClearInterpolation(); - UpdateWaterLevel(_f_Z(), false); + UpdateWaterLevel(false); } } @@ -3462,7 +3462,7 @@ void AActor::Tick () } } - fixed_t oldz = _f_Z(); + double oldz = Z(); // [RH] Give the pain elemental vertical friction // This used to be in APainElemental::Tick but in order to use @@ -3736,7 +3736,7 @@ void AActor::Tick () const sector_t *sec = node->m_sector; if (sec->floorplane.c >= STEEPSLOPE) { - if (floorplane.ZatPointF (_f_PosRelative(node->m_sector)) >= Z() - MaxStepHeight) + if (floorplane.ZatPoint(PosRelative(node->m_sector)) >= Z() - MaxStepHeight) { dopush = false; break; @@ -3858,7 +3858,7 @@ void AActor::Tick () CheckPortalTransition(true); - UpdateWaterLevel (oldz); + UpdateWaterLevel (); // [RH] Don't advance if predicting a player if (player && (player->cheats & CF_PREDICTING)) @@ -4011,7 +4011,7 @@ void AActor::CheckSectorTransition(sector_t *oldsec) // //========================================================================== -bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) +bool AActor::UpdateWaterLevel (bool dosplash) { BYTE lastwaterlevel = waterlevel; double fh = -FLT_MAX; @@ -4068,10 +4068,8 @@ bool AActor::UpdateWaterLevel (fixed_t oldz, bool dosplash) else { // Check 3D floors as well! - for(unsigned int i=0;ie->XFloor.ffloors.Size();i++) + for(auto rover : Sector->e->XFloor.ffloors) { - F3DFloor* rover=Sector->e->XFloor.ffloors[i]; - if (!(rover->flags & FF_EXISTS)) continue; if(!(rover->flags & FF_SWIMMABLE) || rover->flags & FF_SOLID) continue; @@ -4269,7 +4267,7 @@ AActor *AActor::StaticSpawn (PClassActor *type, const DVector3 &pos, replace_t a { actor->Floorclip = 0; } - actor->UpdateWaterLevel (actor->Z(), false); + actor->UpdateWaterLevel (false); if (!SpawningMapThing) { actor->BeginPlay (); diff --git a/src/p_user.cpp b/src/p_user.cpp index c81fe10af..40eefd893 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -1225,10 +1225,10 @@ int APlayerPawn::GetMaxHealth() const // //=========================================================================== -bool APlayerPawn::UpdateWaterLevel (fixed_t oldz, bool splash) +bool APlayerPawn::UpdateWaterLevel (bool splash) { int oldlevel = waterlevel; - bool retval = Super::UpdateWaterLevel (oldz, splash); + bool retval = Super::UpdateWaterLevel (splash); if (player != NULL) { if (oldlevel < 3 && waterlevel == 3) From 696fde69b819b04fb197312dd8b1c08631d4fd5e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Mar 2016 01:30:28 +0100 Subject: [PATCH 12/44] - moved the bot support code from AActor::Tick to a subfunction in the bot sources. No need to pollute a main game file with this stuff. --- src/b_bot.h | 1 + src/b_func.cpp | 42 +++++++++++++++++++++++++++++++ src/p_mobj.cpp | 39 +--------------------------- src/thingdef/thingdef_codeptr.cpp | 2 +- 4 files changed, 45 insertions(+), 39 deletions(-) diff --git a/src/b_bot.h b/src/b_bot.h index e56b03f00..9f9fe55ba 100644 --- a/src/b_bot.h +++ b/src/b_bot.h @@ -106,6 +106,7 @@ public: void SetBodyAt (const DVector3 &pos, int hostnum); double FakeFire (AActor *source, AActor *dest, ticcmd_t *cmd); bool SafeCheckPosition (AActor *actor, double x, double y, FCheckPosition &tm); + void BotTick(AActor *mo); //(b_move.cpp) bool CleanAhead (AActor *thing, double x, double y, ticcmd_t *cmd); diff --git a/src/b_func.cpp b/src/b_func.cpp index 0e36d93d6..e292fd67d 100644 --- a/src/b_func.cpp +++ b/src/b_func.cpp @@ -284,6 +284,48 @@ bool FCajunMaster::IsLeader (player_t *player) return false; } +extern int BotWTG; + +void FCajunMaster::BotTick(AActor *mo) +{ + BotSupportCycles.Clock(); + bglobal.m_Thinking = true; + for (int i = 0; i < MAXPLAYERS; i++) + { + if (!playeringame[i] || players[i].Bot == NULL) + continue; + + if (mo->flags3 & MF3_ISMONSTER) + { + if (mo->health > 0 + && !players[i].Bot->enemy + && mo->player ? !mo->IsTeammate(players[i].mo) : true + && mo->Distance2D(players[i].mo) < MAX_MONSTER_TARGET_DIST + && P_CheckSight(players[i].mo, mo, SF_SEEPASTBLOCKEVERYTHING)) + { //Probably a monster, so go kill it. + players[i].Bot->enemy = mo; + } + } + else if (mo->flags & MF_SPECIAL) + { //Item pickup time + //clock (BotWTG); + players[i].Bot->WhatToGet(mo); + //unclock (BotWTG); + BotWTG++; + } + else if (mo->flags & MF_MISSILE) + { + if (!players[i].Bot->missile && (mo->flags3 & MF3_WARNBOT)) + { //warn for incoming missiles. + if (mo->target != players[i].mo && players[i].Bot->Check_LOS(mo, 90.)) + players[i].Bot->missile = mo; + } + } + } + bglobal.m_Thinking = false; + BotSupportCycles.Unclock(); +} + //This function is called every //tick (for each bot) to set //the mate (teammate coop mate). diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 56f741494..76aa87127 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3532,46 +3532,9 @@ void AActor::Tick () if (bglobal.botnum && !demoplayback && ((flags & (MF_SPECIAL|MF_MISSILE)) || (flags3 & MF3_ISMONSTER))) { - BotSupportCycles.Clock(); - bglobal.m_Thinking = true; - for (i = 0; i < MAXPLAYERS; i++) - { - if (!playeringame[i] || players[i].Bot == NULL) - continue; - - if (flags3 & MF3_ISMONSTER) - { - if (health > 0 - && !players[i].Bot->enemy - && player ? !IsTeammate (players[i].mo) : true - && AproxDistance (players[i].mo) < MAX_MONSTER_TARGET_DIST - && P_CheckSight (players[i].mo, this, SF_SEEPASTBLOCKEVERYTHING)) - { //Probably a monster, so go kill it. - players[i].Bot->enemy = this; - } - } - else if (flags & MF_SPECIAL) - { //Item pickup time - //clock (BotWTG); - players[i].Bot->WhatToGet (this); - //unclock (BotWTG); - BotWTG++; - } - else if (flags & MF_MISSILE) - { - if (!players[i].Bot->missile && (flags3 & MF3_WARNBOT)) - { //warn for incoming missiles. - if (target != players[i].mo && players[i].Bot->Check_LOS (this, 90.)) - players[i].Bot->missile = this; - } - } - } - bglobal.m_Thinking = false; - BotSupportCycles.Unclock(); + bglobal.BotTick(this); } - //End of MC - // [RH] Consider carrying sectors here fixed_t cummx = 0, cummy = 0; if ((level.Scrolls != NULL || player != NULL) && !(flags & MF_NOCLIP) && !(flags & MF_NOSECTOR)) diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index c79b2e6db..1a356796d 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -6505,7 +6505,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckProximity) if (ptrWillChange) { - current = ref->AproxDistance(mo); + current = ref->Distance2D(mo); if ((flags & CPXF_CLOSEST) && (current < closer)) { From 30b57fd7b04c478490bf74f47bdc994d0d4ecfda Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Mar 2016 09:28:00 +0100 Subject: [PATCH 13/44] - floatification of G_CheckSpot and a few other things. --- src/files.h | 8 ++++---- src/g_game.cpp | 32 ++++++++++++++------------------ src/g_level.cpp | 2 +- src/gi.cpp | 9 +-------- src/gi.h | 2 +- src/p_3dfloors.cpp | 28 ++++++++-------------------- src/p_mobj.cpp | 3 +-- 7 files changed, 30 insertions(+), 54 deletions(-) diff --git a/src/files.h b/src/files.h index c417afa09..5889eb6fe 100644 --- a/src/files.h +++ b/src/files.h @@ -46,7 +46,7 @@ public: return *this; } - FileReaderBase &operator>> (fixed_t &v) + FileReaderBase &operator>> (int &v) { Read (&v, 4); v = LittleLong(v); @@ -171,7 +171,7 @@ public: return *this; } - FileReaderZ &operator>> (fixed_t &v) + FileReaderZ &operator>> (int &v) { Read (&v, 4); v = LittleLong(v); @@ -233,7 +233,7 @@ public: return *this; } - FileReaderBZ2 &operator>> (fixed_t &v) + FileReaderBZ2 &operator>> (int &v) { Read (&v, 4); v = LittleLong(v); @@ -297,7 +297,7 @@ public: return *this; } - FileReaderLZMA &operator>> (fixed_t &v) + FileReaderLZMA &operator>> (int &v) { Read (&v, 4); v = LittleLong(v); diff --git a/src/g_game.cpp b/src/g_game.cpp index 2bf490bd2..2334c1ec1 100644 --- a/src/g_game.cpp +++ b/src/g_game.cpp @@ -197,9 +197,9 @@ short consistancy[MAXPLAYERS][BACKUPTICS]; float normforwardmove[2] = {0x19, 0x32}; // [RH] For setting turbo from console float normsidemove[2] = {0x18, 0x28}; // [RH] Ditto -fixed_t forwardmove[2], sidemove[2]; -fixed_t angleturn[4] = {640, 1280, 320, 320}; // + slow turn -fixed_t flyspeed[2] = {1*256, 3*256}; +int forwardmove[2], sidemove[2]; +int angleturn[4] = {640, 1280, 320, 320}; // + slow turn +int flyspeed[2] = {1*256, 3*256}; int lookspeed[2] = {450, 512}; #define SLOWTURNTICS 6 @@ -1182,8 +1182,7 @@ void G_Ticker () } if (players[i].mo) { - DWORD sum = rngsum + players[i].mo->_f_X() + players[i].mo->_f_Y() + players[i].mo->_f_Z() - + players[i].mo->_f_angle() + players[i].mo->_f_pitch(); + DWORD sum = rngsum + int((players[i].mo->X() + players[i].mo->Y() + players[i].mo->Z())*257) + players[i].mo->Angles.Yaw.BAMs() + players[i].mo->Angles.Pitch.BAMs(); sum ^= players[i].health; consistancy[i][buf] = sum; } @@ -1423,33 +1422,30 @@ void G_PlayerReborn (int player) bool G_CheckSpot (int playernum, FPlayerStart *mthing) { - fixed_t x; - fixed_t y; - fixed_t z, oldz; + DVector3 spot; + double oldz; int i; if (mthing->type == 0) return false; - x = mthing->_f_X(); - y = mthing->_f_Y(); - z = mthing->_f_Z(); + spot = mthing->pos; if (!(level.flags & LEVEL_USEPLAYERSTARTZ)) { - z = 0; + spot.Z = 0; } - z += P_PointInSector (x, y)->floorplane.ZatPoint (x, y); + spot.Z += P_PointInSector (spot)->floorplane.ZatPoint (spot); if (!players[playernum].mo) { // first spawn of level, before corpses for (i = 0; i < playernum; i++) - if (players[i].mo && players[i].mo->_f_X() == x && players[i].mo->_f_Y() == y) + if (players[i].mo && players[i].mo->X() == spot.X && players[i].mo->Y() == spot.Y) return false; return true; } - oldz = players[playernum].mo->_f_Z(); // [RH] Need to save corpse's z-height - players[playernum].mo->_f_SetZ(z); // [RH] Checks are now full 3-D + oldz = players[playernum].mo->Z(); // [RH] Need to save corpse's z-height + players[playernum].mo->SetZ(spot.Z); // [RH] Checks are now full 3-D // killough 4/2/98: fix bug where P_CheckPosition() uses a non-solid // corpse to detect collisions with other players in DM starts @@ -1459,9 +1455,9 @@ bool G_CheckSpot (int playernum, FPlayerStart *mthing) // return false; players[playernum].mo->flags |= MF_SOLID; - i = P_CheckPosition(players[playernum].mo, x, y); + i = P_CheckPosition(players[playernum].mo, spot); players[playernum].mo->flags &= ~MF_SOLID; - players[playernum].mo->_f_SetZ(oldz); // [RH] Restore corpse's height + players[playernum].mo->SetZ(oldz); // [RH] Restore corpse's height if (!i) return false; diff --git a/src/g_level.cpp b/src/g_level.cpp index f0355edf2..5aa65ce3b 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1228,7 +1228,7 @@ void G_FinishTravel () { Printf(TEXTCOLOR_RED "No player %d start to travel to!\n", pnum + 1); // Move to the coordinates this player had when they left the level. - pawn->SetXYZ(pawndup->_f_X(), pawndup->_f_Y(), pawndup->_f_Z()); + pawn->SetXYZ(pawndup->Pos()); } } oldpawn = pawndup; diff --git a/src/gi.cpp b/src/gi.cpp index 9ade879df..313df4f0b 100644 --- a/src/gi.cpp +++ b/src/gi.cpp @@ -140,13 +140,6 @@ const char* GameInfoBorders[] = gameinfo.key = sc.Float; \ } -#define GAMEINFOKEY_FIXED(key, variable) \ - else if(nextKey.CompareNoCase(variable) == 0) \ - { \ - sc.MustGetFloat(); \ - gameinfo.key = static_cast (sc.Float*FRACUNIT); \ - } - #define GAMEINFOKEY_COLOR(key, variable) \ else if(nextKey.CompareNoCase(variable) == 0) \ { \ @@ -318,7 +311,7 @@ void FMapInfoParser::ParseGameInfo() GAMEINFOKEY_STRING(quitSound, "quitSound") GAMEINFOKEY_STRING(BorderFlat, "borderFlat") GAMEINFOKEY_DOUBLE(telefogheight, "telefogheight") - GAMEINFOKEY_FIXED(gibfactor, "gibfactor") + GAMEINFOKEY_DOUBLE(gibfactor, "gibfactor") GAMEINFOKEY_INT(defKickback, "defKickback") GAMEINFOKEY_STRING(SkyFlatName, "SkyFlatName") GAMEINFOKEY_STRING(translator, "translator") diff --git a/src/gi.h b/src/gi.h index 223aee2d0..2786b3425 100644 --- a/src/gi.h +++ b/src/gi.h @@ -163,7 +163,7 @@ struct gameinfo_t FName mFontColorHighlight; FName mFontColorSelection; FString mBackButton; - fixed_t gibfactor; + double gibfactor; int TextScreenX; int TextScreenY; FName DefaultEndSequence; diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index bb74986cc..3ba00721e 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -324,12 +324,8 @@ static int P_Set3DFloor(line_t * line, int param, int param2, int alpha) void P_PlayerOnSpecial3DFloor(player_t* player) { - sector_t * sector = player->mo->Sector; - - for(unsigned i=0;ie->XFloor.ffloors.Size();i++) + for(auto rover : player->mo->Sector->e->XFloor.ffloors) { - F3DFloor* rover=sector->e->XFloor.ffloors[i]; - if (!(rover->flags & FF_EXISTS)) continue; if (rover->flags & FF_FIX) continue; @@ -337,13 +333,13 @@ void P_PlayerOnSpecial3DFloor(player_t* player) if(rover->flags & FF_SOLID) { // Player must be on top of the floor to be affected... - if(player->mo->_f_Z() != rover->top.plane->ZatPoint(player->mo)) continue; + if(player->mo->Z() != rover->top.plane->ZatPointF(player->mo)) continue; } else { //Water and DEATH FOG!!! heh - if (player->mo->_f_Z() > rover->top.plane->ZatPoint(player->mo) || - player->mo->_f_Top() < rover->bottom.plane->ZatPoint(player->mo)) + if (player->mo->Z() > rover->top.plane->ZatPointF(player->mo) || + player->mo->Top() < rover->bottom.plane->ZatPointF(player->mo)) continue; } @@ -366,19 +362,15 @@ void P_PlayerOnSpecial3DFloor(player_t* player) //========================================================================== bool P_CheckFor3DFloorHit(AActor * mo) { - sector_t * sector = mo->Sector; - if ((mo->player && (mo->player->cheats & CF_PREDICTING))) return false; - for(unsigned i=0;ie->XFloor.ffloors.Size();i++) + for (auto rover : mo->Sector->e->XFloor.ffloors) { - F3DFloor* rover=sector->e->XFloor.ffloors[i]; - if (!(rover->flags & FF_EXISTS)) continue; if(rover->flags & FF_SOLID && rover->model->SecActTarget) { - if(mo->_f_floorz() == rover->top.plane->ZatPoint(mo)) + if(mo->Z() == rover->top.plane->ZatPointF(mo)) { rover->model->SecActTarget->TriggerAction (mo, SECSPAC_HitFloor); return true; @@ -396,19 +388,15 @@ bool P_CheckFor3DFloorHit(AActor * mo) //========================================================================== bool P_CheckFor3DCeilingHit(AActor * mo) { - sector_t * sector = mo->Sector; - if ((mo->player && (mo->player->cheats & CF_PREDICTING))) return false; - for(unsigned i=0;ie->XFloor.ffloors.Size();i++) + for (auto rover : mo->Sector->e->XFloor.ffloors) { - F3DFloor* rover=sector->e->XFloor.ffloors[i]; - if (!(rover->flags & FF_EXISTS)) continue; if(rover->flags & FF_SOLID && rover->model->SecActTarget) { - if(mo->_f_ceilingz() == rover->bottom.plane->ZatPoint(mo)) + if(mo->Top() == rover->bottom.plane->ZatPointF(mo)) { rover->model->SecActTarget->TriggerAction (mo, SECSPAC_HitCeiling); return true; diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 76aa87127..b64b4777d 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3349,7 +3349,6 @@ void AActor::Tick () AActor *onmo; - int i; //assert (state != NULL); if (state == NULL) @@ -6474,7 +6473,7 @@ int AActor::GetGibHealth() const } else { - return -FixedMul(SpawnHealth(), gameinfo.gibfactor); + return -int(SpawnHealth() * gameinfo.gibfactor); } } From 35bb686281cee1dd91972c9646b5d5437186101e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Mar 2016 09:38:58 +0100 Subject: [PATCH 14/44] - floatification of sector_t::centerspot. --- src/am_map.cpp | 4 ++-- src/fragglescript/t_func.cpp | 8 ++++---- src/p_3dfloors.cpp | 20 ++++++++++---------- src/p_floor.cpp | 20 ++++++++++---------- src/p_pillar.cpp | 12 ++++++------ src/p_setup.cpp | 8 ++++---- src/r_bsp.cpp | 8 ++++---- src/r_defs.h | 11 ++++++++--- src/s_sound.cpp | 8 ++++---- 9 files changed, 52 insertions(+), 47 deletions(-) diff --git a/src/am_map.cpp b/src/am_map.cpp index 1189ec3a7..a07556ccc 100644 --- a/src/am_map.cpp +++ b/src/am_map.cpp @@ -1962,8 +1962,8 @@ void AM_drawSubsectors() } else { - secx = FIXED2DBL(sec->centerspot.x); - secy = FIXED2DBL(sec->centerspot.y); + secx = sec->centerspot.X; + secy = sec->centerspot.Y; } seczb = floorplane->ZatPoint(secx, secy); seczt = sec->ceilingplane.ZatPoint(secx, secy); diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 85d5a102a..f045bf3b7 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -1595,7 +1595,7 @@ void FParser::SF_FloorHeight(void) DFloorChanger * f = new DFloorChanger(§ors[i]); if (!f->Move( abs(dest - sectors[i].CenterFloor()), - sectors[i].floorplane.PointToDist (sectors[i].centerspot, dest), + sectors[i].floorplane.PointToDist (sectors[i]._f_centerspot(), dest), crush? 10:-1, (dest > sectors[i].CenterFloor()) ? 1 : -1)) { @@ -1679,7 +1679,7 @@ void FParser::SF_MoveFloor(void) // Don't start a second thinker on the same floor if (sec->floordata) continue; - new DMoveFloor(sec,sec->floorplane.PointToDist(sec->centerspot,destheight), + new DMoveFloor(sec,sec->floorplane.PointToDist(sec->_f_centerspot(),destheight), destheight < sec->CenterFloor() ? -1:1,crush,platspeed); } } @@ -1743,7 +1743,7 @@ void FParser::SF_CeilingHeight(void) DCeilingChanger * c = new DCeilingChanger(§ors[i]); if (!c->Move( abs(dest - sectors[i].CenterCeiling()), - sectors[i].ceilingplane.PointToDist (sectors[i].centerspot, dest), + sectors[i].ceilingplane.PointToDist (sectors[i]._f_centerspot(), dest), crush? 10:-1, (dest > sectors[i].CenterCeiling()) ? 1 : -1)) { @@ -1787,7 +1787,7 @@ public: m_Silent = silent; m_Type = DCeiling::ceilLowerByValue; // doesn't really matter as long as it's no special value m_Tag=tag; - m_TopHeight=m_BottomHeight=sec->ceilingplane.PointToDist(sec->centerspot,destheight); + m_TopHeight=m_BottomHeight=sec->ceilingplane.PointToDist(sec->_f_centerspot(),destheight); m_Direction=destheight>sec->GetPlaneTexZ(sector_t::ceiling)? 1:-1; // Do not interpolate instant movement ceilings. diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index 3ba00721e..ea5573b0d 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -464,13 +464,13 @@ void P_Recalculate3DFloors(sector_t * sector) while (oldlist.Size()) { pick=oldlist[0]; - fixed_t height=pick->top.plane->ZatPoint(sector->centerspot); + fixed_t height=pick->top.plane->ZatPoint(sector->_f_centerspot()); // find highest starting ffloor - intersections are not supported! pickindex=0; for (j=1;jtop.plane->ZatPoint(sector->centerspot); + fixed_t h2=oldlist[j]->top.plane->ZatPoint(sector->_f_centerspot()); if (h2>height) { @@ -481,7 +481,7 @@ void P_Recalculate3DFloors(sector_t * sector) } oldlist.Delete(pickindex); - fixed_t pick_bottom=pick->bottom.plane->ZatPoint(sector->centerspot); + fixed_t pick_bottom=pick->bottom.plane->ZatPoint(sector->_f_centerspot()); if (pick->flags & FF_THISINSIDE) { @@ -595,7 +595,7 @@ void P_Recalculate3DFloors(sector_t * sector) if ( !(rover->flags & FF_EXISTS) || rover->flags & FF_NOSHADE ) continue; - fixed_t ff_top=rover->top.plane->ZatPoint(sector->centerspot); + fixed_t ff_top=rover->top.plane->ZatPoint(sector->_f_centerspot()); if (ff_top < minheight) break; // reached the floor if (ff_top < maxheight) { @@ -610,7 +610,7 @@ void P_Recalculate3DFloors(sector_t * sector) } else { - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->centerspot); + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->_f_centerspot()); if (ff_bottomflags&FF_DOUBLESHADOW) { - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->centerspot); + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->_f_centerspot()); if(ff_bottom < maxheight && ff_bottom>minheight) { newlight.caster = rover; @@ -724,11 +724,11 @@ lightlist_t * P_GetPlaneLight(sector_t * sector, secplane_t * plane, bool unders unsigned i; TArray &lightlist = sector->e->XFloor.lightlist; - fixed_t planeheight=plane->ZatPoint(sector->centerspot); + fixed_t planeheight=plane->ZatPoint(sector->_f_centerspot()); if(underside) planeheight--; for(i = 1; i < lightlist.Size(); i++) - if (lightlist[i].plane.ZatPoint(sector->centerspot) <= planeheight) + if (lightlist[i].plane.ZatPoint(sector->_f_centerspot()) <= planeheight) return &lightlist[i - 1]; return &lightlist[lightlist.Size() - 1]; @@ -989,8 +989,8 @@ CCMD (dump3df) for (unsigned int i = 0; i < ffloors.Size(); i++) { - fixed_t height=ffloors[i]->top.plane->ZatPoint(sector->centerspot); - fixed_t bheight=ffloors[i]->bottom.plane->ZatPoint(sector->centerspot); + fixed_t height=ffloors[i]->top.plane->ZatPoint(sector->_f_centerspot()); + fixed_t bheight=ffloors[i]->bottom.plane->ZatPoint(sector->_f_centerspot()); IGNORE_FORMAT_PRE Printf("FFloor %d @ top = %f (model = %d), bottom = %f (model = %d), flags = %B, alpha = %d %s %s\n", diff --git a/src/p_floor.cpp b/src/p_floor.cpp index 593328c93..3bda1e44e 100644 --- a/src/p_floor.cpp +++ b/src/p_floor.cpp @@ -344,7 +344,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, case DFloor::floorLowerByValue: floor->m_Direction = -1; newheight = sec->CenterFloor() - height; - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); + floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), newheight); break; case DFloor::floorRaiseInstant: @@ -352,7 +352,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, case DFloor::floorRaiseByValue: floor->m_Direction = 1; newheight = sec->CenterFloor() + height; - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); + floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), newheight); break; case DFloor::floorMoveToValue: @@ -413,7 +413,7 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, case DFloor::floorLowerByTexture: floor->m_Direction = -1; newheight = sec->CenterFloor() - sec->FindShortestTextureAround (); - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); + floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), newheight); break; case DFloor::floorLowerToCeiling: @@ -430,13 +430,13 @@ bool EV_DoFloor (DFloor::EFloor floortype, line_t *line, int tag, // enough, BOOM preserved the code here even though it // also had this function.) newheight = sec->CenterFloor() + sec->FindShortestTextureAround (); - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); + floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), newheight); break; case DFloor::floorRaiseAndChange: floor->m_Direction = 1; newheight = sec->CenterFloor() + height; - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, newheight); + floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), newheight); if (line != NULL) { FTextureID oldpic = sec->GetTexture(sector_t::floor); @@ -620,7 +620,7 @@ bool EV_BuildStairs (int tag, DFloor::EStair type, line_t *line, floor->m_Speed = speed; height = sec->CenterFloor() + stairstep; - floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, height); + floor->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), height); texture = sec->GetTexture(sector_t::floor); osecnum = secnum; //jff 3/4/98 preserve loop index @@ -1037,15 +1037,15 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype, // [RH] elevate up by a specific amount case DElevator::elevateRaise: elevator->m_Direction = 1; - elevator->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, floorheight + height); - elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (sec->centerspot, ceilingheight + height); + elevator->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), floorheight + height); + elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (sec->_f_centerspot(), ceilingheight + height); break; // [RH] elevate down by a specific amount case DElevator::elevateLower: elevator->m_Direction = -1; - elevator->m_FloorDestDist = sec->floorplane.PointToDist (sec->centerspot, floorheight - height); - elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (sec->centerspot, ceilingheight - height); + elevator->m_FloorDestDist = sec->floorplane.PointToDist (sec->_f_centerspot(), floorheight - height); + elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (sec->_f_centerspot(), ceilingheight - height); break; } } diff --git a/src/p_pillar.cpp b/src/p_pillar.cpp index b28d517e5..07155a167 100644 --- a/src/p_pillar.cpp +++ b/src/p_pillar.cpp @@ -144,15 +144,15 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed, if (floordist == 0) { newheight = (sector->CenterFloor () + sector->CenterCeiling ()) / 2; - m_FloorTarget = sector->floorplane.PointToDist (sector->centerspot, newheight); - m_CeilingTarget = sector->ceilingplane.PointToDist (sector->centerspot, newheight); + m_FloorTarget = sector->floorplane.PointToDist (sector->_f_centerspot(), newheight); + m_CeilingTarget = sector->ceilingplane.PointToDist (sector->_f_centerspot(), newheight); floordist = newheight - sector->CenterFloor (); } else { newheight = sector->CenterFloor () + floordist; - m_FloorTarget = sector->floorplane.PointToDist (sector->centerspot, newheight); - m_CeilingTarget = sector->ceilingplane.PointToDist (sector->centerspot, newheight); + m_FloorTarget = sector->floorplane.PointToDist (sector->_f_centerspot(), newheight); + m_CeilingTarget = sector->ceilingplane.PointToDist (sector->_f_centerspot(), newheight); } ceilingdist = sector->CenterCeiling () - newheight; } @@ -169,7 +169,7 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed, else { newheight = sector->CenterFloor() - floordist; - m_FloorTarget = sector->floorplane.PointToDist (sector->centerspot, newheight); + m_FloorTarget = sector->floorplane.PointToDist (sector->_f_centerspot(), newheight); } if (ceilingdist == 0) { @@ -180,7 +180,7 @@ DPillar::DPillar (sector_t *sector, EPillar type, fixed_t speed, else { newheight = sector->CenterCeiling() + ceilingdist; - m_CeilingTarget = sector->ceilingplane.PointToDist (sector->centerspot, newheight); + m_CeilingTarget = sector->ceilingplane.PointToDist (sector->_f_centerspot(), newheight); } } diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 067075ee7..3c096a5f0 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -3223,8 +3223,8 @@ static void P_GroupLines (bool buildmap) } // set the center to the middle of the bounding box - sector->centerspot.x = bbox.Right()/2 + bbox.Left()/2; - sector->centerspot.y = bbox.Top()/2 + bbox.Bottom()/2; + sector->centerspot.X = FIXED2DBL(bbox.Right()/2 + bbox.Left()/2); + sector->centerspot.Y = FIXED2DBL(bbox.Top()/2 + bbox.Bottom()/2); // For triangular sectors the above does not calculate good points unless the longest of the triangle's lines is perfectly horizontal and vertical if (sector->linecount == 3) @@ -3246,8 +3246,8 @@ static void P_GroupLines (bool buildmap) if (DMulScale32 (v->y - Triangle[0]->y, dx, Triangle[0]->x - v->x, dy) != 0) { - sector->centerspot.x = Triangle[0]->x / 3 + Triangle[1]->x / 3 + v->x / 3; - sector->centerspot.y = Triangle[0]->y / 3 + Triangle[1]->y / 3 + v->y / 3; + sector->centerspot.X = FIXED2DBL(Triangle[0]->x / 3 + Triangle[1]->x / 3 + v->x / 3); + sector->centerspot.Y = FIXED2DBL(Triangle[0]->y / 3 + Triangle[1]->y / 3 + v->y / 3); break; } } diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 16bbce41e..42745f8d7 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -1182,9 +1182,9 @@ void R_Subsector (subsector_t *sub) fakeFloor->validcount = validcount; R_3D_NewClip(); } - fakeHeight = fakeFloor->top.plane->ZatPoint(frontsector->centerspot); + fakeHeight = FLOAT2FIXED(fakeFloor->top.plane->ZatPoint(frontsector->centerspot)); if (fakeHeight < viewz && - fakeHeight > frontsector->floorplane.ZatPoint(frontsector->centerspot)) + fakeHeight > FLOAT2FIXED(frontsector->floorplane.ZatPoint(frontsector->centerspot))) { fake3D = FAKE3D_FAKEFLOOR; tempsec = *fakeFloor->model; @@ -1244,9 +1244,9 @@ void R_Subsector (subsector_t *sub) fakeFloor->validcount = validcount; R_3D_NewClip(); } - fakeHeight = fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot); + fakeHeight = FLOAT2FIXED(fakeFloor->bottom.plane->ZatPoint(frontsector->centerspot)); if (fakeHeight > viewz && - fakeHeight < frontsector->ceilingplane.ZatPoint(frontsector->centerspot)) + fakeHeight < FLOAT2FIXED(frontsector->ceilingplane.ZatPoint(frontsector->centerspot))) { fake3D = FAKE3D_FAKECEILING; tempsec = *fakeFloor->model; diff --git a/src/r_defs.h b/src/r_defs.h index a183e78af..6985d174b 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -930,8 +930,8 @@ struct sector_t } // Member variables - fixed_t CenterFloor () const { return floorplane.ZatPoint (centerspot); } - fixed_t CenterCeiling () const { return ceilingplane.ZatPoint (centerspot); } + fixed_t CenterFloor () const { return floorplane.ZatPoint (_f_centerspot()); } + fixed_t CenterCeiling () const { return ceilingplane.ZatPoint (_f_centerspot()); } // [RH] store floor and ceiling planes instead of heights secplane_t floorplane, ceilingplane; @@ -949,10 +949,15 @@ struct sector_t int sky; FNameNoInit SeqName; // Sound sequence name. Setting seqType non-negative will override this. - fixedvec2 centerspot; // origin for any sounds played by the sector + DVector2 centerspot; // origin for any sounds played by the sector int validcount; // if == validcount, already checked AActor* thinglist; // list of mobjs in sector + fixedvec2 _f_centerspot() const + { + return{ FLOAT2FIXED(centerspot.X), FLOAT2FIXED(centerspot.Y) }; + } + // killough 8/28/98: friction is a sector property, not an mobj property. // these fields used to be in AActor, but presented performance problems // when processed as mobj properties. Fix is to make them sector properties. diff --git a/src/s_sound.cpp b/src/s_sound.cpp index a7e289152..1c85f3d97 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -709,8 +709,8 @@ static void CalcPosVel(int type, const AActor *actor, const sector_t *sector, } else { - x = sector->centerspot.x; - z = sector->centerspot.y; + x = sector->_f_centerspot().x; + z = sector->_f_centerspot().y; chanflags |= CHAN_LISTENERZ; } } @@ -777,8 +777,8 @@ static void CalcSectorSoundOrg(const sector_t *sec, int channum, fixed_t *x, fix } else { - *x = sec->centerspot.x; - *y = sec->centerspot.y; + *x = sec->_f_centerspot().x; + *y = sec->_f_centerspot().y; } // Set sound vertical position based on channel. From dabed04d2a376e07043bea59cb7a2cd51d153825 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Mar 2016 12:36:15 +0100 Subject: [PATCH 15/44] - floatification of p_3dfloors, p_3dmidtex and p_acs.cpp plus some leftovers. - removed all references to Doom specific headers from xs_Float.h and cmath.h. --- src/basictypes.h | 6 +- src/fragglescript/t_oper.cpp | 5 +- src/math/cmath.h | 28 +++-- src/math/fastsin.cpp | 6 +- src/p_3dfloors.cpp | 69 +++++------ src/p_3dfloors.h | 19 +-- src/p_3dmidtex.cpp | 34 ++---- src/p_3dmidtex.h | 2 +- src/p_acs.cpp | 96 +++++++-------- src/p_acs.h | 4 +- src/p_effect.cpp | 27 ++--- src/p_effect.h | 7 +- src/p_enemy.cpp | 8 +- src/p_lnspec.cpp | 221 ++++++++++++++++++----------------- src/p_local.h | 3 +- src/p_maputl.cpp | 4 +- src/p_mobj.cpp | 2 +- src/p_switch.cpp | 6 +- src/p_things.cpp | 4 +- src/p_writemap.cpp | 4 +- src/r_defs.h | 17 +++ src/tables.h | 2 +- src/textures/textures.h | 1 - src/vectors.h | 6 +- src/win32/fb_d3d9.cpp | 4 +- src/xs_Float.h | 69 ++++++----- 26 files changed, 319 insertions(+), 335 deletions(-) diff --git a/src/basictypes.h b/src/basictypes.h index 13be07b9f..e06e49494 100644 --- a/src/basictypes.h +++ b/src/basictypes.h @@ -12,10 +12,6 @@ typedef uint32_t uint32; typedef int64_t SQWORD; typedef uint64_t QWORD; -typedef SDWORD int32; -typedef float real32; -typedef double real64; - // windef.h, included by windows.h, has its own incompatible definition // of DWORD as a long. In files that mix Doom and Windows code, you // must define USE_WINDOWS_DWORD before including doomtype.h so that @@ -62,7 +58,7 @@ union QWORD_UNION }; // -// Fixed point, 32bit as 16.16. +// fixed point, 32bit as 16.16. // #define FRACBITS 16 #define FRACUNIT (1< #include "cmath.h" -#include "m_fixed.h" + + +#ifndef M_PI +#define M_PI 3.14159265358979323846 +#endif FFastTrig fasttrig; diff --git a/src/p_3dfloors.cpp b/src/p_3dfloors.cpp index ea5573b0d..c87d61817 100644 --- a/src/p_3dfloors.cpp +++ b/src/p_3dfloors.cpp @@ -422,10 +422,10 @@ void P_Recalculate3DFloors(sector_t * sector) unsigned pickindex; F3DFloor * clipped=NULL; F3DFloor * solid=NULL; - fixed_t solid_bottom=0; - fixed_t clipped_top; - fixed_t clipped_bottom=0; - fixed_t maxheight, minheight; + double solid_bottom=0; + double clipped_top; + double clipped_bottom=0; + double maxheight, minheight; unsigned i, j; lightlist_t newlight; lightlist_t resetlight; // what it goes back to after FF_DOUBLESHADOW @@ -464,13 +464,13 @@ void P_Recalculate3DFloors(sector_t * sector) while (oldlist.Size()) { pick=oldlist[0]; - fixed_t height=pick->top.plane->ZatPoint(sector->_f_centerspot()); + double height=pick->top.plane->ZatPoint(sector->centerspot); // find highest starting ffloor - intersections are not supported! pickindex=0; for (j=1;jtop.plane->ZatPoint(sector->_f_centerspot()); + double h2=oldlist[j]->top.plane->ZatPoint(sector->centerspot); if (h2>height) { @@ -481,7 +481,7 @@ void P_Recalculate3DFloors(sector_t * sector) } oldlist.Delete(pickindex); - fixed_t pick_bottom=pick->bottom.plane->ZatPoint(sector->_f_centerspot()); + double pick_bottom=pick->bottom.plane->ZatPoint(sector->centerspot); if (pick->flags & FF_THISINSIDE) { @@ -586,8 +586,8 @@ void P_Recalculate3DFloors(sector_t * sector) resetlight = lightlist[0]; - maxheight = sector->CenterCeiling(); - minheight = sector->CenterFloor(); + maxheight = sector->ceilingplane.ZatPoint(sector->centerspot); + minheight = sector->floorplane.ZatPoint(sector->centerspot); for(i = 0; i < ffloors.Size(); i++) { rover=ffloors[i]; @@ -595,7 +595,7 @@ void P_Recalculate3DFloors(sector_t * sector) if ( !(rover->flags & FF_EXISTS) || rover->flags & FF_NOSHADE ) continue; - fixed_t ff_top=rover->top.plane->ZatPoint(sector->_f_centerspot()); + double ff_top=rover->top.plane->ZatPoint(sector->centerspot); if (ff_top < minheight) break; // reached the floor if (ff_top < maxheight) { @@ -610,7 +610,7 @@ void P_Recalculate3DFloors(sector_t * sector) } else { - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->_f_centerspot()); + double ff_bottom=rover->bottom.plane->ZatPoint(sector->centerspot); if (ff_bottomflags&FF_DOUBLESHADOW) { - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sector->_f_centerspot()); + double ff_bottom=rover->bottom.plane->ZatPoint(sector->centerspot); if(ff_bottom < maxheight && ff_bottom>minheight) { newlight.caster = rover; @@ -724,11 +724,11 @@ lightlist_t * P_GetPlaneLight(sector_t * sector, secplane_t * plane, bool unders unsigned i; TArray &lightlist = sector->e->XFloor.lightlist; - fixed_t planeheight=plane->ZatPoint(sector->_f_centerspot()); + double planeheight=plane->ZatPoint(sector->centerspot); if(underside) planeheight--; for(i = 1; i < lightlist.Size(); i++) - if (lightlist[i].plane.ZatPoint(sector->_f_centerspot()) <= planeheight) + if (lightlist[i].plane.ZatPoint(sector->centerspot) <= planeheight) return &lightlist[i - 1]; return &lightlist[lightlist.Size() - 1]; @@ -851,12 +851,6 @@ void P_Spawn3DFloors (void) switch(line->special) { case ExtraFloor_LightOnly: - // Note: I am spawning both this and ZDoom's ExtraLight data - // I don't want to mess with both at the same time during rendering - // so inserting this into the 3D-floor table as well seemed to be - // the best option. - // - // This does not yet handle case 0 properly! if (line->args[1] < 0 || line->args[1] > 2) line->args[1] = 0; P_Set3DFloor(line, 3, flagvals[line->args[1]], 0); break; @@ -900,17 +894,16 @@ void P_Spawn3DFloors (void) // //========================================================================== -secplane_t P_FindFloorPlane(sector_t * sector, fixed_t x, fixed_t y, fixed_t z) +secplane_t P_FindFloorPlane(sector_t * sector, const DVector3 &pos) { secplane_t retplane = sector->floorplane; if (sector->e) // apparently this can be called when the data is already gone { - for(unsigned int i=0;ie->XFloor.ffloors.Size();i++) + for(auto rover : sector->e->XFloor.ffloors) { - F3DFloor * rover= sector->e->XFloor.ffloors[i]; if(!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - if (rover->top.plane->ZatPoint(x, y) == z) + if (rover->top.plane->ZatPoint(pos) == pos.Z) { retplane = *rover->top.plane; if (retplane.c<0) retplane.FlipVert(); @@ -928,20 +921,20 @@ 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) +int P_Find3DFloor(sector_t * sec, const DVector3 &pos, bool above, bool floor, double &cmpz) { // If no sector given, find the one appropriate if (sec == NULL) - sec = R_PointInSubsector(x, y)->sector; + sec = P_PointInSector(pos); // Above normal ceiling - cmpz = sec->ceilingplane.ZatPoint(x, y); - if (z >= cmpz) + cmpz = sec->ceilingplane.ZatPoint(pos); + if (pos.Z >= cmpz) return -1; // Below normal floor - cmpz = sec->floorplane.ZatPoint(x, y); - if (z <= cmpz) + cmpz = sec->floorplane.ZatPoint(pos); + if (pos.Z <= cmpz) return -1; // Looking through planes from top to bottom @@ -955,19 +948,19 @@ int P_Find3DFloor(sector_t * sec, fixed_t x, fixed_t y, fixed_t z, bool above, b if (above) { // z is above that floor - if (floor && (z >= (cmpz = rover->top.plane->ZatPoint(x, y)))) + if (floor && (pos.Z >= (cmpz = rover->top.plane->ZatPoint(pos)))) return i - 1; // z is above that ceiling - if (z >= (cmpz = rover->bottom.plane->ZatPoint(x, y))) + if (pos.Z >= (cmpz = rover->bottom.plane->ZatPoint(pos))) return i - 1; } else // below { // z is below that ceiling - if (!floor && (z <= (cmpz = rover->bottom.plane->ZatPoint(x, y)))) + if (!floor && (pos.Z <= (cmpz = rover->bottom.plane->ZatPoint(pos)))) return i; // z is below that floor - if (z <= (cmpz = rover->top.plane->ZatPoint(x, y))) + if (pos.Z <= (cmpz = rover->top.plane->ZatPoint(pos))) return i; } } @@ -989,13 +982,13 @@ CCMD (dump3df) for (unsigned int i = 0; i < ffloors.Size(); i++) { - fixed_t height=ffloors[i]->top.plane->ZatPoint(sector->_f_centerspot()); - fixed_t bheight=ffloors[i]->bottom.plane->ZatPoint(sector->_f_centerspot()); + double height=ffloors[i]->top.plane->ZatPoint(sector->centerspot); + double bheight=ffloors[i]->bottom.plane->ZatPoint(sector->centerspot); IGNORE_FORMAT_PRE Printf("FFloor %d @ top = %f (model = %d), bottom = %f (model = %d), flags = %B, alpha = %d %s %s\n", - i, height / 65536., ffloors[i]->top.model->sectornum, - bheight / 65536., ffloors[i]->bottom.model->sectornum, + i, height, ffloors[i]->top.model->sectornum, + bheight, ffloors[i]->bottom.model->sectornum, ffloors[i]->flags, ffloors[i]->alpha, (ffloors[i]->flags&FF_EXISTS)? "Exists":"", (ffloors[i]->flags&FF_DYNAMIC)? "Dynamic":""); IGNORE_FORMAT_POST } diff --git a/src/p_3dfloors.h b/src/p_3dfloors.h index 3ec2ab202..02e25f882 100644 --- a/src/p_3dfloors.h +++ b/src/p_3dfloors.h @@ -86,8 +86,6 @@ struct F3DFloor short *toplightlevel; - fixed_t delta; - unsigned int flags; line_t* master; @@ -125,7 +123,6 @@ struct lightlist_t class player_s; void P_PlayerOnSpecial3DFloor(player_t* player); -void P_Get3DFloorAndCeiling(AActor * thing, sector_t * sector, fixed_t * floorz, fixed_t * ceilingz, int * floorpic); bool P_CheckFor3DFloorHit(AActor * mo); bool P_CheckFor3DCeilingHit(AActor * mo); void P_Recalculate3DFloors(sector_t *); @@ -141,19 +138,7 @@ struct FLineOpening; void P_LineOpening_XFloors (FLineOpening &open, AActor * thing, const line_t *linedef, double x, double y, bool restrict); -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); -} -inline int P_Find3DFloor(sector_t * sec, const DVector3 &pos, bool above, bool floor, double &cmpz) -{ - fixed_t fr = FLOAT2FIXED(cmpz); - int ret = P_Find3DFloor(sec, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), above, floor, fr); - cmpz = FIXED2DBL(fr); - return ret; -} - +secplane_t P_FindFloorPlane(sector_t * sector, const DVector3 &pos); +int P_Find3DFloor(sector_t * sec, const DVector3 &pos, bool above, bool floor, double &cmpz); #endif \ No newline at end of file diff --git a/src/p_3dmidtex.cpp b/src/p_3dmidtex.cpp index 8b1e5aabb..fda17dc84 100644 --- a/src/p_3dmidtex.cpp +++ b/src/p_3dmidtex.cpp @@ -221,7 +221,7 @@ void P_Attach3dMidtexLinesToSector(sector_t *sector, int lineid, int tag, bool c // Retrieves top and bottom of the current line's mid texture. // //============================================================================ -bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, fixed_t *ptexbot) +bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, double *ptexbot) { if (line->sidedef[0]==NULL || line->sidedef[1]==NULL) return false; @@ -231,45 +231,31 @@ bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, f FTexture * tex= TexMan(texnum); if (!tex) return false; - double totalscale = fabs(FIXED2DBL(side->GetTextureYScale(side_t::mid)) * tex->GetScaleY()); - fixed_t y_offset = side->GetTextureYOffset(side_t::mid); - fixed_t textureheight = tex->GetScaledHeight(totalscale) << FRACBITS; + double totalscale = fabs(side->GetTextureYScaleF(side_t::mid)) * tex->GetScaleY(); + double y_offset = side->GetTextureYOffsetF(side_t::mid); + double textureheight = tex->GetHeight() / totalscale; if (totalscale != 1. && !tex->bWorldPanning) { - y_offset = fixed_t(y_offset * totalscale); + y_offset *= totalscale; } if(line->flags & ML_DONTPEGBOTTOM) { *ptexbot = y_offset + - MAX(line->frontsector->GetPlaneTexZ(sector_t::floor), line->backsector->GetPlaneTexZ(sector_t::floor)); + MAX(line->frontsector->GetPlaneTexZF(sector_t::floor), line->backsector->GetPlaneTexZF(sector_t::floor)); *ptextop = *ptexbot + textureheight; } else { *ptextop = y_offset + - MIN(line->frontsector->GetPlaneTexZ(sector_t::ceiling), line->backsector->GetPlaneTexZ(sector_t::ceiling)); + MIN(line->frontsector->GetPlaneTexZF(sector_t::ceiling), line->backsector->GetPlaneTexZF(sector_t::ceiling)); *ptexbot = *ptextop - textureheight; } return true; } - -bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, double *ptexbot) -{ - fixed_t t, b; - if (P_GetMidTexturePosition(line, sideno, &t, &b)) - { - *ptextop = FIXED2DBL(t); - *ptexbot = FIXED2DBL(b); - return true; - } - return false; -} - - //============================================================================ // // P_LineOpening_3dMidtex @@ -308,8 +294,8 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening & open.abovemidtex = true; open.floorpic = linedef->sidedef[0]->GetTexture(side_t::mid); open.floorterrain = TerrainTypes[open.floorpic]; - open.frontfloorplane.SetAtHeight(FLOAT2FIXED(tt), sector_t::floor); - open.backfloorplane.SetAtHeight(FLOAT2FIXED(tt), sector_t::floor); + open.frontfloorplane.SetAtHeight(tt, sector_t::floor); + open.backfloorplane.SetAtHeight(tt, sector_t::floor); } // returns true if it touches the midtexture @@ -321,7 +307,7 @@ bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, FLineOpening & /* still have to figure out what this code from Eternity means... if((linedef->flags & ML_BLOCKMONSTERS) && !(mo->flags & (MF_FLOAT | MF_DROPOFF)) && - D_abs(mo->z - textop) <= 24*FRACUNIT) + fabs(mo->Z() - tt) <= 24) { opentop = openbottom; openrange = 0; diff --git a/src/p_3dmidtex.h b/src/p_3dmidtex.h index d308f4f3c..641e057ee 100644 --- a/src/p_3dmidtex.h +++ b/src/p_3dmidtex.h @@ -12,7 +12,7 @@ class AActor; bool P_Scroll3dMidtex(sector_t *sector, int crush, fixed_t move, bool ceiling); void P_Start3dMidtexInterpolations(TArray &list, sector_t *sec, bool ceiling); void P_Attach3dMidtexLinesToSector(sector_t *dest, int lineid, int tag, bool ceiling); -bool P_GetMidTexturePosition(const line_t *line, int sideno, fixed_t *ptextop, fixed_t *ptexbot); +bool P_GetMidTexturePosition(const line_t *line, int sideno, double *ptextop, double *ptexbot); bool P_Check3dMidSwitch(AActor *actor, line_t *line, int side); bool P_LineOpening_3dMidtex(AActor *thing, const line_t *linedef, struct FLineOpening &open, bool restrict=false); diff --git a/src/p_acs.cpp b/src/p_acs.cpp index 3ea923542..d9ae0c358 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -175,7 +175,7 @@ inline DAngle ACSToAngle(int acsval) inline int AngleToACS(DAngle ang) { - xs_CRoundToInt(ang.Degrees * (65536. / 360.)); + return ang.BAMs() >> 16; } struct CallReturn @@ -722,7 +722,7 @@ void ACSStringPool::ReadStrings(PNGHandle *png, DWORD id) if (len != 0) { FPNGChunkArchive arc(png->File->GetFile(), id, len); - int32 i, j, poolsize; + int32_t i, j, poolsize; unsigned int h, bucketnum; char *str = NULL; @@ -768,7 +768,7 @@ void ACSStringPool::ReadStrings(PNGHandle *png, DWORD id) void ACSStringPool::WriteStrings(FILE *file, DWORD id) const { - int32 i, poolsize = (int32)Pool.Size(); + int32_t i, poolsize = (int32_t)Pool.Size(); if (poolsize == 0) { // No need to write if we don't have anything. @@ -3554,13 +3554,13 @@ int DLevelScript::DoSpawnSpotFacing (int type, int spot, int tid, bool force) return spawned; } -void DLevelScript::DoFadeTo (int r, int g, int b, int a, fixed_t time) +void DLevelScript::DoFadeTo (int r, int g, int b, int a, int time) { - DoFadeRange (0, 0, 0, -1, clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255), clamp(a, 0, FRACUNIT), time); + DoFadeRange (0, 0, 0, -1, clamp(r, 0, 255), clamp(g, 0, 255), clamp(b, 0, 255), clamp(a, 0, 65536), time); } void DLevelScript::DoFadeRange (int r1, int g1, int b1, int a1, - int r2, int g2, int b2, int a2, fixed_t time) + int r2, int g2, int b2, int a2, int time) { player_t *viewer; float ftime = (float)time / 65536.f; @@ -4220,12 +4220,12 @@ bool DLevelScript::DoCheckActorTexture(int tid, AActor *activator, int string, b if (floor) { - actor->Sector->NextLowestFloorAt(actor->_f_X(), actor->_f_Y(), actor->_f_Z(), 0, actor->_f_MaxStepHeight(), &resultsec, &resffloor); + actor->Sector->NextLowestFloorAt(actor->X(), actor->Y(), actor->Z(), 0, actor->MaxStepHeight, &resultsec, &resffloor); secpic = resffloor ? *resffloor->top.texture : resultsec->planes[sector_t::floor].Texture; } else { - actor->Sector->NextHighestCeilingAt(actor->_f_X(), actor->_f_Y(), actor->_f_Z(), actor->_f_Top(), 0, &resultsec, &resffloor); + actor->Sector->NextHighestCeilingAt(actor->X(), actor->Y(), actor->Z(), actor->Top(), 0, &resultsec, &resffloor); secpic = resffloor ? *resffloor->bottom.texture : resultsec->planes[sector_t::ceiling].Texture; } return tex == TexMan[secpic]; @@ -5957,22 +5957,22 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) case ACSF_GetActorRoll: actor = SingleActorFromTID(args[0], activator); - return actor != NULL? actor->Angles.Roll.FixedAngle() : 0; + return actor != NULL? AngleToACS(actor->Angles.Roll) : 0; // [ZK] A_Warp in ACS case ACSF_Warp: { int tid_dest = args[0]; - fixed_t xofs = args[1]; - fixed_t yofs = args[2]; - fixed_t zofs = args[3]; - angle_t angle = args[4]; + int xofs = args[1]; + int yofs = args[2]; + int zofs = args[3]; + int angle = args[4]; int flags = args[5]; const char *statename = argCount > 6 ? FBehavior::StaticLookupString(args[6]) : ""; bool exact = argCount > 7 ? !!args[7] : false; - fixed_t heightoffset = argCount > 8 ? args[8] : 0; - fixed_t radiusoffset = argCount > 9 ? args[9] : 0; - fixed_t pitch = argCount > 10 ? args[10] : 0; + int heightoffset = argCount > 8 ? args[8] : 0; + int radiusoffset = argCount > 9 ? args[9] : 0; + int pitch = argCount > 10 ? args[10] : 0; FState *state = argCount > 6 ? activator->GetClass()->FindStateByString(statename, exact) : 0; @@ -6047,15 +6047,15 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) bool fullbright = argCount > 1 ? !!args[1] : false; int lifetime = argCount > 2 ? args[2] : 35; int size = argCount > 3 ? args[3] : 1; - fixed_t x = argCount > 4 ? args[4] : 0; - fixed_t y = argCount > 5 ? args[5] : 0; - fixed_t z = argCount > 6 ? args[6] : 0; - fixed_t xvel = argCount > 7 ? args[7] : 0; - fixed_t yvel = argCount > 8 ? args[8] : 0; - fixed_t zvel = argCount > 9 ? args[9] : 0; - fixed_t accelx = argCount > 10 ? args[10] : 0; - fixed_t accely = argCount > 11 ? args[11] : 0; - fixed_t accelz = argCount > 12 ? args[12] : 0; + int x = argCount > 4 ? args[4] : 0; + int y = argCount > 5 ? args[5] : 0; + int z = argCount > 6 ? args[6] : 0; + int xvel = argCount > 7 ? args[7] : 0; + int yvel = argCount > 8 ? args[8] : 0; + int zvel = argCount > 9 ? args[9] : 0; + int accelx = argCount > 10 ? args[10] : 0; + int accely = argCount > 11 ? args[11] : 0; + int accelz = argCount > 12 ? args[12] : 0; int startalpha = argCount > 13 ? args[13] : 0xFF; // Byte trans int fadestep = argCount > 14 ? args[14] : -1; @@ -6065,7 +6065,10 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) size = clamp(size, 0, 65535); // Clamp to word if (lifetime != 0) - P_SpawnParticle(x, y, z, xvel, yvel, zvel, color, fullbright, startalpha, lifetime, size, fadestep, accelx, accely, accelz); + P_SpawnParticle(DVector3(ACSToDouble(x), ACSToDouble(y), ACSToDouble(z)), + DVector3(ACSToDouble(xvel), ACSToDouble(yvel), ACSToDouble(zvel)), + DVector3(ACSToDouble(accelx), ACSToDouble(accely), ACSToDouble(accelz)), + color, fullbright, startalpha/255., lifetime, size, fadestep/255.); } break; @@ -8730,21 +8733,21 @@ scriptwait: case PCD_GETACTORANGLE: { AActor *actor = SingleActorFromTID(STACK(1), activator); - STACK(1) = actor == NULL ? 0 : actor->Angles.Yaw.FixedAngle(); + STACK(1) = actor == NULL ? 0 : AngleToACS(actor->Angles.Yaw); } break; case PCD_GETACTORPITCH: { AActor *actor = SingleActorFromTID(STACK(1), activator); - STACK(1) = actor == NULL ? 0 : actor->Angles.Pitch.FixedAngle(); + STACK(1) = actor == NULL ? 0 : AngleToACS(actor->Angles.Pitch); } break; case PCD_GETLINEROWOFFSET: if (activationline != NULL) { - PushToStack (activationline->sidedef[0]->GetTextureYOffset(side_t::mid) >> FRACBITS); + PushToStack (int(activationline->sidedef[0]->GetTextureYOffsetF(side_t::mid))); } else { @@ -8761,28 +8764,27 @@ scriptwait: { int tag = STACK(3); int secnum; - fixed_t x = STACK(2) << FRACBITS; - fixed_t y = STACK(1) << FRACBITS; - fixed_t z = 0; + DVector2 pos(ACSToDouble(STACK(2)), ACSToDouble(STACK(1))); + double z = 0; if (tag != 0) secnum = P_FindFirstSectorFromTag (tag); else - secnum = int(P_PointInSector (x, y) - sectors); + secnum = int(P_PointInSector (pos) - sectors); if (secnum >= 0) { if (pcd == PCD_GETSECTORFLOORZ) { - z = sectors[secnum].floorplane.ZatPoint (x, y); + z = sectors[secnum].floorplane.ZatPoint (pos); } else { - z = sectors[secnum].ceilingplane.ZatPoint (x, y); + z = sectors[secnum].ceilingplane.ZatPoint (pos); } } sp -= 2; - STACK(1) = z; + STACK(1) = DoubleToACS(z); } break; @@ -8863,12 +8865,12 @@ scriptwait: { // translation using desaturation int start = STACK(8); int end = STACK(7); - fixed_t r1 = STACK(6); - fixed_t g1 = STACK(5); - fixed_t b1 = STACK(4); - fixed_t r2 = STACK(3); - fixed_t g2 = STACK(2); - fixed_t b2 = STACK(1); + int r1 = STACK(6); + int g1 = STACK(5); + int b1 = STACK(4); + int r2 = STACK(3); + int g2 = STACK(2); + int b2 = STACK(1); sp -= 8; if (translation != NULL) @@ -8886,15 +8888,15 @@ scriptwait: break; case PCD_SIN: - STACK(1) = finesine[angle_t(STACK(1)<<16)>>ANGLETOFINESHIFT]; + STACK(1) = DoubleToACS(ACSToAngle(STACK(1)).Sin()); break; case PCD_COS: - STACK(1) = finecosine[angle_t(STACK(1)<<16)>>ANGLETOFINESHIFT]; + STACK(1) = DoubleToACS(ACSToAngle(STACK(1)).Cos()); break; case PCD_VECTORANGLE: - STACK(2) = R_PointToAngle2 (0, 0, STACK(2), STACK(1)) >> 16; + STACK(2) = AngleToACS(VecToAngle(STACK(2), STACK(1)).Degrees); sp--; break; @@ -9075,14 +9077,14 @@ scriptwait: // projectile a TID. // Thing_Projectile2 (tid, type, angle, speed, vspeed, gravity, newtid); P_Thing_Projectile(STACK(7), activator, STACK(6), NULL, STACK(5) * (360. / 256.), - STACK(4) << (FRACBITS - 3), STACK(3) << (FRACBITS - 3), 0, NULL, STACK(2), STACK(1), false); + ACSToDouble(STACK(4)) / 8., ACSToDouble(STACK(3)) / 8., 0, NULL, STACK(2), STACK(1), false); sp -= 7; break; case PCD_SPAWNPROJECTILE: // Same, but takes an actor name instead of a spawn ID. P_Thing_Projectile(STACK(7), activator, 0, FBehavior::StaticLookupString(STACK(6)), STACK(5) * (360. / 256.), - STACK(4) << (FRACBITS - 3), STACK(3) << (FRACBITS - 3), 0, NULL, STACK(2), STACK(1), false); + ACSToDouble(STACK(4)) / 8., ACSToDouble(STACK(3)) / 8., 0, NULL, STACK(2), STACK(1), false); sp -= 7; break; diff --git a/src/p_acs.h b/src/p_acs.h index c6dede0b8..6a7a8d3a1 100644 --- a/src/p_acs.h +++ b/src/p_acs.h @@ -915,9 +915,9 @@ protected: int DoClassifyActor (int tid); int CallFunction(int argCount, int funcIndex, SDWORD *args); - void DoFadeTo (int r, int g, int b, int a, fixed_t time); + void DoFadeTo (int r, int g, int b, int a, int time); void DoFadeRange (int r1, int g1, int b1, int a1, - int r2, int g2, int b2, int a2, fixed_t time); + int r2, int g2, int b2, int a2, int time); void DoSetFont (int fontnum); void SetActorProperty (int tid, int property, int value); void DoSetActorProperty (AActor *actor, int property, int value); diff --git a/src/p_effect.cpp b/src/p_effect.cpp index ba994d4e2..5e5ed316e 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -313,26 +313,27 @@ void P_ThinkParticles () } } -void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t vx, fixed_t vy, fixed_t vz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, int size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz) + +void P_SpawnParticle(const DVector3 &pos, const DVector3 &vel, const DVector3 &accel, PalEntry color, bool fullbright, double startalpha, int lifetime, WORD size, double fadestep) { particle_t *particle = NewParticle(); if (particle) { - particle->x = x; - particle->y = y; - particle->z = z; - particle->vel.x = vx; - particle->vel.y = vy; - particle->vel.z = vz; + particle->x = FLOAT2FIXED(pos.X); + particle->y = FLOAT2FIXED(pos.Y); + particle->z = FLOAT2FIXED(pos.Z); + particle->vel.x = FLOAT2FIXED(vel.X); + particle->vel.y = FLOAT2FIXED(vel.Y); + particle->vel.z = FLOAT2FIXED(vel.Z); particle->color = ParticleColor(color); - particle->trans = startalpha; - if (fadestep < 0) fadestep = FADEFROMTTL(lifetime); - particle->fade = fadestep; + particle->trans = BYTE(startalpha*255); + if (fadestep < 0) particle->fade = FADEFROMTTL(lifetime); + else particle->fade = int(fadestep * 255); particle->ttl = lifetime; - particle->accx = accelx; - particle->accy = accely; - particle->accz = accelz; + particle->accx = FLOAT2FIXED(accel.X); + particle->accy = FLOAT2FIXED(accel.Y); + particle->accz = FLOAT2FIXED(accel.Z); particle->bright = fullbright; particle->size = (WORD)size; } diff --git a/src/p_effect.h b/src/p_effect.h index 856f0d824..d62fc7d65 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -83,12 +83,7 @@ particle_t *JitterParticle (int ttl); particle_t *JitterParticle (int ttl, double drift); void P_ThinkParticles (void); -void P_SpawnParticle(fixed_t x, fixed_t y, fixed_t z, fixed_t vx, fixed_t vy, fixed_t vz, PalEntry color, bool fullbright, BYTE startalpha, BYTE lifetime, int size, int fadestep, fixed_t accelx, fixed_t accely, fixed_t accelz); -inline void P_SpawnParticle(const DVector3 &pos, const DVector3 &vel, const DVector3 &accel, PalEntry color, bool fullbright, double startalpha, int lifetime, WORD size, double fadestep) -{ - P_SpawnParticle(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), FLOAT2FIXED(vel.X), FLOAT2FIXED(vel.Y), FLOAT2FIXED(vel.Z), - color, fullbright, BYTE(startalpha * 255), BYTE(lifetime), WORD(size), fadestep < 0 ? -1 : int(fadestep * 255), FLOAT2FIXED(accel.X), FLOAT2FIXED(accel.Y), FLOAT2FIXED(accel.Z)); -} +void P_SpawnParticle(const DVector3 &pos, const DVector3 &vel, const DVector3 &accel, PalEntry color, bool fullbright, double startalpha, int lifetime, WORD size, double fadestep); void P_InitEffects (void); void P_RunEffects (void); diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 76aecea8c..9f88d7ad8 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2636,12 +2636,12 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) (vilesec != corpsec && corpsec->e->XFloor.ffloors.Size()) ? corpsec : NULL; if (testsec) { - fixed_t zdist1, zdist2; - if (P_Find3DFloor(testsec, corpsehit->_f_Pos(), false, true, zdist1) - != P_Find3DFloor(testsec, self->_f_Pos(), false, true, zdist2)) + double zdist1, 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->_f_Z()) > self->_f_height()) + if (vilesec == corpsec || fabs(zdist1 - self->Z()) > self->Height) continue; } } diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 833f41bad..28764d4d3 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -79,7 +79,8 @@ static const BYTE ChangeMap[8] = { 0, 1, 5, 3, 7, 2, 6, 0 }; #define FUNC(a) static int a (line_t *ln, AActor *it, bool backSide, \ int arg0, int arg1, int arg2, int arg3, int arg4) -#define SPEED(a) ((a)*(FRACUNIT/8)) +#define SPEED(a) ((a) / 8.) +#define _f_SPEED(a) ((a)*(FRACUNIT/8)) #define TICS(a) (((a)*TICRATE)/35) #define OCTICS(a) (((a)*TICRATE)/8) #define _f_BYTEANGLE(a) ((angle_t)((a)<<24)) @@ -147,19 +148,19 @@ FUNC(LS_Polyobj_RotateRight) FUNC(LS_Polyobj_Move) // Polyobj_Move (po, speed, angle, distance) { - return EV_MovePoly (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT, false); + return EV_MovePoly (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT, false); } FUNC(LS_Polyobj_MoveTimes8) // Polyobj_MoveTimes8 (po, speed, angle, distance) { - return EV_MovePoly (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT * 8, false); + return EV_MovePoly (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT * 8, false); } FUNC(LS_Polyobj_MoveTo) // Polyobj_MoveTo (po, speed, x, y) { - return EV_MovePolyTo (ln, arg0, SPEED(arg1), arg2 << FRACBITS, arg3 << FRACBITS, false); + return EV_MovePolyTo (ln, arg0, _f_SPEED(arg1), arg2 << FRACBITS, arg3 << FRACBITS, false); } FUNC(LS_Polyobj_MoveToSpot) @@ -168,7 +169,7 @@ FUNC(LS_Polyobj_MoveToSpot) FActorIterator iterator (arg2); AActor *spot = iterator.Next(); if (spot == NULL) return false; - return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->_f_X(), spot->_f_Y(), false); + return EV_MovePolyTo (ln, arg0, _f_SPEED(arg1), spot->_f_X(), spot->_f_Y(), false); } FUNC(LS_Polyobj_DoorSwing) @@ -180,7 +181,7 @@ FUNC(LS_Polyobj_DoorSwing) FUNC(LS_Polyobj_DoorSlide) // Polyobj_DoorSlide (po, speed, angle, distance, delay) { - return EV_OpenPolyDoor (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg4, arg3*FRACUNIT, PODOOR_SLIDE); + return EV_OpenPolyDoor (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg4, arg3*FRACUNIT, PODOOR_SLIDE); } FUNC(LS_Polyobj_OR_RotateLeft) @@ -198,19 +199,19 @@ FUNC(LS_Polyobj_OR_RotateRight) FUNC(LS_Polyobj_OR_Move) // Polyobj_OR_Move (po, speed, angle, distance) { - return EV_MovePoly (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT, true); + return EV_MovePoly (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT, true); } FUNC(LS_Polyobj_OR_MoveTimes8) // Polyobj_OR_MoveTimes8 (po, speed, angle, distance) { - return EV_MovePoly (ln, arg0, SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT * 8, true); + return EV_MovePoly (ln, arg0, _f_SPEED(arg1), _f_BYTEANGLE(arg2), arg3 * FRACUNIT * 8, true); } FUNC(LS_Polyobj_OR_MoveTo) // Polyobj_OR_MoveTo (po, speed, x, y) { - return EV_MovePolyTo (ln, arg0, SPEED(arg1), arg2 << FRACBITS, arg3 << FRACBITS, true); + return EV_MovePolyTo (ln, arg0, _f_SPEED(arg1), arg2 << FRACBITS, arg3 << FRACBITS, true); } FUNC(LS_Polyobj_OR_MoveToSpot) @@ -219,7 +220,7 @@ FUNC(LS_Polyobj_OR_MoveToSpot) FActorIterator iterator (arg2); AActor *spot = iterator.Next(); if (spot == NULL) return false; - return EV_MovePolyTo (ln, arg0, SPEED(arg1), spot->_f_X(), spot->_f_Y(), true); + return EV_MovePolyTo (ln, arg0, _f_SPEED(arg1), spot->_f_X(), spot->_f_Y(), true); } FUNC(LS_Polyobj_Stop) @@ -231,44 +232,44 @@ FUNC(LS_Polyobj_Stop) FUNC(LS_Door_Close) // Door_Close (tag, speed, lighttag) { - return EV_DoDoor (DDoor::doorClose, ln, it, arg0, SPEED(arg1), 0, 0, arg2); + return EV_DoDoor (DDoor::doorClose, ln, it, arg0, _f_SPEED(arg1), 0, 0, arg2); } FUNC(LS_Door_Open) // Door_Open (tag, speed, lighttag) { - return EV_DoDoor (DDoor::doorOpen, ln, it, arg0, SPEED(arg1), 0, 0, arg2); + return EV_DoDoor (DDoor::doorOpen, ln, it, arg0, _f_SPEED(arg1), 0, 0, arg2); } FUNC(LS_Door_Raise) // Door_Raise (tag, speed, delay, lighttag) { - return EV_DoDoor (DDoor::doorRaise, ln, it, arg0, SPEED(arg1), TICS(arg2), 0, arg3); + return EV_DoDoor (DDoor::doorRaise, ln, it, arg0, _f_SPEED(arg1), TICS(arg2), 0, arg3); } FUNC(LS_Door_LockedRaise) // Door_LockedRaise (tag, speed, delay, lock, lighttag) { return EV_DoDoor (arg2 ? DDoor::doorRaise : DDoor::doorOpen, ln, it, - arg0, SPEED(arg1), TICS(arg2), arg3, arg4); + arg0, _f_SPEED(arg1), TICS(arg2), arg3, arg4); } FUNC(LS_Door_CloseWaitOpen) // Door_CloseWaitOpen (tag, speed, delay, lighttag) { - return EV_DoDoor (DDoor::doorCloseWaitOpen, ln, it, arg0, SPEED(arg1), OCTICS(arg2), 0, arg3); + return EV_DoDoor (DDoor::doorCloseWaitOpen, ln, it, arg0, _f_SPEED(arg1), OCTICS(arg2), 0, arg3); } FUNC(LS_Door_WaitRaise) // Door_WaitRaise(tag, speed, delay, wait, lighttag) { - return EV_DoDoor(DDoor::doorWaitRaise, ln, it, arg0, SPEED(arg1), TICS(arg2), 0, arg4, false, TICS(arg3)); + return EV_DoDoor(DDoor::doorWaitRaise, ln, it, arg0, _f_SPEED(arg1), TICS(arg2), 0, arg4, false, TICS(arg3)); } FUNC(LS_Door_WaitClose) // Door_WaitRaise(tag, speed, wait, lighttag) { - return EV_DoDoor(DDoor::doorWaitClose, ln, it, arg0, SPEED(arg1), 0, 0, arg3, false, TICS(arg2)); + return EV_DoDoor(DDoor::doorWaitClose, ln, it, arg0, _f_SPEED(arg1), 0, 0, arg3, false, TICS(arg2)); } FUNC(LS_Door_Animated) @@ -308,55 +309,55 @@ FUNC(LS_Generic_Door) tag = arg0; lightTag = 0; } - return EV_DoDoor (type, ln, it, tag, SPEED(arg1), OCTICS(arg3), arg4, lightTag, boomgen); + return EV_DoDoor (type, ln, it, tag, _f_SPEED(arg1), OCTICS(arg3), arg4, lightTag, boomgen); } FUNC(LS_Floor_LowerByValue) // Floor_LowerByValue (tag, speed, height, change) { - return EV_DoFloor (DFloor::floorLowerByValue, ln, arg0, SPEED(arg1), FRACUNIT*arg2, -1, CHANGE(arg3), false); + return EV_DoFloor (DFloor::floorLowerByValue, ln, arg0, _f_SPEED(arg1), FRACUNIT*arg2, -1, CHANGE(arg3), false); } FUNC(LS_Floor_LowerToLowest) // Floor_LowerToLowest (tag, speed, change) { - return EV_DoFloor (DFloor::floorLowerToLowest, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), false); + return EV_DoFloor (DFloor::floorLowerToLowest, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), false); } FUNC(LS_Floor_LowerToHighest) // Floor_LowerToHighest (tag, speed, adjust, hereticlower) { - return EV_DoFloor (DFloor::floorLowerToHighest, ln, arg0, SPEED(arg1), (arg2-128)*FRACUNIT, -1, 0, false, arg3==1); + return EV_DoFloor (DFloor::floorLowerToHighest, ln, arg0, _f_SPEED(arg1), (arg2-128)*FRACUNIT, -1, 0, false, arg3==1); } FUNC(LS_Floor_LowerToHighestEE) // Floor_LowerToHighest (tag, speed, change) { - return EV_DoFloor (DFloor::floorLowerToHighest, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), false); + return EV_DoFloor (DFloor::floorLowerToHighest, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), false); } FUNC(LS_Floor_LowerToNearest) // Floor_LowerToNearest (tag, speed, change) { - return EV_DoFloor (DFloor::floorLowerToNearest, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), false); + return EV_DoFloor (DFloor::floorLowerToNearest, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), false); } FUNC(LS_Floor_RaiseByValue) // Floor_RaiseByValue (tag, speed, height, change, crush) { - return EV_DoFloor (DFloor::floorRaiseByValue, ln, arg0, SPEED(arg1), FRACUNIT*arg2, CRUSH(arg4), CHANGE(arg3), true); + return EV_DoFloor (DFloor::floorRaiseByValue, ln, arg0, _f_SPEED(arg1), FRACUNIT*arg2, CRUSH(arg4), CHANGE(arg3), true); } FUNC(LS_Floor_RaiseToHighest) // Floor_RaiseToHighest (tag, speed, change, crush) { - return EV_DoFloor (DFloor::floorRaiseToHighest, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorRaiseToHighest, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); } FUNC(LS_Floor_RaiseToNearest) // Floor_RaiseToNearest (tag, speed, change, crush) { - return EV_DoFloor (DFloor::floorRaiseToNearest, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorRaiseToNearest, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); } FUNC(LS_Floor_RaiseToLowest) @@ -369,25 +370,25 @@ FUNC(LS_Floor_RaiseToLowest) FUNC(LS_Floor_RaiseAndCrush) // Floor_RaiseAndCrush (tag, speed, crush, crushmode) { - return EV_DoFloor (DFloor::floorRaiseAndCrush, ln, arg0, SPEED(arg1), 0, arg2, 0, CRUSHTYPE(arg3)); + return EV_DoFloor (DFloor::floorRaiseAndCrush, ln, arg0, _f_SPEED(arg1), 0, arg2, 0, CRUSHTYPE(arg3)); } FUNC(LS_Floor_RaiseAndCrushDoom) // Floor_RaiseAndCrushDoom (tag, speed, crush, crushmode) { - return EV_DoFloor (DFloor::floorRaiseAndCrushDoom, ln, arg0, SPEED(arg1), 0, arg2, 0, CRUSHTYPE(arg3)); + return EV_DoFloor (DFloor::floorRaiseAndCrushDoom, ln, arg0, _f_SPEED(arg1), 0, arg2, 0, CRUSHTYPE(arg3)); } FUNC(LS_Floor_RaiseByValueTimes8) // FLoor_RaiseByValueTimes8 (tag, speed, height, change, crush) { - return EV_DoFloor (DFloor::floorRaiseByValue, ln, arg0, SPEED(arg1), FRACUNIT*arg2*8, CRUSH(arg4), CHANGE(arg3), true); + return EV_DoFloor (DFloor::floorRaiseByValue, ln, arg0, _f_SPEED(arg1), FRACUNIT*arg2*8, CRUSH(arg4), CHANGE(arg3), true); } FUNC(LS_Floor_LowerByValueTimes8) // Floor_LowerByValueTimes8 (tag, speed, height, change) { - return EV_DoFloor (DFloor::floorLowerByValue, ln, arg0, SPEED(arg1), FRACUNIT*arg2*8, -1, CHANGE(arg3), false); + return EV_DoFloor (DFloor::floorLowerByValue, ln, arg0, _f_SPEED(arg1), FRACUNIT*arg2*8, -1, CHANGE(arg3), false); } FUNC(LS_Floor_CrushStop) @@ -417,57 +418,57 @@ FUNC(LS_Floor_ToCeilingInstant) FUNC(LS_Floor_MoveToValueTimes8) // Floor_MoveToValueTimes8 (tag, speed, height, negative, change) { - return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, SPEED(arg1), + return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT*8*(arg3?-1:1), -1, CHANGE(arg4), false); } FUNC(LS_Floor_MoveToValue) // Floor_MoveToValue (tag, speed, height, negative, change) { - return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, SPEED(arg1), + return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT*(arg3?-1:1), -1, CHANGE(arg4), false); } FUNC(LS_Floor_RaiseToLowestCeiling) // Floor_RaiseToLowestCeiling (tag, speed, change, crush) { - return EV_DoFloor (DFloor::floorRaiseToLowestCeiling, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorRaiseToLowestCeiling, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); } FUNC(LS_Floor_LowerToLowestCeiling) // Floor_LowerToLowestCeiling (tag, speed, change) { - return EV_DoFloor (DFloor::floorLowerToLowestCeiling, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorLowerToLowestCeiling, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), true); } FUNC(LS_Floor_RaiseByTexture) // Floor_RaiseByTexture (tag, speed, change, crush) { - return EV_DoFloor (DFloor::floorRaiseByTexture, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorRaiseByTexture, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); } FUNC(LS_Floor_LowerByTexture) // Floor_LowerByTexture (tag, speed, change, crush) { - return EV_DoFloor (DFloor::floorLowerByTexture, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorLowerByTexture, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), true); } FUNC(LS_Floor_RaiseToCeiling) // Floor_RaiseToCeiling (tag, speed, change, crush) { - return EV_DoFloor (DFloor::floorRaiseToCeiling, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorRaiseToCeiling, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); } FUNC(LS_Floor_RaiseByValueTxTy) // Floor_RaiseByValueTxTy (tag, speed, height) { - return EV_DoFloor (DFloor::floorRaiseAndChange, ln, arg0, SPEED(arg1), arg2*FRACUNIT, -1, 0, false); + return EV_DoFloor (DFloor::floorRaiseAndChange, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, -1, 0, false); } FUNC(LS_Floor_LowerToLowestTxTy) // Floor_LowerToLowestTxTy (tag, speed) { - return EV_DoFloor (DFloor::floorLowerAndChange, ln, arg0, SPEED(arg1), arg2*FRACUNIT, -1, 0, false); + return EV_DoFloor (DFloor::floorLowerAndChange, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, -1, 0, false); } FUNC(LS_Floor_Waggle) @@ -497,7 +498,7 @@ FUNC(LS_Floor_TransferNumeric) FUNC(LS_Floor_Donut) // Floor_Donut (pillartag, pillarspeed, slimespeed) { - return EV_DoDonut (arg0, ln, SPEED(arg1), SPEED(arg2)); + return EV_DoDonut (arg0, ln, _f_SPEED(arg1), _f_SPEED(arg2)); } FUNC(LS_Generic_Floor) @@ -532,7 +533,7 @@ FUNC(LS_Generic_Floor) } } - return EV_DoFloor (type, ln, arg0, SPEED(arg1), arg2*FRACUNIT, + return EV_DoFloor (type, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, (arg4 & 16) ? 20 : -1, arg4 & 7, false); } @@ -541,56 +542,56 @@ FUNC(LS_Stairs_BuildDown) // Stair_BuildDown (tag, speed, height, delay, reset) { return EV_BuildStairs (arg0, DFloor::buildDown, ln, - arg2 * FRACUNIT, SPEED(arg1), TICS(arg3), arg4, 0, DFloor::stairUseSpecials); + arg2 * FRACUNIT, _f_SPEED(arg1), TICS(arg3), arg4, 0, DFloor::stairUseSpecials); } FUNC(LS_Stairs_BuildUp) // Stairs_BuildUp (tag, speed, height, delay, reset) { return EV_BuildStairs (arg0, DFloor::buildUp, ln, - arg2 * FRACUNIT, SPEED(arg1), TICS(arg3), arg4, 0, DFloor::stairUseSpecials); + arg2 * FRACUNIT, _f_SPEED(arg1), TICS(arg3), arg4, 0, DFloor::stairUseSpecials); } FUNC(LS_Stairs_BuildDownSync) // Stairs_BuildDownSync (tag, speed, height, reset) { return EV_BuildStairs (arg0, DFloor::buildDown, ln, - arg2 * FRACUNIT, SPEED(arg1), 0, arg3, 0, DFloor::stairUseSpecials|DFloor::stairSync); + arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg3, 0, DFloor::stairUseSpecials|DFloor::stairSync); } FUNC(LS_Stairs_BuildUpSync) // Stairs_BuildUpSync (tag, speed, height, reset) { return EV_BuildStairs (arg0, DFloor::buildUp, ln, - arg2 * FRACUNIT, SPEED(arg1), 0, arg3, 0, DFloor::stairUseSpecials|DFloor::stairSync); + arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg3, 0, DFloor::stairUseSpecials|DFloor::stairSync); } FUNC(LS_Stairs_BuildUpDoom) // Stairs_BuildUpDoom (tag, speed, height, delay, reset) { return EV_BuildStairs (arg0, DFloor::buildUp, ln, - arg2 * FRACUNIT, SPEED(arg1), TICS(arg3), arg4, 0, 0); + arg2 * FRACUNIT, _f_SPEED(arg1), TICS(arg3), arg4, 0, 0); } FUNC(LS_Stairs_BuildDownDoom) // Stair_BuildDownDoom (tag, speed, height, delay, reset) { return EV_BuildStairs (arg0, DFloor::buildDown, ln, - arg2 * FRACUNIT, SPEED(arg1), TICS(arg3), arg4, 0, 0); + arg2 * FRACUNIT, _f_SPEED(arg1), TICS(arg3), arg4, 0, 0); } FUNC(LS_Stairs_BuildDownDoomSync) // Stairs_BuildDownDoomSync (tag, speed, height, reset) { return EV_BuildStairs (arg0, DFloor::buildDown, ln, - arg2 * FRACUNIT, SPEED(arg1), 0, arg3, 0, DFloor::stairSync); + arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg3, 0, DFloor::stairSync); } FUNC(LS_Stairs_BuildUpDoomSync) // Stairs_BuildUpDoomSync (tag, speed, height, reset) { return EV_BuildStairs (arg0, DFloor::buildUp, ln, - arg2 * FRACUNIT, SPEED(arg1), 0, arg3, 0, DFloor::stairSync); + arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg3, 0, DFloor::stairSync); } @@ -599,7 +600,7 @@ FUNC(LS_Generic_Stairs) { DFloor::EStair type = (arg3 & 1) ? DFloor::buildUp : DFloor::buildDown; bool res = EV_BuildStairs (arg0, type, ln, - arg2 * FRACUNIT, SPEED(arg1), 0, arg4, arg3 & 2, 0); + arg2 * FRACUNIT, _f_SPEED(arg1), 0, arg4, arg3 & 2, 0); if (res && ln && (ln->flags & ML_REPEAT_SPECIAL) && ln->special == Generic_Stairs) // Toggle direction of next activation of repeatable stairs @@ -611,61 +612,61 @@ FUNC(LS_Generic_Stairs) FUNC(LS_Pillar_Build) // Pillar_Build (tag, speed, height) { - return EV_DoPillar (DPillar::pillarBuild, ln, arg0, SPEED(arg1), arg2*FRACUNIT, 0, -1, false); + return EV_DoPillar (DPillar::pillarBuild, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, 0, -1, false); } FUNC(LS_Pillar_BuildAndCrush) // Pillar_BuildAndCrush (tag, speed, height, crush, crushtype) { - return EV_DoPillar (DPillar::pillarBuild, ln, arg0, SPEED(arg1), arg2*FRACUNIT, 0, arg3, CRUSHTYPE(arg4)); + return EV_DoPillar (DPillar::pillarBuild, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, 0, arg3, CRUSHTYPE(arg4)); } FUNC(LS_Pillar_Open) // Pillar_Open (tag, speed, f_height, c_height) { - return EV_DoPillar (DPillar::pillarOpen, ln, arg0, SPEED(arg1), arg2*FRACUNIT, arg3*FRACUNIT, -1, false); + return EV_DoPillar (DPillar::pillarOpen, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, arg3*FRACUNIT, -1, false); } FUNC(LS_Ceiling_LowerByValue) // Ceiling_LowerByValue (tag, speed, height, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false); } FUNC(LS_Ceiling_RaiseByValue) // Ceiling_RaiseByValue (tag, speed, height, change) { - return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false); } FUNC(LS_Ceiling_LowerByValueTimes8) // Ceiling_LowerByValueTimes8 (tag, speed, height, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); } FUNC(LS_Ceiling_RaiseByValueTimes8) // Ceiling_RaiseByValueTimes8 (tag, speed, height, change) { - return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); } FUNC(LS_Ceiling_CrushAndRaise) // Ceiling_CrushAndRaise (tag, speed, crush, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); } FUNC(LS_Ceiling_LowerAndCrush) // Ceiling_LowerAndCrush (tag, speed, crush, crushtype) { - return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); + return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1), 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); } FUNC(LS_Ceiling_LowerAndCrushDist) // Ceiling_LowerAndCrush (tag, speed, crush, dist, crushtype) { - return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), arg3*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1), arg3*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushStop) @@ -677,27 +678,27 @@ FUNC(LS_Ceiling_CrushStop) FUNC(LS_Ceiling_CrushRaiseAndStay) // Ceiling_CrushRaiseAndStay (tag, speed, crush, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); + return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); } FUNC(LS_Ceiling_MoveToValueTimes8) // Ceiling_MoveToValueTimes8 (tag, speed, height, negative, change) { - return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, SPEED(arg1), 0, + return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT*8*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4), false); } FUNC(LS_Ceiling_MoveToValue) // Ceiling_MoveToValue (tag, speed, height, negative, change) { - return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, SPEED(arg1), 0, + return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4), false); } FUNC(LS_Ceiling_LowerToHighestFloor) // Ceiling_LowerToHighestFloor (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToHighestFloor, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); + return EV_DoCeiling (DCeiling::ceilLowerToHighestFloor, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); } FUNC(LS_Ceiling_LowerInstant) @@ -715,79 +716,79 @@ FUNC(LS_Ceiling_RaiseInstant) FUNC(LS_Ceiling_CrushRaiseAndStayA) // Ceiling_CrushRaiseAndStayA (tag, dnspeed, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushRaiseAndStaySilA) // Ceiling_CrushRaiseAndStaySilA (tag, dnspeed, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushAndRaiseA) // Ceiling_CrushAndRaiseA (tag, dnspeed, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushAndRaiseDist) // Ceiling_CrushAndRaiseDist (tag, dist, speed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg2), _f_SPEED(arg2), arg1*FRACUNIT, arg3, 0, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushAndRaiseSilentA) // Ceiling_CrushAndRaiseSilentA (tag, dnspeed, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushAndRaiseSilentDist) // Ceiling_CrushAndRaiseSilentDist (tag, dist, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 1, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg2), _f_SPEED(arg2), arg1*FRACUNIT, arg3, 1, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_RaiseToNearest) // Ceiling_RaiseToNearest (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseToNearest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseToNearest, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); } FUNC(LS_Ceiling_RaiseToHighest) // Ceiling_RaiseToHighest (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); } FUNC(LS_Ceiling_RaiseToLowest) // Ceiling_RaiseToLowest (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseToLowest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseToLowest, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); } FUNC(LS_Ceiling_RaiseToHighestFloor) // Ceiling_RaiseToHighestFloor (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseToHighestFloor, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseToHighestFloor, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); } FUNC(LS_Ceiling_RaiseByTexture) // Ceiling_RaiseByTexture (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseByTexture, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseByTexture, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); } FUNC(LS_Ceiling_LowerToLowest) // Ceiling_LowerToLowest (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToLowest, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); + return EV_DoCeiling (DCeiling::ceilLowerToLowest, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); } FUNC(LS_Ceiling_LowerToNearest) // Ceiling_LowerToNearest (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToNearest, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); + return EV_DoCeiling (DCeiling::ceilLowerToNearest, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); } FUNC(LS_Ceiling_ToHighestInstant) @@ -805,13 +806,13 @@ FUNC(LS_Ceiling_ToFloorInstant) FUNC(LS_Ceiling_LowerToFloor) // Ceiling_LowerToFloor (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToFloor, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false); + return EV_DoCeiling (DCeiling::ceilLowerToFloor, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false); } FUNC(LS_Ceiling_LowerByTexture) // Ceiling_LowerByTexture (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerByTexture, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false); + return EV_DoCeiling (DCeiling::ceilLowerByTexture, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false); } FUNC(LS_Generic_Ceiling) @@ -841,35 +842,35 @@ FUNC(LS_Generic_Ceiling) } } - return EV_DoCeiling (type, ln, arg0, SPEED(arg1), SPEED(arg1), arg2*FRACUNIT, + return EV_DoCeiling (type, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1), arg2*FRACUNIT, (arg4 & 16) ? 20 : -1, 0, arg4 & 7, false); } FUNC(LS_Generic_Crusher) // Generic_Crusher (tag, dnspeed, upspeed, silent, damage) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), - SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, false); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), + _f_SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, false); } FUNC(LS_Generic_Crusher2) // Generic_Crusher2 (tag, dnspeed, upspeed, silent, damage) { // same as above but uses Hexen's crushing method. - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), - SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, true); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), + _f_SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, true); } FUNC(LS_Plat_PerpetualRaise) // Plat_PerpetualRaise (tag, speed, delay) { - return EV_DoPlat (arg0, ln, DPlat::platPerpetualRaise, 0, SPEED(arg1), TICS(arg2), 8, 0); + return EV_DoPlat (arg0, ln, DPlat::platPerpetualRaise, 0, _f_SPEED(arg1), TICS(arg2), 8, 0); } FUNC(LS_Plat_PerpetualRaiseLip) // Plat_PerpetualRaiseLip (tag, speed, delay, lip) { - return EV_DoPlat (arg0, ln, DPlat::platPerpetualRaise, 0, SPEED(arg1), TICS(arg2), arg3, 0); + return EV_DoPlat (arg0, ln, DPlat::platPerpetualRaise, 0, _f_SPEED(arg1), TICS(arg2), arg3, 0); } FUNC(LS_Plat_Stop) @@ -882,7 +883,7 @@ FUNC(LS_Plat_Stop) FUNC(LS_Plat_DownWaitUpStay) // Plat_DownWaitUpStay (tag, speed, delay) { - return EV_DoPlat (arg0, ln, DPlat::platDownWaitUpStay, 0, SPEED(arg1), TICS(arg2), 8, 0); + return EV_DoPlat (arg0, ln, DPlat::platDownWaitUpStay, 0, _f_SPEED(arg1), TICS(arg2), 8, 0); } FUNC(LS_Plat_DownWaitUpStayLip) @@ -890,31 +891,31 @@ FUNC(LS_Plat_DownWaitUpStayLip) { return EV_DoPlat (arg0, ln, arg4 ? DPlat::platDownWaitUpStayStone : DPlat::platDownWaitUpStay, - 0, SPEED(arg1), TICS(arg2), arg3, 0); + 0, _f_SPEED(arg1), TICS(arg2), arg3, 0); } FUNC(LS_Plat_DownByValue) // Plat_DownByValue (tag, speed, delay, height) { - return EV_DoPlat (arg0, ln, DPlat::platDownByValue, FRACUNIT*arg3*8, SPEED(arg1), TICS(arg2), 0, 0); + return EV_DoPlat (arg0, ln, DPlat::platDownByValue, FRACUNIT*arg3*8, _f_SPEED(arg1), TICS(arg2), 0, 0); } FUNC(LS_Plat_UpByValue) // Plat_UpByValue (tag, speed, delay, height) { - return EV_DoPlat (arg0, ln, DPlat::platUpByValue, FRACUNIT*arg3*8, SPEED(arg1), TICS(arg2), 0, 0); + return EV_DoPlat (arg0, ln, DPlat::platUpByValue, FRACUNIT*arg3*8, _f_SPEED(arg1), TICS(arg2), 0, 0); } FUNC(LS_Plat_UpWaitDownStay) // Plat_UpWaitDownStay (tag, speed, delay) { - return EV_DoPlat (arg0, ln, DPlat::platUpWaitDownStay, 0, SPEED(arg1), TICS(arg2), 0, 0); + return EV_DoPlat (arg0, ln, DPlat::platUpWaitDownStay, 0, _f_SPEED(arg1), TICS(arg2), 0, 0); } FUNC(LS_Plat_UpNearestWaitDownStay) // Plat_UpNearestWaitDownStay (tag, speed, delay) { - return EV_DoPlat (arg0, ln, DPlat::platUpNearestWaitDownStay, 0, SPEED(arg1), TICS(arg2), 0, 0); + return EV_DoPlat (arg0, ln, DPlat::platUpNearestWaitDownStay, 0, _f_SPEED(arg1), TICS(arg2), 0, 0); } FUNC(LS_Plat_RaiseAndStayTx0) @@ -936,13 +937,13 @@ FUNC(LS_Plat_RaiseAndStayTx0) } - return EV_DoPlat (arg0, ln, type, 0, SPEED(arg1), 0, 0, 1); + return EV_DoPlat (arg0, ln, type, 0, _f_SPEED(arg1), 0, 0, 1); } FUNC(LS_Plat_UpByValueStayTx) // Plat_UpByValueStayTx (tag, speed, height) { - return EV_DoPlat (arg0, ln, DPlat::platUpByValueStay, FRACUNIT*arg2*8, SPEED(arg1), 0, 0, 2); + return EV_DoPlat (arg0, ln, DPlat::platUpByValueStay, FRACUNIT*arg2*8, _f_SPEED(arg1), 0, 0, 2); } FUNC(LS_Plat_ToggleCeiling) @@ -975,7 +976,7 @@ FUNC(LS_Generic_Lift) break; } - return EV_DoPlat (arg0, ln, type, arg4*8*FRACUNIT, SPEED(arg1), OCTICS(arg2), 0, 0); + return EV_DoPlat (arg0, ln, type, arg4*8*FRACUNIT, _f_SPEED(arg1), OCTICS(arg2), 0, 0); } FUNC(LS_Exit_Normal) @@ -1457,15 +1458,15 @@ FUNC(LS_Thing_Damage) FUNC(LS_Thing_Projectile) // Thing_Projectile (tid, type, angle, speed, vspeed) { - return P_Thing_Projectile (arg0, it, arg1, NULL, BYTEANGLE(arg2), arg3<<(FRACBITS-3), - arg4<<(FRACBITS-3), 0, NULL, 0, 0, false); + return P_Thing_Projectile (arg0, it, arg1, NULL, BYTEANGLE(arg2), SPEED(arg3), + SPEED(arg4), 0, NULL, 0, 0, false); } FUNC(LS_Thing_ProjectileGravity) // Thing_ProjectileGravity (tid, type, angle, speed, vspeed) { - return P_Thing_Projectile (arg0, it, arg1, NULL, BYTEANGLE(arg2), arg3<<(FRACBITS-3), - arg4<<(FRACBITS-3), 0, NULL, 1, 0, false); + return P_Thing_Projectile (arg0, it, arg1, NULL, BYTEANGLE(arg2), SPEED(arg3), + SPEED(arg4), 0, NULL, 1, 0, false); } FUNC(LS_Thing_Hate) @@ -1634,13 +1635,13 @@ FUNC(LS_Thing_Hate) FUNC(LS_Thing_ProjectileAimed) // Thing_ProjectileAimed (tid, type, speed, target, newtid) { - return P_Thing_Projectile (arg0, it, arg1, NULL, 0., arg2<<(FRACBITS-3), 0, arg3, it, 0, arg4, false); + return P_Thing_Projectile (arg0, it, arg1, NULL, 0., SPEED(arg2), 0, arg3, it, 0, arg4, false); } FUNC(LS_Thing_ProjectileIntercept) // Thing_ProjectileIntercept (tid, type, speed, target, newtid) { - return P_Thing_Projectile (arg0, it, arg1, NULL, 0., arg2<<(FRACBITS-3), 0, arg3, it, 0, arg4, true); + return P_Thing_Projectile (arg0, it, arg1, NULL, 0., SPEED(arg2), 0, arg3, it, 0, arg4, true); } // [BC] added newtid for next two @@ -1930,26 +1931,26 @@ FUNC(LS_FS_Execute) FUNC(LS_FloorAndCeiling_LowerByValue) // FloorAndCeiling_LowerByValue (tag, speed, height) { - return EV_DoElevator (ln, DElevator::elevateLower, SPEED(arg1), arg2*FRACUNIT, arg0); + return EV_DoElevator (ln, DElevator::elevateLower, _f_SPEED(arg1), arg2*FRACUNIT, arg0); } FUNC(LS_FloorAndCeiling_RaiseByValue) // FloorAndCeiling_RaiseByValue (tag, speed, height) { - return EV_DoElevator (ln, DElevator::elevateRaise, SPEED(arg1), arg2*FRACUNIT, arg0); + return EV_DoElevator (ln, DElevator::elevateRaise, _f_SPEED(arg1), arg2*FRACUNIT, arg0); } FUNC(LS_FloorAndCeiling_LowerRaise) // FloorAndCeiling_LowerRaise (tag, fspeed, cspeed, boomemu) { - bool res = EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, SPEED(arg2), 0, 0, 0, 0, 0, false); + bool res = EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, _f_SPEED(arg2), 0, 0, 0, 0, 0, false); // The switch based Boom equivalents of FloorandCeiling_LowerRaise do incorrect checks // which cause the floor only to move when the ceiling fails to do so. // To avoid problems with maps that have incorrect args this only uses a // more or less unintuitive value for the fourth arg to trigger Boom's broken behavior if (arg3 != 1998 || !res) // (1998 for the year in which Boom was released... :P) { - res |= EV_DoFloor (DFloor::floorLowerToLowest, ln, arg0, SPEED(arg1), 0, -1, 0, false); + res |= EV_DoFloor (DFloor::floorLowerToLowest, ln, arg0, _f_SPEED(arg1), 0, -1, 0, false); } return res; } @@ -1957,19 +1958,19 @@ FUNC(LS_FloorAndCeiling_LowerRaise) FUNC(LS_Elevator_MoveToFloor) // Elevator_MoveToFloor (tag, speed) { - return EV_DoElevator (ln, DElevator::elevateCurrent, SPEED(arg1), 0, arg0); + return EV_DoElevator (ln, DElevator::elevateCurrent, _f_SPEED(arg1), 0, arg0); } FUNC(LS_Elevator_RaiseToNearest) // Elevator_RaiseToNearest (tag, speed) { - return EV_DoElevator (ln, DElevator::elevateUp, SPEED(arg1), 0, arg0); + return EV_DoElevator (ln, DElevator::elevateUp, _f_SPEED(arg1), 0, arg0); } FUNC(LS_Elevator_LowerToNearest) // Elevator_LowerToNearest (tag, speed) { - return EV_DoElevator (ln, DElevator::elevateDown, SPEED(arg1), 0, arg0); + return EV_DoElevator (ln, DElevator::elevateDown, _f_SPEED(arg1), 0, arg0); } FUNC(LS_Light_ForceLightning) @@ -2893,7 +2894,7 @@ enum PROP_FLIGHT, PROP_UNUSED1, PROP_UNUSED2, - PROP_SPEED, + PROP__f_SPEED, PROP_BUDDHA, }; @@ -2908,7 +2909,7 @@ FUNC(LS_SetPlayerProperty) return false; // Add or remove a power - if (arg2 >= PROP_INVULNERABILITY && arg2 <= PROP_SPEED) + if (arg2 >= PROP_INVULNERABILITY && arg2 <= PROP__f_SPEED) { static PClass * const *powers[11] = { diff --git a/src/p_local.h b/src/p_local.h index 47be75835..e9a9b9992 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -210,8 +210,9 @@ extern FClassMap StrifeTypes; bool P_Thing_Spawn (int tid, AActor *source, int type, DAngle angle, bool fog, int newtid); bool P_Thing_Projectile (int tid, AActor *source, int type, const char * type_name, DAngle angle, - fixed_t speed, fixed_t vspeed, int dest, AActor *forcedest, int gravity, int newtid, + double speed, double vspeed, int dest, AActor *forcedest, int gravity, int newtid, bool leadTarget); + bool P_MoveThing(AActor *source, const DVector3 &pos, bool fog); bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog); int P_Thing_Damage (int tid, AActor *whofor0, int amount, FName type); diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index b4d6dc8fe..adacb4d43 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -243,8 +243,8 @@ void P_LineOpening (FLineOpening &open, AActor *actor, const line_t *linedef, co open.floorterrain = -1; open.bottom = LINEOPEN_MIN; open.lowfloor = LINEOPEN_MAX; - open.frontfloorplane.SetAtHeight(FIXED_MIN, sector_t::floor); - open.backfloorplane.SetAtHeight(FIXED_MIN, sector_t::floor); + open.frontfloorplane.SetAtHeight(LINEOPEN_MIN, sector_t::floor); + open.backfloorplane.SetAtHeight(LINEOPEN_MIN, sector_t::floor); } // Check 3D floors diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b64b4777d..28f264002 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3683,7 +3683,7 @@ void AActor::Tick () secplane_t floorplane; // Check 3D floors as well - floorplane = P_FindFloorPlane(floorsector, _f_X(), _f_Y(), _f_floorz()); + floorplane = P_FindFloorPlane(floorsector, PosAtZ(floorz)); if (floorplane.c < STEEPSLOPE && floorplane.ZatPoint (_f_PosRelative(floorsector)) <= _f_floorz()) diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 91f579250..962330be1 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -119,8 +119,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo if (side == NULL) return true; - fixed_t checktop; - fixed_t checkbot; + double checktop; + double checkbot; sector_t *front = side->sector; FLineOpening open; int flags = line->flags; @@ -229,7 +229,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo // to keep compatibility with Eternity's implementation. if (!P_GetMidTexturePosition(line, sideno, &checktop, &checkbot)) return false; - return user->_f_Z() < checktop && user->_f_Top() > checkbot; + return user->Z() < checktop && user->Top() > checkbot; } else { diff --git a/src/p_things.cpp b/src/p_things.cpp index 929f07482..1560736a0 100644 --- a/src/p_things.cpp +++ b/src/p_things.cpp @@ -169,15 +169,13 @@ bool P_Thing_Move (int tid, AActor *source, int mapspot, bool fog) } bool P_Thing_Projectile (int tid, AActor *source, int type, const char *type_name, DAngle angle, - fixed_t _speed, fixed_t _vspeed, int dest, AActor *forcedest, int gravity, int newtid, + double speed, double vspeed, int dest, AActor *forcedest, int gravity, int newtid, bool leadTarget) { int rtn = 0; PClassActor *kind; AActor *spot, *mobj, *targ = forcedest; FActorIterator iterator (tid); - double speed = FIXED2DBL(_speed); - double vspeed = FIXED2DBL(_vspeed); int defflags3; if (type_name == NULL) diff --git a/src/p_writemap.cpp b/src/p_writemap.cpp index ab3290619..cd8082cfe 100644 --- a/src/p_writemap.cpp +++ b/src/p_writemap.cpp @@ -150,8 +150,8 @@ static int WriteSIDEDEFS (FILE *file) for (int i = 0; i < numsides; ++i) { - msd.textureoffset = LittleShort(short(sides[i].GetTextureXOffset(side_t::mid) >> FRACBITS)); - msd.rowoffset = LittleShort(short(sides[i].GetTextureYOffset(side_t::mid) >> FRACBITS)); + msd.textureoffset = LittleShort(short(sides[i].GetTextureXOffsetF(side_t::mid))); + msd.rowoffset = LittleShort(short(sides[i].GetTextureYOffsetF(side_t::mid))); msd.sector = LittleShort(short(sides[i].sector - sectors)); uppercopy (msd.toptexture, GetTextureName (sides[i].GetTexture(side_t::top))); uppercopy (msd.bottomtexture, GetTextureName (sides[i].GetTexture(side_t::bottom))); diff --git a/src/r_defs.h b/src/r_defs.h index 6985d174b..4be105906 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -405,6 +405,11 @@ struct secplane_t } } + inline void SetAtHeight(double height, int ceiling) + { + SetAtHeight(FLOAT2FIXED(clamp(height, -32767., 32767.)), ceiling); + } + bool CopyPlaneIfValid (secplane_t *dest, const secplane_t *opp) const; }; @@ -1113,6 +1118,10 @@ struct side_t { return textures[which].xoffset; } + double GetTextureXOffsetF(int which) const + { + return FIXED2DBL(textures[which].xoffset); + } void AddTextureXOffset(int which, fixed_t delta) { textures[which].xoffset += delta; @@ -1132,6 +1141,10 @@ struct side_t { return textures[which].yoffset; } + double GetTextureYOffsetF(int which) const + { + return FIXED2DBL(textures[which].yoffset); + } void AddTextureYOffset(int which, fixed_t delta) { textures[which].yoffset += delta; @@ -1167,6 +1180,10 @@ struct side_t { return textures[which].yscale; } + double GetTextureYScaleF(int which) const + { + return FIXED2DBL(textures[which].yscale); + } void MultiplyTextureYScale(int which, fixed_t delta) { textures[which].yscale = FixedMul(textures[which].yscale, delta); diff --git a/src/tables.h b/src/tables.h index 6fe767a4f..085174892 100644 --- a/src/tables.h +++ b/src/tables.h @@ -100,7 +100,7 @@ typedef uint32 angle_t; // note: remove the call to 'abs' since unsigned values cannot be negative inline angle_t absangle(angle_t a) { - return (angle_t)abs((int32)a); + return (angle_t)abs((int32_t)a); } // Effective size is 2049; diff --git a/src/textures/textures.h b/src/textures/textures.h index 82fdac9bf..8f5998954 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -205,7 +205,6 @@ public: int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); } int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); } - int GetScaledHeight(double scale) { int foo = (Height << 17) / FLOAT2FIXED(scale); return (foo >> 1) + (foo & 1); } double GetScaledWidthDouble () { return (Width * 65536.) / xScale; } double GetScaledHeightDouble () { return (Height * 65536.) / yScale; } double GetScaleY() const { return FIXED2DBL(yScale); } diff --git a/src/vectors.h b/src/vectors.h index af19d72b5..32c7508c7 100644 --- a/src/vectors.h +++ b/src/vectors.h @@ -43,6 +43,7 @@ #include #include #include "m_fixed.h" +#include "tables.h" #include "math/cmath.h" @@ -1036,11 +1037,6 @@ struct TAngle return TVector2(length * Cos(), length * Sin()); } - int FixedAngle() // for ACS. This must be normalized so it just converts to BAM first and then shifts 16 bits right. - { - return FLOAT2ANGLE(Degrees) >> 16; - } - vec_t Cos() const { return vec_t(g_cosdeg(Degrees)); diff --git a/src/win32/fb_d3d9.cpp b/src/win32/fb_d3d9.cpp index 8a6e7e50f..4bf3716e2 100644 --- a/src/win32/fb_d3d9.cpp +++ b/src/win32/fb_d3d9.cpp @@ -3074,7 +3074,8 @@ void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, DAngle rotation, FDynamicColormap *colormap, int lightlevel) { // Use an equation similar to player sprites to determine shade - fixed_t shade = LIGHT2SHADE(lightlevel) - 12*FRACUNIT; + double fadelevel = clamp((LIGHT2SHADE(lightlevel)/65536. - 12) / NUMCOLORMAPS, 0.0, 1.0); + BufferedTris *quad; FBVERTEX *verts; D3DTex *tex; @@ -3128,7 +3129,6 @@ void D3DFB::FillSimplePoly(FTexture *texture, FVector2 *points, int npoints, quad->ShaderNum = BQS_InGameColormap; quad->Desat = colormap->Desaturate; color0 = D3DCOLOR_ARGB(255, colormap->Color.r, colormap->Color.g, colormap->Color.b); - double fadelevel = clamp(shade / (NUMCOLORMAPS * 65536.0), 0.0, 1.0); color1 = D3DCOLOR_ARGB(DWORD((1 - fadelevel) * 255), DWORD(colormap->Fade.r * fadelevel), DWORD(colormap->Fade.g * fadelevel), diff --git a/src/xs_Float.h b/src/xs_Float.h index b4b5218c5..33150e4ea 100644 --- a/src/xs_Float.h +++ b/src/xs_Float.h @@ -15,6 +15,8 @@ #ifndef _xs_FLOAT_H_ #define _xs_FLOAT_H_ +#include + // ==================================================================================================================== // Defines // ==================================================================================================================== @@ -37,15 +39,18 @@ #define finline __forceinline #endif +typedef double real64; + + union _xs_doubleints { real64 val; - uint32 ival[2]; + uint32_t ival[2]; }; #if 0 -#define _xs_doublecopysgn(a,b) ((int32*)&a)[_xs_iexp_]&=~(((int32*)&b)[_xs_iexp_]&0x80000000) -#define _xs_doubleisnegative(a) ((((int32*)&a)[_xs_iexp_])|0x80000000) +#define _xs_doublecopysgn(a,b) ((int32_t*)&a)[_xs_iexp_]&=~(((int32_t*)&b)[_xs_iexp_]&0x80000000) +#define _xs_doubleisnegative(a) ((((int32_t*)&a)[_xs_iexp_])|0x80000000) #endif // ==================================================================================================================== @@ -59,37 +64,37 @@ const real64 _xs_doublemagicroundeps = (.5f-_xs_doublemagicdelta); //almos // ==================================================================================================================== // Prototypes // ==================================================================================================================== -static int32 xs_CRoundToInt (real64 val, real64 dmr = _xs_doublemagic); -static int32 xs_ToInt (real64 val, real64 dme = -_xs_doublemagicroundeps); -static int32 xs_FloorToInt (real64 val, real64 dme = _xs_doublemagicroundeps); -static int32 xs_CeilToInt (real64 val, real64 dme = _xs_doublemagicroundeps); -static int32 xs_RoundToInt (real64 val); +static int32_t xs_CRoundToInt (real64 val, real64 dmr = _xs_doublemagic); +static int32_t xs_ToInt (real64 val, real64 dme = -_xs_doublemagicroundeps); +static int32_t xs_FloorToInt (real64 val, real64 dme = _xs_doublemagicroundeps); +static int32_t xs_CeilToInt (real64 val, real64 dme = _xs_doublemagicroundeps); +static int32_t xs_RoundToInt (real64 val); -//int32 versions -finline static int32 xs_CRoundToInt (int32 val) {return val;} -finline static int32 xs_ToInt (int32 val) {return val;} +//int32_t versions +finline static int32_t xs_CRoundToInt (int32_t val) {return val;} +finline static int32_t xs_ToInt (int32_t val) {return val;} // ==================================================================================================================== // Fix Class // ==================================================================================================================== -template class xs_Fix +template class xs_Fix { public: - typedef int32 Fix; + typedef int32_t Fix; // ==================================================================================================================== // Basic Conversion from Numbers // ==================================================================================================================== - finline static Fix ToFix (int32 val) {return val<>N;} + finline static int32_t ToInt (Fix f) {return f>>N;} @@ -97,7 +102,7 @@ protected: // ==================================================================================================================== // Helper function - mainly to preserve _xs_DEFAULT_CONVERSION // ==================================================================================================================== - finline static int32 xs_ConvertToFixed (real64 val) + finline static int32_t xs_ConvertToFixed (real64 val) { #if _xs_DEFAULT_CONVERSION==0 return xs_CRoundToInt(val, _xs_doublemagic/(1<int conversion, but unfortunately, // checking for SSE support every time you need to do a // conversion completely negates its performance advantage. - return int32(val); + return int32_t(val); #else #if _xs_DEFAULT_CONVERSION==0 return (val<0) ? xs_CRoundToInt(val-dme) : xs_CRoundToInt(val+dme); #else - return int32(val); + return int32_t(val); #endif #endif } // ==================================================================================================================== -finline static int32 xs_FloorToInt(real64 val, real64 dme) +finline static int32_t xs_FloorToInt(real64 val, real64 dme) { #if _xs_DEFAULT_CONVERSION==0 return xs_CRoundToInt (val - dme); @@ -167,7 +172,7 @@ finline static int32 xs_FloorToInt(real64 val, real64 dme) // ==================================================================================================================== -finline static int32 xs_CeilToInt(real64 val, real64 dme) +finline static int32_t xs_CeilToInt(real64 val, real64 dme) { #if _xs_DEFAULT_CONVERSION==0 return xs_CRoundToInt (val + dme); @@ -178,7 +183,7 @@ finline static int32 xs_CeilToInt(real64 val, real64 dme) // ==================================================================================================================== -finline static int32 xs_RoundToInt(real64 val) +finline static int32_t xs_RoundToInt(real64 val) { #if _xs_DEFAULT_CONVERSION==0 // Yes, it is important that two fadds be generated, so you cannot override the dmr @@ -197,24 +202,24 @@ finline static int32 xs_RoundToInt(real64 val) // Unsigned variants // ==================================================================================================================== // ==================================================================================================================== -finline static uint32 xs_CRoundToUInt(real64 val) +finline static uint32_t xs_CRoundToUInt(real64 val) { - return (uint32)xs_CRoundToInt(val); + return (uint32_t)xs_CRoundToInt(val); } -finline static uint32 xs_FloorToUInt(real64 val) +finline static uint32_t xs_FloorToUInt(real64 val) { - return (uint32)xs_FloorToInt(val); + return (uint32_t)xs_FloorToInt(val); } -finline static uint32 xs_CeilToUInt(real64 val) +finline static uint32_t xs_CeilToUInt(real64 val) { - return (uint32)xs_CeilToInt(val); + return (uint32_t)xs_CeilToInt(val); } -finline static uint32 xs_RoundToUInt(real64 val) +finline static uint32_t xs_RoundToUInt(real64 val) { - return (uint32)xs_RoundToInt(val); + return (uint32_t)xs_RoundToInt(val); } From 0c39bdd04cd538a1cfb493be86e2b51ee7ebc60c Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Mar 2016 13:37:44 +0100 Subject: [PATCH 16/44] - floatified texture scale values. --- src/p_user.cpp | 14 +++++++++----- src/r_plane.cpp | 12 +++++++----- src/r_segs.cpp | 30 +++++++++++++++--------------- src/r_sky.cpp | 6 +++--- src/r_things.cpp | 16 ++++++++-------- src/textures/multipatchtexture.cpp | 12 ++++++------ src/textures/texture.cpp | 14 +++++++------- src/textures/texturemanager.cpp | 8 ++++---- src/textures/textures.h | 27 ++++++++++++--------------- src/v_draw.cpp | 4 ++-- src/wi_stuff.cpp | 2 +- 11 files changed, 74 insertions(+), 71 deletions(-) diff --git a/src/p_user.cpp b/src/p_user.cpp index 40eefd893..185ce8b5b 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2722,7 +2722,8 @@ void P_PredictionLerpReset() bool P_LerpCalculate(PredictPos from, PredictPos to, PredictPos &result, float scale) { - DVector3 vecFrom(FIXED2DBL(from.x), FIXED2DBL(from.y), FIXED2DBL(from.z)); + //DVector2 pfrom = Displacements.getOffset(from.portalgroup, to.portalgroup); + DVector3 vecFrom(FIXED2DBL(from.x) /* + pfrom.X*/, FIXED2DBL(from.y) /*+ pfrom.Y*/, FIXED2DBL(from.z)); DVector3 vecTo(FIXED2DBL(to.x), FIXED2DBL(to.y), FIXED2DBL(to.z)); DVector3 vecResult; vecResult = vecTo - vecFrom; @@ -2730,9 +2731,11 @@ bool P_LerpCalculate(PredictPos from, PredictPos to, PredictPos &result, float s vecResult = vecResult + vecFrom; DVector3 delta = vecResult - vecTo; + //result.pos = pmo->Vec3Offset(FLOAT2FIXED(vecResult.X) - to.pos.x, FLOAT2FIXED(vecResult.Y) - to.pos.y, FLOAT2FIXED(vecResult.Z) - to.pos.z); result.x = FLOAT2FIXED(vecResult.X); result.y = FLOAT2FIXED(vecResult.Y); result.z = FLOAT2FIXED(vecResult.Z); + //result.portalgroup = P_PointInSector(result.pos.x, result.pos.y)->PortalGroup; // As a fail safe, assume extrapolation is the threshold. return (delta.LengthSquared() > cl_predict_lerpthreshold && scale <= 1.00f); @@ -2844,10 +2847,10 @@ void P_PredictPlayer (player_t *player) // Aditional Debug information if (developer && DoLerp) { - DPrintf("Lerp! Ltic (%d) && Ptic (%d) | Lx (%d) && Px (%d) | Ly (%d) && Py (%d)\n", + DPrintf("Lerp! Ltic (%d) && Ptic (%d) | Lx (%d) && Px (%f) | Ly (%d) && Py (%f)\n", PredictionLast.gametic, i, - (PredictionLast.x >> 16), (player->mo->_f_X() >> 16), - (PredictionLast.y >> 16), (player->mo->_f_Y() >> 16)); + (PredictionLast.x >> 16), (player->mo->X()), + (PredictionLast.y >> 16), (player->mo->Y())); } } } @@ -2868,11 +2871,12 @@ void P_PredictPlayer (player_t *player) PredictionLast.x = player->mo->_f_X(); PredictionLast.y = player->mo->_f_Y(); PredictionLast.z = player->mo->_f_Z(); + //PredictionLast.portalgroup = player->mo->Sector->PortalGroup; if (PredictionLerptics > 0) { if (PredictionLerpFrom.gametic > 0 && - P_LerpCalculate(PredictionLerpFrom, PredictionLast, PredictionLerpResult, (float)PredictionLerptics * cl_predict_lerpscale)) + P_LerpCalculate(/*player->mo,*/ PredictionLerpFrom, PredictionLast, PredictionLerpResult, (float)PredictionLerptics * cl_predict_lerpscale)) { PredictionLerptics++; player->mo->SetXYZ(PredictionLerpResult.x, PredictionLerpResult.y, PredictionLerpResult.z); diff --git a/src/r_plane.cpp b/src/r_plane.cpp index 6a3aa803f..2c004f1f9 100644 --- a/src/r_plane.cpp +++ b/src/r_plane.cpp @@ -957,7 +957,7 @@ static void R_DrawSky (visplane_t *pl) rw_pic = frontskytex; rw_offset = 0; - frontyScale = rw_pic->yScale; + frontyScale = FLOAT2FIXED(rw_pic->Scale.Y); dc_texturemid = MulScale16 (skymid, frontyScale); if (1 << frontskytex->HeightBits == frontskytex->GetHeight()) @@ -1003,6 +1003,7 @@ static void R_DrawSkyStriped (visplane_t *pl) yl = 0; yh = (short)MulScale32 ((frontskytex->GetHeight() << FRACBITS) - topfrac, frontyScale); dc_texturemid = topfrac - iscale * (1-centery); + fixed_t yScale = FLOAT2FIXED(rw_pic->Scale.Y); while (yl < viewheight) { @@ -1015,7 +1016,7 @@ static void R_DrawSkyStriped (visplane_t *pl) { lastskycol[x] = 0xffffffff; } - wallscan (pl->left, pl->right, top, bot, swall, lwall, rw_pic->yScale, + wallscan (pl->left, pl->right, top, bot, swall, lwall, yScale, backskytex == NULL ? R_GetOneSkyColumn : R_GetTwoSkyColumns); yl = yh; yh += drawheight; @@ -1136,8 +1137,8 @@ void R_DrawSinglePlane (visplane_t *pl, fixed_t alpha, bool additive, bool maske masked = false; } R_SetupSpanBits(tex); - pl->xscale = MulScale16 (pl->xscale, tex->xScale); - pl->yscale = MulScale16 (pl->yscale, tex->yScale); + pl->xscale = fixed_t(pl->xscale * tex->Scale.X); + pl->yscale = fixed_t(pl->yscale * tex->Scale.Y); ds_source = tex->GetPixels (); basecolormap = pl->colormap; @@ -1476,7 +1477,8 @@ void R_DrawSkyPlane (visplane_t *pl) // allow old sky textures to be used. skyflip = l->args[2] ? 0u : ~0u; - frontcyl = MAX(frontskytex->GetWidth(), frontskytex->xScale >> (16 - 10)); + int frontxscale = int(frontskytex->Scale.X * 1024); + frontcyl = MAX(frontskytex->GetWidth(), frontxscale); if (skystretch) { skymid = Scale(skymid, frontskytex->GetScaledHeight(), SKYSTRETCH_HEIGHT); diff --git a/src/r_segs.cpp b/src/r_segs.cpp index d31c233d5..8a349516c 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -601,8 +601,8 @@ void R_RenderFakeWall(drawseg_t *ds, int x1, int x2, F3DFloor *rover) scaledside = rover->master->sidedef[0]; scaledpart = side_t::mid; } - xscale = FixedMul(rw_pic->xScale, scaledside->GetTextureXScale(scaledpart)); - yscale = FixedMul(rw_pic->yScale, scaledside->GetTextureYScale(scaledpart)); + xscale = fixed_t(rw_pic->Scale.X * scaledside->GetTextureXScale(scaledpart)); + yscale = fixed_t(rw_pic->Scale.Y * scaledside->GetTextureYScale(scaledpart)); fixed_t rowoffset = curline->sidedef->GetTextureYOffset(side_t::mid) + rover->master->sidedef[0]->GetTextureYOffset(side_t::mid); dc_texturemid = rover->model->GetPlaneTexZ(sector_t::ceiling); @@ -1861,8 +1861,8 @@ void R_RenderSegLoop () { dc_texturemid = rw_midtexturemid; rw_pic = midtexture; - xscale = FixedMul(rw_pic->xScale, rw_midtexturescalex); - yscale = FixedMul(rw_pic->yScale, rw_midtexturescaley); + xscale = fixed_t(rw_pic->Scale.X * rw_midtexturescalex); + yscale = fixed_t(rw_pic->Scale.Y * rw_midtexturescaley); if (xscale != lwallscale) { PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); @@ -1904,8 +1904,8 @@ void R_RenderSegLoop () { dc_texturemid = rw_toptexturemid; rw_pic = toptexture; - xscale = FixedMul(rw_pic->xScale, rw_toptexturescalex); - yscale = FixedMul(rw_pic->yScale, rw_toptexturescaley); + xscale = fixed_t(rw_pic->Scale.X * rw_toptexturescalex); + yscale = fixed_t(rw_pic->Scale.Y * rw_toptexturescaley); if (xscale != lwallscale) { PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); @@ -1950,8 +1950,8 @@ void R_RenderSegLoop () { dc_texturemid = rw_bottomtexturemid; rw_pic = bottomtexture; - xscale = FixedMul(rw_pic->xScale, rw_bottomtexturescalex); - yscale = FixedMul(rw_pic->yScale, rw_bottomtexturescaley); + xscale = fixed_t(rw_pic->Scale.X * rw_bottomtexturescalex); + yscale = fixed_t(rw_pic->Scale.Y * rw_bottomtexturescaley); if (xscale != lwallscale) { PrepLWall (lwall, curline->sidedef->TexelLength*xscale, WallC.sx1, WallC.sx2); @@ -2021,7 +2021,7 @@ void R_NewWall (bool needlights) rowoffset = sidedef->GetTextureYOffset(side_t::mid); rw_midtexturescalex = sidedef->GetTextureXScale(side_t::mid); rw_midtexturescaley = sidedef->GetTextureYScale(side_t::mid); - yrepeat = FixedMul(midtexture->yScale, rw_midtexturescaley); + yrepeat = fixed_t(midtexture->Scale.Y * rw_midtexturescaley); if (yrepeat >= 0) { // normal orientation if (linedef->flags & ML_DONTPEGBOTTOM) @@ -2176,7 +2176,7 @@ void R_NewWall (bool needlights) rowoffset = sidedef->GetTextureYOffset(side_t::top); rw_toptexturescalex = sidedef->GetTextureXScale(side_t::top); rw_toptexturescaley = sidedef->GetTextureYScale(side_t::top); - yrepeat = FixedMul(toptexture->yScale, rw_toptexturescaley); + yrepeat = fixed_t(toptexture->Scale.Y * rw_toptexturescaley); if (yrepeat >= 0) { // normal orientation if (linedef->flags & ML_DONTPEGTOP) @@ -2221,7 +2221,7 @@ void R_NewWall (bool needlights) rowoffset = sidedef->GetTextureYOffset(side_t::bottom); rw_bottomtexturescalex = sidedef->GetTextureXScale(side_t::bottom); rw_bottomtexturescaley = sidedef->GetTextureYScale(side_t::bottom); - yrepeat = FixedMul(bottomtexture->yScale, rw_bottomtexturescaley); + yrepeat = fixed_t(bottomtexture->Scale.Y * rw_bottomtexturescaley); if (yrepeat >= 0) { // normal orientation if (linedef->flags & ML_DONTPEGBOTTOM) @@ -2292,9 +2292,9 @@ void R_NewWall (bool needlights) if (needlights && (segtextured || (backsector && IsFogBoundary(frontsector, backsector)))) { lwallscale = - midtex ? FixedMul(midtex->xScale, sidedef->GetTextureXScale(side_t::mid)) : - toptexture ? FixedMul(toptexture->xScale, sidedef->GetTextureXScale(side_t::top)) : - bottomtexture ? FixedMul(bottomtexture->xScale, sidedef->GetTextureXScale(side_t::bottom)) : + midtex ? int(midtex->Scale.X * sidedef->GetTextureXScale(side_t::mid)) : + toptexture ? int(toptexture->Scale.X * sidedef->GetTextureXScale(side_t::top)) : + bottomtexture ? int(bottomtexture->Scale.X * sidedef->GetTextureXScale(side_t::bottom)) : FRACUNIT; PrepWall (swall, lwall, sidedef->TexelLength * lwallscale, WallC.sx1, WallC.sx2); @@ -2507,7 +2507,7 @@ void R_StoreWallRange (int start, int stop) lwal = (fixed_t *)(openings + ds_p->maskedtexturecol); swal = (fixed_t *)(openings + ds_p->swall); FTexture *pic = TexMan(sidedef->GetTexture(side_t::mid), true); - fixed_t yrepeat = FixedMul(pic->yScale, sidedef->GetTextureYScale(side_t::mid)); + fixed_t yrepeat = int(pic->Scale.X * sidedef->GetTextureYScale(side_t::mid)); fixed_t xoffset = sidedef->GetTextureXOffset(side_t::mid); if (pic->bWorldPanning) diff --git a/src/r_sky.cpp b/src/r_sky.cpp index 00d3dfc66..f3bdbed35 100644 --- a/src/r_sky.cpp +++ b/src/r_sky.cpp @@ -107,7 +107,7 @@ void R_InitSkyMap () } else if (skyheight > 200) { - skytexturemid = FixedMul((200 - skyheight) << FRACBITS, skytex1->yScale); + skytexturemid = FLOAT2FIXED((200 - skyheight) * skytex1->Scale.Y); } if (viewwidth != 0 && viewheight != 0) @@ -131,8 +131,8 @@ void R_InitSkyMap () // giving a total sky width of 1024 pixels. So if the sky texture is no wider than 1024, // we map it to a cylinder with circumfrence 1024. For larger ones, we use the width of // the texture as the cylinder's circumfrence. - sky1cyl = MAX(skytex1->GetWidth(), skytex1->xScale >> (16 - 10)); - sky2cyl = MAX(skytex2->GetWidth(), skytex2->xScale >> (16 - 10)); + sky1cyl = MAX(skytex1->GetWidth(), fixed_t(skytex1->Scale.X * 1024)); + sky2cyl = MAX(skytex2->GetWidth(), fixed_t(skytex2->Scale.Y * 1024)); } diff --git a/src/r_things.cpp b/src/r_things.cpp index 6f99a3790..a35af4867 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -969,7 +969,7 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor renderflags ^= MirrorFlags & RF_XFLIP; // calculate edges of the shape - const fixed_t thingxscalemul = DivScale16(spritescaleX, tex->xScale); + const fixed_t thingxscalemul = fixed_t(spritescaleX / tex->Scale.X); tx -= ((renderflags & RF_XFLIP) ? (tex->GetWidth() - tex->LeftOffset - 1) : tex->LeftOffset) * thingxscalemul; x1 = centerx + MulScale32 (tx, xscale); @@ -985,10 +985,10 @@ void R_ProjectSprite (AActor *thing, int fakeside, F3DFloor *fakefloor, F3DFloor if ((x2 < WindowLeft || x2 <= x1)) return; - xscale = FixedDiv(FixedMul(spritescaleX, xscale), tex->xScale); + xscale = fixed_t(FixedMul(spritescaleX, xscale) / tex->Scale.X); iscale = (tex->GetWidth() << FRACBITS) / (x2 - x1); - fixed_t yscale = SafeDivScale16(spritescaleY, tex->yScale); + fixed_t yscale = fixed_t(spritescaleY / tex->Scale.Y); // store information in a vissprite vis = R_NewVisSprite(); @@ -1335,7 +1335,7 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ vis->floorclip = 0; - vis->texturemid = MulScale16((BASEYCENTER<yScale) + (tex->TopOffset << FRACBITS); + vis->texturemid = int(((BASEYCENTER<Scale.Y) + (tex->TopOffset << FRACBITS); if (camera->player && (RenderTarget != screen || @@ -1365,20 +1365,20 @@ void R_DrawPSprite (pspdef_t* psp, int pspnum, AActor *owner, fixed_t sx, fixed_ } vis->x1 = x1 < 0 ? 0 : x1; vis->x2 = x2 >= viewwidth ? viewwidth : x2; - vis->xscale = DivScale16(pspritexscale, tex->xScale); - vis->yscale = DivScale16(pspriteyscale, tex->yScale); + vis->xscale = fixed_t(pspritexscale / tex->Scale.X); + vis->yscale = fixed_t(pspriteyscale / tex->Scale.Y); vis->Translation = 0; // [RH] Use default colors vis->pic = tex; vis->ColormapNum = 0; if (flip) { - vis->xiscale = -MulScale16(pspritexiscale, tex->xScale); + vis->xiscale = -int(pspritexiscale * tex->Scale.X); vis->startfrac = (tex->GetWidth() << FRACBITS) - 1; } else { - vis->xiscale = MulScale16(pspritexiscale, tex->xScale); + vis->xiscale = int(pspritexiscale * tex->Scale.X); vis->startfrac = 0; } diff --git a/src/textures/multipatchtexture.cpp b/src/textures/multipatchtexture.cpp index 31af81a56..89fe94757 100644 --- a/src/textures/multipatchtexture.cpp +++ b/src/textures/multipatchtexture.cpp @@ -246,8 +246,8 @@ FMultiPatchTexture::FMultiPatchTexture (const void *texdef, FPatchLookup *patchl Name = (char *)mtexture.d->name; CalcBitSize (); - xScale = mtexture.d->ScaleX ? mtexture.d->ScaleX*(FRACUNIT/8) : FRACUNIT; - yScale = mtexture.d->ScaleY ? mtexture.d->ScaleY*(FRACUNIT/8) : FRACUNIT; + Scale.X = mtexture.d->ScaleX ? mtexture.d->ScaleX / 8. : 1.; + Scale.Y = mtexture.d->ScaleY ? mtexture.d->ScaleY / 8. : 1.; if (mtexture.d->Flags & MAPTEXF_WORLDPANNING) { @@ -1243,14 +1243,14 @@ FMultiPatchTexture::FMultiPatchTexture (FScanner &sc, int usetype) if (sc.Compare("XScale")) { sc.MustGetFloat(); - xScale = FLOAT2FIXED(sc.Float); - if (xScale == 0) sc.ScriptError("Texture %s is defined with null x-scale\n", Name.GetChars()); + Scale.X = sc.Float; + if (Scale.X == 0) sc.ScriptError("Texture %s is defined with null x-scale\n", Name.GetChars()); } else if (sc.Compare("YScale")) { sc.MustGetFloat(); - yScale = FLOAT2FIXED(sc.Float); - if (yScale == 0) sc.ScriptError("Texture %s is defined with null y-scale\n", Name.GetChars()); + Scale.Y = sc.Float; + if (Scale.Y == 0) sc.ScriptError("Texture %s is defined with null y-scale\n", Name.GetChars()); } else if (sc.Compare("WorldPanning")) { diff --git a/src/textures/texture.cpp b/src/textures/texture.cpp index ae96605cf..7b90c295f 100644 --- a/src/textures/texture.cpp +++ b/src/textures/texture.cpp @@ -118,12 +118,12 @@ FTexture * FTexture::CreateTexture (int lumpnum, int usetype) // Now we're stuck with this stupid behaviour. if (w==128 && h==128) { - tex->xScale = tex->yScale = 2*FRACUNIT; + tex->Scale.X = tex->Scale.Y = 2; tex->bWorldPanning = true; } else if (w==256 && h==256) { - tex->xScale = tex->yScale = 4*FRACUNIT; + tex->Scale.X = tex->Scale.Y = 4; tex->bWorldPanning = true; } } @@ -147,7 +147,7 @@ FTexture * FTexture::CreateTexture (const char *name, int lumpnum, int usetype) FTexture::FTexture (const char *name, int lumpnum) : LeftOffset(0), TopOffset(0), - WidthBits(0), HeightBits(0), xScale(FRACUNIT), yScale(FRACUNIT), SourceLump(lumpnum), + WidthBits(0), HeightBits(0), Scale(1,1), SourceLump(lumpnum), UseType(TEX_Any), bNoDecals(false), bNoRemap0(false), bWorldPanning(false), bMasked(true), bAlphaTexture(false), bHasCanvas(false), bWarped(0), bComplex(false), bMultiPatch(false), bKeepAround(false), Rotations(0xFFFF), SkyOffset(0), Width(0), Height(0), WidthMask(0), Native(NULL) @@ -562,11 +562,11 @@ FTexture *FTexture::GetRawTexture() void FTexture::SetScaledSize(int fitwidth, int fitheight) { - xScale = FLOAT2FIXED(float(Width) / fitwidth); - yScale = FLOAT2FIXED(float(Height) / fitheight); + Scale.X = double(Width) / fitwidth; + Scale.Y =double(Height) / fitheight; // compensate for roundoff errors - if (MulScale16(xScale, fitwidth) != Width) xScale++; - if (MulScale16(yScale, fitheight) != Height) yScale++; + if (int(Scale.X * fitwidth) != Width) Scale.X += (1 / 65536.); + if (int(Scale.Y * fitheight) != Height) Scale.Y += (1 / 65536.); } diff --git a/src/textures/texturemanager.cpp b/src/textures/texturemanager.cpp index a208d7b49..b2c7164e2 100644 --- a/src/textures/texturemanager.cpp +++ b/src/textures/texturemanager.cpp @@ -569,8 +569,8 @@ void FTextureManager::AddHiresTextures (int wadnum) // Replace the entire texture and adjust the scaling and offset factors. newtex->bWorldPanning = true; newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight()); - newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale); - newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale); + newtex->LeftOffset = int(oldtex->GetScaledLeftOffset() * newtex->Scale.X); + newtex->TopOffset = int(oldtex->GetScaledTopOffset() * newtex->Scale.Y); ReplaceTexture(tlist[i], newtex, true); } } @@ -658,8 +658,8 @@ void FTextureManager::LoadTextureDefs(int wadnum, const char *lumpname) // Replace the entire texture and adjust the scaling and offset factors. newtex->bWorldPanning = true; newtex->SetScaledSize(oldtex->GetScaledWidth(), oldtex->GetScaledHeight()); - newtex->LeftOffset = FixedMul(oldtex->GetScaledLeftOffset(), newtex->xScale); - newtex->TopOffset = FixedMul(oldtex->GetScaledTopOffset(), newtex->yScale); + newtex->LeftOffset = int(oldtex->GetScaledLeftOffset() * newtex->Scale.X); + newtex->TopOffset = int(oldtex->GetScaledTopOffset() * newtex->Scale.Y); ReplaceTexture(tlist[i], newtex, true); } } diff --git a/src/textures/textures.h b/src/textures/textures.h index 8f5998954..e77d4d5de 100644 --- a/src/textures/textures.h +++ b/src/textures/textures.h @@ -1,8 +1,7 @@ #ifndef __TEXTURES_H #define __TEXTURES_H -#include "doomtype.h" -#include "m_fixed.h" +#include "vectors.h" class FBitmap; struct FRemapTable; @@ -123,8 +122,7 @@ public: BYTE WidthBits, HeightBits; - fixed_t xScale; - fixed_t yScale; + DVector2 Scale; int SourceLump; FTextureID id; @@ -203,16 +201,16 @@ public: int GetWidth () { return Width; } int GetHeight () { return Height; } - int GetScaledWidth () { int foo = (Width << 17) / xScale; return (foo >> 1) + (foo & 1); } - int GetScaledHeight () { int foo = (Height << 17) / yScale; return (foo >> 1) + (foo & 1); } - double GetScaledWidthDouble () { return (Width * 65536.) / xScale; } - double GetScaledHeightDouble () { return (Height * 65536.) / yScale; } - double GetScaleY() const { return FIXED2DBL(yScale); } + int GetScaledWidth () { int foo = int((Width * 2) / Scale.X); return (foo >> 1) + (foo & 1); } + int GetScaledHeight () { int foo = int((Height * 2) / Scale.Y); return (foo >> 1) + (foo & 1); } + double GetScaledWidthDouble () { return Width / Scale.X; } + double GetScaledHeightDouble () { return Height / Scale.Y; } + double GetScaleY() const { return Scale.Y; } - int GetScaledLeftOffset () { int foo = (LeftOffset << 17) / xScale; return (foo >> 1) + (foo & 1); } - int GetScaledTopOffset () { int foo = (TopOffset << 17) / yScale; return (foo >> 1) + (foo & 1); } - double GetScaledLeftOffsetDouble() { return (LeftOffset * 65536.) / xScale; } - double GetScaledTopOffsetDouble() { return (TopOffset * 65536.) / yScale; } + int GetScaledLeftOffset () { int foo = int((LeftOffset * 2) / Scale.X); return (foo >> 1) + (foo & 1); } + int GetScaledTopOffset () { int foo = int((TopOffset * 2) / Scale.Y); return (foo >> 1) + (foo & 1); } + double GetScaledLeftOffsetDouble() { return LeftOffset / Scale.X; } + double GetScaledTopOffsetDouble() { return TopOffset / Scale.Y; } virtual void SetFrontSkyLayer(); @@ -238,8 +236,7 @@ public: LeftOffset = BaseTexture->LeftOffset; WidthBits = BaseTexture->WidthBits; HeightBits = BaseTexture->HeightBits; - xScale = BaseTexture->xScale; - yScale = BaseTexture->yScale; + Scale = BaseTexture->Scale; WidthMask = (1 << WidthBits) - 1; } diff --git a/src/v_draw.cpp b/src/v_draw.cpp index 2d3b1e3e2..4845fb624 100644 --- a/src/v_draw.cpp +++ b/src/v_draw.cpp @@ -1201,8 +1201,8 @@ void DCanvas::FillSimplePoly(FTexture *tex, FVector2 *points, int npoints, return; } - scalex /= FIXED2DBL(tex->xScale); - scaley /= FIXED2DBL(tex->yScale); + scalex /= tex->Scale.X; + scaley /= tex->Scale.Y; // Use the CRT's functions here. cosrot = cos(ToRadians(rotation)); diff --git a/src/wi_stuff.cpp b/src/wi_stuff.cpp index e95e6c594..d568051ae 100644 --- a/src/wi_stuff.cpp +++ b/src/wi_stuff.cpp @@ -759,7 +759,7 @@ int CheckRealHeight(FTexture *tex) } } // Scale maxy before returning it - maxy = (maxy << 17) / tex->yScale; + maxy = int((maxy *2) / tex->Scale.Y); maxy = (maxy >> 1) + (maxy & 1); return maxy; } From 00ea8662b811f6da0334192ced319c444793ee8a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Mar 2016 20:59:35 +0100 Subject: [PATCH 17/44] - floatification of p_enemy and p_interaction.cpp. --- src/p_buildmap.cpp | 10 +-- src/p_enemy.cpp | 182 ++++++++++++++++++++---------------------- src/p_enemy.h | 8 +- src/p_interaction.cpp | 22 ++--- src/p_lnspec.cpp | 70 ++++++++-------- src/p_mobj.cpp | 2 +- src/p_spec.h | 5 ++ 7 files changed, 143 insertions(+), 156 deletions(-) diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index b676c8398..2fa2a70f2 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -145,8 +145,8 @@ static bool P_LoadBloodMap (BYTE *data, size_t len, FMapThing **sprites, int *nu static void LoadSectors (sectortype *bsectors); static void LoadWalls (walltype *walls, int numwalls, sectortype *bsectors); static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, sectortype *bsectors, FMapThing *mapthings); -static vertex_t *FindVertex (fixed_t x, fixed_t y); -static void CreateStartSpot (fixed_t *pos, FMapThing *start); +static vertex_t *FindVertex (SDWORD x, SDWORD y); +static void CreateStartSpot (SDWORD *pos, FMapThing *start); static void CalcPlane (SlopeWork &slope, secplane_t &plane); static void Decrypt (void *to, const void *from, int len, int key); @@ -232,7 +232,7 @@ bool P_LoadBuildMap (BYTE *data, size_t len, FMapThing **sprites, int *numspr) numsprites = *(WORD *)(data + 24 + numsectors*sizeof(sectortype) + numwalls*sizeof(walltype)); *sprites = new FMapThing[numsprites + 1]; - CreateStartSpot ((fixed_t *)(data + 4), *sprites); + CreateStartSpot ((SDWORD *)(data + 4), *sprites); *numspr = 1 + LoadSprites ((spritetype *)(data + 26 + numsectors*sizeof(sectortype) + numwalls*sizeof(walltype)), NULL, numsprites, (sectortype *)(data + 22), *sprites + 1); @@ -755,7 +755,7 @@ static int LoadSprites (spritetype *sprites, Xsprite *xsprites, int numsprites, // //========================================================================== -vertex_t *FindVertex (fixed_t x, fixed_t y) +vertex_t *FindVertex (SDWORD x, SDWORD y) { int i; @@ -781,7 +781,7 @@ vertex_t *FindVertex (fixed_t x, fixed_t y) // //========================================================================== -static void CreateStartSpot (fixed_t *pos, FMapThing *start) +static void CreateStartSpot (SDWORD *pos, FMapThing *start) { short angle = LittleShort(*(WORD *)(&pos[3])); FMapThing mt = { 0, }; diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 9f88d7ad8..93361833e 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -124,7 +124,7 @@ void P_RandomChaseDir (AActor *actor); // sound blocking lines cut off traversal. //---------------------------------------------------------------------------- -void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soundblocks, AActor *emitter, fixed_t maxdist) +void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soundblocks, AActor *emitter, double maxdist) { int i; line_t* check; @@ -146,7 +146,7 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun for (actor = sec->thinglist; actor != NULL; actor = actor->snext) { if (actor != soundtarget && (!splash || !(actor->flags4 & MF4_NOSPLASHALERT)) && - (!maxdist || (actor->AproxDistance(emitter) <= maxdist))) + (!maxdist || (actor->Distance2D(emitter) <= maxdist))) { actor->LastHeard = soundtarget; } @@ -162,18 +162,12 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun // I wish there was a better method to do this than randomly looking through the portal at a few places... if (checkabove) { - sector_t *upper = - P_PointInSector(check->v1->x + check->dx / 2 + FLOAT2FIXED(sec->SkyBoxes[sector_t::ceiling]->Scale.X), - check->v1->y + check->dy / 2 + FLOAT2FIXED(sec->SkyBoxes[sector_t::ceiling]->Scale.Y)); - + sector_t *upper = P_PointInSector(check->v1->fPos() + check->Delta() / 2 + sec->SkyBoxes[sector_t::ceiling]->Scale); P_RecursiveSound(upper, soundtarget, splash, soundblocks, emitter, maxdist); } if (checkbelow) { - sector_t *lower = - P_PointInSector(check->v1->x + check->dx / 2 + FLOAT2FIXED(sec->SkyBoxes[sector_t::ceiling]->Scale.X), - check->v1->y + check->dy / 2 + FLOAT2FIXED(sec->SkyBoxes[sector_t::ceiling]->Scale.Y)); - + sector_t *lower = P_PointInSector(check->v1->fPos() + check->Delta() / 2 + sec->SkyBoxes[sector_t::floor]->Scale); P_RecursiveSound(lower, soundtarget, splash, soundblocks, emitter, maxdist); } FLinePortal *port = check->getPortal(); @@ -201,18 +195,18 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun other = check->sidedef[0]->sector; // check for closed door - if ((sec->floorplane.ZatPoint (check->v1->x, check->v1->y) >= - other->ceilingplane.ZatPoint (check->v1->x, check->v1->y) && - sec->floorplane.ZatPoint (check->v2->x, check->v2->y) >= - other->ceilingplane.ZatPoint (check->v2->x, check->v2->y)) - || (other->floorplane.ZatPoint (check->v1->x, check->v1->y) >= - sec->ceilingplane.ZatPoint (check->v1->x, check->v1->y) && - other->floorplane.ZatPoint (check->v2->x, check->v2->y) >= - sec->ceilingplane.ZatPoint (check->v2->x, check->v2->y)) - || (other->floorplane.ZatPoint (check->v1->x, check->v1->y) >= - other->ceilingplane.ZatPoint (check->v1->x, check->v1->y) && - other->floorplane.ZatPoint (check->v2->x, check->v2->y) >= - other->ceilingplane.ZatPoint (check->v2->x, check->v2->y))) + if ((sec->floorplane.ZatPoint (check->v1->fPos()) >= + other->ceilingplane.ZatPoint (check->v1->fPos()) && + sec->floorplane.ZatPoint (check->v2->fPos()) >= + other->ceilingplane.ZatPoint (check->v2->fPos())) + || (other->floorplane.ZatPoint (check->v1->fPos()) >= + sec->ceilingplane.ZatPoint (check->v1->fPos()) && + other->floorplane.ZatPoint (check->v2->fPos()) >= + sec->ceilingplane.ZatPoint (check->v2->fPos())) + || (other->floorplane.ZatPoint (check->v1->fPos()) >= + other->ceilingplane.ZatPoint (check->v1->fPos()) && + other->floorplane.ZatPoint (check->v2->fPos()) >= + other->ceilingplane.ZatPoint (check->v2->fPos()))) { continue; } @@ -240,7 +234,7 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun // //---------------------------------------------------------------------------- -void P_NoiseAlert (AActor *target, AActor *emitter, bool splash, fixed_t maxdist) +void P_NoiseAlert (AActor *target, AActor *emitter, bool splash, double maxdist) { if (emitter == NULL) return; @@ -452,9 +446,9 @@ bool P_HitFriend(AActor * self) bool P_Move (AActor *actor) { - fixed_t tryx, tryy, deltax, deltay, origx, origy; + double tryx, tryy, deltax, deltay, origx, origy; bool try_ok; - fixed_t speed = actor->_f_speed(); + double speed = actor->Speed; double movefactor = ORIG_FRICTION_FACTOR; double friction = ORIG_FRICTION; int dropoff = 0; @@ -489,7 +483,7 @@ bool P_Move (AActor *actor) if ((actor->flags6 & MF6_JUMPDOWN) && target && !(target->IsFriend(actor)) && - actor->AproxDistance(target) < FRACUNIT*144 && + actor->Distance2D(target) < 144 && pr_dropoff() < 235) { dropoff = 2; @@ -504,39 +498,39 @@ bool P_Move (AActor *actor) if (friction < ORIG_FRICTION) { // sludge - speed = fixed_t(speed * ((ORIG_FRICTION_FACTOR - (ORIG_FRICTION_FACTOR-movefactor)/2)) / ORIG_FRICTION_FACTOR); + speed = speed * ((ORIG_FRICTION_FACTOR - (ORIG_FRICTION_FACTOR-movefactor)/2)) / ORIG_FRICTION_FACTOR; if (speed == 0) { // always give the monster a little bit of speed - speed = ksgn(actor->_f_speed()); + speed = actor->Speed; } } } - tryx = (origx = actor->_f_X()) + (deltax = fixed_t (speed * xspeed[actor->movedir])); - tryy = (origy = actor->_f_Y()) + (deltay = fixed_t (speed * yspeed[actor->movedir])); + tryx = (origx = actor->X()) + (deltax = (speed * xspeed[actor->movedir])); + tryy = (origy = actor->Y()) + (deltay = (speed * yspeed[actor->movedir])); // Like P_XYMovement this should do multiple moves if the step size is too large - fixed_t maxmove = actor->_f_radius() - FRACUNIT; + double maxmove = actor->radius - 1; int steps = 1; if (maxmove > 0) { - const fixed_t xspeed = abs (deltax); - const fixed_t yspeed = abs (deltay); + const double xspeed = fabs (deltax); + const double yspeed = fabs (deltay); if (xspeed > yspeed) { if (xspeed > maxmove) { - steps = 1 + xspeed / maxmove; + steps = 1 + int(xspeed / maxmove); } } else { if (yspeed > maxmove) { - steps = 1 + yspeed / maxmove; + steps = 1 + int(yspeed / maxmove); } } } @@ -547,12 +541,12 @@ bool P_Move (AActor *actor) try_ok = true; for(int i=1; i < steps; i++) { - try_ok = P_TryMove(actor, origx + Scale(deltax, i, steps), origy + Scale(deltay, i, steps), dropoff, NULL, tm); + try_ok = P_TryMove(actor, DVector2(origx + deltax * i / steps, origy + deltay * i / steps), dropoff, NULL, tm); if (!try_ok) break; } // killough 3/15/98: don't jump over dropoffs: - if (try_ok) try_ok = P_TryMove (actor, tryx, tryy, dropoff, NULL, tm); + if (try_ok) try_ok = P_TryMove (actor, DVector2(tryx, tryy), dropoff, NULL, tm); // [GrafZahl] Interpolating monster movement as it is done here just looks bad // so make it switchable @@ -563,10 +557,10 @@ bool P_Move (AActor *actor) if (try_ok && friction > ORIG_FRICTION) { - actor->SetOrigin(origx, origy, actor->_f_Z(), false); + actor->SetOrigin(origx, origy, actor->Z(), false); movefactor *= 1.f / ORIG_FRICTION_FACTOR / 4; - actor->Vel.X += FIXED2DBL(deltax * movefactor); - actor->Vel.Y += FIXED2DBL(deltay * movefactor); + actor->Vel.X += deltax * movefactor; + actor->Vel.Y += deltay * movefactor; } // [RH] If a walking monster is no longer on the floor, move it down @@ -589,7 +583,7 @@ bool P_Move (AActor *actor) else { // The monster just hit the floor, so trigger any actions. if (actor->floorsector->SecActTarget != NULL && - actor->_f_floorz() == actor->floorsector->floorplane.ZatPoint(actor->_f_PosRelative(actor->floorsector))) + actor->floorz == actor->floorsector->floorplane.ZatPoint(actor->PosRelative(actor->floorsector))) { actor->floorsector->SecActTarget->TriggerAction(actor, SECSPAC_HitFloor); } @@ -704,7 +698,7 @@ bool P_TryWalk (AActor *actor) // //============================================================================= -void P_DoNewChaseDir (AActor *actor, fixed_t deltax, fixed_t deltay) +void P_DoNewChaseDir (AActor *actor, double deltax, double deltay) { dirtype_t d[2]; int tdir; @@ -715,19 +709,19 @@ void P_DoNewChaseDir (AActor *actor, fixed_t deltax, fixed_t deltay) olddir = (dirtype_t)actor->movedir; turnaround = opposite[olddir]; - if (deltax>10*FRACUNIT) - d[0]= DI_EAST; - else if (deltax<-10*FRACUNIT) - d[0]= DI_WEST; + if (deltax > 10) + d[0] = DI_EAST; + else if (deltax < -10) + d[0] = DI_WEST; else - d[0]=DI_NODIR; + d[0] = DI_NODIR; - if (deltay<-10*FRACUNIT) - d[1]= DI_SOUTH; - else if (deltay>10*FRACUNIT) - d[1]= DI_NORTH; + if (deltay < -10) + d[1] = DI_SOUTH; + else if (deltay>10) + d[1] = DI_NORTH; else - d[1]=DI_NODIR; + d[1] = DI_NODIR; // try direct route if (d[0] != DI_NODIR && d[1] != DI_NODIR) @@ -744,7 +738,7 @@ void P_DoNewChaseDir (AActor *actor, fixed_t deltax, fixed_t deltay) // try other directions if (!(actor->flags5 & MF5_AVOIDINGDROPOFF)) { - if ((pr_newchasedir() > 200 || abs(deltay) > abs(deltax))) + if ((pr_newchasedir() > 200 || fabs(deltay) > fabs(deltax))) { swapvalues (d[0], d[1]); } @@ -848,25 +842,24 @@ void P_DoNewChaseDir (AActor *actor, fixed_t deltax, fixed_t deltay) void P_NewChaseDir(AActor * actor) { - fixedvec2 delta; + DVector2 delta; actor->strafecount = 0; if ((actor->flags5&MF5_CHASEGOAL || actor->goal == actor->target) && actor->goal!=NULL) { - delta = actor->_f_Vec2To(actor->goal); + delta = actor->Vec2To(actor->goal); } else if (actor->target != NULL) { - delta = actor->_f_Vec2To(actor->target); + 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)) { - delta.x = -delta.x; - delta.y = -delta.y; + delta = -delta; } } } @@ -884,7 +877,7 @@ void P_NewChaseDir(AActor * actor) !(actor->flags2 & MF2_ONMOBJ) && !(actor->flags & MF_FLOAT) && !(i_compatflags & COMPATF_DROPOFF)) { - FBoundingBox box(actor->_f_X(), actor->_f_Y(), actor->_f_radius()); + FBoundingBox box(actor->X(), actor->Y(), actor->radius); FBlockLinesIterator it(box); line_t *line; @@ -899,8 +892,8 @@ void P_NewChaseDir(AActor * actor) box.Bottom() < line->bbox[BOXTOP] && box.BoxOnLineSide(line) == -1) { - double front = line->frontsector->floorplane.ZatPointF(actor->_f_PosRelative(line)); - double back = line->backsector->floorplane.ZatPointF(actor->_f_PosRelative(line)); + double front = line->frontsector->floorplane.ZatPoint(actor->PosRelative(line)); + double back = line->backsector->floorplane.ZatPoint(actor->PosRelative(line)); DAngle angle; // The monster must contact one of the two floors, @@ -933,7 +926,7 @@ void P_NewChaseDir(AActor * actor) // use different dropoff movement logic in P_TryMove actor->flags5|=MF5_AVOIDINGDROPOFF; - P_DoNewChaseDir(actor, FLOAT2FIXED(deltax), FLOAT2FIXED(deltay)); + P_DoNewChaseDir(actor, deltax, deltay); actor->flags5&=~MF5_AVOIDINGDROPOFF; // If moving away from dropoff, set movecount to 1 so that @@ -950,7 +943,7 @@ void P_NewChaseDir(AActor * actor) // MBF code for friends. Cannot be done in ZDoom but left here as a reminder for later implementation. if (actor->flags & target->flags & MF_FRIEND && - distfriend << FRACBITS > dist && + distfriend > dist && !P_IsOnLift(target) && !P_IsUnderDamage(actor)) deltax = -deltax, deltay = -deltay; else @@ -979,12 +972,12 @@ void P_NewChaseDir(AActor * actor) if (ismeleeattacker) { actor->strafecount = pr_enemystrafe() & 15; - delta.x = -delta.x, delta.y = -delta.y; + delta = -delta; } } } - P_DoNewChaseDir(actor, delta.x, delta.y); + 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 @@ -1016,7 +1009,7 @@ void P_RandomChaseDir (AActor *actor) if (actor->flags & MF_FRIENDLY) { AActor *player; - fixedvec2 delta; + DVector2 delta; dirtype_t d[3]; if (actor->FriendPlayer != 0) @@ -1038,18 +1031,18 @@ void P_RandomChaseDir (AActor *actor) { if (pr_newchasedir() & 1 || !P_CheckSight (actor, player)) { - delta = actor->_f_Vec2To(player); + delta = actor->Vec2To(player); - if (delta.x>128*FRACUNIT) + if (delta.X>128) d[1]= DI_EAST; - else if (delta.x<-128*FRACUNIT) + else if (delta.X<-128) d[1]= DI_WEST; else d[1]=DI_NODIR; - if (delta.y<-128*FRACUNIT) + if (delta.Y<-128) d[2]= DI_SOUTH; - else if (delta.y>128*FRACUNIT) + else if (delta.Y>128) d[2]= DI_NORTH; else d[2]=DI_NODIR; @@ -1057,13 +1050,13 @@ void P_RandomChaseDir (AActor *actor) // try direct route if (d[1] != DI_NODIR && d[2] != DI_NODIR) { - actor->movedir = diags[((delta.y<0)<<1) + (delta.x>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(delta.y) > abs(delta.x)) + if (pr_newchasedir() > 200 || fabs(delta.Y) > fabs(delta.X)) { swapvalues (d[1], d[2]); } @@ -1213,7 +1206,7 @@ bool P_IsVisible(AActor *lookee, AActor *other, INTBOOL allaround, FLookExParams // //--------------------------------------------------------------------------- -#define MONS_LOOK_RANGE (20*64*FRACUNIT) +#define MONS_LOOK_RANGE (20*64) #define MONS_LOOK_LIMIT 64 bool P_LookForMonsters (AActor *actor) @@ -1233,7 +1226,7 @@ bool P_LookForMonsters (AActor *actor) { // Not a valid monster continue; } - if (mo->AproxDistance (actor) > MONS_LOOK_RANGE) + if (mo->Distance2D (actor) > MONS_LOOK_RANGE) { // Out of range continue; } @@ -1733,8 +1726,7 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params) if ((player->mo->flags & MF_SHADOW && !(i_compatflags & COMPATF_INVISIBILITY)) || player->mo->flags3 & MF3_GHOST) { - if ((player->mo->AproxDistance (actor) > (128 << FRACBITS)) - && P_AproxDistance (player->mo->_f_velx(), player->mo->_f_vely()) < 5*FRACUNIT) + if (player->mo->Distance2D (actor) > 128 && player->mo->Vel.XY().LengthSquared() < 5*5) { // Player is sneaking - can't detect continue; } @@ -1895,7 +1887,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) PARAM_STATE_OPT (seestate) { seestate = NULL; } AActor *targ = NULL; // Shuts up gcc - fixed_t dist; + double dist; if (fov == 0) fov = 180.; FLookExParams params = { fov, minseedist, maxseedist, maxheardist, flags, seestate }; @@ -1936,7 +1928,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) } else { - dist = self->AproxDistance (targ); + dist = self->Distance2D (targ); // [KS] If the target is too far away, don't respond to the sound. if (maxheardist && dist > maxheardist) @@ -2225,7 +2217,7 @@ nosee: // enhancements. // //============================================================================= -#define CLASS_BOSS_STRAFE_RANGE 64*10*FRACUNIT +#define CLASS_BOSS_STRAFE_RANGE 64*10 void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *meleestate, FState *missilestate, bool playactive, bool nightmarefast, bool dontmove, int flags) { @@ -2598,14 +2590,14 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) if (self->movedir != DI_NODIR) { - const fixed_t absSpeed = abs (self->_f_speed()); - fixedvec2 viletry = self->Vec2Offset( - int (absSpeed * xspeed[self->movedir]), - int (absSpeed * yspeed[self->movedir]), true); + const double absSpeed = fabs (self->Speed); + DVector2 viletry = self->Vec2Offset( + absSpeed * xspeed[self->movedir], + absSpeed * yspeed[self->movedir], true); FPortalGroupArray check(FPortalGroupArray::PGA_Full3d); - FMultiBlockThingsIterator it(check, viletry.x, viletry.y, self->_f_Z() - 64* FRACUNIT, self->_f_Top() + 64 * FRACUNIT, 32 * FRACUNIT, false, NULL); + FMultiBlockThingsIterator it(check, viletry.X, viletry.Y, self->Z() - 64, self->Top() + 64, 32., false, NULL); FMultiBlockThingsIterator::CheckResult cres; while (it.Next(&cres)) { @@ -2614,10 +2606,10 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) if (raisestate != NULL) { // use the current actor's _f_radius() instead of the Arch Vile's default. - fixed_t maxdist = corpsehit->GetDefault()->_f_radius() + self->_f_radius(); + double maxdist = corpsehit->GetDefault()->radius + self->radius; - if (abs(corpsehit->_f_Pos().x - cres.position.x) > maxdist || - abs(corpsehit->_f_Pos().y - cres.position.y) > maxdist) + if (fabs(corpsehit->X() - cres.Position.X) > maxdist || + fabs(corpsehit->Y() - cres.Position.Y) > maxdist) continue; // not actually touching // Let's check if there are floors in between the archvile and its target @@ -2868,7 +2860,7 @@ void A_Face(AActor *self, AActor *other, DAngle max_turn, DAngle max_pitch, DAng target_z = other->Center(); } - //Note there is no +32*FRACUNIT on purpose. This is for customization sake. + //Note there is no +32 on purpose. This is for customization sake. //If one doesn't want this behavior, just don't use FAF_BOTTOM. if (flags & FAF_BOTTOM) target_z = other->Z() + other->GetBobOffset(); @@ -3169,7 +3161,7 @@ AInventory *P_DropItem (AActor *source, PClassActor *type, int dropamount, int c } if (style == 2) { - spawnz = 24*FRACUNIT; + spawnz = 24; } else { @@ -3399,13 +3391,13 @@ void A_BossDeath(AActor *self) { if (type == NAME_Fatso) { - EV_DoFloor (DFloor::floorLowerToLowest, NULL, 666, FRACUNIT, 0, -1, 0, false); + EV_DoFloor (DFloor::floorLowerToLowest, NULL, 666, 1., 0, -1, 0, false); return; } if (type == NAME_Arachnotron) { - EV_DoFloor (DFloor::floorRaiseByTexture, NULL, 667, FRACUNIT, 0, -1, 0, false); + EV_DoFloor (DFloor::floorRaiseByTexture, NULL, 667, 1., 0, -1, 0, false); return; } } @@ -3414,15 +3406,15 @@ void A_BossDeath(AActor *self) switch (level.flags & LEVEL_SPECACTIONSMASK) { case LEVEL_SPECLOWERFLOOR: - EV_DoFloor (DFloor::floorLowerToLowest, NULL, 666, FRACUNIT, 0, -1, 0, false); + EV_DoFloor (DFloor::floorLowerToLowest, NULL, 666, 1., 0, -1, 0, false); return; case LEVEL_SPECLOWERFLOORTOHIGHEST: - EV_DoFloor (DFloor::floorLowerToHighest, NULL, 666, FRACUNIT, 0, -1, 0, false); + EV_DoFloor (DFloor::floorLowerToHighest, NULL, 666, 1., 0, -1, 0, false); return; case LEVEL_SPECOPENDOOR: - EV_DoDoor (DDoor::doorOpen, NULL, NULL, 666, 8*FRACUNIT, 0, 0, 0); + EV_DoDoor (DDoor::doorOpen, NULL, NULL, 666, 8., 0, 0, 0); return; } } diff --git a/src/p_enemy.h b/src/p_enemy.h index ee091ce25..9e6b03b72 100644 --- a/src/p_enemy.h +++ b/src/p_enemy.h @@ -47,13 +47,9 @@ struct FLookExParams }; void P_DaggerAlert (AActor *target, AActor *emitter); -void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soundblocks, AActor *emitter=NULL, fixed_t maxdist=0); +void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soundblocks, AActor *emitter=NULL, double maxdist=0); bool P_HitFriend (AActor *self); -void P_NoiseAlert (AActor *target, AActor *emmiter, bool splash=false, fixed_t maxdist=0); -inline void P_NoiseAlert(AActor *target, AActor *emmiter, bool splash, double maxdist) -{ - P_NoiseAlert(target, emmiter, splash, FLOAT2FIXED(maxdist)); -} +void P_NoiseAlert (AActor *target, AActor *emmiter, bool splash=false, double maxdist=0); bool P_CheckMeleeRange2 (AActor *actor); bool P_Move (AActor *actor); diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 35209a9f9..1a9fcfce5 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -85,11 +85,11 @@ FName MeansOfDeath; // void P_TouchSpecialThing (AActor *special, AActor *toucher) { - fixed_t delta = special->_f_Z() - toucher->_f_Z(); + double delta = special->Z() - toucher->Z(); // The pickup is at or above the toucher's feet OR // The pickup is below the toucher. - if (delta > toucher->_f_height() || delta < MIN(-32*FRACUNIT, -special->_f_height())) + if (delta > toucher->Height || delta < MIN(-32., -special->Height)) { // out of reach return; } @@ -931,7 +931,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, { DAngle ang; player_t *player = NULL; - fixed_t thrust; + double thrust; int temp; int painchance = 0; FState * woundstate = NULL; @@ -1163,27 +1163,21 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, ang = origin->AngleTo(target); } - // Calculate this as float to avoid overflows so that the - // clamping that had to be done here can be removed. - double fltthrust; - - fltthrust = mod == NAME_MDK ? 10 : 32; + thrust = mod == NAME_MDK ? 10 : 32; if (target->Mass > 0) { - fltthrust = clamp((damage * 0.125 * kickback) / target->Mass, 0., fltthrust); + thrust = clamp((damage * 0.125 * kickback) / target->Mass, 0., thrust); } - thrust = FLOAT2FIXED(fltthrust); - // Don't apply ultra-small damage thrust - if (thrust < FRACUNIT/100) thrust = 0; + if (thrust < 0.01) thrust = 0; // make fall forwards sometimes if ((damage < 40) && (damage > target->health) && (target->Z() - origin->Z() > 64) && (pr_damagemobj()&1) // [RH] But only if not too fast and not flying - && thrust < 10*FRACUNIT + && thrust < 10 && !(target->flags & MF_NOGRAVITY) && (inflictor == NULL || !(inflictor->flags5 & MF5_NOFORWARDFALL)) ) @@ -1204,7 +1198,7 @@ int P_DamageMobj (AActor *target, AActor *inflictor, AActor *source, int damage, } else { - target->Thrust(ang, FIXED2DBL(thrust)); + target->Thrust(ang, thrust); } } } diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 28764d4d3..79436ae95 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -232,44 +232,44 @@ FUNC(LS_Polyobj_Stop) FUNC(LS_Door_Close) // Door_Close (tag, speed, lighttag) { - return EV_DoDoor (DDoor::doorClose, ln, it, arg0, _f_SPEED(arg1), 0, 0, arg2); + return EV_DoDoor (DDoor::doorClose, ln, it, arg0, SPEED(arg1), 0, 0, arg2); } FUNC(LS_Door_Open) // Door_Open (tag, speed, lighttag) { - return EV_DoDoor (DDoor::doorOpen, ln, it, arg0, _f_SPEED(arg1), 0, 0, arg2); + return EV_DoDoor (DDoor::doorOpen, ln, it, arg0, SPEED(arg1), 0, 0, arg2); } FUNC(LS_Door_Raise) // Door_Raise (tag, speed, delay, lighttag) { - return EV_DoDoor (DDoor::doorRaise, ln, it, arg0, _f_SPEED(arg1), TICS(arg2), 0, arg3); + return EV_DoDoor (DDoor::doorRaise, ln, it, arg0, SPEED(arg1), TICS(arg2), 0, arg3); } FUNC(LS_Door_LockedRaise) // Door_LockedRaise (tag, speed, delay, lock, lighttag) { return EV_DoDoor (arg2 ? DDoor::doorRaise : DDoor::doorOpen, ln, it, - arg0, _f_SPEED(arg1), TICS(arg2), arg3, arg4); + arg0, SPEED(arg1), TICS(arg2), arg3, arg4); } FUNC(LS_Door_CloseWaitOpen) // Door_CloseWaitOpen (tag, speed, delay, lighttag) { - return EV_DoDoor (DDoor::doorCloseWaitOpen, ln, it, arg0, _f_SPEED(arg1), OCTICS(arg2), 0, arg3); + return EV_DoDoor (DDoor::doorCloseWaitOpen, ln, it, arg0, SPEED(arg1), OCTICS(arg2), 0, arg3); } FUNC(LS_Door_WaitRaise) // Door_WaitRaise(tag, speed, delay, wait, lighttag) { - return EV_DoDoor(DDoor::doorWaitRaise, ln, it, arg0, _f_SPEED(arg1), TICS(arg2), 0, arg4, false, TICS(arg3)); + return EV_DoDoor(DDoor::doorWaitRaise, ln, it, arg0, SPEED(arg1), TICS(arg2), 0, arg4, false, TICS(arg3)); } FUNC(LS_Door_WaitClose) // Door_WaitRaise(tag, speed, wait, lighttag) { - return EV_DoDoor(DDoor::doorWaitClose, ln, it, arg0, _f_SPEED(arg1), 0, 0, arg3, false, TICS(arg2)); + return EV_DoDoor(DDoor::doorWaitClose, ln, it, arg0, SPEED(arg1), 0, 0, arg3, false, TICS(arg2)); } FUNC(LS_Door_Animated) @@ -309,86 +309,86 @@ FUNC(LS_Generic_Door) tag = arg0; lightTag = 0; } - return EV_DoDoor (type, ln, it, tag, _f_SPEED(arg1), OCTICS(arg3), arg4, lightTag, boomgen); + return EV_DoDoor (type, ln, it, tag, SPEED(arg1), OCTICS(arg3), arg4, lightTag, boomgen); } FUNC(LS_Floor_LowerByValue) // Floor_LowerByValue (tag, speed, height, change) { - return EV_DoFloor (DFloor::floorLowerByValue, ln, arg0, _f_SPEED(arg1), FRACUNIT*arg2, -1, CHANGE(arg3), false); + return EV_DoFloor (DFloor::floorLowerByValue, ln, arg0, SPEED(arg1), arg2, -1, CHANGE(arg3), false); } FUNC(LS_Floor_LowerToLowest) // Floor_LowerToLowest (tag, speed, change) { - return EV_DoFloor (DFloor::floorLowerToLowest, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), false); + return EV_DoFloor (DFloor::floorLowerToLowest, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), false); } FUNC(LS_Floor_LowerToHighest) // Floor_LowerToHighest (tag, speed, adjust, hereticlower) { - return EV_DoFloor (DFloor::floorLowerToHighest, ln, arg0, _f_SPEED(arg1), (arg2-128)*FRACUNIT, -1, 0, false, arg3==1); + return EV_DoFloor (DFloor::floorLowerToHighest, ln, arg0, SPEED(arg1), (arg2-128), -1, 0, false, arg3==1); } FUNC(LS_Floor_LowerToHighestEE) // Floor_LowerToHighest (tag, speed, change) { - return EV_DoFloor (DFloor::floorLowerToHighest, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), false); + return EV_DoFloor (DFloor::floorLowerToHighest, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), false); } FUNC(LS_Floor_LowerToNearest) // Floor_LowerToNearest (tag, speed, change) { - return EV_DoFloor (DFloor::floorLowerToNearest, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), false); + return EV_DoFloor (DFloor::floorLowerToNearest, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), false); } FUNC(LS_Floor_RaiseByValue) // Floor_RaiseByValue (tag, speed, height, change, crush) { - return EV_DoFloor (DFloor::floorRaiseByValue, ln, arg0, _f_SPEED(arg1), FRACUNIT*arg2, CRUSH(arg4), CHANGE(arg3), true); + return EV_DoFloor (DFloor::floorRaiseByValue, ln, arg0, SPEED(arg1), arg2, CRUSH(arg4), CHANGE(arg3), true); } FUNC(LS_Floor_RaiseToHighest) // Floor_RaiseToHighest (tag, speed, change, crush) { - return EV_DoFloor (DFloor::floorRaiseToHighest, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorRaiseToHighest, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); } FUNC(LS_Floor_RaiseToNearest) // Floor_RaiseToNearest (tag, speed, change, crush) { - return EV_DoFloor (DFloor::floorRaiseToNearest, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorRaiseToNearest, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); } FUNC(LS_Floor_RaiseToLowest) // Floor_RaiseToLowest (tag, change, crush) { // This is merely done for completeness as it's a rather pointless addition. - return EV_DoFloor (DFloor::floorRaiseToLowest, ln, arg0, 2*FRACUNIT, 0, CRUSH(arg3), CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorRaiseToLowest, ln, arg0, 2., 0, CRUSH(arg3), CHANGE(arg2), true); } FUNC(LS_Floor_RaiseAndCrush) // Floor_RaiseAndCrush (tag, speed, crush, crushmode) { - return EV_DoFloor (DFloor::floorRaiseAndCrush, ln, arg0, _f_SPEED(arg1), 0, arg2, 0, CRUSHTYPE(arg3)); + return EV_DoFloor (DFloor::floorRaiseAndCrush, ln, arg0, SPEED(arg1), 0, arg2, 0, CRUSHTYPE(arg3)); } FUNC(LS_Floor_RaiseAndCrushDoom) // Floor_RaiseAndCrushDoom (tag, speed, crush, crushmode) { - return EV_DoFloor (DFloor::floorRaiseAndCrushDoom, ln, arg0, _f_SPEED(arg1), 0, arg2, 0, CRUSHTYPE(arg3)); + return EV_DoFloor (DFloor::floorRaiseAndCrushDoom, ln, arg0, SPEED(arg1), 0, arg2, 0, CRUSHTYPE(arg3)); } FUNC(LS_Floor_RaiseByValueTimes8) // FLoor_RaiseByValueTimes8 (tag, speed, height, change, crush) { - return EV_DoFloor (DFloor::floorRaiseByValue, ln, arg0, _f_SPEED(arg1), FRACUNIT*arg2*8, CRUSH(arg4), CHANGE(arg3), true); + return EV_DoFloor (DFloor::floorRaiseByValue, ln, arg0, SPEED(arg1), arg2*8, CRUSH(arg4), CHANGE(arg3), true); } FUNC(LS_Floor_LowerByValueTimes8) // Floor_LowerByValueTimes8 (tag, speed, height, change) { - return EV_DoFloor (DFloor::floorLowerByValue, ln, arg0, _f_SPEED(arg1), FRACUNIT*arg2*8, -1, CHANGE(arg3), false); + return EV_DoFloor (DFloor::floorLowerByValue, ln, arg0, SPEED(arg1), arg2*8, -1, CHANGE(arg3), false); } FUNC(LS_Floor_CrushStop) @@ -400,13 +400,13 @@ FUNC(LS_Floor_CrushStop) FUNC(LS_Floor_LowerInstant) // Floor_LowerInstant (tag, unused, height, change) { - return EV_DoFloor (DFloor::floorLowerInstant, ln, arg0, 0, arg2*FRACUNIT*8, -1, CHANGE(arg3), false); + return EV_DoFloor (DFloor::floorLowerInstant, ln, arg0, 0., arg2*8, -1, CHANGE(arg3), false); } FUNC(LS_Floor_RaiseInstant) // Floor_RaiseInstant (tag, unused, height, change, crush) { - return EV_DoFloor (DFloor::floorRaiseInstant, ln, arg0, 0, arg2*FRACUNIT*8, CRUSH(arg4), CHANGE(arg3), true); + return EV_DoFloor (DFloor::floorRaiseInstant, ln, arg0, 0., arg2*8, CRUSH(arg4), CHANGE(arg3), true); } FUNC(LS_Floor_ToCeilingInstant) @@ -418,57 +418,57 @@ FUNC(LS_Floor_ToCeilingInstant) FUNC(LS_Floor_MoveToValueTimes8) // Floor_MoveToValueTimes8 (tag, speed, height, negative, change) { - return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, _f_SPEED(arg1), - arg2*FRACUNIT*8*(arg3?-1:1), -1, CHANGE(arg4), false); + return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, SPEED(arg1), + arg2*8*(arg3?-1:1), -1, CHANGE(arg4), false); } FUNC(LS_Floor_MoveToValue) // Floor_MoveToValue (tag, speed, height, negative, change) { return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, _f_SPEED(arg1), - arg2*FRACUNIT*(arg3?-1:1), -1, CHANGE(arg4), false); + arg2*(arg3?-1:1), -1, CHANGE(arg4), false); } FUNC(LS_Floor_RaiseToLowestCeiling) // Floor_RaiseToLowestCeiling (tag, speed, change, crush) { - return EV_DoFloor (DFloor::floorRaiseToLowestCeiling, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorRaiseToLowestCeiling, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); } FUNC(LS_Floor_LowerToLowestCeiling) // Floor_LowerToLowestCeiling (tag, speed, change) { - return EV_DoFloor (DFloor::floorLowerToLowestCeiling, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorLowerToLowestCeiling, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), true); } FUNC(LS_Floor_RaiseByTexture) // Floor_RaiseByTexture (tag, speed, change, crush) { - return EV_DoFloor (DFloor::floorRaiseByTexture, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorRaiseByTexture, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); } FUNC(LS_Floor_LowerByTexture) // Floor_LowerByTexture (tag, speed, change, crush) { - return EV_DoFloor (DFloor::floorLowerByTexture, ln, arg0, _f_SPEED(arg1), 0, -1, CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorLowerByTexture, ln, arg0, SPEED(arg1), 0, -1, CHANGE(arg2), true); } FUNC(LS_Floor_RaiseToCeiling) // Floor_RaiseToCeiling (tag, speed, change, crush) { - return EV_DoFloor (DFloor::floorRaiseToCeiling, ln, arg0, _f_SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); + return EV_DoFloor (DFloor::floorRaiseToCeiling, ln, arg0, SPEED(arg1), 0, CRUSH(arg3), CHANGE(arg2), true); } FUNC(LS_Floor_RaiseByValueTxTy) // Floor_RaiseByValueTxTy (tag, speed, height) { - return EV_DoFloor (DFloor::floorRaiseAndChange, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, -1, 0, false); + return EV_DoFloor (DFloor::floorRaiseAndChange, ln, arg0, SPEED(arg1), arg2, -1, 0, false); } FUNC(LS_Floor_LowerToLowestTxTy) // Floor_LowerToLowestTxTy (tag, speed) { - return EV_DoFloor (DFloor::floorLowerAndChange, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, -1, 0, false); + return EV_DoFloor (DFloor::floorLowerAndChange, ln, arg0, SPEED(arg1), arg2, -1, 0, false); } FUNC(LS_Floor_Waggle) @@ -498,7 +498,7 @@ FUNC(LS_Floor_TransferNumeric) FUNC(LS_Floor_Donut) // Floor_Donut (pillartag, pillarspeed, slimespeed) { - return EV_DoDonut (arg0, ln, _f_SPEED(arg1), _f_SPEED(arg2)); + return EV_DoDonut (arg0, ln, SPEED(arg1), SPEED(arg2)); } FUNC(LS_Generic_Floor) @@ -533,7 +533,7 @@ FUNC(LS_Generic_Floor) } } - return EV_DoFloor (type, ln, arg0, _f_SPEED(arg1), arg2*FRACUNIT, + return EV_DoFloor (type, ln, arg0, SPEED(arg1), arg2, (arg4 & 16) ? 20 : -1, arg4 & 7, false); } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 28f264002..1bdad1bc2 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4458,7 +4458,7 @@ void AActor::AdjustFloorClip () return; } - double oldclip = _f_floorclip(); + double oldclip = Floorclip; double shallowestclip = INT_MAX; const msecnode_t *m; diff --git a/src/p_spec.h b/src/p_spec.h index 78965581e..99c2d0fee 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -787,6 +787,11 @@ inline bool EV_DoFloor(DFloor::EFloor floortype, line_t *line, int tag, { return EV_DoFloor(floortype, line, tag, FLOAT2FIXED(speed), FLOAT2FIXED(height), crush, change, hexencrush, hereticlower); } +inline bool EV_DoFloor(DFloor::EFloor floortype, line_t *line, int tag, + double speed, int height, int crush, int change, bool hexencrush, bool hereticlower = false) +{ + return EV_DoFloor(floortype, line, tag, FLOAT2FIXED(speed), height, crush, change, hexencrush, hereticlower); +} bool EV_FloorCrushStop (int tag); bool EV_DoDonut (int tag, line_t *line, fixed_t pillarspeed, fixed_t slimespeed); From 6e93264016367ef59fd517798dbaa6a0ea2cf774 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 26 Mar 2016 23:19:38 +0100 Subject: [PATCH 18/44] - started floatification on p_map.cpp. --- src/p_checkposition.h | 16 ++- src/p_doors.cpp | 8 +- src/p_lights.cpp | 6 +- src/p_lnspec.cpp | 2 +- src/p_local.h | 19 +-- src/p_map.cpp | 302 ++++++++++++++---------------------------- src/p_maputl.cpp | 26 ++++ src/p_maputl.h | 13 +- src/p_spec.h | 2 +- src/r_defs.h | 5 + 10 files changed, 172 insertions(+), 227 deletions(-) diff --git a/src/p_checkposition.h b/src/p_checkposition.h index 713bc79b7..3a67a3610 100644 --- a/src/p_checkposition.h +++ b/src/p_checkposition.h @@ -13,9 +13,7 @@ struct FCheckPosition { // in AActor *thing; - fixed_t x; - fixed_t y; - fixed_t z; + DVector3 pos; // out sector_t *sector; @@ -59,6 +57,18 @@ struct FCheckPosition { return FLOAT2FIXED(dropoffz); } + inline fixed_t _f_X() + { + return FLOAT2FIXED(pos.X); + } + inline fixed_t _f_Y() + { + return FLOAT2FIXED(pos.Y); + } + inline fixed_t _f_Z() + { + return FLOAT2FIXED(pos.Z); + } }; diff --git a/src/p_doors.cpp b/src/p_doors.cpp index 3cf66119c..754f216d1 100644 --- a/src/p_doors.cpp +++ b/src/p_doors.cpp @@ -142,8 +142,8 @@ void DDoor::Tick () // killough 10/98: implement gradual lighting effects if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.d) { - EV_LightTurnOnPartway (m_LightTag, FixedDiv (m_Sector->ceilingplane.d + m_Sector->floorplane.d, - m_TopDist + m_Sector->floorplane.d)); + EV_LightTurnOnPartway (m_LightTag, + FIXED2DBL(FixedDiv (m_Sector->ceilingplane.d + m_Sector->floorplane.d, m_TopDist + m_Sector->floorplane.d))); } if (res == pastdest) @@ -188,8 +188,8 @@ void DDoor::Tick () // killough 10/98: implement gradual lighting effects if (m_LightTag != 0 && m_TopDist != -m_Sector->floorplane.d) { - EV_LightTurnOnPartway (m_LightTag, FixedDiv (m_Sector->ceilingplane.d + m_Sector->floorplane.d, - m_TopDist + m_Sector->floorplane.d)); + EV_LightTurnOnPartway (m_LightTag, + FIXED2DBL(FixedDiv (m_Sector->ceilingplane.d + m_Sector->floorplane.d, m_TopDist + m_Sector->floorplane.d))); } if (res == pastdest) diff --git a/src/p_lights.cpp b/src/p_lights.cpp index c9e85b800..bd2535c81 100644 --- a/src/p_lights.cpp +++ b/src/p_lights.cpp @@ -474,9 +474,9 @@ void EV_LightTurnOn (int tag, int bright) // //----------------------------------------------------------------------------- -void EV_LightTurnOnPartway (int tag, fixed_t frac) +void EV_LightTurnOnPartway (int tag, double frac) { - frac = clamp (frac, 0, FRACUNIT); + frac = clamp(frac, 0., 1.); // Search all sectors for ones with same tag as activating line int secnum; @@ -500,7 +500,7 @@ void EV_LightTurnOnPartway (int tag, fixed_t frac) } } } - sector->SetLightLevel(DMulScale16 (frac, bright, FRACUNIT-frac, min)); + sector->SetLightLevel(int(frac * bright + (1 - frac) * min)); } } diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 79436ae95..6697f20f3 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -498,7 +498,7 @@ FUNC(LS_Floor_TransferNumeric) FUNC(LS_Floor_Donut) // Floor_Donut (pillartag, pillarspeed, slimespeed) { - return EV_DoDonut (arg0, ln, SPEED(arg1), SPEED(arg2)); + return EV_DoDonut (arg0, ln, _f_SPEED(arg1), _f_SPEED(arg2)); } FUNC(LS_Generic_Floor) diff --git a/src/p_local.h b/src/p_local.h index e9a9b9992..e48b04a61 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -266,8 +266,8 @@ extern msecnode_t *sector_list; // phares 3/16/98 struct spechit_t { line_t *line; - fixedvec2 oldrefpos; - fixedvec2 refpos; + DVector2 Oldrefpos; + DVector2 Refpos; }; extern TArray spechit; @@ -312,15 +312,18 @@ inline bool P_CheckMove(AActor *thing, double x, double y) return P_CheckMove(thing, FLOAT2FIXED(x), FLOAT2FIXED(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 + +bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modifyactor = true); // [RH] Added z and telefrag parameters + +inline bool P_TeleportMove (AActor* thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag, bool modifyactor = true) +{ + return P_TeleportMove(thing, DVector3(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)), telefrag, modifyactor); +} 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); -} -inline bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modifyactor = true) -{ - return P_TeleportMove(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), telefrag, modifyactor); + return P_TeleportMove(thing, DVector3(FIXED2DBL(pos.x), FIXED2DBL(pos.y), FIXED2DBL(pos.z)), telefrag, modifyactor); } + void P_PlayerStartStomp (AActor *actor, bool mononly=false); // [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_map.cpp b/src/p_map.cpp index 82eb9360a..d081ca9ac 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -64,7 +64,7 @@ CVAR(Bool, cl_bloodsplats, true, CVAR_ARCHIVE) CVAR(Int, sv_smartaim, 0, CVAR_ARCHIVE | CVAR_SERVERINFO) CVAR(Bool, cl_doautoaim, false, CVAR_ARCHIVE) -static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, fixedvec2 * posforwindowcheck = NULL); +static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, DVector2 * posforwindowcheck = NULL); static void SpawnShootDecal(AActor *t1, const FTraceResults &trace); static void SpawnDeepSplash(AActor *t1, const FTraceResults &trace, AActor *puff); @@ -81,77 +81,6 @@ TArray portalhit; // Temporary holder for thing_sectorlist threads msecnode_t* sector_list = NULL; // phares 3/16/98 - -//========================================================================== -// -// GetCoefficientClosestPointInLine24 -// -// Formula: (dotProduct(ldv1 - tm, ld) << 24) / dotProduct(ld, ld) -// with: ldv1 = (ld->v1->x, ld->v1->y), tm = (tm.x, tm.y) -// and ld = (ld->dx, ld->dy) -// Returns truncated to range [0, 1 << 24]. -// -//========================================================================== - -static inline fixed_t GetCoefficientClosestPointInLine24(line_t *ld, fixedvec2 pos) -{ -#ifndef USE_FLOAT - // [EP] Use 64 bit integers in order to keep the exact result of the - // multiplication, because in the case the vertexes have both the - // distance coordinates equal to the map limit (32767 units, which is - // 2147418112 in fixed_t notation), the product result would occupy - // 62 bits and the sum of two products would occupy 63 bits - // in the worst case. If instead the vertexes are very close (1 in - // fixed_t notation, which is 1.52587890625e-05 in float notation), the - // product and the sum can be 1 in the worst case, which is very tiny. - - SQWORD r_num = ((SQWORD(pos.x - ld->v1->x)*ld->dx) + - (SQWORD(pos.y - ld->v1->y)*ld->dy)); - - // The denominator is always positive. Use this to avoid useless - // calculations. - SQWORD r_den = (SQWORD(ld->dx)*ld->dx + SQWORD(ld->dy)*ld->dy); - - if (r_num <= 0) { - // [EP] The numerator is less or equal to zero, hence the closest - // point on the line is the first vertex. Truncate the result to 0. - return 0; - } - - if (r_num >= r_den) { - // [EP] The division is greater or equal to 1, hence the closest - // point on the line is the second vertex. Truncate the result to - // 1 << 24. - return (1 << 24); - } - - // [EP] Deal with the limited bits. The original formula is: - // r = (r_num << 24) / r_den, - // but r_num might be big enough to make the shift overflow. - // Since the numerator can't be saved in a 128bit integer, - // the denominator must be right shifted. If the denominator is - // less than (1 << 24), there would be a division by zero. - // Thanks to the fact that in this code path the denominator is greater - // than the numerator, it's possible to avoid this bad situation by - // just checking the last 24 bits of the numerator. - if ((r_num >> (63 - 24)) != 0) { - // [EP] In fact, if the numerator is greater than - // (1 << (63-24)), the denominator must be greater than - // (1 << (63-24)), hence the denominator won't be zero after - // the right shift by 24 places. - return (fixed_t)(r_num / (r_den >> 24)); - } - // [EP] Having the last 24 bits all zero allows left shifting - // the numerator by 24 bits without overflow. - return (fixed_t)((r_num << 24) / r_den); -#else - double dx = ld->dx; - double dy = ld->dy; - return xs_CRoundToInt(((double)(pos.x - ld->v1->x) * dx + (double)(pos.y - ld->v1->y) * dy) / (dx*dx + dy*dy) * 16777216.f); -#endif -} - - //========================================================================== // // FindRefPoint @@ -160,41 +89,30 @@ static inline fixed_t GetCoefficientClosestPointInLine24(line_t *ld, fixedvec2 p // //========================================================================== -static inline fixedvec2 FindRefPoint(line_t *ld, fixedvec2 pos) +static DVector2 FindRefPoint(line_t *ld, const DVector2 &pos) { // If there's any chance of slopes getting in the way we need to get a proper refpoint, otherwise we can save the work. // Slopes can get in here when: // - the actual sector planes are sloped // - there's 3D floors in this sector // - there's a crossable floor portal (for which the dropoff needs to be calculated within P_LineOpening, and the lower sector can easily have slopes) - if ( - (((ld->frontsector->floorplane.a | ld->frontsector->floorplane.b) | - (ld->backsector->floorplane.a | ld->backsector->floorplane.b) | - (ld->frontsector->ceilingplane.a | ld->frontsector->ceilingplane.b) | - (ld->backsector->ceilingplane.a | ld->backsector->ceilingplane.b)) != 0) - || - ld->backsector->e->XFloor.ffloors.Size() != 0 - || - ld->frontsector->e->XFloor.ffloors.Size() != 0 - || + // + // Todo: check if this bootload of checks even helps or if it adds more than it saves + // + if (ld->frontsector->floorplane.isSlope() || + ld->backsector->floorplane.isSlope() || + ld->frontsector->ceilingplane.isSlope() || + ld->backsector->ceilingplane. isSlope() || + ld->backsector->e->XFloor.ffloors.Size() != 0 || + ld->frontsector->e->XFloor.ffloors.Size() != 0 || + !ld->frontsector->PortalBlocksMovement(sector_t::ceiling) || !ld->frontsector->PortalBlocksMovement(sector_t::floor)) { - fixed_t r = GetCoefficientClosestPointInLine24(ld, pos); - if (r <= 0) - { - pos.x = ld->v1->x; - pos.y = ld->v1->y; - } - else if (r >= (1 << 24)) - { - pos.x = ld->v2->x; - pos.y = ld->v2->y; - } - else - { - pos.x = ld->v1->x + MulScale24(r, ld->dx); - pos.y = ld->v1->y + MulScale24(r, ld->dy); - } + + DVector2 v1 = ld->v1->fPos(); + DVector2 d = ld->Delta(); + double r = clamp(((pos.X - v1.X) * d.X + (pos.Y - v1.Y) * d.Y) / (d.X*d.X + d.Y*d.Y), 0., 1.); + return v1 + d*r; } return pos; } @@ -212,13 +130,7 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLines { line_t *ld = cres.line; - if (box.Right() <= ld->bbox[BOXLEFT] - || box.Left() >= ld->bbox[BOXRIGHT] - || box.Top() <= ld->bbox[BOXBOTTOM] - || box.Bottom() >= ld->bbox[BOXTOP]) - return true; - - if (box.BoxOnLineSide(ld) != -1) + if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1) return true; // A line has been hit @@ -226,7 +138,7 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLines if (ffcf_verbose) { Printf("Hit line %d at position %f,%f, group %d\n", - int(ld - lines), FIXED2FLOAT(cres.position.x), FIXED2FLOAT(cres.position.y), ld->frontsector->PortalGroup); + int(ld - lines), cres.Position.X, cres.Position.Y, ld->frontsector->PortalGroup); } if (!ld->backsector) @@ -234,10 +146,10 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLines return true; } - fixedvec2 refpoint = FindRefPoint(ld, cres.position); + DVector2 refpoint = FindRefPoint(ld, cres.Position); FLineOpening open; - P_LineOpening(open, tmf.thing, ld, refpoint.x, refpoint.y, cres.position.x, cres.position.y, flags); + P_LineOpening(open, tmf.thing, ld, refpoint, &cres.Position, flags); // adjust floor / ceiling heights if (!(flags & FFCF_NOCEILING)) @@ -288,11 +200,11 @@ static bool PIT_FindFloorCeiling(FMultiBlockLinesIterator &mit, FMultiBlockLines void P_GetFloorCeilingZ(FCheckPosition &tmf, int flags) { - sector_t *sec = (!(flags & FFCF_SAMESECTOR) || tmf.thing->Sector == NULL)? P_PointInSector(tmf.x, tmf.y) : tmf.sector; + sector_t *sec = (!(flags & FFCF_SAMESECTOR) || tmf.thing->Sector == NULL)? P_PointInSector(tmf.pos) : tmf.sector; F3DFloor *ffc, *fff; - tmf.ceilingz = FIXED2DBL(sec->NextHighestCeilingAt(tmf.x, tmf.y, tmf.z, tmf.z + tmf.thing->_f_height(), flags, &tmf.ceilingsector, &ffc)); - tmf.floorz = tmf.dropoffz = FIXED2DBL(sec->NextLowestFloorAt(tmf.x, tmf.y, tmf.z, flags, tmf.thing->_f_MaxStepHeight(), &tmf.floorsector, &fff)); + tmf.ceilingz = sec->NextHighestCeilingAt(tmf.pos.X, tmf.pos.Y, tmf.pos.Z, tmf.pos.Z + tmf.thing->Height, flags, &tmf.ceilingsector, &ffc); + tmf.floorz = tmf.dropoffz = sec->NextLowestFloorAt(tmf.pos.X, tmf.pos.Y, tmf.pos.Z, flags, tmf.thing->MaxStepHeight, &tmf.floorsector, &fff); if (fff) { @@ -320,9 +232,7 @@ void P_FindFloorCeiling(AActor *actor, int flags) FCheckPosition tmf; tmf.thing = actor; - tmf.x = actor->_f_X(); - tmf.y = actor->_f_Y(); - tmf.z = actor->_f_Z(); + tmf.pos = actor->Pos(); if (flags & FFCF_ONLYSPAWNPOS) { @@ -409,7 +319,7 @@ CCMD(ffcf) // //========================================================================== -bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag, bool modifyactor) +bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modifyactor) { FCheckPosition tmf; sector_t *oldsec = thing->Sector; @@ -420,9 +330,7 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra // The base floor/ceiling is from the subsector that contains the point. // Any contacted lines the step closer together will adjust them. tmf.thing = thing; - tmf.x = x; - tmf.y = y; - tmf.z = z; + tmf.pos = pos; tmf.touchmidtex = false; tmf.abovemidtex = false; P_GetFloorCeilingZ(tmf, 0); @@ -430,23 +338,23 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra bool StompAlwaysFrags = ((thing->flags2 & MF2_TELESTOMP) || (level.flags & LEVEL_MONSTERSTELEFRAG) || telefrag) && !(thing->flags7 & MF7_NOTELESTOMP); // P_LineOpening requires the thing's z to be the destination z in order to work. - fixed_t savedz = thing->_f_Z(); - thing->_f_SetZ(z); - sector_t *sector = P_PointInSector(x, y); + double savedz = thing->Z(); + thing->SetZ(pos.Z); + sector_t *sector = P_PointInSector(pos); FPortalGroupArray grouplist; - FMultiBlockLinesIterator mit(grouplist, x, y, z, thing->_f_height(), thing->_f_radius(), sector); + FMultiBlockLinesIterator mit(grouplist, pos.X, pos.Y, pos.Z, thing->Height, thing->radius, sector); FMultiBlockLinesIterator::CheckResult cres; while (mit.Next(&cres)) { PIT_FindFloorCeiling(mit, cres, mit.Box(), tmf, 0); } - thing->_f_SetZ(savedz); + thing->SetZ(savedz); if (tmf.touchmidtex) tmf.dropoffz = tmf.floorz; - FMultiBlockThingsIterator mit2(grouplist, x, y, z, thing->_f_height(), thing->_f_radius(), false, sector); + FMultiBlockThingsIterator mit2(grouplist, pos.X, pos.Y, pos.Z, thing->Height, thing->radius, false, sector); FMultiBlockThingsIterator::CheckResult cres2; while (mit2.Next(&cres2)) @@ -460,8 +368,8 @@ bool P_TeleportMove(AActor *thing, fixed_t x, fixed_t y, fixed_t z, bool telefra if (th == thing) continue; - fixed_t blockdist = th->_f_radius() + tmf.thing->_f_radius(); - if (abs(th->_f_X() - cres2.position.x) >= blockdist || abs(th->_f_Y() - cres2.position.y) >= blockdist) + double blockdist = th->radius + tmf.thing->radius; + if (fabs(th->X() - cres2.Position.X) >= blockdist || fabs(th->Y() - cres2.Position.Y) >= blockdist) continue; if ((th->flags2 | tmf.thing->flags2) & MF2_THRUACTORS) @@ -477,8 +385,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->_f_Top() || // overhead - z + thing->_f_height() < th->_f_Z()) // underneath + if (pos.Z > th->Top() || // overhead + pos.Z + thing->Height < th->Z()) // underneath continue; } } @@ -499,7 +407,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, false); + thing->SetOrigin(pos, false); thing->floorz = tmf.floorz; thing->ceilingz = tmf.ceilingz; thing->floorsector = tmf.floorsector; @@ -557,8 +465,8 @@ void P_PlayerStartStomp(AActor *actor, bool mononly) if (th == actor || (th->player == actor->player && th->player != NULL)) continue; - fixed_t blockdist = th->_f_radius() + actor->_f_radius(); - if (abs(th->_f_X() - cres.position.x) >= blockdist || abs(th->_f_Y() - cres.position.y) >= blockdist) + double blockdist = th->radius + actor->radius; + if (fabs(th->X() - cres.Position.X) >= blockdist || fabs(th->Y() - cres.Position.Y) >= blockdist) continue; // only kill monsters and other players @@ -618,8 +526,8 @@ double P_GetFriction(const AActor *mo, double *frictionfactor) if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_SWIMMABLE)) continue; - if (mo->_f_Z() > rover->top.plane->ZatPoint(mo) || - mo->_f_Z() < rover->bottom.plane->ZatPoint(mo)) + if (mo->Z() > rover->top.plane->ZatPointF(mo) || + mo->Z() < rover->bottom.plane->ZatPointF(mo)) continue; newfriction = rover->model->GetFriction(rover->top.isceiling, &newmf); @@ -638,7 +546,7 @@ double P_GetFriction(const AActor *mo, double *frictionfactor) for (m = mo->touching_sectorlist; m; m = m->m_tnext) { sec = m->m_sector; - fixedvec3 pos = mo->_f_PosRelative(sec); + DVector3 pos = mo->PosRelative(sec); // 3D floors must be checked, too for (unsigned i = 0; i < sec->e->XFloor.ffloors.Size(); i++) @@ -649,13 +557,13 @@ double P_GetFriction(const AActor *mo, double *frictionfactor) if (rover->flags & FF_SOLID) { // Must be standing on a solid floor - if (mo->Z() != rover->top.plane->ZatPointF(pos)) continue; + if (mo->Z() != rover->top.plane->ZatPoint(pos)) continue; } else if (rover->flags & FF_SWIMMABLE) { // Or on or inside a swimmable floor (e.g. in shallow water) - if (mo->Z() > rover->top.plane->ZatPointF(pos) || - (mo->Top()) < rover->bottom.plane->ZatPointF(pos)) + if (mo->Z() > rover->top.plane->ZatPoint(pos) || + (mo->Top()) < rover->bottom.plane->ZatPoint(pos)) continue; } else @@ -676,9 +584,9 @@ double P_GetFriction(const AActor *mo, double *frictionfactor) } newfriction = sec->GetFriction(sector_t::floor, &newmf); if ((newfriction < friction || friction == ORIG_FRICTION) && - (mo->Z() <= sec->floorplane.ZatPointF(pos) || + (mo->Z() <= sec->floorplane.ZatPoint(pos) || (sec->GetHeightSec() != NULL && - mo->Z() <= sec->heightsec->floorplane.ZatPointF(pos)))) + mo->Z() <= sec->heightsec->floorplane.ZatPoint(pos)))) { friction = newfriction; movefactor = newmf; @@ -781,13 +689,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec line_t *ld = cres.line; bool rail = false; - if (box.Right() <= ld->bbox[BOXLEFT] - || box.Left() >= ld->bbox[BOXRIGHT] - || box.Top() <= ld->bbox[BOXBOTTOM] - || box.Bottom() >= ld->bbox[BOXTOP]) - return true; - - if (box.BoxOnLineSide(ld) != -1) + if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1) return true; // A line has been hit @@ -808,8 +710,8 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec { spechit_t spec; spec.line = ld; - spec.refpos = cres.position; - spec.oldrefpos = tm.thing->_f_PosRelative(ld); + spec.Refpos = cres.Position; + spec.Oldrefpos = tm.thing->PosRelative(ld); portalhit.Push(spec); return true; } @@ -892,15 +794,15 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec } tm.thing->BlockingLine = ld; // Calculate line side based on the actor's original position, not the new one. - CheckForPushSpecial(ld, P_PointOnLineSide(cres.position.x, cres.position.y, ld), tm.thing); + CheckForPushSpecial(ld, P_PointOnLineSide(cres.Position, ld), tm.thing); return false; } } } - fixedvec2 ref = FindRefPoint(ld, cres.position); + DVector2 ref = FindRefPoint(ld, cres.Position); FLineOpening open; - P_LineOpening(open, tm.thing, ld, ref.x, ref.y, cres.position.x, cres.position.y, cres.portalflags); + P_LineOpening(open, tm.thing, ld, ref, &cres.Position, cres.portalflags); // [RH] Steep sectors count as dropoffs, if the actor touches the boundary between a steep slope and something else if (!(tm.thing->flags & MF_DROPOFF) && @@ -917,7 +819,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec // This is to avoid bumpy movement when crossing a linedef with the same slope on both sides. if (open.frontfloorplane == open.backfloorplane && open.bottom > LINEOPEN_MIN) { - open.bottom = open.frontfloorplane._f_ZatPointF(cres.position.x, cres.position.y); + open.bottom = open.frontfloorplane.ZatPoint(cres.Position); } if (rail && @@ -929,7 +831,7 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec // from either side. How long until somebody reports this as a bug and I'm // forced to say, "It's not a bug. It's a feature?" Ugh. (!(level.flags2 & LEVEL2_RAILINGHACK) || - open.bottom == tm.thing->Sector->floorplane._f_ZatPointF(ref.x, ref.y))) + open.bottom == tm.thing->Sector->floorplane.ZatPoint(ref))) { open.bottom += 32; } @@ -976,15 +878,15 @@ bool PIT_CheckLine(FMultiBlockLinesIterator &mit, FMultiBlockLinesIterator::Chec if (ld->special) { spec.line = ld; - spec.refpos = cres.position; - spec.oldrefpos = tm.thing->_f_PosRelative(ld); + spec.Refpos = cres.Position; + spec.Oldrefpos = tm.thing->PosRelative(ld); spechit.Push(spec); } if (ld->isLinePortal()) { spec.line = ld; - spec.refpos = cres.position; - spec.oldrefpos = tm.thing->_f_PosRelative(ld); + spec.Refpos = cres.Position; + spec.Oldrefpos = tm.thing->PosRelative(ld); portalhit.Push(spec); } @@ -1012,13 +914,7 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera // if in another vertical section let's just ignore it. if (cres.portalflags & (FFCF_NOCEILING | FFCF_NOFLOOR)) return false; - if (box.Right() <= cres.line->bbox[BOXLEFT] - || box.Left() >= cres.line->bbox[BOXRIGHT] - || box.Top() <= cres.line->bbox[BOXBOTTOM] - || box.Bottom() >= cres.line->bbox[BOXTOP]) - return false; - - if (box.BoxOnLineSide(cres.line) != -1) + if (!box.inRange(cres.line) || box.BoxOnLineSide(cres.line) != -1) return false; line_t *lp = cres.line->getPortalDestination(); @@ -1033,7 +929,7 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera if (lp->backsector == NULL) lp->backsector = lp->frontsector; tm.thing->AddZ(zofs); - FBoundingBox pbox(cres.position.x, cres.position.y, tm.thing->_f_radius()); + FBoundingBox pbox(cres.Position.X, cres.Position.Y, tm.thing->radius); FBlockLinesIterator it(pbox); bool ret = false; line_t *ld; @@ -1041,22 +937,16 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera // Check all lines at the destination while ((ld = it.Next())) { - if (pbox.Right() <= ld->bbox[BOXLEFT] - || pbox.Left() >= ld->bbox[BOXRIGHT] - || pbox.Top() <= ld->bbox[BOXBOTTOM] - || pbox.Bottom() >= ld->bbox[BOXTOP]) - continue; - - if (pbox.BoxOnLineSide(ld) != -1) + if (!pbox.inRange(ld) || pbox.BoxOnLineSide(ld) != -1) continue; if (ld->backsector == NULL) continue; - fixedvec2 ref = FindRefPoint(ld, cres.position); + DVector2 ref = FindRefPoint(ld, cres.Position); FLineOpening open; - P_LineOpening(open, tm.thing, ld, ref.x, ref.y, cres.position.x, cres.position.y, 0); + P_LineOpening(open, tm.thing, ld, ref, &cres.Position, 0); // adjust floor / ceiling heights if (open.top - zofs < tm.ceilingz) @@ -1610,9 +1500,9 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo tm.thing = thing; - tm.x = x; - tm.y = y; - tm.z = thing->_f_Z(); + tm.pos.X = FIXED2DBL(x); + tm.pos.Y = FIXED2DBL(y); + tm.pos.Z = thing->Z(); newsec = tm.sector = P_PointInSector(x, y); tm.ceilingline = thing->BlockingLine = NULL; @@ -1957,32 +1847,30 @@ void P_FakeZMovement(AActor *mo) // //=========================================================================== -static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, fixedvec2 *posforwindowcheck) +static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, DVector2 *posforwindowcheck) { if (line->special && !(mobj->flags6 & MF6_NOTRIGGER)) { if (posforwindowcheck && !(ib_compatflags & BCOMPATF_NOWINDOWCHECK) && line->backsector != NULL) { // Make sure this line actually blocks us and is not a window // or similar construct we are standing inside of. - fixedvec3 pos = mobj->_f_PosRelative(line); - fixed_t fzt = line->frontsector->ceilingplane.ZatPoint(*posforwindowcheck); - fixed_t fzb = line->frontsector->floorplane.ZatPoint(*posforwindowcheck); - fixed_t bzt = line->backsector->ceilingplane.ZatPoint(*posforwindowcheck); - fixed_t bzb = line->backsector->floorplane.ZatPoint(*posforwindowcheck); - if (fzt >= mobj->_f_Top() && bzt >= mobj->_f_Top() && - fzb <= mobj->_f_Z() && bzb <= mobj->_f_Z()) + DVector3 pos = mobj->PosRelative(line); + double fzt = line->frontsector->ceilingplane.ZatPoint(*posforwindowcheck); + double fzb = line->frontsector->floorplane.ZatPoint(*posforwindowcheck); + double bzt = line->backsector->ceilingplane.ZatPoint(*posforwindowcheck); + double bzb = line->backsector->floorplane.ZatPoint(*posforwindowcheck); + if (fzt >= mobj->Top() && bzt >= mobj->Top() && + fzb <= mobj->Z() && bzb <= mobj->Z()) { // we must also check if some 3D floor in the backsector may be blocking - for (unsigned int i = 0; ibacksector->e->XFloor.ffloors.Size(); i++) + for (auto rover : line->backsector->e->XFloor.ffloors) { - F3DFloor* rover = line->backsector->e->XFloor.ffloors[i]; - if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - fixed_t ff_bottom = rover->bottom.plane->ZatPoint(*posforwindowcheck); - fixed_t ff_top = rover->top.plane->ZatPoint(*posforwindowcheck); + double ff_bottom = rover->bottom.plane->ZatPoint(*posforwindowcheck); + double ff_top = rover->top.plane->ZatPoint(*posforwindowcheck); - if (ff_bottom < mobj->_f_Top() && ff_top > mobj->_f_Z()) + if (ff_bottom < mobj->Top() && ff_top > mobj->Z()) { goto isblocking; } @@ -2275,13 +2163,13 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (ld->frontsector->PortalGroup != thing->Sector->PortalGroup) continue; // must be in the same group to be considered valid. // see if the line was crossed - oldside = P_PointOnLineSide(spec.oldrefpos.x, spec.oldrefpos.y, ld); - side = P_PointOnLineSide(spec.refpos.x, spec.refpos.y, ld); + oldside = P_PointOnLineSide(spec.Oldrefpos, ld); + side = P_PointOnLineSide(spec.Refpos, ld); if (oldside == 0 && side == 1) { - fdivline_t dl2 = { ld->v1->x, ld->v1->y, ld->dx, ld->dy }; - fdivline_t dl1 = { spec.oldrefpos.x, spec.oldrefpos.y, spec.refpos.x - spec.oldrefpos.x, spec.refpos.y - spec.oldrefpos.y }; - fixed_t frac = P_InterceptVector(&dl1, &dl2); + divline_t dl2 = { ld->v1->fX(), ld->v1->fY(), ld->Delta().X, ld->Delta().Y }; + divline_t dl1 = { spec.Oldrefpos.X, spec.Oldrefpos.Y, spec.Refpos.X - spec.Oldrefpos.X, spec.Refpos.Y - spec.Oldrefpos.Y }; + fixed_t frac = FLOAT2FIXED(P_InterceptVector(&dl1, &dl2)); if (frac < bestfrac) { besthit = spec; @@ -2299,7 +2187,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (port->mType == PORTT_LINKED) { thing->UnlinkFromWorld(); - thing->SetXY(tm.x + port->mXDisplacement, tm.y + port->mYDisplacement); + thing->SetXY(tm._f_X() + port->mXDisplacement, tm._f_Y() + port->mYDisplacement); thing->Prev.X += FIXED2DBL(port->mXDisplacement); thing->Prev.Y += FIXED2DBL(port->mYDisplacement); thing->LinkToWorld(); @@ -2308,7 +2196,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } else if (!portalcrossed) { - fixedvec3 pos = { tm.x, tm.y, thing->_f_Z() }; + fixedvec3 pos = { tm._f_X(), tm._f_Y(), thing->_f_Z() }; fixedvec3 oldthingpos = thing->_f_Pos(); fixedvec2 thingpos = oldthingpos; @@ -2335,7 +2223,9 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // so that the renderer can properly calculate an interpolated position along the movement path. if (thing == players[consoleplayer].camera) { - fdivline_t dl1 = { besthit.oldrefpos.x,besthit. oldrefpos.y, besthit.refpos.x - besthit.oldrefpos.x, besthit.refpos.y - besthit.oldrefpos.y }; + //divline_t dl1 = { besthit.Oldrefpos.X,besthit.Oldrefpos.Y, besthit.Refpos.X - besthit.Oldrefpos.Y, besthit.Refpos.Y - besthit.Oldrefpos.Y }; + //DVector3 hit = { dl1.x + dl1.dx * bestfrac, dl1.y + dl1.dy * bestfrac, 0.,0. }; + fdivline_t dl1 = { FLOAT2FIXED(besthit.Oldrefpos.X),FLOAT2FIXED(besthit.Oldrefpos.Y), FLOAT2FIXED(besthit.Refpos.X - besthit.Oldrefpos.Y), FLOAT2FIXED(besthit.Refpos.Y - besthit.Oldrefpos.Y) }; fixedvec3a hit = { dl1.x + FixedMul(dl1.dx, bestfrac), dl1.y + FixedMul(dl1.dy, bestfrac), 0, 0. }; R_AddInterpolationPoint(hit); @@ -2392,7 +2282,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (!(thing->flags & (MF_TELEPORT | MF_NOCLIP))) { spechit_t spec; - fixedvec3 lastpos = thing->_f_Pos(); + DVector2 lastpos = thing->Pos(); while (spechit.Pop(spec)) { line_t *ld = spec.line; @@ -2402,9 +2292,9 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // If the reference position is the same as the actor's position before checking the spechits, // we use the thing's actual position, including all the side effects of the original. // If some portal transition has to be considered here, we cannot do that and use the reference position stored with the spechit. - bool posisoriginal = (spec.refpos.x == lastpos.x && spec.refpos.y == lastpos.y); - side = posisoriginal? P_PointOnLineSide(thing->_f_X(), thing->_f_Y(), ld) : P_PointOnLineSide(spec.refpos.x, spec.refpos.y, ld); - oldside = P_PointOnLineSide(spec.oldrefpos.x, spec.oldrefpos.y, ld); + bool posisoriginal = (spec.Refpos == lastpos); + side = posisoriginal? P_PointOnLineSide(thing->Pos(), ld) : P_PointOnLineSide(spec.Refpos, ld); + oldside = P_PointOnLineSide(spec.Oldrefpos, ld); if (side != oldside && ld->special && !(thing->flags6 & MF6_NOTRIGGER)) { if (thing->player && (thing->player->cheats & CF_PREDICTING)) @@ -2503,8 +2393,8 @@ pushline: { // see which lines were pushed spechit_t &spec = spechit[--numSpecHitTemp]; - side = P_PointOnLineSide(spec.refpos.x, spec.refpos.y, spec.line); - CheckForPushSpecial(spec.line, side, thing, &spec.refpos); + side = P_PointOnLineSide(spec.Refpos, spec.line); + CheckForPushSpecial(spec.line, side, thing, &spec.Refpos); } } return false; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index adacb4d43..724ab9633 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -73,6 +73,30 @@ fixed_t P_AproxDistance (fixed_t dx, fixed_t dy) // //========================================================================== +double P_InterceptVector(const divline_t *v2, const divline_t *v1) +{ + double num; + double den; + + double v1x = v1->x; + double v1y = v1->y; + double v1dx = v1->dx; + double v1dy = v1->dy; + double v2x = v2->x; + double v2y = v2->y; + double v2dx = v2->dx; + double v2dy = v2->dy; + + den = v1dy*v2dx - v1dx*v2dy; + + if (den == 0) + return 0; // parallel + + num = (v1x - v2x)*v1dy + (v2y - v1y)*v1dx; + return num / den; +} + + fixed_t P_InterceptVector (const fdivline_t *v2, const fdivline_t *v1) { #if 0 // [RH] Use 64 bit ints, so long divlines don't overflow @@ -814,6 +838,8 @@ bool FMultiBlockLinesIterator::Next(FMultiBlockLinesIterator::CheckResult *item) item->line = line; item->position.x = offset.x; item->position.y = offset.y; + // same as above in floating point. This is here so that this stuff can be converted piece by piece. + item->Position = { FIXED2DBL(item->position.x), FIXED2DBL(item->position.y), FIXED2DBL(item->position.z) }; item->portalflags = portalflags; return true; } diff --git a/src/p_maputl.h b/src/p_maputl.h index f2442d2bb..b49149b21 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -143,6 +143,10 @@ static const double LINEOPEN_MIN = -FLT_MAX; static const double LINEOPEN_MAX = FLT_MAX; void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, const DVector2 &xy, const DVector2 *ref = NULL, int flags = 0); +inline void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, const DVector2 &xy, const DVector3 *ref = NULL, int flags = 0) +{ + P_LineOpening(open, thing, linedef, xy, reinterpret_cast(ref), flags); +} inline void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, fixed_t x, fixed_t y, fixed_t refx = FIXED_MIN, fixed_t refy = 0, int flags = 0) { @@ -152,7 +156,6 @@ inline void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *lined { P_LineOpening(open, thing, linedef, xy.x, xy.y, refx, refy, flags); } -void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, const DVector2 &xy, fixed_t refx = FIXED_MIN, const DVector2 *ref = NULL, int flags = 0); class FBoundingBox; struct polyblock_t; @@ -281,11 +284,18 @@ public: { line_t *line; fixedvec3 position; + DVector3 Position; int portalflags; }; FMultiBlockLinesIterator(FPortalGroupArray &check, AActor *origin, fixed_t checkradius = -1); FMultiBlockLinesIterator(FPortalGroupArray &check, fixed_t checkx, fixed_t checky, fixed_t checkz, fixed_t checkh, fixed_t checkradius, sector_t *newsec); + + FMultiBlockLinesIterator(FPortalGroupArray &check, double checkx, double checky, double checkz, double checkh, double checkradius, sector_t *newsec) + : FMultiBlockLinesIterator(check, FLOAT2FIXED(checkx), FLOAT2FIXED(checky), FLOAT2FIXED(checkz), FLOAT2FIXED(checkh), FLOAT2FIXED(checkradius), newsec) + { + } + bool Next(CheckResult *item); void Reset(); // for stopping group traversal through portals. Only the calling code can decide whether this is needed so this needs to be set from the outside. @@ -467,6 +477,7 @@ fixed_t P_AproxDistance (fixed_t dx, fixed_t dy); fixed_t P_InterceptVector (const fdivline_t *v2, const fdivline_t *v1); +double P_InterceptVector(const divline_t *v2, const divline_t *v1); #define PT_ADDLINES 1 #define PT_ADDTHINGS 2 diff --git a/src/p_spec.h b/src/p_spec.h index 99c2d0fee..15a088773 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -365,7 +365,7 @@ void EV_StartLightStrobing (int tag, int upper, int lower, int utics, int ltics) void EV_StartLightStrobing (int tag, int utics, int ltics); void EV_TurnTagLightsOff (int tag); void EV_LightTurnOn (int tag, int bright); -void EV_LightTurnOnPartway (int tag, fixed_t frac); // killough 10/98 +void EV_LightTurnOnPartway (int tag, double frac); // killough 10/98 void EV_LightChange (int tag, int value); void EV_StopLightEffect (int tag); diff --git a/src/r_defs.h b/src/r_defs.h index 4be105906..f789073dd 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -246,6 +246,11 @@ struct secplane_t fixed_t a, b, c, d, ic; + bool isSlope() const + { + return a != 0 || b != 0; + } + DVector3 Normal() const { return{ FIXED2FLOAT(a), FIXED2FLOAT(b), FIXED2FLOAT(c) }; From 1877eca2ab8742d87e99c7cee4ee32aca299a1c1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Mar 2016 01:06:54 +0100 Subject: [PATCH 19/44] - more floatification of p_map, plus some stuff used in those functions. --- src/p_local.h | 16 ++------- src/p_map.cpp | 85 ++++++++++++++++++++++++----------------------- src/p_mobj.cpp | 2 +- src/p_sectors.cpp | 34 +++++++++---------- src/p_spec.cpp | 2 +- src/p_spec.h | 2 +- src/portal.h | 15 +++++++++ src/r_defs.h | 25 +++++--------- 8 files changed, 87 insertions(+), 94 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index e48b04a61..4d2cb75be 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -276,20 +276,8 @@ extern TArray portalhit; 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); -} -inline bool P_CheckPosition(AActor *thing, const DVector2 &pos, bool actorsonly = false) -{ - return P_CheckPosition(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), actorsonly); -} -inline bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, bool actorsonly = false) -{ - return P_CheckPosition(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), tm, actorsonly); -} +bool P_CheckPosition(AActor *thing, const DVector2 &pos, bool actorsonly = false); +inline bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, bool actorsonly = false); 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); diff --git a/src/p_map.cpp b/src/p_map.cpp index d081ca9ac..edea639e6 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -918,11 +918,10 @@ static bool PIT_CheckPortal(FMultiBlockLinesIterator &mit, FMultiBlockLinesItera return false; line_t *lp = cres.line->getPortalDestination(); - fixed_t _zofs = 0; + double zofs = 0; - P_TranslatePortalXY(cres.line, cres.position.x, cres.position.y); - P_TranslatePortalZ(cres.line, _zofs); - double zofs = FIXED2DBL(_zofs); + P_TranslatePortalXY(cres.line, cres.Position.X, cres.Position.Y); + P_TranslatePortalZ(cres.line, zofs); // fudge a bit with the portal line so that this gets included in the checks that normally only get run on two-sided lines sector_t *sec = lp->backsector; @@ -1080,7 +1079,7 @@ static bool CanAttackHurt(AActor *victim, AActor *shooter) bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::CheckResult &cres, const FBoundingBox &box, FCheckPosition &tm) { AActor *thing = cres.thing; - fixed_t topz; + double topz; bool solid; int damage; @@ -1091,8 +1090,8 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch if (!((thing->flags & (MF_SOLID | MF_SPECIAL | MF_SHOOTABLE)) || thing->flags6 & MF6_TOUCHY)) return true; // can't hit thing - fixed_t blockdist = thing->_f_radius() + tm.thing->_f_radius(); - if (abs(thing->_f_X() - cres.position.x) >= blockdist || abs(thing->_f_Y() - cres.position.y) >= blockdist) + double blockdist = thing->radius + tm.thing->radius; + if (fabs(thing->X() - cres.Position.X) >= blockdist || fabs(thing->Y() - cres.Position.Y) >= blockdist) return true; if ((thing->flags2 | tm.thing->flags2) & MF2_THRUACTORS) @@ -1102,7 +1101,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch return true; tm.thing->BlockingMobj = thing; - topz = thing->_f_Top(); + topz = thing->Top(); // Both things overlap in x or y direction bool unblocking = false; @@ -1126,31 +1125,31 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch // abs(thing->y - tmy) <= thing->radius) { tm.stepthing = thing; - tm.floorz = FIXED2DBL(topz); + tm.floorz = topz; } } } if (((tm.FromPMove || tm.thing->player != NULL) && thing->flags&MF_SOLID)) { - fixedvec3 oldpos = tm.thing->_f_PosRelative(thing); + DVector3 oldpos = tm.thing->PosRelative(thing); // Both actors already overlap. To prevent them from remaining stuck allow the move if it // takes them further apart or the move does not change the position (when called from P_ChangeSector.) - if (oldpos.x == thing->_f_X() && oldpos.y == thing->_f_Y()) + if (oldpos.X == thing->X() && oldpos.Y == thing->Y()) { unblocking = true; } - else if (abs(thing->_f_X() - oldpos.x) < (thing->_f_radius() + tm.thing->_f_radius()) && - abs(thing->_f_Y() - oldpos.y) < (thing->_f_radius() + tm.thing->_f_radius())) + else if (fabs(thing->X() - oldpos.X) < (thing->radius + tm.thing->radius) && + fabs(thing->Y() - oldpos.Y) < (thing->radius + tm.thing->radius)) { - fixed_t newdist = thing->AproxDistance(cres.position.x, cres.position.y); - fixed_t olddist = thing->AproxDistance(oldpos.x, oldpos.y); + double newdist = thing->Distance2D(cres.Position.X, cres.Position.Y); + double olddist = thing->Distance2D(oldpos.X, oldpos.Y); if (newdist > olddist) { // unblock only if there's already a vertical overlap (or both actors are flagged not to overlap) - unblocking = (tm.thing->_f_Top() > thing->_f_Z() && tm.thing->_f_Z() < topz) || (tm.thing->flags3 & thing->flags3 & MF3_DONTOVERLAP); + unblocking = (tm.thing->Top() > thing->Z() && tm.thing->Z() < topz) || (tm.thing->flags3 & thing->flags3 & MF3_DONTOVERLAP); } } } @@ -1169,7 +1168,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch { // Some things prefer not to overlap each other, if possible return unblocking; } - if ((tm.thing->_f_Z() >= topz) || (tm.thing->_f_Top() <= thing->_f_Z())) + if ((tm.thing->Z() >= topz) || (tm.thing->Top() <= thing->Z())) return true; } } @@ -1185,7 +1184,7 @@ bool PIT_CheckThing(FMultiBlockThingsIterator &it, FMultiBlockThingsIterator::Ch // or different species if DONTHARMSPECIES (!(thing->flags6 & MF6_DONTHARMSPECIES) || thing->GetSpecies() != tm.thing->GetSpecies()) && // touches vertically - topz >= tm.thing->_f_Z() && tm.thing->_f_Top() >= thing->_f_Z() && + topz >= tm.thing->Z() && tm.thing->Top() >= thing->Z() && // prevents lost souls from exploding when fired by pain elementals (thing->master != tm.thing && tm.thing->master != thing)) // Difference with MBF: MBF hardcodes the LS/PE check and lets actors of the same species @@ -1492,7 +1491,7 @@ MOVEMENT CLIPPING // //========================================================================== -bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bool actorsonly) +bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, bool actorsonly) { sector_t *newsec; AActor *thingblocker; @@ -1500,11 +1499,11 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo tm.thing = thing; - tm.pos.X = FIXED2DBL(x); - tm.pos.Y = FIXED2DBL(y); + tm.pos.X = pos.X; + tm.pos.Y = pos.Y; tm.pos.Z = thing->Z(); - newsec = tm.sector = P_PointInSector(x, y); + newsec = tm.sector = P_PointInSector(pos); tm.ceilingline = thing->BlockingLine = NULL; // Retrieve the base floor / ceiling from the target location. @@ -1516,8 +1515,8 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo else { // With noclip2, we must ignore 3D floors and go right to the uppermost ceiling and lowermost floor. - tm.floorz = tm.dropoffz = FIXED2FLOAT(newsec->_f_LowestFloorAt(x, y, &tm.floorsector)); - tm.ceilingz = FIXED2DBL(newsec->_f_HighestCeilingAt(x, y, &tm.ceilingsector)); + tm.floorz = tm.dropoffz = newsec->LowestFloorAt(pos, &tm.floorsector); + tm.ceilingz = newsec->HighestCeilingAt(pos, &tm.ceilingsector); tm.floorpic = tm.floorsector->GetTexture(sector_t::floor); tm.floorterrain = tm.floorsector->GetTerrain(sector_t::floor); tm.ceilingpic = tm.ceilingsector->GetTexture(sector_t::ceiling); @@ -1539,10 +1538,10 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo } tm.stepthing = NULL; - FBoundingBox box(x, y, thing->_f_radius()); + FBoundingBox box(pos.X, pos.Y, thing->radius); FPortalGroupArray pcheck; - FMultiBlockThingsIterator it2(pcheck, x, y, thing->_f_Z(), thing->_f_height(), thing->_f_radius(), false, newsec); + FMultiBlockThingsIterator it2(pcheck, pos.X, pos.Y, thing->Z(), thing->Height, thing->radius, false, newsec); FMultiBlockThingsIterator::CheckResult tcres; while ((it2.Next(&tcres))) @@ -1612,10 +1611,10 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo spechit.Clear(); portalhit.Clear(); - FMultiBlockLinesIterator it(pcheck, x, y, thing->_f_Z(), thing->_f_height(), thing->_f_radius(), newsec); + FMultiBlockLinesIterator it(pcheck, pos.X, pos.Y, thing->Z(), thing->Height, thing->radius, newsec); FMultiBlockLinesIterator::CheckResult lcres; - fixed_t thingdropoffz = tm._f_floorz(); + double thingdropoffz = tm.floorz; //bool onthing = (thingdropoffz != tmdropoffz); tm.floorz = tm.dropoffz; @@ -1654,16 +1653,16 @@ bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, FCheckPosition &tm, bo } else if (tm.stepthing != NULL) { - tm.dropoffz = FIXED2FLOAT(thingdropoffz); + tm.dropoffz = thingdropoffz; } return (thing->BlockingMobj = thingblocker) == NULL; } -bool P_CheckPosition(AActor *thing, fixed_t x, fixed_t y, bool actorsonly) +bool P_CheckPosition(AActor *thing, const DVector2 &pos, bool actorsonly) { FCheckPosition tm; - return P_CheckPosition(thing, x, y, tm, actorsonly); + return P_CheckPosition(thing, pos, tm, actorsonly); } //---------------------------------------------------------------------------- @@ -1928,7 +1927,8 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, thing->_f_SetZ(onfloor->ZatPoint(x, y)); } thing->flags6 |= MF6_INTRYMOVE; - if (!P_CheckPosition(thing, x, y, tm)) + DVector2 pos = { FIXED2DBL(x), FIXED2DBL(y) }; + if (!P_CheckPosition(thing, pos, tm)) { AActor *BlockingMobj = thing->BlockingMobj; // Solid wall or thing @@ -2196,15 +2196,15 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } else if (!portalcrossed) { - fixedvec3 pos = { tm._f_X(), tm._f_Y(), thing->_f_Z() }; - fixedvec3 oldthingpos = thing->_f_Pos(); - fixedvec2 thingpos = oldthingpos; + DVector3 pos(tm.pos, thing->Z()); + DVector3 oldthingpos = thing->Pos(); + DVector2 thingpos = oldthingpos; - P_TranslatePortalXY(ld, pos.x, pos.y); - P_TranslatePortalXY(ld, thingpos.x, thingpos.y); - P_TranslatePortalZ(ld, pos.z); - thing->SetXYZ(thingpos.x, thingpos.y, pos.z); - if (!P_CheckPosition(thing, pos.x, pos.y, true)) // check if some actor blocks us on the other side. (No line checks, because of the mess that'd create.) + P_TranslatePortalXY(ld, pos.X, pos.Y); + P_TranslatePortalXY(ld, thingpos.X, thingpos.Y); + P_TranslatePortalZ(ld, pos.Z); + thing->SetXYZ(thingpos.X, thingpos.Y, pos.Z); + if (!P_CheckPosition(thing, pos, true)) // check if some actor blocks us on the other side. (No line checks, because of the mess that'd create.) { thing->SetXYZ(oldthingpos); thing->flags6 &= ~MF6_INTRYMOVE; @@ -2422,7 +2422,8 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) FCheckPosition tm; fixed_t newz = thing->_f_Z(); - if (!P_CheckPosition(thing, x, y, tm)) + DVector2 pos = { FIXED2DBL(x), FIXED2DBL(y) }; + if (!P_CheckPosition(thing, pos, tm)) { return false; } @@ -5349,7 +5350,7 @@ bool P_AdjustFloorCeil(AActor *thing, FChangePosition *cpos) thing->flags2 |= MF2_PASSMOBJ; } - bool isgood = P_CheckPosition(thing, thing->_f_X(), thing->_f_Y(), tm); + bool isgood = P_CheckPosition(thing, thing->Pos(), tm); thing->floorz = tm.floorz; thing->ceilingz = tm.ceilingz; thing->dropoffz = tm.dropoffz; // killough 11/98: remember dropoffs diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 1bdad1bc2..b218a5248 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -5676,7 +5676,7 @@ bool P_HitFloor (AActor *thing) void P_CheckSplash(AActor *self, double distance) { sector_t *floorsec; - self->Sector->_f_LowestFloorAt(self, &floorsec); + self->Sector->LowestFloorAt(self, &floorsec); if (self->Z() <= self->floorz + distance && self->floorsector == floorsec && self->Sector->GetHeightSec() == NULL && floorsec->heightsec == NULL) { // Explosion splashes never alert monsters. This is because A_Explode has diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index 10a8aedd7..832a9237e 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -889,22 +889,21 @@ void sector_t::CheckPortalPlane(int plane) // //=========================================================================== -fixed_t sector_t::_f_HighestCeilingAt(fixed_t x, fixed_t y, sector_t **resultsec) +double sector_t::HighestCeilingAt(const DVector2 &p, sector_t **resultsec) { sector_t *check = this; fixed_t planeheight = FIXED_MIN; + DVector2 pos = p; // Continue until we find a blocking portal or a portal below where we actually are. while (!check->PortalBlocksMovement(ceiling) && planeheight < FLOAT2FIXED(check->SkyBoxes[ceiling]->specialf1)) { - fixedvec2 pos = check->CeilingDisplacement(); - x += pos.x; - y += pos.y; + pos += check->CeilingDisplacement(); planeheight = FLOAT2FIXED(check->SkyBoxes[ceiling]->specialf1); - check = P_PointInSector(x, y); + check = P_PointInSector(pos); } if (resultsec) *resultsec = check; - return check->ceilingplane.ZatPoint(x, y); + return check->ceilingplane.ZatPoint(pos); } //=========================================================================== @@ -913,22 +912,21 @@ fixed_t sector_t::_f_HighestCeilingAt(fixed_t x, fixed_t y, sector_t **resultsec // //=========================================================================== -fixed_t sector_t::_f_LowestFloorAt(fixed_t x, fixed_t y, sector_t **resultsec) +double sector_t::LowestFloorAt(const DVector2 &p, sector_t **resultsec) { sector_t *check = this; fixed_t planeheight = FIXED_MAX; + DVector2 pos = p; // Continue until we find a blocking portal or a portal above where we actually are. while (!check->PortalBlocksMovement(floor) && planeheight > FLOAT2FIXED(check->SkyBoxes[floor]->specialf1)) { - fixedvec2 pos = check->FloorDisplacement(); - x += pos.x; - y += pos.y; + pos += check->FloorDisplacement(); planeheight = FLOAT2FIXED(check->SkyBoxes[floor]->specialf1); - check = P_PointInSector(x, y); + check = P_PointInSector(pos); } if (resultsec) *resultsec = check; - return check->floorplane.ZatPoint(x, y); + return check->floorplane.ZatPoint(pos); } @@ -967,9 +965,9 @@ fixed_t sector_t::NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fi } else { - fixedvec2 pos = sec->CeilingDisplacement(); - x += pos.x; - y += pos.y; + DVector2 pos = sec->CeilingDisplacement(); + x += FLOAT2FIXED(pos.X); + y += FLOAT2FIXED(pos.Y); planeheight = FLOAT2FIXED(sec->SkyBoxes[ceiling]->specialf1); sec = P_PointInSector(x, y); } @@ -1012,9 +1010,9 @@ fixed_t sector_t::NextLowestFloorAt(fixed_t x, fixed_t y, fixed_t z, int flags, } else { - fixedvec2 pos = sec->FloorDisplacement(); - x += pos.x; - y += pos.y; + DVector2 pos = sec->FloorDisplacement(); + x += FLOAT2FIXED(pos.X); + y += FLOAT2FIXED(pos.Y); planeheight = FLOAT2FIXED(sec->SkyBoxes[floor]->specialf1); sec = P_PointInSector(x, y); } diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 7a32c9fa1..c51c7167e 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -436,7 +436,7 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector) { // Falling, not all the way down yet? sector = player->mo->Sector; - if (player->mo->_f_Z() != sector->_f_LowestFloorAt(player->mo) + if (player->mo->Z() != sector->LowestFloorAt(player->mo) && !player->mo->waterlevel) { return; diff --git a/src/p_spec.h b/src/p_spec.h index 15a088773..2d6060107 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -790,7 +790,7 @@ inline bool EV_DoFloor(DFloor::EFloor floortype, line_t *line, int tag, inline bool EV_DoFloor(DFloor::EFloor floortype, line_t *line, int tag, double speed, int height, int crush, int change, bool hexencrush, bool hereticlower = false) { - return EV_DoFloor(floortype, line, tag, FLOAT2FIXED(speed), height, crush, change, hexencrush, hereticlower); + return EV_DoFloor(floortype, line, tag, FLOAT2FIXED(speed), height<Sector->PortalGroup); + return Displacements.getOffset(PortalGroup, SkyBoxes[sector_t::floor]->Sector->PortalGroup); } - fixedvec2 CeilingDisplacement() + DVector2 CeilingDisplacement() { - return Displacements._f_getOffset(PortalGroup, SkyBoxes[sector_t::ceiling]->Sector->PortalGroup); + return Displacements.getOffset(PortalGroup, SkyBoxes[sector_t::ceiling]->Sector->PortalGroup); } int GetTerrain(int pos) const; @@ -903,27 +903,18 @@ struct sector_t bool PlaneMoving(int pos); // Portal-aware height calculation - fixed_t _f_HighestCeilingAt(fixed_t x, fixed_t y, sector_t **resultsec = NULL); - fixed_t _f_LowestFloorAt(fixed_t x, fixed_t y, sector_t **resultsec = NULL); + double HighestCeilingAt(const DVector2 &a, sector_t **resultsec = NULL); + double LowestFloorAt(const DVector2 &a, sector_t **resultsec = NULL); - fixed_t _f_HighestCeilingAt(AActor *a, sector_t **resultsec = NULL) - { - return _f_HighestCeilingAt(a->_f_X(), a->_f_Y(), resultsec); - } double HighestCeilingAt(AActor *a, sector_t **resultsec = NULL) { - return FIXED2DBL(_f_HighestCeilingAt(a->_f_X(), a->_f_Y(), resultsec)); - } - - fixed_t _f_LowestFloorAt(AActor *a, sector_t **resultsec = NULL) - { - return _f_LowestFloorAt(a->_f_X(), a->_f_Y(), resultsec); + return HighestCeilingAt(a->Pos(), resultsec); } double LowestFloorAt(AActor *a, sector_t **resultsec = NULL) { - return FIXED2DBL(_f_LowestFloorAt(a->_f_X(), a->_f_Y(), resultsec)); + return LowestFloorAt(a->Pos(), resultsec); } fixed_t NextHighestCeilingAt(fixed_t x, fixed_t y, fixed_t bottomz, fixed_t topz, int flags = 0, sector_t **resultsec = NULL, F3DFloor **resultffloor = NULL); From 26ff2f73d7f552cdac3f5d8f52f7697c86abbe2e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Mar 2016 13:29:58 +0200 Subject: [PATCH 20/44] - floatified P_TryMove and the sliding and bouncing code. --- src/p_local.h | 30 +-- src/p_map.cpp | 427 ++++++++++++++---------------- src/p_maputl.h | 10 +- src/p_mobj.cpp | 12 +- src/po_man.cpp | 4 +- src/portal.cpp | 21 +- src/portal.h | 3 +- src/r_utility.cpp | 31 +-- src/r_utility.h | 6 +- src/thingdef/thingdef_codeptr.cpp | 2 +- 10 files changed, 262 insertions(+), 284 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 4d2cb75be..d6e8bdb44 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -280,25 +280,16 @@ bool P_CheckPosition(AActor *thing, const DVector2 &pos, bool actorsonly = false inline bool P_CheckPosition(AActor *thing, const DVector2 &pos, FCheckPosition &tm, bool actorsonly = false); 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); -bool P_TryMove (AActor* thing, fixed_t x, fixed_t y, int dropoff, const secplane_t * onfloor = NULL); +bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor, FCheckPosition &tm, bool missileCheck = false); +bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor = NULL); +/* inline bool P_TryMove(AActor* thing, double x, double y, int dropoff, const secplane_t * onfloor = NULL) { return P_TryMove(thing, FLOAT2FIXED(x), FLOAT2FIXED(y), dropoff, onfloor); } -inline bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor = NULL) -{ - return P_TryMove(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), dropoff, onfloor); -} -inline bool P_TryMove(AActor* thing, const DVector2 &pos, int dropoff, const secplane_t * onfloor, FCheckPosition &tm, bool missileCheck = false) -{ - return P_TryMove(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), dropoff, onfloor, tm, missileCheck); -} -bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y); -inline bool P_CheckMove(AActor *thing, double x, double y) -{ - return P_CheckMove(thing, FLOAT2FIXED(x), FLOAT2FIXED(y)); -} +*/ + +bool P_CheckMove(AActor *thing, const DVector2 &pos); void P_ApplyTorque(AActor *mo); bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modifyactor = true); // [RH] Added z and telefrag parameters @@ -313,7 +304,7 @@ inline bool P_TeleportMove(AActor* thing, const fixedvec3 &pos, bool telefrag, b } void P_PlayerStartStomp (AActor *actor, bool mononly=false); // [RH] Stomp on things for a newly spawned player -void P_SlideMove (AActor* mo, fixed_t tryx, fixed_t tryy, int numsteps); +void P_SlideMove (AActor* mo, const DVector2 &pos, int numsteps); bool P_BounceWall (AActor *mo); bool P_BounceActor (AActor *mo, AActor *BlockingMobj, bool ontop); bool P_CheckSight (AActor *t1, AActor *t2, int flags=0); @@ -455,6 +446,13 @@ bool Check_Sides(AActor *, int, int); // phares // [RH] const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymove); +inline const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move) +{ + fixedvec2 mov = { FLOAT2FIXED(move.X), FLOAT2FIXED(move.Y) }; + const secplane_t *ret = P_CheckSlopeWalk(actor, mov.x, mov.y); + move = { FIXED2DBL(mov.x), FIXED2DBL(mov.y) }; + return ret; +} // // P_SETUP diff --git a/src/p_map.cpp b/src/p_map.cpp index edea639e6..849d70874 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -1481,7 +1481,7 @@ MOVEMENT CLIPPING // // out: // newsubsec -// _f_floorz() +// floorz // ceilingz // tmdropoffz = the lowest point contacted (monsters won't move to a dropoff) // speciallines[] @@ -1703,14 +1703,14 @@ bool P_TestMobjLocation(AActor *mobj) AActor *P_CheckOnmobj(AActor *thing) { - fixed_t oldz; + double oldz; bool good; AActor *onmobj; - oldz = thing->_f_Z(); + oldz = thing->Z(); P_FakeZMovement(thing); good = P_TestMobjZ(thing, false, &onmobj); - thing->_f_SetZ(oldz); + thing->SetZ(oldz); return good ? NULL : onmobj; } @@ -1738,8 +1738,8 @@ bool P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) { AActor *thing = cres.thing; - fixed_t blockdist = thing->_f_radius() + actor->_f_radius(); - if (abs(thing->_f_X() - cres.position.x) >= blockdist || abs(thing->_f_Y() - cres.position.y) >= blockdist) + double blockdist = thing->radius + actor->radius; + if (fabs(thing->X() - cres.Position.X) >= blockdist || fabs(thing->Y() - cres.Position.Y) >= blockdist) { continue; } @@ -1784,7 +1784,7 @@ bool P_TestMobjZ(AActor *actor, bool quick, AActor **pOnmobj) { // under thing continue; } - else if (!quick && onmobj != NULL && thing->_f_Top() < onmobj->_f_Top()) + else if (!quick && onmobj != NULL && thing->Top() < onmobj->Top()) { // something higher is in the way continue; } @@ -1808,22 +1808,22 @@ void P_FakeZMovement(AActor *mo) // // adjust height // - mo->_f_AddZ(mo->_f_velz()); + mo->AddZ(mo->Vel.Z); if ((mo->flags&MF_FLOAT) && mo->target) { // float down towards target if too close if (!(mo->flags & MF_SKULLFLY) && !(mo->flags & MF_INFLOAT)) { - fixed_t dist = mo->AproxDistance(mo->target); - fixed_t delta = (mo->target->_f_Z() + (mo->_f_height() >> 1)) - mo->_f_Z(); + double dist = mo->Distance2D(mo->target); + double delta = mo->target->Center() - mo->Z(); if (delta < 0 && dist < -(delta * 3)) - mo->_f_AddZ(-mo->_f_floatspeed()); + mo->AddZ(-mo->FloatSpeed); else if (delta > 0 && dist < (delta * 3)) - mo->_f_AddZ(mo->_f_floatspeed()); + mo->AddZ(mo->FloatSpeed); } } if (mo->player && mo->flags&MF_NOGRAVITY && (mo->Z() > mo->floorz) && !mo->IsNoClip2()) { - mo->_f_AddZ(finesine[(FINEANGLES / 80 * level.maptime)&FINEMASK] / 8); + mo->AddZ(DAngle(4.5 * level.maptime).Sin()); } // @@ -1906,28 +1906,26 @@ static void CheckForPushSpecial(line_t *line, int side, AActor *mobj, DVector2 * // //========================================================================== -bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, +bool P_TryMove(AActor *thing, const DVector2 &pos, int dropoff, // killough 3/15/98: allow dropoff as option const secplane_t *onfloor, // [RH] Let P_TryMove keep the thing on the floor FCheckPosition &tm, bool missileCheck) // [GZ] Fired missiles ignore the drop-off test { - fixedvec3 oldpos; sector_t *oldsector; - fixed_t oldz; + double oldz; int side; int oldside; sector_t* oldsec = thing->Sector; // [RH] for sector actions sector_t* newsec; tm.floatok = false; - oldz = thing->_f_Z(); + oldz = thing->Z(); if (onfloor) { - thing->_f_SetZ(onfloor->ZatPoint(x, y)); + thing->SetZ(onfloor->ZatPoint(pos)); } thing->flags6 |= MF6_INTRYMOVE; - DVector2 pos = { FIXED2DBL(x), FIXED2DBL(y) }; if (!P_CheckPosition(thing, pos, tm)) { AActor *BlockingMobj = thing->BlockingMobj; @@ -1943,7 +1941,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, goto pushline; } else if (BlockingMobj->Top() - thing->Z() > thing->MaxStepHeight - || (BlockingMobj->Sector->ceilingplane._f_ZatPointF(x, y) - (BlockingMobj->Top()) < thing->Height) + || (BlockingMobj->Sector->ceilingplane.ZatPoint(pos) - (BlockingMobj->Top()) < thing->Height) || (tm.ceilingz - (BlockingMobj->Top()) < thing->Height)) { goto pushline; @@ -1951,7 +1949,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } if (!(tm.thing->flags2 & MF2_PASSMOBJ) || (i_compatflags & COMPATF_NO_PASSMOBJ)) { - thing->_f_SetZ(oldz); + thing->SetZ(oldz); thing->flags6 &= ~MF6_INTRYMOVE; return false; } @@ -2078,7 +2076,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, !(thing->flags2 & MF2_BLASTED) && !missileCheck) { // Can't move over a dropoff unless it's been blasted // [GZ] Or missile-spawned - thing->_f_SetZ(oldz); + thing->SetZ(oldz); thing->flags6 &= ~MF6_INTRYMOVE; return false; } @@ -2099,7 +2097,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, && (tm.floorpic != thing->floorpic || tm.floorz - thing->Z() != 0)) { // must stay within a sector of a certain floor type - thing->_f_SetZ(oldz); + thing->SetZ(oldz); thing->flags6 &= ~MF6_INTRYMOVE; return false; } @@ -2113,7 +2111,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, thing->player->Bot->prev = thing->player->Bot->dest; thing->player->Bot->dest = NULL; thing->Vel.X = thing->Vel.Y = 0; - thing->_f_SetZ(oldz); + thing->SetZ(oldz); thing->flags6 &= ~MF6_INTRYMOVE; return false; } @@ -2129,7 +2127,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (oldsec->heightsec) { - fixed_t eyez = oldz + viewheight; + double eyez = oldz + FIXED2DBL(viewheight); oldAboveFakeFloor = eyez > oldsec->heightsec->floorplane.ZatPoint(thing); oldAboveFakeCeiling = eyez > oldsec->heightsec->ceilingplane.ZatPoint(thing); @@ -2151,7 +2149,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, while (true) { - fixed_t bestfrac = FIXED_MAX; + double bestfrac = 1.1; spechit_t besthit; int besthitnum; // find the portal nearest to the crossing actor @@ -2169,7 +2167,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, { divline_t dl2 = { ld->v1->fX(), ld->v1->fY(), ld->Delta().X, ld->Delta().Y }; divline_t dl1 = { spec.Oldrefpos.X, spec.Oldrefpos.Y, spec.Refpos.X - spec.Oldrefpos.X, spec.Refpos.Y - spec.Oldrefpos.Y }; - fixed_t frac = FLOAT2FIXED(P_InterceptVector(&dl1, &dl2)); + double frac = P_InterceptVector(&dl1, &dl2); if (frac < bestfrac) { besthit = spec; @@ -2179,7 +2177,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, } } - if (bestfrac < FIXED_MAX) + if (bestfrac < 1.1) { portalhit.Delete(besthitnum); line_t *ld = besthit.line; @@ -2187,9 +2185,8 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (port->mType == PORTT_LINKED) { thing->UnlinkFromWorld(); - thing->SetXY(tm._f_X() + port->mXDisplacement, tm._f_Y() + port->mYDisplacement); - thing->Prev.X += FIXED2DBL(port->mXDisplacement); - thing->Prev.Y += FIXED2DBL(port->mYDisplacement); + thing->SetXY(tm.pos + port->mDisplacement); + thing->Prev += port->mDisplacement; thing->LinkToWorld(); P_FindFloorCeiling(thing); portalcrossed = true; @@ -2223,22 +2220,20 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // so that the renderer can properly calculate an interpolated position along the movement path. if (thing == players[consoleplayer].camera) { - //divline_t dl1 = { besthit.Oldrefpos.X,besthit.Oldrefpos.Y, besthit.Refpos.X - besthit.Oldrefpos.Y, besthit.Refpos.Y - besthit.Oldrefpos.Y }; - //DVector3 hit = { dl1.x + dl1.dx * bestfrac, dl1.y + dl1.dy * bestfrac, 0.,0. }; - fdivline_t dl1 = { FLOAT2FIXED(besthit.Oldrefpos.X),FLOAT2FIXED(besthit.Oldrefpos.Y), FLOAT2FIXED(besthit.Refpos.X - besthit.Oldrefpos.Y), FLOAT2FIXED(besthit.Refpos.Y - besthit.Oldrefpos.Y) }; - fixedvec3a hit = { dl1.x + FixedMul(dl1.dx, bestfrac), dl1.y + FixedMul(dl1.dy, bestfrac), 0, 0. }; + divline_t dl1 = { besthit.Oldrefpos.X,besthit.Oldrefpos.Y, besthit.Refpos.X - besthit.Oldrefpos.Y, besthit.Refpos.Y - besthit.Oldrefpos.Y }; + DVector3a hit = { {dl1.x + dl1.dx * bestfrac, dl1.y + dl1.dy * bestfrac, 0.},0. }; R_AddInterpolationPoint(hit); if (port->mType == PORTT_LINKED) { - hit.x += port->mXDisplacement; - hit.y += port->mYDisplacement; + hit.pos.X += port->mDisplacement.X; + hit.pos.Y += port->mDisplacement.Y; } else { - P_TranslatePortalXY(ld, hit.x, hit.y); - P_TranslatePortalZ(ld, hit.z); - players[consoleplayer].viewz += FIXED2DBL(hit.z); // needs to be done here because otherwise the renderer will not catch the change. + P_TranslatePortalXY(ld, hit.pos.X, hit.pos.Y); + P_TranslatePortalZ(ld, hit.pos.Z); + players[consoleplayer].viewz += hit.pos.Z; // needs to be done here because otherwise the renderer will not catch the change. P_TranslatePortalAngle(ld, hit.angle); } R_AddInterpolationPoint(hit); @@ -2258,7 +2253,6 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // the move is ok, so link the thing into its new position thing->UnlinkFromWorld(); - oldpos = thing->_f_Pos(); oldsector = thing->Sector; thing->floorz = tm.floorz; thing->ceilingz= tm.ceilingz; @@ -2268,7 +2262,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, thing->floorsector = tm.floorsector; thing->ceilingpic = tm.ceilingpic; thing->ceilingsector = tm.ceilingsector; - thing->SetXY(x, y); + thing->SetXY(pos); thing->LinkToWorld(); } @@ -2339,8 +2333,8 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (newsec->heightsec && oldsec->heightsec && newsec->SecActTarget) { const sector_t *hs = newsec->heightsec; - fixed_t eyez = thing->_f_Z() + viewheight; - fixed_t fakez = hs->floorplane.ZatPoint(x, y); + double eyez = thing->Z() + FIXED2DBL(viewheight); + double fakez = hs->floorplane.ZatPoint(pos); if (!oldAboveFakeFloor && eyez > fakez) { // View went above fake floor @@ -2353,7 +2347,7 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, if (!(hs->MoreFlags & SECF_FAKEFLOORONLY)) { - fakez = hs->ceilingplane.ZatPoint(x, y); + fakez = hs->ceilingplane.ZatPoint(pos); if (!oldAboveFakeCeiling && eyez > fakez) { // View went above fake ceiling newsec->SecActTarget->TriggerAction(thing, SECSPAC_EyesAboveC); @@ -2379,7 +2373,7 @@ pushline: return false; } - thing->_f_SetZ(oldz); + thing->SetZ(oldz); if (!(thing->flags&(MF_TELEPORT | MF_NOCLIP))) { int numSpecHitTemp; @@ -2400,12 +2394,12 @@ pushline: return false; } -bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, +bool P_TryMove(AActor *thing, const DVector2 &pos, int dropoff, // killough 3/15/98: allow dropoff as option const secplane_t *onfloor) // [RH] Let P_TryMove keep the thing on the floor { FCheckPosition tm; - return P_TryMove(thing, x, y, dropoff, onfloor, tm); + return P_TryMove(thing, pos, dropoff, onfloor, tm); } @@ -2417,12 +2411,11 @@ bool P_TryMove(AActor *thing, fixed_t x, fixed_t y, // //========================================================================== -bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) +bool P_CheckMove(AActor *thing, const DVector2 &pos) { FCheckPosition tm; - fixed_t newz = thing->_f_Z(); + double newz = thing->Z(); - DVector2 pos = { FIXED2DBL(x), FIXED2DBL(y) }; if (!P_CheckPosition(thing, pos, tm)) { return false; @@ -2430,11 +2423,11 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) if (thing->flags3 & MF3_FLOORHUGGER) { - newz = tm._f_floorz(); + newz = tm.floorz; } else if (thing->flags3 & MF3_CEILINGHUGGER) { - newz = tm._f_ceilingz() - thing->_f_height(); + newz = tm.ceilingz - thing->Height; } if (!(thing->flags & MF_NOCLIP)) @@ -2458,20 +2451,20 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) } if (!(thing->flags & MF_TELEPORT) && !(thing->flags3 & MF3_FLOORHUGGER)) { - if (tm._f_floorz() - newz > thing->_f_MaxStepHeight()) + if (tm.floorz - newz > thing->MaxStepHeight) { // too big a step up return false; } - else if ((thing->flags & MF_MISSILE) && !(thing->flags6 & MF6_STEPMISSILE) && tm._f_floorz() > newz) + else if ((thing->flags & MF_MISSILE) && !(thing->flags6 & MF6_STEPMISSILE) && tm.floorz > newz) { // [RH] Don't let normal missiles climb steps return false; } - else if (newz < tm._f_floorz()) + else if (newz < tm.floorz) { // [RH] Check to make sure there's nothing in the way for the step up - fixed_t savedz = thing->_f_Z(); - thing->_f_SetZ(newz = tm._f_floorz()); + double savedz = thing->Z(); + thing->SetZ(newz = tm.floorz); bool good = P_TestMobjZ(thing); - thing->_f_SetZ(savedz); + thing->SetZ(savedz); if (!good) { return false; @@ -2481,7 +2474,7 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) if (thing->flags2 & MF2_CANTLEAVEFLOORPIC && (tm.floorpic != thing->floorpic - || tm._f_floorz() - newz != 0)) + || tm.floorz - newz != 0)) { // must stay within a sector of a certain floor type return false; } @@ -2501,23 +2494,22 @@ bool P_CheckMove(AActor *thing, fixed_t x, fixed_t y) struct FSlide { - fixed_t bestslidefrac; - fixed_t secondslidefrac; + double bestSlidefrac; + double secondSlidefrac; line_t* bestslideline; line_t* secondslideline; AActor* slidemo; - fixed_t tmxmove; - fixed_t tmymove; + DVector2 tmmove; void HitSlideLine(line_t *ld); - void SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); - void SlideMove(AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps); + void SlideTraverse(const DVector2 &start, const DVector2 &end); + void SlideMove(AActor *mo, DVector2 tryp, int numsteps); // The bouncing code uses the same data structure - bool BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy); + bool BounceTraverse(const DVector2 &start, const DVector2 &end); bool BounceWall(AActor *mo); }; @@ -2534,11 +2526,11 @@ void FSlide::HitSlideLine(line_t* ld) { int side; - angle_t lineangle; - angle_t moveangle; - angle_t deltaangle; + DAngle lineangle; + DAngle moveangle; + DAngle deltaangle; - fixed_t movelen; + double movelen; bool icyfloor; // is floor icy? // phares // | // Under icy conditions, if the angle of approach to the wall // V @@ -2550,121 +2542,108 @@ void FSlide::HitSlideLine(line_t* ld) // killough 10/98: only bounce if hit hard (prevents wobbling) icyfloor = - (P_AproxDistance(tmxmove, tmymove) > 4 * FRACUNIT) && + tmmove.LengthSquared() > 4*4 && var_friction && // killough 8/28/98: calc friction on demand slidemo->Z() <= slidemo->floorz && P_GetFriction(slidemo, NULL) > ORIG_FRICTION; - if (ld->dx == 0) + if (ld->Delta().X == 0) { // ST_VERTICAL - if (icyfloor && (abs(tmxmove) > abs(tmymove))) + if (icyfloor && (fabs(tmmove.X) > fabs(tmmove.Y))) { - tmxmove = -tmxmove / 2; // absorb half the velocity - tmymove /= 2; + tmmove.X = -tmmove.X / 2; + tmmove.Y /= 2; // absorb half the velocity if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff!// ^ } } // | else // phares - tmxmove = 0; // no more movement in the X direction + tmmove.X = 0; // no more movement in the X direction return; } - if (ld->dy == 0) + if (ld->Delta().Y == 0) { // ST_HORIZONTAL - if (icyfloor && (abs(tmymove) > abs(tmxmove))) + if (icyfloor && (fabs(tmmove.Y) > fabs(tmmove.X))) { - tmxmove /= 2; // absorb half the velocity - tmymove = -tmymove / 2; + tmmove.X /= 2; // absorb half the velocity + tmmove.Y = -tmmove.Y / 2; if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! } } else - tmymove = 0; // no more movement in the Y direction + tmmove.Y = 0; // no more movement in the Y direction return; } // The wall is angled. Bounce if the angle of approach is // phares // less than 45 degrees. // phares - fixedvec3 pos = slidemo->_f_PosRelative(ld); - side = P_PointOnLineSide(pos.x, pos.y, ld); + DVector3 pos = slidemo->PosRelative(ld); + side = P_PointOnLineSide(pos, ld); - lineangle = R_PointToAngle2(0, 0, ld->dx, ld->dy); + lineangle = ld->Delta().Angle(); if (side == 1) - lineangle += ANG180; + lineangle += 180.; - moveangle = R_PointToAngle2(0, 0, tmxmove, tmymove); + moveangle = tmmove.Angle(); - moveangle += 10; // prevents sudden path reversal due to // phares - // rounding error // | - deltaangle = moveangle - lineangle; // V - movelen = P_AproxDistance(tmxmove, tmymove); - if (icyfloor && (deltaangle > ANG45) && (deltaangle < ANG90 + ANG45)) + // prevents sudden path reversal due to rounding error | // phares + moveangle += 3600/65536.*65536.; // Boom added 10 to the angle_t here. + + deltaangle = ::deltaangle(lineangle, moveangle); // V + movelen = tmmove.Length(); + if (icyfloor && (deltaangle > 45) && (deltaangle < 135)) { - moveangle = lineangle - deltaangle; + moveangle = ::deltaangle(deltaangle, lineangle); movelen /= 2; // absorb if (slidemo->player && slidemo->health > 0 && !(slidemo->player->cheats & CF_PREDICTING)) { S_Sound(slidemo, CHAN_VOICE, "*grunt", 1, ATTN_IDLE); // oooff! } - moveangle >>= ANGLETOFINESHIFT; - tmxmove = FixedMul(movelen, finecosine[moveangle]); - tmymove = FixedMul(movelen, finesine[moveangle]); - } // ^ - else // | - { // phares - // Doom's original algorithm here does not work well due to imprecisions of the sine table. - // However, keep it active if the wallrunning compatibility flag is on - if (i_compatflags & COMPATF_WALLRUN) + tmmove = moveangle.ToVector(movelen); + } + else + { + // The compatibility option that used to be here had to be removed because + // with floating point math it was no longer possible to reproduce. + +#if 0 + // with full precision this should work now. Needs some testing + if (deltaangle < 0) deltaangle += 180.; + tmmove = lineangle.ToVector(movelen * deltaangle.Cos()); +#else + divline_t dll, dlv; + double inter1, inter2, inter3; + + P_MakeDivline(ld, &dll); + + dlv.x = pos.X; + dlv.y = pos.Y; + dlv.dx = dll.dy; + dlv.dy = -dll.dx; + + inter1 = P_InterceptVector(&dll, &dlv); + + dlv.dx = tmmove.X; + dlv.dy = tmmove.Y; + inter2 = P_InterceptVector(&dll, &dlv); + inter3 = P_InterceptVector(&dlv, &dll); + + if (inter3 != 0) { - fixed_t newlen; - - if (deltaangle > ANG180) - deltaangle += ANG180; - // I_Error ("SlideLine: ang>ANG180"); - - lineangle >>= ANGLETOFINESHIFT; - deltaangle >>= ANGLETOFINESHIFT; - - newlen = FixedMul(movelen, finecosine[deltaangle]); - - tmxmove = FixedMul(newlen, finecosine[lineangle]); - tmymove = FixedMul(newlen, finesine[lineangle]); + tmmove.X = (inter2 - inter1) * dll.dx / inter3; + tmmove.Y = (inter2 - inter1) * dll.dy / inter3; } else { - fdivline_t dll, dlv; - fixed_t inter1, inter2, inter3; - - P_MakeDivline(ld, &dll); - - dlv.x = pos.x; - dlv.y = pos.y; - dlv.dx = dll.dy; - dlv.dy = -dll.dx; - - inter1 = P_InterceptVector(&dll, &dlv); - - dlv.dx = tmxmove; - dlv.dy = tmymove; - inter2 = P_InterceptVector(&dll, &dlv); - inter3 = P_InterceptVector(&dlv, &dll); - - if (inter3 != 0) - { - tmxmove = Scale(inter2 - inter1, dll.dx, inter3); - tmymove = Scale(inter2 - inter1, dll.dy, inter3); - } - else - { - tmxmove = tmymove = 0; - } + tmmove.Zero(); } +#endif } // phares } @@ -2675,10 +2654,10 @@ void FSlide::HitSlideLine(line_t* ld) // //========================================================================== -void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) +void FSlide::SlideTraverse(const DVector2 &start, const DVector2 &end) { FLineOpening open; - FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES); + FPathTraverse it(start.X, start.Y, end.X, end.Y, PT_ADDLINES); intercept_t *in; while ((in = it.Next())) @@ -2696,8 +2675,8 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t if (!(li->flags & ML_TWOSIDED) || !li->backsector) { - fixedvec3 pos = slidemo->_f_PosRelative(li); - if (P_PointOnLineSide(pos.x, pos.y, li)) + DVector3 pos = slidemo->PosRelative(li); + if (P_PointOnLineSide(pos, li)) { // don't hit the back side continue; @@ -2719,7 +2698,7 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t } // set openrange, opentop, openbottom - P_LineOpening(open, slidemo, li, it._f_InterceptPoint(in)); + P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); if (open.range < slidemo->Height) goto isblocking; // doesn't fit @@ -2749,11 +2728,11 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t // the line does block movement, // see if it is closer than best so far isblocking: - if (in->frac < bestslidefrac) + if (in->Frac < bestSlidefrac) { - secondslidefrac = bestslidefrac; + secondSlidefrac = bestSlidefrac; secondslideline = bestslideline; - bestslidefrac = in->frac; + bestSlidefrac = in->Frac; bestslideline = li; } @@ -2775,12 +2754,12 @@ void FSlide::SlideTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t // //========================================================================== -void FSlide::SlideMove(AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) +void FSlide::SlideMove(AActor *mo, DVector2 tryp, int numsteps) { - fixed_t leadx, leady; - fixed_t trailx, traily; - fixed_t newx, newy; - fixed_t xmove, ymove; + DVector2 lead; + DVector2 trail; + DVector2 newpos; + DVector2 move; const secplane_t * walkplane; int hitcount; @@ -2795,84 +2774,81 @@ retry: goto stairstep; // don't loop forever // trace along the three leading corners - if (tryx > 0) + if (tryp.X > 0) { - leadx = mo->_f_X() + mo->_f_radius(); - trailx = mo->_f_X() - mo->_f_radius(); + lead.X = mo->X() + mo->radius; + trail.X = mo->X() - mo->radius; } else { - leadx = mo->_f_X() - mo->_f_radius(); - trailx = mo->_f_X() + mo->_f_radius(); + lead.X = mo->X() - mo->radius; + trail.X = mo->X() + mo->radius; } - if (tryy > 0) + if (tryp.Y > 0) { - leady = mo->_f_Y() + mo->_f_radius(); - traily = mo->_f_Y() - mo->_f_radius(); + lead.Y = mo->Y() + mo->radius; + trail.Y = mo->Y() - mo->radius; } else { - leady = mo->_f_Y() - mo->_f_radius(); - traily = mo->_f_Y() + mo->_f_radius(); + lead.Y = mo->Y() - mo->radius; + trail.Y = mo->Y() + mo->radius; } - bestslidefrac = FRACUNIT + 1; + bestSlidefrac = 1.01; - SlideTraverse(leadx, leady, leadx + tryx, leady + tryy); - SlideTraverse(trailx, leady, trailx + tryx, leady + tryy); - SlideTraverse(leadx, traily, leadx + tryx, traily + tryy); + SlideTraverse(lead, lead + tryp); + SlideTraverse(DVector2(trail.X, lead.Y), tryp + DVector2(trail.X, lead.Y)); + SlideTraverse(DVector2(lead.X, trail.Y), tryp + DVector2(lead.X, trail.Y)); // move up to the wall - if (bestslidefrac == FRACUNIT + 1) + if (bestSlidefrac > 1) { // the move must have hit the middle, so stairstep stairstep: // killough 3/15/98: Allow objects to drop off ledges - xmove = 0, ymove = tryy; - walkplane = P_CheckSlopeWalk(mo, xmove, ymove); - if (!P_TryMove(mo, mo->_f_X() + xmove, mo->_f_Y() + ymove, true, walkplane)) + move = { 0, tryp.Y }; + walkplane = P_CheckSlopeWalk(mo, move); + if (!P_TryMove(mo, mo->Pos() + move, true, walkplane)) { - xmove = tryx, ymove = 0; - walkplane = P_CheckSlopeWalk(mo, xmove, ymove); - P_TryMove(mo, mo->_f_X() + xmove, mo->_f_Y() + ymove, true, walkplane); + move = { tryp.X, 0 }; + walkplane = P_CheckSlopeWalk(mo, move); + P_TryMove(mo, mo->Pos() + move, true, walkplane); } return; } // fudge a bit to make sure it doesn't hit - bestslidefrac -= FRACUNIT / 32; - if (bestslidefrac > 0) + bestSlidefrac -= FRACUNIT / 32; + if (bestSlidefrac > 0) { - newx = FixedMul(tryx, bestslidefrac); - newy = FixedMul(tryy, bestslidefrac); + newpos = tryp * bestSlidefrac; // [BL] We need to abandon this function if we end up going through a teleporter - const fixed_t startvelx = mo->_f_velx(); - const fixed_t startvely = mo->_f_vely(); + const DVector2 startvel = mo->Vel.XY(); // killough 3/15/98: Allow objects to drop off ledges - if (!P_TryMove(mo, mo->_f_X() + newx, mo->_f_Y() + newy, true)) + if (!P_TryMove(mo, mo->Pos() + newpos, true)) goto stairstep; - if (mo->_f_velx() != startvelx || mo->_f_vely() != startvely) + if (mo->Vel.XY() != startvel) return; } // Now continue along the wall. - bestslidefrac = FRACUNIT - (bestslidefrac + FRACUNIT / 32); // remainder - if (bestslidefrac > FRACUNIT) - bestslidefrac = FRACUNIT; - else if (bestslidefrac <= 0) + bestSlidefrac = 1. - (bestSlidefrac + 1. / 32); // remainder + if (bestSlidefrac > 1) + bestSlidefrac = 1; + else if (bestSlidefrac <= 0) return; - tryx = tmxmove = FixedMul(tryx, bestslidefrac); - tryy = tmymove = FixedMul(tryy, bestslidefrac); + tryp = tmmove = tryp*bestSlidefrac; HitSlideLine(bestslideline); // clip the moves - mo->Vel.X = FIXED2DBL(tmxmove * numsteps); - mo->Vel.Y = FIXED2DBL(tmymove * numsteps); + mo->Vel.X = tmmove.X * numsteps; + mo->Vel.Y = tmmove.Y * numsteps; // killough 10/98: affect the bobbing the same way (but not voodoo dolls) if (mo->player && mo->player->mo == mo) @@ -2883,19 +2859,19 @@ retry: mo->player->Vel.Y = mo->Vel.Y; } - walkplane = P_CheckSlopeWalk(mo, tmxmove, tmymove); + walkplane = P_CheckSlopeWalk(mo, tmmove); // killough 3/15/98: Allow objects to drop off ledges - if (!P_TryMove(mo, mo->_f_X() + tmxmove, mo->_f_Y() + tmymove, true, walkplane)) + if (!P_TryMove(mo, mo->Pos() + tmmove, true, walkplane)) { goto retry; } } -void P_SlideMove(AActor *mo, fixed_t tryx, fixed_t tryy, int numsteps) +void P_SlideMove(AActor *mo, const DVector2 &pos, int numsteps) { FSlide slide; - slide.SlideMove(mo, tryx, tryy, numsteps); + slide.SlideMove(mo, pos, numsteps); } //============================================================================ @@ -3044,10 +3020,10 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov // //============================================================================ -bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) +bool FSlide::BounceTraverse(const DVector2 &start, const DVector2 &end) { FLineOpening open; - FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES); + FPathTraverse it(start.X, start.Y, end.X, end.Y, PT_ADDLINES); intercept_t *in; while ((in = it.Next())) @@ -3089,11 +3065,11 @@ bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_ // the line does block movement, see if it is closer than best so far bounceblocking: - if (in->frac < bestslidefrac) + if (in->Frac < bestSlidefrac) { - secondslidefrac = bestslidefrac; + secondSlidefrac = bestSlidefrac; secondslideline = bestslideline; - bestslidefrac = in->frac; + bestSlidefrac = in->Frac; bestslideline = li; } return false; // stop @@ -3109,10 +3085,10 @@ bool FSlide::BounceTraverse(fixed_t startx, fixed_t starty, fixed_t endx, fixed_ bool FSlide::BounceWall(AActor *mo) { - fixed_t leadx, leady; + DVector2 lead; int side; - angle_t lineangle, moveangle, deltaangle; - fixed_t movelen; + DAngle lineangle, moveangle, deltaangle; + double movelen; line_t *line; if (!(mo->BounceFlags & BOUNCE_Walls)) @@ -3126,23 +3102,23 @@ bool FSlide::BounceWall(AActor *mo) // if (mo->Vel.X > 0) { - leadx = mo->_f_X() + mo->_f_radius(); + lead.X = mo->X() + mo->radius; } else { - leadx = mo->_f_X() - mo->_f_radius(); + lead.X = mo->X() - mo->radius; } if (mo->Vel.Y > 0) { - leady = mo->_f_Y() + mo->_f_radius(); + lead.Y = mo->Y() + mo->radius; } else { - leady = mo->_f_Y() - mo->_f_radius(); + lead.Y = mo->Y() - mo->radius; } - bestslidefrac = FRACUNIT + 1; + bestSlidefrac = 1.01; bestslideline = mo->BlockingLine; - if (BounceTraverse(leadx, leady, leadx + mo->_f_velx(), leady + mo->_f_vely()) && mo->BlockingLine == NULL) + if (BounceTraverse(lead, lead+mo->Vel.XY()) && mo->BlockingLine == NULL) { // Could not find a wall, so bounce off the floor/ceiling instead. double floordist = mo->Z() - mo->floorz; double ceildist = mo->ceilingz - mo->Z(); @@ -3176,36 +3152,33 @@ bool FSlide::BounceWall(AActor *mo) return true; } - side = P_PointOnLineSide(mo->_f_X(), mo->_f_Y(), line); - lineangle = R_PointToAngle2(0, 0, line->dx, line->dy); + side = P_PointOnLineSide(mo->Pos(), line); + lineangle = line->Delta().Angle(); if (side == 1) { - lineangle += ANG180; + lineangle += 180; } - moveangle = R_PointToAngle2(0, 0, mo->_f_velx(), mo->_f_vely()); - deltaangle = (2 * lineangle) - moveangle; - mo->Angles.Yaw = ANGLE2DBL(deltaangle); + moveangle = mo->Vel.Angle(); + deltaangle = (lineangle * 2) - moveangle; + mo->Angles.Yaw = deltaangle; - deltaangle >>= ANGLETOFINESHIFT; + movelen = mo->Vel.XY().Length() * mo->wallbouncefactor; - movelen = fixed_t(g_sqrt(double(mo->_f_velx())*mo->_f_velx() + double(mo->_f_vely())*mo->_f_vely())); - movelen = fixed_t(movelen * mo->wallbouncefactor); - - FBoundingBox box(mo->_f_X(), mo->_f_Y(), mo->_f_radius()); + FBoundingBox box(mo->X(), mo->Y(), mo->radius); if (box.BoxOnLineSide(line) == -1) { - fixedvec3 pos = mo->Vec3Offset( - FixedMul(mo->_f_radius(), finecosine[deltaangle]), - FixedMul(mo->_f_radius(), finesine[deltaangle]), 0); + DVector2 ofs = deltaangle.ToVector(mo->radius); + DVector3 pos = mo->Vec3Offset(ofs.X, ofs.Y, 0.); mo->SetOrigin(pos, true); } - if (movelen < FRACUNIT) + if (movelen < 1) { - movelen = 2 * FRACUNIT; + movelen = 2; } - mo->Vel.X = FIXED2DBL(FixedMul(movelen, finecosine[deltaangle])); - mo->Vel.Y = FIXED2DBL(FixedMul(movelen, finesine[deltaangle])); + DVector2 vel = deltaangle.ToVector(movelen); + mo->Vel.X = vel.X; + mo->Vel.Y = vel.Y; if (mo->BounceFlags & BOUNCE_UseBounceState) { FState *bouncestate = mo->FindState(NAME_Bounce, NAME_Wall); diff --git a/src/p_maputl.h b/src/p_maputl.h index b49149b21..eee499481 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -122,6 +122,14 @@ inline void P_MakeDivline (const line_t *li, fdivline_t *dl) dl->dy = li->dy; } +inline void P_MakeDivline(const line_t *li, divline_t *dl) +{ + dl->x = li->v1->fX(); + dl->y = li->v1->fY(); + dl->dx = li->Delta().X; + dl->dy = li->Delta().Y; +} + struct FLineOpening { double top; @@ -143,7 +151,7 @@ static const double LINEOPEN_MIN = -FLT_MAX; static const double LINEOPEN_MAX = FLT_MAX; void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, const DVector2 &xy, const DVector2 *ref = NULL, int flags = 0); -inline void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, const DVector2 &xy, const DVector3 *ref = NULL, int flags = 0) +inline void P_LineOpening(FLineOpening &open, AActor *thing, const line_t *linedef, const DVector2 &xy, const DVector3 *ref, int flags = 0) { P_LineOpening(open, thing, linedef, xy, reinterpret_cast(ref), flags); } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index b218a5248..84a6ee1dc 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1939,7 +1939,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) // killough 3/15/98: Allow objects to drop off fixed_t startvelx = mo->_f_velx(), startvely = mo->_f_vely(); - if (!P_TryMove (mo, ptryx, ptryy, true, walkplane, tm)) + if (!P_TryMove (mo, DVector2(FIXED2DBL(ptryx), FIXED2DBL(ptryy)), true, walkplane, tm)) { // blocked move AActor *BlockingMobj = mo->BlockingMobj; @@ -1972,11 +1972,11 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) // If the move is done a second time (because it was too fast for one move), it // is still clipped against the wall at its full speed, so you effectively // execute two moves in one tic. - P_SlideMove (mo, mo->_f_velx(), mo->_f_vely(), 1); + P_SlideMove (mo, mo->Vel, 1); } else { - P_SlideMove (mo, onestepx, onestepy, totalsteps); + P_SlideMove (mo, DVector2(FIXED2DBL(onestepx), FIXED2DBL(onestepy)), totalsteps); } if ((mo->_f_velx() | mo->_f_vely()) == 0) { @@ -2006,7 +2006,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) fixed_t tx, ty; tx = 0, ty = onestepy; walkplane = P_CheckSlopeWalk (mo, tx, ty); - if (P_TryMove (mo, mo->_f_X() + tx, mo->_f_Y() + ty, true, walkplane, tm)) + if (P_TryMove (mo, mo->Pos() + DVector2(FIXED2DBL(tx), FIXED2DBL(ty)), true, walkplane, tm)) { mo->Vel.X = 0; } @@ -2014,7 +2014,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { tx = onestepx, ty = 0; walkplane = P_CheckSlopeWalk (mo, tx, ty); - if (P_TryMove (mo, mo->_f_X() + tx, mo->_f_Y() + ty, true, walkplane, tm)) + if (P_TryMove (mo, mo->Pos() + DVector2(FIXED2DBL(tx), FIXED2DBL(ty)), true, walkplane, tm)) { mo->Vel.Y = 0; } @@ -5744,7 +5744,7 @@ bool P_CheckMissileSpawn (AActor* th, double maxdist) bool MBFGrenade = (!(th->flags & MF_MISSILE) || (th->BounceFlags & BOUNCE_MBF)); // killough 3/15/98: no dropoff (really = don't care for missiles) - if (!(P_TryMove (th, th->_f_X(), th->_f_Y(), false, NULL, tm, true))) + if (!(P_TryMove (th, th->Pos(), false, NULL, tm, true))) { // [RH] Don't explode ripping missiles that spawn inside something if (th->BlockingMobj == NULL || !(th->flags2 & MF2_RIP) || (th->BlockingMobj->flags5 & MF5_DONTRIP)) diff --git a/src/po_man.cpp b/src/po_man.cpp index 91d4218ef..f083da738 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -899,8 +899,8 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side) if (crush) { - fixedvec2 pos = actor->Vec2Offset(FLOAT2FIXED(thrust.X), FLOAT2FIXED(thrust.Y)); - if (bHurtOnTouch || !P_CheckMove (actor, pos.x, pos.y)) + DVector2 pos = actor->Vec2Offset(thrust.X, thrust.Y); + if (bHurtOnTouch || !P_CheckMove (actor, pos)) { int newdam = P_DamageMobj (actor, NULL, NULL, crush, NAME_Crush); P_TraceBleed (newdam > 0 ? newdam : crush, actor); diff --git a/src/portal.cpp b/src/portal.cpp index 81a8e4467..79470d410 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -205,8 +205,7 @@ FArchive &operator<< (FArchive &arc, FLinePortal &port) { arc << port.mOrigin << port.mDestination - << port.mXDisplacement - << port.mYDisplacement + << port.mDisplacement << port.mType << port.mFlags << port.mDefFlags @@ -385,8 +384,8 @@ void P_UpdatePortal(FLinePortal *port) } else { - port->mXDisplacement = port->mDestination->v2->x - port->mOrigin->v1->x; - port->mYDisplacement = port->mDestination->v2->y - port->mOrigin->v1->y; + port->mDisplacement.X = port->mDestination->v2->fX() - port->mOrigin->v1->fX(); + port->mDisplacement.Y = port->mDestination->v2->fY() - port->mOrigin->v1->fY(); } } } @@ -721,10 +720,10 @@ fixedvec2 P_GetOffsetPosition(fixed_t x, fixed_t y, fixed_t dx, fixed_t dy) if (port->mType == PORTT_LINKED) { // optimized handling for linked portals where we only need to add an offset. - hit.x += port->mXDisplacement; - hit.y += port->mYDisplacement; - dest.x += port->mXDisplacement; - dest.y += port->mYDisplacement; + hit.x += FLOAT2FIXED(port->mDisplacement.X); + hit.y += FLOAT2FIXED(port->mDisplacement.Y); + dest.x += FLOAT2FIXED(port->mDisplacement.X); + dest.y += FLOAT2FIXED(port->mDisplacement.Y); } else { @@ -851,13 +850,13 @@ static void AddDisplacementForPortal(FLinePortal *portal) FDisplacement & disp = Displacements(thisgroup, othergroup); if (!disp.isSet) { - disp.pos.x = portal->mXDisplacement; - disp.pos.y = portal->mYDisplacement; + disp.pos.x = FLOAT2FIXED(portal->mDisplacement.X); + disp.pos.y = FLOAT2FIXED(portal->mDisplacement.Y); disp.isSet = true; } else { - if (disp.pos.x != portal->mXDisplacement || disp.pos.y != portal->mYDisplacement) + if (disp.pos.x != FLOAT2FIXED(portal->mDisplacement.X) || disp.pos.y != FLOAT2FIXED(portal->mDisplacement.Y)) { Printf("Portal between lines %d and %d has displacement mismatch\n", int(portal->mOrigin - lines), int(portal->mDestination - lines)); portal->mType = linePortals[portal->mDestination->portalindex].mType = PORTT_TELEPORT; diff --git a/src/portal.h b/src/portal.h index 32844943c..935d6cf6c 100644 --- a/src/portal.h +++ b/src/portal.h @@ -185,8 +185,7 @@ struct FLinePortal { line_t *mOrigin; line_t *mDestination; - fixed_t mXDisplacement; - fixed_t mYDisplacement; + DVector2 mDisplacement; BYTE mType; BYTE mFlags; BYTE mDefFlags; diff --git a/src/r_utility.cpp b/src/r_utility.cpp index 810410e08..f76b32d53 100644 --- a/src/r_utility.cpp +++ b/src/r_utility.cpp @@ -82,7 +82,7 @@ static TArray PastViewers; static FRandom pr_torchflicker ("TorchFlicker"); static FRandom pr_hom; static bool NoInterpolateView; -static TArray InterpolationPath; +static TArray InterpolationPath; // PUBLIC DATA DEFINITIONS ------------------------------------------------- @@ -609,26 +609,26 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi angle_t totaladiff = 0; fixed_t oviewz = iview->oviewz; fixed_t nviewz = iview->nviewz; - fixedvec3a oldpos = { iview->oviewx, iview->oviewy, 0, 0. }; - fixedvec3a newpos = { iview->nviewx, iview->nviewy, 0, 0. }; + DVector3a oldpos = { {FIXED2DBL(iview->oviewx), FIXED2DBL(iview->oviewy), 0.}, 0. }; + DVector3a newpos = { {FIXED2DBL(iview->nviewx), FIXED2DBL(iview->nviewy), 0. }, 0. }; InterpolationPath.Push(newpos); // add this to the array to simplify the loops below for (unsigned i = 0; i < InterpolationPath.Size(); i += 2) { - fixedvec3a &start = i == 0 ? oldpos : InterpolationPath[i - 1]; - fixedvec3a &end = InterpolationPath[i]; - pathlen += xs_CRoundToInt(DVector2(end.x - start.x, end.y - start.y).Length()); - totalzdiff += start.z; + DVector3a &start = i == 0 ? oldpos : InterpolationPath[i - 1]; + DVector3a &end = InterpolationPath[i]; + pathlen += FLOAT2FIXED((end.pos-start.pos).Length()); + totalzdiff += FLOAT2FIXED(start.pos.Z); totaladiff += FLOAT2ANGLE(start.angle.Degrees); } fixed_t interpolatedlen = FixedMul(frac, pathlen); for (unsigned i = 0; i < InterpolationPath.Size(); i += 2) { - fixedvec3a &start = i == 0 ? oldpos : InterpolationPath[i - 1]; - fixedvec3a &end = InterpolationPath[i]; - fixed_t fraglen = xs_CRoundToInt(DVector2(end.x - start.x, end.y - start.y).Length()); - zdiff += start.z; + DVector3a &start = i == 0 ? oldpos : InterpolationPath[i - 1]; + DVector3a &end = InterpolationPath[i]; + fixed_t fraglen = FLOAT2FIXED((end.pos - start.pos).Length()); + zdiff += FLOAT2FIXED(start.pos.Z); adiff += FLOAT2ANGLE(start.angle.Degrees); if (fraglen <= interpolatedlen) { @@ -636,13 +636,14 @@ void R_InterpolateView (player_t *player, fixed_t frac, InterpolationViewer *ivi } else { - fixed_t fragfrac = FixedDiv(interpolatedlen, fraglen); + double fragfrac = FIXED2DBL(FixedDiv(interpolatedlen, fraglen)); oviewz += zdiff; nviewz -= totalzdiff - zdiff; oviewangle += adiff; nviewangle -= totaladiff - adiff; - viewx = start.x + FixedMul(fragfrac, end.x - start.x); - viewy = start.y + FixedMul(fragfrac, end.y - start.y); + DVector2 viewpos = start.pos + (fragfrac * (end.pos - start.pos)); + viewx = FLOAT2FIXED(viewpos.X); + viewy = FLOAT2FIXED(viewpos.Y); viewz = oviewz + FixedMul(frac, nviewz - oviewz); break; } @@ -887,7 +888,7 @@ void R_ClearInterpolationPath() // //========================================================================== -void R_AddInterpolationPoint(const fixedvec3a &vec) +void R_AddInterpolationPoint(const DVector3a &vec) { InterpolationPath.Push(vec); } diff --git a/src/r_utility.h b/src/r_utility.h index dcfb31d65..ff7d552af 100644 --- a/src/r_utility.h +++ b/src/r_utility.h @@ -65,9 +65,9 @@ inline angle_t R_PointToAnglePrecise (fixed_t viewx, fixed_t viewy, fixed_t x, f } // Used for interpolation waypoints. -struct fixedvec3a +struct DVector3a { - fixed_t x, y, z; + DVector3 pos; DAngle angle; }; @@ -78,7 +78,7 @@ void R_ResetViewInterpolation (); void R_RebuildViewInterpolation(player_t *player); bool R_GetViewInterpolationStatus(); void R_ClearInterpolationPath(); -void R_AddInterpolationPoint(const fixedvec3a &vec); +void R_AddInterpolationPoint(const DVector3a &vec); void R_SetViewSize (int blocks); void R_SetFOV (float fov); float R_GetFOV (); diff --git a/src/thingdef/thingdef_codeptr.cpp b/src/thingdef/thingdef_codeptr.cpp index 1a356796d..19cd555e6 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -6642,7 +6642,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_CheckBlock) if (flags & CBF_DROPOFF) { mobj->SetZ(pos.Z); - checker = P_CheckMove(mobj, pos.X, pos.Y); + checker = P_CheckMove(mobj, pos); mobj->SetZ(oldpos.Z); } else From 23d311dd04c5f5a9bfda03a2fde2d195038b516f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Mar 2016 14:07:35 +0200 Subject: [PATCH 21/44] - floatified P_CheckSlopeWalk. It should be noted that this function is one place where full double precision is too high and needed to be truncated. --- src/p_local.h | 12 +++++---- src/p_map.cpp | 70 +++++++++++++++++++++++---------------------------- src/r_defs.h | 17 +++++++++++++ 3 files changed, 55 insertions(+), 44 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index d6e8bdb44..d85e1a5d2 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -445,12 +445,14 @@ double P_GetFriction(const AActor *mo, double *frictionfactor); bool Check_Sides(AActor *, int, int); // phares // [RH] -const secplane_t * P_CheckSlopeWalk (AActor *actor, fixed_t &xmove, fixed_t &ymove); -inline const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move) +const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move); + +inline const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymove) { - fixedvec2 mov = { FLOAT2FIXED(move.X), FLOAT2FIXED(move.Y) }; - const secplane_t *ret = P_CheckSlopeWalk(actor, mov.x, mov.y); - move = { FIXED2DBL(mov.x), FIXED2DBL(mov.y) }; + DVector2 move = { FIXED2DBL(xmove), FIXED2DBL(ymove) }; + const secplane_t *ret = P_CheckSlopeWalk(actor, move); + xmove = FLOAT2FIXED(move.X); + ymove = FLOAT2FIXED(move.Y); return ret; } diff --git a/src/p_map.cpp b/src/p_map.cpp index 849d70874..7c16d7332 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2880,7 +2880,7 @@ void P_SlideMove(AActor *mo, const DVector2 &pos, int numsteps) // //============================================================================ -const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymove) +const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move) { static secplane_t copyplane; if (actor->flags & MF_NOGRAVITY) @@ -2888,21 +2888,20 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov return NULL; } - fixedvec3 pos = actor->_f_PosRelative(actor->floorsector); + DVector3 pos = actor->PosRelative(actor->floorsector); const secplane_t *plane = &actor->floorsector->floorplane; - fixed_t planezhere = plane->ZatPoint(pos); + double planezhere = plane->ZatPoint(pos); - for (unsigned int i = 0; ifloorsector->e->XFloor.ffloors.Size(); i++) + for (auto rover : actor->floorsector->e->XFloor.ffloors) { - F3DFloor * rover = actor->floorsector->e->XFloor.ffloors[i]; if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - fixed_t thisplanez = rover->top.plane->ZatPoint(pos); + double thisplanez = rover->top.plane->ZatPoint(pos); - if (thisplanez>planezhere && thisplanez <= actor->_f_Z() + actor->_f_MaxStepHeight()) + if (thisplanez > planezhere && thisplanez <= actor->Z() + actor->MaxStepHeight) { copyplane = *rover->top.plane; - if (copyplane.c<0) copyplane.FlipVert(); + if (copyplane.c < 0) copyplane.FlipVert(); plane = ©plane; planezhere = thisplanez; } @@ -2910,17 +2909,16 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov if (actor->floorsector != actor->Sector) { - for (unsigned int i = 0; iSector->e->XFloor.ffloors.Size(); i++) + for (auto rover : actor->Sector->e->XFloor.ffloors) { - F3DFloor * rover = actor->Sector->e->XFloor.ffloors[i]; if (!(rover->flags & FF_SOLID) || !(rover->flags & FF_EXISTS)) continue; - fixed_t thisplanez = rover->top.plane->ZatPoint(actor); + double thisplanez = rover->top.plane->ZatPointF(actor); - if (thisplanez>planezhere && thisplanez <= actor->_f_Z() + actor->_f_MaxStepHeight()) + if (thisplanez > planezhere && thisplanez <= actor->Z() + actor->MaxStepHeight) { copyplane = *rover->top.plane; - if (copyplane.c<0) copyplane.FlipVert(); + if (copyplane.c < 0) copyplane.FlipVert(); plane = ©plane; planezhere = thisplanez; } @@ -2930,23 +2928,22 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov if (actor->floorsector != actor->Sector) { // this additional check prevents sliding on sloped dropoffs - if (planezhere>actor->_f_floorz() + 4 * FRACUNIT) + if (planezhere>actor->floorz + 4) return NULL; } - if (actor->_f_Z() - planezhere > FRACUNIT) + if (actor->Z() - planezhere > 1) { // not on floor return NULL; } - if ((plane->a | plane->b) != 0) + if (plane->isSlope()) { - fixed_t destx, desty; - fixed_t t; + DVector2 dest; + double t; - destx = actor->_f_X() + xmove; - desty = actor->_f_Y() + ymove; - t = TMulScale16(plane->a, destx, plane->b, desty, plane->c, actor->_f_Z()) + plane->d; + dest = actor->Pos() + move; + t = plane->fA() * dest.X + plane->fB() * dest.Y + plane->fC() * actor->Z() + plane->fD(); if (t < 0) { // Desired location is behind (below) the plane // (i.e. Walking up the plane) @@ -2968,11 +2965,9 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov sector_t *sec = node->m_sector; if (sec->floorplane.c >= STEEPSLOPE) { - fixedvec3 pos = actor->_f_PosRelative(sec); - pos.x += xmove; - pos.y += ymove; + DVector3 pos = actor->PosRelative(sec) +move; - if (sec->floorplane.ZatPointF(pos) >= actor->Z() - actor->MaxStepHeight) + if (sec->floorplane.ZatPoint(pos) >= actor->Z() - actor->MaxStepHeight) { dopush = false; break; @@ -2982,31 +2977,28 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, fixed_t &xmove, fixed_t &ymov } if (dopush) { - xmove = plane->a * 2; - ymove = plane->b * 2; - actor->Vel.X = FIXED2DBL(xmove); - actor->Vel.Y = FIXED2DBL(ymove); + actor->Vel.X = move.X = plane->fA() * 2; + actor->Vel.Y = move.Y = plane->fB() * 2; } return (actor->floorsector == actor->Sector) ? plane : NULL; } } // Slide the desired location along the plane's normal // so that it lies on the plane's surface - destx -= FixedMul(plane->a, t); - desty -= FixedMul(plane->b, t); - xmove = destx - actor->_f_X(); - ymove = desty - actor->_f_Y(); + dest.X -= plane->fA() * t; + dest.Y -= plane->fB() * t; + move = dest - actor->Pos().XY(); return (actor->floorsector == actor->Sector) ? plane : NULL; } else if (t > 0) { // Desired location is in front of (above) the plane - if (planezhere == actor->_f_Z()) - { // Actor's current spot is on/in the plane, so walk down it + if (fabs(planezhere - actor->Z() < (1/65536.))) // it is very important not to be too precise here. + { + // Actor's current spot is on/in the plane, so walk down it // Same principle as walking up, except reversed - destx += FixedMul(plane->a, t); - desty += FixedMul(plane->b, t); - xmove = destx - actor->_f_X(); - ymove = desty - actor->_f_Y(); + dest.X += plane->fA() * t; + dest.Y += plane->fB() * t; + move = dest - actor->Pos().XY(); return (actor->floorsector == actor->Sector) ? plane : NULL; } } diff --git a/src/r_defs.h b/src/r_defs.h index 76ff5122e..a578e6bb8 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -246,6 +246,23 @@ struct secplane_t fixed_t a, b, c, d, ic; + double fA() const + { + return FIXED2FLOAT(a); + } + double fB() const + { + return FIXED2FLOAT(b); + } + double fC() const + { + return FIXED2FLOAT(c); + } + double fD() const + { + return FIXED2FLOAT(d); + } + bool isSlope() const { return a != 0 || b != 0; From 6ab95da2fcc71906fad8e53c2974fd765fe52b04 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Mar 2016 14:11:46 +0200 Subject: [PATCH 22/44] - fixed copy/paste coordinate screwup in moving camera code. --- src/g_shared/a_movingcamera.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/g_shared/a_movingcamera.cpp b/src/g_shared/a_movingcamera.cpp index 158ec6b50..202e1823f 100644 --- a/src/g_shared/a_movingcamera.cpp +++ b/src/g_shared/a_movingcamera.cpp @@ -374,8 +374,8 @@ bool APathFollower::Interpolate () if (CurrNode->Next->Next==NULL) return false; newpos.X = Splerp(PrevNode->X(), CurrNode->X(), CurrNode->Next->X(), CurrNode->Next->Next->X()); - newpos.X = Splerp(PrevNode->Y(), CurrNode->Y(), CurrNode->Next->Y(), CurrNode->Next->Next->Y()); - newpos.X = Splerp(PrevNode->Z(), CurrNode->Z(), CurrNode->Next->Z(), CurrNode->Next->Next->Z()); + newpos.Y = Splerp(PrevNode->Y(), CurrNode->Y(), CurrNode->Next->Y(), CurrNode->Next->Next->Y()); + newpos.Z = Splerp(PrevNode->Z(), CurrNode->Z(), CurrNode->Next->Z(), CurrNode->Next->Next->Z()); } SetXYZ(newpos); LinkToWorld (); From 228c447a02c1ca32bb654378f03905907798e461 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Mar 2016 14:20:14 +0200 Subject: [PATCH 23/44] - fixed: A_FireCustomMissile used the player position as offset. --- 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 19cd555e6..e403de07d 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -1642,7 +1642,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) if (ti) { DAngle ang = self->Angles.Yaw - 90; - DVector3 ofs = self->Vec3Angle(spawnofs_xy, ang, spawnheight); + DVector2 ofs = ang.ToVector(spawnofs_xy); DAngle shootangle = self->Angles.Yaw; if (flags & FPF_AIMATANGLE) shootangle += angle; @@ -1650,7 +1650,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FireCustomMissile) // Temporarily adjusts the pitch DAngle saved_player_pitch = self->Angles.Pitch; self->Angles.Pitch -= pitch; - AActor * misl=P_SpawnPlayerMissile (self, ofs.X, ofs.Y, ofs.Z, ti, shootangle, &t, NULL, false, (flags & FPF_NOAUTOAIM) != 0); + AActor * misl=P_SpawnPlayerMissile (self, ofs.X, ofs.Y, spawnheight, ti, shootangle, &t, NULL, false, (flags & FPF_NOAUTOAIM) != 0); self->Angles.Pitch = saved_player_pitch; // automatic handling of seeker missiles From 4eee1c7af194088ef45728473da14af5fc649dfc Mon Sep 17 00:00:00 2001 From: MajorCooke Date: Fri, 25 Mar 2016 16:17:28 -0500 Subject: [PATCH 24/44] Fixed: A_FaceMovementDirection was backwards. --- 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 e403de07d..e49d661c2 100644 --- a/src/thingdef/thingdef_codeptr.cpp +++ b/src/thingdef/thingdef_codeptr.cpp @@ -6724,7 +6724,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_FaceMovementDirection) //Code borrowed from A_Face*. if (anglelimit > 0) { - DAngle delta = deltaangle(current, angle); + DAngle delta = -deltaangle(current, angle); if (fabs(delta) > anglelimit) { if (delta < 0) From eae6f7e9eaed5301095f02c7fed92b5c6517ed0a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Mar 2016 17:58:18 +0200 Subject: [PATCH 25/44] - floatified P_AimLineAttack. --- src/p_map.cpp | 177 ++++++++++++++++++++++++-------------------------- 1 file changed, 86 insertions(+), 91 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 7c16d7332..2481b7a09 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -3287,13 +3287,13 @@ CVAR(Bool, aimdebug, false, 0) struct AimTarget : public FTranslatedLineTarget { - angle_t pitch; - fixed_t frac; + DAngle pitch; + double frac; void Clear() { memset(this, 0, sizeof(*this)); - frac = FIXED_MAX; + frac = FLT_MAX; } }; @@ -3305,15 +3305,15 @@ struct aim_t aim_down = 2 }; - fixed_t aimpitch; - fixed_t attackrange; - fixed_t shootz; // Height if not aiming up or down - fixed_t limitz; // height limit for portals to avoid bad setups + DAngle aimpitch; + double attackrange; + double shootz; // Height if not aiming up or down + double limitz; // height limit for portals to avoid bad setups AActor* shootthing; AActor* friender; // actor to check friendliness again AActor* aimtarget; // if we want to aim at precisely this target. - fixed_t toppitch, bottompitch; + DAngle toppitch, bottompitch; AimTarget linetarget; AimTarget thing_friend, thing_other; @@ -3323,9 +3323,9 @@ struct aim_t secplane_t * lastceilingplane; int aimdir; - fixedvec3 startpos; - fixedvec2 aimtrace; - fixed_t startfrac; + DVector3 startpos; + DVector2 aimtrace; + double startfrac; bool crossedffloors; bool unlinked; @@ -3347,24 +3347,19 @@ struct aim_t return cloned; } - // Crosing a line portal does not require a recursive call. We can just alter the current set of data - void CrossLinePortal(line_t *line) - { - } - //============================================================================ // // SetResult // //============================================================================ - void SetResult(AimTarget &res, fixed_t frac, AActor *th, fixed_t pitch) + void SetResult(AimTarget &res, double frac, AActor *th, DAngle pitch) { if (res.frac > frac) { res.linetarget = th; res.pitch = pitch; - res.angleFromSource = VecToAngle(th->_f_X() - startpos.x, th->_f_Y() - startpos.y); + res.angleFromSource = (th->Pos() - startpos).Angle(); res.unlinked = unlinked; res.frac = frac; } @@ -3408,7 +3403,7 @@ struct aim_t // //============================================================================ - bool AimTraverse3DFloors(const fdivline_t &trace, intercept_t * in, int frontflag, int *planestocheck) + bool AimTraverse3DFloors(const divline_t &trace, intercept_t * in, int frontflag, int *planestocheck) { sector_t * nextsector; secplane_t * nexttopplane, *nextbottomplane; @@ -3422,11 +3417,11 @@ struct aim_t if (li->frontsector->e->XFloor.ffloors.Size() || li->backsector->e->XFloor.ffloors.Size()) { F3DFloor* rover; - int highpitch, lowpitch; + DAngle highpitch, lowpitch; - fixed_t trX = trace.x + FixedMul(trace.dx, in->frac); - fixed_t trY = trace.y + FixedMul(trace.dy, in->frac); - fixed_t dist = FixedMul(attackrange, in->frac); + double trX = trace.x + trace.dx * in->Frac; + double trY = trace.y + trace.dy * in->Frac; + double dist = attackrange * in->Frac; // 3D floor check. This is not 100% accurate but normally sufficient when // combined with a final sight check @@ -3441,12 +3436,12 @@ struct aim_t if ((rover->flags & FF_SHOOTTHROUGH) || !(rover->flags & FF_EXISTS)) continue; - fixed_t ff_bottom = rover->bottom.plane->ZatPoint(trX, trY); - fixed_t ff_top = rover->top.plane->ZatPoint(trX, trY); + double ff_bottom = rover->bottom.plane->ZatPoint(trX, trY); + double ff_top = rover->top.plane->ZatPoint(trX, trY); - highpitch = -(int)R_PointToAngle2(0, shootz, dist, ff_top); - lowpitch = -(int)R_PointToAngle2(0, shootz, dist, ff_bottom); + highpitch = -VecToAngle(dist, ff_top - shootz); + lowpitch = -VecToAngle(dist, ff_bottom - shootz); if (highpitch <= toppitch) { @@ -3466,7 +3461,7 @@ struct aim_t else if (lowpitch >= bottompitch) { // blocks lower edge of view - if (highpitchSkyBoxes[position]; - if (position == sector_t::ceiling && FLOAT2FIXED(portal->specialf1) < limitz) return; - else if (position == sector_t::floor && FLOAT2FIXED(portal->specialf1) > limitz) return; + if (position == sector_t::ceiling && portal->specialf1 < limitz) return; + else if (position == sector_t::floor && portal->specialf1 > limitz) return; aim_t newtrace = Clone(); newtrace.toppitch = newtoppitch; newtrace.bottompitch = newbottompitch; newtrace.aimdir = position == sector_t::ceiling? aim_t::aim_up : aim_t::aim_down; - newtrace.startpos = { startpos.x + FLOAT2FIXED(portal->Scale.X), startpos.y + FLOAT2FIXED(portal->Scale.Y), startpos.z }; - newtrace.startfrac = frac + FixedDiv(FRACUNIT, attackrange); // this is to skip the transition line to the portal which would produce a bogus opening - newtrace.lastsector = P_PointInSector(newtrace.startpos.x + FixedMul(aimtrace.x, newtrace.startfrac) , newtrace.startpos.y + FixedMul(aimtrace.y, newtrace.startfrac)); - newtrace.limitz = FLOAT2FIXED(portal->specialf1); + newtrace.startpos = startpos + portal->Scale; + newtrace.startfrac = frac + 1. / attackrange; // this is to skip the transition line to the portal which would produce a bogus opening + newtrace.lastsector = P_PointInSector(newtrace.startpos + aimtrace * newtrace.startfrac); + newtrace.limitz = portal->specialf1; if (aimdebug) Printf("-----Entering %s portal from sector %d to sector %d\n", position ? "ceiling" : "floor", lastsector->sectornum, newtrace.lastsector->sectornum); newtrace.AimTraverse(); @@ -3544,7 +3539,7 @@ struct aim_t // //============================================================================ - void EnterLinePortal(line_t *li, fixed_t frac) + void EnterLinePortal(line_t *li, double frac) { aim_t newtrace = Clone(); @@ -3557,16 +3552,15 @@ struct aim_t newtrace.unlinked = (port->mType != PORTT_LINKED); newtrace.startpos = startpos; newtrace.aimtrace = aimtrace; - P_TranslatePortalXY(li, newtrace.startpos.x, newtrace.startpos.y); - P_TranslatePortalZ(li, newtrace.startpos.z); - P_TranslatePortalVXVY(li, newtrace.aimtrace.x, newtrace.aimtrace.y); + P_TranslatePortalXY(li, newtrace.startpos.X, newtrace.startpos.Y); + P_TranslatePortalZ(li, newtrace.startpos.Z); + P_TranslatePortalVXVY(li, newtrace.aimtrace.X, newtrace.aimtrace.Y); - newtrace.startfrac = frac + FixedDiv(FRACUNIT, attackrange); // this is to skip the transition line to the portal which would produce a bogus opening + newtrace.startfrac = frac + 1 / attackrange; // this is to skip the transition line to the portal which would produce a bogus opening - fixed_t x = newtrace.startpos.x + FixedMul(newtrace.aimtrace.x, newtrace.startfrac); - fixed_t y = newtrace.startpos.y + FixedMul(newtrace.aimtrace.y, newtrace.startfrac); + DVector2 pos = newtrace.startpos + newtrace.aimtrace * newtrace.startfrac; - newtrace.lastsector = P_PointInSector(x, y); + newtrace.lastsector = P_PointInSector(pos); P_TranslatePortalZ(li, limitz); if (aimdebug) Printf("-----Entering line portal from sector %d to sector %d\n", lastsector->sectornum, newtrace.lastsector->sectornum); @@ -3601,9 +3595,9 @@ struct aim_t { if ((rover->flags & FF_SHOOTTHROUGH) || !(rover->flags & FF_EXISTS)) continue; - fixed_t bottomz = rover->bottom.plane->ZatPoint(startpos); + double bottomz = rover->bottom.plane->ZatPoint(startpos); - if (bottomz >= startpos.z + shootthing->_f_height()) + if (bottomz >= startpos.Z + shootthing->Height) { lastceilingplane = rover->bottom.plane; // no ceiling portal if below a 3D floor @@ -3611,47 +3605,47 @@ struct aim_t } bottomz = rover->top.plane->ZatPoint(startpos); - if (bottomz <= startpos.z) + if (bottomz <= startpos.Z) { lastfloorplane = rover->top.plane; // no floor portal if above a 3D floor floorportalstate = false; } } - if (ceilingportalstate) EnterSectorPortal(sector_t::ceiling, 0, lastsector, toppitch, MIN(0, bottompitch)); - if (floorportalstate) EnterSectorPortal(sector_t::floor, 0, lastsector, MAX(0, toppitch), bottompitch); + if (ceilingportalstate) EnterSectorPortal(sector_t::ceiling, 0, lastsector, toppitch, MIN(0., bottompitch)); + if (floorportalstate) EnterSectorPortal(sector_t::floor, 0, lastsector, MAX(0., toppitch), bottompitch); - FPathTraverse it(startpos.x, startpos.y, aimtrace.x, aimtrace.y, PT_ADDLINES | PT_ADDTHINGS | PT_COMPATIBLE | PT_DELTA, startfrac); + FPathTraverse it(startpos.X, startpos.Y, aimtrace.X, aimtrace.Y, PT_ADDLINES | PT_ADDTHINGS | PT_COMPATIBLE | PT_DELTA, startfrac); intercept_t *in; if (aimdebug) Printf("Start AimTraverse, start = %f,%f,%f, vect = %f,%f\n", - startpos.x / 65536., startpos.y / 65536., startpos.z / 65536., - aimtrace.x / 65536., aimtrace.y / 65536.); + startpos.X / 65536., startpos.Y / 65536., startpos.Z / 65536., + aimtrace.X / 65536., aimtrace.Y / 65536.); while ((in = it.Next())) { line_t* li; AActor* th; - fixed_t pitch; - fixed_t thingtoppitch; - fixed_t thingbottompitch; - fixed_t dist; - int thingpitch; + DAngle pitch; + DAngle thingtoppitch; + DAngle thingbottompitch; + double dist; + DAngle thingpitch; - if (linetarget.linetarget != NULL && in->frac > linetarget.frac) return; // we already found something better in another portal section. + if (linetarget.linetarget != NULL && in->Frac > linetarget.frac) return; // we already found something better in another portal section. if (in->isaline) { li = in->d.line; - int frontflag = P_PointOnLineSidePrecise(startpos.x, startpos.y, li); + int frontflag = P_PointOnLineSidePrecise(startpos, li); if (aimdebug) - Printf("Found line %d: toppitch = %f, bottompitch = %f\n", int(li - lines), ANGLE2DBL(toppitch), ANGLE2DBL(bottompitch)); + Printf("Found line %d: ___toppitch = %f, ___bottompitch = %f\n", int(li - lines), toppitch.Degrees, bottompitch.Degrees); if (li->isLinePortal() && frontflag == 0) { - EnterLinePortal(li, in->frac); + EnterLinePortal(li, in->Frac); return; } @@ -3662,24 +3656,24 @@ struct aim_t // Crosses a two sided line. // A two sided line will restrict the possible target ranges. FLineOpening open; - P_LineOpening(open, NULL, li, it._f_InterceptPoint(in), FIXED_MIN, 0, FFCF_NODROPOFF); + P_LineOpening(open, NULL, li, it.InterceptPoint(in), (DVector2*)nullptr, FFCF_NODROPOFF); // The following code assumes that portals on the front of the line have already been processed. if (open.range <= 0 || open.bottom >= open.top) return; - dist = FixedMul(attackrange, in->frac); + dist = attackrange * in->Frac; if (open.bottom != LINEOPEN_MIN) { - pitch = -(int)R_PointToAngle2(0, shootz, dist, FLOAT2FIXED(open.bottom)); + pitch = -VecToAngle(dist, open.bottom - shootz); if (pitch < bottompitch) bottompitch = pitch; } if (open.top != LINEOPEN_MAX) { - pitch = -(int)R_PointToAngle2(0, shootz, dist, FLOAT2FIXED(open.top)); + pitch = -VecToAngle(dist, open.top - shootz); if (pitch > toppitch) toppitch = pitch; } @@ -3687,11 +3681,11 @@ struct aim_t return; int planestocheck; - if (!AimTraverse3DFloors(it._f_Trace(), in, frontflag, &planestocheck)) + if (!AimTraverse3DFloors(it.Trace(), in, frontflag, &planestocheck)) return; if (aimdebug) - Printf("After line %d: toppitch = %f, bottompitch = %f, planestocheck = %d\n", int(li - lines), ANGLE2DBL(toppitch), ANGLE2DBL(bottompitch), planestocheck); + Printf("After line %d: toppitch = %f, bottompitch = %f, planestocheck = %d\n", int(li - lines), toppitch.Degrees, bottompitch.Degrees, planestocheck); sector_t *entersec = frontflag ? li->frontsector : li->backsector; sector_t *exitsec = frontflag ? li->backsector : li->frontsector; @@ -3699,11 +3693,11 @@ struct aim_t // check portal in backsector when aiming up/downward is possible, the line doesn't have portals on both sides and there's actually a portal in the backsector if ((planestocheck & aim_up) && toppitch < 0 && open.top != LINEOPEN_MAX && !entersec->PortalBlocksMovement(sector_t::ceiling)) { - EnterSectorPortal(sector_t::ceiling, in->frac, entersec, toppitch, MIN(0, bottompitch)); + EnterSectorPortal(sector_t::ceiling, in->Frac, entersec, toppitch, MIN(0., bottompitch)); } if ((planestocheck & aim_down) && bottompitch > 0 && open.bottom != LINEOPEN_MIN && !entersec->PortalBlocksMovement(sector_t::floor)) { - EnterSectorPortal(sector_t::floor, in->frac, entersec, MAX(0, toppitch), bottompitch); + EnterSectorPortal(sector_t::floor, in->Frac, entersec, MAX(0., toppitch), bottompitch); } continue; // shot continues } @@ -3735,7 +3729,7 @@ struct aim_t } } } - dist = FixedMul(attackrange, in->frac); + dist = attackrange * in->Frac; // Don't autoaim certain special actors if (!cl_doautoaim && th->flags6 & MF6_NOTAUTOAIMED) @@ -3748,8 +3742,8 @@ struct aim_t { if (lastceilingplane) { - fixed_t ff_top = lastceilingplane->ZatPoint(th); - fixed_t pitch = -(int)R_PointToAngle2(0, shootz, dist, ff_top); + double ff_top = lastceilingplane->ZatPointF(th); + DAngle pitch = -VecToAngle(dist, ff_top - shootz); // upper slope intersects with this 3d-floor if (pitch > toppitch) { @@ -3758,8 +3752,8 @@ struct aim_t } if (lastfloorplane) { - fixed_t ff_bottom = lastfloorplane->ZatPoint(th); - fixed_t pitch = -(int)R_PointToAngle2(0, shootz, dist, ff_bottom); + double ff_bottom = lastfloorplane->ZatPointF(th); + DAngle pitch = -VecToAngle(dist, ff_bottom - shootz); // lower slope intersects with this 3d-floor if (pitch < bottompitch) { @@ -3770,12 +3764,12 @@ struct aim_t // check angles to see if the thing can be aimed at - thingtoppitch = -(int)R_PointToAngle2(0, shootz, dist, th->_f_Z() + th->_f_height()); + thingtoppitch = -VecToAngle(dist, th->Top() - shootz); if (thingtoppitch > bottompitch) continue; // shot over the thing - thingbottompitch = -(int)R_PointToAngle2(0, shootz, dist, th->_f_Z()); + thingbottompitch = -VecToAngle(dist, th->Z() - shootz); if (thingbottompitch < toppitch) continue; // shot under the thing @@ -3814,10 +3808,11 @@ struct aim_t // combination with P_LineAttack. P_LineAttack uses 3D distance but FPathTraverse // only 2D. This causes some problems with Hexen's weapons that use different // attack modes based on distance to target - fixed_t cosine = finecosine[thingpitch >> ANGLETOFINESHIFT]; + double cosine = thingpitch.Cos(); if (cosine != 0) { - fixed_t d3 = FixedDiv(FixedMul(P_AproxDistance(it._f_Trace().dx, it._f_Trace().dy), in->frac), cosine); + double tracelen = DVector2(it.Trace().dx, it.Trace().dy).Length(); + double d3 = tracelen * in->Frac / cosine; if (d3 > attackrange) { return; @@ -3840,7 +3835,7 @@ struct aim_t // friends don't aim at friends (except players), at least not first if (aimdebug) Printf("Hit friend %s at %f,%f,%f\n", th->GetClass()->TypeName.GetChars(), th->X(), th->Y(), th->Z()); - SetResult(thing_friend, in->frac, th, thingpitch); + SetResult(thing_friend, in->Frac, th, thingpitch); } } else if (!(th->flags3 & MF3_ISMONSTER) && th->player == NULL) @@ -3850,14 +3845,14 @@ struct aim_t // don't autoaim at barrels and other shootable stuff unless no monsters have been found if (aimdebug) Printf("Hit other %s at %f,%f,%f\n", th->GetClass()->TypeName.GetChars(), th->X(), th->Y(), th->Z()); - SetResult(thing_other, in->frac, th, thingpitch); + SetResult(thing_other, in->Frac, th, thingpitch); } } else { if (aimdebug) Printf("Hit target %s at %f,%f,%f\n", th->GetClass()->TypeName.GetChars(), th->X(), th->Y(), th->Z()); - SetResult(linetarget, in->frac, th, thingpitch); + SetResult(linetarget, in->Frac, th, thingpitch); return; } } @@ -3865,7 +3860,7 @@ struct aim_t { if (aimdebug) Printf("Hit target %s at %f,%f,%f\n", th->GetClass()->TypeName.GetChars(), th->X(), th->Y(), th->Z()); - SetResult(linetarget, in->frac, th, thingpitch); + SetResult(linetarget, in->Frac, th, thingpitch); return; } } @@ -3881,14 +3876,14 @@ struct aim_t DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLineTarget *pLineTarget, DAngle vrange, int flags, AActor *target, AActor *friender) { - fixed_t shootz = t1->_f_Z() + (t1->_f_height() >> 1) - t1->_f_floorclip(); + double shootz = t1->Center() - t1->Floorclip; if (t1->player != NULL) { - shootz += FLOAT2FIXED(t1->player->mo->AttackZOffset * t1->player->crouchfactor); + shootz += t1->player->mo->AttackZOffset * t1->player->crouchfactor; } else { - shootz += 8 * FRACUNIT; + shootz += 8; } // can't shoot outside view angles @@ -3923,13 +3918,13 @@ DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLin aim.shootthing = t1; aim.friender = (friender == NULL) ? t1 : friender; aim.aimdir = aim_t::aim_up | aim_t::aim_down; - aim.startpos = t1->_f_Pos(); - aim.aimtrace = Vec2Angle(FLOAT2FIXED(distance), angle); + aim.startpos = t1->Pos(); + aim.aimtrace = angle.ToVector(distance); aim.limitz = aim.shootz = shootz; - aim.toppitch = (t1->Angles.Pitch - vrange).BAMs(); - aim.bottompitch = (t1->Angles.Pitch + vrange).BAMs(); - aim.attackrange = FLOAT2FIXED(distance); - aim.aimpitch = t1->_f_pitch(); + aim.toppitch = t1->Angles.Pitch - vrange; + aim.bottompitch = t1->Angles.Pitch + vrange; + aim.attackrange = distance; + aim.aimpitch = t1->Angles.Pitch; aim.lastsector = t1->Sector; aim.startfrac = 0; aim.unlinked = false; @@ -3943,7 +3938,7 @@ DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLin { *pLineTarget = *result; } - return result->linetarget ? DAngle(ANGLE2DBL(result->pitch)) : t1->Angles.Pitch; + return result->linetarget ? result->pitch : t1->Angles.Pitch; } From 0baaa3cf63ec38b60aafd9dc2399892927b4c9fb Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Mar 2016 20:58:01 +0200 Subject: [PATCH 26/44] - floatified P_LineAttack, P_TraceBleed and P_UseLines. --- src/actor.h | 7 +- src/p_acs.cpp | 2 +- src/p_effect.cpp | 5 +- src/p_effect.h | 2 +- src/p_enemy.cpp | 4 +- src/p_local.h | 19 ++--- src/p_map.cpp | 168 +++++++++++++++++++-------------------------- src/p_maputl.cpp | 6 +- src/p_maputl.h | 2 +- src/p_spec.cpp | 4 +- src/p_spec.h | 6 +- src/p_switch.cpp | 43 ++++++------ src/p_teleport.cpp | 4 +- src/p_trace.cpp | 3 +- 14 files changed, 118 insertions(+), 157 deletions(-) diff --git a/src/actor.h b/src/actor.h index 863c0a496..8c459d9a5 100644 --- a/src/actor.h +++ b/src/actor.h @@ -1679,13 +1679,8 @@ inline fixedvec2 Vec2Angle(fixed_t length, angle_t angle) return ret; } -inline fixedvec2 Vec2Angle(fixed_t length, DAngle angle) -{ - return { xs_CRoundToInt(length * angle.Cos()), xs_CRoundToInt(length * angle.Sin()) }; -} - void PrintMiscActorInfo(AActor * query); -AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch, ActorFlags actorMask, DWORD wallMask); +AActor *P_LinePickActor(AActor *t1, DAngle angle, double distance, DAngle pitch, ActorFlags actorMask, DWORD wallMask); // If we want to make P_AimLineAttack capable of handling arbitrary portals, it needs to pass a lot more info than just the linetarget actor. struct FTranslatedLineTarget diff --git a/src/p_acs.cpp b/src/p_acs.cpp index d9ae0c358..0365c974e 100644 --- a/src/p_acs.cpp +++ b/src/p_acs.cpp @@ -5885,7 +5885,7 @@ doplaysound: if (funcIndex == ACSF_PlayActorSound) flags = args[7]; } - AActor* pickedActor = P_LinePickActor(actor, args[1] << 16, args[3], args[2] << 16, actorMask, wallMask); + AActor* pickedActor = P_LinePickActor(actor, ACSToAngle(args[1]), ACSToDouble(args[3]), ACSToAngle(args[2]), actorMask, wallMask); if (pickedActor == NULL) { return 0; } diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 5e5ed316e..75152d6ef 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -637,7 +637,7 @@ void P_DrawSplash2 (int count, const DVector3 &pos, DAngle angle, int updown, in } } -void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, int color1, int color2, double maxdiff_d, int flags, PClassActor *spawnclass, angle_t angle, int duration, double sparsity, double drift, int SpiralOffset) +void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, int color1, int color2, double maxdiff_d, int flags, PClassActor *spawnclass, DAngle angle, int duration, double sparsity, double drift, int SpiralOffset) { double length, lengthsquared; int steps, i; @@ -646,6 +646,7 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, bool fullbright; float maxdiff = (float)maxdiff_d; + dir = end - start; lengthsquared = dir | dir; length = g_sqrt(lengthsquared); @@ -862,7 +863,7 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, } AActor *thing = Spawn (spawnclass, pos + diff, ALLOW_REPLACE); if (thing) - thing->Angles.Yaw = ANGLE2DBL(angle); + thing->Angles.Yaw = angle; pos += trail_step; } } diff --git a/src/p_effect.h b/src/p_effect.h index d62fc7d65..f07943494 100644 --- a/src/p_effect.h +++ b/src/p_effect.h @@ -89,7 +89,7 @@ void P_RunEffects (void); void P_RunEffect (AActor *actor, int effects); -void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, int color1, int color2, double maxdiff = 0, int flags = 0, PClassActor *spawnclass = NULL, angle_t angle = 0, int duration = 35, double sparsity = 1.0, double drift = 1.0, int SpiralOffset = 270); +void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, int color1, int color2, double maxdiff = 0, int flags = 0, PClassActor *spawnclass = NULL, DAngle angle = 0., int duration = 35, double sparsity = 1.0, double drift = 1.0, int SpiralOffset = 270); void P_DrawSplash (int count, const DVector3 &pos, DAngle angle, int kind); void P_DrawSplash2 (int count, const DVector3 &pos, DAngle angle, int updown, int kind); void P_DisconnectEffect (AActor *actor); diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 93361833e..08053630d 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -2605,7 +2605,7 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) FState *raisestate = corpsehit->GetRaiseState(); if (raisestate != NULL) { - // use the current actor's _f_radius() instead of the Arch Vile's default. + // use the current actor's radius instead of the Arch Vile's default. double maxdist = corpsehit->GetDefault()->radius + self->radius; if (fabs(corpsehit->X() - cres.Position.X) > maxdist || @@ -2640,7 +2640,7 @@ static bool P_CheckForResurrection(AActor *self, bool usevilestates) } corpsehit->Vel.X = corpsehit->Vel.Y = 0; - // [RH] Check against real height and _f_radius() + // [RH] Check against real height and radius double oldheight = corpsehit->Height; double oldradius = corpsehit->radius; diff --git a/src/p_local.h b/src/p_local.h index d85e1a5d2..1b19029fd 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -88,7 +88,7 @@ inline int GetSafeBlockY(long long blocky) #define MAXMOVE (30.) #define TALKRANGE (128.) -#define USERANGE (64*FRACUNIT) +#define USERANGE (64.) #define MELEERANGE (64.) #define SAWRANGE (64.+(1./65536.)) // use meleerange + 1 so the puff doesn't skip the flash (i.e. plays all states) @@ -360,20 +360,9 @@ enum // P_LineAttack flags AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, DAngle pitch, int damage, FName damageType, PClassActor *pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL); AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, DAngle pitch, int damage, FName damageType, FName pufftype, int flags = 0, FTranslatedLineTarget *victim = NULL, int *actualdamage = NULL); -void P_TraceBleed (int damage, fixed_t x, fixed_t y, fixed_t z, AActor *target, angle_t angle, int pitch); -inline void P_TraceBleed(int damage, const fixedvec3 &pos, AActor *target, angle_t angle, int pitch) -{ - P_TraceBleed(damage, pos.x, pos.y, pos.z, target, angle, pitch); -} -inline void P_TraceBleed(int damage, const DVector3 &pos, AActor *target, DAngle angle, DAngle pitch) -{ - P_TraceBleed(damage, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), target,angle.BAMs(), pitch.BAMs()); -} -void P_TraceBleed (int damage, AActor *target, angle_t angle, int pitch); -inline void P_TraceBleed(int damage, AActor *target, DAngle angle, DAngle pitch) -{ - P_TraceBleed(damage, target, angle.BAMs(), pitch.BAMs()); -} +void P_TraceBleed(int damage, const DVector3 &pos, AActor *target, DAngle angle, DAngle pitch); +void P_TraceBleed(int damage, AActor *target, DAngle angle, DAngle pitch); + void P_TraceBleed (int damage, AActor *target, AActor *missile); // missile version void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff); // hitscan version void P_TraceBleed (int damage, AActor *target); // random direction version diff --git a/src/p_map.cpp b/src/p_map.cpp index 2481b7a09..0a3d1bd31 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -3535,7 +3535,6 @@ struct aim_t //============================================================================ // // traverses a line portal - // simply calling PortalRelocate does not work here because more needs to be set up // //============================================================================ @@ -3993,12 +3992,11 @@ static ETraceStatus CheckForActor(FTraceResults &res, void *userdata) AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, DAngle pitch, int damage, FName damageType, PClassActor *pufftype, int flags, FTranslatedLineTarget*victim, int *actualdamage) { - fixed_t vx, vy, vz, shootz; + DVector3 direction; + double shootz; FTraceResults trace; Origin TData; TData.Caller = t1; - angle_t srcangle = angle.BAMs(); - int srcpitch = pitch.BAMs(); bool killPuff = false; AActor *puff = NULL; int pflag = 0; @@ -4017,14 +4015,12 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, double pc = pitch.Cos(); - vx = FLOAT2FIXED(pc * angle.Cos()); - vy = FLOAT2FIXED(pc * angle.Sin()); - vz = FLOAT2FIXED(-pitch.Sin()); + direction = { pc * angle.Cos(), pc * angle.Sin(), -pitch.Sin() }; + shootz = t1->Center() - t1->Floorclip; - shootz = t1->_f_Z() - t1->_f_floorclip() + (t1->_f_height() >> 1); if (t1->player != NULL) { - shootz += FLOAT2FIXED(t1->player->mo->AttackZOffset * t1->player->crouchfactor); + shootz += t1->player->mo->AttackZOffset * t1->player->crouchfactor; if (damageType == NAME_Melee || damageType == NAME_Hitscan) { // this is coming from a weapon attack function which needs to transfer information to the obituary code, @@ -4034,7 +4030,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, } else { - shootz += 8 * FRACUNIT; + shootz += 8; } // We need to check the defaults of the replacement here @@ -4059,9 +4055,8 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, if (puffDefaults != NULL && puffDefaults->flags6 & MF6_NOTRIGGER) tflags = TRACE_NoSky; else tflags = TRACE_NoSky | TRACE_Impact; - if (!Trace(t1->_f_X(), t1->_f_Y(), shootz, t1->Sector, vx, vy, vz, FLOAT2FIXED(distance), - MF_SHOOTABLE, ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, t1, trace, - tflags, CheckForActor, &TData)) + if (!Trace(t1->PosAtZ(shootz), t1->Sector, direction, distance, MF_SHOOTABLE, + ML_BLOCKEVERYTHING | ML_BLOCKHITSCAN, t1, trace, tflags, CheckForActor, &TData)) { // hit nothing if (puffDefaults == NULL) { @@ -4217,7 +4212,7 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, } } // [RH] Stick blood to walls - P_TraceBleed(newdam > 0 ? newdam : damage, trace.HitPos, trace.Actor, trace.SrcAngleFromTarget, ANGLE2DBL(srcpitch)); + P_TraceBleed(newdam > 0 ? newdam : damage, trace.HitPos, trace.Actor, trace.SrcAngleFromTarget, pitch); } } if (victim != NULL) @@ -4270,26 +4265,22 @@ AActor *P_LineAttack(AActor *t1, DAngle angle, double distance, // //========================================================================== -AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch, - ActorFlags actorMask, DWORD wallMask) +AActor *P_LinePickActor(AActor *t1, DAngle angle, double distance, DAngle pitch, ActorFlags actorMask, DWORD wallMask) { - fixed_t vx, vy, vz, shootz; - - angle >>= ANGLETOFINESHIFT; - pitch = (angle_t)(pitch) >> ANGLETOFINESHIFT; + DVector3 direction; + double shootz; - vx = FixedMul(finecosine[pitch], finecosine[angle]); - vy = FixedMul(finecosine[pitch], finesine[angle]); - vz = -finesine[pitch]; + double pc = pitch.Cos(); + direction = { pc * angle.Cos(), pc * angle.Sin(), -pitch.Sin() }; + shootz = t1->Center() - t1->Floorclip; - shootz = t1->_f_Z() - t1->_f_floorclip() + (t1->_f_height() >> 1); if (t1->player != NULL) { - shootz += FLOAT2FIXED(t1->player->mo->AttackZOffset * t1->player->crouchfactor); + shootz += t1->player->mo->AttackZOffset * t1->player->crouchfactor; } else { - shootz += 8 * FRACUNIT; + shootz += 8; } FTraceResults trace; @@ -4298,7 +4289,7 @@ AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch, TData.Caller = t1; TData.hitGhosts = true; - if (Trace(t1->_f_X(), t1->_f_Y(), shootz, t1->Sector, vx, vy, vz, distance, + if (Trace(t1->PosAtZ(shootz), t1->Sector, direction, distance, actorMask, wallMask, t1, trace, TRACE_NoSky | TRACE_PortalRestrict, CheckForActor, &TData)) { if (trace.HitType == TRACE_HitActor) @@ -4316,14 +4307,14 @@ AActor *P_LinePickActor(AActor *t1, angle_t angle, fixed_t distance, int pitch, // //========================================================================== -void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, angle_t angle, int pitch) +void P_TraceBleed(int damage, const DVector3 &pos, AActor *actor, DAngle angle, DAngle pitch) { if (!cl_bloodsplats) return; const char *bloodType = "BloodSplat"; int count; - int noise; + double noise; if ((actor->flags & MF_NOBLOOD) || @@ -4333,6 +4324,7 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an { return; } + if (damage < 15) { // For low damages, there is a chance to not spray blood at all if (damage <= 10) @@ -4343,12 +4335,12 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an } } count = 1; - noise = 18; + noise = 11.25 / 256.; } else if (damage < 25) { count = 2; - noise = 19; + noise = 22.5 / 256.; } else { // For high damages, there is a chance to spray just one big glob of blood @@ -4356,12 +4348,12 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an { bloodType = "BloodSmear"; count = 1; - noise = 20; + noise = 45. / 256.; } else { count = 3; - noise = 20; + noise = 45. / 256.; } } @@ -4369,15 +4361,12 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an { FTraceResults bleedtrace; - angle_t bleedang = (angle + ((pr_tracebleed() - 128) << noise)) >> ANGLETOFINESHIFT; - angle_t bleedpitch = (angle_t)(pitch + ((pr_tracebleed() - 128) << noise)) >> ANGLETOFINESHIFT; - fixed_t vx = FixedMul(finecosine[bleedpitch], finecosine[bleedang]); - fixed_t vy = FixedMul(finecosine[bleedpitch], finesine[bleedang]); - fixed_t vz = -finesine[bleedpitch]; + DAngle bleedang = angle + (pr_tracebleed() - 128) * noise; + DAngle bleedpitch = pitch + (pr_tracebleed() - 128) * noise; + double cosp = bleedpitch.Cos(); + DVector3 vdir = DVector3(cosp * bleedang.Cos(), cosp * bleedang.Sin(), -bleedpitch.Sin()); - if (Trace(x, y, z, actor->Sector, - vx, vy, vz, 172 * FRACUNIT, 0, ML_BLOCKEVERYTHING, actor, - bleedtrace, TRACE_NoSky)) + if (Trace(pos, actor->Sector, vdir, 172 * FRACUNIT, 0, ML_BLOCKEVERYTHING, actor, bleedtrace, TRACE_NoSky)) { if (bleedtrace.HitType == TRACE_HitWall) { @@ -4397,10 +4386,9 @@ void P_TraceBleed(int damage, fixed_t x, fixed_t y, fixed_t z, AActor *actor, an } } -void P_TraceBleed(int damage, AActor *target, angle_t angle, int pitch) +void P_TraceBleed(int damage, AActor *target, DAngle angle, DAngle pitch) { - P_TraceBleed(damage, target->_f_X(), target->_f_Y(), target->_f_Z() + target->_f_height() / 2, - target, angle, pitch); + P_TraceBleed(damage, target->PosPlusZ(target->Height/2), target, angle, pitch); } //========================================================================== @@ -4422,7 +4410,7 @@ void P_TraceBleed(int damage, AActor *target, AActor *missile) { double aim; - aim = g_atan((double)missile->_f_velz() / (double)target->AproxDistance(missile)); + aim = g_atan(missile->Vel.Z / target->Distance2D(missile)); pitch = -ToDegrees(aim); } else @@ -4445,9 +4433,8 @@ void P_TraceBleed(int damage, FTranslatedLineTarget *t, AActor *puff) return; } - fixed_t randpitch = (pr_tracebleed() - 128) << 16; - P_TraceBleed(damage, t->linetarget->_f_X(), t->linetarget->_f_Y(), t->linetarget->_f_Z() + t->linetarget->_f_height() / 2, - t->linetarget, FLOAT2ANGLE(t->angleFromSource.Degrees), 0); + DAngle pitch = (pr_tracebleed() - 128) * (360 / 65536.); + P_TraceBleed(damage, t->linetarget->PosPlusZ(t->linetarget->Height/2), t->linetarget, t->angleFromSource, pitch); } //========================================================================== @@ -4460,11 +4447,9 @@ void P_TraceBleed(int damage, AActor *target) { if (target != NULL) { - fixed_t one = pr_tracebleed() << 24; - fixed_t two = (pr_tracebleed() - 128) << 16; - - P_TraceBleed(damage, target->_f_X(), target->_f_Y(), target->_f_Z() + target->_f_height() / 2, - target, one, two); + DAngle angle = pr_tracebleed() * (360 / 256.); + DAngle pitch = (pr_tracebleed() - 128) * (360 / 65536.); + P_TraceBleed(damage, target->PosPlusZ(target->Height / 2), target, angle, pitch); } } @@ -4683,7 +4668,7 @@ void P_RailAttack(FRailParams *p) } // Draw the slug's trail. - P_DrawRailTrail(source, start, trace.HitPos, p->color1, p->color2, p->maxdiff, p->flags, p->spawnclass, angle.BAMs(), p->duration, p->sparsity, p->drift, p->SpiralOffset); + P_DrawRailTrail(source, start, trace.HitPos, p->color1, p->color2, p->maxdiff, p->flags, p->spawnclass, angle, p->duration, p->sparsity, p->drift, p->SpiralOffset); } //========================================================================== @@ -4697,27 +4682,23 @@ CVAR(Float, chase_dist, 90.f, CVAR_ARCHIVE | CVAR_GLOBALCONFIG) void P_AimCamera(AActor *t1, DVector3 &campos, sector_t *&CameraSector, bool &unlinked) { - fixed_t distance = (fixed_t)(clamp(chase_dist, 0, 30000) * FRACUNIT); - angle_t angle = (t1->_f_angle() - ANG180) >> ANGLETOFINESHIFT; - angle_t pitch = (angle_t)(t1->_f_pitch()) >> ANGLETOFINESHIFT; + double distance = clamp(chase_dist, 0, 30000); + DAngle angle = t1->Angles.Yaw - 180; + DAngle pitch = t1->Angles.Pitch; FTraceResults trace; - fixed_t vx, vy, vz, sz; + DVector3 vvec; + double sz; - vx = FixedMul(finecosine[pitch], finecosine[angle]); - vy = FixedMul(finecosine[pitch], finesine[angle]); - vz = finesine[pitch]; + double pc = pitch.Cos(); - DVector3 vvec(vx, vy, vz); - vvec.MakeUnit(); + vvec = { pc * angle.Cos(), pc * angle.Sin(), -pitch.Sin() }; + sz = t1->Top() - t1->Floorclip + clamp(chase_height, -1000, 1000); - sz = t1->_f_Z() - t1->_f_floorclip() + t1->_f_height() + (fixed_t)(clamp(chase_height, -1000, 1000) * FRACUNIT); - - if (Trace(t1->_f_X(), t1->_f_Y(), sz, t1->Sector, - vx, vy, vz, distance, 0, 0, NULL, trace) && + if (Trace(t1->PosAtZ(sz), t1->Sector, vvec, distance, 0, 0, NULL, trace) && trace.Distance > 10) { // Position camera slightly in front of hit thing - campos = t1->PosAtZ(FIXED2DBL(sz)) + vvec *(trace.Distance - 5); + campos = t1->PosAtZ(sz) + vvec *(trace.Distance - 5); } else { @@ -4768,11 +4749,11 @@ bool P_TalkFacing(AActor *player) // //========================================================================== -bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy, bool &foundline) +bool P_UseTraverse(AActor *usething, const DVector2 &start, const DVector2 &end, bool &foundline) { - FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES | PT_ADDTHINGS); + FPathTraverse it(start.X, start.Y, end.X, end.Y, PT_ADDLINES | PT_ADDTHINGS); intercept_t *in; - fixedvec3 xpos = { startx, starty, usething->_f_Z() }; + DVector3 xpos = { start.X, start.Y, usething->Z() }; while ((in = it.Next())) { @@ -4792,6 +4773,7 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end } continue; } + if (it.PortalRelocate(in, PT_ADDLINES | PT_ADDTHINGS, &xpos)) { continue; @@ -4807,7 +4789,7 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end } else { - P_LineOpening(open, NULL, in->d.line, it._f_InterceptPoint(in)); + P_LineOpening(open, NULL, in->d.line, it.InterceptPoint(in)); } if (open.range <= 0 || (in->d.line->special != 0 && (i_compatflags & COMPATF_USEBLOCKING))) @@ -4823,7 +4805,7 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end return true; } - sec = P_PointOnLineSide(xpos.x, xpos.y, in->d.line) == 0 ? + sec = P_PointOnLineSide(xpos, in->d.line) == 0 ? in->d.line->frontsector : in->d.line->backsector; if (sec != NULL && sec->SecActTarget && @@ -4842,7 +4824,7 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end continue; // not a special line, but keep checking } - if (P_PointOnLineSide(xpos.x, xpos.y, in->d.line) == 1) + if (P_PointOnLineSide(xpos, in->d.line) == 1) { if (!(in->d.line->activation & SPAC_UseBack)) { @@ -4900,9 +4882,9 @@ bool P_UseTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t end // //========================================================================== -bool P_NoWayTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t endx, fixed_t endy) +bool P_NoWayTraverse(AActor *usething, const DVector2 &start, const DVector2 &end) { - FPathTraverse it(startx, starty, endx, endy, PT_ADDLINES); + FPathTraverse it(start.X, start.Y, end.X, end.Y, PT_ADDLINES); intercept_t *in; while ((in = it.Next())) @@ -4915,7 +4897,7 @@ bool P_NoWayTraverse(AActor *usething, fixed_t startx, fixed_t starty, fixed_t e if (ld->special) continue; if (ld->isLinePortal()) return false; if (ld->flags&(ML_BLOCKING | ML_BLOCKEVERYTHING | ML_BLOCK_PLAYERS)) return true; - P_LineOpening(open, NULL, ld, it._f_InterceptPoint(in)); + P_LineOpening(open, NULL, ld, it.InterceptPoint(in)); if (open.range <= 0 || open.bottom > usething->Z() + usething->MaxStepHeight || open.top < usething->Top()) return true; @@ -4936,23 +4918,20 @@ void P_UseLines(player_t *player) bool foundline = false; // If the player is transitioning a portal, use the group that is at its vertical center. - fixedvec2 start = player->mo->_f_GetPortalTransition(player->mo->_f_height() / 2); + DVector2 start = player->mo->GetPortalTransition(player->mo->Height / 2); // [NS] Now queries the Player's UseRange. - fixedvec2 end = start + Vec2Angle(FLOAT2FIXED(player->mo->UseRange), player->mo->_f_angle()); + DVector2 end = start + player->mo->Angles.Yaw.ToVector(player->mo->UseRange); // old code: - // - // P_PathTraverse ( x1, y1, x2, y2, PT_ADDLINES, PTR_UseTraverse ); - // // This added test makes the "oof" sound work on 2s lines -- killough: - if (!P_UseTraverse(player->mo, start.x, start.y, end.x, end.y, foundline)) + if (!P_UseTraverse(player->mo, start, end, foundline)) { // [RH] Give sector a chance to eat the use sector_t *sec = player->mo->Sector; int spac = SECSPAC_Use; if (foundline) spac |= SECSPAC_UseWall; if ((!sec->SecActTarget || !sec->SecActTarget->TriggerAction(player->mo, spac)) && - P_NoWayTraverse(player->mo, start.x, start.y, end.x, end.y)) + P_NoWayTraverse(player->mo, start, end)) { S_Sound(player->mo, CHAN_VOICE, "*usefail", 1, ATTN_IDLE); } @@ -4969,23 +4948,20 @@ void P_UseLines(player_t *player) bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) { - int angle; - fixed_t x1, y1, x2, y2, usedist; - - angle = PuzzleItemUser->_f_angle() >> ANGLETOFINESHIFT; - x1 = PuzzleItemUser->_f_X(); - y1 = PuzzleItemUser->_f_Y(); + DVector2 start; + DVector2 end; + double usedist; // [NS] If it's a Player, get their UseRange. if (PuzzleItemUser->player) - usedist = FLOAT2FIXED(PuzzleItemUser->player->mo->UseRange); + usedist = PuzzleItemUser->player->mo->UseRange; else usedist = USERANGE; - x2 = x1 + FixedMul(usedist, finecosine[angle]); - y2 = y1 + FixedMul(usedist, finesine[angle]); + start = PuzzleItemUser->GetPortalTransition(PuzzleItemUser->Height / 2); + end = PuzzleItemUser->Angles.Yaw.ToVector(usedist); - FPathTraverse it(x1, y1, x2, y2, PT_ADDLINES | PT_ADDTHINGS); + FPathTraverse it(start.X, start.Y, end.X, end.Y, PT_ADDLINES | PT_ADDTHINGS); intercept_t *in; while ((in = it.Next())) @@ -4997,14 +4973,14 @@ bool P_UsePuzzleItem(AActor *PuzzleItemUser, int PuzzleItemType) { // Check line if (in->d.line->special != UsePuzzleItem) { - P_LineOpening(open, NULL, in->d.line, it._f_InterceptPoint(in)); + P_LineOpening(open, NULL, in->d.line, it.InterceptPoint(in)); if (open.range <= 0) { return false; // can't use through a wall } continue; } - if (P_PointOnLineSide(PuzzleItemUser->_f_X(), PuzzleItemUser->_f_Y(), in->d.line) == 1) + if (P_PointOnLineSide(PuzzleItemUser->Pos(), in->d.line) == 1) { // Don't use back sides return false; } diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 724ab9633..638943e2b 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -1697,7 +1697,7 @@ void FPathTraverse::init (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int fl // //=========================================================================== -int FPathTraverse::PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos) +int FPathTraverse::PortalRelocate(intercept_t *in, int flags, DVector3 *optpos) { if (!in->isaline || !in->d.line->isLinePortal()) return false; if (P_PointOnLineSidePrecise(trace.x, trace.y, in->d.line) == 1) return false; @@ -1711,8 +1711,8 @@ int FPathTraverse::PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos) P_TranslatePortalXY(in->d.line, endx, endy); if (optpos != NULL) { - P_TranslatePortalXY(in->d.line, optpos->x, optpos->y); - P_TranslatePortalZ(in->d.line, optpos->z); + P_TranslatePortalXY(in->d.line, optpos->X, optpos->Y); + P_TranslatePortalZ(in->d.line, optpos->Z); } line_t *saved = in->d.line; // this gets overwriitten by the init call. intercepts.Resize(intercept_index); diff --git a/src/p_maputl.h b/src/p_maputl.h index eee499481..c1bfc6ecd 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -432,7 +432,7 @@ public: init(FLOAT2FIXED(x1), FLOAT2FIXED(y1), FLOAT2FIXED(x2), FLOAT2FIXED(y2), flags, FLOAT2FIXED(startfrac)); } void init(fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2, int flags, fixed_t startfrac = 0); - int PortalRelocate(intercept_t *in, int flags, fixedvec3 *optpos = NULL); + int PortalRelocate(intercept_t *in, int flags, DVector3 *optpos = NULL); virtual ~FPathTraverse(); const fdivline_t &_f_Trace() const { return trace; } const divline_t &Trace() const { return ftrace; } diff --git a/src/p_spec.cpp b/src/p_spec.cpp index c51c7167e..cf3e067eb 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -198,7 +198,7 @@ bool CheckIfExitIsGood (AActor *self, level_info_t *info) // //============================================================================ -bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, fixedvec3 *optpos) +bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, DVector3 *optpos) { int lineActivation; INTBOOL repeat; @@ -259,7 +259,7 @@ bool P_ActivateLine (line_t *line, AActor *mo, int side, int activationType, fix // //============================================================================ -bool P_TestActivateLine (line_t *line, AActor *mo, int side, int activationType, fixedvec3 *optpos) +bool P_TestActivateLine (line_t *line, AActor *mo, int side, int activationType, DVector3 *optpos) { int lineActivation = line->activation; diff --git a/src/p_spec.h b/src/p_spec.h index 2d6060107..535bd2f77 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -162,8 +162,8 @@ void P_SpawnSpecials (void); void P_UpdateSpecials (void); // when needed -bool P_ActivateLine (line_t *ld, AActor *mo, int side, int activationType, fixedvec3 *optpos = NULL); -bool P_TestActivateLine (line_t *ld, AActor *mo, int side, int activationType, fixedvec3 *optpos = NULL); +bool P_ActivateLine (line_t *ld, AActor *mo, int side, int activationType, DVector3 *optpos = NULL); +bool P_TestActivateLine (line_t *ld, AActor *mo, int side, int activationType, DVector3 *optpos = NULL); bool P_PredictLine (line_t *ld, AActor *mo, int side, int activationType); void P_PlayerInSpecialSector (player_t *player, sector_t * sector=NULL); @@ -382,7 +382,7 @@ void EV_StartLightFading (int tag, int value, int tics); #define BUTTONTIME TICRATE // 1 second, in ticks. bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *quest=NULL); -bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpos = NULL); +bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *optpos = NULL); // // P_PLATS diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 962330be1..a79b7db3d 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -112,7 +112,7 @@ static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, fixed_t // //========================================================================== -bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpos) +bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *optpos) { // Activated from an empty side -> always succeed side_t *side = line->sidedef[sideno]; @@ -135,16 +135,17 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo return true; // calculate the point where the user would touch the wall. - fdivline_t dll, dlu; - fixed_t inter, checkx, checky; + divline_t dll, dlu; + double inter; + DVector2 check; P_MakeDivline (line, &dll); - fixedvec3 pos = optpos? *optpos : user->_f_PosRelative(line); - dlu.x = pos.x; - dlu.y = pos.y; - dlu.dx = finecosine[user->_f_angle() >> ANGLETOFINESHIFT]; - dlu.dy = finesine[user->_f_angle() >> ANGLETOFINESHIFT]; + DVector3 pos = optpos? *optpos : user->PosRelative(line); + dlu.x = pos.X; + dlu.y = pos.Y; + dlu.dx = user->Angles.Yaw.Cos(); + dlu.dy = user->Angles.Yaw.Sin(); inter = P_InterceptVector(&dll, &dlu); @@ -153,14 +154,14 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo { // Get a check point slightly inside the polyobject so that this still works // if the polyobject lies directly on a sector boundary - checkx = dll.x + FixedMul(dll.dx, inter + (FRACUNIT/100)); - checky = dll.y + FixedMul(dll.dy, inter + (FRACUNIT/100)); - front = P_PointInSector(checkx, checky); + check.X = dll.x + dll.dx * (inter + 0.01); + check.Y = dll.y + dll.dy * (inter + 0.01); + front = P_PointInSector(check); } else { - checkx = dll.x + FixedMul(dll.dx, inter); - checky = dll.y + FixedMul(dll.dy, inter); + check.X = dll.x + dll.dx * inter; + check.Y = dll.y + dll.dy * inter; } @@ -168,13 +169,13 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo if (line->sidedef[1] == NULL || (line->sidedef[0]->Flags & WALLF_POLYOBJ)) { onesided: - fixed_t sectorc = front->ceilingplane.ZatPoint(checkx, checky); - fixed_t sectorf = front->floorplane.ZatPoint(checkx, checky); - return (user->_f_Top() >= sectorf && user->_f_Z() <= sectorc); + double sectorc = front->ceilingplane.ZatPoint(check); + double sectorf = front->floorplane.ZatPoint(check); + return (user->Top() >= sectorf && user->Z() <= sectorc); } // Now get the information from the line. - P_LineOpening(open, NULL, line, checkx, checky, pos.x, pos.y); + P_LineOpening(open, NULL, line, check, &pos); if (open.range <= 0) goto onesided; @@ -190,8 +191,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_UPPERTEXTURE)) continue; - if (user->_f_Z() > rover->top.plane->ZatPoint(checkx, checky) || - user->_f_Top() < rover->bottom.plane->ZatPoint(checkx, checky)) + if (user->Z() > rover->top.plane->ZatPoint(check) || + user->Top() < rover->bottom.plane->ZatPoint(check)) continue; // This 3D floor depicts a switch texture in front of the player's eyes @@ -212,8 +213,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, fixedvec3 *optpo if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_LOWERTEXTURE)) continue; - if (user->_f_Z() > rover->top.plane->ZatPoint(checkx, checky) || - user->_f_Top() < rover->bottom.plane->ZatPoint(checkx, checky)) + if (user->Z() > rover->top.plane->ZatPoint(check) || + user->Top() < rover->bottom.plane->ZatPoint(check)) continue; // This 3D floor depicts a switch texture in front of the player's eyes diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 4340d13d5..8b5369f20 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -355,7 +355,7 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f // Rotate 90 degrees, so that walking perpendicularly across // teleporter linedef causes thing to exit in the direction // indicated by the exit thing. - angle = VecToAngle(line->dx, line->dy) - searcher->Angles.Yaw + 90; + angle = line->Delta().Angle() - searcher->Angles.Yaw + 90.; // Sine, cosine of angle adjustment s = angle.Sin(); @@ -457,7 +457,7 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO // Get the angle between the two linedefs, for rotating // orientation and velocity. Rotate 180 degrees, and flip // the position across the exit linedef, if reversed. - DAngle angle = VecToAngle(l->Delta()) - VecToAngle(line->Delta()); + DAngle angle = l->Delta().Angle() - line->Delta().Angle(); if (!reverse) { diff --git a/src/p_trace.cpp b/src/p_trace.cpp index 9ac0f29ca..65a95d185 100644 --- a/src/p_trace.cpp +++ b/src/p_trace.cpp @@ -96,7 +96,7 @@ struct FTraceInfo { Results->SrcFromTarget = { FIXED2DBL(StartX), FIXED2DBL(StartY), FIXED2DBL(StartZ) }; Results->HitVector = { FIXED2DBL(Vx), FIXED2DBL(Vy), FIXED2DBL(Vz) }; - Results->SrcAngleFromTarget = VecToAngle(Results->HitVector); + Results->SrcAngleFromTarget = Results->HitVector.Angle(); } @@ -241,7 +241,6 @@ void FTraceInfo::EnterSectorPortal(int position, fixed_t frac, sector_t *enterse //============================================================================ // // traverses a line portal -// simply calling PortalRelocate does not work here because more needs to be set up // //============================================================================ From fe744a589c7301c2d38dd29460756e99a7dd3cd9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Mar 2016 21:11:17 +0200 Subject: [PATCH 27/44] - floatified P_RadiusAttack. --- src/p_map.cpp | 40 +++++++++++++++++++--------------------- 1 file changed, 19 insertions(+), 21 deletions(-) diff --git a/src/p_map.cpp b/src/p_map.cpp index 0a3d1bd31..e57e037f5 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -5043,13 +5043,12 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo if (bombdistance <= 0) return; fulldamagedistance = clamp(fulldamagedistance, 0, bombdistance - 1); - fixed_t bombdistfix = bombdistance << FRACBITS; - double bombdistancefloat = 1.f / (double)(bombdistance - fulldamagedistance); + double bombdistancefloat = 1. / (double)(bombdistance - fulldamagedistance); double bombdamagefloat = (double)bombdamage; FPortalGroupArray grouplist(FPortalGroupArray::PGA_Full3d); - FMultiBlockThingsIterator it(grouplist, bombspot->_f_X(), bombspot->_f_Y(), bombspot->_f_Z() - bombdistfix, bombspot->_f_height() + bombdistfix*2, bombdistfix, false, bombspot->Sector); + FMultiBlockThingsIterator it(grouplist, bombspot->X(), bombspot->Y(), bombspot->Z() - bombdistance, bombspot->Height + bombdistance*2, bombdistancefloat, false, bombspot->Sector); FMultiBlockThingsIterator::CheckResult cres; if (flags & RADF_SOURCEISSPOT) @@ -5096,28 +5095,28 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo // height of the thing and not the height of the map. double points; double len; - fixed_t dx, dy; + double dx, dy; double boxradius; - fixedvec2 vec = bombspot->_f_Vec2To(thing); - dx = abs(vec.x); - dy = abs(vec.y); - boxradius = double(thing->_f_radius()); + DVector2 vec = bombspot->Vec2To(thing); + dx = fabs(vec.X); + dy = fabs(vec.Y); + boxradius = thing->radius; // The damage pattern is square, not circular. len = double(dx > dy ? dx : dy); - if (bombspot->_f_Z() < thing->_f_Z() || bombspot->_f_Z() >= thing->_f_Top()) + if (bombspot->Z() < thing->Z() || bombspot->Z() >= thing->Top()) { double dz; - if (bombspot->_f_Z() > thing->_f_Z()) + if (bombspot->Z() > thing->Z()) { - dz = double(bombspot->_f_Z() - thing->_f_Top()); + dz = double(bombspot->Z() - thing->Top()); } else { - dz = double(thing->_f_Z() - bombspot->_f_Z()); + dz = double(thing->Z() - bombspot->Z()); } if (len <= boxradius) { @@ -5135,9 +5134,8 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo if (len < 0.f) len = 0.f; } - len /= FRACUNIT; len = clamp(len - (double)fulldamagedistance, 0, len); - points = bombdamagefloat * (1.f - len * bombdistancefloat); + points = bombdamagefloat * (1. - len * bombdistancefloat); if (thing == bombsource) { points = points * splashfactor; @@ -5195,14 +5193,14 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo else { // [RH] Old code just for barrels - fixed_t dx, dy, dist; + double dx, dy, dist; - fixedvec2 vec = bombspot->_f_Vec2To(thing); - dx = abs(vec.x); - dy = abs(vec.y); + DVector2 vec = bombspot->Vec2To(thing); + dx = fabs(vec.X); + dy = fabs(vec.Y); dist = dx>dy ? dx : dy; - dist = (dist - thing->_f_radius()) >> FRACBITS; + dist -= thing->radius; if (dist < 0) dist = 0; @@ -5212,8 +5210,8 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo if (P_CheckSight(thing, bombspot, SF_IGNOREVISIBILITY | SF_IGNOREWATERBOUNDARY)) { // OK to damage; target is in direct path - dist = clamp(dist - fulldamagedistance, 0, dist); - int damage = Scale(bombdamage, bombdistance - dist, bombdistance); + dist = clamp(dist - fulldamagedistance, 0, dist); + int damage = Scale(bombdamage, bombdistance - int(dist), bombdistance); double factor = splashfactor * thing->GetClass()->RDFactor; damage = int(damage * factor); From 8b4a33794ad43dc8e9ffd8ad254a72fbd315c90b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Mar 2016 22:35:58 +0200 Subject: [PATCH 28/44] - floatified P_ChangeSector. --- src/p_local.h | 8 +++-- src/p_map.cpp | 80 +++++++++++++++++++++++--------------------------- src/p_mobj.cpp | 5 ++-- src/p_user.cpp | 2 +- 4 files changed, 46 insertions(+), 49 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 1b19029fd..b5793d835 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -197,7 +197,7 @@ AActor *P_SpawnPlayerMissile (AActor *source, double x, double y, double z, PCla FTranslatedLineTarget *pLineTarget = NULL, AActor **MissileActor = NULL, bool nofreeaim = false, bool noautoaim = false, int aimflags = 0); -void P_CheckFakeFloorTriggers (AActor *mo, fixed_t oldz, bool oldz_has_viewheight=false); +void P_CheckFakeFloorTriggers(AActor *mo, double oldz, bool oldz_has_viewheight = false); AActor *P_SpawnSubMissile (AActor *source, PClassActor *type, AActor *target); // Strife uses it @@ -336,7 +336,11 @@ enum }; void P_FindFloorCeiling (AActor *actor, int flags=0); -bool P_ChangeSector (sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset); +bool P_ChangeSector (sector_t* sector, int crunch, double amt, int floorOrCeil, bool isreset); +inline bool P_ChangeSector(sector_t* sector, int crunch, int amt, int floorOrCeil, bool isreset) +{ + return P_ChangeSector(sector, crunch, FIXED2DBL(amt), floorOrCeil, isreset); +} DAngle P_AimLineAttack(AActor *t1, DAngle angle, double distance, FTranslatedLineTarget *pLineTarget = NULL, DAngle vrange = 0., int flags = 0, AActor *target = NULL, AActor *friender = NULL); diff --git a/src/p_map.cpp b/src/p_map.cpp index e57e037f5..ee3d443e8 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -5250,7 +5250,7 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo struct FChangePosition { sector_t *sector; - int moveamt; + double moveamt; int crushchange; bool nofit; bool movemidtex; @@ -5320,8 +5320,8 @@ void P_FindAboveIntersectors(AActor *actor) while (it.Next(&cres)) { AActor *thing = cres.thing; - fixed_t blockdist = actor->_f_radius() + thing->_f_radius(); - if (abs(thing->_f_X() - cres.position.x) >= blockdist || abs(thing->_f_Y() - cres.position.y) >= blockdist) + double blockdist = actor->radius + thing->radius; + if (fabs(thing->X() - cres.Position.X) >= blockdist || fabs(thing->Y() - cres.Position.Y) >= blockdist) continue; if (!(thing->flags & MF_SOLID)) @@ -5376,8 +5376,8 @@ void P_FindBelowIntersectors(AActor *actor) while (it.Next(&cres)) { AActor *thing = cres.thing; - fixed_t blockdist = actor->_f_radius() + thing->_f_radius(); - if (abs(thing->_f_X() - cres.position.x) >= blockdist || abs(thing->_f_Y() - cres.position.y) >= blockdist) + double blockdist = actor->radius + thing->radius; + if (fabs(thing->X() - cres.Position.X) >= blockdist || fabs(thing->Y() - cres.Position.Y) >= blockdist) continue; if (!(thing->flags & MF_SOLID)) @@ -5511,14 +5511,13 @@ int P_PushUp(AActor *thing, FChangePosition *cpos) // Can't push bridges or things more massive than ourself return 2; } - fixed_t oldz; - oldz = intersect->_f_Z(); + double oldz = intersect->Z(); P_AdjustFloorCeil(intersect, cpos); - intersect->_f_SetZ(thing->_f_Top() + 1); + intersect->SetZ(thing->Top() + 1/65536.); if (P_PushUp(intersect, cpos)) { // Move blocked P_DoCrunch(intersect, cpos); - intersect->_f_SetZ(oldz); + intersect->SetZ(oldz); return 2; } } @@ -5557,15 +5556,15 @@ int P_PushDown(AActor *thing, FChangePosition *cpos) // Can't push bridges or things more massive than ourself return 2; } - fixed_t oldz = intersect->_f_Z(); + double oldz = intersect->Z(); P_AdjustFloorCeil(intersect, cpos); - if (oldz > thing->_f_Z() - intersect->_f_height()) + if (oldz > thing->Z() - intersect->Height) { // Only push things down, not up. - intersect->_f_SetZ(thing->_f_Z() - intersect->_f_height()); + intersect->SetZ(thing->Z() - intersect->Height); if (P_PushDown(intersect, cpos)) { // Move blocked P_DoCrunch(intersect, cpos); - intersect->_f_SetZ(oldz); + intersect->SetZ(oldz); return 2; } } @@ -5582,40 +5581,37 @@ int P_PushDown(AActor *thing, FChangePosition *cpos) void PIT_FloorDrop(AActor *thing, FChangePosition *cpos) { - fixed_t oldfloorz = thing->_f_floorz(); - fixed_t oldz = thing->_f_Z(); + double oldfloorz = thing->floorz; + double oldz = thing->Z(); P_AdjustFloorCeil(thing, cpos); - if (oldfloorz == thing->_f_floorz()) return; + if (oldfloorz == thing->floorz) return; if (thing->flags4 & MF4_ACTLIKEBRIDGE) return; // do not move bridge things - if (thing->_f_velz() == 0 && + if (thing->Vel.Z == 0 && (!(thing->flags & MF_NOGRAVITY) || - (thing->_f_Z() == oldfloorz && !(thing->flags & MF_NOLIFTDROP)))) + (thing->Z() == oldfloorz && !(thing->flags & MF_NOLIFTDROP)))) { - fixed_t oldz = thing->_f_Z(); - if ((thing->flags & MF_NOGRAVITY) || (thing->flags5 & MF5_MOVEWITHSECTOR) || - (((cpos->sector->Flags & SECF_FLOORDROP) || cpos->moveamt < 9 * FRACUNIT) - && thing->_f_Z() - thing->_f_floorz() <= cpos->moveamt)) + (((cpos->sector->Flags & SECF_FLOORDROP) || cpos->moveamt < 9) + && thing->Z() - thing->floorz <= cpos->moveamt)) { thing->SetZ(thing->floorz); P_CheckFakeFloorTriggers(thing, oldz); } } - else if ((thing->_f_Z() != oldfloorz && !(thing->flags & MF_NOLIFTDROP))) + else if ((thing->Z() != oldfloorz && !(thing->flags & MF_NOLIFTDROP))) { - fixed_t oldz = thing->_f_Z(); if ((thing->flags & MF_NOGRAVITY) && (thing->flags6 & MF6_RELATIVETOFLOOR)) { - thing->_f_AddZ(-oldfloorz + thing->_f_floorz()); + thing->AddZ(-oldfloorz + thing->floorz); P_CheckFakeFloorTriggers(thing, oldz); } } if (thing->player && thing->player->mo == thing) { - //thing->player->viewz += thing->_f_Z() - oldz; + thing->player->viewz += thing->Z() - oldz; } } @@ -5627,12 +5623,12 @@ void PIT_FloorDrop(AActor *thing, FChangePosition *cpos) void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) { - fixed_t oldfloorz = thing->_f_floorz(); - fixed_t oldz = thing->_f_Z(); + double oldfloorz = thing->floorz; + double oldz = thing->Z(); P_AdjustFloorCeil(thing, cpos); - if (oldfloorz == thing->_f_floorz()) return; + if (oldfloorz == thing->floorz) return; // Move things intersecting the floor up if (thing->Z() <= thing->floorz) @@ -5650,7 +5646,7 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) if ((thing->flags & MF_NOGRAVITY) && (thing->flags6 & MF6_RELATIVETOFLOOR)) { intersectors.Clear(); - thing->_f_AddZ(-oldfloorz + thing->_f_floorz()); + thing->AddZ(-oldfloorz + thing->floorz); } else return; } @@ -5665,12 +5661,12 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) break; case 2: P_DoCrunch(thing, cpos); - thing->_f_SetZ(oldz); + thing->SetZ(oldz); break; } if (thing->player && thing->player->mo == thing) { - thing->player->viewz += thing->Z() - FIXED2DBL(oldz); + thing->player->viewz += thing->Z() - oldz; } } @@ -5683,7 +5679,7 @@ void PIT_FloorRaise(AActor *thing, FChangePosition *cpos) void PIT_CeilingLower(AActor *thing, FChangePosition *cpos) { bool onfloor; - fixed_t oldz = thing->_f_Z(); + double oldz = thing->Z(); onfloor = thing->Z() <= thing->floorz; P_AdjustFloorCeil(thing, cpos); @@ -5696,7 +5692,6 @@ void PIT_CeilingLower(AActor *thing, FChangePosition *cpos) return; // do not move bridge things } intersectors.Clear(); - fixed_t oldz = thing->_f_Z(); if (thing->ceilingz - thing->Height >= thing->floorz) { thing->SetZ(thing->ceilingz - thing->Height); @@ -5722,7 +5717,7 @@ void PIT_CeilingLower(AActor *thing, FChangePosition *cpos) } if (thing->player && thing->player->mo == thing) { - thing->player->viewz += thing->Z() - FIXED2DBL(oldz); + thing->player->viewz += thing->Z() - oldz; } } @@ -5735,18 +5730,17 @@ void PIT_CeilingLower(AActor *thing, FChangePosition *cpos) void PIT_CeilingRaise(AActor *thing, FChangePosition *cpos) { bool isgood = P_AdjustFloorCeil(thing, cpos); - fixed_t oldz = thing->_f_Z(); + double oldz = thing->Z(); if (thing->flags4 & MF4_ACTLIKEBRIDGE) return; // do not move bridge things // For DOOM compatibility, only move things that are inside the floor. // (or something else?) Things marked as hanging from the ceiling will // stay where they are. - if (thing->_f_Z() < thing->_f_floorz() && - thing->_f_Top() >= thing->_f_ceilingz() - cpos->moveamt && + if (thing->Z() < thing->floorz && + thing->Top() >= thing->ceilingz - cpos->moveamt && !(thing->flags & MF_NOLIFTDROP)) { - fixed_t oldz = thing->_f_Z(); thing->SetZ(thing->floorz); if (thing->Top() > thing->ceilingz) { @@ -5764,7 +5758,7 @@ void PIT_CeilingRaise(AActor *thing, FChangePosition *cpos) } if (thing->player && thing->player->mo == thing) { - thing->player->viewz += thing->Z() - FIXED2DBL(oldz); + thing->player->viewz += thing->Z() - oldz; } } @@ -5778,7 +5772,7 @@ void PIT_CeilingRaise(AActor *thing, FChangePosition *cpos) // //============================================================================= -bool P_ChangeSector(sector_t *sector, int crunch, int amt, int floorOrCeil, bool isreset) +bool P_ChangeSector(sector_t *sector, int crunch, double amt, int floorOrCeil, bool isreset) { FChangePosition cpos; void(*iterator)(AActor *, FChangePosition *); @@ -5787,7 +5781,7 @@ bool P_ChangeSector(sector_t *sector, int crunch, int amt, int floorOrCeil, bool cpos.nofit = false; cpos.crushchange = crunch; - cpos.moveamt = abs(amt); + cpos.moveamt = fabs(amt); cpos.movemidtex = false; cpos.sector = sector; @@ -5924,7 +5918,7 @@ bool P_ChangeSector(sector_t *sector, int crunch, int amt, int floorOrCeil, bool n->visited = true; // mark thing as processed n->m_thing->UpdateWaterLevel(false); - P_CheckFakeFloorTriggers(n->m_thing, n->m_thing->_f_Z() - amt); + P_CheckFakeFloorTriggers(n->m_thing, n->m_thing->Z() - amt); } } } while (n); // repeat from scratch until all things left are marked valid diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 84a6ee1dc..0be882191 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -2619,12 +2619,11 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) } } } - P_CheckFakeFloorTriggers (mo, oldz); + P_CheckFakeFloorTriggers (mo, FIXED2DBL(oldz)); } -void P_CheckFakeFloorTriggers (AActor *mo, fixed_t _oldz, bool oldz_has_viewheight) +void P_CheckFakeFloorTriggers (AActor *mo, double oldz, bool oldz_has_viewheight) { - double oldz = FIXED2FLOAT(_oldz); if (mo->player && (mo->player->cheats & CF_PREDICTING)) { return; diff --git a/src/p_user.cpp b/src/p_user.cpp index 185ce8b5b..2ad92a968 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2268,7 +2268,7 @@ void P_CrouchMove(player_t * player, int direction) player->crouchviewdelta = player->viewheight - player->mo->ViewHeight; // Check for eyes going above/below fake floor due to crouching motion. - P_CheckFakeFloorTriggers(player->mo, player->mo->_f_Z() + FLOAT2FIXED(oldheight), true); + P_CheckFakeFloorTriggers(player->mo, player->mo->Z() + oldheight, true); } //---------------------------------------------------------------------------- From 7b256dda3d5b6ce85b5e4f25cc48a905816abcd8 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 27 Mar 2016 22:49:59 +0200 Subject: [PATCH 29/44] - did the last remaining bits in p_map.cpp. --- src/p_local.h | 2 +- src/p_map.cpp | 30 ++++++++++++------------------ src/p_maputl.cpp | 2 +- 3 files changed, 14 insertions(+), 20 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index b5793d835..8729ada1a 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -432,7 +432,7 @@ void P_RadiusAttack (AActor *spot, AActor *source, int damage, int distance, void P_DelSector_List(); void P_DelSeclist(msecnode_t *); // phares 3/16/98 msecnode_t* P_DelSecnode(msecnode_t *); -void P_CreateSecNodeList(AActor*,fixed_t,fixed_t); // phares 3/14/98 +void P_CreateSecNodeList(AActor*); // phares 3/14/98 double P_GetMoveFactor(const AActor *mo, double *frictionp); // phares 3/6/98 double P_GetFriction(const AActor *mo, double *frictionfactor); bool Check_Sides(AActor *, int, int); // phares diff --git a/src/p_map.cpp b/src/p_map.cpp index ee3d443e8..6c3f965ab 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -678,7 +678,7 @@ static int LineIsBelow(line_t *line, AActor *actor) // // // PIT_CheckLine -// Adjusts tmfloorz and tm_f_ceilingz() as lines are contacted +// Adjusts tmfloorz and tmceilingz as lines are contacted // // //========================================================================== @@ -2593,7 +2593,7 @@ void FSlide::HitSlideLine(line_t* ld) moveangle = tmmove.Angle(); // prevents sudden path reversal due to rounding error | // phares - moveangle += 3600/65536.*65536.; // Boom added 10 to the angle_t here. + moveangle += 3600/65536.*65536.; // Boom added 10 to the angle here. deltaangle = ::deltaangle(lineangle, moveangle); // V movelen = tmmove.Length(); @@ -2820,7 +2820,7 @@ retry: } // fudge a bit to make sure it doesn't hit - bestSlidefrac -= FRACUNIT / 32; + bestSlidefrac -= 1. / 32; if (bestSlidefrac > 0) { newpos = tryp * bestSlidefrac; @@ -3037,13 +3037,13 @@ bool FSlide::BounceTraverse(const DVector2 &start, const DVector2 &end) } if (!(li->flags&ML_TWOSIDED) || !li->backsector) { - if (P_PointOnLineSide(slidemo->_f_X(), slidemo->_f_Y(), li)) + if (P_PointOnLineSide(slidemo->Pos(), li)) continue; // don't hit the back side goto bounceblocking; } - P_LineOpening(open, slidemo, li, it._f_InterceptPoint(in)); // set openrange, opentop, openbottom + P_LineOpening(open, slidemo, li, it.InterceptPoint(in)); // set openrange, opentop, openbottom if (open.range < slidemo->Height) goto bounceblocking; // doesn't fit @@ -3215,7 +3215,7 @@ bool P_BounceActor(AActor *mo, AActor *BlockingMobj, bool ontop) { DAngle angle = BlockingMobj->AngleTo(mo) + ((pr_bounce() % 16) - 8); double speed = mo->VelXYToSpeed() * mo->wallbouncefactor; // [GZ] was 0.75, using wallbouncefactor seems more consistent - mo->Angles.Yaw = ANGLE2DBL(angle); + mo->Angles.Yaw = angle; mo->VelFromAngle(speed); mo->PlayBounceSound(true); if (mo->BounceFlags & BOUNCE_UseBounceState) @@ -4366,7 +4366,7 @@ void P_TraceBleed(int damage, const DVector3 &pos, AActor *actor, DAngle angle, double cosp = bleedpitch.Cos(); DVector3 vdir = DVector3(cosp * bleedang.Cos(), cosp * bleedang.Sin(), -bleedpitch.Sin()); - if (Trace(pos, actor->Sector, vdir, 172 * FRACUNIT, 0, ML_BLOCKEVERYTHING, actor, bleedtrace, TRACE_NoSky)) + if (Trace(pos, actor->Sector, vdir, 172, 0, ML_BLOCKEVERYTHING, actor, bleedtrace, TRACE_NoSky)) { if (bleedtrace.HitType == TRACE_HitWall) { @@ -4619,7 +4619,7 @@ void P_RailAttack(FRailParams *p) if (bleed) { P_SpawnBlood(hitpos, hitangle, newdam > 0 ? newdam : p->damage, hitactor); - P_TraceBleed(newdam > 0 ? newdam : p->damage, hitpos, hitactor, hitangle, ANGLE2DBL(pitch)); + P_TraceBleed(newdam > 0 ? newdam : p->damage, hitpos, hitactor, hitangle, pitch); } } @@ -5059,7 +5059,7 @@ void P_RadiusAttack(AActor *bombspot, AActor *bombsource, int bombdamage, int bo while ((it.Next(&cres))) { AActor *thing = cres.thing; - // Vulnerable actors can be damaged by _f_radius() attacks even if not shootable + // Vulnerable actors can be damaged by radius attacks even if not shootable // Used to emulate MBF's vulnerability of non-missile bouncers to explosions. if (!((thing->flags & MF_SHOOTABLE) || (thing->flags6 & MF6_VULNERABLE))) continue; @@ -6122,7 +6122,7 @@ void P_DelSeclist(msecnode_t *node) // //============================================================================= -void P_CreateSecNodeList(AActor *thing, fixed_t x, fixed_t y) +void P_CreateSecNodeList(AActor *thing) { msecnode_t *node; @@ -6138,19 +6138,13 @@ void P_CreateSecNodeList(AActor *thing, fixed_t x, fixed_t y) node = node->m_tnext; } - FBoundingBox box(thing->_f_X(), thing->_f_Y(), thing->_f_radius()); + FBoundingBox box(thing->X(), thing->Y(), thing->radius); FBlockLinesIterator it(box); line_t *ld; while ((ld = it.Next())) { - if (box.Right() <= ld->bbox[BOXLEFT] || - box.Left() >= ld->bbox[BOXRIGHT] || - box.Top() <= ld->bbox[BOXBOTTOM] || - box.Bottom() >= ld->bbox[BOXTOP]) - continue; - - if (box.BoxOnLineSide(ld) != -1) + if (!box.inRange(ld) || box.BoxOnLineSide(ld) != -1) continue; // This line crosses through the object. diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index 638943e2b..d58ecd975 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -505,7 +505,7 @@ void AActor::LinkToWorld(bool spawningmapthing, sector_t *sector) // When a node is deleted, its sector links (the links starting // at sector_t->touching_thinglist) are broken. When a node is // added, new sector links are created. - P_CreateSecNodeList(this, _f_X(), _f_Y()); + P_CreateSecNodeList(this); touching_sectorlist = sector_list; // Attach to thing sector_list = NULL; // clear for next time } From 217414cb1c2e1c40e97bd644f8947b9bd80ad0c9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Mar 2016 00:55:57 +0200 Subject: [PATCH 30/44] -floatified P_ExplodeMissile and P_XYMovement --- src/p_local.h | 1 - src/p_mobj.cpp | 197 ++++++++++++++++++++----------------------------- src/vectors.h | 5 ++ 3 files changed, 85 insertions(+), 118 deletions(-) diff --git a/src/p_local.h b/src/p_local.h index 8729ada1a..bb7042f3f 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -84,7 +84,6 @@ inline int GetSafeBlockY(long long blocky) } //#define GRAVITY FRACUNIT -#define _f_MAXMOVE (30*FRACUNIT) #define MAXMOVE (30.) #define TALKRANGE (128.) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 0be882191..140736865 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1,5 +1,4 @@ // Emacs style mode select -*- C++ -*- -// Emacs style mode select -*- C++ -*- //----------------------------------------------------------------------------- // // $Id:$ @@ -1386,8 +1385,8 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) if (line != NULL && cl_missiledecals) { - fixedvec3 pos = mo->_f_PosRelative(line); - int side = P_PointOnLineSidePrecise (pos.x, pos.y, line); + DVector3 pos = mo->PosRelative(line); + int side = P_PointOnLineSidePrecise (pos, line); if (line->sidedef[side] == NULL) side ^= 1; if (line->sidedef[side] != NULL) @@ -1396,31 +1395,15 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) if (base != NULL) { // Find the nearest point on the line, and stick a decal there - fixed_t x, y, z; - SQWORD num, den; + DVector3 linepos; + double num, den, frac; - den = (SQWORD)line->dx*line->dx + (SQWORD)line->dy*line->dy; + den = line->Delta().LengthSquared(); if (den != 0) { - SDWORD frac; + frac = clamp((mo->Pos() - line->v1->fPos()) | line->Delta(), 0, den) / den; - num = (SQWORD)(pos.x-line->v1->x)*line->dx+(SQWORD)(pos.y-line->v1->y)*line->dy; - if (num <= 0) - { - frac = 0; - } - else if (num >= den) - { - frac = 1<<30; - } - else - { - frac = (SDWORD)(num / (den>>30)); - } - - x = line->v1->x + MulScale30 (line->dx, frac); - y = line->v1->y + MulScale30 (line->dy, frac); - z = pos.z; + linepos = DVector3(line->v1->fPos() + line->Delta() * frac, pos.Z); F3DFloor * ffloor=NULL; if (line->sidedef[side^1] != NULL) @@ -1434,16 +1417,16 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) if ((rover->flags&(FF_EXISTS|FF_SOLID|FF_RENDERSIDES))==(FF_EXISTS|FF_SOLID|FF_RENDERSIDES)) { - if (z<=rover->top.plane->ZatPoint(x, y) && z>=rover->bottom.plane->ZatPoint( x, y)) + if (pos.Z <= rover->top.plane->ZatPoint(linepos) && pos.Z >= rover->bottom.plane->ZatPoint(linepos)) { - ffloor=rover; + ffloor = rover; break; } } } } - DImpactDecal::StaticCreate(base->GetDecal(), DVector3(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)), line->sidedef[side], ffloor); + DImpactDecal::StaticCreate(base->GetDecal(), linepos, line->sidedef[side], ffloor); } } } @@ -1529,7 +1512,7 @@ void AActor::PlayBounceSound(bool onfloor) bool AActor::FloorBounceMissile (secplane_t &plane) { - if (_f_Z() <= _f_floorz() && P_HitFloor (this)) + if (Z() <= floorz && P_HitFloor (this)) { // Landed in some sort of liquid if (BounceFlags & BOUNCE_ExplodeOnWater) @@ -1760,22 +1743,22 @@ bool P_SeekerMissile (AActor *actor, double thresh, double turnMax, bool precise // Returns the actor's old floorz. // #define STOPSPEED (0x1000/65536.) -#define CARRYSTOPSPEED (0x1000*32/3) +#define CARRYSTOPSPEED ((0x1000*32/3)/65536.) -fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) +double P_XYMovement (AActor *mo, DVector2 scroll) { static int pushtime = 0; - bool bForceSlide = scrollx || scrolly; + bool bForceSlide = !scroll.isZero(); DAngle Angle; - fixed_t ptryx, ptryy; + DVector2 ptry; player_t *player; - fixed_t xmove, ymove; + DVector2 move; const secplane_t * walkplane; static const double windTab[3] = { 5 / 32., 10 / 32., 25 / 32. }; int steps, step, totalsteps; - fixed_t startx, starty; - fixed_t oldfloorz = mo->_f_floorz(); - fixed_t oldz = mo->_f_Z(); + DVector2 start; + double Oldfloorz = mo->floorz; + double oldz = mo->Z(); double maxmove = (mo->waterlevel < 1) || (mo->flags & MF_MISSILE) || (mo->player && mo->player->crouchoffset<-10) ? MAXMOVE : MAXMOVE/4; @@ -1815,29 +1798,27 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) mo->Vel.X *= fac; mo->Vel.Y *= fac; } - xmove = mo->_f_velx(); - ymove = mo->_f_vely(); + move = mo->Vel; // [RH] Carrying sectors didn't work with low speeds in BOOM. This is // because BOOM relied on the speed being fast enough to accumulate // despite friction. If the speed is too low, then its movement will get // cancelled, and it won't accumulate to the desired speed. mo->flags4 &= ~MF4_SCROLLMOVE; - if (abs(scrollx) > CARRYSTOPSPEED) + if (fabs(scroll.X) > CARRYSTOPSPEED) { - scrollx = FixedMul (scrollx, _f_CARRYFACTOR); - mo->Vel.X += FIXED2DBL(scrollx); + scroll.X *= CARRYFACTOR; + mo->Vel.X += scroll.X; mo->flags4 |= MF4_SCROLLMOVE; } - if (abs(scrolly) > CARRYSTOPSPEED) + if (fabs(scroll.Y) > CARRYSTOPSPEED) { - scrolly = FixedMul (scrolly, _f_CARRYFACTOR); - mo->Vel.Y += FIXED2DBL(scrolly); + scroll.Y *= CARRYFACTOR; + mo->Vel.Y += scroll.Y; mo->flags4 |= MF4_SCROLLMOVE; } - xmove += scrollx; - ymove += scrolly; + move += scroll; - if ((xmove | ymove) == 0) + if (move.isZero()) { if (mo->flags & MF_SKULLFLY) { @@ -1855,15 +1836,14 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) mo->tics = -1; } } - return oldfloorz; + return Oldfloorz; } player = mo->player; // [RH] Adjust player movement on sloped floors - fixed_t startxmove = xmove; - fixed_t startymove = ymove; - walkplane = P_CheckSlopeWalk (mo, xmove, ymove); + DVector2 startmove = move; + walkplane = P_CheckSlopeWalk (mo, move); // [RH] Take smaller steps when moving faster than the object's size permits. // Moving as fast as the object's "diameter" is bad because it could skip @@ -1872,15 +1852,15 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) // through the actor. { - fixed_t maxmove = mo->_f_radius() - FRACUNIT; + double maxmove = mo->radius - 1; if (maxmove <= 0) - { // gibs can have _f_radius() 0, so don't divide by zero below! - maxmove = _f_MAXMOVE; + { // gibs can have radius 0, so don't divide by zero below! + maxmove = MAXMOVE; } - const fixed_t xspeed = abs (xmove); - const fixed_t yspeed = abs (ymove); + const double xspeed = fabs (move.X); + const double yspeed = fabs (move.Y); steps = 1; @@ -1888,25 +1868,23 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { if (xspeed > maxmove) { - steps = 1 + xspeed / maxmove; + steps = int(1 + xspeed / maxmove); } } else { if (yspeed > maxmove) { - steps = 1 + yspeed / maxmove; + steps = int(1 + yspeed / maxmove); } } } // P_SlideMove needs to know the step size before P_CheckSlopeWalk // because it also calls P_CheckSlopeWalk on its clipped steps. - fixed_t onestepx = startxmove / steps; - fixed_t onestepy = startymove / steps; + DVector2 onestep = startmove / steps; - startx = mo->_f_X(); - starty = mo->_f_Y(); + start = mo->Pos(); step = 1; totalsteps = steps; @@ -1923,23 +1901,19 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) FCheckPosition tm(!!(mo->flags2 & MF2_RIP)); - angle_t oldangle = mo->_f_angle(); + DAngle oldangle = mo->Angles.Yaw; do { if (i_compatflags & COMPATF_WALLRUN) pushtime++; tm.PushTime = pushtime; - ptryx = startx + Scale (xmove, step, steps); - ptryy = starty + Scale (ymove, step, steps); + ptry = start + move * step / steps; + + DVector2 startvel = mo->Vel; -/* if (mo->player) - Printf ("%d,%d/%d: %d %d %d %d %d %d %d\n", level.time, step, steps, startxmove, Scale(xmove,step,steps), startymove, Scale(ymove,step,steps), mo->x, mo->y, mo->z); -*/ - // [RH] If walking on a slope, stay on the slope // killough 3/15/98: Allow objects to drop off - fixed_t startvelx = mo->_f_velx(), startvely = mo->_f_vely(); - - if (!P_TryMove (mo, DVector2(FIXED2DBL(ptryx), FIXED2DBL(ptryy)), true, walkplane, tm)) + // [RH] If walking on a slope, stay on the slope + if (!P_TryMove (mo, ptry, true, walkplane, tm)) { // blocked move AActor *BlockingMobj = mo->BlockingMobj; @@ -1964,7 +1938,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) } // If the blocked move executed any push specials that changed the // actor's velocity, do not attempt to slide. - if (mo->_f_velx() == startvelx && mo->_f_vely() == startvely) + if (mo->Vel.XY() == startvel) { if (player && (i_compatflags & COMPATF_WALLRUN)) { @@ -1976,9 +1950,9 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) } else { - P_SlideMove (mo, DVector2(FIXED2DBL(onestepx), FIXED2DBL(onestepy)), totalsteps); + P_SlideMove (mo, onestep, totalsteps); } - if ((mo->_f_velx() | mo->_f_vely()) == 0) + if (mo->Vel.XY().isZero()) { steps = 0; } @@ -1986,14 +1960,11 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { if (!player || !(i_compatflags & COMPATF_WALLRUN)) { - xmove = mo->_f_velx(); - ymove = mo->_f_vely(); - onestepx = xmove / steps; - onestepy = ymove / steps; - P_CheckSlopeWalk (mo, xmove, ymove); + move = mo->Vel; + onestep = move / steps; + P_CheckSlopeWalk (mo, move); } - startx = mo->_f_X() - Scale (xmove, step, steps); - starty = mo->_f_Y() - Scale (ymove, step, steps); + start = mo->Pos().XY() - move * step / steps; } } else @@ -2003,18 +1974,18 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) } else { // slide against another actor - fixed_t tx, ty; - tx = 0, ty = onestepy; - walkplane = P_CheckSlopeWalk (mo, tx, ty); - if (P_TryMove (mo, mo->Pos() + DVector2(FIXED2DBL(tx), FIXED2DBL(ty)), true, walkplane, tm)) + DVector2 t; + t.X = 0, t.Y = onestep.Y; + walkplane = P_CheckSlopeWalk (mo, t); + if (P_TryMove (mo, mo->Pos() + t, true, walkplane, tm)) { mo->Vel.X = 0; } else { - tx = onestepx, ty = 0; - walkplane = P_CheckSlopeWalk (mo, tx, ty); - if (P_TryMove (mo, mo->Pos() + DVector2(FIXED2DBL(tx), FIXED2DBL(ty)), true, walkplane, tm)) + t.X = onestep.X, t.Y = 0; + walkplane = P_CheckSlopeWalk (mo, t); + if (P_TryMove (mo, mo->Pos() + t, true, walkplane, tm)) { mo->Vel.Y = 0; } @@ -2045,7 +2016,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) { // Struck a player/creature P_ExplodeMissile (mo, NULL, BlockingMobj); } - return oldfloorz; + return Oldfloorz; } } else @@ -2054,7 +2025,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) if (P_BounceWall (mo)) { mo->PlayBounceSound(false); - return oldfloorz; + return Oldfloorz; } } if (BlockingMobj && (BlockingMobj->flags2 & MF2_REFLECTIVE)) @@ -2105,7 +2076,7 @@ fixed_t P_XYMovement (AActor *mo, fixed_t scrollx, fixed_t scrolly) mo->tracer = mo->target; } mo->target = BlockingMobj; - return oldfloorz; + return Oldfloorz; } explode: // explode a missile @@ -2114,22 +2085,22 @@ explode: if (tm.ceilingline && tm.ceilingline->backsector && tm.ceilingline->backsector->GetTexture(sector_t::ceiling) == skyflatnum && - mo->_f_Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(mo->_f_PosRelative(tm.ceilingline))) + mo->Z() >= tm.ceilingline->backsector->ceilingplane.ZatPoint(mo->PosRelative(tm.ceilingline))) { // Hack to prevent missiles exploding against the sky. // Does not handle sky floors. mo->Destroy (); - return oldfloorz; + return Oldfloorz; } // [RH] Don't explode on horizon lines. if (mo->BlockingLine != NULL && mo->BlockingLine->special == Line_Horizon) { mo->Destroy (); - return oldfloorz; + return Oldfloorz; } } P_ExplodeMissile (mo, mo->BlockingLine, BlockingMobj); - return oldfloorz; + return Oldfloorz; } else { @@ -2139,32 +2110,26 @@ explode: } else { - if (mo->_f_X() != ptryx || mo->_f_Y() != ptryy) + if (mo->Pos().XY() != ptry) { // If the new position does not match the desired position, the player // must have gone through a teleporter, so stop moving right now if it // was a regular teleporter. If it was a line-to-line or fogless teleporter, - // the move should continue, but startx, starty and xmove, ymove need to change. + // the move should continue, but start and move need to change. if (mo->Vel.X == 0 && mo->Vel.Y == 0) { step = steps; } else { - angle_t anglediff = (mo->_f_angle() - oldangle) >> ANGLETOFINESHIFT; + DAngle anglediff = deltaangle(oldangle, mo->Angles.Yaw); if (anglediff != 0) { - fixed_t xnew = FixedMul(xmove, finecosine[anglediff]) - FixedMul(ymove, finesine[anglediff]); - fixed_t ynew = FixedMul(xmove, finesine[anglediff]) + FixedMul(ymove, finecosine[anglediff]); - - xmove = xnew; - ymove = ynew; - oldangle = mo->_f_angle(); // in case more moves are needed this needs to be updated. + move = move.Rotated(anglediff); + oldangle = mo->Angles.Yaw; // in case more moves are needed this needs to be updated. } - - startx = mo->_f_X() - Scale (xmove, step, steps); - starty = mo->_f_Y() - Scale (ymove, step, steps); + start = mo->Pos() - move * step / steps; } } } @@ -2176,12 +2141,12 @@ explode: { // debug option for no sliding at all mo->Vel.X = mo->Vel.Y = 0; player->Vel.X = player->Vel.Y = 0; - return oldfloorz; + return Oldfloorz; } if (mo->flags & (MF_MISSILE | MF_SKULLFLY)) { // no friction for missiles - return oldfloorz; + return Oldfloorz; } if (mo->Z() > mo->floorz && !(mo->flags2 & MF2_ONMOBJ) && @@ -2200,7 +2165,7 @@ explode: player->Vel.Y *= level.airfriction; } } - return oldfloorz; + return Oldfloorz; } // killough 8/11/98: add bouncers @@ -2221,10 +2186,10 @@ explode: // if the floor comes from one in the current sector stop sliding the corpse! F3DFloor * rover=mo->Sector->e->XFloor.ffloors[i]; if (!(rover->flags&FF_EXISTS)) continue; - if (rover->flags&FF_SOLID && rover->top.plane->ZatPoint(mo) == mo->_f_floorz()) break; + if (rover->flags&FF_SOLID && rover->top.plane->ZatPointF(mo) == mo->floorz) break; } if (i==mo->Sector->e->XFloor.ffloors.Size()) - return oldfloorz; + return Oldfloorz; } } } @@ -2291,7 +2256,7 @@ explode: if (fabs(player->Vel.Y) < MinVel) player->Vel.Y = 0; } } - return oldfloorz; + return Oldfloorz; } // Move this to p_inter *** @@ -3724,9 +3689,7 @@ void AActor::Tick () // Handle X and Y velocities BlockingMobj = NULL; - assert(!player || !isnan(Vel.X)); - fixed_t oldfloorz = P_XYMovement (this, cummx, cummy); - assert(!player || !isnan(Vel.X)); + fixed_t oldfloorz = FLOAT2FIXED(P_XYMovement (this, DVector2(FIXED2DBL(cummx), FIXED2DBL(cummy)))); if (ObjectFlags & OF_EuthanizeMe) { // actor was destroyed return; diff --git a/src/vectors.h b/src/vectors.h index 32c7508c7..7e22d59c9 100644 --- a/src/vectors.h +++ b/src/vectors.h @@ -86,6 +86,11 @@ struct TVector2 Y = X = 0; } + bool isZero() const + { + return X == 0 && Y == 0; + } + TVector2 &operator= (const TVector2 &other) { // This might seem backwards, but this helps produce smaller code when a newly From 2fff7005ada1679a3cffc21df03326552c383cf4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Mar 2016 10:01:24 +0200 Subject: [PATCH 31/44] - floatified more of p_mobj.cpp --- src/actor.h | 120 +++---------------------------- src/g_level.h | 2 +- src/p_checkposition.h | 12 ---- src/p_enemy.cpp | 4 +- src/p_mobj.cpp | 164 ++++++++++++++++++++---------------------- src/p_sight.cpp | 4 +- src/p_spec.cpp | 4 +- src/p_user.cpp | 22 +++--- 8 files changed, 106 insertions(+), 226 deletions(-) diff --git a/src/actor.h b/src/actor.h index 8c459d9a5..8d7e530e9 100644 --- a/src/actor.h +++ b/src/actor.h @@ -737,12 +737,7 @@ public: inline bool IsNoClip2() const; void CheckPortalTransition(bool islinked); - fixedvec3 _f_GetPortalTransition(fixed_t byoffset, sector_t **pSec = NULL); - DVector3 GetPortalTransition(double byoffset, sector_t **pSec = NULL) - { - fixedvec3 pos = _f_GetPortalTransition(FLOAT2FIXED(byoffset), pSec); - return{ FIXED2FLOAT(pos.x), FIXED2FLOAT(pos.y),FIXED2FLOAT(pos.z) }; - } + DVector3 GetPortalTransition(double byoffset, sector_t **pSec = NULL); // What species am I? virtual FName GetSpecies(); @@ -823,27 +818,6 @@ public: return bloodcls; } - fixed_t AproxDistance(fixed_t otherx, fixed_t othery) - { - return P_AproxDistance(_f_X() - otherx, _f_Y() - othery); - } - - // 'absolute' is reserved for a linked portal implementation which needs - // to distinguish between portal-aware and portal-unaware distance calculation. - fixed_t AproxDistance(AActor *other, bool absolute = false) - { - fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this); - return P_AproxDistance(_f_X() - otherpos.x, _f_Y() - otherpos.y); - } - - /* - fixed_t AproxDistance(AActor *other, fixed_t xadd, fixed_t yadd, bool absolute = false) - { - fixedvec3 otherpos = absolute ? other->_f_Pos() : other->_f_PosRelative(this); - return P_AproxDistance(_f_X() - otherpos.x + xadd, _f_Y() - otherpos.y + yadd); - } - */ - double Distance2D(AActor *other, bool absolute = false) { DVector2 otherpos = absolute ? other->Pos() : other->PosRelative(this); @@ -887,20 +861,6 @@ public: return VecToAngle(otherpos - Pos() + DVector2(oxofs, oyofs)); } - fixedvec2 _f_Vec2To(AActor *other) const - { - fixedvec3 otherpos = other->_f_PosRelative(this); - fixedvec2 ret = { otherpos.x - _f_X(), otherpos.y - _f_Y() }; - return ret; - } - - fixedvec3 _f_Vec3To(AActor *other) const - { - fixedvec3 otherpos = other->_f_PosRelative(this); - fixedvec3 ret = { otherpos.x - _f_X(), otherpos.y - _f_Y(), otherpos.z - _f_Z() }; - return ret; - } - DVector2 Vec2To(AActor *other) const { return other->PosRelative(this) - Pos(); @@ -911,16 +871,6 @@ public: return other->PosRelative(this) - Pos(); } - fixedvec2 Vec2Offset(fixed_t dx, fixed_t dy, bool absolute = false) - { - if (absolute) - { - fixedvec2 ret = { _f_X() + dx, _f_Y() + dy }; - return ret; - } - else return P_GetOffsetPosition(_f_X(), _f_Y(), dx, dy); - } - DVector2 Vec2Offset(double dx, double dy, bool absolute = false) { if (absolute) @@ -929,8 +879,7 @@ public: } else { - fixedvec2 v = P_GetOffsetPosition(_f_X(), _f_Y(), FLOAT2FIXED(dx), FLOAT2FIXED(dy)); - return{ FIXED2DBL(v.x), FIXED2DBL(v.y) }; + return P_GetOffsetPosition(X(), Y(), dx, dy); } } @@ -943,22 +892,11 @@ public: } else { - fixedvec2 v = P_GetOffsetPosition(_f_X(), _f_Y(), FLOAT2FIXED(dx), FLOAT2FIXED(dy)); - return{ FIXED2DBL(v.x), FIXED2DBL(v.y), atz }; + DVector2 v = P_GetOffsetPosition(X(), Y(), dx, dy); + return DVector3(v, atz); } } - fixedvec2 Vec2Angle(fixed_t length, angle_t angle, bool absolute = false) - { - if (absolute) - { - fixedvec2 ret = { _f_X() + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), - _f_Y() + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]) }; - return ret; - } - else return P_GetOffsetPosition(_f_X(), _f_Y(), FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), FixedMul(length, finesine[angle >> ANGLETOFINESHIFT])); - } - DVector2 Vec2Angle(double length, DAngle angle, bool absolute = false) { if (absolute) @@ -967,8 +905,7 @@ public: } else { - fixedvec2 op = P_GetOffsetPosition(_f_X(), _f_Y(), FLOAT2FIXED(length*angle.Cos()), FLOAT2FIXED(length*angle.Sin())); - return{ FIXED2DBL(op.x), FIXED2DBL(op.y) }; + return P_GetOffsetPosition(X(), Y(), length*angle.Cos(), length*angle.Sin()); } } @@ -995,8 +932,8 @@ public: } else { - fixedvec2 v = P_GetOffsetPosition(_f_X(), _f_Y(), FLOAT2FIXED(dx), FLOAT2FIXED(dy)); - return{ FIXED2DBL(v.x), FIXED2DBL(v.y), Z() + dz }; + DVector2 v = P_GetOffsetPosition(X(), Y(), dx, dy); + return DVector3(v, Z() + dz); } } @@ -1005,22 +942,6 @@ public: return Vec3Offset(ofs.X, ofs.Y, ofs.Z, absolute); } - fixedvec3 _f_Vec3Angle(fixed_t length, angle_t angle, fixed_t dz, bool absolute = false) - { - if (absolute) - { - fixedvec3 ret = { _f_X() + FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), - _f_Y() + FixedMul(length, finesine[angle >> ANGLETOFINESHIFT]), _f_Z() + dz }; - return ret; - } - else - { - fixedvec2 op = P_GetOffsetPosition(_f_X(), _f_Y(), FixedMul(length, finecosine[angle >> ANGLETOFINESHIFT]), FixedMul(length, finesine[angle >> ANGLETOFINESHIFT])); - fixedvec3 pos = { op.x, op.y, _f_Z() + dz }; - return pos; - } - } - DVector3 Vec3Angle(double length, DAngle angle, double dz, bool absolute = false) { if (absolute) @@ -1029,8 +950,8 @@ public: } else { - fixedvec2 op = P_GetOffsetPosition(_f_X(), _f_Y(), FLOAT2FIXED(length*angle.Cos()), FLOAT2FIXED(length*angle.Sin())); - return{ FIXED2DBL(op.x), FIXED2DBL(op.y), Z() + dz }; + DVector2 v = P_GetOffsetPosition(X(), Y(), length*angle.Cos(), length*angle.Sin()); + return DVector3(v, Z() + dz); } } @@ -1041,11 +962,6 @@ public: void ClearInterpolation(); - void Move(fixed_t dx, fixed_t dy, fixed_t dz) - { - SetOrigin(_f_X() + dx, _f_Y() + dy, _f_Z() + dz, true); - } - void SetOrigin(const fixedvec3 & npos, bool moving) { SetOrigin(npos.x, npos.y, npos.z, moving); @@ -1094,12 +1010,7 @@ public: // intentionally stange names so that searching for them is easier. angle_t _f_angle() { return FLOAT2ANGLE(Angles.Yaw.Degrees); } int _f_pitch() { return FLOAT2ANGLE(Angles.Pitch.Degrees); } - angle_t _f_roll() { return FLOAT2ANGLE(Angles.Roll.Degrees); } - fixed_t _f_velx() { return FLOAT2FIXED(Vel.X); } - fixed_t _f_vely() { return FLOAT2FIXED(Vel.Y); } - fixed_t _f_velz() { return FLOAT2FIXED(Vel.Z); } fixed_t _f_speed() { return FLOAT2FIXED(Speed); } - fixed_t _f_floatspeed() { return FLOAT2FIXED(FloatSpeed); } WORD sprite; // used to find patch_t and flip value @@ -1119,19 +1030,10 @@ public: double floorz, ceilingz; // closest together of contacted secs double dropoffz; // killough 11/98: the lowest floor over all contacted Sectors. - inline fixed_t _f_ceilingz() - { - return FLOAT2FIXED(ceilingz); - } inline fixed_t _f_floorz() { return FLOAT2FIXED(floorz); } - inline fixed_t _f_dropoffz() - { - return FLOAT2FIXED(dropoffz); - } - struct sector_t *floorsector; FTextureID floorpic; // contacted sec floorpic @@ -1276,10 +1178,6 @@ public: double MaxDropOffHeight; double MaxStepHeight; - fixed_t _f_MaxStepHeight() - { - return FLOAT2FIXED(MaxStepHeight); - } SDWORD Mass; SWORD PainChance; int PainThreshold; diff --git a/src/g_level.h b/src/g_level.h index 3b320bddb..c4bfd1277 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -377,7 +377,7 @@ struct level_info_t // [RH] These get zeroed every tic and are updated by thinkers. struct FSectorScrollValues { - fixed_t ScrollX, ScrollY; + DVector2 Scroll; }; struct FLevelLocals diff --git a/src/p_checkposition.h b/src/p_checkposition.h index 3a67a3610..b593f0ff0 100644 --- a/src/p_checkposition.h +++ b/src/p_checkposition.h @@ -45,18 +45,6 @@ struct FCheckPosition FromPMove = false; } - inline fixed_t _f_ceilingz() - { - return FLOAT2FIXED(ceilingz); - } - inline fixed_t _f_floorz() - { - return FLOAT2FIXED(floorz); - } - inline fixed_t _f_dropoffz() - { - return FLOAT2FIXED(dropoffz); - } inline fixed_t _f_X() { return FLOAT2FIXED(pos.X); diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 08053630d..8707ffc76 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -1999,7 +1999,7 @@ DEFINE_ACTION_FUNCTION_PARAMS(AActor, A_LookEx) { if (self->flags & MF_AMBUSH) { - dist = self->AproxDistance (self->target); + dist = self->Distance2D (self->target); if (P_CheckSight (self, self->target, SF_SEEPASTBLOCKEVERYTHING) && (!minseedist || dist > minseedist) && (!maxseedist || dist < maxseedist)) @@ -2449,7 +2449,7 @@ void A_DoChase (VMFrameStack *stack, AActor *actor, bool fastchase, FState *mele { actor->FastChaseStrafeCount = 0; actor->Vel.X = actor->Vel.Y = 0; - fixed_t dist = actor->AproxDistance (actor->target); + double dist = actor->Distance2D (actor->target); if (dist < CLASS_BOSS_STRAFE_RANGE) { if (pr_chase() < 100) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 140736865..9c10015a3 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1396,7 +1396,7 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) { // Find the nearest point on the line, and stick a decal there DVector3 linepos; - double num, den, frac; + double den, frac; den = line->Delta().LengthSquared(); if (den != 0) @@ -2263,21 +2263,21 @@ explode: void P_MonsterFallingDamage (AActor *mo) { int damage; - int vel; + double vel; if (!(level.flags2 & LEVEL2_MONSTERFALLINGDAMAGE)) return; if (mo->floorsector->Flags & SECF_NOFALLINGDAMAGE) return; - vel = abs(mo->_f_velz()); - if (vel > 35*FRACUNIT) + vel = fabs(mo->Vel.Z); + if (vel > 35) { // automatic death damage = TELEFRAG_DAMAGE; } else { - damage = ((vel - (23*FRACUNIT))*6)>>FRACBITS; + damage = int((vel - 23)*6); } damage = TELEFRAG_DAMAGE; // always kill 'em P_DamageMobj (mo, NULL, NULL, damage, NAME_Falling); @@ -2287,11 +2287,11 @@ void P_MonsterFallingDamage (AActor *mo) // P_ZMovement // -void P_ZMovement (AActor *mo, fixed_t oldfloorz) +void P_ZMovement (AActor *mo, double oldfloorz) { - fixed_t dist; - fixed_t delta; - fixed_t oldz = mo->_f_Z(); + double dist; + double delta; + double oldz = mo->Z(); double grav = mo->GetGravity(); // @@ -2317,7 +2317,7 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) { // [RH] Double gravity only if running off a ledge. Coming down from // an upward thrust (e.g. a jump) should not double it. - if (mo->Vel.Z == 0 && oldfloorz > mo->_f_floorz() && mo->_f_Z() == oldfloorz) + if (mo->Vel.Z == 0 && oldfloorz > mo->floorz && mo->Z() == oldfloorz) { mo->Vel.Z -= grav + grav; } @@ -2401,19 +2401,19 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) { // float down towards target if too close if (!(mo->flags & (MF_SKULLFLY | MF_INFLOAT))) { - dist = mo->AproxDistance (mo->target); - delta = (mo->target->_f_Z() + (mo->_f_height()>>1)) - mo->_f_Z(); + dist = mo->Distance2D (mo->target); + delta = (mo->target->Center()) - mo->Z(); if (delta < 0 && dist < -(delta*3)) - mo->_f_AddZ(-mo->_f_floatspeed()); + mo->AddZ(-mo->FloatSpeed); else if (delta > 0 && dist < (delta*3)) - mo->_f_AddZ(mo->_f_floatspeed()); + mo->AddZ(mo->FloatSpeed); } } if (mo->player && (mo->flags & MF_NOGRAVITY) && (mo->Z() > mo->floorz)) { if (!mo->IsNoClip2()) { - mo->_f_AddZ(finesine[(FINEANGLES/80*level.maptime)&FINEMASK]/8); + mo->AddZ(DAngle(360 / 80.f * level.maptime).Sin() / 8); } mo->Vel.Z *= FRICTION_FLY; } @@ -2447,7 +2447,7 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) { // Hit the floor if ((!mo->player || !(mo->player->cheats & CF_PREDICTING)) && mo->Sector->SecActTarget != NULL && - mo->Sector->floorplane.ZatPoint(mo) == mo->_f_floorz()) + mo->Sector->floorplane.ZatPointF(mo) == mo->floorz) { // [RH] Let the sector do something to the actor mo->Sector->SecActTarget->TriggerAction (mo, SECSPAC_HitFloor); } @@ -2488,25 +2488,25 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) return; } } - else if (mo->BounceFlags & BOUNCE_MBF && mo->_f_velz()) // check for MBF-like bounce on non-missiles + else if (mo->BounceFlags & BOUNCE_MBF && mo->Vel.Z) // check for MBF-like bounce on non-missiles { mo->FloorBounceMissile(mo->floorsector->floorplane); } if (mo->flags3 & MF3_ISMONSTER) // Blasted mobj falling { - if (mo->_f_velz() < -(23*FRACUNIT)) + if (mo->Vel.Z < -23) { P_MonsterFallingDamage (mo); } } mo->SetZ(mo->floorz); - if (mo->_f_velz() < 0) + if (mo->Vel.Z < 0) { - const fixed_t minvel = -8*FRACUNIT; // landing speed from a jump with normal gravity + const double minvel = -8; // landing speed from a jump with normal gravity // Spawn splashes, etc. P_HitFloor (mo); - if (mo->DamageType == NAME_Ice && mo->_f_velz() < minvel) + if (mo->DamageType == NAME_Ice && mo->Vel.Z < minvel) { mo->tics = 1; mo->Vel.Zero(); @@ -2516,11 +2516,11 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) mo->HitFloor (); if (mo->player) { - if (mo->player->jumpTics < 0 || mo->_f_velz() < minvel) + if (mo->player->jumpTics < 0 || mo->Vel.Z < minvel) { // delay any jumping for a short while mo->player->jumpTics = 7; } - if (mo->_f_velz() < minvel && !(mo->flags & MF_NOGRAVITY)) + if (mo->Vel.Z < minvel && !(mo->flags & MF_NOGRAVITY)) { // Squat down. // Decrease viewheight for a moment after hitting the ground (hard), @@ -2547,7 +2547,7 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) { // hit the ceiling if ((!mo->player || !(mo->player->cheats & CF_PREDICTING)) && mo->Sector->SecActTarget != NULL && - mo->Sector->ceilingplane.ZatPoint(mo) == mo->_f_ceilingz()) + mo->Sector->ceilingplane.ZatPointF(mo) == mo->ceilingz) { // [RH] Let the sector do something to the actor mo->Sector->SecActTarget->TriggerAction (mo, SECSPAC_HitCeiling); } @@ -2584,7 +2584,7 @@ void P_ZMovement (AActor *mo, fixed_t oldfloorz) } } } - P_CheckFakeFloorTriggers (mo, FIXED2DBL(oldz)); + P_CheckFakeFloorTriggers (mo, oldz); } void P_CheckFakeFloorTriggers (AActor *mo, double oldz, bool oldz_has_viewheight) @@ -3212,20 +3212,20 @@ void AActor::SetRoll(DAngle r, bool interpolate) } -fixedvec3 AActor::_f_GetPortalTransition(fixed_t byoffset, sector_t **pSec) +DVector3 AActor::GetPortalTransition(double byoffset, sector_t **pSec) { bool moved = false; sector_t *sec = Sector; - double testz = Z() + FIXED2FLOAT(byoffset); - fixedvec3 pos = _f_Pos(); + double testz = Z() + byoffset; + DVector3 pos = Pos(); while (!sec->PortalBlocksMovement(sector_t::ceiling)) { AActor *port = sec->SkyBoxes[sector_t::ceiling]; if (testz > port->specialf1) { - pos = _f_PosRelative(port->Sector); - sec = P_PointInSector(pos.x, pos.y); + pos = PosRelative(port->Sector); + sec = P_PointInSector(pos); moved = true; } else break; @@ -3237,8 +3237,8 @@ fixedvec3 AActor::_f_GetPortalTransition(fixed_t byoffset, sector_t **pSec) AActor *port = sec->SkyBoxes[sector_t::floor]; if (testz <= port->specialf1) { - pos = _f_PosRelative(port->Sector); - sec = P_PointInSector(pos.x, pos.y); + pos = PosRelative(port->Sector); + sec = P_PointInSector(pos); } else break; } @@ -3294,8 +3294,7 @@ void AActor::CheckPortalTransition(bool islinked) void AActor::Tick () { // [RH] Data for Heretic/Hexen scrolling sectors - static const BYTE HexenScrollDirs[8] = { 64, 0, 192, 128, 96, 32, 224, 160 }; - static const BYTE HexenSpeedMuls[3] = { 5, 10, 25 }; + static const SBYTE HexenCompatSpeeds[] = {-25, 0, -10, -5, 0, 5, 10, 0, 25 }; static const SBYTE HexenScrollies[24][2] = { { 0, 1 }, { 0, 2 }, { 0, 4 }, @@ -3349,7 +3348,7 @@ void AActor::Tick () UnlinkFromWorld (); flags |= MF_NOBLOCKMAP; - SetXYZ(Vec3Offset(_f_velx(), _f_vely(), _f_velz())); + SetXYZ(Vec3Offset(Vel)); CheckPortalTransition(false); LinkToWorld (); } @@ -3434,7 +3433,7 @@ void AActor::Tick () { if (health >0) { - if (abs (_f_velz()) < FRACUNIT/4) + if (fabs (Vel.Z) < 0.25) { Vel.Z = 0; flags4 &= ~MF4_VFRICTION; @@ -3499,10 +3498,10 @@ void AActor::Tick () } // [RH] Consider carrying sectors here - fixed_t cummx = 0, cummy = 0; + DVector2 cumm(0, 0); if ((level.Scrolls != NULL || player != NULL) && !(flags & MF_NOCLIP) && !(flags & MF_NOSECTOR)) { - fixed_t height, waterheight; // killough 4/4/98: add waterheight + double height, waterheight; // killough 4/4/98: add waterheight const msecnode_t *node; int countx, county; @@ -3519,17 +3518,16 @@ void AActor::Tick () for (node = touching_sectorlist; node; node = node->m_tnext) { sector_t *sec = node->m_sector; - fixed_t scrollx, scrolly; + DVector2 scrollv; if (level.Scrolls != NULL) { const FSectorScrollValues *scroll = &level.Scrolls[sec - sectors]; - scrollx = scroll->ScrollX; - scrolly = scroll->ScrollY; + scrollv = scroll->Scroll; } else { - scrollx = scrolly = 0; + scrollv.Zero(); } if (player != NULL) @@ -3542,16 +3540,15 @@ void AActor::Tick () scrolltype -= Scroll_North_Slow; if (i_compatflags&COMPATF_RAVENSCROLL) { - angle_t fineangle = HexenScrollDirs[scrolltype / 3] * 32; - fixed_t carryspeed = DivScale32 (HexenSpeedMuls[scrolltype % 3], 32*_f_CARRYFACTOR); - scrollx += FixedMul (carryspeed, finecosine[fineangle]); - scrolly += FixedMul (carryspeed, finesine[fineangle]); + scrollv.X -= HexenCompatSpeeds[HexenScrollies[scrolltype][0]+4] * (1. / (32 * CARRYFACTOR)); + scrollv.Y += HexenCompatSpeeds[HexenScrollies[scrolltype][1]+4] * (1. / (32 * CARRYFACTOR)); + } else { // Use speeds that actually match the scrolling textures! - scrollx -= HexenScrollies[scrolltype][0] << (FRACBITS-1); - scrolly += HexenScrollies[scrolltype][1] << (FRACBITS-1); + scrollv.X -= HexenScrollies[scrolltype][0] * 0.5; + scrollv.Y += HexenScrollies[scrolltype][1] * 0.5; } } else if (scrolltype >= Carry_East5 && @@ -3559,39 +3556,37 @@ void AActor::Tick () { // Heretic scroll special scrolltype -= Carry_East5; BYTE dir = HereticScrollDirs[scrolltype / 5]; - fixed_t carryspeed = DivScale32 (HereticSpeedMuls[scrolltype % 5], 32*_f_CARRYFACTOR); + double carryspeed = HereticSpeedMuls[scrolltype % 5] * (1. / (32 * CARRYFACTOR)); if (scrolltype<=Carry_East35 && !(i_compatflags&COMPATF_RAVENSCROLL)) { // Use speeds that actually match the scrolling textures! - carryspeed = (1 << ((scrolltype%5) + FRACBITS-1)); + carryspeed = (1 << ((scrolltype%5) - 1)); } - scrollx += carryspeed * ((dir & 3) - 1); - scrolly += carryspeed * (((dir & 12) >> 2) - 1); + scrollv.X += carryspeed * ((dir & 3) - 1); + scrollv.Y += carryspeed * (((dir & 12) >> 2) - 1); } else if (scrolltype == dScroll_EastLavaDamage) { // Special Heretic scroll special if (i_compatflags&COMPATF_RAVENSCROLL) { - scrollx += DivScale32 (28, 32*_f_CARRYFACTOR); + scrollv.X += 28. / (32*CARRYFACTOR); } else { // Use a speed that actually matches the scrolling texture! - scrollx += DivScale32 (12, 32*_f_CARRYFACTOR); + scrollv.X += 12. / (32 * CARRYFACTOR); } } else if (scrolltype == Scroll_StrifeCurrent) { // Strife scroll special int anglespeed = tagManager.GetFirstSectorTag(sec) - 100; - fixed_t carryspeed = DivScale32 (anglespeed % 10, 16*_f_CARRYFACTOR); - angle_t fineangle = (anglespeed / 10) << (32-3); - fineangle >>= ANGLETOFINESHIFT; - scrollx += FixedMul (carryspeed, finecosine[fineangle]); - scrolly += FixedMul (carryspeed, finesine[fineangle]); + double carryspeed = (anglespeed % 10) / (16 * CARRYFACTOR); + DAngle angle = ((anglespeed / 10) * 45.); + scrollv += angle.ToVector(carryspeed); } } - if ((scrollx | scrolly) == 0) + if (scrollv.isZero()) { continue; } @@ -3600,9 +3595,9 @@ void AActor::Tick () { continue; } - fixedvec3 pos = _f_PosRelative(sec); + DVector3 pos = PosRelative(sec); height = sec->floorplane.ZatPoint (pos); - if (_f_Z() > height) + if (Z() > height) { if (heightsec == NULL) { @@ -3610,16 +3605,15 @@ void AActor::Tick () } waterheight = heightsec->floorplane.ZatPoint (pos); - if (waterheight > height && _f_Z() >= waterheight) + if (waterheight > height && Z() >= waterheight) { continue; } } - cummx += scrollx; - cummy += scrolly; - if (scrollx) countx++; - if (scrolly) county++; + cumm += scrollv; + if (scrollv.X) countx++; + if (scrollv.Y) county++; } // Some levels designed with Boom in mind actually want things to accelerate @@ -3629,11 +3623,11 @@ void AActor::Tick () { if (countx > 1) { - cummx /= countx; + cumm.X /= countx; } if (county > 1) { - cummy /= county; + cumm.Y /= county; } } } @@ -3650,7 +3644,7 @@ void AActor::Tick () floorplane = P_FindFloorPlane(floorsector, PosAtZ(floorz)); if (floorplane.c < STEEPSLOPE && - floorplane.ZatPoint (_f_PosRelative(floorsector)) <= _f_floorz()) + floorplane.ZatPoint (PosRelative(floorsector)) <= floorz) { const msecnode_t *node; bool dopush = true; @@ -3689,7 +3683,7 @@ void AActor::Tick () // Handle X and Y velocities BlockingMobj = NULL; - fixed_t oldfloorz = FLOAT2FIXED(P_XYMovement (this, DVector2(FIXED2DBL(cummx), FIXED2DBL(cummy)))); + double oldfloorz = P_XYMovement (this, cumm); if (ObjectFlags & OF_EuthanizeMe) { // actor was destroyed return; @@ -3755,7 +3749,7 @@ void AActor::Tick () onmo->lastbump = level.maptime + TICRATE; } } - if (_f_velz() != 0 && (BounceFlags & BOUNCE_Actors)) + if (Vel.Z != 0 && (BounceFlags & BOUNCE_Actors)) { P_BounceActor(this, onmo, true); } @@ -3902,15 +3896,15 @@ void AActor::CheckSectorTransition(sector_t *oldsec) if (Sector->SecActTarget != NULL) { int act = SECSPAC_Enter; - if (_f_Z() <= Sector->floorplane.ZatPoint(this)) + if (Z() <= Sector->floorplane.ZatPointF(this)) { act |= SECSPAC_HitFloor; } - if (_f_Z() + _f_height() >= Sector->ceilingplane.ZatPoint(this)) + if (Top() >= Sector->ceilingplane.ZatPointF(this)) { act |= SECSPAC_HitCeiling; } - if (Sector->heightsec != NULL && _f_Z() == Sector->heightsec->floorplane.ZatPoint(this)) + if (Sector->heightsec != NULL && Z() == Sector->heightsec->floorplane.ZatPointF(this)) { act |= SECSPAC_HitFakeFloor; } @@ -5585,7 +5579,7 @@ bool P_HitFloor (AActor *thing) // killough 11/98: touchy objects explode on impact // Allow very short drops to be safe, so that a touchy can be summoned without exploding. - if (thing->flags6 & MF6_TOUCHY && ((thing->flags6 & MF6_ARMED) || thing->IsSentient()) && ((thing->_f_velz()) < (-5 * FRACUNIT))) + if (thing->flags6 & MF6_TOUCHY && ((thing->flags6 & MF6_ARMED) || thing->IsSentient()) && thing->Vel.Z < -5) { thing->flags6 &= ~MF6_ARMED; // Disarm P_DamageMobj (thing, NULL, NULL, thing->health, NAME_Crush, DMG_FORCED); // kill object @@ -5938,21 +5932,21 @@ AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, PClassAct { return NULL; } - angle_t an; - fixed_t dist; - fixed_t speed; - fixed_t vz; + DAngle an; + double dist; + double speed; + double vz; - an = source->_f_angle(); + an = source->Angles.Yaw; if (dest->flags & MF_SHADOW) { - an += pr_spawnmissile.Random2() << 20; + an += pr_spawnmissile.Random2() * (16. / 360.); } - dist = source->AproxDistance (dest); - speed = GetDefaultSpeed (type); + dist = source->Distance2D (dest); + speed = FIXED2DBL(GetDefaultSpeed (type)); dist /= speed; - vz = dist != 0 ? (dest->_f_Z() - source->_f_Z())/dist : speed; + vz = dist != 0 ? (dest->Z() - source->Z())/dist : speed; return P_SpawnMissileAngleZSpeed (source, z, type, an, vz, speed); } diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 20d7d2113..cfa93baa1 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -899,10 +899,10 @@ sightcounts[0]++; res = s.P_SightPathTraverse (); if (!res) { - fixed_t dist = t1->AproxDistance(t2); + double dist = t1->Distance2D(t2); for (unsigned i = 0; i < portals.Size(); i++) { - portals[i].frac += FixedDiv(FRACUNIT, dist); + portals[i].frac += FLOAT2FIXED(1 / dist); s.init(t1, t2, NULL, &portals[i], flags); if (s.P_SightPathTraverse()) { diff --git a/src/p_spec.cpp b/src/p_spec.cpp index cf3e067eb..e1ff85759 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -1625,8 +1625,8 @@ void DScroller::Tick () // [RH] Don't actually carry anything here. That happens later. case sc_carry: - level.Scrolls[m_Affectee].ScrollX += dx; - level.Scrolls[m_Affectee].ScrollY += dy; + level.Scrolls[m_Affectee].Scroll.X += FIXED2DBL(dx); + level.Scrolls[m_Affectee].Scroll.Y += FIXED2DBL(dy); break; case sc_carry_ceiling: // to be added later diff --git a/src/p_user.cpp b/src/p_user.cpp index 2ad92a968..15b79bed5 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2040,7 +2040,7 @@ void P_FallingDamage (AActor *actor) { int damagestyle; int damage; - fixed_t vel; + double vel; damagestyle = ((level.flags >> 15) | (dmflags)) & (DF_FORCE_FALLINGZD | DF_FORCE_FALLINGHX); @@ -2051,7 +2051,7 @@ void P_FallingDamage (AActor *actor) if (actor->floorsector->Flags & SECF_NOFALLINGDAMAGE) return; - vel = abs(actor->_f_velz()); + vel = fabs(actor->Vel.Z); // Since Hexen falling damage is stronger than ZDoom's, it takes // precedence. ZDoom falling damage may not be as strong, but it @@ -2060,19 +2060,19 @@ void P_FallingDamage (AActor *actor) switch (damagestyle) { case DF_FORCE_FALLINGHX: // Hexen falling damage - if (vel <= 23*FRACUNIT) + if (vel <= 23) { // Not fast enough to hurt return; } - if (vel >= 63*FRACUNIT) + if (vel >= 63) { // automatic death damage = 1000000; } else { - vel = FixedMul (vel, 16*FRACUNIT/23); - damage = ((FixedMul (vel, vel) / 10) >> FRACBITS) - 24; - if (actor->_f_velz() > -39*FRACUNIT && damage > actor->health + vel *= (16. / 23); + damage = int((vel * vel) / 10 - 24); + if (actor->Vel.Z > -39 && damage > actor->health && actor->health != 1) { // No-death threshold damage = actor->health-1; @@ -2081,17 +2081,17 @@ void P_FallingDamage (AActor *actor) break; case DF_FORCE_FALLINGZD: // ZDoom falling damage - if (vel <= 19*FRACUNIT) + if (vel <= 19) { // Not fast enough to hurt return; } - if (vel >= 84*FRACUNIT) + if (vel >= 84) { // automatic death damage = 1000000; } else { - damage = ((MulScale23 (vel, vel*11) >> FRACBITS) - 30) / 2; + damage = int((vel*vel*(11 / 128.) - 30) / 2); if (damage < 1) { damage = 1; @@ -2100,7 +2100,7 @@ void P_FallingDamage (AActor *actor) break; case DF_FORCE_FALLINGST: // Strife falling damage - if (vel <= 20*FRACUNIT) + if (vel <= 20) { // Not fast enough to hurt return; } From 5e1c79c05019f8ae85c3bac1115f5cf57e54084b Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Mar 2016 12:03:07 +0200 Subject: [PATCH 32/44] - floatified the rest of p_mobj_cpp and removed a large part of the conversion cruft from the headers that was needed to keep the code compileable. --- src/p_effect.cpp | 3 +- src/p_local.h | 46 ++++--------------------- src/p_mobj.cpp | 88 +++++++++++++++++++----------------------------- src/p_switch.cpp | 4 +-- src/p_user.cpp | 2 +- src/s_sound.cpp | 5 ++- src/s_sound.h | 6 +--- 7 files changed, 48 insertions(+), 106 deletions(-) diff --git a/src/p_effect.cpp b/src/p_effect.cpp index 75152d6ef..11e09e5dd 100644 --- a/src/p_effect.cpp +++ b/src/p_effect.cpp @@ -691,8 +691,7 @@ void P_DrawRailTrail(AActor *source, const DVector3 &start, const DVector3 &end, point = start + r * dir; dir.Z = dirz; - S_Sound (FLOAT2FIXED(point.X), FLOAT2FIXED(point.Y), viewz, - CHAN_WEAPON, sound, 1, ATTN_NORM); + S_Sound (DVector3(point.X, point.Y, viewz), CHAN_WEAPON, sound, 1, ATTN_NORM); } } } diff --git a/src/p_local.h b/src/p_local.h index bb7042f3f..d4d1a3591 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -138,11 +138,6 @@ enum EPuffFlags }; AActor *P_SpawnPuff(AActor *source, PClassActor *pufftype, const DVector3 &pos, DAngle hitdir, DAngle particledir, int updown, int flags = 0, AActor *vict = NULL); -inline AActor *P_SpawnPuff(AActor *source, PClassActor *pufftype, const fixedvec3 &pos, angle_t hitdir, angle_t particledir, int updown, int flags = 0, AActor *vict = NULL) -{ - DVector3 _pos(FIXED2DBL(pos.x), FIXED2DBL(pos.y), FIXED2DBL(pos.z)); - return P_SpawnPuff(source, pufftype, _pos, ANGLE2DBL(hitdir), ANGLE2DBL(particledir), updown, flags, vict); -} void P_SpawnBlood (const DVector3 &pos, DAngle angle, int damage, AActor *originator); void P_BloodSplatter (const DVector3 &pos, AActor *originator, DAngle hitangle); void P_BloodSplatter2 (const DVector3 &pos, AActor *originator, DAngle hitangle); @@ -152,42 +147,13 @@ void P_ExplodeMissile (AActor *missile, line_t *explodeline, AActor *target); AActor *P_OldSpawnMissile(AActor *source, AActor *owner, AActor *dest, PClassActor *type); AActor *P_SpawnMissile (AActor* source, AActor* dest, PClassActor *type, AActor* owner = NULL); -AActor *P_SpawnMissileZ (AActor* source, fixed_t z, AActor* dest, PClassActor *type); -inline AActor *P_SpawnMissileZ(AActor* source, double z, AActor* dest, PClassActor *type) -{ - return P_SpawnMissileZ(source, FLOAT2FIXED(z), dest, type); -} +AActor *P_SpawnMissileZ(AActor* source, double z, AActor* dest, PClassActor *type); +AActor *P_SpawnMissileXYZ(DVector3 pos, AActor *source, AActor *dest, PClassActor *type, bool checkspawn = true, AActor *owner = NULL); +AActor *P_SpawnMissileAngle(AActor *source, PClassActor *type, DAngle angle, double vz); +AActor *P_SpawnMissileAngleZ(AActor *source, double z, PClassActor *type, DAngle angle, double vz); +AActor *P_SpawnMissileAngleZSpeed(AActor *source, double z, PClassActor *type, DAngle angle, double vz, double speed, AActor *owner = NULL, bool checkspawn = true); +AActor *P_SpawnMissileZAimed(AActor *source, double z, AActor *dest, PClassActor *type); -AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, AActor *source, AActor *dest, PClassActor *type, bool checkspawn = true, AActor *owner = NULL); -inline AActor *P_SpawnMissileXYZ(const fixedvec3 &pos, AActor *source, AActor *dest, PClassActor *type, bool checkspawn = true, AActor *owner = NULL) -{ - return P_SpawnMissileXYZ(pos.x, pos.y, pos.z, source, dest, type, checkspawn, owner); -} -inline AActor *P_SpawnMissileXYZ(const DVector3 &pos, AActor *source, AActor *dest, PClassActor *type, bool checkspawn = true, AActor *owner = NULL) -{ - return P_SpawnMissileXYZ(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), source, dest, type, checkspawn, owner); -} -AActor *P_SpawnMissileAngle (AActor *source, PClassActor *type, angle_t angle, fixed_t vz); -inline AActor *P_SpawnMissileAngle(AActor *source, PClassActor *type, DAngle angle, double vz) -{ - return P_SpawnMissileAngle(source, type, angle.BAMs(), FLOAT2FIXED(vz)); -} -AActor *P_SpawnMissileAngleSpeed (AActor *source, PClassActor *type, angle_t angle, fixed_t vz, fixed_t speed); -AActor *P_SpawnMissileAngleZ (AActor *source, fixed_t z, PClassActor *type, angle_t angle, fixed_t vz); -inline AActor *P_SpawnMissileAngleZ(AActor *source, double z, PClassActor *type, DAngle angle, double vz) -{ - return P_SpawnMissileAngleZ(source, FLOAT2FIXED(z), type, angle.BAMs(), FLOAT2FIXED(vz)); -} -AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, PClassActor *type, angle_t angle, fixed_t vz, fixed_t speed, AActor *owner=NULL, bool checkspawn = true); -inline AActor *P_SpawnMissileAngleZSpeed(AActor *source, double z, PClassActor *type, DAngle angle, double vz, double speed, AActor *owner = NULL, bool checkspawn = true) -{ - return P_SpawnMissileAngleZSpeed(source, FLOAT2FIXED(z), type, angle.BAMs(), FLOAT2FIXED(vz), FLOAT2FIXED(speed), owner, checkspawn); -} -AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, PClassActor *type); -inline AActor *P_SpawnMissileZAimed(AActor *source, double z, AActor *dest, PClassActor *type) -{ - return P_SpawnMissileZAimed(source, FLOAT2FIXED(z), dest, type); -} AActor *P_SpawnPlayerMissile (AActor* source, PClassActor *type); AActor *P_SpawnPlayerMissile (AActor *source, PClassActor *type, DAngle angle); diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 9c10015a3..ef639d7fa 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4426,9 +4426,9 @@ void AActor::AdjustFloorClip () // do the floorclipping instead of the terrain type. for (m = touching_sectorlist; m; m = m->m_tnext) { - fixedvec3 pos = _f_PosRelative(m->m_sector); + DVector3 pos = PosRelative(m->m_sector); sector_t *hsec = m->m_sector->GetHeightSec(); - if (hsec == NULL && m->m_sector->floorplane.ZatPoint (pos) == _f_Z()) + if (hsec == NULL && m->m_sector->floorplane.ZatPoint (pos) == Z()) { double clip = Terrains[m->m_sector->GetTerrain(sector_t::floor)].FootClip; if (clip < shallowestclip) @@ -5270,7 +5270,7 @@ void P_SpawnBlood (const DVector3 &pos, DAngle dir, int damage, AActor *originat } if (bloodtype >= 1) - P_DrawSplash2 (40, pos, ANGLE2DBL(dir), 2, bloodcolor); + P_DrawSplash2 (40, pos, dir, 2, bloodcolor); } //--------------------------------------------------------------------------- @@ -5590,11 +5590,11 @@ bool P_HitFloor (AActor *thing) return false; // don't splash if landing on the edge above water/lava/etc.... - fixedvec3 pos; + DVector3 pos; for (m = thing->touching_sectorlist; m; m = m->m_tnext) { - pos = thing->_f_PosRelative(m->m_sector); - if (thing->_f_Z() == m->m_sector->floorplane.ZatPoint(pos.x, pos.y)) + pos = thing->PosRelative(m->m_sector); + if (thing->Z() == m->m_sector->floorplane.ZatPoint(pos)) { break; } @@ -5606,7 +5606,7 @@ bool P_HitFloor (AActor *thing) if (!(rover->flags & FF_EXISTS)) continue; if (rover->flags & (FF_SOLID|FF_SWIMMABLE)) { - if (rover->top.plane->ZatPoint(pos.x, pos.y) == thing->_f_Z()) + if (rover->top.plane->ZatPoint(pos) == thing->Z()) { return P_HitWater (thing, m->m_sector, pos); } @@ -5638,8 +5638,8 @@ void P_CheckSplash(AActor *self, double distance) // Explosion splashes never alert monsters. This is because A_Explode has // a separate parameter for that so this would get in the way of proper // behavior. - fixedvec3 pos = self->_f_PosRelative(floorsec); - pos.z = self->_f_floorz(); + DVector3 pos = self->PosRelative(floorsec); + pos.Z = self->floorz; P_HitWater (self, floorsec, pos, false, false); } } @@ -5754,19 +5754,19 @@ void P_PlaySpawnSound(AActor *missile, AActor *spawner) // If there is no spawner use the spawn position. // But not in a silenced sector. if (!(missile->Sector->Flags & SECF_SILENT)) - S_Sound (missile->_f_X(), missile->_f_Y(), missile->_f_Z(), CHAN_WEAPON, missile->SeeSound, 1, ATTN_NORM); + S_Sound (missile->Pos(), CHAN_WEAPON, missile->SeeSound, 1, ATTN_NORM); } } } -static fixed_t GetDefaultSpeed(PClassActor *type) +static double GetDefaultSpeed(PClassActor *type) { if (type == NULL) return 0; else if (G_SkillProperty(SKILLP_FastMonsters) && type->FastSpeed >= 0) - return FLOAT2FIXED(type->FastSpeed); + return type->FastSpeed; else - return GetDefaultByType(type)->_f_speed(); + return GetDefaultByType(type)->Speed; } //--------------------------------------------------------------------------- @@ -5784,21 +5784,19 @@ AActor *P_SpawnMissile (AActor *source, AActor *dest, PClassActor *type, AActor { return NULL; } - return P_SpawnMissileXYZ (source->_f_X(), source->_f_Y(), source->_f_Z() + 32*FRACUNIT + source->_f_GetBobOffset(), - source, dest, type, true, owner); + return P_SpawnMissileXYZ (source->PosPlusZ(32 + source->GetBobOffset()), source, dest, type, true, owner); } -AActor *P_SpawnMissileZ (AActor *source, fixed_t z, AActor *dest, PClassActor *type) +AActor *P_SpawnMissileZ (AActor *source, double z, AActor *dest, PClassActor *type) { if (source == NULL) { return NULL; } - return P_SpawnMissileXYZ (source->_f_X(), source->_f_Y(), z, source, dest, type); + return P_SpawnMissileXYZ (source->PosAtZ(z), source, dest, type); } -AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, - AActor *source, AActor *dest, PClassActor *type, bool checkspawn, AActor *owner) +AActor *P_SpawnMissileXYZ (DVector3 pos, AActor *source, AActor *dest, PClassActor *type, bool checkspawn, AActor *owner) { if (source == NULL) { @@ -5812,12 +5810,11 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, return NULL; } - if (z != ONFLOORZ && z != ONCEILINGZ) + if (pos.Z != ONFLOORZ && pos.Z != ONCEILINGZ) { - z -= source->_f_floorclip(); + pos.Z -= source->Floorclip; } - DVector3 pos(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)); AActor *th = Spawn (type, pos, ALLOW_REPLACE); P_PlaySpawnSound(th, source); @@ -5841,9 +5838,9 @@ AActor *P_SpawnMissileXYZ (fixed_t x, fixed_t y, fixed_t z, velocity.Z = 0; } // [RH] Adjust the trajectory if the missile will go over the target's head. - else if (FIXED2FLOAT(z) - source->Z() >= dest->Height) + else if (pos.Z - source->Z() >= dest->Height) { - velocity.Z += (dest->Height - FIXED2FLOAT(z) + source->Z()); + velocity.Z += (dest->Height - pos.Z + source->Z()); } th->Vel = velocity.Resized(speed); @@ -5908,25 +5905,21 @@ AActor *P_OldSpawnMissile(AActor *source, AActor *owner, AActor *dest, PClassAct // //--------------------------------------------------------------------------- -AActor *P_SpawnMissileAngle (AActor *source, PClassActor *type, - angle_t angle, fixed_t vz) +AActor *P_SpawnMissileAngle (AActor *source, PClassActor *type, DAngle angle, double vz) { if (source == NULL) { return NULL; } - return P_SpawnMissileAngleZSpeed (source, source->_f_Z() + 32*FRACUNIT + source->_f_GetBobOffset(), - type, angle, vz, GetDefaultSpeed (type)); + return P_SpawnMissileAngleZSpeed (source, source->Z() + 32 + source->GetBobOffset(), type, angle, vz, GetDefaultSpeed (type)); } -AActor *P_SpawnMissileAngleZ (AActor *source, fixed_t z, - PClassActor *type, angle_t angle, fixed_t vz) +AActor *P_SpawnMissileAngleZ (AActor *source, double z, PClassActor *type, DAngle angle, double vz) { - return P_SpawnMissileAngleZSpeed (source, z, type, angle, vz, - GetDefaultSpeed (type)); + return P_SpawnMissileAngleZSpeed (source, z, type, angle, vz, GetDefaultSpeed (type)); } -AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, PClassActor *type) +AActor *P_SpawnMissileZAimed (AActor *source, double z, AActor *dest, PClassActor *type) { if (source == NULL) { @@ -5952,26 +5945,15 @@ AActor *P_SpawnMissileZAimed (AActor *source, fixed_t z, AActor *dest, PClassAct //--------------------------------------------------------------------------- // -// FUNC P_SpawnMissileAngleSpeed +// FUNC P_SpawnMissileAngleZSpeed // // Returns NULL if the missile exploded immediately, otherwise returns // a mobj_t pointer to the missile. // //--------------------------------------------------------------------------- -AActor *P_SpawnMissileAngleSpeed (AActor *source, PClassActor *type, - angle_t angle, fixed_t vz, fixed_t speed) -{ - if (source == NULL) - { - return NULL; - } - return P_SpawnMissileAngleZSpeed (source, source->_f_Z() + 32*FRACUNIT + source->_f_GetBobOffset(), - type, angle, vz, speed); -} - -AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, - PClassActor *type, angle_t angle, fixed_t vz, fixed_t speed, AActor *owner, bool checkspawn) +AActor *P_SpawnMissileAngleZSpeed (AActor *source, double z, + PClassActor *type, DAngle angle, double vz, double speed, AActor *owner, bool checkspawn) { if (source == NULL) { @@ -5981,17 +5963,17 @@ AActor *P_SpawnMissileAngleZSpeed (AActor *source, fixed_t z, if (z != ONFLOORZ && z != ONCEILINGZ) { - z -= source->_f_floorclip(); + z -= source->Floorclip; } - mo = Spawn (type, source->PosAtZ(FIXED2FLOAT(z)), ALLOW_REPLACE); + mo = Spawn (type, source->PosAtZ(z), ALLOW_REPLACE); P_PlaySpawnSound(mo, source); if (owner == NULL) owner = source; mo->target = owner; - mo->Angles.Yaw = ANGLE2DBL(angle); - mo->VelFromAngle(FIXED2DBL(speed)); - mo->Vel.Z = FIXED2DBL(vz); + mo->Angles.Yaw = angle; + mo->VelFromAngle(speed); + mo->Vel.Z = vz; if (mo->flags4 & MF4_SPECTRAL) { @@ -6597,7 +6579,7 @@ void PrintMiscActorInfo(AActor *query) Printf("\nTID: %d", query->tid); Printf("\nCoord= x: %f, y: %f, z:%f, floor:%f, ceiling:%f.", query->X(), query->Y(), query->Z(), - FIXED2DBL(query->_f_floorz()), query->ceilingz); + query->floorz, query->ceilingz); Printf("\nSpeed= %f, velocity= x:%f, y:%f, z:%f, combined:%f.\n", query->Speed, query->Vel.X, query->Vel.Y, query->Vel.Z, query->Vel.Length()); } diff --git a/src/p_switch.cpp b/src/p_switch.cpp index a79b7db3d..82067f624 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -309,7 +309,7 @@ bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *ques } if (playsound) { - S_Sound (pt[0], pt[1], 0, CHAN_VOICE|CHAN_LISTENERZ, sound, 1, ATTN_STATIC); + S_Sound (DVector3(FIXED2DBL(pt[0]), FIXED2DBL(pt[1]), 0), CHAN_VOICE|CHAN_LISTENERZ, sound, 1, ATTN_STATIC); } if (quest != NULL) { @@ -391,7 +391,7 @@ void DActiveButton::Tick () if (def != NULL) { m_Frame = -1; - S_Sound (m_X, m_Y, 0, CHAN_VOICE|CHAN_LISTENERZ, + S_Sound (DVector3(FIXED2DBL(m_X), FIXED2DBL(m_Y), 0), CHAN_VOICE|CHAN_LISTENERZ, def->Sound != 0 ? FSoundID(def->Sound) : FSoundID("switches/normbutn"), 1, ATTN_STATIC); bFlippable = false; diff --git a/src/p_user.cpp b/src/p_user.cpp index 15b79bed5..651ac0578 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -2106,7 +2106,7 @@ void P_FallingDamage (AActor *actor) } // The minimum amount of damage you take from falling in Strife // is 52. Ouch! - damage = vel / 25000; + damage = int(vel / (25000./65536.)); break; default: diff --git a/src/s_sound.cpp b/src/s_sound.cpp index 1c85f3d97..d275fc4f3 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1259,10 +1259,9 @@ void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, float volume // //========================================================================== -void S_Sound (fixed_t x, fixed_t y, fixed_t z, int channel, FSoundID sound_id, float volume, float attenuation) +void S_Sound(const DVector3 &pos, int channel, FSoundID sound_id, float volume, float attenuation) { - FVector3 pt(FIXED2FLOAT(x), FIXED2FLOAT(z), FIXED2FLOAT(y)); - S_StartSound (NULL, NULL, NULL, &pt, channel, sound_id, volume, attenuation); + S_StartSound (NULL, NULL, NULL, &pos, channel, sound_id, volume, attenuation); } //========================================================================== diff --git a/src/s_sound.h b/src/s_sound.h index 795232d1a..ad06195e1 100644 --- a/src/s_sound.h +++ b/src/s_sound.h @@ -230,11 +230,7 @@ void S_Sound (AActor *ent, int channel, FSoundID sfxid, float volume, float atte void S_SoundMinMaxDist (AActor *ent, int channel, FSoundID sfxid, float volume, float mindist, float maxdist); void S_Sound (const FPolyObj *poly, int channel, FSoundID sfxid, float volume, float attenuation); void S_Sound (const sector_t *sec, int channel, FSoundID sfxid, float volume, float attenuation); -void S_Sound (fixed_t x, fixed_t y, fixed_t z, int channel, FSoundID sfxid, float volume, float attenuation); -inline void S_Sound(const DVector3 &pos, int channel, FSoundID sfxid, float volume, float attenuation) -{ - S_Sound(FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), channel, sfxid, volume, attenuation); -} +void S_Sound(const DVector3 &pos, int channel, FSoundID sfxid, float volume, float attenuation); // sound channels // channel 0 never willingly overrides From a99ebc2356f9c80730501dbac7eadf489bade22a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Mar 2016 16:22:21 +0200 Subject: [PATCH 33/44] - floatified p_sight.cpp. --- src/d_dehacked.cpp | 8 +- src/p_maputl.h | 4 + src/p_mobj.cpp | 7 +- src/p_sight.cpp | 334 +++++++++++++++++++++------------------------ src/p_terrain.cpp | 6 +- src/p_terrain.h | 2 +- src/po_man.cpp | 6 +- src/po_man.h | 3 +- src/r_defs.h | 5 - src/s_sound.cpp | 3 +- 10 files changed, 180 insertions(+), 198 deletions(-) diff --git a/src/d_dehacked.cpp b/src/d_dehacked.cpp index eeaa12729..a7a378375 100644 --- a/src/d_dehacked.cpp +++ b/src/d_dehacked.cpp @@ -215,7 +215,7 @@ DehInfo deh = 2, // .KFAAC "PLAY", // Name of player sprite 255, // Rocket explosion style, 255=use cvar - FRACUNIT*2/3, // Rocket explosion alpha + 2./3., // Rocket explosion alpha false, // .NoAutofreeze 40, // BFG cells per shot }; @@ -1279,11 +1279,11 @@ static int PatchThing (int thingy) info->RenderStyle = STYLE_Normal; } } - // If this thing's speed is really low (i.e. meant to be a monster), - // bump it up, because all speeds are fixed point now. + // Speed could be either an int of fixed value, depending on its use + // If this value is very large it needs to be rescaled. if (fabs(info->Speed) >= 256) { - info->Speed /= FRACUNIT; + info->Speed /= 65536; } if (info->flags & MF_SPECIAL) diff --git a/src/p_maputl.h b/src/p_maputl.h index c1bfc6ecd..196ba5bdc 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -107,6 +107,10 @@ inline int P_PointOnDivlineSidePrecise(double x, double y, const divline_t *line return (y - line->y) * line->dx + (line->x - x) * line->dy > 0; } +inline int P_PointOnDivlineSidePrecise(const DVector2 &pos, const divline_t *line) +{ + return (pos.Y - line->y) * line->dx + (line->x - pos.X) * line->dy > 0; +} //========================================================================== // diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index ef639d7fa..a4f359d73 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -4784,8 +4784,7 @@ AActor *P_SpawnMapThing (FMapThing *mthing, int position) { polyspawns_t *polyspawn = new polyspawns_t; polyspawn->next = polyspawns; - polyspawn->x = FLOAT2FIXED(mthing->pos.X); - polyspawn->y = FLOAT2FIXED(mthing->pos.Y); + polyspawn->pos = mthing->pos; polyspawn->angle = mthing->angle; polyspawn->type = mentry->Special; polyspawns = polyspawn; @@ -5200,7 +5199,7 @@ void P_SpawnBlood (const DVector3 &pos, DAngle dir, int damage, AActor *originat double z = pr_spawnblood.Random2 () / 64.; th = Spawn(bloodcls, pos + DVector3(0, 0, z), NO_REPLACE); // GetBloodType already performed the replacement th->Vel.Z = 2; - th->Angles.Yaw = ANGLE2DBL(dir); + th->Angles.Yaw = dir; // [NG] Applying PUFFGETSOWNER to the blood will make it target the owner if (th->flags5 & MF5_PUFFGETSOWNER) th->target = originator; if (gameinfo.gametype & GAME_DoomChex) @@ -5937,7 +5936,7 @@ AActor *P_SpawnMissileZAimed (AActor *source, double z, AActor *dest, PClassActo an += pr_spawnmissile.Random2() * (16. / 360.); } dist = source->Distance2D (dest); - speed = FIXED2DBL(GetDefaultSpeed (type)); + speed = GetDefaultSpeed (type); dist /= speed; vz = dist != 0 ? (dest->Z() - source->Z())/dist : speed; return P_SpawnMissileAngleZSpeed (source, z, type, an, vz, speed); diff --git a/src/p_sight.cpp b/src/p_sight.cpp index cfa93baa1..d8f2ccf25 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -59,8 +59,8 @@ enum struct SightOpening { - fixed_t top; - fixed_t bottom; + double top; + double bottom; int range; int portalflags; @@ -72,9 +72,9 @@ struct SightOpening struct SightTask { - fixed_t frac; - fixed_t topslope; - fixed_t bottomslope; + double Frac; + double topslope; + double bottomslope; int direction; int portalgroup; }; @@ -85,23 +85,23 @@ static TArray portals(32); class SightCheck { - fixedvec3 sightstart; - fixedvec2 sightend; - fixed_t startfrac; + DVector3 sightstart; + DVector2 sightend; + double Startfrac; AActor * seeingthing; - fixed_t lastztop; // z at last line - fixed_t lastzbottom; // z at last line + double Lastztop; // z at last line + double Lastzbottom; // z at last line sector_t * lastsector; // last sector being entered by trace - fixed_t topslope, bottomslope; // slopes to top and bottom of target + double topslope, bottomslope; // slopes to top and bottom of target int Flags; - fdivline_t trace; + divline_t Trace; int portaldir; int portalgroup; bool portalfound; unsigned int myseethrough; - void P_SightOpening(SightOpening &open, const line_t *linedef, fixed_t x, fixed_t y); + void P_SightOpening(SightOpening &open, const line_t *linedef, double x, double y); bool PTR_SightTraverse (intercept_t *in); bool P_SightCheckLine (line_t *ld); int P_SightBlockLinesIterator (int x, int y); @@ -112,13 +112,13 @@ public: void init(AActor * t1, AActor * t2, sector_t *startsector, SightTask *task, int flags) { - sightstart = t1->_f_PosRelative(task->portalgroup); - sightend = t2->_f_PosRelative(task->portalgroup); - sightstart.z += t1->_f_height() - (t1->_f_height() >> 2); + sightstart = t1->PosRelative(task->portalgroup); + sightend = t2->PosRelative(task->portalgroup); + sightstart.Z += t1->Height / 2; - startfrac = task->frac; - trace = { sightstart.x, sightstart.y, sightend.x - sightstart.x, sightend.y - sightstart.y }; - lastztop = lastzbottom = sightstart.z; + Startfrac = task->Frac; + Trace = { sightstart.X, sightstart.Y, sightend.X - sightstart.X, sightend.Y - sightstart.Y }; + Lastztop = Lastzbottom = sightstart.Z; lastsector = startsector; seeingthing=t2; topslope = task->topslope; @@ -139,7 +139,7 @@ public: // //========================================================================== -void SightCheck::P_SightOpening(SightOpening &open, const line_t *linedef, fixed_t x, fixed_t y) +void SightCheck::P_SightOpening(SightOpening &open, const line_t *linedef, double x, double y) { open.portalflags = 0; sector_t *front = linedef->frontsector; @@ -159,14 +159,14 @@ void SightCheck::P_SightOpening(SightOpening &open, const line_t *linedef, fixed } - fixed_t fc = 0, ff = 0, bc = 0, bf = 0; + double fc = 0, ff = 0, bc = 0, bf = 0; if (linedef->flags & ML_PORTALCONNECT) { - if (!front->PortalBlocksSight(sector_t::ceiling)) fc = FIXED_MAX, open.portalflags |= SO_TOPFRONT; - if (!back->PortalBlocksSight(sector_t::ceiling)) bc = FIXED_MAX, open.portalflags |= SO_TOPBACK; - if (!front->PortalBlocksSight(sector_t::floor)) ff = FIXED_MIN, open.portalflags |= SO_BOTTOMFRONT; - if (!back->PortalBlocksSight(sector_t::floor)) bf = FIXED_MIN, open.portalflags |= SO_BOTTOMBACK; + if (!front->PortalBlocksSight(sector_t::ceiling)) fc = LINEOPEN_MAX, open.portalflags |= SO_TOPFRONT; + if (!back->PortalBlocksSight(sector_t::ceiling)) bc = LINEOPEN_MAX, open.portalflags |= SO_TOPBACK; + if (!front->PortalBlocksSight(sector_t::floor)) ff = LINEOPEN_MIN, open.portalflags |= SO_BOTTOMFRONT; + if (!back->PortalBlocksSight(sector_t::floor)) bf = LINEOPEN_MIN, open.portalflags |= SO_BOTTOMBACK; } if (fc == 0) fc = front->ceilingplane.ZatPoint(x, y); @@ -178,7 +178,7 @@ void SightCheck::P_SightOpening(SightOpening &open, const line_t *linedef, fixed open.top = MIN(fc, bc); // we only want to know if there is an opening, not how large it is. - open.range = open.bottom >= open.top ? 0 : 1; + open.range = open.bottom < open.top; } @@ -193,7 +193,7 @@ void SightCheck::P_SightOpening(SightOpening &open, const line_t *linedef, fixed bool SightCheck::PTR_SightTraverse (intercept_t *in) { line_t *li; - fixed_t slope; + double slope; SightOpening open; int frontflag = -1; @@ -207,8 +207,8 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) if ((i_compatflags & COMPATF_TRACE) && li->frontsector == li->backsector) return true; - fixed_t trX=trace.x + FixedMul (trace.dx, in->frac); - fixed_t trY=trace.y + FixedMul (trace.dy, in->frac); + double trX = Trace.x + Trace.dx * in->Frac; + double trY = Trace.y + Trace.dy * in->Frac; P_SightOpening (open, li, trX, trY); FLinePortal *lport = li->getPortal(); @@ -217,17 +217,17 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) return false; // stop // check bottom - if (open.bottom > FIXED_MIN) + if (open.bottom > LINEOPEN_MIN) { - slope = FixedDiv(open.bottom - sightstart.z, in->frac); + slope = (open.bottom - sightstart.Z) / in->Frac; if (slope > bottomslope) bottomslope = slope; } // check top - if (open.top < FIXED_MAX) + if (open.top < LINEOPEN_MAX) { - slope = FixedDiv(open.top - sightstart.z, in->frac); + slope = (open.top - sightstart.Z) / in->Frac; if (slope < topslope) topslope = slope; } @@ -235,7 +235,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) if (open.portalflags) { sector_t *frontsec, *backsec; - frontflag = P_PointOnLineSidePrecise(sightstart.x, sightstart.y, li); + frontflag = P_PointOnLineSidePrecise(sightstart, li); if (!frontflag) { frontsec = li->frontsector; @@ -251,16 +251,16 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) if (portaldir != sector_t::floor && (open.portalflags & SO_TOPBACK) && !(open.portalflags & SO_TOPFRONT)) { - portals.Push({ in->frac, topslope, bottomslope, sector_t::ceiling, backsec->SkyBoxes[sector_t::ceiling]->Sector->PortalGroup }); + portals.Push({ in->Frac, topslope, bottomslope, sector_t::ceiling, backsec->SkyBoxes[sector_t::ceiling]->Sector->PortalGroup }); } if (portaldir != sector_t::ceiling && (open.portalflags & SO_BOTTOMBACK) && !(open.portalflags & SO_BOTTOMFRONT)) { - portals.Push({ in->frac, topslope, bottomslope, sector_t::floor, backsec->SkyBoxes[sector_t::floor]->Sector->PortalGroup }); + portals.Push({ in->Frac, topslope, bottomslope, sector_t::floor, backsec->SkyBoxes[sector_t::floor]->Sector->PortalGroup }); } } if (lport) { - portals.Push({ in->frac, topslope, bottomslope, portaldir, lport->mDestination->frontsector->PortalGroup }); + portals.Push({ in->Frac, topslope, bottomslope, portaldir, lport->mDestination->frontsector->PortalGroup }); return false; } @@ -270,41 +270,39 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) // now handle 3D-floors if(li->frontsector->e->XFloor.ffloors.Size() || li->backsector->e->XFloor.ffloors.Size()) { - if (frontflag == -1) frontflag = P_PointOnLineSidePrecise(sightstart.x, sightstart.y, li); + if (frontflag == -1) frontflag = P_PointOnLineSidePrecise(sightstart, li); //Check 3D FLOORS! for(int i=1;i<=2;i++) { sector_t * s=i==1? li->frontsector:li->backsector; - fixed_t highslope, lowslope; + double highslope, lowslope; - fixed_t topz= FixedMul (topslope, in->frac) + sightstart.z; - fixed_t bottomz= FixedMul (bottomslope, in->frac) + sightstart.z; + double topz= topslope * in->Frac + sightstart.Z; + double bottomz= bottomslope * in->Frac + sightstart.Z; - for(unsigned int j=0;je->XFloor.ffloors.Size();j++) + for (auto rover : s->e->XFloor.ffloors) { - F3DFloor* rover=s->e->XFloor.ffloors[j]; - - if((rover->flags & FF_SEETHROUGH) == myseethrough || !(rover->flags & FF_EXISTS)) continue; + if ((rover->flags & FF_SEETHROUGH) == myseethrough || !(rover->flags & FF_EXISTS)) continue; if ((Flags & SF_IGNOREWATERBOUNDARY) && (rover->flags & FF_SOLID) == 0) continue; - - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(trX, trY); - fixed_t ff_top=rover->top.plane->ZatPoint(trX, trY); - highslope = FixedDiv (ff_top - sightstart.z, in->frac); - lowslope = FixedDiv (ff_bottom - sightstart.z, in->frac); + double ff_bottom = rover->bottom.plane->ZatPoint(trX, trY); + double ff_top = rover->top.plane->ZatPoint(trX, trY); - if (highslope>=topslope) + highslope = (ff_top - sightstart.Z) / in->Frac; + lowslope = (ff_bottom - sightstart.Z) / in->Frac; + + if (highslope >= topslope) { // blocks completely - if (lowslope<=bottomslope) return false; + if (lowslope <= bottomslope) return false; // blocks upper edge of view - if (lowslopebottomslope) bottomslope=highslope; + if (highslope > bottomslope) bottomslope = highslope; } else { @@ -312,39 +310,37 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) // itself it can't be view blocking. // However, if there's a 3D-floor on the other side that obstructs the same vertical range // the 2 together will block sight. - sector_t * sb=i==2? li->frontsector:li->backsector; + sector_t * sb = i == 2 ? li->frontsector : li->backsector; - for(unsigned int k=0;ke->XFloor.ffloors.Size();k++) + for (auto rover2 : sb->e->XFloor.ffloors) { - F3DFloor* rover2=sb->e->XFloor.ffloors[k]; - - if((rover2->flags & FF_SEETHROUGH) == myseethrough || !(rover2->flags & FF_EXISTS)) continue; + if ((rover2->flags & FF_SEETHROUGH) == myseethrough || !(rover2->flags & FF_EXISTS)) continue; if ((Flags & SF_IGNOREWATERBOUNDARY) && (rover->flags & FF_SOLID) == 0) continue; - - fixed_t ffb_bottom=rover2->bottom.plane->ZatPoint(trX, trY); - fixed_t ffb_top=rover2->top.plane->ZatPoint(trX, trY); - if ( (ffb_bottom >= ff_bottom && ffb_bottom<=ff_top) || + double ffb_bottom = rover2->bottom.plane->ZatPoint(trX, trY); + double ffb_top = rover2->top.plane->ZatPoint(trX, trY); + + if ((ffb_bottom >= ff_bottom && ffb_bottom <= ff_top) || (ffb_top <= ff_top && ffb_top >= ff_bottom) || (ffb_top >= ff_top && ffb_bottom <= ff_bottom) || - (ffb_top <= ff_top && ffb_bottom >= ff_bottom) ) + (ffb_top <= ff_top && ffb_bottom >= ff_bottom)) { return false; } } } // trace is leaving a sector with a 3d-floor - if (s==lastsector && frontflag==i-1) + if (s == lastsector && frontflag == i - 1) { // upper slope intersects with this 3d-floor - if (lastztop<=ff_bottom && topz>ff_top) + if (Lastztop <= ff_bottom && topz > ff_top) { - topslope=lowslope; + topslope = lowslope; } // lower slope intersects with this 3d-floor - if (lastzbottom>=ff_top && bottomz= ff_top && bottomz < ff_top) { - bottomslope=highslope; + bottomslope = highslope; } } if (topslope <= bottomslope) return false; // stop @@ -354,8 +350,8 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) } else lastsector=NULL; // don't need it if there are no 3D-floors - lastztop= FixedMul (topslope, in->frac) + sightstart.z; - lastzbottom= FixedMul (bottomslope, in->frac) + sightstart.z; + Lastztop = (topslope * in->Frac) + sightstart.Z; + Lastzbottom = (bottomslope * in->Frac) + sightstart.Z; return true; // keep going } @@ -372,21 +368,21 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) bool SightCheck::P_SightCheckLine (line_t *ld) { - fdivline_t dl; + divline_t dl; if (ld->validcount == validcount) { return true; } ld->validcount = validcount; - if (P_PointOnDivlineSidePrecise (ld->v1->x, ld->v1->y, &trace) == - P_PointOnDivlineSidePrecise (ld->v2->x, ld->v2->y, &trace)) + if (P_PointOnDivlineSidePrecise (ld->v1->fPos(), &Trace) == + P_PointOnDivlineSidePrecise (ld->v2->fPos(), &Trace)) { return true; // line isn't crossed } P_MakeDivline (ld, &dl); - if (P_PointOnDivlineSidePrecise (trace.x, trace.y, &dl) == - P_PointOnDivlineSidePrecise (trace.x+trace.dx, trace.y+trace.dy, &dl)) + if (P_PointOnDivlineSidePrecise (Trace.x, Trace.y, &dl) == + P_PointOnDivlineSidePrecise (Trace.x+Trace.dx, Trace.y+Trace.dy, &dl)) { return true; // line isn't crossed } @@ -505,10 +501,10 @@ int SightCheck::P_SightBlockLinesIterator (int x, int y) bool SightCheck::P_SightTraverseIntercepts () { unsigned count; - fixed_t dist; + double dist; intercept_t *scan, *in; unsigned scanpos; - fdivline_t dl; + divline_t dl; count = intercepts.Size (); // @@ -518,10 +514,10 @@ bool SightCheck::P_SightTraverseIntercepts () { scan = &intercepts[scanpos]; P_MakeDivline (scan->d.line, &dl); - scan->frac = P_InterceptVector (&trace, &dl); - if (scan->frac < startfrac) + scan->Frac = P_InterceptVector (&Trace, &dl); + if (scan->Frac < Startfrac) { - scan->frac = FIXED_MAX; + scan->Frac = INT_MAX; count--; } } @@ -534,13 +530,13 @@ bool SightCheck::P_SightTraverseIntercepts () while (count--) { - dist = FIXED_MAX; + dist = INT_MAX; for (scanpos = 0; scanpos < intercepts.Size (); scanpos++) { scan = &intercepts[scanpos]; - if (scan->frac < dist) + if (scan->Frac < dist) { - dist = scan->frac; + dist = scan->Frac; in = scan; } } @@ -549,31 +545,28 @@ bool SightCheck::P_SightTraverseIntercepts () { if (!PTR_SightTraverse (in)) return false; // don't bother going farther - in->frac = FIXED_MAX; + in->Frac = INT_MAX; } } - if (lastsector==seeingthing->Sector && lastsector->e->XFloor.ffloors.Size()) + if (lastsector == seeingthing->Sector && lastsector->e->XFloor.ffloors.Size()) { // we must do one last check whether the trace has crossed a 3D floor in the last sector - fixed_t topz= topslope + sightstart.z; - fixed_t bottomz= bottomslope + sightstart.z; - - for(unsigned int i=0;ie->XFloor.ffloors.Size();i++) + double topz = topslope + sightstart.Z; + double bottomz = bottomslope + sightstart.Z; + + for (auto rover : lastsector->e->XFloor.ffloors) { - F3DFloor* rover = lastsector->e->XFloor.ffloors[i]; - - if((rover->flags & FF_SOLID) == myseethrough || !(rover->flags & FF_EXISTS)) continue; + if ((rover->flags & FF_SOLID) == myseethrough || !(rover->flags & FF_EXISTS)) continue; if ((Flags & SF_IGNOREWATERBOUNDARY) && (rover->flags & FF_SOLID) == 0) continue; - - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(seeingthing); - fixed_t ff_top=rover->top.plane->ZatPoint(seeingthing); - if (lastztop<=ff_bottom && topz>ff_bottom && lastzbottom<=ff_bottom && bottomz>ff_bottom) return false; - if (lastzbottom>=ff_top && bottomz=ff_top && topzbottom.plane->ZatPointF(seeingthing); + double ff_top = rover->top.plane->ZatPointF(seeingthing); + + if (Lastztop <= ff_bottom && topz > ff_bottom && Lastzbottom <= ff_bottom && bottomz > ff_bottom) return false; + if (Lastzbottom >= ff_top && bottomz < ff_top && Lastztop >= ff_top && topz < ff_top) return false; } - } return true; // everything was traversed } @@ -592,40 +585,37 @@ bool SightCheck::P_SightTraverseIntercepts () bool SightCheck::P_SightPathTraverse () { - fixed_t x1, x2, y1, y2; - fixed_t xt1,yt1,xt2,yt2; - long long _x1,_y1,_x2,_y2; - fixed_t xstep,ystep; - fixed_t partialx, partialy; - fixed_t xintercept, yintercept; + double x1, x2, y1, y2; + double xt1,yt1,xt2,yt2; + double xstep,ystep; + double partialx, partialy; + double xintercept, yintercept; int mapx, mapy, mapxstep, mapystep; int count; validcount++; intercepts.Clear (); - x1 = sightstart.x + FixedMul(startfrac, trace.dx); - y1 = sightstart.y + FixedMul(startfrac, trace.dy); - x2 = sightend.x; - y2 = sightend.y; + x1 = sightstart.X + Startfrac * Trace.dx; + y1 = sightstart.Y + Startfrac * Trace.dy; + x2 = sightend.X; + y2 = sightend.Y; if (lastsector == NULL) lastsector = P_PointInSector(x1, y1); // for FF_SEETHROUGH the following rule applies: // If the viewer is in an area without FF_SEETHROUGH he can only see into areas without this flag // If the viewer is in an area with FF_SEETHROUGH he can only see into areas with this flag bool checkfloor = true, checkceiling = true; - for(unsigned int i=0;ie->XFloor.ffloors.Size();i++) + for(auto rover : lastsector->e->XFloor.ffloors) { - F3DFloor* rover = lastsector->e->XFloor.ffloors[i]; - if(!(rover->flags & FF_EXISTS)) continue; - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sightstart); - fixed_t ff_top=rover->top.plane->ZatPoint(sightstart); + double ff_bottom=rover->bottom.plane->ZatPoint(sightstart); + double ff_top=rover->top.plane->ZatPoint(sightstart); - if (sightstart.z < ff_top) checkceiling = false; - if (sightstart.z >= ff_bottom) checkfloor = false; + if (sightstart.Z < ff_top) checkceiling = false; + if (sightstart.Z >= ff_bottom) checkfloor = false; - if (sightstart.z < ff_top && sightstart.z >= ff_bottom) + if (sightstart.Z < ff_top && sightstart.Z >= ff_bottom) { myseethrough = rover->flags & FF_SEETHROUGH; break; @@ -642,92 +632,88 @@ bool SightCheck::P_SightPathTraverse () portals.Push({ 0, topslope, bottomslope, sector_t::floor, lastsector->SkyBoxes[sector_t::floor]->Sector->PortalGroup }); } - if ( ((x1-bmaporgx)&(MAPBLOCKSIZE-1)) == 0) - x1 += FRACUNIT; // don't side exactly on a line - if ( ((y1-bmaporgy)&(MAPBLOCKSIZE-1)) == 0) - y1 += FRACUNIT; // don't side exactly on a line + double bmaporgx = FIXED2DBL(::bmaporgx); + double bmaporgy = FIXED2DBL(::bmaporgy); - _x1 = (long long)x1 - bmaporgx; - _y1 = (long long)y1 - bmaporgy; x1 -= bmaporgx; y1 -= bmaporgy; - xt1 = int(_x1 >> MAPBLOCKSHIFT); - yt1 = int(_y1 >> MAPBLOCKSHIFT); + xt1 = x1 / MAPBLOCKUNITS; + yt1 = y1 / MAPBLOCKUNITS; - _x2 = (long long)x2 - bmaporgx; - _y2 = (long long)y2 - bmaporgy; x2 -= bmaporgx; y2 -= bmaporgy; - xt2 = int(_x2 >> MAPBLOCKSHIFT); - yt2 = int(_y2 >> MAPBLOCKSHIFT); + xt2 = x2 / MAPBLOCKUNITS; + yt2 = y2 / MAPBLOCKUNITS; - if (xt2 > xt1) + mapx = int(xt1); + mapy = int(yt1); + int mapex = int(xt2); + int mapey = int(yt2); + + if (mapex > mapx) { mapxstep = 1; - partialx = FRACUNIT - ((x1>>MAPBTOFRAC)&(FRACUNIT-1)); - ystep = FixedDiv (y2-y1,abs(x2-x1)); + partialx = xs_CeilToInt(xt1) - xt1; + ystep = (y2 - y1) / fabs(x2 - x1); } - else if (xt2 < xt1) + else if (mapex < mapx) { mapxstep = -1; - partialx = (x1>>MAPBTOFRAC)&(FRACUNIT-1); - ystep = FixedDiv (y2-y1,abs(x2-x1)); + partialx = xt1 - xs_FloorToInt(xt1); + ystep = (y2 - y1) / fabs(x2 - x1); } else { mapxstep = 0; - partialx = FRACUNIT; - ystep = 256*FRACUNIT; + partialx = 1.; + ystep = 256; } - yintercept = int(_y1>>MAPBTOFRAC) + FixedMul (partialx, ystep); + yintercept = yt1 + partialx * ystep; - - if (yt2 > yt1) + if (mapey > mapy) { mapystep = 1; - partialy = FRACUNIT - ((y1>>MAPBTOFRAC)&(FRACUNIT-1)); - xstep = FixedDiv (x2-x1,abs(y2-y1)); + partialy = xs_CeilToInt(yt1) - yt1; + xstep = (x2 - x1) / fabs(y2 - y1); } - else if (yt2 < yt1) + else if (mapey < mapy) { mapystep = -1; - partialy = (y1>>MAPBTOFRAC)&(FRACUNIT-1); - xstep = FixedDiv (x2-x1,abs(y2-y1)); + partialy = yt1 - xs_FloorToInt(yt1); + xstep = (x2 - x1) / fabs(y2 - y1); } else { mapystep = 0; - partialy = FRACUNIT; - xstep = 256*FRACUNIT; + partialy = 1; + xstep = 256; } - xintercept = int(_x1>>MAPBTOFRAC) + FixedMul (partialy, xstep); + xintercept = xt1 + partialy * xstep; // [RH] Fix for traces that pass only through blockmap corners. In that case, // xintercept and yintercept can both be set ahead of mapx and mapy, so the // for loop would never advance anywhere. - if (abs(xstep) == FRACUNIT && abs(ystep) == FRACUNIT) + if (fabs(xstep) == 1. && fabs(ystep) == 1.) { if (ystep < 0) { - partialx = FRACUNIT - partialx; + partialx = 1. - partialx; } if (xstep < 0) { - partialy = FRACUNIT - partialy; + partialy = 1. - partialy; } if (partialx == partialy) { - xintercept = xt1 << FRACBITS; - yintercept = yt1 << FRACBITS; + xintercept = xt1; + yintercept = yt1; } } // // step through map blocks // Count is present to prevent a round off error from skipping the break - mapx = xt1; - mapy = yt1; for (count = 0 ; count < 100 ; count++) { @@ -748,7 +734,7 @@ bool SightCheck::P_SightPathTraverse () if (res == -1 || (mapxstep | mapystep) == 0) break; - switch ((((yintercept >> FRACBITS) == mapy) << 1) | ((xintercept >> FRACBITS) == mapx)) + switch (((int(yintercept) == mapy) << 1) | (int(xintercept) == mapx)) { case 0: // neither xintercept nor yintercept match! sightcounts[5]++; @@ -759,14 +745,14 @@ sightcounts[5]++; case 1: // xintercept matches xintercept += xstep; mapy += mapystep; - if (mapy == yt2) + if (mapy == mapey) mapystep = 0; break; case 2: // yintercept matches yintercept += ystep; mapx += mapxstep; - if (mapx == xt2) + if (mapx == mapex) mapxstep = 0; break; @@ -786,9 +772,9 @@ sightcounts[1]++; yintercept += ystep; mapx += mapxstep; mapy += mapystep; - if (mapx == xt2) + if (mapx == mapex) mapxstep = 0; - if (mapy == yt2) + if (mapy == mapey) mapystep = 0; break; } @@ -863,16 +849,16 @@ sightcounts[0]++; if (!(flags & SF_IGNOREWATERBOUNDARY)) { if ((s1->GetHeightSec() && - ((t1->_f_Z() + t1->_f_height() <= s1->heightsec->floorplane.ZatPoint(t1) && - t2->_f_Z() >= s1->heightsec->floorplane.ZatPoint(t2)) || - (t1->_f_Z() >= s1->heightsec->ceilingplane.ZatPoint(t1) && - t2->_f_Z() + t1->_f_height() <= s1->heightsec->ceilingplane.ZatPoint(t2)))) + ((t1->top() <= s1->heightsec->floorplane.ZatPointF(t1) && + t2->Z() >= s1->heightsec->floorplane.ZatPointF(t2)) || + (t1->Z() >= s1->heightsec->ceilingplane.ZatPointF(t1) && + t2->top() <= s1->heightsec->ceilingplane.ZatPointF(t2)))) || (s2->GetHeightSec() && - ((t2->_f_Z() + t2->_f_height() <= s2->heightsec->floorplane.ZatPoint(t2) && - t1->_f_Z() >= s2->heightsec->floorplane.ZatPoint(t1)) || - (t2->_f_Z() >= s2->heightsec->ceilingplane.ZatPoint(t2) && - t1->_f_Z() + t2->_f_height() <= s2->heightsec->ceilingplane.ZatPoint(t1))))) + ((t2->top() <= s2->heightsec->floorplane.ZatPointF(t2) && + t1->Z() >= s2->heightsec->floorplane.ZatPointF(t1)) || + (t2->Z() >= s2->heightsec->ceilingplane.ZatPointF(t2) && + t1->top() <= s2->heightsec->ceilingplane.ZatPointF(t1))))) { res = false; goto done; @@ -886,11 +872,11 @@ sightcounts[0]++; portals.Clear(); { sector_t *sec; - fixed_t lookheight = t1->_f_height() - (t1->_f_height() >> 2); + double lookheight = t1->Center(); t1->GetPortalTransition(lookheight, &sec); - fixed_t bottomslope = t2->_f_Z() - (t1->_f_Z() + lookheight); - fixed_t topslope = bottomslope + t2->_f_height(); + double bottomslope = t2->Z() - (t1->Z() + lookheight); + double topslope = bottomslope + t2->Height; SightTask task = { 0, topslope, bottomslope, -1, sec->PortalGroup }; @@ -902,7 +888,7 @@ sightcounts[0]++; double dist = t1->Distance2D(t2); for (unsigned i = 0; i < portals.Size(); i++) { - portals[i].frac += FLOAT2FIXED(1 / dist); + portals[i].Frac += 1 / dist; s.init(t1, t2, NULL, &portals[i], flags); if (s.P_SightPathTraverse()) { @@ -940,5 +926,3 @@ void P_ResetSightCounters (bool full) SightCycles.Reset(); memset (sightcounts, 0, sizeof(sightcounts)); } - - diff --git a/src/p_terrain.cpp b/src/p_terrain.cpp index f99652758..9a377f214 100644 --- a/src/p_terrain.cpp +++ b/src/p_terrain.cpp @@ -194,7 +194,7 @@ static FGenericParse SplashParser[] = { { GEN_End, {0} }, { GEN_Sound, {myoffsetof(FSplashDef, SmallSplashSound)} }, - { GEN_Fixed, {myoffsetof(FSplashDef, SmallSplashClip)} }, + { GEN_Double, {myoffsetof(FSplashDef, SmallSplashClip)} }, { GEN_Sound, {myoffsetof(FSplashDef, NormalSplashSound)} }, { GEN_Class, {myoffsetof(FSplashDef, SmallSplash)} }, { GEN_Class, {myoffsetof(FSplashDef, SplashBase)} }, @@ -202,7 +202,7 @@ static FGenericParse SplashParser[] = { GEN_Byte, {myoffsetof(FSplashDef, ChunkXVelShift)} }, { GEN_Byte, {myoffsetof(FSplashDef, ChunkYVelShift)} }, { GEN_Byte, {myoffsetof(FSplashDef, ChunkZVelShift)} }, - { GEN_Double, {myoffsetof(FSplashDef, ChunkBaseZVel)} }, + { GEN_Double, {myoffsetof(FSplashDef, ChunkBaseZVel)} }, { GEN_Bool, {myoffsetof(FSplashDef, NoAlert)} } }; @@ -362,7 +362,7 @@ static void SetSplashDefaults (FSplashDef *splashdef) splashdef->ChunkYVelShift = splashdef->ChunkZVelShift = 8; splashdef->ChunkBaseZVel = 1; - splashdef->SmallSplashClip = 12*FRACUNIT; + splashdef->SmallSplashClip = 12.; splashdef->NoAlert = false; } diff --git a/src/p_terrain.h b/src/p_terrain.h index e8e6544d0..2a15eb976 100644 --- a/src/p_terrain.h +++ b/src/p_terrain.h @@ -97,7 +97,7 @@ struct FSplashDef BYTE ChunkZVelShift; bool NoAlert; double ChunkBaseZVel; - fixed_t SmallSplashClip; + double SmallSplashClip; }; struct FTerrainDef diff --git a/src/po_man.cpp b/src/po_man.cpp index f083da738..c43d094ae 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -1730,8 +1730,8 @@ void PO_Init (void) if (polyspawn->type >= SMT_PolySpawn && polyspawn->type <= SMT_PolySpawnHurt) { // Polyobj StartSpot Pt. - polyobjs[polyIndex].StartSpot.x = polyspawn->x; - polyobjs[polyIndex].StartSpot.y = polyspawn->y; + polyobjs[polyIndex].StartSpot.x = FLOAT2FIXED(polyspawn->pos.X); + polyobjs[polyIndex].StartSpot.y = FLOAT2FIXED(polyspawn->pos.Y); SpawnPolyobj(polyIndex, polyspawn->angle, polyspawn->type); polyIndex++; *prev = polyspawn->next; @@ -1750,7 +1750,7 @@ void PO_Init (void) if (polyspawn->type == SMT_PolyAnchor) { // Polyobj Anchor Pt. - TranslateToStartSpot (polyspawn->angle, polyspawn->x, polyspawn->y); + TranslateToStartSpot (polyspawn->angle, FLOAT2FIXED(polyspawn->pos.X), FLOAT2FIXED(polyspawn->pos.Y)); } delete polyspawn; polyspawn = next; diff --git a/src/po_man.h b/src/po_man.h index be3b958b2..eedaeac54 100644 --- a/src/po_man.h +++ b/src/po_man.h @@ -128,8 +128,7 @@ bool EV_StopPoly (int polyNum); struct polyspawns_t { polyspawns_t *next; - fixed_t x; - fixed_t y; + DVector2 pos; short angle; short type; }; diff --git a/src/r_defs.h b/src/r_defs.h index a578e6bb8..37b0389de 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -306,11 +306,6 @@ struct secplane_t return FixedMul (ic, -d - DMulScale16 (a, x, b, y)); } - double _f_ZatPointF(fixed_t x, fixed_t y) const - { - return FIXED2DBL(FixedMul(ic, -d - DMulScale16(a, x, b, y))); - } - // Returns the value of z at (x,y) as a double double ZatPoint (double x, double y) const { diff --git a/src/s_sound.cpp b/src/s_sound.cpp index d275fc4f3..9f049fa00 100644 --- a/src/s_sound.cpp +++ b/src/s_sound.cpp @@ -1261,7 +1261,8 @@ void S_Sound (const FPolyObj *poly, int channel, FSoundID sound_id, float volume void S_Sound(const DVector3 &pos, int channel, FSoundID sound_id, float volume, float attenuation) { - S_StartSound (NULL, NULL, NULL, &pos, channel, sound_id, volume, attenuation); + FVector3 p((float)pos.X, (float)pos.Y, (float)pos.Z); + S_StartSound (NULL, NULL, NULL, &p, channel, sound_id, volume, attenuation); } //========================================================================== From b5f333798ed09e9c66570eb9b110ebf3dc8a1a85 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Mar 2016 17:27:55 +0200 Subject: [PATCH 34/44] - moved all scroller related code into its own file, including the DScroller class definition. --- src/CMakeLists.txt | 1 + src/dobject.h | 2 + src/dthinker.h | 1 + src/g_level.cpp | 2 +- src/g_level.h | 2 +- src/p_lnspec.cpp | 131 +-------- src/p_scroll.cpp | 719 +++++++++++++++++++++++++++++++++++++++++++++ src/p_spec.cpp | 494 +------------------------------ src/p_spec.h | 78 ++--- src/po_man.h | 1 + 10 files changed, 766 insertions(+), 665 deletions(-) create mode 100644 src/p_scroll.cpp diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index d23eb084a..4a8101d79 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1071,6 +1071,7 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE p_plats.cpp p_pspr.cpp p_saveg.cpp + p_scroll.cpp p_sectors.cpp p_setup.cpp p_sight.cpp diff --git a/src/dobject.h b/src/dobject.h index 22e612723..682e9bb08 100644 --- a/src/dobject.h +++ b/src/dobject.h @@ -42,6 +42,7 @@ class PClass; class FArchive; class DObject; +/* class DArgs; class DCanvas; class DConsoleCommand; @@ -77,6 +78,7 @@ class DFloor; class DFloorWaggle; class DPlat; class DPillar; +*/ class PClassActor; diff --git a/src/dthinker.h b/src/dthinker.h index c7b92730c..10a53309d 100644 --- a/src/dthinker.h +++ b/src/dthinker.h @@ -42,6 +42,7 @@ class AActor; class player_t; struct pspdef_s; struct FState; +class DThinker; class FThinkerIterator; diff --git a/src/g_level.cpp b/src/g_level.cpp index 844311092..1a626a40c 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -2023,7 +2023,7 @@ void FLevelLocals::Tick () // //========================================================================== -void FLevelLocals::AddScroller (DScroller *scroller, int secnum) +void FLevelLocals::AddScroller (int secnum) { if (secnum < 0) { diff --git a/src/g_level.h b/src/g_level.h index ca70b654b..17a2a1920 100644 --- a/src/g_level.h +++ b/src/g_level.h @@ -383,7 +383,7 @@ struct FSectorScrollValues struct FLevelLocals { void Tick (); - void AddScroller (DScroller *, int secnum); + void AddScroller (int secnum); int time; // time in the hub int maptime; // time in the map diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index bc70388ae..ca17a4f20 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -2145,17 +2145,11 @@ FUNC(LS_Sector_ChangeFlags) return rtn; } -struct FThinkerCollection -{ - int RefNum; - DThinker *Obj; -}; - -static TArray Collection; void AdjustPusher (int tag, int magnitude, int angle, DPusher::EPusher type) { // Find pushers already attached to the sector, and change their parameters. + TArray Collection; { TThinkerIterator iterator; FThinkerCollection collect; @@ -2188,7 +2182,6 @@ void AdjustPusher (int tag, int magnitude, int angle, DPusher::EPusher type) new DPusher (type, NULL, magnitude, angle, NULL, secnum); } } - Collection.Clear (); } FUNC(LS_Sector_SetWind) @@ -2249,76 +2242,9 @@ FUNC(LS_Sector_SetLink) return false; } +void SetWallScroller(int id, int sidechoice, fixed_t dx, fixed_t dy, EScrollPos Where); +void SetScroller(int tag, EScroll type, fixed_t dx, fixed_t dy); -static void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, int Where) -{ - Where &=7; - if (Where == 0) return; - - if ((dx | dy) == 0) - { - // Special case: Remove the scroller, because the deltas are both 0. - TThinkerIterator iterator (STAT_SCROLLER); - DScroller *scroller; - - while ( (scroller = iterator.Next ()) ) - { - int wallnum = scroller->GetWallNum (); - - if (wallnum >= 0 && tagManager.LineHasID(sides[wallnum].linedef, id) && - int(sides[wallnum].linedef->sidedef[sidechoice] - sides) == wallnum && - Where == scroller->GetScrollParts()) - { - scroller->Destroy (); - } - } - } - else - { - // Find scrollers already attached to the matching walls, and change - // their rates. - { - TThinkerIterator iterator (STAT_SCROLLER); - FThinkerCollection collect; - - while ( (collect.Obj = iterator.Next ()) ) - { - if ((collect.RefNum = ((DScroller *)collect.Obj)->GetWallNum ()) != -1 && - tagManager.LineHasID(sides[collect.RefNum].linedef, id) && - int(sides[collect.RefNum].linedef->sidedef[sidechoice] - sides) == collect.RefNum && - Where == ((DScroller *)collect.Obj)->GetScrollParts()) - { - ((DScroller *)collect.Obj)->SetRate (dx, dy); - Collection.Push (collect); - } - } - } - - size_t numcollected = Collection.Size (); - int linenum; - - // Now create scrollers for any walls that don't already have them. - FLineIdIterator itr(id); - while ((linenum = itr.Next()) >= 0) - { - if (lines[linenum].sidedef[sidechoice] != NULL) - { - int sidenum = int(lines[linenum].sidedef[sidechoice] - sides); - unsigned int i; - for (i = 0; i < numcollected; i++) - { - if (Collection[i].RefNum == sidenum) - break; - } - if (i == numcollected) - { - new DScroller (DScroller::sc_side, dx, dy, -1, sidenum, 0, Where); - } - } - } - Collection.Clear (); - } -} FUNC(LS_Scroll_Texture_Both) // Scroll_Texture_Both (id, left, right, up, down) @@ -2340,7 +2266,7 @@ FUNC(LS_Scroll_Texture_Both) sidechoice = 0; } - SetWallScroller (arg0, sidechoice, dx, dy, 7); + SetWallScroller (arg0, sidechoice, dx, dy, scw_all); return true; } @@ -2351,47 +2277,10 @@ FUNC(LS_Scroll_Wall) if (arg0 == 0) return false; - SetWallScroller (arg0, !!arg3, arg1, arg2, arg4); + SetWallScroller (arg0, !!arg3, arg1, arg2, EScrollPos(arg4)); return true; } -static void SetScroller (int tag, DScroller::EScrollType type, fixed_t dx, fixed_t dy) -{ - TThinkerIterator iterator (STAT_SCROLLER); - DScroller *scroller; - int i; - - // Check if there is already a scroller for this tag - // If at least one sector with this tag is scrolling, then they all are. - // If the deltas are both 0, we don't remove the scroller, because a - // displacement/accelerative scroller might have been set up, and there's - // no way to create one after the level is fully loaded. - i = 0; - while ( (scroller = iterator.Next ()) ) - { - if (scroller->IsType (type)) - { - if (tagManager.SectorHasTag(scroller->GetAffectee (), tag)) - { - i++; - scroller->SetRate (dx, dy); - } - } - } - - if (i > 0 || (dx|dy) == 0) - { - return; - } - - // Need to create scrollers for the sector(s) - FSectorTagIterator itr(tag); - while ((i = itr.Next()) >= 0) - { - new DScroller (type, dx, dy, -1, i, 0); - } -} - // NOTE: For the next two functions, x-move and y-move are // 0-based, not 128-based as they are if they appear on lines. // Note also that parameter ordering is different. @@ -2404,19 +2293,19 @@ FUNC(LS_Scroll_Floor) if (arg3 == 0 || arg3 == 2) { - SetScroller (arg0, DScroller::sc_floor, -dx, dy); + SetScroller (arg0, EScroll::sc_floor, -dx, dy); } else { - SetScroller (arg0, DScroller::sc_floor, 0, 0); + SetScroller (arg0, EScroll::sc_floor, 0, 0); } if (arg3 > 0) { - SetScroller (arg0, DScroller::sc_carry, dx, dy); + SetScroller (arg0, EScroll::sc_carry, dx, dy); } else { - SetScroller (arg0, DScroller::sc_carry, 0, 0); + SetScroller (arg0, EScroll::sc_carry, 0, 0); } return true; } @@ -2427,7 +2316,7 @@ FUNC(LS_Scroll_Ceiling) fixed_t dx = arg1 * FRACUNIT/32; fixed_t dy = arg2 * FRACUNIT/32; - SetScroller (arg0, DScroller::sc_ceiling, -dx, dy); + SetScroller (arg0, EScroll::sc_ceiling, -dx, dy); return true; } diff --git a/src/p_scroll.cpp b/src/p_scroll.cpp new file mode 100644 index 000000000..96889b624 --- /dev/null +++ b/src/p_scroll.cpp @@ -0,0 +1,719 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id:$ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This source is available for distribution and/or modification +// only under the terms of the DOOM Source Code License as +// published by id Software. All rights reserved. +// +// The source is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License +// for more details. +// +// $Log:$ +// +// DESCRIPTION: +// Initializes and implements BOOM linedef triggers for +// Scrollers/Conveyors +// +//----------------------------------------------------------------------------- + + +#include +#include "actor.h" +#include "p_spec.h" +#include "farchive.h" +#include "p_lnspec.h" +#include "r_data/r_interpolate.h" + +//----------------------------------------------------------------------------- +// +// killough 3/7/98: Add generalized scroll effects +// +//----------------------------------------------------------------------------- + +class DScroller : public DThinker +{ + DECLARE_CLASS (DScroller, DThinker) + HAS_OBJECT_POINTERS +public: + + DScroller (EScroll type, fixed_t dx, fixed_t dy, int control, int affectee, int accel, EScrollPos scrollpos = EScrollPos::scw_all); + DScroller (fixed_t dx, fixed_t dy, const line_t *l, int control, int accel, EScrollPos scrollpos = EScrollPos::scw_all); + void Destroy(); + + void Serialize (FArchive &arc); + void Tick (); + + bool AffectsWall (int wallnum) const { return m_Type == EScroll::sc_side && m_Affectee == wallnum; } + int GetWallNum () const { return m_Type == EScroll::sc_side ? m_Affectee : -1; } + void SetRate (fixed_t dx, fixed_t dy) { m_dx = dx; m_dy = dy; } + bool IsType (EScroll type) const { return type == m_Type; } + int GetAffectee () const { return m_Affectee; } + EScrollPos GetScrollParts() const { return m_Parts; } + +protected: + EScroll m_Type; // Type of scroll effect + fixed_t m_dx, m_dy; // (dx,dy) scroll speeds + int m_Affectee; // Number of affected sidedef, sector, tag, or whatever + int m_Control; // Control sector (-1 if none) used to control scrolling + fixed_t m_LastHeight; // Last known height of control sector + fixed_t m_vdx, m_vdy; // Accumulated velocity if accelerative + int m_Accel; // Whether it's accelerative + EScrollPos m_Parts; // Which parts of a sidedef are being scrolled? + TObjPtr m_Interpolations[3]; + +private: + DScroller () + { + } +}; + + +IMPLEMENT_POINTY_CLASS (DScroller) + DECLARE_POINTER (m_Interpolations[0]) + DECLARE_POINTER (m_Interpolations[1]) + DECLARE_POINTER (m_Interpolations[2]) +END_POINTERS + + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +inline FArchive &operator<< (FArchive &arc, EScroll &type) +{ + BYTE val = (BYTE)type; + arc << val; + type = (EScroll)val; + return arc; +} + +inline FArchive &operator<< (FArchive &arc, EScrollPos &type) +{ + int val = (int)type; + arc << val; + type = (EScrollPos)val; + return arc; +} + +EScrollPos operator &(EScrollPos one, EScrollPos two) +{ + return EScrollPos(int(one) & int(two)); +} + +//----------------------------------------------------------------------------- +// +// +// +//----------------------------------------------------------------------------- + +void DScroller::Serialize (FArchive &arc) +{ + Super::Serialize (arc); + arc << m_Type + << m_dx << m_dy + << m_Affectee + << m_Control + << m_LastHeight + << m_vdx << m_vdy + << m_Accel + << m_Parts + << m_Interpolations[0] + << m_Interpolations[1] + << m_Interpolations[2]; +} + +//----------------------------------------------------------------------------- +// +// [RH] Compensate for rotated sector textures by rotating the scrolling +// in the opposite direction. +// +//----------------------------------------------------------------------------- + +static void RotationComp(const sector_t *sec, int which, fixed_t dx, fixed_t dy, fixed_t &tdx, fixed_t &tdy) +{ + angle_t an = sec->GetAngle(which); + if (an == 0) + { + tdx = dx; + tdy = dy; + } + else + { + an = an >> ANGLETOFINESHIFT; + fixed_t ca = -finecosine[an]; + fixed_t sa = -finesine[an]; + tdx = DMulScale16(dx, ca, -dy, sa); + tdy = DMulScale16(dy, ca, dx, sa); + } +} + +//----------------------------------------------------------------------------- +// +// killough 2/28/98: +// +// This function, with the help of r_plane.c and r_bsp.c, supports generalized +// scrolling floors and walls, with optional mobj-carrying properties, e.g. +// conveyor belts, rivers, etc. A linedef with a special type affects all +// tagged sectors the same way, by creating scrolling and/or object-carrying +// properties. Multiple linedefs may be used on the same sector and are +// cumulative, although the special case of scrolling a floor and carrying +// things on it, requires only one linedef. The linedef's direction determines +// the scrolling direction, and the linedef's length determines the scrolling +// speed. This was designed so that an edge around the sector could be used to +// control the direction of the sector's scrolling, which is usually what is +// desired. +// +// Process the active scrollers. +// +// This is the main scrolling code +// killough 3/7/98 +// +//----------------------------------------------------------------------------- + +void DScroller::Tick () +{ + fixed_t dx = m_dx, dy = m_dy, tdx, tdy; + + if (m_Control != -1) + { // compute scroll amounts based on a sector's height changes + fixed_t height = sectors[m_Control].CenterFloor () + + sectors[m_Control].CenterCeiling (); + fixed_t delta = height - m_LastHeight; + m_LastHeight = height; + dx = FixedMul(dx, delta); + dy = FixedMul(dy, delta); + } + + // killough 3/14/98: Add acceleration + if (m_Accel) + { + m_vdx = dx += m_vdx; + m_vdy = dy += m_vdy; + } + + if (!(dx | dy)) // no-op if both (x,y) offsets are 0 + return; + + switch (m_Type) + { + case EScroll::sc_side: // killough 3/7/98: Scroll wall texture + if (m_Parts & EScrollPos::scw_top) + { + sides[m_Affectee].AddTextureXOffset(side_t::top, dx); + sides[m_Affectee].AddTextureYOffset(side_t::top, dy); + } + if (m_Parts & EScrollPos::scw_mid && (sides[m_Affectee].linedef->backsector == NULL || + !(sides[m_Affectee].linedef->flags&ML_3DMIDTEX))) + { + sides[m_Affectee].AddTextureXOffset(side_t::mid, dx); + sides[m_Affectee].AddTextureYOffset(side_t::mid, dy); + } + if (m_Parts & EScrollPos::scw_bottom) + { + sides[m_Affectee].AddTextureXOffset(side_t::bottom, dx); + sides[m_Affectee].AddTextureYOffset(side_t::bottom, dy); + } + break; + + case EScroll::sc_floor: // killough 3/7/98: Scroll floor texture + RotationComp(§ors[m_Affectee], sector_t::floor, dx, dy, tdx, tdy); + sectors[m_Affectee].AddXOffset(sector_t::floor, tdx); + sectors[m_Affectee].AddYOffset(sector_t::floor, tdy); + break; + + case EScroll::sc_ceiling: // killough 3/7/98: Scroll ceiling texture + RotationComp(§ors[m_Affectee], sector_t::ceiling, dx, dy, tdx, tdy); + sectors[m_Affectee].AddXOffset(sector_t::ceiling, tdx); + sectors[m_Affectee].AddYOffset(sector_t::ceiling, tdy); + break; + + // [RH] Don't actually carry anything here. That happens later. + case EScroll::sc_carry: + level.Scrolls[m_Affectee].ScrollX += dx; + level.Scrolls[m_Affectee].ScrollY += dy; + break; + + case EScroll::sc_carry_ceiling: // to be added later + break; + } +} + +//----------------------------------------------------------------------------- +// +// Add_Scroller() +// +// Add a generalized scroller to the thinker list. +// +// type: the enumerated type of scrolling: floor, ceiling, floor carrier, +// wall, floor carrier & scroller +// +// (dx,dy): the direction and speed of the scrolling or its acceleration +// +// control: the sector whose heights control this scroller's effect +// remotely, or -1 if no control sector +// +// affectee: the index of the affected object (sector or sidedef) +// +// accel: non-zero if this is an accelerative effect +// +//----------------------------------------------------------------------------- + +DScroller::DScroller (EScroll type, fixed_t dx, fixed_t dy, + int control, int affectee, int accel, EScrollPos scrollpos) + : DThinker (STAT_SCROLLER) +{ + m_Type = type; + m_dx = dx; + m_dy = dy; + m_Accel = accel; + m_Parts = scrollpos; + m_vdx = m_vdy = 0; + if ((m_Control = control) != -1) + m_LastHeight = + sectors[control].CenterFloor () + sectors[control].CenterCeiling (); + m_Affectee = affectee; + m_Interpolations[0] = m_Interpolations[1] = m_Interpolations[2] = NULL; + + switch (type) + { + case EScroll::sc_carry: + level.AddScroller (affectee); + break; + + case EScroll::sc_side: + sides[affectee].Flags |= WALLF_NOAUTODECALS; + if (m_Parts & EScrollPos::scw_top) + { + m_Interpolations[0] = sides[m_Affectee].SetInterpolation(side_t::top); + } + if (m_Parts & EScrollPos::scw_mid && (sides[m_Affectee].linedef->backsector == NULL || + !(sides[m_Affectee].linedef->flags&ML_3DMIDTEX))) + { + m_Interpolations[1] = sides[m_Affectee].SetInterpolation(side_t::mid); + } + if (m_Parts & EScrollPos::scw_bottom) + { + m_Interpolations[2] = sides[m_Affectee].SetInterpolation(side_t::bottom); + } + break; + + case EScroll::sc_floor: + m_Interpolations[0] = sectors[affectee].SetInterpolation(sector_t::FloorScroll, false); + break; + + case EScroll::sc_ceiling: + m_Interpolations[0] = sectors[affectee].SetInterpolation(sector_t::CeilingScroll, false); + break; + + default: + break; + } +} + +void DScroller::Destroy () +{ + for(int i=0;i<3;i++) + { + if (m_Interpolations[i] != NULL) + { + m_Interpolations[i]->DelRef(); + m_Interpolations[i] = NULL; + } + } + Super::Destroy(); +} + +//----------------------------------------------------------------------------- +// +// Adds wall scroller. Scroll amount is rotated with respect to wall's +// linedef first, so that scrolling towards the wall in a perpendicular +// direction is translated into vertical motion, while scrolling along +// the wall in a parallel direction is translated into horizontal motion. +// +// killough 5/25/98: cleaned up arithmetic to avoid drift due to roundoff +// +//----------------------------------------------------------------------------- + +DScroller::DScroller (fixed_t dx, fixed_t dy, const line_t *l, + int control, int accel, EScrollPos scrollpos) + : DThinker (STAT_SCROLLER) +{ + fixed_t x = abs(l->dx), y = abs(l->dy), d; + if (y > x) + d = x, x = y, y = d; + d = FixedDiv (x, finesine[(tantoangle[FixedDiv(y,x) >> DBITS] + ANG90) + >> ANGLETOFINESHIFT]); + x = -FixedDiv (FixedMul(dy, l->dy) + FixedMul(dx, l->dx), d); + y = -FixedDiv (FixedMul(dx, l->dy) - FixedMul(dy, l->dx), d); + + m_Type = EScroll::sc_side; + m_dx = x; + m_dy = y; + m_vdx = m_vdy = 0; + m_Accel = accel; + m_Parts = scrollpos; + if ((m_Control = control) != -1) + m_LastHeight = sectors[control].CenterFloor() + sectors[control].CenterCeiling(); + m_Affectee = int(l->sidedef[0] - sides); + sides[m_Affectee].Flags |= WALLF_NOAUTODECALS; + m_Interpolations[0] = m_Interpolations[1] = m_Interpolations[2] = NULL; + + if (m_Parts & EScrollPos::scw_top) + { + m_Interpolations[0] = sides[m_Affectee].SetInterpolation(side_t::top); + } + if (m_Parts & EScrollPos::scw_mid && (sides[m_Affectee].linedef->backsector == NULL || + !(sides[m_Affectee].linedef->flags&ML_3DMIDTEX))) + { + m_Interpolations[1] = sides[m_Affectee].SetInterpolation(side_t::mid); + } + if (m_Parts & EScrollPos::scw_bottom) + { + m_Interpolations[2] = sides[m_Affectee].SetInterpolation(side_t::bottom); + } +} + +// Amount (dx,dy) vector linedef is shifted right to get scroll amount +#define SCROLL_SHIFT 5 +#define SCROLLTYPE(i) EScrollPos(((i) <= 0) || ((i) & ~7) ? 7 : (i)) + +//----------------------------------------------------------------------------- +// +// Initialize the scrollers +// +//----------------------------------------------------------------------------- + +void P_SpawnScrollers(void) +{ + int i; + line_t *l = lines; + TArray copyscrollers; + + for (i = 0; i < numlines; i++) + { + if (lines[i].special == Sector_CopyScroller) + { + // don't allow copying the scroller if the sector has the same tag as it would just duplicate it. + if (!tagManager.SectorHasTag(lines[i].frontsector, lines[i].args[0])) + { + copyscrollers.Push(i); + } + lines[i].special = 0; + } + } + + for (i = 0; i < numlines; i++, l++) + { + fixed_t dx; // direction and speed of scrolling + fixed_t dy; + int control = -1, accel = 0; // no control sector or acceleration + int special = l->special; + + // Check for undefined parameters that are non-zero and output messages for them. + // We don't report for specials we don't understand. + FLineSpecial *spec = P_GetLineSpecialInfo(special); + if (spec != NULL) + { + int max = spec->map_args; + for (unsigned arg = max; arg < countof(l->args); ++arg) + { + if (l->args[arg] != 0) + { + Printf("Line %d (type %d:%s), arg %u is %d (should be 0)\n", + i, special, spec->name, arg+1, l->args[arg]); + } + } + } + + // killough 3/7/98: Types 245-249 are same as 250-254 except that the + // first side's sector's heights cause scrolling when they change, and + // this linedef controls the direction and speed of the scrolling. The + // most complicated linedef since donuts, but powerful :) + // + // killough 3/15/98: Add acceleration. Types 214-218 are the same but + // are accelerative. + + // [RH] Assume that it's a scroller and zero the line's special. + l->special = 0; + + dx = dy = 0; // Shut up, GCC + + if (special == Scroll_Ceiling || + special == Scroll_Floor || + special == Scroll_Texture_Model) + { + if (l->args[1] & 3) + { + // if 1, then displacement + // if 2, then accelerative (also if 3) + control = int(l->sidedef[0]->sector - sectors); + if (l->args[1] & 2) + accel = 1; + } + if (special == Scroll_Texture_Model || + l->args[1] & 4) + { + // The line housing the special controls the + // direction and speed of scrolling. + dx = l->dx >> SCROLL_SHIFT; + dy = l->dy >> SCROLL_SHIFT; + } + else + { + // The speed and direction are parameters to the special. + dx = (l->args[3] - 128) * (FRACUNIT / 32); + dy = (l->args[4] - 128) * (FRACUNIT / 32); + } + } + + switch (special) + { + int s; + + case Scroll_Ceiling: + { + FSectorTagIterator itr(l->args[0]); + while ((s = itr.Next()) >= 0) + { + new DScroller(EScroll::sc_ceiling, -dx, dy, control, s, accel); + } + for (unsigned j = 0; j < copyscrollers.Size(); j++) + { + line_t *line = &lines[copyscrollers[j]]; + + if (line->args[0] == l->args[0] && (line->args[1] & 1)) + { + new DScroller(EScroll::sc_ceiling, -dx, dy, control, int(line->frontsector - sectors), accel); + } + } + break; + } + + case Scroll_Floor: + if (l->args[2] != 1) + { // scroll the floor texture + FSectorTagIterator itr(l->args[0]); + while ((s = itr.Next()) >= 0) + { + new DScroller (EScroll::sc_floor, -dx, dy, control, s, accel); + } + for(unsigned j = 0;j < copyscrollers.Size(); j++) + { + line_t *line = &lines[copyscrollers[j]]; + + if (line->args[0] == l->args[0] && (line->args[1] & 2)) + { + new DScroller (EScroll::sc_floor, -dx, dy, control, int(line->frontsector-sectors), accel); + } + } + } + + if (l->args[2] > 0) + { // carry objects on the floor + FSectorTagIterator itr(l->args[0]); + while ((s = itr.Next()) >= 0) + { + new DScroller (EScroll::sc_carry, dx, dy, control, s, accel); + } + for(unsigned j = 0;j < copyscrollers.Size(); j++) + { + line_t *line = &lines[copyscrollers[j]]; + + if (line->args[0] == l->args[0] && (line->args[1] & 4)) + { + new DScroller (EScroll::sc_carry, dx, dy, control, int(line->frontsector-sectors), accel); + } + } + } + break; + + // killough 3/1/98: scroll wall according to linedef + // (same direction and speed as scrolling floors) + case Scroll_Texture_Model: + { + FLineIdIterator itr(l->args[0]); + while ((s = itr.Next()) >= 0) + { + if (s != i) + new DScroller(dx, dy, lines + s, control, accel); + } + break; + } + + case Scroll_Texture_Offsets: + // killough 3/2/98: scroll according to sidedef offsets + s = int(lines[i].sidedef[0] - sides); + new DScroller (EScroll::sc_side, -sides[s].GetTextureXOffset(side_t::mid), + sides[s].GetTextureYOffset(side_t::mid), -1, s, accel, SCROLLTYPE(l->args[0])); + break; + + case Scroll_Texture_Left: + l->special = special; // Restore the special, for compat_useblocking's benefit. + s = int(lines[i].sidedef[0] - sides); + new DScroller (EScroll::sc_side, l->args[0] * (FRACUNIT/64), 0, + -1, s, accel, SCROLLTYPE(l->args[1])); + break; + + case Scroll_Texture_Right: + l->special = special; + s = int(lines[i].sidedef[0] - sides); + new DScroller (EScroll::sc_side, l->args[0] * (-FRACUNIT/64), 0, + -1, s, accel, SCROLLTYPE(l->args[1])); + break; + + case Scroll_Texture_Up: + l->special = special; + s = int(lines[i].sidedef[0] - sides); + new DScroller (EScroll::sc_side, 0, l->args[0] * (FRACUNIT/64), + -1, s, accel, SCROLLTYPE(l->args[1])); + break; + + case Scroll_Texture_Down: + l->special = special; + s = int(lines[i].sidedef[0] - sides); + new DScroller (EScroll::sc_side, 0, l->args[0] * (-FRACUNIT/64), + -1, s, accel, SCROLLTYPE(l->args[1])); + break; + + case Scroll_Texture_Both: + s = int(lines[i].sidedef[0] - sides); + if (l->args[0] == 0) { + dx = (l->args[1] - l->args[2]) * (FRACUNIT/64); + dy = (l->args[4] - l->args[3]) * (FRACUNIT/64); + new DScroller (EScroll::sc_side, dx, dy, -1, s, accel); + } + break; + + default: + // [RH] It wasn't a scroller after all, so restore the special. + l->special = special; + break; + } + } +} + +//----------------------------------------------------------------------------- +// +// Modify a wall scroller +// +//----------------------------------------------------------------------------- + +void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, EScrollPos Where) +{ + Where = Where & scw_all; + if (Where == 0) return; + + if ((dx | dy) == 0) + { + // Special case: Remove the scroller, because the deltas are both 0. + TThinkerIterator iterator (STAT_SCROLLER); + DScroller *scroller; + + while ( (scroller = iterator.Next ()) ) + { + int wallnum = scroller->GetWallNum (); + + if (wallnum >= 0 && tagManager.LineHasID(sides[wallnum].linedef, id) && + int(sides[wallnum].linedef->sidedef[sidechoice] - sides) == wallnum && + Where == scroller->GetScrollParts()) + { + scroller->Destroy (); + } + } + } + else + { + // Find scrollers already attached to the matching walls, and change + // their rates. + TArray Collection; + { + TThinkerIterator iterator (STAT_SCROLLER); + FThinkerCollection collect; + + while ( (collect.Obj = iterator.Next ()) ) + { + if ((collect.RefNum = ((DScroller *)collect.Obj)->GetWallNum ()) != -1 && + tagManager.LineHasID(sides[collect.RefNum].linedef, id) && + int(sides[collect.RefNum].linedef->sidedef[sidechoice] - sides) == collect.RefNum && + Where == ((DScroller *)collect.Obj)->GetScrollParts()) + { + ((DScroller *)collect.Obj)->SetRate (dx, dy); + Collection.Push (collect); + } + } + } + + size_t numcollected = Collection.Size (); + int linenum; + + // Now create scrollers for any walls that don't already have them. + FLineIdIterator itr(id); + while ((linenum = itr.Next()) >= 0) + { + if (lines[linenum].sidedef[sidechoice] != NULL) + { + int sidenum = int(lines[linenum].sidedef[sidechoice] - sides); + unsigned int i; + for (i = 0; i < numcollected; i++) + { + if (Collection[i].RefNum == sidenum) + break; + } + if (i == numcollected) + { + new DScroller (EScroll::sc_side, dx, dy, -1, sidenum, 0, Where); + } + } + } + } +} + +void SetScroller (int tag, EScroll type, fixed_t dx, fixed_t dy) +{ + TThinkerIterator iterator (STAT_SCROLLER); + DScroller *scroller; + int i; + + // Check if there is already a scroller for this tag + // If at least one sector with this tag is scrolling, then they all are. + // If the deltas are both 0, we don't remove the scroller, because a + // displacement/accelerative scroller might have been set up, and there's + // no way to create one after the level is fully loaded. + i = 0; + while ( (scroller = iterator.Next ()) ) + { + if (scroller->IsType (type)) + { + if (tagManager.SectorHasTag(scroller->GetAffectee (), tag)) + { + i++; + scroller->SetRate (dx, dy); + } + } + } + + if (i > 0 || (dx|dy) == 0) + { + return; + } + + // Need to create scrollers for the sector(s) + FSectorTagIterator itr(tag); + while ((i = itr.Next()) >= 0) + { + new DScroller (type, dx, dy, -1, i, 0); + } +} + +void P_CreateScroller(EScroll type, fixed_t dx, fixed_t dy, int control, int affectee, int accel, EScrollPos scrollpos) +{ + new DScroller(type, dx, dy, control, affectee, accel, scrollpos); +} diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 7e14f1ec3..700cf2c1e 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -84,44 +84,10 @@ static FRandom pr_playerinspecialsector ("PlayerInSpecialSector"); EXTERN_CVAR(Bool, cl_predict_specials) -IMPLEMENT_POINTY_CLASS (DScroller) - DECLARE_POINTER (m_Interpolations[0]) - DECLARE_POINTER (m_Interpolations[1]) - DECLARE_POINTER (m_Interpolations[2]) -END_POINTERS - IMPLEMENT_POINTY_CLASS (DPusher) DECLARE_POINTER (m_Source) END_POINTERS -inline FArchive &operator<< (FArchive &arc, DScroller::EScrollType &type) -{ - BYTE val = (BYTE)type; - arc << val; - type = (DScroller::EScrollType)val; - return arc; -} - -DScroller::DScroller () -{ -} - -void DScroller::Serialize (FArchive &arc) -{ - Super::Serialize (arc); - arc << m_Type - << m_dx << m_dy - << m_Affectee - << m_Control - << m_LastHeight - << m_vdx << m_vdy - << m_Accel - << m_Parts - << m_Interpolations[0] - << m_Interpolations[1] - << m_Interpolations[2]; -} - DPusher::DPusher () { } @@ -149,7 +115,7 @@ void DPusher::Serialize (FArchive &arc) } // killough 3/7/98: Initialize generalized scrolling -static void P_SpawnScrollers(); +void P_SpawnScrollers(); static void P_SpawnFriction (); // phares 3/16/98 static void P_SpawnPushers (); // phares 3/20/98 @@ -1243,7 +1209,7 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) if (!nothinkers) { new DStrobe(sector, STROBEBRIGHT, FASTDARK, false); - new DScroller(DScroller::sc_floor, -((FRACUNIT / 2) << 3), + P_CreateScroller(EScroll::sc_floor, -((FRACUNIT / 2) << 3), 0, -1, int(sector - sectors), 0); } keepspecial = true; @@ -1304,13 +1270,13 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) int i = sector->special - Scroll_North_Slow; fixed_t dx = hexenScrollies[i][0] * (FRACUNIT/2); fixed_t dy = hexenScrollies[i][1] * (FRACUNIT/2); - if (!nothinkers) new DScroller (DScroller::sc_floor, dx, dy, -1, int(sector-sectors), 0); + if (!nothinkers) P_CreateScroller(EScroll::sc_floor, dx, dy, -1, int(sector-sectors), 0); } else if (sector->special >= Carry_East5 && sector->special <= Carry_East35) { // Heretic scroll special // Only east scrollers also scroll the texture - if (!nothinkers) new DScroller (DScroller::sc_floor, + if (!nothinkers) P_CreateScroller(EScroll::sc_floor, (-FRACUNIT/2)<<(sector->special - Carry_East5), 0, -1, int(sector-sectors), 0); } @@ -1533,458 +1499,6 @@ void P_SpawnSpecials (void) FBehavior::StaticStartTypedScripts (SCRIPT_Open, NULL, false); } -// killough 2/28/98: -// -// This function, with the help of r_plane.c and r_bsp.c, supports generalized -// scrolling floors and walls, with optional mobj-carrying properties, e.g. -// conveyor belts, rivers, etc. A linedef with a special type affects all -// tagged sectors the same way, by creating scrolling and/or object-carrying -// properties. Multiple linedefs may be used on the same sector and are -// cumulative, although the special case of scrolling a floor and carrying -// things on it, requires only one linedef. The linedef's direction determines -// the scrolling direction, and the linedef's length determines the scrolling -// speed. This was designed so that an edge around the sector could be used to -// control the direction of the sector's scrolling, which is usually what is -// desired. -// -// Process the active scrollers. -// -// This is the main scrolling code -// killough 3/7/98 - -// [RH] Compensate for rotated sector textures by rotating the scrolling -// in the opposite direction. -static void RotationComp(const sector_t *sec, int which, fixed_t dx, fixed_t dy, fixed_t &tdx, fixed_t &tdy) -{ - angle_t an = sec->GetAngle(which); - if (an == 0) - { - tdx = dx; - tdy = dy; - } - else - { - an = an >> ANGLETOFINESHIFT; - fixed_t ca = -finecosine[an]; - fixed_t sa = -finesine[an]; - tdx = DMulScale16(dx, ca, -dy, sa); - tdy = DMulScale16(dy, ca, dx, sa); - } -} - -void DScroller::Tick () -{ - fixed_t dx = m_dx, dy = m_dy, tdx, tdy; - - if (m_Control != -1) - { // compute scroll amounts based on a sector's height changes - fixed_t height = sectors[m_Control].CenterFloor () + - sectors[m_Control].CenterCeiling (); - fixed_t delta = height - m_LastHeight; - m_LastHeight = height; - dx = FixedMul(dx, delta); - dy = FixedMul(dy, delta); - } - - // killough 3/14/98: Add acceleration - if (m_Accel) - { - m_vdx = dx += m_vdx; - m_vdy = dy += m_vdy; - } - - if (!(dx | dy)) // no-op if both (x,y) offsets are 0 - return; - - switch (m_Type) - { - case sc_side: // killough 3/7/98: Scroll wall texture - if (m_Parts & scw_top) - { - sides[m_Affectee].AddTextureXOffset(side_t::top, dx); - sides[m_Affectee].AddTextureYOffset(side_t::top, dy); - } - if (m_Parts & scw_mid && (sides[m_Affectee].linedef->backsector == NULL || - !(sides[m_Affectee].linedef->flags&ML_3DMIDTEX))) - { - sides[m_Affectee].AddTextureXOffset(side_t::mid, dx); - sides[m_Affectee].AddTextureYOffset(side_t::mid, dy); - } - if (m_Parts & scw_bottom) - { - sides[m_Affectee].AddTextureXOffset(side_t::bottom, dx); - sides[m_Affectee].AddTextureYOffset(side_t::bottom, dy); - } - break; - - case sc_floor: // killough 3/7/98: Scroll floor texture - RotationComp(§ors[m_Affectee], sector_t::floor, dx, dy, tdx, tdy); - sectors[m_Affectee].AddXOffset(sector_t::floor, tdx); - sectors[m_Affectee].AddYOffset(sector_t::floor, tdy); - break; - - case sc_ceiling: // killough 3/7/98: Scroll ceiling texture - RotationComp(§ors[m_Affectee], sector_t::ceiling, dx, dy, tdx, tdy); - sectors[m_Affectee].AddXOffset(sector_t::ceiling, tdx); - sectors[m_Affectee].AddYOffset(sector_t::ceiling, tdy); - break; - - // [RH] Don't actually carry anything here. That happens later. - case sc_carry: - level.Scrolls[m_Affectee].ScrollX += dx; - level.Scrolls[m_Affectee].ScrollY += dy; - break; - - case sc_carry_ceiling: // to be added later - break; - } -} - -// -// Add_Scroller() -// -// Add a generalized scroller to the thinker list. -// -// type: the enumerated type of scrolling: floor, ceiling, floor carrier, -// wall, floor carrier & scroller -// -// (dx,dy): the direction and speed of the scrolling or its acceleration -// -// control: the sector whose heights control this scroller's effect -// remotely, or -1 if no control sector -// -// affectee: the index of the affected object (sector or sidedef) -// -// accel: non-zero if this is an accelerative effect -// - -DScroller::DScroller (EScrollType type, fixed_t dx, fixed_t dy, - int control, int affectee, int accel, int scrollpos) - : DThinker (STAT_SCROLLER) -{ - m_Type = type; - m_dx = dx; - m_dy = dy; - m_Accel = accel; - m_Parts = scrollpos; - m_vdx = m_vdy = 0; - if ((m_Control = control) != -1) - m_LastHeight = - sectors[control].CenterFloor () + sectors[control].CenterCeiling (); - m_Affectee = affectee; - m_Interpolations[0] = m_Interpolations[1] = m_Interpolations[2] = NULL; - - switch (type) - { - case sc_carry: - level.AddScroller (this, affectee); - break; - - case sc_side: - sides[affectee].Flags |= WALLF_NOAUTODECALS; - if (m_Parts & scw_top) - { - m_Interpolations[0] = sides[m_Affectee].SetInterpolation(side_t::top); - } - if (m_Parts & scw_mid && (sides[m_Affectee].linedef->backsector == NULL || - !(sides[m_Affectee].linedef->flags&ML_3DMIDTEX))) - { - m_Interpolations[1] = sides[m_Affectee].SetInterpolation(side_t::mid); - } - if (m_Parts & scw_bottom) - { - m_Interpolations[2] = sides[m_Affectee].SetInterpolation(side_t::bottom); - } - break; - - case sc_floor: - m_Interpolations[0] = sectors[affectee].SetInterpolation(sector_t::FloorScroll, false); - break; - - case sc_ceiling: - m_Interpolations[0] = sectors[affectee].SetInterpolation(sector_t::CeilingScroll, false); - break; - - default: - break; - } -} - -void DScroller::Destroy () -{ - for(int i=0;i<3;i++) - { - if (m_Interpolations[i] != NULL) - { - m_Interpolations[i]->DelRef(); - m_Interpolations[i] = NULL; - } - } - Super::Destroy(); -} - -// Adds wall scroller. Scroll amount is rotated with respect to wall's -// linedef first, so that scrolling towards the wall in a perpendicular -// direction is translated into vertical motion, while scrolling along -// the wall in a parallel direction is translated into horizontal motion. -// -// killough 5/25/98: cleaned up arithmetic to avoid drift due to roundoff - -DScroller::DScroller (fixed_t dx, fixed_t dy, const line_t *l, - int control, int accel, int scrollpos) - : DThinker (STAT_SCROLLER) -{ - fixed_t x = abs(l->dx), y = abs(l->dy), d; - if (y > x) - d = x, x = y, y = d; - d = FixedDiv (x, finesine[(tantoangle[FixedDiv(y,x) >> DBITS] + ANG90) - >> ANGLETOFINESHIFT]); - x = -FixedDiv (FixedMul(dy, l->dy) + FixedMul(dx, l->dx), d); - y = -FixedDiv (FixedMul(dx, l->dy) - FixedMul(dy, l->dx), d); - - m_Type = sc_side; - m_dx = x; - m_dy = y; - m_vdx = m_vdy = 0; - m_Accel = accel; - m_Parts = scrollpos; - if ((m_Control = control) != -1) - m_LastHeight = sectors[control].CenterFloor() + sectors[control].CenterCeiling(); - m_Affectee = int(l->sidedef[0] - sides); - sides[m_Affectee].Flags |= WALLF_NOAUTODECALS; - m_Interpolations[0] = m_Interpolations[1] = m_Interpolations[2] = NULL; - - if (m_Parts & scw_top) - { - m_Interpolations[0] = sides[m_Affectee].SetInterpolation(side_t::top); - } - if (m_Parts & scw_mid && (sides[m_Affectee].linedef->backsector == NULL || - !(sides[m_Affectee].linedef->flags&ML_3DMIDTEX))) - { - m_Interpolations[1] = sides[m_Affectee].SetInterpolation(side_t::mid); - } - if (m_Parts & scw_bottom) - { - m_Interpolations[2] = sides[m_Affectee].SetInterpolation(side_t::bottom); - } -} - -// Amount (dx,dy) vector linedef is shifted right to get scroll amount -#define SCROLL_SHIFT 5 -#define SCROLLTYPE(i) (((i) <= 0) || ((i) & ~7) ? 7 : (i)) - -// Initialize the scrollers -static void P_SpawnScrollers(void) -{ - int i; - line_t *l = lines; - TArray copyscrollers; - - for (i = 0; i < numlines; i++) - { - if (lines[i].special == Sector_CopyScroller) - { - // don't allow copying the scroller if the sector has the same tag as it would just duplicate it. - if (!tagManager.SectorHasTag(lines[i].frontsector, lines[i].args[0])) - { - copyscrollers.Push(i); - } - lines[i].special = 0; - } - } - - for (i = 0; i < numlines; i++, l++) - { - fixed_t dx; // direction and speed of scrolling - fixed_t dy; - int control = -1, accel = 0; // no control sector or acceleration - int special = l->special; - - // Check for undefined parameters that are non-zero and output messages for them. - // We don't report for specials we don't understand. - FLineSpecial *spec = P_GetLineSpecialInfo(special); - if (spec != NULL) - { - int max = spec->map_args; - for (unsigned arg = max; arg < countof(l->args); ++arg) - { - if (l->args[arg] != 0) - { - Printf("Line %d (type %d:%s), arg %u is %d (should be 0)\n", - i, special, spec->name, arg+1, l->args[arg]); - } - } - } - - // killough 3/7/98: Types 245-249 are same as 250-254 except that the - // first side's sector's heights cause scrolling when they change, and - // this linedef controls the direction and speed of the scrolling. The - // most complicated linedef since donuts, but powerful :) - // - // killough 3/15/98: Add acceleration. Types 214-218 are the same but - // are accelerative. - - // [RH] Assume that it's a scroller and zero the line's special. - l->special = 0; - - dx = dy = 0; // Shut up, GCC - - if (special == Scroll_Ceiling || - special == Scroll_Floor || - special == Scroll_Texture_Model) - { - if (l->args[1] & 3) - { - // if 1, then displacement - // if 2, then accelerative (also if 3) - control = int(l->sidedef[0]->sector - sectors); - if (l->args[1] & 2) - accel = 1; - } - if (special == Scroll_Texture_Model || - l->args[1] & 4) - { - // The line housing the special controls the - // direction and speed of scrolling. - dx = l->dx >> SCROLL_SHIFT; - dy = l->dy >> SCROLL_SHIFT; - } - else - { - // The speed and direction are parameters to the special. - dx = (l->args[3] - 128) * (FRACUNIT / 32); - dy = (l->args[4] - 128) * (FRACUNIT / 32); - } - } - - switch (special) - { - int s; - - case Scroll_Ceiling: - { - FSectorTagIterator itr(l->args[0]); - while ((s = itr.Next()) >= 0) - { - new DScroller(DScroller::sc_ceiling, -dx, dy, control, s, accel); - } - for (unsigned j = 0; j < copyscrollers.Size(); j++) - { - line_t *line = &lines[copyscrollers[j]]; - - if (line->args[0] == l->args[0] && (line->args[1] & 1)) - { - new DScroller(DScroller::sc_ceiling, -dx, dy, control, int(line->frontsector - sectors), accel); - } - } - break; - } - - case Scroll_Floor: - if (l->args[2] != 1) - { // scroll the floor texture - FSectorTagIterator itr(l->args[0]); - while ((s = itr.Next()) >= 0) - { - new DScroller (DScroller::sc_floor, -dx, dy, control, s, accel); - } - for(unsigned j = 0;j < copyscrollers.Size(); j++) - { - line_t *line = &lines[copyscrollers[j]]; - - if (line->args[0] == l->args[0] && (line->args[1] & 2)) - { - new DScroller (DScroller::sc_floor, -dx, dy, control, int(line->frontsector-sectors), accel); - } - } - } - - if (l->args[2] > 0) - { // carry objects on the floor - FSectorTagIterator itr(l->args[0]); - while ((s = itr.Next()) >= 0) - { - new DScroller (DScroller::sc_carry, dx, dy, control, s, accel); - } - for(unsigned j = 0;j < copyscrollers.Size(); j++) - { - line_t *line = &lines[copyscrollers[j]]; - - if (line->args[0] == l->args[0] && (line->args[1] & 4)) - { - new DScroller (DScroller::sc_carry, dx, dy, control, int(line->frontsector-sectors), accel); - } - } - } - break; - - // killough 3/1/98: scroll wall according to linedef - // (same direction and speed as scrolling floors) - case Scroll_Texture_Model: - { - FLineIdIterator itr(l->args[0]); - while ((s = itr.Next()) >= 0) - { - if (s != i) - new DScroller(dx, dy, lines + s, control, accel); - } - break; - } - - case Scroll_Texture_Offsets: - // killough 3/2/98: scroll according to sidedef offsets - s = int(lines[i].sidedef[0] - sides); - new DScroller (DScroller::sc_side, -sides[s].GetTextureXOffset(side_t::mid), - sides[s].GetTextureYOffset(side_t::mid), -1, s, accel, SCROLLTYPE(l->args[0])); - break; - - case Scroll_Texture_Left: - l->special = special; // Restore the special, for compat_useblocking's benefit. - s = int(lines[i].sidedef[0] - sides); - new DScroller (DScroller::sc_side, l->args[0] * (FRACUNIT/64), 0, - -1, s, accel, SCROLLTYPE(l->args[1])); - break; - - case Scroll_Texture_Right: - l->special = special; - s = int(lines[i].sidedef[0] - sides); - new DScroller (DScroller::sc_side, l->args[0] * (-FRACUNIT/64), 0, - -1, s, accel, SCROLLTYPE(l->args[1])); - break; - - case Scroll_Texture_Up: - l->special = special; - s = int(lines[i].sidedef[0] - sides); - new DScroller (DScroller::sc_side, 0, l->args[0] * (FRACUNIT/64), - -1, s, accel, SCROLLTYPE(l->args[1])); - break; - - case Scroll_Texture_Down: - l->special = special; - s = int(lines[i].sidedef[0] - sides); - new DScroller (DScroller::sc_side, 0, l->args[0] * (-FRACUNIT/64), - -1, s, accel, SCROLLTYPE(l->args[1])); - break; - - case Scroll_Texture_Both: - s = int(lines[i].sidedef[0] - sides); - if (l->args[0] == 0) { - dx = (l->args[1] - l->args[2]) * (FRACUNIT/64); - dy = (l->args[4] - l->args[3]) * (FRACUNIT/64); - new DScroller (DScroller::sc_side, dx, dy, -1, s, accel); - } - break; - - default: - // [RH] It wasn't a scroller after all, so restore the special. - l->special = special; - break; - } - } -} - -// killough 3/7/98 -- end generalized scroll effects - //////////////////////////////////////////////////////////////////////////// // // FRICTION EFFECTS diff --git a/src/p_spec.h b/src/p_spec.h index b0baaa1ea..129e7f03b 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -32,6 +32,32 @@ class FScanner; struct level_info_t; +struct FThinkerCollection +{ + int RefNum; + DThinker *Obj; +}; + +enum class EScroll : int +{ + sc_side, + sc_floor, + sc_ceiling, + sc_carry, + sc_carry_ceiling, // killough 4/11/98: carry objects hanging on ceilings +}; + +enum EScrollPos : int +{ + scw_top = 1, + scw_mid = 2, + scw_bottom = 4, + scw_all = 7, +}; + +void P_CreateScroller(EScroll type, fixed_t dx, fixed_t dy, int control, int affectee, int accel, EScrollPos scrollpos = EScrollPos::scw_all); + + //jff 2/23/98 identify the special classes that can share sectors typedef enum @@ -41,58 +67,6 @@ typedef enum lighting_special, } special_e; -// killough 3/7/98: Add generalized scroll effects - -class DScroller : public DThinker -{ - DECLARE_CLASS (DScroller, DThinker) - HAS_OBJECT_POINTERS -public: - enum EScrollType - { - sc_side, - sc_floor, - sc_ceiling, - sc_carry, - sc_carry_ceiling, // killough 4/11/98: carry objects hanging on ceilings - }; - enum EScrollPos - { - scw_top=1, - scw_mid=2, - scw_bottom=4, - scw_all=7, - }; - - DScroller (EScrollType type, fixed_t dx, fixed_t dy, int control, int affectee, int accel, int scrollpos = scw_all); - DScroller (fixed_t dx, fixed_t dy, const line_t *l, int control, int accel, int scrollpos = scw_all); - void Destroy(); - - void Serialize (FArchive &arc); - void Tick (); - - bool AffectsWall (int wallnum) const { return m_Type == sc_side && m_Affectee == wallnum; } - int GetWallNum () const { return m_Type == sc_side ? m_Affectee : -1; } - void SetRate (fixed_t dx, fixed_t dy) { m_dx = dx; m_dy = dy; } - bool IsType (EScrollType type) const { return type == m_Type; } - int GetAffectee () const { return m_Affectee; } - int GetScrollParts() const { return m_Parts; } - -protected: - EScrollType m_Type; // Type of scroll effect - fixed_t m_dx, m_dy; // (dx,dy) scroll speeds - int m_Affectee; // Number of affected sidedef, sector, tag, or whatever - int m_Control; // Control sector (-1 if none) used to control scrolling - fixed_t m_LastHeight; // Last known height of control sector - fixed_t m_vdx, m_vdy; // Accumulated velocity if accelerative - int m_Accel; // Whether it's accelerative - int m_Parts; // Which parts of a sidedef are being scrolled? - TObjPtr m_Interpolations[3]; - -private: - DScroller (); -}; - // Factor to scale scrolling effect into mobj-carrying properties = 3/32. // (This is so scrolling floors and objects on them can move at same speed.) enum { CARRYFACTOR = (3*FRACUNIT >> 5) }; diff --git a/src/po_man.h b/src/po_man.h index be3b958b2..6ab7d20a7 100644 --- a/src/po_man.h +++ b/src/po_man.h @@ -5,6 +5,7 @@ #include "r_defs.h" #include "m_bbox.h" +class DPolyAction; struct FPolyVertex { From fd46909b1a89402cfcadbf0bfe991fe1835d0c9a Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Mar 2016 17:41:13 +0200 Subject: [PATCH 35/44] - made partial floarting point aliases for EV_DoCeiling so that all the calls in p_lnspec.cpp match the master branch for merging. --- src/p_lnspec.cpp | 64 ++++++++++++++++++++++++------------------------ src/p_sight.cpp | 8 +++--- src/p_spec.h | 15 ++++++++++++ 3 files changed, 51 insertions(+), 36 deletions(-) diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 6697f20f3..1f0ee9c79 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -425,7 +425,7 @@ FUNC(LS_Floor_MoveToValueTimes8) FUNC(LS_Floor_MoveToValue) // Floor_MoveToValue (tag, speed, height, negative, change) { - return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, _f_SPEED(arg1), + return EV_DoFloor (DFloor::floorMoveToValue, ln, arg0, SPEED(arg1), arg2*(arg3?-1:1), -1, CHANGE(arg4), false); } @@ -630,43 +630,43 @@ FUNC(LS_Pillar_Open) FUNC(LS_Ceiling_LowerByValue) // Ceiling_LowerByValue (tag, speed, height, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false); } FUNC(LS_Ceiling_RaiseByValue) // Ceiling_RaiseByValue (tag, speed, height, change) { - return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT, CRUSH(arg4), 0, CHANGE(arg3), false); } FUNC(LS_Ceiling_LowerByValueTimes8) // Ceiling_LowerByValueTimes8 (tag, speed, height, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilLowerByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); } FUNC(LS_Ceiling_RaiseByValueTimes8) // Ceiling_RaiseByValueTimes8 (tag, speed, height, change) { - return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, _f_SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); + return EV_DoCeiling (DCeiling::ceilRaiseByValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8, -1, 0, CHANGE(arg3), false); } FUNC(LS_Ceiling_CrushAndRaise) // Ceiling_CrushAndRaise (tag, speed, crush, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); } FUNC(LS_Ceiling_LowerAndCrush) // Ceiling_LowerAndCrush (tag, speed, crush, crushtype) { - return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1), 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); + return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); } FUNC(LS_Ceiling_LowerAndCrushDist) // Ceiling_LowerAndCrush (tag, speed, crush, dist, crushtype) { - return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1), arg3*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilLowerAndCrush, ln, arg0, SPEED(arg1), SPEED(arg1), arg3*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushStop) @@ -678,27 +678,27 @@ FUNC(LS_Ceiling_CrushStop) FUNC(LS_Ceiling_CrushRaiseAndStay) // Ceiling_CrushRaiseAndStay (tag, speed, crush, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); + return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg1)/2, 8*FRACUNIT, arg2, 0, 0, CRUSHTYPE(arg3)); } FUNC(LS_Ceiling_MoveToValueTimes8) // Ceiling_MoveToValueTimes8 (tag, speed, height, negative, change) { - return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, _f_SPEED(arg1), 0, + return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*8*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4), false); } FUNC(LS_Ceiling_MoveToValue) // Ceiling_MoveToValue (tag, speed, height, negative, change) { - return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, _f_SPEED(arg1), 0, + return EV_DoCeiling (DCeiling::ceilMoveToValue, ln, arg0, SPEED(arg1), 0, arg2*FRACUNIT*((arg3) ? -1 : 1), -1, 0, CHANGE(arg4), false); } FUNC(LS_Ceiling_LowerToHighestFloor) // Ceiling_LowerToHighestFloor (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToHighestFloor, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); + return EV_DoCeiling (DCeiling::ceilLowerToHighestFloor, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); } FUNC(LS_Ceiling_LowerInstant) @@ -716,79 +716,79 @@ FUNC(LS_Ceiling_RaiseInstant) FUNC(LS_Ceiling_CrushRaiseAndStayA) // Ceiling_CrushRaiseAndStayA (tag, dnspeed, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushRaiseAndStaySilA) // Ceiling_CrushRaiseAndStaySilA (tag, dnspeed, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushRaiseAndStay, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushAndRaiseA) // Ceiling_CrushAndRaiseA (tag, dnspeed, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 0, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushAndRaiseDist) // Ceiling_CrushAndRaiseDist (tag, dist, speed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg2), _f_SPEED(arg2), arg1*FRACUNIT, arg3, 0, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 0, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushAndRaiseSilentA) // Ceiling_CrushAndRaiseSilentA (tag, dnspeed, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), SPEED(arg2), 0, arg3, 1, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_CrushAndRaiseSilentDist) // Ceiling_CrushAndRaiseSilentDist (tag, dist, upspeed, damage, crushtype) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg2), _f_SPEED(arg2), arg1*FRACUNIT, arg3, 1, 0, CRUSHTYPE(arg4)); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg2), SPEED(arg2), arg1*FRACUNIT, arg3, 1, 0, CRUSHTYPE(arg4)); } FUNC(LS_Ceiling_RaiseToNearest) // Ceiling_RaiseToNearest (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseToNearest, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseToNearest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); } FUNC(LS_Ceiling_RaiseToHighest) // Ceiling_RaiseToHighest (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); } FUNC(LS_Ceiling_RaiseToLowest) // Ceiling_RaiseToLowest (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseToLowest, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseToLowest, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); } FUNC(LS_Ceiling_RaiseToHighestFloor) // Ceiling_RaiseToHighestFloor (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseToHighestFloor, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseToHighestFloor, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); } FUNC(LS_Ceiling_RaiseByTexture) // Ceiling_RaiseByTexture (tag, speed, change) { - return EV_DoCeiling (DCeiling::ceilRaiseByTexture, ln, arg0, _f_SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); + return EV_DoCeiling (DCeiling::ceilRaiseByTexture, ln, arg0, SPEED(arg1), 0, 0, -1, CHANGE(arg2), 0, false); } FUNC(LS_Ceiling_LowerToLowest) // Ceiling_LowerToLowest (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToLowest, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); + return EV_DoCeiling (DCeiling::ceilLowerToLowest, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); } FUNC(LS_Ceiling_LowerToNearest) // Ceiling_LowerToNearest (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToNearest, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); + return EV_DoCeiling (DCeiling::ceilLowerToNearest, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg2), false); } FUNC(LS_Ceiling_ToHighestInstant) @@ -806,13 +806,13 @@ FUNC(LS_Ceiling_ToFloorInstant) FUNC(LS_Ceiling_LowerToFloor) // Ceiling_LowerToFloor (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerToFloor, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false); + return EV_DoCeiling (DCeiling::ceilLowerToFloor, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false); } FUNC(LS_Ceiling_LowerByTexture) // Ceiling_LowerByTexture (tag, speed, change, crush) { - return EV_DoCeiling (DCeiling::ceilLowerByTexture, ln, arg0, _f_SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false); + return EV_DoCeiling (DCeiling::ceilLowerByTexture, ln, arg0, SPEED(arg1), 0, 0, CRUSH(arg3), 0, CHANGE(arg4), false); } FUNC(LS_Generic_Ceiling) @@ -842,23 +842,23 @@ FUNC(LS_Generic_Ceiling) } } - return EV_DoCeiling (type, ln, arg0, _f_SPEED(arg1), _f_SPEED(arg1), arg2*FRACUNIT, + return EV_DoCeiling (type, ln, arg0, SPEED(arg1), SPEED(arg1), arg2*FRACUNIT, (arg4 & 16) ? 20 : -1, 0, arg4 & 7, false); } FUNC(LS_Generic_Crusher) // Generic_Crusher (tag, dnspeed, upspeed, silent, damage) { - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), - _f_SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, false); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), + SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, false); } FUNC(LS_Generic_Crusher2) // Generic_Crusher2 (tag, dnspeed, upspeed, silent, damage) { // same as above but uses Hexen's crushing method. - return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, _f_SPEED(arg1), - _f_SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, true); + return EV_DoCeiling (DCeiling::ceilCrushAndRaise, ln, arg0, SPEED(arg1), + SPEED(arg2), 0, arg4, arg3 ? 2 : 0, 0, true); } FUNC(LS_Plat_PerpetualRaise) diff --git a/src/p_sight.cpp b/src/p_sight.cpp index d8f2ccf25..4b8a32951 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -849,16 +849,16 @@ sightcounts[0]++; if (!(flags & SF_IGNOREWATERBOUNDARY)) { if ((s1->GetHeightSec() && - ((t1->top() <= s1->heightsec->floorplane.ZatPointF(t1) && + ((t1->Top() <= s1->heightsec->floorplane.ZatPointF(t1) && t2->Z() >= s1->heightsec->floorplane.ZatPointF(t2)) || (t1->Z() >= s1->heightsec->ceilingplane.ZatPointF(t1) && - t2->top() <= s1->heightsec->ceilingplane.ZatPointF(t2)))) + t2->Top() <= s1->heightsec->ceilingplane.ZatPointF(t2)))) || (s2->GetHeightSec() && - ((t2->top() <= s2->heightsec->floorplane.ZatPointF(t2) && + ((t2->Top() <= s2->heightsec->floorplane.ZatPointF(t2) && t1->Z() >= s2->heightsec->floorplane.ZatPointF(t1)) || (t2->Z() >= s2->heightsec->ceilingplane.ZatPointF(t2) && - t1->top() <= s2->heightsec->ceilingplane.ZatPointF(t1))))) + t1->Top() <= s2->heightsec->ceilingplane.ZatPointF(t1))))) { res = false; goto done; diff --git a/src/p_spec.h b/src/p_spec.h index 535bd2f77..de6a510e8 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -675,6 +675,21 @@ private: bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, int tag, fixed_t speed, fixed_t speed2, fixed_t height, int crush, int silent, int change, bool hexencrush); + +inline bool EV_DoCeiling(DCeiling::ECeiling type, line_t *line, + int tag, double speed, double speed2, fixed_t height, + int crush, int silent, int change, bool hexencrush) +{ + return EV_DoCeiling(type, line, tag, FLOAT2FIXED(speed), FLOAT2FIXED(speed2), height, crush, silent, change, hexencrush); +} + +inline bool EV_DoCeiling(DCeiling::ECeiling type, line_t *line, + int tag, double speed, int speed2, fixed_t height, + int crush, int silent, int change, bool hexencrush) +{ + return EV_DoCeiling(type, line, tag, FLOAT2FIXED(speed), speed2, height, crush, silent, change, hexencrush); +} + bool EV_CeilingCrushStop (int tag); void P_ActivateInStasisCeiling (int tag); From 05504b65d2b038c3c94b12e587fdc17b99f566ba Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Mar 2016 21:04:46 +0200 Subject: [PATCH 36/44] - floatified p_scroll.cpp While testing this it became clear that with the higher precision of doubles it has to be avoided at all costs to compare an actor's z position with a value retrieved from ZatPoint to check if it is standing on a floor. There can be some minor variations, depending on what was done with this value. Added isAbove, isBelow and isAtZ checking methods to AActor which properly deal with the problem. --- src/actor.h | 15 ++++++++ src/p_lnspec.cpp | 20 +++++----- src/p_map.cpp | 2 +- src/p_mobj.cpp | 3 +- src/p_scroll.cpp | 96 ++++++++++++++++++++++++------------------------ src/p_spec.cpp | 14 +++---- src/p_spec.h | 6 +-- src/r_defs.h | 22 ++++++++++- 8 files changed, 105 insertions(+), 73 deletions(-) diff --git a/src/actor.h b/src/actor.h index 8d7e530e9..9f9f5efb8 100644 --- a/src/actor.h +++ b/src/actor.h @@ -565,6 +565,7 @@ fixed_t P_AproxDistance (fixed_t dx, fixed_t dy); // since we cannot include p_l angle_t R_PointToAngle2 (fixed_t x1, fixed_t y1, fixed_t x2, fixed_t y2); // same reason here with r_defs.h const double MinVel = 1. / 65536; +const double Z_Epsilon = 1. / 65536.; // Map Object definition. class AActor : public DThinker @@ -1294,6 +1295,20 @@ public: { return __Pos; } + // Note: Never compare z directly with a plane height if you want to know if the actor is *on* the plane. Some very minor inaccuracies may creep in. Always use these inline functions! + // Comparing with floorz is ok because those values come from the same calculations. + bool isAbove(double checkz) const + { + return Z() > checkz + Z_Epsilon; + } + bool isBelow(double checkz) const + { + return Z() < checkz - Z_Epsilon; + } + bool isAtZ(double checkz) + { + return fabs(Z() - checkz) < Z_Epsilon; + } fixedvec3 _f_PosRelative(int grp) const; fixedvec3 _f_PosRelative(const AActor *other) const; diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 904756023..3ff43f27a 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -1955,7 +1955,7 @@ FUNC(LS_FloorAndCeiling_RaiseByValue) FUNC(LS_FloorAndCeiling_LowerRaise) // FloorAndCeiling_LowerRaise (tag, fspeed, cspeed, boomemu) { - bool res = EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, SPEED(arg2), 0, 0, 0, 0, 0, false); + bool res = EV_DoCeiling (DCeiling::ceilRaiseToHighest, ln, arg0, SPEED(arg2), 0, 0, 0, 0, 0); // The switch based Boom equivalents of FloorandCeiling_LowerRaise do incorrect checks // which cause the floor only to move when the ceiling fails to do so. // To avoid problems with maps that have incorrect args this only uses a @@ -2241,8 +2241,8 @@ FUNC(LS_Sector_SetLink) return false; } -void SetWallScroller(int id, int sidechoice, fixed_t dx, fixed_t dy, EScrollPos Where); -void SetScroller(int tag, EScroll type, fixed_t dx, fixed_t dy); +void SetWallScroller(int id, int sidechoice, double dx, double dy, EScrollPos Where); +void SetScroller(int tag, EScroll type, double dx, double dy); FUNC(LS_Scroll_Texture_Both) @@ -2251,8 +2251,8 @@ FUNC(LS_Scroll_Texture_Both) if (arg0 == 0) return false; - fixed_t dx = (arg1 - arg2) * (FRACUNIT/64); - fixed_t dy = (arg4 - arg3) * (FRACUNIT/64); + double dx = (arg1 - arg2) / 64.; + double dy = (arg4 - arg3) / 64.; int sidechoice; if (arg0 < 0) @@ -2276,7 +2276,7 @@ FUNC(LS_Scroll_Wall) if (arg0 == 0) return false; - SetWallScroller (arg0, !!arg3, arg1, arg2, EScrollPos(arg4)); + SetWallScroller (arg0, !!arg3, arg1 / 65536., arg2 / 65536., EScrollPos(arg4)); return true; } @@ -2287,8 +2287,8 @@ FUNC(LS_Scroll_Wall) FUNC(LS_Scroll_Floor) // Scroll_Floor (tag, x-move, y-move, s/c) { - fixed_t dx = arg1 * FRACUNIT/32; - fixed_t dy = arg2 * FRACUNIT/32; + double dx = arg1 / 32.; + double dy = arg2 / 32.; if (arg3 == 0 || arg3 == 2) { @@ -2312,8 +2312,8 @@ FUNC(LS_Scroll_Floor) FUNC(LS_Scroll_Ceiling) // Scroll_Ceiling (tag, x-move, y-move, 0) { - fixed_t dx = arg1 * FRACUNIT/32; - fixed_t dy = arg2 * FRACUNIT/32; + double dx = arg1 / 32.; + double dy = arg2 / 32.; SetScroller (arg0, EScroll::sc_ceiling, -dx, dy); return true; diff --git a/src/p_map.cpp b/src/p_map.cpp index 6c3f965ab..3e2fca2e2 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -2992,7 +2992,7 @@ const secplane_t * P_CheckSlopeWalk(AActor *actor, DVector2 &move) } else if (t > 0) { // Desired location is in front of (above) the plane - if (fabs(planezhere - actor->Z() < (1/65536.))) // it is very important not to be too precise here. + if (actor->isAtZ(planezhere)) // it is very important not to be too precise here. { // Actor's current spot is on/in the plane, so walk down it // Same principle as walking up, except reversed diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index a4f359d73..467d01d0e 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -3597,7 +3597,8 @@ void AActor::Tick () } DVector3 pos = PosRelative(sec); height = sec->floorplane.ZatPoint (pos); - if (Z() > height) + double height2 = sec->floorplane.ZatPoint(this); + if (isAbove(height)) { if (heightsec == NULL) { diff --git a/src/p_scroll.cpp b/src/p_scroll.cpp index 47605d1ae..aad56aa67 100644 --- a/src/p_scroll.cpp +++ b/src/p_scroll.cpp @@ -42,8 +42,8 @@ class DScroller : public DThinker HAS_OBJECT_POINTERS public: - DScroller (EScroll type, fixed_t dx, fixed_t dy, int control, int affectee, int accel, EScrollPos scrollpos = EScrollPos::scw_all); - DScroller (fixed_t dx, fixed_t dy, const line_t *l, int control, int accel, EScrollPos scrollpos = EScrollPos::scw_all); + DScroller (EScroll type, double dx, double dy, int control, int affectee, int accel, EScrollPos scrollpos = EScrollPos::scw_all); + DScroller (double dx, double dy, const line_t *l, int control, int accel, EScrollPos scrollpos = EScrollPos::scw_all); void Destroy(); void Serialize (FArchive &arc); @@ -51,18 +51,18 @@ public: bool AffectsWall (int wallnum) const { return m_Type == EScroll::sc_side && m_Affectee == wallnum; } int GetWallNum () const { return m_Type == EScroll::sc_side ? m_Affectee : -1; } - void SetRate (fixed_t dx, fixed_t dy) { m_dx = dx; m_dy = dy; } + void SetRate (double dx, double dy) { m_dx = dx; m_dy = dy; } bool IsType (EScroll type) const { return type == m_Type; } int GetAffectee () const { return m_Affectee; } EScrollPos GetScrollParts() const { return m_Parts; } protected: EScroll m_Type; // Type of scroll effect - fixed_t m_dx, m_dy; // (dx,dy) scroll speeds + double m_dx, m_dy; // (dx,dy) scroll speeds int m_Affectee; // Number of affected sidedef, sector, tag, or whatever int m_Control; // Control sector (-1 if none) used to control scrolling - fixed_t m_LastHeight; // Last known height of control sector - fixed_t m_vdx, m_vdy; // Accumulated velocity if accelerative + double m_LastHeight; // Last known height of control sector + double m_vdx, m_vdy; // Accumulated velocity if accelerative int m_Accel; // Whether it's accelerative EScrollPos m_Parts; // Which parts of a sidedef are being scrolled? TObjPtr m_Interpolations[3]; @@ -137,9 +137,9 @@ void DScroller::Serialize (FArchive &arc) // //----------------------------------------------------------------------------- -static void RotationComp(const sector_t *sec, int which, fixed_t dx, fixed_t dy, fixed_t &tdx, fixed_t &tdy) +static void RotationComp(const sector_t *sec, int which, double dx, double dy, double &tdx, double &tdy) { - angle_t an = sec->GetAngle(which); + DAngle an = sec->GetAngleF(which); if (an == 0) { tdx = dx; @@ -147,11 +147,10 @@ static void RotationComp(const sector_t *sec, int which, fixed_t dx, fixed_t dy, } else { - an = an >> ANGLETOFINESHIFT; - fixed_t ca = -finecosine[an]; - fixed_t sa = -finesine[an]; - tdx = DMulScale16(dx, ca, -dy, sa); - tdy = DMulScale16(dy, ca, dx, sa); + double ca = an.Cos(); + double sa = an.Sin(); + tdx = dx*ca - dy*sa; + tdy = dy*ca + dx*sa; } } @@ -180,16 +179,16 @@ static void RotationComp(const sector_t *sec, int which, fixed_t dx, fixed_t dy, void DScroller::Tick () { - fixed_t dx = m_dx, dy = m_dy, tdx, tdy; + double dx = m_dx, dy = m_dy, tdx, tdy; if (m_Control != -1) { // compute scroll amounts based on a sector's height changes - fixed_t height = sectors[m_Control].CenterFloor () + - sectors[m_Control].CenterCeiling (); - fixed_t delta = height - m_LastHeight; + double height = sectors[m_Control].CenterFloorF () + + sectors[m_Control].CenterCeilingF (); + double delta = height - m_LastHeight; m_LastHeight = height; - dx = FixedMul(dx, delta); - dy = FixedMul(dy, delta); + dx *= delta; + dy *= delta; } // killough 3/14/98: Add acceleration @@ -199,7 +198,7 @@ void DScroller::Tick () m_vdy = dy += m_vdy; } - if (!(dx | dy)) // no-op if both (x,y) offsets are 0 + if (dx == 0 && dy == 0) return; switch (m_Type) @@ -237,8 +236,8 @@ void DScroller::Tick () // [RH] Don't actually carry anything here. That happens later. case EScroll::sc_carry: - level.Scrolls[m_Affectee].Scroll.X += FIXED2DBL(dx); - level.Scrolls[m_Affectee].Scroll.Y += FIXED2DBL(dy); + level.Scrolls[m_Affectee].Scroll.X += dx; + level.Scrolls[m_Affectee].Scroll.Y += dy; break; case EScroll::sc_carry_ceiling: // to be added later @@ -266,7 +265,7 @@ void DScroller::Tick () // //----------------------------------------------------------------------------- -DScroller::DScroller (EScroll type, fixed_t dx, fixed_t dy, +DScroller::DScroller (EScroll type, double dx, double dy, int control, int affectee, int accel, EScrollPos scrollpos) : DThinker (STAT_SCROLLER) { @@ -278,7 +277,7 @@ DScroller::DScroller (EScroll type, fixed_t dx, fixed_t dy, m_vdx = m_vdy = 0; if ((m_Control = control) != -1) m_LastHeight = - sectors[control].CenterFloor () + sectors[control].CenterCeiling (); + sectors[control].CenterFloorF () + sectors[control].CenterCeilingF (); m_Affectee = affectee; m_Interpolations[0] = m_Interpolations[1] = m_Interpolations[2] = NULL; @@ -342,17 +341,16 @@ void DScroller::Destroy () // //----------------------------------------------------------------------------- -DScroller::DScroller (fixed_t dx, fixed_t dy, const line_t *l, +DScroller::DScroller (double dx, double dy, const line_t *l, int control, int accel, EScrollPos scrollpos) : DThinker (STAT_SCROLLER) { - fixed_t x = abs(l->dx), y = abs(l->dy), d; - if (y > x) - d = x, x = y, y = d; - d = FixedDiv (x, finesine[(tantoangle[FixedDiv(y,x) >> DBITS] + ANG90) - >> ANGLETOFINESHIFT]); - x = -FixedDiv (FixedMul(dy, l->dy) + FixedMul(dx, l->dx), d); - y = -FixedDiv (FixedMul(dx, l->dy) - FixedMul(dy, l->dx), d); + double x = fabs(l->Delta().X), y = fabs(l->Delta().Y), d; + if (y > x) d = x, x = y, y = d; + + d = x / g_sin(g_atan2(y, x) + M_PI / 2); + x = (-dy * l->Delta().Y + dx * l->Delta().X) / d; + y = (-dx * l->Delta().Y - dy * l->Delta().Y) / d; m_Type = EScroll::sc_side; m_dx = x; @@ -412,8 +410,8 @@ void P_SpawnScrollers(void) for (i = 0; i < numlines; i++, l++) { - fixed_t dx; // direction and speed of scrolling - fixed_t dy; + double dx; // direction and speed of scrolling + double dy; int control = -1, accel = 0; // no control sector or acceleration int special = l->special; @@ -463,14 +461,14 @@ void P_SpawnScrollers(void) { // The line housing the special controls the // direction and speed of scrolling. - dx = l->dx >> SCROLL_SHIFT; - dy = l->dy >> SCROLL_SHIFT; + dx = l->Delta().X / 32.; + dy = l->Delta().Y / 32.; } else { // The speed and direction are parameters to the special. - dx = (l->args[3] - 128) * (FRACUNIT / 32); - dy = (l->args[4] - 128) * (FRACUNIT / 32); + dx = (l->args[3] - 128) / 32.; + dy = (l->args[4] - 128) / 32.; } } @@ -558,36 +556,36 @@ void P_SpawnScrollers(void) case Scroll_Texture_Left: l->special = special; // Restore the special, for compat_useblocking's benefit. s = int(lines[i].sidedef[0] - sides); - new DScroller (EScroll::sc_side, l->args[0] * (FRACUNIT/64), 0, + new DScroller (EScroll::sc_side, l->args[0] / 64., 0, -1, s, accel, SCROLLTYPE(l->args[1])); break; case Scroll_Texture_Right: l->special = special; s = int(lines[i].sidedef[0] - sides); - new DScroller (EScroll::sc_side, l->args[0] * (-FRACUNIT/64), 0, + new DScroller (EScroll::sc_side, -l->args[0] / 64., 0, -1, s, accel, SCROLLTYPE(l->args[1])); break; case Scroll_Texture_Up: l->special = special; s = int(lines[i].sidedef[0] - sides); - new DScroller (EScroll::sc_side, 0, l->args[0] * (FRACUNIT/64), + new DScroller (EScroll::sc_side, 0, l->args[0] / 64., -1, s, accel, SCROLLTYPE(l->args[1])); break; case Scroll_Texture_Down: l->special = special; s = int(lines[i].sidedef[0] - sides); - new DScroller (EScroll::sc_side, 0, l->args[0] * (-FRACUNIT/64), + new DScroller (EScroll::sc_side, 0, -l->args[0] / 64., -1, s, accel, SCROLLTYPE(l->args[1])); break; case Scroll_Texture_Both: s = int(lines[i].sidedef[0] - sides); if (l->args[0] == 0) { - dx = (l->args[1] - l->args[2]) * (FRACUNIT/64); - dy = (l->args[4] - l->args[3]) * (FRACUNIT/64); + dx = (l->args[1] - l->args[2]) / 64.; + dy = (l->args[4] - l->args[3]) / 64.; new DScroller (EScroll::sc_side, dx, dy, -1, s, accel); } break; @@ -606,12 +604,12 @@ void P_SpawnScrollers(void) // //----------------------------------------------------------------------------- -void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, EScrollPos Where) +void SetWallScroller (int id, int sidechoice, double dx, double dy, EScrollPos Where) { Where = Where & scw_all; if (Where == 0) return; - if ((dx | dy) == 0) + if (dx == 0 && dy == 0) { // Special case: Remove the scroller, because the deltas are both 0. TThinkerIterator iterator (STAT_SCROLLER); @@ -676,7 +674,7 @@ void SetWallScroller (int id, int sidechoice, fixed_t dx, fixed_t dy, EScrollPos } } -void SetScroller (int tag, EScroll type, fixed_t dx, fixed_t dy) +void SetScroller (int tag, EScroll type, double dx, double dy) { TThinkerIterator iterator (STAT_SCROLLER); DScroller *scroller; @@ -700,7 +698,7 @@ void SetScroller (int tag, EScroll type, fixed_t dx, fixed_t dy) } } - if (i > 0 || (dx|dy) == 0) + if (i > 0 || (dx == 0 && dy == 0)) { return; } @@ -713,7 +711,7 @@ void SetScroller (int tag, EScroll type, fixed_t dx, fixed_t dy) } } -void P_CreateScroller(EScroll type, fixed_t dx, fixed_t dy, int control, int affectee, int accel, EScrollPos scrollpos) +void P_CreateScroller(EScroll type, double dx, double dy, int control, int affectee, int accel, EScrollPos scrollpos) { new DScroller(type, dx, dy, control, affectee, accel, scrollpos); } diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 0979f8ea9..830f20a26 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -402,7 +402,7 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector) { // Falling, not all the way down yet? sector = player->mo->Sector; - if (player->mo->Z() != sector->LowestFloorAt(player->mo) + if (!player->mo->isAtZ(sector->LowestFloorAt(player->mo)) && !player->mo->waterlevel) { return; @@ -1203,8 +1203,7 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) if (!nothinkers) { new DStrobe(sector, STROBEBRIGHT, FASTDARK, false); - P_CreateScroller(EScroll::sc_floor, -((FRACUNIT / 2) << 3), - 0, -1, int(sector - sectors), 0); + P_CreateScroller(EScroll::sc_floor, -4., 0, -1, int(sector - sectors), 0); } keepspecial = true; break; @@ -1248,7 +1247,7 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) if (sector->special >= Scroll_North_Slow && sector->special <= Scroll_SouthWest_Fast) { // Hexen scroll special - static const char hexenScrollies[24][2] = + static const SBYTE hexenScrollies[24][2] = { { 0, 1 }, { 0, 2 }, { 0, 4 }, { -1, 0 }, { -2, 0 }, { -4, 0 }, @@ -1262,8 +1261,8 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) int i = sector->special - Scroll_North_Slow; - fixed_t dx = hexenScrollies[i][0] * (FRACUNIT/2); - fixed_t dy = hexenScrollies[i][1] * (FRACUNIT/2); + double dx = hexenScrollies[i][0] / 2.; + double dy = hexenScrollies[i][1] / 2.; if (!nothinkers) P_CreateScroller(EScroll::sc_floor, dx, dy, -1, int(sector-sectors), 0); } else if (sector->special >= Carry_East5 && @@ -1271,8 +1270,7 @@ void P_InitSectorSpecial(sector_t *sector, int special, bool nothinkers) { // Heretic scroll special // Only east scrollers also scroll the texture if (!nothinkers) P_CreateScroller(EScroll::sc_floor, - (-FRACUNIT/2)<<(sector->special - Carry_East5), - 0, -1, int(sector-sectors), 0); + -0.5 * (1 << ((sector->special & 0xff) - Carry_East5)), 0, -1, int(sector-sectors), 0); } keepspecial = true; break; diff --git a/src/p_spec.h b/src/p_spec.h index ce4cfdb76..0ba82c0bc 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -55,7 +55,7 @@ enum EScrollPos : int scw_all = 7, }; -void P_CreateScroller(EScroll type, fixed_t dx, fixed_t dy, int control, int affectee, int accel, EScrollPos scrollpos = EScrollPos::scw_all); +void P_CreateScroller(EScroll type, double dx, double dy, int control, int affectee, int accel, EScrollPos scrollpos = EScrollPos::scw_all); //jff 2/23/98 identify the special classes that can share sectors @@ -660,14 +660,14 @@ bool EV_DoCeiling (DCeiling::ECeiling type, line_t *line, inline bool EV_DoCeiling(DCeiling::ECeiling type, line_t *line, int tag, double speed, double speed2, fixed_t height, - int crush, int silent, int change, bool hexencrush) + int crush, int silent, int change, DCeiling::ECrushMode hexencrush = DCeiling::ECrushMode::crushDoom) { return EV_DoCeiling(type, line, tag, FLOAT2FIXED(speed), FLOAT2FIXED(speed2), height, crush, silent, change, hexencrush); } inline bool EV_DoCeiling(DCeiling::ECeiling type, line_t *line, int tag, double speed, int speed2, fixed_t height, - int crush, int silent, int change, bool hexencrush) + int crush, int silent, int change, DCeiling::ECrushMode hexencrush = DCeiling::ECrushMode::crushDoom) { return EV_DoCeiling(type, line, tag, FLOAT2FIXED(speed), speed2, height, crush, silent, change, hexencrush); } diff --git a/src/r_defs.h b/src/r_defs.h index 37b0389de..6def54ebe 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -330,7 +330,7 @@ struct secplane_t double ZatPointF(const AActor *ac) const { - return FIXED2DBL(ZatPoint(ac)); + return (d + a*ac->X() + b*ac->Y()) * ic / (-65536.0 * 65536.0); } // Returns the value of z at (x,y) if d is equal to dist @@ -643,6 +643,11 @@ struct sector_t planes[pos].xform.xoffs += o; } + void AddXOffset(int pos, double o) + { + planes[pos].xform.xoffs += FLOAT2FIXED(o); + } + fixed_t GetXOffset(int pos) const { return planes[pos].xform.xoffs; @@ -663,6 +668,11 @@ struct sector_t planes[pos].xform.yoffs += o; } + void AddYOffset(int pos, double o) + { + planes[pos].xform.yoffs += FLOAT2FIXED(o); + } + fixed_t GetYOffset(int pos, bool addbase = true) const { if (!addbase) @@ -945,6 +955,8 @@ struct sector_t // Member variables fixed_t CenterFloor () const { return floorplane.ZatPoint (_f_centerspot()); } fixed_t CenterCeiling () const { return ceilingplane.ZatPoint (_f_centerspot()); } + double CenterFloorF() const { return floorplane.ZatPoint(centerspot); } + double CenterCeilingF() const { return ceilingplane.ZatPoint(centerspot); } // [RH] store floor and ceiling planes instead of heights secplane_t floorplane, ceilingplane; @@ -1134,6 +1146,10 @@ struct side_t { textures[which].xoffset += delta; } + void AddTextureXOffset(int which, double delta) + { + textures[which].xoffset += FLOAT2FIXED(delta); + } void SetTextureYOffset(int which, fixed_t offset) { @@ -1157,6 +1173,10 @@ struct side_t { textures[which].yoffset += delta; } + void AddTextureYOffset(int which, double delta) + { + textures[which].yoffset += FLOAT2FIXED(delta); + } void SetTextureXScale(int which, fixed_t scale) { From 59920095af280ba4bc7df1d34256b885e7fe8761 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Mar 2016 21:57:22 +0200 Subject: [PATCH 37/44] - separated pushers into their own file. --- src/CMakeLists.txt | 1 + src/doomstat.cpp | 1 - src/doomstat.h | 1 - src/p_lnspec.cpp | 41 +---- src/p_spec.cpp | 370 +-------------------------------------------- src/p_spec.h | 45 ------ 6 files changed, 5 insertions(+), 454 deletions(-) diff --git a/src/CMakeLists.txt b/src/CMakeLists.txt index 4a8101d79..e53749904 100644 --- a/src/CMakeLists.txt +++ b/src/CMakeLists.txt @@ -1070,6 +1070,7 @@ add_executable( zdoom WIN32 MACOSX_BUNDLE p_pillar.cpp p_plats.cpp p_pspr.cpp + p_pusher.cpp p_saveg.cpp p_scroll.cpp p_sectors.cpp diff --git a/src/doomstat.cpp b/src/doomstat.cpp index 8f314ad50..d693aae1b 100644 --- a/src/doomstat.cpp +++ b/src/doomstat.cpp @@ -43,7 +43,6 @@ CVAR (Bool, developer, false, 0) // [RH] Feature control cvars CVAR (Bool, var_friction, true, CVAR_SERVERINFO); -CVAR (Bool, var_pushers, true, CVAR_SERVERINFO); CVAR (Bool, alwaysapplydmflags, false, CVAR_SERVERINFO); diff --git a/src/doomstat.h b/src/doomstat.h index 43d81e866..e762b07dc 100644 --- a/src/doomstat.h +++ b/src/doomstat.h @@ -212,7 +212,6 @@ extern bool ToggleFullscreen; extern int Net_Arbitrator; EXTERN_CVAR (Bool, var_friction) -EXTERN_CVAR (Bool, var_pushers) // [RH] Miscellaneous info for DeHackEd support diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index ca17a4f20..849295c2c 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -2146,43 +2146,8 @@ FUNC(LS_Sector_ChangeFlags) } -void AdjustPusher (int tag, int magnitude, int angle, DPusher::EPusher type) -{ - // Find pushers already attached to the sector, and change their parameters. - TArray Collection; - { - TThinkerIterator iterator; - FThinkerCollection collect; - while ( (collect.Obj = iterator.Next ()) ) - { - if ((collect.RefNum = ((DPusher *)collect.Obj)->CheckForSectorMatch (type, tag)) >= 0) - { - ((DPusher *)collect.Obj)->ChangeValues (magnitude, angle); - Collection.Push (collect); - } - } - } - - size_t numcollected = Collection.Size (); - int secnum; - - // Now create pushers for any sectors that don't already have them. - FSectorTagIterator itr(tag); - while ((secnum = itr.Next()) >= 0) - { - unsigned int i; - for (i = 0; i < numcollected; i++) - { - if (Collection[i].RefNum == sectors[secnum].sectornum) - break; - } - if (i == numcollected) - { - new DPusher (type, NULL, magnitude, angle, NULL, secnum); - } - } -} +void AdjustPusher(int tag, int magnitude, int angle, bool wind); FUNC(LS_Sector_SetWind) // Sector_SetWind (tag, amount, angle) @@ -2190,7 +2155,7 @@ FUNC(LS_Sector_SetWind) if (arg3) return false; - AdjustPusher (arg0, arg1, arg2, DPusher::p_wind); + AdjustPusher (arg0, arg1, arg2, true); return true; } @@ -2200,7 +2165,7 @@ FUNC(LS_Sector_SetCurrent) if (arg3) return false; - AdjustPusher (arg0, arg1, arg2, DPusher::p_current); + AdjustPusher (arg0, arg1, arg2, false); return true; } diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 700cf2c1e..834df5956 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -84,40 +84,11 @@ static FRandom pr_playerinspecialsector ("PlayerInSpecialSector"); EXTERN_CVAR(Bool, cl_predict_specials) -IMPLEMENT_POINTY_CLASS (DPusher) - DECLARE_POINTER (m_Source) -END_POINTERS - -DPusher::DPusher () -{ -} - -inline FArchive &operator<< (FArchive &arc, DPusher::EPusher &type) -{ - BYTE val = (BYTE)type; - arc << val; - type = (DPusher::EPusher)val; - return arc; -} - -void DPusher::Serialize (FArchive &arc) -{ - Super::Serialize (arc); - arc << m_Type - << m_Source - << m_Xmag - << m_Ymag - << m_Magnitude - << m_Radius - << m_X - << m_Y - << m_Affectee; -} // killough 3/7/98: Initialize generalized scrolling void P_SpawnScrollers(); static void P_SpawnFriction (); // phares 3/16/98 -static void P_SpawnPushers (); // phares 3/20/98 +void P_SpawnPushers (); // phares 3/20/98 // [RH] Check dmflags for noexit and respond accordingly @@ -1631,345 +1602,6 @@ void P_SetSectorFriction (int tag, int amount, bool alterFlag) // //////////////////////////////////////////////////////////////////////////// -//////////////////////////////////////////////////////////////////////////// -// -// PUSH/PULL EFFECT -// -// phares 3/20/98: Start of push/pull effects -// -// This is where push/pull effects are applied to objects in the sectors. -// -// There are four kinds of push effects -// -// 1) Pushing Away -// -// Pushes you away from a point source defined by the location of an -// MT_PUSH Thing. The force decreases linearly with distance from the -// source. This force crosses sector boundaries and is felt w/in a circle -// whose center is at the MT_PUSH. The force is felt only if the point -// MT_PUSH can see the target object. -// -// 2) Pulling toward -// -// Same as Pushing Away except you're pulled toward an MT_PULL point -// source. This force crosses sector boundaries and is felt w/in a circle -// whose center is at the MT_PULL. The force is felt only if the point -// MT_PULL can see the target object. -// -// 3) Wind -// -// Pushes you in a constant direction. Full force above ground, half -// force on the ground, nothing if you're below it (water). -// -// 4) Current -// -// Pushes you in a constant direction. No force above ground, full -// force if on the ground or below it (water). -// -// The magnitude of the force is controlled by the length of a controlling -// linedef. The force vector for types 3 & 4 is determined by the angle -// of the linedef, and is constant. -// -// For each sector where these effects occur, the sector special type has -// to have the PUSH_MASK bit set. If this bit is turned off by a switch -// at run-time, the effect will not occur. The controlling sector for -// types 1 & 2 is the sector containing the MT_PUSH/MT_PULL Thing. - - -#define PUSH_FACTOR 7 - -///////////////////////////// -// -// Add a push thinker to the thinker list - -DPusher::DPusher (DPusher::EPusher type, line_t *l, int magnitude, int angle, - AActor *source, int affectee) -{ - m_Source = source; - m_Type = type; - if (l) - { - m_Xmag = l->dx>>FRACBITS; - m_Ymag = l->dy>>FRACBITS; - m_Magnitude = P_AproxDistance (m_Xmag, m_Ymag); - } - else - { // [RH] Allow setting magnitude and angle with parameters - ChangeValues (magnitude, angle); - } - if (source) // point source exist? - { - m_Radius = (m_Magnitude) << (FRACBITS+1); // where force goes to zero - m_X = m_Source->X(); - m_Y = m_Source->Y(); - } - m_Affectee = affectee; -} - -int DPusher::CheckForSectorMatch (EPusher type, int tag) -{ - if (m_Type == type && tagManager.SectorHasTag(m_Affectee, tag)) - return m_Affectee; - else - return -1; -} - - -///////////////////////////// -// -// T_Pusher looks for all objects that are inside the radius of -// the effect. -// -void DPusher::Tick () -{ - sector_t *sec; - AActor *thing; - msecnode_t *node; - int xspeed,yspeed; - int ht; - - if (!var_pushers) - return; - - sec = sectors + m_Affectee; - - // Be sure the special sector type is still turned on. If so, proceed. - // Else, bail out; the sector type has been changed on us. - - if (!(sec->Flags & SECF_PUSH)) - return; - - // For constant pushers (wind/current) there are 3 situations: - // - // 1) Affected Thing is above the floor. - // - // Apply the full force if wind, no force if current. - // - // 2) Affected Thing is on the ground. - // - // Apply half force if wind, full force if current. - // - // 3) Affected Thing is below the ground (underwater effect). - // - // Apply no force if wind, full force if current. - // - // Apply the effect to clipped players only for now. - // - // In Phase II, you can apply these effects to Things other than players. - // [RH] No Phase II, but it works with anything having MF2_WINDTHRUST now. - - if (m_Type == p_push) - { - // Seek out all pushable things within the force radius of this - // point pusher. Crosses sectors, so use blockmap. - - FPortalGroupArray check(FPortalGroupArray::PGA_NoSectorPortals); // no sector portals because this thing is utterly z-unaware. - FMultiBlockThingsIterator it(check, m_X, m_Y, 0, 0, m_Radius, false, m_Source->Sector); - FMultiBlockThingsIterator::CheckResult cres; - - - while (it.Next(&cres)) - { - AActor *thing = cres.thing; - // Normal ZDoom is based only on the WINDTHRUST flag, with the noclip cheat as an exemption. - bool pusharound = ((thing->flags2 & MF2_WINDTHRUST) && !(thing->flags & MF_NOCLIP)); - - // MBF allows any sentient or shootable thing to be affected, but players with a fly cheat aren't. - if (compatflags & COMPATF_MBFMONSTERMOVE) - { - pusharound = ((pusharound || (thing->IsSentient()) || (thing->flags & MF_SHOOTABLE)) // Add categories here - && (!(thing->player && (thing->flags & (MF_NOGRAVITY))))); // Exclude flying players here - } - - if ((pusharound) ) - { - int sx = m_X; - int sy = m_Y; - int dist = thing->AproxDistance (sx, sy); - int speed = (m_Magnitude - ((dist>>FRACBITS)>>1))<<(FRACBITS-PUSH_FACTOR-1); - - // If speed <= 0, you're outside the effective radius. You also have - // to be able to see the push/pull source point. - - if ((speed > 0) && (P_CheckSight (thing, m_Source, SF_IGNOREVISIBILITY))) - { - angle_t pushangle = thing->AngleTo(sx, sy); - if (m_Source->GetClass()->TypeName == NAME_PointPusher) - pushangle += ANG180; // away - pushangle >>= ANGLETOFINESHIFT; - thing->vel.x += FixedMul (speed, finecosine[pushangle]); - thing->vel.y += FixedMul (speed, finesine[pushangle]); - } - } - } - return; - } - - // constant pushers p_wind and p_current - - node = sec->touching_thinglist; // things touching this sector - for ( ; node ; node = node->m_snext) - { - thing = node->m_thing; - if (!(thing->flags2 & MF2_WINDTHRUST) || (thing->flags & MF_NOCLIP)) - continue; - - sector_t *hsec = sec->GetHeightSec(); - fixedvec3 pos = thing->PosRelative(sec); - if (m_Type == p_wind) - { - if (hsec == NULL) - { // NOT special water sector - if (thing->Z() > thing->floorz) // above ground - { - xspeed = m_Xmag; // full force - yspeed = m_Ymag; - } - else // on ground - { - xspeed = (m_Xmag)>>1; // half force - yspeed = (m_Ymag)>>1; - } - } - else // special water sector - { - ht = hsec->floorplane.ZatPoint(pos); - if (thing->Z() > ht) // above ground - { - xspeed = m_Xmag; // full force - yspeed = m_Ymag; - } - else if (thing->player->viewz < ht) // underwater - { - xspeed = yspeed = 0; // no force - } - else // wading in water - { - xspeed = (m_Xmag)>>1; // half force - yspeed = (m_Ymag)>>1; - } - } - } - else // p_current - { - const secplane_t *floor; - - if (hsec == NULL) - { // NOT special water sector - floor = &sec->floorplane; - } - else - { // special water sector - floor = &hsec->floorplane; - } - if (thing->Z() > floor->ZatPoint(pos)) - { // above ground - xspeed = yspeed = 0; // no force - } - else - { // on ground/underwater - xspeed = m_Xmag; // full force - yspeed = m_Ymag; - } - } - thing->vel.x += xspeed<<(FRACBITS-PUSH_FACTOR); - thing->vel.y += yspeed<<(FRACBITS-PUSH_FACTOR); - } -} - -///////////////////////////// -// -// P_GetPushThing() returns a pointer to an MT_PUSH or MT_PULL thing, -// NULL otherwise. - -AActor *P_GetPushThing (int s) -{ - AActor* thing; - sector_t* sec; - - sec = sectors + s; - thing = sec->thinglist; - - while (thing && - thing->GetClass()->TypeName != NAME_PointPusher && - thing->GetClass()->TypeName != NAME_PointPuller) - { - thing = thing->snext; - } - return thing; -} - -///////////////////////////// -// -// Initialize the sectors where pushers are present -// - -static void P_SpawnPushers () -{ - int i; - line_t *l = lines; - int s; - - for (i = 0; i < numlines; i++, l++) - { - switch (l->special) - { - case Sector_SetWind: // wind - { - FSectorTagIterator itr(l->args[0]); - while ((s = itr.Next()) >= 0) - new DPusher(DPusher::p_wind, l->args[3] ? l : NULL, l->args[1], l->args[2], NULL, s); - l->special = 0; - break; - } - - case Sector_SetCurrent: // current - { - FSectorTagIterator itr(l->args[0]); - while ((s = itr.Next()) >= 0) - new DPusher(DPusher::p_current, l->args[3] ? l : NULL, l->args[1], l->args[2], NULL, s); - l->special = 0; - break; - } - - case PointPush_SetForce: // push/pull - if (l->args[0]) { // [RH] Find thing by sector - FSectorTagIterator itr(l->args[0]); - while ((s = itr.Next()) >= 0) - { - AActor *thing = P_GetPushThing (s); - if (thing) { // No MT_P* means no effect - // [RH] Allow narrowing it down by tid - if (!l->args[1] || l->args[1] == thing->tid) - new DPusher (DPusher::p_push, l->args[3] ? l : NULL, l->args[2], - 0, thing, s); - } - } - } else { // [RH] Find thing by tid - AActor *thing; - FActorIterator iterator (l->args[1]); - - while ( (thing = iterator.Next ()) ) - { - if (thing->GetClass()->TypeName == NAME_PointPusher || - thing->GetClass()->TypeName == NAME_PointPuller) - { - new DPusher (DPusher::p_push, l->args[3] ? l : NULL, l->args[2], - 0, thing, int(thing->Sector - sectors)); - } - } - } - l->special = 0; - break; - } - } -} - -// -// phares 3/20/98: End of Pusher effects -// -//////////////////////////////////////////////////////////////////////////// - void sector_t::AdjustFloorClip () const { msecnode_t *node; diff --git a/src/p_spec.h b/src/p_spec.h index 129e7f03b..73f913a00 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -71,51 +71,6 @@ typedef enum // (This is so scrolling floors and objects on them can move at same speed.) enum { CARRYFACTOR = (3*FRACUNIT >> 5) }; -// phares 3/20/98: added new model of Pushers for push/pull effects - -class DPusher : public DThinker -{ - DECLARE_CLASS (DPusher, DThinker) - HAS_OBJECT_POINTERS -public: - enum EPusher - { - p_push, - p_pull, - p_wind, - p_current - }; - - DPusher (); - DPusher (EPusher type, line_t *l, int magnitude, int angle, AActor *source, int affectee); - void Serialize (FArchive &arc); - int CheckForSectorMatch (EPusher type, int tag); - void ChangeValues (int magnitude, int angle) - { - angle_t ang = ((angle_t)(angle<<24)) >> ANGLETOFINESHIFT; - m_Xmag = (magnitude * finecosine[ang]) >> FRACBITS; - m_Ymag = (magnitude * finesine[ang]) >> FRACBITS; - m_Magnitude = magnitude; - } - - void Tick (); - -protected: - EPusher m_Type; - TObjPtr m_Source;// Point source if point pusher - int m_Xmag; // X Strength - int m_Ymag; // Y Strength - int m_Magnitude; // Vector strength for point pusher - int m_Radius; // Effective radius for point pusher - int m_X; // X of point source if point pusher - int m_Y; // Y of point source if point pusher - int m_Affectee; // Number of affected sector - - friend bool PIT_PushThing (AActor *thing); -}; - -bool PIT_PushThing (AActor *thing); - // Define values for map objects #define MO_TELEPORTMAN 14 From 263051a77bea81109cc309621d245bf7bf4eb32f Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Mar 2016 22:20:25 +0200 Subject: [PATCH 38/44] - removed a few unnecessary #includes. --- src/fragglescript/t_func.cpp | 1 - src/g_level.cpp | 1 - src/g_shared/a_pickups.cpp | 1 - src/g_shared/shared_sbar.cpp | 1 - src/p_interaction.cpp | 3 +-- src/p_lnspec.cpp | 1 - src/r_draw.cpp | 1 - src/statistics.cpp | 1 - src/thingdef/thingdef.cpp | 1 - src/v_blend.cpp | 1 - 10 files changed, 1 insertion(+), 11 deletions(-) diff --git a/src/fragglescript/t_func.cpp b/src/fragglescript/t_func.cpp index 953297b31..bfda35ad4 100644 --- a/src/fragglescript/t_func.cpp +++ b/src/fragglescript/t_func.cpp @@ -56,7 +56,6 @@ #include "c_console.h" #include "c_dispatch.h" #include "d_player.h" -#include "a_doomglobal.h" #include "w_wad.h" #include "gi.h" #include "zstring.h" diff --git a/src/g_level.cpp b/src/g_level.cpp index 1a626a40c..4fab2e28d 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -79,7 +79,6 @@ #include "v_palette.h" #include "menu/menu.h" #include "a_sharedglobal.h" -#include "a_strifeglobal.h" #include "r_data/colormaps.h" #include "farchive.h" #include "r_renderer.h" diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index b2a80cbc2..76f4bb033 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -11,7 +11,6 @@ #include "c_dispatch.h" #include "gstrings.h" #include "templates.h" -#include "a_strifeglobal.h" #include "a_morph.h" #include "a_specialspot.h" #include "thingdef/thingdef.h" diff --git a/src/g_shared/shared_sbar.cpp b/src/g_shared/shared_sbar.cpp index d0153a98f..16f6d7319 100644 --- a/src/g_shared/shared_sbar.cpp +++ b/src/g_shared/shared_sbar.cpp @@ -52,7 +52,6 @@ #include "v_palette.h" #include "d_player.h" #include "farchive.h" -#include "a_hexenglobal.h" #include "gstrings.h" #include "../version.h" diff --git a/src/p_interaction.cpp b/src/p_interaction.cpp index 90b43323c..648b9f46c 100644 --- a/src/p_interaction.cpp +++ b/src/p_interaction.cpp @@ -47,8 +47,7 @@ #include "b_bot.h" //Added by MC: -#include "ravenshared.h" -#include "a_hexenglobal.h" +#include "d_player.h" #include "a_sharedglobal.h" #include "a_pickups.h" #include "gi.h" diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 849295c2c..6c3dccebd 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -51,7 +51,6 @@ #include "gi.h" #include "m_random.h" #include "p_conversation.h" -#include "a_strifeglobal.h" #include "r_data/r_translate.h" #include "p_3dmidtex.h" #include "d_net.h" diff --git a/src/r_draw.cpp b/src/r_draw.cpp index c16817691..a3cb0de03 100644 --- a/src/r_draw.cpp +++ b/src/r_draw.cpp @@ -33,7 +33,6 @@ #include "v_video.h" #include "doomstat.h" #include "st_stuff.h" -#include "a_hexenglobal.h" #include "g_game.h" #include "g_level.h" #include "r_data/r_translate.h" diff --git a/src/statistics.cpp b/src/statistics.cpp index 292d66f51..3676b8678 100644 --- a/src/statistics.cpp +++ b/src/statistics.cpp @@ -62,7 +62,6 @@ #include "cmdlib.h" #include "p_terrain.h" #include "decallib.h" -#include "a_doomglobal.h" #include "autosegs.h" #include "i_cd.h" #include "stats.h" diff --git a/src/thingdef/thingdef.cpp b/src/thingdef/thingdef.cpp index 551dde93a..a24e8831c 100644 --- a/src/thingdef/thingdef.cpp +++ b/src/thingdef/thingdef.cpp @@ -57,7 +57,6 @@ #include "m_argv.h" #include "p_local.h" #include "doomerrors.h" -#include "a_hexenglobal.h" #include "a_weaponpiece.h" #include "p_conversation.h" #include "v_text.h" diff --git a/src/v_blend.cpp b/src/v_blend.cpp index 3aff4a3a3..b8f3e713d 100644 --- a/src/v_blend.cpp +++ b/src/v_blend.cpp @@ -52,7 +52,6 @@ #include "v_palette.h" #include "d_player.h" #include "farchive.h" -#include "a_hexenglobal.h" From 8c3c18b0085aeb486d6e13a774dde0b158defb42 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Mar 2016 22:25:12 +0200 Subject: [PATCH 39/44] - forgot to add this... --- src/p_pusher.cpp | 485 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 485 insertions(+) create mode 100644 src/p_pusher.cpp diff --git a/src/p_pusher.cpp b/src/p_pusher.cpp new file mode 100644 index 000000000..722e1dc0c --- /dev/null +++ b/src/p_pusher.cpp @@ -0,0 +1,485 @@ +// Emacs style mode select -*- C++ -*- +//----------------------------------------------------------------------------- +// +// $Id:$ +// +// Copyright (C) 1993-1996 by id Software, Inc. +// +// This source is available for distribution and/or modification +// only under the terms of the DOOM Source Code License as +// published by id Software. All rights reserved. +// +// The source is distributed in the hope that it will be useful, +// but WITHOUT ANY WARRANTY; without even the implied warranty of +// FITNESS FOR A PARTICULAR PURPOSE. See the DOOM Source Code License +// for more details. +// +// $Log:$ +// +// DESCRIPTION: +// Initializes and implements BOOM linedef triggers for +// Wind/Current +// +//----------------------------------------------------------------------------- + + +#include +#include "actor.h" +#include "p_spec.h" +#include "farchive.h" +#include "p_lnspec.h" +#include "c_cvars.h" +#include "p_maputl.h" +#include "p_local.h" +#include "d_player.h" + +CVAR(Bool, var_pushers, true, CVAR_SERVERINFO); + +// phares 3/20/98: added new model of Pushers for push/pull effects + +class DPusher : public DThinker +{ + DECLARE_CLASS (DPusher, DThinker) + HAS_OBJECT_POINTERS +public: + enum EPusher + { + p_push, + p_pull, + p_wind, + p_current + }; + + DPusher (); + DPusher (EPusher type, line_t *l, int magnitude, int angle, AActor *source, int affectee); + void Serialize (FArchive &arc); + int CheckForSectorMatch (EPusher type, int tag); + void ChangeValues (int magnitude, int angle) + { + angle_t ang = ((angle_t)(angle<<24)) >> ANGLETOFINESHIFT; + m_Xmag = (magnitude * finecosine[ang]) >> FRACBITS; + m_Ymag = (magnitude * finesine[ang]) >> FRACBITS; + m_Magnitude = magnitude; + } + + void Tick (); + +protected: + EPusher m_Type; + TObjPtr m_Source;// Point source if point pusher + int m_Xmag; // X Strength + int m_Ymag; // Y Strength + int m_Magnitude; // Vector strength for point pusher + int m_Radius; // Effective radius for point pusher + int m_X; // X of point source if point pusher + int m_Y; // Y of point source if point pusher + int m_Affectee; // Number of affected sector + + friend bool PIT_PushThing (AActor *thing); +}; + + +IMPLEMENT_POINTY_CLASS (DPusher) + DECLARE_POINTER (m_Source) +END_POINTERS + +DPusher::DPusher () +{ +} + +inline FArchive &operator<< (FArchive &arc, DPusher::EPusher &type) +{ + BYTE val = (BYTE)type; + arc << val; + type = (DPusher::EPusher)val; + return arc; +} + +void DPusher::Serialize (FArchive &arc) +{ + Super::Serialize (arc); + arc << m_Type + << m_Source + << m_Xmag + << m_Ymag + << m_Magnitude + << m_Radius + << m_X + << m_Y + << m_Affectee; +} + + +//////////////////////////////////////////////////////////////////////////// +// +// PUSH/PULL EFFECT +// +// phares 3/20/98: Start of push/pull effects +// +// This is where push/pull effects are applied to objects in the sectors. +// +// There are four kinds of push effects +// +// 1) Pushing Away +// +// Pushes you away from a point source defined by the location of an +// MT_PUSH Thing. The force decreases linearly with distance from the +// source. This force crosses sector boundaries and is felt w/in a circle +// whose center is at the MT_PUSH. The force is felt only if the point +// MT_PUSH can see the target object. +// +// 2) Pulling toward +// +// Same as Pushing Away except you're pulled toward an MT_PULL point +// source. This force crosses sector boundaries and is felt w/in a circle +// whose center is at the MT_PULL. The force is felt only if the point +// MT_PULL can see the target object. +// +// 3) Wind +// +// Pushes you in a constant direction. Full force above ground, half +// force on the ground, nothing if you're below it (water). +// +// 4) Current +// +// Pushes you in a constant direction. No force above ground, full +// force if on the ground or below it (water). +// +// The magnitude of the force is controlled by the length of a controlling +// linedef. The force vector for types 3 & 4 is determined by the angle +// of the linedef, and is constant. +// +// For each sector where these effects occur, the sector special type has +// to have the PUSH_MASK bit set. If this bit is turned off by a switch +// at run-time, the effect will not occur. The controlling sector for +// types 1 & 2 is the sector containing the MT_PUSH/MT_PULL Thing. + + +#define PUSH_FACTOR 7 + +///////////////////////////// +// +// Add a push thinker to the thinker list + +DPusher::DPusher (DPusher::EPusher type, line_t *l, int magnitude, int angle, + AActor *source, int affectee) +{ + m_Source = source; + m_Type = type; + if (l) + { + m_Xmag = l->dx>>FRACBITS; + m_Ymag = l->dy>>FRACBITS; + m_Magnitude = P_AproxDistance (m_Xmag, m_Ymag); + } + else + { // [RH] Allow setting magnitude and angle with parameters + ChangeValues (magnitude, angle); + } + if (source) // point source exist? + { + m_Radius = (m_Magnitude) << (FRACBITS+1); // where force goes to zero + m_X = m_Source->X(); + m_Y = m_Source->Y(); + } + m_Affectee = affectee; +} + +int DPusher::CheckForSectorMatch (EPusher type, int tag) +{ + if (m_Type == type && tagManager.SectorHasTag(m_Affectee, tag)) + return m_Affectee; + else + return -1; +} + + +///////////////////////////// +// +// T_Pusher looks for all objects that are inside the radius of +// the effect. +// +void DPusher::Tick () +{ + sector_t *sec; + AActor *thing; + msecnode_t *node; + int xspeed,yspeed; + int ht; + + if (!var_pushers) + return; + + sec = sectors + m_Affectee; + + // Be sure the special sector type is still turned on. If so, proceed. + // Else, bail out; the sector type has been changed on us. + + if (!(sec->Flags & SECF_PUSH)) + return; + + // For constant pushers (wind/current) there are 3 situations: + // + // 1) Affected Thing is above the floor. + // + // Apply the full force if wind, no force if current. + // + // 2) Affected Thing is on the ground. + // + // Apply half force if wind, full force if current. + // + // 3) Affected Thing is below the ground (underwater effect). + // + // Apply no force if wind, full force if current. + // + // Apply the effect to clipped players only for now. + // + // In Phase II, you can apply these effects to Things other than players. + // [RH] No Phase II, but it works with anything having MF2_WINDTHRUST now. + + if (m_Type == p_push) + { + // Seek out all pushable things within the force radius of this + // point pusher. Crosses sectors, so use blockmap. + + FPortalGroupArray check(FPortalGroupArray::PGA_NoSectorPortals); // no sector portals because this thing is utterly z-unaware. + FMultiBlockThingsIterator it(check, m_X, m_Y, 0, 0, m_Radius, false, m_Source->Sector); + FMultiBlockThingsIterator::CheckResult cres; + + + while (it.Next(&cres)) + { + AActor *thing = cres.thing; + // Normal ZDoom is based only on the WINDTHRUST flag, with the noclip cheat as an exemption. + bool pusharound = ((thing->flags2 & MF2_WINDTHRUST) && !(thing->flags & MF_NOCLIP)); + + // MBF allows any sentient or shootable thing to be affected, but players with a fly cheat aren't. + if (compatflags & COMPATF_MBFMONSTERMOVE) + { + pusharound = ((pusharound || (thing->IsSentient()) || (thing->flags & MF_SHOOTABLE)) // Add categories here + && (!(thing->player && (thing->flags & (MF_NOGRAVITY))))); // Exclude flying players here + } + + if ((pusharound) ) + { + int sx = m_X; + int sy = m_Y; + int dist = thing->AproxDistance (sx, sy); + int speed = (m_Magnitude - ((dist>>FRACBITS)>>1))<<(FRACBITS-PUSH_FACTOR-1); + + // If speed <= 0, you're outside the effective radius. You also have + // to be able to see the push/pull source point. + + if ((speed > 0) && (P_CheckSight (thing, m_Source, SF_IGNOREVISIBILITY))) + { + angle_t pushangle = thing->AngleTo(sx, sy); + if (m_Source->GetClass()->TypeName == NAME_PointPusher) + pushangle += ANG180; // away + pushangle >>= ANGLETOFINESHIFT; + thing->vel.x += FixedMul (speed, finecosine[pushangle]); + thing->vel.y += FixedMul (speed, finesine[pushangle]); + } + } + } + return; + } + + // constant pushers p_wind and p_current + + node = sec->touching_thinglist; // things touching this sector + for ( ; node ; node = node->m_snext) + { + thing = node->m_thing; + if (!(thing->flags2 & MF2_WINDTHRUST) || (thing->flags & MF_NOCLIP)) + continue; + + sector_t *hsec = sec->GetHeightSec(); + fixedvec3 pos = thing->PosRelative(sec); + if (m_Type == p_wind) + { + if (hsec == NULL) + { // NOT special water sector + if (thing->Z() > thing->floorz) // above ground + { + xspeed = m_Xmag; // full force + yspeed = m_Ymag; + } + else // on ground + { + xspeed = (m_Xmag)>>1; // half force + yspeed = (m_Ymag)>>1; + } + } + else // special water sector + { + ht = hsec->floorplane.ZatPoint(pos); + if (thing->Z() > ht) // above ground + { + xspeed = m_Xmag; // full force + yspeed = m_Ymag; + } + else if (thing->player->viewz < ht) // underwater + { + xspeed = yspeed = 0; // no force + } + else // wading in water + { + xspeed = (m_Xmag)>>1; // half force + yspeed = (m_Ymag)>>1; + } + } + } + else // p_current + { + const secplane_t *floor; + + if (hsec == NULL) + { // NOT special water sector + floor = &sec->floorplane; + } + else + { // special water sector + floor = &hsec->floorplane; + } + if (thing->Z() > floor->ZatPoint(pos)) + { // above ground + xspeed = yspeed = 0; // no force + } + else + { // on ground/underwater + xspeed = m_Xmag; // full force + yspeed = m_Ymag; + } + } + thing->vel.x += xspeed<<(FRACBITS-PUSH_FACTOR); + thing->vel.y += yspeed<<(FRACBITS-PUSH_FACTOR); + } +} + +///////////////////////////// +// +// P_GetPushThing() returns a pointer to an MT_PUSH or MT_PULL thing, +// NULL otherwise. + +AActor *P_GetPushThing (int s) +{ + AActor* thing; + sector_t* sec; + + sec = sectors + s; + thing = sec->thinglist; + + while (thing && + thing->GetClass()->TypeName != NAME_PointPusher && + thing->GetClass()->TypeName != NAME_PointPuller) + { + thing = thing->snext; + } + return thing; +} + +///////////////////////////// +// +// Initialize the sectors where pushers are present +// + +void P_SpawnPushers () +{ + int i; + line_t *l = lines; + int s; + + for (i = 0; i < numlines; i++, l++) + { + switch (l->special) + { + case Sector_SetWind: // wind + { + FSectorTagIterator itr(l->args[0]); + while ((s = itr.Next()) >= 0) + new DPusher(DPusher::p_wind, l->args[3] ? l : NULL, l->args[1], l->args[2], NULL, s); + l->special = 0; + break; + } + + case Sector_SetCurrent: // current + { + FSectorTagIterator itr(l->args[0]); + while ((s = itr.Next()) >= 0) + new DPusher(DPusher::p_current, l->args[3] ? l : NULL, l->args[1], l->args[2], NULL, s); + l->special = 0; + break; + } + + case PointPush_SetForce: // push/pull + if (l->args[0]) { // [RH] Find thing by sector + FSectorTagIterator itr(l->args[0]); + while ((s = itr.Next()) >= 0) + { + AActor *thing = P_GetPushThing (s); + if (thing) { // No MT_P* means no effect + // [RH] Allow narrowing it down by tid + if (!l->args[1] || l->args[1] == thing->tid) + new DPusher (DPusher::p_push, l->args[3] ? l : NULL, l->args[2], + 0, thing, s); + } + } + } else { // [RH] Find thing by tid + AActor *thing; + FActorIterator iterator (l->args[1]); + + while ( (thing = iterator.Next ()) ) + { + if (thing->GetClass()->TypeName == NAME_PointPusher || + thing->GetClass()->TypeName == NAME_PointPuller) + { + new DPusher (DPusher::p_push, l->args[3] ? l : NULL, l->args[2], + 0, thing, int(thing->Sector - sectors)); + } + } + } + l->special = 0; + break; + } + } +} + +void AdjustPusher (int tag, int magnitude, int angle, bool wind) +{ + DPusher::EPusher type = wind? DPusher::p_wind : DPusher::p_current; + + // Find pushers already attached to the sector, and change their parameters. + TArray Collection; + { + TThinkerIterator iterator; + FThinkerCollection collect; + + while ( (collect.Obj = iterator.Next ()) ) + { + if ((collect.RefNum = ((DPusher *)collect.Obj)->CheckForSectorMatch (type, tag)) >= 0) + { + ((DPusher *)collect.Obj)->ChangeValues (magnitude, angle); + Collection.Push (collect); + } + } + } + + size_t numcollected = Collection.Size (); + int secnum; + + // Now create pushers for any sectors that don't already have them. + FSectorTagIterator itr(tag); + while ((secnum = itr.Next()) >= 0) + { + unsigned int i; + for (i = 0; i < numcollected; i++) + { + if (Collection[i].RefNum == sectors[secnum].sectornum) + break; + } + if (i == numcollected) + { + new DPusher (type, NULL, magnitude, angle, NULL, secnum); + } + } +} From 0283df4c42b7955a76eb32c07dfe34960ca54a56 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Mar 2016 22:47:45 +0200 Subject: [PATCH 40/44] - restored floating point pusher code. --- src/p_maputl.h | 1 + src/p_pusher.cpp | 80 ++++++++++++++++++------------------------------ 2 files changed, 31 insertions(+), 50 deletions(-) diff --git a/src/p_maputl.h b/src/p_maputl.h index 196ba5bdc..63875ef89 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -1,6 +1,7 @@ #ifndef __P_MAPUTL_H #define __P_MAPUTL_H +#include #include "r_defs.h" #include "doomstat.h" #include "m_bbox.h" diff --git a/src/p_pusher.cpp b/src/p_pusher.cpp index 722e1dc0c..b6fd2d884 100644 --- a/src/p_pusher.cpp +++ b/src/p_pusher.cpp @@ -56,9 +56,8 @@ public: int CheckForSectorMatch (EPusher type, int tag); void ChangeValues (int magnitude, int angle) { - angle_t ang = ((angle_t)(angle<<24)) >> ANGLETOFINESHIFT; - m_Xmag = (magnitude * finecosine[ang]) >> FRACBITS; - m_Ymag = (magnitude * finesine[ang]) >> FRACBITS; + DAngle ang = angle * (360. / 256.); + m_PushVec = ang.ToVector(magnitude); m_Magnitude = magnitude; } @@ -67,12 +66,9 @@ public: protected: EPusher m_Type; TObjPtr m_Source;// Point source if point pusher - int m_Xmag; // X Strength - int m_Ymag; // Y Strength - int m_Magnitude; // Vector strength for point pusher - int m_Radius; // Effective radius for point pusher - int m_X; // X of point source if point pusher - int m_Y; // Y of point source if point pusher + DVector2 m_PushVec; + double m_Magnitude; // Vector strength for point pusher + double m_Radius; // Effective radius for point pusher int m_Affectee; // Number of affected sector friend bool PIT_PushThing (AActor *thing); @@ -100,12 +96,9 @@ void DPusher::Serialize (FArchive &arc) Super::Serialize (arc); arc << m_Type << m_Source - << m_Xmag - << m_Ymag + << m_PushVec << m_Magnitude << m_Radius - << m_X - << m_Y << m_Affectee; } @@ -155,7 +148,7 @@ void DPusher::Serialize (FArchive &arc) // types 1 & 2 is the sector containing the MT_PUSH/MT_PULL Thing. -#define PUSH_FACTOR 7 +#define PUSH_FACTOR 128 ///////////////////////////// // @@ -168,9 +161,8 @@ DPusher::DPusher (DPusher::EPusher type, line_t *l, int magnitude, int angle, m_Type = type; if (l) { - m_Xmag = l->dx>>FRACBITS; - m_Ymag = l->dy>>FRACBITS; - m_Magnitude = P_AproxDistance (m_Xmag, m_Ymag); + m_PushVec = l->Delta(); + m_Magnitude = m_PushVec.Length(); } else { // [RH] Allow setting magnitude and angle with parameters @@ -178,9 +170,7 @@ DPusher::DPusher (DPusher::EPusher type, line_t *l, int magnitude, int angle, } if (source) // point source exist? { - m_Radius = (m_Magnitude) << (FRACBITS+1); // where force goes to zero - m_X = m_Source->X(); - m_Y = m_Source->Y(); + m_Radius = m_Magnitude * 2; // where force goes to zero } m_Affectee = affectee; } @@ -204,8 +194,7 @@ void DPusher::Tick () sector_t *sec; AActor *thing; msecnode_t *node; - int xspeed,yspeed; - int ht; + double ht; if (!var_pushers) return; @@ -243,7 +232,7 @@ void DPusher::Tick () // point pusher. Crosses sectors, so use blockmap. FPortalGroupArray check(FPortalGroupArray::PGA_NoSectorPortals); // no sector portals because this thing is utterly z-unaware. - FMultiBlockThingsIterator it(check, m_X, m_Y, 0, 0, m_Radius, false, m_Source->Sector); + FMultiBlockThingsIterator it(check, m_Source, FLOAT2FIXED(m_Radius)); FMultiBlockThingsIterator::CheckResult cres; @@ -262,22 +251,18 @@ void DPusher::Tick () if ((pusharound) ) { - int sx = m_X; - int sy = m_Y; - int dist = thing->AproxDistance (sx, sy); - int speed = (m_Magnitude - ((dist>>FRACBITS)>>1))<<(FRACBITS-PUSH_FACTOR-1); + DVector2 pos = m_Source->Vec2To(thing); + double dist = pos.Length(); + double speed = (m_Magnitude - (dist/2)) / (PUSH_FACTOR * 2); // If speed <= 0, you're outside the effective radius. You also have // to be able to see the push/pull source point. if ((speed > 0) && (P_CheckSight (thing, m_Source, SF_IGNOREVISIBILITY))) { - angle_t pushangle = thing->AngleTo(sx, sy); - if (m_Source->GetClass()->TypeName == NAME_PointPusher) - pushangle += ANG180; // away - pushangle >>= ANGLETOFINESHIFT; - thing->vel.x += FixedMul (speed, finecosine[pushangle]); - thing->vel.y += FixedMul (speed, finesine[pushangle]); + DAngle pushangle = pos.Angle(); + if (m_Source->GetClass()->TypeName == NAME_PointPuller) pushangle += 180; + thing->Thrust(pushangle, speed); } } } @@ -294,38 +279,35 @@ void DPusher::Tick () continue; sector_t *hsec = sec->GetHeightSec(); - fixedvec3 pos = thing->PosRelative(sec); + fixedvec3 pos = thing->_f_PosRelative(sec); + DVector2 pushvel; if (m_Type == p_wind) { if (hsec == NULL) { // NOT special water sector if (thing->Z() > thing->floorz) // above ground { - xspeed = m_Xmag; // full force - yspeed = m_Ymag; + pushvel = m_PushVec; // full force } else // on ground { - xspeed = (m_Xmag)>>1; // half force - yspeed = (m_Ymag)>>1; + pushvel = m_PushVec / 2; // half force } } else // special water sector { - ht = hsec->floorplane.ZatPoint(pos); + ht = hsec->floorplane.ZatPointF(pos); if (thing->Z() > ht) // above ground { - xspeed = m_Xmag; // full force - yspeed = m_Ymag; + pushvel = m_PushVec; // full force } else if (thing->player->viewz < ht) // underwater { - xspeed = yspeed = 0; // no force + pushvel.Zero(); // no force } else // wading in water { - xspeed = (m_Xmag)>>1; // half force - yspeed = (m_Ymag)>>1; + pushvel = m_PushVec / 2; // full force } } } @@ -341,18 +323,16 @@ void DPusher::Tick () { // special water sector floor = &hsec->floorplane; } - if (thing->Z() > floor->ZatPoint(pos)) + if (thing->Z() > floor->ZatPointF(pos)) { // above ground - xspeed = yspeed = 0; // no force + pushvel.Zero(); // no force } else { // on ground/underwater - xspeed = m_Xmag; // full force - yspeed = m_Ymag; + pushvel = m_PushVec; // full force } } - thing->vel.x += xspeed<<(FRACBITS-PUSH_FACTOR); - thing->vel.y += yspeed<<(FRACBITS-PUSH_FACTOR); + thing->Vel += pushvel / PUSH_FACTOR; } } From a92de84cf795af39b1387417761cf432d87bba16 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Mon, 28 Mar 2016 22:53:10 +0200 Subject: [PATCH 41/44] - this stuff should not have been saved... --- src/g_level.cpp | 1 + src/g_shared/a_pickups.cpp | 1 + src/p_lnspec.cpp | 1 + 3 files changed, 3 insertions(+) diff --git a/src/g_level.cpp b/src/g_level.cpp index 4fab2e28d..1a626a40c 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -79,6 +79,7 @@ #include "v_palette.h" #include "menu/menu.h" #include "a_sharedglobal.h" +#include "a_strifeglobal.h" #include "r_data/colormaps.h" #include "farchive.h" #include "r_renderer.h" diff --git a/src/g_shared/a_pickups.cpp b/src/g_shared/a_pickups.cpp index 76f4bb033..b2a80cbc2 100644 --- a/src/g_shared/a_pickups.cpp +++ b/src/g_shared/a_pickups.cpp @@ -11,6 +11,7 @@ #include "c_dispatch.h" #include "gstrings.h" #include "templates.h" +#include "a_strifeglobal.h" #include "a_morph.h" #include "a_specialspot.h" #include "thingdef/thingdef.h" diff --git a/src/p_lnspec.cpp b/src/p_lnspec.cpp index 6c3dccebd..849295c2c 100644 --- a/src/p_lnspec.cpp +++ b/src/p_lnspec.cpp @@ -51,6 +51,7 @@ #include "gi.h" #include "m_random.h" #include "p_conversation.h" +#include "a_strifeglobal.h" #include "r_data/r_translate.h" #include "p_3dmidtex.h" #include "d_net.h" From c776a0fb54768449116ceeac3f25311ea941c9a6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 29 Mar 2016 00:31:59 +0200 Subject: [PATCH 42/44] - floatification of p_teleport and p_switch.cpp. --- src/d_net.cpp | 2 +- src/p_local.h | 9 ---- src/p_spec.cpp | 28 +++++----- src/p_spec.h | 6 +-- src/p_switch.cpp | 40 ++++++-------- src/p_teleport.cpp | 129 ++++++++++++++++----------------------------- src/p_terrain.cpp | 6 --- src/r_defs.h | 12 ++++- 8 files changed, 88 insertions(+), 144 deletions(-) diff --git a/src/d_net.cpp b/src/d_net.cpp index 4fe85f239..0758ebe38 100644 --- a/src/d_net.cpp +++ b/src/d_net.cpp @@ -2203,7 +2203,7 @@ void Net_DoCommand (int type, BYTE **stream, int player) x = ReadWord (stream); y = ReadWord (stream); z = ReadWord (stream); - P_TeleportMove (players[player].mo, x * 65536, y * 65536, z * 65536, true); + P_TeleportMove (players[player].mo, DVector3(x, y, z), true); } break; diff --git a/src/p_local.h b/src/p_local.h index d4d1a3591..de40b2f47 100644 --- a/src/p_local.h +++ b/src/p_local.h @@ -259,15 +259,6 @@ void P_ApplyTorque(AActor *mo); bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modifyactor = true); // [RH] Added z and telefrag parameters -inline bool P_TeleportMove (AActor* thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag, bool modifyactor = true) -{ - return P_TeleportMove(thing, DVector3(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)), telefrag, modifyactor); -} -inline bool P_TeleportMove(AActor* thing, const fixedvec3 &pos, bool telefrag, bool modifyactor = true) -{ - return P_TeleportMove(thing, DVector3(FIXED2DBL(pos.x), FIXED2DBL(pos.y), FIXED2DBL(pos.z)), telefrag, modifyactor); -} - void P_PlayerStartStomp (AActor *actor, bool mononly=false); // [RH] Stomp on things for a newly spawned player void P_SlideMove (AActor* mo, const DVector2 &pos, int numsteps); bool P_BounceWall (AActor *mo); diff --git a/src/p_spec.cpp b/src/p_spec.cpp index 088167f9e..3356def66 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -453,7 +453,7 @@ static void DoSectorDamage(AActor *actor, sector_t *sec, int amount, FName type, if (!(flags & DAMAGE_PLAYERS) && actor->player != NULL) return; - if (!(flags & DAMAGE_IN_AIR) && actor->_f_Z() != sec->floorplane.ZatPoint(actor) && !actor->waterlevel) + if (!(flags & DAMAGE_IN_AIR) && !actor->isAtZ(sec->floorplane.ZatPointF(actor)) && !actor->waterlevel) return; if (protectClass != NULL) @@ -490,21 +490,21 @@ void P_SectorDamage(int tag, int amount, FName type, PClassActor *protectClass, { next = actor->snext; // Only affect actors touching the 3D floor - fixed_t z1 = sec->floorplane.ZatPoint(actor); - fixed_t z2 = sec->ceilingplane.ZatPoint(actor); + double z1 = sec->floorplane.ZatPointF(actor); + double z2 = sec->ceilingplane.ZatPointF(actor); if (z2 < z1) { // Account for Vavoom-style 3D floors - fixed_t zz = z1; + double zz = z1; z1 = z2; z2 = zz; } - if (actor->_f_Z() + actor->_f_height() > z1) + if (actor->Top() > z1) { // If DAMAGE_IN_AIR is used, anything not beneath the 3D floor will be // damaged (so, anything touching it or above it). Other 3D floors between // the actor and this one will not stop this effect. - if ((flags & DAMAGE_IN_AIR) || actor->_f_Z() <= z2) + if ((flags & DAMAGE_IN_AIR) || !actor->isAbove(z2)) { // Here we pass the DAMAGE_IN_AIR flag to disable the floor check, since it // only works with the real sector's floor. We did the appropriate height checks @@ -901,7 +901,7 @@ void P_SetupPortals() } } -static void SetPortal(sector_t *sector, int plane, ASkyViewpoint *portal, fixed_t alpha) +static void SetPortal(sector_t *sector, int plane, ASkyViewpoint *portal, double alpha) { // plane: 0=floor, 1=ceiling, 2=both if (plane > 0) @@ -909,7 +909,7 @@ static void SetPortal(sector_t *sector, int plane, ASkyViewpoint *portal, fixed_ if (sector->SkyBoxes[sector_t::ceiling] == NULL || !barrier_cast(sector->SkyBoxes[sector_t::ceiling])->bAlways) { sector->SkyBoxes[sector_t::ceiling] = portal; - if (sector->GetAlpha(sector_t::ceiling) == OPAQUE) + if (sector->GetAlphaF(sector_t::ceiling) == 1.) sector->SetAlpha(sector_t::ceiling, alpha); if (!portal->bAlways) sector->SetTexture(sector_t::ceiling, skyflatnum); @@ -921,14 +921,14 @@ static void SetPortal(sector_t *sector, int plane, ASkyViewpoint *portal, fixed_ { sector->SkyBoxes[sector_t::floor] = portal; } - if (sector->GetAlpha(sector_t::floor) == OPAQUE) + if (sector->GetAlphaF(sector_t::floor) == 1.) sector->SetAlpha(sector_t::floor, alpha); if (!portal->bAlways) sector->SetTexture(sector_t::floor, skyflatnum); } } -static void CopyPortal(int sectortag, int plane, ASkyViewpoint *origin, fixed_t alpha, bool tolines) +static void CopyPortal(int sectortag, int plane, ASkyViewpoint *origin, double alpha, bool tolines) { int s; FSectorTagIterator itr(sectortag); @@ -962,7 +962,7 @@ static void CopyPortal(int sectortag, int plane, ASkyViewpoint *origin, fixed_t } } -void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha, int linked) +void P_SpawnPortal(line_t *line, int sectortag, int plane, int bytealpha, int linked) { if (plane < 0 || plane > 2 || (linked && plane == 2)) return; for (int i=0;ifX() + lines[i].v2->fX()) / 2, (lines[i].v1->fY() + lines[i].v2->fY()) / 2, 0); double z = linked ? line->frontsector->GetPlaneTexZF(plane) : 0; // the map's sector height defines the portal plane for linked portals - fixed_t alpha = Scale (lines[i].args[4], OPAQUE, 255); + double alpha = bytealpha / 255.; AStackPoint *anchor = Spawn(pos1, NO_REPLACE); AStackPoint *reference = Spawn(pos2, NO_REPLACE); @@ -1012,7 +1012,7 @@ void P_SpawnSkybox(ASkyViewpoint *origin) if (Sector == NULL) { Printf("Sector not initialized for SkyCamCompat\n"); - origin->Sector = Sector = P_PointInSector(origin->_f_X(), origin->_f_Y()); + origin->Sector = Sector = P_PointInSector(origin->Pos()); } if (Sector) { @@ -1410,7 +1410,7 @@ void P_SpawnSpecials (void) case Init_Damage: { - int damage = P_AproxDistance (lines[i].dx, lines[i].dy) >> FRACBITS; + int damage = int(lines[i].Delta().Length()); FSectorTagIterator itr(lines[i].args[0]); while ((s = itr.Next()) >= 0) { diff --git a/src/p_spec.h b/src/p_spec.h index 29fea4731..f5c4d49e0 100644 --- a/src/p_spec.h +++ b/src/p_spec.h @@ -878,11 +878,7 @@ inline void P_SpawnTeleportFog(AActor *mobj, double x, double y, double z, bool } */ -bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, int flags); // bool useFog, bool sourceFog, bool keepOrientation, bool haltVelocity = true, bool keepHeight = false -inline bool P_Teleport(AActor *thing, const DVector3 &pos, DAngle angle, int flags) -{ - return P_Teleport(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), angle, flags); -} +inline bool P_Teleport(AActor *thing, DVector3 pos, DAngle angle, int flags); bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags); bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBOOL reverse); bool EV_TeleportOther (int other_tid, int dest_tid, bool fog); diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 82067f624..fdea7747b 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -59,7 +59,7 @@ class DActiveButton : public DThinker DECLARE_CLASS (DActiveButton, DThinker) public: DActiveButton (); - DActiveButton (side_t *, int, FSwitchDef *, fixed_t x, fixed_t y, bool flippable); + DActiveButton (side_t *, int, FSwitchDef *, const DVector2 &pos, bool flippable); void Serialize (FArchive &arc); void Tick (); @@ -71,7 +71,7 @@ public: FSwitchDef *m_SwitchDef; SDWORD m_Frame; DWORD m_Timer; - fixed_t m_X, m_Y; // Location of timer sound + DVector2 m_Pos; protected: bool AdvanceFrame (); @@ -85,7 +85,7 @@ protected: // //========================================================================== -static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, fixed_t x, fixed_t y, bool useagain) +static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, const DVector2 &pos, bool useagain) { DActiveButton *button; TThinkerIterator iterator; @@ -100,7 +100,7 @@ static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, fixed_t } } - new DActiveButton (side, Where, Switch, x, y, useagain); + new DActiveButton (side, Where, Switch, pos, useagain); return true; } @@ -185,13 +185,12 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 * // Check 3D floors on back side { sector_t * back = line->sidedef[1 - sideno]->sector; - for (unsigned i = 0; i < back->e->XFloor.ffloors.Size(); i++) + for (auto rover : back->e->XFloor.ffloors) { - F3DFloor *rover = back->e->XFloor.ffloors[i]; if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_UPPERTEXTURE)) continue; - if (user->Z() > rover->top.plane->ZatPoint(check) || + if (user->isAbove(rover->top.plane->ZatPoint(check)) || user->Top() < rover->bottom.plane->ZatPoint(check)) continue; @@ -213,7 +212,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 * if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_LOWERTEXTURE)) continue; - if (user->Z() > rover->top.plane->ZatPoint(check) || + if (user->isAbove(rover->top.plane->ZatPoint(check)) || user->Top() < rover->bottom.plane->ZatPoint(check)) continue; @@ -230,12 +229,12 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 * // to keep compatibility with Eternity's implementation. if (!P_GetMidTexturePosition(line, sideno, &checktop, &checkbot)) return false; - return user->Z() < checktop && user->Top() > checkbot; + return user->isBelow(checktop) && user->Top() > checkbot; } else { // no switch found. Check whether the player can touch either top or bottom texture - return (user->Top() > open.top) || (user->Z() < open.bottom); + return (user->Top() > open.top) || (user->isBelow(open.bottom)); } } @@ -292,16 +291,13 @@ bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *ques // which wasn't necessarily anywhere near the switch if it was // facing a big sector (and which wasn't necessarily for the // button just activated, either). - fixed_t pt[2]; - line_t *line = side->linedef; + DVector2 pt(side->linedef->v1->fPos() + side->linedef->Delta() / 2); bool playsound; - pt[0] = line->v1->x + (line->dx >> 1); - pt[1] = line->v1->y + (line->dy >> 1); side->SetTexture(texture, Switch->frames[0].Texture); if (useAgain || Switch->NumFrames > 1) { - playsound = P_StartButton (side, texture, Switch, pt[0], pt[1], !!useAgain); + playsound = P_StartButton (side, texture, Switch, pt, !!useAgain); } else { @@ -309,7 +305,7 @@ bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *ques } if (playsound) { - S_Sound (DVector3(FIXED2DBL(pt[0]), FIXED2DBL(pt[1]), 0), CHAN_VOICE|CHAN_LISTENERZ, sound, 1, ATTN_STATIC); + S_Sound (DVector3(pt, 0), CHAN_VOICE|CHAN_LISTENERZ, sound, 1, ATTN_STATIC); } if (quest != NULL) { @@ -332,20 +328,18 @@ DActiveButton::DActiveButton () m_Part = -1; m_SwitchDef = 0; m_Timer = 0; - m_X = 0; - m_Y = 0; + m_Pos = { 0,0 }; bFlippable = false; bReturning = false; m_Frame = 0; } DActiveButton::DActiveButton (side_t *side, int Where, FSwitchDef *Switch, - fixed_t x, fixed_t y, bool useagain) + const DVector2 &pos, bool useagain) { m_Side = side; m_Part = SBYTE(Where); - m_X = x; - m_Y = y; + m_Pos = pos; bFlippable = useagain; bReturning = false; @@ -363,7 +357,7 @@ DActiveButton::DActiveButton (side_t *side, int Where, FSwitchDef *Switch, void DActiveButton::Serialize (FArchive &arc) { Super::Serialize (arc); - arc << m_Side << m_Part << m_SwitchDef << m_Frame << m_Timer << bFlippable << m_X << m_Y << bReturning; + arc << m_Side << m_Part << m_SwitchDef << m_Frame << m_Timer << bFlippable << m_Pos << bReturning; } //========================================================================== @@ -391,7 +385,7 @@ void DActiveButton::Tick () if (def != NULL) { m_Frame = -1; - S_Sound (DVector3(FIXED2DBL(m_X), FIXED2DBL(m_Y), 0), CHAN_VOICE|CHAN_LISTENERZ, + S_Sound (DVector3(m_Pos, 0), CHAN_VOICE|CHAN_LISTENERZ, def->Sound != 0 ? FSoundID(def->Sound) : FSoundID("switches/normbutn"), 1, ATTN_STATIC); bFlippable = false; diff --git a/src/p_teleport.cpp b/src/p_teleport.cpp index 8b5369f20..8dba3a772 100644 --- a/src/p_teleport.cpp +++ b/src/p_teleport.cpp @@ -99,50 +99,50 @@ void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele, bool // TELEPORTATION // -bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, int flags) +bool P_Teleport (AActor *thing, DVector3 pos, DAngle angle, int flags) { bool predicting = (thing->player && (thing->player->cheats & CF_PREDICTING)); DVector3 old; - fixed_t aboveFloor; + double aboveFloor; player_t *player; sector_t *destsect; bool resetpitch = false; - fixed_t floorheight, ceilingheight; + double floorheight, ceilingheight; double missilespeed = 0; old = thing->Pos(); - aboveFloor = thing->_f_Z() - thing->_f_floorz(); - destsect = P_PointInSector (x, y); + aboveFloor = thing->Z() - thing->floorz; + destsect = P_PointInSector (pos); // killough 5/12/98: exclude voodoo dolls: player = thing->player; if (player && player->mo != thing) player = NULL; - floorheight = destsect->floorplane.ZatPoint (x, y); - ceilingheight = destsect->ceilingplane.ZatPoint (x, y); + floorheight = destsect->floorplane.ZatPoint (pos); + ceilingheight = destsect->ceilingplane.ZatPoint (pos); if (thing->flags & MF_MISSILE) { // We don't measure z velocity, because it doesn't change. missilespeed = thing->VelXYToSpeed(); } if (flags & TELF_KEEPHEIGHT) { - z = floorheight + aboveFloor; + pos.Z = floorheight + aboveFloor; } - else if (z == ONFLOORZ) + else if (pos.Z == ONFLOORZ) { if (player) { if (thing->flags & MF_NOGRAVITY && aboveFloor) { - z = floorheight + aboveFloor; - if (z + thing->_f_height() > ceilingheight) + pos.Z = floorheight + aboveFloor; + if (pos.Z + thing->Height > ceilingheight) { - z = ceilingheight - thing->_f_height(); + pos.Z = ceilingheight - thing->Height; } } else { - z = floorheight; + pos.Z = floorheight; if (!(flags & TELF_KEEPORIENTATION)) { resetpitch = false; @@ -151,18 +151,18 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i } else if (thing->flags & MF_MISSILE) { - z = floorheight + aboveFloor; - if (z + thing->_f_height() > ceilingheight) + pos.Z = floorheight + aboveFloor; + if (pos.Z + thing->Height > ceilingheight) { - z = ceilingheight - thing->_f_height(); + pos.Z = ceilingheight - thing->Height; } } else { - z = floorheight; + pos.Z = floorheight; } } - if (!P_TeleportMove (thing, x, y, z, false)) + if (!P_TeleportMove (thing, pos, false)) { return false; } @@ -193,7 +193,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, DAngle angle, i { double fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT; DVector2 vector = angle.ToVector(20); - DVector2 fogpos = P_GetOffsetPosition(FIXED2DBL(x), FIXED2DBL(y), vector.X, vector.Y); + DVector2 fogpos = P_GetOffsetPosition(pos.X, pos.Y, vector.X, vector.Y); P_SpawnTeleportFog(thing, DVector3(fogpos, thing->Z() + fogDelta), false, true); } @@ -324,7 +324,7 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom) bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags) { AActor *searcher; - fixed_t z; + double z; DAngle angle = 0.; double s = 0, c = 0; double vx = 0, vy = 0; @@ -365,11 +365,11 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f vx = thing->Vel.X; vy = thing->Vel.Y; - z = searcher->_f_Z(); + z = searcher->Z(); } else if (searcher->IsKindOf (PClass::FindClass(NAME_TeleportDest2))) { - z = searcher->_f_Z(); + z = searcher->Z(); } else { @@ -379,7 +379,7 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f { badangle = 0.01; } - if (P_Teleport (thing, searcher->_f_X(), searcher->_f_Y(), z, searcher->Angles.Yaw + badangle, flags)) + if (P_Teleport (thing, DVector3(searcher->Pos(), z), searcher->Angles.Yaw + badangle, flags)) { // [RH] Lee Killough's changes for silent teleporters from BOOM if (!(flags & TELF_DESTFOG) && line && (flags & TELF_KEEPORIENTATION)) @@ -484,12 +484,10 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO thing->player : NULL; // Whether walking towards first side of exit linedef steps down - fixed_t x = FLOAT2FIXED(p.X); - fixed_t y = FLOAT2FIXED(p.Y); - bool stepdown = l->frontsector->floorplane.ZatPoint(x, y) < l->backsector->floorplane.ZatPoint(x, y); + bool stepdown = l->frontsector->floorplane.ZatPoint(p) < l->backsector->floorplane.ZatPoint(p); // Height of thing above ground - fixed_t z = thing->_f_Z() - thing->_f_floorz(); + double z = thing->Z() - thing->floorz; // Side to exit the linedef on positionally. // @@ -513,25 +511,30 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO // Exiting on side 1 slightly improves player viewing // when going down a step on a non-reversed teleporter. + // Is this really still necessary with real math instead of imprecise trig tables? +#if 1 int side = reverse || (player && stepdown); int fudge = FUDGEFACTOR; + double dx = line->Delta().X; + double dy = line->Delta().Y; // Make sure we are on correct side of exit linedef. - while (P_PointOnLineSidePrecise(x, y, l) != side && --fudge >= 0) + while (P_PointOnLineSidePrecise(p, l) != side && --fudge >= 0) { - if (abs(l->dx) > abs(l->dy)) - y -= (l->dx < 0) != side ? -1 : 1; + if (fabs(dx) > fabs(dy)) + p.Y -= (dx < 0) != side ? -1 : 1; else - x += (l->dy < 0) != side ? -1 : 1; + p.X += (dy < 0) != side ? -1 : 1; } +#endif // Adjust z position to be same height above ground as before. // Ground level at the exit is measured as the higher of the // two floor heights at the exit linedef. - z = z + l->sidedef[stepdown]->sector->floorplane.ZatPoint(x, y); + z = z + l->sidedef[stepdown]->sector->floorplane.ZatPoint(p); // Attempt to teleport, aborting if blocked - if (!P_TeleportMove (thing, x, y, z, false)) + if (!P_TeleportMove (thing, DVector3(p, z), false)) { return false; } @@ -544,10 +547,8 @@ bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBO // Rotate thing's orientation according to difference in linedef angles thing->Angles.Yaw += angle; - // Velocity of thing crossing teleporter linedef - p = thing->Vel.XY(); - // Rotate thing's velocity to come out of exit just like it entered + p = thing->Vel.XY(); thing->Vel.X = p.X*c - p.Y*s; thing->Vel.Y = p.Y*c + p.X*s; @@ -600,16 +601,14 @@ bool EV_TeleportOther (int other_tid, int dest_tid, bool fog) static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool floorz, bool fog) { - int an = (dest->_f_angle() - source->_f_angle()) >> ANGLETOFINESHIFT; - fixed_t offX = victim->_f_X() - source->_f_X(); - fixed_t offY = victim->_f_Y() - source->_f_Y(); - fixed_t newX = DMulScale16 (offX, finecosine[an], -offY, finesine[an]); - fixed_t newY = DMulScale16 (offX, finesine[an], offY, finecosine[an]); + DAngle an = dest->Angles.Yaw - source->Angles.Yaw; + DVector2 off = victim->Pos() - source->Pos(); + DAngle offAngle = victim->Angles.Yaw - source->Angles.Yaw; + DVector2 newp = { off.X * an.Cos() - off.Y * an.Sin(), off.X * an.Sin() + off.Y * an.Cos() }; + double z = floorz ? ONFLOORZ : dest->Z() + victim->Z() - source->Z(); bool res = - P_Teleport (victim, dest->_f_X() + newX, - dest->_f_Y() + newY, - floorz ? ONFLOORZ : dest->_f_Z() + victim->_f_Z() - source->_f_Z(), + P_Teleport (victim, DVector3(dest->Pos().XY() + newp, z), 0., fog ? (TELF_DESTFOG | TELF_SOURCEFOG) : TELF_KEEPORIENTATION); // P_Teleport only changes angle if fog is true victim->Angles.Yaw = (dest->Angles.Yaw + victim->Angles.Yaw - source->Angles.Yaw).Normalized360(); @@ -617,19 +616,6 @@ static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool fl return res; } -#if 0 -static void MoveTheDecal (DBaseDecal *decal, fixed_t z, AActor *source, AActor *dest) -{ - int an = (dest->_f_angle() - source->_f_angle()) >> ANGLETOFINESHIFT; - fixed_t offX = decal->x - source->x; - fixed_t offY = decal->y - source->y; - fixed_t newX = DMulScale16 (offX, finecosine[an], -offY, finesine[an]); - fixed_t newY = DMulScale16 (offX, finesine[an], offY, finecosine[an]); - - decal->Relocate (dest->x + newX, dest->y + newY, dest->z + z - source->z); -} -#endif - // [RH] Teleport a group of actors centered around source_tid so // that they become centered around dest_tid instead. bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_tid, bool moveSource, bool fog) @@ -677,8 +663,7 @@ bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_t if (moveSource && didSomething) { didSomething |= - P_Teleport (sourceOrigin, destOrigin->_f_X(), destOrigin->_f_Y(), - floorz ? ONFLOORZ : destOrigin->_f_Z(), 0., TELF_KEEPORIENTATION); + P_Teleport (sourceOrigin, destOrigin->PosAtZ(floorz ? ONFLOORZ : destOrigin->Z()), 0., TELF_KEEPORIENTATION); sourceOrigin->Angles.Yaw = destOrigin->Angles.Yaw; } @@ -731,32 +716,6 @@ bool EV_TeleportSector (int tag, int source_tid, int dest_tid, bool fog, int gro } node = next; } - -#if 0 - if (group_tid == 0 && !fog) - { - int lineindex; - for (lineindex = sec->linecount-1; lineindex >= 0; --lineindex) - { - line_t *line = sec->lines[lineindex]; - int wallnum; - - wallnum = line->sidenum[(line->backsector == sec)]; - if (wallnum != -1) - { - side_t *wall = &sides[wallnum]; - ADecal *decal = wall->BoundActors; - - while (decal != NULL) - { - ADecal *next = (ADecal *)decal->snext; - MoveTheDecal (decal, decal->GetRealZ (wall), sourceOrigin, destOrigin); - decal = next; - } - } - } - } -#endif } return didSomething; } diff --git a/src/p_terrain.cpp b/src/p_terrain.cpp index 9a377f214..1b3226780 100644 --- a/src/p_terrain.cpp +++ b/src/p_terrain.cpp @@ -89,7 +89,6 @@ enum ETerrainKeywords enum EGenericType { GEN_End, - GEN_Fixed, GEN_Sound, GEN_Byte, GEN_Class, @@ -534,11 +533,6 @@ static void GenericParse (FScanner &sc, FGenericParse *parser, const char **keyw notdone = false; break; - case GEN_Fixed: - sc.MustGetFloat (); - SET_FIELD (fixed_t, (fixed_t)(FRACUNIT * sc.Float)); - break; - case GEN_Sound: sc.MustGetString (); SET_FIELD (FSoundID, FSoundID(sc.String)); diff --git a/src/r_defs.h b/src/r_defs.h index 6def54ebe..c34fd8525 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -767,12 +767,22 @@ struct sector_t planes[pos].alpha = o; } + void SetAlpha(int pos, double o) + { + planes[pos].alpha = FLOAT2FIXED(o); + } + fixed_t GetAlpha(int pos) const { return planes[pos].alpha; } - int GetFlags(int pos) const + double GetAlphaF(int pos) const + { + return FIXED2DBL(planes[pos].alpha); + } + + int GetFlags(int pos) const { return planes[pos].Flags; } From 8d071f85b3e2c558b64288a791f365fcb6ad94bd Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 29 Mar 2016 02:06:05 +0200 Subject: [PATCH 43/44] - use float vectors for prediction. --- src/p_user.cpp | 43 +++++++++++++++++-------------------------- 1 file changed, 17 insertions(+), 26 deletions(-) diff --git a/src/p_user.cpp b/src/p_user.cpp index 651ac0578..23223a3d3 100644 --- a/src/p_user.cpp +++ b/src/p_user.cpp @@ -83,11 +83,8 @@ CUSTOM_CVAR(Float, cl_predict_lerpthreshold, 2.00f, CVAR_ARCHIVE | CVAR_GLOBALCO struct PredictPos { int gametic; - fixed_t x; - fixed_t y; - fixed_t z; - fixed_t pitch; - fixed_t yaw; + DVector3 pos; + DRotator angles; } static PredictionLerpFrom, PredictionLerpResult, PredictionLast; static int PredictionLerptics; @@ -2288,9 +2285,9 @@ void P_PlayerThink (player_t *player) if (debugfile && !(player->cheats & CF_PREDICTING)) { - fprintf (debugfile, "tic %d for pl %d: (%d, %d, %d, %u) b:%02x p:%d y:%d f:%d s:%d u:%d\n", - gametic, (int)(player-players), player->mo->_f_X(), player->mo->_f_Y(), player->mo->_f_Z(), - player->mo->_f_angle()>>ANGLETOFINESHIFT, player->cmd.ucmd.buttons, + fprintf (debugfile, "tic %d for pl %d: (%f, %f, %f, %f) b:%02x p:%d y:%d f:%d s:%d u:%d\n", + gametic, (int)(player-players), player->mo->X(), player->mo->Y(), player->mo->Z(), + player->mo->Angles.Yaw.Degrees, player->cmd.ucmd.buttons, player->cmd.ucmd.pitch, player->cmd.ucmd.yaw, player->cmd.ucmd.forwardmove, player->cmd.ucmd.sidemove, player->cmd.ucmd.upmove); } @@ -2612,7 +2609,7 @@ void P_PlayerThink (player_t *player) P_PlayerOnSpecial3DFloor (player); P_PlayerInSpecialSector (player); - if (player->mo->_f_Z() <= player->mo->Sector->floorplane.ZatPoint(player->mo) || + if (!player->mo->isAbove(player->mo->Sector->floorplane.ZatPointF(player->mo)) || player->mo->waterlevel) { // Player must be touching the floor @@ -2720,21 +2717,18 @@ void P_PredictionLerpReset() PredictionLerptics = PredictionLast.gametic = PredictionLerpFrom.gametic = PredictionLerpResult.gametic = 0; } -bool P_LerpCalculate(PredictPos from, PredictPos to, PredictPos &result, float scale) +bool P_LerpCalculate(AActor *pmo, PredictPos from, PredictPos to, PredictPos &result, float scale) { //DVector2 pfrom = Displacements.getOffset(from.portalgroup, to.portalgroup); - DVector3 vecFrom(FIXED2DBL(from.x) /* + pfrom.X*/, FIXED2DBL(from.y) /*+ pfrom.Y*/, FIXED2DBL(from.z)); - DVector3 vecTo(FIXED2DBL(to.x), FIXED2DBL(to.y), FIXED2DBL(to.z)); + DVector3 vecFrom = from.pos; + DVector3 vecTo = to.pos; DVector3 vecResult; vecResult = vecTo - vecFrom; vecResult *= scale; vecResult = vecResult + vecFrom; DVector3 delta = vecResult - vecTo; - //result.pos = pmo->Vec3Offset(FLOAT2FIXED(vecResult.X) - to.pos.x, FLOAT2FIXED(vecResult.Y) - to.pos.y, FLOAT2FIXED(vecResult.Z) - to.pos.z); - result.x = FLOAT2FIXED(vecResult.X); - result.y = FLOAT2FIXED(vecResult.Y); - result.z = FLOAT2FIXED(vecResult.Z); + result.pos = pmo->Vec3Offset(vecResult - to.pos); //result.portalgroup = P_PointInSector(result.pos.x, result.pos.y)->PortalGroup; // As a fail safe, assume extrapolation is the threshold. @@ -2841,16 +2835,15 @@ void P_PredictPlayer (player_t *player) { // Z is not compared as lifts will alter this with no apparent change // Make lerping less picky by only testing whole units - DoLerp = ((PredictionLast.x >> 16) != (player->mo->_f_X() >> 16) || - (PredictionLast.y >> 16) != (player->mo->_f_Y() >> 16)); + DoLerp = (int)PredictionLast.pos.X != (int)player->mo->X() || (int)PredictionLast.pos.Y != (int)player->mo->Y(); // Aditional Debug information if (developer && DoLerp) { - DPrintf("Lerp! Ltic (%d) && Ptic (%d) | Lx (%d) && Px (%f) | Ly (%d) && Py (%f)\n", + DPrintf("Lerp! Ltic (%d) && Ptic (%d) | Lx (%f) && Px (%f) | Ly (%f) && Py (%f)\n", PredictionLast.gametic, i, - (PredictionLast.x >> 16), (player->mo->X()), - (PredictionLast.y >> 16), (player->mo->Y())); + (PredictionLast.pos.X), (player->mo->X()), + (PredictionLast.pos.Y), (player->mo->Y())); } } } @@ -2868,18 +2861,16 @@ void P_PredictPlayer (player_t *player) } PredictionLast.gametic = maxtic - 1; - PredictionLast.x = player->mo->_f_X(); - PredictionLast.y = player->mo->_f_Y(); - PredictionLast.z = player->mo->_f_Z(); + PredictionLast.pos = player->mo->Pos(); //PredictionLast.portalgroup = player->mo->Sector->PortalGroup; if (PredictionLerptics > 0) { if (PredictionLerpFrom.gametic > 0 && - P_LerpCalculate(/*player->mo,*/ PredictionLerpFrom, PredictionLast, PredictionLerpResult, (float)PredictionLerptics * cl_predict_lerpscale)) + P_LerpCalculate(player->mo, PredictionLerpFrom, PredictionLast, PredictionLerpResult, (float)PredictionLerptics * cl_predict_lerpscale)) { PredictionLerptics++; - player->mo->SetXYZ(PredictionLerpResult.x, PredictionLerpResult.y, PredictionLerpResult.z); + player->mo->SetXYZ(PredictionLerpResult.pos); } else { From c7ae4688a3f502b894f579eee4f2b528cefbb2b7 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Tue, 29 Mar 2016 10:07:06 +0200 Subject: [PATCH 44/44] - replaced all direct access to vertex coordinates with wrapper functions. So that code replacement can be done piece by piece and not all at once. --- src/m_bbox.cpp | 8 +-- src/nodebuild_extract.cpp | 22 ++++--- src/nodebuild_utility.cpp | 49 ++++++++-------- src/p_buildmap.cpp | 5 +- src/p_enemy.cpp | 28 ++++----- src/p_glnodes.cpp | 11 ++-- src/p_map.cpp | 2 +- src/p_maputl.cpp | 18 +++--- src/p_maputl.h | 14 +++-- src/p_mobj.cpp | 4 +- src/p_sectors.cpp | 28 ++++----- src/p_setup.cpp | 107 ++++++++++++++++++----------------- src/p_sight.cpp | 4 +- src/p_slopes.cpp | 42 +++++++------- src/p_switch.cpp | 2 +- src/p_udmf.cpp | 10 ++-- src/p_writemap.cpp | 6 +- src/po_man.cpp | 79 +++++++++++++------------- src/po_man.h | 4 +- src/portal.cpp | 30 +++++----- src/r_bsp.cpp | 30 +++++----- src/r_data/r_interpolate.cpp | 19 +++---- src/r_defs.h | 43 ++++++++++++-- src/r_main.cpp | 16 +++--- src/r_segs.cpp | 42 +++++++------- src/r_things.cpp | 4 +- 26 files changed, 328 insertions(+), 299 deletions(-) diff --git a/src/m_bbox.cpp b/src/m_bbox.cpp index a2d839b6b..6baba2a56 100644 --- a/src/m_bbox.cpp +++ b/src/m_bbox.cpp @@ -78,8 +78,8 @@ int FBoundingBox::BoxOnLineSide (const line_t *ld) const if (ld->dx == 0) { // ST_VERTICAL - p1 = m_Box[BOXRIGHT] < ld->v1->x; - p2 = m_Box[BOXLEFT] < ld->v1->x; + p1 = m_Box[BOXRIGHT] < ld->v1->fixX(); + p2 = m_Box[BOXLEFT] < ld->v1->fixX(); if (ld->dy < 0) { p1 ^= 1; @@ -88,8 +88,8 @@ int FBoundingBox::BoxOnLineSide (const line_t *ld) const } else if (ld->dy == 0) { // ST_HORIZONTAL: - p1 = m_Box[BOXTOP] > ld->v1->y; - p2 = m_Box[BOXBOTTOM] > ld->v1->y; + p1 = m_Box[BOXTOP] > ld->v1->fixY(); + p2 = m_Box[BOXBOTTOM] > ld->v1->fixY(); if (ld->dx < 0) { p1 ^= 1; diff --git a/src/nodebuild_extract.cpp b/src/nodebuild_extract.cpp index 0d5e0b91c..425c656e3 100644 --- a/src/nodebuild_extract.cpp +++ b/src/nodebuild_extract.cpp @@ -64,8 +64,7 @@ void FNodeBuilder::Extract (node_t *&outNodes, int &nodeCount, for (i = 0; i < vertCount; ++i) { - outVerts[i].x = Vertices[i].x; - outVerts[i].y = Vertices[i].y; + outVerts[i].set(Vertices[i].x, Vertices[i].y); } subCount = Subsectors.Size(); @@ -169,8 +168,7 @@ void FNodeBuilder::ExtractMini (FMiniBSP *bsp) bsp->Verts.Resize(Vertices.Size()); for (i = 0; i < Vertices.Size(); ++i) { - bsp->Verts[i].x = Vertices[i].x; - bsp->Verts[i].y = Vertices[i].y; + bsp->Verts[i].set(Vertices[i].x, Vertices[i].y); } bsp->Subsectors.Resize(Subsectors.Size()); @@ -400,14 +398,14 @@ int FNodeBuilder::CloseSubsector (TArray &segs, int subsector, vertex_t { Printf(PRINT_LOG, " Seg %5d%c(%5d,%5d)-(%5d,%5d) [%08x,%08x]-[%08x,%08x]\n", i, segs[i].linedef == NULL ? '+' : ' ', - segs[i].v1->x>>16, - segs[i].v1->y>>16, - segs[i].v2->x>>16, - segs[i].v2->y>>16, - segs[i].v1->x, - segs[i].v1->y, - segs[i].v2->x, - segs[i].v2->y); + segs[i].v1->fixX()>>16, + segs[i].v1->fixY()>>16, + segs[i].v2->fixX()>>16, + segs[i].v2->fixY()>>16, + segs[i].v1->fixX(), + segs[i].v1->fixY(), + segs[i].v2->fixX(), + segs[i].v2->fixY()); } #endif diff --git a/src/nodebuild_utility.cpp b/src/nodebuild_utility.cpp index d3d560f4c..96da22b8a 100644 --- a/src/nodebuild_utility.cpp +++ b/src/nodebuild_utility.cpp @@ -96,14 +96,14 @@ void FNodeBuilder::FindUsedVertices (vertex_t *oldverts, int max) if (map[v1] == -1) { - newvert.x = oldverts[v1].x; - newvert.y = oldverts[v1].y; + newvert.x = oldverts[v1].fixX(); + newvert.y = oldverts[v1].fixY(); map[v1] = VertexMap->SelectVertexExact (newvert); } if (map[v2] == -1) { - newvert.x = oldverts[v2].x; - newvert.y = oldverts[v2].y; + newvert.x = oldverts[v2].fixX(); + newvert.y = oldverts[v2].fixY(); map[v2] = VertexMap->SelectVertexExact (newvert); } @@ -222,11 +222,11 @@ void FNodeBuilder::AddSegs(seg_t *segs, int numsegs) seg.frontsector = segs[i].frontsector; seg.backsector = segs[i].backsector; - vert.x = segs[i].v1->x; - vert.y = segs[i].v1->y; + vert.x = segs[i].v1->fixX(); + vert.y = segs[i].v1->fixY(); seg.v1 = VertexMap->SelectVertexExact(vert); - vert.x = segs[i].v2->x; - vert.y = segs[i].v2->y; + vert.x = segs[i].v2->fixX(); + vert.y = segs[i].v2->fixY(); seg.v2 = VertexMap->SelectVertexExact(vert); seg.linedef = int(segs[i].linedef - Level.Lines); seg.sidedef = segs[i].sidedef != NULL ? int(segs[i].sidedef - Level.Sides) : int(NO_SIDE); @@ -430,18 +430,18 @@ void FNodeBuilder::FindPolyContainers (TArray &spots, TArrayx + spot->x; - center.y = mid.y - anchor->y + spot->y; + center.set(mid.fixX() - anchor->x + spot->x, + mid.fixY() - anchor->y + spot->y); // Scan right for the seg closest to the polyobject's center after it // gets moved to its start spot. fixed_t closestdist = FIXED_MAX; unsigned int closestseg = UINT_MAX; - P(Printf ("start %d,%d -- center %d, %d\n", spot->x>>16, spot->y>>16, center.x>>16, center.y>>16)); + P(Printf ("start %d,%d -- center %d, %d\n", spot->x>>16, spot->y>>16, center.fixX()>>16, center.fixY()>>16)); for (unsigned int j = 0; j < Segs.Size(); ++j) { @@ -454,16 +454,16 @@ void FNodeBuilder::FindPolyContainers (TArray &spots, TArrayy < center.y && v2->y < center.y) || (v1->y > center.y && v2->y > center.y)) + if ((v1->y < center.fixY() && v2->y < center.fixY()) || (v1->y > center.fixY() && v2->y > center.fixY())) { // Not crossed continue; } fixed_t dx = v2->x - v1->x; - if (PointOnSide (center.x, center.y, v1->x, v1->y, dx, dy) <= 0) + if (PointOnSide (center.fixX(), center.fixY(), v1->x, v1->y, dx, dy) <= 0) { - fixed_t t = DivScale30 (center.y - v1->y, dy); + fixed_t t = DivScale30 (center.fixY() - v1->y, dy); fixed_t sx = v1->x + MulScale30 (dx, t); fixed_t dist = sx - spot->x; @@ -565,8 +565,7 @@ bool FNodeBuilder::GetPolyExtents (int polynum, fixed_t bbox[4]) vert = Segs[i].v1; - start.x = Vertices[vert].x; - start.y = Vertices[vert].y; + start.set(Vertices[vert].x, Vertices[vert].y); do { @@ -574,7 +573,7 @@ bool FNodeBuilder::GetPolyExtents (int polynum, fixed_t bbox[4]) vert = Segs[i].v2; i = Vertices[vert].segs; count++; // to prevent endless loops. Stop when this reaches the number of segs. - } while (i != DWORD_MAX && (Vertices[vert].x != start.x || Vertices[vert].y != start.y) && count < Segs.Size()); + } while (i != DWORD_MAX && (Vertices[vert].x != start.fixX() || Vertices[vert].y != start.fixY()) && count < Segs.Size()); return true; } @@ -614,15 +613,15 @@ void FNodeBuilder::FLevel::FindMapBounds () { fixed_t minx, maxx, miny, maxy; - minx = maxx = Vertices[0].x; - miny = maxy = Vertices[0].y; + minx = maxx = Vertices[0].fixX(); + miny = maxy = Vertices[0].fixY(); for (int i = 1; i < NumVertices; ++i) { - if (Vertices[i].x < minx) minx = Vertices[i].x; - else if (Vertices[i].x > maxx) maxx = Vertices[i].x; - if (Vertices[i].y < miny) miny = Vertices[i].y; - else if (Vertices[i].y > maxy) maxy = Vertices[i].y; + if (Vertices[i].fixX() < minx) minx = Vertices[i].fixX(); + else if (Vertices[i].fixX() > maxx) maxx = Vertices[i].fixX(); + if (Vertices[i].fixY() < miny) miny = Vertices[i].fixY(); + else if (Vertices[i].fixY() > maxy) maxy = Vertices[i].fixY(); } MinX = minx; diff --git a/src/p_buildmap.cpp b/src/p_buildmap.cpp index 2fa2a70f2..4fd0380c8 100644 --- a/src/p_buildmap.cpp +++ b/src/p_buildmap.cpp @@ -764,13 +764,12 @@ vertex_t *FindVertex (SDWORD x, SDWORD y) for (i = 0; i < numvertexes; ++i) { - if (vertexes[i].x == x && vertexes[i].y == y) + if (vertexes[i].fixX() == x && vertexes[i].fixY() == y) { return &vertexes[i]; } } - vertexes[i].x = x; - vertexes[i].y = y; + vertexes[i].set(x, y); numvertexes++; return &vertexes[i]; } diff --git a/src/p_enemy.cpp b/src/p_enemy.cpp index 8707ffc76..4e62b09c1 100644 --- a/src/p_enemy.cpp +++ b/src/p_enemy.cpp @@ -162,12 +162,12 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun // I wish there was a better method to do this than randomly looking through the portal at a few places... if (checkabove) { - sector_t *upper = P_PointInSector(check->v1->fPos() + check->Delta() / 2 + sec->SkyBoxes[sector_t::ceiling]->Scale); + sector_t *upper = P_PointInSector(check->V1() + check->Delta() / 2 + sec->SkyBoxes[sector_t::ceiling]->Scale); P_RecursiveSound(upper, soundtarget, splash, soundblocks, emitter, maxdist); } if (checkbelow) { - sector_t *lower = P_PointInSector(check->v1->fPos() + check->Delta() / 2 + sec->SkyBoxes[sector_t::floor]->Scale); + sector_t *lower = P_PointInSector(check->V1() + check->Delta() / 2 + sec->SkyBoxes[sector_t::floor]->Scale); P_RecursiveSound(lower, soundtarget, splash, soundblocks, emitter, maxdist); } FLinePortal *port = check->getPortal(); @@ -195,18 +195,18 @@ void P_RecursiveSound (sector_t *sec, AActor *soundtarget, bool splash, int soun other = check->sidedef[0]->sector; // check for closed door - if ((sec->floorplane.ZatPoint (check->v1->fPos()) >= - other->ceilingplane.ZatPoint (check->v1->fPos()) && - sec->floorplane.ZatPoint (check->v2->fPos()) >= - other->ceilingplane.ZatPoint (check->v2->fPos())) - || (other->floorplane.ZatPoint (check->v1->fPos()) >= - sec->ceilingplane.ZatPoint (check->v1->fPos()) && - other->floorplane.ZatPoint (check->v2->fPos()) >= - sec->ceilingplane.ZatPoint (check->v2->fPos())) - || (other->floorplane.ZatPoint (check->v1->fPos()) >= - other->ceilingplane.ZatPoint (check->v1->fPos()) && - other->floorplane.ZatPoint (check->v2->fPos()) >= - other->ceilingplane.ZatPoint (check->v2->fPos()))) + if ((sec->floorplane.ZatPoint (check->V1()) >= + other->ceilingplane.ZatPoint (check->V1()) && + sec->floorplane.ZatPoint (check->V2()) >= + other->ceilingplane.ZatPoint (check->V2())) + || (other->floorplane.ZatPoint (check->V1()) >= + sec->ceilingplane.ZatPoint (check->V1()) && + other->floorplane.ZatPoint (check->V2()) >= + sec->ceilingplane.ZatPoint (check->V2())) + || (other->floorplane.ZatPoint (check->V1()) >= + other->ceilingplane.ZatPoint (check->V1()) && + other->floorplane.ZatPoint (check->V2()) >= + other->ceilingplane.ZatPoint (check->V2()))) { continue; } diff --git a/src/p_glnodes.cpp b/src/p_glnodes.cpp index 84951a3a3..cc80296da 100644 --- a/src/p_glnodes.cpp +++ b/src/p_glnodes.cpp @@ -140,7 +140,7 @@ static int CheckForMissingSegs() if (seg->sidedef!=NULL) { // check all the segs and calculate the length they occupy on their sidedef - DVector2 vec1(seg->v2->x - seg->v1->x, seg->v2->y - seg->v1->y); + DVector2 vec1(seg->v2->fixX() - seg->v1->fixX(), seg->v2->fixY() - seg->v1->fixY()); added_seglen[seg->sidedef - sides] += float(vec1.Length()); } } @@ -268,8 +268,7 @@ static bool LoadGLVertexes(FileReader * lump) for (i = firstglvertex; i < numvertexes; i++) { - vertexes[i].x = LittleLong(mgl->x); - vertexes[i].y = LittleLong(mgl->y); + vertexes[i].set(LittleLong(mgl->x), LittleLong(mgl->y)); mgl++; } delete[] gldata; @@ -1102,8 +1101,8 @@ static void CreateCachedNodes(MapData *map) WriteLong(ZNodes, numvertexes); for(int i=0;iflags |= SSECF_DEGENERATE; for(j=2; jnumlines; j++) { - if (!PointOnLine(seg[j].v1->x, seg[j].v1->y, seg->v1->x, seg->v1->y, seg->v2->x-seg->v1->x, seg->v2->y-seg->v1->y)) + if (!PointOnLine(seg[j].v1->fixX(), seg[j].v1->fixY(), seg->v1->fixX(), seg->v1->fixY(), seg->v2->fixX() -seg->v1->fixX(), seg->v2->fixY() -seg->v1->fixY())) { // Not on the same line ss->flags &= ~SSECF_DEGENERATE; diff --git a/src/p_map.cpp b/src/p_map.cpp index 3e2fca2e2..765b0d57e 100644 --- a/src/p_map.cpp +++ b/src/p_map.cpp @@ -109,7 +109,7 @@ static DVector2 FindRefPoint(line_t *ld, const DVector2 &pos) !ld->frontsector->PortalBlocksMovement(sector_t::floor)) { - DVector2 v1 = ld->v1->fPos(); + DVector2 v1 = ld->V1(); DVector2 d = ld->Delta(); double r = clamp(((pos.X - v1.X) * d.X + (pos.Y - v1.Y) * d.Y) / (d.X*d.X + d.Y*d.Y), 0., 1.); return v1 + d*r; diff --git a/src/p_maputl.cpp b/src/p_maputl.cpp index d58ecd975..0c444dd6c 100644 --- a/src/p_maputl.cpp +++ b/src/p_maputl.cpp @@ -104,7 +104,7 @@ fixed_t P_InterceptVector (const fdivline_t *v2, const fdivline_t *v1) SQWORD den = ( ((SQWORD)v1->dy*v2->dx - (SQWORD)v1->dx*v2->dy) >> FRACBITS ); if (den == 0) return 0; // parallel - SQWORD num = ((SQWORD)(v1->x - v2->x)*v1->dy + (SQWORD)(v2->y - v1->y)*v1->dx); + SQWORD num = ((SQWORD)(v1->fixX() - v2->fixX())*v1->dy + (SQWORD)(v2->fixY() - v1->fixY())*v1->dx); return (fixed_t)(num / den); #elif 0 // This is the original Doom version @@ -120,8 +120,8 @@ fixed_t P_InterceptVector (const fdivline_t *v2, const fdivline_t *v1) // I_Error ("P_InterceptVector: parallel"); num = - FixedMul ( (v1->x - v2->x)>>8 ,v1->dy ) - +FixedMul ( (v2->y - v1->y)>>8, v1->dx ); + FixedMul ( (v1->fixX() - v2->fixX())>>8 ,v1->dy ) + +FixedMul ( (v2->fixY() - v1->fixY())>>8, v1->dx ); frac = FixedDiv (num , den); @@ -1230,8 +1230,8 @@ void FPathTraverse::AddLineIntercepts(int bx, int by) || trace.dx < -FRACUNIT*16 || trace.dy < -FRACUNIT*16) { - s1 = P_PointOnDivlineSide (ld->v1->x, ld->v1->y, &trace); - s2 = P_PointOnDivlineSide (ld->v2->x, ld->v2->y, &trace); + s1 = P_PointOnDivlineSide (ld->v1->fixX(), ld->v1->fixY(), &trace); + s2 = P_PointOnDivlineSide (ld->v2->fixX(), ld->v2->fixY(), &trace); } else { @@ -1939,21 +1939,21 @@ int P_VanillaPointOnLineSide(fixed_t x, fixed_t y, const line_t* line) if (!line->dx) { - if (x <= line->v1->x) + if (x <= line->v1->fixX()) return line->dy > 0; return line->dy < 0; } if (!line->dy) { - if (y <= line->v1->y) + if (y <= line->v1->fixY()) return line->dx < 0; return line->dx > 0; } - dx = (x - line->v1->x); - dy = (y - line->v1->y); + dx = (x - line->v1->fixX()); + dy = (y - line->v1->fixY()); left = FixedMul ( line->dy>>FRACBITS , dx ); right = FixedMul ( dy , line->dx>>FRACBITS ); diff --git a/src/p_maputl.h b/src/p_maputl.h index 63875ef89..56e5a7615 100644 --- a/src/p_maputl.h +++ b/src/p_maputl.h @@ -45,18 +45,20 @@ struct intercept_t // //========================================================================== +const double POL_Epsilon = -1. / 65536.; + inline int P_PointOnLineSide (fixed_t x, fixed_t y, const line_t *line) { extern int P_VanillaPointOnLineSide(fixed_t x, fixed_t y, const line_t* line); return i_compatflags2 & COMPATF2_POINTONLINE ? P_VanillaPointOnLineSide(x, y, line) - : DMulScale32 (y-line->v1->y, line->dx, line->v1->x-x, line->dy) > 0; + : DMulScale32 (y-line->v1->fixY(), line->dx, line->v1->fixX()-x, line->dy) > 0; } inline int P_PointOnLineSidePrecise (fixed_t x, fixed_t y, const line_t *line) { - return DMulScale32 (y-line->v1->y, line->dx, line->v1->x-x, line->dy) > 0; + return DMulScale32 (y-line->v1->fixY(), line->dx, line->v1->fixX()-x, line->dy) > 0; } inline int P_PointOnLineSide(double x, double y, const line_t *line) @@ -71,12 +73,12 @@ inline int P_PointOnLineSide(const DVector2 & p, const line_t *line) inline int P_PointOnLineSidePrecise(double x, double y, const line_t *line) { - return DMulScale32(FLOAT2FIXED(y) - line->v1->y, line->dx, line->v1->x - FLOAT2FIXED(x), line->dy) > 0; + return (y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - x) * line->Delta().Y > POL_Epsilon ; } inline int P_PointOnLineSidePrecise(const DVector2 &pt, const line_t *line) { - return DMulScale32(FLOAT2FIXED(pt.Y) - line->v1->y, line->dx, line->v1->x - FLOAT2FIXED(pt.X), line->dy) > 0; + return (pt.Y - line->v1->fY()) * line->Delta().X + (line->v1->fX() - pt.X) * line->Delta().Y > POL_Epsilon; } @@ -121,8 +123,8 @@ inline int P_PointOnDivlineSidePrecise(const DVector2 &pos, const divline_t *lin inline void P_MakeDivline (const line_t *li, fdivline_t *dl) { - dl->x = li->v1->x; - dl->y = li->v1->y; + dl->x = li->v1->fixX(); + dl->y = li->v1->fixY(); dl->dx = li->dx; dl->dy = li->dy; } diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 467d01d0e..1fabbc432 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1401,9 +1401,9 @@ void P_ExplodeMissile (AActor *mo, line_t *line, AActor *target) den = line->Delta().LengthSquared(); if (den != 0) { - frac = clamp((mo->Pos() - line->v1->fPos()) | line->Delta(), 0, den) / den; + frac = clamp((mo->Pos() - line->V1()) | line->Delta(), 0, den) / den; - linepos = DVector3(line->v1->fPos() + line->Delta() * frac, pos.Z); + linepos = DVector3(line->V1() + line->Delta() * frac, pos.Z); F3DFloor * ffloor=NULL; if (line->sidedef[side^1] != NULL) diff --git a/src/p_sectors.cpp b/src/p_sectors.cpp index e96a4328e..41bb46d11 100644 --- a/src/p_sectors.cpp +++ b/src/p_sectors.cpp @@ -725,34 +725,34 @@ void sector_t::ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy) co { vertex_t *v1 = lines[i]->v1; vertex_t *v2 = lines[i]->v2; - double a = v2->x - v1->x; - double b = v2->y - v1->y; + double a = v2->fixX() - v1->fixX(); + double b = v2->fixY() - v1->fixY(); double den = a*a + b*b; double ix, iy, dist; if (den == 0) { // Line is actually a point! - ix = v1->x; - iy = v1->y; + ix = v1->fixX(); + iy = v1->fixY(); } else { - double num = (x - v1->x) * a + (y - v1->y) * b; + double num = (x - v1->fixX()) * a + (y - v1->fixY()) * b; double u = num / den; if (u <= 0) { - ix = v1->x; - iy = v1->y; + ix = v1->fixX(); + iy = v1->fixY(); } else if (u >= 1) { - ix = v2->x; - iy = v2->y; + ix = v2->fixX(); + iy = v2->fixY(); } else { - ix = v1->x + u * a; - iy = v1->y + u * b; + ix = v1->fixX() + u * a; + iy = v1->fixY() + u * b; } } a = (ix - x); @@ -1136,10 +1136,10 @@ bool P_AlignFlat (int linenum, int side, int fc) if (!sec) return false; - fixed_t x = line->v1->x; - fixed_t y = line->v1->y; + fixed_t x = line->v1->fixX(); + fixed_t y = line->v1->fixY(); - angle_t angle = R_PointToAngle2 (x, y, line->v2->x, line->v2->y); + angle_t angle = R_PointToAngle2 (x, y, line->v2->fixX(), line->v2->fixY()); angle_t norm = (angle-ANGLE_90) >> ANGLETOFINESHIFT; fixed_t dist = -DMulScale16 (finecosine[norm], x, finesine[norm], y); diff --git a/src/p_setup.cpp b/src/p_setup.cpp index 3c096a5f0..fb0df8e1d 100644 --- a/src/p_setup.cpp +++ b/src/p_setup.cpp @@ -864,8 +864,7 @@ void P_LoadVertexes (MapData * map) SWORD x, y; (*map->file) >> x >> y; - vertexes[i].x = x << FRACBITS; - vertexes[i].y = y << FRACBITS; + vertexes[i].set(x << FRACBITS, y << FRACBITS); } } @@ -1003,7 +1002,9 @@ void LoadZNodes(FileReaderBase &data, int glnodes) } for (i = 0; i < newVerts; ++i) { - data >> newvertarray[i + orgVerts].x >> newvertarray[i + orgVerts].y; + fixed_t x, y; + data >> x >> y; + newvertarray[i + orgVerts].set(x, y); } if (vertexes != newvertarray) { @@ -1316,28 +1317,30 @@ void P_LoadSegs (MapData * map) // off, then move one vertex. This may seem insignificant, but one degree // errors _can_ cause firelines. - ptp_angle = R_PointToAngle2 (li->v1->x, li->v1->y, li->v2->x, li->v2->y); + ptp_angle = R_PointToAngle2 (li->v1->fixX(), li->v1->fixY(), li->v2->fixX(), li->v2->fixY()); dis = 0; delta_angle = (absangle(ptp_angle-(segangle<<16))>>ANGLETOFINESHIFT)*360/FINEANGLES; if (delta_angle != 0) { segangle >>= (ANGLETOFINESHIFT-16); - dx = (li->v1->x - li->v2->x)>>FRACBITS; - dy = (li->v1->y - li->v2->y)>>FRACBITS; + dx = (li->v1->fixX() - li->v2->fixX())>>FRACBITS; + dy = (li->v1->fixY() - li->v2->fixY())>>FRACBITS; dis = ((int) g_sqrt((double)(dx*dx + dy*dy)))< vnum1) && (vertchanged[vnum2] == 0)) { - li->v2->x = li->v1->x + FixedMul(dis,dx); - li->v2->y = li->v1->y + FixedMul(dis,dy); + li->v2->set( + li->v1->fixX() + FixedMul(dis,dx), + li->v1->fixY() + FixedMul(dis,dy)); vertchanged[vnum2] = 1; // this was changed } else if (vertchanged[vnum1] == 0) { - li->v1->x = li->v2->x - FixedMul(dis,dx); - li->v1->y = li->v2->y - FixedMul(dis,dy); + li->v1->set( + li->v2->fixX() - FixedMul(dis,dx), + li->v2->fixY() - FixedMul(dis,dy)); vertchanged[vnum1] = 1; // this was changed } } @@ -1904,29 +1907,29 @@ void P_AdjustLine (line_t *ld) v1 = ld->v1; v2 = ld->v2; - ld->dx = v2->x - v1->x; - ld->dy = v2->y - v1->y; + ld->dx = v2->fixX() - v1->fixX(); + ld->dy = v2->fixY() - v1->fixY(); - if (v1->x < v2->x) + if (v1->fixX() < v2->fixX()) { - ld->bbox[BOXLEFT] = v1->x; - ld->bbox[BOXRIGHT] = v2->x; + ld->bbox[BOXLEFT] = v1->fixX(); + ld->bbox[BOXRIGHT] = v2->fixX(); } else { - ld->bbox[BOXLEFT] = v2->x; - ld->bbox[BOXRIGHT] = v1->x; + ld->bbox[BOXLEFT] = v2->fixX(); + ld->bbox[BOXRIGHT] = v1->fixX(); } - if (v1->y < v2->y) + if (v1->fixY() < v2->fixY()) { - ld->bbox[BOXBOTTOM] = v1->y; - ld->bbox[BOXTOP] = v2->y; + ld->bbox[BOXBOTTOM] = v1->fixY(); + ld->bbox[BOXTOP] = v2->fixY(); } else { - ld->bbox[BOXBOTTOM] = v2->y; - ld->bbox[BOXTOP] = v1->y; + ld->bbox[BOXBOTTOM] = v2->fixY(); + ld->bbox[BOXTOP] = v1->fixY(); } } @@ -2015,8 +2018,8 @@ void P_FinishLoadingLineDef(line_t *ld, int alpha) ld->frontsector = ld->sidedef[0] != NULL ? ld->sidedef[0]->sector : NULL; ld->backsector = ld->sidedef[1] != NULL ? ld->sidedef[1]->sector : NULL; - double dx = FIXED2DBL(ld->v2->x - ld->v1->x); - double dy = FIXED2DBL(ld->v2->y - ld->v1->y); + double dx = FIXED2DBL(ld->v2->fixX() - ld->v1->fixX()); + double dy = FIXED2DBL(ld->v2->fixY() - ld->v1->fixY()); int linenum = int(ld-lines); if (ld->frontsector == NULL) @@ -2141,8 +2144,8 @@ void P_LoadLineDefs (MapData * map) I_Error ("Line %d has invalid vertices: %d and/or %d.\nThe map only contains %d vertices.", i+skipped, v1, v2, numvertexes); } else if (v1 == v2 || - (vertexes[LittleShort(mld->v1)].x == vertexes[LittleShort(mld->v2)].x && - vertexes[LittleShort(mld->v1)].y == vertexes[LittleShort(mld->v2)].y)) + (vertexes[LittleShort(mld->v1)].fixX() == vertexes[LittleShort(mld->v2)].fixX() && + vertexes[LittleShort(mld->v1)].fixY() == vertexes[LittleShort(mld->v2)].fixY())) { Printf ("Removing 0-length line %d\n", i+skipped); memmove (mld, mld+1, sizeof(*mld)*(numlines-i-1)); @@ -2230,8 +2233,8 @@ void P_LoadLineDefs2 (MapData * map) mld = ((maplinedef2_t*)mldf) + i; if (mld->v1 == mld->v2 || - (vertexes[LittleShort(mld->v1)].x == vertexes[LittleShort(mld->v2)].x && - vertexes[LittleShort(mld->v1)].y == vertexes[LittleShort(mld->v2)].y)) + (vertexes[LittleShort(mld->v1)].fixX() == vertexes[LittleShort(mld->v2)].fixX() && + vertexes[LittleShort(mld->v1)].fixY() == vertexes[LittleShort(mld->v2)].fixY())) { Printf ("Removing 0-length line %d\n", i+skipped); memmove (mld, mld+1, sizeof(*mld)*(numlines-i-1)); @@ -2794,15 +2797,15 @@ static void P_CreateBlockMap () return; // Find map extents for the blockmap - minx = maxx = vertexes[0].x; - miny = maxy = vertexes[0].y; + minx = maxx = vertexes[0].fixX(); + miny = maxy = vertexes[0].fixY(); for (i = 1; i < numvertexes; ++i) { - if (vertexes[i].x < minx) minx = vertexes[i].x; - else if (vertexes[i].x > maxx) maxx = vertexes[i].x; - if (vertexes[i].y < miny) miny = vertexes[i].y; - else if (vertexes[i].y > maxy) maxy = vertexes[i].y; + if (vertexes[i].fixX() < minx) minx = vertexes[i].fixX(); + else if (vertexes[i].fixX() > maxx) maxx = vertexes[i].fixX(); + if (vertexes[i].fixY() < miny) miny = vertexes[i].fixY(); + else if (vertexes[i].fixY() > maxy) maxy = vertexes[i].fixY(); } maxx >>= FRACBITS; @@ -2824,10 +2827,10 @@ static void P_CreateBlockMap () for (line = 0; line < numlines; ++line) { - int x1 = lines[line].v1->x >> FRACBITS; - int y1 = lines[line].v1->y >> FRACBITS; - int x2 = lines[line].v2->x >> FRACBITS; - int y2 = lines[line].v2->y >> FRACBITS; + int x1 = lines[line].v1->fixX() >> FRACBITS; + int y1 = lines[line].v1->fixY() >> FRACBITS; + int x2 = lines[line].v2->fixX() >> FRACBITS; + int y2 = lines[line].v2->fixY() >> FRACBITS; int dx = x2 - x1; int dy = y2 - y1; int bx = (x1 - minx) >> BLOCKBITS; @@ -3217,8 +3220,8 @@ static void P_GroupLines (bool buildmap) for (j = 0; j < sector->linecount; ++j) { li = sector->lines[j]; - bbox.AddToBox (li->v1->x, li->v1->y); - bbox.AddToBox (li->v2->x, li->v2->y); + bbox.AddToBox (li->v1->fixX(), li->v1->fixY()); + bbox.AddToBox (li->v2->fixX(), li->v2->fixY()); } } @@ -3234,8 +3237,8 @@ static void P_GroupLines (bool buildmap) Triangle[1] = sector->lines[0]->v2; if (sector->linecount > 1) { - fixed_t dx = Triangle[1]->x - Triangle[0]->x; - fixed_t dy = Triangle[1]->y - Triangle[0]->y; + fixed_t dx = Triangle[1]->fixX() - Triangle[0]->fixX(); + fixed_t dy = Triangle[1]->fixY() - Triangle[0]->fixY(); // Find another point in the sector that does not lie // on the same line as the first two points. for (j = 0; j < 2; ++j) @@ -3243,11 +3246,11 @@ static void P_GroupLines (bool buildmap) vertex_t *v; v = (j == 1) ? sector->lines[1]->v1 : sector->lines[1]->v2; - if (DMulScale32 (v->y - Triangle[0]->y, dx, - Triangle[0]->x - v->x, dy) != 0) + if (DMulScale32 (v->fixY() - Triangle[0]->fixY(), dx, + Triangle[0]->fixX() - v->fixX(), dy) != 0) { - sector->centerspot.X = FIXED2DBL(Triangle[0]->x / 3 + Triangle[1]->x / 3 + v->x / 3); - sector->centerspot.Y = FIXED2DBL(Triangle[0]->y / 3 + Triangle[1]->y / 3 + v->y / 3); + sector->centerspot.X = FIXED2DBL(Triangle[0]->fixX() / 3 + Triangle[1]->fixX() / 3 + v->fixX() / 3); + sector->centerspot.Y = FIXED2DBL(Triangle[0]->fixY() / 3 + Triangle[1]->fixY() / 3 + v->fixY() / 3); break; } } @@ -3926,8 +3929,8 @@ void P_SetupLevel (const char *lumpname, int position) seg_t * seg=&segs[i]; if (seg->backsector == seg->frontsector && seg->linedef) { - fixed_t d1=P_AproxDistance(seg->v1->x-seg->linedef->v1->x,seg->v1->y-seg->linedef->v1->y); - fixed_t d2=P_AproxDistance(seg->v2->x-seg->linedef->v1->x,seg->v2->y-seg->linedef->v1->y); + fixed_t d1=P_AproxDistance(seg->v1->fixX()-seg->linedef->v1->fixX(),seg->v1->fixY()-seg->linedef->v1->fixY()); + fixed_t d2=P_AproxDistance(seg->v2->fixX()-seg->linedef->v1->fixX(),seg->v2->fixY()-seg->linedef->v1->fixY()); if (d2 (%d,%d)\n", lines[linenum].v1->x >> FRACBITS, - lines[linenum].v1->y >> FRACBITS, - lines[linenum].v2->x >> FRACBITS, - lines[linenum].v2->y >> FRACBITS); + Printf ("(%d,%d) -> (%d,%d)\n", lines[linenum].v1->fixX() >> FRACBITS, + lines[linenum].v1->fixY() >> FRACBITS, + lines[linenum].v2->fixX() >> FRACBITS, + lines[linenum].v2->fixY() >> FRACBITS); } #endif diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 4b8a32951..b812e0f63 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -375,8 +375,8 @@ bool SightCheck::P_SightCheckLine (line_t *ld) return true; } ld->validcount = validcount; - if (P_PointOnDivlineSidePrecise (ld->v1->fPos(), &Trace) == - P_PointOnDivlineSidePrecise (ld->v2->fPos(), &Trace)) + if (P_PointOnDivlineSidePrecise (ld->V1(), &Trace) == + P_PointOnDivlineSidePrecise (ld->V2(), &Trace)) { return true; // line isn't crossed } diff --git a/src/p_slopes.cpp b/src/p_slopes.cpp index 0265a1514..805347b9a 100644 --- a/src/p_slopes.cpp +++ b/src/p_slopes.cpp @@ -79,14 +79,14 @@ static void P_SlopeLineToPoint (int lineid, fixed_t x, fixed_t y, fixed_t z, boo DVector3 p, v1, v2, cross; - p[0] = FIXED2DBL (line->v1->x); - p[1] = FIXED2DBL (line->v1->y); - p[2] = FIXED2DBL (plane->ZatPoint (line->v1->x, line->v1->y)); + p[0] = FIXED2DBL (line->v1->fixX()); + p[1] = FIXED2DBL (line->v1->fixY()); + p[2] = FIXED2DBL (plane->ZatPoint (line->v1->fixX(), line->v1->fixY())); 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); + v1[2] = FIXED2DBL (plane->ZatPoint (line->v2->fixX(), line->v2->fixY())) - p[2]; + v2[0] = FIXED2DBL (x - line->v1->fixX()); + v2[1] = FIXED2DBL (y - line->v1->fixY()); v2[2] = FIXED2DBL (z) - p[2]; cross = v1 ^ v2; @@ -232,12 +232,12 @@ void P_VavoomSlope(sector_t * sec, int id, fixed_t x, fixed_t y, fixed_t z, int 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] = FIXED2DBL (x - l->v2->x); - v1[1] = FIXED2DBL (y - l->v2->y); + v1[0] = FIXED2DBL (x - l->v2->fixX()); + v1[1] = FIXED2DBL (y - l->v2->fixY()); v1[2] = FIXED2DBL (z - srcheight); - v2[0] = FIXED2DBL (x - l->v1->x); - v2[1] = FIXED2DBL (y - l->v1->y); + v2[0] = FIXED2DBL (x - l->v1->fixX()); + v2[1] = FIXED2DBL (y - l->v1->fixY()); v2[2] = FIXED2DBL (z - srcheight); cross = v1 ^ v2; @@ -360,7 +360,7 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, vt2.Z = h2? *h2 : j==0? sec->GetPlaneTexZF(sector_t::floor) : sec->GetPlaneTexZF(sector_t::ceiling); vt3.Z = h3? *h3 : j==0? sec->GetPlaneTexZF(sector_t::floor) : sec->GetPlaneTexZF(sector_t::ceiling); - if (P_PointOnLineSidePrecise(vertexes[vi3].x, vertexes[vi3].y, sec->lines[0]) == 0) + if (P_PointOnLineSidePrecise(vertexes[vi3].fixX(), vertexes[vi3].fixY(), sec->lines[0]) == 0) { vec1 = vt2 - vt3; vec2 = vt1 - vt3; @@ -394,8 +394,8 @@ static void P_SetSlopesFromVertexHeights(FMapThing *firstmt, FMapThing *lastmt, srcplane->b = FLOAT2FIXED (cross[1]); srcplane->c = FLOAT2FIXED (cross[2]); srcplane->ic = DivScale32 (1, srcplane->c); - srcplane->d = -TMulScale16 (srcplane->a, vertexes[vi3].x, - srcplane->b, vertexes[vi3].y, + srcplane->d = -TMulScale16 (srcplane->a, vertexes[vi3].fixX(), + srcplane->b, vertexes[vi3].fixY(), srcplane->c, FLOAT2FIXED(vt3.Z)); } } @@ -507,8 +507,8 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which) vert = (*probe++)->v2; else vert = (*probe)->v1; - dist = fabs((double(line->v1->y) - vert->y) * line->dx - - (double(line->v1->x) - vert->x) * line->dy); + dist = fabs((double(line->v1->fixY()) - vert->fixY()) * line->dx - + (double(line->v1->fixX()) - vert->fixX()) * line->dy); if (dist > bestdist) { @@ -528,14 +528,14 @@ 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] = FIXED2DBL (line->v1->x); - p[1] = FIXED2DBL(line->v1->y); + p[0] = FIXED2DBL (line->v1->fixX()); + p[1] = FIXED2DBL(line->v1->fixY()); p[2] = FIXED2DBL(destheight); v1[0] = FIXED2DBL(line->dx); v1[1] = FIXED2DBL(line->dy); v1[2] = 0; - v2[0] = FIXED2DBL(refvert->x - line->v1->x); - v2[1] = FIXED2DBL(refvert->y - line->v1->y); + v2[0] = FIXED2DBL(refvert->fixX() - line->v1->fixX()); + v2[1] = FIXED2DBL(refvert->fixY() - line->v1->fixY()); v2[2] = FIXED2DBL(srcheight - destheight); cross = (v1 ^ v2).Unit(); @@ -551,8 +551,8 @@ static void P_AlignPlane (sector_t *sec, line_t *line, int which) srcplane->c = FLOAT2FIXED (cross[2]); //srcplane->ic = FLOAT2FIXED (1.f/cross[2]); srcplane->ic = DivScale32 (1, srcplane->c); - srcplane->d = -TMulScale16 (srcplane->a, line->v1->x, - srcplane->b, line->v1->y, + srcplane->d = -TMulScale16 (srcplane->a, line->v1->fixX(), + srcplane->b, line->v1->fixY(), srcplane->c, destheight); } diff --git a/src/p_switch.cpp b/src/p_switch.cpp index fdea7747b..9add91850 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -291,7 +291,7 @@ bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *ques // which wasn't necessarily anywhere near the switch if it was // facing a big sector (and which wasn't necessarily for the // button just activated, either). - DVector2 pt(side->linedef->v1->fPos() + side->linedef->Delta() / 2); + DVector2 pt(side->linedef->V1() + side->linedef->Delta() / 2); bool playsound; side->SetTexture(texture, Switch->frames[0].Texture); diff --git a/src/p_udmf.cpp b/src/p_udmf.cpp index 946e0000c..27de16613 100644 --- a/src/p_udmf.cpp +++ b/src/p_udmf.cpp @@ -1676,21 +1676,22 @@ public: void ParseVertex(vertex_t *vt, vertexdata_t *vd) { - vt->x = vt->y = 0; + vt->set(0, 0); vd->zCeiling = vd->zFloor = vd->flags = 0; sc.MustGetToken('{'); + fixed_t x, y; while (!sc.CheckToken('}')) { FName key = ParseKey(); switch (key) { case NAME_X: - vt->x = CheckFixed(key); + x = CheckFixed(key); break; case NAME_Y: - vt->y = CheckFixed(key); + y = CheckFixed(key); break; case NAME_ZCeiling: @@ -1707,6 +1708,7 @@ public: break; } } + vt->set(x, y); } //=========================================================================== @@ -1729,7 +1731,7 @@ public: I_Error ("Line %d has invalid vertices: %zd and/or %zd.\nThe map only contains %d vertices.", i+skipped, v1i, v2i, numvertexes); } else if (v1i == v2i || - (vertexes[v1i].x == vertexes[v2i].x && vertexes[v1i].y == vertexes[v2i].y)) + (vertexes[v1i].fixX() == vertexes[v2i].fixX() && vertexes[v1i].fixY() == vertexes[v2i].fixY())) { Printf ("Removing 0-length line %d\n", i+skipped); ParsedLines.Delete(i); diff --git a/src/p_writemap.cpp b/src/p_writemap.cpp index cd8082cfe..3b0ba4f13 100644 --- a/src/p_writemap.cpp +++ b/src/p_writemap.cpp @@ -167,8 +167,8 @@ static int WriteVERTEXES (FILE *file) for (int i = 0; i < numvertexes; ++i) { - mv.x = LittleShort(short(vertexes[i].x >> FRACBITS)); - mv.y = LittleShort(short(vertexes[i].y >> FRACBITS)); + mv.x = LittleShort(short(vertexes[i].fixX() >> FRACBITS)); + mv.y = LittleShort(short(vertexes[i].fixY() >> FRACBITS)); fwrite (&mv, sizeof(mv), 1, file); } return numvertexes * sizeof(mv); @@ -189,7 +189,7 @@ static int WriteSEGS (FILE *file) ms.v2 = LittleShort(short(segs[i].v2 - vertexes)); ms.linedef = LittleShort(short(segs[i].linedef - lines)); ms.side = segs[i].sidedef == segs[i].linedef->sidedef[0] ? 0 : LittleShort((short)1); - ms.angle = LittleShort(short(R_PointToAngle2 (segs[i].v1->x, segs[i].v1->y, segs[i].v2->x, segs[i].v2->y)>>16)); + ms.angle = LittleShort(short(R_PointToAngle2 (segs[i].v1->fixX(), segs[i].v1->fixY(), segs[i].v2->fixX(), segs[i].v2->fixY())>>16)); fwrite (&ms, sizeof(ms), 1, file); } } diff --git a/src/po_man.cpp b/src/po_man.cpp index c43d094ae..7fbef05f2 100644 --- a/src/po_man.cpp +++ b/src/po_man.cpp @@ -867,7 +867,7 @@ void FPolyObj::ThrustMobj (AActor *actor, side_t *side) } vertex_t *v1 = side->V1(); vertex_t *v2 = side->V2(); - thrustAngle = VecToAngle(v2->x - v1->x, v2->y - v1->y) - 90.; + thrustAngle = VecToAngle(v2->fixX() - v1->fixX(), v2->fixY() - v1->fixY()) - 90.; pe = static_cast(specialdata); if (pe) @@ -921,30 +921,30 @@ void FPolyObj::UpdateBBox () { line_t *line = Linedefs[i]; - if (line->v1->x < line->v2->x) + if (line->v1->fixX() < line->v2->fixX()) { - line->bbox[BOXLEFT] = line->v1->x; - line->bbox[BOXRIGHT] = line->v2->x; + line->bbox[BOXLEFT] = line->v1->fixX(); + line->bbox[BOXRIGHT] = line->v2->fixX(); } else { - line->bbox[BOXLEFT] = line->v2->x; - line->bbox[BOXRIGHT] = line->v1->x; + line->bbox[BOXLEFT] = line->v2->fixX(); + line->bbox[BOXRIGHT] = line->v1->fixX(); } - if (line->v1->y < line->v2->y) + if (line->v1->fixY() < line->v2->fixY()) { - line->bbox[BOXBOTTOM] = line->v1->y; - line->bbox[BOXTOP] = line->v2->y; + line->bbox[BOXBOTTOM] = line->v1->fixY(); + line->bbox[BOXTOP] = line->v2->fixY(); } else { - line->bbox[BOXBOTTOM] = line->v2->y; - line->bbox[BOXTOP] = line->v1->y; + line->bbox[BOXBOTTOM] = line->v2->fixY(); + line->bbox[BOXTOP] = line->v1->fixY(); } // Update the line's slopetype - line->dx = line->v2->x - line->v1->x; - line->dy = line->v2->y - line->v1->y; + line->dx = line->v2->fixX() - line->v1->fixX(); + line->dy = line->v2->fixY() - line->v1->fixY(); } CalcCenter(); } @@ -954,8 +954,8 @@ void FPolyObj::CalcCenter() SQWORD cx = 0, cy = 0; for(unsigned i=0;ix; - cy += Vertices[i]->y; + cx += Vertices[i]->fixX(); + cy += Vertices[i]->fixY(); } CenterSpot.x = (fixed_t)(cx / Vertices.Size()); CenterSpot.y = (fixed_t)(cy / Vertices.Size()); @@ -1011,8 +1011,7 @@ void FPolyObj::DoMovePolyobj (int x, int y) { for(unsigned i=0;i < Vertices.Size(); i++) { - Vertices[i]->x += x; - Vertices[i]->y += y; + Vertices[i]->set(Vertices[i]->fixX() + x, Vertices[i]->fixY() + y); PrevPts[i].x += x; PrevPts[i].y += y; } @@ -1061,11 +1060,11 @@ bool FPolyObj::RotatePolyobj (angle_t angle, bool fromsave) for(unsigned i=0;i < Vertices.Size(); i++) { - PrevPts[i].x = Vertices[i]->x; - PrevPts[i].y = Vertices[i]->y; - Vertices[i]->x = OriginalPts[i].x; - Vertices[i]->y = OriginalPts[i].y; - RotatePt(an, &Vertices[i]->x, &Vertices[i]->y, StartSpot.x, StartSpot.y); + PrevPts[i].x = Vertices[i]->fixX(); + PrevPts[i].y = Vertices[i]->fixY(); + FPolyVertex torot = OriginalPts[i]; + RotatePt(an, &torot.x, &torot.y, StartSpot.x, StartSpot.y); + Vertices[i]->set(torot.x, torot.y); } blocked = false; validcount++; @@ -1085,8 +1084,7 @@ bool FPolyObj::RotatePolyobj (angle_t angle, bool fromsave) { for(unsigned i=0;i < Vertices.Size(); i++) { - Vertices[i]->x = PrevPts[i].x; - Vertices[i]->y = PrevPts[i].y; + Vertices[i]->set(PrevPts[i].x, PrevPts[i].y); } UpdateBBox(); LinkPolyobj(); @@ -1281,9 +1279,9 @@ void FPolyObj::LinkPolyobj () vertex_t *vt; vt = Sidedefs[i]->linedef->v1; - Bounds.AddToBox(vt->x, vt->y); + Bounds.AddToBox(vt->fixX(), vt->fixY()); vt = Sidedefs[i]->linedef->v2; - Bounds.AddToBox(vt->x, vt->y); + Bounds.AddToBox(vt->fixX(), vt->fixY()); } bbox[BOXRIGHT] = GetSafeBlockX(Bounds.Right() - bmaporgx); bbox[BOXLEFT] = GetSafeBlockX(Bounds.Left() - bmaporgx); @@ -1373,34 +1371,34 @@ void FPolyObj::ClosestPoint(fixed_t fx, fixed_t fy, fixed_t &ox, fixed_t &oy, si { vertex_t *v1 = Sidedefs[i]->V1(); vertex_t *v2 = Sidedefs[i]->V2(); - double a = v2->x - v1->x; - double b = v2->y - v1->y; + double a = v2->fixX() - v1->fixX(); + double b = v2->fixY() - v1->fixY(); double den = a*a + b*b; double ix, iy, dist; if (den == 0) { // Line is actually a point! - ix = v1->x; - iy = v1->y; + ix = v1->fixX(); + iy = v1->fixY(); } else { - double num = (x - v1->x) * a + (y - v1->y) * b; + double num = (x - v1->fixX()) * a + (y - v1->fixY()) * b; double u = num / den; if (u <= 0) { - ix = v1->x; - iy = v1->y; + ix = v1->fixX(); + iy = v1->fixY(); } else if (u >= 1) { - ix = v2->x; - iy = v2->y; + ix = v2->fixX(); + iy = v2->fixY(); } else { - ix = v1->x + u * a; - iy = v1->y + u * b; + ix = v1->fixX() + u * a; + iy = v1->fixY() + u * b; } } a = (ix - x); @@ -1692,10 +1690,9 @@ static void TranslateToStartSpot (int tag, int originX, int originY) } for (unsigned i = 0; i < po->Vertices.Size(); i++) { - po->Vertices[i]->x -= deltaX; - po->Vertices[i]->y -= deltaY; - po->OriginalPts[i].x = po->Vertices[i]->x - po->StartSpot.x; - po->OriginalPts[i].y = po->Vertices[i]->y - po->StartSpot.y; + po->Vertices[i]->set(po->Vertices[i]->fixX() - deltaX, po->Vertices[i]->fixY() - deltaY); + po->OriginalPts[i].x = po->Vertices[i]->fixX() - po->StartSpot.x; + po->OriginalPts[i].y = po->Vertices[i]->fixY() - po->StartSpot.y; } po->CalcCenter(); // For compatibility purposes diff --git a/src/po_man.h b/src/po_man.h index fbfd15acb..e989ad4f5 100644 --- a/src/po_man.h +++ b/src/po_man.h @@ -13,8 +13,8 @@ struct FPolyVertex FPolyVertex &operator=(vertex_t *v) { - x = v->x; - y = v->y; + x = v->fixX(); + y = v->fixX(); return *this; } }; diff --git a/src/portal.cpp b/src/portal.cpp index 79470d410..3e50e2d71 100644 --- a/src/portal.cpp +++ b/src/portal.cpp @@ -168,8 +168,8 @@ void FLinePortalTraverse::AddLineIntercepts(int bx, int by) if (ld->validcount == validcount) continue; // already processed - if (P_PointOnDivlineSidePrecise (ld->v1->x, ld->v1->y, &trace) == - P_PointOnDivlineSidePrecise (ld->v2->x, ld->v2->y, &trace)) + if (P_PointOnDivlineSidePrecise (ld->v1->fixX(), ld->v1->fixY(), &trace) == + P_PointOnDivlineSidePrecise (ld->v2->fixX(), ld->v2->fixY(), &trace)) { continue; // line isn't crossed } @@ -513,13 +513,13 @@ inline int P_PointOnLineSideExplicit (fixed_t x, fixed_t y, fixed_t x1, fixed_t inline int P_GetLineSide(fixed_t x, fixed_t y, const line_t *line) { - return DMulScale32(y - line->v1->y, line->dx, line->v1->x - x, line->dy); + return DMulScale32(y - line->v1->fixY(), line->dx, line->v1->fixX() - x, line->dy); } bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t viewy, bool partial, bool samebehind) { - int behind1 = P_GetLineSide(line->v1->x, line->v1->y, portal); - int behind2 = P_GetLineSide(line->v2->x, line->v2->y, portal); + int behind1 = P_GetLineSide(line->v1->fixX(), line->v1->fixY(), portal); + int behind2 = P_GetLineSide(line->v2->fixX(), line->v2->fixY(), portal); if (behind1 == 0 && behind2 == 0) { @@ -544,8 +544,8 @@ bool P_ClipLineToPortal(line_t* line, line_t* portal, fixed_t viewx, fixed_t vie { // The line intersects with the portal straight, so we need to do another check to see how both ends of the portal lie in relation to the viewer. int viewside = P_PointOnLineSidePrecise(viewx, viewy, line); - int p1side = P_GetLineSide(portal->v1->x, portal->v1->y, line); - int p2side = P_GetLineSide(portal->v2->x, portal->v2->y, line); + int p1side = P_GetLineSide(portal->v1->fixX(), portal->v1->fixY(), line); + int p2side = P_GetLineSide(portal->v2->fixX(), portal->v2->fixY(), line); // Do the same handling of points on the portal straight than above. if (p1side == 0) p1side = p2side; else if (p2side == 0) p2side = p1side; @@ -569,15 +569,15 @@ void P_TranslatePortalXY(line_t* src, fixed_t& x, fixed_t& y) if (!port) return; // offsets from line - fixed_t nposx = x - src->v1->x; - fixed_t nposy = y - src->v1->y; + fixed_t nposx = x - src->v1->fixX(); + fixed_t nposy = y - src->v1->fixY(); // Rotate position along normal to match exit linedef fixed_t tx = FixedMul(nposx, port->mCosRot) - FixedMul(nposy, port->mSinRot); fixed_t ty = FixedMul(nposy, port->mCosRot) + FixedMul(nposx, port->mSinRot); - tx += port->mDestination->v2->x; - ty += port->mDestination->v2->y; + tx += port->mDestination->v2->fixX(); + ty += port->mDestination->v2->fixY(); x = tx; y = ty; @@ -632,11 +632,11 @@ void P_TranslatePortalZ(line_t* src, fixed_t& z) switch (src->getPortalAlignment()) { case PORG_FLOOR: - z = z - src->frontsector->floorplane.ZatPoint(src->v1->x, src->v1->y) + dst->frontsector->floorplane.ZatPoint(dst->v2->x, dst->v2->y); + z = z - src->frontsector->floorplane.ZatPoint(src->v1->fixX(), src->v1->fixY()) + dst->frontsector->floorplane.ZatPoint(dst->v2->fixX(), dst->v2->fixY()); return; case PORG_CEILING: - z = z - src->frontsector->ceilingplane.ZatPoint(src->v1->x, src->v1->y) + dst->frontsector->ceilingplane.ZatPoint(dst->v2->x, dst->v2->y); + z = z - src->frontsector->ceilingplane.ZatPoint(src->v1->fixX(), src->v1->fixY()) + dst->frontsector->ceilingplane.ZatPoint(dst->v2->fixX(), dst->v2->fixY()); return; default: @@ -655,8 +655,8 @@ fixed_t P_PointLineDistance(line_t* line, fixed_t x, fixed_t y) angle_t angle = R_PointToAngle2(0, 0, line->dx, line->dy); angle += ANGLE_180; - fixed_t dx = line->v1->x - x; - fixed_t dy = line->v1->y - y; + fixed_t dx = line->v1->fixX() - x; + fixed_t dy = line->v1->fixY() - y; fixed_t s = finesine[angle>>ANGLETOFINESHIFT]; fixed_t c = finecosine[angle>>ANGLETOFINESHIFT]; diff --git a/src/r_bsp.cpp b/src/r_bsp.cpp index 42745f8d7..2eb5cebc8 100644 --- a/src/r_bsp.cpp +++ b/src/r_bsp.cpp @@ -404,8 +404,8 @@ sector_t *R_FakeFlat(sector_t *sec, sector_t *tempsec, // sectors at the same time. if (back && !r_fakingunderwater && curline->frontsector->heightsec == NULL) { - if (rw_frontcz1 <= s->floorplane.ZatPoint (curline->v1->x, curline->v1->y) && - rw_frontcz2 <= s->floorplane.ZatPoint (curline->v2->x, curline->v2->y)) + if (rw_frontcz1 <= s->floorplane.ZatPoint (curline->v1->fixX(), curline->v1->fixY()) && + rw_frontcz2 <= s->floorplane.ZatPoint (curline->v2->fixX(), curline->v2->fixY())) { // Check that the window is actually visible for (int z = WallC.sx1; z < WallC.sx2; ++z) @@ -529,10 +529,10 @@ void R_AddLine (seg_t *line) // [RH] Color if not texturing line dc_color = (((int)(line - segs) * 8) + 4) & 255; - tx1 = line->v1->x - viewx; - tx2 = line->v2->x - viewx; - ty1 = line->v1->y - viewy; - ty2 = line->v2->y - viewy; + tx1 = line->v1->fixX() - viewx; + tx2 = line->v2->fixX() - viewx; + ty1 = line->v1->fixY() - viewy; + ty2 = line->v2->fixY() - viewy; // Reject lines not facing viewer if (DMulScale32 (ty1, tx1-tx2, tx1, ty2-ty1) >= 0) @@ -573,17 +573,17 @@ void R_AddLine (seg_t *line) { swapvalues (v1, v2); } - WallT.InitFromLine(v1->x - viewx, v1->y - viewy, v2->x - viewx, v2->y - viewy); + WallT.InitFromLine(v1->fixX() - viewx, v1->fixY() - viewy, v2->fixX() - viewx, v2->fixY() - viewy); } if (!(fake3D & FAKE3D_FAKEBACK)) { backsector = line->backsector; } - rw_frontcz1 = frontsector->ceilingplane.ZatPoint (line->v1->x, line->v1->y); - rw_frontfz1 = frontsector->floorplane.ZatPoint (line->v1->x, line->v1->y); - rw_frontcz2 = frontsector->ceilingplane.ZatPoint (line->v2->x, line->v2->y); - rw_frontfz2 = frontsector->floorplane.ZatPoint (line->v2->x, line->v2->y); + rw_frontcz1 = frontsector->ceilingplane.ZatPoint (line->v1->fixX(), line->v1->fixY()); + rw_frontfz1 = frontsector->floorplane.ZatPoint (line->v1->fixX(), line->v1->fixY()); + rw_frontcz2 = frontsector->ceilingplane.ZatPoint (line->v2->fixX(), line->v2->fixY()); + rw_frontfz2 = frontsector->floorplane.ZatPoint (line->v2->fixX(), line->v2->fixY()); rw_mustmarkfloor = rw_mustmarkceiling = false; rw_havehigh = rw_havelow = false; @@ -602,10 +602,10 @@ void R_AddLine (seg_t *line) } doorclosed = 0; // killough 4/16/98 - rw_backcz1 = backsector->ceilingplane.ZatPoint (line->v1->x, line->v1->y); - rw_backfz1 = backsector->floorplane.ZatPoint (line->v1->x, line->v1->y); - rw_backcz2 = backsector->ceilingplane.ZatPoint (line->v2->x, line->v2->y); - rw_backfz2 = backsector->floorplane.ZatPoint (line->v2->x, line->v2->y); + rw_backcz1 = backsector->ceilingplane.ZatPoint (line->v1->fixX(), line->v1->fixY()); + rw_backfz1 = backsector->floorplane.ZatPoint (line->v1->fixX(), line->v1->fixY()); + rw_backcz2 = backsector->ceilingplane.ZatPoint (line->v2->fixX(), line->v2->fixY()); + rw_backfz2 = backsector->floorplane.ZatPoint (line->v2->fixX(), line->v2->fixY()); // Cannot make these walls solid, because it can result in // sprite clipping problems for sprites near the wall diff --git a/src/r_data/r_interpolate.cpp b/src/r_data/r_interpolate.cpp index 565fb2498..1d637394e 100644 --- a/src/r_data/r_interpolate.cpp +++ b/src/r_data/r_interpolate.cpp @@ -788,8 +788,8 @@ void DPolyobjInterpolation::UpdateInterpolation() { for(unsigned int i = 0; i < poly->Vertices.Size(); i++) { - oldverts[i*2 ] = poly->Vertices[i]->x; - oldverts[i*2+1] = poly->Vertices[i]->y; + oldverts[i*2 ] = poly->Vertices[i]->fixX(); + oldverts[i*2+1] = poly->Vertices[i]->fixY(); } oldcx = poly->CenterSpot.x; oldcy = poly->CenterSpot.y; @@ -805,8 +805,7 @@ void DPolyobjInterpolation::Restore() { for(unsigned int i = 0; i < poly->Vertices.Size(); i++) { - poly->Vertices[i]->x = bakverts[i*2 ]; - poly->Vertices[i]->y = bakverts[i*2+1]; + poly->Vertices[i]->set(bakverts[i*2 ], bakverts[i*2+1]); } poly->CenterSpot.x = bakcx; poly->CenterSpot.y = bakcy; @@ -824,17 +823,15 @@ void DPolyobjInterpolation::Interpolate(fixed_t smoothratio) bool changed = false; for(unsigned int i = 0; i < poly->Vertices.Size(); i++) { - fixed_t *px = &poly->Vertices[i]->x; - fixed_t *py = &poly->Vertices[i]->y; - - bakverts[i*2 ] = *px; - bakverts[i*2+1] = *py; + bakverts[i*2 ] = poly->Vertices[i]->fixX(); + bakverts[i*2+1] = poly->Vertices[i]->fixY(); if (bakverts[i * 2] != oldverts[i * 2] || bakverts[i * 2 + 1] != oldverts[i * 2 + 1]) { changed = true; - *px = oldverts[i * 2] + FixedMul(bakverts[i * 2] - oldverts[i * 2], smoothratio); - *py = oldverts[i * 2 + 1] + FixedMul(bakverts[i * 2 + 1] - oldverts[i * 2 + 1], smoothratio); + poly->Vertices[i]->set( + oldverts[i * 2] + FixedMul(bakverts[i * 2] - oldverts[i * 2], smoothratio), + oldverts[i * 2 + 1] + FixedMul(bakverts[i * 2 + 1] - oldverts[i * 2 + 1], smoothratio)); } } if (refcount == 0 && !changed) diff --git a/src/r_defs.h b/src/r_defs.h index c34fd8525..a8000f878 100644 --- a/src/r_defs.h +++ b/src/r_defs.h @@ -91,10 +91,33 @@ struct vertexdata_t double zCeiling, zFloor; DWORD flags; }; + +#ifdef USE_FLOAT +typedef float vtype; +#elif !defined USE_FIXED +typedef double vtype; +#endif + + struct vertex_t { +private: fixed_t x, y; +public: + + void set(fixed_t x, fixed_t y) + { + this->x = x; + this->y = y; + } + + void set(double x, double y) + { + this->x = FLOAT2FIXED(x); + this->y = FLOAT2FIXED(y); + } + double fX() const { return FIXED2DBL(x); @@ -105,6 +128,16 @@ struct vertex_t return FIXED2DBL(y); } + fixed_t fixX() const + { + return x; + } + + fixed_t fixY() const + { + return y; + } + DVector2 fPos() { return{ fX(), fY() }; @@ -320,7 +353,7 @@ struct secplane_t // Returns the value of z at vertex v fixed_t ZatPoint (const vertex_t *v) const { - return FixedMul (ic, -d - DMulScale16 (a, v->x, b, v->y)); + return FixedMul (ic, -d - DMulScale16 (a, v->fixX(), b, v->fixY())); } fixed_t ZatPoint (const AActor *ac) const @@ -342,7 +375,7 @@ struct secplane_t // Returns the value of z at vertex v if d is equal to dist fixed_t ZatPointDist (const vertex_t *v, fixed_t dist) { - return FixedMul (ic, -dist - DMulScale16 (a, v->x, b, v->y)); + return FixedMul (ic, -dist - DMulScale16 (a, v->fixX(), b, v->fixY())); } // Flips the plane's vertical orientiation, so that if it pointed up, @@ -404,7 +437,7 @@ struct secplane_t fixed_t PointToDist (const vertex_t *v, fixed_t z) const { - return -TMulScale16 (a, v->x, b, v->y, z, c); + return -TMulScale16 (a, v->fixX(), b, v->fixY(), z, c); } void SetAtHeight(fixed_t height, int ceiling) @@ -1254,12 +1287,12 @@ struct line_t DVector2 V1() const { - return{ FIXED2DBL(v1->x), FIXED2DBL(v1->y) }; + return v1->fPos(); } DVector2 V2() const { - return{ FIXED2DBL(v2->x), FIXED2DBL(v2->y) }; + return v1->fPos(); } DVector2 Delta() const diff --git a/src/r_main.cpp b/src/r_main.cpp index 8add28594..56945f406 100644 --- a/src/r_main.cpp +++ b/src/r_main.cpp @@ -704,20 +704,20 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) // Reflect the current view behind the mirror. if (pds->src->dx == 0) { // vertical mirror - viewx = v1->x - startx + v1->x; + viewx = v1->fixX() - startx + v1->fixX(); } else if (pds->src->dy == 0) { // horizontal mirror - viewy = v1->y - starty + v1->y; + viewy = v1->fixY() - starty + v1->fixY(); } else { // any mirror--use floats to avoid integer overflow vertex_t *v2 = pds->src->v2; - 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 dx = v2->fX() - v1->fX(); + double dy = v2->fY() - v1->fY(); + double x1 = v1->fX(); + double y1 = v1->fY(); double x = FIXED2DBL(startx); double y = FIXED2DBL(starty); @@ -727,8 +727,8 @@ void R_EnterPortal (PortalDrawseg* pds, int depth) viewx = FLOAT2FIXED((x1 + r * dx)*2 - x); viewy = FLOAT2FIXED((y1 + r * dy)*2 - y); } - viewangle = 2*R_PointToAngle2 (pds->src->v1->x, pds->src->v1->y, - pds->src->v2->x, pds->src->v2->y) - startang; + viewangle = 2*R_PointToAngle2 (pds->src->v1->fixX(), pds->src->v1->fixY(), + pds->src->v2->fixX(), pds->src->v2->fixY()) - startang; } else diff --git a/src/r_segs.cpp b/src/r_segs.cpp index 8a349516c..cdcc1ca11 100644 --- a/src/r_segs.cpp +++ b/src/r_segs.cpp @@ -1388,10 +1388,10 @@ static void wallscan_np2_ds(drawseg_t *ds, int x1, int x2, short *uwal, short *d { if (rw_pic->GetHeight() != 1 << rw_pic->HeightBits) { - fixed_t frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1->x, ds->curline->v1->y); - fixed_t frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1->x, ds->curline->v1->y); - fixed_t frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2->x, ds->curline->v2->y); - fixed_t frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2->x, ds->curline->v2->y); + fixed_t frontcz1 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v1->fixX(), ds->curline->v1->fixY()); + fixed_t frontfz1 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v1->fixX(), ds->curline->v1->fixY()); + fixed_t frontcz2 = ds->curline->frontsector->ceilingplane.ZatPoint(ds->curline->v2->fixX(), ds->curline->v2->fixY()); + fixed_t frontfz2 = ds->curline->frontsector->floorplane.ZatPoint(ds->curline->v2->fixX(), ds->curline->v2->fixY()); fixed_t top = MAX(frontcz1, frontcz2); fixed_t bot = MIN(frontfz1, frontfz2); if (fake3D & FAKE3D_CLIPTOP) @@ -2778,25 +2778,25 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) if (MirrorFlags & RF_XFLIP) { - x = curline->v2->x; - y = curline->v2->y; + x = curline->v2->fixX(); + y = curline->v2->fixY(); if (wallc->sx1 == 0 && 0 != (den = wallc->tx1 - wallc->tx2 + wallc->ty1 - wallc->ty2)) { int frac = SafeDivScale30 (wallc->ty1 + wallc->tx1, den); - x -= MulScale30 (frac, x - curline->v1->x); - y -= MulScale30 (frac, y - curline->v1->y); + x -= MulScale30 (frac, x - curline->v1->fixX()); + y -= MulScale30 (frac, y - curline->v1->fixY()); } z1 = viewz - plane.ZatPoint (x, y); if (wallc->sx2 > wallc->sx1 + 1) { - x = curline->v1->x; - y = curline->v1->y; + x = curline->v1->fixX(); + y = curline->v1->fixY(); if (wallc->sx2 == viewwidth && 0 != (den = wallc->tx1 - wallc->tx2 - wallc->ty1 + wallc->ty2)) { int frac = SafeDivScale30 (wallc->ty2 - wallc->tx2, den); - x += MulScale30 (frac, curline->v2->x - x); - y += MulScale30 (frac, curline->v2->y - y); + x += MulScale30 (frac, curline->v2->fixX() - x); + y += MulScale30 (frac, curline->v2->fixY() - y); } z2 = viewz - plane.ZatPoint (x, y); } @@ -2807,25 +2807,25 @@ int WallMost (short *mostbuf, const secplane_t &plane, const FWallCoords *wallc) } else { - x = curline->v1->x; - y = curline->v1->y; + x = curline->v1->fixX(); + y = curline->v1->fixY(); if (wallc->sx1 == 0 && 0 != (den = wallc->tx1 - wallc->tx2 + wallc->ty1 - wallc->ty2)) { int frac = SafeDivScale30 (wallc->ty1 + wallc->tx1, den); - x += MulScale30 (frac, curline->v2->x - x); - y += MulScale30 (frac, curline->v2->y - y); + x += MulScale30 (frac, curline->v2->fixX() - x); + y += MulScale30 (frac, curline->v2->fixY() - y); } z1 = viewz - plane.ZatPoint (x, y); if (wallc->sx2 > wallc->sx1 + 1) { - x = curline->v2->x; - y = curline->v2->y; + x = curline->v2->fixX(); + y = curline->v2->fixY(); if (wallc->sx2 == viewwidth && 0 != (den = wallc->tx1 - wallc->tx2 - wallc->ty1 + wallc->ty2)) { int frac = SafeDivScale30 (wallc->ty2 - wallc->tx2, den); - x -= MulScale30 (frac, x - curline->v1->x); - y -= MulScale30 (frac, y - curline->v1->y); + x -= MulScale30 (frac, x - curline->v1->fixX()); + y -= MulScale30 (frac, y - curline->v1->fixY()); } z2 = viewz - plane.ZatPoint (x, y); } @@ -3101,7 +3101,7 @@ static void R_RenderDecal (side_t *wall, DBaseDecal *decal, drawseg_t *clipper, decalx = FLOAT2FIXED(dcx); decaly = FLOAT2FIXED(dcy); - angle_t ang = R_PointToAngle2 (curline->v1->x, curline->v1->y, curline->v2->x, curline->v2->y) >> ANGLETOFINESHIFT; + angle_t ang = R_PointToAngle2 (curline->v1->fixX(), curline->v1->fixY(), curline->v2->fixX(), curline->v2->fixY()) >> ANGLETOFINESHIFT; lx = decalx - FixedMul (x1, finecosine[ang]) - viewx; lx2 = decalx + FixedMul (x2, finecosine[ang]) - viewx; ly = decaly - FixedMul (x1, finesine[ang]) - viewy; diff --git a/src/r_things.cpp b/src/r_things.cpp index a35af4867..158716a31 100644 --- a/src/r_things.cpp +++ b/src/r_things.cpp @@ -2211,8 +2211,8 @@ void R_DrawSprite (vissprite_t *spr) } // Check if sprite is in front of draw seg: if ((!spr->bWallSprite && neardepth > spr->depth) || ((spr->bWallSprite || fardepth > spr->depth) && - DMulScale32(spr->gy - ds->curline->v1->y, ds->curline->v2->x - ds->curline->v1->x, - ds->curline->v1->x - spr->gx, ds->curline->v2->y - ds->curline->v1->y) <= 0)) + DMulScale32(spr->gy - ds->curline->v1->fixY(), ds->curline->v2->fixX() - ds->curline->v1->fixX(), + ds->curline->v1->fixX() - spr->gx, ds->curline->v2->fixY() - ds->curline->v1->fixY()) <= 0)) { // seg is behind sprite, so draw the mid texture if it has one if (ds->CurrentPortalUniq == CurrentPortalUniq && // [ZZ] instead, portal uniq check is made here