- eliminated sector[] in position checkers

This commit is contained in:
Christoph Oelckers 2021-11-18 00:43:14 +01:00
parent 27af8a52e9
commit c79dace730
2 changed files with 16 additions and 10 deletions

View file

@ -439,6 +439,12 @@ int32_t try_facespr_intersect(uspriteptr_t const spr, vec3_t const in,
#define MAXUPDATESECTORDIST 1536
#define INITIALUPDATESECTORDIST 256
void updatesector(int const x, int const y, int * const sectnum) ATTRIBUTE((nonnull(3)));
inline void updatesector(int const x, int const y, sectortype** const sectp)
{
int sectno = *sectp? (*sectp) - sector : -1;
updatesector(x, y, &sectno);
*sectp = &sector[sectno];
}
void updatesectorz(int32_t const x, int32_t const y, int32_t const z, int * const sectnum) ATTRIBUTE((nonnull(4)));
void updatesectorneighbor(int32_t const x, int32_t const y, int * const sectnum, int32_t initialMaxDistance = INITIALUPDATESECTORDIST, int32_t maxDistance = MAXUPDATESECTORDIST) ATTRIBUTE((nonnull(3)));

View file

@ -342,19 +342,19 @@ void spawntransporter(DDukeActor *actj, DDukeActor* acti, bool beam)
int spawnbloodpoolpart1(DDukeActor *actj, DDukeActor* acti)
{
auto sp = acti->s;
int s1 = sp->sectnum;
auto s1 = sp->sector();
updatesector(sp->x + 108, sp->y + 108, &s1);
if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz)
if (s1 && s1->floorz == sp->sector()->floorz)
{
updatesector(sp->x - 108, sp->y - 108, &s1);
if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz)
if (s1 && s1->floorz == sp->sector()->floorz)
{
updatesector(sp->x + 108, sp->y - 108, &s1);
if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz)
if (s1 && s1->floorz == sp->sector()->floorz)
{
updatesector(sp->x - 108, sp->y + 108, &s1);
if (s1 >= 0 && sector[s1].floorz != sp->sector()->floorz)
if (s1 && s1->floorz != sp->sector()->floorz)
{
sp->xrepeat = sp->yrepeat = 0; changeactorstat(acti, STAT_MISC); return true;
}
@ -385,19 +385,19 @@ void initfootprint(DDukeActor* actj, DDukeActor* acti)
int sect = sp->sectnum;
if (actj)
{
int s1 = sp->sectnum;
auto s1 = sp->sector();
updatesector(sp->x + 84, sp->y + 84, &s1);
if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz)
if (s1 && s1->floorz == sp->sector()->floorz)
{
updatesector(sp->x - 84, sp->y - 84, &s1);
if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz)
if (s1 && s1->floorz == sp->sector()->floorz)
{
updatesector(sp->x + 84, sp->y - 84, &s1);
if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz)
if (s1 && s1->floorz == sp->sector()->floorz)
{
updatesector(sp->x - 84, sp->y + 84, &s1);
if (s1 >= 0 && sector[s1].floorz != sp->sector()->floorz)
if (s1 && s1->floorz != sp->sector()->floorz)
{
sp->xrepeat = sp->yrepeat = 0; changeactorstat(acti, STAT_MISC); return;
}