diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp index 2328e70ee46b3a035e13514ab46c4cac4bf36e6c..6f912b1860d7619520d9f5abd5822f4624e1cbe1 100644 --- a/indra/newview/llappearancemgr.cpp +++ b/indra/newview/llappearancemgr.cpp @@ -4161,6 +4161,105 @@ void LLAppearanceMgr::serverAppearanceUpdateCoro(LLCoreHttpUtil::HttpCoroutineAd } while (bRetry); } +// [SL:KB] - Patch: Appearance-Misc +// Bad hack but if the viewer and server COF versions get out of sync all appearance requests will start to fail from that point on and require a relog to fix +void LLAppearanceMgr::syncCofVersionAndRefresh() +{ + LLCoros::instance().launch("syncCofVersionAndRefreshCoro", + boost::bind(&LLAppearanceMgr::syncCofVersionAndRefreshCoro, this)); +} + +void LLAppearanceMgr::syncCofVersionAndRefreshCoro() +{ + // If we don't have a region, report it as an error + if (gAgent.getRegion() == NULL) + { + LL_WARNS("Avatar") << "Region not set, cannot request cof_version increment" << LL_ENDL; + return; + } + + std::string url = gAgent.getRegion()->getCapability("IncrementCOFVersion"); + if (url.empty()) + { + LL_WARNS("Avatar") << "No cap for IncrementCofVersion." << LL_ENDL; + return; + } + + LL_INFOS("Avatar") << "Requesting cof_version be incremented via capability to: " << url << LL_ENDL; + + LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t httpAdapter( + new LLCoreHttpUtil::HttpCoroutineAdapter("syncCofVersionAndRefreshCoro", LLCore::HttpRequest::DEFAULT_POLICY_ID)); + + llcoro::suspend(); + S32 retryCount(0); + bool bRetry; + do + { + // Actually send the request. + LL_DEBUGS("Avatar") << "Will send request COF sync" << LL_ENDL; + + bRetry = false; + LLCore::HttpRequest::ptr_t httpRequest(new LLCore::HttpRequest()); + + LLSD result = httpAdapter->getAndSuspend(httpRequest, url); + + LLSD httpResults = result[LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS]; + LLCore::HttpStatus status = LLCoreHttpUtil::HttpCoroutineAdapter::getStatusFromLLSD(httpResults); + + if (!status) + { + std::string message = (result.has("error")) ? result["error"].asString() : status.toString(); + LL_WARNS("Avatar") << "Appearance Failure. server responded with \"" << message << "\"" << LL_ENDL; + + // Wait for a 1/2 second before trying again. Just to keep from asking too quickly. + if (++retryCount > BAKE_RETRY_MAX_COUNT) + { + LL_WARNS("Avatar") << "COF increment retry count exceeded!" << LL_ENDL; + break; + } + F32 timeout = pow(BAKE_RETRY_TIMEOUT, static_cast<float>(retryCount)) - 1.0f; + + LL_WARNS("Avatar") << "COF increment retry #" << retryCount << " in " << timeout << " seconds." << LL_ENDL; + + llcoro::suspendUntilTimeout(timeout); + bRetry = true; + } + else + { + LL_INFOS("Avatar") << "Successfully incremented agent's COF." << LL_ENDL; + + result.erase(LLCoreHttpUtil::HttpCoroutineAdapter::HTTP_RESULTS); + + if (!result.isMap()) + { + LL_WARNS("Avatar") << "Malformed response contents" << LL_ENDL; + bRetry = true; + continue; + } + + // Slam the server version onto the local version + LLViewerInventoryCategory* pCOF = gInventory.getCategory(LLAppearanceMgr::instance().getCOF()); + if (pCOF) + { + S32 cofVersion = result["version"].asInteger(); + LL_INFOS("Avatar") << "Slamming server COF version: was " << pCOF->getVersion() << " now " << cofVersion << LL_ENDL; + pCOF->setVersion(cofVersion); + llassert(gAgentAvatarp->mLastUpdateReceivedCOFVersion < cofVersion); + gAgentAvatarp->mLastUpdateReceivedCOFVersion = cofVersion; + } + + // The viewer version tends to be ahead of the server version so make sure our new request doesn't appear to be stale + gAgentAvatarp->mLastUpdateRequestCOFVersion = gAgentAvatarp->mLastUpdateReceivedCOFVersion; + + } + + } while (bRetry); + + // Try and request an update even if we fail + LLAppearanceMgr::instance().requestServerAppearanceUpdate(); +} +// [/SL:KB] + /*static*/ void LLAppearanceMgr::debugAppearanceUpdateCOF(const LLSD& content) { diff --git a/indra/newview/llappearancemgr.h b/indra/newview/llappearancemgr.h index 5f08cdb24267c49d28bc9a7f058d9ea34c3fb956..6e8dbe72bdf4bec6c349b053a9e9feccaebc6d45 100644 --- a/indra/newview/llappearancemgr.h +++ b/indra/newview/llappearancemgr.h @@ -260,6 +260,10 @@ class LLAppearanceMgr final : public LLSingleton<LLAppearanceMgr> private: void serverAppearanceUpdateCoro(LLCoreHttpUtil::HttpCoroutineAdapter::ptr_t &httpAdapter); +// [SL:KB] - Patch: Appearance-Misc + void syncCofVersionAndRefreshCoro(); +// [/SL:KB] + static void debugAppearanceUpdateCOF(const LLSD& content); std::string mAppearanceServiceURL; diff --git a/indra/newview/llviewermenu.cpp b/indra/newview/llviewermenu.cpp index 9c4adb9885317ffd5f58dbb55ed431ad8183c04d..9b8525449696d910732d6eb0846244b78d8e2397 100644 --- a/indra/newview/llviewermenu.cpp +++ b/indra/newview/llviewermenu.cpp @@ -8666,7 +8666,7 @@ void handle_rebake_textures(void*) if (gAgent.getRegion() && gAgent.getRegion()->getCentralBakeVersion()) { // [SL:KB] - Patch: Appearance-Misc | Checked: 2015-06-27 (Catznip-3.7) -// LLAppearanceMgr::instance().syncCofVersionAndRefresh(); + LLAppearanceMgr::instance().syncCofVersionAndRefresh(); // [/SL:KB] LLAppearanceMgr::instance().requestServerAppearanceUpdate(); } diff --git a/indra/newview/llvoavatar.cpp b/indra/newview/llvoavatar.cpp index 3423ad6364927bb4e656a83b403c2795129cc002..2860f912ede4147f66b55dcae66e326496adbd15 100644 --- a/indra/newview/llvoavatar.cpp +++ b/indra/newview/llvoavatar.cpp @@ -9451,7 +9451,14 @@ void LLVOAvatar::processAvatarAppearance( LLMessageSystem* mesgsys ) // appearance version, which may cause us to look for baked // textures in the wrong place and flag them as missing // assets. - LL_DEBUGS("Avatar") << "ignoring appearance message due to lack of params" << LL_ENDL; + if(isSelf() && mLastUpdateReceivedCOFVersion != -1) + { + LL_INFOS("Avatar") << "Empty appearance for self. Forcing a refresh" << LL_ENDL; + LLNotificationsUtil::add("AvatarRezSelfBakeForceUpdateNotification"); + LLAppearanceMgr::instance().syncCofVersionAndRefresh(); + } + else + LL_DEBUGS("Avatar") << "ignoring appearance message due to lack of params" << LL_ENDL; return; }