summaryrefslogtreecommitdiff
path: root/indra/llappearance
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2015-03-05 16:17:45 -0500
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2015-03-05 16:17:45 -0500
commit6aa63dce3367a60a5f8ae58d0651844ec7a0a79e (patch)
tree2f5743ff07ecbc85e76950e26028aab2c86b768b /indra/llappearance
parent9b45bc992edf8d049d8a1abe2e778870a493295a (diff)
SL-103 WIP - viewer enforces wearable limits based on total articles of clothing rather than per-type limit. Limit is artificially low for testing, will bump before release.
Diffstat (limited to 'indra/llappearance')
-rwxr-xr-xindra/llappearance/llwearabledata.cpp59
-rwxr-xr-x[-rw-r--r--]indra/llappearance/llwearabledata.h14
-rwxr-xr-x[-rw-r--r--]indra/llappearance/llwearabletype.cpp2
3 files changed, 53 insertions, 22 deletions
diff --git a/indra/llappearance/llwearabledata.cpp b/indra/llappearance/llwearabledata.cpp
index cf1ee435a8..39d4179a80 100755
--- a/indra/llappearance/llwearabledata.cpp
+++ b/indra/llappearance/llwearabledata.cpp
@@ -92,7 +92,7 @@ void LLWearableData::setWearable(const LLWearableType::EType type, U32 index, LL
}
}
-U32 LLWearableData::pushWearable(const LLWearableType::EType type,
+void LLWearableData::pushWearable(const LLWearableType::EType type,
LLWearable *wearable,
bool trigger_updated /* = true */)
{
@@ -100,9 +100,8 @@ U32 LLWearableData::pushWearable(const LLWearableType::EType type,
{
// no null wearables please!
LL_WARNS() << "Null wearable sent for type " << type << LL_ENDL;
- return MAX_CLOTHING_PER_TYPE;
}
- if (type < LLWearableType::WT_COUNT || mWearableDatas[type].size() < MAX_CLOTHING_PER_TYPE)
+ if (canAddWearable(type))
{
mWearableDatas[type].push_back(wearable);
if (trigger_updated)
@@ -110,9 +109,7 @@ U32 LLWearableData::pushWearable(const LLWearableType::EType type,
const BOOL removed = FALSE;
wearableUpdated(wearable, removed);
}
- return mWearableDatas[type].size()-1;
}
- return MAX_CLOTHING_PER_TYPE;
}
// virtual
@@ -125,7 +122,7 @@ void LLWearableData::wearableUpdated(LLWearable *wearable, BOOL removed)
}
}
-void LLWearableData::popWearable(LLWearable *wearable)
+void LLWearableData::eraseWearable(LLWearable *wearable)
{
if (wearable == NULL)
{
@@ -133,16 +130,16 @@ void LLWearableData::popWearable(LLWearable *wearable)
return;
}
- U32 index = getWearableIndex(wearable);
const LLWearableType::EType type = wearable->getType();
- if (index < MAX_CLOTHING_PER_TYPE && index < getWearableCount(type))
+ U32 index;
+ if (getWearableIndex(wearable,index))
{
- popWearable(type, index);
+ eraseWearable(type, index);
}
}
-void LLWearableData::popWearable(const LLWearableType::EType type, U32 index)
+void LLWearableData::eraseWearable(const LLWearableType::EType type, U32 index)
{
LLWearable *wearable = getWearable(type, index);
if (wearable)
@@ -203,11 +200,11 @@ void LLWearableData::pullCrossWearableValues(const LLWearableType::EType type)
}
-U32 LLWearableData::getWearableIndex(const LLWearable *wearable) const
+BOOL LLWearableData::getWearableIndex(const LLWearable *wearable, U32& index_found) const
{
if (wearable == NULL)
{
- return MAX_CLOTHING_PER_TYPE;
+ return FALSE;
}
const LLWearableType::EType type = wearable->getType();
@@ -215,18 +212,50 @@ U32 LLWearableData::getWearableIndex(const LLWearable *wearable) const
if (wearable_iter == mWearableDatas.end())
{
LL_WARNS() << "tried to get wearable index with an invalid type!" << LL_ENDL;
- return MAX_CLOTHING_PER_TYPE;
+ return FALSE;
}
const wearableentry_vec_t& wearable_vec = wearable_iter->second;
for(U32 index = 0; index < wearable_vec.size(); index++)
{
if (wearable_vec[index] == wearable)
{
- return index;
+ index_found = index;
+ return TRUE;
}
}
- return MAX_CLOTHING_PER_TYPE;
+ return FALSE;
+}
+
+U32 LLWearableData::getClothingLayerCount() const
+{
+ U32 count = 0;
+ for (S32 i = 0; i < LLWearableType::WT_COUNT; i++)
+ {
+ LLWearableType::EType type = (LLWearableType::EType)i;
+ if (LLWearableType::getAssetType(type)==LLAssetType::AT_CLOTHING)
+ {
+ count += getWearableCount(type);
+ }
+ }
+ return count;
+}
+
+BOOL LLWearableData::canAddWearable(const LLWearableType::EType type) const
+{
+ LLAssetType::EType a_type = LLWearableType::getAssetType(type);
+ if (a_type==LLAssetType::AT_CLOTHING)
+ {
+ return (getClothingLayerCount() < MAX_CLOTHING_LAYERS);
+ }
+ else if (a_type==LLAssetType::AT_BODYPART)
+ {
+ return (getWearableCount(type) < 1);
+ }
+ else
+ {
+ return FALSE;
+ }
}
BOOL LLWearableData::isOnTop(LLWearable* wearable) const
diff --git a/indra/llappearance/llwearabledata.h b/indra/llappearance/llwearabledata.h
index 03bd179f25..cb6cb954f0 100644..100755
--- a/indra/llappearance/llwearabledata.h
+++ b/indra/llappearance/llwearabledata.h
@@ -60,11 +60,13 @@ public:
const LLWearable* getBottomWearable(const LLWearableType::EType type) const;
U32 getWearableCount(const LLWearableType::EType type) const;
U32 getWearableCount(const U32 tex_index) const;
- U32 getWearableIndex(const LLWearable *wearable) const;
+ BOOL getWearableIndex(const LLWearable *wearable, U32& index) const;
+ U32 getClothingLayerCount() const;
+ BOOL canAddWearable(const LLWearableType::EType type) const;
BOOL isOnTop(LLWearable* wearable) const;
-
- static const U32 MAX_CLOTHING_PER_TYPE = 5;
+
+ static const U32 MAX_CLOTHING_LAYERS = 10;
//--------------------------------------------------------------------
// Setters
@@ -72,11 +74,11 @@ public:
protected:
// Low-level data structure setter - public access is via setWearableItem, etc.
void setWearable(const LLWearableType::EType type, U32 index, LLWearable *wearable);
- U32 pushWearable(const LLWearableType::EType type, LLWearable *wearable,
+ void pushWearable(const LLWearableType::EType type, LLWearable *wearable,
bool trigger_updated = true);
virtual void wearableUpdated(LLWearable *wearable, BOOL removed);
- void popWearable(LLWearable *wearable);
- void popWearable(const LLWearableType::EType type, U32 index);
+ void eraseWearable(LLWearable *wearable);
+ void eraseWearable(const LLWearableType::EType type, U32 index);
void clearWearableType(const LLWearableType::EType type);
bool swapWearables(const LLWearableType::EType type, U32 index_a, U32 index_b);
diff --git a/indra/llappearance/llwearabletype.cpp b/indra/llappearance/llwearabletype.cpp
index 618e2a1941..58c446e586 100644..100755
--- a/indra/llappearance/llwearabletype.cpp
+++ b/indra/llappearance/llwearabletype.cpp
@@ -160,7 +160,7 @@ BOOL LLWearableType::getDisableCameraSwitch(LLWearableType::EType type)
return entry->mDisableCameraSwitch;
}
-// static
+// static
BOOL LLWearableType::getAllowMultiwear(LLWearableType::EType type)
{
const LLWearableDictionary *dict = LLWearableDictionary::getInstance();