diff options
Diffstat (limited to 'OpenSim/Services')
-rw-r--r-- | OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | 155 | ||||
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 15 |
2 files changed, 167 insertions, 3 deletions
diff --git a/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs new file mode 100644 index 0000000..f68c10a --- /dev/null +++ b/OpenSim/Services/Connectors/Grid/HypergridServiceConnector.cs | |||
@@ -0,0 +1,155 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSimulator Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | */ | ||
27 | |||
28 | using System; | ||
29 | using System.Collections; | ||
30 | using System.Collections.Generic; | ||
31 | using System.Text; | ||
32 | using System.Drawing; | ||
33 | using System.Net; | ||
34 | using System.Reflection; | ||
35 | using OpenSim.Services.Interfaces; | ||
36 | |||
37 | using OpenSim.Framework; | ||
38 | |||
39 | using OpenMetaverse; | ||
40 | using OpenMetaverse.Imaging; | ||
41 | using log4net; | ||
42 | using Nwc.XmlRpc; | ||
43 | |||
44 | namespace OpenSim.Services.Connectors.Grid | ||
45 | { | ||
46 | public class HypergridServiceConnector | ||
47 | { | ||
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
49 | |||
50 | private IAssetService m_AssetService; | ||
51 | |||
52 | public HypergridServiceConnector(IAssetService assService) | ||
53 | { | ||
54 | m_AssetService = assService; | ||
55 | } | ||
56 | |||
57 | public UUID LinkRegion(SimpleRegionInfo info) | ||
58 | { | ||
59 | UUID uuid = UUID.Zero; | ||
60 | |||
61 | //Hashtable hash = new Hashtable(); | ||
62 | //hash["region_name"] = info.RegionName; | ||
63 | |||
64 | //IList paramList = new ArrayList(); | ||
65 | //paramList.Add(hash); | ||
66 | |||
67 | //XmlRpcRequest request = new XmlRpcRequest("link_region", paramList); | ||
68 | //string uri = "http://" + info.ExternalEndPoint.Address + ":" + info.HttpPort + "/"; | ||
69 | //m_log.Debug("[HGrid]: Linking to " + uri); | ||
70 | //XmlRpcResponse response = request.Send(uri, 10000); | ||
71 | //if (response.IsFault) | ||
72 | //{ | ||
73 | // m_log.ErrorFormat("[HGrid]: remote call returned an error: {0}", response.FaultString); | ||
74 | //} | ||
75 | //else | ||
76 | //{ | ||
77 | // hash = (Hashtable)response.Value; | ||
78 | // //foreach (Object o in hash) | ||
79 | // // m_log.Debug(">> " + ((DictionaryEntry)o).Key + ":" + ((DictionaryEntry)o).Value); | ||
80 | // try | ||
81 | // { | ||
82 | // UUID.TryParse((string)hash["uuid"], out uuid); | ||
83 | // info.RegionID = uuid; | ||
84 | // if ((string)hash["handle"] != null) | ||
85 | // { | ||
86 | // info.regionSecret = (string)hash["handle"]; | ||
87 | // //m_log.Debug(">> HERE: " + info.regionSecret); | ||
88 | // } | ||
89 | // if (hash["region_image"] != null) | ||
90 | // { | ||
91 | // UUID img = UUID.Zero; | ||
92 | // UUID.TryParse((string)hash["region_image"], out img); | ||
93 | // info.RegionSettings.TerrainImageID = img; | ||
94 | // } | ||
95 | // if (hash["region_name"] != null) | ||
96 | // { | ||
97 | // info.RegionName = (string)hash["region_name"]; | ||
98 | // //m_log.Debug(">> " + info.RegionName); | ||
99 | // } | ||
100 | // if (hash["internal_port"] != null) | ||
101 | // { | ||
102 | // int port = Convert.ToInt32((string)hash["internal_port"]); | ||
103 | // info.InternalEndPoint = new IPEndPoint(IPAddress.Parse("0.0.0.0"), port); | ||
104 | // //m_log.Debug(">> " + info.InternalEndPoint.ToString()); | ||
105 | // } | ||
106 | // if (hash["remoting_port"] != null) | ||
107 | // { | ||
108 | // info.RemotingPort = Convert.ToUInt32(hash["remoting_port"]); | ||
109 | // //m_log.Debug(">> " + info.RemotingPort); | ||
110 | // } | ||
111 | |||
112 | // } | ||
113 | // catch (Exception e) | ||
114 | // { | ||
115 | // m_log.Error("[HGrid]: Got exception while parsing hyperlink response " + e.StackTrace); | ||
116 | // } | ||
117 | //} | ||
118 | return uuid; | ||
119 | } | ||
120 | |||
121 | public void GetMapImage(SimpleRegionInfo info) | ||
122 | { | ||
123 | try | ||
124 | { | ||
125 | string regionimage = "regionImage" + info.RegionID.ToString(); | ||
126 | regionimage = regionimage.Replace("-", ""); | ||
127 | |||
128 | WebClient c = new WebClient(); | ||
129 | string uri = "http://" + info.ExternalHostName + ":" + info.HttpPort + "/index.php?method=" + regionimage; | ||
130 | //m_log.Debug("JPEG: " + uri); | ||
131 | c.DownloadFile(uri, info.RegionID.ToString() + ".jpg"); | ||
132 | Bitmap m = new Bitmap(info.RegionID.ToString() + ".jpg"); | ||
133 | //m_log.Debug("Size: " + m.PhysicalDimension.Height + "-" + m.PhysicalDimension.Width); | ||
134 | byte[] imageData = OpenJPEG.EncodeFromImage(m, true); | ||
135 | AssetBase ass = new AssetBase(UUID.Random(), "region " + info.RegionID.ToString()); | ||
136 | |||
137 | // !!! for now | ||
138 | //info.RegionSettings.TerrainImageID = ass.FullID; | ||
139 | |||
140 | ass.Type = (int)AssetType.Texture; | ||
141 | ass.Temporary = true; | ||
142 | ass.Local = true; | ||
143 | ass.Data = imageData; | ||
144 | |||
145 | m_AssetService.Store(ass); | ||
146 | |||
147 | } | ||
148 | catch // LEGIT: Catching problems caused by OpenJPEG p/invoke | ||
149 | { | ||
150 | m_log.Warn("[HGrid]: Failed getting/storing map image, because it is probably already in the cache"); | ||
151 | } | ||
152 | } | ||
153 | |||
154 | } | ||
155 | } | ||
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 2229421..dd529f5 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -95,7 +95,9 @@ namespace OpenSim.Services.GridService | |||
95 | if (region != null) | 95 | if (region != null) |
96 | { | 96 | { |
97 | // Not really? Maybe? | 97 | // Not really? Maybe? |
98 | List<RegionData> rdatas = m_Database.Get(region.posX - 1, region.posY - 1, region.posX + 1, region.posY + 1, scopeID); | 98 | List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize, |
99 | region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); | ||
100 | |||
99 | foreach (RegionData rdata in rdatas) | 101 | foreach (RegionData rdata in rdatas) |
100 | rinfos.Add(RegionData2RegionInfo(rdata)); | 102 | rinfos.Add(RegionData2RegionInfo(rdata)); |
101 | 103 | ||
@@ -114,7 +116,9 @@ namespace OpenSim.Services.GridService | |||
114 | 116 | ||
115 | public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) | 117 | public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) |
116 | { | 118 | { |
117 | RegionData rdata = m_Database.Get(x, y, scopeID); | 119 | int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; |
120 | int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; | ||
121 | RegionData rdata = m_Database.Get(snapX, snapY, scopeID); | ||
118 | if (rdata != null) | 122 | if (rdata != null) |
119 | return RegionData2RegionInfo(rdata); | 123 | return RegionData2RegionInfo(rdata); |
120 | 124 | ||
@@ -151,7 +155,12 @@ namespace OpenSim.Services.GridService | |||
151 | 155 | ||
152 | public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | 156 | public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) |
153 | { | 157 | { |
154 | List<RegionData> rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); | 158 | int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; |
159 | int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; | ||
160 | int yminSnap = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; | ||
161 | int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; | ||
162 | |||
163 | List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); | ||
155 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); | 164 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); |
156 | foreach (RegionData rdata in rdatas) | 165 | foreach (RegionData rdata in rdatas) |
157 | rinfos.Add(RegionData2RegionInfo(rdata)); | 166 | rinfos.Add(RegionData2RegionInfo(rdata)); |