Bazaar developer reference

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

Defined in
CvPlayer.cpp, line 3742
Class
CvPlayer
Hook name
CivHooks::CvPlayer_initUnitWithNameOffset

Hooks

static bool BeforeCvPlayer_initUnitWithNameOffset(CvPlayer* self, UnitTypes eUnit, int nameOffset, int iX, int iY, UnitAITypes eUnitAI, DirectionTypes eFacingDirection, bool bNoMove, bool bSetupGraphical, int iMapLayer, int iNumGoodyHutsPopped, CvUnit*& result);static void AfterCvPlayer_initUnitWithNameOffset(CvPlayer* self, UnitTypes eUnit, int nameOffset, int iX, int iY, UnitAITypes eUnitAI, DirectionTypes eFacingDirection, bool bNoMove, bool bSetupGraphical, int iMapLayer, int iNumGoodyHutsPopped, CvUnit*& result);static CvUnit* ReplaceCvPlayer_initUnitWithNameOffset(CvUnit* (*original)(CvPlayer*, UnitTypes, int, int, int, UnitAITypes, DirectionTypes, bool, bool, int, int), CvPlayer* self, UnitTypes eUnit, int nameOffset, int iX, int iY, UnitAITypes eUnitAI, DirectionTypes eFacingDirection, bool bNoMove, bool bSetupGraphical, int iMapLayer, int iNumGoodyHutsPopped);CivRegisterBefore<CivHooks::CvPlayer_initUnitWithNameOffset>(host, &BeforeCvPlayer_initUnitWithNameOffset);CivRegisterAfter<CivHooks::CvPlayer_initUnitWithNameOffset>(host, &AfterCvPlayer_initUnitWithNameOffset);CivRegisterReplace<CivHooks::CvPlayer_initUnitWithNameOffset>(host, &ReplaceCvPlayer_initUnitWithNameOffset);

Code

3742CvUnit* CvPlayer::initUnitWithNameOffset(UnitTypes eUnit, int nameOffset, int iX, int iY, UnitAITypes eUnitAI, DirectionTypes eFacingDirection, bool bNoMove, bool bSetupGraphical, int iMapLayer /* = 0 */, int iNumGoodyHutsPopped)3743{3744	CvAssertMsg(eUnit != NO_UNIT, "Unit is not assigned a valid value");3745	if (eUnit == NO_UNIT)3746		return NULL;37473748	CvUnitEntry* pkUnitDef = GC.getUnitInfo(eUnit);3749	CvAssertFmt(pkUnitDef != NULL, "Trying to create unit of type %d, which does not exist", eUnit);3750	if (pkUnitDef == NULL)3751		return NULL;37523753	CvUnit* pUnit = addUnit();3754	CvAssertMsg(pUnit != NULL, "Unit is not assigned a valid value");3755	if(NULL != pUnit)3756	{3757		pUnit->initWithNameOffset(pUnit->GetID(), eUnit, nameOffset, ((eUnitAI == NO_UNITAI) ? ((UnitAITypes)(pkUnitDef->GetDefaultUnitAIType())) : eUnitAI), GetID(), iX, iY, eFacingDirection, bNoMove, bSetupGraphical, iMapLayer, iNumGoodyHutsPopped);37583759#if !defined(NO_TUTORIALS)3760		// slewis - added for the tutorial3761		if(pUnit->getUnitInfo().GetWorkRate() > 0 && pUnit->getUnitInfo().GetDomainType() == DOMAIN_LAND)3762		{3763			m_bEverTrainedBuilder = true;3764		}3765		// end added for the tutorial3766#endif3767	}37683769	m_kPlayerAchievements.AddUnit(pUnit);37703771	return pUnit;3772}

Calls

Called by