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.cs367
1 files changed, 147 insertions, 220 deletions
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 204c319..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,11 +59,19 @@ 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
64 protected List<UUID> m_agentsInTransit; 66 protected List<UUID> m_agentsInTransit;
65 67
68 public bool RegionLoginsEnabled
69 {
70 get { return m_regionLoginsEnabled; }
71 set { m_regionLoginsEnabled = value; }
72 }
73 private bool m_regionLoginsEnabled = false;
74
66 /// <summary> 75 /// <summary>
67 /// An agent is crossing into this region 76 /// An agent is crossing into this region
68 /// </summary> 77 /// </summary>
@@ -84,10 +93,10 @@ namespace OpenSim.Region.Framework.Scenes
84 /// </summary> 93 /// </summary>
85 public event PrimCrossing OnPrimCrossingIntoRegion; 94 public event PrimCrossing OnPrimCrossingIntoRegion;
86 95
87 /// <summary> 96 ///// <summary>
88 /// A New Region is up and available 97 ///// A New Region is up and available
89 /// </summary> 98 ///// </summary>
90 public event RegionUp OnRegionUp; 99 //public event RegionUp OnRegionUp;
91 100
92 /// <summary> 101 /// <summary>
93 /// 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
@@ -110,7 +119,7 @@ namespace OpenSim.Region.Framework.Scenes
110 private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim; 119 private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
111 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection; 120 private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
112 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion; 121 private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
113 private RegionUp handlerRegionUp = null; // OnRegionUp; 122 //private RegionUp handlerRegionUp = null; // OnRegionUp;
114 private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate; 123 private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
115 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar; 124 //private RemoveKnownRegionsFromAvatarList handlerRemoveKnownRegionFromAvatar = null; // OnRemoveKnownRegionFromAvatar;
116 private LogOffUser handlerLogOffUser = null; 125 private LogOffUser handlerLogOffUser = null;
@@ -124,6 +133,13 @@ namespace OpenSim.Region.Framework.Scenes
124 m_agentsInTransit = new List<UUID>(); 133 m_agentsInTransit = new List<UUID>();
125 } 134 }
126 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
127 /// <summary> 143 /// <summary>
128 /// Register a region with the grid 144 /// Register a region with the grid
129 /// </summary> 145 /// </summary>
@@ -131,40 +147,30 @@ namespace OpenSim.Region.Framework.Scenes
131 /// <exception cref="System.Exception">Thrown if region registration fails.</exception> 147 /// <exception cref="System.Exception">Thrown if region registration fails.</exception>
132 public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos) 148 public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos)
133 { 149 {
134 m_interregionCommsOut = comms_out; 150 //m_interregionCommsOut = comms_out;
135 151
136 m_regionInfo = regionInfos; 152 //m_regionInfo = regionInfos;
137 m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName; 153 //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
138 regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo); 154 //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
139 155
140 if (regionCommsHost != null) 156 //if (regionCommsHost != null)
141 { 157 //{
142 //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());
143 159
144 regionCommsHost.debugRegionName = regionInfos.RegionName; 160 // regionCommsHost.debugRegionName = regionInfos.RegionName;
145 regionCommsHost.OnExpectPrim += IncomingPrimCrossing; 161 // regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
146 regionCommsHost.OnExpectUser += NewUserConnection; 162 // regionCommsHost.OnExpectUser += NewUserConnection;
147 regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing; 163 // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
148 regionCommsHost.OnCloseAgentConnection += CloseConnection; 164 // regionCommsHost.OnCloseAgentConnection += CloseConnection;
149 regionCommsHost.OnRegionUp += newRegionUp; 165 // regionCommsHost.OnRegionUp += newRegionUp;
150 regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate; 166 // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
151 regionCommsHost.OnLogOffUser += GridLogOffUser; 167 // regionCommsHost.OnLogOffUser += GridLogOffUser;
152 regionCommsHost.OnGetLandData += FetchLandData; 168 // regionCommsHost.OnGetLandData += FetchLandData;
153 } 169 //}
154 else 170 //else
155 { 171 //{
156 //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");
157 } 173 //}
158 }
159
160 /// <summary>
161 /// Returns a region with the name closest to string provided
162 /// </summary>
163 /// <param name="name">Partial Region Name for matching</param>
164 /// <returns>Region Information for the region</returns>
165 public RegionInfo RequestClosestRegion(string name)
166 {
167 return m_commsProvider.GridService.RequestClosestRegion(name);
168 } 174 }
169 175
170 /// <summary> 176 /// <summary>
@@ -173,30 +179,31 @@ namespace OpenSim.Region.Framework.Scenes
173 /// </summary> 179 /// </summary>
174 public void Close() 180 public void Close()
175 { 181 {
176 if (regionCommsHost != null) 182
177 { 183 //if (regionCommsHost != null)
178 regionCommsHost.OnLogOffUser -= GridLogOffUser; 184 //{
179 regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate; 185 // regionCommsHost.OnLogOffUser -= GridLogOffUser;
180 regionCommsHost.OnRegionUp -= newRegionUp; 186 // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
181 regionCommsHost.OnExpectUser -= NewUserConnection; 187 // regionCommsHost.OnRegionUp -= newRegionUp;
182 regionCommsHost.OnExpectPrim -= IncomingPrimCrossing; 188 // regionCommsHost.OnExpectUser -= NewUserConnection;
183 regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing; 189 // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
184 regionCommsHost.OnCloseAgentConnection -= CloseConnection; 190 // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
185 regionCommsHost.OnGetLandData -= FetchLandData; 191 // regionCommsHost.OnCloseAgentConnection -= CloseConnection;
192 // regionCommsHost.OnGetLandData -= FetchLandData;
186 193
187 try 194 // try
188 { 195 // {
189 m_commsProvider.GridService.DeregisterRegion(m_regionInfo); 196 // m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
190 } 197 // }
191 catch (Exception e) 198 // catch (Exception e)
192 { 199 // {
193 m_log.ErrorFormat( 200 // m_log.ErrorFormat(
194 "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing", 201 // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
195 m_regionInfo.RegionName, e); 202 // m_regionInfo.RegionName, e);
196 } 203 // }
197 204
198 regionCommsHost = null; 205 // regionCommsHost = null;
199 } 206 //}
200 } 207 }
201 208
202 #region CommsManager Event handlers 209 #region CommsManager Event handlers
@@ -232,22 +239,6 @@ namespace OpenSim.Region.Framework.Scenes
232 } 239 }
233 240
234 /// <summary> 241 /// <summary>
235 /// A New Region is now available. Inform the scene that there is a new region available.
236 /// </summary>
237 /// <param name="region">Information about the new region that is available</param>
238 /// <returns>True if the event was handled</returns>
239 protected bool newRegionUp(RegionInfo region)
240 {
241 handlerRegionUp = OnRegionUp;
242 if (handlerRegionUp != null)
243 {
244 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: newRegionUp Fired for User:" + region.RegionName);
245 handlerRegionUp(region);
246 }
247 return true;
248 }
249
250 /// <summary>
251 /// 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
252 /// </summary> 243 /// </summary>
253 /// <param name="cAgentData"></param> 244 /// <param name="cAgentData"></param>
@@ -330,7 +321,7 @@ namespace OpenSim.Region.Framework.Scenes
330 #region Inform Client of Neighbours 321 #region Inform Client of Neighbours
331 322
332 private delegate void InformClientOfNeighbourDelegate( 323 private delegate void InformClientOfNeighbourDelegate(
333 ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, IPEndPoint endPoint, bool newAgent); 324 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
334 325
335 private void InformClientOfNeighbourCompleted(IAsyncResult iar) 326 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
336 { 327 {
@@ -348,7 +339,7 @@ namespace OpenSim.Region.Framework.Scenes
348 /// <param name="a"></param> 339 /// <param name="a"></param>
349 /// <param name="regionHandle"></param> 340 /// <param name="regionHandle"></param>
350 /// <param name="endPoint"></param> 341 /// <param name="endPoint"></param>
351 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, 342 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
352 IPEndPoint endPoint, bool newAgent) 343 IPEndPoint endPoint, bool newAgent)
353 { 344 {
354 // 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
@@ -366,8 +357,7 @@ namespace OpenSim.Region.Framework.Scenes
366 357
367 string reason = String.Empty; 358 string reason = String.Empty;
368 359
369 //bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a); 360
370
371 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason); 361 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason);
372 362
373 if (regionAccepted && newAgent) 363 if (regionAccepted && newAgent)
@@ -400,17 +390,7 @@ namespace OpenSim.Region.Framework.Scenes
400 390
401 } 391 }
402 392
403 public void RequestNeighbors(RegionInfo region) 393 public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
404 {
405 // List<SimpleRegionInfo> neighbours =
406 m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
407 //IPEndPoint blah = new IPEndPoint();
408
409 //blah.Address = region.RemotingAddress;
410 //blah.Port = region.RemotingPort;
411 }
412
413 public List<SimpleRegionInfo> RequestNeighbors(Scene pScene, uint pRegionLocX, uint pRegionLocY)
414 { 394 {
415 Border[] northBorders = pScene.NorthBorders.ToArray(); 395 Border[] northBorders = pScene.NorthBorders.ToArray();
416 Border[] southBorders = pScene.SouthBorders.ToArray(); 396 Border[] southBorders = pScene.SouthBorders.ToArray();
@@ -420,50 +400,34 @@ namespace OpenSim.Region.Framework.Scenes
420 // 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.
421 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)
422 { 402 {
423 return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); 403 return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
424 } 404 }
425 else 405 else
426 { 406 {
427 Vector2 extent = Vector2.Zero; 407 Vector2 extent = Vector2.Zero;
428 for (int i=0;i<eastBorders.Length;i++) 408 for (int i = 0; i < eastBorders.Length; i++)
429 { 409 {
430 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;
431 } 411 }
432 for (int i=0;i<northBorders.Length;i++) 412 for (int i = 0; i < northBorders.Length; i++)
433 { 413 {
434 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;
435 } 415 }
436 416
437 List<SimpleRegionInfo> neighbourList = new List<SimpleRegionInfo>();
438
439 // Loss of fraction on purpose 417 // Loss of fraction on purpose
440 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1; 418 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
441 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1; 419 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
442 420
443 int startX = (int) pRegionLocX - 1; 421 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
444 int startY = (int) pRegionLocY - 1; 422 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
445 423
446 int endX = (int) pRegionLocX + (int)extent.X; 424 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
447 int endY = (int) pRegionLocY + (int)extent.Y; 425 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
448 426
449 for (int i=startX;i<endX;i++) 427 List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
450 { 428 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
451 for (int j=startY;j<endY;j++) 429
452 { 430 return neighbours;
453 // Skip CurrentRegion
454 if (i == (int)pRegionLocX && j == (int)pRegionLocY)
455 continue;
456
457 ulong regionHandle = Util.UIntsToLong((uint)(i * Constants.RegionSize),
458 (uint)(j * Constants.RegionSize));
459 RegionInfo neighborreg = m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
460 if (neighborreg != null)
461 {
462 neighbourList.Add(neighborreg);
463 }
464 }
465 }
466 return neighbourList;
467 //SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo() 431 //SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo()
468 //return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY); 432 //return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY);
469 } 433 }
@@ -475,29 +439,28 @@ namespace OpenSim.Region.Framework.Scenes
475 /// </summary> 439 /// </summary>
476 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours) 440 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
477 { 441 {
478 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); 442 //List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>();
443 List<GridRegion> neighbours = new List<GridRegion>();
479 444
480 //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 445 ////m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
481 for (int i = 0; i < lstneighbours.Count; i++) 446 //for (int i = 0; i < lstneighbours.Count; i++)
482 { 447 //{
483 // 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.
484 if (!(lstneighbours[i].commFailTF)) 449 // if (!(lstneighbours[i].commFailTF))
485 { 450 // {
486 neighbours.Add(new SimpleRegionInfo(lstneighbours[i])); 451 // neighbours.Add(new SimpleRegionInfo(lstneighbours[i]));
487 } 452 // }
488 } 453 //}
489 // 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
490 // 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 :/
491 if (m_regionInfo != null) 456 if (m_regionInfo != null)
492 { 457 {
493 neighbours = 458 neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
494 RequestNeighbors(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
495 } 459 }
496 else 460 else
497 { 461 {
498 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?");
499 } 463 }
500
501 464
502 /// 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
503 /// 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.
@@ -540,8 +503,9 @@ namespace OpenSim.Region.Framework.Scenes
540 503
541 /// Create the necessary child agents 504 /// Create the necessary child agents
542 List<AgentCircuitData> cagents = new List<AgentCircuitData>(); 505 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
543 foreach (SimpleRegionInfo neighbour in neighbours) 506 //foreach (SimpleRegionInfo neighbour in neighbours)
544 { 507 foreach (GridRegion neighbour in neighbours)
508 {
545 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle) 509 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
546 { 510 {
547 511
@@ -581,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes
581 545
582 bool newAgent = false; 546 bool newAgent = false;
583 int count = 0; 547 int count = 0;
584 foreach (SimpleRegionInfo neighbour in neighbours) 548 foreach (GridRegion neighbour in neighbours)
585 { 549 {
586 // 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
587 if (newRegions.Contains(neighbour.RegionHandle)) 551 if (newRegions.Contains(neighbour.RegionHandle))
@@ -634,7 +598,7 @@ namespace OpenSim.Region.Framework.Scenes
634 /// This informs a single neighboring region about agent "avatar". 598 /// This informs a single neighboring region about agent "avatar".
635 /// 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.
636 /// </summary> 600 /// </summary>
637 public void InformNeighborChildAgent(ScenePresence avatar, SimpleRegionInfo region) 601 public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
638 { 602 {
639 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo(); 603 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
640 agent.BaseFolder = UUID.Zero; 604 agent.BaseFolder = UUID.Zero;
@@ -665,61 +629,63 @@ namespace OpenSim.Region.Framework.Scenes
665 /// <param name="regionhandle"></param> 629 /// <param name="regionhandle"></param>
666 private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle) 630 private void InformNeighboursThatRegionIsUpAsync(INeighbourService neighbourService, RegionInfo region, ulong regionhandle)
667 { 631 {
668 m_log.Info("[INTERGRID]: Starting to inform neighbors that I'm here"); 632 uint x = 0, y = 0;
669 //RegionUpData regiondata = new RegionUpData(region.RegionLocX, region.RegionLocY, region.ExternalHostName, region.InternalEndPoint.Port); 633 Utils.LongToUInts(regionhandle, out x, out y);
670 634
671 //bool regionAccepted = 635 GridRegion neighbour = null;
672 // m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region), regionhandle);
673
674 //bool regionAccepted = m_interregionCommsOut.SendHelloNeighbour(regionhandle, region);
675 bool regionAccepted = false;
676 if (neighbourService != null) 636 if (neighbourService != null)
677 regionAccepted = neighbourService.HelloNeighbour(regionhandle, region); 637 neighbour = neighbourService.HelloNeighbour(regionhandle, region);
678 else 638 else
679 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");
680 640
681 if (regionAccepted) 641 if (neighbour != null)
682 { 642 {
683 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);
684 handlerRegionUp = OnRegionUp; 644 m_scene.EventManager.TriggerOnRegionUp(neighbour);
685
686 // yes, we're notifying ourselves.
687 if (handlerRegionUp != null)
688 handlerRegionUp(region);
689 } 645 }
690 else 646 else
691 { 647 {
692 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);
693 } 649 }
694 } 650 }
695 651
696 /// <summary> 652
697 /// Called by scene when region is initialized (not always when it's listening for agents)
698 /// This is an inter-region message that informs the surrounding neighbors that the sim is up.
699 /// </summary>
700 public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region) 653 public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
701 { 654 {
702 //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);
703 656
704 657 for (int x = (int)region.RegionLocX - 1; x <= region.RegionLocX + 1; x++)
705 List<SimpleRegionInfo> neighbours = new List<SimpleRegionInfo>(); 658 for (int y = (int)region.RegionLocY - 1; y <= region.RegionLocY + 1; y++)
706 // 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
707 neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY); 660 {
708 if (neighbours != null) 661 ulong handle = Utils.UIntsToLong((uint)x * Constants.RegionSize, (uint)y * Constants.RegionSize);
709 { 662 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
710 for (int i = 0; i < neighbours.Count; i++)
711 {
712 InformNeighbourThatRegionUpDelegate d = InformNeighboursThatRegionIsUpAsync;
713 663
714 d.BeginInvoke(neighbourService, region, neighbours[i].RegionHandle, 664 d.BeginInvoke(neighbourService, region, handle,
715 InformNeighborsThatRegionisUpCompleted, 665 InformNeighborsThatRegionisUpCompleted,
716 d); 666 d);
717 } 667 }
718 } 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 //}
719 684
720 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region)); 685 //bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
721 } 686 }
722 687
688
723 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle); 689 public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle);
724 690
725 /// <summary> 691 /// <summary>
@@ -815,41 +781,6 @@ namespace OpenSim.Region.Framework.Scenes
815 } 781 }
816 } 782 }
817 783
818 /// <summary>
819 /// Helper function to request neighbors from grid-comms
820 /// </summary>
821 /// <param name="regionHandle"></param>
822 /// <returns></returns>
823 public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
824 {
825 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionHandle.ToString());
826 return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
827 }
828
829 /// <summary>
830 /// Helper function to request neighbors from grid-comms
831 /// </summary>
832 /// <param name="regionID"></param>
833 /// <returns></returns>
834 public virtual RegionInfo RequestNeighbouringRegionInfo(UUID regionID)
835 {
836 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionID);
837 return m_commsProvider.GridService.RequestNeighbourInfo(regionID);
838 }
839
840 /// <summary>
841 /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
842 /// </summary>
843 /// <param name="minX"></param>
844 /// <param name="minY"></param>
845 /// <param name="maxX"></param>
846 /// <param name="maxY"></param>
847 public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
848 {
849 List<MapBlockData> mapBlocks;
850 mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4);
851 remoteClient.SendMapBlock(mapBlocks, 0);
852 }
853 784
854 /// <summary> 785 /// <summary>
855 /// Try to teleport an agent to a new region. 786 /// Try to teleport an agent to a new region.
@@ -914,7 +845,10 @@ namespace OpenSim.Region.Framework.Scenes
914 } 845 }
915 else 846 else
916 { 847 {
917 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
918 if (reg != null) 852 if (reg != null)
919 { 853 {
920 m_log.DebugFormat( 854 m_log.DebugFormat(
@@ -1163,7 +1097,7 @@ namespace OpenSim.Region.Framework.Scenes
1163 } 1097 }
1164 } 1098 }
1165 1099
1166 private bool IsOutsideRegion(Scene s, Vector3 pos) 1100 protected bool IsOutsideRegion(Scene s, Vector3 pos)
1167 { 1101 {
1168 1102
1169 if (s.TestBorderCross(pos,Cardinals.N)) 1103 if (s.TestBorderCross(pos,Cardinals.N))
@@ -1221,10 +1155,10 @@ namespace OpenSim.Region.Framework.Scenes
1221 return false; 1155 return false;
1222 } 1156 }
1223 1157
1224 private List<ulong> NeighbourHandles(List<SimpleRegionInfo> neighbours) 1158 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1225 { 1159 {
1226 List<ulong> handles = new List<ulong>(); 1160 List<ulong> handles = new List<ulong>();
1227 foreach (SimpleRegionInfo reg in neighbours) 1161 foreach (GridRegion reg in neighbours)
1228 { 1162 {
1229 handles.Add(reg.RegionHandle); 1163 handles.Add(reg.RegionHandle);
1230 } 1164 }
@@ -1475,7 +1409,10 @@ namespace OpenSim.Region.Framework.Scenes
1475 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);
1476 1410
1477 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));
1478 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
1479 if (neighbourRegion != null && agent.ValidateAttachments()) 1416 if (neighbourRegion != null && agent.ValidateAttachments())
1480 { 1417 {
1481 pos = pos + (agent.Velocity); 1418 pos = pos + (agent.Velocity);
@@ -1602,11 +1539,6 @@ namespace OpenSim.Region.Framework.Scenes
1602 } 1539 }
1603 1540
1604 1541
1605 public Dictionary<string, string> GetGridSettings()
1606 {
1607 return m_commsProvider.GridService.GetGridSettings();
1608 }
1609
1610 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)
1611 { 1543 {
1612 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat); 1544 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
@@ -1643,19 +1575,14 @@ namespace OpenSim.Region.Framework.Scenes
1643 return m_commsProvider.GetUserFriendList(friendlistowner); 1575 return m_commsProvider.GetUserFriendList(friendlistowner);
1644 } 1576 }
1645 1577
1646 public List<MapBlockData> RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
1647 {
1648 return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
1649 }
1650
1651 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query) 1578 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
1652 { 1579 {
1653 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query); 1580 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
1654 } 1581 }
1655 1582
1656 public List<RegionInfo> RequestNamedRegions(string name, int maxNumber) 1583 public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
1657 { 1584 {
1658 return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber); 1585 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
1659 } 1586 }
1660 1587
1661 //private void Dump(string msg, List<ulong> handles) 1588 //private void Dump(string msg, List<ulong> handles)