Hooks
static bool BeforeCvDealAI_DoAddVoteCommitmentToThem(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeTheirExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iAmountOverWeWillRequest, bool bUseEvenValue);static void AfterCvDealAI_DoAddVoteCommitmentToThem(CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeTheirExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iAmountOverWeWillRequest, bool bUseEvenValue);static void ReplaceCvDealAI_DoAddVoteCommitmentToThem(void (*original)(CvDealAI*, CvDeal*, PlayerTypes, bool, int&, int&, int&, int, bool), CvDealAI* self, CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeTheirExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iAmountOverWeWillRequest, bool bUseEvenValue);CivRegisterBefore<CivHooks::CvDealAI_DoAddVoteCommitmentToThem>(host, &BeforeCvDealAI_DoAddVoteCommitmentToThem);CivRegisterAfter<CivHooks::CvDealAI_DoAddVoteCommitmentToThem>(host, &AfterCvDealAI_DoAddVoteCommitmentToThem);CivRegisterReplace<CivHooks::CvDealAI_DoAddVoteCommitmentToThem>(host, &ReplaceCvDealAI_DoAddVoteCommitmentToThem);
Code
2411/// See if adding Vote Commitment to their side of the deal helps even out pDeal2412void CvDealAI::DoAddVoteCommitmentToThem(CvDeal* pDeal, PlayerTypes eThem, bool bDontChangeTheirExistingItems, int& iTotalValue, int& iValueImOffering, int& iValueTheyreOffering, int iAmountOverWeWillRequest, bool bUseEvenValue)2413{2414 CvAssert(eThem >= 0);2415 CvAssert(eThem < MAX_MAJOR_CIVS);2416 CvAssertMsg(eThem != GetPlayer()->GetID(), "DEAL_AI: Trying to add Vote Commitment to Them, but them is us. Please send Anton your save file and version.");24172418 if(!bDontChangeTheirExistingItems)2419 {2420 if(iTotalValue < 0)2421 {2422 PlayerTypes eMyPlayer = GetPlayer()->GetID();24232424 // Can't already be a Vote Commitment in the Deal2425 if(!pDeal->IsVoteCommitmentTrade(eThem) && !pDeal->IsVoteCommitmentTrade(eMyPlayer))2426 {2427 CvLeagueAI::VoteCommitmentList vDesiredCommitments = GetPlayer()->GetLeagueAI()->GetDesiredVoteCommitments(eThem);2428 for (CvLeagueAI::VoteCommitmentList::iterator it = vDesiredCommitments.begin(); it != vDesiredCommitments.end(); ++it)2429 {2430 int iProposalID = it->iResolutionID;2431 int iVoteChoice = it->iVoteChoice;2432 int iNumVotes = it->iNumVotes;2433 bool bRepeal = !it->bEnact;24342435 if (iProposalID != -1 && pDeal->IsPossibleToTradeItem(eThem, eMyPlayer, TRADE_ITEM_VOTE_COMMITMENT, iProposalID, iVoteChoice, iNumVotes, bRepeal))2436 {2437 int iItemValue = GetTradeItemValue(TRADE_ITEM_VOTE_COMMITMENT, /*bFromMe*/ false, eThem, iProposalID, iVoteChoice, iNumVotes, bRepeal, -1, bUseEvenValue);24382439 // If adding this to the deal doesn't take it over the limit, do it2440#if defined(MOD_AI_NO_ZERO_VALUE_TRADE_ITEMS)2441 if((iItemValue > 0) && (iItemValue + iTotalValue <= iAmountOverWeWillRequest))2442#else2443 if(iItemValue + iTotalValue <= iAmountOverWeWillRequest)2444#endif2445 {2446 pDeal->AddVoteCommitment(eThem, iProposalID, iVoteChoice, iNumVotes, bRepeal);2447 iTotalValue = GetDealValue(pDeal, iValueImOffering, iValueTheyreOffering, bUseEvenValue);2448 }2449 }2450 }2451 }2452 }2453 }2454}