Bazaar developer reference

CvDealAI::DoAddPlayersAlliesToTreaty(PlayerTypes, CvDeal *)

Defined in
CvDealAI.cpp, line 3660
Class
CvDealAI
Hook name
CivHooks::CvDealAI_DoAddPlayersAlliesToTreaty

Hooks

static bool BeforeCvDealAI_DoAddPlayersAlliesToTreaty(CvDealAI* self, PlayerTypes eToPlayer, CvDeal* pDeal);static void AfterCvDealAI_DoAddPlayersAlliesToTreaty(CvDealAI* self, PlayerTypes eToPlayer, CvDeal* pDeal);static void ReplaceCvDealAI_DoAddPlayersAlliesToTreaty(void (*original)(CvDealAI*, PlayerTypes, CvDeal*), CvDealAI* self, PlayerTypes eToPlayer, CvDeal* pDeal);CivRegisterBefore<CivHooks::CvDealAI_DoAddPlayersAlliesToTreaty>(host, &BeforeCvDealAI_DoAddPlayersAlliesToTreaty);CivRegisterAfter<CivHooks::CvDealAI_DoAddPlayersAlliesToTreaty>(host, &AfterCvDealAI_DoAddPlayersAlliesToTreaty);CivRegisterReplace<CivHooks::CvDealAI_DoAddPlayersAlliesToTreaty>(host, &ReplaceCvDealAI_DoAddPlayersAlliesToTreaty);

Code

3659/// Add third party peace for allied city-states3660void CvDealAI::DoAddPlayersAlliesToTreaty(PlayerTypes eToPlayer, CvDeal* pDeal)3661{3662	int iPeaceDuration = GC.getGame().getGameSpeedInfo().getPeaceDealDuration();3663	PlayerTypes eMinor;3664	CvPlayer* pMinor;3665	for(int iMinorLoop = MAX_MAJOR_CIVS; iMinorLoop < MAX_CIV_PLAYERS; iMinorLoop++)3666	{3667		eMinor = (PlayerTypes) iMinorLoop;3668		pMinor = &GET_PLAYER(eMinor);36693670		// Minor not alive?3671		if(!pMinor->isAlive())3672			continue;36733674		PlayerTypes eAlly = pMinor->GetMinorCivAI()->GetAlly();3675		// ally of other player3676		if (eAlly == eToPlayer)3677		{3678			// if they are not at war with us, continue3679			if (!GET_TEAM(GetTeam()).isAtWar(pMinor->getTeam()))3680			{3681				continue;3682			}36833684			// if they are always at war with us, continue3685			if (pMinor->GetMinorCivAI()->IsPermanentWar(GetTeam()))3686			{3687				continue;3688			}36893690			// Add peace with this minor to the deal3691			// slewis - if there is not a peace deal with them already on the table and we can trade it3692			if(!pDeal->IsThirdPartyPeaceTrade(GetPlayer()->GetID(), pMinor->getTeam()) && pDeal->IsPossibleToTradeItem(GetPlayer()->GetID(), eToPlayer, TRADE_ITEM_THIRD_PARTY_PEACE, pMinor->getTeam()))3693			{3694				pDeal->AddThirdPartyPeace(GetPlayer()->GetID(), pMinor->getTeam(), iPeaceDuration);3695			}3696		}3697		// ally with us3698		else if (eAlly == GetPlayer()->GetID())3699		{3700			// if they are not at war with the opponent, continue3701			if (!GET_TEAM(GET_PLAYER(eToPlayer).getTeam()).isAtWar(pMinor->getTeam()))3702			{3703				continue;3704			}37053706			// if they are always at war with them, continue3707			if (pMinor->GetMinorCivAI()->IsPermanentWar(GET_PLAYER(eToPlayer).getTeam()))3708			{3709				continue;3710			}37113712			// Add peace with this minor to the deal3713			// slewis - if there is not a peace deal with them already on the table and we can trade it3714			if(!pDeal->IsThirdPartyPeaceTrade(eToPlayer, pMinor->getTeam()) && pDeal->IsPossibleToTradeItem(eToPlayer, GetPlayer()->GetID(), TRADE_ITEM_THIRD_PARTY_PEACE, pMinor->getTeam()))3715			{3716				pDeal->AddThirdPartyPeace(eToPlayer, pMinor->getTeam(), iPeaceDuration);3717			}3718		}3719	}3720}

Calls

Called by