From: Samual Lenks Date: Wed, 16 Jan 2013 22:37:31 +0000 (-0500) Subject: And now finish Local_Notifications too X-Git-Tag: xonotic-v0.7.0~62^2~23^2~304 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=69a88bf7f23d0ecab76a99e5cca4a0d808c0a492;p=xonotic%2Fxonotic-data.pk3dir.git And now finish Local_Notifications too --- diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 15436ca1e..abc297c33 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -706,22 +706,60 @@ void backtrace(string msg) #endif +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) +{ + #define VARLIST \ + VARITEM(1, 0, s1) \ + VARITEM(2, 0, XPD2(s1, s2)) \ + VARITEM(3, 0, XPD3(s1, s2, s3)) \ + VARITEM(4, 0, XPD4(s1, s2, s3, s4)) \ + VARITEM(0, 1, f1) \ + VARITEM(1, 1, XPD2(s1, f1)) \ + VARITEM(2, 1, XPD2(XPD2(s1, s2), f1)) \ + VARITEM(3, 1, XPD2(XPD3(s1, s2, s3), f1)) \ + VARITEM(4, 1, XPD2(XPD4(s1, s2, s3, s4), f1)) \ + VARITEM(0, 2, XPD2(f1, f2)) \ + VARITEM(1, 2, XPD2(s1, XPD2(f1, f2))) \ + VARITEM(2, 2, XPD2(XPD2(s1, s2), XPD2(f1, f2))) \ + VARITEM(3, 2, XPD2(XPD3(s1, s2, s3), XPD2(f1, f2))) \ + VARITEM(4, 2, XPD2(XPD4(s1, s2, s3, s4), XPD2(f1, f2))) \ + VARITEM(0, 3, XPD3(f1, f2, f3)) \ + VARITEM(1, 3, XPD2(s1, XPD3(f1, f2, f3))) \ + VARITEM(2, 3, XPD2(XPD2(s1, s2), XPD3(f1, f2, f3))) \ + VARITEM(3, 3, XPD2(XPD3(s1, s2, s3), XPD3(f1, f2, f3))) \ + VARITEM(4, 3, XPD2(XPD4(s1, s2, s3, s4), XPD3(f1, f2, f3))) \ + VARITEM(0, 4, XPD4(f1, f2, f3, f4)) \ + VARITEM(1, 4, XPD2(s1, XPD4(f1, f2, f3, f4))) \ + VARITEM(2, 4, XPD2(XPD2(s1, s2), XPD4(f1, f2, f3, f4))) \ + VARITEM(3, 4, XPD2(XPD3(s1, s2, s3), XPD4(f1, f2, f3, f4))) \ + VARITEM(4, 4, XPD2(XPD4(s1, s2, s3, s4), XPD4(f1, f2, f3, f4))) + + #define VARITEM(stringc,floatc,args) if((stringcount == stringc) && (floatcount == floatc)) { Local_Notification(net_type, net_name, args); } + VARLIST + #undef VARITEM + #undef VARLIST +} + void Local_Notification(float net_type, float net_name, ...count) { float stringcount = stof(Get_Field_Value(F_STRNUM, net_type, net_name)); + float floatcount = stof(Get_Field_Value(F_FLNUM, net_type, net_name)); + + if((stringcount + floatcount) > count) { backtrace(strcat("Not enough arguments for Local_Notification! ", strcat("stringcount(", ftos(stringcount), ") + floatcount(", ftos(floatcount), "),"), " > count(", ftos(count), ").\nCheck the notification definition and the function call for accuracy...?\n")); return; } + else if((stringcount + floatcount) < count) { backtrace(strcat("Too many arguments for Local_Notification! ", strcat("stringcount(", ftos(stringcount), ") + floatcount(", ftos(floatcount), "),"), " < count(", ftos(count), ").\nCheck the notification definition and the function call for accuracy...?\n")); return; } - if(stringcount > count) { backtrace("Local_Notification called with incorrect parameters!"); return; } - string s1 = ((0 < stringcount) ? ...(0, string) : NO_STR_ARG); string s2 = ((1 < stringcount) ? ...(1, string) : NO_STR_ARG); - //string s3 = ((2 < count) ? ...(2, string) : NO_STR_ARG); - //string s4 = ((3 < count) ? ...(3, string) : NO_STR_ARG); - float f1 = (((stringcount) < count) ? ...(stringcount, float) : NO_FL_ARG); + string s3 = ((2 < stringcount) ? ...(2, string) : NO_STR_ARG); + string s4 = ((3 < stringcount) ? ...(3, string) : NO_STR_ARG); + float f1 = ((stringcount < count) ? ...(stringcount, float) : NO_FL_ARG); float f2 = (((stringcount + 1) < count) ? ...((stringcount + 1), float) : NO_FL_ARG); float f3 = (((stringcount + 2) < count) ? ...((stringcount + 2), float) : NO_FL_ARG); - //float f4 = (((stringcount + 3) < count) ? ...((stringcount + 3), float) : NO_FL_ARG); + float f4 = (((stringcount + 3) < count) ? ...((stringcount + 3), float) : NO_FL_ARG); - //print("Local_Notification(", ftos(net_type), ", ", Get_Field_Value(F_NAME, net_type, net_name), strcat(", ", s1, ", ", s2, ", ", ftos(f1), strcat(", ", ftos(f2), ", ", ftos(f3), ");\n"))); + print("Local_Notification(", ftos(net_type), ", ", Get_Field_Value(F_NAME, net_type, net_name), strcat(", ", s1, ", ", s2, ", ", s3, ", ", s4, ", "), strcat(ftos(f1), strcat(", ", ftos(f2), ", ", ftos(f3), ", ", ftos(f4), ");\n"))); + switch(net_type) { case MSG_INFO: @@ -757,10 +795,12 @@ void Local_Notification(float net_type, float net_name, ...count) { NOTIF_MATCH(name, net_name) CHECK_AUTOCVAR(name) \ { \ #if infoname != NO_MSG \ - Local_Notification(MSG_INFO, infoname, s1, s2, f1, f2, f3); \ + Local_Notification_Without_VarArgs(MSG_INFO, infoname, stringcount, floatcount, s1, s2, s3, s4, f1, f2, f3, f4); \ #endif \ - #if centername != NO_MSG \ - Local_Notification(MSG_CENTER, centername, s1, s2, f1, f2, f3); \ + #ifdef CSQC \ + #if centername != NO_MSG \ + Local_Notification_Without_VarArgs(MSG_CENTER, centername, stringcount, floatcount, s1, s2, s3, s4, f1, f2, f3, f4); \ + #endif \ #endif \ } } MSG_WEAPON_NOTIFICATIONS @@ -773,10 +813,12 @@ void Local_Notification(float net_type, float net_name, ...count) { NOTIF_MATCH(name, net_name) CHECK_AUTOCVAR(name) \ { \ #if infoname != NO_MSG \ - Local_Notification(MSG_INFO, infoname, s1, s2, f1, f2, f3); \ + Local_Notification_Without_VarArgs(MSG_INFO, infoname, stringcount, floatcount, s1, s2, s3, s4, f1, f2, f3, f4); \ #endif \ - #if centername != NO_MSG \ - Local_Notification(MSG_CENTER, centername, s1, s2, f1, f2, f3); \ + #ifdef CSQC \ + #if centername != NO_MSG \ + Local_Notification_Without_VarArgs(MSG_CENTER, centername, stringcount, floatcount, s1, s2, s3, s4, f1, f2, f3, f4); \ + #endif \ #endif \ } } MSG_DEATH_NOTIFICATIONS @@ -785,40 +827,6 @@ 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) -{ - #define VARLIST \ - VARITEM(1, 0, s1) \ - VARITEM(2, 0, XPD2(s1, s2)) \ - VARITEM(3, 0, XPD3(s1, s2, s3)) \ - VARITEM(4, 0, XPD4(s1, s2, s3, s4)) \ - VARITEM(0, 1, f1) \ - VARITEM(1, 1, XPD2(s1, f1)) \ - VARITEM(2, 1, XPD2(XPD2(s1, s2), f1)) \ - VARITEM(3, 1, XPD2(XPD3(s1, s2, s3), f1)) \ - VARITEM(4, 1, XPD2(XPD4(s1, s2, s3, s4), f1)) \ - VARITEM(0, 2, XPD2(f1, f2)) \ - VARITEM(1, 2, XPD2(s1, XPD2(f1, f2))) \ - VARITEM(2, 2, XPD2(XPD2(s1, s2), XPD2(f1, f2))) \ - VARITEM(3, 2, XPD2(XPD3(s1, s2, s3), XPD2(f1, f2))) \ - VARITEM(4, 2, XPD2(XPD4(s1, s2, s3, s4), XPD2(f1, f2))) \ - VARITEM(0, 3, XPD3(f1, f2, f3)) \ - VARITEM(1, 3, XPD2(s1, XPD3(f1, f2, f3))) \ - VARITEM(2, 3, XPD2(XPD2(s1, s2), XPD3(f1, f2, f3))) \ - VARITEM(3, 3, XPD2(XPD3(s1, s2, s3), XPD3(f1, f2, f3))) \ - VARITEM(4, 3, XPD2(XPD4(s1, s2, s3, s4), XPD3(f1, f2, f3))) \ - VARITEM(0, 4, XPD4(f1, f2, f3, f4)) \ - VARITEM(1, 4, XPD2(s1, XPD4(f1, f2, f3, f4))) \ - VARITEM(2, 4, XPD2(XPD2(s1, s2), XPD4(f1, f2, f3, f4))) \ - VARITEM(3, 4, XPD2(XPD3(s1, s2, s3), XPD4(f1, f2, f3, f4))) \ - VARITEM(4, 4, XPD2(XPD4(s1, s2, s3, s4), XPD4(f1, f2, f3, f4))) - - #define VARITEM(stringc,floatc,args) if((stringcount == stringc) && (floatcount == floatc)) { Local_Notification(net_type, net_name, args); } - VARLIST - #undef VARITEM - #undef VARLIST -} #endif @@ -891,8 +899,8 @@ void Send_Notification(entity client, float broadcast, float net_type, float net /*if(stringcount != f_stringcount) { backtrace(strcat("Incorrect string arguments for notification! stringcount: ", ftos(stringcount), ", f_stringcount: ", ftos(f_stringcount), ".\nCheck the notification definition and the function call for accuracy...?\n")); return; } else if(floatcount != f_floatcount) { backtrace(strcat("Incorrect float arguments for notification! floatcount: ", ftos(floatcount), ", f_floatcount: ", ftos(f_floatcount), ".\nCheck the notification definition and the function call for accuracy...?\n")); return; } - else*/ if((stringcount + floatcount) > count) { backtrace(strcat("Not enough arguments for notification! ", strcat("stringcount(", ftos(stringcount), ") + floatcount(", ftos(floatcount), "),"), " > count(", ftos(count), ").\nCheck the notification definition and the function call for accuracy...?\n")); return; } - else if((stringcount + floatcount) < count) { backtrace(strcat("Too many arguments for notification! ", strcat("stringcount(", ftos(stringcount), ") + floatcount(", ftos(floatcount), "),"), " < count(", ftos(count), ").\nCheck the notification definition and the function call for accuracy...?\n")); return; } + else*/ if((stringcount + floatcount) > count) { backtrace(strcat("Not enough arguments for Send_Notification! ", strcat("stringcount(", ftos(stringcount), ") + floatcount(", ftos(floatcount), "),"), " > count(", ftos(count), ").\nCheck the notification definition and the function call for accuracy...?\n")); return; } + else if((stringcount + floatcount) < count) { backtrace(strcat("Too many arguments for Send_Notification! ", strcat("stringcount(", ftos(stringcount), ") + floatcount(", ftos(floatcount), "),"), " < count(", ftos(count), ").\nCheck the notification definition and the function call for accuracy...?\n")); return; } //if(Count_Proper_Strings(NO_STR_ARG, s1, s2) > stringcount) { backtrace("Too many string arguments for notification!\n"); return; } //if(Count_Proper_Floats(NO_FL_ARG, f1, f2, f3) > floatcount) { backtrace("Too many float arguments for notification!\n"); return; }