---------------------------------------------- UPDATE UNITS ----------------------------------------------
| 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() |
no test coverage detected