From f426f8a694429209ca0eeea9156173e8a12ddc46 Mon Sep 17 00:00:00 2001 From: "Brad Payne (Vir Linden)" Date: Thu, 29 Aug 2013 17:08:30 -0400 Subject: SH-4455 WIP - versioned some metrics whose usage has changed, added name and item id checks in setWearableOutfit() --- indra/newview/llagentwearables.cpp | 52 +++++++++++++++++++++++++------------- 1 file changed, 35 insertions(+), 17 deletions(-) (limited to 'indra/newview/llagentwearables.cpp') diff --git a/indra/newview/llagentwearables.cpp b/indra/newview/llagentwearables.cpp index 326c584c32..8501436b5b 100755 --- a/indra/newview/llagentwearables.cpp +++ b/indra/newview/llagentwearables.cpp @@ -1237,31 +1237,49 @@ void LLAgentWearables::setWearableOutfit(const LLInventoryItem::item_array_t& it S32 count = wearables.count(); llassert(items.count() == count); - // Check for whether outfit already matches the one requested (!) - S32 i; - + // Check for whether outfit already matches the one requested S32 matched = 0, mismatched = 0; - std::vector type_counts(LLWearableType::WT_COUNT,0); - for (i = 0; i < count; i++) + const S32 arr_size = LLWearableType::WT_COUNT; + S32 type_counts[arr_size]; + std::fill(type_counts,type_counts+arr_size,0); + for (S32 i = 0; i < count; i++) { LLViewerWearable* new_wearable = wearables[i]; LLPointer new_item = items[i]; + const LLWearableType::EType type = new_wearable->getType(); - S32 index = type_counts[type]; - LLViewerWearable *curr_wearable = dynamic_cast(getWearable(type,index)); - if (new_wearable && curr_wearable && - new_wearable->getAssetID() == curr_wearable->getAssetID()) + if (type < 0 || type>=LLWearableType::WT_COUNT) { - matched++; + llwarns << "invalid type " << type << llendl; + mismatched++; + continue; } - else + S32 index = type_counts[type]; + type_counts[type]++; + + LLViewerWearable *curr_wearable = dynamic_cast(getWearable(type,index)); + if (!new_wearable || !curr_wearable || + new_wearable->getAssetID() != curr_wearable->getAssetID()) { LL_DEBUGS("Avatar") << "mismatch, type " << type << " index " << index << " names " << (curr_wearable ? curr_wearable->getName() : "NONE") << "," << " names " << (new_wearable ? new_wearable->getName() : "NONE") << llendl; mismatched++; + continue; } - type_counts[type]++; + + if (curr_wearable->getName() != new_item->getName() || + curr_wearable->getItemID() != new_item->getUUID()) + { + LL_DEBUGS("Avatar") << "mismatch on name or inventory id, names " + << curr_wearable->getName() << " vs " << new_item->getName() + << " item ids " << curr_wearable->getItemID() << " vs " << new_item->getUUID() + << llendl; + mismatched++; + continue; + } + // If we got here, everything matches. + matched++; } LL_DEBUGS("Avatar") << "matched " << matched << " mismatched " << mismatched << llendl; for (S32 j=0; j new_item = items[i]; -- cgit v1.3