Hooks
static bool BeforeCvGameReligions_EnhanceReligion(CvGameReligions* self, PlayerTypes ePlayer, ReligionTypes eReligion, BeliefTypes eBelief1, BeliefTypes eBelief2, bool bNotify);static void AfterCvGameReligions_EnhanceReligion(CvGameReligions* self, PlayerTypes ePlayer, ReligionTypes eReligion, BeliefTypes eBelief1, BeliefTypes eBelief2, bool bNotify);static void ReplaceCvGameReligions_EnhanceReligion(void (*original)(CvGameReligions*, PlayerTypes, ReligionTypes, BeliefTypes, BeliefTypes, bool), CvGameReligions* self, PlayerTypes ePlayer, ReligionTypes eReligion, BeliefTypes eBelief1, BeliefTypes eBelief2, bool bNotify);CivRegisterBefore<CivHooks::CvGameReligions_EnhanceReligion>(host, &BeforeCvGameReligions_EnhanceReligion);CivRegisterAfter<CivHooks::CvGameReligions_EnhanceReligion>(host, &AfterCvGameReligions_EnhanceReligion);CivRegisterReplace<CivHooks::CvGameReligions_EnhanceReligion>(host, &ReplaceCvGameReligions_EnhanceReligion);
Code
1296/// Add new beliefs to an existing religion1297#if defined(MOD_API_RELIGION)1298void CvGameReligions::EnhanceReligion(PlayerTypes ePlayer, ReligionTypes eReligion, BeliefTypes eBelief1, BeliefTypes eBelief2, bool bNotify)1299#else1300void CvGameReligions::EnhanceReligion(PlayerTypes ePlayer, ReligionTypes eReligion, BeliefTypes eBelief1, BeliefTypes eBelief2)1301#endif1302{1303 bool bFoundIt = false;1304 CvPlayer& kPlayer = GET_PLAYER(ePlayer);1305 ReligionList::iterator it;1306 for(it = m_CurrentReligions.begin(); it != m_CurrentReligions.end(); it++)1307 {1308#if defined(MOD_API_RELIGION)1309 // We use the same code for enhancing a pantheon, so make sure we find the pantheon for the player!1310 if(it->m_eReligion == eReligion && it->m_eReligion == RELIGION_PANTHEON)1311 {1312 if(it->m_eFounder == ePlayer)1313 {1314 bFoundIt = true;1315 break;1316 }1317 }1318 else 1319#endif1320 if(it->m_eReligion == eReligion)1321 {1322 bFoundIt = true;1323 break;1324 }1325 }1326 if(!bFoundIt)1327 {1328 CvAssertMsg(false, "Internal error in religion code.");1329 CUSTOMLOG("Trying to enhance a religion/pantheon that doesn't exist!!!");1330 return;1331 }13321333 it->m_Beliefs.AddBelief(eBelief1);1334#if defined(MOD_API_RELIGION)1335 if(eBelief2 != NO_BELIEF)1336#endif1337 it->m_Beliefs.AddBelief(eBelief2);13381339#if defined(MOD_API_RELIGION)1340 if(eReligion != RELIGION_PANTHEON)1341#endif1342 it->m_bEnhanced = true;13431344#if defined(MOD_TRAITS_OTHER_PREREQS)1345 if (MOD_TRAITS_OTHER_PREREQS) {1346 // Update our traits (some may have become obsolete)1347 kPlayer.GetPlayerTraits()->Reset();1348 kPlayer.GetPlayerTraits()->InitPlayerTraits();1349 kPlayer.recomputePolicyCostModifier();1350 }1351#endif13521353 // Update game systems1354 UpdateAllCitiesThisReligion(eReligion);1355 kPlayer.UpdateReligion();13561357#if defined(MOD_EVENTS_FOUND_RELIGION)1358 if (MOD_EVENTS_FOUND_RELIGION) {1359 GAMEEVENTINVOKE_HOOK(GAMEEVENT_ReligionEnhanced, ePlayer, eReligion, eBelief1, eBelief2);1360 } else {1361#endif1362 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();1363 if(pkScriptSystem) 1364 {1365 CvLuaArgsHandle args;1366 args->Push(ePlayer);1367 args->Push(eReligion);1368 args->Push(eBelief1);1369 args->Push(eBelief2);13701371 bool bResult;1372 LuaSupport::CallHook(pkScriptSystem, "ReligionEnhanced", args.get(), bResult);1373 }1374#if defined(MOD_EVENTS_FOUND_RELIGION)1375 }1376#endif13771378#if defined(MOD_API_RELIGION)1379 if (bNotify) {1380#endif1381 //Notify the masses1382 for(int iNotifyLoop = 0; iNotifyLoop < MAX_MAJOR_CIVS; ++iNotifyLoop){1383 PlayerTypes eNotifyPlayer = (PlayerTypes) iNotifyLoop;1384 CvPlayerAI& kNotifyPlayer = GET_PLAYER(eNotifyPlayer);1385 CvNotifications* pNotifications = kNotifyPlayer.GetNotifications();1386 if(pNotifications){1387#if defined(MOD_API_RELIGION)1388 Localization::String strSummary;1389 Localization::String notificationText;1390 if (eReligion == RELIGION_PANTHEON) {1391 strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_PANTHEON_ENHANCED_S");1392 notificationText = Localization::Lookup("TXT_KEY_NOTIFICATION_PANTHEON_ENHANCED");1393 notificationText << kPlayer.getCivilizationShortDescriptionKey();1394 } else {1395 strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_RELIGION_ENHANCED_S");1396 notificationText = Localization::Lookup("TXT_KEY_NOTIFICATION_RELIGION_ENHANCED");1397 notificationText << kPlayer.getCivilizationShortDescriptionKey() << it->GetName();1398 }1399#else1400 Localization::String strSummary = Localization::Lookup("TXT_KEY_NOTIFICATION_RELIGION_ENHANCED_S");1401 Localization::String notificationText = Localization::Lookup("TXT_KEY_NOTIFICATION_RELIGION_ENHANCED");1402 notificationText << kPlayer.getCivilizationShortDescriptionKey() << it->GetName();1403#endif14041405 // Message slightly different for enhancing player1406 if(ePlayer == eNotifyPlayer)1407 {1408#if defined(MOD_API_RELIGION)1409 Localization::String localizedText;1410 if (eReligion == RELIGION_PANTHEON) {1411 localizedText = Localization::Lookup("TXT_KEY_NOTIFICATION_PANTHEON_ENHANCED_ACTIVE_PLAYER");1412 } else {1413 localizedText = Localization::Lookup("TXT_KEY_NOTIFICATION_RELIGION_ENHANCED_ACTIVE_PLAYER");1414 localizedText << it->GetName();1415 }1416#else1417 Localization::String localizedText = Localization::Lookup("TXT_KEY_NOTIFICATION_RELIGION_ENHANCED_ACTIVE_PLAYER");1418 localizedText << it->GetName();1419#endif14201421#if defined(MOD_API_EXTENSIONS)1422 pNotifications->Add(NOTIFICATION_RELIGION_ENHANCED_ACTIVE_PLAYER, localizedText.toUTF8(), strSummary.toUTF8(), -1, -1, eReligion, -1);1423#else1424 pNotifications->Add(NOTIFICATION_RELIGION_ENHANCED_ACTIVE_PLAYER, localizedText.toUTF8(), strSummary.toUTF8(), -1, -1, -1);1425#endif1426 }1427 else1428 {1429 CvTeam& kNotifyTeam = GET_TEAM(kNotifyPlayer.getTeam());1430 if(kNotifyTeam.isHasMet(kPlayer.getTeam()))1431 {1432#if defined(MOD_API_EXTENSIONS)1433 pNotifications->Add(NOTIFICATION_RELIGION_ENHANCED, notificationText.toUTF8(), strSummary.toUTF8(), -1, -1, eReligion, -1);1434#else1435 pNotifications->Add(NOTIFICATION_RELIGION_ENHANCED, notificationText.toUTF8(), strSummary.toUTF8(), -1, -1, -1);1436#endif1437 }1438 else1439 {1440#if defined(MOD_API_RELIGION)1441 Localization::String unknownText;1442 if (eReligion == RELIGION_PANTHEON) {1443 unknownText = Localization::Lookup("TXT_KEY_NOTIFICATION_PANTHEON_ENHANCED_UNKNOWN");1444 } else {1445 unknownText = Localization::Lookup("TXT_KEY_NOTIFICATION_RELIGION_ENHANCED_UNKNOWN");1446 unknownText << it->GetName();1447 }1448#else1449 Localization::String unknownText = Localization::Lookup("TXT_KEY_NOTIFICATION_RELIGION_ENHANCED_UNKNOWN");1450 unknownText << it->GetName();1451#endif14521453#if defined(MOD_API_EXTENSIONS)1454 pNotifications->Add(NOTIFICATION_RELIGION_ENHANCED, unknownText.toUTF8(), strSummary.toUTF8(), -1, -1, eReligion, -1);1455#else1456 pNotifications->Add(NOTIFICATION_RELIGION_ENHANCED, unknownText.toUTF8(), strSummary.toUTF8(), -1, -1, -1);1457#endif1458 }1459 }1460 }14611462 // Logging1463 if(GC.getLogging())1464 {1465 CvString strLogMsg;1466 strLogMsg = kPlayer.getCivilizationShortDescription();1467 strLogMsg += ", RELIGION ENHANCED";1468 LogReligionMessage(strLogMsg);1469 }1470 }1471#if defined(MOD_API_RELIGION)1472 }1473#endif14741475 GC.GetEngineUserInterface()->setDirty(CityInfo_DIRTY_BIT, true);1476}