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

Method updateUnits

bwapi/BWAPI/Source/BWAPI/GameUnits.cpp:472–523  ·  view source on GitHub ↗

---------------------------------------------- UPDATE UNITS ----------------------------------------------

Source from the content-addressed store, hash-verified

470 }
471 //---------------------------------------------- UPDATE UNITS ----------------------------------------------
472 void GameImpl::updateUnits()
473 {
474 static Unitset selectedU;
475
476 // Update all unit data
477 computeUnitExistence();
478 computePrimaryUnitSets();
479 extractUnitData();
480 augmentUnitData();
481 applyLatencyCompensation();
482 computeSecondaryUnitSets();
483
484 // Update selection data
485 selectedU = selectedUnitSet;
486 selectedUnitSet.clear();
487 for ( Unit ui : selectedU )
488 {
489 UnitImpl *u = static_cast<UnitImpl*>(ui);
490 if ( u->exists() )
491 selectedUnitSet.insert(u);
492 else
493 {
494 u->setSelected(false);
495 if ( u->self )
496 u->self->isSelected = false;
497 } // if exists
498 } // for each in selectedU
499
500 // Get all units under disruption web and dark swarm
501 for ( Unit u : neutralUnits )
502 {
503 BWAPI::UnitType ut = u->getType();
504 if ( ut != UnitTypes::Spell_Dark_Swarm &&
505 ut != UnitTypes::Spell_Disruption_Web )
506 continue;
507
508 int r = u->getRight() - (ut == UnitTypes::Spell_Disruption_Web ? 1 : 0);
509 int b = u->getBottom() - (ut == UnitTypes::Spell_Disruption_Web ? 1 : 0);
510
511 // Get units under the ability that are affected
512 Unitset unitsInside( this->getUnitsInRectangle(u->getLeft(), u->getTop(), r, b, !IsSpell && !IsFlyer && !IsLifted ) );
513 for ( Unit uInsidei : unitsInside )
514 {
515 UnitImpl *uInside = static_cast<UnitImpl*>(uInsidei);
516 // Assign the boolean for whatever spell the unit is under
517 if ( ut == UnitTypes::Spell_Dark_Swarm )
518 uInside->self->isUnderDarkSwarm = true;
519 else if ( ut == UnitTypes::Spell_Disruption_Web )
520 uInside->self->isUnderDWeb = true;
521 }
522 } // for each neutral units
523 } // updateUnits
524
525 //------------------------------------------- CENTER ON SELECTED -------------------------------------------
526 void GameImpl::moveToSelectedUnits()

Callers 1

updateMethod · 0.95

Calls 9

getUnitsInRectangleMethod · 0.95
setSelectedMethod · 0.80
getRightMethod · 0.80
getBottomMethod · 0.80
getLeftMethod · 0.80
getTopMethod · 0.80
clearMethod · 0.45
existsMethod · 0.45
getTypeMethod · 0.45

Tested by

no test coverage detected