Skip to content

Commit

Permalink
- use pointer variant of nextsectorneighborz.
Browse files Browse the repository at this point in the history
  • Loading branch information
coelckers committed Nov 21, 2021
1 parent 16bd329 commit ec1e4ad
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 28 deletions.
2 changes: 1 addition & 1 deletion source/games/duke/src/bowling.cpp
Expand Up @@ -74,7 +74,7 @@ int pinsectorresetup(int sect)

if (j == -1)
{
j = sector[nextsectorneighborz(sect, sector[sect].ceilingz, -1, -1)].ceilingz;
j = nextsectorneighborzptr(&sector[sect], sector[sect].ceilingz, -1, -1)->ceilingz;
setanimation(sect, anim_ceilingz, sect, j, 64);
return 1;
}
Expand Down
40 changes: 19 additions & 21 deletions source/games/duke/src/sectors.cpp
Expand Up @@ -620,22 +620,20 @@ static void handle_st16(int sn, DDukeActor* actor)
{
sectortype* sptr = &sector[sn];
int i = getanimationgoal(anim_floorz, sn);
int j;
sectortype* sectp;

if (i == -1)
{
i = nextsectorneighborz(sn, sptr->floorz, 1, 1);
if (i == -1)
sectp = nextsectorneighborzptr(sptr, sptr->floorz, 1, 1);
if (sectp == nullptr)
{
i = nextsectorneighborz(sn, sptr->floorz, 1, -1);
if (i == -1) return;
j = sector[i].floorz;
setanimation(sn, anim_floorz, sn, j, sptr->extra);
sectp = nextsectorneighborzptr(sptr, sptr->floorz, 1, -1);
if (sectp == nullptr) return;
setanimation(sn, anim_floorz, sn, sectp->floorz, sptr->extra);
}
else
{
j = sector[i].floorz;
setanimation(sn, anim_floorz, sn, j, sptr->extra);
setanimation(sn, anim_floorz, sn, sectp->floorz, sptr->extra);
}
callsound(sn, actor);
}
Expand All @@ -654,10 +652,10 @@ static void handle_st18(int sn, DDukeActor* actor)

if (i == -1)
{
i = nextsectorneighborz(sn, sptr->floorz, 1, -1);
if (i == -1) i = nextsectorneighborz(sn, sptr->floorz, 1, 1);
if (i == -1) return;
int j = sector[i].floorz;
auto sectp = nextsectorneighborzptr(sptr, sptr->floorz, 1, -1);
if (sectp == nullptr) sectp = nextsectorneighborzptr(sectp, sptr->floorz, 1, 1);
if (sectp == nullptr) return;
int j = sectp->floorz;
int q = sptr->extra;
int l = sptr->ceilingz - sptr->floorz;
setanimation(sn, anim_floorz, sn, j, q);
Expand All @@ -678,9 +676,9 @@ static void handle_st29(int sn, DDukeActor* actor)
int j;

if (sptr->lotag & 0x8000)
j = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz;
j = nextsectorneighborzptr(sptr, sptr->ceilingz, 1, 1)->floorz;
else
j = sector[nextsectorneighborz(sn, sptr->ceilingz, -1, -1)].ceilingz;
j = nextsectorneighborzptr(sn, sptr->ceilingz, -1, -1)->ceilingz;

DukeStatIterator it(STAT_EFFECTOR);
while (auto act2 = it.Next())
Expand Down Expand Up @@ -731,9 +729,9 @@ static void handle_st20(int sn, DDukeActor* actor)
}
else
{
j = nextsectorneighborz(sn, sptr->ceilingz, -1, -1);
auto sectp = nextsectorneighborzptr(sptr, sptr->ceilingz, -1, -1);

if (j >= 0) j = sector[j].ceilingz;
if (sectp) j = sectp->ceilingz;
else
{
sptr->lotag |= 32768;
Expand Down Expand Up @@ -761,14 +759,14 @@ static void handle_st21(int sn, DDukeActor* actor)
if (i >= 0)
{
if (animategoal[i] == sptr->ceilingz)
animategoal[i] = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz;
animategoal[i] = nextsectorneighborzptr(sptr, sptr->ceilingz, 1, 1)->floorz;
else animategoal[i] = sptr->ceilingz;
j = animategoal[i];
}
else
{
if (sptr->ceilingz == sptr->floorz)
j = sector[nextsectorneighborz(sn, sptr->ceilingz, 1, 1)].floorz;
j = nextsectorneighborzptr(sn, sptr->ceilingz, 1, 1)->floorz;
else j = sptr->ceilingz;

sptr->lotag ^= 0x8000;
Expand Down Expand Up @@ -796,9 +794,9 @@ static void handle_st22(int sn, DDukeActor* actor)
}
else
{
q = sector[nextsectorneighborz(sn, sptr->floorz, 1, 1)].floorz;
q = nextsectorneighborzptr(sptr, sptr->floorz, 1, 1)->floorz;
j = setanimation(sn, anim_floorz, sn, q, sptr->extra);
q = sector[nextsectorneighborz(sn, sptr->ceilingz, -1, -1)].ceilingz;
q = nextsectorneighborzptr(sptr, sptr->ceilingz, -1, -1)->ceilingz;
j = setanimation(sn, anim_ceilingz, sn, q, sptr->extra);
}

Expand Down
8 changes: 2 additions & 6 deletions source/games/duke/src/spawn.cpp
Expand Up @@ -763,12 +763,8 @@ void spawneffector(DDukeActor* actor)
case SE_17_WARP_ELEVATOR:
{
t[2] = sectp->floorz; //Stopping loc

int j = nextsectorneighborz(sect, sectp->floorz, -1, -1);
t[3] = sector[j].ceilingz;

j = nextsectorneighborz(sect, sectp->ceilingz, 1, 1);
t[4] = sector[j].floorz;
t[3] = nextsectorneighborzptr(sect, sectp->floorz, -1, -1)->ceilingz;
t[4] = nextsectorneighborzptr(sect, sectp->ceilingz, 1, 1)->floorz;

if (numplayers < 2)
{
Expand Down

0 comments on commit ec1e4ad

Please sign in to comment.