Bazaar developer reference

CvArmyAI::SetFormationIndex(int)

Defined in
CvArmyAI.cpp, line 344
Class
CvArmyAI
Hook name
CivHooks::CvArmyAI_SetFormationIndex

Hooks

static bool BeforeCvArmyAI_SetFormationIndex(CvArmyAI* self, int iFormationIndex);static void AfterCvArmyAI_SetFormationIndex(CvArmyAI* self, int iFormationIndex);static void ReplaceCvArmyAI_SetFormationIndex(void (*original)(CvArmyAI*, int), CvArmyAI* self, int iFormationIndex);CivRegisterBefore<CivHooks::CvArmyAI_SetFormationIndex>(host, &BeforeCvArmyAI_SetFormationIndex);CivRegisterAfter<CivHooks::CvArmyAI_SetFormationIndex>(host, &AfterCvArmyAI_SetFormationIndex);CivRegisterReplace<CivHooks::CvArmyAI_SetFormationIndex>(host, &ReplaceCvArmyAI_SetFormationIndex);

Code

343/// Set index of the formation used by this army344void CvArmyAI::SetFormationIndex(int iFormationIndex)345{346	CvArmyFormationSlot slot;347348	if(m_iFormationIndex != iFormationIndex)349	{350		m_iFormationIndex = iFormationIndex;351352		CvMultiUnitFormationInfo* thisFormation = GC.getMultiUnitFormationInfo(m_iFormationIndex);353		if(thisFormation)354		{355			int iNumSlots = thisFormation->getNumFormationSlotEntries();356357			// Build all the formation entries358			m_FormationEntries.clear();359			for(int iI = 0; iI < iNumSlots; iI++)360			{361				slot.SetUnitID(ARMY_NO_UNIT);362				slot.SetTurnAtCheckpoint(ARMYSLOT_UNKNOWN_TURN_AT_CHECKPOINT);363				m_FormationEntries.push_back(slot);364			}365		}366	}367}

Calls

Called by