[FIRE-16526] Fix Teleport and Location History for OpenSim when Hypergridding

This commit is contained in:
Hecklezz
2026-04-21 08:31:22 +10:00
parent 6a3066fb33
commit 1bbe36a9f0
7 changed files with 232 additions and 30 deletions
+25 -4
View File
@@ -34,6 +34,8 @@
#include <string>
#include <boost/signals2.hpp>
#include "llslurl.h" // <FS/> 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 ):
// <FS:TJ> 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()):
// </FS:TJ>
mLocation(typed_location),
mGlobalPos(global_position),
mToolTip(tooltip),
mType(type)
mType(type),
mSLURL(slurl) // <FS:TJ/> 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) // <FS:TJ/> 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()))
{}
// <FS:TJ> Fix Teleport and Location History for OpenSim
//{}
{
if (data.has("slurl") && !data["slurl"].asString().empty())
{
mSLURL = LLSLURL(data["slurl"].asString());
}
else
{
mSLURL = LLSLURL();
}
}
// </FS:TJ>
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(); // <FS:TJ/> 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; // <FS:TJ/> Fix Teleport and Location History for OpenSim
};
class LLLocationHistory: public LLSingleton<LLLocationHistory>
+13 -1
View File
@@ -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
// <FS:TJ> 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;
}
// </FS:TJ>
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(); // <FS:TJ/> Fix Teleport and Location History for OpenSim
addLocationHistoryEntry(it->getLocation(), value);
}
}
+70 -4
View File
@@ -53,6 +53,7 @@
#include "llviewerinventory.h"
#include "llviewermenu.h"
#include "llviewernetwork.h" // <FS:AW hypergrid support >
#include "lfsimfeaturehandler.h" // <FS/> 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"))
{
// <FS:TJ> 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
// </FS:TJ>
gAgent.teleportViaLocation(LLVector3d(value["global_pos"]));
return;
}
@@ -685,11 +729,30 @@ void LLNavigationBar::onTeleportFinished(const LLVector3d& global_agent_pos)
gAgent.getPosAgentFromGlobal(global_agent_pos));
// <FS:Beq pp Oren> 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());
// </FS:Beq pp Oren>
LLLocationHistoryItem item (location,
global_agent_pos, tooltip,TYPED_REGION_SLURL);// we can add into history only TYPED location
// <FS:TJ> 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
}
// </FS:TJ>
//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(
// </FS:Beq pp Oren>
gAgent.teleportViaLocation(global_pos);
}
else if (gSavedSettings.getBOOL("SearchFromAddressBar"))
// <FS:TJ> Fix Teleport and Location History for OpenSim
//else if (gSavedSettings.getBOOL("SearchFromAddressBar"))
else if (!typed_location.empty() && gSavedSettings.getBOOL("SearchFromAddressBar"))
// </FS:TJ>
{
invokeSearch(typed_location);
}
+7 -6
View File
@@ -102,7 +102,7 @@ void LLTeleportHistory::goToItem(int idx)
return;
}
// <FS> [FIRE-35355] OpenSim global position is dependent on the Grid you are on
// <FS:TJ> [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
// </FS>
// </FS:TJ>
// 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]
// <FS> [FIRE-35355] OpenSim global position is dependent on the Grid you are on,
// <FS:TJ> [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
// </FS>
// </FS:TJ>
}
//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(); // <FS:TJ/> Fix Teleport and Location History for OpenSim
LL_INFOS() << line.str() << LL_ENDL;
}
}
// <FS> [FIRE-35355] Callback for OpenSim so we can teleport to the correct global position on another grid
// <FS:TJ> [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();
}
}
// </FS>
// </FS:TJ>
+5 -4
View File
@@ -49,11 +49,12 @@ public:
LLTeleportHistoryItem()
{}
// <FS> [FIRE-35355] OpenSim requires knowing the grid to teleport correctly if changing grids
// <FS:TJ> [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)
// </FS:TJ>
{}
/**
@@ -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; // <FS/> [FIRE-35355] slurl for the location required for OpenSim
LLSLURL mSLURL; // <FS:TJ/> [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);
// <FS> [FIRE-35355] Callback for OpenSim so we can teleport to the correct global position on another grid
// <FS:TJ> [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);
// </FS>
// </FS:TJ>
/**
* Actually, the teleport history.
+87 -5
View File
@@ -39,6 +39,11 @@
#include "rlvactions.h"
// [/RLVa:KB]
#include "llviewernetwork.h" // <FS/> Access to GridManager
#include "lfsimfeaturehandler.h" // <FS/> Access to hyperGridURL
#include "llworldmapmessage.h" // <FS/> Access to sendNamedRegionRequest
#include "llregionhandle.h" // <FS/> 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"];
// <FS:TJ> Fix Teleport and Location History for OpenSim
if (val.has("slurl") && !val["slurl"].asString().empty())
{
mSLURL = LLSLURL(val["slurl"].asString());
}
else
{
mSLURL = LLSLURL();
}
// </FS:TJ>
}
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(); // <FS:TJ/> Fix Teleport and Location History for OpenSim
return val;
}
@@ -105,7 +121,10 @@ void LLTeleportHistoryStorage::onTeleportHistoryChange()
}
// [/RLVa:KB]
addItem(item.mTitle, item.mGlobalPos);
// <FS:TJ> Fix Teleport and Location History for OpenSim
//addItem(item.mTitle, item.mGlobalPos);
addItem(item.mTitle, item.mGlobalPos, item.mSLURL);
// </FS:TJ>
save();
}
@@ -115,10 +134,14 @@ void LLTeleportHistoryStorage::purgeItems()
mHistoryChangedSignal(-1);
}
void LLTeleportHistoryStorage::addItem(const std::string title, const LLVector3d& global_pos)
// <FS:TJ> 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);
}
// </FS:TJ>
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)
// <FS:TJ> 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);
// <FS:TJ> 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(); // <FS:TJ/> Fix Teleport and Location History for OpenSim
LL_INFOS() << line.str() << LL_ENDL;
}
@@ -280,6 +308,36 @@ void LLTeleportHistoryStorage::goToItem(S32 idx)
return;
}
// <FS:TJ> 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
// </FS:TJ>
// Attempt to teleport to the requested item.
gAgent.teleportViaLocation(mItems[idx].mGlobalPos);
}
@@ -304,3 +362,27 @@ void LLTeleportHistoryStorage::showItemOnMap(S32 idx)
}
}
// <FS:TJ> 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;
}
}
// </FS:TJ>
+25 -6
View File
@@ -33,6 +33,8 @@
#include "lldate.h"
#include "v3dmath.h"
#include "llslurl.h" // <FS/> 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())
// <FS:TJ> 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)
// </FS:TJ>
{}
LLTeleportHistoryPersistentItem(const std::string title, const LLVector3d& global_pos, const LLDate& date)
: mTitle(title), mGlobalPos(global_pos), mDate(date)
// <FS:TJ> 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)
// </FS:TJ>
{}
LLTeleportHistoryPersistentItem(const LLSD& val);
@@ -60,6 +70,7 @@ public:
std::string mTitle;
LLVector3d mGlobalPos;
LLDate mDate;
LLSLURL mSLURL; // <FS:TJ/> 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);
// <FS:TJ> 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());
// </FS:TJ>
void removeItem(S32 idx);
@@ -114,6 +129,10 @@ public:
*/
void showItemOnMap(S32 idx);
// <FS:TJ> Fix Teleport and Location History for OpenSim
void regionNameCallback(int idx, U64 handle, const LLSLURL& slurl, const LLUUID& snapshot_id, bool teleport);
// </FS:TJ>
//private:
// [RLVa:KB] - Checked: 2010-09-03 (RLVa-1.2.1b) | Added: RLVa-1.2.1b
protected: