diff options
Diffstat (limited to 'OpenSim/Region/Framework')
34 files changed, 1061 insertions, 3757 deletions
diff --git a/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs new file mode 100644 index 0000000..0222b02 --- /dev/null +++ b/OpenSim/Region/Framework/Interfaces/IAttachmentsModule.cs | |||
@@ -0,0 +1,106 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using OpenMetaverse; | ||
30 | using OpenSim.Framework; | ||
31 | using OpenSim.Region.Framework.Scenes; | ||
32 | |||
33 | namespace OpenSim.Region.Framework.Interfaces | ||
34 | { | ||
35 | public interface IAttachmentsModule | ||
36 | { | ||
37 | /// <summary> | ||
38 | /// Attach an object to an avatar from the world. | ||
39 | /// </summary> | ||
40 | /// <param name="controllingClient"></param> | ||
41 | /// <param name="localID"></param> | ||
42 | /// <param name="attachPoint"></param> | ||
43 | /// <param name="rot"></param> | ||
44 | /// <param name="silent"></param> | ||
45 | void AttachObject( | ||
46 | IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent); | ||
47 | |||
48 | /// <summary> | ||
49 | /// Attach an object to an avatar. | ||
50 | /// </summary> | ||
51 | /// <param name="controllingClient"></param> | ||
52 | /// <param name="localID"></param> | ||
53 | /// <param name="attachPoint"></param> | ||
54 | /// <param name="rot"></param> | ||
55 | /// <param name="attachPos"></param> | ||
56 | /// <param name="silent"></param> | ||
57 | /// <returns>true if the object was successfully attached, false otherwise</returns> | ||
58 | bool AttachObject( | ||
59 | IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent); | ||
60 | |||
61 | /// <summary> | ||
62 | /// Rez an attachment from user inventory and change inventory status to match. | ||
63 | /// </summary> | ||
64 | /// <param name="remoteClient"></param> | ||
65 | /// <param name="itemID"></param> | ||
66 | /// <param name="AttachmentPt"></param> | ||
67 | /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> | ||
68 | UUID RezSingleAttachmentFromInventory(IClientAPI remoteClient, UUID itemID, uint AttachmentPt); | ||
69 | |||
70 | /// <summary> | ||
71 | /// Rez an attachment from user inventory | ||
72 | /// </summary> | ||
73 | /// <param name="remoteClient"></param> | ||
74 | /// <param name="itemID"></param> | ||
75 | /// <param name="AttachmentPt"></param> | ||
76 | /// <param name="updateinventoryStatus"> | ||
77 | /// If true, we also update the user's inventory to show that the attachment is set. If false, we do not. | ||
78 | /// False is required so that we don't attempt to update information when a user enters a scene with the | ||
79 | /// attachment already correctly set up in inventory. | ||
80 | /// <returns>The uuid of the scene object that was attached. Null if the scene object could not be found</returns> | ||
81 | UUID RezSingleAttachmentFromInventory( | ||
82 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt, bool updateInventoryStatus); | ||
83 | |||
84 | /// <summary> | ||
85 | /// Update the user inventory to the attachment of an item | ||
86 | /// </summary> | ||
87 | /// <param name="att"></param> | ||
88 | /// <param name="remoteClient"></param> | ||
89 | /// <param name="itemID"></param> | ||
90 | /// <param name="AttachmentPt"></param> | ||
91 | /// <returns></returns> | ||
92 | UUID SetAttachmentInventoryStatus( | ||
93 | SceneObjectGroup att, IClientAPI remoteClient, UUID itemID, uint AttachmentPt); | ||
94 | |||
95 | /// <summary> | ||
96 | /// Update the user inventory to show a detach. | ||
97 | /// </summary> | ||
98 | /// <param name="itemID"> | ||
99 | /// A <see cref="UUID"/> | ||
100 | /// </param> | ||
101 | /// <param name="remoteClient"> | ||
102 | /// A <see cref="IClientAPI"/> | ||
103 | /// </param> | ||
104 | void ShowDetachInUserInventory(UUID itemID, IClientAPI remoteClient); | ||
105 | } | ||
106 | } \ No newline at end of file | ||
diff --git a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs index ce57c44..35b4b63 100644 --- a/OpenSim/Region/Framework/Interfaces/IDialogModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IDialogModule.cs | |||
@@ -131,5 +131,10 @@ namespace OpenSim.Region.Framework.Interfaces | |||
131 | /// <param name="fromAvatarName">The name of the user doing the sending</param> | 131 | /// <param name="fromAvatarName">The name of the user doing the sending</param> |
132 | /// <param name="message">The message being sent to the user</param> | 132 | /// <param name="message">The message being sent to the user</param> |
133 | void SendNotificationToUsersInEstate(UUID fromAvatarID, string fromAvatarName, string message); | 133 | void SendNotificationToUsersInEstate(UUID fromAvatarID, string fromAvatarName, string message); |
134 | |||
135 | /// <summary> | ||
136 | /// Send a textbox entry for the client to respond to | ||
137 | /// </summary> | ||
138 | void SendTextBoxToUser(UUID avatarid, string message, int chatChannel, string name, UUID objectid, UUID ownerid); | ||
134 | } | 139 | } |
135 | } | 140 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs index 5d4e7ac..e8738c4 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs +++ b/OpenSim/Region/Framework/Interfaces/IEntityTransferModule.cs | |||
@@ -26,31 +26,35 @@ | |||
26 | */ | 26 | */ |
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | ||
30 | |||
31 | using OpenSim.Framework; | ||
32 | using OpenSim.Services.Interfaces; | 29 | using OpenSim.Services.Interfaces; |
30 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
31 | |||
33 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | ||
34 | using OpenSim.Region.Framework.Scenes; | ||
34 | 35 | ||
35 | namespace OpenSim.Region.Framework.Scenes.Hypergrid | 36 | namespace OpenSim.Region.Framework.Interfaces |
36 | { | 37 | { |
37 | public class HGUuidGatherer : UuidGatherer | 38 | public interface IEntityTransferModule |
39 | { | ||
40 | void Teleport(ScenePresence agent, ulong regionHandle, Vector3 position, | ||
41 | Vector3 lookAt, uint teleportFlags); | ||
42 | |||
43 | void TeleportHome(UUID id, IClientAPI client); | ||
44 | |||
45 | void Cross(ScenePresence agent, bool isFlying); | ||
46 | |||
47 | void AgentArrivedAtDestination(UUID agent); | ||
48 | |||
49 | void EnableChildAgents(ScenePresence agent); | ||
50 | |||
51 | void EnableChildAgent(ScenePresence agent, GridRegion region); | ||
52 | |||
53 | void Cross(SceneObjectGroup sog, Vector3 position, bool silent); | ||
54 | } | ||
55 | |||
56 | public interface IUserAgentVerificationModule | ||
38 | { | 57 | { |
39 | protected string m_assetServerURL; | 58 | bool VerifyClient(AgentCircuitData aCircuit, string token); |
40 | protected HGAssetMapper m_assetMapper; | ||
41 | |||
42 | public HGUuidGatherer(HGAssetMapper assMap, IAssetService assetCache, string assetServerURL) : base(assetCache) | ||
43 | { | ||
44 | m_assetMapper = assMap; | ||
45 | m_assetServerURL = assetServerURL; | ||
46 | } | ||
47 | |||
48 | protected override AssetBase GetAsset(UUID uuid) | ||
49 | { | ||
50 | if (string.Empty == m_assetServerURL) | ||
51 | return m_assetCache.Get(uuid.ToString()); | ||
52 | else | ||
53 | return m_assetMapper.FetchAsset(m_assetServerURL, uuid); | ||
54 | } | ||
55 | } | 59 | } |
56 | } | 60 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs index 8386030..0ff7dee 100644 --- a/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IFriendsModule.cs | |||
@@ -33,19 +33,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
33 | { | 33 | { |
34 | public interface IFriendsModule | 34 | public interface IFriendsModule |
35 | { | 35 | { |
36 | /// <summary> | 36 | uint GetFriendPerms(UUID PrincipalID, UUID FriendID); |
37 | /// Offer a friendship to a user from the server end rather than by direct initiation from a client. | 37 | void SendFriendsOnlineIfNeeded(IClientAPI client); |
38 | /// </summary> | ||
39 | /// <param name="fromUserId"> | ||
40 | /// A user with this id must existing in the user data store, but need not be logged on. | ||
41 | /// </param> | ||
42 | /// <param name="toUserClient"> | ||
43 | /// An actually logged in client to which the offer is being made. | ||
44 | /// FIXME: This is somewhat too tightly coupled - it should arguably be possible to offer friendships even if the | ||
45 | /// receiving user is not currently online. | ||
46 | /// </param> | ||
47 | /// <param name="offerMessage"></param> | ||
48 | void OfferFriendship(UUID fromUserId, IClientAPI toUserClient, string offerMessage); | ||
49 | List<FriendListItem> GetUserFriends(UUID agentID); | ||
50 | } | 38 | } |
51 | } | 39 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/ITeleportModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs index 5f9129d..8185258 100644 --- a/OpenSim/Region/Framework/Interfaces/ITeleportModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IInventoryAccessModule.cs | |||
@@ -27,15 +27,21 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Text; | 30 | |
31 | using OpenMetaverse; | 31 | using OpenSim.Framework; |
32 | using OpenSim.Region.Framework.Scenes; | 32 | using OpenSim.Region.Framework.Scenes; |
33 | 33 | ||
34 | using OpenMetaverse; | ||
35 | |||
34 | namespace OpenSim.Region.Framework.Interfaces | 36 | namespace OpenSim.Region.Framework.Interfaces |
35 | { | 37 | { |
36 | public interface ITeleportModule | 38 | public interface IInventoryAccessModule |
37 | { | 39 | { |
38 | void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position, | 40 | UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data); |
39 | Vector3 lookAt, uint teleportFlags); | 41 | UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient); |
42 | SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | ||
43 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
44 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment); | ||
45 | void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver); | ||
40 | } | 46 | } |
41 | } | 47 | } |
diff --git a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs index 2d038ce..fbadd91 100644 --- a/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IInventoryArchiverModule.cs | |||
@@ -27,7 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.IO; | 29 | using System.IO; |
30 | using OpenSim.Framework.Communications.Cache; | 30 | using OpenSim.Services.Interfaces; |
31 | 31 | ||
32 | namespace OpenSim.Region.Framework.Interfaces | 32 | namespace OpenSim.Region.Framework.Interfaces |
33 | { | 33 | { |
@@ -41,7 +41,7 @@ namespace OpenSim.Region.Framework.Interfaces | |||
41 | /// <param name="savePath">The stream to which the archive was saved</param> | 41 | /// <param name="savePath">The stream to which the archive was saved</param> |
42 | /// <param name="reportedException">Contains the exception generated if the save did not succeed</param> | 42 | /// <param name="reportedException">Contains the exception generated if the save did not succeed</param> |
43 | public delegate void InventoryArchiveSaved( | 43 | public delegate void InventoryArchiveSaved( |
44 | Guid id, bool succeeded, CachedUserInfo userInfo, string invPath, Stream saveStream, Exception reportedException); | 44 | Guid id, bool succeeded, UserAccount userInfo, string invPath, Stream saveStream, Exception reportedException); |
45 | 45 | ||
46 | public interface IInventoryArchiverModule | 46 | public interface IInventoryArchiverModule |
47 | { | 47 | { |
diff --git a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs index 630c6a3..d44c1e1 100644 --- a/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs +++ b/OpenSim/Region/Framework/Interfaces/IPresenceModule.cs | |||
@@ -31,13 +31,13 @@ namespace OpenSim.Region.Framework.Interfaces | |||
31 | { | 31 | { |
32 | public struct PresenceInfo | 32 | public struct PresenceInfo |
33 | { | 33 | { |
34 | public UUID userID; | 34 | public string UserID; |
35 | public UUID regionID; | 35 | public UUID RegionID; |
36 | 36 | ||
37 | public PresenceInfo(UUID userID, UUID regionID) | 37 | public PresenceInfo(string userID, UUID regionID) |
38 | { | 38 | { |
39 | this.userID = userID; | 39 | UserID = userID; |
40 | this.regionID = regionID; | 40 | RegionID = regionID; |
41 | } | 41 | } |
42 | } | 42 | } |
43 | 43 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs index be0e985..fd7d44f 100644 --- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs +++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs | |||
@@ -385,7 +385,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation | |||
385 | } | 385 | } |
386 | } | 386 | } |
387 | 387 | ||
388 | AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); | 388 | AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation, m_scenePresence.UUID.ToString()); |
389 | Animasset.Data = anim.ToBytes(); | 389 | Animasset.Data = anim.ToBytes(); |
390 | Animasset.Temporary = true; | 390 | Animasset.Temporary = true; |
391 | Animasset.Local = true; | 391 | Animasset.Local = true; |
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs index 9a7863b..c08b961 100644 --- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs +++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs | |||
@@ -32,6 +32,7 @@ using System.Timers; | |||
32 | using log4net; | 32 | using log4net; |
33 | using OpenMetaverse; | 33 | using OpenMetaverse; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Region.Framework.Interfaces; | ||
35 | 36 | ||
36 | namespace OpenSim.Region.Framework.Scenes | 37 | namespace OpenSim.Region.Framework.Scenes |
37 | { | 38 | { |
@@ -137,7 +138,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
137 | 138 | ||
138 | try | 139 | try |
139 | { | 140 | { |
140 | m_scene.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); | 141 | IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); |
142 | if (invAccess != null) | ||
143 | invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); | ||
141 | if (x.permissionToDelete) | 144 | if (x.permissionToDelete) |
142 | m_scene.DeleteSceneObject(x.objectGroup, false); | 145 | m_scene.DeleteSceneObject(x.objectGroup, false); |
143 | } | 146 | } |
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs index 7fb1cd8..37a51d9 100644 --- a/OpenSim/Region/Framework/Scenes/EventManager.cs +++ b/OpenSim/Region/Framework/Scenes/EventManager.cs | |||
@@ -66,13 +66,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
66 | public event OnClientConnectCoreDelegate OnClientConnect; | 66 | public event OnClientConnectCoreDelegate OnClientConnect; |
67 | 67 | ||
68 | public delegate void OnNewClientDelegate(IClientAPI client); | 68 | public delegate void OnNewClientDelegate(IClientAPI client); |
69 | 69 | ||
70 | /// <summary> | 70 | /// <summary> |
71 | /// Deprecated in favour of OnClientConnect. | 71 | /// Deprecated in favour of OnClientConnect. |
72 | /// Will be marked Obsolete after IClientCore has 100% of IClientAPI interfaces. | 72 | /// Will be marked Obsolete after IClientCore has 100% of IClientAPI interfaces. |
73 | /// </summary> | 73 | /// </summary> |
74 | public event OnNewClientDelegate OnNewClient; | 74 | public event OnNewClientDelegate OnNewClient; |
75 | 75 | ||
76 | public delegate void OnClientLoginDelegate(IClientAPI client); | ||
77 | public event OnClientLoginDelegate OnClientLogin; | ||
78 | |||
76 | public delegate void OnNewPresenceDelegate(ScenePresence presence); | 79 | public delegate void OnNewPresenceDelegate(ScenePresence presence); |
77 | 80 | ||
78 | public event OnNewPresenceDelegate OnNewPresence; | 81 | public event OnNewPresenceDelegate OnNewPresence; |
@@ -107,12 +110,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
107 | public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; | 110 | public event OnSetRootAgentSceneDelegate OnSetRootAgentScene; |
108 | 111 | ||
109 | /// <summary> | 112 | /// <summary> |
110 | /// Called when an object is touched/grabbed. | 113 | /// Fired when an object is touched/grabbed. |
111 | /// </summary> | 114 | /// </summary> |
112 | /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of | 115 | /// The originalID is the local ID of the part that was actually touched. The localID itself is always that of |
113 | /// the root part. | 116 | /// the root part. |
114 | public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs); | ||
115 | public event ObjectGrabDelegate OnObjectGrab; | 117 | public event ObjectGrabDelegate OnObjectGrab; |
118 | public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs); | ||
116 | 119 | ||
117 | public event ObjectGrabDelegate OnObjectGrabbing; | 120 | public event ObjectGrabDelegate OnObjectGrabbing; |
118 | public event ObjectDeGrabDelegate OnObjectDeGrab; | 121 | public event ObjectDeGrabDelegate OnObjectDeGrab; |
@@ -120,8 +123,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
120 | 123 | ||
121 | public event OnPermissionErrorDelegate OnPermissionError; | 124 | public event OnPermissionErrorDelegate OnPermissionError; |
122 | 125 | ||
123 | public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); | 126 | /// <summary> |
127 | /// Fired when a new script is created. | ||
128 | /// </summary> | ||
124 | public event NewRezScript OnRezScript; | 129 | public event NewRezScript OnRezScript; |
130 | public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource); | ||
125 | 131 | ||
126 | public delegate void RemoveScript(uint localID, UUID itemID); | 132 | public delegate void RemoveScript(uint localID, UUID itemID); |
127 | public event RemoveScript OnRemoveScript; | 133 | public event RemoveScript OnRemoveScript; |
@@ -165,36 +171,33 @@ namespace OpenSim.Region.Framework.Scenes | |||
165 | 171 | ||
166 | public event ClientClosed OnClientClosed; | 172 | public event ClientClosed OnClientClosed; |
167 | 173 | ||
168 | public delegate void ScriptChangedEvent(uint localID, uint change); | 174 | /// <summary> |
169 | 175 | /// This is fired when a scene object property that a script might be interested in (such as color, scale or | |
176 | /// inventory) changes. Only enough information is sent for the LSL changed event | ||
177 | /// (see http://lslwiki.net/lslwiki/wakka.php?wakka=changed) | ||
178 | /// </summary> | ||
170 | public event ScriptChangedEvent OnScriptChangedEvent; | 179 | public event ScriptChangedEvent OnScriptChangedEvent; |
180 | public delegate void ScriptChangedEvent(uint localID, uint change); | ||
171 | 181 | ||
172 | public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed); | 182 | public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed); |
173 | |||
174 | public event ScriptControlEvent OnScriptControlEvent; | 183 | public event ScriptControlEvent OnScriptControlEvent; |
175 | 184 | ||
176 | public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); | 185 | public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos); |
177 | |||
178 | public event ScriptAtTargetEvent OnScriptAtTargetEvent; | 186 | public event ScriptAtTargetEvent OnScriptAtTargetEvent; |
179 | 187 | ||
180 | public delegate void ScriptNotAtTargetEvent(uint localID); | 188 | public delegate void ScriptNotAtTargetEvent(uint localID); |
181 | |||
182 | public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; | 189 | public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent; |
183 | 190 | ||
184 | public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot); | 191 | public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot); |
185 | |||
186 | public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent; | 192 | public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent; |
187 | 193 | ||
188 | public delegate void ScriptNotAtRotTargetEvent(uint localID); | 194 | public delegate void ScriptNotAtRotTargetEvent(uint localID); |
189 | |||
190 | public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent; | 195 | public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent; |
191 | 196 | ||
192 | public delegate void ScriptColliding(uint localID, ColliderArgs colliders); | 197 | public delegate void ScriptColliding(uint localID, ColliderArgs colliders); |
193 | |||
194 | public event ScriptColliding OnScriptColliderStart; | 198 | public event ScriptColliding OnScriptColliderStart; |
195 | public event ScriptColliding OnScriptColliding; | 199 | public event ScriptColliding OnScriptColliding; |
196 | public event ScriptColliding OnScriptCollidingEnd; | 200 | public event ScriptColliding OnScriptCollidingEnd; |
197 | |||
198 | public event ScriptColliding OnScriptLandColliderStart; | 201 | public event ScriptColliding OnScriptLandColliderStart; |
199 | public event ScriptColliding OnScriptLandColliding; | 202 | public event ScriptColliding OnScriptLandColliding; |
200 | public event ScriptColliding OnScriptLandColliderEnd; | 203 | public event ScriptColliding OnScriptLandColliderEnd; |
@@ -587,6 +590,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
587 | } | 590 | } |
588 | } | 591 | } |
589 | 592 | ||
593 | public void TriggerOnClientLogin(IClientAPI client) | ||
594 | { | ||
595 | OnClientLoginDelegate handlerClientLogin = OnClientLogin; | ||
596 | if (handlerClientLogin != null) | ||
597 | { | ||
598 | foreach (OnClientLoginDelegate d in handlerClientLogin.GetInvocationList()) | ||
599 | { | ||
600 | try | ||
601 | { | ||
602 | d(client); | ||
603 | } | ||
604 | catch (Exception e) | ||
605 | { | ||
606 | m_log.ErrorFormat( | ||
607 | "[EVENT MANAGER]: Delegate for TriggerOnClientLogin failed - continuing. {0} {1}", | ||
608 | e.Message, e.StackTrace); | ||
609 | } | ||
610 | } | ||
611 | } | ||
612 | |||
613 | } | ||
614 | |||
590 | public void TriggerOnNewPresence(ScenePresence presence) | 615 | public void TriggerOnNewPresence(ScenePresence presence) |
591 | { | 616 | { |
592 | OnNewPresenceDelegate handlerNewPresence = OnNewPresence; | 617 | OnNewPresenceDelegate handlerNewPresence = OnNewPresence; |
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs deleted file mode 100644 index ec50598..0000000 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ /dev/null | |||
@@ -1,265 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Reflection; | ||
31 | using System.Threading; | ||
32 | using log4net; | ||
33 | using OpenMetaverse; | ||
34 | using OpenSim.Framework; | ||
35 | using OpenSim.Framework.Communications.Cache; | ||
36 | using OpenSim.Framework.Communications.Clients; | ||
37 | using OpenSim.Region.Framework.Scenes.Serialization; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Services.Interfaces; | ||
40 | |||
41 | //using HyperGrid.Framework; | ||
42 | //using OpenSim.Region.Communications.Hypergrid; | ||
43 | |||
44 | namespace OpenSim.Region.Framework.Scenes.Hypergrid | ||
45 | { | ||
46 | public class HGAssetMapper | ||
47 | { | ||
48 | #region Fields | ||
49 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
50 | |||
51 | // This maps between inventory server urls and inventory server clients | ||
52 | // private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); | ||
53 | |||
54 | private Scene m_scene; | ||
55 | |||
56 | private IHyperAssetService m_hyper; | ||
57 | IHyperAssetService HyperlinkAssets | ||
58 | { | ||
59 | get | ||
60 | { | ||
61 | if (m_hyper == null) | ||
62 | m_hyper = m_scene.RequestModuleInterface<IHyperAssetService>(); | ||
63 | return m_hyper; | ||
64 | } | ||
65 | } | ||
66 | |||
67 | #endregion | ||
68 | |||
69 | #region Constructor | ||
70 | |||
71 | public HGAssetMapper(Scene scene) | ||
72 | { | ||
73 | m_scene = scene; | ||
74 | } | ||
75 | |||
76 | #endregion | ||
77 | |||
78 | #region Internal functions | ||
79 | |||
80 | // private string UserAssetURL(UUID userID) | ||
81 | // { | ||
82 | // CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); | ||
83 | // if (uinfo != null) | ||
84 | // return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI; | ||
85 | // return null; | ||
86 | // } | ||
87 | |||
88 | // private string UserInventoryURL(UUID userID) | ||
89 | // { | ||
90 | // CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); | ||
91 | // if (uinfo != null) | ||
92 | // return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI; | ||
93 | // return null; | ||
94 | // } | ||
95 | |||
96 | |||
97 | public AssetBase FetchAsset(string url, UUID assetID) | ||
98 | { | ||
99 | AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString()); | ||
100 | |||
101 | if (asset != null) | ||
102 | { | ||
103 | m_log.DebugFormat("[HGScene]: Copied asset {0} from {1} to local asset server. ", asset.ID, url); | ||
104 | return asset; | ||
105 | } | ||
106 | return null; | ||
107 | } | ||
108 | |||
109 | public bool PostAsset(string url, AssetBase asset) | ||
110 | { | ||
111 | if (asset != null) | ||
112 | { | ||
113 | // See long comment in AssetCache.AddAsset | ||
114 | if (!asset.Temporary || asset.Local) | ||
115 | { | ||
116 | // We need to copy the asset into a new asset, because | ||
117 | // we need to set its ID to be URL+UUID, so that the | ||
118 | // HGAssetService dispatches it to the remote grid. | ||
119 | // It's not pretty, but the best that can be done while | ||
120 | // not having a global naming infrastructure | ||
121 | AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type); | ||
122 | Copy(asset, asset1); | ||
123 | try | ||
124 | { | ||
125 | asset1.ID = url + "/" + asset.ID; | ||
126 | } | ||
127 | catch | ||
128 | { | ||
129 | m_log.Warn("[HGScene]: Oops."); | ||
130 | } | ||
131 | |||
132 | m_scene.AssetService.Store(asset1); | ||
133 | m_log.DebugFormat("[HGScene]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url); | ||
134 | } | ||
135 | return true; | ||
136 | } | ||
137 | else | ||
138 | m_log.Warn("[HGScene]: Tried to post asset to remote server, but asset not in local cache."); | ||
139 | |||
140 | return false; | ||
141 | } | ||
142 | |||
143 | private void Copy(AssetBase from, AssetBase to) | ||
144 | { | ||
145 | to.Data = from.Data; | ||
146 | to.Description = from.Description; | ||
147 | to.FullID = from.FullID; | ||
148 | to.ID = from.ID; | ||
149 | to.Local = from.Local; | ||
150 | to.Name = from.Name; | ||
151 | to.Temporary = from.Temporary; | ||
152 | to.Type = from.Type; | ||
153 | |||
154 | } | ||
155 | |||
156 | // TODO: unused | ||
157 | // private void Dump(Dictionary<UUID, bool> lst) | ||
158 | // { | ||
159 | // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); | ||
160 | // foreach (KeyValuePair<UUID, bool> kvp in lst) | ||
161 | // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")"); | ||
162 | // m_log.Debug("XXX -------- UUID DUMP ------- XXX"); | ||
163 | // } | ||
164 | |||
165 | #endregion | ||
166 | |||
167 | |||
168 | #region Public interface | ||
169 | |||
170 | public void Get(UUID assetID, UUID ownerID) | ||
171 | { | ||
172 | // Get the item from the remote asset server onto the local AssetCache | ||
173 | // and place an entry in m_assetMap | ||
174 | |||
175 | string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID); | ||
176 | if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer())) | ||
177 | { | ||
178 | m_log.Debug("[HGScene]: Fetching object " + assetID + " from asset server " + userAssetURL); | ||
179 | AssetBase asset = FetchAsset(userAssetURL, assetID); | ||
180 | |||
181 | if (asset != null) | ||
182 | { | ||
183 | // OK, now fetch the inside. | ||
184 | Dictionary<UUID, int> ids = new Dictionary<UUID, int>(); | ||
185 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL); | ||
186 | uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); | ||
187 | foreach (UUID uuid in ids.Keys) | ||
188 | FetchAsset(userAssetURL, uuid); | ||
189 | |||
190 | m_log.DebugFormat("[HGScene]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL); | ||
191 | |||
192 | } | ||
193 | else | ||
194 | m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL); | ||
195 | } | ||
196 | else | ||
197 | m_log.Debug("[HGScene]: user's asset server is the local region's asset server"); | ||
198 | } | ||
199 | |||
200 | //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo) | ||
201 | //{ | ||
202 | // InventoryClient invCli = null; | ||
203 | // string inventoryURL = UserInventoryURL(item.Owner); | ||
204 | // if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli)) | ||
205 | // { | ||
206 | // m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL); | ||
207 | // invCli = new InventoryClient(inventoryURL); | ||
208 | // m_inventoryServers.Add(inventoryURL, invCli); | ||
209 | // } | ||
210 | |||
211 | // item = invCli.GetInventoryItem(item); | ||
212 | // if (item != null) | ||
213 | // { | ||
214 | // // Change the folder, stick it in root folder, all items flattened out here in this region cache | ||
215 | // item.Folder = rootFolder; | ||
216 | // //userInfo.AddItem(item); don't use this, it calls back to the inventory server | ||
217 | // lock (userInfo.RootFolder.Items) | ||
218 | // { | ||
219 | // userInfo.RootFolder.Items[item.ID] = item; | ||
220 | // } | ||
221 | |||
222 | // } | ||
223 | // return item; | ||
224 | //} | ||
225 | |||
226 | public void Post(UUID assetID, UUID ownerID) | ||
227 | { | ||
228 | // Post the item from the local AssetCache onto the remote asset server | ||
229 | // and place an entry in m_assetMap | ||
230 | |||
231 | string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID); | ||
232 | if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer())) | ||
233 | { | ||
234 | m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL); | ||
235 | AssetBase asset = m_scene.AssetService.Get(assetID.ToString()); | ||
236 | if (asset != null) | ||
237 | { | ||
238 | Dictionary<UUID, int> ids = new Dictionary<UUID, int>(); | ||
239 | HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty); | ||
240 | uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids); | ||
241 | foreach (UUID uuid in ids.Keys) | ||
242 | { | ||
243 | asset = m_scene.AssetService.Get(uuid.ToString()); | ||
244 | if (asset == null) | ||
245 | m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid); | ||
246 | else | ||
247 | PostAsset(userAssetURL, asset); | ||
248 | } | ||
249 | |||
250 | // maybe all pieces got there... | ||
251 | m_log.DebugFormat("[HGScene]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL); | ||
252 | |||
253 | } | ||
254 | else | ||
255 | m_log.DebugFormat("[HGScene]: Something wrong with asset {0}, it could not be found", assetID); | ||
256 | } | ||
257 | else | ||
258 | m_log.Debug("[HGScene]: user's asset server is local region's asset server"); | ||
259 | |||
260 | } | ||
261 | |||
262 | #endregion | ||
263 | |||
264 | } | ||
265 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs deleted file mode 100644 index 6f7f34f..0000000 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs +++ /dev/null | |||
@@ -1,174 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System.Reflection; | ||
29 | using log4net; | ||
30 | using Nini.Config; | ||
31 | using OpenMetaverse; | ||
32 | using OpenSim.Framework; | ||
33 | using OpenSim.Framework.Communications; | ||
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Framework.Interfaces; | ||
36 | |||
37 | namespace OpenSim.Region.Framework.Scenes.Hypergrid | ||
38 | { | ||
39 | public partial class HGScene : Scene | ||
40 | { | ||
41 | #region Fields | ||
42 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
43 | |||
44 | private HGAssetMapper m_assMapper; | ||
45 | public HGAssetMapper AssetMapper | ||
46 | { | ||
47 | get { return m_assMapper; } | ||
48 | } | ||
49 | |||
50 | private IHyperAssetService m_hyper; | ||
51 | private IHyperAssetService HyperAssets | ||
52 | { | ||
53 | get | ||
54 | { | ||
55 | if (m_hyper == null) | ||
56 | m_hyper = RequestModuleInterface<IHyperAssetService>(); | ||
57 | return m_hyper; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | #endregion | ||
62 | |||
63 | #region Constructors | ||
64 | |||
65 | public HGScene(RegionInfo regInfo, AgentCircuitManager authen, | ||
66 | CommunicationsManager commsMan, SceneCommunicationService sceneGridService, | ||
67 | StorageManager storeManager, | ||
68 | ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, | ||
69 | bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) | ||
70 | : base(regInfo, authen, commsMan, sceneGridService, storeManager, moduleLoader, | ||
71 | dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion) | ||
72 | { | ||
73 | m_log.Info("[HGScene]: Starting HGScene."); | ||
74 | m_assMapper = new HGAssetMapper(this); | ||
75 | |||
76 | EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem; | ||
77 | } | ||
78 | |||
79 | #endregion | ||
80 | |||
81 | #region Event handlers | ||
82 | |||
83 | public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel) | ||
84 | { | ||
85 | CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(avatarID); | ||
86 | if (userInfo != null) | ||
87 | { | ||
88 | m_assMapper.Post(assetID, avatarID); | ||
89 | } | ||
90 | } | ||
91 | |||
92 | #endregion | ||
93 | |||
94 | #region Overrides of Scene.Inventory methods | ||
95 | |||
96 | /// | ||
97 | /// CapsUpdateInventoryItemAsset | ||
98 | /// | ||
99 | public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) | ||
100 | { | ||
101 | UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data); | ||
102 | |||
103 | UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0); | ||
104 | |||
105 | return newAssetID; | ||
106 | } | ||
107 | |||
108 | /// | ||
109 | /// DeleteToInventory | ||
110 | /// | ||
111 | public override UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient) | ||
112 | { | ||
113 | UUID assetID = base.DeleteToInventory(action, folderID, objectGroup, remoteClient); | ||
114 | |||
115 | if (!assetID.Equals(UUID.Zero)) | ||
116 | { | ||
117 | UploadInventoryItem(remoteClient.AgentId, assetID, "", 0); | ||
118 | } | ||
119 | else | ||
120 | m_log.Debug("[HGScene]: Scene.Inventory did not create asset"); | ||
121 | |||
122 | return assetID; | ||
123 | } | ||
124 | |||
125 | /// | ||
126 | /// RezObject | ||
127 | /// | ||
128 | public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | ||
129 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
130 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
131 | { | ||
132 | m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID); | ||
133 | |||
134 | //if (fromTaskID.Equals(UUID.Zero)) | ||
135 | //{ | ||
136 | InventoryItemBase item = new InventoryItemBase(itemID); | ||
137 | item.Owner = remoteClient.AgentId; | ||
138 | item = InventoryService.GetItem(item); | ||
139 | //if (item == null) | ||
140 | //{ // Fetch the item | ||
141 | // item = new InventoryItemBase(); | ||
142 | // item.Owner = remoteClient.AgentId; | ||
143 | // item.ID = itemID; | ||
144 | // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo); | ||
145 | //} | ||
146 | if (item != null) | ||
147 | { | ||
148 | m_assMapper.Get(item.AssetID, remoteClient.AgentId); | ||
149 | |||
150 | } | ||
151 | //} | ||
152 | |||
153 | // OK, we're done fetching. Pass it up to the default RezObject | ||
154 | return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | ||
155 | RezSelected, RemoveItem, fromTaskID, attachment); | ||
156 | |||
157 | } | ||
158 | |||
159 | protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) | ||
160 | { | ||
161 | string userAssetServer = HyperAssets.GetUserAssetServer(sender); | ||
162 | if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) | ||
163 | m_assMapper.Get(item.AssetID, sender); | ||
164 | |||
165 | userAssetServer = HyperAssets.GetUserAssetServer(receiver); | ||
166 | if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer())) | ||
167 | m_assMapper.Post(item.AssetID, receiver); | ||
168 | } | ||
169 | |||
170 | #endregion | ||
171 | |||
172 | } | ||
173 | |||
174 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs deleted file mode 100644 index b1981b6..0000000 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs +++ /dev/null | |||
@@ -1,77 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using OpenMetaverse; | ||
29 | using OpenSim.Framework; | ||
30 | using OpenSim.Framework.Communications.Cache; | ||
31 | using TPFlags = OpenSim.Framework.Constants.TeleportFlags; | ||
32 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
33 | |||
34 | namespace OpenSim.Region.Framework.Scenes.Hypergrid | ||
35 | { | ||
36 | public partial class HGScene : Scene | ||
37 | { | ||
38 | /// <summary> | ||
39 | /// Teleport an avatar to their home region | ||
40 | /// </summary> | ||
41 | /// <param name="agentId"></param> | ||
42 | /// <param name="client"></param> | ||
43 | public override void TeleportClientHome(UUID agentId, IClientAPI client) | ||
44 | { | ||
45 | m_log.Debug("[HGScene]: TeleportClientHome " + client.FirstName + " " + client.LastName); | ||
46 | |||
47 | CachedUserInfo uinfo = CommsManager.UserProfileCacheService.GetUserDetails(agentId); | ||
48 | if (uinfo != null) | ||
49 | { | ||
50 | UserProfileData UserProfile = uinfo.UserProfile; | ||
51 | |||
52 | if (UserProfile != null) | ||
53 | { | ||
54 | GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); | ||
55 | //if (regionInfo != null) | ||
56 | //{ | ||
57 | // UserProfile.HomeRegionID = regionInfo.RegionID; | ||
58 | // //CommsManager.UserService.UpdateUserProfile(UserProfile); | ||
59 | //} | ||
60 | if (regionInfo == null) | ||
61 | { | ||
62 | // can't find the Home region: Tell viewer and abort | ||
63 | client.SendTeleportFailed("Your home-region could not be found."); | ||
64 | return; | ||
65 | } | ||
66 | RequestTeleportLocation( | ||
67 | client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt, | ||
68 | (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome)); | ||
69 | } | ||
70 | } | ||
71 | else | ||
72 | client.SendTeleportFailed("Sorry! I lost your home-region information."); | ||
73 | |||
74 | } | ||
75 | |||
76 | } | ||
77 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs deleted file mode 100644 index 416826c..0000000 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs +++ /dev/null | |||
@@ -1,391 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Net; | ||
31 | using System.Reflection; | ||
32 | using System.Threading; | ||
33 | using log4net; | ||
34 | using OpenMetaverse; | ||
35 | using OpenSim.Framework; | ||
36 | using OpenSim.Framework.Client; | ||
37 | using OpenSim.Framework.Communications; | ||
38 | using OpenSim.Framework.Communications.Cache; | ||
39 | using OpenSim.Framework.Capabilities; | ||
40 | using OpenSim.Region.Framework.Interfaces; | ||
41 | using OpenSim.Services.Interfaces; | ||
42 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
43 | |||
44 | namespace OpenSim.Region.Framework.Scenes.Hypergrid | ||
45 | { | ||
46 | public class HGSceneCommunicationService : SceneCommunicationService | ||
47 | { | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private IHyperlinkService m_hg; | ||
51 | IHyperlinkService HyperlinkService | ||
52 | { | ||
53 | get | ||
54 | { | ||
55 | if (m_hg == null) | ||
56 | m_hg = m_scene.RequestModuleInterface<IHyperlinkService>(); | ||
57 | return m_hg; | ||
58 | } | ||
59 | } | ||
60 | |||
61 | public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan) | ||
62 | { | ||
63 | } | ||
64 | |||
65 | |||
66 | /// <summary> | ||
67 | /// Try to teleport an agent to a new region. | ||
68 | /// </summary> | ||
69 | /// <param name="remoteClient"></param> | ||
70 | /// <param name="RegionHandle"></param> | ||
71 | /// <param name="position"></param> | ||
72 | /// <param name="lookAt"></param> | ||
73 | /// <param name="flags"></param> | ||
74 | public override void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position, | ||
75 | Vector3 lookAt, uint teleportFlags) | ||
76 | { | ||
77 | if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID)) | ||
78 | return; | ||
79 | |||
80 | bool destRegionUp = true; | ||
81 | |||
82 | IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>(); | ||
83 | |||
84 | // Reset animations; the viewer does that in teleports. | ||
85 | avatar.Animator.ResetAnimations(); | ||
86 | |||
87 | if (regionHandle == m_regionInfo.RegionHandle) | ||
88 | { | ||
89 | // Teleport within the same region | ||
90 | if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0) | ||
91 | { | ||
92 | Vector3 emergencyPos = new Vector3(128, 128, 128); | ||
93 | |||
94 | m_log.WarnFormat( | ||
95 | "[HGSceneCommService]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", | ||
96 | position, avatar.Name, avatar.UUID, emergencyPos); | ||
97 | position = emergencyPos; | ||
98 | } | ||
99 | // TODO: Get proper AVG Height | ||
100 | float localAVHeight = 1.56f; | ||
101 | |||
102 | float posZLimit = 22; | ||
103 | |||
104 | if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize) | ||
105 | { | ||
106 | posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y]; | ||
107 | } | ||
108 | |||
109 | float newPosZ = posZLimit + localAVHeight; | ||
110 | if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | ||
111 | { | ||
112 | position.Z = newPosZ; | ||
113 | } | ||
114 | |||
115 | // Only send this if the event queue is null | ||
116 | if (eq == null) | ||
117 | avatar.ControllingClient.SendTeleportLocationStart(); | ||
118 | |||
119 | |||
120 | avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); | ||
121 | avatar.Teleport(position); | ||
122 | } | ||
123 | else | ||
124 | { | ||
125 | uint x = 0, y = 0; | ||
126 | Utils.LongToUInts(regionHandle, out x, out y); | ||
127 | GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); | ||
128 | |||
129 | if (reg != null) | ||
130 | { | ||
131 | |||
132 | uint newRegionX = (uint)(reg.RegionHandle >> 40); | ||
133 | uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); | ||
134 | uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); | ||
135 | uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); | ||
136 | |||
137 | /// | ||
138 | /// Hypergrid mod start | ||
139 | /// | ||
140 | /// | ||
141 | bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null); | ||
142 | bool isHomeUser = true; | ||
143 | ulong realHandle = regionHandle; | ||
144 | CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID); | ||
145 | if (uinfo != null) | ||
146 | { | ||
147 | isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID); | ||
148 | realHandle = m_hg.FindRegionHandle(regionHandle); | ||
149 | m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString()); | ||
150 | } | ||
151 | /// | ||
152 | /// Hypergrid mod stop | ||
153 | /// | ||
154 | /// | ||
155 | |||
156 | if (eq == null) | ||
157 | avatar.ControllingClient.SendTeleportLocationStart(); | ||
158 | |||
159 | |||
160 | // Let's do DNS resolution only once in this process, please! | ||
161 | // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, | ||
162 | // it's actually doing a lot of work. | ||
163 | IPEndPoint endPoint = reg.ExternalEndPoint; | ||
164 | if (endPoint.Address == null) | ||
165 | { | ||
166 | // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses. | ||
167 | destRegionUp = false; | ||
168 | } | ||
169 | |||
170 | if (destRegionUp) | ||
171 | { | ||
172 | // Fixing a bug where teleporting while sitting results in the avatar ending up removed from | ||
173 | // both regions | ||
174 | if (avatar.ParentID != (uint)0) | ||
175 | avatar.StandUp(); | ||
176 | |||
177 | if (!avatar.ValidateAttachments()) | ||
178 | { | ||
179 | avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); | ||
180 | return; | ||
181 | } | ||
182 | |||
183 | // the avatar.Close below will clear the child region list. We need this below for (possibly) | ||
184 | // closing the child agents, so save it here (we need a copy as it is Clear()-ed). | ||
185 | //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList()); | ||
186 | // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport | ||
187 | // failure at this point (unlike a border crossing failure). So perhaps this can never fail | ||
188 | // once we reach here... | ||
189 | //avatar.Scene.RemoveCapsHandler(avatar.UUID); | ||
190 | |||
191 | string capsPath = String.Empty; | ||
192 | AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo(); | ||
193 | agentCircuit.BaseFolder = UUID.Zero; | ||
194 | agentCircuit.InventoryFolder = UUID.Zero; | ||
195 | agentCircuit.startpos = position; | ||
196 | agentCircuit.child = true; | ||
197 | if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY)) | ||
198 | { | ||
199 | // brand new agent, let's create a new caps seed | ||
200 | agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
201 | } | ||
202 | |||
203 | string reason = String.Empty; | ||
204 | |||
205 | //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit)) | ||
206 | if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason)) | ||
207 | { | ||
208 | avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}", | ||
209 | reason)); | ||
210 | return; | ||
211 | } | ||
212 | |||
213 | // Let's close some agents | ||
214 | if (isHyperLink) // close them all except this one | ||
215 | { | ||
216 | List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles); | ||
217 | regions.Remove(avatar.Scene.RegionInfo.RegionHandle); | ||
218 | SendCloseChildAgentConnections(avatar.UUID, regions); | ||
219 | } | ||
220 | else // close just a few | ||
221 | avatar.CloseChildAgents(newRegionX, newRegionY); | ||
222 | |||
223 | if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY) || isHyperLink) | ||
224 | { | ||
225 | capsPath | ||
226 | = "http://" | ||
227 | + reg.ExternalHostName | ||
228 | + ":" | ||
229 | + reg.HttpPort | ||
230 | + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | ||
231 | |||
232 | if (eq != null) | ||
233 | { | ||
234 | #region IP Translation for NAT | ||
235 | IClientIPEndpoint ipepClient; | ||
236 | if (avatar.ClientView.TryGet(out ipepClient)) | ||
237 | { | ||
238 | endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); | ||
239 | } | ||
240 | #endregion | ||
241 | |||
242 | eq.EnableSimulator(realHandle, endPoint, avatar.UUID); | ||
243 | |||
244 | // ES makes the client send a UseCircuitCode message to the destination, | ||
245 | // which triggers a bunch of things there. | ||
246 | // So let's wait | ||
247 | Thread.Sleep(2000); | ||
248 | |||
249 | eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath); | ||
250 | } | ||
251 | else | ||
252 | { | ||
253 | avatar.ControllingClient.InformClientOfNeighbour(realHandle, endPoint); | ||
254 | // TODO: make Event Queue disablable! | ||
255 | } | ||
256 | } | ||
257 | else | ||
258 | { | ||
259 | // child agent already there | ||
260 | agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle); | ||
261 | capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort | ||
262 | + "/CAPS/" + agentCircuit.CapsPath + "0000/"; | ||
263 | } | ||
264 | |||
265 | //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, | ||
266 | // position, false); | ||
267 | |||
268 | //if (!m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, | ||
269 | // position, false)) | ||
270 | //{ | ||
271 | // avatar.ControllingClient.SendTeleportFailed("Problem with destination."); | ||
272 | // // We should close that agent we just created over at destination... | ||
273 | // List<ulong> lst = new List<ulong>(); | ||
274 | // lst.Add(realHandle); | ||
275 | // SendCloseChildAgentAsync(avatar.UUID, lst); | ||
276 | // return; | ||
277 | //} | ||
278 | |||
279 | SetInTransit(avatar.UUID); | ||
280 | // Let's send a full update of the agent. This is a synchronous call. | ||
281 | AgentData agent = new AgentData(); | ||
282 | avatar.CopyTo(agent); | ||
283 | agent.Position = position; | ||
284 | agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort + | ||
285 | "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/"; | ||
286 | |||
287 | m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent); | ||
288 | |||
289 | m_log.DebugFormat( | ||
290 | "[CAPS]: Sending new CAPS seed url {0} to client {1}", agentCircuit.CapsPath, avatar.UUID); | ||
291 | |||
292 | |||
293 | /// | ||
294 | /// Hypergrid mod: realHandle instead of reg.RegionHandle | ||
295 | /// | ||
296 | /// | ||
297 | if (eq != null) | ||
298 | { | ||
299 | eq.TeleportFinishEvent(realHandle, 13, endPoint, | ||
300 | 4, teleportFlags, capsPath, avatar.UUID); | ||
301 | } | ||
302 | else | ||
303 | { | ||
304 | avatar.ControllingClient.SendRegionTeleport(realHandle, 13, endPoint, 4, | ||
305 | teleportFlags, capsPath); | ||
306 | } | ||
307 | /// | ||
308 | /// Hypergrid mod stop | ||
309 | /// | ||
310 | |||
311 | |||
312 | // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which | ||
313 | // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation | ||
314 | // that the client contacted the destination before we send the attachments and close things here. | ||
315 | if (!WaitForCallback(avatar.UUID)) | ||
316 | { | ||
317 | // Client never contacted destination. Let's restore everything back | ||
318 | avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination."); | ||
319 | |||
320 | ResetFromTransit(avatar.UUID); | ||
321 | // Yikes! We should just have a ref to scene here. | ||
322 | avatar.Scene.InformClientOfNeighbours(avatar); | ||
323 | |||
324 | // Finally, kill the agent we just created at the destination. | ||
325 | m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID); | ||
326 | |||
327 | return; | ||
328 | } | ||
329 | |||
330 | // Can't go back from here | ||
331 | if (KiPrimitive != null) | ||
332 | { | ||
333 | KiPrimitive(avatar.LocalId); | ||
334 | } | ||
335 | |||
336 | avatar.MakeChildAgent(); | ||
337 | |||
338 | // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it | ||
339 | avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true); | ||
340 | |||
341 | |||
342 | // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone | ||
343 | /// | ||
344 | /// Hypergrid mod: extra check for isHyperLink | ||
345 | /// | ||
346 | if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY) || isHyperLink) | ||
347 | { | ||
348 | Thread.Sleep(5000); | ||
349 | avatar.Close(); | ||
350 | CloseConnection(avatar.UUID); | ||
351 | } | ||
352 | // if (teleport success) // seems to be always success here | ||
353 | // the user may change their profile information in other region, | ||
354 | // so the userinfo in UserProfileCache is not reliable any more, delete it | ||
355 | if (avatar.Scene.NeedSceneCacheClear(avatar.UUID) || isHyperLink) | ||
356 | { | ||
357 | m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID); | ||
358 | m_log.DebugFormat( | ||
359 | "[HGSceneCommService]: User {0} is going to another region, profile cache removed", | ||
360 | avatar.UUID); | ||
361 | } | ||
362 | } | ||
363 | else | ||
364 | { | ||
365 | avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); | ||
366 | } | ||
367 | } | ||
368 | else | ||
369 | { | ||
370 | // TP to a place that doesn't exist (anymore) | ||
371 | // Inform the viewer about that | ||
372 | avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore"); | ||
373 | |||
374 | // and set the map-tile to '(Offline)' | ||
375 | uint regX, regY; | ||
376 | Utils.LongToUInts(regionHandle, out regX, out regY); | ||
377 | |||
378 | MapBlockData block = new MapBlockData(); | ||
379 | block.X = (ushort)(regX / Constants.RegionSize); | ||
380 | block.Y = (ushort)(regY / Constants.RegionSize); | ||
381 | block.Access = 254; // == not there | ||
382 | |||
383 | List<MapBlockData> blocks = new List<MapBlockData>(); | ||
384 | blocks.Add(block); | ||
385 | avatar.ControllingClient.SendMapBlock(blocks, 0); | ||
386 | } | ||
387 | } | ||
388 | } | ||
389 | |||
390 | } | ||
391 | } | ||
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs index e9660b1..d25d5dd 100644 --- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs +++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs | |||
@@ -36,8 +36,7 @@ using OpenMetaverse; | |||
36 | using OpenMetaverse.StructuredData; | 36 | using OpenMetaverse.StructuredData; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.Communications.Services; | 39 | |
40 | using OpenSim.Framework.Communications.Cache; | ||
41 | using OpenSim.Framework.Console; | 40 | using OpenSim.Framework.Console; |
42 | using OpenSim.Framework.Servers; | 41 | using OpenSim.Framework.Servers; |
43 | using OpenSim.Framework.Servers.HttpServer; | 42 | using OpenSim.Framework.Servers.HttpServer; |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs index ffbf745..cadb858 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs | |||
@@ -35,7 +35,7 @@ using OpenMetaverse; | |||
35 | using OpenMetaverse.Packets; | 35 | using OpenMetaverse.Packets; |
36 | using log4net; | 36 | using log4net; |
37 | using OpenSim.Framework; | 37 | using OpenSim.Framework; |
38 | using OpenSim.Framework.Communications.Cache; | 38 | |
39 | using OpenSim.Region.Framework; | 39 | using OpenSim.Region.Framework; |
40 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
41 | using OpenSim.Region.Framework.Scenes.Serialization; | 41 | using OpenSim.Region.Framework.Scenes.Serialization; |
@@ -101,12 +101,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
101 | { | 101 | { |
102 | userlevel = 1; | 102 | userlevel = 1; |
103 | } | 103 | } |
104 | // TODO: remove this cruft once MasterAvatar is fully deprecated | ||
105 | // | ||
106 | if (m_regInfo.MasterAvatarAssignedUUID == AgentID) | ||
107 | { | ||
108 | userlevel = 2; | ||
109 | } | ||
110 | EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel); | 104 | EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel); |
111 | } | 105 | } |
112 | else | 106 | else |
@@ -132,61 +126,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
132 | } | 126 | } |
133 | 127 | ||
134 | /// <summary> | 128 | /// <summary> |
135 | /// Capability originating call to update the asset of an item in an agent's inventory | ||
136 | /// </summary> | ||
137 | /// <param name="remoteClient"></param> | ||
138 | /// <param name="itemID"></param> | ||
139 | /// <param name="data"></param> | ||
140 | /// <returns></returns> | ||
141 | public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data) | ||
142 | { | ||
143 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
144 | item = InventoryService.GetItem(item); | ||
145 | |||
146 | if (item != null) | ||
147 | { | ||
148 | if ((InventoryType)item.InvType == InventoryType.Notecard) | ||
149 | { | ||
150 | if (!Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId)) | ||
151 | { | ||
152 | remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false); | ||
153 | return UUID.Zero; | ||
154 | } | ||
155 | |||
156 | remoteClient.SendAgentAlertMessage("Notecard saved", false); | ||
157 | } | ||
158 | else if ((InventoryType)item.InvType == InventoryType.LSL) | ||
159 | { | ||
160 | if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId)) | ||
161 | { | ||
162 | remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false); | ||
163 | return UUID.Zero; | ||
164 | } | ||
165 | |||
166 | remoteClient.SendAgentAlertMessage("Script saved", false); | ||
167 | } | ||
168 | |||
169 | AssetBase asset = | ||
170 | CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data); | ||
171 | item.AssetID = asset.FullID; | ||
172 | AssetService.Store(asset); | ||
173 | |||
174 | InventoryService.UpdateItem(item); | ||
175 | |||
176 | // remoteClient.SendInventoryItemCreateUpdate(item); | ||
177 | return (asset.FullID); | ||
178 | } | ||
179 | else | ||
180 | { | ||
181 | m_log.ErrorFormat( | ||
182 | "[AGENT INVENTORY]: Could not find item {0} for caps inventory update", | ||
183 | itemID); | ||
184 | } | ||
185 | |||
186 | return UUID.Zero; | ||
187 | } | ||
188 | |||
189 | /// <summary> | ||
190 | /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> | 129 | /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> |
191 | /// </summary> | 130 | /// </summary> |
192 | public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) | 131 | public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) |
@@ -195,7 +134,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
195 | 134 | ||
196 | if (TryGetAvatar(avatarId, out avatar)) | 135 | if (TryGetAvatar(avatarId, out avatar)) |
197 | { | 136 | { |
198 | return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); | 137 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); |
138 | if (invAccess != null) | ||
139 | return invAccess.CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); | ||
199 | } | 140 | } |
200 | else | 141 | else |
201 | { | 142 | { |
@@ -251,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
251 | return new ArrayList(); | 192 | return new ArrayList(); |
252 | } | 193 | } |
253 | 194 | ||
254 | AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data); | 195 | AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId); |
255 | AssetService.Store(asset); | 196 | AssetService.Store(asset); |
256 | 197 | ||
257 | if (isScriptRunning) | 198 | if (isScriptRunning) |
@@ -478,7 +419,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
478 | itemCopy.SaleType = item.SaleType; | 419 | itemCopy.SaleType = item.SaleType; |
479 | 420 | ||
480 | if (InventoryService.AddItem(itemCopy)) | 421 | if (InventoryService.AddItem(itemCopy)) |
481 | TransferInventoryAssets(itemCopy, senderId, recipient); | 422 | { |
423 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); | ||
424 | if (invAccess != null) | ||
425 | invAccess.TransferInventoryAssets(itemCopy, senderId, recipient); | ||
426 | } | ||
482 | 427 | ||
483 | if (!Permissions.BypassPermissions()) | 428 | if (!Permissions.BypassPermissions()) |
484 | { | 429 | { |
@@ -500,10 +445,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
500 | 445 | ||
501 | } | 446 | } |
502 | 447 | ||
503 | protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver) | ||
504 | { | ||
505 | } | ||
506 | |||
507 | /// <summary> | 448 | /// <summary> |
508 | /// Give an entire inventory folder from one user to another. The entire contents (including all descendent | 449 | /// Give an entire inventory folder from one user to another. The entire contents (including all descendent |
509 | /// folders) is given. | 450 | /// folders) is given. |
@@ -573,7 +514,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
573 | "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", | 514 | "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", |
574 | remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); | 515 | remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); |
575 | 516 | ||
576 | InventoryItemBase item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(oldItemID); | 517 | InventoryItemBase item = null; |
518 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) | ||
519 | item = LibraryService.LibraryRootFolder.FindItem(oldItemID); | ||
577 | 520 | ||
578 | if (item == null) | 521 | if (item == null) |
579 | { | 522 | { |
@@ -627,15 +570,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
627 | /// <summary> | 570 | /// <summary> |
628 | /// Create a new asset data structure. | 571 | /// Create a new asset data structure. |
629 | /// </summary> | 572 | /// </summary> |
630 | /// <param name="name"></param> | 573 | private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, UUID creatorID) |
631 | /// <param name="description"></param> | ||
632 | /// <param name="invType"></param> | ||
633 | /// <param name="assetType"></param> | ||
634 | /// <param name="data"></param> | ||
635 | /// <returns></returns> | ||
636 | private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data) | ||
637 | { | 574 | { |
638 | AssetBase asset = new AssetBase(UUID.Random(), name, assetType); | 575 | AssetBase asset = new AssetBase(UUID.Random(), name, assetType, creatorID.ToString()); |
639 | asset.Description = description; | 576 | asset.Description = description; |
640 | asset.Data = (data == null) ? new byte[1] : data; | 577 | asset.Data = (data == null) ? new byte[1] : data; |
641 | 578 | ||
@@ -745,13 +682,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
745 | 682 | ||
746 | if (transactionID == UUID.Zero) | 683 | if (transactionID == UUID.Zero) |
747 | { | 684 | { |
748 | CachedUserInfo userInfo | 685 | ScenePresence presence; |
749 | = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); | 686 | if (TryGetAvatar(remoteClient.AgentId, out presence)) |
750 | |||
751 | if (userInfo != null) | ||
752 | { | 687 | { |
753 | ScenePresence presence; | ||
754 | TryGetAvatar(remoteClient.AgentId, out presence); | ||
755 | byte[] data = null; | 688 | byte[] data = null; |
756 | 689 | ||
757 | if (invType == (sbyte)InventoryType.Landmark && presence != null) | 690 | if (invType == (sbyte)InventoryType.Landmark && presence != null) |
@@ -765,7 +698,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
765 | data = Encoding.ASCII.GetBytes(strdata); | 698 | data = Encoding.ASCII.GetBytes(strdata); |
766 | } | 699 | } |
767 | 700 | ||
768 | AssetBase asset = CreateAsset(name, description, assetType, data); | 701 | AssetBase asset = CreateAsset(name, description, assetType, data, remoteClient.AgentId); |
769 | AssetService.Store(asset); | 702 | AssetService.Store(asset); |
770 | 703 | ||
771 | CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate); | 704 | CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate); |
@@ -773,7 +706,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
773 | else | 706 | else |
774 | { | 707 | { |
775 | m_log.ErrorFormat( | 708 | m_log.ErrorFormat( |
776 | "userInfo for agent uuid {0} unexpectedly null in CreateNewInventoryItem", | 709 | "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem", |
777 | remoteClient.AgentId); | 710 | remoteClient.AgentId); |
778 | } | 711 | } |
779 | } | 712 | } |
@@ -1170,15 +1103,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1170 | 1103 | ||
1171 | private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) | 1104 | private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) |
1172 | { | 1105 | { |
1173 | m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); | 1106 | if (folder == null) |
1107 | return; | ||
1108 | |||
1109 | // Fetch the folder contents | ||
1174 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); | 1110 | InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); |
1175 | InventoryFolderBase containingFolder = new InventoryFolderBase(); | 1111 | |
1176 | containingFolder.ID = folder.ID; | 1112 | // Fetch the folder itself to get its current version |
1177 | containingFolder.Owner = client.AgentId; | 1113 | InventoryFolderBase containingFolder = new InventoryFolderBase(folder.ID, client.AgentId); |
1178 | containingFolder = InventoryService.GetFolder(containingFolder); | 1114 | containingFolder = InventoryService.GetFolder(containingFolder); |
1179 | int version = containingFolder.Version; | ||
1180 | 1115 | ||
1181 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); | 1116 | //m_log.DebugFormat("[AGENT INVENTORY]: Sending inventory folder contents ({0} nodes) for \"{1}\" to {2} {3}", |
1117 | // contents.Folders.Count + contents.Items.Count, containingFolder.Name, client.FirstName, client.LastName); | ||
1118 | |||
1119 | if (containingFolder != null) | ||
1120 | client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, containingFolder.Version, fetchFolders, fetchItems); | ||
1182 | } | 1121 | } |
1183 | 1122 | ||
1184 | /// <summary> | 1123 | /// <summary> |
@@ -1220,9 +1159,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1220 | item = InventoryService.GetItem(item); | 1159 | item = InventoryService.GetItem(item); |
1221 | 1160 | ||
1222 | // Try library | 1161 | // Try library |
1223 | if (null == item) | 1162 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1224 | { | 1163 | { |
1225 | item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 1164 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1226 | } | 1165 | } |
1227 | 1166 | ||
1228 | if (item != null) | 1167 | if (item != null) |
@@ -1289,9 +1228,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1289 | 1228 | ||
1290 | // Try library | 1229 | // Try library |
1291 | // XXX clumsy, possibly should be one call | 1230 | // XXX clumsy, possibly should be one call |
1292 | if (null == item) | 1231 | if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null) |
1293 | { | 1232 | { |
1294 | item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); | 1233 | item = LibraryService.LibraryRootFolder.FindItem(itemID); |
1295 | } | 1234 | } |
1296 | 1235 | ||
1297 | if (item != null) | 1236 | if (item != null) |
@@ -1348,7 +1287,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1348 | itemBase.InvType, part.UUID, remoteClient.AgentId)) | 1287 | itemBase.InvType, part.UUID, remoteClient.AgentId)) |
1349 | return; | 1288 | return; |
1350 | 1289 | ||
1351 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}")); | 1290 | AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, |
1291 | Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"), | ||
1292 | remoteClient.AgentId); | ||
1352 | AssetService.Store(asset); | 1293 | AssetService.Store(asset); |
1353 | 1294 | ||
1354 | TaskInventoryItem taskItem = new TaskInventoryItem(); | 1295 | TaskInventoryItem taskItem = new TaskInventoryItem(); |
@@ -1617,237 +1558,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1617 | } | 1558 | } |
1618 | } | 1559 | } |
1619 | 1560 | ||
1620 | /// <summary> | ||
1621 | /// Delete a scene object from a scene and place in the given avatar's inventory. | ||
1622 | /// Returns the UUID of the newly created asset. | ||
1623 | /// </summary> | ||
1624 | /// <param name="action"></param> | ||
1625 | /// <param name="folderID"></param> | ||
1626 | /// <param name="objectGroup"></param> | ||
1627 | /// <param name="remoteClient"> </param> | ||
1628 | public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID, | ||
1629 | SceneObjectGroup objectGroup, IClientAPI remoteClient) | ||
1630 | { | ||
1631 | UUID assetID = UUID.Zero; | ||
1632 | |||
1633 | Vector3 inventoryStoredPosition = new Vector3 | ||
1634 | (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1635 | ? 250 | ||
1636 | : objectGroup.AbsolutePosition.X) | ||
1637 | , | ||
1638 | (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize) | ||
1639 | ? 250 | ||
1640 | : objectGroup.AbsolutePosition.X, | ||
1641 | objectGroup.AbsolutePosition.Z); | ||
1642 | |||
1643 | Vector3 originalPosition = objectGroup.AbsolutePosition; | ||
1644 | |||
1645 | objectGroup.AbsolutePosition = inventoryStoredPosition; | ||
1646 | |||
1647 | string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup); | ||
1648 | |||
1649 | objectGroup.AbsolutePosition = originalPosition; | ||
1650 | |||
1651 | // Get the user info of the item destination | ||
1652 | // | ||
1653 | UUID userID = UUID.Zero; | ||
1654 | |||
1655 | if (action == DeRezAction.Take || action == DeRezAction.TakeCopy || | ||
1656 | action == DeRezAction.SaveToExistingUserInventoryItem) | ||
1657 | { | ||
1658 | // Take or take copy require a taker | ||
1659 | // Saving changes requires a local user | ||
1660 | // | ||
1661 | if (remoteClient == null) | ||
1662 | return UUID.Zero; | ||
1663 | |||
1664 | userID = remoteClient.AgentId; | ||
1665 | } | ||
1666 | else | ||
1667 | { | ||
1668 | // All returns / deletes go to the object owner | ||
1669 | // | ||
1670 | |||
1671 | userID = objectGroup.RootPart.OwnerID; | ||
1672 | } | ||
1673 | |||
1674 | if (userID == UUID.Zero) // Can't proceed | ||
1675 | { | ||
1676 | return UUID.Zero; | ||
1677 | } | ||
1678 | |||
1679 | // If we're returning someone's item, it goes back to the | ||
1680 | // owner's Lost And Found folder. | ||
1681 | // Delete is treated like return in this case | ||
1682 | // Deleting your own items makes them go to trash | ||
1683 | // | ||
1684 | |||
1685 | InventoryFolderBase folder = null; | ||
1686 | InventoryItemBase item = null; | ||
1687 | |||
1688 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | ||
1689 | { | ||
1690 | item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID); | ||
1691 | item = InventoryService.GetItem(item); | ||
1692 | |||
1693 | //item = userInfo.RootFolder.FindItem( | ||
1694 | // objectGroup.RootPart.FromUserInventoryItemID); | ||
1695 | |||
1696 | if (null == item) | ||
1697 | { | ||
1698 | m_log.DebugFormat( | ||
1699 | "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.", | ||
1700 | objectGroup.Name, objectGroup.UUID); | ||
1701 | return UUID.Zero; | ||
1702 | } | ||
1703 | } | ||
1704 | else | ||
1705 | { | ||
1706 | // Folder magic | ||
1707 | // | ||
1708 | if (action == DeRezAction.Delete) | ||
1709 | { | ||
1710 | // Deleting someone else's item | ||
1711 | // | ||
1712 | |||
1713 | |||
1714 | if (remoteClient == null || | ||
1715 | objectGroup.OwnerID != remoteClient.AgentId) | ||
1716 | { | ||
1717 | // Folder skeleton may not be loaded and we | ||
1718 | // have to wait for the inventory to find | ||
1719 | // the destination folder | ||
1720 | // | ||
1721 | folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
1722 | } | ||
1723 | else | ||
1724 | { | ||
1725 | // Assume inventory skeleton was loaded during login | ||
1726 | // and all folders can be found | ||
1727 | // | ||
1728 | folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | ||
1729 | } | ||
1730 | } | ||
1731 | else if (action == DeRezAction.Return) | ||
1732 | { | ||
1733 | |||
1734 | // Dump to lost + found unconditionally | ||
1735 | // | ||
1736 | folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
1737 | } | ||
1738 | |||
1739 | if (folderID == UUID.Zero && folder == null) | ||
1740 | { | ||
1741 | if (action == DeRezAction.Delete) | ||
1742 | { | ||
1743 | // Deletes go to trash by default | ||
1744 | // | ||
1745 | folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder); | ||
1746 | } | ||
1747 | else | ||
1748 | { | ||
1749 | // Catch all. Use lost & found | ||
1750 | // | ||
1751 | |||
1752 | folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder); | ||
1753 | } | ||
1754 | } | ||
1755 | |||
1756 | if (folder == null) // None of the above | ||
1757 | { | ||
1758 | //folder = userInfo.RootFolder.FindFolder(folderID); | ||
1759 | folder = new InventoryFolderBase(folderID); | ||
1760 | |||
1761 | if (folder == null) // Nowhere to put it | ||
1762 | { | ||
1763 | return UUID.Zero; | ||
1764 | } | ||
1765 | } | ||
1766 | |||
1767 | item = new InventoryItemBase(); | ||
1768 | item.CreatorId = objectGroup.RootPart.CreatorID.ToString(); | ||
1769 | item.ID = UUID.Random(); | ||
1770 | item.InvType = (int)InventoryType.Object; | ||
1771 | item.Folder = folder.ID; | ||
1772 | item.Owner = userID; | ||
1773 | } | ||
1774 | |||
1775 | AssetBase asset = CreateAsset( | ||
1776 | objectGroup.GetPartName(objectGroup.RootPart.LocalId), | ||
1777 | objectGroup.GetPartDescription(objectGroup.RootPart.LocalId), | ||
1778 | (sbyte)AssetType.Object, | ||
1779 | Utils.StringToBytes(sceneObjectXml)); | ||
1780 | AssetService.Store(asset); | ||
1781 | assetID = asset.FullID; | ||
1782 | |||
1783 | if (DeRezAction.SaveToExistingUserInventoryItem == action) | ||
1784 | { | ||
1785 | item.AssetID = asset.FullID; | ||
1786 | InventoryService.UpdateItem(item); | ||
1787 | } | ||
1788 | else | ||
1789 | { | ||
1790 | item.AssetID = asset.FullID; | ||
1791 | |||
1792 | if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions()) | ||
1793 | { | ||
1794 | uint perms=objectGroup.GetEffectivePermissions(); | ||
1795 | uint nextPerms=(perms & 7) << 13; | ||
1796 | if ((nextPerms & (uint)PermissionMask.Copy) == 0) | ||
1797 | perms &= ~(uint)PermissionMask.Copy; | ||
1798 | if ((nextPerms & (uint)PermissionMask.Transfer) == 0) | ||
1799 | perms &= ~(uint)PermissionMask.Transfer; | ||
1800 | if ((nextPerms & (uint)PermissionMask.Modify) == 0) | ||
1801 | perms &= ~(uint)PermissionMask.Modify; | ||
1802 | |||
1803 | item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask; | ||
1804 | item.CurrentPermissions = item.BasePermissions; | ||
1805 | item.NextPermissions = objectGroup.RootPart.NextOwnerMask; | ||
1806 | item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask; | ||
1807 | item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask; | ||
1808 | item.CurrentPermissions |= 8; // Slam! | ||
1809 | } | ||
1810 | else | ||
1811 | { | ||
1812 | uint ownerPerms = objectGroup.GetEffectivePermissions(); | ||
1813 | if ((objectGroup.RootPart.OwnerMask & (uint)PermissionMask.Modify) != 0) | ||
1814 | ownerPerms |= (uint)PermissionMask.Modify; | ||
1815 | |||
1816 | item.BasePermissions = ownerPerms; | ||
1817 | item.CurrentPermissions = ownerPerms; | ||
1818 | |||
1819 | item.NextPermissions = objectGroup.RootPart.NextOwnerMask; | ||
1820 | item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask; | ||
1821 | item.GroupPermissions = objectGroup.RootPart.GroupMask; | ||
1822 | |||
1823 | item.CurrentPermissions |= 8; // Slam! | ||
1824 | } | ||
1825 | |||
1826 | // TODO: add the new fields (Flags, Sale info, etc) | ||
1827 | item.CreationDate = Util.UnixTimeSinceEpoch(); | ||
1828 | item.Description = asset.Description; | ||
1829 | item.Name = asset.Name; | ||
1830 | item.AssetType = asset.Type; | ||
1831 | |||
1832 | InventoryService.AddItem(item); | ||
1833 | |||
1834 | if (remoteClient != null && item.Owner == remoteClient.AgentId) | ||
1835 | { | ||
1836 | remoteClient.SendInventoryItemCreateUpdate(item, 0); | ||
1837 | } | ||
1838 | else | ||
1839 | { | ||
1840 | ScenePresence notifyUser = GetScenePresence(item.Owner); | ||
1841 | if (notifyUser != null) | ||
1842 | { | ||
1843 | notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0); | ||
1844 | } | ||
1845 | } | ||
1846 | } | ||
1847 | |||
1848 | return assetID; | ||
1849 | } | ||
1850 | |||
1851 | public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) | 1561 | public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) |
1852 | { | 1562 | { |
1853 | SceneObjectGroup objectGroup = grp; | 1563 | SceneObjectGroup objectGroup = grp; |
@@ -1874,7 +1584,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1874 | objectGroup.GetPartName(objectGroup.LocalId), | 1584 | objectGroup.GetPartName(objectGroup.LocalId), |
1875 | objectGroup.GetPartDescription(objectGroup.LocalId), | 1585 | objectGroup.GetPartDescription(objectGroup.LocalId), |
1876 | (sbyte)AssetType.Object, | 1586 | (sbyte)AssetType.Object, |
1877 | Utils.StringToBytes(sceneObjectXml)); | 1587 | Utils.StringToBytes(sceneObjectXml), |
1588 | remoteClient.AgentId); | ||
1878 | AssetService.Store(asset); | 1589 | AssetService.Store(asset); |
1879 | 1590 | ||
1880 | item.AssetID = asset.FullID; | 1591 | item.AssetID = asset.FullID; |
@@ -1921,7 +1632,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
1921 | grp.GetPartName(grp.LocalId), | 1632 | grp.GetPartName(grp.LocalId), |
1922 | grp.GetPartDescription(grp.LocalId), | 1633 | grp.GetPartDescription(grp.LocalId), |
1923 | (sbyte)AssetType.Object, | 1634 | (sbyte)AssetType.Object, |
1924 | Utils.StringToBytes(sceneObjectXml)); | 1635 | Utils.StringToBytes(sceneObjectXml), |
1636 | remoteClient.AgentId); | ||
1925 | AssetService.Store(asset); | 1637 | AssetService.Store(asset); |
1926 | 1638 | ||
1927 | InventoryItemBase item = new InventoryItemBase(); | 1639 | InventoryItemBase item = new InventoryItemBase(); |
@@ -1988,225 +1700,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1988 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | 1700 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, |
1989 | bool RezSelected, bool RemoveItem, UUID fromTaskID) | 1701 | bool RezSelected, bool RemoveItem, UUID fromTaskID) |
1990 | { | 1702 | { |
1991 | RezObject( | 1703 | IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>(); |
1992 | remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, | 1704 | if (invAccess != null) |
1993 | RezSelected, RemoveItem, fromTaskID, false); | 1705 | invAccess.RezObject( |
1994 | } | 1706 | remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, |
1995 | 1707 | RezSelected, RemoveItem, fromTaskID, false); | |
1996 | /// <summary> | ||
1997 | /// Rez an object into the scene from the user's inventory | ||
1998 | /// </summary> | ||
1999 | /// <param name="remoteClient"></param> | ||
2000 | /// <param name="itemID"></param> | ||
2001 | /// <param name="RayEnd"></param> | ||
2002 | /// <param name="RayStart"></param> | ||
2003 | /// <param name="RayTargetID"></param> | ||
2004 | /// <param name="BypassRayCast"></param> | ||
2005 | /// <param name="RayEndIsIntersection"></param> | ||
2006 | /// <param name="RezSelected"></param> | ||
2007 | /// <param name="RemoveItem"></param> | ||
2008 | /// <param name="fromTaskID"></param> | ||
2009 | /// <param name="attachment"></param> | ||
2010 | /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns> | ||
2011 | public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, | ||
2012 | UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, | ||
2013 | bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment) | ||
2014 | { | ||
2015 | // Work out position details | ||
2016 | byte bRayEndIsIntersection = (byte)0; | ||
2017 | |||
2018 | if (RayEndIsIntersection) | ||
2019 | { | ||
2020 | bRayEndIsIntersection = (byte)1; | ||
2021 | } | ||
2022 | else | ||
2023 | { | ||
2024 | bRayEndIsIntersection = (byte)0; | ||
2025 | } | ||
2026 | |||
2027 | Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f); | ||
2028 | |||
2029 | |||
2030 | Vector3 pos = GetNewRezLocation( | ||
2031 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | ||
2032 | BypassRayCast, bRayEndIsIntersection,true,scale, false); | ||
2033 | |||
2034 | // Rez object | ||
2035 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
2036 | item = InventoryService.GetItem(item); | ||
2037 | |||
2038 | if (item != null) | ||
2039 | { | ||
2040 | AssetBase rezAsset = AssetService.Get(item.AssetID.ToString()); | ||
2041 | |||
2042 | if (rezAsset != null) | ||
2043 | { | ||
2044 | UUID itemId = UUID.Zero; | ||
2045 | |||
2046 | // If we have permission to copy then link the rezzed object back to the user inventory | ||
2047 | // item that it came from. This allows us to enable 'save object to inventory' | ||
2048 | if (!Permissions.BypassPermissions()) | ||
2049 | { | ||
2050 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy) | ||
2051 | { | ||
2052 | itemId = item.ID; | ||
2053 | } | ||
2054 | } | ||
2055 | else | ||
2056 | { | ||
2057 | // Brave new fullperm world | ||
2058 | // | ||
2059 | itemId = item.ID; | ||
2060 | } | ||
2061 | |||
2062 | string xmlData = Utils.BytesToString(rezAsset.Data); | ||
2063 | SceneObjectGroup group | ||
2064 | = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData); | ||
2065 | |||
2066 | if (!Permissions.CanRezObject( | ||
2067 | group.Children.Count, remoteClient.AgentId, pos) | ||
2068 | && !attachment) | ||
2069 | { | ||
2070 | // The client operates in no fail mode. It will | ||
2071 | // have already removed the item from the folder | ||
2072 | // if it's no copy. | ||
2073 | // Put it back if it's not an attachment | ||
2074 | // | ||
2075 | if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment)) | ||
2076 | remoteClient.SendBulkUpdateInventory(item); | ||
2077 | return null; | ||
2078 | } | ||
2079 | |||
2080 | group.ResetIDs(); | ||
2081 | |||
2082 | if (attachment) | ||
2083 | { | ||
2084 | group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom; | ||
2085 | group.RootPart.IsAttachment = true; | ||
2086 | } | ||
2087 | |||
2088 | AddNewSceneObject(group, true); | ||
2089 | |||
2090 | // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z); | ||
2091 | // if attachment we set it's asset id so object updates can reflect that | ||
2092 | // if not, we set it's position in world. | ||
2093 | if (!attachment) | ||
2094 | { | ||
2095 | float offsetHeight = 0; | ||
2096 | pos = GetNewRezLocation( | ||
2097 | RayStart, RayEnd, RayTargetID, Quaternion.Identity, | ||
2098 | BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false); | ||
2099 | pos.Z += offsetHeight; | ||
2100 | group.AbsolutePosition = pos; | ||
2101 | // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight); | ||
2102 | |||
2103 | } | ||
2104 | else | ||
2105 | { | ||
2106 | group.SetFromItemID(itemID); | ||
2107 | } | ||
2108 | |||
2109 | SceneObjectPart rootPart = null; | ||
2110 | try | ||
2111 | { | ||
2112 | rootPart = group.GetChildPart(group.UUID); | ||
2113 | } | ||
2114 | catch (NullReferenceException) | ||
2115 | { | ||
2116 | string isAttachment = ""; | ||
2117 | |||
2118 | if (attachment) | ||
2119 | isAttachment = " Object was an attachment"; | ||
2120 | |||
2121 | m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment); | ||
2122 | } | ||
2123 | |||
2124 | // Since renaming the item in the inventory does not affect the name stored | ||
2125 | // in the serialization, transfer the correct name from the inventory to the | ||
2126 | // object itself before we rez. | ||
2127 | rootPart.Name = item.Name; | ||
2128 | rootPart.Description = item.Description; | ||
2129 | |||
2130 | List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values); | ||
2131 | |||
2132 | group.SetGroup(remoteClient.ActiveGroupId, remoteClient); | ||
2133 | if (rootPart.OwnerID != item.Owner) | ||
2134 | { | ||
2135 | //Need to kill the for sale here | ||
2136 | rootPart.ObjectSaleType = 0; | ||
2137 | rootPart.SalePrice = 10; | ||
2138 | |||
2139 | if (Permissions.PropagatePermissions()) | ||
2140 | { | ||
2141 | if ((item.CurrentPermissions & 8) != 0) | ||
2142 | { | ||
2143 | foreach (SceneObjectPart part in partList) | ||
2144 | { | ||
2145 | part.EveryoneMask = item.EveryOnePermissions; | ||
2146 | part.NextOwnerMask = item.NextPermissions; | ||
2147 | part.GroupMask = 0; // DO NOT propagate here | ||
2148 | } | ||
2149 | } | ||
2150 | group.ApplyNextOwnerPermissions(); | ||
2151 | } | ||
2152 | } | ||
2153 | |||
2154 | foreach (SceneObjectPart part in partList) | ||
2155 | { | ||
2156 | if (part.OwnerID != item.Owner) | ||
2157 | { | ||
2158 | part.LastOwnerID = part.OwnerID; | ||
2159 | part.OwnerID = item.Owner; | ||
2160 | part.Inventory.ChangeInventoryOwner(item.Owner); | ||
2161 | } | ||
2162 | else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam! | ||
2163 | { | ||
2164 | part.EveryoneMask = item.EveryOnePermissions; | ||
2165 | part.NextOwnerMask = item.NextPermissions; | ||
2166 | |||
2167 | part.GroupMask = 0; // DO NOT propagate here | ||
2168 | } | ||
2169 | } | ||
2170 | |||
2171 | rootPart.TrimPermissions(); | ||
2172 | |||
2173 | if (!attachment) | ||
2174 | { | ||
2175 | if (group.RootPart.Shape.PCode == (byte)PCode.Prim) | ||
2176 | { | ||
2177 | group.ClearPartAttachmentData(); | ||
2178 | } | ||
2179 | } | ||
2180 | |||
2181 | if (!attachment) | ||
2182 | { | ||
2183 | // Fire on_rez | ||
2184 | group.CreateScriptInstances(0, true, DefaultScriptEngine, 0); | ||
2185 | |||
2186 | rootPart.ScheduleFullUpdate(); | ||
2187 | } | ||
2188 | |||
2189 | if (!Permissions.BypassPermissions()) | ||
2190 | { | ||
2191 | if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) | ||
2192 | { | ||
2193 | // If this is done on attachments, no | ||
2194 | // copy ones will be lost, so avoid it | ||
2195 | // | ||
2196 | if (!attachment) | ||
2197 | { | ||
2198 | List<UUID> uuids = new List<UUID>(); | ||
2199 | uuids.Add(item.ID); | ||
2200 | InventoryService.DeleteItems(item.Owner, uuids); | ||
2201 | } | ||
2202 | } | ||
2203 | } | ||
2204 | |||
2205 | return rootPart.ParentGroup; | ||
2206 | } | ||
2207 | } | ||
2208 | |||
2209 | return null; | ||
2210 | } | 1708 | } |
2211 | 1709 | ||
2212 | /// <summary> | 1710 | /// <summary> |
@@ -2349,94 +1847,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2349 | EventManager.TriggerOnAttach(localID, itemID, avatarID); | 1847 | EventManager.TriggerOnAttach(localID, itemID, avatarID); |
2350 | } | 1848 | } |
2351 | 1849 | ||
2352 | public UUID RezSingleAttachment(IClientAPI remoteClient, UUID itemID, | ||
2353 | uint AttachmentPt) | ||
2354 | { | ||
2355 | SceneObjectGroup att = m_sceneGraph.RezSingleAttachment(remoteClient, itemID, AttachmentPt); | ||
2356 | |||
2357 | if (att == null) | ||
2358 | { | ||
2359 | DetachSingleAttachmentToInv(itemID, remoteClient); | ||
2360 | return UUID.Zero; | ||
2361 | } | ||
2362 | |||
2363 | return RezSingleAttachment(att, remoteClient, itemID, AttachmentPt); | ||
2364 | } | ||
2365 | |||
2366 | public UUID RezSingleAttachment(SceneObjectGroup att, | ||
2367 | IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | ||
2368 | { | ||
2369 | if (!att.IsDeleted) | ||
2370 | AttachmentPt = att.RootPart.AttachmentPoint; | ||
2371 | |||
2372 | ScenePresence presence; | ||
2373 | if (TryGetAvatar(remoteClient.AgentId, out presence)) | ||
2374 | { | ||
2375 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
2376 | item = InventoryService.GetItem(item); | ||
2377 | |||
2378 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); | ||
2379 | } | ||
2380 | return att.UUID; | ||
2381 | } | ||
2382 | |||
2383 | public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, | 1850 | public void RezMultipleAttachments(IClientAPI remoteClient, RezMultipleAttachmentsFromInvPacket.HeaderDataBlock header, |
2384 | RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects) | 1851 | RezMultipleAttachmentsFromInvPacket.ObjectDataBlock[] objects) |
2385 | { | 1852 | { |
2386 | foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects) | 1853 | foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in objects) |
2387 | { | 1854 | { |
2388 | RezSingleAttachment(remoteClient, obj.ItemID, obj.AttachmentPt); | 1855 | AttachmentsModule.RezSingleAttachmentFromInventory(remoteClient, obj.ItemID, obj.AttachmentPt); |
2389 | } | ||
2390 | } | ||
2391 | |||
2392 | /// <summary> | ||
2393 | /// Attach an object. | ||
2394 | /// </summary> | ||
2395 | /// <param name="controllingClient"></param> | ||
2396 | /// <param name="localID"></param> | ||
2397 | /// <param name="attachPoint"></param> | ||
2398 | /// <param name="rot"></param> | ||
2399 | /// <param name="pos"></param> | ||
2400 | /// <param name="silent"></param> | ||
2401 | /// <returns>true if the object was successfully attached, false otherwise</returns> | ||
2402 | public bool AttachObject(IClientAPI controllingClient, uint localID, uint attachPoint, Quaternion rot, Vector3 pos, bool silent) | ||
2403 | { | ||
2404 | return m_sceneGraph.AttachObject(controllingClient, localID, attachPoint, rot, pos, silent); | ||
2405 | } | ||
2406 | |||
2407 | public void AttachObject(IClientAPI remoteClient, uint AttachmentPt, UUID itemID, SceneObjectGroup att) | ||
2408 | { | ||
2409 | if (UUID.Zero == itemID) | ||
2410 | { | ||
2411 | m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error inventory item ID."); | ||
2412 | return; | ||
2413 | } | ||
2414 | |||
2415 | if (0 == AttachmentPt) | ||
2416 | { | ||
2417 | m_log.Error("[SCENE INVENTORY]: Unable to save attachment. Error attachment point."); | ||
2418 | return; | ||
2419 | } | ||
2420 | |||
2421 | if (null == att.RootPart) | ||
2422 | { | ||
2423 | m_log.Error("[SCENE INVENTORY]: Unable to save attachment for a prim without the rootpart!"); | ||
2424 | return; | ||
2425 | } | ||
2426 | |||
2427 | ScenePresence presence; | ||
2428 | if (TryGetAvatar(remoteClient.AgentId, out presence)) | ||
2429 | { | ||
2430 | // XXYY!! | ||
2431 | InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); | ||
2432 | item = InventoryService.GetItem(item); | ||
2433 | presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); | ||
2434 | |||
2435 | if (m_AvatarFactory != null) | ||
2436 | { | ||
2437 | m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
2438 | } | ||
2439 | |||
2440 | } | 1856 | } |
2441 | } | 1857 | } |
2442 | 1858 | ||
@@ -2470,24 +1886,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2470 | SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); | 1886 | SendAttachEvent(part.ParentGroup.LocalId, itemID, UUID.Zero); |
2471 | } | 1887 | } |
2472 | 1888 | ||
2473 | public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) | ||
2474 | { | ||
2475 | ScenePresence presence; | ||
2476 | if (TryGetAvatar(remoteClient.AgentId, out presence)) | ||
2477 | { | ||
2478 | presence.Appearance.DetachAttachment(itemID); | ||
2479 | |||
2480 | // Save avatar attachment information | ||
2481 | if (m_AvatarFactory != null) | ||
2482 | { | ||
2483 | m_log.Info("[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId + ", ItemID: " + itemID); | ||
2484 | m_AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
2485 | } | ||
2486 | } | ||
2487 | |||
2488 | m_sceneGraph.DetachSingleAttachmentToInv(itemID, remoteClient); | ||
2489 | } | ||
2490 | |||
2491 | public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) | 1889 | public void GetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) |
2492 | { | 1890 | { |
2493 | EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); | 1891 | EventManager.TriggerGetScriptRunning(controllingClient, objectID, itemID); |
@@ -2519,6 +1917,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2519 | { | 1917 | { |
2520 | sog.SetOwnerId(ownerID); | 1918 | sog.SetOwnerId(ownerID); |
2521 | sog.SetGroup(groupID, remoteClient); | 1919 | sog.SetGroup(groupID, remoteClient); |
1920 | sog.ScheduleGroupForFullUpdate(); | ||
2522 | 1921 | ||
2523 | foreach (SceneObjectPart child in sog.Children.Values) | 1922 | foreach (SceneObjectPart child in sog.Children.Values) |
2524 | child.Inventory.ChangeInventoryOwner(ownerID); | 1923 | child.Inventory.ChangeInventoryOwner(ownerID); |
@@ -2540,6 +1939,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2540 | sog.SetOwnerId(groupID); | 1939 | sog.SetOwnerId(groupID); |
2541 | sog.ApplyNextOwnerPermissions(); | 1940 | sog.ApplyNextOwnerPermissions(); |
2542 | } | 1941 | } |
1942 | |||
2543 | } | 1943 | } |
2544 | 1944 | ||
2545 | foreach (uint localID in localIDs) | 1945 | foreach (uint localID in localIDs) |
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index ac04dc7..bc10230 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -32,7 +32,7 @@ using OpenMetaverse; | |||
32 | using OpenMetaverse.Packets; | 32 | using OpenMetaverse.Packets; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Communications.Cache; | 35 | using OpenSim.Services.Interfaces; |
36 | 36 | ||
37 | namespace OpenSim.Region.Framework.Scenes | 37 | namespace OpenSim.Region.Framework.Scenes |
38 | { | 38 | { |
@@ -371,14 +371,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
371 | { | 371 | { |
372 | //EventManager.TriggerAvatarPickerRequest(); | 372 | //EventManager.TriggerAvatarPickerRequest(); |
373 | 373 | ||
374 | List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>(); | 374 | List<UserAccount> accounts = UserAccountService.GetUserAccounts(RegionInfo.ScopeID, query); |
375 | AvatarResponses = m_sceneGridService.GenerateAgentPickerRequestResponse(RequestID, query); | 375 | |
376 | if (accounts == null) | ||
377 | return; | ||
376 | 378 | ||
377 | AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); | 379 | AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); |
378 | // TODO: don't create new blocks if recycling an old packet | 380 | // TODO: don't create new blocks if recycling an old packet |
379 | 381 | ||
380 | AvatarPickerReplyPacket.DataBlock[] searchData = | 382 | AvatarPickerReplyPacket.DataBlock[] searchData = |
381 | new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; | 383 | new AvatarPickerReplyPacket.DataBlock[accounts.Count]; |
382 | AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); | 384 | AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); |
383 | 385 | ||
384 | agentData.AgentID = avatarID; | 386 | agentData.AgentID = avatarID; |
@@ -387,16 +389,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
387 | //byte[] bytes = new byte[AvatarResponses.Count*32]; | 389 | //byte[] bytes = new byte[AvatarResponses.Count*32]; |
388 | 390 | ||
389 | int i = 0; | 391 | int i = 0; |
390 | foreach (AvatarPickerAvatar item in AvatarResponses) | 392 | foreach (UserAccount item in accounts) |
391 | { | 393 | { |
392 | UUID translatedIDtem = item.AvatarID; | 394 | UUID translatedIDtem = item.PrincipalID; |
393 | searchData[i] = new AvatarPickerReplyPacket.DataBlock(); | 395 | searchData[i] = new AvatarPickerReplyPacket.DataBlock(); |
394 | searchData[i].AvatarID = translatedIDtem; | 396 | searchData[i].AvatarID = translatedIDtem; |
395 | searchData[i].FirstName = Utils.StringToBytes((string) item.firstName); | 397 | searchData[i].FirstName = Utils.StringToBytes((string) item.FirstName); |
396 | searchData[i].LastName = Utils.StringToBytes((string) item.lastName); | 398 | searchData[i].LastName = Utils.StringToBytes((string) item.LastName); |
397 | i++; | 399 | i++; |
398 | } | 400 | } |
399 | if (AvatarResponses.Count == 0) | 401 | if (accounts.Count == 0) |
400 | { | 402 | { |
401 | searchData = new AvatarPickerReplyPacket.DataBlock[0]; | 403 | searchData = new AvatarPickerReplyPacket.DataBlock[0]; |
402 | } | 404 | } |
@@ -455,7 +457,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
455 | } | 457 | } |
456 | ); | 458 | ); |
457 | } | 459 | } |
458 | 460 | ||
461 | public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) | ||
462 | { | ||
463 | if (LibraryService != null && (LibraryService.LibraryRootFolder.Owner == uuid)) | ||
464 | { | ||
465 | remote_client.SendNameReply(uuid, "Mr", "OpenSim"); | ||
466 | } | ||
467 | else | ||
468 | { | ||
469 | string[] names = GetUserNames(uuid); | ||
470 | if (names.Length == 2) | ||
471 | { | ||
472 | remote_client.SendNameReply(uuid, names[0], names[1]); | ||
473 | } | ||
474 | |||
475 | } | ||
476 | } | ||
477 | |||
459 | /// <summary> | 478 | /// <summary> |
460 | /// Handle a fetch inventory request from the client | 479 | /// Handle a fetch inventory request from the client |
461 | /// </summary> | 480 | /// </summary> |
@@ -464,7 +483,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
464 | /// <param name="ownerID"></param> | 483 | /// <param name="ownerID"></param> |
465 | public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) | 484 | public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) |
466 | { | 485 | { |
467 | if (ownerID == CommsManager.UserProfileCacheService.LibraryRoot.Owner) | 486 | if (LibraryService != null && LibraryService.LibraryRootFolder != null && ownerID == LibraryService.LibraryRootFolder.Owner) |
468 | { | 487 | { |
469 | //m_log.Debug("request info for library item"); | 488 | //m_log.Debug("request info for library item"); |
470 | return; | 489 | return; |
@@ -498,13 +517,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
498 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. | 517 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. |
499 | // can be handled transparently). | 518 | // can be handled transparently). |
500 | InventoryFolderImpl fold = null; | 519 | InventoryFolderImpl fold = null; |
501 | if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) | 520 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) |
502 | { | 521 | if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) |
503 | remoteClient.SendInventoryFolderDetails( | 522 | { |
504 | fold.Owner, folderID, fold.RequestListOfItems(), | 523 | remoteClient.SendInventoryFolderDetails( |
505 | fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); | 524 | fold.Owner, folderID, fold.RequestListOfItems(), |
506 | return; | 525 | fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); |
507 | } | 526 | return; |
527 | } | ||
508 | 528 | ||
509 | // We're going to send the reply async, because there may be | 529 | // We're going to send the reply async, because there may be |
510 | // an enormous quantity of packets -- basically the entire inventory! | 530 | // an enormous quantity of packets -- basically the entire inventory! |
@@ -552,15 +572,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
552 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. | 572 | // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. |
553 | // can be handled transparently). | 573 | // can be handled transparently). |
554 | InventoryFolderImpl fold; | 574 | InventoryFolderImpl fold; |
555 | if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) | 575 | if (LibraryService != null && LibraryService.LibraryRootFolder != null) |
556 | { | 576 | if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null) |
557 | version = 0; | 577 | { |
558 | InventoryCollection ret = new InventoryCollection(); | 578 | version = 0; |
559 | ret.Folders = new List<InventoryFolderBase>(); | 579 | InventoryCollection ret = new InventoryCollection(); |
560 | ret.Items = fold.RequestListOfItems(); | 580 | ret.Folders = new List<InventoryFolderBase>(); |
581 | ret.Items = fold.RequestListOfItems(); | ||
561 | 582 | ||
562 | return ret; | 583 | return ret; |
563 | } | 584 | } |
564 | 585 | ||
565 | InventoryCollection contents = new InventoryCollection(); | 586 | InventoryCollection contents = new InventoryCollection(); |
566 | 587 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs index ab0d397..03f1ee2 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.cs | |||
@@ -27,6 +27,7 @@ | |||
27 | 27 | ||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Diagnostics; | ||
30 | using System.Drawing; | 31 | using System.Drawing; |
31 | using System.Drawing.Imaging; | 32 | using System.Drawing.Imaging; |
32 | using System.IO; | 33 | using System.IO; |
@@ -41,8 +42,7 @@ using OpenMetaverse.Imaging; | |||
41 | using OpenSim.Framework; | 42 | using OpenSim.Framework; |
42 | using OpenSim.Services.Interfaces; | 43 | using OpenSim.Services.Interfaces; |
43 | using OpenSim.Framework.Communications; | 44 | using OpenSim.Framework.Communications; |
44 | using OpenSim.Framework.Communications.Cache; | 45 | |
45 | using OpenSim.Framework.Communications.Clients; | ||
46 | using OpenSim.Framework.Console; | 46 | using OpenSim.Framework.Console; |
47 | using OpenSim.Region.Framework.Interfaces; | 47 | using OpenSim.Region.Framework.Interfaces; |
48 | using OpenSim.Region.Framework.Scenes.Scripting; | 48 | using OpenSim.Region.Framework.Scenes.Scripting; |
@@ -141,7 +141,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
141 | protected ModuleLoader m_moduleLoader; | 141 | protected ModuleLoader m_moduleLoader; |
142 | protected StorageManager m_storageManager; | 142 | protected StorageManager m_storageManager; |
143 | protected AgentCircuitManager m_authenticateHandler; | 143 | protected AgentCircuitManager m_authenticateHandler; |
144 | public CommunicationsManager CommsManager; | ||
145 | 144 | ||
146 | protected SceneCommunicationService m_sceneGridService; | 145 | protected SceneCommunicationService m_sceneGridService; |
147 | public bool LoginsDisabled = true; | 146 | public bool LoginsDisabled = true; |
@@ -189,11 +188,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
189 | { | 188 | { |
190 | m_AuthorizationService = RequestModuleInterface<IAuthorizationService>(); | 189 | m_AuthorizationService = RequestModuleInterface<IAuthorizationService>(); |
191 | 190 | ||
192 | if (m_AuthorizationService == null) | 191 | //if (m_AuthorizationService == null) |
193 | { | 192 | //{ |
194 | // don't throw an exception if no authorization service is set for the time being | 193 | // // don't throw an exception if no authorization service is set for the time being |
195 | m_log.InfoFormat("[SCENE]: No Authorization service is configured"); | 194 | // m_log.InfoFormat("[SCENE]: No Authorization service is configured"); |
196 | } | 195 | //} |
197 | } | 196 | } |
198 | 197 | ||
199 | return m_AuthorizationService; | 198 | return m_AuthorizationService; |
@@ -240,8 +239,76 @@ namespace OpenSim.Region.Framework.Scenes | |||
240 | } | 239 | } |
241 | } | 240 | } |
242 | 241 | ||
242 | protected ILibraryService m_LibraryService; | ||
243 | |||
244 | public ILibraryService LibraryService | ||
245 | { | ||
246 | get | ||
247 | { | ||
248 | if (m_LibraryService == null) | ||
249 | m_LibraryService = RequestModuleInterface<ILibraryService>(); | ||
250 | |||
251 | return m_LibraryService; | ||
252 | } | ||
253 | } | ||
254 | |||
255 | protected ISimulationService m_simulationService; | ||
256 | public ISimulationService SimulationService | ||
257 | { | ||
258 | get | ||
259 | { | ||
260 | if (m_simulationService == null) | ||
261 | m_simulationService = RequestModuleInterface<ISimulationService>(); | ||
262 | return m_simulationService; | ||
263 | } | ||
264 | } | ||
265 | |||
266 | protected IAuthenticationService m_AuthenticationService; | ||
267 | public IAuthenticationService AuthenticationService | ||
268 | { | ||
269 | get | ||
270 | { | ||
271 | if (m_AuthenticationService == null) | ||
272 | m_AuthenticationService = RequestModuleInterface<IAuthenticationService>(); | ||
273 | return m_AuthenticationService; | ||
274 | } | ||
275 | } | ||
276 | |||
277 | protected IPresenceService m_PresenceService; | ||
278 | public IPresenceService PresenceService | ||
279 | { | ||
280 | get | ||
281 | { | ||
282 | if (m_PresenceService == null) | ||
283 | m_PresenceService = RequestModuleInterface<IPresenceService>(); | ||
284 | return m_PresenceService; | ||
285 | } | ||
286 | } | ||
287 | protected IUserAccountService m_UserAccountService; | ||
288 | public IUserAccountService UserAccountService | ||
289 | { | ||
290 | get | ||
291 | { | ||
292 | if (m_UserAccountService == null) | ||
293 | m_UserAccountService = RequestModuleInterface<IUserAccountService>(); | ||
294 | return m_UserAccountService; | ||
295 | } | ||
296 | } | ||
297 | |||
298 | protected OpenSim.Services.Interfaces.IAvatarService m_AvatarService; | ||
299 | public OpenSim.Services.Interfaces.IAvatarService AvatarService | ||
300 | { | ||
301 | get | ||
302 | { | ||
303 | if (m_AvatarService == null) | ||
304 | m_AvatarService = RequestModuleInterface<IAvatarService>(); | ||
305 | return m_AvatarService; | ||
306 | } | ||
307 | } | ||
308 | |||
243 | protected IXMLRPC m_xmlrpcModule; | 309 | protected IXMLRPC m_xmlrpcModule; |
244 | protected IWorldComm m_worldCommModule; | 310 | protected IWorldComm m_worldCommModule; |
311 | public IAttachmentsModule AttachmentsModule { get; set; } | ||
245 | protected IAvatarFactory m_AvatarFactory; | 312 | protected IAvatarFactory m_AvatarFactory; |
246 | public IAvatarFactory AvatarFactory | 313 | public IAvatarFactory AvatarFactory |
247 | { | 314 | { |
@@ -249,10 +316,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
249 | } | 316 | } |
250 | protected IConfigSource m_config; | 317 | protected IConfigSource m_config; |
251 | protected IRegionSerialiserModule m_serialiser; | 318 | protected IRegionSerialiserModule m_serialiser; |
252 | protected IInterregionCommsOut m_interregionCommsOut; | ||
253 | protected IInterregionCommsIn m_interregionCommsIn; | ||
254 | protected IDialogModule m_dialogModule; | 319 | protected IDialogModule m_dialogModule; |
255 | protected ITeleportModule m_teleportModule; | 320 | protected IEntityTransferModule m_teleportModule; |
256 | 321 | ||
257 | protected ICapabilitiesModule m_capsModule; | 322 | protected ICapabilitiesModule m_capsModule; |
258 | public ICapabilitiesModule CapsModule | 323 | public ICapabilitiesModule CapsModule |
@@ -483,7 +548,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
483 | #region Constructors | 548 | #region Constructors |
484 | 549 | ||
485 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, | 550 | public Scene(RegionInfo regInfo, AgentCircuitManager authen, |
486 | CommunicationsManager commsMan, SceneCommunicationService sceneGridService, | 551 | SceneCommunicationService sceneGridService, |
487 | StorageManager storeManager, | 552 | StorageManager storeManager, |
488 | ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, | 553 | ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, |
489 | bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) | 554 | bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) |
@@ -519,7 +584,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
519 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); | 584 | m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); |
520 | m_moduleLoader = moduleLoader; | 585 | m_moduleLoader = moduleLoader; |
521 | m_authenticateHandler = authen; | 586 | m_authenticateHandler = authen; |
522 | CommsManager = commsMan; | ||
523 | m_sceneGridService = sceneGridService; | 587 | m_sceneGridService = sceneGridService; |
524 | m_storageManager = storeManager; | 588 | m_storageManager = storeManager; |
525 | m_regInfo = regInfo; | 589 | m_regInfo = regInfo; |
@@ -778,6 +842,36 @@ namespace OpenSim.Region.Framework.Scenes | |||
778 | return m_simulatorVersion; | 842 | return m_simulatorVersion; |
779 | } | 843 | } |
780 | 844 | ||
845 | public string[] GetUserNames(UUID uuid) | ||
846 | { | ||
847 | string[] returnstring = new string[0]; | ||
848 | |||
849 | UserAccount account = UserAccountService.GetUserAccount(RegionInfo.ScopeID, uuid); | ||
850 | |||
851 | if (account != null) | ||
852 | { | ||
853 | returnstring = new string[2]; | ||
854 | returnstring[0] = account.FirstName; | ||
855 | returnstring[1] = account.LastName; | ||
856 | } | ||
857 | |||
858 | return returnstring; | ||
859 | } | ||
860 | |||
861 | public string GetUserName(UUID uuid) | ||
862 | { | ||
863 | string[] names = GetUserNames(uuid); | ||
864 | if (names.Length == 2) | ||
865 | { | ||
866 | string firstname = names[0]; | ||
867 | string lastname = names[1]; | ||
868 | |||
869 | return firstname + " " + lastname; | ||
870 | |||
871 | } | ||
872 | return "(hippos)"; | ||
873 | } | ||
874 | |||
781 | /// <summary> | 875 | /// <summary> |
782 | /// Another region is up. | 876 | /// Another region is up. |
783 | /// | 877 | /// |
@@ -811,7 +905,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
811 | regInfo.RegionName = otherRegion.RegionName; | 905 | regInfo.RegionName = otherRegion.RegionName; |
812 | regInfo.ScopeID = otherRegion.ScopeID; | 906 | regInfo.ScopeID = otherRegion.ScopeID; |
813 | regInfo.ExternalHostName = otherRegion.ExternalHostName; | 907 | regInfo.ExternalHostName = otherRegion.ExternalHostName; |
814 | 908 | GridRegion r = new GridRegion(regInfo); | |
815 | try | 909 | try |
816 | { | 910 | { |
817 | ForEachScenePresence(delegate(ScenePresence agent) | 911 | ForEachScenePresence(delegate(ScenePresence agent) |
@@ -825,7 +919,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
825 | List<ulong> old = new List<ulong>(); | 919 | List<ulong> old = new List<ulong>(); |
826 | old.Add(otherRegion.RegionHandle); | 920 | old.Add(otherRegion.RegionHandle); |
827 | agent.DropOldNeighbours(old); | 921 | agent.DropOldNeighbours(old); |
828 | InformClientOfNeighbor(agent, regInfo); | 922 | if (m_teleportModule != null) |
923 | m_teleportModule.EnableChildAgent(agent, r); | ||
829 | } | 924 | } |
830 | } | 925 | } |
831 | ); | 926 | ); |
@@ -985,6 +1080,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
985 | { | 1080 | { |
986 | foreach (RegionInfo region in m_regionRestartNotifyList) | 1081 | foreach (RegionInfo region in m_regionRestartNotifyList) |
987 | { | 1082 | { |
1083 | GridRegion r = new GridRegion(region); | ||
988 | try | 1084 | try |
989 | { | 1085 | { |
990 | ForEachScenePresence(delegate(ScenePresence agent) | 1086 | ForEachScenePresence(delegate(ScenePresence agent) |
@@ -992,9 +1088,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
992 | // If agent is a root agent. | 1088 | // If agent is a root agent. |
993 | if (!agent.IsChildAgent) | 1089 | if (!agent.IsChildAgent) |
994 | { | 1090 | { |
995 | //agent.ControllingClient.new | 1091 | if (m_teleportModule != null) |
996 | //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); | 1092 | m_teleportModule.EnableChildAgent(agent, r); |
997 | InformClientOfNeighbor(agent, region); | ||
998 | } | 1093 | } |
999 | } | 1094 | } |
1000 | ); | 1095 | ); |
@@ -1053,10 +1148,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1053 | 1148 | ||
1054 | public int GetInaccurateNeighborCount() | 1149 | public int GetInaccurateNeighborCount() |
1055 | { | 1150 | { |
1056 | lock (m_neighbours) | 1151 | return m_neighbours.Count; |
1057 | { | ||
1058 | return m_neighbours.Count; | ||
1059 | } | ||
1060 | } | 1152 | } |
1061 | 1153 | ||
1062 | // This is the method that shuts down the scene. | 1154 | // This is the method that shuts down the scene. |
@@ -1136,12 +1228,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1136 | m_worldCommModule = RequestModuleInterface<IWorldComm>(); | 1228 | m_worldCommModule = RequestModuleInterface<IWorldComm>(); |
1137 | XferManager = RequestModuleInterface<IXfer>(); | 1229 | XferManager = RequestModuleInterface<IXfer>(); |
1138 | m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); | 1230 | m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); |
1231 | AttachmentsModule = RequestModuleInterface<IAttachmentsModule>(); | ||
1139 | m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); | 1232 | m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); |
1140 | m_interregionCommsOut = RequestModuleInterface<IInterregionCommsOut>(); | ||
1141 | m_interregionCommsIn = RequestModuleInterface<IInterregionCommsIn>(); | ||
1142 | m_dialogModule = RequestModuleInterface<IDialogModule>(); | 1233 | m_dialogModule = RequestModuleInterface<IDialogModule>(); |
1143 | m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); | 1234 | m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); |
1144 | m_teleportModule = RequestModuleInterface<ITeleportModule>(); | 1235 | m_teleportModule = RequestModuleInterface<IEntityTransferModule>(); |
1145 | } | 1236 | } |
1146 | 1237 | ||
1147 | #endregion | 1238 | #endregion |
@@ -1591,7 +1682,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
1591 | GridRegion region = new GridRegion(RegionInfo); | 1682 | GridRegion region = new GridRegion(RegionInfo); |
1592 | string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); | 1683 | string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); |
1593 | if (error != String.Empty) | 1684 | if (error != String.Empty) |
1685 | { | ||
1594 | throw new Exception(error); | 1686 | throw new Exception(error); |
1687 | } | ||
1595 | 1688 | ||
1596 | m_sceneGridService.SetScene(this); | 1689 | m_sceneGridService.SetScene(this); |
1597 | m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); | 1690 | m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); |
@@ -1840,14 +1933,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
1840 | //m_log.DebugFormat( | 1933 | //m_log.DebugFormat( |
1841 | // "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName); | 1934 | // "[SCENE]: Scene.AddNewPrim() pcode {0} called for {1} in {2}", shape.PCode, ownerID, RegionInfo.RegionName); |
1842 | 1935 | ||
1936 | SceneObjectGroup sceneObject = null; | ||
1937 | |||
1843 | // If an entity creator has been registered for this prim type then use that | 1938 | // If an entity creator has been registered for this prim type then use that |
1844 | if (m_entityCreators.ContainsKey((PCode)shape.PCode)) | 1939 | if (m_entityCreators.ContainsKey((PCode)shape.PCode)) |
1845 | return m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape); | 1940 | { |
1941 | sceneObject = m_entityCreators[(PCode)shape.PCode].CreateEntity(ownerID, groupID, pos, rot, shape); | ||
1942 | } | ||
1943 | else | ||
1944 | { | ||
1945 | // Otherwise, use this default creation code; | ||
1946 | sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape); | ||
1947 | AddNewSceneObject(sceneObject, true); | ||
1948 | sceneObject.SetGroup(groupID, null); | ||
1949 | } | ||
1846 | 1950 | ||
1847 | // Otherwise, use this default creation code; | 1951 | sceneObject.ScheduleGroupForFullUpdate(); |
1848 | SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape); | ||
1849 | AddNewSceneObject(sceneObject, true); | ||
1850 | sceneObject.SetGroup(groupID, null); | ||
1851 | 1952 | ||
1852 | return sceneObject; | 1953 | return sceneObject; |
1853 | } | 1954 | } |
@@ -1875,7 +1976,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1875 | } | 1976 | } |
1876 | 1977 | ||
1877 | /// <summary> | 1978 | /// <summary> |
1878 | /// Add a newly created object to the scene | 1979 | /// Add a newly created object to the scene. Updates are also sent to viewers. |
1879 | /// </summary> | 1980 | /// </summary> |
1880 | /// <param name="sceneObject"></param> | 1981 | /// <param name="sceneObject"></param> |
1881 | /// <param name="attachToBackup"> | 1982 | /// <param name="attachToBackup"> |
@@ -1884,7 +1985,24 @@ namespace OpenSim.Region.Framework.Scenes | |||
1884 | /// </param> | 1985 | /// </param> |
1885 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) | 1986 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) |
1886 | { | 1987 | { |
1887 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup); | 1988 | return AddNewSceneObject(sceneObject, attachToBackup, true); |
1989 | } | ||
1990 | |||
1991 | /// <summary> | ||
1992 | /// Add a newly created object to the scene | ||
1993 | /// </summary> | ||
1994 | /// <param name="sceneObject"></param> | ||
1995 | /// <param name="attachToBackup"> | ||
1996 | /// If true, the object is made persistent into the scene. | ||
1997 | /// If false, the object will not persist over server restarts | ||
1998 | /// </param> | ||
1999 | /// <param name="sendClientUpdates"> | ||
2000 | /// If true, updates for the new scene object are sent to all viewers in range. | ||
2001 | /// If false, it is left to the caller to schedule the update | ||
2002 | /// </param> | ||
2003 | public bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) | ||
2004 | { | ||
2005 | return m_sceneGraph.AddNewSceneObject(sceneObject, attachToBackup, sendClientUpdates); | ||
1888 | } | 2006 | } |
1889 | 2007 | ||
1890 | /// <summary> | 2008 | /// <summary> |
@@ -1978,7 +2096,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1978 | /// Move the given scene object into a new region depending on which region its absolute position has moved | 2096 | /// Move the given scene object into a new region depending on which region its absolute position has moved |
1979 | /// into. | 2097 | /// into. |
1980 | /// | 2098 | /// |
1981 | /// This method locates the new region handle and offsets the prim position for the new region | ||
1982 | /// </summary> | 2099 | /// </summary> |
1983 | /// <param name="attemptedPosition">the attempted out of region position of the scene object</param> | 2100 | /// <param name="attemptedPosition">the attempted out of region position of the scene object</param> |
1984 | /// <param name="grp">the scene object that we're crossing</param> | 2101 | /// <param name="grp">the scene object that we're crossing</param> |
@@ -2020,191 +2137,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2020 | return; | 2137 | return; |
2021 | } | 2138 | } |
2022 | 2139 | ||
2023 | int thisx = (int)RegionInfo.RegionLocX; | 2140 | if (m_teleportModule != null) |
2024 | int thisy = (int)RegionInfo.RegionLocY; | 2141 | m_teleportModule.Cross(grp, attemptedPosition, silent); |
2025 | Vector3 EastCross = new Vector3(0.1f,0,0); | ||
2026 | Vector3 WestCross = new Vector3(-0.1f, 0, 0); | ||
2027 | Vector3 NorthCross = new Vector3(0, 0.1f, 0); | ||
2028 | Vector3 SouthCross = new Vector3(0, -0.1f, 0); | ||
2029 | |||
2030 | |||
2031 | // use this if no borders were crossed! | ||
2032 | ulong newRegionHandle | ||
2033 | = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize), | ||
2034 | (uint)((thisy) * Constants.RegionSize)); | ||
2035 | |||
2036 | Vector3 pos = attemptedPosition; | ||
2037 | |||
2038 | int changeX = 1; | ||
2039 | int changeY = 1; | ||
2040 | |||
2041 | if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W)) | ||
2042 | { | ||
2043 | if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) | ||
2044 | { | ||
2045 | |||
2046 | Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); | ||
2047 | |||
2048 | if (crossedBorderx.BorderLine.Z > 0) | ||
2049 | { | ||
2050 | pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); | ||
2051 | changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize); | ||
2052 | } | ||
2053 | else | ||
2054 | pos.X = ((pos.X + Constants.RegionSize)); | ||
2055 | |||
2056 | Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); | ||
2057 | //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) | ||
2058 | |||
2059 | if (crossedBordery.BorderLine.Z > 0) | ||
2060 | { | ||
2061 | pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); | ||
2062 | changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); | ||
2063 | } | ||
2064 | else | ||
2065 | pos.Y = ((pos.Y + Constants.RegionSize)); | ||
2066 | |||
2067 | |||
2068 | |||
2069 | newRegionHandle | ||
2070 | = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), | ||
2071 | (uint)((thisy - changeY) * Constants.RegionSize)); | ||
2072 | // x - 1 | ||
2073 | // y - 1 | ||
2074 | } | ||
2075 | else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) | ||
2076 | { | ||
2077 | Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); | ||
2078 | |||
2079 | if (crossedBorderx.BorderLine.Z > 0) | ||
2080 | { | ||
2081 | pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); | ||
2082 | changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); | ||
2083 | } | ||
2084 | else | ||
2085 | pos.X = ((pos.X + Constants.RegionSize)); | ||
2086 | |||
2087 | |||
2088 | Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); | ||
2089 | //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) | ||
2090 | |||
2091 | try | ||
2092 | { | ||
2093 | if (crossedBordery.BorderLine.Z > 0) | ||
2094 | { | ||
2095 | pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); | ||
2096 | changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); | ||
2097 | } | ||
2098 | else | ||
2099 | pos.Y = ((pos.Y + Constants.RegionSize)); | ||
2100 | |||
2101 | newRegionHandle | ||
2102 | = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), | ||
2103 | (uint)((thisy + changeY) * Constants.RegionSize)); | ||
2104 | // x - 1 | ||
2105 | // y + 1 | ||
2106 | } | ||
2107 | catch (Exception ex) | ||
2108 | { | ||
2109 | } | ||
2110 | } | ||
2111 | else | ||
2112 | { | ||
2113 | Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W); | ||
2114 | |||
2115 | if (crossedBorderx.BorderLine.Z > 0) | ||
2116 | { | ||
2117 | pos.X = ((pos.X + crossedBorderx.BorderLine.Z)); | ||
2118 | changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize); | ||
2119 | } | ||
2120 | else | ||
2121 | pos.X = ((pos.X + Constants.RegionSize)); | ||
2122 | |||
2123 | newRegionHandle | ||
2124 | = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize), | ||
2125 | (uint) (thisy*Constants.RegionSize)); | ||
2126 | // x - 1 | ||
2127 | } | ||
2128 | } | ||
2129 | else if (TestBorderCross(attemptedPosition + EastCross, Cardinals.E)) | ||
2130 | { | ||
2131 | if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) | ||
2132 | { | ||
2133 | |||
2134 | pos.X = ((pos.X - Constants.RegionSize)); | ||
2135 | Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); | ||
2136 | //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) | ||
2137 | |||
2138 | if (crossedBordery.BorderLine.Z > 0) | ||
2139 | { | ||
2140 | pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); | ||
2141 | changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); | ||
2142 | } | ||
2143 | else | ||
2144 | pos.Y = ((pos.Y + Constants.RegionSize)); | ||
2145 | |||
2146 | |||
2147 | newRegionHandle | ||
2148 | = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), | ||
2149 | (uint)((thisy - changeY) * Constants.RegionSize)); | ||
2150 | // x + 1 | ||
2151 | // y - 1 | ||
2152 | } | ||
2153 | else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) | ||
2154 | { | ||
2155 | pos.X = ((pos.X - Constants.RegionSize)); | ||
2156 | pos.Y = ((pos.Y - Constants.RegionSize)); | ||
2157 | newRegionHandle | ||
2158 | = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), | ||
2159 | (uint)((thisy + changeY) * Constants.RegionSize)); | ||
2160 | // x + 1 | ||
2161 | // y + 1 | ||
2162 | } | ||
2163 | else | ||
2164 | { | ||
2165 | pos.X = ((pos.X - Constants.RegionSize)); | ||
2166 | newRegionHandle | ||
2167 | = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), | ||
2168 | (uint) (thisy*Constants.RegionSize)); | ||
2169 | // x + 1 | ||
2170 | } | ||
2171 | } | ||
2172 | else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) | ||
2173 | { | ||
2174 | Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S); | ||
2175 | //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize) | ||
2176 | |||
2177 | if (crossedBordery.BorderLine.Z > 0) | ||
2178 | { | ||
2179 | pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); | ||
2180 | changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize); | ||
2181 | } | ||
2182 | else | ||
2183 | pos.Y = ((pos.Y + Constants.RegionSize)); | ||
2184 | |||
2185 | newRegionHandle | ||
2186 | = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize)); | ||
2187 | // y - 1 | ||
2188 | } | ||
2189 | else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N)) | ||
2190 | { | ||
2191 | |||
2192 | pos.Y = ((pos.Y - Constants.RegionSize)); | ||
2193 | newRegionHandle | ||
2194 | = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize)); | ||
2195 | // y + 1 | ||
2196 | } | ||
2197 | |||
2198 | // Offset the positions for the new region across the border | ||
2199 | Vector3 oldGroupPosition = grp.RootPart.GroupPosition; | ||
2200 | grp.OffsetForNewRegion(pos); | ||
2201 | |||
2202 | // If we fail to cross the border, then reset the position of the scene object on that border. | ||
2203 | if (!CrossPrimGroupIntoNewRegion(newRegionHandle, grp, silent)) | ||
2204 | { | ||
2205 | grp.OffsetForNewRegion(oldGroupPosition); | ||
2206 | grp.ScheduleGroupForFullUpdate(); | ||
2207 | } | ||
2208 | } | 2142 | } |
2209 | 2143 | ||
2210 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) | 2144 | public Border GetCrossedBorder(Vector3 position, Cardinals gridline) |
@@ -2388,75 +2322,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2388 | 2322 | ||
2389 | 2323 | ||
2390 | /// <summary> | 2324 | /// <summary> |
2391 | /// Move the given scene object into a new region | ||
2392 | /// </summary> | ||
2393 | /// <param name="newRegionHandle"></param> | ||
2394 | /// <param name="grp">Scene Object Group that we're crossing</param> | ||
2395 | /// <returns> | ||
2396 | /// true if the crossing itself was successful, false on failure | ||
2397 | /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region | ||
2398 | /// </returns> | ||
2399 | public bool CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp, bool silent) | ||
2400 | { | ||
2401 | //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<"); | ||
2402 | |||
2403 | bool successYN = false; | ||
2404 | grp.RootPart.UpdateFlag = 0; | ||
2405 | //int primcrossingXMLmethod = 0; | ||
2406 | |||
2407 | if (newRegionHandle != 0) | ||
2408 | { | ||
2409 | //string objectState = grp.GetStateSnapshot(); | ||
2410 | |||
2411 | //successYN | ||
2412 | // = m_sceneGridService.PrimCrossToNeighboringRegion( | ||
2413 | // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod); | ||
2414 | //if (successYN && (objectState != "") && m_allowScriptCrossings) | ||
2415 | //{ | ||
2416 | // successYN = m_sceneGridService.PrimCrossToNeighboringRegion( | ||
2417 | // newRegionHandle, grp.UUID, objectState, 100); | ||
2418 | //} | ||
2419 | |||
2420 | // And the new channel... | ||
2421 | if (m_interregionCommsOut != null) | ||
2422 | successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true); | ||
2423 | |||
2424 | if (successYN) | ||
2425 | { | ||
2426 | // We remove the object here | ||
2427 | try | ||
2428 | { | ||
2429 | DeleteSceneObject(grp, silent); | ||
2430 | } | ||
2431 | catch (Exception e) | ||
2432 | { | ||
2433 | m_log.ErrorFormat( | ||
2434 | "[INTERREGION]: Exception deleting the old object left behind on a border crossing for {0}, {1}", | ||
2435 | grp, e); | ||
2436 | } | ||
2437 | } | ||
2438 | else | ||
2439 | { | ||
2440 | if (!grp.IsDeleted) | ||
2441 | { | ||
2442 | if (grp.RootPart.PhysActor != null) | ||
2443 | { | ||
2444 | grp.RootPart.PhysActor.CrossingFailure(); | ||
2445 | } | ||
2446 | } | ||
2447 | |||
2448 | m_log.ErrorFormat("[INTERREGION]: Prim crossing failed for {0}", grp); | ||
2449 | } | ||
2450 | } | ||
2451 | else | ||
2452 | { | ||
2453 | m_log.Error("[INTERREGION]: region handle was unexpectedly 0 in Scene.CrossPrimGroupIntoNewRegion()"); | ||
2454 | } | ||
2455 | |||
2456 | return successYN; | ||
2457 | } | ||
2458 | |||
2459 | /// <summary> | ||
2460 | /// Called when objects or attachments cross the border between regions. | 2325 | /// Called when objects or attachments cross the border between regions. |
2461 | /// </summary> | 2326 | /// </summary> |
2462 | /// <param name="sog"></param> | 2327 | /// <param name="sog"></param> |
@@ -2500,10 +2365,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
2500 | //m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID); | 2365 | //m_log.DebugFormat(" >>> IncomingCreateObject(userID, itemID) <<< {0} {1}", userID, itemID); |
2501 | 2366 | ||
2502 | ScenePresence sp = GetScenePresence(userID); | 2367 | ScenePresence sp = GetScenePresence(userID); |
2503 | if (sp != null) | 2368 | if (sp != null && AttachmentsModule != null) |
2504 | { | 2369 | { |
2505 | uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID); | 2370 | uint attPt = (uint)sp.Appearance.GetAttachpoint(itemID); |
2506 | m_sceneGraph.RezSingleAttachment(sp.ControllingClient, itemID, attPt); | 2371 | AttachmentsModule.RezSingleAttachmentFromInventory(sp.ControllingClient, itemID, attPt); |
2507 | } | 2372 | } |
2508 | 2373 | ||
2509 | return false; | 2374 | return false; |
@@ -2528,6 +2393,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2528 | 2393 | ||
2529 | return false; | 2394 | return false; |
2530 | } | 2395 | } |
2396 | |||
2397 | sceneObject.SetScene(this); | ||
2398 | |||
2531 | // Force allocation of new LocalId | 2399 | // Force allocation of new LocalId |
2532 | // | 2400 | // |
2533 | foreach (SceneObjectPart p in sceneObject.Children.Values) | 2401 | foreach (SceneObjectPart p in sceneObject.Children.Values) |
@@ -2564,9 +2432,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
2564 | //grp.SetFromAssetID(grp.RootPart.LastOwnerID); | 2432 | //grp.SetFromAssetID(grp.RootPart.LastOwnerID); |
2565 | m_log.DebugFormat( | 2433 | m_log.DebugFormat( |
2566 | "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); | 2434 | "[ATTACHMENT]: Attach to avatar {0} at position {1}", sp.UUID, grp.AbsolutePosition); |
2435 | |||
2436 | if (AttachmentsModule != null) | ||
2437 | AttachmentsModule.AttachObject( | ||
2438 | sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); | ||
2567 | 2439 | ||
2568 | AttachObject( | ||
2569 | sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); | ||
2570 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); | 2440 | RootPrim.RemFlag(PrimFlags.TemporaryOnRez); |
2571 | grp.SendGroupFullUpdate(); | 2441 | grp.SendGroupFullUpdate(); |
2572 | } | 2442 | } |
@@ -2606,6 +2476,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2606 | /// <param name="client"></param> | 2476 | /// <param name="client"></param> |
2607 | public override void AddNewClient(IClientAPI client) | 2477 | public override void AddNewClient(IClientAPI client) |
2608 | { | 2478 | { |
2479 | bool vialogin = false; | ||
2480 | |||
2609 | m_clientManager.Add(client); | 2481 | m_clientManager.Add(client); |
2610 | 2482 | ||
2611 | CheckHeartbeat(); | 2483 | CheckHeartbeat(); |
@@ -2640,23 +2512,48 @@ namespace OpenSim.Region.Framework.Scenes | |||
2640 | { | 2512 | { |
2641 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); | 2513 | AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); |
2642 | 2514 | ||
2643 | m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); | 2515 | // Do the verification here |
2644 | /* | 2516 | System.Net.EndPoint ep = client.GetClientEP(); |
2645 | string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}", | 2517 | if (aCircuit != null) |
2646 | ((aCircuit.child == true) ? "child" : "root"), client.Name, | 2518 | { |
2647 | RegionInfo.RegionName); | 2519 | if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0) |
2648 | 2520 | { | |
2649 | m_log.Debug(logMsg); | 2521 | m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName); |
2650 | */ | 2522 | vialogin = true; |
2523 | IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>(); | ||
2524 | if (userVerification != null && ep != null) | ||
2525 | { | ||
2526 | if (!userVerification.VerifyClient(aCircuit, ep.ToString())) | ||
2527 | { | ||
2528 | // uh-oh, this is fishy | ||
2529 | m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.", | ||
2530 | client.AgentId, client.SessionId, ep.ToString()); | ||
2531 | try | ||
2532 | { | ||
2533 | client.Close(); | ||
2534 | } | ||
2535 | catch (Exception e) | ||
2536 | { | ||
2537 | m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace); | ||
2538 | } | ||
2539 | return; | ||
2540 | } | ||
2541 | else | ||
2542 | m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} returned true", aCircuit.firstname, aCircuit.lastname); | ||
2543 | } | ||
2544 | } | ||
2545 | } | ||
2651 | 2546 | ||
2652 | CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); | 2547 | m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); |
2653 | 2548 | ||
2654 | ScenePresence sp = CreateAndAddScenePresence(client); | 2549 | ScenePresence sp = CreateAndAddScenePresence(client); |
2550 | if (aCircuit != null) | ||
2551 | sp.Appearance = aCircuit.Appearance; | ||
2655 | 2552 | ||
2656 | // HERE!!! Do the initial attachments right here | 2553 | // HERE!!! Do the initial attachments right here |
2657 | // first agent upon login is a root agent by design. | 2554 | // first agent upon login is a root agent by design. |
2658 | // All other AddNewClient calls find aCircuit.child to be true | 2555 | // All other AddNewClient calls find aCircuit.child to be true |
2659 | if (aCircuit == null || aCircuit.child == false) | 2556 | if (aCircuit == null || (aCircuit != null && aCircuit.child == false)) |
2660 | { | 2557 | { |
2661 | sp.IsChildAgent = false; | 2558 | sp.IsChildAgent = false; |
2662 | Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); | 2559 | Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); |
@@ -2665,6 +2562,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2665 | 2562 | ||
2666 | m_LastLogin = Util.EnvironmentTickCount(); | 2563 | m_LastLogin = Util.EnvironmentTickCount(); |
2667 | EventManager.TriggerOnNewClient(client); | 2564 | EventManager.TriggerOnNewClient(client); |
2565 | if (vialogin) | ||
2566 | EventManager.TriggerOnClientLogin(client); | ||
2668 | } | 2567 | } |
2669 | 2568 | ||
2670 | 2569 | ||
@@ -2770,19 +2669,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2770 | } | 2669 | } |
2771 | 2670 | ||
2772 | public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) | 2671 | public virtual void SubscribeToClientAttachmentEvents(IClientAPI client) |
2773 | { | 2672 | { |
2774 | client.OnRezSingleAttachmentFromInv += RezSingleAttachment; | 2673 | client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments; |
2775 | client.OnRezMultipleAttachmentsFromInv += RezMultipleAttachments; | ||
2776 | client.OnDetachAttachmentIntoInv += DetachSingleAttachmentToInv; | ||
2777 | client.OnObjectAttach += m_sceneGraph.AttachObject; | ||
2778 | client.OnObjectDetach += m_sceneGraph.DetachObject; | 2674 | client.OnObjectDetach += m_sceneGraph.DetachObject; |
2675 | |||
2676 | if (AttachmentsModule != null) | ||
2677 | { | ||
2678 | client.OnRezSingleAttachmentFromInv += AttachmentsModule.RezSingleAttachmentFromInventory; | ||
2679 | client.OnObjectAttach += AttachmentsModule.AttachObject; | ||
2680 | client.OnDetachAttachmentIntoInv += AttachmentsModule.ShowDetachInUserInventory; | ||
2681 | } | ||
2779 | } | 2682 | } |
2780 | 2683 | ||
2781 | public virtual void SubscribeToClientTeleportEvents(IClientAPI client) | 2684 | public virtual void SubscribeToClientTeleportEvents(IClientAPI client) |
2782 | { | 2685 | { |
2783 | client.OnTeleportLocationRequest += RequestTeleportLocation; | 2686 | client.OnTeleportLocationRequest += RequestTeleportLocation; |
2784 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; | 2687 | client.OnTeleportLandmarkRequest += RequestTeleportLandmark; |
2785 | client.OnTeleportHomeRequest += TeleportClientHome; | ||
2786 | } | 2688 | } |
2787 | 2689 | ||
2788 | public virtual void SubscribeToClientScriptEvents(IClientAPI client) | 2690 | public virtual void SubscribeToClientScriptEvents(IClientAPI client) |
@@ -2802,7 +2704,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2802 | 2704 | ||
2803 | public virtual void SubscribeToClientGridEvents(IClientAPI client) | 2705 | public virtual void SubscribeToClientGridEvents(IClientAPI client) |
2804 | { | 2706 | { |
2805 | client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; | 2707 | client.OnNameFromUUIDRequest += HandleUUIDNameRequest; |
2806 | client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; | 2708 | client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; |
2807 | client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; | 2709 | client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; |
2808 | client.OnSetStartLocationRequest += SetHomeRezPoint; | 2710 | client.OnSetStartLocationRequest += SetHomeRezPoint; |
@@ -2824,7 +2726,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2824 | 2726 | ||
2825 | protected virtual void UnsubscribeToClientEvents(IClientAPI client) | 2727 | protected virtual void UnsubscribeToClientEvents(IClientAPI client) |
2826 | { | 2728 | { |
2827 | |||
2828 | } | 2729 | } |
2829 | 2730 | ||
2830 | /// <summary> | 2731 | /// <summary> |
@@ -2846,7 +2747,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2846 | 2747 | ||
2847 | UnSubscribeToClientNetworkEvents(client); | 2748 | UnSubscribeToClientNetworkEvents(client); |
2848 | 2749 | ||
2849 | |||
2850 | // EventManager.TriggerOnNewClient(client); | 2750 | // EventManager.TriggerOnNewClient(client); |
2851 | } | 2751 | } |
2852 | 2752 | ||
@@ -2903,7 +2803,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
2903 | client.OnRezObject -= RezObject; | 2803 | client.OnRezObject -= RezObject; |
2904 | } | 2804 | } |
2905 | 2805 | ||
2906 | |||
2907 | public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client) | 2806 | public virtual void UnSubscribeToClientInventoryEvents(IClientAPI client) |
2908 | { | 2807 | { |
2909 | client.OnCreateNewInventoryItem -= CreateNewInventoryItem; | 2808 | client.OnCreateNewInventoryItem -= CreateNewInventoryItem; |
@@ -2927,18 +2826,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
2927 | 2826 | ||
2928 | public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) | 2827 | public virtual void UnSubscribeToClientAttachmentEvents(IClientAPI client) |
2929 | { | 2828 | { |
2930 | client.OnRezSingleAttachmentFromInv -= RezSingleAttachment; | 2829 | client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments; |
2931 | client.OnRezMultipleAttachmentsFromInv -= RezMultipleAttachments; | ||
2932 | client.OnDetachAttachmentIntoInv -= DetachSingleAttachmentToInv; | ||
2933 | client.OnObjectAttach -= m_sceneGraph.AttachObject; | ||
2934 | client.OnObjectDetach -= m_sceneGraph.DetachObject; | 2830 | client.OnObjectDetach -= m_sceneGraph.DetachObject; |
2831 | |||
2832 | if (AttachmentsModule != null) | ||
2833 | { | ||
2834 | client.OnRezSingleAttachmentFromInv -= AttachmentsModule.RezSingleAttachmentFromInventory; | ||
2835 | client.OnObjectAttach -= AttachmentsModule.AttachObject; | ||
2836 | client.OnDetachAttachmentIntoInv -= AttachmentsModule.ShowDetachInUserInventory; | ||
2837 | } | ||
2935 | } | 2838 | } |
2936 | 2839 | ||
2937 | public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) | 2840 | public virtual void UnSubscribeToClientTeleportEvents(IClientAPI client) |
2938 | { | 2841 | { |
2939 | client.OnTeleportLocationRequest -= RequestTeleportLocation; | 2842 | client.OnTeleportLocationRequest -= RequestTeleportLocation; |
2940 | client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; | 2843 | client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; |
2941 | client.OnTeleportHomeRequest -= TeleportClientHome; | 2844 | //client.OnTeleportHomeRequest -= TeleportClientHome; |
2942 | } | 2845 | } |
2943 | 2846 | ||
2944 | public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) | 2847 | public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) |
@@ -2958,7 +2861,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2958 | 2861 | ||
2959 | public virtual void UnSubscribeToClientGridEvents(IClientAPI client) | 2862 | public virtual void UnSubscribeToClientGridEvents(IClientAPI client) |
2960 | { | 2863 | { |
2961 | client.OnNameFromUUIDRequest -= CommsManager.HandleUUIDNameRequest; | 2864 | client.OnNameFromUUIDRequest -= HandleUUIDNameRequest; |
2962 | client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; | 2865 | client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; |
2963 | client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; | 2866 | client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; |
2964 | client.OnSetStartLocationRequest -= SetHomeRezPoint; | 2867 | client.OnSetStartLocationRequest -= SetHomeRezPoint; |
@@ -2985,30 +2888,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2985 | /// <param name="client">The IClientAPI for the client</param> | 2888 | /// <param name="client">The IClientAPI for the client</param> |
2986 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) | 2889 | public virtual void TeleportClientHome(UUID agentId, IClientAPI client) |
2987 | { | 2890 | { |
2988 | UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); | 2891 | if (m_teleportModule != null) |
2989 | if (UserProfile != null) | 2892 | m_teleportModule.TeleportHome(agentId, client); |
2893 | else | ||
2990 | { | 2894 | { |
2991 | GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); | 2895 | m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active"); |
2992 | if (regionInfo == null) | 2896 | client.SendTeleportFailed("Unable to perform teleports on this simulator."); |
2993 | { | ||
2994 | uint x = 0, y = 0; | ||
2995 | Utils.LongToUInts(UserProfile.HomeRegion, out x, out y); | ||
2996 | regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | ||
2997 | if (regionInfo != null) // home region can be away temporarily, too | ||
2998 | { | ||
2999 | UserProfile.HomeRegionID = regionInfo.RegionID; | ||
3000 | CommsManager.UserService.UpdateUserProfile(UserProfile); | ||
3001 | } | ||
3002 | } | ||
3003 | if (regionInfo == null) | ||
3004 | { | ||
3005 | // can't find the Home region: Tell viewer and abort | ||
3006 | client.SendTeleportFailed("Your home-region could not be found."); | ||
3007 | return; | ||
3008 | } | ||
3009 | RequestTeleportLocation( | ||
3010 | client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt, | ||
3011 | (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome)); | ||
3012 | } | 2897 | } |
3013 | } | 2898 | } |
3014 | 2899 | ||
@@ -3099,7 +2984,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3099 | } | 2984 | } |
3100 | 2985 | ||
3101 | /// <summary> | 2986 | /// <summary> |
3102 | /// Sets the Home Point. The GridService uses this to know where to put a user when they log-in | 2987 | /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in |
3103 | /// </summary> | 2988 | /// </summary> |
3104 | /// <param name="remoteClient"></param> | 2989 | /// <param name="remoteClient"></param> |
3105 | /// <param name="regionHandle"></param> | 2990 | /// <param name="regionHandle"></param> |
@@ -3108,27 +2993,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
3108 | /// <param name="flags"></param> | 2993 | /// <param name="flags"></param> |
3109 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) | 2994 | public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) |
3110 | { | 2995 | { |
3111 | UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); | 2996 | if (PresenceService.SetHomeLocation(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt)) |
3112 | if (UserProfile != null) | ||
3113 | { | ||
3114 | // I know I'm ignoring the regionHandle provided by the teleport location request. | ||
3115 | // reusing the TeleportLocationRequest delegate, so regionHandle isn't valid | ||
3116 | UserProfile.HomeRegionID = RegionInfo.RegionID; | ||
3117 | // TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around. | ||
3118 | // TODO: The HomeRegion property can be removed then, too | ||
3119 | UserProfile.HomeRegion = RegionInfo.RegionHandle; | ||
3120 | |||
3121 | UserProfile.HomeLocation = position; | ||
3122 | UserProfile.HomeLookAt = lookAt; | ||
3123 | CommsManager.UserService.UpdateUserProfile(UserProfile); | ||
3124 | |||
3125 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. | 2997 | // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. |
3126 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); | 2998 | m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); |
3127 | } | ||
3128 | else | 2999 | else |
3129 | { | ||
3130 | m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); | 3000 | m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); |
3131 | } | ||
3132 | } | 3001 | } |
3133 | 3002 | ||
3134 | /// <summary> | 3003 | /// <summary> |
@@ -3201,14 +3070,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3201 | m_sceneGraph.removeUserCount(!childagentYN); | 3070 | m_sceneGraph.removeUserCount(!childagentYN); |
3202 | CapsModule.RemoveCapsHandler(agentID); | 3071 | CapsModule.RemoveCapsHandler(agentID); |
3203 | 3072 | ||
3204 | if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) | 3073 | // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever |
3205 | { | 3074 | // this method is doing is HORRIBLE!!! |
3206 | CommsManager.UserProfileCacheService.RemoveUser(agentID); | 3075 | avatar.Scene.NeedSceneCacheClear(avatar.UUID); |
3207 | } | ||
3208 | 3076 | ||
3209 | if (!avatar.IsChildAgent) | 3077 | if (!avatar.IsChildAgent) |
3210 | { | 3078 | { |
3211 | m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat); | ||
3212 | //List<ulong> childknownRegions = new List<ulong>(); | 3079 | //List<ulong> childknownRegions = new List<ulong>(); |
3213 | //List<ulong> ckn = avatar.KnownChildRegionHandles; | 3080 | //List<ulong> ckn = avatar.KnownChildRegionHandles; |
3214 | //for (int i = 0; i < ckn.Count; i++) | 3081 | //for (int i = 0; i < ckn.Count; i++) |
@@ -3263,12 +3130,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3263 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); | 3130 | m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); |
3264 | } | 3131 | } |
3265 | 3132 | ||
3266 | // Remove client agent from profile, so new logins will work | ||
3267 | if (!childagentYN) | ||
3268 | { | ||
3269 | m_sceneGridService.ClearUserAgent(agentID); | ||
3270 | } | ||
3271 | |||
3272 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); | 3133 | m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); |
3273 | 3134 | ||
3274 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); | 3135 | //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); |
@@ -3341,15 +3202,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3341 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; | 3202 | m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid; |
3342 | m_sceneGridService.KiPrimitive += SendKillObject; | 3203 | m_sceneGridService.KiPrimitive += SendKillObject; |
3343 | m_sceneGridService.OnGetLandData += GetLandData; | 3204 | m_sceneGridService.OnGetLandData += GetLandData; |
3344 | |||
3345 | if (m_interregionCommsIn != null) | ||
3346 | { | ||
3347 | m_log.Debug("[SCENE]: Registering with InterregionCommsIn"); | ||
3348 | m_interregionCommsIn.OnChildAgentUpdate += IncomingChildAgentDataUpdate; | ||
3349 | } | ||
3350 | else | ||
3351 | m_log.Debug("[SCENE]: Unable to register with InterregionCommsIn"); | ||
3352 | |||
3353 | } | 3205 | } |
3354 | 3206 | ||
3355 | /// <summary> | 3207 | /// <summary> |
@@ -3367,9 +3219,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3367 | m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; | 3219 | m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; |
3368 | m_sceneGridService.OnGetLandData -= GetLandData; | 3220 | m_sceneGridService.OnGetLandData -= GetLandData; |
3369 | 3221 | ||
3370 | if (m_interregionCommsIn != null) | ||
3371 | m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; | ||
3372 | |||
3373 | // this does nothing; should be removed | 3222 | // this does nothing; should be removed |
3374 | m_sceneGridService.Close(); | 3223 | m_sceneGridService.Close(); |
3375 | 3224 | ||
@@ -3406,6 +3255,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3406 | /// also return a reason.</returns> | 3255 | /// also return a reason.</returns> |
3407 | public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) | 3256 | public bool NewUserConnection(AgentCircuitData agent, uint teleportFlags, out string reason) |
3408 | { | 3257 | { |
3258 | TeleportFlags tp = (TeleportFlags)teleportFlags; | ||
3409 | //Teleport flags: | 3259 | //Teleport flags: |
3410 | // | 3260 | // |
3411 | // TeleportFlags.ViaGodlikeLure - Border Crossing | 3261 | // TeleportFlags.ViaGodlikeLure - Border Crossing |
@@ -3426,7 +3276,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3426 | agent.AgentID, agent.circuitcode, teleportFlags); | 3276 | agent.AgentID, agent.circuitcode, teleportFlags); |
3427 | 3277 | ||
3428 | reason = String.Empty; | 3278 | reason = String.Empty; |
3429 | if (!AuthenticateUser(agent, out reason)) | 3279 | if (!VerifyUserPresence(agent, out reason)) |
3430 | return false; | 3280 | return false; |
3431 | 3281 | ||
3432 | if (!AuthorizeUser(agent, out reason)) | 3282 | if (!AuthorizeUser(agent, out reason)) |
@@ -3439,6 +3289,17 @@ namespace OpenSim.Region.Framework.Scenes | |||
3439 | 3289 | ||
3440 | CapsModule.NewUserConnection(agent); | 3290 | CapsModule.NewUserConnection(agent); |
3441 | 3291 | ||
3292 | ILandObject land = LandChannel.GetLandObject(agent.startpos.X, agent.startpos.Y); | ||
3293 | |||
3294 | //On login or border crossing test land permisions | ||
3295 | if (tp != TeleportFlags.Default) | ||
3296 | { | ||
3297 | if (land != null && !TestLandRestrictions(agent, land, out reason)) | ||
3298 | { | ||
3299 | return false; | ||
3300 | } | ||
3301 | } | ||
3302 | |||
3442 | ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); | 3303 | ScenePresence sp = m_sceneGraph.GetScenePresence(agent.AgentID); |
3443 | if (sp != null) | 3304 | if (sp != null) |
3444 | { | 3305 | { |
@@ -3526,40 +3387,73 @@ namespace OpenSim.Region.Framework.Scenes | |||
3526 | */// This is now handled properly in ScenePresence.MakeRootAgent | 3387 | */// This is now handled properly in ScenePresence.MakeRootAgent |
3527 | } | 3388 | } |
3528 | 3389 | ||
3390 | agent.teleportFlags = teleportFlags; | ||
3529 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); | 3391 | m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); |
3530 | 3392 | ||
3531 | // rewrite session_id | 3393 | return true; |
3532 | CachedUserInfo userinfo = CommsManager.UserProfileCacheService.GetUserDetails(agent.AgentID); | 3394 | } |
3533 | if (userinfo != null) | 3395 | |
3534 | { | 3396 | private bool TestLandRestrictions(AgentCircuitData agent, ILandObject land, out string reason) |
3535 | userinfo.SessionID = agent.SessionID; | 3397 | { |
3536 | } | 3398 | |
3537 | else | 3399 | bool banned = land.IsBannedFromLand(agent.AgentID); |
3400 | bool restricted = land.IsRestrictedFromLand(agent.AgentID); | ||
3401 | |||
3402 | if (banned || restricted) | ||
3538 | { | 3403 | { |
3539 | m_log.WarnFormat( | 3404 | ILandObject nearestParcel = GetNearestAllowedParcel(agent.AgentID, agent.startpos.X, agent.startpos.Y); |
3540 | "[CONNECTION BEGIN]: We couldn't find a User Info record for {0}. This is usually an indication that the UUID we're looking up is invalid", agent.AgentID); | 3405 | if (nearestParcel != null) |
3406 | { | ||
3407 | //Move agent to nearest allowed | ||
3408 | Vector3 newPosition = GetParcelCenterAtGround(nearestParcel); | ||
3409 | agent.startpos.X = newPosition.X; | ||
3410 | agent.startpos.Y = newPosition.Y; | ||
3411 | } | ||
3412 | else | ||
3413 | { | ||
3414 | if (banned) | ||
3415 | { | ||
3416 | reason = "Cannot regioncross into banned parcel."; | ||
3417 | } | ||
3418 | else | ||
3419 | { | ||
3420 | reason = String.Format("Denied access to private region {0}: You are not on the access list for that region.", | ||
3421 | RegionInfo.RegionName); | ||
3422 | } | ||
3423 | return false; | ||
3424 | } | ||
3541 | } | 3425 | } |
3542 | 3426 | reason = ""; | |
3543 | return true; | 3427 | return true; |
3544 | } | 3428 | } |
3545 | 3429 | ||
3546 | /// <summary> | 3430 | /// <summary> |
3547 | /// Verifies that the user has a session on the Grid | 3431 | /// Verifies that the user has a presence on the Grid |
3548 | /// </summary> | 3432 | /// </summary> |
3549 | /// <param name="agent">Circuit Data of the Agent we're verifying</param> | 3433 | /// <param name="agent">Circuit Data of the Agent we're verifying</param> |
3550 | /// <param name="reason">Outputs the reason for the false response on this string</param> | 3434 | /// <param name="reason">Outputs the reason for the false response on this string</param> |
3551 | /// <returns>True if the user has a session on the grid. False if it does not. False will | 3435 | /// <returns>True if the user has a session on the grid. False if it does not. False will |
3552 | /// also return a reason.</returns> | 3436 | /// also return a reason.</returns> |
3553 | public virtual bool AuthenticateUser(AgentCircuitData agent, out string reason) | 3437 | public virtual bool VerifyUserPresence(AgentCircuitData agent, out string reason) |
3554 | { | 3438 | { |
3555 | reason = String.Empty; | 3439 | reason = String.Empty; |
3556 | 3440 | ||
3557 | bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID); | 3441 | IPresenceService presence = RequestModuleInterface<IPresenceService>(); |
3558 | m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result); | 3442 | if (presence == null) |
3559 | if (!result) | 3443 | { |
3560 | reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname); | 3444 | reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName); |
3445 | return false; | ||
3446 | } | ||
3447 | |||
3448 | OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID); | ||
3561 | 3449 | ||
3562 | return result; | 3450 | if (pinfo == null || (pinfo != null && pinfo.Online == false)) |
3451 | { | ||
3452 | reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName); | ||
3453 | return false; | ||
3454 | } | ||
3455 | |||
3456 | return true; | ||
3563 | } | 3457 | } |
3564 | 3458 | ||
3565 | /// <summary> | 3459 | /// <summary> |
@@ -3664,6 +3558,18 @@ namespace OpenSim.Region.Framework.Scenes | |||
3664 | return true; | 3558 | return true; |
3665 | } | 3559 | } |
3666 | 3560 | ||
3561 | private ILandObject GetParcelAtPoint(float x, float y) | ||
3562 | { | ||
3563 | foreach (var parcel in AllParcels()) | ||
3564 | { | ||
3565 | if (parcel.ContainsPoint((int)x,(int)y)) | ||
3566 | { | ||
3567 | return parcel; | ||
3568 | } | ||
3569 | } | ||
3570 | return null; | ||
3571 | } | ||
3572 | |||
3667 | /// <summary> | 3573 | /// <summary> |
3668 | /// Update an AgentCircuitData object with new information | 3574 | /// Update an AgentCircuitData object with new information |
3669 | /// </summary> | 3575 | /// </summary> |
@@ -3760,8 +3666,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3760 | /// <returns>true if we handled it.</returns> | 3666 | /// <returns>true if we handled it.</returns> |
3761 | public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) | 3667 | public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) |
3762 | { | 3668 | { |
3763 | // m_log.DebugFormat( | 3669 | m_log.DebugFormat( |
3764 | // "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); | 3670 | "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); |
3765 | 3671 | ||
3766 | // We have to wait until the viewer contacts this region after receiving EAC. | 3672 | // We have to wait until the viewer contacts this region after receiving EAC. |
3767 | // That calls AddNewClient, which finally creates the ScenePresence | 3673 | // That calls AddNewClient, which finally creates the ScenePresence |
@@ -3830,16 +3736,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3830 | return false; | 3736 | return false; |
3831 | } | 3737 | } |
3832 | 3738 | ||
3833 | public virtual bool IncomingReleaseAgent(UUID id) | ||
3834 | { | ||
3835 | return m_sceneGridService.ReleaseAgent(id); | ||
3836 | } | ||
3837 | |||
3838 | public void SendReleaseAgent(ulong regionHandle, UUID id, string uri) | ||
3839 | { | ||
3840 | m_interregionCommsOut.SendReleaseAgent(regionHandle, id, uri); | ||
3841 | } | ||
3842 | |||
3843 | /// <summary> | 3739 | /// <summary> |
3844 | /// Tell a single agent to disconnect from the region. | 3740 | /// Tell a single agent to disconnect from the region. |
3845 | /// </summary> | 3741 | /// </summary> |
@@ -3884,30 +3780,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3884 | } | 3780 | } |
3885 | 3781 | ||
3886 | /// <summary> | 3782 | /// <summary> |
3887 | /// Tell neighboring regions about this agent | ||
3888 | /// When the regions respond with a true value, | ||
3889 | /// tell the agents about the region. | ||
3890 | /// | ||
3891 | /// We have to tell the regions about the agents first otherwise it'll deny them access | ||
3892 | /// | ||
3893 | /// </summary> | ||
3894 | /// <param name="presence"></param> | ||
3895 | public void InformClientOfNeighbours(ScenePresence presence) | ||
3896 | { | ||
3897 | m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours); | ||
3898 | } | ||
3899 | |||
3900 | /// <summary> | ||
3901 | /// Tell a neighboring region about this agent | ||
3902 | /// </summary> | ||
3903 | /// <param name="presence"></param> | ||
3904 | /// <param name="region"></param> | ||
3905 | public void InformClientOfNeighbor(ScenePresence presence, RegionInfo region) | ||
3906 | { | ||
3907 | m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours); | ||
3908 | } | ||
3909 | |||
3910 | /// <summary> | ||
3911 | /// Tries to teleport agent to other region. | 3783 | /// Tries to teleport agent to other region. |
3912 | /// </summary> | 3784 | /// </summary> |
3913 | /// <param name="remoteClient"></param> | 3785 | /// <param name="remoteClient"></param> |
@@ -3982,16 +3854,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3982 | } | 3854 | } |
3983 | 3855 | ||
3984 | if (m_teleportModule != null) | 3856 | if (m_teleportModule != null) |
3985 | { | 3857 | m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags); |
3986 | m_teleportModule.RequestTeleportToLocation(sp, regionHandle, | ||
3987 | position, lookAt, teleportFlags); | ||
3988 | } | ||
3989 | else | 3858 | else |
3990 | { | 3859 | { |
3991 | m_sceneGridService.RequestTeleportToLocation(sp, regionHandle, | 3860 | m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active"); |
3992 | position, lookAt, teleportFlags); | 3861 | sp.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator."); |
3993 | } | 3862 | } |
3994 | |||
3995 | } | 3863 | } |
3996 | } | 3864 | } |
3997 | 3865 | ||
@@ -4017,7 +3885,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
4017 | 3885 | ||
4018 | public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) | 3886 | public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) |
4019 | { | 3887 | { |
4020 | m_sceneGridService.CrossAgentToNewRegion(this, agent, isFlying); | 3888 | if (m_teleportModule != null) |
3889 | m_teleportModule.Cross(agent, isFlying); | ||
3890 | else | ||
3891 | { | ||
3892 | m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule"); | ||
3893 | } | ||
4021 | } | 3894 | } |
4022 | 3895 | ||
4023 | public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) | 3896 | public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) |
@@ -4043,35 +3916,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
4043 | objectCapacity = objects; | 3916 | objectCapacity = objects; |
4044 | } | 3917 | } |
4045 | 3918 | ||
4046 | public List<FriendListItem> GetFriendList(string id) | ||
4047 | { | ||
4048 | UUID avatarID; | ||
4049 | if (!UUID.TryParse(id, out avatarID)) | ||
4050 | return new List<FriendListItem>(); | ||
4051 | |||
4052 | return CommsManager.GetUserFriendList(avatarID); | ||
4053 | } | ||
4054 | |||
4055 | public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids) | ||
4056 | { | ||
4057 | return CommsManager.GetFriendRegionInfos(uuids); | ||
4058 | } | ||
4059 | |||
4060 | public virtual void StoreAddFriendship(UUID ownerID, UUID friendID, uint perms) | ||
4061 | { | ||
4062 | m_sceneGridService.AddNewUserFriend(ownerID, friendID, perms); | ||
4063 | } | ||
4064 | |||
4065 | public virtual void StoreUpdateFriendship(UUID ownerID, UUID friendID, uint perms) | ||
4066 | { | ||
4067 | m_sceneGridService.UpdateUserFriendPerms(ownerID, friendID, perms); | ||
4068 | } | ||
4069 | |||
4070 | public virtual void StoreRemoveFriendship(UUID ownerID, UUID ExfriendID) | ||
4071 | { | ||
4072 | m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID); | ||
4073 | } | ||
4074 | |||
4075 | #endregion | 3919 | #endregion |
4076 | 3920 | ||
4077 | public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) | 3921 | public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) |
@@ -4466,7 +4310,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
4466 | return m_sceneGraph.GetGroupByPrim(localID); | 4310 | return m_sceneGraph.GetGroupByPrim(localID); |
4467 | } | 4311 | } |
4468 | 4312 | ||
4469 | public bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) | 4313 | public override bool TryGetAvatar(UUID avatarId, out ScenePresence avatar) |
4470 | { | 4314 | { |
4471 | return m_sceneGraph.TryGetAvatar(avatarId, out avatar); | 4315 | return m_sceneGraph.TryGetAvatar(avatarId, out avatar); |
4472 | } | 4316 | } |
@@ -4663,7 +4507,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
4663 | group.GetPartName(localID), | 4507 | group.GetPartName(localID), |
4664 | group.GetPartDescription(localID), | 4508 | group.GetPartDescription(localID), |
4665 | (sbyte)AssetType.Object, | 4509 | (sbyte)AssetType.Object, |
4666 | Utils.StringToBytes(sceneObjectXml)); | 4510 | Utils.StringToBytes(sceneObjectXml), |
4511 | group.OwnerID); | ||
4667 | AssetService.Store(asset); | 4512 | AssetService.Store(asset); |
4668 | 4513 | ||
4669 | InventoryItemBase item = new InventoryItemBase(); | 4514 | InventoryItemBase item = new InventoryItemBase(); |
@@ -4987,5 +4832,185 @@ namespace OpenSim.Region.Framework.Scenes | |||
4987 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) | 4832 | if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) |
4988 | StartTimer(); | 4833 | StartTimer(); |
4989 | } | 4834 | } |
4835 | |||
4836 | public override ISceneObject DeserializeObject(string representation) | ||
4837 | { | ||
4838 | return SceneObjectSerializer.FromXml2Format(representation); | ||
4839 | } | ||
4840 | |||
4841 | public override bool AllowScriptCrossings | ||
4842 | { | ||
4843 | get { return m_allowScriptCrossings; } | ||
4844 | } | ||
4845 | |||
4846 | public Vector3? GetNearestAllowedPosition(ScenePresence avatar) | ||
4847 | { | ||
4848 | //simulate to make sure we have pretty up to date positions | ||
4849 | PhysicsScene.Simulate(0); | ||
4850 | |||
4851 | ILandObject nearestParcel = GetNearestAllowedParcel(avatar.UUID, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); | ||
4852 | |||
4853 | if (nearestParcel != null) | ||
4854 | { | ||
4855 | Vector3 dir = Vector3.Normalize(Vector3.Multiply(avatar.Velocity, -1)); | ||
4856 | //Try to get a location that feels like where they came from | ||
4857 | Vector3? nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | ||
4858 | if (nearestPoint != null) | ||
4859 | { | ||
4860 | Debug.WriteLine("Found a sane previous position based on velocity, sending them to: " + nearestPoint.ToString()); | ||
4861 | return nearestPoint.Value; | ||
4862 | } | ||
4863 | |||
4864 | //Sometimes velocity might be zero (local teleport), so try finding point along path from avatar to center of nearest parcel | ||
4865 | Vector3 directionToParcelCenter = Vector3.Subtract(GetParcelCenterAtGround(nearestParcel), avatar.AbsolutePosition); | ||
4866 | dir = Vector3.Normalize(directionToParcelCenter); | ||
4867 | nearestPoint = GetNearestPointInParcelAlongDirectionFromPoint(avatar.AbsolutePosition, dir, nearestParcel); | ||
4868 | if (nearestPoint != null) | ||
4869 | { | ||
4870 | Debug.WriteLine("They had a zero velocity, sending them to: " + nearestPoint.ToString()); | ||
4871 | return nearestPoint.Value; | ||
4872 | } | ||
4873 | |||
4874 | //Ultimate backup if we have no idea where they are | ||
4875 | Debug.WriteLine("Have no idea where they are, sending them to: " + avatar.lastKnownAllowedPosition.ToString()); | ||
4876 | return avatar.lastKnownAllowedPosition; | ||
4877 | |||
4878 | } | ||
4879 | |||
4880 | //Go to the edge, this happens in teleporting to a region with no available parcels | ||
4881 | Vector3 nearestRegionEdgePoint = GetNearestRegionEdgePosition(avatar); | ||
4882 | //Debug.WriteLine("They are really in a place they don't belong, sending them to: " + nearestRegionEdgePoint.ToString()); | ||
4883 | return nearestRegionEdgePoint; | ||
4884 | return null; | ||
4885 | } | ||
4886 | |||
4887 | private Vector3 GetParcelCenterAtGround(ILandObject parcel) | ||
4888 | { | ||
4889 | Vector2 center = GetParcelCenter(parcel); | ||
4890 | return GetPositionAtGround(center.X, center.Y); | ||
4891 | } | ||
4892 | |||
4893 | private Vector3? GetNearestPointInParcelAlongDirectionFromPoint(Vector3 pos, Vector3 direction, ILandObject parcel) | ||
4894 | { | ||
4895 | Vector3 unitDirection = Vector3.Normalize(direction); | ||
4896 | //Making distance to search go through some sane limit of distance | ||
4897 | for (float distance = 0; distance < Constants.RegionSize * 2; distance += .5f) | ||
4898 | { | ||
4899 | Vector3 testPos = Vector3.Add(pos, Vector3.Multiply(unitDirection, distance)); | ||
4900 | if (parcel.ContainsPoint((int)testPos.X, (int)testPos.Y)) | ||
4901 | { | ||
4902 | return testPos; | ||
4903 | } | ||
4904 | } | ||
4905 | return null; | ||
4906 | } | ||
4907 | |||
4908 | public ILandObject GetNearestAllowedParcel(UUID avatarId, float x, float y) | ||
4909 | { | ||
4910 | List<ILandObject> all = AllParcels(); | ||
4911 | float minParcelDistance = float.MaxValue; | ||
4912 | ILandObject nearestParcel = null; | ||
4913 | |||
4914 | foreach (var parcel in all) | ||
4915 | { | ||
4916 | if (!parcel.IsEitherBannedOrRestricted(avatarId)) | ||
4917 | { | ||
4918 | float parcelDistance = GetParcelDistancefromPoint(parcel, x, y); | ||
4919 | if (parcelDistance < minParcelDistance) | ||
4920 | { | ||
4921 | minParcelDistance = parcelDistance; | ||
4922 | nearestParcel = parcel; | ||
4923 | } | ||
4924 | } | ||
4925 | } | ||
4926 | |||
4927 | return nearestParcel; | ||
4928 | } | ||
4929 | |||
4930 | private List<ILandObject> AllParcels() | ||
4931 | { | ||
4932 | return LandChannel.AllParcels(); | ||
4933 | } | ||
4934 | |||
4935 | private float GetParcelDistancefromPoint(ILandObject parcel, float x, float y) | ||
4936 | { | ||
4937 | return Vector2.Distance(new Vector2(x, y), GetParcelCenter(parcel)); | ||
4938 | } | ||
4939 | |||
4940 | //calculate the average center point of a parcel | ||
4941 | private Vector2 GetParcelCenter(ILandObject parcel) | ||
4942 | { | ||
4943 | int count = 0; | ||
4944 | int avgx = 0; | ||
4945 | int avgy = 0; | ||
4946 | for (int x = 0; x < Constants.RegionSize; x++) | ||
4947 | { | ||
4948 | for (int y = 0; y < Constants.RegionSize; y++) | ||
4949 | { | ||
4950 | //Just keep a running average as we check if all the points are inside or not | ||
4951 | if (parcel.ContainsPoint(x, y)) | ||
4952 | { | ||
4953 | if (count == 0) | ||
4954 | { | ||
4955 | avgx = x; | ||
4956 | avgy = y; | ||
4957 | } | ||
4958 | else | ||
4959 | { | ||
4960 | avgx = (avgx * count + x) / (count + 1); | ||
4961 | avgy = (avgy * count + y) / (count + 1); | ||
4962 | } | ||
4963 | count += 1; | ||
4964 | } | ||
4965 | } | ||
4966 | } | ||
4967 | return new Vector2(avgx, avgy); | ||
4968 | } | ||
4969 | |||
4970 | private Vector3 GetNearestRegionEdgePosition(ScenePresence avatar) | ||
4971 | { | ||
4972 | float xdistance = avatar.AbsolutePosition.X < Constants.RegionSize / 2 ? avatar.AbsolutePosition.X : Constants.RegionSize - avatar.AbsolutePosition.X; | ||
4973 | float ydistance = avatar.AbsolutePosition.Y < Constants.RegionSize / 2 ? avatar.AbsolutePosition.Y : Constants.RegionSize - avatar.AbsolutePosition.Y; | ||
4974 | |||
4975 | //find out what vertical edge to go to | ||
4976 | if (xdistance < ydistance) | ||
4977 | { | ||
4978 | if (avatar.AbsolutePosition.X < Constants.RegionSize / 2) | ||
4979 | { | ||
4980 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, 0.0f, avatar.AbsolutePosition.Y); | ||
4981 | } | ||
4982 | else | ||
4983 | { | ||
4984 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, Constants.RegionSize, avatar.AbsolutePosition.Y); | ||
4985 | } | ||
4986 | } | ||
4987 | //find out what horizontal edge to go to | ||
4988 | else | ||
4989 | { | ||
4990 | if (avatar.AbsolutePosition.Y < Constants.RegionSize / 2) | ||
4991 | { | ||
4992 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, 0.0f); | ||
4993 | } | ||
4994 | else | ||
4995 | { | ||
4996 | return GetPositionAtAvatarHeightOrGroundHeight(avatar, avatar.AbsolutePosition.X, Constants.RegionSize); | ||
4997 | } | ||
4998 | } | ||
4999 | } | ||
5000 | |||
5001 | private Vector3 GetPositionAtAvatarHeightOrGroundHeight(ScenePresence avatar, float x, float y) | ||
5002 | { | ||
5003 | Vector3 ground = GetPositionAtGround(x, y); | ||
5004 | if (avatar.AbsolutePosition.Z > ground.Z) | ||
5005 | { | ||
5006 | ground.Z = avatar.AbsolutePosition.Z; | ||
5007 | } | ||
5008 | return ground; | ||
5009 | } | ||
5010 | |||
5011 | private Vector3 GetPositionAtGround(float x, float y) | ||
5012 | { | ||
5013 | return new Vector3(x, y, GetGroundHeight(x, y)); | ||
5014 | } | ||
4990 | } | 5015 | } |
4991 | } | 5016 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs index 5e798c0..74476ed 100644 --- a/OpenSim/Region/Framework/Scenes/SceneBase.cs +++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs | |||
@@ -34,7 +34,7 @@ using log4net; | |||
34 | using Nini.Config; | 34 | using Nini.Config; |
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Framework.Console; | 36 | using OpenSim.Framework.Console; |
37 | using OpenSim.Framework.Communications.Cache; | 37 | |
38 | using OpenSim.Region.Framework.Interfaces; | 38 | using OpenSim.Region.Framework.Interfaces; |
39 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 39 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
40 | 40 | ||
@@ -190,6 +190,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
190 | /// <param name="agentID"></param> | 190 | /// <param name="agentID"></param> |
191 | public abstract void RemoveClient(UUID agentID); | 191 | public abstract void RemoveClient(UUID agentID); |
192 | 192 | ||
193 | public bool TryGetAvatar(UUID agentID, out object scenePresence) | ||
194 | { | ||
195 | scenePresence = null; | ||
196 | ScenePresence sp = null; | ||
197 | if (TryGetAvatar(agentID, out sp)) | ||
198 | { | ||
199 | scenePresence = sp; | ||
200 | return true; | ||
201 | } | ||
202 | |||
203 | return false; | ||
204 | } | ||
205 | |||
206 | public abstract bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence); | ||
207 | |||
193 | #endregion | 208 | #endregion |
194 | 209 | ||
195 | /// <summary> | 210 | /// <summary> |
@@ -510,5 +525,16 @@ namespace OpenSim.Region.Framework.Scenes | |||
510 | 525 | ||
511 | MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); | 526 | MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); |
512 | } | 527 | } |
528 | |||
529 | public virtual ISceneObject DeserializeObject(string representation) | ||
530 | { | ||
531 | return null; | ||
532 | } | ||
533 | |||
534 | public virtual bool AllowScriptCrossings | ||
535 | { | ||
536 | get { return false; } | ||
537 | } | ||
538 | |||
513 | } | 539 | } |
514 | } | 540 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 5f84252..9d0e6f4 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | |||
@@ -36,7 +36,6 @@ using log4net; | |||
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Client; | 37 | using OpenSim.Framework.Client; |
38 | using OpenSim.Framework.Communications; | 38 | using OpenSim.Framework.Communications; |
39 | using OpenSim.Framework.Communications.Cache; | ||
40 | using OpenSim.Framework.Capabilities; | 39 | using OpenSim.Framework.Capabilities; |
41 | using OpenSim.Region.Framework.Interfaces; | 40 | using OpenSim.Region.Framework.Interfaces; |
42 | using OpenSim.Services.Interfaces; | 41 | using OpenSim.Services.Interfaces; |
@@ -56,8 +55,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
56 | { | 55 | { |
57 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 56 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
58 | 57 | ||
59 | protected CommunicationsManager m_commsProvider; | ||
60 | protected IInterregionCommsOut m_interregionCommsOut; | ||
61 | protected RegionInfo m_regionInfo; | 58 | protected RegionInfo m_regionInfo; |
62 | protected Scene m_scene; | 59 | protected Scene m_scene; |
63 | 60 | ||
@@ -106,29 +103,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
106 | /// </summary> | 103 | /// </summary> |
107 | public event GetLandData OnGetLandData; | 104 | public event GetLandData OnGetLandData; |
108 | 105 | ||
109 | private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion; | 106 | // private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion; |
110 | private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser; | 107 | // private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser; |
111 | private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; | 108 | // private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; |
112 | private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; | 109 | // private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; |
113 | //private RegionUp handlerRegionUp = null; // OnRegionUp; | 110 | //private RegionUp handlerRegionUp = null; // OnRegionUp; |
114 | private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate; | 111 | // private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate; |
115 | //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar; | 112 | //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar; |
116 | private LogOffUser handlerLogOffUser = null; | 113 | // private LogOffUser handlerLogOffUser = null; |
117 | private GetLandData handlerGetLandData = null; // OnGetLandData | 114 | // private GetLandData handlerGetLandData = null; // OnGetLandData |
118 | 115 | ||
119 | public KiPrimitiveDelegate KiPrimitive; | 116 | public KiPrimitiveDelegate KiPrimitive; |
120 | 117 | ||
121 | public SceneCommunicationService(CommunicationsManager commsMan) | 118 | public SceneCommunicationService() |
122 | { | 119 | { |
123 | m_commsProvider = commsMan; | ||
124 | m_agentsInTransit = new List<UUID>(); | ||
125 | } | 120 | } |
126 | 121 | ||
127 | public void SetScene(Scene s) | 122 | public void SetScene(Scene s) |
128 | { | 123 | { |
129 | m_scene = s; | 124 | m_scene = s; |
130 | m_regionInfo = s.RegionInfo; | 125 | m_regionInfo = s.RegionInfo; |
131 | m_interregionCommsOut = m_scene.RequestModuleInterface<IInterregionCommsOut>(); | ||
132 | } | 126 | } |
133 | 127 | ||
134 | /// <summary> | 128 | /// <summary> |
@@ -148,377 +142,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
148 | { | 142 | { |
149 | } | 143 | } |
150 | 144 | ||
151 | #region CommsManager Event handlers | ||
152 | |||
153 | /// <summary> | ||
154 | /// A New User will arrive shortly, Informs the scene that there's a new user on the way | ||
155 | /// </summary> | ||
156 | /// <param name="agent">Data we need to ensure that the agent can connect</param> | ||
157 | /// | ||
158 | protected void NewUserConnection(AgentCircuitData agent) | ||
159 | { | ||
160 | handlerExpectUser = OnExpectUser; | ||
161 | if (handlerExpectUser != null) | ||
162 | { | ||
163 | //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: OnExpectUser Fired for User:" + agent.firstname + " " + agent.lastname); | ||
164 | handlerExpectUser(agent); | ||
165 | } | ||
166 | } | ||
167 | |||
168 | /// <summary> | ||
169 | /// The Grid has requested us to log-off the user | ||
170 | /// </summary> | ||
171 | /// <param name="AgentID">Unique ID of agent to log-off</param> | ||
172 | /// <param name="RegionSecret">The secret string that the region establishes with the grid when registering</param> | ||
173 | /// <param name="message">The message to send to the user that tells them why they were logged off</param> | ||
174 | protected void GridLogOffUser(UUID AgentID, UUID RegionSecret, string message) | ||
175 | { | ||
176 | handlerLogOffUser = OnLogOffUser; | ||
177 | if (handlerLogOffUser != null) | ||
178 | { | ||
179 | handlerLogOffUser(AgentID, RegionSecret, message); | ||
180 | } | ||
181 | } | ||
182 | |||
183 | /// <summary> | ||
184 | /// Inform the scene that we've got an update about a child agent that we have | ||
185 | /// </summary> | ||
186 | /// <param name="cAgentData"></param> | ||
187 | /// <returns></returns> | ||
188 | protected bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData) | ||
189 | { | ||
190 | handlerChildAgentUpdate = OnChildAgentUpdate; | ||
191 | if (handlerChildAgentUpdate != null) | ||
192 | handlerChildAgentUpdate(cAgentData); | ||
193 | |||
194 | return true; | ||
195 | } | ||
196 | |||
197 | |||
198 | protected void AgentCrossing(UUID agentID, Vector3 position, bool isFlying) | ||
199 | { | ||
200 | handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion; | ||
201 | if (handlerAvatarCrossingIntoRegion != null) | ||
202 | { | ||
203 | handlerAvatarCrossingIntoRegion(agentID, position, isFlying); | ||
204 | } | ||
205 | } | ||
206 | |||
207 | protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical) | ||
208 | { | ||
209 | handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion; | ||
210 | if (handlerPrimCrossingIntoRegion != null) | ||
211 | { | ||
212 | handlerPrimCrossingIntoRegion(primID, position, isPhysical); | ||
213 | } | ||
214 | } | ||
215 | |||
216 | protected bool CloseConnection(UUID agentID) | ||
217 | { | ||
218 | m_log.Debug("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID); | ||
219 | |||
220 | handlerCloseAgentConnection = OnCloseAgentConnection; | ||
221 | if (handlerCloseAgentConnection != null) | ||
222 | { | ||
223 | return handlerCloseAgentConnection(agentID); | ||
224 | } | ||
225 | |||
226 | return false; | ||
227 | } | ||
228 | |||
229 | protected LandData FetchLandData(uint x, uint y) | ||
230 | { | ||
231 | handlerGetLandData = OnGetLandData; | ||
232 | if (handlerGetLandData != null) | ||
233 | { | ||
234 | return handlerGetLandData(x, y); | ||
235 | } | ||
236 | return null; | ||
237 | } | ||
238 | |||
239 | #endregion | ||
240 | |||
241 | #region Inform Client of Neighbours | ||
242 | |||
243 | private delegate void InformClientOfNeighbourDelegate( | ||
244 | ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent); | ||
245 | |||
246 | private void InformClientOfNeighbourCompleted(IAsyncResult iar) | ||
247 | { | ||
248 | InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState; | ||
249 | icon.EndInvoke(iar); | ||
250 | } | ||
251 | |||
252 | /// <summary> | ||
253 | /// Async component for informing client of which neighbours exist | ||
254 | /// </summary> | ||
255 | /// <remarks> | ||
256 | /// This needs to run asynchronously, as a network timeout may block the thread for a long while | ||
257 | /// </remarks> | ||
258 | /// <param name="remoteClient"></param> | ||
259 | /// <param name="a"></param> | ||
260 | /// <param name="regionHandle"></param> | ||
261 | /// <param name="endPoint"></param> | ||
262 | private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg, | ||
263 | IPEndPoint endPoint, bool newAgent) | ||
264 | { | ||
265 | // Let's wait just a little to give time to originating regions to catch up with closing child agents | ||
266 | // after a cross here | ||
267 | Thread.Sleep(500); | ||
268 | |||
269 | uint x, y; | ||
270 | Utils.LongToUInts(reg.RegionHandle, out x, out y); | ||
271 | x = x / Constants.RegionSize; | ||
272 | y = y / Constants.RegionSize; | ||
273 | m_log.Info("[INTERGRID]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")"); | ||
274 | |||
275 | string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort | ||
276 | + "/CAPS/" + a.CapsPath + "0000/"; | ||
277 | |||
278 | string reason = String.Empty; | ||
279 | |||
280 | |||
281 | bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason); | ||
282 | |||
283 | if (regionAccepted && newAgent) | ||
284 | { | ||
285 | IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>(); | ||
286 | if (eq != null) | ||
287 | { | ||
288 | #region IP Translation for NAT | ||
289 | IClientIPEndpoint ipepClient; | ||
290 | if (avatar.ClientView.TryGet(out ipepClient)) | ||
291 | { | ||
292 | endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); | ||
293 | } | ||
294 | #endregion | ||
295 | |||
296 | eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID); | ||
297 | eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath); | ||
298 | m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}", | ||
299 | capsPath, avatar.UUID, avatar.Scene.RegionInfo.RegionName); | ||
300 | } | ||
301 | else | ||
302 | { | ||
303 | avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint); | ||
304 | // TODO: make Event Queue disablable! | ||
305 | } | ||
306 | |||
307 | m_log.Info("[INTERGRID]: Completed inform client about neighbour " + endPoint.ToString()); | ||
308 | |||
309 | } | ||
310 | |||
311 | } | ||
312 | |||
313 | public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY) | ||
314 | { | ||
315 | Border[] northBorders = pScene.NorthBorders.ToArray(); | ||
316 | Border[] southBorders = pScene.SouthBorders.ToArray(); | ||
317 | Border[] eastBorders = pScene.EastBorders.ToArray(); | ||
318 | Border[] westBorders = pScene.WestBorders.ToArray(); | ||
319 | |||
320 | // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. | ||
321 | if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) | ||
322 | { | ||
323 | return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID); | ||
324 | } | ||
325 | else | ||
326 | { | ||
327 | Vector2 extent = Vector2.Zero; | ||
328 | for (int i = 0; i < eastBorders.Length; i++) | ||
329 | { | ||
330 | extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; | ||
331 | } | ||
332 | for (int i = 0; i < northBorders.Length; i++) | ||
333 | { | ||
334 | extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; | ||
335 | } | ||
336 | |||
337 | // Loss of fraction on purpose | ||
338 | extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; | ||
339 | extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; | ||
340 | |||
341 | int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize; | ||
342 | int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize; | ||
343 | |||
344 | int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize; | ||
345 | int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize; | ||
346 | |||
347 | List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY); | ||
348 | neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; }); | ||
349 | |||
350 | return neighbours; | ||
351 | } | ||
352 | } | ||
353 | |||
354 | /// <summary> | ||
355 | /// This informs all neighboring regions about agent "avatar". | ||
356 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | ||
357 | /// </summary> | ||
358 | public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours) | ||
359 | { | ||
360 | List<GridRegion> neighbours = new List<GridRegion>(); | ||
361 | |||
362 | if (m_regionInfo != null) | ||
363 | { | ||
364 | neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); | ||
365 | } | ||
366 | else | ||
367 | { | ||
368 | m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?"); | ||
369 | } | ||
370 | |||
371 | /// We need to find the difference between the new regions where there are no child agents | ||
372 | /// and the regions where there are already child agents. We only send notification to the former. | ||
373 | List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region | ||
374 | neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too | ||
375 | List<ulong> previousRegionNeighbourHandles ; | ||
376 | |||
377 | if (avatar.Scene.CapsModule != null) | ||
378 | { | ||
379 | previousRegionNeighbourHandles = | ||
380 | new List<ulong>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys); | ||
381 | } | ||
382 | else | ||
383 | { | ||
384 | previousRegionNeighbourHandles = new List<ulong>(); | ||
385 | } | ||
386 | |||
387 | List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles); | ||
388 | List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles); | ||
389 | |||
390 | //Dump("Current Neighbors", neighbourHandles); | ||
391 | //Dump("Previous Neighbours", previousRegionNeighbourHandles); | ||
392 | //Dump("New Neighbours", newRegions); | ||
393 | //Dump("Old Neighbours", oldRegions); | ||
394 | |||
395 | /// Update the scene presence's known regions here on this region | ||
396 | avatar.DropOldNeighbours(oldRegions); | ||
397 | |||
398 | /// Collect as many seeds as possible | ||
399 | Dictionary<ulong, string> seeds; | ||
400 | if (avatar.Scene.CapsModule != null) | ||
401 | seeds | ||
402 | = new Dictionary<ulong, string>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID)); | ||
403 | else | ||
404 | seeds = new Dictionary<ulong, string>(); | ||
405 | |||
406 | //m_log.Debug(" !!! No. of seeds: " + seeds.Count); | ||
407 | if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle)) | ||
408 | seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath); | ||
409 | |||
410 | /// Create the necessary child agents | ||
411 | List<AgentCircuitData> cagents = new List<AgentCircuitData>(); | ||
412 | foreach (GridRegion neighbour in neighbours) | ||
413 | { | ||
414 | if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle) | ||
415 | { | ||
416 | |||
417 | AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); | ||
418 | agent.BaseFolder = UUID.Zero; | ||
419 | agent.InventoryFolder = UUID.Zero; | ||
420 | agent.startpos = new Vector3(128, 128, 70); | ||
421 | agent.child = true; | ||
422 | |||
423 | if (newRegions.Contains(neighbour.RegionHandle)) | ||
424 | { | ||
425 | agent.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
426 | avatar.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath); | ||
427 | seeds.Add(neighbour.RegionHandle, agent.CapsPath); | ||
428 | } | ||
429 | else | ||
430 | agent.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, neighbour.RegionHandle); | ||
431 | |||
432 | cagents.Add(agent); | ||
433 | } | ||
434 | } | ||
435 | |||
436 | /// Update all child agent with everyone's seeds | ||
437 | foreach (AgentCircuitData a in cagents) | ||
438 | { | ||
439 | a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds); | ||
440 | } | ||
441 | |||
442 | if (avatar.Scene.CapsModule != null) | ||
443 | { | ||
444 | // These two are the same thing! | ||
445 | avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds); | ||
446 | } | ||
447 | avatar.KnownRegions = seeds; | ||
448 | //avatar.Scene.DumpChildrenSeeds(avatar.UUID); | ||
449 | //avatar.DumpKnownRegions(); | ||
450 | |||
451 | bool newAgent = false; | ||
452 | int count = 0; | ||
453 | foreach (GridRegion neighbour in neighbours) | ||
454 | { | ||
455 | // Don't do it if there's already an agent in that region | ||
456 | if (newRegions.Contains(neighbour.RegionHandle)) | ||
457 | newAgent = true; | ||
458 | else | ||
459 | newAgent = false; | ||
460 | |||
461 | if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle) | ||
462 | { | ||
463 | InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; | ||
464 | try | ||
465 | { | ||
466 | d.BeginInvoke(avatar, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent, | ||
467 | InformClientOfNeighbourCompleted, | ||
468 | d); | ||
469 | } | ||
470 | |||
471 | catch (ArgumentOutOfRangeException) | ||
472 | { | ||
473 | m_log.ErrorFormat( | ||
474 | "[REGIONINFO]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).", | ||
475 | neighbour.ExternalHostName, | ||
476 | neighbour.RegionHandle, | ||
477 | neighbour.RegionLocX, | ||
478 | neighbour.RegionLocY); | ||
479 | } | ||
480 | catch (Exception e) | ||
481 | { | ||
482 | m_log.ErrorFormat( | ||
483 | "[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}", | ||
484 | neighbour.ExternalHostName, | ||
485 | neighbour.RegionHandle, | ||
486 | neighbour.RegionLocX, | ||
487 | neighbour.RegionLocY, | ||
488 | e); | ||
489 | |||
490 | // FIXME: Okay, even though we've failed, we're still going to throw the exception on, | ||
491 | // since I don't know what will happen if we just let the client continue | ||
492 | |||
493 | // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes. | ||
494 | // throw e; | ||
495 | |||
496 | } | ||
497 | } | ||
498 | count++; | ||
499 | } | ||
500 | } | ||
501 | |||
502 | /// <summary> | ||
503 | /// This informs a single neighboring region about agent "avatar". | ||
504 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | ||
505 | /// </summary> | ||
506 | public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region) | ||
507 | { | ||
508 | AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); | ||
509 | agent.BaseFolder = UUID.Zero; | ||
510 | agent.InventoryFolder = UUID.Zero; | ||
511 | agent.startpos = new Vector3(128, 128, 70); | ||
512 | agent.child = true; | ||
513 | |||
514 | InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync; | ||
515 | d.BeginInvoke(avatar, agent, region, region.ExternalEndPoint, true, | ||
516 | InformClientOfNeighbourCompleted, | ||
517 | d); | ||
518 | } | ||
519 | |||
520 | #endregion | ||
521 | |||
522 | public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle); | 145 | public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle); |
523 | 146 | ||
524 | private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) | 147 | private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) |
@@ -550,7 +173,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
550 | } | 173 | } |
551 | else | 174 | else |
552 | { | 175 | { |
553 | m_log.WarnFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize); | 176 | m_log.InfoFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize); |
554 | } | 177 | } |
555 | } | 178 | } |
556 | 179 | ||
@@ -592,7 +215,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
592 | try | 215 | try |
593 | { | 216 | { |
594 | //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); | 217 | //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); |
595 | m_interregionCommsOut.SendChildAgentUpdate(regionHandle, cAgentData); | 218 | uint x = 0, y = 0; |
219 | Utils.LongToUInts(regionHandle, out x, out y); | ||
220 | GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | ||
221 | m_scene.SimulationService.UpdateAgent(destination, cAgentData); | ||
596 | } | 222 | } |
597 | catch | 223 | catch |
598 | { | 224 | { |
@@ -652,7 +278,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
652 | // let's do our best, but there's not much we can do if the neighbour doesn't accept. | 278 | // let's do our best, but there's not much we can do if the neighbour doesn't accept. |
653 | 279 | ||
654 | //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); | 280 | //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); |
655 | m_interregionCommsOut.SendCloseAgent(regionHandle, agentID); | 281 | uint x = 0, y = 0; |
282 | Utils.LongToUInts(regionHandle, out x, out y); | ||
283 | GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y); | ||
284 | m_scene.SimulationService.CloseAgent(destination, agentID); | ||
656 | } | 285 | } |
657 | 286 | ||
658 | private void SendCloseChildAgentCompleted(IAsyncResult iar) | 287 | private void SendCloseChildAgentCompleted(IAsyncResult iar) |
@@ -672,848 +301,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
672 | } | 301 | } |
673 | } | 302 | } |
674 | 303 | ||
675 | |||
676 | /// <summary> | ||
677 | /// Try to teleport an agent to a new region. | ||
678 | /// </summary> | ||
679 | /// <param name="remoteClient"></param> | ||
680 | /// <param name="RegionHandle"></param> | ||
681 | /// <param name="position"></param> | ||
682 | /// <param name="lookAt"></param> | ||
683 | /// <param name="flags"></param> | ||
684 | public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position, | ||
685 | Vector3 lookAt, uint teleportFlags) | ||
686 | { | ||
687 | if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID)) | ||
688 | return; | ||
689 | |||
690 | bool destRegionUp = true; | ||
691 | |||
692 | IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>(); | ||
693 | |||
694 | // Reset animations; the viewer does that in teleports. | ||
695 | avatar.Animator.ResetAnimations(); | ||
696 | |||
697 | if (regionHandle == m_regionInfo.RegionHandle) | ||
698 | { | ||
699 | m_log.DebugFormat( | ||
700 | "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}", | ||
701 | position, m_regionInfo.RegionName); | ||
702 | |||
703 | // Teleport within the same region | ||
704 | if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0) | ||
705 | { | ||
706 | Vector3 emergencyPos = new Vector3(128, 128, 128); | ||
707 | |||
708 | m_log.WarnFormat( | ||
709 | "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", | ||
710 | position, avatar.Name, avatar.UUID, emergencyPos); | ||
711 | position = emergencyPos; | ||
712 | } | ||
713 | |||
714 | Vector3 currentPos = avatar.AbsolutePosition; | ||
715 | ILandObject srcLand = m_scene.LandChannel.GetLandObject(currentPos.X, currentPos.Y); | ||
716 | ILandObject destLand = m_scene.LandChannel.GetLandObject(position.X, position.Y); | ||
717 | if (srcLand != null && destLand != null && (teleportFlags & (uint)TeleportFlags.ViaLure) == 0 && (teleportFlags & (uint)TeleportFlags.ViaGodlikeLure) == 0) | ||
718 | { | ||
719 | if (srcLand.LandData.LocalID == destLand.LandData.LocalID) | ||
720 | { | ||
721 | //TPing within the same parcel. If the landing point is restricted, block the TP. | ||
722 | //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. | ||
723 | if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID) | ||
724 | { | ||
725 | //Disabling this behaviour for now pending review. ~CasperW | ||
726 | |||
727 | //avatar.ControllingClient.SendAgentAlertMessage("Can't TP to the destination; landing point set.", false); | ||
728 | //position = currentPos; | ||
729 | } | ||
730 | } | ||
731 | else | ||
732 | { | ||
733 | //Tping to a different parcel. Respect the landing point on the destination parcel. | ||
734 | if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID) | ||
735 | { | ||
736 | position = destLand.LandData.UserLocation; | ||
737 | } | ||
738 | } | ||
739 | } | ||
740 | |||
741 | // TODO: Get proper AVG Height | ||
742 | float localAVHeight = 1.56f; | ||
743 | float posZLimit = 22; | ||
744 | |||
745 | // TODO: Check other Scene HeightField | ||
746 | if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <=(int)Constants.RegionSize) | ||
747 | { | ||
748 | posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y]; | ||
749 | } | ||
750 | |||
751 | float newPosZ = posZLimit + localAVHeight; | ||
752 | if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) | ||
753 | { | ||
754 | position.Z = newPosZ; | ||
755 | } | ||
756 | |||
757 | // Only send this if the event queue is null | ||
758 | if (eq == null) | ||
759 | avatar.ControllingClient.SendTeleportLocationStart(); | ||
760 | |||
761 | avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags); | ||
762 | avatar.Teleport(position); | ||
763 | } | ||
764 | else | ||
765 | { | ||
766 | uint x = 0, y = 0; | ||
767 | Utils.LongToUInts(regionHandle, out x, out y); | ||
768 | GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); | ||
769 | |||
770 | if (reg != null) | ||
771 | { | ||
772 | m_log.DebugFormat( | ||
773 | "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation to {0} in {1}", | ||
774 | position, reg.RegionName); | ||
775 | |||
776 | if (eq == null) | ||
777 | avatar.ControllingClient.SendTeleportLocationStart(); | ||
778 | |||
779 | // Let's do DNS resolution only once in this process, please! | ||
780 | // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field, | ||
781 | // it's actually doing a lot of work. | ||
782 | IPEndPoint endPoint = reg.ExternalEndPoint; | ||
783 | if (endPoint.Address == null) | ||
784 | { | ||
785 | // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses. | ||
786 | destRegionUp = false; | ||
787 | } | ||
788 | |||
789 | if (destRegionUp) | ||
790 | { | ||
791 | uint newRegionX = (uint)(reg.RegionHandle >> 40); | ||
792 | uint newRegionY = (((uint)(reg.RegionHandle)) >> 8); | ||
793 | uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40); | ||
794 | uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8); | ||
795 | |||
796 | // Fixing a bug where teleporting while sitting results in the avatar ending up removed from | ||
797 | // both regions | ||
798 | if (avatar.ParentID != (uint)0) | ||
799 | avatar.StandUp(); | ||
800 | |||
801 | if (!avatar.ValidateAttachments()) | ||
802 | { | ||
803 | avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state"); | ||
804 | return; | ||
805 | } | ||
806 | |||
807 | // the avatar.Close below will clear the child region list. We need this below for (possibly) | ||
808 | // closing the child agents, so save it here (we need a copy as it is Clear()-ed). | ||
809 | //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList()); | ||
810 | // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport | ||
811 | // failure at this point (unlike a border crossing failure). So perhaps this can never fail | ||
812 | // once we reach here... | ||
813 | //avatar.Scene.RemoveCapsHandler(avatar.UUID); | ||
814 | |||
815 | string capsPath = String.Empty; | ||
816 | AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo(); | ||
817 | agentCircuit.BaseFolder = UUID.Zero; | ||
818 | agentCircuit.InventoryFolder = UUID.Zero; | ||
819 | agentCircuit.startpos = position; | ||
820 | agentCircuit.child = true; | ||
821 | |||
822 | if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY)) | ||
823 | { | ||
824 | // brand new agent, let's create a new caps seed | ||
825 | agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath(); | ||
826 | } | ||
827 | |||
828 | string reason = String.Empty; | ||
829 | |||
830 | // Let's create an agent there if one doesn't exist yet. | ||
831 | //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit)) | ||
832 | if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason)) | ||
833 | { | ||
834 | avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}", | ||
835 | reason)); | ||
836 | return; | ||
837 | } | ||
838 | |||
839 | // OK, it got this agent. Let's close some child agents | ||
840 | avatar.CloseChildAgents(newRegionX, newRegionY); | ||
841 | |||
842 | if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY)) | ||
843 | { | ||
844 | #region IP Translation for NAT | ||
845 | IClientIPEndpoint ipepClient; | ||
846 | if (avatar.ClientView.TryGet(out ipepClient)) | ||
847 | { | ||
848 | capsPath | ||
849 | = "http://" | ||
850 | + NetworkUtil.GetHostFor(ipepClient.EndPoint, reg.ExternalHostName) | ||
851 | + ":" | ||
852 | + reg.HttpPort | ||
853 | + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | ||
854 | } | ||
855 | else | ||
856 | { | ||
857 | capsPath | ||
858 | = "http://" | ||
859 | + reg.ExternalHostName | ||
860 | + ":" | ||
861 | + reg.HttpPort | ||
862 | + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath); | ||
863 | } | ||
864 | #endregion | ||
865 | |||
866 | if (eq != null) | ||
867 | { | ||
868 | #region IP Translation for NAT | ||
869 | // Uses ipepClient above | ||
870 | if (avatar.ClientView.TryGet(out ipepClient)) | ||
871 | { | ||
872 | endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address); | ||
873 | } | ||
874 | #endregion | ||
875 | |||
876 | eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID); | ||
877 | |||
878 | // ES makes the client send a UseCircuitCode message to the destination, | ||
879 | // which triggers a bunch of things there. | ||
880 | // So let's wait | ||
881 | Thread.Sleep(2000); | ||
882 | |||
883 | eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath); | ||
884 | } | ||
885 | else | ||
886 | { | ||
887 | avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint); | ||
888 | } | ||
889 | } | ||
890 | else | ||
891 | { | ||
892 | agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle); | ||
893 | capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort | ||
894 | + "/CAPS/" + agentCircuit.CapsPath + "0000/"; | ||
895 | } | ||
896 | |||
897 | // Expect avatar crossing is a heavy-duty function at the destination. | ||
898 | // That is where MakeRoot is called, which fetches appearance and inventory. | ||
899 | // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates. | ||
900 | //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId, | ||
901 | // position, false); | ||
902 | |||
903 | //{ | ||
904 | // avatar.ControllingClient.SendTeleportFailed("Problem with destination."); | ||
905 | // // We should close that agent we just created over at destination... | ||
906 | // List<ulong> lst = new List<ulong>(); | ||
907 | // lst.Add(reg.RegionHandle); | ||
908 | // SendCloseChildAgentAsync(avatar.UUID, lst); | ||
909 | // return; | ||
910 | //} | ||
911 | |||
912 | SetInTransit(avatar.UUID); | ||
913 | // Let's send a full update of the agent. This is a synchronous call. | ||
914 | AgentData agent = new AgentData(); | ||
915 | avatar.CopyTo(agent); | ||
916 | agent.Position = position; | ||
917 | agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort + | ||
918 | "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/"; | ||
919 | |||
920 | m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent); | ||
921 | |||
922 | m_log.DebugFormat( | ||
923 | "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID); | ||
924 | |||
925 | |||
926 | if (eq != null) | ||
927 | { | ||
928 | eq.TeleportFinishEvent(reg.RegionHandle, 13, endPoint, | ||
929 | 0, teleportFlags, capsPath, avatar.UUID); | ||
930 | } | ||
931 | else | ||
932 | { | ||
933 | avatar.ControllingClient.SendRegionTeleport(reg.RegionHandle, 13, endPoint, 4, | ||
934 | teleportFlags, capsPath); | ||
935 | } | ||
936 | |||
937 | // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which | ||
938 | // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation | ||
939 | // that the client contacted the destination before we send the attachments and close things here. | ||
940 | if (!WaitForCallback(avatar.UUID)) | ||
941 | { | ||
942 | // Client never contacted destination. Let's restore everything back | ||
943 | avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination."); | ||
944 | |||
945 | ResetFromTransit(avatar.UUID); | ||
946 | |||
947 | // Yikes! We should just have a ref to scene here. | ||
948 | avatar.Scene.InformClientOfNeighbours(avatar); | ||
949 | |||
950 | // Finally, kill the agent we just created at the destination. | ||
951 | m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID); | ||
952 | |||
953 | return; | ||
954 | } | ||
955 | |||
956 | // Can't go back from here | ||
957 | if (KiPrimitive != null) | ||
958 | { | ||
959 | KiPrimitive(avatar.LocalId); | ||
960 | } | ||
961 | |||
962 | avatar.MakeChildAgent(); | ||
963 | |||
964 | // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it | ||
965 | avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true); | ||
966 | |||
967 | // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone | ||
968 | |||
969 | if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY)) | ||
970 | { | ||
971 | Thread.Sleep(5000); | ||
972 | avatar.Close(); | ||
973 | CloseConnection(avatar.UUID); | ||
974 | } | ||
975 | else | ||
976 | // now we have a child agent in this region. | ||
977 | avatar.Reset(); | ||
978 | |||
979 | |||
980 | // if (teleport success) // seems to be always success here | ||
981 | // the user may change their profile information in other region, | ||
982 | // so the userinfo in UserProfileCache is not reliable any more, delete it | ||
983 | if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) | ||
984 | { | ||
985 | m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID); | ||
986 | m_log.DebugFormat( | ||
987 | "[SCENE COMMUNICATION SERVICE]: User {0} is going to another region, profile cache removed", | ||
988 | avatar.UUID); | ||
989 | } | ||
990 | } | ||
991 | else | ||
992 | { | ||
993 | avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down"); | ||
994 | } | ||
995 | } | ||
996 | else | ||
997 | { | ||
998 | // TP to a place that doesn't exist (anymore) | ||
999 | // Inform the viewer about that | ||
1000 | avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore"); | ||
1001 | |||
1002 | // and set the map-tile to '(Offline)' | ||
1003 | uint regX, regY; | ||
1004 | Utils.LongToUInts(regionHandle, out regX, out regY); | ||
1005 | |||
1006 | MapBlockData block = new MapBlockData(); | ||
1007 | block.X = (ushort)(regX / Constants.RegionSize); | ||
1008 | block.Y = (ushort)(regY / Constants.RegionSize); | ||
1009 | block.Access = 254; // == not there | ||
1010 | |||
1011 | List<MapBlockData> blocks = new List<MapBlockData>(); | ||
1012 | blocks.Add(block); | ||
1013 | avatar.ControllingClient.SendMapBlock(blocks, 0); | ||
1014 | } | ||
1015 | } | ||
1016 | } | ||
1017 | |||
1018 | protected bool IsOutsideRegion(Scene s, Vector3 pos) | ||
1019 | { | ||
1020 | |||
1021 | if (s.TestBorderCross(pos,Cardinals.N)) | ||
1022 | return true; | ||
1023 | if (s.TestBorderCross(pos, Cardinals.S)) | ||
1024 | return true; | ||
1025 | if (s.TestBorderCross(pos, Cardinals.E)) | ||
1026 | return true; | ||
1027 | if (s.TestBorderCross(pos, Cardinals.W)) | ||
1028 | return true; | ||
1029 | |||
1030 | return false; | ||
1031 | } | ||
1032 | |||
1033 | public bool WaitForCallback(UUID id) | ||
1034 | { | ||
1035 | int count = 200; | ||
1036 | while (m_agentsInTransit.Contains(id) && count-- > 0) | ||
1037 | { | ||
1038 | //m_log.Debug(" >>> Waiting... " + count); | ||
1039 | Thread.Sleep(100); | ||
1040 | } | ||
1041 | |||
1042 | if (count > 0) | ||
1043 | return true; | ||
1044 | else | ||
1045 | return false; | ||
1046 | } | ||
1047 | |||
1048 | public bool ReleaseAgent(UUID id) | ||
1049 | { | ||
1050 | //m_log.Debug(" >>> ReleaseAgent called <<< "); | ||
1051 | return ResetFromTransit(id); | ||
1052 | } | ||
1053 | |||
1054 | public void SetInTransit(UUID id) | ||
1055 | { | ||
1056 | lock (m_agentsInTransit) | ||
1057 | { | ||
1058 | if (!m_agentsInTransit.Contains(id)) | ||
1059 | m_agentsInTransit.Add(id); | ||
1060 | } | ||
1061 | } | ||
1062 | |||
1063 | protected bool ResetFromTransit(UUID id) | ||
1064 | { | ||
1065 | lock (m_agentsInTransit) | ||
1066 | { | ||
1067 | if (m_agentsInTransit.Contains(id)) | ||
1068 | { | ||
1069 | m_agentsInTransit.Remove(id); | ||
1070 | return true; | ||
1071 | } | ||
1072 | } | ||
1073 | return false; | ||
1074 | } | ||
1075 | |||
1076 | private List<ulong> NeighbourHandles(List<GridRegion> neighbours) | ||
1077 | { | ||
1078 | List<ulong> handles = new List<ulong>(); | ||
1079 | foreach (GridRegion reg in neighbours) | ||
1080 | { | ||
1081 | handles.Add(reg.RegionHandle); | ||
1082 | } | ||
1083 | return handles; | ||
1084 | } | ||
1085 | |||
1086 | private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) | ||
1087 | { | ||
1088 | return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); }); | ||
1089 | } | ||
1090 | |||
1091 | // private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) | ||
1092 | // { | ||
1093 | // return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); }); | ||
1094 | // } | ||
1095 | |||
1096 | private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours) | ||
1097 | { | ||
1098 | return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); }); | ||
1099 | } | ||
1100 | |||
1101 | public void CrossAgentToNewRegion(Scene scene, ScenePresence agent, bool isFlying) | ||
1102 | { | ||
1103 | Vector3 pos = agent.AbsolutePosition; | ||
1104 | Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z); | ||
1105 | uint neighbourx = m_regionInfo.RegionLocX; | ||
1106 | uint neighboury = m_regionInfo.RegionLocY; | ||
1107 | const float boundaryDistance = 1.7f; | ||
1108 | Vector3 northCross = new Vector3(0,boundaryDistance, 0); | ||
1109 | Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0); | ||
1110 | Vector3 eastCross = new Vector3(boundaryDistance, 0, 0); | ||
1111 | Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0); | ||
1112 | |||
1113 | // distance to edge that will trigger crossing | ||
1114 | |||
1115 | |||
1116 | // distance into new region to place avatar | ||
1117 | const float enterDistance = 0.5f; | ||
1118 | |||
1119 | if (scene.TestBorderCross(pos + westCross, Cardinals.W)) | ||
1120 | { | ||
1121 | if (scene.TestBorderCross(pos + northCross, Cardinals.N)) | ||
1122 | { | ||
1123 | Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); | ||
1124 | neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); | ||
1125 | } | ||
1126 | else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) | ||
1127 | { | ||
1128 | Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); | ||
1129 | if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) | ||
1130 | { | ||
1131 | neighboury--; | ||
1132 | newpos.Y = Constants.RegionSize - enterDistance; | ||
1133 | } | ||
1134 | else | ||
1135 | { | ||
1136 | neighboury = b.TriggerRegionY; | ||
1137 | neighbourx = b.TriggerRegionX; | ||
1138 | |||
1139 | Vector3 newposition = pos; | ||
1140 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | ||
1141 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | ||
1142 | agent.ControllingClient.SendAgentAlertMessage( | ||
1143 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | ||
1144 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | ||
1145 | return; | ||
1146 | } | ||
1147 | } | ||
1148 | |||
1149 | Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W); | ||
1150 | if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) | ||
1151 | { | ||
1152 | neighbourx--; | ||
1153 | newpos.X = Constants.RegionSize - enterDistance; | ||
1154 | } | ||
1155 | else | ||
1156 | { | ||
1157 | neighboury = ba.TriggerRegionY; | ||
1158 | neighbourx = ba.TriggerRegionX; | ||
1159 | |||
1160 | |||
1161 | Vector3 newposition = pos; | ||
1162 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | ||
1163 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | ||
1164 | agent.ControllingClient.SendAgentAlertMessage( | ||
1165 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | ||
1166 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | ||
1167 | |||
1168 | |||
1169 | return; | ||
1170 | } | ||
1171 | |||
1172 | } | ||
1173 | else if (scene.TestBorderCross(pos + eastCross, Cardinals.E)) | ||
1174 | { | ||
1175 | Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E); | ||
1176 | neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); | ||
1177 | newpos.X = enterDistance; | ||
1178 | |||
1179 | if (scene.TestBorderCross(pos + southCross, Cardinals.S)) | ||
1180 | { | ||
1181 | Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S); | ||
1182 | if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0) | ||
1183 | { | ||
1184 | neighboury--; | ||
1185 | newpos.Y = Constants.RegionSize - enterDistance; | ||
1186 | } | ||
1187 | else | ||
1188 | { | ||
1189 | neighboury = ba.TriggerRegionY; | ||
1190 | neighbourx = ba.TriggerRegionX; | ||
1191 | Vector3 newposition = pos; | ||
1192 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | ||
1193 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | ||
1194 | agent.ControllingClient.SendAgentAlertMessage( | ||
1195 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | ||
1196 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | ||
1197 | return; | ||
1198 | } | ||
1199 | } | ||
1200 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) | ||
1201 | { | ||
1202 | Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N); | ||
1203 | neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize); | ||
1204 | newpos.Y = enterDistance; | ||
1205 | } | ||
1206 | |||
1207 | |||
1208 | } | ||
1209 | else if (scene.TestBorderCross(pos + southCross, Cardinals.S)) | ||
1210 | { | ||
1211 | Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S); | ||
1212 | if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0) | ||
1213 | { | ||
1214 | neighboury--; | ||
1215 | newpos.Y = Constants.RegionSize - enterDistance; | ||
1216 | } | ||
1217 | else | ||
1218 | { | ||
1219 | neighboury = b.TriggerRegionY; | ||
1220 | neighbourx = b.TriggerRegionX; | ||
1221 | Vector3 newposition = pos; | ||
1222 | newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize; | ||
1223 | newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize; | ||
1224 | agent.ControllingClient.SendAgentAlertMessage( | ||
1225 | String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false); | ||
1226 | InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene); | ||
1227 | return; | ||
1228 | } | ||
1229 | } | ||
1230 | else if (scene.TestBorderCross(pos + northCross, Cardinals.N)) | ||
1231 | { | ||
1232 | |||
1233 | Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N); | ||
1234 | neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize); | ||
1235 | newpos.Y = enterDistance; | ||
1236 | } | ||
1237 | |||
1238 | /* | ||
1239 | |||
1240 | if (pos.X < boundaryDistance) //West | ||
1241 | { | ||
1242 | neighbourx--; | ||
1243 | newpos.X = Constants.RegionSize - enterDistance; | ||
1244 | } | ||
1245 | else if (pos.X > Constants.RegionSize - boundaryDistance) // East | ||
1246 | { | ||
1247 | neighbourx++; | ||
1248 | newpos.X = enterDistance; | ||
1249 | } | ||
1250 | |||
1251 | if (pos.Y < boundaryDistance) // South | ||
1252 | { | ||
1253 | neighboury--; | ||
1254 | newpos.Y = Constants.RegionSize - enterDistance; | ||
1255 | } | ||
1256 | else if (pos.Y > Constants.RegionSize - boundaryDistance) // North | ||
1257 | { | ||
1258 | neighboury++; | ||
1259 | newpos.Y = enterDistance; | ||
1260 | } | ||
1261 | */ | ||
1262 | |||
1263 | CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync; | ||
1264 | d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d); | ||
1265 | } | ||
1266 | |||
1267 | public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY, | ||
1268 | Vector3 position, | ||
1269 | Scene initiatingScene); | ||
1270 | |||
1271 | public void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position, | ||
1272 | Scene initiatingScene) | ||
1273 | { | ||
1274 | |||
1275 | // This assumes that we know what our neighbors are. | ||
1276 | |||
1277 | InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync; | ||
1278 | d.BeginInvoke(agent,regionX,regionY,position,initiatingScene, | ||
1279 | InformClientToInitiateTeleportToLocationCompleted, | ||
1280 | d); | ||
1281 | } | ||
1282 | |||
1283 | public void InformClientToInitiateTeleportToLocationAsync(ScenePresence agent, uint regionX, uint regionY, Vector3 position, | ||
1284 | Scene initiatingScene) | ||
1285 | { | ||
1286 | Thread.Sleep(10000); | ||
1287 | IMessageTransferModule im = initiatingScene.RequestModuleInterface<IMessageTransferModule>(); | ||
1288 | if (im != null) | ||
1289 | { | ||
1290 | UUID gotoLocation = Util.BuildFakeParcelID( | ||
1291 | Util.UIntsToLong( | ||
1292 | (regionX * | ||
1293 | (uint)Constants.RegionSize), | ||
1294 | (regionY * | ||
1295 | (uint)Constants.RegionSize)), | ||
1296 | (uint)(int)position.X, | ||
1297 | (uint)(int)position.Y, | ||
1298 | (uint)(int)position.Z); | ||
1299 | GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero, | ||
1300 | "Region", agent.UUID, | ||
1301 | (byte)InstantMessageDialog.GodLikeRequestTeleport, false, | ||
1302 | "", gotoLocation, false, new Vector3(127, 0, 0), | ||
1303 | new Byte[0]); | ||
1304 | im.SendInstantMessage(m, delegate(bool success) | ||
1305 | { | ||
1306 | m_log.DebugFormat("[CLIENT]: Client Initiating Teleport sending IM success = {0}", success); | ||
1307 | }); | ||
1308 | |||
1309 | } | ||
1310 | } | ||
1311 | |||
1312 | private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar) | ||
1313 | { | ||
1314 | InformClientToInitateTeleportToLocationDelegate icon = | ||
1315 | (InformClientToInitateTeleportToLocationDelegate) iar.AsyncState; | ||
1316 | icon.EndInvoke(iar); | ||
1317 | } | ||
1318 | |||
1319 | public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying); | ||
1320 | |||
1321 | /// <summary> | ||
1322 | /// This Closes child agents on neighboring regions | ||
1323 | /// Calls an asynchronous method to do so.. so it doesn't lag the sim. | ||
1324 | /// </summary> | ||
1325 | protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying) | ||
1326 | { | ||
1327 | m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); | ||
1328 | |||
1329 | ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); | ||
1330 | |||
1331 | int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize); | ||
1332 | GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y); | ||
1333 | |||
1334 | if (neighbourRegion != null && agent.ValidateAttachments()) | ||
1335 | { | ||
1336 | pos = pos + (agent.Velocity); | ||
1337 | |||
1338 | //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID); | ||
1339 | //if (userInfo != null) | ||
1340 | //{ | ||
1341 | // userInfo.DropInventory(); | ||
1342 | //} | ||
1343 | //else | ||
1344 | //{ | ||
1345 | // m_log.WarnFormat("[SCENE COMM]: No cached user info found for {0} {1} on leaving region {2}", | ||
1346 | // agent.Name, agent.UUID, agent.Scene.RegionInfo.RegionName); | ||
1347 | //} | ||
1348 | |||
1349 | //bool crossingSuccessful = | ||
1350 | // CrossToNeighbouringRegion(neighbourHandle, agent.ControllingClient.AgentId, pos, | ||
1351 | //isFlying); | ||
1352 | |||
1353 | SetInTransit(agent.UUID); | ||
1354 | AgentData cAgent = new AgentData(); | ||
1355 | agent.CopyTo(cAgent); | ||
1356 | cAgent.Position = pos; | ||
1357 | if (isFlying) | ||
1358 | cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY; | ||
1359 | cAgent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort + | ||
1360 | "/agent/" + agent.UUID.ToString() + "/" + agent.Scene.RegionInfo.RegionHandle.ToString() + "/release/"; | ||
1361 | |||
1362 | m_interregionCommsOut.SendChildAgentUpdate(neighbourHandle, cAgent); | ||
1363 | |||
1364 | // Next, let's close the child agent connections that are too far away. | ||
1365 | agent.CloseChildAgents(neighbourx, neighboury); | ||
1366 | |||
1367 | //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo(); | ||
1368 | agent.ControllingClient.RequestClientInfo(); | ||
1369 | |||
1370 | //m_log.Debug("BEFORE CROSS"); | ||
1371 | //Scene.DumpChildrenSeeds(UUID); | ||
1372 | //DumpKnownRegions(); | ||
1373 | string agentcaps; | ||
1374 | if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps)) | ||
1375 | { | ||
1376 | m_log.ErrorFormat("[SCENE COMM]: No CAPS information for region handle {0}, exiting CrossToNewRegion.", | ||
1377 | neighbourRegion.RegionHandle); | ||
1378 | return agent; | ||
1379 | } | ||
1380 | // TODO Should construct this behind a method | ||
1381 | string capsPath = | ||
1382 | "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort | ||
1383 | + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/"; | ||
1384 | |||
1385 | m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID); | ||
1386 | |||
1387 | IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>(); | ||
1388 | if (eq != null) | ||
1389 | { | ||
1390 | eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, | ||
1391 | capsPath, agent.UUID, agent.ControllingClient.SessionId); | ||
1392 | } | ||
1393 | else | ||
1394 | { | ||
1395 | agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint, | ||
1396 | capsPath); | ||
1397 | } | ||
1398 | |||
1399 | if (!WaitForCallback(agent.UUID)) | ||
1400 | { | ||
1401 | ResetFromTransit(agent.UUID); | ||
1402 | |||
1403 | // Yikes! We should just have a ref to scene here. | ||
1404 | agent.Scene.InformClientOfNeighbours(agent); | ||
1405 | |||
1406 | return agent; | ||
1407 | } | ||
1408 | |||
1409 | agent.MakeChildAgent(); | ||
1410 | // now we have a child agent in this region. Request all interesting data about other (root) agents | ||
1411 | agent.SendInitialFullUpdateToAllClients(); | ||
1412 | |||
1413 | agent.CrossAttachmentsIntoNewRegion(neighbourHandle, true); | ||
1414 | |||
1415 | // m_scene.SendKillObject(m_localId); | ||
1416 | |||
1417 | agent.Scene.NotifyMyCoarseLocationChange(); | ||
1418 | // the user may change their profile information in other region, | ||
1419 | // so the userinfo in UserProfileCache is not reliable any more, delete it | ||
1420 | if (agent.Scene.NeedSceneCacheClear(agent.UUID)) | ||
1421 | { | ||
1422 | agent.Scene.CommsManager.UserProfileCacheService.RemoveUser(agent.UUID); | ||
1423 | m_log.DebugFormat( | ||
1424 | "[SCENE COMM]: User {0} is going to another region, profile cache removed", agent.UUID); | ||
1425 | } | ||
1426 | } | ||
1427 | |||
1428 | //m_log.Debug("AFTER CROSS"); | ||
1429 | //Scene.DumpChildrenSeeds(UUID); | ||
1430 | //DumpKnownRegions(); | ||
1431 | return agent; | ||
1432 | } | ||
1433 | |||
1434 | private void CrossAgentToNewRegionCompleted(IAsyncResult iar) | ||
1435 | { | ||
1436 | CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState; | ||
1437 | ScenePresence agent = icon.EndInvoke(iar); | ||
1438 | |||
1439 | // If the cross was successful, this agent is a child agent | ||
1440 | if (agent.IsChildAgent) | ||
1441 | { | ||
1442 | agent.Reset(); | ||
1443 | } | ||
1444 | else // Not successful | ||
1445 | { | ||
1446 | //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID); | ||
1447 | //if (userInfo != null) | ||
1448 | //{ | ||
1449 | // userInfo.FetchInventory(); | ||
1450 | //} | ||
1451 | agent.RestoreInCurrentScene(); | ||
1452 | } | ||
1453 | // In any case | ||
1454 | agent.NotInTransit(); | ||
1455 | |||
1456 | //m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname); | ||
1457 | } | ||
1458 | |||
1459 | |||
1460 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) | ||
1461 | { | ||
1462 | m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat); | ||
1463 | } | ||
1464 | |||
1465 | // deprecated as of 2008-08-27 | ||
1466 | public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz) | ||
1467 | { | ||
1468 | m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz); | ||
1469 | } | ||
1470 | |||
1471 | public void ClearUserAgent(UUID avatarID) | ||
1472 | { | ||
1473 | m_commsProvider.UserService.ClearUserAgent(avatarID); | ||
1474 | } | ||
1475 | |||
1476 | public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms) | ||
1477 | { | ||
1478 | m_commsProvider.AddNewUserFriend(friendlistowner, friend, perms); | ||
1479 | } | ||
1480 | |||
1481 | public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms) | ||
1482 | { | ||
1483 | m_commsProvider.UpdateUserFriendPerms(friendlistowner, friend, perms); | ||
1484 | } | ||
1485 | |||
1486 | public void RemoveUserFriend(UUID friendlistowner, UUID friend) | ||
1487 | { | ||
1488 | m_commsProvider.RemoveUserFriend(friendlistowner, friend); | ||
1489 | } | ||
1490 | |||
1491 | public List<FriendListItem> GetUserFriendList(UUID friendlistowner) | ||
1492 | { | ||
1493 | return m_commsProvider.GetUserFriendList(friendlistowner); | ||
1494 | } | ||
1495 | |||
1496 | public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) | ||
1497 | { | ||
1498 | return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); | ||
1499 | } | ||
1500 | |||
1501 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) | 304 | public List<GridRegion> RequestNamedRegions(string name, int maxNumber) |
1502 | { | 305 | { |
1503 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); | 306 | return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); |
1504 | } | 307 | } |
1505 | 308 | ||
1506 | //private void Dump(string msg, List<ulong> handles) | ||
1507 | //{ | ||
1508 | // m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg); | ||
1509 | // foreach (ulong handle in handles) | ||
1510 | // { | ||
1511 | // uint x, y; | ||
1512 | // Utils.LongToUInts(handle, out x, out y); | ||
1513 | // x = x / Constants.RegionSize; | ||
1514 | // y = y / Constants.RegionSize; | ||
1515 | // m_log.InfoFormat("({0}, {1})", x, y); | ||
1516 | // } | ||
1517 | //} | ||
1518 | } | 309 | } |
1519 | } | 310 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs index e28d29f..db70d6a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs +++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs | |||
@@ -35,6 +35,7 @@ using log4net; | |||
35 | using OpenSim.Framework; | 35 | using OpenSim.Framework; |
36 | using OpenSim.Region.Framework.Scenes.Types; | 36 | using OpenSim.Region.Framework.Scenes.Types; |
37 | using OpenSim.Region.Physics.Manager; | 37 | using OpenSim.Region.Physics.Manager; |
38 | using OpenSim.Region.Framework.Interfaces; | ||
38 | 39 | ||
39 | namespace OpenSim.Region.Framework.Scenes | 40 | namespace OpenSim.Region.Framework.Scenes |
40 | { | 41 | { |
@@ -252,7 +253,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
252 | sceneObject.HasGroupChanged = true; | 253 | sceneObject.HasGroupChanged = true; |
253 | } | 254 | } |
254 | 255 | ||
255 | return AddSceneObject(sceneObject, attachToBackup); | 256 | return AddSceneObject(sceneObject, attachToBackup, true); |
256 | } | 257 | } |
257 | 258 | ||
258 | /// <summary> | 259 | /// <summary> |
@@ -267,12 +268,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
267 | /// <returns> | 268 | /// <returns> |
268 | /// true if the object was added, false if an object with the same uuid was already in the scene | 269 | /// true if the object was added, false if an object with the same uuid was already in the scene |
269 | /// </returns> | 270 | /// </returns> |
270 | protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) | 271 | protected internal bool AddNewSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) |
271 | { | 272 | { |
272 | // Ensure that we persist this new scene object | 273 | // Ensure that we persist this new scene object |
273 | sceneObject.HasGroupChanged = true; | 274 | sceneObject.HasGroupChanged = true; |
274 | 275 | ||
275 | return AddSceneObject(sceneObject, attachToBackup); | 276 | return AddSceneObject(sceneObject, attachToBackup, sendClientUpdates); |
276 | } | 277 | } |
277 | 278 | ||
278 | /// <summary> | 279 | /// <summary> |
@@ -284,12 +285,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
284 | /// If true, the object is made persistent into the scene. | 285 | /// If true, the object is made persistent into the scene. |
285 | /// If false, the object will not persist over server restarts | 286 | /// If false, the object will not persist over server restarts |
286 | /// </param> | 287 | /// </param> |
287 | /// <returns>true if the object was added, false if an object with the same uuid was already in the scene | 288 | /// <param name="sendClientUpdates"> |
289 | /// If true, updates for the new scene object are sent to all viewers in range. | ||
290 | /// If false, it is left to the caller to schedule the update | ||
291 | /// </param> | ||
292 | /// <returns> | ||
293 | /// true if the object was added, false if an object with the same uuid was already in the scene | ||
288 | /// </returns> | 294 | /// </returns> |
289 | protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup) | 295 | protected bool AddSceneObject(SceneObjectGroup sceneObject, bool attachToBackup, bool sendClientUpdates) |
290 | { | 296 | { |
291 | if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero) | 297 | if (sceneObject == null || sceneObject.RootPart == null || sceneObject.RootPart.UUID == UUID.Zero) |
292 | return false; | 298 | return false; |
299 | |||
300 | bool alreadyExisted = false; | ||
293 | 301 | ||
294 | if (m_parentScene.m_clampPrimSize) | 302 | if (m_parentScene.m_clampPrimSize) |
295 | { | 303 | { |
@@ -310,6 +318,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
310 | 318 | ||
311 | sceneObject.AttachToScene(m_parentScene); | 319 | sceneObject.AttachToScene(m_parentScene); |
312 | 320 | ||
321 | if (sendClientUpdates) | ||
322 | sceneObject.ScheduleGroupForFullUpdate(); | ||
323 | |||
313 | lock (sceneObject) | 324 | lock (sceneObject) |
314 | { | 325 | { |
315 | if (!Entities.ContainsKey(sceneObject.UUID)) | 326 | if (!Entities.ContainsKey(sceneObject.UUID)) |
@@ -333,12 +344,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
333 | SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; | 344 | SceneObjectGroupsByLocalID[part.LocalId] = sceneObject; |
334 | } | 345 | } |
335 | } | 346 | } |
336 | 347 | } | |
337 | return true; | 348 | else |
349 | { | ||
350 | alreadyExisted = true; | ||
338 | } | 351 | } |
339 | } | 352 | } |
340 | 353 | ||
341 | return false; | 354 | return alreadyExisted; |
342 | } | 355 | } |
343 | 356 | ||
344 | /// <summary> | 357 | /// <summary> |
@@ -463,7 +476,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
463 | if (group != null) | 476 | if (group != null) |
464 | { | 477 | { |
465 | //group.DetachToGround(); | 478 | //group.DetachToGround(); |
466 | m_parentScene.DetachSingleAttachmentToInv(group.GetFromItemID(), remoteClient); | 479 | m_parentScene.AttachmentsModule.ShowDetachInUserInventory(group.GetFromItemID(), remoteClient); |
467 | } | 480 | } |
468 | } | 481 | } |
469 | 482 | ||
@@ -497,204 +510,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
497 | } | 510 | } |
498 | } | 511 | } |
499 | 512 | ||
500 | /// <summary> | ||
501 | /// Event Handling routine for Attach Object | ||
502 | /// </summary> | ||
503 | /// <param name="remoteClient"></param> | ||
504 | /// <param name="objectLocalID"></param> | ||
505 | /// <param name="AttachmentPt"></param> | ||
506 | /// <param name="rot"></param> | ||
507 | protected internal void AttachObject(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, bool silent) | ||
508 | { | ||
509 | // If we can't take it, we can't attach it! | ||
510 | SceneObjectPart part = m_parentScene.GetSceneObjectPart(objectLocalID); | ||
511 | if (part == null) | ||
512 | return; | ||
513 | |||
514 | if (!m_parentScene.Permissions.CanTakeObject(part.UUID, remoteClient.AgentId)) | ||
515 | return; | ||
516 | |||
517 | // Calls attach with a Zero position | ||
518 | if (AttachObject(remoteClient, objectLocalID, AttachmentPt, rot, Vector3.Zero, false)) | ||
519 | { | ||
520 | m_parentScene.SendAttachEvent(objectLocalID, part.ParentGroup.GetFromItemID(), remoteClient.AgentId); | ||
521 | |||
522 | // Save avatar attachment information | ||
523 | ScenePresence presence; | ||
524 | if (m_parentScene.AvatarFactory != null && m_parentScene.TryGetAvatar(remoteClient.AgentId, out presence)) | ||
525 | { | ||
526 | m_log.Info( | ||
527 | "[SCENE]: Saving avatar attachment. AgentID: " + remoteClient.AgentId | ||
528 | + ", AttachmentPoint: " + AttachmentPt); | ||
529 | |||
530 | m_parentScene.AvatarFactory.UpdateDatabase(remoteClient.AgentId, presence.Appearance); | ||
531 | } | ||
532 | } | ||
533 | } | ||
534 | |||
535 | /// <summary> | ||
536 | /// Rez an attachment | ||
537 | /// </summary> | ||
538 | /// <param name="remoteClient"></param> | ||
539 | /// <param name="itemID"></param> | ||
540 | /// <param name="AttachmentPt"></param> | ||
541 | /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> | ||
542 | public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) | ||
543 | { | ||
544 | SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, | ||
545 | itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, | ||
546 | false, false, remoteClient.AgentId, true); | ||
547 | |||
548 | if (objatt != null) | ||
549 | { | ||
550 | bool tainted = false; | ||
551 | if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) | ||
552 | tainted = true; | ||
553 | |||
554 | if (AttachObject( | ||
555 | remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false)) | ||
556 | { | ||
557 | objatt.ScheduleGroupForFullUpdate(); | ||
558 | if (tainted) | ||
559 | objatt.HasGroupChanged = true; | ||
560 | |||
561 | // Fire after attach, so we don't get messy perms dialogs | ||
562 | // 3 == AttachedRez | ||
563 | objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); | ||
564 | |||
565 | // Do this last so that event listeners have access to all the effects of the attachment | ||
566 | m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId); | ||
567 | } | ||
568 | } | ||
569 | |||
570 | return objatt; | ||
571 | } | ||
572 | |||
573 | // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. | ||
574 | // To LocalId or UUID, *THAT* is the question. How now Brown UUID?? | ||
575 | public void DetachSingleAttachmentToInv(UUID itemID, IClientAPI remoteClient) | ||
576 | { | ||
577 | if (itemID == UUID.Zero) // If this happened, someone made a mistake.... | ||
578 | return; | ||
579 | |||
580 | // We can NOT use the dictionries here, as we are looking | ||
581 | // for an entity by the fromAssetID, which is NOT the prim UUID | ||
582 | // | ||
583 | List<EntityBase> detachEntities = GetEntities(); | ||
584 | SceneObjectGroup group; | ||
585 | |||
586 | foreach (EntityBase entity in detachEntities) | ||
587 | { | ||
588 | if (entity is SceneObjectGroup) | ||
589 | { | ||
590 | group = (SceneObjectGroup)entity; | ||
591 | if (group.GetFromItemID() == itemID) | ||
592 | { | ||
593 | m_parentScene.SendAttachEvent(group.LocalId, itemID, UUID.Zero); | ||
594 | bool hasScripts = false; | ||
595 | foreach (SceneObjectPart part in group.Children.Values) | ||
596 | { | ||
597 | if (part.Inventory.ContainsScripts()) | ||
598 | { | ||
599 | hasScripts = true; | ||
600 | break; | ||
601 | } | ||
602 | } | ||
603 | |||
604 | if (hasScripts) // Allow the object to execute the attach(NULL_KEY) event | ||
605 | System.Threading.Thread.Sleep(100); | ||
606 | group.DetachToInventoryPrep(); | ||
607 | m_log.Debug("[DETACH]: Saving attachpoint: " + | ||
608 | ((uint)group.GetAttachmentPoint()).ToString()); | ||
609 | m_parentScene.UpdateKnownItem(remoteClient, group, | ||
610 | group.GetFromItemID(), group.OwnerID); | ||
611 | m_parentScene.DeleteSceneObject(group, false); | ||
612 | return; | ||
613 | } | ||
614 | } | ||
615 | } | ||
616 | } | ||
617 | |||
618 | /// <summary> | ||
619 | /// Attach a scene object to an avatar. | ||
620 | /// </summary> | ||
621 | /// <param name="remoteClient"></param> | ||
622 | /// <param name="objectLocalID"></param> | ||
623 | /// <param name="AttachmentPt"></param> | ||
624 | /// <param name="rot"></param> | ||
625 | /// <param name="attachPos"></param> | ||
626 | /// <param name="silent"></param> | ||
627 | /// <returns>true if the attachment was successful, false otherwise</returns> | ||
628 | protected internal bool AttachObject( | ||
629 | IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, Quaternion rot, Vector3 attachPos, bool silent) | ||
630 | { | ||
631 | SceneObjectGroup group = GetGroupByPrim(objectLocalID); | ||
632 | if (group != null) | ||
633 | { | ||
634 | if (m_parentScene.Permissions.CanTakeObject(group.UUID, remoteClient.AgentId)) | ||
635 | { | ||
636 | // If the attachment point isn't the same as the one previously used | ||
637 | // set it's offset position = 0 so that it appears on the attachment point | ||
638 | // and not in a weird location somewhere unknown. | ||
639 | if (AttachmentPt != 0 && AttachmentPt != (uint)group.GetAttachmentPoint()) | ||
640 | { | ||
641 | attachPos = Vector3.Zero; | ||
642 | } | ||
643 | |||
644 | // AttachmentPt 0 means the client chose to 'wear' the attachment. | ||
645 | if (AttachmentPt == 0) | ||
646 | { | ||
647 | // Check object for stored attachment point | ||
648 | AttachmentPt = (uint)group.GetAttachmentPoint(); | ||
649 | } | ||
650 | |||
651 | // if we still didn't find a suitable attachment point....... | ||
652 | if (AttachmentPt == 0) | ||
653 | { | ||
654 | // Stick it on left hand with Zero Offset from the attachment point. | ||
655 | AttachmentPt = (uint)AttachmentPoint.LeftHand; | ||
656 | attachPos = Vector3.Zero; | ||
657 | } | ||
658 | |||
659 | group.SetAttachmentPoint((byte)AttachmentPt); | ||
660 | group.AbsolutePosition = attachPos; | ||
661 | |||
662 | // Saves and gets itemID | ||
663 | UUID itemId; | ||
664 | |||
665 | if (group.GetFromItemID() == UUID.Zero) | ||
666 | { | ||
667 | m_parentScene.attachObjectAssetStore(remoteClient, group, remoteClient.AgentId, out itemId); | ||
668 | } | ||
669 | else | ||
670 | { | ||
671 | itemId = group.GetFromItemID(); | ||
672 | } | ||
673 | |||
674 | m_parentScene.AttachObject(remoteClient, AttachmentPt, itemId, group); | ||
675 | |||
676 | group.AttachToAgent(remoteClient.AgentId, AttachmentPt, attachPos, silent); | ||
677 | // In case it is later dropped again, don't let | ||
678 | // it get cleaned up | ||
679 | // | ||
680 | group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); | ||
681 | group.HasGroupChanged = false; | ||
682 | } | ||
683 | else | ||
684 | { | ||
685 | remoteClient.SendAgentAlertMessage("You don't have sufficient permissions to attach this object", false); | ||
686 | return false; | ||
687 | } | ||
688 | } | ||
689 | else | ||
690 | { | ||
691 | m_log.DebugFormat("[SCENE GRAPH]: AttachObject found no such scene object {0}", objectLocalID); | ||
692 | return false; | ||
693 | } | ||
694 | |||
695 | return true; | ||
696 | } | ||
697 | |||
698 | protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) | 513 | protected internal ScenePresence CreateAndAddChildScenePresence(IClientAPI client, AvatarAppearance appearance) |
699 | { | 514 | { |
700 | ScenePresence newAvatar = null; | 515 | ScenePresence newAvatar = null; |
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs index c2e3370..680c39a 100644 --- a/OpenSim/Region/Framework/Scenes/SceneManager.cs +++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs | |||
@@ -422,7 +422,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
422 | 422 | ||
423 | if (!scenePresence.IsChildAgent) | 423 | if (!scenePresence.IsChildAgent) |
424 | { | 424 | { |
425 | m_log.ErrorFormat("Packet debug for {0} {1} set to {2}", | 425 | m_log.DebugFormat("Packet debug for {0} {1} set to {2}", |
426 | scenePresence.Firstname, | 426 | scenePresence.Firstname, |
427 | scenePresence.Lastname, | 427 | scenePresence.Lastname, |
428 | newDebug); | 428 | newDebug); |
@@ -468,11 +468,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
468 | return presences; | 468 | return presences; |
469 | } | 469 | } |
470 | 470 | ||
471 | public RegionInfo GetRegionInfo(ulong regionHandle) | 471 | public RegionInfo GetRegionInfo(UUID regionID) |
472 | { | 472 | { |
473 | foreach (Scene scene in m_localScenes) | 473 | foreach (Scene scene in m_localScenes) |
474 | { | 474 | { |
475 | if (scene.RegionInfo.RegionHandle == regionHandle) | 475 | if (scene.RegionInfo.RegionID == regionID) |
476 | { | 476 | { |
477 | return scene.RegionInfo; | 477 | return scene.RegionInfo; |
478 | } | 478 | } |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 5443c28..d083119 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | |||
@@ -377,6 +377,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
377 | RootPart.ScriptSetPhysicsStatus(false); | 377 | RootPart.ScriptSetPhysicsStatus(false); |
378 | Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), | 378 | Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"), |
379 | ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); | 379 | ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false); |
380 | lockPartsForRead(false); | ||
380 | return; | 381 | return; |
381 | } | 382 | } |
382 | } | 383 | } |
@@ -489,8 +490,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
489 | private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); | 490 | private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); |
490 | public List<SceneObjectPart> PlaySoundSlavePrims | 491 | public List<SceneObjectPart> PlaySoundSlavePrims |
491 | { | 492 | { |
492 | get { return m_LoopSoundSlavePrims; } | 493 | get { return m_PlaySoundSlavePrims; } |
493 | set { m_LoopSoundSlavePrims = value; } | 494 | set { m_PlaySoundSlavePrims = value; } |
494 | } | 495 | } |
495 | 496 | ||
496 | private SceneObjectPart m_LoopSoundMasterPrim = null; | 497 | private SceneObjectPart m_LoopSoundMasterPrim = null; |
@@ -642,8 +643,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
642 | } | 643 | } |
643 | 644 | ||
644 | ApplyPhysics(m_scene.m_physicalPrim); | 645 | ApplyPhysics(m_scene.m_physicalPrim); |
645 | 646 | ||
646 | ScheduleGroupForFullUpdate(); | 647 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled |
648 | // for the same object with very different properties. The caller must schedule the update. | ||
649 | //ScheduleGroupForFullUpdate(); | ||
647 | } | 650 | } |
648 | 651 | ||
649 | public Vector3 GroupScale() | 652 | public Vector3 GroupScale() |
@@ -1045,10 +1048,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
1045 | // don't attach attachments to child agents | 1048 | // don't attach attachments to child agents |
1046 | if (avatar.IsChildAgent) return; | 1049 | if (avatar.IsChildAgent) return; |
1047 | 1050 | ||
1051 | // m_log.DebugFormat("[SOG]: Adding attachment {0} to avatar {1}", Name, avatar.Name); | ||
1052 | |||
1048 | DetachFromBackup(); | 1053 | DetachFromBackup(); |
1049 | 1054 | ||
1050 | // Remove from database and parcel prim count | 1055 | // Remove from database and parcel prim count |
1051 | // | ||
1052 | m_scene.DeleteFromStorage(UUID); | 1056 | m_scene.DeleteFromStorage(UUID); |
1053 | m_scene.EventManager.TriggerParcelPrimCountTainted(); | 1057 | m_scene.EventManager.TriggerParcelPrimCountTainted(); |
1054 | 1058 | ||
@@ -1074,7 +1078,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
1074 | SetAttachmentPoint(Convert.ToByte(attachmentpoint)); | 1078 | SetAttachmentPoint(Convert.ToByte(attachmentpoint)); |
1075 | 1079 | ||
1076 | avatar.AddAttachment(this); | 1080 | avatar.AddAttachment(this); |
1077 | m_log.Debug("[SOG]: Added attachment " + UUID + " to avatar " + avatar.UUID); | ||
1078 | 1081 | ||
1079 | if (!silent) | 1082 | if (!silent) |
1080 | { | 1083 | { |
@@ -1091,6 +1094,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1091 | ScheduleGroupForFullUpdate(); | 1094 | ScheduleGroupForFullUpdate(); |
1092 | } | 1095 | } |
1093 | } | 1096 | } |
1097 | else | ||
1098 | { | ||
1099 | m_log.WarnFormat( | ||
1100 | "[SOG]: Tried to add attachment {0} to avatar with UUID {1} in region {2} but the avatar is not present", | ||
1101 | UUID, agentID, Scene.RegionInfo.RegionName); | ||
1102 | } | ||
1094 | } | 1103 | } |
1095 | 1104 | ||
1096 | public byte GetAttachmentPoint() | 1105 | public byte GetAttachmentPoint() |
@@ -1597,11 +1606,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1597 | 1606 | ||
1598 | #endregion | 1607 | #endregion |
1599 | 1608 | ||
1600 | #region Client Updating | ||
1601 | |||
1602 | public void SendFullUpdateToClient(IClientAPI remoteClient) | 1609 | public void SendFullUpdateToClient(IClientAPI remoteClient) |
1603 | { | 1610 | { |
1604 | SendPartFullUpdate(remoteClient, RootPart, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); | 1611 | RootPart.SendFullUpdate( |
1612 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, RootPart.UUID)); | ||
1605 | 1613 | ||
1606 | lockPartsForRead(true); | 1614 | lockPartsForRead(true); |
1607 | { | 1615 | { |
@@ -1609,42 +1617,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
1609 | { | 1617 | { |
1610 | 1618 | ||
1611 | if (part != RootPart) | 1619 | if (part != RootPart) |
1612 | SendPartFullUpdate(remoteClient, part, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); | 1620 | part.SendFullUpdate( |
1613 | 1621 | remoteClient, m_scene.Permissions.GenerateClientFlags(remoteClient.AgentId, part.UUID)); | |
1614 | } | 1622 | } |
1615 | } | 1623 | } |
1616 | lockPartsForRead(false); | ||
1617 | } | 1624 | } |
1618 | 1625 | ||
1619 | /// <summary> | ||
1620 | /// Send a full update to the client for the given part | ||
1621 | /// </summary> | ||
1622 | /// <param name="remoteClient"></param> | ||
1623 | /// <param name="part"></param> | ||
1624 | internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags) | ||
1625 | { | ||
1626 | // m_log.DebugFormat( | ||
1627 | // "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); | ||
1628 | |||
1629 | if (m_rootPart.UUID == part.UUID) | ||
1630 | { | ||
1631 | if (IsAttachment) | ||
1632 | { | ||
1633 | part.SendFullUpdateToClient(remoteClient, m_rootPart.AttachedPos, clientFlags); | ||
1634 | } | ||
1635 | else | ||
1636 | { | ||
1637 | part.SendFullUpdateToClient(remoteClient, AbsolutePosition, clientFlags); | ||
1638 | } | ||
1639 | } | ||
1640 | else | ||
1641 | { | ||
1642 | part.SendFullUpdateToClient(remoteClient, clientFlags); | ||
1643 | } | ||
1644 | } | ||
1645 | |||
1646 | #endregion | ||
1647 | |||
1648 | #region Copying | 1626 | #region Copying |
1649 | 1627 | ||
1650 | /// <summary> | 1628 | /// <summary> |
@@ -2136,6 +2114,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2136 | 2114 | ||
2137 | public void ScheduleFullUpdateToAvatar(ScenePresence presence) | 2115 | public void ScheduleFullUpdateToAvatar(ScenePresence presence) |
2138 | { | 2116 | { |
2117 | // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1} just to avatar {2}", Name, UUID, presence.Name); | ||
2118 | |||
2139 | RootPart.AddFullUpdateToAvatar(presence); | 2119 | RootPart.AddFullUpdateToAvatar(presence); |
2140 | 2120 | ||
2141 | lockPartsForRead(true); | 2121 | lockPartsForRead(true); |
@@ -2154,14 +2134,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2154 | public void ScheduleTerseUpdateToAvatar(ScenePresence presence) | 2134 | public void ScheduleTerseUpdateToAvatar(ScenePresence presence) |
2155 | { | 2135 | { |
2156 | lockPartsForRead(true); | 2136 | lockPartsForRead(true); |
2137 | |||
2138 | foreach (SceneObjectPart part in m_parts.Values) | ||
2157 | { | 2139 | { |
2158 | foreach (SceneObjectPart part in m_parts.Values) | 2140 | part.AddTerseUpdateToAvatar(presence); |
2159 | { | ||
2160 | |||
2161 | part.AddTerseUpdateToAvatar(presence); | ||
2162 | |||
2163 | } | ||
2164 | } | 2141 | } |
2142 | |||
2165 | lockPartsForRead(false); | 2143 | lockPartsForRead(false); |
2166 | } | 2144 | } |
2167 | 2145 | ||
@@ -2170,6 +2148,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2170 | /// </summary> | 2148 | /// </summary> |
2171 | public void ScheduleGroupForFullUpdate() | 2149 | public void ScheduleGroupForFullUpdate() |
2172 | { | 2150 | { |
2151 | // m_log.DebugFormat("[SOG]: Scheduling full update for {0} {1}", Name, UUID); | ||
2152 | |||
2173 | checkAtTargets(); | 2153 | checkAtTargets(); |
2174 | RootPart.ScheduleFullUpdate(); | 2154 | RootPart.ScheduleFullUpdate(); |
2175 | 2155 | ||
@@ -2192,14 +2172,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2192 | public void ScheduleGroupForTerseUpdate() | 2172 | public void ScheduleGroupForTerseUpdate() |
2193 | { | 2173 | { |
2194 | lockPartsForRead(true); | 2174 | lockPartsForRead(true); |
2175 | |||
2176 | foreach (SceneObjectPart part in m_parts.Values) | ||
2195 | { | 2177 | { |
2196 | foreach (SceneObjectPart part in m_parts.Values) | 2178 | part.ScheduleTerseUpdate(); |
2197 | { | ||
2198 | |||
2199 | part.ScheduleTerseUpdate(); | ||
2200 | |||
2201 | } | ||
2202 | } | 2179 | } |
2180 | |||
2203 | lockPartsForRead(false); | 2181 | lockPartsForRead(false); |
2204 | } | 2182 | } |
2205 | 2183 | ||
@@ -2210,6 +2188,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2210 | { | 2188 | { |
2211 | if (IsDeleted) | 2189 | if (IsDeleted) |
2212 | return; | 2190 | return; |
2191 | |||
2192 | // m_log.DebugFormat("[SOG]: Sending immediate full group update for {0} {1}", Name, UUID); | ||
2213 | 2193 | ||
2214 | RootPart.SendFullUpdateToAllClients(); | 2194 | RootPart.SendFullUpdateToAllClients(); |
2215 | 2195 | ||
@@ -2229,7 +2209,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2229 | /// <summary> | 2209 | /// <summary> |
2230 | /// Immediately send an update for this scene object's root prim only. | 2210 | /// Immediately send an update for this scene object's root prim only. |
2231 | /// This is for updates regarding the object as a whole, and none of its parts in particular. | 2211 | /// This is for updates regarding the object as a whole, and none of its parts in particular. |
2232 | /// Note: this may not be cused by opensim (it probably should) but it's used by | 2212 | /// Note: this may not be used by opensim (it probably should) but it's used by |
2233 | /// external modules. | 2213 | /// external modules. |
2234 | /// </summary> | 2214 | /// </summary> |
2235 | public void SendGroupRootTerseUpdate() | 2215 | public void SendGroupRootTerseUpdate() |
@@ -2244,6 +2224,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2244 | { | 2224 | { |
2245 | if (m_scene == null) // Need to check here as it's null during object creation | 2225 | if (m_scene == null) // Need to check here as it's null during object creation |
2246 | return; | 2226 | return; |
2227 | |||
2247 | m_scene.SceneGraph.AddToUpdateList(this); | 2228 | m_scene.SceneGraph.AddToUpdateList(this); |
2248 | } | 2229 | } |
2249 | 2230 | ||
@@ -3050,8 +3031,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
3050 | { | 3031 | { |
3051 | if (obPart.UUID != m_rootPart.UUID) | 3032 | if (obPart.UUID != m_rootPart.UUID) |
3052 | { | 3033 | { |
3053 | obPart.IgnoreUndoUpdate = true; | ||
3054 | Vector3 oldSize = new Vector3(obPart.Scale); | 3034 | Vector3 oldSize = new Vector3(obPart.Scale); |
3035 | obPart.IgnoreUndoUpdate = true; | ||
3055 | 3036 | ||
3056 | float f = 1.0f; | 3037 | float f = 1.0f; |
3057 | float a = 1.0f; | 3038 | float a = 1.0f; |
@@ -3745,7 +3726,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
3745 | HasGroupChanged = true; | 3726 | HasGroupChanged = true; |
3746 | } | 3727 | } |
3747 | lockPartsForRead(false); | 3728 | lockPartsForRead(false); |
3748 | ScheduleGroupForFullUpdate(); | 3729 | |
3730 | // Don't trigger the update here - otherwise some client issues occur when multiple updates are scheduled | ||
3731 | // for the same object with very different properties. The caller must schedule the update. | ||
3732 | //ScheduleGroupForFullUpdate(); | ||
3749 | } | 3733 | } |
3750 | 3734 | ||
3751 | public void TriggerScriptChangedEvent(Changed val) | 3735 | public void TriggerScriptChangedEvent(Changed val) |
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs index 548a64f..48e34ee 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs | |||
@@ -573,8 +573,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
573 | private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); | 573 | private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>(); |
574 | public List<SceneObjectPart> PlaySoundSlavePrims | 574 | public List<SceneObjectPart> PlaySoundSlavePrims |
575 | { | 575 | { |
576 | get { return m_LoopSoundSlavePrims; } | 576 | get { return m_PlaySoundSlavePrims; } |
577 | set { m_LoopSoundSlavePrims = value; } | 577 | set { m_PlaySoundSlavePrims = value; } |
578 | } | 578 | } |
579 | 579 | ||
580 | private SceneObjectPart m_LoopSoundMasterPrim = null; | 580 | private SceneObjectPart m_LoopSoundMasterPrim = null; |
@@ -2060,6 +2060,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2060 | { | 2060 | { |
2061 | m_lastColliders.Remove(localID); | 2061 | m_lastColliders.Remove(localID); |
2062 | } | 2062 | } |
2063 | |||
2063 | if (m_parentGroup == null) | 2064 | if (m_parentGroup == null) |
2064 | return; | 2065 | return; |
2065 | if (m_parentGroup.IsDeleted) | 2066 | if (m_parentGroup.IsDeleted) |
@@ -2820,29 +2821,59 @@ namespace OpenSim.Region.Framework.Scenes | |||
2820 | } | 2821 | } |
2821 | } | 2822 | } |
2822 | 2823 | ||
2824 | // /// <summary> | ||
2825 | // /// | ||
2826 | // /// </summary> | ||
2827 | // /// <param name="remoteClient"></param> | ||
2828 | // public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags) | ||
2829 | // { | ||
2830 | // m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags); | ||
2831 | // } | ||
2832 | |||
2833 | |||
2823 | /// <summary> | 2834 | /// <summary> |
2824 | /// | 2835 | /// Send a full update to the client for the given part |
2825 | /// </summary> | 2836 | /// </summary> |
2826 | /// <param name="remoteClient"></param> | 2837 | /// <param name="remoteClient"></param> |
2827 | public void SendFullUpdate(IClientAPI remoteClient, uint clientFlags) | 2838 | /// <param name="clientFlags"></param> |
2839 | protected internal void SendFullUpdate(IClientAPI remoteClient, uint clientFlags) | ||
2828 | { | 2840 | { |
2829 | m_parentGroup.SendPartFullUpdate(remoteClient, this, clientFlags); | 2841 | // m_log.DebugFormat( |
2842 | // "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId); | ||
2843 | |||
2844 | if (IsRoot) | ||
2845 | { | ||
2846 | if (IsAttachment) | ||
2847 | { | ||
2848 | SendFullUpdateToClient(remoteClient, AttachedPos, clientFlags); | ||
2849 | } | ||
2850 | else | ||
2851 | { | ||
2852 | SendFullUpdateToClient(remoteClient, AbsolutePosition, clientFlags); | ||
2853 | } | ||
2854 | } | ||
2855 | else | ||
2856 | { | ||
2857 | SendFullUpdateToClient(remoteClient, clientFlags); | ||
2858 | } | ||
2830 | } | 2859 | } |
2831 | 2860 | ||
2832 | /// <summary> | 2861 | /// <summary> |
2833 | /// | 2862 | /// Send a full update for this part to all clients. |
2834 | /// </summary> | 2863 | /// </summary> |
2835 | public void SendFullUpdateToAllClients() | 2864 | public void SendFullUpdateToAllClients() |
2836 | { | 2865 | { |
2837 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); | 2866 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); |
2838 | for (int i = 0; i < avatars.Length; i++) | 2867 | for (int i = 0; i < avatars.Length; i++) |
2839 | { | 2868 | { |
2840 | // Ugly reference :( | 2869 | SendFullUpdate(avatars[i].ControllingClient, avatars[i].GenerateClientFlags(UUID)); |
2841 | m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, | ||
2842 | avatars[i].GenerateClientFlags(UUID)); | ||
2843 | } | 2870 | } |
2844 | } | 2871 | } |
2845 | 2872 | ||
2873 | /// <summary> | ||
2874 | /// Send a full update to all clients except the one nominated. | ||
2875 | /// </summary> | ||
2876 | /// <param name="agentID"></param> | ||
2846 | public void SendFullUpdateToAllClientsExcept(UUID agentID) | 2877 | public void SendFullUpdateToAllClientsExcept(UUID agentID) |
2847 | { | 2878 | { |
2848 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); | 2879 | ScenePresence[] avatars = m_parentGroup.Scene.GetScenePresences(); |
@@ -2850,10 +2881,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2850 | { | 2881 | { |
2851 | // Ugly reference :( | 2882 | // Ugly reference :( |
2852 | if (avatars[i].UUID != agentID) | 2883 | if (avatars[i].UUID != agentID) |
2853 | { | 2884 | SendFullUpdate(avatars[i].ControllingClient, avatars[i].GenerateClientFlags(UUID)); |
2854 | m_parentGroup.SendPartFullUpdate(avatars[i].ControllingClient, this, | ||
2855 | avatars[i].GenerateClientFlags(UUID)); | ||
2856 | } | ||
2857 | } | 2885 | } |
2858 | } | 2886 | } |
2859 | 2887 | ||
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs index 5d00917..836622d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs | |||
@@ -34,7 +34,6 @@ using System.Reflection; | |||
34 | using OpenMetaverse; | 34 | using OpenMetaverse; |
35 | using log4net; | 35 | using log4net; |
36 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
37 | using OpenSim.Framework.Communications.Cache; | ||
38 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes.Scripting; | 38 | using OpenSim.Region.Framework.Scenes.Scripting; |
40 | 39 | ||
@@ -642,7 +641,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
642 | m_items[item.ItemID] = item; | 641 | m_items[item.ItemID] = item; |
643 | m_inventorySerial++; | 642 | m_inventorySerial++; |
644 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); | 643 | m_part.TriggerScriptChangedEvent(Changed.INVENTORY); |
645 | |||
646 | HasInventoryChanged = true; | 644 | HasInventoryChanged = true; |
647 | m_part.ParentGroup.HasGroupChanged = true; | 645 | m_part.ParentGroup.HasGroupChanged = true; |
648 | m_items.LockItemsForWrite(false); | 646 | m_items.LockItemsForWrite(false); |
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs index 123d6f3..2661dc3 100644 --- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs +++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs | |||
@@ -33,12 +33,12 @@ using OpenMetaverse; | |||
33 | using log4net; | 33 | using log4net; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Client; | 35 | using OpenSim.Framework.Client; |
36 | using OpenSim.Framework.Communications.Cache; | ||
37 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
38 | using OpenSim.Region.Framework.Scenes.Animation; | 37 | using OpenSim.Region.Framework.Scenes.Animation; |
39 | using OpenSim.Region.Framework.Scenes.Types; | 38 | using OpenSim.Region.Framework.Scenes.Types; |
40 | using OpenSim.Region.Physics.Manager; | 39 | using OpenSim.Region.Physics.Manager; |
41 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | 40 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; |
41 | using OpenSim.Services.Interfaces; | ||
42 | 42 | ||
43 | namespace OpenSim.Region.Framework.Scenes | 43 | namespace OpenSim.Region.Framework.Scenes |
44 | { | 44 | { |
@@ -150,7 +150,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
150 | 150 | ||
151 | private float m_sitAvatarHeight = 2.0f; | 151 | private float m_sitAvatarHeight = 2.0f; |
152 | 152 | ||
153 | private float m_godlevel; | 153 | private int m_godLevel; |
154 | private int m_userLevel; | ||
154 | 155 | ||
155 | private bool m_invulnerable = true; | 156 | private bool m_invulnerable = true; |
156 | 157 | ||
@@ -266,6 +267,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
266 | 267 | ||
267 | // For teleports and crossings callbacks | 268 | // For teleports and crossings callbacks |
268 | string m_callbackURI; | 269 | string m_callbackURI; |
270 | UUID m_originRegionID; | ||
271 | |||
269 | ulong m_rootRegionHandle; | 272 | ulong m_rootRegionHandle; |
270 | 273 | ||
271 | /// <value> | 274 | /// <value> |
@@ -302,9 +305,14 @@ namespace OpenSim.Region.Framework.Scenes | |||
302 | get { return m_invulnerable; } | 305 | get { return m_invulnerable; } |
303 | } | 306 | } |
304 | 307 | ||
305 | public float GodLevel | 308 | public int UserLevel |
309 | { | ||
310 | get { return m_userLevel; } | ||
311 | } | ||
312 | |||
313 | public int GodLevel | ||
306 | { | 314 | { |
307 | get { return m_godlevel; } | 315 | get { return m_godLevel; } |
308 | } | 316 | } |
309 | 317 | ||
310 | public ulong RegionHandle | 318 | public ulong RegionHandle |
@@ -676,6 +684,11 @@ namespace OpenSim.Region.Framework.Scenes | |||
676 | m_regionInfo = reginfo; | 684 | m_regionInfo = reginfo; |
677 | m_localId = m_scene.AllocateLocalId(); | 685 | m_localId = m_scene.AllocateLocalId(); |
678 | 686 | ||
687 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, m_uuid); | ||
688 | |||
689 | if (account != null) | ||
690 | m_userLevel = account.UserLevel; | ||
691 | |||
679 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); | 692 | IGroupsModule gm = m_scene.RequestModuleInterface<IGroupsModule>(); |
680 | if (gm != null) | 693 | if (gm != null) |
681 | m_grouptitle = gm.GetGroupTitle(m_uuid); | 694 | m_grouptitle = gm.GetGroupTitle(m_uuid); |
@@ -866,47 +879,22 @@ namespace OpenSim.Region.Framework.Scenes | |||
866 | if (land != null) | 879 | if (land != null) |
867 | { | 880 | { |
868 | //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. | 881 | //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni. |
869 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_godlevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) | 882 | if (land.LandData.LandingType == (byte)1 && land.LandData.UserLocation != Vector3.Zero && m_userLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(m_uuid) && land.LandData.OwnerID != m_uuid) |
870 | { | 883 | { |
871 | pos = land.LandData.UserLocation; | 884 | pos = land.LandData.UserLocation; |
872 | } | 885 | } |
873 | } | 886 | } |
874 | } | 887 | } |
875 | 888 | ||
876 | if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) | 889 | if (pos.X < 0f || pos.Y < 0f || pos.Z < 0f) |
877 | { | 890 | { |
878 | Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); | ||
879 | |||
880 | if (pos.X < 0) | ||
881 | { | ||
882 | emergencyPos.X = (int)Constants.RegionSize + pos.X; | ||
883 | if (!(pos.Y < 0)) | ||
884 | emergencyPos.Y = pos.Y; | ||
885 | if (!(pos.Z < 0)) | ||
886 | emergencyPos.X = pos.X; | ||
887 | } | ||
888 | if (pos.Y < 0) | ||
889 | { | ||
890 | emergencyPos.Y = (int)Constants.RegionSize + pos.Y; | ||
891 | if (!(pos.X < 0)) | ||
892 | emergencyPos.X = pos.X; | ||
893 | if (!(pos.Z < 0)) | ||
894 | emergencyPos.Z = pos.Z; | ||
895 | } | ||
896 | if (pos.Z < 0) | ||
897 | { | ||
898 | if (!(pos.X < 0)) | ||
899 | emergencyPos.X = pos.X; | ||
900 | if (!(pos.Y < 0)) | ||
901 | emergencyPos.Y = pos.Y; | ||
902 | //Leave as 128 | ||
903 | } | ||
904 | |||
905 | m_log.WarnFormat( | 891 | m_log.WarnFormat( |
906 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", | 892 | "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Clamping", |
907 | pos, Name, UUID, emergencyPos); | 893 | pos, Name, UUID); |
908 | 894 | ||
909 | pos = emergencyPos; | 895 | if (pos.X < 0f) pos.X = 0f; |
896 | if (pos.Y < 0f) pos.Y = 0f; | ||
897 | if (pos.Z < 0f) pos.Z = 0f; | ||
910 | } | 898 | } |
911 | 899 | ||
912 | float localAVHeight = 1.56f; | 900 | float localAVHeight = 1.56f; |
@@ -917,7 +905,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
917 | 905 | ||
918 | float posZLimit = 0; | 906 | float posZLimit = 0; |
919 | 907 | ||
920 | if (pos.X <Constants.RegionSize && pos.Y < Constants.RegionSize) | 908 | if (pos.X < Constants.RegionSize && pos.Y < Constants.RegionSize) |
921 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; | 909 | posZLimit = (float)m_scene.Heightmap[(int)pos.X, (int)pos.Y]; |
922 | 910 | ||
923 | float newPosZ = posZLimit + localAVHeight / 2; | 911 | float newPosZ = posZLimit + localAVHeight / 2; |
@@ -1160,8 +1148,10 @@ namespace OpenSim.Region.Framework.Scenes | |||
1160 | /// This is called upon a very important packet sent from the client, | 1148 | /// This is called upon a very important packet sent from the client, |
1161 | /// so it's client-controlled. Never call this method directly. | 1149 | /// so it's client-controlled. Never call this method directly. |
1162 | /// </summary> | 1150 | /// </summary> |
1163 | public void CompleteMovement() | 1151 | public void CompleteMovement(IClientAPI client) |
1164 | { | 1152 | { |
1153 | //m_log.Debug("[SCENE PRESENCE]: CompleteMovement"); | ||
1154 | |||
1165 | Vector3 look = Velocity; | 1155 | Vector3 look = Velocity; |
1166 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) | 1156 | if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) |
1167 | { | 1157 | { |
@@ -1186,7 +1176,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
1186 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) | 1176 | if ((m_callbackURI != null) && !m_callbackURI.Equals("")) |
1187 | { | 1177 | { |
1188 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); | 1178 | m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); |
1189 | Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); | 1179 | Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI); |
1190 | m_callbackURI = null; | 1180 | m_callbackURI = null; |
1191 | } | 1181 | } |
1192 | 1182 | ||
@@ -1194,6 +1184,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
1194 | 1184 | ||
1195 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); | 1185 | m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); |
1196 | SendInitialData(); | 1186 | SendInitialData(); |
1187 | |||
1188 | // Create child agents in neighbouring regions | ||
1189 | if (!m_isChildAgent) | ||
1190 | { | ||
1191 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); | ||
1192 | if (m_agentTransfer != null) | ||
1193 | m_agentTransfer.EnableChildAgents(this); | ||
1194 | else | ||
1195 | m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active"); | ||
1196 | |||
1197 | IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>(); | ||
1198 | if (friendsModule != null) | ||
1199 | friendsModule.SendFriendsOnlineIfNeeded(ControllingClient); | ||
1200 | } | ||
1201 | |||
1197 | } | 1202 | } |
1198 | 1203 | ||
1199 | /// <summary> | 1204 | /// <summary> |
@@ -2397,6 +2402,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
2397 | { | 2402 | { |
2398 | if (m_isChildAgent) | 2403 | if (m_isChildAgent) |
2399 | { | 2404 | { |
2405 | // WHAT??? | ||
2400 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); | 2406 | m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); |
2401 | 2407 | ||
2402 | // we have to reset the user's child agent connections. | 2408 | // we have to reset the user's child agent connections. |
@@ -2420,7 +2426,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2420 | 2426 | ||
2421 | if (m_scene.SceneGridService != null) | 2427 | if (m_scene.SceneGridService != null) |
2422 | { | 2428 | { |
2423 | m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); | 2429 | IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>(); |
2430 | if (m_agentTransfer != null) | ||
2431 | m_agentTransfer.EnableChildAgents(this); | ||
2424 | } | 2432 | } |
2425 | 2433 | ||
2426 | return; | 2434 | return; |
@@ -2720,14 +2728,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
2720 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, | 2728 | m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, |
2721 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); | 2729 | pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); |
2722 | 2730 | ||
2723 | if (!m_isChildAgent) | ||
2724 | { | ||
2725 | m_scene.InformClientOfNeighbours(this); | ||
2726 | } | ||
2727 | |||
2728 | SendInitialFullUpdateToAllClients(); | 2731 | SendInitialFullUpdateToAllClients(); |
2729 | SendAppearanceToAllOtherAgents(); | 2732 | SendAppearanceToAllOtherAgents(); |
2730 | } | 2733 | } |
2731 | 2734 | ||
2732 | /// <summary> | 2735 | /// <summary> |
2733 | /// Tell the client for this scene presence what items it should be wearing now | 2736 | /// Tell the client for this scene presence what items it should be wearing now |
@@ -2809,14 +2812,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2809 | } | 2812 | } |
2810 | } | 2813 | } |
2811 | } | 2814 | } |
2815 | |||
2812 | } | 2816 | } |
2813 | 2817 | ||
2818 | |||
2814 | #endregion Bake Cache Check | 2819 | #endregion Bake Cache Check |
2815 | 2820 | ||
2816 | m_appearance.SetAppearance(textureEntry, visualParams); | 2821 | m_appearance.SetAppearance(textureEntry, visualParams); |
2817 | if (m_appearance.AvatarHeight > 0) | 2822 | if (m_appearance.AvatarHeight > 0) |
2818 | SetHeight(m_appearance.AvatarHeight); | 2823 | SetHeight(m_appearance.AvatarHeight); |
2819 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); | 2824 | |
2825 | // This is not needed, because only the transient data changed | ||
2826 | //AvatarData adata = new AvatarData(m_appearance); | ||
2827 | //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); | ||
2820 | 2828 | ||
2821 | SendAppearanceToAllOtherAgents(); | 2829 | SendAppearanceToAllOtherAgents(); |
2822 | if (!m_startAnimationSet) | 2830 | if (!m_startAnimationSet) |
@@ -2836,7 +2844,8 @@ namespace OpenSim.Region.Framework.Scenes | |||
2836 | public void SetWearable(int wearableId, AvatarWearable wearable) | 2844 | public void SetWearable(int wearableId, AvatarWearable wearable) |
2837 | { | 2845 | { |
2838 | m_appearance.SetWearable(wearableId, wearable); | 2846 | m_appearance.SetWearable(wearableId, wearable); |
2839 | m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); | 2847 | AvatarData adata = new AvatarData(m_appearance); |
2848 | m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata); | ||
2840 | m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); | 2849 | m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); |
2841 | } | 2850 | } |
2842 | 2851 | ||
@@ -2858,7 +2867,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2858 | /// </summary> | 2867 | /// </summary> |
2859 | protected void CheckForSignificantMovement() | 2868 | protected void CheckForSignificantMovement() |
2860 | { | 2869 | { |
2861 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > 0.5) | 2870 | // Movement updates for agents in neighboring regions are sent directly to clients. |
2871 | // This value only affects how often agent positions are sent to neighbor regions | ||
2872 | // for things such as distance-based update prioritization | ||
2873 | const float SIGNIFICANT_MOVEMENT = 2.0f; | ||
2874 | |||
2875 | if (Util.GetDistanceTo(AbsolutePosition, posLastSignificantMove) > SIGNIFICANT_MOVEMENT) | ||
2862 | { | 2876 | { |
2863 | posLastSignificantMove = AbsolutePosition; | 2877 | posLastSignificantMove = AbsolutePosition; |
2864 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); | 2878 | m_scene.EventManager.TriggerSignificantClientMovement(m_controllingClient); |
@@ -2869,18 +2883,19 @@ namespace OpenSim.Region.Framework.Scenes | |||
2869 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || | 2883 | if (Util.GetDistanceTo(AbsolutePosition, m_lastChildAgentUpdatePosition) >= Scene.ChildReprioritizationDistance || |
2870 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) | 2884 | Util.GetDistanceTo(CameraPosition, m_lastChildAgentUpdateCamPosition) >= Scene.ChildReprioritizationDistance) |
2871 | { | 2885 | { |
2886 | m_lastChildAgentUpdatePosition = AbsolutePosition; | ||
2887 | m_lastChildAgentUpdateCamPosition = CameraPosition; | ||
2888 | |||
2872 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); | 2889 | ChildAgentDataUpdate cadu = new ChildAgentDataUpdate(); |
2873 | cadu.ActiveGroupID = UUID.Zero.Guid; | 2890 | cadu.ActiveGroupID = UUID.Zero.Guid; |
2874 | cadu.AgentID = UUID.Guid; | 2891 | cadu.AgentID = UUID.Guid; |
2875 | cadu.alwaysrun = m_setAlwaysRun; | 2892 | cadu.alwaysrun = m_setAlwaysRun; |
2876 | cadu.AVHeight = m_avHeight; | 2893 | cadu.AVHeight = m_avHeight; |
2877 | sLLVector3 tempCameraCenter = new sLLVector3(new Vector3(m_CameraCenter.X, m_CameraCenter.Y, m_CameraCenter.Z)); | 2894 | Vector3 tempCameraCenter = m_CameraCenter; |
2878 | cadu.cameraPosition = tempCameraCenter; | 2895 | cadu.cameraPosition = tempCameraCenter; |
2879 | cadu.drawdistance = m_DrawDistance; | 2896 | cadu.drawdistance = m_DrawDistance; |
2880 | if (m_scene.Permissions.IsGod(new UUID(cadu.AgentID))) | ||
2881 | cadu.godlevel = m_godlevel; | ||
2882 | cadu.GroupAccess = 0; | 2897 | cadu.GroupAccess = 0; |
2883 | cadu.Position = new sLLVector3(AbsolutePosition); | 2898 | cadu.Position = AbsolutePosition; |
2884 | cadu.regionHandle = m_rootRegionHandle; | 2899 | cadu.regionHandle = m_rootRegionHandle; |
2885 | float multiplier = 1; | 2900 | float multiplier = 1; |
2886 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); | 2901 | int innacurateNeighbors = m_scene.GetInaccurateNeighborCount(); |
@@ -2895,15 +2910,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
2895 | 2910 | ||
2896 | //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); | 2911 | //m_log.Info("[NeighborThrottle]: " + m_scene.GetInaccurateNeighborCount().ToString() + " - m: " + multiplier.ToString()); |
2897 | cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); | 2912 | cadu.throttles = ControllingClient.GetThrottlesPacked(multiplier); |
2898 | cadu.Velocity = new sLLVector3(Velocity); | 2913 | cadu.Velocity = Velocity; |
2899 | 2914 | ||
2900 | AgentPosition agentpos = new AgentPosition(); | 2915 | AgentPosition agentpos = new AgentPosition(); |
2901 | agentpos.CopyFrom(cadu); | 2916 | agentpos.CopyFrom(cadu); |
2902 | 2917 | ||
2903 | m_scene.SendOutChildAgentUpdates(agentpos, this); | 2918 | m_scene.SendOutChildAgentUpdates(agentpos, this); |
2904 | |||
2905 | m_lastChildAgentUpdatePosition = AbsolutePosition; | ||
2906 | m_lastChildAgentUpdateCamPosition = CameraPosition; | ||
2907 | } | 2919 | } |
2908 | } | 2920 | } |
2909 | 2921 | ||
@@ -3159,18 +3171,21 @@ namespace OpenSim.Region.Framework.Scenes | |||
3159 | // For now, assign god level 200 to anyone | 3171 | // For now, assign god level 200 to anyone |
3160 | // who is granted god powers, but has no god level set. | 3172 | // who is granted god powers, but has no god level set. |
3161 | // | 3173 | // |
3162 | CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); | 3174 | UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID); |
3163 | if (profile.UserProfile.GodLevel > 0) | 3175 | if (account != null) |
3164 | m_godlevel = profile.UserProfile.GodLevel; | 3176 | { |
3165 | else | 3177 | if (account.UserLevel > 0) |
3166 | m_godlevel = 200; | 3178 | m_godLevel = account.UserLevel; |
3179 | else | ||
3180 | m_godLevel = 200; | ||
3181 | } | ||
3167 | } | 3182 | } |
3168 | else | 3183 | else |
3169 | { | 3184 | { |
3170 | m_godlevel = 0; | 3185 | m_godLevel = 0; |
3171 | } | 3186 | } |
3172 | 3187 | ||
3173 | ControllingClient.SendAdminResponse(token, (uint)m_godlevel); | 3188 | ControllingClient.SendAdminResponse(token, (uint)m_godLevel); |
3174 | } | 3189 | } |
3175 | 3190 | ||
3176 | #region Child Agent Updates | 3191 | #region Child Agent Updates |
@@ -3229,7 +3244,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3229 | public void CopyTo(AgentData cAgent) | 3244 | public void CopyTo(AgentData cAgent) |
3230 | { | 3245 | { |
3231 | cAgent.AgentID = UUID; | 3246 | cAgent.AgentID = UUID; |
3232 | cAgent.RegionHandle = m_rootRegionHandle; | 3247 | cAgent.RegionID = Scene.RegionInfo.RegionID; |
3233 | 3248 | ||
3234 | cAgent.Position = AbsolutePosition; | 3249 | cAgent.Position = AbsolutePosition; |
3235 | cAgent.Velocity = m_velocity; | 3250 | cAgent.Velocity = m_velocity; |
@@ -3261,7 +3276,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3261 | cAgent.ControlFlags = (uint)m_AgentControlFlags; | 3276 | cAgent.ControlFlags = (uint)m_AgentControlFlags; |
3262 | 3277 | ||
3263 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3278 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3264 | cAgent.GodLevel = (byte)m_godlevel; | 3279 | cAgent.GodLevel = (byte)m_godLevel; |
3265 | else | 3280 | else |
3266 | cAgent.GodLevel = (byte) 0; | 3281 | cAgent.GodLevel = (byte) 0; |
3267 | 3282 | ||
@@ -3328,7 +3343,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3328 | 3343 | ||
3329 | public void CopyFrom(AgentData cAgent) | 3344 | public void CopyFrom(AgentData cAgent) |
3330 | { | 3345 | { |
3331 | m_rootRegionHandle = cAgent.RegionHandle; | 3346 | m_originRegionID = cAgent.RegionID; |
3332 | 3347 | ||
3333 | m_callbackURI = cAgent.CallbackURI; | 3348 | m_callbackURI = cAgent.CallbackURI; |
3334 | 3349 | ||
@@ -3350,7 +3365,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3350 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; | 3365 | m_AgentControlFlags = (AgentManager.ControlFlags)cAgent.ControlFlags; |
3351 | 3366 | ||
3352 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) | 3367 | if (m_scene.Permissions.IsGod(new UUID(cAgent.AgentID))) |
3353 | m_godlevel = cAgent.GodLevel; | 3368 | m_godLevel = cAgent.GodLevel; |
3354 | m_setAlwaysRun = cAgent.AlwaysRun; | 3369 | m_setAlwaysRun = cAgent.AlwaysRun; |
3355 | 3370 | ||
3356 | uint i = 0; | 3371 | uint i = 0; |
@@ -3708,36 +3723,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
3708 | } | 3723 | } |
3709 | } | 3724 | } |
3710 | 3725 | ||
3711 | public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent) | ||
3712 | { | ||
3713 | lock (m_attachments) | ||
3714 | { | ||
3715 | // Validate | ||
3716 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3717 | { | ||
3718 | if (gobj == null || gobj.IsDeleted) | ||
3719 | return false; | ||
3720 | } | ||
3721 | |||
3722 | foreach (SceneObjectGroup gobj in m_attachments) | ||
3723 | { | ||
3724 | // If the prim group is null then something must have happened to it! | ||
3725 | if (gobj != null && gobj.RootPart != null) | ||
3726 | { | ||
3727 | // Set the parent localID to 0 so it transfers over properly. | ||
3728 | gobj.RootPart.SetParentLocalId(0); | ||
3729 | gobj.AbsolutePosition = gobj.RootPart.AttachedPos; | ||
3730 | gobj.RootPart.IsAttachment = false; | ||
3731 | //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID(); | ||
3732 | m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle); | ||
3733 | m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent); | ||
3734 | } | ||
3735 | } | ||
3736 | m_attachments.Clear(); | ||
3737 | |||
3738 | return true; | ||
3739 | } | ||
3740 | } | ||
3741 | 3726 | ||
3742 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) | 3727 | public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) |
3743 | { | 3728 | { |
@@ -3973,7 +3958,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
3973 | { | 3958 | { |
3974 | if (null == m_appearance) | 3959 | if (null == m_appearance) |
3975 | { | 3960 | { |
3976 | m_log.WarnFormat("[ATTACHMENT] Appearance has not been initialized for agent {0}", UUID); | 3961 | m_log.WarnFormat("[ATTACHMENT]: Appearance has not been initialized for agent {0}", UUID); |
3977 | return; | 3962 | return; |
3978 | } | 3963 | } |
3979 | 3964 | ||
@@ -3997,12 +3982,12 @@ namespace OpenSim.Region.Framework.Scenes | |||
3997 | try | 3982 | try |
3998 | { | 3983 | { |
3999 | // Rez from inventory | 3984 | // Rez from inventory |
4000 | UUID asset = m_scene.RezSingleAttachment(ControllingClient, | 3985 | UUID asset |
4001 | itemID, (uint)p); | 3986 | = m_scene.AttachmentsModule.RezSingleAttachmentFromInventory(ControllingClient, itemID, (uint)p); |
4002 | |||
4003 | m_log.InfoFormat("[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", | ||
4004 | p, itemID, assetID, asset); | ||
4005 | 3987 | ||
3988 | m_log.InfoFormat( | ||
3989 | "[ATTACHMENT]: Rezzed attachment in point {0} from item {1} and asset {2} ({3})", | ||
3990 | p, itemID, assetID, asset); | ||
4006 | } | 3991 | } |
4007 | catch (Exception e) | 3992 | catch (Exception e) |
4008 | { | 3993 | { |
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs index 1cff0eb..4ba4fab 100644 --- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs +++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs | |||
@@ -31,7 +31,6 @@ using OpenMetaverse; | |||
31 | using log4net; | 31 | using log4net; |
32 | using OpenSim.Framework; | 32 | using OpenSim.Framework; |
33 | using OpenSim.Framework.Client; | 33 | using OpenSim.Framework.Client; |
34 | using OpenSim.Framework.Communications.Cache; | ||
35 | using OpenSim.Region.Framework.Interfaces; | 34 | using OpenSim.Region.Framework.Interfaces; |
36 | using OpenSim.Region.Framework.Scenes.Types; | 35 | using OpenSim.Region.Framework.Scenes.Types; |
37 | 36 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs index 8230f32..840039c 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs | |||
@@ -65,6 +65,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
65 | { | 65 | { |
66 | throw new NotImplementedException(); | 66 | throw new NotImplementedException(); |
67 | } | 67 | } |
68 | |||
69 | public override bool TryGetAvatar(UUID agentID, out ScenePresence scenePresence) | ||
70 | { | ||
71 | throw new NotImplementedException(); | ||
72 | } | ||
68 | } | 73 | } |
69 | 74 | ||
70 | [Test] | 75 | [Test] |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs index 0ed00de..78f2ae3 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs | |||
@@ -32,8 +32,7 @@ using NUnit.Framework.SyntaxHelpers; | |||
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Communications.Cache; | 35 | |
36 | using OpenSim.Region.Communications.Local; | ||
37 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Tests.Common; | 37 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 38 | using OpenSim.Tests.Common.Mock; |
@@ -87,6 +86,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
87 | public void TestDeleteSceneObjectAsync() | 86 | public void TestDeleteSceneObjectAsync() |
88 | { | 87 | { |
89 | TestHelper.InMethod(); | 88 | TestHelper.InMethod(); |
89 | //log4net.Config.XmlConfigurator.Configure(); | ||
90 | 90 | ||
91 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); | 91 | UUID agentId = UUID.Parse("00000000-0000-0000-0000-000000000001"); |
92 | 92 | ||
@@ -95,16 +95,18 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
95 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. | 95 | // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. |
96 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; | 96 | AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; |
97 | sogd.Enabled = false; | 97 | sogd.Enabled = false; |
98 | 98 | ||
99 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); | 99 | SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); |
100 | 100 | ||
101 | IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); | 101 | IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); |
102 | scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero); | 102 | scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero); |
103 | 103 | ||
104 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); | 104 | SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); |
105 | |||
105 | Assert.That(retrievedPart, Is.Not.Null); | 106 | Assert.That(retrievedPart, Is.Not.Null); |
106 | 107 | ||
107 | sogd.InventoryDeQueueAndDelete(); | 108 | sogd.InventoryDeQueueAndDelete(); |
109 | |||
108 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); | 110 | SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); |
109 | Assert.That(retrievedPart2, Is.Null); | 111 | Assert.That(retrievedPart2, Is.Null); |
110 | } | 112 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs index 709cca2..0b7608d 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs | |||
@@ -32,8 +32,7 @@ using NUnit.Framework.SyntaxHelpers; | |||
32 | using OpenMetaverse; | 32 | using OpenMetaverse; |
33 | using OpenSim.Framework; | 33 | using OpenSim.Framework; |
34 | using OpenSim.Framework.Communications; | 34 | using OpenSim.Framework.Communications; |
35 | using OpenSim.Framework.Communications.Cache; | 35 | |
36 | using OpenSim.Region.Communications.Local; | ||
37 | using OpenSim.Region.Framework.Scenes; | 36 | using OpenSim.Region.Framework.Scenes; |
38 | using OpenSim.Tests.Common; | 37 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 38 | using OpenSim.Tests.Common.Mock; |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs index f00dd66..501207e 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs | |||
@@ -40,8 +40,8 @@ using OpenSim.Framework; | |||
40 | using OpenSim.Framework.Communications; | 40 | using OpenSim.Framework.Communications; |
41 | using OpenSim.Region.Framework.Scenes; | 41 | using OpenSim.Region.Framework.Scenes; |
42 | using OpenSim.Region.Framework.Interfaces; | 42 | using OpenSim.Region.Framework.Interfaces; |
43 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; | ||
44 | using OpenSim.Region.CoreModules.World.Serialiser; | 43 | using OpenSim.Region.CoreModules.World.Serialiser; |
44 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; | ||
45 | using OpenSim.Tests.Common; | 45 | using OpenSim.Tests.Common; |
46 | using OpenSim.Tests.Common.Mock; | 46 | using OpenSim.Tests.Common.Mock; |
47 | using OpenSim.Tests.Common.Setup; | 47 | using OpenSim.Tests.Common.Setup; |
@@ -58,7 +58,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
58 | public UUID agent1, agent2, agent3; | 58 | public UUID agent1, agent2, agent3; |
59 | public static Random random; | 59 | public static Random random; |
60 | public ulong region1,region2,region3; | 60 | public ulong region1,region2,region3; |
61 | public TestCommunicationsManager cm; | ||
62 | public AgentCircuitData acd1; | 61 | public AgentCircuitData acd1; |
63 | public SceneObjectGroup sog1, sog2, sog3; | 62 | public SceneObjectGroup sog1, sog2, sog3; |
64 | public TestClient testclient; | 63 | public TestClient testclient; |
@@ -66,12 +65,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
66 | [TestFixtureSetUp] | 65 | [TestFixtureSetUp] |
67 | public void Init() | 66 | public void Init() |
68 | { | 67 | { |
69 | cm = new TestCommunicationsManager(); | 68 | scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000); |
70 | scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000, cm); | 69 | scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000); |
71 | scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000, cm); | 70 | scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000); |
72 | scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000, cm); | ||
73 | 71 | ||
74 | ISharedRegionModule interregionComms = new RESTInterregionComms(); | 72 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); |
75 | interregionComms.Initialise(new IniConfigSource()); | 73 | interregionComms.Initialise(new IniConfigSource()); |
76 | interregionComms.PostInitialise(); | 74 | interregionComms.PostInitialise(); |
77 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); | 75 | SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); |
@@ -373,7 +371,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
373 | 371 | ||
374 | Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); | 372 | Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); |
375 | 373 | ||
376 | Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); | 374 | //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); |
377 | Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); | 375 | Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); |
378 | Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); | 376 | Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); |
379 | } | 377 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs index 5abbb82..68035ca 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs | |||
@@ -141,7 +141,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
141 | RegionInfo regionInfo = new RegionInfo(0,0,null,null); | 141 | RegionInfo regionInfo = new RegionInfo(0,0,null,null); |
142 | FakeStorageManager storageManager = new FakeStorageManager(); | 142 | FakeStorageManager storageManager = new FakeStorageManager(); |
143 | 143 | ||
144 | new Scene(regionInfo, null, null, null, storageManager, null, false, false, false, null, null); | 144 | new Scene(regionInfo, null, null, storageManager, null, false, false, false, null, null); |
145 | } | 145 | } |
146 | } | 146 | } |
147 | } | 147 | } |
diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs index b46eb8e..cafe48a 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs | |||
@@ -34,7 +34,7 @@ using OpenMetaverse; | |||
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Communications; | 35 | using OpenSim.Framework.Communications; |
36 | using OpenSim.Region.Framework.Interfaces; | 36 | using OpenSim.Region.Framework.Interfaces; |
37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; | 37 | using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation; |
38 | using OpenSim.Tests.Common; | 38 | using OpenSim.Tests.Common; |
39 | using OpenSim.Tests.Common.Mock; | 39 | using OpenSim.Tests.Common.Mock; |
40 | using OpenSim.Tests.Common.Setup; | 40 | using OpenSim.Tests.Common.Setup; |
@@ -113,17 +113,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
113 | 113 | ||
114 | UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); | 114 | UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); |
115 | UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); | 115 | UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); |
116 | TestCommunicationsManager cm = new TestCommunicationsManager(); | ||
117 | 116 | ||
118 | // shared module | 117 | // shared module |
119 | ISharedRegionModule interregionComms = new RESTInterregionComms(); | 118 | ISharedRegionModule interregionComms = new LocalSimulationConnectorModule(); |
120 | 119 | ||
121 | 120 | ||
122 | Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, cm, "grid"); | 121 | Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, "grid"); |
123 | SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); | 122 | SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); |
124 | sceneB.RegisterRegionWithGrid(); | 123 | sceneB.RegisterRegionWithGrid(); |
125 | 124 | ||
126 | Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, cm, "grid"); | 125 | Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, "grid"); |
127 | SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); | 126 | SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); |
128 | sceneA.RegisterRegionWithGrid(); | 127 | sceneA.RegisterRegionWithGrid(); |
129 | 128 | ||
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs index a36c4db..6686264 100644 --- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs +++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs | |||
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests | |||
58 | TestHelper.InMethod(); | 58 | TestHelper.InMethod(); |
59 | 59 | ||
60 | UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); | 60 | UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); |
61 | AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET"); | 61 | AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET", UUID.Zero); |
62 | m_assetService.Store(corruptAsset); | 62 | m_assetService.Store(corruptAsset); |
63 | 63 | ||
64 | IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); | 64 | IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); |