Bazaar developer reference

CvDiplomacyAI::IsPlayerValid(PlayerTypes, bool)

Defined in
CvDiplomacyAI.cpp, line 24425
Class
CvDiplomacyAI
Hook name
CivHooks::CvDiplomacyAI_IsPlayerValid

Hooks

static bool BeforeCvDiplomacyAI_IsPlayerValid(CvDiplomacyAI* self, PlayerTypes eOtherPlayer, bool bMyTeamIsValid, bool& result);static void AfterCvDiplomacyAI_IsPlayerValid(CvDiplomacyAI* self, PlayerTypes eOtherPlayer, bool bMyTeamIsValid, bool& result);static bool ReplaceCvDiplomacyAI_IsPlayerValid(bool (*original)(CvDiplomacyAI*, PlayerTypes, bool), CvDiplomacyAI* self, PlayerTypes eOtherPlayer, bool bMyTeamIsValid);CivRegisterBefore<CivHooks::CvDiplomacyAI_IsPlayerValid>(host, &BeforeCvDiplomacyAI_IsPlayerValid);CivRegisterAfter<CivHooks::CvDiplomacyAI_IsPlayerValid>(host, &AfterCvDiplomacyAI_IsPlayerValid);CivRegisterReplace<CivHooks::CvDiplomacyAI_IsPlayerValid>(host, &ReplaceCvDiplomacyAI_IsPlayerValid);

Code

24424/// Helper function: is this a valid player to be looking at?  (e.g. are they alive, do we know them, etc.)24425bool CvDiplomacyAI::IsPlayerValid(PlayerTypes eOtherPlayer, bool bMyTeamIsValid)24426{24427	CvAssertMsg(eOtherPlayer >= 0, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");24428	CvAssertMsg(eOtherPlayer < MAX_CIV_PLAYERS, "DIPLOMACY_AI: Invalid Player Index.  Please send Jon this with your last 5 autosaves and what changelist # you're playing.");2442924430	// Alive?24431	if(!GET_PLAYER(eOtherPlayer).isAlive())24432	{24433		return false;24434	}2443524436	// REALLY Alive? (For some reason a player can be "alive" but have no Cities, Units, etc... grrrr)24437	if(GET_PLAYER(eOtherPlayer).getNumCities() == 0)24438	{24439		return false;24440	}2444124442	// A player we've met?24443	if(!GET_TEAM(GetTeam()).isHasMet(GET_PLAYER(eOtherPlayer).getTeam()))24444	{24445		return false;24446	}2444724448	// Teammate?24449	if(!bMyTeamIsValid)24450	{24451		if(GetTeam() == GET_PLAYER(eOtherPlayer).getTeam())24452		{24453			return false;24454		}24455	}2445624457	return true;24458}

Calls

Called by

74 functions in 6 files