- more direct native functions for sector utilities.

This commit is contained in:
Christoph Oelckers 2018-11-29 17:38:58 +01:00
parent e3c13fe193
commit 62efe11a85
8 changed files with 128 additions and 127 deletions

View file

@ -264,7 +264,7 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t
break; break;
case DCeiling::ceilRaiseToHighest: case DCeiling::ceilRaiseToHighest:
targheight = sec->FindHighestCeilingSurrounding (&spot); targheight = FindHighestCeilingSurrounding (sec, &spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1; ceiling->m_Direction = 1;
break; break;
@ -300,13 +300,13 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t
break; break;
case DCeiling::ceilLowerToHighestFloor: case DCeiling::ceilLowerToHighestFloor:
targheight = sec->FindHighestFloorSurrounding (&spot) + height; targheight = FindHighestFloorSurrounding (sec, &spot) + height;
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
break; break;
case DCeiling::ceilRaiseToHighestFloor: case DCeiling::ceilRaiseToHighestFloor:
targheight = sec->FindHighestFloorSurrounding (&spot); targheight = FindHighestFloorSurrounding (sec, &spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1; ceiling->m_Direction = 1;
break; break;
@ -326,25 +326,25 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t
break; break;
case DCeiling::ceilLowerToNearest: case DCeiling::ceilLowerToNearest:
targheight = sec->FindNextLowestCeiling (&spot); targheight = FindNextLowestCeiling (sec, &spot);
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
break; break;
case DCeiling::ceilRaiseToNearest: case DCeiling::ceilRaiseToNearest:
targheight = sec->FindNextHighestCeiling (&spot); targheight = FindNextHighestCeiling (sec, &spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1; ceiling->m_Direction = 1;
break; break;
case DCeiling::ceilLowerToLowest: case DCeiling::ceilLowerToLowest:
targheight = sec->FindLowestCeilingSurrounding (&spot); targheight = FindLowestCeilingSurrounding (sec, &spot);
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
break; break;
case DCeiling::ceilRaiseToLowest: case DCeiling::ceilRaiseToLowest:
targheight = sec->FindLowestCeilingSurrounding (&spot); targheight = FindLowestCeilingSurrounding (sec, &spot);
ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_TopHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = 1; ceiling->m_Direction = 1;
break; break;
@ -362,7 +362,7 @@ bool P_CreateCeiling(sector_t *sec, DCeiling::ECeiling type, line_t *line, int t
break; break;
case DCeiling::ceilLowerToHighest: case DCeiling::ceilLowerToHighest:
targheight = sec->FindHighestCeilingSurrounding (&spot); targheight = FindHighestCeilingSurrounding (sec, &spot);
ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight); ceiling->m_BottomHeight = sec->ceilingplane.PointToDist (spot, targheight);
ceiling->m_Direction = -1; ceiling->m_Direction = -1;
break; break;

View file

@ -359,7 +359,7 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, double speed, int delay, int lightTag
{ {
case doorClose: case doorClose:
m_Direction = -1; m_Direction = -1;
height = sec->FindLowestCeilingSurrounding (&spot); height = FindLowestCeilingSurrounding (sec, &spot);
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4); m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4);
DoorSound (false); DoorSound (false);
break; break;
@ -367,7 +367,7 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, double speed, int delay, int lightTag
case doorOpen: case doorOpen:
case doorRaise: case doorRaise:
m_Direction = 1; m_Direction = 1;
height = sec->FindLowestCeilingSurrounding (&spot); height = FindLowestCeilingSurrounding (sec, &spot);
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4); m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4);
if (m_TopDist != sec->ceilingplane.fD()) if (m_TopDist != sec->ceilingplane.fD())
DoorSound (true); DoorSound (true);
@ -381,7 +381,7 @@ DDoor::DDoor (sector_t *sec, EVlDoor type, double speed, int delay, int lightTag
case doorWaitRaise: case doorWaitRaise:
m_Direction = 2; m_Direction = 2;
height = sec->FindLowestCeilingSurrounding (&spot); height = FindLowestCeilingSurrounding (sec, &spot);
m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4); m_TopDist = sec->ceilingplane.PointToDist (spot, height - 4);
break; break;

View file

@ -300,7 +300,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
{ {
case DFloor::floorLowerToHighest: case DFloor::floorLowerToHighest:
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->FindHighestFloorSurrounding(&spot); newheight = FindHighestFloorSurrounding(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
// [RH] DOOM's turboLower type did this. I've just extended it // [RH] DOOM's turboLower type did this. I've just extended it
// to be applicable to all LowerToHighest types. // to be applicable to all LowerToHighest types.
@ -310,14 +310,14 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
case DFloor::floorLowerToLowest: case DFloor::floorLowerToLowest:
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->FindLowestFloorSurrounding(&spot); newheight = FindLowestFloorSurrounding(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
case DFloor::floorLowerToNearest: case DFloor::floorLowerToNearest:
//jff 02/03/30 support lowering floor to next lowest floor //jff 02/03/30 support lowering floor to next lowest floor
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->FindNextLowestFloor(&spot); newheight = FindNextLowestFloor(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
@ -347,7 +347,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
height = 8; height = 8;
case DFloor::floorRaiseToLowestCeiling: case DFloor::floorRaiseToLowestCeiling:
floor->m_Direction = 1; floor->m_Direction = 1;
newheight = sec->FindLowestCeilingSurrounding(&spot) - height; newheight = FindLowestCeilingSurrounding(sec, &spot) - height;
ceilingheight = FindLowestCeilingPoint(sec, &spot2); ceilingheight = FindLowestCeilingPoint(sec, &spot2);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
if (sec->floorplane.ZatPointDist(spot2, floor->m_FloorDestDist) > ceilingheight) if (sec->floorplane.ZatPointDist(spot2, floor->m_FloorDestDist) > ceilingheight)
@ -356,19 +356,19 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
case DFloor::floorRaiseToHighest: case DFloor::floorRaiseToHighest:
floor->m_Direction = 1; floor->m_Direction = 1;
newheight = sec->FindHighestFloorSurrounding(&spot); newheight = FindHighestFloorSurrounding(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
case DFloor::floorRaiseToNearest: case DFloor::floorRaiseToNearest:
floor->m_Direction = 1; floor->m_Direction = 1;
newheight = sec->FindNextHighestFloor(&spot); newheight = FindNextHighestFloor(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
case DFloor::floorRaiseToLowest: case DFloor::floorRaiseToLowest:
floor->m_Direction = 1; floor->m_Direction = 1;
newheight = sec->FindLowestFloorSurrounding(&spot); newheight = FindLowestFloorSurrounding(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
@ -386,7 +386,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
case DFloor::floorLowerToLowestCeiling: case DFloor::floorLowerToLowestCeiling:
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->FindLowestCeilingSurrounding(&spot); newheight = FindLowestCeilingSurrounding(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
break; break;
@ -431,7 +431,7 @@ bool P_CreateFloor(sector_t *sec, DFloor::EFloor floortype, line_t *line,
case DFloor::floorLowerAndChange: case DFloor::floorLowerAndChange:
floor->m_Direction = -1; floor->m_Direction = -1;
newheight = sec->FindLowestFloorSurrounding(&spot); newheight = FindLowestFloorSurrounding(sec, &spot);
floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight); floor->m_FloorDestDist = sec->floorplane.PointToDist(spot, newheight);
floor->m_Texture = sec->GetTexture(sector_t::floor); floor->m_Texture = sec->GetTexture(sector_t::floor);
// jff 1/24/98 make sure floor->m_NewSpecial gets initialized // jff 1/24/98 make sure floor->m_NewSpecial gets initialized
@ -1037,7 +1037,7 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
// elevator down to next floor // elevator down to next floor
case DElevator::elevateDown: case DElevator::elevateDown:
elevator->m_Direction = -1; elevator->m_Direction = -1;
newheight = sec->FindNextLowestFloor (&spot); newheight = FindNextLowestFloor (sec, &spot);
elevator->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); elevator->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
newheight += sec->ceilingplane.ZatPoint(spot) - sec->floorplane.ZatPoint(spot); newheight += sec->ceilingplane.ZatPoint(spot) - sec->floorplane.ZatPoint(spot);
elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (spot, newheight); elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (spot, newheight);
@ -1046,7 +1046,7 @@ bool EV_DoElevator (line_t *line, DElevator::EElevator elevtype,
// elevator up to next floor // elevator up to next floor
case DElevator::elevateUp: case DElevator::elevateUp:
elevator->m_Direction = 1; elevator->m_Direction = 1;
newheight = sec->FindNextHighestFloor (&spot); newheight = FindNextHighestFloor (sec, &spot);
elevator->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight); elevator->m_FloorDestDist = sec->floorplane.PointToDist (spot, newheight);
newheight += sec->ceilingplane.ZatPoint(spot) - sec->floorplane.ZatPoint(spot); newheight += sec->ceilingplane.ZatPoint(spot) - sec->floorplane.ZatPoint(spot);
elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (spot, newheight); elevator->m_CeilingDestDist = sec->ceilingplane.PointToDist (spot, newheight);

View file

@ -157,7 +157,7 @@ DPillar::DPillar (sector_t *sector, EPillar type, double speed,
// surrounding sectors // surrounding sectors
if (floordist == 0) if (floordist == 0)
{ {
newheight = sector->FindLowestFloorSurrounding (&spot); newheight = FindLowestFloorSurrounding (sector, &spot);
m_FloorTarget = sector->floorplane.PointToDist (spot, newheight); m_FloorTarget = sector->floorplane.PointToDist (spot, newheight);
floordist = sector->floorplane.ZatPoint (spot) - newheight; floordist = sector->floorplane.ZatPoint (spot) - newheight;
} }
@ -168,7 +168,7 @@ DPillar::DPillar (sector_t *sector, EPillar type, double speed,
} }
if (ceilingdist == 0) if (ceilingdist == 0)
{ {
newheight = sector->FindHighestCeilingSurrounding (&spot); newheight = FindHighestCeilingSurrounding (sector, &spot);
m_CeilingTarget = sector->ceilingplane.PointToDist (spot, newheight); m_CeilingTarget = sector->ceilingplane.PointToDist (spot, newheight);
ceilingdist = newheight - sector->ceilingplane.ZatPoint (spot); ceilingdist = newheight - sector->ceilingplane.ZatPoint (spot);
} }

View file

@ -279,7 +279,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
{ {
case DPlat::platRaiseAndStay: case DPlat::platRaiseAndStay:
case DPlat::platRaiseAndStayLockout: case DPlat::platRaiseAndStayLockout:
newheight = sec->FindNextHighestFloor (&spot); newheight = FindNextHighestFloor (sec, &spot);
plat->m_High = sec->floorplane.PointToDist (spot, newheight); plat->m_High = sec->floorplane.PointToDist (spot, newheight);
plat->m_Low = sec->floorplane.fD(); plat->m_Low = sec->floorplane.fD();
plat->m_Status = DPlat::up; plat->m_Status = DPlat::up;
@ -306,7 +306,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
case DPlat::platDownWaitUpStay: case DPlat::platDownWaitUpStay:
case DPlat::platDownWaitUpStayStone: case DPlat::platDownWaitUpStayStone:
newheight = sec->FindLowestFloorSurrounding (&spot) + lip; newheight = FindLowestFloorSurrounding (sec, &spot) + lip;
plat->m_Low = sec->floorplane.PointToDist (spot, newheight); plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
if (plat->m_Low < sec->floorplane.fD()) if (plat->m_Low < sec->floorplane.fD())
@ -318,13 +318,13 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
break; break;
case DPlat::platUpNearestWaitDownStay: case DPlat::platUpNearestWaitDownStay:
newheight = sec->FindNextHighestFloor (&spot); newheight = FindNextHighestFloor (sec, &spot);
// Intentional fall-through // Intentional fall-through
case DPlat::platUpWaitDownStay: case DPlat::platUpWaitDownStay:
if (type == DPlat::platUpWaitDownStay) if (type == DPlat::platUpWaitDownStay)
{ {
newheight = sec->FindHighestFloorSurrounding (&spot); newheight = FindHighestFloorSurrounding (sec, &spot);
} }
plat->m_High = sec->floorplane.PointToDist (spot, newheight); plat->m_High = sec->floorplane.PointToDist (spot, newheight);
plat->m_Low = sec->floorplane.fD(); plat->m_Low = sec->floorplane.fD();
@ -337,13 +337,13 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
break; break;
case DPlat::platPerpetualRaise: case DPlat::platPerpetualRaise:
newheight = sec->FindLowestFloorSurrounding (&spot) + lip; newheight = FindLowestFloorSurrounding (sec, &spot) + lip;
plat->m_Low = sec->floorplane.PointToDist (spot, newheight); plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
if (plat->m_Low < sec->floorplane.fD()) if (plat->m_Low < sec->floorplane.fD())
plat->m_Low = sec->floorplane.fD(); plat->m_Low = sec->floorplane.fD();
newheight = sec->FindHighestFloorSurrounding (&spot); newheight = FindHighestFloorSurrounding (sec, &spot);
plat->m_High = sec->floorplane.PointToDist (spot, newheight); plat->m_High = sec->floorplane.PointToDist (spot, newheight);
if (plat->m_High > sec->floorplane.fD()) if (plat->m_High > sec->floorplane.fD())
@ -366,7 +366,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
break; break;
case DPlat::platDownToNearestFloor: case DPlat::platDownToNearestFloor:
newheight = sec->FindNextLowestFloor (&spot) + lip; newheight = FindNextLowestFloor (sec, &spot) + lip;
plat->m_Low = sec->floorplane.PointToDist (spot, newheight); plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
plat->m_Status = DPlat::down; plat->m_Status = DPlat::down;
plat->m_High = sec->floorplane.fD(); plat->m_High = sec->floorplane.fD();
@ -374,7 +374,7 @@ bool EV_DoPlat (int tag, line_t *line, DPlat::EPlatType type, double height,
break; break;
case DPlat::platDownToLowestCeiling: case DPlat::platDownToLowestCeiling:
newheight = sec->FindLowestCeilingSurrounding (&spot); newheight = FindLowestCeilingSurrounding (sec, &spot);
plat->m_Low = sec->floorplane.PointToDist (spot, newheight); plat->m_Low = sec->floorplane.PointToDist (spot, newheight);
plat->m_High = sec->floorplane.fD(); plat->m_High = sec->floorplane.fD();

View file

@ -104,37 +104,37 @@ DEFINE_ACTION_FUNCTION(_Sector, NextSpecialSector)
// P_FindLowestFloorSurrounding() // P_FindLowestFloorSurrounding()
// FIND LOWEST FLOOR HEIGHT IN SURROUNDING SECTORS // FIND LOWEST FLOOR HEIGHT IN SURROUNDING SECTORS
// //
double sector_t::FindLowestFloorSurrounding (vertex_t **v) const double FindLowestFloorSurrounding (const sector_t *sector, vertex_t **v)
{ {
sector_t *other; sector_t *other;
double floor; double floor;
double ofloor; double ofloor;
vertex_t *spot; vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::floor); if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::floor);
spot = Lines[0]->v1; spot = sector->Lines[0]->v1;
floor = floorplane.ZatPoint(spot); floor = sector->floorplane.ZatPoint(spot);
for (auto check : Lines) for (auto check : sector->Lines)
{ {
if (NULL != (other = getNextSector (check, this))) if (NULL != (other = getNextSector (check, sector)))
{ {
ofloor = other->floorplane.ZatPoint (check->v1); ofloor = other->floorplane.ZatPoint (check->v1);
if (ofloor < floor && ofloor < floorplane.ZatPoint (check->v1)) if (ofloor < floor && ofloor < sector->floorplane.ZatPoint (check->v1))
{ {
floor = ofloor; floor = ofloor;
spot = check->v1; spot = check->v1;
} }
ofloor = other->floorplane.ZatPoint (check->v2); ofloor = other->floorplane.ZatPoint (check->v2);
if (ofloor < floor && ofloor < floorplane.ZatPoint (check->v2)) if (ofloor < floor && ofloor < sector->floorplane.ZatPoint (check->v2))
{ {
floor = ofloor; floor = ofloor;
spot = check->v2; spot = check->v2;
} }
} }
} }
if (v != NULL) if (v != nullptr)
*v = spot; *v = spot;
return floor; return floor;
} }
@ -143,21 +143,21 @@ double sector_t::FindLowestFloorSurrounding (vertex_t **v) const
// P_FindHighestFloorSurrounding() // P_FindHighestFloorSurrounding()
// FIND HIGHEST FLOOR HEIGHT IN SURROUNDING SECTORS // FIND HIGHEST FLOOR HEIGHT IN SURROUNDING SECTORS
// //
double sector_t::FindHighestFloorSurrounding (vertex_t **v) const double FindHighestFloorSurrounding (const sector_t *sector, vertex_t **v)
{ {
sector_t *other; sector_t *other;
double floor; double floor;
double ofloor; double ofloor;
vertex_t *spot; vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::floor); if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::floor);
spot = Lines[0]->v1; spot = sector->Lines[0]->v1;
floor = -FLT_MAX; floor = -FLT_MAX;
for (auto check : Lines) for (auto check : sector->Lines)
{ {
if (NULL != (other = getNextSector (check, this))) if (NULL != (other = getNextSector (check, sector)))
{ {
ofloor = other->floorplane.ZatPoint (check->v1); ofloor = other->floorplane.ZatPoint (check->v1);
if (ofloor > floor) if (ofloor > floor)
@ -173,7 +173,7 @@ double sector_t::FindHighestFloorSurrounding (vertex_t **v) const
} }
} }
} }
if (v != NULL) if (v != nullptr)
*v = spot; *v = spot;
return floor; return floor;
} }
@ -188,7 +188,7 @@ double sector_t::FindHighestFloorSurrounding (vertex_t **v) const
// //
// Rewritten by Lee Killough to avoid fixed array and to be faster // Rewritten by Lee Killough to avoid fixed array and to be faster
// //
double sector_t::FindNextHighestFloor (vertex_t **v) const double FindNextHighestFloor (const sector_t *sector, vertex_t **v)
{ {
double height; double height;
double heightdiff; double heightdiff;
@ -196,27 +196,27 @@ double sector_t::FindNextHighestFloor (vertex_t **v) const
sector_t *other; sector_t *other;
vertex_t *spot; vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::floor); if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::floor);
spot = Lines[0]->v1; spot = sector->Lines[0]->v1;
height = floorplane.ZatPoint(spot); height = sector->floorplane.ZatPoint(spot);
heightdiff = FLT_MAX; heightdiff = FLT_MAX;
for (auto check : Lines) for (auto check : sector->Lines)
{ {
if (NULL != (other = getNextSector (check, this))) if (NULL != (other = getNextSector (check, sector)))
{ {
ofloor = other->floorplane.ZatPoint (check->v1); ofloor = other->floorplane.ZatPoint (check->v1);
floor = floorplane.ZatPoint (check->v1); floor = sector->floorplane.ZatPoint (check->v1);
if (ofloor > floor && ofloor - floor < heightdiff && !IsLinked(other, false)) if (ofloor > floor && ofloor - floor < heightdiff && !sector->IsLinked(other, false))
{ {
heightdiff = ofloor - floor; heightdiff = ofloor - floor;
height = ofloor; height = ofloor;
spot = check->v1; spot = check->v1;
} }
ofloor = other->floorplane.ZatPoint (check->v2); ofloor = other->floorplane.ZatPoint (check->v2);
floor = floorplane.ZatPoint (check->v2); floor = sector->floorplane.ZatPoint (check->v2);
if (ofloor > floor && ofloor - floor < heightdiff && !IsLinked(other, false)) if (ofloor > floor && ofloor - floor < heightdiff && !sector->IsLinked(other, false))
{ {
heightdiff = ofloor - floor; heightdiff = ofloor - floor;
height = ofloor; height = ofloor;
@ -224,7 +224,7 @@ double sector_t::FindNextHighestFloor (vertex_t **v) const
} }
} }
} }
if (v != NULL) if (v != nullptr)
*v = spot; *v = spot;
return height; return height;
} }
@ -240,7 +240,7 @@ double sector_t::FindNextHighestFloor (vertex_t **v) const
// //
// jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this // jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this
// //
double sector_t::FindNextLowestFloor (vertex_t **v) const double FindNextLowestFloor (const sector_t *sector, vertex_t **v)
{ {
double height; double height;
double heightdiff; double heightdiff;
@ -248,27 +248,27 @@ double sector_t::FindNextLowestFloor (vertex_t **v) const
sector_t *other; sector_t *other;
vertex_t *spot; vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::floor); if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::floor);
spot = Lines[0]->v1; spot = sector->Lines[0]->v1;
height = floorplane.ZatPoint (spot); height = sector->floorplane.ZatPoint (spot);
heightdiff = FLT_MAX; heightdiff = FLT_MAX;
for (auto check : Lines) for (auto check : sector->Lines)
{ {
if (NULL != (other = getNextSector (check, this))) if (NULL != (other = getNextSector (check, sector)))
{ {
ofloor = other->floorplane.ZatPoint (check->v1); ofloor = other->floorplane.ZatPoint (check->v1);
floor = floorplane.ZatPoint (check->v1); floor = sector->floorplane.ZatPoint (check->v1);
if (ofloor < floor && floor - ofloor < heightdiff && !IsLinked(other, false)) if (ofloor < floor && floor - ofloor < heightdiff && !sector->IsLinked(other, false))
{ {
heightdiff = floor - ofloor; heightdiff = floor - ofloor;
height = ofloor; height = ofloor;
spot = check->v1; spot = check->v1;
} }
ofloor = other->floorplane.ZatPoint (check->v2); ofloor = other->floorplane.ZatPoint (check->v2);
floor = floorplane.ZatPoint(check->v2); floor = sector->floorplane.ZatPoint(check->v2);
if (ofloor < floor && floor - ofloor < heightdiff && !IsLinked(other, false)) if (ofloor < floor && floor - ofloor < heightdiff && !sector->IsLinked(other, false))
{ {
heightdiff = floor - ofloor; heightdiff = floor - ofloor;
height = ofloor; height = ofloor;
@ -276,7 +276,7 @@ double sector_t::FindNextLowestFloor (vertex_t **v) const
} }
} }
} }
if (v != NULL) if (v != nullptr)
*v = spot; *v = spot;
return height; return height;
} }
@ -292,7 +292,7 @@ double sector_t::FindNextLowestFloor (vertex_t **v) const
// //
// jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this // jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this
// //
double sector_t::FindNextLowestCeiling (vertex_t **v) const double FindNextLowestCeiling (const sector_t *sector, vertex_t **v)
{ {
double height; double height;
double heightdiff; double heightdiff;
@ -300,27 +300,27 @@ double sector_t::FindNextLowestCeiling (vertex_t **v) const
sector_t *other; sector_t *other;
vertex_t *spot; vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::floor); if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::floor);
spot = Lines[0]->v1; spot = sector->Lines[0]->v1;
height = ceilingplane.ZatPoint(spot); height = sector->ceilingplane.ZatPoint(spot);
heightdiff = FLT_MAX; heightdiff = FLT_MAX;
for (auto check : Lines) for (auto check : sector->Lines)
{ {
if (NULL != (other = getNextSector (check, this))) if (NULL != (other = getNextSector (check, sector)))
{ {
oceil = other->ceilingplane.ZatPoint(check->v1); oceil = other->ceilingplane.ZatPoint(check->v1);
ceil = ceilingplane.ZatPoint(check->v1); ceil = sector->ceilingplane.ZatPoint(check->v1);
if (oceil < ceil && ceil - oceil < heightdiff && !IsLinked(other, true)) if (oceil < ceil && ceil - oceil < heightdiff && !sector->IsLinked(other, true))
{ {
heightdiff = ceil - oceil; heightdiff = ceil - oceil;
height = oceil; height = oceil;
spot = check->v1; spot = check->v1;
} }
oceil = other->ceilingplane.ZatPoint(check->v2); oceil = other->ceilingplane.ZatPoint(check->v2);
ceil = ceilingplane.ZatPoint(check->v2); ceil = sector->ceilingplane.ZatPoint(check->v2);
if (oceil < ceil && ceil - oceil < heightdiff && !IsLinked(other, true)) if (oceil < ceil && ceil - oceil < heightdiff && !sector->IsLinked(other, true))
{ {
heightdiff = ceil - oceil; heightdiff = ceil - oceil;
height = oceil; height = oceil;
@ -328,7 +328,7 @@ double sector_t::FindNextLowestCeiling (vertex_t **v) const
} }
} }
} }
if (v != NULL) if (v != nullptr)
*v = spot; *v = spot;
return height; return height;
} }
@ -344,7 +344,7 @@ double sector_t::FindNextLowestCeiling (vertex_t **v) const
// //
// jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this // jff 02/03/98 Twiddled Lee's P_FindNextHighestFloor to make this
// //
double sector_t::FindNextHighestCeiling (vertex_t **v) const double FindNextHighestCeiling (const sector_t *sector, vertex_t **v)
{ {
double height; double height;
double heightdiff; double heightdiff;
@ -352,27 +352,27 @@ double sector_t::FindNextHighestCeiling (vertex_t **v) const
sector_t *other; sector_t *other;
vertex_t *spot; vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::ceiling); if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::ceiling);
spot = Lines[0]->v1; spot = sector->Lines[0]->v1;
height = ceilingplane.ZatPoint(spot); height = sector->ceilingplane.ZatPoint(spot);
heightdiff = FLT_MAX; heightdiff = FLT_MAX;
for (auto check : Lines) for (auto check : sector->Lines)
{ {
if (NULL != (other = getNextSector (check, this))) if (NULL != (other = getNextSector (check, sector)))
{ {
oceil = other->ceilingplane.ZatPoint(check->v1); oceil = other->ceilingplane.ZatPoint(check->v1);
ceil = ceilingplane.ZatPoint(check->v1); ceil = sector->ceilingplane.ZatPoint(check->v1);
if (oceil > ceil && oceil - ceil < heightdiff && !IsLinked(other, true)) if (oceil > ceil && oceil - ceil < heightdiff && !sector->IsLinked(other, true))
{ {
heightdiff = oceil - ceil; heightdiff = oceil - ceil;
height = oceil; height = oceil;
spot = check->v1; spot = check->v1;
} }
oceil = other->ceilingplane.ZatPoint(check->v2); oceil = other->ceilingplane.ZatPoint(check->v2);
ceil = ceilingplane.ZatPoint(check->v2); ceil = sector->ceilingplane.ZatPoint(check->v2);
if (oceil > ceil && oceil - ceil < heightdiff && !IsLinked(other, true)) if (oceil > ceil && oceil - ceil < heightdiff && !sector->IsLinked(other, true))
{ {
heightdiff = oceil - ceil; heightdiff = oceil - ceil;
height = oceil; height = oceil;
@ -380,7 +380,7 @@ double sector_t::FindNextHighestCeiling (vertex_t **v) const
} }
} }
} }
if (v != NULL) if (v != nullptr)
*v = spot; *v = spot;
return height; return height;
} }
@ -389,21 +389,21 @@ double sector_t::FindNextHighestCeiling (vertex_t **v) const
// //
// FIND LOWEST CEILING IN THE SURROUNDING SECTORS // FIND LOWEST CEILING IN THE SURROUNDING SECTORS
// //
double sector_t::FindLowestCeilingSurrounding (vertex_t **v) const double FindLowestCeilingSurrounding (const sector_t *sector, vertex_t **v)
{ {
double height; double height;
double oceil; double oceil;
sector_t *other; sector_t *other;
vertex_t *spot; vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::ceiling); if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::ceiling);
spot = Lines[0]->v1; spot = sector->Lines[0]->v1;
height = FLT_MAX; height = FLT_MAX;
for (auto check : Lines) for (auto check : sector->Lines)
{ {
if (NULL != (other = getNextSector (check, this))) if (NULL != (other = getNextSector (check, sector)))
{ {
oceil = other->ceilingplane.ZatPoint(check->v1); oceil = other->ceilingplane.ZatPoint(check->v1);
if (oceil < height) if (oceil < height)
@ -419,7 +419,7 @@ double sector_t::FindLowestCeilingSurrounding (vertex_t **v) const
} }
} }
} }
if (v != NULL) if (v != nullptr)
*v = spot; *v = spot;
return height; return height;
} }
@ -428,21 +428,21 @@ double sector_t::FindLowestCeilingSurrounding (vertex_t **v) const
// //
// FIND HIGHEST CEILING IN THE SURROUNDING SECTORS // FIND HIGHEST CEILING IN THE SURROUNDING SECTORS
// //
double sector_t::FindHighestCeilingSurrounding (vertex_t **v) const double FindHighestCeilingSurrounding (const sector_t *sector, vertex_t **v)
{ {
double height; double height;
double oceil; double oceil;
sector_t *other; sector_t *other;
vertex_t *spot; vertex_t *spot;
if (Lines.Size() == 0) return GetPlaneTexZ(sector_t::ceiling); if (sector->Lines.Size() == 0) return sector->GetPlaneTexZ(sector_t::ceiling);
spot = Lines[0]->v1; spot = sector->Lines[0]->v1;
height = -FLT_MAX; height = -FLT_MAX;
for (auto check : Lines) for (auto check : sector->Lines)
{ {
if (NULL != (other = getNextSector (check, this))) if (NULL != (other = getNextSector (check, sector)))
{ {
oceil = other->ceilingplane.ZatPoint(check->v1); oceil = other->ceilingplane.ZatPoint(check->v1);
if (oceil > height) if (oceil > height)
@ -458,7 +458,7 @@ double sector_t::FindHighestCeilingSurrounding (vertex_t **v) const
} }
} }
} }
if (v != NULL) if (v != nullptr)
*v = spot; *v = spot;
return height; return height;
} }

