bugfix for command transition not properly resetting status

This commit is contained in:
Mark Vejvoda 2011-10-28 04:37:10 +00:00
parent 4223567f2b
commit 64eeba93cb
1 changed files with 7 additions and 7 deletions

View File

@ -823,6 +823,7 @@ void Unit::setCurrSkill(const SkillType *currSkill) {
throw runtime_error(szBuf); throw runtime_error(szBuf);
} }
changedActiveCommand = false;
if(currSkill->getClass() != this->currSkill->getClass() || if(currSkill->getClass() != this->currSkill->getClass() ||
currSkill->getName() != this->currSkill->getName()) { currSkill->getName() != this->currSkill->getName()) {
animProgress= 0; animProgress= 0;
@ -1197,6 +1198,9 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
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()) {
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__);
@ -1231,6 +1235,7 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
} }
else { else {
delete command; delete command;
changedActiveCommand = false;
} }
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());
@ -1240,13 +1245,12 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
//pop front (used when order is done) //pop front (used when order is done)
CommandResult Unit::finishCommand() { CommandResult Unit::finishCommand() {
changedActiveCommand = false;
retryCurrCommandCount=0; retryCurrCommandCount=0;
this->setCurrentUnitTitle(""); this->setCurrentUnitTitle("");
//is empty? //is empty?
if(commands.empty()) { if(commands.empty()) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__); if(SystemFlags::getSystemSettingType(SystemFlags::debugLUA).enabled) SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__, __LINE__);
changedActiveCommand = false;
return crFailUndefined; return crFailUndefined;
} }
@ -1256,7 +1260,6 @@ CommandResult Unit::finishCommand() {
delete commands.front(); delete commands.front();
commands.erase(commands.begin()); commands.erase(commands.begin());
changedActiveCommand = false;
safeMutex.ReleaseLock(true); safeMutex.ReleaseLock(true);
@ -1279,7 +1282,7 @@ CommandResult Unit::finishCommand() {
//to cancel a command //to cancel a command
CommandResult Unit::cancelCommand() { CommandResult Unit::cancelCommand() {
changedActiveCommand = false;
retryCurrCommandCount=0; retryCurrCommandCount=0;
this->setCurrentUnitTitle(""); this->setCurrentUnitTitle("");
@ -1298,7 +1301,6 @@ CommandResult Unit::cancelCommand() {
delete commands.back(); delete commands.back();
commands.pop_back(); commands.pop_back();
changedActiveCommand = false;
safeMutex.ReleaseLock(); safeMutex.ReleaseLock();
@ -1469,7 +1471,6 @@ bool Unit::needToUpdate() {
if(changedActiveCommand) { if(changedActiveCommand) {
speed = CHANGE_COMMAND_SPEED; speed = CHANGE_COMMAND_SPEED;
//return_value = true;
} }
//speed modifier //speed modifier
@ -1566,7 +1567,6 @@ bool Unit::update() {
if(changedActiveCommand) { if(changedActiveCommand) {
speed = CHANGE_COMMAND_SPEED; speed = CHANGE_COMMAND_SPEED;
//return_value = true;
} }
//speed modifier //speed modifier