diff options
Diffstat (limited to 'OpenSim/Data/MSSQL/MSSQLSimulationData.cs')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLSimulationData.cs | 1572 |
1 files changed, 1572 insertions, 0 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs new file mode 100644 index 0000000..ae105d5 --- /dev/null +++ b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs | |||
@@ -0,0 +1,1572 @@ | |||
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.Generic; | ||
30 | using System.Data; | ||
31 | using System.Data.SqlClient; | ||
32 | using System.Drawing; | ||
33 | using System.IO; | ||
34 | using System.Reflection; | ||
35 | using log4net; | ||
36 | using OpenMetaverse; | ||
37 | using OpenSim.Framework; | ||
38 | using OpenSim.Region.Framework.Interfaces; | ||
39 | using OpenSim.Region.Framework.Scenes; | ||
40 | |||
41 | namespace OpenSim.Data.MSSQL | ||
42 | { | ||
43 | /// <summary> | ||
44 | /// A MSSQL Interface for the Region Server. | ||
45 | /// </summary> | ||
46 | public class MSSQLSimulationData : ISimulationDataStore | ||
47 | { | ||
48 | private const string _migrationStore = "RegionStore"; | ||
49 | |||
50 | // private static FileSystemDataStore Instance = new FileSystemDataStore(); | ||
51 | private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | ||
52 | |||
53 | /// <summary> | ||
54 | /// The database manager | ||
55 | /// </summary> | ||
56 | private MSSQLManager _Database; | ||
57 | private string m_connectionString; | ||
58 | /// <summary> | ||
59 | /// Initialises the region datastore | ||
60 | /// </summary> | ||
61 | /// <param name="connectionString">The connection string.</param> | ||
62 | public void Initialise(string connectionString) | ||
63 | { | ||
64 | m_connectionString = connectionString; | ||
65 | _Database = new MSSQLManager(connectionString); | ||
66 | |||
67 | |||
68 | //Migration settings | ||
69 | _Database.CheckMigration(_migrationStore); | ||
70 | } | ||
71 | |||
72 | /// <summary> | ||
73 | /// Dispose the database | ||
74 | /// </summary> | ||
75 | public void Dispose() { } | ||
76 | |||
77 | #region SceneObjectGroup region for loading and Store of the scene. | ||
78 | |||
79 | /// <summary> | ||
80 | /// Loads the objects present in the region. | ||
81 | /// </summary> | ||
82 | /// <param name="regionUUID">The region UUID.</param> | ||
83 | /// <returns></returns> | ||
84 | public List<SceneObjectGroup> LoadObjects(UUID regionUUID) | ||
85 | { | ||
86 | UUID lastGroupID = UUID.Zero; | ||
87 | |||
88 | Dictionary<UUID, SceneObjectPart> prims = new Dictionary<UUID, SceneObjectPart>(); | ||
89 | Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>(); | ||
90 | SceneObjectGroup grp = null; | ||
91 | |||
92 | string sql = "SELECT *, " + | ||
93 | "sort = CASE WHEN prims.UUID = prims.SceneGroupID THEN 0 ELSE 1 END " + | ||
94 | "FROM prims " + | ||
95 | "LEFT JOIN primshapes ON prims.UUID = primshapes.UUID " + | ||
96 | "WHERE RegionUUID = @RegionUUID " + | ||
97 | "ORDER BY SceneGroupID asc, sort asc, LinkNumber asc"; | ||
98 | |||
99 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
100 | using (SqlCommand command = new SqlCommand(sql, conn)) | ||
101 | { | ||
102 | command.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID)); | ||
103 | conn.Open(); | ||
104 | using (SqlDataReader reader = command.ExecuteReader()) | ||
105 | { | ||
106 | while (reader.Read()) | ||
107 | { | ||
108 | SceneObjectPart sceneObjectPart = BuildPrim(reader); | ||
109 | if (reader["Shape"] is DBNull) | ||
110 | sceneObjectPart.Shape = PrimitiveBaseShape.Default; | ||
111 | else | ||
112 | sceneObjectPart.Shape = BuildShape(reader); | ||
113 | |||
114 | prims[sceneObjectPart.UUID] = sceneObjectPart; | ||
115 | |||
116 | UUID groupID = new UUID((Guid)reader["SceneGroupID"]); | ||
117 | |||
118 | if (groupID != lastGroupID) // New SOG | ||
119 | { | ||
120 | if (grp != null) | ||
121 | objects[grp.UUID] = grp; | ||
122 | |||
123 | lastGroupID = groupID; | ||
124 | |||
125 | // There sometimes exist OpenSim bugs that 'orphan groups' so that none of the prims are | ||
126 | // recorded as the root prim (for which the UUID must equal the persisted group UUID). In | ||
127 | // this case, force the UUID to be the same as the group UUID so that at least these can be | ||
128 | // deleted (we need to change the UUID so that any other prims in the linkset can also be | ||
129 | // deleted). | ||
130 | if (sceneObjectPart.UUID != groupID && groupID != UUID.Zero) | ||
131 | { | ||
132 | _Log.WarnFormat( | ||
133 | "[REGION DB]: Found root prim {0} {1} at {2} where group was actually {3}. Forcing UUID to group UUID", | ||
134 | sceneObjectPart.Name, sceneObjectPart.UUID, sceneObjectPart.GroupPosition, groupID); | ||
135 | |||
136 | sceneObjectPart.UUID = groupID; | ||
137 | } | ||
138 | |||
139 | grp = new SceneObjectGroup(sceneObjectPart); | ||
140 | } | ||
141 | else | ||
142 | { | ||
143 | // Black magic to preserve link numbers | ||
144 | // Why is this needed, fix this in AddPart method. | ||
145 | int link = sceneObjectPart.LinkNum; | ||
146 | |||
147 | grp.AddPart(sceneObjectPart); | ||
148 | |||
149 | if (link != 0) | ||
150 | sceneObjectPart.LinkNum = link; | ||
151 | } | ||
152 | } | ||
153 | } | ||
154 | } | ||
155 | |||
156 | if (grp != null) | ||
157 | objects[grp.UUID] = grp; | ||
158 | |||
159 | // Instead of attempting to LoadItems on every prim, | ||
160 | // most of which probably have no items... get a | ||
161 | // list from DB of all prims which have items and | ||
162 | // LoadItems only on those | ||
163 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); | ||
164 | string qry = "select distinct primID from primitems"; | ||
165 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
166 | using (SqlCommand command = new SqlCommand(qry, conn)) | ||
167 | { | ||
168 | conn.Open(); | ||
169 | using (SqlDataReader itemReader = command.ExecuteReader()) | ||
170 | { | ||
171 | while (itemReader.Read()) | ||
172 | { | ||
173 | if (!(itemReader["primID"] is DBNull)) | ||
174 | { | ||
175 | UUID primID = new UUID(itemReader["primID"].ToString()); | ||
176 | if (prims.ContainsKey(primID)) | ||
177 | { | ||
178 | primsWithInventory.Add(prims[primID]); | ||
179 | } | ||
180 | } | ||
181 | } | ||
182 | } | ||
183 | } | ||
184 | |||
185 | LoadItems(primsWithInventory); | ||
186 | |||
187 | _Log.DebugFormat("[REGION DB]: Loaded {0} objects using {1} prims", objects.Count, prims.Count); | ||
188 | |||
189 | return new List<SceneObjectGroup>(objects.Values); | ||
190 | } | ||
191 | |||
192 | /// <summary> | ||
193 | /// Load in the prim's persisted inventory. | ||
194 | /// </summary> | ||
195 | /// <param name="allPrims">all prims with inventory on a region</param> | ||
196 | private void LoadItems(List<SceneObjectPart> allPrimsWithInventory) | ||
197 | { | ||
198 | string sql = "SELECT * FROM primitems WHERE PrimID = @PrimID"; | ||
199 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
200 | using (SqlCommand command = new SqlCommand(sql, conn)) | ||
201 | { | ||
202 | conn.Open(); | ||
203 | foreach (SceneObjectPart objectPart in allPrimsWithInventory) | ||
204 | { | ||
205 | command.Parameters.Clear(); | ||
206 | command.Parameters.Add(_Database.CreateParameter("@PrimID", objectPart.UUID)); | ||
207 | |||
208 | List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); | ||
209 | |||
210 | using (SqlDataReader reader = command.ExecuteReader()) | ||
211 | { | ||
212 | while (reader.Read()) | ||
213 | { | ||
214 | TaskInventoryItem item = BuildItem(reader); | ||
215 | |||
216 | item.ParentID = objectPart.UUID; // Values in database are | ||
217 | // often wrong | ||
218 | inventory.Add(item); | ||
219 | } | ||
220 | } | ||
221 | |||
222 | objectPart.Inventory.RestoreInventoryItems(inventory); | ||
223 | } | ||
224 | } | ||
225 | } | ||
226 | |||
227 | /// <summary> | ||
228 | /// Stores all object's details apart from inventory | ||
229 | /// </summary> | ||
230 | /// <param name="obj"></param> | ||
231 | /// <param name="regionUUID"></param> | ||
232 | public void StoreObject(SceneObjectGroup obj, UUID regionUUID) | ||
233 | { | ||
234 | _Log.DebugFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count); | ||
235 | |||
236 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
237 | { | ||
238 | conn.Open(); | ||
239 | SqlTransaction transaction = conn.BeginTransaction(); | ||
240 | |||
241 | try | ||
242 | { | ||
243 | foreach (SceneObjectPart sceneObjectPart in obj.Children.Values) | ||
244 | { | ||
245 | //Update prim | ||
246 | using (SqlCommand sqlCommand = conn.CreateCommand()) | ||
247 | { | ||
248 | sqlCommand.Transaction = transaction; | ||
249 | try | ||
250 | { | ||
251 | StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); | ||
252 | } | ||
253 | catch (SqlException sqlEx) | ||
254 | { | ||
255 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber); | ||
256 | throw; | ||
257 | } | ||
258 | } | ||
259 | |||
260 | //Update primshapes | ||
261 | using (SqlCommand sqlCommand = conn.CreateCommand()) | ||
262 | { | ||
263 | sqlCommand.Transaction = transaction; | ||
264 | try | ||
265 | { | ||
266 | StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); | ||
267 | } | ||
268 | catch (SqlException sqlEx) | ||
269 | { | ||
270 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber); | ||
271 | throw; | ||
272 | } | ||
273 | } | ||
274 | } | ||
275 | |||
276 | transaction.Commit(); | ||
277 | } | ||
278 | catch (Exception ex) | ||
279 | { | ||
280 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectGroup error: {0}, Rolling back...", ex.Message); | ||
281 | try | ||
282 | { | ||
283 | transaction.Rollback(); | ||
284 | } | ||
285 | catch (Exception ex2) | ||
286 | { | ||
287 | //Show error | ||
288 | _Log.InfoFormat("[REGION DB]: Rollback of SceneObjectGroup store transaction failed with error: {0}", ex2.Message); | ||
289 | |||
290 | } | ||
291 | } | ||
292 | } | ||
293 | } | ||
294 | |||
295 | /// <summary> | ||
296 | /// Stores the prim of the sceneobjectpart. | ||
297 | /// </summary> | ||
298 | /// <param name="sceneObjectPart">The sceneobjectpart or prim.</param> | ||
299 | /// <param name="sqlCommand">The SQL command with the transaction.</param> | ||
300 | /// <param name="sceneGroupID">The scenegroup UUID.</param> | ||
301 | /// <param name="regionUUID">The region UUID.</param> | ||
302 | private void StoreSceneObjectPrim(SceneObjectPart sceneObjectPart, SqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) | ||
303 | { | ||
304 | //Big query to update or insert a new prim. | ||
305 | //Note for SQL Server 2008 this could be simplified | ||
306 | string queryPrims = @" | ||
307 | IF EXISTS (SELECT UUID FROM prims WHERE UUID = @UUID) | ||
308 | BEGIN | ||
309 | UPDATE prims SET | ||
310 | CreationDate = @CreationDate, Name = @Name, Text = @Text, Description = @Description, SitName = @SitName, | ||
311 | TouchName = @TouchName, ObjectFlags = @ObjectFlags, OwnerMask = @OwnerMask, NextOwnerMask = @NextOwnerMask, GroupMask = @GroupMask, | ||
312 | EveryoneMask = @EveryoneMask, BaseMask = @BaseMask, PositionX = @PositionX, PositionY = @PositionY, PositionZ = @PositionZ, | ||
313 | GroupPositionX = @GroupPositionX, GroupPositionY = @GroupPositionY, GroupPositionZ = @GroupPositionZ, VelocityX = @VelocityX, | ||
314 | VelocityY = @VelocityY, VelocityZ = @VelocityZ, AngularVelocityX = @AngularVelocityX, AngularVelocityY = @AngularVelocityY, | ||
315 | AngularVelocityZ = @AngularVelocityZ, AccelerationX = @AccelerationX, AccelerationY = @AccelerationY, | ||
316 | AccelerationZ = @AccelerationZ, RotationX = @RotationX, RotationY = @RotationY, RotationZ = @RotationZ, RotationW = @RotationW, | ||
317 | SitTargetOffsetX = @SitTargetOffsetX, SitTargetOffsetY = @SitTargetOffsetY, SitTargetOffsetZ = @SitTargetOffsetZ, | ||
318 | SitTargetOrientW = @SitTargetOrientW, SitTargetOrientX = @SitTargetOrientX, SitTargetOrientY = @SitTargetOrientY, | ||
319 | SitTargetOrientZ = @SitTargetOrientZ, RegionUUID = @RegionUUID, CreatorID = @CreatorID, OwnerID = @OwnerID, GroupID = @GroupID, | ||
320 | LastOwnerID = @LastOwnerID, SceneGroupID = @SceneGroupID, PayPrice = @PayPrice, PayButton1 = @PayButton1, PayButton2 = @PayButton2, | ||
321 | PayButton3 = @PayButton3, PayButton4 = @PayButton4, LoopedSound = @LoopedSound, LoopedSoundGain = @LoopedSoundGain, | ||
322 | TextureAnimation = @TextureAnimation, OmegaX = @OmegaX, OmegaY = @OmegaY, OmegaZ = @OmegaZ, CameraEyeOffsetX = @CameraEyeOffsetX, | ||
323 | CameraEyeOffsetY = @CameraEyeOffsetY, CameraEyeOffsetZ = @CameraEyeOffsetZ, CameraAtOffsetX = @CameraAtOffsetX, | ||
324 | CameraAtOffsetY = @CameraAtOffsetY, CameraAtOffsetZ = @CameraAtOffsetZ, ForceMouselook = @ForceMouselook, | ||
325 | ScriptAccessPin = @ScriptAccessPin, AllowedDrop = @AllowedDrop, DieAtEdge = @DieAtEdge, SalePrice = @SalePrice, | ||
326 | SaleType = @SaleType, ColorR = @ColorR, ColorG = @ColorG, ColorB = @ColorB, ColorA = @ColorA, ParticleSystem = @ParticleSystem, | ||
327 | ClickAction = @ClickAction, Material = @Material, CollisionSound = @CollisionSound, CollisionSoundVolume = @CollisionSoundVolume, PassTouches = @PassTouches, | ||
328 | LinkNumber = @LinkNumber, MediaURL = @MediaURL | ||
329 | WHERE UUID = @UUID | ||
330 | END | ||
331 | ELSE | ||
332 | BEGIN | ||
333 | INSERT INTO | ||
334 | prims ( | ||
335 | UUID, CreationDate, Name, Text, Description, SitName, TouchName, ObjectFlags, OwnerMask, NextOwnerMask, GroupMask, | ||
336 | EveryoneMask, BaseMask, PositionX, PositionY, PositionZ, GroupPositionX, GroupPositionY, GroupPositionZ, VelocityX, | ||
337 | VelocityY, VelocityZ, AngularVelocityX, AngularVelocityY, AngularVelocityZ, AccelerationX, AccelerationY, AccelerationZ, | ||
338 | RotationX, RotationY, RotationZ, RotationW, SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ, SitTargetOrientW, | ||
339 | SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ, RegionUUID, CreatorID, OwnerID, GroupID, LastOwnerID, SceneGroupID, | ||
340 | PayPrice, PayButton1, PayButton2, PayButton3, PayButton4, LoopedSound, LoopedSoundGain, TextureAnimation, OmegaX, | ||
341 | OmegaY, OmegaZ, CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ, CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ, | ||
342 | ForceMouselook, ScriptAccessPin, AllowedDrop, DieAtEdge, SalePrice, SaleType, ColorR, ColorG, ColorB, ColorA, | ||
343 | ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber, MediaURL | ||
344 | ) VALUES ( | ||
345 | @UUID, @CreationDate, @Name, @Text, @Description, @SitName, @TouchName, @ObjectFlags, @OwnerMask, @NextOwnerMask, @GroupMask, | ||
346 | @EveryoneMask, @BaseMask, @PositionX, @PositionY, @PositionZ, @GroupPositionX, @GroupPositionY, @GroupPositionZ, @VelocityX, | ||
347 | @VelocityY, @VelocityZ, @AngularVelocityX, @AngularVelocityY, @AngularVelocityZ, @AccelerationX, @AccelerationY, @AccelerationZ, | ||
348 | @RotationX, @RotationY, @RotationZ, @RotationW, @SitTargetOffsetX, @SitTargetOffsetY, @SitTargetOffsetZ, @SitTargetOrientW, | ||
349 | @SitTargetOrientX, @SitTargetOrientY, @SitTargetOrientZ, @RegionUUID, @CreatorID, @OwnerID, @GroupID, @LastOwnerID, @SceneGroupID, | ||
350 | @PayPrice, @PayButton1, @PayButton2, @PayButton3, @PayButton4, @LoopedSound, @LoopedSoundGain, @TextureAnimation, @OmegaX, | ||
351 | @OmegaY, @OmegaZ, @CameraEyeOffsetX, @CameraEyeOffsetY, @CameraEyeOffsetZ, @CameraAtOffsetX, @CameraAtOffsetY, @CameraAtOffsetZ, | ||
352 | @ForceMouselook, @ScriptAccessPin, @AllowedDrop, @DieAtEdge, @SalePrice, @SaleType, @ColorR, @ColorG, @ColorB, @ColorA, | ||
353 | @ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber, @MediaURL | ||
354 | ) | ||
355 | END"; | ||
356 | |||
357 | //Set commandtext. | ||
358 | sqlCommand.CommandText = queryPrims; | ||
359 | //Add parameters | ||
360 | sqlCommand.Parameters.AddRange(CreatePrimParameters(sceneObjectPart, sceneGroupID, regionUUID)); | ||
361 | |||
362 | //Execute the query. If it fails then error is trapped in calling function | ||
363 | sqlCommand.ExecuteNonQuery(); | ||
364 | } | ||
365 | |||
366 | /// <summary> | ||
367 | /// Stores the scene object prim shapes. | ||
368 | /// </summary> | ||
369 | /// <param name="sceneObjectPart">The sceneobjectpart containing prim shape.</param> | ||
370 | /// <param name="sqlCommand">The SQL command with the transaction.</param> | ||
371 | /// <param name="sceneGroupID">The scenegroup UUID.</param> | ||
372 | /// <param name="regionUUID">The region UUID.</param> | ||
373 | private void StoreSceneObjectPrimShapes(SceneObjectPart sceneObjectPart, SqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) | ||
374 | { | ||
375 | //Big query to or insert or update primshapes | ||
376 | //Note for SQL Server 2008 this can be simplified | ||
377 | string queryPrimShapes = @" | ||
378 | IF EXISTS (SELECT UUID FROM primshapes WHERE UUID = @UUID) | ||
379 | BEGIN | ||
380 | UPDATE primshapes SET | ||
381 | Shape = @Shape, ScaleX = @ScaleX, ScaleY = @ScaleY, ScaleZ = @ScaleZ, PCode = @PCode, PathBegin = @PathBegin, | ||
382 | PathEnd = @PathEnd, PathScaleX = @PathScaleX, PathScaleY = @PathScaleY, PathShearX = @PathShearX, PathShearY = @PathShearY, | ||
383 | PathSkew = @PathSkew, PathCurve = @PathCurve, PathRadiusOffset = @PathRadiusOffset, PathRevolutions = @PathRevolutions, | ||
384 | PathTaperX = @PathTaperX, PathTaperY = @PathTaperY, PathTwist = @PathTwist, PathTwistBegin = @PathTwistBegin, | ||
385 | ProfileBegin = @ProfileBegin, ProfileEnd = @ProfileEnd, ProfileCurve = @ProfileCurve, ProfileHollow = @ProfileHollow, | ||
386 | Texture = @Texture, ExtraParams = @ExtraParams, State = @State, Media = @Media | ||
387 | WHERE UUID = @UUID | ||
388 | END | ||
389 | ELSE | ||
390 | BEGIN | ||
391 | INSERT INTO | ||
392 | primshapes ( | ||
393 | UUID, Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, | ||
394 | PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, | ||
395 | ProfileEnd, ProfileCurve, ProfileHollow, Texture, ExtraParams, State, Media | ||
396 | ) VALUES ( | ||
397 | @UUID, @Shape, @ScaleX, @ScaleY, @ScaleZ, @PCode, @PathBegin, @PathEnd, @PathScaleX, @PathScaleY, @PathShearX, @PathShearY, | ||
398 | @PathSkew, @PathCurve, @PathRadiusOffset, @PathRevolutions, @PathTaperX, @PathTaperY, @PathTwist, @PathTwistBegin, @ProfileBegin, | ||
399 | @ProfileEnd, @ProfileCurve, @ProfileHollow, @Texture, @ExtraParams, @State, @Media | ||
400 | ) | ||
401 | END"; | ||
402 | |||
403 | //Set commandtext. | ||
404 | sqlCommand.CommandText = queryPrimShapes; | ||
405 | |||
406 | //Add parameters | ||
407 | sqlCommand.Parameters.AddRange(CreatePrimShapeParameters(sceneObjectPart, sceneGroupID, regionUUID)); | ||
408 | |||
409 | //Execute the query. If it fails then error is trapped in calling function | ||
410 | sqlCommand.ExecuteNonQuery(); | ||
411 | |||
412 | } | ||
413 | |||
414 | /// <summary> | ||
415 | /// Removes a object from the database. | ||
416 | /// Meaning removing it from tables Prims, PrimShapes and PrimItems | ||
417 | /// </summary> | ||
418 | /// <param name="objectID">id of scenegroup</param> | ||
419 | /// <param name="regionUUID">regionUUID (is this used anyway</param> | ||
420 | public void RemoveObject(UUID objectID, UUID regionUUID) | ||
421 | { | ||
422 | _Log.InfoFormat("[MSSQL]: Removing obj: {0} from region: {1}", objectID, regionUUID); | ||
423 | |||
424 | //Remove from prims and primsitem table | ||
425 | string sqlPrims = "DELETE FROM PRIMS WHERE SceneGroupID = @objectID"; | ||
426 | string sqlPrimItems = "DELETE FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE SceneGroupID = @objectID)"; | ||
427 | string sqlPrimShapes = "DELETE FROM PRIMSHAPES WHERE uuid in (SELECT UUID FROM PRIMS WHERE SceneGroupID = @objectID)"; | ||
428 | |||
429 | lock (_Database) | ||
430 | { | ||
431 | //Using the non transaction mode. | ||
432 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
433 | using (SqlCommand cmd = new SqlCommand()) | ||
434 | { | ||
435 | cmd.Connection = conn; | ||
436 | cmd.CommandText = sqlPrimShapes; | ||
437 | conn.Open(); | ||
438 | cmd.Parameters.Add(_Database.CreateParameter("objectID", objectID)); | ||
439 | cmd.ExecuteNonQuery(); | ||
440 | |||
441 | cmd.CommandText = sqlPrimItems; | ||
442 | cmd.ExecuteNonQuery(); | ||
443 | |||
444 | cmd.CommandText = sqlPrims; | ||
445 | cmd.ExecuteNonQuery(); | ||
446 | } | ||
447 | } | ||
448 | } | ||
449 | |||
450 | /// <summary> | ||
451 | /// Store the inventory of a prim. Warning deletes everything first and then adds all again. | ||
452 | /// </summary> | ||
453 | /// <param name="primID"></param> | ||
454 | /// <param name="items"></param> | ||
455 | public void StorePrimInventory(UUID primID, ICollection<TaskInventoryItem> items) | ||
456 | { | ||
457 | //_Log.InfoFormat("[REGION DB: Persisting Prim Inventory with prim ID {0}", primID); | ||
458 | |||
459 | //Statement from MySQL section! | ||
460 | // For now, we're just going to crudely remove all the previous inventory items | ||
461 | // no matter whether they have changed or not, and replace them with the current set. | ||
462 | |||
463 | //Delete everything from PrimID | ||
464 | //TODO add index on PrimID in DB, if not already exist | ||
465 | |||
466 | string sql = "DELETE PRIMITEMS WHERE primID = @primID"; | ||
467 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
468 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
469 | { | ||
470 | cmd.Parameters.Add(_Database.CreateParameter("@primID", primID)); | ||
471 | conn.Open(); | ||
472 | cmd.ExecuteNonQuery(); | ||
473 | } | ||
474 | |||
475 | sql = | ||
476 | @"INSERT INTO primitems ( | ||
477 | itemID,primID,assetID,parentFolderID,invType,assetType,name,description,creationDate,creatorID,ownerID,lastOwnerID,groupID, | ||
478 | nextPermissions,currentPermissions,basePermissions,everyonePermissions,groupPermissions,flags) | ||
479 | VALUES (@itemID,@primID,@assetID,@parentFolderID,@invType,@assetType,@name,@description,@creationDate,@creatorID,@ownerID, | ||
480 | @lastOwnerID,@groupID,@nextPermissions,@currentPermissions,@basePermissions,@everyonePermissions,@groupPermissions,@flags)"; | ||
481 | |||
482 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
483 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
484 | { | ||
485 | foreach (TaskInventoryItem taskItem in items) | ||
486 | { | ||
487 | cmd.Parameters.AddRange(CreatePrimInventoryParameters(taskItem)); | ||
488 | conn.Open(); | ||
489 | cmd.ExecuteNonQuery(); | ||
490 | |||
491 | cmd.Parameters.Clear(); | ||
492 | } | ||
493 | } | ||
494 | } | ||
495 | |||
496 | #endregion | ||
497 | |||
498 | /// <summary> | ||
499 | /// Loads the terrain map. | ||
500 | /// </summary> | ||
501 | /// <param name="regionID">regionID.</param> | ||
502 | /// <returns></returns> | ||
503 | public double[,] LoadTerrain(UUID regionID) | ||
504 | { | ||
505 | double[,] terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; | ||
506 | terrain.Initialize(); | ||
507 | |||
508 | string sql = "select top 1 RegionUUID, Revision, Heightfield from terrain where RegionUUID = @RegionUUID order by Revision desc"; | ||
509 | |||
510 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
511 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
512 | { | ||
513 | // MySqlParameter param = new MySqlParameter(); | ||
514 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | ||
515 | conn.Open(); | ||
516 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
517 | { | ||
518 | int rev; | ||
519 | if (reader.Read()) | ||
520 | { | ||
521 | MemoryStream str = new MemoryStream((byte[])reader["Heightfield"]); | ||
522 | BinaryReader br = new BinaryReader(str); | ||
523 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
524 | { | ||
525 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
526 | { | ||
527 | terrain[x, y] = br.ReadDouble(); | ||
528 | } | ||
529 | } | ||
530 | rev = (int)reader["Revision"]; | ||
531 | } | ||
532 | else | ||
533 | { | ||
534 | _Log.Info("[REGION DB]: No terrain found for region"); | ||
535 | return null; | ||
536 | } | ||
537 | _Log.Info("[REGION DB]: Loaded terrain revision r" + rev); | ||
538 | } | ||
539 | } | ||
540 | |||
541 | return terrain; | ||
542 | } | ||
543 | |||
544 | /// <summary> | ||
545 | /// Stores the terrain map to DB. | ||
546 | /// </summary> | ||
547 | /// <param name="terrain">terrain map data.</param> | ||
548 | /// <param name="regionID">regionID.</param> | ||
549 | public void StoreTerrain(double[,] terrain, UUID regionID) | ||
550 | { | ||
551 | int revision = Util.UnixTimeSinceEpoch(); | ||
552 | |||
553 | //Delete old terrain map | ||
554 | string sql = "delete from terrain where RegionUUID=@RegionUUID"; | ||
555 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
556 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
557 | { | ||
558 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | ||
559 | conn.Open(); | ||
560 | cmd.ExecuteNonQuery(); | ||
561 | } | ||
562 | |||
563 | sql = "insert into terrain(RegionUUID, Revision, Heightfield) values(@RegionUUID, @Revision, @Heightfield)"; | ||
564 | |||
565 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
566 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
567 | { | ||
568 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | ||
569 | cmd.Parameters.Add(_Database.CreateParameter("@Revision", revision)); | ||
570 | cmd.Parameters.Add(_Database.CreateParameter("@Heightfield", serializeTerrain(terrain))); | ||
571 | conn.Open(); | ||
572 | cmd.ExecuteNonQuery(); | ||
573 | } | ||
574 | |||
575 | _Log.Info("[REGION DB]: Stored terrain revision r " + revision); | ||
576 | } | ||
577 | |||
578 | /// <summary> | ||
579 | /// Loads all the land objects of a region. | ||
580 | /// </summary> | ||
581 | /// <param name="regionUUID">The region UUID.</param> | ||
582 | /// <returns></returns> | ||
583 | public List<LandData> LoadLandObjects(UUID regionUUID) | ||
584 | { | ||
585 | List<LandData> LandDataForRegion = new List<LandData>(); | ||
586 | |||
587 | string sql = "select * from land where RegionUUID = @RegionUUID"; | ||
588 | |||
589 | //Retrieve all land data from region | ||
590 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
591 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
592 | { | ||
593 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionUUID)); | ||
594 | conn.Open(); | ||
595 | using (SqlDataReader readerLandData = cmd.ExecuteReader()) | ||
596 | { | ||
597 | while (readerLandData.Read()) | ||
598 | { | ||
599 | LandDataForRegion.Add(BuildLandData(readerLandData)); | ||
600 | } | ||
601 | } | ||
602 | } | ||
603 | |||
604 | //Retrieve all accesslist data for all landdata | ||
605 | foreach (LandData LandData in LandDataForRegion) | ||
606 | { | ||
607 | sql = "select * from landaccesslist where LandUUID = @LandUUID"; | ||
608 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
609 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
610 | { | ||
611 | cmd.Parameters.Add(_Database.CreateParameter("@LandUUID", LandData.GlobalID)); | ||
612 | conn.Open(); | ||
613 | using (SqlDataReader readerAccessList = cmd.ExecuteReader()) | ||
614 | { | ||
615 | while (readerAccessList.Read()) | ||
616 | { | ||
617 | LandData.ParcelAccessList.Add(BuildLandAccessData(readerAccessList)); | ||
618 | } | ||
619 | } | ||
620 | } | ||
621 | } | ||
622 | |||
623 | //Return data | ||
624 | return LandDataForRegion; | ||
625 | } | ||
626 | |||
627 | /// <summary> | ||
628 | /// Stores land object with landaccess list. | ||
629 | /// </summary> | ||
630 | /// <param name="parcel">parcel data.</param> | ||
631 | public void StoreLandObject(ILandObject parcel) | ||
632 | { | ||
633 | //As this is only one record in land table I just delete all and then add a new record. | ||
634 | //As the delete landaccess is already in the mysql code | ||
635 | |||
636 | //Delete old values | ||
637 | RemoveLandObject(parcel.LandData.GlobalID); | ||
638 | |||
639 | //Insert new values | ||
640 | string sql = @"INSERT INTO [land] | ||
641 | ([UUID],[RegionUUID],[LocalLandID],[Bitmap],[Name],[Description],[OwnerUUID],[IsGroupOwned],[Area],[AuctionID],[Category],[ClaimDate],[ClaimPrice],[GroupUUID],[SalePrice],[LandStatus],[LandFlags],[LandingType],[MediaAutoScale],[MediaTextureUUID],[MediaURL],[MusicURL],[PassHours],[PassPrice],[SnapshotUUID],[UserLocationX],[UserLocationY],[UserLocationZ],[UserLookAtX],[UserLookAtY],[UserLookAtZ],[AuthbuyerID],[OtherCleanTime]) | ||
642 | VALUES | ||
643 | (@UUID,@RegionUUID,@LocalLandID,@Bitmap,@Name,@Description,@OwnerUUID,@IsGroupOwned,@Area,@AuctionID,@Category,@ClaimDate,@ClaimPrice,@GroupUUID,@SalePrice,@LandStatus,@LandFlags,@LandingType,@MediaAutoScale,@MediaTextureUUID,@MediaURL,@MusicURL,@PassHours,@PassPrice,@SnapshotUUID,@UserLocationX,@UserLocationY,@UserLocationZ,@UserLookAtX,@UserLookAtY,@UserLookAtZ,@AuthbuyerID,@OtherCleanTime)"; | ||
644 | |||
645 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
646 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
647 | { | ||
648 | cmd.Parameters.AddRange(CreateLandParameters(parcel.LandData, parcel.RegionUUID)); | ||
649 | conn.Open(); | ||
650 | cmd.ExecuteNonQuery(); | ||
651 | } | ||
652 | |||
653 | sql = "INSERT INTO [landaccesslist] ([LandUUID],[AccessUUID],[Flags]) VALUES (@LandUUID,@AccessUUID,@Flags)"; | ||
654 | |||
655 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
656 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
657 | { | ||
658 | conn.Open(); | ||
659 | foreach (ParcelManager.ParcelAccessEntry parcelAccessEntry in parcel.LandData.ParcelAccessList) | ||
660 | { | ||
661 | cmd.Parameters.AddRange(CreateLandAccessParameters(parcelAccessEntry, parcel.RegionUUID)); | ||
662 | |||
663 | cmd.ExecuteNonQuery(); | ||
664 | cmd.Parameters.Clear(); | ||
665 | } | ||
666 | } | ||
667 | } | ||
668 | |||
669 | /// <summary> | ||
670 | /// Removes a land object from DB. | ||
671 | /// </summary> | ||
672 | /// <param name="globalID">UUID of landobject</param> | ||
673 | public void RemoveLandObject(UUID globalID) | ||
674 | { | ||
675 | string sql = "delete from land where UUID=@UUID"; | ||
676 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
677 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
678 | { | ||
679 | cmd.Parameters.Add(_Database.CreateParameter("@UUID", globalID)); | ||
680 | conn.Open(); | ||
681 | cmd.ExecuteNonQuery(); | ||
682 | } | ||
683 | sql = "delete from landaccesslist where LandUUID=@UUID"; | ||
684 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
685 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
686 | { | ||
687 | cmd.Parameters.Add(_Database.CreateParameter("@UUID", globalID)); | ||
688 | conn.Open(); | ||
689 | cmd.ExecuteNonQuery(); | ||
690 | } | ||
691 | } | ||
692 | public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) | ||
693 | { | ||
694 | //This connector doesn't support the windlight module yet | ||
695 | //Return default LL windlight settings | ||
696 | return new RegionLightShareData(); | ||
697 | } | ||
698 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | ||
699 | { | ||
700 | //This connector doesn't support the windlight module yet | ||
701 | } | ||
702 | /// <summary> | ||
703 | /// Loads the settings of a region. | ||
704 | /// </summary> | ||
705 | /// <param name="regionUUID">The region UUID.</param> | ||
706 | /// <returns></returns> | ||
707 | public RegionSettings LoadRegionSettings(UUID regionUUID) | ||
708 | { | ||
709 | string sql = "select * from regionsettings where regionUUID = @regionUUID"; | ||
710 | RegionSettings regionSettings; | ||
711 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
712 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
713 | { | ||
714 | cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID)); | ||
715 | conn.Open(); | ||
716 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
717 | { | ||
718 | if (reader.Read()) | ||
719 | { | ||
720 | regionSettings = BuildRegionSettings(reader); | ||
721 | regionSettings.OnSave += StoreRegionSettings; | ||
722 | |||
723 | return regionSettings; | ||
724 | } | ||
725 | } | ||
726 | } | ||
727 | |||
728 | //If we reach this point then there are new region settings for that region | ||
729 | regionSettings = new RegionSettings(); | ||
730 | regionSettings.RegionUUID = regionUUID; | ||
731 | regionSettings.OnSave += StoreRegionSettings; | ||
732 | |||
733 | //Store new values | ||
734 | StoreNewRegionSettings(regionSettings); | ||
735 | |||
736 | return regionSettings; | ||
737 | } | ||
738 | |||
739 | /// <summary> | ||
740 | /// Store region settings, need to check if the check is really necesary. If we can make something for creating new region. | ||
741 | /// </summary> | ||
742 | /// <param name="regionSettings">region settings.</param> | ||
743 | public void StoreRegionSettings(RegionSettings regionSettings) | ||
744 | { | ||
745 | //Little check if regionUUID already exist in DB | ||
746 | string regionUUID; | ||
747 | string sql = "SELECT regionUUID FROM regionsettings WHERE regionUUID = @regionUUID"; | ||
748 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
749 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
750 | { | ||
751 | cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionSettings.RegionUUID)); | ||
752 | conn.Open(); | ||
753 | regionUUID = cmd.ExecuteScalar().ToString(); | ||
754 | } | ||
755 | |||
756 | if (string.IsNullOrEmpty(regionUUID)) | ||
757 | { | ||
758 | StoreNewRegionSettings(regionSettings); | ||
759 | } | ||
760 | else | ||
761 | { | ||
762 | //This method only updates region settings!!! First call LoadRegionSettings to create new region settings in DB | ||
763 | sql = | ||
764 | @"UPDATE [regionsettings] SET [block_terraform] = @block_terraform ,[block_fly] = @block_fly ,[allow_damage] = @allow_damage | ||
765 | ,[restrict_pushing] = @restrict_pushing ,[allow_land_resell] = @allow_land_resell ,[allow_land_join_divide] = @allow_land_join_divide | ||
766 | ,[block_show_in_search] = @block_show_in_search ,[agent_limit] = @agent_limit ,[object_bonus] = @object_bonus ,[maturity] = @maturity | ||
767 | ,[disable_scripts] = @disable_scripts ,[disable_collisions] = @disable_collisions ,[disable_physics] = @disable_physics | ||
768 | ,[terrain_texture_1] = @terrain_texture_1 ,[terrain_texture_2] = @terrain_texture_2 ,[terrain_texture_3] = @terrain_texture_3 | ||
769 | ,[terrain_texture_4] = @terrain_texture_4 ,[elevation_1_nw] = @elevation_1_nw ,[elevation_2_nw] = @elevation_2_nw | ||
770 | ,[elevation_1_ne] = @elevation_1_ne ,[elevation_2_ne] = @elevation_2_ne ,[elevation_1_se] = @elevation_1_se ,[elevation_2_se] = @elevation_2_se | ||
771 | ,[elevation_1_sw] = @elevation_1_sw ,[elevation_2_sw] = @elevation_2_sw ,[water_height] = @water_height ,[terrain_raise_limit] = @terrain_raise_limit | ||
772 | ,[terrain_lower_limit] = @terrain_lower_limit ,[use_estate_sun] = @use_estate_sun ,[fixed_sun] = @fixed_sun ,[sun_position] = @sun_position | ||
773 | ,[covenant] = @covenant , [sunvectorx] = @sunvectorx, [sunvectory] = @sunvectory, [sunvectorz] = @sunvectorz, [Sandbox] = @Sandbox, [loaded_creation_datetime] = @loaded_creation_datetime, [loaded_creation_id] = @loaded_creation_id | ||
774 | WHERE [regionUUID] = @regionUUID"; | ||
775 | |||
776 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
777 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
778 | { | ||
779 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); | ||
780 | conn.Open(); | ||
781 | cmd.ExecuteNonQuery(); | ||
782 | } | ||
783 | } | ||
784 | } | ||
785 | |||
786 | public void Shutdown() | ||
787 | { | ||
788 | //Not used?? | ||
789 | } | ||
790 | |||
791 | #region Private Methods | ||
792 | |||
793 | /// <summary> | ||
794 | /// Serializes the terrain data for storage in DB. | ||
795 | /// </summary> | ||
796 | /// <param name="val">terrain data</param> | ||
797 | /// <returns></returns> | ||
798 | private static Array serializeTerrain(double[,] val) | ||
799 | { | ||
800 | MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) * sizeof(double)); | ||
801 | BinaryWriter bw = new BinaryWriter(str); | ||
802 | |||
803 | // TODO: COMPATIBILITY - Add byte-order conversions | ||
804 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
805 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
806 | { | ||
807 | double height = val[x, y]; | ||
808 | if (height == 0.0) | ||
809 | height = double.Epsilon; | ||
810 | |||
811 | bw.Write(height); | ||
812 | } | ||
813 | |||
814 | return str.ToArray(); | ||
815 | } | ||
816 | |||
817 | /// <summary> | ||
818 | /// Stores new regionsettings. | ||
819 | /// </summary> | ||
820 | /// <param name="regionSettings">The region settings.</param> | ||
821 | private void StoreNewRegionSettings(RegionSettings regionSettings) | ||
822 | { | ||
823 | string sql = @"INSERT INTO [regionsettings] | ||
824 | ([regionUUID],[block_terraform],[block_fly],[allow_damage],[restrict_pushing],[allow_land_resell],[allow_land_join_divide], | ||
825 | [block_show_in_search],[agent_limit],[object_bonus],[maturity],[disable_scripts],[disable_collisions],[disable_physics], | ||
826 | [terrain_texture_1],[terrain_texture_2],[terrain_texture_3],[terrain_texture_4],[elevation_1_nw],[elevation_2_nw],[elevation_1_ne], | ||
827 | [elevation_2_ne],[elevation_1_se],[elevation_2_se],[elevation_1_sw],[elevation_2_sw],[water_height],[terrain_raise_limit], | ||
828 | [terrain_lower_limit],[use_estate_sun],[fixed_sun],[sun_position],[covenant],[sunvectorx], [sunvectory], [sunvectorz],[Sandbox], [loaded_creation_datetime], [loaded_creation_id] | ||
829 | ) | ||
830 | VALUES | ||
831 | (@regionUUID,@block_terraform,@block_fly,@allow_damage,@restrict_pushing,@allow_land_resell,@allow_land_join_divide, | ||
832 | @block_show_in_search,@agent_limit,@object_bonus,@maturity,@disable_scripts,@disable_collisions,@disable_physics, | ||
833 | @terrain_texture_1,@terrain_texture_2,@terrain_texture_3,@terrain_texture_4,@elevation_1_nw,@elevation_2_nw,@elevation_1_ne, | ||
834 | @elevation_2_ne,@elevation_1_se,@elevation_2_se,@elevation_1_sw,@elevation_2_sw,@water_height,@terrain_raise_limit, | ||
835 | @terrain_lower_limit,@use_estate_sun,@fixed_sun,@sun_position,@covenant,@sunvectorx,@sunvectory, @sunvectorz, @Sandbox, @loaded_creation_datetime, @loaded_creation_id)"; | ||
836 | |||
837 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
838 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
839 | { | ||
840 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); | ||
841 | conn.Open(); | ||
842 | cmd.ExecuteNonQuery(); | ||
843 | } | ||
844 | } | ||
845 | |||
846 | #region Private DataRecord conversion methods | ||
847 | |||
848 | /// <summary> | ||
849 | /// Builds the region settings from a datarecod. | ||
850 | /// </summary> | ||
851 | /// <param name="row">datarecord with regionsettings.</param> | ||
852 | /// <returns></returns> | ||
853 | private static RegionSettings BuildRegionSettings(IDataRecord row) | ||
854 | { | ||
855 | //TODO change this is some more generic code so we doesnt have to change it every time a new field is added? | ||
856 | RegionSettings newSettings = new RegionSettings(); | ||
857 | |||
858 | newSettings.RegionUUID = new UUID((Guid)row["regionUUID"]); | ||
859 | newSettings.BlockTerraform = Convert.ToBoolean(row["block_terraform"]); | ||
860 | newSettings.AllowDamage = Convert.ToBoolean(row["allow_damage"]); | ||
861 | newSettings.BlockFly = Convert.ToBoolean(row["block_fly"]); | ||
862 | newSettings.RestrictPushing = Convert.ToBoolean(row["restrict_pushing"]); | ||
863 | newSettings.AllowLandResell = Convert.ToBoolean(row["allow_land_resell"]); | ||
864 | newSettings.AllowLandJoinDivide = Convert.ToBoolean(row["allow_land_join_divide"]); | ||
865 | newSettings.BlockShowInSearch = Convert.ToBoolean(row["block_show_in_search"]); | ||
866 | newSettings.AgentLimit = Convert.ToInt32(row["agent_limit"]); | ||
867 | newSettings.ObjectBonus = Convert.ToDouble(row["object_bonus"]); | ||
868 | newSettings.Maturity = Convert.ToInt32(row["maturity"]); | ||
869 | newSettings.DisableScripts = Convert.ToBoolean(row["disable_scripts"]); | ||
870 | newSettings.DisableCollisions = Convert.ToBoolean(row["disable_collisions"]); | ||
871 | newSettings.DisablePhysics = Convert.ToBoolean(row["disable_physics"]); | ||
872 | newSettings.TerrainTexture1 = new UUID((Guid)row["terrain_texture_1"]); | ||
873 | newSettings.TerrainTexture2 = new UUID((Guid)row["terrain_texture_2"]); | ||
874 | newSettings.TerrainTexture3 = new UUID((Guid)row["terrain_texture_3"]); | ||
875 | newSettings.TerrainTexture4 = new UUID((Guid)row["terrain_texture_4"]); | ||
876 | newSettings.Elevation1NW = Convert.ToDouble(row["elevation_1_nw"]); | ||
877 | newSettings.Elevation2NW = Convert.ToDouble(row["elevation_2_nw"]); | ||
878 | newSettings.Elevation1NE = Convert.ToDouble(row["elevation_1_ne"]); | ||
879 | newSettings.Elevation2NE = Convert.ToDouble(row["elevation_2_ne"]); | ||
880 | newSettings.Elevation1SE = Convert.ToDouble(row["elevation_1_se"]); | ||
881 | newSettings.Elevation2SE = Convert.ToDouble(row["elevation_2_se"]); | ||
882 | newSettings.Elevation1SW = Convert.ToDouble(row["elevation_1_sw"]); | ||
883 | newSettings.Elevation2SW = Convert.ToDouble(row["elevation_2_sw"]); | ||
884 | newSettings.WaterHeight = Convert.ToDouble(row["water_height"]); | ||
885 | newSettings.TerrainRaiseLimit = Convert.ToDouble(row["terrain_raise_limit"]); | ||
886 | newSettings.TerrainLowerLimit = Convert.ToDouble(row["terrain_lower_limit"]); | ||
887 | newSettings.UseEstateSun = Convert.ToBoolean(row["use_estate_sun"]); | ||
888 | newSettings.Sandbox = Convert.ToBoolean(row["sandbox"]); | ||
889 | newSettings.FixedSun = Convert.ToBoolean(row["fixed_sun"]); | ||
890 | newSettings.SunPosition = Convert.ToDouble(row["sun_position"]); | ||
891 | newSettings.SunVector = new Vector3( | ||
892 | Convert.ToSingle(row["sunvectorx"]), | ||
893 | Convert.ToSingle(row["sunvectory"]), | ||
894 | Convert.ToSingle(row["sunvectorz"]) | ||
895 | ); | ||
896 | newSettings.Covenant = new UUID((Guid)row["covenant"]); | ||
897 | |||
898 | newSettings.LoadedCreationDateTime = Convert.ToInt32(row["loaded_creation_datetime"]); | ||
899 | |||
900 | if (row["loaded_creation_id"] is DBNull) | ||
901 | newSettings.LoadedCreationID = ""; | ||
902 | else | ||
903 | newSettings.LoadedCreationID = (String)row["loaded_creation_id"]; | ||
904 | return newSettings; | ||
905 | } | ||
906 | |||
907 | /// <summary> | ||
908 | /// Builds the land data from a datarecord. | ||
909 | /// </summary> | ||
910 | /// <param name="row">datarecord with land data</param> | ||
911 | /// <returns></returns> | ||
912 | private static LandData BuildLandData(IDataRecord row) | ||
913 | { | ||
914 | LandData newData = new LandData(); | ||
915 | |||
916 | newData.GlobalID = new UUID((Guid)row["UUID"]); | ||
917 | newData.LocalID = Convert.ToInt32(row["LocalLandID"]); | ||
918 | |||
919 | // Bitmap is a byte[512] | ||
920 | newData.Bitmap = (Byte[])row["Bitmap"]; | ||
921 | |||
922 | newData.Name = (string)row["Name"]; | ||
923 | newData.Description = (string)row["Description"]; | ||
924 | newData.OwnerID = new UUID((Guid)row["OwnerUUID"]); | ||
925 | newData.IsGroupOwned = Convert.ToBoolean(row["IsGroupOwned"]); | ||
926 | newData.Area = Convert.ToInt32(row["Area"]); | ||
927 | newData.AuctionID = Convert.ToUInt32(row["AuctionID"]); //Unemplemented | ||
928 | newData.Category = (ParcelCategory)Convert.ToInt32(row["Category"]); | ||
929 | //Enum libsecondlife.Parcel.ParcelCategory | ||
930 | newData.ClaimDate = Convert.ToInt32(row["ClaimDate"]); | ||
931 | newData.ClaimPrice = Convert.ToInt32(row["ClaimPrice"]); | ||
932 | newData.GroupID = new UUID((Guid)row["GroupUUID"]); | ||
933 | newData.SalePrice = Convert.ToInt32(row["SalePrice"]); | ||
934 | newData.Status = (ParcelStatus)Convert.ToInt32(row["LandStatus"]); | ||
935 | //Enum. libsecondlife.Parcel.ParcelStatus | ||
936 | newData.Flags = Convert.ToUInt32(row["LandFlags"]); | ||
937 | newData.LandingType = Convert.ToByte(row["LandingType"]); | ||
938 | newData.MediaAutoScale = Convert.ToByte(row["MediaAutoScale"]); | ||
939 | newData.MediaID = new UUID((Guid)row["MediaTextureUUID"]); | ||
940 | newData.MediaURL = (string)row["MediaURL"]; | ||
941 | newData.MusicURL = (string)row["MusicURL"]; | ||
942 | newData.PassHours = Convert.ToSingle(row["PassHours"]); | ||
943 | newData.PassPrice = Convert.ToInt32(row["PassPrice"]); | ||
944 | |||
945 | // UUID authedbuyer; | ||
946 | // UUID snapshotID; | ||
947 | // | ||
948 | // if (UUID.TryParse((string)row["AuthBuyerID"], out authedbuyer)) | ||
949 | // newData.AuthBuyerID = authedbuyer; | ||
950 | // | ||
951 | // if (UUID.TryParse((string)row["SnapshotUUID"], out snapshotID)) | ||
952 | // newData.SnapshotID = snapshotID; | ||
953 | newData.AuthBuyerID = new UUID((Guid)row["AuthBuyerID"]); | ||
954 | newData.SnapshotID = new UUID((Guid)row["SnapshotUUID"]); | ||
955 | |||
956 | newData.OtherCleanTime = Convert.ToInt32(row["OtherCleanTime"]); | ||
957 | |||
958 | try | ||
959 | { | ||
960 | newData.UserLocation = | ||
961 | new Vector3(Convert.ToSingle(row["UserLocationX"]), Convert.ToSingle(row["UserLocationY"]), | ||
962 | Convert.ToSingle(row["UserLocationZ"])); | ||
963 | newData.UserLookAt = | ||
964 | new Vector3(Convert.ToSingle(row["UserLookAtX"]), Convert.ToSingle(row["UserLookAtY"]), | ||
965 | Convert.ToSingle(row["UserLookAtZ"])); | ||
966 | } | ||
967 | catch (InvalidCastException) | ||
968 | { | ||
969 | newData.UserLocation = Vector3.Zero; | ||
970 | newData.UserLookAt = Vector3.Zero; | ||
971 | _Log.ErrorFormat("[PARCEL]: unable to get parcel telehub settings for {1}", newData.Name); | ||
972 | } | ||
973 | |||
974 | newData.ParcelAccessList = new List<ParcelManager.ParcelAccessEntry>(); | ||
975 | |||
976 | return newData; | ||
977 | } | ||
978 | |||
979 | /// <summary> | ||
980 | /// Builds the landaccess data from a data record. | ||
981 | /// </summary> | ||
982 | /// <param name="row">datarecord with landaccess data</param> | ||
983 | /// <returns></returns> | ||
984 | private static ParcelManager.ParcelAccessEntry BuildLandAccessData(IDataRecord row) | ||
985 | { | ||
986 | ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); | ||
987 | entry.AgentID = new UUID((Guid)row["AccessUUID"]); | ||
988 | entry.Flags = (AccessList)Convert.ToInt32(row["Flags"]); | ||
989 | entry.Time = new DateTime(); | ||
990 | return entry; | ||
991 | } | ||
992 | |||
993 | /// <summary> | ||
994 | /// Builds the prim from a datarecord. | ||
995 | /// </summary> | ||
996 | /// <param name="primRow">datarecord</param> | ||
997 | /// <returns></returns> | ||
998 | private static SceneObjectPart BuildPrim(IDataRecord primRow) | ||
999 | { | ||
1000 | SceneObjectPart prim = new SceneObjectPart(); | ||
1001 | |||
1002 | prim.UUID = new UUID((Guid)primRow["UUID"]); | ||
1003 | // explicit conversion of integers is required, which sort | ||
1004 | // of sucks. No idea if there is a shortcut here or not. | ||
1005 | prim.CreationDate = Convert.ToInt32(primRow["CreationDate"]); | ||
1006 | prim.Name = (string)primRow["Name"]; | ||
1007 | // various text fields | ||
1008 | prim.Text = (string)primRow["Text"]; | ||
1009 | prim.Color = Color.FromArgb(Convert.ToInt32(primRow["ColorA"]), | ||
1010 | Convert.ToInt32(primRow["ColorR"]), | ||
1011 | Convert.ToInt32(primRow["ColorG"]), | ||
1012 | Convert.ToInt32(primRow["ColorB"])); | ||
1013 | prim.Description = (string)primRow["Description"]; | ||
1014 | prim.SitName = (string)primRow["SitName"]; | ||
1015 | prim.TouchName = (string)primRow["TouchName"]; | ||
1016 | // permissions | ||
1017 | prim.Flags = (PrimFlags)Convert.ToUInt32(primRow["ObjectFlags"]); | ||
1018 | prim.CreatorID = new UUID((Guid)primRow["CreatorID"]); | ||
1019 | prim.OwnerID = new UUID((Guid)primRow["OwnerID"]); | ||
1020 | prim.GroupID = new UUID((Guid)primRow["GroupID"]); | ||
1021 | prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]); | ||
1022 | prim.OwnerMask = Convert.ToUInt32(primRow["OwnerMask"]); | ||
1023 | prim.NextOwnerMask = Convert.ToUInt32(primRow["NextOwnerMask"]); | ||
1024 | prim.GroupMask = Convert.ToUInt32(primRow["GroupMask"]); | ||
1025 | prim.EveryoneMask = Convert.ToUInt32(primRow["EveryoneMask"]); | ||
1026 | prim.BaseMask = Convert.ToUInt32(primRow["BaseMask"]); | ||
1027 | // vectors | ||
1028 | prim.OffsetPosition = new Vector3( | ||
1029 | Convert.ToSingle(primRow["PositionX"]), | ||
1030 | Convert.ToSingle(primRow["PositionY"]), | ||
1031 | Convert.ToSingle(primRow["PositionZ"])); | ||
1032 | |||
1033 | prim.GroupPosition = new Vector3( | ||
1034 | Convert.ToSingle(primRow["GroupPositionX"]), | ||
1035 | Convert.ToSingle(primRow["GroupPositionY"]), | ||
1036 | Convert.ToSingle(primRow["GroupPositionZ"])); | ||
1037 | |||
1038 | prim.Velocity = new Vector3( | ||
1039 | Convert.ToSingle(primRow["VelocityX"]), | ||
1040 | Convert.ToSingle(primRow["VelocityY"]), | ||
1041 | Convert.ToSingle(primRow["VelocityZ"])); | ||
1042 | |||
1043 | prim.AngularVelocity = new Vector3( | ||
1044 | Convert.ToSingle(primRow["AngularVelocityX"]), | ||
1045 | Convert.ToSingle(primRow["AngularVelocityY"]), | ||
1046 | Convert.ToSingle(primRow["AngularVelocityZ"])); | ||
1047 | |||
1048 | prim.Acceleration = new Vector3( | ||
1049 | Convert.ToSingle(primRow["AccelerationX"]), | ||
1050 | Convert.ToSingle(primRow["AccelerationY"]), | ||
1051 | Convert.ToSingle(primRow["AccelerationZ"])); | ||
1052 | |||
1053 | // quaternions | ||
1054 | prim.RotationOffset = new Quaternion( | ||
1055 | Convert.ToSingle(primRow["RotationX"]), | ||
1056 | Convert.ToSingle(primRow["RotationY"]), | ||
1057 | Convert.ToSingle(primRow["RotationZ"]), | ||
1058 | Convert.ToSingle(primRow["RotationW"])); | ||
1059 | |||
1060 | prim.SitTargetPositionLL = new Vector3( | ||
1061 | Convert.ToSingle(primRow["SitTargetOffsetX"]), | ||
1062 | Convert.ToSingle(primRow["SitTargetOffsetY"]), | ||
1063 | Convert.ToSingle(primRow["SitTargetOffsetZ"])); | ||
1064 | |||
1065 | prim.SitTargetOrientationLL = new Quaternion( | ||
1066 | Convert.ToSingle(primRow["SitTargetOrientX"]), | ||
1067 | Convert.ToSingle(primRow["SitTargetOrientY"]), | ||
1068 | Convert.ToSingle(primRow["SitTargetOrientZ"]), | ||
1069 | Convert.ToSingle(primRow["SitTargetOrientW"])); | ||
1070 | |||
1071 | prim.PayPrice[0] = Convert.ToInt32(primRow["PayPrice"]); | ||
1072 | prim.PayPrice[1] = Convert.ToInt32(primRow["PayButton1"]); | ||
1073 | prim.PayPrice[2] = Convert.ToInt32(primRow["PayButton2"]); | ||
1074 | prim.PayPrice[3] = Convert.ToInt32(primRow["PayButton3"]); | ||
1075 | prim.PayPrice[4] = Convert.ToInt32(primRow["PayButton4"]); | ||
1076 | |||
1077 | prim.Sound = new UUID((Guid)primRow["LoopedSound"]); | ||
1078 | prim.SoundGain = Convert.ToSingle(primRow["LoopedSoundGain"]); | ||
1079 | prim.SoundFlags = 1; // If it's persisted at all, it's looped | ||
1080 | |||
1081 | if (!(primRow["TextureAnimation"] is DBNull)) | ||
1082 | prim.TextureAnimation = (Byte[])primRow["TextureAnimation"]; | ||
1083 | if (!(primRow["ParticleSystem"] is DBNull)) | ||
1084 | prim.ParticleSystem = (Byte[])primRow["ParticleSystem"]; | ||
1085 | |||
1086 | prim.AngularVelocity = new Vector3( | ||
1087 | Convert.ToSingle(primRow["OmegaX"]), | ||
1088 | Convert.ToSingle(primRow["OmegaY"]), | ||
1089 | Convert.ToSingle(primRow["OmegaZ"])); | ||
1090 | |||
1091 | prim.SetCameraEyeOffset(new Vector3( | ||
1092 | Convert.ToSingle(primRow["CameraEyeOffsetX"]), | ||
1093 | Convert.ToSingle(primRow["CameraEyeOffsetY"]), | ||
1094 | Convert.ToSingle(primRow["CameraEyeOffsetZ"]) | ||
1095 | )); | ||
1096 | |||
1097 | prim.SetCameraAtOffset(new Vector3( | ||
1098 | Convert.ToSingle(primRow["CameraAtOffsetX"]), | ||
1099 | Convert.ToSingle(primRow["CameraAtOffsetY"]), | ||
1100 | Convert.ToSingle(primRow["CameraAtOffsetZ"]) | ||
1101 | )); | ||
1102 | |||
1103 | if (Convert.ToInt16(primRow["ForceMouselook"]) != 0) | ||
1104 | prim.SetForceMouselook(true); | ||
1105 | |||
1106 | prim.ScriptAccessPin = Convert.ToInt32(primRow["ScriptAccessPin"]); | ||
1107 | |||
1108 | if (Convert.ToInt16(primRow["AllowedDrop"]) != 0) | ||
1109 | prim.AllowedDrop = true; | ||
1110 | |||
1111 | if (Convert.ToInt16(primRow["DieAtEdge"]) != 0) | ||
1112 | prim.DIE_AT_EDGE = true; | ||
1113 | |||
1114 | prim.SalePrice = Convert.ToInt32(primRow["SalePrice"]); | ||
1115 | prim.ObjectSaleType = Convert.ToByte(primRow["SaleType"]); | ||
1116 | |||
1117 | prim.Material = Convert.ToByte(primRow["Material"]); | ||
1118 | |||
1119 | if (!(primRow["ClickAction"] is DBNull)) | ||
1120 | prim.ClickAction = Convert.ToByte(primRow["ClickAction"]); | ||
1121 | |||
1122 | prim.CollisionSound = new UUID((Guid)primRow["CollisionSound"]); | ||
1123 | prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]); | ||
1124 | if (Convert.ToInt16(primRow["PassTouches"]) != 0) | ||
1125 | prim.PassTouches = true; | ||
1126 | prim.LinkNum = Convert.ToInt32(primRow["LinkNumber"]); | ||
1127 | |||
1128 | if (!(primRow["MediaURL"] is System.DBNull)) | ||
1129 | prim.MediaUrl = (string)primRow["MediaURL"]; | ||
1130 | |||
1131 | return prim; | ||
1132 | } | ||
1133 | |||
1134 | /// <summary> | ||
1135 | /// Builds the prim shape from a datarecord. | ||
1136 | /// </summary> | ||
1137 | /// <param name="shapeRow">The row.</param> | ||
1138 | /// <returns></returns> | ||
1139 | private static PrimitiveBaseShape BuildShape(IDataRecord shapeRow) | ||
1140 | { | ||
1141 | PrimitiveBaseShape baseShape = new PrimitiveBaseShape(); | ||
1142 | |||
1143 | baseShape.Scale = new Vector3( | ||
1144 | Convert.ToSingle(shapeRow["ScaleX"]), | ||
1145 | Convert.ToSingle(shapeRow["ScaleY"]), | ||
1146 | Convert.ToSingle(shapeRow["ScaleZ"])); | ||
1147 | |||
1148 | // paths | ||
1149 | baseShape.PCode = Convert.ToByte(shapeRow["PCode"]); | ||
1150 | baseShape.PathBegin = Convert.ToUInt16(shapeRow["PathBegin"]); | ||
1151 | baseShape.PathEnd = Convert.ToUInt16(shapeRow["PathEnd"]); | ||
1152 | baseShape.PathScaleX = Convert.ToByte(shapeRow["PathScaleX"]); | ||
1153 | baseShape.PathScaleY = Convert.ToByte(shapeRow["PathScaleY"]); | ||
1154 | baseShape.PathShearX = Convert.ToByte(shapeRow["PathShearX"]); | ||
1155 | baseShape.PathShearY = Convert.ToByte(shapeRow["PathShearY"]); | ||
1156 | baseShape.PathSkew = Convert.ToSByte(shapeRow["PathSkew"]); | ||
1157 | baseShape.PathCurve = Convert.ToByte(shapeRow["PathCurve"]); | ||
1158 | baseShape.PathRadiusOffset = Convert.ToSByte(shapeRow["PathRadiusOffset"]); | ||
1159 | baseShape.PathRevolutions = Convert.ToByte(shapeRow["PathRevolutions"]); | ||
1160 | baseShape.PathTaperX = Convert.ToSByte(shapeRow["PathTaperX"]); | ||
1161 | baseShape.PathTaperY = Convert.ToSByte(shapeRow["PathTaperY"]); | ||
1162 | baseShape.PathTwist = Convert.ToSByte(shapeRow["PathTwist"]); | ||
1163 | baseShape.PathTwistBegin = Convert.ToSByte(shapeRow["PathTwistBegin"]); | ||
1164 | // profile | ||
1165 | baseShape.ProfileBegin = Convert.ToUInt16(shapeRow["ProfileBegin"]); | ||
1166 | baseShape.ProfileEnd = Convert.ToUInt16(shapeRow["ProfileEnd"]); | ||
1167 | baseShape.ProfileCurve = Convert.ToByte(shapeRow["ProfileCurve"]); | ||
1168 | baseShape.ProfileHollow = Convert.ToUInt16(shapeRow["ProfileHollow"]); | ||
1169 | |||
1170 | byte[] textureEntry = (byte[])shapeRow["Texture"]; | ||
1171 | baseShape.TextureEntry = textureEntry; | ||
1172 | |||
1173 | baseShape.ExtraParams = (byte[])shapeRow["ExtraParams"]; | ||
1174 | |||
1175 | try | ||
1176 | { | ||
1177 | baseShape.State = Convert.ToByte(shapeRow["State"]); | ||
1178 | } | ||
1179 | catch (InvalidCastException) | ||
1180 | { | ||
1181 | } | ||
1182 | |||
1183 | if (!(shapeRow["Media"] is System.DBNull)) | ||
1184 | baseShape.Media = PrimitiveBaseShape.MediaList.FromXml((string)shapeRow["Media"]); | ||
1185 | |||
1186 | return baseShape; | ||
1187 | } | ||
1188 | |||
1189 | /// <summary> | ||
1190 | /// Build a prim inventory item from the persisted data. | ||
1191 | /// </summary> | ||
1192 | /// <param name="inventoryRow"></param> | ||
1193 | /// <returns></returns> | ||
1194 | private static TaskInventoryItem BuildItem(IDataRecord inventoryRow) | ||
1195 | { | ||
1196 | TaskInventoryItem taskItem = new TaskInventoryItem(); | ||
1197 | |||
1198 | taskItem.ItemID = new UUID((Guid)inventoryRow["itemID"]); | ||
1199 | taskItem.ParentPartID = new UUID((Guid)inventoryRow["primID"]); | ||
1200 | taskItem.AssetID = new UUID((Guid)inventoryRow["assetID"]); | ||
1201 | taskItem.ParentID = new UUID((Guid)inventoryRow["parentFolderID"]); | ||
1202 | |||
1203 | taskItem.InvType = Convert.ToInt32(inventoryRow["invType"]); | ||
1204 | taskItem.Type = Convert.ToInt32(inventoryRow["assetType"]); | ||
1205 | |||
1206 | taskItem.Name = (string)inventoryRow["name"]; | ||
1207 | taskItem.Description = (string)inventoryRow["description"]; | ||
1208 | taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]); | ||
1209 | taskItem.CreatorID = new UUID((Guid)inventoryRow["creatorID"]); | ||
1210 | taskItem.OwnerID = new UUID((Guid)inventoryRow["ownerID"]); | ||
1211 | taskItem.LastOwnerID = new UUID((Guid)inventoryRow["lastOwnerID"]); | ||
1212 | taskItem.GroupID = new UUID((Guid)inventoryRow["groupID"]); | ||
1213 | |||
1214 | taskItem.NextPermissions = Convert.ToUInt32(inventoryRow["nextPermissions"]); | ||
1215 | taskItem.CurrentPermissions = Convert.ToUInt32(inventoryRow["currentPermissions"]); | ||
1216 | taskItem.BasePermissions = Convert.ToUInt32(inventoryRow["basePermissions"]); | ||
1217 | taskItem.EveryonePermissions = Convert.ToUInt32(inventoryRow["everyonePermissions"]); | ||
1218 | taskItem.GroupPermissions = Convert.ToUInt32(inventoryRow["groupPermissions"]); | ||
1219 | taskItem.Flags = Convert.ToUInt32(inventoryRow["flags"]); | ||
1220 | |||
1221 | return taskItem; | ||
1222 | } | ||
1223 | |||
1224 | #endregion | ||
1225 | |||
1226 | #region Create parameters methods | ||
1227 | |||
1228 | /// <summary> | ||
1229 | /// Creates the prim inventory parameters. | ||
1230 | /// </summary> | ||
1231 | /// <param name="taskItem">item in inventory.</param> | ||
1232 | /// <returns></returns> | ||
1233 | private SqlParameter[] CreatePrimInventoryParameters(TaskInventoryItem taskItem) | ||
1234 | { | ||
1235 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1236 | |||
1237 | parameters.Add(_Database.CreateParameter("itemID", taskItem.ItemID)); | ||
1238 | parameters.Add(_Database.CreateParameter("primID", taskItem.ParentPartID)); | ||
1239 | parameters.Add(_Database.CreateParameter("assetID", taskItem.AssetID)); | ||
1240 | parameters.Add(_Database.CreateParameter("parentFolderID", taskItem.ParentID)); | ||
1241 | parameters.Add(_Database.CreateParameter("invType", taskItem.InvType)); | ||
1242 | parameters.Add(_Database.CreateParameter("assetType", taskItem.Type)); | ||
1243 | |||
1244 | parameters.Add(_Database.CreateParameter("name", taskItem.Name)); | ||
1245 | parameters.Add(_Database.CreateParameter("description", taskItem.Description)); | ||
1246 | parameters.Add(_Database.CreateParameter("creationDate", taskItem.CreationDate)); | ||
1247 | parameters.Add(_Database.CreateParameter("creatorID", taskItem.CreatorID)); | ||
1248 | parameters.Add(_Database.CreateParameter("ownerID", taskItem.OwnerID)); | ||
1249 | parameters.Add(_Database.CreateParameter("lastOwnerID", taskItem.LastOwnerID)); | ||
1250 | parameters.Add(_Database.CreateParameter("groupID", taskItem.GroupID)); | ||
1251 | parameters.Add(_Database.CreateParameter("nextPermissions", taskItem.NextPermissions)); | ||
1252 | parameters.Add(_Database.CreateParameter("currentPermissions", taskItem.CurrentPermissions)); | ||
1253 | parameters.Add(_Database.CreateParameter("basePermissions", taskItem.BasePermissions)); | ||
1254 | parameters.Add(_Database.CreateParameter("everyonePermissions", taskItem.EveryonePermissions)); | ||
1255 | parameters.Add(_Database.CreateParameter("groupPermissions", taskItem.GroupPermissions)); | ||
1256 | parameters.Add(_Database.CreateParameter("flags", taskItem.Flags)); | ||
1257 | |||
1258 | return parameters.ToArray(); | ||
1259 | } | ||
1260 | |||
1261 | /// <summary> | ||
1262 | /// Creates the region setting parameters. | ||
1263 | /// </summary> | ||
1264 | /// <param name="settings">regionsettings.</param> | ||
1265 | /// <returns></returns> | ||
1266 | private SqlParameter[] CreateRegionSettingParameters(RegionSettings settings) | ||
1267 | { | ||
1268 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1269 | |||
1270 | parameters.Add(_Database.CreateParameter("regionUUID", settings.RegionUUID)); | ||
1271 | parameters.Add(_Database.CreateParameter("block_terraform", settings.BlockTerraform)); | ||
1272 | parameters.Add(_Database.CreateParameter("block_fly", settings.BlockFly)); | ||
1273 | parameters.Add(_Database.CreateParameter("allow_damage", settings.AllowDamage)); | ||
1274 | parameters.Add(_Database.CreateParameter("restrict_pushing", settings.RestrictPushing)); | ||
1275 | parameters.Add(_Database.CreateParameter("allow_land_resell", settings.AllowLandResell)); | ||
1276 | parameters.Add(_Database.CreateParameter("allow_land_join_divide", settings.AllowLandJoinDivide)); | ||
1277 | parameters.Add(_Database.CreateParameter("block_show_in_search", settings.BlockShowInSearch)); | ||
1278 | parameters.Add(_Database.CreateParameter("agent_limit", settings.AgentLimit)); | ||
1279 | parameters.Add(_Database.CreateParameter("object_bonus", settings.ObjectBonus)); | ||
1280 | parameters.Add(_Database.CreateParameter("maturity", settings.Maturity)); | ||
1281 | parameters.Add(_Database.CreateParameter("disable_scripts", settings.DisableScripts)); | ||
1282 | parameters.Add(_Database.CreateParameter("disable_collisions", settings.DisableCollisions)); | ||
1283 | parameters.Add(_Database.CreateParameter("disable_physics", settings.DisablePhysics)); | ||
1284 | parameters.Add(_Database.CreateParameter("terrain_texture_1", settings.TerrainTexture1)); | ||
1285 | parameters.Add(_Database.CreateParameter("terrain_texture_2", settings.TerrainTexture2)); | ||
1286 | parameters.Add(_Database.CreateParameter("terrain_texture_3", settings.TerrainTexture3)); | ||
1287 | parameters.Add(_Database.CreateParameter("terrain_texture_4", settings.TerrainTexture4)); | ||
1288 | parameters.Add(_Database.CreateParameter("elevation_1_nw", settings.Elevation1NW)); | ||
1289 | parameters.Add(_Database.CreateParameter("elevation_2_nw", settings.Elevation2NW)); | ||
1290 | parameters.Add(_Database.CreateParameter("elevation_1_ne", settings.Elevation1NE)); | ||
1291 | parameters.Add(_Database.CreateParameter("elevation_2_ne", settings.Elevation2NE)); | ||
1292 | parameters.Add(_Database.CreateParameter("elevation_1_se", settings.Elevation1SE)); | ||
1293 | parameters.Add(_Database.CreateParameter("elevation_2_se", settings.Elevation2SE)); | ||
1294 | parameters.Add(_Database.CreateParameter("elevation_1_sw", settings.Elevation1SW)); | ||
1295 | parameters.Add(_Database.CreateParameter("elevation_2_sw", settings.Elevation2SW)); | ||
1296 | parameters.Add(_Database.CreateParameter("water_height", settings.WaterHeight)); | ||
1297 | parameters.Add(_Database.CreateParameter("terrain_raise_limit", settings.TerrainRaiseLimit)); | ||
1298 | parameters.Add(_Database.CreateParameter("terrain_lower_limit", settings.TerrainLowerLimit)); | ||
1299 | parameters.Add(_Database.CreateParameter("use_estate_sun", settings.UseEstateSun)); | ||
1300 | parameters.Add(_Database.CreateParameter("sandbox", settings.Sandbox)); | ||
1301 | parameters.Add(_Database.CreateParameter("fixed_sun", settings.FixedSun)); | ||
1302 | parameters.Add(_Database.CreateParameter("sun_position", settings.SunPosition)); | ||
1303 | parameters.Add(_Database.CreateParameter("sunvectorx", settings.SunVector.X)); | ||
1304 | parameters.Add(_Database.CreateParameter("sunvectory", settings.SunVector.Y)); | ||
1305 | parameters.Add(_Database.CreateParameter("sunvectorz", settings.SunVector.Z)); | ||
1306 | parameters.Add(_Database.CreateParameter("covenant", settings.Covenant)); | ||
1307 | parameters.Add(_Database.CreateParameter("Loaded_Creation_DateTime", settings.LoadedCreationDateTime)); | ||
1308 | parameters.Add(_Database.CreateParameter("Loaded_Creation_ID", settings.LoadedCreationID)); | ||
1309 | |||
1310 | return parameters.ToArray(); | ||
1311 | } | ||
1312 | |||
1313 | /// <summary> | ||
1314 | /// Creates the land parameters. | ||
1315 | /// </summary> | ||
1316 | /// <param name="land">land parameters.</param> | ||
1317 | /// <param name="regionUUID">region UUID.</param> | ||
1318 | /// <returns></returns> | ||
1319 | private SqlParameter[] CreateLandParameters(LandData land, UUID regionUUID) | ||
1320 | { | ||
1321 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1322 | |||
1323 | parameters.Add(_Database.CreateParameter("UUID", land.GlobalID)); | ||
1324 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); | ||
1325 | parameters.Add(_Database.CreateParameter("LocalLandID", land.LocalID)); | ||
1326 | |||
1327 | // Bitmap is a byte[512] | ||
1328 | parameters.Add(_Database.CreateParameter("Bitmap", land.Bitmap)); | ||
1329 | |||
1330 | parameters.Add(_Database.CreateParameter("Name", land.Name)); | ||
1331 | parameters.Add(_Database.CreateParameter("Description", land.Description)); | ||
1332 | parameters.Add(_Database.CreateParameter("OwnerUUID", land.OwnerID)); | ||
1333 | parameters.Add(_Database.CreateParameter("IsGroupOwned", land.IsGroupOwned)); | ||
1334 | parameters.Add(_Database.CreateParameter("Area", land.Area)); | ||
1335 | parameters.Add(_Database.CreateParameter("AuctionID", land.AuctionID)); //Unemplemented | ||
1336 | parameters.Add(_Database.CreateParameter("Category", (int)land.Category)); //Enum libsecondlife.Parcel.ParcelCategory | ||
1337 | parameters.Add(_Database.CreateParameter("ClaimDate", land.ClaimDate)); | ||
1338 | parameters.Add(_Database.CreateParameter("ClaimPrice", land.ClaimPrice)); | ||
1339 | parameters.Add(_Database.CreateParameter("GroupUUID", land.GroupID)); | ||
1340 | parameters.Add(_Database.CreateParameter("SalePrice", land.SalePrice)); | ||
1341 | parameters.Add(_Database.CreateParameter("LandStatus", (int)land.Status)); //Enum. libsecondlife.Parcel.ParcelStatus | ||
1342 | parameters.Add(_Database.CreateParameter("LandFlags", land.Flags)); | ||
1343 | parameters.Add(_Database.CreateParameter("LandingType", land.LandingType)); | ||
1344 | parameters.Add(_Database.CreateParameter("MediaAutoScale", land.MediaAutoScale)); | ||
1345 | parameters.Add(_Database.CreateParameter("MediaTextureUUID", land.MediaID)); | ||
1346 | parameters.Add(_Database.CreateParameter("MediaURL", land.MediaURL)); | ||
1347 | parameters.Add(_Database.CreateParameter("MusicURL", land.MusicURL)); | ||
1348 | parameters.Add(_Database.CreateParameter("PassHours", land.PassHours)); | ||
1349 | parameters.Add(_Database.CreateParameter("PassPrice", land.PassPrice)); | ||
1350 | parameters.Add(_Database.CreateParameter("SnapshotUUID", land.SnapshotID)); | ||
1351 | parameters.Add(_Database.CreateParameter("UserLocationX", land.UserLocation.X)); | ||
1352 | parameters.Add(_Database.CreateParameter("UserLocationY", land.UserLocation.Y)); | ||
1353 | parameters.Add(_Database.CreateParameter("UserLocationZ", land.UserLocation.Z)); | ||
1354 | parameters.Add(_Database.CreateParameter("UserLookAtX", land.UserLookAt.X)); | ||
1355 | parameters.Add(_Database.CreateParameter("UserLookAtY", land.UserLookAt.Y)); | ||
1356 | parameters.Add(_Database.CreateParameter("UserLookAtZ", land.UserLookAt.Z)); | ||
1357 | parameters.Add(_Database.CreateParameter("AuthBuyerID", land.AuthBuyerID)); | ||
1358 | parameters.Add(_Database.CreateParameter("OtherCleanTime", land.OtherCleanTime)); | ||
1359 | |||
1360 | return parameters.ToArray(); | ||
1361 | } | ||
1362 | |||
1363 | /// <summary> | ||
1364 | /// Creates the land access parameters. | ||
1365 | /// </summary> | ||
1366 | /// <param name="parcelAccessEntry">parcel access entry.</param> | ||
1367 | /// <param name="parcelID">parcel ID.</param> | ||
1368 | /// <returns></returns> | ||
1369 | private SqlParameter[] CreateLandAccessParameters(ParcelManager.ParcelAccessEntry parcelAccessEntry, UUID parcelID) | ||
1370 | { | ||
1371 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1372 | |||
1373 | parameters.Add(_Database.CreateParameter("LandUUID", parcelID)); | ||
1374 | parameters.Add(_Database.CreateParameter("AccessUUID", parcelAccessEntry.AgentID)); | ||
1375 | parameters.Add(_Database.CreateParameter("Flags", parcelAccessEntry.Flags)); | ||
1376 | |||
1377 | return parameters.ToArray(); | ||
1378 | } | ||
1379 | |||
1380 | /// <summary> | ||
1381 | /// Creates the prim parameters for storing in DB. | ||
1382 | /// </summary> | ||
1383 | /// <param name="prim">Basic data of SceneObjectpart prim.</param> | ||
1384 | /// <param name="sceneGroupID">The scenegroup ID.</param> | ||
1385 | /// <param name="regionUUID">The region ID.</param> | ||
1386 | /// <returns></returns> | ||
1387 | private SqlParameter[] CreatePrimParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) | ||
1388 | { | ||
1389 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1390 | |||
1391 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); | ||
1392 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); | ||
1393 | parameters.Add(_Database.CreateParameter("CreationDate", prim.CreationDate)); | ||
1394 | parameters.Add(_Database.CreateParameter("Name", prim.Name)); | ||
1395 | parameters.Add(_Database.CreateParameter("SceneGroupID", sceneGroupID)); | ||
1396 | // the UUID of the root part for this SceneObjectGroup | ||
1397 | // various text fields | ||
1398 | parameters.Add(_Database.CreateParameter("Text", prim.Text)); | ||
1399 | parameters.Add(_Database.CreateParameter("ColorR", prim.Color.R)); | ||
1400 | parameters.Add(_Database.CreateParameter("ColorG", prim.Color.G)); | ||
1401 | parameters.Add(_Database.CreateParameter("ColorB", prim.Color.B)); | ||
1402 | parameters.Add(_Database.CreateParameter("ColorA", prim.Color.A)); | ||
1403 | parameters.Add(_Database.CreateParameter("Description", prim.Description)); | ||
1404 | parameters.Add(_Database.CreateParameter("SitName", prim.SitName)); | ||
1405 | parameters.Add(_Database.CreateParameter("TouchName", prim.TouchName)); | ||
1406 | // permissions | ||
1407 | parameters.Add(_Database.CreateParameter("ObjectFlags", (uint)prim.Flags)); | ||
1408 | parameters.Add(_Database.CreateParameter("CreatorID", prim.CreatorID)); | ||
1409 | parameters.Add(_Database.CreateParameter("OwnerID", prim.OwnerID)); | ||
1410 | parameters.Add(_Database.CreateParameter("GroupID", prim.GroupID)); | ||
1411 | parameters.Add(_Database.CreateParameter("LastOwnerID", prim.LastOwnerID)); | ||
1412 | parameters.Add(_Database.CreateParameter("OwnerMask", prim.OwnerMask)); | ||
1413 | parameters.Add(_Database.CreateParameter("NextOwnerMask", prim.NextOwnerMask)); | ||
1414 | parameters.Add(_Database.CreateParameter("GroupMask", prim.GroupMask)); | ||
1415 | parameters.Add(_Database.CreateParameter("EveryoneMask", prim.EveryoneMask)); | ||
1416 | parameters.Add(_Database.CreateParameter("BaseMask", prim.BaseMask)); | ||
1417 | // vectors | ||
1418 | parameters.Add(_Database.CreateParameter("PositionX", prim.OffsetPosition.X)); | ||
1419 | parameters.Add(_Database.CreateParameter("PositionY", prim.OffsetPosition.Y)); | ||
1420 | parameters.Add(_Database.CreateParameter("PositionZ", prim.OffsetPosition.Z)); | ||
1421 | parameters.Add(_Database.CreateParameter("GroupPositionX", prim.GroupPosition.X)); | ||
1422 | parameters.Add(_Database.CreateParameter("GroupPositionY", prim.GroupPosition.Y)); | ||
1423 | parameters.Add(_Database.CreateParameter("GroupPositionZ", prim.GroupPosition.Z)); | ||
1424 | parameters.Add(_Database.CreateParameter("VelocityX", prim.Velocity.X)); | ||
1425 | parameters.Add(_Database.CreateParameter("VelocityY", prim.Velocity.Y)); | ||
1426 | parameters.Add(_Database.CreateParameter("VelocityZ", prim.Velocity.Z)); | ||
1427 | parameters.Add(_Database.CreateParameter("AngularVelocityX", prim.AngularVelocity.X)); | ||
1428 | parameters.Add(_Database.CreateParameter("AngularVelocityY", prim.AngularVelocity.Y)); | ||
1429 | parameters.Add(_Database.CreateParameter("AngularVelocityZ", prim.AngularVelocity.Z)); | ||
1430 | parameters.Add(_Database.CreateParameter("AccelerationX", prim.Acceleration.X)); | ||
1431 | parameters.Add(_Database.CreateParameter("AccelerationY", prim.Acceleration.Y)); | ||
1432 | parameters.Add(_Database.CreateParameter("AccelerationZ", prim.Acceleration.Z)); | ||
1433 | // quaternions | ||
1434 | parameters.Add(_Database.CreateParameter("RotationX", prim.RotationOffset.X)); | ||
1435 | parameters.Add(_Database.CreateParameter("RotationY", prim.RotationOffset.Y)); | ||
1436 | parameters.Add(_Database.CreateParameter("RotationZ", prim.RotationOffset.Z)); | ||
1437 | parameters.Add(_Database.CreateParameter("RotationW", prim.RotationOffset.W)); | ||
1438 | |||
1439 | // Sit target | ||
1440 | Vector3 sitTargetPos = prim.SitTargetPositionLL; | ||
1441 | parameters.Add(_Database.CreateParameter("SitTargetOffsetX", sitTargetPos.X)); | ||
1442 | parameters.Add(_Database.CreateParameter("SitTargetOffsetY", sitTargetPos.Y)); | ||
1443 | parameters.Add(_Database.CreateParameter("SitTargetOffsetZ", sitTargetPos.Z)); | ||
1444 | |||
1445 | Quaternion sitTargetOrient = prim.SitTargetOrientationLL; | ||
1446 | parameters.Add(_Database.CreateParameter("SitTargetOrientW", sitTargetOrient.W)); | ||
1447 | parameters.Add(_Database.CreateParameter("SitTargetOrientX", sitTargetOrient.X)); | ||
1448 | parameters.Add(_Database.CreateParameter("SitTargetOrientY", sitTargetOrient.Y)); | ||
1449 | parameters.Add(_Database.CreateParameter("SitTargetOrientZ", sitTargetOrient.Z)); | ||
1450 | |||
1451 | parameters.Add(_Database.CreateParameter("PayPrice", prim.PayPrice[0])); | ||
1452 | parameters.Add(_Database.CreateParameter("PayButton1", prim.PayPrice[1])); | ||
1453 | parameters.Add(_Database.CreateParameter("PayButton2", prim.PayPrice[2])); | ||
1454 | parameters.Add(_Database.CreateParameter("PayButton3", prim.PayPrice[3])); | ||
1455 | parameters.Add(_Database.CreateParameter("PayButton4", prim.PayPrice[4])); | ||
1456 | |||
1457 | if ((prim.SoundFlags & 1) != 0) // Looped | ||
1458 | { | ||
1459 | parameters.Add(_Database.CreateParameter("LoopedSound", prim.Sound)); | ||
1460 | parameters.Add(_Database.CreateParameter("LoopedSoundGain", prim.SoundGain)); | ||
1461 | } | ||
1462 | else | ||
1463 | { | ||
1464 | parameters.Add(_Database.CreateParameter("LoopedSound", UUID.Zero)); | ||
1465 | parameters.Add(_Database.CreateParameter("LoopedSoundGain", 0.0f)); | ||
1466 | } | ||
1467 | |||
1468 | parameters.Add(_Database.CreateParameter("TextureAnimation", prim.TextureAnimation)); | ||
1469 | parameters.Add(_Database.CreateParameter("ParticleSystem", prim.ParticleSystem)); | ||
1470 | |||
1471 | parameters.Add(_Database.CreateParameter("OmegaX", prim.AngularVelocity.X)); | ||
1472 | parameters.Add(_Database.CreateParameter("OmegaY", prim.AngularVelocity.Y)); | ||
1473 | parameters.Add(_Database.CreateParameter("OmegaZ", prim.AngularVelocity.Z)); | ||
1474 | |||
1475 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetX", prim.GetCameraEyeOffset().X)); | ||
1476 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetY", prim.GetCameraEyeOffset().Y)); | ||
1477 | parameters.Add(_Database.CreateParameter("CameraEyeOffsetZ", prim.GetCameraEyeOffset().Z)); | ||
1478 | |||
1479 | parameters.Add(_Database.CreateParameter("CameraAtOffsetX", prim.GetCameraAtOffset().X)); | ||
1480 | parameters.Add(_Database.CreateParameter("CameraAtOffsetY", prim.GetCameraAtOffset().Y)); | ||
1481 | parameters.Add(_Database.CreateParameter("CameraAtOffsetZ", prim.GetCameraAtOffset().Z)); | ||
1482 | |||
1483 | if (prim.GetForceMouselook()) | ||
1484 | parameters.Add(_Database.CreateParameter("ForceMouselook", 1)); | ||
1485 | else | ||
1486 | parameters.Add(_Database.CreateParameter("ForceMouselook", 0)); | ||
1487 | |||
1488 | parameters.Add(_Database.CreateParameter("ScriptAccessPin", prim.ScriptAccessPin)); | ||
1489 | |||
1490 | if (prim.AllowedDrop) | ||
1491 | parameters.Add(_Database.CreateParameter("AllowedDrop", 1)); | ||
1492 | else | ||
1493 | parameters.Add(_Database.CreateParameter("AllowedDrop", 0)); | ||
1494 | |||
1495 | if (prim.DIE_AT_EDGE) | ||
1496 | parameters.Add(_Database.CreateParameter("DieAtEdge", 1)); | ||
1497 | else | ||
1498 | parameters.Add(_Database.CreateParameter("DieAtEdge", 0)); | ||
1499 | |||
1500 | parameters.Add(_Database.CreateParameter("SalePrice", prim.SalePrice)); | ||
1501 | parameters.Add(_Database.CreateParameter("SaleType", prim.ObjectSaleType)); | ||
1502 | |||
1503 | byte clickAction = prim.ClickAction; | ||
1504 | parameters.Add(_Database.CreateParameter("ClickAction", clickAction)); | ||
1505 | |||
1506 | parameters.Add(_Database.CreateParameter("Material", prim.Material)); | ||
1507 | |||
1508 | parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound)); | ||
1509 | parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume)); | ||
1510 | if (prim.PassTouches) | ||
1511 | parameters.Add(_Database.CreateParameter("PassTouches", 1)); | ||
1512 | else | ||
1513 | parameters.Add(_Database.CreateParameter("PassTouches", 0)); | ||
1514 | parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); | ||
1515 | parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); | ||
1516 | |||
1517 | return parameters.ToArray(); | ||
1518 | } | ||
1519 | |||
1520 | /// <summary> | ||
1521 | /// Creates the primshape parameters for stroing in DB. | ||
1522 | /// </summary> | ||
1523 | /// <param name="prim">Basic data of SceneObjectpart prim.</param> | ||
1524 | /// <param name="sceneGroupID">The scene group ID.</param> | ||
1525 | /// <param name="regionUUID">The region UUID.</param> | ||
1526 | /// <returns></returns> | ||
1527 | private SqlParameter[] CreatePrimShapeParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) | ||
1528 | { | ||
1529 | List<SqlParameter> parameters = new List<SqlParameter>(); | ||
1530 | |||
1531 | PrimitiveBaseShape s = prim.Shape; | ||
1532 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); | ||
1533 | // shape is an enum | ||
1534 | parameters.Add(_Database.CreateParameter("Shape", 0)); | ||
1535 | // vectors | ||
1536 | parameters.Add(_Database.CreateParameter("ScaleX", s.Scale.X)); | ||
1537 | parameters.Add(_Database.CreateParameter("ScaleY", s.Scale.Y)); | ||
1538 | parameters.Add(_Database.CreateParameter("ScaleZ", s.Scale.Z)); | ||
1539 | // paths | ||
1540 | parameters.Add(_Database.CreateParameter("PCode", s.PCode)); | ||
1541 | parameters.Add(_Database.CreateParameter("PathBegin", s.PathBegin)); | ||
1542 | parameters.Add(_Database.CreateParameter("PathEnd", s.PathEnd)); | ||
1543 | parameters.Add(_Database.CreateParameter("PathScaleX", s.PathScaleX)); | ||
1544 | parameters.Add(_Database.CreateParameter("PathScaleY", s.PathScaleY)); | ||
1545 | parameters.Add(_Database.CreateParameter("PathShearX", s.PathShearX)); | ||
1546 | parameters.Add(_Database.CreateParameter("PathShearY", s.PathShearY)); | ||
1547 | parameters.Add(_Database.CreateParameter("PathSkew", s.PathSkew)); | ||
1548 | parameters.Add(_Database.CreateParameter("PathCurve", s.PathCurve)); | ||
1549 | parameters.Add(_Database.CreateParameter("PathRadiusOffset", s.PathRadiusOffset)); | ||
1550 | parameters.Add(_Database.CreateParameter("PathRevolutions", s.PathRevolutions)); | ||
1551 | parameters.Add(_Database.CreateParameter("PathTaperX", s.PathTaperX)); | ||
1552 | parameters.Add(_Database.CreateParameter("PathTaperY", s.PathTaperY)); | ||
1553 | parameters.Add(_Database.CreateParameter("PathTwist", s.PathTwist)); | ||
1554 | parameters.Add(_Database.CreateParameter("PathTwistBegin", s.PathTwistBegin)); | ||
1555 | // profile | ||
1556 | parameters.Add(_Database.CreateParameter("ProfileBegin", s.ProfileBegin)); | ||
1557 | parameters.Add(_Database.CreateParameter("ProfileEnd", s.ProfileEnd)); | ||
1558 | parameters.Add(_Database.CreateParameter("ProfileCurve", s.ProfileCurve)); | ||
1559 | parameters.Add(_Database.CreateParameter("ProfileHollow", s.ProfileHollow)); | ||
1560 | parameters.Add(_Database.CreateParameter("Texture", s.TextureEntry)); | ||
1561 | parameters.Add(_Database.CreateParameter("ExtraParams", s.ExtraParams)); | ||
1562 | parameters.Add(_Database.CreateParameter("State", s.State)); | ||
1563 | parameters.Add(_Database.CreateParameter("Media", null == s.Media ? null : s.Media.ToXml())); | ||
1564 | |||
1565 | return parameters.ToArray(); | ||
1566 | } | ||
1567 | |||
1568 | #endregion | ||
1569 | |||
1570 | #endregion | ||
1571 | } | ||
1572 | } | ||