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/EventManager.cs13
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs33
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs232
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs25
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs181
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs358
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs6
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs3
10 files changed, 282 insertions, 575 deletions
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 287d8d9..7424b24 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -32,6 +32,7 @@ using OpenSim.Framework;
32using OpenSim.Framework.Client; 32using OpenSim.Framework.Client;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using Caps=OpenSim.Framework.Capabilities.Caps; 34using Caps=OpenSim.Framework.Capabilities.Caps;
35using GridRegion = OpenSim.Services.Interfaces.GridRegion;
35 36
36namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
37{ 38{
@@ -305,6 +306,9 @@ namespace OpenSim.Region.Framework.Scenes
305 public delegate void Attach(uint localID, UUID itemID, UUID avatarID); 306 public delegate void Attach(uint localID, UUID itemID, UUID avatarID);
306 public event Attach OnAttach; 307 public event Attach OnAttach;
307 308
309 public delegate void RegionUp(GridRegion region);
310 public event RegionUp OnRegionUp;
311
308 public class MoneyTransferArgs : EventArgs 312 public class MoneyTransferArgs : EventArgs
309 { 313 {
310 public UUID sender; 314 public UUID sender;
@@ -446,6 +450,7 @@ namespace OpenSim.Region.Framework.Scenes
446 private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null; 450 private EmptyScriptCompileQueue handlerEmptyScriptCompileQueue = null;
447 451
448 private Attach handlerOnAttach = null; 452 private Attach handlerOnAttach = null;
453 private RegionUp handlerOnRegionUp = null;
449 454
450 public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID) 455 public void TriggerOnAttach(uint localID, UUID itemID, UUID avatarID)
451 { 456 {
@@ -1035,5 +1040,13 @@ namespace OpenSim.Region.Framework.Scenes
1035 if (handlerSetRootAgentScene != null) 1040 if (handlerSetRootAgentScene != null)
1036 handlerSetRootAgentScene(agentID, scene); 1041 handlerSetRootAgentScene(agentID, scene);
1037 } 1042 }
1043
1044 public void TriggerOnRegionUp(GridRegion otherRegion)
1045 {
1046 handlerOnRegionUp = OnRegionUp;
1047 if (handlerOnRegionUp != null)
1048 handlerOnRegionUp(otherRegion);
1049 }
1050
1038 } 1051 }
1039} 1052}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
index 62efd60..b6fa41d 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
@@ -35,6 +35,7 @@ using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients; 36using OpenSim.Framework.Communications.Clients;
37using OpenSim.Region.Framework.Scenes.Serialization; 37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Services.Interfaces;
38 39
39//using HyperGrid.Framework; 40//using HyperGrid.Framework;
40//using OpenSim.Region.Communications.Hypergrid; 41//using OpenSim.Region.Communications.Hypergrid;
@@ -50,6 +51,18 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
50// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>(); 51// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
51 52
52 private Scene m_scene; 53 private Scene m_scene;
54
55 private IHyperlinkService m_hyper;
56 IHyperlinkService HyperlinkService
57 {
58 get
59 {
60 if (m_hyper == null)
61 m_hyper = m_scene.RequestModuleInterface<IHyperlinkService>();
62 return m_hyper;
63 }
64 }
65
53 #endregion 66 #endregion
54 67
55 #region Constructor 68 #region Constructor
@@ -79,22 +92,6 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
79// return null; 92// return null;
80// } 93// }
81 94
82 private bool IsLocalUser(UUID userID)
83 {
84 CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
85
86 if (uinfo != null)
87 {
88 if (HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile))
89 {
90 m_log.Debug("[HGScene]: Home user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
91 return true;
92 }
93 }
94
95 m_log.Debug("[HGScene]: Foreign user " + uinfo.UserProfile.FirstName + " " + uinfo.UserProfile.SurName);
96 return false;
97 }
98 95
99 public AssetBase FetchAsset(string url, UUID assetID) 96 public AssetBase FetchAsset(string url, UUID assetID)
100 { 97 {
@@ -170,7 +167,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
170 167
171 public void Get(UUID assetID, UUID ownerID) 168 public void Get(UUID assetID, UUID ownerID)
172 { 169 {
173 if (!IsLocalUser(ownerID)) 170 if (!HyperlinkService.IsLocalUser(ownerID))
174 { 171 {
175 // Get the item from the remote asset server onto the local AssetCache 172 // Get the item from the remote asset server onto the local AssetCache
176 // and place an entry in m_assetMap 173 // and place an entry in m_assetMap
@@ -228,7 +225,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
228 225
229 public void Post(UUID assetID, UUID ownerID) 226 public void Post(UUID assetID, UUID ownerID)
230 { 227 {
231 if (!IsLocalUser(ownerID)) 228 if (!HyperlinkService.IsLocalUser(ownerID))
232 { 229 {
233 // Post the item from the local AssetCache onto the remote asset server 230 // Post the item from the local AssetCache onto the remote asset server
234 // and place an entry in m_assetMap 231 // and place an entry in m_assetMap
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
deleted file mode 100644
index a576feb..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
+++ /dev/null
@@ -1,232 +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.Net;
30using System.Reflection;
31using log4net;
32using OpenMetaverse;
33using OpenSim.Framework;
34
35namespace OpenSim.Region.Framework.Scenes.Hypergrid
36{
37 public class HGHyperlink
38 {
39 private static readonly ILog m_log =
40 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41 private static Random random = new Random();
42
43 public static RegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc)
44 {
45 string host = "127.0.0.1";
46 string portstr;
47 string regionName = "";
48 uint port = 9000;
49 string[] parts = mapName.Split(new char[] { ':' });
50 if (parts.Length >= 1)
51 {
52 host = parts[0];
53 }
54 if (parts.Length >= 2)
55 {
56 portstr = parts[1];
57 if (!UInt32.TryParse(portstr, out port))
58 regionName = parts[1];
59 }
60 // always take the last one
61 if (parts.Length >= 3)
62 {
63 regionName = parts[2];
64 }
65
66 // Sanity check. Don't ever link to this sim.
67 IPAddress ipaddr = null;
68 try
69 {
70 ipaddr = Util.GetHostFromDNS(host);
71 }
72 catch { }
73
74 if ((ipaddr != null) &&
75 !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
76 {
77 RegionInfo regInfo;
78 bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
79 if (success)
80 {
81 regInfo.RegionName = mapName;
82 return regInfo;
83 }
84 }
85
86 return null;
87 }
88
89 public static RegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
90 {
91 uint xloc = (uint)(random.Next(0, Int16.MaxValue));
92 return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
93 }
94
95 public static bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc,
96 string externalRegionName, uint externalPort, string externalHostName, out RegionInfo regInfo)
97 {
98 m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
99
100 regInfo = new RegionInfo();
101 regInfo.RegionName = externalRegionName;
102 regInfo.HttpPort = externalPort;
103 regInfo.ExternalHostName = externalHostName;
104 regInfo.RegionLocX = xloc;
105 regInfo.RegionLocY = yloc;
106
107 try
108 {
109 regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
110 }
111 catch (Exception e)
112 {
113 m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message);
114 return false;
115 }
116 regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
117
118 // Finally, link it
119 try
120 {
121 m_scene.CommsManager.GridService.RegisterRegion(regInfo);
122 }
123 catch (Exception e)
124 {
125 m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
126 return false;
127 }
128
129 uint x, y;
130 if (!Check4096(m_scene, regInfo, out x, out y))
131 {
132 m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
133 if (client != null)
134 client.SendAlertMessage("Region is too far (" + x + ", " + y + ")");
135 m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")");
136 return false;
137 }
138
139 if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y))
140 {
141 m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
142 if (client != null)
143 client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")");
144 m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")");
145 return false;
146 }
147
148 m_log.Debug("[HGrid]: link region succeeded");
149 return true;
150 }
151
152 public static bool TryUnlinkRegion(Scene m_scene, string mapName)
153 {
154 RegionInfo regInfo = null;
155 if (mapName.Contains(":"))
156 {
157 string host = "127.0.0.1";
158 //string portstr;
159 //string regionName = "";
160 uint port = 9000;
161 string[] parts = mapName.Split(new char[] { ':' });
162 if (parts.Length >= 1)
163 {
164 host = parts[0];
165 }
166// if (parts.Length >= 2)
167// {
168// portstr = parts[1];
169// if (!UInt32.TryParse(portstr, out port))
170// regionName = parts[1];
171// }
172 // always take the last one
173// if (parts.Length >= 3)
174// {
175// regionName = parts[2];
176// }
177 regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(host, port);
178 }
179 else
180 {
181 regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(mapName);
182 }
183 if (regInfo != null)
184 {
185 return m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
186 }
187 else
188 {
189 m_log.InfoFormat("[HGrid]: Region {0} not found", mapName);
190 return false;
191 }
192 }
193
194 /// <summary>
195 /// Cope with this viewer limitation.
196 /// </summary>
197 /// <param name="regInfo"></param>
198 /// <returns></returns>
199 public static bool Check4096(Scene m_scene, RegionInfo regInfo, out uint x, out uint y)
200 {
201 ulong realHandle;
202 if (UInt64.TryParse(regInfo.regionSecret, out realHandle))
203 {
204 Utils.LongToUInts(realHandle, out x, out y);
205 x = x / Constants.RegionSize;
206 y = y / Constants.RegionSize;
207
208 if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) ||
209 (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096))
210 {
211 return false;
212 }
213 return true;
214 }
215 else
216 {
217 m_scene.CommsManager.GridService.RegisterRegion(regInfo);
218 m_log.Debug("[HGrid]: Gnomes. Region deregistered.");
219 x = y = 0;
220 return false;
221 }
222 }
223
224 public static bool CheckCoords(uint thisx, uint thisy, uint x, uint y)
225 {
226 if ((thisx == x) && (thisy == y))
227 return false;
228 return true;
229 }
230
231 }
232}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
index bf55df7..b1981b6 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
@@ -29,6 +29,7 @@ using OpenMetaverse;
29using OpenSim.Framework; 29using OpenSim.Framework;
30using OpenSim.Framework.Communications.Cache; 30using OpenSim.Framework.Communications.Cache;
31using TPFlags = OpenSim.Framework.Constants.TeleportFlags; 31using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
32 33
33namespace OpenSim.Region.Framework.Scenes.Hypergrid 34namespace OpenSim.Region.Framework.Scenes.Hypergrid
34{ 35{
@@ -50,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
50 51
51 if (UserProfile != null) 52 if (UserProfile != null)
52 { 53 {
53 RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); 54 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
54 //if (regionInfo != null) 55 //if (regionInfo != null)
55 //{ 56 //{
56 // UserProfile.HomeRegionID = regionInfo.RegionID; 57 // UserProfile.HomeRegionID = regionInfo.RegionID;
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
index efc644d..1217f9b 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
@@ -38,6 +38,8 @@ using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache; 38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Capabilities; 39using OpenSim.Framework.Capabilities;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Services.Interfaces;
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41 43
42namespace OpenSim.Region.Framework.Scenes.Hypergrid 44namespace OpenSim.Region.Framework.Scenes.Hypergrid
43{ 45{
@@ -45,11 +47,19 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
45 { 47 {
46 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
47 49
48 public readonly IHyperlink m_hg; 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 }
49 60
50 public HGSceneCommunicationService(CommunicationsManager commsMan, IHyperlink hg) : base(commsMan) 61 public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan)
51 { 62 {
52 m_hg = hg;
53 } 63 }
54 64
55 65
@@ -112,7 +122,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
112 } 122 }
113 else 123 else
114 { 124 {
115 RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); 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
116 if (reg != null) 129 if (reg != null)
117 { 130 {
118 131
@@ -125,13 +138,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
125 /// Hypergrid mod start 138 /// Hypergrid mod start
126 /// 139 ///
127 /// 140 ///
128 bool isHyperLink = m_hg.IsHyperlinkRegion(reg.RegionHandle); 141 bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null);
129 bool isHomeUser = true; 142 bool isHomeUser = true;
130 ulong realHandle = regionHandle; 143 ulong realHandle = regionHandle;
131 CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID); 144 CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID);
132 if (uinfo != null) 145 if (uinfo != null)
133 { 146 {
134 isHomeUser = HGNetworkServersInfo.Singleton.IsLocalUser(uinfo.UserProfile); 147 isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID);
135 realHandle = m_hg.FindRegionHandle(regionHandle); 148 realHandle = m_hg.FindRegionHandle(regionHandle);
136 m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString()); 149 m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString());
137 } 150 }
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d8478a2..bb47ff4 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -49,6 +49,7 @@ using OpenSim.Region.Framework.Scenes.Serialization;
49using OpenSim.Region.Physics.Manager; 49using OpenSim.Region.Physics.Manager;
50using Timer=System.Timers.Timer; 50using Timer=System.Timers.Timer;
51using TPFlags = OpenSim.Framework.Constants.TeleportFlags; 51using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
52using GridRegion = OpenSim.Services.Interfaces.GridRegion;
52 53
53namespace OpenSim.Region.Framework.Scenes 54namespace OpenSim.Region.Framework.Scenes
54{ 55{
@@ -193,6 +194,26 @@ namespace OpenSim.Region.Framework.Scenes
193 } 194 }
194 } 195 }
195 196
197 protected IGridService m_GridService = null;
198
199 public IGridService GridService
200 {
201 get
202 {
203 if (m_GridService == null)
204 {
205 m_GridService = RequestModuleInterface<IGridService>();
206
207 if (m_GridService == null)
208 {
209 throw new Exception("No IGridService available. This could happen if the config_include folder doesn't exist or if the OpenSim.ini [Architecture] section isn't set. Please also check that you have the correct version of your inventory service dll. Sometimes old versions of this dll will still exist. Do a clean checkout and re-create the opensim.ini from the opensim.ini.example.");
210 }
211 }
212
213 return m_GridService;
214 }
215 }
216
196 protected IXMLRPC m_xmlrpcModule; 217 protected IXMLRPC m_xmlrpcModule;
197 protected IWorldComm m_worldCommModule; 218 protected IWorldComm m_worldCommModule;
198 protected IAvatarFactory m_AvatarFactory; 219 protected IAvatarFactory m_AvatarFactory;
@@ -566,10 +587,7 @@ namespace OpenSim.Region.Framework.Scenes
566 } 587 }
567 588
568 /// <summary> 589 /// <summary>
569 /// Another region is up. Gets called from Grid Comms: 590 /// Another region is up.
570 /// (OGS1 -> LocalBackEnd -> RegionListened -> SceneCommunicationService)
571 /// We have to tell all our ScenePresences about it, and add it to the
572 /// neighbor list.
573 /// 591 ///
574 /// We only add it to the neighbor list if it's within 1 region from here. 592 /// We only add it to the neighbor list if it's within 1 region from here.
575 /// Agents may have draw distance values that cross two regions though, so 593 /// Agents may have draw distance values that cross two regions though, so
@@ -578,47 +596,30 @@ namespace OpenSim.Region.Framework.Scenes
578 /// </summary> 596 /// </summary>
579 /// <param name="otherRegion">RegionInfo handle for the new region.</param> 597 /// <param name="otherRegion">RegionInfo handle for the new region.</param>
580 /// <returns>True after all operations complete, throws exceptions otherwise.</returns> 598 /// <returns>True after all operations complete, throws exceptions otherwise.</returns>
581 public override bool OtherRegionUp(RegionInfo otherRegion) 599 public override void OtherRegionUp(GridRegion otherRegion)
582 { 600 {
583 m_log.InfoFormat("[SCENE]: Region {0} up in coords {1}-{2}", otherRegion.RegionName, otherRegion.RegionLocX, otherRegion.RegionLocY); 601 uint xcell = (uint)((int)otherRegion.RegionLocX / (int)Constants.RegionSize);
602 uint ycell = (uint)((int)otherRegion.RegionLocY / (int)Constants.RegionSize);
603 m_log.InfoFormat("[SCENE]: (on region {0}): Region {1} up in coords {2}-{3}",
604 RegionInfo.RegionName, otherRegion.RegionName, xcell, ycell);
584 605
585 if (RegionInfo.RegionHandle != otherRegion.RegionHandle) 606 if (RegionInfo.RegionHandle != otherRegion.RegionHandle)
586 { 607 {
587 for (int i = 0; i < m_neighbours.Count; i++)
588 {
589 // The purpose of this loop is to re-update the known neighbors
590 // when another region comes up on top of another one.
591 // The latest region in that location ends up in the
592 // 'known neighbors list'
593 // Additionally, the commFailTF property gets reset to false.
594 if (m_neighbours[i].RegionHandle == otherRegion.RegionHandle)
595 {
596 lock (m_neighbours)
597 {
598 m_neighbours[i] = otherRegion;
599
600 }
601 }
602 }
603
604 // If the value isn't in the neighbours, add it.
605 // If the RegionInfo isn't exact but is for the same XY World location,
606 // then the above loop will fix that.
607
608 if (!(CheckNeighborRegion(otherRegion)))
609 {
610 lock (m_neighbours)
611 {
612 m_neighbours.Add(otherRegion);
613 //m_log.Info("[UP]: " + otherRegion.RegionHandle.ToString());
614 }
615 }
616 608
617 // If these are cast to INT because long + negative values + abs returns invalid data 609 // If these are cast to INT because long + negative values + abs returns invalid data
618 int resultX = Math.Abs((int)otherRegion.RegionLocX - (int)RegionInfo.RegionLocX); 610 int resultX = Math.Abs((int)xcell - (int)RegionInfo.RegionLocX);
619 int resultY = Math.Abs((int)otherRegion.RegionLocY - (int)RegionInfo.RegionLocY); 611 int resultY = Math.Abs((int)ycell - (int)RegionInfo.RegionLocY);
620 if (resultX <= 1 && resultY <= 1) 612 if (resultX <= 1 && resultY <= 1)
621 { 613 {
614 // Let the grid service module know, so this can be cached
615 m_eventManager.TriggerOnRegionUp(otherRegion);
616
617 RegionInfo regInfo = new RegionInfo(xcell, ycell, otherRegion.InternalEndPoint, otherRegion.ExternalHostName);
618 regInfo.RegionID = otherRegion.RegionID;
619 regInfo.RegionName = otherRegion.RegionName;
620 regInfo.ScopeID = otherRegion.ScopeID;
621 regInfo.ExternalHostName = otherRegion.ExternalHostName;
622
622 try 623 try
623 { 624 {
624 ForEachScenePresence(delegate(ScenePresence agent) 625 ForEachScenePresence(delegate(ScenePresence agent)
@@ -632,7 +633,7 @@ namespace OpenSim.Region.Framework.Scenes
632 List<ulong> old = new List<ulong>(); 633 List<ulong> old = new List<ulong>();
633 old.Add(otherRegion.RegionHandle); 634 old.Add(otherRegion.RegionHandle);
634 agent.DropOldNeighbours(old); 635 agent.DropOldNeighbours(old);
635 InformClientOfNeighbor(agent, otherRegion); 636 InformClientOfNeighbor(agent, regInfo);
636 } 637 }
637 } 638 }
638 ); 639 );
@@ -643,6 +644,7 @@ namespace OpenSim.Region.Framework.Scenes
643 // This shouldn't happen too often anymore. 644 // This shouldn't happen too often anymore.
644 m_log.Error("[SCENE]: Couldn't inform client of regionup because we got a null reference exception"); 645 m_log.Error("[SCENE]: Couldn't inform client of regionup because we got a null reference exception");
645 } 646 }
647
646 } 648 }
647 else 649 else
648 { 650 {
@@ -651,7 +653,6 @@ namespace OpenSim.Region.Framework.Scenes
651 otherRegion.RegionLocY.ToString() + ")"); 653 otherRegion.RegionLocY.ToString() + ")");
652 } 654 }
653 } 655 }
654 return true;
655 } 656 }
656 657
657 public void AddNeighborRegion(RegionInfo region) 658 public void AddNeighborRegion(RegionInfo region)
@@ -683,9 +684,10 @@ namespace OpenSim.Region.Framework.Scenes
683 } 684 }
684 685
685 // Alias IncomingHelloNeighbour OtherRegionUp, for now 686 // Alias IncomingHelloNeighbour OtherRegionUp, for now
686 public bool IncomingHelloNeighbour(RegionInfo neighbour) 687 public GridRegion IncomingHelloNeighbour(RegionInfo neighbour)
687 { 688 {
688 return OtherRegionUp(neighbour); 689 OtherRegionUp(new GridRegion(neighbour));
690 return new GridRegion(RegionInfo);
689 } 691 }
690 692
691 /// <summary> 693 /// <summary>
@@ -1336,24 +1338,31 @@ namespace OpenSim.Region.Framework.Scenes
1336 RegisterCommsEvents(); 1338 RegisterCommsEvents();
1337 1339
1338 // These two 'commands' *must be* next to each other or sim rebooting fails. 1340 // These two 'commands' *must be* next to each other or sim rebooting fails.
1339 m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); 1341 //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo);
1342
1343 GridRegion region = new GridRegion(RegionInfo);
1344 bool success = GridService.RegisterRegion(RegionInfo.ScopeID, region);
1345 if (!success)
1346 throw new Exception("Can't register with grid");
1347
1348 m_sceneGridService.SetScene(this);
1340 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); 1349 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
1341 1350
1342 Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings(); 1351 //Dictionary<string, string> dGridSettings = m_sceneGridService.GetGridSettings();
1343 1352
1344 if (dGridSettings.ContainsKey("allow_forceful_banlines")) 1353 //if (dGridSettings.ContainsKey("allow_forceful_banlines"))
1345 { 1354 //{
1346 if (dGridSettings["allow_forceful_banlines"] != "TRUE") 1355 // if (dGridSettings["allow_forceful_banlines"] != "TRUE")
1347 { 1356 // {
1348 m_log.Info("[GRID]: Grid is disabling forceful parcel banlists"); 1357 // m_log.Info("[GRID]: Grid is disabling forceful parcel banlists");
1349 EventManager.TriggerSetAllowForcefulBan(false); 1358 // EventManager.TriggerSetAllowForcefulBan(false);
1350 } 1359 // }
1351 else 1360 // else
1352 { 1361 // {
1353 m_log.Info("[GRID]: Grid is allowing forceful parcel banlists"); 1362 // m_log.Info("[GRID]: Grid is allowing forceful parcel banlists");
1354 EventManager.TriggerSetAllowForcefulBan(true); 1363 // EventManager.TriggerSetAllowForcefulBan(true);
1355 } 1364 // }
1356 } 1365 //}
1357 } 1366 }
1358 1367
1359 /// <summary> 1368 /// <summary>
@@ -2717,10 +2726,12 @@ namespace OpenSim.Region.Framework.Scenes
2717 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); 2726 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId);
2718 if (UserProfile != null) 2727 if (UserProfile != null)
2719 { 2728 {
2720 RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegionID); 2729 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
2721 if (regionInfo == null) 2730 if (regionInfo == null)
2722 { 2731 {
2723 regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion); 2732 uint x = 0, y = 0;
2733 Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
2734 regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
2724 if (regionInfo != null) // home region can be away temporarily, too 2735 if (regionInfo != null) // home region can be away temporarily, too
2725 { 2736 {
2726 UserProfile.HomeRegionID = regionInfo.RegionID; 2737 UserProfile.HomeRegionID = regionInfo.RegionID;
@@ -3074,7 +3085,7 @@ namespace OpenSim.Region.Framework.Scenes
3074 m_sceneGridService.OnExpectUser += HandleNewUserConnection; 3085 m_sceneGridService.OnExpectUser += HandleNewUserConnection;
3075 m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing; 3086 m_sceneGridService.OnAvatarCrossingIntoRegion += AgentCrossing;
3076 m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent; 3087 m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent;
3077 m_sceneGridService.OnRegionUp += OtherRegionUp; 3088 //m_eventManager.OnRegionUp += OtherRegionUp;
3078 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate; 3089 //m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3079 m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup; 3090 m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
3080 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar; 3091 //m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
@@ -3102,7 +3113,7 @@ namespace OpenSim.Region.Framework.Scenes
3102 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar; 3113 //m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
3103 m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup; 3114 m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
3104 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3115 //m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3105 m_sceneGridService.OnRegionUp -= OtherRegionUp; 3116 //m_eventManager.OnRegionUp -= OtherRegionUp;
3106 m_sceneGridService.OnExpectUser -= HandleNewUserConnection; 3117 m_sceneGridService.OnExpectUser -= HandleNewUserConnection;
3107 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing; 3118 m_sceneGridService.OnAvatarCrossingIntoRegion -= AgentCrossing;
3108 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; 3119 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
@@ -3111,7 +3122,11 @@ namespace OpenSim.Region.Framework.Scenes
3111 if (m_interregionCommsIn != null) 3122 if (m_interregionCommsIn != null)
3112 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate; 3123 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3113 3124
3125 // this does nothing; should be removed
3114 m_sceneGridService.Close(); 3126 m_sceneGridService.Close();
3127
3128 if (!GridService.DeregisterRegion(m_regInfo.RegionID))
3129 m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName);
3115 } 3130 }
3116 3131
3117 /// <summary> 3132 /// <summary>
@@ -3557,30 +3572,6 @@ namespace OpenSim.Region.Framework.Scenes
3557 } 3572 }
3558 3573
3559 /// <summary> 3574 /// <summary>
3560 /// Requests information about this region from gridcomms
3561 /// </summary>
3562 /// <param name="regionHandle"></param>
3563 /// <returns></returns>
3564 public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
3565 {
3566 return m_sceneGridService.RequestNeighbouringRegionInfo(regionHandle);
3567 }
3568
3569 /// <summary>
3570 /// Requests textures for map from minimum region to maximum region in world cordinates
3571 /// </summary>
3572 /// <param name="remoteClient"></param>
3573 /// <param name="minX"></param>
3574 /// <param name="minY"></param>
3575 /// <param name="maxX"></param>
3576 /// <param name="maxY"></param>
3577 public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
3578 {
3579 m_log.DebugFormat("[MAPBLOCK]: {0}-{1}, {2}-{3}", minX, minY, maxX, maxY);
3580 m_sceneGridService.RequestMapBlocks(remoteClient, minX, minY, maxX, maxY);
3581 }
3582
3583 /// <summary>
3584 /// Tries to teleport agent to other region. 3575 /// Tries to teleport agent to other region.
3585 /// </summary> 3576 /// </summary>
3586 /// <param name="remoteClient"></param> 3577 /// <param name="remoteClient"></param>
@@ -3591,7 +3582,7 @@ namespace OpenSim.Region.Framework.Scenes
3591 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position, 3582 public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
3592 Vector3 lookat, uint teleportFlags) 3583 Vector3 lookat, uint teleportFlags)
3593 { 3584 {
3594 RegionInfo regionInfo = m_sceneGridService.RequestClosestRegion(regionName); 3585 GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName);
3595 if (regionInfo == null) 3586 if (regionInfo == null)
3596 { 3587 {
3597 // can't find the region: Tell viewer and abort 3588 // can't find the region: Tell viewer and abort
@@ -3680,7 +3671,7 @@ namespace OpenSim.Region.Framework.Scenes
3680 /// <param name="position"></param> 3671 /// <param name="position"></param>
3681 public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position) 3672 public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position)
3682 { 3673 {
3683 RegionInfo info = CommsManager.GridService.RequestNeighbourInfo(regionID); 3674 GridRegion info = GridService.GetRegionByUUID(UUID.Zero, regionID);
3684 3675
3685 if (info == null) 3676 if (info == null)
3686 { 3677 {
@@ -3864,10 +3855,6 @@ namespace OpenSim.Region.Framework.Scenes
3864 return LandChannel.GetLandObject((int)x, (int)y).landData; 3855 return LandChannel.GetLandObject((int)x, (int)y).landData;
3865 } 3856 }
3866 3857
3867 public RegionInfo RequestClosestRegion(string name)
3868 {
3869 return m_sceneGridService.RequestClosestRegion(name);
3870 }
3871 3858
3872 #endregion 3859 #endregion
3873 3860
@@ -4178,14 +4165,18 @@ namespace OpenSim.Region.Framework.Scenes
4178 4165
4179 public void RegionHandleRequest(IClientAPI client, UUID regionID) 4166 public void RegionHandleRequest(IClientAPI client, UUID regionID)
4180 { 4167 {
4181 RegionInfo info; 4168 ulong handle = 0;
4182 if (regionID == RegionInfo.RegionID) 4169 if (regionID == RegionInfo.RegionID)
4183 info = RegionInfo; 4170 handle = RegionInfo.RegionHandle;
4184 else 4171 else
4185 info = CommsManager.GridService.RequestNeighbourInfo(regionID); 4172 {
4173 GridRegion r = GridService.GetRegionByUUID(UUID.Zero, regionID);
4174 if (r != null)
4175 handle = r.RegionHandle;
4176 }
4186 4177
4187 if (info != null) 4178 if (handle != 0)
4188 client.SendRegionHandle(regionID, info.RegionHandle); 4179 client.SendRegionHandle(regionID, handle);
4189 } 4180 }
4190 4181
4191 public void TerrainUnAcked(IClientAPI client, int patchX, int patchY) 4182 public void TerrainUnAcked(IClientAPI client, int patchX, int patchY)
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 2a82237..2af98cc 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Communications.Cache; 37using OpenSim.Framework.Communications.Cache;
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
40namespace OpenSim.Region.Framework.Scenes 41namespace OpenSim.Region.Framework.Scenes
41{ 42{
@@ -227,7 +228,7 @@ namespace OpenSim.Region.Framework.Scenes
227 return false; 228 return false;
228 } 229 }
229 230
230 public abstract bool OtherRegionUp(RegionInfo thisRegion); 231 public abstract void OtherRegionUp(GridRegion otherRegion);
231 232
232 public virtual string GetSimulatorVersion() 233 public virtual string GetSimulatorVersion()
233 { 234 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 5f2333e..4a2db5e 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -41,6 +41,7 @@ using OpenSim.Framework.Capabilities;
41using OpenSim.Region.Framework.Interfaces; 41using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
43using OSD = OpenMetaverse.StructuredData.OSD; 43using OSD = OpenMetaverse.StructuredData.OSD;
44using GridRegion = OpenSim.Services.Interfaces.GridRegion;
44 45
45namespace OpenSim.Region.Framework.Scenes 46namespace OpenSim.Region.Framework.Scenes
46{ 47{
@@ -58,6 +59,7 @@ namespace OpenSim.Region.Framework.Scenes
58 protected CommunicationsManager m_commsProvider; 59 protected CommunicationsManager m_commsProvider;
59 protected IInterregionCommsOut m_interregionCommsOut; 60 protected IInterregionCommsOut m_interregionCommsOut;
60 protected RegionInfo m_regionInfo; 61 protected RegionInfo m_regionInfo;
62 protected Scene m_scene;
61 63
62 protected RegionCommsListener regionCommsHost; 64 protected RegionCommsListener regionCommsHost;
63 65
@@ -91,10 +93,10 @@ namespace OpenSim.Region.Framework.Scenes
91 /// </summary> 93 /// </summary>
92 public event PrimCrossing OnPrimCrossingIntoRegion; 94 public event PrimCrossing OnPrimCrossingIntoRegion;
93 95
94 /// <summary> 96 ///// <summary>
95 /// A New Region is up and available 97 ///// A New Region is up and available
96 /// </summary> 98 ///// </summary>
97 public event RegionUp OnRegionUp; 99 //public event RegionUp OnRegionUp;
98 100
99 /// <summary> 101 /// <summary>
100 /// We have a child agent for this avatar and we're getting a status update about it 102 /// We have a child agent for this avatar and we're getting a status update about it
@@ -117,7 +119,7 @@ namespace OpenSim.Region.Framework.Scenes
117 private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim; 119 private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
118 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; 120 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
119 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; 121 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
120 private RegionUp handlerRegionUp = null; // OnRegionUp; 122 //private RegionUp handlerRegionUp = null; // OnRegionUp;
121 private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate; 123 private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
122 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar; 124 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
123 private LogOffUser handlerLogOffUser = null; 125 private LogOffUser handlerLogOffUser = null;
@@ -131,6 +133,13 @@ namespace OpenSim.Region.Framework.Scenes
131 m_agentsInTransit = new List<UUID>(); 133 m_agentsInTransit = new List<UUID>();
132 } 134 }
133 135
136 public void SetScene(Scene s)
137 {
138 m_scene = s;
139 m_regionInfo = s.RegionInfo;
140 m_interregionCommsOut = m_scene.RequestModuleInterface<IInterregionCommsOut>();
141 }
142
134 /// <summary> 143 /// <summary>
135 /// Register a region with the grid 144 /// Register a region with the grid
136 /// </summary> 145 /// </summary>
@@ -138,40 +147,30 @@ namespace OpenSim.Region.Framework.Scenes
138 /// <exception cref="System.Exception">Thrown if region registration fails.</exception> 147 /// <exception cref="System.Exception">Thrown if region registration fails.</exception>
139 public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos) 148 public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos)
140 { 149 {
141 m_interregionCommsOut = comms_out; 150 //m_interregionCommsOut = comms_out;
142 151
143 m_regionInfo = regionInfos; 152 //m_regionInfo = regionInfos;
144 m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName; 153 //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
145 regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); 154 //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
146 155
147 if (regionCommsHost != null) 156 //if (regionCommsHost != null)
148 { 157 //{
149 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString()); 158 // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
150 159
151 regionCommsHost.debugRegionName = regionInfos.RegionName; 160 // regionCommsHost.debugRegionName = regionInfos.RegionName;
152 regionCommsHost.OnExpectPrim += IncomingPrimCrossing; 161 // regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
153 regionCommsHost.OnExpectUser += NewUserConnection; 162 // regionCommsHost.OnExpectUser += NewUserConnection;
154 regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; 163 // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
155 regionCommsHost.OnCloseAgentConnection += CloseConnection; 164 // regionCommsHost.OnCloseAgentConnection += CloseConnection;
156 regionCommsHost.OnRegionUp += newRegionUp; 165 // regionCommsHost.OnRegionUp += newRegionUp;
157 regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; 166 // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
158 regionCommsHost.OnLogOffUser += GridLogOffUser; 167 // regionCommsHost.OnLogOffUser += GridLogOffUser;
159 regionCommsHost.OnGetLandData += FetchLandData; 168 // regionCommsHost.OnGetLandData += FetchLandData;
160 } 169 //}
161 else 170 //else
162 { 171 //{
163 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null"); 172 // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
164 } 173 //}
165 }
166
167 /// <summary>
168 /// Returns a region with the name closest to string provided
169 /// </summary>
170 /// <param name="name">Partial Region Name for matching</param>
171 /// <returns>Region Information for the region</returns>
172 public RegionInfo RequestClosestRegion(string name)
173 {
174 return m_commsProvider.GridService.RequestClosestRegion(name);
175 } 174 }
176 175
177 /// <summary> 176 /// <summary>
@@ -180,30 +179,31 @@ namespace OpenSim.Region.Framework.Scenes
180 /// </summary> 179 /// </summary>
181 public void Close() 180 public void Close()
182 { 181 {
183 if (regionCommsHost != null) 182
184 { 183 //if (regionCommsHost != null)
185 regionCommsHost.OnLogOffUser -= GridLogOffUser; 184 //{
186 regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; 185 // regionCommsHost.OnLogOffUser -= GridLogOffUser;
187 regionCommsHost.OnRegionUp -= newRegionUp; 186 // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
188 regionCommsHost.OnExpectUser -= NewUserConnection; 187 // regionCommsHost.OnRegionUp -= newRegionUp;
189 regionCommsHost.OnExpectPrim -= IncomingPrimCrossing; 188 // regionCommsHost.OnExpectUser -= NewUserConnection;
190 regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; 189 // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
191 regionCommsHost.OnCloseAgentConnection -= CloseConnection; 190 // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
192 regionCommsHost.OnGetLandData -= FetchLandData; 191 // regionCommsHost.OnCloseAgentConnection -= CloseConnection;
192 // regionCommsHost.OnGetLandData -= FetchLandData;
193 193
194 try 194 // try
195 { 195 // {
196 m_commsProvider.GridService.DeregisterRegion(m_regionInfo); 196 // m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
197 } 197 // }
198 catch (Exception e) 198 // catch (Exception e)
199 { 199 // {
200 m_log.ErrorFormat( 200 // m_log.ErrorFormat(
201 "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing", 201 // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
202 m_regionInfo.RegionName, e); 202 // m_regionInfo.RegionName, e);
203 } 203 // }
204 204
205 regionCommsHost = null; 205 // regionCommsHost = null;
206 } 206 //}
207 } 207 }
208 208
209 #region CommsManager Event handlers 209 #region CommsManager Event handlers
@@ -239,22 +239,6 @@ namespace OpenSim.Region.Framework.Scenes
239 } 239 }
240 240
241 /// <summary> 241 /// <summary>
242 /// A New Region is now available. Inform the scene that there is a new region available.
243 /// </summary>
244 /// <param name="region">Information about the new region that is available</param>
245 /// <returns>True if the event was handled</returns>
246 protected bool newRegionUp(RegionInfo region)
247 {
248 handlerRegionUp = OnRegionUp;
249 if (handlerRegionUp != null)
250 {
251 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName);
252 handlerRegionUp(region);
253 }
254 return true;
255 }
256
257 /// <summary>
258 /// Inform the scene that we've got an update about a child agent that we have 242 /// Inform the scene that we've got an update about a child agent that we have
259 /// </summary> 243 /// </summary>
260 /// <param name="cAgentData"></param> 244 /// <param name="cAgentData"></param>
@@ -337,7 +321,7 @@ namespace OpenSim.Region.Framework.Scenes
337 #region Inform Client of Neighbours 321 #region Inform Client of Neighbours
338 322
339 private delegate void InformClientOfNeighbourDelegate( 323 private delegate void InformClientOfNeighbourDelegate(
340 ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, IPEndPoint endPoint, bool newAgent); 324 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
341 325
342 private void InformClientOfNeighbourCompleted(IAsyncResult iar) 326 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
343 { 327 {
@@ -355,7 +339,7 @@ namespace OpenSim.Region.Framework.Scenes
355 /// <param name="a"></param> 339 /// <param name="a"></param>
356 /// <param name="regionHandle"></param> 340 /// <param name="regionHandle"></param>
357 /// <param name="endPoint"></param> 341 /// <param name="endPoint"></param>
358 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, 342 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
359 IPEndPoint endPoint, bool newAgent) 343 IPEndPoint endPoint, bool newAgent)
360 { 344 {
361 // Let's wait just a little to give time to originating regions to catch up with closing child agents 345 // Let's wait just a little to give time to originating regions to catch up with closing child agents
@@ -373,8 +357,7 @@ namespace OpenSim.Region.Framework.Scenes
373 357
374 string reason = String.Empty; 358 string reason = String.Empty;
375 359
376 //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a); 360
377
378 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason); 361 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason);
379 362
380 if (regionAccepted && newAgent) 363 if (regionAccepted && newAgent)
@@ -407,17 +390,7 @@ namespace OpenSim.Region.Framework.Scenes
407 390
408 } 391 }
409 392
410 public void RequestNeighbors(RegionInfo region) 393 public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
411 {
412 // List<SimpleRegionInfo> neighbours =
413 m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
414 //IPEndPoint blah = new IPEndPoint();
415
416 //blah.Address = region.RemotingAddress;
417 //blah.Port = region.RemotingPort;
418 }
419
420 public List<SimpleRegionInfo> RequestNeighbors(Scene pScene, uint pRegionLocX, uint pRegionLocY)
421 { 394 {
422 Border[] northBorders = pScene.NorthBorders.ToArray(); 395 Border[] northBorders = pScene.NorthBorders.ToArray();
423 Border[] southBorders = pScene.SouthBorders.ToArray(); 396 Border[] southBorders = pScene.SouthBorders.ToArray();
@@ -427,50 +400,34 @@ namespace OpenSim.Region.Framework.Scenes
427 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. 400 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
428 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1) 401 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
429 { 402 {
430 return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); 403 return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
431 } 404 }
432 else 405 else
433 { 406 {
434 Vector2 extent = Vector2.Zero; 407 Vector2 extent = Vector2.Zero;
435 for (int i=0;i<eastBorders.Length;i++) 408 for (int i = 0; i < eastBorders.Length; i++)
436 { 409 {
437 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; 410 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
438 } 411 }
439 for (int i=0;i<northBorders.Length;i++) 412 for (int i = 0; i < northBorders.Length; i++)
440 { 413 {
441 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; 414 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
442 } 415 }
443 416
444 List<SimpleRegionInfo> neighbourList = new List<SimpleRegionInfo>();
445
446 // Loss of fraction on purpose 417 // Loss of fraction on purpose
447 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; 418 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
448 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; 419 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
449 420
450 int startX = (int) pRegionLocX - 1; 421 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
451 int startY = (int) pRegionLocY - 1; 422 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
452 423
453 int endX = (int) pRegionLocX + (int)extent.X; 424 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
454 int endY = (int) pRegionLocY + (int)extent.Y; 425 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
455 426
456 for (int i=startX;i<endX;i++) 427 List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
457 { 428 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
458 for (int j=startY;j<endY;j++) 429
459 { 430 return neighbours;
460 // Skip CurrentRegion
461 if (i == (int)pRegionLocX && j == (int)pRegionLocY)
462 continue;
463
464 ulong regionHandle = Util.UIntsToLong((uint)(i * Constants.RegionSize),
465 (uint)(j * Constants.RegionSize));
466 RegionInfo neighborreg = m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
467 if (neighborreg != null)
468 {
469 neighbourList.Add(neighborreg);
470 }
471 }
472 }
473 return neighbourList;
474 //SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo() 431 //SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo()
475 //return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); 432 //return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY);
476 } 433 }
@@ -482,29 +439,28 @@ namespace OpenSim.Region.Framework.Scenes
482 /// </summary> 439 /// </summary>
483 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours) 440 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
484 { 441 {
485 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); 442 //List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
443 List<GridRegion> neighbours = new List<GridRegion>();
486 444
487 //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 445 ////m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
488 for (int i = 0; i < lstneighbours.Count; i++) 446 //for (int i = 0; i < lstneighbours.Count; i++)
489 { 447 //{
490 // We don't want to keep sending to regions that consistently fail on comms. 448 // // We don't want to keep sending to regions that consistently fail on comms.
491 if (!(lstneighbours[i].commFailTF)) 449 // if (!(lstneighbours[i].commFailTF))
492 { 450 // {
493 neighbours.Add(new SimpleRegionInfo(lstneighbours[i])); 451 // neighbours.Add(new SimpleRegionInfo(lstneighbours[i]));
494 } 452 // }
495 } 453 //}
496 // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be 454 // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be
497 // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/ 455 // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/
498 if (m_regionInfo != null) 456 if (m_regionInfo != null)
499 { 457 {
500 neighbours = 458 neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
501 RequestNeighbors(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
502 } 459 }
503 else 460 else
504 { 461 {
505 m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?"); 462 m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?");
506 } 463 }
507
508 464
509 /// We need to find the difference between the new regions where there are no child agents 465 /// We need to find the difference between the new regions where there are no child agents
510 /// and the regions where there are already child agents. We only send notification to the former. 466 /// and the regions where there are already child agents. We only send notification to the former.
@@ -547,8 +503,9 @@ namespace OpenSim.Region.Framework.Scenes
547 503
548 /// Create the necessary child agents 504 /// Create the necessary child agents
549 List<AgentCircuitData> cagents = new List<AgentCircuitData>(); 505 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
550 foreach (SimpleRegionInfo neighbour in neighbours) 506 //foreach (SimpleRegionInfo neighbour in neighbours)
551 { 507 foreach (GridRegion neighbour in neighbours)
508 {
552 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle) 509 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
553 { 510 {
554 511
@@ -588,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes
588 545
589 bool newAgent = false; 546 bool newAgent = false;
590 int count = 0; 547 int count = 0;
591 foreach (SimpleRegionInfo neighbour in neighbours) 548 foreach (GridRegion neighbour in neighbours)
592 { 549 {
593 // Don't do it if there's already an agent in that region 550 // Don't do it if there's already an agent in that region
594 if (newRegions.Contains(neighbour.RegionHandle)) 551 if (newRegions.Contains(neighbour.RegionHandle))
@@ -641,7 +598,7 @@ namespace OpenSim.Region.Framework.Scenes
641 /// This informs a single neighboring region about agent "avatar". 598 /// This informs a single neighboring region about agent "avatar".
642 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 599 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
643 /// </summary> 600 /// </summary>
644 public void InformNeighborChildAgent(ScenePresence avatar, SimpleRegionInfo region) 601 public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
645 { 602 {
646 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); 603 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
647 agent.BaseFolder = UUID.Zero; 604 agent.BaseFolder = UUID.Zero;
@@ -672,61 +629,63 @@ namespace OpenSim.Region.Framework.Scenes
672 /// <param name="regionhandle"></param> 629 /// <param name="regionhandle"></param>
673 private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle) 630 private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
674 { 631 {
675 m_log.Info("[INTERGRID]: Starting to inform neighbors that I'm here"); 632 uint x = 0, y = 0;
676 //RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port); 633 Utils.LongToUInts(regionhandle, out x, out y);
677
678 //bool regionAccepted =
679 // m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region), regionhandle);
680 634
681 //bool regionAccepted = m_interregionCommsOut.SendHelloNeighbour(regionhandle, region); 635 GridRegion neighbour = null;
682 bool regionAccepted = false;
683 if (neighbourService != null) 636 if (neighbourService != null)
684 regionAccepted = neighbourService.HelloNeighbour(regionhandle, region); 637 neighbour = neighbourService.HelloNeighbour(regionhandle, region);
685 else 638 else
686 m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region"); 639 m_log.DebugFormat("[SCS]: No neighbour service provided for informing neigbhours of this region");
687 640
688 if (regionAccepted) 641 if (neighbour != null)
689 { 642 {
690 m_log.Info("[INTERGRID]: Completed informing neighbors that I'm here"); 643 m_log.DebugFormat("[INTERGRID]: Successfully informed neighbour {0}-{1} that I'm here", x / Constants.RegionSize, y / Constants.RegionSize);
691 handlerRegionUp = OnRegionUp; 644 m_scene.EventManager.TriggerOnRegionUp(neighbour);
692
693 // yes, we're notifying ourselves.
694 if (handlerRegionUp != null)
695 handlerRegionUp(region);
696 } 645 }
697 else 646 else
698 { 647 {
699 m_log.Warn("[INTERGRID]: Failed to inform neighbors that I'm here."); 648 m_log.WarnFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
700 } 649 }
701 } 650 }
702 651
703 /// <summary> 652
704 /// Called by scene when region is initialized (not always when it's listening for agents)
705 /// This is an inter-region message that informs the surrounding neighbors that the sim is up.
706 /// </summary>
707 public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region) 653 public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
708 { 654 {
709 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); 655 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
710 656
711 657 for (int x = (int)region.RegionLocX - 1; x <= region.RegionLocX + 1; x++)
712 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); 658 for (int y = (int)region.RegionLocY - 1; y <= region.RegionLocY + 1; y++)
713 // This stays uncached because we don't already know about our neighbors at this point. 659 if (!((x == region.RegionLocX) && (y == region.RegionLocY))) // skip this region
714 neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 660 {
715 if (neighbours != null) 661 ulong handle = Utils.UIntsToLong((uint)x * Constants.RegionSize, (uint)y * Constants.RegionSize);
716 { 662 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
717 for (int i = 0; i < neighbours.Count; i++)
718 {
719 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
720 663
721 d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle, 664 d.BeginInvoke(neighbourService, region, handle,
722 InformNeighborsThatRegionisUpCompleted, 665 InformNeighborsThatRegionisUpCompleted,
723 d); 666 d);
724 } 667 }
725 } 668
669 //List<GridRegion> neighbours = new List<GridRegion>();
670 //// This stays uncached because we don't already know about our neighbors at this point.
671
672 //neighbours = m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
673 //if (neighbours != null)
674 //{
675 // for (int i = 0; i < neighbours.Count; i++)
676 // {
677 // InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
678
679 // d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle,
680 // InformNeighborsThatRegionisUpCompleted,
681 // d);
682 // }
683 //}
726 684
727 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region)); 685 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
728 } 686 }
729 687
688
730 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle); 689 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle);
731 690
732 /// <summary> 691 /// <summary>
@@ -822,41 +781,6 @@ namespace OpenSim.Region.Framework.Scenes
822 } 781 }
823 } 782 }
824 783
825 /// <summary>
826 /// Helper function to request neighbors from grid-comms
827 /// </summary>
828 /// <param name="regionHandle"></param>
829 /// <returns></returns>
830 public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
831 {
832 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionHandle.ToString());
833 return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
834 }
835
836 /// <summary>
837 /// Helper function to request neighbors from grid-comms
838 /// </summary>
839 /// <param name="regionID"></param>
840 /// <returns></returns>
841 public virtual RegionInfo RequestNeighbouringRegionInfo(UUID regionID)
842 {
843 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionID);
844 return m_commsProvider.GridService.RequestNeighbourInfo(regionID);
845 }
846
847 /// <summary>
848 /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
849 /// </summary>
850 /// <param name="minX"></param>
851 /// <param name="minY"></param>
852 /// <param name="maxX"></param>
853 /// <param name="maxY"></param>
854 public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
855 {
856 List<MapBlockData> mapBlocks;
857 mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4);
858 remoteClient.SendMapBlock(mapBlocks, 0);
859 }
860 784
861 /// <summary> 785 /// <summary>
862 /// Try to teleport an agent to a new region. 786 /// Try to teleport an agent to a new region.
@@ -921,7 +845,10 @@ namespace OpenSim.Region.Framework.Scenes
921 } 845 }
922 else 846 else
923 { 847 {
924 RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); 848 uint x = 0, y = 0;
849 Utils.LongToUInts(regionHandle, out x, out y);
850 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
851
925 if (reg != null) 852 if (reg != null)
926 { 853 {
927 m_log.DebugFormat( 854 m_log.DebugFormat(
@@ -1228,10 +1155,10 @@ namespace OpenSim.Region.Framework.Scenes
1228 return false; 1155 return false;
1229 } 1156 }
1230 1157
1231 private List<ulong> NeighbourHandles(List<SimpleRegionInfo> neighbours) 1158 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1232 { 1159 {
1233 List<ulong> handles = new List<ulong>(); 1160 List<ulong> handles = new List<ulong>();
1234 foreach (SimpleRegionInfo reg in neighbours) 1161 foreach (GridRegion reg in neighbours)
1235 { 1162 {
1236 handles.Add(reg.RegionHandle); 1163 handles.Add(reg.RegionHandle);
1237 } 1164 }
@@ -1482,7 +1409,10 @@ namespace OpenSim.Region.Framework.Scenes
1482 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury); 1409 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
1483 1410
1484 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); 1411 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
1485 SimpleRegionInfo neighbourRegion = RequestNeighbouringRegionInfo(neighbourHandle); 1412
1413 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
1414 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1415
1486 if (neighbourRegion != null && agent.ValidateAttachments()) 1416 if (neighbourRegion != null && agent.ValidateAttachments())
1487 { 1417 {
1488 pos = pos + (agent.Velocity); 1418 pos = pos + (agent.Velocity);
@@ -1609,11 +1539,6 @@ namespace OpenSim.Region.Framework.Scenes
1609 } 1539 }
1610 1540
1611 1541
1612 public Dictionary<string, string> GetGridSettings()
1613 {
1614 return m_commsProvider.GridService.GetGridSettings();
1615 }
1616
1617 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat) 1542 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
1618 { 1543 {
1619 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat); 1544 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
@@ -1650,19 +1575,14 @@ namespace OpenSim.Region.Framework.Scenes
1650 return m_commsProvider.GetUserFriendList(friendlistowner); 1575 return m_commsProvider.GetUserFriendList(friendlistowner);
1651 } 1576 }
1652 1577
1653 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
1654 {
1655 return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
1656 }
1657
1658 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) 1578 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
1659 { 1579 {
1660 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); 1580 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
1661 } 1581 }
1662 1582
1663 public List<RegionInfo> RequestNamedRegions(string name, int maxNumber) 1583 public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
1664 { 1584 {
1665 return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber); 1585 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
1666 } 1586 }
1667 1587
1668 //private void Dump(string msg, List<ulong> handles) 1588 //private void Dump(string msg, List<ulong> handles)
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6772f75..286b7ca 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -36,6 +36,7 @@ using OpenSim.Framework.Communications.Cache;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes.Types; 37using OpenSim.Region.Framework.Scenes.Types;
38using OpenSim.Region.Physics.Manager; 38using OpenSim.Region.Physics.Manager;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
39 40
40namespace OpenSim.Region.Framework.Scenes 41namespace OpenSim.Region.Framework.Scenes
41{ 42{
@@ -2934,8 +2935,9 @@ namespace OpenSim.Region.Framework.Scenes
2934 else if (dir > 3 && dir < 7) // Heading Sout 2935 else if (dir > 3 && dir < 7) // Heading Sout
2935 neighboury--; 2936 neighboury--;
2936 2937
2937 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); 2938 int x = (int)(neighbourx * Constants.RegionSize);
2938 SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle); 2939 int y = (int)(neighboury * Constants.RegionSize);
2940 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y);
2939 2941
2940 if (neighbourRegion == null) 2942 if (neighbourRegion == null)
2941 { 2943 {
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
index f6737a5..5c9e66f 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneBaseTests.cs
@@ -29,6 +29,7 @@ using System;
29using NUnit.Framework; 29using NUnit.Framework;
30using OpenMetaverse; 30using OpenMetaverse;
31using OpenSim.Framework; 31using OpenSim.Framework;
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
32 33
33namespace OpenSim.Region.Framework.Scenes.Tests 34namespace OpenSim.Region.Framework.Scenes.Tests
34{ 35{
@@ -65,7 +66,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
65 throw new NotImplementedException(); 66 throw new NotImplementedException();
66 } 67 }
67 68
68 public override bool OtherRegionUp(RegionInfo thisRegion) 69 public override void OtherRegionUp(GridRegion otherRegion)
69 { 70 {
70 throw new NotImplementedException(); 71 throw new NotImplementedException();
71 } 72 }