From 16480ccfcc804d733f20f7a4e263ff7fbb801dd6 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Wed, 24 Nov 2021 23:11:01 +0100 Subject: [PATCH] - use sector wrappers where applicable. --- source/games/sw/src/game.cpp | 7 ++++--- source/games/sw/src/game.h | 1 + source/games/sw/src/player.cpp | 12 ++++++------ source/games/sw/src/rooms.cpp | 2 +- 4 files changed, 12 insertions(+), 10 deletions(-) diff --git a/source/games/sw/src/game.cpp b/source/games/sw/src/game.cpp index 82b8888da..764752fe2 100644 --- a/source/games/sw/src/game.cpp +++ b/source/games/sw/src/game.cpp @@ -328,10 +328,11 @@ void InitLevel(MapRecord *maprec) STAT_NewLevel(currentLevel->fileName); Player[0].angle.ang = buildang(ang); - if (sector[0].extra != -1) + auto vissect = §or[0]; // hack alert! + if (vissect->extra != -1) { - NormalVisibility = g_visibility = sector[0].extra; - sector[0].extra = 0; + NormalVisibility = g_visibility = vissect->extra; + vissect->extra = 0; } else NormalVisibility = g_visibility; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 28d30d3ee..af60cfb9a 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -787,6 +787,7 @@ struct PLAYERstruct int cursectnum,lastcursectnum; sectortype* cursector() { return cursectnum < 0? nullptr : §or[cursectnum]; } + sectortype* lastcursector() { return lastcursectnum < 0 ? nullptr : §or[lastcursectnum]; } void setcursector(sectortype* s) { cursectnum = sectnum(s); } bool insector() const { return cursectnum >= 0; } fixed_t turn180_target; // 180 degree turn diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 3baa21996..cfc4cc509 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1614,7 +1614,7 @@ void SlipSlope(PLAYERp pp) void DoPlayerHorizon(PLAYERp pp, float const horz, double const scaleAdjust) { bool const canslopetilt = !TEST(pp->Flags, PF_FLYING|PF_SWIMMING|PF_DIVING|PF_CLIMBING|PF_JUMPING|PF_FALLING) && TEST(pp->cursector()->floorstat, FLOOR_STAT_SLOPE); - pp->horizon.calcviewpitch(pp->pos.vec2, pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, §or[pp->cursectnum], scaleAdjust, TEST(pp->Flags, PF_CLIMBING)); + pp->horizon.calcviewpitch(pp->pos.vec2, pp->angle.ang, pp->input.actions & SB_AIMMODE, canslopetilt, pp->cursector(), scaleAdjust, TEST(pp->Flags, PF_CLIMBING)); pp->horizon.applyinput(horz, &pp->input.actions, scaleAdjust); } @@ -1892,7 +1892,7 @@ void DoPlayerZrange(PLAYERp pp) } else { - pp->hi_sectp = §or[ceilColl.index]; + pp->hi_sectp = ceilColl.sector(); } if (floorColl.type == kHitSprite) @@ -1903,14 +1903,14 @@ void DoPlayerZrange(PLAYERp pp) auto fsp = &floorColl.actor->s(); if (fsp->statnum == STAT_ENEMY && floorColl.actor->u()->ID == ZOMBIE_RUN_R0) { - pp->lo_sectp = §or[fsp->sectnum]; + pp->lo_sectp = fsp->sector(); pp->loz = fsp->z; pp->lowActor = nullptr; } } else { - pp->lo_sectp = §or[floorColl.index]; + pp->lo_sectp = floorColl.sector(); } } @@ -3440,7 +3440,7 @@ int DoPlayerWadeSuperJump(PLAYERp pp) { hitinfo.hitsect = hitinfo.wall()->nextsector; - if (hitinfo.hitsect >= 0 && labs(sector[hitinfo.hitsect].floorz - pp->posz) < Z(50)) + if (hitinfo.hitsect >= 0 && labs(hitinfo.sector()->floorz - pp->posz) < Z(50)) { if (Distance(pp->posx, pp->posy, hitinfo.pos.x, hitinfo.pos.y) < ((((int)pp->Actor()->s().clipdist)<<2) + 256)) return true; @@ -3490,7 +3490,7 @@ bool PlayerFallTest(PLAYERp pp, int player_height) if (pp->lo_sectp && labs(pp->lo_sectp->floorheinum) > 3000 && TEST(pp->lo_sectp->floorstat, FLOOR_STAT_SLOPE) && - pp->lo_sectp == §or[pp->lastcursectnum]) + pp->lo_sectp == pp->lastcursector()) { return false; } diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index d70fca1ca..15bc36145 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -505,7 +505,7 @@ void WaterAdjust(const Collision& florhit, int32_t* loz) { if (florhit.type == kHitSector) { - auto sect = §or[florhit.index]; + auto sect = florhit.sector(); if (!sect->hasU()) return; if (sect->hasU() && FixedToInt(sect->depth_fixed))