diff --git a/indra/newview/NACLantispam.cpp b/indra/newview/NACLantispam.cpp index da97fca3cc..b7adba63a4 100644 --- a/indra/newview/NACLantispam.cpp +++ b/indra/newview/NACLantispam.cpp @@ -6,6 +6,7 @@ #include "llnotificationsutil.h" #include "llviewercontrol.h" #include "llviewerobjectlist.h" +#include "sound_ids.h" #include // NACLAntiSpamQueueEntry @@ -186,6 +187,11 @@ NACLAntiSpamRegistry::NACLAntiSpamRegistry() : { mQueues[queue] = new NACLAntiSpamQueue(mGlobalTime, mGlobalAmount); } + + for (S32 i = 0; i < COLLISION_SOUNDS_SIZE; ++i) + { + mCollisionSounds.insert(LLUUID(COLLISION_SOUNDS[i])); + } } NACLAntiSpamRegistry::~NACLAntiSpamRegistry() @@ -493,3 +499,8 @@ void NACLAntiSpamRegistry::purgeGlobalEntries() } mGlobalEntries.clear(); } + +bool NACLAntiSpamRegistry::isCollisionSound(const LLUUID& sound_id) +{ + return (mCollisionSounds.find(sound_id) != mCollisionSounds.end()); +} diff --git a/indra/newview/NACLantispam.h b/indra/newview/NACLantispam.h index df6e1f4614..e55b74cc0e 100644 --- a/indra/newview/NACLantispam.h +++ b/indra/newview/NACLantispam.h @@ -2,6 +2,7 @@ #define NACL_ANTISPAM_H #include +#include #include "fscommon.h" #include "lluuid.h" #include "llsingleton.h" @@ -44,6 +45,7 @@ private: }; typedef boost::unordered_map t_spam_queue_entry_map; +typedef boost::unordered_set t_collision_sound_set; class NACLAntiSpamQueue { @@ -93,6 +95,8 @@ public: void clearAllQueues(); void purgeAllQueues(); + bool isCollisionSound(const LLUUID& sound_id); + private: NACLAntiSpamRegistry(); ~NACLAntiSpamRegistry(); @@ -110,5 +114,6 @@ private: U32 mGlobalTime; U32 mGlobalAmount; bool mGlobalQueue; + t_collision_sound_set mCollisionSounds; }; #endif // NACL_ANTISPAM_H diff --git a/indra/newview/llviewermessage.cpp b/indra/newview/llviewermessage.cpp index 9a03bf9e06..332491c0ed 100644 --- a/indra/newview/llviewermessage.cpp +++ b/indra/newview/llviewermessage.cpp @@ -5529,22 +5529,16 @@ void process_sound_trigger(LLMessageSystem *msg, void **) } // NaCl - Antispam Registry - bool bDoSpamCheck = true; - std::string sSound = sound_id.asString(); static LLCachedControl _NACL_AntiSpamSoundMulti(gSavedSettings, "_NACL_AntiSpamSoundMulti"); static LLCachedControl FSPlayCollisionSounds(gSavedSettings, "FSPlayCollisionSounds"); - for (S32 i = 0; i < COLLISION_SOUNDS_SIZE; i++) //AO: Should probably do this as a hashmap O(1) instead of O(n) + if (NACLAntiSpamRegistry::instance().isCollisionSound(sound_id)) { - if (COLLISION_SOUNDS[i] == sSound) + if (!FSPlayCollisionSounds) { - if (!FSPlayCollisionSounds) - { - return; - } - bDoSpamCheck = false; + return; } } - if (bDoSpamCheck) + else { if (NACLAntiSpamRegistry::instance().checkQueue(ANTISPAM_QUEUE_SOUND, object_id, _NACL_AntiSpamSoundMulti)) {