Skip to content

Commit c776a0f

Browse files
author
Christoph Oelckers
committed
- floatification of p_teleport and p_switch.cpp.
1 parent 0a238e7 commit c776a0f

8 files changed

+88
-144
lines changed

src/d_net.cpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -2203,7 +2203,7 @@ void Net_DoCommand (int type, BYTE **stream, int player)
22032203
x = ReadWord (stream);
22042204
y = ReadWord (stream);
22052205
z = ReadWord (stream);
2206-
P_TeleportMove (players[player].mo, x * 65536, y * 65536, z * 65536, true);
2206+
P_TeleportMove (players[player].mo, DVector3(x, y, z), true);
22072207
}
22082208
break;
22092209

src/p_local.h

-9
Original file line numberDiff line numberDiff line change
@@ -259,15 +259,6 @@ void P_ApplyTorque(AActor *mo);
259259

260260
bool P_TeleportMove(AActor* thing, const DVector3 &pos, bool telefrag, bool modifyactor = true); // [RH] Added z and telefrag parameters
261261

262-
inline bool P_TeleportMove (AActor* thing, fixed_t x, fixed_t y, fixed_t z, bool telefrag, bool modifyactor = true)
263-
{
264-
return P_TeleportMove(thing, DVector3(FIXED2DBL(x), FIXED2DBL(y), FIXED2DBL(z)), telefrag, modifyactor);
265-
}
266-
inline bool P_TeleportMove(AActor* thing, const fixedvec3 &pos, bool telefrag, bool modifyactor = true)
267-
{
268-
return P_TeleportMove(thing, DVector3(FIXED2DBL(pos.x), FIXED2DBL(pos.y), FIXED2DBL(pos.z)), telefrag, modifyactor);
269-
}
270-
271262
void P_PlayerStartStomp (AActor *actor, bool mononly=false); // [RH] Stomp on things for a newly spawned player
272263
void P_SlideMove (AActor* mo, const DVector2 &pos, int numsteps);
273264
bool P_BounceWall (AActor *mo);

src/p_spec.cpp

