Hooks
static bool BeforeCvDiplomacyAI_DoUpdateMinorCivProtection(CvDiplomacyAI* self, PlayerTypes eMinor, MinorCivApproachTypes eApproach);static void AfterCvDiplomacyAI_DoUpdateMinorCivProtection(CvDiplomacyAI* self, PlayerTypes eMinor, MinorCivApproachTypes eApproach);static void ReplaceCvDiplomacyAI_DoUpdateMinorCivProtection(void (*original)(CvDiplomacyAI*, PlayerTypes, MinorCivApproachTypes), CvDiplomacyAI* self, PlayerTypes eMinor, MinorCivApproachTypes eApproach);CivRegisterBefore<CivHooks::CvDiplomacyAI_DoUpdateMinorCivProtection>(host, &BeforeCvDiplomacyAI_DoUpdateMinorCivProtection);CivRegisterAfter<CivHooks::CvDiplomacyAI_DoUpdateMinorCivProtection>(host, &AfterCvDiplomacyAI_DoUpdateMinorCivProtection);CivRegisterReplace<CivHooks::CvDiplomacyAI_DoUpdateMinorCivProtection>(host, &ReplaceCvDiplomacyAI_DoUpdateMinorCivProtection);
Code
13635void CvDiplomacyAI::DoUpdateMinorCivProtection(PlayerTypes eMinor, MinorCivApproachTypes eApproach)13636{13637 // Only change protection if this player is not human controlled!13638 if(!GetPlayer()->isHuman())13639 {13640 if(eApproach == MINOR_CIV_APPROACH_PROTECTIVE)13641 {13642 // We are protective, so do a PtP if we are able to and haven't already13643 if(GET_PLAYER(eMinor).GetMinorCivAI()->CanMajorStartProtection(GetPlayer()->GetID()))13644 {13645 GC.getGame().DoMinorPledgeProtection(GetPlayer()->GetID(), eMinor, true);13646 DoMakePublicDeclaration(PUBLIC_DECLARATION_PROTECT_MINOR, eMinor, -1, eMinor);13647 }13648 }13649 else13650 {13651 // We are not protective, so revoke PtP if we can13652 if(GET_PLAYER(eMinor).GetMinorCivAI()->IsProtectedByMajor(GetPlayer()->GetID()) && GET_PLAYER(eMinor).GetMinorCivAI()->CanMajorWithdrawProtection(GetPlayer()->GetID()))13653 {13654 GC.getGame().DoMinorPledgeProtection(GetPlayer()->GetID(), eMinor, false);13655 DoMakePublicDeclaration(PUBLIC_DECLARATION_ABANDON_MINOR, eMinor, -1, eMinor);13656 }13657 }13658 }13659}