From f5234b7c82fb70991867927d1639b40166e39fe8 Mon Sep 17 00:00:00 2001 From: Bradley Bell Date: Fri, 30 Jan 2015 15:18:22 -0800 Subject: [PATCH] play D1 midi for D1 missions, by allowing descent.hog to override the builtin hog, and reinitializing songs on mission change --- include/cfile.h | 2 +- main/mission.c | 5 ++++- main/songs.c | 6 ++++++ main/songs.h | 3 +++ 4 files changed, 14 insertions(+), 2 deletions(-) diff --git a/include/cfile.h b/include/cfile.h index 1ffcbe3e..f8936d7b 100644 --- a/include/cfile.h +++ b/include/cfile.h @@ -46,7 +46,7 @@ static inline int cfile_init(char *hogname) if (!PHYSFSX_getRealPath(hogname, pathname)) return 0; - return PHYSFS_addToSearchPath(pathname, 1); + return PHYSFS_addToSearchPath(pathname, 0); } static inline int cfile_close(char *hogname) diff --git a/main/mission.c b/main/mission.c index 2dd3fbb8..a4aaa79c 100644 --- a/main/mission.c +++ b/main/mission.c @@ -609,13 +609,16 @@ int load_mission(mle *mission) *(mle *) Current_mission = *mission; Current_mission->filename = d_strdup(mission->filename); // don't want to lose it + songs_close(); + // for Descent 1 missions, load descent.hog if (EMULATING_D1) { if (!cfile_init("descent.hog")) Warning("descent.hog not available, this mission may be missing some files required for briefings and exit sequence\n"); if (!stricmp(Current_mission_filename, D1_MISSION_FILENAME)) return load_mission_d1(); - } + } else + cfile_close("descent.hog"); if (PLAYING_BUILTIN_MISSION) { switch (Current_mission->builtin_hogsize) { diff --git a/main/songs.c b/main/songs.c index 749da3ea..97b191f8 100644 --- a/main/songs.c +++ b/main/songs.c @@ -66,6 +66,12 @@ void set_redbook_volume(int volume) } +void songs_close(void) +{ + Songs_initialized = 0; +} + + void songs_init() { int i; diff --git a/main/songs.h b/main/songs.h index d66538d7..f612de72 100644 --- a/main/songs.h +++ b/main/songs.h @@ -56,4 +56,7 @@ void songs_stop_all(void); // this should be called regularly to check for redbook restart void songs_check_redbook_repeat(void); +// require songs to be reinitialized, i.e. when changing missions +void songs_close(void); + #endif /* _SONGS_H */ -- 2.39.2