mirror of
https://github.com/s1lentq/ReGameDLL_CS.git
synced 2024-12-28 15:45:41 +03:00
IsWalkableTraceLineClear: Fixed deadlock (mutual collisions in traces leading to hang)
This commit is contained in:
parent
5d2174fbbf
commit
92775824e6
@ -388,15 +388,21 @@ inline bool IsWalkableTraceLineClear(Vector &from, Vector &to, unsigned int flag
|
|||||||
{
|
{
|
||||||
TraceResult result;
|
TraceResult result;
|
||||||
edict_t *pEntIgnore = nullptr;
|
edict_t *pEntIgnore = nullptr;
|
||||||
|
edict_t *pEntPrev = nullptr;
|
||||||
Vector useFrom = from;
|
Vector useFrom = from;
|
||||||
|
|
||||||
while (true)
|
const int maxTries = 50;
|
||||||
|
for (int t = 0; t < maxTries; ++t)
|
||||||
{
|
{
|
||||||
UTIL_TraceLine(useFrom, to, ignore_monsters, pEntIgnore, &result);
|
UTIL_TraceLine(useFrom, to, ignore_monsters, pEntIgnore, &result);
|
||||||
|
|
||||||
// if we hit a walkable entity, try again
|
// if we hit a walkable entity, try again
|
||||||
if (result.flFraction != 1.0f && (result.pHit && IsEntityWalkable(VARS(result.pHit), flags)))
|
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;
|
pEntIgnore = result.pHit;
|
||||||
|
|
||||||
// start from just beyond where we hit to avoid infinite loops
|
// start from just beyond where we hit to avoid infinite loops
|
||||||
|
Loading…
Reference in New Issue
Block a user