This commit is contained in:
nashmuhandes 2016-09-25 19:11:06 +08:00
commit 5f9ca7ce21
7 changed files with 57 additions and 33 deletions

View file

@ -61,6 +61,7 @@ void DSectorEffect::Destroy()
}
DSectorEffect::DSectorEffect (sector_t *sector)
: DThinker(STAT_SECTOREFFECT)
{
m_Sector = sector;
}

View file

@ -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();

View file

@ -47,6 +47,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);
@ -57,6 +62,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);

View file

@ -71,6 +71,7 @@
#include "p_spec.h"
#include "p_checkposition.h"
#include "serializer.h"
#include "r_utility.h"
// MACROS ------------------------------------------------------------------
@ -1041,11 +1042,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;
@ -1053,28 +1054,26 @@ bool AActor::IsInsideVisibleAngles() const
angleend = temp;
}
if (pitchstart > angleend)
if (pitchstart > pitchend)
{
DAngle temp = pitchstart;
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))

View file

@ -642,6 +642,11 @@ static void ReadOnePlayer(FSerializer &arc, bool skipload)
{
CopyPlayer(&players[i], &playerTemp, name);
}
else
{
// we need the player actor, so that G_FinishTravel can destroy it later.
players[i].mo = playerTemp.mo;
}
}
else
{
@ -755,6 +760,13 @@ static void ReadMultiplePlayers(FSerializer &arc, int numPlayers, int numPlayers
}
}
}
else
{
for (i = 0; i < MAXPLAYERS; ++i)
{
players[i].mo = playertemp[i].mo;
}
}
delete[] tempPlayerUsed;
delete[] playertemp;

View file

@ -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;
}

View file

@ -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;
}