X-Git-Url: http://de.git.xonotic.org/?a=blobdiff_plain;f=qcsrc%2Fcommon%2Fnotifications.qc;h=b72380cceec19db94a27e807bb0f869e91f551eb;hb=1633673cc6c65bdca0120f2a4fc33e8c2449f06d;hp=0feda9ba90138afc04136667ba8ab42247716e5f;hpb=3d8db498ea6450331f0851f57d2fc7fd076d3737;p=xonotic%2Fxonotic-data.pk3dir.git diff --git a/qcsrc/common/notifications.qc b/qcsrc/common/notifications.qc index 0feda9ba9..b72380cce 100644 --- a/qcsrc/common/notifications.qc +++ b/qcsrc/common/notifications.qc @@ -349,7 +349,7 @@ void Create_Notification_Entity( float centername, float channel, string snd, - float volume, + float vol, float position, float strnum, float flnum, @@ -370,6 +370,13 @@ void Create_Notification_Entity( 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"; @@ -419,7 +426,7 @@ void Create_Notification_Entity( 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( @@ -433,6 +440,9 @@ void Create_Notification_Entity( } 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; @@ -455,6 +465,41 @@ void Create_Notification_Entity( 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 @@ -701,6 +746,7 @@ void Dump_Notifications(float fh, float alsoprint) NOTIF_WRITE_HARDCODED("ctf_capture_verbose", "0", "Show extra information when someone captures a flag"); NOTIF_WRITE_HARDCODED("ctf_pickup_enemy_verbose", "0", "Show extra information if an enemy picks up a flag"); NOTIF_WRITE_HARDCODED("ctf_pickup_team_verbose", "0", "Show extra information if a team mate picks up a flag"); + NOTIF_WRITE_HARDCODED("debug", "0", "Print extra debug information on all notification function calls (Requires -DNOTIFICATIONS_DEBUG flag to be enabled on QCSRC compilation)... 0 = disabled, 1 = dprint, 2 = print"); NOTIF_WRITE_HARDCODED("errors_are_fatal", "1", "If a notification fails upon initialization, cause a Host_Error to stop the program"); NOTIF_WRITE_HARDCODED("frag_verbose", "1", "Show extra information when you frag someone (or when you are fragged"); NOTIF_WRITE_HARDCODED("item_centerprinttime", "1.5", "How long to show item information centerprint messages (like 'You got the Electro' or such)"); @@ -752,13 +798,24 @@ void Notification_GetCvars() // Frontend Notification Pushing // =============================== +#ifdef NOTIFICATIONS_DEBUG +void Debug_Notification(string input) +{ + switch(autocvar_notification_debug) + { + case 1: { dprint(input); break; } + case 2: { print(input); break; } + } +} +#endif + string Local_Notification_sprintf( string input, string args, string s1, string s2, string s3, string s4, float f1, float f2, float f3, float f4) { #ifdef NOTIFICATIONS_DEBUG - dprint(sprintf( + Debug_Notification(sprintf( "Local_Notification_sprintf('%s^7', '%s', %s, %s);\n", MakeConsoleSafe(input), args, @@ -798,6 +855,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 + Debug_Notification(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 + Debug_Notification(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) @@ -822,7 +935,7 @@ void Local_Notification_HUD_Notify_Push( } } #ifdef NOTIFICATIONS_DEBUG - dprint(sprintf( + Debug_Notification(sprintf( "Local_Notification_HUD_Notify_Push('%s^7', '%s', %s, %s);\n", icon, hudargs, @@ -862,7 +975,7 @@ void Local_Notification_centerprint_generic( } } #ifdef NOTIFICATIONS_DEBUG - dprint(sprintf( + Debug_Notification(sprintf( "Local_Notification_centerprint_generic('%s^7', '%s', %d, %d, %d, %d);\n", MakeConsoleSafe(input), durcnt, @@ -885,7 +998,7 @@ void Local_Notification(float net_type, float net_name, ...count) if not(notif.nent_enabled) { #ifdef NOTIFICATIONS_DEBUG - dprint(sprintf( + Debug_Notification(sprintf( "Local_Notification(%s, %s): Entity was disabled...\n", Get_Notif_TypeName(net_type), notif.nent_name @@ -931,7 +1044,7 @@ void Local_Notification(float net_type, float net_name, ...count) float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0); #ifdef NOTIFICATIONS_DEBUG - dprint(sprintf( + Debug_Notification(sprintf( "Local_Notification(%s, %s, %s, %s);\n", Get_Notif_TypeName(net_type), notif.nent_name, @@ -944,7 +1057,16 @@ void Local_Notification(float net_type, float net_name, ...count) { case MSG_ANNCE: { - print("blah blah\n"); + #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; } @@ -999,6 +1121,16 @@ void Local_Notification(float net_type, float net_name, ...count) 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) { @@ -1047,7 +1179,7 @@ void Read_Notification(float is_new) if(net_type == MSG_CENTER_CPID) { #ifdef NOTIFICATIONS_DEBUG - dprint(sprintf( + Debug_Notification(sprintf( "Read_Notification(%d) at %f: net_type = %s, net_name = %d\n", is_new, time, @@ -1080,7 +1212,7 @@ void Read_Notification(float is_new) if not(notif) { backtrace("Read_Notification: Could not find notification entity!\n"); return; } #ifdef NOTIFICATIONS_DEBUG - dprint(sprintf( + Debug_Notification(sprintf( "Read_Notification(%d) at %f: net_type = %s, net_name = %s\n", is_new, time, @@ -1117,7 +1249,7 @@ void Net_Notification_Remove() if not(self) { backtrace(sprintf("Net_Notification_Remove() at %f: Missing self!?\n", time)); return; } #ifdef NOTIFICATIONS_DEBUG - dprint(sprintf( + Debug_Notification(sprintf( "Net_Notification_Remove() at %f: %s '%s - %s' notification\n", time, ((self.nent_net_name == -1) ? "Killed" : "Removed"), @@ -1230,11 +1362,11 @@ void Kill_Notification( if(checkargs != "") { backtrace(sprintf("Incorrect usage of Kill_Notification: %s\n", checkargs)); return; } #ifdef NOTIFICATIONS_DEBUG - dprint(sprintf( + Debug_Notification(sprintf( "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 @@ -1291,7 +1423,7 @@ void Kill_Notification( { 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) { @@ -1364,7 +1496,7 @@ void Send_Notification( float f2 = ((1 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 1), float) : 0); float f3 = ((2 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 2), float) : 0); float f4 = ((3 < notif.nent_floatcount) ? ...((notif.nent_stringcount + 3), float) : 0); - dprint(sprintf( + Debug_Notification(sprintf( "Send_Notification(%d, %s, %s, %s, %s);\n", broadcast, Get_Notif_TypeName(net_type), @@ -1420,7 +1552,7 @@ void Send_Notification_WOVA( entity notif = Get_Notif_Ent(net_type, net_name); #ifdef NOTIFICATIONS_DEBUG - dprint(sprintf( + Debug_Notification(sprintf( "Send_Notification_WOVA(%d, %s, %s, %s, %s);\n", broadcast, Get_Notif_TypeName(net_type),