fixed command transition choppiness
This commit is contained in:
parent
fdb2b65bf7
commit
b08516e7de
|
@ -399,6 +399,7 @@ Unit::~Unit() {
|
||||||
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
static string mutexOwnerId = string(__FILE__) + string("_") + intToStr(__LINE__);
|
||||||
MutexSafeWrapper safeMutex(&mutexCommands,mutexOwnerId);
|
MutexSafeWrapper safeMutex(&mutexCommands,mutexOwnerId);
|
||||||
|
|
||||||
|
changedActiveCommand = false;
|
||||||
while(commands.empty() == false) {
|
while(commands.empty() == false) {
|
||||||
delete commands.back();
|
delete commands.back();
|
||||||
commands.pop_back();
|
commands.pop_back();
|
||||||
|
@ -1191,8 +1192,9 @@ 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__);
|
||||||
|
|
||||||
changedActiveCommand = (commands.size() > 0);
|
bool willChangedActiveCommand = (commands.size() > 0);
|
||||||
clearCommands();
|
clearCommands();
|
||||||
|
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());
|
||||||
|
@ -1240,6 +1242,7 @@ CommandResult Unit::finishCommand() {
|
||||||
//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;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1249,6 +1252,7 @@ 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);
|
||||||
|
|
||||||
|
@ -1290,6 +1294,7 @@ CommandResult Unit::cancelCommand() {
|
||||||
|
|
||||||
delete commands.back();
|
delete commands.back();
|
||||||
commands.pop_back();
|
commands.pop_back();
|
||||||
|
changedActiveCommand = false;
|
||||||
|
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
|
|
||||||
|
@ -1458,6 +1463,11 @@ bool Unit::needToUpdate() {
|
||||||
//speed
|
//speed
|
||||||
int speed = currSkill->getTotalSpeed(&totalUpgrade);
|
int speed = currSkill->getTotalSpeed(&totalUpgrade);
|
||||||
|
|
||||||
|
if(changedActiveCommand) {
|
||||||
|
speed = 325;
|
||||||
|
//return_value = true;
|
||||||
|
}
|
||||||
|
|
||||||
//speed modifier
|
//speed modifier
|
||||||
float diagonalFactor= 1.f;
|
float diagonalFactor= 1.f;
|
||||||
float heightFactor= 1.f;
|
float heightFactor= 1.f;
|
||||||
|
@ -1550,6 +1560,11 @@ bool Unit::update() {
|
||||||
//speed
|
//speed
|
||||||
int speed= currSkill->getTotalSpeed(&totalUpgrade);
|
int speed= currSkill->getTotalSpeed(&totalUpgrade);
|
||||||
|
|
||||||
|
if(changedActiveCommand) {
|
||||||
|
speed = 325;
|
||||||
|
//return_value = true;
|
||||||
|
}
|
||||||
|
|
||||||
//speed modifier
|
//speed modifier
|
||||||
float diagonalFactor = 1.f;
|
float diagonalFactor = 1.f;
|
||||||
float heightFactor = 1.f;
|
float heightFactor = 1.f;
|
||||||
|
@ -1812,15 +1827,6 @@ bool Unit::update() {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(changedActiveCommand) {
|
|
||||||
changedActiveCommand = false;
|
|
||||||
highlight = 0.0f;
|
|
||||||
lastAnimProgress = 0.0f;
|
|
||||||
animProgress = 0.0f;
|
|
||||||
progress = 0.0f;
|
|
||||||
return_value = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
return return_value;
|
return return_value;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2489,6 +2495,7 @@ void Unit::clearCommands() {
|
||||||
|
|
||||||
safeMutex.ReleaseLock();
|
safeMutex.ReleaseLock();
|
||||||
}
|
}
|
||||||
|
changedActiveCommand = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Unit::deleteQueuedCommand(Command *command) {
|
void Unit::deleteQueuedCommand(Command *command) {
|
||||||
|
|
Loading…
Reference in New Issue