diff options
Diffstat (limited to 'indra/newview/rlvhandler.cpp')
| -rw-r--r-- | indra/newview/rlvhandler.cpp | 211 |
1 files changed, 211 insertions, 0 deletions
diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index 6c4b439105..2cc06b3bbc 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -28,8 +28,14 @@ #include "llviewerprecompiledheaders.h" #include "llagent.h" #include "llstartup.h" +#include "llappearancemgr.h" +#include "llinventoryfunctions.h" +#include "llinventorymodel.h" +#include "llmoveview.h" #include "llviewercontrol.h" +#include "llviewermenu.h" #include "llviewerobject.h" +#include "llviewerobjectlist.h" #include "rlvcommon.h" #include "rlvhandler.h" @@ -109,6 +115,9 @@ ECmdRet RlvHandler::processCommand(std::reference_wrapper<const RlvCommand> rlvC switch (rlvCmd.get().getParamType()) { case EParamType::Reply: + case EParamType::Force: + case EParamType::Remove: + case EParamType::Add: eRet = rlvCmd.get().processCommand(); break; case EParamType::Unknown: @@ -222,4 +231,206 @@ ECmdRet ReplyHandler<EBehaviour::VersionNum>::onCommand(const RlvCommand& rlvCmd return ECmdRet::Succeeded; } +template<> template<> +ECmdRet ReplyHandler<EBehaviour::GetSitID>::onCommand(const RlvCommand& rlvCmd, std::string& strReply) +{ + if (gAgent.isSitting()) + gAgent.getSitObjectID().toString(strReply); + else + strReply = "00000000-0000-0000-0000-000000000000"; + return ECmdRet::Succeeded; +} + +template<> template<> +ECmdRet ReplyHandler<EBehaviour::GetInv>::onCommand(const RlvCommand& rlvCmd, std::string& strReply) +{ + auto folderID = gInventory.getRootFolderID(); + LLNameCategoryCollector has_name("#RLV"); + if (!gInventory.hasMatchingDirectDescendent(folderID, has_name)) + return ECmdRet::FailedNoSharedRoot; + folderID = findDescendentCategoryIDByName(folderID, "#RLV"); + strReply = ""; + LLInventoryModel::cat_array_t* cats; + LLInventoryModel::item_array_t* items; + std::vector<std::string> optionList; + auto option = rlvCmd.getOption(); + if (!option.empty()) + { + Util::parseStringList(option, optionList, "/"); + auto optIter = optionList.begin(); + for(; optionList.end() != optIter; ++optIter) + { + auto name = *optIter; + if (!name.empty()) + folderID = findDescendentCategoryIDByName(folderID, name); + } + } + gInventory.getDirectDescendentsOf(folderID, cats, items); + auto iter = cats->begin(); + for(; cats->end() != iter; ++iter) + { + auto name = (*iter)->getName(); + if (name.front() == '.') + continue; + if (iter != cats->begin()) + strReply.append(","); + strReply.append(name); + } + return ECmdRet::Succeeded; +} + +// Force + +ECmdRet CommandHandlerBaseImpl<EParamType::Force>::processCommand(const RlvCommand& rlvCmd, ForceHandlerFunc* pHandler) +{ + return (*pHandler)(rlvCmd); +} + +template<> template<> +ECmdRet ForceHandler<EBehaviour::Sit>::onCommand(const RlvCommand& rlvCmd) +{ + handle_object_sit(LLUUID{rlvCmd.getOption()}); + return ECmdRet::Succeeded; +} + +template<> template<> +ECmdRet ForceHandler<EBehaviour::SitGround>::onCommand(const RlvCommand& rlvCmd) +{ + gAgent.sitDown(); + return ECmdRet::Succeeded; +} + +template<> template<> +ECmdRet ForceHandler<EBehaviour::Unsit>::onCommand(const RlvCommand& rlvCmd) +{ + gAgent.standUp(); + return ECmdRet::Succeeded; +} + +template<> template<> +ECmdRet ForceHandler<EBehaviour::RemOutfit>::onCommand(const RlvCommand& rlvCmd) +{ + std::vector<std::string> optionList; + auto option = rlvCmd.getOption(); + if (option.empty()) + { + LLAppearanceMgr::instance().removeAllClothesFromAvatar(); + } + else + { + LLWearableType::EType type = LLWearableType::getInstance()->typeNameToType(option); + if (type >= LLWearableType::WT_SHAPE + && type < LLWearableType::WT_COUNT + && (gAgentWearables.getWearableCount(type) > 0)) + { + U32 wearable_index = gAgentWearables.getWearableCount(type) - 1; + LLUUID item_id = gAgentWearables.getWearableItemID(type,wearable_index); + LLAppearanceMgr::instance().removeItemFromAvatar(item_id); + } + } + return ECmdRet::Succeeded; +} + +#define RESTRAINED_LOVE_OUTFIT(A) \ + auto folderID = gInventory.getRootFolderID();\ + LLNameCategoryCollector has_name("#RLV");\ + if (!gInventory.hasMatchingDirectDescendent(folderID, has_name))\ + return ECmdRet::FailedNoSharedRoot;\ + folderID = findDescendentCategoryIDByName(folderID, "#RLV");\ + std::vector<std::string> optionList;\ + auto option = rlvCmd.getOption();\ + if (!option.empty())\ + {\ + folderID = findDescendentCategoryIDByName(folderID, option);\ + if (folderID == LLUUID::null)\ + {\ + Util::parseStringList(option, optionList, "/");\ + auto iter = optionList.begin();\ + for(; optionList.end() != iter; ++iter)\ + {\ + auto name = *iter;\ + if (!name.empty())\ + folderID = findDescendentCategoryIDByName(folderID, name);\ + }\ + }\ + A\ + }\ + return ECmdRet::Succeeded; + +#define RESTRAINED_LOVE_REPLACE \ + LLAppearanceMgr::instance().replaceCurrentOutfit(folderID); + +#define RESTRAINED_LOVE_ADD \ + LLAppearanceMgr::instance().addCategoryToCurrentOutfit(folderID); + +template<> template<> +ECmdRet ForceHandler<EBehaviour::Attach>::onCommand(const RlvCommand& rlvCmd) +{ + RESTRAINED_LOVE_OUTFIT(RESTRAINED_LOVE_REPLACE); +} + +template<> template<> +ECmdRet ForceHandler<EBehaviour::AttachOver>::onCommand(const RlvCommand& rlvCmd) +{ + RESTRAINED_LOVE_OUTFIT(RESTRAINED_LOVE_ADD); +} + +template<> template<> +ECmdRet ForceHandler<EBehaviour::Detach>::onCommand(const RlvCommand& rlvCmd) +{ + auto folderID = gInventory.getRootFolderID(); + LLNameCategoryCollector has_name("#RLV"); + if (!gInventory.hasMatchingDirectDescendent(folderID, has_name)) + return ECmdRet::FailedNoSharedRoot; + folderID = findDescendentCategoryIDByName(folderID, "#RLV"); + std::vector<std::string> optionList; + auto option = rlvCmd.getOption(); + if (!option.empty()) + { + LLNameCategoryCollector is_named(option); + if (gInventory.hasMatchingDirectDescendent(folderID, is_named)) + { + folderID = findDescendentCategoryIDByName(folderID, option); + LLAppearanceMgr::instance().takeOffOutfit(folderID); + } + } + return ECmdRet::Succeeded; +} + +// AddRem + +ECmdRet CommandHandlerBaseImpl<EParamType::AddRem>::processCommand(const RlvCommand& rlvCmd, BhvrHandlerFunc* pHandler, BhvrToggleHandlerFunc* pToggleHandler) +{ + auto param = rlvCmd.getParam(); + bool toggle = false; + if (param == "y") + toggle = true; + else if (param != "n") + return ECmdRet::FailedParam; + return (*pHandler)(rlvCmd, toggle); +} + +template<> template<> +ECmdRet BehaviourToggleHandler<EBehaviour::Sit>::onCommand(const RlvCommand& rlvCmd, bool& toggle) +{ + gAgent.setAllowedToSit(toggle); + return ECmdRet::Succeeded; +} + +template<> template<> +ECmdRet BehaviourToggleHandler<EBehaviour::Unsit>::onCommand(const RlvCommand& rlvCmd, bool& toggle) +{ + gAgent.setAllowedToStand(toggle); + if (gAgent.isSitting()) + LLPanelStandStopFlying::getInstance()->setVisibleStandButton(toggle); + return ECmdRet::Succeeded; +} + +template<> template<> +ECmdRet BehaviourToggleHandler<EBehaviour::Detach>::onCommand(const RlvCommand& rlvCmd, bool& toggle) +{ + gObjectList.findObject(rlvCmd.getObjectID())->setLocked(!toggle); + return ECmdRet::Succeeded; +} + // ============================================================================ |
