Hooks
static bool BeforeCvGameReligions_AddReformationBelief(CvGameReligions* self, PlayerTypes ePlayer, ReligionTypes eReligion, BeliefTypes eBelief1);static void AfterCvGameReligions_AddReformationBelief(CvGameReligions* self, PlayerTypes ePlayer, ReligionTypes eReligion, BeliefTypes eBelief1);static void ReplaceCvGameReligions_AddReformationBelief(void (*original)(CvGameReligions*, PlayerTypes, ReligionTypes, BeliefTypes), CvGameReligions* self, PlayerTypes ePlayer, ReligionTypes eReligion, BeliefTypes eBelief1);CivRegisterBefore<CivHooks::CvGameReligions_AddReformationBelief>(host, &BeforeCvGameReligions_AddReformationBelief);CivRegisterAfter<CivHooks::CvGameReligions_AddReformationBelief>(host, &AfterCvGameReligions_AddReformationBelief);CivRegisterReplace<CivHooks::CvGameReligions_AddReformationBelief>(host, &ReplaceCvGameReligions_AddReformationBelief);
Code
1512/// Add an extra belief to a religion (through a policy)1513void CvGameReligions::AddReformationBelief(PlayerTypes ePlayer, ReligionTypes eReligion, BeliefTypes eBelief1)1514{1515 bool bFoundIt = false;1516 CvPlayer& kPlayer = GET_PLAYER(ePlayer);1517 ReligionList::iterator it;1518 for(it = m_CurrentReligions.begin(); it != m_CurrentReligions.end(); it++)1519 {1520 if(it->m_eReligion == eReligion)1521 {1522 bFoundIt = true;1523 break;1524 }1525 }1526 if(!bFoundIt)1527 {1528 CvAssertMsg(false, "Internal error in religion code.");1529 return;1530 }15311532 it->m_Beliefs.AddBelief(eBelief1);15331534#if defined(MOD_TRAITS_OTHER_PREREQS)1535 if (MOD_TRAITS_OTHER_PREREQS) {1536 // Update our traits (some may have become obsolete)1537 kPlayer.GetPlayerTraits()->Reset();1538 kPlayer.GetPlayerTraits()->InitPlayerTraits();1539 kPlayer.recomputePolicyCostModifier();1540 }1541#endif15421543 // Update game systems1544 UpdateAllCitiesThisReligion(eReligion);1545 kPlayer.UpdateReligion();15461547#if defined(MOD_EVENTS_FOUND_RELIGION)1548 if (MOD_EVENTS_FOUND_RELIGION) {1549 GAMEEVENTINVOKE_HOOK(GAMEEVENT_ReligionReformed, ePlayer, eReligion, eBelief1);1550 }1551#endif15521553 //Notify the masses1554 for(int iNotifyLoop = 0; iNotifyLoop < MAX_MAJOR_CIVS; ++iNotifyLoop){1555 PlayerTypes eNotifyPlayer = (PlayerTypes) iNotifyLoop;1556 CvPlayerAI& kNotifyPlayer = GET_PLAYER(eNotifyPlayer);1557 CvNotifications* pNotifications = kNotifyPlayer.GetNotifications();1558 if(pNotifications){1559 Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_REFORMATION_BELIEF_ADDED_S");1560 Localization::String notificationText = Localization::Lookup("TXT_KEY_NOTIFICATION_REFORMATION_BELIEF_ADDED");1561 notificationText << kPlayer.getCivilizationShortDescriptionKey() << it->GetName();15621563 // Message slightly different for reformation player1564 if(ePlayer == eNotifyPlayer)1565 {1566 Localization::String localizedText = Localization::Lookup("TXT_KEY_NOTIFICATION_REFORMATION_BELIEF_ADDED_ACTIVE_PLAYER");1567 localizedText << it->GetName();15681569 pNotifications->Add(NOTIFICATION_REFORMATION_BELIEF_ADDED_ACTIVE_PLAYER, localizedText.toUTF8(), strSummary.toUTF8(), -1, -1, -1);1570 }1571 else1572 {1573 CvTeam& kNotifyTeam = GET_TEAM(kNotifyPlayer.getTeam());1574 if(kNotifyTeam.isHasMet(kPlayer.getTeam()))1575 {1576 pNotifications->Add(NOTIFICATION_REFORMATION_BELIEF_ADDED, notificationText.toUTF8(), strSummary.toUTF8(), -1, -1, -1);1577 }1578 else1579 {1580 Localization::String unknownText = Localization::Lookup("TXT_KEY_NOTIFICATION_REFORMATION_BELIEF_ADDED_UNKNOWN");1581 unknownText << it->GetName();15821583 pNotifications->Add(NOTIFICATION_REFORMATION_BELIEF_ADDED, unknownText.toUTF8(), strSummary.toUTF8(), -1, -1, -1);1584 }1585 }1586 }15871588 // Logging1589 if(GC.getLogging())1590 {1591 CvString strLogMsg;1592 strLogMsg = kPlayer.getCivilizationShortDescription();1593 strLogMsg += ", REFORMATION BELIEF ADDED";1594 LogReligionMessage(strLogMsg);1595 }1596 }1597 GC.GetEngineUserInterface()->setDirty(CityInfo_DIRTY_BIT, true);1598}