From 13e25faea7da696b3bfb7794bf051bd217dda6b9 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 20 Jan 2016 14:20:14 +0100 Subject: [PATCH] - p_sight.cpp, p_spec.cpp and p_switch.cpp refactored. --- src/p_sight.cpp | 32 ++++++++++++++++---------------- src/p_spec.cpp | 20 ++++++++++---------- src/p_switch.cpp | 25 +++++++++++++------------ 3 files changed, 39 insertions(+), 38 deletions(-) diff --git a/src/p_sight.cpp b/src/p_sight.cpp index 2d465aab5..259b3baa8 100644 --- a/src/p_sight.cpp +++ b/src/p_sight.cpp @@ -68,11 +68,11 @@ public: SightCheck(const AActor * t1, const AActor * t2, int flags) { - lastztop = lastzbottom = sightzstart = t1->z + t1->height - (t1->height>>2); + lastztop = lastzbottom = sightzstart = t1->Z() + t1->height - (t1->height>>2); lastsector = t1->Sector; sightthing=t1; seeingthing=t2; - bottomslope = t2->z - sightzstart; + bottomslope = t2->Z() - sightzstart; topslope = bottomslope + t2->height; Flags = flags; @@ -132,7 +132,7 @@ bool SightCheck::PTR_SightTraverse (intercept_t *in) { int frontflag; - frontflag = P_PointOnLineSidePrecise(sightthing->x, sightthing->y, li); + frontflag = P_PointOnLineSidePrecise(sightthing->X(), sightthing->Y(), li); //Check 3D FLOORS! for(int i=1;i<=2;i++) @@ -413,8 +413,8 @@ bool SightCheck::P_SightTraverseIntercepts () if((rover->flags & FF_SOLID) == myseethrough || !(rover->flags & FF_EXISTS)) continue; if ((Flags & SF_IGNOREWATERBOUNDARY) && (rover->flags & FF_SOLID) == 0) continue; - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(seeingthing->x, seeingthing->y); - fixed_t ff_top=rover->top.plane->ZatPoint(seeingthing->x, seeingthing->y); + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(seeingthing); + fixed_t ff_top=rover->top.plane->ZatPoint(seeingthing); if (lastztop<=ff_bottom && topz>ff_bottom && lastzbottom<=ff_bottom && bottomz>ff_bottom) return false; if (lastzbottom>=ff_top && bottomz=ff_top && topzflags & FF_EXISTS)) continue; - fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sightthing->x, sightthing->y); - fixed_t ff_top=rover->top.plane->ZatPoint(sightthing->x, sightthing->y); + fixed_t ff_bottom=rover->bottom.plane->ZatPoint(sightthing); + fixed_t ff_top=rover->top.plane->ZatPoint(sightthing); if (sightzstart < ff_top && sightzstart >= ff_bottom) { @@ -691,16 +691,16 @@ sightcounts[0]++; if (!(flags & SF_IGNOREWATERBOUNDARY)) { if ((s1->GetHeightSec() && - ((t1->z + t1->height <= s1->heightsec->floorplane.ZatPoint (t1->x, t1->y) && - t2->z >= s1->heightsec->floorplane.ZatPoint (t2->x, t2->y)) || - (t1->z >= s1->heightsec->ceilingplane.ZatPoint (t1->x, t1->y) && - t2->z + t1->height <= s1->heightsec->ceilingplane.ZatPoint (t2->x, t2->y)))) + ((t1->Z() + t1->height <= s1->heightsec->floorplane.ZatPoint(t1) && + t2->Z() >= s1->heightsec->floorplane.ZatPoint(t2)) || + (t1->Z() >= s1->heightsec->ceilingplane.ZatPoint(t1) && + t2->Z() + t1->height <= s1->heightsec->ceilingplane.ZatPoint(t2)))) || (s2->GetHeightSec() && - ((t2->z + t2->height <= s2->heightsec->floorplane.ZatPoint (t2->x, t2->y) && - t1->z >= s2->heightsec->floorplane.ZatPoint (t1->x, t1->y)) || - (t2->z >= s2->heightsec->ceilingplane.ZatPoint (t2->x, t2->y) && - t1->z + t2->height <= s2->heightsec->ceilingplane.ZatPoint (t1->x, t1->y))))) + ((t2->Z() + t2->height <= s2->heightsec->floorplane.ZatPoint(t2) && + t1->Z() >= s2->heightsec->floorplane.ZatPoint(t1)) || + (t2->Z() >= s2->heightsec->ceilingplane.ZatPoint(t2) && + t1->Z() + t2->height <= s2->heightsec->ceilingplane.ZatPoint(t1))))) { res = false; goto done; @@ -713,7 +713,7 @@ sightcounts[0]++; validcount++; { SightCheck s(t1, t2, flags); - res = s.P_SightPathTraverse (t1->x, t1->y, t2->x, t2->y); + res = s.P_SightPathTraverse (t1->X(), t1->Y(), t2->X(), t2->Y()); } done: diff --git a/src/p_spec.cpp b/src/p_spec.cpp index baec6d9e1..523295642 100644 --- a/src/p_spec.cpp +++ b/src/p_spec.cpp @@ -430,7 +430,7 @@ void P_PlayerInSpecialSector (player_t *player, sector_t * sector) { // Falling, not all the way down yet? sector = player->mo->Sector; - if (player->mo->z != sector->floorplane.ZatPoint(player->mo) + if (player->mo->Z() != sector->floorplane.ZatPoint(player->mo) && !player->mo->waterlevel) { return; @@ -507,7 +507,7 @@ static void DoSectorDamage(AActor *actor, sector_t *sec, int amount, FName type, if (!(flags & DAMAGE_PLAYERS) && actor->player != NULL) return; - if (!(flags & DAMAGE_IN_AIR) && actor->z != sec->floorplane.ZatPoint(actor) && !actor->waterlevel) + if (!(flags & DAMAGE_IN_AIR) && actor->Z() != sec->floorplane.ZatPoint(actor) && !actor->waterlevel) return; if (protectClass != NULL) @@ -553,12 +553,12 @@ void P_SectorDamage(int tag, int amount, FName type, const PClass *protectClass, z1 = z2; z2 = zz; } - if (actor->z + actor->height > z1) + if (actor->Z() + actor->height > z1) { // 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 // the actor and this one will not stop this effect. - if ((flags & DAMAGE_IN_AIR) || actor->z <= z2) + if ((flags & DAMAGE_IN_AIR) || actor->Z() <= z2) { // 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 @@ -1058,7 +1058,7 @@ void P_SpawnSkybox(ASkyViewpoint *origin) if (Sector == NULL) { Printf("Sector not initialized for SkyCamCompat\n"); - origin->Sector = Sector = P_PointInSector(origin->x, origin->y); + origin->Sector = Sector = P_PointInSector(origin->X(), origin->Y()); } if (Sector) { @@ -2152,8 +2152,8 @@ DPusher::DPusher (DPusher::EPusher type, line_t *l, int magnitude, int angle, if (source) // point source exist? { m_Radius = (m_Magnitude) << (FRACBITS+1); // where force goes to zero - m_X = m_Source->x; - m_Y = m_Source->y; + m_X = m_Source->X(); + m_Y = m_Source->Y(); } m_Affectee = affectee; } @@ -2268,7 +2268,7 @@ void DPusher::Tick () { if (hsec == NULL) { // NOT special water sector - if (thing->z > thing->floorz) // above ground + if (thing->Z() > thing->floorz) // above ground { xspeed = m_Xmag; // full force yspeed = m_Ymag; @@ -2282,7 +2282,7 @@ void DPusher::Tick () else // special water sector { ht = hsec->floorplane.ZatPoint(thing); - if (thing->z > ht) // above ground + if (thing->Z() > ht) // above ground { xspeed = m_Xmag; // full force yspeed = m_Ymag; @@ -2310,7 +2310,7 @@ void DPusher::Tick () { // special water sector floor = &hsec->floorplane; } - if (thing->z > floor->ZatPoint(thing)) + if (thing->Z() > floor->ZatPoint(thing)) { // above ground xspeed = yspeed = 0; // no force } diff --git a/src/p_switch.cpp b/src/p_switch.cpp index 984794c8a..1ae0c43ea 100644 --- a/src/p_switch.cpp +++ b/src/p_switch.cpp @@ -138,8 +138,9 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) P_MakeDivline (line, &dll); - dlu.x = user->x; - dlu.y = user->y; + fixedvec3 pos = user->PosRelative(line); + dlu.x = pos.x; + dlu.y = pos.y; dlu.dx = finecosine[user->angle >> ANGLETOFINESHIFT]; dlu.dy = finesine[user->angle >> ANGLETOFINESHIFT]; inter = P_InterceptVector(&dll, &dlu); @@ -167,11 +168,11 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) onesided: fixed_t sectorc = front->ceilingplane.ZatPoint(checkx, checky); fixed_t sectorf = front->floorplane.ZatPoint(checkx, checky); - return (user->z + user->height >= sectorf && user->z <= sectorc); + return (user->Top() >= sectorf && user->Z() <= sectorc); } // Now get the information from the line. - P_LineOpening(open, NULL, line, checkx, checky, user->x, user->y); + P_LineOpening(open, NULL, line, checkx, checky, pos.x, pos.y); if (open.range <= 0) goto onesided; @@ -187,8 +188,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_UPPERTEXTURE)) continue; - if (user->z > rover->top.plane->ZatPoint(checkx, checky) || - user->z + user->height < rover->bottom.plane->ZatPoint(checkx, checky)) + if (user->Z() > rover->top.plane->ZatPoint(checkx, checky) || + user->Top() < rover->bottom.plane->ZatPoint(checkx, checky)) continue; // This 3D floor depicts a switch texture in front of the player's eyes @@ -196,7 +197,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) } } - return (user->z + user->height > open.top); + return (user->Top() > open.top); } else if ((TexMan.FindSwitch(side->GetTexture(side_t::bottom))) != NULL) { @@ -209,8 +210,8 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) if (!(rover->flags & FF_EXISTS)) continue; if (!(rover->flags & FF_LOWERTEXTURE)) continue; - if (user->z > rover->top.plane->ZatPoint(checkx, checky) || - user->z + user->height < rover->bottom.plane->ZatPoint(checkx, checky)) + if (user->Z() > rover->top.plane->ZatPoint(checkx, checky) || + user->Top() < rover->bottom.plane->ZatPoint(checkx, checky)) continue; // This 3D floor depicts a switch texture in front of the player's eyes @@ -218,7 +219,7 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) } } - return (user->z < open.bottom); + return (user->Z() < open.bottom); } else if ((flags & ML_3DMIDTEX) || (TexMan.FindSwitch(side->GetTexture(side_t::mid))) != NULL) { @@ -226,12 +227,12 @@ bool P_CheckSwitchRange(AActor *user, line_t *line, int sideno) // to keep compatibility with Eternity's implementation. if (!P_GetMidTexturePosition(line, sideno, &checktop, &checkbot)) return false; - return user->z < checktop && user->z + user->height > checkbot; + return user->Z() < checktop && user->Top() > checkbot; } else { // no switch found. Check whether the player can touch either top or bottom texture - return (user->z + user->height > open.top) || (user->z < open.bottom); + return (user->Top() > open.top) || (user->Z() < open.bottom); } }