Bazaar developer reference

CvTeam::changeCanEmbarkCount(int)

Defined in
CvTeam.cpp, line 3445
Class
CvTeam
Hook name
CivHooks::CvTeam_changeCanEmbarkCount

Hooks

static bool BeforeCvTeam_changeCanEmbarkCount(CvTeam* self, int iChange);static void AfterCvTeam_changeCanEmbarkCount(CvTeam* self, int iChange);static void ReplaceCvTeam_changeCanEmbarkCount(void (*original)(CvTeam*, int), CvTeam* self, int iChange);CivRegisterBefore<CivHooks::CvTeam_changeCanEmbarkCount>(host, &BeforeCvTeam_changeCanEmbarkCount);CivRegisterAfter<CivHooks::CvTeam_changeCanEmbarkCount>(host, &AfterCvTeam_changeCanEmbarkCount);CivRegisterReplace<CivHooks::CvTeam_changeCanEmbarkCount>(host, &ReplaceCvTeam_changeCanEmbarkCount);

Code

3445void CvTeam::changeCanEmbarkCount(int iChange)3446{3447	if(iChange != 0)3448	{3449		m_iCanEmbarkCount += iChange;34503451		if(canEmbark())3452		{3453			int iLoop;3454			CvUnit* pLoopUnit;34553456			// Give embarkation promotion to all civilians, because they have no way to earn it later3457			for(int iI = 0; iI < MAX_PLAYERS; iI++)3458			{3459				if(GET_PLAYER((PlayerTypes)iI).isAlive() && GET_PLAYER((PlayerTypes)iI).getTeam() == GetID())3460				{3461					for(pLoopUnit = GET_PLAYER((PlayerTypes)iI).firstUnit(&iLoop); pLoopUnit != NULL; pLoopUnit = GET_PLAYER((PlayerTypes)iI).nextUnit(&iLoop))3462					{3463						// Land Unit3464						if(pLoopUnit->getDomainType() == DOMAIN_LAND)3465						{3466							// If we're in friendly territory and we can embark, give the promotion for free3467							if(pLoopUnit->plot()->IsFriendlyTerritory((PlayerTypes)iI))3468							{3469								// Civilian unit or the unit can acquire this promotion3470								PromotionTypes ePromotionEmbarkation = GET_PLAYER((PlayerTypes)iI).GetEmbarkationPromotion();3471								if(!pLoopUnit->IsCombatUnit() || ::IsPromotionValidForUnitCombatType(ePromotionEmbarkation, pLoopUnit->getUnitType()))3472									pLoopUnit->setHasPromotion(ePromotionEmbarkation, true);3473							}3474						}3475					}3476				}3477			}3478		}3479	}34803481	CvAssert(getCanEmbarkCount() >= 0);3482}

Calls

Called by