diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 0f4663381..048f264aa 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -852,11 +852,11 @@ static void SpawnPortals() { if (processedTags.Find(spr->hitag) == processedTags.Size()) { - int s1 = spr->sectnum, s2 = spr2->sectnum; - sector[s1].portalflags = PORTAL_SECTOR_FLOOR; - sector[s2].portalflags = PORTAL_SECTOR_CEILING; - sector[s1].portalnum = portalAdd(PORTAL_SECTOR_FLOOR, s2, spr2->x - spr->x, spr2->y - spr->y, spr->hitag); - sector[s2].portalnum = portalAdd(PORTAL_SECTOR_CEILING, s1, spr->x - spr2->x, spr->y - spr2->y, spr->hitag); + sectortype* s1 = spr->sector(), *s2 = spr2->sector(); + s1->portalflags = PORTAL_SECTOR_FLOOR; + s1->portalflags = PORTAL_SECTOR_CEILING; + s2->portalnum = portalAdd(PORTAL_SECTOR_FLOOR, sectnum(s2), spr2->x - spr->x, spr2->y - spr->y, spr->hitag); + s2->portalnum = portalAdd(PORTAL_SECTOR_CEILING, sectnum(s1), spr->x - spr2->x, spr->y - spr2->y, spr->hitag); processedTags.Push(spr->hitag); } else diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index f6620ef93..a0089e27f 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -439,7 +439,7 @@ int setanimation(int animsect, int animtype, walltype* animtarget, int thegoal, bool activatewarpelevators(DDukeActor* actor, int d) //Parm = sectoreffectornum { - int sn = actor->s->sectnum; + auto sect = actor->s->sector(); // See if the sector exists @@ -449,8 +449,8 @@ bool activatewarpelevators(DDukeActor* actor, int d) //Parm = sectoreffectornum { if (act2->s->lotag == SE_17_WARP_ELEVATOR || (isRRRA() && act2->s->lotag == SE_18_INCREMENTAL_SECTOR_RISE_FALL)) if (act2->s->hitag == actor->s->hitag) - if ((abs(sector[sn].floorz - actor->temp_data[2]) > act2->s->yvel) || - (act2->getSector()->hitag == (sector[sn].hitag - d))) + if ((abs(sect->floorz - actor->temp_data[2]) > act2->s->yvel) || + (act2->getSector()->hitag == (sect->hitag - d))) break; } diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 6848469d0..b703b6b02 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -1346,10 +1346,9 @@ void checkhitwall_r(DDukeActor* spr, walltype* wal, int x, int y, int z, int atw if (sn < 0) return; darkestwall = 0; - wal = sector[sn].firstWall(); - for (i = sector[sn].wallnum; i > 0; i--, wal++) - if (wal->shade > darkestwall) - darkestwall = wal->shade; + for (auto& wl : wallsofsector(wal->nextsector)) + if (wl.shade > darkestwall) + darkestwall = wl.shade; j = krand() & 1; DukeStatIterator it(STAT_EFFECTOR); @@ -2602,7 +2601,9 @@ void checksectors_r(int snum) if (isanunderoperator(p->GetActor()->getSector()->lotag)) neartagsector = p->GetActor()->s->sectnum; - if (neartagsector >= 0 && (sector[neartagsector].lotag & 16384)) + auto ntsect = neartagsector < 0? nullptr : §or[neartagsector]; + + if (neartagsector >= 0 && (ntsect->lotag & 16384)) return; if (neartagsprite == nullptr && neartagwall == -1) @@ -2739,7 +2740,7 @@ void checksectors_r(int snum) } } - if (neartagsector >= 0 && (sector[neartagsector].lotag & 16384) == 0 && isanearoperator(sector[neartagsector].lotag)) + if (neartagsector >= 0 && (ntsect->lotag & 16384) == 0 && isanearoperator(ntsect->lotag)) { DukeSectIterator it(neartagsector); while (auto act = it.Next()) diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index 914900274..d2772d413 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -584,7 +584,7 @@ void S_StopSound(int sndNum, DDukeActor* actor, int channel) else soundEngine->StopSound(SOURCE_Actor, actor, channel, -1); // StopSound kills the actor reference so this cannot be delayed until ChannelEnded gets called. At that point the actor may also not be valid anymore. - if (S_IsAmbientSFX(actor) && sector[actor->s->sectnum].lotag < 3) // ST_2_UNDERWATER + if (S_IsAmbientSFX(actor) && actor->s->sector()->lotag < 3) // ST_2_UNDERWATER actor->temp_data[0] = 0; } }