From 5b84755aedcee18b588eae1a4079ee6d7635b606 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Sun, 14 Nov 2021 17:57:48 +0100 Subject: [PATCH] - do the same for plr.sector to eliminate another large batch of sector[] references. --- source/games/whaven/src/aigonzo.cpp | 4 +-- source/games/whaven/src/drawweapon.cpp | 4 +-- source/games/whaven/src/input.cpp | 26 +++++++------- source/games/whaven/src/items.cpp | 2 +- source/games/whaven/src/player.h | 1 + source/games/whaven/src/whani.cpp | 8 ++--- source/games/whaven/src/whfx.cpp | 50 +++++++++++++------------- source/games/whaven/src/whmap.cpp | 2 +- source/games/whaven/src/whplr.cpp | 2 +- source/games/whaven/src/whtag.cpp | 20 +++++------ 10 files changed, 60 insertions(+), 59 deletions(-) diff --git a/source/games/whaven/src/aigonzo.cpp b/source/games/whaven/src/aigonzo.cpp index 4553d724b..fcba98ab3 100644 --- a/source/games/whaven/src/aigonzo.cpp +++ b/source/games/whaven/src/aigonzo.cpp @@ -63,7 +63,7 @@ static void chasegonzo(PLAYER& plr, DWHActor* actor) SetActorPos(actor, &spr.pos); moveStat.type = -1; // make invalid. - if (rand() % 100 > 80 && sector[plr.sector].lotag == 25) { + if (rand() % 100 > 80 && plr.Sector()->lotag == 25) { SetNewStatus(actor, AMBUSH); spr.z -= (getPlayerHeight() << 6); spr.lotag = 60; @@ -75,7 +75,7 @@ static void chasegonzo(PLAYER& plr, DWHActor* actor) } - if (moveStat.type == kHitWall && sector[plr.sector].lotag == 25) { + if (moveStat.type == kHitWall && plr.Sector()->lotag == 25) { SetNewStatus(actor, AMBUSH); spr.z -= (getPlayerHeight() << 6); spr.lotag = 90; diff --git a/source/games/whaven/src/drawweapon.cpp b/source/games/whaven/src/drawweapon.cpp index b3b2a6e13..b7c43f227 100644 --- a/source/games/whaven/src/drawweapon.cpp +++ b/source/games/whaven/src/drawweapon.cpp @@ -27,7 +27,7 @@ void drawweapons(int snum, double const dasmoothratio) { dapalnum = 0; } else { - dashade = sector[plr.sector].ceilingshade; + dashade = plr.Sector()->ceilingshade; dapalnum = 0; } @@ -404,7 +404,7 @@ static void spikeheart(PLAYER& plr) int dax = spikeanimtics[plr.currspikeframe].currx; int day = spikeanimtics[plr.currspikeframe].curry; - overwritesprite(dax, day, plr.spikeframe, sector[plr.sector].ceilingshade, 0, 0); + overwritesprite(dax, day, plr.spikeframe, plr.Sector()->ceilingshade, 0, 0); startredflash(10); } diff --git a/source/games/whaven/src/input.cpp b/source/games/whaven/src/input.cpp index b0ae9527d..1256cc07b 100644 --- a/source/games/whaven/src/input.cpp +++ b/source/games/whaven/src/input.cpp @@ -258,7 +258,7 @@ void processinput(int num) { else onsprite = -1; - feetoffground = (plr.sector != -1) ? (sector[plr.sector].floorz - plr.z) : 0; + feetoffground = (plr.sector != -1) ? (plr.Sector()->floorz - plr.z) : 0; if (abs(plr.plInput.svel) > gi->playerKeyMove() || abs(plr.plInput.fvel) > gi->playerKeyMove()) { if (feetoffground > (32 << 8)) @@ -311,21 +311,21 @@ void processinput(int num) { plr.angle.applyinput(plr.plInput.avel, &bits); } - if (plr.sector != -1 && ((sector[plr.sector].floorpicnum != LAVA || sector[plr.sector].floorpicnum != SLIME - || sector[plr.sector].floorpicnum != WATER || sector[plr.sector].floorpicnum != HEALTHWATER - || sector[plr.sector].floorpicnum != ANILAVA || sector[plr.sector].floorpicnum != LAVA1 - || sector[plr.sector].floorpicnum != LAVA2) && feetoffground <= (32 << 8))) { + if (plr.sector != -1 && ((plr.Sector()->floorpicnum != LAVA || plr.Sector()->floorpicnum != SLIME + || plr.Sector()->floorpicnum != WATER || plr.Sector()->floorpicnum != HEALTHWATER + || plr.Sector()->floorpicnum != ANILAVA || plr.Sector()->floorpicnum != LAVA1 + || plr.Sector()->floorpicnum != LAVA2) && feetoffground <= (32 << 8))) { plr.plInput.fvel /= 3; plr.plInput.svel /= 3; } - if ((plr.sector != -1 && (sector[plr.sector].floorpicnum == LAVA || sector[plr.sector].floorpicnum == SLIME - || sector[plr.sector].floorpicnum == WATER || sector[plr.sector].floorpicnum == HEALTHWATER - || sector[plr.sector].floorpicnum == ANILAVA || sector[plr.sector].floorpicnum == LAVA1 - || sector[plr.sector].floorpicnum == LAVA2)) && plr.orbactive[5] < 0 // loz - && plr.z >= sector[plr.sector].floorz - (plr.height << 8) - (8 << 8)) { + if ((plr.sector != -1 && (plr.Sector()->floorpicnum == LAVA || plr.Sector()->floorpicnum == SLIME + || plr.Sector()->floorpicnum == WATER || plr.Sector()->floorpicnum == HEALTHWATER + || plr.Sector()->floorpicnum == ANILAVA || plr.Sector()->floorpicnum == LAVA1 + || plr.Sector()->floorpicnum == LAVA2)) && plr.orbactive[5] < 0 // loz + && plr.z >= plr.Sector()->floorz - (plr.height << 8) - (8 << 8)) { goalz = loz - (32 << 8); - switch (sector[plr.sector].floorpicnum) { + switch (plr.Sector()->floorpicnum) { case ANILAVA: case LAVA: case LAVA1: @@ -383,7 +383,7 @@ void processinput(int num) { } if ((bits & SB_CROUCH) != 0) { - if (plr.sector != -1 && goalz < ((sector[plr.sector].floorz) - (plr.height >> 3))) { + if (plr.sector != -1 && goalz < ((plr.Sector()->floorz) - (plr.height >> 3))) { if (isWh2()) goalz += (48 << 8); else @@ -457,7 +457,7 @@ void processinput(int num) { // JSA BLORB if (plr.sector != plr.oldsector) { - switch (sector[plr.sector].floorpicnum) { + switch (plr.Sector()->floorpicnum) { case ANILAVA: case LAVA: case LAVA1: diff --git a/source/games/whaven/src/items.cpp b/source/games/whaven/src/items.cpp index a7dd0f80a..3771fba3b 100644 --- a/source/games/whaven/src/items.cpp +++ b/source/games/whaven/src/items.cpp @@ -542,7 +542,7 @@ void InitItems() items[a++].Init(-1, -1, true, true, [](PLAYER& plr, DWHActor* actor) // PENTAGRAM { - if (sector[plr.sector].lotag == 4002) + if (plr.Sector()->lotag == 4002) return; else { plr.treasure[TPENTAGRAM] = 1; diff --git a/source/games/whaven/src/player.h b/source/games/whaven/src/player.h index 287802caf..20cc0a031 100644 --- a/source/games/whaven/src/player.h +++ b/source/games/whaven/src/player.h @@ -24,6 +24,7 @@ struct PLAYER { int oldsector; short spritenum; DWHActor* actor() { return &whActors[spritenum]; } + sectortype* Sector() { return &::sector[sector]; } boolean keytoggle; int flags; int weapon[MAXWEAPONS], preenchantedweapon[MAXWEAPONS]; diff --git a/source/games/whaven/src/whani.cpp b/source/games/whaven/src/whani.cpp index 2f152d3a0..b67df0b78 100644 --- a/source/games/whaven/src/whani.cpp +++ b/source/games/whaven/src/whani.cpp @@ -315,10 +315,10 @@ void animateobjs(PLAYER& plr) { if (spr.lotag < 0) { DeleteActor(actor); // set back to normall - sector[plr.sector].ceilingshade = ceilingshadearray[plr.sector]; - sector[plr.sector].floorshade = floorshadearray[plr.sector]; - startwall = sector[plr.sector].wallptr; - endwall = (short) (startwall + sector[plr.sector].wallnum - 1); + plr.Sector()->ceilingshade = ceilingshadearray[plr.sector]; + plr.Sector()->floorshade = floorshadearray[plr.sector]; + startwall = plr.Sector()->wallptr; + endwall = (short) (startwall + plr.Sector()->wallnum - 1); for (k = startwall; k <= endwall; k++) { wall[k].shade = wallshadearray[k]; } diff --git a/source/games/whaven/src/whfx.cpp b/source/games/whaven/src/whfx.cpp index d88106f35..fc0a80a40 100644 --- a/source/games/whaven/src/whfx.cpp +++ b/source/games/whaven/src/whfx.cpp @@ -428,7 +428,7 @@ void teleporter() { if (plr.sector == -1) return; - if (sector[plr.sector].lotag == 10) { + if (plr.Sector()->lotag == 10) { if (plr.sector != plr.oldsector) { daang = plr.angle.ang.asbuild(); warpfxsprite(plr.spritenum); @@ -447,7 +447,7 @@ void teleporter() { } } - if (sector[plr.sector].lotag == 4002) { + if (plr.Sector()->lotag == 4002) { if (plr.sector != plr.oldsector) { if (plr.treasure[TPENTAGRAM] == 1) { plr.treasure[TPENTAGRAM] = 0; @@ -458,7 +458,7 @@ void teleporter() { return; } #endif - switch (sector[plr.sector].hitag) { + switch (plr.Sector()->hitag) { case 1: // NEXTLEVEL justteleported = true; CompleteLevel(currentLevel); @@ -593,7 +593,7 @@ void sectorsounds() { PLAYER& plr = player[pyrn]; - int sec = sector[plr.sector].extra & 0xFFFF; + int sec = plr.Sector()->extra & 0xFFFF; if (sec != 0) { if ((sec & 32768) != 0) @@ -610,7 +610,7 @@ void sectorsounds() { soundEngine->StopSound(CHAN_AMBIENT1 + index); } } else { - if (plr.z <= sector[plr.sector].floorz - (8 << 8)) + if (plr.z <= plr.Sector()->floorz - (8 << 8)) spritesound(sec, &sprite[plr.spritenum]); } } @@ -654,7 +654,7 @@ void dofx() { cracks(); if (isWh2()) { PLAYER& plr = player[0]; - if (sector[plr.sector].lotag == 50 && sector[plr.sector].hitag > 0) + if (plr.Sector()->lotag == 50 && plr.Sector()->hitag > 0) weaponpowerup(plr); } @@ -775,13 +775,13 @@ void thesplash() { if (plr.sector == -1) return; - if (sector[plr.sector].floorpicnum == WATER || sector[plr.sector].floorpicnum == LAVA - || sector[plr.sector].floorpicnum == SLIME) { + if (plr.Sector()->floorpicnum == WATER || plr.Sector()->floorpicnum == LAVA + || plr.Sector()->floorpicnum == SLIME) { if (plr.onsomething == 0) return; if (plr.sector != plr.oldsector) { - switch (sector[plr.sector].floorpicnum) { + switch (plr.Sector()->floorpicnum) { case WATER: makeasplash(SPLASHAROO, plr); break; @@ -805,7 +805,7 @@ void makeasplash(int picnum, PLAYER& plr) { spawned.x = plr.x; spawned.y = plr.y; - spawned.z = sector[plr.sector].floorz + (tileHeight(picnum) << 8); + spawned.z = plr.Sector()->floorz + (tileHeight(picnum) << 8); spawned.cstat = 0; // Hitscan does not hit other bullets spawned.picnum = (short) picnum; spawned.shade = 0; @@ -920,38 +920,38 @@ void cracks() { if (plr.sector == -1) return; - int datag = sector[plr.sector].lotag; + int datag = plr.Sector()->lotag; if (floorpanningcnt < 64) if (datag >= 3500 && datag <= 3599) { - sector[plr.sector].hitag = 0; - int daz = sector[plr.sector].floorz + (1024 * (sector[plr.sector].lotag - 3500)); + plr.Sector()->hitag = 0; + int daz = plr.Sector()->floorz + (1024 * (plr.Sector()->lotag - 3500)); if ((setanimation(plr.sector, daz, 32, 0, FLOORZ)) >= 0) { - sector[plr.sector].floorpicnum = LAVA1; - sector[plr.sector].floorshade = -25; + plr.Sector()->floorpicnum = LAVA1; + plr.Sector()->floorshade = -25; SND_Sound(S_CRACKING); } - sector[plr.sector].lotag = 80; + plr.Sector()->lotag = 80; floorpanninglist[floorpanningcnt++] = plr.sector; } if (datag >= 5100 && datag <= 5199) { - sector[plr.sector].hitag = 0; - sector[plr.sector].lotag = 0; + plr.Sector()->hitag = 0; + plr.Sector()->lotag = 0; } if (datag >= 5200 && datag <= 5299) { - sector[plr.sector].hitag = 0; - sector[plr.sector].lotag = 0; + plr.Sector()->hitag = 0; + plr.Sector()->lotag = 0; } if (datag == 3001) { - sector[plr.sector].lotag = 0; + plr.Sector()->lotag = 0; WHSpriteIterator it; while (auto itActor = it.Next()) { auto& spk = itActor->s(); - if (sector[plr.sector].hitag == spk.hitag) { + if (plr.Sector()->hitag == spk.hitag) { spk.lotag = 36; spk.zvel = (short) (krand() & 1024 + 512); SetNewStatus(itActor, SHOVE); @@ -1071,9 +1071,9 @@ void weaponpowerup(PLAYER& plr) { break; } - if (sector[plr.sector].hitag > 0) { - sector[plr.sector].hitag--; - if (sector[plr.sector].hitag == 0) { + if (plr.Sector()->hitag > 0) { + plr.Sector()->hitag--; + if (plr.Sector()->hitag == 0) { WHSectIterator it(plr.sector); while (auto actor = it.Next()) { diff --git a/source/games/whaven/src/whmap.cpp b/source/games/whaven/src/whmap.cpp index 441bc9a35..67527e139 100644 --- a/source/games/whaven/src/whmap.cpp +++ b/source/games/whaven/src/whmap.cpp @@ -782,7 +782,7 @@ boolean prepareboard(const char* fname) { pspr.x = plr.x; pspr.y = plr.y; - pspr.z = sector[plr.sector].floorz; + pspr.z = plr.Sector()->floorz; pspr.cstat = 1 + 256; pspr.picnum = isWh2() ? GRONSW : FRED; pspr.shade = 0; diff --git a/source/games/whaven/src/whplr.cpp b/source/games/whaven/src/whplr.cpp index 8bc4d82c3..1c3850587 100644 --- a/source/games/whaven/src/whplr.cpp +++ b/source/games/whaven/src/whplr.cpp @@ -88,7 +88,7 @@ void initplayersprite(PLAYER& plr) { plr.oldsector = plr.sector; plr.horizon.horiz = q16horiz(0); plr.height = getPlayerHeight(); - plr.z = sector[plr.sector].floorz - (plr.height << 8); + plr.z = plr.Sector()->floorz - (plr.height << 8); plr.spritenum = (short) insertsprite(plr.sector, (short) 0); auto& spr = sprite[plr.spritenum]; diff --git a/source/games/whaven/src/whtag.cpp b/source/games/whaven/src/whtag.cpp index f69f7d8a5..9596a828a 100644 --- a/source/games/whaven/src/whtag.cpp +++ b/source/games/whaven/src/whtag.cpp @@ -291,7 +291,7 @@ void operatesector(PLAYER& plr, int s) { case PLATFORMELEVTAG: i = getanimationgoal(sector[s], 1); - goalz = sector[plr.sector].floorz; + goalz = plr.Sector()->floorz; if (i >= 0) { gAnimationData[i].goal = goalz; } else { @@ -302,7 +302,7 @@ void operatesector(PLAYER& plr, int s) { i = getanimationgoal(sector[s], 1); j = getanimationgoal(sector[s], 2); size = sector[s].ceilingz - sector[s].floorz; - goalz = sector[plr.sector].floorz; + goalz = plr.Sector()->floorz; if (i >= 0) { gAnimationData[i].goal = goalz; @@ -901,9 +901,9 @@ void animatetags(int nPlayer) { PLAYER& plr = player[nPlayer]; if (plr.sector != -1) { - if (sector[plr.sector].lotag == 2) { + if (plr.Sector()->lotag == 2) { for (i = 0; i < numsectors; i++) - if (sector[i].hitag == sector[plr.sector].hitag) + if (sector[i].hitag == plr.Sector()->hitag) if (sector[i].lotag != 2) operatesector(plr, i); @@ -913,16 +913,16 @@ void animatetags(int nPlayer) { SPRITE& spr = actor->s(); int i = actor->GetSpriteIndex(); - if (spr.hitag == sector[plr.sector].hitag) + if (spr.hitag == plr.Sector()->hitag) operatesprite(plr, i); } - sector[plr.sector].lotag = 0; - sector[plr.sector].hitag = 0; + plr.Sector()->lotag = 0; + plr.Sector()->hitag = 0; } - if ((sector[plr.sector].lotag == 1) && (plr.sector != plr.oldsector)) { + if ((plr.Sector()->lotag == 1) && (plr.sector != plr.oldsector)) { for (i = 0; i < numsectors; i++) - if (sector[i].hitag == sector[plr.sector].hitag) + if (sector[i].hitag == plr.Sector()->hitag) if (sector[i].lotag != 2) operatesector(plr, i); @@ -932,7 +932,7 @@ void animatetags(int nPlayer) { SPRITE& spr = actor->s(); int i = actor->GetSpriteIndex(); - if (spr.hitag == sector[plr.sector].hitag) + if (spr.hitag == plr.Sector()->hitag) operatesprite(plr, i); } }