summaryrefslogtreecommitdiff
path: root/indra/newview/llgesturemgr.cpp
diff options
context:
space:
mode:
authorMonroe Williams <monroe@lindenlab.com>2007-08-02 01:18:34 +0000
committerMonroe Williams <monroe@lindenlab.com>2007-08-02 01:18:34 +0000
commit7138fb673ac3df46b9cb5f23d0d74e70fdd2b6b3 (patch)
tree3c34a3a180b5275bd4166b0056765c5868f56447 /indra/newview/llgesturemgr.cpp
parentf6a10b3214d79df4e8f5768acaa68edbd2de5620 (diff)
Merge down from Branch_1-18-1:
svn merge --ignore-ancestry svn+ssh://svn.lindenlab.com/svn/linden/release@66449 svn+ssh://svn.lindenlab.com/svn/linden/branches/Branch_1-18-1@67131
Diffstat (limited to 'indra/newview/llgesturemgr.cpp')
-rw-r--r--indra/newview/llgesturemgr.cpp63
1 files changed, 49 insertions, 14 deletions
diff --git a/indra/newview/llgesturemgr.cpp b/indra/newview/llgesturemgr.cpp
index be1c26381b..3c51d7dcf1 100644
--- a/indra/newview/llgesturemgr.cpp
+++ b/indra/newview/llgesturemgr.cpp
@@ -83,7 +83,7 @@ void LLGestureManager::activateGesture(const LLUUID& item_id)
mDeactivateSimilarNames.clear();
const BOOL inform_server = TRUE;
- const BOOL deactivate_similar = TRUE;
+ const BOOL deactivate_similar = FALSE;
activateGestureWithAsset(item_id, asset_id, inform_server, deactivate_similar);
}
@@ -403,7 +403,7 @@ void LLGestureManager::replaceGesture(const LLUUID& item_id, LLMultiGesture* new
LLLoadInfo* info = new LLLoadInfo;
info->mItemID = item_id;
info->mInformServer = TRUE;
- info->mDeactivateSimilar = TRUE;
+ info->mDeactivateSimilar = FALSE;
const BOOL high_priority = TRUE;
gAssetStorage->getAssetData(asset_id,
@@ -474,6 +474,8 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s
LLString cur_token_lower = cur_token;
LLString::toLower(cur_token_lower);
+ // collect gestures that match
+ std::vector <LLMultiGesture *> matching;
item_map_t::iterator it;
for (it = mActive.begin(); it != mActive.end(); ++it)
{
@@ -481,16 +483,32 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s
// Gesture asset data might not have arrived yet
if (!gesture) continue;
-
+
if (!stricmp(gesture->mTrigger.c_str(), cur_token_lower.c_str()))
{
+ matching.push_back(gesture);
+ }
+
+ gesture = NULL;
+ }
+
+
+ if (matching.size() > 0)
+ {
+ // choose one at random
+ {
+ S32 random = ll_rand(matching.size());
+
+ gesture = matching[random];
+
playGesture(gesture);
if (!gesture->mReplaceText.empty())
{
if( !first_token )
{
- revised_string->append( " " );
+ if (revised_string)
+ revised_string->append( " " );
}
// Don't muck with the user's capitalization if we don't have to.
@@ -499,30 +517,34 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s
LLString::toLower(output_lower);
if( cur_token_lower == output_lower )
{
- revised_string->append( cur_token );
+ if (revised_string)
+ revised_string->append( cur_token );
}
else
{
- revised_string->append( output );
+ if (revised_string)
+ revised_string->append( output );
}
}
found_gestures = TRUE;
- break;
}
- gesture = NULL;
}
}
-
- if( !gesture )
+
+ if(!gesture)
{
+ // This token doesn't match a gesture. Pass it through to the output.
if( !first_token )
{
- revised_string->append( " " );
+ if (revised_string)
+ revised_string->append( " " );
}
- revised_string->append( cur_token );
+ if (revised_string)
+ revised_string->append( cur_token );
}
first_token = FALSE;
+ gesture = NULL;
}
return found_gestures;
}
@@ -530,7 +552,10 @@ BOOL LLGestureManager::triggerAndReviseString(const std::string &utf8str, std::s
BOOL LLGestureManager::triggerGesture(KEY key, MASK mask)
{
+ std::vector <LLMultiGesture *> matching;
item_map_t::iterator it;
+
+ // collect matching gestures
for (it = mActive.begin(); it != mActive.end(); ++it)
{
LLMultiGesture* gesture = (*it).second;
@@ -541,10 +566,20 @@ BOOL LLGestureManager::triggerGesture(KEY key, MASK mask)
if (gesture->mKey == key
&& gesture->mMask == mask)
{
- playGesture(gesture);
- return TRUE;
+ matching.push_back(gesture);
}
}
+
+ // choose one and play it
+ if (matching.size() > 0)
+ {
+ U32 random = ll_rand(matching.size());
+
+ LLMultiGesture* gesture = matching[random];
+
+ playGesture(gesture);
+ return TRUE;
+ }
return FALSE;
}