void LLPanelPlaceInfo::displayParcelInfo(const LLUUID& region_id, const LLVector3d& pos_global) { LLViewerRegion* region = gAgent.getRegion(); if (!region) return; mPosRegion.setVec((F32)fmod(pos_global.mdV[VX], (F64)REGION_WIDTH_METERS), (F32)fmod(pos_global.mdV[VY], (F64)REGION_WIDTH_METERS), (F32)pos_global.mdV[VZ]); LLSD body; std::string url = region->getCapability("RemoteParcelRequest"); if (!url.empty()) { body["location"] = ll_sd_from_vector3(mPosRegion); if (!region_id.isNull()) { body["region_id"] = region_id; } if (!pos_global.isExactlyZero()) { U64 region_handle = to_region_handle(pos_global); body["region_handle"] = ll_sd_from_U64(region_handle); } LLHTTPClient::post(url, body, new LLRemoteParcelRequestResponder(getObserverHandle())); } else { mDescEditor->setText(getString("server_update_text")); } }
void LLPanelPlace::displayParcelInfo(const LLVector3& pos_region, const LLUUID& landmark_asset_id, const LLUUID& region_id, const LLVector3d& pos_global) { LLSD body; mPosRegion = pos_region; mPosGlobal = pos_global; mLandmarkAssetID = landmark_asset_id; std::string url = gAgent.getRegion()->getCapability("RemoteParcelRequest"); if (!url.empty()) { body["location"] = ll_sd_from_vector3(pos_region); if (!region_id.isNull()) { body["region_id"] = region_id; } if (!pos_global.isExactlyZero()) { U64 region_handle = to_region_handle(pos_global); body["region_handle"] = ll_sd_from_U64(region_handle); } LLHTTPClient::post(url, body, new LLRemoteParcelRequestResponder(getObserverHandle())); } else { mDescEditor->setText(getString("server_update_text")); } mSnapshotCtrl->setImageAssetID(LLUUID::null); }
// static public // Insert a region in the region map // returns true if region inserted, false otherwise bool LLWorldMap::insertRegion(U32 x_world, U32 y_world, U32 x_size, U32 y_size, U32 agent_flags, std::string& name, LLUUID& image_id, U32 accesscode, U32 region_flags) { // This region doesn't exist if (accesscode == 255) { // Checks if the track point is in it and invalidates it if it is if (LLWorldMap::getInstance()->isTrackingInRectangle( x_world, y_world, x_world + REGION_WIDTH_UNITS, y_world + REGION_WIDTH_UNITS)) { LLWorldMap::getInstance()->setTrackingInvalid(); } // return failure to insert return false; } else { U64 handle = to_region_handle(x_world, y_world); //LL_INFOS("World Map") << "Map sim : " << name << ", ID : " << image_id.getString() << LL_ENDL; // Insert the region in the region map of the world map // Loading the LLSimInfo object with what we got and insert it in the map LLSimInfo* siminfo = LLWorldMap::getInstance()->simInfoFromHandle(handle); if (siminfo == NULL) { siminfo = LLWorldMap::getInstance()->createSimInfoFromHandle(handle); } siminfo->setName( name ); siminfo->setAccess( accesscode ); siminfo->setRegionFlags( region_flags ); //siminfo->setWaterHeight((F32) water_height); U32 layer = flagsToLayer(agent_flags); if (layer == SIM_LAYER_OVERLAY) siminfo->setLandForSaleImage(image_id); else if(layer < SIM_LAYER_COUNT) siminfo->setMapImageID( image_id, layer ); siminfo->setSize( x_size, y_size ); // Handle the location tracking (for teleport, UI feedback and info display) if (LLWorldMap::getInstance()->isTrackingInRectangle( x_world, y_world, x_world + REGION_WIDTH_UNITS, y_world + REGION_WIDTH_UNITS)) { if (siminfo->isDown()) { // We were tracking this location, but it's no available LLWorldMap::getInstance()->setTrackingInvalid(); } else { // We were tracking this location, and it does exist and is available LLWorldMap::getInstance()->setTrackingValid(); } } // return insert region success return true; } }
// For DEV-17507, do lazy image loading in llworldmapview.cpp instead, // limiting requests to currently visible regions and minimizing the // number of textures being requested simultaneously. // // Uncomment IMMEDIATE_IMAGE_LOAD to restore the old behavior // //#define IMMEDIATE_IMAGE_LOAD LLItemInfo::LLItemInfo(F32 global_x, F32 global_y, const std::string& name, LLUUID id, S32 extra, S32 extra2) : mName(name), mToolTip(""), mPosGlobal(global_x, global_y, 40.0), mID(id), mSelected(FALSE), mExtra(extra), mExtra2(extra2) { mRegionHandle = to_region_handle(mPosGlobal); }
void LLWorldMapMessage::handleSLURL(std::string& name, U32 x_world, U32 y_world, LLUUID image_id) { // Handle the SLURL callback if any url_callback_t callback = LLWorldMapMessage::getInstance()->mSLURLCallback; if(callback != NULL) { U64 handle = to_region_handle(x_world, y_world); // Check if we reached the requested region if ((LLStringUtil::compareInsensitive(LLWorldMapMessage::getInstance()->mSLURLRegionName, name)==0) || (LLWorldMapMessage::getInstance()->mSLURLRegionHandle == handle)) { LLWorldMapMessage::getInstance()->mSLURLCallback = NULL; LLWorldMapMessage::getInstance()->mSLURLRegionName.clear(); LLWorldMapMessage::getInstance()->mSLURLRegionHandle = 0; callback(handle, LLWorldMapMessage::getInstance()->mSLURL, image_id, LLWorldMapMessage::getInstance()->mSLURLTeleport); } } }
bool LLWorldMap::simNameFromPosGlobal(const LLVector3d& pos_global, std::string & outSimName ) { bool gotSimName = true; U64 handle = to_region_handle(pos_global); sim_info_map_t::iterator it = mSimInfoMap.find(handle); if (it != mSimInfoMap.end()) { LLSimInfo* info = (*it).second; outSimName = info->mName; } else { gotSimName = false; outSimName = "(unknown region)"; } return gotSimName; }
void LLLandmarkActions::getRegionNameAndCoordsFromPosGlobal(const LLVector3d& global_pos, region_name_and_coords_callback_t cb) { std::string sim_name; LLSimInfo* sim_infop = LLWorldMap::getInstance()->simInfoFromPosGlobal(global_pos); if (sim_infop) { LLVector3 pos = sim_infop->getLocalPos(global_pos); std::string name = sim_infop->getName() ; cb(name, llround(pos.mV[VX]), llround(pos.mV[VY]),llround(pos.mV[VZ])); } else { U64 new_region_handle = to_region_handle(global_pos); LLWorldMapMessage::url_callback_t url_cb = boost::bind(&LLLandmarkActions::onRegionResponseNameAndCoords, cb, global_pos, _1); LLWorldMapMessage::getInstance()->sendHandleRegionRequest(new_region_handle, url_cb, std::string("unused"), false); } }
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) { std::string slurl = LLSLURL(sim_name, global_pos).getSLURLString(); cb(slurl); return; } else { U64 new_region_handle = to_region_handle(global_pos); LLWorldMapMessage::url_callback_t url_cb = boost::bind(&LLLandmarkActions::onRegionResponseSLURL, cb, global_pos, escaped, _2); LLWorldMapMessage::getInstance()->sendHandleRegionRequest(new_region_handle, url_cb, std::string("unused"), false); } }
void LLLandmarksPanel::doCreatePick(LLLandmark* landmark) { LLViewerRegion* region = gAgent.getRegion(); if (!region) return; LLGlobalVec pos_global; LLUUID region_id; landmark->getGlobalPos(pos_global); landmark->getRegionID(region_id); LLVector3 region_pos((F32)fmod(pos_global.mdV[VX], (F64)REGION_WIDTH_METERS), (F32)fmod(pos_global.mdV[VY], (F64)REGION_WIDTH_METERS), (F32)pos_global.mdV[VZ]); LLSD body; std::string url = region->getCapability("RemoteParcelRequest"); if (!url.empty()) { body["location"] = ll_sd_from_vector3(region_pos); if (!region_id.isNull()) { body["region_id"] = region_id; } if (!pos_global.isExactlyZero()) { U64 region_handle = to_region_handle(pos_global); body["region_handle"] = ll_sd_from_U64(region_handle); } LLHTTPClient::post(url, body, new LLRemoteParcelRequestResponder(getObserverHandle())); } else { LL_WARNS() << "Can't create pick for landmark for region" << region_id << ". Region: " << region->getName() << " does not support RemoteParcelRequest" << LL_ENDL; } }
/*static*/ void LLURLDispatcherImpl::regionNameCallback(U64 region_handle, const std::string& url, const LLUUID& snapshot_id, bool teleport) { std::string sim_string = stripProtocol(url); std::string region_name; S32 x = 128; S32 y = 128; S32 z = 0; LLURLSimString::parse(sim_string, ®ion_name, &x, &y, &z); LLVector3 local_pos; local_pos.mV[VX] = (F32)x; local_pos.mV[VY] = (F32)y; local_pos.mV[VZ] = (F32)z; // determine whether the point is in this region if ((x >= 0) && (x < REGION_WIDTH_UNITS) && (y >= 0) && (y < REGION_WIDTH_UNITS)) { // if so, we're done regionHandleCallback(region_handle, url, snapshot_id, teleport); } else { // otherwise find the new region from the location // add the position to get the new region LLVector3d global_pos = from_region_handle(region_handle) + LLVector3d(local_pos); U64 new_region_handle = to_region_handle(global_pos); LLWorldMap::getInstance()->sendHandleRegionRequest(new_region_handle, LLURLDispatcherImpl::regionHandleCallback, url, teleport); } }
// public static void LLWorldMapMessage::processMapBlockReply(LLMessageSystem* msg, void**) { U32 agent_flags; msg->getU32Fast(_PREHASH_AgentData, _PREHASH_Flags, agent_flags); U32 layer = flagsToLayer(agent_flags); if (layer >= SIM_LAYER_COUNT) { llwarns << "Invalid map image type returned! layer = " << agent_flags << llendl; return; } S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_Data); //LL_INFOS("World Map") << "LLWorldMap::processMapBlockReply(), num_blocks = " << num_blocks << LL_ENDL; bool found_null_sim = false; for (S32 block=0; block<num_blocks; ++block) { U16 x_regions; U16 y_regions; U16 x_size = 256; U16 y_size = 256; std::string name; U8 accesscode; U32 region_flags; // U8 water_height; // U8 agents; LLUUID image_id; msg->getU16Fast(_PREHASH_Data, _PREHASH_X, x_regions, block); msg->getU16Fast(_PREHASH_Data, _PREHASH_Y, y_regions, block); msg->getStringFast(_PREHASH_Data, _PREHASH_Name, name, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_Access, accesscode, block); msg->getU32Fast(_PREHASH_Data, _PREHASH_RegionFlags, region_flags, block); // msg->getU8Fast(_PREHASH_Data, _PREHASH_WaterHeight, water_height, block); // msg->getU8Fast(_PREHASH_Data, _PREHASH_Agents, agents, block); msg->getUUIDFast(_PREHASH_Data, _PREHASH_MapImageID, image_id, block); if(msg->getNumberOfBlocksFast(_PREHASH_Size) > 0) { msg->getU16Fast(_PREHASH_Size, _PREHASH_SizeX, x_size, block); msg->getU16Fast(_PREHASH_Size, _PREHASH_SizeY, y_size, block); } if(x_size == 0 || (x_size % 16) != 0|| (y_size % 16) != 0) { x_size = 256; y_size = 256; } U32 x_world = (U32)(x_regions) * REGION_WIDTH_UNITS; U32 y_world = (U32)(y_regions) * REGION_WIDTH_UNITS; // name shouldn't be empty, see EXT-4568 //llassert(!name.empty()); //Opensim bug. BlockRequest can return sims without names, with an accesscode that isn't 255. // skip if this has happened. if(name.empty() && accesscode != 255) continue; // Insert that region in the world map, if failure, flag it as a "null_sim" if (!(LLWorldMap::getInstance()->insertRegion(x_world, y_world, x_size, y_size, agent_flags, name, image_id, (U32)accesscode, region_flags))) { found_null_sim = true; } // If we hit a valid tracking location, do what needs to be done app level wise if (LLWorldMap::getInstance()->isTrackingValidLocation()) { LLVector3d pos_global = LLWorldMap::getInstance()->getTrackedPositionGlobal(); if (LLWorldMap::getInstance()->isTrackingDoubleClick()) { // Teleport if the user double clicked gAgent.teleportViaLocation(pos_global); } // Update the "real" tracker information gFloaterWorldMap->trackLocation(pos_global); } U64 handle = to_region_handle(x_world, y_world); // Handle the SLURL callback if any url_callback_t callback = LLWorldMapMessage::getInstance()->mSLURLCallback; if(callback != NULL) { // Check if we reached the requested region if ((LLStringUtil::compareInsensitive(LLWorldMapMessage::getInstance()->mSLURLRegionName, name)==0) || (LLWorldMapMessage::getInstance()->mSLURLRegionHandle == handle)) { LLWorldMapMessage::getInstance()->mSLURLCallback = NULL; LLWorldMapMessage::getInstance()->mSLURLRegionName.clear(); LLWorldMapMessage::getInstance()->mSLURLRegionHandle = 0; callback(handle, LLWorldMapMessage::getInstance()->mSLURL, image_id, LLWorldMapMessage::getInstance()->mSLURLTeleport); } } if( gAgent.mPendingLure && gAgent.mPendingLure->mRegionHandle == handle) { gAgent.onFoundLureDestination(); } } // Tell the UI to update itself gFloaterWorldMap->updateSims(found_null_sim); }
// static public // Insert an item in the relevant region map // returns true if item inserted, false otherwise bool LLWorldMap::insertItem(U32 x_world, U32 y_world, std::string& name, LLUUID& uuid, U32 type, S32 extra, S32 extra2) { // Create an item record for the received object LLItemInfo new_item((F32)x_world, (F32)y_world, name, uuid); // Compute a region handle based on the objects coordinates LLVector3d pos((F32)x_world, (F32)y_world, 40.0); U64 handle = to_region_handle(pos); // Get the region record for that handle or NULL if we haven't browsed it yet LLSimInfo* siminfo = LLWorldMap::getInstance()->simInfoFromHandle(handle); if (siminfo == NULL) { siminfo = LLWorldMap::getInstance()->createSimInfoFromHandle(handle); } //LL_INFOS("World Map") << "Process item : type = " << type << LL_ENDL; switch (type) { case MAP_ITEM_TELEHUB: // telehubs { /* Merov: we are not using the hub color anymore for display so commenting that out // Telehub color U32 X = x_world / REGION_WIDTH_UNITS; U32 Y = y_world / REGION_WIDTH_UNITS; F32 red = fmod((F32)X * 0.11f, 1.f) * 0.8f; F32 green = fmod((F32)Y * 0.11f, 1.f) * 0.8f; F32 blue = fmod(1.5f * (F32)(X + Y) * 0.11f, 1.f) * 0.8f; F32 add_amt = (X % 2) ? 0.15f : -0.15f; add_amt += (Y % 2) ? -0.15f : 0.15f; LLColor4 color(red + add_amt, green + add_amt, blue + add_amt); new_item.setColor(color); */ // extra2 specifies whether this is an infohub or a telehub. if (extra2) { siminfo->insertInfoHub(new_item); } else { siminfo->insertTeleHub(new_item); } break; } case MAP_ITEM_PG_EVENT: // events case MAP_ITEM_MATURE_EVENT: case MAP_ITEM_ADULT_EVENT: { struct tm* timep; // Convert to Pacific, based on server's opinion of whether // it's daylight savings time there. timep = utc_to_pacific_time(extra, gPacificDaylightTime); S32 display_hour = timep->tm_hour % 12; if (display_hour == 0) display_hour = 12; std::string tooltip = llformat( "%d:%02d %s", display_hour, timep->tm_min, (timep->tm_hour < 12 ? "AM" : "PM") ); new_item.setTooltip(tooltip); // HACK: store Z in extra2 new_item.setElevation((F64)extra2); if (type == MAP_ITEM_PG_EVENT) { siminfo->insertPGEvent(new_item); } else if (type == MAP_ITEM_MATURE_EVENT) { siminfo->insertMatureEvent(new_item); } else if (type == MAP_ITEM_ADULT_EVENT) { siminfo->insertAdultEvent(new_item); } break; } case MAP_ITEM_LAND_FOR_SALE: // land for sale case MAP_ITEM_LAND_FOR_SALE_ADULT: // adult land for sale { F32 cost_per_sqm = 0.0f; if (extra > 0) { cost_per_sqm = (F32)extra2 / (F32)extra; } std::string tooltip = llformat("%d sq.m. L$%d (L$ %.1f/sq.m.)", extra, extra2, cost_per_sqm); new_item.setTooltip(tooltip); if (type == MAP_ITEM_LAND_FOR_SALE) { siminfo->insertLandForSale(new_item); } else if (type == MAP_ITEM_LAND_FOR_SALE_ADULT) { siminfo->insertLandForSaleAdult(new_item); } break; } case MAP_ITEM_CLASSIFIED: // classifieds { //DEPRECATED: no longer used break; } case MAP_ITEM_AGENT_LOCATIONS: // agent locations { // LL_INFOS("World Map") << "New Location " << new_item.mName << LL_ENDL; if (extra > 0) { new_item.setCount(extra); siminfo->insertAgentLocation(new_item); } break; } default: break; } return true; }
LLSimInfo* LLWorldMap::simInfoFromPosGlobal(const LLVector3d& pos_global) { U64 handle = to_region_handle(pos_global); return simInfoFromHandle(handle); }
LLViewerRegion* LLWorld::addRegion(const U64 ®ion_handle, const LLHost &host) { LLMemType mt(LLMemType::MTYPE_REGIONS); llinfos << "Add region with handle: " << region_handle << " on host " << host << llendl; LLViewerRegion *regionp = getRegionFromHandle(region_handle); if (regionp) { llinfos << "Region exists, removing it " << llendl; LLHost old_host = regionp->getHost(); // region already exists! if (host == old_host && regionp->isAlive()) { // This is a duplicate for the same host and it's alive, don't bother. return regionp; } if (host != old_host) { llwarns << "LLWorld::addRegion exists, but old host " << old_host << " does not match new host " << host << llendl; } if (!regionp->isAlive()) { llwarns << "LLWorld::addRegion exists, but isn't alive" << llendl; } // Kill the old host, and then we can continue on and add the new host. We have to kill even if the host // matches, because all the agent state for the new camera is completely different. removeRegion(old_host); } U32 iindex = 0; U32 jindex = 0; from_region_handle(region_handle, &iindex, &jindex); S32 x = (S32)(iindex/mWidth); S32 y = (S32)(jindex/mWidth); llinfos << "Adding new region (" << x << ":" << y << ")" << llendl; llinfos << "Host: " << host << llendl; LLVector3d origin_global; origin_global = from_region_handle(region_handle); regionp = new LLViewerRegion(region_handle, host, mWidth, WORLD_PATCH_SIZE, getRegionWidthInMeters() ); if (!regionp) { llerrs << "Unable to create new region!" << llendl; } regionp->mCloudLayer.create(regionp); regionp->mCloudLayer.setWidth((F32)mWidth); regionp->mCloudLayer.setWindPointer(®ionp->mWind); mRegionList.push_back(regionp); mActiveRegionList.push_back(regionp); mCulledRegionList.push_back(regionp); // Find all the adjacent regions, and attach them. // Generate handles for all of the adjacent regions, and attach them in the correct way. // connect the edges F32 adj_x = 0.f; F32 adj_y = 0.f; F32 region_x = 0.f; F32 region_y = 0.f; U64 adj_handle = 0; F32 width = getRegionWidthInMeters(); LLViewerRegion *neighborp; from_region_handle(region_handle, ®ion_x, ®ion_y); // Iterate through all directions, and connect neighbors if there. S32 dir; for (dir = 0; dir < 8; dir++) { adj_x = region_x + width * gDirAxes[dir][0]; adj_y = region_y + width * gDirAxes[dir][1]; to_region_handle(adj_x, adj_y, &adj_handle); neighborp = getRegionFromHandle(adj_handle); if (neighborp) { //llinfos << "Connecting " << region_x << ":" << region_y << " -> " << adj_x << ":" << adj_y << llendl; regionp->connectNeighbor(neighborp, dir); } } updateWaterObjects(); return regionp; }
LLViewerRegion* LLWorld::addRegion(const U64 ®ion_handle, const LLHost &host) { llinfos << "Add region with handle: " << region_handle << " on host " << host << llendl; LLViewerRegion *regionp = getRegionFromHandle(region_handle); if (regionp) { llinfos << "Region exists, removing it " << llendl; LLHost old_host = regionp->getHost(); // region already exists! if (host == old_host && regionp->isAlive()) { // This is a duplicate for the same host and it's alive, don't bother. return regionp; } if (host != old_host) { llwarns << "LLWorld::addRegion exists, but old host " << old_host << " does not match new host " << host << llendl; } if (!regionp->isAlive()) { llwarns << "LLWorld::addRegion exists, but isn't alive" << llendl; } // Kill the old host, and then we can continue on and add the new host. We have to kill even if the host // matches, because all the agent state for the new camera is completely different. removeRegion(old_host); } U32 iindex = 0; U32 jindex = 0; from_region_handle(region_handle, &iindex, &jindex); // <FS:CR> Aurora Sim //S32 x = (S32)(iindex/mWidth); //S32 y = (S32)(jindex/mWidth); S32 x = (S32)(iindex/256); //MegaRegion S32 y = (S32)(jindex/256); //MegaRegion // </FS:CR> Aurora Sim llinfos << "Adding new region (" << x << ":" << y << ")" << llendl; llinfos << "Host: " << host << llendl; LLVector3d origin_global; origin_global = from_region_handle(region_handle); regionp = new LLViewerRegion(region_handle, host, mWidth, WORLD_PATCH_SIZE, getRegionWidthInMeters() ); if (!regionp) { llerrs << "Unable to create new region!" << llendl; } //Classic clouds #if ENABLE_CLASSIC_CLOUDS regionp->mCloudLayer.create(regionp); regionp->mCloudLayer.setWidth((F32)mWidth); regionp->mCloudLayer.setWindPointer(®ionp->mWind); #endif mRegionList.push_back(regionp); mActiveRegionList.push_back(regionp); mCulledRegionList.push_back(regionp); // Find all the adjacent regions, and attach them. // Generate handles for all of the adjacent regions, and attach them in the correct way. // connect the edges F32 adj_x = 0.f; F32 adj_y = 0.f; F32 region_x = 0.f; F32 region_y = 0.f; U64 adj_handle = 0; F32 width = getRegionWidthInMeters(); LLViewerRegion *neighborp; from_region_handle(region_handle, ®ion_x, ®ion_y); // Iterate through all directions, and connect neighbors if there. S32 dir; for (dir = 0; dir < 8; dir++) { adj_x = region_x + width * gDirAxes[dir][0]; adj_y = region_y + width * gDirAxes[dir][1]; if (mWidth == 256 && mLength == 256) { to_region_handle(adj_x, adj_y, &adj_handle); neighborp = getRegionFromHandle(adj_handle); if (neighborp) { //llinfos << "Connecting " << region_x << ":" << region_y << " -> " << adj_x << ":" << adj_y << llendl; regionp->connectNeighbor(neighborp, dir); } } else // Unconventional region size { LLViewerRegion* last_neighborp = NULL; if(gDirAxes[dir][0] < 0) adj_x = region_x - WORLD_PATCH_SIZE; if(gDirAxes[dir][1] < 0) adj_y = region_y - WORLD_PATCH_SIZE; for (S32 offset = 0; offset < width; offset += WORLD_PATCH_SIZE) { to_region_handle(adj_x, adj_y, &adj_handle); neighborp = getRegionFromHandle(adj_handle); if (neighborp && last_neighborp != neighborp) { //llinfos << "Connecting " << region_x << ":" << region_y << " -> " << adj_x << ":" << adj_y << llendl; regionp->connectNeighbor(neighborp, dir); last_neighborp = neighborp; } if (dir == NORTH || dir == SOUTH) adj_x += WORLD_PATCH_SIZE; else if (dir == EAST || dir == WEST) adj_y += WORLD_PATCH_SIZE; else if (dir == NORTHEAST || dir == NORTHWEST || dir == SOUTHWEST || dir == SOUTHEAST) break; } } } updateWaterObjects(); return regionp; }
// public static void LLWorldMap::processMapBlockReply(LLMessageSystem* msg, void**) { U32 agent_flags; msg->getU32Fast(_PREHASH_AgentData, _PREHASH_Flags, agent_flags); if ((S32)agent_flags < 0 || agent_flags >= MAP_SIM_IMAGE_TYPES) { llwarns << "Invalid map image type returned! " << agent_flags << llendl; return; } S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_Data); bool found_null_sim = false; #ifdef IMMEDIATE_IMAGE_LOAD bool use_web_map_tiles = useWebMapTiles(); #endif BOOL adjust = FALSE; for (S32 block=0; block<num_blocks; ++block) { U16 x_regions; U16 y_regions; std::string name; U8 accesscode; U32 region_flags; U8 water_height; U8 agents; LLUUID image_id; msg->getU16Fast(_PREHASH_Data, _PREHASH_X, x_regions, block); msg->getU16Fast(_PREHASH_Data, _PREHASH_Y, y_regions, block); msg->getStringFast(_PREHASH_Data, _PREHASH_Name, name, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_Access, accesscode, block); msg->getU32Fast(_PREHASH_Data, _PREHASH_RegionFlags, region_flags, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_WaterHeight, water_height, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_Agents, agents, block); msg->getUUIDFast(_PREHASH_Data, _PREHASH_MapImageID, image_id, block); U32 x_meters = x_regions * REGION_WIDTH_UNITS; U32 y_meters = y_regions * REGION_WIDTH_UNITS; U64 handle = to_region_handle(x_meters, y_meters); if (accesscode == 255) { // This region doesn't exist if (LLWorldMap::getInstance()->mIsTrackingUnknownLocation && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] >= x_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] < x_meters + 256 && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] >= y_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] < y_meters + 256) { // We were tracking this location, but it doesn't exist LLWorldMap::getInstance()->mInvalidLocation = TRUE; } found_null_sim = true; } else { adjust = LLWorldMap::getInstance()->extendAABB(x_meters, y_meters, x_meters+REGION_WIDTH_UNITS, y_meters+REGION_WIDTH_UNITS) || adjust; // llinfos << "Map sim " << name << " image layer " << agent_flags << " ID " << image_id.getString() << llendl; LLSimInfo* siminfo = new LLSimInfo(); sim_info_map_t::iterator iter = LLWorldMap::getInstance()->mSimInfoMap.find(handle); if (iter != LLWorldMap::getInstance()->mSimInfoMap.end()) { LLSimInfo* oldinfo = iter->second; for (S32 image=0; image<MAP_SIM_IMAGE_TYPES; ++image) { siminfo->mMapImageID[image] = oldinfo->mMapImageID[image]; } delete oldinfo; } LLWorldMap::getInstance()->mSimInfoMap[handle] = siminfo; siminfo->mHandle = handle; siminfo->msizeX = 256; siminfo->msizeY = 256; siminfo->mName.assign( name ); siminfo->mAccess = accesscode; siminfo->mRegionFlags = region_flags; siminfo->mWaterHeight = (F32) water_height; siminfo->mMapImageID[agent_flags] = image_id; #ifdef IMMEDIATE_IMAGE_LOAD if (use_web_map_tiles) { siminfo->mCurrentImage = loadObjectsTile((U32)x_regions, (U32)y_regions); } else { siminfo->mCurrentImage = gImageList.getImage(siminfo->mMapImageID[LLWorldMap::getInstance()->mCurrentMap], MIPMAP_TRUE, FALSE); } gGL.getTexUnit(0)->bind(siminfo->mCurrentImage.get()); siminfo->mCurrentImage->setAddressMode(LLTexUnit::TAM_CLAMP); #endif if (siminfo->mMapImageID[2].notNull()) { #ifdef IMMEDIATE_IMAGE_LOAD siminfo->mOverlayImage = gImageList.getImage(siminfo->mMapImageID[2], MIPMAP_TRUE, FALSE); #endif } else { siminfo->mOverlayImage = NULL; } if (LLWorldMap::getInstance()->mIsTrackingUnknownLocation && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] >= x_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] < x_meters + 256 && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] >= y_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] < y_meters + 256) { if (siminfo->mAccess == SIM_ACCESS_DOWN) { // We were tracking this location, but it doesn't exist LLWorldMap::getInstance()->mInvalidLocation = true; } else { // We were tracking this location, and it does exist bool is_tracking_dbl = LLWorldMap::getInstance()->mIsTrackingDoubleClick == TRUE; gFloaterWorldMap->trackLocation(LLWorldMap::getInstance()->mUnknownLocation); if (is_tracking_dbl) { LLVector3d pos_global = LLTracker::getTrackedPositionGlobal(); gAgent.teleportViaLocation( pos_global ); } } } } if(LLWorldMap::getInstance()->mSLURLCallback != NULL) { // Server returns definitive capitalization, SLURL might not have that. if ((LLStringUtil::compareInsensitive(LLWorldMap::getInstance()->mSLURLRegionName, name)==0) || (LLWorldMap::getInstance()->mSLURLRegionHandle == handle)) { url_callback_t callback = LLWorldMap::getInstance()->mSLURLCallback; LLWorldMap::getInstance()->mSLURLCallback = NULL; LLWorldMap::getInstance()->mSLURLRegionName.clear(); LLWorldMap::getInstance()->mSLURLRegionHandle = 0; callback(handle, LLWorldMap::getInstance()->mSLURL, image_id, LLWorldMap::getInstance()->mSLURLTeleport); } } if(gAgent.mLureShow) { if((x_regions == gAgent.mLureGlobalX) && (y_regions == gAgent.mLureGlobalY)) { gAgent.onFoundLureDestination(); } } } if(adjust) gFloaterWorldMap->adjustZoomSliderBounds(); gFloaterWorldMap->updateSims(found_null_sim); }
// There are three types of water objects: // Region water objects: the water in a region. // Hole water objects: water in the void but within current draw distance. // Edge water objects: the water outside the draw distance, up till the horizon. // // For example: // // -----------------------horizon------------------------- // | | | | // | Edge Water | | | // | | | | // | | | | // | | | | // | | | | // | | rwidth | | // | | <-----> | | // ------------------------------------------------------- // | |Hole |other| | | // | |Water|reg. | | | // | |-----------------| | // | |other|cur. |<--> | | // | |reg. | reg.| \__|_ draw distance | // | |-----------------| | // | | | |<--->| | // | | | | \__|_ range | // ------------------------------------------------------- // | |<----width------>|<--horizon ext.->| // | | | | // | | | | // | | | | // | | | | // | | | | // | | | | // | | | | // ------------------------------------------------------- // void LLWorld::updateWaterObjects() { if (!gAgent.getRegion()) { return; } if (mRegionList.empty()) { llwarns << "No regions!" << llendl; return; } LLViewerRegion const* regionp = gAgent.getRegion(); // Region width in meters. S32 const rwidth = (S32)regionp->getWidth(); // The distance we might see into the void // when standing on the edge of a region, in meters. S32 const draw_distance = llceil(mLandFarClip); // We can only have "holes" in the water (where there no region) if we // can have existing regions around it. Taking into account that this // code is only executed when we enter a region, and not when we walk // around in it, we (only) need to take into account regions that fall // within the draw_distance. // // Set 'range' to draw_distance, rounded up to the nearest multiple of rwidth. S32 const nsims = (draw_distance + rwidth - 1) / rwidth; S32 const range = nsims * rwidth; // Get South-West corner of current region. U32 region_x, region_y; from_region_handle(regionp->getHandle(), ®ion_x, ®ion_y); // The min. and max. coordinates of the South-West corners of the Hole water objects. S32 const min_x = (S32)region_x - range; S32 const min_y = (S32)region_y - range; S32 const max_x = (S32)region_x + rwidth-256 + range; S32 const max_y = (S32)region_y + rwidth-256 + range; // Attempt to determine a sensible water height for all the // Hole Water objects. // // It make little sense to try to guess what the best water // height should be when that isn't completely obvious: if it's // impossible to satisfy every region's water height without // getting a jump in the water height. // // In order to keep the reasoning simple, we assume something // logical as a group of connected regions, where the coastline // is at the outer edge. Anything more complex that would "break" // under such an assumption would probably break anyway (would // depend on terrain editing and existing mega prims, say, if // anything would make sense at all). // // So, what we do is find all connected regions within the // draw distance that border void, and then pick the lowest // water height of those (coast) regions. S32 const n = 2 * nsims + 1; S32 const origin = nsims + nsims * n; std::vector<F32> water_heights(n * n); std::vector<U8> checked(n * n, 0); // index = nx + ny * n + origin; U8 const region_bit = 1; U8 const hole_bit = 2; U8 const bordering_hole_bit = 4; U8 const bordering_edge_bit = 8; // Use the legacy waterheight for the Edge water in the case // that we don't find any Hole water at all. F32 water_height = DEFAULT_WATER_HEIGHT; int max_count = 0; LL_DEBUGS("WaterHeight") << "Current region: " << regionp->getName() << "; water height: " << regionp->getWaterHeight() << " m." << LL_ENDL; std::map<S32, int> water_height_counts; typedef std::queue<std::pair<S32, S32>, std::deque<std::pair<S32, S32> > > nxny_pairs_type; nxny_pairs_type nxny_pairs; nxny_pairs.push(nxny_pairs_type::value_type(0, 0)); water_heights[origin] = regionp->getWaterHeight(); checked[origin] = region_bit; // For debugging purposes. int number_of_connected_regions = 1; int uninitialized_regions = 0; int bordering_hole = 0; int bordering_edge = 0; while(!nxny_pairs.empty()) { S32 const nx = nxny_pairs.front().first; S32 const ny = nxny_pairs.front().second; LL_DEBUGS("WaterHeight") << "nx,ny = " << nx << "," << ny << LL_ENDL; S32 const index = nx + ny * n + origin; nxny_pairs.pop(); for (S32 dir = 0; dir < 4; ++dir) { S32 const cnx = nx + gDirAxes[dir][0]; S32 const cny = ny + gDirAxes[dir][1]; LL_DEBUGS("WaterHeight") << "dir = " << dir << "; cnx,cny = " << cnx << "," << cny << LL_ENDL; S32 const cindex = cnx + cny * n + origin; bool is_hole = false; bool is_edge = false; LLViewerRegion* new_region_found = NULL; if (cnx < -nsims || cnx > nsims || cny < -nsims || cny > nsims) { LL_DEBUGS("WaterHeight") << " Edge Water!" << LL_ENDL; // Bumped into Edge water object. is_edge = true; } else if (checked[cindex]) { LL_DEBUGS("WaterHeight") << " Already checked before!" << LL_ENDL; // Already checked. is_hole = (checked[cindex] & hole_bit); } else { S32 x = (S32)region_x + cnx * rwidth; S32 y = (S32)region_y + cny * rwidth; U64 region_handle = to_region_handle(x, y); new_region_found = getRegionFromHandle(region_handle); is_hole = !new_region_found; checked[cindex] = is_hole ? hole_bit : region_bit; } if (is_hole) { // This was a region that borders at least one 'hole'. // Count the found coastline. F32 new_water_height = water_heights[index]; LL_DEBUGS("WaterHeight") << " This is void; counting coastline with water height of " << new_water_height << LL_ENDL; S32 new_water_height_cm = llround(new_water_height * 100); int count = (water_height_counts[new_water_height_cm] += 1); // Just use the lowest water height: this is mainly about the horizon water, // and whatever we do, we don't want it to be possible to look under the water // when looking in the distance: it is better to make a step downwards in water // height when going away from the avie than a step upwards. However, since // everyone is used to DEFAULT_WATER_HEIGHT, don't allow a single region // to drag the water level below DEFAULT_WATER_HEIGHT on it's own. if (bordering_hole == 0 || // First time we get here. (new_water_height >= DEFAULT_WATER_HEIGHT && new_water_height < water_height) || (new_water_height < DEFAULT_WATER_HEIGHT && count > max_count) ) { water_height = new_water_height; } if (count > max_count) { max_count = count; } if (!(checked[index] & bordering_hole_bit)) { checked[index] |= bordering_hole_bit; ++bordering_hole; } } else if (is_edge && !(checked[index] & bordering_edge_bit)) { checked[index] |= bordering_edge_bit; ++bordering_edge; } if (!new_region_found) { // Dead end, there is no region here. continue; } // Found a new connected region. ++number_of_connected_regions; if (new_region_found->getName().empty()) { // Uninitialized LLViewerRegion, don't use it's water height. LL_DEBUGS("WaterHeight") << " Uninitialized region." << LL_ENDL; ++uninitialized_regions; continue; } nxny_pairs.push(nxny_pairs_type::value_type(cnx, cny)); water_heights[cindex] = new_region_found->getWaterHeight(); LL_DEBUGS("WaterHeight") << " Found a new region (name: " << new_region_found->getName() << "; water height: " << water_heights[cindex] << " m)!" << LL_ENDL; } } llinfos << "Number of connected regions: " << number_of_connected_regions << " (" << uninitialized_regions << " uninitialized); number of regions bordering Hole water: " << bordering_hole << "; number of regions bordering Edge water: " << bordering_edge << llendl; llinfos << "Coastline count (height, count): "; bool first = true; for (std::map<S32, int>::iterator iter = water_height_counts.begin(); iter != water_height_counts.end(); ++iter) { if (!first) llcont << ", "; llcont << "(" << (iter->first / 100.f) << ", " << iter->second << ")"; first = false; } llcont << llendl; llinfos << "Water height used for Hole and Edge water objects: " << water_height << llendl; // Update all Region water objects. for (region_list_t::iterator iter = mRegionList.begin(); iter != mRegionList.end(); ++iter) { LLViewerRegion* regionp = *iter; LLVOWater* waterp = regionp->getLand().getWaterObj(); if (waterp) { gObjectList.updateActive(waterp); } } // Clean up all existing Hole water objects. for (std::list<LLVOWater*>::iterator iter = mHoleWaterObjects.begin(); iter != mHoleWaterObjects.end(); ++iter) { LLVOWater* waterp = *iter; gObjectList.killObject(waterp); } mHoleWaterObjects.clear(); // Let the Edge and Hole water boxes be 1024 meter high so that they // are never too small to be drawn (A LL_VO_*_WATER box has water // rendered on it's bottom surface only), and put their bottom at // the current regions water height. F32 const box_height = 1024; F32 const water_center_z = water_height + box_height / 2; const S32 step = 256; // Create new Hole water objects within 'range' where there is no region. for (S32 x = min_x; x <= max_x; x += step) { for (S32 y = min_y; y <= max_y; y += step) { U64 region_handle = to_region_handle(x, y); if (!getRegionFromHandle(region_handle)) { LLVOWater* waterp = (LLVOWater*)gObjectList.createObjectViewer(LLViewerObject::LL_VO_VOID_WATER, gAgent.getRegion()); waterp->setUseTexture(FALSE); waterp->setPositionGlobal(LLVector3d(x + step / 2, y + step / 2, water_center_z)); waterp->setScale(LLVector3((F32)step, (F32)step, box_height)); gPipeline.createObject(waterp); mHoleWaterObjects.push_back(waterp); } } } // Center of the region. S32 const center_x = region_x + step / 2; S32 const center_y = region_y + step / 2; // Width of the area with Hole water objects. S32 const width = step + 2 * range; S32 const horizon_extend = 2048 + 512 - range; // Legacy value. // The overlap is needed to get rid of sky pixels being visible between the // Edge and Hole water object at greater distances (due to floating point // round off errors). S32 const edge_hole_overlap = 1; // Twice the actual overlap. for (S32 dir = 0; dir < 8; ++dir) { // Size of the Edge water objects. S32 const dim_x = (gDirAxes[dir][0] == 0) ? width : (horizon_extend + edge_hole_overlap); S32 const dim_y = (gDirAxes[dir][1] == 0) ? width : (horizon_extend + edge_hole_overlap); // And their position. S32 const water_center_x = center_x + (width + horizon_extend) / 2 * gDirAxes[dir][0]; S32 const water_center_y = center_y + (width + horizon_extend) / 2 * gDirAxes[dir][1]; LLVOWater* waterp = mEdgeWaterObjects[dir]; if (!waterp || waterp->isDead()) { // The edge water objects can be dead because they're attached to the region that the // agent was in when they were originally created. mEdgeWaterObjects[dir] = (LLVOWater *)gObjectList.createObjectViewer(LLViewerObject::LL_VO_VOID_WATER, gAgent.getRegion()); waterp = mEdgeWaterObjects[dir]; waterp->setUseTexture(FALSE); waterp->setIsEdgePatch(TRUE); // Mark that this is edge water and not hole water. gPipeline.createObject(waterp); } waterp->setRegion(gAgent.getRegion()); LLVector3d water_pos(water_center_x, water_center_y, water_center_z); LLVector3 water_scale((F32) dim_x, (F32) dim_y, box_height); waterp->setPositionGlobal(water_pos); waterp->setScale(water_scale); gObjectList.updateActive(waterp); } }
// static public // Insert an item in the relevant region map // returns true if item inserted, false otherwise bool LLWorldMap::insertItem(U32 x_world, U32 y_world, std::string& name, LLUUID& uuid, U32 type, S32 extra, S32 extra2) { // Create an item record for the received object LLItemInfo new_item((F32)x_world, (F32)y_world, name, uuid); // Compute a region handle based on the objects coordinates LLVector3d pos((F32)x_world, (F32)y_world, 40.0); U64 handle = to_region_handle(pos); // Get the region record for that handle or NULL if we haven't browsed it yet LLSimInfo* siminfo = LLWorldMap::getInstance()->simInfoFromHandle(handle); if (siminfo == NULL) { siminfo = LLWorldMap::getInstance()->createSimInfoFromHandle(handle); } //LL_INFOS("World Map") << "Process item : type = " << type << LL_ENDL; switch (type) { case MAP_ITEM_TELEHUB: // telehubs { /* Merov: we are not using the hub color anymore for display so commenting that out // Telehub color U32 X = x_world / REGION_WIDTH_UNITS; U32 Y = y_world / REGION_WIDTH_UNITS; F32 red = fmod((F32)X * 0.11f, 1.f) * 0.8f; F32 green = fmod((F32)Y * 0.11f, 1.f) * 0.8f; F32 blue = fmod(1.5f * (F32)(X + Y) * 0.11f, 1.f) * 0.8f; F32 add_amt = (X % 2) ? 0.15f : -0.15f; add_amt += (Y % 2) ? -0.15f : 0.15f; LLColor4 color(red + add_amt, green + add_amt, blue + add_amt); new_item.setColor(color); */ // extra2 specifies whether this is an infohub or a telehub. if (extra2) { siminfo->insertInfoHub(new_item); } else { siminfo->insertTeleHub(new_item); } break; } case MAP_ITEM_PG_EVENT: // events case MAP_ITEM_MATURE_EVENT: case MAP_ITEM_ADULT_EVENT: { std::string timeStr = "["+ LLTrans::getString ("TimeHour")+"]:[" +LLTrans::getString ("TimeMin")+"] [" +LLTrans::getString ("TimeAMPM")+"]"; LLSD substitution; substitution["datetime"] = (S32) extra; LLStringUtil::format (timeStr, substitution); new_item.setTooltip(timeStr); // HACK: store Z in extra2 new_item.setElevation((F64)extra2); if (type == MAP_ITEM_PG_EVENT) { siminfo->insertPGEvent(new_item); } else if (type == MAP_ITEM_MATURE_EVENT) { siminfo->insertMatureEvent(new_item); } else if (type == MAP_ITEM_ADULT_EVENT) { siminfo->insertAdultEvent(new_item); } break; } case MAP_ITEM_LAND_FOR_SALE: // land for sale case MAP_ITEM_LAND_FOR_SALE_ADULT: // adult land for sale { static LLUIString tooltip_fmt = LLTrans::getString("worldmap_item_tooltip_format"); std::string type_currency = LLGridManager::getInstance()->getCurrency(); tooltip_fmt.setArg("[AREA]", llformat("%d", extra)); tooltip_fmt.setArg("[PRICE]", llformat("%d", extra2)); tooltip_fmt.setArg("[CUR]", type_currency); new_item.setTooltip(tooltip_fmt.getString()); if (type == MAP_ITEM_LAND_FOR_SALE) { siminfo->insertLandForSale(new_item); } else if (type == MAP_ITEM_LAND_FOR_SALE_ADULT) { siminfo->insertLandForSaleAdult(new_item); } break; } case MAP_ITEM_CLASSIFIED: // classifieds { //DEPRECATED: no longer used break; } case MAP_ITEM_AGENT_LOCATIONS: // agent locations { // LL_INFOS("World Map") << "New Location " << new_item.mName << LL_ENDL; if (extra > 0) { new_item.setCount(extra); siminfo->insertAgentLocation(new_item); } break; } default: break; } return true; }
// public static void LLWorldMapMessage::processMapBlockReply(LLMessageSystem* msg, void**) { U32 agent_flags; msg->getU32Fast(_PREHASH_AgentData, _PREHASH_Flags, agent_flags); // There's only one flag that we ever use here if (agent_flags != LAYER_FLAG) { llwarns << "Invalid map image type returned! layer = " << agent_flags << llendl; return; } S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_Data); //LL_INFOS("World Map") << "LLWorldMap::processMapBlockReply(), num_blocks = " << num_blocks << LL_ENDL; bool found_null_sim = false; for (S32 block=0; block<num_blocks; ++block) { U16 x_regions; U16 y_regions; std::string name; U8 accesscode; U32 region_flags; // U8 water_height; // U8 agents; LLUUID image_id; msg->getU16Fast(_PREHASH_Data, _PREHASH_X, x_regions, block); msg->getU16Fast(_PREHASH_Data, _PREHASH_Y, y_regions, block); msg->getStringFast(_PREHASH_Data, _PREHASH_Name, name, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_Access, accesscode, block); msg->getU32Fast(_PREHASH_Data, _PREHASH_RegionFlags, region_flags, block); // msg->getU8Fast(_PREHASH_Data, _PREHASH_WaterHeight, water_height, block); // msg->getU8Fast(_PREHASH_Data, _PREHASH_Agents, agents, block); msg->getUUIDFast(_PREHASH_Data, _PREHASH_MapImageID, image_id, block); U32 x_world = (U32)(x_regions) * REGION_WIDTH_UNITS; U32 y_world = (U32)(y_regions) * REGION_WIDTH_UNITS; // Insert that region in the world map, if failure, flag it as a "null_sim" if (!(LLWorldMap::getInstance()->insertRegion(x_world, y_world, name, image_id, (U32)accesscode, region_flags))) { found_null_sim = true; } // If we hit a valid tracking location, do what needs to be done app level wise if (LLWorldMap::getInstance()->isTrackingValidLocation()) { LLVector3d pos_global = LLWorldMap::getInstance()->getTrackedPositionGlobal(); if (LLWorldMap::getInstance()->isTrackingDoubleClick()) { // Teleport if the user double clicked gAgent.teleportViaLocation(pos_global); } // Update the "real" tracker information gFloaterWorldMap->trackLocation(pos_global); } // Handle the SLURL callback if any if(LLWorldMapMessage::getInstance()->mSLURLCallback != NULL) { U64 handle = to_region_handle(x_world, y_world); // Check if we reached the requested region if ((LLStringUtil::compareInsensitive(LLWorldMapMessage::getInstance()->mSLURLRegionName, name)==0) || (LLWorldMapMessage::getInstance()->mSLURLRegionHandle == handle)) { url_callback_t callback = LLWorldMapMessage::getInstance()->mSLURLCallback; LLWorldMapMessage::getInstance()->mSLURLCallback = NULL; LLWorldMapMessage::getInstance()->mSLURLRegionName.clear(); LLWorldMapMessage::getInstance()->mSLURLRegionHandle = 0; callback(handle, LLWorldMapMessage::getInstance()->mSLURL, image_id, LLWorldMapMessage::getInstance()->mSLURLTeleport); } } } // Tell the UI to update itself gFloaterWorldMap->updateSims(found_null_sim); }
BOOL LLPanelScriptLimitsRegionMemory::StartRequestChain() { LLUUID region_id; LLFloaterLand* instance = LLFloaterReg::getTypedInstance<LLFloaterLand>("about_land"); if(!instance) { childSetValue("loading_text", LLSD(std::string(""))); //might have to do parent post build here //if not logic below could use early outs return FALSE; } LLParcel* parcel = instance->getCurrentSelectedParcel(); LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion(); LLUUID current_region_id = gAgent.getRegion()->getRegionID(); if ((region) && (parcel)) { LLVector3 parcel_center = parcel->getCenterpoint(); region_id = region->getRegionID(); if(region_id != current_region_id) { std::string msg_wrong_region = LLTrans::getString("ScriptLimitsRequestWrongRegion"); childSetValue("loading_text", LLSD(msg_wrong_region)); return FALSE; } LLVector3d pos_global = region->getCenterGlobal(); LLSD body; std::string url = region->getCapability("RemoteParcelRequest"); if (!url.empty()) { body["location"] = ll_sd_from_vector3(parcel_center); if (!region_id.isNull()) { body["region_id"] = region_id; } if (!pos_global.isExactlyZero()) { U64 region_handle = to_region_handle(pos_global); body["region_handle"] = ll_sd_from_U64(region_handle); } LLHTTPClient::post(url, body, new LLRemoteParcelRequestResponder(getObserverHandle())); } else { llwarns << "Can't get parcel info for script information request" << region_id << ". Region: " << region->getName() << " does not support RemoteParcelRequest" << llendl; std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestError"); childSetValue("loading_text", LLSD(msg_waiting)); } } else { std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestNoParcelSelected"); childSetValue("loading_text", LLSD(msg_waiting)); } return LLPanelScriptLimitsInfo::postBuild(); }
//virtual void LLMapLayerResponder::result(const LLSD& result) { llinfos << "LLMapLayerResponder::result from capabilities" << llendl; S32 agent_flags = result["AgentData"]["Flags"]; if (agent_flags != gWorldMap->mCurrentMap) { llwarns << "Invalid or out of date map image type returned!" << llendl; return; } LLUUID image_id; //U32 left, right, top, bottom; gWorldMap->mMapLayers[agent_flags].clear(); LLSD::array_const_iterator iter; BOOL adjust = FALSE; for(iter = result["LayerData"].beginArray(); iter != result["LayerData"].endArray(); ++iter) { const LLSD& layer_data = *iter; LLWorldMapLayer new_layer; new_layer.LayerDefined = TRUE; new_layer.LayerImageID = layer_data["ImageID"]; new_layer.LayerImage = gImageList.getImage(new_layer.LayerImageID, MIPMAP_TRUE, FALSE); new_layer.LayerImage->bindTexture(0); new_layer.LayerImage->setClamp(TRUE, TRUE); new_layer.LayerExtents.mLeft = layer_data["Left"]; new_layer.LayerExtents.mRight = layer_data["Right"]; new_layer.LayerExtents.mBottom = layer_data["Bottom"]; new_layer.LayerExtents.mTop = layer_data["Top"]; F32 x_meters = F32(new_layer.LayerExtents.mLeft*REGION_WIDTH_UNITS); F32 y_meters = F32(new_layer.LayerExtents.mBottom*REGION_WIDTH_UNITS); adjust = gWorldMap->extendAABB(U32(x_meters), U32(y_meters), U32(x_meters+REGION_WIDTH_UNITS*new_layer.LayerExtents.getWidth()), U32(y_meters+REGION_WIDTH_UNITS*new_layer.LayerExtents.getHeight())) || adjust; gWorldMap->mMapLayers[agent_flags].push_back(new_layer); } gWorldMap->mMapLoaded[agent_flags] = TRUE; if(adjust) gFloaterWorldMap->adjustZoomSliderBounds(); /* U32 agent_flags; msg->getU32Fast(_PREHASH_AgentData, _PREHASH_Flags, agent_flags); if (agent_flags < 0 || agent_flags >= MAP_SIM_IMAGE_TYPES) { llwarns << "Invalid map image type returned! " << agent_flags << llendl; return; } */ bool found_null_sim = false; adjust = FALSE; if (result.has("MapBlocks")) { const LLSD& map_blocks = result["MapBlocks"]; for (iter = map_blocks.beginArray(); iter != map_blocks.endArray(); ++iter) { const LLSD& map_block = *iter; S32 x_regions = map_block["X"]; S32 y_regions = map_block["Y"]; std::string name = map_block["Name"]; S32 access = map_block["Access"]; S32 region_flags = map_block["RegionFlags"]; S32 water_height = map_block["WaterHeight"]; LLUUID image_id = map_block["MapImageID"]; U32 x_meters = x_regions * REGION_WIDTH_UNITS; U32 y_meters = y_regions * REGION_WIDTH_UNITS; if (access == 255) { // This region doesn't exist if (gWorldMap->mIsTrackingUnknownLocation && gWorldMap->mUnknownLocation.mdV[0] >= x_meters && gWorldMap->mUnknownLocation.mdV[0] < x_meters + 256 && gWorldMap->mUnknownLocation.mdV[1] >= y_meters && gWorldMap->mUnknownLocation.mdV[1] < y_meters + 256) { // We were tracking this location, but it doesn't exist gWorldMap->mInvalidLocation = TRUE; } found_null_sim = true; } else { adjust = gWorldMap->extendAABB(x_meters, y_meters, x_meters+REGION_WIDTH_UNITS, y_meters+REGION_WIDTH_UNITS) || adjust; U64 handle = to_region_handle(x_meters, y_meters); // llinfos << "Map sim " << name << " image layer " << agent_flags << " ID " << image_id.getString() << llendl; LLSimInfo* siminfo = new LLSimInfo(); LLWorldMap::sim_info_map_t::iterator iter = gWorldMap->mSimInfoMap.find(handle); if (iter != gWorldMap->mSimInfoMap.end()) { LLSimInfo* oldinfo = iter->second; for (S32 image=0; image<MAP_SIM_IMAGE_TYPES; ++image) { siminfo->mMapImageID[image] = oldinfo->mMapImageID[image]; } delete oldinfo; } gWorldMap->mSimInfoMap[handle] = siminfo; siminfo->mHandle = handle; siminfo->mName.assign( name ); siminfo->mAccess = access; /*Flawfinder: ignore*/ siminfo->mRegionFlags = region_flags; siminfo->mWaterHeight = (F32) water_height; siminfo->mMapImageID[agent_flags] = image_id; siminfo->mCurrentImage = gImageList.getImage(siminfo->mMapImageID[gWorldMap->mCurrentMap], MIPMAP_TRUE, FALSE); siminfo->mCurrentImage->bindTexture(0); siminfo->mCurrentImage->setClamp(TRUE, TRUE); if (siminfo->mMapImageID[2].notNull()) { siminfo->mOverlayImage = gImageList.getImage(siminfo->mMapImageID[2], MIPMAP_TRUE, FALSE); } else { siminfo->mOverlayImage = NULL; } if (gWorldMap->mIsTrackingUnknownLocation && gWorldMap->mUnknownLocation.mdV[0] >= x_meters && gWorldMap->mUnknownLocation.mdV[0] < x_meters + 256 && gWorldMap->mUnknownLocation.mdV[1] >= y_meters && gWorldMap->mUnknownLocation.mdV[1] < y_meters + 256) { if (siminfo->mAccess == SIM_ACCESS_DOWN) { // We were tracking this location, but it doesn't exist gWorldMap->mInvalidLocation = true; } else { // We were tracking this location, and it does exist bool is_tracking_dbl = gWorldMap->mIsTrackingDoubleClick == TRUE; gFloaterWorldMap->trackLocation(gWorldMap->mUnknownLocation); if (is_tracking_dbl) { LLVector3d pos_global = LLTracker::getTrackedPositionGlobal(); gAgent.teleportViaLocation( pos_global ); } } } } } } if(adjust) gFloaterWorldMap->adjustZoomSliderBounds(); gFloaterWorldMap->updateSims(found_null_sim); }
// public static void LLWorldMap::processMapBlockReply(LLMessageSystem* msg, void**) { U32 agent_flags; msg->getU32Fast(_PREHASH_AgentData, _PREHASH_Flags, agent_flags); if ((S32)agent_flags < 0 || agent_flags >= MAP_SIM_IMAGE_TYPES) { llwarns << "Invalid map image type returned! " << agent_flags << llendl; return; } S32 num_blocks = msg->getNumberOfBlocksFast(_PREHASH_Data); bool found_null_sim = false; #ifdef IMMEDIATE_IMAGE_LOAD bool use_web_map_tiles = useWebMapTiles(); #endif BOOL adjust = FALSE; for (S32 block=0; block<num_blocks; ++block) { U16 x_regions; U16 y_regions; U16 x_size = 256; U16 y_size = 256; std::string name; U8 accesscode; U32 region_flags; U8 water_height; U8 agents; LLUUID image_id; msg->getU16Fast(_PREHASH_Data, _PREHASH_X, x_regions, block); msg->getU16Fast(_PREHASH_Data, _PREHASH_Y, y_regions, block); msg->getStringFast(_PREHASH_Data, _PREHASH_Name, name, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_Access, accesscode, block); msg->getU32Fast(_PREHASH_Data, _PREHASH_RegionFlags, region_flags, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_WaterHeight, water_height, block); msg->getU8Fast(_PREHASH_Data, _PREHASH_Agents, agents, block); msg->getUUIDFast(_PREHASH_Data, _PREHASH_MapImageID, image_id, block); if(msg->getNumberOfBlocksFast(_PREHASH_Size) > 0) { msg->getU16Fast(_PREHASH_Size, _PREHASH_SizeX, x_size, block); msg->getU16Fast(_PREHASH_Size, _PREHASH_SizeY, y_size, block); } if(x_size == 0 || (x_size % 16) != 0|| (y_size % 16) != 0) { x_size = 256; y_size = 256; } U32 x_meters = x_regions * REGION_WIDTH_UNITS; U32 y_meters = y_regions * REGION_WIDTH_UNITS; U64 handle = to_region_handle(x_meters, y_meters); if (accesscode == 255) { // This region doesn't exist if (LLWorldMap::getInstance()->mIsTrackingUnknownLocation && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] >= x_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] < x_meters + 256 && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] >= y_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] < y_meters + 256) { // We were tracking this location, but it doesn't exist LLWorldMap::getInstance()->mInvalidLocation = TRUE; } found_null_sim = true; } else { adjust = LLWorldMap::getInstance()->extendAABB(x_meters, y_meters, x_meters+REGION_WIDTH_UNITS, y_meters+REGION_WIDTH_UNITS) || adjust; //LL_INFOS("World Map") << "Map sim : " << name << ", ID : " << image_id.getString() << LL_ENDL; // Insert the region in the region map of the world map // Loading the LLSimInfo object with what we got and insert it in the map LLSimInfo* siminfo = LLWorldMap::getInstance()->simInfoFromHandle(handle); if (siminfo == NULL) { siminfo = LLWorldMap::getInstance()->createSimInfoFromHandle(handle); } siminfo->setName( name ); siminfo->setAccess( accesscode ); siminfo->setRegionFlags( region_flags ); siminfo->setWaterHeight((F32) water_height); siminfo->setMapImageID( image_id, agent_flags ); siminfo->setSize( x_size, y_size ); #ifdef IMMEDIATE_IMAGE_LOAD if (use_web_map_tiles) { siminfo->mCurrentImage = loadObjectsTile((U32)x_regions, (U32)y_regions); } else { siminfo->mCurrentImage = LLViewerTextureManager::getFetchedTexture(siminfo->mMapImageID[LLWorldMap::getInstance()->mCurrentMap], MIPMAP_TRUE, FALSE); } gGL.getTexUnit(0)->bind(siminfo->mCurrentImage.get()); siminfo->mCurrentImage->setAddressMode(LLTexUnit::TAM_CLAMP); #endif if (siminfo->mMapImageID[2].notNull()) { #ifdef IMMEDIATE_IMAGE_LOAD siminfo->mOverlayImage = LLViewerTextureManager::getFetchedTextureURL(siminfo->mMapImageID[2]); #endif } else { siminfo->mOverlayImage = NULL; } if (LLWorldMap::getInstance()->mIsTrackingUnknownLocation && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] >= x_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[0] < x_meters + 256 && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] >= y_meters && LLWorldMap::getInstance()->mUnknownLocation.mdV[1] < y_meters + 256) { if (siminfo->isDown()) { // We were tracking this location, but it doesn't exist LLWorldMap::getInstance()->mInvalidLocation = true; } else { // We were tracking this location, and it does exist bool is_tracking_dbl = LLWorldMap::getInstance()->mIsTrackingDoubleClick == TRUE; gFloaterWorldMap->trackLocation(LLWorldMap::getInstance()->mUnknownLocation); if (is_tracking_dbl) { LLVector3d pos_global = LLTracker::getTrackedPositionGlobal(); gAgent.teleportViaLocation( pos_global ); } } } } if(LLWorldMap::getInstance()->mSLURLCallback != NULL) { // Server returns definitive capitalization, SLURL might not have that. if ((LLStringUtil::compareInsensitive(LLWorldMap::getInstance()->mSLURLRegionName, name)==0) || (LLWorldMap::getInstance()->mSLURLRegionHandle == handle)) { url_callback_t callback = LLWorldMap::getInstance()->mSLURLCallback; LLWorldMap::getInstance()->mSLURLCallback = NULL; LLWorldMap::getInstance()->mSLURLRegionName.clear(); LLWorldMap::getInstance()->mSLURLRegionHandle = 0; callback(handle, LLWorldMap::getInstance()->mSLURL, image_id, LLWorldMap::getInstance()->mSLURLTeleport); } } if( gAgent.mPendingLure && (U16)(gAgent.mPendingLure->mPosGlobal.mdV[0] / REGION_WIDTH_UNITS) == x_regions && (U16)(gAgent.mPendingLure->mPosGlobal.mdV[1] / REGION_WIDTH_UNITS) == y_regions ) { gAgent.onFoundLureDestination(); } } if(adjust) gFloaterWorldMap->adjustZoomSliderBounds(); gFloaterWorldMap->updateSims(found_null_sim); }
BOOL LLPanelScriptLimitsRegionMemory::StartRequestChain() { LLUUID region_id; LLFloaterLand* instance = LLFloaterLand::getInstance(); if(!instance) { getChild<LLUICtrl>("loading_text")->setValue(LLSD(std::string(""))); //might have to do parent post build here //if not logic below could use early outs return FALSE; } LLParcel* parcel = instance->getCurrentSelectedParcel(); LLViewerRegion* region = LLViewerParcelMgr::getInstance()->getSelectionRegion(); LLUUID current_region_id = gAgent.getRegion()->getRegionID(); // <alchemy> Fall back to the parcel we're on if none is selected. // Fixes parcel script info intermittently working and broken in toolbar button. if (!parcel) { parcel = LLViewerParcelMgr::getInstance()->getAgentParcel(); region = gAgent.getRegion(); } // </alchemy> if ((region) && (parcel)) { LLVector3 parcel_center = parcel->getCenterpoint(); region_id = region->getRegionID(); if(region_id != current_region_id) { std::string msg_wrong_region = LLTrans::getString("ScriptLimitsRequestWrongRegion"); getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_wrong_region)); return FALSE; } LLVector3d pos_global = region->getCenterGlobal(); LLSD body; std::string url = region->getCapability("RemoteParcelRequest"); if (!url.empty()) { body["location"] = ll_sd_from_vector3(parcel_center); if (!region_id.isNull()) { body["region_id"] = region_id; } if (!pos_global.isExactlyZero()) { U64 region_handle = to_region_handle(pos_global); body["region_handle"] = ll_sd_from_U64(region_handle); } LLHTTPClient::post(url, body, new LLRemoteParcelRequestResponder(getObserverHandle())); } else { LL_WARNS() << "Can't get parcel info for script information request" << region_id << ". Region: " << region->getName() << " does not support RemoteParcelRequest" << LL_ENDL; std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestError"); getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_waiting)); } } else { std::string msg_waiting = LLTrans::getString("ScriptLimitsRequestNoParcelSelected"); getChild<LLUICtrl>("loading_text")->setValue(LLSD(msg_waiting)); } return LLPanelScriptLimitsInfo::postBuild(); }