From e54613da226abdf1e31a404761aac7085e65cb7c Mon Sep 17 00:00:00 2001 From: elektrahesse Date: Thu, 16 Sep 2010 17:23:48 +0200 Subject: Fixed a bug related to the names cache clearing :P --- linden/indra/newview/llchatbar.cpp | 79 +++++++++++++++++++------------------- 1 file changed, 39 insertions(+), 40 deletions(-) (limited to 'linden/indra') diff --git a/linden/indra/newview/llchatbar.cpp b/linden/indra/newview/llchatbar.cpp index 52397b4..9d56638 100644 --- a/linden/indra/newview/llchatbar.cpp +++ b/linden/indra/newview/llchatbar.cpp @@ -252,62 +252,61 @@ BOOL LLChatBar::handleKeyHere( KEY key, MASK mask ) else return handled; - std::string to_match_test(to_match); - std::transform(to_match_test.begin(), to_match_test.end(), to_match_test.begin(), tolower); + names.clear(); - if (last_initials != to_match_test) + for (U32 i=0; iisAvatar()) { - LLViewerObject *av_obj = gObjectList.findObject(avatar_ids[i]); - if (av_obj != NULL && av_obj->isAvatar()) - { - LLVOAvatar* avatarp = (LLVOAvatar*)av_obj; - if (avatarp != NULL) - real_pos = avatarp->getPositionGlobal(); - } + LLVOAvatar* avatarp = (LLVOAvatar*)av_obj; + if (avatarp != NULL) + real_pos = avatarp->getPositionGlobal(); } + } - F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal())); - if (dist > CHAT_SHOUT_RADIUS) - continue; + F32 dist = F32(dist_vec(positions[i], gAgent.getPositionGlobal())); + if (dist > CHAT_SHOUT_RADIUS) + continue; - std::string agent_name = " "; - std::string agent_surname = " "; + std::string agent_name = " "; + std::string agent_surname = " "; - if(!gCacheName->getName(avatar_ids[i], agent_name, agent_surname) && (agent_name == " " || agent_surname == " ")) - continue; + if(!gCacheName->getName(avatar_ids[i], agent_name, agent_surname) && (agent_name == " " || agent_surname == " ")) + continue; - std::string test_name(agent_name); - std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower); - std::transform(to_match.begin(), to_match.end(), to_match.begin(), tolower); + std::string test_name(agent_name); + std::transform(test_name.begin(), test_name.end(), test_name.begin(), tolower); + std::transform(to_match.begin(), to_match.end(), to_match.begin(), tolower); + + if (test_name.find(to_match) == 0) + names.push_back(agent_name); + } - if (test_name.find(to_match) == 0) - names.push_back(agent_name); - } + if (current_index >= names.size() || to_match != last_initials) + { + current_index = 0; + last_initials = to_match; } - std::string current_name = names[current_index]; - mInputEditor->setText(left_part.substr(0, left_part.length() - to_match.length()) + current_name + right_part); - mInputEditor->setSelection(cursorPos, cursorPos + (current_name.length() - to_match.length())); + if (names.size() > 0) + { + std::string current_name = names[current_index]; - current_index++; + mInputEditor->setText(left_part.substr(0, left_part.length() - to_match.length()) + current_name + right_part); + mInputEditor->setSelection(cursorPos, cursorPos + (current_name.length() - to_match.length())); - if (current_index == names.size()) - current_index = 0; + current_index++; - return TRUE; + return TRUE; + } } } } -- cgit v1.1