From f3df997b5b5a4b9a4bdc68d3fae0b1a2e00651e3 Mon Sep 17 00:00:00 2001 From: Lirusaito Date: Wed, 6 Mar 2019 15:56:43 -0500 Subject: [PATCH] [RLVa] Allow inexact group name matches --- indra/newview/rlvhandler.cpp | 24 +++++++++++++++++++----- 1 file changed, 19 insertions(+), 5 deletions(-) diff --git a/indra/newview/rlvhandler.cpp b/indra/newview/rlvhandler.cpp index e32433ccd..2ef6cce03 100644 --- a/indra/newview/rlvhandler.cpp +++ b/indra/newview/rlvhandler.cpp @@ -1836,16 +1836,30 @@ ERlvCmdRet RlvHandler::onForceGroup(const RlvCommand& rlvCmd) const } 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[idxGroup].mName, rlvCmd.getOption())) - idGroup = gAgent.mGroups[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)