本文整理汇总了C++中CFactoryCAI::RemoveBuildCommand方法的典型用法代码示例。如果您正苦于以下问题:C++ CFactoryCAI::RemoveBuildCommand方法的具体用法?C++ CFactoryCAI::RemoveBuildCommand怎么用?C++ CFactoryCAI::RemoveBuildCommand使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CFactoryCAI
的用法示例。
在下文中一共展示了CFactoryCAI::RemoveBuildCommand方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: ExecuteRemove
void CCommandAI::ExecuteRemove(const Command& c)
{
// disable repeating during the removals
const bool prevRepeat = repeatOrders;
repeatOrders = false;
CCommandQueue* queue = &commandQue;
bool facBuildQueue = false;
CFactoryCAI* facCAI = dynamic_cast<CFactoryCAI*>(this);
if (facCAI) {
if (c.options & CONTROL_KEY) {
// check the build order
facBuildQueue = true;
} else {
// use the new commands
queue = &facCAI->newUnitCommands;
}
}
if ((c.params.size() <= 0) || (queue->size() <= 0)) {
return;
}
// erase commands by a list of command types
bool active = false;
for (unsigned int p = 0; p < c.params.size(); p++) {
const int removeValue = (int)c.params[p]; // tag or id
if (facBuildQueue && (removeValue == 0) && !(c.options & ALT_KEY)) {
continue; // don't remove tag=0 commands from build queues, they
// are used the same way that CMD_STOP is, to void orders
}
CCommandQueue::iterator ci;
do {
for (ci = queue->begin(); ci != queue->end(); ++ci) {
const Command& qc = *ci;
if (c.options & ALT_KEY) {
if (qc.id != removeValue) { continue; }
} else {
if (qc.tag != removeValue) { continue; }
}
if (qc.id == CMD_WAIT) {
waitCommandsAI.RemoveWaitCommand(owner, qc);
}
if (facBuildQueue) {
facCAI->RemoveBuildCommand(ci);
ci = queue->begin();
break; // the removal may have corrupted the iterator
}
if (!facCAI && (ci == queue->begin())) {
if (!active) {
active = true;
FinishCommand();
ci = queue->begin();
break;
}
active = true;
}
queue->erase(ci);
ci = queue->begin();
break; // the removal may have corrupted the iterator
}
}
while (ci != queue->end());
}
repeatOrders = prevRepeat;
return;
}