Exemplo n.º 1
0
// static
void LLLandmarkList::processGetAssetReply(
	LLVFS *vfs,
	const LLUUID& uuid,
	LLAssetType::EType type,
	void* user_data,
	S32 status)
{
	if( status == 0 )
	{
		LLVFile file(vfs, uuid, type);
		S32 file_length = file.getSize();

		char* buffer = new char[ file_length + 1 ];
		file.read( (U8*)buffer, file_length);		/*Flawfinder: ignore*/
		buffer[ file_length ] = 0;

		LLLandmark* landmark = LLLandmark::constructFromString(buffer);
		if (landmark)
		{
			LLVector3d pos;
			if(!landmark->getGlobalPos(pos))
			{
				LLUUID region_id;
				if(landmark->getRegionID(region_id))
				{
					LLLandmark::requestRegionHandle(
						gMessageSystem,
						gAgent.getRegionHost(),
						region_id,
						NULL);
				}
			}
			gLandmarkList.mList[ uuid ] = landmark;
		}

		delete[] buffer;
	}
	else
	{
		if( gViewerStats )
		{
			gViewerStats->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );
		}

		if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status )
		{
			LLNotifyBox::showXml("LandmarkMissing");
		}
		else
		{
			LLNotifyBox::showXml("UnableToLoadLandmark");
		}

		gLandmarkList.mBadList.insert(uuid);
	}

}
Exemplo n.º 2
0
void LLPanelPlaces::onShowOnMapButtonClicked()
{
	LLPanelPlaceInfo* panel = getCurrentInfoPanel();
	if (panel && panel->getVisible())
	{
		LLFloaterWorldMap* worldmap_instance = LLFloaterWorldMap::getInstance();
		if(!worldmap_instance)
			return;

		if (mPlaceInfoType == AGENT_INFO_TYPE ||
			mPlaceInfoType == CREATE_LANDMARK_INFO_TYPE ||
			mPlaceInfoType == REMOTE_PLACE_INFO_TYPE ||
			mPlaceInfoType == TELEPORT_HISTORY_INFO_TYPE)
		{
			if (!mPosGlobal.isExactlyZero())
			{
				worldmap_instance->trackLocation(mPosGlobal);
				LLFloaterReg::showInstance("world_map", "center");
			}
		}
		else if (mPlaceInfoType == LANDMARK_INFO_TYPE)
		{
			LLLandmark* landmark = gLandmarkList.getAsset(mItem->getAssetUUID());
			if (!landmark)
				return;

			LLVector3d landmark_global_pos;
			if (!landmark->getGlobalPos(landmark_global_pos))
				return;
			
			if (!landmark_global_pos.isExactlyZero())
			{
				worldmap_instance->trackLocation(landmark_global_pos);
				LLFloaterReg::showInstance("world_map", "center");
			}
		}
	}
	else
	{
		if (mActivePanel && mActivePanel->isSingleItemSelected())
		{
			mActivePanel->onShowOnMap();
		}
		else
		{
			LLFloaterWorldMap* worldmap_instance = LLFloaterWorldMap::getInstance();
			LLVector3d global_pos = gAgent.getPositionGlobal();

			if (!global_pos.isExactlyZero() && worldmap_instance)
			{
				worldmap_instance->trackLocation(global_pos);
				LLFloaterReg::showInstance("world_map", "center");
			}
		}
	}
}
Exemplo n.º 3
0
void LLLandmarkActions::copySLURLtoClipboard(const LLUUID& landmarkInventoryItemID)
{
	LLLandmark* landmark = LLLandmarkActions::getLandmark(landmarkInventoryItemID);
	if(landmark)
	{
		LLVector3d global_pos;
		landmark->getGlobalPos(global_pos);
		LLLandmarkActions::getSLURLfromPosGlobal(global_pos,&copy_slurl_to_clipboard_callback,true);
	}
}
Exemplo n.º 4
0
bool LLLandmarkActions::getLandmarkGlobalPos(const LLUUID& landmarkInventoryItemID, LLVector3d& posGlobal)
{
	LLViewerInventoryItem* item = gInventory.getItem(landmarkInventoryItemID);
	if (NULL == item)
		return false;

	const LLUUID& asset_id = item->getAssetUUID();

	LLLandmark* landmark = gLandmarkList.getAsset(asset_id, NULL);
	if (NULL == landmark)
		return false;

	return landmark->getGlobalPos(posGlobal);
}
Exemplo n.º 5
0
	/*virtual*/ bool operator()(LLInventoryCategory* cat, LLInventoryItem* item)
	{
		if (mFounded || !item || item->getType() != LLAssetType::AT_LANDMARK)
			return false;

		LLLandmark* landmark = gLandmarkList.getAsset(item->getAssetUUID());
		if (!landmark) // the landmark not been loaded yet
			return false;

		LLVector3d landmark_global_pos;
		if (!landmark->getGlobalPos(landmark_global_pos))
			return false;
		mFounded = LLViewerParcelMgr::getInstance()->inAgentParcel(landmark_global_pos);
		return mFounded;
	}
