Tried to fix the command-queing bug not canceling attack on produce command
This commit is contained in:
parent
f010130c38
commit
6d4697f2ba
|
@ -1,7 +1,7 @@
|
||||||
// ==============================================================
|
// ==============================================================
|
||||||
// This file is part of Glest (www.glest.org)
|
// This file is part of Glest (www.glest.org)
|
||||||
//
|
//
|
||||||
// Copyright (C) 2001-2008 Marti<EFBFBD>o Figueroa
|
// Copyright (C) 2001-2008 Martiño Figueroa
|
||||||
//
|
//
|
||||||
// You can redistribute this code and/or modify it under
|
// You can redistribute this code and/or modify it under
|
||||||
// the terms of the GNU General Public License as published
|
// the terms of the GNU General Public License as published
|
||||||
|
@ -500,6 +500,11 @@ unsigned int Unit::getCommandSize() const{
|
||||||
return commands.size();
|
return commands.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#define deleteSingleCommand(command) {\
|
||||||
|
undoCommand(command);\
|
||||||
|
delete command;\
|
||||||
|
}
|
||||||
|
|
||||||
//give one command (clear, and push back)
|
//give one command (clear, and push back)
|
||||||
CommandResult Unit::giveCommand(Command *command, bool tryQueue){
|
CommandResult Unit::giveCommand(Command *command, bool tryQueue){
|
||||||
|
|
||||||
|
@ -515,7 +520,18 @@ CommandResult Unit::giveCommand(Command *command, bool tryQueue){
|
||||||
|
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
if(command->getCommandType()->isQueuable(tryQueue)){
|
const int command_priority = command->getCommandType()->getPriority();
|
||||||
|
|
||||||
|
if(command->getCommandType()->isQueuable(tryQueue) && (commands.empty() || (command_priority >= commands.back()->getCommandType()->getPriority()))){
|
||||||
|
//Delete all lower-prioirty commands
|
||||||
|
for (list<Command*>::iterator i = commands.begin(); i != commands.end();) {
|
||||||
|
if ((*i)->getCommandType()->getPriority() < command_priority) {
|
||||||
|
deleteSingleCommand(*i);
|
||||||
|
i = commands.erase(i);
|
||||||
|
} else {
|
||||||
|
++i;
|
||||||
|
}
|
||||||
|
}
|
||||||
//cancel current command if it is not queuable
|
//cancel current command if it is not queuable
|
||||||
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
SystemFlags::OutputDebug(SystemFlags::debugSystem,"In [%s::%s Line: %d]\n",__FILE__,__FUNCTION__,__LINE__);
|
||||||
|
|
||||||
|
|
|
@ -88,6 +88,8 @@ public:
|
||||||
Queueability q = isQueuable();
|
Queueability q = isQueuable();
|
||||||
return (q != qNever) && (q != qOnlyLast);
|
return (q != qNever) && (q != qOnlyLast);
|
||||||
}
|
}
|
||||||
|
//Priority: commands of higher priority will cancel commands of lower priority
|
||||||
|
virtual int getPriority() const {return 0;}
|
||||||
|
|
||||||
//get
|
//get
|
||||||
CommandClass getClass() const;
|
CommandClass getClass() const;
|
||||||
|
@ -110,6 +112,7 @@ public:
|
||||||
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
|
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
|
||||||
virtual string toString() const;
|
virtual string toString() const;
|
||||||
virtual Queueability isQueuable() const {return qNever;}
|
virtual Queueability isQueuable() const {return qNever;}
|
||||||
|
virtual int getPriority() const {return 100000;}
|
||||||
//get
|
//get
|
||||||
const StopSkillType *getStopSkillType() const {return stopSkillType;};
|
const StopSkillType *getStopSkillType() const {return stopSkillType;};
|
||||||
};
|
};
|
||||||
|
@ -151,6 +154,7 @@ public:
|
||||||
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
|
virtual string getDesc(const TotalUpgrade *totalUpgrade) const;
|
||||||
virtual string toString() const;
|
virtual string toString() const;
|
||||||
|
|
||||||
|
|
||||||
//get
|
//get
|
||||||
const MoveSkillType * getMoveSkillType() const {return moveSkillType;}
|
const MoveSkillType * getMoveSkillType() const {return moveSkillType;}
|
||||||
const AttackSkillType * getAttackSkillType() const {return attackSkillType;}
|
const AttackSkillType * getAttackSkillType() const {return attackSkillType;}
|
||||||
|
@ -286,6 +290,7 @@ public:
|
||||||
virtual string toString() const;
|
virtual string toString() const;
|
||||||
virtual const ProducibleType *getProduced() const;
|
virtual const ProducibleType *getProduced() const;
|
||||||
virtual Queueability isQueuable() const {return qAlways;}
|
virtual Queueability isQueuable() const {return qAlways;}
|
||||||
|
virtual int getPriority() const {return 5;} //higher priority to cancel attack
|
||||||
|
|
||||||
//get
|
//get
|
||||||
const ProduceSkillType *getProduceSkillType() const {return produceSkillType;}
|
const ProduceSkillType *getProduceSkillType() const {return produceSkillType;}
|
||||||
|
@ -311,6 +316,7 @@ public:
|
||||||
virtual string getReqDesc() const;
|
virtual string getReqDesc() const;
|
||||||
virtual const ProducibleType *getProduced() const;
|
virtual const ProducibleType *getProduced() const;
|
||||||
virtual Queueability isQueuable() const {return qAlways;}
|
virtual Queueability isQueuable() const {return qAlways;}
|
||||||
|
virtual int getPriority() const {return 5;} //higher priority to cancel attack (and same as Build)
|
||||||
|
|
||||||
//get
|
//get
|
||||||
const UpgradeSkillType *getUpgradeSkillType() const {return upgradeSkillType;}
|
const UpgradeSkillType *getUpgradeSkillType() const {return upgradeSkillType;}
|
||||||
|
|
Loading…
Reference in New Issue