Skip to content

Commit

Permalink
Merge branch 'master'
Browse files Browse the repository at this point in the history
  • Loading branch information
Vaqtincha committed Mar 5, 2024
2 parents 6feae65 + 9277582 commit 8c8e8ed
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion regamedll/game_shared/bot/nav.h
Original file line number Diff line number Diff line change
Expand Up @@ -388,15 +388,21 @@ inline bool IsWalkableTraceLineClear(Vector &from, Vector &to, unsigned int flag
{
TraceResult result;
edict_t *pEntIgnore = nullptr;
edict_t *pEntPrev = nullptr;
Vector useFrom = from;

while (true)
const int maxTries = 50;
for (int t = 0; t < maxTries; ++t)
{
UTIL_TraceLine(useFrom, to, ignore_monsters, pEntIgnore, &result);

// if we hit a walkable entity, try again
if (result.flFraction != 1.0f && (result.pHit && IsEntityWalkable(VARS(result.pHit), flags)))
{
if (result.pHit == pEntPrev)
return false; // deadlock, give up

pEntPrev = pEntIgnore;
pEntIgnore = result.pHit;

// start from just beyond where we hit to avoid infinite loops
Expand Down

0 comments on commit 8c8e8ed

Please sign in to comment.