From 3f17d64f90c0795b5d70ecdbe72fdae88a3b32ab Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sat, 24 Sep 2016 09:42:35 +0200 Subject: [PATCH 1/4] - fixed pitch comparison in visibility checking. --- src/p_mobj.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 8d6d752379..4369ae9cc0 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -1052,7 +1052,7 @@ bool AActor::IsInsideVisibleAngles() const angleend = temp; } - if (pitchstart > angleend) + if (pitchstart > pitchend) { DAngle temp = pitchstart; pitchstart = pitchend; From a419b581a8744ead4b0c16833cd67113858ecc2f Mon Sep 17 00:00:00 2001 From: "alexey.lysiuk" Date: Sat, 24 Sep 2016 13:15:45 +0300 Subject: [PATCH 2/4] Fixed compilation on macOS --- src/m_swap.h | 15 +++++++++++++++ src/serializer.cpp | 2 +- 2 files changed, 16 insertions(+), 1 deletion(-) diff --git a/src/m_swap.h b/src/m_swap.h index f5606e59c3..ddcf8eaf90 100644 --- a/src/m_swap.h +++ b/src/m_swap.h @@ -46,6 +46,11 @@ inline short LittleShort(int x) return OSSwapLittleToHostInt16((uint16_t)x); } +inline unsigned short LittleShort(unsigned int x) +{ + return OSSwapLittleToHostInt16((uint16_t)x); +} + inline int LittleLong(int x) { return OSSwapLittleToHostInt32((uint32_t)x); @@ -56,6 +61,16 @@ inline unsigned int LittleLong(unsigned int x) return OSSwapLittleToHostInt32(x); } +inline int LittleLong(long x) +{ + return OSSwapLittleToHostInt32((uint32_t)x); +} + +inline unsigned int LittleLong(unsigned long x) +{ + return OSSwapLittleToHostInt32((uint32_t)x); +} + inline short BigShort(short x) { return (short)OSSwapBigToHostInt16((uint16_t)x); diff --git a/src/serializer.cpp b/src/serializer.cpp index a23459ced0..445a3b22b0 100644 --- a/src/serializer.cpp +++ b/src/serializer.cpp @@ -1294,7 +1294,7 @@ FSerializer &SerializePointer(FSerializer &arc, const char *key, T *&value, T ** assert(base != nullptr); if (arc.isReading() || !arc.w->inObject() || defval == nullptr || value != *defval) { - ptrdiff_t vv = value == nullptr ? -1 : value - base; + int64_t vv = value == nullptr ? -1 : value - base; Serialize(arc, key, vv, nullptr); value = vv < 0 ? nullptr : base + vv; } From 74b8e9f28660f62f10825c9e502f5c8428924596 Mon Sep 17 00:00:00 2001 From: Major Cooke Date: Sat, 24 Sep 2016 10:26:21 -0500 Subject: [PATCH 3/4] - Don't use Normalized180() on angles. This could result in ranges being wrongly inverted. - Fixed properties not having the proper indices. - Use ViewPos-to-actor instead of measuring actor-to-actor. - Use the actual camera instead of the actor so camera textures can work. --- src/p_mobj.cpp | 25 ++++++++++++------------- src/thingdef/thingdef_properties.cpp | 4 ++-- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/src/p_mobj.cpp b/src/p_mobj.cpp index 4369ae9cc0..400b417981 100644 --- a/src/p_mobj.cpp +++ b/src/p_mobj.cpp @@ -70,6 +70,7 @@ #include "p_spec.h" #include "p_checkposition.h" #include "serializer.h" +#include "r_utility.h" // MACROS ------------------------------------------------------------------ @@ -1040,11 +1041,11 @@ bool AActor::IsInsideVisibleAngles() const if (players[consoleplayer].camera == nullptr) return true; - DAngle anglestart = VisibleStartAngle.Normalized180(); - DAngle angleend = VisibleEndAngle.Normalized180(); - DAngle pitchstart = VisibleStartPitch.Normalized180(); - DAngle pitchend = VisibleEndPitch.Normalized180(); - + DAngle anglestart = VisibleStartAngle; + DAngle angleend = VisibleEndAngle; + DAngle pitchstart = VisibleStartPitch; + DAngle pitchend = VisibleEndPitch; + if (anglestart > angleend) { DAngle temp = anglestart; @@ -1058,22 +1059,20 @@ bool AActor::IsInsideVisibleAngles() const pitchstart = pitchend; pitchend = temp; } + - player_t* pPlayer = players[consoleplayer].camera->player; + AActor *mo = players[consoleplayer].camera; - if (pPlayer && pPlayer->mo) + if (mo != nullptr) { - AActor *mo = pPlayer->mo; - DVector3 diffang = Vec3To(mo); + + DVector3 diffang = ViewPos - Pos(); DAngle to = diffang.Angle(); if (!(renderflags & RF_ABSMASKANGLE)) to = deltaangle(Angles.Yaw, to); - // Note that this check is inversed due to only being able to vectorize - // from one way (this actor to the player). It still means to pass - // if the player is within the visible angles. - if ((to <= anglestart || to >= angleend)) + if ((to >= anglestart && to <= angleend)) { to = diffang.Pitch(); if (!(renderflags & RF_ABSMASKPITCH)) diff --git a/src/thingdef/thingdef_properties.cpp b/src/thingdef/thingdef_properties.cpp index 8ada05aa67..927e3e5372 100644 --- a/src/thingdef/thingdef_properties.cpp +++ b/src/thingdef/thingdef_properties.cpp @@ -1437,7 +1437,7 @@ DEFINE_PROPERTY(spriterotation, F, Actor) DEFINE_PROPERTY(visibleangles, Ff, Actor) { PROP_DOUBLE_PARM(visstart, 0); - PROP_DOUBLE_PARM(visend, 0); + PROP_DOUBLE_PARM(visend, 1); defaults->VisibleStartAngle = visstart; defaults->VisibleEndAngle = visend; } @@ -1448,7 +1448,7 @@ DEFINE_PROPERTY(visibleangles, Ff, Actor) DEFINE_PROPERTY(visiblepitch, Ff, Actor) { PROP_DOUBLE_PARM(visstart, 0); - PROP_DOUBLE_PARM(visend, 0); + PROP_DOUBLE_PARM(visend, 1); defaults->VisibleStartPitch = visstart; defaults->VisibleEndPitch = visend; } From 6a6a0e8017109fbf1256bccf878277cf6e75403e Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 25 Sep 2016 01:28:27 +0200 Subject: [PATCH 4/4] - removed some more hubtravel related player start fudging. * do not skip the player_t init when travelling in a hub. The old player may still be needed in some edge cases. This applies only to singleplayer for now. The multiplayer version still needs reviewing. I left it alone because it may shuffle players around which is not wanted when doing hub travelling. * do not spawn two temp players in G_FinishTravel. Instead handle the case where no player_t::mo can be found gracefully by adding a few nullptr checks. This temp player served no real purpose except for having a valid pointer. The actual start position was retrieved from somewhere else. --- src/g_level.cpp | 29 +++++++++++++---------------- src/p_saveg.cpp | 11 ++++------- 2 files changed, 17 insertions(+), 23 deletions(-) diff --git a/src/g_level.cpp b/src/g_level.cpp index dcf97ba4fe..90b31138d2 100644 --- a/src/g_level.cpp +++ b/src/g_level.cpp @@ -1207,29 +1207,23 @@ void G_FinishTravel () pnum = int(pawn->player - players); pawn->ChangeStatNum (STAT_PLAYER); pawndup = pawn->player->mo; - start = NULL; assert (pawn != pawndup); - if (pawndup == NULL) - { // Oh no! there was no start for this player! - start = G_PickPlayerStart(pnum, PPS_FORCERANDOM); - if (start != NULL) pawndup = P_SpawnPlayer(start, pnum, (level.flags2 & LEVEL2_PRERAISEWEAPON) ? SPF_WEAPONFULLYUP : 0); - if (pawndup == NULL) - { - pawn->flags |= MF_NOSECTOR | MF_NOBLOCKMAP; - pawn->Destroy(); - continue; - } - } + start = G_PickPlayerStart(pnum, 0); if (start == NULL) { - start = G_PickPlayerStart(pnum, 0); - if (start == NULL) + if (pawndup != nullptr) { 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->Pos()); } + else + { + // Could not find a start for this player at all. This really should never happen but if it does, let's better abort. + DThinker::DestroyThinkersInList(STAT_TRAVELLING); + I_Error ("No player %d start to travel to!\n", pnum + 1); + } } oldpawn = pawndup; @@ -1266,8 +1260,11 @@ void G_FinishTravel () pawn->player->camera = pawn; pawn->player->viewheight = pawn->ViewHeight; pawn->flags2 &= ~MF2_BLASTED; - DObject::StaticPointerSubstitution (oldpawn, pawn); - oldpawn->Destroy(); + if (oldpawn != nullptr) + { + DObject::StaticPointerSubstitution (oldpawn, pawn); + oldpawn->Destroy(); + } if (pawndup != NULL) { pawndup->Destroy(); diff --git a/src/p_saveg.cpp b/src/p_saveg.cpp index 4657601374..2382d3ede5 100644 --- a/src/p_saveg.cpp +++ b/src/p_saveg.cpp @@ -537,7 +537,7 @@ void P_SerializeSounds(FSerializer &arc) //========================================================================== void CopyPlayer(player_t *dst, player_t *src, const char *name); -static void ReadOnePlayer(FSerializer &arc, bool skipload); +static void ReadOnePlayer(FSerializer &arc); static void ReadMultiplePlayers(FSerializer &arc, int numPlayers, int numPlayersNow, bool skipload); static void SpawnExtraPlayers(); @@ -594,7 +594,7 @@ void P_SerializePlayers(FSerializer &arc, bool skipload) // first player present, no matter what their name. if (numPlayers == 1) { - ReadOnePlayer(arc, skipload); + ReadOnePlayer(arc); } else { @@ -617,7 +617,7 @@ void P_SerializePlayers(FSerializer &arc, bool skipload) // //========================================================================== -static void ReadOnePlayer(FSerializer &arc, bool skipload) +static void ReadOnePlayer(FSerializer &arc) { int i; const char *name = NULL; @@ -636,10 +636,7 @@ static void ReadOnePlayer(FSerializer &arc, bool skipload) didIt = true; player_t playerTemp; playerTemp.Serialize(arc); - if (!skipload) - { - CopyPlayer(&players[i], &playerTemp, name); - } + CopyPlayer(&players[i], &playerTemp, name); } else {