From 06bbe1bb663e099c5b15c07e8d8433ec065edcc3 Mon Sep 17 00:00:00 2001 From: McCabe Maxsted Date: Sat, 23 Oct 2010 23:54:22 -0700 Subject: #637: teleport target location in local chat, ported from Phoenix by Ansariel Hiller --- linden/indra/newview/llagent.cpp | 65 ++++++++++++++++++++++++++++++++ linden/indra/newview/llagent.h | 14 +++++++ linden/indra/newview/llviewermessage.cpp | 56 +++++++++++++++++++++++++++ linden/indra/newview/llworldmap.cpp | 7 ++++ 4 files changed, 142 insertions(+) diff --git a/linden/indra/newview/llagent.cpp b/linden/indra/newview/llagent.cpp index eb5cf9b..0a0374c 100644 --- a/linden/indra/newview/llagent.cpp +++ b/linden/indra/newview/llagent.cpp @@ -226,6 +226,16 @@ LLAgent gAgent; // BOOL LLAgent::sPhantom = FALSE; +BOOL LLAgent::lure_show = FALSE; +std::string LLAgent::lure_name; +LLVector3d LLAgent::lure_posglobal; +U16 LLAgent::lure_global_x; +U16 LLAgent::lure_global_y; +int LLAgent::lure_x; +int LLAgent::lure_y; +int LLAgent::lure_z; +std::string LLAgent::lure_maturity; + const F32 LLAgent::TYPING_TIMEOUT_SECS = 5.f; std::map LLAgent::sTeleportErrorMessages; @@ -8080,5 +8090,60 @@ LLVector3 LLAgent::getLastCoords() return mLastCoordinates; } +void LLAgent::showLureDestination(const std::string fromname, const int global_x, const int global_y, const int x, const int y, const int z, const std::string maturity) +{ + const LLVector3d posglobal = LLVector3d(F64(global_x), F64(global_y), F64(0)); + LLSimInfo* siminfo; + siminfo = LLWorldMap::getInstance()->simInfoFromPosGlobal(posglobal); + std::string sim_name; + LLWorldMap::getInstance()->simNameFromPosGlobal( posglobal, sim_name ); + + if(siminfo) + { + + llinfos << fromname << "'s teleport lure is to " << sim_name.c_str() << " (" << maturity << ")" << llendl; + std::string url = LLURLDispatcher::buildSLURL(sim_name.c_str(), S32(x), S32(y), S32(z)); + std::string msg; + msg = llformat("%s's teleport lure is to %s", fromname.c_str(), url.c_str()); + if(maturity != "") + msg.append(llformat(" (%s)", maturity.c_str())); + LLChat chat(msg); + LLFloaterChat::addChat(chat); + } + else + { + LLAgent::lure_show = TRUE; + LLAgent::lure_name = fromname; + LLAgent::lure_posglobal = posglobal; + LLAgent::lure_global_x = U16(global_x / 256); + LLAgent::lure_global_y = U16(global_y / 256); + LLAgent::lure_x = x; + LLAgent::lure_y = y; + LLAgent::lure_z = z; + LLAgent::lure_maturity = maturity; + LLWorldMap::getInstance()->sendMapBlockRequest(lure_global_x, lure_global_y, lure_global_x, lure_global_y, true); + } +} + +void LLAgent::onFoundLureDestination() +{ + LLAgent::lure_show = FALSE; + LLSimInfo* siminfo; + siminfo = LLWorldMap::getInstance()->simInfoFromPosGlobal(LLAgent::lure_posglobal); + std::string sim_name; + LLWorldMap::getInstance()->simNameFromPosGlobal( LLAgent::lure_posglobal, sim_name ); + + if(siminfo && (!gRlvHandler.hasBehaviour(RLV_BHVR_SHOWLOC))) + { + llinfos << LLAgent::lure_name << " is offering a TP to " << sim_name.c_str() << " (" << LLAgent::lure_maturity << ")" << llendl; + std::string url = LLURLDispatcher::buildSLURL(sim_name.c_str(), S32(LLAgent::lure_x), S32(LLAgent::lure_y), S32(LLAgent::lure_z)); + std::string msg; + msg = llformat("%s is offering a TP to %s", LLAgent::lure_name.c_str(), url.c_str()); + if(LLAgent::lure_maturity != "") + msg.append(llformat(" (%s)", LLAgent::lure_maturity.c_str())); + LLChat chat(msg); + LLFloaterChat::addChat(chat); + } +} // EOF diff --git a/linden/indra/newview/llagent.h b/linden/indra/newview/llagent.h index 141c72c..03b0045 100644 --- a/linden/indra/newview/llagent.h +++ b/linden/indra/newview/llagent.h @@ -767,6 +767,17 @@ public: BOOL mInitialized; + static BOOL lure_show; + static std::string lure_name; + static LLVector3d lure_posglobal; + static U16 lure_global_x; + static U16 lure_global_y; + static int lure_x; + static int lure_y; + static int lure_z; + static std::string lure_maturity; + + S32 mNumPendingQueries; S32* mActiveCacheQueries; @@ -782,6 +793,9 @@ public: LLFrameTimer mDoubleTapRunTimer; EDoubleTapRunMode mDoubleTapRunMode; + static void showLureDestination(const std::string fromname, const int global_x, const int global_y, const int x, const int y, const int z, const std::string maturity); + static void onFoundLureDestination(); + private: bool mbTeleportKeepsLookAt; bool mbAlwaysRun; // should the avatar run by default rather than walk diff --git a/linden/indra/newview/llviewermessage.cpp b/linden/indra/newview/llviewermessage.cpp index dbf9d72..d3ca5f6 100755 --- a/linden/indra/newview/llviewermessage.cpp +++ b/linden/indra/newview/llviewermessage.cpp @@ -2520,6 +2520,62 @@ void process_improved_im(LLMessageSystem *msg, void **user_data) else { LLNotifications::instance().add("TeleportOffered", args, payload); + if(binary_bucket_size) + { + char* dest = new char[binary_bucket_size]; + strncpy(dest, (char*)binary_bucket, binary_bucket_size-1); /* Flawfinder: ignore */ + dest[binary_bucket_size-1] = '\0'; + + llinfos << "IM_LURE_USER binary_bucket " << dest << llendl; + + std::string str(dest); + typedef boost::tokenizer > tokenizer; + boost::char_separator sep("|","",boost::keep_empty_tokens); + tokenizer tokens(str, sep); + tokenizer::iterator iter = tokens.begin(); + std::string global_x_str(*iter++); + std::string global_y_str(*iter++); + std::string x_str(*iter++); + std::string y_str(*iter++); + std::string z_str(*iter++); + // skip what I think must be LookAt + if(iter != tokens.end()) + iter++; // x + if(iter != tokens.end()) + iter++; // y + if(iter != tokens.end()) + iter++; // z + std::string mat_str(""); + if(iter != tokens.end()) + mat_str.assign(*iter++); + mat_str = utf8str_trim(mat_str); + + llinfos << "IM_LURE_USER tokenized " << global_x_str << "|" << global_y_str << "|" << x_str << "|" << y_str << "|" << z_str << "|" << mat_str << llendl; + + std::istringstream gxstr(global_x_str); + int global_x; + gxstr >> global_x; + + std::istringstream gystr(global_y_str); + int global_y; + gystr >> global_y; + + std::istringstream xstr(x_str); + int x; + xstr >> x; + + std::istringstream ystr(y_str); + int y; + ystr >> y; + + std::istringstream zstr(z_str); + int z; + zstr >> z; + + llinfos << "IM_LURE_USER parsed " << global_x << "|" << global_y << "|" << x << "|" << y << "|" << z << "|" << mat_str << llendl; + + gAgent.showLureDestination(name, global_x, global_y, x, y, z, mat_str); + } } // [/RLVa:KB] //LLNotifications::instance().add("TeleportOffered", args, payload); diff --git a/linden/indra/newview/llworldmap.cpp b/linden/indra/newview/llworldmap.cpp index c6242f6..01a66d4 100644 --- a/linden/indra/newview/llworldmap.cpp +++ b/linden/indra/newview/llworldmap.cpp @@ -735,6 +735,13 @@ void LLWorldMap::processMapBlockReply(LLMessageSystem* msg, void**) callback(handle, LLWorldMap::getInstance()->mSLURL, image_id, LLWorldMap::getInstance()->mSLURLTeleport); } } + if(LLAgent::lure_show) + { + if((x_regions == LLAgent::lure_global_x) && (y_regions == LLAgent::lure_global_y)) + { + gAgent.onFoundLureDestination(); + } + } } if(adjust) gFloaterWorldMap->adjustZoomSliderBounds(); -- cgit v1.1