From d4dc41dbd5b54501fcb3c94e07e4753ed4196eac Mon Sep 17 00:00:00 2001
From: "Brad Payne (Vir Linden)" <vir@lindenlab.com>
Date: Thu, 1 Nov 2012 14:19:00 -0400
Subject: [PATCH] misc error detection, debug coloration for avatar meshes

---
 indra/llmessage/llurlrequest.cpp              |  4 ++
 indra/newview/llappearancemgr.cpp             |  4 +-
 .../llinventorymodelbackgroundfetch.cpp       |  2 +-
 indra/newview/lltexturefetch.cpp              |  2 +-
 indra/newview/llviewerregion.cpp              |  5 ++
 indra/newview/llviewertexture.cpp             |  6 +-
 indra/newview/llvoavatar.cpp                  | 56 ++++++++++---------
 indra/newview/llvoavatar.h                    |  1 +
 8 files changed, 50 insertions(+), 30 deletions(-)
 mode change 100644 => 100755 indra/llmessage/llurlrequest.cpp
 mode change 100644 => 100755 indra/newview/llviewertexture.cpp

diff --git a/indra/llmessage/llurlrequest.cpp b/indra/llmessage/llurlrequest.cpp
old mode 100644
new mode 100755
index f3f00072054..8c0ad352049
--- a/indra/llmessage/llurlrequest.cpp
+++ b/indra/llmessage/llurlrequest.cpp
@@ -181,6 +181,10 @@ void LLURLRequest::setURL(const std::string& url)
 {
 	LLMemType m1(LLMemType::MTYPE_IO_URL_REQUEST);
 	mDetail->mURL = url;
+	if (url.empty())
+	{
+		llwarns << "empty URL specified" << llendl;
+	}
 }
 
 std::string LLURLRequest::getURL() const
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index 7a8586ebdc1..51de2fd17b3 100755
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -1750,6 +1750,8 @@ void LLAppearanceMgr::updateAppearanceFromCOF(bool update_base_outfit_ordering)
 	{
 		requestServerAppearanceUpdate();
 	}
+	// DRANO really should wait for the appearance message to set this.
+	// verify that deleting this line doesn't break anything.
 	gAgentAvatarp->setIsUsingServerBakes(gAgent.getRegion() && gAgent.getRegion()->getCentralBakeVersion());
 	
 	//dumpCat(getCOF(),"COF, start");
@@ -2684,7 +2686,7 @@ void LLAppearanceMgr::requestServerAppearanceUpdate()
 	std::string url = gAgent.getRegion()->getCapability("UpdateAvatarAppearance");	
 	if (url.empty())
 	{
-		llwarns << "NO CAP for UpdateAvatarAppearance. This is a bug." << llendl;
+		llwarns << "No cap for UpdateAvatarAppearance." << llendl;
 		return;
 	}
 	
