diff --git a/source/games/sw/src/actor.cpp b/source/games/sw/src/actor.cpp index 116641d4d..27330dfdd 100644 --- a/source/games/sw/src/actor.cpp +++ b/source/games/sw/src/actor.cpp @@ -592,7 +592,7 @@ void KeepActorOnFloor(DSWActor* actor) { int ceilz, florz; Collision ctrash, ftrash; - FAFgetzrangepoint(sp->x, sp->y, sp->z, sp->sectnum, + FAFgetzrangepoint(sp->x, sp->y, sp->z, sp->sector(), &ceilz, &ctrash, &florz, &ftrash); u->oz = sp->z = florz; diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index 398632c93..7d76dbacc 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -221,7 +221,7 @@ int DoShadowFindGroundPoint(tspriteptr_t sp) save_cstat = sp->cstat; RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); - FAFgetzrangepoint(sp->x, sp->y, sp->z, sp->sectnum, &hiz, &ceilhit, &loz, &florhit); + FAFgetzrangepoint(sp->x, sp->y, sp->z, sp->sector(), &hiz, &ceilhit, &loz, &florhit); sp->cstat = save_cstat; switch (florhit.type) diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 4424dd8fe..05dd31803 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -1926,7 +1926,7 @@ void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* loz, Collision* florhit, int32_t clipdist, int32_t clipmask); -void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t sectnum, +void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, sectortype* sect, int32_t* hiz, Collision* ceilhit, int32_t* loz, Collision* florhit); diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index 33d687551..ac1c511c8 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -570,11 +570,11 @@ void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit, } } -void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, int16_t const sectnum, +void FAFgetzrangepoint(int32_t x, int32_t y, int32_t z, sectortype* const sect, int32_t* hiz, Collision* ceilhit, int32_t* loz, Collision* florhit) { - auto sect = §or[sectnum]; + int sectnum = ::sectnum(sect); int foo1; Collision foo2; bool SkipFAFcheck; diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 2b43ad6f6..1c821f05b 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -665,20 +665,6 @@ sectortype* FindNextSectorByTag(sectortype* sect, int tag) } -int SectorDistance(short sect1, int sect2) -{ - - if (sect1 < 0 || sect2 < 0) - return 9999999; - - auto wall1 = sector[sect1].firstWall(); - auto wall2 = sector[sect2].firstWall(); - - // return the distance between the two sectors. - return Distance(wall1->x, wall1->y, wall2->x, wall2->y); -} - - short DoSpawnActorTrigger(short match) { short spawn_count = 0; diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 3d55df97b..2d5b661d3 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -4683,7 +4683,7 @@ int DoActorGlobZ(DSWActor* actor) } -bool ActorDrop(DSWActor* actor, int x, int y, int z, short new_sector, short min_height) +bool ActorDrop(DSWActor* actor, int x, int y, int z, sectortype* new_sector, short min_height) { SPRITEp sp = &actor->s(); int hiz, loz; @@ -4739,7 +4739,6 @@ bool DropAhead(DSWActor* actor, int min_height) { SPRITEp sp = &actor->s(); int dax, day; - int newsector; // dax = sp->x + MOVEx(128, sp->ang); // day = sp->y + MOVEy(128, sp->ang); @@ -4747,7 +4746,7 @@ bool DropAhead(DSWActor* actor, int min_height) dax = sp->x + MOVEx(256, sp->ang); day = sp->y + MOVEy(256, sp->ang); - newsector = sp->sectnum; + auto newsector = sp->sector(); updatesector(dax, day, &newsector); // look straight down for a drop @@ -4826,7 +4825,7 @@ int move_actor(DSWActor* actor, int xchange, int ychange, int zchange) return false; } - if (ActorDrop(actor, sp->x, sp->y, sp->z, sp->sectnum, u->lo_step)) + if (ActorDrop(actor, sp->x, sp->y, sp->z, sp->sector(), u->lo_step)) { // cancel move sp->x = x; @@ -6655,7 +6654,7 @@ MissileZrange(DSWActor* actor) tempshort = sp->cstat; RESET(sp->cstat, CSTAT_SPRITE_BLOCK); - FAFgetzrangepoint(sp->x, sp->y, sp->z - 1, sp->sectnum, + FAFgetzrangepoint(sp->x, sp->y, sp->z - 1, sp->sector(), &globhiz, &globhihit, &globloz, &globlohit); sp->cstat = tempshort; @@ -6714,7 +6713,7 @@ Collision move_missile(DSWActor* actor, int xchange, int ychange, int zchange, i tempshort = sp->cstat; RESET(sp->cstat, CSTAT_SPRITE_BLOCK); - FAFgetzrangepoint(sp->x, sp->y, sp->z - 1, sp->sectnum, + FAFgetzrangepoint(sp->x, sp->y, sp->z - 1, sp->sector(), &globhiz, &globhihit, &globloz, &globlohit); sp->cstat = tempshort; diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 1281b6c6d..936e920c9 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -11249,7 +11249,7 @@ int DoFindGroundPoint(DSWActor* actor) save_cstat = sp->cstat; RESET(sp->cstat, CSTAT_SPRITE_BLOCK | CSTAT_SPRITE_BLOCK_HITSCAN); - FAFgetzrangepoint(sp->x, sp->y, sp->z, sp->sectnum, &u->hiz, &ceilhit, &u->loz, &florhit); + FAFgetzrangepoint(sp->x, sp->y, sp->z, sp->sector(), &u->hiz, &ceilhit, &u->loz, &florhit); sp->cstat = save_cstat; switch (florhit.type)