From 1cd6520335a01c762b1315b63cac8130b6d854f6 Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Tue, 29 Nov 2011 00:54:38 +0000 Subject: [PATCH] fast commands only for fighting / no regeneration when in "be_build" state --- source/glest_game/facilities/game_util.cpp | 2 +- source/glest_game/type_instances/unit.cpp | 90 ++++++++++++++-------- 2 files changed, 59 insertions(+), 33 deletions(-) diff --git a/source/glest_game/facilities/game_util.cpp b/source/glest_game/facilities/game_util.cpp index 3ac83ba6..3cd52d18 100644 --- a/source/glest_game/facilities/game_util.cpp +++ b/source/glest_game/facilities/game_util.cpp @@ -27,7 +27,7 @@ using namespace Shared::Platform; namespace Glest { namespace Game { const char *mailString = " http://bugs.megaglest.org"; -const string glestVersionString = "v3.5.3-beta1"; +const string glestVersionString = "v3.5.3-dev"; #if defined(SVNVERSION) const string SVN_Rev = string("Rev: ") + string(SVNVERSION); #elif defined(SVNVERSIONHEADER) diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index f9344536..d76840de 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -1219,12 +1219,34 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) { //empty command queue if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Clear commands because current is NOT queable.\n",__FILE__,__FUNCTION__,__LINE__); - bool willChangedActiveCommand = (commands.size() > 0); - if(willChangedActiveCommand && getCurrCommand()->getCommandType()->getClass() == command->getCommandType()->getClass()) { - willChangedActiveCommand = false; +// bool willChangedActiveCommand = (commands.size() > 0); +// if(willChangedActiveCommand && getCurrCommand()->getCommandType()->getClass() == command->getCommandType()->getClass()) { +// willChangedActiveCommand = false; +// } +// clearCommands(); +// changedActiveCommand = willChangedActiveCommand; + + bool willChangedActiveCommand= (commands.size() > 0); + if(willChangedActiveCommand){ + CommandClass currCommandClass=getCurrCommand()->getCommandType()->getClass(); + CommandClass commandClass=command->getCommandType()->getClass(); + if(currCommandClass + == commandClass){ + willChangedActiveCommand= false; + } + else if(currCommandClass==ccAttack || currCommandClass==ccAttackStopped || + commandClass==ccAttack || commandClass==ccAttackStopped){ + willChangedActiveCommand= true; + } + else{ + willChangedActiveCommand= false; + } } clearCommands(); - changedActiveCommand = willChangedActiveCommand; + changedActiveCommand= willChangedActiveCommand; + + + //printf("In [%s::%s] Line: %d cleared existing commands\n",__FILE__,__FUNCTION__,__LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugPerformance).enabled && chrono.getMillis() > 0) SystemFlags::OutputDebug(SystemFlags::debugPerformance,"In [%s::%s] Line: %d took msecs: %lld\n",__FILE__,__FUNCTION__,__LINE__,chrono.getMillis()); @@ -2098,44 +2120,48 @@ void Unit::tick() { //regenerate hp upgrade / or boost if(type->getTotalMaxHpRegeneration(&totalUpgrade) != 0) { - if(type->getTotalMaxHpRegeneration(&totalUpgrade) >= 0) { - checkItemInVault(&this->hp,this->hp); - hp += type->getTotalMaxHpRegeneration(&totalUpgrade); - if(hp > type->getTotalMaxHp(&totalUpgrade)) { - hp = type->getTotalMaxHp(&totalUpgrade); - } - addItemToVault(&this->hp,this->hp); + if( currSkill->getClass() != scBeBuilt){ + if(type->getTotalMaxHpRegeneration(&totalUpgrade) >= 0) { + checkItemInVault(&this->hp,this->hp); + hp += type->getTotalMaxHpRegeneration(&totalUpgrade); + if(hp > type->getTotalMaxHp(&totalUpgrade)) { + hp = type->getTotalMaxHp(&totalUpgrade); + } + addItemToVault(&this->hp,this->hp); - //if(this->getType()->getName() == "spearman") printf("tick hp#2 [type->getTotalMaxHpRegeneration(&totalUpgrade)] = %d type->getTotalMaxHp(&totalUpgrade) [%d] newhp = %d\n",type->getTotalMaxHpRegeneration(&totalUpgrade),type->getTotalMaxHp(&totalUpgrade),hp); - } - // If we have negative regeneration then check if the unit should die - else { - bool decHpResult = decHp(-type->getTotalMaxHpRegeneration(&totalUpgrade)); - if(decHpResult) { - this->setCauseOfDeath(ucodStarvedRegeneration); - - Unit::game->getWorld()->getStats()->die(getFactionIndex()); - game->getScriptManager()->onUnitDied(this); + //if(this->getType()->getName() == "spearman") printf("tick hp#2 [type->getTotalMaxHpRegeneration(&totalUpgrade)] = %d type->getTotalMaxHp(&totalUpgrade) [%d] newhp = %d\n",type->getTotalMaxHpRegeneration(&totalUpgrade),type->getTotalMaxHp(&totalUpgrade),hp); } - StaticSound *sound= this->getType()->getFirstStOfClass(scDie)->getSound(); - if(sound != NULL && - (this->getFactionIndex() == Unit::game->getWorld()->getThisFactionIndex() || - (game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true))) { - SoundRenderer::getInstance().playFx(sound); + // If we have negative regeneration then check if the unit should die + else { + bool decHpResult = decHp(-type->getTotalMaxHpRegeneration(&totalUpgrade)); + if(decHpResult) { + this->setCauseOfDeath(ucodStarvedRegeneration); + + Unit::game->getWorld()->getStats()->die(getFactionIndex()); + game->getScriptManager()->onUnitDied(this); + } + StaticSound *sound= this->getType()->getFirstStOfClass(scDie)->getSound(); + if(sound != NULL && + (this->getFactionIndex() == Unit::game->getWorld()->getThisFactionIndex() || + (game->getWorld()->showWorldForPlayer(game->getWorld()->getThisTeamIndex()) == true))) { + SoundRenderer::getInstance().playFx(sound); + } } } } //regenerate hp else { if(type->getHpRegeneration() >= 0) { - checkItemInVault(&this->hp,this->hp); + if( currSkill->getClass() != scBeBuilt){ + checkItemInVault(&this->hp,this->hp); - hp += type->getHpRegeneration(); - if(hp > type->getTotalMaxHp(&totalUpgrade)) { - hp = type->getTotalMaxHp(&totalUpgrade); + hp += type->getHpRegeneration(); + if(hp > type->getTotalMaxHp(&totalUpgrade)) { + hp = type->getTotalMaxHp(&totalUpgrade); + } + addItemToVault(&this->hp,this->hp); + //if(this->getType()->getName() == "spearman") printf("tick hp#1 [type->getHpRegeneration()] = %d type->getTotalMaxHp(&totalUpgrade) [%d] newhp = %d\n",type->getHpRegeneration(),type->getTotalMaxHp(&totalUpgrade),hp); } - addItemToVault(&this->hp,this->hp); - //if(this->getType()->getName() == "spearman") printf("tick hp#1 [type->getHpRegeneration()] = %d type->getTotalMaxHp(&totalUpgrade) [%d] newhp = %d\n",type->getHpRegeneration(),type->getTotalMaxHp(&totalUpgrade),hp); } // If we have negative regeneration then check if the unit should die else {