* Add a new cheat/debug-command "showsamples"

* This command will cause the amount of samples in the sound library's queues & lists to be constantly displayed (until turned off) on screen

Patch #887 by Buginator


git-svn-id: svn+ssh://svn.gna.org/svn/warzone/trunk@3107 4a71c877-e1ca-e34f-864e-861f7616d084
master
Giel van Schijndel 2007-12-19 20:17:54 +00:00
parent ddca71af93
commit db3d933791
9 changed files with 86 additions and 2 deletions

View File

@ -41,6 +41,47 @@ static BOOL g_bAudioEnabled = FALSE;
static BOOL g_bAudioPaused = FALSE;
static AUDIO_SAMPLE g_sPreviousSample;
/** Counts the number of samples in the SampleQueue
* \return the number of samples in the SampleQueue
*/
unsigned int audio_GetSampleQueueCount()
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AUDIO_SAMPLE *psSample = NULL;
unsigned int count=0;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// loop through SampleQueue to count how many we have.
psSample = g_psSampleQueue;
while ( psSample != NULL )
{
count++;
psSample = psSample->psNext;
}
return count;
}
/** Counts the number of samples in the SampleList
* \return the number of samples in the SampleList
*/
unsigned int audio_GetSampleListCount()
{
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
AUDIO_SAMPLE *psSample = NULL;
unsigned int count = 0;
//~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
// loop through SampleList to count how many we have.
psSample = g_psSampleList;
while (psSample != NULL)
{
++count;
psSample = psSample->psNext;
}
return count;
}
//*
// =======================================================================================================================
// =======================================================================================================================

View File

@ -69,7 +69,9 @@ extern void audio_StopAll( void );
extern SDWORD audio_GetTrackID( const char *fileName );
extern void audio_RemoveObj(const void* psObj);
extern unsigned int audio_GetSampleQueueCount(void);
extern unsigned int audio_GetSampleListCount(void);
extern unsigned int sound_GetActiveSamplesCount(void);
/***************************************************************************/
#endif // _AUDIO_H_

View File

@ -216,6 +216,21 @@ static void sound_DestroyIteratedSample(SAMPLE_LIST** previous, SAMPLE_LIST** sa
*sample = (*previous != NULL) ? (*previous)->next : active_samples;
}
/** Counts the number of samples in active_samples
* \return the number of actively playing sound samples
*/
unsigned int sound_GetActiveSamplesCount()
{
unsigned int num = 0;
SAMPLE_LIST* node = active_samples;
while(node)
{
num++;
node = node->next;
}
return num;
}
void sound_Update()
{
#ifndef WZ_NOSOUND

View File

@ -77,6 +77,7 @@ void sound_PauseAll( void );
void sound_ResumeAll( void );
void sound_StopAll( void );
void sound_Update( void );
unsigned int sound_GetActiveSamplesCount(void);
UDWORD sound_GetGameTime( void );

View File

@ -69,6 +69,7 @@ static CHEAT_ENTRY cheatCodes[] =
{"no faults", kf_NoFaults},//carol vorderman
{"tileinfo", kf_TileInfo}, // output debug info about a tile
{"showfps", kf_ToggleFPS}, //displays your average FPS
{"showsamples", kf_ToggleSamples}, //displays the # of Sound samples in Queue & List
{"end of list",NULL}
};

View File

@ -218,6 +218,7 @@ static unsigned int underwaterTile = WATER_TILE;
static unsigned int rubbleTile = BLOCKING_RUBBLE_TILE;
bool showFPS = false; // default OFF, turn ON via console command 'showfps'
bool showSAMPLES = false; // default OFF, turn ON via console command 'showsamples'
UDWORD geoOffset;
static int averageCentreTerrainHeight;
@ -356,12 +357,26 @@ void draw3DScene( void )
{
displayMultiChat();
}
if (showSAMPLES) //Displays the number of sound samples we currently have
{
unsigned int width, height;
const char *Qbuf, *Lbuf, *Abuf;
sasprintf((char**)&Qbuf,"Que: %04u",audio_GetSampleQueueCount());
sasprintf((char**)&Lbuf,"Lst: %04u",audio_GetSampleListCount());
sasprintf((char**)&Abuf,"Act: %04u",sound_GetActiveSamplesCount());
width = iV_GetTextWidth(Qbuf) + 11;
height = iV_GetTextHeight(Qbuf);
iV_DrawText(Qbuf, pie_GetVideoBufferWidth() - width, height + 2);
iV_DrawText(Lbuf, pie_GetVideoBufferWidth() - width, height + 48);
iV_DrawText(Abuf, pie_GetVideoBufferWidth() - width, height + 59);
}
if (showFPS)
{
unsigned int width, height;
const char* fps;
sasprintf((char**)&fps, "FPS: %u", frameGetAverageRate());
width = iV_GetTextWidth(fps) + 10;
height = iV_GetTextHeight(fps);

View File

@ -42,6 +42,7 @@ typedef enum
} TILE_ID;
extern bool showFPS;
extern bool showSAMPLES;
extern void setViewAngle(SDWORD angle);
extern UDWORD getViewDistance(void);

View File

@ -309,6 +309,13 @@ void kf_ToggleFPS(void) //This shows *just FPS* and is always visable (when acti
CONPRINTF(ConsoleString, (ConsoleString, "FPS display is %s", showFPS ? "Enabled" : "Disabled"));
}
void kf_ToggleSamples(void) //Displays number of sound sample in the sound queues & lists.
{
// Toggle the boolean value of showFPS
showSAMPLES = !showSAMPLES;
CONPRINTF(ConsoleString, (ConsoleString, "Sound Samples displayed is %s", showSAMPLES ? "Enabled" : "Disabled"));
}
/* Writes out the frame rate */
void kf_FrameRate( void )
{

View File

@ -25,6 +25,7 @@ extern void kf_HalveHeights( void );
extern void kf_DebugDroidInfo( void );
extern void kf_BuildInfo( void );
extern void kf_ToggleFPS(void); //FPS counter NOT same as kf_Framerate! -Q
extern void kf_ToggleSamples(void); //displays # of sound samples in Q/list.
extern void kf_FrameRate( void );
extern void kf_ShowNumObjects( void );
extern void kf_ToggleRadar( void );