diff --git a/indra/newview/llinventorymodelbackgroundfetch.cpp b/indra/newview/llinventorymodelbackgroundfetch.cpp
index f4d0110b0f4..eb92902de9a 100644
--- a/indra/newview/llinventorymodelbackgroundfetch.cpp
+++ b/indra/newview/llinventorymodelbackgroundfetch.cpp
@@ -183,7 +183,7 @@ void LLInventoryModelBackgroundFetch::backgroundFetchCB(void *)
 
 void LLInventoryModelBackgroundFetch::backgroundFetch()
 {
-	if (mBackgroundFetchActive && gAgent.getRegion())
+	if (mBackgroundFetchActive && gAgent.getRegion() && gAgent.getRegion()->capabilitiesReceived())
 	{
 		// If we'll be using the capability, we'll be sending batches and the background thing isn't as important.
 		if (gSavedSettings.getBOOL("UseHTTPInventory")) 
diff --git a/indra/newview/lltexturefetch.cpp b/indra/newview/lltexturefetch.cpp
index db08c16f15b..43bfb4442bf 100644
--- a/indra/newview/lltexturefetch.cpp
+++ b/indra/newview/lltexturefetch.cpp
@@ -351,7 +351,7 @@ class HTTPGetResponder : public LLCurl::Responder
 			if (!success)
 			{
 				worker->setGetStatus(status, reason);
-// 				llwarns << "CURL GET FAILED, status:" << status << " reason:" << reason << llendl;
+ 				llwarns << "CURL GET FAILED, status:" << status << " reason:" << reason << " id: " << mID <<llendl;
 			}
 			
 			data_size = worker->callbackHttpGet(channels, buffer, partial, success);
diff --git a/indra/newview/llviewerregion.cpp b/indra/newview/llviewerregion.cpp
index 0855bc9243e..c8ab055e3f7 100755
--- a/indra/newview/llviewerregion.cpp
+++ b/indra/newview/llviewerregion.cpp
@@ -1745,6 +1745,11 @@ bool LLViewerRegion::isSpecialCapabilityName(const std::string &name)
 
 std::string LLViewerRegion::getCapability(const std::string& name) const
 {
+	if (!capabilitiesReceived() && (name!=std::string("Seed")))
+	{
+		llwarns << "getCapability called before caps received" << llendl;
+	}
+	
 	CapabilityMap::const_iterator iter = mImpl->mCapabilities.find(name);
 	if(iter == mImpl->mCapabilities.end())
 	{
diff --git a/indra/newview/llviewertexture.cpp b/indra/newview/llviewertexture.cpp
old mode 100644
new mode 100755
index a73ce1d1151..37f2fd35206
--- a/indra/newview/llviewertexture.cpp
+++ b/indra/newview/llviewertexture.cpp
@@ -1946,8 +1946,10 @@ void LLViewerFetchedTexture::setIsMissingAsset()
 	}
 	else
 	{
-		//it is normal no map tile on an empty region.
-		//llwarns << mUrl << ": Marking image as missing" << llendl;
+		// This may or may not be an error - it is normal to have no
+		// map tile on an empty region, but bad if we're failing on a
+		// server bake texture.
+		llwarns << mUrl << ": Marking image as missing" << llendl;
 	}
 	if (mHasFetcher)
 	{
diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp
index 168a116b95f..ed5b332e268 100755
--- a/indra/newview/llvoavatar.cpp
+++ b/indra/newview/llvoavatar.cpp
@@ -5767,6 +5767,25 @@ LLMotion* LLVOAvatar::findMotion(const LLUUID& id) const
 	return mMotionController.findMotion(id);
 }
 
+void LLVOAvatar::debugColorizeSubMeshes(U32 i, const LLColor4& color)
+{
+	if (gSavedSettings.getBOOL("DebugAvatarCompositeBaked"))
+	{
+		avatar_joint_mesh_list_t::iterator iter = mBakedTextureDatas[i].mJointMeshes.begin();
+		avatar_joint_mesh_list_t::iterator end  = mBakedTextureDatas[i].mJointMeshes.end();
+		for (; iter != end; ++iter)
+		{
+			LLAvatarJointMesh* mesh = (*iter);
+			if (mesh)
+			{
+				{
+					mesh->setColor(color);
+				}
+			}
+		}
+	}
+}
+
 //-----------------------------------------------------------------------------
 // updateMeshTextures()
 // Uses the current TE values to set the meshes' and layersets' textures.
@@ -5831,6 +5850,8 @@ void LLVOAvatar::updateMeshTextures()
 	
 	for (U32 i=0; i < mBakedTextureDatas.size(); i++)
 	{
+		debugColorizeSubMeshes(i, LLColor4::white);
+
 		LLViewerTexLayerSet* layerset = getTexLayerSet(i);
 		if (use_lkg_baked_layer[i] && !isUsingLocalAppearance() )
 		{
@@ -5853,6 +5874,9 @@ void LLVOAvatar::updateMeshTextures()
 			}
 
 			mBakedTextureDatas[i].mIsUsed = TRUE;
+
+			debugColorizeSubMeshes(i,LLColor4::red);
+
 			avatar_joint_mesh_list_t::iterator iter = mBakedTextureDatas[i].mJointMeshes.begin();
 			avatar_joint_mesh_list_t::iterator end  = mBakedTextureDatas[i].mJointMeshes.end();
 			for (; iter != end; ++iter)
@@ -5861,10 +5885,6 @@ void LLVOAvatar::updateMeshTextures()
 				if (mesh)
 				{
 					mesh->setTexture( baked_img );
-					if (gSavedSettings.getBOOL("DebugAvatarCompositeBaked"))
-					{
-						mesh->setColor(LLColor4::red);
-					}
 				}
 			}
 		}
@@ -5890,9 +5910,12 @@ void LLVOAvatar::updateMeshTextures()
 		}
 		else if (layerset && isUsingLocalAppearance())
 		{
+			debugColorizeSubMeshes(i,LLColor4::yellow );
+
 			layerset->createComposite();
 			layerset->setUpdatesEnabled( TRUE );
 			mBakedTextureDatas[i].mIsUsed = FALSE;
+
 			avatar_joint_mesh_list_t::iterator iter = mBakedTextureDatas[i].mJointMeshes.begin();
 			avatar_joint_mesh_list_t::iterator end  = mBakedTextureDatas[i].mJointMeshes.end();
 			for (; iter != end; ++iter)
@@ -5901,28 +5924,12 @@ void LLVOAvatar::updateMeshTextures()
 				if (mesh)
 				{
 					mesh->setLayerSet( layerset );
-					if (gSavedSettings.getBOOL("DebugAvatarCompositeBaked"))
-					{
-						mesh->setColor( LLColor4::yellow );
-					}
 				}
 			}
 		}
 		else
 		{
-			if (gSavedSettings.getBOOL("DebugAvatarCompositeBaked"))
-			{
-				avatar_joint_mesh_list_t::iterator iter = mBakedTextureDatas[i].mJointMeshes.begin();
-				avatar_joint_mesh_list_t::iterator end  = mBakedTextureDatas[i].mJointMeshes.end();
-				for (; iter != end; ++iter)
-				{
-					LLAvatarJointMesh* mesh = (*iter);
-					if (mesh)
-					{
-						mesh->setColor( LLColor4::blue );
-					}
-				}
-			}
+			debugColorizeSubMeshes(i,LLColor4::blue);
 		}
 	}
 
