]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/notifications/all.qc
Merge branch 'master' into z411/bai-server
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / notifications / all.qc
index dd200973bc007804c28258c12343b02130d6ec55..82c14207284c844d9a327e9de5411eb47a3a8350 100644 (file)
@@ -41,6 +41,7 @@ string Notification_CheckArgs(
                        break;
                }
 
+               case NOTIF_ALL_SPEC:
                case NOTIF_ALL:
                {
                        if (client) {
@@ -50,6 +51,7 @@ string Notification_CheckArgs(
                }
 
                case NOTIF_TEAM:
+               case NOTIF_TEAM_ONLY:
                {
                        if (!teamplay) {
                                return "Teamplay not active!";
@@ -60,6 +62,7 @@ string Notification_CheckArgs(
                }
 
                case NOTIF_TEAM_EXCEPT:
+               case NOTIF_TEAM_ONLY_EXCEPT:
                {
                        if (!teamplay) {
                                return "Teamplay not active!";
@@ -120,6 +123,20 @@ bool Notification_ShouldSend(NOTIF broadcast, entity to_client, entity other_cli
                                        )
                                )
                        );
+               case NOTIF_TEAM_ONLY:
+                       return (
+                               (to_client.team == other_client.team)
+                       );
+               case NOTIF_TEAM_ONLY_EXCEPT:
+                       return (
+                               (to_client != other_client)
+                               &&
+                               (to_client.team == other_client.team)
+                       );
+               case NOTIF_ALL_SPEC:
+                       return (
+                               (IS_SPEC(to_client) || IS_OBSERVER(to_client))
+                       );
                case NOTIF_ALL:
                        return true;
                case NOTIF_ALL_EXCEPT:
@@ -419,6 +436,7 @@ void Create_Notification_Entity(entity notif,
                case MSG_CENTER:
                case MSG_MULTI:
                case MSG_CHOICE:
+               case MSG_MEDAL:
                        break;
                default:
                        LOG_INFOF(
@@ -757,6 +775,17 @@ void Create_Notification_Entity_Choice(entity notif,
                        }
                }
 
+void Create_Notification_Entity_Medal(entity notif,
+                                                                               float var_cvar,
+                                                                               string namestring,
+                                                                               /* MSG_MEDAL */
+                                                                               string icon,
+                                                                               Notification anncename)
+       {
+               notif.nent_floatcount = 1;
+               if (icon != "") { notif.nent_icon = strzone(icon); }
+               if (anncename) { notif.nent_msgannce = anncename; }
+       }
 
 // ===============
 //  Cvar Handling
@@ -829,6 +858,7 @@ void Dump_Notifications(int fh, bool alsoprint)
        int NOTIF_CENTER_COUNT = 0;
        int NOTIF_MULTI_COUNT = 0;
        int NOTIF_CHOICE_COUNT = 0;
+       int NOTIF_MEDAL_COUNT = 0;
        FOREACH(Notifications, true, {
                switch (it.nent_type)
                {
@@ -837,6 +867,7 @@ void Dump_Notifications(int fh, bool alsoprint)
                        case MSG_CENTER: ++NOTIF_CENTER_COUNT; break;
                        case MSG_MULTI: ++NOTIF_MULTI_COUNT; break;
                        case MSG_CHOICE: ++NOTIF_CHOICE_COUNT; break;
+                       case MSG_MEDAL: ++NOTIF_MEDAL_COUNT; break;
                }
        });
 
@@ -876,6 +907,13 @@ void Dump_Notifications(int fh, bool alsoprint)
                        "Allow choice for this notification 0 = off, 1 = only in warmup mode, 2 = always"
                );
        });
+       
+       NOTIF_WRITE(sprintf("\n// MSG_MEDAL notifications (count = %d):\n", NOTIF_MEDAL_COUNT));
+       FOREACH(Notifications, it.nent_type == MSG_MEDAL && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
+               NOTIF_WRITE_ENTITY(it,
+                       "Enable this multiple notification"
+               );
+       });
 
        // edit these to match whichever cvars are used for specific notification options
        NOTIF_WRITE("\n// HARD CODED notification variables:\n");
@@ -971,13 +1009,15 @@ void Dump_Notifications(int fh, bool alsoprint)
                        NOTIF_INFO_COUNT +
                        NOTIF_CENTER_COUNT +
                        NOTIF_MULTI_COUNT +
-                       NOTIF_CHOICE_COUNT
+                       NOTIF_CHOICE_COUNT +
+                       NOTIF_MEDAL_COUNT
                ),
                NOTIF_ANNCE_COUNT,
                NOTIF_INFO_COUNT,
                NOTIF_CENTER_COUNT,
                NOTIF_MULTI_COUNT,
