MCPcopy Create free account
hub / github.com/bwapi/bwapi / ReserveAllStructures

Function ReserveAllStructures

bwapi/BWAPILIB/Source/Game.cpp:315–336  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

313 }
314
315 void ReserveAllStructures(PlacementReserve &reserve, UnitType type, TilePosition desiredPosition)
316 {
317 if ( type.isAddon() )
318 return;
319 reserve.backup();
320
321 // Reserve space around owned resource depots and resource containers
322 Unitset myUnits = Broodwar->self()->getUnits();
323 myUnits.erase_if( !(Exists && (IsCompleted || (ProducesLarva && IsMorphing)) && IsBuilding && (IsResourceDepot || IsRefinery)) );
324 for ( auto &u : myUnits)
325 ReserveStructure(reserve, u, 2, type, desiredPosition);
326
327 // Reserve space around neutral resources
328 if ( type != UnitTypes::Terran_Bunker )
329 {
330 Unitset resources = Broodwar->getNeutralUnits();
331 resources.erase_if( !(Exists && IsResourceContainer) );
332 for ( auto &u : resources)
333 ReserveStructure(reserve, u, 2, type, desiredPosition);
334 }
335 reserve.restoreIfInvalid(__FUNCTION__);
336 }
337
338 TilePosition gDirections[] = {
339 TilePosition( 1, 1),

Callers 1

ReservePlacementFunction · 0.85

Calls 7

ReserveStructureFunction · 0.85
isAddonMethod · 0.80
backupMethod · 0.80
erase_ifMethod · 0.80
restoreIfInvalidMethod · 0.80
getUnitsMethod · 0.45
selfMethod · 0.45

Tested by

no test coverage detected