diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 40d4711c5..5c91ba3b4 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -978,7 +978,7 @@ void movemasterswitch(DDukeActor *actor, int spectype1, int spectype2) { operatesectors(spri->sector(), actor); - DukeSectIterator it(spri->sectnum); + DukeSectIterator it(actor->sector()); while (auto effector = it.Next()) { auto sj = effector->s; @@ -2255,7 +2255,7 @@ bool jibs(DDukeActor *actor, int JIBS6, bool timeout, bool callsetsprite, bool f if (callsetsprite) setsprite(actor, s->pos); // this was after the slope calls, but we should avoid calling that for invalid sectors. - if (!validSectorIndex(s->sectnum)) + if (!s->insector()) { deletesprite(actor); return false; @@ -2451,7 +2451,7 @@ void shell(DDukeActor* actor, bool morecheck) ssp(actor, CLIPMASK0); - if (s->sectnum < 0 || morecheck) + if (!s->insector() || morecheck) { deletesprite(actor); return; @@ -2506,7 +2506,7 @@ void glasspieces(DDukeActor* actor) makeitfall(actor); if (s->zvel > 4096) s->zvel = 4096; - if (s->sectnum < 0) + if (!s->insector()) { deletesprite(actor); return; @@ -3006,7 +3006,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) auto Owner = actor->GetOwner(); if (Owner) { - DukeSectIterator itr(Owner->s->sectnum); + DukeSectIterator itr(Owner->sector()); while (auto a2 = itr.Next()) { if (a2->s->statnum == 1 && badguy(a2) && a2->s->picnum != SECTOREFFECTOR && a2->s->picnum != LOCATORS) @@ -3174,7 +3174,7 @@ void handle_se30(DDukeActor *actor, int JIBS6) if (Owner) { - DukeSectIterator it(Owner->s->sectnum); + DukeSectIterator it(Owner->sector()); while (auto a2 = it.Next()) { if (a2->s->statnum == 1 && badguy(a2) && a2->s->picnum != SECTOREFFECTOR && a2->s->picnum != LOCATORS) @@ -3990,7 +3990,7 @@ void handle_se17(DDukeActor* actor) if (act2 == nullptr) return; auto spr2 = act2->s; - DukeSectIterator its(s->sectnum); + DukeSectIterator its(actor->sector()); while (auto act3 = its.Next()) { auto spr3 = act3->s; @@ -4065,7 +4065,7 @@ void handle_se18(DDukeActor *actor, bool morecheck) sc->floorz += sc->extra; if (morecheck) { - DukeSectIterator it(actor->s->sectnum); + DukeSectIterator it(actor->sector()); while (auto a2 = it.Next()) { if (a2->s->picnum == TILE_APLAYER && a2->GetOwner()) @@ -4102,7 +4102,7 @@ void handle_se18(DDukeActor *actor, bool morecheck) sc->floorz -= sc->extra; if (morecheck) { - DukeSectIterator it(actor->s->sectnum); + DukeSectIterator it(actor->sector()); while (auto a2 = it.Next()) { if (a2->s->picnum == TILE_APLAYER && a2->GetOwner()) @@ -4489,7 +4489,7 @@ void handle_se24(DDukeActor *actor, const int16_t *list1, const int16_t *list2, int x = MulScale(actor->s->yvel, bcos(actor->s->ang), 18); int l = MulScale(actor->s->yvel, bsin(actor->s->ang), 18); - DukeSectIterator it(actor->s->sectnum); + DukeSectIterator it(actor->sector()); while (auto a2 = it.Next()) { auto s2 = a2->s; diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 6fe20fd36..3d90956c6 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -1413,7 +1413,7 @@ void movestandables_d(void) { int picnum = act->s->picnum; - if (act->s->sectnum < 0) + if (!act->insector()) { deletesprite(act); continue; @@ -1794,7 +1794,7 @@ static void weaponcommon_d(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) + if (!s->insector()) { deletesprite(proj); return; @@ -1927,7 +1927,7 @@ void moveweapons_d(void) DukeStatIterator it(STAT_PROJECTILE); while (auto act = it.Next()) { - if (act->s->sectnum < 0) + if (!act->insector()) { deletesprite(act); continue; @@ -2009,7 +2009,7 @@ void movetransports_d(void) if (act->temp_data[0] > 0) act->temp_data[0]--; - DukeSectIterator itj(spr->sectnum); + DukeSectIterator itj(act->sector()); while (auto act2 = itj.Next()) { auto spr2 = act2->s; @@ -2757,7 +2757,7 @@ static void flamethrowerflame(DDukeActor *actor) movesprite_ex(actor, MulScale(xvel, bcos(s->ang), 14), MulScale(xvel, bsin(s->ang), 14), s->zvel, CLIPMASK1, coll); - if (s->sectnum < 0) + if (!s->insector()) { deletesprite(actor); return; @@ -3268,7 +3268,7 @@ void moveexplosions_d(void) // STATNUM 5 { auto s = act->s; - if (s->sectnum < 0 || s->xrepeat == 0) + if (!s->insector() || s->xrepeat == 0) { deletesprite(act); continue; diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index d1882b64b..602d7b972 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -986,7 +986,7 @@ void movestandables_r(void) { int picnum = act->s->picnum; - if (act->s->sectnum < 0) + if (!act->insector()) { deletesprite(act); continue; @@ -1406,7 +1406,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() && s->sector()->filler == 800)) + if (!s->insector()) // || (isRR() && s->sector()->filler == 800)) { deletesprite(proj); return; @@ -1504,7 +1504,7 @@ void moveweapons_r(void) DukeStatIterator it(STAT_PROJECTILE); while (auto proj = it.Next()) { - if (proj->s->sectnum < 0) + if (!proj->insector()) { deletesprite(proj); continue; @@ -2854,7 +2854,7 @@ void moveactors_r(void) auto s = act->s; bool deleteafterexecute = false; // taking a cue here from RedNukem to not run scripts on deleted sprites. - if( s->xrepeat == 0 || !validSectorIndex(s->sectnum)) + if( s->xrepeat == 0 || !s->insector()) { deletesprite(act); continue; @@ -3124,7 +3124,7 @@ void moveexplosions_r(void) // STATNUM 5 t = &act->temp_data[0]; auto sectp = s->sector(); - if (s->sectnum < 0 || s->xrepeat == 0) + if (!s->insector() || s->xrepeat == 0) { deletesprite(act); continue; diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index 83a2ce58c..12c8fe49d 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -164,7 +164,6 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int t->pos = s->interpolatedvec3(smoothratio); } - //sect = s->sectnum; auto sectp = s->sector(); t1 = h->temp_data[1]; t3 = h->temp_data[3]; diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 9f89f3302..da49b00a7 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2113,7 +2113,7 @@ int ParseState::parse(void) break; case concmd_spawn: insptr++; - if(validSectorIndex(g_sp->sectnum)) + if(g_ac->insector()) spawn(g_ac,*insptr); insptr++; break; @@ -2147,7 +2147,7 @@ int ParseState::parse(void) insptr++; bool weap = fi.spawnweapondebris(g_sp->picnum, dnum); - if(validSectorIndex(g_sp->sectnum)) + if(g_ac->insector()) for(j=(*insptr)-1;j>=0;j--) { if(weap) @@ -2858,7 +2858,7 @@ int ParseState::parse(void) lIn = *insptr++; lIn = GetGameVarID(lIn, g_ac, g_p); - if(validSectorIndex(g_sp->sectnum)) + if(g_ac->insector()) lReturn = spawn(g_ac, lIn); SetGameVarID(g_iReturnVarID, ActorToScriptIndex(lReturn), g_ac, g_p); @@ -2868,7 +2868,7 @@ int ParseState::parse(void) { DDukeActor* lReturn = nullptr; insptr++; - if(validSectorIndex(g_sp->sectnum)) + if(g_ac->insector()) lReturn = spawn(g_ac, *insptr); insptr++; SetGameVarID(g_iReturnVarID, ActorToScriptIndex(lReturn), g_ac, g_p); @@ -3668,7 +3668,7 @@ void LoadActor(DDukeActor *actor, int p, int x) s.killit_flag = 0; - if(!validSectorIndex(actor->s->sectnum)) + if(!actor->insector()) { deletesprite(actor); return; @@ -3757,7 +3757,7 @@ void execute(DDukeActor *actor,int p,int x) s.killit_flag = 0; - if(!validSectorIndex(actor->s->sectnum)) + if(!actor->insector()) { if(badguy(actor)) ps[p].actors_killed++; diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 53ec5e99e..11154cd5e 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1824,7 +1824,7 @@ void checksectors_d(int snum) { if (isanunderoperator(p->GetActor()->sector()->lotag)) { - DukeSectIterator it(p->GetActor()->s->sectnum); + DukeSectIterator it(p->GetActor()->sector()); while (auto act = it.Next()) { if (act->s->picnum == ACTIVATOR || act->s->picnum == MASTERSWITCH) return; diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 2bfd313ee..6820feb9f 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -2774,7 +2774,7 @@ void checksectors_r(int snum) { if (isanunderoperator(p->GetActor()->sector()->lotag)) { - DukeSectIterator it(p->GetActor()->s->sectnum); + DukeSectIterator it(p->GetActor()->sector()); while (auto act = it.Next()) { if (act->s->picnum == ACTIVATOR || act->s->picnum == MASTERSWITCH)