From b517f56959fa6c20c5606092763da0c80fdaa623 Mon Sep 17 00:00:00 2001 From: myT Date: Tue, 22 Nov 2022 21:24:51 +0100 Subject: [PATCH] only print warnings for excessive sound loads with /developer 1 --- changelog.txt | 2 -- code/client/snd_dma.cpp | 19 ++++++++++++++----- 2 files changed, 14 insertions(+), 7 deletions(-) diff --git a/changelog.txt b/changelog.txt index 4536353..e4d53c3 100644 --- a/changelog.txt +++ b/changelog.txt @@ -70,8 +70,6 @@ chg: r_showtris/r_shownormals (default: 0) draws wireframe triangles/v 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: all rendering backends use depth clipping, near clip plane distance is 1 instead of 4 diff --git a/code/client/snd_dma.cpp b/code/client/snd_dma.cpp index cc314a2..2155ef7 100644 --- a/code/client/snd_dma.cpp +++ b/code/client/snd_dma.cpp @@ -200,13 +200,17 @@ 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 ) { + // Some stuff can't really be pre-loaded, such as when loading a new player model. + if ( cls.state == CA_ACTIVE && com_developer && com_developer->integer ) { + enum { SoundBufferSize = 16 }; + static sfx_t* sounds[SoundBufferSize]; + static int soundIndex = 0; static int64_t lastLoadTime = -9000; static int64_t lastMsgTime = -9000; static int loadCount = 1; + sounds[soundIndex++] = sfx; + const int64_t currTime = Sys_Milliseconds(); if ( currTime < lastLoadTime + 1000 ) ++loadCount; @@ -214,8 +218,13 @@ static void S_memoryLoad( sfx_t* sfx ) loadCount = 1; lastLoadTime = currTime; - if ( loadCount > 1 && currTime >= lastMsgTime + 1000 ) { - Com_Printf( "^3WARNING^7: Excessive sound loads. Increase " S_COLOR_CVAR "com_soundMegs ^7if performance drops.\n" ); + if ( loadCount > 2 && currTime >= lastMsgTime + 1000 ) { + 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; loadCount = 1; }