diff options
author | Justin Clark-Casey (justincc) | 2009-09-24 17:35:03 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2009-09-24 17:35:03 +0100 |
commit | ad753d784cfefacd8fb745a1431bf98feac9bbd6 (patch) | |
tree | 795ec1ba25eada570c342746f07654849a7199f4 /OpenSim/Services/GridService/GridService.cs | |
parent | minor: make rest (not comm) modules less noisy if they are disabled (diff) | |
parent | Changed name of the hyperlink XMLRPC method to linkk-region, so that it doesn... (diff) | |
download | opensim-SC-ad753d784cfefacd8fb745a1431bf98feac9bbd6.zip opensim-SC-ad753d784cfefacd8fb745a1431bf98feac9bbd6.tar.gz opensim-SC-ad753d784cfefacd8fb745a1431bf98feac9bbd6.tar.bz2 opensim-SC-ad753d784cfefacd8fb745a1431bf98feac9bbd6.tar.xz |
Merge branch 'master' of ssh://justincc@opensimulator.org/var/git/opensim
Diffstat (limited to 'OpenSim/Services/GridService/GridService.cs')
-rw-r--r-- | OpenSim/Services/GridService/GridService.cs | 58 |
1 files changed, 36 insertions, 22 deletions
diff --git a/OpenSim/Services/GridService/GridService.cs b/OpenSim/Services/GridService/GridService.cs index 2229421..01ffa1d 100644 --- a/OpenSim/Services/GridService/GridService.cs +++ b/OpenSim/Services/GridService/GridService.cs | |||
@@ -35,6 +35,7 @@ using OpenSim.Framework; | |||
35 | using OpenSim.Framework.Console; | 35 | using OpenSim.Framework.Console; |
36 | using OpenSim.Data; | 36 | using OpenSim.Data; |
37 | using OpenSim.Services.Interfaces; | 37 | using OpenSim.Services.Interfaces; |
38 | using GridRegion = OpenSim.Services.Interfaces.GridRegion; | ||
38 | using OpenMetaverse; | 39 | using OpenMetaverse; |
39 | 40 | ||
40 | namespace OpenSim.Services.GridService | 41 | namespace OpenSim.Services.GridService |
@@ -48,6 +49,7 @@ namespace OpenSim.Services.GridService | |||
48 | public GridService(IConfigSource config) | 49 | public GridService(IConfigSource config) |
49 | : base(config) | 50 | : base(config) |
50 | { | 51 | { |
52 | m_log.DebugFormat("[GRID SERVICE]: Starting..."); | ||
51 | MainConsole.Instance.Commands.AddCommand("kfs", false, | 53 | MainConsole.Instance.Commands.AddCommand("kfs", false, |
52 | "show digest", | 54 | "show digest", |
53 | "show digest <ID>", | 55 | "show digest <ID>", |
@@ -62,14 +64,16 @@ namespace OpenSim.Services.GridService | |||
62 | 64 | ||
63 | #region IGridService | 65 | #region IGridService |
64 | 66 | ||
65 | public bool RegisterRegion(UUID scopeID, SimpleRegionInfo regionInfos) | 67 | public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) |
66 | { | 68 | { |
67 | if (m_Database.Get(regionInfos.RegionID, scopeID) != null) | 69 | if (m_Database.Get(regionInfos.RegionID, scopeID) != null) |
68 | { | 70 | { |
69 | m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); | 71 | m_log.WarnFormat("[GRID SERVICE]: Region {0} already registered in scope {1}.", regionInfos.RegionID, scopeID); |
70 | return false; | 72 | return false; |
71 | } | 73 | } |
72 | if (m_Database.Get((int)regionInfos.RegionLocX, (int)regionInfos.RegionLocY, scopeID) != null) | 74 | // This needs better sanity testing. What if regionInfo is registering in |
75 | // overlapping coords? | ||
76 | if (m_Database.Get(regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID) != null) | ||
73 | { | 77 | { |
74 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", | 78 | m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", |
75 | regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); | 79 | regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); |
@@ -88,22 +92,25 @@ namespace OpenSim.Services.GridService | |||
88 | return m_Database.Delete(regionID); | 92 | return m_Database.Delete(regionID); |
89 | } | 93 | } |
90 | 94 | ||
91 | public List<SimpleRegionInfo> GetNeighbours(UUID scopeID, UUID regionID) | 95 | public List<GridRegion> GetNeighbours(UUID scopeID, UUID regionID) |
92 | { | 96 | { |
93 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); | 97 | List<GridRegion> rinfos = new List<GridRegion>(); |
94 | RegionData region = m_Database.Get(regionID, scopeID); | 98 | RegionData region = m_Database.Get(regionID, scopeID); |
95 | if (region != null) | 99 | if (region != null) |
96 | { | 100 | { |
97 | // Not really? Maybe? | 101 | // Not really? Maybe? |
98 | List<RegionData> rdatas = m_Database.Get(region.posX - 1, region.posY - 1, region.posX + 1, region.posY + 1, scopeID); | 102 | List<RegionData> rdatas = m_Database.Get(region.posX - (int)Constants.RegionSize, region.posY - (int)Constants.RegionSize, |
103 | region.posX + (int)Constants.RegionSize, region.posY + (int)Constants.RegionSize, scopeID); | ||
104 | |||
99 | foreach (RegionData rdata in rdatas) | 105 | foreach (RegionData rdata in rdatas) |
100 | rinfos.Add(RegionData2RegionInfo(rdata)); | 106 | if (rdata.RegionID != regionID) |
107 | rinfos.Add(RegionData2RegionInfo(rdata)); | ||
101 | 108 | ||
102 | } | 109 | } |
103 | return rinfos; | 110 | return rinfos; |
104 | } | 111 | } |
105 | 112 | ||
106 | public SimpleRegionInfo GetRegionByUUID(UUID scopeID, UUID regionID) | 113 | public GridRegion GetRegionByUUID(UUID scopeID, UUID regionID) |
107 | { | 114 | { |
108 | RegionData rdata = m_Database.Get(regionID, scopeID); | 115 | RegionData rdata = m_Database.Get(regionID, scopeID); |
109 | if (rdata != null) | 116 | if (rdata != null) |
@@ -112,16 +119,18 @@ namespace OpenSim.Services.GridService | |||
112 | return null; | 119 | return null; |
113 | } | 120 | } |
114 | 121 | ||
115 | public SimpleRegionInfo GetRegionByPosition(UUID scopeID, int x, int y) | 122 | public GridRegion GetRegionByPosition(UUID scopeID, int x, int y) |
116 | { | 123 | { |
117 | RegionData rdata = m_Database.Get(x, y, scopeID); | 124 | int snapX = (int)(x / Constants.RegionSize) * (int)Constants.RegionSize; |
125 | int snapY = (int)(y / Constants.RegionSize) * (int)Constants.RegionSize; | ||
126 | RegionData rdata = m_Database.Get(snapX, snapY, scopeID); | ||
118 | if (rdata != null) | 127 | if (rdata != null) |
119 | return RegionData2RegionInfo(rdata); | 128 | return RegionData2RegionInfo(rdata); |
120 | 129 | ||
121 | return null; | 130 | return null; |
122 | } | 131 | } |
123 | 132 | ||
124 | public SimpleRegionInfo GetRegionByName(UUID scopeID, string regionName) | 133 | public GridRegion GetRegionByName(UUID scopeID, string regionName) |
125 | { | 134 | { |
126 | List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID); | 135 | List<RegionData> rdatas = m_Database.Get(regionName + "%", scopeID); |
127 | if ((rdatas != null) && (rdatas.Count > 0)) | 136 | if ((rdatas != null) && (rdatas.Count > 0)) |
@@ -130,12 +139,12 @@ namespace OpenSim.Services.GridService | |||
130 | return null; | 139 | return null; |
131 | } | 140 | } |
132 | 141 | ||
133 | public List<SimpleRegionInfo> GetRegionsByName(UUID scopeID, string name, int maxNumber) | 142 | public List<GridRegion> GetRegionsByName(UUID scopeID, string name, int maxNumber) |
134 | { | 143 | { |
135 | List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID); | 144 | List<RegionData> rdatas = m_Database.Get("%" + name + "%", scopeID); |
136 | 145 | ||
137 | int count = 0; | 146 | int count = 0; |
138 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); | 147 | List<GridRegion> rinfos = new List<GridRegion>(); |
139 | 148 | ||
140 | if (rdatas != null) | 149 | if (rdatas != null) |
141 | { | 150 | { |
@@ -149,10 +158,15 @@ namespace OpenSim.Services.GridService | |||
149 | return rinfos; | 158 | return rinfos; |
150 | } | 159 | } |
151 | 160 | ||
152 | public List<SimpleRegionInfo> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) | 161 | public List<GridRegion> GetRegionRange(UUID scopeID, int xmin, int xmax, int ymin, int ymax) |
153 | { | 162 | { |
154 | List<RegionData> rdatas = m_Database.Get(xmin, ymin, xmax, ymax, scopeID); | 163 | int xminSnap = (int)(xmin / Constants.RegionSize) * (int)Constants.RegionSize; |
155 | List<SimpleRegionInfo> rinfos = new List<SimpleRegionInfo>(); | 164 | int xmaxSnap = (int)(xmax / Constants.RegionSize) * (int)Constants.RegionSize; |
165 | int yminSnap = (int)(ymin / Constants.RegionSize) * (int)Constants.RegionSize; | ||
166 | int ymaxSnap = (int)(ymax / Constants.RegionSize) * (int)Constants.RegionSize; | ||
167 | |||
168 | List<RegionData> rdatas = m_Database.Get(xminSnap, yminSnap, xmaxSnap, ymaxSnap, scopeID); | ||
169 | List<GridRegion> rinfos = new List<GridRegion>(); | ||
156 | foreach (RegionData rdata in rdatas) | 170 | foreach (RegionData rdata in rdatas) |
157 | rinfos.Add(RegionData2RegionInfo(rdata)); | 171 | rinfos.Add(RegionData2RegionInfo(rdata)); |
158 | 172 | ||
@@ -163,25 +177,25 @@ namespace OpenSim.Services.GridService | |||
163 | 177 | ||
164 | #region Data structure conversions | 178 | #region Data structure conversions |
165 | 179 | ||
166 | protected RegionData RegionInfo2RegionData(SimpleRegionInfo rinfo) | 180 | protected RegionData RegionInfo2RegionData(GridRegion rinfo) |
167 | { | 181 | { |
168 | RegionData rdata = new RegionData(); | 182 | RegionData rdata = new RegionData(); |
169 | rdata.posX = (int)rinfo.RegionLocX; | 183 | rdata.posX = (int)rinfo.RegionLocX; |
170 | rdata.posY = (int)rinfo.RegionLocY; | 184 | rdata.posY = (int)rinfo.RegionLocY; |
171 | rdata.RegionID = rinfo.RegionID; | 185 | rdata.RegionID = rinfo.RegionID; |
172 | rdata.Data = rinfo.ToKeyValuePairs(); | 186 | rdata.Data = rinfo.ToKeyValuePairs(); |
173 | //rdata.RegionName = rinfo.RegionName; | 187 | rdata.RegionName = rinfo.RegionName; |
174 | 188 | ||
175 | return rdata; | 189 | return rdata; |
176 | } | 190 | } |
177 | 191 | ||
178 | protected SimpleRegionInfo RegionData2RegionInfo(RegionData rdata) | 192 | protected GridRegion RegionData2RegionInfo(RegionData rdata) |
179 | { | 193 | { |
180 | SimpleRegionInfo rinfo = new SimpleRegionInfo(rdata.Data); | 194 | GridRegion rinfo = new GridRegion(rdata.Data); |
181 | rinfo.RegionLocX = (uint)rdata.posX; | 195 | rinfo.RegionLocX = rdata.posX; |
182 | rinfo.RegionLocY = (uint)rdata.posY; | 196 | rinfo.RegionLocY = rdata.posY; |
183 | rinfo.RegionID = rdata.RegionID; | 197 | rinfo.RegionID = rdata.RegionID; |
184 | //rinfo.RegionName = rdata.RegionName; | 198 | rinfo.RegionName = rdata.RegionName; |
185 | 199 | ||
186 | return rinfo; | 200 | return rinfo; |
187 | } | 201 | } |