]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/commitdiff
Switch entirely to using entities to retrieve information about notifs
authorSamual Lenks <samual@xonotic.org>
Tue, 12 Feb 2013 08:02:57 +0000 (03:02 -0500)
committerSamual Lenks <samual@xonotic.org>
Tue, 12 Feb 2013 08:02:57 +0000 (03:02 -0500)
qcsrc/common/notifications.qc
qcsrc/common/notifications.qh
qcsrc/server/g_damage.qc
qcsrc/server/mutators/gamemode_ctf.qc

index ca85888fe09fda8428f286236f75529e1b35f78a..c5627adb759541cd2a8fbbffd5e9fa20dad032a7 100644 (file)
@@ -79,52 +79,48 @@ entity Get_Notif_Ent(float net_type, float net_name)
                case MSG_WEAPON: return msg_weapon_notifs[net_name - 1];
                case MSG_DEATH: return msg_death_notifs[net_name - 1];
        }
+       backtrace(sprintf("Get_Notif_Ent(%d, %d): Improper net type!\n", net_type, net_name));
        return world;
 }
 
 string Get_Notif_Name(float net_type, float net_name)
 {
        entity e = Get_Notif_Ent(net_type, net_name);
-
        if(e) { return e.nent_name; }
-
+       backtrace(sprintf("Get_Notif_Name(%d, %d): Could not find entity!\n", net_type, net_name));
        return "";
 }
 
-float Get_Notif_Strnum(float net_type, float net_name)
+float Get_Notif_Infval(float net_type, float net_name)
 {
        entity e = Get_Notif_Ent(net_type, net_name);
-
-       if(e) { return e.nent_stringcount; }
-
-       return FALSE;
+       if(e) { return e.nent_infoname; }
+       backtrace(sprintf("Get_Notif_Infval(%d, %d): Could not find entity!\n", net_type, net_name));
+       return NO_MSG;
 }
 
-float Get_Notif_Flnum(float net_type, float net_name)
+float Get_Notif_Cenval(float net_type, float net_name)
 {
        entity e = Get_Notif_Ent(net_type, net_name);
-
-       if(e) { return e.nent_floatcount; }
-
-       return FALSE;
+       if(e) { return e.nent_centername; }
+       backtrace(sprintf("Get_Notif_Cenval(%d, %d): Could not find entity!\n", net_type, net_name));
+       return NO_MSG;
 }
 
-string Get_Field_Value(float field, float net_type, float net_name)
+float Get_Notif_Strnum(float net_type, float net_name)
 {
        entity e = Get_Notif_Ent(net_type, net_name);
+       if(e) { return e.nent_stringcount; }
+       backtrace(sprintf("Get_Notif_Strnum(%d, %d): Could not find entity!\n", net_type, net_name));
+       return NO_MSG;
+}
 
-       //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(field)
-       {
-               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_floatcount); }
-       }
-       
-       return "";
+float Get_Notif_Flnum(float net_type, float net_name)
+{
+       entity e = Get_Notif_Ent(net_type, net_name);
+       if(e) { return e.nent_floatcount; }
+       backtrace(sprintf("Get_Notif_Flnum(%d, %d): Could not find entity!\n", net_type, net_name));
+       return NO_MSG;
 }
 #endif // ifndef MENUQC
 
@@ -219,8 +215,8 @@ void Local_Notification(float net_type, float net_name, ...count)
        }
        #endif
        
-       float stringcount = stof(Get_Field_Value(F_STRNUM, net_type, net_name));
-       float floatcount = stof(Get_Field_Value(F_FLNUM, net_type, net_name));
+       float stringcount = Get_Notif_Strnum(net_type, net_name);
+       float floatcount = Get_Notif_Flnum(net_type, net_name);
 
        string s1 = ((0 < stringcount) ? ...(0, string) : NO_STR_ARG);
        string s2 = ((1 < stringcount) ? ...(1, string) : NO_STR_ARG);
