From f97f0ef8523f7cfcd1e8ef9ca41aea2bda9fb369 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Sun, 21 Dec 2014 21:07:24 -0800 Subject: [PATCH] - more general bugfixes (not all upgrade values were being used in the code) --- source/glest_game/graphics/renderer.cpp | 2 +- source/glest_game/menu/menu_state_connected_game.cpp | 1 - source/glest_game/menu/menu_state_custom_game.cpp | 1 - source/glest_game/type_instances/faction.cpp | 2 +- source/glest_game/type_instances/unit.cpp | 10 +++++----- source/glest_game/types/upgrade_type.cpp | 2 +- 6 files changed, 8 insertions(+), 10 deletions(-) diff --git a/source/glest_game/graphics/renderer.cpp b/source/glest_game/graphics/renderer.cpp index 3b586f87f..fcbdde173 100644 --- a/source/glest_game/graphics/renderer.cpp +++ b/source/glest_game/graphics/renderer.cpp @@ -8425,7 +8425,7 @@ void Renderer::renderHealthBar(Vec3f v, Unit *unit, float height, bool lineBorde int barCount=0; float hp=unit->getHpRatio(); float ep=-1.f; - if(unit->getType()->getMaxEp()!=0){ + if(unit->getType()->getTotalMaxEp(unit->getTotalUpgrade()) !=0 ) { ep=unit->getEpRatio(); numberOfBars++; } diff --git a/source/glest_game/menu/menu_state_connected_game.cpp b/source/glest_game/menu/menu_state_connected_game.cpp index dca77a737..7325c4c23 100644 --- a/source/glest_game/menu/menu_state_connected_game.cpp +++ b/source/glest_game/menu/menu_state_connected_game.cpp @@ -482,7 +482,6 @@ MenuStateConnectedGame::MenuStateConnectedGame(Program *program, MainMenu *mainM buttonPlayNow.init(buttonx, buttony, 125); buttonPlayNow.setText(lang.getString("PlayNow")); buttonPlayNow.setVisible(false); - buttonx+=130; // write hint to console: diff --git a/source/glest_game/menu/menu_state_custom_game.cpp b/source/glest_game/menu/menu_state_custom_game.cpp index a937f89c6..7a35b1165 100644 --- a/source/glest_game/menu/menu_state_custom_game.cpp +++ b/source/glest_game/menu/menu_state_custom_game.cpp @@ -221,7 +221,6 @@ MenuStateCustomGame::MenuStateCustomGame(Program *program, MainMenu *mainMenu, buttonPlayNow.registerGraphicComponent(containerName,"buttonPlayNow"); buttonPlayNow.init(buttonx, buttony, 125); - buttonx+=130; labelLocalGameVersion.registerGraphicComponent(containerName,"labelLocalGameVersion"); labelLocalGameVersion.init(10, networkHeadPos+labelOffset); diff --git a/source/glest_game/type_instances/faction.cpp b/source/glest_game/type_instances/faction.cpp index 93a56885f..7f95d31ad 100644 --- a/source/glest_game/type_instances/faction.cpp +++ b/source/glest_game/type_instances/faction.cpp @@ -1220,7 +1220,7 @@ void Faction::applyCostsOnInterval(const ResourceType *rtApply) { //decrease unit hp if(scriptManager->getPlayerModifiers(this->index)->getConsumeEnabled() == true) { - bool decHpResult = unit->decHp(unit->getType()->getMaxHp() / 3); + bool decHpResult = unit->decHp(unit->getType()->getTotalMaxHp(unit->getTotalUpgrade()) / 3); if(decHpResult) { unit->setCauseOfDeath(ucodStarvedResource); world->getStats()->die(unit->getFactionIndex(),unit->getType()->getCountUnitDeathInStats()); diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 88587cf55..cb8a20b0c 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -1050,7 +1050,7 @@ float Unit::getEpRatio() const { throw megaglest_runtime_error(szBuf); } - if(type->getMaxHp() == 0) { + if(type->getTotalMaxHp(&totalUpgrade) == 0) { return 0.f; } else { @@ -3199,11 +3199,11 @@ void Unit::tick() { } //regenerate hp else { - if(type->getHpRegeneration() >= 0) { + if(type->getTotalMaxHpRegeneration(&totalUpgrade) >= 0) { if( currSkill->getClass() != scBeBuilt){ checkItemInVault(&this->hp,this->hp); int original_hp = this->hp; - this->hp += type->getHpRegeneration(); + this->hp += type->getTotalMaxHpRegeneration(&totalUpgrade); if(this->hp > type->getTotalMaxHp(&totalUpgrade)) { this->hp = type->getTotalMaxHp(&totalUpgrade); } @@ -3220,7 +3220,7 @@ void Unit::tick() { } // If we have negative regeneration then check if the unit should die else { - bool decHpResult = decHp(-type->getHpRegeneration()); + bool decHpResult = decHp(-type->getTotalMaxHpRegeneration(&totalUpgrade)); if(decHpResult) { this->setCauseOfDeath(ucodStarvedRegeneration); @@ -4262,7 +4262,7 @@ void Unit::checkCustomizedParticleTriggers(bool force) { } void Unit::startDamageParticles() { - if(hp < type->getMaxHp() / 2 && hp > 0 && alive == true) { + if(hp < type->getTotalMaxHp(&totalUpgrade) / 2 && hp > 0 && alive == true) { //start additional particles if( showUnitParticles && type->damageParticleSystemTypes.empty() == false ) { diff --git a/source/glest_game/types/upgrade_type.cpp b/source/glest_game/types/upgrade_type.cpp index 44376c721..24da5fbf5 100644 --- a/source/glest_game/types/upgrade_type.cpp +++ b/source/glest_game/types/upgrade_type.cpp @@ -1463,7 +1463,7 @@ void TotalUpgrade::deapply(int sourceUnitId, const UpgradeTypeBase *ut,int destU sourceUnitId,destUnitId,ut->toString().c_str()); for(unsigned int index = 0; index < boostUpgrades.size(); ++index) { TotalUpgrade *boost = boostUpgrades[index]; - printf("\nBoost #%d\n%s\n",index,boost->toString().c_str()); + printf("\nBoost #%u\n%s\n",index,boost->toString().c_str()); } } }