]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
More cleanup, plus re-implement HUD_Notify_Push properly
authorSamual Lenks <samual@xonotic.org>
Wed, 13 Feb 2013 18:36:23 +0000 (13:36 -0500)
committerSamual Lenks <samual@xonotic.org>
Wed, 13 Feb 2013 18:36:23 +0000 (13:36 -0500)
qcsrc/client/hud.qc
qcsrc/common/notifications.qc
qcsrc/common/notifications.qh

index 3e3663db5a90b99e95838e61b0180a61e5867577..5cdc317463f062ddee1ef7b79989fc470103ab4b 100644 (file)
@@ -2056,6 +2056,27 @@ void HUD_KillNotify(string s1, string s2, string s3, float type, float msg) // s
                }
        }*/
 }
+void HUD_Notify_Push(string icon, string attacker, string victim)
+{
+       if(icon != "")
+       {
+               --kn_index;
+               if (kn_index == -1) { kn_index = KN_MAX_ENTRIES-1; }
+               killnotify_times[kn_index] = time;
+
+               // icon
+               if(killnotify_icon[kn_index]) { strunzone(killnotify_icon[kn_index]); }
+               killnotify_icon[kn_index] = strzone(icon);
+
+               // attacker
+               if(killnotify_attackers[kn_index]) { strunzone(killnotify_attackers[kn_index]); }
+               killnotify_attackers[kn_index] = strzone(attacker);
+
+               // victim
+               if(killnotify_victims[kn_index]) { strunzone(killnotify_victims[kn_index]); }
+               killnotify_victims[kn_index] = strzone(victim);
+       }
+}
 
 void HUD_Notify(void)
 {
index 0f51f3524af426dfff9d494d2609a088cacab437..4d92ec1ac94eea228f224db9bc5397ba068399f9 100644 (file)
@@ -4,7 +4,6 @@
 // ================================================
 
 #ifndef MENUQC
-string arg_slot[7];
 entity Get_Notif_Ent(float net_type, float net_name)
 {
        switch(net_type)
@@ -109,31 +108,6 @@ void Dump_Notifications(float fh, float alsoprint)
 }
 
 #ifndef MENUQC
-#ifdef CSQC
-void HUD_Notify_Push(string icon, string attacker, string victim)
-{
-       if(icon != "")
-       {
-               --kn_index;
-               if (kn_index == -1) { kn_index = KN_MAX_ENTRIES-1; }
-               killnotify_times[kn_index] = time;
-
-               // icon
-               if(killnotify_icon[kn_index]) { strunzone(killnotify_icon[kn_index]); }
-               killnotify_icon[kn_index] = strzone(icon);
-
-               // attacker
-               if(killnotify_attackers[kn_index]) { strunzone(killnotify_attackers[kn_index]); }
-               killnotify_attackers[kn_index] = strzone(attacker);
-
-               // victim
-               if(killnotify_victims[kn_index]) { strunzone(killnotify_victims[kn_index]); }
-               killnotify_victims[kn_index] = strzone(victim);
-       }
-}
-#endif // ifdef CSQC
-
-
 string Local_Notification_sprintf(string input, string args, 
        string s1, string s2, string s3, string s4,
        float f1, float f2, float f3, float f4)
@@ -152,6 +126,8 @@ string Local_Notification_sprintf(string input, string args,
        #ifdef CSQC
        string tmp_s;
        #endif
+
+       arg_slot[0] = ""; arg_slot[1] = ""; arg_slot[2] = ""; arg_slot[3] = ""; arg_slot[4] = ""; arg_slot[5] = ""; arg_slot[6] = "";
        
        if((remaining != "") && (input != ""))
        {
@@ -204,6 +180,38 @@ string Local_Notification_sprintf(string input, string args,
        return "";
 }
 
+#ifdef CSQC
+void Local_Notification_HUD_Notify_Push(string icon, string hudargs, string s1, string s2)
+{
+       string selected, remaining = hudargs;
+       float sel_num = 0;
+
+       arg_slot[0] = ""; arg_slot[1] = "";
+       
+       if(remaining != "")
+       {
+               for(;remaining;)
+               {
+                       selected = car(remaining); remaining = cdr(remaining);
+
+                       switch(strtolower(selected))
+                       {
+                               #define ADD_ARG_CASE(selected,result) case selected: { arg_slot[sel_num] = result; ++sel_num; break; }
+                               
+                               ADD_ARG_CASE("s1", s1)
+                               ADD_ARG_CASE("s2", s2)
+                               
+                               #undef ADD_ARG_CASE
+                               default: { backtrace(sprintf("Hit unknown token in selected string! '%s'\n", selected)); break; }
+                       }
+                       if(sel_num == 7) { backtrace("Hit maximum arguments!\n"); break; }
+               }
+       }
+
+       HUD_Notify_Push(icon, arg_slot[0], arg_slot[1]);
+}
+#endif
+
 void Local_Notification(float net_type, float net_name, ...count)
 {
        // check supplied type and name for errors
@@ -265,7 +273,7 @@ void Local_Notification(float net_type, float net_name, ...count)
                                s1, s2, s3, s4, f1, f2, f3, f4));
                                
                        #ifdef CSQC 
-                       if(notif.nent_icon != "") { HUD_Notify_Push(notif.nent_icon, s1, s2); } 
+                       if(notif.nent_icon != "") { Local_Notification_HUD_Notify_Push(notif.nent_icon, notif.nent_hudargs, s1, s2); } 
                        #endif 
                        break;
                }
index 4cc6da9c95e725dce161bece97ec997c717f7fa4..4b3262efc15d60c5f7f49f5051503ef16d4c55b1 100644 (file)
 #define NO_FL_ARG -12345
 #define NO_MSG -12345
 
-// field identifiers for Get_Field_Value()
-#define F_NAME 1
-#define F_INFNAME 2
-#define F_CENNAME 3
-#define F_INFVAL 4
-#define F_CENVAL 5
-#define F_STRNUM 6
-#define F_FLNUM 7
-
 // ping of bots defined for extra frag message notification information
 #define BOT_PING -1
 
@@ -60,6 +51,8 @@ float Get_Notif_Cenval(float net_type, float net_name);
 float Get_Notif_Strnum(float net_type, float net_name);
 float Get_Notif_Flnum(float net_type, float net_name);
 
+string arg_slot[7]; 
+
 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);