Compact some notification code
authorterencehill <piuntn@gmail.com>
Mon, 16 Jan 2017 18:12:51 +0000 (19:12 +0100)
committerterencehill <piuntn@gmail.com>
Mon, 16 Jan 2017 18:12:51 +0000 (19:12 +0100)
qcsrc/common/notifications/all.qc

index 2a9217b..e312aca 100644 (file)
@@ -85,11 +85,7 @@ bool Notification_ShouldSend(NOTIF broadcast, entity to_client, entity other_cli
                        return (
                                (to_client == other_client)
                                ||
-                               (
-                                       IS_SPEC(to_client)
-                                       &&
-                                       (to_client.enemy == other_client)
-                               )
+                               (IS_SPEC(to_client) && (to_client.enemy == other_client))
                        );
                case NOTIF_ONE_ONLY:
                        return (to_client == other_client);
@@ -442,6 +438,8 @@ void Create_Notification_Entity(entity notif,
        }
 }
 
+#define AnnouncerFilename(snd) sprintf("announcer/%s/%s.wav", AnnouncerOption(), snd)
+
 void Create_Notification_Entity_Annce(entity notif,
                                                                                float var_cvar,
                                                                                string namestring,
@@ -460,7 +458,7 @@ void Create_Notification_Entity_Annce(entity notif,
                                {
                                        if(notif.nent_enabled)
                                        {
-                                               precache_sound(sprintf("announcer/%s/%s.wav", AnnouncerOption(), snd));
+                                               precache_sound(AnnouncerFilename(snd));
                                                notif.nent_channel = channel;
                                                notif.nent_snd = strzone(snd);
                                                notif.nent_vol = vol;
@@ -1048,9 +1046,7 @@ string Local_Notification_sprintf(
 }
 
 #ifdef CSQC
-void Local_Notification_sound(
-       int soundchannel, string soundfile,
-       float soundvolume, float soundposition)
+void Local_Notification_sound(int soundchannel, string soundfile, float soundvolume, float soundposition)
 {
        if ((soundfile != prev_soundfile) || (time >= (prev_soundtime + autocvar_cl_announcer_antispam)))
        {
@@ -1058,27 +1054,13 @@ void Local_Notification_sound(
                Debug_Notification(sprintf(
                        "Local_Notification_sound(%f, '%s', %f, %f);\n",
                        soundchannel,
-                       sprintf(
-                               "announcer/%s/%s.wav",
-                               AnnouncerOption(),
-                               soundfile
-                       ),
+                       AnnouncerFilename(soundfile),
                        soundvolume,
                        soundposition
                ));
                #endif
 
-               _sound(
-                       NULL,
-                       soundchannel,
-                       sprintf(
-                               "announcer/%s/%s.wav",
-                               AnnouncerOption(),
-                               soundfile
-                       ),
-                       soundvolume,
-                       soundposition
-               );
+               _sound(NULL, soundchannel, AnnouncerFilename(soundfile), soundvolume, soundposition);
 
                if (prev_soundfile) strunzone(prev_soundfile);
                prev_soundfile = strzone(soundfile);
@@ -1089,15 +1071,11 @@ void Local_Notification_sound(
                #ifdef NOTIFICATIONS_DEBUG
                Debug_Notification(sprintf(
                        (
-                               "Local_Notification_sound(NULL, %f, '%s', %f, %f) "
+                               "Local_Notification_sound(%f, '%s', %f, %f) "
                                "^1BLOCKED BY ANTISPAM:^7 prevsnd: '%s', timediff: %f, limit: %f\n"
-                        ),
-                       soundchannel,
-                       sprintf(
-                               "announcer/%s/%s.wav",
-                               AnnouncerOption(),
-                               soundfile
                        ),
+                       soundchannel,
+                       AnnouncerFilename(soundfile),
                        soundvolume,
                        soundposition,
                        prev_soundfile,
@@ -1271,12 +1249,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_sound(notif.nent_channel, notif.nent_snd, notif.nent_vol, notif.nent_position);
                        #else
                        backtrace("MSG_ANNCE on server?... Please notify Samual immediately!\n");
                        #endif
@@ -1535,8 +1508,7 @@ void Kill_Notification(
        net_notif.nent_net_name = ORDINAL(net_cpid);
        Net_LinkEntity(net_notif, false, autocvar_notification_lifetime_runtime, Net_Write_Notification);
 
-       IL_EACH(
-               g_notifications,
+       IL_EACH(g_notifications,
                (it.owner.nent_type == net_type || net_type == MSG_Null) && (it.owner.nent_cpid == net_cpid || net_cpid == CPID_Null),
                {
                        it.nent_net_name = -1;
@@ -1609,20 +1581,9 @@ void Send_Notification(
                return;
        }
 
-       if (
-               server_is_dedicated
-               &&
-               (
-                       broadcast == NOTIF_ALL
-                       ||
-                       broadcast == NOTIF_ALL_EXCEPT
-               )
-               &&
-               !(
-                       net_type == MSG_ANNCE
-                       ||
-                       net_type == MSG_CENTER
-               )
+       if (server_is_dedicated
+               && (broadcast == NOTIF_ALL || broadcast == NOTIF_ALL_EXCEPT)
+               && !(net_type == MSG_ANNCE || net_type == MSG_CENTER)
        )
        {
                Local_Notification_WOVA(