]> git.rm.cloudns.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
More work on entity notifications
authorSamual Lenks <samual@xonotic.org>
Mon, 11 Feb 2013 19:36:38 +0000 (14:36 -0500)
committerSamual Lenks <samual@xonotic.org>
Mon, 11 Feb 2013 19:36:38 +0000 (14:36 -0500)
qcsrc/common/notifications.qc
qcsrc/common/notifications.qh

index 035eb91444dc27cc664ebce532e76a3dd416f4b3..cea5d3de29e008040769e32e976731c3c46d5746 100644 (file)
@@ -70,8 +70,38 @@ string Fill_Notif_Args(string args, string input,
        return "";
 }
 
-// get the actual name of a notification and return it as a string
+entity Get_Notif_Ent(float net_type, float net_name)
+{
+       switch(net_type)
+       {
+               case MSG_INFO: return msg_info_notifs[net_name - 1];
+               case MSG_CENTER: return msg_center_notifs[net_name - 1];
+               case MSG_WEAPON: return msg_weapon_notifs[net_name - 1];
+               case MSG_DEATH: return msg_death_notifs[net_name - 1];
+       }
+       return world;
+}
+
 string Get_Field_Value(float field, float net_type, float net_name)
+{
+       entity e = Get_Notif_Ent(net_type, net_name);
+
+       dprint(sprintf("Get_Field_Value(%d, %d, %d); - name=%s, stringcount=%d, floatcount=%d...\n", field, net_type, net_name, e.nent_name, e.nent_stringcount, e.nent_floatcount));
+
+       switch(net_type)
+       {
+               case F_NAME: { return e.nent_name; }
+               case F_INFVAL: { return ftos(e.nent_infoname); } 
+               case F_CENVAL: { return ftos(e.nent_centername); } 
+               case F_STRNUM: { return ftos(e.nent_stringcount); } 
+               case F_FLNUM: { return ftos(e.nent_stringcount); }
+       }
+       
+       return "";
+}
+
+// get the actual name of a notification and return it as a string
+/*string Get_Field_Value(float field, float net_type, float net_name)
 {
        #ifdef NOTIFICATIONS_DEBUG
                dprint(sprintf("Get_Field_Value(%d, %d, %d);\n", field, net_type, net_name));
@@ -140,7 +170,7 @@ string Get_Field_Value(float field, float net_type, float net_name)
        #undef GET_FIELD_VALUE_OUTPUT_PAIR
        #undef CLPSE_GETVALUE
        return "";
-}
+}*/
 #endif // ifndef MENUQC
 
 
@@ -386,7 +416,7 @@ void Read_Notification(float is_new)
        float f4 = ((floatcount == 4) ? ReadLong() : NO_FL_ARG);
 
        #ifdef NOTIFICATIONS_DEBUG
-               dprint(sprintf("Read_Notification(%d) at %d: net_name = %s.\n", is_new, time, Get_Field_Value(F_NAME, net_type, net_name)));
+               dprint(sprintf("Read_Notification(%d) at %f: net_name = %s.\n", is_new, time, Get_Field_Value(F_NAME, net_type, net_name)));
        #endif
        
        if(is_new) { Local_Notification_Without_VarArgs(net_type, net_name, stringcount, floatcount, s1, s2, s3, s4, f1, f2, f3, f4); }
