From: Guus Sliepen Date: Sun, 13 Feb 2011 17:11:28 +0000 (+0100) Subject: Allow music tags to be stored in the pak file. X-Git-Url: https://git.mxchange.org/?a=commitdiff_plain;h=d524487b69db73902c2d93a89e3fd5a3a730c919;p=quix0rs-blobwars.git Allow music tags to be stored in the pak file. --- diff --git a/src/CAudio.cpp b/src/CAudio.cpp index 40af208..f37aa30 100644 --- a/src/CAudio.cpp +++ b/src/CAudio.cpp @@ -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]; diff --git a/src/CEngine.cpp b/src/CEngine.cpp index a5a75ac..7017039 100644 --- a/src/CEngine.cpp +++ b/src/CEngine.cpp @@ -19,6 +19,7 @@ Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. */ #include "headers.h" +#include 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; } diff --git a/src/defs.h b/src/defs.h index bf2be4f..0664e39 100644 --- a/src/defs.h +++ b/src/defs.h @@ -372,7 +372,8 @@ enum { PAK_SOUND, PAK_MUSIC, PAK_DATA, - PAK_FONT + PAK_FONT, + PAK_TAGS }; /* ############# debug ################## */