- use sector wrappers where applicable.

This commit is contained in:
Christoph Oelckers 2021-11-24 23:11:01 +01:00
parent 52d9451cbc
commit 16480ccfcc
4 changed files with 12 additions and 10 deletions

View file

@ -328,10 +328,11 @@ void InitLevel(MapRecord *maprec)
STAT_NewLevel(currentLevel->fileName); STAT_NewLevel(currentLevel->fileName);
Player[0].angle.ang = buildang(ang); Player[0].angle.ang = buildang(ang);
if (sector[0].extra != -1) auto vissect = &sector[0]; // hack alert!
if (vissect->extra != -1)
{ {
NormalVisibility = g_visibility = sector[0].extra; NormalVisibility = g_visibility = vissect->extra;
sector[0].extra = 0; vissect->extra = 0;
} }
else else
NormalVisibility = g_visibility; NormalVisibility = g_visibility;

View file

@ -787,6 +787,7 @@ struct PLAYERstruct
int cursectnum,lastcursectnum; int cursectnum,lastcursectnum;
sectortype* cursector() { return cursectnum < 0? nullptr : &sector[cursectnum]; } sectortype* cursector() { return cursectnum < 0? nullptr : &sector[cursectnum]; }
sectortype* lastcursector() { return lastcursectnum < 0 ? nullptr : &sector[lastcursectnum]; }
void setcursector(sectortype* s) { cursectnum = sectnum(s); } void setcursector(sectortype* s) { cursectnum = sectnum(s); }
bool insector() const { return cursectnum >= 0; } bool insector() const { return cursectnum >= 0; }
fixed_t turn180_target; // 180 degree turn fixed_t turn180_target; // 180 degree turn

View file

@ -1614,7 +1614,7 @@ void SlipSlope(PLAYERp pp)
void DoPlayerHorizon(PLAYERp pp, float const horz, double const scaleAdjust) 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); 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, &sector[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); pp->horizon.applyinput(horz, &pp->input.actions, scaleAdjust);
} }
@ -1892,7 +1892,7 @@ void DoPlayerZrange(PLAYERp pp)
} }
else else
{ {
pp->hi_sectp = &sector[ceilColl.index]; pp->hi_sectp = ceilColl.sector();
} }
if (floorColl.type == kHitSprite) if (floorColl.type == kHitSprite)
@ -1903,14 +1903,14 @@ void DoPlayerZrange(PLAYERp pp)
auto fsp = &floorColl.actor->s(); auto fsp = &floorColl.actor->s();
if (fsp->statnum == STAT_ENEMY && floorColl.actor->u()->ID == ZOMBIE_RUN_R0) if (fsp->statnum == STAT_ENEMY && floorColl.actor->u()->ID == ZOMBIE_RUN_R0)
{ {
pp->lo_sectp = &sector[fsp->sectnum]; pp->lo_sectp = fsp->sector();
pp->loz = fsp->z; pp->loz = fsp->z;
pp->lowActor = nullptr; pp->lowActor = nullptr;
} }
} }
else else
{ {
pp->lo_sectp = &sector[floorColl.index]; pp->lo_sectp = floorColl.sector();
} }
} }
@ -3440,7 +3440,7 @@ int DoPlayerWadeSuperJump(PLAYERp pp)
{ {
hitinfo.hitsect = hitinfo.wall()->nextsector; 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)) if (Distance(pp->posx, pp->posy, hitinfo.pos.x, hitinfo.pos.y) < ((((int)pp->Actor()->s().clipdist)<<2) + 256))
return true; return true;
@ -3490,7 +3490,7 @@ bool PlayerFallTest(PLAYERp pp, int player_height)
if (pp->lo_sectp && if (pp->lo_sectp &&
labs(pp->lo_sectp->floorheinum) > 3000 && labs(pp->lo_sectp->floorheinum) > 3000 &&
TEST(pp->lo_sectp->floorstat, FLOOR_STAT_SLOPE) && TEST(pp->lo_sectp->floorstat, FLOOR_STAT_SLOPE) &&
pp->lo_sectp == &sector[pp->lastcursectnum]) pp->lo_sectp == pp->lastcursector())
{ {
return false; return false;
} }

View file

@ -505,7 +505,7 @@ void WaterAdjust(const Collision& florhit, int32_t* loz)
{ {
if (florhit.type == kHitSector) if (florhit.type == kHitSector)
{ {
auto sect = &sector[florhit.index]; auto sect = florhit.sector();
if (!sect->hasU()) return; if (!sect->hasU()) return;
if (sect->hasU() && FixedToInt(sect->depth_fixed)) if (sect->hasU() && FixedToInt(sect->depth_fixed))