Bazaar developer reference

CvMinorCivAI::GetStatusChangeNotificationStrings(PlayerTypes, bool, bool, bool, PlayerTypes, PlayerTypes)

Defined in
CvMinorCivAI.cpp, line 10859
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_GetStatusChangeNotificationStrings

Hooks

static bool BeforeCvMinorCivAI_GetStatusChangeNotificationStrings(CvMinorCivAI* self, PlayerTypes ePlayer, bool bAdd, bool bFriends, bool bAllies, PlayerTypes eOldAlly, PlayerTypes eNewAlly, pair<CvString, CvString>& result);static void AfterCvMinorCivAI_GetStatusChangeNotificationStrings(CvMinorCivAI* self, PlayerTypes ePlayer, bool bAdd, bool bFriends, bool bAllies, PlayerTypes eOldAlly, PlayerTypes eNewAlly, pair<CvString, CvString>& result);static pair<CvString, CvString> ReplaceCvMinorCivAI_GetStatusChangeNotificationStrings(pair<CvString, CvString> (*original)(CvMinorCivAI*, PlayerTypes, bool, bool, bool, PlayerTypes, PlayerTypes), CvMinorCivAI* self, PlayerTypes ePlayer, bool bAdd, bool bFriends, bool bAllies, PlayerTypes eOldAlly, PlayerTypes eNewAlly);CivRegisterBefore<CivHooks::CvMinorCivAI_GetStatusChangeNotificationStrings>(host, &BeforeCvMinorCivAI_GetStatusChangeNotificationStrings);CivRegisterAfter<CivHooks::CvMinorCivAI_GetStatusChangeNotificationStrings>(host, &AfterCvMinorCivAI_GetStatusChangeNotificationStrings);CivRegisterReplace<CivHooks::CvMinorCivAI_GetStatusChangeNotificationStrings>(host, &ReplaceCvMinorCivAI_GetStatusChangeNotificationStrings);

Code

