bool __thiscall
GameCore::AI::CongressSupport::ReligiousTarget
(CongressSupport *this,Instance *owner,int outcomeType,GameModifierAnalysis *output)
{
PlayerTypes iOwnerPlayerId;
int iNumFollowingCities;
Religion *pkReligion;
ReligionList *pReligionList;
const_iterator religions_start;
const_iterator religions_end;
Instance *pFounderPlayer;
Stats *pFounderStats;
PlayerTypes iFounderPlayerId;
int iMaxNumFollowingCities;
/* default choice (no religion) */
output->Religion = NO_RELIGION;
pkReligion = GameCore::Game::Religion::Get();
pReligionList = GameCore::Game::Religion::GetReligions(pkReligion);
religions_start = eastl::vector<>::begin(pReligionList);
religions_end = eastl::vector<>::end(pReligionList);
/* this whole block is basically a foreach loop */
if (religions_start != religions_end) {
iMaxNumFollowingCities = 0;
do {
iFounderPlayerId = religions_start->m_eFounder;
iOwnerPlayerId = GameCore::Player::Instance::GetID(owner);
if ((outcomeType == 1) && (iFounderPlayerId == iOwnerPlayerId)) {
output->Religion = religions_start->m_eReligion;
}
else if ((outcomeType == 2) &&
(iFounderPlayerId = religions_start->m_eFounder,
iOwnerPlayerId = GameCore::Player::Instance::GetID(owner),
iFounderPlayerId != iOwnerPlayerId)) {
pFounderPlayer = GameCore::Context::Globals::GetPlayer(religions_start->m_eFounder);
pFounderStats = GameCore::Player::Instance::GetStats(pFounderPlayer);
iNumFollowingCities =
GameCore::Player::Stats::GetNumCitiesFollowingReligion(pFounderStats,true);
if (iMaxNumFollowingCities < iNumFollowingCities) {
output->Religion = religions_start->m_eReligion;
iMaxNumFollowingCities = iNumFollowingCities;
}
}
religions_start = religions_start + 1;
} while (religions_end != religions_start);
}
return output->Religion != NO_RELIGION;
}