summaryrefslogtreecommitdiff
path: root/indra/newview/llappearancemgr.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'indra/newview/llappearancemgr.cpp')
-rw-r--r--indra/newview/llappearancemgr.cpp129
1 files changed, 75 insertions, 54 deletions
diff --git a/indra/newview/llappearancemgr.cpp b/indra/newview/llappearancemgr.cpp
index b825bd9f41..b6e59f5d2e 100644
--- a/indra/newview/llappearancemgr.cpp
+++ b/indra/newview/llappearancemgr.cpp
@@ -31,6 +31,7 @@
#include "llagent.h"
#include "llagentcamera.h"
#include "llagentwearables.h"
+#include "llappearancelistener.h"
#include "llappearancemgr.h"
#include "llattachmentsmgr.h"
#include "llcommandhandler.h"
@@ -48,6 +49,7 @@
#include "lloutfitslist.h"
#include "llselectmgr.h"
#include "llsidepanelappearance.h"
+#include "lltransutil.h"
#include "llviewerobjectlist.h"
#include "llvoavatar.h"
#include "llvoavatarself.h"
@@ -66,10 +68,7 @@
#include "llavatarpropertiesprocessor.h"
-#if LL_MSVC
-// disable boost::lexical_cast warning
-#pragma warning (disable:4702)
-#endif
+LLAppearanceListener sAppearanceListener;
namespace
{
@@ -118,26 +117,16 @@ public:
LLOutfitUnLockTimer(F32 period) : LLEventTimer(period)
{
// restart timer on BOF changed event
- LLOutfitObserver::instance().addBOFChangedCallback(boost::bind(
- &LLOutfitUnLockTimer::reset, this));
+ LLOutfitObserver::instance().addBOFChangedCallback([this]{ start(); });
stop();
}
- /*virtual*/
- BOOL tick()
+ bool tick() override
{
- if(mEventTimer.hasExpired())
- {
- LLAppearanceMgr::instance().setOutfitLocked(false);
- }
- return FALSE;
+ LLAppearanceMgr::instance().setOutfitLocked(false);
+ return false;
}
- void stop() { mEventTimer.stop(); }
- void start() { mEventTimer.start(); }
- void reset() { mEventTimer.reset(); }
- BOOL getStarted() { return mEventTimer.getStarted(); }
-
- LLTimer& getEventTimer() { return mEventTimer;}
+ bool getStarted() { return isRunning(); }
};
// support for secondlife:///app/appearance SLapps
@@ -332,7 +321,7 @@ public:
// virtual
// Will be deleted after returning true - only safe to do this if all callbacks have fired.
- BOOL tick()
+ bool tick() override
{
// mPendingRequests will be zero if all requests have been
// responded to. mWaitTimes.empty() will be true if we have
@@ -625,8 +614,8 @@ void LLBrokenLinkObserver::changed(U32 mask)
if (id == mUUID)
{
// Might not be processed yet and it is not a
- // good idea to update appearane here, postpone.
- doOnIdleOneTime([this]()
+ // good idea to update appearance here, postpone.
+ doOnIdleOneTime([this]
{
postProcess();
});
@@ -719,7 +708,7 @@ public:
bool isMostRecent();
void handleLateArrivals();
void resetTime(F32 timeout);
- static S32 countActive() { return sActiveHoldingPatterns.size(); }
+ static S32 countActive() { return static_cast<S32>(sActiveHoldingPatterns.size()); }
S32 index() { return mIndex; }
private:
@@ -1335,7 +1324,7 @@ void LLWearableHoldingPattern::onWearableAssetFetch(LLViewerWearable *wearable)
wearable_item->setAssetUUID(new_wearable->getAssetID());
wearable_item->setTransactionID(new_wearable->getTransactionID());
gInventory.updateItem(wearable_item, LLInventoryObserver::INTERNAL);
- wearable_item->updateServer(FALSE);
+ wearable_item->updateServer(false);
use_count++;
}
@@ -1374,7 +1363,7 @@ static void removeDuplicateItems(LLInventoryModel::item_array_t& items)
// encountered, so we actually keep the *last* of each duplicate
// item. This is needed to give the right priority when adding
// duplicate items to an existing outfit.
- for (S32 i=items.size()-1; i>=0; i--)
+ for (S32 i = static_cast<S32>(items.size()) - 1; i >= 0; i--)
{
LLViewerInventoryItem *item = items.at(i);
LLUUID item_id = item->getLinkedUUID();
@@ -1712,7 +1701,6 @@ void LLAppearanceMgr::setOutfitLocked(bool locked)
mOutfitLocked = locked;
if (locked)
{
- mUnlockOutfitTimer->reset();
mUnlockOutfitTimer->start();
}
else
@@ -1735,7 +1723,7 @@ void LLAppearanceMgr::takeOffOutfit(const LLUUID& cat_id)
LLInventoryModel::item_array_t items;
LLFindWearablesEx collector(/*is_worn=*/ true, /*include_body_parts=*/ false);
- gInventory.collectDescendentsIf(cat_id, cats, items, FALSE, collector);
+ gInventory.collectDescendentsIf(cat_id, cats, items, false, collector);
LLInventoryModel::item_array_t::const_iterator it = items.begin();
const LLInventoryModel::item_array_t::const_iterator it_end = items.end();
@@ -1918,7 +1906,7 @@ void LLAppearanceMgr::shallowCopyCategoryContents(const LLUUID& src_id, const LL
}
}
-BOOL LLAppearanceMgr::getCanMakeFolderIntoOutfit(const LLUUID& folder_id)
+bool LLAppearanceMgr::getCanMakeFolderIntoOutfit(const LLUUID& folder_id)
{
// These are the wearable items that are required for considering this
// folder as containing a complete outfit.
@@ -1945,7 +1933,7 @@ BOOL LLAppearanceMgr::getCanMakeFolderIntoOutfit(const LLUUID& folder_id)
}
}
- // If the folder contains the required wearables, return TRUE.
+ // If the folder contains the required wearables, return true.
return ((required_wearables & folder_wearables) == required_wearables);
}
@@ -2074,7 +2062,7 @@ bool LLAppearanceMgr::canAddWearables(const uuid_vec_t& item_ids, bool warn_on_t
{
if (warn_on_type_mismatch)
{
- LL_WARNS() << "Unexpected wearable type" << LL_ENDL;
+ LL_WARNS() << "Unexpected wearable type" << LL_ENDL;
}
return false;
}
@@ -2136,7 +2124,7 @@ void LLAppearanceMgr::filterWearableItems(
items.clear();
for (S32 i=0; i<LLWearableType::WT_COUNT; i++)
{
- S32 size = items_by_type[i].size();
+ S32 size = (S32)items_by_type[i].size();
if (size <= 0)
continue;
S32 start_index = llmax(0,size-max_per_type);
@@ -2911,11 +2899,21 @@ void LLAppearanceMgr::wearInventoryCategoryOnAvatar( LLInventoryCategory* catego
LLFloaterSidePanelContainer::showPanel("appearance", LLSD().with("type", "edit_outfit"));
}
- LLAppearanceMgr::changeOutfit(TRUE, category->getUUID(), append);
+ LLAppearanceMgr::changeOutfit(true, category->getUUID(), append);
}
-// FIXME do we really want to search entire inventory for matching name?
-void LLAppearanceMgr::wearOutfitByName(const std::string& name)
+bool LLAppearanceMgr::wearOutfitByName(const std::string& name, bool append)
+{
+ std::string error_msg;
+ if(!wearOutfitByName(name, error_msg, append))
+ {
+ LL_WARNS() << error_msg << LL_ENDL;
+ return false;
+ }
+ return true;
+}
+
+bool LLAppearanceMgr::wearOutfitByName(const std::string& name, std::string& error_msg, bool append)
{
LL_INFOS("Avatar") << self_av_string() << "Wearing category " << name << LL_ENDL;
@@ -2948,15 +2946,38 @@ void LLAppearanceMgr::wearOutfitByName(const std::string& name)
}
}
- if(cat)
+ return wearOutfit(stringize(std::quoted(name)), cat, error_msg, copy_items, append);
+}
+
+bool LLAppearanceMgr::wearOutfit(const LLUUID &cat_id, std::string &error_msg, bool append)
+{
+ LLViewerInventoryCategory *cat = gInventory.getCategory(cat_id);
+ return wearOutfit(stringize(cat_id), cat, error_msg, false, append);
+}
+
+bool LLAppearanceMgr::wearOutfit(const std::string &desc, LLInventoryCategory* cat,
+ std::string &error_msg, bool copy_items, bool append)
+{
+ if (!cat)
{
- LLAppearanceMgr::wearInventoryCategory(cat, copy_items, false);
+ error_msg = stringize(LLTrans::getString("OutfitNotFound"), desc);
+ return false;
}
- else
+ // don't allow wearing a system folder
+ if (LLFolderType::lookupIsProtectedType(cat->getPreferredType()))
+ {
+ error_msg = stringize(LLTrans::getString("SystemFolderNotWorn"), std::quoted(cat->getName()));
+ return false;
+ }
+ bool can_wear = append ? getCanAddToCOF(cat->getUUID()) : getCanReplaceCOF(cat->getUUID());
+ if (!can_wear)
{
- LL_WARNS() << "Couldn't find outfit " <<name<< " in wearOutfitByName()"
- << LL_ENDL;
+ std::string msg = append ? LLTrans::getString("OutfitNotAdded") : LLTrans::getString("OutfitNotReplaced");
+ error_msg = stringize(msg, std::quoted(cat->getName()), " , id: ", cat->getUUID());
+ return false;
}
+ wearInventoryCategory(cat, copy_items, append);
+ return true;
}
bool areMatchingWearables(const LLViewerInventoryItem *a, const LLViewerInventoryItem *b)
@@ -3591,7 +3612,7 @@ struct WearablesOrderComparator
LOG_CLASS(WearablesOrderComparator);
WearablesOrderComparator(const LLWearableType::EType type)
{
- mControlSize = build_order_string(type, 0).size();
+ mControlSize = static_cast<U32>(build_order_string(type, 0).size());
};
bool operator()(const LLInventoryItem* item1, const LLInventoryItem* item2)
@@ -3626,7 +3647,7 @@ void LLAppearanceMgr::getWearableOrderingDescUpdates(LLInventoryModel::item_arra
for (U32 type = LLWearableType::WT_SHIRT; type < LLWearableType::WT_COUNT; type++)
{
- U32 size = items_by_type[type].size();
+ U32 size = static_cast<U32>(items_by_type[type].size());
if (!size) continue;
//sinking down invalid items which need reordering
@@ -3937,7 +3958,7 @@ void LLAppearanceMgr::serverAppearanceUpdateCoro(LLCoreHttpUtil::HttpCoroutineAd
LL_WARNS("Avatar") << "Bake retry count exceeded!" << LL_ENDL;
break;
}
- F32 timeout = pow(BAKE_RETRY_TIMEOUT, static_cast<float>(retryCount)) - 1.0;
+ F32 timeout = pow(BAKE_RETRY_TIMEOUT, static_cast<float>(retryCount)) - 1.0f;
LL_WARNS("Avatar") << "Bake retry #" << retryCount << " in " << timeout << " seconds." << LL_ENDL;
@@ -4246,12 +4267,12 @@ bool LLAppearanceMgr::moveWearable(LLViewerInventoryItem* item, bool closer_to_b
// FIXME switch to use AISv3 where supported.
//items need to be updated on a dataserver
- item->setComplete(TRUE);
- item->updateServer(FALSE);
+ item->setComplete(true);
+ item->updateServer(false);
gInventory.updateItem(item);
- swap_item->setComplete(TRUE);
- swap_item->updateServer(FALSE);
+ swap_item->setComplete(true);
+ swap_item->updateServer(false);
gInventory.updateItem(swap_item);
//to cause appearance of the agent to be updated
@@ -4332,7 +4353,7 @@ LLAppearanceMgr::LLAppearanceMgr():
outfit_observer.addCOFSavedCallback(boost::bind(
&LLAppearanceMgr::setOutfitLocked, this, false));
- mUnlockOutfitTimer.reset(new LLOutfitUnLockTimer(gSavedSettings.getS32(
+ mUnlockOutfitTimer.reset(new LLOutfitUnLockTimer((F32)gSavedSettings.getS32(
"OutfitOperationsTimeout")));
gIdleCallbacks.addFunction(&LLAttachmentsMgr::onIdle, NULL);
@@ -4405,15 +4426,15 @@ void LLAppearanceMgr::unregisterAttachment(const LLUUID& item_id)
mAttachmentsChangeSignal();
}
-BOOL LLAppearanceMgr::getIsInCOF(const LLUUID& obj_id) const
+bool LLAppearanceMgr::getIsInCOF(const LLUUID& obj_id) const
{
const LLUUID& cof = getCOF();
if (obj_id == cof)
- return TRUE;
+ return true;
const LLInventoryObject* obj = gInventory.getObject(obj_id);
if (obj && obj->getParentUUID() == cof)
- return TRUE;
- return FALSE;
+ return true;
+ return false;
}
bool LLAppearanceMgr::getIsInCOF(const LLInventoryObject* obj) const
@@ -4580,7 +4601,7 @@ public:
LLInventoryModel::item_array_t* items;
gInventory.getDirectDescendentsOf(mComplete.front(), cats, items);
- S32 count = items->size();
+ auto count = items->size();
if(!count)
{
LL_WARNS() << "Nothing fetched in category " << mComplete.front()
@@ -4596,7 +4617,7 @@ public:
S32 version = cat ? cat->getVersion() : -2;
LL_INFOS() << "stage1, category " << mComplete.front() << " got " << count << " items, version " << version << " passing to stage2 " << LL_ENDL;
uuid_vec_t ids;
- for(S32 i = 0; i < count; ++i)
+ for(size_t i = 0; i < count; ++i)
{
ids.push_back(items->at(i)->getUUID());
}
@@ -4765,7 +4786,7 @@ public:
LLAppearanceMgr::getInstance()->wearInventoryCategory(category, true, false);
// *TODOw: This may not be necessary if initial outfit is chosen already -- josh
- gAgent.setOutfitChosen(TRUE);
+ gAgent.setOutfitChosen(true);
}
}