opensim – Blame information for rev 1
?pathlinks?
Rev | Author | Line No. | Line |
---|---|---|---|
1 | eva | 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.Reflection; |
||
29 | using System.Collections.Generic; |
||
30 | using log4net; |
||
31 | using OpenMetaverse; |
||
32 | using OpenSim.Framework; |
||
33 | using OpenSim.Region.Framework.Interfaces; |
||
34 | using OpenSim.Region.Framework.Scenes; |
||
35 | |||
36 | namespace OpenSim.Data.Null |
||
37 | { |
||
38 | public class NullDataService : ISimulationDataService |
||
39 | { |
||
40 | private NullDataStore m_store; |
||
41 | |||
42 | public NullDataService() |
||
43 | { |
||
44 | m_store = new NullDataStore(); |
||
45 | } |
||
46 | |||
47 | public void StoreObject(SceneObjectGroup obj, UUID regionUUID) |
||
48 | { |
||
49 | m_store.StoreObject(obj, regionUUID); |
||
50 | } |
||
51 | |||
52 | public void RemoveObject(UUID uuid, UUID regionUUID) |
||
53 | { |
||
54 | m_store.RemoveObject(uuid, regionUUID); |
||
55 | } |
||
56 | |||
57 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) |
||
58 | { |
||
59 | m_store.StorePrimInventory(primID, items); |
||
60 | } |
||
61 | |||
62 | public List<SceneObjectGroup> LoadObjects(UUID regionUUID) |
||
63 | { |
||
64 | return m_store.LoadObjects(regionUUID); |
||
65 | } |
||
66 | |||
67 | public void StoreTerrain(double[,] terrain, UUID regionID) |
||
68 | { |
||
69 | m_store.StoreTerrain(terrain, regionID); |
||
70 | } |
||
71 | |||
72 | public void StoreTerrain(TerrainData terrain, UUID regionID) |
||
73 | { |
||
74 | m_store.StoreTerrain(terrain, regionID); |
||
75 | } |
||
76 | |||
77 | public double[,] LoadTerrain(UUID regionID) |
||
78 | { |
||
79 | return m_store.LoadTerrain(regionID); |
||
80 | } |
||
81 | |||
82 | public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) |
||
83 | { |
||
84 | return m_store.LoadTerrain(regionID, pSizeX, pSizeY, pSizeZ); |
||
85 | } |
||
86 | |||
87 | public void StoreLandObject(ILandObject Parcel) |
||
88 | { |
||
89 | m_store.StoreLandObject(Parcel); |
||
90 | } |
||
91 | |||
92 | public void RemoveLandObject(UUID globalID) |
||
93 | { |
||
94 | m_store.RemoveLandObject(globalID); |
||
95 | } |
||
96 | |||
97 | public List<LandData> LoadLandObjects(UUID regionUUID) |
||
98 | { |
||
99 | return m_store.LoadLandObjects(regionUUID); |
||
100 | } |
||
101 | |||
102 | public void StoreRegionSettings(RegionSettings rs) |
||
103 | { |
||
104 | m_store.StoreRegionSettings(rs); |
||
105 | } |
||
106 | |||
107 | public RegionSettings LoadRegionSettings(UUID regionUUID) |
||
108 | { |
||
109 | return m_store.LoadRegionSettings(regionUUID); |
||
110 | } |
||
111 | |||
112 | public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) |
||
113 | { |
||
114 | return m_store.LoadRegionWindlightSettings(regionUUID); |
||
115 | } |
||
116 | |||
117 | public void RemoveRegionWindlightSettings(UUID regionID) |
||
118 | { |
||
119 | } |
||
120 | |||
121 | public void StoreRegionWindlightSettings(RegionLightShareData wl) |
||
122 | { |
||
123 | m_store.StoreRegionWindlightSettings(wl); |
||
124 | } |
||
125 | |||
126 | public string LoadRegionEnvironmentSettings(UUID regionUUID) |
||
127 | { |
||
128 | return m_store.LoadRegionEnvironmentSettings(regionUUID); |
||
129 | } |
||
130 | |||
131 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) |
||
132 | { |
||
133 | m_store.StoreRegionEnvironmentSettings(regionUUID, settings); |
||
134 | } |
||
135 | |||
136 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) |
||
137 | { |
||
138 | m_store.RemoveRegionEnvironmentSettings(regionUUID); |
||
139 | } |
||
140 | |||
141 | public void SaveExtra(UUID regionID, string name, string value) |
||
142 | { |
||
143 | } |
||
144 | |||
145 | public void RemoveExtra(UUID regionID, string name) |
||
146 | { |
||
147 | } |
||
148 | |||
149 | public Dictionary<string, string> GetExtra(UUID regionID) |
||
150 | { |
||
151 | return null; |
||
152 | } |
||
153 | } |
||
154 | |||
155 | /// <summary> |
||
156 | /// Mock region data plugin. This obeys the api contract for persistence but stores everything in memory, so that |
||
157 | /// tests can check correct persistence. |
||
158 | /// </summary> |
||
159 | public class NullDataStore : ISimulationDataStore |
||
160 | { |
||
161 | // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
||
162 | |||
163 | protected Dictionary<UUID, RegionSettings> m_regionSettings = new Dictionary<UUID, RegionSettings>(); |
||
164 | protected Dictionary<UUID, SceneObjectPart> m_sceneObjectParts = new Dictionary<UUID, SceneObjectPart>(); |
||
165 | protected Dictionary<UUID, ICollection<TaskInventoryItem>> m_primItems |
||
166 | = new Dictionary<UUID, ICollection<TaskInventoryItem>>(); |
||
167 | protected Dictionary<UUID, TerrainData> m_terrains = new Dictionary<UUID, TerrainData>(); |
||
168 | protected Dictionary<UUID, LandData> m_landData = new Dictionary<UUID, LandData>(); |
||
169 | |||
170 | public void Initialise(string dbfile) |
||
171 | { |
||
172 | return; |
||
173 | } |
||
174 | |||
175 | public void Dispose() |
||
176 | { |
||
177 | } |
||
178 | |||
179 | public void StoreRegionSettings(RegionSettings rs) |
||
180 | { |
||
181 | m_regionSettings[rs.RegionUUID] = rs; |
||
182 | } |
||
183 | |||
184 | public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) |
||
185 | { |
||
186 | //This connector doesn't support the windlight module yet |
||
187 | //Return default LL windlight settings |
||
188 | return new RegionLightShareData(); |
||
189 | } |
||
190 | |||
191 | public void RemoveRegionWindlightSettings(UUID regionID) |
||
192 | { |
||
193 | } |
||
194 | |||
195 | public void StoreRegionWindlightSettings(RegionLightShareData wl) |
||
196 | { |
||
197 | //This connector doesn't support the windlight module yet |
||
198 | } |
||
199 | |||
200 | #region Environment Settings |
||
201 | public string LoadRegionEnvironmentSettings(UUID regionUUID) |
||
202 | { |
||
203 | //This connector doesn't support the Environment module yet |
||
204 | return string.Empty; |
||
205 | } |
||
206 | |||
207 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) |
||
208 | { |
||
209 | //This connector doesn't support the Environment module yet |
||
210 | } |
||
211 | |||
212 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) |
||
213 | { |
||
214 | //This connector doesn't support the Environment module yet |
||
215 | } |
||
216 | #endregion |
||
217 | |||
218 | public RegionSettings LoadRegionSettings(UUID regionUUID) |
||
219 | { |
||
220 | RegionSettings rs = null; |
||
221 | m_regionSettings.TryGetValue(regionUUID, out rs); |
||
222 | |||
223 | if (rs == null) |
||
224 | rs = new RegionSettings(); |
||
225 | |||
226 | return rs; |
||
227 | } |
||
228 | |||
229 | public void StoreObject(SceneObjectGroup obj, UUID regionUUID) |
||
230 | { |
||
231 | // We can't simply store groups here because on delinking, OpenSim will not update the original group |
||
232 | // directly. Rather, the newly delinked parts will be updated to be in their own scene object group |
||
233 | // Therefore, we need to store parts rather than groups. |
||
234 | foreach (SceneObjectPart prim in obj.Parts) |
||
235 | { |
||
236 | // m_log.DebugFormat( |
||
237 | // "[MOCK REGION DATA PLUGIN]: Storing part {0} {1} in object {2} {3} in region {4}", |
||
238 | // prim.Name, prim.UUID, obj.Name, obj.UUID, regionUUID); |
||
239 | |||
240 | m_sceneObjectParts[prim.UUID] = prim; |
||
241 | } |
||
242 | } |
||
243 | |||
244 | public void RemoveObject(UUID obj, UUID regionUUID) |
||
245 | { |
||
246 | // All parts belonging to the object with the uuid are removed. |
||
247 | List<SceneObjectPart> parts = new List<SceneObjectPart>(m_sceneObjectParts.Values); |
||
248 | foreach (SceneObjectPart part in parts) |
||
249 | { |
||
250 | if (part.ParentGroup.UUID == obj) |
||
251 | { |
||
252 | // m_log.DebugFormat( |
||
253 | // "[MOCK REGION DATA PLUGIN]: Removing part {0} {1} as part of object {2} from {3}", |
||
254 | // part.Name, part.UUID, obj, regionUUID); |
||
255 | m_sceneObjectParts.Remove(part.UUID); |
||
256 | } |
||
257 | } |
||
258 | } |
||
259 | |||
260 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) |
||
261 | { |
||
262 | m_primItems[primID] = items; |
||
263 | } |
||
264 | |||
265 | public List<SceneObjectGroup> LoadObjects(UUID regionUUID) |
||
266 | { |
||
267 | Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>(); |
||
268 | |||
269 | // Create all of the SOGs from the root prims first |
||
270 | foreach (SceneObjectPart prim in m_sceneObjectParts.Values) |
||
271 | { |
||
272 | if (prim.IsRoot) |
||
273 | { |
||
274 | // m_log.DebugFormat( |
||
275 | // "[MOCK REGION DATA PLUGIN]: Loading root part {0} {1} in {2}", prim.Name, prim.UUID, regionUUID); |
||
276 | objects[prim.UUID] = new SceneObjectGroup(prim); |
||
277 | } |
||
278 | } |
||
279 | |||
280 | // Add all of the children objects to the SOGs |
||
281 | foreach (SceneObjectPart prim in m_sceneObjectParts.Values) |
||
282 | { |
||
283 | SceneObjectGroup sog; |
||
284 | if (prim.UUID != prim.ParentUUID) |
||
285 | { |
||
286 | if (objects.TryGetValue(prim.ParentUUID, out sog)) |
||
287 | { |
||
288 | int originalLinkNum = prim.LinkNum; |
||
289 | |||
290 | sog.AddPart(prim); |
||
291 | |||
292 | // SceneObjectGroup.AddPart() tries to be smart and automatically set the LinkNum. |
||
293 | // We override that here |
||
294 | if (originalLinkNum != 0) |
||
295 | prim.LinkNum = originalLinkNum; |
||
296 | } |
||
297 | else |
||
298 | { |
||
299 | // m_log.WarnFormat( |
||
300 | // "[MOCK REGION DATA PLUGIN]: Database contains an orphan child prim {0} {1} in region {2} pointing to missing parent {3}. This prim will not be loaded.", |
||
301 | // prim.Name, prim.UUID, regionUUID, prim.ParentUUID); |
||
302 | } |
||
303 | } |
||
304 | } |
||
305 | |||
306 | // TODO: Load items. This is assymetric - we store items as a separate method but don't retrieve them that |
||
307 | // way! |
||
308 | |||
309 | return new List<SceneObjectGroup>(objects.Values); |
||
310 | } |
||
311 | |||
312 | public void StoreTerrain(TerrainData ter, UUID regionID) |
||
313 | { |
||
314 | m_terrains[regionID] = ter; |
||
315 | } |
||
316 | |||
317 | public void StoreTerrain(double[,] ter, UUID regionID) |
||
318 | { |
||
319 | m_terrains[regionID] = new HeightmapTerrainData(ter); |
||
320 | } |
||
321 | |||
322 | public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) |
||
323 | { |
||
324 | if (m_terrains.ContainsKey(regionID)) |
||
325 | return m_terrains[regionID]; |
||
326 | else |
||
327 | return null; |
||
328 | } |
||
329 | |||
330 | public double[,] LoadTerrain(UUID regionID) |
||
331 | { |
||
332 | if (m_terrains.ContainsKey(regionID)) |
||
333 | return m_terrains[regionID].GetDoubles(); |
||
334 | else |
||
335 | return null; |
||
336 | } |
||
337 | |||
338 | public void RemoveLandObject(UUID globalID) |
||
339 | { |
||
340 | if (m_landData.ContainsKey(globalID)) |
||
341 | m_landData.Remove(globalID); |
||
342 | } |
||
343 | |||
344 | public void StoreLandObject(ILandObject land) |
||
345 | { |
||
346 | m_landData[land.LandData.GlobalID] = land.LandData; |
||
347 | } |
||
348 | |||
349 | public List<LandData> LoadLandObjects(UUID regionUUID) |
||
350 | { |
||
351 | return new List<LandData>(m_landData.Values); |
||
352 | } |
||
353 | |||
354 | public void Shutdown() |
||
355 | { |
||
356 | } |
||
357 | |||
358 | public void SaveExtra(UUID regionID, string name, string value) |
||
359 | { |
||
360 | } |
||
361 | |||
362 | public void RemoveExtra(UUID regionID, string name) |
||
363 | { |
||
364 | } |
||
365 | |||
366 | public Dictionary<string, string> GetExtra(UUID regionID) |
||
367 | { |
||
368 | return null; |
||
369 | } |
||
370 | } |
||
371 | } |