]> git.mxchange.org Git - quix0rs-blobwars.git/blobdiff - src/CAudio.cpp
Mention that we are now using SDL2 in the manual and intro screen.
[quix0rs-blobwars.git] / src / CAudio.cpp
index 521c18ba750ea5a34fd1d864ebbea56a05a08b5a..98d1a86babce839a9c57e859081d8c7d0061497d 100644 (file)
@@ -1,5 +1,6 @@
 /*
-Copyright (C) 2004 Parallel Realities
+Copyright (C) 2004-2011 Parallel Realities
+Copyright (C) 2011-2015 Perpendicular Dimensions
 
 This program is free software; you can redistribute it and/or
 modify it under the terms of the GNU General Public License
@@ -110,8 +111,6 @@ bool Audio::loadMusic(const char *filename)
 
        remove(tempPath);
        
-       SDL_Delay(250); // wait a bit, just to be sure!
-
        if (music != NULL)
        {
                Mix_HaltMusic();
@@ -138,7 +137,15 @@ bool Audio::loadMusic(const char *filename)
                return false;
        }
 
-       snprintf(tempPath, sizeof tempPath, "%s.tags", filename);
+       #if USEPAK
+               snprintf(tempPath, sizeof tempPath, "%smusic.tags", engine->userHomeDirectory);
+               remove(tempPath);
+               char tagfilename[PATH_MAX];
+               snprintf(tagfilename, sizeof tagfilename, "%s.tags", filename);
+               engine->unpack(tagfilename, PAK_TAGS);
+       #else
+               snprintf(tempPath, sizeof tempPath, "%s.tags", filename);
+       #endif
        FILE *fp = fopen(tempPath, "r");
        char line[1024];
        
@@ -149,11 +156,11 @@ bool Audio::loadMusic(const char *filename)
                        line[l - 1] = 0;
 
                if(!strncasecmp(line, "title=", 6))
-                        strncpy(songtitle, line + 6, sizeof songtitle);
+                        strlcpy(songtitle, line + 6, sizeof songtitle);
                else if(!strncasecmp(line, "album=", 6))
-                        strncpy(songalbum, line + 6, sizeof songalbum);
+                        strlcpy(songalbum, line + 6, sizeof songalbum);
                else if(!strncasecmp(line, "artist=", 7))
-                        strncpy(songartist, line + 7, sizeof songartist);
+                        strlcpy(songartist, line + 7, sizeof songartist);
                else if(!strncasecmp(line, "license=", 8))
                {
                        if(!strncasecmp(line + 8, "CC-BY ", 6))
@@ -166,7 +173,7 @@ bool Audio::loadMusic(const char *filename)
        if(fp)
                fclose(fp);
        
-       strncpy(levelMusicName, filename, sizeof levelMusicName);
+       strlcpy(levelMusicName, filename, sizeof levelMusicName);
 
        return true;
 }