no longer denying looping sounds

this is mostly undoing e50a60fe17
and warning when delayed loads happen in quick succession

with this change:
- we no longer block legit looping sounds like the RG hum
- we only warn when there are too many loads instead of spamming for legit stuff
This commit is contained in:
myT 2022-04-11 00:40:27 +02:00
parent dbfb3c5028
commit 51863892f0
2 changed files with 21 additions and 24 deletions

View file

@ -9,7 +9,7 @@ add: r_alphaToCoverageMipBoost <0.0 to 0.5> (default: 0.125) boosts the alpha va
chg: r_lightmap 1 now handles most alpha-tested surfaces
chg: sound loads from disk during gameplay print warnings and get denied for looping sounds
chg: printing warnings when there are excessive sound loads from disk during gameplay
chg: com_soundMegs now defaults to 16

View file

@ -196,36 +196,33 @@ static sfx_t* S_FindName( const char *name )
}
static void S_memoryLoad( sfx_t* sfx, qbool looping = qfalse )
static void S_memoryLoad( sfx_t* sfx )
{
// Unfortunately, sound and image loads during gameplay are perfectly valid.
// Mod code really should pre-load as much as it can during CGAME_INIT.
// Even though correct sound playback behavior is given the priority here,
// it's important to let the user know his config might need a tweak.
if ( cls.state == CA_ACTIVE ) {
static int64_t lastMessage = -1000;
static int64_t lastLoadTime = -9000;
static int64_t lastMsgTime = -9000;
static int loadCount = 1;
const int64_t currTime = Sys_Milliseconds();
if ( currTime < lastLoadTime + 1000 )
++loadCount;
else
loadCount = 1;
lastLoadTime = currTime;
if ( currTime >= lastMessage + 1000 ) {
Com_Printf(
"^3WARNING^7: " S_COLOR_CVAR "com_soundMegs " S_COLOR_VAL "%d ^7is too low for this map!\n",
Cvar_VariableIntegerValue( "com_soundMegs" ) );
if ( looping )
Com_Printf( "^1ERROR ^7: blocked sound load: '%s'\n", sfx->soundName );
else
Com_Printf( "^3WARNING^7: allowed sound load: '%s'\n", sfx->soundName );
if ( loadCount > 1 && currTime >= lastMsgTime + 1000 ) {
Com_Printf( "^3WARNING^7: Excessive sound loads. Increase " S_COLOR_CVAR "com_soundMegs ^7if performance drops.\n" );
lastMsgTime = currTime;
loadCount = 1;
}
lastMessage = currTime;
}
if ( cls.state == CA_ACTIVE && looping ) {
// never load a looping sound on demand when the map is already loaded
// this should help prevent performance dropping massively on some maps
// with very long ambient sounds, e.g. ct3tourney3
// the downside is that some legit stuff can be filtered out (e.g. RG hum)
// that should be fine though as we expect the user to take action quickly
if ( !S_LoadSound( sfx ) )
sfx->defaultSound = qtrue;
}
else if ( !S_LoadSound( sfx ) ) {
//Com_Printf( S_COLOR_YELLOW "WARNING: couldn't load sound: %s\n", sfx->soundName );
sfx->defaultSound = qtrue;
}
sfx->inMemory = qtrue;
}
@ -561,7 +558,7 @@ static void S_Base_AddLoopingSound( int entityNum, const vec3_t origin, sfxHandl
sfx_t* sfx = &s_knownSfx[ sfxHandle ];
if (sfx->inMemory == qfalse) {
S_memoryLoad( sfx, qtrue );
S_memoryLoad( sfx );
}
if ( !sfx->soundLength ) {