From 7df0a4ddd0c48358e7152733aaba01464f2620be Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Thu, 14 Nov 2019 15:01:50 +0000
Subject: SL-10499, SL-10497 - use LLAgentBenefits info

---
 indra/newview/llagentbenefits.cpp                  | 17 ++++++-
 indra/newview/llagentbenefits.h                    |  2 +
 indra/newview/llfloaterbvhpreview.cpp              | 11 +++--
 indra/newview/llfloaternamedesc.cpp                |  1 +
 indra/newview/llfloaterreporter.cpp                |  6 ---
 indra/newview/lloutfitgallery.cpp                  |  3 +-
 indra/newview/llpanelmaininventory.cpp             | 48 +++++++++----------
 indra/newview/llpanelpeople.cpp                    |  1 +
 indra/newview/llpanelsnapshotoptions.cpp           |  8 ++--
 indra/newview/llstartup.cpp                        | 24 ++--------
 indra/newview/llviewerassetupload.cpp              | 18 +-------
 indra/newview/llviewerassetupload.h                |  1 -
 indra/newview/llviewermenu.cpp                     | 54 +++++++++++++++-------
 indra/newview/llvoavatar.cpp                       | 35 ++------------
 indra/newview/skins/default/xui/en/menu_viewer.xml |  9 ++--
 15 files changed, 105 insertions(+), 133 deletions(-)

(limited to 'indra/newview')

diff --git a/indra/newview/llagentbenefits.cpp b/indra/newview/llagentbenefits.cpp
index 724b2e1dc1..09be8f46c1 100644
--- a/indra/newview/llagentbenefits.cpp
+++ b/indra/newview/llagentbenefits.cpp
@@ -26,7 +26,14 @@
 #include "llviewerprecompiledheaders.h"
 #include "llagentbenefits.h"
 
-LLAgentBenefits::LLAgentBenefits()
+LLAgentBenefits::LLAgentBenefits():
+	m_initalized(false),
+	m_animated_object_limit(-1),
+	m_animation_upload_cost(-1),
+	m_attachment_limit(-1),
+	m_group_membership_limit(-1),
+	m_sound_upload_cost(-1),
+	m_texture_upload_cost(-1)
 {
 }
 
@@ -78,35 +85,43 @@ bool LLAgentBenefits::init(const LLSD& benefits_sd)
 	{
 		return false;
 	}
+
+	m_initalized = true;
 	return true;
 }
 
 S32 LLAgentBenefits::getAnimatedObjectLimit() const
 {
+	//llassert(m_initalized);
 	return m_animated_object_limit;
 }
 
 S32 LLAgentBenefits::getAnimationUploadCost() const
 {
+	//llassert(m_initalized);
 	return m_animation_upload_cost;
 }
 
 S32 LLAgentBenefits::getAttachmentLimit() const
 {
+	//llassert(m_initalized);
 	return m_attachment_limit;
 }
 
 S32 LLAgentBenefits::getGroupMembershipLimit() const
 {
+	//llassert(m_initalized);
 	return m_group_membership_limit;
 }
 
 S32 LLAgentBenefits::getSoundUploadCost() const
 {
+	//llassert(m_initalized);
 	return m_sound_upload_cost;
 }
 
 S32 LLAgentBenefits::getTextureUploadCost() const
 {
+	//llassert(m_initalized);
 	return m_texture_upload_cost;
 }
diff --git a/indra/newview/llagentbenefits.h b/indra/newview/llagentbenefits.h
index 0a8e33af28..995833149c 100644
--- a/indra/newview/llagentbenefits.h
+++ b/indra/newview/llagentbenefits.h
@@ -52,6 +52,8 @@ private:
 	S32 m_group_membership_limit;
 	S32 m_sound_upload_cost;
 	S32 m_texture_upload_cost;
+
+	bool m_initalized;
 };
 
 #endif
diff --git a/indra/newview/llfloaterbvhpreview.cpp b/indra/newview/llfloaterbvhpreview.cpp
index ee7e6f8562..91a6e63665 100644
--- a/indra/newview/llfloaterbvhpreview.cpp
+++ b/indra/newview/llfloaterbvhpreview.cpp
@@ -38,6 +38,7 @@
 #include "llstring.h"
 
 #include "llagent.h"
