Fix potential game freeze from infinite while-loop in GetGroundHeight #963
+8
−0
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
This PR fixes a potential infinite loop in
CNavMesh::GetGroundHeight()
by adding an early out if the position input is NaN.The place that I noticed this being an issue is the TF2 Sentry Buster's mission behavior, which will input a vector of all NaNs if it doesn't have a mission target set.
I don't believe this can happen under normal circumstances currently, but if the
SetMission()
vscript function gets fixed then users who forget or simply don't know that they need to set a mission target first will find that their game will freeze, not crash, due to it getting stuck attempting to trace a line to the ground from NaN to NaN over and over again.Technically superseded by #972, which fixes the bug in the sentry buster code rather than the NavMesh code
This probably could be fixed within the Sentry Buster's behavior too (CTFBotMissionSuicideBomber::Update()
, specifically the lineif ( m_path.Compute( me, m_lastKnownVictimPosition, cost ) == false )
), especially since if a the path compute check fails 3 times the Sentry Buster starts its detonation, but I decided to go for the change in the NavMesh code in case other parts of the code may cause the same issue when used via vscript or sourcemods in ways not originally intended by the developers over a decade ago.