From: Samual Lenks Date: Fri, 8 Feb 2013 23:40:43 +0000 (-0500) Subject: Transfer the switch into yet another macro X-Git-Tag: xonotic-v0.7.0~62^2~23^2~254 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=b846591d474a2012722ccae237e87923fae77848;p=xonotic%2Fxonotic-data.pk3dir.git Transfer the switch into yet another macro --- diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 994b5d7e4..fdd93459a 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -25,11 +25,7 @@ string Get_Field_Value(float field, float net_type, float net_name) { #define MSG_INFO_NOTIF(name,strnum,flnum,args,hudargs,icon,normal,gentle) case name: { GET_FIELD_VALUE_OUTPUT(field,name,strnum,flnum) } - switch(net_name) - { - MSG_INFO_NOTIFICATIONS - default: { backtrace(strcat("^1NOTIFICATION HAD NO MATCH: ^7net_type = MSG_INFO, net_name = ", ftos(net_name), ".\n")); return ""; } - } + NOTIF_SWITCH_LIST(MSG_INFO, net_name, return "") #undef MSG_INFO_NOTIF break; @@ -38,11 +34,7 @@ string Get_Field_Value(float field, float net_type, float net_name) { #define MSG_CENTER_NOTIF(name,strnum,flnum,args,cpid,durcnt,normal,gentle) case name: { GET_FIELD_VALUE_OUTPUT(field,name,strnum,flnum) } - switch(net_name) - { - MSG_CENTER_NOTIFICATIONS - default: { backtrace(strcat("^1NOTIFICATION HAD NO MATCH: ^7net_type = MSG_CENTER, net_name = ", ftos(net_name), ".\n")); return ""; } - } + NOTIF_SWITCH_LIST(MSG_CENTER, net_name, return "") #undef MSG_CENTER_NOTIF break; @@ -53,11 +45,7 @@ string Get_Field_Value(float field, float net_type, float net_name) max(CLPSE_GETVALUE(infoname, MSG_INFO, F_STRNUM), CLPSE_GETVALUE(centername, MSG_CENTER, F_STRNUM)), \ max(CLPSE_GETVALUE(infoname, MSG_INFO, F_FLNUM), CLPSE_GETVALUE(centername, MSG_CENTER, F_FLNUM))) } - switch(net_name) - { - MSG_WEAPON_NOTIFICATIONS - default: { backtrace(strcat("^1NOTIFICATION HAD NO MATCH: ^7net_type = MSG_WEAPON, net_name = ", ftos(net_name), ".\n")); return ""; } - } + NOTIF_SWITCH_LIST(MSG_WEAPON, net_name, return "") #undef MSG_WEAPON_NOTIF break; @@ -68,11 +56,7 @@ string Get_Field_Value(float field, float net_type, float net_name) max(CLPSE_GETVALUE(infoname, MSG_INFO, F_STRNUM), CLPSE_GETVALUE(centername, MSG_CENTER, F_STRNUM)), \ max(CLPSE_GETVALUE(infoname, MSG_INFO, F_FLNUM), CLPSE_GETVALUE(centername, MSG_CENTER, F_FLNUM))) } - switch(net_name) - { - MSG_DEATH_NOTIFICATIONS - default: { backtrace(strcat("^1NOTIFICATION HAD NO MATCH: ^7net_type = MSG_DEATH, net_name = ", ftos(net_name), ".\n")); return ""; } - } + NOTIF_SWITCH_LIST(MSG_DEATH, net_name, return "") #undef MSG_DEATH_NOTIF break; @@ -174,11 +158,7 @@ void Local_Notification(float net_type, float net_name, ...count) #endif \ } return; } - switch(net_name) - { - MSG_INFO_NOTIFICATIONS - default: { backtrace(strcat("^1NOTIFICATION HAD NO MATCH: ^7net_type = MSG_INFO, net_name = ", ftos(net_name), ".\n")); return; } - } + NOTIF_SWITCH_LIST(MSG_INFO, net_name, return) #undef MSG_INFO_NOTIF break; @@ -192,11 +172,7 @@ void Local_Notification(float net_type, float net_name, ...count) centerprint_generic(HANDLE_CPID(cpid), sprintf(CCR(normal_or_gentle(normal, gentle)), args), durcnt); \ } return; } - switch(net_name) - { - MSG_CENTER_NOTIFICATIONS - default: { backtrace(strcat("^1NOTIFICATION HAD NO MATCH: ^7net_type = MSG_CENTER, net_name = ", ftos(net_name), ".\n")); return; } - } + NOTIF_SWITCH_LIST(MSG_CENTER, net_name, return) #undef MSG_CENTER_NOTIF break; @@ -223,11 +199,7 @@ void Local_Notification(float net_type, float net_name, ...count) #endif \ } return; } - switch(net_name) - { - MSG_WEAPON_NOTIFICATIONS - default: { backtrace(strcat("^1NOTIFICATION HAD NO MATCH: ^7net_type = MSG_WEAPON, net_name = ", ftos(net_name), ".\n")); return; } - } + NOTIF_SWITCH_LIST(MSG_WEAPON, net_name, return) #undef MSG_WEAPON_NOTIF break; @@ -253,11 +225,7 @@ void Local_Notification(float net_type, float net_name, ...count) #endif \ } return; } - switch(net_name) - { - MSG_DEATH_NOTIFICATIONS - default: { backtrace(strcat("^1NOTIFICATION HAD NO MATCH: ^7net_type = MSG_DEATH, net_name = ", ftos(net_name), ".\n")); return; } - } + NOTIF_SWITCH_LIST(MSG_DEATH, net_name, return) #undef MSG_DEATH_NOTIF break; diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index a1f2e7e46..d3a93ea0e 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -89,6 +89,13 @@ string got_commandkey; #define ADD_AUTOCVAR(name) var float autocvar_notification_##name = TRUE; #define CHECK_AUTOCVAR(name) if(autocvar_notification_##name) +#define NOTIF_SWITCH_LIST(net_type,net_name,returnv) \ + switch(net_name) \ + { \ + ##net_type##_NOTIFICATIONS \ + default: { backtrace(strcat("^1NOTIFICATION HAD NO MATCH: ^7net_type = ##net_type##, net_name = ", ftos(net_name), ".\n")); returnv; } \ + } + string Get_Field_Value(float field, float net_type, float net_name); // get the actual name of a notification and return it as a string void Local_Notification(float net_type, float net_name, ...count); void Local_Notification_Without_VarArgs(float net_type, float net_name, float stringcount, float floatcount, string s1, string s2, string s3, string s4, float f1, float f2, float f3, float f4);