From 5aa6092f1fca2fad9e2f81272a078d7d6729234e Mon Sep 17 00:00:00 2001 From: Titus Tscharntke Date: Fri, 8 Apr 2011 20:25:03 +0000 Subject: [PATCH] produce commands are not ALWAYS queued! Behaviour should be like in original glest! --- source/glest_game/type_instances/unit.cpp | 28 +++++++++++++++-------- source/glest_game/types/command_type.h | 2 ++ 2 files changed, 20 insertions(+), 10 deletions(-) diff --git a/source/glest_game/type_instances/unit.cpp b/source/glest_game/type_instances/unit.cpp index 9df32b31..c46f2627 100644 --- a/source/glest_game/type_instances/unit.cpp +++ b/source/glest_game/type_instances/unit.cpp @@ -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::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::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 diff --git a/source/glest_game/types/command_type.h b/source/glest_game/types/command_type.h index b53b6844..c1199d48 100644 --- a/source/glest_game/types/command_type.h +++ b/source/glest_game/types/command_type.h @@ -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;}