- bugfix for enemy cell segfault for AI players

This commit is contained in:
Mark Vejvoda 2011-05-01 15:22:58 +00:00
parent 4486b4d5c3
commit 5d1f75ebe6
1 changed files with 14 additions and 11 deletions

View File

@ -2033,6 +2033,8 @@ void UnitUpdater::findEnemiesForCell(const Vec2i pos, int size, int sightRange,
for(int i = pos.x - sightRange; i < pos.x + size + sightRange; ++i) {
for(int j = pos.y - sightRange; j < pos.y + size + sightRange; ++j) {
Vec2i testPos(i,j);
if( map->isInside(testPos) &&
map->isInsideSurface(map->toSurfCoords(testPos))) {
Cell *cell = map->getCell(testPos);
//check field
Unit *possibleEnemy = cell->getUnit(f);
@ -2054,6 +2056,7 @@ void UnitUpdater::findEnemiesForCell(const Vec2i pos, int size, int sightRange,
}
}
}
}
//if the unit has any enemy on range
bool UnitUpdater::unitOnRange(const Unit *unit, int range, Unit **rangedPtr,