Skip to content

Commit

Permalink
Fix invalid access to cluster 0 in AAS_AreaRouteToGoalArea()
Browse files Browse the repository at this point in the history
Newer versions of BSPC such as 2.1h included with the Quake 3 GPL source
code create AAS files containing areas in cluster 0 if the area has no
reachabilities.

The AAS files included with Quake 3 and Team Arena do not contain areas
in cluster 0. It's apparent that BSPC would not create them. Instead it
created clusters with no reachability areas.

It seems the intention was to check if the areanum and goalareanum have
reachable areas using AAS_AreaReachability(areanum) everywhere before
calling AAS_AreaRouteToGoalArea(). This prevents adding cluster 0 to
the routing cache and portal cache. However, it is not checked
everywhere and including some places in the Game VM.

Fix AAS_AreaRouteToGoalArea() instead of trying to wack-a-mole with all
the places that call it.

Cluster 0 access reported by Thomas Köppe (github @tkoeppe) as causing
crashes in rare cases.
  • Loading branch information
zturtleman committed Feb 4, 2018
1 parent 0822772 commit fc16ac6
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion code/botlib/be_aas_route.c
Expand Up @@ -1603,7 +1603,7 @@ int AAS_AreaRouteToGoalArea(int areanum, vec3_t origin, int goalareanum, int tra
*reachnum = 0;
return qtrue;
}
//
//check !AAS_AreaReachability(areanum) with custom developer-only debug message
if (areanum <= 0 || areanum >= aasworld.numareas)
{
if (botDeveloper)
Expand All @@ -1620,6 +1620,10 @@ int AAS_AreaRouteToGoalArea(int areanum, vec3_t origin, int goalareanum, int tra
} //end if
return qfalse;
} //end if
if (!aasworld.areasettings[areanum].numreachableareas || !aasworld.areasettings[goalareanum].numreachableareas)
{
return qfalse;
} //end if
// make sure the routing cache doesn't grow to large
while(AvailableMemory() < 1 * 1024 * 1024) {
if (!AAS_FreeOldestCache()) break;
Expand Down

0 comments on commit fc16ac6

Please sign in to comment.