1
0
mirror of https://github.com/vcmi/vcmi.git synced 2024-11-28 08:48:48 +02:00

Merge pull request #3849 from IvanSavenko/fix_vcai_crash

Fix possible crash on AI attempting to build building in town
This commit is contained in:
Ivan Savenko 2024-04-28 19:48:23 +03:00 committed by GitHub
commit be54836401
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -35,12 +35,12 @@ TSubgoal BuildThis::whatToDoToAchieve()
if(!town) if(!town)
{ {
for(const CGTownInstance * t : cb->getTownsInfo()) for(const CGTownInstance * candidateTown : cb->getTownsInfo())
{ {
switch(cb->canBuildStructure(town, b)) switch(cb->canBuildStructure(candidateTown, b))
{ {
case EBuildingState::ALLOWED: case EBuildingState::ALLOWED:
town = t; town = candidateTown;
break; //TODO: look for prerequisites? this is not our reponsibility break; //TODO: look for prerequisites? this is not our reponsibility
default: default:
continue; continue;