Hooks
static bool BeforeCvLeagueAI_FindBestVoteChoices_with_CvRepealProposal_VoteConsiderationList(CvLeagueAI* self, CvRepealProposal * pProposal, CvWeightedVector<CvLeagueAI::VoteConsideration, 32> & considerations);static void AfterCvLeagueAI_FindBestVoteChoices_with_CvRepealProposal_VoteConsiderationList(CvLeagueAI* self, CvRepealProposal * pProposal, CvWeightedVector<CvLeagueAI::VoteConsideration, 32> & considerations);static void ReplaceCvLeagueAI_FindBestVoteChoices_with_CvRepealProposal_VoteConsiderationList(void (*original)(CvLeagueAI*, CvRepealProposal *, CvWeightedVector<CvLeagueAI::VoteConsideration, 32> &), CvLeagueAI* self, CvRepealProposal * pProposal, CvWeightedVector<CvLeagueAI::VoteConsideration, 32> & considerations);CivRegisterBefore<CivHooks::CvLeagueAI_FindBestVoteChoices_with_CvRepealProposal_VoteConsiderationList>(host, &BeforeCvLeagueAI_FindBestVoteChoices_with_CvRepealProposal_VoteConsiderationList);CivRegisterAfter<CivHooks::CvLeagueAI_FindBestVoteChoices_with_CvRepealProposal_VoteConsiderationList>(host, &AfterCvLeagueAI_FindBestVoteChoices_with_CvRepealProposal_VoteConsiderationList);CivRegisterReplace<CivHooks::CvLeagueAI_FindBestVoteChoices_with_CvRepealProposal_VoteConsiderationList>(host, &ReplaceCvLeagueAI_FindBestVoteChoices_with_CvRepealProposal_VoteConsiderationList);
Code
8784// Find the best choices for a particular proposal, and add the data directly to the reference list parameter8785void CvLeagueAI::FindBestVoteChoices(CvRepealProposal* pProposal, VoteConsiderationList& considerations)8786{8787 VoteConsiderationList vScoredChoices;8788 int iMaxChoicesToConsider = 1;87898790 CvAssert(GC.getGame().GetGameLeagues()->GetNumActiveLeagues() > 0);8791 if (!(GC.getGame().GetGameLeagues()->GetNumActiveLeagues() > 0)) return;8792 CvLeague* pLeague = GC.getGame().GetGameLeagues()->GetActiveLeague();8793 CvAssert(pLeague != NULL);8794 if (!(pLeague != NULL)) return;87958796 switch (pProposal->GetRepealDecision()->GetType())8797 {8798 case RESOLUTION_DECISION_REPEAL:8799 {8800 iMaxChoicesToConsider = 1;8801 break;8802 }8803 default:8804 {8805 CvAssertMsg(false, "Unexpected decision type when evaluating choices for AI on a proposed resolution.");8806 break;8807 }8808 }88098810 std::vector<int> vChoices = pLeague->GetChoicesForDecision(pProposal->GetRepealDecision()->GetType(), GetPlayer()->GetID());8811 for (uint i = 0; i < vChoices.size(); i++)8812 {8813 VoteConsideration consideration(/*bEnact*/ false, pProposal->GetID(), vChoices[i]);8814 int iScore = ScoreVoteChoice(pProposal, vChoices[i]);8815 iScore = MAX(iScore, 0); // No negative weights8816 vScoredChoices.push_back(consideration, iScore);8817 }88188819 if (vScoredChoices.size() > 0)8820 {8821 vScoredChoices.SortItems();8822 for (int i = 0; i < vScoredChoices.size() && i < iMaxChoicesToConsider; i++)8823 {8824 considerations.push_back(vScoredChoices.GetElement(i), vScoredChoices.GetWeight(i));8825 LogVoteChoiceConsidered(pProposal, vScoredChoices.GetElement(i).iChoice, vScoredChoices.GetWeight(i));8826 }8827 }8828}