shithub: choc

Download patch

ref: 77ad7dc5f88eafb2d0c502957ae879fab073200d
parent: 2c7e16c3e4fcebf4eae907eb76da33dc86c8ea63
author: Simon Howard <[email protected]>
date: Wed Jan 25 15:53:30 EST 2017

music: Add config variable for music packs path.

The current setup where you have to extract the music packs in your
config directory is rather awkward and inflexible. Instead, add a
config variable 'music_pack_path' to specify where to find extracted
music packs.

First part of #843.

--- a/src/i_sdlmusic.c
+++ b/src/i_sdlmusic.c
@@ -111,6 +111,7 @@
 static boolean musicpaused = false;
 static int current_music_volume;
 
+char *music_pack_path = "";
 char *timidity_cfg_path = "";
 
 static char *temp_timidity_cfg = NULL;
@@ -672,7 +673,14 @@
     char *path;
     unsigned int i;
 
-    if (!strcmp(configdir, ""))
+    // We can configure the path to music packs using the music_pack_path
+    // configuration variable. Otherwise we use the current directory, or
+    // $configdir/music to look for .cfg files.
+    if (strcmp(music_pack_path, "") != 0)
+    {
+        musicdir = M_StringJoin(music_pack_path, DIR_SEPARATOR_S, NULL);
+    }
+    else if (!strcmp(configdir, ""))
     {
         musicdir = M_StringDuplicate("");
     }
--- a/src/i_sound.c
+++ b/src/i_sound.c
@@ -75,6 +75,7 @@
 
 // For native music module:
 
+extern char *music_pack_path;
 extern char *timidity_cfg_path;
 
 // DOS-specific options: These are unused but should be maintained
@@ -450,6 +451,7 @@
     M_BindIntVariable("opl_io_port",             &opl_io_port);
     M_BindIntVariable("snd_pitchshift",          &snd_pitchshift);
 
+    M_BindStringVariable("music_pack_path",      &music_pack_path);
     M_BindStringVariable("timidity_cfg_path",    &timidity_cfg_path);
     M_BindStringVariable("gus_patch_path",       &gus_patch_path);
     M_BindIntVariable("gus_ram_kb",              &gus_ram_kb);
--- a/src/m_config.c
+++ b/src/m_config.c
@@ -889,6 +889,15 @@
     CONFIG_VARIABLE_FLOAT(libsamplerate_scale),
 
     //!
+    // Full path to a directory containing configuration files for
+    // substitute music packs. These packs contain high quality renderings
+    // of game music to be played instead of using the system's built-in
+    // MIDI playback.
+    //
+
+    CONFIG_VARIABLE_STRING(music_pack_path),
+
+    //!
     // Full path to a Timidity configuration file to use for MIDI
     // playback. The file will be evaluated from the directory where
     // it is evaluated, so there is no need to add "dir" commands