From 56a1836e68ac77b99c250931892f46ff9d1755c4 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Fri, 19 Nov 2021 23:20:58 +0100 Subject: [PATCH] - all SectUsers replaced, except for the maintenance code of the array. --- source/games/sw/src/game.h | 2 +- source/games/sw/src/rooms.cpp | 4 +++- source/games/sw/src/rotator.cpp | 8 +++----- source/games/sw/src/slidor.cpp | 8 +++----- source/games/sw/src/track.cpp | 36 ++++++++++++++++++--------------- source/games/sw/src/vator.cpp | 15 ++++++-------- source/games/sw/src/weapon.cpp | 4 ++-- 7 files changed, 38 insertions(+), 39 deletions(-) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index b93fbb603..7c3861673 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2095,7 +2095,7 @@ void LoadGameDescr(short save_num, char *descr); // save.c void SetRotatorActive(DSWActor* actor); // rotator.c bool VatorSwitch(short match, short setting); // vator.c -void MoveSpritesWithSector(short sectnum,int z_amt,bool type); // vator.c +void MoveSpritesWithSector(int sectnum,int z_amt,bool type); // vator.c void SetVatorActive(DSWActor*); // vator.c void DoSpikeMatch(short match); // spike.c diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index 61c7c82ac..1d657030d 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -489,7 +489,9 @@ void WaterAdjust(const Collision& florhit, int32_t* loz) { if (florhit.type == kHitSector) { - SECT_USERp sectu = SectUser[florhit.index].Data(); + auto sect = §or[florhit.index]; + if (!sect->hasU()) return; + SECT_USERp sectu = sect->u(); if (sectu && FixedToInt(sectu->depth_fixed)) *loz += Z(FixedToInt(sectu->depth_fixed)); diff --git a/source/games/sw/src/rotator.cpp b/source/games/sw/src/rotator.cpp index df21f9971..986227db3 100644 --- a/source/games/sw/src/rotator.cpp +++ b/source/games/sw/src/rotator.cpp @@ -180,13 +180,11 @@ void DoRotatorMatch(PLAYERp pp, short match, bool manual) if (firstVator == nullptr) firstVator = actor; - sectnum = fsp->sectnum; + auto sect = fsp->sector(); - if (pp && SectUser[sectnum].Data() && SectUser[sectnum]->stag == SECT_LOCK_DOOR && SectUser[sectnum]->number) + if (pp && sect->hasU() && sect->u()->stag == SECT_LOCK_DOOR && sect->u()->number) { - short key_num; - - key_num = SectUser[sectnum]->number; + int key_num = sect->u()->number; { PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1)); diff --git a/source/games/sw/src/slidor.cpp b/source/games/sw/src/slidor.cpp index c2326ac21..30658b471 100644 --- a/source/games/sw/src/slidor.cpp +++ b/source/games/sw/src/slidor.cpp @@ -172,13 +172,11 @@ void DoSlidorMatch(PLAYERp pp, short match, bool manual) continue; } - sectnum = fsp->sectnum; + auto sect = fsp->sector(); - if (pp && SectUser[sectnum].Data() && SectUser[sectnum]->stag == SECT_LOCK_DOOR && SectUser[sectnum]->number) + if (pp && sect->hasU() && sect->u()->stag == SECT_LOCK_DOOR && sect->u()->number) { - short key_num; - - key_num = SectUser[sectnum]->number; + int key_num = sect->u()->number; { PutStringInfo(pp, quoteMgr.GetQuote(QUOTE_DOORMSG + key_num - 1)); diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index a614a630c..de954b227 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -806,25 +806,26 @@ void SectorObjectSetupBounds(SECTOR_OBJECTp sop) if (SectorInBounds) { + auto sect = §or[k]; sop->sector[sop->num_sectors] = k; - sop->sectp[sop->num_sectors] = §or[k]; + sop->sectp[sop->num_sectors] = sect; // all sectors in sector object have this flag set - for colision // detection and recognition - SET(sector[k].extra, SECTFX_SECTOR_OBJECT); + SET(sect->extra, SECTFX_SECTOR_OBJECT); - sop->zorig_floor[sop->num_sectors] = sector[k].floorz; - sop->zorig_ceiling[sop->num_sectors] = sector[k].ceilingz; + sop->zorig_floor[sop->num_sectors] = sect->floorz; + sop->zorig_ceiling[sop->num_sectors] = sect->ceilingz; - if (TEST(sector[k].extra, SECTFX_SINK)) - sop->zorig_floor[sop->num_sectors] += Z(FixedToInt(SectUser[k]->depth_fixed)); + if (TEST(sect->extra, SECTFX_SINK)) + sop->zorig_floor[sop->num_sectors] += Z(FixedToInt(sect->u()->depth_fixed)); // lowest and highest floorz's - if (sector[k].floorz > sop->floor_loz) - sop->floor_loz = sector[k].floorz; + if (sect->floorz > sop->floor_loz) + sop->floor_loz = sect->floorz; - if (sector[k].floorz < sop->floor_hiz) - sop->floor_hiz = sector[k].floorz; + if (sect->floorz < sop->floor_hiz) + sop->floor_hiz = sect->floorz; sop->num_sectors++; } @@ -2531,14 +2532,17 @@ void DoTrack(SECTOR_OBJECTp sop, short locktics, int *nx, int *ny) for (i = 0, sectp = &sop->sectp[0]; *sectp; sectp++, i++) { - sectu = SectUser[sectnum(*sectp)].Data(); - - if (sectu && sectu->stag == SECT_SO_FORM_WHIRLPOOL) + if ((*sectp)->hasU()) { - AnimSet(ANIM_Floorz, sectnum(*sectp), nullptr, (*sectp)->floorz + Z(sectu->height), 128); - (*sectp)->floorshade += sectu->height/6; + sectu = (*sectp)->u(); - RESET((*sectp)->extra, SECTFX_NO_RIDE); + if (sectu && sectu->stag == SECT_SO_FORM_WHIRLPOOL) + { + AnimSet(ANIM_Floorz, sectnum(*sectp), nullptr, (*sectp)->floorz + Z(sectu->height), 128); + (*sectp)->floorshade += sectu->height / 6; + + RESET((*sectp)->extra, SECTFX_NO_RIDE); + } } } diff --git a/source/games/sw/src/vator.cpp b/source/games/sw/src/vator.cpp index 90917cd70..02bb00fe3 100644 --- a/source/games/sw/src/vator.cpp +++ b/source/games/sw/src/vator.cpp @@ -295,13 +295,13 @@ void InterpSectorSprites(short sectnum, bool state) } } -void MoveSpritesWithSector(short sectnum, int z_amt, bool type) +void MoveSpritesWithSector(int sectnum, int z_amt, bool type) { SPRITEp sp; bool both = false; - - if (SectUser[sectnum].Data()) - both = !!TEST(SectUser[sectnum]->flags, SECTFU_VATOR_BOTH); + auto sect = §or[sectnum]; + if ( sect->hasU()) + both = !!TEST(sect->u()->flags, SECTFU_VATOR_BOTH); SWSectIterator it(sectnum); while (auto actor = it.Next()) @@ -320,7 +320,7 @@ void MoveSpritesWithSector(short sectnum, int z_amt, bool type) case STAT_STATIC_FIRE: break; default: - goto cont; + continue; } } else @@ -331,7 +331,7 @@ void MoveSpritesWithSector(short sectnum, int z_amt, bool type) case STAT_HOLE_QUEUE: // case STAT_WALLBLOOD_QUEUE: // case STAT_FLOORBLOOD_QUEUE: - goto cont; + continue; } } @@ -356,9 +356,6 @@ void MoveSpritesWithSector(short sectnum, int z_amt, bool type) } sp->z += z_amt; - -cont: - continue; } } diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 7f54a4caf..62119dd6c 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -4335,7 +4335,7 @@ bool WeaponMoveHit(DSWActor* actor) return true; } - if (SectUser[hit_sect].Data() && FixedToInt(SectUser[hit_sect]->depth_fixed) > 0) + if (sector[hit_sect].hasU() && FixedToInt(sector[hit_sect].u()->depth_fixed) > 0) { SpawnSplash(actor); return true; @@ -7678,7 +7678,7 @@ int DoStar(DSWActor* actor) if (sp->z > ((u->hiz + u->loz) >> 1)) { - if (SectUser[hit_sect].Data() && FixedToInt(SectUser[hit_sect]->depth_fixed) > 0) + if (sector[hit_sect].hasU() && FixedToInt(sector[hit_sect].u()->depth_fixed) > 0) { SpawnSplash(actor); KillActor(actor);