Bazaar developer reference

CvMinorCivAI::DoTestEndSkirmishes(PlayerTypes)

Defined in
CvMinorCivAI.cpp, line 2915
Class
CvMinorCivAI
Hook name
CivHooks::CvMinorCivAI_DoTestEndSkirmishes

Hooks

static bool BeforeCvMinorCivAI_DoTestEndSkirmishes(CvMinorCivAI* self, PlayerTypes eNewAlly);static void AfterCvMinorCivAI_DoTestEndSkirmishes(CvMinorCivAI* self, PlayerTypes eNewAlly);static void ReplaceCvMinorCivAI_DoTestEndSkirmishes(void (*original)(CvMinorCivAI*, PlayerTypes), CvMinorCivAI* self, PlayerTypes eNewAlly);CivRegisterBefore<CivHooks::CvMinorCivAI_DoTestEndSkirmishes>(host, &BeforeCvMinorCivAI_DoTestEndSkirmishes);CivRegisterAfter<CivHooks::CvMinorCivAI_DoTestEndSkirmishes>(host, &AfterCvMinorCivAI_DoTestEndSkirmishes);CivRegisterReplace<CivHooks::CvMinorCivAI_DoTestEndSkirmishes>(host, &ReplaceCvMinorCivAI_DoTestEndSkirmishes);

Code

2913#if defined(MOD_GLOBAL_CS_NO_ALLIED_SKIRMISHES)2914/// Are we at war with a minor also allied to our new BFF?2915void CvMinorCivAI::DoTestEndSkirmishes(PlayerTypes eNewAlly)2916{2917	if(eNewAlly != NO_PLAYER)2918	{2919		if(!GetPlayer()->isAlive())2920			return;29212922		for(int iTeamLoop = 0; iTeamLoop < MAX_CIV_TEAMS; iTeamLoop++)2923		{2924			TeamTypes eLoopTeam = (TeamTypes) iTeamLoop;29252926			// Another Minor2927			if(!GET_TEAM(eLoopTeam).isMinorCiv())2928				continue;29292930			// They're not alive!2931			if(!GET_TEAM(eLoopTeam).isAlive())2932				continue;29332934			// At war with them2935			if(!GET_TEAM(GetPlayer()->getTeam()).isAtWar(eLoopTeam))2936				continue;29372938			if(IsPermanentWar(eLoopTeam))2939				continue;29402941			// New ally IS at war (how???)2942			if(GET_TEAM(GET_PLAYER(eNewAlly).getTeam()).isAtWar(eLoopTeam))2943				continue;29442945			for(int iOtherMinorLoop = MAX_MAJOR_CIVS; iOtherMinorLoop < MAX_CIV_PLAYERS; iOtherMinorLoop++)2946			{2947				PlayerTypes eOtherMinor = (PlayerTypes) iOtherMinorLoop;2948				CvPlayer& kOtherMinor = GET_PLAYER(eOtherMinor);29492950				// Other minor is on this team2951				if(kOtherMinor.isAlive() && kOtherMinor.getTeam() == eLoopTeam)2952				{2953					if(kOtherMinor.GetMinorCivAI()->GetAlly() == eNewAlly)2954					{2955						// We are at war with our new ally's ally!2956						CUSTOMLOG("CS %i is at war with CS %i but they share the same ally %i - making peace", GetPlayer()->GetID(), iOtherMinorLoop, ((int) eNewAlly));2957#if defined(MOD_EVENTS_WAR_AND_PEACE)2958						GET_TEAM(GetPlayer()->getTeam()).makePeace(eLoopTeam, true, false, GetPlayer()->GetID());2959#else2960						GET_TEAM(GetPlayer()->getTeam()).makePeace(eLoopTeam);2961#endif2962					}2963				}2964			}2965		}2966	}2967}

Calls

Called by