diff --git a/source/games/sw/src/ai.cpp b/source/games/sw/src/ai.cpp index 1373a44aa..364d1087e 100644 --- a/source/games/sw/src/ai.cpp +++ b/source/games/sw/src/ai.cpp @@ -236,7 +236,7 @@ bool CanSeePlayer(DSWActor* actor) //if (FAF_Sector(sp->sectnum)) // return(true); - if (u->targetActor && FAFcansee(sp->x, sp->y, look_height, sp->sectnum, u->targetActor->s().x, u->targetActor->s().y, ActorUpper(u->targetActor), u->targetActor->s().sectnum)) + if (u->targetActor && FAFcansee(sp->x, sp->y, look_height, sp->sector(), u->targetActor->s().x, u->targetActor->s().y, ActorUpper(u->targetActor), u->targetActor->s().sector())) return true; else return false; @@ -384,7 +384,7 @@ int DoActorPickClosePlayer(DSWActor* actor) DISTANCE(sp->x, sp->y, pp->posx, pp->posy, dist, a, b, c); auto psp = &pp->Actor()->s(); - if (dist < near_dist && FAFcansee(sp->x, sp->y, look_height, sp->sectnum, psp->x, psp->y, SPRITEp_UPPER(psp), psp->sectnum)) + if (dist < near_dist && FAFcansee(sp->x, sp->y, look_height, sp->sector(), psp->x, psp->y, SPRITEp_UPPER(psp), psp->sector())) { near_dist = dist; u->targetActor = pp->Actor(); @@ -411,7 +411,7 @@ TARGETACTOR: auto itSp = &itActor->s(); DISTANCE(sp->x, sp->y, itSp->x, itSp->y, dist, a, b, c); - if (dist < near_dist && FAFcansee(sp->x, sp->y, look_height, sp->sectnum, itSp->x, itSp->y, SPRITEp_UPPER(itSp), itSp->sectnum)) + if (dist < near_dist && FAFcansee(sp->x, sp->y, look_height, sp->sector(), itSp->x, itSp->y, SPRITEp_UPPER(itSp), itSp->sector())) { near_dist = dist; u->targetActor = itActor; diff --git a/source/games/sw/src/bunny.cpp b/source/games/sw/src/bunny.cpp index 025673b04..399640fc8 100644 --- a/source/games/sw/src/bunny.cpp +++ b/source/games/sw/src/bunny.cpp @@ -927,7 +927,7 @@ void DoPickCloseBunny(DSWActor* actor) if (dist > near_dist) continue; - ICanSee = FAFcansee(sp->x, sp->y, look_height, sp->sectnum, tsp->x, tsp->y, SPRITEp_UPPER(tsp), tsp->sectnum); + ICanSee = FAFcansee(sp->x, sp->y, look_height, sp->sector(), tsp->x, tsp->y, SPRITEp_UPPER(tsp), tsp->sector()); if (ICanSee && dist < near_dist && tu->ID == BUNNY_RUN_R0) { @@ -1032,7 +1032,7 @@ int DoBunnyQuickJump(DSWActor* actor) if (pp == Player+myconnectindex) { choose_snd = STD_RANDOM_RANGE(2<<8)>>8; - if (FAFcansee(sp->x,sp->y,SPRITEp_TOS(sp),sp->sectnum,pp->posx, pp->posy, pp->posz, pp->cursectnum) && Facing(actor, u->targetActor)) + if (FAFcansee(sp->x,sp->y,SPRITEp_TOS(sp),sp->sector(),pp->posx, pp->posy, pp->posz, pp->cursector()) && Facing(actor, u->targetActor)) PlayerSound(fagsnds[choose_snd], v3df_doppler|v3df_follow|v3df_dontpan,pp); } } @@ -1047,7 +1047,7 @@ int DoBunnyQuickJump(DSWActor* actor) if (pp == Player+myconnectindex) { choose_snd = STD_RANDOM_RANGE(3<<8)>>8; - if (FAFcansee(sp->x,sp->y,SPRITEp_TOS(sp),sp->sectnum,pp->posx, pp->posy, pp->posz, pp->cursectnum) && Facing(actor, u->targetActor)) + if (FAFcansee(sp->x,sp->y,SPRITEp_TOS(sp),sp->sector(),pp->posx, pp->posy, pp->posz, pp->cursector()) && Facing(actor, u->targetActor)) PlayerSound(straightsnds[choose_snd], v3df_doppler|v3df_follow|v3df_dontpan,pp); } } diff --git a/source/games/sw/src/draw.cpp b/source/games/sw/src/draw.cpp index d025a42c7..cdccbbae2 100644 --- a/source/games/sw/src/draw.cpp +++ b/source/games/sw/src/draw.cpp @@ -1097,8 +1097,8 @@ void CameraView(PLAYERp pp, int *tx, int *ty, int *tz, int *tsectnum, binangle * ang_test = getincangle(ang.asbuild(), sp->ang) < sp->lotag; FAFcansee_test = - (FAFcansee(sp->x, sp->y, sp->z, sp->sectnum, *tx, *ty, *tz, pp->cursectnum) || - FAFcansee(sp->x, sp->y, sp->z, sp->sectnum, *tx, *ty, *tz + SPRITEp_SIZE_Z(&pp->Actor()->s()), pp->cursectnum)); + (FAFcansee(sp->x, sp->y, sp->z, sp->sector(), *tx, *ty, *tz, pp->cursector()) || + FAFcansee(sp->x, sp->y, sp->z, sp->sector(), *tx, *ty, *tz + SPRITEp_SIZE_Z(&pp->Actor()->s()), pp->cursector())); player_in_camera = ang_test && FAFcansee_test; diff --git a/source/games/sw/src/game.h b/source/games/sw/src/game.h index 447cd3e61..b8bb2092c 100644 --- a/source/games/sw/src/game.h +++ b/source/games/sw/src/game.h @@ -786,6 +786,7 @@ struct PLAYERstruct int16_t camera_check_time_delay; int cursectnum,lastcursectnum; + sectortype* cursector() { return cursectnum < 0? nullptr : §or[cursectnum]; } fixed_t turn180_target; // 180 degree turn // variables that do not fit into sprite structure @@ -1916,7 +1917,7 @@ void FAFhitscan(int32_t x, int32_t y, int32_t z, int16_t sectnum, int32_t xvect, int32_t yvect, int32_t zvect, HITINFO* hitinfo, int32_t clipmask); -bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects, int32_t xe, int32_t ye, int32_t ze, int16_t secte); +bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, sectortype* sects, int32_t xe, int32_t ye, int32_t ze, sectortype* secte); void FAFgetzrange(vec3_t pos, int16_t sectnum, int32_t* hiz, Collision* ceilhit, @@ -2055,6 +2056,7 @@ void computergetinput(int snum,InputPacket *syn); // jplayer.c void DrawOverlapRoom(int tx,int ty,int tz,fixed_t tq16ang,fixed_t tq16horiz,short tsectnum); // rooms.c void SetupMirrorTiles(void); // rooms.c bool FAF_Sector(int sectnum); // rooms.c +bool FAF_Sector(sectortype* sectnum); // rooms.c int GetZadjustment(short sectnum,short hitag); // rooms.c void InitSetup(void); // setup.c diff --git a/source/games/sw/src/jweapon.cpp b/source/games/sw/src/jweapon.cpp index b75238b3f..edcc17c8b 100644 --- a/source/games/sw/src/jweapon.cpp +++ b/source/games/sw/src/jweapon.cpp @@ -1535,7 +1535,7 @@ int PlayerInitFlashBomb(PLAYERp pp) if (!TEST(sp->cstat, CSTAT_SPRITE_BLOCK)) continue; - if (!FAFcansee(hp->x, hp->y, hp->z, hp->sectnum, sp->x, sp->y, sp->z - SPRITEp_SIZE_Z(sp), sp->sectnum)) + if (!FAFcansee(hp->x, hp->y, hp->z, hp->sector(), sp->x, sp->y, sp->z - SPRITEp_SIZE_Z(sp), sp->sector())) continue; damage = GetDamage(itActor, pp->Actor(), DMG_FLASHBOMB); @@ -1601,7 +1601,7 @@ InitFlashBomb(DSWActor* actor) if (!TEST(sp->cstat, CSTAT_SPRITE_BLOCK)) continue; - if (!FAFcansee(hp->x, hp->y, hp->z, hp->sectnum, sp->x, sp->y, sp->z - SPRITEp_SIZE_Z(sp), sp->sectnum)) + if (!FAFcansee(hp->x, hp->y, hp->z, hp->sector(), sp->x, sp->y, sp->z - SPRITEp_SIZE_Z(sp), sp->sector())) continue; damage = GetDamage(itActor, actor, DMG_FLASHBOMB); @@ -2051,7 +2051,7 @@ DSWActor* DoFlagRangeTest(DSWActor* actor, int range) if (!TEST(sp->extra, SPRX_PLAYER_OR_ENEMY)) continue; - if (!FAFcansee(sp->x, sp->y, sp->z, sp->sectnum, wp->x, wp->y, wp->z, wp->sectnum)) + if (!FAFcansee(sp->x, sp->y, sp->z, sp->sector(), wp->x, wp->y, wp->z, wp->sector())) continue; dist = FindDistance3D(wp->x - sp->x, wp->y - sp->y, wp->z - sp->z); diff --git a/source/games/sw/src/miscactr.cpp b/source/games/sw/src/miscactr.cpp index cf01d7e9f..be0fc628c 100644 --- a/source/games/sw/src/miscactr.cpp +++ b/source/games/sw/src/miscactr.cpp @@ -155,7 +155,7 @@ int DoToiletGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,u->targetActor->s().x,u->targetActor->s().y,ActorMid(u->targetActor),u->targetActor->s().sectnum); + ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),u->targetActor->s().x,u->targetActor->s().y,ActorMid(u->targetActor),u->targetActor->s().sector()); if (u->FlagOwner != 1) { @@ -210,7 +210,7 @@ int NullToiletGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,u->targetActor->s().x,u->targetActor->s().y,u->targetActor->s().z,u->targetActor->s().sectnum); + ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),u->targetActor->s().x,u->targetActor->s().y,u->targetActor->s().z,u->targetActor->s().sector()); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(actor); @@ -390,7 +390,7 @@ int DoWashGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,u->targetActor->s().x,u->targetActor->s().y,ActorMid(u->targetActor),u->targetActor->s().sectnum); + ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),u->targetActor->s().x,u->targetActor->s().y,ActorMid(u->targetActor),u->targetActor->s().sector()); if (RandomRange(1000) > 980 && u->ShellNum <= 0) { @@ -454,7 +454,7 @@ int NullWashGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,u->targetActor->s().x,u->targetActor->s().y,u->targetActor->s().z,u->targetActor->s().sectnum); + ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),u->targetActor->s().x,u->targetActor->s().y,u->targetActor->s().z,u->targetActor->s().sector()); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(actor); @@ -1259,7 +1259,7 @@ int DoCarGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,u->targetActor->s().x,u->targetActor->s().y,ActorMid(u->targetActor),u->targetActor->s().sectnum); + ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),u->targetActor->s().x,u->targetActor->s().y,ActorMid(u->targetActor),u->targetActor->s().sector()); if (u->FlagOwner == 1) { @@ -1305,7 +1305,7 @@ int NullCarGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,u->targetActor->s().x,u->targetActor->s().y,u->targetActor->s().z,u->targetActor->s().sectnum); + ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),u->targetActor->s().x,u->targetActor->s().y,u->targetActor->s().z,u->targetActor->s().sector()); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(actor); @@ -1474,7 +1474,7 @@ int DoMechanicGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,u->targetActor->s().x,u->targetActor->s().y,ActorMid(u->targetActor),u->targetActor->s().sectnum); + ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),u->targetActor->s().x,u->targetActor->s().y,ActorMid(u->targetActor),u->targetActor->s().sector()); if (u->FlagOwner == 1) { @@ -1520,7 +1520,7 @@ int NullMechanicGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,u->targetActor->s().x,u->targetActor->s().y,u->targetActor->s().z,u->targetActor->s().sectnum); + ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),u->targetActor->s().x,u->targetActor->s().y,u->targetActor->s().z,u->targetActor->s().sector()); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(actor); @@ -1690,7 +1690,7 @@ int DoSailorGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,u->targetActor->s().x,u->targetActor->s().y,ActorMid(u->targetActor),u->targetActor->s().sectnum); + ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),u->targetActor->s().x,u->targetActor->s().y,ActorMid(u->targetActor),u->targetActor->s().sector()); if (u->FlagOwner == 1) { @@ -1741,7 +1741,7 @@ int NullSailorGirl(DSWActor* actor) static short alreadythrew = 0; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,u->targetActor->s().x,u->targetActor->s().y,u->targetActor->s().z,u->targetActor->s().sectnum); + ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),u->targetActor->s().x,u->targetActor->s().y,u->targetActor->s().z,u->targetActor->s().sector()); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(actor); @@ -1898,7 +1898,7 @@ int DoPruneGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,u->targetActor->s().x,u->targetActor->s().y,ActorMid(u->targetActor),u->targetActor->s().sectnum); + ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),u->targetActor->s().x,u->targetActor->s().y,ActorMid(u->targetActor),u->targetActor->s().sector()); if (u->FlagOwner == 1) { @@ -1960,7 +1960,7 @@ int NullPruneGirl(DSWActor* actor) bool ICanSee = false; DoActorPickClosePlayer(actor); - ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,u->targetActor->s().x,u->targetActor->s().y,u->targetActor->s().z,u->targetActor->s().sectnum); + ICanSee = FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),u->targetActor->s().x,u->targetActor->s().y,u->targetActor->s().z,u->targetActor->s().sector()); if (!TEST(u->Flags,SPR_CLIMBING)) KeepActorOnFloor(actor); diff --git a/source/games/sw/src/player.cpp b/source/games/sw/src/player.cpp index 7cc975cd1..88f9c3c29 100644 --- a/source/games/sw/src/player.cpp +++ b/source/games/sw/src/player.cpp @@ -1208,9 +1208,9 @@ DSWActor* DoPickTarget(DSWActor* actor, uint32_t max_delta_ang, int skip_targets ezhl = SPRITEp_BOS(ep) - (SPRITEp_SIZE_Z(ep) >> 2); // If you can't see 'em you can't shoot 'em - if (!FAFcansee(sp->x, sp->y, zh, sp->sectnum, ep->x, ep->y, ezh, ep->sectnum) && - !FAFcansee(sp->x, sp->y, zh, sp->sectnum, ep->x, ep->y, ezhm, ep->sectnum) && - !FAFcansee(sp->x, sp->y, zh, sp->sectnum, ep->x, ep->y, ezhl, ep->sectnum) + if (!FAFcansee(sp->x, sp->y, zh, sp->sector(), ep->x, ep->y, ezh, ep->sector()) && + !FAFcansee(sp->x, sp->y, zh, sp->sector(), ep->x, ep->y, ezhm, ep->sector()) && + !FAFcansee(sp->x, sp->y, zh, sp->sector(), ep->x, ep->y, ezhl, ep->sector()) ) continue; @@ -5840,7 +5840,7 @@ void DoPlayerDeathFollowKiller(PLAYERp pp) { SPRITEp kp = &pp->KillerActor->s(); - if (FAFcansee(kp->x, kp->y, SPRITEp_TOS(kp), kp->sectnum, pp->posx, pp->posy, pp->posz, pp->cursectnum)) + if (FAFcansee(kp->x, kp->y, SPRITEp_TOS(kp), kp->sector(), pp->posx, pp->posy, pp->posz, pp->cursector())) { pp->angle.addadjustment(getincanglebam(pp->angle.ang, bvectangbam(kp->x - pp->posx, kp->y - pp->posy)) >> 4); } diff --git a/source/games/sw/src/rooms.cpp b/source/games/sw/src/rooms.cpp index 554a6276a..977c93266 100644 --- a/source/games/sw/src/rooms.cpp +++ b/source/games/sw/src/rooms.cpp @@ -100,6 +100,25 @@ bool FAF_Sector(int sectnum) return false; } +bool FAF_Sector(sectortype* sectnum) +{ + SPRITEp sp; + + SWSectIterator it(sectnum); + while (auto actor = it.Next()) + { + sp = &actor->s(); + + if (sp->statnum == STAT_FAF && + (sp->hitag >= VIEW_LEVEL1 && sp->hitag <= VIEW_LEVEL6)) + { + return true; + } + } + + return false; +} + void SetWallWarpHitscan(short sectnum) { short start_wall, wall_num; @@ -269,11 +288,11 @@ FAFhitscan(int32_t x, int32_t y, int32_t z, int16_t sectnum, } } -bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects, - int32_t xe, int32_t ye, int32_t ze, int16_t secte) +bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, sectortype* sects, + int32_t xe, int32_t ye, int32_t ze, sectortype* secte) { int loz, hiz; - int newsectnum = sects; + auto newsect = sects; int xvect, yvect, zvect; short ang; hitdata_t hitinfo; @@ -284,7 +303,7 @@ bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects, // ASSERT(sects >= 0 && secte >= 0); // early out to regular routine - if ((sects < 0 || !FAF_Sector(sects)) && (secte < 0 || !FAF_Sector(secte))) + if ((!sects || !FAF_Sector(sects)) && (!secte || !FAF_Sector(secte))) { return !!cansee(xs,ys,zs,sects,xe,ye,ze,secte); } @@ -311,7 +330,7 @@ bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects, else zvect = 0; - hitscan(&s, sects, xvect, yvect, zvect, + hitscan(&s, sectnum(sects), xvect, yvect, zvect, &hitinfo, CLIPMASK_MISSILE); if (hitinfo.sect < 0) @@ -325,7 +344,7 @@ bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects, { if (FAF_ConnectFloor(hitinfo.sect)) { - updatesectorz(hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z + Z(12), &newsectnum); + updatesectorz(hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z + Z(12), &newsect); plax_found = true; } } @@ -333,7 +352,7 @@ bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects, { if (FAF_ConnectCeiling(hitinfo.sect)) { - updatesectorz(hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z - Z(12), &newsectnum); + updatesectorz(hitinfo.pos.x, hitinfo.pos.y, hitinfo.pos.z - Z(12), &newsect); plax_found = true; } } @@ -344,7 +363,7 @@ bool FAFcansee(int32_t xs, int32_t ys, int32_t zs, int16_t sects, } if (plax_found) - return !!cansee(hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,newsectnum,xe,ye,ze,secte); + return !!cansee(hitinfo.pos.x,hitinfo.pos.y,hitinfo.pos.z,newsect,xe,ye,ze,secte); return false; } diff --git a/source/games/sw/src/sector.cpp b/source/games/sw/src/sector.cpp index 259992882..d89a51276 100644 --- a/source/games/sw/src/sector.cpp +++ b/source/games/sw/src/sector.cpp @@ -1251,7 +1251,7 @@ void WeaponExplodeSectorInRange(DSWActor* wActor) if ((unsigned int)dist > (wu->Radius/2) + radius) continue; - if (!FAFcansee(wp->x,wp->y,wp->z,wp->sectnum,sp->x,sp->y,sp->z,sp->sectnum)) + if (!FAFcansee(wp->x,wp->y,wp->z,wp->sector(),sp->x,sp->y,sp->z,sp->sector())) continue; @@ -1500,7 +1500,7 @@ int OperateSprite(DSWActor* actor, short player_is_operating) { pp = GlobPlayerP; - if (!FAFcansee(pp->posx, pp->posy, pp->posz, pp->cursectnum, sp->x, sp->y, sp->z - DIV2(SPRITEp_SIZE_Z(sp)), sp->sectnum)) + if (!FAFcansee(pp->posx, pp->posy, pp->posz, pp->cursector(), sp->x, sp->y, sp->z - DIV2(SPRITEp_SIZE_Z(sp)), sp->sector())) return false; } diff --git a/source/games/sw/src/sounds.cpp b/source/games/sw/src/sounds.cpp index 6bdadb0eb..edb103e5f 100644 --- a/source/games/sw/src/sounds.cpp +++ b/source/games/sw/src/sounds.cpp @@ -382,7 +382,7 @@ static void UpdateAmbients() if (sdist < 255 && amb->vocIndex == DIGI_WHIPME) { PLAYERp pp = Player + screenpeek; - if (!FAFcansee(sp->pos.x, sp->pos.y, sp->pos.z, sp->sectnum, pp->posx, pp->posy, pp->posz, pp->cursectnum)) + if (!FAFcansee(sp->pos.x, sp->pos.y, sp->pos.z, sp->sector(), pp->posx, pp->posy, pp->posz, pp->cursector())) { sdist = 255; } @@ -560,7 +560,7 @@ void SWSoundEngine::CalcPosVel(int type, const void* source, const float pt[3], // Can the ambient sound see the player? If not, tone it down some. if ((chanflags & CHANF_LOOP)) { - if (!FAFcansee(vpos->x, vpos->y, vpos->z, sp->sectnum, pp->posx, pp->posy, pp->posz, pp->cursectnum)) + if (!FAFcansee(vpos->x, vpos->y, vpos->z, sp->sector(), pp->posx, pp->posy, pp->posz, pp->cursector())) { auto distvec = npos - campos; npos = campos + distvec * 1.75f; // Play more quietly diff --git a/source/games/sw/src/sprite.cpp b/source/games/sw/src/sprite.cpp index 20193d625..d8916e82b 100644 --- a/source/games/sw/src/sprite.cpp +++ b/source/games/sw/src/sprite.cpp @@ -5331,8 +5331,8 @@ int DoGet(DSWActor* actor) cstat_bak = sp->cstat; SET(sp->cstat, CSTAT_SPRITE_BLOCK|CSTAT_SPRITE_BLOCK_HITSCAN); - can_see = FAFcansee(sp->x, sp->y, sp->z, sp->sectnum, - pp->posx, pp->posy, pp->posz, pp->cursectnum); + can_see = FAFcansee(sp->x, sp->y, sp->z, sp->sector(), + pp->posx, pp->posy, pp->posz, pp->cursector()); sp->cstat = cstat_bak; if (!can_see) @@ -6204,7 +6204,7 @@ AdjustActiveRange(PLAYERp pp, DSWActor* actor, int dist) // if actor can still see the player look_height = SPRITEp_TOS(sp); - if (FAFcansee(sp->x, sp->y, look_height, sp->sectnum, psp->x, psp->y, SPRITEp_UPPER(psp), psp->sectnum)) + if (FAFcansee(sp->x, sp->y, look_height, sp->sector(), psp->x, psp->y, SPRITEp_UPPER(psp), psp->sector())) { // Player is visible // adjust update range of this sprite diff --git a/source/games/sw/src/track.cpp b/source/games/sw/src/track.cpp index e28d2cae5..2f3e1daf6 100644 --- a/source/games/sw/src/track.cpp +++ b/source/games/sw/src/track.cpp @@ -257,7 +257,7 @@ short ActorFindTrack(DSWActor* actor, int8_t player_dir, int track_type, int *tr updatesector(near_tp->x, near_tp->y, &track_sect); // if can see the point, return the track number - if (FAFcansee(sp->x, sp->y, sp->z - Z(16), sp->sectnum, near_tp->x, near_tp->y, sector[track_sect].floorz - Z(32), track_sect)) + if (FAFcansee(sp->x, sp->y, sp->z - Z(16), sp->sector(), near_tp->x, near_tp->y, sector[track_sect].floorz - Z(32), §or[track_sect])) { //DSPRINTF(ds,"Found track point in sector %d\n",track_sect); MONO_PRINT(ds); @@ -2907,8 +2907,8 @@ void DoAutoTurretObject(SECTOR_OBJECTp sop) if (shootp->statnum == STAT_SO_SHOOT_POINT) { - if (!FAFcansee(shootp->x, shootp->y, shootp->z-Z(4), shootp->sectnum, - u->targetActor->s().x, u->targetActor->s().y, ActorUpper(u->targetActor), u->targetActor->s().sectnum)) + if (!FAFcansee(shootp->x, shootp->y, shootp->z-Z(4), shootp->sector(), + u->targetActor->s().x, u->targetActor->s().y, ActorUpper(u->targetActor), u->targetActor->s().sector())) { return; } diff --git a/source/games/sw/src/vis.cpp b/source/games/sw/src/vis.cpp index 2701db345..f8996bcdf 100644 --- a/source/games/sw/src/vis.cpp +++ b/source/games/sw/src/vis.cpp @@ -89,7 +89,7 @@ void VisViewChange(PLAYERp pp, int *vis) SPRITEp sp; short BrightestVis = NormalVisibility; int x,y,z; - short sectnum; + sectortype* sectp; if (paused) return; @@ -106,18 +106,18 @@ void VisViewChange(PLAYERp pp, int *vis) x = own->s().x; y = own->s().y; z = own->s().z; - sectnum = own->s().sectnum; + sectp = own->s().sector(); } else { x = sp->x; y = sp->y; z = sp->z; - sectnum = sp->sectnum; + sectp = sp->sector(); } // save off the brightest vis that you can see - if (FAFcansee(pp->posx, pp->posy, pp->posz, pp->cursectnum, x, y, z, sectnum)) + if (FAFcansee(pp->posx, pp->posy, pp->posz, pp->cursector(), x, y, z, sectp)) { if (VIS_VisCur(sp) < BrightestVis) BrightestVis = VIS_VisCur(sp); diff --git a/source/games/sw/src/weapon.cpp b/source/games/sw/src/weapon.cpp index 003722006..23014b1f3 100644 --- a/source/games/sw/src/weapon.cpp +++ b/source/games/sw/src/weapon.cpp @@ -7182,7 +7182,7 @@ int DoDamageTest(DSWActor* actor) // For speed's sake, try limiting check only to radius weapons! if (wu->Radius > 200) { - if (!FAFcansee(sp->x,sp->y, SPRITEp_UPPER(sp), sp->sectnum,wp->x,wp->y,wp->z,wp->sectnum)) + if (!FAFcansee(sp->x,sp->y, SPRITEp_UPPER(sp), sp->sector(),wp->x,wp->y,wp->z,wp->sector())) continue; } @@ -7263,7 +7263,7 @@ int DoFlamesDamageTest(DSWActor* actor) if (wu->Radius > 200) // Note: No weaps have bigger radius than 200 cept explosion stuff { - if (FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,wp->x,wp->y,SPRITEp_MID(wp),wp->sectnum)) + if (FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),wp->x,wp->y,SPRITEp_MID(wp),wp->sector())) { DoDamage(itActor, actor); } @@ -7344,7 +7344,7 @@ void TraverseBreakableWalls(short start_sect, int x, int y, int z, short ang, in if (WallBreakPosition(&wal, §num, &hit_x, &hit_y, &hit_z, &wall_ang)) { - if (hit_x != INT32_MAX && sectnum >= 0 && FAFcansee(x, y, z, start_sect, hit_x, hit_y, hit_z, sectnum)) + if (hit_x != INT32_MAX && sectnum >= 0 && FAFcansee(x, y, z, §or[start_sect], hit_x, hit_y, hit_z, §or[sectnum])) { HitBreakWall(&wal, INT32_MAX, INT32_MAX, INT32_MAX, ang, 0); @@ -7426,8 +7426,8 @@ int DoExpDamageTest(DSWActor* actor) // Second parameter MUST have blocking bits set or cansee won't work // added second check for FAF water - hitscans were hitting ceiling - if (!FAFcansee(wp->x, wp->y, wp->z, wp->sectnum, sp->x, sp->y, SPRITEp_UPPER(sp), sp->sectnum) && - !FAFcansee(wp->x, wp->y, wp->z, wp->sectnum, sp->x, sp->y, SPRITEp_LOWER(sp), sp->sectnum)) + if (!FAFcansee(wp->x, wp->y, wp->z, wp->sector(), sp->x, sp->y, SPRITEp_UPPER(sp), sp->sector()) && + !FAFcansee(wp->x, wp->y, wp->z, wp->sector(), sp->x, sp->y, SPRITEp_LOWER(sp), sp->sector())) continue; DoDamage(itActor, actor); @@ -7459,7 +7459,7 @@ int DoExpDamageTest(DSWActor* actor) if ((unsigned)dist > wu->Radius) continue; - if (!FAFcansee(sp->x, sp->y, SPRITEp_MID(sp), sp->sectnum, wp->x, wp->y, wp->z, wp->sectnum)) + if (!FAFcansee(sp->x, sp->y, SPRITEp_MID(sp), sp->sector(), wp->x, wp->y, wp->z, wp->sector())) continue; if (TEST(sp->extra, SPRX_BREAKABLE)) @@ -8894,7 +8894,7 @@ int DoMineRangeTest(DSWActor* actor, int range) if (dist > range) continue; - if (!FAFcansee(sp->x,sp->y,SPRITEp_UPPER(sp),sp->sectnum,wp->x,wp->y,wp->z,wp->sectnum)) + if (!FAFcansee(sp->x,sp->y,SPRITEp_UPPER(sp),sp->sector(),wp->x,wp->y,wp->z,wp->sector())) continue; return true; @@ -12543,7 +12543,7 @@ int InitSwordAttack(PLAYERp pp) { if (SpriteOverlapZ(pp->Actor(), itActor, Z(20))) { - if (FAFcansee(sp->x, sp->y, SPRITEp_MID(sp), sp->sectnum, psp->x, psp->y, SPRITEp_MID(psp), psp->sectnum)) + if (FAFcansee(sp->x, sp->y, SPRITEp_MID(sp), sp->sector(), psp->x, psp->y, SPRITEp_MID(psp), psp->sector())) DoDamage(itActor, pp->Actor()); } } @@ -12728,7 +12728,7 @@ int InitFistAttack(PLAYERp pp) { if (SpriteOverlapZ(pp->Actor(), itActor, Z(20)) || face == 190) { - if (FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,psp->x,psp->y,SPRITEp_MID(psp),psp->sectnum)) + if (FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),psp->x,psp->y,SPRITEp_MID(psp),psp->sector())) DoDamage(itActor, pp->Actor()); if (face == 190) { @@ -13029,7 +13029,7 @@ int InitSumoStompAttack(DSWActor* actor) if (dist < CLOSE_RANGE_DIST_FUDGE(tsp, sp, reach)) { - if (FAFcansee(tsp->x,tsp->y,SPRITEp_MID(tsp),tsp->sectnum,sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum)) + if (FAFcansee(tsp->x,tsp->y,SPRITEp_MID(tsp),tsp->sector(),sp->x,sp->y,SPRITEp_MID(sp),sp->sector())) DoDamage(itActor, actor); } } @@ -13058,7 +13058,7 @@ int InitMiniSumoClap(DSWActor* actor) { if (SpriteOverlapZ(actor, u->targetActor, Z(20))) { - if (FAFcansee(tsp->x, tsp->y, ActorMid(u->targetActor), tsp->sectnum, sp->x, sp->y, SPRITEp_MID(sp), sp->sectnum)) + if (FAFcansee(tsp->x, tsp->y, ActorMid(u->targetActor), tsp->sector(), sp->x, sp->y, SPRITEp_MID(sp), sp->sector())) { PlaySound(DIGI_CGTHIGHBONE, actor, v3df_follow | v3df_dontpan); DoDamage(u->targetActor, actor); @@ -13067,7 +13067,7 @@ int InitMiniSumoClap(DSWActor* actor) } else if (dist < CLOSE_RANGE_DIST_FUDGE(tsp, sp, reach)) { - if (FAFcansee(tsp->x, tsp->y, ActorMid(u->targetActor), tsp->sectnum, sp->x, sp->y, SPRITEp_MID(sp), sp->sectnum)) + if (FAFcansee(tsp->x, tsp->y, ActorMid(u->targetActor), tsp->sector(), sp->x, sp->y, SPRITEp_MID(sp), sp->sector())) { PlaySound(DIGI_30MMEXPLODE, actor, v3df_none); SpawnFireballFlames(actor, u->targetActor); @@ -14803,7 +14803,7 @@ int DoStaticFlamesDamage(DSWActor* actor) DoDamage(itActor, actor); else if (u->Radius > 200) { - if (FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sectnum,hp->x,hp->y,SPRITEp_MID(hp),hp->sectnum)) + if (FAFcansee(sp->x,sp->y,SPRITEp_MID(sp),sp->sector(),hp->x,hp->y,SPRITEp_MID(hp),hp->sector())) DoDamage(itActor, actor); } }