CvCityConnections::GetIndexFromCity(CvCity *)
- Defined in
- CvCityConnections.cpp, line 531
- Class
- CvCityConnections
- Hook name
CivHooks::CvCityConnections_GetIndexFromCity
Hooks
static bool BeforeCvCityConnections_GetIndexFromCity(CvCityConnections* self, CvCity* pCity, uint& result);static void AfterCvCityConnections_GetIndexFromCity(CvCityConnections* self, CvCity* pCity, uint& result);static uint ReplaceCvCityConnections_GetIndexFromCity(uint (*original)(CvCityConnections*, CvCity*), CvCityConnections* self, CvCity* pCity);CivRegisterBefore<CivHooks::CvCityConnections_GetIndexFromCity>(host, &BeforeCvCityConnections_GetIndexFromCity);CivRegisterAfter<CivHooks::CvCityConnections_GetIndexFromCity>(host, &AfterCvCityConnections_GetIndexFromCity);CivRegisterReplace<CivHooks::CvCityConnections_GetIndexFromCity>(host, &ReplaceCvCityConnections_GetIndexFromCity);
Code
530/// Get the index value from the city passed in531uint CvCityConnections::GetIndexFromCity(CvCity* pCity)532{533 CvCity* pOtherCity = NULL;534 for(uint ui = 0; ui < m_aiCityPlotIDs.size(); ui++)535 {536 int iPlotIndex = m_aiCityPlotIDs[ui];537 CvPlot* pPlot = GC.getMap().plotByIndex(iPlotIndex);538 CvAssertMsg(pPlot, "invalid plot. whut??");539 if(pPlot)540 {541 pOtherCity = pPlot->getPlotCity();542 CvAssertMsg(pOtherCity, "No city on this plot. Whut?");543544 if(pOtherCity == pCity)545 {546 return ui;547 }548 }549 }550551 CvAssertMsg(false, "City not found");552 return UINT_MAX;553}
Calls
BaseVector::operator[]BaseVector::size- CvGlobals::getMap()
- CvMap::plotByIndex(int) const
- CvPlot::getPlotCity() const