Basic logic here is to see if the intro file specified actually exists, and if so, then it's not dynamic music, When called by the cgame start it loads up, then stops the playback (because of stutter issues), so that when the actual snapshot is received and the real play request is processed the data has already been loaded so will be quicker. to be honest, although the code still plays WAVs some
| 4517 | // to use WAV music you'll have to do some tweaking below (but I've got other things to do so it'll have to wait - Ste) |
| 4518 | // |
| 4519 | void S_StartBackgroundTrack( const char *intro, const char *loop, qboolean bCalledByCGameStart ) |
| 4520 | { |
| 4521 | bMusic_IsDynamic = qfalse; |
| 4522 | |
| 4523 | if (!s_soundStarted) |
| 4524 | { //we have no sound, so don't even bother trying |
| 4525 | return; |
| 4526 | } |
| 4527 | |
| 4528 | if ( !intro ) { |
| 4529 | intro = ""; |
| 4530 | } |
| 4531 | if ( !loop || !loop[0] ) { |
| 4532 | loop = intro; |
| 4533 | } |
| 4534 | |
| 4535 | if ( intro != gsIntroMusic ) { |
| 4536 | Q_strncpyz( gsIntroMusic, intro, sizeof(gsIntroMusic) ); |
| 4537 | } |
| 4538 | if ( loop != gsLoopMusic ) { |
| 4539 | Q_strncpyz( gsLoopMusic, loop, sizeof(gsLoopMusic) ); |
| 4540 | } |
| 4541 | |
| 4542 | char sNameIntro[MAX_QPATH]; |
| 4543 | char sNameLoop [MAX_QPATH]; |
| 4544 | Q_strncpyz(sNameIntro, intro, sizeof(sNameIntro)); |
| 4545 | Q_strncpyz(sNameLoop, loop, sizeof(sNameLoop)); |
| 4546 | |
| 4547 | COM_DefaultExtension( sNameIntro, sizeof( sNameIntro ), ".mp3" ); |
| 4548 | COM_DefaultExtension( sNameLoop, sizeof( sNameLoop), ".mp3" ); |
| 4549 | |
| 4550 | // if dynamic music not allowed, then just stream the explore music instead of playing dynamic... |
| 4551 | // |
| 4552 | if (!s_allowDynamicMusic->integer && Music_DynamicDataAvailable(intro)) // "intro", NOT "sName" (i.e. don't use version with ".mp3" extension) |
| 4553 | { |
| 4554 | const char *psMusicName = Music_GetFileNameForState( eBGRNDTRACK_DATABEGIN ); |
| 4555 | if (psMusicName && S_FileExists( psMusicName )) |
| 4556 | { |
| 4557 | Q_strncpyz(sNameIntro,psMusicName,sizeof(sNameIntro)); |
| 4558 | Q_strncpyz(sNameLoop, psMusicName,sizeof(sNameLoop )); |
| 4559 | } |
| 4560 | } |
| 4561 | |
| 4562 | // conceptually we always play the 'intro'[/sName] track, intro-to-loop transition is handled in UpdateBackGroundTrack(). |
| 4563 | // |
| 4564 | if ( (strstr(sNameIntro,"/") && S_FileExists( sNameIntro )) ) // strstr() check avoids extra file-exists check at runtime if reverting from streamed music to dynamic since literal files all need at least one slash in their name (eg "music/blah") |
| 4565 | { |
| 4566 | const char *psLoopName = S_FileExists( sNameLoop ) ? sNameLoop : sNameIntro; |
| 4567 | Com_DPrintf("S_StartBackgroundTrack: Found/using non-dynamic music track '%s' (loop: '%s')\n", sNameIntro, psLoopName); |
| 4568 | S_StartBackgroundTrack_Actual( &tMusic_Info[eBGRNDTRACK_NONDYNAMIC], bMusic_IsDynamic, sNameIntro, psLoopName ); |
| 4569 | } |
| 4570 | else |
| 4571 | { |
| 4572 | if (Music_DynamicDataAvailable(intro)) // "intro", NOT "sName" (i.e. don't use version with ".mp3" extension) |
| 4573 | { |
| 4574 | extern const char *Music_GetLevelSetName(void); |
| 4575 | Q_strncpyz(sInfoOnly_CurrentDynamicMusicSet, Music_GetLevelSetName(), sizeof(sInfoOnly_CurrentDynamicMusicSet)); |
| 4576 | for (int i = eBGRNDTRACK_DATABEGIN; i != eBGRNDTRACK_DATAEND; i++) |
no test coverage detected