diff --git a/source/games/duke/src/_polymost.cpp b/source/games/duke/src/_polymost.cpp index 045c4ed41..023472476 100644 --- a/source/games/duke/src/_polymost.cpp +++ b/source/games/duke/src/_polymost.cpp @@ -75,17 +75,17 @@ void SE40_Draw(int tag, spritetype *spr, int x, int y, int z, binangle a, fixedh { if (k == tag + 0) { - tempsectorz[spr->sectnum] = sector[spr->sectnum].floorz; - sector[spr->sectnum].floorz += (((z - sector[spr->sectnum].floorz) / 32768) + 1) * 32768; - tempsectorpicnum[spr->sectnum] = sector[spr->sectnum].floorpicnum; - sector[spr->sectnum].floorpicnum = 13; + tempsectorz[spr->sectnum] = spr->sector()->floorz; + spr->sector()->floorz += (((z - spr->sector()->floorz) / 32768) + 1) * 32768; + tempsectorpicnum[spr->sectnum] = spr->sector()->floorpicnum; + spr->sector()->floorpicnum = 13; } if (k == tag + 1) { - tempsectorz[spr->sectnum] = sector[spr->sectnum].ceilingz; - sector[spr->sectnum].ceilingz += (((z - sector[spr->sectnum].ceilingz) / 32768) - 1) * 32768; - tempsectorpicnum[spr->sectnum] = sector[spr->sectnum].ceilingpicnum; - sector[spr->sectnum].ceilingpicnum = 13; + tempsectorz[spr->sectnum] = spr->sector()->ceilingz; + spr->sector()->ceilingz += (((z - spr->sector()->ceilingz) / 32768) - 1) * 32768; + tempsectorpicnum[spr->sectnum] = spr->sector()->ceilingpicnum; + spr->sector()->ceilingpicnum = 13; } } } @@ -108,13 +108,13 @@ void SE40_Draw(int tag, spritetype *spr, int x, int y, int z, binangle a, fixedh { if (k == tag + 0) { - sector[spr->sectnum].floorz = tempsectorz[spr->sectnum]; - sector[spr->sectnum].floorpicnum = tempsectorpicnum[spr->sectnum]; + spr->sector()->floorz = tempsectorz[spr->sectnum]; + spr->sector()->floorpicnum = tempsectorpicnum[spr->sectnum]; } if (k == tag + 1) { - sector[spr->sectnum].ceilingz = tempsectorz[spr->sectnum]; - sector[spr->sectnum].ceilingpicnum = tempsectorpicnum[spr->sectnum]; + spr->sector()->ceilingz = tempsectorz[spr->sectnum]; + spr->sector()->ceilingpicnum = tempsectorpicnum[spr->sectnum]; } }// end if }// end for diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 0830b7df4..bf2b3e1f2 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -293,8 +293,8 @@ void ms(DDukeActor* const actor) int j = actor->temp_data[1]; int k = actor->temp_data[2]; - startwall = sector[s->sectnum].wallptr; - endwall = startwall + sector[s->sectnum].wallnum; + startwall = s->sector()->wallptr; + endwall = startwall + s->sector()->wallnum; for (x = startwall; x < endwall; x++) { rotatepoint( @@ -374,7 +374,7 @@ void movedummyplayers(void) if (ps[p].on_ground && ps[p].on_warping_sector == 1 && sector[ps[p].cursectnum].lotag == 1) { spri->cstat = CSTAT_SPRITE_BLOCK_ALL; - spri->z = sector[spri->sectnum].ceilingz + (27 << 8); + spri->z = spri->sector()->ceilingz + (27 << 8); spri->ang = ps[p].angle.ang.asbuild(); if (act->temp_data[0] == 8) act->temp_data[0] = 0; @@ -382,7 +382,7 @@ void movedummyplayers(void) } else { - if (sector[spri->sectnum].lotag != 2) spri->z = sector[spri->sectnum].floorz; + if (spri->sector()->lotag != 2) spri->z = spri->sector()->floorz; spri->cstat = (short)32768; } } @@ -509,9 +509,9 @@ void moveplayers(void) else { spri->yrepeat = 36; - if (sector[spri->sectnum].lotag != ST_2_UNDERWATER) + if (spri->sector()->lotag != ST_2_UNDERWATER) makeitfall(act); - if (spri->zvel == 0 && sector[spri->sectnum].lotag == ST_1_ABOVE_WATER) + if (spri->zvel == 0 && spri->sector()->lotag == ST_1_ABOVE_WATER) spri->z += (32 << 8); } @@ -529,10 +529,10 @@ void moveplayers(void) } } - if (sector[spri->sectnum].ceilingstat & 1) - spri->shade += (sector[spri->sectnum].ceilingshade - spri->shade) >> 1; + if (spri->sector()->ceilingstat & 1) + spri->shade += (spri->sector()->ceilingshade - spri->shade) >> 1; else - spri->shade += (sector[spri->sectnum].floorshade - spri->shade) >> 1; + spri->shade += (spri->sector()->floorshade - spri->shade) >> 1; } } @@ -595,7 +595,7 @@ void movefx(void) act->temp_data[0] = 0; } } - else if (spri->lotag < 999 && (unsigned)sector[spri->sectnum].lotag < ST_9_SLIDING_ST_DOOR && snd_ambience && sector[spri->sectnum].floorz != sector[spri->sectnum].ceilingz) + else if (spri->lotag < 999 && (unsigned)spri->sector()->lotag < ST_9_SLIDING_ST_DOOR && snd_ambience && spri->sector()->floorz != spri->sector()->ceilingz) { int flags = S_GetUserFlags(spri->lotag); if (flags & SF_MSFX) @@ -904,7 +904,7 @@ void moveflammable(DDukeActor* actor, int tire, int box, int pool) if (box >= 0 && spri->picnum == box) { makeitfall(actor); - actor->ceilingz = sector[spri->sectnum].ceilingz; + actor->ceilingz = spri->sector()->ceilingz; } } @@ -1648,9 +1648,9 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p getglobalz(actor); - if (sector[s->sectnum].ceilingstat & 1) - s->shade += (sector[s->sectnum].ceilingshade - s->shade) >> 1; - else s->shade += (sector[s->sectnum].floorshade - s->shade) >> 1; + if (s->sector()->ceilingstat & 1) + s->shade += (s->sector()->ceilingshade - s->shade) >> 1; + else s->shade += (s->sector()->floorshade - s->shade) >> 1; if (s->z < sector[sect].ceilingz + (32 << 8)) s->z = sector[sect].ceilingz + (32 << 8); @@ -2292,7 +2292,7 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f s->y += MulScale(s->xvel, bsin(s->ang), 14); s->z += s->zvel; - if (floorcheck && s->z >= sector[s->sectnum].floorz) + if (floorcheck && s->z >= s->sector()->floorz) { deletesprite(actor); return false; @@ -2312,7 +2312,7 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f deletesprite(actor); return false; } - if ((sector[s->sectnum].floorstat & 2)) + if ((s->sector()->floorstat & 2)) { deletesprite(actor); return false; @@ -2952,7 +2952,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) while (auto a2 = it.Next()) { auto sj = a2->s; - if (sj->statnum != 10 && sector[sj->sectnum].lotag != 2 && sj->picnum != SECTOREFFECTOR && sj->picnum != LOCATORS) + if (sj->statnum != 10 && sj->sector()->lotag != 2 && sj->picnum != SECTOREFFECTOR && sj->picnum != LOCATORS) { rotatepoint(s->x, s->y, sj->x, sj->y, q, &sj->x, &sj->y); @@ -3604,7 +3604,7 @@ void handle_se10(DDukeActor* actor, const int* specialtags) { if (specialtags) for (int i = 0; specialtags[i]; i++) { - if (sector[s->sectnum].lotag == specialtags[i] && getanimationgoal(anim_ceilingz, s->sectnum) >= 0) + if (s->sector()->lotag == specialtags[i] && getanimationgoal(anim_ceilingz, s->sectnum) >= 0) { return; } @@ -3998,7 +3998,7 @@ void handle_se17(DDukeActor* actor) while ((act2 = it.Next())) { if (actor != act2 && (act2->s->lotag) == 17) - if ((sc->hitag - t[0]) == (sector[act2->s->sectnum].hitag) && sh == (act2->s->hitag)) + if ((sc->hitag - t[0]) == (act2->getSector()->hitag) && sh == (act2->s->hitag)) break; } @@ -4015,10 +4015,10 @@ void handle_se17(DDukeActor* actor) ps[p].pos.x += spr2->x - s->x; ps[p].pos.y += spr2->y - s->y; - ps[p].pos.z = sector[spr2->sectnum].floorz - (sc->floorz - ps[p].pos.z); + ps[p].pos.z = spr2->sector()->floorz - (sc->floorz - ps[p].pos.z); - act3->floorz = sector[spr2->sectnum].floorz; - act3->ceilingz = sector[spr2->sectnum].ceilingz; + act3->floorz = spr2->sector()->floorz; + act3->ceilingz = spr2->sector()->ceilingz; ps[p].bobposx = ps[p].oposx = ps[p].pos.x; ps[p].bobposy = ps[p].oposy = ps[p].pos.y; @@ -4035,15 +4035,15 @@ void handle_se17(DDukeActor* actor) { spr3->x += spr2->x - s->x; spr3->y += spr2->y - s->y; - spr3->z = sector[spr2->sectnum].floorz - (sc->floorz - spr3->z); + spr3->z = spr2->sector()->floorz - (sc->floorz - spr3->z); spr3->backupz(); changeactorsect(act3, spr2->sectnum); setsprite(act3, spr3->pos); - act3->floorz = sector[spr2->sectnum].floorz; - act3->ceilingz = sector[spr2->sectnum].ceilingz; + act3->floorz = spr2->sector()->floorz; + act3->ceilingz = spr2->sector()->ceilingz; } } @@ -4196,8 +4196,8 @@ void handle_se19(DDukeActor *actor, int BIGFORCE) if (a2->s->lotag == 0 && a2->s->hitag == sh && a2Owner) { q = a2Owner->s->sectnum; - sector[a2->s->sectnum].floorpal = sector[a2->s->sectnum].ceilingpal = sector[q].floorpal; - sector[a2->s->sectnum].floorshade = sector[a2->s->sectnum].ceilingshade = sector[q].floorshade; + a2->getSector()->floorpal = a2->getSector()->ceilingpal = sector[q].floorpal; + a2->getSector()->floorshade = a2->getSector()->ceilingshade = sector[q].floorshade; a2Owner->temp_data[0] = 2; } } @@ -4291,7 +4291,7 @@ void handle_se20(DDukeActor* actor) a2->s->x += x; a2->s->y += l; setsprite(a2, a2->s->pos); - if (sector[a2->s->sectnum].floorstat & 2) + if (a2->getSector()->floorstat & 2) if (a2->s->statnum == 2) makeitfall(a2); } @@ -4550,7 +4550,7 @@ void handle_se24(DDukeActor *actor, int16_t *list1, int16_t *list2, bool scroll, setsprite(a2, s2->pos); - if (sector[s2->sectnum].floorstat & 2) + if (s2->sector()->floorstat & 2) if (s2->statnum == 2) makeitfall(a2); } @@ -4982,15 +4982,15 @@ void getglobalz(DDukeActor* actor) } else if(s->statnum == STAT_PROJECTILE && lz.actor->s->picnum == TILE_APLAYER && actor->GetOwner() == actor) { - actor->ceilingz = sector[s->sectnum].ceilingz; - actor->floorz = sector[s->sectnum].floorz; + actor->ceilingz = s->sector()->ceilingz; + actor->floorz = s->sector()->floorz; } } } else { - actor->ceilingz = sector[s->sectnum].ceilingz; - actor->floorz = sector[s->sectnum].floorz; + actor->ceilingz = s->sector()->ceilingz; + actor->floorz = s->sector()->floorz; } } @@ -5009,7 +5009,7 @@ void makeitfall(DDukeActor* actor) c = 0; else { - if( fi.ceilingspace(s->sectnum) || sector[s->sectnum].lotag == ST_2_UNDERWATER) + if( fi.ceilingspace(s->sectnum) || s->sector()->lotag == ST_2_UNDERWATER) c = gs.gravity/6; else c = gs.gravity; } @@ -5026,13 +5026,13 @@ void makeitfall(DDukeActor* actor) } else { - actor->ceilingz = sector[s->sectnum].ceilingz; - actor->floorz = sector[s->sectnum].floorz; + actor->ceilingz = s->sector()->ceilingz; + actor->floorz = s->sector()->floorz; } if( s->z < actor->floorz-(FOURSLEIGHT) ) { - if( sector[s->sectnum].lotag == 2 && s->zvel > 3122 ) + if( s->sector()->lotag == 2 && s->zvel > 3122 ) s->zvel = 3144; if(s->zvel < 6144) s->zvel += c; @@ -5260,12 +5260,12 @@ void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLO c = 0; else { - if (fi.ceilingspace(s->sectnum) || sector[s->sectnum].lotag == 2) + if (fi.ceilingspace(s->sectnum) || s->sector()->lotag == 2) c = gs.gravity / 6; else c = gs.gravity; } - if (actor->cgg <= 0 || (sector[s->sectnum].floorstat & 2)) + if (actor->cgg <= 0 || (s->sector()->floorstat & 2)) { getglobalz(actor); actor->cgg = 6; @@ -5311,7 +5311,7 @@ void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLO actor->extra = 1; s->zvel = 0; } - else if (s->zvel > 2048 && sector[s->sectnum].lotag != 1) + else if (s->zvel > 2048 && s->sector()->lotag != 1) { short j = s->sectnum; @@ -5324,7 +5324,7 @@ void fall_common(DDukeActor *actor, int playernum, int JIBS6, int DRONE, int BLO S_PlayActorSound(thud, actor); } } - if (sector[s->sectnum].lotag == 1) + if (s->sector()->lotag == 1) s->z += gs.actorinfo[s->picnum].falladjustz; else s->zvel = 0; } diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 52be1a7b2..1fe08fd7a 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -770,9 +770,9 @@ void movefta_d(void) case NUKEBARRELDENTED: case NUKEBARRELLEAKED: case TRIPBOMB: - if (sector[s->sectnum].ceilingstat&1) - s->shade = sector[s->sectnum].ceilingshade; - else s->shade = sector[s->sectnum].floorshade; + if (s->sector()->ceilingstat&1) + s->shade = s->sector()->ceilingshade; + else s->shade = s->sector()->floorshade; act->timetosleep = 0; changeactorstat(act, STAT_STANDABLE); @@ -789,9 +789,9 @@ void movefta_d(void) } if (badguy(act)) { - if (sector[s->sectnum].ceilingstat & 1) - s->shade = sector[s->sectnum].ceilingshade; - else s->shade = sector[s->sectnum].floorshade; + if (s->sector()->ceilingstat & 1) + s->shade = s->sector()->ceilingshade; + else s->shade = s->sector()->floorshade; } } } @@ -1546,7 +1546,7 @@ static bool movefireball(DDukeActor* actor) auto s = actor->s; auto Owner = actor->GetOwner(); - if (sector[s->sectnum].lotag == 2) + if (s->sector()->lotag == 2) { deletesprite(actor); return true; @@ -1712,8 +1712,8 @@ static bool weaponhitsector(DDukeActor* proj, const vec3_t& oldpos, bool firebal if (s->zvel < 0) { - if (sector[s->sectnum].ceilingstat & 1) - if (sector[s->sectnum].ceilingpal == 0) + if (s->sector()->ceilingstat & 1) + if (s->sector()->ceilingpal == 0) { deletesprite(proj); return true; @@ -1763,7 +1763,7 @@ static void weaponcommon_d(DDukeActor* proj) int k, ll; vec3_t oldpos = s->pos; - if (s->picnum == RPG && sector[s->sectnum].lotag == 2) + if (s->picnum == RPG && s->sector()->lotag == 2) { k = s->xvel >> 1; ll = s->zvel >> 1; @@ -1779,7 +1779,7 @@ static void weaponcommon_d(DDukeActor* proj) switch (s->picnum) { case RPG: - if (proj->picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) + if (proj->picnum != BOSS2 && s->xrepeat >= 10 && s->sector()->lotag != 2) { auto spawned = spawn(proj, SMALLSMOKE); spawned->s->z += (1 << 8); @@ -1814,11 +1814,11 @@ static void weaponcommon_d(DDukeActor* proj) s->zvel = -1; } else - if ((s->z > proj->floorz && sector[s->sectnum].lotag != 1) || - (s->z > proj->floorz + (16 << 8) && sector[s->sectnum].lotag == 1)) + if ((s->z > proj->floorz && s->sector()->lotag != 1) || + (s->z > proj->floorz + (16 << 8) && s->sector()->lotag == 1)) { coll.setSector(s->sectnum); - if (sector[s->sectnum].lotag != 1) + if (s->sector()->lotag != 1) s->zvel = 1; } } @@ -1913,7 +1913,7 @@ static void weaponcommon_d(DDukeActor* proj) return; } } - else if (s->picnum == RPG && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(140)) + else if (s->picnum == RPG && s->sector()->lotag == 2 && s->xrepeat >= 10 && rnd(140)) spawn(proj, WATERBUBBLE); } @@ -2097,7 +2097,7 @@ void movetransports_d(void) if (ps[p].GetActor()->s->extra > 0) S_PlayActorSound(DUKE_UNDERWATER, act2); ps[p].oposz = ps[p].pos.z = - sector[Owner->s->sectnum].ceilingz + (7 << 8); + Owner->getSector()->ceilingz + (7 << 8); ps[p].posxv = 4096 - (krand() & 8192); ps[p].posyv = 4096 - (krand() & 8192); @@ -2115,7 +2115,7 @@ void movetransports_d(void) S_PlayActorSound(DUKE_GASP, act2); ps[p].oposz = ps[p].pos.z = - sector[Owner->s->sectnum].floorz - (7 << 8); + Owner->getSector()->floorz - (7 << 8); ps[p].jumping_toggle = 1; ps[p].jumping_counter = 0; @@ -2236,7 +2236,7 @@ void movetransports_d(void) { spr2->x += (Owner->s->x - spr->x); spr2->y += (Owner->s->y - spr->y); - spr2->z -= spr->z - sector[Owner->s->sectnum].floorz; + spr2->z -= spr->z - Owner->getSector()->floorz; spr2->ang = Owner->s->ang; spr2->backupang(); @@ -2273,7 +2273,7 @@ void movetransports_d(void) case 1: spr2->x += (Owner->s->x - spr->x); spr2->y += (Owner->s->y - spr->y); - spr2->z = sector[Owner->s->sectnum].ceilingz + ll; + spr2->z = Owner->getSector()->ceilingz + ll; spr2->backupz(); @@ -2283,7 +2283,7 @@ void movetransports_d(void) case 2: spr2->x += (Owner->s->x - spr->x); spr2->y += (Owner->s->y - spr->y); - spr2->z = sector[Owner->s->sectnum].floorz - ll; + spr2->z = Owner->getSector()->floorz - ll; spr2->backupz(); @@ -2764,11 +2764,11 @@ static void flamethrowerflame(DDukeActor *actor) coll.setSector(s->sectnum); s->zvel = -1; } - else if ((s->z > actor->floorz && sector[s->sectnum].lotag != 1) - || (s->z > actor->floorz + (16 << 8) && sector[s->sectnum].lotag == 1)) + else if ((s->z > actor->floorz && s->sector()->lotag != 1) + || (s->z > actor->floorz + (16 << 8) && s->sector()->lotag == 1)) { coll.setSector(s->sectnum); - if (sector[s->sectnum].lotag != 1) + if (s->sector()->lotag != 1) s->zvel = 1; } } @@ -2859,7 +2859,7 @@ static void heavyhbomb(DDukeActor *actor) if (s->yvel > 0 || (s->yvel == 0 && actor->floorz == sector[sect].floorz)) S_PlayActorSound(PIPEBOMB_BOUNCE, actor); s->zvel = -((4 - s->yvel) << 8); - if (sector[s->sectnum].lotag == 2) + if (s->sector()->lotag == 2) s->zvel >>= 2; s->yvel++; } @@ -2876,7 +2876,7 @@ static void heavyhbomb(DDukeActor *actor) MulScale(s->xvel, bsin(s->ang), 14), s->zvel, CLIPMASK0, coll); - if (sector[s->sectnum].lotag == 1 && s->zvel == 0) + if (s->sector()->lotag == 1 && s->zvel == 0) { s->z += (32 << 8); if (t[5] == 0) @@ -3971,11 +3971,11 @@ void move_d(DDukeActor *actor, int playernum, int xvel) if (a) { - if (sector[spr->sectnum].ceilingstat & 1) - spr->shade += (sector[spr->sectnum].ceilingshade - spr->shade) >> 1; - else spr->shade += (sector[spr->sectnum].floorshade - spr->shade) >> 1; + if (spr->sector()->ceilingstat & 1) + spr->shade += (spr->sector()->ceilingshade - spr->shade) >> 1; + else spr->shade += (spr->sector()->floorshade - spr->shade) >> 1; - if (sector[spr->sectnum].floorpicnum == MIRROR) + if (spr->sector()->floorpicnum == MIRROR) deletesprite(actor); } } diff --git a/source/games/duke/src/actors_lava.cpp b/source/games/duke/src/actors_lava.cpp index db5981df4..84543d9ba 100644 --- a/source/games/duke/src/actors_lava.cpp +++ b/source/games/duke/src/actors_lava.cpp @@ -128,7 +128,7 @@ void addtorch(spritetype* s) I_Error("Too many torch effects"); torchsector[torchcnt] = s->sectnum; - torchsectorshade[torchcnt] = sector[s->sectnum].floorshade; + torchsectorshade[torchcnt] = s->sector()->floorshade; torchtype[torchcnt] = s->lotag; torchcnt++; } @@ -139,7 +139,7 @@ void addlightning(spritetype* s) I_Error("Too many lightnin effects"); lightninsector[lightnincnt] = s->sectnum; - lightninsectorshade[lightnincnt] = sector[s->sectnum].floorshade; + lightninsectorshade[lightnincnt] = s->sector()->floorshade; lightnincnt++; } diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index ec8420f30..6210623b0 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -592,9 +592,9 @@ void movefta_r(void) case NUKEBARREL: case NUKEBARRELDENTED: case NUKEBARRELLEAKED: - if (sector[s->sectnum].ceilingstat & 1) - s->shade = sector[s->sectnum].ceilingshade; - else s->shade = sector[s->sectnum].floorshade; + if (s->sector()->ceilingstat & 1) + s->shade = s->sector()->ceilingshade; + else s->shade = s->sector()->floorshade; act->timetosleep = 0; changeactorstat(act, STAT_STANDABLE); @@ -614,9 +614,9 @@ void movefta_r(void) } if (/*!j &&*/ badguy(act)) // this is like RedneckGDX. j is uninitialized here, i.e. most likely not 0. { - if (sector[s->sectnum].ceilingstat & 1) - s->shade = sector[s->sectnum].ceilingshade; - else s->shade = sector[s->sectnum].floorshade; + if (s->sector()->ceilingstat & 1) + s->shade = s->sector()->ceilingshade; + else s->shade = s->sector()->floorshade; if (s->picnum == HEN || s->picnum == COW || s->picnum == PIG || s->picnum == DOGRUN || ((isRRRA()) && s->picnum == RABBIT)) { @@ -1098,7 +1098,7 @@ static void chickenarrow(DDukeActor* actor) { auto s = actor->s; s->hitag++; - if (actor->picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) + if (actor->picnum != BOSS2 && s->xrepeat >= 10 && s->sector()->lotag != 2) { auto spawned = spawn(actor, SMALLSMOKE); spawned->s->z += (1 << 8); @@ -1320,8 +1320,8 @@ bool weaponhitsector(DDukeActor *proj, const vec3_t& oldpos) if (s->zvel < 0) { - if (sector[s->sectnum].ceilingstat & 1) - if (sector[s->sectnum].ceilingpal == 0) + if (s->sector()->ceilingstat & 1) + if (s->sector()->ceilingpal == 0) { deletesprite(proj); return true; @@ -1359,12 +1359,12 @@ static void weaponcommon_r(DDukeActor *proj) p = -1; - if (s->picnum == RPG && sector[s->sectnum].lotag == 2) + if (s->picnum == RPG && s->sector()->lotag == 2) { k = s->xvel >> 1; ll = s->zvel >> 1; } - else if (isRRRA() && s->picnum == RPG2 && sector[s->sectnum].lotag == 2) + else if (isRRRA() && s->picnum == RPG2 && s->sector()->lotag == 2) { k = s->xvel >> 1; ll = s->zvel >> 1; @@ -1382,7 +1382,7 @@ static void weaponcommon_r(DDukeActor *proj) switch (s->picnum) { case RPG: - if (proj->picnum != BOSS2 && s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) + if (proj->picnum != BOSS2 && s->xrepeat >= 10 && s->sector()->lotag != 2) { spawn(proj, SMALLSMOKE)->s->z += (1 << 8); } @@ -1401,7 +1401,7 @@ static void weaponcommon_r(DDukeActor *proj) } else makeitfall(proj); - if (s->xrepeat >= 10 && sector[s->sectnum].lotag != 2) + if (s->xrepeat >= 10 && s->sector()->lotag != 2) { spawn(proj, SMALLSMOKE)->s->z += (1 << 8); } @@ -1417,7 +1417,7 @@ static void weaponcommon_r(DDukeActor *proj) if (FindDistance2D(s->x - proj->temp_actor->s->x, s->y - proj->temp_actor->s->y) < 256) coll.setSprite(proj->temp_actor); - if (s->sectnum < 0) // || (isRR() && sector[s->sectnum].filler == 800)) + if (s->sectnum < 0) // || (isRR() && s->sector()->filler == 800)) { deletesprite(proj); return; @@ -1434,7 +1434,7 @@ static void weaponcommon_r(DDukeActor *proj) if (s->z > proj->floorz) { coll.setSector(s->sectnum); - if (sector[s->sectnum].lotag != 1) + if (s->sector()->lotag != 1) s->zvel = 1; } } @@ -1493,7 +1493,7 @@ static void weaponcommon_r(DDukeActor *proj) deletesprite(proj); return; } - if ((s->picnum == RPG || (isRRRA() && s->picnum == RPG2)) && sector[s->sectnum].lotag == 2 && s->xrepeat >= 10 && rnd(184)) + if ((s->picnum == RPG || (isRRRA() && s->picnum == RPG2)) && s->sector()->lotag == 2 && s->xrepeat >= 10 && rnd(184)) spawn(proj, WATERBUBBLE); } @@ -2089,7 +2089,7 @@ static void rrra_specialstats() s->extra = 1; } movesprite_ex(act, 0, 0, -300, CLIPMASK0, coll); - if (sector[s->sectnum].ceilingz + (4 << 8) > s->z) + if (s->sector()->ceilingz + (4 << 8) > s->z) { s->picnum = 0; s->extra = 100; @@ -2097,7 +2097,7 @@ static void rrra_specialstats() } else if (s->extra == 200) { - setsprite(act, s->x, s->y, sector[s->sectnum].floorz - 10); + setsprite(act, s->x, s->y, s->sector()->floorz - 10); s->extra = 1; s->picnum = PIG + 11; spawn(act, TRANSPORTERSTAR); @@ -2326,8 +2326,8 @@ void rr_specialstats() if (s->hitag == 100) { s->z += (4 << 8); - if (s->z >= sector[s->sectnum].floorz + 15168) - s->z = sector[s->sectnum].floorz + 15168; + if (s->z >= s->sector()->floorz + 15168) + s->z = s->sector()->floorz + 15168; } if (s->picnum == LUMBERBLADE) @@ -2336,7 +2336,7 @@ void rr_specialstats() if (s->extra == 192) { s->hitag = 0; - s->z = sector[s->sectnum].floorz - 15168; + s->z = s->sector()->floorz - 15168; s->extra = 0; s->picnum = RRTILE3410; DukeStatIterator it2(STAT_DEFAULT); @@ -2558,7 +2558,7 @@ static void heavyhbomb(DDukeActor *actor) } } s->zvel = -((4 - s->yvel) << 8); - if (sector[s->sectnum].lotag == 2) + if (s->sector()->lotag == 2) s->zvel >>= 2; s->yvel++; } @@ -2574,7 +2574,7 @@ static void heavyhbomb(DDukeActor *actor) MulScale(s->xvel, bsin(s->ang), 14), s->zvel, CLIPMASK0, coll); - if (sector[s->sectnum].lotag == 1 && s->zvel == 0) + if (s->sector()->lotag == 1 && s->zvel == 0) { s->z += (32 << 8); if (t[5] == 0) @@ -2660,7 +2660,7 @@ DETONATEB: case CHEERBOMB: m = gs.morterblastradius; break; } - if (sector[s->sectnum].lotag != 800) + if (s->sector()->lotag != 800) { fi.hitradius(actor, m, x >> 2, x >> 1, x - (x >> 2), x); spawn(actor, EXPLOSION2); @@ -2757,7 +2757,7 @@ static int henstand(DDukeActor *actor) return 1; } } - if (sector[s->sectnum].lotag == 900) + if (s->sector()->lotag == 900) s->xvel = 0; if (s->xvel) { @@ -2815,7 +2815,7 @@ static int henstand(DDukeActor *actor) return 2;//deletesprite(actor); still needs to run a script but should not do on a deleted object } } - else if (sector[s->sectnum].lotag == 900) + else if (s->sector()->lotag == 900) { if (s->picnum == BOWLINGBALL) ballreturn(actor); @@ -2980,7 +2980,7 @@ void moveactors_r(void) deletesprite(act); continue; } - if (sector[s->sectnum].lotag == 900) + if (s->sector()->lotag == 900) { S_StopSound(356, nullptr); } @@ -3130,8 +3130,8 @@ void moveexplosions_r(void) // STATNUM 5 switch (s->picnum) { case SHOTGUNSPRITE: - if (sector[s->sectnum].lotag == 800) - if (s->z >= sector[s->sectnum].floorz - (8 << 8)) + if (s->sector()->lotag == 800) + if (s->z >= s->sector()->floorz - (8 << 8)) { deletesprite(act); continue; @@ -3220,7 +3220,7 @@ void moveexplosions_r(void) // STATNUM 5 continue; case FEATHER + 1: // feather act->floorz = s->z = getflorzofslope(s->sectnum, s->x, s->y); - if (sector[s->sectnum].lotag == 800) + if (s->sector()->lotag == 800) { deletesprite(act); continue; @@ -3229,8 +3229,8 @@ void moveexplosions_r(void) // STATNUM 5 case FEATHER: if (!money(act, BLOODPOOL)) continue; - if (sector[s->sectnum].lotag == 800) - if (s->z >= sector[s->sectnum].floorz - (8 << 8)) + if (s->sector()->lotag == 800) + if (s->z >= s->sector()->floorz - (8 << 8)) { deletesprite(act); continue; @@ -3283,8 +3283,8 @@ void moveexplosions_r(void) // STATNUM 5 if (!jibs(act, JIBS6, false, true, true, s->picnum == DUKELEG || s->picnum == DUKETORSO || s->picnum == DUKEGUN, isRRRA() && (s->picnum == RRTILE2465 || s->picnum == RRTILE2560))) continue; - if (sector[s->sectnum].lotag == 800) - if (s->z >= sector[s->sectnum].floorz - (8 << 8)) + if (s->sector()->lotag == 800) + if (s->z >= s->sector()->floorz - (8 << 8)) { deletesprite(act); continue; @@ -3295,8 +3295,8 @@ void moveexplosions_r(void) // STATNUM 5 case BLOODPOOL: if (!bloodpool(act, false, TIRE)) continue; - if (sector[s->sectnum].lotag == 800) - if (s->z >= sector[s->sectnum].floorz - (8 << 8)) + if (s->sector()->lotag == 800) + if (s->z >= s->sector()->floorz - (8 << 8)) { deletesprite(act); } @@ -3373,7 +3373,7 @@ void handle_se06_r(DDukeActor *actor) ns->s->pal = 33; if (!hulkspawn) { - ns = EGS(s->sectnum, s->x, s->y, sector[s->sectnum].ceilingz + 119428, 3677, -8, 16, 16, 0, 0, 0, actor, 5); + ns = EGS(s->sectnum, s->x, s->y, s->sector()->ceilingz + 119428, 3677, -8, 16, 16, 0, 0, 0, actor, 5); ns->s->cstat = 514; ns->s->pal = 7; ns->s->xrepeat = 80; @@ -3381,7 +3381,7 @@ void handle_se06_r(DDukeActor *actor) ns = spawn(actor, 296); ns->s->cstat = 0; ns->s->cstat |= 32768; - ns->s->z = sector[s->sectnum].floorz - 6144; + ns->s->z = s->sector()->floorz - 6144; deletesprite(actor); return; } @@ -3805,7 +3805,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel) } if (badguy(actor) && spr->extra <= 0) { - if (sector[spr->sectnum].ceilingstat & 1) + if (spr->sector()->ceilingstat & 1) { if (shadedsector[spr->sectnum] == 1) { @@ -3813,12 +3813,12 @@ void move_r(DDukeActor *actor, int pnum, int xvel) } else { - spr->shade += (sector[spr->sectnum].ceilingshade - spr->shade) >> 1; + spr->shade += (spr->sector()->ceilingshade - spr->shade) >> 1; } } else { - spr->shade += (sector[spr->sectnum].floorshade - spr->shade) >> 1; + spr->shade += (spr->sector()->floorshade - spr->shade) >> 1; } } return; @@ -3925,7 +3925,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel) } if (isRRRA()) { - if (sector[spr->sectnum].lotag != 1) + if (spr->sector()->lotag != 1) { switch (spr->picnum) { @@ -3936,7 +3936,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel) break; } } - else if (sector[spr->sectnum].lotag == 1) + else if (spr->sector()->lotag == 1) { switch (spr->picnum) { @@ -3957,7 +3957,7 @@ void move_r(DDukeActor *actor, int pnum, int xvel) if (a) { - if (sector[spr->sectnum].ceilingstat & 1) + if (spr->sector()->ceilingstat & 1) { if (shadedsector[spr->sectnum] == 1) { @@ -3965,12 +3965,12 @@ void move_r(DDukeActor *actor, int pnum, int xvel) } else { - spr->shade += (sector[spr->sectnum].ceilingshade - spr->shade) >> 1; + spr->shade += (spr->sector()->ceilingshade - spr->shade) >> 1; } } - else spr->shade += (sector[spr->sectnum].floorshade - spr->shade) >> 1; + else spr->shade += (spr->sector()->floorshade - spr->shade) >> 1; - if (sector[spr->sectnum].floorpicnum == MIRROR) + if (spr->sector()->floorpicnum == MIRROR) deletesprite(actor); } } @@ -4010,7 +4010,7 @@ static int fallspecial(DDukeActor *actor, int playernum) int sphit = 0; if (isRRRA()) { - if (sector[s->sectnum].lotag == 801) + if (s->sector()->lotag == 801) { if (s->picnum == ROCK) { @@ -4020,7 +4020,7 @@ static int fallspecial(DDukeActor *actor, int playernum) } return 0; } - else if (sector[s->sectnum].lotag == 802) + else if (s->sector()->lotag == 802) { if (s->picnum != APLAYER && badguy(actor) && s->z == actor->floorz - FOURSLEIGHT) { @@ -4030,14 +4030,14 @@ static int fallspecial(DDukeActor *actor, int playernum) } return 0; } - else if (sector[s->sectnum].lotag == 803) + else if (s->sector()->lotag == 803) { if (s->picnum == ROCK2) addspritetodelete(); return 0; } } - if (sector[s->sectnum].lotag == 800) + if (s->sector()->lotag == 800) { if (s->picnum == 40) { @@ -4061,7 +4061,7 @@ static int fallspecial(DDukeActor *actor, int playernum) actor->picnum = SHOTSPARK1; actor->extra = 1; } - else if (isRRRA() && (sector[s->sectnum].floorpicnum == RRTILE7820 || sector[s->sectnum].floorpicnum == RRTILE7768)) + else if (isRRRA() && (s->sector()->floorpicnum == RRTILE7820 || s->sector()->floorpicnum == RRTILE7768)) { if (s->picnum != MINION && s->pal != 19) { diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index fe48e4d87..d43219b48 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -134,10 +134,10 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int continue; } - if (sector[t->sectnum].ceilingstat & 1) - l = sector[t->sectnum].ceilingshade; + if (t->sector()->ceilingstat & 1) + l = t->sector()->ceilingshade; else - l = sector[t->sectnum].floorshade; + l = t->sector()->floorshade; if (l < -127) l = -127; if (l > 128) l = 127; @@ -403,7 +403,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int else t->cstat &= ~4; } - if (sector[t->sectnum].lotag == 2) k += 1795 - 1405; + if (t->sector()->lotag == 2) k += 1795 - 1405; else if ((h->floorz - s->z) > (64 << 8)) k += 60; t->picnum += k; @@ -412,7 +412,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int goto PALONLY; } - if (ps[p].on_crane == nullptr && (sector[s->sectnum].lotag & 0x7ff) != 1) + if (ps[p].on_crane == nullptr && (s->sector()->lotag & 0x7ff) != 1) { l = s->z - ps[p].GetActor()->floorz + (3 << 8); if (l > 1024 && s->yrepeat > 32 && s->extra > 0) @@ -489,7 +489,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int break; case WATERBUBBLE: - if (sector[t->sectnum].floorpicnum == FLOORSLIME) + if (t->sector()->floorpicnum == FLOORSLIME) { t->pal = 7; break; @@ -636,7 +636,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int { case LASERLINE: if (!Owner) break; - if (sector[t->sectnum].lotag == 2) t->pal = 8; + if (t->sector()->lotag == 2) t->pal = 8; t->z = Owner->z - (3 << 8); if (gs.lasermode == 2 && ps[screenpeek].heat_on == 0) t->yrepeat = 0; @@ -665,7 +665,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int case BURNING2: if (!Owner) break; if (Owner->picnum != TREE1 && Owner->picnum != TREE2) - t->z = sector[t->sectnum].floorz; + t->z = t->sector()->floorz; t->shade = -127; break; case COOLEXPLOSION1: @@ -748,7 +748,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int } h->dispicnum = t->picnum; - if (sector[t->sectnum].floorpicnum == MIRROR) + if (t->sector()->floorpicnum == MIRROR) t->xrepeat = t->yrepeat = 0; } } diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 0db2e2ccb..0c736b211 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -119,7 +119,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int } } - if (sector[t->sectnum].ceilingstat & 1) + if (t->sector()->ceilingstat & 1) { if (badguy(s)) l = s->shade; @@ -127,7 +127,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int l = s->shade; } else - l = sector[t->sectnum].floorshade; + l = t->sector()->floorshade; if (l < -127) l = -127; if (l > 128) l = 127; @@ -452,7 +452,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int else t->cstat &= ~4; } - if (sector[t->sectnum].lotag == 2) k += 1795 - 1405; + if (t->sector()->lotag == 2) k += 1795 - 1405; else if ((h->floorz - s->z) > (64 << 8)) k += 60; t->picnum += k; @@ -461,7 +461,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int goto PALONLY; } - if (ps[p].on_crane == nullptr && (sector[s->sectnum].lotag & 0x7ff) != 1) + if (ps[p].on_crane == nullptr && (s->sector()->lotag & 0x7ff) != 1) { l = s->z - ps[p].GetActor()->floorz + (3 << 8); if (l > 1024 && s->yrepeat > 32 && s->extra > 0) @@ -624,7 +624,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int break; case WATERBUBBLE: - if (sector[t->sectnum].floorpicnum == FLOORSLIME) + if (t->sector()->floorpicnum == FLOORSLIME) { t->pal = 7; break; @@ -825,7 +825,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int case FIRE: case BURNING: if (Owner && Owner->picnum != TREE1 && Owner->picnum != TREE2) - t->z = sector[t->sectnum].floorz; + t->z = t->sector()->floorz; t->shade = -127; break; case WALLLIGHT3: @@ -978,7 +978,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int } h->dispicnum = t->picnum; - if (sector[t->sectnum].floorpicnum == MIRROR) + if (t->sector()->floorpicnum == MIRROR) t->xrepeat = t->yrepeat = 0; } } diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index a713e66ae..29e3f5894 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2282,10 +2282,10 @@ int ParseState::parse(void) parseifelse(ud.coop || numplayers > 2); break; case concmd_ifonmud: - parseifelse(abs(g_sp->z - sector[g_sp->sectnum].floorz) < (32 << 8) && sector[g_sp->sectnum].floorpicnum == 3073); // eew, hard coded tile numbers.. :? + parseifelse(abs(g_sp->z - g_sp->sector()->floorz) < (32 << 8) && g_sp->sector()->floorpicnum == 3073); // eew, hard coded tile numbers.. :? break; case concmd_ifonwater: - parseifelse( abs(g_sp->z-sector[g_sp->sectnum].floorz) < (32<<8) && sector[g_sp->sectnum].lotag == ST_1_ABOVE_WATER); + parseifelse( abs(g_sp->z-g_sp->sector()->floorz) < (32<<8) && g_sp->sector()->lotag == ST_1_ABOVE_WATER); break; case concmd_ifmotofast: parseifelse(ps[g_p].MotoSpeed > 60); @@ -2306,7 +2306,7 @@ int ParseState::parse(void) break; case concmd_ifinwater: - parseifelse( sector[g_sp->sectnum].lotag == 2); + parseifelse( g_sp->sector()->lotag == 2); break; case concmd_ifcount: insptr++; @@ -2479,14 +2479,14 @@ int ParseState::parse(void) parseifelse(PlayerInput(g_p, SB_OPEN)); break; case concmd_ifoutside: - parseifelse(sector[g_sp->sectnum].ceilingstat & 1); + parseifelse(g_sp->sector()->ceilingstat & 1); break; case concmd_ifmultiplayer: parseifelse(ud.multimode > 1); break; case concmd_operate: insptr++; - if( sector[g_sp->sectnum].lotag == 0 ) + if( g_sp->sector()->lotag == 0 ) { int16_t neartagsector, neartagwall; DDukeActor* neartagsprite; @@ -3422,19 +3422,19 @@ int ParseState::parse(void) case concmd_sectgetlotag: { insptr++; - SetGameVarID(g_iLoTagID, sector[g_sp->sectnum].lotag, g_ac, g_p); + SetGameVarID(g_iLoTagID, g_sp->sector()->lotag, g_ac, g_p); break; } case concmd_sectgethitag: { insptr++; - SetGameVarID(g_iHiTagID, sector[g_sp->sectnum].hitag, g_ac, g_p); + SetGameVarID(g_iHiTagID, g_sp->sector()->hitag, g_ac, g_p); break; } case concmd_gettexturefloor: { insptr++; - SetGameVarID(g_iTextureID, sector[g_sp->sectnum].floorpicnum, g_ac, g_p); + SetGameVarID(g_iTextureID, g_sp->sector()->floorpicnum, g_ac, g_p); break; } @@ -3571,7 +3571,7 @@ int ParseState::parse(void) case concmd_gettextureceiling: { insptr++; - SetGameVarID(g_iTextureID, sector[g_sp->sectnum].ceilingpicnum, g_ac, g_p); + SetGameVarID(g_iTextureID, g_sp->sector()->ceilingpicnum, g_ac, g_p); break; } case concmd_ifvarvarand: diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index d9ef28f46..23484a6b2 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -176,7 +176,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, int sx, int sy, int if (badguy(actor) && (s->hitag & face_player_smart) != 0) sa = (short)(s->ang + (krand() & 31) - 16); - if (sector[s->sectnum].lotag == 2 && (krand() % 5) == 0) + if (s->sector()->lotag == 2 && (krand() % 5) == 0) spawned = spawn(actor, WATERBUBBLE); } else @@ -186,7 +186,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, int sx, int sy, int vel = (int)((((512 - (1024 - abs(abs(getangle(sx - ps[p].oposx, sy - ps[p].oposy) - sa) - 1024))) * 0.001953125f) * ps[p].GetActor()->s->xvel) + 400); - if (sector[s->sectnum].lotag == 2 && (krand() % 5) == 0) + if (s->sector()->lotag == 2 && (krand() % 5) == 0) spawned = spawn(actor, WATERBUBBLE); } @@ -2885,9 +2885,9 @@ void processinput_d(int snum) if (p->spritebridge == 0) { - j = sector[s->sectnum].floorpicnum; + j = s->sector()->floorpicnum; - if (j == PURPLELAVA || sector[s->sectnum].ceilingpicnum == PURPLELAVA) + if (j == PURPLELAVA || s->sector()->ceilingpicnum == PURPLELAVA) { if (p->boot_amount > 0) { @@ -3076,8 +3076,8 @@ HORIZONLY: { if (abs(pact->floorz - pact->ceilingz) < (48 << 8) || j) { - if (!(sector[s->sectnum].lotag & 0x8000) && (isanunderoperator(sector[s->sectnum].lotag) || - isanearoperator(sector[s->sectnum].lotag))) + if (!(s->sector()->lotag & 0x8000) && (isanunderoperator(s->sector()->lotag) || + isanearoperator(s->sector()->lotag))) fi.activatebysector(s->sectnum, pact); if (j) { diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 00a159943..eb1e43850 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -126,11 +126,11 @@ static void shootmelee(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, ny = hity + (effector->GetOwner()->s->y - effector->s->y); if (sector[hitsect].lotag == 161) { - nz = sector[effector->GetOwner()->s->sectnum].floorz; + nz = effector->GetOwner()->getSector()->floorz; } else { - nz = sector[effector->GetOwner()->s->sectnum].ceilingz; + nz = effector->GetOwner()->getSector()->ceilingz; } hitscan(nx, ny, nz, effector->GetOwner()->s->sectnum, bcos(sa), bsin(sa), zvel << 6, &hitsect, &hitwall, &hitsprt, &hitx, &hity, &hitz, CLIPMASK1); @@ -283,11 +283,11 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa ny = hity + (effector->GetOwner()->s->y - effector->s->y); if (sector[hitsect].lotag == 161) { - nz = sector[effector->GetOwner()->s->sectnum].floorz; + nz = effector->GetOwner()->getSector()->floorz; } else { - nz = sector[effector->GetOwner()->s->sectnum].ceilingz; + nz = effector->GetOwner()->getSector()->ceilingz; } hitscan(nx, ny, nz, effector->GetOwner()->s->sectnum, bcos(sa), bsin(sa), zvel << 6, &hitsect, &hitwall, &hitsprt, &hitx, &hity, &hitz, CLIPMASK1); @@ -3620,7 +3620,7 @@ void processinput_r(int snum) if (p->spritebridge == 0) { - int j = sector[s->sectnum].floorpicnum; + int j = s->sector()->floorpicnum; k = 0; if (p->on_ground && truefdist <= gs.playerheight + (16 << 8)) @@ -3927,8 +3927,8 @@ HORIZONLY: { if (abs(pact->floorz - pact->ceilingz) < (48 << 8) || j) { - if (!(sector[s->sectnum].lotag & 0x8000) && (isanunderoperator(sector[s->sectnum].lotag) || - isanearoperator(sector[s->sectnum].lotag))) + if (!(s->sector()->lotag & 0x8000) && (isanunderoperator(s->sector()->lotag) || + isanearoperator(s->sector()->lotag))) fi.activatebysector(s->sectnum, pact); if (j) { diff --git a/source/games/duke/src/premap_d.cpp b/source/games/duke/src/premap_d.cpp index 2d1c9f61a..d6c489fc6 100644 --- a/source/games/duke/src/premap_d.cpp +++ b/source/games/duke/src/premap_d.cpp @@ -292,7 +292,7 @@ void prelevel_d(int g) else switch (si->picnum) { case GPSPEED: - sector[si->sectnum].extra = si->lotag; + si->sector()->extra = si->lotag; deletesprite(ac); break; @@ -302,7 +302,7 @@ void prelevel_d(int g) cyclers[numcyclers][0] = si->sectnum; cyclers[numcyclers][1] = si->lotag; cyclers[numcyclers][2] = si->shade; - cyclers[numcyclers][3] = sector[si->sectnum].floorshade; + cyclers[numcyclers][3] = si->sector()->floorshade; cyclers[numcyclers][4] = si->hitag; cyclers[numcyclers][5] = (si->ang == 1536); numcyclers++; diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index 4d25e99bc..d8c90267a 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -547,7 +547,7 @@ void prelevel_r(int g) break; case GPSPEED: - sector[si->sectnum].extra = si->lotag; + si->sector()->extra = si->lotag; deletesprite(ac); break; @@ -557,7 +557,7 @@ void prelevel_r(int g) cyclers[numcyclers][0] = si->sectnum; cyclers[numcyclers][1] = si->lotag; cyclers[numcyclers][2] = si->shade; - cyclers[numcyclers][3] = sector[si->sectnum].floorshade; + cyclers[numcyclers][3] = si->sector()->floorshade; cyclers[numcyclers][4] = si->hitag; cyclers[numcyclers][5] = (si->ang == 1536); numcyclers++; diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index 60bb6ce33..980ed4df2 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -90,7 +90,7 @@ int callsound(int sn, DDukeActor* whatsprite) act->temp_actor = whatsprite; } - if ((sector[si->sectnum].lotag & 0xff) != ST_22_SPLITTING_DOOR) + if ((si->sector()->lotag & 0xff) != ST_22_SPLITTING_DOOR) act->temp_data[0] = 1; } } @@ -444,7 +444,7 @@ 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) || - (sector[act2->s->sectnum].hitag == (sector[sn].hitag - d))) + (act2->getSector()->hitag == (sector[sn].hitag - d))) break; } @@ -679,7 +679,7 @@ static void handle_st29(int sn, DDukeActor* actor) if ((act2->s->lotag == 22) && (act2->s->hitag == sptr->hitag)) { - sector[act2->s->sectnum].extra = -sector[act2->s->sectnum].extra; + act2->getSector()->extra = -act2->getSector()->extra; act2->temp_data[0] = sn; act2->temp_data[1] = 1; @@ -820,7 +820,7 @@ static void handle_st23(int sn, DDukeActor* actor) } if (!act2) return; - int l = sector[act2->s->sectnum].lotag & 0x8000; + int l = act2->getSector()->lotag & 0x8000; if (act2) { @@ -828,7 +828,7 @@ static void handle_st23(int sn, DDukeActor* actor) while (auto act3 = it.Next()) { - if (l == (sector[act3->s->sectnum].lotag & 0x8000) && act3->s->lotag == SE_11_SWINGING_DOOR && act2->s->hitag == act3->s->hitag && act3->temp_data[4]) + if (l == (act3->getSector()->lotag & 0x8000) && act3->s->lotag == SE_11_SWINGING_DOOR && act2->s->hitag == act3->s->hitag && act3->temp_data[4]) { return; } @@ -837,10 +837,10 @@ static void handle_st23(int sn, DDukeActor* actor) it.Reset(STAT_EFFECTOR); while (auto act3 = it.Next()) { - if (l == (sector[act3->s->sectnum].lotag & 0x8000) && act3->s->lotag == SE_11_SWINGING_DOOR && act2->s->hitag == act3->s->hitag) + if (l == (act3->getSector()->lotag & 0x8000) && act3->s->lotag == SE_11_SWINGING_DOOR && act2->s->hitag == act3->s->hitag) { - if (sector[act3->s->sectnum].lotag & 0x8000) sector[act3->s->sectnum].lotag &= 0x7fff; - else sector[act3->s->sectnum].lotag |= 0x8000; + if (act3->getSector()->lotag & 0x8000) act3->getSector()->lotag &= 0x7fff; + else act3->getSector()->lotag |= 0x8000; act3->temp_data[4] = 1; act3->temp_data[3] = -act3->temp_data[3]; if (q == 0) @@ -881,11 +881,11 @@ static void handle_st25(int sn, DDukeActor* actor) { if (act3->s->lotag == 15) { - sector[act3->s->sectnum].lotag ^= 0x8000; // Toggle the open or close + act3->getSector()->lotag ^= 0x8000; // Toggle the open or close act3->s->ang += 1024; if (act3->temp_data[4]) callsound(act3->s->sectnum, act3); callsound(act3->s->sectnum, act3); - if (sector[act3->s->sectnum].lotag & 0x8000) act3->temp_data[4] = 1; + if (act3->getSector()->lotag & 0x8000) act3->temp_data[4] = 1; else act3->temp_data[4] = 2; } } @@ -1103,11 +1103,11 @@ void operateactivators(int low, int plnum) { if (act->s->picnum == ACTIVATORLOCKED) { - sector[act->s->sectnum].lotag ^= 16384; + act->getSector()->lotag ^= 16384; if (plnum >= 0) { - if (sector[act->s->sectnum].lotag & 16384) + if (act->getSector()->lotag & 16384) FTA(4, &ps[plnum]); else FTA(8, &ps[plnum]); } @@ -1119,20 +1119,20 @@ void operateactivators(int low, int plnum) case 0: break; case 1: - if (sector[act->s->sectnum].floorz != sector[act->s->sectnum].ceilingz) + if (act->getSector()->floorz != act->getSector()->ceilingz) { continue; } break; case 2: - if (sector[act->s->sectnum].floorz == sector[act->s->sectnum].ceilingz) + if (act->getSector()->floorz == act->getSector()->ceilingz) { continue; } break; } - if (sector[act->s->sectnum].lotag < 3) + if (act->getSector()->lotag < 3) { DukeSectIterator it(act->s->sectnum); while (auto a2 = it.Next()) @@ -1151,7 +1151,7 @@ void operateactivators(int low, int plnum) } } - if (k == -1 && (sector[act->s->sectnum].lotag & 0xff) == 22) + if (k == -1 && (act->getSector()->lotag & 0xff) == 22) k = callsound(act->s->sectnum, act); operatesectors(act->s->sectnum, act); @@ -1242,8 +1242,8 @@ void allignwarpelevators(void) { if ((act2->s->lotag) == SE_17_WARP_ELEVATOR && act != act2 && act->s->hitag == act2->s->hitag) { - sector[act2->s->sectnum].floorz = sector[act->s->sectnum].floorz; - sector[act2->s->sectnum].ceilingz = sector[act->s->sectnum].ceilingz; + act2->getSector()->floorz = act->getSector()->floorz; + act2->getSector()->ceilingz = act->getSector()->ceilingz; } } } diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index ab34828d9..4163ab4ee 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1129,8 +1129,8 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) case FANSPRITE: s->picnum = FANSPRITEBROKE; s->cstat &= (65535 - 257); - if (sector[s->sectnum].floorpicnum == FANSHADOW) - sector[s->sectnum].floorpicnum = FANSHADOWBROKE; + if (s->sector()->floorpicnum == FANSHADOW) + s->sector()->floorpicnum = FANSHADOWBROKE; S_PlayActorSound(GLASS_HEAVYBREAK, targ); for (j = 0; j < 16; j++) RANDOMSCRAP(targ); @@ -1150,7 +1150,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) if (gs.actorinfo[SHOTSPARK1].scriptaddress && pspr->extra != ScriptCode[gs.actorinfo[SHOTSPARK1].scriptaddress]) { for (j = 0; j < 15; j++) - EGS(s->sectnum, s->x, s->y, sector[s->sectnum].floorz - (12 << 8) - (j << 9), SCRAP1 + (krand() & 15), -8, 64, 64, + EGS(s->sectnum, s->x, s->y, s->sector()->floorz - (12 << 8) - (j << 9), SCRAP1 + (krand() & 15), -8, 64, 64, krand() & 2047, (krand() & 127) + 64, -(krand() & 511) - 256, targ, 5); spawn(targ, EXPLOSION2); deletesprite(targ); @@ -1305,7 +1305,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) } { auto j = spawn(targ, STEAM); - j->s->z = sector[s->sectnum].floorz - (32 << 8); + j->s->z = s->sector()->floorz - (32 << 8); } break; @@ -1619,7 +1619,7 @@ void checksectors_d(int snum) } if (p->newOwner == nullptr && neartagsprite == nullptr && neartagsector == -1 && neartagwall == -1) - if (isanunderoperator(sector[p->GetActor()->s->sectnum].lotag)) + if (isanunderoperator(p->GetActor()->getSector()->lotag)) neartagsector = p->GetActor()->s->sectnum; if (neartagsector >= 0 && (sector[neartagsector].lotag & 16384)) @@ -1788,9 +1788,9 @@ void checksectors_d(int snum) } operatesectors(neartagsector, p->GetActor()); } - else if ((sector[p->GetActor()->s->sectnum].lotag & 16384) == 0) + else if ((p->GetActor()->getSector()->lotag & 16384) == 0) { - if (isanunderoperator(sector[p->GetActor()->s->sectnum].lotag)) + if (isanunderoperator(p->GetActor()->getSector()->lotag)) { DukeSectIterator it(p->GetActor()->s->sectnum); while (auto act = it.Next()) diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 68a8ade0e..5eec9e79f 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -1090,11 +1090,11 @@ void checkhitwall_r(DDukeActor* spr, int dawallnum, int x, int y, int z, int atw act->spriteextra++; if (act->spriteextra == 25) { - startwall = sector[s->sectnum].wallptr; - endwall = startwall + sector[s->sectnum].wallnum; + startwall = s->sector()->wallptr; + endwall = startwall + s->sector()->wallnum; for (i = startwall; i < endwall; i++) sector[wall[i].nextsector].lotag = 0; - sector[s->sectnum].lotag = 0; + s->sector()->lotag = 0; S_StopSound(act->s->lotag); S_PlayActorSound(400, act); deletesprite(act); @@ -2193,7 +2193,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) if (gs.actorinfo[SHOTSPARK1].scriptaddress && pspr->extra != ScriptCode[gs.actorinfo[SHOTSPARK1].scriptaddress]) { for (j = 0; j < 15; j++) - EGS(s->sectnum, s->x, s->y, sector[s->sectnum].floorz - (12 << 8) - (j << 9), SCRAP1 + (krand() & 15), -8, 64, 64, + EGS(s->sectnum, s->x, s->y, s->sector()->floorz - (12 << 8) - (j << 9), SCRAP1 + (krand() & 15), -8, 64, 64, krand() & 2047, (krand() & 127) + 64, -(krand() & 511) - 256, targ, 5); spawn(targ, EXPLOSION2); deletesprite(targ); @@ -2317,7 +2317,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) } { auto j = spawn(targ, STEAM); - j->s->z = sector[s->sectnum].floorz - (32 << 8); + j->s->z = s->sector()->floorz - (32 << 8); } break; @@ -2590,7 +2590,7 @@ void checksectors_r(int snum) } if (p->newOwner == nullptr && neartagsprite == nullptr && neartagsector == -1 && neartagwall == -1) - if (isanunderoperator(sector[p->GetActor()->s->sectnum].lotag)) + if (isanunderoperator(p->GetActor()->getSector()->lotag)) neartagsector = p->GetActor()->s->sectnum; if (neartagsector >= 0 && (sector[neartagsector].lotag & 16384)) @@ -2750,9 +2750,9 @@ void checksectors_r(int snum) FTA(41, p); } } - else if ((sector[p->GetActor()->s->sectnum].lotag & 16384) == 0) + else if ((p->GetActor()->getSector()->lotag & 16384) == 0) { - if (isanunderoperator(sector[p->GetActor()->s->sectnum].lotag)) + if (isanunderoperator(p->GetActor()->getSector()->lotag)) { DukeSectIterator it(p->GetActor()->s->sectnum); while (auto act = it.Next()) diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index fbc58059c..92c673832 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -287,7 +287,7 @@ static int GetPositionInfo(DDukeActor* actor, int soundNum, int sectNum, { orgsndist = sndist = int(16 * (sndorg - campos).Length()); - if ((userflags & (SF_GLOBAL | SF_DTAG)) != SF_GLOBAL && sp->picnum == MUSICANDSFX && sp->lotag < 999 && (sector[sp->sectnum].lotag & 0xff) < ST_9_SLIDING_ST_DOOR) + if ((userflags & (SF_GLOBAL | SF_DTAG)) != SF_GLOBAL && sp->picnum == MUSICANDSFX && sp->lotag < 999 && (sp->sector()->lotag & 0xff) < ST_9_SLIDING_ST_DOOR) sndist = DivScale(sndist, sp->hitag + 1, 14); } diff --git a/source/games/duke/src/spawn.cpp b/source/games/duke/src/spawn.cpp index e8206d2af..8f958bbb0 100644 --- a/source/games/duke/src/spawn.cpp +++ b/source/games/duke/src/spawn.cpp @@ -168,8 +168,8 @@ int initspriteforspawn(DDukeActor* actj, int pn, const std::initializer_listmovflag = 0; act->tempang = 0; act->dispicnum = 0; - act->floorz = sector[sp->sectnum].floorz; - act->ceilingz = sector[sp->sectnum].ceilingz; + act->floorz = sp->sector()->floorz; + act->ceilingz = sp->sector()->ceilingz; act->lastvx = 0; act->lastvy = 0; @@ -306,7 +306,7 @@ void spawntransporter(DDukeActor *actj, DDukeActor* acti, bool beam) { sp->xrepeat = 31; sp->yrepeat = 1; - sp->z = sector[spj->sectnum].floorz - (isRR() ? PHEIGHT_RR : PHEIGHT_DUKE); + sp->z = spj->sector()->floorz - (isRR() ? PHEIGHT_RR : PHEIGHT_DUKE); } else { @@ -346,16 +346,16 @@ int spawnbloodpoolpart1(DDukeActor *actj, DDukeActor* acti) short s1 = sp->sectnum; updatesector(sp->x + 108, sp->y + 108, &s1); - if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz) { updatesector(sp->x - 108, sp->y - 108, &s1); - if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz) { updatesector(sp->x + 108, sp->y - 108, &s1); - if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + if (s1 >= 0 && sector[s1].floorz == sp->sector()->floorz) { updatesector(sp->x - 108, sp->y + 108, &s1); - if (s1 >= 0 && sector[s1].floorz != sector[sp->sectnum].floorz) + if (s1 >= 0 && sector[s1].floorz != sp->sector()->floorz) { sp->xrepeat = sp->yrepeat = 0; changeactorstat(acti, STAT_MISC); return true; } @@ -366,7 +366,7 @@ int spawnbloodpoolpart1(DDukeActor *actj, DDukeActor* acti) } else { sp->xrepeat = sp->yrepeat = 0; changeactorstat(acti, STAT_MISC); return true; } - if (sector[sp->sectnum].lotag == 1) + if (sp->sector()->lotag == 1) { changeactorstat(acti, STAT_MISC); return true; @@ -388,18 +388,19 @@ void initfootprint(DDukeActor* actj, DDukeActor* acti) { short s1; s1 = sp->sectnum; + auto sect1 = §or[s1]; updatesector(sp->x + 84, sp->y + 84, &s1); - if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + if (s1 >= 0 && sect1->floorz == sp->sector()->floorz) { updatesector(sp->x - 84, sp->y - 84, &s1); - if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + if (s1 >= 0 && sect1->floorz == sp->sector()->floorz) { updatesector(sp->x + 84, sp->y - 84, &s1); - if (s1 >= 0 && sector[s1].floorz == sector[sp->sectnum].floorz) + if (s1 >= 0 && sect1->floorz == sp->sector()->floorz) { updatesector(sp->x - 84, sp->y + 84, &s1); - if (s1 >= 0 && sector[s1].floorz != sector[sp->sectnum].floorz) + if (s1 >= 0 && sect1->floorz != sp->sector()->floorz) { sp->xrepeat = sp->yrepeat = 0; changeactorstat(acti, STAT_MISC); return; } @@ -1071,8 +1072,8 @@ void spawneffector(DDukeActor* actor) } else if (sp->lotag == SE_2_EARTHQUAKE) { - t[5] = sector[sp->sectnum].floorheinum; - sector[sp->sectnum].floorheinum = 0; + t[5] = sp->sector()->floorheinum; + sp->sector()->floorheinum = 0; } } @@ -1085,7 +1086,7 @@ void spawneffector(DDukeActor* actor) if (j == -1) { if (!isRR()) j = SUBWAY; // Duke - else if (sector[sp->sectnum].floorpal == 7) j = 456; + else if (sp->sector()->floorpal == 7) j = 456; else j = 75; } actor->lastvx = j; diff --git a/source/games/duke/src/spawn_d.cpp b/source/games/duke/src/spawn_d.cpp index e50961f8c..c348a04f8 100644 --- a/source/games/duke/src/spawn_d.cpp +++ b/source/games/duke/src/spawn_d.cpp @@ -166,12 +166,12 @@ int spawn_d(int j, int pn) sp->cstat |= 128; if(j >= 0) { - if(sector[spj->sectnum].lotag == 2) + if(spj->sector()->lotag == 2) { sp->z = getceilzofslope(sp->sectnum,sp->x,sp->y)+(16<<8); sp->cstat |= 8; } - else if( sector[spj->sectnum].lotag == 1) + else if( spj->sector()->lotag == 1) sp->z = getflorzofslope(sp->sectnum,sp->x,sp->y); } @@ -655,7 +655,7 @@ int spawn_d(int j, int pn) sp->xrepeat = spj->xrepeat; sp->yrepeat = spj->yrepeat; sp->zvel = 128; - if(sector[sp->sectnum].lotag != 2) + if(sp->sector()->lotag != 2) sp->cstat |= 32768; } changespritestat(i, STAT_DUMMYPLAYER); @@ -902,7 +902,7 @@ int spawn_d(int j, int pn) case ACTIVATOR: sp->cstat = (short) 32768; if(sp->picnum == ACTIVATORLOCKED) - sector[sp->sectnum].lotag |= 16384; + sp->sector()->lotag |= 16384; changespritestat(i,8); break; diff --git a/source/games/duke/src/spawn_r.cpp b/source/games/duke/src/spawn_r.cpp index 46acf8686..cffa149c1 100644 --- a/source/games/duke/src/spawn_r.cpp +++ b/source/games/duke/src/spawn_r.cpp @@ -221,12 +221,12 @@ int spawn_r(int j, int pn) sp->cstat |= 128; if (j >= 0) { - if (sector[spj->sectnum].lotag == 2) + if (spj->sector()->lotag == 2) { sp->z = getceilzofslope(sp->sectnum, sp->x, sp->y) + (16 << 8); sp->cstat |= 8; } - else if (sector[spj->sectnum].lotag == 1) + else if (spj->sector()->lotag == 1) sp->z = getflorzofslope(sp->sectnum, sp->x, sp->y); } @@ -668,7 +668,7 @@ int spawn_r(int j, int pn) sp->xrepeat = spj->xrepeat; sp->yrepeat = spj->yrepeat; sp->zvel = 128; - if(sector[sp->sectnum].lotag != 2) + if(sp->sector()->lotag != 2) sp->cstat |= 32768; } changespritestat(i,13); @@ -1314,7 +1314,7 @@ int spawn_r(int j, int pn) sp->yrepeat = 16; break; } - sp->shade = sector[sp->sectnum].floorshade; + sp->shade = sp->sector()->floorshade; break; case WATERFOUNTAIN: sp->lotag = 1;