- FindSector.

This commit is contained in:
Christoph Oelckers 2021-11-24 01:30:05 +01:00
parent b8953849ee
commit 9017fee74f
3 changed files with 23 additions and 40 deletions

View file

@ -35,19 +35,19 @@ BEGIN_BLD_NS
HITINFO gHitInfo;
bool FindSector(int nX, int nY, int nZ, int *nSector)
bool FindSector(int nX, int nY, int nZ, sectortype** pSector)
{
int32_t nZFloor, nZCeil;
assert(validSectorIndex(*nSector));
if (inside(nX, nY, *nSector))
assert(pSector);
if (inside(nX, nY, *pSector))
{
getzsofslope(*nSector, nX, nY, &nZCeil, &nZFloor);
getzsofslopeptr(*pSector, nX, nY, &nZCeil, &nZFloor);
if (nZ >= nZCeil && nZ <= nZFloor)
{
return 1;
}
}
for (auto& wal : wallsofsector(*nSector))
for (auto& wal : wallsofsector(*pSector))
{
auto pOSector = wal.nextSector();
if (pOSector != nullptr && inside(nX, nY, pOSector))
@ -55,19 +55,19 @@ bool FindSector(int nX, int nY, int nZ, int *nSector)
getzsofslopeptr(pOSector, nX, nY, &nZCeil, &nZFloor);
if (nZ >= nZCeil && nZ <= nZFloor)
{
*nSector = sectnum(pOSector);
*pSector = pOSector;
return 1;
}
}
}
for (int i = 0; i < numsectors; i++)
for(auto& sec : sectors())
{
if (inside(nX, nY, i))
if (inside(nX, nY, &sec))
{
getzsofslope(i, nX, nY, &nZCeil, &nZFloor);
getzsofslopeptr(&sec, nX, nY, &nZCeil, &nZFloor);
if (nZ >= nZCeil && nZ <= nZFloor)
{
*nSector = i;
*pSector = &sec;
return 1;
}
}
@ -75,27 +75,27 @@ bool FindSector(int nX, int nY, int nZ, int *nSector)
return 0;
}
bool FindSector(int nX, int nY, int *nSector)
bool FindSector(int nX, int nY, sectortype** pSector)
{
assert(validSectorIndex(*nSector));
if (inside(nX, nY, *nSector))
assert(*pSector);
if (inside(nX, nY, *pSector))
{
return 1;
}
for (auto& wal : wallsofsector(*nSector))
for (auto& wal : wallsofsector(*pSector))
{
auto pOSector = wal.nextSector();
if (pOSector != nullptr && inside(nX, nY, pOSector))
{
*nSector = sectnum(pOSector);
*pSector = pOSector;
return 1;
}
}
for (int i = 0; i < numsectors; i++)
for (auto& sec : sectors())
{
if (inside(nX, nY, i))
if (inside(nX, nY, &sec))
{
*nSector = i;
*pSector = &sec;
return 1;
}
}

View file

@ -52,27 +52,8 @@ enum {
struct Collision;
bool FindSector(int nX, int nY, int nZ, int *nSector);
inline bool FindSector(int nX, int nY, int nZ, sectortype** ppSector)
{
int n = sectnum(*ppSector);
bool res = FindSector(nX, nY, nZ, &n);
*ppSector = &sector[n];
return res;
}
bool FindSector(int nX, int nY, int *nSector);
inline bool FindSector(int nX, int nY, sectortype** ppSector)
{
int n = sectnum(*ppSector);
bool res = FindSector(nX, nY, &n);
*ppSector = &sector[n];
return res;
}
[[deprecated]]
bool FindSector(int nX, int nY, int nZ, int* nSector);
[[deprecated]]
bool FindSector(int nX, int nY, int* nSector);
bool FindSector(int nX, int nY, int nZ, sectortype** ppSector);
bool FindSector(int nX, int nY, sectortype** ppSector);
bool CheckProximity(DBloodActor *pSprite, int nX, int nY, int nZ, sectortype* pSector, int nDist);
bool CheckProximityPoint(int nX1, int nY1, int nZ1, int nX2, int nY2, int nZ2, int nDist);

View file

@ -163,7 +163,8 @@ void viewInit(void)
int othercameradist = 1280;
int othercameraclock;
void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsectnum, int nAng, fixed_t zm, int smoothratio)
#if 0
void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, sectortype** vsectnum, int nAng, fixed_t zm, int smoothratio) // currently unused
{
int vX = MulScale(-Cos(nAng), 1280, 30);
int vY = MulScale(-Sin(nAng), 1280, 30);
@ -208,6 +209,7 @@ void CalcOtherPosition(spritetype *pSprite, int *pX, int *pY, int *pZ, int *vsec
FindSector(*pX, *pY, *pZ, vsectnum);
pSprite->cstat = bakCstat;
}
#endif
// by NoOne: show warning msgs in game instead of throwing errors (in some cases)
void viewSetSystemMessage(const char* pMessage, ...) {