Giel van Schijndel wrote:
Author: muggenhor
Date: Mon Feb 19 22:52:27 2007
New Revision: 792
URL: http://svn.gna.org/viewcvs/warzone?rev=792&view=rev
Log:
* removed some redundant code from src/data.c:
- the function dataAudioLoad first checked whether the audio system is
disabled and if it is sets return buffer (*ppData) to NULL, even though this
functionality is already performed by the function it calls
(audio_LoadTrackFromBuffer)
Well, you made a little mistake there. The function is supposed to
return FALSE ONLY when an error occurs. Returning FALSE causes for me:
error: resLoad: failed to parse wrf/frontend.wrf
error: Shutting down after failure
And you also made it return FALSE when sound is disabled. The attached
patch corrects this, and also removes the redundant function
audio_LoadTrackFromBuffer which was only a very thin wrapper for
sound_LoadTrackFromBuffer. The check if sound is enabled is again in
dataAudioLoad.
- Gerard
Index: src/data.c
===================================================================
--- src/data.c (revision 792)
+++ src/data.c (working copy)
@@ -989,13 +989,16 @@
/* Load an audio file */
BOOL dataAudioLoad(char *pBuffer, UDWORD size, void **ppData)
{
- // If audio is disabled or a track can't be constructed the return value will be NULL
- *ppData = audio_LoadTrackFromBuffer( pBuffer, size );
+ if ( audio_Disabled() == TRUE )
+ {
+ *ppData = NULL;
+ // No error occurred (sound is just disabled), so we return TRUE
+ return TRUE;
+ }
+ // Load the track from a file
+ *ppData = sound_LoadTrackFromBuffer( pBuffer, size );
- if (*ppData == NULL)
- return FALSE;
-
- return TRUE;
+ return *ppData != NULL;
}
void dataAudioRelease( void *pData )
Index: lib/sound/audio.c
===================================================================
--- lib/sound/audio.c (revision 792)
+++ lib/sound/audio.c (working copy)
@@ -614,23 +614,8 @@
}
//*
-// =======================================================================================================================
-// =======================================================================================================================
//
-TRACK *audio_LoadTrackFromBuffer(char *pBuffer, UDWORD udwSize)
-{
- // if audio not enabled return TRUE to carry on game without audio
- if ( g_bAudioEnabled == FALSE )
- {
- return NULL;
- }
- return sound_LoadTrackFromBuffer( pBuffer, udwSize );
-}
-
-//*
-//
-
// Routine to convert wav filename into a track number
// ... This is really not going to be practical on the PSX is it?
//
Index: lib/sound/audio.h
===================================================================
--- lib/sound/audio.h (revision 792)
+++ lib/sound/audio.h (working copy)
@@ -36,7 +36,6 @@
extern BOOL audio_Disabled( void );
extern BOOL audio_LoadTrackFromFile( char szFileName[] );
-extern TRACK * audio_LoadTrackFromBuffer(char *pBuffer, UDWORD udwSize);
extern BOOL audio_SetTrackVals( char szFileName[], BOOL bLoop, int *piID,
int iVol, int iPriority, int iAudibleRadius );
extern BOOL audio_SetTrackValsHashName( UDWORD hash, BOOL bLoop, int iTrack, int iVol,
_______________________________________________
Warzone-dev mailing list
Warzone-dev@gna.org
https://mail.gna.org/listinfo/warzone-dev