]> git.xonotic.org Git - xonotic/xonotic-data.pk3dir.git/blobdiff - qcsrc/common/notifications/all.qc
Merge branch 'drjaska/handicap' into 'master'
[xonotic/xonotic-data.pk3dir.git] / qcsrc / common / notifications / all.qc
index 767496d071ad423b23bf5211a9f05f05495ef1b2..dd200973bc007804c28258c12343b02130d6ec55 100644 (file)
@@ -840,14 +840,14 @@ void Dump_Notifications(int fh, bool alsoprint)
                }
        });
 
-       NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT));
+       NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications:\n"));
        FOREACH(Notifications, it.nent_type == MSG_ANNCE && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
                NOTIF_WRITE_ENTITY(it,
                        "0 = disabled, 1 = enabled if gentle mode is off, 2 = always enabled"
                );
        });
 
-       NOTIF_WRITE(sprintf("\n// MSG_INFO notifications (count = %d):\n", NOTIF_INFO_COUNT));
+       NOTIF_WRITE(sprintf("\n// MSG_INFO notifications:\n"));
        FOREACH(Notifications, it.nent_type == MSG_INFO && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
                NOTIF_WRITE_ENTITY(it,
                        "0 = off, 1 = print to console, "
@@ -855,21 +855,21 @@ void Dump_Notifications(int fh, bool alsoprint)
                );
        });
 
-       NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications (count = %d):\n", NOTIF_CENTER_COUNT));
+       NOTIF_WRITE(sprintf("\n// MSG_CENTER notifications:\n"));
        FOREACH(Notifications, it.nent_type == MSG_CENTER && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
                NOTIF_WRITE_ENTITY(it,
                        "0 = off, 1 = centerprint"
                );
        });
 
-       NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications (count = %d):\n", NOTIF_MULTI_COUNT));
+       NOTIF_WRITE(sprintf("\n// MSG_MULTI notifications:\n"));
        FOREACH(Notifications, it.nent_type == MSG_MULTI && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
                NOTIF_WRITE_ENTITY(it,
                        "Enable this multiple notification"
                );
        });
 
-       NOTIF_WRITE(sprintf("\n// MSG_CHOICE notifications (count = %d):\n", NOTIF_CHOICE_COUNT));
+       NOTIF_WRITE(sprintf("\n// MSG_CHOICE notifications:\n"));
        FOREACH(Notifications, it.nent_type == MSG_CHOICE && (!it.nent_teamnum || it.nent_teamnum == NUM_TEAM_1), {
                NOTIF_WRITE_ENTITY_CHOICE(it,
                        "Choice for this notification 0 = off, 1 = default message, 2 = verbose message",
@@ -964,11 +964,8 @@ void Dump_Notifications(int fh, bool alsoprint)
                "Don't show attacker spree information in MSG_INFO messages if it isn't an achievement"
        );
 
-       NOTIF_WRITE(sprintf(
-               (
-                       "\n// Notification counts (total = %d): "
-                       "MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d, MSG_CHOICE = %d\n"
-               ),
+       LOG_INFOF("Notification counts (total = %d): "
+               "MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d, MSG_CHOICE = %d\n",
                (
                        NOTIF_ANNCE_COUNT +
                        NOTIF_INFO_COUNT +
@@ -981,7 +978,7 @@ void Dump_Notifications(int fh, bool alsoprint)
                NOTIF_CENTER_COUNT,
                NOTIF_MULTI_COUNT,
                NOTIF_CHOICE_COUNT
-       ));
+       );
        #undef NOTIF_WRITE_HARDCODED
        #undef NOTIF_WRITE_ENTITY
        #undef NOTIF_WRITE
@@ -1184,7 +1181,7 @@ void Local_Notification_centerprint_Add(
 }
 
 void Local_Notification_Queue_Run(MSG net_type, entity notif)
-{              
+{
        switch (net_type)
        {
                case MSG_ANNCE:
@@ -1196,20 +1193,23 @@ void Local_Notification_Queue_Run(MSG net_type, entity notif)
 }
 
 void Local_Notification_Queue_Add(MSG net_type, entity notif, float queue_time)
-{      
-       //LOG_INFOF("Comparison %d > %d", time, notif_queue_next_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) {
-               //LOG_INFOF("Running NOW!");
+               // Run immediately
                Local_Notification_Queue_Run(net_type, notif);
                notif_queue_next_time = time + queue_time;
        } else {
-               //LOG_INFOF("Queueing: %d %d", notif_queue_length, notif_queue_next_time);
+               // 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;
        }
@@ -1217,23 +1217,17 @@ void Local_Notification_Queue_Add(MSG net_type, entity notif, float queue_time)
 
 void Local_Notification_Queue_Process()
 {
-       if(!notif_queue_length)
+       if(!notif_queue_length || notif_queue_time[0] > time)
                return;
 
-       int j;
-       
-       if(notif_queue_time[0] <= time) {
-               //LOG_INFOF("Process running: %d <= %d", notif_queue_time[0], time);
-               Local_Notification_Queue_Run(notif_queue_type[0], notif_queue_entity[0]);
-               
-               // Shift queue to the left
-               for (j = 0; j < notif_queue_length - 1; 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];
-               } 
-               
-               --notif_queue_length;
+       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];
        }
 }