Bazaar developer reference

CvCityConnections::UpdateCityPlotIDs()

Defined in
CvCityConnections.cpp, line 148
Class
CvCityConnections
Hook name
CivHooks::CvCityConnections_UpdateCityPlotIDs

Hooks

static bool BeforeCvCityConnections_UpdateCityPlotIDs(CvCityConnections* self);static void AfterCvCityConnections_UpdateCityPlotIDs(CvCityConnections* self);static void ReplaceCvCityConnections_UpdateCityPlotIDs(void (*original)(CvCityConnections*), CvCityConnections* self);CivRegisterBefore<CivHooks::CvCityConnections_UpdateCityPlotIDs>(host, &BeforeCvCityConnections_UpdateCityPlotIDs);CivRegisterAfter<CivHooks::CvCityConnections_UpdateCityPlotIDs>(host, &AfterCvCityConnections_UpdateCityPlotIDs);CivRegisterReplace<CivHooks::CvCityConnections_UpdateCityPlotIDs>(host, &ReplaceCvCityConnections_UpdateCityPlotIDs);

Code

147/// Update the city ids to the correct ones148void CvCityConnections::UpdateCityPlotIDs(void)149{150	ResetCityPlotIDs();151	int iIndex = 0;152	int iLoop;153	CvCity* pLoopCity;154155	for(uint ui = 0; ui < MAX_CIV_PLAYERS; ui++)156	{157		PlayerTypes ePlayer = (PlayerTypes)ui;158		if(GET_PLAYER(ePlayer).isBarbarian())159		{160			continue;161		}162163		TeamTypes ePlayerTeam = GET_PLAYER(ePlayer).getTeam();164		TeamTypes eMyPlayerTeam = m_pPlayer->getTeam();165166		if(ePlayerTeam == eMyPlayerTeam)167		{168			// player's city169			for(pLoopCity = GET_PLAYER(ePlayer).firstCity(&iLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(ePlayer).nextCity(&iLoop))170			{171				CvAssertMsg(pLoopCity->plot(), "pLoopCity does not have a plot. What??");172				int iPlotIndex = pLoopCity->plot()->GetPlotIndex();173				m_aiCityPlotIDs.push_back(iPlotIndex);174				iIndex++;175			}176		}177		else if(ShouldConnectToOtherPlayer(ePlayer))178		{179			CvCity* pOtherCapital = GET_PLAYER(ePlayer).getCapitalCity();180			if(pOtherCapital)181			{182				int iPlotIndex = pOtherCapital->plot()->GetPlotIndex();183				m_aiCityPlotIDs.push_back(iPlotIndex);184				iIndex++;185			}186		}187	}188}

Calls

Called by