summaryrefslogtreecommitdiff
path: root/indra/newview/llagentwearables.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llagentwearables.cpp')
-rw-r--r--indra/newview/llagentwearables.cpp64
1 files changed, 42 insertions, 22 deletions
diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp
index bb00468d40..b9a0b4293d 100644
--- a/indra/newview/llagentwearables.cpp
+++ b/indra/newview/llagentwearables.cpp
@@ -649,6 +649,7 @@ void LLAgentWearables::setWearable(const EWearableType type, U32 index, LLWearab
else
{
wearable_vec[index] = wearable;
+ mAvatarObject->wearableUpdated(wearable->getType());
}
}
@@ -663,14 +664,23 @@ U32 LLAgentWearables::pushWearable(const EWearableType type, LLWearable *wearabl
if (type < WT_COUNT || mWearableDatas[type].size() < MAX_WEARABLES_PER_TYPE)
{
mWearableDatas[type].push_back(wearable);
+ mAvatarObject->wearableUpdated(wearable->getType());
return mWearableDatas[type].size()-1;
}
return MAX_WEARABLES_PER_TYPE;
}
-void LLAgentWearables::popWearable(const EWearableType type, LLWearable *wearable)
+void LLAgentWearables::popWearable(LLWearable *wearable)
{
- U32 index = getWearableIndex(type, wearable);
+ if (wearable == NULL)
+ {
+ // nothing to do here. move along.
+ return;
+ }
+
+ U32 index = getWearableIndex(wearable);
+ EWearableType type = wearable->getType();
+
if (index < MAX_WEARABLES_PER_TYPE && index < getWearableCount(type))
{
popWearable(type, index);
@@ -679,14 +689,22 @@ void LLAgentWearables::popWearable(const EWearableType type, LLWearable *wearabl
void LLAgentWearables::popWearable(const EWearableType type, U32 index)
{
- if (getWearable(type, index))
+ LLWearable *wearable = getWearable(type, index);
+ if (wearable)
{
mWearableDatas[type].erase(mWearableDatas[type].begin() + index);
+ mAvatarObject->wearableUpdated(wearable->getType());
}
}
-U32 LLAgentWearables::getWearableIndex(const EWearableType type, LLWearable *wearable)
+U32 LLAgentWearables::getWearableIndex(LLWearable *wearable)
{
+ if (wearable == NULL)
+ {
+ return MAX_WEARABLES_PER_TYPE;
+ }
+
+ const EWearableType type = wearable->getType();
wearableentry_map_t::const_iterator wearable_iter = mWearableDatas.find(type);
if (wearable_iter == mWearableDatas.end())
{
@@ -780,22 +798,12 @@ const LLUUID LLAgentWearables::getWearableAssetID(EWearableType type, U32 index)
return LLUUID();
}
-// Warning: include_linked_items = TRUE makes this operation expensive.
-BOOL LLAgentWearables::isWearingItem(const LLUUID& item_id, BOOL include_linked_items) const
+BOOL LLAgentWearables::isWearingItem(const LLUUID& item_id) const
{
- if (getWearableFromItemID(item_id) != NULL) return TRUE;
- if (include_linked_items)
+ const LLUUID& base_item_id = gInventory.getLinkedItemID(item_id);
+ if (getWearableFromItemID(base_item_id) != NULL)
{
- LLInventoryModel::item_array_t item_array;
- gInventory.collectLinkedItems(item_id, item_array);
- for (LLInventoryModel::item_array_t::iterator iter = item_array.begin();
- iter != item_array.end();
- iter++)
- {
- LLViewerInventoryItem *linked_item = (*iter);
- const LLUUID &linked_item_id = linked_item->getUUID();
- if (getWearableFromItemID(linked_item_id) != NULL) return TRUE;
- }
+ return TRUE;
}
return FALSE;
}
@@ -1310,6 +1318,11 @@ void LLAgentWearables::removeWearable(const EWearableType type, bool do_remove_a
// TODO: enable the removing of a single undershirt/underpants if multiple are worn. - Nyx
return;
}
+ if (getWearableCount(type) == 0)
+ {
+ // no wearables to remove
+ return;
+ }
if (do_remove_all)
{
@@ -1376,8 +1389,9 @@ void LLAgentWearables::removeWearableFinal(const EWearableType type, bool do_rem
for (S32 i=max_entry; i>=0; i--)
{
LLWearable* old_wearable = getWearable(type,i);
- gInventory.addChangedMask(LLInventoryObserver::LABEL, getWearableItemID(type,i));
+ const LLUUID &item_id = getWearableItemID(type,i);
popWearable(type,i);
+ gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id);
//queryWearableCache(); // moved below
if (old_wearable)
@@ -1391,8 +1405,9 @@ void LLAgentWearables::removeWearableFinal(const EWearableType type, bool do_rem
{
LLWearable* old_wearable = getWearable(type, index);
- gInventory.addChangedMask(LLInventoryObserver::LABEL, getWearableItemID(type,index));
+ const LLUUID &item_id = getWearableItemID(type,index);
popWearable(type, index);
+ gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id);
//queryWearableCache(); // moved below
@@ -1431,6 +1446,9 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
wearables_to_remove[WT_UNDERSHIRT] = (!gAgent.isTeen()) & remove;
wearables_to_remove[WT_UNDERPANTS] = (!gAgent.isTeen()) & remove;
wearables_to_remove[WT_SKIRT] = remove;
+ wearables_to_remove[WT_ALPHA] = remove;
+ wearables_to_remove[WT_TATTOO] = remove;
+
S32 count = wearables.count();
llassert(items.count() == count);
@@ -1457,7 +1475,6 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
}
gInventory.addChangedMask(LLInventoryObserver::LABEL, old_item_id);
-
// Assumes existing wearables are not dirty.
if (old_wearable->isDirty())
{
@@ -1479,7 +1496,8 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it
{
// MULTI_WEARABLE: assuming 0th
LLWearable* wearable = getWearable((EWearableType)i, 0);
- gInventory.addChangedMask(LLInventoryObserver::LABEL, getWearableItemID((EWearableType)i,0));
+ const LLUUID &item_id = getWearableItemID((EWearableType)i,0);
+ gInventory.addChangedMask(LLInventoryObserver::LABEL, item_id);
if (wearable)
{
wearables_being_removed.push_back(wearable);
@@ -1743,6 +1761,8 @@ void LLAgentWearables::userRemoveAllClothesStep2(BOOL proceed)
gAgentWearables.removeWearable(WT_UNDERSHIRT,true,0);
gAgentWearables.removeWearable(WT_UNDERPANTS,true,0);
gAgentWearables.removeWearable(WT_SKIRT,true,0);
+ gAgentWearables.removeWearable(WT_ALPHA,true,0);
+ gAgentWearables.removeWearable(WT_TATTOO,true,0);
}
}