View file

@ -622,14 +622,7 @@ public:
} }
bool IsLinked(sector_t *other, bool ceiling) const; bool IsLinked(sector_t *other, bool ceiling) const;
double FindLowestFloorSurrounding(vertex_t **v) const;
double FindHighestFloorSurrounding(vertex_t **v) const;
double FindNextHighestFloor(vertex_t **v) const;
double FindNextLowestFloor(vertex_t **v) const;
double FindLowestCeilingSurrounding(vertex_t **v) const; // jff 2/04/98
double FindHighestCeilingSurrounding(vertex_t **v) const; // jff 2/04/98
double FindNextLowestCeiling(vertex_t **v) const; // jff 2/04/98
double FindNextHighestCeiling(vertex_t **v) const; // jff 2/04/98
int FindMinSurroundingLight (int max) const; int FindMinSurroundingLight (int max) const;
sector_t *NextSpecialSector (int type, sector_t *prev) const; // [RH] sector_t *NextSpecialSector (int type, sector_t *prev) const; // [RH]
double FindHighestFloorPoint(vertex_t **v) const; double FindHighestFloorPoint(vertex_t **v) const;
@ -1597,6 +1590,14 @@ inline void FColormap::CopyFrom3DLight(lightlist_t *light)
} }
} }
double FindLowestFloorSurrounding(const sector_t *sec, vertex_t **v);
double FindHighestFloorSurrounding(const sector_t *sec, vertex_t **v);
double FindNextHighestFloor(const sector_t *sec, vertex_t **v);
double FindNextLowestFloor(const sector_t *sec, vertex_t **v);
double FindLowestCeilingSurrounding(const sector_t *sec, vertex_t **v); // jff 2/04/98
double FindHighestCeilingSurrounding(const sector_t *sec, vertex_t **v); // jff 2/04/98
double FindNextLowestCeiling(const sector_t *sec, vertex_t **v); // jff 2/04/98
double FindNextHighestCeiling(const sector_t *sec, vertex_t **v); // jff 2/04/98
double FindShortestTextureAround(sector_t *sector); // jff 2/04/98 double FindShortestTextureAround(sector_t *sector); // jff 2/04/98
double FindShortestUpperAround(sector_t *sector); // jff 2/04/98 double FindShortestUpperAround(sector_t *sector); // jff 2/04/98

