From a9ced0fe7962654be7bf7282babd475761f8bb50 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Mon, 21 Sep 2009 19:33:56 -0700 Subject: Added Remote grid connector module. --- .../Grid/RemoteGridServiceConnector.cs | 108 +++++++++++++++++++++ 1 file changed, 108 insertions(+) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs new file mode 100644 index 0000000..b0cfc9c --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -0,0 +1,108 @@ +/* + * 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 log4net; +using System; +using System.Collections.Generic; +using System.Reflection; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Services.Connectors; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid +{ + public class RemoteGridServicesConnector : + GridServicesConnector, ISharedRegionModule, IGridService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "RemoteGridServicesConnector"; } + } + + public override void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("GridServices", ""); + if (name == Name) + { + IConfig gridConfig = source.Configs["GridService"]; + if (gridConfig == null) + { + m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini"); + return; + } + + m_Enabled = true; + + base.Initialise(source); + + m_log.Info("[GRID CONNECTOR]: Remote grid enabled"); + } + } + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) + { + } + } +} -- cgit v1.1 From 34f4738159300ab6370e3db47df5187b6cea8771 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 11:58:40 -0700 Subject: Added HGGridConnector and related code. --- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 304 +++++++++++++++++++++ .../Grid/LocalGridServiceConnector.cs | 64 +++-- .../Grid/RemoteGridServiceConnector.cs | 34 ++- 3 files changed, 364 insertions(+), 38 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs new file mode 100644 index 0000000..b7e3213 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -0,0 +1,304 @@ +/* + * 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.Collections.Generic; +using System.Reflection; + +using OpenSim.Framework; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Services.Interfaces; +using OpenSim.Server.Base; +using OpenSim.Services.Connectors.Grid; + +using OpenMetaverse; +using log4net; +using Nini.Config; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid +{ + public class HGGridConnector : ISharedRegionModule, IGridService + { + private static readonly ILog m_log = + LogManager.GetLogger( + MethodBase.GetCurrentMethod().DeclaringType); + + private bool m_Enabled = false; + private bool m_Initialized = false; + + private IGridService m_GridServiceConnector; + private HypergridServiceConnector m_HypergridServiceConnector; + + // Hyperlink regions are hyperlinks on the map + protected Dictionary m_HyperlinkRegions = new Dictionary(); + + // Known regions are home regions of visiting foreign users. + // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when + // the visitor goes away. They are mapped to X=0 on the map. + // This is key-ed on agent ID + protected Dictionary m_knownRegions = new Dictionary(); + + #region ISharedRegionModule + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "HGGridServicesConnector"; } + } + + public void Initialise(IConfigSource source) + { + IConfig moduleConfig = source.Configs["Modules"]; + if (moduleConfig != null) + { + string name = moduleConfig.GetString("GridServices", ""); + if (name == Name) + { + IConfig gridConfig = source.Configs["GridService"]; + if (gridConfig == null) + { + m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini"); + return; + } + + + InitialiseConnectorModule(source); + + m_Enabled = true; + m_log.Info("[HGGRID CONNECTOR]: HG grid enabled"); + } + } + } + + private void InitialiseConnectorModule(IConfigSource source) + { + IConfig gridConfig = source.Configs["GridService"]; + if (gridConfig == null) + { + m_log.Error("[HGGRID CONNECTOR]: GridService missing from OpenSim.ini"); + throw new Exception("Grid connector init error"); + } + + string module = gridConfig.GetString("GridServiceConnectorModule", String.Empty); + if (module == String.Empty) + { + m_log.Error("[HGGRID CONNECTOR]: No GridServiceConnectorModule named in section GridService"); + //return; + throw new Exception("Unable to proceed. Please make sure your ini files in config-include are updated according to .example's"); + } + + Object[] args = new Object[] { source }; + m_GridServiceConnector = ServerUtils.LoadPlugin(module, args); + + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + scene.RegisterModuleInterface(this); + } + + public void RemoveRegion(Scene scene) + { + } + + public void RegionLoaded(Scene scene) + { + if (m_Enabled && !m_Initialized) + { + m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); + m_Initialized = true; + } + } + + #endregion + + #region IGridService + + public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + { + // Region doesn't exist here. Trying to link remote region + if (regionInfo.RegionID.Equals(UUID.Zero)) + { + m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort); + regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo); + if (!regionInfo.RegionID.Equals(UUID.Zero)) + { + m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); + m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID); + + // Try get the map image + m_HypergridServiceConnector.GetMapImage(regionInfo); + return true; + } + else + { + m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")"); + return false; + } + // Note that these remote regions aren't registered in localBackend, so return null, no local listeners + } + else // normal grid + return m_GridServiceConnector.RegisterRegion(scopeID, regionInfo); + } + + public bool DeregisterRegion(UUID regionID) + { + // Try the hyperlink collection + if (m_HyperlinkRegions.ContainsKey(regionID)) + { + m_HyperlinkRegions.Remove(regionID); + return true; + } + // Try the foreign users home collection + if (m_knownRegions.ContainsKey(regionID)) + { + m_knownRegions.Remove(regionID); + return true; + } + // Finally, try the normal route + return m_GridServiceConnector.DeregisterRegion(regionID); + } + + public List GetNeighbours(UUID scopeID, UUID regionID) + { + // No serving neighbours on hyperliked regions. + // Just the regular regions. + return m_GridServiceConnector.GetNeighbours(scopeID, regionID); + } + + public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + { + // Try the hyperlink collection + if (m_HyperlinkRegions.ContainsKey(regionID)) + return m_HyperlinkRegions[regionID]; + + // Try the foreign users home collection + if (m_knownRegions.ContainsKey(regionID)) + return m_knownRegions[regionID]; + + // Finally, try the normal route + return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); + } + + public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + { + int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize; + int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; + // Try the hyperlink collection + foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + { + if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) + return r; + } + + // Try the foreign users home collection + foreach (SimpleRegionInfo r in m_knownRegions.Values) + { + if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) + return r; + } + + // Finally, try the normal route + return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); + } + + public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + { + // Try normal grid first + SimpleRegionInfo region = m_GridServiceConnector.GetRegionByName(scopeID, regionName); + if (region != null) + return region; + + // !!! Commenting until region name exists + //// Try the hyperlink collection + //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + //{ + // if (r.RegionName == regionName) + // return r; + //} + + //// Try the foreign users home collection + //foreach (SimpleRegionInfo r in m_knownRegions.Values) + //{ + // if (r.RegionName == regionName) + // return r; + //} + return null; + } + + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + { + List rinfos = new List(); + + // Commenting until regionname exists + //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + // if ((r.RegionName != null) && r.RegionName.StartsWith(name)) + // rinfos.Add(r); + + rinfos.AddRange(m_GridServiceConnector.GetRegionsByName(scopeID, name, maxNumber)); + return rinfos; + } + + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + { + int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; + int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; + int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; + int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; + + List rinfos = new List(); + foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) && + (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax)) + rinfos.Add(r); + + rinfos.AddRange(m_GridServiceConnector.GetRegionRange(scopeID, xmin, xmax, ymin, ymax)); + + return rinfos; + } + + #endregion + + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 74ece2e..3f29401 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -50,6 +50,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private bool m_Enabled = false; + public LocalGridServicesConnector(IConfigSource source) + { + InitialiseService(source); + } + #region ISharedRegionModule public Type ReplaceableInterface @@ -70,38 +75,43 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid string name = moduleConfig.GetString("GridServices", ""); if (name == Name) { - IConfig assetConfig = source.Configs["GridService"]; - if (assetConfig == null) - { - m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini"); - return; - } - - string serviceDll = assetConfig.GetString("LocalServiceModule", - String.Empty); - - if (serviceDll == String.Empty) - { - m_log.Error("[GRID CONNECTOR]: No LocalServiceModule named in section GridService"); - return; - } - - Object[] args = new Object[] { source }; - m_GridService = - ServerUtils.LoadPlugin(serviceDll, - args); - - if (m_GridService == null) - { - m_log.Error("[GRID CONNECTOR]: Can't load asset service"); - return; - } + InitialiseService(source); m_Enabled = true; - m_log.Info("[GRID CONNECTOR]: Local grid connector enabled"); + m_log.Info("[LOCAL GRID CONNECTOR]: Local grid connector enabled"); } } } + private void InitialiseService(IConfigSource source) + { + IConfig assetConfig = source.Configs["GridService"]; + if (assetConfig == null) + { + m_log.Error("[LOCAL GRID CONNECTOR]: GridService missing from OpenSim.ini"); + return; + } + + string serviceDll = assetConfig.GetString("LocalServiceModule", + String.Empty); + + if (serviceDll == String.Empty) + { + m_log.Error("[LOCAL GRID CONNECTOR]: No LocalServiceModule named in section GridService"); + return; + } + + Object[] args = new Object[] { source }; + m_GridService = + ServerUtils.LoadPlugin(serviceDll, + args); + + if (m_GridService == null) + { + m_log.Error("[LOCAL GRID CONNECTOR]: Can't load asset service"); + return; + } + } + public void PostInitialise() { } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index b0cfc9c..22b1015 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -47,6 +47,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private bool m_Enabled = false; + public RemoteGridServicesConnector(IConfigSource source) + { + InitialiseService(source); + } + + #region ISharedRegionmodule + public Type ReplaceableInterface { get { return null; } @@ -65,22 +72,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid string name = moduleConfig.GetString("GridServices", ""); if (name == Name) { - IConfig gridConfig = source.Configs["GridService"]; - if (gridConfig == null) - { - m_log.Error("[GRID CONNECTOR]: GridService missing from OpenSim.ini"); - return; - } - + InitialiseService(source); m_Enabled = true; - - base.Initialise(source); - - m_log.Info("[GRID CONNECTOR]: Remote grid enabled"); + m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled"); } } } + private void InitialiseService(IConfigSource source) + { + IConfig gridConfig = source.Configs["GridService"]; + if (gridConfig == null) + { + m_log.Error("[REMOTE GRID CONNECTOR]: GridService missing from OpenSim.ini"); + return; + } + + base.Initialise(source); + } + public void PostInitialise() { } @@ -104,5 +114,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void RegionLoaded(Scene scene) { } + + #endregion } } -- cgit v1.1 From ffd30b8ac31bc408316079ba86076bf9e984a8be Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 14:46:05 -0700 Subject: Moved RegionName from RegionInfo to SimpleRegionInfo. --- .../CoreModules/Scripting/LSLHttp/UrlModule.cs | 484 ++++++++++----------- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 83 +++- .../Shared/Api/Implementation/LSL_Api.cs | 10 +- 3 files changed, 306 insertions(+), 271 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 2d81e4c..8b7a878 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -54,12 +54,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { public UUID requestID; public Dictionary headers; - public string body; - public int responseCode; + public string body; + public int responseCode; public string responseBody; - public ManualResetEvent ev; + public ManualResetEvent ev; public bool requestDone; - public int startTime; + public int startTime; public string uri; } @@ -73,23 +73,23 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp new Dictionary(); private Dictionary m_UrlMap = - new Dictionary(); - + new Dictionary(); + private int m_TotalUrls = 100; - private IHttpServer m_HttpServer = null; - - private string m_ExternalHostNameForLSL = ""; + private IHttpServer m_HttpServer = null; + + private string m_ExternalHostNameForLSL = ""; public Type ReplaceableInterface { get { return null; } - } - - private Hashtable HandleHttpPoll(Hashtable request) - { - return new Hashtable(); + } + + private Hashtable HandleHttpPoll(Hashtable request) + { + return new Hashtable(); } public string Name @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } public void Initialise(IConfigSource config) - { + { m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName); } @@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void Close() { - } + } public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID) { UUID urlcode = UUID.Random(); @@ -141,8 +141,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; - } - string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; + } + string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; @@ -152,14 +152,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp urlData.urlcode = urlcode; urlData.requests = new Dictionary(); - - m_UrlMap[url] = urlData; - - string uri = "/lslhttp/" + urlcode.ToString() + "/"; - - m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, - new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, - urlcode)); + + m_UrlMap[url] = urlData; + + string uri = "/lslhttp/" + urlcode.ToString() + "/"; + + m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, + new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, + urlcode)); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } @@ -180,11 +180,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { lock (m_UrlMap) { - UrlData data; - - if (!m_UrlMap.TryGetValue(url, out data)) - { - return; + UrlData data; + + if (!m_UrlMap.TryGetValue(url, out data)) + { + return; } foreach (UUID req in data.requests.Keys) @@ -196,36 +196,36 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } public void HttpResponse(UUID request, int status, string body) - { - if (m_RequestMap.ContainsKey(request)) - { - UrlData urlData = m_RequestMap[request]; - RequestData requestData=urlData.requests[request]; - urlData.requests[request].responseCode = status; - urlData.requests[request].responseBody = body; - //urlData.requests[request].ev.Set(); - urlData.requests[request].requestDone=true; - } - else - { - m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); + { + if (m_RequestMap.ContainsKey(request)) + { + UrlData urlData = m_RequestMap[request]; + RequestData requestData=urlData.requests[request]; + urlData.requests[request].responseCode = status; + urlData.requests[request].responseBody = body; + //urlData.requests[request].ev.Set(); + urlData.requests[request].requestDone=true; + } + else + { + m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); } } public string GetHttpHeader(UUID requestId, string header) - { - if (m_RequestMap.ContainsKey(requestId)) - { - UrlData urlData=m_RequestMap[requestId]; - string value; - if (urlData.requests[requestId].headers.TryGetValue(header,out value)) - return value; - } - else - { + { + if (m_RequestMap.ContainsKey(requestId)) + { + UrlData urlData=m_RequestMap[requestId]; + string value; + if (urlData.requests[requestId].headers.TryGetValue(header,out value)) + return value; + } + else + { m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); - } - return String.Empty; + } + return String.Empty; } public int GetFreeUrls() @@ -275,63 +275,63 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp foreach (string urlname in removeURLs) m_UrlMap.Remove(urlname); } - } - + } + private void RemoveUrl(UrlData data) { - m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); - } - - private Hashtable NoEvents(UUID requestID, UUID sessionID) - { - Hashtable response = new Hashtable(); - UrlData url; - lock (m_RequestMap) - { - if (!m_RequestMap.ContainsKey(requestID)) - return response; - url = m_RequestMap[requestID]; - } - - if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) - { - response["int_response_code"] = 500; - response["str_response_string"] = "Script timeout"; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - - //remove from map - lock (url) - { - url.requests.Remove(requestID); - m_RequestMap.Remove(requestID); - } - - return response; + m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); + } + + private Hashtable NoEvents(UUID requestID, UUID sessionID) + { + Hashtable response = new Hashtable(); + UrlData url; + lock (m_RequestMap) + { + if (!m_RequestMap.ContainsKey(requestID)) + return response; + url = m_RequestMap[requestID]; + } + + if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) + { + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + //remove from map + lock (url) + { + url.requests.Remove(requestID); + m_RequestMap.Remove(requestID); + } + + return response; } - - return response; - } - + + return response; + } + private bool HasEvents(UUID requestID, UUID sessionID) { - UrlData url=null; + UrlData url=null; lock (m_RequestMap) - { - if (!m_RequestMap.ContainsKey(requestID)) - { - return false; - } - url = m_RequestMap[requestID]; - if (!url.requests.ContainsKey(requestID)) - { - return false; + { + if (!m_RequestMap.ContainsKey(requestID)) + { + return false; } - } + url = m_RequestMap[requestID]; + if (!url.requests.ContainsKey(requestID)) + { + return false; + } + } if (System.Environment.TickCount-url.requests[requestID].startTime>25000) { @@ -343,146 +343,146 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp else return false; - } - private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) - { - UrlData url = null; - RequestData requestData = null; - - lock (m_RequestMap) - { - if (!m_RequestMap.ContainsKey(requestID)) - return NoEvents(requestID,sessionID); - url = m_RequestMap[requestID]; - requestData = url.requests[requestID]; - } - - if (!requestData.requestDone) - return NoEvents(requestID,sessionID); - - Hashtable response = new Hashtable(); - - if (System.Environment.TickCount - requestData.startTime > 25000) - { - response["int_response_code"] = 500; - response["str_response_string"] = "Script timeout"; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - return response; - } - //put response - response["int_response_code"] = requestData.responseCode; - response["str_response_string"] = requestData.responseBody; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - - //remove from map - lock (url) - { - url.requests.Remove(requestID); - m_RequestMap.Remove(requestID); - } - - return response; - } + } + private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) + { + UrlData url = null; + RequestData requestData = null; + + lock (m_RequestMap) + { + if (!m_RequestMap.ContainsKey(requestID)) + return NoEvents(requestID,sessionID); + url = m_RequestMap[requestID]; + requestData = url.requests[requestID]; + } + + if (!requestData.requestDone) + return NoEvents(requestID,sessionID); + + Hashtable response = new Hashtable(); + + if (System.Environment.TickCount - requestData.startTime > 25000) + { + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + return response; + } + //put response + response["int_response_code"] = requestData.responseCode; + response["str_response_string"] = requestData.responseBody; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + //remove from map + lock (url) + { + url.requests.Remove(requestID); + m_RequestMap.Remove(requestID); + } + + return response; + } public void HttpRequestHandler(UUID requestID, Hashtable request) - { - lock (request) - { - string uri = request["uri"].ToString(); - - try - { - Hashtable headers = (Hashtable)request["headers"]; - - string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; - - int pos1 = uri.IndexOf("/");// /lslhttp - int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ - int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp// - string uri_tmp = uri.Substring(0, pos3 + 1); - //HTTP server code doesn't provide us with QueryStrings - string pathInfo; - string queryString; - queryString = ""; - - pathInfo = uri.Substring(pos3); - - UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; - - //for llGetHttpHeader support we need to store original URI here - //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers - //as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader - - RequestData requestData = new RequestData(); - requestData.requestID = requestID; - requestData.requestDone = false; - requestData.startTime = System.Environment.TickCount; - requestData.uri = uri; - if (requestData.headers == null) - requestData.headers = new Dictionary(); - - foreach (DictionaryEntry header in headers) - { - string key = (string)header.Key; - string value = (string)header.Value; - requestData.headers.Add(key, value); - } - foreach (DictionaryEntry de in request) - { - if (de.Key.ToString() == "querystringkeys") - { - System.String[] keys = (System.String[])de.Value; - foreach (String key in keys) - { - if (request.ContainsKey(key)) - { - string val = (String)request[key]; - queryString = queryString + key + "=" + val + "&"; - } - } - if (queryString.Length > 1) - queryString = queryString.Substring(0, queryString.Length - 1); - - } - - } - - //if this machine is behind DNAT/port forwarding, currently this is being - //set to address of port forwarding router - requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; - requestData.headers["x-path-info"] = pathInfo; - requestData.headers["x-query-string"] = queryString; - requestData.headers["x-script-url"] = url.url; - - requestData.ev = new ManualResetEvent(false); - lock (url.requests) - { - url.requests.Add(requestID, requestData); - } - lock (m_RequestMap) - { - //add to request map - m_RequestMap.Add(requestID, url); - } - - url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); - - //send initial response? - Hashtable response = new Hashtable(); - - return; - - } - catch (Exception we) - { - //Hashtable response = new Hashtable(); - m_log.Warn("[HttpRequestHandler]: http-in request failed"); - m_log.Warn(we.Message); - m_log.Warn(we.StackTrace); - } + { + lock (request) + { + string uri = request["uri"].ToString(); + + try + { + Hashtable headers = (Hashtable)request["headers"]; + + string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; + + int pos1 = uri.IndexOf("/");// /lslhttp + int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ + int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp// + string uri_tmp = uri.Substring(0, pos3 + 1); + //HTTP server code doesn't provide us with QueryStrings + string pathInfo; + string queryString; + queryString = ""; + + pathInfo = uri.Substring(pos3); + + UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; + + //for llGetHttpHeader support we need to store original URI here + //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers + //as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader + + RequestData requestData = new RequestData(); + requestData.requestID = requestID; + requestData.requestDone = false; + requestData.startTime = System.Environment.TickCount; + requestData.uri = uri; + if (requestData.headers == null) + requestData.headers = new Dictionary(); + + foreach (DictionaryEntry header in headers) + { + string key = (string)header.Key; + string value = (string)header.Value; + requestData.headers.Add(key, value); + } + foreach (DictionaryEntry de in request) + { + if (de.Key.ToString() == "querystringkeys") + { + System.String[] keys = (System.String[])de.Value; + foreach (String key in keys) + { + if (request.ContainsKey(key)) + { + string val = (String)request[key]; + queryString = queryString + key + "=" + val + "&"; + } + } + if (queryString.Length > 1) + queryString = queryString.Substring(0, queryString.Length - 1); + + } + + } + + //if this machine is behind DNAT/port forwarding, currently this is being + //set to address of port forwarding router + requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; + requestData.headers["x-path-info"] = pathInfo; + requestData.headers["x-query-string"] = queryString; + requestData.headers["x-script-url"] = url.url; + + requestData.ev = new ManualResetEvent(false); + lock (url.requests) + { + url.requests.Add(requestID, requestData); + } + lock (m_RequestMap) + { + //add to request map + m_RequestMap.Add(requestID, url); + } + + url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); + + //send initial response? + Hashtable response = new Hashtable(); + + return; + + } + catch (Exception we) + { + //Hashtable response = new Hashtable(); + m_log.Warn("[HttpRequestHandler]: http-in request failed"); + m_log.Warn(we.Message); + m_log.Warn(we.StackTrace); + } } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index b7e3213..e3cb05c 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -63,6 +63,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // This is key-ed on agent ID protected Dictionary m_knownRegions = new Dictionary(); + protected Dictionary m_HyperlinkHandles = new Dictionary(); + #region ISharedRegionModule public Type ReplaceableInterface @@ -160,10 +162,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (regionInfo.RegionID.Equals(UUID.Zero)) { m_log.Info("[HGrid]: Linking remote region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort); - regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo); + ulong regionHandle = 0; + regionInfo.RegionID = m_HypergridServiceConnector.LinkRegion(regionInfo, out regionHandle); if (!regionInfo.RegionID.Equals(UUID.Zero)) { - m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); + AddHyperlinkRegion(regionInfo, regionHandle); m_log.Info("[HGrid]: Successfully linked to region_uuid " + regionInfo.RegionID); // Try get the map image @@ -186,15 +189,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // Try the hyperlink collection if (m_HyperlinkRegions.ContainsKey(regionID)) { - m_HyperlinkRegions.Remove(regionID); + RemoveHyperlinkRegion(regionID); return true; } // Try the foreign users home collection - if (m_knownRegions.ContainsKey(regionID)) - { - m_knownRegions.Remove(regionID); - return true; - } + + foreach (SimpleRegionInfo r in m_knownRegions.Values) + if (r.RegionID == regionID) + { + RemoveHyperlinkHomeRegion(regionID); + return true; + } + // Finally, try the normal route return m_GridServiceConnector.DeregisterRegion(regionID); } @@ -213,8 +219,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_HyperlinkRegions[regionID]; // Try the foreign users home collection - if (m_knownRegions.ContainsKey(regionID)) - return m_knownRegions[regionID]; + foreach (SimpleRegionInfo r in m_knownRegions.Values) + if (r.RegionID == regionID) + return m_knownRegions[regionID]; // Finally, try the normal route return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); @@ -249,20 +256,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (region != null) return region; - // !!! Commenting until region name exists - //// Try the hyperlink collection - //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) - //{ - // if (r.RegionName == regionName) - // return r; - //} - - //// Try the foreign users home collection - //foreach (SimpleRegionInfo r in m_knownRegions.Values) - //{ - // if (r.RegionName == regionName) - // return r; - //} + // Try the hyperlink collection + foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + { + if (r.RegionName == regionName) + return r; + } + + // Try the foreign users home collection + foreach (SimpleRegionInfo r in m_knownRegions.Values) + { + if (r.RegionName == regionName) + return r; + } return null; } @@ -299,6 +305,35 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #endregion + private void AddHyperlinkRegion(SimpleRegionInfo regionInfo, ulong regionHandle) + { + m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); + m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); + } + + private void RemoveHyperlinkRegion(UUID regionID) + { + m_HyperlinkRegions.Remove(regionID); + m_HyperlinkHandles.Remove(regionID); + } + + private void AddHyperlinkHomeRegion(UUID userID, SimpleRegionInfo regionInfo, ulong regionHandle) + { + m_knownRegions.Add(userID, regionInfo); + m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); + } + + private void RemoveHyperlinkHomeRegion(UUID regionID) + { + foreach (KeyValuePair kvp in m_knownRegions) + { + if (kvp.Value.RegionID == regionID) + { + m_knownRegions.Remove(kvp.Key); + } + } + m_HyperlinkHandles.Remove(regionID); + } } } diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b631478..d4d5ccc 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -7838,8 +7838,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetHTTPHeader(LSL_Key request_id, string header) { m_host.AddScriptLPS(1); - - if (m_UrlModule != null) + + if (m_UrlModule != null) return m_UrlModule.GetHttpHeader(new UUID(request_id), header); return String.Empty; } @@ -9124,9 +9124,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Partial implementation: support for parameter flags needed // see http://wiki.secondlife.com/wiki/llHTTPResponse - m_host.AddScriptLPS(1); - - if (m_UrlModule != null) + m_host.AddScriptLPS(1); + + if (m_UrlModule != null) m_UrlModule.HttpResponse(new UUID(id), status,body); } -- cgit v1.1 From 882d2c9cc399c4c7d1809702104ce94c9c2c7b17 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Tue, 22 Sep 2009 20:25:00 -0700 Subject: Added hg console commands to the module. Added the IN connector module for link-region and corresponding handler to be used in the regions only. No service as such is needed. This will replace the current link-region machinery. Compiles but not tested. --- .../Grid/HypergridServiceInConnectorModule.cs | 129 +++++++++ .../ServiceConnectorsOut/Grid/HGCommands.cs | 295 +++++++++++++++++++++ .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 213 ++++++++++++++- .../Grid/RemoteGridServiceConnector.cs | 64 ++++- 4 files changed, 696 insertions(+), 5 deletions(-) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs new file mode 100644 index 0000000..8d113d3 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs @@ -0,0 +1,129 @@ +/* + * 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.Reflection; +using System.Collections.Generic; +using log4net; +using Nini.Config; +using OpenSim.Framework; +using OpenSim.Framework.Servers.HttpServer; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Interfaces; +using OpenSim.Server.Base; +using OpenSim.Server.Handlers.Base; +using OpenSim.Server.Handlers.Grid; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid +{ + public class HypergridServiceInConnectorModule : ISharedRegionModule + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private static bool m_Enabled = false; + + private IConfigSource m_Config; + bool m_Registered = false; + HypergridServiceInConnector m_HypergridHandler; + + #region IRegionModule interface + + public void Initialise(IConfigSource config) + { + //// This module is only on for standalones in hypergrid mode + //enabled = (!config.Configs["Startup"].GetBoolean("gridmode", true)) && + // config.Configs["Startup"].GetBoolean("hypergrid", true); + //m_log.DebugFormat("[RegionInventoryService]: enabled? {0}", enabled); + m_Config = config; + IConfig moduleConfig = config.Configs["Modules"]; + if (moduleConfig != null) + { + m_Enabled = moduleConfig.GetBoolean("HypergridServiceInConnector", false); + if (m_Enabled) + { + m_log.Info("[INVENTORY IN CONNECTOR]: Hypergrid Service In Connector enabled"); + } + + } + + } + + public void PostInitialise() + { + } + + public void Close() + { + } + + public Type ReplaceableInterface + { + get { return null; } + } + + public string Name + { + get { return "HypergridService"; } + } + + public void AddRegion(Scene scene) + { + if (!m_Enabled) + return; + + if (!m_Registered) + { + m_Registered = true; + + m_log.Info("[HypergridService]: Starting..."); + + Object[] args = new Object[] { m_Config, MainServer.Instance }; + + m_HypergridHandler = new HypergridServiceInConnector(m_Config, MainServer.Instance); + //ServerUtils.LoadPlugin("OpenSim.Server.Handlers.dll:HypergridServiceInConnector", args); + } + + SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo); + m_HypergridHandler.AddRegion(rinfo); + } + + public void RemoveRegion(Scene scene) + { + if (!m_Enabled) + return; + + SimpleRegionInfo rinfo = new SimpleRegionInfo(scene.RegionInfo); + m_HypergridHandler.RemoveRegion(rinfo); + } + + public void RegionLoaded(Scene scene) + { + } + + #endregion + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs new file mode 100644 index 0000000..eee3a6c --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs @@ -0,0 +1,295 @@ +/* + * 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.Collections.Generic; +using System.Reflection; +using System.Xml; +using log4net; +using Nini.Config; +using OpenSim.Framework; +//using OpenSim.Framework.Communications; +using OpenSim.Framework.Console; +using OpenSim.Region.Framework; +using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Hypergrid; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid +{ + public class HGCommands + { + private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); + private HGGridConnector m_HGGridConnector; + private Scene m_scene; + + private static uint m_autoMappingX = 0; + private static uint m_autoMappingY = 0; + private static bool m_enableAutoMapping = false; + + public HGCommands(HGGridConnector hgConnector, Scene scene) + { + m_HGGridConnector = hgConnector; + m_scene = scene; + } + + //public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager, + // StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version) + //{ + // HGSceneCommunicationService sceneGridService = new HGSceneCommunicationService(m_commsManager, HGServices); + + // return + // new HGScene( + // regionInfo, circuitManager, m_commsManager, sceneGridService, storageManager, + // m_moduleLoader, false, m_configSettings.PhysicalPrim, + // m_configSettings.See_into_region_from_neighbor, m_config.Source, m_version); + //} + + public void RunCommand(string module, string[] cmdparams) + { + List args = new List(cmdparams); + if (args.Count < 1) + return; + + string command = args[0]; + args.RemoveAt(0); + + cmdparams = args.ToArray(); + + RunHGCommand(command, cmdparams); + + } + + private void RunHGCommand(string command, string[] cmdparams) + { + if (command.Equals("link-mapping")) + { + if (cmdparams.Length == 2) + { + try + { + m_autoMappingX = Convert.ToUInt32(cmdparams[0]); + m_autoMappingY = Convert.ToUInt32(cmdparams[1]); + m_enableAutoMapping = true; + } + catch (Exception) + { + m_autoMappingX = 0; + m_autoMappingY = 0; + m_enableAutoMapping = false; + } + } + } + else if (command.Equals("link-region")) + { + if (cmdparams.Length < 3) + { + if ((cmdparams.Length == 1) || (cmdparams.Length == 2)) + { + LoadXmlLinkFile(cmdparams); + } + else + { + LinkRegionCmdUsage(); + } + return; + } + + if (cmdparams[2].Contains(":")) + { + // New format + uint xloc, yloc; + string mapName; + try + { + xloc = Convert.ToUInt32(cmdparams[0]); + yloc = Convert.ToUInt32(cmdparams[1]); + mapName = cmdparams[2]; + if (cmdparams.Length > 3) + for (int i = 3; i < cmdparams.Length; i++) + mapName += " " + cmdparams[i]; + + m_log.Info(">> MapName: " + mapName); + //internalPort = Convert.ToUInt32(cmdparams[4]); + //remotingPort = Convert.ToUInt32(cmdparams[5]); + } + catch (Exception e) + { + m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message); + LinkRegionCmdUsage(); + return; + } + + m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc); + } + else + { + // old format + SimpleRegionInfo regInfo; + uint xloc, yloc; + uint externalPort; + string externalHostName; + try + { + xloc = Convert.ToUInt32(cmdparams[0]); + yloc = Convert.ToUInt32(cmdparams[1]); + externalPort = Convert.ToUInt32(cmdparams[3]); + externalHostName = cmdparams[2]; + //internalPort = Convert.ToUInt32(cmdparams[4]); + //remotingPort = Convert.ToUInt32(cmdparams[5]); + } + catch (Exception e) + { + m_log.Warn("[HGrid] Wrong format for link-region command: " + e.Message); + LinkRegionCmdUsage(); + return; + } + + //if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo)) + if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo)) + { + if (cmdparams.Length >= 5) + { + regInfo.RegionName = ""; + for (int i = 4; i < cmdparams.Length; i++) + regInfo.RegionName += cmdparams[i] + " "; + } + } + } + return; + } + else if (command.Equals("unlink-region")) + { + if (cmdparams.Length < 1) + { + UnlinkRegionCmdUsage(); + return; + } + if (m_HGGridConnector.TryUnlinkRegion(m_scene, cmdparams[0])) + m_log.InfoFormat("[HGrid]: Successfully unlinked {0}", cmdparams[0]); + else + m_log.InfoFormat("[HGrid]: Unable to unlink {0}, region not found", cmdparams[0]); + } + } + + private void LoadXmlLinkFile(string[] cmdparams) + { + //use http://www.hgurl.com/hypergrid.xml for test + try + { + XmlReader r = XmlReader.Create(cmdparams[0]); + XmlConfigSource cs = new XmlConfigSource(r); + string[] excludeSections = null; + + if (cmdparams.Length == 2) + { + if (cmdparams[1].ToLower().StartsWith("excludelist:")) + { + string excludeString = cmdparams[1].ToLower(); + excludeString = excludeString.Remove(0, 12); + char[] splitter = { ';' }; + + excludeSections = excludeString.Split(splitter); + } + } + + for (int i = 0; i < cs.Configs.Count; i++) + { + bool skip = false; + if ((excludeSections != null) && (excludeSections.Length > 0)) + { + for (int n = 0; n < excludeSections.Length; n++) + { + if (excludeSections[n] == cs.Configs[i].Name.ToLower()) + { + skip = true; + break; + } + } + } + if (!skip) + { + ReadLinkFromConfig(cs.Configs[i]); + } + } + } + catch (Exception e) + { + m_log.Error(e.ToString()); + } + } + + + private void ReadLinkFromConfig(IConfig config) + { + SimpleRegionInfo regInfo; + uint xloc, yloc; + uint externalPort; + string externalHostName; + uint realXLoc, realYLoc; + + xloc = Convert.ToUInt32(config.GetString("xloc", "0")); + yloc = Convert.ToUInt32(config.GetString("yloc", "0")); + externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); + externalHostName = config.GetString("externalHostName", ""); + realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); + realYLoc = Convert.ToUInt32(config.GetString("real-yloc", "0")); + + if (m_enableAutoMapping) + { + xloc = (uint)((xloc % 100) + m_autoMappingX); + yloc = (uint)((yloc % 100) + m_autoMappingY); + } + + if (((realXLoc == 0) && (realYLoc == 0)) || + (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && + ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) + { + if ( + m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, + externalHostName, out regInfo)) + { + regInfo.RegionName = config.GetString("localName", ""); + } + } + } + + + private void LinkRegionCmdUsage() + { + m_log.Info("Usage: link-region :[:]"); + m_log.Info("Usage: link-region []"); + m_log.Info("Usage: link-region []"); + } + + private void UnlinkRegionCmdUsage() + { + m_log.Info("Usage: unlink-region :"); + m_log.Info("Usage: unlink-region "); + } + + } +} diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index e3cb05c..7aeb761 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -27,14 +27,18 @@ using System; using System.Collections.Generic; +using System.Net; using System.Reflection; +using System.Xml; using OpenSim.Framework; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; +using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Services.Interfaces; using OpenSim.Server.Base; using OpenSim.Services.Connectors.Grid; +using OpenSim.Framework.Console; using OpenMetaverse; using log4net; @@ -94,7 +98,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid InitialiseConnectorModule(source); - + m_Enabled = true; m_log.Info("[HGGRID CONNECTOR]: HG grid enabled"); } @@ -137,6 +141,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return; scene.RegisterModuleInterface(this); + } public void RemoveRegion(Scene scene) @@ -145,11 +150,25 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public void RegionLoaded(Scene scene) { - if (m_Enabled && !m_Initialized) + if (!m_Enabled) + return; + + if (!m_Initialized) { m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); m_Initialized = true; } + + HGCommands hgCommands = new HGCommands(this, scene); + scene.AddCommand("HG", "link-region", + "link-region :[:] ", + "Link a hypergrid region", hgCommands.RunCommand); + scene.AddCommand("HG", "unlink-region", + "unlink-region or : ", + "Unlink a hypergrid region", hgCommands.RunCommand); + scene.AddCommand("HG", "link-mapping", "link-mapping [ ] ", + "Set local coordinate to map HG regions to", hgCommands.RunCommand); + } #endregion @@ -305,6 +324,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #endregion + #region Auxiliary + private void AddHyperlinkRegion(SimpleRegionInfo regionInfo, ulong regionHandle) { m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); @@ -334,6 +355,194 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } m_HyperlinkHandles.Remove(regionID); } + #endregion + + #region Hyperlinks + + private static Random random = new Random(); + + public SimpleRegionInfo 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))) + { + SimpleRegionInfo regInfo; + bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); + if (success) + { + regInfo.RegionName = mapName; + return regInfo; + } + } + + return null; + } + + public SimpleRegionInfo 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 bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc, + string externalRegionName, uint externalPort, string externalHostName, out SimpleRegionInfo regInfo) + { + m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); + + regInfo = new SimpleRegionInfo(); + 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; + } + + // Finally, link it + try + { + RegisterRegion(UUID.Zero, 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)) + { + DeregisterRegion(regInfo.RegionID); + 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)) + { + DeregisterRegion(regInfo.RegionID); + 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 bool TryUnlinkRegion(Scene m_scene, string mapName) + { + SimpleRegionInfo 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]; + // } + foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) + regInfo = r; + } + else + { + foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + if (r.RegionName.Equals(mapName)) + regInfo = r; + } + if (regInfo != null) + { + return DeregisterRegion(regInfo.RegionID); + } + else + { + m_log.InfoFormat("[HGrid]: Region {0} not found", mapName); + return false; + } + } + + /// + /// Cope with this viewer limitation. + /// + /// + /// + public bool Check4096(Scene m_scene, SimpleRegionInfo regInfo, out uint x, out uint y) + { + ulong realHandle = m_HyperlinkHandles[regInfo.RegionID]; + 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; + } + + public bool CheckCoords(uint thisx, uint thisy, uint x, uint y) + { + if ((thisx == x) && (thisy == y)) + return false; + return true; + } + + #endregion } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 22b1015..8526653 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -30,6 +30,8 @@ using System; using System.Collections.Generic; using System.Reflection; using Nini.Config; +using OpenMetaverse; + using OpenSim.Framework; using OpenSim.Services.Connectors; using OpenSim.Region.Framework.Interfaces; @@ -47,9 +49,11 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private bool m_Enabled = false; + private IGridService m_LocalGridService; + public RemoteGridServicesConnector(IConfigSource source) { - InitialiseService(source); + InitialiseServices(source); } #region ISharedRegionmodule @@ -72,14 +76,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid string name = moduleConfig.GetString("GridServices", ""); if (name == Name) { - InitialiseService(source); + InitialiseServices(source); m_Enabled = true; m_log.Info("[REMOTE GRID CONNECTOR]: Remote grid enabled"); } } } - private void InitialiseService(IConfigSource source) + private void InitialiseServices(IConfigSource source) { IConfig gridConfig = source.Configs["GridService"]; if (gridConfig == null) @@ -89,6 +93,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } base.Initialise(source); + + m_LocalGridService = new LocalGridServicesConnector(source); } public void PostInitialise() @@ -116,5 +122,57 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } #endregion + + #region IGridService + + public override bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + { + if (m_LocalGridService.RegisterRegion(scopeID, regionInfo)) + return base.RegisterRegion(scopeID, regionInfo); + + return false; + } + + public override bool DeregisterRegion(UUID regionID) + { + if (m_LocalGridService.DeregisterRegion(regionID)) + return base.DeregisterRegion(regionID); + + return false; + } + + // Let's not override GetNeighbours -- let's get them all from the grid server + + public override SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + { + SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID); + if (rinfo == null) + rinfo = base.GetRegionByUUID(scopeID, regionID); + + return rinfo; + } + + public override SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + { + SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); + if (rinfo == null) + rinfo = base.GetRegionByPosition(scopeID, x, y); + + return rinfo; + } + + public override SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + { + SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); + if (rinfo == null) + rinfo = base.GetRegionByName(scopeID, regionName); + + return rinfo; + } + + // Let's not override GetRegionsByName -- let's get them all from the grid server + // Let's not override GetRegionRange -- let's get them all from the grid server + + #endregion } } -- cgit v1.1 From 35deff7ec4df6156abccdbeed83b14a6083e28f9 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 09:27:01 -0700 Subject: Modules active. Tested HGGridConnector in standalone only for now. Modules commands work. --- .../Resources/CoreModulePlugin.addin.xml | 4 ++++ .../Grid/HypergridServiceInConnectorModule.cs | 2 +- .../ServiceConnectorsOut/Grid/HGCommands.cs | 6 ++--- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 28 +++++++++++++++------- .../Grid/LocalGridServiceConnector.cs | 4 ++++ .../Grid/RemoteGridServiceConnector.cs | 4 ++++ 6 files changed, 35 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml index f9e61aa..8f82718 100644 --- a/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml +++ b/OpenSim/Region/CoreModules/Resources/CoreModulePlugin.addin.xml @@ -38,11 +38,15 @@ + + + \ + \ diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs index 8d113d3..4fbee7f 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsIn/Grid/HypergridServiceInConnectorModule.cs @@ -64,7 +64,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Grid m_Enabled = moduleConfig.GetBoolean("HypergridServiceInConnector", false); if (m_Enabled) { - m_log.Info("[INVENTORY IN CONNECTOR]: Hypergrid Service In Connector enabled"); + m_log.Info("[HGGRID IN CONNECTOR]: Hypergrid Service In Connector enabled"); } } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs index eee3a6c..2a862d4 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs @@ -85,7 +85,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void RunHGCommand(string command, string[] cmdparams) { - if (command.Equals("link-mapping")) + if (command.Equals("linkk-mapping")) { if (cmdparams.Length == 2) { @@ -103,7 +103,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } } } - else if (command.Equals("link-region")) + else if (command.Equals("linkk-region")) { if (cmdparams.Length < 3) { @@ -181,7 +181,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } return; } - else if (command.Equals("unlink-region")) + else if (command.Equals("unlinkk-region")) { if (cmdparams.Length < 1) { diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index 7aeb761..c6ade15 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -156,18 +156,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (!m_Initialized) { m_HypergridServiceConnector = new HypergridServiceConnector(scene.AssetService); + HGCommands hgCommands = new HGCommands(this, scene); + MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-region", + "link-region :[:] ", + "Link a hypergrid region", hgCommands.RunCommand); + MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "unlinkk-region", + "unlink-region or : ", + "Unlink a hypergrid region", hgCommands.RunCommand); + MainConsole.Instance.Commands.AddCommand("HGGridServicesConnector", false, "linkk-mapping", "link-mapping [ ] ", + "Set local coordinate to map HG regions to", hgCommands.RunCommand); m_Initialized = true; } - HGCommands hgCommands = new HGCommands(this, scene); - scene.AddCommand("HG", "link-region", - "link-region :[:] ", - "Link a hypergrid region", hgCommands.RunCommand); - scene.AddCommand("HG", "unlink-region", - "unlink-region or : ", - "Unlink a hypergrid region", hgCommands.RunCommand); - scene.AddCommand("HG", "link-mapping", "link-mapping [ ] ", - "Set local coordinate to map HG regions to", hgCommands.RunCommand); + + //scene.AddCommand("HGGridServicesConnector", "linkk-region", + // "link-region :[:] ", + // "Link a hypergrid region", hgCommands.RunCommand); + //scene.AddCommand("HGGridServicesConnector", "unlinkk-region", + // "unlink-region or : ", + // "Unlink a hypergrid region", hgCommands.RunCommand); + //scene.AddCommand("HGGridServicesConnector", "linkk-mapping", "link-mapping [ ] ", + // "Set local coordinate to map HG regions to", hgCommands.RunCommand); } @@ -407,6 +416,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return null; } + // From the map search and secondlife://blah public SimpleRegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) { uint xloc = (uint)(random.Next(0, Int16.MaxValue)); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index 3f29401..c1b7235 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -50,6 +50,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private bool m_Enabled = false; + public LocalGridServicesConnector() + { + } + public LocalGridServicesConnector(IConfigSource source) { InitialiseService(source); diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 8526653..4303fa8 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -51,6 +51,10 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private IGridService m_LocalGridService; + public RemoteGridServicesConnector() + { + } + public RemoteGridServicesConnector(IConfigSource source) { InitialiseServices(source); -- cgit v1.1 From 9c2ffa8f2e49aa70e0b2c6afff875bbdb84ba0dc Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Wed, 23 Sep 2009 14:55:22 -0400 Subject: * fix endlines in LSL_api.cs --- .../Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs index b631478..4c52b11 100644 --- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs +++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs @@ -24,7 +24,7 @@ * (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.Collections; using System.Collections.Generic; @@ -7838,8 +7838,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api public LSL_String llGetHTTPHeader(LSL_Key request_id, string header) { m_host.AddScriptLPS(1); - - if (m_UrlModule != null) + + if (m_UrlModule != null) return m_UrlModule.GetHttpHeader(new UUID(request_id), header); return String.Empty; } @@ -9124,9 +9124,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api // Partial implementation: support for parameter flags needed // see http://wiki.secondlife.com/wiki/llHTTPResponse - m_host.AddScriptLPS(1); - - if (m_UrlModule != null) + m_host.AddScriptLPS(1); + + if (m_UrlModule != null) m_UrlModule.HttpResponse(new UUID(id), status,body); } -- cgit v1.1 From c592a60f4613587fd6c297de57f9958bcc60deaa Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Wed, 23 Sep 2009 15:00:18 -0400 Subject: Fix endlines on UrlModule.cs --- .../CoreModules/Scripting/LSLHttp/UrlModule.cs | 484 ++++++++++----------- 1 file changed, 242 insertions(+), 242 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 2d81e4c..8b7a878 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -54,12 +54,12 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { public UUID requestID; public Dictionary headers; - public string body; - public int responseCode; + public string body; + public int responseCode; public string responseBody; - public ManualResetEvent ev; + public ManualResetEvent ev; public bool requestDone; - public int startTime; + public int startTime; public string uri; } @@ -73,23 +73,23 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp new Dictionary(); private Dictionary m_UrlMap = - new Dictionary(); - + new Dictionary(); + private int m_TotalUrls = 100; - private IHttpServer m_HttpServer = null; - - private string m_ExternalHostNameForLSL = ""; + private IHttpServer m_HttpServer = null; + + private string m_ExternalHostNameForLSL = ""; public Type ReplaceableInterface { get { return null; } - } - - private Hashtable HandleHttpPoll(Hashtable request) - { - return new Hashtable(); + } + + private Hashtable HandleHttpPoll(Hashtable request) + { + return new Hashtable(); } public string Name @@ -98,7 +98,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } public void Initialise(IConfigSource config) - { + { m_ExternalHostNameForLSL = config.Configs["Network"].GetString("ExternalHostNameForLSL", System.Environment.MachineName); } @@ -130,7 +130,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp public void Close() { - } + } public UUID RequestURL(IScriptModule engine, SceneObjectPart host, UUID itemID) { UUID urlcode = UUID.Random(); @@ -141,8 +141,8 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_DENIED", "" }); return urlcode; - } - string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; + } + string url = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + "/lslhttp/" + urlcode.ToString() + "/"; UrlData urlData = new UrlData(); urlData.hostID = host.UUID; @@ -152,14 +152,14 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp urlData.urlcode = urlcode; urlData.requests = new Dictionary(); - - m_UrlMap[url] = urlData; - - string uri = "/lslhttp/" + urlcode.ToString() + "/"; - - m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, - new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, - urlcode)); + + m_UrlMap[url] = urlData; + + string uri = "/lslhttp/" + urlcode.ToString() + "/"; + + m_HttpServer.AddPollServiceHTTPHandler(uri,HandleHttpPoll, + new PollServiceEventArgs(HttpRequestHandler,HasEvents, GetEvents, NoEvents, + urlcode)); engine.PostScriptEvent(itemID, "http_request", new Object[] { urlcode.ToString(), "URL_REQUEST_GRANTED", url }); } @@ -180,11 +180,11 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { lock (m_UrlMap) { - UrlData data; - - if (!m_UrlMap.TryGetValue(url, out data)) - { - return; + UrlData data; + + if (!m_UrlMap.TryGetValue(url, out data)) + { + return; } foreach (UUID req in data.requests.Keys) @@ -196,36 +196,36 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp } public void HttpResponse(UUID request, int status, string body) - { - if (m_RequestMap.ContainsKey(request)) - { - UrlData urlData = m_RequestMap[request]; - RequestData requestData=urlData.requests[request]; - urlData.requests[request].responseCode = status; - urlData.requests[request].responseBody = body; - //urlData.requests[request].ev.Set(); - urlData.requests[request].requestDone=true; - } - else - { - m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); + { + if (m_RequestMap.ContainsKey(request)) + { + UrlData urlData = m_RequestMap[request]; + RequestData requestData=urlData.requests[request]; + urlData.requests[request].responseCode = status; + urlData.requests[request].responseBody = body; + //urlData.requests[request].ev.Set(); + urlData.requests[request].requestDone=true; + } + else + { + m_log.Info("[HttpRequestHandler] There is no http-in request with id " + request.ToString()); } } public string GetHttpHeader(UUID requestId, string header) - { - if (m_RequestMap.ContainsKey(requestId)) - { - UrlData urlData=m_RequestMap[requestId]; - string value; - if (urlData.requests[requestId].headers.TryGetValue(header,out value)) - return value; - } - else - { + { + if (m_RequestMap.ContainsKey(requestId)) + { + UrlData urlData=m_RequestMap[requestId]; + string value; + if (urlData.requests[requestId].headers.TryGetValue(header,out value)) + return value; + } + else + { m_log.Warn("[HttpRequestHandler] There was no http-in request with id " + requestId); - } - return String.Empty; + } + return String.Empty; } public int GetFreeUrls() @@ -275,63 +275,63 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp foreach (string urlname in removeURLs) m_UrlMap.Remove(urlname); } - } - + } + private void RemoveUrl(UrlData data) { - m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); - } - - private Hashtable NoEvents(UUID requestID, UUID sessionID) - { - Hashtable response = new Hashtable(); - UrlData url; - lock (m_RequestMap) - { - if (!m_RequestMap.ContainsKey(requestID)) - return response; - url = m_RequestMap[requestID]; - } - - if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) - { - response["int_response_code"] = 500; - response["str_response_string"] = "Script timeout"; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - - //remove from map - lock (url) - { - url.requests.Remove(requestID); - m_RequestMap.Remove(requestID); - } - - return response; + m_HttpServer.RemoveHTTPHandler("", "/lslhttp/"+data.urlcode.ToString()+"/"); + } + + private Hashtable NoEvents(UUID requestID, UUID sessionID) + { + Hashtable response = new Hashtable(); + UrlData url; + lock (m_RequestMap) + { + if (!m_RequestMap.ContainsKey(requestID)) + return response; + url = m_RequestMap[requestID]; + } + + if (System.Environment.TickCount - url.requests[requestID].startTime > 25000) + { + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + //remove from map + lock (url) + { + url.requests.Remove(requestID); + m_RequestMap.Remove(requestID); + } + + return response; } - - return response; - } - + + return response; + } + private bool HasEvents(UUID requestID, UUID sessionID) { - UrlData url=null; + UrlData url=null; lock (m_RequestMap) - { - if (!m_RequestMap.ContainsKey(requestID)) - { - return false; - } - url = m_RequestMap[requestID]; - if (!url.requests.ContainsKey(requestID)) - { - return false; + { + if (!m_RequestMap.ContainsKey(requestID)) + { + return false; } - } + url = m_RequestMap[requestID]; + if (!url.requests.ContainsKey(requestID)) + { + return false; + } + } if (System.Environment.TickCount-url.requests[requestID].startTime>25000) { @@ -343,146 +343,146 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp else return false; - } - private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) - { - UrlData url = null; - RequestData requestData = null; - - lock (m_RequestMap) - { - if (!m_RequestMap.ContainsKey(requestID)) - return NoEvents(requestID,sessionID); - url = m_RequestMap[requestID]; - requestData = url.requests[requestID]; - } - - if (!requestData.requestDone) - return NoEvents(requestID,sessionID); - - Hashtable response = new Hashtable(); - - if (System.Environment.TickCount - requestData.startTime > 25000) - { - response["int_response_code"] = 500; - response["str_response_string"] = "Script timeout"; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - return response; - } - //put response - response["int_response_code"] = requestData.responseCode; - response["str_response_string"] = requestData.responseBody; - response["content_type"] = "text/plain"; - response["keepalive"] = false; - response["reusecontext"] = false; - - //remove from map - lock (url) - { - url.requests.Remove(requestID); - m_RequestMap.Remove(requestID); - } - - return response; - } + } + private Hashtable GetEvents(UUID requestID, UUID sessionID, string request) + { + UrlData url = null; + RequestData requestData = null; + + lock (m_RequestMap) + { + if (!m_RequestMap.ContainsKey(requestID)) + return NoEvents(requestID,sessionID); + url = m_RequestMap[requestID]; + requestData = url.requests[requestID]; + } + + if (!requestData.requestDone) + return NoEvents(requestID,sessionID); + + Hashtable response = new Hashtable(); + + if (System.Environment.TickCount - requestData.startTime > 25000) + { + response["int_response_code"] = 500; + response["str_response_string"] = "Script timeout"; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + return response; + } + //put response + response["int_response_code"] = requestData.responseCode; + response["str_response_string"] = requestData.responseBody; + response["content_type"] = "text/plain"; + response["keepalive"] = false; + response["reusecontext"] = false; + + //remove from map + lock (url) + { + url.requests.Remove(requestID); + m_RequestMap.Remove(requestID); + } + + return response; + } public void HttpRequestHandler(UUID requestID, Hashtable request) - { - lock (request) - { - string uri = request["uri"].ToString(); - - try - { - Hashtable headers = (Hashtable)request["headers"]; - - string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; - - int pos1 = uri.IndexOf("/");// /lslhttp - int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ - int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp// - string uri_tmp = uri.Substring(0, pos3 + 1); - //HTTP server code doesn't provide us with QueryStrings - string pathInfo; - string queryString; - queryString = ""; - - pathInfo = uri.Substring(pos3); - - UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; - - //for llGetHttpHeader support we need to store original URI here - //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers - //as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader - - RequestData requestData = new RequestData(); - requestData.requestID = requestID; - requestData.requestDone = false; - requestData.startTime = System.Environment.TickCount; - requestData.uri = uri; - if (requestData.headers == null) - requestData.headers = new Dictionary(); - - foreach (DictionaryEntry header in headers) - { - string key = (string)header.Key; - string value = (string)header.Value; - requestData.headers.Add(key, value); - } - foreach (DictionaryEntry de in request) - { - if (de.Key.ToString() == "querystringkeys") - { - System.String[] keys = (System.String[])de.Value; - foreach (String key in keys) - { - if (request.ContainsKey(key)) - { - string val = (String)request[key]; - queryString = queryString + key + "=" + val + "&"; - } - } - if (queryString.Length > 1) - queryString = queryString.Substring(0, queryString.Length - 1); - - } - - } - - //if this machine is behind DNAT/port forwarding, currently this is being - //set to address of port forwarding router - requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; - requestData.headers["x-path-info"] = pathInfo; - requestData.headers["x-query-string"] = queryString; - requestData.headers["x-script-url"] = url.url; - - requestData.ev = new ManualResetEvent(false); - lock (url.requests) - { - url.requests.Add(requestID, requestData); - } - lock (m_RequestMap) - { - //add to request map - m_RequestMap.Add(requestID, url); - } - - url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); - - //send initial response? - Hashtable response = new Hashtable(); - - return; - - } - catch (Exception we) - { - //Hashtable response = new Hashtable(); - m_log.Warn("[HttpRequestHandler]: http-in request failed"); - m_log.Warn(we.Message); - m_log.Warn(we.StackTrace); - } + { + lock (request) + { + string uri = request["uri"].ToString(); + + try + { + Hashtable headers = (Hashtable)request["headers"]; + + string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; + + int pos1 = uri.IndexOf("/");// /lslhttp + int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ + int pos3 = uri.IndexOf("/", pos2 + 1);// /lslhttp// + string uri_tmp = uri.Substring(0, pos3 + 1); + //HTTP server code doesn't provide us with QueryStrings + string pathInfo; + string queryString; + queryString = ""; + + pathInfo = uri.Substring(pos3); + + UrlData url = m_UrlMap["http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri_tmp]; + + //for llGetHttpHeader support we need to store original URI here + //to make x-path-info / x-query-string / x-script-url / x-remote-ip headers + //as per http://wiki.secondlife.com/wiki/LlGetHTTPHeader + + RequestData requestData = new RequestData(); + requestData.requestID = requestID; + requestData.requestDone = false; + requestData.startTime = System.Environment.TickCount; + requestData.uri = uri; + if (requestData.headers == null) + requestData.headers = new Dictionary(); + + foreach (DictionaryEntry header in headers) + { + string key = (string)header.Key; + string value = (string)header.Value; + requestData.headers.Add(key, value); + } + foreach (DictionaryEntry de in request) + { + if (de.Key.ToString() == "querystringkeys") + { + System.String[] keys = (System.String[])de.Value; + foreach (String key in keys) + { + if (request.ContainsKey(key)) + { + string val = (String)request[key]; + queryString = queryString + key + "=" + val + "&"; + } + } + if (queryString.Length > 1) + queryString = queryString.Substring(0, queryString.Length - 1); + + } + + } + + //if this machine is behind DNAT/port forwarding, currently this is being + //set to address of port forwarding router + requestData.headers["x-remote-ip"] = requestData.headers["remote_addr"]; + requestData.headers["x-path-info"] = pathInfo; + requestData.headers["x-query-string"] = queryString; + requestData.headers["x-script-url"] = url.url; + + requestData.ev = new ManualResetEvent(false); + lock (url.requests) + { + url.requests.Add(requestID, requestData); + } + lock (m_RequestMap) + { + //add to request map + m_RequestMap.Add(requestID, url); + } + + url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); + + //send initial response? + Hashtable response = new Hashtable(); + + return; + + } + catch (Exception we) + { + //Hashtable response = new Hashtable(); + m_log.Warn("[HttpRequestHandler]: http-in request failed"); + m_log.Warn(we.Message); + m_log.Warn(we.StackTrace); + } } } -- cgit v1.1 From 67276589c883fe1a74d8d52057db1431d637dade Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 17:20:07 -0700 Subject: Changed IGridService to use the new GridRegion data structure instead of old SimpleRegionInfo. Added grid configs to standalones. --- .../ServiceConnectorsOut/Grid/HGCommands.cs | 36 ++++++---- .../ServiceConnectorsOut/Grid/HGGridConnector.cs | 82 +++++++++++----------- .../Grid/LocalGridServiceConnector.cs | 18 ++--- .../Grid/RemoteGridServiceConnector.cs | 15 ++-- 4 files changed, 82 insertions(+), 69 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs index 2a862d4..36915ef 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGCommands.cs @@ -37,6 +37,7 @@ using OpenSim.Framework.Console; using OpenSim.Region.Framework; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Hypergrid; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { @@ -121,12 +122,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (cmdparams[2].Contains(":")) { // New format - uint xloc, yloc; + int xloc, yloc; string mapName; try { - xloc = Convert.ToUInt32(cmdparams[0]); - yloc = Convert.ToUInt32(cmdparams[1]); + xloc = Convert.ToInt32(cmdparams[0]); + yloc = Convert.ToInt32(cmdparams[1]); mapName = cmdparams[2]; if (cmdparams.Length > 3) for (int i = 3; i < cmdparams.Length; i++) @@ -143,19 +144,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return; } + // Convert cell coordinates given by the user to meters + xloc = xloc * (int)Constants.RegionSize; + yloc = yloc * (int)Constants.RegionSize; m_HGGridConnector.TryLinkRegionToCoords(m_scene, null, mapName, xloc, yloc); } else { // old format - SimpleRegionInfo regInfo; - uint xloc, yloc; + GridRegion regInfo; + int xloc, yloc; uint externalPort; string externalHostName; try { - xloc = Convert.ToUInt32(cmdparams[0]); - yloc = Convert.ToUInt32(cmdparams[1]); + xloc = Convert.ToInt32(cmdparams[0]); + yloc = Convert.ToInt32(cmdparams[1]); externalPort = Convert.ToUInt32(cmdparams[3]); externalHostName = cmdparams[2]; //internalPort = Convert.ToUInt32(cmdparams[4]); @@ -168,7 +172,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return; } - //if (TryCreateLink(xloc, yloc, externalPort, externalHostName, out regInfo)) + // Convert cell coordinates given by the user to meters + xloc = xloc * (int)Constants.RegionSize; + yloc = yloc * (int)Constants.RegionSize; if (m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo)) { if (cmdparams.Length >= 5) @@ -245,14 +251,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void ReadLinkFromConfig(IConfig config) { - SimpleRegionInfo regInfo; - uint xloc, yloc; + GridRegion regInfo; + int xloc, yloc; uint externalPort; string externalHostName; uint realXLoc, realYLoc; - xloc = Convert.ToUInt32(config.GetString("xloc", "0")); - yloc = Convert.ToUInt32(config.GetString("yloc", "0")); + xloc = Convert.ToInt32(config.GetString("xloc", "0")); + yloc = Convert.ToInt32(config.GetString("yloc", "0")); externalPort = Convert.ToUInt32(config.GetString("externalPort", "0")); externalHostName = config.GetString("externalHostName", ""); realXLoc = Convert.ToUInt32(config.GetString("real-xloc", "0")); @@ -260,14 +266,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (m_enableAutoMapping) { - xloc = (uint)((xloc % 100) + m_autoMappingX); - yloc = (uint)((yloc % 100) + m_autoMappingY); + xloc = (int)((xloc % 100) + m_autoMappingX); + yloc = (int)((yloc % 100) + m_autoMappingY); } if (((realXLoc == 0) && (realYLoc == 0)) || (((realXLoc - xloc < 3896) || (xloc - realXLoc < 3896)) && ((realYLoc - yloc < 3896) || (yloc - realYLoc < 3896)))) { + xloc = xloc * (int)Constants.RegionSize; + yloc = yloc * (int)Constants.RegionSize; if ( m_HGGridConnector.TryCreateLink(m_scene, null, xloc, yloc, "", externalPort, externalHostName, out regInfo)) diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs index c6ade15..0c2a835 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/HGGridConnector.cs @@ -36,6 +36,7 @@ using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes.Hypergrid; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenSim.Server.Base; using OpenSim.Services.Connectors.Grid; using OpenSim.Framework.Console; @@ -59,13 +60,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private HypergridServiceConnector m_HypergridServiceConnector; // Hyperlink regions are hyperlinks on the map - protected Dictionary m_HyperlinkRegions = new Dictionary(); + protected Dictionary m_HyperlinkRegions = new Dictionary(); // Known regions are home regions of visiting foreign users. // They are not on the map as static hyperlinks. They are dynamic hyperlinks, they go away when // the visitor goes away. They are mapped to X=0 on the map. // This is key-ed on agent ID - protected Dictionary m_knownRegions = new Dictionary(); + protected Dictionary m_knownRegions = new Dictionary(); protected Dictionary m_HyperlinkHandles = new Dictionary(); @@ -184,7 +185,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #region IGridService - public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + public bool RegisterRegion(UUID scopeID, GridRegion regionInfo) { // Region doesn't exist here. Trying to link remote region if (regionInfo.RegionID.Equals(UUID.Zero)) @@ -222,7 +223,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } // Try the foreign users home collection - foreach (SimpleRegionInfo r in m_knownRegions.Values) + foreach (GridRegion r in m_knownRegions.Values) if (r.RegionID == regionID) { RemoveHyperlinkHomeRegion(regionID); @@ -233,21 +234,21 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_GridServiceConnector.DeregisterRegion(regionID); } - public List GetNeighbours(UUID scopeID, UUID regionID) + public List GetNeighbours(UUID scopeID, UUID regionID) { // No serving neighbours on hyperliked regions. // Just the regular regions. return m_GridServiceConnector.GetNeighbours(scopeID, regionID); } - public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { // Try the hyperlink collection if (m_HyperlinkRegions.ContainsKey(regionID)) return m_HyperlinkRegions[regionID]; // Try the foreign users home collection - foreach (SimpleRegionInfo r in m_knownRegions.Values) + foreach (GridRegion r in m_knownRegions.Values) if (r.RegionID == regionID) return m_knownRegions[regionID]; @@ -255,19 +256,19 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_GridServiceConnector.GetRegionByUUID(scopeID, regionID); } - public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { int snapX = (int) (x / Constants.RegionSize) * (int)Constants.RegionSize; int snapY = (int) (y / Constants.RegionSize) * (int)Constants.RegionSize; // Try the hyperlink collection - foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + foreach (GridRegion r in m_HyperlinkRegions.Values) { if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) return r; } // Try the foreign users home collection - foreach (SimpleRegionInfo r in m_knownRegions.Values) + foreach (GridRegion r in m_knownRegions.Values) { if ((r.RegionLocX == snapX) && (r.RegionLocY == snapY)) return r; @@ -277,22 +278,22 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_GridServiceConnector.GetRegionByPosition(scopeID, x, y); } - public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public GridRegion GetRegionByName(UUID scopeID, string regionName) { // Try normal grid first - SimpleRegionInfo region = m_GridServiceConnector.GetRegionByName(scopeID, regionName); + GridRegion region = m_GridServiceConnector.GetRegionByName(scopeID, regionName); if (region != null) return region; // Try the hyperlink collection - foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + foreach (GridRegion r in m_HyperlinkRegions.Values) { if (r.RegionName == regionName) return r; } // Try the foreign users home collection - foreach (SimpleRegionInfo r in m_knownRegions.Values) + foreach (GridRegion r in m_knownRegions.Values) { if (r.RegionName == regionName) return r; @@ -300,9 +301,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return null; } - public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { - List rinfos = new List(); + List rinfos = new List(); // Commenting until regionname exists //foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) @@ -313,15 +314,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return rinfos; } - public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { int snapXmin = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; int snapXmax = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; int snapYmin = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; int snapYmax = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; - List rinfos = new List(); - foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + List rinfos = new List(); + foreach (GridRegion r in m_HyperlinkRegions.Values) if ((r.RegionLocX > snapXmin) && (r.RegionLocX < snapYmax) && (r.RegionLocY > snapYmin) && (r.RegionLocY < snapYmax)) rinfos.Add(r); @@ -335,7 +336,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #region Auxiliary - private void AddHyperlinkRegion(SimpleRegionInfo regionInfo, ulong regionHandle) + private void AddHyperlinkRegion(GridRegion regionInfo, ulong regionHandle) { m_HyperlinkRegions.Add(regionInfo.RegionID, regionInfo); m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); @@ -347,7 +348,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid m_HyperlinkHandles.Remove(regionID); } - private void AddHyperlinkHomeRegion(UUID userID, SimpleRegionInfo regionInfo, ulong regionHandle) + private void AddHyperlinkHomeRegion(UUID userID, GridRegion regionInfo, ulong regionHandle) { m_knownRegions.Add(userID, regionInfo); m_HyperlinkHandles.Add(regionInfo.RegionID, regionHandle); @@ -355,7 +356,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private void RemoveHyperlinkHomeRegion(UUID regionID) { - foreach (KeyValuePair kvp in m_knownRegions) + foreach (KeyValuePair kvp in m_knownRegions) { if (kvp.Value.RegionID == regionID) { @@ -370,7 +371,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid private static Random random = new Random(); - public SimpleRegionInfo TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, uint xloc, uint yloc) + public GridRegion TryLinkRegionToCoords(Scene m_scene, IClientAPI client, string mapName, int xloc, int yloc) { string host = "127.0.0.1"; string portstr; @@ -404,7 +405,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if ((ipaddr != null) && !((m_scene.RegionInfo.ExternalEndPoint.Address.Equals(ipaddr)) && (m_scene.RegionInfo.HttpPort == port))) { - SimpleRegionInfo regInfo; + GridRegion regInfo; bool success = TryCreateLink(m_scene, client, xloc, yloc, regionName, port, host, out regInfo); if (success) { @@ -417,18 +418,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid } // From the map search and secondlife://blah - public SimpleRegionInfo TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) + public GridRegion TryLinkRegion(Scene m_scene, IClientAPI client, string mapName) { - uint xloc = (uint)(random.Next(0, Int16.MaxValue)); + int xloc = random.Next(0, Int16.MaxValue); return TryLinkRegionToCoords(m_scene, client, mapName, xloc, 0); } - public bool TryCreateLink(Scene m_scene, IClientAPI client, uint xloc, uint yloc, - string externalRegionName, uint externalPort, string externalHostName, out SimpleRegionInfo regInfo) + public bool TryCreateLink(Scene m_scene, IClientAPI client, int xloc, int yloc, + string externalRegionName, uint externalPort, string externalHostName, out GridRegion regInfo) { m_log.DebugFormat("[HGrid]: Link to {0}:{1}, in {2}-{3}", externalHostName, externalPort, xloc, yloc); - regInfo = new SimpleRegionInfo(); + regInfo = new GridRegion(); regInfo.RegionName = externalRegionName; regInfo.HttpPort = externalPort; regInfo.ExternalHostName = externalHostName; @@ -456,7 +457,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return false; } - uint x, y; + int x, y; if (!Check4096(m_scene, regInfo, out x, out y)) { DeregisterRegion(regInfo.RegionID); @@ -481,7 +482,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public bool TryUnlinkRegion(Scene m_scene, string mapName) { - SimpleRegionInfo regInfo = null; + GridRegion regInfo = null; if (mapName.Contains(":")) { string host = "127.0.0.1"; @@ -504,13 +505,13 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // { // regionName = parts[2]; // } - foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + foreach (GridRegion r in m_HyperlinkRegions.Values) if (host.Equals(r.ExternalHostName) && (port == r.HttpPort)) regInfo = r; } else { - foreach (SimpleRegionInfo r in m_HyperlinkRegions.Values) + foreach (GridRegion r in m_HyperlinkRegions.Values) if (r.RegionName.Equals(mapName)) regInfo = r; } @@ -530,22 +531,23 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid /// /// /// - public bool Check4096(Scene m_scene, SimpleRegionInfo regInfo, out uint x, out uint y) + public bool Check4096(Scene m_scene, GridRegion regInfo, out int x, out int y) { ulong realHandle = m_HyperlinkHandles[regInfo.RegionID]; - Utils.LongToUInts(realHandle, out x, out y); - x = x / Constants.RegionSize; - y = y / Constants.RegionSize; + uint ux = 0, uy = 0; + Utils.LongToUInts(realHandle, out ux, out uy); + x = (int)(ux / Constants.RegionSize); + y = (int)(uy / Constants.RegionSize); - if ((Math.Abs((int)m_scene.RegionInfo.RegionLocX - (int)x) >= 4096) || - (Math.Abs((int)m_scene.RegionInfo.RegionLocY - (int)y) >= 4096)) + if ((Math.Abs((int)(m_scene.RegionInfo.RegionLocX / Constants.RegionSize) - x) >= 4096) || + (Math.Abs((int)(m_scene.RegionInfo.RegionLocY / Constants.RegionSize) - y) >= 4096)) { return false; } return true; } - public bool CheckCoords(uint thisx, uint thisy, uint x, uint y) + public bool CheckCoords(uint thisx, uint thisy, int x, int y) { if ((thisx == x) && (thisy == y)) return false; diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs index c1b7235..743d3b9 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/LocalGridServiceConnector.cs @@ -35,6 +35,7 @@ using OpenSim.Server.Base; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; using OpenMetaverse; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid @@ -56,6 +57,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid public LocalGridServicesConnector(IConfigSource source) { + m_log.Debug("[LOCAL GRID CONNECTOR]: LocalGridServicesConnector instantiated"); InitialiseService(source); } @@ -111,7 +113,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid if (m_GridService == null) { - m_log.Error("[LOCAL GRID CONNECTOR]: Can't load asset service"); + m_log.Error("[LOCAL GRID CONNECTOR]: Can't load grid service"); return; } } @@ -144,7 +146,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #region IGridService - public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + public bool RegisterRegion(UUID scopeID, GridRegion regionInfo) { return m_GridService.RegisterRegion(scopeID, regionInfo); } @@ -154,32 +156,32 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid return m_GridService.DeregisterRegion(regionID); } - public List GetNeighbours(UUID scopeID, UUID regionID) + public List GetNeighbours(UUID scopeID, UUID regionID) { return m_GridService.GetNeighbours(scopeID, regionID); } - public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { return m_GridService.GetRegionByUUID(scopeID, regionID); } - public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { return m_GridService.GetRegionByPosition(scopeID, x, y); } - public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public GridRegion GetRegionByName(UUID scopeID, string regionName) { return m_GridService.GetRegionByName(scopeID, regionName); } - public List GetRegionsByName(UUID scopeID, string name, int maxNumber) + public List GetRegionsByName(UUID scopeID, string name, int maxNumber) { return m_GridService.GetRegionsByName(scopeID, name, maxNumber); } - public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) + public List GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) { return m_GridService.GetRegionRange(scopeID, xmin, xmax, ymin, ymax); } diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs index 4303fa8..91a808b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/RemoteGridServiceConnector.cs @@ -37,6 +37,7 @@ using OpenSim.Services.Connectors; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; using OpenSim.Services.Interfaces; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid { @@ -129,7 +130,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid #region IGridService - public override bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfo) + public override bool RegisterRegion(UUID scopeID, GridRegion regionInfo) { if (m_LocalGridService.RegisterRegion(scopeID, regionInfo)) return base.RegisterRegion(scopeID, regionInfo); @@ -147,27 +148,27 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid // Let's not override GetNeighbours -- let's get them all from the grid server - public override SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) + public override GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) { - SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID); + GridRegion rinfo = m_LocalGridService.GetRegionByUUID(scopeID, regionID); if (rinfo == null) rinfo = base.GetRegionByUUID(scopeID, regionID); return rinfo; } - public override SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) + public override GridRegion GetRegionByPosition(UUID scopeID, int x, int y) { - SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); + GridRegion rinfo = m_LocalGridService.GetRegionByPosition(scopeID, x, y); if (rinfo == null) rinfo = base.GetRegionByPosition(scopeID, x, y); return rinfo; } - public override SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) + public override GridRegion GetRegionByName(UUID scopeID, string regionName) { - SimpleRegionInfo rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); + GridRegion rinfo = m_LocalGridService.GetRegionByName(scopeID, regionName); if (rinfo == null) rinfo = base.GetRegionByName(scopeID, regionName); -- cgit v1.1 From 3c19bd5142479e468aa9841a2177ddd33b46f8f6 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 20:35:16 -0700 Subject: Unit tests for the grid service. Yey! --- .../Grid/Tests/GridConnectorsTests.cs | 122 +++++++++++++++++++++ 1 file changed, 122 insertions(+) create mode 100644 OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs new file mode 100644 index 0000000..8d44249 --- /dev/null +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs @@ -0,0 +1,122 @@ +/* + * 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.Collections.Generic; +using System.IO; +using System.Reflection; +using System.Threading; +using log4net.Config; +using NUnit.Framework; +using NUnit.Framework.SyntaxHelpers; +using OpenMetaverse; +using OpenSim.Framework; +using Nini.Config; + +using OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid; +using OpenSim.Region.Framework.Scenes; +using GridRegion = OpenSim.Services.Interfaces.GridRegion; +using OpenSim.Tests.Common; +using OpenSim.Tests.Common.Setup; + +namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests +{ + [TestFixture] + public class GridConnectorsTests + { + LocalGridServicesConnector m_LocalConnector; + private void SetUp() + { + IConfigSource config = new IniConfigSource(); + config.AddConfig("Modules"); + config.AddConfig("GridService"); + config.Configs["Modules"].Set("GridServices", "LocalGridServicesConnector"); + config.Configs["GridService"].Set("LocalServiceModule", "OpenSim.Services.GridService.dll:GridService"); + config.Configs["GridService"].Set("StorageProvider", "OpenSim.Data.Null.dll:NullRegionData"); + + m_LocalConnector = new LocalGridServicesConnector(config); + } + + /// + /// Test saving a V0.2 OpenSim Region Archive. + /// + [Test] + public void TestRegisterRegionV0_2() + { + SetUp(); + + // Create 3 regions + GridRegion r1 = new GridRegion(); + r1.RegionName = "Test Region 1"; + r1.RegionID = new UUID(1); + r1.RegionLocX = 1000 * (int)Constants.RegionSize; + r1.RegionLocY = 1000 * (int)Constants.RegionSize; + r1.ExternalHostName = "127.0.0.1"; + r1.HttpPort = 9001; + r1.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); + + GridRegion r2 = new GridRegion(); + r2.RegionName = "Test Region 2"; + r2.RegionID = new UUID(2); + r2.RegionLocX = 1000 * (int)Constants.RegionSize + 1; + r2.RegionLocY = 1000 * (int)Constants.RegionSize; + r2.ExternalHostName = "127.0.0.1"; + r2.HttpPort = 9002; + r2.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); + + GridRegion r3 = new GridRegion(); + r3.RegionName = "Test Region 3"; + r3.RegionID = new UUID(3); + r3.RegionLocX = 1000 * (int)Constants.RegionSize + 5; + r3.RegionLocY = 1000 * (int)Constants.RegionSize; + r3.ExternalHostName = "127.0.0.1"; + r3.HttpPort = 9003; + r3.InternalEndPoint = new System.Net.IPEndPoint(System.Net.IPAddress.Parse("0.0.0.0"), 0); + + m_LocalConnector.RegisterRegion(UUID.Zero, r1); + GridRegion result = m_LocalConnector.GetRegionByName(UUID.Zero, "Test"); + Assert.IsNotNull(result, "Retrieved GetRegionByName is null"); + Assert.That(result.RegionName, Is.EqualTo("Test Region 1"), "Retrieved region's name does not match"); + + result = m_LocalConnector.GetRegionByUUID(UUID.Zero, new UUID(1)); + Assert.IsNotNull(result, "Retrieved GetRegionByUUID is null"); + Assert.That(result.RegionID, Is.EqualTo(new UUID(1)), "Retrieved region's UUID does not match"); + + result = m_LocalConnector.GetRegionByPosition(UUID.Zero, 1000 * (int)Constants.RegionSize, 1000 * (int)Constants.RegionSize); + Assert.IsNotNull(result, "Retrieved GetRegionByPosition is null"); + Assert.That(result.RegionLocX, Is.EqualTo(1000 * (int)Constants.RegionSize), "Retrieved region's position does not match"); + + m_LocalConnector.RegisterRegion(UUID.Zero, r2); + m_LocalConnector.RegisterRegion(UUID.Zero, r3); + + List results = m_LocalConnector.GetNeighbours(UUID.Zero, new UUID(1)); + Assert.IsNotNull(results, "Retrieved neighbours list is null"); + Assert.That(results.Count, Is.EqualTo(1), "Retrieved neighbour collection is greater than expected"); + Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2))); + } + } +} -- cgit v1.1 From fd8fb7735b0eb6150679ccad84b2a32fd5315a38 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 20:39:25 -0700 Subject: First test passes -- regions being registered and retrieved correctly in Data.Null. --- .../ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index 8d44249..bd3293d 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs @@ -82,7 +82,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests GridRegion r2 = new GridRegion(); r2.RegionName = "Test Region 2"; r2.RegionID = new UUID(2); - r2.RegionLocX = 1000 * (int)Constants.RegionSize + 1; + r2.RegionLocX = 1001 * (int)Constants.RegionSize; r2.RegionLocY = 1000 * (int)Constants.RegionSize; r2.ExternalHostName = "127.0.0.1"; r2.HttpPort = 9002; @@ -91,7 +91,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests GridRegion r3 = new GridRegion(); r3.RegionName = "Test Region 3"; r3.RegionID = new UUID(3); - r3.RegionLocX = 1000 * (int)Constants.RegionSize + 5; + r3.RegionLocX = 1005 * (int)Constants.RegionSize; r3.RegionLocY = 1000 * (int)Constants.RegionSize; r3.ExternalHostName = "127.0.0.1"; r3.HttpPort = 9003; -- cgit v1.1 From 1260c81a9cfc19306e2053a8b066e50c78dbc7c1 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Wed, 23 Sep 2009 20:51:04 -0700 Subject: More tests. Seems to be working. Grid connector modules are enabled for standalones only, but nothing in the simulator uses them yet, so it's safe to go in. --- .../ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs index bd3293d..be32d6b 100644 --- a/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs +++ b/OpenSim/Region/CoreModules/ServiceConnectorsOut/Grid/Tests/GridConnectorsTests.cs @@ -116,7 +116,16 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid.Tests List results = m_LocalConnector.GetNeighbours(UUID.Zero, new UUID(1)); Assert.IsNotNull(results, "Retrieved neighbours list is null"); Assert.That(results.Count, Is.EqualTo(1), "Retrieved neighbour collection is greater than expected"); - Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2))); + Assert.That(results[0].RegionID, Is.EqualTo(new UUID(2)), "Retrieved region's UUID does not match"); + + results = m_LocalConnector.GetRegionsByName(UUID.Zero, "Test", 10); + Assert.IsNotNull(results, "Retrieved GetRegionsByName list is null"); + Assert.That(results.Count, Is.EqualTo(3), "Retrieved neighbour collection is less than expected"); + + results = m_LocalConnector.GetRegionRange(UUID.Zero, 900 * (int)Constants.RegionSize, 1002 * (int)Constants.RegionSize, + 900 * (int)Constants.RegionSize, 1100 * (int)Constants.RegionSize); + Assert.IsNotNull(results, "Retrieved GetRegionRange list is null"); + Assert.That(results.Count, Is.EqualTo(2), "Retrieved neighbour collection is not the number expected"); } } } -- cgit v1.1 From aca9fd182ee6dec5ac778f7aafd9a8fa6a5fd4e2 Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 24 Sep 2009 20:27:11 +1000 Subject: * Added two new commands to EstateManagementModule * Also, I hate git. --- .../World/Estate/EstateManagementModule.cs | 61 +++++++++++++++++++--- 1 file changed, 55 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index 75b3fe6..f52a287 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -33,7 +33,6 @@ using log4net; using Nini.Config; using OpenMetaverse; using OpenSim.Framework; -using OpenSim.Region.CoreModules.World.Terrain; using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Scenes; @@ -47,7 +46,7 @@ namespace OpenSim.Region.CoreModules.World.Estate private Scene m_scene; - private EstateTerrainXferHandler TerrainUploader = null; + private EstateTerrainXferHandler TerrainUploader; #region Packet Data Responders @@ -668,7 +667,7 @@ namespace OpenSim.Region.CoreModules.World.Estate LookupUUID(uuidNameLookupList); } - private void LookupUUIDSCompleted(IAsyncResult iar) + private static void LookupUUIDSCompleted(IAsyncResult iar) { LookupUUIDS icon = (LookupUUIDS)iar.AsyncState; icon.EndInvoke(iar); @@ -683,7 +682,7 @@ namespace OpenSim.Region.CoreModules.World.Estate } private void LookupUUIDsAsync(List uuidLst) { - UUID[] uuidarr = new UUID[0]; + UUID[] uuidarr; lock (uuidLst) { @@ -707,7 +706,7 @@ namespace OpenSim.Region.CoreModules.World.Estate for (int i = 0; i < avatars.Count; i++) { - HandleRegionInfoRequest(avatars[i].ControllingClient); ; + HandleRegionInfoRequest(avatars[i].ControllingClient); } } @@ -768,7 +767,7 @@ namespace OpenSim.Region.CoreModules.World.Estate else { m_scene.RegionInfo.EstateSettings.UseGlobalTime = false; - m_scene.RegionInfo.EstateSettings.SunPosition = (double)(parms2 - 0x1800)/1024.0; + m_scene.RegionInfo.EstateSettings.SunPosition = (parms2 - 0x1800)/1024.0; } if ((parms1 & 0x00000010) != 0) @@ -828,8 +827,58 @@ namespace OpenSim.Region.CoreModules.World.Estate m_scene.RegisterModuleInterface(this); m_scene.EventManager.OnNewClient += EventManager_OnNewClient; m_scene.EventManager.OnRequestChangeWaterHeight += changeWaterHeight; + + m_scene.AddCommand(this, "set terrain texture", + "set terrain texture [] []", + "Sets the terrain to , if or are specified, it will only " + + "set it on regions with a matching coordinate. Specify -1 in or to wildcard" + + " that coordinate.", + consoleSetTerrainTexture); + + m_scene.AddCommand(this, "set terrain heights", + "set terrain heights [] []", + "Sets the terrain texture heights on corner # to /, if or are specified, it will only " + + "set it on regions with a matching coordinate. Specify -1 in or to wildcard" + + " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.", + consoleSetTerrainTexture); } + #region Console Commands + + public void consoleSetTerrainTexture(string module, string[] args) + { + string num = args[3]; + string uuid = args[4]; + int x = (args.Length > 5 ? int.Parse(args[5]) : -1); + int y = (args.Length > 6 ? int.Parse(args[6]) : -1); + + if (x != -1 && m_scene.RegionInfo.RegionLocX != x) + { + if (y != -1 && m_scene.RegionInfo.RegionLocY != y) + { + setEstateTerrainBaseTexture(null, int.Parse(num), UUID.Parse(uuid)); + } + } + } + + public void consoleSetTerrainHeights(string module, string[] args) + { + string num = args[3]; + string min = args[4]; + string max = args[5]; + int x = (args.Length > 6 ? int.Parse(args[6]) : -1); + int y = (args.Length > 7 ? int.Parse(args[7]) : -1); + + if (x != -1 && m_scene.RegionInfo.RegionLocX != x) + { + if (y != -1 && m_scene.RegionInfo.RegionLocY != y) + { + setEstateTerrainTextureHeights(null, int.Parse(num), float.Parse(min), float.Parse(max)); + } + } + } + + #endregion public void PostInitialise() { -- cgit v1.1 From 57429423bbb080d5381dd91ffe4d927537fbf62f Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 24 Sep 2009 21:29:57 +1000 Subject: * Fixing typo. --- OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index f52a287..fa52334 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -840,7 +840,7 @@ namespace OpenSim.Region.CoreModules.World.Estate "Sets the terrain texture heights on corner # to /, if or are specified, it will only " + "set it on regions with a matching coordinate. Specify -1 in or to wildcard" + " that coordinate. Corner # SW = 0, NW = 1, SE = 2, NE = 3.", - consoleSetTerrainTexture); + consoleSetTerrainHeights); } #region Console Commands -- cgit v1.1 From 8605c5d2eb0d514c1475b94120fd6db9644874cf Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 24 Sep 2009 21:46:41 +1000 Subject: * Establishing why new console commands fail to work. >_> --- .../Region/CoreModules/World/Estate/EstateManagementModule.cs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index fa52334..bb77bd5 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -852,10 +852,11 @@ namespace OpenSim.Region.CoreModules.World.Estate int x = (args.Length > 5 ? int.Parse(args[5]) : -1); int y = (args.Length > 6 ? int.Parse(args[6]) : -1); - if (x != -1 && m_scene.RegionInfo.RegionLocX != x) + if (x == -1 || m_scene.RegionInfo.RegionLocX == x) { - if (y != -1 && m_scene.RegionInfo.RegionLocY != y) + if (y == -1 || m_scene.RegionInfo.RegionLocY == y) { + m_log.Debug("[ESTATEMODULE] Setting terrain textures for " + m_scene.RegionInfo.RegionName); setEstateTerrainBaseTexture(null, int.Parse(num), UUID.Parse(uuid)); } } @@ -869,10 +870,11 @@ namespace OpenSim.Region.CoreModules.World.Estate int x = (args.Length > 6 ? int.Parse(args[6]) : -1); int y = (args.Length > 7 ? int.Parse(args[7]) : -1); - if (x != -1 && m_scene.RegionInfo.RegionLocX != x) + if (x == -1 || m_scene.RegionInfo.RegionLocX == x) { - if (y != -1 && m_scene.RegionInfo.RegionLocY != y) + if (y == -1 || m_scene.RegionInfo.RegionLocY == y) { + m_log.Debug("[ESTATEMODULE] Setting terrain heights " + m_scene.RegionInfo.RegionName); setEstateTerrainTextureHeights(null, int.Parse(num), float.Parse(min), float.Parse(max)); } } -- cgit v1.1 From ca69fac13e2a0b648b02bf32a368f77d2fbec1fb Mon Sep 17 00:00:00 2001 From: Adam Frisby Date: Thu, 24 Sep 2009 22:02:29 +1000 Subject: * Send Updated Information Packet to Clients after updating estate settings. --- OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs | 2 ++ 1 file changed, 2 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs index bb77bd5..0d51cf4 100644 --- a/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs +++ b/OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs @@ -154,6 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Estate break; } m_scene.RegionInfo.RegionSettings.Save(); + sendRegionInfoPacketToAll(); } public void setEstateTerrainTextureHeights(IClientAPI client, int corner, float lowValue, float highValue) @@ -178,6 +179,7 @@ namespace OpenSim.Region.CoreModules.World.Estate break; } m_scene.RegionInfo.RegionSettings.Save(); + sendRegionInfoPacketToAll(); } private void handleCommitEstateTerrainTextureRequest(IClientAPI remoteClient) -- cgit v1.1 From 7870152d23db4cb6f5834d4921fac17feb717220 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 24 Sep 2009 14:54:12 +0100 Subject: Allow load/save iar password checks to be done in grid mode This should allow load/save iar to work for grid mode as long as the grid user service is later than this revision Grid services of earlier revisions will always erroneously report incorrect password. This will be addressed shortly. --- .../Communications/Local/LocalUserServices.cs | 19 +++++++++- .../Region/Communications/OGS1/OGS1UserServices.cs | 43 +++++++++++++++++++++- .../Inventory/Archiver/InventoryArchiverModule.cs | 21 +++-------- 3 files changed, 64 insertions(+), 19 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Communications/Local/LocalUserServices.cs b/OpenSim/Region/Communications/Local/LocalUserServices.cs index af4fb37..d18937e 100644 --- a/OpenSim/Region/Communications/Local/LocalUserServices.cs +++ b/OpenSim/Region/Communications/Local/LocalUserServices.cs @@ -80,6 +80,21 @@ namespace OpenSim.Region.Communications.Local throw new Exception("[LOCAL USER SERVICES]: Unknown master user UUID. Possible reason: UserServer is not running."); } return data; - } + } + + public override bool AuthenticateUserByPassword(UUID userID, string password) + { + UserProfileData userProfile = GetUserProfile(userID); + + if (null == userProfile) + return false; + + string md5PasswordHash = Util.Md5Hash(Util.Md5Hash(password) + ":" + userProfile.PasswordSalt); + + if (md5PasswordHash == userProfile.PasswordHash) + return true; + else + return false; + } } -} +} \ No newline at end of file diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index dff8305..89b3e42 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -140,6 +140,47 @@ namespace OpenSim.Region.Communications.OGS1 { m_log.DebugFormat("[OGS1 USER SERVICES]: Verifying user session for " + userID); return AuthClient.VerifySession(GetUserServerURL(userID), userID, sessionID); - } + } + + public override bool AuthenticateUserByPassword(UUID userID, string password) + { + try + { + Hashtable param = new Hashtable(); + param["user_uuid"] = userID.ToString(); + param["password"] = password; + IList parameters = new ArrayList(); + parameters.Add(param); + XmlRpcRequest req = new XmlRpcRequest("authenticate_user_by_password", parameters); + XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000); + Hashtable respData = (Hashtable)resp.Value; + +// foreach (object key in respData.Keys) +// { +// Console.WriteLine("respData {0}, {1}", key, respData[key]); +// } + +// m_log.DebugFormat( +// "[OGS1 USER SERVICES]: AuthenticatedUserByPassword response for {0} is [{1}]", +// userID, respData["auth_user"]); + + if ((string)respData["auth_user"] == "TRUE") + { + return true; + } + else + { + return false; + } + } + catch (Exception e) + { + m_log.ErrorFormat( + "[OGS1 USER SERVICES]: Error when trying to authenticate user by password from remote user server: {0}", + e); + + return false; + } + } } } \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index 196205c..b82b940 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -322,7 +322,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver /// User password /// protected CachedUserInfo GetUserInfo(string firstName, string lastName, string pass) - { + { CachedUserInfo userInfo = m_aScene.CommsManager.UserProfileCacheService.GetUserDetails(firstName, lastName); //m_aScene.CommsManager.UserService.GetUserProfile(firstName, lastName); if (null == userInfo) @@ -333,29 +333,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return null; } - string md5PasswdHash = Util.Md5Hash(Util.Md5Hash(pass) + ":" + userInfo.UserProfile.PasswordSalt); - - if (userInfo.UserProfile.PasswordHash == null || userInfo.UserProfile.PasswordHash == String.Empty) + if (m_aScene.CommsManager.UserService.AuthenticateUserByPassword(userInfo.UserProfile.ID, pass)) { - m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: Sorry, the grid mode service is not providing password hash details for the check. This will be fixed in an OpenSim git revision soon"); - - return null; + return userInfo; } - -// m_log.DebugFormat( -// "[INVENTORY ARCHIVER]: received salt {0}, hash {1}, supplied hash {2}", -// userInfo.UserProfile.PasswordSalt, userInfo.UserProfile.PasswordHash, md5PasswdHash); - - if (userInfo.UserProfile.PasswordHash != md5PasswdHash) + else { m_log.ErrorFormat( "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.", firstName, lastName); + return null; } - - return userInfo; } /// -- cgit v1.1 From f62b5e6cec31fe496ec4b9f7dcd6ae1f4063bead Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 24 Sep 2009 15:19:47 +0100 Subject: Produce a different error message if the user service does not have the authenticate method available --- .../Region/Communications/OGS1/OGS1UserServices.cs | 46 +++++++++++----------- .../Inventory/Archiver/InventoryArchiverModule.cs | 29 ++++++++------ 2 files changed, 41 insertions(+), 34 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index 89b3e42..a55b62e 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -144,16 +144,25 @@ namespace OpenSim.Region.Communications.OGS1 public override bool AuthenticateUserByPassword(UUID userID, string password) { - try + Hashtable param = new Hashtable(); + param["user_uuid"] = userID.ToString(); + param["password"] = password; + IList parameters = new ArrayList(); + parameters.Add(param); + XmlRpcRequest req = new XmlRpcRequest("authenticate_user_by_password", parameters); + XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000); + + // Temporary measure to deal with older services + if (resp.IsFault && resp.FaultCode == XmlRpcErrorCodes.SERVER_ERROR_METHOD) + //if ((string)respData["fault_code"] != null && (string)respData["fault_code"] == { - Hashtable param = new Hashtable(); - param["user_uuid"] = userID.ToString(); - param["password"] = password; - IList parameters = new ArrayList(); - parameters.Add(param); - XmlRpcRequest req = new XmlRpcRequest("authenticate_user_by_password", parameters); - XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000); - Hashtable respData = (Hashtable)resp.Value; + throw new Exception( + String.Format( + "XMLRPC method 'authenticate_user_by_password' not yet implemented by user service at {0}", + m_commsManager.NetworkServersInfo.UserURL)); + } + + Hashtable respData = (Hashtable)resp.Value; // foreach (object key in respData.Keys) // { @@ -164,23 +173,14 @@ namespace OpenSim.Region.Communications.OGS1 // "[OGS1 USER SERVICES]: AuthenticatedUserByPassword response for {0} is [{1}]", // userID, respData["auth_user"]); - if ((string)respData["auth_user"] == "TRUE") - { - return true; - } - else - { - return false; - } + if ((string)respData["auth_user"] == "TRUE") + { + return true; } - catch (Exception e) + else { - m_log.ErrorFormat( - "[OGS1 USER SERVICES]: Error when trying to authenticate user by password from remote user server: {0}", - e); - return false; - } + } } } } \ No newline at end of file diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs index b82b940..55dce05 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiverModule.cs @@ -333,16 +333,23 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver return null; } - if (m_aScene.CommsManager.UserService.AuthenticateUserByPassword(userInfo.UserProfile.ID, pass)) - { - return userInfo; + try + { + if (m_aScene.CommsManager.UserService.AuthenticateUserByPassword(userInfo.UserProfile.ID, pass)) + { + return userInfo; + } + else + { + m_log.ErrorFormat( + "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.", + firstName, lastName); + return null; + } } - else + catch (Exception e) { - m_log.ErrorFormat( - "[INVENTORY ARCHIVER]: Password for user {0} {1} incorrect. Please try again.", - firstName, lastName); - + m_log.ErrorFormat("[INVENTORY ARCHIVER]: Could not authenticate password, {0}", e.Message); return null; } } @@ -364,9 +371,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver { foreach (InventoryNodeBase node in loadedNodes) { - m_log.DebugFormat( - "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}", - user.Name, node.Name); +// m_log.DebugFormat( +// "[INVENTORY ARCHIVER]: Notifying {0} of loaded inventory node {1}", +// user.Name, node.Name); user.ControllingClient.SendBulkUpdateInventory(node); } -- cgit v1.1 From e1abc3d4c49ae4068faf7b8d1dcb220829429757 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Thu, 24 Sep 2009 15:22:47 +0100 Subject: re-enable registration of user service authentication method I accidentally disabled a few commits ago load/save iar on a grid should now work, provided that the user service is this revision or newer --- OpenSim/Region/Communications/OGS1/OGS1UserServices.cs | 12 +----------- 1 file changed, 1 insertion(+), 11 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs index a55b62e..51ba2e9 100644 --- a/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs +++ b/OpenSim/Region/Communications/OGS1/OGS1UserServices.cs @@ -153,8 +153,7 @@ namespace OpenSim.Region.Communications.OGS1 XmlRpcResponse resp = req.Send(m_commsManager.NetworkServersInfo.UserURL, 30000); // Temporary measure to deal with older services - if (resp.IsFault && resp.FaultCode == XmlRpcErrorCodes.SERVER_ERROR_METHOD) - //if ((string)respData["fault_code"] != null && (string)respData["fault_code"] == + if (resp.IsFault && resp.FaultCode == XmlRpcErrorCodes.SERVER_ERROR_METHOD) { throw new Exception( String.Format( @@ -164,15 +163,6 @@ namespace OpenSim.Region.Communications.OGS1 Hashtable respData = (Hashtable)resp.Value; -// foreach (object key in respData.Keys) -// { -// Console.WriteLine("respData {0}, {1}", key, respData[key]); -// } - -// m_log.DebugFormat( -// "[OGS1 USER SERVICES]: AuthenticatedUserByPassword response for {0} is [{1}]", -// userID, respData["auth_user"]); - if ((string)respData["auth_user"] == "TRUE") { return true; -- cgit v1.1 From daffb691741250dae9e3f767580f0349bd2c5c4f Mon Sep 17 00:00:00 2001 From: dahlia Date: Thu, 24 Sep 2009 18:16:29 -0700 Subject: modify BulletDotNETPrim.cs in preparation for Mantis #4181 --- .../Physics/BulletDotNETPlugin/BulletDotNETPrim.cs | 234 +++++++++++---------- 1 file changed, 122 insertions(+), 112 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs index 7ab8b98..f22ea71 100644 --- a/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs +++ b/OpenSim/Region/Physics/BulletDotNETPlugin/BulletDotNETPrim.cs @@ -204,7 +204,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin tempAngularVelocity2 = new btVector3(0, 0, 0); tempInertia1 = new btVector3(0, 0, 0); tempInertia2 = new btVector3(0, 0, 0); - tempOrientation1 = new btQuaternion(0,0,0,1); + tempOrientation1 = new btQuaternion(0, 0, 0, 1); tempOrientation2 = new btQuaternion(0, 0, 0, 1); _parent_scene = parent_scene; tempTransform1 = new btTransform(_parent_scene.QuatIdentity, _parent_scene.VectorZero); @@ -216,10 +216,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin tempMotionState2 = new btDefaultMotionState(_parent_scene.TransZero); tempMotionState3 = new btDefaultMotionState(_parent_scene.TransZero); - + AxisLockLinearLow = new btVector3(-1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize, -1 * (int)Constants.RegionSize); - int regionsize = (int) Constants.RegionSize; - + int regionsize = (int)Constants.RegionSize; + if (regionsize == 256) regionsize = 512; @@ -611,7 +611,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin DisableAxisMotor(); DisposeOfBody(); SetCollisionShape(null); - + if (tempMotionState3 != null && tempMotionState3.Handle != IntPtr.Zero) { tempMotionState3.Dispose(); @@ -677,8 +677,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin tempInertia2.Dispose(); tempInertia1 = null; } - - + + if (tempAngularVelocity2 != null && tempAngularVelocity2.Handle != IntPtr.Zero) { tempAngularVelocity2.Dispose(); @@ -802,7 +802,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin changesize(timestep); } - // + // if (m_taintshape) { @@ -1001,7 +1001,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin else SetBody(0); changeSelectedStatus(timestep); - + resetCollisionAccounting(); m_taintPhysics = m_isphysical; } @@ -1012,7 +1012,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { if (_parent_scene.needsMeshing(_pbs)) { - ProcessGeomCreationAsTriMesh(PhysicsVector.Zero,Quaternion.Identity); + ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); // createmesh returns null when it doesn't mesh. CreateGeom(IntPtr.Zero, _mesh); } @@ -1038,32 +1038,32 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin meshlod = _parent_scene.MeshSculptphysicalLOD; IMesh mesh = _parent_scene.mesher.CreateMesh(SOPName, _pbs, _size, meshlod, IsPhysical); - if (!positionOffset.IsIdentical(PhysicsVector.Zero,0.001f) || orientation != Quaternion.Identity) + if (!positionOffset.IsIdentical(PhysicsVector.Zero, 0.001f) || orientation != Quaternion.Identity) { - - float[] xyz = new float[3]; - xyz[0] = positionOffset.X; - xyz[1] = positionOffset.Y; - xyz[2] = positionOffset.Z; - - Matrix4 m4 = Matrix4.CreateFromQuaternion(orientation); - - float[,] matrix = new float[3,3]; - - matrix[0, 0] = m4.M11; - matrix[0, 1] = m4.M12; - matrix[0, 2] = m4.M13; - matrix[1, 0] = m4.M21; - matrix[1, 1] = m4.M22; - matrix[1, 2] = m4.M23; - matrix[2, 0] = m4.M31; - matrix[2, 1] = m4.M32; - matrix[2, 2] = m4.M33; - - - mesh.TransformLinear(matrix, xyz); - - + + float[] xyz = new float[3]; + xyz[0] = positionOffset.X; + xyz[1] = positionOffset.Y; + xyz[2] = positionOffset.Z; + + Matrix4 m4 = Matrix4.CreateFromQuaternion(orientation); + + float[,] matrix = new float[3, 3]; + + matrix[0, 0] = m4.M11; + matrix[0, 1] = m4.M12; + matrix[0, 2] = m4.M13; + matrix[1, 0] = m4.M21; + matrix[1, 1] = m4.M22; + matrix[1, 2] = m4.M23; + matrix[2, 0] = m4.M31; + matrix[2, 1] = m4.M32; + matrix[2, 2] = m4.M33; + + + mesh.TransformLinear(matrix, xyz); + + } @@ -1088,12 +1088,12 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin SetCollisionShape(null); // Construction of new prim ProcessGeomCreation(); - + if (IsPhysical) SetBody(Mass); else SetBody(0); - + m_taintsize = _size; } @@ -1136,7 +1136,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin //prim_geom = IntPtr.Zero; m_log.Error("[PHYSICS]: PrimGeom dead"); } - + // we don't need to do space calculation because the client sends a position update also. if (_size.X <= 0) _size.X = 0.01f; if (_size.Y <= 0) _size.Y = 0.01f; @@ -1153,8 +1153,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin tempTransform1.Dispose(); tempTransform1 = new btTransform(tempOrientation1, tempPosition1); - - + + //d.GeomBoxSetLengths(prim_geom, _size.X, _size.Y, _size.Z); if (IsPhysical) @@ -1162,7 +1162,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin SetBody(Mass); // Re creates body on size. // EnableBody also does setMass() - + } else { @@ -1179,7 +1179,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } } resetCollisionAccounting(); - + m_taintshape = false; } @@ -1291,7 +1291,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { Body.setCollisionFlags((int)ContactFlags.CF_NO_CONTACT_RESPONSE); disableBodySoft(); - + } else { @@ -1299,7 +1299,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin enableBodySoft(); } m_isSelected = m_taintselected; - + } private void changevelocity(float timestep) @@ -1368,7 +1368,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin _parent = m_taintparent; m_taintPhysics = m_isphysical; - + } private void changefloatonwater(float timestep) @@ -1627,7 +1627,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { if (m_zeroPosition == null) m_zeroPosition = new PhysicsVector(0, 0, 0); - m_zeroPosition.setValues(_position.X,_position.Y,_position.Z); + m_zeroPosition.setValues(_position.X, _position.Y, _position.Z); return; } } @@ -1981,7 +1981,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin //_mesh = _parent_scene.mesher.CreateMesh(m_primName, _pbs, _size, _parent_scene.meshSculptLOD, IsPhysical); _mesh = p_mesh; setMesh(_parent_scene, _mesh); - + } else { @@ -1994,15 +1994,15 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin //SetGeom to a Regular Sphere if (tempSize1 == null) tempSize1 = new btVector3(0, 0, 0); - tempSize1.setValue(_size.X * 0.5f,_size.Y * 0.5f, _size.Z * 0.5f); - SetCollisionShape(new btSphereShape(_size.X*0.5f)); + tempSize1.setValue(_size.X * 0.5f, _size.Y * 0.5f, _size.Z * 0.5f); + SetCollisionShape(new btSphereShape(_size.X * 0.5f)); } else { // uses halfextents if (tempSize1 == null) tempSize1 = new btVector3(0, 0, 0); - tempSize1.setValue(_size.X*0.5f, _size.Y*0.5f, _size.Z*0.5f); + tempSize1.setValue(_size.X * 0.5f, _size.Y * 0.5f, _size.Z * 0.5f); SetCollisionShape(new btBoxShape(tempSize1)); } } @@ -2052,14 +2052,24 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } } + //IMesh oldMesh = primMesh; + + //primMesh = mesh; + + //float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory + //int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage + ////Array.Reverse(indexList); + //primMesh.releaseSourceMeshData(); // free up the original mesh data to save memory + IMesh oldMesh = primMesh; primMesh = mesh; - - float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory - int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage + + float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory + int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage //Array.Reverse(indexList); - primMesh.releaseSourceMeshData(); // free up the original mesh data to save memory + mesh.releaseSourceMeshData(); // free up the original mesh data to save memory + int VertexCount = vertexList.GetLength(0) / 3; int IndexCount = indexList.GetLength(0); @@ -2068,17 +2078,17 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin btshapeArray.Dispose(); //Array.Reverse(indexList); btshapeArray = new btTriangleIndexVertexArray(IndexCount / 3, indexList, (3 * sizeof(int)), - VertexCount, vertexList, 3*sizeof (float)); + VertexCount, vertexList, 3 * sizeof(float)); SetCollisionShape(new btGImpactMeshShape(btshapeArray)); //((btGImpactMeshShape) prim_geom).updateBound(); - ((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1,1, 1)); + ((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1, 1, 1)); ((btGImpactMeshShape)prim_geom).updateBound(); _parent_scene.SetUsingGImpact(); - if (oldMesh != null) - { - oldMesh.releasePinned(); - oldMesh = null; - } + //if (oldMesh != null) + //{ + // oldMesh.releasePinned(); + // oldMesh = null; + //} } @@ -2102,7 +2112,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } */ prim_geom = shape; - + //Body.set } @@ -2143,8 +2153,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin if (prim_geom is btGImpactMeshShape) { - ((btGImpactMeshShape) prim_geom).setLocalScaling(new btVector3(1, 1, 1)); - ((btGImpactMeshShape) prim_geom).updateBound(); + ((btGImpactMeshShape)prim_geom).setLocalScaling(new btVector3(1, 1, 1)); + ((btGImpactMeshShape)prim_geom).updateBound(); } //Body.setCollisionFlags(Body.getCollisionFlags() | (int)ContactFlags.CF_CUSTOM_MATERIAL_CALLBACK); //Body.setUserPointer((IntPtr) (int)m_localID); @@ -2159,7 +2169,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { if (chld == null) continue; - + // if (chld.NeedsMeshing()) // hasTrimesh = true; } @@ -2167,40 +2177,40 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin //if (hasTrimesh) //{ - ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); - // createmesh returns null when it doesn't mesh. - - /* - if (_mesh is Mesh) - { - } - else - { - m_log.Warn("[PHYSICS]: Can't link a OpenSim.Region.Physics.Meshing.Mesh object"); - return; - } - */ + ProcessGeomCreationAsTriMesh(PhysicsVector.Zero, Quaternion.Identity); + // createmesh returns null when it doesn't mesh. - - - foreach (BulletDotNETPrim chld in childrenPrim) - { - if (chld == null) - continue; - PhysicsVector offset = chld.Position - Position; - Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z); - pos *= Quaternion.Inverse(Orientation); - //pos *= Orientation; - offset.setValues(pos.X, pos.Y, pos.Z); - chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation); - - _mesh.Append(chld._mesh); - + /* + if (_mesh is Mesh) + { + } + else + { + m_log.Warn("[PHYSICS]: Can't link a OpenSim.Region.Physics.Meshing.Mesh object"); + return; + } + */ - } - setMesh(_parent_scene, _mesh); - - //} + + + foreach (BulletDotNETPrim chld in childrenPrim) + { + if (chld == null) + continue; + PhysicsVector offset = chld.Position - Position; + Vector3 pos = new Vector3(offset.X, offset.Y, offset.Z); + pos *= Quaternion.Inverse(Orientation); + //pos *= Orientation; + offset.setValues(pos.X, pos.Y, pos.Z); + chld.ProcessGeomCreationAsTriMesh(offset, chld.Orientation); + + _mesh.Append(chld._mesh); + + + } + setMesh(_parent_scene, _mesh); + + //} if (tempMotionState1 != null && tempMotionState1.Handle != IntPtr.Zero) tempMotionState1.Dispose(); @@ -2238,7 +2248,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin ((btGImpactMeshShape)prim_geom).updateBound(); } _parent_scene.AddPrimToScene(this); - + } if (IsPhysical) @@ -2252,7 +2262,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin if (Body.Handle != IntPtr.Zero) { DisableAxisMotor(); - _parent_scene.removeFromWorld(this,Body); + _parent_scene.removeFromWorld(this, Body); Body.Dispose(); } Body = null; @@ -2305,7 +2315,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin return; - + lock (childrenPrim) { if (!childrenPrim.Contains(prm)) @@ -2313,8 +2323,8 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin childrenPrim.Add(prm); } } - - + + } public void disableBody() @@ -2386,7 +2396,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin { Body.clearForces(); Body.forceActivationState(0); - + } } @@ -2400,7 +2410,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin Body.clearForces(); Body.forceActivationState(4); forceenable = true; - + } m_disabled = false; } @@ -2415,7 +2425,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin SetBody(Mass); else SetBody(0); - + // TODO: Set Collision Category Bits and Flags // TODO: Set Auto Disable data @@ -2587,10 +2597,10 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin _velocity.Y = tempLinearVelocity1.getY(); _velocity.Z = tempLinearVelocity1.getZ(); - _acceleration = ((_velocity - m_lastVelocity)/0.1f); - _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X/0.1f, - _velocity.Y - m_lastVelocity.Y/0.1f, - _velocity.Z - m_lastVelocity.Z/0.1f); + _acceleration = ((_velocity - m_lastVelocity) / 0.1f); + _acceleration = new PhysicsVector(_velocity.X - m_lastVelocity.X / 0.1f, + _velocity.Y - m_lastVelocity.Y / 0.1f, + _velocity.Z - m_lastVelocity.Z / 0.1f); //m_log.Info("[PHYSICS]: V1: " + _velocity + " V2: " + m_lastVelocity + " Acceleration: " + _acceleration.ToString()); if (_velocity.IsIdentical(pv, 0.5f)) @@ -2669,7 +2679,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin if (AxisLockAngleHigh != null && AxisLockAngleHigh.Handle != IntPtr.Zero) AxisLockAngleHigh.Dispose(); - + m_aMotor = new btGeneric6DofConstraint(Body, _parent_scene.TerrainBody, _parent_scene.TransZero, _parent_scene.TransZero, false); @@ -2683,7 +2693,7 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin m_aMotor.setLinearUpperLimit(AxisLockLinearHigh); _parent_scene.getBulletWorld().addConstraint((btTypedConstraint)m_aMotor); //m_aMotor. - + } internal void DisableAxisMotor() @@ -2698,4 +2708,4 @@ namespace OpenSim.Region.Physics.BulletDotNETPlugin } } - + -- cgit v1.1 From 1b2828f5d859d2941167b0457158142e683efe39 Mon Sep 17 00:00:00 2001 From: Dan Lake Date: Thu, 24 Sep 2009 10:00:31 -0700 Subject: Meshmerizer stores dictionary of unique Meshes keyed on construction parameters. CreateMesh() returns a Mesh from the dictionary or creates a new Mesh if it has not been created before. Meshes are never purged from the dictionary. The raw Mesh data is discarded once the memory is pinned for ODE use. All copies of the same prim/mesh use the same pinned memory. ONLY IMPLEMENTED AND TESTED WITH MESHMERIZER AND ODE Signed-off-by: dahlia --- OpenSim/Region/Physics/Meshing/Mesh.cs | 87 +++++++++------------------ OpenSim/Region/Physics/Meshing/Meshmerizer.cs | 69 +++++++++++++++++++-- OpenSim/Region/Physics/OdePlugin/ODEPrim.cs | 17 +----- 3 files changed, 95 insertions(+), 78 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/Meshing/Mesh.cs b/OpenSim/Region/Physics/Meshing/Mesh.cs index ceafaad..7567556 100644 --- a/OpenSim/Region/Physics/Meshing/Mesh.cs +++ b/OpenSim/Region/Physics/Meshing/Mesh.cs @@ -40,7 +40,6 @@ namespace OpenSim.Region.Physics.Meshing private List triangles; GCHandle pinnedVirtexes; GCHandle pinnedIndex; - public PrimMesh primMesh = null; public float[] normals; public Mesh() @@ -63,6 +62,8 @@ namespace OpenSim.Region.Physics.Meshing public void Add(Triangle triangle) { + if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated) + throw new NotSupportedException("Attempt to Add to a pinned Mesh"); // If a vertex of the triangle is not yet in the vertices list, // add it and set its index to the current index count if (!vertices.ContainsKey(triangle.v1)) @@ -148,40 +149,22 @@ namespace OpenSim.Region.Physics.Meshing public float[] getVertexListAsFloatLocked() { + if( pinnedVirtexes.IsAllocated ) + return (float[])(pinnedVirtexes.Target); float[] result; - if (primMesh == null) + //m_log.WarnFormat("vertices.Count = {0}", vertices.Count); + result = new float[vertices.Count * 3]; + foreach (KeyValuePair kvp in vertices) { - //m_log.WarnFormat("vertices.Count = {0}", vertices.Count); - result = new float[vertices.Count * 3]; - foreach (KeyValuePair kvp in vertices) - { - Vertex v = kvp.Key; - int i = kvp.Value; - //m_log.WarnFormat("kvp.Value = {0}", i); - result[3 * i + 0] = v.X; - result[3 * i + 1] = v.Y; - result[3 * i + 2] = v.Z; - } - pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned); - } - else - { - int count = primMesh.coords.Count; - result = new float[count * 3]; - for (int i = 0; i < count; i++) - { - Coord c = primMesh.coords[i]; - { - int resultIndex = 3 * i; - result[resultIndex] = c.X; - result[resultIndex + 1] = c.Y; - result[resultIndex + 2] = c.Z; - } - - } - pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned); + Vertex v = kvp.Key; + int i = kvp.Value; + //m_log.WarnFormat("kvp.Value = {0}", i); + result[3 * i + 0] = v.X; + result[3 * i + 1] = v.Y; + result[3 * i + 2] = v.Z; } + pinnedVirtexes = GCHandle.Alloc(result, GCHandleType.Pinned); return result; } @@ -189,33 +172,13 @@ namespace OpenSim.Region.Physics.Meshing { int[] result; - if (primMesh == null) - { - result = new int[triangles.Count * 3]; - for (int i = 0; i < triangles.Count; i++) - { - Triangle t = triangles[i]; - result[3 * i + 0] = vertices[t.v1]; - result[3 * i + 1] = vertices[t.v2]; - result[3 * i + 2] = vertices[t.v3]; - } - } - else + result = new int[triangles.Count * 3]; + for (int i = 0; i < triangles.Count; i++) { - int numFaces = primMesh.faces.Count; - result = new int[numFaces * 3]; - for (int i = 0; i < numFaces; i++) - { - Face f = primMesh.faces[i]; -// Coord c1 = primMesh.coords[f.v1]; -// Coord c2 = primMesh.coords[f.v2]; -// Coord c3 = primMesh.coords[f.v3]; - - int resultIndex = i * 3; - result[resultIndex] = f.v1; - result[resultIndex + 1] = f.v2; - result[resultIndex + 2] = f.v3; - } + Triangle t = triangles[i]; + result[3 * i + 0] = vertices[t.v1]; + result[3 * i + 1] = vertices[t.v2]; + result[3 * i + 2] = vertices[t.v3]; } return result; } @@ -226,6 +189,9 @@ namespace OpenSim.Region.Physics.Meshing /// public int[] getIndexListAsIntLocked() { + if (pinnedIndex.IsAllocated) + return (int[])(pinnedIndex.Target); + int[] result = getIndexListAsInt(); pinnedIndex = GCHandle.Alloc(result, GCHandleType.Pinned); @@ -245,11 +211,13 @@ namespace OpenSim.Region.Physics.Meshing { triangles = null; vertices = null; - primMesh = null; } public void Append(IMesh newMesh) { + if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated) + throw new NotSupportedException("Attempt to Append to a pinned Mesh"); + if (!(newMesh is Mesh)) return; @@ -260,6 +228,9 @@ namespace OpenSim.Region.Physics.Meshing // Do a linear transformation of mesh. public void TransformLinear(float[,] matrix, float[] offset) { + if (pinnedIndex.IsAllocated || pinnedVirtexes.IsAllocated) + throw new NotSupportedException("Attempt to TransformLinear a pinned Mesh"); + foreach (Vertex v in vertices.Keys) { if (v == null) diff --git a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs index f469ad6..0873035 100644 --- a/OpenSim/Region/Physics/Meshing/Meshmerizer.cs +++ b/OpenSim/Region/Physics/Meshing/Meshmerizer.cs @@ -76,6 +76,7 @@ namespace OpenSim.Region.Physics.Meshing private float minSizeForComplexMesh = 0.2f; // prims with all dimensions smaller than this will have a bounding box mesh + private Dictionary m_uniqueMeshes = new Dictionary(); /// /// creates a simple box mesh of the specified size. This mesh is of very low vertex count and may @@ -170,9 +171,62 @@ namespace OpenSim.Region.Physics.Meshing } - public Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) + private ulong GetMeshKey( PrimitiveBaseShape pbs, PhysicsVector size, float lod ) + { + ulong hash = 5381; + + hash = djb2(hash, pbs.PathCurve); + hash = djb2(hash, (byte)((byte)pbs.HollowShape | (byte)pbs.ProfileShape)); + hash = djb2(hash, pbs.PathBegin); + hash = djb2(hash, pbs.PathEnd); + hash = djb2(hash, pbs.PathScaleX); + hash = djb2(hash, pbs.PathScaleY); + hash = djb2(hash, pbs.PathShearX); + hash = djb2(hash, pbs.PathShearY); + hash = djb2(hash, (byte)pbs.PathTwist); + hash = djb2(hash, (byte)pbs.PathTwistBegin); + hash = djb2(hash, (byte)pbs.PathRadiusOffset); + hash = djb2(hash, (byte)pbs.PathTaperX); + hash = djb2(hash, (byte)pbs.PathTaperY); + hash = djb2(hash, pbs.PathRevolutions); + hash = djb2(hash, (byte)pbs.PathSkew); + hash = djb2(hash, pbs.ProfileBegin); + hash = djb2(hash, pbs.ProfileEnd); + hash = djb2(hash, pbs.ProfileHollow); + + // TODO: Separate scale out from the primitive shape data (after + // scaling is supported at the physics engine level) + byte[] scaleBytes = size.GetBytes(); + for (int i = 0; i < scaleBytes.Length; i++) + hash = djb2(hash, scaleBytes[i]); + + // Include LOD in hash, accounting for endianness + byte[] lodBytes = new byte[4]; + Buffer.BlockCopy(BitConverter.GetBytes(lod), 0, lodBytes, 0, 4); + if (!BitConverter.IsLittleEndian) + { + Array.Reverse(lodBytes, 0, 4); + } + for (int i = 0; i < lodBytes.Length; i++) + hash = djb2(hash, lodBytes[i]); + + return hash; + } + + private ulong djb2(ulong hash, byte c) + { + return ((hash << 5) + hash) + (ulong)c; + } + + private ulong djb2(ulong hash, ushort c) + { + hash = ((hash << 5) + hash) + (ulong)((byte)c); + return ((hash << 5) + hash) + (ulong)(c >> 8); + } + + + private Mesh CreateMeshFromPrimMesher(string primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod) { - Mesh mesh = new Mesh(); PrimMesh primMesh; PrimMesher.SculptMesh sculptMesh; @@ -385,8 +439,6 @@ namespace OpenSim.Region.Physics.Meshing coords = primMesh.coords; faces = primMesh.faces; - - } @@ -401,13 +453,13 @@ namespace OpenSim.Region.Physics.Meshing vertices.Add(new Vertex(c.X, c.Y, c.Z)); } + Mesh mesh = new Mesh(); // Add the corresponding triangles to the mesh for (int i = 0; i < numFaces; i++) { Face f = faces[i]; mesh.Add(new Triangle(vertices[f.v1], vertices[f.v2], vertices[f.v3])); } - return mesh; } @@ -418,7 +470,12 @@ namespace OpenSim.Region.Physics.Meshing public IMesh CreateMesh(String primName, PrimitiveBaseShape primShape, PhysicsVector size, float lod, bool isPhysical) { + // If this mesh has been created already, return it instead of creating another copy + // For large regions with 100k+ prims and hundreds of copies of each, this can save a GB or more of memory + ulong key = GetMeshKey(primShape, size, lod); Mesh mesh = null; + if (m_uniqueMeshes.TryGetValue(key, out mesh)) + return mesh; if (size.X < 0.01f) size.X = 0.01f; if (size.Y < 0.01f) size.Y = 0.01f; @@ -441,7 +498,7 @@ namespace OpenSim.Region.Physics.Meshing // trim the vertex and triangle lists to free up memory mesh.TrimExcess(); } - + m_uniqueMeshes.Add(key, mesh); return mesh; } } diff --git a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs index 673ae39..032b5df 100644 --- a/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs +++ b/OpenSim/Region/Physics/OdePlugin/ODEPrim.cs @@ -82,7 +82,6 @@ namespace OpenSim.Region.Physics.OdePlugin // private float m_tensor = 5f; private int body_autodisable_frames = 20; - private IMesh primMesh = null; private const CollisionCategories m_default_collisionFlags = (CollisionCategories.Geom @@ -814,14 +813,10 @@ namespace OpenSim.Region.Physics.OdePlugin } } - IMesh oldMesh = primMesh; + float[] vertexList = mesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory + int[] indexList = mesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage - primMesh = mesh; - - float[] vertexList = primMesh.getVertexListAsFloatLocked(); // Note, that vertextList is pinned in memory - int[] indexList = primMesh.getIndexListAsIntLocked(); // Also pinned, needs release after usage - - primMesh.releaseSourceMeshData(); // free up the original mesh data to save memory + mesh.releaseSourceMeshData(); // free up the original mesh data to save memory int VertexCount = vertexList.GetLength(0)/3; int IndexCount = indexList.GetLength(0); @@ -847,12 +842,6 @@ namespace OpenSim.Region.Physics.OdePlugin return; } - if (oldMesh != null) - { - oldMesh.releasePinned(); - oldMesh = null; - } - // if (IsPhysical && Body == (IntPtr) 0) // { // Recreate the body -- cgit v1.1 From 730458be1f8c74da1c112df36ec54233b30caed0 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Sep 2009 14:31:29 +0100 Subject: minor: remove some mono compiler warnings --- .../Region/CoreModules/Scripting/LSLHttp/UrlModule.cs | 7 +++---- .../Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs | 17 ++++++++--------- 2 files changed, 11 insertions(+), 13 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs index 8b7a878..b885420 100644 --- a/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs +++ b/OpenSim/Region/CoreModules/Scripting/LSLHttp/UrlModule.cs @@ -200,11 +200,10 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp if (m_RequestMap.ContainsKey(request)) { UrlData urlData = m_RequestMap[request]; - RequestData requestData=urlData.requests[request]; urlData.requests[request].responseCode = status; urlData.requests[request].responseBody = body; //urlData.requests[request].ev.Set(); - urlData.requests[request].requestDone=true; + urlData.requests[request].requestDone =true; } else { @@ -397,7 +396,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp { Hashtable headers = (Hashtable)request["headers"]; - string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; +// string uri_full = "http://" + m_ExternalHostNameForLSL + ":" + m_HttpServer.Port.ToString() + uri;// "/lslhttp/" + urlcode.ToString() + "/"; int pos1 = uri.IndexOf("/");// /lslhttp int pos2 = uri.IndexOf("/", pos1 + 1);// /lslhttp/ @@ -471,7 +470,7 @@ namespace OpenSim.Region.CoreModules.Scripting.LSLHttp url.engine.PostScriptEvent(url.itemID, "http_request", new Object[] { requestID.ToString(), request["http-method"].ToString(), request["body"].ToString() }); //send initial response? - Hashtable response = new Hashtable(); +// Hashtable response = new Hashtable(); return; diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs index 5d65f98..62efd60 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs @@ -47,8 +47,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); // This maps between inventory server urls and inventory server clients - private Dictionary m_inventoryServers = new Dictionary(); - +// private Dictionary m_inventoryServers = new Dictionary(); private Scene m_scene; #endregion @@ -72,13 +71,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid return null; } - private string UserInventoryURL(UUID userID) - { - CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); - if (uinfo != null) - return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI; - return null; - } +// private string UserInventoryURL(UUID userID) +// { +// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID); +// if (uinfo != null) +// return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI; +// return null; +// } private bool IsLocalUser(UUID userID) { -- cgit v1.1 From 613cb417c01fbca0cc28c3ef0313bf46e8d7c586 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Sep 2009 14:52:53 +0100 Subject: add control files containing version info to iars --- .../Archiver/InventoryArchiveWriteRequest.cs | 28 ++++++++++++++++++++++ 1 file changed, 28 insertions(+) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index 7b4a9eb..fd42586 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -118,6 +118,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver protected void ReceivedAllAssets(ICollection assetsFoundUuids, ICollection assetsNotFoundUuids) { + // We're almost done. Just need to write out the control file now + m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile()); + m_log.InfoFormat("[ARCHIVER]: Added control file to archive."); + Exception reportedException = null; bool succeeded = true; @@ -409,5 +413,29 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver ArchiveConstants.INVENTORY_NODE_NAME_COMPONENT_SEPARATOR, id); } + + /// + /// Create the control file for a 0.1 version archive + /// + /// + public static string Create0p1ControlFile() + { + StringWriter sw = new StringWriter(); + XmlTextWriter xtw = new XmlTextWriter(sw); + xtw.Formatting = Formatting.Indented; + xtw.WriteStartDocument(); + xtw.WriteStartElement("archive"); + xtw.WriteAttributeString("major_version", "0"); + xtw.WriteAttributeString("minor_version", "1"); + xtw.WriteEndElement(); + + xtw.Flush(); + xtw.Close(); + + String s = sw.ToString(); + sw.Close(); + + return s; + } } } \ No newline at end of file -- cgit v1.1 From 9249c026f25a0a24c62ca76fca37b1d23bcc3494 Mon Sep 17 00:00:00 2001 From: Justin Clark-Casey (justincc) Date: Fri, 25 Sep 2009 16:22:43 +0100 Subject: Don't preserve full user profile details within iars for now This information was not being used in the load process --- .../Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs index fd42586..c6ebb24 100644 --- a/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs +++ b/OpenSim/Region/CoreModules/Avatar/Inventory/Archiver/InventoryArchiveWriteRequest.cs @@ -324,7 +324,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver SaveInvFolder(inventoryFolder, ArchiveConstants.INVENTORY_PATH, !foundStar); } - SaveUsers(); + // Don't put all this profile information into the archive right now. + //SaveUsers(); + new AssetsRequest( new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys, m_scene.AssetService, ReceivedAllAssets).Execute(); -- cgit v1.1 From 902279f0fda655c8542b3e7ff7a8769bb3aff1a2 Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 25 Sep 2009 08:39:09 -0700 Subject: Moved the property RegionLoginsEnabled from GridComms to the Scene -- not the scene itself but SceneCommunicationService, for now. Beginning to clear the code from using Region.Communications. grid stuff. --- OpenSim/Region/Application/OpenSim.cs | 2 +- OpenSim/Region/Application/OpenSimBase.cs | 8 ++++---- OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs | 2 +- OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | 7 +++++++ 4 files changed, 13 insertions(+), 6 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Application/OpenSim.cs b/OpenSim/Region/Application/OpenSim.cs index 10071a0..e9c9dc1 100644 --- a/OpenSim/Region/Application/OpenSim.cs +++ b/OpenSim/Region/Application/OpenSim.cs @@ -557,7 +557,7 @@ namespace OpenSim /// private void HandleLoginStatus(string module, string[] cmd) { - if (m_commsManager.GridService.RegionLoginsEnabled == false) + if (m_sceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled == false) m_log.Info("[ Login ] Login are disabled "); else diff --git a/OpenSim/Region/Application/OpenSimBase.cs b/OpenSim/Region/Application/OpenSimBase.cs index 7bc0b77..4d13e83 100644 --- a/OpenSim/Region/Application/OpenSimBase.cs +++ b/OpenSim/Region/Application/OpenSimBase.cs @@ -209,9 +209,9 @@ namespace OpenSim } // Only enable logins to the regions once we have completely finished starting up (apart from scripts) - if ((m_commsManager != null) && (m_commsManager.GridService != null)) + if ((SceneManager.CurrentOrFirstScene != null) && (SceneManager.CurrentOrFirstScene.SceneGridService != null)) { - m_commsManager.GridService.RegionLoginsEnabled = true; + SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = true; } AddPluginCommands(); @@ -299,12 +299,12 @@ namespace OpenSim if (LoginEnabled) { m_log.Info("[LOGIN]: Login is now enabled."); - m_commsManager.GridService.RegionLoginsEnabled = true; + SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = true; } else { m_log.Info("[LOGIN]: Login is now disabled."); - m_commsManager.GridService.RegionLoginsEnabled = false; + SceneManager.CurrentOrFirstScene.SceneGridService.RegionLoginsEnabled = false; } } diff --git a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs index 613dbe9..4199c98 100644 --- a/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs +++ b/OpenSim/Region/CoreModules/Hypergrid/HGStandaloneLoginModule.cs @@ -61,7 +61,7 @@ namespace OpenSim.Region.CoreModules.Hypergrid { if (m_firstScene != null) { - return m_firstScene.CommsManager.GridService.RegionLoginsEnabled; + return m_firstScene.SceneGridService.RegionLoginsEnabled; } else { diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 204c319..56cd87d 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -63,6 +63,13 @@ namespace OpenSim.Region.Framework.Scenes protected List m_agentsInTransit; + public bool RegionLoginsEnabled + { + get { return m_regionLoginsEnabled; } + set { m_regionLoginsEnabled = value; } + } + private bool m_regionLoginsEnabled = false; + /// /// An agent is crossing into this region /// -- cgit v1.1 From eed8a615598e39d9aec2a5591fd2adbf7c2df7eb Mon Sep 17 00:00:00 2001 From: Diva Canto Date: Fri, 25 Sep 2009 08:47:45 -0700 Subject: More small changes to FlotsamAssetCache as per mcortez' request. --- OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs index d85d3df..37cccc8 100644 --- a/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs +++ b/OpenSim/Region/CoreModules/Asset/FlotsamAssetCache.cs @@ -142,7 +142,7 @@ namespace Flotsam.RegionModules.AssetCache m_CacheDirectory = assetConfig.GetString("CacheDirectory", m_DefaultCacheDirectory); m_log.InfoFormat("[FLOTSAM ASSET CACHE]: Cache Directory", m_DefaultCacheDirectory); - m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", true); + m_MemoryCacheEnabled = assetConfig.GetBoolean("MemoryCacheEnabled", false); m_MemoryExpiration = TimeSpan.FromHours(assetConfig.GetDouble("MemoryCacheTimeout", m_DefaultMemoryExpiration)); #if WAIT_ON_INPROGRESS_REQUESTS @@ -150,7 +150,7 @@ namespace Flotsam.RegionModules.AssetCache #endif m_LogLevel = assetConfig.GetInt("LogLevel", 1); - m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1); + m_HitRateDisplay = (ulong)assetConfig.GetInt("HitRateDisplay", 1000); m_FileExpiration = TimeSpan.FromHours(assetConfig.GetDouble("FileCacheTimeout", m_DefaultFileExpiration)); m_FileExpirationCleanupTimer = TimeSpan.FromHours(assetConfig.GetDouble("FileCleanupTimer", m_DefaultFileExpiration)); -- cgit v1.1 From 0a0b532270d7cc952648b99ed7ab7ec3b0f99676 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 25 Sep 2009 15:31:19 -0400 Subject: * Fixes teleporting within megaregions on HG enabled regions. You can teleport around now. (but it still doesn't fix the inconsistent attachment state when teleporting into region slots that are not the south west region on megaregions) --- .../Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs | 10 ++++++++-- OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs | 2 +- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs index 5c99d73..efc644d 100644 --- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs @@ -77,7 +77,7 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid if (regionHandle == m_regionInfo.RegionHandle) { // Teleport within the same region - if (position.X < 0 || position.X > Constants.RegionSize || position.Y < 0 || position.Y > Constants.RegionSize || position.Z < 0) + if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0) { Vector3 emergencyPos = new Vector3(128, 128, 128); @@ -89,7 +89,13 @@ namespace OpenSim.Region.Framework.Scenes.Hypergrid // TODO: Get proper AVG Height float localAVHeight = 1.56f; - float posZLimit = (float)avatar.Scene.Heightmap[(int)position.X, (int)position.Y]; + float posZLimit = 22; + + if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize) + { + posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y]; + } + float newPosZ = posZLimit + localAVHeight; if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ))) { diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs index 56cd87d..5f2333e 100644 --- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs +++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs @@ -1170,7 +1170,7 @@ namespace OpenSim.Region.Framework.Scenes } } - private bool IsOutsideRegion(Scene s, Vector3 pos) + protected bool IsOutsideRegion(Scene s, Vector3 pos) { if (s.TestBorderCross(pos,Cardinals.N)) -- cgit v1.1 From fb2cabd6b35bdbc966598de361044e2ff0164e5c Mon Sep 17 00:00:00 2001 From: dahlia Date: Fri, 25 Sep 2009 13:00:49 -0700 Subject: corrections to viewerMode AddPos() --- OpenSim/Region/Physics/Meshing/PrimMesher.cs | 27 +++++++++++++++++++++++++++ OpenSim/Region/Physics/Meshing/SculptMesh.cs | 14 +++++++++++++- 2 files changed, 40 insertions(+), 1 deletion(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/Physics/Meshing/PrimMesher.cs b/OpenSim/Region/Physics/Meshing/PrimMesher.cs index 0d19c01..abfd400 100644 --- a/OpenSim/Region/Physics/Meshing/PrimMesher.cs +++ b/OpenSim/Region/Physics/Meshing/PrimMesher.cs @@ -345,6 +345,21 @@ namespace PrimMesher this.v3.Z *= z; } + public void AddPos(float x, float y, float z) + { + this.v1.X += x; + this.v2.X += x; + this.v3.X += x; + + this.v1.Y += y; + this.v2.Y += y; + this.v3.Y += y; + + this.v1.Z += z; + this.v2.Z += z; + this.v3.Z += z; + } + public void AddRot(Quat q) { this.v1 *= q; @@ -2141,6 +2156,18 @@ namespace PrimMesher vert.Z += z; this.coords[i] = vert; } + + if (this.viewerFaces != null) + { + int numViewerFaces = this.viewerFaces.Count; + + for (i = 0; i < numViewerFaces; i++) + { + ViewerFace v = this.viewerFaces[i]; + v.AddPos(x, y, z); + this.viewerFaces[i] = v; + } + } } /// diff --git a/OpenSim/Region/Physics/Meshing/SculptMesh.cs b/OpenSim/Region/Physics/Meshing/SculptMesh.cs index bf42fee..bd63aef 100644 --- a/OpenSim/Region/Physics/Meshing/SculptMesh.cs +++ b/OpenSim/Region/Physics/Meshing/SculptMesh.cs @@ -494,6 +494,18 @@ namespace PrimMesher vert.Z += z; this.coords[i] = vert; } + + if (this.viewerFaces != null) + { + int numViewerFaces = this.viewerFaces.Count; + + for (i = 0; i < numViewerFaces; i++) + { + ViewerFace v = this.viewerFaces[i]; + v.AddPos(x, y, z); + this.viewerFaces[i] = v; + } + } } /// @@ -556,7 +568,7 @@ namespace PrimMesher if (path == null) return; String fileName = name + "_" + title + ".raw"; - String completePath = Path.Combine(path, fileName); + String completePath = System.IO.Path.Combine(path, fileName); StreamWriter sw = new StreamWriter(completePath); for (int i = 0; i < this.faces.Count; i++) -- cgit v1.1 From 2bb513329ac98914ff13a2817aa83b60d85603d9 Mon Sep 17 00:00:00 2001 From: Teravus Ovares (Dan Olivares) Date: Fri, 25 Sep 2009 16:06:04 -0400 Subject: * Does a full battery of tests to ensure that the object isn't an attachment before border crossing * Fixes 'Inconsistent Attachment State' when teleporting into another region besides the SW most region slot on a MegaRegion. * Fixes a host of other unintended attachment border cross edge cases that lead to Inconsistent attachment state. --- OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs | 6 +++--- OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs | 7 ++++++- 2 files changed, 9 insertions(+), 4 deletions(-) (limited to 'OpenSim/Region') diff --git a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs index 1436912..181c5ae 100644 --- a/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs +++ b/OpenSim/Region/CoreModules/World/Land/RegionCombinerModule.cs @@ -79,12 +79,12 @@ namespace OpenSim.Region.CoreModules.World.Land { if (!enabledYN) return; - +/* // For testing on a single instance if (scene.RegionInfo.RegionLocX == 1004 && scene.RegionInfo.RegionLocY == 1000) return; - // - + // +*/ lock (m_startingScenes) m_startingScenes.Add(scene.RegionInfo.originRegionID, scene); diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs index 3c17bbe..ad5d56f 100644 --- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs +++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs @@ -245,6 +245,11 @@ namespace OpenSim.Region.Framework.Scenes } } + private bool IsAttachmentCheckFull() + { + return (IsAttachment || (m_rootPart.Shape.PCode == 9 && m_rootPart.Shape.State != 0)); + } + /// /// The absolute position of this scene object in the scene /// @@ -257,7 +262,7 @@ namespace OpenSim.Region.Framework.Scenes if ((m_scene.TestBorderCross(val - Vector3.UnitX, Cardinals.E) || m_scene.TestBorderCross(val + Vector3.UnitX, Cardinals.W) || m_scene.TestBorderCross(val - Vector3.UnitY, Cardinals.N) || m_scene.TestBorderCross(val + Vector3.UnitY, Cardinals.S)) - && !IsAttachment) + && !IsAttachmentCheckFull()) { m_scene.CrossPrimGroupIntoNewRegion(val, this, true); } -- cgit v1.1