This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** This function checks if there are any structures to repair on a given radius near the droid defined by REPAIR_RANGE if it is on secundary state onHold, and REPAIR_MAXDIST*REPAIR_MAXDIST if not on hold.
* It returns a damaged structure if any was found or NULL if none was found.
* @todo this function performs a cycle on all buildings of a given player, which is ineficient. Suggestion to improve it.
/** This function checks if there are any structures to repair or help build in a given radius near the droid defined by REPAIR_RANGE if it is on hold, and REPAIR_MAXDIST if not on hold.
* It returns a damaged or incomplete structure if any was found or NULL if none was found.
std::pair<STRUCTURE *, DROID_ACTION> best = {nullptr, DACTION_NONE};
for (BASE_OBJECT *object : gridStartIterate(psDroid->pos.x, psDroid->pos.y, radius))
{
//check for damage
if (psCurr->status == SS_BUILT && structIsDamaged(psCurr) && !checkDroidsDemolishing(psCurr)
&& visibleObject(psDroid, psCurr, false)
&& (unsigned)droidSqDist(psDroid, psCurr) < // Cast to unsigned, since droidSqDist returns -1 if psCurr is unreachable, which should compare greater than the maximum range.
// Hold position? Repair range, else repair max dist
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters