diff --git a/config/defaults.cfg b/config/defaults.cfg index 2dd8765e..ecd1270f 100644 --- a/config/defaults.cfg +++ b/config/defaults.cfg @@ -10,7 +10,6 @@ skin_rvsf (rnd 6) setfont default // Choose your font gfxqualityalias = 3 // Default GFX is medium. -soundqualityalias = 3 // Default sound is best. menuBotGameLength = 15 diff --git a/config/menus_settings.cfg b/config/menus_settings.cfg index 4f00359e..2a4b94c1 100644 --- a/config/menus_settings.cfg +++ b/config/menus_settings.cfg @@ -57,7 +57,7 @@ menuitemcheckbox [Fullscreen: ] "$fullscreen" [ fullscreen $arg1 ] menuitemtextinput [Mouse sensitivity: ] "$sensitivity" [ sensitivity $arg1 ] menuitemcheckbox [Reduced violence mode: ] "$poniesmodeon" [ reducedviolencemode $arg1 ] menuitemslider [Graphics detail: ] 1 6 "$gfxqualityalias" 1 [Horrible Low Medium Good High "INSANE! (May perform slowly on older gfx)"] [ new_gfx_quality $arg1 ] -menuitemslider [Sound detail: ] 1 3 "$soundqualityalias" 1 [Low Medium High] [ new_sound_quality $arg1 ] +menuitemslider [Sound detail: ] 1 3 "$__soundquality" 1 [Low Medium High] [ __set_sound_quality $arg1 ] menuitemslider [Field of view: ] 75 120 "$fov" 2 [] [ fov $arg1 ] menuitem [] -1 menuitem "\f0\t\t\t [ OK; View FAQ ]" [ closecurmenu; resetgl; load_faq ; showmenu faq ] @@ -214,28 +214,20 @@ const new_gfx_quality [ ] ] -const new_sound_quality [ - if (= $arg1 3) [ // high sound (DEFAULT) - soundqualityalias = 3 - maxsoundsatonce (getvarrange default maxsoundsatonce) - footsteps 1 - bulletairsound 1 - bulletbouncesound 1 - ] [ - if (= $arg1 2) [ // medium - soundqualityalias = 2 - maxsoundsatonce (div (getvarrange default maxsoundsatonce) 2) - footsteps 1 - bulletairsound 0 - bulletbouncesound 1 - ] [ // low - soundqualityalias = 1 - maxsoundsatonce (div (getvarrange default maxsoundsatonce) 4) - footsteps 0 - bulletairsound 0 - bulletbouncesound 0 +const __set_sound_quality [ + looplist [ + 3 (getvarrange default maxsoundsatonce) 1 1 1 + 2 (div (getvarrange default maxsoundsatonce) 2) 1 0 1 + 1 (div (getvarrange default maxsoundsatonce) 4) 0 0 0 + ] [ idx maxsounds foots bullair bullbounce ] [ + if (= $arg1 $idx) [ + __soundquality = $idx + maxsoundsatonce $maxsounds + footsteps $foots + bulletairsound $bullair + bulletbouncesound $bullbounce + ] ] - ] ] newmenu [Reset settings] @@ -526,7 +518,7 @@ const reducedviolencemode [ poniesmodeon = (! $x) blood $x gib $x - looplist "26 27 28 29 30 31 32 33 48" i [ mutesound $i $x ] // (Un-) Mute pain sounds: 26 to 33 and 48 + looplist (enumsounds PAIN) [i d] [ mutesound $i $x ] // (Un-) Mute pain sounds: 26 to 33 and 48 echo "\f2OMG! \f8PW\f1NI\f3ES\f5! mode" (if $x [result "has been disabled."] [result "enabled - Violent game content has now been reduced."]) pop x ] @@ -588,11 +580,13 @@ menuitemslider [ Spectator max-roll: ] 0 (getvarrange max maxrollremote) "$m menuitem [] -1 menuitem [Customize your scoreboard...] [ showmenu [Customize your scoreboard] ] +alias __soundquality 3 + newmenu sound menuitemslider [Sound volume: ] 0 255 "$soundvol" 16 [] [ soundvol $arg1 ] menuitemslider [Music volume: ] 0 255 "$musicvol" 16 [] [ musicvol $arg1 ] -menuitemslider [Sound detail: ] 1 3 "($soundqualityalias)" 1 [Low Medium High] [ new_sound_quality $arg1 ] +menuitemslider [Sound detail: ] 1 3 "($__soundquality)" 1 [Low Medium High] [ __set_sound_quality $arg1 ] menuitem [] -1 menuitem [Mute/Un-mute specific sounds...] [ showmenu [Mute specific sounds] ] menuitem [] -1 @@ -605,8 +599,6 @@ menuitemcheckbox [ Disable own footsteps: ] "(= $localfootsteps)" [ menuitemcheckbox [ Bullet hit: ] "$bulletbouncesound" [ bulletbouncesound $arg1 ] menuitemcheckbox [ Bullet near-miss: ] "$bulletairsound" [ bulletairsound $arg1 ] -const muteitem [ menuitemcheckbox (concatword $arg1 [: ]) (concat ! "(soundmuted" $arg2 ")") (concat mutesound $arg2 "$arg1") ] - newmenu [Mute specific sounds] menuitem [Weapon sounds] [ showmenu [Mute weapon sounds] ] @@ -619,127 +611,18 @@ menuitem [Other sounds] [ showmenu [Mute other sounds] ] menuitem [] -1 menuitem [Un-mute all sounds...] [ unmuteallsounds ] -newmenu [Mute weapon sounds] - -muteitem [Knife] 7 -muteitem [Pistol] 8 -muteitem [Pistol reloading] 9 -muteitem [Carbine] 10 -muteitem [Carbine reloading] 11 -muteitem [Shotgun] 12 -muteitem [Shotgun reloading] 13 -muteitem [Submachine gun] 14 -muteitem [Submachine gun reloading] 15 -muteitem [Sniper] 16 -muteitem [Sniper reloading] 17 -muteitem [Assault rifle] 18 -muteitem [Assault rifle reloading] 19 -muteitem [Grenade pull] 41 -muteitem [Grenade throw] 42 -muteitem [Grenade bounce 1] 43 -muteitem [Grenade bounce 2] 44 -muteitem [Akimbo reload] 45 -muteitem [Change weapon] 46 -muteitem [Empty clip] 24 - -newmenu [Mute pickup sounds] - -muteitem [Ammo pickup] 20 -muteitem [Health pickup] 21 -muteitem [Armour pickup] 22 -muteitem [Akimbo pickup] 23 -muteitem [Akimbo finished] 25 -muteitem [Helmet pickup] 99 - -newmenu [Mute pain/death sounds] - -muteitem [Pain 1] 26 -muteitem [Pain 2] 27 -muteitem [Pain 3] 28 -muteitem [Pain 4] 29 -muteitem [Pain 5] 30 -muteitem [Pain 6] 31 -muteitem [Die 1] 32 -muteitem [Die 2] 33 -muteitem [Gib sounds] 48 -muteitem [Tinnitus] 62 -muteitem [Heartbeat] 100 - -newmenu [Mute movement sounds] - -muteitem [Footsteps] 53 -muteitem [Crouch] 54 -muteitem [Water footsteps] 55 -muteitem [Water crouching] 56 -muteitem [Crouch-in] 57 -muteitem [Crouch-out] 58 -muteitem [Jump] 0 -muteitem [Soft landing] 1 -muteitem [Hard landing] 2 -muteitem [Splash 1] 35 -muteitem [Splash 2] 36 -muteitem [Underwater] 61 - -newmenu [Mute bullet/explosion sounds] - -muteitem [Ricochet air 1] 3 -muteitem [Ricochet air 2] 4 -muteitem [Ricochet hit] 5 -muteitem [Bullet (water impact)] 6 -muteitem [Grenade explosion] 34 -muteitem [Hit sound] 47 - -newmenu [Mute other sounds] - -muteitem [Flag drop] 37 -muteitem [Flag pickup] 38 -muteitem [Flag return] 39 -muteitem [Flag score] 40 -muteitem [Headshot] 49 -muteitem [Call vote] 50 -muteitem [Pass vote] 51 -muteitem [Fail vote] 52 -muteitem [Menu select] 59 -muteitem [Menu enter] 60 - -newmenu [Mute voice-coms] - -muteitem [Affirmative] 63 -muteitem [All-right sir] 64 -muteitem [Come on, move] 65 -muteitem [Coming in with the flag] 66 -muteitem [Cover me] 67 -muteitem [Defend the flag] 68 -muteitem [Enemy down] 69 -muteitem [Go get 'em boys!] 70 -muteitem [Good job team] 71 -muteitem [I got one!] 72 -muteitem [I made contact] 73 -muteitem [I'm attacking] 74 -muteitem [I'm on defense] 75 -muteitem [I'm on your team] 76 -muteitem [Negative] 77 -muteitem [No can do] 78 -muteitem [Recover the flag] 79 -muteitem [Sorry] 80 -muteitem [Spread out] 81 -muteitem [Stay here] 82 -muteitem [Stay together] 83 -muteitem [There's no way sir] 84 -muteitem [We did it!] 85 -muteitem [Yes] 86 -muteitem [Under way] 87 -muteitem [On the move] 88 -muteitem [Got your back] 89 -muteitem [Got you covered] 90 -muteitem [In position] 91 -muteitem [In position now] 92 -muteitem [Report in!] 93 -muteitem [Nice shot] 94 -muteitem [Thanks] 95 -muteitem [Thanks, man] 96 -muteitem [Awesome (1)] 97 -muteitem [Awesome (2)] 98 +looplist [ + "Mute weapon sounds" WEAPON + "Mute pickup sounds" PICKUP + "Mute pain/death sounds" "PAIN OWNPAIN" + "Mute movement sounds" MOVEMENT + "Mute bullet/explosion sounds" BULLET + "Mute other sounds" OTHER + "Mute voice-coms" VOICECOM + ] [ mt sc ] [ + newmenu $mt + looplist (enumsounds $sc) [ idx desc ] [ menuitemcheckbox (concatword $desc ": ") (concat ! "(soundmuted" $idx ")") (concat mutesound $idx "$arg1") ] +] newmenu [Kill Messages] menuitem "\f9Frag messages: " -1 diff --git a/config/scripts.cfg b/config/scripts.cfg index 0d1e4ed3..e8499d4f 100644 --- a/config/scripts.cfg +++ b/config/scripts.cfg @@ -82,6 +82,7 @@ looplist [ addpunct punctuations // the command addpunct actually wants the punctuation name as second argument, but we can't do that. sry. loadcrosshair crosshairnames edittexturestack texturestacktypes + enumsounds soundcategories ] [ cmd options ] [ listcomplete $cmd (listoptions $options) ] listcomplete edittagclip "none plclip clip" diff --git a/config/sounds.cfg b/config/sounds.cfg index 4b9cb95f..06c7ba62 100644 --- a/config/sounds.cfg +++ b/config/sounds.cfg @@ -1,118 +1,5 @@ // AssaultCube game sounds -// This does not include ambient sounds, which are map-specific... -// Files listed in here can be either *.wav or *.ogg -// Filename extensions do not need to be listed. - -// Whenever adding new sounds, or changing the positions of previously existing -// sounds in this config file, please update the "Mute/Un-mute specific sounds" -// menu inside the "menus_settings.cfg" file. - -registersound "player/jump" 80 // 0 - S_JUMP -registersound "player/step" 90 0 24 // 1 - S_SOFTLAND -registersound "player/land" 95 0 24 // 2 - S_HARDLAND -registersound "weapon/ric1" // 3 - S_BULLETAIR1 -registersound "weapon/ric2" // 4 - S_BULLETAIR2 -registersound "weapon/ric3" // 5 - S_BULLETHIT -registersound "weapon/waterimpact" // 6 - S_BULLETWATERHIT -registersound "weapon/knife" // 7 - S_KNIFE -registersound "weapon/usp" // 8 - S_PISTOL -registersound "weapon/pistol_reload" // 9 - S_RPISTOL -registersound "weapon/carbine" // 10 - S_CARBINE -registersound "weapon/carbine_reload" // 11 - S_RCARBINE // temporary -registersound "weapon/shotgun" // 12 - S_SHOTGUN -registersound "weapon/shotgun_reload" // 13 - S_RSHOTGUN -registersound "weapon/sub" // 14 - S_SUBGUN -registersound "weapon/sub_reload" // 15 - S_RSUBGUN -registersound "weapon/sniper" // 16 - S_SNIPER -registersound "weapon/sniper_reload" // 17 - S_RSNIPER -registersound "weapon/auto" // 18 - S_ASSAULT -registersound "weapon/auto_reload" // 19 - S_RASSAULT -registersound "misc/pickup_ammo_clip" // 20 - S_ITEMAMMO -registersound "misc/pickup_health" // 21 - S_ITEMHEALTH -registersound "misc/pickup_armour" // 22 - S_ITEMARMOUR -registersound "misc/tick9" // 23 - S_ITEMPUP -registersound "weapon/clip_empty" // 24 - S_NOAMMO -registersound "misc/tick11" // 25 - S_PUPOUT -registersound "player/pain1" // 26 - S_PAIN1 -registersound "player/pain2" // 27 - S_PAIN2 -registersound "player/pain3" // 28 - S_PAIN3 -registersound "player/pain4" // 29 - S_PAIN4 -registersound "player/pain5" // 30 - S_PAIN5 -registersound "player/pain6" // 31 - S_PAIN6 -registersound "player/die1" // 32 - S_DIE1 -registersound "player/die2" // 33 - S_DIE2 -registersound "weapon/grenade_exp" // 34 - S_FEXPLODE -registersound "player/splash1" // 35 - S_SPLASH1 -registersound "player/splash2" // 36 - S_SPLASH2 -registersound "ctf/flagdrop" // 37 - S_FLAGDROP -registersound "ctf/flagpickup" // 38 - S_FLAGPICKUP -registersound "ctf/flagreturn" // 39 - S_FLAGRETURN -registersound "ctf/flagscore" // 40 - S_FLAGSCORE -registersound "weapon/grenade_pull" // 41 - S_GRENADEPULL -registersound "weapon/grenade_throw" // 42 - S_GRENADETHROW -registersound "weapon/grenade_bounce1" // 43 - S_GRENADEBOUNCE1 -registersound "weapon/grenade_bounce2" // 44 - S_GRENADEBOUNCE2 -registersound "weapon/pistol_akreload" // 45 - S_RAKIMBO -registersound "misc/change_gun" // 46 - S_GUNCHANGE -registersound "misc/impact_t" // 47 - S_HITSOUND -registersound "player/gib" // 48 - S_GIB -registersound "misc/headshot" 10 // 49 - S_HEADSHOT -registersound "vote/vote_call" // 50 - S_CALLVOTE -registersound "vote/vote_pass" // 51 - S_VOTEPASS -registersound "vote/vote_fail" // 52 - S_VOTEFAIL -registersound "player/footsteps" 40 1 20 // 53 - S_FOOTSTEPS -registersound "player/crouch" 40 1 10 // 54 - S_FOOTSTEPSCROUCH -registersound "player/watersteps" 40 1 20 // 55 - S_WATERFOOTSTEPS -registersound "player/watercrouch" 40 1 10// 56 - S_WATERFOOTSTEPSCROUCH -registersound "player/crouch_in" 85 0 14 // 57 - S_CROUCH -registersound "player/crouch_out" 75 0 14 // 58 - S_UNCROUCH -registersound "misc/menu_click1" // 59 - S_MENUSELECT -registersound "misc/menu_click2" // 60 - S_MENUENTER -registersound "player/underwater" // 61 - S_UNDERWATER -registersound "misc/tinnitus" 2 // 62 - S_TINNITUS - - // In-game voice coms -registersound "voicecom/affirmative" // 63 -registersound "voicecom/allrightsir" // 64 -registersound "voicecom/comeonmove" // 65 -registersound "voicecom/cominginwiththeflag" // 66 -registersound "voicecom/coverme" // 67 -registersound "voicecom/defendtheflag" // 68 -registersound "voicecom/enemydown" // 69 -registersound "voicecom/gogetemboys" // 70 -registersound "voicecom/goodjobteam" // 71 -registersound "voicecom/igotone" // 72 -registersound "voicecom/imadecontact" // 73 -registersound "voicecom/imattacking" // 74 -registersound "voicecom/imondefense" // 75 -registersound "voicecom/imonyourteamman" // 76 -registersound "voicecom/negative" // 77 -registersound "voicecom/nocando" // 78 -registersound "voicecom/recovertheflag" // 79 -registersound "voicecom/sorry" // 80 -registersound "voicecom/spreadout" // 81 -registersound "voicecom/stayhere" // 82 -registersound "voicecom/staytogether" // 83 -registersound "voicecom/theresnowaysir" // 84 -registersound "voicecom/wedidit" // 85 -registersound "voicecom/yes" // 86 -registersound "voicecom/onthemove_1" // 87 -registersound "voicecom/onthemove_2" // 88 -registersound "voicecom/igotyourback" // 89 -registersound "voicecom/igotyoucovered" // 90 -registersound "voicecom/inposition_1" // 91 -registersound "voicecom/inposition_2" // 92 -registersound "voicecom/reportin" // 93 -registersound "voicecom/niceshot" // 94 : public -registersound "voicecom/thanks_1" // 95 : public -registersound "voicecom/thanks_2" // 96 : public -registersound "voicecom/awesome_1" // 97 : public -registersound "voicecom/awesome_2" // 98 : public -registersound "misc/pickup_helmet" // 99 - S_ITEMHELMET -registersound "player/heartbeat" // 100 - S_HEARTBEAT -registersound "ktf/flagscore" // 101 - S_KTFSCORE - // Music registermusic "pingpong/Ping_Pong_-_Kamikadze" // M_FLAGGRAB registermusic "pingpong/Ping_Pong_-_Headshot" // M_LASTMINUTE1 diff --git a/source/src/audiomanager.cpp b/source/src/audiomanager.cpp index 579288ec..fdc2298b 100644 --- a/source/src/audiomanager.cpp +++ b/source/src/audiomanager.cpp @@ -201,7 +201,7 @@ void audiomanager::registermusic(char *name) musics.add(newstring(name)); } -int audiomanager::findsound(char *name, int vol, vector &sounds) +int audiomanager::findsound(const char *name, int vol, vector &sounds) { loopv(sounds) { @@ -210,7 +210,7 @@ int audiomanager::findsound(char *name, int vol, vector &sounds) return -1; } -int audiomanager::addsound(char *name, int vol, int maxuses, bool loop, vector &sounds, bool load, int audibleradius) +int audiomanager::addsound(const char *name, int vol, int maxuses, bool loop, vector &sounds, bool load, int audibleradius) { if(nosound) return -1; if(!soundvol) return -1; @@ -429,9 +429,9 @@ void voicecom(char *sound, char *text) { defformatstring(soundpath)("voicecom/%s", sound); int s = audiomgr.findsound(soundpath, 0, gamesounds); - if(!valid_voicecom(s)) return; + if(!gamesound_isvoicecom(s)) return; if(voicecomsounds>0) audiomgr.playsound(s, SP_HIGH); - if(valid_voicecom_public(s)) // public + if(gamesound_ispublicvoicecom(s)) // public { addmsg(SV_VOICECOM, "ri", s); toserver(text); @@ -819,6 +819,34 @@ COMMANDF(registersound, "siii", (char *name, int *vol, int *loop, int *audiblera intret(audiomgr.addsound(name, *vol, -1, *loop != 0, gamesounds, true, *audibleradius)); }); +void registerdefaultsounds() +{ + loopi(S_NULL) + { + ASSERT(soundcfg[i].key == i); + audiomgr.addsound(soundcfg[i].name, soundcfg[i].vol, -1, soundcfg[i].loop != 0, gamesounds, true, soundcfg[i].audibleradius); + } +} + +const char *soundcategories[SC_NUM + 1] = { "PAIN", "OWNPAIN", "WEAPON", "PICKUP", "MOVEMENT", "BULLET", "OTHER", "VOICECOM", "TEAM", "PUBLIC", "FFA", "FLAGONLY", "" }; + +void enumsounds(char *what) +{ + vector w; + explodelist(what, w); + int flags = 0, nflags = 0; + loopv(w) + { + if(w[i][0] == '!') nflags |= 1 << getlistindex(w[i] + 1, soundcategories, false, 0); + else flags |= 1 << getlistindex(w[i], soundcategories, false, 0); + delstring(w[i]); + } + vector res; + loopi(S_NULL) if((soundcfg[i].flags & flags) && !(soundcfg[i].flags & nflags)) cvecprintf(res, "%d %s\n", i, escapestring(soundcfg[i].desc)); + resultcharvector(res, -1); +} +COMMAND(enumsounds, "s"); + const char *mapsoundbasepath = "packages/audio/", *mapsoundfinalpath = "ambience/"; const int mapsoundbasepath_n = strlen(mapsoundbasepath), mapsoundfinalpath_n = strlen(mapsoundfinalpath); diff --git a/source/src/clientgame.cpp b/source/src/clientgame.cpp index 5e597023..1da9651d 100644 --- a/source/src/clientgame.cpp +++ b/source/src/clientgame.cpp @@ -926,7 +926,7 @@ void dokill(playerent *pl, playerent *act, bool gib, int gun) deathstate(pl); pl->deaths++; - audiomgr.playsound(S_DIE1+rnd(2), pl); + audiomgr.playsound(rnd(2) ? S_DIE1 : S_DIE2, pl); } void pstat_weap(int *cn) diff --git a/source/src/command.cpp b/source/src/command.cpp index 9b30ee7c..f23e80a0 100644 --- a/source/src/command.cpp +++ b/source/src/command.cpp @@ -1794,9 +1794,9 @@ COMMANDF(getmode, "i", (int *acr) { result(modestr(gamemode, *acr != 0)); }); void listoptions(char *s) { - extern const char *menufilesortorders[], *texturestacktypes[], *soundprioritynames[]; - const char *optionnames[] = { "entities", "ents", "weapons", "teamnames", "teamnames-abbrv", "punctuations", "crosshairnames", "menufilesortorders", "texturestacktypes", "cubetypes", "soundpriorities", "" }; - const char **optionlists[] = { optionnames, entnames + 1, entnames + 1, gunnames, teamnames, teamnames_s, punctnames, crosshairnames, menufilesortorders, texturestacktypes, cubetypenames, soundprioritynames }; + extern const char *menufilesortorders[], *texturestacktypes[], *soundprioritynames[], *soundcategories[]; + const char *optionnames[] = { "entities", "ents", "weapons", "teamnames", "teamnames-abbrv", "punctuations", "crosshairnames", "menufilesortorders", "texturestacktypes", "cubetypes", "soundpriorities", "soundcategories", "" }; + const char **optionlists[] = { optionnames, entnames + 1, entnames + 1, gunnames, teamnames, teamnames_s, punctnames, crosshairnames, menufilesortorders, texturestacktypes, cubetypenames, soundprioritynames, soundcategories }; const char **listp = optionlists[getlistindex(s, optionnames, true, -1) + 1]; commandret = conc(listp, -1, true); } diff --git a/source/src/main.cpp b/source/src/main.cpp index 7e34f024..88ce868b 100644 --- a/source/src/main.cpp +++ b/source/src/main.cpp @@ -1187,6 +1187,7 @@ int main(int argc, char **argv) exec("config/menus.cfg"); exec("config/scripts.cfg"); exec("config/prefabs.cfg"); + registerdefaultsounds(); exec("config/sounds.cfg"); exec("config/securemaps.cfg"); exec("config/admin.cfg"); diff --git a/source/src/openal.cpp b/source/src/openal.cpp index a466d06d..b309d553 100644 --- a/source/src/openal.cpp +++ b/source/src/openal.cpp @@ -363,7 +363,7 @@ void sbuffer::unload() bufferhashtable::~bufferhashtable() {} -sbuffer *bufferhashtable::find(char *name) +sbuffer *bufferhashtable::find(const char *name) { sbuffer *b = access(name); if(!b) diff --git a/source/src/renderparticles.cpp b/source/src/renderparticles.cpp index 845b0436..85fdbd23 100644 --- a/source/src/renderparticles.cpp +++ b/source/src/renderparticles.cpp @@ -689,6 +689,6 @@ void addshotline(dynent *pl, const vec &from, const vec &to) soundpos.mul(fd/(fd+td)*dist); soundpos.add(from); if(!bulletairsound || soundpos.dist(camera1->o) > bulletairsoundrad) return; // outside player radius - audiomgr.playsound(S_BULLETAIR1 + rnd(2), &soundpos, SP_LOW); + audiomgr.playsound(rnd(2) ? S_BULLETAIR1 : S_BULLETAIR2, &soundpos, SP_LOW); } diff --git a/source/src/server.cpp b/source/src/server.cpp index c2be486b..9f1b56aa 100644 --- a/source/src/server.cpp +++ b/source/src/server.cpp @@ -3030,7 +3030,7 @@ void process(ENetPacket *packet, int sender, int chan) /* spam filter */ if ( servmillis > cl->mute ) // client is not muted { - if( s < S_AFFIRMATIVE || s >= S_NULL ) cl->mute = servmillis + 10000; // vc is invalid + if(!gamesound_isvoicecom(s)) cl->mute = servmillis + 10000; // vc is invalid else if ( cl->lastvc + 4000 < servmillis ) { if ( cl->spam > 0 ) cl->spam -= (servmillis - cl->lastvc) / 4000; } // no vc in the last 4 seconds else cl->spam++; // the guy is spamming if ( cl->spam < 0 ) cl->spam = 0; diff --git a/source/src/server.h b/source/src/server.h index 350b7b66..da0fec4b 100644 --- a/source/src/server.h +++ b/source/src/server.h @@ -547,3 +547,111 @@ const char *teamnames_s[] = {"CLA", "RVSF", "CSPC", "RSPC", "SPEC", "", "void"}; // for both client and server // default messages are hardcoded ! char killmessages[2][NUMGUNS][MAXKILLMSGLEN] = {{ "", "busted", "picked off", "peppered", "sprayed", "punctured", "shredded", "busted", "", "busted" }, { "slashed", "", "", "splattered", "", "headshot", "", "", "gibbed", "" }}; + +#define C(x) (1<<(SC_##x)) +soundcfgitem soundcfg[S_NULL] = +{ // name desc vol, loop, rad, key, flags + { "player/jump", "Jump", 80, 0, 0, S_JUMP, C(MOVEMENT) }, // 0 + { "player/step", "Soft landing", 90, 0, 24, S_SOFTLAND, C(MOVEMENT) }, // 1 + { "player/land", "Hard landing", 95, 0, 24, S_HARDLAND, C(MOVEMENT) }, // 2 + { "weapon/ric1", "Ricochet air 1", 0, 0, 0, S_BULLETAIR1, C(BULLET) }, // 3 + { "weapon/ric2", "Ricochet air 2", 0, 0, 0, S_BULLETAIR2, C(BULLET) }, // 4 + { "weapon/ric3", "Ricochet hit", 0, 0, 0, S_BULLETHIT, C(BULLET) }, // 5 + { "weapon/waterimpact", "Bullet (water impact)", 0, 0, 0, S_BULLETWATERHIT, C(BULLET) }, // 6 + { "weapon/knife", "Knife", 0, 0, 0, S_KNIFE, C(WEAPON) }, // 7 + { "weapon/usp", "Pistol", 0, 0, 0, S_PISTOL, C(WEAPON) }, // 8 + { "weapon/pistol_reload", "Pistol reloading", 0, 0, 0, S_RPISTOL, C(WEAPON) }, // 9 + { "weapon/carbine", "Carbine", 0, 0, 0, S_CARBINE, C(WEAPON) }, // 10 + { "weapon/carbine_reload", "Carbine reloading", 0, 0, 0, S_RCARBINE, C(WEAPON) }, // 11 + { "weapon/shotgun", "Shotgun", 0, 0, 0, S_SHOTGUN, C(WEAPON) }, // 12 + { "weapon/shotgun_reload", "Shotgun reloading", 0, 0, 0, S_RSHOTGUN, C(WEAPON) }, // 13 + { "weapon/sub", "Submachine gun", 0, 0, 0, S_SUBGUN, C(WEAPON) }, // 14 + { "weapon/sub_reload", "Submachine gun reloading", 0, 0, 0, S_RSUBGUN, C(WEAPON) }, // 15 + { "weapon/sniper", "Sniper", 0, 0, 0, S_SNIPER, C(WEAPON) }, // 16 + { "weapon/sniper_reload", "Sniper reloading", 0, 0, 0, S_RSNIPER, C(WEAPON) }, // 17 + { "weapon/auto", "Assault rifle", 0, 0, 0, S_ASSAULT, C(WEAPON) }, // 18 + { "weapon/auto_reload", "Assault rifle reloading", 0, 0, 0, S_RASSAULT, C(WEAPON) }, // 19 + { "misc/pickup_ammo_clip", "Ammo pickup", 0, 0, 0, S_ITEMAMMO, C(PICKUP) }, // 20 + { "misc/pickup_health", "Health pickup", 0, 0, 0, S_ITEMHEALTH, C(PICKUP) }, // 21 + { "misc/pickup_armour", "Armour pickup", 0, 0, 0, S_ITEMARMOUR, C(PICKUP) }, // 22 + { "misc/tick9", "Akimbo pickup", 0, 0, 0, S_ITEMAKIMBO, C(PICKUP) }, // 23 + { "weapon/clip_empty", "Empty clip", 0, 0, 0, S_NOAMMO, C(WEAPON) }, // 24 + { "misc/tick11", "Akimbo finished", 0, 0, 0, S_AKIMBOOUT, C(PICKUP) }, // 25 + { "player/pain1", "Pain 1", 0, 0, 0, S_PAIN1, C(PAIN) }, // 26 + { "player/pain2", "Pain 2", 0, 0, 0, S_PAIN2, C(PAIN) }, // 27 + { "player/pain3", "Pain 3", 0, 0, 0, S_PAIN3, C(PAIN) }, // 28 + { "player/pain4", "Pain 4", 0, 0, 0, S_PAIN4, C(PAIN) }, // 29 + { "player/pain5", "Pain 5", 0, 0, 0, S_PAIN5, C(PAIN) }, // 30 + { "player/pain6", "Pain 6", 0, 0, 0, S_PAIN6, C(PAIN) }, // 31 + { "player/die1", "Die 1", 0, 0, 0, S_DIE1, C(PAIN) }, // 32 + { "player/die2", "Die 2", 0, 0, 0, S_DIE2, C(PAIN) }, // 33 + { "weapon/grenade_exp", "Grenade explosion", 0, 0, 0, S_FEXPLODE, C(BULLET) }, // 34 + { "player/splash1", "Splash 1", 0, 0, 0, S_SPLASH1, C(MOVEMENT) }, // 35 + { "player/splash2", "Splash 2", 0, 0, 0, S_SPLASH2, C(MOVEMENT) }, // 36 + { "ctf/flagdrop", "Flag drop", 0, 0, 0, S_FLAGDROP, C(OTHER) }, // 37 + { "ctf/flagpickup", "Flag pickup", 0, 0, 0, S_FLAGPICKUP, C(OTHER) }, // 38 + { "ctf/flagreturn", "Flag return", 0, 0, 0, S_FLAGRETURN, C(OTHER) }, // 39 + { "ctf/flagscore", "Flag score", 0, 0, 0, S_FLAGSCORE, C(OTHER) }, // 40 + { "weapon/grenade_pull", "Grenade pull", 0, 0, 0, S_GRENADEPULL, C(WEAPON) }, // 41 + { "weapon/grenade_throw", "Grenade throw", 0, 0, 0, S_GRENADETHROW, C(WEAPON) }, // 42 + { "weapon/grenade_bounce1", "Grenade bounce 1", 0, 0, 0, S_GRENADEBOUNCE1, C(WEAPON) }, // 43 + { "weapon/grenade_bounce2", "Grenade bounce 2", 0, 0, 0, S_GRENADEBOUNCE2, C(WEAPON) }, // 44 + { "weapon/pistol_akreload", "Akimbo reload", 0, 0, 0, S_RAKIMBO, C(WEAPON) }, // 45 + { "misc/change_gun", "Change weapon", 0, 0, 0, S_GUNCHANGE, C(WEAPON) }, // 46 + { "misc/impact_t", "Hit sound", 0, 0, 0, S_HITSOUND, C(BULLET) }, // 47 + { "player/gib", "Gib sounds", 0, 0, 0, S_GIB, C(PAIN) }, // 48 + { "misc/headshot", "Headshot", 10, 0, 0, S_HEADSHOT, C(OTHER) }, // 49 + { "vote/vote_call", "Call vote", 0, 0, 0, S_CALLVOTE, C(OTHER) }, // 50 + { "vote/vote_pass", "Pass vote", 0, 0, 0, S_VOTEPASS, C(OTHER) }, // 51 + { "vote/vote_fail", "Fail vote", 0, 0, 0, S_VOTEFAIL, C(OTHER) }, // 52 + { "player/footsteps", "Footsteps", 40, 1, 20, S_FOOTSTEPS, C(MOVEMENT) }, // 53 + { "player/crouch", "Crouch", 40, 1, 10, S_FOOTSTEPSCROUCH, C(MOVEMENT) }, // 54 + { "player/watersteps", "Water footsteps", 40, 1, 20, S_WATERFOOTSTEPS, C(MOVEMENT) }, // 55 + { "player/watercrouch", "Water crouching", 40, 1, 10, S_WATERFOOTSTEPSCROUCH, C(MOVEMENT) }, // 56 + { "player/crouch_in", "Crouch-in", 85, 0, 14, S_CROUCH, C(MOVEMENT) }, // 57 + { "player/crouch_out", "Crouch-out", 75, 0, 14, S_UNCROUCH, C(MOVEMENT) }, // 58 + { "misc/menu_click1", "Menu select", 0, 0, 0, S_MENUSELECT, C(OTHER) }, // 59 + { "misc/menu_click2", "Menu enter", 0, 0, 0, S_MENUENTER, C(OTHER) }, // 60 + { "player/underwater", "Underwater", 0, 0, 0, S_UNDERWATER, C(MOVEMENT) }, // 61 + { "misc/tinnitus", "Tinnitus", 2, 0, 0, S_TINNITUS, C(OWNPAIN) }, // 62 + { "voicecom/affirmative", "Affirmative", 0, 0, 0, S_AFFIRMATIVE, C(VOICECOM)|C(TEAM) }, // 63 + { "voicecom/allrightsir", "All-right sir", 0, 0, 0, S_ALLRIGHTSIR, C(VOICECOM)|C(TEAM) }, // 64 + { "voicecom/comeonmove", "Come on, move", 0, 0, 0, S_COMEONMOVE, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 65 + { "voicecom/cominginwiththeflag", "Coming in with the flag", 0,0,0, S_COMINGINWITHTHEFLAG, C(VOICECOM)|C(TEAM) |C(FLAGONLY) }, // 66 + { "voicecom/coverme", "Cover me", 0, 0, 0, S_COVERME, C(VOICECOM)|C(TEAM) }, // 67 + { "voicecom/defendtheflag", "Defend the flag", 0, 0, 0, S_DEFENDTHEFLAG, C(VOICECOM)|C(TEAM) |C(FLAGONLY) }, // 68 + { "voicecom/enemydown", "Enemy down", 0, 0, 0, S_ENEMYDOWN, C(VOICECOM)|C(TEAM)|C(PUBLIC) }, // 69 + { "voicecom/gogetemboys", "Go get 'em boys!", 0, 0, 0, S_GOGETEMBOYS, C(VOICECOM)|C(TEAM) }, // 70 + { "voicecom/goodjobteam", "Good job team", 0, 0, 0, S_GOODJOBTEAM, C(VOICECOM)|C(TEAM) }, // 71 + { "voicecom/igotone", "I got one!", 0, 0, 0, S_IGOTONE, C(VOICECOM)|C(TEAM)|C(PUBLIC) }, // 72 + { "voicecom/imadecontact", "I made contact", 0, 0, 0, S_IMADECONTACT, C(VOICECOM)|C(TEAM) }, // 73 + { "voicecom/imattacking", "I'm attacking", 0, 0, 0, S_IMATTACKING, C(VOICECOM)|C(TEAM) }, // 74 + { "voicecom/imondefense", "I'm on defense", 0, 0, 0, S_IMONDEFENSE, C(VOICECOM)|C(TEAM) }, // 75 + { "voicecom/imonyourteamman", "I'm on your team", 0, 0, 0, S_IMONYOURTEAMMAN, C(VOICECOM)|C(TEAM) }, // 76 + { "voicecom/negative", "Negative", 0, 0, 0, S_NEGATIVE, C(VOICECOM)|C(TEAM) }, // 77 + { "voicecom/nocando", "No can do", 0, 0, 0, S_NOCANDO, C(VOICECOM)|C(TEAM) }, // 78 + { "voicecom/recovertheflag", "Recover the flag", 0, 0, 0, S_RECOVERTHEFLAG, C(VOICECOM)|C(TEAM) |C(FLAGONLY) }, // 79 + { "voicecom/sorry", "Sorry", 0, 0, 0, S_SORRY, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 80 + { "voicecom/spreadout", "Spread out", 0, 0, 0, S_SPREADOUT, C(VOICECOM)|C(TEAM) }, // 81 + { "voicecom/stayhere", "Stay here", 0, 0, 0, S_STAYHERE, C(VOICECOM)|C(TEAM) }, // 82 + { "voicecom/staytogether", "Stay together", 0, 0, 0, S_STAYTOGETHER, C(VOICECOM)|C(TEAM) }, // 83 + { "voicecom/theresnowaysir", "There's no way sir", 0, 0, 0, S_THERESNOWAYSIR, C(VOICECOM)|C(TEAM) }, // 84 + { "voicecom/wedidit", "We did it!", 0, 0, 0, S_WEDIDIT, C(VOICECOM)|C(TEAM) }, // 85 + { "voicecom/yes", "Yes", 0, 0, 0, S_YES, C(VOICECOM)|C(TEAM) }, // 86 + { "voicecom/onthemove_1", "Under way", 0, 0, 0, S_ONTHEMOVE1, C(VOICECOM)|C(TEAM) }, // 87 + { "voicecom/onthemove_2", "On the move", 0, 0, 0, S_ONTHEMOVE2, C(VOICECOM)|C(TEAM) }, // 88 + { "voicecom/igotyourback", "Got your back", 0, 0, 0, S_GOTURBACK, C(VOICECOM)|C(TEAM) }, // 89 + { "voicecom/igotyoucovered", "Got you covered", 0, 0, 0, S_GOTUCOVERED, C(VOICECOM)|C(TEAM) }, // 90 + { "voicecom/inposition_1", "In position", 0, 0, 0, S_INPOSITION1, C(VOICECOM)|C(TEAM) }, // 91 + { "voicecom/inposition_2", "In position now", 0, 0, 0, S_INPOSITION2, C(VOICECOM)|C(TEAM) }, // 92 + { "voicecom/reportin", "Report in!", 0, 0, 0, S_REPORTIN, C(VOICECOM)|C(TEAM) }, // 93 + { "voicecom/niceshot", "Nice shot", 0, 0, 0, S_NICESHOT, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 94 + { "voicecom/thanks_1", "Thanks", 0, 0, 0, S_THANKS1, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 95 + { "voicecom/thanks_2", "Thanks, man", 0, 0, 0, S_THANKS2, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 96 + { "voicecom/awesome_1", "Awesome (1)", 0, 0, 0, S_AWESOME1, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 97 + { "voicecom/awesome_2", "Awesome (2)", 0, 0, 0, S_AWESOME2, C(VOICECOM)|C(TEAM)|C(PUBLIC)|C(FFA) }, // 98 + { "misc/pickup_helmet", "Helmet pickup", 0, 0, 0, S_ITEMHELMET, C(PICKUP) }, // 99 + { "player/heartbeat", "Heartbeat", 0, 0, 0, S_HEARTBEAT, C(OWNPAIN) }, // 100 + { "ktf/flagscore", "KTF score", 0, 0, 0, S_KTFSCORE, C(OTHER) } // 101 +}; +#undef C diff --git a/source/src/sound.h b/source/src/sound.h index 7e7e24c2..1dd6a30a 100644 --- a/source/src/sound.h +++ b/source/src/sound.h @@ -1,9 +1,7 @@ -// hardcoded sounds, defined in sounds.cfg - +// hardcoded sounds, details in server.h enum -{ // To avoid a lot of work, possible bugs and allow backward compatibility for players own custom - // cfg files, it's best not to change the listed sound order, instead, just add to it. +{ // beware: sound order is part of the game protocol S_JUMP = 0, S_SOFTLAND, S_HARDLAND, S_BULLETAIR1, S_BULLETAIR2, S_BULLETHIT, S_BULLETWATERHIT, @@ -17,7 +15,7 @@ enum S_ITEMAMMO, S_ITEMHEALTH, S_ITEMARMOUR, S_ITEMAKIMBO, S_NOAMMO, S_AKIMBOOUT, - S_PAIN1, S_PAIN2, S_PAIN3, S_PAIN4, S_PAIN5, S_PAIN6, + S_PAIN1, S_PAIN2, S_PAIN3, S_PAIN4, S_PAIN5, S_PAIN6, // S_PAIN2..S_PAIN5 are hardcoded S_PAIN1+1..S_PAIN1+4 S_DIE1, S_DIE2, S_FEXPLODE, S_SPLASH1, S_SPLASH2, @@ -27,7 +25,7 @@ enum S_HITSOUND, S_GIB, S_HEADSHOT, S_CALLVOTE, S_VOTEPASS, S_VOTEFAIL, - S_FOOTSTEPS, S_FOOTSTEPSCROUCH, S_WATERFOOTSTEPS, S_WATERFOOTSTEPSCROUCH, + S_FOOTSTEPS, S_FOOTSTEPSCROUCH, S_WATERFOOTSTEPS, S_WATERFOOTSTEPSCROUCH, // hardcoded S_FOOTSTEPS+0..S_FOOTSTEPS+3 S_CROUCH, S_UNCROUCH, S_MENUSELECT, S_MENUENTER, S_UNDERWATER, @@ -76,8 +74,20 @@ enum S_NULL }; -#define valid_voicecom(x) ((x) >= S_AFFIRMATIVE && (x) <= S_AWESOME2) // all voicecoms -#define valid_voicecom_public(x) ((x) >= S_NICESHOT && (x) <= S_AWESOME2) // voicecoms always sent to all players +enum { SC_PAIN = 0, SC_OWNPAIN, SC_WEAPON, SC_PICKUP, SC_MOVEMENT, SC_BULLET, SC_OTHER, SC_VOICECOM, SC_TEAM, SC_PUBLIC, SC_FFA, SC_FLAGONLY, SC_NUM }; // sound categories + +#define gamesound_isvalid(x) ((x) >= 0 && (x) < S_NULL) // bounds check for soundcfg[] +#define gamesound_hasflag(x, mask) (gamesound_isvalid(x) && (soundcfg[x].flags & mask) != 0) +#define gamesound_isvoicecom(x) gamesound_hasflag(x, 1 << SC_VOICECOM) // all voicecoms +#define gamesound_ispublicvoicecom(x) gamesound_hasflag(x, 1 << SC_PUBLIC) // voicecoms always sent to all players + +struct soundcfgitem { + const char *name, *desc; + uchar vol, loop, audibleradius, key; + int flags; +}; + +extern soundcfgitem soundcfg[S_NULL]; // hardcoded music @@ -171,11 +181,11 @@ public: // buffer storage -class bufferhashtable : public hashtable +class bufferhashtable : public hashtable { public: virtual ~bufferhashtable(); - virtual sbuffer *find(char *name); + virtual sbuffer *find(const char *name); }; // manages available sources, abstracts audio channels @@ -401,7 +411,7 @@ public: // configuration void setchannels(int num); void setlistenervol(int vol); - int addsound(char *name, int vol, int maxuses, bool loop, vector &sounds, bool load, int audibleradius); + int addsound(const char *name, int vol, int maxuses, bool loop, vector &sounds, bool load, int audibleradius); void registermusic(char *name); void mutesound(int n, int off); void unmuteallsounds(); @@ -429,7 +439,7 @@ public: void playsoundname(char *s, const vec *loc, int vol); void playsoundc(int n, physent *p = NULL, int priority = SP_NORMAL); void sound(int n); - int findsound(char *name, int vol, vector &sounds); + int findsound(const char *name, int vol, vector &sounds); void detachsounds(class playerent *owner); // update @@ -451,7 +461,6 @@ extern ov_callbacks oggcallbacks; extern int soundvol; extern int audiodebug; extern int voicecomsounds; - extern audiomanager audiomgr; - +extern void registerdefaultsounds(); #endif //#ifndef STANDALONE diff --git a/source/src/weapon.cpp b/source/src/weapon.cpp index 180275c4..c1b9870f 100644 --- a/source/src/weapon.cpp +++ b/source/src/weapon.cpp @@ -783,7 +783,7 @@ bool weapon::reload(bool autoreloaded) ammo -= numbullets; bool local = (player1 == owner); - audiomgr.playsound(info.reload, owner, local ? SP_HIGH : SP_NORMAL); + if(info.reload != S_NULL) audiomgr.playsound(info.reload, owner, local ? SP_HIGH : SP_NORMAL); if(local) { addmsg(SV_RELOAD, "ri2", lastmillis, owner->weaponsel->type); @@ -1013,7 +1013,7 @@ bool grenadeent::applyphysics() { return nadestate==NS_THROWN; } void grenadeent::oncollision() { - if(distsincebounce>=1.5f) audiomgr.playsound(S_GRENADEBOUNCE1+rnd(2), &o); + if(distsincebounce>=1.5f) audiomgr.playsound(rnd(2) ? S_GRENADEBOUNCE1 : S_GRENADEBOUNCE2, &o); distsincebounce = 0.0f; }