produce commands are not ALWAYS queued! Behaviour should be like in original glest!

This commit is contained in:
Titus Tscharntke 2011-04-08 20:25:03 +00:00
parent b99d37c02c
commit 5aa6092f1f
2 changed files with 20 additions and 10 deletions

View File

@ -827,19 +827,27 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue) {
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::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Command is Queable\n",__FILE__,__FUNCTION__,__LINE__);
//Delete all lower-prioirty commands
for (list<Command*>::iterator i = commands.begin(); i != commands.end();) {
if ((*i)->getPriority() < command_priority) {
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled) SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Deleting lower priority command [%s]\n",__FILE__,__FUNCTION__,__LINE__,(*i)->toString().c_str());
if(command->getCommandType()->isQueuable() == qAlways && tryQueue){
// Its a produce or upgrade command called without queued key
// in this case we must NOT delete lower priority commands!
// we just queue it!
deleteQueuedCommand(*i);
i = commands.erase(i);
}
else {
++i;
}
else{
//Delete all lower-prioirty commands
for(list<Command*>::iterator i= commands.begin(); i != commands.end();){
if((*i)->getPriority() < command_priority){
if(SystemFlags::getSystemSettingType(SystemFlags::debugUnitCommands).enabled)
SystemFlags::OutputDebug(SystemFlags::debugUnitCommands,"In [%s::%s Line: %d] Deleting lower priority command [%s]\n",__FILE__,__FUNCTION__,__LINE__,(*i)->toString().c_str());
deleteQueuedCommand(*i);
i= commands.erase(i);
}
else{
++i;
}
}
}
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());
//cancel current command if it is not queuable

View File

@ -317,6 +317,7 @@ public:
virtual string toString() const;
virtual const ProducibleType *getProduced() const;
virtual Queueability isQueuable() const {return qAlways;}
virtual int getTypePriority() const {return 15;}
//get
const ProduceSkillType *getProduceSkillType() const {return produceSkillType;}
@ -344,6 +345,7 @@ public:
virtual string getReqDesc() const;
virtual const ProducibleType *getProduced() const;
virtual Queueability isQueuable() const {return qAlways;}
virtual int getTypePriority() const {return 15;}
//get
const UpgradeSkillType *getUpgradeSkillType() const {return upgradeSkillType;}