Bazaar developer reference

CvNotifications::Add(NotificationTypes, const char *, const char *, int, int, int, int)

Defined in
CvNotifications.cpp, line 404
Class
CvNotifications
Hook name
CivHooks::CvNotifications_Add
Changed in
0.5.0

Hand-placed hooks inside

A replacement for this function that does not call original stops these hooks from running.

Hooks

static bool BeforeCvNotifications_Add(CvNotifications* self, NotificationTypes eNotificationType, const char* strMessage, const char* strSummary, int iX, int iY, int iGameDataIndex, int iExtraGameData, int& result);static void AfterCvNotifications_Add(CvNotifications* self, NotificationTypes eNotificationType, const char* strMessage, const char* strSummary, int iX, int iY, int iGameDataIndex, int iExtraGameData, int& result);static int ReplaceCvNotifications_Add(int (*original)(CvNotifications*, NotificationTypes, const char*, const char*, int, int, int, int), CvNotifications* self, NotificationTypes eNotificationType, const char* strMessage, const char* strSummary, int iX, int iY, int iGameDataIndex, int iExtraGameData);CivRegisterBefore<CivHooks::CvNotifications_Add>(host, &BeforeCvNotifications_Add);CivRegisterAfter<CivHooks::CvNotifications_Add>(host, &AfterCvNotifications_Add);CivRegisterReplace<CivHooks::CvNotifications_Add>(host, &ReplaceCvNotifications_Add);

Code

403/// Adds a new notification to the list404int CvNotifications::Add(NotificationTypes eNotificationType, const char* strMessage, const char* strSummary, int iX, int iY, int iGameDataIndex, int iExtraGameData)405{406	// if the player is not human, do not record407	if(!GET_PLAYER(m_ePlayer).isHuman())408	{409		return -1;410	}411412	// If we're in debug mode, don't do anything413	if(GC.getGame().isDebugMode())414		return -1;415416417	Notification newNotification;418	newNotification.Clear();419	newNotification.m_ePlayerID = m_ePlayer;420	newNotification.m_eNotificationType = eNotificationType;421	newNotification.m_strMessage = strMessage;422	newNotification.m_strSummary = strSummary;423	newNotification.m_iX = iX;424	newNotification.m_iY = iY;425	newNotification.m_iGameDataIndex = iGameDataIndex;426	newNotification.m_iExtraGameData = iExtraGameData;427	newNotification.m_iTurn = GC.getGame().getGameTurn();428	newNotification.m_iLookupIndex = m_iCurrentLookupIndex;429	newNotification.m_bNeedsBroadcast = true;430	newNotification.m_bDismissed = false;431	newNotification.m_bWaitExtraTurn = false;432433	// Is this notification being added during the player's auto-moves and will it expire at the end of the turn?434	// If so, set a flag so the notification will stick around for an extra turn.435	if (GET_PLAYER(m_ePlayer).isTurnActive() && GET_PLAYER(m_ePlayer).isAutoMoves() && IsNotificationTypeEndOfTurnExpired(eNotificationType))436		newNotification.m_bWaitExtraTurn = true;437438	if(IsNotificationRedundant(newNotification))439	{440		// redundant notification441		return -1;442	}443444	if(IsArrayFull())445	{446		RemoveOldestNotification();447	}448449	m_aNotifications[m_iNotificationsEndIndex] = newNotification;450451	if(GC.getGame().isFinalInitialized())452	{453		// If the notification is for the 'active' player and that active player actually has his turn active or its not hotseat, then show the notification, else wait454		// The 'active' player is only set to a human and during the AI turn, the 'active' player is the last human to do their turn.455		if(newNotification.m_ePlayerID == GC.getGame().getActivePlayer() && (!CvPreGame::isHotSeatGame() || GET_PLAYER(GC.getGame().getActivePlayer()).isTurnActive()))456		{457			GC.GetEngineUserInterface()->AddNotification(newNotification.m_iLookupIndex, newNotification.m_eNotificationType, newNotification.m_strMessage.c_str(), newNotification.m_strSummary.c_str(), newNotification.m_iGameDataIndex, newNotification.m_iExtraGameData, m_ePlayer, iX, iY);458459#if defined(MOD_UI_CITY_EXPANSION)460			// Don't show effect with production notification or city tile acquisition461			bool bShow = (eNotificationType != NOTIFICATION_PRODUCTION);462			463			if (MOD_UI_CITY_EXPANSION) {464				bShow = bShow && (eNotificationType != NOTIFICATION_CITY_TILE);465			}466			467			if(bShow)468#else469			// Don't show effect with production notification470			if(eNotificationType != NOTIFICATION_PRODUCTION)471#endif472			{473				CvPlot* pPlot = GC.getMap().plot(iX, iY);474				if(pPlot != NULL)475				{476					auto_ptr<ICvPlot1> pDllPlot(new CvDllPlot(pPlot));477					gDLL->GameplayDoFX(pDllPlot.get());478				}479				else480				{481					gDLL->GameplayDoFX(NULL);482				}483484485			}486			m_aNotifications[m_iNotificationsEndIndex].m_bNeedsBroadcast = false;487		}488489		gDLL->GameplayMinimapNotification(iX, iY, m_iCurrentLookupIndex+1);	// The index is used to uniquely identify each flashing dot on the minimap. We're adding 1 since the selected unit is always 0. It ain't pretty, but it'll work490	}491492	IncrementEndIndex();493494	m_iCurrentLookupIndex++;495496#if defined(CIV_HOST_API)497	CivHandNotificationAdded(m_ePlayer, eNotificationType, strMessage, strSummary, iX, iY, iGameDataIndex, iExtraGameData,hand-placed hook: NotificationAdded498		newNotification.m_iLookupIndex);499#endif500	return newNotification.m_iLookupIndex;501}

Calls

Called by

116 functions in 25 files