Fix invalid access to cluster 0 in AAS_AreaRouteToGoalArea()

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.
This commit is contained in:
Zack Middleton 2018-02-04 09:07:44 -06:00
parent 0822772ea2
commit fc16ac6bd2

View file

@ -1603,7 +1603,7 @@ int AAS_AreaRouteToGoalArea(int areanum, vec3_t origin, int goalareanum, int tra
*reachnum = 0; *reachnum = 0;
return qtrue; return qtrue;
} }
// //check !AAS_AreaReachability(areanum) with custom developer-only debug message
if (areanum <= 0 || areanum >= aasworld.numareas) if (areanum <= 0 || areanum >= aasworld.numareas)
{ {
if (botDeveloper) if (botDeveloper)
@ -1620,6 +1620,10 @@ int AAS_AreaRouteToGoalArea(int areanum, vec3_t origin, int goalareanum, int tra
} //end if } //end if
return qfalse; return qfalse;
} //end if } //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 // make sure the routing cache doesn't grow to large
while(AvailableMemory() < 1 * 1024 * 1024) { while(AvailableMemory() < 1 * 1024 * 1024) {
if (!AAS_FreeOldestCache()) break; if (!AAS_FreeOldestCache()) break;