Code
19592/// Units in the ether coming towards us?19593void CvPlayer::DoIncomingUnits()19594{19595 AI_PERF_FORMAT("AI-perf.csv", ("CvPlayer::DoIncomingUnits, Turn %03d, %s", GC.getGame().getElapsedGameTurns(), getCivilizationShortDescription()) );19596 for(int iLoop = 0; iLoop < MAX_PLAYERS; iLoop++)19597 {19598 PlayerTypes eLoopPlayer = (PlayerTypes) iLoop;19599 CvAssertMsg(GetIncomingUnitCountdown(eLoopPlayer) >= -1, "Incoming Unit countdown is an invalid value. Please send Jon this with your last 5 autosaves and what changelist # you're playing.");19600 if(GetIncomingUnitCountdown(eLoopPlayer) > 0)19601 {19602 ChangeIncomingUnitCountdown(eLoopPlayer, -1);1960319604 // Time to spawn a new unit19605 if(GetIncomingUnitCountdown(eLoopPlayer) == 0)19606 {19607 // Must have capital to actually spawn unit19608 CvCity* pCapital = getCapitalCity();19609 if(pCapital)19610 {19611 CvUnit* pNewUnit = initUnit(GetIncomingUnitType(eLoopPlayer), pCapital->getX(), pCapital->getY());19612 CvAssert(pNewUnit);19613 if (pNewUnit)19614 {19615 if(pNewUnit->getDomainType() != DOMAIN_AIR)19616 {19617 if (!pNewUnit->jumpToNearestValidPlot())19618 pNewUnit->kill(false);19619 }1962019621 // Gift from a major to a city-state19622 if (isMinorCiv() && !GET_PLAYER(eLoopPlayer).isMinorCiv())19623 {19624 GetMinorCivAI()->DoUnitGiftFromMajor(eLoopPlayer, pNewUnit, /*bDistanceGift*/ true);19625 }19626 }19627 }1962819629 // Reset stuff19630 SetIncomingUnitCountdown(eLoopPlayer, -1);19631 SetIncomingUnitType(eLoopPlayer, NO_UNIT);19632 }19633 }19634 }19635}