104 // Returns a pointer to the voicepack with the given name. |
104 // Returns a pointer to the voicepack with the given name. |
105 function AskForVoicepack(name: shortstring): Pointer; |
105 function AskForVoicepack(name: shortstring): Pointer; |
106 |
106 |
107 var MusicFN: shortstring; // music file name |
107 var MusicFN: shortstring; // music file name |
108 SDMusicFN: shortstring; // SD music file name |
108 SDMusicFN: shortstring; // SD music file name |
|
109 FallbackMusicFN: shortstring; // fallback music file name |
|
110 FallbackSDMusicFN: shortstring; // fallback SD music fille name |
109 |
111 |
110 var Volume: LongInt; |
112 var Volume: LongInt; |
111 SoundTimerTicks: Longword; |
113 SoundTimerTicks: Longword; |
112 implementation |
114 implementation |
113 uses uVariables, uConsole, uCommands, uDebug, uPhysFSLayer; |
115 uses uVariables, uConsole, uCommands, uDebug, uPhysFSLayer; |
630 if SuddenDeath and (SDMusicFN <> '') then |
632 if SuddenDeath and (SDMusicFN <> '') then |
631 s:= '/Music/' + SDMusicFN |
633 s:= '/Music/' + SDMusicFN |
632 else s:= '/Music/' + MusicFN; |
634 else s:= '/Music/' + MusicFN; |
633 WriteToConsole(msgLoading + s + ' '); |
635 WriteToConsole(msgLoading + s + ' '); |
634 |
636 |
|
637 // Load normal music |
635 Mus:= Mix_LoadMUS_RW(rwopsOpenRead(s)); |
638 Mus:= Mix_LoadMUS_RW(rwopsOpenRead(s)); |
636 SDLCheck(Mus <> nil, 'Mix_LoadMUS_RW', false); |
639 SDLCheck(Mus <> nil, 'Mix_LoadMUS_RW', false); |
637 WriteLnToConsole(msgOK); |
640 if Mus <> nil then |
|
641 WriteLnToConsole(msgOK); |
|
642 |
|
643 // If normal music failed, try to get fallback music |
|
644 if Mus = nil then |
|
645 begin |
|
646 WriteLnToConsole('Music not found. Trying fallback music.'); |
|
647 if SuddenDeath and (FallbackSDMusicFN <> '') then |
|
648 s:= '/Music/' + FallbackSDMusicFN |
|
649 else if (not SuddenDeath) and (FallbackMusicFN <> '') then |
|
650 s:= '/Music/' + FallbackMusicFN |
|
651 else |
|
652 begin |
|
653 WriteLnToConsole('No fallback music configured!'); |
|
654 s:= '' |
|
655 end; |
|
656 |
|
657 if (s <> '') then |
|
658 begin |
|
659 WriteLnToConsole(msgLoading + s + ' '); |
|
660 Mus:= Mix_LoadMUS_RW(rwopsOpenRead(s)); |
|
661 SDLCheck(Mus <> nil, 'Mix_LoadMUS_RW', false); |
|
662 if Mus <> nil then |
|
663 WriteLnToConsole(msgOK) |
|
664 end; |
|
665 end; |
638 |
666 |
639 SDLCheck(Mix_FadeInMusic(Mus, -1, 3000) <> -1, 'Mix_FadeInMusic', false) |
667 SDLCheck(Mix_FadeInMusic(Mus, -1, 3000) <> -1, 'Mix_FadeInMusic', false) |
640 end; |
668 end; |
641 |
669 |
642 procedure SetVolume(vol: LongInt); |
670 procedure SetVolume(vol: LongInt); |