CvGameReligions::SpreadReligionToOneCity(CvCity *)
- Defined in
- CvReligionClasses.cpp, line 338
- Class
- CvGameReligions
- Hook name
CivHooks::CvGameReligions_SpreadReligionToOneCity
Hooks
static bool BeforeCvGameReligions_SpreadReligionToOneCity(CvGameReligions* self, CvCity* pCity);static void AfterCvGameReligions_SpreadReligionToOneCity(CvGameReligions* self, CvCity* pCity);static void ReplaceCvGameReligions_SpreadReligionToOneCity(void (*original)(CvGameReligions*, CvCity*), CvGameReligions* self, CvCity* pCity);CivRegisterBefore<CivHooks::CvGameReligions_SpreadReligionToOneCity>(host, &BeforeCvGameReligions_SpreadReligionToOneCity);CivRegisterAfter<CivHooks::CvGameReligions_SpreadReligionToOneCity>(host, &AfterCvGameReligions_SpreadReligionToOneCity);CivRegisterReplace<CivHooks::CvGameReligions_SpreadReligionToOneCity>(host, &ReplaceCvGameReligions_SpreadReligionToOneCity);
Code
337/// Spread religious pressure to one city338void CvGameReligions::SpreadReligionToOneCity(CvCity* pCity)339{340 // Used to calculate how many trade routes are applying pressure to this city. This resets the value so we get a true count every turn.341 pCity->GetCityReligions()->ResetNumTradeRoutePressure();342343 // Is this a city where a religion was founded?344 if(pCity->GetCityReligions()->IsHolyCityAnyReligion())345 {346 pCity->GetCityReligions()->AddHolyCityPressure();347 }348349 // Loop through all the players350 for(int iI = 0; iI < MAX_PLAYERS; iI++)351 {352 CvPlayer& kPlayer = GET_PLAYER((PlayerTypes)iI);353 if(kPlayer.isAlive())354 {355 int iSpyPressure = kPlayer.GetReligions()->GetSpyPressure();356 if (iSpyPressure > 0)357 {358 if (kPlayer.GetEspionage()->GetSpyIndexInCity(pCity) != -1)359 {360 ReligionTypes eReligionFounded = kPlayer.GetReligions()->GetReligionCreatedByPlayer();361 pCity->GetCityReligions()->AddSpyPressure(eReligionFounded, iSpyPressure);362 }363 }364365 // Loop through each of their cities366 int iLoop;367 CvCity* pLoopCity;368 for(pLoopCity = kPlayer.firstCity(&iLoop); pLoopCity != NULL; pLoopCity = kPlayer.nextCity(&iLoop))369 {370 // Ignore the same city371 if(pCity == pLoopCity)372 {373 continue;374 }375376 // Does this city have a majority religion?377 ReligionTypes eMajorityReligion = pLoopCity->GetCityReligions()->GetReligiousMajority();378 if(eMajorityReligion == NO_RELIGION)379 {380 continue;381 }382383 int iNumTradeRoutes = 0;384 int iPressure = GetAdjacentCityReligiousPressure (eMajorityReligion, pLoopCity, pCity, iNumTradeRoutes, false);385 if (iPressure > 0)386 {387 pCity->GetCityReligions()->AddReligiousPressure(FOLLOWER_CHANGE_ADJACENT_PRESSURE, eMajorityReligion, iPressure);388 if (iNumTradeRoutes != 0)389 {390 pCity->GetCityReligions()->IncrementNumTradeRouteConnections(eMajorityReligion, iNumTradeRoutes);391 }392 }393 }394 }395 }396}
Calls
- CvCity::GetCityReligions() const
- CvCityReligions::AddHolyCityPressure()
- CvCityReligions::AddReligiousPressure(CvReligiousFollowChangeReason, ReligionTypes, int, PlayerTypes)
- CvCityReligions::AddSpyPressure(ReligionTypes, int)
- CvCityReligions::GetReligiousMajority()
- CvCityReligions::IncrementNumTradeRouteConnections(ReligionTypes, int)
- CvCityReligions::IsHolyCityAnyReligion()
- CvCityReligions::ResetNumTradeRoutePressure()
- CvGameReligions::GetAdjacentCityReligiousPressure(ReligionTypes, CvCity *, CvCity *, int &, bool)
- CvPlayer::firstCity(int *, bool)
- CvPlayer::GetEspionage() const
- CvPlayer::GetReligions() const
- CvPlayer::isAlive() const
- CvPlayer::nextCity(int *, bool)
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlayerEspionage::GetSpyIndexInCity(CvCity *)
- CvPlayerReligions::GetReligionCreatedByPlayer(bool) const
- CvPlayerReligions::GetSpyPressure() const