Hooks
static bool BeforeCvGameDeals_DoCancelAllProposedDealsWithPlayer(CvGameDeals* self, PlayerTypes eCancelPlayer, DiplomacyPlayerType eTargetPlayers);static void AfterCvGameDeals_DoCancelAllProposedDealsWithPlayer(CvGameDeals* self, PlayerTypes eCancelPlayer, DiplomacyPlayerType eTargetPlayers);static void ReplaceCvGameDeals_DoCancelAllProposedDealsWithPlayer(void (*original)(CvGameDeals*, PlayerTypes, DiplomacyPlayerType), CvGameDeals* self, PlayerTypes eCancelPlayer, DiplomacyPlayerType eTargetPlayers);CivRegisterBefore<CivHooks::CvGameDeals_DoCancelAllProposedDealsWithPlayer>(host, &BeforeCvGameDeals_DoCancelAllProposedDealsWithPlayer);CivRegisterAfter<CivHooks::CvGameDeals_DoCancelAllProposedDealsWithPlayer>(host, &AfterCvGameDeals_DoCancelAllProposedDealsWithPlayer);CivRegisterReplace<CivHooks::CvGameDeals_DoCancelAllProposedDealsWithPlayer>(host, &ReplaceCvGameDeals_DoCancelAllProposedDealsWithPlayer);
Code
3193#if defined(MOD_AI_MP_DIPLOMACY)3194// JdH => added eTargetPlayers parameter to be able to control proposed deal removal3195void CvGameDeals::DoCancelAllProposedDealsWithPlayer(PlayerTypes eCancelPlayer, DiplomacyPlayerType eTargetPlayers)3196#else3197void CvGameDeals::DoCancelAllProposedDealsWithPlayer(PlayerTypes eCancelPlayer)3198#endif3199{//Cancel all proposed deals involving eCancelPlayer.3200 PlayerTypes eLoopPlayer;3201 for(int iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)3202 {3203 eLoopPlayer = (PlayerTypes) iPlayerLoop;3204#if defined(MOD_AI_MP_DIPLOMACY)3205 if (MOD_AI_MP_DIPLOMACY) {3206 CvPlayer& kLoopPlayer = GET_PLAYER(eLoopPlayer);3207 if ( (eTargetPlayers == DIPLO_AI_PLAYERS && !kLoopPlayer.isHuman())3208 || (eTargetPlayers == DIPLO_ALL_PLAYERS)3209 || (eLoopPlayer == static_cast<PlayerTypes>(eTargetPlayers)))3210 {3211 CvDeal kDeal;3212 while (RemoveProposedDeal(eCancelPlayer, eLoopPlayer, &kDeal, true))3213 {//deal from eCancelPlayer3214 FinalizeDeal(kDeal, false);3215 }3216 while (RemoveProposedDeal(eLoopPlayer, eCancelPlayer, &kDeal, true))3217 {//deal to eCancelPlayer3218 FinalizeDeal(kDeal, false);3219 }3220 }3221 } else {3222#endif3223 if(GetProposedDeal(eCancelPlayer, eLoopPlayer))3224 {//deal from eCancelPlayer3225 FinalizeDeal(eCancelPlayer, eLoopPlayer, false);3226 }3227 if(GetProposedDeal(eLoopPlayer, eCancelPlayer))3228 {//deal to eCancelPlayer3229 FinalizeDeal(eLoopPlayer, eCancelPlayer, false);3230 }3231#if defined(MOD_AI_MP_DIPLOMACY)3232 }3233#endif3234 }3235}