From 7c1f17b994ca987df2167101054f523cc33d7fb9 Mon Sep 17 00:00:00 2001
From: Teravus Ovares
Date: Wed, 16 Apr 2008 14:10:54 +0000
Subject: * Applying melanie's Landmark patch. Thanks Melanie! * To make a
landmark, you currently have to enable admin options in the advanced menu
first. We're working on this.. however use the admin options solution in
the mean time.
---
OpenSim/Region/ClientStack/ClientView.cs | 51 ++++++++--------------
.../Region/Environment/Scenes/Scene.Inventory.cs | 15 ++++++-
OpenSim/Region/Environment/Scenes/Scene.cs | 16 +++++++
OpenSim/Region/Environment/Scenes/ScenePresence.cs | 4 ++
.../Region/Examples/SimpleModule/MyNpcCharacter.cs | 1 +
5 files changed, 54 insertions(+), 33 deletions(-)
(limited to 'OpenSim/Region')
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs
index dba5b38..9c56c52 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/ClientView.cs
@@ -154,6 +154,7 @@ namespace OpenSim.Region.ClientStack
private FetchInventory handlerAgentDataUpdateRequest = null; //OnAgentDataUpdateRequest;
private FetchInventory handlerUserInfoRequest = null; //OnUserInfoRequest;
private TeleportLocationRequest handlerSetStartLocationRequest = null; //OnSetStartLocationRequest;
+ private TeleportLandmarkRequest handlerTeleportLandmarkRequest = null; //OnTeleportLandmarkRequest;
private LinkObjects handlerLinkObjects = null; //OnLinkObjects;
private DelinkObjects handlerDelinkObjects = null; //OnDelinkObjects;
private AddNewPrim handlerAddPrim = null; //OnAddPrim;
@@ -716,6 +717,7 @@ namespace OpenSim.Region.ClientStack
public event RequestMapBlocks OnRequestMapBlocks;
public event RequestMapName OnMapNameRequest;
public event TeleportLocationRequest OnTeleportLocationRequest;
+ public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
public event DisconnectUser OnDisconnectUser;
public event RequestAvatarProperties OnRequestAvatarProperties;
public event SetAlwaysRun OnSetAlwaysRun;
@@ -4185,50 +4187,35 @@ namespace OpenSim.Region.ClientStack
break;
case PacketType.TeleportLandmarkRequest:
TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
-
- TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
- tpStart.Info.TeleportFlags = 8; // tp via lm
- OutPacket(tpStart, ThrottleOutPacketType.Task);
-
- TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
- tpProgress.Info.Message = (new UTF8Encoding()).GetBytes("sending_landmark");
- tpProgress.Info.TeleportFlags = 8;
- tpProgress.AgentData.AgentID = tpReq.Info.AgentID;
- OutPacket(tpProgress, ThrottleOutPacketType.Task);
-
- // Fetch landmark
LLUUID lmid = tpReq.Info.LandmarkID;
AssetBase lma = m_assetCache.GetAsset(lmid, false);
- if (lma != null)
+
+ if(lma == null)
{
- AssetLandmark lm = new AssetLandmark(lma);
-
- if (lm.RegionID == m_scene.RegionInfo.RegionID)
- {
- TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
+ // Failed to find landmark
+
+ TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
+ tpCancel.Info.SessionID = tpReq.Info.SessionID;
+ tpCancel.Info.AgentID = tpReq.Info.AgentID;
+ OutPacket(tpCancel, ThrottleOutPacketType.Task);
+ }
- tpLocal.Info.AgentID = tpReq.Info.AgentID;
- tpLocal.Info.TeleportFlags = 8; // Teleport via landmark
- tpLocal.Info.LocationID = 2;
- tpLocal.Info.Position = lm.Position;
- OutPacket(tpLocal, ThrottleOutPacketType.Task);
- }
- else
- {
- TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
- tpCancel.Info.AgentID = tpReq.Info.AgentID;
- tpCancel.Info.SessionID = tpReq.Info.SessionID;
- OutPacket(tpCancel, ThrottleOutPacketType.Task);
- }
+ AssetLandmark lm = new AssetLandmark(lma);
+ handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
+ if (handlerTeleportLandmarkRequest != null)
+ {
+ handlerTeleportLandmarkRequest(this, lm.RegionHandle, lm.Position);
}
else
{
- Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented");
+ //no event handler so cancel request
+
TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
tpCancel.Info.AgentID = tpReq.Info.AgentID;
tpCancel.Info.SessionID = tpReq.Info.SessionID;
OutPacket(tpCancel, ThrottleOutPacketType.Task);
+
}
break;
case PacketType.TeleportLocationRequest:
diff --git a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
index 97d09aa..ff0f3a7 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.Inventory.cs
@@ -545,7 +545,20 @@ namespace OpenSim.Region.Environment.Scenes
if (userInfo != null)
{
- AssetBase asset = CreateAsset(name, description, invType, assetType, null);
+ ScenePresence presence;
+ TryGetAvatar(remoteClient.AgentId, out presence);
+ byte[] data = null;
+ if(invType == 3 && presence != null) // libsecondlife.asset.assettype.landmark = 3 - needs to be turned into an enum
+ {
+ LLVector3 pos=presence.AbsolutePosition;
+ string strdata=String.Format("Landmark version 2\nregion_id {0}\nlocal_pos {1} {2} {3}\nregion_handle {4}\n",
+ presence.Scene.RegionInfo.RegionID,
+ pos.X, pos.Y, pos.Z,
+ presence.RegionHandle);
+ data=Encoding.ASCII.GetBytes(strdata);
+ }
+
+ AssetBase asset = CreateAsset(name, description, invType, assetType, data);
AssetCache.AddAsset(asset);
CreateNewInventoryItem(remoteClient, folderID, callbackID, asset, nextOwnerMask);
diff --git a/OpenSim/Region/Environment/Scenes/Scene.cs b/OpenSim/Region/Environment/Scenes/Scene.cs
index 464926d..08cf3d8 100644
--- a/OpenSim/Region/Environment/Scenes/Scene.cs
+++ b/OpenSim/Region/Environment/Scenes/Scene.cs
@@ -1518,6 +1518,7 @@ namespace OpenSim.Region.Environment.Scenes
client.OnRequestMapBlocks += RequestMapBlocks;
client.OnUpdatePrimTexture += m_innerScene.UpdatePrimTexture;
client.OnTeleportLocationRequest += RequestTeleportLocation;
+ client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
client.OnObjectSelect += SelectPrim;
client.OnObjectDeselect += DeselectPrim;
client.OnGrabUpdate += m_innerScene.MoveObject;
@@ -2082,6 +2083,21 @@ namespace OpenSim.Region.Environment.Scenes
}
///
+ /// Tries to teleport agent to landmark.
+ ///
+ ///
+ ///
+ ///
+ public void RequestTeleportLandmark(IClientAPI remoteClient, ulong regionHandle, LLVector3 position)
+ {
+ if (m_scenePresences.ContainsKey(remoteClient.AgentId))
+ {
+ m_sceneGridService.RequestTeleportToLocation(m_scenePresences[remoteClient.AgentId], regionHandle,
+ position, LLVector3.Zero, 0);
+ }
+ }
+
+ ///
/// Agent is crossing the border into a neighbouring region. Tell the neighbour about it!
///
///
diff --git a/OpenSim/Region/Environment/Scenes/ScenePresence.cs b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
index 795224e..8b8373d 100644
--- a/OpenSim/Region/Environment/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Environment/Scenes/ScenePresence.cs
@@ -270,6 +270,7 @@ namespace OpenSim.Region.Environment.Scenes
}
m_pos = value;
+ m_parentPosition=new LLVector3(0, 0, 0);
}
}
@@ -602,7 +603,10 @@ namespace OpenSim.Region.Environment.Scenes
///
public void Teleport(LLVector3 pos)
{
+ RemoveFromPhysicalScene();
+ Velocity = new LLVector3(0, 0, 0);
AbsolutePosition = pos;
+ AddToPhysicalScene();
SendTerseUpdateToAllClients();
}
diff --git a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
index d5dc937..426ab7e 100644
--- a/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
+++ b/OpenSim/Region/Examples/SimpleModule/MyNpcCharacter.cs
@@ -68,6 +68,7 @@ namespace OpenSim.Region.Examples.SimpleModule
public event RequestMapBlocks OnRequestMapBlocks;
public event RequestMapName OnMapNameRequest;
public event TeleportLocationRequest OnTeleportLocationRequest;
+ public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
public event DisconnectUser OnDisconnectUser;
public event RequestAvatarProperties OnRequestAvatarProperties;
public event SetAlwaysRun OnSetAlwaysRun;
--
cgit v1.1