Bazaar developer reference

CvPlayer::initUnit(UnitTypes, int, int, UnitAITypes, DirectionTypes, bool, bool, int, int)

Defined in
CvPlayer.cpp, line 3710
Class
CvPlayer
Hook name
CivHooks::CvPlayer_initUnit

Hooks

static bool BeforeCvPlayer_initUnit(CvPlayer* self, UnitTypes eUnit, int iX, int iY, UnitAITypes eUnitAI, DirectionTypes eFacingDirection, bool bNoMove, bool bSetupGraphical, int iMapLayer, int iNumGoodyHutsPopped, CvUnit*& result);static void AfterCvPlayer_initUnit(CvPlayer* self, UnitTypes eUnit, int iX, int iY, UnitAITypes eUnitAI, DirectionTypes eFacingDirection, bool bNoMove, bool bSetupGraphical, int iMapLayer, int iNumGoodyHutsPopped, CvUnit*& result);static CvUnit* ReplaceCvPlayer_initUnit(CvUnit* (*original)(CvPlayer*, UnitTypes, int, int, UnitAITypes, DirectionTypes, bool, bool, int, int), CvPlayer* self, UnitTypes eUnit, int iX, int iY, UnitAITypes eUnitAI, DirectionTypes eFacingDirection, bool bNoMove, bool bSetupGraphical, int iMapLayer, int iNumGoodyHutsPopped);CivRegisterBefore<CivHooks::CvPlayer_initUnit>(host, &BeforeCvPlayer_initUnit);CivRegisterAfter<CivHooks::CvPlayer_initUnit>(host, &AfterCvPlayer_initUnit);CivRegisterReplace<CivHooks::CvPlayer_initUnit>(host, &ReplaceCvPlayer_initUnit);

Code

3710CvUnit* CvPlayer::initUnit(UnitTypes eUnit, int iX, int iY, UnitAITypes eUnitAI, DirectionTypes eFacingDirection, bool bNoMove, bool bSetupGraphical, int iMapLayer /* = 0 */, int iNumGoodyHutsPopped)3711{3712	CvAssertMsg(eUnit != NO_UNIT, "Unit is not assigned a valid value");3713	if (eUnit == NO_UNIT)3714		return NULL;37153716	CvUnitEntry* pkUnitDef = GC.getUnitInfo(eUnit);3717	CvAssertFmt(pkUnitDef != NULL, "Trying to create unit of type %d, which does not exist", eUnit);3718	if (pkUnitDef == NULL)3719		return NULL;37203721	CvUnit* pUnit = addUnit();3722	CvAssertMsg(pUnit != NULL, "Unit is not assigned a valid value");3723	if(NULL != pUnit)3724	{3725		pUnit->init(pUnit->GetID(), eUnit, ((eUnitAI == NO_UNITAI) ? ((UnitAITypes)(pkUnitDef->GetDefaultUnitAIType())) : eUnitAI), GetID(), iX, iY, eFacingDirection, bNoMove, bSetupGraphical, iMapLayer, iNumGoodyHutsPopped);37263727#if !defined(NO_TUTORIALS)3728		// slewis - added for the tutorial3729		if(pUnit->getUnitInfo().GetWorkRate() > 0 && pUnit->getUnitInfo().GetDomainType() == DOMAIN_LAND)3730		{3731			m_bEverTrainedBuilder = true;3732		}3733		// end added for the tutorial3734#endif3735	}37363737	m_kPlayerAchievements.AddUnit(pUnit);37383739	return pUnit;3740}

Calls

Called by

33 functions in 12 files