Code
2780/// ProcessSpyMessages - This is called at the beginning of the player's turn and takes the messages queued up and sends them to the notification system. It then clears the list.2781void CvPlayerEspionage::ProcessSpyMessages()2782{2783 CvNotifications* pNotifications = m_pPlayer->GetNotifications();2784 if(!pNotifications)2785 {2786 m_aSpyNotificationMessages.clear();2787 return;2788 }27892790 bool bMultiplayer = GC.getGame().countHumanPlayersEverAlive() > 1;2791 CvEspionageAI* pEspionageAI = m_pPlayer->GetEspionageAI();27922793 for(uint ui = 0; ui < m_aSpyNotificationMessages.size(); ui++)2794 {2795 CvPlot* pPlot = GC.getMap().plot(m_aSpyNotificationMessages[ui].m_iCityX, m_aSpyNotificationMessages[ui].m_iCityY);2796 CvCity* pCity = NULL;2797 CvCityEspionage* pCityEspionage = NULL;2798 CvAssertMsg(pPlot, "Could not find plot location for SpyNotificationMessages");2799 if(pPlot)2800 {2801 pCity = pPlot->getPlotCity();2802 CvAssertMsg(pCity, "Plot does not contain a city");2803 if(pCity)2804 {2805 CvAssertMsg(pCity->getOwner() == m_pPlayer->GetID(), "City does not belong to player. This is very strange");2806 pCityEspionage = pCity->GetCityEspionage();2807 }2808 }28092810 if(!pCity || !pCityEspionage)2811 {2812 continue;2813 }28142815 CvTechEntry* pTechEntry = NULL;2816 if(m_aSpyNotificationMessages[ui].m_eStolenTech != NO_TECH)2817 {2818 pTechEntry = GC.getTechInfo(m_aSpyNotificationMessages[ui].m_eStolenTech);2819 }28202821 if(bMultiplayer || !pTechEntry)2822 {2823 switch(m_aSpyNotificationMessages[ui].m_iSpyResult)2824 {2825 case SPY_RESULT_UNDETECTED:2826 // do nothing2827 break;2828 case SPY_RESULT_DETECTED:2829 // notify defending player that a spy of unknown origin stole something2830 {2831 Localization::String strSummary = GetLocalizedText("TXT_KEY_NOTIFICATION_TECH_STOLEN_SPY_DETECTED_WO_TECH_S");;2832 Localization::String strNotification;28332834 if(pCityEspionage->m_aiSpyAssignment[m_pPlayer->GetID()] == -1)2835 {2836 strNotification = Localization::Lookup("TXT_KEY_NOTIFICATION_TECH_STOLEN_SPY_DETECTED_WO_TECH_W_TIP");2837 }2838 else2839 {2840 strNotification = Localization::Lookup("TXT_KEY_NOTIFICATION_TECH_STOLEN_SPY_DETECTED_WO_TECH");2841 }2842 strNotification << pCity->getNameKey();2843 pNotifications->Add(NOTIFICATION_TECH_STOLEN_SPY_DETECTED, strNotification.toUTF8(), strSummary.toUTF8(), -1, -1, -1);2844 }2845 break;2846 case SPY_RESULT_IDENTIFIED:2847 // notify defending player that a spy of known origin stole something2848 {2849 Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_TECH_STOLEN_SPY_IDENTIFIED_WO_TECH_S");2850 strSummary << GET_PLAYER(m_aSpyNotificationMessages[ui].m_eAttackingPlayer).getCivilizationInfo().getShortDescriptionKey();2851 Localization::String strNotification;28522853 if(pCityEspionage->m_aiSpyAssignment[m_pPlayer->GetID()] == -1)2854 {2855 strNotification = Localization::Lookup("TXT_KEY_NOTIFICATION_TECH_STOLEN_SPY_IDENTIFIED_WO_TECH_W_TIP");2856 }2857 else2858 {2859 strNotification = Localization::Lookup("TXT_KEY_NOTIFICATION_TECH_STOLEN_SPY_IDENTIFIED_WO_TECH");2860 }2861 strNotification << GET_PLAYER(m_aSpyNotificationMessages[ui].m_eAttackingPlayer).getCivilizationInfo().getAdjectiveKey();2862 strNotification << pCity->getNameKey();2863 pNotifications->Add(NOTIFICATION_TECH_STOLEN_SPY_IDENTIFIED, strNotification.toUTF8(), strSummary.toUTF8(), -1, -1, m_aSpyNotificationMessages[ui].m_eAttackingPlayer);2864 }2865 break;2866 case SPY_RESULT_KILLED:2867 // notify defending player that they killed a spy2868 {2869 int iDefendingSpy = pCityEspionage->m_aiSpyAssignment[m_pPlayer->GetID()];2870 CvAssertMsg(iDefendingSpy >= 0, "iDefendingSpy value is out of bounds");2871 if(iDefendingSpy >= 0)2872 {2873 Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_KILLED_A_SPY_S");2874 strSummary << GET_PLAYER(m_aSpyNotificationMessages[ui].m_eAttackingPlayer).getCivilizationAdjectiveKey();2875 Localization::String strNotification = Localization::Lookup("TXT_KEY_NOTIFICATION_KILLED_A_SPY");2876 strNotification << GetSpyRankName(m_aSpyList[iDefendingSpy].m_eRank);2877#if defined(MOD_BUGFIX_SPY_NAMES)2878 strNotification << m_aSpyList[iDefendingSpy].GetSpyName(m_pPlayer);2879#else2880 strNotification << m_pPlayer->getCivilizationInfo().getSpyNames(m_aSpyList[iDefendingSpy].m_iName);2881#endif2882 strNotification << GET_PLAYER(m_aSpyNotificationMessages[ui].m_eAttackingPlayer).getCivilizationAdjectiveKey();2883 strNotification << pCity->getNameKey();28842885 pNotifications->Add(NOTIFICATION_SPY_KILLED_A_SPY, strNotification.toUTF8(), strSummary.toUTF8(), -1, -1, m_aSpyNotificationMessages[ui].m_eAttackingPlayer);2886 2887#if !defined(NO_ACHIEVEMENTS)2888 //Achievements2889 if(m_pPlayer->GetID() == GC.getGame().getActivePlayer())2890 {2891 gDLL->UnlockAchievement(ACHIEVEMENT_XP1_15);2892 }2893#endif2894 }2895 }2896 break;2897 }2898 }2899 else2900 {2901 switch(m_aSpyNotificationMessages[ui].m_iSpyResult)2902 {2903 case SPY_RESULT_UNDETECTED:2904 // nothing happens, nobody is notified2905 break;2906 case SPY_RESULT_DETECTED:2907 {2908 // notify defending player that a spy of unknown origin stole a tech2909 Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_TECH_STOLEN_SPY_DETECTED_S");2910 strSummary << pTechEntry->GetDescriptionKey();29112912 Localization::String strNotification;2913 if(pCityEspionage->m_aiSpyAssignment[m_pPlayer->GetID()] == -1) // no defensive spy2914 {2915 strNotification = Localization::Lookup("TXT_KEY_NOTIFICATION_TECH_STOLEN_SPY_DETECTED_W_TIP");2916 }2917 else // defensive spy2918 {2919 strNotification = Localization::Lookup("TXT_KEY_NOTIFICATION_TECH_STOLEN_SPY_DETECTED");2920 }2921 strNotification << pTechEntry->GetDescriptionKey();2922 strNotification << pCity->getNameKey();2923 pNotifications->Add(NOTIFICATION_TECH_STOLEN_SPY_DETECTED, strNotification.toUTF8(), strSummary.toUTF8(), -1, -1, -1);2924 }2925 break;2926 case SPY_RESULT_IDENTIFIED:2927 {2928 Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_TECH_STOLEN_SPY_IDENTIFIED_S");2929 strSummary << GET_PLAYER(m_aSpyNotificationMessages[ui].m_eAttackingPlayer).getCivilizationInfo().getShortDescriptionKey();2930 strSummary << pTechEntry->GetDescriptionKey();29312932 Localization::String strNotification;2933 if(pCityEspionage->m_aiSpyAssignment[m_pPlayer->GetID()] == -1) // no defensive spy2934 {2935 strNotification = Localization::Lookup("TXT_KEY_NOTIFICATION_TECH_STOLEN_SPY_IDENTIFIED_W_TIP");2936 }2937 else2938 {2939 strNotification = Localization::Lookup("TXT_KEY_NOTIFICATION_TECH_STOLEN_SPY_IDENTIFIED");2940 }2941 strNotification << GET_PLAYER(m_aSpyNotificationMessages[ui].m_eAttackingPlayer).getCivilizationInfo().getAdjectiveKey();2942 strNotification << pTechEntry->GetDescriptionKey();2943 strNotification << pCity->getNameKey();2944 pNotifications->Add(NOTIFICATION_TECH_STOLEN_SPY_IDENTIFIED, strNotification.toUTF8(), strSummary.toUTF8(), -1, -1, m_aSpyNotificationMessages[ui].m_eAttackingPlayer);29452946 pEspionageAI->m_aiNumSpiesCaught[m_aSpyNotificationMessages[ui].m_eAttackingPlayer]++;2947 pEspionageAI->m_aiTurnLastSpyCaught[m_aSpyNotificationMessages[ui].m_eAttackingPlayer] = GC.getGame().getGameTurn();2948 }2949 break;2950 case SPY_RESULT_KILLED:2951 // notify defending player that they killed a spy2952 {2953 CvAssertMsg(false, "This code was not expected to be called");2954 }2955 break;2956 }2957 }2958 }29592960 m_aSpyNotificationMessages.clear();2961}