Bazaar developer reference

CvTeam::addTeam(TeamTypes)

Defined in
CvTeam.cpp, line 390
Class
CvTeam
Hook name
CivHooks::CvTeam_addTeam

Hooks

static bool BeforeCvTeam_addTeam(CvTeam* self, TeamTypes eTeam);static void AfterCvTeam_addTeam(CvTeam* self, TeamTypes eTeam);static void ReplaceCvTeam_addTeam(void (*original)(CvTeam*, TeamTypes), CvTeam* self, TeamTypes eTeam);CivRegisterBefore<CivHooks::CvTeam_addTeam>(host, &BeforeCvTeam_addTeam);CivRegisterAfter<CivHooks::CvTeam_addTeam>(host, &AfterCvTeam_addTeam);CivRegisterReplace<CivHooks::CvTeam_addTeam>(host, &ReplaceCvTeam_addTeam);

Code

390void CvTeam::addTeam(TeamTypes eTeam)391{392	CvPlot* pLoopPlot;393	CvString strBuffer;394	int iI, iJ;395396	CvAssert(eTeam != NO_TEAM);397	CvAssert(eTeam != GetID());398399	for(iI = 0; iI < MAX_PLAYERS; iI++)400	{401		if(GET_PLAYER((PlayerTypes)iI).isAlive())402		{403			if((GET_PLAYER((PlayerTypes)iI).getTeam() != GetID()) && (GET_PLAYER((PlayerTypes)iI).getTeam() != eTeam))404			{405				if(GET_TEAM(GET_PLAYER((PlayerTypes)iI).getTeam()).isHasMet(GetID()) && GET_TEAM(GET_PLAYER((PlayerTypes)iI).getTeam()).isHasMet(eTeam))406				{407					if(iI == GC.getGame().getActivePlayer())408					{409						strBuffer = GetLocalizedText("TXT_KEY_MISC_PLAYER_PERMANENT_ALLIANCE", getName().GetCString(), GET_TEAM(eTeam).getName().GetCString());410						DLLUI->AddMessage(0, ((PlayerTypes)iI), false, GC.getEVENT_MESSAGE_TIME(), strBuffer/*, "AS2D_THEIRALLIANCE", MESSAGE_TYPE_MINOR_EVENT, NULL, (ColorTypes)GC.getInfoTypeForString("COLOR_HIGHLIGHT_TEXT")*/);411					}412				}413			}414		}415	}416417	strBuffer = GetLocalizedText("TXT_KEY_MISC_PLAYER_PERMANENT_ALLIANCE", getName().GetCString(), GET_TEAM(eTeam).getName().GetCString());418	GC.getGame().addReplayMessage(REPLAY_MESSAGE_MAJOR_EVENT, getLeaderID(), strBuffer, -1, -1);419420	// To be replaced with new diplomatic code421422	shareItems(eTeam);423	GET_TEAM(eTeam).shareItems(GetID());424425	for(iI = 0; iI < MAX_TEAMS; iI++)426	{427		if((iI != GetID()) && (iI != eTeam))428		{429			if(GET_TEAM((TeamTypes)iI).isAlive())430			{431				if(GET_TEAM(eTeam).isHasMet((TeamTypes)iI))432				{433					meet(((TeamTypes)iI), false);434				}435				else if(isHasMet((TeamTypes)iI))436				{437					GET_TEAM(eTeam).meet((TeamTypes)iI, false);438				}439			}440		}441	}442443	for(iI = 0; iI < MAX_TEAMS; iI++)444	{445		if((iI != GetID()) && (iI != eTeam))446		{447			if(GET_TEAM((TeamTypes)iI).isAlive())448			{449				if(GET_TEAM(eTeam).isAtWar((TeamTypes)iI))450				{451#if defined(MOD_EVENTS_WAR_AND_PEACE)452					declareWar(((TeamTypes)iI), false, getLeaderID());453#else454					declareWar(((TeamTypes)iI));455#endif456				}457				else if(isAtWar((TeamTypes)iI))458				{459#if defined(MOD_EVENTS_WAR_AND_PEACE)460					GET_TEAM(eTeam).declareWar(((TeamTypes)iI), false, GET_TEAM(eTeam).getLeaderID());461#else462					GET_TEAM(eTeam).declareWar(((TeamTypes)iI));463#endif464				}465			}466		}467	}468469	for(iI = 0; iI < MAX_TEAMS; iI++)470	{471		if((iI != GetID()) && (iI != eTeam))472		{473			if(GET_TEAM((TeamTypes)iI).isAlive())474			{475				if(GET_TEAM(eTeam).isPermanentWarPeace((TeamTypes)iI))476				{477					setPermanentWarPeace(((TeamTypes)iI), true);478				}479				else if(isPermanentWarPeace((TeamTypes)iI))480				{481					GET_TEAM(eTeam).setPermanentWarPeace(((TeamTypes)iI), true);482				}483			}484		}485	}486487	for(iI = 0; iI < MAX_TEAMS; iI++)488	{489		if((iI != GetID()) && (iI != eTeam))490		{491			if(GET_TEAM((TeamTypes)iI).isAlive())492			{493				if(GET_TEAM(eTeam).HasEmbassyAtTeam((TeamTypes)iI))494				{495					SetHasEmbassyAtTeam(((TeamTypes)iI), true);496				}497				else if(HasEmbassyAtTeam((TeamTypes)iI))498				{499					GET_TEAM(eTeam).SetHasEmbassyAtTeam(((TeamTypes)iI), true);500				}501			}502		}503	}504505	for(iI = 0; iI < MAX_TEAMS; iI++)506	{507		if((iI != GetID()) && (iI != eTeam))508		{509			if(GET_TEAM((TeamTypes)iI).isAlive())510			{511				if(GET_TEAM(eTeam).IsAllowsOpenBordersToTeam((TeamTypes)iI))512				{513					SetAllowsOpenBordersToTeam(((TeamTypes)iI), true);514					GET_TEAM((TeamTypes)iI).SetAllowsOpenBordersToTeam(GetID(), true);515				}516				else if(IsAllowsOpenBordersToTeam((TeamTypes)iI))517				{518					GET_TEAM(eTeam).SetAllowsOpenBordersToTeam(((TeamTypes)iI), true);519					GET_TEAM((TeamTypes)iI).SetAllowsOpenBordersToTeam(eTeam, true);520				}521			}522		}523	}524525	for(iI = 0; iI < MAX_TEAMS; iI++)526	{527		if((iI != GetID()) && (iI != eTeam))528		{529			if(GET_TEAM((TeamTypes)iI).isAlive())530			{531				if(GET_TEAM(eTeam).IsHasDefensivePact((TeamTypes)iI))532				{533					SetHasDefensivePact(((TeamTypes)iI), true);534					GET_TEAM((TeamTypes)iI).SetHasDefensivePact(GetID(), true);535				}536				else if(IsHasDefensivePact((TeamTypes)iI))537				{538					GET_TEAM(eTeam).SetHasDefensivePact(((TeamTypes)iI), true);539					GET_TEAM((TeamTypes)iI).SetHasDefensivePact(eTeam, true);540				}541			}542		}543	}544545	for(iI = 0; iI < MAX_TEAMS; iI++)546	{547		if((iI != GetID()) && (iI != eTeam))548		{549			if(GET_TEAM((TeamTypes)iI).isAlive())550			{551				if(GET_TEAM(eTeam).isForcePeace((TeamTypes)iI))552				{553					setForcePeace(((TeamTypes)iI), true);554					GET_TEAM((TeamTypes)iI).setForcePeace(GetID(), true);555				}556				else if(isForcePeace((TeamTypes)iI))557				{558					GET_TEAM(eTeam).setForcePeace(((TeamTypes)iI), true);559					GET_TEAM((TeamTypes)iI).setForcePeace(eTeam, true);560				}561			}562		}563	}564565	shareCounters(eTeam);566	GET_TEAM(eTeam).shareCounters(GetID());567568	for(iI = 0; iI < MAX_PLAYERS; iI++)569	{570		if(GET_PLAYER((PlayerTypes)iI).getTeam() == eTeam)571		{572			GET_PLAYER((PlayerTypes)iI).setTeam(GetID());573		}574	}575576	const int iNumInvisibleInfos = NUM_INVISIBLE_TYPES;577	for(iI = 0; iI < GC.getMap().numPlots(); iI++)578	{579		pLoopPlot = GC.getMap().plotByIndexUnchecked(iI);580581		pLoopPlot->changeVisibilityCount(GetID(), pLoopPlot->getVisibilityCount(eTeam), NO_INVISIBLE, true, false);582583		for(iJ = 0; iJ < iNumInvisibleInfos; iJ++)584		{585			pLoopPlot->changeInvisibleVisibilityCount(GetID(), ((InvisibleTypes)iJ), pLoopPlot->getInvisibleVisibilityCount(eTeam, ((InvisibleTypes)iJ)));586		}587588		if(pLoopPlot->isRevealed(eTeam))589		{590			pLoopPlot->setRevealed(GetID(), true, false, eTeam);591		}592	}593594	GC.getGame().updateScore(true);595}

Calls

Called by