]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Working on notification initialization-- plus, start working on weapons
authorSamual Lenks <samual@xonotic.org>
Wed, 27 Feb 2013 06:02:25 +0000 (01:02 -0500)
committerSamual Lenks <samual@xonotic.org>
Wed, 27 Feb 2013 06:02:25 +0000 (01:02 -0500)
qcsrc/common/notifications.qh
qcsrc/common/util.qh
qcsrc/server/cl_weapons.qc

index 91bef5fba450f18f8a15593e988b5d9040e4aee1..f3f2d50d72e100bc6e6546e0d7d86c888f98583f 100644 (file)
@@ -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
index d2b63f7ba2c5c858b704c8da847bc9d759d14cd0..2eebd1b8d59c0ef9225da4782b8b29db115151f5 100644 (file)
@@ -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
index cb40be9144d4281a39607ee49505530c8a4348cc..cea561451c9f180d8ea576cc16fc04c9d2ed9c05 100644 (file)
@@ -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