From: Samual Lenks Date: Tue, 25 Sep 2012 23:22:01 +0000 (-0400) Subject: Keep track of "Maxmimum notifications" limit X-Git-Tag: xonotic-v0.7.0~62^2~23^2~417 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=7b85c4374ffbfc05fd6e64e5978bcff2cd1129ed;p=xonotic%2Fxonotic-data.pk3dir.git Keep track of "Maxmimum notifications" limit --- diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 487e26526..d3a2b20fc 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -16,19 +16,22 @@ // accumulate functions for declarations #define NOTIF_FIRST 1 -#define NOTIF_MAX 1024 +#define NOTIF_MAX 1024 // limit of recursive functions with ACCUMULATE_FUNCTION float NOTIF_INFO_COUNT; float NOTIF_NOTIFY_COUNT; float NOTIF_CENTER_COUNT; float NOTIF_WEAPON_COUNT; float NOTIF_CPID_COUNT; +#define CHECK_MAX_NOTIFICATIONS(count) if(count == NOTIF_MAX) { error("Maximum notifications hit!\n"); } + #define MSG_INFO_NOTIF(name,args,normal,gentle) \ float name; \ void DecNotif_##name() { \ if(!name) { \ name = (NOTIF_FIRST + NOTIF_INFO_COUNT); \ - ++NOTIF_INFO_COUNT; } } \ + ++NOTIF_INFO_COUNT; } \ + CHECK_MAX_NOTIFICATIONS(NOTIF_INFO_COUNT) } \ ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name) #define MSG_NOTIFY_NOTIF(name,args,icon,normal,gentle) \ @@ -36,7 +39,8 @@ float NOTIF_CPID_COUNT; void DecNotif_##name() { \ if(!name) { \ name = (NOTIF_FIRST + NOTIF_NOTIFY_COUNT); \ - ++NOTIF_NOTIFY_COUNT; } } \ + ++NOTIF_NOTIFY_COUNT; } \ + CHECK_MAX_NOTIFICATIONS(NOTIF_NOTIFY_COUNT) } \ ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name) #define MSG_CENTER_NOTIF(name,args,cpid,normal,gentle) \ @@ -48,7 +52,8 @@ float NOTIF_CPID_COUNT; ++NOTIF_CENTER_COUNT; } \ if(!cpid) { \ cpid = (NOTIF_FIRST + NOTIF_CPID_COUNT); \ - ++NOTIF_CPID_COUNT; } } \ + ++NOTIF_CPID_COUNT; } \ + CHECK_MAX_NOTIFICATIONS(NOTIF_CENTER_COUNT) } \ ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name) #define MSG_WEAPON_NOTIF(name,args,normal,gentle) \ @@ -56,7 +61,8 @@ float NOTIF_CPID_COUNT; void DecNotif_##name() { \ if(!name) { \ name = (NOTIF_FIRST + NOTIF_WEAPON_COUNT); \ - ++NOTIF_WEAPON_COUNT; } } \ + ++NOTIF_WEAPON_COUNT; } \ + CHECK_MAX_NOTIFICATIONS(NOTIF_WEAPON_COUNT) } \ ACCUMULATE_FUNCTION(DecNotifs, DecNotif_##name)