From 67d3b8c193b51bbf892fd965547746511e8ddf87 Mon Sep 17 00:00:00 2001 From: Andrei Karas Date: Tue, 16 Apr 2013 23:06:58 +0300 Subject: add delay to action sounds. delay now unused. --- src/resources/iteminfo.cpp | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) (limited to 'src/resources/iteminfo.cpp') diff --git a/src/resources/iteminfo.cpp b/src/resources/iteminfo.cpp index 4ec5d81f9..a6372ca93 100644 --- a/src/resources/iteminfo.cpp +++ b/src/resources/iteminfo.cpp @@ -23,6 +23,7 @@ #include "resources/iteminfo.h" #include "resources/itemdb.h" + #include "configuration.h" #include "utils/dtor.h" @@ -105,22 +106,24 @@ void ItemInfo::setAttackAction(const std::string &attackAction) mAttackAction = attackAction; } -void ItemInfo::addSound(const EquipmentSoundEvent event, - const std::string &filename) +void ItemInfo::addSound(const SoundEvent event, + const std::string &filename, const int delay) { - mSounds[event].push_back(paths.getStringValue("sfx").append(filename)); + mSounds[event].push_back(SoundInfo( + paths.getStringValue("sfx").append(filename), delay)); } -const std::string &ItemInfo::getSound(const EquipmentSoundEvent event) const +const SoundInfo &ItemInfo::getSound(const SoundEvent event) const { - static const std::string empty; - std::map::const_iterator i; + static const SoundInfo empty("", 0); + std::map::const_iterator i; i = mSounds.find(event); if (i == mSounds.end()) return empty; - return (!i->second.empty()) ? i->second[rand() % i->second.size()] : empty; + return (!i->second.empty()) ? i->second[rand() + % i->second.size()] : empty; } std::map *ItemInfo::addReplaceSprite(const int sprite, -- cgit v1.2.3-70-g09d2