Skip to content

Commit

Permalink
- eliminated sector[] in position checkers
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Nov 21, 2021
1 parent 5076cda commit 055a1a0
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 10 deletions.
6 changes: 6 additions & 0 deletions source/build/include/build.h
Expand Up @@ -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)));
Expand Down
20 changes: 10 additions & 10 deletions source/games/duke/src/spawn.cpp
Expand Up @@ -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;
}
Expand Down Expand Up @@ -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;
}
Expand Down

0 comments on commit 055a1a0

Please sign in to comment.