mirror of
https://github.com/ZDoom/qzdoom.git
synced 2024-11-28 06:53:58 +00:00
Fixed P_LookForPlayers scanning redundancies
- Players could be scanned multiple times, repeating expensive tests - Players could be skipped completely and become invisible as a result
This commit is contained in:
parent
4270838613
commit
d855bd66b3
1 changed files with 11 additions and 10 deletions
|
@ -1542,7 +1542,6 @@ bool P_LookForEnemies (AActor *actor, INTBOOL allaround, FLookExParams *params)
|
||||||
bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params)
|
bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params)
|
||||||
{
|
{
|
||||||
int c;
|
int c;
|
||||||
int stop;
|
|
||||||
int pnum;
|
int pnum;
|
||||||
player_t* player;
|
player_t* player;
|
||||||
bool chasegoal = params? (!(params->flags & LOF_DONTCHASEGOAL)) : true;
|
bool chasegoal = params? (!(params->flags & LOF_DONTCHASEGOAL)) : true;
|
||||||
|
@ -1615,20 +1614,22 @@ bool P_LookForPlayers (AActor *actor, INTBOOL allaround, FLookExParams *params)
|
||||||
{
|
{
|
||||||
pnum = actor->LastLookPlayerNumber;
|
pnum = actor->LastLookPlayerNumber;
|
||||||
}
|
}
|
||||||
stop = (pnum - 1) & (MAXPLAYERS-1);
|
|
||||||
|
|
||||||
for (;;)
|
for (;;)
|
||||||
{
|
{
|
||||||
pnum = (pnum + 1) & (MAXPLAYERS-1);
|
// [ED850] Each and every player should only ever be checked once.
|
||||||
if (!playeringame[pnum])
|
if (c++ < MAXPLAYERS)
|
||||||
continue;
|
|
||||||
|
|
||||||
if (actor->TIDtoHate == 0)
|
|
||||||
{
|
{
|
||||||
actor->LastLookPlayerNumber = pnum;
|
pnum = (pnum + 1) & (MAXPLAYERS - 1);
|
||||||
}
|
if (!playeringame[pnum])
|
||||||
|
continue;
|
||||||
|
|
||||||
if (++c == MAXPLAYERS-1 || pnum == stop)
|
if (actor->TIDtoHate == 0)
|
||||||
|
{
|
||||||
|
actor->LastLookPlayerNumber = pnum;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
{
|
{
|
||||||
// done looking
|
// done looking
|
||||||
if (actor->target == NULL)
|
if (actor->target == NULL)
|
||||||
|
|
Loading…
Reference in a new issue