only print warnings for excessive sound loads with /developer 1

This commit is contained in:
myT 2022-11-22 21:24:51 +01:00
parent f7a1d6655e
commit b517f56959
2 changed files with 14 additions and 7 deletions

View file

@ -70,8 +70,6 @@ chg: r_showtris/r_shownormals <bitmask> (default: 0) draws wireframe triangles/v
chg: r_lightmap 1 now handles most alpha-tested surfaces chg: r_lightmap 1 now handles most alpha-tested surfaces
chg: printing warnings when there are excessive sound loads from disk during gameplay
chg: com_soundMegs now defaults to 16 chg: com_soundMegs now defaults to 16
chg: all rendering backends use depth clipping, near clip plane distance is 1 instead of 4 chg: all rendering backends use depth clipping, near clip plane distance is 1 instead of 4

View file

@ -200,13 +200,17 @@ static void S_memoryLoad( sfx_t* sfx )
{ {
// Unfortunately, sound and image loads during gameplay are perfectly valid. // Unfortunately, sound and image loads during gameplay are perfectly valid.
// Mod code really should pre-load as much as it can during CGAME_INIT. // 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, // Some stuff can't really be pre-loaded, such as when loading a new player model.
// it's important to let the user know his config might need a tweak. if ( cls.state == CA_ACTIVE && com_developer && com_developer->integer ) {
if ( cls.state == CA_ACTIVE ) { enum { SoundBufferSize = 16 };
static sfx_t* sounds[SoundBufferSize];
static int soundIndex = 0;
static int64_t lastLoadTime = -9000; static int64_t lastLoadTime = -9000;
static int64_t lastMsgTime = -9000; static int64_t lastMsgTime = -9000;
static int loadCount = 1; static int loadCount = 1;
sounds[soundIndex++] = sfx;
const int64_t currTime = Sys_Milliseconds(); const int64_t currTime = Sys_Milliseconds();
if ( currTime < lastLoadTime + 1000 ) if ( currTime < lastLoadTime + 1000 )
++loadCount; ++loadCount;
@ -214,8 +218,13 @@ static void S_memoryLoad( sfx_t* sfx )
loadCount = 1; loadCount = 1;
lastLoadTime = currTime; lastLoadTime = currTime;
if ( loadCount > 1 && currTime >= lastMsgTime + 1000 ) { if ( loadCount > 2 && currTime >= lastMsgTime + 1000 ) {
Com_Printf( "^3WARNING^7: Excessive sound loads. Increase " S_COLOR_CVAR "com_soundMegs ^7if performance drops.\n" ); Com_Printf( "^3WARNING: excessive sound loads\n" );
for ( int i = 0; i < SoundBufferSize; ++i ) {
sfx_t* const sound = sounds[ ( soundIndex + i ) % SoundBufferSize ];
if ( sound != NULL )
Com_Printf( "^3- %s\n", sound->soundName );
}
lastMsgTime = currTime; lastMsgTime = currTime;
loadCount = 1; loadCount = 1;
} }