Added wearable index handling to LLAgentWearables to scope out further changes. Index is still always zero for now, so behavior should not have changed. (marked with // TODO: MULTI-WEARABLE)

This commit is contained in:
Shyotl
2012-01-21 19:02:19 -06:00
parent 4a4b786a60
commit 51746dc751
14 changed files with 357 additions and 292 deletions

View File

@@ -84,7 +84,7 @@ public:
// Add all currently worn wearables // Add all currently worn wearables
for (S32 idxType = 0; idxType < LLWearableType::WT_COUNT; idxType++) for (S32 idxType = 0; idxType < LLWearableType::WT_COUNT; idxType++)
{ {
const LLUUID& idItem = gAgentWearables.getWearableItemID((LLWearableType::EType)idxType); const LLUUID& idItem = gAgentWearables.getWearableItemID((LLWearableType::EType)idxType,0); // TODO: MULTI-WEARABLE
if (idItem.isNull()) if (idItem.isNull())
continue; continue;
idItems.push_back(idItem); idItems.push_back(idItem);
@@ -486,7 +486,7 @@ void LLCOFMgr::synchWearables()
uuid_vec_t newItems; uuid_vec_t newItems;
for (S32 idxType = 0; idxType < LLWearableType::WT_COUNT; idxType++) for (S32 idxType = 0; idxType < LLWearableType::WT_COUNT; idxType++)
{ {
const LLUUID& idItem = gAgentWearables.getWearableItemID((LLWearableType::EType)idxType); const LLUUID& idItem = gAgentWearables.getWearableItemID((LLWearableType::EType)idxType, 0); // TODO: MULTI-WEARABLE
if (idItem.isNull()) if (idItem.isNull())
continue; continue;
newItems.push_back(idItem); newItems.push_back(idItem);

View File

@@ -3950,7 +3950,7 @@ void LLAgent::sendAgentSetAppearance()
static bool send_physics_params = false; static bool send_physics_params = false;
send_physics_params |= !!gAgentWearables.getWearable(LLWearableType::WT_PHYSICS); send_physics_params |= !!gAgentWearables.selfHasWearable(LLWearableType::WT_PHYSICS);
S32 transmitted_params = 0; S32 transmitted_params = 0;
for (LLViewerVisualParam* param = (LLViewerVisualParam*)gAgentAvatarp->getFirstVisualParam(); for (LLViewerVisualParam* param = (LLViewerVisualParam*)gAgentAvatarp->getFirstVisualParam();
param; param;

View File

@@ -105,22 +105,39 @@ LLAgentWearables::sendAgentWearablesUpdateCallback::~sendAgentWearablesUpdateCal
gAgentWearables.sendAgentWearablesUpdate(); gAgentWearables.sendAgentWearablesUpdate();
} }
/**
* @brief Construct a callback for dealing with the wearables.
*
* Would like to pass the agent in here, but we can't safely
* count on it being around later. Just use gAgent directly.
* @param cb callback to execute on completion (??? unused ???)
* @param type Type for the wearable in the agent
* @param wearable The wearable data.
* @param todo Bitmask of actions to take on completion.
*/
LLAgentWearables::addWearableToAgentInventoryCallback::addWearableToAgentInventoryCallback( LLAgentWearables::addWearableToAgentInventoryCallback::addWearableToAgentInventoryCallback(
LLPointer<LLRefCount> cb, LLWearableType::EType type, LLWearable* wearable, U32 todo) : LLPointer<LLRefCount> cb, LLWearableType::EType type, U32 index, LLWearable* wearable, U32 todo) :
mType(type), mType(type),
mIndex(index),
mWearable(wearable), mWearable(wearable),
mTodo(todo), mTodo(todo),
mCB(cb) mCB(cb)
{ {
llassert_always(index == 0);
llinfos << "constructor" << llendl; llinfos << "constructor" << llendl;
} }
void LLAgentWearables::addWearableToAgentInventoryCallback::fire(const LLUUID& inv_item) void LLAgentWearables::addWearableToAgentInventoryCallback::fire(const LLUUID& inv_item)
{ {
if (mTodo & CALL_CREATESTANDARDDONE)
{
llinfos << "callback fired, inv_item " << inv_item.asString() << llendl;
}
if (inv_item.isNull()) if (inv_item.isNull())
return; return;
gAgentWearables.addWearabletoAgentInventoryDone(mType, inv_item, mWearable); gAgentWearables.addWearabletoAgentInventoryDone(mType, mIndex, inv_item, mWearable);
if (mTodo & CALL_UPDATE) if (mTodo & CALL_UPDATE)
{ {
@@ -135,24 +152,28 @@ void LLAgentWearables::addWearableToAgentInventoryCallback::fire(const LLUUID& i
*/ */
if (mTodo & CALL_CREATESTANDARDDONE) if (mTodo & CALL_CREATESTANDARDDONE)
{ {
gAgentWearables.createStandardWearablesDone(mType); gAgentWearables.createStandardWearablesDone(mType, mIndex);
} }
if (mTodo & CALL_MAKENEWOUTFITDONE) if (mTodo & CALL_MAKENEWOUTFITDONE)
{ {
gAgentWearables.makeNewOutfitDone(mType); gAgentWearables.makeNewOutfitDone(mType, mIndex);
} }
} }
void LLAgentWearables::addWearabletoAgentInventoryDone(const LLWearableType::EType type, void LLAgentWearables::addWearabletoAgentInventoryDone(const LLWearableType::EType type,
const LLUUID& item_id, const U32 index,
LLWearable* wearable) const LLUUID& item_id,
LLWearable* wearable)
{ {
llinfos << "type " << type << " item " << item_id.asString() << llendl; llassert_always(index == 0);
llinfos << "type " << type << " index " << index << " item " << item_id.asString() << llendl;
if (item_id.isNull()) if (item_id.isNull())
return; return;
LLUUID old_item_id = getWearableItemID(type,index);
LLUUID old_item_id = getWearableItemID(type);
if (wearable) if (wearable)
{ {
wearable->setItemID(item_id); wearable->setItemID(item_id);
@@ -160,7 +181,7 @@ void LLAgentWearables::addWearabletoAgentInventoryDone(const LLWearableType::ETy
if (old_item_id.notNull()) if (old_item_id.notNull())
{ {
gInventory.addChangedMask(LLInventoryObserver::LABEL, old_item_id); gInventory.addChangedMask(LLInventoryObserver::LABEL, old_item_id);
setWearable(type,wearable); setWearable(type,index,wearable);
} }
else else
{ {
@@ -189,8 +210,9 @@ void LLAgentWearables::sendAgentWearablesUpdate()
// First make sure that we have inventory items for each wearable // First make sure that we have inventory items for each wearable
for (S32 type=0; type < LLWearableType::WT_COUNT; ++type) for (S32 type=0; type < LLWearableType::WT_COUNT; ++type)
{ {
for (U32 index=0; index < getWearableCount((LLWearableType::EType)type); ++index)
{ {
LLWearable* wearable = getWearable((LLWearableType::EType)type); LLWearable* wearable = getWearable((LLWearableType::EType)type,index);
if (wearable) if (wearable)
{ {
if (wearable->getItemID().isNull()) if (wearable->getItemID().isNull())
@@ -199,6 +221,7 @@ void LLAgentWearables::sendAgentWearablesUpdate()
new addWearableToAgentInventoryCallback( new addWearableToAgentInventoryCallback(
LLPointer<LLRefCount>(NULL), LLPointer<LLRefCount>(NULL),
(LLWearableType::EType)type, (LLWearableType::EType)type,
index,
wearable, wearable,
addWearableToAgentInventoryCallback::CALL_NONE); addWearableToAgentInventoryCallback::CALL_NONE);
addWearableToAgentInventory(cb, wearable); addWearableToAgentInventory(cb, wearable);
@@ -226,18 +249,19 @@ void LLAgentWearables::sendAgentWearablesUpdate()
gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); gMessageSystem->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID());
lldebugs << "sendAgentWearablesUpdate()" << llendl; lldebugs << "sendAgentWearablesUpdate()" << llendl;
for (S32 type=0; type < LLWearableType::WT_COUNT; ++type) // MULTI-WEARABLE: DEPRECATED: HACK: index to 0- server database tables don't support concept of multiwearables.
for (S32 type=0; type < LLWearableType::WT_COUNT; ++type)
{ {
gMessageSystem->nextBlockFast(_PREHASH_WearableData); gMessageSystem->nextBlockFast(_PREHASH_WearableData);
U8 type_u8 = (U8)type; U8 type_u8 = (U8)type;
gMessageSystem->addU8Fast(_PREHASH_WearableType, type_u8 ); gMessageSystem->addU8Fast(_PREHASH_WearableType, type_u8 );
LLWearable* wearable = getWearable((LLWearableType::EType)type); LLWearable* wearable = getWearable((LLWearableType::EType)type, 0);
if( wearable ) if( wearable )
{ {
//llinfos << "Sending wearable " << wearable->getName() << llendl;
LLUUID item_id = wearable->getItemID(); LLUUID item_id = wearable->getItemID();
LL_DEBUGS("Wearables") << "Sending wearable " << wearable->getName() << " mItemID = " << item_id << LL_ENDL;
const LLViewerInventoryItem *item = gInventory.getItem(item_id); const LLViewerInventoryItem *item = gInventory.getItem(item_id);
if (item && item->getIsLinkType()) if (item && item->getIsLinkType())
{ {
@@ -249,8 +273,8 @@ void LLAgentWearables::sendAgentWearablesUpdate()
} }
else else
{ {
LL_DEBUGS("Wearables") << "Not wearing wearable type " << LLWearableType::getTypeName((LLWearableType::EType)type) << LL_ENDL; //llinfos << "Not wearing wearable type " << LLWearableType::getTypeName((LLWearableType::EType)i) << llendl;
gMessageSystem->addUUIDFast(_PREHASH_ItemID, LLUUID::null ); gMessageSystem->addUUIDFast(_PREHASH_ItemID, LLUUID::null);
} }
lldebugs << " " << LLWearableType::getTypeLabel((LLWearableType::EType)type) << ": " << (wearable ? wearable->getAssetID() : LLUUID::null) << llendl; lldebugs << " " << LLWearableType::getTypeLabel((LLWearableType::EType)type) << ": " << (wearable ? wearable->getAssetID() : LLUUID::null) << llendl;
@@ -258,10 +282,11 @@ void LLAgentWearables::sendAgentWearablesUpdate()
gAgent.sendReliableMessage(); gAgent.sendReliableMessage();
} }
void LLAgentWearables::saveWearable(const LLWearableType::EType type, BOOL send_update, void LLAgentWearables::saveWearable(const LLWearableType::EType type, const U32 index, BOOL send_update,
const std::string new_name) const std::string new_name)
{ {
LLWearable* old_wearable = getWearable(type); llassert_always(index == 0);
LLWearable* old_wearable = getWearable(type, index);
if(!old_wearable) return; if(!old_wearable) return;
bool name_changed = !new_name.empty() && (new_name != old_wearable->getName()); bool name_changed = !new_name.empty() && (new_name != old_wearable->getName());
if (name_changed || old_wearable->isDirty() || old_wearable->isOldVersion()) if (name_changed || old_wearable->isDirty() || old_wearable->isOldVersion())
@@ -269,7 +294,7 @@ void LLAgentWearables::saveWearable(const LLWearableType::EType type, BOOL send_
LLUUID old_item_id = old_wearable->getItemID(); LLUUID old_item_id = old_wearable->getItemID();
LLWearable* new_wearable = LLWearableList::instance().createCopyFromAvatar( old_wearable ); LLWearable* new_wearable = LLWearableList::instance().createCopyFromAvatar( old_wearable );
new_wearable->setItemID(old_item_id); // should this be in LLWearable::copyDataFrom()? new_wearable->setItemID(old_item_id); // should this be in LLWearable::copyDataFrom()?
setWearable(type,new_wearable); setWearable(type,index,new_wearable);
LLInventoryItem* item = gInventory.getItem(old_item_id); LLInventoryItem* item = gInventory.getItem(old_item_id);
if( item ) if( item )
@@ -313,6 +338,7 @@ void LLAgentWearables::saveWearable(const LLWearableType::EType type, BOOL send_
new addWearableToAgentInventoryCallback( new addWearableToAgentInventoryCallback(
LLPointer<LLRefCount>(NULL), LLPointer<LLRefCount>(NULL),
type, type,
index,
new_wearable, new_wearable,
todo); todo);
addWearableToAgentInventory(cb, new_wearable); addWearableToAgentInventory(cb, new_wearable);
@@ -329,23 +355,25 @@ void LLAgentWearables::saveWearable(const LLWearableType::EType type, BOOL send_
} }
void LLAgentWearables::saveWearableAs(const LLWearableType::EType type, void LLAgentWearables::saveWearableAs(const LLWearableType::EType type,
const U32 index,
const std::string& new_name, const std::string& new_name,
BOOL save_in_lost_and_found) BOOL save_in_lost_and_found)
{ {
if(!isWearableCopyable(type)) llassert_always(index == 0);
if (!isWearableCopyable(type, index))
{ {
llwarns << "LLAgent::saveWearableAs() not copyable." << llendl; llwarns << "LLAgent::saveWearableAs() not copyable." << llendl;
return; return;
} }
LLWearable* old_wearable = getWearable(type); LLWearable* old_wearable = getWearable(type, index);
if(!old_wearable) if (!old_wearable)
{ {
llwarns << "LLAgent::saveWearableAs() no old wearable." << llendl; llwarns << "LLAgent::saveWearableAs() no old wearable." << llendl;
return; return;
} }
LLInventoryItem* item = gInventory.getItem(getWearableItemID(type)); LLInventoryItem* item = gInventory.getItem(getWearableItemID(type,index));
if(!item) if (!item)
{ {
llwarns << "LLAgent::saveWearableAs() no inventory item." << llendl; llwarns << "LLAgent::saveWearableAs() no inventory item." << llendl;
return; return;
@@ -359,6 +387,7 @@ void LLAgentWearables::saveWearableAs(const LLWearableType::EType type,
new addWearableToAgentInventoryCallback( new addWearableToAgentInventoryCallback(
LLPointer<LLRefCount>(NULL), LLPointer<LLRefCount>(NULL),
type, type,
index,
new_wearable, new_wearable,
addWearableToAgentInventoryCallback::CALL_UPDATE); addWearableToAgentInventoryCallback::CALL_UPDATE);
LLUUID category_id; LLUUID category_id;
@@ -422,9 +451,10 @@ void LLAgentWearables::saveWearableAs(const LLWearableType::EType type,
*/ */
} }
void LLAgentWearables::revertWearable( LLWearableType::EType type ) void LLAgentWearables::revertWearable(const LLWearableType::EType type, const U32 index)
{ {
LLWearable* wearable = getWearable(type); llassert_always(index == 0);
LLWearable* wearable = getWearable(type, index);
llassert(wearable); llassert(wearable);
if( wearable ) if( wearable )
{ {
@@ -438,7 +468,8 @@ void LLAgentWearables::revertAllWearables()
{ {
for( S32 i=0; i < LLWearableType::WT_COUNT; i++ ) for( S32 i=0; i < LLWearableType::WT_COUNT; i++ )
{ {
revertWearable( (LLWearableType::EType)i ); for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++)
revertWearable( (LLWearableType::EType)i, j);
} }
} }
@@ -451,7 +482,8 @@ void LLAgentWearables::saveAllWearables()
for( S32 i=0; i < LLWearableType::WT_COUNT; i++ ) for( S32 i=0; i < LLWearableType::WT_COUNT; i++ )
{ {
saveWearable( (LLWearableType::EType)i, FALSE ); for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++)
saveWearable((LLWearableType::EType)i, j, FALSE);
} }
sendAgentWearablesUpdate(); sendAgentWearablesUpdate();
} }
@@ -461,35 +493,39 @@ void LLAgentWearables::setWearableName( const LLUUID& item_id, const std::string
{ {
for( S32 i=0; i < LLWearableType::WT_COUNT; i++ ) for( S32 i=0; i < LLWearableType::WT_COUNT; i++ )
{ {
LLUUID curr_item_id = getWearableItemID((LLWearableType::EType)i); for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++)
if( curr_item_id == item_id )
{ {
LLWearable* old_wearable = getWearable((LLWearableType::EType)i); LLUUID curr_item_id = getWearableItemID((LLWearableType::EType)i,j);
llassert( old_wearable ); if (curr_item_id == item_id)
if (!old_wearable) continue;
std::string old_name = old_wearable->getName();
old_wearable->setName( new_name );
LLWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable);
new_wearable->setItemID(item_id);
LLInventoryItem* item = gInventory.getItem(item_id);
if(item)
{ {
new_wearable->setPermissions(item->getPermissions()); LLWearable* old_wearable = getWearable((LLWearableType::EType)i,j);
} llassert(old_wearable);
old_wearable->setName( old_name ); if (!old_wearable) continue;
setWearable((LLWearableType::EType)i,new_wearable); std::string old_name = old_wearable->getName();
sendAgentWearablesUpdate(); old_wearable->setName(new_name);
break; LLWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable);
new_wearable->setItemID(item_id);
LLInventoryItem* item = gInventory.getItem(item_id);
if (item)
{
new_wearable->setPermissions(item->getPermissions());
}
old_wearable->setName(old_name);
setWearable((LLWearableType::EType)i,j,new_wearable);
sendAgentWearablesUpdate();
break;
}
} }
} }
} }
BOOL LLAgentWearables::isWearableModifiable(LLWearableType::EType type) const BOOL LLAgentWearables::isWearableModifiable(LLWearableType::EType type, U32 index) const
{ {
LLUUID item_id = getWearableItemID(type); llassert_always(index == 0);
LLUUID item_id = getWearableItemID(type, index);
return item_id.notNull() ? isWearableModifiable(item_id) : FALSE; return item_id.notNull() ? isWearableModifiable(item_id) : FALSE;
} }
@@ -508,10 +544,11 @@ BOOL LLAgentWearables::isWearableModifiable(const LLUUID& item_id) const
return FALSE; return FALSE;
} }
BOOL LLAgentWearables::isWearableCopyable(LLWearableType::EType type) const BOOL LLAgentWearables::isWearableCopyable(LLWearableType::EType type, U32 index) const
{ {
LLUUID item_id = getWearableItemID(type); llassert_always(index == 0);
if(!item_id.isNull()) LLUUID item_id = getWearableItemID(type, index);
if (!item_id.isNull())
{ {
LLInventoryItem* item = gInventory.getItem(item_id); LLInventoryItem* item = gInventory.getItem(item_id);
if(item && item->getPermissions().allowCopyBy(gAgent.getID(), if(item && item->getPermissions().allowCopyBy(gAgent.getID(),
@@ -530,7 +567,7 @@ BOOL LLAgentWearables::areWearablesLoaded() const
return mWearablesLoaded; return mWearablesLoaded;
} }
U32 LLAgentWearables::getWearablePermMask(LLWearableType::EType type) const /*U32 LLAgentWearables::getWearablePermMask(LLWearableType::EType type) const
{ {
LLUUID item_id = getWearableItemID(type); LLUUID item_id = getWearableItemID(type);
if(!item_id.isNull()) if(!item_id.isNull())
@@ -543,10 +580,12 @@ U32 LLAgentWearables::getWearablePermMask(LLWearableType::EType type) const
} }
return PERM_NONE; return PERM_NONE;
} }
*/
LLInventoryItem* LLAgentWearables::getWearableInventoryItem(LLWearableType::EType type) LLInventoryItem* LLAgentWearables::getWearableInventoryItem(LLWearableType::EType type, U32 index)
{ {
LLUUID item_id = getWearableItemID(type); llassert_always(index == 0);
LLUUID item_id = getWearableItemID(type,index);
LLInventoryItem* item = NULL; LLInventoryItem* item = NULL;
if(item_id.notNull()) if(item_id.notNull())
{ {
@@ -558,12 +597,15 @@ LLInventoryItem* LLAgentWearables::getWearableInventoryItem(LLWearableType::ETyp
const LLWearable* LLAgentWearables::getWearableFromItemID( const LLUUID& item_id ) const const LLWearable* LLAgentWearables::getWearableFromItemID( const LLUUID& item_id ) const
{ {
const LLUUID& base_item_id = gInventory.getLinkedItemID(item_id); const LLUUID& base_item_id = gInventory.getLinkedItemID(item_id);
for( S32 i=0; i < LLWearableType::WT_COUNT; i++ ) for (S32 i=0; i < LLWearableType::WT_COUNT; i++)
{ {
const LLWearable * curr_wearable = getWearable((LLWearableType::EType)i); for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++)
if (curr_wearable && (curr_wearable->getItemID() == base_item_id))
{ {
return curr_wearable; const LLWearable * curr_wearable = getWearable((LLWearableType::EType)i, j);
if (curr_wearable && (curr_wearable->getItemID() == base_item_id))
{
return curr_wearable;
}
} }
} }
return NULL; return NULL;
@@ -572,12 +614,15 @@ const LLWearable* LLAgentWearables::getWearableFromItemID( const LLUUID& item_id
LLWearable* LLAgentWearables::getWearableFromItemID( const LLUUID& item_id ) LLWearable* LLAgentWearables::getWearableFromItemID( const LLUUID& item_id )
{ {
const LLUUID& base_item_id = gInventory.getLinkedItemID(item_id); const LLUUID& base_item_id = gInventory.getLinkedItemID(item_id);
for( S32 i=0; i < LLWearableType::WT_COUNT; i++ ) for (S32 i=0; i < LLWearableType::WT_COUNT; i++)
{ {
LLWearable * curr_wearable = getWearable((LLWearableType::EType)i); for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++)
if (curr_wearable && (curr_wearable->getItemID() == base_item_id))
{ {
return curr_wearable; LLWearable * curr_wearable = getWearable((LLWearableType::EType)i, j);
if (curr_wearable && (curr_wearable->getItemID() == base_item_id))
{
return curr_wearable;
}
} }
} }
return NULL; return NULL;
@@ -587,10 +632,13 @@ LLWearable* LLAgentWearables::getWearableFromAssetID(const LLUUID& asset_id)
{ {
for (S32 i=0; i < LLWearableType::WT_COUNT; i++) for (S32 i=0; i < LLWearableType::WT_COUNT; i++)
{ {
LLWearable * curr_wearable = getWearable((LLWearableType::EType)i); for (U32 j=0; j < getWearableCount((LLWearableType::EType)i); j++)
if (curr_wearable && (curr_wearable->getAssetID() == asset_id))
{ {
return curr_wearable; LLWearable * curr_wearable = getWearable((LLWearableType::EType)i, j);
if (curr_wearable && (curr_wearable->getAssetID() == asset_id))
{
return curr_wearable;
}
} }
} }
return NULL; return NULL;
@@ -612,14 +660,14 @@ BOOL LLAgentWearables::selfHasWearable(LLWearableType::EType type)
return (gAgentWearables.getWearableCount(type) > 0); return (gAgentWearables.getWearableCount(type) > 0);
} }
LLWearable* LLAgentWearables::getWearable(const LLWearableType::EType type) LLWearable* LLAgentWearables::getWearable(const LLWearableType::EType type, U32 index)
{ {
llassert_always(index == 0);
wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(type); wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(type);
if (wearable_iter == mWearableDatas.end()) if (wearable_iter == mWearableDatas.end())
{ {
return NULL; return NULL;
} }
U32 index = 0; //Remove when multi-wearables are implemented.
wearableentry_vec_t& wearable_vec = wearable_iter->second; wearableentry_vec_t& wearable_vec = wearable_iter->second;
if (index>=wearable_vec.size()) if (index>=wearable_vec.size())
{ {
@@ -631,17 +679,16 @@ LLWearable* LLAgentWearables::getWearable(const LLWearableType::EType type)
} }
} }
void LLAgentWearables::setWearable(const LLWearableType::EType type, LLWearable *wearable) void LLAgentWearables::setWearable(const LLWearableType::EType type, U32 index, LLWearable *wearable)
{ {
llassert_always(index == 0);
LLWearable *old_wearable = getWearable(type); LLWearable *old_wearable = getWearable(type,index);
if (!old_wearable) if (!old_wearable)
{ {
pushWearable(type,wearable); pushWearable(type,wearable);
return; return;
} }
U32 index = 0; //Remove when multi-wearables are implemented.
wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(type); wearableentry_map_t::iterator wearable_iter = mWearableDatas.find(type);
if (wearable_iter == mWearableDatas.end()) if (wearable_iter == mWearableDatas.end())
{ {
@@ -692,22 +739,23 @@ void LLAgentWearables::popWearable(LLWearable *wearable)
// nothing to do here. move along. // nothing to do here. move along.
return; return;
} }
U32 index = 0; //Remove when multi-wearables are implemented. U32 index = getWearableIndex(wearable);
LLWearableType::EType type = wearable->getType(); LLWearableType::EType type = wearable->getType();
if (index < MAX_CLOTHING_PER_TYPE && index < getWearableCount(type)) if (index < MAX_CLOTHING_PER_TYPE && index < getWearableCount(type))
{ {
popWearable(type); popWearable(type, index);
} }
} }
void LLAgentWearables::popWearable(const LLWearableType::EType type) void LLAgentWearables::popWearable(const LLWearableType::EType type, U32 index)
{ {
LLWearable *wearable = getWearable(type); llassert_always(index == 0);
LLWearable *wearable = getWearable(type, index);
if (wearable) if (wearable)
{ {
mWearableDatas[type].erase(mWearableDatas[type].begin()); mWearableDatas[type].erase(mWearableDatas[type].begin() + index);
gAgentAvatarp->wearableUpdated(wearable->getType(), TRUE); gAgentAvatarp->wearableUpdated(wearable->getType(), TRUE);
wearable->setLabelUpdated(); wearable->setLabelUpdated();
} }
@@ -739,15 +787,14 @@ U32 LLAgentWearables::getWearableIndex(const LLWearable *wearable) const
return MAX_CLOTHING_PER_TYPE; return MAX_CLOTHING_PER_TYPE;
} }
const LLWearable* LLAgentWearables::getWearable(const LLWearableType::EType type, U32 index) const
const LLWearable* LLAgentWearables::getWearable(const LLWearableType::EType type) const
{ {
llassert_always(index == 0);
wearableentry_map_t::const_iterator wearable_iter = mWearableDatas.find(type); wearableentry_map_t::const_iterator wearable_iter = mWearableDatas.find(type);
if (wearable_iter == mWearableDatas.end()) if (wearable_iter == mWearableDatas.end())
{ {
return NULL; return NULL;
} }
U32 index = 0; //Remove when multi-wearables are implemented.
const wearableentry_vec_t& wearable_vec = wearable_iter->second; const wearableentry_vec_t& wearable_vec = wearable_iter->second;
if (index>=wearable_vec.size()) if (index>=wearable_vec.size())
{ {
@@ -767,7 +814,7 @@ LLWearable* LLAgentWearables::getTopWearable(const LLWearableType::EType type)
return NULL; return NULL;
} }
return getWearable(type); return getWearable(type, count-1);
} }
LLWearable* LLAgentWearables::getBottomWearable(const LLWearableType::EType type) LLWearable* LLAgentWearables::getBottomWearable(const LLWearableType::EType type)
@@ -777,7 +824,7 @@ LLWearable* LLAgentWearables::getBottomWearable(const LLWearableType::EType type
return NULL; return NULL;
} }
return getWearable(type); return getWearable(type, 0);
} }
U32 LLAgentWearables::getWearableCount(const LLWearableType::EType type) const U32 LLAgentWearables::getWearableCount(const LLWearableType::EType type) const
@@ -798,18 +845,20 @@ U32 LLAgentWearables::getWearableCount(const U32 tex_index) const
} }
const LLUUID LLAgentWearables::getWearableItemID(LLWearableType::EType type) const const LLUUID LLAgentWearables::getWearableItemID(LLWearableType::EType type, U32 index) const
{ {
const LLWearable *wearable = getWearable(type); llassert_always(index == 0);
const LLWearable *wearable = getWearable(type,index);
if (wearable) if (wearable)
return wearable->getItemID(); return wearable->getItemID();
else else
return LLUUID(); return LLUUID();
} }
const LLUUID LLAgentWearables::getWearableAssetID(LLWearableType::EType type) const const LLUUID LLAgentWearables::getWearableAssetID(LLWearableType::EType type, U32 index) const
{ {
const LLWearable *wearable = getWearable(type); llassert_always(index == 0);
const LLWearable *wearable = getWearable(type,index);
if (wearable) if (wearable)
return wearable->getAssetID(); return wearable->getAssetID();
else else
@@ -822,8 +871,12 @@ BOOL LLAgentWearables::isWearingItem( const LLUUID& item_id ) const
return (getWearableFromItemID(base_item_id) != NULL); return (getWearableFromItemID(base_item_id) != NULL);
} }
// MULTI-WEARABLE: DEPRECATED (see backwards compatibility)
// static // static
void LLAgentWearables::processAgentInitialWearablesUpdate( LLMessageSystem* mesgsys, void** user_data ) // ! BACKWARDS COMPATIBILITY ! When we stop supporting viewer1.23, we can assume
// that viewers have a Current Outfit Folder and won't need this message, and thus
// we can remove/ignore this whole function. EXCEPT gAgentWearables.notifyLoadingStarted
void LLAgentWearables::processAgentInitialWearablesUpdate(LLMessageSystem* mesgsys, void** user_data)
{ {
// We should only receive this message a single time. Ignore subsequent AgentWearablesUpdates // We should only receive this message a single time. Ignore subsequent AgentWearablesUpdates
// that may result from AgentWearablesRequest having been sent more than once. // that may result from AgentWearablesRequest having been sent more than once.
@@ -881,7 +934,7 @@ void LLAgentWearables::processAgentInitialWearablesUpdate( LLMessageSystem* mesg
asset_id_array[type] = std::pair<LLUUID, LLUUID>(asset_id,item_id); asset_id_array[type] = std::pair<LLUUID, LLUUID>(asset_id,item_id);
} }
LL_DEBUGS("Wearables") << " " << LLWearableType::getTypeLabel(type) << " " << asset_id << " item id " << gAgentWearables.getWearableItemID(type).asString() << LL_ENDL; LL_DEBUGS("Wearables") << " " << LLWearableType::getTypeLabel(type) << " " << asset_id << " item id " << gAgentWearables.getWearableItemID(type, 0).asString() << LL_ENDL;
} }
LLCOFMgr::instance().fetchCOF(); LLCOFMgr::instance().fetchCOF();
@@ -928,7 +981,7 @@ void LLAgentWearables::onInitialWearableAssetArrived( LLWearable* wearable, void
{ {
llassert( type == wearable->getType() ); llassert( type == wearable->getType() );
wearable->setItemID(item_id); wearable->setItemID(item_id);
gAgentWearables.setWearable(type,wearable); gAgentWearables.setWearable(type,0,wearable);
// disable composites if initial textures are baked // disable composites if initial textures are baked
avatar->setupComposites(); avatar->setupComposites();
@@ -941,7 +994,7 @@ void LLAgentWearables::onInitialWearableAssetArrived( LLWearable* wearable, void
else else
{ {
// Somehow the asset doesn't exist in the database. // Somehow the asset doesn't exist in the database.
gAgentWearables.recoverMissingWearable( type ); gAgentWearables.recoverMissingWearable( type, 0 );
} }
gInventory.notifyObservers(); gInventory.notifyObservers();
@@ -952,7 +1005,7 @@ void LLAgentWearables::onInitialWearableAssetArrived( LLWearable* wearable, void
gAgentWearables.mWearablesLoaded = TRUE; gAgentWearables.mWearablesLoaded = TRUE;
for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ ) for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ )
{ {
if( !gAgentWearables.getWearableItemID((LLWearableType::EType)i).isNull() && !gAgentWearables.getWearable((LLWearableType::EType)i) ) if( !gAgentWearables.getWearableItemID((LLWearableType::EType)i, 0).isNull() && !gAgentWearables.getWearable((LLWearableType::EType)i, 0) )
{ {
gAgentWearables.mWearablesLoaded = FALSE; gAgentWearables.mWearablesLoaded = FALSE;
break; break;
@@ -977,14 +1030,15 @@ void LLAgentWearables::onInitialWearableAssetArrived( LLWearable* wearable, void
// Normally, all wearables referred to "AgentWearablesUpdate" will correspond to actual assets in the // Normally, all wearables referred to "AgentWearablesUpdate" will correspond to actual assets in the
// database. If for some reason, we can't load one of those assets, we can try to reconstruct it so that // database. If for some reason, we can't load one of those assets, we can try to reconstruct it so that
// the user isn't left without a shape, for example. (We can do that only after the inventory has loaded.) // the user isn't left without a shape, for example. (We can do that only after the inventory has loaded.)
void LLAgentWearables::recoverMissingWearable( LLWearableType::EType type ) void LLAgentWearables::recoverMissingWearable(const LLWearableType::EType type, U32 index)
{ {
llassert_always(index == 0);
// Try to recover by replacing missing wearable with a new one. // Try to recover by replacing missing wearable with a new one.
LLNotificationsUtil::add("ReplacedMissingWearable"); LLNotificationsUtil::add("ReplacedMissingWearable");
lldebugs << "Wearable " << LLWearableType::getTypeLabel( type ) << " could not be downloaded. Replaced inventory item with default wearable." << llendl; lldebugs << "Wearable " << LLWearableType::getTypeLabel( type ) << " could not be downloaded. Replaced inventory item with default wearable." << llendl;
LLWearable* new_wearable = LLWearableList::instance().createNewWearable(type); LLWearable* new_wearable = LLWearableList::instance().createNewWearable(type);
setWearable(type,new_wearable); setWearable(type,index,new_wearable);
new_wearable->writeToAvatar( TRUE ); new_wearable->writeToAvatar( TRUE );
// Add a new one in the lost and found folder. // Add a new one in the lost and found folder.
@@ -995,6 +1049,7 @@ void LLAgentWearables::recoverMissingWearable( LLWearableType::EType type )
new addWearableToAgentInventoryCallback( new addWearableToAgentInventoryCallback(
LLPointer<LLRefCount>(NULL), LLPointer<LLRefCount>(NULL),
type, type,
index,
new_wearable, new_wearable,
addWearableToAgentInventoryCallback::CALL_RECOVERDONE); addWearableToAgentInventoryCallback::CALL_RECOVERDONE);
addWearableToAgentInventory( cb, new_wearable, lost_and_found_id, TRUE); addWearableToAgentInventory( cb, new_wearable, lost_and_found_id, TRUE);
@@ -1063,15 +1118,16 @@ void LLAgentWearables::createStandardWearables(BOOL female)
new addWearableToAgentInventoryCallback( new addWearableToAgentInventoryCallback(
donecb, donecb,
(LLWearableType::EType)i, (LLWearableType::EType)i,
0,
wearable, wearable,
addWearableToAgentInventoryCallback::CALL_CREATESTANDARDDONE); addWearableToAgentInventoryCallback::CALL_CREATESTANDARDDONE);
addWearableToAgentInventory(cb, wearable, LLUUID::null, FALSE); addWearableToAgentInventory(cb, wearable, LLUUID::null, FALSE);
} }
} }
} }
void LLAgentWearables::createStandardWearablesDone(S32 index) void LLAgentWearables::createStandardWearablesDone(S32 type, U32 index)
{ {
LLWearable* wearable = getWearable((LLWearableType::EType)index); LLWearable* wearable = getWearable((LLWearableType::EType)type, index);
if (wearable) if (wearable)
{ {
@@ -1126,10 +1182,10 @@ void LLAgentWearables::makeNewOutfit(
for( i = 0; i < count; ++i ) for( i = 0; i < count; ++i )
{ {
S32 index = wearables_to_include[i]; S32 index = wearables_to_include[i];
LLWearable* old_wearable = getWearable((LLWearableType::EType)index); LLWearable* old_wearable = getWearable((LLWearableType::EType)index, 0);
if( old_wearable ) if( old_wearable )
{ {
LLViewerInventoryItem* item = gInventory.getItem(getWearableItemID((LLWearableType::EType)index)); LLViewerInventoryItem* item = gInventory.getItem(getWearableItemID((LLWearableType::EType)index, 0));
llassert(item); llassert(item);
if (!item) if (!item)
continue; continue;
@@ -1157,7 +1213,7 @@ void LLAgentWearables::makeNewOutfit(
LLStringUtil::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN); LLStringUtil::truncate(new_name, DB_INV_ITEM_NAME_STR_LEN);
} }
if (fUseLinks || isWearableCopyable((LLWearableType::EType)index)) if (fUseLinks || isWearableCopyable((LLWearableType::EType)index, 0))
{ {
LLWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable); LLWearable* new_wearable = LLWearableList::instance().createCopy(old_wearable);
if (rename_clothing) if (rename_clothing)
@@ -1178,9 +1234,10 @@ void LLAgentWearables::makeNewOutfit(
new addWearableToAgentInventoryCallback( new addWearableToAgentInventoryCallback(
cbdone, cbdone,
(LLWearableType::EType)index, (LLWearableType::EType)index,
0,
new_wearable, new_wearable,
todo); todo);
if (isWearableCopyable((LLWearableType::EType)index)) if (isWearableCopyable((LLWearableType::EType)index, 0))
{ {
copy_inventory_item( copy_inventory_item(
gAgent.getID(), gAgent.getID(),
@@ -1292,9 +1349,9 @@ void LLAgentWearables::makeNewOutfit(
} }
} }
void LLAgentWearables::makeNewOutfitDone(S32 type) void LLAgentWearables::makeNewOutfitDone(S32 type, U32 index)
{ {
LLUUID first_item_id = getWearableItemID((LLWearableType::EType)type); LLUUID first_item_id = getWearableItemID((LLWearableType::EType)type, index);
// Open the inventory and select the first item we added. // Open the inventory and select the first item we added.
if( first_item_id.notNull() ) if( first_item_id.notNull() )
{ {
@@ -1325,15 +1382,16 @@ void LLAgentWearables::addWearableToAgentInventory(LLPointer<LLInventoryCallback
cb); cb);
} }
void LLAgentWearables::removeWearable( LLWearableType::EType type ) void LLAgentWearables::removeWearable(const LLWearableType::EType type, bool do_remove_all, U32 index)
{ {
llassert_always(index == 0);
if (gAgent.isTeen() && if (gAgent.isTeen() &&
(type == LLWearableType::WT_UNDERSHIRT || type == LLWearableType::WT_UNDERPANTS)) (type == LLWearableType::WT_UNDERSHIRT || type == LLWearableType::WT_UNDERPANTS))
{ {
// Can't take off underclothing in simple UI mode or on PG accounts // Can't take off underclothing in simple UI mode or on PG accounts
// TODO: enable the removing of a single undershirt/underpants if multiple are worn. - Nyx
return; return;
} }
if (getWearableCount(type) == 0) if (getWearableCount(type) == 0)
{ {
// no wearables to remove // no wearables to remove
@@ -1346,41 +1404,50 @@ void LLAgentWearables::removeWearable( LLWearableType::EType type )
return; return;
} }
// [/RLVa:KB] // [/RLVa:KB]
if (do_remove_all)
LLWearable* old_wearable = getWearable(type);
if( old_wearable )
{ {
if( old_wearable->isDirty() ) removeWearableFinal(type, do_remove_all, index);
}
else
{
LLWearable* old_wearable = getWearable(type,index);
if (old_wearable)
{ {
LLSD payload; if (old_wearable->isDirty())
payload["wearable_type"] = (S32)type; {
// Bring up view-modal dialog: Save changes? Yes, No, Cancel LLSD payload;
LLNotificationsUtil::add("WearableSave", LLSD(), payload, &LLAgentWearables::onRemoveWearableDialog); payload["wearable_type"] = (S32)type;
return; payload["wearable_index"] = (S32)index;
} // Bring up view-modal dialog: Save changes? Yes, No, Cancel
else LLNotificationsUtil::add("WearableSave", LLSD(), payload, &LLAgentWearables::onRemoveWearableDialog);
{ return;
removeWearableFinal( type ); }
else
{
removeWearableFinal(type, do_remove_all, index);
}
} }
} }
} }
// static // static
bool LLAgentWearables::onRemoveWearableDialog(const LLSD& notification, const LLSD& response ) bool LLAgentWearables::onRemoveWearableDialog(const LLSD& notification, const LLSD& response)
{ {
S32 option = LLNotificationsUtil::getSelectedOption(notification, response); S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
LLWearableType::EType type = (LLWearableType::EType)notification["payload"]["wearable_type"].asInteger(); LLWearableType::EType type = (LLWearableType::EType)notification["payload"]["wearable_type"].asInteger();
switch( option ) S32 index = (S32)notification["payload"]["wearable_index"].asInteger();
switch(option)
{ {
case 0: // "Save" case 0: // "Save"
gAgentWearables.saveWearable( type ); gAgentWearables.saveWearable(type, index);
gAgentWearables.removeWearableFinal( type ); gAgentWearables.removeWearableFinal(type, false, index);
break; break;
case 1: // "Don't Save" case 1: // "Don't Save"
gAgentWearables.removeWearableFinal( type ); gAgentWearables.removeWearableFinal(type, false, index);
break; break;
case 2: // "Cancel" case 2: // "Cancel"
break; break;
@@ -1393,17 +1460,35 @@ bool LLAgentWearables::onRemoveWearableDialog(const LLSD& notification, const LL
} }
// Called by removeWearable() and onRemoveWearableDialog() to actually do the removal. // Called by removeWearable() and onRemoveWearableDialog() to actually do the removal.
void LLAgentWearables::removeWearableFinal( LLWearableType::EType type ) void LLAgentWearables::removeWearableFinal( LLWearableType::EType type, bool do_remove_all, U32 index)
{ {
gInventory.addChangedMask( LLInventoryObserver::LABEL, getWearableItemID(type) ); llassert_always(index == 0);
gInventory.addChangedMask( LLInventoryObserver::LABEL, getWearableItemID(type, index) );
LLWearable* old_wearable = getWearable(type); if (do_remove_all)
//queryWearableCache();
if( old_wearable )
{ {
popWearable(old_wearable); S32 max_entry = mWearableDatas[type].size()-1;
old_wearable->removeFromAvatar( TRUE ); for (S32 i=max_entry; i>=0; i--)
{
LLWearable* old_wearable = getWearable(type,i);
//queryWearableCache(); // moved below
if (old_wearable)
{
popWearable(old_wearable);
old_wearable->removeFromAvatar(TRUE);
}
}
mWearableDatas[type].clear();
}
else
{
LLWearable* old_wearable = getWearable(type, index);
//queryWearableCache(); // moved below
if (old_wearable)
{
popWearable(old_wearable);
old_wearable->removeFromAvatar(TRUE);
}
} }
queryWearableCache(); queryWearableCache();
@@ -1413,47 +1498,6 @@ void LLAgentWearables::removeWearableFinal( LLWearableType::EType type )
gInventory.notifyObservers(); gInventory.notifyObservers();
} }
void LLAgentWearables::copyWearableToInventory( LLWearableType::EType type )
{
LLWearable* wearable = getWearable(type);
if( wearable )
{
// Save the old wearable if it has changed.
if( wearable->isDirty() )
{
LLWearable * new_wearable = LLWearableList::instance().createCopyFromAvatar( wearable );
new_wearable->setItemID(wearable->getItemID());
setWearable(type,new_wearable);
wearable = new_wearable;
}
// Make a new entry in the inventory. (Put it in the same folder as the original item if possible.)
LLUUID category_id;
LLInventoryItem* item = gInventory.getItem( wearable->getItemID() );
if( item )
{
category_id = item->getParentUUID();
wearable->setPermissions(item->getPermissions());
}
LLPointer<LLInventoryCallback> cb =
new addWearableToAgentInventoryCallback(
LLPointer<LLRefCount>(NULL),
type,
wearable);
addWearableToAgentInventory(cb, wearable, category_id);
}
}
// A little struct to let setWearable() communicate more than one value with onSetWearableDialog().
struct LLSetWearableData
{
LLSetWearableData( const LLUUID& new_item_id, LLWearable* new_wearable ) :
mNewItemID( new_item_id ), mNewWearable( new_wearable ) {}
LLUUID mNewItemID;
LLWearable* mNewWearable;
};
static bool isFirstPhysicsWearable(LLWearableType::EType type, LLInventoryItem *new_item, LLWearable *new_wearable) static bool isFirstPhysicsWearable(LLWearableType::EType type, LLInventoryItem *new_item, LLWearable *new_wearable)
{ {
if (type == LLWearableType::WT_PHYSICS && gSavedSettings.getWarning("FirstPhysicsWearable")) if (type == LLWearableType::WT_PHYSICS && gSavedSettings.getWarning("FirstPhysicsWearable"))
@@ -1529,10 +1573,10 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
LLWearableType::EType type = new_wearable->getType(); LLWearableType::EType type = new_wearable->getType();
wearables_to_remove[type] = FALSE; wearables_to_remove[type] = FALSE;
LLWearable* old_wearable = getWearable(type); LLWearable* old_wearable = getWearable(type, 0);
if( old_wearable ) if( old_wearable )
{ {
const LLUUID& old_item_id = getWearableItemID(type); const LLUUID& old_item_id = getWearableItemID(type, 0);
if( (old_wearable->getAssetID() == new_wearable->getAssetID()) && if( (old_wearable->getAssetID() == new_wearable->getAssetID()) &&
(old_item_id == new_item->getUUID()) ) (old_item_id == new_item->getUUID()) )
{ {
@@ -1561,11 +1605,11 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
if (LLWearableType::getAssetType(type) == LLAssetType::AT_BODYPART) if (LLWearableType::getAssetType(type) == LLAssetType::AT_BODYPART)
{ {
// exactly one wearable per body part // exactly one wearable per body part
setWearable(type,new_wearable); setWearable(type,0,new_wearable);
} }
else if(old_wearable) //Remove when multi-wearables are implemented. else if(old_wearable) //Remove when multi-wearables are implemented.
{ {
setWearable(type,new_wearable); setWearable(type,0,new_wearable);
} }
else else
{ {
@@ -1580,8 +1624,8 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
{ {
if( wearables_to_remove[i] ) if( wearables_to_remove[i] )
{ {
LLWearable* wearable = getWearable((LLWearableType::EType)i); LLWearable* wearable = getWearable((LLWearableType::EType)i, 0);
wearables_being_removed.push_back(getWearable((LLWearableType::EType)i)); wearables_being_removed.push_back(getWearable((LLWearableType::EType)i, 0));
popWearable(wearable); popWearable(wearable);
gInventory.addChangedMask(LLInventoryObserver::LABEL, wearable->getItemID()); gInventory.addChangedMask(LLInventoryObserver::LABEL, wearable->getItemID());
@@ -1644,7 +1688,7 @@ void LLAgentWearables::setWearableItem( LLInventoryItem* new_item, LLWearable* n
return; return;
} }
LLWearable* old_wearable = getWearable(type); LLWearable* old_wearable = getWearable(type,0);
if( old_wearable ) if( old_wearable )
{ {
const LLUUID& old_item_id = old_wearable->getItemID(); const LLUUID& old_item_id = old_wearable->getItemID();
@@ -1673,6 +1717,7 @@ bool LLAgentWearables::onSetWearableDialog( const LLSD& notification, const LLSD
{ {
S32 option = LLNotificationsUtil::getSelectedOption(notification, response); S32 option = LLNotificationsUtil::getSelectedOption(notification, response);
LLInventoryItem* new_item = gInventory.getItem( notification["payload"]["item_id"].asUUID()); LLInventoryItem* new_item = gInventory.getItem( notification["payload"]["item_id"].asUUID());
U32 index = gAgentWearables.getWearableIndex(wearable);
if( !new_item ) if( !new_item )
{ {
delete wearable; delete wearable;
@@ -1682,7 +1727,7 @@ bool LLAgentWearables::onSetWearableDialog( const LLSD& notification, const LLSD
switch( option ) switch( option )
{ {
case 0: // "Save" case 0: // "Save"
gAgentWearables.saveWearable( wearable->getType() ); gAgentWearables.saveWearable(wearable->getType(),index);
gAgentWearables.setWearableFinal( new_item, wearable ); gAgentWearables.setWearableFinal( new_item, wearable );
break; break;
@@ -1707,24 +1752,29 @@ void LLAgentWearables::setWearableFinal( LLInventoryItem* new_item, LLWearable*
{ {
const LLWearableType::EType type = new_wearable->getType(); const LLWearableType::EType type = new_wearable->getType();
// Replace the old wearable with a new one.
llassert( new_item->getAssetUUID() == new_wearable->getAssetID() );
LLWearable *old_wearable = getWearable(type);
LLUUID old_item_id;
if (old_wearable)
{ {
old_item_id = old_wearable->getItemID(); // Replace the old wearable with a new one.
} llassert(new_item->getAssetUUID() == new_wearable->getAssetID());
new_wearable->setItemID(new_item->getUUID());
setWearable(type,new_wearable);
if (old_item_id.notNull()) LLWearable *old_wearable = getWearable(type,0);
{ LLUUID old_item_id;
gInventory.addChangedMask( LLInventoryObserver::LABEL, old_item_id ); if (old_wearable)
gInventory.notifyObservers(); {
old_item_id = old_wearable->getItemID();
}
new_wearable->setItemID(new_item->getUUID());
setWearable(type,0,new_wearable);
if (old_item_id.notNull())
{
gInventory.addChangedMask(LLInventoryObserver::LABEL, old_item_id);
gInventory.notifyObservers();
}
llinfos << "Replaced current element 0 for type " << type
<< " size is now " << mWearableDatas[type].size() << llendl;
} }
//llinfos << "LLVOAvatar::setWearable()" << llendl; //llinfos << "LLVOAvatar::setWearableItem()" << llendl;
queryWearableCache(); queryWearableCache();
new_wearable->writeToAvatar( TRUE ); new_wearable->writeToAvatar( TRUE );
@@ -1793,13 +1843,16 @@ LLUUID LLAgentWearables::computeBakedTextureHash(LLVOAvatarDefines::EBakedTextur
for (U8 i=0; i < baked_dict->mWearables.size(); i++) for (U8 i=0; i < baked_dict->mWearables.size(); i++)
{ {
const LLWearableType::EType baked_type = baked_dict->mWearables[i]; const LLWearableType::EType baked_type = baked_dict->mWearables[i];
//TO-DO: MULTI-WEARABLE const U32 num_wearables = getWearableCount(baked_type);
const LLWearable* wearable = getWearable(baked_type); for (U32 index = 0; index < num_wearables; ++index)
if (wearable)
{ {
LLUUID asset_id = wearable->getAssetID(); const LLWearable* wearable = getWearable(baked_type,index);
hash.update((const unsigned char*)asset_id.mData, UUID_BYTES); if (wearable)
hash_computed = true; {
LLUUID asset_id = wearable->getAssetID();
hash.update((const unsigned char*)asset_id.mData, UUID_BYTES);
hash_computed = true;
}
} }
} }
if (hash_computed) if (hash_computed)
@@ -1823,12 +1876,22 @@ LLUUID LLAgentWearables::computeBakedTextureHash(LLVOAvatarDefines::EBakedTextur
// User has picked "remove from avatar" from a menu. // User has picked "remove from avatar" from a menu.
// static // static
void LLAgentWearables::userRemoveWearable(const LLWearableType::EType &type) void LLAgentWearables::userRemoveWearable(const LLWearableType::EType &type, const U32 &index)
{ {
if( !(type==LLWearableType::WT_SHAPE || type==LLWearableType::WT_SKIN || type==LLWearableType::WT_HAIR || type==LLWearableType::WT_EYES) ) //&& if( !(type==LLWearableType::WT_SHAPE || type==LLWearableType::WT_SKIN || type==LLWearableType::WT_HAIR || type==LLWearableType::WT_EYES) ) //&&
//!((!gAgent.isTeen()) && ( type==WT_UNDERPANTS || type==WT_UNDERSHIRT )) ) //!((!gAgent.isTeen()) && ( type==WT_UNDERPANTS || type==WT_UNDERSHIRT )) )
{ {
gAgentWearables.removeWearable( type ); gAgentWearables.removeWearable(type,false,index);
}
}
//static
void LLAgentWearables::userRemoveWearablesOfType(const LLWearableType::EType &type)
{
if (!(type==LLWearableType::WT_SHAPE || type==LLWearableType::WT_SKIN || type==LLWearableType::WT_HAIR || type==LLWearableType::WT_EYES)) //&&
//!((!gAgent.isTeen()) && (type==LLWearableType::WT_UNDERPANTS || type==LLWearableType::WT_UNDERSHIRT)))
{
gAgentWearables.removeWearable(type,true,0);
} }
} }
@@ -1849,18 +1912,18 @@ void LLAgentWearables::userRemoveAllClothesStep2( BOOL proceed, void* userdata )
{ {
if( proceed ) if( proceed )
{ {
gAgentWearables.removeWearable( LLWearableType::WT_SHIRT ); gAgentWearables.userRemoveWearablesOfType( LLWearableType::WT_SHIRT );
gAgentWearables.removeWearable( LLWearableType::WT_PANTS ); gAgentWearables.userRemoveWearablesOfType( LLWearableType::WT_PANTS );
gAgentWearables.removeWearable( LLWearableType::WT_SHOES ); gAgentWearables.userRemoveWearablesOfType( LLWearableType::WT_SHOES );
gAgentWearables.removeWearable( LLWearableType::WT_SOCKS ); gAgentWearables.userRemoveWearablesOfType( LLWearableType::WT_SOCKS );
gAgentWearables.removeWearable( LLWearableType::WT_JACKET ); gAgentWearables.userRemoveWearablesOfType( LLWearableType::WT_JACKET );
gAgentWearables.removeWearable( LLWearableType::WT_GLOVES ); gAgentWearables.userRemoveWearablesOfType( LLWearableType::WT_GLOVES );
gAgentWearables.removeWearable( LLWearableType::WT_UNDERSHIRT ); gAgentWearables.userRemoveWearablesOfType( LLWearableType::WT_UNDERSHIRT );
gAgentWearables.removeWearable( LLWearableType::WT_UNDERPANTS ); gAgentWearables.userRemoveWearablesOfType( LLWearableType::WT_UNDERPANTS );
gAgentWearables.removeWearable( LLWearableType::WT_SKIRT ); gAgentWearables.userRemoveWearablesOfType( LLWearableType::WT_SKIRT );
gAgentWearables.removeWearable( LLWearableType::WT_ALPHA ); gAgentWearables.userRemoveWearablesOfType( LLWearableType::WT_ALPHA );
gAgentWearables.removeWearable( LLWearableType::WT_TATTOO ); gAgentWearables.userRemoveWearablesOfType( LLWearableType::WT_TATTOO );
gAgentWearables.removeWearable( LLWearableType::WT_PHYSICS ); gAgentWearables.userRemoveWearablesOfType( LLWearableType::WT_PHYSICS );
} }
} }
@@ -2099,7 +2162,7 @@ void LLAgentWearables::updateWearablesLoaded()
mWearablesLoaded = TRUE; mWearablesLoaded = TRUE;
for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ ) for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ )
{ {
if( !getWearableItemID((LLWearableType::EType)i).isNull() && !getWearable((LLWearableType::EType)i) ) if( !getWearableItemID((LLWearableType::EType)i, 0).isNull() && !getWearable((LLWearableType::EType)i, 0) )
{ {
mWearablesLoaded = FALSE; mWearablesLoaded = FALSE;
break; break;

View File

@@ -70,7 +70,7 @@ public:
// LLInitClass interface // LLInitClass interface
static void initClass(); static void initClass();
protected: protected:
void createStandardWearablesDone(S32 type); void createStandardWearablesDone(S32 type, U32 index/* = 0*/);
void createStandardWearablesAllDone(); void createStandardWearablesAllDone();
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@@ -78,10 +78,10 @@ protected:
//-------------------------------------------------------------------- //--------------------------------------------------------------------
public: public:
BOOL isWearingItem(const LLUUID& item_id) const; BOOL isWearingItem(const LLUUID& item_id) const;
BOOL isWearableModifiable(LLWearableType::EType type) const; BOOL isWearableModifiable(LLWearableType::EType type, U32 index /*= 0*/) const;
BOOL isWearableModifiable(const LLUUID& item_id) const; BOOL isWearableModifiable(const LLUUID& item_id) const;
BOOL isWearableCopyable(LLWearableType::EType type) const; BOOL isWearableCopyable(LLWearableType::EType type, U32 index /*= 0*/) const;
BOOL areWearablesLoaded() const; BOOL areWearablesLoaded() const;
void updateWearablesLoaded(); void updateWearablesLoaded();
//void checkWearablesLoaded() const; //void checkWearablesLoaded() const;
@@ -93,28 +93,26 @@ public:
//void animateAllWearableParams(F32 delta, BOOL upload_bake); //void animateAllWearableParams(F32 delta, BOOL upload_bake);
BOOL needsReplacement(LLWearableType::EType wearableType, S32 remove); BOOL needsReplacement(LLWearableType::EType wearableType, S32 remove);
U32 getWearablePermMask(LLWearableType::EType type) const; //U32 getWearablePermMask(LLWearableType::EType type) const;
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Accessors // Accessors
//-------------------------------------------------------------------- //--------------------------------------------------------------------
public: public:
const LLUUID getWearableItemID(LLWearableType::EType type ) const; const LLUUID getWearableItemID(LLWearableType::EType type, U32 index /*= 0*/) const;
const LLUUID getWearableAssetID(LLWearableType::EType type) const; const LLUUID getWearableAssetID(LLWearableType::EType type, U32 index /*= 0*/) const;
const LLWearable* getWearableFromItemID(const LLUUID& item_id) const; const LLWearable* getWearableFromItemID(const LLUUID& item_id) const;
LLWearable* getWearableFromItemID(const LLUUID& item_id); LLWearable* getWearableFromItemID(const LLUUID& item_id);
LLWearable* getWearableFromAssetID(const LLUUID& asset_id); LLWearable* getWearableFromAssetID(const LLUUID& asset_id);
LLInventoryItem* getWearableInventoryItem(LLWearableType::EType type); LLInventoryItem* getWearableInventoryItem(LLWearableType::EType type, U32 index /*= 0*/);
static BOOL selfHasWearable(LLWearableType::EType type); static BOOL selfHasWearable(LLWearableType::EType type);
LLWearable* getWearable( const LLWearableType::EType type ); LLWearable* getWearable(const LLWearableType::EType type, U32 index /*= 0*/);
const LLWearable* getWearable( const LLWearableType::EType type ) const; const LLWearable* getWearable(const LLWearableType::EType type, U32 index /*= 0*/) const;
LLWearable* getTopWearable(const LLWearableType::EType type); LLWearable* getTopWearable(const LLWearableType::EType type);
LLWearable* getBottomWearable(const LLWearableType::EType type); LLWearable* getBottomWearable(const LLWearableType::EType type);
U32 getWearableCount(const LLWearableType::EType type) const; U32 getWearableCount(const LLWearableType::EType type) const;
U32 getWearableCount(const U32 tex_index) const; U32 getWearableCount(const U32 tex_index) const;
void copyWearableToInventory( LLWearableType::EType type );
static const U32 MAX_CLOTHING_PER_TYPE = 1; static const U32 MAX_CLOTHING_PER_TYPE = 1;
@@ -124,11 +122,11 @@ public:
private: private:
// Low-level data structure setter - public access is via setWearableItem, etc. // Low-level data structure setter - public access is via setWearableItem, etc.
void setWearable(const LLWearableType::EType type, LLWearable *wearable); void setWearable(const LLWearableType::EType type, U32 index, LLWearable *wearable);
U32 pushWearable(const LLWearableType::EType type, LLWearable *wearable); U32 pushWearable(const LLWearableType::EType type, LLWearable *wearable);
void wearableUpdated(LLWearable *wearable); void wearableUpdated(LLWearable *wearable);
void popWearable(LLWearable *wearable); void popWearable(LLWearable *wearable);
void popWearable(const LLWearableType::EType type); void popWearable(const LLWearableType::EType type, U32 index);
public: public:
void setWearableItem(LLInventoryItem* new_item, LLWearable* wearable); void setWearableItem(LLInventoryItem* new_item, LLWearable* wearable);
@@ -156,11 +154,11 @@ protected:
* @param item_id The inventory item id of the new wearable to wear. * @param item_id The inventory item id of the new wearable to wear.
* @param wearable The actual wearable data. * @param wearable The actual wearable data.
*/ */
void addWearabletoAgentInventoryDone(const LLWearableType::EType type, void addWearabletoAgentInventoryDone(const LLWearableType::EType type,
const LLUUID& item_id, const U32 index,
LLWearable* wearable); const LLUUID& item_id,
LLWearable* wearable);
void recoverMissingWearable(LLWearableType::EType type); void recoverMissingWearable(const LLWearableType::EType type, U32 index /*= 0*/);
void recoverMissingWearableDone(); void recoverMissingWearableDone();
//-------------------------------------------------------------------- //--------------------------------------------------------------------
@@ -182,9 +180,9 @@ private:
// Removing wearables // Removing wearables
//-------------------------------------------------------------------- //--------------------------------------------------------------------
public: public:
void removeWearable( LLWearableType::EType type ); void removeWearable(const LLWearableType::EType type, bool do_remove_all /*= false*/, U32 index /*= 0*/);
private: private:
void removeWearableFinal( LLWearableType::EType type ); void removeWearableFinal(const LLWearableType::EType type, bool do_remove_all /*= false*/, U32 index /*= 0*/);
protected: protected:
static bool onRemoveWearableDialog(const LLSD& notification, const LLSD& response); static bool onRemoveWearableDialog(const LLSD& notification, const LLSD& response);
static void userRemoveAllClothesStep2(BOOL proceed, void* userdata ); // userdata is NULL static void userRemoveAllClothesStep2(BOOL proceed, void* userdata ); // userdata is NULL
@@ -220,25 +218,26 @@ public:
BOOL rename_clothing); BOOL rename_clothing);
private: private:
void makeNewOutfitDone(S32 type); void makeNewOutfitDone(S32 type, U32 index);
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Save Wearables // Save Wearables
//-------------------------------------------------------------------- //--------------------------------------------------------------------
public: public:
void saveWearableAs(const LLWearableType::EType type, const std::string& new_name, BOOL save_in_lost_and_found ); void saveWearableAs(const LLWearableType::EType type, const U32 index, const std::string& new_name, BOOL save_in_lost_and_found );
void saveWearable(const LLWearableType::EType type, BOOL send_update = TRUE, void saveWearable(const LLWearableType::EType type, const U32 index, BOOL send_update = TRUE,
const std::string new_name = ""); const std::string new_name = "");
void saveAllWearables(); void saveAllWearables();
void revertWearable( LLWearableType::EType type ); void revertWearable( LLWearableType::EType type, const U32 index);
void revertAllWearables(); void revertAllWearables();
//-------------------------------------------------------------------- //--------------------------------------------------------------------
// Static UI hooks // Static UI hooks
//-------------------------------------------------------------------- //--------------------------------------------------------------------
public: public:
static void userRemoveWearable(const LLWearableType::EType &type); static void userRemoveWearable(const LLWearableType::EType &type, const U32 &index);
static void userRemoveWearablesOfType(const LLWearableType::EType &type);
static void userRemoveAllClothes(); static void userRemoveAllClothes();
typedef std::vector<LLViewerObject*> llvo_vec_t; typedef std::vector<LLViewerObject*> llvo_vec_t;
@@ -321,12 +320,14 @@ private:
*/ */
addWearableToAgentInventoryCallback(LLPointer<LLRefCount> cb, addWearableToAgentInventoryCallback(LLPointer<LLRefCount> cb,
LLWearableType::EType type, LLWearableType::EType type,
U32 index,
LLWearable* wearable, LLWearable* wearable,
U32 todo = CALL_NONE); U32 todo = CALL_NONE);
virtual void fire(const LLUUID& inv_item); virtual void fire(const LLUUID& inv_item);
private: private:
LLWearableType::EType mType; LLWearableType::EType mType;
U32 mIndex;
LLWearable* mWearable; LLWearable* mWearable;
U32 mTodo; U32 mTodo;
LLPointer<LLRefCount> mCB; LLPointer<LLRefCount> mCB;

View File

@@ -590,7 +590,7 @@ void LLPanelEditWearable::setSubpart( ESubpart subpart )
LLVOAvatar* avatar = gAgentAvatarp; LLVOAvatar* avatar = gAgentAvatarp;
ESex avatar_sex = avatar->getSex(); ESex avatar_sex = avatar->getSex();
LLViewerInventoryItem* item; LLViewerInventoryItem* item;
item = (LLViewerInventoryItem*)gAgentWearables.getWearableInventoryItem(mType); item = (LLViewerInventoryItem*)gAgentWearables.getWearableInventoryItem(mType,0); // TODO: MULTI-WEARABLE
U32 perm_mask = 0x0; U32 perm_mask = 0x0;
BOOL is_complete = FALSE; BOOL is_complete = FALSE;
bool can_export = false; bool can_export = false;
@@ -656,27 +656,27 @@ void LLPanelEditWearable::onBtnTakeOff( void* userdata )
{ {
LLPanelEditWearable* self = (LLPanelEditWearable*) userdata; LLPanelEditWearable* self = (LLPanelEditWearable*) userdata;
LLWearable* wearable = gAgentWearables.getWearable( self->mType ); LLWearable* wearable = gAgentWearables.getWearable( self->mType, 0 ); // TODO: MULTI-WEARABLE
if( !wearable ) if( !wearable )
{ {
return; return;
} }
gAgentWearables.removeWearable( self->mType ); gAgentWearables.removeWearable( self->mType, false, 0 ); // TODO: MULTI-WEARABLE
} }
// static // static
void LLPanelEditWearable::onBtnSave( void* userdata ) void LLPanelEditWearable::onBtnSave( void* userdata )
{ {
LLPanelEditWearable* self = (LLPanelEditWearable*) userdata; LLPanelEditWearable* self = (LLPanelEditWearable*) userdata;
gAgentWearables.saveWearable( self->mType ); gAgentWearables.saveWearable( self->mType, 0 ); // TODO: MULTI-WEARABLE
} }
// static // static
void LLPanelEditWearable::onBtnSaveAs( void* userdata ) void LLPanelEditWearable::onBtnSaveAs( void* userdata )
{ {
LLPanelEditWearable* self = (LLPanelEditWearable*) userdata; LLPanelEditWearable* self = (LLPanelEditWearable*) userdata;
LLWearable* wearable = gAgentWearables.getWearable( self->getType() ); LLWearable* wearable = gAgentWearables.getWearable( self->getType(), 0 ); // TODO: MULTI-WEARABLE
if( wearable ) if( wearable )
{ {
LLWearableSaveAsDialog* save_as_dialog = new LLWearableSaveAsDialog( wearable->getName(), onSaveAsCommit, self ); LLWearableSaveAsDialog* save_as_dialog = new LLWearableSaveAsDialog( wearable->getName(), onSaveAsCommit, self );
@@ -692,7 +692,7 @@ void LLPanelEditWearable::onSaveAsCommit( LLWearableSaveAsDialog* save_as_dialog
LLVOAvatar* avatar = gAgentAvatarp; LLVOAvatar* avatar = gAgentAvatarp;
if( avatar ) if( avatar )
{ {
gAgentWearables.saveWearableAs( self->getType(), save_as_dialog->getItemName(), FALSE ); gAgentWearables.saveWearableAs( self->getType(), 0, save_as_dialog->getItemName(), FALSE ); // TODO: MULTI-WEARABLE
} }
} }
@@ -701,7 +701,7 @@ void LLPanelEditWearable::onSaveAsCommit( LLWearableSaveAsDialog* save_as_dialog
void LLPanelEditWearable::onBtnRevert( void* userdata ) void LLPanelEditWearable::onBtnRevert( void* userdata )
{ {
LLPanelEditWearable* self = (LLPanelEditWearable*) userdata; LLPanelEditWearable* self = (LLPanelEditWearable*) userdata;
gAgentWearables.revertWearable( self->mType ); gAgentWearables.revertWearable( self->mType, 0 ); // TODO: MULTI-WEARABLE
} }
// static // static
@@ -740,7 +740,7 @@ bool LLPanelEditWearable::onSelectAutoWearOption(const LLSD& notification, const
bool LLPanelEditWearable::textureIsInvisible(ETextureIndex te) bool LLPanelEditWearable::textureIsInvisible(ETextureIndex te)
{ {
if (gAgentWearables.getWearable(mType)) if (gAgentWearables.getWearable(mType, 0)) // TODO: MULTI-WEARABLE
{ {
LLVOAvatar *avatar = gAgentAvatarp; LLVOAvatar *avatar = gAgentAvatarp;
if (avatar) if (avatar)
@@ -876,7 +876,7 @@ void LLPanelEditWearable::addTextureDropTarget( ETextureIndex te, const std::str
LLVOAvatar* avatar = gAgentAvatarp; LLVOAvatar* avatar = gAgentAvatarp;
if (avatar) if (avatar)
{ {
LLWearable* wearable = gAgentWearables.getWearable(mType); LLWearable* wearable = gAgentWearables.getWearable(mType, 0); // TODO: MULTI-WEARABLE
if (wearable && mType == LLWearableType::WT_ALPHA) if (wearable && mType == LLWearableType::WT_ALPHA)
{ {
const LLTextureEntry* current_te = avatar->getTE(te); const LLTextureEntry* current_te = avatar->getTE(te);
@@ -906,7 +906,7 @@ void LLPanelEditWearable::onTextureCommit( LLUICtrl* ctrl, void* userdata )
image = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT_AVATAR); image = LLViewerTextureManager::getFetchedTexture(IMG_DEFAULT_AVATAR);
} }
self->mTextureList[ctrl->getName()] = te; self->mTextureList[ctrl->getName()] = te;
if (gAgentWearables.getWearable(self->mType)) if (gAgentWearables.getWearable(self->mType, 0)) // TODO: MULTI-WEARABLE
{ {
avatar->setLocTexTE(te, image, TRUE); avatar->setLocTexTE(te, image, TRUE);
avatar->wearableUpdated(self->mType, FALSE); avatar->wearableUpdated(self->mType, FALSE);
@@ -958,14 +958,14 @@ void LLPanelEditWearable::draw()
return; return;
} }
LLWearable* wearable = gAgentWearables.getWearable( mType ); LLWearable* wearable = gAgentWearables.getWearable( mType, 0 ); // TODO: MULTI-WEARABLE
BOOL has_wearable = (wearable != NULL ); BOOL has_wearable = (wearable != NULL );
BOOL is_dirty = isDirty(); BOOL is_dirty = isDirty();
BOOL is_modifiable = FALSE; BOOL is_modifiable = FALSE;
BOOL is_copyable = FALSE; BOOL is_copyable = FALSE;
BOOL is_complete = FALSE; BOOL is_complete = FALSE;
LLViewerInventoryItem* item; LLViewerInventoryItem* item;
item = (LLViewerInventoryItem*)gAgentWearables.getWearableInventoryItem(mType); item = (LLViewerInventoryItem*)gAgentWearables.getWearableInventoryItem(mType, 0); // TODO: MULTI-WEARABLE
if(item) if(item)
{ {
const LLPermissions& perm = item->getPermissions(); const LLPermissions& perm = item->getPermissions();
@@ -1041,7 +1041,7 @@ void LLPanelEditWearable::draw()
childSetTextArg("title_loading", "[DESC]", std::string(LLWearableType::getTypeLabel( mType ))); childSetTextArg("title_loading", "[DESC]", std::string(LLWearableType::getTypeLabel( mType )));
std::string path; std::string path;
const LLUUID& item_id = gAgentWearables.getWearableItemID( wearable->getType() ); const LLUUID& item_id = gAgentWearables.getWearableItemID( wearable->getType(), 0 ); // TODO: MULTI-WEARABLE
append_path(item_id, path); append_path(item_id, path);
childSetVisible("path", TRUE); childSetVisible("path", TRUE);
childSetTextArg("path", "[PATH]", path); childSetTextArg("path", "[PATH]", path);
@@ -1054,7 +1054,7 @@ void LLPanelEditWearable::draw()
childSetTextArg("title", "[DESC]", wearable->getName() ); childSetTextArg("title", "[DESC]", wearable->getName() );
std::string path; std::string path;
const LLUUID& item_id = gAgentWearables.getWearableItemID( wearable->getType() ); const LLUUID& item_id = gAgentWearables.getWearableItemID( wearable->getType(), 0 ); // TODO: MULTI-WEARABLE
append_path(item_id, path); append_path(item_id, path);
childSetVisible("path", TRUE); childSetVisible("path", TRUE);
childSetTextArg("path", "[PATH]", path); childSetTextArg("path", "[PATH]", path);
@@ -1201,7 +1201,7 @@ void LLPanelEditWearable::setVisible(BOOL visible)
BOOL LLPanelEditWearable::isDirty() const BOOL LLPanelEditWearable::isDirty() const
{ {
LLWearable* wearable = gAgentWearables.getWearable( mType ); LLWearable* wearable = gAgentWearables.getWearable( mType, 0 ); // TODO: MULTI-WEARABLE
if( !wearable ) if( !wearable )
{ {
return FALSE; return FALSE;
@@ -1226,7 +1226,7 @@ void LLPanelEditWearable::onCommitSexChange( LLUICtrl*, void* userdata )
return; return;
} }
if( !gAgentWearables.isWearableModifiable(self->mType)) if( !gAgentWearables.isWearableModifiable(self->mType, 0)) // TODO: MULTI-WEARABLE
{ {
return; return;
} }
@@ -1936,10 +1936,10 @@ void LLFloaterCustomize::onBtnExport_continued(AIFilePicker* filepicker)
for( S32 i=0; i < LLWearableType::WT_COUNT; i++ ) for( S32 i=0; i < LLWearableType::WT_COUNT; i++ )
{ {
is_modifiable = FALSE; is_modifiable = FALSE;
LLWearable* old_wearable = gAgentWearables.getWearable((LLWearableType::EType)i); LLWearable* old_wearable = gAgentWearables.getWearable((LLWearableType::EType)i, 0); // TODO: MULTI-WEARABLE
if( old_wearable ) if( old_wearable )
{ {
item = (LLViewerInventoryItem*)gAgentWearables.getWearableInventoryItem((LLWearableType::EType)i); item = (LLViewerInventoryItem*)gAgentWearables.getWearableInventoryItem((LLWearableType::EType)i, 0); // TODO: MULTI-WEARABLE
if(item) if(item)
{ {
const LLPermissions& perm = item->getPermissions(); const LLPermissions& perm = item->getPermissions();
@@ -1960,10 +1960,10 @@ void LLFloaterCustomize::onBtnExport_continued(AIFilePicker* filepicker)
for( S32 i=0; i < LLWearableType::WT_COUNT; i++ ) for( S32 i=0; i < LLWearableType::WT_COUNT; i++ )
{ {
is_modifiable = FALSE; is_modifiable = FALSE;
LLWearable* old_wearable = gAgentWearables.getWearable((LLWearableType::EType)i); LLWearable* old_wearable = gAgentWearables.getWearable((LLWearableType::EType)i, 0); // TODO: MULTI-WEARABLE
if( old_wearable ) if( old_wearable )
{ {
item = (LLViewerInventoryItem*)gAgentWearables.getWearableInventoryItem((LLWearableType::EType)i); item = (LLViewerInventoryItem*)gAgentWearables.getWearableInventoryItem((LLWearableType::EType)i, 0); // TODO: MULTI-WEARABLE
if(item) if(item)
{ {
const LLPermissions& perm = item->getPermissions(); const LLPermissions& perm = item->getPermissions();
@@ -2015,7 +2015,7 @@ void LLFloaterCustomize::onBtnMakeOutfit( void* userdata )
for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ ) for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ )
{ {
BOOL enabled = (gAgentWearables.getWearable( (LLWearableType::EType) i ) != NULL); BOOL enabled = (gAgentWearables.getWearable( (LLWearableType::EType) i, 0 ) != NULL); // TODO: MULTI-WEARABLE
BOOL selected = (enabled && (LLWearableType::WT_SHIRT <= i) && (i < LLWearableType::WT_COUNT)); // only select clothing by default BOOL selected = (enabled && (LLWearableType::WT_SHIRT <= i) && (i < LLWearableType::WT_COUNT)); // only select clothing by default
if (gAgent.isTeen() if (gAgent.isTeen()
&& !edit_wearable_for_teens((LLWearableType::EType)i)) && !edit_wearable_for_teens((LLWearableType::EType)i))
@@ -2748,13 +2748,13 @@ bool LLFloaterCustomize::onSaveDialog(const LLSD& notification, const LLSD& resp
switch( option ) switch( option )
{ {
case 0: // "Save" case 0: // "Save"
gAgentWearables.saveWearable( cur ); gAgentWearables.saveWearable( cur, 0 ); // TODO: MULTI-WEARABLE
proceed = TRUE; proceed = TRUE;
break; break;
case 1: // "Don't Save" case 1: // "Don't Save"
{ {
gAgentWearables.revertWearable( cur ); gAgentWearables.revertWearable( cur, 0 ); // TODO: MULTI-WEARABLE
proceed = TRUE; proceed = TRUE;
} }
break; break;
@@ -2790,7 +2790,7 @@ void LLFloaterCustomize::fetchInventory()
LLUUID item_id; LLUUID item_id;
for(S32 type = (S32)LLWearableType::WT_SHAPE; type < (S32)LLWearableType::WT_COUNT; ++type) for(S32 type = (S32)LLWearableType::WT_SHAPE; type < (S32)LLWearableType::WT_COUNT; ++type)
{ {
item_id = gAgentWearables.getWearableItemID((LLWearableType::EType)type); item_id = gAgentWearables.getWearableItemID((LLWearableType::EType)type, 0); // TODO: MULTI-WEARABLE
if(item_id.notNull()) if(item_id.notNull())
{ {
ids.push_back(item_id); ids.push_back(item_id);
@@ -2816,7 +2816,7 @@ void LLFloaterCustomize::updateInventoryUI()
panel = mWearablePanelList[i]; panel = mWearablePanelList[i];
if(panel) if(panel)
{ {
item = (LLViewerInventoryItem*)gAgentWearables.getWearableInventoryItem(panel->getType()); item = (LLViewerInventoryItem*)gAgentWearables.getWearableInventoryItem(panel->getType(), 0); // TODO: MULTI-WEARABLE
} }
if(item) if(item)
{ {
@@ -2851,7 +2851,7 @@ void LLFloaterCustomize::updateScrollingPanelUI()
LLPanelEditWearable* panel = mWearablePanelList[sCurrentWearableType]; LLPanelEditWearable* panel = mWearablePanelList[sCurrentWearableType];
if(panel) if(panel)
{ {
LLViewerInventoryItem* item = (LLViewerInventoryItem*)gAgentWearables.getWearableInventoryItem(panel->getType()); LLViewerInventoryItem* item = (LLViewerInventoryItem*)gAgentWearables.getWearableInventoryItem(panel->getType(), 0); // TODO: MULTI-WEARABLE
if(item) if(item)
{ {
U32 perm_mask = item->getPermissions().getMaskOwner(); U32 perm_mask = item->getPermissions().getMaskOwner();

View File

@@ -5422,7 +5422,7 @@ void LLWearableBridge::onRemoveFromAvatarArrived(LLWearable* wearable,
if( !(type==LLWearableType::WT_SHAPE || type==LLWearableType::WT_SKIN || type==LLWearableType::WT_HAIR || type==LLWearableType::WT_EYES) ) //&& if( !(type==LLWearableType::WT_SHAPE || type==LLWearableType::WT_SKIN || type==LLWearableType::WT_HAIR || type==LLWearableType::WT_EYES) ) //&&
//!((!gAgent.isTeen()) && ( type==WT_UNDERPANTS || type==WT_UNDERSHIRT )) ) //!((!gAgent.isTeen()) && ( type==WT_UNDERPANTS || type==WT_UNDERSHIRT )) )
{ {
gAgentWearables.removeWearable( type ); gAgentWearables.removeWearable( type, false, 0 ); // TODO: MULTI-WEARABLE
} }
} }
} }

View File

@@ -84,7 +84,7 @@ LLBakedUploadData::LLBakedUploadData( LLVOAvatar* avatar,
mStartTime = LLFrameTimer::getTotalTime(); // Record starting time mStartTime = LLFrameTimer::getTotalTime(); // Record starting time
for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ ) for( S32 i = 0; i < LLWearableType::WT_COUNT; i++ )
{ {
LLWearable* wearable = gAgentWearables.getWearable( (LLWearableType::EType)i); LLWearable* wearable = gAgentWearables.getWearable( (LLWearableType::EType)i, 0); // TODO: MULTI-WEARABLE
if( wearable ) if( wearable )
{ {
mWearableAssets[i] = wearable->getAssetID(); mWearableAssets[i] = wearable->getAssetID();

View File

@@ -9184,7 +9184,7 @@ class LLEditTakeOff : public view_listener_t
LLWearableType::EType type = LLWearableType::typeNameToType(clothing); LLWearableType::EType type = LLWearableType::typeNameToType(clothing);
if (type >= LLWearableType::WT_SHAPE if (type >= LLWearableType::WT_SHAPE
&& type < LLWearableType::WT_COUNT) && type < LLWearableType::WT_COUNT)
LLAgentWearables::userRemoveWearable(type); LLAgentWearables::userRemoveWearable(type,0); // TODO: MULTI-WEARABLE
} }
return true; return true;
} }

View File

@@ -659,7 +659,7 @@ void LLWearable::writeToAvatar( BOOL set_by_user )
if( gFloaterCustomize ) if( gFloaterCustomize )
{ {
LLViewerInventoryItem* item; LLViewerInventoryItem* item;
item = (LLViewerInventoryItem*)gInventory.getItem(gAgentWearables.getWearableItemID(mType)); item = (LLViewerInventoryItem*)gInventory.getItem(gAgentWearables.getWearableItemID(mType, 0)); // TODO: MULTI-WEARABLE
U32 perm_mask = PERM_NONE; U32 perm_mask = PERM_NONE;
BOOL is_complete = FALSE; BOOL is_complete = FALSE;
if(item) if(item)

View File

@@ -33,6 +33,7 @@
#ifndef LL_LLWEARABLELIST_H #ifndef LL_LLWEARABLELIST_H
#define LL_LLWEARABLELIST_H #define LL_LLWEARABLELIST_H
#include "llmemory.h"
#include "llwearable.h" #include "llwearable.h"
#include "lluuid.h" #include "lluuid.h"
#include "llassetstorage.h" #include "llassetstorage.h"

View File

@@ -2005,7 +2005,7 @@ ERlvCmdRet RlvHandler::onGetOutfit(const RlvCommand& rlvCmd, std::string& strRep
{ {
// We never hide body parts, even if they're "locked" and we're hiding locked layers // We never hide body parts, even if they're "locked" and we're hiding locked layers
// (nor do we hide a layer if the issuing object is the only one that has this layer locked) // (nor do we hide a layer if the issuing object is the only one that has this layer locked)
bool fWorn = (gAgentWearables.getWearable(wtRlvTypes[idxType])) && bool fWorn = (gAgentWearables.getWearable(wtRlvTypes[idxType], 0)) && // TODO: MULTI-WEARABLE
( (!RlvSettings::getHideLockedLayers()) || ( (!RlvSettings::getHideLockedLayers()) ||
(LLAssetType::AT_BODYPART == LLWearableType::getAssetType(wtRlvTypes[idxType])) || (LLAssetType::AT_BODYPART == LLWearableType::getAssetType(wtRlvTypes[idxType])) ||
(RlvForceWear::isForceRemovable(wtRlvTypes[idxType], true, rlvCmd.getObjectID())) ); (RlvForceWear::isForceRemovable(wtRlvTypes[idxType], true, rlvCmd.getObjectID())) );
@@ -2033,7 +2033,7 @@ ERlvCmdRet RlvHandler::onGetOutfitNames(const RlvCommand& rlvCmd, std::string& s
switch (rlvCmd.getBehaviourType()) switch (rlvCmd.getBehaviourType())
{ {
case RLV_BHVR_GETOUTFITNAMES: // Every layer that's worn case RLV_BHVR_GETOUTFITNAMES: // Every layer that's worn
fAdd = (gAgentWearables.getWearable(wtType) != NULL); fAdd = (gAgentWearables.getWearable(wtType, 0) != NULL); // TODO: MULTI-WEARABLE
break; break;
/* /*
case RLV_BHVR_GETADDOUTFITNAMES: // Every layer that can be worn on (but ignore any locks set by the issuer) case RLV_BHVR_GETADDOUTFITNAMES: // Every layer that can be worn on (but ignore any locks set by the issuer)

View File

@@ -213,7 +213,7 @@ RlvCommandOptionGetPath::RlvCommandOptionGetPath(const RlvCommand& rlvCmd)
if (rlvCmdOption.isWearableType()) // <option> can be a clothing layer if (rlvCmdOption.isWearableType()) // <option> can be a clothing layer
{ {
LLWearableType::EType wtType = rlvCmdOption.getWearableType(); LLWearableType::EType wtType = rlvCmdOption.getWearableType();
m_idItems.push_back(gAgentWearables.getWearableItemID(wtType)); m_idItems.push_back(gAgentWearables.getWearableItemID(wtType, 0)); // TODO: MULTI-WEARABLE
} }
else if (rlvCmdOption.isAttachmentPoint()) // ... or it can specify an attachment point else if (rlvCmdOption.isAttachmentPoint()) // ... or it can specify an attachment point
{ {
@@ -554,7 +554,7 @@ bool RlvForceWear::isForceRemovable(const LLWearable* pWearable, bool fCheckComp
(pWearable) && (LLAssetType::AT_CLOTHING == pWearable->getAssetType()) (pWearable) && (LLAssetType::AT_CLOTHING == pWearable->getAssetType())
&& ( (idExcept.isNull()) ? !gRlvWearableLocks.isLockedWearable(pWearable) && ( (idExcept.isNull()) ? !gRlvWearableLocks.isLockedWearable(pWearable)
: !gRlvWearableLocks.isLockedWearableExcept(pWearable, idExcept) ) : !gRlvWearableLocks.isLockedWearableExcept(pWearable, idExcept) )
&& (isStrippable(gAgentWearables.getWearableItemID(pWearable->getType()))) && (isStrippable(gAgentWearables.getWearableItemID(pWearable->getType(), 0))) // TODO: MULTI-WEARABLE
#ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS #ifdef RLV_EXPERIMENTAL_COMPOSITEFOLDERS
&& ( (!fCheckComposite) || (!RlvSettings::getEnableComposites()) || && ( (!fCheckComposite) || (!RlvSettings::getEnableComposites()) ||
(!gRlvHandler.getCompositeInfo(pWearable->getItemID(), NULL, &pFolder)) || (gRlvHandler.canTakeOffComposite(pFolder)) ) (!gRlvHandler.getCompositeInfo(pWearable->getItemID(), NULL, &pFolder)) || (gRlvHandler.canTakeOffComposite(pFolder)) )
@@ -566,7 +566,7 @@ bool RlvForceWear::isForceRemovable(const LLWearable* pWearable, bool fCheckComp
bool RlvForceWear::isForceRemovable(LLWearableType::EType wtType, bool fCheckComposite /*=true*/, const LLUUID& idExcept /*=LLUUID::null*/) bool RlvForceWear::isForceRemovable(LLWearableType::EType wtType, bool fCheckComposite /*=true*/, const LLUUID& idExcept /*=LLUUID::null*/)
{ {
// Wearable type can be removed by an RLV command if there's at least one currently worn wearable that can be removed // Wearable type can be removed by an RLV command if there's at least one currently worn wearable that can be removed
if (isForceRemovable(gAgentWearables.getWearable(wtType), fCheckComposite, idExcept)) if (isForceRemovable(gAgentWearables.getWearable(wtType, 0), fCheckComposite, idExcept)) // TODO: MULTI-WEARABLE
return true; return true;
return false; return false;
} }
@@ -600,7 +600,7 @@ void RlvForceWear::forceRemove(const LLWearable* pWearable)
// Checked: 2010-03-19 (RLVa-1.1.3a) | Added: RLVa-1.2.0a // Checked: 2010-03-19 (RLVa-1.1.3a) | Added: RLVa-1.2.0a
void RlvForceWear::forceRemove(LLWearableType::EType wtType) void RlvForceWear::forceRemove(LLWearableType::EType wtType)
{ {
forceRemove(gAgentWearables.getWearable(wtType)); forceRemove(gAgentWearables.getWearable(wtType,0)); // TODO: MULTI-WEARABLE
} }
// Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a // Checked: 2010-03-19 (RLVa-1.2.0c) | Modified: RLVa-1.2.0a
@@ -741,7 +741,7 @@ void RlvForceWear::addWearable(const LLViewerInventoryItem* pItem, EWearAction e
void RlvForceWear::remWearable(const LLWearable* pWearable) void RlvForceWear::remWearable(const LLWearable* pWearable)
{ {
// Remove it from 'm_addWearables' if it's queued for wearing // Remove it from 'm_addWearables' if it's queued for wearing
const LLViewerInventoryItem* pItem = gInventory.getItem(gAgentWearables.getWearableItemID(pWearable->getType())); const LLViewerInventoryItem* pItem = gInventory.getItem(gAgentWearables.getWearableItemID(pWearable->getType(), 0)); // TODO: MULTI-WEARABLE
if ( (pItem) && (isAddWearable(pItem)) ) if ( (pItem) && (isAddWearable(pItem)) )
{ {
addwearables_map_t::iterator itAddWearables = m_addWearables.find(pItem->getWearableType()); addwearables_map_t::iterator itAddWearables = m_addWearables.find(pItem->getWearableType());
@@ -775,7 +775,7 @@ void RlvForceWear::done()
if (m_remWearables.size()) if (m_remWearables.size())
{ {
for (std::list<const LLWearable*>::const_iterator itWearable = m_remWearables.begin(); itWearable != m_remWearables.end(); ++itWearable) for (std::list<const LLWearable*>::const_iterator itWearable = m_remWearables.begin(); itWearable != m_remWearables.end(); ++itWearable)
gAgentWearables.removeWearable((*itWearable)->getType()); gAgentWearables.removeWearable((*itWearable)->getType(), false, 0); // TODO: MULTI-WEARABLE
m_remWearables.clear(); m_remWearables.clear();
} }

View File

@@ -141,7 +141,7 @@ void RlvInventory::fetchWornItems()
// Fetch all currently worn clothing layers and body parts // Fetch all currently worn clothing layers and body parts
for (int type = 0; type < LLWearableType::WT_COUNT; type++) for (int type = 0; type < LLWearableType::WT_COUNT; type++)
{ {
const LLUUID idItem = gAgentWearables.getWearableItemID((LLWearableType::EType)type); const LLUUID idItem = gAgentWearables.getWearableItemID((LLWearableType::EType)type, 0); // TODO: MULTI-WEARABLE
if (idItem.notNull()) if (idItem.notNull())
idItems.push_back(idItem); idItems.push_back(idItem);
} }

View File

@@ -876,7 +876,7 @@ void RlvWearableLocks::addWearableTypeLock(LLWearableType::EType eType, const LL
if (eLock & RLV_LOCK_REMOVE) if (eLock & RLV_LOCK_REMOVE)
{ {
m_WearableTypeRem.insert(std::pair<LLWearableType::EType, LLUUID>(eType, idRlvObj)); m_WearableTypeRem.insert(std::pair<LLWearableType::EType, LLUUID>(eType, idRlvObj));
LLUUID item_id = gAgentWearables.getWearableItemID(eType); LLUUID item_id = gAgentWearables.getWearableItemID(eType, 0); // TODO: MULTI-WEARABLE
if(item_id.notNull()) if(item_id.notNull())
{ {
gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id);
@@ -891,7 +891,7 @@ void RlvWearableLocks::addWearableTypeLock(LLWearableType::EType eType, const LL
bool RlvWearableLocks::canRemove(LLWearableType::EType eType) const bool RlvWearableLocks::canRemove(LLWearableType::EType eType) const
{ {
// NOTE: we return TRUE if the wearable type has at least one wearable that can be removed by the user // NOTE: we return TRUE if the wearable type has at least one wearable that can be removed by the user
LLWearable* pWearable = gAgentWearables.getWearable(eType); LLWearable* pWearable = gAgentWearables.getWearable(eType, 0); // TODO: MULTI-WEARABLE
if ( (pWearable) && (!isLockedWearable(pWearable)) ) if ( (pWearable) && (!isLockedWearable(pWearable)) )
return true; return true;
return false; return false;
@@ -901,7 +901,7 @@ bool RlvWearableLocks::canRemove(LLWearableType::EType eType) const
bool RlvWearableLocks::hasLockedWearable(LLWearableType::EType eType) const bool RlvWearableLocks::hasLockedWearable(LLWearableType::EType eType) const
{ {
// NOTE: we return TRUE if there is at least 1 non-removable wearable currently worn on this wearable type // NOTE: we return TRUE if there is at least 1 non-removable wearable currently worn on this wearable type
LLWearable* pWearable = gAgentWearables.getWearable(eType); LLWearable* pWearable = gAgentWearables.getWearable(eType, 0); // TODO: MULTI-WEARABLE
if ( (pWearable) && (isLockedWearable(pWearable)) ) if ( (pWearable) && (isLockedWearable(pWearable)) )
return true; return true;
return false; return false;
@@ -972,7 +972,7 @@ void RlvWearableLocks::removeWearableTypeLock(LLWearableType::EType eType, const
{ {
if(m_WearableTypeRem.find(eType) == m_WearableTypeRem.end()) if(m_WearableTypeRem.find(eType) == m_WearableTypeRem.end())
{ {
LLUUID item_id = gAgentWearables.getWearableItemID(eType); LLUUID item_id = gAgentWearables.getWearableItemID(eType, 0); // TODO: MULTI-WEARABLE
if(item_id.notNull()) if(item_id.notNull())
{ {
gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id); gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id);