From 9a0c52a247ecbd79f5f872ceb97a6be3e0499bea Mon Sep 17 00:00:00 2001
From: Don Kjer <don@lindenlab.com>
Date: Tue, 5 Mar 2013 11:28:06 -0800
Subject: Adding debug setting to allow overriding appearance service url

---
 indra/newview/app_settings/settings.xml | 22 +++++++++++-----------
 indra/newview/llappearancemgr.cpp       |  9 +++++++++
 indra/newview/llappearancemgr.h         |  7 +++++++
 indra/newview/llstartup.cpp             |  2 +-
 indra/newview/llvoavatar.cpp            |  7 ++++---
 indra/newview/llvoavatarself.cpp        |  2 +-
 6 files changed, 33 insertions(+), 16 deletions(-)

diff --git a/indra/newview/app_settings/settings.xml b/indra/newview/app_settings/settings.xml
index 215fcf4eab..089bc7d4cd 100755
--- a/indra/newview/app_settings/settings.xml
+++ b/indra/newview/app_settings/settings.xml
@@ -71,17 +71,6 @@
       <key>Value</key>
       <integer>0</integer>
     </map>
-    <key>AgentAppearanceServiceURL</key>
-    <map>
-      <key>Comment</key>
-      <string>Current Session Agent Appearance Service URL</string>
-      <key>Persist</key>
-      <integer>0</integer>
-      <key>Type</key>
-      <string>String</string>
-      <key>Value</key>
-      <string></string>
-    </map>
     <key>AlertedUnsupportedHardware</key>
     <map>
       <key>Comment</key>
@@ -1949,6 +1938,17 @@
     <key>Value</key>
     <integer>0</integer>
   </map>
+    <key>DebugAvatarAppearanceServiceURLOverride</key>
+    <map>
+      <key>Comment</key>
+      <string>URL to use for baked texture requests; overrides value returned by login server.</string>
+      <key>Persist</key>
+      <integer>1</integer>
+      <key>Type</key>
+      <string>String</string>
+      <key>Value</key>
+      <string />
+    </map>
 	<key>DebugAvatarRezTime</key>
 	<map>
 		<key>Comment</key>
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index fa239e2c8a..1561f8d74c 100755
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -3359,6 +3359,15 @@ void LLAppearanceMgr::incrementCofVersion(LLHTTPClient::ResponderPtr responder_p
 	LLHTTPClient::get(url, body, responder_ptr, headers, 30.0f);
 }
 
+std::string LLAppearanceMgr::getAppearanceServiceURL() const
+{
+	if (gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride").empty())
+	{
+		return mAppearanceServiceURL;
+	}
+	return gSavedSettings.getString("DebugAvatarAppearanceServiceURLOverride");
+}
+
 void show_created_outfit(LLUUID& folder_id, bool show_panel = true)
 {
 	if (!LLApp::isRunning())
diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h
index 84e08db4c8..d49f5d6c15 100755
--- a/indra/newview/llappearancemgr.h
+++ b/indra/newview/llappearancemgr.h
@@ -205,6 +205,13 @@ public:
 	// *HACK Remove this after server side texture baking is deployed on all sims.
 	void incrementCofVersionLegacy();
 
+	void setAppearanceServiceURL(const std::string& url) { mAppearanceServiceURL = url; }
+	std::string getAppearanceServiceURL() const;
+
+private:
+	std::string		mAppearanceServiceURL;
+	
+
 protected:
 	LLAppearanceMgr();
 	~LLAppearanceMgr();
diff --git a/indra/newview/llstartup.cpp b/indra/newview/llstartup.cpp
index 156aa25274..e6e7b8650c 100755
--- a/indra/newview/llstartup.cpp
+++ b/indra/newview/llstartup.cpp
@@ -3449,7 +3449,7 @@ bool process_login_success_response()
 	std::string agent_appearance_url = response["agent_appearance_service"];
 	if (!agent_appearance_url.empty())
 	{
-		gSavedSettings.setString("AgentAppearanceServiceURL", agent_appearance_url);
+		LLAppearanceMgr::instance().setAppearanceServiceURL(agent_appearance_url);
 	}
 
 	// Set the location of the snapshot sharing config endpoint
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index f6fd8b2409..df44251c32 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -4496,7 +4496,8 @@ const std::string LLVOAvatar::getImageURL(const U8 te, const LLUUID &uuid)
 	std::string url = "";
 	if (isUsingServerBakes())
 	{
-		if (gSavedSettings.getString("AgentAppearanceServiceURL").empty())
+		const std::string& appearance_service_url = LLAppearanceMgr::instance().getAppearanceServiceURL();
+		if (appearance_service_url.empty())
 		{
 			// Probably a server-side issue if we get here:
 			llwarns << "AgentAppearanceServiceURL not set - Baked texture requests will fail" << llendl;
@@ -4506,7 +4507,7 @@ const std::string LLVOAvatar::getImageURL(const U8 te, const LLUUID &uuid)
 		const LLAvatarAppearanceDictionary::TextureEntry* texture_entry = LLAvatarAppearanceDictionary::getInstance()->getTexture((ETextureIndex)te);
 		if (texture_entry != NULL)
 		{
-			url = gSavedSettings.getString("AgentAppearanceServiceURL") + "texture/" + getID().asString() + "/" + texture_entry->mDefaultImageName + "/" + uuid.asString();
+			url = appearance_service_url + "texture/" + getID().asString() + "/" + texture_entry->mDefaultImageName + "/" + uuid.asString();
 			//llinfos << "baked texture url: " << url << llendl;
 		}
 	}
@@ -7256,7 +7257,7 @@ void LLVOAvatar::onBakedTextureLoaded(BOOL success,
 									  LLViewerFetchedTexture *src_vi, LLImageRaw* src, LLImageRaw* aux_src,
 									  S32 discard_level, BOOL final, void* userdata)
 {
-	// llinfos << "onBakedTextureLoaded: " << src_vi->getID() << llendl;
+	LL_DEBUGS("Avatar") << "onBakedTextureLoaded: " << src_vi->getID() << LL_ENDL;
 
 	LLUUID id = src_vi->getID();
 	LLUUID *avatar_idp = (LLUUID *)userdata;
diff --git a/indra/newview/llvoavatarself.cpp b/indra/newview/llvoavatarself.cpp
index d3c91f3339..3605383c5c 100755
--- a/indra/newview/llvoavatarself.cpp
+++ b/indra/newview/llvoavatarself.cpp
@@ -2469,7 +2469,7 @@ void LLVOAvatarSelf::checkForUnsupportedServerBakeAppearance()
 		return;
 
 	// if baked image service is unknown, need to refresh.
-	if (gSavedSettings.getString("AgentAppearanceServiceURL").empty())
+	if (LLAppearanceMgr::instance().getAppearanceServiceURL().empty())
 	{
 		CheckAgentAppearanceServiceResponder::forceAppearanceUpdate();
 	}
-- 
cgit v1.2.3