diff --git a/indra/newview/lllocationhistory.h b/indra/newview/lllocationhistory.h index 34cb83367f..8bfb8acc18 100644 --- a/indra/newview/lllocationhistory.h +++ b/indra/newview/lllocationhistory.h @@ -34,6 +34,8 @@ #include #include +#include "llslurl.h" // Access to LLSLURL + class LLSD; /** * This enum is responsible for identifying of history item. @@ -48,24 +50,41 @@ class LLLocationHistoryItem { public: LLLocationHistoryItem(){} LLLocationHistoryItem(std::string typed_location, - LLVector3d global_position, std::string tooltip,ELocationType type ): + // Fix Teleport and Location History for OpenSim + //LLVector3d global_position, std::string tooltip,ELocationType type ): + LLVector3d global_position, std::string tooltip, ELocationType type, const LLSLURL& slurl = LLSLURL()): + // mLocation(typed_location), mGlobalPos(global_position), mToolTip(tooltip), - mType(type) + mType(type), + mSLURL(slurl) // Fix Teleport and Location History for OpenSim {} LLLocationHistoryItem(const LLLocationHistoryItem& item): mGlobalPos(item.mGlobalPos), mToolTip(item.mToolTip), mLocation(item.mLocation), - mType(item.mType) + mType(item.mType), + mSLURL(item.mSLURL) // Fix Teleport and Location History for OpenSim {} LLLocationHistoryItem(const LLSD& data): mLocation(data["location"]), mGlobalPos(data["global_pos"]), mToolTip(data["tooltip"]), mType(ELocationType(data["item_type"].asInteger())) - {} + // Fix Teleport and Location History for OpenSim + //{} + { + if (data.has("slurl") && !data["slurl"].asString().empty()) + { + mSLURL = LLSLURL(data["slurl"].asString()); + } + else + { + mSLURL = LLSLURL(); + } + } + // bool operator==(const LLLocationHistoryItem& item) { @@ -84,6 +103,7 @@ public: val["global_pos"] = mGlobalPos.getValue(); val["tooltip"] = mToolTip; val["item_type"] = mType; + val["slurl"] = mSLURL.getSLURLString(); // Fix Teleport and Location History for OpenSim return val; } const std::string& getLocation() const { return mLocation; }; @@ -98,6 +118,7 @@ public: std::string mToolTip;// SURL std::string mLocation;// typed_location ELocationType mType; + LLSLURL mSLURL; // Fix Teleport and Location History for OpenSim }; class LLLocationHistory: public LLSingleton diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index a1fef7c5ef..0fa21fcd89 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -784,8 +784,19 @@ void LLLocationInputCtrl::onLocationPrearrange(const LLSD& data) value["global_pos"] = result->mGlobalPos.getValue(); std::string region_name = result->mTitle.substr(0, result->mTitle.find(',')); //TODO*: add Surl to teleportitem or parse region name from title + // Fix Teleport and Location History for OpenSim //value["tooltip"] = LLSLURL(region_name, result->mGlobalPos).getSLURLString(); - value["tooltip"] = LLSLURL(region_name, regionp->getOriginGlobal(), result->mGlobalPos).getSLURLString(); + if (LLGridManager::getInstance()->isInSecondLife()) + { + value["tooltip"] = LLSLURL(region_name, regionp->getOriginGlobal(), result->mGlobalPos).getSLURLString(); + } + else + { + std::string slurl = result->mSLURL.getSLURLString(); + value["tooltip"] = slurl; + value["slurl"] = slurl; + } + // addLocationHistoryEntry(result->getTitle(), value); } else @@ -1106,6 +1117,7 @@ void LLLocationInputCtrl::rebuildLocationHistory(const std::string& filter) //location history can contain only typed locations value["item_type"] = TYPED_REGION_SLURL; value["global_pos"] = it->mGlobalPos.getValue(); + value["slurl"] = it->mSLURL.getSLURLString(); // Fix Teleport and Location History for OpenSim addLocationHistoryEntry(it->getLocation(), value); } } diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp index 6e6f07f2a4..8e5265d814 100644 --- a/indra/newview/llnavigationbar.cpp +++ b/indra/newview/llnavigationbar.cpp @@ -53,6 +53,7 @@ #include "llviewerinventory.h" #include "llviewermenu.h" #include "llviewernetwork.h" // +#include "lfsimfeaturehandler.h" // Access to hyperGridURL #include "llviewerparcelmgr.h" #include "llworldmapmessage.h" #include "llappviewer.h" @@ -575,6 +576,49 @@ void LLNavigationBar::onLocationSelection() case TYPED_REGION_SLURL: if(value.has("global_pos")) { + // Fix Teleport and Location History for OpenSim + #ifdef OPENSIM + if (LLGridManager::getInstance()->isInOpenSim()) + { + LLSLURL slurl = LLSLURL(); + if (value.has("slurl") && !value["slurl"].asString().empty()) + { + slurl = LLSLURL(value["slurl"].asString()); + } + else if (value.has("tooltip") && !value["tooltip"].asString().empty()) + { + // Try get the slurl from the tooltip as a fallback if it exists + slurl = LLSLURL(value["tooltip"].asString()); + } + + std::string grid = slurl.getGrid(); + std::string current_grid = LFSimFeatureHandler::instance().hyperGridURL(); + std::string gatekeeper = LLGridManager::getInstance()->getGatekeeper(grid); + + LL_INFOS("Hecklezz") << "grid: " << grid << ", current_grid: " << current_grid << ", gatekeeper: " << gatekeeper << LL_ENDL; + + // Requesting region information from the server is only required when changing grid + if (slurl.isValid() && grid != current_grid) + { + if (!gatekeeper.empty()) + { + slurl = LLSLURL(gatekeeper + ":" + slurl.getRegion(), slurl.getPosition(), true); + } + + LLWorldMapMessage::getInstance()->sendNamedRegionRequest( + slurl.getRegion(), + boost::bind(&LLNavigationBar::onRegionNameResponse, + this, std::string(), slurl.getRegion(), slurl.getPosition(), _1, _2, _3, _4), + slurl.getSLURLString(), + true + ); + + return; // The teleport will occur in the callback with the correct global position + } + } + #endif + // + gAgent.teleportViaLocation(LLVector3d(value["global_pos"])); return; } @@ -685,11 +729,30 @@ void LLNavigationBar::onTeleportFinished(const LLVector3d& global_agent_pos) gAgent.getPosAgentFromGlobal(global_agent_pos)); // FIRE-30768: SLURL's don't work in VarRegions //std::string tooltip (LLSLURL(gAgent.getRegion()->getName(), global_agent_pos).getSLURLString()); - std::string tooltip (LLSLURL(gAgent.getRegion()->getName(), gAgent.getRegion()->getOriginGlobal(), global_agent_pos).getSLURLString()); + std::string grid = LLGridManager::getInstance()->getGrid(); + std::string current_grid = LFSimFeatureHandler::instance().hyperGridURL(); + LLSLURL slurl = LLSLURL(gAgent.getRegion()->getName(), gAgent.getRegion()->getOriginGlobal(), global_agent_pos); + if (!LLGridManager::getInstance()->isInSecondLife() && grid != current_grid) + { + slurl = LLSLURL(current_grid, gAgent.getRegion()->getName(), gAgent.getRegion()->getOriginGlobal(), global_agent_pos, true); + } + std::string tooltip(slurl.getSLURLString()); // - LLLocationHistoryItem item (location, - global_agent_pos, tooltip,TYPED_REGION_SLURL);// we can add into history only TYPED location + // Fix Teleport and Location History for OpenSim + //LLLocationHistoryItem item (location, + // global_agent_pos, tooltip,TYPED_REGION_SLURL);// we can add into history only TYPED location + LLLocationHistoryItem item; + if (LLGridManager::getInstance()->isInSecondLife()) { + item = LLLocationHistoryItem(location, + global_agent_pos, tooltip,TYPED_REGION_SLURL);// we can add into history only TYPED location + } + else + { + item = LLLocationHistoryItem(location, + global_agent_pos, tooltip, TYPED_REGION_SLURL, slurl);// we can add into history only TYPED location + } + // //Touch it, if it is at list already, add new location otherwise if ( !lh->touchItem(item) ) { lh->addItem(item); @@ -780,7 +843,10 @@ void LLNavigationBar::onRegionNameResponse( // gAgent.teleportViaLocation(global_pos); } - else if (gSavedSettings.getBOOL("SearchFromAddressBar")) + // Fix Teleport and Location History for OpenSim + //else if (gSavedSettings.getBOOL("SearchFromAddressBar")) + else if (!typed_location.empty() && gSavedSettings.getBOOL("SearchFromAddressBar")) + // { invokeSearch(typed_location); } diff --git a/indra/newview/llteleporthistory.cpp b/indra/newview/llteleporthistory.cpp index 3c20615a24..b0e705ec22 100644 --- a/indra/newview/llteleporthistory.cpp +++ b/indra/newview/llteleporthistory.cpp @@ -102,7 +102,7 @@ void LLTeleportHistory::goToItem(int idx) return; } - // [FIRE-35355] OpenSim global position is dependent on the Grid you are on + // [FIRE-35355] OpenSim global position is dependent on the Grid you are on #ifdef OPENSIM if (LLGridManager::getInstance()->isInOpenSim()) { @@ -140,7 +140,7 @@ void LLTeleportHistory::goToItem(int idx) } } #endif - // + // // Attempt to teleport to the requested item. gAgent.teleportViaLocation(mItems[idx].mGlobalPos); @@ -255,7 +255,7 @@ void LLTeleportHistory::updateCurrentLocation(const LLVector3d& new_pos) } // [/RLVa:KB] - // [FIRE-35355] OpenSim global position is dependent on the Grid you are on, + // [FIRE-35355] OpenSim global position is dependent on the Grid you are on, // so we need to store the slurl so we can request the global position later #ifdef OPENSIM if (LLGridManager::getInstance()->isInOpenSim()) @@ -269,7 +269,7 @@ void LLTeleportHistory::updateCurrentLocation(const LLVector3d& new_pos) } } #endif - // + // } //dump(); // LO - removing the dump from happening every time we TP. @@ -344,11 +344,12 @@ void LLTeleportHistory::dump() const line << i << ": " << mItems[i].mTitle; line << " REGION_ID: " << mItems[i].mRegionID; line << ", pos: " << mItems[i].mGlobalPos; + line << ", slurl: " << mItems[i].mSLURL.asString(); // Fix Teleport and Location History for OpenSim LL_INFOS() << line.str() << LL_ENDL; } } -// [FIRE-35355] Callback for OpenSim so we can teleport to the correct global position on another grid +// [FIRE-35355] Callback for OpenSim so we can teleport to the correct global position on another grid void LLTeleportHistory::regionNameCallback(int idx, U64 region_handle, const LLSLURL& slurl, const LLUUID& snapshot_id, bool teleport) { if (region_handle) @@ -378,4 +379,4 @@ void LLTeleportHistory::regionNameCallback(int idx, U64 region_handle, const LLS onTeleportFailed(); } } -// +// diff --git a/indra/newview/llteleporthistory.h b/indra/newview/llteleporthistory.h index eff88d620f..12e092bfc2 100644 --- a/indra/newview/llteleporthistory.h +++ b/indra/newview/llteleporthistory.h @@ -49,11 +49,12 @@ public: LLTeleportHistoryItem() {} - // [FIRE-35355] OpenSim requires knowing the grid to teleport correctly if changing grids + // [FIRE-35355] OpenSim requires knowing the grid to teleport correctly if changing grids //LLTeleportHistoryItem(std::string title, LLVector3d global_pos) // : mTitle(title), mGlobalPos(global_pos) LLTeleportHistoryItem(std::string title, LLVector3d global_pos, const LLSLURL& slurl = LLSLURL()) : mTitle(title), mGlobalPos(global_pos), mSLURL(slurl) + // {} /** @@ -66,7 +67,7 @@ public: std::string mFullTitle; // human-readable location title including coordinates LLVector3d mGlobalPos; // global position LLUUID mRegionID; // region ID for getting the region info - LLSLURL mSLURL; // [FIRE-35355] slurl for the location required for OpenSim + LLSLURL mSLURL; // [FIRE-35355] slurl for the location required for OpenSim }; /** @@ -186,9 +187,9 @@ private: */ static std::string getCurrentLocationTitle(bool full, const LLVector3& local_pos_override); - // [FIRE-35355] Callback for OpenSim so we can teleport to the correct global position on another grid + // [FIRE-35355] Callback for OpenSim so we can teleport to the correct global position on another grid void regionNameCallback(int idx, U64 handle, const LLSLURL& slurl, const LLUUID& snapshot_id, bool teleport); - // + // /** * Actually, the teleport history. diff --git a/indra/newview/llteleporthistorystorage.cpp b/indra/newview/llteleporthistorystorage.cpp index a73e149649..b53eb75cd8 100644 --- a/indra/newview/llteleporthistorystorage.cpp +++ b/indra/newview/llteleporthistorystorage.cpp @@ -39,6 +39,11 @@ #include "rlvactions.h" // [/RLVa:KB] +#include "llviewernetwork.h" // Access to GridManager +#include "lfsimfeaturehandler.h" // Access to hyperGridURL +#include "llworldmapmessage.h" // Access to sendNamedRegionRequest +#include "llregionhandle.h" // Access to from_region_handle + // Max offset for two global positions to consider them as equal const F64 MAX_GLOBAL_POS_OFFSET = 5.0f; @@ -47,6 +52,16 @@ LLTeleportHistoryPersistentItem::LLTeleportHistoryPersistentItem(const LLSD& val mTitle = val["title"].asString(); mGlobalPos.setValue(val["global_pos"]); mDate = val["date"]; + // Fix Teleport and Location History for OpenSim + if (val.has("slurl") && !val["slurl"].asString().empty()) + { + mSLURL = LLSLURL(val["slurl"].asString()); + } + else + { + mSLURL = LLSLURL(); + } + // } LLSD LLTeleportHistoryPersistentItem::toLLSD() const @@ -56,6 +71,7 @@ LLSD LLTeleportHistoryPersistentItem::toLLSD() const val["title"] = mTitle; val["global_pos"] = mGlobalPos.getValue(); val["date"] = mDate; + val["slurl"] = mSLURL.getSLURLString(); // Fix Teleport and Location History for OpenSim return val; } @@ -105,7 +121,10 @@ void LLTeleportHistoryStorage::onTeleportHistoryChange() } // [/RLVa:KB] - addItem(item.mTitle, item.mGlobalPos); + // Fix Teleport and Location History for OpenSim + //addItem(item.mTitle, item.mGlobalPos); + addItem(item.mTitle, item.mGlobalPos, item.mSLURL); + // save(); } @@ -115,10 +134,14 @@ void LLTeleportHistoryStorage::purgeItems() mHistoryChangedSignal(-1); } -void LLTeleportHistoryStorage::addItem(const std::string title, const LLVector3d& global_pos) +// Fix Teleport and Location History for OpenSim +//void LLTeleportHistoryStorage::addItem(const std::string title, const LLVector3d& global_pos) +void LLTeleportHistoryStorage::addItem(const std::string title, const LLVector3d& global_pos, const LLSLURL& slurl) { - addItem(title, global_pos, LLDate::now()); + //addItem(title, global_pos, LLDate::now()); + addItem(title, global_pos, LLDate::now(), slurl); } +// bool LLTeleportHistoryStorage::compareByTitleAndGlobalPos(const LLTeleportHistoryPersistentItem& a, const LLTeleportHistoryPersistentItem& b) @@ -126,7 +149,9 @@ bool LLTeleportHistoryStorage::compareByTitleAndGlobalPos(const LLTeleportHistor return a.mTitle == b.mTitle && (a.mGlobalPos - b.mGlobalPos).length() < MAX_GLOBAL_POS_OFFSET; } -void LLTeleportHistoryStorage::addItem(const std::string title, const LLVector3d& global_pos, const LLDate& date) +// Fix Teleport and Location History for OpenSim +//void LLTeleportHistoryStorage::addItem(const std::string title, const LLVector3d& global_pos, const LLDate& date) +void LLTeleportHistoryStorage::addItem(const std::string title, const LLVector3d& global_pos, const LLDate& date, const LLSLURL& slurl) { // [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1b) | Added: RLVa-1.2.1b if (!RlvActions::canShowLocation()) @@ -135,7 +160,9 @@ void LLTeleportHistoryStorage::addItem(const std::string title, const LLVector3d } // [/RLVa:KB] - LLTeleportHistoryPersistentItem item(title, global_pos, date); + // Fix Teleport and Location History for OpenSim + //LLTeleportHistoryPersistentItem item(title, global_pos, date); + LLTeleportHistoryPersistentItem item(title, global_pos, date, slurl); slurl_list_t::iterator item_iter = std::find_if(mItems.begin(), mItems.end(), boost::bind(&LLTeleportHistoryStorage::compareByTitleAndGlobalPos, this, _1, item)); @@ -260,6 +287,7 @@ void LLTeleportHistoryStorage::dump() const line << i << ": " << mItems[i].mTitle; line << " global pos: " << mItems[i].mGlobalPos; line << " date: " << mItems[i].mDate; + line << " slurl: " << mItems[i].mSLURL.asString(); // Fix Teleport and Location History for OpenSim LL_INFOS() << line.str() << LL_ENDL; } @@ -280,6 +308,36 @@ void LLTeleportHistoryStorage::goToItem(S32 idx) return; } + // Fix Teleport and Location History for OpenSim +#ifdef OPENSIM + if (LLGridManager::getInstance()->isInOpenSim()) + { + LLSLURL slurl = LLSLURL(mItems[idx].mSLURL); + std::string grid = slurl.getGrid(); + std::string current_grid = LFSimFeatureHandler::instance().hyperGridURL(); + std::string gatekeeper = LLGridManager::getInstance()->getGatekeeper(grid); + + // Requesting region information from the server is only required when changing grid + if (slurl.isValid() && grid != current_grid) + { + if (!gatekeeper.empty()) + { + slurl = LLSLURL(gatekeeper + ":" + slurl.getRegion(), slurl.getPosition(), true); + } + + LLWorldMapMessage::getInstance()->sendNamedRegionRequest( + slurl.getRegion(), + boost::bind(&LLTeleportHistoryStorage::regionNameCallback, this, idx, _1, _2, _3, _4), + slurl.getSLURLString(), + true + ); + + return; // The teleport will occur in the callback with the correct global position + } + } +#endif + // + // Attempt to teleport to the requested item. gAgent.teleportViaLocation(mItems[idx].mGlobalPos); } @@ -304,3 +362,27 @@ void LLTeleportHistoryStorage::showItemOnMap(S32 idx) } } +// Fix Teleport and Location History for OpenSim +void LLTeleportHistoryStorage::regionNameCallback(int idx, U64 region_handle, const LLSLURL& slurl, const LLUUID& snapshot_id, bool teleport) +{ + if (region_handle) + { + // Sanity checks again just in case since time has passed since the request was made + if (idx < 0 ||idx >= (int)mItems.size()) + { + LL_WARNS() << "Invalid teleport history storage index (" << idx << ") specified" << LL_ENDL; + return; + } + + LLVector3d origin_pos = from_region_handle(region_handle); + LLVector3d global_pos(origin_pos + LLVector3d(slurl.getPosition())); + + // Attempt to teleport to the target grids region + gAgent.teleportViaLocation(global_pos); + } + else + { + LL_WARNS() << "Invalid teleport history storage region handle" << LL_ENDL; + } +} +// diff --git a/indra/newview/llteleporthistorystorage.h b/indra/newview/llteleporthistorystorage.h index 18001fd3cf..d21ae877cc 100644 --- a/indra/newview/llteleporthistorystorage.h +++ b/indra/newview/llteleporthistorystorage.h @@ -33,6 +33,8 @@ #include "lldate.h" #include "v3dmath.h" +#include "llslurl.h" // Access to LLSLURL + class LLSD; /** @@ -46,12 +48,20 @@ public: LLTeleportHistoryPersistentItem() {} - LLTeleportHistoryPersistentItem(const std::string title, const LLVector3d& global_pos) - : mTitle(title), mGlobalPos(global_pos), mDate(LLDate::now()) + // Fix Teleport and Location History for OpenSim + //LLTeleportHistoryPersistentItem(const std::string title, const LLVector3d& global_pos) + // : mTitle(title), mGlobalPos(global_pos), mDate(LLDate::now()) + LLTeleportHistoryPersistentItem(const std::string title, const LLVector3d& global_pos, const LLSLURL& slurl = LLSLURL()) + : mTitle(title), mGlobalPos(global_pos), mDate(LLDate::now()), mSLURL(slurl) + // {} - LLTeleportHistoryPersistentItem(const std::string title, const LLVector3d& global_pos, const LLDate& date) - : mTitle(title), mGlobalPos(global_pos), mDate(date) + // Fix Teleport and Location History for OpenSim + //LLTeleportHistoryPersistentItem(const std::string title, const LLVector3d& global_pos, const LLDate& date) + // : mTitle(title), mGlobalPos(global_pos), mDate(date) + LLTeleportHistoryPersistentItem(const std::string title, const LLVector3d& global_pos, const LLDate& date, const LLSLURL& slurl = LLSLURL()) + : mTitle(title), mGlobalPos(global_pos), mDate(date), mSLURL(slurl) + // {} LLTeleportHistoryPersistentItem(const LLSD& val); @@ -60,6 +70,7 @@ public: std::string mTitle; LLVector3d mGlobalPos; LLDate mDate; + LLSLURL mSLURL; // Fix Teleport and Location History for OpenSim }; /** @@ -86,8 +97,12 @@ public: const slurl_list_t& getItems() const { return mItems; } void purgeItems(); - void addItem(const std::string title, const LLVector3d& global_pos); - void addItem(const std::string title, const LLVector3d& global_pos, const LLDate& date); + // Fix Teleport and Location History for OpenSim + //void addItem(const std::string title, const LLVector3d& global_pos); + //void addItem(const std::string title, const LLVector3d& global_pos, const LLDate& date); + void addItem(const std::string title, const LLVector3d& global_pos, const LLSLURL& slurl = LLSLURL()); + void addItem(const std::string title, const LLVector3d& global_pos, const LLDate& date, const LLSLURL& slurl = LLSLURL()); + // void removeItem(S32 idx); @@ -114,6 +129,10 @@ public: */ void showItemOnMap(S32 idx); + // Fix Teleport and Location History for OpenSim + void regionNameCallback(int idx, U64 handle, const LLSLURL& slurl, const LLUUID& snapshot_id, bool teleport); + // + //private: // [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1b) | Added: RLVa-1.2.1b protected: