Make asset blacklist sound flags actually work properly
parent
0a7523c3f1
commit
9798fae3d2
|
|
@ -40,7 +40,7 @@
|
|||
|
||||
const LLUUID MAGIC_ID("3c115e51-04f4-523c-9fa6-98aff1034730");
|
||||
|
||||
LLAssetType::EType S32toAssetType(S32 assetindex)
|
||||
static LLAssetType::EType S32toAssetType(S32 assetindex)
|
||||
{
|
||||
LLAssetType::EType type;
|
||||
switch (assetindex)
|
||||
|
|
@ -72,46 +72,36 @@ void FSAssetBlacklist::init()
|
|||
loadBlacklist();
|
||||
}
|
||||
|
||||
bool FSAssetBlacklist::isBlacklisted(const LLUUID& id, LLAssetType::EType type, eBlacklistFlag flag)
|
||||
bool FSAssetBlacklist::isBlacklisted(const LLUUID& id, LLAssetType::EType type, eBlacklistFlag flag) const
|
||||
{
|
||||
if (mBlacklistData.empty())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
blacklist_type_map_t::iterator it = mBlacklistTypeContainer.find(type);
|
||||
|
||||
if (it == mBlacklistTypeContainer.end())
|
||||
if (!mBlacklistTypeContainer.contains(type))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
blacklisted_uuid_container_t uuids = it->second;
|
||||
if (uuids.find(id) == uuids.end())
|
||||
if (!mBlacklistTypeContainer.at(type).contains(id))
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
if (flag == eBlacklistFlag::NONE)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
const auto& data_it = mBlacklistData.find(id);
|
||||
if (data_it == mBlacklistData.end())
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
const LLSD& data = data_it->second;
|
||||
if (!data.has("asset_blacklist_flag"))
|
||||
eBlacklistFlag stored_flag{ eBlacklistFlag::NONE };
|
||||
if (const LLSD& data = data_it->second; data.has("asset_blacklist_flag"))
|
||||
{
|
||||
return false;
|
||||
stored_flag = static_cast<eBlacklistFlag>(data["asset_blacklist_flag"].asInteger());
|
||||
}
|
||||
|
||||
eBlacklistFlag stored_flag = static_cast<eBlacklistFlag>(data["asset_blacklist_flag"].asInteger());
|
||||
|
||||
return (static_cast<S32>(stored_flag) & static_cast<S32>(flag)) != 0;
|
||||
return (stored_flag == eBlacklistFlag::NONE && flag == eBlacklistFlag::NONE) || (static_cast<S32>(stored_flag) & static_cast<S32>(flag)) != 0;
|
||||
}
|
||||
|
||||
void FSAssetBlacklist::addNewItemToBlacklist(const LLUUID& id, const std::string& name, const std::string& region, LLAssetType::EType type, eBlacklistFlag flag /*= eBlacklistFlag::NONE*/, bool permanent /*= true*/, bool save /*= true*/)
|
||||
|
|
@ -123,23 +113,19 @@ void FSAssetBlacklist::addNewItemToBlacklist(const LLUUID& id, const std::string
|
|||
|
||||
LLSD data;
|
||||
|
||||
if (isBlacklisted(id, type))
|
||||
if (auto it = mBlacklistData.find(id); it != mBlacklistData.end())
|
||||
{
|
||||
auto it = mBlacklistData.find(id);
|
||||
if (it != mBlacklistData.end())
|
||||
{
|
||||
data = it->second;
|
||||
data = it->second;
|
||||
|
||||
S32 existing_flag = data.has("asset_blacklist_flag") ? data["asset_blacklist_flag"].asInteger() : 0;
|
||||
data["asset_blacklist_flag"] = static_cast<S32>(existing_flag | static_cast<S32>(flag));
|
||||
S32 existing_flag = data.has("asset_blacklist_flag") ? data["asset_blacklist_flag"].asInteger() : 0;
|
||||
data["asset_blacklist_flag"] = static_cast<S32>(existing_flag | static_cast<S32>(flag));
|
||||
|
||||
data["asset_name"] = name;
|
||||
data["asset_region"] = region;
|
||||
data["asset_date"] = input_date;
|
||||
data["asset_permanent"] = permanent;
|
||||
data["asset_name"] = name;
|
||||
data["asset_region"] = region;
|
||||
data["asset_date"] = input_date;
|
||||
data["asset_permanent"] = permanent;
|
||||
|
||||
addNewItemToBlacklistData(id, data, save);
|
||||
}
|
||||
addNewItemToBlacklistData(id, data, save);
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
@ -211,7 +197,8 @@ void FSAssetBlacklist::removeItemsFromBlacklist(const uuid_vec_t& ids)
|
|||
}
|
||||
|
||||
void FSAssetBlacklist::removeFlagsFromItem(const LLUUID& id, S32 combined_flags)
|
||||
{auto it = mBlacklistData.find(id);
|
||||
{
|
||||
auto it = mBlacklistData.find(id);
|
||||
if (it == mBlacklistData.end())
|
||||
{
|
||||
return;
|
||||
|
|
@ -242,8 +229,7 @@ void FSAssetBlacklist::addNewItemToBlacklistData(const LLUUID& id, const LLSD& d
|
|||
{
|
||||
LLAssetType::EType type = S32toAssetType(data["asset_type"].asInteger());
|
||||
|
||||
auto it = mBlacklistData.find(id);
|
||||
if (it != mBlacklistData.end())
|
||||
if (auto it = mBlacklistData.find(id); it != mBlacklistData.end())
|
||||
{
|
||||
it->second = data;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -44,17 +44,18 @@ class FSAssetBlacklist : public LLSingleton<FSAssetBlacklist>
|
|||
LLSINGLETON_EMPTY_CTOR(FSAssetBlacklist);
|
||||
|
||||
public:
|
||||
void init();
|
||||
enum class eBlacklistFlag
|
||||
{
|
||||
NONE = 0,
|
||||
WORN = 1 << 0,
|
||||
REZZED = 1 << 1,
|
||||
NONE = 0,
|
||||
WORN = 1 << 0,
|
||||
REZZED = 1 << 1,
|
||||
GESTURE = 1 << 2,
|
||||
|
||||
LAST_FLAG = 1 << 2
|
||||
};
|
||||
bool isBlacklisted(const LLUUID& id, LLAssetType::EType type, eBlacklistFlag flag = eBlacklistFlag::NONE);
|
||||
|
||||
void init();
|
||||
bool isBlacklisted(const LLUUID& id, LLAssetType::EType type, eBlacklistFlag flag = eBlacklistFlag::NONE) const;
|
||||
void addNewItemToBlacklist(const LLUUID& id, const std::string& name, const std::string& region, LLAssetType::EType type, eBlacklistFlag flag = eBlacklistFlag::NONE,bool permanent = true, bool save = true);
|
||||
void addNewItemToBlacklistData(const LLUUID& id, const LLSD& data, bool save = true);
|
||||
void removeItemFromBlacklist(const LLUUID& id);
|
||||
|
|
|
|||
|
|
@ -99,7 +99,7 @@ FSAssetBlacklist::eBlacklistFlag FSFloaterAssetBlacklist::getFlagFromLLSD(const
|
|||
return FSAssetBlacklist::eBlacklistFlag::NONE;
|
||||
}
|
||||
|
||||
std::string FSFloaterAssetBlacklist::getTypeString(S32 type)
|
||||
std::string FSFloaterAssetBlacklist::getTypeString(S32 type) const
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
|
|
@ -118,7 +118,7 @@ std::string FSFloaterAssetBlacklist::getTypeString(S32 type)
|
|||
}
|
||||
}
|
||||
|
||||
std::string FSFloaterAssetBlacklist::getFlagString(FSAssetBlacklist::eBlacklistFlag flag)
|
||||
std::string FSFloaterAssetBlacklist::getFlagString(FSAssetBlacklist::eBlacklistFlag flag) const
|
||||
{
|
||||
switch (flag)
|
||||
{
|
||||
|
|
@ -179,25 +179,32 @@ void FSFloaterAssetBlacklist::addElementToList(const LLUUID& id, const LLSD& dat
|
|||
element["columns"][0]["column"] = "name";
|
||||
element["columns"][0]["type"] = "text";
|
||||
element["columns"][0]["value"] = !data["asset_name"].asString().empty() ? data["asset_name"].asString() : getString("unknown_object");
|
||||
|
||||
element["columns"][1]["column"] = "region";
|
||||
element["columns"][1]["type"] = "text";
|
||||
element["columns"][1]["value"] = !data["asset_region"].asString().empty() ? data["asset_region"].asString() : getString("unknown_region");
|
||||
|
||||
element["columns"][2]["column"] = "type";
|
||||
element["columns"][2]["type"] = "text";
|
||||
element["columns"][2]["value"] = getTypeString(asset_type);
|
||||
|
||||
element["columns"][3]["column"] = "flags";
|
||||
element["columns"][3]["type"] = "text";
|
||||
element["columns"][3]["value"] = getFlagString(flag);
|
||||
|
||||
element["columns"][4]["column"] = "date";
|
||||
element["columns"][4]["type"] = "text";
|
||||
element["columns"][4]["value"] = date_str;
|
||||
|
||||
element["columns"][5]["column"] = "permanent";
|
||||
element["columns"][5]["type"] = "text";
|
||||
element["columns"][5]["halign"] = "center";
|
||||
element["columns"][5]["value"] = data["asset_permanent"].asBoolean() ? getString("asset_permanent") : LLStringUtil::null;
|
||||
|
||||
element["columns"][6]["column"] = "date_sort";
|
||||
element["columns"][6]["type"] = "text";
|
||||
element["columns"][6]["value"] = llformat("%u", (U64)date.secondsSinceEpoch());
|
||||
|
||||
element["columns"][7]["column"] = "asset_type";
|
||||
element["columns"][7]["type"] = "integer";
|
||||
element["columns"][7]["value"] = data["asset_type"].asInteger();
|
||||
|
|
|
|||
|
|
@ -64,8 +64,8 @@ protected:
|
|||
void onSelectionChanged();
|
||||
|
||||
void buildBlacklist();
|
||||
std::string getTypeString(S32 type);
|
||||
std::string getFlagString(FSAssetBlacklist::eBlacklistFlag source);
|
||||
std::string getTypeString(S32 type) const;
|
||||
std::string getFlagString(FSAssetBlacklist::eBlacklistFlag source) const;
|
||||
static FSAssetBlacklist::eBlacklistFlag getFlagFromLLSD(const LLSD& data);
|
||||
|
||||
LLUUID mAudioSourceID;
|
||||
|
|
|
|||
|
|
@ -4691,22 +4691,23 @@ static bool is_sound_blacklisted(const LLUUID& sound_id, const LLUUID& object_id
|
|||
{
|
||||
return true;
|
||||
}
|
||||
else if (object_id == owner_id && blacklist.isBlacklisted(owner_id, LLAssetType::AT_SOUND, FSAssetBlacklist::eBlacklistFlag::GESTURE))
|
||||
else if (object_id == owner_id)
|
||||
{
|
||||
// Gesture sound
|
||||
return true;
|
||||
return blacklist.isBlacklisted(sound_id, LLAssetType::AT_SOUND, FSAssetBlacklist::eBlacklistFlag::GESTURE);
|
||||
}
|
||||
else if (LLViewerObject* object = gObjectList.findObject(object_id);
|
||||
object && object->isAttachment() &&
|
||||
blacklist.isBlacklisted(owner_id, LLAssetType::AT_SOUND, FSAssetBlacklist::eBlacklistFlag::WORN))
|
||||
else if (LLViewerObject* object = gObjectList.findObject(object_id))
|
||||
{
|
||||
// Attachment sound
|
||||
return true;
|
||||
}
|
||||
else if (blacklist.isBlacklisted(owner_id, LLAssetType::AT_SOUND, FSAssetBlacklist::eBlacklistFlag::REZZED))
|
||||
{
|
||||
// Rezzed object sound
|
||||
return true;
|
||||
if (object->isAttachment())
|
||||
{
|
||||
// Attachment sound
|
||||
return blacklist.isBlacklisted(sound_id, LLAssetType::AT_SOUND, FSAssetBlacklist::eBlacklistFlag::WORN);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Rezzed object sound
|
||||
return blacklist.isBlacklisted(sound_id, LLAssetType::AT_SOUND, FSAssetBlacklist::eBlacklistFlag::REZZED);
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
|
|
|
|||
|
|
@ -6596,24 +6596,6 @@ void LLViewerObject::setAttachedSound(const LLUUID &audio_uuid, const LLUUID& ow
|
|||
return;
|
||||
}
|
||||
|
||||
// <FS:Ansariel> Asset blacklist
|
||||
FSAssetBlacklist& blacklist = FSAssetBlacklist::instance();
|
||||
if (blacklist.isBlacklisted(audio_uuid, LLAssetType::AT_SOUND))
|
||||
{
|
||||
return;
|
||||
}
|
||||
else if (isAttachment() && blacklist.isBlacklisted(owner_id, LLAssetType::AT_SOUND, FSAssetBlacklist::eBlacklistFlag::WORN))
|
||||
{
|
||||
// Attachment sound
|
||||
return;
|
||||
}
|
||||
else if (blacklist.isBlacklisted(owner_id, LLAssetType::AT_SOUND, FSAssetBlacklist::eBlacklistFlag::REZZED))
|
||||
{
|
||||
// Rezzed object sound
|
||||
return;
|
||||
}
|
||||
// </FS:Ansariel>
|
||||
|
||||
if (flags & LL_SOUND_FLAG_LOOP
|
||||
&& mAudioSourcep && mAudioSourcep->isLoop() && mAudioSourcep->getCurrentData()
|
||||
&& mAudioSourcep->getCurrentData()->getID() == audio_uuid)
|
||||
|
|
|
|||
Loading…
Reference in New Issue