fast commands only for fighting / no regeneration when in "be_build" state

This commit is contained in:
Titus Tscharntke
2011-11-29 00:54:38 +00:00
parent 30972bcddb
commit 1cd6520335
2 changed files with 59 additions and 33 deletions

View File

@@ -27,7 +27,7 @@ using namespace Shared::Platform;
namespace Glest { namespace Game { namespace Glest { namespace Game {
const char *mailString = " http://bugs.megaglest.org"; const char *mailString = " http://bugs.megaglest.org";
const string glestVersionString = "v3.5.3-beta1"; const string glestVersionString = "v3.5.3-dev";
#if defined(SVNVERSION) #if defined(SVNVERSION)
const string SVN_Rev = string("Rev: ") + string(SVNVERSION); const string SVN_Rev = string("Rev: ") + string(SVNVERSION);
#elif defined(SVNVERSIONHEADER) #elif defined(SVNVERSIONHEADER)

View File

@@ -1219,12 +1219,34 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
//empty command queue //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__); 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); // bool willChangedActiveCommand = (commands.size() > 0);
if(willChangedActiveCommand && getCurrCommand()->getCommandType()->getClass() == command->getCommandType()->getClass()) { // if(willChangedActiveCommand && getCurrCommand()->getCommandType()->getClass() == command->getCommandType()->getClass()) {
willChangedActiveCommand = false; // 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(); clearCommands();
changedActiveCommand = willChangedActiveCommand; changedActiveCommand= willChangedActiveCommand;
//printf("In [%s::%s] Line: %d cleared existing commands\n",__FILE__,__FUNCTION__,__LINE__); //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()); 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,6 +2120,7 @@ void Unit::tick() {
//regenerate hp upgrade / or boost //regenerate hp upgrade / or boost
if(type->getTotalMaxHpRegeneration(&totalUpgrade) != 0) { if(type->getTotalMaxHpRegeneration(&totalUpgrade) != 0) {
if( currSkill->getClass() != scBeBuilt){
if(type->getTotalMaxHpRegeneration(&totalUpgrade) >= 0) { if(type->getTotalMaxHpRegeneration(&totalUpgrade) >= 0) {
checkItemInVault(&this->hp,this->hp); checkItemInVault(&this->hp,this->hp);
hp += type->getTotalMaxHpRegeneration(&totalUpgrade); hp += type->getTotalMaxHpRegeneration(&totalUpgrade);
@@ -2125,9 +2148,11 @@ void Unit::tick() {
} }
} }
} }
}
//regenerate hp //regenerate hp
else { else {
if(type->getHpRegeneration() >= 0) { if(type->getHpRegeneration() >= 0) {
if( currSkill->getClass() != scBeBuilt){
checkItemInVault(&this->hp,this->hp); checkItemInVault(&this->hp,this->hp);
hp += type->getHpRegeneration(); hp += type->getHpRegeneration();
@@ -2137,6 +2162,7 @@ void Unit::tick() {
addItemToVault(&this->hp,this->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(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 // If we have negative regeneration then check if the unit should die
else { else {
bool decHpResult = decHp(-type->getHpRegeneration()); bool decHpResult = decHp(-type->getHpRegeneration());