diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 370c9064f..ca5b08920 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -83,7 +83,7 @@ struct ParseState int furthestcanseepoint(DDukeActor* i, DDukeActor* ts, int* dax, int* day); bool ifsquished(DDukeActor* i, int p); void fakebubbaspawn(DDukeActor* actor, int g_p); -void tearitup(int sect); +void tearitup(sectortype* sect); void destroyit(DDukeActor* actor); void mamaspawn(DDukeActor* actor); void forceplayerangle(int snum); @@ -1817,7 +1817,7 @@ int ParseState::parse(void) break; case concmd_tearitup: insptr++; - tearitup(g_sp->sectnum); + tearitup(g_sp->sector()); break; case concmd_fall: insptr++; diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 87ab9ec11..1427ce44a 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -86,7 +86,7 @@ void incur_damage_r(struct player_struct* p) static void shootmelee(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, int atwith) { spritetype* const s = actor->s; - int sect = s->sectnum; + auto sectp = s->sector(); int zvel; int hitx, hity, hitz; DDukeActor* hitsprt; @@ -107,7 +107,7 @@ static void shootmelee(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, sa = getangle(pspr->s->x - sx, pspr->s->y - sy); } - hitscan(sx, sy, sz, sect, + hitscan(sx, sy, sz, sectp, bcos(sa), bsin(sa), zvel << 6, &hitsectp, &wal, &hitsprt, &hitx, &hity, &hitz, CLIPMASK1); @@ -132,7 +132,7 @@ static void shootmelee(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, { nz = effector->GetOwner()->sector()->ceilingz; } - hitscan(nx, ny, nz, effector->GetOwner()->s->sectnum, bcos(sa), bsin(sa), zvel << 6, + hitscan(nx, ny, nz, effector->GetOwner()->s->sector(), bcos(sa), bsin(sa), zvel << 6, &hitsectp, &wal, &hitsprt, &hitx, &hity, &hitz, CLIPMASK1); break; } @@ -213,7 +213,7 @@ static void shootmelee(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, int atwith) { auto s = actor->s; - int sect = s->sectnum; + auto sectp = s->sector(); int zvel = 0; int hitx, hity, hitz; DDukeActor* hitsprt; @@ -271,7 +271,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa } s->cstat &= ~257; - hitscan(sx, sy, sz, sect, bcos(sa), bsin(sa), + hitscan(sx, sy, sz, sectp, bcos(sa), bsin(sa), zvel << 6, &hitsectp, &wal, &hitsprt, &hitx, &hity, &hitz, CLIPMASK1); if (isRRRA() && hitsectp != nullptr && (((hitsectp->lotag == 160 && zvel > 0) || (hitsectp->lotag == 161 && zvel < 0)) @@ -294,7 +294,7 @@ static void shootweapon(DDukeActor* actor, int p, int sx, int sy, int sz, int sa { nz = effector->GetOwner()->sector()->ceilingz; } - hitscan(nx, ny, nz, effector->GetOwner()->s->sectnum, bcos(sa), bsin(sa), zvel << 6, + hitscan(nx, ny, nz, effector->GetOwner()->s->sector(), bcos(sa), bsin(sa), zvel << 6, &hitsectp, &wal, &hitsprt, &hitx, &hity, &hitz, CLIPMASK1); break; } diff --git a/source/games/duke/src/premap_r.cpp b/source/games/duke/src/premap_r.cpp index f8e3c4683..fdb5be34b 100644 --- a/source/games/duke/src/premap_r.cpp +++ b/source/games/duke/src/premap_r.cpp @@ -506,14 +506,15 @@ void prelevel_r(int g) { dist = sj->lotag << 4; speed = sj->hitag; - for (ii = 0; ii < MAXSPRITES; ii++) + DukeSpriteIterator itt; + while(auto act = itt.Next()) { - auto spr = &sprite[ii]; + auto spr = act->s; if (spr->picnum == RRTILE66) if (spr->lotag == sj->sectnum) { childsectnum = spr->sector(); - deletesprite(ii); + deletesprite(act); } } deletesprite(act); diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index dd419564b..16b476633 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -129,7 +129,7 @@ int check_activator_motion(int lotag) DukeStatIterator it1(STAT_EFFECTOR); while (auto act2 = it1.Next()) { - if (act->s->sectnum == act2->s->sectnum) + if (act->s->sector() == act2->s->sector()) switch (act2->s->lotag) { case SE_11_SWINGING_DOOR: diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index 1cfa1e8ef..b822eadc7 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1424,10 +1424,10 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) if ((s->cstat & 48) == 0) s->ang = (pspr->ang + 1024) & 2047; s->xvel = -(pspr->extra << 2); - j = s->sectnum; - pushmove(&s->pos, &j, 128L, (4 << 8), (4 << 8), CLIPMASK0); - if (j != s->sectnum && validSectorIndex(j)) - changeactorsect(targ, j); + auto sp = s->sector(); + pushmove(&s->pos, &sp, 128L, (4 << 8), (4 << 8), CLIPMASK0); + if (sp != s->sector() && sp != nullptr) + changeactorsect(targ, sp); } if (s->statnum == 2) @@ -1623,17 +1623,17 @@ void checksectors_d(int snum) return; } if (p->newOwner != nullptr) - neartag(p->oposx, p->oposy, p->oposz, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->oposx, p->oposy, p->oposz, p->GetActor()->sector(), p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); else { - neartag(p->pos.x, p->pos.y, p->pos.z, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->pos.x, p->pos.y, p->pos.z, p->GetActor()->sector(), p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); if (neartagsprite == nullptr && ntwall == nullptr && ntsector == nullptr) - neartag(p->pos.x, p->pos.y, p->pos.z + (8 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->pos.x, p->pos.y, p->pos.z + (8 << 8), p->GetActor()->sector(), p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); if (neartagsprite == nullptr && ntwall == nullptr && ntsector == nullptr) - neartag(p->pos.x, p->pos.y, p->pos.z + (16 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->pos.x, p->pos.y, p->pos.z + (16 << 8), p->GetActor()->sector(), p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); if (neartagsprite == nullptr && ntwall == nullptr && ntsector == nullptr) { - neartag(p->pos.x, p->pos.y, p->pos.z + (16 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 3); + neartag(p->pos.x, p->pos.y, p->pos.z + (16 << 8), p->GetActor()->sector(), p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 3); if (neartagsprite != nullptr) { switch (neartagsprite->s->picnum) diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 8b2a0dfc3..e3f9e0caf 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -2572,21 +2572,21 @@ void checksectors_r(int snum) } return; } - neartag(p->pos.x, p->pos.y, p->pos.z, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 3); + neartag(p->pos.x, p->pos.y, p->pos.z, p->GetActor()->sector(), p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 3); } if (p->newOwner != nullptr) - neartag(p->oposx, p->oposy, p->oposz, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->oposx, p->oposy, p->oposz, p->GetActor()->sector(), p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); else { - neartag(p->pos.x, p->pos.y, p->pos.z, p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->pos.x, p->pos.y, p->pos.z, p->GetActor()->sector(), p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); if (neartagsprite == nullptr && ntwall == nullptr && ntsector == nullptr) - neartag(p->pos.x, p->pos.y, p->pos.z + (8 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->pos.x, p->pos.y, p->pos.z + (8 << 8), p->GetActor()->sector(), p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); if (neartagsprite == nullptr && ntwall == nullptr && ntsector == nullptr) - neartag(p->pos.x, p->pos.y, p->pos.z + (16 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); + neartag(p->pos.x, p->pos.y, p->pos.z + (16 << 8), p->GetActor()->sector(), p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 1); if (neartagsprite == nullptr && ntwall == nullptr && ntsector == nullptr) { - neartag(p->pos.x, p->pos.y, p->pos.z + (16 << 8), p->GetActor()->s->sectnum, p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 3); + neartag(p->pos.x, p->pos.y, p->pos.z + (16 << 8), p->GetActor()->sector(), p->angle.oang.asbuild(), &ntsector, &ntwall, &neartagsprite, &neartaghitdist, 1280L, 3); if (neartagsprite != nullptr) { switch (neartagsprite->s->picnum) @@ -2915,7 +2915,7 @@ void dofurniture(walltype* wlwal, sectortype* sectp, int snum) // //--------------------------------------------------------------------------- -void tearitup(int sect) +void tearitup(sectortype* sect) { DukeSectIterator it(sect); while (auto act = it.Next()) diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index 82e1c8991..fed2b204b 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -265,7 +265,7 @@ inline bool S_IsAmbientSFX(DDukeActor* actor) // //========================================================================== -static int GetPositionInfo(DDukeActor* actor, int soundNum, int sectNum, +static int GetPositionInfo(DDukeActor* actor, int soundNum, sectortype* sect, const vec3_t *cam, const vec3_t *pos, int *distPtr, FVector3 *sndPos) { // There's a lot of hackery going on here that could be mapped to rolloff and attenuation parameters. @@ -291,7 +291,7 @@ static int GetPositionInfo(DDukeActor* actor, int soundNum, int sectNum, sndist += dist_adjust; if (sndist < 0) sndist = 0; - if (sectNum > -1 && sndist && sp->picnum != MUSICANDSFX && !cansee(cam->x, cam->y, cam->z - (24 << 8), sectNum, sp->x, sp->y, sp->z - (24 << 8), sp->sectnum)) + if (sect!= nullptr && sndist && sp->picnum != MUSICANDSFX && !cansee(cam->x, cam->y, cam->z - (24 << 8), sect, sp->x, sp->y, sp->z - (24 << 8), sp->sector())) sndist += sndist >> (isRR() ? 2 : 5); // Here the sound distance was clamped to a minimum of 144*4. @@ -325,19 +325,19 @@ static int GetPositionInfo(DDukeActor* actor, int soundNum, int sectNum, // //========================================================================== -void S_GetCamera(vec3_t** c, int32_t* ca, int32_t* cs) +void S_GetCamera(vec3_t** c, int32_t* ca, sectortype** cs) { if (ud.cameraactor == nullptr) { auto p = &ps[screenpeek]; if (c) *c = &p->pos; - if (cs) *cs = sectnum(p->cursector); + if (cs) *cs = p->cursector; if (ca) *ca = p->angle.ang.asbuild(); } else { if (c) *c = &ud.cameraactor->s->pos; - if (cs) *cs = ud.cameraactor->s->sectnum; + if (cs) *cs = ud.cameraactor->s->sector(); if (ca) *ca = ud.cameraactor->s->ang; } } @@ -355,7 +355,7 @@ void DukeSoundEngine::CalcPosVel(int type, const void* source, const float pt[3] if (pos != nullptr) { vec3_t* campos; - int32_t camsect; + sectortype* camsect; S_GetCamera(&campos, nullptr, &camsect); if (vel) vel->Zero(); @@ -402,7 +402,8 @@ void GameInterface::UpdateSounds(void) { SoundListener listener; vec3_t* c; - int32_t ca, cs; + int32_t ca; + sectortype* cs; if (isRR() && !Mus_IsPlaying() && !paused && gamestate == GS_LEVEL) S_PlayRRMusic(); @@ -480,7 +481,7 @@ int S_PlaySound3D(int sndnum, DDukeActor* actor, const vec3_t* pos, int channel, FVector3 sndpos; // this is in sound engine space. vec3_t* campos; - int32_t camsect; + sectortype* camsect; S_GetCamera(&campos, nullptr, &camsect); GetPositionInfo(actor, sndnum, camsect, campos, pos, &sndist, &sndpos); diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 85cf728ad..20193d625 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -1476,7 +1476,7 @@ void PreMapCombineFloors(void) int i, j, k; int base_offset; int dx, dy; - int dasect, startwall, endwall, nextsector; + int startwall, endwall, nextsector; short pnum; typedef struct @@ -1544,7 +1544,7 @@ void PreMapCombineFloors(void) TRAVERSE_CONNECT(pnum) { PLAYERp pp = &Player[pnum]; - dasect = pp->cursectnum; + unsigned dasect = pp->cursectnum; search.Rewind(); for (unsigned itsect; (itsect = search.GetNext()) != BFSSearch::EOL;) {