Skip to content

Commit

Permalink
Misc
Browse files Browse the repository at this point in the history
  • Loading branch information
lhog committed Aug 15, 2023
1 parent a2035c7 commit 10c4252
Showing 1 changed file with 17 additions and 19 deletions.
36 changes: 17 additions & 19 deletions rts/Sim/Units/CommandAI/CommandAI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -508,27 +508,25 @@ bool CCommandAI::HandleBuildOptionRemoval(int cmdId)
if (cmdId >= 0)
return false;

if (cmdId < 0) {
if (auto* bcai = dynamic_cast<CBuilderCAI*>(this); bcai != nullptr) {
// clear the removed unitDef from the construction queue
for (size_t i = 0; i < bcai->commandQue.size(); /*NOOP*/) {
if (const auto& q = bcai->commandQue[i]; q.GetID() == cmdId)
bcai->commandQue.erase(commandQue.begin() + i);
else
++i;
}
bcai->buildOptions.erase(cmdId);
if (auto* bcai = dynamic_cast<CBuilderCAI*>(this); bcai != nullptr) {
// clear the removed unitDef from the construction queue
for (size_t i = 0; i < bcai->commandQue.size(); /*NOOP*/) {
if (const auto& q = bcai->commandQue[i]; q.GetID() == cmdId)
bcai->commandQue.erase(commandQue.begin() + i);
else
++i;
}
else if (auto* fcai = dynamic_cast<CFactoryCAI*>(this); fcai != nullptr) {
// clear the removed unitDef from the construction queue
for (size_t i = 0; i < fcai->commandQue.size(); /*NOOP*/) {
if (const auto& q = fcai->commandQue[i]; q.GetID() == cmdId)
fcai->commandQue.erase(commandQue.begin() + i);
else
++i;
}
fcai->buildOptions.erase(cmdId);
bcai->buildOptions.erase(cmdId);
}
else if (auto* fcai = dynamic_cast<CFactoryCAI*>(this); fcai != nullptr) {
// clear the removed unitDef from the construction queue
for (size_t i = 0; i < fcai->commandQue.size(); /*NOOP*/) {
if (const auto& q = fcai->commandQue[i]; q.GetID() == cmdId)
fcai->commandQue.erase(commandQue.begin() + i);
else
++i;
}
fcai->buildOptions.erase(cmdId);
}

return true;
Expand Down

0 comments on commit 10c4252

Please sign in to comment.