DEADSOFTWARE

fix some warnings
[flatwaifu.git] / src / music.c
index 1f0881584ba96fef761bbf69e010e22377002faf..4dc87c295fbfc66a3569e70939577c83772c4dac 100644 (file)
@@ -22,6 +22,7 @@
 
 #include "glob.h"
 #include "sound.h"
+#include "files.h"
 #include <SDL.h>
 #include <SDL_mixer.h>
 
@@ -64,9 +65,11 @@ void S_initmusic(void)
 
 void S_donemusic(void)
 {
-    F_freemus();
-    Mix_CloseAudio();
-    SDL_QuitSubSystem(SDL_INIT_AUDIO);
+    if (SDL_WasInit(SDL_INIT_AUDIO)) {
+        F_freemus();
+        Mix_CloseAudio();
+        SDL_QuitSubSystem(SDL_INIT_AUDIO);
+    }
 }
 
 void S_startmusic(int time)
@@ -175,22 +178,31 @@ void trans_ascii_str (char *dest, char *src)
 void F_loadmus(char n[8]) {
     if (musdisabled) return;
     char f[50];
+    char name[50];
 #ifndef WIN32
-    strcpy(f,"music/");
+    strcpy(f, "/usr/share/doom2d-rembo/music/");
 #else
-    strcpy(f,"music\\");
+    strcpy(f, "music\\");
 #endif
-    strncpy(&f[6], n, 8);
-    f[6+8]='\0';
-    muslo = Mix_LoadMUS(f);
-    if (muslo == NULL) {
-        char name[50];
+    int l = strlen(f);
+    strncpy(&f[l], n, 8);
+    f[l+8]='\0';
+    trans_ascii_str(name, f);
+    muslo = Mix_LoadMUS(name);
+    if (muslo == NULL)
+    {
+#ifndef WIN32
+        strcpy(f, "music/");
+        int l = strlen(f);
+        strncpy(&f[l], n, 8);
+        f[l+8]='\0';
         trans_ascii_str(name, f);
         muslo = Mix_LoadMUS(name);
-        if (!muslo) logo("Music not found '%s'\n", name);
+#endif
     }
-}
+    if (!muslo) logo("Music not found '%s'\n", name);
 
+}
 
 void F_freemus(void) {
     if (musdisabled) return;
@@ -201,7 +213,7 @@ void F_freemus(void) {
     muslo = NULL;
 }
 
-extern byte g_music[8];
+extern char g_music[8];
 
 static int volsetcount = 0;