]> git.mxchange.org Git - quix0rs-blobwars.git/commitdiff
Allow music tags to be stored in the pak file.
authorGuus Sliepen <guus@debian.org>
Sun, 13 Feb 2011 17:11:28 +0000 (18:11 +0100)
committerGuus Sliepen <guus@debian.org>
Sun, 13 Feb 2011 17:11:28 +0000 (18:11 +0100)
src/CAudio.cpp
src/CEngine.cpp
src/defs.h

index 40af208fc2b2966ab985451364dafe3cf433f3cb..f37aa30b7d16fa4faf19930c84cc226f6111d6b1 100644 (file)
@@ -110,8 +110,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 +136,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];
        
index a5a75acd34702c8d312d2fa45762dc402e0d9e67..7017039722123c54f5df2ad448a3a2297b5b4282 100644 (file)
@@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
 */
 
 #include "headers.h"
+#include <errno.h>
 
 Engine::Engine()
 {
@@ -365,7 +366,7 @@ bool Engine::unpack(const char *filename, int fileType)
                }
        }
 
-       if ((fileType == PAK_MUSIC) || (fileType == PAK_FONT))
+       if ((fileType == PAK_MUSIC) || (fileType == PAK_FONT) || (fileType == PAK_TAGS))
        {
                char tempPath[PATH_MAX];
                
@@ -377,6 +378,12 @@ bool Engine::unpack(const char *filename, int fileType)
                        fp = fopen(tempPath, "wb");
                }
 
+               if (fileType == PAK_TAGS)
+               {
+                       snprintf(tempPath, sizeof tempPath, "%smusic.tags", userHomeDirectory);
+                       fp = fopen(tempPath, "wb");
+               }
+
                if (fileType == PAK_FONT)
                {
                        snprintf(tempPath, sizeof tempPath, "%sfont.ttf", userHomeDirectory);
@@ -385,6 +392,7 @@ bool Engine::unpack(const char *filename, int fileType)
 
                if (!fp)
                {
+                       printf("Fatal Error: could not open %s for writing: %s", tempPath, strerror(errno));
                        return false;
                }
 
index bf2be4f86a9bb23323d4756c0f7981d7f16961fc..0664e3922758d09c51eea2af476663cae0b00a32 100644 (file)
@@ -372,7 +372,8 @@ enum {
        PAK_SOUND,
        PAK_MUSIC,
        PAK_DATA,
-       PAK_FONT
+       PAK_FONT,
+       PAK_TAGS
 };
 
 /* ############# debug ################## */