//------------------------------------------------------------------------------ void CvDllNetMessageHandler::ResponseEnhanceReligion(PlayerTypes ePlayer, ReligionTypes eReligion, const char* szCustomName, BeliefTypes eBelief1, BeliefTypes eBelief2, int iCityX, int iCityY) { CvGame& kGame(GC.getGame()); CvGameReligions* pkGameReligions(kGame.GetGameReligions()); CvGameReligions::FOUNDING_RESULT eResult = pkGameReligions->CanEnhanceReligion(ePlayer, eReligion, eBelief1, eBelief2); if(eResult == CvGameReligions::FOUNDING_OK) pkGameReligions->EnhanceReligion(ePlayer, eReligion, eBelief1, eBelief2); else { CvGameReligions::NotifyPlayer(ePlayer, eResult); // We don't want them to lose the opportunity to enhance the religion, and the Great Prophet is already gone so just repost the notification CvCity* pkCity = GC.getMap().plot(iCityX, iCityY)->getPlotCity(); CvPlayerAI& kPlayer = GET_PLAYER(ePlayer); if(kPlayer.isHuman() && eResult != CvGameReligions::FOUNDING_NO_RELIGIONS_AVAILABLE && pkCity) { CvNotifications* pNotifications = kPlayer.GetNotifications(); if(pNotifications) { CvString strBuffer = GetLocalizedText("TXT_KEY_NOTIFICATION_ENHANCE_RELIGION"); CvString strSummary = GetLocalizedText("TXT_KEY_NOTIFICATION_SUMMARY_ENHANCE_RELIGION"); #if defined(MOD_API_EXTENSIONS) pNotifications->Add(NOTIFICATION_ENHANCE_RELIGION, strBuffer, strSummary, iCityX, iCityY, eReligion, pkCity->GetID()); #else pNotifications->Add(NOTIFICATION_ENHANCE_RELIGION, strBuffer, strSummary, iCityX, iCityY, -1, pkCity->GetID()); #endif } kPlayer.GetReligions()->SetFoundingReligion(true); } } }
//------------------------------------------------------------------------------ void CvDllNetMessageHandler::ResponseFoundReligion(PlayerTypes ePlayer, ReligionTypes eReligion, const char* szCustomName, BeliefTypes eBelief1, BeliefTypes eBelief2, BeliefTypes eBelief3, BeliefTypes eBelief4, int iCityX, int iCityY) { CvGame& kGame(GC.getGame()); CvGameReligions* pkGameReligions(kGame.GetGameReligions()); CvCity* pkCity = GC.getMap().plot(iCityX, iCityY)->getPlotCity(); if(pkCity && ePlayer != NO_PLAYER) { CvGameReligions::FOUNDING_RESULT eResult = pkGameReligions->CanFoundReligion(ePlayer, eReligion, szCustomName, eBelief1, eBelief2, eBelief3, eBelief4, pkCity); if(eResult == CvGameReligions::FOUNDING_OK) pkGameReligions->FoundReligion(ePlayer, eReligion, szCustomName, eBelief1, eBelief2, eBelief3, eBelief4, pkCity); else { CvGameReligions::NotifyPlayer(ePlayer, eResult); // We don't want them to lose the opportunity to found the religion, and the Great Prophet is already gone so just repost the notification // If someone beat them to the last religion, well... tough luck. CvPlayerAI& kPlayer = GET_PLAYER(ePlayer); if(kPlayer.isHuman() && eResult != CvGameReligions::FOUNDING_NO_RELIGIONS_AVAILABLE) { CvNotifications* pNotifications = kPlayer.GetNotifications(); if(pNotifications) { CvString strBuffer = GetLocalizedText("TXT_KEY_NOTIFICATION_FOUND_RELIGION"); CvString strSummary = GetLocalizedText("TXT_KEY_NOTIFICATION_SUMMARY_FOUND_RELIGION"); pNotifications->Add(NOTIFICATION_FOUND_RELIGION, strBuffer, strSummary, iCityX, iCityY, -1, pkCity->GetID()); } kPlayer.GetReligions()->SetFoundingReligion(true); } } } }
bool QuietDiplomacy::LeaderDiscussion(CvPlayer* human, CvPlayer* computer, const char* text) { CvAssertMsg(human && computer && text, "Quiet Diplomacy: Assertion error!"); CvAssertMsg(human->isHuman(), "Quiet Diplomacy: Not a human!"); // Send a notification. CvNotifications* notifications = human->GetNotifications(); if(notifications) { // Create localized strings. // Hardcode some translation strings so DLL can be used alone without XML texts. std::string language = Localization::GetCurrentLanguage().GetType(); std::string message; std::string summary; if(DoesTextKeyExist("TXT_KEY_QUIETDIPLOMACY_LEADERDISCUSSION_SUMMARY") && DoesTextKeyExist("TXT_KEY_QUIETDIPLOMACY_LEADERDISCUSSION_MESSAGE")) { // Fetch from the database. Localization::String localeSummary = Localization::Lookup("TXT_KEY_QUIETDIPLOMACY_LEADERDISCUSSION_SUMMARY"); localeSummary << Localization::Lookup(computer->getNameKey()); Localization::String localeMessage = Localization::Lookup("TXT_KEY_QUIETDIPLOMACY_LEADERDISCUSSION_MESSAGE"); localeMessage << Localization::Lookup(computer->getNameKey()); localeMessage << text; summary = localeSummary.toUTF8(); message = localeMessage.toUTF8(); } else { if(language == "pl_PL") { // Polish Localization::String localeLeader = Localization::Lookup(computer->getNameKey()); size_t localeLeaderBytes = 0; const char* localeLeaderString = localeLeader.toUTF8(localeLeaderBytes, 2); summary += "Wiadomo\xc5\x9b\xc4\x87 od "; summary.append(localeLeaderString, localeLeaderBytes); message += Localization::Lookup(computer->getNameKey()).toUTF8(); message += ": "; message += text; } else { // English summary += "Message from "; summary += Localization::Lookup(computer->getNameKey()).toUTF8(); message += Localization::Lookup(computer->getNameKey()).toUTF8(); message += ": "; message += text; } } // Get computer's capital. int x = -1; int y = -1; CvCity* computerCapital = computer->getCapitalCity(); if(computerCapital && computerCapital->isRevealed(human->getTeam(), false)) { x = computerCapital->getX(); y = computerCapital->getY(); } // Add a notification. notifications->Add(NOTIFICATION_PEACE_ACTIVE_PLAYER, message.c_str(), summary.c_str(), x, y, computer->GetID()); } // Inform that we took care of it. return true; }