mirror of
https://github.com/JGRennison/OpenTTD-patches.git
synced 2024-11-16 00:12:51 +00:00
(svn r6793) -Fix(5464): When checking items on an array, make sure to respect boundaries(jez).
Made some comments code style compliant
This commit is contained in:
parent
6b5c105e28
commit
6ad7878fb2
32
music_gui.c
32
music_gui.c
@ -49,14 +49,11 @@ static void SkipToPrevSong(void)
|
|||||||
byte *p = b;
|
byte *p = b;
|
||||||
byte t;
|
byte t;
|
||||||
|
|
||||||
// empty playlist
|
if (b[0] == 0) return; // empty playlist
|
||||||
if (b[0] == 0) return;
|
|
||||||
|
|
||||||
// find the end
|
do p++; while (p[0] != 0); // find the end
|
||||||
do p++; while (p[0] != 0);
|
|
||||||
|
|
||||||
// and copy the bytes
|
t = *--p; // and copy the bytes
|
||||||
t = *--p;
|
|
||||||
while (p != b) {
|
while (p != b) {
|
||||||
p--;
|
p--;
|
||||||
p[1] = p[0];
|
p[1] = p[0];
|
||||||
@ -109,14 +106,17 @@ static void SelectSongToPlay(void)
|
|||||||
|
|
||||||
memset(_cur_playlist, 0, sizeof(_cur_playlist));
|
memset(_cur_playlist, 0, sizeof(_cur_playlist));
|
||||||
do {
|
do {
|
||||||
|
if (_playlists[msf.playlist][i] != 0) { // Don't evaluate playlist terminator
|
||||||
snprintf(filename, sizeof(filename), "%s%s",
|
snprintf(filename, sizeof(filename), "%s%s",
|
||||||
_path.gm_dir, origin_songs_specs[_playlists[msf.playlist][i]].filename);
|
_path.gm_dir, origin_songs_specs[(_playlists[msf.playlist][i]) - 1].filename);
|
||||||
//we are now checking for the existence of that file prior
|
|
||||||
//to add it to the list of available songs
|
/* we are now checking for the existence of that file prior
|
||||||
|
* to add it to the list of available songs */
|
||||||
if (FileExists(filename)) {
|
if (FileExists(filename)) {
|
||||||
_cur_playlist[j] = _playlists[msf.playlist][i];
|
_cur_playlist[j] = _playlists[msf.playlist][i];
|
||||||
j++;
|
j++;
|
||||||
}
|
}
|
||||||
|
}
|
||||||
} while (_playlists[msf.playlist][i++] != 0 && i < lengthof(_cur_playlist) - 1);
|
} while (_playlists[msf.playlist][i++] != 0 && i < lengthof(_cur_playlist) - 1);
|
||||||
|
|
||||||
if (msf.shuffle) {
|
if (msf.shuffle) {
|
||||||
@ -147,9 +147,9 @@ static void PlayPlaylistSong(void)
|
|||||||
{
|
{
|
||||||
if (_cur_playlist[0] == 0) {
|
if (_cur_playlist[0] == 0) {
|
||||||
SelectSongToPlay();
|
SelectSongToPlay();
|
||||||
//if there is not songs in the playlist, it may indicate
|
/* if there is not songs in the playlist, it may indicate
|
||||||
//no file on the gm folder, or even no gm folder.
|
* no file on the gm folder, or even no gm folder.
|
||||||
//Stop the playback, then
|
* Stop the playback, then */
|
||||||
if (_cur_playlist[0] == 0) {
|
if (_cur_playlist[0] == 0) {
|
||||||
_song_is_active = false;
|
_song_is_active = false;
|
||||||
_music_wnd_cursong = 0;
|
_music_wnd_cursong = 0;
|
||||||
@ -241,7 +241,7 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
|
|||||||
|
|
||||||
case WE_CLICK:
|
case WE_CLICK:
|
||||||
switch (e->we.click.widget) {
|
switch (e->we.click.widget) {
|
||||||
case 3: { /* add to playlist */
|
case 3: { // add to playlist
|
||||||
int y = (e->we.click.pt.y - 23) / 6;
|
int y = (e->we.click.pt.y - 23) / 6;
|
||||||
uint i;
|
uint i;
|
||||||
byte *p;
|
byte *p;
|
||||||
@ -261,7 +261,7 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
|
|||||||
}
|
}
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 4: { /* remove from playlist */
|
case 4: { // remove from playlist
|
||||||
int y = (e->we.click.pt.y - 23) / 6;
|
int y = (e->we.click.pt.y - 23) / 6;
|
||||||
uint i;
|
uint i;
|
||||||
byte *p;
|
byte *p;
|
||||||
@ -278,7 +278,7 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
|
|||||||
SelectSongToPlay();
|
SelectSongToPlay();
|
||||||
} break;
|
} break;
|
||||||
|
|
||||||
case 11: /* clear */
|
case 11: // clear
|
||||||
_playlists[msf.playlist][0] = 0;
|
_playlists[msf.playlist][0] = 0;
|
||||||
SetWindowDirty(w);
|
SetWindowDirty(w);
|
||||||
StopMusic();
|
StopMusic();
|
||||||
@ -286,7 +286,7 @@ static void MusicTrackSelectionWndProc(Window *w, WindowEvent *e)
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
#if 0
|
#if 0
|
||||||
case 12: /* save */
|
case 12: // save
|
||||||
ShowInfo("MusicTrackSelectionWndProc:save not implemented\n");
|
ShowInfo("MusicTrackSelectionWndProc:save not implemented\n");
|
||||||
break;
|
break;
|
||||||
#endif
|
#endif
|
||||||
|
Loading…
Reference in New Issue
Block a user