@@ -6768,6 +6775,9 @@ void LLVOAvatar::useBakedTexture( const LLUUID& id )
 			mBakedTextureDatas[i].mIsLoaded = true;
 			mBakedTextureDatas[i].mLastTextureIndex = id;
 			mBakedTextureDatas[i].mIsUsed = true;
+
+			debugColorizeSubMeshes(i,LLColor4::green);
+
 			avatar_joint_mesh_list_t::iterator iter = mBakedTextureDatas[i].mJointMeshes.begin();
 			avatar_joint_mesh_list_t::iterator end  = mBakedTextureDatas[i].mJointMeshes.end();
 			for (; iter != end; ++iter)
@@ -6776,10 +6786,6 @@ void LLVOAvatar::useBakedTexture( const LLUUID& id )
 				if (mesh)
 				{
 					mesh->setTexture( image_baked );
-					if (gSavedSettings.getBOOL("DebugAvatarCompositeBaked"))
-					{
-						mesh->setColor( LLColor4::green );
-					}
 				}
 			}
 			if (mBakedTextureDatas[i].mTexLayerSet)
diff --git a/indra/newview/llvoavatar.h b/indra/newview/llvoavatar.h
index 5f858a2bea5..8f3811f1847 100755
--- a/indra/newview/llvoavatar.h
+++ b/indra/newview/llvoavatar.h
@@ -595,6 +595,7 @@ class LLVOAvatar :
  **/
 
 public:
+	void			debugColorizeSubMeshes(U32 i, const LLColor4& color);
 	virtual void 	updateMeshTextures();
 	void 			updateSexDependentLayerSets(BOOL upload_bake);
 	virtual void	dirtyMesh(); // Dirty the avatar mesh
-- 
GitLab