Bazaar developer reference

CvPlayer::changeFreeBuildingCount(BuildingTypes, int)

Defined in
CvPlayer.cpp, line 20306
Class
CvPlayer
Hook name
CivHooks::CvPlayer_changeFreeBuildingCount

Hooks

static bool BeforeCvPlayer_changeFreeBuildingCount(CvPlayer* self, BuildingTypes eIndex, int iChange);static void AfterCvPlayer_changeFreeBuildingCount(CvPlayer* self, BuildingTypes eIndex, int iChange);static void ReplaceCvPlayer_changeFreeBuildingCount(void (*original)(CvPlayer*, BuildingTypes, int), CvPlayer* self, BuildingTypes eIndex, int iChange);CivRegisterBefore<CivHooks::CvPlayer_changeFreeBuildingCount>(host, &BeforeCvPlayer_changeFreeBuildingCount);CivRegisterAfter<CivHooks::CvPlayer_changeFreeBuildingCount>(host, &AfterCvPlayer_changeFreeBuildingCount);CivRegisterReplace<CivHooks::CvPlayer_changeFreeBuildingCount>(host, &ReplaceCvPlayer_changeFreeBuildingCount);

Code

20306void CvPlayer::changeFreeBuildingCount(BuildingTypes eIndex, int iChange)20307{20308	CvCity* pLoopCity;20309	int iOldFreeBuildingCount;20310	int iLoop;2031120312	CvAssertMsg(eIndex >= 0, "eIndex is expected to be non-negative (invalid Index)");20313	CvAssertMsg(eIndex < GC.getNumBuildingInfos(), "eIndex is expected to be within maximum bounds (invalid Index)");2031420315	if(iChange != 0)20316	{20317		iOldFreeBuildingCount = getFreeBuildingCount(eIndex);2031820319		m_paiFreeBuildingCount.setAt(eIndex, m_paiFreeBuildingCount[eIndex] + iChange);20320		CvAssert(getFreeBuildingCount(eIndex) >= 0);2032120322		if(iOldFreeBuildingCount == 0)20323		{20324			CvAssertMsg(getFreeBuildingCount(eIndex) > 0, "getFreeBuildingCount(eIndex) is expected to be greater than 0");2032520326			for(pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))20327			{20328				pLoopCity->GetCityBuildings()->SetNumFreeBuilding(eIndex, 1);20329			}20330		}20331		else if(getFreeBuildingCount(eIndex) == 0)20332		{20333			CvAssertMsg(iOldFreeBuildingCount > 0, "iOldFreeBuildingCount is expected to be greater than 0");2033420335			for(pLoopCity = firstCity(&iLoop); pLoopCity != NULL; pLoopCity = nextCity(&iLoop))20336			{20337				pLoopCity->GetCityBuildings()->SetNumFreeBuilding(eIndex, 0);20338			}20339		}20340	}20341}

Calls

Called by