diff --git a/source/build/include/build.h b/source/build/include/build.h index b66793d46ac..17e42a3aec6 100644 --- a/source/build/include/build.h +++ b/source/build/include/build.h @@ -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, §no); + *sectp = §or[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))); diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index a8d8ff964b2..7bfe6c34480 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -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; }