Merge the boolean args to EV/P_Teleport into a single flags arg

- The flags use TELF_ since DECORATE has an A_Teleport with its
  own set of TF_ flags.
- TELF_KEEPVELOCITY is used instead of TELF_HALTVELOCITY, because
  there was only one call that ever set bHaltVelocity to false.
This commit is contained in:
Randy Heit 2016-01-28 20:36:06 -06:00
parent 939989dc8c
commit c1b2861362
7 changed files with 59 additions and 33 deletions

View file

@ -1082,7 +1082,7 @@ void FParser::SF_Teleport(void)
}
if(mo)
EV_Teleport(0, tag, NULL, 0, mo, true, true, false);
EV_Teleport(0, tag, NULL, 0, mo, TELF_DESTFOG | TELF_SOURCEFOG);
}
}
@ -1111,7 +1111,7 @@ void FParser::SF_SilentTeleport(void)
}
if(mo)
EV_Teleport(0, tag, NULL, 0, mo, false, false, true);
EV_Teleport(0, tag, NULL, 0, mo, TELF_KEEPORIENTATION);
}
}

View file

@ -97,7 +97,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase)
spot = iterator.Next ();
if (spot != NULL)
{
P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->angle, true, true, false);
P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->angle, TELF_SOURCEFOG | TELF_DESTFOG);
}
P_StartScript (self, NULL, 249, NULL, NULL, 0, 0);
@ -136,7 +136,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase)
self->tracer = spot;
if (spot)
{
P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->angle, true, true, false);
P_Teleport (self, spot->X(), spot->Y(), ONFLOORZ, spot->angle, TELF_SOURCEFOG | TELF_DESTFOG);
}
}
}

View file