Exemplo n.º 6
0
void LLTracker::cacheLandmarkPosition()
{
	// the landmark asset download may have finished, in which case
	// we'll now be able to figure out where we're trying to go
	BOOL found_landmark = FALSE;
	if( mTrackedLandmarkAssetID == LLFloaterWorldMap::getHomeID())
	{
		LLVector3d pos_global;
		if ( gAgent.getHomePosGlobal( &mTrackedPositionGlobal ))
		{
			found_landmark = TRUE;
		}
		else
		{
			llwarns << "LLTracker couldn't find home pos" << llendl;
			mTrackedLandmarkAssetID.setNull();
			mTrackedLandmarkItemID.setNull();
		}
	}
	else
	{
		LLLandmark* landmark = gLandmarkList.getAsset(mTrackedLandmarkAssetID);
		if(landmark && landmark->getGlobalPos(mTrackedPositionGlobal))
		{
			found_landmark = TRUE;

			// cache the object's visitation status
			mLandmarkHasBeenVisited = FALSE;
			LLInventoryItem* item = gInventory.getItem(mTrackedLandmarkItemID);
			if (   item 
				&& item->getFlags()&LLInventoryItem::II_FLAGS_LANDMARK_VISITED)
			{
				mLandmarkHasBeenVisited = TRUE;
			}
		}
	}
	if ( found_landmark && gFloaterWorldMap )
	{
		mHasReachedLandmark = FALSE;
		F32 dist = gFloaterWorldMap->getDistanceToDestination(mTrackedPositionGlobal, 1.0f);
		if ( dist < DESTINATION_UNVISITED_RADIUS )
		{
			mHasReachedLandmark = TRUE;
		}
		mHasLandmarkPosition = TRUE;
	}
	mHasLandmarkPosition = found_landmark;
}
Exemplo n.º 7
0
	/*virtual*/ bool operator()(LLInventoryCategory* cat, LLInventoryItem* item)
	{
		if (!item || item->getType() != LLAssetType::AT_LANDMARK)
			return false;

		LLLandmark* landmark = gLandmarkList.getAsset(item->getAssetUUID());
		if (!landmark) // the landmark not been loaded yet
			return false;

		LLVector3d landmark_global_pos;
		if (!landmark->getGlobalPos(landmark_global_pos))
			return false;
		//we have to round off each coordinates to compare positions properly
		return llround(mPos.mdV[VX]) ==  llround(landmark_global_pos.mdV[VX])
				&& llround(mPos.mdV[VY]) ==  llround(landmark_global_pos.mdV[VY])
				&& llround(mPos.mdV[VZ]) ==  llround(landmark_global_pos.mdV[VZ]);
	}
