]> de.git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/notifications/all.qc
Fix FL_WEAPON flag overlapping FL_JUMPRELEASED. This unintentional change was introdu...
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / notifications / all.qc
index 98b0f18e1c41a758ac90c5734df9f5be9e1a71e2..dd200973bc007804c28258c12343b02130d6ec55 100644 (file)
@@ -450,7 +450,8 @@ void Create_Notification_Entity_Annce(entity notif,
                                                                                float channel,
                                                                                string snd,
                                                                                float vol,
-                                                                               float position)
+                                                                               float position,
+                                                                               float queuetime)
                {
                        // Set MSG_ANNCE information and handle precaching
                        #ifdef CSQC
@@ -466,6 +467,7 @@ void Create_Notification_Entity_Annce(entity notif,
                                                notif.nent_snd = strzone(snd);
                                                notif.nent_vol = vol;
                                                notif.nent_position = position;
+                                               notif.nent_queuetime = queuetime;
                                        }
                                }
                                else
@@ -1177,6 +1179,58 @@ void Local_Notification_centerprint_Add(
        #endif
        centerprint_Add(ORDINAL(cpid), input, stof(arg_slot[0]), stof(arg_slot[1]));
 }
+
+void Local_Notification_Queue_Run(MSG net_type, entity notif)
+{
+       switch (net_type)
+       {
+               case MSG_ANNCE:
+               {
+                       Local_Notification_sound(notif.nent_channel, notif.nent_snd, notif.nent_vol, notif.nent_position);
+                       break;
+               }
+       }
+}
+
+void Local_Notification_Queue_Add(MSG net_type, entity notif, float queue_time)
+{
+       // 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);
+               notif_queue_next_time = time + queue_time;
+       } else {
+               // Put in queue
+               if(notif_queue_length >= NOTIF_QUEUE_MAX) return;
+
+               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_next_time += queue_time;
+               ++notif_queue_length;
+       }
+}
+
+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]);
+
+       // Shift queue to the left
+       --notif_queue_length;
+       for (int j = 0; j < notif_queue_length; ++j) {
+               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];
+       }
+}
+
 #endif
 
 void Local_Notification(MSG net_type, Notification net_name, ...count)
@@ -1249,7 +1303,7 @@ void Local_Notification(MSG net_type, Notification net_name, ...count)
                case MSG_ANNCE:
                {
                        #ifdef CSQC
-                       Local_Notification_sound(notif.nent_channel, notif.nent_snd, notif.nent_vol, notif.nent_position);
+                       Local_Notification_Queue_Add(net_type, notif, notif.nent_queuetime);
                        #else
                        backtrace("MSG_ANNCE on server?... Please notify Samual immediately!\n");
                        #endif
@@ -1357,6 +1411,7 @@ void Local_Notification(MSG net_type, Notification net_name, ...count)
                                found_choice.nent_floatcount,
                                s1, s2, s3, s4,
                                f1, f2, f3, f4);
+                       break;
                }
        }
 }