]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/CAudio.cpp
Remove a debug message.
[quix0rs-blobwars.git] / src / CAudio.cpp
index c985f5e3c92de3e95827f68fcbe4b3d682f94d26..521c18ba750ea5a34fd1d864ebbea56a05a08b5a 100644 (file)
@@ -35,6 +35,10 @@ Audio::Audio()
        quickSound = NULL;
        
        levelMusicName[0] = 0;
+       songtitle[0] = 0;
+       songalbum[0] = 0;
+       songartist[0] = 0;
+       songlicense = -1;
 }
 
 void Audio::setSoundVolume(int soundVolume)
@@ -123,12 +127,45 @@ bool Audio::loadMusic(const char *filename)
                music = Mix_LoadMUS(filename);
        #endif
 
+       songtitle[0] = 0;
+       songalbum[0] = 0;
+       songartist[0] = 0;
+       songlicense = -1;
+
        if (!music)
        {
                debug(("WARNING - Failed to load %s\n", filename));
                return false;
        }
-               
+
+       snprintf(tempPath, sizeof tempPath, "%s.tags", filename);
+       FILE *fp = fopen(tempPath, "r");
+       char line[1024];
+       
+       while(fp && fgets(line, sizeof line, fp))
+       {
+               int l = strlen(line);
+               if(line[l - 1] == '\n')
+                       line[l - 1] = 0;
+
+               if(!strncasecmp(line, "title=", 6))
+                        strncpy(songtitle, line + 6, sizeof songtitle);
+               else if(!strncasecmp(line, "album=", 6))
+                        strncpy(songalbum, line + 6, sizeof songalbum);
+               else if(!strncasecmp(line, "artist=", 7))
+                        strncpy(songartist, line + 7, sizeof songartist);
+               else if(!strncasecmp(line, "license=", 8))
+               {
+                       if(!strncasecmp(line + 8, "CC-BY ", 6))
+                               songlicense = 0;
+                       else if(!strncasecmp(line + 8, "CC-BY-SA ", 9))
+                               songlicense = 1;
+               }
+       }
+
+       if(fp)
+               fclose(fp);
+       
        strncpy(levelMusicName, filename, sizeof levelMusicName);
 
        return true;
@@ -202,10 +239,10 @@ bool Audio::loadGameOverMusic()
        }
 
        #if USEPAK
-               engine->unpack("music/friendDied.mod", PAK_MUSIC);
+               engine->unpack("music/gameover", PAK_MUSIC);
                music = Mix_LoadMUS(tempPath);
        #else
-               music = Mix_LoadMUS("music/friendDied.mod");
+               music = Mix_LoadMUS("music/gameover");
        #endif
 
        if (!music)