Bazaar developer reference

CvDiplomacyAI::DoMakePublicDeclaration(PublicDeclarationTypes, int, int, PlayerTypes, PlayerTypes)

Defined in
CvDiplomacyAI.cpp, line 12433
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_DoMakePublicDeclaration

Hooks

static bool BeforeCvDiplomacyAI_DoMakePublicDeclaration(CvDiplomacyAI* self, PublicDeclarationTypes eDeclaration, int iData1, int iData2, PlayerTypes eMustHaveMetPlayer, PlayerTypes eForSpecificPlayer);static void AfterCvDiplomacyAI_DoMakePublicDeclaration(CvDiplomacyAI* self, PublicDeclarationTypes eDeclaration, int iData1, int iData2, PlayerTypes eMustHaveMetPlayer, PlayerTypes eForSpecificPlayer);static void ReplaceCvDiplomacyAI_DoMakePublicDeclaration(void (*original)(CvDiplomacyAI*, PublicDeclarationTypes, int, int, PlayerTypes, PlayerTypes), CvDiplomacyAI* self, PublicDeclarationTypes eDeclaration, int iData1, int iData2, PlayerTypes eMustHaveMetPlayer, PlayerTypes eForSpecificPlayer);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoMakePublicDeclaration>(host, &BeforeCvDiplomacyAI_DoMakePublicDeclaration);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoMakePublicDeclaration>(host, &AfterCvDiplomacyAI_DoMakePublicDeclaration);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoMakePublicDeclaration>(host, &ReplaceCvDiplomacyAI_DoMakePublicDeclaration);

Code

12432/// Does this AI have something to say to the world this turn?12433void CvDiplomacyAI::DoMakePublicDeclaration(PublicDeclarationTypes eDeclaration, int iData1, int iData2, PlayerTypes eMustHaveMetPlayer, PlayerTypes eForSpecificPlayer)12434{12435	// Don't give Public Declarations if we're a human12436	if(GetPlayer()->isHuman())12437	{12438		return;12439	}1244012441	CvAssertMsg(eDeclaration >= 0, "DIPLOMACY_AI: Invalid PublicDeclarationType.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");12442	CvAssertMsg(eDeclaration < NUM_PUBLIC_DECLARATION_TYPES, "DIPLOMACY_AI: Invalid PublicDeclarationType.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");12443	CvAssertMsg(eForSpecificPlayer >= NO_PLAYER, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");	// We can be sending to no specific player12444	CvAssertMsg(eForSpecificPlayer < MAX_MAJOR_CIVS, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");1244512446	const char* strText = "";12447	//LeaderheadAnimationTypes eAnimation;12448	//DiploUIStateTypes eDiploState = DIPLO_UI_STATE_DEFAULT_ROOT;1244912450	bool bActive = true;1245112452	// We're protecting a Minor Civ, so watch out!12453	if(eDeclaration == PUBLIC_DECLARATION_PROTECT_MINOR)12454	{12455		PlayerTypes eMinorCiv = (PlayerTypes) iData1;12456		const char* strMinorCivKey = GET_PLAYER(eMinorCiv).getNameKey();1245712458		strText = GetDiploStringForMessage(DIPLO_MESSAGE_DECLARATION_PROTECT_CITY_STATE, NO_PLAYER, strMinorCivKey);12459		//eAnimation = LEADERHEAD_ANIM_POSITIVE;12460		//eDiploState = DIPLO_UI_STATE_DISCUSS_PROTECT_MINOR_CIV;12461	}1246212463	// We're no longer protecting a Minor Civ, sorry...12464	if(eDeclaration == PUBLIC_DECLARATION_ABANDON_MINOR)12465	{12466		// Make previous declarations to protect this Minor inactive12467		DoMakeDeclarationInactive(PUBLIC_DECLARATION_PROTECT_MINOR, iData1, iData2);1246812469		// No point in telling new people we JUST meet we're not protecting someone any more...12470		bActive = false;1247112472		PlayerTypes eMinorCiv = (PlayerTypes) iData1;12473		const char* strMinorCivKey = GET_PLAYER(eMinorCiv).getNameKey();1247412475		strText = GetDiploStringForMessage(DIPLO_MESSAGE_DECLARATION_ABANDON_CITY_STATE, NO_PLAYER, strMinorCivKey);12476		//eAnimation = LEADERHEAD_ANIM_POSITIVE;12477	}12478124791248012481	// Should also send to the other AIs here somehow12482124831248412485	// If our declaration is only for a specific player (e.g. we just met them) take that into account12486	if(eForSpecificPlayer != NO_PLAYER)12487	{12488	}1248912490	// Only add this Declaration to the log if it's for everyone, as announcements to specific people are only for catching them up after meeting them later12491	if(eForSpecificPlayer == NO_PLAYER)12492	{12493		DoAddNewDeclarationToLog(eDeclaration, iData1, iData2, eMustHaveMetPlayer, bActive);1249412495		//Send notification to everyone that can get it.12496		for(int iCurPlayer = 0; iCurPlayer < MAX_MAJOR_CIVS; ++iCurPlayer){12497			PlayerTypes eCurPlayer = (PlayerTypes) iCurPlayer;12498			CvPlayerAI& kCurPlayer = GET_PLAYER(eCurPlayer);12499			if(IsPlayerValid(eCurPlayer) 12500				&& (eMustHaveMetPlayer == NO_PLAYER || GET_TEAM(kCurPlayer.getTeam()).isHasMet(GET_PLAYER(eMustHaveMetPlayer).getTeam()))){12501				CvNotifications* pNotifications = GET_PLAYER(eCurPlayer).GetNotifications();12502				if(pNotifications){12503					Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_DIPLOMACY_DECLARATION");12504					strSummary << GetPlayer()->getCivilizationShortDescriptionKey();12505					pNotifications->Add(NOTIFICATION_DIPLOMACY_DECLARATION, strText, strSummary.toUTF8(), -1, -1, -1);12506				}12507			}12508		}12509	}12510	else12511	{12512		//send notification to the specific player.12513		CvPlayerAI& kSpecificPlayer = GET_PLAYER(eForSpecificPlayer);12514		if(IsPlayerValid(eForSpecificPlayer) 12515			&& (eMustHaveMetPlayer == NO_PLAYER || GET_TEAM(kSpecificPlayer.getTeam()).isHasMet(GET_PLAYER(eMustHaveMetPlayer).getTeam()))){	12516			CvNotifications* pNotifications = kSpecificPlayer.GetNotifications();12517			if(pNotifications){12518				Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_DIPLOMACY_DECLARATION");12519				strSummary << GetPlayer()->getCivilizationShortDescriptionKey();12520				pNotifications->Add(NOTIFICATION_DIPLOMACY_DECLARATION, strText, strSummary.toUTF8(), -1, -1, -1);12521			}12522		}12523	}1252412525	LogPublicDeclaration(eDeclaration, iData1, eForSpecificPlayer);12526}

Calls

Called by