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.cs1202
-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.cs90
-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, 385 insertions, 3245 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 ddebd0b..669720a 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
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 2059
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)
@@ -2338,75 +2240,6 @@ namespace OpenSim.Region.Framework.Scenes
2338 2240
2339 2241
2340 /// <summary> 2242 /// <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 /// <summary>
2410 /// Called when objects or attachments cross the border between regions. 2243 /// Called when objects or attachments cross the border between regions.
2411 /// </summary> 2244 /// </summary>
2412 /// <param name="sog"></param> 2245 /// <param name="sog"></param>
@@ -2478,6 +2311,9 @@ namespace OpenSim.Region.Framework.Scenes
2478 2311
2479 return false; 2312 return false;
2480 } 2313 }
2314
2315 sceneObject.SetScene(this);
2316
2481 // Force allocation of new LocalId 2317 // Force allocation of new LocalId
2482 // 2318 //
2483 foreach (SceneObjectPart p in sceneObject.Children.Values) 2319 foreach (SceneObjectPart p in sceneObject.Children.Values)
@@ -2590,6 +2426,37 @@ namespace OpenSim.Region.Framework.Scenes
2590 { 2426 {
2591 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); 2427 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
2592 2428
2429 // Do the verification here
2430 System.Net.EndPoint ep = client.GetClientEP();
2431 if (aCircuit != null)
2432 {
2433 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
2434 {
2435 m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2436 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
2437 if (userVerification != null)
2438 {
2439 if (!userVerification.VerifyClient(aCircuit, ep.ToString()))
2440 {
2441 // uh-oh, this is fishy
2442 m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
2443 client.AgentId, client.SessionId, ep.ToString());
2444 try
2445 {
2446 client.Close();
2447 }
2448 catch (Exception e)
2449 {
2450 m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace);
2451 }
2452 return;
2453 }
2454 else
2455 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} returned true", aCircuit.firstname, aCircuit.lastname);
2456 }
2457 }
2458 }
2459
2593 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); 2460 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
2594 /* 2461 /*
2595 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}", 2462 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}",
@@ -2599,9 +2466,9 @@ namespace OpenSim.Region.Framework.Scenes
2599 m_log.Debug(logMsg); 2466 m_log.Debug(logMsg);
2600 */ 2467 */
2601 2468
2602 CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); 2469 //CommsManager.UserProfileCacheService.AddNewUser(client.AgentId);
2603
2604 ScenePresence sp = CreateAndAddScenePresence(client); 2470 ScenePresence sp = CreateAndAddScenePresence(client);
2471 sp.Appearance = aCircuit.Appearance;
2605 2472
2606 // HERE!!! Do the initial attachments right here 2473 // HERE!!! Do the initial attachments right here
2607 // first agent upon login is a root agent by design. 2474 // first agent upon login is a root agent by design.
@@ -2615,6 +2482,7 @@ namespace OpenSim.Region.Framework.Scenes
2615 2482
2616 m_LastLogin = Util.EnvironmentTickCount(); 2483 m_LastLogin = Util.EnvironmentTickCount();
2617 EventManager.TriggerOnNewClient(client); 2484 EventManager.TriggerOnNewClient(client);
2485
2618 } 2486 }
2619 2487
2620 2488
@@ -2731,7 +2599,6 @@ namespace OpenSim.Region.Framework.Scenes
2731 { 2599 {
2732 client.OnTeleportLocationRequest += RequestTeleportLocation; 2600 client.OnTeleportLocationRequest += RequestTeleportLocation;
2733 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 2601 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
2734 client.OnTeleportHomeRequest += TeleportClientHome;
2735 } 2602 }
2736 2603
2737 public virtual void SubscribeToClientScriptEvents(IClientAPI client) 2604 public virtual void SubscribeToClientScriptEvents(IClientAPI client)
@@ -2751,7 +2618,7 @@ namespace OpenSim.Region.Framework.Scenes
2751 2618
2752 public virtual void SubscribeToClientGridEvents(IClientAPI client) 2619 public virtual void SubscribeToClientGridEvents(IClientAPI client)
2753 { 2620 {
2754 client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; 2621 client.OnNameFromUUIDRequest += HandleUUIDNameRequest;
2755 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; 2622 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
2756 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; 2623 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest;
2757 client.OnSetStartLocationRequest += SetHomeRezPoint; 2624 client.OnSetStartLocationRequest += SetHomeRezPoint;
@@ -2886,7 +2753,7 @@ namespace OpenSim.Region.Framework.Scenes
2886 { 2753 {
2887 client.OnTeleportLocationRequest -= RequestTeleportLocation; 2754 client.OnTeleportLocationRequest -= RequestTeleportLocation;
2888 client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; 2755 client.OnTeleportLandmarkRequest -= RequestTeleportLandmark;
2889 client.OnTeleportHomeRequest -= TeleportClientHome; 2756 //client.OnTeleportHomeRequest -= TeleportClientHome;
2890 } 2757 }
2891 2758
2892 public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) 2759 public virtual void UnSubscribeToClientScriptEvents(IClientAPI client)
@@ -2906,7 +2773,7 @@ namespace OpenSim.Region.Framework.Scenes
2906 2773
2907 public virtual void UnSubscribeToClientGridEvents(IClientAPI client) 2774 public virtual void UnSubscribeToClientGridEvents(IClientAPI client)
2908 { 2775 {
2909 client.OnNameFromUUIDRequest -= CommsManager.HandleUUIDNameRequest; 2776 client.OnNameFromUUIDRequest -= HandleUUIDNameRequest;
2910 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; 2777 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest;
2911 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; 2778 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest;
2912 client.OnSetStartLocationRequest -= SetHomeRezPoint; 2779 client.OnSetStartLocationRequest -= SetHomeRezPoint;
@@ -2933,30 +2800,12 @@ namespace OpenSim.Region.Framework.Scenes
2933 /// <param name="client">The IClientAPI for the client</param> 2800 /// <param name="client">The IClientAPI for the client</param>
2934 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2801 public virtual void TeleportClientHome(UUID agentId, IClientAPI client)
2935 { 2802 {
2936 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); 2803 if (m_teleportModule != null)
2937 if (UserProfile != null) 2804 m_teleportModule.TeleportHome(agentId, client);
2805 else
2938 { 2806 {
2939 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); 2807 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2940 if (regionInfo == null) 2808 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2941 {
2942 uint x = 0, y = 0;
2943 Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
2944 regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
2945 if (regionInfo != null) // home region can be away temporarily, too
2946 {
2947 UserProfile.HomeRegionID = regionInfo.RegionID;
2948 CommsManager.UserService.UpdateUserProfile(UserProfile);
2949 }
2950 }
2951 if (regionInfo == null)
2952 {
2953 // can't find the Home region: Tell viewer and abort
2954 client.SendTeleportFailed("Your home-region could not be found.");
2955 return;
2956 }
2957 RequestTeleportLocation(
2958 client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
2959 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
2960 } 2809 }
2961 } 2810 }
2962 2811
@@ -3047,7 +2896,7 @@ namespace OpenSim.Region.Framework.Scenes
3047 } 2896 }
3048 2897
3049 /// <summary> 2898 /// <summary>
3050 /// Sets the Home Point. The GridService uses this to know where to put a user when they log-in 2899 /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in
3051 /// </summary> 2900 /// </summary>
3052 /// <param name="remoteClient"></param> 2901 /// <param name="remoteClient"></param>
3053 /// <param name="regionHandle"></param> 2902 /// <param name="regionHandle"></param>
@@ -3056,27 +2905,11 @@ namespace OpenSim.Region.Framework.Scenes
3056 /// <param name="flags"></param> 2905 /// <param name="flags"></param>
3057 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 2906 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3058 { 2907 {
3059 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); 2908 if (PresenceService.SetHomeLocation(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3060 if (UserProfile != null)
3061 {
3062 // I know I'm ignoring the regionHandle provided by the teleport location request.
3063 // reusing the TeleportLocationRequest delegate, so regionHandle isn't valid
3064 UserProfile.HomeRegionID = RegionInfo.RegionID;
3065 // TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around.
3066 // TODO: The HomeRegion property can be removed then, too
3067 UserProfile.HomeRegion = RegionInfo.RegionHandle;
3068
3069 UserProfile.HomeLocation = position;
3070 UserProfile.HomeLookAt = lookAt;
3071 CommsManager.UserService.UpdateUserProfile(UserProfile);
3072
3073 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 2909 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3074 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 2910 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
3075 }
3076 else 2911 else
3077 {
3078 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); 2912 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed.");
3079 }
3080 } 2913 }
3081 2914
3082 /// <summary> 2915 /// <summary>
@@ -3150,14 +2983,12 @@ namespace OpenSim.Region.Framework.Scenes
3150 m_sceneGraph.removeUserCount(!childagentYN); 2983 m_sceneGraph.removeUserCount(!childagentYN);
3151 CapsModule.RemoveCapsHandler(agentID); 2984 CapsModule.RemoveCapsHandler(agentID);
3152 2985
3153 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) 2986 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3154 { 2987 // this method is doing is HORRIBLE!!!
3155 CommsManager.UserProfileCacheService.RemoveUser(agentID); 2988 avatar.Scene.NeedSceneCacheClear(avatar.UUID);
3156 }
3157 2989
3158 if (!avatar.IsChildAgent) 2990 if (!avatar.IsChildAgent)
3159 { 2991 {
3160 m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat);
3161 //List<ulong> childknownRegions = new List<ulong>(); 2992 //List<ulong> childknownRegions = new List<ulong>();
3162 //List<ulong> ckn = avatar.KnownChildRegionHandles; 2993 //List<ulong> ckn = avatar.KnownChildRegionHandles;
3163 //for (int i = 0; i < ckn.Count; i++) 2994 //for (int i = 0; i < ckn.Count; i++)
@@ -3212,12 +3043,6 @@ namespace OpenSim.Region.Framework.Scenes
3212 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3043 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3213 } 3044 }
3214 3045
3215 // Remove client agent from profile, so new logins will work
3216 if (!childagentYN)
3217 {
3218 m_sceneGridService.ClearUserAgent(agentID);
3219 }
3220
3221 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3046 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3222 3047
3223 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3048 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
@@ -3291,14 +3116,6 @@ namespace OpenSim.Region.Framework.Scenes
3291 m_sceneGridService.KiPrimitive += SendKillObject; 3116 m_sceneGridService.KiPrimitive += SendKillObject;
3292 m_sceneGridService.OnGetLandData += GetLandData; 3117 m_sceneGridService.OnGetLandData += GetLandData;
3293 3118
3294 if (m_interregionCommsIn != null)
3295 {
3296 m_log.Debug("[SCENE]: Registering with InterregionCommsIn");
3297 m_interregionCommsIn.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3298 }
3299 else
3300 m_log.Debug("[SCENE]: Unable to register with InterregionCommsIn");
3301
3302 } 3119 }
3303 3120
3304 /// <summary> 3121 /// <summary>
@@ -3316,9 +3133,6 @@ namespace OpenSim.Region.Framework.Scenes
3316 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; 3133 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
3317 m_sceneGridService.OnGetLandData -= GetLandData; 3134 m_sceneGridService.OnGetLandData -= GetLandData;
3318 3135
3319 if (m_interregionCommsIn != null)
3320 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3321
3322 // this does nothing; should be removed 3136 // this does nothing; should be removed
3323 m_sceneGridService.Close(); 3137 m_sceneGridService.Close();
3324 3138
@@ -3375,7 +3189,7 @@ namespace OpenSim.Region.Framework.Scenes
3375 agent.AgentID, agent.circuitcode, teleportFlags); 3189 agent.AgentID, agent.circuitcode, teleportFlags);
3376 3190
3377 reason = String.Empty; 3191 reason = String.Empty;
3378 if (!AuthenticateUser(agent, out reason)) 3192 if (!VerifyUserPresence(agent, out reason))
3379 return false; 3193 return false;
3380 3194
3381 if (!AuthorizeUser(agent, out reason)) 3195 if (!AuthorizeUser(agent, out reason))
@@ -3470,40 +3284,39 @@ namespace OpenSim.Region.Framework.Scenes
3470 } 3284 }
3471 } 3285 }
3472 3286
3287 agent.teleportFlags = teleportFlags;
3473 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3288 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3474 3289
3475 // rewrite session_id
3476 CachedUserInfo userinfo = CommsManager.UserProfileCacheService.GetUserDetails(agent.AgentID);
3477 if (userinfo != null)
3478 {
3479 userinfo.SessionID = agent.SessionID;
3480 }
3481 else
3482 {
3483 m_log.WarnFormat(
3484 "[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);
3485 }
3486
3487 return true; 3290 return true;
3488 } 3291 }
3489 3292
3490 /// <summary> 3293 /// <summary>
3491 /// Verifies that the user has a session on the Grid 3294 /// Verifies that the user has a presence on the Grid
3492 /// </summary> 3295 /// </summary>
3493 /// <param name="agent">Circuit Data of the Agent we're verifying</param> 3296 /// <param name="agent">Circuit Data of the Agent we're verifying</param>
3494 /// <param name="reason">Outputs the reason for the false response on this string</param> 3297 /// <param name="reason">Outputs the reason for the false response on this string</param>
3495 /// <returns>True if the user has a session on the grid. False if it does not. False will 3298 /// <returns>True if the user has a session on the grid. False if it does not. False will
3496 /// also return a reason.</returns> 3299 /// also return a reason.</returns>
3497 public virtual bool AuthenticateUser(AgentCircuitData agent, out string reason) 3300 public virtual bool VerifyUserPresence(AgentCircuitData agent, out string reason)
3498 { 3301 {
3499 reason = String.Empty; 3302 reason = String.Empty;
3500 3303
3501 bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID); 3304 IPresenceService presence = RequestModuleInterface<IPresenceService>();
3502 m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result); 3305 if (presence == null)
3503 if (!result) 3306 {
3504 reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname); 3307 reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3308 return false;
3309 }
3310
3311 OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID);
3312
3313 if (pinfo == null || (pinfo != null && pinfo.Online == false))
3314 {
3315 reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3316 return false;
3317 }
3505 3318
3506 return result; 3319 return true;
3507 } 3320 }
3508 3321
3509 /// <summary> 3322 /// <summary>
@@ -3704,8 +3517,8 @@ namespace OpenSim.Region.Framework.Scenes
3704 /// <returns>true if we handled it.</returns> 3517 /// <returns>true if we handled it.</returns>
3705 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) 3518 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData)
3706 { 3519 {
3707// m_log.DebugFormat( 3520 m_log.DebugFormat(
3708// "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); 3521 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
3709 3522
3710 // We have to wait until the viewer contacts this region after receiving EAC. 3523 // We have to wait until the viewer contacts this region after receiving EAC.
3711 // That calls AddNewClient, which finally creates the ScenePresence 3524 // That calls AddNewClient, which finally creates the ScenePresence
@@ -3774,16 +3587,6 @@ namespace OpenSim.Region.Framework.Scenes
3774 return false; 3587 return false;
3775 } 3588 }
3776 3589
3777 public virtual bool IncomingReleaseAgent(UUID id)
3778 {
3779 return m_sceneGridService.ReleaseAgent(id);
3780 }
3781
3782 public void SendReleaseAgent(ulong regionHandle, UUID id, string uri)
3783 {
3784 m_interregionCommsOut.SendReleaseAgent(regionHandle, id, uri);
3785 }
3786
3787 /// <summary> 3590 /// <summary>
3788 /// Tell a single agent to disconnect from the region. 3591 /// Tell a single agent to disconnect from the region.
3789 /// </summary> 3592 /// </summary>
@@ -3828,30 +3631,6 @@ namespace OpenSim.Region.Framework.Scenes
3828 } 3631 }
3829 3632
3830 /// <summary> 3633 /// <summary>
3831 /// Tell neighboring regions about this agent
3832 /// When the regions respond with a true value,
3833 /// tell the agents about the region.
3834 ///
3835 /// We have to tell the regions about the agents first otherwise it'll deny them access
3836 ///
3837 /// </summary>
3838 /// <param name="presence"></param>
3839 public void InformClientOfNeighbours(ScenePresence presence)
3840 {
3841 m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
3842 }
3843
3844 /// <summary>
3845 /// Tell a neighboring region about this agent
3846 /// </summary>
3847 /// <param name="presence"></param>
3848 /// <param name="region"></param>
3849 public void InformClientOfNeighbor(ScenePresence presence, RegionInfo region)
3850 {
3851 m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
3852 }
3853
3854 /// <summary>
3855 /// Tries to teleport agent to other region. 3634 /// Tries to teleport agent to other region.
3856 /// </summary> 3635 /// </summary>
3857 /// <param name="remoteClient"></param> 3636 /// <param name="remoteClient"></param>
@@ -3926,16 +3705,12 @@ namespace OpenSim.Region.Framework.Scenes
3926 } 3705 }
3927 3706
3928 if (m_teleportModule != null) 3707 if (m_teleportModule != null)
3929 { 3708 m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
3930 m_teleportModule.RequestTeleportToLocation(sp, regionHandle,
3931 position, lookAt, teleportFlags);
3932 }
3933 else 3709 else
3934 { 3710 {
3935 m_sceneGridService.RequestTeleportToLocation(sp, regionHandle, 3711 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
3936 position, lookAt, teleportFlags); 3712 sp.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator.");
3937 } 3713 }
3938
3939 } 3714 }
3940 } 3715 }
3941 3716
@@ -3961,7 +3736,12 @@ namespace OpenSim.Region.Framework.Scenes
3961 3736
3962 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 3737 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
3963 { 3738 {
3964 m_sceneGridService.CrossAgentToNewRegion(this, agent, isFlying); 3739 if (m_teleportModule != null)
3740 m_teleportModule.Cross(agent, isFlying);
3741 else
3742 {
3743 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
3744 }
3965 } 3745 }
3966 3746
3967 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) 3747 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence)
@@ -3987,35 +3767,6 @@ namespace OpenSim.Region.Framework.Scenes
3987 objectCapacity = objects; 3767 objectCapacity = objects;
3988 } 3768 }
3989 3769
3990 public List<FriendListItem> GetFriendList(string id)
3991 {
3992 UUID avatarID;
3993 if (!UUID.TryParse(id, out avatarID))
3994 return new List<FriendListItem>();
3995
3996 return CommsManager.GetUserFriendList(avatarID);
3997 }
3998
3999 public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
4000 {
4001 return CommsManager.GetFriendRegionInfos(uuids);
4002 }
4003
4004 public virtual void StoreAddFriendship(UUID ownerID, UUID friendID, uint perms)
4005 {
4006 m_sceneGridService.AddNewUserFriend(ownerID, friendID, perms);
4007 }
4008
4009 public virtual void StoreUpdateFriendship(UUID ownerID, UUID friendID, uint perms)
4010 {
4011 m_sceneGridService.UpdateUserFriendPerms(ownerID, friendID, perms);
4012 }
4013
4014 public virtual void StoreRemoveFriendship(UUID ownerID, UUID ExfriendID)
4015 {
4016 m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID);
4017 }
4018
4019 #endregion 3770 #endregion
4020 3771
4021 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) 3772 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set)
@@ -4931,5 +4682,15 @@ namespace OpenSim.Region.Framework.Scenes
4931 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4682 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000)
4932 StartTimer(); 4683 StartTimer();
4933 } 4684 }
4685
4686 public override ISceneObject DeserializeObject(string representation)
4687 {
4688 return SceneObjectSerializer.FromXml2Format(representation);
4689 }
4690
4691 public override bool AllowScriptCrossings
4692 {
4693 get { return m_allowScriptCrossings; }
4694 }
4934 } 4695 }
4935} 4696}
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 2f6a0db..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,377 +142,6 @@ namespace OpenSim.Region.Framework.Scenes
148 { 142 {
149 } 143 }
150 144
151 #region CommsManager Event handlers
152
153 /// <summary>
154 /// A New User will arrive shortly, Informs the scene that there's a new user on the way
155 /// </summary>
156 /// <param name="agent">Data we need to ensure that the agent can connect</param>
157 ///
158 protected void NewUserConnection(AgentCircuitData agent)
159 {
160 handlerExpectUser = OnExpectUser;
161 if (handlerExpectUser != null)
162 {
163 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: OnExpectUser Fired for User:" + agent.firstname + " " + agent.lastname);
164 handlerExpectUser(agent);
165 }
166 }
167
168 /// <summary>
169 /// The Grid has requested us to log-off the user
170 /// </summary>
171 /// <param name="AgentID">Unique ID of agent to log-off</param>
172 /// <param name="RegionSecret">The secret string that the region establishes with the grid when registering</param>
173 /// <param name="message">The message to send to the user that tells them why they were logged off</param>
174 protected void GridLogOffUser(UUID AgentID, UUID RegionSecret, string message)
175 {
176 handlerLogOffUser = OnLogOffUser;
177 if (handlerLogOffUser != null)
178 {
179 handlerLogOffUser(AgentID, RegionSecret, message);
180 }
181 }
182
183 /// <summary>
184 /// Inform the scene that we've got an update about a child agent that we have
185 /// </summary>
186 /// <param name="cAgentData"></param>
187 /// <returns></returns>
188 protected bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData)
189 {
190 handlerChildAgentUpdate = OnChildAgentUpdate;
191 if (handlerChildAgentUpdate != null)
192 handlerChildAgentUpdate(cAgentData);
193
194 return true;
195 }
196
197
198 protected void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
199 {
200 handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion;
201 if (handlerAvatarCrossingIntoRegion != null)
202 {
203 handlerAvatarCrossingIntoRegion(agentID, position, isFlying);
204 }
205 }
206
207 protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical)
208 {
209 handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
210 if (handlerPrimCrossingIntoRegion != null)
211 {
212 handlerPrimCrossingIntoRegion(primID, position, isPhysical);
213 }
214 }
215
216 protected bool CloseConnection(UUID agentID)
217 {
218 m_log.Debug("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID);
219
220 handlerCloseAgentConnection = OnCloseAgentConnection;
221 if (handlerCloseAgentConnection != null)
222 {
223 return handlerCloseAgentConnection(agentID);
224 }
225
226 return false;
227 }
228
229 protected LandData FetchLandData(uint x, uint y)
230 {
231 handlerGetLandData = OnGetLandData;
232 if (handlerGetLandData != null)
233 {
234 return handlerGetLandData(x, y);
235 }
236 return null;
237 }
238
239 #endregion
240
241 #region Inform Client of Neighbours
242
243 private delegate void InformClientOfNeighbourDelegate(
244 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
245
246 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
247 {
248 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState;
249 icon.EndInvoke(iar);
250 }
251
252 /// <summary>
253 /// Async component for informing client of which neighbours exist
254 /// </summary>
255 /// <remarks>
256 /// This needs to run asynchronously, as a network timeout may block the thread for a long while
257 /// </remarks>
258 /// <param name="remoteClient"></param>
259 /// <param name="a"></param>
260 /// <param name="regionHandle"></param>
261 /// <param name="endPoint"></param>
262 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
263 IPEndPoint endPoint, bool newAgent)
264 {
265 // Let's wait just a little to give time to originating regions to catch up with closing child agents
266 // after a cross here
267 Thread.Sleep(500);
268
269 uint x, y;
270 Utils.LongToUInts(reg.RegionHandle, out x, out y);
271 x = x / Constants.RegionSize;
272 y = y / Constants.RegionSize;
273 m_log.Info("[INTERGRID]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")");
274
275 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
276 + "/CAPS/" + a.CapsPath + "0000/";
277
278 string reason = String.Empty;
279
280
281 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason);
282
283 if (regionAccepted && newAgent)
284 {
285 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
286 if (eq != null)
287 {
288 #region IP Translation for NAT
289 IClientIPEndpoint ipepClient;
290 if (avatar.ClientView.TryGet(out ipepClient))
291 {
292 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
293 }
294 #endregion
295
296 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
297 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
298 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}",
299 capsPath, avatar.UUID, avatar.Scene.RegionInfo.RegionName);
300 }
301 else
302 {
303 avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
304 // TODO: make Event Queue disablable!
305 }
306
307 m_log.Info("[INTERGRID]: Completed inform client about neighbour " + endPoint.ToString());
308
309 }
310
311 }
312
313 public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
314 {
315 Border[] northBorders = pScene.NorthBorders.ToArray();
316 Border[] southBorders = pScene.SouthBorders.ToArray();
317 Border[] eastBorders = pScene.EastBorders.ToArray();
318 Border[] westBorders = pScene.WestBorders.ToArray();
319
320 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
321 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
322 {
323 return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
324 }
325 else
326 {
327 Vector2 extent = Vector2.Zero;
328 for (int i = 0; i < eastBorders.Length; i++)
329 {
330 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
331 }
332 for (int i = 0; i < northBorders.Length; i++)
333 {
334 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
335 }
336
337 // Loss of fraction on purpose
338 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
339 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
340
341 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
342 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
343
344 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
345 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
346
347 List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
348 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
349
350 return neighbours;
351 }
352 }
353
354 /// <summary>
355 /// This informs all neighboring regions about agent "avatar".
356 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
357 /// </summary>
358 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
359 {
360 List<GridRegion> neighbours = new List<GridRegion>();
361
362 if (m_regionInfo != null)
363 {
364 neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
365 }
366 else
367 {
368 m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?");
369 }
370
371 /// We need to find the difference between the new regions where there are no child agents
372 /// and the regions where there are already child agents. We only send notification to the former.
373 List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
374 neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too
375 List<ulong> previousRegionNeighbourHandles ;
376
377 if (avatar.Scene.CapsModule != null)
378 {
379 previousRegionNeighbourHandles =
380 new List<ulong>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys);
381 }
382 else
383 {
384 previousRegionNeighbourHandles = new List<ulong>();
385 }
386
387 List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
388 List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
389
390 //Dump("Current Neighbors", neighbourHandles);
391 //Dump("Previous Neighbours", previousRegionNeighbourHandles);
392 //Dump("New Neighbours", newRegions);
393 //Dump("Old Neighbours", oldRegions);
394
395 /// Update the scene presence's known regions here on this region
396 avatar.DropOldNeighbours(oldRegions);
397
398 /// Collect as many seeds as possible
399 Dictionary<ulong, string> seeds;
400 if (avatar.Scene.CapsModule != null)
401 seeds
402 = new Dictionary<ulong, string>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID));
403 else
404 seeds = new Dictionary<ulong, string>();
405
406 //m_log.Debug(" !!! No. of seeds: " + seeds.Count);
407 if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle))
408 seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath);
409
410 /// Create the necessary child agents
411 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
412 foreach (GridRegion neighbour in neighbours)
413 {
414 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
415 {
416
417 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
418 agent.BaseFolder = UUID.Zero;
419 agent.InventoryFolder = UUID.Zero;
420 agent.startpos = new Vector3(128, 128, 70);
421 agent.child = true;
422
423 if (newRegions.Contains(neighbour.RegionHandle))
424 {
425 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
426 avatar.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
427 seeds.Add(neighbour.RegionHandle, agent.CapsPath);
428 }
429 else
430 agent.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, neighbour.RegionHandle);
431
432 cagents.Add(agent);
433 }
434 }
435
436 /// Update all child agent with everyone's seeds
437 foreach (AgentCircuitData a in cagents)
438 {
439 a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
440 }
441
442 if (avatar.Scene.CapsModule != null)
443 {
444 // These two are the same thing!
445 avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds);
446 }
447 avatar.KnownRegions = seeds;
448 //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
449 //avatar.DumpKnownRegions();
450
451 bool newAgent = false;
452 int count = 0;
453 foreach (GridRegion neighbour in neighbours)
454 {
455 // Don't do it if there's already an agent in that region
456 if (newRegions.Contains(neighbour.RegionHandle))
457 newAgent = true;
458 else
459 newAgent = false;
460
461 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
462 {
463 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
464 try
465 {
466 d.BeginInvoke(avatar, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
467 InformClientOfNeighbourCompleted,
468 d);
469 }
470
471 catch (ArgumentOutOfRangeException)
472 {
473 m_log.ErrorFormat(
474 "[REGIONINFO]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).",
475 neighbour.ExternalHostName,
476 neighbour.RegionHandle,
477 neighbour.RegionLocX,
478 neighbour.RegionLocY);
479 }
480 catch (Exception e)
481 {
482 m_log.ErrorFormat(
483 "[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
484 neighbour.ExternalHostName,
485 neighbour.RegionHandle,
486 neighbour.RegionLocX,
487 neighbour.RegionLocY,
488 e);
489
490 // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
491 // since I don't know what will happen if we just let the client continue
492
493 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
494 // throw e;
495
496 }
497 }
498 count++;
499 }
500 }
501
502 /// <summary>
503 /// This informs a single neighboring region about agent "avatar".
504 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
505 /// </summary>
506 public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
507 {
508 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
509 agent.BaseFolder = UUID.Zero;
510 agent.InventoryFolder = UUID.Zero;
511 agent.startpos = new Vector3(128, 128, 70);
512 agent.child = true;
513
514 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
515 d.BeginInvoke(avatar, agent, region, region.ExternalEndPoint, true,
516 InformClientOfNeighbourCompleted,
517 d);
518 }
519
520 #endregion
521
522 public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle); 145 public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle);
523 146
524 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) 147 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar)
@@ -592,7 +215,10 @@ namespace OpenSim.Region.Framework.Scenes
592 try 215 try
593 { 216 {
594 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); 217 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData);
595 m_interregionCommsOut.SendChildAgentUpdate(regionHandle, cAgentData); 218 uint x = 0, y = 0;
219 Utils.LongToUInts(regionHandle, out x, out y);
220 GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
221 m_scene.SimulationService.UpdateAgent(destination, cAgentData);
596 } 222 }
597 catch 223 catch
598 { 224 {
@@ -652,7 +278,10 @@ namespace OpenSim.Region.Framework.Scenes
652 // let's do our best, but there's not much we can do if the neighbour doesn't accept. 278 // let's do our best, but there's not much we can do if the neighbour doesn't accept.
653 279
654 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); 280 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
655 m_interregionCommsOut.SendCloseAgent(regionHandle, agentID); 281 uint x = 0, y = 0;
282 Utils.LongToUInts(regionHandle, out x, out y);
283 GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
284 m_scene.SimulationService.CloseAgent(destination, agentID);
656 } 285 }
657 286
658 private void SendCloseChildAgentCompleted(IAsyncResult iar) 287 private void SendCloseChildAgentCompleted(IAsyncResult iar)
@@ -671,822 +300,11 @@ namespace OpenSim.Region.Framework.Scenes
671 d); 300 d);
672 } 301 }
673 } 302 }
674 303
675
676 /// <summary>
677 /// Try to teleport an agent to a new region.
678 /// </summary>
679 /// <param name="remoteClient"></param>
680 /// <param name="RegionHandle"></param>
681 /// <param name="position"></param>
682 /// <param name="lookAt"></param>
683 /// <param name="flags"></param>
684 public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
685 Vector3 lookAt, uint teleportFlags)
686 {
687 if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
688 return;
689
690 bool destRegionUp = true;
691
692 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
693
694 // Reset animations; the viewer does that in teleports.
695 avatar.Animator.ResetAnimations();
696
697 if (regionHandle == m_regionInfo.RegionHandle)
698 {
699 m_log.DebugFormat(
700 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}",
701 position, m_regionInfo.RegionName);
702
703 // Teleport within the same region
704 if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
705 {
706 Vector3 emergencyPos = new Vector3(128, 128, 128);
707
708 m_log.WarnFormat(
709 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
710 position, avatar.Name, avatar.UUID, emergencyPos);
711 position = emergencyPos;
712 }
713
714 // TODO: Get proper AVG Height
715 float localAVHeight = 1.56f;
716 float posZLimit = 22;
717
718 // TODO: Check other Scene HeightField
719 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <=(int)Constants.RegionSize)
720 {
721 posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
722 }
723
724 float newPosZ = posZLimit + localAVHeight;
725 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
726 {
727 position.Z = newPosZ;
728 }
729
730 // Only send this if the event queue is null
731 if (eq == null)
732 avatar.ControllingClient.SendTeleportLocationStart();
733
734 avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
735 avatar.Teleport(position);
736 }
737 else
738 {
739 uint x = 0, y = 0;
740 Utils.LongToUInts(regionHandle, out x, out y);
741 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
742
743 if (reg != null)
744 {
745 m_log.DebugFormat(
746 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation to {0} in {1}",
747 position, reg.RegionName);
748
749 if (eq == null)
750 avatar.ControllingClient.SendTeleportLocationStart();
751
752 // Let's do DNS resolution only once in this process, please!
753 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
754 // it's actually doing a lot of work.
755 IPEndPoint endPoint = reg.ExternalEndPoint;
756 if (endPoint.Address == null)
757 {
758 // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
759 destRegionUp = false;
760 }
761
762 if (destRegionUp)
763 {
764 uint newRegionX = (uint)(reg.RegionHandle >> 40);
765 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
766 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
767 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
768
769 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
770 // both regions
771 if (avatar.ParentID != (uint)0)
772 avatar.StandUp();
773
774 if (!avatar.ValidateAttachments())
775 {
776 avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
777 return;
778 }
779
780 // the avatar.Close below will clear the child region list. We need this below for (possibly)
781 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
782 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
783 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
784 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
785 // once we reach here...
786 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
787
788 string capsPath = String.Empty;
789 AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
790 agentCircuit.BaseFolder = UUID.Zero;
791 agentCircuit.InventoryFolder = UUID.Zero;
792 agentCircuit.startpos = position;
793 agentCircuit.child = true;
794
795 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
796 {
797 // brand new agent, let's create a new caps seed
798 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
799 }
800
801 string reason = String.Empty;
802
803 // Let's create an agent there if one doesn't exist yet.
804 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
805 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
806 {
807 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
808 reason));
809 return;
810 }
811
812 // OK, it got this agent. Let's close some child agents
813 avatar.CloseChildAgents(newRegionX, newRegionY);
814
815 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
816 {
817 #region IP Translation for NAT
818 IClientIPEndpoint ipepClient;
819 if (avatar.ClientView.TryGet(out ipepClient))
820 {
821 capsPath
822 = "http://"
823 + NetworkUtil.GetHostFor(ipepClient.EndPoint, reg.ExternalHostName)
824 + ":"
825 + reg.HttpPort
826 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
827 }
828 else
829 {
830 capsPath
831 = "http://"
832 + reg.ExternalHostName
833 + ":"
834 + reg.HttpPort
835 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
836 }
837 #endregion
838
839 if (eq != null)
840 {
841 #region IP Translation for NAT
842 // Uses ipepClient above
843 if (avatar.ClientView.TryGet(out ipepClient))
844 {
845 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
846 }
847 #endregion
848
849 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
850
851 // ES makes the client send a UseCircuitCode message to the destination,
852 // which triggers a bunch of things there.
853 // So let's wait
854 Thread.Sleep(2000);
855
856 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
857 }
858 else
859 {
860 avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
861 }
862 }
863 else
864 {
865 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
866 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
867 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
868 }
869
870 // Expect avatar crossing is a heavy-duty function at the destination.
871 // That is where MakeRoot is called, which fetches appearance and inventory.
872 // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates.
873 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
874 // position, false);
875
876 //{
877 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
878 // // We should close that agent we just created over at destination...
879 // List<ulong> lst = new List<ulong>();
880 // lst.Add(reg.RegionHandle);
881 // SendCloseChildAgentAsync(avatar.UUID, lst);
882 // return;
883 //}
884
885 SetInTransit(avatar.UUID);
886 // Let's send a full update of the agent. This is a synchronous call.
887 AgentData agent = new AgentData();
888 avatar.CopyTo(agent);
889 agent.Position = position;
890 agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
891 "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
892
893 m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
894
895 m_log.DebugFormat(
896 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID);
897
898
899 if (eq != null)
900 {
901 eq.TeleportFinishEvent(reg.RegionHandle, 13, endPoint,
902 0, teleportFlags, capsPath, avatar.UUID);
903 }
904 else
905 {
906 avatar.ControllingClient.SendRegionTeleport(reg.RegionHandle, 13, endPoint, 4,
907 teleportFlags, capsPath);
908 }
909
910 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
911 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
912 // that the client contacted the destination before we send the attachments and close things here.
913 if (!WaitForCallback(avatar.UUID))
914 {
915 // Client never contacted destination. Let's restore everything back
916 avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
917
918 ResetFromTransit(avatar.UUID);
919
920 // Yikes! We should just have a ref to scene here.
921 avatar.Scene.InformClientOfNeighbours(avatar);
922
923 // Finally, kill the agent we just created at the destination.
924 m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
925
926 return;
927 }
928
929 // Can't go back from here
930 if (KiPrimitive != null)
931 {
932 KiPrimitive(avatar.LocalId);
933 }
934
935 avatar.MakeChildAgent();
936
937 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
938 avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
939
940 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
941
942 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
943 {
944 Thread.Sleep(5000);
945 avatar.Close();
946 CloseConnection(avatar.UUID);
947 }
948 else
949 // now we have a child agent in this region.
950 avatar.Reset();
951
952
953 // if (teleport success) // seems to be always success here
954 // the user may change their profile information in other region,
955 // so the userinfo in UserProfileCache is not reliable any more, delete it
956 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID))
957 {
958 m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
959 m_log.DebugFormat(
960 "[SCENE COMMUNICATION SERVICE]: User {0} is going to another region, profile cache removed",
961 avatar.UUID);
962 }
963 }
964 else
965 {
966 avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
967 }
968 }
969 else
970 {
971 // TP to a place that doesn't exist (anymore)
972 // Inform the viewer about that
973 avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
974
975 // and set the map-tile to '(Offline)'
976 uint regX, regY;
977 Utils.LongToUInts(regionHandle, out regX, out regY);
978
979 MapBlockData block = new MapBlockData();
980 block.X = (ushort)(regX / Constants.RegionSize);
981 block.Y = (ushort)(regY / Constants.RegionSize);
982 block.Access = 254; // == not there
983
984 List<MapBlockData> blocks = new List<MapBlockData>();
985 blocks.Add(block);
986 avatar.ControllingClient.SendMapBlock(blocks, 0);
987 }
988 }
989 }
990
991 protected bool IsOutsideRegion(Scene s, Vector3 pos)
992 {
993
994 if (s.TestBorderCross(pos,Cardinals.N))
995 return true;
996 if (s.TestBorderCross(pos, Cardinals.S))
997 return true;
998 if (s.TestBorderCross(pos, Cardinals.E))
999 return true;
1000 if (s.TestBorderCross(pos, Cardinals.W))
1001 return true;
1002
1003 return false;
1004 }
1005
1006 public bool WaitForCallback(UUID id)
1007 {
1008 int count = 200;
1009 while (m_agentsInTransit.Contains(id) && count-- > 0)
1010 {
1011 //m_log.Debug(" >>> Waiting... " + count);
1012 Thread.Sleep(100);
1013 }
1014
1015 if (count > 0)
1016 return true;
1017 else
1018 return false;
1019 }
1020
1021 public bool ReleaseAgent(UUID id)
1022 {
1023 //m_log.Debug(" >>> ReleaseAgent called <<< ");
1024 return ResetFromTransit(id);
1025 }
1026
1027 public void SetInTransit(UUID id)
1028 {
1029 lock (m_agentsInTransit)
1030 {
1031 if (!m_agentsInTransit.Contains(id))
1032 m_agentsInTransit.Add(id);
1033 }
1034 }
1035
1036 protected bool ResetFromTransit(UUID id)
1037 {
1038 lock (m_agentsInTransit)
1039 {
1040 if (m_agentsInTransit.Contains(id))
1041 {
1042 m_agentsInTransit.Remove(id);
1043 return true;
1044 }
1045 }
1046 return false;
1047 }
1048
1049 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1050 {
1051 List<ulong> handles = new List<ulong>();
1052 foreach (GridRegion reg in neighbours)
1053 {
1054 handles.Add(reg.RegionHandle);
1055 }
1056 return handles;
1057 }
1058
1059 private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1060 {
1061 return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); });
1062 }
1063
1064// private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1065// {
1066// return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); });
1067// }
1068
1069 private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1070 {
1071 return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
1072 }
1073
1074 public void CrossAgentToNewRegion(Scene scene, ScenePresence agent, bool isFlying)
1075 {
1076 Vector3 pos = agent.AbsolutePosition;
1077 Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z);
1078 uint neighbourx = m_regionInfo.RegionLocX;
1079 uint neighboury = m_regionInfo.RegionLocY;
1080 const float boundaryDistance = 1.7f;
1081 Vector3 northCross = new Vector3(0,boundaryDistance, 0);
1082 Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0);
1083 Vector3 eastCross = new Vector3(boundaryDistance, 0, 0);
1084 Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0);
1085
1086 // distance to edge that will trigger crossing
1087
1088
1089 // distance into new region to place avatar
1090 const float enterDistance = 0.5f;
1091
1092 if (scene.TestBorderCross(pos + westCross, Cardinals.W))
1093 {
1094 if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1095 {
1096 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1097 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1098 }
1099 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1100 {
1101 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1102 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1103 {
1104 neighboury--;
1105 newpos.Y = Constants.RegionSize - enterDistance;
1106 }
1107 else
1108 {
1109 neighboury = b.TriggerRegionY;
1110 neighbourx = b.TriggerRegionX;
1111
1112 Vector3 newposition = pos;
1113 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1114 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1115 agent.ControllingClient.SendAgentAlertMessage(
1116 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1117 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1118 return;
1119 }
1120 }
1121
1122 Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W);
1123 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1124 {
1125 neighbourx--;
1126 newpos.X = Constants.RegionSize - enterDistance;
1127 }
1128 else
1129 {
1130 neighboury = ba.TriggerRegionY;
1131 neighbourx = ba.TriggerRegionX;
1132
1133
1134 Vector3 newposition = pos;
1135 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1136 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1137 agent.ControllingClient.SendAgentAlertMessage(
1138 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1139 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1140
1141
1142 return;
1143 }
1144
1145 }
1146 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E))
1147 {
1148 Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E);
1149 neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1150 newpos.X = enterDistance;
1151
1152 if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1153 {
1154 Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1155 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1156 {
1157 neighboury--;
1158 newpos.Y = Constants.RegionSize - enterDistance;
1159 }
1160 else
1161 {
1162 neighboury = ba.TriggerRegionY;
1163 neighbourx = ba.TriggerRegionX;
1164 Vector3 newposition = pos;
1165 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1166 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1167 agent.ControllingClient.SendAgentAlertMessage(
1168 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1169 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1170 return;
1171 }
1172 }
1173 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1174 {
1175 Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1176 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
1177 newpos.Y = enterDistance;
1178 }
1179
1180
1181 }
1182 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1183 {
1184 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1185 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1186 {
1187 neighboury--;
1188 newpos.Y = Constants.RegionSize - enterDistance;
1189 }
1190 else
1191 {
1192 neighboury = b.TriggerRegionY;
1193 neighbourx = b.TriggerRegionX;
1194 Vector3 newposition = pos;
1195 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1196 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1197 agent.ControllingClient.SendAgentAlertMessage(
1198 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1199 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1200 return;
1201 }
1202 }
1203 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1204 {
1205
1206 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1207 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1208 newpos.Y = enterDistance;
1209 }
1210
1211 /*
1212
1213 if (pos.X < boundaryDistance) //West
1214 {
1215 neighbourx--;
1216 newpos.X = Constants.RegionSize - enterDistance;
1217 }
1218 else if (pos.X > Constants.RegionSize - boundaryDistance) // East
1219 {
1220 neighbourx++;
1221 newpos.X = enterDistance;
1222 }
1223
1224 if (pos.Y < boundaryDistance) // South
1225 {
1226 neighboury--;
1227 newpos.Y = Constants.RegionSize - enterDistance;
1228 }
1229 else if (pos.Y > Constants.RegionSize - boundaryDistance) // North
1230 {
1231 neighboury++;
1232 newpos.Y = enterDistance;
1233 }
1234 */
1235
1236 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
1237 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d);
1238 }
1239
1240 public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY,
1241 Vector3 position,
1242 Scene initiatingScene);
1243
1244 public void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
1245 Scene initiatingScene)
1246 {
1247
1248 // This assumes that we know what our neighbors are.
1249
1250 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync;
1251 d.BeginInvoke(agent,regionX,regionY,position,initiatingScene,
1252 InformClientToInitiateTeleportToLocationCompleted,
1253 d);
1254 }
1255
1256 public void InformClientToInitiateTeleportToLocationAsync(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
1257 Scene initiatingScene)
1258 {
1259 Thread.Sleep(10000);
1260 IMessageTransferModule im = initiatingScene.RequestModuleInterface<IMessageTransferModule>();
1261 if (im != null)
1262 {
1263 UUID gotoLocation = Util.BuildFakeParcelID(
1264 Util.UIntsToLong(
1265 (regionX *
1266 (uint)Constants.RegionSize),
1267 (regionY *
1268 (uint)Constants.RegionSize)),
1269 (uint)(int)position.X,
1270 (uint)(int)position.Y,
1271 (uint)(int)position.Z);
1272 GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero,
1273 "Region", agent.UUID,
1274 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
1275 "", gotoLocation, false, new Vector3(127, 0, 0),
1276 new Byte[0]);
1277 im.SendInstantMessage(m, delegate(bool success)
1278 {
1279 m_log.DebugFormat("[CLIENT]: Client Initiating Teleport sending IM success = {0}", success);
1280 });
1281
1282 }
1283 }
1284
1285 private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar)
1286 {
1287 InformClientToInitateTeleportToLocationDelegate icon =
1288 (InformClientToInitateTeleportToLocationDelegate) iar.AsyncState;
1289 icon.EndInvoke(iar);
1290 }
1291
1292 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying);
1293
1294 /// <summary>
1295 /// This Closes child agents on neighboring regions
1296 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
1297 /// </summary>
1298 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying)
1299 {
1300 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
1301
1302 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
1303
1304 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
1305 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1306
1307 if (neighbourRegion != null && agent.ValidateAttachments())
1308 {
1309 pos = pos + (agent.Velocity);
1310
1311 //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
1312 //if (userInfo != null)
1313 //{
1314 // userInfo.DropInventory();
1315 //}
1316 //else
1317 //{
1318 // m_log.WarnFormat("[SCENE COMM]: No cached user info found for {0} {1} on leaving region {2}",
1319 // agent.Name, agent.UUID, agent.Scene.RegionInfo.RegionName);
1320 //}
1321
1322 //bool crossingSuccessful =
1323 // CrossToNeighbouringRegion(neighbourHandle, agent.ControllingClient.AgentId, pos,
1324 //isFlying);
1325
1326 SetInTransit(agent.UUID);
1327 AgentData cAgent = new AgentData();
1328 agent.CopyTo(cAgent);
1329 cAgent.Position = pos;
1330 if (isFlying)
1331 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1332 cAgent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
1333 "/agent/" + agent.UUID.ToString() + "/" + agent.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
1334
1335 m_interregionCommsOut.SendChildAgentUpdate(neighbourHandle, cAgent);
1336
1337 // Next, let's close the child agent connections that are too far away.
1338 agent.CloseChildAgents(neighbourx, neighboury);
1339
1340 //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
1341 agent.ControllingClient.RequestClientInfo();
1342
1343 //m_log.Debug("BEFORE CROSS");
1344 //Scene.DumpChildrenSeeds(UUID);
1345 //DumpKnownRegions();
1346 string agentcaps;
1347 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
1348 {
1349 m_log.ErrorFormat("[SCENE COMM]: No CAPS information for region handle {0}, exiting CrossToNewRegion.",
1350 neighbourRegion.RegionHandle);
1351 return agent;
1352 }
1353 // TODO Should construct this behind a method
1354 string capsPath =
1355 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
1356 + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/";
1357
1358 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
1359
1360 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
1361 if (eq != null)
1362 {
1363 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1364 capsPath, agent.UUID, agent.ControllingClient.SessionId);
1365 }
1366 else
1367 {
1368 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1369 capsPath);
1370 }
1371
1372 if (!WaitForCallback(agent.UUID))
1373 {
1374 ResetFromTransit(agent.UUID);
1375
1376 // Yikes! We should just have a ref to scene here.
1377 agent.Scene.InformClientOfNeighbours(agent);
1378
1379 return agent;
1380 }
1381
1382 agent.MakeChildAgent();
1383 // now we have a child agent in this region. Request all interesting data about other (root) agents
1384 agent.SendInitialFullUpdateToAllClients();
1385
1386 agent.CrossAttachmentsIntoNewRegion(neighbourHandle, true);
1387
1388 // m_scene.SendKillObject(m_localId);
1389
1390 agent.Scene.NotifyMyCoarseLocationChange();
1391 // the user may change their profile information in other region,
1392 // so the userinfo in UserProfileCache is not reliable any more, delete it
1393 if (agent.Scene.NeedSceneCacheClear(agent.UUID))
1394 {
1395 agent.Scene.CommsManager.UserProfileCacheService.RemoveUser(agent.UUID);
1396 m_log.DebugFormat(
1397 "[SCENE COMM]: User {0} is going to another region, profile cache removed", agent.UUID);
1398 }
1399 }
1400
1401 //m_log.Debug("AFTER CROSS");
1402 //Scene.DumpChildrenSeeds(UUID);
1403 //DumpKnownRegions();
1404 return agent;
1405 }
1406
1407 private void CrossAgentToNewRegionCompleted(IAsyncResult iar)
1408 {
1409 CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState;
1410 ScenePresence agent = icon.EndInvoke(iar);
1411
1412 // If the cross was successful, this agent is a child agent
1413 if (agent.IsChildAgent)
1414 {
1415 agent.Reset();
1416 }
1417 else // Not successful
1418 {
1419 //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
1420 //if (userInfo != null)
1421 //{
1422 // userInfo.FetchInventory();
1423 //}
1424 agent.RestoreInCurrentScene();
1425 }
1426 // In any case
1427 agent.NotInTransit();
1428
1429 //m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
1430 }
1431
1432
1433 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
1434 {
1435 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
1436 }
1437
1438 // deprecated as of 2008-08-27
1439 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
1440 {
1441 m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
1442 }
1443
1444 public void ClearUserAgent(UUID avatarID)
1445 {
1446 m_commsProvider.UserService.ClearUserAgent(avatarID);
1447 }
1448
1449 public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
1450 {
1451 m_commsProvider.AddNewUserFriend(friendlistowner, friend, perms);
1452 }
1453
1454 public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
1455 {
1456 m_commsProvider.UpdateUserFriendPerms(friendlistowner, friend, perms);
1457 }
1458
1459 public void RemoveUserFriend(UUID friendlistowner, UUID friend)
1460 {
1461 m_commsProvider.RemoveUserFriend(friendlistowner, friend);
1462 }
1463
1464 public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
1465 {
1466 return m_commsProvider.GetUserFriendList(friendlistowner);
1467 }
1468
1469 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
1470 {
1471 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
1472 }
1473
1474 public List<GridRegion> RequestNamedRegions(string name, int maxNumber) 304 public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
1475 { 305 {
1476 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); 306 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
1477 } 307 }
1478 308
1479 //private void Dump(string msg, List<ulong> handles)
1480 //{
1481 // m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg);
1482 // foreach (ulong handle in handles)
1483 // {
1484 // uint x, y;
1485 // Utils.LongToUInts(handle, out x, out y);
1486 // x = x / Constants.RegionSize;
1487 // y = y / Constants.RegionSize;
1488 // m_log.InfoFormat("({0}, {1})", x, y);
1489 // }
1490 //}
1491 } 309 }
1492} 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 6b95624..b8a937a 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{
@@ -225,7 +225,7 @@ namespace OpenSim.Region.Framework.Scenes
225 // Agent's Draw distance. 225 // Agent's Draw distance.
226 protected float m_DrawDistance; 226 protected float m_DrawDistance;
227 227
228 protected AvatarAppearance m_appearance; 228 protected AvatarAppearance m_appearance;
229 229
230 // neighbouring regions we have enabled a child agent in 230 // neighbouring regions we have enabled a child agent in
231 // holds the seed cap for the child agent in that region 231 // holds the seed cap for the child agent in that region
@@ -254,6 +254,8 @@ namespace OpenSim.Region.Framework.Scenes
254 254
255 // For teleports and crossings callbacks 255 // For teleports and crossings callbacks
256 string m_callbackURI; 256 string m_callbackURI;
257 UUID m_originRegionID;
258
257 ulong m_rootRegionHandle; 259 ulong m_rootRegionHandle;
258 260
259 /// <value> 261 /// <value>
@@ -1081,6 +1083,8 @@ namespace OpenSim.Region.Framework.Scenes
1081 /// </summary> 1083 /// </summary>
1082 public void CompleteMovement() 1084 public void CompleteMovement()
1083 { 1085 {
1086 //m_log.Debug("[SCENE PRESENCE]: CompleteMovement");
1087
1084 Vector3 look = Velocity; 1088 Vector3 look = Velocity;
1085 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1089 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1086 { 1090 {
@@ -1105,7 +1109,7 @@ namespace OpenSim.Region.Framework.Scenes
1105 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1109 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1106 { 1110 {
1107 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1111 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
1108 Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); 1112 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1109 m_callbackURI = null; 1113 m_callbackURI = null;
1110 } 1114 }
1111 1115
@@ -1113,6 +1117,17 @@ namespace OpenSim.Region.Framework.Scenes
1113 1117
1114 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 1118 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
1115 SendInitialData(); 1119 SendInitialData();
1120
1121 // Create child agents in neighbouring regions
1122 if (!m_isChildAgent)
1123 {
1124 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1125 if (m_agentTransfer != null)
1126 m_agentTransfer.EnableChildAgents(this);
1127 else
1128 m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active");
1129 }
1130
1116 } 1131 }
1117 1132
1118 /// <summary> 1133 /// <summary>
@@ -2171,6 +2186,7 @@ namespace OpenSim.Region.Framework.Scenes
2171 { 2186 {
2172 if (m_isChildAgent) 2187 if (m_isChildAgent)
2173 { 2188 {
2189 // WHAT???
2174 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); 2190 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!");
2175 2191
2176 // we have to reset the user's child agent connections. 2192 // we have to reset the user's child agent connections.
@@ -2194,7 +2210,9 @@ namespace OpenSim.Region.Framework.Scenes
2194 2210
2195 if (m_scene.SceneGridService != null) 2211 if (m_scene.SceneGridService != null)
2196 { 2212 {
2197 m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); 2213 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
2214 if (m_agentTransfer != null)
2215 m_agentTransfer.EnableChildAgents(this);
2198 } 2216 }
2199 2217
2200 return; 2218 return;
@@ -2491,14 +2509,9 @@ namespace OpenSim.Region.Framework.Scenes
2491 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2509 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
2492 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); 2510 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot));
2493 2511
2494 if (!m_isChildAgent)
2495 {
2496 m_scene.InformClientOfNeighbours(this);
2497 }
2498
2499 SendInitialFullUpdateToAllClients(); 2512 SendInitialFullUpdateToAllClients();
2500 SendAppearanceToAllOtherAgents(); 2513 SendAppearanceToAllOtherAgents();
2501 } 2514 }
2502 2515
2503 /// <summary> 2516 /// <summary>
2504 /// Tell the client for this scene presence what items it should be wearing now 2517 /// Tell the client for this scene presence what items it should be wearing now
@@ -2578,14 +2591,19 @@ namespace OpenSim.Region.Framework.Scenes
2578 } 2591 }
2579 } 2592 }
2580 } 2593 }
2594
2581 } 2595 }
2582 2596
2597
2583 #endregion Bake Cache Check 2598 #endregion Bake Cache Check
2584 2599
2585 m_appearance.SetAppearance(textureEntry, visualParams); 2600 m_appearance.SetAppearance(textureEntry, visualParams);
2586 if (m_appearance.AvatarHeight > 0) 2601 if (m_appearance.AvatarHeight > 0)
2587 SetHeight(m_appearance.AvatarHeight); 2602 SetHeight(m_appearance.AvatarHeight);
2588 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2603
2604 // This is not needed, because only the transient data changed
2605 //AvatarData adata = new AvatarData(m_appearance);
2606 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2589 2607
2590 SendAppearanceToAllOtherAgents(); 2608 SendAppearanceToAllOtherAgents();
2591 if (!m_startAnimationSet) 2609 if (!m_startAnimationSet)
@@ -2605,7 +2623,8 @@ namespace OpenSim.Region.Framework.Scenes
2605 public void SetWearable(int wearableId, AvatarWearable wearable) 2623 public void SetWearable(int wearableId, AvatarWearable wearable)
2606 { 2624 {
2607 m_appearance.SetWearable(wearableId, wearable); 2625 m_appearance.SetWearable(wearableId, wearable);
2608 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2626 AvatarData adata = new AvatarData(m_appearance);
2627 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2609 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); 2628 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2610 } 2629 }
2611 2630
@@ -2889,11 +2908,14 @@ namespace OpenSim.Region.Framework.Scenes
2889 // For now, assign god level 200 to anyone 2908 // For now, assign god level 200 to anyone
2890 // who is granted god powers, but has no god level set. 2909 // who is granted god powers, but has no god level set.
2891 // 2910 //
2892 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); 2911 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID);
2893 if (profile.UserProfile.GodLevel > 0) 2912 if (account != null)
2894 m_godlevel = profile.UserProfile.GodLevel; 2913 {
2895 else 2914 if (account.UserLevel > 0)
2896 m_godlevel = 200; 2915 m_godlevel = account.UserLevel;
2916 else
2917 m_godlevel = 200;
2918 }
2897 } 2919 }
2898 else 2920 else
2899 { 2921 {
@@ -2959,7 +2981,7 @@ namespace OpenSim.Region.Framework.Scenes
2959 public void CopyTo(AgentData cAgent) 2981 public void CopyTo(AgentData cAgent)
2960 { 2982 {
2961 cAgent.AgentID = UUID; 2983 cAgent.AgentID = UUID;
2962 cAgent.RegionHandle = m_rootRegionHandle; 2984 cAgent.RegionID = Scene.RegionInfo.RegionID;
2963 2985
2964 cAgent.Position = AbsolutePosition; 2986 cAgent.Position = AbsolutePosition;
2965 cAgent.Velocity = m_velocity; 2987 cAgent.Velocity = m_velocity;
@@ -3058,7 +3080,7 @@ namespace OpenSim.Region.Framework.Scenes
3058 3080
3059 public void CopyFrom(AgentData cAgent) 3081 public void CopyFrom(AgentData cAgent)
3060 { 3082 {
3061 m_rootRegionHandle = cAgent.RegionHandle; 3083 m_originRegionID = cAgent.RegionID;
3062 3084
3063 m_callbackURI = cAgent.CallbackURI; 3085 m_callbackURI = cAgent.CallbackURI;
3064 3086
@@ -3416,36 +3438,6 @@ namespace OpenSim.Region.Framework.Scenes
3416 } 3438 }
3417 } 3439 }
3418 3440
3419 public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent)
3420 {
3421 lock (m_attachments)
3422 {
3423 // Validate
3424 foreach (SceneObjectGroup gobj in m_attachments)
3425 {
3426 if (gobj == null || gobj.IsDeleted)
3427 return false;
3428 }
3429
3430 foreach (SceneObjectGroup gobj in m_attachments)
3431 {
3432 // If the prim group is null then something must have happened to it!
3433 if (gobj != null && gobj.RootPart != null)
3434 {
3435 // Set the parent localID to 0 so it transfers over properly.
3436 gobj.RootPart.SetParentLocalId(0);
3437 gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
3438 gobj.RootPart.IsAttachment = false;
3439 //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
3440 m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle);
3441 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent);
3442 }
3443 }
3444 m_attachments.Clear();
3445
3446 return true;
3447 }
3448 }
3449 3441
3450 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) 3442 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
3451 { 3443 {
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