From 5266981c86f3ec2a79f01efa7f4d75614fc5e633 Mon Sep 17 00:00:00 2001 From: Kitty Barnett Date: Sat, 12 Nov 2016 13:45:02 +0100 Subject: [PATCH] @setgroup:=force will now do a "starts with" rather than an exact match -> see FIRE-20266 - problem when group name contains a comma (or colon?) -> an exact match has precedence over a partial match; in case of multiple partial matches the last match wins (group ordering isn't guaranteed so essentially 'random') -> @setgroup:=force is still preferred --HG-- branch : RLVa --- indra/newview/rlvhandler.cpp | 26 +++++++++++++++++++------- 1 file changed, 19 insertions(+), 7 deletions(-) diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index 2d4683cff7..0360623900 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -2473,21 +2473,33 @@ template<> template<> ERlvCmdRet RlvForceHandler::onCommand(const RlvCommand& rlvCmd) { if (!RlvActions::canChangeActiveGroup(rlvCmd.getObjectID())) - { return RLV_RET_FAILED_LOCK; - } LLUUID idGroup; bool fValid = false; - if (idGroup.set(rlvCmd.getOption())) + if ("none" == rlvCmd.getOption()) + { + idGroup.setNull(); + fValid = true; + } + else if (idGroup.set(rlvCmd.getOption())) { fValid = (idGroup.isNull()) || (gAgent.isInGroup(idGroup, true)); } else { - for (S32 idxGroup = 0, cntGroup = gAgent.mGroups.size(); (idxGroup < cntGroup) && (idGroup.isNull()); idxGroup++) - if (boost::iequals(gAgent.mGroups.at(idxGroup).mName, rlvCmd.getOption())) - idGroup = gAgent.mGroups.at(idxGroup).mID; - fValid = (idGroup.notNull()) || ("none" == rlvCmd.getOption()); + bool fExactMatch = false; + for (const auto& groupData : gAgent.mGroups) + { + // NOTE: exact matches take precedence over partial matches; in case of partial matches the last match wins + if (boost::istarts_with(groupData.mName, rlvCmd.getOption())) + { + idGroup = groupData.mID; + fExactMatch = groupData.mName.length() == rlvCmd.getOption().length(); + if (fExactMatch) + break; + } + } + fValid = idGroup.notNull(); } if (fValid)