summaryrefslogtreecommitdiff
path: root/src/sound.cpp
diff options
context:
space:
mode:
authorPhilipp Sehmisch <crush@themanaworld.org>2009-04-16 20:55:59 +0200
committerPhilipp Sehmisch <crush@themanaworld.org>2009-04-16 21:14:40 +0200
commitdac1c9d9b9558053ab9fc96eac8772604b8eedf2 (patch)
tree7077f0300e6ae39d7de27aae29eb0c4bb06069b5 /src/sound.cpp
parent255c491375005abb1d2de22fa5aa1a821ac3a4f6 (diff)
downloadmana-dac1c9d9b9558053ab9fc96eac8772604b8eedf2.tar.gz
mana-dac1c9d9b9558053ab9fc96eac8772604b8eedf2.tar.bz2
mana-dac1c9d9b9558053ab9fc96eac8772604b8eedf2.tar.xz
mana-dac1c9d9b9558053ab9fc96eac8772604b8eedf2.zip
Added support for playing music in zip files.
Diffstat (limited to 'src/sound.cpp')
-rw-r--r--src/sound.cpp14
1 files changed, 13 insertions, 1 deletions
diff --git a/src/sound.cpp b/src/sound.cpp
index 3686d009..39651045 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,18 @@ 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());
+ resman->moveFile("music/" + filename, "tempMusic.ogg");
+ path = resman->getPath("tempMusic.ogg");
+ } else {
+ logger->log("Loading music \"%s\"", path.c_str());
+ }
Mix_Music *music = Mix_LoadMUS(path.c_str());