From b0f7b078f6bd1eb969d5ec841b9b9d7fa9e3cd2d Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sun, 21 Dec 2014 17:23:20 -0800 Subject: [PATCH 1/2] - apply sight upgrades when units sight is involved in cacls --- source/glest_game/type_instances/unit.cpp | 4 ++-- source/glest_game/world/unit_updater.cpp | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) 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/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); } From e65ad1b69c217168a0d2e779e87bf6aab0885e4d Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sun, 21 Dec 2014 17:32:04 -0800 Subject: [PATCH 2/2] - added more error checking in case segfault reproduced from: https://forum.megaglest.org/index.php?topic=9612.0;topicseen --- source/glest_game/world/map.cpp | 14 ++++++++++++++ 1 file changed, 14 insertions(+) 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; }