Bazaar developer reference

CvPlayer::DoCityRevolt()

Defined in
CvPlayer.cpp, line 11869
Class
CvPlayer
Hook name
CivHooks::CvPlayer_DoCityRevolt

Hooks

static bool BeforeCvPlayer_DoCityRevolt(CvPlayer* self);static void AfterCvPlayer_DoCityRevolt(CvPlayer* self);static void ReplaceCvPlayer_DoCityRevolt(void (*original)(CvPlayer*), CvPlayer* self);CivRegisterBefore<CivHooks::CvPlayer_DoCityRevolt>(host, &BeforeCvPlayer_DoCityRevolt);CivRegisterAfter<CivHooks::CvPlayer_DoCityRevolt>(host, &AfterCvPlayer_DoCityRevolt);CivRegisterReplace<CivHooks::CvPlayer_DoCityRevolt>(host, &ReplaceCvPlayer_DoCityRevolt);

Code

11868// Fire off a city revolt somewhere11869void CvPlayer::DoCityRevolt()11870{11871	CvCity *pMostUnhappyCity = GetMostUnhappyCity();11872	PlayerTypes eRecipient = GetMostUnhappyCityRecipient();11873	if(pMostUnhappyCity && eRecipient != NO_PLAYER)11874	{11875		CvPlayer &kRecipient = GET_PLAYER(eRecipient);11876		for(int iNotifyLoop = 0; iNotifyLoop < MAX_MAJOR_CIVS; ++iNotifyLoop){11877			PlayerTypes eNotifyPlayer = (PlayerTypes) iNotifyLoop;11878			CvPlayerAI& kCurNotifyPlayer = GET_PLAYER(eNotifyPlayer);11879			CvNotifications* pNotifications = kCurNotifyPlayer.GetNotifications();11880			if(pNotifications)11881			{11882				Localization::String strMessage;11883				if (eNotifyPlayer == GetID())11884				{11885					strMessage = GetLocalizedText("TXT_KEY_NOTIFICATION_CITY_REVOLT", pMostUnhappyCity->getName(), kRecipient.getCivilizationShortDescription());11886				}11887				else11888				{11889					strMessage = GetLocalizedText("TXT_KEY_NOTIFICATION_OTHER_PLAYER_CITY_REVOLT", getCivilizationAdjective(), pMostUnhappyCity->getName(), kRecipient.getCivilizationShortDescription());11890				}11891				Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_CITY_REVOLT_SUMMARY");11892				pNotifications->Add(NOTIFICATION_CITY_REVOLT, strMessage.toUTF8(), strSummary.toUTF8(), pMostUnhappyCity->getX(), pMostUnhappyCity->getY(), -1);11893			}11894		}1189511896		kRecipient.acquireCity(pMostUnhappyCity, false/*bConquest*/, false/*bGift*/);1189711898		// Move Units from player that don't belong here11899		CvPlot *pPlot = pMostUnhappyCity->plot();11900		if(pPlot->getNumUnits() > 0)11901		{11902			// Get the current list of units because we will possibly be moving them out of the plot's list11903			IDInfoVector currentUnits;11904			if (pPlot->getUnits(&currentUnits) > 0)11905			{11906				for(IDInfoVector::const_iterator itr = currentUnits.begin(); itr != currentUnits.end(); ++itr)11907				{11908					CvUnit* pLoopUnit = (CvUnit*)GetPlayerUnit(*itr);1190911910					if(pLoopUnit && pLoopUnit->getOwner() == GetID())11911					{11912						pLoopUnit->finishMoves();11913						if (!pLoopUnit->jumpToNearestValidPlot())11914							pLoopUnit->kill(false);11915					}11916				}11917			}11918		}11919	}11920}

Calls

Called by