diff options
author | Merov Linden <merov@lindenlab.com> | 2015-04-13 15:29:56 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2015-04-13 15:29:56 -0700 |
commit | 637e096d5718d0a174b5383aa29e3480edd734ea (patch) | |
tree | d7ad5d848ab9c3448f8f0a4d80b74ab1bc743893 /indra/newview | |
parent | a9c3681cb5eecc043dab3f5c9dc9d97bc1af1075 (diff) |
DD-388 : More resilient way of reacting to not evaluated stock count throughout marketplace handling
Diffstat (limited to 'indra/newview')
-rwxr-xr-x | indra/newview/llfolderviewmodelinventory.cpp | 8 | ||||
-rwxr-xr-x | indra/newview/llinventorybridge.cpp | 14 | ||||
-rwxr-xr-x | indra/newview/llinventoryfunctions.cpp | 18 | ||||
-rwxr-xr-x | indra/newview/llinventoryfunctions.h | 4 | ||||
-rwxr-xr-x | indra/newview/llmarketplacefunctions.cpp | 36 |
5 files changed, 63 insertions, 17 deletions
diff --git a/indra/newview/llfolderviewmodelinventory.cpp b/indra/newview/llfolderviewmodelinventory.cpp index 8c360befc3..44eda4d6c0 100755 --- a/indra/newview/llfolderviewmodelinventory.cpp +++ b/indra/newview/llfolderviewmodelinventory.cpp @@ -319,14 +319,14 @@ bool LLInventorySort::operator()(const LLFolderViewModelItemInventory* const& a, // Equal weight -> use alphabetical order return (LLStringUtil::compareDict(a->getDisplayName(), b->getDisplayName()) < 0); } - else if (weight_a == -1) + else if (weight_a == COMPUTE_STOCK_INFINITE) { - // No weight -> move a at the end of the list + // No stock -> move a at the end of the list return false; } - else if (weight_b == -1) + else if (weight_b == COMPUTE_STOCK_INFINITE) { - // No weight -> move b at the end of the list + // No stock -> move b at the end of the list return true; } else diff --git a/indra/newview/llinventorybridge.cpp b/indra/newview/llinventorybridge.cpp index df07c06467..6d92a05102 100755 --- a/indra/newview/llinventorybridge.cpp +++ b/indra/newview/llinventorybridge.cpp @@ -4261,15 +4261,23 @@ std::string LLMarketplaceFolderBridge::getLabelSuffix() const { suffix += " (" + LLTrans::getString("MarketplaceNoStock") + ")"; } - else if (stock_count != -1) + else if (stock_count != COMPUTE_STOCK_INFINITE) { if (getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK) { - suffix += " (" + LLTrans::getString("MarketplaceStock") + "=" + llformat("%d", stock_count) + ")"; + suffix += " (" + LLTrans::getString("MarketplaceStock"); } else { - suffix += " (" + LLTrans::getString("MarketplaceMax") + "=" + llformat("%d", stock_count) + ")"; + suffix += " (" + LLTrans::getString("MarketplaceMax"); + } + if (stock_count == COMPUTE_STOCK_NOT_EVALUATED) + { + suffix += "=" + LLTrans::getString("MarketplaceUpdating") + ")"; + } + else + { + suffix += "=" + llformat("%d", stock_count) + ")"; } } // Add updating suffix diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 135b6f2f17..9e88acdbd7 100755 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -1020,14 +1020,15 @@ S32 compute_stock_count(LLUUID cat_uuid, bool force_count /* false */) if (!cat) { // Not a category so no stock count to speak of - return -1; + return COMPUTE_STOCK_INFINITE; } if (cat->getPreferredType() == LLFolderType::FT_MARKETPLACE_STOCK) { if (cat->getVersion() == LLViewerInventoryCategory::VERSION_UNKNOWN) { // If the folder is not completely fetched, we do not want to return any confusing value that could lead to unlisting - return -1; + // "COMPUTE_STOCK_NOT_EVALUATED" denotes that a stock folder has a count that cannot be evaluated at this time (folder not up to date) + return COMPUTE_STOCK_NOT_EVALUATED; } // Note: stock folders are *not* supposed to have nested subfolders so we stop recursion here but we count only items (subfolders will be ignored) // Note: we *always* give a stock count for stock folders, it's useful even if the listing is unassociated @@ -1047,7 +1048,7 @@ S32 compute_stock_count(LLUUID cat_uuid, bool force_count /* false */) if (!LLMarketplaceData::instance().isListed(listing_uuid)) { // If not listed, the notion of stock is meaningless so it won't be computed for any level - return -1; + return COMPUTE_STOCK_INFINITE; } LLUUID version_folder_uuid = LLMarketplaceData::instance().getVersionFolder(listing_uuid); @@ -1062,7 +1063,7 @@ S32 compute_stock_count(LLUUID cat_uuid, bool force_count /* false */) else { // If there's no version folder associated, the notion of stock count has no meaning - return -1; + return COMPUTE_STOCK_INFINITE; } } else if (depth == 2) @@ -1070,18 +1071,19 @@ S32 compute_stock_count(LLUUID cat_uuid, bool force_count /* false */) if (version_folder_uuid.notNull() && (version_folder_uuid != cat_uuid)) { // If there is a version folder but we're not it, our stock count is meaningless - return -1; + return COMPUTE_STOCK_INFINITE; } } } // In all other cases, the stock count is the min of stock folders count found in the descendents + // "COMPUTE_STOCK_NOT_EVALUATED" denotes that a stock folder in the hierarchy has a count that cannot be evaluated at this time (folder not up to date) LLInventoryModel::cat_array_t* cat_array; LLInventoryModel::item_array_t* item_array; gInventory.getDirectDescendentsOf(cat_uuid,cat_array,item_array); - // "-1" denotes a folder that doesn't countain any stock folders in its descendents - S32 curr_count = -1; + // "COMPUTE_STOCK_INFINITE" denotes a folder that doesn't countain any stock folders in its descendents + S32 curr_count = COMPUTE_STOCK_INFINITE; // Note: marketplace listings have a maximum depth nesting of 4 LLInventoryModel::cat_array_t cat_array_copy = *cat_array; @@ -1089,7 +1091,7 @@ S32 compute_stock_count(LLUUID cat_uuid, bool force_count /* false */) { LLInventoryCategory* category = *iter; S32 count = compute_stock_count(category->getUUID(), true); - if ((curr_count == -1) || ((count != -1) && (count < curr_count))) + if ((curr_count == COMPUTE_STOCK_INFINITE) || ((count != COMPUTE_STOCK_INFINITE) && (count < curr_count))) { curr_count = count; } diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 4f4a64a7f9..687aa57d7f 100755 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -32,6 +32,10 @@ #include "llinventory.h" #include "llwearabletype.h" +// compute_stock_count() return error code +const S32 COMPUTE_STOCK_INFINITE = -1; +const S32 COMPUTE_STOCK_NOT_EVALUATED = -2; + /******************************************************************************** ** ** ** MISCELLANEOUS GLOBAL FUNCTIONS diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index de3bd35de0..88a05c1e7f 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1426,6 +1426,14 @@ bool LLMarketplaceData::createListing(const LLUUID& folder_id) { count = compute_stock_count(version_id, true); } + + // Validate the count on hand + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated, we will consider it empty (out of stock) at creation time + // It will get reevaluated and updated once the items are fetched + count = 0; + } // Post the listing creation request to SLM createSLMListing(folder_id, version_id, count); @@ -1517,7 +1525,13 @@ bool LLMarketplaceData::activateListing(const LLUUID& folder_id, bool activate) // Also update the count on hand S32 count = compute_stock_count(folder_id); - + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated locally, we should not change that SLM value + // We are assuming that this issue is local and should not modify server side values + count = getCountOnHand(listing_uuid); + } + // Post the listing update request to SLM updateSLMListing(listing_uuid, listing_id, version_uuid, activate, count); @@ -1547,6 +1561,12 @@ bool LLMarketplaceData::setVersionFolder(const LLUUID& folder_id, const LLUUID& // Also update the count on hand S32 count = compute_stock_count(version_id); + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated, we will consider it empty (out of stock) when resetting the version folder + // It will get reevaluated and updated once the items are fetched + count = 0; + } // Post the listing update request to SLM updateSLMListing(listing_uuid, listing_id, version_id, is_listed, count); @@ -1569,11 +1589,16 @@ bool LLMarketplaceData::updateCountOnHand(const LLUUID& folder_id) // Compute the new count on hand S32 count = compute_stock_count(folder_id); - if (getCountOnHand(listing_uuid) == count) + if (count == getCountOnHand(listing_uuid)) { // If count on hand is unchanged, no point spamming SLM with an update return true; } + else if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If local count on hand is not known at that point, do *not* force an update to SLM + return false; + } // Get the unchanged values bool is_listed = getActivationState(listing_uuid); @@ -1611,6 +1636,13 @@ bool LLMarketplaceData::associateListing(const LLUUID& folder_id, const LLUUID& { count = compute_stock_count(version_id, true); // Use the stock count of the new listing } + // Validate the count on hand + if (count == COMPUTE_STOCK_NOT_EVALUATED) + { + // If the count on hand cannot be evaluated, we will consider it empty (out of stock) at reassign time + // It will get reevaluated and updated once the items are fetched + count = 0; + } // Post the listing update request to SLM updateSLMListing(folder_id, listing_id, version_id, is_listed, count); |