From 5757afe7665543e8b3ed4a322a7d6e095dafcdb3 Mon Sep 17 00:00:00 2001
From: Diva Canto
Date: Sat, 26 Sep 2009 07:48:21 -0700
Subject: First pass at the heart surgery for grid services. Compiles and runs
minimally. A few bugs to catch now.
---
.../Framework/Scenes/Hypergrid/HGHyperlink.cs | 232 -----------------
.../Region/Framework/Scenes/Hypergrid/HGScene.cs | 3 +-
.../Hypergrid/HGSceneCommunicationService.cs | 6 +-
OpenSim/Region/Framework/Scenes/Scene.cs | 114 +++++----
.../Framework/Scenes/SceneCommunicationService.cs | 275 ++++++++-------------
OpenSim/Region/Framework/Scenes/ScenePresence.cs | 6 +-
6 files changed, 181 insertions(+), 455 deletions(-)
delete mode 100644 OpenSim/Region/Framework/Scenes/Hypergrid/HGHyperlink.cs
(limited to 'OpenSim/Region/Framework')
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 @@
-/*
- * Copyright (c) Contributors, http://opensimulator.org/
- * See CONTRIBUTORS.TXT for a full list of copyright holders.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of the OpenSimulator Project nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
- * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-using System;
-using System.Net;
-using System.Reflection;
-using log4net;
-using OpenMetaverse;
-using OpenSim.Framework;
-
-namespace OpenSim.Region.Framework.Scenes.Hypergrid
-{
- public class HGHyperlink
- {
- private static readonly ILog m_log =
- LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
- private static Random random = new Random();
-
- public static RegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc)
- {
- string host = "127.0.0.1";
- string portstr;
- string regionName = "";
- uint port = 9000;
- string[] parts = mapName.Split(new char[] { ':' });
- if (parts.Length >= 1)
- {
- host = parts[0];
- }
- if (parts.Length >= 2)
- {
- portstr = parts[1];
- if (!UInt32.TryParse(portstr, out port))
- regionName = parts[1];
- }
- // always take the last one
- if (parts.Length >= 3)
- {
- regionName = parts[2];
- }
-
- // Sanity check. Don't ever link to this sim.
- IPAddress ipaddr = null;
- try
- {
- ipaddr = Util.GetHostFromDNS(host);
- }
- catch { }
-
- if ((ipaddr != null) &&
- !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port)))
- {
- RegionInfo regInfo;
- bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo);
- if (success)
- {
- regInfo.RegionName = mapName;
- return regInfo;
- }
- }
-
- return null;
- }
-
- public static RegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName)
- {
- uint xloc = (uint)(random.Next(0, Int16.MaxValue));
- return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0);
- }
-
- public static bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc,
- string externalRegionName, uint externalPort, string externalHostName, out RegionInfo regInfo)
- {
- m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc);
-
- regInfo = new RegionInfo();
- regInfo.RegionName = externalRegionName;
- regInfo.HttpPort = externalPort;
- regInfo.ExternalHostName = externalHostName;
- regInfo.RegionLocX = xloc;
- regInfo.RegionLocY = yloc;
-
- try
- {
- regInfo.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), (int)0);
- }
- catch (Exception e)
- {
- m_log.Warn("[HGrid]: Wrong format for link-region: " + e.Message);
- return false;
- }
- regInfo.RemotingAddress = regInfo.ExternalEndPoint.Address.ToString();
-
- // Finally, link it
- try
- {
- m_scene.CommsManager.GridService.RegisterRegion(regInfo);
- }
- catch (Exception e)
- {
- m_log.Warn("[HGrid]: Unable to link region: " + e.Message);
- return false;
- }
-
- uint x, y;
- if (!Check4096(m_scene, regInfo, out x, out y))
- {
- m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
- if (client != null)
- client.SendAlertMessage("Region is too far (" + x + ", " + y + ")");
- m_log.Info("[HGrid]: Unable to link, region is too far (" + x + ", " + y + ")");
- return false;
- }
-
- if (!CheckCoords(m_scene.RegionInfo.RegionLocX, m_scene.RegionInfo.RegionLocY, x, y))
- {
- m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
- if (client != null)
- client.SendAlertMessage("Region has incompatible coordinates (" + x + ", " + y + ")");
- m_log.Info("[HGrid]: Unable to link, region has incompatible coordinates (" + x + ", " + y + ")");
- return false;
- }
-
- m_log.Debug("[HGrid]: link region succeeded");
- return true;
- }
-
- public static bool TryUnlinkRegion(Scene m_scene, string mapName)
- {
- RegionInfo regInfo = null;
- if (mapName.Contains(":"))
- {
- string host = "127.0.0.1";
- //string portstr;
- //string regionName = "";
- uint port = 9000;
- string[] parts = mapName.Split(new char[] { ':' });
- if (parts.Length >= 1)
- {
- host = parts[0];
- }
-// if (parts.Length >= 2)
-// {
-// portstr = parts[1];
-// if (!UInt32.TryParse(portstr, out port))
-// regionName = parts[1];
-// }
- // always take the last one
-// if (parts.Length >= 3)
-// {
-// regionName = parts[2];
-// }
- regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(host, port);
- }
- else
- {
- regInfo = m_scene.CommsManager.GridService.RequestNeighbourInfo(mapName);
- }
- if (regInfo != null)
- {
- return m_scene.CommsManager.GridService.DeregisterRegion(regInfo);
- }
- else
- {
- m_log.InfoFormat("[HGrid]: Region {0} not found", mapName);
- return false;
- }
- }
-
- ///
- /// Cope with this viewer limitation.
- ///
- ///
- ///
- public static bool Check4096(Scene m_scene, RegionInfo regInfo, out uint x, out uint y)
- {
- ulong realHandle;
- if (UInt64.TryParse(regInfo.regionSecret, out realHandle))
- {
- Utils.LongToUInts(realHandle, out x, out y);
- x = x / Constants.RegionSize;
- y = y / Constants.RegionSize;
-
- if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) ||
- (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096))
- {
- return false;
- }
- return true;
- }
- else
- {
- m_scene.CommsManager.GridService.RegisterRegion(regInfo);
- m_log.Debug("[HGrid]: Gnomes. Region deregistered.");
- x = y = 0;
- return false;
- }
- }
-
- public static bool CheckCoords(uint thisx, uint thisy, uint x, uint y)
- {
- if ((thisx == x) && (thisy == y))
- return false;
- return true;
- }
-
- }
-}
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;
using OpenSim.Framework;
using OpenSim.Framework.Communications.Cache;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes.Hypergrid
{
@@ -50,7 +51,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
if (UserProfile != null)
{
- RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion);
+ GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
//if (regionInfo != null)
//{
// UserProfile.HomeRegionID = regionInfo.RegionID;
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
index 5c99d73..e8e5e78 100644
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
@@ -38,6 +38,7 @@ using OpenSim.Framework.Communications;
using OpenSim.Framework.Communications.Cache;
using OpenSim.Framework.Capabilities;
using OpenSim.Region.Framework.Interfaces;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes.Hypergrid
{
@@ -106,7 +107,10 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid
}
else
{
- RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle);
+ uint x = 0, y = 0;
+ Utils.LongToUInts(regionHandle, out x, out y);
+ GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
+
if (reg != null)
{
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index d8478a2..8990f29 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;
using OpenSim.Region.Physics.Manager;
using Timer=System.Timers.Timer;
using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes
{
@@ -193,6 +194,26 @@ namespace OpenSim.Region.Framework.Scenes
}
}
+ protected IGridService m_GridService = null;
+
+ public IGridService GridService
+ {
+ get
+ {
+ if (m_GridService == null)
+ {
+ m_GridService = RequestModuleInterface();
+
+ if (m_GridService == null)
+ {
+ 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.");
+ }
+ }
+
+ return m_GridService;
+ }
+ }
+
protected IXMLRPC m_xmlrpcModule;
protected IWorldComm m_worldCommModule;
protected IAvatarFactory m_AvatarFactory;
@@ -1336,24 +1357,31 @@ namespace OpenSim.Region.Framework.Scenes
RegisterCommsEvents();
// These two 'commands' *must be* next to each other or sim rebooting fails.
- m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo);
+ //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo);
+
+ GridRegion region = new GridRegion(RegionInfo);
+ bool success = GridService.RegisterRegion(RegionInfo.ScopeID, region);
+ if (!success)
+ throw new Exception("Can't register with grid");
+
+ m_sceneGridService.SetScene(this);
m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface(), RegionInfo);
- Dictionary dGridSettings = m_sceneGridService.GetGridSettings();
+ //Dictionary dGridSettings = m_sceneGridService.GetGridSettings();
- if (dGridSettings.ContainsKey("allow_forceful_banlines"))
- {
- if (dGridSettings["allow_forceful_banlines"] != "TRUE")
- {
- m_log.Info("[GRID]: Grid is disabling forceful parcel banlists");
- EventManager.TriggerSetAllowForcefulBan(false);
- }
- else
- {
- m_log.Info("[GRID]: Grid is allowing forceful parcel banlists");
- EventManager.TriggerSetAllowForcefulBan(true);
- }
- }
+ //if (dGridSettings.ContainsKey("allow_forceful_banlines"))
+ //{
+ // if (dGridSettings["allow_forceful_banlines"] != "TRUE")
+ // {
+ // m_log.Info("[GRID]: Grid is disabling forceful parcel banlists");
+ // EventManager.TriggerSetAllowForcefulBan(false);
+ // }
+ // else
+ // {
+ // m_log.Info("[GRID]: Grid is allowing forceful parcel banlists");
+ // EventManager.TriggerSetAllowForcefulBan(true);
+ // }
+ //}
}
///
@@ -2717,10 +2745,12 @@ namespace OpenSim.Region.Framework.Scenes
UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId);
if (UserProfile != null)
{
- RegionInfo regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegionID);
+ GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
if (regionInfo == null)
{
- regionInfo = CommsManager.GridService.RequestNeighbourInfo(UserProfile.HomeRegion);
+ uint x = 0, y = 0;
+ Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
+ regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
if (regionInfo != null) // home region can be away temporarily, too
{
UserProfile.HomeRegionID = regionInfo.RegionID;
@@ -3111,7 +3141,11 @@ namespace OpenSim.Region.Framework.Scenes
if (m_interregionCommsIn != null)
m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
+ // this does nothing; should be removed
m_sceneGridService.Close();
+
+ if (!GridService.DeregisterRegion(m_regInfo.RegionID))
+ m_log.WarnFormat("[SCENE]: Deregister from grid failed for region {0}", m_regInfo.RegionName);
}
///
@@ -3557,30 +3591,6 @@ namespace OpenSim.Region.Framework.Scenes
}
///
- /// Requests information about this region from gridcomms
- ///
- ///
- ///
- public RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
- {
- return m_sceneGridService.RequestNeighbouringRegionInfo(regionHandle);
- }
-
- ///
- /// Requests textures for map from minimum region to maximum region in world cordinates
- ///
- ///
- ///
- ///
- ///
- ///
- public void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
- {
- m_log.DebugFormat("[MAPBLOCK]: {0}-{1}, {2}-{3}", minX, minY, maxX, maxY);
- m_sceneGridService.RequestMapBlocks(remoteClient, minX, minY, maxX, maxY);
- }
-
- ///
/// Tries to teleport agent to other region.
///
///
@@ -3591,7 +3601,7 @@ namespace OpenSim.Region.Framework.Scenes
public void RequestTeleportLocation(IClientAPI remoteClient, string regionName, Vector3 position,
Vector3 lookat, uint teleportFlags)
{
- RegionInfo regionInfo = m_sceneGridService.RequestClosestRegion(regionName);
+ GridRegion regionInfo = GridService.GetRegionByName(UUID.Zero, regionName);
if (regionInfo == null)
{
// can't find the region: Tell viewer and abort
@@ -3680,7 +3690,7 @@ namespace OpenSim.Region.Framework.Scenes
///
public void RequestTeleportLandmark(IClientAPI remoteClient, UUID regionID, Vector3 position)
{
- RegionInfo info = CommsManager.GridService.RequestNeighbourInfo(regionID);
+ GridRegion info = GridService.GetRegionByUUID(UUID.Zero, regionID);
if (info == null)
{
@@ -3864,10 +3874,6 @@ namespace OpenSim.Region.Framework.Scenes
return LandChannel.GetLandObject((int)x, (int)y).landData;
}
- public RegionInfo RequestClosestRegion(string name)
- {
- return m_sceneGridService.RequestClosestRegion(name);
- }
#endregion
@@ -4178,14 +4184,18 @@ namespace OpenSim.Region.Framework.Scenes
public void RegionHandleRequest(IClientAPI client, UUID regionID)
{
- RegionInfo info;
+ ulong handle = 0;
if (regionID == RegionInfo.RegionID)
- info = RegionInfo;
+ handle = RegionInfo.RegionHandle;
else
- info = CommsManager.GridService.RequestNeighbourInfo(regionID);
+ {
+ GridRegion r = GridService.GetRegionByUUID(UUID.Zero, regionID);
+ if (r != null)
+ handle = r.RegionHandle;
+ }
- if (info != null)
- client.SendRegionHandle(regionID, info.RegionHandle);
+ if (handle != 0)
+ client.SendRegionHandle(regionID, handle);
}
public void TerrainUnAcked(IClientAPI client, int patchX, int patchY)
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;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Services.Interfaces;
using OSD = OpenMetaverse.StructuredData.OSD;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes
{
@@ -58,6 +59,7 @@ namespace OpenSim.Region.Framework.Scenes
protected CommunicationsManager m_commsProvider;
protected IInterregionCommsOut m_interregionCommsOut;
protected RegionInfo m_regionInfo;
+ protected Scene m_scene;
protected RegionCommsListener regionCommsHost;
@@ -131,6 +133,13 @@ namespace OpenSim.Region.Framework.Scenes
m_agentsInTransit = new List();
}
+ public void SetScene(Scene s)
+ {
+ m_scene = s;
+ m_regionInfo = s.RegionInfo;
+ m_interregionCommsOut = m_scene.RequestModuleInterface();
+ }
+
///
/// Register a region with the grid
///
@@ -138,40 +147,30 @@ namespace OpenSim.Region.Framework.Scenes
/// Thrown if region registration fails.
public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos)
{
- m_interregionCommsOut = comms_out;
+ //m_interregionCommsOut = comms_out;
- m_regionInfo = regionInfos;
- m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
- regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
+ //m_regionInfo = regionInfos;
+ //m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
+ //regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
- if (regionCommsHost != null)
- {
- //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
-
- regionCommsHost.debugRegionName = regionInfos.RegionName;
- regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
- regionCommsHost.OnExpectUser += NewUserConnection;
- regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
- regionCommsHost.OnCloseAgentConnection += CloseConnection;
- regionCommsHost.OnRegionUp += newRegionUp;
- regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
- regionCommsHost.OnLogOffUser += GridLogOffUser;
- regionCommsHost.OnGetLandData += FetchLandData;
- }
- else
- {
- //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
- }
- }
-
- ///
- /// Returns a region with the name closest to string provided
- ///
- /// Partial Region Name for matching
- /// Region Information for the region
- public RegionInfo RequestClosestRegion(string name)
- {
- return m_commsProvider.GridService.RequestClosestRegion(name);
+ //if (regionCommsHost != null)
+ //{
+ // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
+
+ // regionCommsHost.debugRegionName = regionInfos.RegionName;
+ // regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
+ // regionCommsHost.OnExpectUser += NewUserConnection;
+ // regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
+ // regionCommsHost.OnCloseAgentConnection += CloseConnection;
+ // regionCommsHost.OnRegionUp += newRegionUp;
+ // regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
+ // regionCommsHost.OnLogOffUser += GridLogOffUser;
+ // regionCommsHost.OnGetLandData += FetchLandData;
+ //}
+ //else
+ //{
+ // //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
+ //}
}
///
@@ -180,30 +179,31 @@ namespace OpenSim.Region.Framework.Scenes
///
public void Close()
{
- if (regionCommsHost != null)
- {
- regionCommsHost.OnLogOffUser -= GridLogOffUser;
- regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
- regionCommsHost.OnRegionUp -= newRegionUp;
- regionCommsHost.OnExpectUser -= NewUserConnection;
- regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
- regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
- regionCommsHost.OnCloseAgentConnection -= CloseConnection;
- regionCommsHost.OnGetLandData -= FetchLandData;
+
+ //if (regionCommsHost != null)
+ //{
+ // regionCommsHost.OnLogOffUser -= GridLogOffUser;
+ // regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
+ // regionCommsHost.OnRegionUp -= newRegionUp;
+ // regionCommsHost.OnExpectUser -= NewUserConnection;
+ // regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
+ // regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
+ // regionCommsHost.OnCloseAgentConnection -= CloseConnection;
+ // regionCommsHost.OnGetLandData -= FetchLandData;
- try
- {
- m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
- }
- catch (Exception e)
- {
- m_log.ErrorFormat(
- "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
- m_regionInfo.RegionName, e);
- }
+ // try
+ // {
+ // m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
+ // }
+ // catch (Exception e)
+ // {
+ // m_log.ErrorFormat(
+ // "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
+ // m_regionInfo.RegionName, e);
+ // }
- regionCommsHost = null;
- }
+ // regionCommsHost = null;
+ //}
}
#region CommsManager Event handlers
@@ -337,7 +337,7 @@ namespace OpenSim.Region.Framework.Scenes
#region Inform Client of Neighbours
private delegate void InformClientOfNeighbourDelegate(
- ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg, IPEndPoint endPoint, bool newAgent);
+ ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
private void InformClientOfNeighbourCompleted(IAsyncResult iar)
{
@@ -355,7 +355,7 @@ namespace OpenSim.Region.Framework.Scenes
///
///
///
- private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, SimpleRegionInfo reg,
+ private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
IPEndPoint endPoint, bool newAgent)
{
// 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
string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
+ "/CAPS/" + a.CapsPath + "0000/";
+ m_log.DebugFormat("[XXX] CAPS = {0}", capsPath);
+ m_log.DebugFormat("[XXX] ExternalEndPoint = {0}", endPoint.ToString());
+
string reason = String.Empty;
//bool regionAccepted = m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, a);
bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, out reason);
+ m_log.DebugFormat("[XXX] Here 1 {0}", regionAccepted);
if (regionAccepted && newAgent)
{
@@ -390,6 +394,7 @@ namespace OpenSim.Region.Framework.Scenes
}
#endregion
+ m_log.DebugFormat("[XXX] HERE 2");
eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
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
}
- public void RequestNeighbors(RegionInfo region)
- {
- // List neighbours =
- m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
- //IPEndPoint blah = new IPEndPoint();
-
- //blah.Address = region.RemotingAddress;
- //blah.Port = region.RemotingPort;
- }
-
- public List RequestNeighbors(Scene pScene, uint pRegionLocX, uint pRegionLocY)
+ public List RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
{
Border[] northBorders = pScene.NorthBorders.ToArray();
Border[] southBorders = pScene.SouthBorders.ToArray();
@@ -427,50 +422,34 @@ namespace OpenSim.Region.Framework.Scenes
// Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
{
- return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY);
+ return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
}
else
{
Vector2 extent = Vector2.Zero;
- for (int i=0;i extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
}
- for (int i=0;i extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
}
- List neighbourList = new List();
-
// Loss of fraction on purpose
extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
- int startX = (int) pRegionLocX - 1;
- int startY = (int) pRegionLocY - 1;
+ int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
+ int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
- int endX = (int) pRegionLocX + (int)extent.X;
- int endY = (int) pRegionLocY + (int)extent.Y;
+ int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
+ int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
- for (int i=startX;i neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
+ neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
+
+ return neighbours;
//SimpleRegionInfo regionData = m_commsProvider.GridService.RequestNeighbourInfo()
//return m_commsProvider.GridService.RequestNeighbours(pRegionLocX, pRegionLocY);
}
@@ -482,23 +461,24 @@ namespace OpenSim.Region.Framework.Scenes
///
public void EnableNeighbourChildAgents(ScenePresence avatar, List lstneighbours)
{
- List neighbours = new List();
+ //List neighbours = new List();
+ List neighbours = new List();
- //m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
- for (int i = 0; i < lstneighbours.Count; i++)
- {
- // We don't want to keep sending to regions that consistently fail on comms.
- if (!(lstneighbours[i].commFailTF))
- {
- neighbours.Add(new SimpleRegionInfo(lstneighbours[i]));
- }
- }
+ ////m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
+ //for (int i = 0; i < lstneighbours.Count; i++)
+ //{
+ // // We don't want to keep sending to regions that consistently fail on comms.
+ // if (!(lstneighbours[i].commFailTF))
+ // {
+ // neighbours.Add(new SimpleRegionInfo(lstneighbours[i]));
+ // }
+ //}
// we're going to be using the above code once neighbour cache is correct. Currently it doesn't appear to be
// So we're temporarily going back to the old method of grabbing it from the Grid Server Every time :/
if (m_regionInfo != null)
{
neighbours =
- RequestNeighbors(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
+ RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
}
else
{
@@ -547,8 +527,9 @@ namespace OpenSim.Region.Framework.Scenes
/// Create the necessary child agents
List cagents = new List();
- foreach (SimpleRegionInfo neighbour in neighbours)
- {
+ //foreach (SimpleRegionInfo neighbour in neighbours)
+ foreach (GridRegion neighbour in neighbours)
+ {
if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
{
@@ -588,7 +569,7 @@ namespace OpenSim.Region.Framework.Scenes
bool newAgent = false;
int count = 0;
- foreach (SimpleRegionInfo neighbour in neighbours)
+ foreach (GridRegion neighbour in neighbours)
{
// Don't do it if there's already an agent in that region
if (newRegions.Contains(neighbour.RegionHandle))
@@ -641,7 +622,7 @@ namespace OpenSim.Region.Framework.Scenes
/// This informs a single neighboring region about agent "avatar".
/// Calls an asynchronous method to do so.. so it doesn't lag the sim.
///
- public void InformNeighborChildAgent(ScenePresence avatar, SimpleRegionInfo region)
+ public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
{
AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
agent.BaseFolder = UUID.Zero;
@@ -700,18 +681,16 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- ///
- /// Called by scene when region is initialized (not always when it's listening for agents)
- /// This is an inter-region message that informs the surrounding neighbors that the sim is up.
- ///
+
public void InformNeighborsThatRegionisUp(INeighbourService neighbourService, RegionInfo region)
{
//m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending InterRegion Notification that region is up " + region.RegionName);
-
- List neighbours = new List();
+
+ List neighbours = new List();
// This stays uncached because we don't already know about our neighbors at this point.
- neighbours = m_commsProvider.GridService.RequestNeighbours(m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
+
+ neighbours = m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
if (neighbours != null)
{
for (int i = 0; i < neighbours.Count; i++)
@@ -727,6 +706,7 @@ namespace OpenSim.Region.Framework.Scenes
//bool val = m_commsProvider.InterRegion.RegionUp(new SerializableRegionInfo(region));
}
+
public delegate void SendChildAgentDataUpdateDelegate(AgentPosition cAgentData, ulong regionHandle);
///
@@ -822,41 +802,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
- ///
- /// Helper function to request neighbors from grid-comms
- ///
- ///
- ///
- public virtual RegionInfo RequestNeighbouringRegionInfo(ulong regionHandle)
- {
- //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionHandle.ToString());
- return m_commsProvider.GridService.RequestNeighbourInfo(regionHandle);
- }
-
- ///
- /// Helper function to request neighbors from grid-comms
- ///
- ///
- ///
- public virtual RegionInfo RequestNeighbouringRegionInfo(UUID regionID)
- {
- //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: Sending Grid Services Request about neighbor " + regionID);
- return m_commsProvider.GridService.RequestNeighbourInfo(regionID);
- }
-
- ///
- /// Requests map blocks in area of minX, maxX, minY, MaxY in world cordinates
- ///
- ///
- ///
- ///
- ///
- public virtual void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY)
- {
- List mapBlocks;
- mapBlocks = m_commsProvider.GridService.RequestNeighbourMapBlocks(minX - 4, minY - 4, minX + 4, minY + 4);
- remoteClient.SendMapBlock(mapBlocks, 0);
- }
///
/// Try to teleport an agent to a new region.
@@ -921,7 +866,10 @@ namespace OpenSim.Region.Framework.Scenes
}
else
{
- RegionInfo reg = RequestNeighbouringRegionInfo(regionHandle);
+ uint x = 0, y = 0;
+ Utils.LongToUInts(regionHandle, out x, out y);
+ GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
+
if (reg != null)
{
m_log.DebugFormat(
@@ -1228,10 +1176,10 @@ namespace OpenSim.Region.Framework.Scenes
return false;
}
- private List NeighbourHandles(List neighbours)
+ private List NeighbourHandles(List neighbours)
{
List handles = new List();
- foreach (SimpleRegionInfo reg in neighbours)
+ foreach (GridRegion reg in neighbours)
{
handles.Add(reg.RegionHandle);
}
@@ -1482,7 +1430,10 @@ namespace OpenSim.Region.Framework.Scenes
m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
- SimpleRegionInfo neighbourRegion = RequestNeighbouringRegionInfo(neighbourHandle);
+
+ int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
+ GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
+
if (neighbourRegion != null && agent.ValidateAttachments())
{
pos = pos + (agent.Velocity);
@@ -1609,11 +1560,6 @@ namespace OpenSim.Region.Framework.Scenes
}
- public Dictionary GetGridSettings()
- {
- return m_commsProvider.GridService.GetGridSettings();
- }
-
public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
{
m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
@@ -1650,19 +1596,14 @@ namespace OpenSim.Region.Framework.Scenes
return m_commsProvider.GetUserFriendList(friendlistowner);
}
- public List RequestNeighbourMapBlocks(int minX, int minY, int maxX, int maxY)
- {
- return m_commsProvider.GridService.RequestNeighbourMapBlocks(minX, minY, maxX, maxY);
- }
-
public List GenerateAgentPickerRequestResponse(UUID queryID, string query)
{
return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
}
- public List RequestNamedRegions(string name, int maxNumber)
+ public List RequestNamedRegions(string name, int maxNumber)
{
- return m_commsProvider.GridService.RequestNamedRegions(name, maxNumber);
+ return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
}
//private void Dump(string msg, List 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;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes.Types;
using OpenSim.Region.Physics.Manager;
+using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.Framework.Scenes
{
@@ -2934,8 +2935,9 @@ namespace OpenSim.Region.Framework.Scenes
else if (dir > 3 && dir < 7) // Heading Sout
neighboury--;
- ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
- SimpleRegionInfo neighbourRegion = m_scene.RequestNeighbouringRegionInfo(neighbourHandle);
+ int x = (int)(neighbourx * Constants.RegionSize);
+ int y = (int)(neighboury * Constants.RegionSize);
+ GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, x, y);
if (neighbourRegion == null)
{
--
cgit v1.1