Merge remote branch 'refs/remotes/origin/fruitiex/votesounds'
authorRudolf Polzer <divverent@alientrap.org>
Wed, 4 Aug 2010 11:41:21 +0000 (13:41 +0200)
committerRudolf Polzer <divverent@alientrap.org>
Wed, 4 Aug 2010 11:41:21 +0000 (13:41 +0200)
qcsrc/client/miscfunctions.qc
qcsrc/server/vote.qc
sound/announcer/default/voteaccept.wav [new file with mode: 0644]
sound/announcer/default/votecall.wav [new file with mode: 0644]
sound/announcer/default/votefail.wav [new file with mode: 0644]

index c573fe30518ee2c02591327918d0a1e43cf58375..02698745083654f3b71b0da7579ebf3b634b5ded 100644 (file)
@@ -45,54 +45,54 @@ void restartAnnouncer_Think() {
  * Plays the 1minute or 5 minutes (of maptime) remaining sound, if client wants it
  */
 void maptimeAnnouncer() {
-    float timelimit;
-    timelimit = getstatf(STAT_TIMELIMIT);
-    float timeleft;
-    timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
-
-    float warmuplimit;
-    float warmuptimeleft;
-    if(warmup_stage) {
-        warmuplimit = cvar("g_warmup_limit");
-        if(warmuplimit > 0) {
-           warmuptimeleft = max(0, warmuplimit + getstatf(STAT_GAMESTARTTIME) - time); 
-        }
-    }
-
-    //5 minute check
-    if (cvar("cl_sound_maptime_warning") >= 2) {
-        //make sure that after connect (and e.g. 4 minutes left) we will not get a wrong sound
-        if(announcer_5min)
-        {
+       float timelimit;
+       timelimit = getstatf(STAT_TIMELIMIT);
+       float timeleft;
+       timeleft = max(0, timelimit * 60 + getstatf(STAT_GAMESTARTTIME) - time);
+
+       float warmuplimit;
+       float warmuptimeleft;
+       if(warmup_stage) {
+               warmuplimit = cvar("g_warmup_limit");
+               if(warmuplimit > 0) {
+                       warmuptimeleft = max(0, warmuplimit + getstatf(STAT_GAMESTARTTIME) - time); 
+               }
+       }
+
+       //5 minute check
+       if (cvar("cl_sound_maptime_warning") >= 2) {
+               //make sure that after connect (and e.g. 4 minutes left) we will not get a wrong sound
+               if(announcer_5min)
+               {
                        if(((!warmup_stage || warmuplimit == 0) && timeleft > 300) || (warmup_stage && warmuplimit > 0 && warmuptimeleft > 300))
                                announcer_5min = FALSE;
-        }
-        else if (((!warmup_stage || warmuplimit == 0) && timelimit > 0 && timeleft < 300 && timeleft > 299) || (warmup_stage && warmuplimit > 0 && warmuptimeleft < 300 && warmuptimeleft > 299))
-       //if we're in warmup mode, check whether there's a warmup timelimit
-        if not (warmuplimit == -1 && warmup_stage) {
-                       announcer_5min = TRUE;
-                       //dprint("i will play the sound, I promise!\n");
-                       sound(self, CHAN_VOICE, strcat("announcer/", cvar_string("cl_announcer"), "/5minutesremain.wav"), VOL_BASEVOICE, ATTN_NONE);
                }
-    }
+               else if (((!warmup_stage || warmuplimit == 0) && timelimit > 0 && timeleft < 300 && timeleft > 299) || (warmup_stage && warmuplimit > 0 && warmuptimeleft < 300 && warmuptimeleft > 299))
+                       //if we're in warmup mode, check whether there's a warmup timelimit
+                       if not (warmuplimit == -1 && warmup_stage) {
+                               announcer_5min = TRUE;
+                               //dprint("i will play the sound, I promise!\n");
+                               sound(self, CHAN_VOICE, strcat("announcer/", cvar_string("cl_announcer"), "/5minutesremain.wav"), VOL_BASEVOICE, ATTN_NONE);
+                       }
+       }
 
-    //1 minute check
-    if (cvar("cl_sound_maptime_warning") == 1 || cvar("cl_sound_maptime_warning") == 3) {
-       if (announcer_1min)
-       {
+       //1 minute check
+       if (cvar("cl_sound_maptime_warning") == 1 || cvar("cl_sound_maptime_warning") == 3) {
+               if (announcer_1min)
+               {
                        if(((!warmup_stage || warmuplimit == 0) && timeleft > 60) || (warmup_stage && warmuplimit > 0 && warmuptimeleft > 60))
                                announcer_1min = FALSE;
-       }
-       else if (((!warmup_stage || warmuplimit == 0) && timelimit > 0 && timeleft < 60) || (warmup_stage && warmuplimit > 0 && warmuptimeleft < 60))
-       //if we're in warmup mode, check whether there's a warmup timelimit
-       if not (warmuplimit == -1 && warmup_stage) {
-                       announcer_1min = TRUE;
-                       sound(self, CHAN_VOICE, strcat("announcer/", cvar_string("cl_announcer"), "/1minuteremains.wav"), VOL_BASEVOICE, ATTN_NONE);
-       }
+               }
+               else if (((!warmup_stage || warmuplimit == 0) && timelimit > 0 && timeleft < 60) || (warmup_stage && warmuplimit > 0 && warmuptimeleft < 60))
+                       //if we're in warmup mode, check whether there's a warmup timelimit
+                       if not (warmuplimit == -1 && warmup_stage) {
+                               announcer_1min = TRUE;
+                               sound(self, CHAN_VOICE, strcat("announcer/", cvar_string("cl_announcer"), "/1minuteremains.wav"), VOL_BASEVOICE, ATTN_NONE);
+                       }
        }
 }
 
- /**
+/**
  * Announce carried items (e.g. flags in CTF).
  */
 float redflag_prev;
@@ -181,6 +181,10 @@ void Announcer_Precache () {
 
        precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/lastsecond.wav"));
        precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/narrowly.wav"));
+
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/voteaccept.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/votecall.wav"));
+       precache_sound (strcat("announcer/", cvar_string("cl_announcer"), "/votefail.wav"));
 }
 
 void AuditLists()
@@ -472,41 +476,41 @@ void drawpic_tiled(vector pos, string pic, vector sz, vector area, vector color,
 var float imgaspect;
 var float aspect;
 #define drawpic_aspect(pos,pic,mySize,color,alpha,drawflag)\
-do {\
-       vector imgsize;\
-       imgsize = drawgetimagesize(pic);\
-       imgaspect = imgsize_x/imgsize_y;\
-       vector oldsz, sz;\
-       oldsz = sz = mySize;\
-       aspect = sz_x/sz_y;\
-       if(aspect > imgaspect) {\
-               sz_x = sz_y * imgaspect;\
-               drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);\
-       } else {\
-               sz_y = sz_x / imgaspect;\
-               drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);\
-       }\
-} while(0)
+       do {\
+               vector imgsize;\
+               imgsize = drawgetimagesize(pic);\
+               imgaspect = imgsize_x/imgsize_y;\
+               vector oldsz, sz;\
+               oldsz = sz = mySize;\
+               aspect = sz_x/sz_y;\
+               if(aspect > imgaspect) {\
+                       sz_x = sz_y * imgaspect;\
+                       drawpic(pos + eX * (oldsz_x - sz_x) * 0.5, pic, sz, color, alpha, drawflag);\
+               } else {\
+                       sz_y = sz_x / imgaspect;\
+                       drawpic(pos + eY * (oldsz_y - sz_y) * 0.5, pic, sz, color, alpha, drawflag);\
+               }\
+       } while(0)
 
 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
 #define drawpic_aspect_skin(pos,pic,sz,color,alpha,drawflag)\
-do{\
-       picpath = strcat(hud_skin_path, "/", pic);\
-       if(precache_pic(picpath) == "") {\
-               picpath = strcat("gfx/hud/default/", pic);\
-       }\
-       drawpic_aspect(pos, picpath, sz, color, alpha, drawflag);\
-} while(0)
+       do{\
+               picpath = strcat(hud_skin_path, "/", pic);\
+               if(precache_pic(picpath) == "") {\
+                       picpath = strcat("gfx/hud/default/", pic);\
+               }\
+               drawpic_aspect(pos, picpath, sz, color, alpha, drawflag);\
+       } while(0)
 
 // draw HUD element with image from gfx/hud/hud_skin/foo.tga if it exists, otherwise gfx/hud/default/foo.tga
 #define drawpic_skin(pos,pic,sz,color,alpha,drawflag)\
-do{\
-       picpath = strcat(hud_skin_path, "/", pic);\
-       if(precache_pic(picpath) == "") {\
-               picpath = strcat("gfx/hud/default/", pic);\
-       }\
-       drawpic(pos, picpath, sz, color, alpha, drawflag);\
-} while(0)
+       do{\
+               picpath = strcat(hud_skin_path, "/", pic);\
+               if(precache_pic(picpath) == "") {\
+                       picpath = strcat("gfx/hud/default/", pic);\
+               }\
+               drawpic(pos, picpath, sz, color, alpha, drawflag);\
+       } while(0)
 
 void drawpic_aspect_skin_expanding(vector position, string pic, vector scale, vector rgb, float alpha, float flag, float fadelerp)
 {
@@ -526,7 +530,7 @@ void drawpic_aspect_skin_expanding_two(vector position, string pic, vector scale
 void drawstring_aspect(vector pos, string text, vector sz, vector color, float alpha, float drawflag) {
        vector textsize;
        textsize = eX * stringwidth(text, FALSE, '1 1 1' * sz_y) + eY * sz_y;
-       
+
        float textaspect;
        textaspect = textsize_x/textsize_y;
 
@@ -548,7 +552,7 @@ void drawstring_aspect(vector pos, string text, vector sz, vector color, float a
 void drawcolorcodedstring_aspect(vector pos, string text, vector sz, float alpha, float drawflag) {
        vector textsize;
        textsize = eX * stringwidth(text, TRUE, '1 1 1' * sz_y) + eY * sz_y;
-       
+
        float textaspect;
        textaspect = textsize_x/textsize_y;
 
@@ -574,7 +578,7 @@ void drawstring_expanding(vector position, string text, vector scale, vector rgb
 
        drawfontscale = sz * '1 1 0';
        dummyfunction(0, 0, 0, 0, 0, 0, 0, 0);
-        drawstring(position + expandingbox_resize_centered_box_offset(sz, scale, stringwidth(text, FALSE, scale * (sz / drawfontscale_x)) / (scale_x * sz)), text, scale * (sz / drawfontscale_x), rgb, alpha * (1 - fadelerp), flag);
+       drawstring(position + expandingbox_resize_centered_box_offset(sz, scale, stringwidth(text, FALSE, scale * (sz / drawfontscale_x)) / (scale_x * sz)), text, scale * (sz / drawfontscale_x), rgb, alpha * (1 - fadelerp), flag);
        // width parameter:
        //    (scale_x * sz / drawfontscale_x) * drawfontscale_x * SIZE1 / (scale_x * sz)
        //    SIZE1
@@ -585,7 +589,7 @@ void drawstring_expanding(vector position, string text, vector scale, vector rgb
 void drawstring_aspect_expanding(vector pos, string text, vector sz, vector color, float alpha, float drawflag, float fadelerp) {
        vector textsize;
        textsize = eX * stringwidth(text, FALSE, '1 1 1' * sz_y) + eY * sz_y;
-       
+
        float textaspect;
        textaspect = textsize_x/textsize_y;
 
index e67b5378073820b7815b4c428d000aec986b0237..1fbdecad9fdf6714fff928c760ab9444eb140a35 100644 (file)
@@ -129,6 +129,7 @@ void VoteDialog_Reset() {
 }
 
 float GameCommand_Vote(string s, entity e) {
+       local float playercount;
        float argc;
        argc = tokenize_console(s);
        if(argv(0) == "help") {
@@ -161,8 +162,8 @@ float GameCommand_Vote(string s, entity e) {
                                        if(vote == "") {
                                                print_to(e, "^1Your vote is empty. See 'vhelp' for more info.");
                                        } else if(e
-                                               && time < e.vote_next) {
-                                                       print_to(e, strcat("^1You have to wait ^2", ftos(ceil(e.vote_next - time)), "^1 seconds before you can again call a vote."));
+                                                       && time < e.vote_next) {
+                                               print_to(e, strcat("^1You have to wait ^2", ftos(ceil(e.vote_next - time)), "^1 seconds before you can again call a vote."));
                                        } else if(VoteCheckNasty(vote)) {
                                                print_to(e, "Syntax error in command. See 'vhelp' for more info.");
                                        } else if(RemapVote(vote, "vcall", e)) {
@@ -183,6 +184,14 @@ float GameCommand_Vote(string s, entity e) {
                                                Nagger_VoteChanged();
                                                msg_entity = e;
                                                VoteDialog_UpdateHighlight(1);
+
+                                               local entity player;
+                                               FOR_EACH_REALCLIENT(player)
+                                               {
+                                                       ++playercount;
+                                               }
+                                               if(playercount > 1) // don't announce a "vote now" sound if player is alone
+                                                       Announce("votecall");
                                        } else {
                                                print_to(e, "^1This vote is not ok. See 'vhelp' for more info.");
                                        }
@@ -486,16 +495,19 @@ void VoteAccept() {
                                          // no wait for next vote
        }
        VoteReset();
+       Announce("voteaccept");
 }
 
 void VoteReject() {
        bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2's vote for ", votecalledvote_display, "^2 was rejected\n");
        VoteReset();
+       Announce("votefail");
 }
 
 void VoteTimeout() {
        bprint("\{1}^2* ^3", VoteNetname(votecaller), "^2's vote for ", votecalledvote_display, "^2 timed out\n");
        VoteReset();
+       Announce("votefail");
 }
 
 void VoteStop(entity stopper) {
diff --git a/sound/announcer/default/voteaccept.wav b/sound/announcer/default/voteaccept.wav
new file mode 100644 (file)
index 0000000..b21587a
Binary files /dev/null and b/sound/announcer/default/voteaccept.wav differ
diff --git a/sound/announcer/default/votecall.wav b/sound/announcer/default/votecall.wav
new file mode 100644 (file)
index 0000000..8441af3
Binary files /dev/null and b/sound/announcer/default/votecall.wav differ
diff --git a/sound/announcer/default/votefail.wav b/sound/announcer/default/votefail.wav
new file mode 100644 (file)
index 0000000..b60bdaf
Binary files /dev/null and b/sound/announcer/default/votefail.wav differ