From 076719e6a409a64f71b21c1cecb882cd38f0aded Mon Sep 17 00:00:00 2001 From: MonsterIestyn Date: Wed, 18 Feb 2015 18:59:52 +0000 Subject: [PATCH] P_CheckSight should ideally be called AFTER most other things in things like P_LookForPlayers at least git-svn-id: https://code.orospakr.ca/svn/srb2/trunk@9043 6de4a73c-47e2-0310-b8c1-93d6ecd3f8cd --- src/p_enemy.c | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/src/p_enemy.c b/src/p_enemy.c index 2a8ab5bb..ee244d3c 100644 --- a/src/p_enemy.c +++ b/src/p_enemy.c @@ -363,12 +363,12 @@ boolean P_CheckMissileRange(mobj_t *actor) if (!actor->target) return false; - if (!P_CheckSight(actor, actor->target)) - return false; - if (actor->reactiontime) return false; // do not attack yet + if (!P_CheckSight(actor, actor->target)) + return false; + // OPTIMIZE: get this from a global checksight dist = P_AproxDistance(actor->x-actor->target->x, actor->y-actor->target->y) - FixedMul(64*FRACUNIT, actor->scale); @@ -652,6 +652,9 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed player = &players[actor->lastlook]; + if ((netgame || multiplayer) && player->spectator) + continue; + if (player->health <= 0) continue; // dead @@ -661,12 +664,6 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed if (!player->mo || P_MobjWasRemoved(player->mo)) continue; - if (!P_CheckSight(actor, player->mo)) - continue; // out of sight - - if ((netgame || multiplayer) && player->spectator) - continue; - if (dist > 0 && P_AproxDistance(P_AproxDistance(player->mo->x - actor->x, player->mo->y - actor->y), player->mo->z - actor->z) > dist) continue; // Too far away @@ -683,6 +680,9 @@ boolean P_LookForPlayers(mobj_t *actor, boolean allaround, boolean tracer, fixed } } + if (!P_CheckSight(actor, player->mo)) + continue; // out of sight + if (tracer) P_SetTarget(&actor->tracer, player->mo); else