CvAIOperation::GrabUnitsFromTheReserves(CvPlot *, CvPlot *)
- Defined in
- CvAIOperation.cpp, line 449
- Class
- CvAIOperation
- Hook name
CivHooks::CvAIOperation_GrabUnitsFromTheReserves
Hooks
static bool BeforeCvAIOperation_GrabUnitsFromTheReserves(CvAIOperation* self, CvPlot* pMusterPlot, CvPlot* pTargetPlot, bool& result);static void AfterCvAIOperation_GrabUnitsFromTheReserves(CvAIOperation* self, CvPlot* pMusterPlot, CvPlot* pTargetPlot, bool& result);static bool ReplaceCvAIOperation_GrabUnitsFromTheReserves(bool (*original)(CvAIOperation*, CvPlot*, CvPlot*), CvAIOperation* self, CvPlot* pMusterPlot, CvPlot* pTargetPlot);CivRegisterBefore<CivHooks::CvAIOperation_GrabUnitsFromTheReserves>(host, &BeforeCvAIOperation_GrabUnitsFromTheReserves);CivRegisterAfter<CivHooks::CvAIOperation_GrabUnitsFromTheReserves>(host, &AfterCvAIOperation_GrabUnitsFromTheReserves);CivRegisterReplace<CivHooks::CvAIOperation_GrabUnitsFromTheReserves>(host, &ReplaceCvAIOperation_GrabUnitsFromTheReserves);
Code
448/// Assigns available units to our operation. Returns true if all needed units assigned.449bool CvAIOperation::GrabUnitsFromTheReserves(CvPlot* pMusterPlot, CvPlot* pTargetPlot)450{451 bool rtnValue = true;452 bool success;453 std::vector<OperationSlot>::iterator it;454 bool bRequired;455456 // Copy over the list457 std::vector<OperationSlot> secondList;458 for(it = m_viListOfUnitsWeStillNeedToBuild.begin(); it != m_viListOfUnitsWeStillNeedToBuild.end(); ++it)459 {460 secondList.push_back(*it);461 }462463 // Clear main list464 m_viListOfUnitsWeStillNeedToBuild.clear();465466 for(it = secondList.begin(); it != secondList.end(); ++it)467 {468 success = FindBestFitReserveUnit(*it, pMusterPlot, pTargetPlot, &bRequired);469470 // If any fail, check to see if they were required471 if(!success)472 {473 if(bRequired)474 {475 // Return false to say that operation is not ready to roll yet476 rtnValue = false;477478 // And add them back to the list of units needed479 m_viListOfUnitsWeStillNeedToBuild.push_back(*it);480 }481 else482 {483 CvArmyAI* pArmy;484 pArmy = GET_PLAYER(m_eOwner).getArmyAI(it->m_iArmyID);485 if(pArmy)486 {487 pArmy->SetEstimatedTurn(it->m_iSlotID, ARMYSLOT_NOT_INCLUDING_IN_OPERATION);488 }489 }490 }491 }492493 return rtnValue;494}
Calls
- CvAIOperation::FindBestFitReserveUnit(OperationSlot, CvPlot *, CvPlot *, bool *)
- CvArmyAI::SetEstimatedTurn(int, int)
- CvPlayer::getArmyAI(int)
- CvPlayerAI::getPlayer(PlayerTypes)
OperationSlot::OperationSlotstd::_Vector_const_iterator::operator!=std::_Vector_iterator::_Vector_iteratorstd::_Vector_iterator::operator*std::_Vector_iterator::operator++std::_Vector_iterator::operator->std::_Vector_iterator::operator=std::vector::beginstd::vector::clearstd::vector::endstd::vector::push_backstd::vector::vector
Called by
- CvAIEnemyTerritoryOperation::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- CvAIEscortedOperation::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- CvAINavalEscortedOperation::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- CvAIOperation::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- CvAIOperationBasicCityAttack::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- CvAIOperationCityCloseDefense::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- CvAIOperationFoundCity::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- CvAIOperationFoundCity::ShouldAbort()
- CvAIOperationNavalAttack::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- CvAIOperationNavalBombardment::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- CvAIOperationNavalSuperiority::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- CvAIOperationNukeAttack::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- CvAIOperationPureNavalCityAttack::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)
- CvAIOperationRapidResponse::Init(int, PlayerTypes, PlayerTypes, int, CvCity *, CvCity *)