Bazaar developer reference

CvMinorCivAI::DoTestEndWarsVSMinors(PlayerTypes, PlayerTypes)

Defined in
CvMinorCivAI.cpp, line 2831
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_DoTestEndWarsVSMinors

Hooks

static bool BeforeCvMinorCivAI_DoTestEndWarsVSMinors(CvMinorCivAI* self, PlayerTypes eOldAlly, PlayerTypes eNewAlly);static void AfterCvMinorCivAI_DoTestEndWarsVSMinors(CvMinorCivAI* self, PlayerTypes eOldAlly, PlayerTypes eNewAlly);static void ReplaceCvMinorCivAI_DoTestEndWarsVSMinors(void (*original)(CvMinorCivAI*, PlayerTypes, PlayerTypes), CvMinorCivAI* self, PlayerTypes eOldAlly, PlayerTypes eNewAlly);CivRegisterBefore<CivHooks::CvMinorCivAI_DoTestEndWarsVSMinors>(host, &BeforeCvMinorCivAI_DoTestEndWarsVSMinors);CivRegisterAfter<CivHooks::CvMinorCivAI_DoTestEndWarsVSMinors>(host, &AfterCvMinorCivAI_DoTestEndWarsVSMinors);CivRegisterReplace<CivHooks::CvMinorCivAI_DoTestEndWarsVSMinors>(host, &ReplaceCvMinorCivAI_DoTestEndWarsVSMinors);

Code

2830/// Are we at war with a minor and not allied with anyone?2831void CvMinorCivAI::DoTestEndWarsVSMinors(PlayerTypes eOldAlly, PlayerTypes eNewAlly)2832{2833	if(eOldAlly == NO_PLAYER)2834		return;28352836	if(!GetPlayer()->isAlive())2837		return;28382839	PlayerTypes eOtherMinor;2840	int iOtherMinorLoop;2841	PlayerTypes eOtherAlly;2842	bool bForcedWar;28432844	TeamTypes eLoopTeam;2845	for(int iTeamLoop = 0; iTeamLoop < MAX_CIV_TEAMS; iTeamLoop++)2846	{2847		eLoopTeam = (TeamTypes) iTeamLoop;28482849		// Another Minor2850		if(!GET_TEAM(eLoopTeam).isMinorCiv())2851			continue;28522853		// They not alive!2854		if(!GET_TEAM(eLoopTeam).isAlive())2855			continue;28562857		// At war with him2858		if(!GET_TEAM(GetPlayer()->getTeam()).isAtWar(eLoopTeam))2859			continue;28602861		if(eOldAlly != NO_PLAYER)2862		{2863			// Old ally wasn't at war2864			if(!GET_TEAM(GET_PLAYER(eOldAlly).getTeam()).isAtWar(eLoopTeam))2865				continue;2866		}28672868		if(eNewAlly != NO_PLAYER)2869		{2870			// New ally IS at war2871			if(GET_TEAM(GET_PLAYER(eNewAlly).getTeam()).isAtWar(eLoopTeam))2872				continue;2873		}28742875		// Make sure this guy isn't allied with someone at war with us2876		bForcedWar = false;28772878		for(iOtherMinorLoop = 0; iOtherMinorLoop < MAX_CIV_TEAMS; iOtherMinorLoop++)2879		{2880			eOtherMinor = (PlayerTypes) iOtherMinorLoop;28812882			// Other minor is on this team2883			if(GET_PLAYER(eOtherMinor).getTeam() == eLoopTeam)2884			{2885				eOtherAlly = GET_PLAYER(eOtherMinor).GetMinorCivAI()->GetAlly();2886				if(eOtherAlly != NO_PLAYER)2887				{2888					// This guy's ally at war with us?2889					if(GET_TEAM(GET_PLAYER(eOtherAlly).getTeam()).isAtWar(GetPlayer()->getTeam()))2890					{2891						bForcedWar = true;2892						break;2893					}2894				}2895			}28962897		}28982899		if(bForcedWar)2900			continue;29012902		if(IsPermanentWar(eLoopTeam))2903			continue;29042905#if defined(MOD_EVENTS_WAR_AND_PEACE)2906		GET_TEAM(GetPlayer()->getTeam()).makePeace(eLoopTeam, true, false, GetPlayer()->GetID());2907#else2908		GET_TEAM(GetPlayer()->getTeam()).makePeace(eLoopTeam);2909#endif2910	}2911}

Calls

Called by