diff options
author | prep <prep@lindenlab.com> | 2013-03-11 15:17:13 -0400 |
---|---|---|
committer | prep <prep@lindenlab.com> | 2013-03-11 15:17:13 -0400 |
commit | 8e3b190e919fde84a2189d974208f9d199d4bea6 (patch) | |
tree | 7ab1db96d291260cbad356533607e1bce36ed0a7 /indra/newview/llwearablelist.cpp | |
parent | 2ea750ebcad8335aeb0ec77a483831b62d05f643 (diff) | |
parent | e0c9174609e2457fab7fe6d7291c6ebbd030397c (diff) |
merge
Diffstat (limited to 'indra/newview/llwearablelist.cpp')
-rw-r--r-- | indra/newview/llwearablelist.cpp | 54 |
1 files changed, 34 insertions, 20 deletions
diff --git a/indra/newview/llwearablelist.cpp b/indra/newview/llwearablelist.cpp index 6f6411ce3c..ef1a953f59 100644 --- a/indra/newview/llwearablelist.cpp +++ b/indra/newview/llwearablelist.cpp @@ -42,20 +42,23 @@ struct LLWearableArrivedData { LLWearableArrivedData(LLAssetType::EType asset_type, const std::string& wearable_name, - void(*asset_arrived_callback)(LLWearable*, void* userdata), + LLAvatarAppearance* avatarp, + void(*asset_arrived_callback)(LLViewerWearable*, void* userdata), void* userdata) : mAssetType( asset_type ), mCallback( asset_arrived_callback ), mUserdata( userdata ), mName( wearable_name ), - mRetries(0) + mRetries(0), + mAvatarp(avatarp) {} LLAssetType::EType mAssetType; - void (*mCallback)(LLWearable*, void* userdata); + void (*mCallback)(LLViewerWearable*, void* userdata); void* mUserdata; std::string mName; S32 mRetries; + LLAvatarAppearance *mAvatarp; }; //////////////////////////////////////////////////////////////////////////// @@ -72,10 +75,10 @@ void LLWearableList::cleanup() mList.clear(); } -void LLWearableList::getAsset(const LLAssetID& assetID, const std::string& wearable_name, LLAssetType::EType asset_type, void(*asset_arrived_callback)(LLWearable*, void* userdata), void* userdata) +void LLWearableList::getAsset(const LLAssetID& assetID, const std::string& wearable_name, LLAvatarAppearance* avatarp, LLAssetType::EType asset_type, void(*asset_arrived_callback)(LLViewerWearable*, void* userdata), void* userdata) { llassert( (asset_type == LLAssetType::AT_CLOTHING) || (asset_type == LLAssetType::AT_BODYPART) ); - LLWearable* instance = get_if_there(mList, assetID, (LLWearable*)NULL ); + LLViewerWearable* instance = get_if_there(mList, assetID, (LLViewerWearable*)NULL ); if( instance ) { asset_arrived_callback( instance, userdata ); @@ -85,7 +88,7 @@ void LLWearableList::getAsset(const LLAssetID& assetID, const std::string& weara gAssetStorage->getAssetData(assetID, asset_type, LLWearableList::processGetAssetReply, - (void*)new LLWearableArrivedData( asset_type, wearable_name, asset_arrived_callback, userdata ), + (void*)new LLWearableArrivedData( asset_type, wearable_name, avatarp, asset_arrived_callback, userdata ), TRUE); } } @@ -95,25 +98,31 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID { BOOL isNewWearable = FALSE; LLWearableArrivedData* data = (LLWearableArrivedData*) userdata; - LLWearable* wearable = NULL; // NULL indicates failure + LLViewerWearable* wearable = NULL; // NULL indicates failure + LLAvatarAppearance *avatarp = data->mAvatarp; if( !filename ) { LL_WARNS("Wearable") << "Bad Wearable Asset: missing file." << LL_ENDL; } + else if(!avatarp) + { + LL_WARNS("Wearable") << "Bad asset request: missing avatar pointer." << LL_ENDL; + } else if (status >= 0) { // read the file - LLFILE* fp = LLFile::fopen(std::string(filename), "rb"); /*Flawfinder: ignore*/ - if( !fp ) + llifstream ifs(filename, llifstream::binary); + if( !ifs.is_open() ) { LL_WARNS("Wearable") << "Bad Wearable Asset: unable to open file: '" << filename << "'" << LL_ENDL; } else { - wearable = new LLWearable(uuid); - bool res = wearable->importFile( fp ); - if (!res) + wearable = new LLViewerWearable(uuid); + LLWearable::EImportResult result = wearable->importStream( + ifs, avatarp ); + if (LLWearable::SUCCESS != result) { if (wearable->getType() == LLWearableType::WT_COUNT) { @@ -123,9 +132,12 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID wearable = NULL; } - fclose( fp ); if(filename) { + if (ifs.is_open()) + { + ifs.close(); + } LLFile::remove(std::string(filename)); } } @@ -203,11 +215,11 @@ void LLWearableList::processGetAssetReply( const char* filename, const LLAssetID } -LLWearable* LLWearableList::createCopy(const LLWearable* old_wearable, const std::string& new_name) +LLViewerWearable* LLWearableList::createCopy(const LLViewerWearable* old_wearable, const std::string& new_name) { lldebugs << "LLWearableList::createCopy()" << llendl; - LLWearable *wearable = generateNewWearable(); + LLViewerWearable *wearable = generateNewWearable(); wearable->copyDataFrom(old_wearable); LLPermissions perm(old_wearable->getPermissions()); @@ -222,12 +234,12 @@ LLWearable* LLWearableList::createCopy(const LLWearable* old_wearable, const std return wearable; } -LLWearable* LLWearableList::createNewWearable( LLWearableType::EType type ) +LLViewerWearable* LLWearableList::createNewWearable( LLWearableType::EType type, LLAvatarAppearance *avatarp ) { lldebugs << "LLWearableList::createNewWearable()" << llendl; - LLWearable *wearable = generateNewWearable(); - wearable->setType( type ); + LLViewerWearable *wearable = generateNewWearable(); + wearable->setType( type, avatarp ); std::string name = LLTrans::getString( LLWearableType::getTypeDefaultNewName(wearable->getType()) ); wearable->setName( name ); @@ -237,6 +249,8 @@ LLWearable* LLWearableList::createNewWearable( LLWearableType::EType type ) perm.initMasks(PERM_ALL, PERM_ALL, PERM_NONE, PERM_NONE, PERM_MOVE | PERM_TRANSFER); wearable->setPermissions(perm); + wearable->setDefinitionVersion(LLWearable::getCurrentDefinitionVersion()); + // Description and sale info have default values. wearable->setParamsToDefaults(); wearable->setTexturesToDefaults(); @@ -251,13 +265,13 @@ LLWearable* LLWearableList::createNewWearable( LLWearableType::EType type ) return wearable; } -LLWearable *LLWearableList::generateNewWearable() +LLViewerWearable *LLWearableList::generateNewWearable() { LLTransactionID tid; tid.generate(); LLAssetID new_asset_id = tid.makeAssetID(gAgent.getSecureSessionID()); - LLWearable* wearable = new LLWearable(tid); + LLViewerWearable* wearable = new LLViewerWearable(tid); mList[new_asset_id] = wearable; return wearable; } |