Bazaar developer reference

CvNotifications::IsNotificationRedundant(Notification &)

Defined in
CvNotifications.cpp, line 1259
Class
CvNotifications
Hook name
CivHooks::CvNotifications_IsNotificationRedundant

Hooks

static bool BeforeCvNotifications_IsNotificationRedundant(CvNotifications* self, CvNotifications::Notification & notification, bool& result);static void AfterCvNotifications_IsNotificationRedundant(CvNotifications* self, CvNotifications::Notification & notification, bool& result);static bool ReplaceCvNotifications_IsNotificationRedundant(bool (*original)(CvNotifications*, CvNotifications::Notification &), CvNotifications* self, CvNotifications::Notification & notification);CivRegisterBefore<CivHooks::CvNotifications_IsNotificationRedundant>(host, &BeforeCvNotifications_IsNotificationRedundant);CivRegisterAfter<CivHooks::CvNotifications_IsNotificationRedundant>(host, &AfterCvNotifications_IsNotificationRedundant);CivRegisterReplace<CivHooks::CvNotifications_IsNotificationRedundant>(host, &ReplaceCvNotifications_IsNotificationRedundant);

Code

1259bool CvNotifications::IsNotificationRedundant(Notification& notification)1260{1261	switch(notification.m_eNotificationType)1262	{1263	case NOTIFICATION_TECH:1264	{1265		int iIndex = m_iNotificationsBeginIndex;1266		while(iIndex != m_iNotificationsEndIndex)1267		{1268			if(notification.m_eNotificationType == m_aNotifications[iIndex].m_eNotificationType)1269			{1270				if(!notification.m_bDismissed && !m_aNotifications[iIndex].m_bDismissed)1271				{1272					if (IsNotificationTypeEndOfTurnExpired(notification.m_eNotificationType) && notification.m_bWaitExtraTurn)1273					{1274						if (m_aNotifications[iIndex].m_bWaitExtraTurn)1275							return true;1276					}1277					else1278						// We already added this kind of notification so we don't need another1279						return true;1280				}1281			}128212831284			iIndex++;1285			if(iIndex >= (int)m_aNotifications.size())1286			{1287				iIndex = 0;1288			}1289		}12901291		return false;1292	}1293	break;12941295	case NOTIFICATION_FREE_TECH:1296	{1297		int iIndex = m_iNotificationsBeginIndex;1298		while(iIndex != m_iNotificationsEndIndex)1299		{1300			if(notification.m_eNotificationType == m_aNotifications[iIndex].m_eNotificationType)1301			{1302				if(!notification.m_bDismissed && !m_aNotifications[iIndex].m_bDismissed)1303				{1304					// we've already added a free tech notification, don't need another1305					return true;1306				}1307			}130813091310			iIndex++;1311			if(iIndex >= (int)m_aNotifications.size())1312			{1313				iIndex = 0;1314			}1315		}13161317		return false;1318	}1319	break;13201321	case NOTIFICATION_POLICY:1322	{1323		int iIndex = m_iNotificationsBeginIndex;1324		while(iIndex != m_iNotificationsEndIndex)1325		{1326			if(notification.m_eNotificationType == m_aNotifications[iIndex].m_eNotificationType)1327			{1328				if(!notification.m_bDismissed && !m_aNotifications[iIndex].m_bDismissed)1329				{1330					// we've already added a policy notification, don't need another1331					return true;1332				}1333			}133413351336			iIndex++;1337			if(iIndex >= (int)m_aNotifications.size())1338			{1339				iIndex = 0;1340			}1341		}13421343		return false;1344	}1345	break;13461347	case NOTIFICATION_FREE_POLICY:1348	{1349		int iIndex = m_iNotificationsBeginIndex;1350		while(iIndex != m_iNotificationsEndIndex)1351		{1352			if(notification.m_eNotificationType == m_aNotifications[iIndex].m_eNotificationType)1353			{1354				if(!notification.m_bDismissed && !m_aNotifications[iIndex].m_bDismissed)1355				{1356					// we've already added a tech notification, don't need another1357					return true;1358				}1359			}136013611362			iIndex++;1363			if(iIndex >= (int)m_aNotifications.size())1364			{1365				iIndex = 0;1366			}1367		}13681369		return false;1370	}1371	break;13721373	case NOTIFICATION_PRODUCTION:1374	{1375		int iIndex = m_iNotificationsBeginIndex;1376		while(iIndex != m_iNotificationsEndIndex)1377		{1378			if(notification.m_eNotificationType == m_aNotifications[iIndex].m_eNotificationType &&1379			        notification.m_iX == m_aNotifications[iIndex].m_iX &&1380			        notification.m_iY == m_aNotifications[iIndex].m_iY)1381			{1382				if(!notification.m_bDismissed && !m_aNotifications[iIndex].m_bDismissed)1383				{1384					// we've already added a notification for this city to the notification system, so don't add another one1385					return true;1386				}1387			}13881389			iIndex++;1390			if(iIndex >= (int)m_aNotifications.size())1391			{1392				iIndex = 0;1393			}1394		}13951396		return false;1397	}1398	break;13991400#if defined(MOD_UI_CITY_EXPANSION)1401	case NOTIFICATION_CITY_TILE:1402	{1403		if (MOD_UI_CITY_EXPANSION) {1404			int iIndex = m_iNotificationsBeginIndex;1405			while(iIndex != m_iNotificationsEndIndex)1406			{1407				if(notification.m_eNotificationType == m_aNotifications[iIndex].m_eNotificationType &&1408				   notification.m_iX == m_aNotifications[iIndex].m_iX && notification.m_iY == m_aNotifications[iIndex].m_iY)1409				{1410					if(!notification.m_bDismissed && !m_aNotifications[iIndex].m_bDismissed)1411					{1412						// we've already added a notification for this city to the notification system, so don't add another one1413						return true;1414					}1415				}14161417				iIndex++;1418				if(iIndex >= (int)m_aNotifications.size())1419				{1420					iIndex = 0;1421				}1422			}1423		}14241425		return false;1426	}1427	break;1428#endif14291430	case NOTIFICATION_ENEMY_IN_TERRITORY:1431	{1432		int iIndex = m_iNotificationsBeginIndex;1433		while(iIndex != m_iNotificationsEndIndex)1434		{1435			// Only one "enemy in territory" notification at a time1436			if(notification.m_eNotificationType == m_aNotifications[iIndex].m_eNotificationType)1437			{1438				if(!notification.m_bDismissed && !m_aNotifications[iIndex].m_bDismissed)1439				{1440					return true;1441				}1442			}14431444			iIndex++;1445			if(iIndex >= (int)m_aNotifications.size())1446			{1447				iIndex = 0;1448			}1449		}14501451		return false;1452	}1453	break;14541455	case NOTIFICATION_UNIT_PROMOTION:1456	{1457		int iIndex = m_iNotificationsBeginIndex;1458		while(iIndex != m_iNotificationsEndIndex)1459		{1460			if(notification.m_eNotificationType == m_aNotifications[iIndex].m_eNotificationType)1461			{1462				if(notification.m_iExtraGameData == m_aNotifications[iIndex].m_iExtraGameData)1463				{1464					if(!notification.m_bDismissed && !m_aNotifications[iIndex].m_bDismissed)1465					{1466						// we've already added a notification for this unit to the notification system, so don't add another one1467						return true;1468					}1469				}1470			}14711472			iIndex++;1473			if(iIndex >= (int)m_aNotifications.size())1474			{1475				iIndex = 0;1476			}1477		}14781479		return false;1480	}1481	break;14821483	case NOTIFICATION_DIPLOMACY_DECLARATION:1484	{1485		PlayerTypes eOurPlayer1 = (PlayerTypes) notification.m_iGameDataIndex;1486		PlayerTypes eOurPlayer2 = (PlayerTypes) notification.m_iExtraGameData;14871488		// Notification is NOT being used to inform of a DoF or Denouncement (otherwise there would be valid players in these slots)1489		if(eOurPlayer1 == -1 || eOurPlayer2 == -1)1490			return false;14911492		PlayerTypes eCheckingPlayer1, eCheckingPlayer2;14931494		int iIndex = m_iNotificationsBeginIndex;1495		while(iIndex != m_iNotificationsEndIndex)1496		{1497			if(notification.m_eNotificationType == m_aNotifications[iIndex].m_eNotificationType)1498			{1499				eCheckingPlayer1 = (PlayerTypes) m_aNotifications[iIndex].m_iGameDataIndex;1500				eCheckingPlayer2 = (PlayerTypes) m_aNotifications[iIndex].m_iExtraGameData;15011502				// Players match - we already have a notification with this player combo1503				if((eOurPlayer1 == eCheckingPlayer1 && eOurPlayer2 == eCheckingPlayer2) ||1504				        (eOurPlayer1 == eCheckingPlayer2 && eOurPlayer2 == eCheckingPlayer1))1505				{1506					return true;1507				}1508			}15091510			iIndex++;1511			if(iIndex >= (int)m_aNotifications.size())1512				iIndex = 0;1513		}15141515		return false;1516	}1517	break;15181519	case NOTIFICATION_FOUND_PANTHEON:1520	case NOTIFICATION_FOUND_RELIGION:1521	case NOTIFICATION_ENHANCE_RELIGION:1522	case NOTIFICATION_ADD_REFORMATION_BELIEF:1523	case NOTIFICATION_CHOOSE_ARCHAEOLOGY:1524	case NOTIFICATION_CHOOSE_IDEOLOGY:1525	{1526		int iIndex = m_iNotificationsBeginIndex;1527		while(iIndex != m_iNotificationsEndIndex)1528		{1529			if(notification.m_eNotificationType == m_aNotifications[iIndex].m_eNotificationType)1530			{1531				if(!notification.m_bDismissed && !m_aNotifications[iIndex].m_bDismissed)1532				{1533					// we've already added a pantheon notification, don't need another1534					return true;1535				}1536			}153715381539			iIndex++;1540			if(iIndex >= (int)m_aNotifications.size())1541			{1542				iIndex = 0;1543			}1544		}15451546		return false;1547	}1548	break;15491550	case NOTIFICATION_LEAGUE_CALL_FOR_PROPOSALS:1551	case NOTIFICATION_LEAGUE_CALL_FOR_VOTES:1552	case NOTIFICATION_LEAGUE_VOTING_SOON:1553	{1554		int iIndex = m_iNotificationsBeginIndex;1555		while(iIndex != m_iNotificationsEndIndex)1556		{1557			if(notification.m_eNotificationType == m_aNotifications[iIndex].m_eNotificationType)1558			{1559				if(!notification.m_bDismissed && !m_aNotifications[iIndex].m_bDismissed)1560				{1561					// we've already added one of this notification type, don't need another1562					return true;1563				}1564			}156515661567			iIndex++;1568			if(iIndex >= (int)m_aNotifications.size())1569			{1570				iIndex = 0;1571			}1572		}1573		return false;1574	}1575	break;15761577	case NOTIFICATION_LEAGUE_PROJECT_COMPLETE:1578	case NOTIFICATION_LEAGUE_PROJECT_PROGRESS:1579		{1580			int iIndex = m_iNotificationsBeginIndex;1581			while(iIndex != m_iNotificationsEndIndex)1582			{1583				if(notification.m_eNotificationType == m_aNotifications[iIndex].m_eNotificationType)1584				{1585					if(!notification.m_bDismissed && !m_aNotifications[iIndex].m_bDismissed)1586					{1587						// Same League ID1588						if (notification.m_iGameDataIndex == m_aNotifications[iIndex].m_iGameDataIndex)1589						{1590							// Same Project type1591							if (notification.m_iExtraGameData == m_aNotifications[iIndex].m_iExtraGameData)1592							{1593								return true;1594							}1595						}1596					}1597				}159815991600				iIndex++;1601				if(iIndex >= (int)m_aNotifications.size())1602				{1603					iIndex = 0;1604				}1605			}1606			return false;1607		}1608		break;16091610	default:1611		return false;1612		break;1613	}1614}

Calls

Called by