--------------------------------------------- HAS PATH ---------------------------------------------------
| 156 | } |
| 157 | //--------------------------------------------- HAS PATH --------------------------------------------------- |
| 158 | bool UnitInterface::hasPath(Position target) const |
| 159 | { |
| 160 | Broodwar->setLastError(); |
| 161 | // Return error if the position is invalid |
| 162 | if (!target) |
| 163 | return Broodwar->setLastError(Errors::Invalid_Parameter); |
| 164 | |
| 165 | // Return true if this unit is an air unit |
| 166 | if (this->isFlying()) |
| 167 | return true; |
| 168 | |
| 169 | // Return error if this does not exist |
| 170 | if (!exists()) |
| 171 | return Broodwar->setLastError(Errors::Unit_Not_Visible); |
| 172 | |
| 173 | // Check the center of the unit (most common behaviour) |
| 174 | if (Broodwar->hasPath(this->getPosition(), target)) |
| 175 | return true; |
| 176 | |
| 177 | // Otherwise check all four corners of the unit, in case it accidentally fell out of its region |
| 178 | if (Broodwar->hasPath(Position(getLeft(), getTop()), target)) |
| 179 | return true; |
| 180 | |
| 181 | if (Broodwar->hasPath(Position(getRight(), getTop()), target)) |
| 182 | return true; |
| 183 | |
| 184 | if (Broodwar->hasPath(Position(getLeft(), getBottom()), target)) |
| 185 | return true; |
| 186 | |
| 187 | return Broodwar->hasPath(Position(getRight(), getBottom()), target); |
| 188 | } |
| 189 | bool UnitInterface::hasPath(Unit target) const |
| 190 | { |
| 191 | Broodwar->setLastError(); |
nothing calls this directly
no test coverage detected