]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/notifications/all.qh
Use a single field instead of 4 to store a team notification choice and reduce number...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / notifications / all.qh
index b201fa1cbde88cd589047d06486253b388408d1b..60b3874de233d369109b16c50a53e1fb3426fe48 100644 (file)
@@ -6,6 +6,7 @@
 #include <common/teams.qh>
 #include <common/util.qh>
 #include <common/sounds/sound.qh>
+#include <common/weapons/all.qh>
 
 #ifdef CSQC
 #include <client/autocvars.qh>
@@ -309,7 +310,6 @@ float autocvar_notification_lifetime_mapload = 10;
 #endif
 
 #ifdef SVQC
-.float FRAG_VERBOSE;
 void Notification_GetCvars(entity this);
 float autocvar_notification_server_allows_location = 1; // 0 = no, 1 = yes
 #else
@@ -440,9 +440,10 @@ string BUFF_NAME(int i);
        ARG_CASE(ARG_CS_SV_HA,  "minigame1_name",find(NULL,netname,s1).descriptor.message) \
        ARG_CASE(ARG_CS_SV_HA,  "minigame1_d",   find(NULL,netname,s1).descriptor.netname)
 
-#define NOTIF_HIT_MAX(count,funcname) MACRO_BEGIN \
+#define NOTIF_HIT_MAX(count,funcname) MACRO_BEGIN \
        if(sel_num == count) { backtrace(sprintf("%s: Hit maximum arguments!\n", funcname)); break; } \
-} MACRO_END
+MACRO_END
+
 #define NOTIF_HIT_UNKNOWN(token,funcname) { backtrace(sprintf("%s: Hit unknown token in selected string! '%s'\n", funcname, selected)); break; }
 
 #define KILL_SPREE_LIST \
@@ -630,12 +631,12 @@ string notif_arg_item_wepammo(float f1, float f2)
        Weapon wep = Weapons_from(f1);
        switch (wep.ammo_type)
        {
-               case RESOURCE_SHELLS:  ammoitems = ITEM_Shells.m_name;      break;
-               case RESOURCE_BULLETS: ammoitems = ITEM_Bullets.m_name;     break;
-               case RESOURCE_ROCKETS: ammoitems = ITEM_Rockets.m_name;     break;
-               case RESOURCE_CELLS:   ammoitems = ITEM_Cells.m_name;       break;
-               case RESOURCE_PLASMA:  ammoitems = ITEM_Plasma.m_name;      break;
-               case RESOURCE_FUEL:    ammoitems = ITEM_JetpackFuel.m_name; break;
+               case RES_SHELLS:  ammoitems = ITEM_Shells.m_name;      break;
+               case RES_BULLETS: ammoitems = ITEM_Bullets.m_name;     break;
+               case RES_ROCKETS: ammoitems = ITEM_Rockets.m_name;     break;
+               case RES_CELLS:   ammoitems = ITEM_Cells.m_name;       break;
+               case RES_PLASMA:  ammoitems = ITEM_Plasma.m_name;      break;
+               case RES_FUEL:    ammoitems = ITEM_JetpackFuel.m_name; break;
                default: return ""; // doesn't use ammo
        }
        return sprintf(_(" with %d %s"), f2, ammoitems);
@@ -698,7 +699,9 @@ REGISTRY_SORT(Notifications);
 STATIC_INIT(Notifications) { FOREACH(Notifications, true, it.m_id = i); }
 REGISTRY_CHECK(Notifications)
 
-const int NOTIF_CHOICE_MAX = 50;
+const int NOTIF_CHOICE_MAX = 20;
+// NOTE: a team choice is actually made of 4 choices (one per team) with the same nent_choice_idx
+// thus they are counted as 1 in nent_choice_count
 int nent_choice_count = 0;
 .int nent_choice_idx;
 .int msg_choice_choices[NOTIF_CHOICE_MAX]; // set on each player containing MSG_CHOICE choices
@@ -706,12 +709,11 @@ int nent_choice_count = 0;
 bool notif_error;
 bool notif_global_error;
 
-STATIC_INIT_LATE(Notif_Choices) {
-       int c = 0;
-       FOREACH(Notifications, it.nent_type == MSG_CHOICE, { c++; });
-       if (c > NOTIF_CHOICE_MAX) {
-               LOG_FATALF("Too many MSG_CHOICE notifications (%d)", c);
-       }
+STATIC_INIT_LATE(Notif_Choices)
+{
+       if (nent_choice_count > NOTIF_CHOICE_MAX)
+               LOG_FATALF("Too many MSG_CHOICE notifications (%d), hit NOTIF_CHOICE_MAX (%d) limit",
+                       nent_choice_count, NOTIF_CHOICE_MAX);
 }
 
 string Get_Notif_CvarName(Notification notif)
@@ -830,7 +832,9 @@ Notification Get_Notif_Ent(MSG net_type, int net_name)
 
 #define MSG_CHOICE_NOTIF_(teamnum, name, cvarname, default, challow, chtype, optiona, optionb) \
        REGISTER(Notifications, name, m_id, new_pure(msg_choice_notification)) { \
-               this.nent_choice_idx = nent_choice_count++; \
+               this.nent_choice_idx = nent_choice_count; \
+               if (!teamnum || teamnum == NUM_TEAM_4) \
+                       nent_choice_count++; \
                Create_Notification_Entity       (this, default, ACVNN(cvarname), MSG_CHOICE, strtoupper(#name), teamnum); \
                Create_Notification_Entity_Choice(this, ACVNN(cvarname), strtoupper(#name), \
                        challow,                                 /* challow_def */ \