summaryrefslogtreecommitdiff
path: root/src/resources/loaders/soundloader.cpp
diff options
context:
space:
mode:
authorAndrei Karas <akaras@inbox.ru>2016-07-28 19:54:02 +0300
committerAndrei Karas <akaras@inbox.ru>2016-07-28 19:54:02 +0300
commit442a2dd0a4417182cbdd9f9fefb45bda4914e3d7 (patch)
tree9208c3b353bfd89009e35f21fa4c29670bfc1579 /src/resources/loaders/soundloader.cpp
parent6b2264b7c5f2b1dba3360eb090ad1dd0052d7afb (diff)
downloadmanaverse-442a2dd0a4417182cbdd9f9fefb45bda4914e3d7.tar.gz
manaverse-442a2dd0a4417182cbdd9f9fefb45bda4914e3d7.tar.bz2
manaverse-442a2dd0a4417182cbdd9f9fefb45bda4914e3d7.tar.xz
manaverse-442a2dd0a4417182cbdd9f9fefb45bda4914e3d7.zip
Move soundeffect load code into soundloader.
Diffstat (limited to 'src/resources/loaders/soundloader.cpp')
-rw-r--r--src/resources/loaders/soundloader.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/resources/loaders/soundloader.cpp b/src/resources/loaders/soundloader.cpp
index b39c5fcbe..8c325db7c 100644
--- a/src/resources/loaders/soundloader.cpp
+++ b/src/resources/loaders/soundloader.cpp
@@ -36,7 +36,6 @@ namespace
struct ResourceLoader final
{
std::string path;
- ResourceManager::loader fun;
static Resource *load(const void *const v)
{
@@ -51,15 +50,26 @@ namespace
rl->path.c_str());
return nullptr;
}
- Resource *const res = rl->fun(rw, rl->path);
- return res;
+ // Load the music data and free the RWops structure
+ Mix_Chunk *const tmpSoundEffect = Mix_LoadWAV_RW(rw, 1);
+
+ if (tmpSoundEffect)
+ {
+ return new SoundEffect(tmpSoundEffect, rl->path);
+ }
+ else
+ {
+ reportAlways("Error, failed to load sound effect: %s",
+ Mix_GetError());
+ return nullptr;
+ }
}
};
} // namespace
SoundEffect *Loader::getSoundEffect(const std::string &idPath)
{
- ResourceLoader rl = { idPath, &SoundEffect::load };
+ ResourceLoader rl = { idPath };
return static_cast<SoundEffect*>(resourceManager->get(
idPath, ResourceLoader::load, &rl));
}