Skip to content

Commit

Permalink
CGAME: Vote announcer sound feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
kai-li-wop committed Sep 4, 2023
1 parent 0f68abb commit 0c8b0fa
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 0 deletions.
4 changes: 4 additions & 0 deletions code/cgame/cg_main.c
Original file line number Diff line number Diff line change
Expand Up @@ -758,6 +758,10 @@ static void CG_RegisterSounds(void) {
cgs.media.padaceSound = trap_S_RegisterSound("sound/feedback/awards/padace", qtrue);
cgs.media.padstarSound = trap_S_RegisterSound("sound/feedback/awards/padstar", qtrue);

cgs.media.voteNow = trap_S_RegisterSound("sound/feedback/vote_now", qtrue);
cgs.media.votePassed = trap_S_RegisterSound("sound/feedback/vote_passed", qtrue);
cgs.media.voteFailed = trap_S_RegisterSound("sound/feedback/vote_failed", qtrue);

cgs.media.watrInSound = trap_S_RegisterSound("sound/padplayer/water_in", qfalse);
cgs.media.watrOutSound = trap_S_RegisterSound("sound/padplayer/water_out", qfalse);
cgs.media.watrUnSound = trap_S_RegisterSound("sound/padplayer/water_under", qfalse);
Expand Down
9 changes: 9 additions & 0 deletions code/cgame/cg_servercmds.c
Original file line number Diff line number Diff line change
Expand Up @@ -329,6 +329,7 @@ static void CG_ConfigStringModified(void) {
cgs.voteModified = qtrue;
} else if (num == CS_VOTE_STRING) {
Q_strncpyz(cgs.voteString, str, sizeof(cgs.voteString));
trap_S_StartLocalSound(cgs.media.voteNow, CHAN_ANNOUNCER);
} else if (num >= CS_TEAMVOTE_TIME && num <= CS_TEAMVOTE_TIME + 1) {
cgs.teamVoteTime[num - CS_TEAMVOTE_TIME] = atoi(str);
cgs.teamVoteModified[num - CS_TEAMVOTE_TIME] = qtrue;
Expand All @@ -340,6 +341,7 @@ static void CG_ConfigStringModified(void) {
cgs.teamVoteModified[num - CS_TEAMVOTE_NO] = qtrue;
} else if (num >= CS_TEAMVOTE_STRING && num <= CS_TEAMVOTE_STRING + 1) {
Q_strncpyz(cgs.teamVoteString[num - CS_TEAMVOTE_STRING], str, sizeof(cgs.teamVoteString));
trap_S_StartLocalSound(cgs.media.voteNow, CHAN_ANNOUNCER);
} else if (num == CS_INTERMISSION) {
cg.intermissionStarted = atoi(str);
} else if (num >= CS_MODELS && num < CS_MODELS + MAX_MODELS) {
Expand Down Expand Up @@ -548,6 +550,13 @@ static void CG_ServerCommand(void) {

if (!strcmp(cmd, "print")) {
CG_Printf("%s", CG_Argv(1));
cmd = CG_Argv(1); // yes, this is obviously a hack, but so is the way we hear about
// votes passing or failing
if (!Q_stricmpn(cmd, "vote failed", 11) || !Q_stricmpn(cmd, "team vote failed", 16)) {
trap_S_StartLocalSound(cgs.media.voteFailed, CHAN_ANNOUNCER);
} else if (!Q_stricmpn(cmd, "vote passed", 11) || !Q_stricmpn(cmd, "team vote passed", 16)) {
trap_S_StartLocalSound(cgs.media.votePassed, CHAN_ANNOUNCER);
}
return;
}

Expand Down

0 comments on commit 0c8b0fa

Please sign in to comment.