@ -162,7 +162,7 @@ void P_TeleportToPlayerStarts (AActor *victim)
destX = start->x;
destY = start->y;
destAngle = ANG45 * (start->angle/45);
P_Teleport (victim, destX, destY, ONFLOORZ, destAngle, true, true, false);
P_Teleport (victim, destX, destY, ONFLOORZ, destAngle, TELF_SOURCEFOG | TELF_DESTFOG);
}
//===========================================================================
@ -184,7 +184,7 @@ void P_TeleportToDeathmatchStarts (AActor *victim)
destX = deathmatchstarts[i].x;
destY = deathmatchstarts[i].y;
destAngle = ANG45 * (deathmatchstarts[i].angle/45);
P_Teleport (victim, destX, destY, ONFLOORZ, destAngle, true, true, false);
P_Teleport (victim, destX, destY, ONFLOORZ, destAngle, TELF_SOURCEFOG | TELF_DESTFOG);
}
else
{

View file

@ -43,7 +43,7 @@ bool AArtiTeleport::Use (bool pickup)
destY = start->y;
destAngle = ANG45 * (start->angle/45);
}
P_Teleport (Owner, destX, destY, ONFLOORZ, destAngle, true, true, false);
P_Teleport (Owner, destX, destY, ONFLOORZ, destAngle, TELF_SOURCEFOG | TELF_DESTFOG);
bool canlaugh = true;
if (Owner->player->morphTics && (Owner->player->MorphStyle & MORPH_UNDOBYCHAOSDEVICE))
{ // Teleporting away will undo any morph effects (pig)

View file

@ -880,19 +880,38 @@ FUNC(LS_Teleport_NewMap)
FUNC(LS_Teleport)
// Teleport (tid, sectortag, bNoSourceFog)
{
return EV_Teleport (arg0, arg1, ln, backSide, it, true, !arg2, false);
int flags = TELF_DESTFOG;
if (!arg2)
{
flags |= TELF_SOURCEFOG;
}
return EV_Teleport (arg0, arg1, ln, backSide, it, flags);
}
FUNC( LS_Teleport_NoStop )
// Teleport_NoStop (tid, sectortag, bNoSourceFog)
{
return EV_Teleport( arg0, arg1, ln, backSide, it, true, !arg2, false, false );
int flags = TELF_DESTFOG | TELF_KEEPVELOCITY;
if (!arg2)
{
flags |= TELF_SOURCEFOG;
}
return EV_Teleport( arg0, arg1, ln, backSide, it, flags);
}
FUNC(LS_Teleport_NoFog)
// Teleport_NoFog (tid, useang, sectortag, keepheight)
{
return EV_Teleport (arg0, arg2, ln, backSide, it, false, false, !arg1, true, !!arg3);
int flags = 0;
if (arg1)
{
flags |= TELF_KEEPORIENTATION;
}
if (arg3)
{
flags |= TELF_KEEPHEIGHT;
}
return EV_Teleport (arg0, arg2, ln, backSide, it, flags);
}
FUNC(LS_Teleport_ZombieChanger)
@ -901,7 +920,7 @@ FUNC(LS_Teleport_ZombieChanger)
// This is practically useless outside of Strife, but oh well.
if (it != NULL)
{
EV_Teleport (arg0, arg1, ln, backSide, it, false, false, false);
EV_Teleport (arg0, arg1, ln, backSide, it, 0);
if (it->health >= 0) it->SetState (it->FindState(NAME_Pain));
return true;
}

View file

@ -902,13 +902,22 @@ bool EV_DoChange (line_t *line, EChange changetype, int tag);
//
// P_TELEPT
//
enum
{
TELF_DESTFOG = 1,
TELF_SOURCEFOG = 2,
TELF_KEEPORIENTATION = 4,
TELF_KEEPVELOCITY = 8,
TELF_KEEPHEIGHT = 16,
};
void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool beforeTele = true, bool setTarget = false); //Spawns teleport fog. Pass the actor to pluck TeleFogFromType and TeleFogToType. 'from' determines if this is the fog to spawn at the old position (true) or new (false).
inline void P_SpawnTeleportFog(AActor *mobj, const fixedvec3 &pos, bool beforeTele = true, bool setTarget = false)
{
P_SpawnTeleportFog(mobj, pos.x, pos.y, pos.z, beforeTele, setTarget);
}
bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, bool useFog, bool sourceFog, bool keepOrientation, bool haltVelocity = true, bool keepHeight = false);
bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, bool fog, bool sourceFog, bool keepOrientation, bool haltVelocity = true, bool keepHeight = false);
bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, int flags); // bool useFog, bool sourceFog, bool keepOrientation, bool haltVelocity = true, bool keepHeight = false
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);
bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_tid, bool moveSource, bool fog);

View file

