{
// kill all networked notifications and centerprints
#ifdef SVQC
- Kill_Notification(NOTIF_ALL, NULL, 0, 0);
+ Kill_Notification(NOTIF_ALL, NULL, MSG_Null, 0);
#else
reset_centerprint_messages();
#endif
}
string Process_Notif_Line(
- int typeId,
+ MSG typeId,
bool chat,
string input,
string notiftype,
if(substring(input, (strlen(input) - 1), 1) == "\n")
{
LOG_INFOF(
- strcat(
- "^1TRAILING NEW LINE AT END OF NOTIFICATION: ",
+ (
+ "^1TRAILING NEW LINE AT END OF NOTIFICATION: "
"^7net_type = %s, net_name = %s, string = %s.\n"
),
notiftype,
if(sel_num == NOTIF_MAX_ARGS)
{
LOG_INFOF(
- strcat(
- "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
+ (
+ "^1NOTIFICATION HAS TOO MANY ARGUMENTS: "
"^7net_type = %s, net_name = %s, max args = %d.\n"
),
notiftype,
default:
{
LOG_INFOF(
- strcat(
- "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
+ (
+ "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: "
"^7net_type = %s, net_name = %s, args arg = '%s'.\n"
),
notiftype,
if(sel_num == NOTIF_MAX_HUDARGS)
{
LOG_INFOF(
- strcat(
- "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
+ (
+ "^1NOTIFICATION HAS TOO MANY ARGUMENTS: "
"^7net_type = %s, net_name = %s, max hudargs = %d.\n"
),
notiftype,
default:
{
LOG_INFOF(
- strcat(
- "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
+ (
+ "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: "
"^7net_type = %s, net_name = %s, hudargs arg = '%s'.\n"
),
notiftype,
if(sel_num == NOTIF_MAX_DURCNT)
{
LOG_INFOF(
- strcat(
- "^1NOTIFICATION HAS TOO MANY ARGUMENTS: ",
+ (
+ "^1NOTIFICATION HAS TOO MANY ARGUMENTS: "
"^7net_type = %s, net_name = %s, max durcnt = %d.\n"
),
notiftype,
else
{
LOG_INFOF(
- strcat(
- "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: ",
+ (
+ "^1NOTIFICATION WITH UNKNOWN TOKEN IN ARGUMENT STRING: "
"^7net_type = %s, net_name = %s, durcnt arg = '%s'.\n"
),
notiftype,
void Create_Notification_Entity(entity notif,
float var_default,
float var_cvar,
- int typeId,
+ MSG typeId,
string namestring)
{
// =====================
break;
default:
LOG_INFOF(
- strcat(
- "^1NOTIFICATION WITH IMPROPER TYPE: ",
+ (
+ "^1NOTIFICATION WITH IMPROPER TYPE: "
"^7net_type = %d, net_name = %s.\n"
),
typeId,
{
// Set MSG_ANNCE information and handle precaching
#ifdef CSQC
- int typeId = MSG_ANNCE;
+ MSG typeId = MSG_ANNCE;
if (!(GENTLE && (var_cvar == 1)))
{
if(snd != "")
{
string typestring = Get_Notif_TypeName(typeId);
LOG_INFOF(
- strcat(
- "^1NOTIFICATION WITH NO SOUND: ",
+ (
+ "^1NOTIFICATION WITH NO SOUND: "
"^7net_type = %s, net_name = %s.\n"
),
typestring,
string normal,
string gentle)
{
- int typeId = notif.nent_type;
+ MSG typeId = notif.nent_type;
// Set MSG_INFO and MSG_CENTER string/float counts
notif.nent_stringcount = strnum;
notif.nent_floatcount = flnum;
else if((hudargs == "") && (durcnt ==""))
{
LOG_INFOF(
- strcat(
- "^1NOTIFICATION HAS ARG COUNTS BUT NO ARGS OR HUDARGS OR DURCNT: ",
+ (
+ "^1NOTIFICATION HAS ARG COUNTS BUT NO ARGS OR HUDARGS OR DURCNT: "
"^7net_type = %s, net_name = %s, strnum = %d, flnum = %d\n"
),
typestring,
else
{
LOG_INFOF(
- strcat(
- "^1NOTIFICATION HAS HUDARGS BUT NO ICON: ",
+ (
+ "^1NOTIFICATION HAS HUDARGS BUT NO ICON: "
"^7net_type = %s, net_name = %s.\n"
),
typestring,
else if(icon != "")
{
LOG_INFOF(
- strcat(
- "^1NOTIFICATION HAS ICON BUT NO HUDARGS: ",
+ (
+ "^1NOTIFICATION HAS ICON BUT NO HUDARGS: "
"^7net_type = %s, net_name = %s.\n"
),
typestring,
else
{
LOG_INFOF(
- strcat(
- "^1NOTIFICATION HAS DURCNT BUT NO CPID: ",
+ (
+ "^1NOTIFICATION HAS DURCNT BUT NO CPID: "
"^7net_type = %s, net_name = %s.\n"
),
typestring,
if(notif.nent_string == "")
{
LOG_INFOF(
- strcat(
- "^1EMPTY NOTIFICATION: ",
+ (
+ "^1EMPTY NOTIFICATION: "
"^7net_type = %s, net_name = %s.\n"
),
typestring,
Notification infoname,
Notification centername)
{
- int typeId = MSG_MULTI;
+ MSG typeId = MSG_MULTI;
// Set MSG_MULTI string/float counts
if((anncename == NO_MSG) && (infoname == NO_MSG) && (centername == NO_MSG))
{
string typestring = Get_Notif_TypeName(typeId);
LOG_INFOF(
- strcat(
- "^1NOTIFICATION WITH NO SUBCALLS: ",
+ (
+ "^1NOTIFICATION WITH NO SUBCALLS: "
"^7net_type = %s, net_name = %s.\n"
),
typestring,
/* MSG_CHOICE */
float challow_def,
float challow_var,
- int chtype,
+ MSG chtype,
Notification optiona,
Notification optionb)
{
- int typeId = MSG_CHOICE;
- if((chtype == NO_MSG_) || (optiona == NO_MSG) || (optionb == NO_MSG))
+ MSG typeId = MSG_CHOICE;
+ if((chtype == MSG_Null) || (optiona == NO_MSG) || (optionb == NO_MSG))
{
string typestring = Get_Notif_TypeName(typeId);
LOG_INFOF(
- strcat(
- "^1NOTIFICATION IS MISSING CHOICE PARAMS: ",
+ (
+ "^1NOTIFICATION IS MISSING CHOICE PARAMS: "
"^7net_type = %s, net_name = %s.\n"
),
typestring,
);
NOTIF_WRITE(sprintf(
- strcat(
- "\n// Notification counts (total = %d): ",
+ (
+ "\n// Notification counts (total = %d): "
"MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d, MSG_CHOICE = %d\n"
),
(
{
#ifdef NOTIFICATIONS_DEBUG
Debug_Notification(sprintf(
- strcat(
- "Local_Notification_sound(world, %f, '%s', %f, %f) ",
+ (
+ "Local_Notification_sound(world, %f, '%s', %f, %f) "
"^1BLOCKED BY ANTISPAM:^7 prevsnd: '%s', timediff: %f, limit: %f\n"
),
soundchannel,
}
#endif
-void Local_Notification(int net_type, Notification net_name, ...count)
+void Local_Notification(MSG net_type, Notification net_name, ...count)
{
// check if this should be aborted
if (net_name == NOTIF_ABORT)
if ((notif.nent_stringcount + notif.nent_floatcount) != count)
{
backtrace(sprintf(
- strcat(
- "Arguments mismatch for Local_Notification(%s, %s, ...)! ",
- "stringcount(%d) + floatcount(%d) != count(%d)\n",
+ (
+ "Arguments mismatch for Local_Notification(%s, %s, ...)! "
+ "stringcount(%d) + floatcount(%d) != count(%d)\n"
"Check the definition and function call for accuracy...?\n"
),
Get_Notif_TypeName(net_type),
// WOVA = Without Variable Arguments
void Local_Notification_WOVA(
- int net_type, Notification net_name,
+ MSG net_type, Notification net_name,
float stringcount, float floatcount,
string s1, string s2, string s3, string s4,
float f1, float f2, float f3, float f4)
NET_HANDLE(ENT_CLIENT_NOTIFICATION, bool is_new)
{
make_pure(this);
- int net_type = ReadByte();
+ MSG net_type = ENUMCAST(MSG, ReadByte());
int net_name = ReadShort();
Notification notif = Get_Notif_Ent(net_type, net_name);
{
if (!Notification_ShouldSend(this.nent_broadcast, client, this.nent_client)) return false;
WriteHeader(MSG_ENTITY, ENT_CLIENT_NOTIFICATION);
- WriteByte(MSG_ENTITY, this.nent_net_type);
+ WriteByte(MSG_ENTITY, ORDINAL(this.nent_net_type));
WriteShort(MSG_ENTITY, this.nent_net_name);
for (int i = 0; i < this.nent_stringcount; ++i) { WriteString(MSG_ENTITY, this.nent_strings[i]); }
for (int i = 0; i < this.nent_floatcount; ++i) { WriteLong(MSG_ENTITY, this.nent_floats[i]); }
void Kill_Notification(
NOTIF broadcast, entity client,
/** primary group */
- float net_type,
+ MSG net_type,
/** secondary group */
float net_name)
{
switch (net_type)
{
- case 0:
+ case MSG_Null:
{
killed_cpid = 0; // kill ALL centerprints
break;
void Send_Notification(
NOTIF broadcast, entity client,
- float net_type, Notification net_name,
+ MSG net_type, Notification net_name,
...count)
{
entity notif = net_name;
// WOVA = Without Variable Arguments
void Send_Notification_WOVA(
NOTIF broadcast, entity client,
- float net_type, Notification net_name,
+ MSG net_type, Notification net_name,
float stringcount, float floatcount,
string s1, string s2, string s3, string s4,
float f1, float f2, float f3, float f4)
// WOCOVA = Without Counts Or Variable Arguments
void Send_Notification_WOCOVA(
NOTIF broadcast, entity client,
- float net_type, Notification net_name,
+ MSG net_type, Notification net_name,
string s1, string s2, string s3, string s4,
float f1, float f2, float f3, float f4)
{
#include "teams.qh"
#include "util.qh"
-// ================================================
-// Unified notification system, written by Samual
-// Last updated: March, 2013
-// ================================================
-
-// main types/groups of notifications
-const int MSG_ANNCE = 1; // "Global" AND "personal" announcer messages
-const int MSG_INFO = 2; // "Global" information messages
-const int MSG_CENTER = 3; // "Personal" centerprint messages
-const int MSG_MULTI = 5; // Subcall MSG_INFO and/or MSG_CENTER notifications
-const int MSG_CHOICE = 6; // Choose which subcall wrapper to activate
-
-const int MSG_CENTER_CPID = 4; // Kill centerprint message
-
-string Get_Notif_TypeName(int net_type)
+/** main types/groups of notifications */
+ENUMCLASS(MSG)
+ /** "Global" AND "personal" announcer messages */
+ CASE(MSG, ANNCE)
+ /** "Global" information messages */
+ CASE(MSG, INFO)
+ /** "Personal" centerprint messages */
+ CASE(MSG, CENTER)
+ /** Subcall MSG_INFO and/or MSG_CENTER notifications */
+ CASE(MSG, MULTI)
+ /** Choose which subcall wrapper to activate */
+ CASE(MSG, CHOICE)
+
+ /** Kill centerprint message */
+ CASE(MSG, CENTER_CPID)
+ENUMCLASS_END(MSG)
+
+string Get_Notif_TypeName(MSG net_type)
{
switch (net_type)
{
void Create_Notification_Entity(entity notif,
float var_default,
float var_cvar,
- float typeId,
+ MSG typeId,
string namestring);
void Create_Notification_Entity_Annce(entity notif,
float var_cvar,
/* MSG_CHOICE */
float challow_def,
float challow_var,
- int chtype,
+ MSG chtype,
Notification optiona,
Notification optionb);
}
#endif
-void Local_Notification(int net_type, Notification net_name, ...count);
+void Local_Notification(MSG net_type, Notification net_name, ...count);
/** glue for networking, forwards to `Local_Notification` */
void Local_Notification_WOVA(
- float net_type, Notification net_name,
+ MSG net_type, Notification net_name,
float stringcount, float floatcount,
string s1, string s2, string s3, string s4,
float f1, float f2, float f3, float f4);
void Kill_Notification(
NOTIF broadcast, entity client,
- float net_type, float net_name);
+ MSG net_type, float net_name);
void Send_Notification(
NOTIF broadcast, entity client,
- float net_type, Notification net_name,
+ MSG net_type, Notification net_name,
...count);
void Send_Notification_WOVA(
NOTIF broadcast, entity client,
- float net_type, Notification net_name,
+ MSG net_type, Notification net_name,
float stringcount, float floatcount,
string s1, string s2, string s3, string s4,
float f1, float f2, float f3, float f4);
void Send_Notification_WOCOVA(
NOTIF broadcast, entity client,
- float net_type, Notification net_name,
+ MSG net_type, Notification net_name,
string s1, string s2, string s3, string s4,
float f1, float f2, float f3, float f4);
#endif
// common notification entity values
.int nent_default;
.bool nent_enabled;
-.int nent_type;
+.MSG nent_type;
.string nent_name;
.int nent_stringcount;
.int nent_floatcount;
.NOTIF nent_broadcast;
#endif
.entity nent_client;
-.float nent_net_type;
+.MSG nent_net_type;
.float nent_net_name;
.string nent_strings[4];
.float nent_floats[4];
}
}
-Notification Get_Notif_Ent(int net_type, int net_name)
+Notification Get_Notif_Ent(MSG net_type, int net_name)
{
if (net_type == MSG_CENTER_CPID) return NULL;
Notification it = _Notifications_from(net_name, NULL);