diff --git a/CHANGELOG.txt b/CHANGELOG.txt index 9e6a229dc..238cb3b50 100644 --- a/CHANGELOG.txt +++ b/CHANGELOG.txt @@ -3,6 +3,7 @@ D2X-Rebirth Changelog 20100219 -------- main/gauges.c: The little light bulb showing homing warning in Cockpit was broken and I replaced it; Rewritten code to show weapon text in Cockpit and Statusbar slightly +main/songs.c, main/songs.h: Making reading of descent.sng a bit more flexible; Not dynamically allocated, yet, since missions are not as well 20100215 -------- diff --git a/main/songs.c b/main/songs.c index 985cdfe66..88e956092 100644 --- a/main/songs.c +++ b/main/songs.c @@ -56,6 +56,8 @@ void songs_init() char inputline[80+1]; CFILE * fp; + memset(Songs, '\0', sizeof(Songs)); + if (cfexist("descent.sng")) { // mac (demo?) datafiles don't have the .sng file fp = cfopen( "descent.sng", "rb" ); if ( fp == NULL ) @@ -63,16 +65,23 @@ void songs_init() Error( "Couldn't open descent.sng" ); } i = 0; - while (cfgets(inputline, 80, fp )) + while (!PHYSFS_eof(fp)) { + cfgets(inputline, 80, fp ); if ( strlen( inputline ) ) { Assert( i < MAX_NUM_SONGS ); + memset(Songs[i].filename, '\0', sizeof(char)*16); + memset(Songs[i].melodic_bank_file, '\0', sizeof(char)*16); + memset(Songs[i].drum_bank_file, '\0', sizeof(char)*16); sscanf( inputline, "%15s %15s %15s", Songs[i].filename, Songs[i].melodic_bank_file, Songs[i].drum_bank_file ); - i++; + + if (strchr(Songs[i].filename, '.')) + if (!stricmp(strchr(Songs[i].filename, '.'), ".hmp")) + i++; } } Num_songs = i; diff --git a/main/songs.h b/main/songs.h index 210a860a5..7427ea8e3 100644 --- a/main/songs.h +++ b/main/songs.h @@ -27,27 +27,16 @@ typedef struct song_info { char drum_bank_file[16]; } song_info; +extern int Num_songs; //how many songs extern song_info Songs[]; #define SONG_TITLE 0 -#ifdef MACINTOSH -#define SONG_BRIEFING 3 // endgame and briefing the same -#else #define SONG_BRIEFING 1 -#endif #define SONG_ENDLEVEL 2 #define SONG_ENDGAME 3 #define SONG_CREDITS 4 #define SONG_FIRST_LEVEL_SONG 5 - - -#ifdef MACINTOSH -#define MAX_NUM_SONGS 9 -#define Num_songs 9 -#else -#define MAX_NUM_SONGS 30 -extern int Num_songs; //how many MIDI songs -#endif +#define MAX_NUM_SONGS (5+MAX_LEVELS_PER_MISSION+MAX_SECRET_LEVELS_PER_MISSION) void songs_play_song( int songnum, int repeat ); void songs_play_level_song( int levelnum );