CvMinorCivAI::CanMajorWithdrawProtection(PlayerTypes)
- Defined in
- CvMinorCivAI.cpp, line 7450
- Class
- CvMinorCivAI
- Hook name
CivHooks::CvMinorCivAI_CanMajorWithdrawProtection- Lua events
GameEvents.PlayerCanRevoke
Hooks
static bool BeforeCvMinorCivAI_CanMajorWithdrawProtection(CvMinorCivAI* self, PlayerTypes eMajor, bool& result);static void AfterCvMinorCivAI_CanMajorWithdrawProtection(CvMinorCivAI* self, PlayerTypes eMajor, bool& result);static bool ReplaceCvMinorCivAI_CanMajorWithdrawProtection(bool (*original)(CvMinorCivAI*, PlayerTypes), CvMinorCivAI* self, PlayerTypes eMajor);CivRegisterBefore<CivHooks::CvMinorCivAI_CanMajorWithdrawProtection>(host, &BeforeCvMinorCivAI_CanMajorWithdrawProtection);CivRegisterAfter<CivHooks::CvMinorCivAI_CanMajorWithdrawProtection>(host, &AfterCvMinorCivAI_CanMajorWithdrawProtection);CivRegisterReplace<CivHooks::CvMinorCivAI_CanMajorWithdrawProtection>(host, &ReplaceCvMinorCivAI_CanMajorWithdrawProtection);
Code
7450bool CvMinorCivAI::CanMajorWithdrawProtection(PlayerTypes eMajor)7451{7452 CvAssertMsg(eMajor >= 0, "eMajor is expected to be non-negative (invalid Index)");7453 CvAssertMsg(eMajor < MAX_MAJOR_CIVS, "eMajor is expected to be within maximum bounds (invalid Index)");7454 if(eMajor < 0 || eMajor >= MAX_MAJOR_CIVS) return false;74557456 if (!IsProtectedByMajor(eMajor))7457 return false;74587459 // Pledge is locked in for a certain time7460 int iCurrentTurn = GC.getGame().getGameTurn();7461 int iLastPledgeTurn = GetTurnLastPledgedProtectionByMajor(eMajor);7462 const int iGracePeriod = 10; //antonjs: todo: xml7463 if (iLastPledgeTurn >= 0 && iLastPledgeTurn + iGracePeriod > iCurrentTurn)7464 return false;74657466#if defined(MOD_EVENTS_MINORS_INTERACTION)7467 if (MOD_EVENTS_MINORS_INTERACTION) {7468 if (GAMEEVENTINVOKE_TESTALL(GAMEEVENT_PlayerCanRevoke, eMajor, GetPlayer()->GetID()) == GAMEEVENTRETURN_FALSE) {7469 return false;7470 }7471 }7472#endif 7473 7474 return true;7475}
Calls
- CustomMods::eventTestAll(const char *, const char *, ...)
- CustomMods::isEVENTS_MINORS_INTERACTION()
- CvGame::getGameTurn()
- CvGlobals::getGame()
- CvMinorCivAI::GetPlayer()
- CvMinorCivAI::GetTurnLastPledgedProtectionByMajor(PlayerTypes) const
- CvMinorCivAI::IsProtectedByMajor(PlayerTypes) const
- CvPlayer::GetID() const