10859pair<CvString, CvString> CvMinorCivAI::GetStatusChangeNotificationStrings(PlayerTypes ePlayer, bool bAdd, bool bFriends, bool bAllies, PlayerTypes eOldAlly, PlayerTypes eNewAlly)10860{10861	Localization::String strMessage;10862	Localization::String strSummary;1086310864	CvTeam* pTeam = &GET_TEAM(GET_PLAYER(ePlayer).getTeam());10865	CvAssertMsg(pTeam, "pTeam not expected to be NULL. Please send Anton your save file and version.");1086610867	const char* strMinorsNameKey = GetPlayer()->getNameKey();1086810869	// Adding/Increasing bonus10870	if(bAdd)10871	{10872		// Jumped up to Allies (either from Neutral or from Friends, or passing another player)10873		if(bAllies)10874		{10875			// BASE ALLIES MESSAGE1087610877			// No previous Ally (or it was us)10878			if(eOldAlly == NO_PLAYER || eOldAlly == ePlayer)10879			{10880				strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_MINOR_NOW_ALLIES_BASE");10881			}10882			// We're passing someone10883			else10884			{10885				CvAssertMsg(eOldAlly != NO_PLAYER, "eOldAlly not expected to be NO_PLAYER here. Please send Anton your save file and version.");10886				const char* strOldBestPlayersNameKey = "TXT_KEY_UNMET_PLAYER";10887				TeamTypes eOldAllyTeam = GET_PLAYER(eOldAlly).getTeam();10888				if(pTeam->isHasMet(eOldAllyTeam))10889					strOldBestPlayersNameKey = GET_PLAYER(eOldAlly).getCivilizationShortDescriptionKey();1089010891				strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_MINOR_NOW_ALLIES_BASE_PASSED");10892				strMessage << strOldBestPlayersNameKey;10893			}1089410895			strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_MINOR_ALLIES_STATUS");1089610897			// Build Resource info10898			int iNumResourceTypes = 0;10899			FStaticVector<ResourceTypes, 64, true, c_eCiv5GameplayDLL, 0> veResources;10900			ResourceTypes eResource;10901			ResourceUsageTypes eUsage;10902			int iResourceQuantity;10903			for(int iResourceLoop = 0; iResourceLoop < GC.getNumResourceInfos(); iResourceLoop++)10904			{10905				eResource = (ResourceTypes) iResourceLoop;10906				iResourceQuantity = GetPlayer()->getNumResourceTotal(eResource);1090710908				if(iResourceQuantity > 0)10909				{10910					const CvResourceInfo* pkResourceInfo = GC.getResourceInfo(eResource);					10911					if (pkResourceInfo != NULL)10912					{10913						eUsage = GC.getResourceInfo(eResource)->getResourceUsage();1091410915						if(eUsage == RESOURCEUSAGE_STRATEGIC || eUsage == RESOURCEUSAGE_LUXURY)10916						{10917							veResources.push_back(eResource);10918							iNumResourceTypes++;10919						}10920					}10921				}10922			}10923			// APPEND RESOURCE INFO10924			Localization::String strResourceDetails;10925			if(iNumResourceTypes == 0)10926			{10927				strResourceDetails = Localization::Lookup("TXT_KEY_NOTIFICATION_MINOR_GAINED_BEST_RELATIONS_BONUS_NONE");10928				strResourceDetails << strMinorsNameKey;10929			}10930			else10931			{10932				CvString strResourceNames = GC.getResourceInfo(veResources[0])->GetDescription();10933				int i = 1;10934				while(i < iNumResourceTypes)10935				{10936					strResourceNames += ", ";10937					strResourceNames += GC.getResourceInfo(veResources[i++])->GetDescription();10938				}1093910940				strResourceDetails = Localization::Lookup("TXT_KEY_NOTIFICATION_MINOR_GAINED_BEST_RELATIONS_BONUS_SOME");10941				strResourceDetails << strResourceNames.c_str();10942			}10943			strMessage << strResourceDetails.toUTF8();10944		}10945		// Went from Neutral to Friends10946		else if(bFriends)10947		{10948			strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_MINOR_NOW_FRIENDS_BASE");10949			strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_MINOR_FRIENDS_STATUS");10950		}10951	}10952	// Removing/Reducing bonus10953	else10954	{10955		// Dropped from Allies10956		if(bAllies)10957		{10958			// Normal friendship decay10959			if(eNewAlly == NO_PLAYER)10960			{10961				strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_MINOR_ALLIES_LOST");10962				strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_MINOR_ALLIES_STATUS_LOST");10963			}10964			// Someone passed us up10965			else10966			{10967				CvAssertMsg(eNewAlly != NO_PLAYER, "eNewAlly not expected to be NO_PLAYER here. Please send Anton your save file and version.");10968				CvAssertMsg(eNewAlly != ePlayer, "eNewAlly not expected to be same as ePlayer here. Please send Anton your save file and version.");10969				const char* strNewBestPlayersNameKey = "TXT_KEY_UNMET_PLAYER";10970				TeamTypes eNewAllyTeam = GET_PLAYER(eNewAlly).getTeam();10971				if(pTeam->isHasMet(eNewAllyTeam))10972					strNewBestPlayersNameKey = GET_PLAYER(eNewAlly).getCivilizationShortDescriptionKey();1097310974				strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_MINOR_ALLIES_PASSED");10975				strMessage << strNewBestPlayersNameKey;10976				strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_MINOR_ALLIES_STATUS_PASSED");10977				strSummary << strNewBestPlayersNameKey;10978			}10979		}10980		// Dropped down to Neutral from Friends (case of Allies down to Neutral not handled well... let's hope it doesn't happen often!)10981		else if(bFriends)10982		{10983			strMessage = Localization::Lookup("TXT_KEY_NOTIFICATION_MINOR_FRIENDS_LOST_BASE");10984			strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_SUMMARY_MINOR_FRIENDS_STATUS_LOST");10985		}10986	}1098710988	CvString strDetailedInfo = GetStatusChangeDetails(ePlayer, bAdd, bFriends, bAllies);10989	strMessage << GetPlayer()->getNameKey() << strDetailedInfo;10990	strSummary << GetPlayer()->getNameKey();1099110992	pair<CvString, CvString> notifStrings = pair<CvString, CvString>(strMessage.toUTF8(), strSummary.toUTF8());10993	return notifStrings;10994}

Calls

Called by