From a1f1fb3ff4dcb3c7a392eacbcfeb2f08768dd353 Mon Sep 17 00:00:00 2001 From: Beq Date: Wed, 12 May 2021 16:50:21 +0100 Subject: [PATCH] [OpenSim] Var Region fixups from Oren @ kitely --- indra/newview/fsslurl.cpp | 37 +++++++++++++----- indra/newview/fsslurl.h | 6 ++- indra/newview/llagentui.cpp | 5 ++- indra/newview/llfloaterexperienceprofile.cpp | 5 ++- indra/newview/llfloaterworldmap.cpp | 15 ++++++-- indra/newview/lllandmarkactions.cpp | 40 +++++++++++++++----- indra/newview/lllocationinputctrl.cpp | 26 +++++++++---- indra/newview/llnavigationbar.cpp | 12 ++++-- indra/newview/llpanelplacestab.cpp | 14 +++++-- indra/newview/llslurl.cpp | 10 ++++- indra/newview/llslurl.h | 8 +++- 11 files changed, 135 insertions(+), 43 deletions(-) diff --git a/indra/newview/fsslurl.cpp b/indra/newview/fsslurl.cpp index be5a5b5d43..86e7b9794e 100644 --- a/indra/newview/fsslurl.cpp +++ b/indra/newview/fsslurl.cpp @@ -469,29 +469,46 @@ LLSLURL::LLSLURL(const std::string& region, const LLVector3& position, bool hype *this = LLSLURL(LLGridManager::getInstance()->getGrid(), region, position); } +// FIRE-30768: SLURL's don't work in VarRegions // create a slurl from a global position -LLSLURL::LLSLURL(const std::string& grid, const std::string& region, const LLVector3d& global_position, bool hypergrid) -: mHypergrid(hypergrid) -{ +//LLSLURL::LLSLURL(const std::string& grid, const std::string& region, const LLVector3d& global_position, bool hypergrid) +//: mHypergrid(hypergrid) +//{ // Aurora-sim var region teleports //*this = LLSLURL(grid, // region, LLVector3(global_position.mdV[VX], // global_position.mdV[VY], // global_position.mdV[VZ])); - S32 x = ll_round( (F32)fmod( (F32)global_position.mdV[VX], (F32)REGION_WIDTH_METERS ) ); - S32 y = ll_round( (F32)fmod( (F32)global_position.mdV[VY], (F32)REGION_WIDTH_METERS ) ); - S32 z = ll_round( (F32)global_position.mdV[VZ] ); +// S32 x = ll_round( (F32)fmod( (F32)global_position.mdV[VX], (F32)REGION_WIDTH_METERS ) ); +// S32 y = ll_round( (F32)fmod( (F32)global_position.mdV[VY], (F32)REGION_WIDTH_METERS ) ); +// S32 z = ll_round( (F32)global_position.mdV[VZ] ); - *this = LLSLURL(grid, region, LLVector3(x, y, z)); +// *this = LLSLURL(grid, region, LLVector3(x, y, z)); // +//} +// +// create a slurl from a global position +//LLSLURL::LLSLURL(const std::string& region, const LLVector3d& global_position, bool hypergrid) +//: mHypergrid(hypergrid) +//{ +// *this = LLSLURL(LLGridManager::getInstance()->getGrid(), region, global_position); +//} + +// create a slurl from a global position +LLSLURL::LLSLURL(const std::string& grid, const std::string& region, const LLVector3d& region_origin, const LLVector3d& global_position, bool hypergrid) + : mHypergrid(hypergrid) +{ + LLVector3 local_position = LLVector3(global_position - region_origin); + *this = LLSLURL(grid, region, local_position); } // create a slurl from a global position -LLSLURL::LLSLURL(const std::string& region, const LLVector3d& global_position, bool hypergrid) -: mHypergrid(hypergrid) +LLSLURL::LLSLURL(const std::string& region, const LLVector3d& region_origin, const LLVector3d& global_position, bool hypergrid) + : mHypergrid(hypergrid) { - *this = LLSLURL(LLGridManager::getInstance()->getGrid(), region, global_position); + *this = LLSLURL(LLGridManager::getInstance()->getGrid(), region, region_origin, global_position); } +// LLSLURL::LLSLURL(const std::string& command, const LLUUID&id, const std::string& verb) : mHypergrid(false) diff --git a/indra/newview/fsslurl.h b/indra/newview/fsslurl.h index e01764190b..86727bf877 100644 --- a/indra/newview/fsslurl.h +++ b/indra/newview/fsslurl.h @@ -73,8 +73,12 @@ public: LLSLURL(const std::string& grid, const std::string& region, bool hypergrid = false); LLSLURL(const std::string& region, const LLVector3& position, bool hypergrid = false); LLSLURL(const std::string& grid, const std::string& region, const LLVector3& position, bool hypergrid = false); - LLSLURL(const std::string& grid, const std::string& region, const LLVector3d& global_position, bool hypergrid = false); LLSLURL(const std::string& region, const LLVector3d& global_position, bool hypergrid = false); +// FIRE-30768: SLURL's don't work in VarRegions (patch from Oren) +// LLSLURL(const std::string& grid, const std::string& region, const LLVector3d& global_position, bool hypergrid = false); + LLSLURL(const std::string& grid, const std::string& region, const LLVector3d& region_origin, const LLVector3d& global_position, bool hypergrid = false); + LLSLURL(const std::string& region, const LLVector3d& region_origin, const LLVector3d& global_position, bool hypergrid = false); +// LLSLURL(const std::string& command, const LLUUID&id, const std::string& verb); LLSLURL(const LLSD& path_array, bool from_app); diff --git a/indra/newview/llagentui.cpp b/indra/newview/llagentui.cpp index 065087cea6..d8541bf9d3 100644 --- a/indra/newview/llagentui.cpp +++ b/indra/newview/llagentui.cpp @@ -72,7 +72,10 @@ void LLAgentUI::buildSLURL(LLSLURL& slurl, const bool escaped /*= true*/) else #endif // - return_slurl = LLSLURL(regionp->getName(), gAgent.getPositionGlobal()); + // FIRE-30768: SLURL's don't work in VarRegions + //return_slurl = LLSLURL(regionp->getName(), gAgent.getPositionGlobal()); + return_slurl = LLSLURL(regionp->getName(), regionp->getOriginGlobal(), gAgent.getPositionGlobal()); + // } slurl = return_slurl; } diff --git a/indra/newview/llfloaterexperienceprofile.cpp b/indra/newview/llfloaterexperienceprofile.cpp index e8be5a402c..8c414ecde9 100644 --- a/indra/newview/llfloaterexperienceprofile.cpp +++ b/indra/newview/llfloaterexperienceprofile.cpp @@ -679,7 +679,10 @@ void LLFloaterExperienceProfile::onClickLocation() if(region) { LLTextBox* child = getChild(EDIT TF_SLURL); - mLocationSLURL = LLSLURL(region->getName(), gAgent.getPositionGlobal()).getSLURLString(); + // FIRE-30768: SLURL's don't work in VarRegions (Patch from Oren) + //mLocationSLURL = LLSLURL(region->getName(), gAgent.getPositionGlobal()).getSLURLString(); + mLocationSLURL = LLSLURL(region->getName(), region->getOriginGlobal(), gAgent.getPositionGlobal()).getSLURLString(); + // child->setText(mLocationSLURL); onFieldChanged(); } diff --git a/indra/newview/llfloaterworldmap.cpp b/indra/newview/llfloaterworldmap.cpp index 2a2887c257..bd0d828acf 100644 --- a/indra/newview/llfloaterworldmap.cpp +++ b/indra/newview/llfloaterworldmap.cpp @@ -1022,7 +1022,12 @@ void LLFloaterWorldMap::updateLocation() return; // invalid location } std::string sim_name; - gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal( pos_global, sim_name ); + // FIRE-30768: SLURL's don't work in VarRegions + //gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal( pos_global, sim_name ); + LLSimInfo* sim_info = LLWorldMap::getInstance()->simInfoFromPosGlobal(pos_global); + if (sim_info) + sim_name = sim_info->getName(); + // if ((status != LLTracker::TRACKING_NOTHING) && (status != mTrackedStatus || pos_global != mTrackedLocation || sim_name != mTrackedSimName)) { @@ -1055,12 +1060,16 @@ void LLFloaterWorldMap::updateLocation() childSetValue("location", RlvStrings::getString(RlvStringKeys::Hidden::Region)); } - else if (gotSimName) +// FORE-30768 Slurls in Var regions are b0rked + // else if (gotSimName) + else if (sim_info) // [/RLVa:KB] // if ( gotSimName ) { - mSLURL = LLSLURL(sim_name, pos_global); + // mSLURL = LLSLURL(sim_name, pos_global); + mSLURL = LLSLURL(sim_info->getName(), sim_info->getGlobalOrigin(), pos_global); } +// else { // Empty SLURL will disable the "Copy SLURL to clipboard" button mSLURL = LLSLURL(); diff --git a/indra/newview/lllandmarkactions.cpp b/indra/newview/lllandmarkactions.cpp index 1778a945a6..436b25ffe4 100644 --- a/indra/newview/lllandmarkactions.cpp +++ b/indra/newview/lllandmarkactions.cpp @@ -327,11 +327,18 @@ void LLLandmarkActions::getSLURLfromPosGlobalAndLocal(const LLVector3d& global_p // void LLLandmarkActions::getSLURLfromPosGlobal(const LLVector3d& global_pos, slurl_callback_t cb, bool escaped /* = true */) { - std::string sim_name; - bool gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal(global_pos, sim_name); - if (gotSimName) + // FIRE-30768: SLURL's don't work in VarRegions + //std::string sim_name; + //bool gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal(global_pos, sim_name); + //if (gotSimName) + //{ + // std::string slurl = LLSLURL(sim_name, global_pos).getSLURLString(); + + LLSimInfo* sim_info = LLWorldMap::getInstance()->simInfoFromPosGlobal(global_pos); + if (sim_info) { - std::string slurl = LLSLURL(sim_name, global_pos).getSLURLString(); + std::string slurl = LLSLURL(sim_info->getName(), sim_info->getGlobalOrigin(), global_pos).getSLURLString(); + // cb(slurl); return; @@ -389,19 +396,34 @@ void LLLandmarkActions::onRegionResponseSLURL(slurl_callback_t cb, bool escaped, const std::string& url) { - std::string sim_name; +// FIRE-30768: SLURL's don't work in VarRegions +// std::string sim_name; +// std::string slurl; +// bool gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal(global_pos, sim_name); +// if (gotSimName) +// { +// // Debug... +// if (sim_name.empty()) +// { +// LL_WARNS() << "Requested sim name is empty!" << LL_ENDL; +// } +// // +// slurl = LLSLURL(sim_name, global_pos).getSLURLString(); +// } + std::string slurl; - bool gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal(global_pos, sim_name); - if (gotSimName) + LLSimInfo* sim_info = LLWorldMap::getInstance()->simInfoFromPosGlobal(global_pos); + if (sim_info) { // Debug... - if (sim_name.empty()) + if (sim_info->getName().empty()) { LL_WARNS() << "Requested sim name is empty!" << LL_ENDL; } // - slurl = LLSLURL(sim_name, global_pos).getSLURLString(); + slurl = LLSLURL(sim_info->getName(), sim_info->getGlobalOrigin(), global_pos).getSLURLString(); } +// else { slurl = ""; diff --git a/indra/newview/lllocationinputctrl.cpp b/indra/newview/lllocationinputctrl.cpp index 821ab12537..de802f6275 100644 --- a/indra/newview/lllocationinputctrl.cpp +++ b/indra/newview/lllocationinputctrl.cpp @@ -49,6 +49,7 @@ #include "lllandmarkactions.h" #include "lllandmarklist.h" #include "llpathfindingmanager.h" +#include "llworld.h" // FIRE-30768: SLURL's don't work in VarRegions #include "llpathfindingnavmesh.h" #include "llpathfindingnavmeshstatus.h" #include "llteleporthistory.h" @@ -775,13 +776,24 @@ void LLLocationInputCtrl::onLocationPrearrange(const LLSD& data) //mFullTitile format - region_name[, parcel_name] (local_x,local_y, local_z) if (new_item_titles.insert(result->mFullTitle).second) { - LLSD value; - value["item_type"] = TELEPORT_HISTORY; - 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 - value["tooltip"] = LLSLURL(region_name, result->mGlobalPos).getSLURLString(); - add(result->getTitle(), value); + // FIRE-30768: SLURL's don't work in VarRegions + LLViewerRegion* regionp = LLWorld::instance().getRegionFromID(result->mRegionID); + if (regionp) + { + LLSD value; + value["item_type"] = TELEPORT_HISTORY; + 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 + //value["tooltip"] = LLSLURL(region_name, result->mGlobalPos).getSLURLString(); + value["tooltip"] = LLSLURL(region_name, regionp->getOriginGlobal(), result->mGlobalPos).getSLURLString(); + add(result->getTitle(), value); + } + else + { + LL_WARNS("LocationInputCtrl") << "unable to resolve region " << result->mRegionID << LL_ENDL; + } + // } result = std::find_if(result + 1, th_items.end(), boost::bind( &LLLocationInputCtrl::findTeleportItemsByTitle, this, diff --git a/indra/newview/llnavigationbar.cpp b/indra/newview/llnavigationbar.cpp index edd2d4e91b..34b5853bb9 100644 --- a/indra/newview/llnavigationbar.cpp +++ b/indra/newview/llnavigationbar.cpp @@ -672,8 +672,11 @@ void LLNavigationBar::onTeleportFinished(const LLVector3d& global_agent_pos) */ LLAgentUI::buildLocationString(location, LLAgentUI::LOCATION_FORMAT_NO_MATURITY, gAgent.getPosAgentFromGlobal(global_agent_pos)); - std::string tooltip (LLSLURL(gAgent.getRegion()->getName(), global_agent_pos).getSLURLString()); - + // 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()); + // + LLLocationHistoryItem item (location, global_agent_pos, tooltip,TYPED_REGION_SLURL);// we can add into history only TYPED location //Touch it, if it is at list already, add new location otherwise @@ -760,7 +763,10 @@ void LLNavigationBar::onRegionNameResponse( LLVector3d region_pos = from_region_handle(region_handle); LLVector3d global_pos = region_pos + (LLVector3d) local_coords; - LL_INFOS() << "Teleporting to: " << LLSLURL(region_name, global_pos).getSLURLString() << LL_ENDL; + // FIRE-30768: SLURL's don't work in VarRegions + //LL_INFOS() << "Teleporting to: " << LLSLURL(region_name, global_pos).getSLURLString() << LL_ENDL; + LL_INFOS() << "Teleporting to: " << LLSLURL(region_name, region_pos, global_pos).getSLURLString() << LL_ENDL; + // gAgent.teleportViaLocation(global_pos); } else if (gSavedSettings.getBOOL("SearchFromAddressBar")) diff --git a/indra/newview/llpanelplacestab.cpp b/indra/newview/llpanelplacestab.cpp index 9644b7518e..34a36b186e 100644 --- a/indra/newview/llpanelplacestab.cpp +++ b/indra/newview/llpanelplacestab.cpp @@ -60,14 +60,20 @@ void LLPanelPlacesTab::onRegionResponse(const LLVector3d& landmark_global_pos, const LLUUID& snapshot_id, bool teleport) { - std::string sim_name; - bool gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal( landmark_global_pos, sim_name ); + // FIRE-30768: SLURL's don't work in VarRegions + //std::string sim_name; + //bool gotSimName = LLWorldMap::getInstance()->simNameFromPosGlobal( landmark_global_pos, sim_name ); + LLSimInfo* sim_info = LLWorldMap::getInstance()->simInfoFromPosGlobal(landmark_global_pos); std::string sl_url; - if ( gotSimName ) + //if ( gotSimName ) + if (sim_info) { - sl_url = LLSLURL(sim_name, landmark_global_pos).getSLURLString(); + //sl_url = LLSLURL(sim_name, landmark_global_pos).getSLURLString(); + sl_url = LLSLURL(sim_info->getName(), sim_info->getGlobalOrigin(), landmark_global_pos).getSLURLString(); } + // + else { sl_url = ""; diff --git a/indra/newview/llslurl.cpp b/indra/newview/llslurl.cpp index f9b0dc241d..ffa964b117 100644 --- a/indra/newview/llslurl.cpp +++ b/indra/newview/llslurl.cpp @@ -363,10 +363,16 @@ LLSLURL::LLSLURL(const std::string& grid, // create a slurl from a global position LLSLURL::LLSLURL(const std::string& region, + const LLVector3d& region_origin, // FIRE-30768: SLURL's don't work in VarRegions const LLVector3d& global_position) { - *this = LLSLURL(LLGridManager::getInstance()->getGridId(), - region, global_position); + *this = LLSLURL(LLGridManager::getInstance()->getGridId(), + // FIRE-30768: SLURL's don't work in VarRegions + // region, global_position); + region, + region_origin, + global_position); + // } LLSLURL::LLSLURL(const std::string& command, const LLUUID&id, const std::string& verb) diff --git a/indra/newview/llslurl.h b/indra/newview/llslurl.h index d722852ba3..86b8d3cd89 100644 --- a/indra/newview/llslurl.h +++ b/indra/newview/llslurl.h @@ -71,8 +71,12 @@ public: LLSLURL(const std::string& grid, const std::string& region); LLSLURL(const std::string& region, const LLVector3& position); LLSLURL(const std::string& grid, const std::string& region, const LLVector3& position); - LLSLURL(const std::string& grid, const std::string& region, const LLVector3d& global_position); - LLSLURL(const std::string& region, const LLVector3d& global_position); + // FIRE-30768: SLURL's don't work in VarRegions + //LLSLURL(const std::string& grid, const std::string& region, const LLVector3d& global_position); + //LLSLURL(const std::string& region, const LLVector3d& global_position); + LLSLURL(const std::string& grid, const std::string& region, const LLVector3d& region_origin, const LLVector3d& global_position); + LLSLURL(const std::string& region, const LLVector3d& region_origin, const LLVector3d& global_position); + // LLSLURL(const std::string& command, const LLUUID&id, const std::string& verb); SLURL_TYPE getType() const { return mType; }