aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2012-05-09 23:25:01 +0100
committerJustin Clark-Casey (justincc)2012-05-09 23:25:01 +0100
commitd8a78374aa11c5460d6e58a6f4110fca61dfded4 (patch)
tree4214094c092eeff11f2dcd60f71cfc294ab887be /OpenSim/Services/Connectors/Land/LandServicesConnector.cs
parentImprove logging on the prim inventory script asset request path for future use. (diff)
downloadopensim-SC-d8a78374aa11c5460d6e58a6f4110fca61dfded4.zip
opensim-SC-d8a78374aa11c5460d6e58a6f4110fca61dfded4.tar.gz
opensim-SC-d8a78374aa11c5460d6e58a6f4110fca61dfded4.tar.bz2
opensim-SC-d8a78374aa11c5460d6e58a6f4110fca61dfded4.tar.xz
Where necessary, rename OpenSim/Services/Connectors/*.cs files to reflect the actual class names.
This is usually because the file name was singular (*Service*) but the class name was plural (*Services*). This is to make configuration easier rather than having to look in the c# code itself to find the slightly different name of the connector. This does not affect existing configuration since the files are being renamed rather than the classes.
Diffstat (limited to 'OpenSim/Services/Connectors/Land/LandServicesConnector.cs')
-rw-r--r--OpenSim/Services/Connectors/Land/LandServicesConnector.cs133
1 files changed, 133 insertions, 0 deletions
diff --git a/OpenSim/Services/Connectors/Land/LandServicesConnector.cs b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
new file mode 100644
index 0000000..30a73a4
--- /dev/null
+++ b/OpenSim/Services/Connectors/Land/LandServicesConnector.cs
@@ -0,0 +1,133 @@
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
28using log4net;
29using System;
30using System.Collections;
31using System.Collections.Generic;
32using System.IO;
33using System.Reflection;
34using Nini.Config;
35using OpenSim.Framework;
36using OpenSim.Framework.Communications;
37using OpenSim.Services.Interfaces;
38using OpenMetaverse;
39using Nwc.XmlRpc;
40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41
42namespace OpenSim.Services.Connectors
43{
44 public class LandServicesConnector : ILandService
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(
48 MethodBase.GetCurrentMethod().DeclaringType);
49
50 protected IGridService m_GridService = null;
51
52 public LandServicesConnector()
53 {
54 }
55
56 public LandServicesConnector(IGridService gridServices)
57 {
58 Initialise(gridServices);
59 }
60
61 public virtual void Initialise(IGridService gridServices)
62 {
63 m_GridService = gridServices;
64 }
65
66 public virtual LandData GetLandData(UUID scopeID, ulong regionHandle, uint x, uint y, out byte regionAccess)
67 {
68 LandData landData = null;
69 Hashtable hash = new Hashtable();
70 hash["region_handle"] = regionHandle.ToString();
71 hash["x"] = x.ToString();
72 hash["y"] = y.ToString();
73
74 IList paramList = new ArrayList();
75 paramList.Add(hash);
76 regionAccess = 42; // Default to adult. Better safe...
77
78 try
79 {
80 uint xpos = 0, ypos = 0;
81 Utils.LongToUInts(regionHandle, out xpos, out ypos);
82 GridRegion info = m_GridService.GetRegionByPosition(scopeID, (int)xpos, (int)ypos);
83 if (info != null) // just to be sure
84 {
85 XmlRpcRequest request = new XmlRpcRequest("land_data", paramList);
86 XmlRpcResponse response = request.Send(info.ServerURI, 10000);
87 if (response.IsFault)
88 {
89 m_log.ErrorFormat("[LAND CONNECTOR]: remote call returned an error: {0}", response.FaultString);
90 }
91 else
92 {
93 hash = (Hashtable)response.Value;
94 try
95 {
96 landData = new LandData();
97 landData.AABBMax = Vector3.Parse((string)hash["AABBMax"]);
98 landData.AABBMin = Vector3.Parse((string)hash["AABBMin"]);
99 landData.Area = Convert.ToInt32(hash["Area"]);
100 landData.AuctionID = Convert.ToUInt32(hash["AuctionID"]);
101 landData.Description = (string)hash["Description"];
102 landData.Flags = Convert.ToUInt32(hash["Flags"]);
103 landData.GlobalID = new UUID((string)hash["GlobalID"]);
104 landData.Name = (string)hash["Name"];
105 landData.OwnerID = new UUID((string)hash["OwnerID"]);
106 landData.SalePrice = Convert.ToInt32(hash["SalePrice"]);
107 landData.SnapshotID = new UUID((string)hash["SnapshotID"]);
108 landData.UserLocation = Vector3.Parse((string)hash["UserLocation"]);
109 if (hash["RegionAccess"] != null)
110 regionAccess = (byte)Convert.ToInt32((string)hash["RegionAccess"]);
111 m_log.DebugFormat("[LAND CONNECTOR]: Got land data for parcel {0}", landData.Name);
112 }
113 catch (Exception e)
114 {
115 m_log.ErrorFormat(
116 "[LAND CONNECTOR]: Got exception while parsing land-data: {0} {1}",
117 e.Message, e.StackTrace);
118 }
119 }
120 }
121 else
122 m_log.WarnFormat("[LAND CONNECTOR]: Couldn't find region with handle {0}", regionHandle);
123 }
124 catch (Exception e)
125 {
126 m_log.ErrorFormat(
127 "[LAND CONNECTOR]: Couldn't contact region {0}: {1} {2}", regionHandle, e.Message, e.StackTrace);
128 }
129
130 return landData;
131 }
132 }
133} \ No newline at end of file