diff --git a/source/core/gamefuncs.h b/source/core/gamefuncs.h index 4737c22f7..5303d3545 100644 --- a/source/core/gamefuncs.h +++ b/source/core/gamefuncs.h @@ -345,6 +345,23 @@ inline int pushmove(vec3_t *const vect, sectortype**const sect, int32_t const wa return res; } +inline void alignceilslope(sectortype* dasect, int32_t x, int32_t y, int32_t z) +{ + alignceilslope(sector.IndexOf(dasect), x, y, z); +} +inline void alignflorslope(sectortype* dasect, int32_t x, int32_t y, int32_t z) +{ + alignflorslope(sector.IndexOf(dasect), x, y, z); +} + +inline void updatesectorneighbor(int32_t const x, int32_t const y, sectortype* * const sect, int32_t maxDistance = MAXUPDATESECTORDIST) +{ + int sectno = *sect? sector.IndexOf(*sect) : -1; + updatesectorneighbor(x, y, §no, maxDistance); + *sect = sectno < 0? nullptr : §or[sectno]; +} + + inline int findwallbetweensectors(sectortype* sect1, sectortype* sect2) { diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 39d54d3de..ebdb5088c 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -4185,7 +4185,7 @@ void handle_se19(DDukeActor *actor, int BIGFORCE) } else //Not hit yet { - auto hitter = fi.ifhitsectors(actor->s->sectnum); + auto hitter = fi.ifhitsectors(actor->sector()); if (hitter) { FTA(8, &ps[myconnectindex]); diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 3392a5814..93f157f8c 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -430,7 +430,7 @@ void hitradius_d(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h int d = dist(actor, act2); if (spri2->picnum == APLAYER) spri2->z += gs.playerheight; - if (d < r && cansee(spri2->x, spri2->y, spri2->z - (8 << 8), spri2->sectnum, spri->x, spri->y, spri->z - (12 << 8), spri->sectnum)) + if (d < r && cansee(spri2->x, spri2->y, spri2->z - (8 << 8), spri2->sector(), spri->x, spri->y, spri->z - (12 << 8), spri->sector())) { act2->ang = getangle(spri2->x - spri->x, spri2->y - spri->y); @@ -691,7 +691,7 @@ void movefta_d(void) { int x, px, py, sx, sy; int p; - int psect, ssect; + sectortype* psect, *ssect; int j; DukeStatIterator iti(STAT_ZOMBIEACTOR); @@ -701,7 +701,7 @@ void movefta_d(void) auto s = act->s; p = findplayer(act, &x); - ssect = psect = s->sectnum; + ssect = psect = s->sector(); auto pa = ps[p].GetActor(); if (pa->s->extra > 0) @@ -716,14 +716,14 @@ void movefta_d(void) px = ps[p].oposx + 64 - (krand() & 127); py = ps[p].oposy + 64 - (krand() & 127); updatesector(px, py, &psect); - if (psect == -1) + if (psect == nullptr) { continue; } sx = s->x + 64 - (krand() & 127); sy = s->y + 64 - (krand() & 127); updatesector(px, py, &ssect); - if (ssect == -1) + if (ssect == nullptr) { continue; } @@ -789,12 +789,12 @@ void movefta_d(void) // //--------------------------------------------------------------------------- -DDukeActor* ifhitsectors_d(int sectnum) +DDukeActor* ifhitsectors_d(sectortype* sect) { DukeStatIterator it(STAT_MISC); while (auto a1 = it.Next()) { - if (a1->s->picnum == EXPLOSION2 && sectnum == a1->s->sectnum) + if (a1->s->picnum == EXPLOSION2 && sect == a1->s->sector()) return a1; } return nullptr; @@ -1103,11 +1103,11 @@ static void movetripbomb(DDukeActor *actor) s->z -= (3 << 8); // Laser fix from EDuke32. - int const oldSectNum = s->sectnum; - int curSectNum = s->sectnum; + auto const oldSect = s->sector(); + auto curSect = s->sector(); - updatesectorneighbor(s->x, s->y, &curSectNum, 2048); - changeactorsect(actor, curSectNum); + updatesectorneighbor(s->x, s->y, &curSect, 2048); + changeactorsect(actor, curSect); DDukeActor* hit; x = hitasprite(actor, &hit); @@ -1137,15 +1137,15 @@ static void movetripbomb(DDukeActor *actor) s->x += bcos(actor->temp_data[5], -4); s->y += bsin(actor->temp_data[5], -4); - updatesectorneighbor(s->x, s->y, &curSectNum, 2048); + updatesectorneighbor(s->x, s->y, &curSect, 2048); - if (curSectNum == -1) + if (curSect == nullptr) break; - changeactorsect(actor, curSectNum); + changeactorsect(actor, curSect); // this is a hack to work around the LASERLINE sprite's art tile offset - changeactorsect(spawned, curSectNum); + changeactorsect(spawned, curSect); } } } @@ -1153,7 +1153,7 @@ static void movetripbomb(DDukeActor *actor) actor->temp_data[0]++; s->x = actor->temp_data[3]; s->y = actor->temp_data[4]; s->z += (3 << 8); - changeactorsect(actor, oldSectNum); + changeactorsect(actor, oldSect); actor->temp_data[3] = 0; if (hit && lTripBombControl & TRIPBOMB_TRIPWIRE) { @@ -3037,16 +3037,16 @@ DETONATEB: void moveactors_d(void) { int x; - int sect, p; + int p; unsigned int k; DukeStatIterator it(STAT_ACTOR); while (auto act = it.Next()) { auto s = act->s; - sect = s->sectnum; + auto sectp = s->sector(); - if (s->xrepeat == 0 || !validSectorIndex(sect)) + if (s->xrepeat == 0 || sectp == nullptr) { deletesprite(act); continue; @@ -3772,7 +3772,7 @@ void moveeffectors_d(void) //STATNUM 3 auto sc = act->sector(); if (sc->wallnum != 4) continue; auto wal = sc->firstWall() + 2; - alignflorslope(act->s->sectnum, wal->x, wal->y, wal->nextSector()->floorz); + alignflorslope(act->s->sector(), wal->x, wal->y, wal->nextSector()->floorz); } } diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index f580dcc47..235b8264a 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -252,9 +252,9 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h } int x1 = (((wal.x + wal.point2Wall()->x) >> 1) + spri->x) >> 1; int y1 = (((wal.y + wal.point2Wall()->y) >> 1) + spri->y) >> 1; - int sect; + auto sect = wal.sectorp(); updatesector(x1, y1, §); - if (sect >= 0 && cansee(x1, y1, spri->z, sect, spri->x, spri->y, spri->z, spri->sectnum)) + if (sect != nullptr && cansee(x1, y1, spri->z, sect, spri->x, spri->y, spri->z, spri->sector())) fi.checkhitwall(actor, &wal, wal.x, wal.y, spri->z, spri->picnum); } } @@ -275,7 +275,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h if (spri2->cstat & 257) if (dist(actor, act2) < r) { - if (badguy(act2) && !cansee(spri2->x, spri2->y, spri2->z + q, spri2->sectnum, spri->x, spri->y, spri->z + q, spri->sectnum)) + if (badguy(act2) && !cansee(spri2->x, spri2->y, spri2->z + q, spri2->sector(), spri->x, spri->y, spri->z + q, spri->sector())) { continue; } @@ -297,7 +297,7 @@ void hitradius_r(DDukeActor* actor, int r, int hp1, int hp2, int hp3, int h int d = dist(actor, act2); if (spri2->picnum == APLAYER) spri2->z += gs.playerheight; - if (d < r && cansee(spri2->x, spri2->y, spri2->z - (8 << 8), spri2->sectnum, spri->x, spri->y, spri->z - (12 << 8), spri->sectnum)) + if (d < r && cansee(spri2->x, spri2->y, spri2->z - (8 << 8), spri2->sector(), spri->x, spri->y, spri->z - (12 << 8), spri->sector())) { if ((isRRRA()) && spri2->picnum == MINION && spri2->pal == 19) { @@ -510,7 +510,7 @@ void movefta_r(void) { int x, px, py, sx, sy; int j, p; - int psect, ssect; + sectortype* psect, *ssect; DukeStatIterator it(STAT_ZOMBIEACTOR); while(auto act = it.Next()) @@ -519,7 +519,7 @@ void movefta_r(void) p = findplayer(act, &x); j = 0; - ssect = psect = s->sectnum; + ssect = psect = s->sector(); if (ps[p].GetActor()->s->extra > 0) { @@ -533,14 +533,14 @@ void movefta_r(void) px = ps[p].oposx + 64 - (krand() & 127); py = ps[p].oposy + 64 - (krand() & 127); updatesector(px, py, &psect); - if (psect == -1) + if (psect == nullptr) { continue; } sx = s->x + 64 - (krand() & 127); sy = s->y + 64 - (krand() & 127); updatesector(px, py, &ssect); - if (ssect == -1) + if (ssect == nullptr) { continue; } @@ -622,12 +622,13 @@ void movefta_r(void) // //--------------------------------------------------------------------------- -DDukeActor* ifhitsectors_r(int sectnum) + +DDukeActor* ifhitsectors_r(sectortype* sect) { DukeStatIterator it(STAT_MISC); while (auto a1 = it.Next()) { - if (a1->s->picnum == EXPLOSION2 || (a1->s->picnum == EXPLOSION3 && sectnum == a1->s->sectnum)) + if (a1->s->picnum == EXPLOSION2 || (a1->s->picnum == EXPLOSION3 && sect == a1->s->sector())) return a1; } return nullptr; @@ -2487,7 +2488,7 @@ void rr_specialstats() ps[p].bobposy = ps[p].oposy = ps[p].pos.y = act2->s->y; ps[p].oposz = ps[p].pos.z = act2->s->z - (36 << 8); auto pact = ps[p].GetActor(); - changeactorsect(pact, act2->s->sectnum); + changeactorsect(pact, act2->sector()); ps[p].setCursector(pact->sector()); S_PlayActorSound(70, act2); deletesprite(act2); @@ -3659,7 +3660,7 @@ void moveeffectors_r(void) //STATNUM 3 auto sc = act->sector(); if (sc->wallnum != 4) continue; auto wal = sc->firstWall() + 2; - alignflorslope(act->s->sectnum, wal->x, wal->y, wal->nextSector()->floorz); + alignflorslope(act->sector(), wal->x, wal->y, wal->nextSector()->floorz); } } @@ -4105,10 +4106,9 @@ void fall_r(DDukeActor* ac, int g_p) void destroyit(DDukeActor *actor) { int lotag = 0, hitag = 0; - int sectnum; DDukeActor* spr = nullptr; - DukeSectIterator it1(actor->s->sectnum); + DukeSectIterator it1(actor->sector()); while (auto a2 = it1.Next()) { if (a2->s->picnum == RRTILE63) @@ -4138,7 +4138,7 @@ void destroyit(DDukeActor *actor) if (spr && spr->s->sector() != it_sect) if (lotag == a2->s->lotag) { - sectnum = spr->s->sectnum; + auto sect = spr->s->sector(); auto destsect = spr->sector(); auto srcsect = it_sect; @@ -4183,7 +4183,7 @@ void destroyit(DDukeActor *actor) destsect->extra = srcsect->extra; } } - it1.Reset(actor->s->sectnum); + it1.Reset(actor->s->sector()); while (auto a2 = it1.Next()) { switch (a2->s->picnum) diff --git a/source/games/duke/src/animatesprites_d.cpp b/source/games/duke/src/animatesprites_d.cpp index b2da159b9..1f7d1ed3d 100644 --- a/source/games/duke/src/animatesprites_d.cpp +++ b/source/games/duke/src/animatesprites_d.cpp @@ -327,7 +327,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int t->y = interpolatedvalue(omyy, myy, smoothratio); t->z = interpolatedvalue(omyz, myz, smoothratio) + PHEIGHT_DUKE; t->ang = interpolatedangle(omyang, myang, smoothratio).asbuild(); - t->sectnum = mycursectnum; + t->sector = mycursectnum; } #endif } diff --git a/source/games/duke/src/animatesprites_r.cpp b/source/games/duke/src/animatesprites_r.cpp index c7db8956b..8df428988 100644 --- a/source/games/duke/src/animatesprites_r.cpp +++ b/source/games/duke/src/animatesprites_r.cpp @@ -368,7 +368,7 @@ void animatesprites_r(spritetype* tsprite, int& spritesortcnt, int x, int y, int t->y = interpolatedvalue(omyy, myy, smoothratio); t->z = interpolatedvalue(omyz, myz, smoothratio) + PHEIGHT_RR; t->ang = interpolatedangle(omyang, myang, smoothratio).asbuild(); - t->sectnum = mycursectnum; + t->sector = mycursectnum; } #endif } diff --git a/source/games/duke/src/bowling.cpp b/source/games/duke/src/bowling.cpp index 4e5cb243c..23c28cd84 100644 --- a/source/games/duke/src/bowling.cpp +++ b/source/games/duke/src/bowling.cpp @@ -39,7 +39,7 @@ void ballreturn(DDukeActor *ball) DukeStatIterator it(STAT_BOWLING); while (auto act = it.Next()) { - if (act->s->picnum == RRTILE281 && ball->s->sectnum == act->s->sectnum) + if (act->s->picnum == RRTILE281 && ball->s->sector() == act->s->sector()) { DukeStatIterator it2(STAT_BOWLING); while (auto act2 = it2.Next()) diff --git a/source/games/duke/src/dispatch.cpp b/source/games/duke/src/dispatch.cpp index 7589e9585..b740decb6 100644 --- a/source/games/duke/src/dispatch.cpp +++ b/source/games/duke/src/dispatch.cpp @@ -70,8 +70,8 @@ void lotsofpaper_d(DDukeActor* s, int n); void lotsoffeathers_r(DDukeActor* s, int n); void guts_d(DDukeActor* s, int gtype, int n, int p); void guts_r(DDukeActor* s, int gtype, int n, int p); -DDukeActor* ifhitsectors_d(int sectnum); -DDukeActor* ifhitsectors_r(int sectnum); +DDukeActor* ifhitsectors_d(sectortype* sectnum); +DDukeActor* ifhitsectors_r(sectortype* sectnum); int ifhitbyweapon_r(DDukeActor* sn); int ifhitbyweapon_d(DDukeActor* sn); void fall_d(DDukeActor* i, int g_p); diff --git a/source/games/duke/src/duke3d.h b/source/games/duke/src/duke3d.h index 04bf359da..978e1cc20 100644 --- a/source/games/duke/src/duke3d.h +++ b/source/games/duke/src/duke3d.h @@ -95,7 +95,7 @@ struct Dispatcher void (*lotsofmail)(DDukeActor *s, int n); void (*lotsofpaper)(DDukeActor *s, int n); void (*guts)(DDukeActor* s, int gtype, int n, int p); - DDukeActor* (*ifhitsectors)(int sectnum); + DDukeActor* (*ifhitsectors)(sectortype* sectnum); int (*ifhitbyweapon)(DDukeActor* sectnum); void (*fall)(DDukeActor* actor, int g_p); bool (*spawnweapondebris)(int picnum, int dnum); diff --git a/source/games/duke/src/dukeactor.h b/source/games/duke/src/dukeactor.h index 9d807052e..bfccfc37a 100644 --- a/source/games/duke/src/dukeactor.h +++ b/source/games/duke/src/dukeactor.h @@ -245,5 +245,18 @@ inline void neartag(int32_t xs, int32_t ys, int32_t zs, int sectnum, int ange, *neartagwall = ntwal == -1? nullptr : &wall[ntwal]; } +inline void neartag(int32_t xs, int32_t ys, int32_t zs, sectortype* sect, int ange, + sectortype** neartagsector, walltype** neartagwall, DDukeActor** neartagsprite, + int32_t* neartaghitdist, int32_t neartagrange, uint8_t tagsearch) +{ + int16_t nts; + int16_t ntsec, ntwal; + ::neartag(xs, ys, zs, sectnum(sect), ange, &ntsec, &ntwal, &nts, neartaghitdist, neartagrange, tagsearch); + *neartagsprite = nts == -1 ? nullptr : &hittype[nts]; + *neartagsector = ntsec == -1 ? nullptr : §or[ntsec]; + *neartagwall = ntwal == -1 ? nullptr : &wall[ntwal]; +} + + END_DUKE_NS diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index 7dcd5c9aa..370c9064f 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -1437,7 +1437,7 @@ static bool ifcansee(DDukeActor* actor, int pnum) if (ps[pnum].holoduke_on != nullptr && !isRR()) { tosee = ps[pnum].holoduke_on; - j = cansee(spr->x, spr->y, spr->z - (krand() & ((32 << 8) - 1)), spr->sectnum, tosee->s->x, tosee->s->y, tosee->s->z, tosee->s->sectnum); + j = cansee(spr->x, spr->y, spr->z - (krand() & ((32 << 8) - 1)), spr->sector(), tosee->s->x, tosee->s->y, tosee->s->z, tosee->sector()); if (j == 0) { @@ -1449,7 +1449,7 @@ static bool ifcansee(DDukeActor* actor, int pnum) else tosee = ps[pnum].GetActor(); // holoduke not on. look for player // can they see player, (or player's holoduke) - j = cansee(spr->x, spr->y, spr->z - (krand() & ((47 << 8))), spr->sectnum, tosee->s->x, tosee->s->y, tosee->s->z - ((isRR()? 28 : 24) << 8), tosee->s->sectnum); + j = cansee(spr->x, spr->y, spr->z - (krand() & ((47 << 8))), spr->sector(), tosee->s->x, tosee->s->y, tosee->s->z - ((isRR()? 28 : 24) << 8), tosee->sector()); if (j == 0) { @@ -1501,12 +1501,12 @@ int ParseState::parse(void) parseifelse(ifcanshoottarget(g_ac, g_p, g_x)); break; case concmd_ifcanseetarget: - j = cansee(g_sp->x, g_sp->y, g_sp->z - ((krand() & 41) << 8), g_sp->sectnum, ps[g_p].pos.x, ps[g_p].pos.y, ps[g_p].pos.z/*-((krand()&41)<<8)*/, ps[g_p].GetActor()->s->sectnum); + j = cansee(g_sp->x, g_sp->y, g_sp->z - ((krand() & 41) << 8), g_sp->sector(), ps[g_p].pos.x, ps[g_p].pos.y, ps[g_p].pos.z/*-((krand()&41)<<8)*/, ps[g_p].GetActor()->sector()); parseifelse(j); if (j) g_ac->timetosleep = SLEEPTIME; break; case concmd_ifnocover: - j = cansee(g_sp->x, g_sp->y, g_sp->z, g_sp->sectnum, ps[g_p].pos.x, ps[g_p].pos.y, ps[g_p].pos.z, ps[g_p].GetActor()->s->sectnum); + j = cansee(g_sp->x, g_sp->y, g_sp->z, g_sp->sector(), ps[g_p].pos.x, ps[g_p].pos.y, ps[g_p].pos.z, ps[g_p].GetActor()->sector()); parseifelse(j); if (j) g_ac->timetosleep = SLEEPTIME; break; @@ -2469,7 +2469,7 @@ int ParseState::parse(void) walltype* neartagwall; DDukeActor* neartagsprite; int32_t neartaghitdist; - neartag(g_sp->x, g_sp->y, g_sp->z - (32 << 8), g_sp->sectnum, g_sp->ang, §p, &neartagwall, &neartagsprite, &neartaghitdist, 768L, 1); + neartag(g_sp->x, g_sp->y, g_sp->z - (32 << 8), g_sp->sector(), g_sp->ang, §p, &neartagwall, &neartagsprite, &neartaghitdist, 768L, 1); if (sectp) { if (isanearoperator(sectp->lotag)) @@ -2776,7 +2776,7 @@ int ParseState::parse(void) case concmd_pstomp: insptr++; if( ps[g_p].knee_incs == 0 && ps[g_p].GetActor()->s->xrepeat >= (isRR()? 9: 40) ) - if( cansee(g_sp->x,g_sp->y,g_sp->z-(4<<8),g_sp->sectnum,ps[g_p].pos.x,ps[g_p].pos.y,ps[g_p].pos.z+(16<<8),ps[g_p].GetActor()->s->sectnum) ) + if( cansee(g_sp->x,g_sp->y,g_sp->z-(4<<8),g_sp->sector(),ps[g_p].pos.x,ps[g_p].pos.y,ps[g_p].pos.z+(16<<8),ps[g_p].GetActor()->s->sector()) ) { ps[g_p].knee_incs = 1; if(ps[g_p].weapon_pos == 0) @@ -2786,23 +2786,21 @@ int ParseState::parse(void) break; case concmd_ifawayfromwall: { - int s1; - - s1 = g_sp->sectnum; + auto s1 = g_sp->sector(); j = 0; updatesector(g_sp->x + 108, g_sp->y + 108, &s1); - if (s1 == g_sp->sectnum) + if (s1 == g_sp->sector()) { updatesector(g_sp->x - 108, g_sp->y - 108, &s1); - if (s1 == g_sp->sectnum) + if (s1 == g_sp->sector()) { updatesector(g_sp->x + 108, g_sp->y - 108, &s1); - if (s1 == g_sp->sectnum) + if (s1 == g_sp->sector()) { updatesector(g_sp->x - 108, g_sp->y + 108, &s1); - if (s1 == g_sp->sectnum) + if (s1 == g_sp->sector()) j = 1; } } diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index cc9653dee..f53417591 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -175,7 +175,7 @@ int hits(DDukeActor* actor) if (sp->picnum == TILE_APLAYER) zoff = isRR() ? PHEIGHT_RR : PHEIGHT_DUKE; else zoff = 0; - hitscan(sp->x, sp->y, sp->z - zoff, sp->sectnum, bcos(sp->ang), bsin(sp->ang), 0, nullptr, nullptr, nullptr, &sx, &sy, &sz, CLIPMASK1); + hitscan(sp->x, sp->y, sp->z - zoff, sp->sector(), bcos(sp->ang), bsin(sp->ang), 0, nullptr, nullptr, nullptr, &sx, &sy, &sz, CLIPMASK1); return (FindDistance2D(sx - sp->x, sy - sp->y)); } @@ -197,7 +197,7 @@ int hitasprite(DDukeActor* actor, DDukeActor** hitsp) else if (sp->picnum == TILE_APLAYER) zoff = (39 << 8); else zoff = 0; - hitscan(sp->x, sp->y, sp->z - zoff, sp->sectnum, bcos(sp->ang), bsin(sp->ang), 0, nullptr, &wal, hitsp, &sx, &sy, &sz, CLIPMASK1); + hitscan(sp->x, sp->y, sp->z - zoff, sp->sector(), bcos(sp->ang), bsin(sp->ang), 0, nullptr, &wal, hitsp, &sx, &sy, &sz, CLIPMASK1); if (wal != nullptr && (wal->cstat & 16) && badguy(actor)) return((1 << 30)); @@ -334,7 +334,7 @@ DDukeActor* aim(DDukeActor* actor, int aang) a = (abs(Scale(sp->z - s->z, 10, sdist) - ps[s->yvel].horizon.sum().asbuild()) < 100); else a = 1; - cans = cansee(sp->x, sp->y, sp->z - (32 << 8) + gs.actorinfo[sp->picnum].aimoffset, sp->sectnum, s->x, s->y, s->z - (32 << 8), s->sectnum); + cans = cansee(sp->x, sp->y, sp->z - (32 << 8) + gs.actorinfo[sp->picnum].aimoffset, sp->sector(), s->x, s->y, s->z - (32 << 8), s->sector()); if (a && cans) { @@ -485,13 +485,12 @@ void footprints(int snum) auto p = &ps[snum]; auto actor = p->GetActor(); auto s = actor->s; - auto psect = s->sectnum; if (p->footprintcount > 0 && p->on_ground) if ((p->cursector->floorstat & 2) != 2) { int j = -1; - DukeSectIterator it(psect); + DukeSectIterator it(s->sector()); while (auto act = it.Next()) { if (act->s->picnum == TILE_FOOTPRINTS || act->s->picnum == TILE_FOOTPRINTS2 || act->s->picnum == TILE_FOOTPRINTS3 || act->s->picnum == TILE_FOOTPRINTS4) @@ -992,7 +991,7 @@ int haskey(sectortype* sectp, int snum) void shootbloodsplat(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, int atwith, int BIGFORCE, int OOZFILTER, int NEWBEAST) { spritetype* const s = actor->s; - int sect = s->sectnum; + auto sectp = s->sector(); int zvel; int hitx, hity, hitz; sectortype* hitsectp; @@ -1005,7 +1004,7 @@ void shootbloodsplat(DDukeActor* actor, int p, int sx, int sy, int sz, int sa, i zvel = 1024 - (krand() & 2047); - hitscan(sx, sy, sz, sect, + hitscan(sx, sy, sz, sectp, bcos(sa), bsin(sa), zvel << 6, &hitsectp, &wal, &d, &hitx, &hity, &hitz, CLIPMASK1); diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 3f489010f..87b9e69cb 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -234,7 +234,7 @@ static void shootflamethrowerflame(DDukeActor* actor, int p, int sx, int sy, int static void shootknee(DDukeActor* actor, int p, int sx, int sy, int sz, int sa) { auto s = actor->s; - int sect = s->sectnum; + auto sectp = s->sector(); int zvel; int hitx, hity, hitz; DDukeActor* hitsprt; @@ -255,7 +255,7 @@ static void shootknee(DDukeActor* actor, int p, int sx, int sy, int sz, int sa) sa = getangle(pactor->s->x - sx, pactor->s->y - sy); } - hitscan(sx, sy, sz, sect, + hitscan(sx, sy, sz, sectp, bcos(sa), bsin(sa), zvel << 6, &hitsectp, &hitwallp, &hitsprt, &hitx, &hity, &hitz, CLIPMASK1); @@ -328,7 +328,7 @@ static void shootknee(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* hitact; @@ -415,7 +415,7 @@ static void shootweapon(DDukeActor *actor, int p, int sx, int sy, int sz, int sa } s->cstat &= ~257; - hitscan(sx, sy, sz, sect, + hitscan(sx, sy, sz, sectp, bcos(sa), bsin(sa), zvel << 6, &hitsectp, &hitwallp, &hitact, &hitx, &hity, &hitz, CLIPMASK1); @@ -865,7 +865,7 @@ static void shootrpg(DDukeActor *actor, int p, int sx, int sy, int sz, int sa, i static void shootlaser(DDukeActor* actor, int p, int sx, int sy, int sz, int sa) { spritetype* const s = actor->s; - int sect = s->sectnum; + auto sectp = s->sector(); int zvel; int j; int hitx, hity, hitz; @@ -877,7 +877,7 @@ static void shootlaser(DDukeActor* actor, int p, int sx, int sy, int sz, int sa) zvel = -ps[p].horizon.sum().asq16() >> 11; else zvel = 0; - hitscan(sx, sy, sz - ps[p].pyoff, sect, + hitscan(sx, sy, sz - ps[p].pyoff, sectp, bcos(sa), bsin(sa), zvel << 6, &hitsectp, &wal, &hitsprt, &hitx, &hity, &hitz, CLIPMASK1);