@ -96,8 +96,7 @@ void P_SpawnTeleportFog(AActor *mobj, fixed_t x, fixed_t y, fixed_t z, bool befo
// TELEPORTATION
//
bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
bool useFog, bool sourceFog, bool keepOrientation, bool bHaltVelocity, bool keepHeight)
bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, int flags)
{
bool predicting = (thing->player && (thing->player->cheats & CF_PREDICTING));
@ -123,7 +122,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
{ // We don't measure z velocity, because it doesn't change.
missilespeed = xs_CRoundToInt(TVector2<double>(thing->velx, thing->vely).Length());
}
if (keepHeight)
if (flags & TELF_KEEPHEIGHT)
{
z = floorheight + aboveFloor;
}
@ -142,7 +141,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
else
{
z = floorheight;
if (!keepOrientation)
if (!(flags & TELF_KEEPORIENTATION))
{
resetpitch = false;
}
@ -173,7 +172,7 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
player->mo->pitch = 0;
}
}
if (!keepOrientation)
if (!(flags & TELF_KEEPORIENTATION))
{
thing->angle = angle;
}
@ -182,11 +181,11 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
angle = thing->angle;
}
// Spawn teleport fog at source and destination
if (sourceFog && !predicting)
if ((flags & TELF_SOURCEFOG) && !predicting)
{
P_SpawnTeleportFog(thing, old, true, true); //Passes the actor through which then pulls the TeleFog metadata types based on properties.
}
if (useFog)
if (flags & TELF_DESTFOG)
{
if (!predicting)
{
@ -199,12 +198,12 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
{
// [RH] Zoom player's field of vision
// [BC] && bHaltVelocity.
if (telezoom && thing->player->mo == thing && bHaltVelocity)
if (telezoom && thing->player->mo == thing && !(flags & TELF_KEEPVELOCITY))
thing->player->FOV = MIN (175.f, thing->player->DesiredFOV + 45.f);
}
}
// [BC] && bHaltVelocity.
if (thing->player && (useFog || !keepOrientation) && bHaltVelocity)
if (thing->player && ((flags & TELF_DESTFOG) || !(flags & TELF_KEEPORIENTATION)) && !(flags & TELF_KEEPVELOCITY))
{
// Freeze player for about .5 sec
if (thing->Inventory == NULL || !thing->Inventory->GetNoTeleportFreeze())
@ -217,8 +216,8 @@ bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle,
thing->vely = FixedMul (missilespeed, finesine[angle]);
}
// [BC] && bHaltVelocity.
else if (!keepOrientation && bHaltVelocity) // no fog doesn't alter the player's momentum
{
else if (!(flags & TELF_KEEPORIENTATION) && !(flags & TELF_KEEPVELOCITY))
{ // no fog doesn't alter the player's momentum
thing->velx = thing->vely = thing->velz = 0;
// killough 10/98: kill all bobbing velocity too
if (player)
@ -322,10 +321,8 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom)
return NULL;
}
bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, bool fog,
bool sourceFog, bool keepOrientation, bool haltVelocity, bool keepHeight)
bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags)
{
AActor *searcher;
fixed_t z;
angle_t angle = 0;
@ -352,7 +349,7 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, bool
return false;
}
// [RH] Lee Killough's changes for silent teleporters from BOOM
if (keepOrientation && line)
if ((flags & TELF_KEEPORIENTATION) && line)
{
// Get the angle between the exit thing and source linedef.
// Rotate 90 degrees, so that walking perpendicularly across
@ -382,10 +379,10 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, bool
{
badangle = 1 << ANGLETOFINESHIFT;
}
if (P_Teleport (thing, searcher->X(), searcher->Y(), z, searcher->angle + badangle, fog, sourceFog, keepOrientation, haltVelocity, keepHeight))
if (P_Teleport (thing, searcher->X(), searcher->Y(), z, searcher->angle + badangle, flags))
{
// [RH] Lee Killough's changes for silent teleporters from BOOM
if (!fog && line && keepOrientation)
if (!(flags & TELF_DESTFOG) && line && (flags & TELF_KEEPORIENTATION))
{
// Rotate thing according to difference in angles
thing->angle += angle;
@ -601,7 +598,8 @@ bool EV_TeleportOther (int other_tid, int dest_tid, bool fog)
while ( (victim = iterator.Next ()) )
{
didSomething |= EV_Teleport (dest_tid, 0, NULL, 0, victim, fog, fog, !fog);
didSomething |= EV_Teleport (dest_tid, 0, NULL, 0, victim,
fog ? (TELF_DESTFOG | TELF_SOURCEFOG) : TELF_KEEPORIENTATION);
}
}
@ -621,7 +619,7 @@ static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool fl
P_Teleport (victim, dest->X() + newX,
dest->Y() + newY,
floorz ? ONFLOORZ : dest->Z() + victim->Z() - source->Z(),
0, fog, fog, !fog);
0, fog ? (TELF_DESTFOG | TELF_SOURCEFOG) : TELF_KEEPORIENTATION);
// P_Teleport only changes angle if fog is true
victim->angle = dest->angle + offAngle;
@ -689,7 +687,7 @@ bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_t
{
didSomething |=
P_Teleport (sourceOrigin, destOrigin->X(), destOrigin->Y(),
floorz ? ONFLOORZ : destOrigin->Z(), 0, false, false, true);
floorz ? ONFLOORZ : destOrigin->Z(), 0, TELF_KEEPORIENTATION);
sourceOrigin->angle = destOrigin->angle;
}