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