- Duke: a large batch of quick'n easy sector[] replacements with pointers.

This commit is contained in:
Christoph Oelckers 2021-11-06 23:05:25 +01:00
parent d45f687d4b
commit 8c5e4a7fa9
4 changed files with 96 additions and 94 deletions

View file

@ -47,7 +47,6 @@ BEGIN_DUKE_NS
void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio) void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int a, int smoothratio)
{ {
int i, j, k, p; int i, j, k, p;
short sect;
int l, t1, t3, t4; int l, t1, t3, t4;
spritetype* s; spritetype* s;
tspritetype* t; tspritetype* t;
@ -186,7 +185,7 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int
t->pos = s->interpolatedvec3(smoothratio); t->pos = s->interpolatedvec3(smoothratio);
} }
sect = s->sectnum; auto sectp = s->sector();
t1 = h->temp_data[1]; t1 = h->temp_data[1];
t3 = h->temp_data[3]; t3 = h->temp_data[3];
t4 = h->temp_data[4]; t4 = h->temp_data[4];
@ -438,8 +437,8 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int
PALONLY: PALONLY:
if (sector[sect].floorpal) if (sectp->floorpal)
copyfloorpal(t, &sector[sect]); copyfloorpal(t, sectp);
if (!h->GetOwner()) continue; if (!h->GetOwner()) continue;
@ -484,8 +483,8 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int
else t->picnum += h->temp_data[0]; else t->picnum += h->temp_data[0];
t->shade -= 6; t->shade -= 6;
if (sector[sect].floorpal) if (sectp->floorpal)
copyfloorpal(t, &sector[sect]); copyfloorpal(t, sectp);
break; break;
case WATERBUBBLE: case WATERBUBBLE:
@ -496,8 +495,8 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int
} }
default: default:
if (sector[sect].floorpal) if (sectp->floorpal)
copyfloorpal(t, &sector[sect]); copyfloorpal(t, sectp);
break; break;
} }
@ -584,8 +583,8 @@ void animatesprites_d(spritetype* tsprite, int& spritesortcnt, int x, int y, int
{ {
int daz; int daz;
if ((sector[sect].lotag & 0xff) > 2 || s->statnum == 4 || s->statnum == 5 || s->picnum == DRONE || s->picnum == COMMANDER) if ((sectp->lotag & 0xff) > 2 || s->statnum == 4 || s->statnum == 5 || s->picnum == DRONE || s->picnum == COMMANDER)
daz = sector[sect].floorz; daz = sectp->floorz;
else else
daz = h->floorz; daz = h->floorz;

View file

@ -1038,95 +1038,96 @@ void DoSector(char bSet, int lVar1, int lLabelID, int lVar2, DDukeActor* sActor,
} }
lValue = GetGameVarID(lVar2, sActor, sPlayer); lValue = GetGameVarID(lVar2, sActor, sPlayer);
auto sectp = &sector[iSector];
// All fields affecting map geometry have been made read-only! // All fields affecting map geometry have been made read-only!
switch (lLabelID) switch (lLabelID)
{ {
case SECTOR_WALLPTR: case SECTOR_WALLPTR:
if (!bSet) SetGameVarID(lVar2, sector[iSector].wallptr, sActor, sPlayer); if (!bSet) SetGameVarID(lVar2, sectp->wallptr, sActor, sPlayer);
break; break;
case SECTOR_WALLNUM: case SECTOR_WALLNUM:
if (!bSet) SetGameVarID(lVar2, sector[iSector].wallnum, sActor, sPlayer); if (!bSet) SetGameVarID(lVar2, sectp->wallnum, sActor, sPlayer);
break; break;
case SECTOR_CEILINGZ: case SECTOR_CEILINGZ:
if (bSet) sector[iSector].ceilingz = lValue; if (bSet) sectp->ceilingz = lValue;
else SetGameVarID(lVar2, sector[iSector].ceilingz, sActor, sPlayer); else SetGameVarID(lVar2, sectp->ceilingz, sActor, sPlayer);
break; break;
case SECTOR_FLOORZ: case SECTOR_FLOORZ:
if (bSet) sector[iSector].floorz = lValue; if (bSet) sectp->floorz = lValue;
else SetGameVarID(lVar2, sector[iSector].floorz, sActor, sPlayer); else SetGameVarID(lVar2, sectp->floorz, sActor, sPlayer);
break; break;
case SECTOR_CEILINGSTAT: case SECTOR_CEILINGSTAT:
if (bSet) sector[iSector].ceilingstat = lValue; if (bSet) sectp->ceilingstat = lValue;
else SetGameVarID(lVar2, sector[iSector].ceilingstat, sActor, sPlayer); else SetGameVarID(lVar2, sectp->ceilingstat, sActor, sPlayer);
break; break;
case SECTOR_FLOORSTAT: case SECTOR_FLOORSTAT:
if (bSet) sector[iSector].floorstat = lValue; if (bSet) sectp->floorstat = lValue;
else SetGameVarID(lVar2, sector[iSector].floorstat, sActor, sPlayer); else SetGameVarID(lVar2, sectp->floorstat, sActor, sPlayer);
break; break;
case SECTOR_CEILINGPICNUM: case SECTOR_CEILINGPICNUM:
if (bSet) sector[iSector].ceilingpicnum = lValue; if (bSet) sectp->ceilingpicnum = lValue;
else SetGameVarID(lVar2, sector[iSector].ceilingpicnum, sActor, sPlayer); else SetGameVarID(lVar2, sectp->ceilingpicnum, sActor, sPlayer);
break; break;
case SECTOR_CEILINGSLOPE: case SECTOR_CEILINGSLOPE:
if (bSet) sector[iSector].ceilingheinum = lValue; if (bSet) sectp->ceilingheinum = lValue;
else SetGameVarID(lVar2, sector[iSector].ceilingheinum, sActor, sPlayer); else SetGameVarID(lVar2, sectp->ceilingheinum, sActor, sPlayer);
break; break;
case SECTOR_CEILINGSHADE: case SECTOR_CEILINGSHADE:
if (bSet) sector[iSector].ceilingshade = lValue; if (bSet) sectp->ceilingshade = lValue;
else SetGameVarID(lVar2, sector[iSector].ceilingshade, sActor, sPlayer); else SetGameVarID(lVar2, sectp->ceilingshade, sActor, sPlayer);
break; break;
case SECTOR_CEILINGPAL: case SECTOR_CEILINGPAL:
if (bSet) sector[iSector].ceilingpal = lValue; if (bSet) sectp->ceilingpal = lValue;
else SetGameVarID(lVar2, sector[iSector].ceilingpal, sActor, sPlayer); else SetGameVarID(lVar2, sectp->ceilingpal, sActor, sPlayer);
break; break;
case SECTOR_CEILINGXPANNING: case SECTOR_CEILINGXPANNING:
if (bSet) sector[iSector].ceilingxpan_ = (float)(lValue & 255); if (bSet) sectp->ceilingxpan_ = (float)(lValue & 255);
else SetGameVarID(lVar2, sector[iSector].ceilingxpan(), sActor, sPlayer); else SetGameVarID(lVar2, sectp->ceilingxpan(), sActor, sPlayer);
break; break;
case SECTOR_CEILINGYPANNING: case SECTOR_CEILINGYPANNING:
if (bSet) sector[iSector].ceilingypan_ = (float)(lValue & 255); if (bSet) sectp->ceilingypan_ = (float)(lValue & 255);
else SetGameVarID(lVar2, sector[iSector].ceilingypan(), sActor, sPlayer); else SetGameVarID(lVar2, sectp->ceilingypan(), sActor, sPlayer);
break; break;
case SECTOR_FLOORPICNUM: case SECTOR_FLOORPICNUM:
if (bSet) sector[iSector].floorpicnum = lValue; if (bSet) sectp->floorpicnum = lValue;
else SetGameVarID(lVar2, sector[iSector].floorpicnum, sActor, sPlayer); else SetGameVarID(lVar2, sectp->floorpicnum, sActor, sPlayer);
break; break;
case SECTOR_FLOORSLOPE: case SECTOR_FLOORSLOPE:
if (bSet) sector[iSector].floorheinum = lValue; if (bSet) sectp->floorheinum = lValue;
else SetGameVarID(lVar2, sector[iSector].floorheinum, sActor, sPlayer); else SetGameVarID(lVar2, sectp->floorheinum, sActor, sPlayer);
break; break;
case SECTOR_FLOORSHADE: case SECTOR_FLOORSHADE:
if (bSet) sector[iSector].floorshade = lValue; if (bSet) sectp->floorshade = lValue;
else SetGameVarID(lVar2, sector[iSector].floorshade, sActor, sPlayer); else SetGameVarID(lVar2, sectp->floorshade, sActor, sPlayer);
break; break;
case SECTOR_FLOORPAL: case SECTOR_FLOORPAL:
if (bSet) sector[iSector].floorpal = lValue; if (bSet) sectp->floorpal = lValue;
else SetGameVarID(lVar2, sector[iSector].floorpal, sActor, sPlayer); else SetGameVarID(lVar2, sectp->floorpal, sActor, sPlayer);
break; break;
case SECTOR_FLOORXPANNING: case SECTOR_FLOORXPANNING:
if (bSet) sector[iSector].floorxpan_ = (float)(lValue & 255); if (bSet) sectp->floorxpan_ = (float)(lValue & 255);
else SetGameVarID(lVar2, sector[iSector].floorxpan(), sActor, sPlayer); else SetGameVarID(lVar2, sectp->floorxpan(), sActor, sPlayer);
break; break;
case SECTOR_FLOORYPANNING: case SECTOR_FLOORYPANNING:
if (bSet) sector[iSector].floorypan_ = (float)(lValue & 255); if (bSet) sectp->floorypan_ = (float)(lValue & 255);
else SetGameVarID(lVar2, sector[iSector].floorypan(), sActor, sPlayer); else SetGameVarID(lVar2, sectp->floorypan(), sActor, sPlayer);
break; break;
case SECTOR_VISIBILITY: case SECTOR_VISIBILITY:
if (bSet) sector[iSector].visibility = lValue; if (bSet) sectp->visibility = lValue;
else SetGameVarID(lVar2, sector[iSector].visibility, sActor, sPlayer); else SetGameVarID(lVar2, sectp->visibility, sActor, sPlayer);
break; break;
case SECTOR_LOTAG: case SECTOR_LOTAG:
if (bSet) sector[iSector].lotag = lValue; if (bSet) sectp->lotag = lValue;
else SetGameVarID(lVar2, sector[iSector].lotag, sActor, sPlayer); else SetGameVarID(lVar2, sectp->lotag, sActor, sPlayer);
break; break;
case SECTOR_HITAG: case SECTOR_HITAG:
if (bSet) sector[iSector].hitag = lValue; if (bSet) sectp->hitag = lValue;
else SetGameVarID(lVar2, sector[iSector].hitag, sActor, sPlayer); else SetGameVarID(lVar2, sectp->hitag, sActor, sPlayer);
break; break;
case SECTOR_EXTRA: case SECTOR_EXTRA:
if (bSet) sector[iSector].extra = lValue; if (bSet) sectp->extra = lValue;
else SetGameVarID(lVar2, sector[iSector].extra, sActor, sPlayer); else SetGameVarID(lVar2, sectp->extra, sActor, sPlayer);
break; break;
default: default:
break; break;

View file

@ -950,9 +950,10 @@ void checkplayerhurt_d(struct player_struct* p, const Collision& coll)
bool checkhitceiling_d(int sn) bool checkhitceiling_d(int sn)
{ {
auto sectp = &sector[sn];
int j; int j;
switch (sector[sn].ceilingpicnum) switch (sectp->ceilingpicnum)
{ {
case WALLLIGHT1: case WALLLIGHT1:
case WALLLIGHT2: case WALLLIGHT2:
@ -964,26 +965,26 @@ bool checkhitceiling_d(int sn)
ceilingglass(ps[myconnectindex].GetActor(), sn, 10); ceilingglass(ps[myconnectindex].GetActor(), sn, 10);
S_PlayActorSound(GLASS_BREAKING, ps[screenpeek].GetActor()); S_PlayActorSound(GLASS_BREAKING, ps[screenpeek].GetActor());
if (sector[sn].ceilingpicnum == WALLLIGHT1) if (sectp->ceilingpicnum == WALLLIGHT1)
sector[sn].ceilingpicnum = WALLLIGHTBUST1; sectp->ceilingpicnum = WALLLIGHTBUST1;
if (sector[sn].ceilingpicnum == WALLLIGHT2) if (sectp->ceilingpicnum == WALLLIGHT2)
sector[sn].ceilingpicnum = WALLLIGHTBUST2; sectp->ceilingpicnum = WALLLIGHTBUST2;
if (sector[sn].ceilingpicnum == WALLLIGHT3) if (sectp->ceilingpicnum == WALLLIGHT3)
sector[sn].ceilingpicnum = WALLLIGHTBUST3; sectp->ceilingpicnum = WALLLIGHTBUST3;
if (sector[sn].ceilingpicnum == WALLLIGHT4) if (sectp->ceilingpicnum == WALLLIGHT4)
sector[sn].ceilingpicnum = WALLLIGHTBUST4; sectp->ceilingpicnum = WALLLIGHTBUST4;
if (sector[sn].ceilingpicnum == TECHLIGHT2) if (sectp->ceilingpicnum == TECHLIGHT2)
sector[sn].ceilingpicnum = TECHLIGHTBUST2; sectp->ceilingpicnum = TECHLIGHTBUST2;
if (sector[sn].ceilingpicnum == TECHLIGHT4) if (sectp->ceilingpicnum == TECHLIGHT4)
sector[sn].ceilingpicnum = TECHLIGHTBUST4; sectp->ceilingpicnum = TECHLIGHTBUST4;
if (!sector[sn].hitag) if (!sectp->hitag)
{ {
DukeSectIterator it(sn); DukeSectIterator it(sn);
while (auto act = it.Next()) while (auto act = it.Next())
@ -1005,7 +1006,7 @@ bool checkhitceiling_d(int sn)
DukeStatIterator it(STAT_EFFECTOR); DukeStatIterator it(STAT_EFFECTOR);
while (auto act = it.Next()) while (auto act = it.Next())
{ {
if (act->s->hitag == (sector[sn].hitag) && act->s->lotag == 3) if (act->s->hitag == (sectp->hitag) && act->s->lotag == 3)
{ {
act->temp_data[2] = j; act->temp_data[2] = j;
act->temp_data[4] = 1; act->temp_data[4] = 1;

View file

@ -1433,9 +1433,10 @@ void checkplayerhurt_r(struct player_struct* p, const Collision &coll)
bool checkhitceiling_r(int sn) bool checkhitceiling_r(int sn)
{ {
auto sectp = &sector[sn];
short j; short j;
switch (sector[sn].ceilingpicnum) switch (sectp->ceilingpicnum)
{ {
case WALLLIGHT1: case WALLLIGHT1:
case WALLLIGHT3: case WALLLIGHT3:
@ -1454,44 +1455,44 @@ bool checkhitceiling_r(int sn)
ceilingglass(ps[myconnectindex].GetActor(), sn, 10); ceilingglass(ps[myconnectindex].GetActor(), sn, 10);
S_PlayActorSound(GLASS_BREAKING, ps[screenpeek].GetActor()); S_PlayActorSound(GLASS_BREAKING, ps[screenpeek].GetActor());
if (sector[sn].ceilingpicnum == WALLLIGHT1) if (sectp->ceilingpicnum == WALLLIGHT1)
sector[sn].ceilingpicnum = WALLLIGHTBUST1; sectp->ceilingpicnum = WALLLIGHTBUST1;
if (sector[sn].ceilingpicnum == WALLLIGHT3) if (sectp->ceilingpicnum == WALLLIGHT3)
sector[sn].ceilingpicnum = WALLLIGHTBUST3; sectp->ceilingpicnum = WALLLIGHTBUST3;
if (sector[sn].ceilingpicnum == WALLLIGHT4) if (sectp->ceilingpicnum == WALLLIGHT4)
sector[sn].ceilingpicnum = WALLLIGHTBUST4; sectp->ceilingpicnum = WALLLIGHTBUST4;
if (sector[sn].ceilingpicnum == TECHLIGHT2) if (sectp->ceilingpicnum == TECHLIGHT2)
sector[sn].ceilingpicnum = TECHLIGHTBUST2; sectp->ceilingpicnum = TECHLIGHTBUST2;
if (sector[sn].ceilingpicnum == TECHLIGHT4) if (sectp->ceilingpicnum == TECHLIGHT4)
sector[sn].ceilingpicnum = TECHLIGHTBUST4; sectp->ceilingpicnum = TECHLIGHTBUST4;
if (sector[sn].ceilingpicnum == RRTILE1986) if (sectp->ceilingpicnum == RRTILE1986)
sector[sn].ceilingpicnum = RRTILE1987; sectp->ceilingpicnum = RRTILE1987;
if (sector[sn].ceilingpicnum == RRTILE1939) if (sectp->ceilingpicnum == RRTILE1939)
sector[sn].ceilingpicnum = RRTILE2004; sectp->ceilingpicnum = RRTILE2004;
if (sector[sn].ceilingpicnum == RRTILE1988) if (sectp->ceilingpicnum == RRTILE1988)
sector[sn].ceilingpicnum = RRTILE2005; sectp->ceilingpicnum = RRTILE2005;
if (sector[sn].ceilingpicnum == RRTILE2898) if (sectp->ceilingpicnum == RRTILE2898)
sector[sn].ceilingpicnum = RRTILE2899; sectp->ceilingpicnum = RRTILE2899;
if (sector[sn].ceilingpicnum == RRTILE2878) if (sectp->ceilingpicnum == RRTILE2878)
sector[sn].ceilingpicnum = RRTILE2879; sectp->ceilingpicnum = RRTILE2879;
if (sector[sn].ceilingpicnum == RRTILE2123) if (sectp->ceilingpicnum == RRTILE2123)
sector[sn].ceilingpicnum = RRTILE2124; sectp->ceilingpicnum = RRTILE2124;
if (sector[sn].ceilingpicnum == RRTILE2125) if (sectp->ceilingpicnum == RRTILE2125)
sector[sn].ceilingpicnum = RRTILE2126; sectp->ceilingpicnum = RRTILE2126;
if (!sector[sn].hitag) if (!sectp->hitag)
{ {
DukeSectIterator it(sn); DukeSectIterator it(sn);
while (auto act1 = it.Next()) while (auto act1 = it.Next())
@ -1515,7 +1516,7 @@ bool checkhitceiling_r(int sn)
while (auto act1 = it.Next()) while (auto act1 = it.Next())
{ {
auto spr1 = act1->s; auto spr1 = act1->s;
if (spr1->hitag == (sector[sn].hitag) && spr1->lotag == 3) if (spr1->hitag == (sectp->hitag) && spr1->lotag == 3)
{ {
act1->temp_data[2] = j; act1->temp_data[2] = j;
act1->temp_data[4] = 1; act1->temp_data[4] = 1;