Bazaar developer reference

CvAIOperationFoundCity::ShouldAbort()

Defined in
CvAIOperation.cpp, line 3267
Class
CvAIOperationFoundCity
Hook name
CivHooks::CvAIOperationFoundCity_ShouldAbort
Overrides
CvAIOperation::ShouldAbort()

Hooks

static bool BeforeCvAIOperationFoundCity_ShouldAbort(CvAIOperationFoundCity* self, bool& result);static void AfterCvAIOperationFoundCity_ShouldAbort(CvAIOperationFoundCity* self, bool& result);static bool ReplaceCvAIOperationFoundCity_ShouldAbort(bool (*original)(CvAIOperationFoundCity*), CvAIOperationFoundCity* self);CivRegisterBefore<CivHooks::CvAIOperationFoundCity_ShouldAbort>(host, &BeforeCvAIOperationFoundCity_ShouldAbort);CivRegisterAfter<CivHooks::CvAIOperationFoundCity_ShouldAbort>(host, &AfterCvAIOperationFoundCity_ShouldAbort);CivRegisterReplace<CivHooks::CvAIOperationFoundCity_ShouldAbort>(host, &ReplaceCvAIOperationFoundCity_ShouldAbort);

Code

3266/// Returns true when we should abort the operation totally (besides when we have lost all units in it)3267bool CvAIOperationFoundCity::ShouldAbort()3268{3269	// If parent says we're done, don't even check anything else3270	bool rtnValue = CvAIOperation::ShouldAbort();32713272	if(!rtnValue)3273	{3274		if(m_eCurrentState == AI_OPERATION_STATE_RECRUITING_UNITS && m_bEscorted)3275		{3276			CvArmyAI* pThisArmy = GET_PLAYER(m_eOwner).getArmyAI(m_viArmyIDs[0]);3277			CvArmyFormationSlot* pSlot = pThisArmy->GetFormationSlot(0);32783279			if (GetMusterPlot()->getOwner() != m_eOwner || GC.getGame().getGameTurn() - pSlot->GetTurnAtCheckpoint() > 15) // fifteen turns and still no escort even being built?3280			{3281				if (m_viListOfUnitsCitiesHaveCommittedToBuild.size() == 0)3282				{3283					// try to get the escort from existing units that are waiting around3284					GrabUnitsFromTheReserves(GetMusterPlot(), GetTargetPlot());3285					if(pThisArmy->GetNumSlotsFilled() > 1)3286					{3287						pThisArmy->SetArmyAIState(ARMYAISTATE_WAITING_FOR_UNITS_TO_CATCH_UP);3288						m_eCurrentState = AI_OPERATION_STATE_GATHERING_FORCES;3289					}3290					else3291					{3292						// we are going by our lonesome3293						m_bEscorted = false;3294						// Clear the list of units we need3295						m_viListOfUnitsWeStillNeedToBuild.clear();3296						// Send the settler directly to the target3297						pThisArmy->SetArmyAIState(ARMYAISTATE_MOVING_TO_DESTINATION);3298						m_eCurrentState = AI_OPERATION_STATE_MOVING_TO_TARGET;3299					}3300				}3301			}3302		}3303		else if (m_eCurrentState == AI_OPERATION_STATE_GATHERING_FORCES && m_bEscorted)3304		{3305			CvArmyAI* pThisArmy = GET_PLAYER(m_eOwner).getArmyAI(m_viArmyIDs[0]);3306			CvArmyFormationSlot* pSlot = pThisArmy->GetFormationSlot(0);3307			if (pSlot->GetUnitID() != NO_UNIT)3308			{3309				UnitHandle pUnit = GET_PLAYER(m_eOwner).getUnit(pSlot->GetUnitID());3310				if (pUnit->plot()->isWater())3311				{3312					// we are going by our lonesome3313					m_bEscorted = false;3314					pThisArmy->SetArmyAIState(ARMYAISTATE_MOVING_TO_DESTINATION);3315					m_eCurrentState = AI_OPERATION_STATE_MOVING_TO_TARGET;3316				}3317			}3318		}3319	}33203321	return rtnValue;3322}

Calls