@@ -234,7 +230,7 @@ void Local_Notification(float net_type, float net_name, ...count)
        #ifdef NOTIFICATIONS_DEBUG
        {
                dprint(sprintf("Local_Notification(%d, %s, %s, %s, %s, %s, %d, %d, %d, %d);\n",
-                       net_type, Get_Field_Value(F_NAME, net_type, net_name),
+                       net_type, Get_Notif_Name(net_type, net_name),
                        s1, s2, s3, s4, f1, f2, f3, f4));
 
                if((stringcount + floatcount) > count)
@@ -287,15 +283,15 @@ void Local_Notification(float net_type, float net_name, ...count)
                                { \
                                        #if infoname != NO_MSG \
                                                Local_Notification_Without_VarArgs(MSG_INFO, infoname, \
-                                                       stof(Get_Field_Value(F_STRNUM, MSG_INFO, infoname)), \
-                                                       stof(Get_Field_Value(F_FLNUM, MSG_INFO, infoname)), \
+                                                       Get_Notif_Strnum(MSG_INFO, infoname), \
+                                                       Get_Notif_Flnum(MSG_INFO, infoname), \
                                                        s1, s2, s3, s4, f1, f2, f3, f4); \
                                        #endif \
                                        #ifdef CSQC \
                                                #if centername != NO_MSG \
                                                        Local_Notification_Without_VarArgs(MSG_CENTER, centername, \
-                                                               stof(Get_Field_Value(F_STRNUM, MSG_CENTER, centername)), \
-                                                               stof(Get_Field_Value(F_FLNUM, MSG_CENTER, centername)), \
+                                                               Get_Notif_Strnum(MSG_CENTER, centername), \
+                                                               Get_Notif_Flnum(MSG_CENTER, centername), \
                                                                s1, s2, s3, s4, f1, f2, f3, f4); \
                                                #endif \
                                        #endif \
@@ -313,15 +309,15 @@ void Local_Notification(float net_type, float net_name, ...count)
                                { \
                                        #if infoname != NO_MSG \
                                                Local_Notification_Without_VarArgs(MSG_INFO, infoname, \
-                                                       stof(Get_Field_Value(F_STRNUM, MSG_INFO, infoname)), \
-                                                       stof(Get_Field_Value(F_FLNUM, MSG_INFO, infoname)), \
+                                                       Get_Notif_Strnum(MSG_INFO, infoname), \
+                                                       Get_Notif_Flnum(MSG_INFO, infoname), \
                                                        s1, s2, s3, s4, f1, f2, f3, f4); \
                                        #endif \
                                        #ifdef CSQC \
                                                #if centername != NO_MSG \
                                                        Local_Notification_Without_VarArgs(MSG_CENTER, centername, \
-                                                               stof(Get_Field_Value(F_STRNUM, MSG_CENTER, centername)), \
-                                                               stof(Get_Field_Value(F_FLNUM, MSG_CENTER, centername)), \
+                                                               Get_Notif_Strnum(MSG_CENTER, centername), \
+                                                               Get_Notif_Flnum(MSG_CENTER, centername), \
                                                                s1, s2, s3, s4, f1, f2, f3, f4); \
                                                #endif \
                                        #endif \
@@ -358,8 +354,8 @@ void Read_Notification(float is_new)
        float net_type = ReadByte();
        float net_name = ReadShort();
 
-       float stringcount = stof(Get_Field_Value(F_STRNUM, net_type, net_name));
-       float floatcount = stof(Get_Field_Value(F_FLNUM, net_type, net_name));
+       float stringcount = Get_Notif_Strnum(net_type, net_name);
+       float floatcount = Get_Notif_Flnum(net_type, net_name);
 
        string s1 = ((stringcount >= 1) ? ReadString() : NO_STR_ARG);
        string s2 = ((stringcount >= 2) ? ReadString() : NO_STR_ARG);
@@ -371,7 +367,7 @@ void Read_Notification(float is_new)
        float f4 = ((floatcount == 4) ? ReadLong() : NO_FL_ARG);
 
        #ifdef NOTIFICATIONS_DEBUG
-               dprint(sprintf("Read_Notification(%d) at %f: 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_Notif_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); }
@@ -463,16 +459,13 @@ void Send_Notification(float broadcast, entity client,
        #endif
 
        // retreive counts for the arguments of this notification
-       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));
+       float stringcount = Get_Notif_Strnum(net_type, net_name);
+       float floatcount = Get_Notif_Flnum(net_type, net_name);
 
        #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));
+                       broadcast, net_type, Get_Notif_Name(net_type, net_name), stringcount, floatcount, count));
 
                if((stringcount + floatcount) > count)
                        { backtrace(sprintf(strcat("Not enough arguments for Send_Notification! stringcount(%d) + floatcount(%d) > count(%d)\n", 
@@ -524,8 +517,8 @@ void Send_Notification_Legacy_Wrapper(float broadcast, entity client,
        string s1, string s2,
        float f1, float f2, float f3)
 {
-       float stringcount = stof(Get_Field_Value(F_STRNUM, net_type, net_name));
-       float floatcount = stof(Get_Field_Value(F_FLNUM, net_type, net_name));
+       float stringcount = Get_Notif_Strnum(net_type, net_name);
+       float floatcount = Get_Notif_Flnum(net_type, net_name);
        Send_Notification_Without_VarArgs(broadcast, client, net_type, net_name, stringcount, floatcount, s1, s2, NO_STR_ARG, NO_STR_ARG, f1, f2, f3, NO_FL_ARG);
 }
 
index a6be4bf499b50fcfa8ce7913e1821c5abda15233..3d60579ddac82803be1f582aaef4ae51c18c0a05 100644 (file)
@@ -97,7 +97,13 @@ string got_commandkey;
                default: { backtrace(strcat("^1NOTIFICATION HAD NO MATCH: ^7net_type = ", VAR_TO_TEXT(net_type), ", net_name = ", ftos(net_name), ".\n")); returnv; } \
        }
 
-string Get_Field_Value(float field, float net_type, float net_name); // get the actual name of a notification and return it as a string
+entity Get_Notif_Ent(float net_type, float net_name);
+string Get_Notif_Name(float net_type, float net_name);
+float Get_Notif_Infval(float net_type, float net_name);
+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);
+
 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);
 
index 03222e09cd598c32e0f1508b96d62c81140be413..f2ba98b51bf20f1de9c7b7d048e71d0b78cc4324 100644 (file)
@@ -366,7 +366,7 @@ float Obituary_WeaponDeath(entity notif_target, float murder, float deathtype, s
                if(death_message)
                {
                        Send_Notification_Legacy_Wrapper(NOTIF_ONE, notif_target, MSG_WEAPON, death_message, s1, s2, f1, NO_FL_ARG, NO_FL_ARG);
-                       Send_Notification_Legacy_Wrapper(NOTIF_ANY_EXCEPT, notif_target, MSG_INFO, stof(Get_Field_Value(F_INFVAL, MSG_WEAPON, death_message)), s1, s2, f1, NO_FL_ARG, NO_FL_ARG);
+                       Send_Notification_Legacy_Wrapper(NOTIF_ANY_EXCEPT, notif_target, MSG_INFO, Get_Notif_Infval(MSG_WEAPON, death_message), s1, s2, f1, NO_FL_ARG, NO_FL_ARG);
                        //print(Get_Field_Value(F_INFVAL, MSG_WEAPON, death_message), "\n");
                }
                else { dprint(sprintf("Obituary_WeaponDeath(): ^1Deathtype ^7(%s-%d)^1 has no notification for weapon %d!\n", Deathtype_Name(deathtype), deathtype, death_weapon)); }
index 132896d32c95cfcd902e71cf1ee685a2c8e328cf..7d1f3f2014a92bcf768f6a87ea0c3ecc78ae121e 100644 (file)
@@ -47,7 +47,7 @@ void ctf_CaptureRecord(entity flag, entity player)
 
        // notify server log too
        if not(autocvar_notification_ctf_capture_verbose) { notification = APP_TEAM_ENT_2(flag, INFO_CTF_CAPTURE_); s2 = NO_STR_ARG; f1 = f2 = NO_FL_ARG; }
-       Local_Notification_Without_VarArgs(MSG_INFO, notification, stof(Get_Field_Value(F_STRNUM, MSG_INFO, notification)), stof(Get_Field_Value(F_FLNUM, MSG_INFO, notification)), s1, s2, NO_STR_ARG, NO_STR_ARG, f1, f2, NO_FL_ARG, NO_FL_ARG);
+       Local_Notification_Without_VarArgs(MSG_INFO, notification, Get_Notif_Strnum(MSG_INFO, notification), Get_Notif_Flnum(MSG_INFO, notification), s1, s2, NO_STR_ARG, NO_STR_ARG, f1, f2, NO_FL_ARG, NO_FL_ARG);
 
        // write that shit in the database
        if(success)