------------------------------------------- CAN TRAIN --------------------------------------------------
| 872 | } |
| 873 | //------------------------------------------- CAN TRAIN -------------------------------------------------- |
| 874 | static inline bool canTrain(Unit thisUnit, bool checkCommandibility = true) |
| 875 | { |
| 876 | if ( !checkCommandibility ) |
| 877 | Broodwar->setLastError(); |
| 878 | else if ( !canCommand(thisUnit) ) |
| 879 | return false; |
| 880 | |
| 881 | if ( thisUnit->getType().producesLarva() ) |
| 882 | { |
| 883 | if ( !thisUnit->isConstructing() && thisUnit->isCompleted() ) |
| 884 | return Broodwar->setLastError(); |
| 885 | Unitset larvae( thisUnit->getLarva() ); |
| 886 | for (Unit larva : larvae) |
| 887 | { |
| 888 | if ( !larva->isConstructing() && larva->isCompleted() && canCommand(larva) ) |
| 889 | return Broodwar->setLastError(); |
| 890 | } |
| 891 | return Broodwar->setLastError(Errors::Unit_Busy); |
| 892 | } |
| 893 | |
| 894 | if ( thisUnit->isConstructing() || |
| 895 | !thisUnit->isCompleted() || |
| 896 | thisUnit->isLifted() ) |
| 897 | return Broodwar->setLastError(Errors::Unit_Busy); |
| 898 | if ( !thisUnit->getType().canProduce() && |
| 899 | thisUnit->getType() != UnitTypes::Enum::Terran_Nuclear_Silo && |
| 900 | thisUnit->getType() != UnitTypes::Enum::Zerg_Hydralisk && |
| 901 | thisUnit->getType() != UnitTypes::Enum::Zerg_Mutalisk && |
| 902 | thisUnit->getType() != UnitTypes::Enum::Zerg_Creep_Colony && |
| 903 | thisUnit->getType() != UnitTypes::Enum::Zerg_Spire && |
| 904 | thisUnit->getType() != UnitTypes::Enum::Zerg_Larva ) |
| 905 | return Broodwar->setLastError(Errors::Incompatible_UnitType); |
| 906 | if ( thisUnit->isHallucination() ) |
| 907 | return Broodwar->setLastError(Errors::Incompatible_UnitType); |
| 908 | |
| 909 | return true; |
| 910 | } |
| 911 | static inline bool canTrain(Unit thisUnit, UnitType uType, bool checkCanIssueCommandType = true, bool checkCommandibility = true) |
| 912 | { |
| 913 | if ( !checkCommandibility ) |
no test coverage detected