LLLandmark* LLLandmarkList::getAsset(const LLUUID& asset_uuid, loaded_callback_t cb)
{
	LLLandmark* landmark = get_ptr_in_map(mList, asset_uuid);
	if(landmark)
	{
		LLVector3d dummy;
		if(cb && !landmark->getGlobalPos(dummy))
		{
			// landmark is not completely loaded yet
			loaded_callback_map_t::value_type vt(asset_uuid, cb);
			mLoadedCallbackMap.insert(vt);
		}
		return landmark;
	}
	else
	{
	    if ( mBadList.find(asset_uuid) != mBadList.end() )
		{
			return NULL;
		}
		
		landmark_requested_list_t::iterator iter = mRequestedList.find(asset_uuid);
		if (iter != mRequestedList.end())
		{
			const F32 rerequest_time = 30.f; // 30 seconds between requests
			if (gFrameTimeSeconds - iter->second < rerequest_time)
			{
				return NULL;
			}
		}
		
		if (cb)
		{
			loaded_callback_map_t::value_type vt(asset_uuid, cb);
			mLoadedCallbackMap.insert(vt);
		}

		gAssetStorage->getAssetData(asset_uuid,
									LLAssetType::AT_LANDMARK,
									LLLandmarkList::processGetAssetReply,
									NULL);
		mRequestedList[asset_uuid] = gFrameTimeSeconds;
	}
	return NULL;
}
void LLLandmarkList::onRegionHandle(const LLUUID& landmark_id)
{
	LLLandmark* landmark = getAsset(landmark_id);

	if (!landmark)
	{
		LL_WARNS() << "Got region handle but the landmark not found." << LL_ENDL;
		return;
	}

	// Calculate landmark global position.
	// This should succeed since the region handle is available.
	LLVector3d pos;
	if (!landmark->getGlobalPos(pos))
	{
		LL_WARNS() << "Got region handle but the landmark global position is still unknown." << LL_ENDL;
		return;
	}

	makeCallbacks(landmark_id);
}
Exemplo n.º 10
0
void LLFloaterWorldMap::teleportToLandmark()
{
	BOOL has_destination = FALSE;
	LLUUID destination_id; // Null means "home"

	if( LLTracker::getTrackedLandmarkAssetID() == sHomeID )
	{
		has_destination = TRUE;
	}
	else
	{
		LLLandmark* landmark = gLandmarkList.getAsset( LLTracker::getTrackedLandmarkAssetID() );
		LLVector3d global_pos;
		if(landmark && landmark->getGlobalPos(global_pos))
		{
			destination_id = LLTracker::getTrackedLandmarkAssetID();
			has_destination = TRUE;
		}
		else if(landmark)
		{
			// pop up an anonymous request request.
			LLUUID region_id;
			if(landmark->getRegionID(region_id))
			{
				LLLandmark::requestRegionHandle(
					gMessageSystem,
					gAgent.getRegionHost(),
					region_id,
					NULL);
			}
		}
	}

	if( has_destination )
	{
		gAgent.teleportViaLandmark( destination_id );
	}
}
Exemplo n.º 11
0
// protected
void LLFloaterWorldMap::teleport()
{
	BOOL teleport_home = FALSE;
	LLVector3d pos_global;
	LLAvatarTracker& av_tracker = LLAvatarTracker::instance();

	LLTracker::ETrackingStatus tracking_status = LLTracker::getTrackingStatus();
	if (LLTracker::TRACKING_AVATAR == tracking_status
		&& av_tracker.haveTrackingInfo() )
	{
		pos_global = av_tracker.getGlobalPos();
		pos_global.mdV[VZ] = childGetValue("spin z");
	}
	else if ( LLTracker::TRACKING_LANDMARK == tracking_status)
	{
		if( LLTracker::getTrackedLandmarkAssetID() == sHomeID )
		{
			teleport_home = TRUE;
		}
		else
		{
			LLLandmark* landmark = gLandmarkList.getAsset( LLTracker::getTrackedLandmarkAssetID() );
			LLUUID region_id;
			if(landmark
			   && !landmark->getGlobalPos(pos_global)
			   && landmark->getRegionID(region_id))
			{
				LLLandmark::requestRegionHandle(
					gMessageSystem,
					gAgent.getRegionHost(),
					region_id,
					NULL);
			}
		}
	}
	else if ( LLTracker::TRACKING_LOCATION == tracking_status)
	{
		pos_global = LLTracker::getTrackedPositionGlobal();
	}
	else
	{
		make_ui_sound("UISndInvalidOp");
	}

	// Do the teleport, which will also close the floater
	if (teleport_home)
	{
		gAgent.teleportHome();
	}
	else if (!pos_global.isExactlyZero())
	{
		if(LLTracker::TRACKING_LANDMARK == tracking_status)
		{
			gAgent.teleportViaLandmark(LLTracker::getTrackedLandmarkAssetID());
		}
		else
		{
			gAgent.teleportViaLocation( pos_global );
		}
	}
}
// static
void LLLandmarkList::processGetAssetReply(
	LLVFS *vfs,
	const LLUUID& uuid,
	LLAssetType::EType type,
	void* user_data,
	S32 status, 
	LLExtStat ext_status )
{
	if( status == 0 )
	{
		LLVFile file(vfs, uuid, type);
		S32 file_length = file.getSize();

		std::vector<char> buffer(file_length + 1);
		file.read( (U8*)&buffer[0], file_length);
		buffer[ file_length ] = 0;

		LLLandmark* landmark = LLLandmark::constructFromString(&buffer[0]);
		if (landmark)
		{
			gLandmarkList.mList[ uuid ] = landmark;
			gLandmarkList.mRequestedList.erase(uuid);
			
			LLVector3d pos;
			if(!landmark->getGlobalPos(pos))
			{
				LLUUID region_id;
				if(landmark->getRegionID(region_id))
				{
					LLLandmark::requestRegionHandle(
						gMessageSystem,
						gAgent.getRegionHost(),
						region_id,
						boost::bind(&LLLandmarkList::onRegionHandle, &gLandmarkList, uuid));
				}

				// the callback will be called when we get the region handle.
			}
			else
			{
				gLandmarkList.makeCallbacks(uuid);
			}
		}
	}
	else
	{
		LLViewerStats::getInstance()->incStat( LLViewerStats::ST_DOWNLOAD_FAILED );

		if( LL_ERR_ASSET_REQUEST_NOT_IN_DATABASE == status )
		{
			LLNotificationsUtil::add("LandmarkMissing");
		}
		else
		{
			LLNotificationsUtil::add("UnableToLoadLandmark");
		}

		gLandmarkList.mBadList.insert(uuid);
	}

}