Bazaar developer reference

CvPlayer::GetNumUnitsWithDomain(DomainTypes, bool)

Defined in
CvPlayer.cpp, line 4249
Class
CvPlayer
Hook name
CivHooks::CvPlayer_GetNumUnitsWithDomain

Hooks

static bool BeforeCvPlayer_GetNumUnitsWithDomain(CvPlayer* self, DomainTypes eDomain, bool bMilitaryOnly, int& result);static void AfterCvPlayer_GetNumUnitsWithDomain(CvPlayer* self, DomainTypes eDomain, bool bMilitaryOnly, int& result);static int ReplaceCvPlayer_GetNumUnitsWithDomain(int (*original)(CvPlayer*, DomainTypes, bool), CvPlayer* self, DomainTypes eDomain, bool bMilitaryOnly);CivRegisterBefore<CivHooks::CvPlayer_GetNumUnitsWithDomain>(host, &BeforeCvPlayer_GetNumUnitsWithDomain);CivRegisterAfter<CivHooks::CvPlayer_GetNumUnitsWithDomain>(host, &AfterCvPlayer_GetNumUnitsWithDomain);CivRegisterReplace<CivHooks::CvPlayer_GetNumUnitsWithDomain>(host, &ReplaceCvPlayer_GetNumUnitsWithDomain);

Code

4248/// Returns number of Units a player has of a particular domain.  The second argument allows you to check whether or not to include civilians.4249int CvPlayer::GetNumUnitsWithDomain(DomainTypes eDomain, bool bMilitaryOnly)4250{4251	int iNumUnits = 0;42524253	CvUnit* pLoopUnit;4254	int iLoop;42554256	// Current Units4257	for(pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop))4258	{4259		if(pLoopUnit->getDomainType() == eDomain)4260		{4261			if(!bMilitaryOnly || pLoopUnit->IsCombatUnit())4262			{4263				iNumUnits++;4264			}4265		}4266	}42674268	return iNumUnits;4269}

Calls

Called by