diff --git a/source/games/duke/src/_polymost.cpp b/source/games/duke/src/_polymost.cpp index 00684ab10..3582b7804 100644 --- a/source/games/duke/src/_polymost.cpp +++ b/source/games/duke/src/_polymost.cpp @@ -147,7 +147,7 @@ void se40code(int x, int y, int z, binangle a, fixedhoriz h, int smoothratio) case 43: case 44: case 45: - if (ps[screenpeek].cursector() == act->s->sector()) + if (ps[screenpeek].cursector == act->s->sector()) SE40_Draw(tag, act->s, x, y, z, a, h, smoothratio); break; } diff --git a/source/games/duke/src/actors.cpp b/source/games/duke/src/actors.cpp index 21a9c6fdf..bd1097d06 100644 --- a/source/games/duke/src/actors.cpp +++ b/source/games/duke/src/actors.cpp @@ -207,7 +207,7 @@ void clearcamera(player_struct* ps) ps->pos.y = ps->oposy; ps->pos.z = ps->oposz; ps->angle.restore(); - updatesector(ps->pos.x, ps->pos.y, &ps->cursectnum); + updatesector(ps->pos.x, ps->pos.y, &ps->cursector); DukeStatIterator it(STAT_ACTOR); while (auto k = it.Next()) @@ -360,7 +360,7 @@ void movedummyplayers(void) p = act->GetOwner()->PlayerIndex(); auto spri = act->s; - if ((!isRR() && ps[p].on_crane != nullptr) || !ps[p].insector() || ps[p].cursector()->lotag != 1 || ps->GetActor()->s->extra <= 0) + if ((!isRR() && ps[p].on_crane != nullptr) || !ps[p].insector() || ps[p].cursector->lotag != 1 || ps->GetActor()->s->extra <= 0) { ps[p].dummyplayersprite = nullptr; deletesprite(act); @@ -368,7 +368,7 @@ void movedummyplayers(void) } else { - if (ps[p].on_ground && ps[p].on_warping_sector == 1 && ps[p].cursector()->lotag == 1) + if (ps[p].on_ground && ps[p].on_warping_sector == 1 && ps[p].cursector->lotag == 1) { spri->cstat = CSTAT_SPRITE_BLOCK_ALL; spri->z = spri->sector()->ceilingz + (27 << 8); @@ -619,7 +619,7 @@ void movefx(void) { if (act->temp_data[4] > 0) act->temp_data[4]--; else for (p = connecthead; p >= 0; p = connectpoint2[p]) - if (p == myconnectindex && ps[p].cursector() == spri->sector()) + if (p == myconnectindex && ps[p].cursector == spri->sector()) { S_PlaySound(spri->lotag + (unsigned)global_random % (spri->hitag + 1)); act->temp_data[4] = 26 * 40 + (global_random % (26 * 40)); @@ -1572,7 +1572,7 @@ bool queball(DDukeActor *actor, int pocket, int queball, int stripeball) } } } - if (x < 512 && s->sector() == ps[p].cursector()) + if (x < 512 && s->sector() == ps[p].cursector) { s->ang = getangle(s->x - ps[p].pos.x, s->y - ps[p].pos.y); s->xvel = 48; @@ -1724,7 +1724,7 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p fi.shoot(actor, firelaser); s->ang = a; } - if (t[2] > (26 * 3) || !cansee(s->x, s->y, s->z - (16 << 8), s->sector(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursector())) + if (t[2] > (26 * 3) || !cansee(s->x, s->y, s->z - (16 << 8), s->sector(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursector)) { t[0] = 0; t[2] = 0; @@ -1747,7 +1747,7 @@ void recon(DDukeActor *actor, int explosion, int firelaser, int attacksnd, int p else { t[2]++; - if (t[2] > (26 * 3) || !cansee(s->x, s->y, s->z - (16 << 8), s->sector(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursector())) + if (t[2] > (26 * 3) || !cansee(s->x, s->y, s->z - (16 << 8), s->sector(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursector)) { t[0] = 1; t[2] = 0; @@ -2749,7 +2749,7 @@ void handle_se00(DDukeActor* actor, int LASERLINE) int p; for (p = connecthead; p >= 0; p = connectpoint2[p]) { - if (ps[p].cursector() == s->sector() && ps[p].on_ground == 1) + if (ps[p].cursector == s->sector() && ps[p].on_ground == 1) { ps[p].angle.addadjustment(l * q); @@ -2905,9 +2905,9 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) auto psp = ps[p].GetActor(); if (psp->s->extra > 0) { - auto k = ps[p].cursector(); + auto k = ps[p].cursector; updatesector(ps[p].pos.x, ps[p].pos.y, &k); - if ((k == nullptr && ud.clipping == 0) || (k == s->sector() && ps[p].cursector() != s->sector())) + if ((k == nullptr && ud.clipping == 0) || (k == s->sector() && ps[p].cursector != s->sector())) { ps[p].pos.x = s->x; ps[p].pos.y = s->y; @@ -2926,7 +2926,7 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) for (int p = connecthead; p >= 0; p = connectpoint2[p]) { auto psp = ps[p].GetActor(); - if (ps[p].insector() && ps[p].cursector()->lotag != 2) + if (ps[p].insector() && ps[p].cursector->lotag != 2) { if (po[p].os == s->sector()) { @@ -2989,9 +2989,9 @@ void handle_se14(DDukeActor* actor, bool checkstat, int RPG, int JIBS6) { if (ps[p].GetActor()->s->extra > 0) { - auto k = ps[p].cursector(); + auto k = ps[p].cursector; updatesector(ps[p].pos.x, ps[p].pos.y, &k); - if ((k == nullptr && ud.clipping == 0) || (k == s->sector() && ps[p].cursector() != s->sector())) + if ((k == nullptr && ud.clipping == 0) || (k == s->sector() && ps[p].cursector != s->sector())) { ps[p].oposx = ps[p].pos.x = s->x; ps[p].oposy = ps[p].pos.y = s->y; @@ -3092,9 +3092,9 @@ void handle_se30(DDukeActor *actor, int JIBS6) auto psp = ps[p].GetActor(); if (psp->s->extra > 0) { - auto k = ps[p].cursector(); + auto k = ps[p].cursector; updatesector(ps[p].pos.x, ps[p].pos.y, &k); - if ((k == nullptr && ud.clipping == 0) || (k == s->sector() && ps[p].cursector() != s->sector())) + if ((k == nullptr && ud.clipping == 0) || (k == s->sector() && ps[p].cursector != s->sector())) { ps[p].pos.x = s->x; ps[p].pos.y = s->y; @@ -3155,9 +3155,9 @@ void handle_se30(DDukeActor *actor, int JIBS6) for (int p = connecthead; p >= 0; p = connectpoint2[p]) if (ps[p].GetActor()->s->extra > 0) { - auto k = ps[p].cursector(); + auto k = ps[p].cursector; updatesector(ps[p].pos.x, ps[p].pos.y, &k); - if ((k == nullptr && ud.clipping == 0) || (k == s->sector() && ps[p].cursector() != s->sector())) + if ((k == nullptr && ud.clipping == 0) || (k == s->sector() && ps[p].cursector != s->sector())) { ps[p].pos.x = s->x; ps[p].pos.y = s->y; @@ -3248,7 +3248,7 @@ void handle_se02(DDukeActor* actor) for (int p = connecthead; p >= 0; p = connectpoint2[p]) - if (ps[p].cursector() == s->sector() && ps[p].on_ground) + if (ps[p].cursector == s->sector() && ps[p].on_ground) { ps[p].pos.x += m; ps[p].pos.y += x; @@ -4282,7 +4282,7 @@ void handle_se20(DDukeActor* actor) dragpoint(wal[1], wal[1]->x + x, wal[1]->y + l); for (int p = connecthead; p >= 0; p = connectpoint2[p]) - if (ps[p].cursector() == s->sector() && ps[p].on_ground) + if (ps[p].cursector == s->sector() && ps[p].on_ground) { ps[p].pos.x += x; ps[p].pos.y += l; @@ -4437,7 +4437,7 @@ void handle_se27(DDukeActor* actor) } else if (ud.recstat == 2 && ps[p].newOwner == nullptr) { - if (cansee(s->x, s->y, s->z, s->sector(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursector())) + if (cansee(s->x, s->y, s->z, s->sector(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursector)) { if (x < sh) { @@ -4539,7 +4539,7 @@ void handle_se24(DDukeActor *actor, const int16_t *list1, const int16_t *list2, for (auto p = connecthead; p >= 0; p = connectpoint2[p]) { - if (ps[p].cursector() == actor->s->sector() && ps[p].on_ground) + if (ps[p].cursector == actor->s->sector() && ps[p].on_ground) { if (abs(ps[p].pos.z - ps[p].truefz) < gs.playerheight + (9 << 8)) { diff --git a/source/games/duke/src/actors_d.cpp b/source/games/duke/src/actors_d.cpp index 7a8183d2d..4b04daace 100644 --- a/source/games/duke/src/actors_d.cpp +++ b/source/games/duke/src/actors_d.cpp @@ -730,13 +730,13 @@ void movefta_d(void) int r1 = krand(); int r2 = krand(); - j = cansee(sx, sy, s->z - (r2 % (52 << 8)), s->sector(), px, py, ps[p].oposz - (r1 % (32 << 8)), ps[p].cursector()); + j = cansee(sx, sy, s->z - (r2 % (52 << 8)), s->sector(), px, py, ps[p].oposz - (r1 % (32 << 8)), ps[p].cursector); } else { int r1 = krand(); int r2 = krand(); - j = cansee(s->x, s->y, s->z - ((r2 & 31) << 8), s->sector(), ps[p].oposx, ps[p].oposy, ps[p].oposz - ((r1 & 31) << 8), ps[p].cursector()); + j = cansee(s->x, s->y, s->z - ((r2 & 31) << 8), s->sector(), ps[p].oposx, ps[p].oposy, ps[p].oposz - ((r1 & 31) << 8), ps[p].cursector); } @@ -2032,7 +2032,7 @@ void movetransports_d(void) } for (int k = connecthead; k >= 0; k = connectpoint2[k]) - if (ps[k].cursector() == Owner->sector()) + if (ps[k].cursector == Owner->sector()) { ps[k].frag_ps = p; ps[k].GetActor()->s->extra = 0; @@ -2451,7 +2451,7 @@ static void greenslime(DDukeActor *actor) ps[p].pos.z = ps[p].oposz; ps[p].angle.restore(); - updatesector(ps[p].pos.x, ps[p].pos.y, &ps[p].cursectnum); + updatesector(ps[p].pos.x, ps[p].pos.y, &ps[p].cursector); DukeStatIterator it(STAT_ACTOR); while (auto ac = it.Next()) @@ -2985,7 +2985,7 @@ DETONATEB: } } else if (s->picnum == HEAVYHBOMB && x < 788 && t[0] > 7 && s->xvel == 0) - if (cansee(s->x, s->y, s->z - (8 << 8), s->sector(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursector())) + if (cansee(s->x, s->y, s->z - (8 << 8), s->sector(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursector)) if (ps[p].ammo_amount[HANDBOMB_WEAPON] < gs.max_ammo_amount[HANDBOMB_WEAPON]) { if (ud.coop >= 1 && Owner == actor) @@ -3543,7 +3543,7 @@ static void handle_se28(DDukeActor* actor) } else if (t[2] > (t[1] >> 3) && t[2] < (t[1] >> 2)) { - int j = !!cansee(s->x, s->y, s->z, s->sector(), ps[screenpeek].pos.x, ps[screenpeek].pos.y, ps[screenpeek].pos.z, ps[screenpeek].cursector()); + int j = !!cansee(s->x, s->y, s->z, s->sector(), ps[screenpeek].pos.x, ps[screenpeek].pos.y, ps[screenpeek].pos.z, ps[screenpeek].cursector); if (rnd(192) && (t[2] & 1)) { diff --git a/source/games/duke/src/actors_r.cpp b/source/games/duke/src/actors_r.cpp index 3e07190d0..17fcaf047 100644 --- a/source/games/duke/src/actors_r.cpp +++ b/source/games/duke/src/actors_r.cpp @@ -553,14 +553,14 @@ void movefta_r(void) { int r1 = krand(); int r2 = krand(); - j = cansee(sx, sy, s->z - (r2 % (52 << 8)), s->sector(), px, py, ps[p].oposz - (r1 % (32 << 8)), ps[p].cursector()); + j = cansee(sx, sy, s->z - (r2 % (52 << 8)), s->sector(), px, py, ps[p].oposz - (r1 % (32 << 8)), ps[p].cursector); } } else { int r1 = krand(); int r2 = krand(); - j = cansee(s->x, s->y, s->z - ((r2 & 31) << 8), s->sector(), ps[p].oposx, ps[p].oposy, ps[p].oposz - ((r1 & 31) << 8), ps[p].cursector()); + j = cansee(s->x, s->y, s->z - ((r2 & 31) << 8), s->sector(), ps[p].oposx, ps[p].oposy, ps[p].oposz - ((r1 & 31) << 8), ps[p].cursector); } @@ -1611,7 +1611,7 @@ void movetransports_r(void) S_PlayActorSound(TELEPORTER, act); for (k = connecthead; k >= 0; k = connectpoint2[k]) - if (ps[k].cursector() == Owner->sector()) + if (ps[k].cursector == Owner->sector()) { ps[k].frag_ps = p; ps[k].GetActor()->s->extra = 0; @@ -2691,7 +2691,7 @@ DETONATEB: } } else if (s->picnum == HEAVYHBOMB && x < 788 && t[0] > 7 && s->xvel == 0) - if (cansee(s->x, s->y, s->z - (8 << 8), s->sector(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursector())) + if (cansee(s->x, s->y, s->z - (8 << 8), s->sector(), ps[p].pos.x, ps[p].pos.y, ps[p].pos.z, ps[p].cursector)) if (ps[p].ammo_amount[DYNAMITE_WEAPON] < gs.max_ammo_amount[DYNAMITE_WEAPON]) if (s->pal == 0) { diff --git a/source/games/duke/src/game_misc.cpp b/source/games/duke/src/game_misc.cpp index 928297cd8..b95f748aa 100644 --- a/source/games/duke/src/game_misc.cpp +++ b/source/games/duke/src/game_misc.cpp @@ -60,8 +60,8 @@ FString GameInterface::GetCoordString() FString out; out.Format("pos= %d, %d, %d - angle = %2.3f - sector = %d, lotag = %d, hitag = %d", - ps[snum].pos.x, ps[snum].pos.y, ps[snum].pos.z, ps[snum].angle.ang.asdeg(), ps[snum].cursectnum, - ps[snum].cursector()->lotag, ps[snum].cursector()->hitag); + ps[snum].pos.x, ps[snum].pos.y, ps[snum].pos.z, ps[snum].angle.ang.asdeg(), sectnum(ps[snum].cursector), + ps[snum].cursector->lotag, ps[snum].cursector->hitag); return out; } @@ -238,7 +238,7 @@ void drawoverlays(double smoothratio) else videoclearFade(); - MarkSectorSeen(pp->cursectnum); + MarkSectorSeen(sectnum(pp->cursector)); if (ud.cameraactor == nullptr) { @@ -250,7 +250,7 @@ void drawoverlays(double smoothratio) { fi.displayweapon(screenpeek, smoothratio); if (pp->over_shoulder_on == 0) - fi.displaymasks(screenpeek, pp->GetActor()->s->pal == 1 || !pp->insector() ? 1 : pp->cursector()->floorpal, smoothratio); + fi.displaymasks(screenpeek, pp->GetActor()->s->pal == 1 || !pp->insector() ? 1 : pp->cursector->floorpal, smoothratio); } if (!isRR()) moveclouds(smoothratio); diff --git a/source/games/duke/src/gameexec.cpp b/source/games/duke/src/gameexec.cpp index b5c325475..7dcd5c9aa 100644 --- a/source/games/duke/src/gameexec.cpp +++ b/source/games/duke/src/gameexec.cpp @@ -2030,7 +2030,7 @@ int ParseState::parse(void) ps[g_p].pos.y = ps[g_p].oposy; ps[g_p].pos.z = ps[g_p].oposz; ps[g_p].angle.restore(); - updatesector(ps[g_p].pos.x,ps[g_p].pos.y,&ps[g_p].cursectnum); + updatesector(ps[g_p].pos.x,ps[g_p].pos.y,&ps[g_p].cursector); DukeStatIterator it(STAT_ACTOR); while (auto j = it.Next()) @@ -2209,7 +2209,7 @@ int ParseState::parse(void) g_sp->y = ps[g_p].bobposy = ps[g_p].oposy = ps[g_p].pos.y; g_sp->z = ps[g_p].oposz = ps[g_p].pos.z; g_sp->backuppos(); - updatesector(ps[g_p].pos.x, ps[g_p].pos.y, &ps[g_p].cursectnum); + updatesector(ps[g_p].pos.x, ps[g_p].pos.y, &ps[g_p].cursector); setsprite(ps[g_p].GetActor(), ps[g_p].pos.x, ps[g_p].pos.y, ps[g_p].pos.z + gs.playerheight); g_sp->cstat = 257; diff --git a/source/games/duke/src/hudweapon_d.cpp b/source/games/duke/src/hudweapon_d.cpp index 0ec879cc4..f93835a70 100644 --- a/source/games/duke/src/hudweapon_d.cpp +++ b/source/games/duke/src/hudweapon_d.cpp @@ -251,7 +251,7 @@ void displayweapon_d(int snum, double smoothratio) shade = p->GetActor()->s->shade; if(shade > 24) shade = 24; - pal = !p->insector() ? 0 : p->GetActor()->s->pal == 1 ? 1 : p->cursector()->floorpal; + pal = !p->insector() ? 0 : p->GetActor()->s->pal == 1 ? 1 : p->cursector->floorpal; if (pal == 0) pal = p->palookup; @@ -1162,7 +1162,7 @@ void displayweapon_d(int snum, double smoothratio) auto displayflamethrower = [&]() { - if (*kb < 1 || p->cursector()->lotag == 2) + if (*kb < 1 || p->cursector->lotag == 2) { hud_drawpal(weapon_xoffset + 210 - look_anghalf, looking_arc + 261 - gun_pos, FLAMETHROWER, shade, o, pal); hud_drawpal(weapon_xoffset + 210 - look_anghalf, looking_arc + 261 - gun_pos, FLAMETHROWERPILOT, shade, o, pal); diff --git a/source/games/duke/src/hudweapon_r.cpp b/source/games/duke/src/hudweapon_r.cpp index 5aaa7a40e..c556b0302 100644 --- a/source/games/duke/src/hudweapon_r.cpp +++ b/source/games/duke/src/hudweapon_r.cpp @@ -144,13 +144,13 @@ void displayweapon_r(int snum, double smoothratio) weapon_xoffset -= bcosf(weapon_sway * 0.5) * (1. / 1536.); weapon_xoffset -= 58 + p->weapon_ang; - if (p->insector() && p->cursector()->shadedsector == 1) + if (p->insector() && p->cursector->shadedsector == 1) shade = 16; else shade = p->GetActor()->s->shade; if(shade > 24) shade = 24; - pal = !p->insector()? 0 : p->GetActor()->s->pal == 1? 1 : p->cursector()->floorpal; + pal = !p->insector()? 0 : p->GetActor()->s->pal == 1? 1 : p->cursector->floorpal; if(p->newOwner != nullptr || ud.cameraactor != nullptr || p->over_shoulder_on > 0 || (p->GetActor()->s->pal != 1 && p->GetActor()->s->extra <= 0)) return; diff --git a/source/games/duke/src/inlines.h b/source/games/duke/src/inlines.h index ab0b64579..398d2f202 100644 --- a/source/games/duke/src/inlines.h +++ b/source/games/duke/src/inlines.h @@ -189,8 +189,8 @@ inline bool playrunning() inline void doslopetilting(player_struct* p, double const scaleAdjust = 1) { - bool const canslopetilt = p->on_ground && p->insector() && p->cursector()->lotag != ST_2_UNDERWATER && (p->cursector()->floorstat & 2); - p->horizon.calcviewpitch(p->pos.vec2, p->angle.ang, p->aim_mode == 0, canslopetilt, p->cursectnum, scaleAdjust); + bool const canslopetilt = p->on_ground && p->insector() && p->cursector->lotag != ST_2_UNDERWATER && (p->cursector->floorstat & 2); + p->horizon.calcviewpitch(p->pos.vec2, p->angle.ang, p->aim_mode == 0, canslopetilt, sectnum(p->cursector), scaleAdjust); } //--------------------------------------------------------------------------- @@ -201,7 +201,7 @@ inline void doslopetilting(player_struct* p, double const scaleAdjust = 1) inline void hud_draw(double x, double y, int tilenum, int shade, int orientation) { - int p = ps[screenpeek].cursector()->floorpal; + int p = ps[screenpeek].cursector->floorpal; hud_drawsprite(x, y, 65536, 0, tilenum, shade, p, 2 | orientation); } diff --git a/source/games/duke/src/input.cpp b/source/games/duke/src/input.cpp index 9073ba610..8d58faec4 100644 --- a/source/games/duke/src/input.cpp +++ b/source/games/duke/src/input.cpp @@ -281,7 +281,7 @@ void hud_input(int plnum) p->inven_icon = 3; auto pactor = - EGS(p->cursector(), + EGS(p->cursector, p->pos.x, p->pos.y, p->pos.z + (30 << 8), TILE_APLAYER, -64, 0, 0, p->angle.ang.asbuild(), 0, 0, nullptr, 10); @@ -335,7 +335,7 @@ void hud_input(int plnum) S_PlayActorSound(390, pact); p->noise_radius = 16384; madenoise(plnum); - if (p->cursector()->lotag == 857) + if (p->cursector->lotag == 857) { if (p->GetActor()->s->extra <= gs.max_player_health) { @@ -526,7 +526,7 @@ enum static void processInputBits(player_struct *p, ControlInfo* const hidInput) { // Set-up crouch bools. - int const sectorLotag = p->insector() ? p->cursector()->lotag : 0; + int const sectorLotag = p->insector() ? p->cursector->lotag : 0; bool const crouchable = sectorLotag != ST_2_UNDERWATER && (sectorLotag != ST_1_ABOVE_WATER || p->spritebridge); bool const disableToggle = p->jetpack_on || (!crouchable && p->on_ground) || (isRRRA() && (p->OnMotorcycle || p->OnBoat)); diff --git a/source/games/duke/src/player.cpp b/source/games/duke/src/player.cpp index 12b4163a3..cc9653dee 100644 --- a/source/games/duke/src/player.cpp +++ b/source/games/duke/src/player.cpp @@ -84,8 +84,8 @@ int setpal(struct player_struct* p) if (p->DrugMode) palette = DRUGPAL; else if (p->heat_on) palette = SLIMEPAL; else if (!p->insector()) palette = BASEPAL; // don't crash if out of range. - else if (p->cursector()->ceilingpicnum >= TILE_FLOORSLIME && p->cursector()->ceilingpicnum <= TILE_FLOORSLIME + 2) palette = SLIMEPAL; - else if (p->cursector()->lotag == ST_2_UNDERWATER) palette = WATERPAL; + else if (p->cursector->ceilingpicnum >= TILE_FLOORSLIME && p->cursector->ceilingpicnum <= TILE_FLOORSLIME + 2) palette = SLIMEPAL; + else if (p->cursector->lotag == ST_2_UNDERWATER) palette = WATERPAL; else palette = BASEPAL; return palette; } @@ -215,7 +215,7 @@ int hitawall(struct player_struct* p, walltype** hitw) { int sx, sy, sz; - hitscan(p->pos.x, p->pos.y, p->pos.z, p->cursector(), + hitscan(p->pos.x, p->pos.y, p->pos.z, p->cursector, p->angle.ang.bcos(), p->angle.ang.bsin(), 0, nullptr, hitw, nullptr, &sx, &sy, &sz, CLIPMASK0); return (FindDistance2D(sx - p->pos.x, sy - p->pos.y)); @@ -488,7 +488,7 @@ void footprints(int snum) auto psect = s->sectnum; if (p->footprintcount > 0 && p->on_ground) - if ((p->cursector()->floorstat & 2) != 2) + if ((p->cursector->floorstat & 2) != 2) { int j = -1; DukeSectIterator it(psect); @@ -505,7 +505,7 @@ void footprints(int snum) if (j < 0) { p->footprintcount--; - if (p->cursector()->lotag == 0 && p->cursector()->hitag == 0) + if (p->cursector->lotag == 0 && p->cursector->hitag == 0) { DDukeActor* fprint; switch (krand() & 3) @@ -607,16 +607,16 @@ void playerisdead(int snum, int psectlotag, int fz, int cz) } Collision coll; - clipmove_ex(&p->pos, &p->cursectnum, 0, 0, 164, (4 << 8), (4 << 8), CLIPMASK0, coll); + clipmove_ex(&p->pos, &p->cursector, 0, 0, 164, (4 << 8), (4 << 8), CLIPMASK0, coll); } backupplayer(p); p->horizon.horizoff = p->horizon.horiz = q16horiz(0); - updatesector(p->pos.x, p->pos.y, &p->cursectnum); + updatesector(p->pos.x, p->pos.y, &p->cursector); - pushmove(&p->pos, &p->cursectnum, 128L, (4 << 8), (20 << 8), CLIPMASK0); + pushmove(&p->pos, &p->cursector, 128L, (4 << 8), (20 << 8), CLIPMASK0); if (fz > cz + (16 << 8) && s->pal != 1) p->angle.rotscrnang = buildang(p->dead_flag + ((fz + p->pos.z) >> 7)); @@ -1098,7 +1098,7 @@ DEFINE_FIELD_X(DukePlayer, player_struct, randomflamex) DEFINE_FIELD_X(DukePlayer, player_struct, crack_time) DEFINE_FIELD_X(DukePlayer, player_struct, aim_mode) DEFINE_FIELD_X(DukePlayer, player_struct, ftt) -DEFINE_FIELD_X(DukePlayer, player_struct, cursectnum) +DEFINE_FIELD_X(DukePlayer, player_struct, cursector) DEFINE_FIELD_X(DukePlayer, player_struct, last_extra) DEFINE_FIELD_X(DukePlayer, player_struct, subweapon) DEFINE_FIELD_X(DukePlayer, player_struct, ammo_amount) diff --git a/source/games/duke/src/player_d.cpp b/source/games/duke/src/player_d.cpp index 3ff526dbd..3f489010f 100644 --- a/source/games/duke/src/player_d.cpp +++ b/source/games/duke/src/player_d.cpp @@ -1607,7 +1607,7 @@ int doincrements_d(struct player_struct* p) } } - if (p->scuba_on == 0 && p->insector() && p->cursector()->lotag == 2) + if (p->scuba_on == 0 && p->insector() && p->cursector->lotag == 2) { if (p->scuba_amount > 0) { @@ -1811,7 +1811,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int p->dummyplayersprite = spawn(pact, PLAYERONWATER); p->footprintcount = 6; - if (p->cursector()->floorpicnum == FLOORSLIME) + if (p->cursector->floorpicnum == FLOORSLIME) p->footprintpal = 8; else p->footprintpal = 0; p->footprintshade = 0; @@ -1844,7 +1844,7 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int if ((p->pos.z + p->poszv) >= (fz - (i << 8))) // hit the ground { S_StopSound(DUKE_SCREAM, pact); - if (!p->insector() || p->cursector()->lotag != 1) + if (!p->insector() || p->cursector->lotag != 1) { if (p->falling_counter > 62) quickkill(p); @@ -2055,7 +2055,7 @@ int operateTripbomb(int snum) walltype* wal; hitscan(p->pos.x, p->pos.y, p->pos.z, - p->cursector(), p->angle.ang.bcos(), + p->cursector, p->angle.ang.bcos(), p->angle.ang.bsin(), -p->horizon.sum().asq16() >> 11, &hitsectp, &wal, &hitsprt, &sx, &sy, &sz, CLIPMASK1); @@ -2195,7 +2195,7 @@ static void fireweapon(int snum) if (isWorldTour() && p->ammo_amount[FLAMETHROWER_WEAPON] > 0) { p->kickback_pic = 1; - if (p->cursector()->lotag != 2) + if (p->cursector->lotag != 2) S_PlayActorSound(FLAMETHROWER_INTRO, pact); } break; @@ -2247,7 +2247,7 @@ static void operateweapon(int snum, ESyncBits actions) i = -512 - MulScale(p->horizon.sum().asq16(), 20, 16); } - auto spawned = EGS(p->cursector(), + auto spawned = EGS(p->cursector, p->pos.x + p->angle.ang.bcos(-6), p->pos.y + p->angle.ang.bsin(-6), p->pos.z, HEAVYHBOMB, -16, 9, 9, @@ -2599,7 +2599,7 @@ static void operateweapon(int snum, ESyncBits actions) p->kickback_pic++; if (p->kickback_pic == 2) { - if (p->cursector()->lotag != 2) + if (p->cursector->lotag != 2) { p->ammo_amount[FLAMETHROWER_WEAPON]--; if (snum == screenpeek) @@ -2775,7 +2775,7 @@ void processinput_d(int snum) auto sb_svel = PlayerInputSideVel(snum); auto sb_avel = PlayerInputAngVel(snum); - auto psectp = p->cursector(); + auto psectp = p->cursector; if (psectp == nullptr) { if (s->extra > 0 && ud.clipping == 0) @@ -2899,7 +2899,7 @@ void processinput_d(int snum) s->xvel = clamp(ksqrt((p->pos.x - p->bobposx) * (p->pos.x - p->bobposx) + (p->pos.y - p->bobposy) * (p->pos.y - p->bobposy)), 0, 512); if (p->on_ground) p->bobcounter += p->GetActor()->s->xvel >> 1; - p->backuppos(ud.clipping == 0 && (p->cursector()->floorpicnum == MIRROR || !p->insector())); + p->backuppos(ud.clipping == 0 && (p->cursector->floorpicnum == MIRROR || !p->insector())); // Shrinking code @@ -3061,7 +3061,7 @@ HORIZONLY: if (psectlotag == 1 || p->spritebridge == 1) ii = (4L << 8); else ii = (20L << 8); - if (p->insector() && p->cursector()->lotag == 2) k = 0; + if (p->insector() && p->cursector->lotag == 2) k = 0; else k = 1; Collision clip{}; @@ -3069,11 +3069,11 @@ HORIZONLY: { p->pos.x += p->posxv >> 14; p->pos.y += p->posyv >> 14; - updatesector(p->pos.x, p->pos.y, &p->cursectnum); - changeactorsect(pact, p->cursector()); + updatesector(p->pos.x, p->pos.y, &p->cursector); + changeactorsect(pact, p->cursector); } else - clipmove_ex(&p->pos, &p->cursectnum, p->posxv, p->posyv, 164, (4 << 8), ii, CLIPMASK0, clip); + clipmove_ex(&p->pos, &p->cursector, p->posxv, p->posyv, 164, (4 << 8), ii, CLIPMASK0, clip); if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) p->pos.z += 32 << 8; @@ -3113,15 +3113,15 @@ HORIZONLY: } } - if (truefdist < gs.playerheight && p->on_ground && psectlotag != 1 && shrunk == 0 && p->insector() && p->cursector()->lotag == 1) + if (truefdist < gs.playerheight && p->on_ground && psectlotag != 1 && shrunk == 0 && p->insector() && p->cursector->lotag == 1) if (!S_CheckActorSoundPlaying(pact, DUKE_ONWATER)) S_PlayActorSound(DUKE_ONWATER, pact); - if (p->cursector() != s->sector()) - changeactorsect(pact, p->cursector()); + if (p->cursector != s->sector()) + changeactorsect(pact, p->cursector); if (ud.clipping == 0) - j = (pushmove(&p->pos, &p->cursectnum, 164L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); + j = (pushmove(&p->pos, &p->cursector, 164L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); else j = 0; if (ud.clipping == 0) diff --git a/source/games/duke/src/player_r.cpp b/source/games/duke/src/player_r.cpp index 2750ddf2c..87ab9ec11 100644 --- a/source/games/duke/src/player_r.cpp +++ b/source/games/duke/src/player_r.cpp @@ -1446,7 +1446,7 @@ int doincrements_r(struct player_struct* p) } } - if (p->scuba_on == 0 && p->insector() && p->cursector()->lotag == 2) + if (p->scuba_on == 0 && p->insector() && p->cursector->lotag == 2) { if (p->scuba_amount > 0) { @@ -2109,12 +2109,12 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int p->dummyplayersprite = spawn(pact, PLAYERONWATER); p->footprintcount = 6; - if (p->cursector()->floorpicnum == FLOORSLIME) + if (p->cursector->floorpicnum == FLOORSLIME) { p->footprintpal = 8; p->footprintshade = 0; } - else if (isRRRA() && (p->cursector()->floorpicnum == RRTILE7756 || p->cursector()->floorpicnum == RRTILE7888)) + else if (isRRRA() && (p->cursector->floorpicnum == RRTILE7756 || p->cursector->floorpicnum == RRTILE7888)) { p->footprintpal = 0; p->footprintshade = 40; @@ -2173,10 +2173,10 @@ static void movement(int snum, ESyncBits actions, sectortype* psect, int fz, int if ((p->pos.z + p->poszv) >= (fz - (i << 8))) // hit the ground { S_StopSound(DUKE_SCREAM, pact); - if (!p->insector() || p->cursector()->lotag != 1) + if (!p->insector() || p->cursector->lotag != 1) { if (isRRRA()) p->MotoOnGround = 1; - if (p->falling_counter > 62 || (isRRRA() && p->falling_counter > 2 && p->insector() && p->cursector()->lotag == 802)) + if (p->falling_counter > 62 || (isRRRA() && p->falling_counter > 2 && p->insector() && p->cursector->lotag == 802)) quickkill(p); else if (p->falling_counter > 9) @@ -2767,7 +2767,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) i = -512 - MulScale(p->horizon.sum().asq16(), 20, 16); } - auto spawned = EGS(p->cursector(), + auto spawned = EGS(p->cursector, p->pos.x + p->angle.ang.bcos(-6), p->pos.y + p->angle.ang.bsin(-6), p->pos.z, HEAVYHBOMB, -16, 9, 9, @@ -3183,7 +3183,7 @@ static void operateweapon(int snum, ESyncBits actions, sectortype* psectp) i = -512 - MulScale(p->horizon.sum().asq16(), 20, 16); } - EGS(p->cursector(), + EGS(p->cursector, p->pos.x + p->angle.ang.bcos(-6), p->pos.y + p->angle.ang.bsin(-6), p->pos.z, TRIPBOMBSPRITE, -16, 9, 9, @@ -3379,7 +3379,7 @@ void processinput_r(int snum) auto sb_svel = PlayerInputSideVel(snum); auto sb_avel = PlayerInputAngVel(snum); - auto psectp = p->cursector(); + auto psectp = p->cursector; if (p->OnMotorcycle && s->extra > 0) { onMotorcycle(snum, actions); @@ -3596,7 +3596,7 @@ void processinput_r(int snum) s->xvel = clamp(ksqrt((p->pos.x - p->bobposx) * (p->pos.x - p->bobposx) + (p->pos.y - p->bobposy) * (p->pos.y - p->bobposy)), 0, 512); if (p->on_ground) p->bobcounter += p->GetActor()->s->xvel >> 1; - p->backuppos(ud.clipping == 0 && (p->cursector()->floorpicnum == MIRROR || !p->insector())); + p->backuppos(ud.clipping == 0 && (p->cursector->floorpicnum == MIRROR || !p->insector())); // Shrinking code @@ -3605,7 +3605,7 @@ void processinput_r(int snum) if (psectlotag == ST_17_PLATFORM_UP || (isRRRA() && psectlotag == ST_18_ELEVATOR_DOWN)) { int tmp; - tmp = getanimationgoal(anim_floorz, p->cursector()); + tmp = getanimationgoal(anim_floorz, p->cursector); if (tmp >= 0) { if (!S_CheckActorSoundPlaying(pact, 432)) @@ -3707,7 +3707,7 @@ void processinput_r(int snum) break; case 1: if ((krand() & 1) == 0) - if (!isRRRA() || (!p->OnBoat && !p->OnMotorcycle && p->cursector()->hitag != 321)) + if (!isRRRA() || (!p->OnBoat && !p->OnMotorcycle && p->cursector->hitag != 321)) S_PlayActorSound(DUKE_ONWATER, pact); p->walking_snd_toggle = 1; break; @@ -3802,7 +3802,7 @@ HORIZONLY: if (psectlotag == 1 || p->spritebridge == 1) i = (4L << 8); else i = (20L << 8); - if (p->insector() && p->cursector()->lotag == 2) k = 0; + if (p->insector() && p->cursector->lotag == 2) k = 0; else k = 1; Collision clip{}; @@ -3810,11 +3810,11 @@ HORIZONLY: { p->pos.x += p->posxv >> 14; p->pos.y += p->posyv >> 14; - updatesector(p->pos.x, p->pos.y, &p->cursectnum); - changeactorsect(pact, p->cursector()); + updatesector(p->pos.x, p->pos.y, &p->cursector); + changeactorsect(pact, p->cursector); } else - clipmove_ex(&p->pos, &p->cursectnum, p->posxv, p->posyv, 164, (4 << 8), i, CLIPMASK0, clip); + clipmove_ex(&p->pos, &p->cursector, p->posxv, p->posyv, 164, (4 << 8), i, CLIPMASK0, clip); if (p->jetpack_on == 0 && psectlotag != 2 && psectlotag != 1 && shrunk) p->pos.z += 32 << 8; @@ -3842,11 +3842,11 @@ HORIZONLY: { if (wal->lotag < 44) { - dofurniture(clip.wall(), p->cursector(), snum); - pushmove(&p->pos, &p->cursectnum, 172L, (4L << 8), (4L << 8), CLIPMASK0); + dofurniture(clip.wall(), p->cursector, snum); + pushmove(&p->pos, &p->cursector, 172L, (4L << 8), (4L << 8), CLIPMASK0); } else - pushmove(&p->pos, &p->cursectnum, 172L, (4L << 8), (4L << 8), CLIPMASK0); + pushmove(&p->pos, &p->cursector, 172L, (4L << 8), (4L << 8), CLIPMASK0); } } } @@ -3934,21 +3934,21 @@ HORIZONLY: } } - if (truefdist < gs.playerheight && p->on_ground && psectlotag != 1 && shrunk == 0 && p->insector() && p->cursector()->lotag == 1) + if (truefdist < gs.playerheight && p->on_ground && psectlotag != 1 && shrunk == 0 && p->insector() && p->cursector->lotag == 1) if (!S_CheckActorSoundPlaying(pact, DUKE_ONWATER)) - if (!isRRRA() || (!p->OnBoat && !p->OnMotorcycle && p->cursector()->hitag != 321)) + if (!isRRRA() || (!p->OnBoat && !p->OnMotorcycle && p->cursector->hitag != 321)) S_PlayActorSound(DUKE_ONWATER, pact); - if (p->cursector() != s->sector()) - changeactorsect(pact, p->cursector()); + if (p->cursector != s->sector()) + changeactorsect(pact, p->cursector); int j; if (ud.clipping == 0) { if (s->clipdist == 64) - j = (pushmove(&p->pos, &p->cursectnum, 128L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); + j = (pushmove(&p->pos, &p->cursector, 128L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); else - j = (pushmove(&p->pos, &p->cursectnum, 16L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); + j = (pushmove(&p->pos, &p->cursector, 16L, (4L << 8), (4L << 8), CLIPMASK0) < 0 && furthestangle(p->GetActor(), 8) < 512); } else j = 0; @@ -3969,7 +3969,7 @@ HORIZONLY: fi.activatebysector(psectp, pact); } - if (ud.clipping == 0 && p->cursector()->ceilingz > (p->cursector()->floorz - (12 << 8))) + if (ud.clipping == 0 && p->cursector->ceilingz > (p->cursector->floorz - (12 << 8))) { quickkill(p); return; @@ -4053,7 +4053,7 @@ HORIZONLY: void OnMotorcycle(struct player_struct *p, DDukeActor* motosprite) { - if (!p->OnMotorcycle && !(p->cursector()->lotag == 2)) + if (!p->OnMotorcycle && !(p->cursector->lotag == 2)) { if (motosprite) { diff --git a/source/games/duke/src/player_w.cpp b/source/games/duke/src/player_w.cpp index cd1ca3ae8..4d35c5302 100644 --- a/source/games/duke/src/player_w.cpp +++ b/source/games/duke/src/player_w.cpp @@ -341,7 +341,7 @@ void operateweapon_ww(int snum, ESyncBits actions) i = -512 - MulScale(p->horizon.sum().asq16(), 20, 16); } - auto j = EGS(p->cursector(), + auto j = EGS(p->cursector, p->pos.x + p->angle.ang.bcos(-6), p->pos.y + p->angle.ang.bsin(-6), p->pos.z, HEAVYHBOMB, -16, 9, 9, diff --git a/source/games/duke/src/prediction.cpp b/source/games/duke/src/prediction.cpp index 52f3e3170..13780b8ce 100644 --- a/source/games/duke/src/prediction.cpp +++ b/source/games/duke/src/prediction.cpp @@ -57,7 +57,7 @@ void resetmys() myang = ps[myconnectindex].angle.ang; myhoriz = omyhoriz = ps[myconnectindex].horizon.horiz; myhorizoff = omyhorizoff = ps[myconnectindex].horizon.horizoff; - mycursectnum = ps[myconnectindex].cursectnum; + mycursectnum = sectnum(ps[myconnectindex].cursector); myjumpingcounter = ps[myconnectindex].jumping_counter; myjumpingtoggle = ps[myconnectindex].jumping_toggle; myonground = ps[myconnectindex].on_ground; diff --git a/source/games/duke/src/premap.cpp b/source/games/duke/src/premap.cpp index 1cb857a45..569862c44 100644 --- a/source/games/duke/src/premap.cpp +++ b/source/games/duke/src/premap.cpp @@ -508,7 +508,7 @@ void resetpspritevars(int g) int aimmode[MAXPLAYERS]; STATUSBARTYPE tsbar[MAXPLAYERS]; - EGS(ps[0].cursector(), ps[0].pos.x, ps[0].pos.y, ps[0].pos.z, + EGS(ps[0].cursector, ps[0].pos.x, ps[0].pos.y, ps[0].pos.z, TILE_APLAYER, 0, 0, 0, ps[0].angle.ang.asbuild(), 0, 0, nullptr, 10); if (ud.recstat != 2) for (i = 0; i < MAXPLAYERS; i++) @@ -634,7 +634,7 @@ void resetpspritevars(int g) s->backuppos(); ps[j].angle.oang = ps[j].angle.ang = buildang(s->ang); - updatesector(s->x, s->y, &ps[j].cursectnum); + updatesector(s->x, s->y, &ps[j].cursector); j = connectpoint2[j]; @@ -945,8 +945,8 @@ static int LoadTheMap(MapRecord *mi, struct player_struct *p, int gamemode) currentLevel = mi; int sect; - engineLoadBoard(mi->fileName, isShareware(), &p->pos, &lbang, §);// &p->cursectnum); - p->cursectnum = sect; + engineLoadBoard(mi->fileName, isShareware(), &p->pos, &lbang, §); + p->cursector = §or[sect]; SECRET_SetMapName(mi->DisplayName(), mi->name); STAT_NewLevel(mi->fileName); diff --git a/source/games/duke/src/render.cpp b/source/games/duke/src/render.cpp index 3868613d9..9833a2342 100644 --- a/source/games/duke/src/render.cpp +++ b/source/games/duke/src/render.cpp @@ -272,7 +272,7 @@ void displayrooms(int snum, double smoothratio) videoSetCorrectedAspect(); - auto sect = p->cursector(); + auto sect = p->cursector; GlobalMapFog = fogactive ? 0x999999 : 0; GlobalFogDensity = fogactive ? 350.f : 0.f; diff --git a/source/games/duke/src/savegame.cpp b/source/games/duke/src/savegame.cpp index dc4440ad7..800dd1473 100644 --- a/source/games/duke/src/savegame.cpp +++ b/source/games/duke/src/savegame.cpp @@ -131,7 +131,7 @@ FSerializer& Serialize(FSerializer& arc, const char* keyname, player_struct& w, ("crack_time", w.crack_time) ("aim.mode", w.aim_mode) ("psectlotag", w.psectlotag) - ("cursectnum", w.cursectnum) + ("cursectnum", w.cursector) ("last_extra", w.last_extra) ("subweapon", w.subweapon) .Array("ammo_count", w.ammo_amount, MAX_WEAPONS) diff --git a/source/games/duke/src/sectors.cpp b/source/games/duke/src/sectors.cpp index e5507e48f..dd419564b 100644 --- a/source/games/duke/src/sectors.cpp +++ b/source/games/duke/src/sectors.cpp @@ -345,7 +345,7 @@ void doanimations(void) if (animatetype[i] == anim_floorz) { for (p = connecthead; p >= 0; p = connectpoint2[p]) - if (ps[p].cursector() == dasectp) + if (ps[p].cursector == dasectp) if ((dasectp->floorz - ps[p].pos.z) < (64 << 8)) if (ps[p].GetActor()->GetOwner() != nullptr) { diff --git a/source/games/duke/src/sectors_d.cpp b/source/games/duke/src/sectors_d.cpp index ef389d2ea..1cfa1e8ef 100644 --- a/source/games/duke/src/sectors_d.cpp +++ b/source/games/duke/src/sectors_d.cpp @@ -1473,7 +1473,7 @@ void checkhitsprite_d(DDukeActor* targ, DDukeActor* proj) ps[p].pos.z = ps[p].oposz; ps[p].angle.restore(); - updatesector(ps[p].pos.x, ps[p].pos.y, &ps[p].cursectnum); + updatesector(ps[p].pos.x, ps[p].pos.y, &ps[p].cursector); DukeStatIterator it(STAT_ACTOR); while (auto j = it.Next()) @@ -1511,7 +1511,7 @@ void clearcameras(int i, player_struct* p) p->pos.z = p->oposz; p->newOwner = nullptr; - updatesector(p->pos.x, p->pos.y, &p->cursectnum); + updatesector(p->pos.x, p->pos.y, &p->cursector); DukeStatIterator it(STAT_ACTOR); while (auto act = it.Next()) @@ -1544,30 +1544,30 @@ void checksectors_d(int snum) if (!p->insector()) return; - switch (p->cursector()->lotag) + switch (p->cursector->lotag) { case 32767: - p->cursector()->lotag = 0; + p->cursector->lotag = 0; FTA(9, p); p->secret_rooms++; - SECRET_Trigger(p->cursectnum); + SECRET_Trigger(sectnum(p->cursector)); return; case -1: - p->cursector()->lotag = 0; + p->cursector->lotag = 0; setnextmap(false); return; case -2: - p->cursector()->lotag = 0; + p->cursector->lotag = 0; p->timebeforeexit = 26 * 8; - p->customexitsound = p->cursector()->hitag; + p->customexitsound = p->cursector->hitag; return; default: - if (p->cursector()->lotag >= 10000 && p->cursector()->lotag < 16383) + if (p->cursector->lotag >= 10000 && p->cursector->lotag < 16383) { if (snum == screenpeek || ud.coop == 1) - S_PlayActorSound(p->cursector()->lotag - 10000, pact); - p->cursector()->lotag = 0; + S_PlayActorSound(p->cursector->lotag - 10000, pact); + p->cursector->lotag = 0; } break; @@ -1670,7 +1670,7 @@ void checksectors_d(int snum) return; if (neartagsprite == nullptr && ntwall == nullptr) - if (p->cursector()->lotag == 2) + if (p->cursector->lotag == 2) { DDukeActor* hit; oldz = hitasprite(p->GetActor(), &hit); diff --git a/source/games/duke/src/sectors_r.cpp b/source/games/duke/src/sectors_r.cpp index 0b247474b..8b2a0dfc3 100644 --- a/source/games/duke/src/sectors_r.cpp +++ b/source/games/duke/src/sectors_r.cpp @@ -2420,7 +2420,7 @@ void checkhitsprite_r(DDukeActor* targ, DDukeActor* proj) ps[p].pos.y = ps[p].oposy; ps[p].pos.z = ps[p].oposz; - updatesector(ps[p].pos.x, ps[p].pos.y, &ps[p].cursectnum); + updatesector(ps[p].pos.x, ps[p].pos.y, &ps[p].cursector); DukeStatIterator it(STAT_EFFECTOR); while (auto act = it.Next()) @@ -2460,17 +2460,17 @@ void checksectors_r(int snum) if (!p->insector()) return; - switch (p->cursector()->lotag) + switch (p->cursector->lotag) { case 32767: - p->cursector()->lotag = 0; + p->cursector->lotag = 0; FTA(9, p); p->secret_rooms++; - SECRET_Trigger(p->cursectnum); + SECRET_Trigger(sectnum(p->cursector)); return; case -1: - p->cursector()->lotag = 0; + p->cursector->lotag = 0; if (!isRRRA() || !RRRA_ExitedLevel) { setnextmap(false); @@ -2478,16 +2478,16 @@ void checksectors_r(int snum) } return; case -2: - p->cursector()->lotag = 0; + p->cursector->lotag = 0; p->timebeforeexit = 26 * 8; - p->customexitsound = p->cursector()->hitag; + p->customexitsound = p->cursector->hitag; return; default: - if (p->cursector()->lotag >= 10000) + if (p->cursector->lotag >= 10000) { if (snum == screenpeek || ud.coop == 1) - S_PlayActorSound(p->cursector()->lotag - 10000, pact); - p->cursector()->lotag = 0; + S_PlayActorSound(p->cursector->lotag - 10000, pact); + p->cursector->lotag = 0; } break; @@ -2616,7 +2616,7 @@ void checksectors_r(int snum) return; if (neartagsprite == nullptr && ntwall == nullptr) - if (p->cursector()->lotag == 2) + if (p->cursector->lotag == 2) { DDukeActor* hit; oldz = hitasprite(p->GetActor(), &hit); diff --git a/source/games/duke/src/sounds.cpp b/source/games/duke/src/sounds.cpp index e9ebffd75..82e1c8991 100644 --- a/source/games/duke/src/sounds.cpp +++ b/source/games/duke/src/sounds.cpp @@ -331,7 +331,7 @@ void S_GetCamera(vec3_t** c, int32_t* ca, int32_t* cs) { auto p = &ps[screenpeek]; if (c) *c = &p->pos; - if (cs) *cs = p->cursectnum; + if (cs) *cs = sectnum(p->cursector); if (ca) *ca = p->angle.ang.asbuild(); } else @@ -488,7 +488,7 @@ int S_PlaySound3D(int sndnum, DDukeActor* actor, const vec3_t* pos, int channel, bool explosion = ((userflags & (SF_GLOBAL | SF_DTAG)) == (SF_GLOBAL | SF_DTAG)) || ((sndnum == PIPEBOMB_EXPLODE || sndnum == LASERTRIP_EXPLODE || sndnum == RPG_EXPLODE)); - bool underwater = ps[screenpeek].insector() && ps[screenpeek].cursector()->lotag == ST_2_UNDERWATER; + bool underwater = ps[screenpeek].insector() && ps[screenpeek].cursector->lotag == ST_2_UNDERWATER; if (explosion) { if (underwater) diff --git a/source/games/duke/src/types.h b/source/games/duke/src/types.h index 39f0d68c5..f68240bde 100644 --- a/source/games/duke/src/types.h +++ b/source/games/duke/src/types.h @@ -218,7 +218,7 @@ struct player_struct int aim_mode, ftt; - int cursectnum; + sectortype* cursector; sectortype* one_parallax_sectnum; // wall + sector references. Make them pointers later? walltype* access_wall; @@ -316,20 +316,14 @@ struct player_struct return (psectlotag == ST_2_UNDERWATER)? avel * 0.875f : avel; } - sectortype* cursector() const - { - return cursectnum < 0 ? nullptr : &::sector[cursectnum]; - } - void setCursector(sectortype* sect) { - cursectnum = ::sector.IndexOf(sect); + cursector = sect; } bool insector() const { - assert(cursectnum >= -1 && cursectnum < numsectors); // check for truly invalid values. - return validSectorIndex(cursectnum); + return cursector != nullptr; } }; diff --git a/wadsrc/static/zscript/games/sw/swgame.zs b/wadsrc/static/zscript/games/sw/swgame.zs index f18aa755c..d07212c47 100644 --- a/wadsrc/static/zscript/games/sw/swgame.zs +++ b/wadsrc/static/zscript/games/sw/swgame.zs @@ -211,7 +211,7 @@ struct SWPlayer native native int16 circle_camera_ang; native int16 camera_check_time_delay; - native int cursectnum,lastcursectnum; + //native int /*cursectnum,*/lastcursectnum; native int turn180_target; // 180 degree turn // variables that do not fit into sprite structure