From 092bf185fc056338bcde2749a304e576edf342fd Mon Sep 17 00:00:00 2001 From: Bjørn Lindeijer Date: Sun, 3 Dec 2006 13:32:07 +0000 Subject: Don't try to play empty strings as sounds, and don't return a SoundEffect instance when Mix_Chunk loading failed. --- ChangeLog | 62 ++++++++++++++++++++++----------------- NEWS | 4 ++- src/monster.cpp | 4 +-- src/resources/resourcemanager.cpp | 4 +-- src/resources/soundeffect.cpp | 19 ++++++++---- src/sound.cpp | 6 ++-- src/sound.h | 4 ++- 7 files changed, 61 insertions(+), 42 deletions(-) diff --git a/ChangeLog b/ChangeLog index 13519a96..6475033c 100644 --- a/ChangeLog +++ b/ChangeLog @@ -1,35 +1,43 @@ +2006-12-03 Bjørn Lindeijer + + * src/sound.cpp, src/monster.cpp, src/sound.h, + src/resources/soundeffect.cpp, src/resources/resourcemanager.cpp: + Don't try to play empty strings as sounds, and don't return a + SoundEffect instance when Mix_Chunk loading failed. + 2006-12-02 Philipp Sehmisch - * data/graphics/sprites/chest-leather-female.png: A little correction at the - female leather shirt by mangamaniac. + * data/graphics/sprites/chest-leather-female.png: A little correction + at the female leather shirt by mangamaniac. 2006-12-01 Philipp Sehmisch - * src/net/beinghandler.cpp, src/being.h, src/being.cpp, src/monster.h, - src/gui/gui.cpp: - Visible equipment slot numbers are now converted by the beinghandler from - eAthena to our system. No more distinction between monster attacking and - player attacking between beinghandler and the being classes. - * src/being.cpp, src/monster.cpp, src/being.h, src/monster.h: Moved the - monster specific action handling into the monster class. - * monster.cpp, mosterinfo.cpp, monsterinfo.h: Monsters now make sounds when - they attack, gett hurt or die. - * src/being.cpp: Delayed the damage numbers a bit to synchronize them better - with the hurt sounds. - * data/monsters.xml, data/sfx//bat-dying1.ogg, data/sfx/bat-hit1.ogg, - data/sfx/bow_shoot_1.ogg, data/sfx/fire-goblin-hit1.ogg, - data/sfx/fire-goblin-hit2.ogg, data/sfx/fire-goblin-miss1.ogg, - data/sfx/fist-swish.ogg, data/sfx/flower-hit1.ogg, data/sfx/flower-hit2.ogg, - data/sfx/flower-miss1.ogg, data/sfx/fluffy-hit1.ogg, - data/sfx/fluffy-hit2.ogg, data/sfx/fluffy-hit3.ogg, - data/sfx/fluffy-hurt1.ogg, data/sfx/fluffy-miss1.ogg, - data/sfx/knife-hit1.ogg, data/sfx/knife-miss1.ogg, data/sfx/levelup.ogg, - data/sfx/scorpion-hit1.ogg, data/sfx/scorpion-hit2.ogg, - data/sfx/scorpion-hit3.ogg, data/sfx/scorpion-hit4.ogg, - data/sfx/scorpion-miss1.ogg, data/sfx/short-sword-hit1.ogg, - data/sfx/short-sword-miss1.ogg, data/sfx/shroom-hit1.ogg, - data/sfx/slime-hit1.ogg, data/sfx/Makefile.AM, data/sfx/CMakeLists.txt: - Added a lot of sound effects by Cosmostrator. + * src/net/beinghandler.cpp, src/being.h, src/being.cpp, src/monster.h, + src/gui/gui.cpp: Visible equipment slot numbers are now converted by + the beinghandler from eAthena to our system. No more distinction + between monster attacking and player attacking between beinghandler + and the being classes. + * src/being.cpp, src/monster.cpp, src/being.h, src/monster.h: Moved + the monster specific action handling into the monster class. + * monster.cpp, mosterinfo.cpp, monsterinfo.h: Monsters now make sounds + when they attack, gett hurt or die. + * src/being.cpp: Delayed the damage numbers a bit to synchronize them + better with the hurt sounds. + * data/monsters.xml, data/sfx//bat-dying1.ogg, data/sfx/bat-hit1.ogg, + data/sfx/bow_shoot_1.ogg, data/sfx/fire-goblin-hit1.ogg, + data/sfx/fire-goblin-hit2.ogg, data/sfx/fire-goblin-miss1.ogg, + data/sfx/fist-swish.ogg, data/sfx/flower-hit1.ogg, + data/sfx/flower-hit2.ogg, data/sfx/flower-miss1.ogg, + data/sfx/fluffy-hit1.ogg, data/sfx/fluffy-hit2.ogg, + data/sfx/fluffy-hit3.ogg, data/sfx/fluffy-hurt1.ogg, + data/sfx/fluffy-miss1.ogg, data/sfx/knife-hit1.ogg, + data/sfx/knife-miss1.ogg, data/sfx/levelup.ogg, + data/sfx/scorpion-hit1.ogg, data/sfx/scorpion-hit2.ogg, + data/sfx/scorpion-hit3.ogg, data/sfx/scorpion-hit4.ogg, + data/sfx/scorpion-miss1.ogg, data/sfx/short-sword-hit1.ogg, + data/sfx/short-sword-miss1.ogg, data/sfx/shroom-hit1.ogg, + data/sfx/slime-hit1.ogg, data/sfx/Makefile.AM, + data/sfx/CMakeLists.txt: Added a lot of sound effects by Cosmostrator. 2006-11-30 Bjørn Lindeijer diff --git a/NEWS b/NEWS index 0135b579..f3b586f8 100644 --- a/NEWS +++ b/NEWS @@ -1,4 +1,6 @@ -0.0.21.2 (...) +0.0.22 (...) +- Added support for female-specific equipment graphics +- Added support for monster sounds - Changed to new update host (http://updates.themanaworld.org) - Worked around a Guichan exception thrown for mice with many buttons - Changed mouse walk to keep following mouse while button is held down diff --git a/src/monster.cpp b/src/monster.cpp index f624ff07..68e9d6ba 100644 --- a/src/monster.cpp +++ b/src/monster.cpp @@ -73,11 +73,11 @@ Monster::setAction(Uint8 action) break; case DEAD: currentAction = ACTION_DEAD; - sound.playSfx(MonsterDB::get(mJob-1002).getSound(EVENT_DIE).c_str()); + sound.playSfx(MonsterDB::get(mJob - 1002).getSound(EVENT_DIE)); break; case ATTACK: currentAction = ACTION_ATTACK; - sound.playSfx(MonsterDB::get(mJob-1002).getSound(EVENT_HIT).c_str()); + sound.playSfx(MonsterDB::get(mJob - 1002).getSound(EVENT_HIT)); mSprites[BASE_SPRITE]->reset(); break; case STAND: diff --git a/src/resources/resourcemanager.cpp b/src/resources/resourcemanager.cpp index 9ad18db3..4ed316cf 100644 --- a/src/resources/resourcemanager.cpp +++ b/src/resources/resourcemanager.cpp @@ -174,9 +174,9 @@ ResourceManager::get(const E_RESOURCE_TYPE &type, const std::string &idPath) free(buffer); - if (resource) { + if (resource) + { resource->incRef(); - mResources[idPath] = resource; } diff --git a/src/resources/soundeffect.cpp b/src/resources/soundeffect.cpp index 3340e5ea..bb35218e 100644 --- a/src/resources/soundeffect.cpp +++ b/src/resources/soundeffect.cpp @@ -23,6 +23,8 @@ #include "soundeffect.h" +#include "../log.h" + SoundEffect::SoundEffect(const std::string &idPath, Mix_Chunk *soundEffect): Resource(idPath), mChunk(soundEffect) @@ -41,13 +43,18 @@ SoundEffect::load(void *buffer, unsigned int bufferSize, // 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); + // Load the music data and free the RWops structure + Mix_Chunk *tmpSoundEffect = Mix_LoadWAV_RW(rw, 1); - return new SoundEffect(idPath, tmpSoundEffect); + if (tmpSoundEffect) + { + return new SoundEffect(idPath, tmpSoundEffect); + } + else + { + logger->log("Error while loading sound effect (%s)", idPath.c_str()); + return NULL; + } } bool diff --git a/src/sound.cpp b/src/sound.cpp index 8b012176..1ef4c23d 100644 --- a/src/sound.cpp +++ b/src/sound.cpp @@ -191,15 +191,15 @@ void Sound::fadeOutMusic(int ms) } } -void Sound::playSfx(const char *path) +void Sound::playSfx(const std::string &path) { - if (!mInstalled) return; + if (!mInstalled || path.length() == 0) return; ResourceManager *resman = ResourceManager::getInstance(); SoundEffect *sample = resman->getSoundEffect(path); if (sample) { + logger->log("Sound::playSfx() Playing: %s", path.c_str()); sample->play(0, 120); - logger->log("Sound::playSfx() Playing: %s", path); } } diff --git a/src/sound.h b/src/sound.h index 39901121..07db0587 100644 --- a/src/sound.h +++ b/src/sound.h @@ -26,6 +26,8 @@ #include +#include + /** Sound engine * * \ingroup CORE @@ -105,7 +107,7 @@ class Sound { * * \param path Full path to file */ - void playSfx(const char *path); + void playSfx(const std::string &path); private: bool mInstalled; -- cgit v1.2.3-60-g2f50