From: Samual Date: Tue, 18 Oct 2011 15:40:25 +0000 (-0400) Subject: Add antispam cvar, move declarations out of defs.qh and main.qh, and X-Git-Tag: xonotic-v0.6.0~35^2~66^2~2^2~15 X-Git-Url: https://git.rm.cloudns.org/?a=commitdiff_plain;h=79b2d83cac5aefaa339c7a81fbfd0a136dfa316e;p=xonotic%2Fxonotic-data.pk3dir.git Add antispam cvar, move declarations out of defs.qh and main.qh, and re-write some more in announcer code --- diff --git a/defaultXonotic.cfg b/defaultXonotic.cfg index f92882f44..1e8c20537 100644 --- a/defaultXonotic.cfg +++ b/defaultXonotic.cfg @@ -960,6 +960,7 @@ seta cl_sound_maptime_warning "1" "play announcer sound telling you the remainin seta cl_notify_carried_items "3" "notify you of carried items when you obtain them (e.g. flags in CTF) - 0: disabled, 1: notify of taken items, 2: notify of picking up dropped items, 3: notify of both" seta cl_announcer default "name of the announcer you wish to use from data/sound/announcer" +seta cl_announcer_antispam 2 "number of seconds before an announcement of the same sound can be played again" // startmap_dm is used when running with the -listen or -dedicated commandline options set serverconfig server.cfg diff --git a/qcsrc/client/Defs.qc b/qcsrc/client/Defs.qc index b074aa3b2..a1a32404d 100644 --- a/qcsrc/client/Defs.qc +++ b/qcsrc/client/Defs.qc @@ -222,10 +222,6 @@ float spectatee_status; // short mapname string shortmapname; -//remaining maptime announcer sounds, true when sound was already played -float announcer_1min; -float announcer_5min; - // database for misc stuff float tempdb; float ClientProgsDB; diff --git a/qcsrc/client/announcer.qc b/qcsrc/client/announcer.qc index 0d64d6535..7dc6a9d57 100644 --- a/qcsrc/client/announcer.qc +++ b/qcsrc/client/announcer.qc @@ -1,9 +1,14 @@ float previous_announcement_time; +float previous_game_starttime; string previous_announcement; +//remaining maptime announcer sounds, true when sound was already played +float announcer_1min; +float announcer_5min; + void Announcer_Play(string announcement) { - if((announcement != previous_announcement) || (time >= (previous_announcement_time + 5))) + if((announcement != previous_announcement) || (time >= (previous_announcement_time + autocvar_cl_announcer_antispam))) { sound(world, CH_INFO, strcat("announcer/", autocvar_cl_announcer, "/", announcement, ".wav"), VOL_BASEVOICE, ATTN_NONE); @@ -12,6 +17,34 @@ void Announcer_Play(string announcement) } } +void Announcer_Countdown() +{ + float starttime = getstatf(STAT_GAMESTARTTIME); + float countdown = (starttime - time); + float countdown_rounded = floor(0.5 + countdown); + + if(countdown <= 0) // countdown has finished, starttime is now + { + if (!spectatee_status) + centerprint_generic(CPID_GAME_STARTING, _("^1Begin!"), 1, 0); + + Announcer_Play("begin"); + announcer_5min = announcer_1min = FALSE; //reset maptime announcers now as well + remove(self); + return; + } + else // countdown is still going + { + if (!spectatee_status) + centerprint_generic(CPID_GAME_STARTING, _("^1Game starts in %d seconds"), 1, countdown_rounded); + + if(countdown_rounded <= 3 && countdown_rounded >= 1) + Announcer_Play(ftos(countdown_rounded)); + + self.nextthink = (starttime - (countdown - 1)); + } +} + /** * Checks whether the server initiated a map restart (stat_game_starttime changed) * @@ -19,50 +52,28 @@ void Announcer_Play(string announcement) * timelimit, fraglimit and game_starttime! Requires engine changes (remove STAT_TIMELIMIT * and STAT_FRAGLIMIT to be auto-sent) */ -void CheckForGamestartChange() { - float startTime; - startTime = getstatf(STAT_GAMESTARTTIME); - if (previous_game_starttime != startTime) { - if ((time + 5.0) < startTime) { - //if connecting to server while restart was active don't always play prepareforbattle - sound(world, CH_INFO, strcat("announcer/", autocvar_cl_announcer, "/prepareforbattle.wav"), VOL_BASEVOICE, ATTN_NONE); +void Announcer_Gamestart() +{ + float startTime = getstatf(STAT_GAMESTARTTIME); + + if (previous_game_starttime != startTime) + { + if ((time + 5.0) < startTime) //if connecting to server while restart was active don't always play prepareforbattle + { + Announcer_Play("prepareforbattle"); } - if (time < startTime) { - restartAnnouncer = spawn(); - restartAnnouncer.think = restartAnnouncer_Think; - restartAnnouncer.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime + if (time < startTime) + { + entity e; + e = spawn(); + e.think = Announcer_Countdown; + e.nextthink = startTime - floor(startTime - time); //synchronize nextthink to startTime } } + previous_game_starttime = startTime; } -void restartAnnouncer_Think() { - float countdown_rounded, countdown; - countdown = getstatf(STAT_GAMESTARTTIME) - time; - countdown_rounded = floor(0.5 + countdown); - if(countdown <= 0) { - if (!spectatee_status) //do cprint only for players - centerprint_generic(CPID_GAME_STARTING, _("^1Begin!"), 1, 0); - - sound(world, CH_INFO, strcat("announcer/", autocvar_cl_announcer, "/begin.wav"), VOL_BASEVOICE, ATTN_NONE); - //reset maptime announcers now as well - announcer_5min = announcer_1min = FALSE; - - remove(self); - return; - } - else { - if (!spectatee_status) //do cprint only for players - centerprint_generic(CPID_GAME_STARTING, _("^1Game starts in %d seconds"), 1, countdown_rounded); - - if(countdown_rounded <= 3 && countdown_rounded >= 1) { - sound(world, CH_INFO, strcat("announcer/", autocvar_cl_announcer, "/", ftos(countdown_rounded), ".wav"), VOL_BASEVOICE, ATTN_NONE); - } - - self.nextthink = getstatf(STAT_GAMESTARTTIME) - (countdown - 1); - } -} - /** * Plays the 1minute or 5 minutes (of maptime) remaining sound, if client wants it */ @@ -159,7 +170,7 @@ void carrierAnnouncer() { void Announcer() { - CheckForGamestartChange(); + Announcer_Gamestart(); maptimeAnnouncer(); carrierAnnouncer(); } diff --git a/qcsrc/client/autocvars.qh b/qcsrc/client/autocvars.qh index 7259761c2..c62546b1f 100644 --- a/qcsrc/client/autocvars.qh +++ b/qcsrc/client/autocvars.qh @@ -19,6 +19,7 @@ float autocvar_camera_speed_roll; float autocvar_chase_active; float autocvar_cl_allow_uid2name; string autocvar_cl_announcer; +float autocvar_cl_announcer_antispam; float autocvar_cl_autodemo_delete; float autocvar_cl_autodemo_delete_keeprecords; float autocvar_cl_casings; diff --git a/qcsrc/client/main.qh b/qcsrc/client/main.qh index 9ea50c02b..58a0bad19 100644 --- a/qcsrc/client/main.qh +++ b/qcsrc/client/main.qh @@ -131,10 +131,6 @@ float ready_waiting_for_me; float vote_waiting; float vote_waiting_for_me; -float previous_game_starttime; -entity restartAnnouncer; //a temporary entity which will play the countdown sounds 3, 2, 1 for the client -void restartAnnouncer_Think(); - float current_zoomfraction; float cs_project_is_b0rked;