diff options
author | Merov Linden <merov@lindenlab.com> | 2015-04-07 15:22:32 -0700 |
---|---|---|
committer | Merov Linden <merov@lindenlab.com> | 2015-04-07 15:22:32 -0700 |
commit | 79b891a688c0ebd329118a7ebc1a527c72d8f83f (patch) | |
tree | b1b3789192145d697ad5a86d2cba56b7625b1237 | |
parent | 32e5d99c9d4b14116eb12a49e9349ee7b1802ee4 (diff) |
DD-382 : Set count_on_hand correctly when creating or assigning a listing
-rwxr-xr-x | indra/newview/llinventoryfunctions.cpp | 55 | ||||
-rwxr-xr-x | indra/newview/llinventoryfunctions.h | 2 | ||||
-rwxr-xr-x | indra/newview/llmarketplacefunctions.cpp | 16 |
3 files changed, 44 insertions, 29 deletions
diff --git a/indra/newview/llinventoryfunctions.cpp b/indra/newview/llinventoryfunctions.cpp index 1a7b804d44..aeee3738f9 100755 --- a/indra/newview/llinventoryfunctions.cpp +++ b/indra/newview/llinventoryfunctions.cpp @@ -1014,7 +1014,7 @@ LLUUID nested_parent_id(LLUUID cur_uuid, S32 depth) return cur_uuid; } -S32 compute_stock_count(LLUUID cat_uuid) +S32 compute_stock_count(LLUUID cat_uuid, bool force_count /* false */) { // Handle the case of the folder being a stock folder immediately LLViewerInventoryCategory* cat = gInventory.getCategory(cat_uuid); @@ -1033,36 +1033,41 @@ S32 compute_stock_count(LLUUID cat_uuid) return item_array->size(); } - // Grab marketplace data for this folder - S32 depth = depth_nesting_in_marketplace(cat_uuid); - LLUUID listing_uuid = nested_parent_id(cat_uuid, depth); - if (!LLMarketplaceData::instance().isListed(listing_uuid)) + // When force_count is true, we do not do any verification of the marketplace status and simply compute + // the stock amount based on the descendent hierarchy. This is used specifically when creating a listing. + if (!force_count) { - // If not listed, the notion of stock is meaningless so it won't be computed for any level - return -1; - } - - LLUUID version_folder_uuid = LLMarketplaceData::instance().getVersionFolder(listing_uuid); - // Handle the case of the first 2 levels : listing and version folders - if (depth == 1) - { - if (version_folder_uuid.notNull()) + // Grab marketplace data for this folder + S32 depth = depth_nesting_in_marketplace(cat_uuid); + LLUUID listing_uuid = nested_parent_id(cat_uuid, depth); + if (!!LLMarketplaceData::instance().isListed(listing_uuid)) { - // If there is a version folder, the stock value for the listing is the version folder stock - return compute_stock_count(version_folder_uuid); + // If not listed, the notion of stock is meaningless so it won't be computed for any level + return -1; } - else + + LLUUID version_folder_uuid = LLMarketplaceData::instance().getVersionFolder(listing_uuid); + // Handle the case of the first 2 levels : listing and version folders + if (depth == 1) { - // If there's no version folder associated, the notion of stock count has no meaning - return -1; + if (version_folder_uuid.notNull()) + { + // If there is a version folder, the stock value for the listing is the version folder stock + return compute_stock_count(version_folder_uuid); + } + else + { + // If there's no version folder associated, the notion of stock count has no meaning + return -1; + } } - } - else if (depth == 2) - { - if (version_folder_uuid.notNull() && (version_folder_uuid != cat_uuid)) + else if (depth == 2) { - // If there is a version folder but we're not it, our stock count is meaningless - return -1; + 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; + } } } diff --git a/indra/newview/llinventoryfunctions.h b/indra/newview/llinventoryfunctions.h index 86124e1dad..4f4a64a7f9 100755 --- a/indra/newview/llinventoryfunctions.h +++ b/indra/newview/llinventoryfunctions.h @@ -83,7 +83,7 @@ bool move_folder_to_marketplacelistings(LLInventoryCategory* inv_cat, const LLUU bool validate_marketplacelistings(LLInventoryCategory* inv_cat, validation_callback_t cb = NULL, bool fix_hierarchy = true, S32 depth = -1); S32 depth_nesting_in_marketplace(LLUUID cur_uuid); LLUUID nested_parent_id(LLUUID cur_uuid, S32 depth); -S32 compute_stock_count(LLUUID cat_uuid); +S32 compute_stock_count(LLUUID cat_uuid, bool force_count = false); /** Miscellaneous global functions ** ** diff --git a/indra/newview/llmarketplacefunctions.cpp b/indra/newview/llmarketplacefunctions.cpp index 6ba98ff00e..d634a252d9 100755 --- a/indra/newview/llmarketplacefunctions.cpp +++ b/indra/newview/llmarketplacefunctions.cpp @@ -1274,8 +1274,13 @@ void LLMarketplaceData::createSLMListing(const LLUUID& folder_id) LLViewerInventoryCategory* category = gInventory.getCategory(folder_id); // Get the version folder: if there is only one subfolder, we will set it as a version folder immediately + S32 count = -1; LLUUID version_id = getVersionFolderIfUnique(folder_id); - + if (version_id.notNull()) + { + count = compute_stock_count(version_id, true); + } + // Build the json message Json::Value root; Json::FastWriter writer; @@ -1283,7 +1288,7 @@ void LLMarketplaceData::createSLMListing(const LLUUID& folder_id) root["listing"]["name"] = category->getName(); root["listing"]["inventory_info"]["listing_folder_id"] = folder_id.asString(); root["listing"]["inventory_info"]["version_folder_id"] = version_id.asString(); - root["listing"]["inventory_info"]["count_on_hand"] = -1; + root["listing"]["inventory_info"]["count_on_hand"] = count; std::string json_str = writer.write(root); @@ -1343,7 +1348,12 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing headers["Content-Type"] = "application/json"; // Get the version folder: if there is only one subfolder, we will set it as a version folder immediately + S32 count = -1; LLUUID version_id = getVersionFolderIfUnique(folder_id); + if (version_id.notNull()) + { + count = compute_stock_count(version_id, true); + } Json::Value root; Json::FastWriter writer; @@ -1352,7 +1362,7 @@ void LLMarketplaceData::associateSLMListing(const LLUUID& folder_id, S32 listing root["listing"]["id"] = listing_id; root["listing"]["inventory_info"]["listing_folder_id"] = folder_id.asString(); root["listing"]["inventory_info"]["version_folder_id"] = version_id.asString(); - root["listing"]["inventory_info"]["count_on_hand"] = -1; + root["listing"]["inventory_info"]["count_on_hand"] = count; std::string json_str = writer.write(root); |