IsoRTS
IsoRTS copied to clipboard
Potential crash in simpleAI.cpp
The last return statement in the implementation of "int distanceToResource(int, cords)," currently line 135, has the potential to crash as it may dereference the front() of an empty list.
int distanceToResource(int kind, cords from)
{
std::list <nearestBuildingTile> listOfResourceLocations;
if (!listOfObjects.empty()) { ... }
if (!listOfResourceLocations.empty()) { ... }
return listOfResourceLocations.front().deltaDistance;
//Crash here if both of the above if statements are false since listOfResourceLocations is empty
}
Thanks for catching that. I made it return a really long distance until a add code to make the AI deal with a resource which is unavailble. For now it should not matter for placing buildings. All the spots will have the same 'penalty' of 9999