Skip to content

Commit

Permalink
UnitHandler update to be support irregular move types triggering arbi…
Browse files Browse the repository at this point in the history
…trary active unit changes.
  • Loading branch information
marcushutchings committed Sep 12, 2022
1 parent bc7b996 commit 7c57e61
Showing 1 changed file with 7 additions and 13 deletions.
20 changes: 7 additions & 13 deletions rts/Sim/Units/UnitHandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -329,7 +329,6 @@ void CUnitHandler::UpdateUnitMoveTypes()

{
// SCOPED_TIMER("Sim::Unit::MoveType::3::UpdateMT");
std::size_t len = activeUnits.size();
for_mt(0, activeUnits.size(), [this](const int i){
CUnit* unit = activeUnits[i];
AMoveType* moveType = unit->moveType;
Expand All @@ -346,30 +345,25 @@ void CUnitHandler::UpdateUnitMoveTypes()
AMoveType* moveType = unit->moveType;

moveType->ProcessCollisionEvents();

if (!unit->pos.IsInBounds() && (unit->speed.w > MAX_UNIT_SPEED))
unit->ForcedKillUnit(nullptr, false, true, false);

assert(activeUnits[activeUpdateUnit] == unit);
}
}

{
// SCOPED_TIMER("Sim::Unit::MoveType::5::UpdateST");
std::size_t len = activeUnits.size();
for (std::size_t i=0; i<len; ++i) {
CUnit* unit = activeUnits[i];
for (activeUpdateUnit = 0; activeUpdateUnit < activeUnits.size(); ++activeUpdateUnit) {
CUnit* unit = activeUnits[activeUpdateUnit];
AMoveType* moveType = unit->moveType;

if (moveType->Update())
eventHandler.UnitMoved(unit);

// // this unit is not coming back, kill it now without any death
// // sequence (s.t. deathScriptFinished becomes true immediately)
// if (!unit->pos.IsInBounds() && (unit->speed.w > MAX_UNIT_SPEED))
// unit->ForcedKillUnit(nullptr, false, true, false);
// this unit is not coming back, kill it now without any death
// sequence (s.t. deathScriptFinished becomes true immediately)
if (!unit->pos.IsInBounds() && (unit->speed.w > MAX_UNIT_SPEED))
unit->ForcedKillUnit(nullptr, false, true, false);

unit->SanityCheck();
assert(activeUnits[activeUpdateUnit] == unit);
}
}
}
Expand Down

0 comments on commit 7c57e61

Please sign in to comment.