+14-14
Original file line numberDiff line numberDiff line change
@@ -453,7 +453,7 @@ static void DoSectorDamage(AActor *actor, sector_t *sec, int amount, FName type,
453453
if (!(flags & DAMAGE_PLAYERS) && actor->player != NULL)
454454
return;
455455

456-
if (!(flags & DAMAGE_IN_AIR) && actor->_f_Z() != sec->floorplane.ZatPoint(actor) && !actor->waterlevel)
456+
if (!(flags & DAMAGE_IN_AIR) && !actor->isAtZ(sec->floorplane.ZatPointF(actor)) && !actor->waterlevel)
457457
return;
458458

459459
if (protectClass != NULL)
@@ -490,21 +490,21 @@ void P_SectorDamage(int tag, int amount, FName type, PClassActor *protectClass,
490490
{
491491
next = actor->snext;
492492
// Only affect actors touching the 3D floor
493-
fixed_t z1 = sec->floorplane.ZatPoint(actor);
494-
fixed_t z2 = sec->ceilingplane.ZatPoint(actor);
493+
double z1 = sec->floorplane.ZatPointF(actor);
494+
double z2 = sec->ceilingplane.ZatPointF(actor);
495495
if (z2 < z1)
496496
{
497497
// Account for Vavoom-style 3D floors
498-
fixed_t zz = z1;
498+
double zz = z1;
499499
z1 = z2;
500500
z2 = zz;
501501
}
502-
if (actor->_f_Z() + actor->_f_height() > z1)
502+
if (actor->Top() > z1)
503503
{
504504
// If DAMAGE_IN_AIR is used, anything not beneath the 3D floor will be
505505
// damaged (so, anything touching it or above it). Other 3D floors between
506506
// the actor and this one will not stop this effect.
507-
if ((flags & DAMAGE_IN_AIR) || actor->_f_Z() <= z2)
507+
if ((flags & DAMAGE_IN_AIR) || !actor->isAbove(z2))
508508
{
509509
// Here we pass the DAMAGE_IN_AIR flag to disable the floor check, since it
510510
// only works with the real sector's floor. We did the appropriate height checks
@@ -901,15 +901,15 @@ void P_SetupPortals()
901901
}
902902
}
903903

904-
static void SetPortal(sector_t *sector, int plane, ASkyViewpoint *portal, fixed_t alpha)
904+
static void SetPortal(sector_t *sector, int plane, ASkyViewpoint *portal, double alpha)
905905
{
906906
// plane: 0=floor, 1=ceiling, 2=both
907907
if (plane > 0)
908908
{
909909
if (sector->SkyBoxes[sector_t::ceiling] == NULL || !barrier_cast<ASkyViewpoint*>(sector->SkyBoxes[sector_t::ceiling])->bAlways)
910910
{
911911
sector->SkyBoxes[sector_t::ceiling] = portal;
912-
if (sector->GetAlpha(sector_t::ceiling) == OPAQUE)
912+
if (sector->GetAlphaF(sector_t::ceiling) == 1.)
913913
sector->SetAlpha(sector_t::ceiling, alpha);
914914

915915
if (!portal->bAlways) sector->SetTexture(sector_t::ceiling, skyflatnum);
@@ -921,14 +921,14 @@ static void SetPortal(sector_t *sector, int plane, ASkyViewpoint *portal, fixed_
921921
{
922922
sector->SkyBoxes[sector_t::floor] = portal;
923923
}
924-
if (sector->GetAlpha(sector_t::floor) == OPAQUE)
924+
if (sector->GetAlphaF(sector_t::floor) == 1.)
925925
sector->SetAlpha(sector_t::floor, alpha);
926926

927927
if (!portal->bAlways) sector->SetTexture(sector_t::floor, skyflatnum);
928928
}
929929
}
930930

931-
static void CopyPortal(int sectortag, int plane, ASkyViewpoint *origin, fixed_t alpha, bool tolines)
931+
static void CopyPortal(int sectortag, int plane, ASkyViewpoint *origin, double alpha, bool tolines)
932932
{
933933
int s;
934934
FSectorTagIterator itr(sectortag);
@@ -962,7 +962,7 @@ static void CopyPortal(int sectortag, int plane, ASkyViewpoint *origin, fixed_t
962962
}
963963
}
964964

965-
void P_SpawnPortal(line_t *line, int sectortag, int plane, int alpha, int linked)
965+
void P_SpawnPortal(line_t *line, int sectortag, int plane, int bytealpha, int linked)
966966
{
967967
if (plane < 0 || plane > 2 || (linked && plane == 2)) return;
968968
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
980980
DVector3 pos2((lines[i].v1->fX() + lines[i].v2->fX()) / 2, (lines[i].v1->fY() + lines[i].v2->fY()) / 2, 0);
981981
double z = linked ? line->frontsector->GetPlaneTexZF(plane) : 0; // the map's sector height defines the portal plane for linked portals
982982

983-
fixed_t alpha = Scale (lines[i].args[4], OPAQUE, 255);
983+
double alpha = bytealpha / 255.;
984984

985985
AStackPoint *anchor = Spawn<AStackPoint>(pos1, NO_REPLACE);
986986
AStackPoint *reference = Spawn<AStackPoint>(pos2, NO_REPLACE);
@@ -1012,7 +1012,7 @@ void P_SpawnSkybox(ASkyViewpoint *origin)
10121012
if (Sector == NULL)
10131013
{
10141014
Printf("Sector not initialized for SkyCamCompat\n");
1015-
origin->Sector = Sector = P_PointInSector(origin->_f_X(), origin->_f_Y());
1015+
origin->Sector = Sector = P_PointInSector(origin->Pos());
10161016
}
10171017
if (Sector)
10181018
{
@@ -1410,7 +1410,7 @@ void P_SpawnSpecials (void)
14101410

14111411
case Init_Damage:
14121412
{
1413-
int damage = P_AproxDistance (lines[i].dx, lines[i].dy) >> FRACBITS;
1413+
int damage = int(lines[i].Delta().Length());
14141414
FSectorTagIterator itr(lines[i].args[0]);
14151415
while ((s = itr.Next()) >= 0)
14161416
{

src/p_spec.h

+1-5
Original file line numberDiff line numberDiff line change
@@ -878,11 +878,7 @@ inline void P_SpawnTeleportFog(AActor *mobj, double x, double y, double z, bool
878878
}
879879
*/
880880

881-
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
882-
inline bool P_Teleport(AActor *thing, const DVector3 &pos, DAngle angle, int flags)
883-
{
884-
return P_Teleport(thing, FLOAT2FIXED(pos.X), FLOAT2FIXED(pos.Y), FLOAT2FIXED(pos.Z), angle, flags);
885-
}
881+
inline bool P_Teleport(AActor *thing, DVector3 pos, DAngle angle, int flags);
886882
bool EV_Teleport (int tid, int tag, line_t *line, int side, AActor *thing, int flags);
887883
bool EV_SilentLineTeleport (line_t *line, int side, AActor *thing, int id, INTBOOL reverse);
888884
bool EV_TeleportOther (int other_tid, int dest_tid, bool fog);

src/p_switch.cpp

+17-23
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ class DActiveButton : public DThinker
5959
DECLARE_CLASS (DActiveButton, DThinker)
6060
public:
6161
DActiveButton ();
62-
DActiveButton (side_t *, int, FSwitchDef *, fixed_t x, fixed_t y, bool flippable);
62+
DActiveButton (side_t *, int, FSwitchDef *, const DVector2 &pos, bool flippable);
6363

6464
void Serialize (FArchive &arc);
6565
void Tick ();
@@ -71,7 +71,7 @@ class DActiveButton : public DThinker
7171
FSwitchDef *m_SwitchDef;
7272
SDWORD m_Frame;
7373
DWORD m_Timer;
74-
fixed_t m_X, m_Y; // Location of timer sound
74+
DVector2 m_Pos;
7575

7676
protected:
7777
bool AdvanceFrame ();
@@ -85,7 +85,7 @@ class DActiveButton : public DThinker
8585
//
8686
//==========================================================================
8787

88-
static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, fixed_t x, fixed_t y, bool useagain)
88+
static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, const DVector2 &pos, bool useagain)
8989
{
9090
DActiveButton *button;
9191
TThinkerIterator<DActiveButton> iterator;
@@ -100,7 +100,7 @@ static bool P_StartButton (side_t *side, int Where, FSwitchDef *Switch, fixed_t
100100
}
101101
}
102102

103-
new DActiveButton (side, Where, Switch, x, y, useagain);
103+
new DActiveButton (side, Where, Switch, pos, useagain);
104104
return true;
105105
}
106106

@@ -185,13 +185,12 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *
185185
// Check 3D floors on back side
186186
{
187187
sector_t * back = line->sidedef[1 - sideno]->sector;
188-
for (unsigned i = 0; i < back->e->XFloor.ffloors.Size(); i++)
188+
for (auto rover : back->e->XFloor.ffloors)
189189
{
190-
F3DFloor *rover = back->e->XFloor.ffloors[i];
191190
if (!(rover->flags & FF_EXISTS)) continue;
192191
if (!(rover->flags & FF_UPPERTEXTURE)) continue;
193192

194-
if (user->Z() > rover->top.plane->ZatPoint(check) ||
193+
if (user->isAbove(rover->top.plane->ZatPoint(check)) ||
195194
user->Top() < rover->bottom.plane->ZatPoint(check))
196195
continue;
197196

@@ -213,7 +212,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *
213212
if (!(rover->flags & FF_EXISTS)) continue;
214213
if (!(rover->flags & FF_LOWERTEXTURE)) continue;
215214

216-
if (user->Z() > rover->top.plane->ZatPoint(check) ||
215+
if (user->isAbove(rover->top.plane->ZatPoint(check)) ||
217216
user->Top() < rover->bottom.plane->ZatPoint(check))
218217
continue;
219218

@@ -230,12 +229,12 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno, const DVector3 *
230229
// to keep compatibility with Eternity's implementation.
231230
if (!P_GetMidTexturePosition(line, sideno, &checktop, &checkbot))
232231
return false;
233-
return user->Z() < checktop && user->Top() > checkbot;
232+
return user->isBelow(checktop) && user->Top() > checkbot;
234233
}
235234
else
236235
{
237236
// no switch found. Check whether the player can touch either top or bottom texture
238-
return (user->Top() > open.top) || (user->Z() < open.bottom);
237+
return (user->Top() > open.top) || (user->isBelow(open.bottom));
239238
}
240239
}
241240

@@ -292,24 +291,21 @@ bool P_ChangeSwitchTexture (side_t *side, int useAgain, BYTE special, bool *ques
292291
// which wasn't necessarily anywhere near the switch if it was
293292
// facing a big sector (and which wasn't necessarily for the
294293
// button just activated, either).
295-
fixed_t pt[2];
296-
line_t *line = side->linedef;
294+
DVector2 pt(side->linedef->v1->fPos() + side->linedef->Delta() / 2);
297295
bool playsound;
298296

299-
pt[0] = line->v1->x + (line->dx >> 1);
300-
pt[1] = line->v1->y + (line->dy >> 1);
301297
side->SetTexture(texture, Switch->frames[0].Texture);
302298
if (useAgain || Switch->NumFrames > 1)
303299
{
304-
playsound = P_StartButton (side, texture, Switch, pt[0], pt[1], !!useAgain);
300+
playsound = P_StartButton (side, texture, Switch, pt, !!useAgain);
305301
}
306302
else
307303
{
308304
playsound = true;
309305
}
310306
if (playsound)
311307
{
312-
S_Sound (DVector3(FIXED2DBL(pt[0]), FIXED2DBL(pt[1]), 0), CHAN_VOICE|CHAN_LISTENERZ, sound, 1, ATTN_STATIC);
308+
S_Sound (DVector3(pt, 0), CHAN_VOICE|CHAN_LISTENERZ, sound, 1, ATTN_STATIC);
313309
}
314310
if (quest != NULL)
315311
{
@@ -332,20 +328,18 @@ DActiveButton::DActiveButton ()
332328
m_Part = -1;
333329
m_SwitchDef = 0;
334330
m_Timer = 0;
335-
m_X = 0;
336-
m_Y = 0;
331+
m_Pos = { 0,0 };
337332
bFlippable = false;
338333
bReturning = false;
339334
m_Frame = 0;
340335
}
341336

342337
DActiveButton::DActiveButton (side_t *side, int Where, FSwitchDef *Switch,
343-
fixed_t x, fixed_t y, bool useagain)
338+
const DVector2 &pos, bool useagain)
344339
{
345340
m_Side = side;
346341
m_Part = SBYTE(Where);
347-
m_X = x;
348-
m_Y = y;
342+
m_Pos = pos;
349343
bFlippable = useagain;
350344
bReturning = false;
351345

@@ -363,7 +357,7 @@ DActiveButton::DActiveButton (side_t *side, int Where, FSwitchDef *Switch,
363357
void DActiveButton::Serialize (FArchive &arc)
364358
{
365359
Super::Serialize (arc);
366-
arc << m_Side << m_Part << m_SwitchDef << m_Frame << m_Timer << bFlippable << m_X << m_Y << bReturning;
360+
arc << m_Side << m_Part << m_SwitchDef << m_Frame << m_Timer << bFlippable << m_Pos << bReturning;
367361
}
368362

369363
//==========================================================================
@@ -391,7 +385,7 @@ void DActiveButton::Tick ()
391385
if (def != NULL)
392386
{
393387
m_Frame = -1;
394-
S_Sound (DVector3(FIXED2DBL(m_X), FIXED2DBL(m_Y), 0), CHAN_VOICE|CHAN_LISTENERZ,
388+
S_Sound (DVector3(m_Pos, 0), CHAN_VOICE|CHAN_LISTENERZ,
395389
def->Sound != 0 ? FSoundID(def->Sound) : FSoundID("switches/normbutn"),
396390
1, ATTN_STATIC);
397391
bFlippable = false;

0 commit comments

Comments
 (0)