Bazaar developer reference

CvPlayer::disband(CvCity *)

Defined in
CvPlayer.cpp, line 6243
Class
CvPlayer
Hook name
CivHooks::CvPlayer_disband

Hooks

static bool BeforeCvPlayer_disband(CvPlayer* self, CvCity* pCity);static void AfterCvPlayer_disband(CvPlayer* self, CvCity* pCity);static void ReplaceCvPlayer_disband(void (*original)(CvPlayer*, CvCity*), CvPlayer* self, CvCity* pCity);CivRegisterBefore<CivHooks::CvPlayer_disband>(host, &BeforeCvPlayer_disband);CivRegisterAfter<CivHooks::CvPlayer_disband>(host, &AfterCvPlayer_disband);CivRegisterReplace<CivHooks::CvPlayer_disband>(host, &ReplaceCvPlayer_disband);

Code

6243void CvPlayer::disband(CvCity* pCity)6244{6245	CvPlot* pPlot = pCity->plot();62466247	if(getNumCities() == 1)6248	{6249		setFoundedFirstCity(false);6250	}62516252	GC.getGame().addDestroyedCityName(pCity->getNameKey());62536254	for(int eBuildingType = 0; eBuildingType < GC.getNumBuildingInfos(); eBuildingType++)6255	{6256		CvBuildingEntry* buildingInfo = GC.getBuildingInfo((BuildingTypes) eBuildingType);6257		if(buildingInfo)6258		{6259			// if this building exists6260			int iExists = pCity->GetCityBuildings()->GetNumRealBuilding((BuildingTypes) eBuildingType);6261			int iPreferredPosition = buildingInfo->GetPreferredDisplayPosition();6262			if(iPreferredPosition > 0)6263			{6264				auto_ptr<ICvCity1> pDllCity(new CvDllCity(pCity));62656266				if(iExists > 0)6267				{6268					// kill the wonder6269					GC.GetEngineUserInterface()->AddDeferredWonderCommand(WONDER_REMOVED, pDllCity.get(), (BuildingTypes) eBuildingType, 0);6270				}6271				else6272				{6273					// else if we are currently in the process of building this wonder6274					if(pCity->getProductionBuilding() == eBuildingType)6275					{6276						// kill the half built wonder6277						if(isWorldWonderClass(buildingInfo->GetBuildingClassInfo()))6278						{6279							GC.GetEngineUserInterface()->AddDeferredWonderCommand(WONDER_REMOVED, pDllCity.get(), (BuildingTypes) eBuildingType, 0);6280						}6281					}6282				}6283			}6284		}6285	}62866287	{6288		auto_ptr<ICvCity1> pkDllCity(new CvDllCity(pCity));6289		gDLL->GameplayCitySetDamage(pkDllCity.get(), 0, pCity->getDamage());6290		gDLL->GameplayCityDestroyed(pkDllCity.get(), NO_PLAYER);6291	}62926293	pCity->kill();62946295	if(pPlot)6296	{6297		IDInfoVector currentUnits;6298		if (pPlot->getUnits(&currentUnits) > 0)6299		{6300			for (IDInfoVector::const_iterator itr = currentUnits.begin(); itr != currentUnits.end(); ++itr)6301			{6302				CvUnit* pUnit = ::getUnit(*itr);63036304				if(pUnit && !pPlot->isValidDomainForLocation(*pUnit))6305				{6306					if (!pUnit->jumpToNearestValidPlot())6307						pUnit->kill(false);6308				}6309			}6310		}6311	}6312}

Calls

Called by