View file

@ -28,82 +28,82 @@
#include "p_local.h" #include "p_local.h"
DEFINE_ACTION_FUNCTION(_Sector, FindLowestFloorSurrounding) DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindLowestFloorSurrounding, FindLowestFloorSurrounding)
{ {
PARAM_SELF_STRUCT_PROLOGUE(sector_t); PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v; vertex_t *v;
double h = self->FindLowestFloorSurrounding(&v); double h = FindLowestFloorSurrounding(self, &v);
if (numret > 0) ret[0].SetFloat(h); if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v); if (numret > 1) ret[1].SetPointer(v);
return numret; return numret;
} }
DEFINE_ACTION_FUNCTION(_Sector, FindHighestFloorSurrounding) DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindHighestFloorSurrounding, FindHighestFloorSurrounding)
{ {
PARAM_SELF_STRUCT_PROLOGUE(sector_t); PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v; vertex_t *v;
double h = self->FindHighestFloorSurrounding(&v); double h = FindHighestFloorSurrounding(self, &v);
if (numret > 0) ret[0].SetFloat(h); if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v); if (numret > 1) ret[1].SetPointer(v);
return numret; return numret;
} }
DEFINE_ACTION_FUNCTION(_Sector, FindNextHighestFloor) DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindNextHighestFloor, FindNextHighestFloor)
{ {
PARAM_SELF_STRUCT_PROLOGUE(sector_t); PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v; vertex_t *v;
double h = self->FindNextHighestFloor(&v); double h = FindNextHighestFloor(self, &v);
if (numret > 0) ret[0].SetFloat(h); if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v); if (numret > 1) ret[1].SetPointer(v);
return numret; return numret;
} }
DEFINE_ACTION_FUNCTION(_Sector, FindNextLowestFloor) DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindNextLowestFloor, FindNextLowestFloor)
{ {
PARAM_SELF_STRUCT_PROLOGUE(sector_t); PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v; vertex_t *v;
double h = self->FindNextLowestFloor(&v); double h = FindNextLowestFloor(self, &v);
if (numret > 0) ret[0].SetFloat(h); if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v); if (numret > 1) ret[1].SetPointer(v);
return numret; return numret;
} }
DEFINE_ACTION_FUNCTION(_Sector, FindNextLowestCeiling) DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindNextLowestCeiling, FindNextLowestCeiling)
{ {
PARAM_SELF_STRUCT_PROLOGUE(sector_t); PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v; vertex_t *v;
double h = self->FindNextLowestCeiling(&v); double h = FindNextLowestCeiling(self, &v);
if (numret > 0) ret[0].SetFloat(h); if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v); if (numret > 1) ret[1].SetPointer(v);
return numret; return numret;
} }
DEFINE_ACTION_FUNCTION(_Sector, FindNextHighestCeiling) DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindNextHighestCeiling, FindNextHighestCeiling)
{ {
PARAM_SELF_STRUCT_PROLOGUE(sector_t); PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v; vertex_t *v;
double h = self->FindNextHighestCeiling(&v); double h = FindNextHighestCeiling(self, &v);
if (numret > 0) ret[0].SetFloat(h); if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v); if (numret > 1) ret[1].SetPointer(v);
return numret; return numret;
} }
DEFINE_ACTION_FUNCTION(_Sector, FindLowestCeilingSurrounding) DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindLowestCeilingSurrounding, FindLowestCeilingSurrounding)
{ {
PARAM_SELF_STRUCT_PROLOGUE(sector_t); PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v; vertex_t *v;
double h = self->FindLowestCeilingSurrounding(&v); double h = FindLowestCeilingSurrounding(self, &v);
if (numret > 0) ret[0].SetFloat(h); if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v); if (numret > 1) ret[1].SetPointer(v);
return numret; return numret;
} }
DEFINE_ACTION_FUNCTION(_Sector, FindHighestCeilingSurrounding) DEFINE_ACTION_FUNCTION_NATIVE(_Sector, FindHighestCeilingSurrounding, FindHighestCeilingSurrounding)
{ {
PARAM_SELF_STRUCT_PROLOGUE(sector_t); PARAM_SELF_STRUCT_PROLOGUE(sector_t);
vertex_t *v; vertex_t *v;
double h = self->FindHighestCeilingSurrounding(&v); double h = FindHighestCeilingSurrounding(self, &v);
if (numret > 0) ret[0].SetFloat(h); if (numret > 0) ret[0].SetFloat(h);
if (numret > 1) ret[1].SetPointer(v); if (numret > 1) ret[1].SetPointer(v);
return numret; return numret;