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) 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) 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 (); spot = iterator.Next ();
if (spot != NULL) 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); P_StartScript (self, NULL, 249, NULL, NULL, 0, 0);
@ -136,7 +136,7 @@ DEFINE_ACTION_FUNCTION(AActor, A_KoraxChase)
self->tracer = spot; self->tracer = spot;
if (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; destX = start->x;
destY = start->y; destY = start->y;
destAngle = ANG45 * (start->angle/45); 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; destX = deathmatchstarts[i].x;
destY = deathmatchstarts[i].y; destY = deathmatchstarts[i].y;
destAngle = ANG45 * (deathmatchstarts[i].angle/45); 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 else
{ {

View file

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

View file

@ -880,19 +880,38 @@ FUNC(LS_Teleport_NewMap)
FUNC(LS_Teleport) FUNC(LS_Teleport)
// Teleport (tid, sectortag, bNoSourceFog) // 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 ) FUNC( LS_Teleport_NoStop )
// Teleport_NoStop (tid, sectortag, bNoSourceFog) // 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) FUNC(LS_Teleport_NoFog)
// Teleport_NoFog (tid, useang, sectortag, keepheight) // 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) FUNC(LS_Teleport_ZombieChanger)
@ -901,7 +920,7 @@ FUNC(LS_Teleport_ZombieChanger)
// This is practically useless outside of Strife, but oh well. // This is practically useless outside of Strife, but oh well.
if (it != NULL) 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)); if (it->health >= 0) it->SetState (it->FindState(NAME_Pain));
return true; return true;
} }

View file

@ -902,13 +902,22 @@ bool EV_DoChange (line_t *line, EChange changetype, int tag);
// //
// P_TELEPT // 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). 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) 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); 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 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, bool fog, 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_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_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); 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 // TELEPORTATION
// //
bool P_Teleport (AActor *thing, fixed_t x, fixed_t y, fixed_t z, angle_t angle, 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 bHaltVelocity, bool keepHeight)
{ {
bool predicting = (thing->player && (thing->player->cheats & CF_PREDICTING)); 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. { // We don't measure z velocity, because it doesn't change.
missilespeed = xs_CRoundToInt(TVector2<double>(thing->velx, thing->vely).Length()); missilespeed = xs_CRoundToInt(TVector2<double>(thing->velx, thing->vely).Length());
} }
if (keepHeight) if (flags & TELF_KEEPHEIGHT)
{ {
z = floorheight + aboveFloor; 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 else
{ {
z = floorheight; z = floorheight;
if (!keepOrientation) if (!(flags & TELF_KEEPORIENTATION))
{ {
resetpitch = false; 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; player->mo->pitch = 0;
} }
} }
if (!keepOrientation) if (!(flags & TELF_KEEPORIENTATION))
{ {
thing->angle = angle; 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; angle = thing->angle;
} }
// Spawn teleport fog at source and destination // 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. 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) 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 // [RH] Zoom player's field of vision
// [BC] && bHaltVelocity. // [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); thing->player->FOV = MIN (175.f, thing->player->DesiredFOV + 45.f);
} }
} }
// [BC] && bHaltVelocity. // [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 // Freeze player for about .5 sec
if (thing->Inventory == NULL || !thing->Inventory->GetNoTeleportFreeze()) 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]); thing->vely = FixedMul (missilespeed, finesine[angle]);
} }
// [BC] && bHaltVelocity. // [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; thing->velx = thing->vely = thing->velz = 0;
// killough 10/98: kill all bobbing velocity too // killough 10/98: kill all bobbing velocity too
if (player) if (player)
@ -322,10 +321,8 @@ static AActor *SelectTeleDest (int tid, int tag, bool norandom)
return NULL; return NULL;
} }
bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, bool fog, bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags)
bool sourceFog, bool keepOrientation, bool haltVelocity, bool keepHeight)
{ {
AActor *searcher; AActor *searcher;
fixed_t z; fixed_t z;
angle_t angle = 0; 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; return false;
} }
// [RH] Lee Killough's changes for silent teleporters from BOOM // [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. // Get the angle between the exit thing and source linedef.
// Rotate 90 degrees, so that walking perpendicularly across // 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; 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 // [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 // Rotate thing according to difference in angles
thing->angle += angle; thing->angle += angle;
@ -601,7 +598,8 @@ bool EV_TeleportOther (int other_tid, int dest_tid, bool fog)
while ( (victim = iterator.Next ()) ) 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, P_Teleport (victim, dest->X() + newX,
dest->Y() + newY, dest->Y() + newY,
floorz ? ONFLOORZ : dest->Z() + victim->Z() - source->Z(), 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 // P_Teleport only changes angle if fog is true
victim->angle = dest->angle + offAngle; victim->angle = dest->angle + offAngle;
@ -689,7 +687,7 @@ bool EV_TeleportGroup (int group_tid, AActor *victim, int source_tid, int dest_t
{ {
didSomething |= didSomething |=
P_Teleport (sourceOrigin, destOrigin->X(), destOrigin->Y(), 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; sourceOrigin->angle = destOrigin->angle;
} }