mirror of https://github.com/OpenTTD/OpenTTD
(svn r26809) -Fix: do not dereference the -1 index of the file names array of music files. It definitely breaks on m68k, and might cause failures on other platforms as well
parent
ed9cadade4
commit
4438821b80
|
@ -202,13 +202,18 @@ static void SelectSongToPlay()
|
||||||
|
|
||||||
memset(_cur_playlist, 0, sizeof(_cur_playlist));
|
memset(_cur_playlist, 0, sizeof(_cur_playlist));
|
||||||
do {
|
do {
|
||||||
const char *filename = BaseMusic::GetUsedSet()->files[_playlists[_settings_client.music.playlist][i] - 1].filename;
|
/* File is the index into the file table of the music set. The play list uses 0 as 'no entry',
|
||||||
|
* so we need to subtract 1. In case of 'no entry' (file = -1), just skip adding it outright. */
|
||||||
|
int file = _playlists[_settings_client.music.playlist][i] - 1;
|
||||||
|
if (file >= 0) {
|
||||||
|
const char *filename = BaseMusic::GetUsedSet()->files[file].filename;
|
||||||
/* We are now checking for the existence of that file prior
|
/* We are now checking for the existence of that file prior
|
||||||
* to add it to the list of available songs */
|
* to add it to the list of available songs */
|
||||||
if (!StrEmpty(filename) && FioCheckFileExists(filename, BASESET_DIR)) {
|
if (!StrEmpty(filename) && FioCheckFileExists(filename, BASESET_DIR)) {
|
||||||
_cur_playlist[j] = _playlists[_settings_client.music.playlist][i];
|
_cur_playlist[j] = _playlists[_settings_client.music.playlist][i];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} while (_playlists[_settings_client.music.playlist][++i] != 0 && j < lengthof(_cur_playlist) - 1);
|
} while (_playlists[_settings_client.music.playlist][++i] != 0 && j < lengthof(_cur_playlist) - 1);
|
||||||
|
|
||||||
/* Do not shuffle when on the intro-start window, as the song to play has to be the original TTD Theme*/
|
/* Do not shuffle when on the intro-start window, as the song to play has to be the original TTD Theme*/
|
||||||
|
|
Loading…
Reference in New Issue