src/music_gui.cpp
branchgamebalance
changeset 9913 e79cd19772dd
parent 9910 0b2aebc8283e
child 7666 a5fccd76176a
equal deleted inserted replaced
9912:1ac8aac92385 9913:e79cd19772dd
     5 #include "stdafx.h"
     5 #include "stdafx.h"
     6 #include "openttd.h"
     6 #include "openttd.h"
     7 #include "table/strings.h"
     7 #include "table/strings.h"
     8 #include "table/sprites.h"
     8 #include "table/sprites.h"
     9 #include "functions.h"
     9 #include "functions.h"
       
    10 #include "fileio.h"
    10 #include "window.h"
    11 #include "window.h"
    11 #include "gfx.h"
    12 #include "gfx.h"
    12 #include "sound.h"
    13 #include "sound.h"
    13 #include "hal.h"
    14 #include "hal.h"
    14 #include "macros.h"
    15 #include "macros.h"
    88 	_music_driver->set_volume(new_vol);
    89 	_music_driver->set_volume(new_vol);
    89 }
    90 }
    90 
    91 
    91 static void DoPlaySong()
    92 static void DoPlaySong()
    92 {
    93 {
    93 	char filename[256];
    94 	char filename[MAX_PATH];
    94 	snprintf(filename, sizeof(filename), "%s%s",
    95 	FioFindFullPath(filename, lengthof(filename), GM_DIR,
    95 		_paths.gm_dir, origin_songs_specs[_music_wnd_cursong - 1].filename);
    96 			origin_songs_specs[_music_wnd_cursong - 1].filename);
    96 	_music_driver->play_song(filename);
    97 	_music_driver->play_song(filename);
    97 }
    98 }
    98 
    99 
    99 static void DoStopMusic()
   100 static void DoStopMusic()
   100 {
   101 {
   103 
   104 
   104 static void SelectSongToPlay()
   105 static void SelectSongToPlay()
   105 {
   106 {
   106 	uint i = 0;
   107 	uint i = 0;
   107 	uint j = 0;
   108 	uint j = 0;
   108 	char filename[256];
       
   109 
   109 
   110 	memset(_cur_playlist, 0, sizeof(_cur_playlist));
   110 	memset(_cur_playlist, 0, sizeof(_cur_playlist));
   111 	do {
   111 	do {
   112 		if (_playlists[msf.playlist][i] != 0) {  // Don't evaluate playlist terminator
   112 		/* We are now checking for the existence of that file prior
   113 			snprintf(filename, sizeof(filename),  "%s%s",
   113 		 * to add it to the list of available songs */
   114 				_paths.gm_dir, origin_songs_specs[(_playlists[msf.playlist][i]) - 1].filename);
   114 		if (FioCheckFileExists(origin_songs_specs[_playlists[msf.playlist][i]].filename, GM_DIR)) {
   115 
   115 			_cur_playlist[j] = _playlists[msf.playlist][i];
   116 			/* we are now checking for the existence of that file prior
   116 			j++;
   117 			 * to add it to the list of available songs */
       
   118 			if (FileExists(filename)) {
       
   119 				_cur_playlist[j] = _playlists[msf.playlist][i];
       
   120 				j++;
       
   121 			}
       
   122 		}
   117 		}
   123 	} while (_playlists[msf.playlist][i++] != 0 && i < lengthof(_cur_playlist) - 1);
   118 	} while (_playlists[msf.playlist][i++] != 0 && i < lengthof(_cur_playlist) - 1);
   124 
   119 
   125 	if (msf.shuffle) {
   120 	if (msf.shuffle) {
   126 		i = 500;
   121 		i = 500;