aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs')
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs275
1 files changed, 108 insertions, 167 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 56cd87d..60e89e0 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
@@ -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
@@ -337,7 +337,7 @@ namespace OpenSim.Region.Framework.Scenes
337 #region Inform Client of Neighbours 337 #region Inform Client of Neighbours
338 338
339 private delegate void InformClientOfNeighbourDelegate( 339 private delegate void InformClientOfNeighbourDelegate(
340 ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, IPEndPoint endPoint, bool newAgent); 340 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
341 341
342 private void InformClientOfNeighbourCompleted(IAsyncResult iar) 342 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
343 { 343 {
@@ -355,7 +355,7 @@ namespace OpenSim.Region.Framework.Scenes
355 /// <param name="a"></param> 355 /// <param name="a"></param>
356 /// <param name="regionHandle"></param> 356 /// <param name="regionHandle"></param>
357 /// <param name="endPoint"></param> 357 /// <param name="endPoint"></param>
358 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, 358 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
359 IPEndPoint endPoint, bool newAgent) 359 IPEndPoint endPoint, bool newAgent)
360 { 360 {
361 // Let's wait just a little to give time to originating regions to catch up with closing child agents 361 // Let's wait just a little to give time to originating regions to catch up with closing child agents
@@ -371,11 +371,15 @@ namespace OpenSim.Region.Framework.Scenes
371 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort 371 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
372 + "/CAPS/" + a.CapsPath + "0000/"; 372 + "/CAPS/" + a.CapsPath + "0000/";
373 373
374 m_log.DebugFormat("[XXX] CAPS = {0}", capsPath);
375 m_log.DebugFormat("[XXX] ExternalEndPoint = {0}", endPoint.ToString());
376
374 string reason = String.Empty; 377 string reason = String.Empty;
375 378
376 //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a); 379 //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a);
377 380
378 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason); 381 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason);
382 m_log.DebugFormat("[XXX] Here 1 {0}", regionAccepted);
379 383
380 if (regionAccepted && newAgent) 384 if (regionAccepted && newAgent)
381 { 385 {
@@ -390,6 +394,7 @@ namespace OpenSim.Region.Framework.Scenes
390 } 394 }
391 #endregion 395 #endregion
392 396
397 m_log.DebugFormat("[XXX] HERE 2");
393 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID); 398 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
394 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath); 399 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
395 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}", 400 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}",
@@ -407,17 +412,7 @@ namespace OpenSim.Region.Framework.Scenes
407 412
408 } 413 }
409 414
410 public void RequestNeighbors(RegionInfo region) 415 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 { 416 {
422 Border[] northBorders = pScene.NorthBorders.ToArray(); 417 Border[] northBorders = pScene.NorthBorders.ToArray();
423 Border[] southBorders = pScene.SouthBorders.ToArray(); 418 Border[] southBorders = pScene.SouthBorders.ToArray();
@@ -427,50 +422,34 @@ namespace OpenSim.Region.Framework.Scenes
427 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement. 422 // 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) 423 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
429 { 424 {
430 return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); 425 return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
431 } 426 }
432 else 427 else
433 { 428 {
434 Vector2 extent = Vector2.Zero; 429 Vector2 extent = Vector2.Zero;
435 for (int i=0;i<eastBorders.Length;i++) 430 for (int i = 0; i < eastBorders.Length; i++)
436 { 431 {
437 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X; 432 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
438 } 433 }
439 for (int i=0;i<northBorders.Length;i++) 434 for (int i = 0; i < northBorders.Length; i++)
440 { 435 {
441 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y; 436 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
442 } 437 }
443 438
444 List<SimpleRegionInfo> neighbourList = new List<SimpleRegionInfo>();
445
446 // Loss of fraction on purpose 439 // Loss of fraction on purpose
447 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; 440 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
448 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; 441 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
449 442
450 int startX = (int) pRegionLocX - 1; 443 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
451 int startY = (int) pRegionLocY - 1; 444 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
452 445
453 int endX = (int) pRegionLocX + (int)extent.X; 446 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
454 int endY = (int) pRegionLocY + (int)extent.Y; 447 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
455 448
456 for (int i=startX;i<endX;i++) 449 List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
457 { 450 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
458 for (int j=startY;j<endY;j++) 451
459 { 452 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() 453 //SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo()
475 //return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); 454 //return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY);
476 } 455 }
@@ -482,23 +461,24 @@ namespace OpenSim.Region.Framework.Scenes
482 /// </summary> 461 /// </summary>
483 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours) 462 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
484 { 463 {
485 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); 464 //List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
465 List<GridRegion> neighbours = new List<GridRegion>();
486 466
487 //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 467 ////m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
488 for (int i = 0; i < lstneighbours.Count; i++) 468 //for (int i = 0; i < lstneighbours.Count; i++)
489 { 469 //{
490 // We don't want to keep sending to regions that consistently fail on comms. 470 // // We don't want to keep sending to regions that consistently fail on comms.
491 if (!(lstneighbours[i].commFailTF)) 471 // if (!(lstneighbours[i].commFailTF))
492 { 472 // {
493 neighbours.Add(new SimpleRegionInfo(lstneighbours[i])); 473 // neighbours.Add(new SimpleRegionInfo(lstneighbours[i]));
494 } 474 // }
495 } 475 //}
496 // we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be 476 // 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 :/ 477 // So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/
498 if (m_regionInfo != null) 478 if (m_regionInfo != null)
499 { 479 {
500 neighbours = 480 neighbours =
501 RequestNeighbors(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 481 RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
502 } 482 }
503 else 483 else
504 { 484 {
@@ -547,8 +527,9 @@ namespace OpenSim.Region.Framework.Scenes
547 527
548 /// Create the necessary child agents 528 /// Create the necessary child agents
549 List<AgentCircuitData> cagents = new List<AgentCircuitData>(); 529 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
550 foreach (SimpleRegionInfo neighbour in neighbours) 530 //foreach (SimpleRegionInfo neighbour in neighbours)
551 { 531 foreach (GridRegion neighbour in neighbours)
532 {
552 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle) 533 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
553 { 534 {
554 535
@@ -588,7 +569,7 @@ namespace OpenSim.Region.Framework.Scenes
588 569
589 bool newAgent = false; 570 bool newAgent = false;
590 int count = 0; 571 int count = 0;
591 foreach (SimpleRegionInfo neighbour in neighbours) 572 foreach (GridRegion neighbour in neighbours)
592 { 573 {
593 // Don't do it if there's already an agent in that region 574 // Don't do it if there's already an agent in that region
594 if (newRegions.Contains(neighbour.RegionHandle)) 575 if (newRegions.Contains(neighbour.RegionHandle))
@@ -641,7 +622,7 @@ namespace OpenSim.Region.Framework.Scenes
641 /// This informs a single neighboring region about agent "avatar". 622 /// This informs a single neighboring region about agent "avatar".
642 /// Calls an asynchronous method to do so.. so it doesn't lag the sim. 623 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
643 /// </summary> 624 /// </summary>
644 public void InformNeighborChildAgent(ScenePresence avatar, SimpleRegionInfo region) 625 public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
645 { 626 {
646 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); 627 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
647 agent.BaseFolder = UUID.Zero; 628 agent.BaseFolder = UUID.Zero;
@@ -700,18 +681,16 @@ namespace OpenSim.Region.Framework.Scenes
700 } 681 }
701 } 682 }
702 683
703 /// <summary> 684
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) 685 public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
708 { 686 {
709 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName); 687 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
710 688
711 689
712 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); 690 List<GridRegion> neighbours = new List<GridRegion>();
713 // This stays uncached because we don't already know about our neighbors at this point. 691 // This stays uncached because we don't already know about our neighbors at this point.
714 neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 692
693 neighbours = m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
715 if (neighbours != null) 694 if (neighbours != null)
716 { 695 {
717 for (int i = 0; i < neighbours.Count; i++) 696 for (int i = 0; i < neighbours.Count; i++)
@@ -727,6 +706,7 @@ namespace OpenSim.Region.Framework.Scenes
727 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region)); 706 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
728 } 707 }
729 708
709
730 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle); 710 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle);
731 711
732 /// <summary> 712 /// <summary>
@@ -822,41 +802,6 @@ namespace OpenSim.Region.Framework.Scenes
822 } 802 }
823 } 803 }
824 804
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 805
861 /// <summary> 806 /// <summary>
862 /// Try to teleport an agent to a new region. 807 /// Try to teleport an agent to a new region.
@@ -921,7 +866,10 @@ namespace OpenSim.Region.Framework.Scenes
921 } 866 }
922 else 867 else
923 { 868 {
924 RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle); 869 uint x = 0, y = 0;
870 Utils.LongToUInts(regionHandle, out x, out y);
871 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
872
925 if (reg != null) 873 if (reg != null)
926 { 874 {
927 m_log.DebugFormat( 875 m_log.DebugFormat(
@@ -1228,10 +1176,10 @@ namespace OpenSim.Region.Framework.Scenes
1228 return false; 1176 return false;
1229 } 1177 }
1230 1178
1231 private List<ulong> NeighbourHandles(List<SimpleRegionInfo> neighbours) 1179 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1232 { 1180 {
1233 List<ulong> handles = new List<ulong>(); 1181 List<ulong> handles = new List<ulong>();
1234 foreach (SimpleRegionInfo reg in neighbours) 1182 foreach (GridRegion reg in neighbours)
1235 { 1183 {
1236 handles.Add(reg.RegionHandle); 1184 handles.Add(reg.RegionHandle);
1237 } 1185 }
@@ -1482,7 +1430,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); 1430 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
1483 1431
1484 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize)); 1432 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
1485 SimpleRegionInfo neighbourRegion = RequestNeighbouringRegionInfo(neighbourHandle); 1433
1434 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
1435 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1436
1486 if (neighbourRegion != null && agent.ValidateAttachments()) 1437 if (neighbourRegion != null && agent.ValidateAttachments())
1487 { 1438 {
1488 pos = pos + (agent.Velocity); 1439 pos = pos + (agent.Velocity);
@@ -1609,11 +1560,6 @@ namespace OpenSim.Region.Framework.Scenes
1609 } 1560 }
1610 1561
1611 1562
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) 1563 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
1618 { 1564 {
1619 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat); 1565 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
@@ -1650,19 +1596,14 @@ namespace OpenSim.Region.Framework.Scenes
1650 return m_commsProvider.GetUserFriendList(friendlistowner); 1596 return m_commsProvider.GetUserFriendList(friendlistowner);
1651 } 1597 }
1652 1598
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) 1599 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
1659 { 1600 {
1660 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); 1601 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
1661 } 1602 }
1662 1603
1663 public List<RegionInfo> RequestNamedRegions(string name, int maxNumber) 1604 public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
1664 { 1605 {
1665 return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber); 1606 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
1666 } 1607 }
1667 1608
1668 //private void Dump(string msg, List<ulong> handles) 1609 //private void Dump(string msg, List<ulong> handles)