@@ -481,17 +511,20 @@ void Send_Notification(float broadcast, entity client,
        float stringcount = stof(Get_Field_Value(F_STRNUM, net_type, net_name));
        float floatcount = stof(Get_Field_Value(F_FLNUM, net_type, net_name));
 
+       entity e = Get_Notif_Ent(net_type, net_name);
+       print(sprintf("stringcount from ent: %d... floatcount from ent: %d\n", e.nent_stringcount, e.nent_floatcount));
+
        #ifdef NOTIFICATIONS_DEBUG
        {
                dprint(sprintf("Send_Notification(%d, %d, %s, stringcount: %d, floatcount: %d, varargs: %d);\n",
                        broadcast, net_type, Get_Field_Value(F_NAME, net_type, net_name), stringcount, floatcount, count));
 
                if((stringcount + floatcount) > count)
-                       { backtrace(sprintf("Not enough arguments for Send_Notification! stringcount(%d) + floatcount(%d) > count(%d) \
-                       \nCheck the notification definition and function call for accuracy...?\n", stringcount, floatcount, count)); return; }
+                       { backtrace(sprintf(strcat("Not enough arguments for Send_Notification! stringcount(%d) + floatcount(%d) > count(%d)\n", 
+                       "Check the notification definition and function call for accuracy...?\n"), stringcount, floatcount, count)); return; }
                else if((stringcount + floatcount) < count)
-                       { backtrace(sprintf("Too many arguments for Send_Notification! stringcount(%d) + floatcount(%d) < count(%d) \
-                       \nCheck the notification definition and function call for accuracy...?\n", stringcount, floatcount, count)); return; }
+                       { backtrace(sprintf(strcat("Too many arguments for Send_Notification! stringcount(%d) + floatcount(%d) < count(%d)\n",
+                       "Check the notification definition and function call for accuracy...?\n"), stringcount, floatcount, count)); return; }
        }
        #endif
 
index 6f7350ccca86f619f17f88309ade10682f70b9d5..a67f9af151535479f5be8d6cfc5b1aaa2a5dfbf9 100644 (file)
@@ -623,22 +623,22 @@ entity msg_death_notifs[NOTIF_MAX];
 .entity nent_client;
 .float nent_net_type;
 .float nent_net_name;
-.float nent_stringcount;
-.float nent_floatcount; 
 .string nent_strings[4];
 .float nent_floats[4];
 
 .string nent_name;
+.float nent_infoname;
+.float nent_centername;
+.float nent_stringcount;
+.float nent_floatcount; 
 .string nent_args;
 .string nent_hudargs;
 .string nent_icon;
+.float nent_cpid;
 .string nent_durcnt;
 .string nent_normal;
 .string nent_gentle;
 
-.float nent_cpid;
-.float nent_durcnt;
-
 //     notif.nent_args = strzone(args); \
 //     notif.nent_hudargs = strzone(hudargs); \
 // if(durcnt != "") { notif.nent_durcnt = durcnt; } \
@@ -680,7 +680,7 @@ entity msg_death_notifs[NOTIF_MAX];
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_INFO_COUNT, "notifications") \
                CREATE_NOTIF_ENTITY(info, name, NO_MSG, NO_MSG, \
                        strnum, flnum, args, hudargs, icon, NO_MSG, NO_MSG, \
-                       normal, gentle, TRUE, FALSE) \
+                       normal, gentle, 1, 0) \
        } \
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
@@ -695,7 +695,7 @@ entity msg_death_notifs[NOTIF_MAX];
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_CENTER_COUNT, "notifications") \
                CREATE_NOTIF_ENTITY(center, name, NO_MSG, NO_MSG, \
                        strnum, flnum, args, "", "", cpid, durcnt, \
-                       normal, gentle, FALSE, FALSE) \
+                       normal, gentle, 0, 0) \
        } \
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
@@ -708,7 +708,7 @@ entity msg_death_notifs[NOTIF_MAX];
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_WEAPON_COUNT, "notifications") \
                CREATE_NOTIF_ENTITY(weapon, name, infoname, centername, \
                        NO_MSG, NO_MSG, "", "", "", NO_MSG, NO_MSG, \
-                       "", "", FALSE, TRUE) \
+                       "", "", 0, 1) \
        } \
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)
 
@@ -721,7 +721,7 @@ entity msg_death_notifs[NOTIF_MAX];
                CHECK_MAX_COUNT(name, NOTIF_MAX, NOTIF_DEATH_COUNT, "notifications") \
                CREATE_NOTIF_ENTITY(death, name, infoname, centername, \
                        NO_MSG, NO_MSG, "", "", "", NO_MSG, NO_MSG, \
-                       "", "", FALSE, TRUE) \
+                       "", "", 0, 1) \
        } \
        ACCUMULATE_FUNCTION(RegisterNotifications, RegisterNotification_##name)