- floatification of p_teleport and p_switch.cpp.

This commit is contained in:
Christoph Oelckers 2016-03-29 00:31:59 +02:00
parent 0a238e7e18
commit c776a0fb54
8 changed files with 88 additions and 144 deletions

View file

@ -2203,7 +2203,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
x = ReadWord (stream); x = ReadWord (stream);
y = ReadWord (stream); y = ReadWord (stream);
z = 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; break;

View file

@ -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 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_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); void P_SlideMove (AActor* mo, const DVector2 &pos, int numsteps);
bool P_BounceWall (AActor *mo); bool P_BounceWall (AActor *mo);

View file

@ -453,7 +453,7 @@ static void DoSectorDamage(AActor *actor, sector_t *sec, int amount, FName type,
if (!(flags & DAMAGE_PLAYERS) && actor->player != NULL) if (!(flags & DAMAGE_PLAYERS) && actor->player != NULL)
return; 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; return;
if (protectClass != NULL) if (protectClass != NULL)
@ -490,21 +490,21 @@ void P_SectorDamage(int tag, int amount, FName type, PClassActor *protectClass,
{ {
next = actor->snext; next = actor->snext;
// Only affect actors touching the 3D floor // Only affect actors touching the 3D floor
fixed_t z1 = sec->floorplane.ZatPoint(actor); double z1 = sec->floorplane.ZatPointF(actor);
fixed_t z2 = sec->ceilingplane.ZatPoint(actor); double z2 = sec->ceilingplane.ZatPointF(actor);
if (z2 < z1) if (z2 < z1)
{ {
// Account for Vavoom-style 3D floors // Account for Vavoom-style 3D floors
fixed_t zz = z1; double zz = z1;
z1 = z2; z1 = z2;
z2 = zz; 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 // 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 // damaged (so, anything touching it or above it). Other 3D floors between
// the actor and this one will not stop this effect. // 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 // 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 // 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 // plane: 0=floor, 1=ceiling, 2=both
if (plane > 0) 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<ASkyViewpoint*>(sector->SkyBoxes[sector_t::ceiling])->bAlways) if (sector->SkyBoxes[sector_t::ceiling] == NULL || !barrier_cast<ASkyViewpoint*>(sector->SkyBoxes[sector_t::ceiling])->bAlways)
{ {
sector->SkyBoxes[sector_t::ceiling] = portal; 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); sector->SetAlpha(sector_t::ceiling, alpha);
if (!portal->bAlways) sector->SetTexture(sector_t::ceiling, skyflatnum); 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; 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); sector->SetAlpha(sector_t::floor, alpha);
if (!portal->bAlways) sector->SetTexture(sector_t::floor, skyflatnum); 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; int s;
FSectorTagIterator itr(sectortag); 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; if (plane < 0 || plane > 2 || (linked && plane == 2)) return;
for (int i=0;i<numlines;i++) for (int i=0;i<numlines;i++)
@ -980,7 +980,7 @@ void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha, int linked
DVector3 pos2((lines[i].v1->fX() + lines[i].v2->fX()) / 2, (lines[i].v1->fY() + lines[i].v2->fY()) / 2, 0); DVector3 pos2((lines[i].v1->fX() + 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 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<AStackPoint>(pos1, NO_REPLACE); AStackPoint *anchor = Spawn<AStackPoint>(pos1, NO_REPLACE);
AStackPoint *reference = Spawn<AStackPoint>(pos2, NO_REPLACE); AStackPoint *reference = Spawn<AStackPoint>(pos2, NO_REPLACE);
@ -1012,7 +1012,7 @@ void P_SpawnSkybox(ASkyViewpoint *origin)
if (Sector == NULL) if (Sector == NULL)
{ {
Printf("Sector not initialized for SkyCamCompat\n"); 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) if (Sector)
{ {
@ -1410,7 +1410,7 @@ void P_SpawnSpecials (void)
case Init_Damage: 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]); FSectorTagIterator itr(lines[i].args[0]);
while ((s = itr.Next()) >= 0) while ((s = itr.Next()) >= 0)
{ {

View file

@ -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, DVector3 pos, DAngle angle, int flags);
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);
}
bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, 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_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);

View file

@ -59,7 +59,7 @@ class DActiveButton : public DThinker
DECLARE_CLASS (DActiveButton, DThinker) DECLARE_CLASS (DActiveButton, DThinker)
public: public:
DActiveButton (); 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 Serialize (FArchive &arc);
void Tick (); void Tick ();
@ -71,7 +71,7 @@ public:
FSwitchDef *m_SwitchDef; FSwitchDef *m_SwitchDef;
SDWORD m_Frame; SDWORD m_Frame;
DWORD m_Timer; DWORD m_Timer;
fixed_t m_X, m_Y; // Location of timer sound DVector2 m_Pos;
protected: protected:
bool AdvanceFrame (); 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; DActiveButton *button;
TThinkerIterator<DActiveButton> iterator; TThinkerIterator<DActiveButton> 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; return true;
} }
@ -185,13 +185,12 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *
// Check 3D floors on back side // Check 3D floors on back side
{ {
sector_t * back = line->sidedef[1 - sideno]->sector; 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_EXISTS)) continue;
if (!(rover->flags & FF_UPPERTEXTURE)) 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)) user->Top() < rover->bottom.plane->ZatPoint(check))
continue; 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_EXISTS)) continue;
if (!(rover->flags & FF_LOWERTEXTURE)) 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)) user->Top() < rover->bottom.plane->ZatPoint(check))
continue; continue;
@ -230,12 +229,12 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *
// to keep compatibility with Eternity's implementation. // to keep compatibility with Eternity's implementation.
if (!P_GetMidTexturePosition(line, sideno, &checktop, &checkbot)) if (!P_GetMidTexturePosition(line, sideno, &checktop, &checkbot))
return false; return false;
return user->Z() < checktop && user->Top() > checkbot; return user->isBelow(checktop) && user->Top() > checkbot;
} }
else else
{ {
// no switch found. Check whether the player can touch either top or bottom texture // 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 // which wasn't necessarily anywhere near the switch if it was
// facing a big sector (and which wasn't necessarily for the // facing a big sector (and which wasn't necessarily for the
// button just activated, either). // button just activated, either).
fixed_t pt[2]; DVector2 pt(side->linedef->v1->fPos() + side->linedef->Delta() / 2);
line_t *line = side->linedef;
bool playsound; 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); side->SetTexture(texture, Switch->frames[0].Texture);
if (useAgain || Switch->NumFrames > 1) 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 else
{ {
@ -309,7 +305,7 @@ bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *ques
} }
if (playsound) 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) if (quest != NULL)
{ {
@ -332,20 +328,18 @@ DActiveButton::DActiveButton ()
m_Part = -1; m_Part = -1;
m_SwitchDef = 0; m_SwitchDef = 0;
m_Timer = 0; m_Timer = 0;
m_X = 0; m_Pos = { 0,0 };
m_Y = 0;
bFlippable = false; bFlippable = false;
bReturning = false; bReturning = false;
m_Frame = 0; m_Frame = 0;
} }
DActiveButton::DActiveButton (side_t *side, int Where, FSwitchDef *Switch, 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_Side = side;
m_Part = SBYTE(Where); m_Part = SBYTE(Where);
m_X = x; m_Pos = pos;
m_Y = y;
bFlippable = useagain; bFlippable = useagain;
bReturning = false; bReturning = false;
@ -363,7 +357,7 @@ DActiveButton::DActiveButton (side_t *side, int Where, FSwitchDef *Switch,
void DActiveButton::Serialize (FArchive &arc) void DActiveButton::Serialize (FArchive &arc)
{ {
Super::Serialize (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) if (def != NULL)
{ {
m_Frame = -1; 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"), def->Sound != 0 ? FSoundID(def->Sound) : FSoundID("switches/normbutn"),
1, ATTN_STATIC); 1, ATTN_STATIC);
bFlippable = false; bFlippable = false;

View file

@ -99,50 +99,50 @@ void P_SpawnTeleportFog(AActor *mobj, const DVector3 &pos, bool beforeTele, bool
// TELEPORTATION // 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)); bool predicting = (thing->player && (thing->player->cheats & CF_PREDICTING));
DVector3 old; DVector3 old;
fixed_t aboveFloor; double aboveFloor;
player_t *player; player_t *player;
sector_t *destsect; sector_t *destsect;
bool resetpitch = false; bool resetpitch = false;
fixed_t floorheight, ceilingheight; double floorheight, ceilingheight;
double missilespeed = 0; double missilespeed = 0;
old = thing->Pos(); old = thing->Pos();
aboveFloor = thing->_f_Z() - thing->_f_floorz(); aboveFloor = thing->Z() - thing->floorz;
destsect = P_PointInSector (x, y); destsect = P_PointInSector (pos);
// killough 5/12/98: exclude voodoo dolls: // killough 5/12/98: exclude voodoo dolls:
player = thing->player; player = thing->player;
if (player && player->mo != thing) if (player && player->mo != thing)
player = NULL; player = NULL;
floorheight = destsect->floorplane.ZatPoint (x, y); floorheight = destsect->floorplane.ZatPoint (pos);
ceilingheight = destsect->ceilingplane.ZatPoint (x, y); ceilingheight = destsect->ceilingplane.ZatPoint (pos);
if (thing->flags & MF_MISSILE) if (thing->flags & MF_MISSILE)
{ // We don't measure z velocity, because it doesn't change. { // We don't measure z velocity, because it doesn't change.
missilespeed = thing->VelXYToSpeed(); missilespeed = thing->VelXYToSpeed();
} }
if (flags & TELF_KEEPHEIGHT) if (flags & TELF_KEEPHEIGHT)
{ {
z = floorheight + aboveFloor; pos.Z = floorheight + aboveFloor;
} }
else if (z == ONFLOORZ) else if (pos.Z == ONFLOORZ)
{ {
if (player) if (player)
{ {
if (thing->flags & MF_NOGRAVITY && aboveFloor) if (thing->flags & MF_NOGRAVITY && aboveFloor)
{ {
z = floorheight + aboveFloor; pos.Z = floorheight + aboveFloor;
if (z + thing->_f_height() > ceilingheight) if (pos.Z + thing->Height > ceilingheight)
{ {
z = ceilingheight - thing->_f_height(); pos.Z = ceilingheight - thing->Height;
} }
} }
else else
{ {
z = floorheight; pos.Z = floorheight;
if (!(flags & TELF_KEEPORIENTATION)) if (!(flags & TELF_KEEPORIENTATION))
{ {
resetpitch = false; 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) else if (thing->flags & MF_MISSILE)
{ {
z = floorheight + aboveFloor; pos.Z = floorheight + aboveFloor;
if (z + thing->_f_height() > ceilingheight) if (pos.Z + thing->Height > ceilingheight)
{ {
z = ceilingheight - thing->_f_height(); pos.Z = ceilingheight - thing->Height;
} }
} }
else else
{ {
z = floorheight; pos.Z = floorheight;
} }
} }
if (!P_TeleportMove (thing, x, y, z, false)) if (!P_TeleportMove (thing, pos, false))
{ {
return 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; double fogDelta = thing->flags & MF_MISSILE ? 0 : TELEFOGHEIGHT;
DVector2 vector = angle.ToVector(20); 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); 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) bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags)
{ {
AActor *searcher; AActor *searcher;
fixed_t z; double z;
DAngle angle = 0.; DAngle angle = 0.;
double s = 0, c = 0; double s = 0, c = 0;
double vx = 0, vy = 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; vx = thing->Vel.X;
vy = thing->Vel.Y; vy = thing->Vel.Y;
z = searcher->_f_Z(); z = searcher->Z();
} }
else if (searcher->IsKindOf (PClass::FindClass(NAME_TeleportDest2))) else if (searcher->IsKindOf (PClass::FindClass(NAME_TeleportDest2)))
{ {
z = searcher->_f_Z(); z = searcher->Z();
} }
else else
{ {
@ -379,7 +379,7 @@ bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int f
{ {
badangle = 0.01; 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 // [RH] Lee Killough's changes for silent teleporters from BOOM
if (!(flags & TELF_DESTFOG) && line && (flags & TELF_KEEPORIENTATION)) 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; thing->player : NULL;
// Whether walking towards first side of exit linedef steps down // Whether walking towards first side of exit linedef steps down
fixed_t x = FLOAT2FIXED(p.X); bool stepdown = l->frontsector->floorplane.ZatPoint(p) < l->backsector->floorplane.ZatPoint(p);
fixed_t y = FLOAT2FIXED(p.Y);
bool stepdown = l->frontsector->floorplane.ZatPoint(x, y) < l->backsector->floorplane.ZatPoint(x, y);
// Height of thing above ground // 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. // 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 // Exiting on side 1 slightly improves player viewing
// when going down a step on a non-reversed teleporter. // 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 side = reverse || (player && stepdown);
int fudge = FUDGEFACTOR; int fudge = FUDGEFACTOR;
double dx = line->Delta().X;
double dy = line->Delta().Y;
// Make sure we are on correct side of exit linedef. // 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)) if (fabs(dx) > fabs(dy))
y -= (l->dx < 0) != side ? -1 : 1; p.Y -= (dx < 0) != side ? -1 : 1;
else 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. // Adjust z position to be same height above ground as before.
// Ground level at the exit is measured as the higher of the // Ground level at the exit is measured as the higher of the
// two floor heights at the exit linedef. // 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 // Attempt to teleport, aborting if blocked
if (!P_TeleportMove (thing, x, y, z, false)) if (!P_TeleportMove (thing, DVector3(p, z), false))
{ {
return 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 // Rotate thing's orientation according to difference in linedef angles
thing->Angles.Yaw += angle; 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 // 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.X = p.X*c - p.Y*s;
thing->Vel.Y = p.Y*c + p.X*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) static bool DoGroupForOne (AActor *victim, AActor *source, AActor *dest, bool floorz, bool fog)
{ {
int an = (dest->_f_angle() - source->_f_angle()) >> ANGLETOFINESHIFT; DAngle an = dest->Angles.Yaw - source->Angles.Yaw;
fixed_t offX = victim->_f_X() - source->_f_X(); DVector2 off = victim->Pos() - source->Pos();
fixed_t offY = victim->_f_Y() - source->_f_Y(); DAngle offAngle = victim->Angles.Yaw - source->Angles.Yaw;
fixed_t newX = DMulScale16 (offX, finecosine[an], -offY, finesine[an]); DVector2 newp = { off.X * an.Cos() - off.Y * an.Sin(), off.X * an.Sin() + off.Y * an.Cos() };
fixed_t newY = DMulScale16 (offX, finesine[an], offY, finecosine[an]); double z = floorz ? ONFLOORZ : dest->Z() + victim->Z() - source->Z();
bool res = bool res =
P_Teleport (victim, dest->_f_X() + newX, P_Teleport (victim, DVector3(dest->Pos().XY() + newp, z),
dest->_f_Y() + newY,
floorz ? ONFLOORZ : dest->_f_Z() + victim->_f_Z() - source->_f_Z(),
0., fog ? (TELF_DESTFOG | TELF_SOURCEFOG) : TELF_KEEPORIENTATION); 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->Angles.Yaw = (dest->Angles.Yaw + victim->Angles.Yaw - source->Angles.Yaw).Normalized360(); 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; 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 // [RH] Teleport a group of actors centered around source_tid so
// that they become centered around dest_tid instead. // 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) 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) if (moveSource && didSomething)
{ {
didSomething |= didSomething |=
P_Teleport (sourceOrigin, destOrigin->_f_X(), destOrigin->_f_Y(), P_Teleport (sourceOrigin, destOrigin->PosAtZ(floorz ? ONFLOORZ : destOrigin->Z()), 0., TELF_KEEPORIENTATION);
floorz ? ONFLOORZ : destOrigin->_f_Z(), 0., TELF_KEEPORIENTATION);
sourceOrigin->Angles.Yaw = destOrigin->Angles.Yaw; 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; 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; return didSomething;
} }

View file

@ -89,7 +89,6 @@ enum ETerrainKeywords
enum EGenericType enum EGenericType
{ {
GEN_End, GEN_End,
GEN_Fixed,
GEN_Sound, GEN_Sound,
GEN_Byte, GEN_Byte,
GEN_Class, GEN_Class,
@ -534,11 +533,6 @@ static void GenericParse (FScanner &sc, FGenericParse *parser, const char **keyw
notdone = false; notdone = false;
break; break;
case GEN_Fixed:
sc.MustGetFloat ();
SET_FIELD (fixed_t, (fixed_t)(FRACUNIT * sc.Float));
break;
case GEN_Sound: case GEN_Sound:
sc.MustGetString (); sc.MustGetString ();
SET_FIELD (FSoundID, FSoundID(sc.String)); SET_FIELD (FSoundID, FSoundID(sc.String));

View file

@ -767,12 +767,22 @@ struct sector_t
planes[pos].alpha = o; planes[pos].alpha = o;
} }
void SetAlpha(int pos, double o)
{
planes[pos].alpha = FLOAT2FIXED(o);
}
fixed_t GetAlpha(int pos) const fixed_t GetAlpha(int pos) const
{ {
return planes[pos].alpha; 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; return planes[pos].Flags;
} }