Bazaar developer reference

CvCityBuildings::DoSellBuilding(BuildingTypes)

Defined in
CvBuildingClasses.cpp, line 2476
Class
CvCityBuildings
Hook name
CivHooks::CvCityBuildings_DoSellBuilding

Hooks

static bool BeforeCvCityBuildings_DoSellBuilding(CvCityBuildings* self, BuildingTypes eIndex);static void AfterCvCityBuildings_DoSellBuilding(CvCityBuildings* self, BuildingTypes eIndex);static void ReplaceCvCityBuildings_DoSellBuilding(void (*original)(CvCityBuildings*, BuildingTypes), CvCityBuildings* self, BuildingTypes eIndex);CivRegisterBefore<CivHooks::CvCityBuildings_DoSellBuilding>(host, &BeforeCvCityBuildings_DoSellBuilding);CivRegisterAfter<CivHooks::CvCityBuildings_DoSellBuilding>(host, &AfterCvCityBuildings_DoSellBuilding);CivRegisterReplace<CivHooks::CvCityBuildings_DoSellBuilding>(host, &ReplaceCvCityBuildings_DoSellBuilding);

Code

2475/// Sell eIndex~!2476void CvCityBuildings::DoSellBuilding(BuildingTypes eIndex)2477{2478	CvAssertMsg(eIndex >= 0, "eIndex expected to be >= 0");2479	CvAssertMsg(eIndex < m_pBuildings->GetNumBuildings(), "eIndex expected to be < m_pBuildings->GetNumBuildings()");24802481	CvBuildingEntry* pkBuildingEntry = GC.getBuildingInfo(eIndex);2482	if(!pkBuildingEntry)2483		return;24842485	// Can we actually do this?2486	if(!IsBuildingSellable(*pkBuildingEntry))2487		return;24882489	// Gold refund2490	int iRefund = GetSellBuildingRefund(eIndex);2491	GET_PLAYER(m_pCity->getOwner()).GetTreasury()->ChangeGold(iRefund);24922493	// Kick everyone out2494	m_pCity->GetCityCitizens()->DoRemoveAllSpecialistsFromBuilding(eIndex);24952496	SetNumRealBuilding(eIndex, 0);24972498	SetSoldBuildingThisTurn(true);2499}

Calls

Called by