From: Samual Lenks Date: Fri, 26 Apr 2013 00:03:06 +0000 (-0400) Subject: Merge remote-tracking branch 'origin/master' X-Git-Tag: xonotic-v0.7.0~73 X-Git-Url: http://git.xonotic.org/?a=commitdiff_plain;h=5d91cc9be5e22267a8801a4a634d32b7a58fb060;hp=-c;p=xonotic%2Fxonotic-data.pk3dir.git Merge remote-tracking branch 'origin/master' --- 5d91cc9be5e22267a8801a4a634d32b7a58fb060 diff --combined qcsrc/common/notifications.qc index 7d8dfc382,a0f19746a..81e058e59 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@@ -7,6 -7,7 +7,7 @@@ string Get_Notif_TypeName(float net_typ { switch(net_type) { + case MSG_ANNCE: return "MSG_ANNCE"; case MSG_INFO: return "MSG_INFO"; case MSG_CENTER: return "MSG_CENTER"; case MSG_CENTER_CPID: return "MSG_CENTER_CPID"; @@@ -20,6 -21,7 +21,7 @@@ entity Get_Notif_Ent(float net_type, fl { switch(net_type) { + case MSG_ANNCE: return msg_annce_notifs[net_name - 1]; case MSG_INFO: return msg_info_notifs[net_name - 1]; case MSG_CENTER: return msg_center_notifs[net_name - 1]; case MSG_MULTI: return msg_multi_notifs[net_name - 1]; @@@ -37,6 -39,7 +39,7 @@@ string Notification_CheckArgs_TypeName( { checkargs = sprintf("Improper name: %d!", net_name); } break; } switch(net_type) { + CHECKARG_TYPENAME(ANNCE) CHECKARG_TYPENAME(INFO) CHECKARG_TYPENAME(CENTER) CHECKARG_TYPENAME(MULTI) @@@ -104,6 -107,7 +107,7 @@@ string Notification_CheckArgs void Destroy_Notification_Entity(entity notif) { if(notif.nent_name != "") { strunzone(notif.nent_name); } + if(notif.nent_snd != "") { strunzone(notif.nent_snd); } if(notif.nent_args != "") { strunzone(notif.nent_args); } if(notif.nent_hudargs != "") { strunzone(notif.nent_hudargs); } if(notif.nent_icon != "") { strunzone(notif.nent_icon); } @@@ -133,6 -137,7 +137,7 @@@ void Destroy_All_Notifications(void #endif // kill all real notification entities + DESTROY_LOOP(MSG_ANNCE, NOTIF_ANNCE_COUNT) DESTROY_LOOP(MSG_INFO, NOTIF_INFO_COUNT) DESTROY_LOOP(MSG_CENTER, NOTIF_CENTER_COUNT) DESTROY_LOOP(MSG_MULTI, NOTIF_MULTI_COUNT) @@@ -339,8 -344,13 +344,13 @@@ void Create_Notification_Entity float typeid, float nameid, string namestring, + float anncename, float infoname, float centername, + float channel, + string snd, + float vol, + float position, float strnum, float flnum, string args, @@@ -360,6 -370,13 +370,13 @@@ string typestring = ""; switch(typeid) { + case MSG_ANNCE: + { + typestring = "MSG_ANNCE"; + msg_annce_notifs[nameid - 1] = notif; + notif.classname = "msg_annce_notification"; + break; + } case MSG_INFO: { typestring = "MSG_INFO"; @@@ -409,7 -426,7 +426,7 @@@ if(msg_is_multi) { // Set MSG_MULTI string/float counts - if((infoname == NO_MSG) && (centername == NO_MSG)) + if((anncename == NO_MSG) && (infoname == NO_MSG) && (centername == NO_MSG)) { print(sprintf( strcat( @@@ -423,6 -440,9 +440,9 @@@ } else { + // announcements don't actually need any arguments, so lets not even count them. + if(anncename != NO_MSG) { notif.nent_msgannce = msg_annce_notifs[anncename - 1]; } + float infoname_stringcount = 0, infoname_floatcount = 0; float centername_stringcount = 0, centername_floatcount = 0; @@@ -445,6 -465,41 +465,41 @@@ notif.nent_floatcount = max(infoname_floatcount, centername_floatcount); } } + else if(typeid == MSG_ANNCE) + { + // Set MSG_ANNCE information and handle precaching + #ifdef CSQC + if not(GENTLE && (var_cvar == 1)) + { + if(snd != "") + { + if(notif.nent_enabled) + { + precache_sound(sprintf("announcer/%s/%s.wav", autocvar_cl_announcer, snd)); + notif.nent_channel = channel; + notif.nent_snd = strzone(snd); + notif.nent_vol = vol; + notif.nent_position = position; + } + } + else + { + print(sprintf( + strcat( + "^1NOTIFICATION WITH NO SOUND: ", + "^7net_type = %s, net_name = %s.\n" + ), + typestring, + namestring + )); + notif_error = TRUE; + } + } + else { notif.nent_enabled = FALSE; } + #else + notif.nent_enabled = FALSE; + #endif + } else { // Set MSG_INFO and MSG_CENTER string/float counts @@@ -653,6 -708,14 +708,14 @@@ void Dump_Notifications(float fh, floa // This is not necessary, and does not matter if they vary between config versions, // it is just a semi-helpful tool for those who want to manually change their user settings. + NOTIF_WRITE(sprintf("\n// MSG_ANNCE notifications (count = %d):\n", NOTIF_ANNCE_COUNT)); + for(i = 1; i <= NOTIF_ANNCE_COUNT; ++i) + { + e = Get_Notif_Ent(MSG_ANNCE, i); + if not(e) { backtrace("Dump_Notifications(): Missing notification entity!\n"); return; } + NOTIF_WRITE_ENTITY(e.nent_name, e.nent_default, "Notification control cvar: 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)); for(i = 1; i <= NOTIF_INFO_COUNT; ++i) { @@@ -702,13 -765,15 +765,15 @@@ NOTIF_WRITE(sprintf( strcat( "\n// Notification counts (total = %d): ", - "MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d\n" + "MSG_ANNCE = %d, MSG_INFO = %d, MSG_CENTER = %d, MSG_MULTI = %d\n" ), ( + NOTIF_ANNCE_COUNT + NOTIF_INFO_COUNT + NOTIF_CENTER_COUNT + NOTIF_MULTI_COUNT - ), + ), + NOTIF_ANNCE_COUNT, NOTIF_INFO_COUNT, NOTIF_CENTER_COUNT, NOTIF_MULTI_COUNT @@@ -778,6 -843,62 +843,62 @@@ string Local_Notification_sprintf } #ifdef CSQC + void Local_Notification_sound( + float soundchannel, string soundfile, + float soundvolume, float soundposition) + { + if((soundfile != prev_soundfile) || (time >= (prev_soundtime + autocvar_cl_announcer_antispam))) + { + #ifdef NOTIFICATIONS_DEBUG + dprint(sprintf( + "Local_Notification_sound(world, %f, '%s', %f, %f);\n", + soundchannel, + sprintf( + "announcer/%s/%s.wav", + autocvar_cl_announcer, + soundfile + ), + soundvolume, + soundposition + )); + #endif + + sound( + world, + soundchannel, + sprintf( + "announcer/%s/%s.wav", + autocvar_cl_announcer, + soundfile + ), + soundvolume, + soundposition + ); + + if(prev_soundfile) { strunzone(prev_soundfile); } + prev_soundfile = strzone(soundfile); + prev_soundtime = time; + } + else + { + #ifdef NOTIFICATIONS_DEBUG + dprint(sprintf( + "Local_Notification_sound(world, %f, '%s', %f, %f) ^1BLOCKED BY ANTISPAM:^7 prevsnd: '%s', time/prevtime: %f, limit: %f\n", + soundchannel, + sprintf( + "announcer/%s/%s.wav", + autocvar_cl_announcer, + soundfile + ), + soundvolume, + soundposition, + prev_soundfile, + (time - prev_soundtime), + autocvar_cl_announcer_antispam + )); + #endif + } + } void Local_Notification_HUD_Notify_Push( string icon, string hudargs, string s1, string s2, string s3, string s4) @@@ -922,6 -1043,21 +1043,21 @@@ void Local_Notification(float net_type switch(net_type) { + case MSG_ANNCE: + { + #ifdef CSQC + 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 + break; + } + case MSG_INFO: { print( @@@ -973,6 -1109,16 +1109,16 @@@ f1, f2, f3, f4); } #ifdef CSQC + if(notif.nent_msgannce) + if(notif.nent_msgannce.nent_enabled) + { + Local_Notification_WOVA( + MSG_ANNCE, + notif.nent_msgannce.nent_id, + 0, 0, + "", "", "", "", + 0, 0, 0, 0); + } if(notif.nent_msgcenter) if(notif.nent_msgcenter.nent_enabled) { @@@ -1208,7 -1354,7 +1354,7 @@@ void Kill_Notification "Kill_Notification(%d, '%s', %s, %d);\n", broadcast, client.netname, - Get_Notif_TypeName(net_type), + (net_type ? Get_Notif_TypeName(net_type) : "0"), net_name )); #endif @@@ -1265,7 -1411,7 +1411,7 @@@ { if(net_type) { - if(killed_cpid != NO_CPID) + if((killed_cpid != NO_CPID) && (notif.nent_net_type == MSG_CENTER)) { if(notif.owner.nent_cpid == killed_cpid) { @@@ -1373,7 -1519,7 +1519,7 @@@ void Send_Notification Net_LinkEntity(net_notif, FALSE, 0, Net_Write_Notification); - if(server_is_dedicated && (broadcast == NOTIF_ALL || broadcast == NOTIF_ALL_EXCEPT) && (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( net_type, net_name,