+#include "llagentbenefits.h"
 #include "llanimationstates.h"
 #include "llbbox.h"
 #include "llbutton.h"
@@ -1004,16 +1005,18 @@ void LLFloaterBvhPreview::onBtnOK(void* userdata)
 			{
 				std::string name = floaterp->getChild<LLUICtrl>("name_form")->getValue().asString();
 				std::string desc = floaterp->getChild<LLUICtrl>("description_form")->getValue().asString();
-				S32 expected_upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload();
+				S32 expected_upload_cost = LLAgentBenefits::instance().getAnimationUploadCost();
 
-                LLResourceUploadInfo::ptr_t assetUpdloadInfo(new LLResourceUploadInfo(
+                LLResourceUploadInfo::ptr_t assetUploadInfo(new LLResourceUploadInfo(
                     floaterp->mTransactionID, LLAssetType::AT_ANIMATION,
                     name, desc, 0,
                     LLFolderType::FT_NONE, LLInventoryType::IT_ANIMATION,
-                    LLFloaterPerms::getNextOwnerPerms("Uploads"), LLFloaterPerms::getGroupPerms("Uploads"), LLFloaterPerms::getEveryonePerms("Uploads"),
+                    LLFloaterPerms::getNextOwnerPerms("Uploads"),
+					LLFloaterPerms::getGroupPerms("Uploads"),
+					LLFloaterPerms::getEveryonePerms("Uploads"),
                     expected_upload_cost));
 
-                upload_new_resource(assetUpdloadInfo);
+                upload_new_resource(assetUploadInfo);
 			}
 			else
 			{
diff --git a/indra/newview/llfloaternamedesc.cpp b/indra/newview/llfloaternamedesc.cpp
index c9a689281e..33dfae8be8 100644
--- a/indra/newview/llfloaternamedesc.cpp
+++ b/indra/newview/llfloaternamedesc.cpp
@@ -161,6 +161,7 @@ void LLFloaterNameDesc::onBtnOK( )
 {
 	getChildView("ok_btn")->setEnabled(FALSE); // don't allow inadvertent extra uploads
 	
+	// FIXME PREMIUM - upload cost. Need to know which asset type this is, use agent benefits.
 	LLAssetStorage::LLStoreAssetCallback callback = NULL;
 	S32 expected_upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass).
 
diff --git a/indra/newview/llfloaterreporter.cpp b/indra/newview/llfloaterreporter.cpp
index 960fd9620d..4cc43254a5 100644
--- a/indra/newview/llfloaterreporter.cpp
+++ b/indra/newview/llfloaterreporter.cpp
@@ -102,7 +102,6 @@ public:
 
     virtual LLSD        prepareUpload();
     virtual LLSD        generatePostBody();
-    virtual S32         getEconomyUploadCost();
     virtual LLUUID      finishUpload(LLSD &result);
 
     virtual bool        showInventoryPanel() const { return false; }
@@ -129,11 +128,6 @@ LLSD LLARScreenShotUploader::generatePostBody()
     return mReport;
 }
 
-S32 LLARScreenShotUploader::getEconomyUploadCost()
-{   // Abuse report screen shots do not cost anything to upload.
-    return 0;
-}
-
 LLUUID LLARScreenShotUploader::finishUpload(LLSD &result)
 {
     /* *TODO$: Report success or failure. Carried over from previous todo on responder*/
diff --git a/indra/newview/lloutfitgallery.cpp b/indra/newview/lloutfitgallery.cpp
index b2b6de94b3..8f5626bd7a 100644
--- a/indra/newview/lloutfitgallery.cpp
+++ b/indra/newview/lloutfitgallery.cpp
@@ -36,6 +36,7 @@
 
 #include "llaccordionctrltab.h"
 #include "llappearancemgr.h"
+#include "llagentbenefits.h"
 #include "lleconomy.h"
 #include "llerror.h"
 #include "llfilepicker.h"
@@ -1205,7 +1206,7 @@ void LLOutfitGallery::uploadOutfitImage(const std::vector<std::string>& filename
             return;
         }
 
-        S32 expected_upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload(); // kinda hack - assumes that unsubclassed LLFloaterNameDesc is only used for uploading chargeable assets, which it is right now (it's only used unsubclassed for the sound upload dialog, and THAT should be a subclass).
+        S32 expected_upload_cost = LLAgentBenefits::instance().getTextureUploadCost();
         void *nruserdata = NULL;
         nruserdata = (void *)&outfit_id;
 
diff --git a/indra/newview/llpanelmaininventory.cpp b/indra/newview/llpanelmaininventory.cpp
index f63e604927..7404798589 100644
--- a/indra/newview/llpanelmaininventory.cpp
+++ b/indra/newview/llpanelmaininventory.cpp
@@ -28,6 +28,7 @@
 #include "llpanelmaininventory.h"
 
 #include "llagent.h"
+#include "llagentbenefits.h"
 #include "llagentcamera.h"
 #include "llavataractions.h"
 #include "llcheckboxctrl.h"
@@ -227,16 +228,21 @@ BOOL LLPanelMainInventory::postBuild()
 
 	initListCommandsHandlers();
 
-	// *TODO:Get the cost info from the server
-	const std::string upload_cost("10");
+	const std::string texture_upload_cost_str = std::to_string(LLAgentBenefits::instance().getTextureUploadCost());
+	const std::string sound_upload_cost_str = std::to_string(LLAgentBenefits::instance().getSoundUploadCost());
+	const std::string animation_upload_cost_str = std::to_string(LLAgentBenefits::instance().getAnimationUploadCost());
 
 	LLMenuGL* menu = (LLMenuGL*)mMenuAddHandle.get();
 	if (menu)
 	{
-		menu->getChild<LLMenuItemGL>("Upload Image")->setLabelArg("[COST]", upload_cost);
-		menu->getChild<LLMenuItemGL>("Upload Sound")->setLabelArg("[COST]", upload_cost);
-		menu->getChild<LLMenuItemGL>("Upload Animation")->setLabelArg("[COST]", upload_cost);
-		menu->getChild<LLMenuItemGL>("Bulk Upload")->setLabelArg("[COST]", upload_cost);
+		menu->getChild<LLMenuItemGL>("Upload Image")->setLabelArg("[COST]", texture_upload_cost_str);
+		menu->getChild<LLMenuItemGL>("Upload Sound")->setLabelArg("[COST]", sound_upload_cost_str);
+		menu->getChild<LLMenuItemGL>("Upload Animation")->setLabelArg("[COST]", animation_upload_cost_str);
+
+		// FIXME PREMIUM - bulk upload of what? This doesn't work with
+		// mixed items if costs aren't all the same. For now treating
+		// as textures.
+		menu->getChild<LLMenuItemGL>("Bulk Upload")->setLabelArg("[COST]", texture_upload_cost_str);
 	}
 
 	// Trigger callback for focus received so we can deselect items in inbox/outbox
@@ -1512,28 +1518,18 @@ void LLPanelMainInventory::setUploadCostIfNeeded()
 	LLMenuGL* menu = (LLMenuGL*)mMenuAddHandle.get();
 	if(mNeedUploadCost && menu)
 	{
-		LLMenuItemBranchGL* upload_menu = menu->findChild<LLMenuItemBranchGL>("upload");
-		if(upload_menu)
-		{
-			S32 upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload();
-			std::string cost_str;
+		const std::string texture_upload_cost_str = std::to_string(LLAgentBenefits::instance().getTextureUploadCost());
+		const std::string sound_upload_cost_str = std::to_string(LLAgentBenefits::instance().getSoundUploadCost());
+		const std::string animation_upload_cost_str = std::to_string(LLAgentBenefits::instance().getAnimationUploadCost());
 
-			// getPriceUpload() returns -1 if no data available yet.
-			if(upload_cost >= 0)
-			{
-				mNeedUploadCost = false;
-				cost_str = llformat("%d", upload_cost);
-			}
-			else
-			{
-				cost_str = llformat("%d", gSavedSettings.getU32("DefaultUploadCost"));
-			}
+		menu->getChild<LLView>("Upload Image")->setLabelArg("[COST]", texture_upload_cost_str);
+		menu->getChild<LLView>("Upload Sound")->setLabelArg("[COST]", sound_upload_cost_str);
+		menu->getChild<LLView>("Upload Animation")->setLabelArg("[COST]", animation_upload_cost_str);
 
-			upload_menu->getChild<LLView>("Upload Image")->setLabelArg("[COST]", cost_str);
-			upload_menu->getChild<LLView>("Upload Sound")->setLabelArg("[COST]", cost_str);
-			upload_menu->getChild<LLView>("Upload Animation")->setLabelArg("[COST]", cost_str);
-			upload_menu->getChild<LLView>("Bulk Upload")->setLabelArg("[COST]", cost_str);
-		}
+		// FIXME PREMIUM - bulk upload of what? This doesn't work with
+		// mixed items if costs aren't all the same. For now treating
+		// as textures.
+		menu->getChild<LLView>("Bulk Upload")->setLabelArg("[COST]", texture_upload_cost_str);
 	}
 }
 
diff --git a/indra/newview/llpanelpeople.cpp b/indra/newview/llpanelpeople.cpp
index be174475e1..d138433ed8 100644
--- a/indra/newview/llpanelpeople.cpp
+++ b/indra/newview/llpanelpeople.cpp
@@ -612,6 +612,7 @@ void LLPanelPeople::removePicker()
 
 BOOL LLPanelPeople::postBuild()
 {
+	// FIXME PREMIUM - need to get premium vs. basic info via BaaS
 	S32 max_premium = PREMIUM_MAX_AGENT_GROUPS; 
 	if (gAgent.getRegion())
 	{
diff --git a/indra/newview/llpanelsnapshotoptions.cpp b/indra/newview/llpanelsnapshotoptions.cpp
index 23747a8efd..63206e2780 100644
--- a/indra/newview/llpanelsnapshotoptions.cpp
+++ b/indra/newview/llpanelsnapshotoptions.cpp
@@ -35,12 +35,13 @@
 #include "llfloaterflickr.h"
 #include "llfloatertwitter.h"
 
+#include "llagentbenefits.h"
+
 /**
  * Provides several ways to save a snapshot.
  */
 class LLPanelSnapshotOptions
 :	public LLPanel
-,	public LLEconomyObserver
 {
 	LOG_CLASS(LLPanelSnapshotOptions);
 
@@ -49,7 +50,6 @@ public:
 	~LLPanelSnapshotOptions();
 	/*virtual*/ BOOL postBuild();
 	/*virtual*/ void onOpen(const LLSD& key);
-	/*virtual*/ void onEconomyDataChange() { updateUploadCost(); }
 
 private:
 	void updateUploadCost();
@@ -74,12 +74,10 @@ LLPanelSnapshotOptions::LLPanelSnapshotOptions()
 	mCommitCallbackRegistrar.add("Snapshot.SaveToComputer",		boost::bind(&LLPanelSnapshotOptions::onSaveToComputer,	this));
 	mCommitCallbackRegistrar.add("Snapshot.SendToTwitter",		boost::bind(&LLPanelSnapshotOptions::onSendToTwitter, this));
 	mCommitCallbackRegistrar.add("Snapshot.SendToFlickr",		boost::bind(&LLPanelSnapshotOptions::onSendToFlickr, this));
-	LLGlobalEconomy::getInstance()->addObserver(this);
 }
 
 LLPanelSnapshotOptions::~LLPanelSnapshotOptions()
 {
-	LLGlobalEconomy::getInstance()->removeObserver(this);
 }
 
 // virtual
@@ -97,7 +95,7 @@ void LLPanelSnapshotOptions::onOpen(const LLSD& key)
 
 void LLPanelSnapshotOptions::updateUploadCost()
 {
-	S32 upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload();
+	S32 upload_cost = LLAgentBenefits::instance().getTextureUploadCost();
 	getChild<LLUICtrl>("save_to_inventory_btn")->setLabelArg("[AMOUNT]", llformat("%d", upload_cost));
 }
 
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 73e8d3cf5f..979fe63432 100644
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -247,7 +247,6 @@ static std::string gAgentStartLocation = "safe";
 static bool mLoginStatePastUI = false;
 
 const S32 DEFAULT_MAX_AGENT_GROUPS = 42;
-const S32 ALLOWED_MAX_AGENT_GROUPS = 500;
 const F32 STATE_AGENT_WAIT_TIMEOUT = 240; //seconds
 
 boost::scoped_ptr<LLEventPump> LLStartUp::sStateWatcher(new LLEventStream("StartupState"));
@@ -3607,26 +3606,9 @@ bool process_login_success_response()
 		LLViewerMedia::getInstance()->openIDSetup(openid_url, openid_token);
 	}
 
-	gMaxAgentGroups = DEFAULT_MAX_AGENT_GROUPS;
-	if(response.has("max-agent-groups"))
-	{
-		S32 agent_groups = atoi(std::string(response["max-agent-groups"]).c_str());
-		if (agent_groups > 0 && agent_groups <= ALLOWED_MAX_AGENT_GROUPS)
-		{
-			gMaxAgentGroups = agent_groups;
-			LL_INFOS("LLStartup") << "gMaxAgentGroups read from login.cgi: "
-				<< gMaxAgentGroups << LL_ENDL;
-		}
-		else
-		{
-			LL_INFOS("LLStartup") << "Invalid value received, using defaults for gMaxAgentGroups: "
-				<< gMaxAgentGroups << LL_ENDL;
-		}
-	}
-	else {
-		LL_INFOS("LLStartup") << "Missing max-agent-groups, using default value for gMaxAgentGroups: "
-							  << gMaxAgentGroups << LL_ENDL;
-	}
+	gMaxAgentGroups = LLAgentBenefits::instance().getGroupMembershipLimit();
+	LL_INFOS("LLStartup") << "gMaxAgentGroups set from agent benefits: "
+						  << gMaxAgentGroups << LL_ENDL;
 		
 	bool success = false;
 	// JC: gesture loading done below, when we have an asset system
diff --git a/indra/newview/llviewerassetupload.cpp b/indra/newview/llviewerassetupload.cpp
index 97fbb8c601..a919362321 100644
--- a/indra/newview/llviewerassetupload.cpp
+++ b/indra/newview/llviewerassetupload.cpp
@@ -171,22 +171,6 @@ void LLResourceUploadInfo::logPreparedUpload()
         "Asset Type: " << LLAssetType::lookup(mAssetType) << LL_ENDL;
 }
 
-S32 LLResourceUploadInfo::getEconomyUploadCost()
-{
-    // Update L$ and ownership credit information
-    // since it probably changed on the server
-    if (getAssetType() == LLAssetType::AT_TEXTURE ||
-        getAssetType() == LLAssetType::AT_SOUND ||
-        getAssetType() == LLAssetType::AT_ANIMATION ||
-        getAssetType() == LLAssetType::AT_MESH)
-    {
-        return LLGlobalEconomy::instance().getPriceUpload();
-    }
-
-    return 0;
-}
-
-
 LLUUID LLResourceUploadInfo::finishUpload(LLSD &result)
 {
     if (getFolderId().isNull())
@@ -740,7 +724,7 @@ void LLViewerAssetUpload::AssetInventoryUploadCoproc(LLCoreHttpUtil::HttpCorouti
             return;
         }
 
-        S32 uploadPrice = result["upload_price"].asInteger();//uploadInfo->getEconomyUploadCost();
+        S32 uploadPrice = result["upload_price"].asInteger();
 
         if (uploadPrice > 0)
         {
diff --git a/indra/newview/llviewerassetupload.h b/indra/newview/llviewerassetupload.h
index ee1806b782..0ba16dce1d 100644
--- a/indra/newview/llviewerassetupload.h
+++ b/indra/newview/llviewerassetupload.h
@@ -62,7 +62,6 @@ public:
     virtual LLSD        prepareUpload();
     virtual LLSD        generatePostBody();
     virtual void        logPreparedUpload();
-    virtual S32         getEconomyUploadCost();
     virtual LLUUID      finishUpload(LLSD &result);
 
     LLTransactionID     getTransactionId() const { return mTransactionId; }
diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp
index dc82719109..0fda4d3df8 100644
--- a/indra/newview/llviewermenu.cpp
+++ b/indra/newview/llviewermenu.cpp
@@ -45,6 +45,7 @@
 // newview includes
 #include "llagent.h"
 #include "llagentaccess.h"
+#include "llagentbenefits.h"
 #include "llagentcamera.h"
 #include "llagentui.h"
 #include "llagentwearables.h"
@@ -134,6 +135,7 @@
 #include "llstartup.h"
 #include "boost/unordered_map.hpp"
 #include <boost/regex.hpp>
+#include <boost/algorithm/string.hpp>
 #include "llcleanup.h"
 
 using namespace LLAvatarAppearanceDefines;
@@ -508,13 +510,15 @@ void init_menus()
     gViewerWindow->setMenuBackgroundColor(false, 
         LLGridManager::getInstance()->isInProductionGrid());
 
-	// Assume L$10 for now, the server will tell us the real cost at login
 	// *TODO:Also fix cost in llfolderview.cpp for Inventory menus
-	const std::string upload_cost("10");
-	gMenuHolder->childSetLabelArg("Upload Image", "[COST]", upload_cost);
-	gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", upload_cost);
-	gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", upload_cost);
-	gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", upload_cost);
+	const std::string texture_upload_cost_str = std::to_string(LLAgentBenefits::instance().getTextureUploadCost());
+	const std::string sound_upload_cost_str = std::to_string(LLAgentBenefits::instance().getSoundUploadCost());
+	const std::string animation_upload_cost_str = std::to_string(LLAgentBenefits::instance().getAnimationUploadCost());
+	gMenuHolder->childSetLabelArg("Upload Image", "[COST]", texture_upload_cost_str);
+	gMenuHolder->childSetLabelArg("Upload Sound", "[COST]", sound_upload_cost_str);
+	gMenuHolder->childSetLabelArg("Upload Animation", "[COST]", animation_upload_cost_str);
+	// FIXME PREMIUM - do we need to handle non-texture bulk uploads?
+	gMenuHolder->childSetLabelArg("Bulk Upload", "[COST]", texture_upload_cost_str);
 	
 	gAttachSubMenu = gMenuBarView->findChildMenuByName("Attach Object", TRUE);
 	gDetachSubMenu = gMenuBarView->findChildMenuByName("Detach Object", TRUE);
@@ -8665,18 +8669,30 @@ class LLUploadCostCalculator : public view_listener_t
 
 	bool handleEvent(const LLSD& userdata)
 	{
-		std::string menu_name = userdata.asString();
+		std::vector<std::string> fields;
+		boost::split(fields, userdata.asString(), boost::is_any_of(","));
+		if (fields.size()<1)
+		{
+			return false;
+		}
+		std::string menu_name = fields[0];
+		std::string asset_type_str = "texture";
+		if (fields.size()>1)
+		{
+			asset_type_str = fields[1];
+		}
+		LL_DEBUGS("Benefits") << "userdata " << userdata << " menu_name " << menu_name << " asset_type_str " << asset_type_str << LL_ENDL;
+		calculateCost(asset_type_str);
 		gMenuHolder->childSetLabelArg(menu_name, "[COST]", mCostStr);
 
 		return true;
 	}
 
-	void calculateCost();
+	void calculateCost(const std::string& asset_type_str);
 
 public:
 	LLUploadCostCalculator()
 	{
-		calculateCost();
 	}
 };
 
@@ -8702,19 +8718,24 @@ class LLToggleUIHints : public view_listener_t
 	}
 };
 
-void LLUploadCostCalculator::calculateCost()
+void LLUploadCostCalculator::calculateCost(const std::string& asset_type_str)
 {
-	S32 upload_cost = LLGlobalEconomy::getInstance()->getPriceUpload();
+	// FIXME PREMIUM reasonable default?
+	S32 upload_cost = LLAgentBenefits::instance().getTextureUploadCost();
 
-	// getPriceUpload() returns -1 if no data available yet.
-	if(upload_cost >= 0)
+	if (asset_type_str == "texture")
 	{
-		mCostStr = llformat("%d", upload_cost);
+		upload_cost = LLAgentBenefits::instance().getTextureUploadCost();
 	}
-	else
+	else if (asset_type_str == "animation")
+	{
+		upload_cost = LLAgentBenefits::instance().getAnimationUploadCost();
+	}
+	else if (asset_type_str == "sound")
 	{
-		mCostStr = llformat("%d", gSavedSettings.getU32("DefaultUploadCost"));
+		upload_cost = LLAgentBenefits::instance().getSoundUploadCost();
 	}
+	mCostStr = std::to_string(upload_cost);
 }
 
 void show_navbar_context_menu(LLView* ctrl, S32 x, S32 y)
@@ -8819,6 +8840,7 @@ void initialize_menus()
 
 	enable.add("displayViewerEventRecorderMenuItems",boost::bind(&LLViewerEventRecorder::displayViewerEventRecorderMenuItems,&LLViewerEventRecorder::instance()));
 
+	// FIXME PREMIUM these need to be distinguished by asset type - see menu_viewer.xml
 	view_listener_t::addEnable(new LLUploadCostCalculator(), "Upload.CalculateCosts");
 
 	enable.add("Conversation.IsConversationLoggingAllowed", boost::bind(&LLFloaterIMContainer::isConversationLoggingAllowed));
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index ca1216b89d..f8ff71911e 100644
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -38,6 +38,7 @@
 #include "raytrace.h"
 
 #include "llagent.h" //  Get state values from here
+#include "llagentbenefits.h"
 #include "llagentcamera.h"
 #include "llagentwearables.h"
 #include "llanimationstates.h"
@@ -7060,20 +7061,7 @@ U32 LLVOAvatar::getNumAttachments() const
 //-----------------------------------------------------------------------------
 S32 LLVOAvatar::getMaxAttachments() const
 {
-	const S32 MAX_AGENT_ATTACHMENTS = 38;
-
-	S32 max_attach = MAX_AGENT_ATTACHMENTS;
-	
-	if (gAgent.getRegion())
-	{
-		LLSD features;
-		gAgent.getRegion()->getSimulatorFeatures(features);
-		if (features.has("MaxAgentAttachments"))
-		{
-			max_attach = features["MaxAgentAttachments"].asInteger();
-		}
-	}
-	return max_attach;
+	return LLAgentBenefits::instance().getAttachmentLimit();
 }
 
 //-----------------------------------------------------------------------------
@@ -7107,24 +7095,7 @@ U32 LLVOAvatar::getNumAnimatedObjectAttachments() const
 //-----------------------------------------------------------------------------
 S32 LLVOAvatar::getMaxAnimatedObjectAttachments() const
 {
-    S32 max_attach = 0;
-    if (gSavedSettings.getBOOL("AnimatedObjectsIgnoreLimits"))
-    {
-        max_attach = getMaxAttachments(); 
-    }
-    else
-    {
-        if (gAgent.getRegion())
-        {
-            LLSD features;
-            gAgent.getRegion()->getSimulatorFeatures(features);
-            if (features.has("AnimatedObjects"))
-            {
-                max_attach = features["AnimatedObjects"]["MaxAgentAnimatedObjectAttachments"].asInteger();
-            }
-        }
-    }
-    return max_attach;
+	return LLAgentBenefits::instance().getAnimatedObjectLimit();
 }
 
 //-----------------------------------------------------------------------------
diff --git a/indra/newview/skins/default/xui/en/menu_viewer.xml b/indra/newview/skins/default/xui/en/menu_viewer.xml
index 7bb7b5d62c..165986448f 100644
--- a/indra/newview/skins/default/xui/en/menu_viewer.xml
+++ b/indra/newview/skins/default/xui/en/menu_viewer.xml
@@ -1306,7 +1306,7 @@
                  function="File.EnableUpload" />
                 <menu_item_call.on_visible
                  function="Upload.CalculateCosts"
-                 parameter="Upload Image" />
+                 parameter="Upload Image,texture" />
             </menu_item_call>
             <menu_item_call
              label="Sound (L$[COST])..."
@@ -1319,7 +1319,7 @@
                  function="File.EnableUpload" />
                 <menu_item_call.on_visible
                  function="Upload.CalculateCosts"
-                 parameter="Upload Sound" />
+                 parameter="Upload Sound,sound" />
             </menu_item_call>
             <menu_item_call
              label="Animation (L$[COST])..."
@@ -1332,7 +1332,7 @@
                  function="File.EnableUpload" />
                 <menu_item_call.on_visible
                  function="Upload.CalculateCosts"
-                 parameter="Upload Animation" />
+                 parameter="Upload Animation,animation" />
             </menu_item_call>
             <menu_item_call
            label="Model..."
@@ -1350,6 +1350,9 @@
              label="Bulk (L$[COST] per file)..."
              layout="topleft"
              name="Bulk Upload">
+                <menu_item_call.on_visible
+                 function="Upload.CalculateCosts"
+                 parameter="Bulk Upload,texture" />
                 <menu_item_call.on_click
                  function="File.UploadBulk"
                  parameter="" />
-- 
cgit v1.2.3