Browse Source

engine: client: try to prepend media/ if audio stream couldn't be opened

pull/4/head
Alibek Omarov 12 months ago
parent
commit
cee6862924
  1. 1
      engine/client/s_stream.c
  2. 15
      engine/common/soundlib/snd_main.c

1
engine/client/s_stream.c

@ -96,6 +96,7 @@ void S_StartBackgroundTrack( const char *introTrack, const char *mainTrack, int @@ -96,6 +96,7 @@ void S_StartBackgroundTrack( const char *introTrack, const char *mainTrack, int
// open stream
s_bgTrack.stream = FS_OpenStream( introTrack );
Q_strncpy( s_bgTrack.current, introTrack, sizeof( s_bgTrack.current ));
memset( &musicfade, 0, sizeof( musicfade )); // clear any soundfade
s_bgTrack.source = cls.key_dest;

15
engine/common/soundlib/snd_main.c

@ -152,7 +152,7 @@ stream_t *FS_OpenStream( const char *filename ) @@ -152,7 +152,7 @@ stream_t *FS_OpenStream( const char *filename )
string path, loadname;
qboolean anyformat = true;
const streamfmt_t *format;
stream_t *stream;
stream_t *stream = NULL;
Sound_Reset(); // clear old streaminfo
Q_strncpy( loadname, filename, sizeof( loadname ));
@ -188,9 +188,18 @@ stream_t *FS_OpenStream( const char *filename ) @@ -188,9 +188,18 @@ stream_t *FS_OpenStream( const char *filename )
}
}
Con_Reportf( "FS_OpenStream: couldn't open \"%s\"\n", loadname );
// compatibility with original Xash3D, try media/ folder
if( Q_strncmp( filename, "media/", sizeof( "media/" ) - 1 ))
{
Q_snprintf( loadname, sizeof( loadname ), "media/%s", filename );
stream = FS_OpenStream( loadname );
}
else
{
Con_Reportf( "%s: couldn't open \"%s\" or \"%s\"\n", __func__, filename + 6, filename );
}
return NULL;
return stream;
}
/*

Loading…
Cancel
Save