Bazaar developer reference

CvDiplomacyAI::DoDenouncePlayer(PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 21407
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoDenouncePlayer

Hooks

static bool BeforeCvDiplomacyAI_DoDenouncePlayer(CvDiplomacyAI* self, PlayerTypes ePlayer);static void AfterCvDiplomacyAI_DoDenouncePlayer(CvDiplomacyAI* self, PlayerTypes ePlayer);static void ReplaceCvDiplomacyAI_DoDenouncePlayer(void (*original)(CvDiplomacyAI*, PlayerTypes), CvDiplomacyAI* self, PlayerTypes ePlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoDenouncePlayer>(host, &BeforeCvDiplomacyAI_DoDenouncePlayer);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoDenouncePlayer>(host, &AfterCvDiplomacyAI_DoDenouncePlayer);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoDenouncePlayer>(host, &ReplaceCvDiplomacyAI_DoDenouncePlayer);

Code

21407void CvDiplomacyAI::DoDenouncePlayer(PlayerTypes ePlayer)21408{21409	CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");21410	CvAssertMsg(ePlayer < MAX_MAJOR_CIVS, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");2141121412	PlayerTypes eMyPlayer = GetPlayer()->GetID();21413	TeamTypes eMyTeam = GetPlayer()->getTeam();21414	TeamTypes eTheirTeam = GET_PLAYER(ePlayer).getTeam();2141521416	SetDenouncedPlayer(ePlayer, true);2141721418	SetDenouncedPlayerCounter(ePlayer, 0);2141921420	// close both embassies21421	GET_TEAM(eMyTeam).CloseEmbassyAtTeam(eTheirTeam);21422	GET_TEAM(eTheirTeam).CloseEmbassyAtTeam(eMyTeam);2142321424	// WAS working with this player21425	if(IsDoFAccepted(ePlayer))21426	{21427		SetDoFAccepted(ePlayer, false);21428		SetDoFCounter(ePlayer, -666);21429		GET_PLAYER(ePlayer).GetDiplomacyAI()->SetDoFAccepted(eMyPlayer, false);21430		GET_PLAYER(ePlayer).GetDiplomacyAI()->SetDoFCounter(eMyPlayer, -666);2143121432		// They now view us as a traitor!21433		GET_PLAYER(ePlayer).GetDiplomacyAI()->SetFriendDenouncedUs(eMyPlayer, true);21434	}2143521436	// Going to war, if so don't pretend to be friendly21437	if(GetWarFaceWithPlayer(ePlayer) == WAR_FACE_FRIENDLY)21438	{21439		SetWarFaceWithPlayer(ePlayer, WAR_FACE_NEUTRAL);21440	}2144121442	// Third party arrangements21443	PlayerTypes eThirdParty;21444	for(int iThirdPartyLoop = 0; iThirdPartyLoop < MAX_MAJOR_CIVS; iThirdPartyLoop++)21445	{21446		eThirdParty = (PlayerTypes) iThirdPartyLoop;2144721448		// WAS in or planning a coop war with the guy we're now at war with21449		if(GetCoopWarAcceptedState(ePlayer, eThirdParty) >= COOP_WAR_STATE_SOON)21450		{21451			SetCoopWarAcceptedState(ePlayer, eThirdParty, NO_COOP_WAR_STATE);21452			SetCoopWarCounter(ePlayer, eThirdParty, -666);21453			GET_PLAYER(ePlayer).GetDiplomacyAI()->SetCoopWarAcceptedState(eMyPlayer, eThirdParty, NO_COOP_WAR_STATE);21454			GET_PLAYER(ePlayer).GetDiplomacyAI()->SetCoopWarCounter(eMyPlayer, eThirdParty, -666);21455		}21456	}2145721458	Localization::String someoneDenounceInfo = Localization::Lookup("TXT_KEY_NOTIFICATION_DENOUNCE");21459	Localization::String someoneDenounceSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_DENOUNCE_S");21460	Localization::String youDenounceInfo = Localization::Lookup("TXT_KEY_NOTIFICATION_YOU_DENOUNCE");21461	Localization::String youDenounceSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_YOU_DENOUNCE_S");21462	Localization::String denounceYouInfo = Localization::Lookup("TXT_KEY_NOTIFICATION_DENOUNCE_YOU");21463	Localization::String denounceYouSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_DENOUNCED_YOU_S");21464	for(int iCurPlayer = 0; iCurPlayer < MAX_MAJOR_CIVS; ++iCurPlayer){21465		PlayerTypes eCurPlayer = (PlayerTypes) iCurPlayer;21466		CvPlayerAI& kCurPlayer = GET_PLAYER(eCurPlayer);21467		CvNotifications* pNotifications = GET_PLAYER(eCurPlayer).GetNotifications();21468		if(pNotifications)21469		{21470			const char* strThisPlayerName;21471			const char* strOtherPlayerName;2147221473			CvTeam* pNotifyTeam = &GET_TEAM(kCurPlayer.getTeam());2147421475			bool bFromMe = GetPlayer()->getTeam() == kCurPlayer.getTeam();21476			bool bAtMe = GET_PLAYER(ePlayer).getTeam() == kCurPlayer.getTeam();2147721478			// Have we met these guys yet?21479			if(!bFromMe)21480			{21481				if(pNotifyTeam->isHasMet(GetPlayer()->getTeam()))21482					strThisPlayerName = GetPlayer()->getCivilizationShortDescriptionKey();21483				else21484					strThisPlayerName = "TXT_KEY_UNMET_PLAYER";21485			}2148621487			if(!bAtMe)21488			{21489				if(pNotifyTeam->isHasMet(GET_PLAYER(ePlayer).getTeam()))21490					strOtherPlayerName = GET_PLAYER(ePlayer).getCivilizationShortDescriptionKey();21491				else21492					strOtherPlayerName = "TXT_KEY_UNMET_PLAYER";21493			}2149421495			Localization::String strText;21496			Localization::String strSummary;2149721498			if(bFromMe)21499			{21500				strText = youDenounceInfo;21501				strText << strOtherPlayerName;21502				strSummary = youDenounceSummary;21503				strSummary << strOtherPlayerName;21504			}21505			else if(bAtMe)21506			{21507				strText = denounceYouInfo;21508				strText << strThisPlayerName;21509				strSummary = denounceYouSummary;21510				strSummary << strThisPlayerName;21511			}21512			else21513			{21514				bool bHasMetThisTeam = pNotifyTeam->isHasMet(GetPlayer()->getTeam());21515				bool bHasMetOtherTeam = pNotifyTeam->isHasMet(GET_PLAYER(ePlayer).getTeam());2151621517				//Only display notification if we've met either team.21518				if(bHasMetThisTeam || bHasMetOtherTeam)21519				{21520					strText = someoneDenounceInfo;21521					strText << strThisPlayerName << strOtherPlayerName;21522					strSummary = someoneDenounceSummary;21523					strSummary << strThisPlayerName << strOtherPlayerName;21524				}21525				else21526				{21527					continue;21528				}21529			}2153021531			pNotifications->Add(NOTIFICATION_DIPLOMACY_DECLARATION, strText.toUTF8(), strSummary.toUTF8(), -1, -1, GetPlayer()->GetID(), ePlayer);21532		}21533	}21534}

Calls

Called by