FIRE-31508: check folder limit before attaching all the things in a folder

meow-7.2.2
Angeldark Raymaker 2024-08-14 22:49:28 +01:00
parent 1d4269a28c
commit 11cbf8a3dc
2 changed files with 55 additions and 16 deletions

View File

@ -3680,6 +3680,11 @@ void LLFolderBridge::performAction(LLInventoryModel* model, std::string action)
// <FS:TT> Patch: ReplaceWornItemsOnly
else if ("replaceitems" == action)
{
//<FS:AR> FIRE-31508: check folder limit
if (modifyOutfitExceedsWearFolderLimit())
return;
//</FS:AR> FIRE-31508
LLInventoryModel* model = getInventoryModel();
if(!model) return;
LLViewerInventoryCategory* cat = getCategory();
@ -5368,6 +5373,35 @@ void LLFolderBridge::createWearable(LLFolderBridge* bridge, LLWearableType::ETyp
LLAgentWearables::createWearable(type, false, parent_id);
}
//<FS:AR> FIRE-31508: refactored from void LLFolderBridge::modifyOutfit(BOOL append)
bool LLFolderBridge::modifyOutfitExceedsWearFolderLimit()
{
LLInventoryModel *model = getInventoryModel();
if (!model)
return false;
LLViewerInventoryCategory *cat = getCategory();
if (!cat)
return false;
// checking amount of items to wear
U32 max_items = gSavedSettings.getU32("WearFolderLimit");
LLInventoryModel::cat_array_t cats;
LLInventoryModel::item_array_t items;
LLFindWearablesEx not_worn(/*is_worn=*/false, /*include_body_parts=*/false);
gInventory.collectDescendentsIf(cat->getUUID(), cats, items, LLInventoryModel::EXCLUDE_TRASH, not_worn);
if (items.size() > max_items)
{
LLSD args;
args["AMOUNT"] = llformat("%d", max_items);
LLNotificationsUtil::add("TooManyWearables", args);
return true;
}
return false;
}
//</FS:AR> FIRE-31508
void LLFolderBridge::modifyOutfit(BOOL append)
{
LLInventoryModel* model = getInventoryModel();
@ -5375,24 +5409,28 @@ void LLFolderBridge::modifyOutfit(BOOL append)
LLViewerInventoryCategory* cat = getCategory();
if(!cat) return;
// checking amount of items to wear
U32 max_items = gSavedSettings.getU32("WearFolderLimit");
LLInventoryModel::cat_array_t cats;
LLInventoryModel::item_array_t items;
LLFindWearablesEx not_worn(/*is_worn=*/ false, /*include_body_parts=*/ false);
gInventory.collectDescendentsIf(cat->getUUID(),
cats,
items,
LLInventoryModel::EXCLUDE_TRASH,
not_worn);
//<FS:AR> FIRE-31508: refactored to bool modifyOutfitExceedsWearFolderLimit(), rather than duplicating code
//// checking amount of items to wear
//U32 max_items = gSavedSettings.getU32("WearFolderLimit");
//LLInventoryModel::cat_array_t cats;
//LLInventoryModel::item_array_t items;
//LLFindWearablesEx not_worn(/*is_worn=*/ false, /*include_body_parts=*/ false);
//gInventory.collectDescendentsIf(cat->getUUID(),
// cats,
// items,
// LLInventoryModel::EXCLUDE_TRASH,
// not_worn);
if (items.size() > max_items)
{
LLSD args;
args["AMOUNT"] = llformat("%d", max_items);
LLNotificationsUtil::add("TooManyWearables", args);
//if (items.size() > max_items)
//{
// LLSD args;
// args["AMOUNT"] = llformat("%d", max_items);
// LLNotificationsUtil::add("TooManyWearables", args);
// return;
//}
if (modifyOutfitExceedsWearFolderLimit())
return;
}
//</FS:AR> FIRE-31508
if (isAgentInventory())
{

View File

@ -389,6 +389,7 @@ protected:
BOOL checkFolderForContentsOfType(LLInventoryModel* model, LLInventoryCollectFunctor& typeToCheck);
bool modifyOutfitExceedsWearFolderLimit(); //<FS:AR> FIRE-31508
void modifyOutfit(BOOL append);
void copyOutfitToClipboard();
void determineFolderType();