summaryrefslogtreecommitdiff
path: root/src/sound.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/sound.cpp')
-rw-r--r--src/sound.cpp19
1 files changed, 18 insertions, 1 deletions
diff --git a/src/sound.cpp b/src/sound.cpp
index a366f28d..6fb75d84 100644
--- a/src/sound.cpp
+++ b/src/sound.cpp
@@ -20,6 +20,7 @@
*/
#include <SDL.h>
+#include <physfs.h>
#include "log.h"
#include "sound.h"
@@ -141,7 +142,23 @@ static Mix_Music *loadMusic(const std::string &filename)
ResourceManager *resman = ResourceManager::getInstance();
std::string path = resman->getPath("music/" + filename);
- logger->log("Loading music \"%s\"", path.c_str());
+ if (path.find(".zip/") != std::string::npos ||
+ path.find(".zip\\") != std::string::npos)
+ {
+ // Music file is a virtual file inside a zip archive - we have to copy
+ // it to a temporary physical file so that SDL_mixer can stream it.
+ logger->log("Loading music \"%s\" from temporary file tempMusic.ogg",
+ path.c_str());
+ bool success = resman->copyFile("music/" + filename, "tempMusic.ogg");
+ if (success)
+ {
+ path = resman->getPath("tempMusic.ogg");
+ } else {
+ return NULL;
+ }
+ } else {
+ logger->log("Loading music \"%s\"", path.c_str());
+ }
Mix_Music *music = Mix_LoadMUS(path.c_str());