Hooks
static bool BeforeCvDiplomacyAI_SetDoFAccepted(CvDiplomacyAI* self, PlayerTypes ePlayer, bool bValue);static void AfterCvDiplomacyAI_SetDoFAccepted(CvDiplomacyAI* self, PlayerTypes ePlayer, bool bValue);static void ReplaceCvDiplomacyAI_SetDoFAccepted(void (*original)(CvDiplomacyAI*, PlayerTypes, bool), CvDiplomacyAI* self, PlayerTypes ePlayer, bool bValue);CivRegisterBefore<CivHooks::CvDiplomacyAI_SetDoFAccepted>(host, &BeforeCvDiplomacyAI_SetDoFAccepted);CivRegisterAfter<CivHooks::CvDiplomacyAI_SetDoFAccepted>(host, &AfterCvDiplomacyAI_SetDoFAccepted);CivRegisterReplace<CivHooks::CvDiplomacyAI_SetDoFAccepted>(host, &ReplaceCvDiplomacyAI_SetDoFAccepted);
Code
21229void CvDiplomacyAI::SetDoFAccepted(PlayerTypes ePlayer, bool bValue)21230{21231 CvAssertMsg(ePlayer >= 0, "DIPLOMACY_AI: Invalid Player Index. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");21232 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.");2123321234 if(bValue != IsDoFAccepted(ePlayer))21235 {21236 m_pabDoFAccepted[ePlayer] = bValue;2123721238 m_pPlayer->recomputeGreatPeopleModifiers();2123921240 if(bValue){21241 // Someone made a DoF, send out notifications to everyone21242 Localization::String strText = Localization::Lookup("TXT_KEY_NOTIFICATION_DOF");21243 Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_DOF_S");21244 for(int iCurPlayer = 0; iCurPlayer < MAX_MAJOR_CIVS; ++iCurPlayer){21245 PlayerTypes eCurPlayer = (PlayerTypes) iCurPlayer;21246 CvPlayerAI& kCurPlayer = GET_PLAYER(eCurPlayer);21247 CvNotifications* pNotifications = GET_PLAYER(eCurPlayer).GetNotifications();21248 if(iCurPlayer != ePlayer && iCurPlayer !=GetPlayer()->GetID() && pNotifications){21249 const char* strThisPlayerName;21250 const char* strOtherPlayerName;2125121252 CvTeam* pCurTeam = &GET_TEAM(kCurPlayer.getTeam());2125321254 // Have we met these guys yet?21255 bool bHasMetThisTeam = pCurTeam->isHasMet(GetPlayer()->getTeam());21256 if(bHasMetThisTeam)21257 strThisPlayerName = GetPlayer()->getCivilizationShortDescriptionKey();21258 else21259 strThisPlayerName = "TXT_KEY_UNMET_PLAYER";2126021261 bool bHasMetOtherTeam = pCurTeam->isHasMet(GET_PLAYER(ePlayer).getTeam());21262 if(bHasMetOtherTeam)21263 strOtherPlayerName = GET_PLAYER(ePlayer).getCivilizationShortDescriptionKey();21264 else21265 strOtherPlayerName = "TXT_KEY_UNMET_PLAYER";2126621267 //Only display notification if we've met one of the players.21268 if(bHasMetThisTeam || bHasMetOtherTeam){21269 Localization::String tempInfoStr = strText;21270 tempInfoStr << strThisPlayerName << strOtherPlayerName;21271 Localization::String tempSummaryStr = strSummary;21272 tempSummaryStr << strThisPlayerName << strOtherPlayerName;21273 pNotifications->Add(NOTIFICATION_DIPLOMACY_DECLARATION, tempInfoStr.toUTF8(), tempSummaryStr.toUTF8(), -1, -1, GetPlayer()->GetID(), ePlayer);21274 }21275 }21276 }21277 }21278 }21279}