Bazaar developer reference

CvPlayer::GetNumUnitsOutOfSupply() const

Defined in
CvPlayer.cpp, line 9754
Class
CvPlayer
Hook name
CivHooks::CvPlayer_GetNumUnitsOutOfSupply

Hooks

static bool BeforeCvPlayer_GetNumUnitsOutOfSupply(const CvPlayer* self, int& result);static void AfterCvPlayer_GetNumUnitsOutOfSupply(const CvPlayer* self, int& result);static int ReplaceCvPlayer_GetNumUnitsOutOfSupply(int (*original)(const CvPlayer*), const CvPlayer* self);CivRegisterBefore<CivHooks::CvPlayer_GetNumUnitsOutOfSupply>(host, &BeforeCvPlayer_GetNumUnitsOutOfSupply);CivRegisterAfter<CivHooks::CvPlayer_GetNumUnitsOutOfSupply>(host, &AfterCvPlayer_GetNumUnitsOutOfSupply);CivRegisterReplace<CivHooks::CvPlayer_GetNumUnitsOutOfSupply>(host, &ReplaceCvPlayer_GetNumUnitsOutOfSupply);

Code

9753/// How much Units are eating Production?9754int CvPlayer::GetNumUnitsOutOfSupply() const9755{9756	int iFreeUnits = GetNumUnitsSupplied();9757	int iNumUnits = getNumUnits();9758	9759	int iNumTradeUnits = 0;9760	int iLoop = 0;9761	const CvUnit* pLoopUnit = NULL;9762	for(pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop))9763	{9764		if(pLoopUnit->isTrade())9765		{9766			iNumTradeUnits++;9767		}9768	}97699770#if defined(MOD_UNITS_NO_SUPPLY)9771	if (MOD_UNITS_NO_SUPPLY) {9772		for(pLoopUnit = firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = nextUnit(&iLoop))9773		{9774			if(pLoopUnit->isNoSupply())9775			{9776				iFreeUnits++;9777			}9778		}9779	}9780#endif97819782	int iNumUnitsToSupply = iNumUnits - iNumTradeUnits;9783	return std::max(0, iNumUnitsToSupply - iFreeUnits);9784}

Calls

Called by