From 104e80e34aec7fbb185d44031d3349b0cd429ee1 Mon Sep 17 00:00:00 2001 From: Christoph Oelckers Date: Thu, 25 Nov 2021 19:25:05 +0100 Subject: [PATCH] - NEAR_TAG_LIST, also deleted useless OperateWall code. --- source/games/sw/src/ai.cpp | 9 -------- source/games/sw/src/game.h | 2 +- source/games/sw/src/sector.cpp | 39 ++++++++++---------------------- source/games/sw/src/sector.h | 3 ++- source/games/sw/src/sprite.cpp | 4 ++-- source/games/sw/src/sumo.cpp | 2 +- source/games/sw/src/track.cpp | 18 --------------- source/games/sw/src/wallmove.cpp | 2 +- source/games/sw/src/warp.cpp | 2 +- source/games/sw/src/weapon.cpp | 5 ++-- 10 files changed, 22 insertions(+), 64 deletions(-) diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index 4a6972f4a..189e89c33 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -487,15 +487,6 @@ int DoActorOperate(DSWActor* actor) } } - if (nearwall >= 0 && nearhitdist < 1024) - { - if (OperateWall(nearwall, false)) - { - u->WaitTics = 2 * 120; - - NewStateGroup(actor, u->ActorActionSet->Stand); - } - } return true; } diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 2ffc62462..105879f2b 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -2101,7 +2101,7 @@ int DoWallMoveMatch(short match); // wallmove.c int DoWallMove(DSWActor* sp); // wallmove.c bool CanSeeWallMove(SPRITEp wp,short match); // wallmove.c -void DoSpikeOperate(short sectnum); // spike.c +void DoSpikeOperate(sectortype* sect); // spike.c void SetSpikeActive(DSWActor*); // spike.c #define NTAG_SEARCH_LO 1 diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 2a7e30eec..3db5dd68f 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -740,12 +740,6 @@ int OperateSector(sectortype* sect, short player_is_operating) return false; } -int -OperateWall(short wallnum, short player_is_operating) -{ - return false; -} - enum { SWITCH_LEVER = 581, @@ -2130,8 +2124,8 @@ void NearTagList(NEAR_TAG_INFOp ntip, PLAYERp pp, int z, int dist, int type, int save_hitag = ntsec->hitag; ntip->dist = neartaghitdist; - ntip->sectnum = neartagsector; - ntip->wallnum = -1; + ntip->sectp = ntsec; + ntip->wallp = nullptr; ntip->actor = nullptr; nti_cnt++; ntip++; @@ -2157,8 +2151,8 @@ void NearTagList(NEAR_TAG_INFOp ntip, PLAYERp pp, int z, int dist, int type, int save_hitag = ntwall->hitag; ntip->dist = neartaghitdist; - ntip->sectnum = -1; - ntip->wallnum = neartagwall; + ntip->sectp = nullptr; + ntip->wallp = ntwall; ntip->actor = nullptr; nti_cnt++; ntip++; @@ -2185,8 +2179,8 @@ void NearTagList(NEAR_TAG_INFOp ntip, PLAYERp pp, int z, int dist, int type, int save_hitag = sp->hitag; ntip->dist = neartaghitdist; - ntip->sectnum = -1; - ntip->wallnum = -1; + ntip->sectp = nullptr; + ntip->wallp = nullptr; ntip->actor = actor; nti_cnt++; ntip++; @@ -2207,8 +2201,8 @@ void NearTagList(NEAR_TAG_INFOp ntip, PLAYERp pp, int z, int dist, int type, int else { ntip->dist = -1; - ntip->sectnum = -1; - ntip->wallnum = -1; + ntip->sectp = nullptr; + ntip->wallp = nullptr; ntip->actor = nullptr; nti_cnt++; ntip++; @@ -2341,28 +2335,19 @@ void PlayerOperateEnv(PLAYERp pp) { int neartaghitdist; - short neartagsector, neartagwall; + sectortype* neartagsector; neartaghitdist = nti[0].dist; - neartagsector = nti[0].sectnum; - neartagwall = nti[0].wallnum; + neartagsector = nti[0].sectp; - if (neartagsector >= 0 && neartaghitdist < 1024) + if (neartagsector != nullptr && neartaghitdist < 1024) { - if (OperateSector(§or[neartagsector], true)) + if (OperateSector(neartagsector, true)) { // Release the key pp->KeyPressBits &= ~SB_OPEN; } } - - if (neartagwall >= 0 && neartaghitdist < 1024) - { - if (OperateWall(neartagwall, true)) - { - pp->KeyPressBits &= ~SB_OPEN; - } - } } // diff --git a/source/games/sw/src/sector.h b/source/games/sw/src/sector.h index 0916226cb..a1cb3f585 100644 --- a/source/games/sw/src/sector.h +++ b/source/games/sw/src/sector.h @@ -60,7 +60,8 @@ enum SO_SCALE_TYPE typedef struct { int dist; - short sectnum, wallnum; + sectortype* sectp; + walltype* wallp; DSWActor* actor; } NEAR_TAG_INFO, *NEAR_TAG_INFOp; extern short nti_cnt; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 656189247..ce0f5987b 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -1592,7 +1592,7 @@ void SpriteSetupPost(void) if (jActor->hasU()) continue; - getzsofslope(ds->sectnum, ds->x, ds->y, &cz, &fz); + getzsofslopeptr(ds->sector(), ds->x, ds->y, &cz, &fz); if (labs(ds->z - fz) > Z(4)) continue; @@ -3581,7 +3581,7 @@ bool ItemSpotClear(DSWActor* actor, short statnum, short id) if (TEST_BOOL2(sip)) { - SWSectIterator it(sip->sectnum); + SWSectIterator it(sip->sector()); while (auto itActor = it.Next()) { if (itActor->s().statnum == statnum && itActor->u()->ID == id) diff --git a/source/games/sw/src/sumo.cpp b/source/games/sw/src/sumo.cpp index 647288e79..410eea39e 100644 --- a/source/games/sw/src/sumo.cpp +++ b/source/games/sw/src/sumo.cpp @@ -838,7 +838,7 @@ void BossHealthMeter(void) sp = &BossSpriteNum[i]->s(); u = BossSpriteNum[i]->u(); - if (cansee(sp->x, sp->y, SPRITEp_TOS(sp), sp->sectnum, pp->posx, pp->posy, pp->posz - Z(40), pp->cursectnum)) + if (cansee(sp->x, sp->y, SPRITEp_TOS(sp), sp->sector(), pp->posx, pp->posy, pp->posz - Z(40), pp->cursector())) { if (i == 0 && !bosswasseen[0]) { diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index c5ded700f..0ce51c313 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -1670,10 +1670,8 @@ void MovePoints(SECTOR_OBJECTp sop, short delta_ang, int nx, int ny) sop->sp_child->s().x = sop->xmid; sop->sp_child->s().y = sop->ymid; - //updatesector(sop->xmid, sop->ymid, &sop->sectnum); // setting floorz if need be - //if (!TEST(sop->flags, SOBJ_SPRITE_OBJ)) if (TEST(sop->flags, SOBJ_ZMID_FLOOR)) sop->zmid = sop->mid_sector->floorz; @@ -3222,9 +3220,6 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor) sp->ang = tpoint->ang; -// //DSPRINTF(ds,"sp->x = %ld, sp->y = %ld, sp->sector = %d, tp->x = %ld, tp->y = %ld, tp->ang = %d\n",sp->x,sp->y,sp->sectnum,tpoint->x,tpoint->y,tpoint->ang); -// MONO_PRINT(ds); - z[0] = sp->z - SPRITEp_SIZE_Z(sp) + Z(5); z[1] = sp->z - DIV2(SPRITEp_SIZE_Z(sp)); @@ -3261,19 +3256,6 @@ bool ActorTrackDecide(TRACK_POINTp tpoint, DSWActor* actor) } } - if (nearwall >= 0 && nearhitdist < 1024) - { - if (OperateWall(nearwall, false)) - { - if (!tpoint->tag_high) - u->WaitTics = 2 * 120; - else - u->WaitTics = tpoint->tag_high * 128; - - NewStateGroup(actor, u->ActorActionSet->Stand); - } - } - break; } diff --git a/source/games/sw/src/wallmove.cpp b/source/games/sw/src/wallmove.cpp index bd46ee0be..ef18fd942 100644 --- a/source/games/sw/src/wallmove.cpp +++ b/source/games/sw/src/wallmove.cpp @@ -176,7 +176,7 @@ bool CanSeeWallMove(SPRITEp wp, short match) { found = true; - if (cansee(wp->x, wp->y, wp->z, wp->sectnum, sp->x, sp->y, sp->z, sp->sectnum)) + if (cansee(wp->x, wp->y, wp->z, wp->sector(), sp->x, sp->y, sp->z, sp->sector())) { return true; } diff --git a/source/games/sw/src/warp.cpp b/source/games/sw/src/warp.cpp index 5e4eb5885..1b38fa0f9 100644 --- a/source/games/sw/src/warp.cpp +++ b/source/games/sw/src/warp.cpp @@ -177,7 +177,7 @@ DSWActor* WarpToArea(DSWActor* sp_from, int32_t* x, int32_t* y, int32_t* z, int* // exp: WARP_CEILING or WARP_CEILING_PLANE if (spi->hitag == to_tag) { - if (!validSectorIndex(spi->sectnum)) + if (!spi->insector()) return nullptr; // determine new x,y,z position diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index e2eb40bd1..078a98afc 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -18585,7 +18585,7 @@ int QueueStar(DSWActor* actor) // move old star to new stars place osp = &StarQueue[StarQueueHead]->s(); osp->pos = sp->pos; - ChangeActorSect(StarQueue[StarQueueHead], sp->sectnum); + ChangeActorSect(StarQueue[StarQueueHead], sp->sector()); KillActor(actor); actor = StarQueue[StarQueueHead]; } @@ -19101,11 +19101,10 @@ void QueueGeneric(DSWActor* actor, short pic) { // move old sprite to new sprite's place osp = &GenericQueue[GenericQueueHead]->s(); - //setspritez(GenericQueue[GenericQueueHead], &sp->pos); osp->x = sp->x; osp->y = sp->y; osp->z = sp->z; - ChangeActorSect(GenericQueue[GenericQueueHead], sp->sectnum); + ChangeActorSect(GenericQueue[GenericQueueHead], sp->sector()); KillActor(actor); actor = GenericQueue[GenericQueueHead]; ASSERT(actor->s().statnum != MAXSTATUS);