summaryrefslogtreecommitdiff
path: root/indra/llappearance
diff options
context:
space:
mode:
authorBrad Payne (Vir Linden) <vir@lindenlab.com>2015-05-28 17:47:37 -0400
committerBrad Payne (Vir Linden) <vir@lindenlab.com>2015-05-28 17:47:37 -0400
commitd822d0e96bb69374f49fef8a827a042474deda8d (patch)
tree91834ede57a52fb6e1d85dace0e1ea49bb62c394 /indra/llappearance
parent25c7e0114085a296eb3e2f7fba7cd2cb5b6177f8 (diff)
parentf3c58f765c0168f25bb13c4427e34b4bdad2f671 (diff)
merge
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.cpp9
-rwxr-xr-x[-rw-r--r--]indra/llappearance/llwearabletype.h1
4 files changed, 61 insertions, 22 deletions
diff --git a/indra/llappearance/llwearabledata.cpp b/indra/llappearance/llwearabledata.cpp
index 5dfb201fc4..2bf3b9085b 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)
@@ -204,11 +201,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();
@@ -216,18 +213,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..a0c446ea9e 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 = 60;
//--------------------------------------------------------------------
// 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..87109a5906 100644..100755
--- a/indra/llappearance/llwearabletype.cpp
+++ b/indra/llappearance/llwearabletype.cpp
@@ -27,6 +27,7 @@
#include "linden_common.h"
#include "llwearabletype.h"
#include "llinventorytype.h"
+#include "llinventorydefines.h"
static LLTranslationBridge* sTrans = NULL;
@@ -160,7 +161,7 @@ BOOL LLWearableType::getDisableCameraSwitch(LLWearableType::EType type)
return entry->mDisableCameraSwitch;
}
-// static
+// static
BOOL LLWearableType::getAllowMultiwear(LLWearableType::EType type)
{
const LLWearableDictionary *dict = LLWearableDictionary::getInstance();
@@ -169,3 +170,9 @@ BOOL LLWearableType::getAllowMultiwear(LLWearableType::EType type)
return entry->mAllowMultiwear;
}
+// static
+LLWearableType::EType LLWearableType::inventoryFlagsToWearableType(U32 flags)
+{
+ return (LLWearableType::EType)(flags & LLInventoryItemFlags::II_FLAGS_WEARABLES_MASK);
+}
+
diff --git a/indra/llappearance/llwearabletype.h b/indra/llappearance/llwearabletype.h
index 7c9594644d..519d5b92a2 100644..100755
--- a/indra/llappearance/llwearabletype.h
+++ b/indra/llappearance/llwearabletype.h
@@ -80,6 +80,7 @@ public:
static LLInventoryType::EIconName getIconName(EType type);
static BOOL getDisableCameraSwitch(EType type);
static BOOL getAllowMultiwear(EType type);
+ static EType inventoryFlagsToWearableType(U32 flags);
protected:
LLWearableType() {}