--------------------------------------------- ISSUE COMMAND ----------------------------------------------
| 19 | } |
| 20 | //--------------------------------------------- ISSUE COMMAND ---------------------------------------------- |
| 21 | bool UnitImpl::issueCommand(UnitCommand command) |
| 22 | { |
| 23 | if ( !canIssueCommand(command) ) |
| 24 | return false; |
| 25 | |
| 26 | command.unit = this; |
| 27 | |
| 28 | // If using train or morph on a hatchery, automatically switch selection to larva |
| 29 | // (assuming canIssueCommand ensures that there is a larva) |
| 30 | if ( (command.type == UnitCommandTypes::Train || |
| 31 | command.type == UnitCommandTypes::Morph) && |
| 32 | getType().producesLarva() && command.getUnitType().whatBuilds().first == UnitTypes::Zerg_Larva ) |
| 33 | { |
| 34 | Unitset larvae( this->getLarva() ); |
| 35 | for (Unit larva : larvae) |
| 36 | { |
| 37 | if ( !larva->isConstructing() && larva->isCompleted() && larva->canCommand() ) |
| 38 | { |
| 39 | command.unit = larva; |
| 40 | break; |
| 41 | } |
| 42 | } |
| 43 | if ( command.unit == this ) |
| 44 | return false; |
| 45 | } |
| 46 | |
| 47 | BWAPIC::UnitCommand c; |
| 48 | c.type = command.type; |
| 49 | #pragma warning(suppress: 6011) |
| 50 | c.unitIndex = command.unit->getID(); |
| 51 | if ( command.target ) |
| 52 | c.targetIndex = command.target->getID(); |
| 53 | else |
| 54 | c.targetIndex = -1; |
| 55 | c.x = command.x; |
| 56 | c.y = command.y; |
| 57 | c.extra = command.extra; |
| 58 | Command{ command }.execute(); |
| 59 | static_cast<GameImpl*>(BroodwarPtr)->addUnitCommand(c); |
| 60 | lastCommandFrame = Broodwar->getFrameCount(); |
| 61 | lastCommand = command; |
| 62 | return true; |
| 63 | } |
| 64 | } |
nothing calls this directly
no test coverage detected