Bazaar developer reference

CvTeam::DoTestSmallAwards()

Defined in
CvTeam.cpp, line 5251
Class
CvTeam
Hook name
CivHooks::CvTeam_DoTestSmallAwards

Hooks

static bool BeforeCvTeam_DoTestSmallAwards(CvTeam* self);static void AfterCvTeam_DoTestSmallAwards(CvTeam* self);static void ReplaceCvTeam_DoTestSmallAwards(void (*original)(CvTeam*), CvTeam* self);CivRegisterBefore<CivHooks::CvTeam_DoTestSmallAwards>(host, &BeforeCvTeam_DoTestSmallAwards);CivRegisterAfter<CivHooks::CvTeam_DoTestSmallAwards>(host, &AfterCvTeam_DoTestSmallAwards);CivRegisterReplace<CivHooks::CvTeam_DoTestSmallAwards>(host, &ReplaceCvTeam_DoTestSmallAwards);

Code

5250/// See if there are any Small Awards we've just accomplished5251void CvTeam::DoTestSmallAwards()5252{5253	if(!isAlive() || isMinorCiv())5254	{5255		return;5256	}52575258	int iPlayerLoop;5259	PlayerTypes ePlayer;52605261	CvCity* pLoopCity;5262	int iCityLoop;52635264	int iAwardRequirement;52655266	bool bShouldShowNotification;5267	int iNotificationData;5268	int iNotificationX, iNotificationY;52695270	for(int iSmallAwardLoop = 0; iSmallAwardLoop < GC.getNumSmallAwardInfos(); iSmallAwardLoop++)5271	{5272		SmallAwardTypes eAward = static_cast<SmallAwardTypes>(iSmallAwardLoop);5273		CvSmallAwardInfo* pkSmallAwardInfo = GC.getSmallAwardInfo(eAward);5274		if(pkSmallAwardInfo)5275		{5276			bShouldShowNotification = false;5277			iNotificationX = -1;5278			iNotificationY = -1;52795280			if(!IsSmallAwardAchieved(eAward))5281			{5282				// Cities5283				iAwardRequirement = GC.getSmallAwardInfo(eAward)->GetNumCities();5284				if(iAwardRequirement > 0)5285				{5286					for(iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)5287					{5288						ePlayer = (PlayerTypes) iPlayerLoop;52895290						if(GET_PLAYER(ePlayer).getTeam() == GetID())5291						{5292							if(GET_PLAYER(ePlayer).getNumCities() >= iAwardRequirement)5293							{5294								SetSmallAwardAchieved(eAward, true);5295								changeVictoryPoints(GC.getSmallAwardInfo(eAward)->GetNumVictoryPoints());52965297								bShouldShowNotification = true;5298								iNotificationData = iAwardRequirement;52995300								if(GET_PLAYER(ePlayer).getCapitalCity() != NULL)5301								{5302									iNotificationX = GET_PLAYER(ePlayer).getCapitalCity()->getX();5303									iNotificationY = GET_PLAYER(ePlayer).getCapitalCity()->getY();5304								}5305							}5306						}5307					}5308				}53095310				// Population5311				iAwardRequirement = pkSmallAwardInfo->GetCityPopulation();5312				if(iAwardRequirement > 0)5313				{5314					for(iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)5315					{5316						ePlayer = (PlayerTypes) iPlayerLoop;53175318						if(GET_PLAYER(ePlayer).getTeam() == GetID())5319						{5320							// Check all Cities5321							for(pLoopCity = GET_PLAYER(ePlayer).firstCity(&iCityLoop); pLoopCity != NULL; pLoopCity = GET_PLAYER(ePlayer).nextCity(&iCityLoop))5322							{5323								if(pLoopCity->getPopulation() >= iAwardRequirement)5324								{5325									SetSmallAwardAchieved(eAward, true);5326									changeVictoryPoints(pkSmallAwardInfo->GetNumVictoryPoints());53275328									bShouldShowNotification = true;5329									iNotificationData = iAwardRequirement;5330									iNotificationX = pLoopCity->getX();5331									iNotificationY = pLoopCity->getY();5332								}5333							}5334						}5335					}5336				}53375338				// Give notification to all players on this team5339				if(bShouldShowNotification)5340				{5341					CvString strBuffer;5342					CvString strSummary;5343					for(iPlayerLoop = 0; iPlayerLoop < MAX_MAJOR_CIVS; iPlayerLoop++)5344					{5345						ePlayer = (PlayerTypes) iPlayerLoop;53465347						if(GET_PLAYER(ePlayer).getTeam() == GetID())5348						{5349							CvNotifications* pNotifications = GET_PLAYER(ePlayer).GetNotifications();5350							if(pNotifications)5351							{5352								if(getNumMembers() == 1)5353								{5354									strBuffer = GetLocalizedText(pkSmallAwardInfo->GetNotificationString(), iNotificationData, pkSmallAwardInfo->GetNumVictoryPoints());5355									strSummary = GetLocalizedText(pkSmallAwardInfo->GetDescription());5356								}5357								// Team game, different string5358								else5359								{5360									strBuffer = GetLocalizedText(pkSmallAwardInfo->GetTeamNotificationString(), iNotificationData, pkSmallAwardInfo->GetNumVictoryPoints());5361									strSummary = GetLocalizedText(pkSmallAwardInfo->GetDescription());5362								}5363								pNotifications->Add(NOTIFICATION_VICTORY, strBuffer, strSummary, iNotificationX, iNotificationY, -1);5364							}5365						}5366					}5367				}5368			}5369		}5370	}5371}

Calls

Called by