void LLFloaterHUD::find() // Scanner activated by Scan button { if(mHalt) return; // this basically checks if the scan has been toggled on or off otherwise llvoavatar calls the scan on avatar activity mListNames->deleteAllItems(); //Clear the list std::vector< LLCharacter* >::iterator avatar_it; for(avatar_it = LLCharacter::sInstances.begin(); avatar_it != LLCharacter::sInstances.end(); ++avatar_it) { LLVOAvatar* avatarp = (LLVOAvatar*)*avatar_it; if (avatarp->isDead() || avatarp->isSelf()) //Dont show the user! { continue; } if (dist_vec(avatarp->getPositionAgent(), gAgent.getPositionAgent()) <= SCAN_MAX_RADIUS) //Scanner radius set in indra constants. { // Pull in that avatar data! std::string name = avatarp->getFullname(); LLVector3d position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition()); LLUUID avid = avatarp->getID(); // Work out distance relative to user! LLVector3d mypos = gAgent.getPositionGlobal(); LLVector3d delta = position - mypos; F32 distance = (F32)delta.magVec(); //Build the list LLSD element; element["id"] = avid; element["columns"][LIST_AVATAR_NAME]["column"] = "name"; element["columns"][LIST_AVATAR_NAME]["value"] = name; element["columns"][LIST_DISTANCE]["column"] = "distance"; element["columns"][LIST_DISTANCE]["value"] = distance; mListNames->addElement(element); mListNames->sortByColumn("distance", TRUE); mListNames->setCallbackUserData(this); } } return; }
void LLFloaterAvatarList::updateAvatarList() { if (sInstance != this) return; //llinfos << "radar refresh: updating map" << llendl; // Check whether updates are enabled LLCheckboxCtrl* check = getChild<LLCheckboxCtrl>("update_enabled_cb"); if (check && !check->getValue()) { mUpdate = FALSE; refreshTracker(); return; } else { mUpdate = TRUE; } LLVector3d mypos = gAgent.getPositionGlobal(); { std::vector<LLUUID> avatar_ids; std::vector<LLUUID> sorted_avatar_ids; std::vector<LLVector3d> positions; LLWorld::instance().getAvatars(&avatar_ids, &positions, mypos, F32_MAX); sorted_avatar_ids = avatar_ids; std::sort(sorted_avatar_ids.begin(), sorted_avatar_ids.end()); for (std::vector<LLCharacter*>::const_iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) { LLUUID avid = (*iter)->getID(); if (!std::binary_search(sorted_avatar_ids.begin(), sorted_avatar_ids.end(), avid)) { avatar_ids.push_back(avid); } } size_t i; size_t count = avatar_ids.size(); bool announce = gSavedSettings.getBOOL("RadarChatKeys"); std::queue<LLUUID> announce_keys; for (i = 0; i < count; ++i) { std::string name; std::string first; std::string last; const LLUUID &avid = avatar_ids[i]; LLVector3d position; LLVOAvatar* avatarp = gObjectList.findAvatar(avid); if (avatarp) { // Skip if avatar is dead(what's that?) // or if the avatar is ourselves. // or if the avatar is a dummy if (avatarp->isDead() || avatarp->isSelf() || avatarp->mIsDummy) { continue; } // Get avatar data position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition()); name = avatarp->getFullname(); // [Ansariel: Display name support] LLAvatarName avatar_name; if (LLAvatarNameCache::get(avatarp->getID(), &avatar_name)) { static const LLCachedControl<S32> phoenix_name_system("PhoenixNameSystem", 0); switch (phoenix_name_system) { case 0 : name = avatar_name.getLegacyName(); break; case 1 : name = (avatar_name.mIsDisplayNameDefault ? avatar_name.mDisplayName : avatar_name.getCompleteName()); break; case 2 : name = avatar_name.mDisplayName; break; default : name = avatar_name.getLegacyName(); break; } first = avatar_name.mLegacyFirstName; last = avatar_name.mLegacyLastName; } else continue; // [/Ansariel: Display name support] //duped for lower section if (name.empty() || (name.compare(" ") == 0))// || (name.compare(gCacheName->getDefaultName()) == 0)) { if (!gCacheName->getFullName(avid, name)) //seems redudant with LLAvatarNameCache::get above... { continue; } } if (avid.isNull()) { //llinfos << "Key empty for avatar " << name << llendl; continue; } if (mAvatars.count(avid) > 0) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); mAvatars[avid].setPosition(position, (avatarp->getRegion() == gAgent.getRegion()), true, dist < 20.0, dist < 100.0); } else { // Avatar not there yet, add it LLAvatarListEntry entry(avid, name, position); if(announce && avatarp->getRegion() == gAgent.getRegion()) announce_keys.push(avid); mAvatars[avid] = entry; } } else { if (i < positions.size()) { position = positions[i]; } else { continue; } if (!gCacheName->getFullName(avid, name)) { //name = gCacheName->getDefaultName(); continue; //prevent (Loading...) } if (mAvatars.count(avid) > 0) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); mAvatars[avid].setPosition(position, gAgent.getRegion()->pointInRegionGlobal(position), false, dist < 20.0, dist < 100.0); } else { LLAvatarListEntry entry(avid, name, position); if(announce && gAgent.getRegion()->pointInRegionGlobal(position)) announce_keys.push(avid); mAvatars[avid] = entry; } } } //let us send the keys in a more timely fashion if(announce && !announce_keys.empty()) { std::ostringstream ids; int transact_num = (int)gFrameCount; int num_ids = 0; while(!announce_keys.empty()) { LLUUID id = announce_keys.front(); announce_keys.pop(); ids << "," << id.asString(); ++num_ids; if(ids.tellp() > 200) { gMessageSystem->newMessage("ScriptDialogReply"); gMessageSystem->nextBlock("AgentData"); gMessageSystem->addUUID("AgentID", gAgent.getID()); gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); gMessageSystem->nextBlock("Data"); gMessageSystem->addUUID("ObjectID", gAgent.getID()); gMessageSystem->addS32("ChatChannel", -777777777); gMessageSystem->addS32("ButtonIndex", 1); gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); gAgent.sendReliableMessage(); num_ids = 0; ids.seekp(0); ids.str(""); } } if(num_ids > 0) { gMessageSystem->newMessage("ScriptDialogReply"); gMessageSystem->nextBlock("AgentData"); gMessageSystem->addUUID("AgentID", gAgent.getID()); gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); gMessageSystem->nextBlock("Data"); gMessageSystem->addUUID("ObjectID", gAgent.getID()); gMessageSystem->addS32("ChatChannel", -777777777); gMessageSystem->addS32("ButtonIndex", 1); gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); gAgent.sendReliableMessage(); } } } // llinfos << "radar refresh: done" << llendl; expireAvatarList(); refreshAvatarList(); refreshTracker(); }
void LLFloaterAvatarList::updateAvatarList() { if (sInstance != this) return; //llinfos << "radar refresh: updating map" << llendl; // Check whether updates are enabled LLCheckboxCtrl* check = getChild<LLCheckboxCtrl>("update_enabled_cb"); if (check && !check->getValue()) { mUpdate = FALSE; refreshTracker(); return; } else { mUpdate = TRUE; } LLVector3d mypos = gAgent.getPositionGlobal(); { std::vector<LLUUID> avatar_ids; std::vector<LLUUID> sorted_avatar_ids; std::vector<LLVector3d> positions; LLWorld::getInstance()->getAvatars(&avatar_ids, &positions, mypos, F32_MAX); sorted_avatar_ids = avatar_ids; std::sort(sorted_avatar_ids.begin(), sorted_avatar_ids.end()); for (std::vector<LLCharacter*>::const_iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) { LLUUID avid = (*iter)->getID(); if (!std::binary_search(sorted_avatar_ids.begin(), sorted_avatar_ids.end(), avid)) { avatar_ids.push_back(avid); } } size_t i; size_t count = avatar_ids.size(); for (i = 0; i < count; ++i) { std::string name; std::string first; std::string last; const LLUUID &avid = avatar_ids[i]; LLVector3d position; LLViewerObject *obj = gObjectList.findObject(avid); if (obj) { LLVOAvatar* avatarp = dynamic_cast<LLVOAvatar*>(obj); if (avatarp == NULL) { continue; } // Skip if avatar is dead(what's that?) // or if the avatar is ourselves. if (avatarp->isDead() || avatarp->isSelf()) { continue; } // Get avatar data position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition()); name = avatarp->getFullname(); // Apparently, sometimes the name comes out empty, with a " " name. This is because // getFullname concatenates first and last name with a " " in the middle. // This code will avoid adding a nameless entry to the list until it acquires a name. //duped for lower section if (name.empty() || (name.compare(" ") == 0))// || (name.compare(gCacheName->getDefaultName()) == 0)) { if (gCacheName->getName(avid, first, last)) { name = first + " " + last; } else { continue; } } if (avid.isNull()) { //llinfos << "Key empty for avatar " << name << llendl; continue; } if (mAvatars.count(avid) > 0) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); mAvatars[avid].setPosition(position, (avatarp->getRegion() == gAgent.getRegion()), true, dist < 20.0, dist < 100.0); } else { // Avatar not there yet, add it LLAvatarListEntry entry(avid, name, position); mAvatars[avid] = entry; } } else { if (i < positions.size()) { position = positions[i]; } else { continue; } if (gCacheName->getName(avid, first, last)) { name = first + " " + last; } else { //name = gCacheName->getDefaultName(); continue; //prevent (Loading...) } if (mAvatars.count(avid) > 0) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); mAvatars[avid].setPosition(position, gAgent.getRegion()->pointInRegionGlobal(position), false, dist < 20.0, dist < 100.0); } else { LLAvatarListEntry entry(avid, name, position); mAvatars[avid] = entry; } } } } // llinfos << "radar refresh: done" << llendl; expireAvatarList(); refreshAvatarList(); refreshTracker(); }
BOOL FloaterAvatarList::tick() { if(!gDisconnected) { LLCheckboxCtrl* check = getChild<LLCheckboxCtrl>("update_enabled_cb"); if(check && check->getValue()) { //UPDATES// LLVector3d agent_pos = gAgent.getPositionGlobal(); std::vector<LLUUID> avatar_ids; std::vector<LLUUID> sorted_avatar_ids; std::vector<LLVector3d> positions; LLWorld::instance().getAvatars(&avatar_ids, &positions,agent_pos); sorted_avatar_ids = avatar_ids; std::sort(sorted_avatar_ids.begin(), sorted_avatar_ids.end()); for(std::vector<LLCharacter*>::const_iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) { LLUUID avid = (*iter)->getID(); if(!std::binary_search(sorted_avatar_ids.begin(), sorted_avatar_ids.end(), avid)) { avatar_ids.push_back(avid); } } int i = 0; int len = avatar_ids.size(); for(i = 0; i < len; i++) { LLUUID &avid = avatar_ids[i]; if(avid != gAgent.getID()) { std::string name; std::string first; std::string last; LLVector3d position; LLViewerObject *obj = gObjectList.findObject(avid); bool same_region = false; bool in_draw = false; if(obj) { LLVOAvatar* avatarp = dynamic_cast<LLVOAvatar*>(obj); if (avatarp == NULL) { continue; } if (avatarp->isDead()) { continue; } position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition()); in_draw = true; same_region = avatarp->getRegion() == gAgent.getRegion(); }else { if( i < (int)positions.size()) { position = positions[i]; } else { continue; } same_region = gAgent.getRegion()->pointInRegionGlobal(position); } if(gCacheName->getName(avid, first, last)) { name = first + " " + last; } else { continue;//name = LLCacheName::getDefaultName(); } if (mAvatars.find(avid) == mAvatars.end()) { avatar_entry new_entry; new_entry.id = avid; new_entry.is_linden = (strcmp(last.c_str(),"Linden") == 0 || strcmp(last.c_str(),"Tester") == 0) ? true : false; mAvatars[avid] = new_entry; if(gSavedSettings.getBOOL("EmeraldRadarChatKeys")) { gMessageSystem->newMessage("ScriptDialogReply"); gMessageSystem->nextBlock("AgentData"); gMessageSystem->addUUID("AgentID", gAgent.getID()); gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); gMessageSystem->nextBlock("Data"); gMessageSystem->addUUID("ObjectID", gAgent.getID()); gMessageSystem->addS32("ChatChannel", gSavedSettings.getS32("EmeraldRadarChatKeysChannel")); gMessageSystem->addS32("ButtonIndex", 1); gMessageSystem->addString("ButtonLabel",llformat("%d,%d,", gFrameCount, 1) + avid.asString()); gAgent.sendReliableMessage(); } } avatar_entry* entry = &(mAvatars[avid]); entry->name = name; entry->position = position; entry->same_region = same_region; entry->last_update_frame = gFrameCount; entry->last_update_sec.reset(); bool in_chat = (position - agent_pos).magVec() < 20.0f; chat_alerts(entry,same_region, in_draw, in_chat); if(entry->last_in_sim != same_region) { LLViewerRegion* regionp = gAgent.getRegion(); if(sInstance->mEstateMemoryBans.find(regionp) != sInstance->mEstateMemoryBans.end()) { std::set<LLUUID> *mem = &mEstateMemoryBans[regionp]; if(mem->find(avid) != mem->end()) { cmdline_printchat("Enforcing memory ban."); execEstateKick(avid); } } } entry->last_in_sim = same_region; entry->last_in_draw = in_draw; entry->last_in_chat = in_chat; } } //END UPDATES// //EXPIRE// std::map<LLUUID, avatar_entry>::iterator iter; std::queue<LLUUID> delete_queue; for(iter = mAvatars.begin(); iter != mAvatars.end(); iter++) { //avatar_entry *entry = &iter->second; F32 aged = iter->second.last_update_sec.getElapsedTimeF32(); if ( aged > CLEANUP_TIMEOUT ) { LLUUID av_id = iter->first; delete_queue.push(av_id); } else if(iter->second.last_update_frame != gFrameCount) if(iter->second.last_update_frame != -1) { LLUUID av_id = iter->first; chat_alerts(&iter->second,false, false, false); iter->second.last_in_sim = false; iter->second.last_in_draw = false; iter->second.last_in_chat = false; iter->second.last_update_frame = -1; if(gSavedSettings.getBOOL("EmeraldRadarChatKeys")) { gMessageSystem->newMessage("ScriptDialogReply"); gMessageSystem->nextBlock("AgentData"); gMessageSystem->addUUID("AgentID", gAgent.getID()); gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); gMessageSystem->nextBlock("Data"); gMessageSystem->addUUID("ObjectID", gAgent.getID()); gMessageSystem->addS32("ChatChannel", gSavedSettings.getS32("EmeraldRadarChatKeysChannel")); gMessageSystem->addS32("ButtonIndex", 1); gMessageSystem->addString("ButtonLabel",llformat("%d,%d,", gFrameCount, 0) + av_id.asString()); gAgent.sendReliableMessage(); } } } while(!delete_queue.empty()) { mAvatars.erase(delete_queue.front()); delete_queue.pop(); } //END EXPIRE// //DRAW// if (sInstance->getVisible()) { LLCheckboxCtrl* fetch_data = getChild<LLCheckboxCtrl>("fetch_avdata_enabled_cb"); BOOL fetching = fetch_data->getValue(); LLDynamicArray<LLUUID> selected = mAvatarList->getSelectedIDs(); S32 scrollpos = mAvatarList->getScrollPos(); mAvatarList->deleteAllItems(); std::map<LLUUID, avatar_entry>::iterator iter; for(iter = mAvatars.begin(); iter != mAvatars.end(); iter++) { LLUUID av_id; av_id = iter->first; avatar_entry *entry = &iter->second; //llinfos << entry->last_update_sec.getElapsedSeconds() << llendl; if(entry->last_update_sec.getElapsedTimeF32() < 5.0f) { LLSD element; if(entry->has_info == false && fetching && last_av_req.getElapsedTimeF32() > MIN_REQUEST_INTERVAL) { F32 now = entry->lifetime.getElapsedTimeF32(); F32 diff = now - entry->last_info_req; bool requested = entry->info_requested(); if(diff > entry->request_timeout || !requested) { if(requested && entry->request_timeout < 256.0f)entry->request_timeout *= 2.0f; last_av_req.reset(); entry->last_info_req = entry->lifetime.getElapsedTimeF32(); LLMessageSystem *msg = gMessageSystem; msg->newMessageFast(_PREHASH_AvatarPropertiesRequest); msg->nextBlockFast(_PREHASH_AgentData); msg->addUUIDFast(_PREHASH_AgentID, gAgent.getID()); msg->addUUIDFast(_PREHASH_SessionID, gAgent.getSessionID()); msg->addUUIDFast(_PREHASH_AvatarID, av_id); gAgent.sendReliableMessage(); } } LLVector3d delta = entry->position - agent_pos; F32 distance = (F32)delta.magVec(); delta.mdV[VZ] = 0.0f; //F32 side_distance = (F32)delta.magVec(); if(av_id.isNull())continue; element["id"] = av_id; std::string icon = ""; if(entry->is_linden) { element["columns"][LIST_AVATAR_NAME]["font-style"] = "BOLD"; } element["columns"][LIST_AVATAR_NAME]["column"] = "avatar_name"; element["columns"][LIST_AVATAR_NAME]["type"] = "text"; element["columns"][LIST_AVATAR_NAME]["value"] = entry->name; element["columns"][LIST_AVATAR_NAME]["color"] = gColors.getColor("DefaultListText").getValue(); element["columns"][LIST_DISTANCE]["column"] = "distance"; element["columns"][LIST_DISTANCE]["type"] = "text"; if(entry->position.mdV[VZ] == 0.0) { static F32 *sRenderFarClip = rebind_llcontrol<F32>("RenderFarClip",&gSavedSettings,true); element["columns"][LIST_DISTANCE]["value"] = llformat("> %d", S32(*sRenderFarClip) ); }else { element["columns"][LIST_DISTANCE]["value"] = llformat("%.2f", distance); } LLColor4 dist_color; static LLColor4U *sAvatarListTextDistNormalRange = rebind_llcontrol<LLColor4U>("AvatarListTextDistNormalRange",&gColors,true); static LLColor4U *sAvatarListTextDistShoutRange = rebind_llcontrol<LLColor4U>("AvatarListTextDistShoutRange",&gColors,true); static LLColor4U *sAvatarListTextDistOver = rebind_llcontrol<LLColor4U>("AvatarListTextDistOver",&gColors,true); if(distance <= 20.0f)dist_color = LLColor4(*sAvatarListTextDistNormalRange); else if(distance > 20.0f && distance <= 96.0f)dist_color = LLColor4(*sAvatarListTextDistShoutRange); else dist_color = LLColor4(*sAvatarListTextDistOver); element["columns"][LIST_DISTANCE]["color"] = dist_color.getValue(); if(entry->has_info) { static F32 *sEmeraldAvatarAgeAlertDays = rebind_llcontrol<F32>("EmeraldAvatarAgeAlertDays",&gSavedSettings,true); if(entry->account_age < *sEmeraldAvatarAgeAlertDays && entry->age_alerted == false) { entry->age_alerted = true; } element["columns"][LIST_AGE]["column"] = "age"; element["columns"][LIST_AGE]["type"] = "text"; element["columns"][LIST_AGE]["value"] = llformat("%d",entry->account_age); LLColor4 age_color; static LLColor4U *sAvatarListTextAgeYoung = rebind_llcontrol<LLColor4U>("AvatarListTextAgeYoung",&gColors,true); static LLColor4U *sAvatarListTextAgeNormal = rebind_llcontrol<LLColor4U>("AvatarListTextAgeNormal",&gColors,true); if ( entry->account_age <= 7 )age_color = LLColor4(*sAvatarListTextAgeYoung); else age_color = LLColor4(*sAvatarListTextAgeNormal); element["columns"][LIST_AGE]["color"] = age_color.getValue(); } element["columns"][LIST_SIM]["column"] = "samesim"; element["columns"][LIST_SIM]["type"] = "text"; icon = ""; if(entry->last_update_sec.getElapsedTimeF32() < 0.5) { if(entry->same_region) { icon = "account_id_green.tga"; } }else { icon = "avatar_gone.tga"; } if (!icon.empty() ) { element["columns"][LIST_SIM].erase("color"); element["columns"][LIST_SIM]["type"] = "icon"; element["columns"][LIST_SIM]["value"] = icon; } icon = ""; if(!entry->has_info) { if(entry->info_requested()) { if(entry->request_timeout < 256.0f) icon = "info_fetching.tga"; else icon = "info_error.tga"; }else icon = "info_unknown.tga"; }else { switch(entry->agent_info.payment) { case PAYMENT_NONE: break; case PAYMENT_ON_FILE: icon = "payment_info_filled.tga"; break; case PAYMENT_USED: icon = "payment_info_used.tga"; break; case PAYMENT_LINDEN: // confusingly named icon, maybe use something else icon = "icon_top_pick.tga"; break; } } element["columns"][LIST_PAYMENT]["column"] = "payment_data"; element["columns"][LIST_PAYMENT]["type"] = "text"; if ( !icon.empty() ) { element["columns"][LIST_PAYMENT]["type"] = "icon"; element["columns"][LIST_PAYMENT]["value"] = icon; } S32 seentime = (S32)entry->lifetime.getElapsedTimeF32(); S32 hours = (S32)(seentime / (60*60)); S32 mins = (S32)((seentime - hours*(60*60)) / 60); S32 secs = (S32)((seentime - hours*(60*60) - mins*60)); element["columns"][LIST_TIME]["column"] = "time"; element["columns"][LIST_TIME]["type"] = "text"; element["columns"][LIST_TIME]["color"] = gColors.getColor("DefaultListText").getValue(); element["columns"][LIST_TIME]["value"] = llformat("%d:%02d:%02d", hours,mins,secs); element["columns"][LIST_CLIENT]["column"] = "client"; element["columns"][LIST_CLIENT]["type"] = "text"; static LLColor4U *sAvatarNameColor = rebind_llcontrol<LLColor4U>("AvatarNameColor",&gColors,true); static LLColor4U *sScrollUnselectedColor = rebind_llcontrol<LLColor4U>("ScrollUnselectedColor",&gColors,true); LLColor4 avatar_name_color = LLColor4(*sAvatarNameColor); std::string client; LLVOAvatar *av = (LLVOAvatar*)gObjectList.findObject(av_id); if(av) { LLVOAvatar::resolveClient(avatar_name_color, client, av); if(client == "") { avatar_name_color = LLColor4(*sScrollUnselectedColor); client = "?"; } element["columns"][LIST_CLIENT]["value"] = client.c_str(); } else { element["columns"][LIST_CLIENT]["value"] = "Out Of Range"; avatar_name_color = LLColor4(*sScrollUnselectedColor); } avatar_name_color = (avatar_name_color * 0.5) + (LLColor4(*sScrollUnselectedColor) * 0.5); element["columns"][LIST_CLIENT]["color"] = avatar_name_color.getValue(); mAvatarList->addElement(element, ADD_BOTTOM); } } mAvatarList->sortItems(); mAvatarList->selectMultiple(selected); mAvatarList->setScrollPos(scrollpos); } //END DRAW// } } if( mTracking && LLTracker::getTrackedPositionGlobal().isExactlyZero() ) { // trying to track an avatar, but tracker stopped tracking if ( mAvatars.find(mTrackedAvatar) != mAvatars.end() && !mTrackByLocation) { mTrackByLocation = TRUE; } else { LLTracker::stopTracking(NULL); mTracking = FALSE; } } if ( mTracking && mTrackByLocation) { std::string name = mAvatars[mTrackedAvatar].name; std::string tooltip = "Tracking last known position"; name += " (near)"; LLTracker::trackLocation(mAvatars[mTrackedAvatar].position,name, tooltip); } return FALSE; }
void LLFloaterAvatarList::updateAvatarList() { //llinfos << "radar refresh: updating map" << llendl; // Check whether updates are enabled LLCheckboxCtrl* check = getChild<LLCheckboxCtrl>("update_enabled_cb"); if (check && !check->getValue()) { mUpdate = FALSE; refreshTracker(); return; } else { mUpdate = TRUE; } //moved to pipeline to prevent a crash //gPipeline.forAllVisibleDrawables(updateParticleActivity); //todo: make this less of a hacked up copypasta from dales 1.18. if(gAudiop != NULL) { LLAudioEngine::source_map::iterator iter; for (iter = gAudiop->mAllSources.begin(); iter != gAudiop->mAllSources.end(); ++iter) { LLAudioSource *sourcep = iter->second; LLUUID uuid = sourcep->getOwnerID(); LLAvatarListEntry *ent = getAvatarEntry(uuid); if ( ent ) { ent->setActivity(LLAvatarListEntry::ACTIVITY_SOUND); } } } LLVector3d mypos = gAgent.getPositionGlobal(); { std::vector<LLUUID> avatar_ids; std::vector<LLUUID> sorted_avatar_ids; std::vector<LLVector3d> positions; LLWorld::instance().getAvatars(&avatar_ids, &positions, mypos, F32_MAX); sorted_avatar_ids = avatar_ids; std::sort(sorted_avatar_ids.begin(), sorted_avatar_ids.end()); BOOST_FOREACH(std::vector<LLCharacter*>::value_type& iter, LLCharacter::sInstances) { LLUUID avid = iter->getID(); if (!std::binary_search(sorted_avatar_ids.begin(), sorted_avatar_ids.end(), avid)) { avatar_ids.push_back(avid); } } size_t i; size_t count = avatar_ids.size(); static LLCachedControl<bool> announce(gSavedSettings, "RadarChatKeys"); std::queue<LLUUID> announce_keys; for (i = 0; i < count; ++i) { std::string name; const LLUUID &avid = avatar_ids[i]; LLVector3d position; LLVOAvatar* avatarp = gObjectList.findAvatar(avid); if (avatarp) { // Skip if avatar is dead(what's that?) // or if the avatar is ourselves. // or if the avatar is a dummy if (avatarp->isDead() || avatarp->isSelf() || avatarp->mIsDummy) { continue; } // Get avatar data position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition()); name = avatarp->getFullname(); if (!LLAvatarNameCache::getPNSName(avatarp->getID(), name)) continue; //duped for lower section if (name.empty() || (name.compare(" ") == 0))// || (name.compare(gCacheName->getDefaultName()) == 0)) { if (!gCacheName->getFullName(avid, name)) //seems redudant with LLAvatarNameCache::getPNSName above... { continue; } } if (avid.isNull()) { //llinfos << "Key empty for avatar " << name << llendl; continue; } LLAvatarListEntry* entry = getAvatarEntry(avid); if (entry) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); entry->setPosition(position, (avatarp->getRegion() == gAgent.getRegion()), true, dist < 20.0, dist < 100.0); if(avatarp->isTyping())entry->setActivity(LLAvatarListEntry::ACTIVITY_TYPING); } else { // Avatar not there yet, add it if(announce && avatarp->getRegion() == gAgent.getRegion()) announce_keys.push(avid); mAvatars.push_back(LLAvatarListEntryPtr(new LLAvatarListEntry(avid, name, position))); } } else { if (i < positions.size()) { position = positions[i]; } else { continue; } if (!LLAvatarNameCache::getPNSName(avid, name)) { //name = gCacheName->getDefaultName(); continue; //prevent (Loading...) } LLAvatarListEntry* entry = getAvatarEntry(avid); if (entry) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); entry->setPosition(position, gAgent.getRegion()->pointInRegionGlobal(position), false, dist < 20.0, dist < 100.0); } else { if(announce && gAgent.getRegion()->pointInRegionGlobal(position)) announce_keys.push(avid); mAvatars.push_back(LLAvatarListEntryPtr(new LLAvatarListEntry(avid, name, position))); } } } //let us send the keys in a more timely fashion if (announce && !announce_keys.empty()) { // NOTE: This fragment is repeated in sendKey std::ostringstream ids; int transact_num = (int)gFrameCount; int num_ids = 0; while(!announce_keys.empty()) { LLUUID id = announce_keys.front(); announce_keys.pop(); ids << "," << id.asString(); ++num_ids; if (ids.tellp() > 200) { send_keys_message(transact_num, num_ids, ids.str()); num_ids = 0; ids.seekp(0); ids.str(""); } } if (num_ids > 0) send_keys_message(transact_num, num_ids, ids.str()); } }
void LLFloaterAvatarList::updateAvatarList() { if (sInstance != this) return; #ifdef LL_RRINTERFACE_H //MK if (gRRenabled && gAgent.mRRInterface.mContainsShownames) { close(); } #endif //mk //llinfos << "radar refresh: updating map" << llendl; // Check whether updates are enabled LLCheckboxCtrl* check = getChild<LLCheckboxCtrl>("update_enabled_cb"); if (check && !check->getValue()) { mUpdate = FALSE; refreshTracker(); return; } else { mUpdate = TRUE; } LLVector3d mypos = gAgent.getPositionGlobal(); { std::vector<LLUUID> avatar_ids; std::vector<LLUUID> sorted_avatar_ids; std::vector<LLVector3d> positions; LLWorld::instance().getAvatars(&avatar_ids, &positions, mypos, F32_MAX); sorted_avatar_ids = avatar_ids; std::sort(sorted_avatar_ids.begin(), sorted_avatar_ids.end()); for (std::vector<LLCharacter*>::const_iterator iter = LLCharacter::sInstances.begin(); iter != LLCharacter::sInstances.end(); ++iter) { LLUUID avid = (*iter)->getID(); if (!std::binary_search(sorted_avatar_ids.begin(), sorted_avatar_ids.end(), avid)) { avatar_ids.push_back(avid); } } size_t i; size_t count = avatar_ids.size(); bool announce = gSavedSettings.getBOOL("RadarChatKeys"); std::queue<LLUUID> announce_keys; for (i = 0; i < count; ++i) { std::string name, first, last; const LLUUID &avid = avatar_ids[i]; LLVector3d position; LLViewerObject *obj = gObjectList.findObject(avid); if (obj) { LLVOAvatar* avatarp = dynamic_cast<LLVOAvatar*>(obj); if (avatarp == NULL) { continue; } // Skip if avatar is dead(what's that?) // or if the avatar is ourselves. // or if the avatar is a dummy if (avatarp->isDead() || avatarp->isSelf() || avatarp->mIsDummy) { continue; } // Get avatar data position = gAgent.getPosGlobalFromAgent(avatarp->getCharacterPosition()); name = avatarp->getFullname(); // Apparently, sometimes the name comes out empty, with a " " name. This is because // getFullname concatenates first and last name with a " " in the middle. // This code will avoid adding a nameless entry to the list until it acquires a name. //duped for lower section if (name.empty() || (name.compare(" ") == 0))// || (name.compare(gCacheName->getDefaultName()) == 0)) { if (gCacheName->getName(avid, first, last)) { name = first + " " + last; } else { continue; } } ifdef LL_DISPLAY_NAMES std::string display_name = name; if (LLAvatarNameCache::useDisplayNames()) { LLAvatarName avatar_name; if (LLAvatarNameCache::get(avid, &avatar_name)) { if (LLAvatarNameCache::useDisplayNames() == 2) { display_name = avatar_name.mDisplayName; } else { display_name = avatar_name.getNames(); } } } #endif if (avid.isNull()) { //llinfos << "Key empty for avatar " << name << llendl; continue; } if (mAvatars.count(avid) > 0) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); mAvatars[avid].setPosition(position, (avatarp->getRegion() == gAgent.getRegion()), true, dist < 20.0, dist < 100.0); } else { // Avatar not there yet, add it LLAvatarListEntry entry(avid, name, position); if(announce && avatarp->getRegion() == gAgent.getRegion()) announce_keys.push(avid); mAvatars[avid] = entry; } #ifdef LL_DISPLAY_NAMES // update avatar display name. mAvatars[avid].setDisplayName(display_name); #endif } else { if (i < positions.size()) { position = positions[i]; } else { continue; } if (gCacheName->getName(avid, first, last)) { name = first + " " + last; } else { //name = gCacheName->getDefaultName(); continue; //prevent (Loading...) } #ifdef LL_DISPLAY_NAMES std::string display_name = name; if (LLAvatarNameCache::useDisplayNames()) { LLAvatarName avatar_name; if (LLAvatarNameCache::get(avid, &avatar_name)) { if (LLAvatarNameCache::useDisplayNames() == 2) { display_name = avatar_name.mDisplayName; } else { display_name = avatar_name.getNames(); } } } #endif if (mAvatars.count(avid) > 0) { // Avatar already in list, update position F32 dist = (F32)(position - mypos).magVec(); mAvatars[avid].setPosition(position, gAgent.getRegion()->pointInRegionGlobal(position), false, dist < 20.0, dist < 100.0); } else { LLAvatarListEntry entry(avid, name, position); if(announce && gAgent.getRegion()->pointInRegionGlobal(position)) announce_keys.push(avid); mAvatars[avid] = entry; } #ifdef LL_DISPLAY_NAMES // update avatar display name. mAvatars[avid].setDisplayName(display_name); #endif } } //let us send the keys in a more timely fashion if(announce && !announce_keys.empty()) { std::ostringstream ids; int transact_num = (int)gFrameCount; int num_ids = 0; while(!announce_keys.empty()) { LLUUID id = announce_keys.front(); announce_keys.pop(); ids << "," << id.asString(); ++num_ids; if(ids.tellp() > 200) { gMessageSystem->newMessage("ScriptDialogReply"); gMessageSystem->nextBlock("AgentData"); gMessageSystem->addUUID("AgentID", gAgent.getID()); gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); gMessageSystem->nextBlock("Data"); gMessageSystem->addUUID("ObjectID", gAgent.getID()); gMessageSystem->addS32("ChatChannel", -777777777); gMessageSystem->addS32("ButtonIndex", 1); gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); gAgent.sendReliableMessage(); num_ids = 0; ids.seekp(0); ids.str(""); } } if(num_ids > 0) { gMessageSystem->newMessage("ScriptDialogReply"); gMessageSystem->nextBlock("AgentData"); gMessageSystem->addUUID("AgentID", gAgent.getID()); gMessageSystem->addUUID("SessionID", gAgent.getSessionID()); gMessageSystem->nextBlock("Data"); gMessageSystem->addUUID("ObjectID", gAgent.getID()); gMessageSystem->addS32("ChatChannel", -777777777); gMessageSystem->addS32("ButtonIndex", 1); gMessageSystem->addString("ButtonLabel",llformat("%d,%d", transact_num, num_ids) + ids.str()); gAgent.sendReliableMessage(); } } } // llinfos << "radar refresh: done" << llendl; expireAvatarList(); refreshAvatarList(); refreshTracker(); }