aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs265
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs174
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs77
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs391
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs56
-rw-r--r--OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs561
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs73
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs651
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs1203
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs32
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs94
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneViewer.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs9
22 files changed, 389 insertions, 3246 deletions
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;
32using log4net; 32using log4net;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
35 36
36namespace OpenSim.Region.Framework.Scenes 37namespace 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/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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients;
37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Services.Interfaces;
40
41//using HyperGrid.Framework;
42//using OpenSim.Region.Communications.Hypergrid;
43
44namespace 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
28using System.Reflection;
29using log4net;
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces;
36
37namespace 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
28using OpenMetaverse;
29using OpenSim.Framework;
30using OpenSim.Framework.Communications.Cache;
31using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
33
34namespace 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
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Client;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Capabilities;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Services.Interfaces;
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43
44namespace 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/Hypergrid/HGUuidGatherer.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
deleted file mode 100644
index 5d4e7ac..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
+++ /dev/null
@@ -1,56 +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
28using System;
29using System.Collections.Generic;
30
31using OpenSim.Framework;
32using OpenSim.Services.Interfaces;
33using OpenMetaverse;
34
35namespace OpenSim.Region.Framework.Scenes.Hypergrid
36{
37 public class HGUuidGatherer : UuidGatherer
38 {
39 protected string m_assetServerURL;
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 }
56}
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;
36using OpenMetaverse.StructuredData; 36using OpenMetaverse.StructuredData;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Services; 39
40using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
42using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
43using OpenSim.Framework.Servers.HttpServer; 42using OpenSim.Framework.Servers.HttpServer;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index 7df3e50..e032a07 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -35,7 +35,7 @@ using OpenMetaverse;
35using OpenMetaverse.Packets; 35using OpenMetaverse.Packets;
36using log4net; 36using log4net;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications.Cache; 38
39using OpenSim.Region.Framework; 39using OpenSim.Region.Framework;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes.Serialization; 41using 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 {
@@ -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 {
@@ -742,13 +685,9 @@ namespace OpenSim.Region.Framework.Scenes
742 685
743 if (transactionID == UUID.Zero) 686 if (transactionID == UUID.Zero)
744 { 687 {
745 CachedUserInfo userInfo 688 ScenePresence presence;
746 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 689 if (TryGetAvatar(remoteClient.AgentId, out presence))
747
748 if (userInfo != null)
749 { 690 {
750 ScenePresence presence;
751 TryGetAvatar(remoteClient.AgentId, out presence);
752 byte[] data = null; 691 byte[] data = null;
753 692
754 if (invType == (sbyte)InventoryType.Landmark && presence != null) 693 if (invType == (sbyte)InventoryType.Landmark && presence != null)
@@ -770,7 +709,7 @@ namespace OpenSim.Region.Framework.Scenes
770 else 709 else
771 { 710 {
772 m_log.ErrorFormat( 711 m_log.ErrorFormat(
773 "userInfo for agent uuid {0} unexpectedly null in CreateNewInventoryItem", 712 "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem",
774 remoteClient.AgentId); 713 remoteClient.AgentId);
775 } 714 }
776 } 715 }
@@ -1163,15 +1102,21 @@ namespace OpenSim.Region.Framework.Scenes
1163 1102
1164 private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) 1103 private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems)
1165 { 1104 {
1105 if (folder == null)
1106 return;
1107
1166 m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); 1108 m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName);
1167 InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); 1109 InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID);
1168 InventoryFolderBase containingFolder = new InventoryFolderBase(); 1110 InventoryFolderBase containingFolder = new InventoryFolderBase();
1169 containingFolder.ID = folder.ID; 1111 containingFolder.ID = folder.ID;
1170 containingFolder.Owner = client.AgentId; 1112 containingFolder.Owner = client.AgentId;
1171 containingFolder = InventoryService.GetFolder(containingFolder); 1113 containingFolder = InventoryService.GetFolder(containingFolder);
1172 int version = containingFolder.Version; 1114 if (containingFolder != null)
1115 {
1116 int version = containingFolder.Version;
1173 1117
1174 client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); 1118 client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems);
1119 }
1175 } 1120 }
1176 1121
1177 /// <summary> 1122 /// <summary>
@@ -1213,9 +1158,9 @@ namespace OpenSim.Region.Framework.Scenes
1213 item = InventoryService.GetItem(item); 1158 item = InventoryService.GetItem(item);
1214 1159
1215 // Try library 1160 // Try library
1216 if (null == item) 1161 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1217 { 1162 {
1218 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1163 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1219 } 1164 }
1220 1165
1221 if (item != null) 1166 if (item != null)
@@ -1282,9 +1227,9 @@ namespace OpenSim.Region.Framework.Scenes
1282 1227
1283 // Try library 1228 // Try library
1284 // XXX clumsy, possibly should be one call 1229 // XXX clumsy, possibly should be one call
1285 if (null == item) 1230 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1286 { 1231 {
1287 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1232 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1288 } 1233 }
1289 1234
1290 if (item != null) 1235 if (item != null)
@@ -1609,232 +1554,6 @@ namespace OpenSim.Region.Framework.Scenes
1609 } 1554 }
1610 } 1555 }
1611 1556
1612 /// <summary>
1613 /// Delete a scene object from a scene and place in the given avatar's inventory.
1614 /// Returns the UUID of the newly created asset.
1615 /// </summary>
1616 /// <param name="action"></param>
1617 /// <param name="folderID"></param>
1618 /// <param name="objectGroup"></param>
1619 /// <param name="remoteClient"> </param>
1620 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
1621 SceneObjectGroup objectGroup, IClientAPI remoteClient)
1622 {
1623 UUID assetID = UUID.Zero;
1624
1625 Vector3 inventoryStoredPosition = new Vector3
1626 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1627 ? 250
1628 : objectGroup.AbsolutePosition.X)
1629 ,
1630 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1631 ? 250
1632 : objectGroup.AbsolutePosition.X,
1633 objectGroup.AbsolutePosition.Z);
1634
1635 Vector3 originalPosition = objectGroup.AbsolutePosition;
1636
1637 objectGroup.AbsolutePosition = inventoryStoredPosition;
1638
1639 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
1640
1641 objectGroup.AbsolutePosition = originalPosition;
1642
1643 // Get the user info of the item destination
1644 //
1645 UUID userID = UUID.Zero;
1646
1647 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
1648 action == DeRezAction.SaveToExistingUserInventoryItem)
1649 {
1650 // Take or take copy require a taker
1651 // Saving changes requires a local user
1652 //
1653 if (remoteClient == null)
1654 return UUID.Zero;
1655
1656 userID = remoteClient.AgentId;
1657 }
1658 else
1659 {
1660 // All returns / deletes go to the object owner
1661 //
1662
1663 userID = objectGroup.RootPart.OwnerID;
1664 }
1665
1666 if (userID == UUID.Zero) // Can't proceed
1667 {
1668 return UUID.Zero;
1669 }
1670
1671 // If we're returning someone's item, it goes back to the
1672 // owner's Lost And Found folder.
1673 // Delete is treated like return in this case
1674 // Deleting your own items makes them go to trash
1675 //
1676
1677 InventoryFolderBase folder = null;
1678 InventoryItemBase item = null;
1679
1680 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1681 {
1682 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID);
1683 item = InventoryService.GetItem(item);
1684
1685 //item = userInfo.RootFolder.FindItem(
1686 // objectGroup.RootPart.FromUserInventoryItemID);
1687
1688 if (null == item)
1689 {
1690 m_log.DebugFormat(
1691 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
1692 objectGroup.Name, objectGroup.UUID);
1693 return UUID.Zero;
1694 }
1695 }
1696 else
1697 {
1698 // Folder magic
1699 //
1700 if (action == DeRezAction.Delete)
1701 {
1702 // Deleting someone else's item
1703 //
1704
1705
1706 if (remoteClient == null ||
1707 objectGroup.OwnerID != remoteClient.AgentId)
1708 {
1709 // Folder skeleton may not be loaded and we
1710 // have to wait for the inventory to find
1711 // the destination folder
1712 //
1713 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1714 }
1715 else
1716 {
1717 // Assume inventory skeleton was loaded during login
1718 // and all folders can be found
1719 //
1720 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1721 }
1722 }
1723 else if (action == DeRezAction.Return)
1724 {
1725
1726 // Dump to lost + found unconditionally
1727 //
1728 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1729 }
1730
1731 if (folderID == UUID.Zero && folder == null)
1732 {
1733 if (action == DeRezAction.Delete)
1734 {
1735 // Deletes go to trash by default
1736 //
1737 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1738 }
1739 else
1740 {
1741 // Catch all. Use lost & found
1742 //
1743
1744 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1745 }
1746 }
1747
1748 if (folder == null) // None of the above
1749 {
1750 //folder = userInfo.RootFolder.FindFolder(folderID);
1751 folder = new InventoryFolderBase(folderID);
1752
1753 if (folder == null) // Nowhere to put it
1754 {
1755 return UUID.Zero;
1756 }
1757 }
1758
1759 item = new InventoryItemBase();
1760 item.CreatorId = objectGroup.RootPart.CreatorID.ToString();
1761 item.ID = UUID.Random();
1762 item.InvType = (int)InventoryType.Object;
1763 item.Folder = folder.ID;
1764 item.Owner = userID;
1765 }
1766
1767 AssetBase asset = CreateAsset(
1768 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
1769 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
1770 (sbyte)AssetType.Object,
1771 Utils.StringToBytes(sceneObjectXml));
1772 AssetService.Store(asset);
1773 assetID = asset.FullID;
1774
1775 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1776 {
1777 item.AssetID = asset.FullID;
1778 InventoryService.UpdateItem(item);
1779 }
1780 else
1781 {
1782 item.AssetID = asset.FullID;
1783
1784 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions())
1785 {
1786 uint perms=objectGroup.GetEffectivePermissions();
1787 uint nextPerms=(perms & 7) << 13;
1788 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
1789 perms &= ~(uint)PermissionMask.Copy;
1790 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
1791 perms &= ~(uint)PermissionMask.Transfer;
1792 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
1793 perms &= ~(uint)PermissionMask.Modify;
1794
1795 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
1796 item.CurrentPermissions = item.BasePermissions;
1797 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1798 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
1799 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
1800 item.CurrentPermissions |= 8; // Slam!
1801 }
1802 else
1803 {
1804 item.BasePermissions = objectGroup.GetEffectivePermissions();
1805 item.CurrentPermissions = objectGroup.GetEffectivePermissions();
1806 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1807 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1808 item.GroupPermissions = objectGroup.RootPart.GroupMask;
1809
1810 item.CurrentPermissions |= 8; // Slam!
1811 }
1812
1813 // TODO: add the new fields (Flags, Sale info, etc)
1814 item.CreationDate = Util.UnixTimeSinceEpoch();
1815 item.Description = asset.Description;
1816 item.Name = asset.Name;
1817 item.AssetType = asset.Type;
1818
1819 InventoryService.AddItem(item);
1820
1821 if (remoteClient != null && item.Owner == remoteClient.AgentId)
1822 {
1823 remoteClient.SendInventoryItemCreateUpdate(item, 0);
1824 }
1825 else
1826 {
1827 ScenePresence notifyUser = GetScenePresence(item.Owner);
1828 if (notifyUser != null)
1829 {
1830 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
1831 }
1832 }
1833 }
1834
1835 return assetID;
1836 }
1837
1838 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) 1557 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
1839 { 1558 {
1840 SceneObjectGroup objectGroup = grp; 1559 SceneObjectGroup objectGroup = grp;
@@ -1975,225 +1694,11 @@ namespace OpenSim.Region.Framework.Scenes
1975 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 1694 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1976 bool RezSelected, bool RemoveItem, UUID fromTaskID) 1695 bool RezSelected, bool RemoveItem, UUID fromTaskID)
1977 { 1696 {
1978 RezObject( 1697 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
1979 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 1698 if (invAccess != null)
1980 RezSelected, RemoveItem, fromTaskID, false); 1699 invAccess.RezObject(
1981 } 1700 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
1982 1701 RezSelected, RemoveItem, fromTaskID, false);
1983 /// <summary>
1984 /// Rez an object into the scene from the user's inventory
1985 /// </summary>
1986 /// <param name="remoteClient"></param>
1987 /// <param name="itemID"></param>
1988 /// <param name="RayEnd"></param>
1989 /// <param name="RayStart"></param>
1990 /// <param name="RayTargetID"></param>
1991 /// <param name="BypassRayCast"></param>
1992 /// <param name="RayEndIsIntersection"></param>
1993 /// <param name="RezSelected"></param>
1994 /// <param name="RemoveItem"></param>
1995 /// <param name="fromTaskID"></param>
1996 /// <param name="attachment"></param>
1997 /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns>
1998 public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
1999 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
2000 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
2001 {
2002 // Work out position details
2003 byte bRayEndIsIntersection = (byte)0;
2004
2005 if (RayEndIsIntersection)
2006 {
2007 bRayEndIsIntersection = (byte)1;
2008 }
2009 else
2010 {
2011 bRayEndIsIntersection = (byte)0;
2012 }
2013
2014 Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f);
2015
2016
2017 Vector3 pos = GetNewRezLocation(
2018 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2019 BypassRayCast, bRayEndIsIntersection,true,scale, false);
2020
2021 // Rez object
2022 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2023 item = InventoryService.GetItem(item);
2024
2025 if (item != null)
2026 {
2027 AssetBase rezAsset = AssetService.Get(item.AssetID.ToString());
2028
2029 if (rezAsset != null)
2030 {
2031 UUID itemId = UUID.Zero;
2032
2033 // If we have permission to copy then link the rezzed object back to the user inventory
2034 // item that it came from. This allows us to enable 'save object to inventory'
2035 if (!Permissions.BypassPermissions())
2036 {
2037 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
2038 {
2039 itemId = item.ID;
2040 }
2041 }
2042 else
2043 {
2044 // Brave new fullperm world
2045 //
2046 itemId = item.ID;
2047 }
2048
2049 string xmlData = Utils.BytesToString(rezAsset.Data);
2050 SceneObjectGroup group
2051 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData);
2052
2053 if (!Permissions.CanRezObject(
2054 group.Children.Count, remoteClient.AgentId, pos)
2055 && !attachment)
2056 {
2057 // The client operates in no fail mode. It will
2058 // have already removed the item from the folder
2059 // if it's no copy.
2060 // Put it back if it's not an attachment
2061 //
2062 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
2063 remoteClient.SendBulkUpdateInventory(item);
2064 return null;
2065 }
2066
2067 group.ResetIDs();
2068
2069 if (attachment)
2070 {
2071 group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
2072 group.RootPart.IsAttachment = true;
2073 }
2074
2075 AddNewSceneObject(group, true);
2076
2077 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
2078 // if attachment we set it's asset id so object updates can reflect that
2079 // if not, we set it's position in world.
2080 if (!attachment)
2081 {
2082 float offsetHeight = 0;
2083 pos = GetNewRezLocation(
2084 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2085 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
2086 pos.Z += offsetHeight;
2087 group.AbsolutePosition = pos;
2088 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
2089
2090 }
2091 else
2092 {
2093 group.SetFromItemID(itemID);
2094 }
2095
2096 SceneObjectPart rootPart = null;
2097 try
2098 {
2099 rootPart = group.GetChildPart(group.UUID);
2100 }
2101 catch (NullReferenceException)
2102 {
2103 string isAttachment = "";
2104
2105 if (attachment)
2106 isAttachment = " Object was an attachment";
2107
2108 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
2109 }
2110
2111 // Since renaming the item in the inventory does not affect the name stored
2112 // in the serialization, transfer the correct name from the inventory to the
2113 // object itself before we rez.
2114 rootPart.Name = item.Name;
2115 rootPart.Description = item.Description;
2116
2117 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
2118
2119 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
2120 if (rootPart.OwnerID != item.Owner)
2121 {
2122 //Need to kill the for sale here
2123 rootPart.ObjectSaleType = 0;
2124 rootPart.SalePrice = 10;
2125
2126 if (Permissions.PropagatePermissions())
2127 {
2128 if ((item.CurrentPermissions & 8) != 0)
2129 {
2130 foreach (SceneObjectPart part in partList)
2131 {
2132 part.EveryoneMask = item.EveryOnePermissions;
2133 part.NextOwnerMask = item.NextPermissions;
2134 part.GroupMask = 0; // DO NOT propagate here
2135 }
2136 }
2137 group.ApplyNextOwnerPermissions();
2138 }
2139 }
2140
2141 foreach (SceneObjectPart part in partList)
2142 {
2143 if (part.OwnerID != item.Owner)
2144 {
2145 part.LastOwnerID = part.OwnerID;
2146 part.OwnerID = item.Owner;
2147 part.Inventory.ChangeInventoryOwner(item.Owner);
2148 }
2149 else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam!
2150 {
2151 part.EveryoneMask = item.EveryOnePermissions;
2152 part.NextOwnerMask = item.NextPermissions;
2153
2154 part.GroupMask = 0; // DO NOT propagate here
2155 }
2156 }
2157
2158 rootPart.TrimPermissions();
2159
2160 if (!attachment)
2161 {
2162 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
2163 {
2164 group.ClearPartAttachmentData();
2165 }
2166 }
2167
2168 if (!attachment)
2169 {
2170 // Fire on_rez
2171 group.CreateScriptInstances(0, true, DefaultScriptEngine, 0);
2172
2173 rootPart.ScheduleFullUpdate();
2174 }
2175
2176 if (!Permissions.BypassPermissions())
2177 {
2178 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
2179 {
2180 // If this is done on attachments, no
2181 // copy ones will be lost, so avoid it
2182 //
2183 if (!attachment)
2184 {
2185 List<UUID> uuids = new List<UUID>();
2186 uuids.Add(item.ID);
2187 InventoryService.DeleteItems(item.Owner, uuids);
2188 }
2189 }
2190 }
2191
2192 return rootPart.ParentGroup;
2193 }
2194 }
2195
2196 return null;
2197 } 1702 }
2198 1703
2199 /// <summary> 1704 /// <summary>
@@ -2417,7 +1922,7 @@ namespace OpenSim.Region.Framework.Scenes
2417 // XXYY!! 1922 // XXYY!!
2418 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 1923 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2419 item = InventoryService.GetItem(item); 1924 item = InventoryService.GetItem(item);
2420 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); 1925 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
2421 1926
2422 if (m_AvatarFactory != null) 1927 if (m_AvatarFactory != null)
2423 { 1928 {
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;
32using OpenMetaverse.Packets; 32using OpenMetaverse.Packets;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Services.Interfaces;
36 36
37namespace OpenSim.Region.Framework.Scenes 37namespace 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 73b0b3e..f109589 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -41,8 +41,7 @@ using OpenMetaverse.Imaging;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
43using OpenSim.Framework.Communications; 43using OpenSim.Framework.Communications;
44using OpenSim.Framework.Communications.Cache; 44
45using OpenSim.Framework.Communications.Clients;
46using OpenSim.Framework.Console; 45using OpenSim.Framework.Console;
47using OpenSim.Region.Framework.Interfaces; 46using OpenSim.Region.Framework.Interfaces;
48using OpenSim.Region.Framework.Scenes.Scripting; 47using OpenSim.Region.Framework.Scenes.Scripting;
@@ -141,7 +140,6 @@ namespace OpenSim.Region.Framework.Scenes
141 protected ModuleLoader m_moduleLoader; 140 protected ModuleLoader m_moduleLoader;
142 protected StorageManager m_storageManager; 141 protected StorageManager m_storageManager;
143 protected AgentCircuitManager m_authenticateHandler; 142 protected AgentCircuitManager m_authenticateHandler;
144 public CommunicationsManager CommsManager;
145 143
146 protected SceneCommunicationService m_sceneGridService; 144 protected SceneCommunicationService m_sceneGridService;
147 public bool LoginsDisabled = true; 145 public bool LoginsDisabled = true;
@@ -189,11 +187,11 @@ namespace OpenSim.Region.Framework.Scenes
189 { 187 {
190 m_AuthorizationService = RequestModuleInterface<IAuthorizationService>(); 188 m_AuthorizationService = RequestModuleInterface<IAuthorizationService>();
191 189
192 if (m_AuthorizationService == null) 190 //if (m_AuthorizationService == null)
193 { 191 //{
194 // don't throw an exception if no authorization service is set for the time being 192 // // 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"); 193 // m_log.InfoFormat("[SCENE]: No Authorization service is configured");
196 } 194 //}
197 } 195 }
198 196
199 return m_AuthorizationService; 197 return m_AuthorizationService;
@@ -240,6 +238,73 @@ namespace OpenSim.Region.Framework.Scenes
240 } 238 }
241 } 239 }
242 240
241 protected ILibraryService m_LibraryService;
242
243 public ILibraryService LibraryService
244 {
245 get
246 {
247 if (m_LibraryService == null)
248 m_LibraryService = RequestModuleInterface<ILibraryService>();
249
250 return m_LibraryService;
251 }
252 }
253
254 protected ISimulationService m_simulationService;
255 public ISimulationService SimulationService
256 {
257 get
258 {
259 if (m_simulationService == null)
260 m_simulationService = RequestModuleInterface<ISimulationService>();
261 return m_simulationService;
262 }
263 }
264
265 protected IAuthenticationService m_AuthenticationService;
266 public IAuthenticationService AuthenticationService
267 {
268 get
269 {
270 if (m_AuthenticationService == null)
271 m_AuthenticationService = RequestModuleInterface<IAuthenticationService>();
272 return m_AuthenticationService;
273 }
274 }
275
276 protected IPresenceService m_PresenceService;
277 public IPresenceService PresenceService
278 {
279 get
280 {
281 if (m_PresenceService == null)
282 m_PresenceService = RequestModuleInterface<IPresenceService>();
283 return m_PresenceService;
284 }
285 }
286 protected IUserAccountService m_UserAccountService;
287 public IUserAccountService UserAccountService
288 {
289 get
290 {
291 if (m_UserAccountService == null)
292 m_UserAccountService = RequestModuleInterface<IUserAccountService>();
293 return m_UserAccountService;
294 }
295 }
296
297 protected OpenSim.Services.Interfaces.IAvatarService m_AvatarService;
298 public OpenSim.Services.Interfaces.IAvatarService AvatarService
299 {
300 get
301 {
302 if (m_AvatarService == null)
303 m_AvatarService = RequestModuleInterface<IAvatarService>();
304 return m_AvatarService;
305 }
306 }
307
243 protected IXMLRPC m_xmlrpcModule; 308 protected IXMLRPC m_xmlrpcModule;
244 protected IWorldComm m_worldCommModule; 309 protected IWorldComm m_worldCommModule;
245 protected IAvatarFactory m_AvatarFactory; 310 protected IAvatarFactory m_AvatarFactory;
@@ -249,10 +314,8 @@ namespace OpenSim.Region.Framework.Scenes
249 } 314 }
250 protected IConfigSource m_config; 315 protected IConfigSource m_config;
251 protected IRegionSerialiserModule m_serialiser; 316 protected IRegionSerialiserModule m_serialiser;
252 protected IInterregionCommsOut m_interregionCommsOut;
253 protected IInterregionCommsIn m_interregionCommsIn;
254 protected IDialogModule m_dialogModule; 317 protected IDialogModule m_dialogModule;
255 protected ITeleportModule m_teleportModule; 318 protected IEntityTransferModule m_teleportModule;
256 319
257 protected ICapabilitiesModule m_capsModule; 320 protected ICapabilitiesModule m_capsModule;
258 public ICapabilitiesModule CapsModule 321 public ICapabilitiesModule CapsModule
@@ -483,7 +546,7 @@ namespace OpenSim.Region.Framework.Scenes
483 #region Constructors 546 #region Constructors
484 547
485 public Scene(RegionInfo regInfo, AgentCircuitManager authen, 548 public Scene(RegionInfo regInfo, AgentCircuitManager authen,
486 CommunicationsManager commsMan, SceneCommunicationService sceneGridService, 549 SceneCommunicationService sceneGridService,
487 StorageManager storeManager, 550 StorageManager storeManager,
488 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, 551 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
489 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) 552 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
@@ -519,7 +582,6 @@ namespace OpenSim.Region.Framework.Scenes
519 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); 582 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4);
520 m_moduleLoader = moduleLoader; 583 m_moduleLoader = moduleLoader;
521 m_authenticateHandler = authen; 584 m_authenticateHandler = authen;
522 CommsManager = commsMan;
523 m_sceneGridService = sceneGridService; 585 m_sceneGridService = sceneGridService;
524 m_storageManager = storeManager; 586 m_storageManager = storeManager;
525 m_regInfo = regInfo; 587 m_regInfo = regInfo;
@@ -776,6 +838,36 @@ namespace OpenSim.Region.Framework.Scenes
776 return m_simulatorVersion; 838 return m_simulatorVersion;
777 } 839 }
778 840
841 public string[] GetUserNames(UUID uuid)
842 {
843 string[] returnstring = new string[0];
844
845 UserAccount account = UserAccountService.GetUserAccount(RegionInfo.ScopeID, uuid);
846
847 if (account != null)
848 {
849 returnstring = new string[2];
850 returnstring[0] = account.FirstName;
851 returnstring[1] = account.LastName;
852 }
853
854 return returnstring;
855 }
856
857 public string GetUserName(UUID uuid)
858 {
859 string[] names = GetUserNames(uuid);
860 if (names.Length == 2)
861 {
862 string firstname = names[0];
863 string lastname = names[1];
864
865 return firstname + " " + lastname;
866
867 }
868 return "(hippos)";
869 }
870
779 /// <summary> 871 /// <summary>
780 /// Another region is up. 872 /// Another region is up.
781 /// 873 ///
@@ -809,7 +901,7 @@ namespace OpenSim.Region.Framework.Scenes
809 regInfo.RegionName = otherRegion.RegionName; 901 regInfo.RegionName = otherRegion.RegionName;
810 regInfo.ScopeID = otherRegion.ScopeID; 902 regInfo.ScopeID = otherRegion.ScopeID;
811 regInfo.ExternalHostName = otherRegion.ExternalHostName; 903 regInfo.ExternalHostName = otherRegion.ExternalHostName;
812 904 GridRegion r = new GridRegion(regInfo);
813 try 905 try
814 { 906 {
815 ForEachScenePresence(delegate(ScenePresence agent) 907 ForEachScenePresence(delegate(ScenePresence agent)
@@ -823,7 +915,8 @@ namespace OpenSim.Region.Framework.Scenes
823 List<ulong> old = new List<ulong>(); 915 List<ulong> old = new List<ulong>();
824 old.Add(otherRegion.RegionHandle); 916 old.Add(otherRegion.RegionHandle);
825 agent.DropOldNeighbours(old); 917 agent.DropOldNeighbours(old);
826 InformClientOfNeighbor(agent, regInfo); 918 if (m_teleportModule != null)
919 m_teleportModule.EnableChildAgent(agent, r);
827 } 920 }
828 } 921 }
829 ); 922 );
@@ -971,6 +1064,7 @@ namespace OpenSim.Region.Framework.Scenes
971 { 1064 {
972 foreach (RegionInfo region in m_regionRestartNotifyList) 1065 foreach (RegionInfo region in m_regionRestartNotifyList)
973 { 1066 {
1067 GridRegion r = new GridRegion(region);
974 try 1068 try
975 { 1069 {
976 ForEachScenePresence(delegate(ScenePresence agent) 1070 ForEachScenePresence(delegate(ScenePresence agent)
@@ -978,9 +1072,8 @@ namespace OpenSim.Region.Framework.Scenes
978 // If agent is a root agent. 1072 // If agent is a root agent.
979 if (!agent.IsChildAgent) 1073 if (!agent.IsChildAgent)
980 { 1074 {
981 //agent.ControllingClient.new 1075 if (m_teleportModule != null)
982 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 1076 m_teleportModule.EnableChildAgent(agent, r);
983 InformClientOfNeighbor(agent, region);
984 } 1077 }
985 } 1078 }
986 ); 1079 );
@@ -1123,11 +1216,9 @@ namespace OpenSim.Region.Framework.Scenes
1123 XferManager = RequestModuleInterface<IXfer>(); 1216 XferManager = RequestModuleInterface<IXfer>();
1124 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); 1217 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>();
1125 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1218 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1126 m_interregionCommsOut = RequestModuleInterface<IInterregionCommsOut>();
1127 m_interregionCommsIn = RequestModuleInterface<IInterregionCommsIn>();
1128 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1219 m_dialogModule = RequestModuleInterface<IDialogModule>();
1129 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1220 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1130 m_teleportModule = RequestModuleInterface<ITeleportModule>(); 1221 m_teleportModule = RequestModuleInterface<IEntityTransferModule>();
1131 } 1222 }
1132 1223
1133 #endregion 1224 #endregion
@@ -1564,7 +1655,9 @@ namespace OpenSim.Region.Framework.Scenes
1564 GridRegion region = new GridRegion(RegionInfo); 1655 GridRegion region = new GridRegion(RegionInfo);
1565 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); 1656 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region);
1566 if (error != String.Empty) 1657 if (error != String.Empty)
1658 {
1567 throw new Exception(error); 1659 throw new Exception(error);
1660 }
1568 1661
1569 m_sceneGridService.SetScene(this); 1662 m_sceneGridService.SetScene(this);
1570 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); 1663 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
@@ -1951,7 +2044,6 @@ namespace OpenSim.Region.Framework.Scenes
1951 /// Move the given scene object into a new region depending on which region its absolute position has moved 2044 /// Move the given scene object into a new region depending on which region its absolute position has moved
1952 /// into. 2045 /// into.
1953 /// 2046 ///
1954 /// This method locates the new region handle and offsets the prim position for the new region
1955 /// </summary> 2047 /// </summary>
1956 /// <param name="attemptedPosition">the attempted out of region position of the scene object</param> 2048 /// <param name="attemptedPosition">the attempted out of region position of the scene object</param>
1957 /// <param name="grp">the scene object that we're crossing</param> 2049 /// <param name="grp">the scene object that we're crossing</param>
@@ -1962,199 +2054,9 @@ namespace OpenSim.Region.Framework.Scenes
1962 if (grp.IsDeleted) 2054 if (grp.IsDeleted)
1963 return; 2055 return;
1964 2056
1965 if (grp.RootPart.DIE_AT_EDGE) 2057 if (m_teleportModule != null)
1966 { 2058 m_teleportModule.Cross(grp, attemptedPosition, silent);
1967 // We remove the object here
1968 try
1969 {
1970 DeleteSceneObject(grp, false);
1971 }
1972 catch (Exception)
1973 {
1974 m_log.Warn("[DATABASE]: exception when trying to remove the prim that crossed the border.");
1975 }
1976 return;
1977 }
1978 2059
1979 int thisx = (int)RegionInfo.RegionLocX;
1980 int thisy = (int)RegionInfo.RegionLocY;
1981 Vector3 EastCross = new Vector3(0.1f,0,0);
1982 Vector3 WestCross = new Vector3(-0.1f, 0, 0);
1983 Vector3 NorthCross = new Vector3(0, 0.1f, 0);
1984 Vector3 SouthCross = new Vector3(0, -0.1f, 0);
1985
1986
1987 // use this if no borders were crossed!
1988 ulong newRegionHandle
1989 = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize),
1990 (uint)((thisy) * Constants.RegionSize));
1991
1992 Vector3 pos = attemptedPosition;
1993
1994 int changeX = 1;
1995 int changeY = 1;
1996
1997 if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W))
1998 {
1999 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2000 {
2001
2002 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2003
2004 if (crossedBorderx.BorderLine.Z > 0)
2005 {
2006 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2007 changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize);
2008 }
2009 else
2010 pos.X = ((pos.X + Constants.RegionSize));
2011
2012 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2013 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2014
2015 if (crossedBordery.BorderLine.Z > 0)
2016 {
2017 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2018 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2019 }
2020 else
2021 pos.Y = ((pos.Y + Constants.RegionSize));
2022
2023
2024
2025 newRegionHandle
2026 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2027 (uint)((thisy - changeY) * Constants.RegionSize));
2028 // x - 1
2029 // y - 1
2030 }
2031 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2032 {
2033 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2034
2035 if (crossedBorderx.BorderLine.Z > 0)
2036 {
2037 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2038 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
2039 }
2040 else
2041 pos.X = ((pos.X + Constants.RegionSize));
2042
2043
2044 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2045 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2046
2047 if (crossedBordery.BorderLine.Z > 0)
2048 {
2049 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2050 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2051 }
2052 else
2053 pos.Y = ((pos.Y + Constants.RegionSize));
2054
2055 newRegionHandle
2056 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2057 (uint)((thisy + changeY) * Constants.RegionSize));
2058 // x - 1
2059 // y + 1
2060 }
2061 else
2062 {
2063 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2064
2065 if (crossedBorderx.BorderLine.Z > 0)
2066 {
2067 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2068 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
2069 }
2070 else
2071 pos.X = ((pos.X + Constants.RegionSize));
2072
2073 newRegionHandle
2074 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2075 (uint) (thisy*Constants.RegionSize));
2076 // x - 1
2077 }
2078 }
2079 else if (TestBorderCross(attemptedPosition + EastCross, Cardinals.E))
2080 {
2081 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2082 {
2083
2084 pos.X = ((pos.X - Constants.RegionSize));
2085 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2086 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2087
2088 if (crossedBordery.BorderLine.Z > 0)
2089 {
2090 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2091 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2092 }
2093 else
2094 pos.Y = ((pos.Y + Constants.RegionSize));
2095
2096
2097 newRegionHandle
2098 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2099 (uint)((thisy - changeY) * Constants.RegionSize));
2100 // x + 1
2101 // y - 1
2102 }
2103 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2104 {
2105 pos.X = ((pos.X - Constants.RegionSize));
2106 pos.Y = ((pos.Y - Constants.RegionSize));
2107 newRegionHandle
2108 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2109 (uint)((thisy + changeY) * Constants.RegionSize));
2110 // x + 1
2111 // y + 1
2112 }
2113 else
2114 {
2115 pos.X = ((pos.X - Constants.RegionSize));
2116 newRegionHandle
2117 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2118 (uint) (thisy*Constants.RegionSize));
2119 // x + 1
2120 }
2121 }
2122 else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2123 {
2124 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2125 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2126
2127 if (crossedBordery.BorderLine.Z > 0)
2128 {
2129 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2130 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2131 }
2132 else
2133 pos.Y = ((pos.Y + Constants.RegionSize));
2134
2135 newRegionHandle
2136 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize));
2137 // y - 1
2138 }
2139 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2140 {
2141
2142 pos.Y = ((pos.Y - Constants.RegionSize));
2143 newRegionHandle
2144 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize));
2145 // y + 1
2146 }
2147
2148 // Offset the positions for the new region across the border
2149 Vector3 oldGroupPosition = grp.RootPart.GroupPosition;
2150 grp.OffsetForNewRegion(pos);
2151
2152 // If we fail to cross the border, then reset the position of the scene object on that border.
2153 if (!CrossPrimGroupIntoNewRegion(newRegionHandle, grp, silent))
2154 {
2155 grp.OffsetForNewRegion(oldGroupPosition);
2156 grp.ScheduleGroupForFullUpdate();
2157 }
2158 } 2060 }
2159 2061
2160 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2062 public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
@@ -2337,75 +2239,6 @@ namespace OpenSim.Region.Framework.Scenes
2337 } 2239 }
2338 2240
2339 2241
2340 /// <summary>
2341 /// Move the given scene object into a new region
2342 /// </summary>
2343 /// <param name="newRegionHandle"></param>
2344 /// <param name="grp">Scene Object Group that we're crossing</param>
2345 /// <returns>
2346 /// true if the crossing itself was successful, false on failure
2347 /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region
2348 /// </returns>
2349 public bool CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp, bool silent)
2350 {
2351 //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<");
2352
2353 bool successYN = false;
2354 grp.RootPart.UpdateFlag = 0;
2355 //int primcrossingXMLmethod = 0;
2356
2357 if (newRegionHandle != 0)
2358 {
2359 //string objectState = grp.GetStateSnapshot();
2360
2361 //successYN
2362 // = m_sceneGridService.PrimCrossToNeighboringRegion(
2363 // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod);
2364 //if (successYN && (objectState != "") && m_allowScriptCrossings)
2365 //{
2366 // successYN = m_sceneGridService.PrimCrossToNeighboringRegion(
2367 // newRegionHandle, grp.UUID, objectState, 100);
2368 //}
2369
2370 // And the new channel...
2371 if (m_interregionCommsOut != null)
2372 successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true);
2373
2374 if (successYN)
2375 {
2376 // We remove the object here
2377 try
2378 {
2379 DeleteSceneObject(grp, silent);
2380 }
2381 catch (Exception e)
2382 {
2383 m_log.ErrorFormat(
2384 "[INTERREGION]: Exception deleting the old object left behind on a border crossing for {0}, {1}",
2385 grp, e);
2386 }
2387 }
2388 else
2389 {
2390 if (!grp.IsDeleted)
2391 {
2392 if (grp.RootPart.PhysActor != null)
2393 {
2394 grp.RootPart.PhysActor.CrossingFailure();
2395 }
2396 }
2397
2398 m_log.ErrorFormat("[INTERREGION]: Prim crossing failed for {0}", grp);
2399 }
2400 }
2401 else
2402 {
2403 m_log.Error("[INTERREGION]: region handle was unexpectedly 0 in Scene.CrossPrimGroupIntoNewRegion()");
2404 }
2405
2406 return successYN;
2407 }
2408
2409 public bool IncomingCreateObject(ISceneObject sog) 2242 public bool IncomingCreateObject(ISceneObject sog)
2410 { 2243 {
2411 //m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted); 2244 //m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted);
@@ -2466,6 +2299,9 @@ namespace OpenSim.Region.Framework.Scenes
2466 2299
2467 return false; 2300 return false;
2468 } 2301 }
2302
2303 sceneObject.SetScene(this);
2304
2469 // Force allocation of new LocalId 2305 // Force allocation of new LocalId
2470 // 2306 //
2471 foreach (SceneObjectPart p in sceneObject.Children.Values) 2307 foreach (SceneObjectPart p in sceneObject.Children.Values)
@@ -2584,6 +2420,37 @@ namespace OpenSim.Region.Framework.Scenes
2584 { 2420 {
2585 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); 2421 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
2586 2422
2423 // Do the verification here
2424 System.Net.EndPoint ep = client.GetClientEP();
2425 if (aCircuit != null)
2426 {
2427 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
2428 {
2429 m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2430 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
2431 if (userVerification != null)
2432 {
2433 if (!userVerification.VerifyClient(aCircuit, ep.ToString()))
2434 {
2435 // uh-oh, this is fishy
2436 m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
2437 client.AgentId, client.SessionId, ep.ToString());
2438 try
2439 {
2440 client.Close();
2441 }
2442 catch (Exception e)
2443 {
2444 m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace);
2445 }
2446 return;
2447 }
2448 else
2449 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} returned true", aCircuit.firstname, aCircuit.lastname);
2450 }
2451 }
2452 }
2453
2587 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); 2454 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
2588 /* 2455 /*
2589 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}", 2456 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}",
@@ -2593,9 +2460,9 @@ namespace OpenSim.Region.Framework.Scenes
2593 m_log.Debug(logMsg); 2460 m_log.Debug(logMsg);
2594 */ 2461 */
2595 2462
2596 CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); 2463 //CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
2597
2598 ScenePresence sp = CreateAndAddScenePresence(client); 2464 ScenePresence sp = CreateAndAddScenePresence(client);
2465 sp.Appearance = aCircuit.Appearance;
2599 2466
2600 // HERE!!! Do the initial attachments right here 2467 // HERE!!! Do the initial attachments right here
2601 // first agent upon login is a root agent by design. 2468 // first agent upon login is a root agent by design.
@@ -2609,6 +2476,7 @@ namespace OpenSim.Region.Framework.Scenes
2609 2476
2610 m_LastLogin = Util.EnvironmentTickCount(); 2477 m_LastLogin = Util.EnvironmentTickCount();
2611 EventManager.TriggerOnNewClient(client); 2478 EventManager.TriggerOnNewClient(client);
2479
2612 } 2480 }
2613 2481
2614 2482
@@ -2725,7 +2593,6 @@ namespace OpenSim.Region.Framework.Scenes
2725 { 2593 {
2726 client.OnTeleportLocationRequest += RequestTeleportLocation; 2594 client.OnTeleportLocationRequest += RequestTeleportLocation;
2727 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 2595 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
2728 client.OnTeleportHomeRequest += TeleportClientHome;
2729 } 2596 }
2730 2597
2731 public virtual void SubscribeToClientScriptEvents(IClientAPI client) 2598 public virtual void SubscribeToClientScriptEvents(IClientAPI client)
@@ -2745,7 +2612,7 @@ namespace OpenSim.Region.Framework.Scenes
2745 2612
2746 public virtual void SubscribeToClientGridEvents(IClientAPI client) 2613 public virtual void SubscribeToClientGridEvents(IClientAPI client)
2747 { 2614 {
2748 client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; 2615 client.OnNameFromUUIDRequest += HandleUUIDNameRequest;
2749 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; 2616 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
2750 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; 2617 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest;
2751 client.OnSetStartLocationRequest += SetHomeRezPoint; 2618 client.OnSetStartLocationRequest += SetHomeRezPoint;
@@ -2880,7 +2747,7 @@ namespace OpenSim.Region.Framework.Scenes
2880 { 2747 {
2881 client.OnTeleportLocationRequest -= RequestTeleportLocation; 2748 client.OnTeleportLocationRequest -= RequestTeleportLocation;
2882 client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; 2749 client.OnTeleportLandmarkRequest -= RequestTeleportLandmark;
2883 client.OnTeleportHomeRequest -= TeleportClientHome; 2750 //client.OnTeleportHomeRequest -= TeleportClientHome;
2884 } 2751 }
2885 2752
2886 public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) 2753 public virtual void UnSubscribeToClientScriptEvents(IClientAPI client)
@@ -2900,7 +2767,7 @@ namespace OpenSim.Region.Framework.Scenes
2900 2767
2901 public virtual void UnSubscribeToClientGridEvents(IClientAPI client) 2768 public virtual void UnSubscribeToClientGridEvents(IClientAPI client)
2902 { 2769 {
2903 client.OnNameFromUUIDRequest -= CommsManager.HandleUUIDNameRequest; 2770 client.OnNameFromUUIDRequest -= HandleUUIDNameRequest;
2904 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; 2771 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest;
2905 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; 2772 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest;
2906 client.OnSetStartLocationRequest -= SetHomeRezPoint; 2773 client.OnSetStartLocationRequest -= SetHomeRezPoint;
@@ -2927,30 +2794,12 @@ namespace OpenSim.Region.Framework.Scenes
2927 /// <param name="client">The IClientAPI for the client</param> 2794 /// <param name="client">The IClientAPI for the client</param>
2928 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2795 public virtual void TeleportClientHome(UUID agentId, IClientAPI client)
2929 { 2796 {
2930 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); 2797 if (m_teleportModule != null)
2931 if (UserProfile != null) 2798 m_teleportModule.TeleportHome(agentId, client);
2799 else
2932 { 2800 {
2933 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); 2801 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2934 if (regionInfo == null) 2802 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2935 {
2936 uint x = 0, y = 0;
2937 Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
2938 regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
2939 if (regionInfo != null) // home region can be away temporarily, too
2940 {
2941 UserProfile.HomeRegionID = regionInfo.RegionID;
2942 CommsManager.UserService.UpdateUserProfile(UserProfile);
2943 }
2944 }
2945 if (regionInfo == null)
2946 {
2947 // can't find the Home region: Tell viewer and abort
2948 client.SendTeleportFailed("Your home-region could not be found.");
2949 return;
2950 }
2951 RequestTeleportLocation(
2952 client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
2953 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
2954 } 2803 }
2955 } 2804 }
2956 2805
@@ -3041,7 +2890,7 @@ namespace OpenSim.Region.Framework.Scenes
3041 } 2890 }
3042 2891
3043 /// <summary> 2892 /// <summary>
3044 /// Sets the Home Point. The GridService uses this to know where to put a user when they log-in 2893 /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in
3045 /// </summary> 2894 /// </summary>
3046 /// <param name="remoteClient"></param> 2895 /// <param name="remoteClient"></param>
3047 /// <param name="regionHandle"></param> 2896 /// <param name="regionHandle"></param>
@@ -3050,27 +2899,11 @@ namespace OpenSim.Region.Framework.Scenes
3050 /// <param name="flags"></param> 2899 /// <param name="flags"></param>
3051 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 2900 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3052 { 2901 {
3053 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); 2902 if (PresenceService.SetHomeLocation(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3054 if (UserProfile != null)
3055 {
3056 // I know I'm ignoring the regionHandle provided by the teleport location request.
3057 // reusing the TeleportLocationRequest delegate, so regionHandle isn't valid
3058 UserProfile.HomeRegionID = RegionInfo.RegionID;
3059 // TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around.
3060 // TODO: The HomeRegion property can be removed then, too
3061 UserProfile.HomeRegion = RegionInfo.RegionHandle;
3062
3063 UserProfile.HomeLocation = position;
3064 UserProfile.HomeLookAt = lookAt;
3065 CommsManager.UserService.UpdateUserProfile(UserProfile);
3066
3067 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 2903 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3068 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 2904 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
3069 }
3070 else 2905 else
3071 {
3072 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); 2906 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed.");
3073 }
3074 } 2907 }
3075 2908
3076 /// <summary> 2909 /// <summary>
@@ -3144,14 +2977,12 @@ namespace OpenSim.Region.Framework.Scenes
3144 m_sceneGraph.removeUserCount(!childagentYN); 2977 m_sceneGraph.removeUserCount(!childagentYN);
3145 CapsModule.RemoveCapsHandler(agentID); 2978 CapsModule.RemoveCapsHandler(agentID);
3146 2979
3147 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) 2980 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3148 { 2981 // this method is doing is HORRIBLE!!!
3149 CommsManager.UserProfileCacheService.RemoveUser(agentID); 2982 avatar.Scene.NeedSceneCacheClear(avatar.UUID);
3150 }
3151 2983
3152 if (!avatar.IsChildAgent) 2984 if (!avatar.IsChildAgent)
3153 { 2985 {
3154 m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat);
3155 //List<ulong> childknownRegions = new List<ulong>(); 2986 //List<ulong> childknownRegions = new List<ulong>();
3156 //List<ulong> ckn = avatar.KnownChildRegionHandles; 2987 //List<ulong> ckn = avatar.KnownChildRegionHandles;
3157 //for (int i = 0; i < ckn.Count; i++) 2988 //for (int i = 0; i < ckn.Count; i++)
@@ -3206,12 +3037,6 @@ namespace OpenSim.Region.Framework.Scenes
3206 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3037 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3207 } 3038 }
3208 3039
3209 // Remove client agent from profile, so new logins will work
3210 if (!childagentYN)
3211 {
3212 m_sceneGridService.ClearUserAgent(agentID);
3213 }
3214
3215 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3040 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3216 3041
3217 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3042 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
@@ -3285,14 +3110,6 @@ namespace OpenSim.Region.Framework.Scenes
3285 m_sceneGridService.KiPrimitive += SendKillObject; 3110 m_sceneGridService.KiPrimitive += SendKillObject;
3286 m_sceneGridService.OnGetLandData += GetLandData; 3111 m_sceneGridService.OnGetLandData += GetLandData;
3287 3112
3288 if (m_interregionCommsIn != null)
3289 {
3290 m_log.Debug("[SCENE]: Registering with InterregionCommsIn");
3291 m_interregionCommsIn.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3292 }
3293 else
3294 m_log.Debug("[SCENE]: Unable to register with InterregionCommsIn");
3295
3296 } 3113 }
3297 3114
3298 /// <summary> 3115 /// <summary>
@@ -3310,9 +3127,6 @@ namespace OpenSim.Region.Framework.Scenes
3310 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; 3127 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
3311 m_sceneGridService.OnGetLandData -= GetLandData; 3128 m_sceneGridService.OnGetLandData -= GetLandData;
3312 3129
3313 if (m_interregionCommsIn != null)
3314 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3315
3316 // this does nothing; should be removed 3130 // this does nothing; should be removed
3317 m_sceneGridService.Close(); 3131 m_sceneGridService.Close();
3318 3132
@@ -3369,7 +3183,7 @@ namespace OpenSim.Region.Framework.Scenes
3369 agent.AgentID, agent.circuitcode, teleportFlags); 3183 agent.AgentID, agent.circuitcode, teleportFlags);
3370 3184
3371 reason = String.Empty; 3185 reason = String.Empty;
3372 if (!AuthenticateUser(agent, out reason)) 3186 if (!VerifyUserPresence(agent, out reason))
3373 return false; 3187 return false;
3374 3188
3375 if (!AuthorizeUser(agent, out reason)) 3189 if (!AuthorizeUser(agent, out reason))
@@ -3464,40 +3278,39 @@ namespace OpenSim.Region.Framework.Scenes
3464 } 3278 }
3465 } 3279 }
3466 3280
3281 agent.teleportFlags = teleportFlags;
3467 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3282 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3468 3283
3469 // rewrite session_id
3470 CachedUserInfo userinfo = CommsManager.UserProfileCacheService.GetUserDetails(agent.AgentID);
3471 if (userinfo != null)
3472 {
3473 userinfo.SessionID = agent.SessionID;
3474 }
3475 else
3476 {
3477 m_log.WarnFormat(
3478 "[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);
3479 }
3480
3481 return true; 3284 return true;
3482 } 3285 }
3483 3286
3484 /// <summary> 3287 /// <summary>
3485 /// Verifies that the user has a session on the Grid 3288 /// Verifies that the user has a presence on the Grid
3486 /// </summary> 3289 /// </summary>
3487 /// <param name="agent">Circuit Data of the Agent we're verifying</param> 3290 /// <param name="agent">Circuit Data of the Agent we're verifying</param>
3488 /// <param name="reason">Outputs the reason for the false response on this string</param> 3291 /// <param name="reason">Outputs the reason for the false response on this string</param>
3489 /// <returns>True if the user has a session on the grid. False if it does not. False will 3292 /// <returns>True if the user has a session on the grid. False if it does not. False will
3490 /// also return a reason.</returns> 3293 /// also return a reason.</returns>
3491 public virtual bool AuthenticateUser(AgentCircuitData agent, out string reason) 3294 public virtual bool VerifyUserPresence(AgentCircuitData agent, out string reason)
3492 { 3295 {
3493 reason = String.Empty; 3296 reason = String.Empty;
3494 3297
3495 bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID); 3298 IPresenceService presence = RequestModuleInterface<IPresenceService>();
3496 m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result); 3299 if (presence == null)
3497 if (!result) 3300 {
3498 reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname); 3301 reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3302 return false;
3303 }
3304
3305 OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID);
3499 3306
3500 return result; 3307 if (pinfo == null || (pinfo != null && pinfo.Online == false))
3308 {
3309 reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3310 return false;
3311 }
3312
3313 return true;
3501 } 3314 }
3502 3315
3503 /// <summary> 3316 /// <summary>
@@ -3698,8 +3511,8 @@ namespace OpenSim.Region.Framework.Scenes
3698 /// <returns>true if we handled it.</returns> 3511 /// <returns>true if we handled it.</returns>
3699 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) 3512 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData)
3700 { 3513 {
3701// m_log.DebugFormat( 3514 m_log.DebugFormat(
3702// "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); 3515 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
3703 3516
3704 // We have to wait until the viewer contacts this region after receiving EAC. 3517 // We have to wait until the viewer contacts this region after receiving EAC.
3705 // That calls AddNewClient, which finally creates the ScenePresence 3518 // That calls AddNewClient, which finally creates the ScenePresence
@@ -3768,16 +3581,6 @@ namespace OpenSim.Region.Framework.Scenes
3768 return false; 3581 return false;
3769 } 3582 }
3770 3583
3771 public virtual bool IncomingReleaseAgent(UUID id)
3772 {
3773 return m_sceneGridService.ReleaseAgent(id);
3774 }
3775
3776 public void SendReleaseAgent(ulong regionHandle, UUID id, string uri)
3777 {
3778 m_interregionCommsOut.SendReleaseAgent(regionHandle, id, uri);
3779 }
3780
3781 /// <summary> 3584 /// <summary>
3782 /// Tell a single agent to disconnect from the region. 3585 /// Tell a single agent to disconnect from the region.
3783 /// </summary> 3586 /// </summary>
@@ -3822,30 +3625,6 @@ namespace OpenSim.Region.Framework.Scenes
3822 } 3625 }
3823 3626
3824 /// <summary> 3627 /// <summary>
3825 /// Tell neighboring regions about this agent
3826 /// When the regions respond with a true value,
3827 /// tell the agents about the region.
3828 ///
3829 /// We have to tell the regions about the agents first otherwise it'll deny them access
3830 ///
3831 /// </summary>
3832 /// <param name="presence"></param>
3833 public void InformClientOfNeighbours(ScenePresence presence)
3834 {
3835 m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
3836 }
3837
3838 /// <summary>
3839 /// Tell a neighboring region about this agent
3840 /// </summary>
3841 /// <param name="presence"></param>
3842 /// <param name="region"></param>
3843 public void InformClientOfNeighbor(ScenePresence presence, RegionInfo region)
3844 {
3845 m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
3846 }
3847
3848 /// <summary>
3849 /// Tries to teleport agent to other region. 3628 /// Tries to teleport agent to other region.
3850 /// </summary> 3629 /// </summary>
3851 /// <param name="remoteClient"></param> 3630 /// <param name="remoteClient"></param>
@@ -3920,16 +3699,12 @@ namespace OpenSim.Region.Framework.Scenes
3920 } 3699 }
3921 3700
3922 if (m_teleportModule != null) 3701 if (m_teleportModule != null)
3923 { 3702 m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
3924 m_teleportModule.RequestTeleportToLocation(sp, regionHandle,
3925 position, lookAt, teleportFlags);
3926 }
3927 else 3703 else
3928 { 3704 {
3929 m_sceneGridService.RequestTeleportToLocation(sp, regionHandle, 3705 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
3930 position, lookAt, teleportFlags); 3706 sp.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator.");
3931 } 3707 }
3932
3933 } 3708 }
3934 } 3709 }
3935 3710
@@ -3955,7 +3730,12 @@ namespace OpenSim.Region.Framework.Scenes
3955 3730
3956 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 3731 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
3957 { 3732 {
3958 m_sceneGridService.CrossAgentToNewRegion(this, agent, isFlying); 3733 if (m_teleportModule != null)
3734 m_teleportModule.Cross(agent, isFlying);
3735 else
3736 {
3737 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
3738 }
3959 } 3739 }
3960 3740
3961 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) 3741 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence)
@@ -3981,35 +3761,6 @@ namespace OpenSim.Region.Framework.Scenes
3981 objectCapacity = objects; 3761 objectCapacity = objects;
3982 } 3762 }
3983 3763
3984 public List<FriendListItem> GetFriendList(string id)
3985 {
3986 UUID avatarID;
3987 if (!UUID.TryParse(id, out avatarID))
3988 return new List<FriendListItem>();
3989
3990 return CommsManager.GetUserFriendList(avatarID);
3991 }
3992
3993 public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
3994 {
3995 return CommsManager.GetFriendRegionInfos(uuids);
3996 }
3997
3998 public virtual void StoreAddFriendship(UUID ownerID, UUID friendID, uint perms)
3999 {
4000 m_sceneGridService.AddNewUserFriend(ownerID, friendID, perms);
4001 }
4002
4003 public virtual void StoreUpdateFriendship(UUID ownerID, UUID friendID, uint perms)
4004 {
4005 m_sceneGridService.UpdateUserFriendPerms(ownerID, friendID, perms);
4006 }
4007
4008 public virtual void StoreRemoveFriendship(UUID ownerID, UUID ExfriendID)
4009 {
4010 m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID);
4011 }
4012
4013 #endregion 3764 #endregion
4014 3765
4015 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) 3766 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set)
@@ -4925,5 +4676,15 @@ namespace OpenSim.Region.Framework.Scenes
4925 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4676 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000)
4926 StartTimer(); 4677 StartTimer();
4927 } 4678 }
4679
4680 public override ISceneObject DeserializeObject(string representation)
4681 {
4682 return SceneObjectSerializer.FromXml2Format(representation);
4683 }
4684
4685 public override bool AllowScriptCrossings
4686 {
4687 get { return m_allowScriptCrossings; }
4688 }
4928 } 4689 }
4929} 4690}
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 1547f9a..aed8640 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -34,7 +34,7 @@ using log4net;
34using Nini.Config; 34using Nini.Config;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Communications.Cache; 37
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 40
@@ -510,5 +510,16 @@ namespace OpenSim.Region.Framework.Scenes
510 510
511 MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); 511 MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback);
512 } 512 }
513
514 public virtual ISceneObject DeserializeObject(string representation)
515 {
516 return null;
517 }
518
519 public virtual bool AllowScriptCrossings
520 {
521 get { return false; }
522 }
523
513 } 524 }
514} 525}
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 6164368..f1813a5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -36,7 +36,6 @@ using log4net;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Client; 37using OpenSim.Framework.Client;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Capabilities; 39using OpenSim.Framework.Capabilities;
41using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Services.Interfaces; 41using 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
@@ -118,17 +115,14 @@ namespace OpenSim.Region.Framework.Scenes
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,378 +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
195 return true;
196 }
197
198
199 protected void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
200 {
201 handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion;
202 if (handlerAvatarCrossingIntoRegion != null)
203 {
204 handlerAvatarCrossingIntoRegion(agentID, position, isFlying);
205 }
206 }
207
208 protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical)
209 {
210 handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
211 if (handlerPrimCrossingIntoRegion != null)
212 {
213 handlerPrimCrossingIntoRegion(primID, position, isPhysical);
214 }
215 }
216
217 protected bool CloseConnection(UUID agentID)
218 {
219 m_log.Debug("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID);
220
221 handlerCloseAgentConnection = OnCloseAgentConnection;
222 if (handlerCloseAgentConnection != null)
223 {
224 return handlerCloseAgentConnection(agentID);
225 }
226
227 return false;
228 }
229
230 protected LandData FetchLandData(uint x, uint y)
231 {
232 handlerGetLandData = OnGetLandData;
233 if (handlerGetLandData != null)
234 {
235 return handlerGetLandData(x, y);
236 }
237 return null;
238 }
239
240 #endregion
241
242 #region Inform Client of Neighbours
243
244 private delegate void InformClientOfNeighbourDelegate(
245 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
246
247 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
248 {
249 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState;
250 icon.EndInvoke(iar);
251 }
252
253 /// <summary>
254 /// Async component for informing client of which neighbours exist
255 /// </summary>
256 /// <remarks>
257 /// This needs to run asynchronously, as a network timeout may block the thread for a long while
258 /// </remarks>
259 /// <param name="remoteClient"></param>
260 /// <param name="a"></param>
261 /// <param name="regionHandle"></param>
262 /// <param name="endPoint"></param>
263 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
264 IPEndPoint endPoint, bool newAgent)
265 {
266 // Let's wait just a little to give time to originating regions to catch up with closing child agents
267 // after a cross here
268 Thread.Sleep(500);
269
270 uint x, y;
271 Utils.LongToUInts(reg.RegionHandle, out x, out y);
272 x = x / Constants.RegionSize;
273 y = y / Constants.RegionSize;
274 m_log.Info("[INTERGRID]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")");
275
276 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
277 + "/CAPS/" + a.CapsPath + "0000/";
278
279 string reason = String.Empty;
280
281
282 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason);
283
284 if (regionAccepted && newAgent)
285 {
286 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
287 if (eq != null)
288 {
289 #region IP Translation for NAT
290 IClientIPEndpoint ipepClient;
291 if (avatar.ClientView.TryGet(out ipepClient))
292 {
293 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
294 }
295 #endregion
296
297 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
298 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
299 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}",
300 capsPath, avatar.UUID, avatar.Scene.RegionInfo.RegionName);
301 }
302 else
303 {
304 avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
305 // TODO: make Event Queue disablable!
306 }
307
308 m_log.Info("[INTERGRID]: Completed inform client about neighbour " + endPoint.ToString());
309
310 }
311
312 }
313
314 public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
315 {
316 Border[] northBorders = pScene.NorthBorders.ToArray();
317 Border[] southBorders = pScene.SouthBorders.ToArray();
318 Border[] eastBorders = pScene.EastBorders.ToArray();
319 Border[] westBorders = pScene.WestBorders.ToArray();
320
321 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
322 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
323 {
324 return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
325 }
326 else
327 {
328 Vector2 extent = Vector2.Zero;
329 for (int i = 0; i < eastBorders.Length; i++)
330 {
331 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
332 }
333 for (int i = 0; i < northBorders.Length; i++)
334 {
335 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
336 }
337
338 // Loss of fraction on purpose
339 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
340 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
341
342 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
343 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
344
345 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
346 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
347
348 List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
349 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
350
351 return neighbours;
352 }
353 }
354
355 /// <summary>
356 /// This informs all neighboring regions about agent "avatar".
357 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
358 /// </summary>
359 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
360 {
361 List<GridRegion> neighbours = new List<GridRegion>();
362
363 if (m_regionInfo != null)
364 {
365 neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
366 }
367 else
368 {
369 m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?");
370 }
371
372 /// We need to find the difference between the new regions where there are no child agents
373 /// and the regions where there are already child agents. We only send notification to the former.
374 List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
375 neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too
376 List<ulong> previousRegionNeighbourHandles ;
377
378 if (avatar.Scene.CapsModule != null)
379 {
380 previousRegionNeighbourHandles =
381 new List<ulong>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys);
382 }
383 else
384 {
385 previousRegionNeighbourHandles = new List<ulong>();
386 }
387
388 List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
389 List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
390
391 //Dump("Current Neighbors", neighbourHandles);
392 //Dump("Previous Neighbours", previousRegionNeighbourHandles);
393 //Dump("New Neighbours", newRegions);
394 //Dump("Old Neighbours", oldRegions);
395
396 /// Update the scene presence's known regions here on this region
397 avatar.DropOldNeighbours(oldRegions);
398
399 /// Collect as many seeds as possible
400 Dictionary<ulong, string> seeds;
401 if (avatar.Scene.CapsModule != null)
402 seeds
403 = new Dictionary<ulong, string>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID));
404 else
405 seeds = new Dictionary<ulong, string>();
406
407 //m_log.Debug(" !!! No. of seeds: " + seeds.Count);
408 if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle))
409 seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath);
410
411 /// Create the necessary child agents
412 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
413 foreach (GridRegion neighbour in neighbours)
414 {
415 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
416 {
417
418 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
419 agent.BaseFolder = UUID.Zero;
420 agent.InventoryFolder = UUID.Zero;
421 agent.startpos = new Vector3(128, 128, 70);
422 agent.child = true;
423
424 if (newRegions.Contains(neighbour.RegionHandle))
425 {
426 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
427 avatar.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
428 seeds.Add(neighbour.RegionHandle, agent.CapsPath);
429 }
430 else
431 agent.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, neighbour.RegionHandle);
432
433 cagents.Add(agent);
434 }
435 }
436
437 /// Update all child agent with everyone's seeds
438 foreach (AgentCircuitData a in cagents)
439 {
440 a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
441 }
442
443 if (avatar.Scene.CapsModule != null)
444 {
445 // These two are the same thing!
446 avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds);
447 }
448 avatar.KnownRegions = seeds;
449 //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
450 //avatar.DumpKnownRegions();
451
452 bool newAgent = false;
453 int count = 0;
454 foreach (GridRegion neighbour in neighbours)
455 {
456 // Don't do it if there's already an agent in that region
457 if (newRegions.Contains(neighbour.RegionHandle))
458 newAgent = true;
459 else
460 newAgent = false;
461
462 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
463 {
464 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
465 try
466 {
467 d.BeginInvoke(avatar, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
468 InformClientOfNeighbourCompleted,
469 d);
470 }
471
472 catch (ArgumentOutOfRangeException)
473 {
474 m_log.ErrorFormat(
475 "[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}).",
476 neighbour.ExternalHostName,
477 neighbour.RegionHandle,
478 neighbour.RegionLocX,
479 neighbour.RegionLocY);
480 }
481 catch (Exception e)
482 {
483 m_log.ErrorFormat(
484 "[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
485 neighbour.ExternalHostName,
486 neighbour.RegionHandle,
487 neighbour.RegionLocX,
488 neighbour.RegionLocY,
489 e);
490
491 // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
492 // since I don't know what will happen if we just let the client continue
493
494 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
495 // throw e;
496
497 }
498 }
499 count++;
500 }
501 }
502
503 /// <summary>
504 /// This informs a single neighboring region about agent "avatar".
505 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
506 /// </summary>
507 public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
508 {
509 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
510 agent.BaseFolder = UUID.Zero;
511 agent.InventoryFolder = UUID.Zero;
512 agent.startpos = new Vector3(128, 128, 70);
513 agent.child = true;
514
515 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
516 d.BeginInvoke(avatar, agent, region, region.ExternalEndPoint, true,
517 InformClientOfNeighbourCompleted,
518 d);
519 }
520
521 #endregion
522
523 public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle); 145 public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle);
524 146
525 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) 147 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar)
@@ -593,7 +215,10 @@ namespace OpenSim.Region.Framework.Scenes
593 try 215 try
594 { 216 {
595 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); 217 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData);
596 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);
597 } 222 }
598 catch 223 catch
599 { 224 {
@@ -653,7 +278,10 @@ namespace OpenSim.Region.Framework.Scenes
653 // 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.
654 279
655 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); 280 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
656 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);
657 } 285 }
658 286
659 private void SendCloseChildAgentCompleted(IAsyncResult iar) 287 private void SendCloseChildAgentCompleted(IAsyncResult iar)
@@ -672,822 +300,11 @@ namespace OpenSim.Region.Framework.Scenes
672 d); 300 d);
673 } 301 }
674 } 302 }
675 303
676
677 /// <summary>
678 /// Try to teleport an agent to a new region.
679 /// </summary>
680 /// <param name="remoteClient"></param>
681 /// <param name="RegionHandle"></param>
682 /// <param name="position"></param>
683 /// <param name="lookAt"></param>
684 /// <param name="flags"></param>
685 public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
686 Vector3 lookAt, uint teleportFlags)
687 {
688 if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
689 return;
690
691 bool destRegionUp = true;
692
693 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
694
695 // Reset animations; the viewer does that in teleports.
696 avatar.Animator.ResetAnimations();
697
698 if (regionHandle == m_regionInfo.RegionHandle)
699 {
700 m_log.DebugFormat(
701 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}",
702 position, m_regionInfo.RegionName);
703
704 // Teleport within the same region
705 if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
706 {
707 Vector3 emergencyPos = new Vector3(128, 128, 128);
708
709 m_log.WarnFormat(
710 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
711 position, avatar.Name, avatar.UUID, emergencyPos);
712 position = emergencyPos;
713 }
714
715 // TODO: Get proper AVG Height
716 float localAVHeight = 1.56f;
717 float posZLimit = 22;
718
719 // TODO: Check other Scene HeightField
720 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <=(int)Constants.RegionSize)
721 {
722 posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
723 }
724
725 float newPosZ = posZLimit + localAVHeight;
726 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
727 {
728 position.Z = newPosZ;
729 }
730
731 // Only send this if the event queue is null
732 if (eq == null)
733 avatar.ControllingClient.SendTeleportLocationStart();
734
735 avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
736 avatar.Teleport(position);
737 }
738 else
739 {
740 uint x = 0, y = 0;
741 Utils.LongToUInts(regionHandle, out x, out y);
742 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
743
744 if (reg != null)
745 {
746 m_log.DebugFormat(
747 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation to {0} in {1}",
748 position, reg.RegionName);
749
750 if (eq == null)
751 avatar.ControllingClient.SendTeleportLocationStart();
752
753 // Let's do DNS resolution only once in this process, please!
754 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
755 // it's actually doing a lot of work.
756 IPEndPoint endPoint = reg.ExternalEndPoint;
757 if (endPoint.Address == null)
758 {
759 // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
760 destRegionUp = false;
761 }
762
763 if (destRegionUp)
764 {
765 uint newRegionX = (uint)(reg.RegionHandle >> 40);
766 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
767 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
768 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
769
770 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
771 // both regions
772 if (avatar.ParentID != (uint)0)
773 avatar.StandUp();
774
775 if (!avatar.ValidateAttachments())
776 {
777 avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
778 return;
779 }
780
781 // the avatar.Close below will clear the child region list. We need this below for (possibly)
782 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
783 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
784 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
785 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
786 // once we reach here...
787 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
788
789 string capsPath = String.Empty;
790 AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
791 agentCircuit.BaseFolder = UUID.Zero;
792 agentCircuit.InventoryFolder = UUID.Zero;
793 agentCircuit.startpos = position;
794 agentCircuit.child = true;
795
796 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
797 {
798 // brand new agent, let's create a new caps seed
799 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
800 }
801
802 string reason = String.Empty;
803
804 // Let's create an agent there if one doesn't exist yet.
805 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
806 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
807 {
808 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
809 reason));
810 return;
811 }
812
813 // OK, it got this agent. Let's close some child agents
814 avatar.CloseChildAgents(newRegionX, newRegionY);
815
816 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
817 {
818 #region IP Translation for NAT
819 IClientIPEndpoint ipepClient;
820 if (avatar.ClientView.TryGet(out ipepClient))
821 {
822 capsPath
823 = "http://"
824 + NetworkUtil.GetHostFor(ipepClient.EndPoint, reg.ExternalHostName)
825 + ":"
826 + reg.HttpPort
827 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
828 }
829 else
830 {
831 capsPath
832 = "http://"
833 + reg.ExternalHostName
834 + ":"
835 + reg.HttpPort
836 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
837 }
838 #endregion
839
840 if (eq != null)
841 {
842 #region IP Translation for NAT
843 // Uses ipepClient above
844 if (avatar.ClientView.TryGet(out ipepClient))
845 {
846 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
847 }
848 #endregion
849
850 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
851
852 // ES makes the client send a UseCircuitCode message to the destination,
853 // which triggers a bunch of things there.
854 // So let's wait
855 Thread.Sleep(2000);
856
857 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
858 }
859 else
860 {
861 avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
862 }
863 }
864 else
865 {
866 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
867 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
868 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
869 }
870
871 // Expect avatar crossing is a heavy-duty function at the destination.
872 // That is where MakeRoot is called, which fetches appearance and inventory.
873 // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates.
874 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
875 // position, false);
876
877 //{
878 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
879 // // We should close that agent we just created over at destination...
880 // List<ulong> lst = new List<ulong>();
881 // lst.Add(reg.RegionHandle);
882 // SendCloseChildAgentAsync(avatar.UUID, lst);
883 // return;
884 //}
885
886 SetInTransit(avatar.UUID);
887 // Let's send a full update of the agent. This is a synchronous call.
888 AgentData agent = new AgentData();
889 avatar.CopyTo(agent);
890 agent.Position = position;
891 agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
892 "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
893
894 m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
895
896 m_log.DebugFormat(
897 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID);
898
899
900 if (eq != null)
901 {
902 eq.TeleportFinishEvent(reg.RegionHandle, 13, endPoint,
903 0, teleportFlags, capsPath, avatar.UUID);
904 }
905 else
906 {
907 avatar.ControllingClient.SendRegionTeleport(reg.RegionHandle, 13, endPoint, 4,
908 teleportFlags, capsPath);
909 }
910
911 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
912 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
913 // that the client contacted the destination before we send the attachments and close things here.
914 if (!WaitForCallback(avatar.UUID))
915 {
916 // Client never contacted destination. Let's restore everything back
917 avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
918
919 ResetFromTransit(avatar.UUID);
920
921 // Yikes! We should just have a ref to scene here.
922 avatar.Scene.InformClientOfNeighbours(avatar);
923
924 // Finally, kill the agent we just created at the destination.
925 m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
926
927 return;
928 }
929
930 // Can't go back from here
931 if (KiPrimitive != null)
932 {
933 KiPrimitive(avatar.LocalId);
934 }
935
936 avatar.MakeChildAgent();
937
938 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
939 avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
940
941 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
942
943 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
944 {
945 Thread.Sleep(5000);
946 avatar.Close();
947 CloseConnection(avatar.UUID);
948 }
949 else
950 // now we have a child agent in this region.
951 avatar.Reset();
952
953
954 // if (teleport success) // seems to be always success here
955 // the user may change their profile information in other region,
956 // so the userinfo in UserProfileCache is not reliable any more, delete it
957 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID))
958 {
959 m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
960 m_log.DebugFormat(
961 "[SCENE COMMUNICATION SERVICE]: User {0} is going to another region, profile cache removed",
962 avatar.UUID);
963 }
964 }
965 else
966 {
967 avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
968 }
969 }
970 else
971 {
972 // TP to a place that doesn't exist (anymore)
973 // Inform the viewer about that
974 avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
975
976 // and set the map-tile to '(Offline)'
977 uint regX, regY;
978 Utils.LongToUInts(regionHandle, out regX, out regY);
979
980 MapBlockData block = new MapBlockData();
981 block.X = (ushort)(regX / Constants.RegionSize);
982 block.Y = (ushort)(regY / Constants.RegionSize);
983 block.Access = 254; // == not there
984
985 List<MapBlockData> blocks = new List<MapBlockData>();
986 blocks.Add(block);
987 avatar.ControllingClient.SendMapBlock(blocks, 0);
988 }
989 }
990 }
991
992 protected bool IsOutsideRegion(Scene s, Vector3 pos)
993 {
994
995 if (s.TestBorderCross(pos,Cardinals.N))
996 return true;
997 if (s.TestBorderCross(pos, Cardinals.S))
998 return true;
999 if (s.TestBorderCross(pos, Cardinals.E))
1000 return true;
1001 if (s.TestBorderCross(pos, Cardinals.W))
1002 return true;
1003
1004 return false;
1005 }
1006
1007 public bool WaitForCallback(UUID id)
1008 {
1009 int count = 200;
1010 while (m_agentsInTransit.Contains(id) && count-- > 0)
1011 {
1012 //m_log.Debug(" >>> Waiting... " + count);
1013 Thread.Sleep(100);
1014 }
1015
1016 if (count > 0)
1017 return true;
1018 else
1019 return false;
1020 }
1021
1022 public bool ReleaseAgent(UUID id)
1023 {
1024 //m_log.Debug(" >>> ReleaseAgent called <<< ");
1025 return ResetFromTransit(id);
1026 }
1027
1028 public void SetInTransit(UUID id)
1029 {
1030 lock (m_agentsInTransit)
1031 {
1032 if (!m_agentsInTransit.Contains(id))
1033 m_agentsInTransit.Add(id);
1034 }
1035 }
1036
1037 protected bool ResetFromTransit(UUID id)
1038 {
1039 lock (m_agentsInTransit)
1040 {
1041 if (m_agentsInTransit.Contains(id))
1042 {
1043 m_agentsInTransit.Remove(id);
1044 return true;
1045 }
1046 }
1047 return false;
1048 }
1049
1050 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1051 {
1052 List<ulong> handles = new List<ulong>();
1053 foreach (GridRegion reg in neighbours)
1054 {
1055 handles.Add(reg.RegionHandle);
1056 }
1057 return handles;
1058 }
1059
1060 private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1061 {
1062 return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); });
1063 }
1064
1065// private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1066// {
1067// return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); });
1068// }
1069
1070 private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1071 {
1072 return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
1073 }
1074
1075 public void CrossAgentToNewRegion(Scene scene, ScenePresence agent, bool isFlying)
1076 {
1077 Vector3 pos = agent.AbsolutePosition;
1078 Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z);
1079 uint neighbourx = m_regionInfo.RegionLocX;
1080 uint neighboury = m_regionInfo.RegionLocY;
1081 const float boundaryDistance = 1.7f;
1082 Vector3 northCross = new Vector3(0,boundaryDistance, 0);
1083 Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0);
1084 Vector3 eastCross = new Vector3(boundaryDistance, 0, 0);
1085 Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0);
1086
1087 // distance to edge that will trigger crossing
1088
1089
1090 // distance into new region to place avatar
1091 const float enterDistance = 0.5f;
1092
1093 if (scene.TestBorderCross(pos + westCross, Cardinals.W))
1094 {
1095 if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1096 {
1097 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1098 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1099 }
1100 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1101 {
1102 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1103 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1104 {
1105 neighboury--;
1106 newpos.Y = Constants.RegionSize - enterDistance;
1107 }
1108 else
1109 {
1110 neighboury = b.TriggerRegionY;
1111 neighbourx = b.TriggerRegionX;
1112
1113 Vector3 newposition = pos;
1114 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1115 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1116 agent.ControllingClient.SendAgentAlertMessage(
1117 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1118 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1119 return;
1120 }
1121 }
1122
1123 Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W);
1124 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1125 {
1126 neighbourx--;
1127 newpos.X = Constants.RegionSize - enterDistance;
1128 }
1129 else
1130 {
1131 neighboury = ba.TriggerRegionY;
1132 neighbourx = ba.TriggerRegionX;
1133
1134
1135 Vector3 newposition = pos;
1136 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1137 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1138 agent.ControllingClient.SendAgentAlertMessage(
1139 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1140 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1141
1142
1143 return;
1144 }
1145
1146 }
1147 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E))
1148 {
1149 Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E);
1150 neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1151 newpos.X = enterDistance;
1152
1153 if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1154 {
1155 Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1156 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1157 {
1158 neighboury--;
1159 newpos.Y = Constants.RegionSize - enterDistance;
1160 }
1161 else
1162 {
1163 neighboury = ba.TriggerRegionY;
1164 neighbourx = ba.TriggerRegionX;
1165 Vector3 newposition = pos;
1166 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1167 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1168 agent.ControllingClient.SendAgentAlertMessage(
1169 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1170 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1171 return;
1172 }
1173 }
1174 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1175 {
1176 Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1177 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
1178 newpos.Y = enterDistance;
1179 }
1180
1181
1182 }
1183 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1184 {
1185 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1186 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1187 {
1188 neighboury--;
1189 newpos.Y = Constants.RegionSize - enterDistance;
1190 }
1191 else
1192 {
1193 neighboury = b.TriggerRegionY;
1194 neighbourx = b.TriggerRegionX;
1195 Vector3 newposition = pos;
1196 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1197 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1198 agent.ControllingClient.SendAgentAlertMessage(
1199 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1200 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1201 return;
1202 }
1203 }
1204 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1205 {
1206
1207 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1208 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1209 newpos.Y = enterDistance;
1210 }
1211
1212 /*
1213
1214 if (pos.X < boundaryDistance) //West
1215 {
1216 neighbourx--;
1217 newpos.X = Constants.RegionSize - enterDistance;
1218 }
1219 else if (pos.X > Constants.RegionSize - boundaryDistance) // East
1220 {
1221 neighbourx++;
1222 newpos.X = enterDistance;
1223 }
1224
1225 if (pos.Y < boundaryDistance) // South
1226 {
1227 neighboury--;
1228 newpos.Y = Constants.RegionSize - enterDistance;
1229 }
1230 else if (pos.Y > Constants.RegionSize - boundaryDistance) // North
1231 {
1232 neighboury++;
1233 newpos.Y = enterDistance;
1234 }
1235 */
1236
1237 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
1238 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d);
1239 }
1240
1241 public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY,
1242 Vector3 position,
1243 Scene initiatingScene);
1244
1245 public void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
1246 Scene initiatingScene)
1247 {
1248
1249 // This assumes that we know what our neighbors are.
1250
1251 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync;
1252 d.BeginInvoke(agent,regionX,regionY,position,initiatingScene,
1253 InformClientToInitiateTeleportToLocationCompleted,
1254 d);
1255 }
1256
1257 public void InformClientToInitiateTeleportToLocationAsync(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
1258 Scene initiatingScene)
1259 {
1260 Thread.Sleep(10000);
1261 IMessageTransferModule im = initiatingScene.RequestModuleInterface<IMessageTransferModule>();
1262 if (im != null)
1263 {
1264 UUID gotoLocation = Util.BuildFakeParcelID(
1265 Util.UIntsToLong(
1266 (regionX *
1267 (uint)Constants.RegionSize),
1268 (regionY *
1269 (uint)Constants.RegionSize)),
1270 (uint)(int)position.X,
1271 (uint)(int)position.Y,
1272 (uint)(int)position.Z);
1273 GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero,
1274 "Region", agent.UUID,
1275 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
1276 "", gotoLocation, false, new Vector3(127, 0, 0),
1277 new Byte[0]);
1278 im.SendInstantMessage(m, delegate(bool success)
1279 {
1280 m_log.DebugFormat("[CLIENT]: Client Initiating Teleport sending IM success = {0}", success);
1281 });
1282
1283 }
1284 }
1285
1286 private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar)
1287 {
1288 InformClientToInitateTeleportToLocationDelegate icon =
1289 (InformClientToInitateTeleportToLocationDelegate) iar.AsyncState;
1290 icon.EndInvoke(iar);
1291 }
1292
1293 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying);
1294
1295 /// <summary>
1296 /// This Closes child agents on neighboring regions
1297 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
1298 /// </summary>
1299 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying)
1300 {
1301 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
1302
1303 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
1304
1305 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
1306 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1307
1308 if (neighbourRegion != null && agent.ValidateAttachments())
1309 {
1310 pos = pos + (agent.Velocity);
1311
1312 //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
1313 //if (userInfo != null)
1314 //{
1315 // userInfo.DropInventory();
1316 //}
1317 //else
1318 //{
1319 // m_log.WarnFormat("[SCENE COMM]: No cached user info found for {0} {1} on leaving region {2}",
1320 // agent.Name, agent.UUID, agent.Scene.RegionInfo.RegionName);
1321 //}
1322
1323 //bool crossingSuccessful =
1324 // CrossToNeighbouringRegion(neighbourHandle, agent.ControllingClient.AgentId, pos,
1325 //isFlying);
1326
1327 SetInTransit(agent.UUID);
1328 AgentData cAgent = new AgentData();
1329 agent.CopyTo(cAgent);
1330 cAgent.Position = pos;
1331 if (isFlying)
1332 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1333 cAgent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
1334 "/agent/" + agent.UUID.ToString() + "/" + agent.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
1335
1336 m_interregionCommsOut.SendChildAgentUpdate(neighbourHandle, cAgent);
1337
1338 // Next, let's close the child agent connections that are too far away.
1339 agent.CloseChildAgents(neighbourx, neighboury);
1340
1341 //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
1342 agent.ControllingClient.RequestClientInfo();
1343
1344 //m_log.Debug("BEFORE CROSS");
1345 //Scene.DumpChildrenSeeds(UUID);
1346 //DumpKnownRegions();
1347 string agentcaps;
1348 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
1349 {
1350 m_log.ErrorFormat("[SCENE COMM]: No CAPS information for region handle {0}, exiting CrossToNewRegion.",
1351 neighbourRegion.RegionHandle);
1352 return agent;
1353 }
1354 // TODO Should construct this behind a method
1355 string capsPath =
1356 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
1357 + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/";
1358
1359 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
1360
1361 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
1362 if (eq != null)
1363 {
1364 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1365 capsPath, agent.UUID, agent.ControllingClient.SessionId);
1366 }
1367 else
1368 {
1369 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1370 capsPath);
1371 }
1372
1373 if (!WaitForCallback(agent.UUID))
1374 {
1375 ResetFromTransit(agent.UUID);
1376
1377 // Yikes! We should just have a ref to scene here.
1378 agent.Scene.InformClientOfNeighbours(agent);
1379
1380 return agent;
1381 }
1382
1383 agent.MakeChildAgent();
1384 // now we have a child agent in this region. Request all interesting data about other (root) agents
1385 agent.SendInitialFullUpdateToAllClients();
1386
1387 agent.CrossAttachmentsIntoNewRegion(neighbourHandle, true);
1388
1389 // m_scene.SendKillObject(m_localId);
1390
1391 agent.Scene.NotifyMyCoarseLocationChange();
1392 // the user may change their profile information in other region,
1393 // so the userinfo in UserProfileCache is not reliable any more, delete it
1394 if (agent.Scene.NeedSceneCacheClear(agent.UUID))
1395 {
1396 agent.Scene.CommsManager.UserProfileCacheService.RemoveUser(agent.UUID);
1397 m_log.DebugFormat(
1398 "[SCENE COMM]: User {0} is going to another region, profile cache removed", agent.UUID);
1399 }
1400 }
1401
1402 //m_log.Debug("AFTER CROSS");
1403 //Scene.DumpChildrenSeeds(UUID);
1404 //DumpKnownRegions();
1405 return agent;
1406 }
1407
1408 private void CrossAgentToNewRegionCompleted(IAsyncResult iar)
1409 {
1410 CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState;
1411 ScenePresence agent = icon.EndInvoke(iar);
1412
1413 // If the cross was successful, this agent is a child agent
1414 if (agent.IsChildAgent)
1415 {
1416 agent.Reset();
1417 }
1418 else // Not successful
1419 {
1420 //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
1421 //if (userInfo != null)
1422 //{
1423 // userInfo.FetchInventory();
1424 //}
1425 agent.RestoreInCurrentScene();
1426 }
1427 // In any case
1428 agent.NotInTransit();
1429
1430 //m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
1431 }
1432
1433
1434 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
1435 {
1436 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
1437 }
1438
1439 // deprecated as of 2008-08-27
1440 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
1441 {
1442 m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
1443 }
1444
1445 public void ClearUserAgent(UUID avatarID)
1446 {
1447 m_commsProvider.UserService.ClearUserAgent(avatarID);
1448 }
1449
1450 public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
1451 {
1452 m_commsProvider.AddNewUserFriend(friendlistowner, friend, perms);
1453 }
1454
1455 public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
1456 {
1457 m_commsProvider.UpdateUserFriendPerms(friendlistowner, friend, perms);
1458 }
1459
1460 public void RemoveUserFriend(UUID friendlistowner, UUID friend)
1461 {
1462 m_commsProvider.RemoveUserFriend(friendlistowner, friend);
1463 }
1464
1465 public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
1466 {
1467 return m_commsProvider.GetUserFriendList(friendlistowner);
1468 }
1469
1470 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
1471 {
1472 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
1473 }
1474
1475 public List<GridRegion> RequestNamedRegions(string name, int maxNumber) 304 public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
1476 { 305 {
1477 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); 306 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
1478 } 307 }
1479 308
1480 //private void Dump(string msg, List<ulong> handles)
1481 //{
1482 // m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg);
1483 // foreach (ulong handle in handles)
1484 // {
1485 // uint x, y;
1486 // Utils.LongToUInts(handle, out x, out y);
1487 // x = x / Constants.RegionSize;
1488 // y = y / Constants.RegionSize;
1489 // m_log.InfoFormat("({0}, {1})", x, y);
1490 // }
1491 //}
1492 } 309 }
1493} 310}
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 1ac061a..7bd4329 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -35,6 +35,7 @@ using log4net;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes.Types; 36using OpenSim.Region.Framework.Scenes.Types;
37using OpenSim.Region.Physics.Manager; 37using OpenSim.Region.Physics.Manager;
38using OpenSim.Region.Framework.Interfaces;
38 39
39namespace OpenSim.Region.Framework.Scenes 40namespace OpenSim.Region.Framework.Scenes
40{ 41{
@@ -508,33 +509,32 @@ namespace OpenSim.Region.Framework.Scenes
508 /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> 509 /// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
509 public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) 510 public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
510 { 511 {
511 SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, 512 IInventoryAccessModule invAccess = m_parentScene.RequestModuleInterface<IInventoryAccessModule>();
512 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, 513 if (invAccess != null)
513 false, false, remoteClient.AgentId, true);
514
515 if (objatt != null)
516 { 514 {
517 bool tainted = false; 515 SceneObjectGroup objatt = invAccess.RezObject(remoteClient,
518 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) 516 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
519 tainted = true; 517 false, false, remoteClient.AgentId, true);
518
520 519
521 if (AttachObject( 520 if (objatt != null)
522 remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false))
523 { 521 {
522 bool tainted = false;
523 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
524 tainted = true;
525
526 AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
524 objatt.ScheduleGroupForFullUpdate(); 527 objatt.ScheduleGroupForFullUpdate();
525 if (tainted) 528 if (tainted)
526 objatt.HasGroupChanged = true; 529 objatt.HasGroupChanged = true;
527 530
528 // Fire after attach, so we don't get messy perms dialogs 531 // Fire after attach, so we don't get messy perms dialogs
529 // 3 == AttachedRez 532 // 3 == AttachedRez
530 objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); 533 objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3);
531
532 // Do this last so that event listeners have access to all the effects of the attachment
533 m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
534 } 534 }
535 return objatt;
535 } 536 }
536 537 return null;
537 return objatt;
538 } 538 }
539 539
540 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. 540 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index c2e3370..6395d98 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -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/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 298ede9..d0de513 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -34,7 +34,6 @@ using System.Reflection;
34using OpenMetaverse; 34using OpenMetaverse;
35using log4net; 35using log4net;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Communications.Cache;
38using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes.Scripting; 38using OpenSim.Region.Framework.Scenes.Scripting;
40 39
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index bcf22c3..29f607b 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -33,12 +33,12 @@ using OpenMetaverse;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Client; 35using OpenSim.Framework.Client;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes.Animation; 37using OpenSim.Region.Framework.Scenes.Animation;
39using OpenSim.Region.Framework.Scenes.Types; 38using OpenSim.Region.Framework.Scenes.Types;
40using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.Physics.Manager;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenSim.Services.Interfaces;
42 42
43namespace OpenSim.Region.Framework.Scenes 43namespace OpenSim.Region.Framework.Scenes
44{ 44{
@@ -217,7 +217,12 @@ namespace OpenSim.Region.Framework.Scenes
217 // Agent's Draw distance. 217 // Agent's Draw distance.
218 protected float m_DrawDistance; 218 protected float m_DrawDistance;
219 219
220 protected AvatarAppearance m_appearance; 220 protected AvatarAppearance m_appearance;
221
222 public List<SceneObjectGroup> Attachments
223 {
224 get { return m_attachments; }
225 }
221 226
222 // neighbouring regions we have enabled a child agent in 227 // neighbouring regions we have enabled a child agent in
223 // holds the seed cap for the child agent in that region 228 // holds the seed cap for the child agent in that region
@@ -246,6 +251,8 @@ namespace OpenSim.Region.Framework.Scenes
246 251
247 // For teleports and crossings callbacks 252 // For teleports and crossings callbacks
248 string m_callbackURI; 253 string m_callbackURI;
254 UUID m_originRegionID;
255
249 ulong m_rootRegionHandle; 256 ulong m_rootRegionHandle;
250 257
251 /// <value> 258 /// <value>
@@ -1073,6 +1080,8 @@ namespace OpenSim.Region.Framework.Scenes
1073 /// </summary> 1080 /// </summary>
1074 public void CompleteMovement() 1081 public void CompleteMovement()
1075 { 1082 {
1083 //m_log.Debug("[SCENE PRESENCE]: CompleteMovement");
1084
1076 Vector3 look = Velocity; 1085 Vector3 look = Velocity;
1077 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1086 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1078 { 1087 {
@@ -1097,7 +1106,7 @@ namespace OpenSim.Region.Framework.Scenes
1097 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1106 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1098 { 1107 {
1099 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1108 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
1100 Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); 1109 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1101 m_callbackURI = null; 1110 m_callbackURI = null;
1102 } 1111 }
1103 1112
@@ -1106,6 +1115,16 @@ namespace OpenSim.Region.Framework.Scenes
1106 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 1115 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
1107 SendInitialData(); 1116 SendInitialData();
1108 1117
1118 // Create child agents in neighbouring regions
1119 if (!m_isChildAgent)
1120 {
1121 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1122 if (m_agentTransfer != null)
1123 m_agentTransfer.EnableChildAgents(this);
1124 else
1125 m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active");
1126 }
1127
1109 } 1128 }
1110 1129
1111 /// <summary> 1130 /// <summary>
@@ -2164,6 +2183,7 @@ namespace OpenSim.Region.Framework.Scenes
2164 { 2183 {
2165 if (m_isChildAgent) 2184 if (m_isChildAgent)
2166 { 2185 {
2186 // WHAT???
2167 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); 2187 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!");
2168 2188
2169 // we have to reset the user's child agent connections. 2189 // we have to reset the user's child agent connections.
@@ -2187,7 +2207,9 @@ namespace OpenSim.Region.Framework.Scenes
2187 2207
2188 if (m_scene.SceneGridService != null) 2208 if (m_scene.SceneGridService != null)
2189 { 2209 {
2190 m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); 2210 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
2211 if (m_agentTransfer != null)
2212 m_agentTransfer.EnableChildAgents(this);
2191 } 2213 }
2192 2214
2193 return; 2215 return;
@@ -2484,14 +2506,9 @@ namespace OpenSim.Region.Framework.Scenes
2484 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2506 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
2485 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); 2507 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot));
2486 2508
2487 if (!m_isChildAgent)
2488 {
2489 m_scene.InformClientOfNeighbours(this);
2490 }
2491
2492 SendInitialFullUpdateToAllClients(); 2509 SendInitialFullUpdateToAllClients();
2493 SendAppearanceToAllOtherAgents(); 2510 SendAppearanceToAllOtherAgents();
2494 } 2511 }
2495 2512
2496 /// <summary> 2513 /// <summary>
2497 /// Tell the client for this scene presence what items it should be wearing now 2514 /// Tell the client for this scene presence what items it should be wearing now
@@ -2571,14 +2588,19 @@ namespace OpenSim.Region.Framework.Scenes
2571 } 2588 }
2572 } 2589 }
2573 } 2590 }
2591
2574 } 2592 }
2575 2593
2594
2576 #endregion Bake Cache Check 2595 #endregion Bake Cache Check
2577 2596
2578 m_appearance.SetAppearance(textureEntry, visualParams); 2597 m_appearance.SetAppearance(textureEntry, visualParams);
2579 if (m_appearance.AvatarHeight > 0) 2598 if (m_appearance.AvatarHeight > 0)
2580 SetHeight(m_appearance.AvatarHeight); 2599 SetHeight(m_appearance.AvatarHeight);
2581 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2600
2601 // This is not needed, because only the transient data changed
2602 //AvatarData adata = new AvatarData(m_appearance);
2603 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2582 2604
2583 SendAppearanceToAllOtherAgents(); 2605 SendAppearanceToAllOtherAgents();
2584 if (!m_startAnimationSet) 2606 if (!m_startAnimationSet)
@@ -2598,7 +2620,8 @@ namespace OpenSim.Region.Framework.Scenes
2598 public void SetWearable(int wearableId, AvatarWearable wearable) 2620 public void SetWearable(int wearableId, AvatarWearable wearable)
2599 { 2621 {
2600 m_appearance.SetWearable(wearableId, wearable); 2622 m_appearance.SetWearable(wearableId, wearable);
2601 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2623 AvatarData adata = new AvatarData(m_appearance);
2624 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2602 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); 2625 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2603 } 2626 }
2604 2627
@@ -2882,11 +2905,14 @@ namespace OpenSim.Region.Framework.Scenes
2882 // For now, assign god level 200 to anyone 2905 // For now, assign god level 200 to anyone
2883 // who is granted god powers, but has no god level set. 2906 // who is granted god powers, but has no god level set.
2884 // 2907 //
2885 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); 2908 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID);
2886 if (profile.UserProfile.GodLevel > 0) 2909 if (account != null)
2887 m_godlevel = profile.UserProfile.GodLevel; 2910 {
2888 else 2911 if (account.UserLevel > 0)
2889 m_godlevel = 200; 2912 m_godlevel = account.UserLevel;
2913 else
2914 m_godlevel = 200;
2915 }
2890 } 2916 }
2891 else 2917 else
2892 { 2918 {
@@ -2952,7 +2978,7 @@ namespace OpenSim.Region.Framework.Scenes
2952 public void CopyTo(AgentData cAgent) 2978 public void CopyTo(AgentData cAgent)
2953 { 2979 {
2954 cAgent.AgentID = UUID; 2980 cAgent.AgentID = UUID;
2955 cAgent.RegionHandle = m_rootRegionHandle; 2981 cAgent.RegionID = Scene.RegionInfo.RegionID;
2956 2982
2957 cAgent.Position = AbsolutePosition; 2983 cAgent.Position = AbsolutePosition;
2958 cAgent.Velocity = m_velocity; 2984 cAgent.Velocity = m_velocity;
@@ -3051,7 +3077,7 @@ namespace OpenSim.Region.Framework.Scenes
3051 3077
3052 public void CopyFrom(AgentData cAgent) 3078 public void CopyFrom(AgentData cAgent)
3053 { 3079 {
3054 m_rootRegionHandle = cAgent.RegionHandle; 3080 m_originRegionID = cAgent.RegionID;
3055 3081
3056 m_callbackURI = cAgent.CallbackURI; 3082 m_callbackURI = cAgent.CallbackURI;
3057 3083
@@ -3410,36 +3436,6 @@ namespace OpenSim.Region.Framework.Scenes
3410 } 3436 }
3411 } 3437 }
3412 3438
3413 public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent)
3414 {
3415 lock (m_attachments)
3416 {
3417 // Validate
3418 foreach (SceneObjectGroup gobj in m_attachments)
3419 {
3420 if (gobj == null || gobj.IsDeleted)
3421 return false;
3422 }
3423
3424 foreach (SceneObjectGroup gobj in m_attachments)
3425 {
3426 // If the prim group is null then something must have happened to it!
3427 if (gobj != null && gobj.RootPart != null)
3428 {
3429 // Set the parent localID to 0 so it transfers over properly.
3430 gobj.RootPart.SetParentLocalId(0);
3431 gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
3432 gobj.RootPart.IsAttachment = false;
3433 //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
3434 m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle);
3435 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent);
3436 }
3437 }
3438 m_attachments.Clear();
3439
3440 return true;
3441 }
3442 }
3443 3439
3444 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) 3440 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
3445 { 3441 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
index e4296ef..c6cf4cc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
@@ -31,7 +31,6 @@ using OpenMetaverse;
31using log4net; 31using log4net;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Client; 33using OpenSim.Framework.Client;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes.Types; 35using OpenSim.Region.Framework.Scenes.Types;
37 36
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 0ed00de..b775d27 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;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common; 37using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 38using OpenSim.Tests.Common.Mock;
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;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common; 37using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 38using 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;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion;
44using OpenSim.Region.CoreModules.World.Serialiser; 43using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
45using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock; 46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup; 47using 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 8a27b7b..c77220c 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -132,7 +132,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
132 RegionInfo regionInfo = new RegionInfo(0,0,null,null); 132 RegionInfo regionInfo = new RegionInfo(0,0,null,null);
133 FakeStorageManager storageManager = new FakeStorageManager(); 133 FakeStorageManager storageManager = new FakeStorageManager();
134 134
135 new Scene(regionInfo, null, null, null, storageManager, null, false, false, false, null, null); 135 new Scene(regionInfo, null, null, storageManager, null, false, false, false, null, null);
136 } 136 }
137 } 137 }
138} 138}
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;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; 37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
38using OpenSim.Tests.Common; 38using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 39using OpenSim.Tests.Common.Mock;
40using OpenSim.Tests.Common.Setup; 40using 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