From 86743e27186ab5068bef3d0b0e5bdb964cdf8cbc Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Sat, 25 Jun 2011 14:18:53 +0000 Subject: [PATCH] - more bugfixes for attack-boost check (and now in debug mode if unit selected show his attack-boost radius as well as the units affected) --- source/glest_game/graphics/renderer.cpp | 21 +++++++++++++++++++++ source/glest_game/type_instances/unit.cpp | 16 +++++++++++++--- source/glest_game/type_instances/unit.h | 2 ++ 3 files changed, 36 insertions(+), 3 deletions(-) diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index ee6e39c3..b279ebb6 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -3109,6 +3109,27 @@ void Renderer::renderSelectionEffects() { glColor4f(unit->getEpRatio()/2.f, unit->getEpRatio(), unit->getEpRatio(), 0.5f); renderSelectionCircle(currVec, unit->getType()->getSize(), magicCircleRadius); } + + // Render Attack-boost circles + if(showDebugUI == true) { + const std::pair > ¤tAttackBoostUnits = unit->getCurrentAttackBoostUnits(); + + if(currentAttackBoostUnits.first->isAttackBoostEnabled() == true) { + glColor4f(MAGENTA.x,MAGENTA.y,MAGENTA.z,MAGENTA.w); + renderSelectionCircle(currVec, unit->getType()->getSize(), currentAttackBoostUnits.first->getAttackBoost()->radius); + + for(unsigned int i = 0; i < currentAttackBoostUnits.second.size(); ++i) { + // Remove attack boost upgrades from unit + Unit *affectedUnit = currentAttackBoostUnits.second[i]; + + Vec3f currVecBoost = affectedUnit->getCurrVectorFlat(); + currVecBoost.y += 0.3f; + + renderSelectionCircle(currVecBoost, affectedUnit->getType()->getSize(), 1.f); + } + } + } + } if(selectedResourceObject!=NULL) { diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index dce0a6b3..418948e2 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -1018,6 +1018,18 @@ void Unit::kill() { void Unit::undertake() { if(SystemFlags::getSystemSettingType(SystemFlags::debugSystem).enabled) SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d] about to undertake unit id = %d [%s] [%s]\n",__FILE__,__FUNCTION__,__LINE__,this->id, this->getFullName().c_str(),this->getDesc().c_str()); + // Remove any units that were previously in attack-boost range + if(currentAttackBoostUnits.second.size() > 0) { + for(unsigned int i = 0; i < currentAttackBoostUnits.second.size(); ++i) { + // Remove attack boost upgrades from unit + Unit *affectedUnit = currentAttackBoostUnits.second[i]; + affectedUnit->deapplyAttackBoost(currentAttackBoostUnits.first->getAttackBoost(), this); + + //printf("!!!! DE-APPLY ATTACK BOOST from unit [%s - %d]\n",affectedUnit->getType()->getName().c_str(),affectedUnit->getId()); + } + currentAttackBoostUnits.second.clear(); + } + UnitUpdater *unitUpdater = game->getWorld()->getUnitUpdater(); //unitUpdater->clearUnitPrecache(this); unitUpdater->removeUnitPrecache(this); @@ -1233,8 +1245,7 @@ bool Unit::update() { } } - //if(currSkill != currentAttackBoostUnits.first) { - // First remove any units that were previosuly in range + // Remove any units that were previously in range if(currentAttackBoostUnits.second.size() > 0) { for(unsigned int i = 0; i < currentAttackBoostUnits.second.size(); ++i) { // Remove attack boost upgrades from unit @@ -1245,7 +1256,6 @@ bool Unit::update() { } currentAttackBoostUnits.second.clear(); } - //} currentAttackBoostUnits.first = currSkill; if(currSkill->isAttackBoostEnabled() == true) { diff --git a/source/glest_game/type_instances/unit.h b/source/glest_game/type_instances/unit.h index ec75a213..8997f274 100644 --- a/source/glest_game/type_instances/unit.h +++ b/source/glest_game/type_instances/unit.h @@ -352,6 +352,8 @@ public: static void setGame(Game *value) { game=value;} + const std::pair > & getCurrentAttackBoostUnits() const { return currentAttackBoostUnits; } + //queries void setIgnoreCheckCommand(bool value) { ignoreCheckCommand=value;} bool getIgnoreCheckCommand() const {return ignoreCheckCommand;}