Bazaar developer reference

CvAIOperationDestroyBarbarianCamp::ShouldAbort()

Defined in
CvAIOperation.cpp, line 2424
Class
CvAIOperationDestroyBarbarianCamp
Hook name
CivHooks::CvAIOperationDestroyBarbarianCamp_ShouldAbort
Overrides
CvAIOperation::ShouldAbort()

Hooks

static bool BeforeCvAIOperationDestroyBarbarianCamp_ShouldAbort(CvAIOperationDestroyBarbarianCamp* self, bool& result);static void AfterCvAIOperationDestroyBarbarianCamp_ShouldAbort(CvAIOperationDestroyBarbarianCamp* self, bool& result);static bool ReplaceCvAIOperationDestroyBarbarianCamp_ShouldAbort(bool (*original)(CvAIOperationDestroyBarbarianCamp*), CvAIOperationDestroyBarbarianCamp* self);CivRegisterBefore<CivHooks::CvAIOperationDestroyBarbarianCamp_ShouldAbort>(host, &BeforeCvAIOperationDestroyBarbarianCamp_ShouldAbort);CivRegisterAfter<CivHooks::CvAIOperationDestroyBarbarianCamp_ShouldAbort>(host, &AfterCvAIOperationDestroyBarbarianCamp_ShouldAbort);CivRegisterReplace<CivHooks::CvAIOperationDestroyBarbarianCamp_ShouldAbort>(host, &ReplaceCvAIOperationDestroyBarbarianCamp_ShouldAbort);

Code

2423/// Returns true when we should abort the operation totally (besides when we have lost all units in it)2424bool CvAIOperationDestroyBarbarianCamp::ShouldAbort()2425{2426	CvString strMsg;24272428	// If parent says we're done, don't even check anything else2429	bool rtnValue = CvAIOperation::ShouldAbort();24302431	if(!rtnValue)2432	{2433		// See if our target camp is still there2434		if (!m_bCivilianRescue && GetTargetPlot()->getImprovementType() != GC.getBARBARIAN_CAMP_IMPROVEMENT())2435		{2436			// Success!  The camp is gone2437			if(GC.getLogging() && GC.getAILogging())2438			{2439				strMsg.Format("Barbarian camp at (x=%d y=%d) no longer exists. Aborting", GetTargetPlot()->getX(), GetTargetPlot()->getY());2440				LogOperationSpecialMessage(strMsg);2441			}2442			return true;2443		}24442445		else if (m_bCivilianRescue)2446		{2447			// is the unit rescued?2448			CvPlayerAI& BarbPlayer = GET_PLAYER(BARBARIAN_PLAYER);2449			CvUnit* pUnitToRescue = BarbPlayer.getUnit(m_iUnitToRescue);2450			if (!pUnitToRescue)2451			{2452				if (GC.getLogging() && GC.getAILogging())2453				{2454					strMsg.Format ("Civilian can no longer be rescued from barbarians. Aborting");2455					LogOperationSpecialMessage(strMsg);2456				}2457				return true;2458			}2459			else2460			{2461				if (pUnitToRescue->GetOriginalOwner() != m_eOwner || (pUnitToRescue->AI_getUnitAIType() != UNITAI_SETTLE && pUnitToRescue->AI_getUnitAIType() != UNITAI_WORKER))2462				{2463					if (GC.getLogging() && GC.getAILogging())2464					{2465						strMsg.Format ("Civilian can no longer be rescued from barbarians. Aborting");2466						LogOperationSpecialMessage(strMsg);2467					}2468					return true;2469				}2470			}2471		}24722473		else if(m_eCurrentState != AI_OPERATION_STATE_RECRUITING_UNITS)2474		{2475			// If down below strength of camp, abort2476			CvArmyAI* pThisArmy = GET_PLAYER(m_eOwner).getArmyAI(m_viArmyIDs[0]);2477			CvPlot* pTarget = GetTargetPlot();2478			UnitHandle pCampDefender = pTarget->getBestDefender(NO_PLAYER);2479			if(pCampDefender && pThisArmy->GetTotalPower() < pCampDefender->GetPower())2480			{2481				if(GC.getLogging() && GC.getAILogging())2482				{2483					strMsg.Format("Barbarian camp stronger (%d) than our units (%d). Aborting", pCampDefender->GetPower(), pThisArmy->GetTotalPower());2484					LogOperationSpecialMessage(strMsg);2485				}2486				return true;2487			}2488		}2489	}24902491	return rtnValue;2492}

Calls