diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/PGSQL/PGSQLSimulationData.cs (renamed from OpenSim/Data/MSSQL/MSSQLSimulationData.cs) | 960 |
1 files changed, 492 insertions, 468 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs index 17f42e1..77d87d4 100644 --- a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs +++ b/OpenSim/Data/PGSQL/PGSQLSimulationData.cs | |||
@@ -28,7 +28,6 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Data; | 30 | using System.Data; |
31 | using System.Data.SqlClient; | ||
32 | using System.Drawing; | 31 | using System.Drawing; |
33 | using System.IO; | 32 | using System.IO; |
34 | using System.Reflection; | 33 | using System.Reflection; |
@@ -37,15 +36,17 @@ using OpenMetaverse; | |||
37 | using OpenSim.Framework; | 36 | using OpenSim.Framework; |
38 | using OpenSim.Region.Framework.Interfaces; | 37 | using OpenSim.Region.Framework.Interfaces; |
39 | using OpenSim.Region.Framework.Scenes; | 38 | using OpenSim.Region.Framework.Scenes; |
39 | using Npgsql; | ||
40 | 40 | ||
41 | namespace OpenSim.Data.MSSQL | 41 | namespace OpenSim.Data.PGSQL |
42 | { | 42 | { |
43 | /// <summary> | 43 | /// <summary> |
44 | /// A MSSQL Interface for the Region Server. | 44 | /// A PGSQL Interface for the Region Server. |
45 | /// </summary> | 45 | /// </summary> |
46 | public class MSSQLSimulationData : ISimulationDataStore | 46 | public class PGSQLSimulationData : ISimulationDataStore |
47 | { | 47 | { |
48 | private const string _migrationStore = "RegionStore"; | 48 | private const string _migrationStore = "RegionStore"; |
49 | private const string LogHeader = "[REGION DB PGSQL]"; | ||
49 | 50 | ||
50 | // private static FileSystemDataStore Instance = new FileSystemDataStore(); | 51 | // private static FileSystemDataStore Instance = new FileSystemDataStore(); |
51 | private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 52 | private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
@@ -53,18 +54,18 @@ namespace OpenSim.Data.MSSQL | |||
53 | /// <summary> | 54 | /// <summary> |
54 | /// The database manager | 55 | /// The database manager |
55 | /// </summary> | 56 | /// </summary> |
56 | private MSSQLManager _Database; | 57 | private PGSQLManager _Database; |
57 | private string m_connectionString; | 58 | private string m_connectionString; |
58 | protected virtual Assembly Assembly | 59 | protected virtual Assembly Assembly |
59 | { | 60 | { |
60 | get { return GetType().Assembly; } | 61 | get { return GetType().Assembly; } |
61 | } | 62 | } |
62 | 63 | ||
63 | public MSSQLSimulationData() | 64 | public PGSQLSimulationData() |
64 | { | 65 | { |
65 | } | 66 | } |
66 | 67 | ||
67 | public MSSQLSimulationData(string connectionString) | 68 | public PGSQLSimulationData(string connectionString) |
68 | { | 69 | { |
69 | Initialise(connectionString); | 70 | Initialise(connectionString); |
70 | } | 71 | } |
@@ -76,9 +77,9 @@ namespace OpenSim.Data.MSSQL | |||
76 | public void Initialise(string connectionString) | 77 | public void Initialise(string connectionString) |
77 | { | 78 | { |
78 | m_connectionString = connectionString; | 79 | m_connectionString = connectionString; |
79 | _Database = new MSSQLManager(connectionString); | 80 | _Database = new PGSQLManager(connectionString); |
80 | 81 | ||
81 | using (SqlConnection conn = new SqlConnection(connectionString)) | 82 | using (NpgsqlConnection conn = new NpgsqlConnection(connectionString)) |
82 | { | 83 | { |
83 | conn.Open(); | 84 | conn.Open(); |
84 | //New Migration settings | 85 | //New Migration settings |
@@ -107,19 +108,19 @@ namespace OpenSim.Data.MSSQL | |||
107 | Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>(); | 108 | Dictionary<UUID, SceneObjectGroup> objects = new Dictionary<UUID, SceneObjectGroup>(); |
108 | SceneObjectGroup grp = null; | 109 | SceneObjectGroup grp = null; |
109 | 110 | ||
110 | string sql = "SELECT *, " + | 111 | string sql = @"SELECT *, |
111 | "sort = CASE WHEN prims.UUID = prims.SceneGroupID THEN 0 ELSE 1 END " + | 112 | CASE WHEN prims.""UUID"" = prims.""SceneGroupID"" THEN 0 ELSE 1 END as sort |
112 | "FROM prims " + | 113 | FROM prims |
113 | "LEFT JOIN primshapes ON prims.UUID = primshapes.UUID " + | 114 | LEFT JOIN primshapes ON prims.""UUID"" = primshapes.""UUID"" |
114 | "WHERE RegionUUID = @RegionUUID " + | 115 | WHERE ""RegionUUID"" = :RegionUUID |
115 | "ORDER BY SceneGroupID asc, sort asc, LinkNumber asc"; | 116 | ORDER BY ""SceneGroupID"" asc, sort asc, ""LinkNumber"" asc"; |
116 | 117 | ||
117 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 118 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
118 | using (SqlCommand command = new SqlCommand(sql, conn)) | 119 | using (NpgsqlCommand command = new NpgsqlCommand(sql, conn)) |
119 | { | 120 | { |
120 | command.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID)); | 121 | command.Parameters.Add(_Database.CreateParameter("regionUUID", regionUUID)); |
121 | conn.Open(); | 122 | conn.Open(); |
122 | using (SqlDataReader reader = command.ExecuteReader()) | 123 | using (NpgsqlDataReader reader = command.ExecuteReader()) |
123 | { | 124 | { |
124 | while (reader.Read()) | 125 | while (reader.Read()) |
125 | { | 126 | { |
@@ -179,12 +180,12 @@ namespace OpenSim.Data.MSSQL | |||
179 | // list from DB of all prims which have items and | 180 | // list from DB of all prims which have items and |
180 | // LoadItems only on those | 181 | // LoadItems only on those |
181 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); | 182 | List<SceneObjectPart> primsWithInventory = new List<SceneObjectPart>(); |
182 | string qry = "select distinct primID from primitems"; | 183 | string qry = "select distinct \"primID\" from primitems"; |
183 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 184 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
184 | using (SqlCommand command = new SqlCommand(qry, conn)) | 185 | using (NpgsqlCommand command = new NpgsqlCommand(qry, conn)) |
185 | { | 186 | { |
186 | conn.Open(); | 187 | conn.Open(); |
187 | using (SqlDataReader itemReader = command.ExecuteReader()) | 188 | using (NpgsqlDataReader itemReader = command.ExecuteReader()) |
188 | { | 189 | { |
189 | while (itemReader.Read()) | 190 | while (itemReader.Read()) |
190 | { | 191 | { |
@@ -213,19 +214,19 @@ namespace OpenSim.Data.MSSQL | |||
213 | /// <param name="allPrims">all prims with inventory on a region</param> | 214 | /// <param name="allPrims">all prims with inventory on a region</param> |
214 | private void LoadItems(List<SceneObjectPart> allPrimsWithInventory) | 215 | private void LoadItems(List<SceneObjectPart> allPrimsWithInventory) |
215 | { | 216 | { |
216 | string sql = "SELECT * FROM primitems WHERE PrimID = @PrimID"; | 217 | string sql = @"SELECT * FROM primitems WHERE ""primID"" = :PrimID"; |
217 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 218 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
218 | using (SqlCommand command = new SqlCommand(sql, conn)) | 219 | using (NpgsqlCommand command = new NpgsqlCommand(sql, conn)) |
219 | { | 220 | { |
220 | conn.Open(); | 221 | conn.Open(); |
221 | foreach (SceneObjectPart objectPart in allPrimsWithInventory) | 222 | foreach (SceneObjectPart objectPart in allPrimsWithInventory) |
222 | { | 223 | { |
223 | command.Parameters.Clear(); | 224 | command.Parameters.Clear(); |
224 | command.Parameters.Add(_Database.CreateParameter("@PrimID", objectPart.UUID)); | 225 | command.Parameters.Add(_Database.CreateParameter("PrimID", objectPart.UUID)); |
225 | 226 | ||
226 | List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); | 227 | List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); |
227 | 228 | ||
228 | using (SqlDataReader reader = command.ExecuteReader()) | 229 | using (NpgsqlDataReader reader = command.ExecuteReader()) |
229 | { | 230 | { |
230 | while (reader.Read()) | 231 | while (reader.Read()) |
231 | { | 232 | { |
@@ -257,43 +258,43 @@ namespace OpenSim.Data.MSSQL | |||
257 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) | 258 | if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0) |
258 | return; | 259 | return; |
259 | 260 | ||
260 | _Log.DebugFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Parts.Length); | 261 | //_Log.DebugFormat("[PGSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Parts.Length); |
261 | 262 | ||
262 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 263 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
263 | { | 264 | { |
264 | conn.Open(); | 265 | conn.Open(); |
265 | SqlTransaction transaction = conn.BeginTransaction(); | 266 | NpgsqlTransaction transaction = conn.BeginTransaction(); |
266 | 267 | ||
267 | try | 268 | try |
268 | { | 269 | { |
269 | foreach (SceneObjectPart sceneObjectPart in obj.Parts) | 270 | foreach (SceneObjectPart sceneObjectPart in obj.Parts) |
270 | { | 271 | { |
271 | //Update prim | 272 | //Update prim |
272 | using (SqlCommand sqlCommand = conn.CreateCommand()) | 273 | using (NpgsqlCommand sqlCommand = conn.CreateCommand()) |
273 | { | 274 | { |
274 | sqlCommand.Transaction = transaction; | 275 | sqlCommand.Transaction = transaction; |
275 | try | 276 | try |
276 | { | 277 | { |
277 | StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); | 278 | StoreSceneObjectPrim(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); |
278 | } | 279 | } |
279 | catch (SqlException sqlEx) | 280 | catch (NpgsqlException sqlEx) |
280 | { | 281 | { |
281 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber); | 282 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrim SQL error: {0} at line {1}", sqlEx.Message, sqlEx.Line); |
282 | throw; | 283 | throw; |
283 | } | 284 | } |
284 | } | 285 | } |
285 | 286 | ||
286 | //Update primshapes | 287 | //Update primshapes |
287 | using (SqlCommand sqlCommand = conn.CreateCommand()) | 288 | using (NpgsqlCommand sqlCommand = conn.CreateCommand()) |
288 | { | 289 | { |
289 | sqlCommand.Transaction = transaction; | 290 | sqlCommand.Transaction = transaction; |
290 | try | 291 | try |
291 | { | 292 | { |
292 | StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); | 293 | StoreSceneObjectPrimShapes(sceneObjectPart, sqlCommand, obj.UUID, regionUUID); |
293 | } | 294 | } |
294 | catch (SqlException sqlEx) | 295 | catch (NpgsqlException sqlEx) |
295 | { | 296 | { |
296 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.LineNumber); | 297 | _Log.ErrorFormat("[REGION DB]: Store SceneObjectPrimShapes SQL error: {0} at line {1}", sqlEx.Message, sqlEx.Line); |
297 | throw; | 298 | throw; |
298 | } | 299 | } |
299 | } | 300 | } |
@@ -325,60 +326,59 @@ namespace OpenSim.Data.MSSQL | |||
325 | /// <param name="sqlCommand">The SQL command with the transaction.</param> | 326 | /// <param name="sqlCommand">The SQL command with the transaction.</param> |
326 | /// <param name="sceneGroupID">The scenegroup UUID.</param> | 327 | /// <param name="sceneGroupID">The scenegroup UUID.</param> |
327 | /// <param name="regionUUID">The region UUID.</param> | 328 | /// <param name="regionUUID">The region UUID.</param> |
328 | private void StoreSceneObjectPrim(SceneObjectPart sceneObjectPart, SqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) | 329 | private void StoreSceneObjectPrim(SceneObjectPart sceneObjectPart, NpgsqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) |
329 | { | 330 | { |
330 | //Big query to update or insert a new prim. | 331 | //Big query to update or insert a new prim. |
331 | //Note for SQL Server 2008 this could be simplified | 332 | |
332 | string queryPrims = @" | 333 | string queryPrims = @" |
333 | IF EXISTS (SELECT UUID FROM prims WHERE UUID = @UUID) | ||
334 | BEGIN | ||
335 | UPDATE prims SET | 334 | UPDATE prims SET |
336 | CreationDate = @CreationDate, Name = @Name, Text = @Text, Description = @Description, SitName = @SitName, | 335 | ""CreationDate"" = :CreationDate, ""Name"" = :Name, ""Text"" = :Text, ""Description"" = :Description, ""SitName"" = :SitName, |
337 | TouchName = @TouchName, ObjectFlags = @ObjectFlags, OwnerMask = @OwnerMask, NextOwnerMask = @NextOwnerMask, GroupMask = @GroupMask, | 336 | ""TouchName"" = :TouchName, ""ObjectFlags"" = :ObjectFlags, ""OwnerMask"" = :OwnerMask, ""NextOwnerMask"" = :NextOwnerMask, ""GroupMask"" = :GroupMask, |
338 | EveryoneMask = @EveryoneMask, BaseMask = @BaseMask, PositionX = @PositionX, PositionY = @PositionY, PositionZ = @PositionZ, | 337 | ""EveryoneMask"" = :EveryoneMask, ""BaseMask"" = :BaseMask, ""PositionX"" = :PositionX, ""PositionY"" = :PositionY, ""PositionZ"" = :PositionZ, |
339 | GroupPositionX = @GroupPositionX, GroupPositionY = @GroupPositionY, GroupPositionZ = @GroupPositionZ, VelocityX = @VelocityX, | 338 | ""GroupPositionX"" = :GroupPositionX, ""GroupPositionY"" = :GroupPositionY, ""GroupPositionZ"" = :GroupPositionZ, ""VelocityX"" = :VelocityX, |
340 | VelocityY = @VelocityY, VelocityZ = @VelocityZ, AngularVelocityX = @AngularVelocityX, AngularVelocityY = @AngularVelocityY, | 339 | ""VelocityY"" = :VelocityY, ""VelocityZ"" = :VelocityZ, ""AngularVelocityX"" = :AngularVelocityX, ""AngularVelocityY"" = :AngularVelocityY, |
341 | AngularVelocityZ = @AngularVelocityZ, AccelerationX = @AccelerationX, AccelerationY = @AccelerationY, | 340 | ""AngularVelocityZ"" = :AngularVelocityZ, ""AccelerationX"" = :AccelerationX, ""AccelerationY"" = :AccelerationY, |
342 | AccelerationZ = @AccelerationZ, RotationX = @RotationX, RotationY = @RotationY, RotationZ = @RotationZ, RotationW = @RotationW, | 341 | ""AccelerationZ"" = :AccelerationZ, ""RotationX"" = :RotationX, ""RotationY"" = :RotationY, ""RotationZ"" = :RotationZ, ""RotationW"" = :RotationW, |
343 | SitTargetOffsetX = @SitTargetOffsetX, SitTargetOffsetY = @SitTargetOffsetY, SitTargetOffsetZ = @SitTargetOffsetZ, | 342 | ""SitTargetOffsetX"" = :SitTargetOffsetX, ""SitTargetOffsetY"" = :SitTargetOffsetY, ""SitTargetOffsetZ"" = :SitTargetOffsetZ, |
344 | SitTargetOrientW = @SitTargetOrientW, SitTargetOrientX = @SitTargetOrientX, SitTargetOrientY = @SitTargetOrientY, | 343 | ""SitTargetOrientW"" = :SitTargetOrientW, ""SitTargetOrientX"" = :SitTargetOrientX, ""SitTargetOrientY"" = :SitTargetOrientY, |
345 | SitTargetOrientZ = @SitTargetOrientZ, RegionUUID = @RegionUUID, CreatorID = @CreatorID, OwnerID = @OwnerID, GroupID = @GroupID, | 344 | ""SitTargetOrientZ"" = :SitTargetOrientZ, ""RegionUUID"" = :RegionUUID, ""CreatorID"" = :CreatorID, ""OwnerID"" = :OwnerID, ""GroupID"" = :GroupID, |
346 | LastOwnerID = @LastOwnerID, SceneGroupID = @SceneGroupID, PayPrice = @PayPrice, PayButton1 = @PayButton1, PayButton2 = @PayButton2, | 345 | ""LastOwnerID"" = :LastOwnerID, ""SceneGroupID"" = :SceneGroupID, ""PayPrice"" = :PayPrice, ""PayButton1"" = :PayButton1, ""PayButton2"" = :PayButton2, |
347 | PayButton3 = @PayButton3, PayButton4 = @PayButton4, LoopedSound = @LoopedSound, LoopedSoundGain = @LoopedSoundGain, | 346 | ""PayButton3"" = :PayButton3, ""PayButton4"" = :PayButton4, ""LoopedSound"" = :LoopedSound, ""LoopedSoundGain"" = :LoopedSoundGain, |
348 | TextureAnimation = @TextureAnimation, OmegaX = @OmegaX, OmegaY = @OmegaY, OmegaZ = @OmegaZ, CameraEyeOffsetX = @CameraEyeOffsetX, | 347 | ""TextureAnimation"" = :TextureAnimation, ""OmegaX"" = :OmegaX, ""OmegaY"" = :OmegaY, ""OmegaZ"" = :OmegaZ, ""CameraEyeOffsetX"" = :CameraEyeOffsetX, |
349 | CameraEyeOffsetY = @CameraEyeOffsetY, CameraEyeOffsetZ = @CameraEyeOffsetZ, CameraAtOffsetX = @CameraAtOffsetX, | 348 | ""CameraEyeOffsetY"" = :CameraEyeOffsetY, ""CameraEyeOffsetZ"" = :CameraEyeOffsetZ, ""CameraAtOffsetX"" = :CameraAtOffsetX, |
350 | CameraAtOffsetY = @CameraAtOffsetY, CameraAtOffsetZ = @CameraAtOffsetZ, ForceMouselook = @ForceMouselook, | 349 | ""CameraAtOffsetY"" = :CameraAtOffsetY, ""CameraAtOffsetZ"" = :CameraAtOffsetZ, ""ForceMouselook"" = :ForceMouselook, |
351 | ScriptAccessPin = @ScriptAccessPin, AllowedDrop = @AllowedDrop, DieAtEdge = @DieAtEdge, SalePrice = @SalePrice, | 350 | ""ScriptAccessPin"" = :ScriptAccessPin, ""AllowedDrop"" = :AllowedDrop, ""DieAtEdge"" = :DieAtEdge, ""SalePrice"" = :SalePrice, |
352 | SaleType = @SaleType, ColorR = @ColorR, ColorG = @ColorG, ColorB = @ColorB, ColorA = @ColorA, ParticleSystem = @ParticleSystem, | 351 | ""SaleType"" = :SaleType, ""ColorR"" = :ColorR, ""ColorG"" = :ColorG, ""ColorB"" = :ColorB, ""ColorA"" = :ColorA, ""ParticleSystem"" = :ParticleSystem, |
353 | ClickAction = @ClickAction, Material = @Material, CollisionSound = @CollisionSound, CollisionSoundVolume = @CollisionSoundVolume, PassTouches = @PassTouches, | 352 | ""ClickAction"" = :ClickAction, ""Material"" = :Material, ""CollisionSound"" = :CollisionSound, ""CollisionSoundVolume"" = :CollisionSoundVolume, ""PassTouches"" = :PassTouches, |
354 | LinkNumber = @LinkNumber, MediaURL = @MediaURL | 353 | ""LinkNumber"" = :LinkNumber, ""MediaURL"" = :MediaURL, ""DynAttrs"" = :DynAttrs, |
355 | WHERE UUID = @UUID | 354 | ""PhysicsShapeType"" = :PhysicsShapeType, ""Density"" = :Density, ""GravityModifier"" = :GravityModifier, ""Friction"" = :Friction, ""Restitution"" = :Restitution |
356 | END | 355 | WHERE ""UUID"" = :UUID ; |
357 | ELSE | 356 | |
358 | BEGIN | ||
359 | INSERT INTO | 357 | INSERT INTO |
360 | prims ( | 358 | prims ( |
361 | UUID, CreationDate, Name, Text, Description, SitName, TouchName, ObjectFlags, OwnerMask, NextOwnerMask, GroupMask, | 359 | ""UUID"", ""CreationDate"", ""Name"", ""Text"", ""Description"", ""SitName"", ""TouchName"", ""ObjectFlags"", ""OwnerMask"", ""NextOwnerMask"", ""GroupMask"", |
362 | EveryoneMask, BaseMask, PositionX, PositionY, PositionZ, GroupPositionX, GroupPositionY, GroupPositionZ, VelocityX, | 360 | ""EveryoneMask"", ""BaseMask"", ""PositionX"", ""PositionY"", ""PositionZ"", ""GroupPositionX"", ""GroupPositionY"", ""GroupPositionZ"", ""VelocityX"", |
363 | VelocityY, VelocityZ, AngularVelocityX, AngularVelocityY, AngularVelocityZ, AccelerationX, AccelerationY, AccelerationZ, | 361 | ""VelocityY"", ""VelocityZ"", ""AngularVelocityX"", ""AngularVelocityY"", ""AngularVelocityZ"", ""AccelerationX"", ""AccelerationY"", ""AccelerationZ"", |
364 | RotationX, RotationY, RotationZ, RotationW, SitTargetOffsetX, SitTargetOffsetY, SitTargetOffsetZ, SitTargetOrientW, | 362 | ""RotationX"", ""RotationY"", ""RotationZ"", ""RotationW"", ""SitTargetOffsetX"", ""SitTargetOffsetY"", ""SitTargetOffsetZ"", ""SitTargetOrientW"", |
365 | SitTargetOrientX, SitTargetOrientY, SitTargetOrientZ, RegionUUID, CreatorID, OwnerID, GroupID, LastOwnerID, SceneGroupID, | 363 | ""SitTargetOrientX"", ""SitTargetOrientY"", ""SitTargetOrientZ"", ""RegionUUID"", ""CreatorID"", ""OwnerID"", ""GroupID"", ""LastOwnerID"", ""SceneGroupID"", |
366 | PayPrice, PayButton1, PayButton2, PayButton3, PayButton4, LoopedSound, LoopedSoundGain, TextureAnimation, OmegaX, | 364 | ""PayPrice"", ""PayButton1"", ""PayButton2"", ""PayButton3"", ""PayButton4"", ""LoopedSound"", ""LoopedSoundGain"", ""TextureAnimation"", ""OmegaX"", |
367 | OmegaY, OmegaZ, CameraEyeOffsetX, CameraEyeOffsetY, CameraEyeOffsetZ, CameraAtOffsetX, CameraAtOffsetY, CameraAtOffsetZ, | 365 | ""OmegaY"", ""OmegaZ"", ""CameraEyeOffsetX"", ""CameraEyeOffsetY"", ""CameraEyeOffsetZ"", ""CameraAtOffsetX"", ""CameraAtOffsetY"", ""CameraAtOffsetZ"", |
368 | ForceMouselook, ScriptAccessPin, AllowedDrop, DieAtEdge, SalePrice, SaleType, ColorR, ColorG, ColorB, ColorA, | 366 | ""ForceMouselook"", ""ScriptAccessPin"", ""AllowedDrop"", ""DieAtEdge"", ""SalePrice"", ""SaleType"", ""ColorR"", ""ColorG"", ""ColorB"", ""ColorA"", |
369 | ParticleSystem, ClickAction, Material, CollisionSound, CollisionSoundVolume, PassTouches, LinkNumber, MediaURL | 367 | ""ParticleSystem"", ""ClickAction"", ""Material"", ""CollisionSound"", ""CollisionSoundVolume"", ""PassTouches"", ""LinkNumber"", ""MediaURL"", ""DynAttrs"", |
370 | ) VALUES ( | 368 | ""PhysicsShapeType"", ""Density"", ""GravityModifier"", ""Friction"", ""Restitution"" |
371 | @UUID, @CreationDate, @Name, @Text, @Description, @SitName, @TouchName, @ObjectFlags, @OwnerMask, @NextOwnerMask, @GroupMask, | 369 | ) Select |
372 | @EveryoneMask, @BaseMask, @PositionX, @PositionY, @PositionZ, @GroupPositionX, @GroupPositionY, @GroupPositionZ, @VelocityX, | 370 | :UUID, :CreationDate, :Name, :Text, :Description, :SitName, :TouchName, :ObjectFlags, :OwnerMask, :NextOwnerMask, :GroupMask, |
373 | @VelocityY, @VelocityZ, @AngularVelocityX, @AngularVelocityY, @AngularVelocityZ, @AccelerationX, @AccelerationY, @AccelerationZ, | 371 | :EveryoneMask, :BaseMask, :PositionX, :PositionY, :PositionZ, :GroupPositionX, :GroupPositionY, :GroupPositionZ, :VelocityX, |
374 | @RotationX, @RotationY, @RotationZ, @RotationW, @SitTargetOffsetX, @SitTargetOffsetY, @SitTargetOffsetZ, @SitTargetOrientW, | 372 | :VelocityY, :VelocityZ, :AngularVelocityX, :AngularVelocityY, :AngularVelocityZ, :AccelerationX, :AccelerationY, :AccelerationZ, |
375 | @SitTargetOrientX, @SitTargetOrientY, @SitTargetOrientZ, @RegionUUID, @CreatorID, @OwnerID, @GroupID, @LastOwnerID, @SceneGroupID, | 373 | :RotationX, :RotationY, :RotationZ, :RotationW, :SitTargetOffsetX, :SitTargetOffsetY, :SitTargetOffsetZ, :SitTargetOrientW, |
376 | @PayPrice, @PayButton1, @PayButton2, @PayButton3, @PayButton4, @LoopedSound, @LoopedSoundGain, @TextureAnimation, @OmegaX, | 374 | :SitTargetOrientX, :SitTargetOrientY, :SitTargetOrientZ, :RegionUUID, :CreatorID, :OwnerID, :GroupID, :LastOwnerID, :SceneGroupID, |
377 | @OmegaY, @OmegaZ, @CameraEyeOffsetX, @CameraEyeOffsetY, @CameraEyeOffsetZ, @CameraAtOffsetX, @CameraAtOffsetY, @CameraAtOffsetZ, | 375 | :PayPrice, :PayButton1, :PayButton2, :PayButton3, :PayButton4, :LoopedSound, :LoopedSoundGain, :TextureAnimation, :OmegaX, |
378 | @ForceMouselook, @ScriptAccessPin, @AllowedDrop, @DieAtEdge, @SalePrice, @SaleType, @ColorR, @ColorG, @ColorB, @ColorA, | 376 | :OmegaY, :OmegaZ, :CameraEyeOffsetX, :CameraEyeOffsetY, :CameraEyeOffsetZ, :CameraAtOffsetX, :CameraAtOffsetY, :CameraAtOffsetZ, |
379 | @ParticleSystem, @ClickAction, @Material, @CollisionSound, @CollisionSoundVolume, @PassTouches, @LinkNumber, @MediaURL | 377 | :ForceMouselook, :ScriptAccessPin, :AllowedDrop, :DieAtEdge, :SalePrice, :SaleType, :ColorR, :ColorG, :ColorB, :ColorA, |
380 | ) | 378 | :ParticleSystem, :ClickAction, :Material, :CollisionSound, :CollisionSoundVolume, :PassTouches, :LinkNumber, :MediaURL, :DynAttrs, |
381 | END"; | 379 | :PhysicsShapeType, :Density, :GravityModifier, :Friction, :Restitution |
380 | where not EXISTS (SELECT ""UUID"" FROM prims WHERE ""UUID"" = :UUID); | ||
381 | "; | ||
382 | 382 | ||
383 | //Set commandtext. | 383 | //Set commandtext. |
384 | sqlCommand.CommandText = queryPrims; | 384 | sqlCommand.CommandText = queryPrims; |
@@ -396,35 +396,32 @@ ELSE | |||
396 | /// <param name="sqlCommand">The SQL command with the transaction.</param> | 396 | /// <param name="sqlCommand">The SQL command with the transaction.</param> |
397 | /// <param name="sceneGroupID">The scenegroup UUID.</param> | 397 | /// <param name="sceneGroupID">The scenegroup UUID.</param> |
398 | /// <param name="regionUUID">The region UUID.</param> | 398 | /// <param name="regionUUID">The region UUID.</param> |
399 | private void StoreSceneObjectPrimShapes(SceneObjectPart sceneObjectPart, SqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) | 399 | private void StoreSceneObjectPrimShapes(SceneObjectPart sceneObjectPart, NpgsqlCommand sqlCommand, UUID sceneGroupID, UUID regionUUID) |
400 | { | 400 | { |
401 | //Big query to or insert or update primshapes | 401 | //Big query to or insert or update primshapes |
402 | //Note for SQL Server 2008 this can be simplified | 402 | |
403 | string queryPrimShapes = @" | 403 | string queryPrimShapes = @" |
404 | IF EXISTS (SELECT UUID FROM primshapes WHERE UUID = @UUID) | ||
405 | BEGIN | ||
406 | UPDATE primshapes SET | 404 | UPDATE primshapes SET |
407 | Shape = @Shape, ScaleX = @ScaleX, ScaleY = @ScaleY, ScaleZ = @ScaleZ, PCode = @PCode, PathBegin = @PathBegin, | 405 | ""Shape"" = :Shape, ""ScaleX"" = :ScaleX, ""ScaleY"" = :ScaleY, ""ScaleZ"" = :ScaleZ, ""PCode"" = :PCode, ""PathBegin"" = :PathBegin, |
408 | PathEnd = @PathEnd, PathScaleX = @PathScaleX, PathScaleY = @PathScaleY, PathShearX = @PathShearX, PathShearY = @PathShearY, | 406 | ""PathEnd"" = :PathEnd, ""PathScaleX"" = :PathScaleX, ""PathScaleY"" = :PathScaleY, ""PathShearX"" = :PathShearX, ""PathShearY"" = :PathShearY, |
409 | PathSkew = @PathSkew, PathCurve = @PathCurve, PathRadiusOffset = @PathRadiusOffset, PathRevolutions = @PathRevolutions, | 407 | ""PathSkew"" = :PathSkew, ""PathCurve"" = :PathCurve, ""PathRadiusOffset"" = :PathRadiusOffset, ""PathRevolutions"" = :PathRevolutions, |
410 | PathTaperX = @PathTaperX, PathTaperY = @PathTaperY, PathTwist = @PathTwist, PathTwistBegin = @PathTwistBegin, | 408 | ""PathTaperX"" = :PathTaperX, ""PathTaperY"" = :PathTaperY, ""PathTwist"" = :PathTwist, ""PathTwistBegin"" = :PathTwistBegin, |
411 | ProfileBegin = @ProfileBegin, ProfileEnd = @ProfileEnd, ProfileCurve = @ProfileCurve, ProfileHollow = @ProfileHollow, | 409 | ""ProfileBegin"" = :ProfileBegin, ""ProfileEnd"" = :ProfileEnd, ""ProfileCurve"" = :ProfileCurve, ""ProfileHollow"" = :ProfileHollow, |
412 | Texture = @Texture, ExtraParams = @ExtraParams, State = @State, Media = @Media | 410 | ""Texture"" = :Texture, ""ExtraParams"" = :ExtraParams, ""State"" = :State, ""Media"" = :Media |
413 | WHERE UUID = @UUID | 411 | WHERE ""UUID"" = :UUID ; |
414 | END | 412 | |
415 | ELSE | ||
416 | BEGIN | ||
417 | INSERT INTO | 413 | INSERT INTO |
418 | primshapes ( | 414 | primshapes ( |
419 | UUID, Shape, ScaleX, ScaleY, ScaleZ, PCode, PathBegin, PathEnd, PathScaleX, PathScaleY, PathShearX, PathShearY, | 415 | ""UUID"", ""Shape"", ""ScaleX"", ""ScaleY"", ""ScaleZ"", ""PCode"", ""PathBegin"", ""PathEnd"", ""PathScaleX"", ""PathScaleY"", ""PathShearX"", ""PathShearY"", |
420 | PathSkew, PathCurve, PathRadiusOffset, PathRevolutions, PathTaperX, PathTaperY, PathTwist, PathTwistBegin, ProfileBegin, | 416 | ""PathSkew"", ""PathCurve"", ""PathRadiusOffset"", ""PathRevolutions"", ""PathTaperX"", ""PathTaperY"", ""PathTwist"", ""PathTwistBegin"", ""ProfileBegin"", |
421 | ProfileEnd, ProfileCurve, ProfileHollow, Texture, ExtraParams, State, Media | 417 | ""ProfileEnd"", ""ProfileCurve"", ""ProfileHollow"", ""Texture"", ""ExtraParams"", ""State"", ""Media"" |
422 | ) VALUES ( | 418 | ) |
423 | @UUID, @Shape, @ScaleX, @ScaleY, @ScaleZ, @PCode, @PathBegin, @PathEnd, @PathScaleX, @PathScaleY, @PathShearX, @PathShearY, | 419 | Select |
424 | @PathSkew, @PathCurve, @PathRadiusOffset, @PathRevolutions, @PathTaperX, @PathTaperY, @PathTwist, @PathTwistBegin, @ProfileBegin, | 420 | :UUID, :Shape, :ScaleX, :ScaleY, :ScaleZ, :PCode, :PathBegin, :PathEnd, :PathScaleX, :PathScaleY, :PathShearX, :PathShearY, |
425 | @ProfileEnd, @ProfileCurve, @ProfileHollow, @Texture, @ExtraParams, @State, @Media | 421 | :PathSkew, :PathCurve, :PathRadiusOffset, :PathRevolutions, :PathTaperX, :PathTaperY, :PathTwist, :PathTwistBegin, :ProfileBegin, |
426 | ) | 422 | :ProfileEnd, :ProfileCurve, :ProfileHollow, :Texture, :ExtraParams, :State, :Media |
427 | END"; | 423 | where not EXISTS (SELECT ""UUID"" FROM primshapes WHERE ""UUID"" = :UUID); |
424 | "; | ||
428 | 425 | ||
429 | //Set commandtext. | 426 | //Set commandtext. |
430 | sqlCommand.CommandText = queryPrimShapes; | 427 | sqlCommand.CommandText = queryPrimShapes; |
@@ -445,18 +442,18 @@ ELSE | |||
445 | /// <param name="regionUUID">regionUUID (is this used anyway</param> | 442 | /// <param name="regionUUID">regionUUID (is this used anyway</param> |
446 | public void RemoveObject(UUID objectID, UUID regionUUID) | 443 | public void RemoveObject(UUID objectID, UUID regionUUID) |
447 | { | 444 | { |
448 | _Log.InfoFormat("[MSSQL]: Removing obj: {0} from region: {1}", objectID, regionUUID); | 445 | //_Log.InfoFormat("[PGSQL]: Removing obj: {0} from region: {1}", objectID, regionUUID); |
449 | 446 | ||
450 | //Remove from prims and primsitem table | 447 | //Remove from prims and primsitem table |
451 | string sqlPrims = "DELETE FROM PRIMS WHERE SceneGroupID = @objectID"; | 448 | string sqlPrims = @"DELETE FROM PRIMS WHERE ""SceneGroupID"" = :objectID"; |
452 | string sqlPrimItems = "DELETE FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE SceneGroupID = @objectID)"; | 449 | string sqlPrimItems = @"DELETE FROM PRIMITEMS WHERE ""primID"" in (SELECT ""UUID"" FROM PRIMS WHERE ""SceneGroupID"" = :objectID)"; |
453 | string sqlPrimShapes = "DELETE FROM PRIMSHAPES WHERE uuid in (SELECT UUID FROM PRIMS WHERE SceneGroupID = @objectID)"; | 450 | string sqlPrimShapes = @"DELETE FROM PRIMSHAPES WHERE ""UUID"" in (SELECT ""UUID"" FROM PRIMS WHERE ""SceneGroupID"" = :objectID)"; |
454 | 451 | ||
455 | lock (_Database) | 452 | lock (_Database) |
456 | { | 453 | { |
457 | //Using the non transaction mode. | 454 | //Using the non transaction mode. |
458 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 455 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
459 | using (SqlCommand cmd = new SqlCommand()) | 456 | using (NpgsqlCommand cmd = new NpgsqlCommand()) |
460 | { | 457 | { |
461 | cmd.Connection = conn; | 458 | cmd.Connection = conn; |
462 | cmd.CommandText = sqlPrimShapes; | 459 | cmd.CommandText = sqlPrimShapes; |
@@ -482,31 +479,31 @@ ELSE | |||
482 | { | 479 | { |
483 | //_Log.InfoFormat("[REGION DB: Persisting Prim Inventory with prim ID {0}", primID); | 480 | //_Log.InfoFormat("[REGION DB: Persisting Prim Inventory with prim ID {0}", primID); |
484 | 481 | ||
485 | //Statement from MySQL section! | 482 | //Statement from PGSQL section! |
486 | // For now, we're just going to crudely remove all the previous inventory items | 483 | // For now, we're just going to crudely remove all the previous inventory items |
487 | // no matter whether they have changed or not, and replace them with the current set. | 484 | // no matter whether they have changed or not, and replace them with the current set. |
488 | 485 | ||
489 | //Delete everything from PrimID | 486 | //Delete everything from PrimID |
490 | //TODO add index on PrimID in DB, if not already exist | 487 | //TODO add index on PrimID in DB, if not already exist |
491 | 488 | ||
492 | string sql = "DELETE PRIMITEMS WHERE primID = @primID"; | 489 | string sql = @"delete from primitems where ""primID"" = :primID"; |
493 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 490 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
494 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 491 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
495 | { | 492 | { |
496 | cmd.Parameters.Add(_Database.CreateParameter("@primID", primID)); | 493 | cmd.Parameters.Add(_Database.CreateParameter("primID", primID)); |
497 | conn.Open(); | 494 | conn.Open(); |
498 | cmd.ExecuteNonQuery(); | 495 | cmd.ExecuteNonQuery(); |
499 | } | 496 | } |
500 | 497 | ||
501 | sql = | 498 | sql = |
502 | @"INSERT INTO primitems ( | 499 | @"INSERT INTO primitems ( |
503 | itemID,primID,assetID,parentFolderID,invType,assetType,name,description,creationDate,creatorID,ownerID,lastOwnerID,groupID, | 500 | ""itemID"",""primID"",""assetID"",""parentFolderID"",""invType"",""assetType"",""name"",""description"",""creationDate"",""creatorID"",""ownerID"",""lastOwnerID"",""groupID"", |
504 | nextPermissions,currentPermissions,basePermissions,everyonePermissions,groupPermissions,flags) | 501 | ""nextPermissions"",""currentPermissions"",""basePermissions"",""everyonePermissions"",""groupPermissions"",""flags"") |
505 | VALUES (@itemID,@primID,@assetID,@parentFolderID,@invType,@assetType,@name,@description,@creationDate,@creatorID,@ownerID, | 502 | VALUES (:itemID,:primID,:assetID,:parentFolderID,:invType,:assetType,:name,:description,:creationDate,:creatorID,:ownerID, |
506 | @lastOwnerID,@groupID,@nextPermissions,@currentPermissions,@basePermissions,@everyonePermissions,@groupPermissions,@flags)"; | 503 | :lastOwnerID,:groupID,:nextPermissions,:currentPermissions,:basePermissions,:everyonePermissions,:groupPermissions,:flags)"; |
507 | 504 | ||
508 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 505 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
509 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 506 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
510 | { | 507 | { |
511 | conn.Open(); | 508 | conn.Open(); |
512 | foreach (TaskInventoryItem taskItem in items) | 509 | foreach (TaskInventoryItem taskItem in items) |
@@ -527,43 +524,54 @@ ELSE | |||
527 | /// <returns></returns> | 524 | /// <returns></returns> |
528 | public double[,] LoadTerrain(UUID regionID) | 525 | public double[,] LoadTerrain(UUID regionID) |
529 | { | 526 | { |
530 | double[,] terrain = new double[(int)Constants.RegionSize, (int)Constants.RegionSize]; | 527 | double[,] ret = null; |
531 | terrain.Initialize(); | 528 | TerrainData terrData = LoadTerrain(regionID, (int)Constants.RegionSize, (int)Constants.RegionSize, (int)Constants.RegionHeight); |
529 | if (terrData != null) | ||
530 | ret = terrData.GetDoubles(); | ||
531 | return ret; | ||
532 | } | ||
533 | |||
534 | // Returns 'null' if region not found | ||
535 | public TerrainData LoadTerrain(UUID regionID, int pSizeX, int pSizeY, int pSizeZ) | ||
536 | { | ||
537 | TerrainData terrData = null; | ||
532 | 538 | ||
533 | string sql = "select top 1 RegionUUID, Revision, Heightfield from terrain where RegionUUID = @RegionUUID order by Revision desc"; | 539 | string sql = @"select ""RegionUUID"", ""Revision"", ""Heightfield"" from terrain |
540 | where ""RegionUUID"" = :RegionUUID order by ""Revision"" desc limit 1; "; | ||
534 | 541 | ||
535 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 542 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
536 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
537 | { | 543 | { |
538 | // MySqlParameter param = new MySqlParameter(); | 544 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
539 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | ||
540 | conn.Open(); | ||
541 | using (SqlDataReader reader = cmd.ExecuteReader()) | ||
542 | { | 545 | { |
543 | int rev; | 546 | // PGSqlParameter param = new PGSqlParameter(); |
544 | if (reader.Read()) | 547 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); |
548 | conn.Open(); | ||
549 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) | ||
545 | { | 550 | { |
546 | MemoryStream str = new MemoryStream((byte[])reader["Heightfield"]); | 551 | int rev; |
547 | BinaryReader br = new BinaryReader(str); | 552 | if (reader.Read()) |
548 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
549 | { | 553 | { |
550 | for (int y = 0; y < (int)Constants.RegionSize; y++) | 554 | rev = Convert.ToInt32(reader["Revision"]); |
551 | { | 555 | byte[] blob = (byte[])reader["Heightfield"]; |
552 | terrain[x, y] = br.ReadDouble(); | 556 | terrData = TerrainData.CreateFromDatabaseBlobFactory(pSizeX, pSizeY, pSizeZ, rev, blob); |
553 | } | ||
554 | } | 557 | } |
555 | rev = (int)reader["Revision"]; | 558 | else |
556 | } | 559 | { |
557 | else | 560 | _Log.Info("[REGION DB]: No terrain found for region"); |
558 | { | 561 | return null; |
559 | _Log.Info("[REGION DB]: No terrain found for region"); | 562 | } |
560 | return null; | 563 | _Log.Info("[REGION DB]: Loaded terrain revision r" + rev); |
561 | } | 564 | } |
562 | _Log.Info("[REGION DB]: Loaded terrain revision r" + rev); | ||
563 | } | 565 | } |
564 | } | 566 | } |
565 | 567 | ||
566 | return terrain; | 568 | return terrData; |
569 | } | ||
570 | |||
571 | // Legacy entry point for when terrain was always a 256x256 heightmap | ||
572 | public void StoreTerrain(double[,] terrain, UUID regionID) | ||
573 | { | ||
574 | StoreTerrain(new HeightmapTerrainData(terrain), regionID); | ||
567 | } | 575 | } |
568 | 576 | ||
569 | /// <summary> | 577 | /// <summary> |
@@ -571,33 +579,43 @@ ELSE | |||
571 | /// </summary> | 579 | /// </summary> |
572 | /// <param name="terrain">terrain map data.</param> | 580 | /// <param name="terrain">terrain map data.</param> |
573 | /// <param name="regionID">regionID.</param> | 581 | /// <param name="regionID">regionID.</param> |
574 | public void StoreTerrain(double[,] terrain, UUID regionID) | 582 | public void StoreTerrain(TerrainData terrData, UUID regionID) |
575 | { | 583 | { |
576 | int revision = Util.UnixTimeSinceEpoch(); | ||
577 | |||
578 | //Delete old terrain map | 584 | //Delete old terrain map |
579 | string sql = "delete from terrain where RegionUUID=@RegionUUID"; | 585 | string sql = @"delete from terrain where ""RegionUUID""=:RegionUUID"; |
580 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 586 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
581 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
582 | { | 587 | { |
583 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | 588 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
584 | conn.Open(); | 589 | { |
585 | cmd.ExecuteNonQuery(); | 590 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); |
591 | conn.Open(); | ||
592 | cmd.ExecuteNonQuery(); | ||
593 | |||
594 | _Log.InfoFormat("{0} Deleted terrain revision id = {1}", LogHeader, regionID); | ||
595 | } | ||
586 | } | 596 | } |
587 | 597 | ||
588 | sql = "insert into terrain(RegionUUID, Revision, Heightfield) values(@RegionUUID, @Revision, @Heightfield)"; | 598 | int terrainDBRevision; |
599 | Array terrainDBblob; | ||
600 | terrData.GetDatabaseBlob(out terrainDBRevision, out terrainDBblob); | ||
601 | |||
602 | sql = @"insert into terrain(""RegionUUID"", ""Revision"", ""Heightfield"") values(:RegionUUID, :Revision, :Heightfield)"; | ||
589 | 603 | ||
590 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 604 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
591 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | ||
592 | { | 605 | { |
593 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionID)); | 606 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
594 | cmd.Parameters.Add(_Database.CreateParameter("@Revision", revision)); | 607 | { |
595 | cmd.Parameters.Add(_Database.CreateParameter("@Heightfield", serializeTerrain(terrain))); | 608 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionID)); |
596 | conn.Open(); | 609 | cmd.Parameters.Add(_Database.CreateParameter("Revision", terrainDBRevision)); |
597 | cmd.ExecuteNonQuery(); | 610 | cmd.Parameters.Add(_Database.CreateParameter("Heightfield", terrainDBblob)); |
611 | conn.Open(); | ||
612 | cmd.ExecuteNonQuery(); | ||
613 | |||
614 | _Log.InfoFormat("{0} Stored terrain id = {1}, terrainSize = <{2},{3}>", | ||
615 | LogHeader, regionID, terrData.SizeX, terrData.SizeY); | ||
616 | } | ||
598 | } | 617 | } |
599 | 618 | ||
600 | _Log.Info("[REGION DB]: Stored terrain revision r " + revision); | ||
601 | } | 619 | } |
602 | 620 | ||
603 | /// <summary> | 621 | /// <summary> |
@@ -609,15 +627,15 @@ ELSE | |||
609 | { | 627 | { |
610 | List<LandData> LandDataForRegion = new List<LandData>(); | 628 | List<LandData> LandDataForRegion = new List<LandData>(); |
611 | 629 | ||
612 | string sql = "select * from land where RegionUUID = @RegionUUID"; | 630 | string sql = @"select * from land where ""RegionUUID"" = :RegionUUID"; |
613 | 631 | ||
614 | //Retrieve all land data from region | 632 | //Retrieve all land data from region |
615 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 633 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
616 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 634 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
617 | { | 635 | { |
618 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", regionUUID)); | 636 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); |
619 | conn.Open(); | 637 | conn.Open(); |
620 | using (SqlDataReader readerLandData = cmd.ExecuteReader()) | 638 | using (NpgsqlDataReader readerLandData = cmd.ExecuteReader()) |
621 | { | 639 | { |
622 | while (readerLandData.Read()) | 640 | while (readerLandData.Read()) |
623 | { | 641 | { |
@@ -629,13 +647,13 @@ ELSE | |||
629 | //Retrieve all accesslist data for all landdata | 647 | //Retrieve all accesslist data for all landdata |
630 | foreach (LandData LandData in LandDataForRegion) | 648 | foreach (LandData LandData in LandDataForRegion) |
631 | { | 649 | { |
632 | sql = "select * from landaccesslist where LandUUID = @LandUUID"; | 650 | sql = @"select * from landaccesslist where ""LandUUID"" = :LandUUID"; |
633 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 651 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
634 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 652 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
635 | { | 653 | { |
636 | cmd.Parameters.Add(_Database.CreateParameter("@LandUUID", LandData.GlobalID)); | 654 | cmd.Parameters.Add(_Database.CreateParameter("LandUUID", LandData.GlobalID)); |
637 | conn.Open(); | 655 | conn.Open(); |
638 | using (SqlDataReader readerAccessList = cmd.ExecuteReader()) | 656 | using (NpgsqlDataReader readerAccessList = cmd.ExecuteReader()) |
639 | { | 657 | { |
640 | while (readerAccessList.Read()) | 658 | while (readerAccessList.Read()) |
641 | { | 659 | { |
@@ -656,29 +674,33 @@ ELSE | |||
656 | public void StoreLandObject(ILandObject parcel) | 674 | public void StoreLandObject(ILandObject parcel) |
657 | { | 675 | { |
658 | //As this is only one record in land table I just delete all and then add a new record. | 676 | //As this is only one record in land table I just delete all and then add a new record. |
659 | //As the delete landaccess is already in the mysql code | 677 | //As the delete landaccess is already in the pgsql code |
660 | 678 | ||
661 | //Delete old values | 679 | //Delete old values |
662 | RemoveLandObject(parcel.LandData.GlobalID); | 680 | RemoveLandObject(parcel.LandData.GlobalID); |
663 | 681 | ||
664 | //Insert new values | 682 | //Insert new values |
665 | string sql = @"INSERT INTO [land] | 683 | string sql = @"INSERT INTO land |
666 | ([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]) | 684 | (""UUID"",""RegionUUID"",""LocalLandID"",""Bitmap"",""Name"",""Description"",""OwnerUUID"",""IsGroupOwned"",""Area"",""AuctionID"",""Category"",""ClaimDate"",""ClaimPrice"", |
667 | VALUES | 685 | ""GroupUUID"",""SalePrice"",""LandStatus"",""LandFlags"",""LandingType"",""MediaAutoScale"",""MediaTextureUUID"",""MediaURL"",""MusicURL"",""PassHours"",""PassPrice"", |
668 | (@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)"; | 686 | ""SnapshotUUID"",""UserLocationX"",""UserLocationY"",""UserLocationZ"",""UserLookAtX"",""UserLookAtY"",""UserLookAtZ"",""AuthbuyerID"",""OtherCleanTime"") |
669 | 687 | VALUES | |
670 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 688 | (:UUID,:RegionUUID,:LocalLandID,:Bitmap,:Name,:Description,:OwnerUUID,:IsGroupOwned,:Area,:AuctionID,:Category,:ClaimDate,:ClaimPrice, |
671 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 689 | :GroupUUID,:SalePrice,:LandStatus,:LandFlags,:LandingType,:MediaAutoScale,:MediaTextureUUID,:MediaURL,:MusicURL,:PassHours,:PassPrice, |
690 | :SnapshotUUID,:UserLocationX,:UserLocationY,:UserLocationZ,:UserLookAtX,:UserLookAtY,:UserLookAtZ,:AuthbuyerID,:OtherCleanTime)"; | ||
691 | |||
692 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
693 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
672 | { | 694 | { |
673 | cmd.Parameters.AddRange(CreateLandParameters(parcel.LandData, parcel.RegionUUID)); | 695 | cmd.Parameters.AddRange(CreateLandParameters(parcel.LandData, parcel.RegionUUID)); |
674 | conn.Open(); | 696 | conn.Open(); |
675 | cmd.ExecuteNonQuery(); | 697 | cmd.ExecuteNonQuery(); |
676 | } | 698 | } |
677 | 699 | ||
678 | sql = "INSERT INTO [landaccesslist] ([LandUUID],[AccessUUID],[Flags],[Expires]) VALUES (@LandUUID,@AccessUUID,@Flags,@Expires)"; | 700 | sql = @"INSERT INTO landaccesslist (""LandUUID"",""AccessUUID"",""LandFlags"",""Expires"") VALUES (:LandUUID,:AccessUUID,:Flags,:Expires)"; |
679 | 701 | ||
680 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 702 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
681 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 703 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
682 | { | 704 | { |
683 | conn.Open(); | 705 | conn.Open(); |
684 | foreach (LandAccessEntry parcelAccessEntry in parcel.LandData.ParcelAccessList) | 706 | foreach (LandAccessEntry parcelAccessEntry in parcel.LandData.ParcelAccessList) |
@@ -697,19 +719,19 @@ VALUES | |||
697 | /// <param name="globalID">UUID of landobject</param> | 719 | /// <param name="globalID">UUID of landobject</param> |
698 | public void RemoveLandObject(UUID globalID) | 720 | public void RemoveLandObject(UUID globalID) |
699 | { | 721 | { |
700 | string sql = "delete from land where UUID=@UUID"; | 722 | string sql = @"delete from land where ""UUID""=:UUID"; |
701 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 723 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
702 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 724 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
703 | { | 725 | { |
704 | cmd.Parameters.Add(_Database.CreateParameter("@UUID", globalID)); | 726 | cmd.Parameters.Add(_Database.CreateParameter("UUID", globalID)); |
705 | conn.Open(); | 727 | conn.Open(); |
706 | cmd.ExecuteNonQuery(); | 728 | cmd.ExecuteNonQuery(); |
707 | } | 729 | } |
708 | sql = "delete from landaccesslist where LandUUID=@UUID"; | 730 | sql = @"delete from landaccesslist where ""LandUUID""=:UUID"; |
709 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 731 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
710 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 732 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
711 | { | 733 | { |
712 | cmd.Parameters.Add(_Database.CreateParameter("@UUID", globalID)); | 734 | cmd.Parameters.Add(_Database.CreateParameter("UUID", globalID)); |
713 | conn.Open(); | 735 | conn.Open(); |
714 | cmd.ExecuteNonQuery(); | 736 | cmd.ExecuteNonQuery(); |
715 | } | 737 | } |
@@ -718,13 +740,15 @@ VALUES | |||
718 | { | 740 | { |
719 | RegionLightShareData nWP = new RegionLightShareData(); | 741 | RegionLightShareData nWP = new RegionLightShareData(); |
720 | nWP.OnSave += StoreRegionWindlightSettings; | 742 | nWP.OnSave += StoreRegionWindlightSettings; |
721 | string sql = "select * from [regionwindlight] where region_id = @regionID"; | 743 | |
722 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 744 | string sql = @"select * from regionwindlight where ""region_id"" = :regionID"; |
723 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 745 | |
746 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
747 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
724 | { | 748 | { |
725 | cmd.Parameters.Add(_Database.CreateParameter("@regionID", regionUUID)); | 749 | cmd.Parameters.Add(_Database.CreateParameter("regionID", regionUUID.ToString() )); |
726 | conn.Open(); | 750 | conn.Open(); |
727 | using (SqlDataReader result = cmd.ExecuteReader()) | 751 | using (NpgsqlDataReader result = cmd.ExecuteReader()) |
728 | { | 752 | { |
729 | if (!result.Read()) | 753 | if (!result.Read()) |
730 | { | 754 | { |
@@ -807,27 +831,28 @@ VALUES | |||
807 | 831 | ||
808 | public void RemoveRegionWindlightSettings(UUID regionID) | 832 | public void RemoveRegionWindlightSettings(UUID regionID) |
809 | { | 833 | { |
810 | string sql = "delete from [regionwindlight] where region_id = @region_id"; | 834 | string sql = @"delete from regionwindlight where ""region_id"" = :region_id"; |
811 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 835 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
812 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 836 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
813 | { | 837 | { |
814 | conn.Open(); | 838 | conn.Open(); |
815 | cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionID)); | 839 | cmd.Parameters.Add(_Database.CreateParameter("region_id", regionID.ToString())); |
816 | cmd.ExecuteNonQuery(); | 840 | cmd.ExecuteNonQuery(); |
817 | } | 841 | } |
818 | } | 842 | } |
819 | 843 | ||
820 | public void StoreRegionWindlightSettings(RegionLightShareData wl) | 844 | public void StoreRegionWindlightSettings(RegionLightShareData wl) |
821 | { | 845 | { |
822 | string sql = "select count (region_id) from regionwindlight where region_id = @region_id"; | 846 | string sql = @"select region_id from regionwindlight where ""region_id"" = :region_id limit 1;"; |
823 | bool exists = false; | 847 | bool exists = false; |
824 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 848 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
825 | { | 849 | { |
826 | conn.Open(); | 850 | conn.Open(); |
827 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 851 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
828 | { | 852 | { |
829 | cmd.Parameters.Add(_Database.CreateParameter("@region_id", wl.regionID)); | 853 | cmd.Parameters.Add(_Database.CreateParameter("region_id", wl.regionID.ToString() )); |
830 | exists = (int)cmd.ExecuteScalar() > 0; | 854 | NpgsqlDataReader dr = cmd.ExecuteReader(); |
855 | exists = dr.Read(); | ||
831 | } | 856 | } |
832 | } | 857 | } |
833 | if (exists) | 858 | if (exists) |
@@ -836,140 +861,141 @@ VALUES | |||
836 | } | 861 | } |
837 | 862 | ||
838 | // sql insert | 863 | // sql insert |
839 | sql = @"INSERT INTO [regionwindlight] | 864 | sql = @"INSERT INTO regionwindlight |
840 | ([region_id] | 865 | (region_id |
841 | ,[water_color_r] | 866 | ,water_color_r |
842 | ,[water_color_g] | 867 | ,water_color_g |
843 | ,[water_color_b] | 868 | ,water_color_b |
844 | ,[water_fog_density_exponent] | 869 | ,water_fog_density_exponent |
845 | ,[underwater_fog_modifier] | 870 | ,underwater_fog_modifier |
846 | ,[reflection_wavelet_scale_1] | 871 | ,reflection_wavelet_scale_1 |
847 | ,[reflection_wavelet_scale_2] | 872 | ,reflection_wavelet_scale_2 |
848 | ,[reflection_wavelet_scale_3] | 873 | ,reflection_wavelet_scale_3 |
849 | ,[fresnel_scale] | 874 | ,fresnel_scale |
850 | ,[fresnel_offset] | 875 | ,fresnel_offset |
851 | ,[refract_scale_above] | 876 | ,refract_scale_above |
852 | ,[refract_scale_below] | 877 | ,refract_scale_below |
853 | ,[blur_multiplier] | 878 | ,blur_multiplier |
854 | ,[big_wave_direction_x] | 879 | ,big_wave_direction_x |
855 | ,[big_wave_direction_y] | 880 | ,big_wave_direction_y |
856 | ,[little_wave_direction_x] | 881 | ,little_wave_direction_x |
857 | ,[little_wave_direction_y] | 882 | ,little_wave_direction_y |
858 | ,[normal_map_texture] | 883 | ,normal_map_texture |
859 | ,[horizon_r] | 884 | ,horizon_r |
860 | ,[horizon_g] | 885 | ,horizon_g |
861 | ,[horizon_b] | 886 | ,horizon_b |
862 | ,[horizon_i] | 887 | ,horizon_i |
863 | ,[haze_horizon] | 888 | ,haze_horizon |
864 | ,[blue_density_r] | 889 | ,blue_density_r |
865 | ,[blue_density_g] | 890 | ,blue_density_g |
866 | ,[blue_density_b] | 891 | ,blue_density_b |
867 | ,[blue_density_i] | 892 | ,blue_density_i |
868 | ,[haze_density] | 893 | ,haze_density |
869 | ,[density_multiplier] | 894 | ,density_multiplier |
870 | ,[distance_multiplier] | 895 | ,distance_multiplier |
871 | ,[max_altitude] | 896 | ,max_altitude |
872 | ,[sun_moon_color_r] | 897 | ,sun_moon_color_r |
873 | ,[sun_moon_color_g] | 898 | ,sun_moon_color_g |
874 | ,[sun_moon_color_b] | 899 | ,sun_moon_color_b |
875 | ,[sun_moon_color_i] | 900 | ,sun_moon_color_i |
876 | ,[sun_moon_position] | 901 | ,sun_moon_position |
877 | ,[ambient_r] | 902 | ,ambient_r |
878 | ,[ambient_g] | 903 | ,ambient_g |
879 | ,[ambient_b] | 904 | ,ambient_b |
880 | ,[ambient_i] | 905 | ,ambient_i |
881 | ,[east_angle] | 906 | ,east_angle |
882 | ,[sun_glow_focus] | 907 | ,sun_glow_focus |
883 | ,[sun_glow_size] | 908 | ,sun_glow_size |
884 | ,[scene_gamma] | 909 | ,scene_gamma |
885 | ,[star_brightness] | 910 | ,star_brightness |
886 | ,[cloud_color_r] | 911 | ,cloud_color_r |
887 | ,[cloud_color_g] | 912 | ,cloud_color_g |
888 | ,[cloud_color_b] | 913 | ,cloud_color_b |
889 | ,[cloud_color_i] | 914 | ,cloud_color_i |
890 | ,[cloud_x] | 915 | ,cloud_x |
891 | ,[cloud_y] | 916 | ,cloud_y |
892 | ,[cloud_density] | 917 | ,cloud_density |
893 | ,[cloud_coverage] | 918 | ,cloud_coverage |
894 | ,[cloud_scale] | 919 | ,cloud_scale |
895 | ,[cloud_detail_x] | 920 | ,cloud_detail_x |
896 | ,[cloud_detail_y] | 921 | ,cloud_detail_y |
897 | ,[cloud_detail_density] | 922 | ,cloud_detail_density |
898 | ,[cloud_scroll_x] | 923 | ,cloud_scroll_x |
899 | ,[cloud_scroll_x_lock] | 924 | ,cloud_scroll_x_lock |
900 | ,[cloud_scroll_y] | 925 | ,cloud_scroll_y |
901 | ,[cloud_scroll_y_lock] | 926 | ,cloud_scroll_y_lock |
902 | ,[draw_classic_clouds]) | 927 | ,draw_classic_clouds) |
903 | VALUES | 928 | VALUES |
904 | (@region_id | 929 | (:region_id |
905 | ,@water_color_r | 930 | ,:water_color_r |
906 | ,@water_color_g | 931 | ,:water_color_g |
907 | ,@water_color_b | 932 | ,:water_color_b |
908 | ,@water_fog_density_exponent | 933 | ,:water_fog_density_exponent |
909 | ,@underwater_fog_modifier | 934 | ,:underwater_fog_modifier |
910 | ,@reflection_wavelet_scale_1 | 935 | ,:reflection_wavelet_scale_1 |
911 | ,@reflection_wavelet_scale_2 | 936 | ,:reflection_wavelet_scale_2 |
912 | ,@reflection_wavelet_scale_3 | 937 | ,:reflection_wavelet_scale_3 |
913 | ,@fresnel_scale | 938 | ,:fresnel_scale |
914 | ,@fresnel_offset | 939 | ,:fresnel_offset |
915 | ,@refract_scale_above | 940 | ,:refract_scale_above |
916 | ,@refract_scale_below | 941 | ,:refract_scale_below |
917 | ,@blur_multiplier | 942 | ,:blur_multiplier |
918 | ,@big_wave_direction_x | 943 | ,:big_wave_direction_x |
919 | ,@big_wave_direction_y | 944 | ,:big_wave_direction_y |
920 | ,@little_wave_direction_x | 945 | ,:little_wave_direction_x |
921 | ,@little_wave_direction_y | 946 | ,:little_wave_direction_y |
922 | ,@normal_map_texture | 947 | ,:normal_map_texture |
923 | ,@horizon_r | 948 | ,:horizon_r |
924 | ,@horizon_g | 949 | ,:horizon_g |
925 | ,@horizon_b | 950 | ,:horizon_b |
926 | ,@horizon_i | 951 | ,:horizon_i |
927 | ,@haze_horizon | 952 | ,:haze_horizon |
928 | ,@blue_density_r | 953 | ,:blue_density_r |
929 | ,@blue_density_g | 954 | ,:blue_density_g |
930 | ,@blue_density_b | 955 | ,:blue_density_b |
931 | ,@blue_density_i | 956 | ,:blue_density_i |
932 | ,@haze_density | 957 | ,:haze_density |
933 | ,@density_multiplier | 958 | ,:density_multiplier |
934 | ,@distance_multiplier | 959 | ,:distance_multiplier |
935 | ,@max_altitude | 960 | ,:max_altitude |
936 | ,@sun_moon_color_r | 961 | ,:sun_moon_color_r |
937 | ,@sun_moon_color_g | 962 | ,:sun_moon_color_g |
938 | ,@sun_moon_color_b | 963 | ,:sun_moon_color_b |
939 | ,@sun_moon_color_i | 964 | ,:sun_moon_color_i |
940 | ,@sun_moon_position | 965 | ,:sun_moon_position |
941 | ,@ambient_r | 966 | ,:ambient_r |
942 | ,@ambient_g | 967 | ,:ambient_g |
943 | ,@ambient_b | 968 | ,:ambient_b |
944 | ,@ambient_i | 969 | ,:ambient_i |
945 | ,@east_angle | 970 | ,:east_angle |
946 | ,@sun_glow_focus | 971 | ,:sun_glow_focus |
947 | ,@sun_glow_size | 972 | ,:sun_glow_size |
948 | ,@scene_gamma | 973 | ,:scene_gamma |
949 | ,@star_brightness | 974 | ,:star_brightness |
950 | ,@cloud_color_r | 975 | ,:cloud_color_r |
951 | ,@cloud_color_g | 976 | ,:cloud_color_g |
952 | ,@cloud_color_b | 977 | ,:cloud_color_b |
953 | ,@cloud_color_i | 978 | ,:cloud_color_i |
954 | ,@cloud_x | 979 | ,:cloud_x |
955 | ,@cloud_y | 980 | ,:cloud_y |
956 | ,@cloud_density | 981 | ,:cloud_density |
957 | ,@cloud_coverage | 982 | ,:cloud_coverage |
958 | ,@cloud_scale | 983 | ,:cloud_scale |
959 | ,@cloud_detail_x | 984 | ,:cloud_detail_x |
960 | ,@cloud_detail_y | 985 | ,:cloud_detail_y |
961 | ,@cloud_detail_density | 986 | ,:cloud_detail_density |
962 | ,@cloud_scroll_x | 987 | ,:cloud_scroll_x |
963 | ,@cloud_scroll_x_lock | 988 | ,:cloud_scroll_x_lock |
964 | ,@cloud_scroll_y | 989 | ,:cloud_scroll_y |
965 | ,@cloud_scroll_y_lock | 990 | ,:cloud_scroll_y_lock |
966 | ,@draw_classic_clouds)"; | 991 | ,:draw_classic_clouds);"; |
967 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 992 | |
993 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
968 | { | 994 | { |
969 | conn.Open(); | 995 | conn.Open(); |
970 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 996 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
971 | { | 997 | { |
972 | cmd.Parameters.Add(_Database.CreateParameter("region_id", wl.regionID)); | 998 | cmd.Parameters.Add(_Database.CreateParameter("region_id", wl.regionID.ToString())); |
973 | cmd.Parameters.Add(_Database.CreateParameter("water_color_r", wl.waterColor.X)); | 999 | cmd.Parameters.Add(_Database.CreateParameter("water_color_r", wl.waterColor.X)); |
974 | cmd.Parameters.Add(_Database.CreateParameter("water_color_g", wl.waterColor.Y)); | 1000 | cmd.Parameters.Add(_Database.CreateParameter("water_color_g", wl.waterColor.Y)); |
975 | cmd.Parameters.Add(_Database.CreateParameter("water_color_b", wl.waterColor.Z)); | 1001 | cmd.Parameters.Add(_Database.CreateParameter("water_color_b", wl.waterColor.Z)); |
@@ -987,7 +1013,7 @@ VALUES | |||
987 | cmd.Parameters.Add(_Database.CreateParameter("big_wave_direction_y", wl.bigWaveDirection.Y)); | 1013 | cmd.Parameters.Add(_Database.CreateParameter("big_wave_direction_y", wl.bigWaveDirection.Y)); |
988 | cmd.Parameters.Add(_Database.CreateParameter("little_wave_direction_x", wl.littleWaveDirection.X)); | 1014 | cmd.Parameters.Add(_Database.CreateParameter("little_wave_direction_x", wl.littleWaveDirection.X)); |
989 | cmd.Parameters.Add(_Database.CreateParameter("little_wave_direction_y", wl.littleWaveDirection.Y)); | 1015 | cmd.Parameters.Add(_Database.CreateParameter("little_wave_direction_y", wl.littleWaveDirection.Y)); |
990 | cmd.Parameters.Add(_Database.CreateParameter("normal_map_texture", wl.normalMapTexture)); | 1016 | cmd.Parameters.Add(_Database.CreateParameter("normal_map_texture", wl.normalMapTexture.ToString())); |
991 | cmd.Parameters.Add(_Database.CreateParameter("horizon_r", wl.horizon.X)); | 1017 | cmd.Parameters.Add(_Database.CreateParameter("horizon_r", wl.horizon.X)); |
992 | cmd.Parameters.Add(_Database.CreateParameter("horizon_g", wl.horizon.Y)); | 1018 | cmd.Parameters.Add(_Database.CreateParameter("horizon_g", wl.horizon.Y)); |
993 | cmd.Parameters.Add(_Database.CreateParameter("horizon_b", wl.horizon.Z)); | 1019 | cmd.Parameters.Add(_Database.CreateParameter("horizon_b", wl.horizon.Z)); |
@@ -1185,13 +1211,13 @@ VALUES | |||
1185 | #region Environment Settings | 1211 | #region Environment Settings |
1186 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | 1212 | public string LoadRegionEnvironmentSettings(UUID regionUUID) |
1187 | { | 1213 | { |
1188 | string sql = "select * from [regionenvironment] where region_id = @region_id"; | 1214 | string sql = "select * from regionenvironment where region_id = :region_id"; |
1189 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1215 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
1190 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1216 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
1191 | { | 1217 | { |
1192 | cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID)); | 1218 | cmd.Parameters.Add(_Database.CreateParameter("region_id", regionUUID)); |
1193 | conn.Open(); | 1219 | conn.Open(); |
1194 | using (SqlDataReader result = cmd.ExecuteReader()) | 1220 | using (NpgsqlDataReader result = cmd.ExecuteReader()) |
1195 | { | 1221 | { |
1196 | if (!result.Read()) | 1222 | if (!result.Read()) |
1197 | { | 1223 | { |
@@ -1208,24 +1234,23 @@ VALUES | |||
1208 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | 1234 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) |
1209 | { | 1235 | { |
1210 | { | 1236 | { |
1211 | string sql = "DELETE FROM [regionenvironment] WHERE region_id = @region_id"; | 1237 | string sql = "DELETE FROM regionenvironment WHERE region_id = :region_id ;"; |
1212 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1238 | |
1213 | 1239 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | |
1214 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1240 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
1215 | { | 1241 | { |
1216 | cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID)); | 1242 | cmd.Parameters.Add(_Database.CreateParameter("region_id", regionUUID)); |
1217 | conn.Open(); | 1243 | conn.Open(); |
1218 | cmd.ExecuteNonQuery(); | 1244 | cmd.ExecuteNonQuery(); |
1219 | } | 1245 | } |
1220 | 1246 | ||
1221 | sql = "INSERT INTO [regionenvironment] (region_id, llsd_settings) VALUES (@region_id, @llsd_settings)"; | 1247 | sql = "INSERT INTO regionenvironment (region_id, llsd_settings) VALUES (:region_id, :llsd_settings) ;"; |
1222 | |||
1223 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | ||
1224 | 1248 | ||
1225 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1249 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
1250 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
1226 | { | 1251 | { |
1227 | cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID)); | 1252 | cmd.Parameters.Add(_Database.CreateParameter("region_id", regionUUID)); |
1228 | cmd.Parameters.Add(_Database.CreateParameter("@llsd_settings", settings)); | 1253 | cmd.Parameters.Add(_Database.CreateParameter("llsd_settings", settings)); |
1229 | 1254 | ||
1230 | conn.Open(); | 1255 | conn.Open(); |
1231 | cmd.ExecuteNonQuery(); | 1256 | cmd.ExecuteNonQuery(); |
@@ -1235,11 +1260,11 @@ VALUES | |||
1235 | 1260 | ||
1236 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | 1261 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) |
1237 | { | 1262 | { |
1238 | string sql = "delete from [regionenvironment] where region_id = @region_id"; | 1263 | string sql = "delete from regionenvironment where region_id = :region_id ;"; |
1239 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1264 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
1240 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1265 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
1241 | { | 1266 | { |
1242 | cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionUUID)); | 1267 | cmd.Parameters.Add(_Database.CreateParameter("region_id", regionUUID)); |
1243 | 1268 | ||
1244 | conn.Open(); | 1269 | conn.Open(); |
1245 | cmd.ExecuteNonQuery(); | 1270 | cmd.ExecuteNonQuery(); |
@@ -1254,14 +1279,14 @@ VALUES | |||
1254 | /// <returns></returns> | 1279 | /// <returns></returns> |
1255 | public RegionSettings LoadRegionSettings(UUID regionUUID) | 1280 | public RegionSettings LoadRegionSettings(UUID regionUUID) |
1256 | { | 1281 | { |
1257 | string sql = "select * from regionsettings where regionUUID = @regionUUID"; | 1282 | string sql = @"select * from regionsettings where ""regionUUID"" = :regionUUID"; |
1258 | RegionSettings regionSettings; | 1283 | RegionSettings regionSettings; |
1259 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1284 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
1260 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1285 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
1261 | { | 1286 | { |
1262 | cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionUUID)); | 1287 | cmd.Parameters.Add(_Database.CreateParameter("regionUUID", regionUUID)); |
1263 | conn.Open(); | 1288 | conn.Open(); |
1264 | using (SqlDataReader reader = cmd.ExecuteReader()) | 1289 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
1265 | { | 1290 | { |
1266 | if (reader.Read()) | 1291 | if (reader.Read()) |
1267 | { | 1292 | { |
@@ -1294,11 +1319,11 @@ VALUES | |||
1294 | { | 1319 | { |
1295 | //Little check if regionUUID already exist in DB | 1320 | //Little check if regionUUID already exist in DB |
1296 | string regionUUID; | 1321 | string regionUUID; |
1297 | string sql = "SELECT regionUUID FROM regionsettings WHERE regionUUID = @regionUUID"; | 1322 | string sql = @"SELECT ""regionUUID"" FROM regionsettings WHERE ""regionUUID"" = :regionUUID"; |
1298 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1323 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
1299 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1324 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
1300 | { | 1325 | { |
1301 | cmd.Parameters.Add(_Database.CreateParameter("@regionUUID", regionSettings.RegionUUID)); | 1326 | cmd.Parameters.Add(_Database.CreateParameter("regionUUID", regionSettings.RegionUUID)); |
1302 | conn.Open(); | 1327 | conn.Open(); |
1303 | regionUUID = cmd.ExecuteScalar().ToString(); | 1328 | regionUUID = cmd.ExecuteScalar().ToString(); |
1304 | } | 1329 | } |
@@ -1311,20 +1336,22 @@ VALUES | |||
1311 | { | 1336 | { |
1312 | //This method only updates region settings!!! First call LoadRegionSettings to create new region settings in DB | 1337 | //This method only updates region settings!!! First call LoadRegionSettings to create new region settings in DB |
1313 | sql = | 1338 | sql = |
1314 | @"UPDATE [regionsettings] SET [block_terraform] = @block_terraform ,[block_fly] = @block_fly ,[allow_damage] = @allow_damage | 1339 | @"UPDATE regionsettings SET block_terraform = :block_terraform ,block_fly = :block_fly ,allow_damage = :allow_damage |
1315 | ,[restrict_pushing] = @restrict_pushing ,[allow_land_resell] = @allow_land_resell ,[allow_land_join_divide] = @allow_land_join_divide | 1340 | ,restrict_pushing = :restrict_pushing ,allow_land_resell = :allow_land_resell ,allow_land_join_divide = :allow_land_join_divide |
1316 | ,[block_show_in_search] = @block_show_in_search ,[agent_limit] = @agent_limit ,[object_bonus] = @object_bonus ,[maturity] = @maturity | 1341 | ,block_show_in_search = :block_show_in_search ,agent_limit = :agent_limit ,object_bonus = :object_bonus ,maturity = :maturity |
1317 | ,[disable_scripts] = @disable_scripts ,[disable_collisions] = @disable_collisions ,[disable_physics] = @disable_physics | 1342 | ,disable_scripts = :disable_scripts ,disable_collisions = :disable_collisions ,disable_physics = :disable_physics |
1318 | ,[terrain_texture_1] = @terrain_texture_1 ,[terrain_texture_2] = @terrain_texture_2 ,[terrain_texture_3] = @terrain_texture_3 | 1343 | ,terrain_texture_1 = :terrain_texture_1 ,terrain_texture_2 = :terrain_texture_2 ,terrain_texture_3 = :terrain_texture_3 |
1319 | ,[terrain_texture_4] = @terrain_texture_4 ,[elevation_1_nw] = @elevation_1_nw ,[elevation_2_nw] = @elevation_2_nw | 1344 | ,terrain_texture_4 = :terrain_texture_4 ,elevation_1_nw = :elevation_1_nw ,elevation_2_nw = :elevation_2_nw |
1320 | ,[elevation_1_ne] = @elevation_1_ne ,[elevation_2_ne] = @elevation_2_ne ,[elevation_1_se] = @elevation_1_se ,[elevation_2_se] = @elevation_2_se | 1345 | ,elevation_1_ne = :elevation_1_ne ,elevation_2_ne = :elevation_2_ne ,elevation_1_se = :elevation_1_se ,elevation_2_se = :elevation_2_se |
1321 | ,[elevation_1_sw] = @elevation_1_sw ,[elevation_2_sw] = @elevation_2_sw ,[water_height] = @water_height ,[terrain_raise_limit] = @terrain_raise_limit | 1346 | ,elevation_1_sw = :elevation_1_sw ,elevation_2_sw = :elevation_2_sw ,water_height = :water_height ,terrain_raise_limit = :terrain_raise_limit |
1322 | ,[terrain_lower_limit] = @terrain_lower_limit ,[use_estate_sun] = @use_estate_sun ,[fixed_sun] = @fixed_sun ,[sun_position] = @sun_position | 1347 | ,terrain_lower_limit = :terrain_lower_limit ,use_estate_sun = :use_estate_sun ,fixed_sun = :fixed_sun ,sun_position = :sun_position |
1323 | ,[covenant] = @covenant ,[covenant_datetime] = @covenant_datetime, [sunvectorx] = @sunvectorx, [sunvectory] = @sunvectory, [sunvectorz] = @sunvectorz, [Sandbox] = @Sandbox, [loaded_creation_datetime] = @loaded_creation_datetime, [loaded_creation_id] = @loaded_creation_id, [map_tile_id] = @TerrainImageID, [telehubobject] = @telehubobject, [parcel_tile_id] = @ParcelImageID | 1348 | ,covenant = :covenant ,covenant_datetime = :covenant_datetime, sunvectorx = :sunvectorx, sunvectory = :sunvectory, sunvectorz = :sunvectorz, |
1324 | WHERE [regionUUID] = @regionUUID"; | 1349 | ""Sandbox"" = :Sandbox, loaded_creation_datetime = :loaded_creation_datetime, loaded_creation_id = :loaded_creation_id, ""map_tile_ID"" = :TerrainImageID, |
1325 | 1350 | ""TelehubObject"" = :telehubobject, ""parcel_tile_ID"" = :ParcelImageID | |
1326 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1351 | WHERE ""regionUUID"" = :regionUUID"; |
1327 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1352 | |
1353 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) | ||
1354 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
1328 | { | 1355 | { |
1329 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); | 1356 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); |
1330 | conn.Open(); | 1357 | conn.Open(); |
@@ -1342,51 +1369,29 @@ VALUES | |||
1342 | #region Private Methods | 1369 | #region Private Methods |
1343 | 1370 | ||
1344 | /// <summary> | 1371 | /// <summary> |
1345 | /// Serializes the terrain data for storage in DB. | ||
1346 | /// </summary> | ||
1347 | /// <param name="val">terrain data</param> | ||
1348 | /// <returns></returns> | ||
1349 | private static Array serializeTerrain(double[,] val) | ||
1350 | { | ||
1351 | MemoryStream str = new MemoryStream(((int)Constants.RegionSize * (int)Constants.RegionSize) * sizeof(double)); | ||
1352 | BinaryWriter bw = new BinaryWriter(str); | ||
1353 | |||
1354 | // TODO: COMPATIBILITY - Add byte-order conversions | ||
1355 | for (int x = 0; x < (int)Constants.RegionSize; x++) | ||
1356 | for (int y = 0; y < (int)Constants.RegionSize; y++) | ||
1357 | { | ||
1358 | double height = val[x, y]; | ||
1359 | if (height == 0.0) | ||
1360 | height = double.Epsilon; | ||
1361 | |||
1362 | bw.Write(height); | ||
1363 | } | ||
1364 | |||
1365 | return str.ToArray(); | ||
1366 | } | ||
1367 | |||
1368 | /// <summary> | ||
1369 | /// Stores new regionsettings. | 1372 | /// Stores new regionsettings. |
1370 | /// </summary> | 1373 | /// </summary> |
1371 | /// <param name="regionSettings">The region settings.</param> | 1374 | /// <param name="regionSettings">The region settings.</param> |
1372 | private void StoreNewRegionSettings(RegionSettings regionSettings) | 1375 | private void StoreNewRegionSettings(RegionSettings regionSettings) |
1373 | { | 1376 | { |
1374 | string sql = @"INSERT INTO [regionsettings] | 1377 | string sql = @"INSERT INTO regionsettings |
1375 | ([regionUUID],[block_terraform],[block_fly],[allow_damage],[restrict_pushing],[allow_land_resell],[allow_land_join_divide], | 1378 | (""regionUUID"",block_terraform,block_fly,allow_damage,restrict_pushing,allow_land_resell,allow_land_join_divide, |
1376 | [block_show_in_search],[agent_limit],[object_bonus],[maturity],[disable_scripts],[disable_collisions],[disable_physics], | 1379 | block_show_in_search,agent_limit,object_bonus,maturity,disable_scripts,disable_collisions,disable_physics, |
1377 | [terrain_texture_1],[terrain_texture_2],[terrain_texture_3],[terrain_texture_4],[elevation_1_nw],[elevation_2_nw],[elevation_1_ne], | 1380 | terrain_texture_1,terrain_texture_2,terrain_texture_3,terrain_texture_4,elevation_1_nw,elevation_2_nw,elevation_1_ne, |
1378 | [elevation_2_ne],[elevation_1_se],[elevation_2_se],[elevation_1_sw],[elevation_2_sw],[water_height],[terrain_raise_limit], | 1381 | elevation_2_ne,elevation_1_se,elevation_2_se,elevation_1_sw,elevation_2_sw,water_height,terrain_raise_limit, |
1379 | [terrain_lower_limit],[use_estate_sun],[fixed_sun],[sun_position],[covenant],[covenant_datetime],[sunvectorx], [sunvectory], [sunvectorz],[Sandbox], [loaded_creation_datetime], [loaded_creation_id] | 1382 | terrain_lower_limit,use_estate_sun,fixed_sun,sun_position,covenant,covenant_datetime,sunvectorx, sunvectory, sunvectorz, |
1380 | ) | 1383 | ""Sandbox"", loaded_creation_datetime, loaded_creation_id |
1384 | ) | ||
1381 | VALUES | 1385 | VALUES |
1382 | (@regionUUID,@block_terraform,@block_fly,@allow_damage,@restrict_pushing,@allow_land_resell,@allow_land_join_divide, | 1386 | (:regionUUID,:block_terraform,:block_fly,:allow_damage,:restrict_pushing,:allow_land_resell,:allow_land_join_divide, |
1383 | @block_show_in_search,@agent_limit,@object_bonus,@maturity,@disable_scripts,@disable_collisions,@disable_physics, | 1387 | :block_show_in_search,:agent_limit,:object_bonus,:maturity,:disable_scripts,:disable_collisions,:disable_physics, |
1384 | @terrain_texture_1,@terrain_texture_2,@terrain_texture_3,@terrain_texture_4,@elevation_1_nw,@elevation_2_nw,@elevation_1_ne, | 1388 | :terrain_texture_1,:terrain_texture_2,:terrain_texture_3,:terrain_texture_4,:elevation_1_nw,:elevation_2_nw,:elevation_1_ne, |
1385 | @elevation_2_ne,@elevation_1_se,@elevation_2_se,@elevation_1_sw,@elevation_2_sw,@water_height,@terrain_raise_limit, | 1389 | :elevation_2_ne,:elevation_1_se,:elevation_2_se,:elevation_1_sw,:elevation_2_sw,:water_height,:terrain_raise_limit, |
1386 | @terrain_lower_limit,@use_estate_sun,@fixed_sun,@sun_position,@covenant, @covenant_datetime, @sunvectorx,@sunvectory, @sunvectorz, @Sandbox, @loaded_creation_datetime, @loaded_creation_id)"; | 1390 | :terrain_lower_limit,:use_estate_sun,:fixed_sun,:sun_position,:covenant, :covenant_datetime, :sunvectorx,:sunvectory, |
1387 | 1391 | :sunvectorz, :Sandbox, :loaded_creation_datetime, :loaded_creation_id )"; | |
1388 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 1392 | |
1389 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 1393 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
1394 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
1390 | { | 1395 | { |
1391 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); | 1396 | cmd.Parameters.AddRange(CreateRegionSettingParameters(regionSettings)); |
1392 | conn.Open(); | 1397 | conn.Open(); |
@@ -1578,8 +1583,8 @@ VALUES | |||
1578 | prim.TouchName = (string)primRow["TouchName"]; | 1583 | prim.TouchName = (string)primRow["TouchName"]; |
1579 | // permissions | 1584 | // permissions |
1580 | prim.Flags = (PrimFlags)Convert.ToUInt32(primRow["ObjectFlags"]); | 1585 | prim.Flags = (PrimFlags)Convert.ToUInt32(primRow["ObjectFlags"]); |
1581 | //prim.CreatorID = new UUID((Guid)primRow["CreatorID"]); | 1586 | //prim.creatorID = new UUID((Guid)primRow["creatorID"]); |
1582 | prim.CreatorIdentification = (string)primRow["CreatorID"]; | 1587 | prim.CreatorIdentification = (string)primRow["CreatorID"].ToString(); |
1583 | prim.OwnerID = new UUID((Guid)primRow["OwnerID"]); | 1588 | prim.OwnerID = new UUID((Guid)primRow["OwnerID"]); |
1584 | prim.GroupID = new UUID((Guid)primRow["GroupID"]); | 1589 | prim.GroupID = new UUID((Guid)primRow["GroupID"]); |
1585 | prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]); | 1590 | prim.LastOwnerID = new UUID((Guid)primRow["LastOwnerID"]); |
@@ -1685,13 +1690,23 @@ VALUES | |||
1685 | 1690 | ||
1686 | prim.CollisionSound = new UUID((Guid)primRow["CollisionSound"]); | 1691 | prim.CollisionSound = new UUID((Guid)primRow["CollisionSound"]); |
1687 | prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]); | 1692 | prim.CollisionSoundVolume = Convert.ToSingle(primRow["CollisionSoundVolume"]); |
1688 | if (Convert.ToInt16(primRow["PassTouches"]) != 0) | 1693 | |
1689 | prim.PassTouches = true; | 1694 | prim.PassTouches = (bool)primRow["PassTouches"]; |
1690 | prim.LinkNum = Convert.ToInt32(primRow["LinkNumber"]); | ||
1691 | 1695 | ||
1692 | if (!(primRow["MediaURL"] is System.DBNull)) | 1696 | if (!(primRow["MediaURL"] is System.DBNull)) |
1693 | prim.MediaUrl = (string)primRow["MediaURL"]; | 1697 | prim.MediaUrl = (string)primRow["MediaURL"]; |
1694 | 1698 | ||
1699 | if (!(primRow["DynAttrs"] is System.DBNull) && (string)primRow["DynAttrs"] != "") | ||
1700 | prim.DynAttrs = DAMap.FromXml((string)primRow["DynAttrs"]); | ||
1701 | else | ||
1702 | prim.DynAttrs = new DAMap(); | ||
1703 | |||
1704 | prim.PhysicsShapeType = Convert.ToByte(primRow["PhysicsShapeType"]); | ||
1705 | prim.Density = Convert.ToSingle(primRow["Density"]); | ||
1706 | prim.GravityModifier = Convert.ToSingle(primRow["GravityModifier"]); | ||
1707 | prim.Friction = Convert.ToSingle(primRow["Friction"]); | ||
1708 | prim.Restitution = Convert.ToSingle(primRow["Restitution"]); | ||
1709 | |||
1695 | return prim; | 1710 | return prim; |
1696 | } | 1711 | } |
1697 | 1712 | ||
@@ -1749,7 +1764,6 @@ VALUES | |||
1749 | baseShape.Media = PrimitiveBaseShape.MediaList.FromXml((string)shapeRow["Media"]); | 1764 | baseShape.Media = PrimitiveBaseShape.MediaList.FromXml((string)shapeRow["Media"]); |
1750 | } | 1765 | } |
1751 | 1766 | ||
1752 | |||
1753 | return baseShape; | 1767 | return baseShape; |
1754 | } | 1768 | } |
1755 | 1769 | ||
@@ -1773,8 +1787,8 @@ VALUES | |||
1773 | taskItem.Name = (string)inventoryRow["name"]; | 1787 | taskItem.Name = (string)inventoryRow["name"]; |
1774 | taskItem.Description = (string)inventoryRow["description"]; | 1788 | taskItem.Description = (string)inventoryRow["description"]; |
1775 | taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]); | 1789 | taskItem.CreationDate = Convert.ToUInt32(inventoryRow["creationDate"]); |
1776 | //taskItem.CreatorID = new UUID((Guid)inventoryRow["creatorID"]); | 1790 | //taskItem.creatorID = new UUID((Guid)inventoryRow["creatorID"]); |
1777 | taskItem.CreatorIdentification = (string)inventoryRow["creatorID"]; | 1791 | taskItem.CreatorIdentification = (string)inventoryRow["creatorID"].ToString(); |
1778 | taskItem.OwnerID = new UUID((Guid)inventoryRow["ownerID"]); | 1792 | taskItem.OwnerID = new UUID((Guid)inventoryRow["ownerID"]); |
1779 | taskItem.LastOwnerID = new UUID((Guid)inventoryRow["lastOwnerID"]); | 1793 | taskItem.LastOwnerID = new UUID((Guid)inventoryRow["lastOwnerID"]); |
1780 | taskItem.GroupID = new UUID((Guid)inventoryRow["groupID"]); | 1794 | taskItem.GroupID = new UUID((Guid)inventoryRow["groupID"]); |
@@ -1798,9 +1812,9 @@ VALUES | |||
1798 | /// </summary> | 1812 | /// </summary> |
1799 | /// <param name="taskItem">item in inventory.</param> | 1813 | /// <param name="taskItem">item in inventory.</param> |
1800 | /// <returns></returns> | 1814 | /// <returns></returns> |
1801 | private SqlParameter[] CreatePrimInventoryParameters(TaskInventoryItem taskItem) | 1815 | private NpgsqlParameter[] CreatePrimInventoryParameters(TaskInventoryItem taskItem) |
1802 | { | 1816 | { |
1803 | List<SqlParameter> parameters = new List<SqlParameter>(); | 1817 | List<NpgsqlParameter> parameters = new List<NpgsqlParameter>(); |
1804 | 1818 | ||
1805 | parameters.Add(_Database.CreateParameter("itemID", taskItem.ItemID)); | 1819 | parameters.Add(_Database.CreateParameter("itemID", taskItem.ItemID)); |
1806 | parameters.Add(_Database.CreateParameter("primID", taskItem.ParentPartID)); | 1820 | parameters.Add(_Database.CreateParameter("primID", taskItem.ParentPartID)); |
@@ -1831,9 +1845,9 @@ VALUES | |||
1831 | /// </summary> | 1845 | /// </summary> |
1832 | /// <param name="settings">regionsettings.</param> | 1846 | /// <param name="settings">regionsettings.</param> |
1833 | /// <returns></returns> | 1847 | /// <returns></returns> |
1834 | private SqlParameter[] CreateRegionSettingParameters(RegionSettings settings) | 1848 | private NpgsqlParameter[] CreateRegionSettingParameters(RegionSettings settings) |
1835 | { | 1849 | { |
1836 | List<SqlParameter> parameters = new List<SqlParameter>(); | 1850 | List<NpgsqlParameter> parameters = new List<NpgsqlParameter>(); |
1837 | 1851 | ||
1838 | parameters.Add(_Database.CreateParameter("regionUUID", settings.RegionUUID)); | 1852 | parameters.Add(_Database.CreateParameter("regionUUID", settings.RegionUUID)); |
1839 | parameters.Add(_Database.CreateParameter("block_terraform", settings.BlockTerraform)); | 1853 | parameters.Add(_Database.CreateParameter("block_terraform", settings.BlockTerraform)); |
@@ -1888,9 +1902,9 @@ VALUES | |||
1888 | /// <param name="land">land parameters.</param> | 1902 | /// <param name="land">land parameters.</param> |
1889 | /// <param name="regionUUID">region UUID.</param> | 1903 | /// <param name="regionUUID">region UUID.</param> |
1890 | /// <returns></returns> | 1904 | /// <returns></returns> |
1891 | private SqlParameter[] CreateLandParameters(LandData land, UUID regionUUID) | 1905 | private NpgsqlParameter[] CreateLandParameters(LandData land, UUID regionUUID) |
1892 | { | 1906 | { |
1893 | List<SqlParameter> parameters = new List<SqlParameter>(); | 1907 | List<NpgsqlParameter> parameters = new List<NpgsqlParameter>(); |
1894 | 1908 | ||
1895 | parameters.Add(_Database.CreateParameter("UUID", land.GlobalID)); | 1909 | parameters.Add(_Database.CreateParameter("UUID", land.GlobalID)); |
1896 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); | 1910 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); |
@@ -1912,8 +1926,8 @@ VALUES | |||
1912 | parameters.Add(_Database.CreateParameter("SalePrice", land.SalePrice)); | 1926 | parameters.Add(_Database.CreateParameter("SalePrice", land.SalePrice)); |
1913 | parameters.Add(_Database.CreateParameter("LandStatus", (int)land.Status)); //Enum. libsecondlife.Parcel.ParcelStatus | 1927 | parameters.Add(_Database.CreateParameter("LandStatus", (int)land.Status)); //Enum. libsecondlife.Parcel.ParcelStatus |
1914 | parameters.Add(_Database.CreateParameter("LandFlags", land.Flags)); | 1928 | parameters.Add(_Database.CreateParameter("LandFlags", land.Flags)); |
1915 | parameters.Add(_Database.CreateParameter("LandingType", land.LandingType)); | 1929 | parameters.Add(_Database.CreateParameter("LandingType", Convert.ToInt32( land.LandingType) )); |
1916 | parameters.Add(_Database.CreateParameter("MediaAutoScale", land.MediaAutoScale)); | 1930 | parameters.Add(_Database.CreateParameter("MediaAutoScale", Convert.ToInt32( land.MediaAutoScale ))); |
1917 | parameters.Add(_Database.CreateParameter("MediaTextureUUID", land.MediaID)); | 1931 | parameters.Add(_Database.CreateParameter("MediaTextureUUID", land.MediaID)); |
1918 | parameters.Add(_Database.CreateParameter("MediaURL", land.MediaURL)); | 1932 | parameters.Add(_Database.CreateParameter("MediaURL", land.MediaURL)); |
1919 | parameters.Add(_Database.CreateParameter("MusicURL", land.MusicURL)); | 1933 | parameters.Add(_Database.CreateParameter("MusicURL", land.MusicURL)); |
@@ -1938,9 +1952,9 @@ VALUES | |||
1938 | /// <param name="parcelAccessEntry">parcel access entry.</param> | 1952 | /// <param name="parcelAccessEntry">parcel access entry.</param> |
1939 | /// <param name="parcelID">parcel ID.</param> | 1953 | /// <param name="parcelID">parcel ID.</param> |
1940 | /// <returns></returns> | 1954 | /// <returns></returns> |
1941 | private SqlParameter[] CreateLandAccessParameters(LandAccessEntry parcelAccessEntry, UUID parcelID) | 1955 | private NpgsqlParameter[] CreateLandAccessParameters(LandAccessEntry parcelAccessEntry, UUID parcelID) |
1942 | { | 1956 | { |
1943 | List<SqlParameter> parameters = new List<SqlParameter>(); | 1957 | List<NpgsqlParameter> parameters = new List<NpgsqlParameter>(); |
1944 | 1958 | ||
1945 | parameters.Add(_Database.CreateParameter("LandUUID", parcelID)); | 1959 | parameters.Add(_Database.CreateParameter("LandUUID", parcelID)); |
1946 | parameters.Add(_Database.CreateParameter("AccessUUID", parcelAccessEntry.AgentID)); | 1960 | parameters.Add(_Database.CreateParameter("AccessUUID", parcelAccessEntry.AgentID)); |
@@ -1957,9 +1971,9 @@ VALUES | |||
1957 | /// <param name="sceneGroupID">The scenegroup ID.</param> | 1971 | /// <param name="sceneGroupID">The scenegroup ID.</param> |
1958 | /// <param name="regionUUID">The region ID.</param> | 1972 | /// <param name="regionUUID">The region ID.</param> |
1959 | /// <returns></returns> | 1973 | /// <returns></returns> |
1960 | private SqlParameter[] CreatePrimParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) | 1974 | private NpgsqlParameter[] CreatePrimParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) |
1961 | { | 1975 | { |
1962 | List<SqlParameter> parameters = new List<SqlParameter>(); | 1976 | List<NpgsqlParameter> parameters = new List<NpgsqlParameter>(); |
1963 | 1977 | ||
1964 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); | 1978 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); |
1965 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); | 1979 | parameters.Add(_Database.CreateParameter("RegionUUID", regionUUID)); |
@@ -2080,12 +2094,22 @@ VALUES | |||
2080 | 2094 | ||
2081 | parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound)); | 2095 | parameters.Add(_Database.CreateParameter("CollisionSound", prim.CollisionSound)); |
2082 | parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume)); | 2096 | parameters.Add(_Database.CreateParameter("CollisionSoundVolume", prim.CollisionSoundVolume)); |
2083 | if (prim.PassTouches) | 2097 | |
2084 | parameters.Add(_Database.CreateParameter("PassTouches", 1)); | 2098 | parameters.Add(_Database.CreateParameter("PassTouches", prim.PassTouches)); |
2085 | else | 2099 | |
2086 | parameters.Add(_Database.CreateParameter("PassTouches", 0)); | ||
2087 | parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); | 2100 | parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); |
2088 | parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); | 2101 | parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); |
2102 | |||
2103 | if (prim.DynAttrs.CountNamespaces > 0) | ||
2104 | parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml())); | ||
2105 | else | ||
2106 | parameters.Add(_Database.CreateParameter("DynAttrs", null)); | ||
2107 | |||
2108 | parameters.Add(_Database.CreateParameter("PhysicsShapeType", prim.PhysicsShapeType)); | ||
2109 | parameters.Add(_Database.CreateParameter("Density", (double)prim.Density)); | ||
2110 | parameters.Add(_Database.CreateParameter("GravityModifier", (double)prim.GravityModifier)); | ||
2111 | parameters.Add(_Database.CreateParameter("Friction", (double)prim.Friction)); | ||
2112 | parameters.Add(_Database.CreateParameter("Restitution", (double)prim.Restitution)); | ||
2089 | 2113 | ||
2090 | return parameters.ToArray(); | 2114 | return parameters.ToArray(); |
2091 | } | 2115 | } |
@@ -2097,9 +2121,9 @@ VALUES | |||
2097 | /// <param name="sceneGroupID">The scene group ID.</param> | 2121 | /// <param name="sceneGroupID">The scene group ID.</param> |
2098 | /// <param name="regionUUID">The region UUID.</param> | 2122 | /// <param name="regionUUID">The region UUID.</param> |
2099 | /// <returns></returns> | 2123 | /// <returns></returns> |
2100 | private SqlParameter[] CreatePrimShapeParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) | 2124 | private NpgsqlParameter[] CreatePrimShapeParameters(SceneObjectPart prim, UUID sceneGroupID, UUID regionUUID) |
2101 | { | 2125 | { |
2102 | List<SqlParameter> parameters = new List<SqlParameter>(); | 2126 | List<NpgsqlParameter> parameters = new List<NpgsqlParameter>(); |
2103 | 2127 | ||
2104 | PrimitiveBaseShape s = prim.Shape; | 2128 | PrimitiveBaseShape s = prim.Shape; |
2105 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); | 2129 | parameters.Add(_Database.CreateParameter("UUID", prim.UUID)); |
@@ -2143,7 +2167,6 @@ VALUES | |||
2143 | parameters.Add(_Database.CreateParameter("Media", s.Media.ToXml())); | 2167 | parameters.Add(_Database.CreateParameter("Media", s.Media.ToXml())); |
2144 | } | 2168 | } |
2145 | 2169 | ||
2146 | |||
2147 | return parameters.ToArray(); | 2170 | return parameters.ToArray(); |
2148 | } | 2171 | } |
2149 | 2172 | ||
@@ -2155,13 +2178,14 @@ VALUES | |||
2155 | { | 2178 | { |
2156 | rs.ClearSpawnPoints(); | 2179 | rs.ClearSpawnPoints(); |
2157 | 2180 | ||
2158 | string sql = "SELECT Yaw, Pitch, Distance FROM spawn_points WHERE RegionUUID = @RegionUUID"; | 2181 | string sql = @"SELECT ""Yaw"", ""Pitch"", ""Distance"" FROM spawn_points WHERE ""RegionUUID"" = :RegionUUID"; |
2159 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 2182 | |
2160 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 2183 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
2184 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) | ||
2161 | { | 2185 | { |
2162 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", rs.RegionUUID.ToString())); | 2186 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", rs.RegionUUID)); |
2163 | conn.Open(); | 2187 | conn.Open(); |
2164 | using (SqlDataReader reader = cmd.ExecuteReader()) | 2188 | using (NpgsqlDataReader reader = cmd.ExecuteReader()) |
2165 | { | 2189 | { |
2166 | if (reader.Read()) | 2190 | if (reader.Read()) |
2167 | { | 2191 | { |
@@ -2179,24 +2203,24 @@ VALUES | |||
2179 | 2203 | ||
2180 | private void SaveSpawnPoints(RegionSettings rs) | 2204 | private void SaveSpawnPoints(RegionSettings rs) |
2181 | { | 2205 | { |
2182 | string sql = "DELETE FROM spawn_points WHERE RegionUUID = @RegionUUID"; | 2206 | string sql = @"DELETE FROM spawn_points WHERE ""RegionUUID"" = :RegionUUID"; |
2183 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 2207 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
2184 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 2208 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
2185 | { | 2209 | { |
2186 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", rs.RegionUUID)); | 2210 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", rs.RegionUUID)); |
2187 | conn.Open(); | 2211 | conn.Open(); |
2188 | cmd.ExecuteNonQuery(); | 2212 | cmd.ExecuteNonQuery(); |
2189 | } | 2213 | } |
2190 | foreach (SpawnPoint p in rs.SpawnPoints()) | 2214 | foreach (SpawnPoint p in rs.SpawnPoints()) |
2191 | { | 2215 | { |
2192 | sql = "INSERT INTO spawn_points (RegionUUID, Yaw, Pitch, Distance) VALUES (@RegionUUID, @Yaw, @Pitch, @Distance)"; | 2216 | sql = @"INSERT INTO spawn_points (""RegionUUID"", ""Yaw"", ""Pitch"", ""Distance"") VALUES (:RegionUUID, :Yaw, :Pitch, :Distance)"; |
2193 | using (SqlConnection conn = new SqlConnection(m_connectionString)) | 2217 | using (NpgsqlConnection conn = new NpgsqlConnection(m_connectionString)) |
2194 | using (SqlCommand cmd = new SqlCommand(sql, conn)) | 2218 | using (NpgsqlCommand cmd = new NpgsqlCommand(sql, conn)) |
2195 | { | 2219 | { |
2196 | cmd.Parameters.Add(_Database.CreateParameter("@RegionUUID", rs.RegionUUID)); | 2220 | cmd.Parameters.Add(_Database.CreateParameter("RegionUUID", rs.RegionUUID)); |
2197 | cmd.Parameters.Add(_Database.CreateParameter("@Yaw", p.Yaw)); | 2221 | cmd.Parameters.Add(_Database.CreateParameter("Yaw", p.Yaw)); |
2198 | cmd.Parameters.Add(_Database.CreateParameter("@Pitch", p.Pitch)); | 2222 | cmd.Parameters.Add(_Database.CreateParameter("Pitch", p.Pitch)); |
2199 | cmd.Parameters.Add(_Database.CreateParameter("@Distance", p.Distance)); | 2223 | cmd.Parameters.Add(_Database.CreateParameter("Distance", p.Distance)); |
2200 | conn.Open(); | 2224 | conn.Open(); |
2201 | cmd.ExecuteNonQuery(); | 2225 | cmd.ExecuteNonQuery(); |
2202 | } | 2226 | } |