-               NOTIF_CHOICE_COUNT
+               NOTIF_CHOICE_COUNT,
+               NOTIF_MEDAL_COUNT
        );
        #undef NOTIF_WRITE_HARDCODED
        #undef NOTIF_WRITE_ENTITY
@@ -1180,8 +1220,8 @@ void Local_Notification_centerprint_Add(
        centerprint_Add(ORDINAL(cpid), input, stof(arg_slot[0]), stof(arg_slot[1]));
 }
 
-void Local_Notification_Queue_Run(MSG net_type, entity notif)
-{
+void Local_Notification_Queue_Run(MSG net_type, entity notif, float f1)
+{              
        switch (net_type)
        {
                case MSG_ANNCE:
@@ -1189,18 +1229,30 @@ void Local_Notification_Queue_Run(MSG net_type, entity notif)
                        Local_Notification_sound(notif.nent_channel, notif.nent_snd, notif.nent_vol, notif.nent_position);
                        break;
                }
+               
+               case MSG_MEDAL:
+               {
+                       centerprint_Medal(notif.nent_icon, f1);
+                       if(notif.nent_msgannce)
+                               Local_Notification_sound(
+                                       notif.nent_msgannce.nent_channel,
+                                       notif.nent_msgannce.nent_snd,
+                                       notif.nent_msgannce.nent_vol,
+                                       notif.nent_msgannce.nent_position);
+                       break;
+               }
        }
 }
 
-void Local_Notification_Queue_Add(MSG net_type, entity notif, float queue_time)
-{
+void Local_Notification_Queue_Add(MSG net_type, entity notif, float queue_time, float f1)
+{      
        // Guess length if required
        if(queue_time == 0)
                queue_time = soundlength(AnnouncerFilename(notif.nent_snd));
 
        if(queue_time == -1 || time > notif_queue_next_time) {
                // Run immediately
-               Local_Notification_Queue_Run(net_type, notif);
+               Local_Notification_Queue_Run(net_type, notif, f1);
                notif_queue_next_time = time + queue_time;
        } else {
                // Put in queue
@@ -1209,6 +1261,7 @@ void Local_Notification_Queue_Add(MSG net_type, entity notif, float queue_time)
                notif_queue_type[notif_queue_length] = net_type;
                notif_queue_entity[notif_queue_length] = notif;
                notif_queue_time[notif_queue_length] = notif_queue_next_time;
+               notif_queue_f1[notif_queue_length] = f1;
 
                notif_queue_next_time += queue_time;
                ++notif_queue_length;
@@ -1220,7 +1273,7 @@ void Local_Notification_Queue_Process()
        if(!notif_queue_length || notif_queue_time[0] > time)
                return;
 
-       Local_Notification_Queue_Run(notif_queue_type[0], notif_queue_entity[0]);
+       Local_Notification_Queue_Run(notif_queue_type[0], notif_queue_entity[0], notif_queue_f1[0]);
 
        // Shift queue to the left
        --notif_queue_length;
@@ -1228,6 +1281,7 @@ void Local_Notification_Queue_Process()
                notif_queue_type[j] = notif_queue_type[j+1];
                notif_queue_entity[j] = notif_queue_entity[j+1];
                notif_queue_time[j] = notif_queue_time[j+1];
+               notif_queue_f1[j] = notif_queue_f1[j+1];
        }
 }
 
@@ -1303,7 +1357,7 @@ void Local_Notification(MSG net_type, Notification net_name, ...count)
                case MSG_ANNCE:
                {
                        #ifdef CSQC
-                       Local_Notification_Queue_Add(net_type, notif, notif.nent_queuetime);
+                       Local_Notification_Queue_Add(net_type, notif, notif.nent_queuetime, f1);
                        #else
                        backtrace("MSG_ANNCE on server?... Please notify Samual immediately!\n");
                        #endif
@@ -1413,6 +1467,18 @@ void Local_Notification(MSG net_type, Notification net_name, ...count)
                                f1, f2, f3, f4);
                        break;
                }
+               
+               #ifdef CSQC
+               case MSG_MEDAL:
+               {
+                       Local_Notification_Queue_Add(
+                               net_type,
+                               notif,
+                               (notif.nent_msgannce ? MSG_MEDAL_TIME : 0),
+                               f1);
+                       break;
+               }
+               #endif
        }
 }