- FAF_Connect* functions and related code.

This commit is contained in:
Christoph Oelckers 2021-11-25 00:45:55 +01:00
parent 96915a646b
commit 0c9d465e4c
9 changed files with 61 additions and 60 deletions

View file

@ -770,7 +770,7 @@ void analyzesprites(spritetype* tsprite, int& spritesortcnt, int viewx, int view
}
}
if (OverlapDraw && FAF_ConnectArea(tsp->sectnum) && tsp->owner >= 0)
if (OverlapDraw && FAF_ConnectArea(tsp->sector()) && tsp->owner >= 0)
{
ConnectCopySprite(tsp);
}
@ -1255,7 +1255,7 @@ DSWActor* ConnectCopySprite(spritetype const * tsp)
int newsector;
int testz;
if (FAF_ConnectCeiling(tsp->sectnum))
if (FAF_ConnectCeiling(tsp->sector()))
{
newsector = tsp->sectnum;
testz = SPRITEp_TOS(tsp) - Z(10);
@ -1269,7 +1269,7 @@ DSWActor* ConnectCopySprite(spritetype const * tsp)
}
}
if (FAF_ConnectFloor(tsp->sectnum))
if (FAF_ConnectFloor(tsp->sector()))
{
newsector = tsp->sectnum;
testz = SPRITEp_BOS(tsp) + Z(10);

View file

@ -435,7 +435,7 @@ int DoEelMatchPlayerZ(DSWActor* actor)
int bound;
if (FAF_ConnectArea(sp->sectnum))
if (FAF_ConnectArea(sp->sector()))
{
if (u->hi_sectp)
{

View file

@ -1901,19 +1901,19 @@ int SpawnBlood(DSWActor* actor, DSWActor* weapActor, short hit_ang, int hit_x, i
#define FAF_PLACE_MIRROR_PIC 341
#define FAF_MIRROR_PIC 2356
inline bool FAF_ConnectCeiling(int sectnum)
inline bool FAF_ConnectCeiling(sectortype* sect)
{
return (sector[(sectnum)].ceilingpicnum == FAF_MIRROR_PIC);
return (sect->ceilingpicnum == FAF_MIRROR_PIC);
}
inline bool FAF_ConnectFloor(int sectnum)
inline bool FAF_ConnectFloor(sectortype* sect)
{
return (sector[(sectnum)].floorpicnum == FAF_MIRROR_PIC);
return (sect->floorpicnum == FAF_MIRROR_PIC);
}
inline bool FAF_ConnectArea(int sectnum)
inline bool FAF_ConnectArea(sectortype* sect)
{
return (FAF_ConnectCeiling(sectnum) || FAF_ConnectFloor(sectnum));
return (FAF_ConnectCeiling(sect) || FAF_ConnectFloor(sect));
}
bool PlayerCeilingHit(PLAYERp pp, int zlimit);

View file

@ -462,7 +462,7 @@ int DoBloodSpray(DSWActor* actor)
else
{
auto bsp = &bldActor->s();
if (FAF_Sector(bsp->sectnum) || FAF_ConnectArea(bsp->sectnum))
if (FAF_Sector(bsp->sectnum) || FAF_ConnectArea(bsp->sector()))
{
KillActor(actor);
return 0;

View file

@ -2183,52 +2183,52 @@ void DoPlayerMove(PLAYERp pp)
void DoPlayerSectorUpdatePreMove(PLAYERp pp)
{
int sectnum = pp->cursectnum;
auto sect = pp->cursector();
if (sectnum < 0)
if (sect == nullptr)
return;
if (TEST(pp->cursector()->extra, SECTFX_DYNAMIC_AREA))
{
updatesectorz(pp->posx, pp->posy, pp->posz, &sectnum);
if (sectnum < 0)
updatesectorz(pp->posx, pp->posy, pp->posz, &sect);
if (sect == nullptr)
{
sectnum = pp->cursectnum;
updatesector(pp->posx, pp->posy, &sectnum);
sect = pp->cursector();
updatesector(pp->posx, pp->posy, &sect);
}
ASSERT(sectnum >= 0);
ASSERT(sect);
}
else if (FAF_ConnectArea(sectnum))
else if (FAF_ConnectArea(sect))
{
updatesectorz(pp->posx, pp->posy, pp->posz, &sectnum);
if (sectnum < 0)
updatesectorz(pp->posx, pp->posy, pp->posz, &sect);
if (sect == nullptr)
{
sectnum = pp->cursectnum;
updatesector(pp->posx, pp->posy, &sectnum);
sect = pp->cursector();
updatesector(pp->posx, pp->posy, &sect);
}
ASSERT(sectnum >= 0);
ASSERT(sect);
}
pp->cursectnum = sectnum;
pp->setcursector(sect);
}
void DoPlayerSectorUpdatePostMove(PLAYERp pp)
{
short sectnum = pp->cursectnum;
auto sect = pp->cursector();
int fz,cz;
// need to do updatesectorz if in connect area
if (sectnum >= 0 && FAF_ConnectArea(sectnum))
if (sect != nullptr && FAF_ConnectArea(sect))
{
updatesectorz(pp->posx, pp->posy, pp->posz, &pp->cursectnum);
// can mess up if below
if (!pp->insector())
{
pp->cursectnum = sectnum;
pp->setcursector(sect);
// adjust the posz to be in a sector
getzsofslope(pp->cursectnum, pp->posx, pp->posy, &cz, &fz);
getzsofslopeptr(pp->cursector(), pp->posx, pp->posy, &cz, &fz);
if (pp->posz > fz)
pp->posz = fz;
@ -2237,7 +2237,6 @@ void DoPlayerSectorUpdatePostMove(PLAYERp pp)
// try again
updatesectorz(pp->posx, pp->posy, pp->posz, &pp->cursectnum);
// ASSERT(pp->cursectnum >= 0);
}
}
else
@ -2994,7 +2993,7 @@ void DoPlayerBeginFall(PLAYERp pp)
void StackedWaterSplash(PLAYERp pp)
{
if (FAF_ConnectArea(pp->cursectnum))
if (FAF_ConnectArea(pp->cursector()))
{
auto sectnum = pp->cursector();
@ -3367,7 +3366,7 @@ void DoPlayerClimb(PLAYERp pp)
DoPlayerHorizon(pp, pp->input.horz, 1);
}
if (FAF_ConnectArea(pp->cursectnum))
if (FAF_ConnectArea(pp->cursector()))
{
updatesectorz(pp->posx, pp->posy, pp->posz, &pp->cursectnum);
LadderUpdate = true;
@ -3510,7 +3509,7 @@ void DoPlayerCrawl(PLAYERp pp)
if (SectorIsUnderwaterArea(pp->cursector()))
{
// if stacked water - which it should be
if (FAF_ConnectArea(pp->cursectnum))
if (FAF_ConnectArea(pp->cursector()))
{
// adjust the z
pp->posz = pp->cursector()->ceilingz + Z(12);
@ -3878,7 +3877,7 @@ int PlayerCanDiveNoWarp(PLAYERp pp)
// check for diving
if (pp->jump_speed > 1400)
{
if (FAF_ConnectArea(pp->cursectnum))
if (FAF_ConnectArea(pp->cursector()))
{
auto sect = pp->cursector();
@ -4497,7 +4496,7 @@ void DoPlayerDive(PLAYERp pp)
pp->posz += pp->z_speed;
if (pp->z_speed < 0 && FAF_ConnectArea(pp->cursectnum))
if (pp->z_speed < 0 && FAF_ConnectArea(pp->cursector()))
{
if (pp->posz < pp->cursector()->ceilingz + Z(10))
{
@ -7098,7 +7097,7 @@ int DoFootPrints(DSWActor* actor)
if (u->PlayerP->cursectnum < 0)
return 0;
if (FAF_ConnectArea(u->PlayerP->cursectnum))
if (FAF_ConnectArea(u->PlayerP->cursector()))
return 0;
if (u->PlayerP->NumFootPrints > 0)

View file

@ -248,7 +248,7 @@ FAFhitscan(int32_t x, int32_t y, int32_t z, sectortype* sect,
getzsofslopeptr(hitinfo->sector(), hitinfo->pos.x, hitinfo->pos.y, &hiz, &loz);
if (abs(hitinfo->pos.z - loz) < Z(4))
{
if (FAF_ConnectFloor(sectnum(hitinfo->sector())) && !TEST(hitinfo->sector()->floorstat, FLOOR_STAT_FAF_BLOCK_HITSCAN))
if (FAF_ConnectFloor(hitinfo->sector()) && !TEST(hitinfo->sector()->floorstat, FLOOR_STAT_FAF_BLOCK_HITSCAN))
{
updatesectorz(e_hitinfo.pos.x, e_hitinfo.pos.y, e_hitinfo.pos.z + Z(12), &newsector);
plax_found = true;
@ -256,7 +256,7 @@ FAFhitscan(int32_t x, int32_t y, int32_t z, sectortype* sect,
}
else if (labs(e_hitinfo.pos.z - hiz) < Z(4))
{
if (FAF_ConnectCeiling(sectnum(hitinfo->sector())) && !TEST(sector[e_hitinfo.sect].floorstat, CEILING_STAT_FAF_BLOCK_HITSCAN))
if (FAF_ConnectCeiling(hitinfo->sector()) && !TEST(hitinfo->sector()->floorstat, CEILING_STAT_FAF_BLOCK_HITSCAN))
{
updatesectorz(hitinfo->pos.x, hitinfo->pos.y, hitinfo->pos.z - Z(12), &newsector);
plax_found = true;
@ -279,7 +279,6 @@ bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, sectortype* sects,
auto newsect = sects;
int xvect, yvect, zvect;
short ang;
hitdata_t hitinfo;
int dist;
bool plax_found = false;
vec3_t s = { xs, ys, zs };
@ -314,19 +313,21 @@ bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, sectortype* sects,
else
zvect = 0;
hitscan(&s, sectnum(sects), xvect, yvect, zvect,
&hitinfo, CLIPMASK_MISSILE);
hitdata_t e_hitinfo;
hitscan(&s, sectnum(sects), xvect, yvect, zvect, &e_hitinfo, CLIPMASK_MISSILE);
HITINFO hitinfo;
hitinfo.set(&e_hitinfo);
if (hitinfo.sect < 0)
if (hitinfo.sector() == nullptr)
return false;
// make sure it hit JUST a sector before doing a check
if (hitinfo.wall < 0 && hitinfo.sprite < 0)
if (hitinfo.wall() == nullptr && hitinfo.hitactor == nullptr)
{
getzsofslope(hitinfo.sect, hitinfo.pos.x, hitinfo.pos.y, &hiz, &loz);
getzsofslopeptr(hitinfo.sector(), hitinfo.pos.x, hitinfo.pos.y, &hiz, &loz);
if (labs(hitinfo.pos.z - loz) < Z(4))
{
if (FAF_ConnectFloor(hitinfo.sect))
if (FAF_ConnectFloor(hitinfo.sector()))
{
updatesectorz(hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z + Z(12), &newsect);
plax_found = true;
@ -334,7 +335,7 @@ bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, sectortype* sects,
}
else if (labs(hitinfo.pos.z - hiz) < Z(4))
{
if (FAF_ConnectCeiling(hitinfo.sect))
if (FAF_ConnectCeiling(hitinfo.sector()))
{
updatesectorz(hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z - Z(12), &newsect);
plax_found = true;
@ -390,7 +391,7 @@ bool SectorZadjust(const Collision& ceilhit, int32_t* hiz, const Collision& flor
auto hit_sector = florhit.sector();
// don't jack with connect sectors
if (FAF_ConnectFloor(sectnum(hit_sector)))
if (FAF_ConnectFloor(hit_sector))
{
// rippers were dying through the floor in $rock
if (TEST(hit_sector->floorstat, CEILING_STAT_FAF_BLOCK_HITSCAN))
@ -444,7 +445,7 @@ bool SectorZadjust(const Collision& ceilhit, int32_t* hiz, const Collision& flor
auto hit_sector = ceilhit.sector();
// don't jack with connect sectors
if (FAF_ConnectCeiling(sectnum(hit_sector)))
if (FAF_ConnectCeiling(hit_sector))
{
if (TEST(hit_sector->extra, SECTFX_Z_ADJUST))
{
@ -510,6 +511,7 @@ static void getzrange(vec3_t* pos, int16_t sectnum, int32_t* hiz, Collision* cei
void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit, int32_t* loz, Collision* florhit, int32_t clipdist, int32_t clipmask)
{
sectortype* sect = &sector[sectnum];
int foo1;
Collision foo2;
bool SkipFAFcheck;
@ -520,7 +522,7 @@ void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit,
// because the ceiling and floors get moved out of the way for drawing.
// early out to regular routine
if (sectnum < 0 || !FAF_ConnectArea(sectnum))
if (sectnum < 0 || !FAF_ConnectArea(sect))
{
getzrange(&pos, sectnum, hiz, ceilhit, loz, florhit, clipdist, clipmask);
SectorZadjust(*ceilhit, hiz, *florhit, loz);
@ -535,7 +537,7 @@ void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit,
if (SkipFAFcheck)
return;
if (FAF_ConnectCeiling(sectnum))
if (FAF_ConnectCeiling(sect))
{
int uppersect = sectnum;
int newz = *hiz - Z(2);
@ -550,7 +552,7 @@ void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit,
getzrange(&npos, uppersect, hiz, ceilhit, &foo1, &foo2, clipdist, clipmask);
SectorZadjust(*ceilhit, hiz, trash, nullptr);
}
else if (FAF_ConnectFloor(sectnum) && !TEST(sector[sectnum].floorstat, FLOOR_STAT_FAF_BLOCK_HITSCAN))
else if (FAF_ConnectFloor(sect) && !TEST(sect->floorstat, FLOOR_STAT_FAF_BLOCK_HITSCAN))
{
int lowersect = sectnum;
int newz = *loz + Z(2);
@ -568,10 +570,11 @@ void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit,
}
}
void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t sectnum,
void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t const sectnum,
int32_t* hiz, Collision* ceilhit,
int32_t* loz, Collision* florhit)
{
auto sect = &sector[sectnum];
int foo1;
Collision foo2;
bool SkipFAFcheck;
@ -582,7 +585,7 @@ void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t sectnum,
// because the ceiling and floors get moved out of the way for drawing.
// early out to regular routine
if (!FAF_ConnectArea(sectnum))
if (!FAF_ConnectArea(sect))
{
getzrangepoint(x, y, z, sectnum, hiz, ceilhit, loz, florhit);
SectorZadjust(*ceilhit, hiz, *florhit, loz);
@ -597,7 +600,7 @@ void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t sectnum,
if (SkipFAFcheck)
return;
if (FAF_ConnectCeiling(sectnum))
if (FAF_ConnectCeiling(sect))
{
int uppersect = sectnum;
int newz = *hiz - Z(2);
@ -610,8 +613,7 @@ void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t sectnum,
getzrangepoint(x, y, newz, uppersect, hiz, ceilhit, &foo1, &foo2);
SectorZadjust(*ceilhit, hiz, trash, nullptr);
}
else if (FAF_ConnectFloor(sectnum) && !TEST(sector[sectnum].floorstat, FLOOR_STAT_FAF_BLOCK_HITSCAN))
//if (FAF_ConnectFloor(sectnum))
else if (FAF_ConnectFloor(sect) && !TEST(sect->floorstat, FLOOR_STAT_FAF_BLOCK_HITSCAN))
{
int lowersect = sectnum;
int newz = *loz + Z(2);

View file

@ -6546,7 +6546,7 @@ Collision move_sprite(DSWActor* actor, int xchange, int ychange, int zchange, in
}
// extra processing for Stacks and warping
if (FAF_ConnectArea(spr->sectnum))
if (FAF_ConnectArea(spr->sector()))
SetActorZ(actor, &spr->pos);
if (TEST(sector[spr->sectnum].extra, SECTFX_WARP_SECTOR))
@ -6749,7 +6749,7 @@ Collision move_missile(DSWActor* actor, int xchange, int ychange, int zchange, i
sp->z = clippos.z;
}
if (FAF_ConnectArea(sp->sectnum))
if (FAF_ConnectArea(sp->sector()))
SetActorZ(actor, &sp->pos);
if (TEST(sp->sector()->extra, SECTFX_WARP_SECTOR))

View file

@ -18236,7 +18236,7 @@ bool MissileHitDiveArea(DSWActor* actor)
// correctly set underwater bit for missiles
// in Stacked water areas.
if (FAF_ConnectArea(sp->sectnum))
if (FAF_ConnectArea(sp->sector()))
{
if (SectorIsUnderwaterArea(sp->sector()))
SET(u->Flags, SPR_UNDERWATER);

View file

@ -824,7 +824,7 @@ void SpawnZombie2(DSWActor* actor)
if (SectorIsUnderwaterArea(sp->sector()))
return;
if (FAF_ConnectArea(sp->sectnum))
if (FAF_ConnectArea(sp->sector()))
{
auto newsect = sp->sector();
updatesectorz(sp->x, sp->y, sp->z + Z(10), &newsect);