Bazaar developer reference

CvDealAI::IsMakeOfferForOpenBorders(PlayerTypes, CvDeal *)

Defined in
CvDealAI.cpp, line 3871
Class
CvDealAI
Hook name
CivHooks::CvDealAI_IsMakeOfferForOpenBorders

Hooks

static bool BeforeCvDealAI_IsMakeOfferForOpenBorders(CvDealAI* self, PlayerTypes eOtherPlayer, CvDeal* pDeal, bool& result);static void AfterCvDealAI_IsMakeOfferForOpenBorders(CvDealAI* self, PlayerTypes eOtherPlayer, CvDeal* pDeal, bool& result);static bool ReplaceCvDealAI_IsMakeOfferForOpenBorders(bool (*original)(CvDealAI*, PlayerTypes, CvDeal*), CvDealAI* self, PlayerTypes eOtherPlayer, CvDeal* pDeal);CivRegisterBefore<CivHooks::CvDealAI_IsMakeOfferForOpenBorders>(host, &BeforeCvDealAI_IsMakeOfferForOpenBorders);CivRegisterAfter<CivHooks::CvDealAI_IsMakeOfferForOpenBorders>(host, &AfterCvDealAI_IsMakeOfferForOpenBorders);CivRegisterReplace<CivHooks::CvDealAI_IsMakeOfferForOpenBorders>(host, &ReplaceCvDealAI_IsMakeOfferForOpenBorders);

Code

3870/// A good time to make an offer to get Open Borders?3871bool CvDealAI::IsMakeOfferForOpenBorders(PlayerTypes eOtherPlayer, CvDeal* pDeal)3872{3873	CvAssert(eOtherPlayer >= 0);3874	CvAssert(eOtherPlayer < MAX_MAJOR_CIVS);38753876	// Don't ask for Open Borders if we're hostile or planning war3877	MajorCivApproachTypes eApproach = GetPlayer()->GetDiplomacyAI()->GetMajorCivApproach(eOtherPlayer, /*bHideTrueFeelings*/ false);3878	if(eApproach == MAJOR_CIV_APPROACH_HOSTILE ||3879	        eApproach == MAJOR_CIV_APPROACH_WAR)3880	{3881		return false;3882	}38833884	// Can we actually complete this deal?3885	if(!pDeal->IsPossibleToTradeItem(eOtherPlayer, GetPlayer()->GetID(), TRADE_ITEM_OPEN_BORDERS))3886	{3887		return false;3888	}38893890	// Do we actually want OB with eOtherPlayer?3891	if(GetPlayer()->GetDiplomacyAI()->IsWantsOpenBordersWithPlayer(eOtherPlayer))3892	{3893		// Seed the deal with the item we want3894		pDeal->AddOpenBorders(eOtherPlayer, GC.getGame().GetDealDuration());38953896		bool bDealAcceptable = false;38973898		// AI evaluation3899		if(!GET_PLAYER(eOtherPlayer).isHuman())3900		{3901			bDealAcceptable = DoEqualizeDealWithAI(pDeal, eOtherPlayer);	// Change the deal as necessary to make it work3902		}3903		else3904		{3905			bool bUselessReferenceVariable;3906			bool bCantMatchOffer;3907			bDealAcceptable = DoEqualizeDealWithHuman(pDeal, eOtherPlayer, false, true, bUselessReferenceVariable, bCantMatchOffer);	// Change the deal as necessary to make it work3908		}39093910		return bDealAcceptable;3911	}39123913	return false;3914}

Calls

Called by