diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 646922bf..88587cf5 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -1406,7 +1406,7 @@ FowAlphaCellsLookupItem Unit::getFogOfWarRadius(bool useCache) const { } //iterate through all cells - int sightRange= this->getType()->getSight(); + int sightRange= this->getType()->getTotalSight(this->getTotalUpgrade()); int radius = sightRange + World::indirectSightRange; PosCircularIterator pci(map, this->getPosNotThreadSafe(), radius); FowAlphaCellsLookupItem result; @@ -4365,7 +4365,7 @@ uint32 Unit::getFrameCount() const { void Unit::exploreCells() { if(this->isOperative() == true) { const Vec2i &newPos = this->getCenteredPos(); - int sightRange = this->getType()->getSight(); + int sightRange = this->getType()->getTotalSight(this->getTotalUpgrade()); int teamIndex = this->getTeam(); if(game == NULL) { diff --git a/source/glest_game/world/map.cpp b/source/glest_game/world/map.cpp index 95dc8bf6..200c7db6 100644 --- a/source/glest_game/world/map.cpp +++ b/source/glest_game/world/map.cpp @@ -170,11 +170,25 @@ bool SurfaceCell::decAmount(int value) { return object->getResource()->decAmount(value); } void SurfaceCell::setExplored(int teamIndex, bool explored) { + if(teamIndex < 0 || teamIndex >= GameConstants::maxPlayers + GameConstants::specialFactions) { + char szBuf[8096]=""; + snprintf(szBuf,8096,"Invalid value for teamIndex [%d]",teamIndex); + printf("%s\n",szBuf); + throw megaglest_runtime_error(szBuf); + } + this->explored[teamIndex]= explored; //printf("Setting explored to %d for teamIndex %d\n",explored,teamIndex); } void SurfaceCell::setVisible(int teamIndex, bool visible) { + if(teamIndex < 0 || teamIndex >= GameConstants::maxPlayers + GameConstants::specialFactions) { + char szBuf[8096]=""; + snprintf(szBuf,8096,"Invalid value for teamIndex [%d]",teamIndex); + printf("%s\n",szBuf); + throw megaglest_runtime_error(szBuf); + } + this->visible[teamIndex]= visible; } diff --git a/source/glest_game/world/unit_updater.cpp b/source/glest_game/world/unit_updater.cpp index 05f13bea..63a22120 100644 --- a/source/glest_game/world/unit_updater.cpp +++ b/source/glest_game/world/unit_updater.cpp @@ -2760,7 +2760,7 @@ bool UnitUpdater::attackerOnSight(Unit *unit, Unit **rangedPtr, bool evalMode){ } bool UnitUpdater::attackableOnSight(Unit *unit, Unit **rangedPtr, const AttackSkillType *ast, bool evalMode) { - int range= unit->getType()->getSight(); + int range = unit->getType()->getTotalSight(unit->getTotalUpgrade()); return unitOnRange(unit, range, rangedPtr, ast, evalMode); }