From 655365e14a8f0f45141831d04166e9434d8320d1 Mon Sep 17 00:00:00 2001 From: Samual Lenks Date: Wed, 27 Feb 2013 01:02:25 -0500 Subject: [PATCH] Working on notification initialization-- plus, start working on weapons --- qcsrc/common/notifications.qh | 92 +++++++++++++++++++++-------------- qcsrc/common/util.qh | 11 +++++ qcsrc/server/cl_weapons.qc | 9 ++-- 3 files changed, 70 insertions(+), 42 deletions(-) diff --git a/qcsrc/common/notifications.qh b/qcsrc/common/notifications.qh index 91bef5fba..f3f2d50d7 100644 --- a/qcsrc/common/notifications.qh +++ b/qcsrc/common/notifications.qh @@ -1022,44 +1022,52 @@ string Process_Notif_Args(float arg_type, string args, string notiftype, string notif.nent_floatcount = max(infoname_floatcount, centername_floatcount); \ #endif \ #else /* MSG_INFO and MSG_CENTER */ \ - float nent_chat = (autocvar_notification_##name > 1); \ - \ notif.nent_stringcount = strnum; \ notif.nent_floatcount = flnum; \ - if(strnum + flnum) \ - { \ - if(args != "") { notif.nent_args = strzone(Process_Notif_Args(1, args, strtoupper(#type), #name)); } \ - else if((hudargs == "") && (durcnt =="")) { print(sprintf("^1NOTIFICATION HAS ARG COUNTS BUT NO ARGS OR HUDARGS OR DURCNT: ^7net_type = MSG_%s, net_name = %s, strnum = %d, flnum = %d\n", strtoupper(#type), #name, strnum, flnum)); notif_error = TRUE; } \ - } \ - else if(args != "") { notif.nent_args = strzone(Process_Notif_Args(1, args, strtoupper(#type), #name)); } \ \ - /* MSG_INFO only */ \ - if(hudargs != "") \ - { \ - notif.nent_hudargs = strzone(Process_Notif_Args(2, hudargs, strtoupper(#type), #name)); \ - if(icon != "") { notif.nent_icon = strzone(icon); } \ - else { print(sprintf("^1NOTIFICATION HAS HUDARGS BUT NO ICON: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); notif_error = TRUE; } \ - } \ - else if(icon != "") { print(sprintf("^1NOTIFICATION HAS ICON BUT NO HUDARGS: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); notif_error = TRUE; } \ - \ - /* MSG_CENTER only */ \ - if(durcnt != "") \ - { \ - notif.nent_durcnt = strzone(Process_Notif_Args(3, durcnt, strtoupper(#type), #name)); \ - if(cpid != NO_MSG) { notif.nent_cpid = cpid; } \ - else { print(sprintf("^1NOTIFICATION HAS DURCNT BUT NO CPID: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); notif_error = TRUE; } \ - } \ - else if(cpid != NO_MSG) { notif.nent_cpid = cpid; } \ + /* only initialize this information if we're on a client or a dedicated server */ \ + #ifdef SVQC \ + if(server_is_dedicated) { \ + #endif \ \ - /* string setup */ \ - /* select gentle/normal string and bake color codes in on init, this way it does not need to be re-processed at run time */ \ - if(GENTLE) \ - { \ - if(gentle != "") { notif.nent_string = strzone(CCR(Process_Notif_Line(check_newline, nent_chat, gentle, strtoupper(#type), #name, "GENTLE"))); } \ + if(strnum + flnum) \ + { \ + if(args != "") { notif.nent_args = strzone(Process_Notif_Args(1, args, strtoupper(#type), #name)); } \ + else if((hudargs == "") && (durcnt =="")) { print(sprintf("^1NOTIFICATION HAS ARG COUNTS BUT NO ARGS OR HUDARGS OR DURCNT: ^7net_type = MSG_%s, net_name = %s, strnum = %d, flnum = %d\n", strtoupper(#type), #name, strnum, flnum)); notif_error = TRUE; } \ + } \ + else if(args != "") { notif.nent_args = strzone(Process_Notif_Args(1, args, strtoupper(#type), #name)); } \ + \ + /* MSG_INFO only */ \ + if(hudargs != "") \ + { \ + notif.nent_hudargs = strzone(Process_Notif_Args(2, hudargs, strtoupper(#type), #name)); \ + if(icon != "") { notif.nent_icon = strzone(icon); } \ + else { print(sprintf("^1NOTIFICATION HAS HUDARGS BUT NO ICON: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); notif_error = TRUE; } \ + } \ + else if(icon != "") { print(sprintf("^1NOTIFICATION HAS ICON BUT NO HUDARGS: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); notif_error = TRUE; } \ + \ + /* MSG_CENTER only */ \ + if(durcnt != "") \ + { \ + notif.nent_durcnt = strzone(Process_Notif_Args(3, durcnt, strtoupper(#type), #name)); \ + if(cpid != NO_MSG) { notif.nent_cpid = cpid; } \ + else { print(sprintf("^1NOTIFICATION HAS DURCNT BUT NO CPID: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); notif_error = TRUE; } \ + } \ + else if(cpid != NO_MSG) { notif.nent_cpid = cpid; } \ + \ + /* string setup */ \ + /* select gentle/normal string and bake color codes in on init, this way it does not need to be re-processed at run time */ \ + float nent_chat = (autocvar_notification_##name > 1); \ + if(GENTLE) \ + { \ + if(gentle != "") { notif.nent_string = strzone(CCR(Process_Notif_Line(check_newline, nent_chat, gentle, strtoupper(#type), #name, "GENTLE"))); } \ + else if(normal != "") { notif.nent_string = strzone(CCR(Process_Notif_Line(check_newline, nent_chat, normal, strtoupper(#type), #name, "NORMAL"))); } \ + } \ else if(normal != "") { notif.nent_string = strzone(CCR(Process_Notif_Line(check_newline, nent_chat, normal, strtoupper(#type), #name, "NORMAL"))); } \ + if(notif.nent_string == "") { print(sprintf("^1EMPTY NOTIFICATION: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); notif_error = TRUE; } \ + #ifdef SVQC \ } \ - else if(normal != "") { notif.nent_string = strzone(CCR(Process_Notif_Line(check_newline, nent_chat, normal, strtoupper(#type), #name, "NORMAL"))); } \ - if(notif.nent_string == "") { print(sprintf("^1EMPTY NOTIFICATION: ^7net_type = MSG_%s, net_name = %s.\n", strtoupper(#type), #name)); notif_error = TRUE; } \ + #endif \ #endif \ \ /* now check to see if any errors happened */ \ @@ -1183,6 +1191,14 @@ string Process_Notif_Args(float arg_type, string args, string notiftype, string void RegisterNotifications_First() { notif_global_error = FALSE; + + #ifdef SVQC + #define dedi (server_is_dedicated ? "a dedicated " : "") + #else + #define dedi "" + #endif + + print(sprintf("Beginning notification initialization on %s%s program...\n", dedi, PROGNAME)); // maybe do another implementation of this with checksums? for now, we don't need versioning /*if(autocvar_notification_version != NOTIF_VERSION) @@ -1195,17 +1211,21 @@ void RegisterNotifications_First() notif_global_error = TRUE; print(sprintf("^1NOTIFICATION VERSION MISMATCH: ^7program = %s, config = %d, code = %d.\n", - "foobar", autocvar_notification_version, NOTIF_VERSION)); + PROGNAME, autocvar_notification_version, NOTIF_VERSION)); }*/ } void RegisterNotifications_Done() { - if(notif_global_error && autocvar_notification_errors_are_fatal) + if(notif_global_error) { - // shit happened... stop the loading of the program now - error("Notification initialization failed!"); + // shit happened... stop the loading of the program now if this is unacceptable + if(autocvar_notification_errors_are_fatal) + error("Notification initialization failed! Read above and fix the errors!\n"); + else + print("Notification initialization failed! Read above and fix the errors!\n"); } + else { print("Notification initialization successful!\n"); } } // NOW we actually activate the declarations diff --git a/qcsrc/common/util.qh b/qcsrc/common/util.qh index d2b63f7ba..2eebd1b8d 100644 --- a/qcsrc/common/util.qh +++ b/qcsrc/common/util.qh @@ -449,3 +449,14 @@ string process_time(string fields, float seconds); #ifdef SVQC void dedicated_print(string input); #endif + +// todo: better way to do this? +#ifdef MENUQC +#define PROGNAME "MENUQC" +#else +#ifdef SVQC +#define PROGNAME "SVQC" +#else +#define PROGNAME "CSQC" +#endif +#endif diff --git a/qcsrc/server/cl_weapons.qc b/qcsrc/server/cl_weapons.qc index cb40be914..cea561451 100644 --- a/qcsrc/server/cl_weapons.qc +++ b/qcsrc/server/cl_weapons.qc @@ -349,12 +349,9 @@ void W_ThrowWeapon(vector velo, vector delta, float doreduce) W_SwitchWeapon_Force(self, w_getbestweapon(self)); a = W_ThrowNewWeapon(self, w, doreduce, self.origin + delta, velo); - if not(a) - return; - if(a == "") - sprint(self, strcat("You dropped the ^2", W_Name(w), "\n")); - else - sprint(self, strcat("You dropped the ^2", W_Name(w), " with ", a, "\n")); + + if not(a) return; + Send_Notification(NOTIF_ONE, self, MSG_WEAPON, INFO_WEAPON_DROPPED, w, a); } // Bringed back weapon frame -- 2.39.2