summaryrefslogtreecommitdiff
path: root/src/resources/soundeffect.cpp
diff options
context:
space:
mode:
authorBjørn Lindeijer <bjorn@lindeijer.nl>2005-10-09 03:34:45 +0000
committerBjørn Lindeijer <bjorn@lindeijer.nl>2005-10-09 03:34:45 +0000
commit8bde9095c5840b8d62ebafe11beaed98877d6ac2 (patch)
tree537f717a339d1247cae222eb7a354ea5dbe8babf /src/resources/soundeffect.cpp
parenta246c08cef5e4d598fc07a681eb971bfbcf01519 (diff)
downloadmana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.gz
mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.bz2
mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.tar.xz
mana-8bde9095c5840b8d62ebafe11beaed98877d6ac2.zip
* Made Sprite into an interface implemented by both FloorItem and Being, which
hook themselves into the map on construction. The improved fringe layer is working as expected now. * Made sure TMW compiles without warnings even when using "-Wconversion -Wshadow -Wcast-qual -Wwrite-strings -ansi -pedantic", lots of cleanups. * Added two new small tilesets that contain the desert tiles that are twice and three times the height of a normal tile. One well in new_3-1 has been converted to use the new double tiles for testing purposes.
Diffstat (limited to 'src/resources/soundeffect.cpp')
-rw-r--r--src/resources/soundeffect.cpp22
1 files changed, 12 insertions, 10 deletions
diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp
index 7c77d5b7..3340e5ea 100644
--- a/src/resources/soundeffect.cpp
+++ b/src/resources/soundeffect.cpp
@@ -24,34 +24,36 @@
#include "soundeffect.h"
SoundEffect::SoundEffect(const std::string &idPath, Mix_Chunk *soundEffect):
- Resource(idPath), soundEffect(soundEffect)
+ Resource(idPath),
+ mChunk(soundEffect)
{
}
SoundEffect::~SoundEffect()
{
- Mix_FreeChunk(soundEffect);
- soundEffect = NULL;
+ Mix_FreeChunk(mChunk);
}
-SoundEffect* SoundEffect::load(void* buffer, unsigned int bufferSize, const std::string &idPath)
+SoundEffect*
+SoundEffect::load(void *buffer, unsigned int bufferSize,
+ const std::string &idPath)
{
// Load the raw file data from the buffer in an RWops structure
SDL_RWops *rw = SDL_RWFromMem(buffer, bufferSize);
// Use Mix_LoadWAV_RW to load the raw music data
Mix_Chunk *tmpSoundEffect = Mix_LoadWAV_RW(rw, 0);
-
+
// Now free the SDL_RWops data
SDL_FreeRW(rw);
return new SoundEffect(idPath, tmpSoundEffect);
}
-bool SoundEffect::play(int loops, int volume)
+bool
+SoundEffect::play(int loops, int volume)
{
- Mix_VolumeChunk(soundEffect, volume);
- if (Mix_PlayChannel(-1, soundEffect, loops) != -1)
- return true;
- return false;
+ Mix_VolumeChunk(mChunk, volume);
+
+ return Mix_PlayChannel(-1, mChunk, loops) != -1;
}