aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorChris Hart2011-06-01 04:01:18 +0100
committerJustin Clark-Casey (justincc)2011-06-01 21:01:04 +0100
commit5fb0455e929d96efb41d23f67653b329792ab834 (patch)
treeb28593f324ba685cd3c4d23036438a4890bb7bb8 /OpenSim/Data
parenta few minor formatting tweaks (diff)
downloadopensim-SC-5fb0455e929d96efb41d23f67653b329792ab834.zip
opensim-SC-5fb0455e929d96efb41d23f67653b329792ab834.tar.gz
opensim-SC-5fb0455e929d96efb41d23f67653b329792ab834.tar.bz2
opensim-SC-5fb0455e929d96efb41d23f67653b329792ab834.tar.xz
Updates to MSSQL to most recent compatibility, also included Windlight support. Needs plenty of testing but clean install and migration from 0.6.9 have been tested and work, a few indexes still need to be added for performance.
Diffstat (limited to 'OpenSim/Data')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLEstateData.cs203
-rw-r--r--OpenSim/Data/MSSQL/MSSQLFriendsData.cs1
-rw-r--r--OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs22
-rw-r--r--OpenSim/Data/MSSQL/MSSQLMigration.cs32
-rw-r--r--OpenSim/Data/MSSQL/MSSQLRegionData.cs1
-rw-r--r--OpenSim/Data/MSSQL/MSSQLSimulationData.cs513
-rw-r--r--OpenSim/Data/MSSQL/MSSQLXInventoryData.cs32
-rw-r--r--OpenSim/Data/MSSQL/Resources/Avatar.migrations24
-rw-r--r--OpenSim/Data/MSSQL/Resources/GridUserStore.migrations46
-rw-r--r--OpenSim/Data/MSSQL/Resources/RegionStore.migrations2
10 files changed, 828 insertions, 48 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLEstateData.cs b/OpenSim/Data/MSSQL/MSSQLEstateData.cs
index d10ebe4..9c54e77 100644
--- a/OpenSim/Data/MSSQL/MSSQLEstateData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLEstateData.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Data.MSSQL
41 { 41 {
42 private const string _migrationStore = "EstateStore"; 42 private const string _migrationStore = "EstateStore";
43 43
44 private static readonly ILog _Log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 45
46 private MSSQLManager _Database; 46 private MSSQLManager _Database;
47 private string m_connectionString; 47 private string m_connectionString;
@@ -72,7 +72,12 @@ namespace OpenSim.Data.MSSQL
72 } 72 }
73 73
74 //Migration settings 74 //Migration settings
75 _Database.CheckMigration(_migrationStore); 75 using (SqlConnection conn = new SqlConnection(m_connectionString))
76 {
77 conn.Open();
78 Migration m = new Migration(conn, GetType().Assembly, "EstateStore");
79 m.Update();
80 }
76 81
77 //Interesting way to get parameters! Maybe implement that also with other types 82 //Interesting way to get parameters! Maybe implement that also with other types
78 Type t = typeof(EstateSettings); 83 Type t = typeof(EstateSettings);
@@ -112,19 +117,19 @@ namespace OpenSim.Data.MSSQL
112 { 117 {
113 FieldInfo f = _FieldMap[name]; 118 FieldInfo f = _FieldMap[name];
114 object v = reader[name]; 119 object v = reader[name];
115 if (f.FieldType == typeof(bool) ) 120 if (f.FieldType == typeof(bool))
116 { 121 {
117 f.SetValue(es, Convert.ToInt32(v) != 0); 122 f.SetValue(es, Convert.ToInt32(v) != 0);
118 } 123 }
119 else if (f.FieldType == typeof(UUID) ) 124 else if (f.FieldType == typeof(UUID))
120 { 125 {
121 f.SetValue(es, new UUID((Guid)v)); // uuid); 126 f.SetValue(es, new UUID((Guid)v)); // uuid);
122 } 127 }
123 else if (f.FieldType == typeof(string)) 128 else if (f.FieldType == typeof(string))
124 { 129 {
125 f.SetValue(es, v.ToString()); 130 f.SetValue(es, v.ToString());
126 } 131 }
127 else if (f.FieldType == typeof(UInt32)) 132 else if (f.FieldType == typeof(UInt32))
128 { 133 {
129 f.SetValue(es, Convert.ToUInt32(v)); 134 f.SetValue(es, Convert.ToUInt32(v));
130 } 135 }
@@ -186,7 +191,7 @@ namespace OpenSim.Data.MSSQL
186 } 191 }
187 catch (Exception e) 192 catch (Exception e)
188 { 193 {
189 _Log.DebugFormat("[ESTATE DB]: Error inserting regionID and EstateID in estate_map: {0}", e); 194 m_log.DebugFormat("[ESTATE DB]: Error inserting regionID and EstateID in estate_map: {0}", e);
190 } 195 }
191 } 196 }
192 197
@@ -310,12 +315,12 @@ namespace OpenSim.Data.MSSQL
310 conn.Open(); 315 conn.Open();
311 using (SqlCommand cmd = conn.CreateCommand()) 316 using (SqlCommand cmd = conn.CreateCommand())
312 { 317 {
313 cmd.CommandText = "delete from estateban where EstateID = @EstateID"; 318 cmd.CommandText = "delete from estateban where EstateID = @EstateID";
314 cmd.Parameters.AddWithValue("@EstateID", (int)es.EstateID); 319 cmd.Parameters.AddWithValue("@EstateID", (int)es.EstateID);
315 cmd.ExecuteNonQuery(); 320 cmd.ExecuteNonQuery();
316 321
317 //Insert after 322 //Insert after
318 cmd.CommandText = "insert into estateban (EstateID, bannedUUID) values ( @EstateID, @bannedUUID )"; 323 cmd.CommandText = "insert into estateban (EstateID, bannedUUID,bannedIp, bannedIpHostMask, bannedNameMask) values ( @EstateID, @bannedUUID, '','','' )";
319 cmd.Parameters.AddWithValue("@bannedUUID", Guid.Empty); 324 cmd.Parameters.AddWithValue("@bannedUUID", Guid.Empty);
320 foreach (EstateBan b in es.EstateBans) 325 foreach (EstateBan b in es.EstateBans)
321 { 326 {
@@ -350,43 +355,195 @@ namespace OpenSim.Data.MSSQL
350 355
351 public EstateSettings LoadEstateSettings(int estateID) 356 public EstateSettings LoadEstateSettings(int estateID)
352 { 357 {
353 // TODO: Implementation! 358 EstateSettings es = new EstateSettings();
354 return new EstateSettings(); 359 string sql = "select estate_settings." + String.Join(",estate_settings.", FieldList) + " from estate_settings where EstateID = @EstateID";
360 using (SqlConnection conn = new SqlConnection(m_connectionString))
361 {
362 conn.Open();
363 using (SqlCommand cmd = new SqlCommand(sql, conn))
364 {
365 cmd.Parameters.AddWithValue("@EstateID", (int)estateID);
366 using (SqlDataReader reader = cmd.ExecuteReader())
367 {
368 if (reader.Read())
369 {
370 foreach (string name in FieldList)
371 {
372 FieldInfo f = _FieldMap[name];
373 object v = reader[name];
374 if (f.FieldType == typeof(bool))
375 {
376 f.SetValue(es, Convert.ToInt32(v) != 0);
377 }
378 else if (f.FieldType == typeof(UUID))
379 {
380 f.SetValue(es, new UUID((Guid)v)); // uuid);
381 }
382 else if (f.FieldType == typeof(string))
383 {
384 f.SetValue(es, v.ToString());
385 }
386 else if (f.FieldType == typeof(UInt32))
387 {
388 f.SetValue(es, Convert.ToUInt32(v));
389 }
390 else if (f.FieldType == typeof(Single))
391 {
392 f.SetValue(es, Convert.ToSingle(v));
393 }
394 else
395 f.SetValue(es, v);
396 }
397 }
398
399 }
400 }
401 }
402 LoadBanList(es);
403
404 es.EstateManagers = LoadUUIDList(es.EstateID, "estate_managers");
405 es.EstateAccess = LoadUUIDList(es.EstateID, "estate_users");
406 es.EstateGroups = LoadUUIDList(es.EstateID, "estate_groups");
407
408 //Set event
409 es.OnSave += StoreEstateSettings;
410 return es;
411
355 } 412 }
356 413
357 public List<EstateSettings> LoadEstateSettingsAll() 414 public List<EstateSettings> LoadEstateSettingsAll()
358 { 415 {
359 // TODO: Implementation! 416 List<EstateSettings> allEstateSettings = new List<EstateSettings>();
360 return new List<EstateSettings>(); 417
418 List<int> allEstateIds = GetEstatesAll();
419
420 foreach (int estateId in allEstateIds)
421 allEstateSettings.Add(LoadEstateSettings(estateId));
422
423 return allEstateSettings;
361 } 424 }
362 425
363 public List<int> GetEstates(string search) 426 public List<int> GetEstates(string search)
364 { 427 {
365 // TODO: Implementation! 428 List<int> result = new List<int>();
366 return new List<int>(); 429 string sql = "select estateID from estate_settings where EstateName = @EstateName";
430 using (SqlConnection conn = new SqlConnection(m_connectionString))
431 {
432 conn.Open();
433 using (SqlCommand cmd = new SqlCommand(sql, conn))
434 {
435 cmd.Parameters.AddWithValue("@EstateName", search);
436
437 using (IDataReader reader = cmd.ExecuteReader())
438 {
439 while (reader.Read())
440 {
441 result.Add(Convert.ToInt32(reader["EstateID"]));
442 }
443 reader.Close();
444 }
445 }
446 }
447
448 return result;
367 } 449 }
368 450
369 public List<int> GetEstatesAll() 451 public List<int> GetEstatesAll()
370 { 452 {
371 // TODO: Implementation! 453 List<int> result = new List<int>();
372 return new List<int>(); 454 string sql = "select estateID from estate_settings";
455 using (SqlConnection conn = new SqlConnection(m_connectionString))
456 {
457 conn.Open();
458 using (SqlCommand cmd = new SqlCommand(sql, conn))
459 {
460 using (IDataReader reader = cmd.ExecuteReader())
461 {
462 while (reader.Read())
463 {
464 result.Add(Convert.ToInt32(reader["EstateID"]));
465 }
466 reader.Close();
467 }
468 }
469 }
470
471 return result;
373 } 472 }
374 473
375 public List<int> GetEstatesByOwner(UUID ownerID) 474 public List<int> GetEstatesByOwner(UUID ownerID)
376 { 475 {
377 return new List<int>(); 476 List<int> result = new List<int>();
477 string sql = "select estateID from estate_settings where EstateOwner = @EstateOwner";
478 using (SqlConnection conn = new SqlConnection(m_connectionString))
479 {
480 conn.Open();
481 using (SqlCommand cmd = new SqlCommand(sql, conn))
482 {
483 cmd.Parameters.AddWithValue("@EstateOwner", ownerID);
484
485 using (IDataReader reader = cmd.ExecuteReader())
486 {
487 while (reader.Read())
488 {
489 result.Add(Convert.ToInt32(reader["EstateID"]));
490 }
491 reader.Close();
492 }
493 }
494 }
495
496 return result;
378 } 497 }
379 498
380 public bool LinkRegion(UUID regionID, int estateID) 499 public bool LinkRegion(UUID regionID, int estateID)
381 { 500 {
382 // TODO: Implementation! 501 string sql = "insert into estate_map values (@RegionID, @EstateID)";
502 using (SqlConnection conn = new SqlConnection(m_connectionString))
503 {
504 conn.Open();
505 try
506 {
507 using (SqlCommand cmd = new SqlCommand(sql, conn))
508 {
509 cmd.Parameters.AddWithValue("@RegionID", regionID);
510 cmd.Parameters.AddWithValue("@EstateID", estateID);
511
512 int ret = cmd.ExecuteNonQuery();
513 return (ret != 0);
514 }
515 }
516 catch (Exception ex)
517 {
518 m_log.Error("[REGION DB]: LinkRegion failed: " + ex.Message);
519 }
520 }
383 return false; 521 return false;
384 } 522 }
385 523
386 public List<UUID> GetRegions(int estateID) 524 public List<UUID> GetRegions(int estateID)
387 { 525 {
388 // TODO: Implementation! 526 List<UUID> result = new List<UUID>();
389 return new List<UUID>(); 527 string sql = "select RegionID from estate_map where EstateID = @EstateID";
528 using (SqlConnection conn = new SqlConnection(m_connectionString))
529 {
530 conn.Open();
531 using (SqlCommand cmd = new SqlCommand(sql, conn))
532 {
533 cmd.Parameters.AddWithValue("@EstateID", estateID);
534
535 using (IDataReader reader = cmd.ExecuteReader())
536 {
537 while (reader.Read())
538 {
539 result.Add(DBGuid.FromDB(reader["RegionID"]));
540 }
541 reader.Close();
542 }
543 }
544 }
545
546 return result;
390 } 547 }
391 548
392 public bool DeleteEstate(int estateID) 549 public bool DeleteEstate(int estateID)
diff --git a/OpenSim/Data/MSSQL/MSSQLFriendsData.cs b/OpenSim/Data/MSSQL/MSSQLFriendsData.cs
index 0b178f1..09dde5e 100644
--- a/OpenSim/Data/MSSQL/MSSQLFriendsData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLFriendsData.cs
@@ -89,6 +89,5 @@ namespace OpenSim.Data.MSSQL
89 return DoQuery(cmd); 89 return DoQuery(cmd);
90 } 90 }
91 } 91 }
92
93 } 92 }
94} 93}
diff --git a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs
index ab9df4c..4145d95 100644
--- a/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs
+++ b/OpenSim/Data/MSSQL/MSSQLGenericTableHandler.cs
@@ -168,14 +168,13 @@ namespace OpenSim.Data.MSSQL
168 168
169 protected T[] DoQuery(SqlCommand cmd) 169 protected T[] DoQuery(SqlCommand cmd)
170 { 170 {
171 List<T> result = new List<T>();
171 using (SqlDataReader reader = cmd.ExecuteReader()) 172 using (SqlDataReader reader = cmd.ExecuteReader())
172 { 173 {
173 if (reader == null) 174 if (reader == null)
174 return new T[0]; 175 return new T[0];
175 176
176 CheckColumnNames(reader); 177 CheckColumnNames(reader);
177
178 List<T> result = new List<T>();
179 178
180 while (reader.Read()) 179 while (reader.Read())
181 { 180 {
@@ -262,6 +261,15 @@ namespace OpenSim.Data.MSSQL
262 { 261 {
263 names.Add(fi.Name); 262 names.Add(fi.Name);
264 values.Add("@" + fi.Name); 263 values.Add("@" + fi.Name);
264 // Temporarily return more information about what field is unexpectedly null for
265 // http://opensimulator.org/mantis/view.php?id=5403. This might be due to a bug in the
266 // InventoryTransferModule or we may be required to substitute a DBNull here.
267 if (fi.GetValue(row) == null)
268 throw new NullReferenceException(
269 string.Format(
270 "[MSSQL GENERIC TABLE HANDLER]: Trying to store field {0} for {1} which is unexpectedly null",
271 fi.Name, row));
272
265 if (constraintFields.Count > 0 && constraintFields.Contains(fi.Name)) 273 if (constraintFields.Count > 0 && constraintFields.Contains(fi.Name))
266 { 274 {
267 constraints.Add(new KeyValuePair<string, string>(fi.Name, fi.GetValue(row).ToString())); 275 constraints.Add(new KeyValuePair<string, string>(fi.Name, fi.GetValue(row).ToString()));
@@ -363,7 +371,13 @@ namespace OpenSim.Data.MSSQL
363 cmd.Connection = conn; 371 cmd.Connection = conn;
364 cmd.CommandText = query; 372 cmd.CommandText = query;
365 conn.Open(); 373 conn.Open();
366 return cmd.ExecuteNonQuery() > 0; 374
375 if (cmd.ExecuteNonQuery() > 0)
376 {
377 //m_log.Warn("[MSSQLGenericTable]: " + deleteCommand);
378 return true;
379 }
380 return false;
367 } 381 }
368 } 382 }
369 } 383 }
diff --git a/OpenSim/Data/MSSQL/MSSQLMigration.cs b/OpenSim/Data/MSSQL/MSSQLMigration.cs
index cd395b8..1aa96c7 100644
--- a/OpenSim/Data/MSSQL/MSSQLMigration.cs
+++ b/OpenSim/Data/MSSQL/MSSQLMigration.cs
@@ -29,16 +29,19 @@ using System;
29using System.Data; 29using System.Data;
30using System.Data.Common; 30using System.Data.Common;
31using System.Reflection; 31using System.Reflection;
32using System.Data.SqlClient;
32 33
33namespace OpenSim.Data.MSSQL 34namespace OpenSim.Data.MSSQL
34{ 35{
35 public class MSSQLMigration : Migration 36 public class MSSQLMigration : Migration
36 { 37 {
37 public MSSQLMigration(DbConnection conn, Assembly assem, string type) : base(conn, assem, type) 38 public MSSQLMigration(DbConnection conn, Assembly assem, string type)
39 : base(conn, assem, type)
38 { 40 {
39 } 41 }
40 42
41 public MSSQLMigration(DbConnection conn, Assembly assem, string subtype, string type) : base(conn, assem, subtype, type) 43 public MSSQLMigration(DbConnection conn, Assembly assem, string subtype, string type)
44 : base(conn, assem, subtype, type)
42 { 45 {
43 } 46 }
44 47
@@ -67,5 +70,30 @@ namespace OpenSim.Data.MSSQL
67 } 70 }
68 return version; 71 return version;
69 } 72 }
73
74 protected override void ExecuteScript(DbConnection conn, string[] script)
75 {
76 if (!(conn is SqlConnection))
77 {
78 base.ExecuteScript(conn, script);
79 return;
80 }
81
82 foreach (string sql in script)
83 {
84 try
85 {
86 using (SqlCommand cmd = new SqlCommand(sql, (SqlConnection)conn))
87 {
88 cmd.ExecuteNonQuery();
89 }
90 }
91 catch (Exception ex)
92 {
93 throw new Exception(sql);
94
95 }
96 }
97 }
70 } 98 }
71} 99}
diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/MSSQL/MSSQLRegionData.cs
index cdf8ec0..3ae87c3 100644
--- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLRegionData.cs
@@ -70,6 +70,7 @@ namespace OpenSim.Data.MSSQL
70 string sql = "select * from ["+m_Realm+"] where regionName like @regionName"; 70 string sql = "select * from ["+m_Realm+"] where regionName like @regionName";
71 if (scopeID != UUID.Zero) 71 if (scopeID != UUID.Zero)
72 sql += " and ScopeID = @scopeID"; 72 sql += " and ScopeID = @scopeID";
73 sql += " order by regionName";
73 using (SqlConnection conn = new SqlConnection(m_ConnectionString)) 74 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
74 using (SqlCommand cmd = new SqlCommand(sql, conn)) 75 using (SqlCommand cmd = new SqlCommand(sql, conn))
75 { 76 {
diff --git a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
index 5155e56..78f80e1 100644
--- a/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLSimulationData.cs
@@ -55,6 +55,10 @@ namespace OpenSim.Data.MSSQL
55 /// </summary> 55 /// </summary>
56 private MSSQLManager _Database; 56 private MSSQLManager _Database;
57 private string m_connectionString; 57 private string m_connectionString;
58 protected virtual Assembly Assembly
59 {
60 get { return GetType().Assembly; }
61 }
58 62
59 public MSSQLSimulationData() 63 public MSSQLSimulationData()
60 { 64 {
@@ -74,9 +78,28 @@ namespace OpenSim.Data.MSSQL
74 m_connectionString = connectionString; 78 m_connectionString = connectionString;
75 _Database = new MSSQLManager(connectionString); 79 _Database = new MSSQLManager(connectionString);
76 80
81 using (SqlConnection conn = new SqlConnection(connectionString))
82 {
83 conn.Open();
84 //New Migration settings
85 Migration m = new Migration(conn, Assembly, "RegionStore");
86 m.Update();
77 87
78 //Migration settings 88 // Clean dropped attachments
79 _Database.CheckMigration(_migrationStore); 89 //
90 try
91 {
92 using (SqlCommand cmd = conn.CreateCommand())
93 {
94 cmd.CommandText = "delete from prims where prims.UUID in (select UUID from primshapes where PCode = 9 and State <> 0); delete from primshapes where PCode = 9 and State <> 0";
95 cmd.ExecuteNonQuery();
96 }
97 }
98 catch (Exception ex)
99 {
100 _Log.Error("[REGION DB]: Error cleaning up dropped attachments: " + ex.Message);
101 }
102 }
80 } 103 }
81 104
82 /// <summary> 105 /// <summary>
@@ -214,7 +237,7 @@ namespace OpenSim.Data.MSSQL
214 { 237 {
215 command.Parameters.Clear(); 238 command.Parameters.Clear();
216 command.Parameters.Add(_Database.CreateParameter("@PrimID", objectPart.UUID)); 239 command.Parameters.Add(_Database.CreateParameter("@PrimID", objectPart.UUID));
217 240
218 List<TaskInventoryItem> inventory = new List<TaskInventoryItem>(); 241 List<TaskInventoryItem> inventory = new List<TaskInventoryItem>();
219 242
220 using (SqlDataReader reader = command.ExecuteReader()) 243 using (SqlDataReader reader = command.ExecuteReader())
@@ -241,6 +264,14 @@ namespace OpenSim.Data.MSSQL
241 /// <param name="regionUUID"></param> 264 /// <param name="regionUUID"></param>
242 public void StoreObject(SceneObjectGroup obj, UUID regionUUID) 265 public void StoreObject(SceneObjectGroup obj, UUID regionUUID)
243 { 266 {
267 uint flags = obj.RootPart.GetEffectiveObjectFlags();
268 // Eligibility check
269 //
270 if ((flags & (uint)PrimFlags.Temporary) != 0)
271 return;
272 if ((flags & (uint)PrimFlags.TemporaryOnRez) != 0)
273 return;
274
244 _Log.DebugFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Parts.Length); 275 _Log.DebugFormat("[MSSQL]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Parts.Length);
245 276
246 using (SqlConnection conn = new SqlConnection(m_connectionString)) 277 using (SqlConnection conn = new SqlConnection(m_connectionString))
@@ -700,16 +731,470 @@ VALUES
700 } 731 }
701 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID) 732 public RegionLightShareData LoadRegionWindlightSettings(UUID regionUUID)
702 { 733 {
703 //This connector doesn't support the windlight module yet 734 RegionLightShareData nWP = new RegionLightShareData();
704 //Return default LL windlight settings 735 nWP.OnSave += StoreRegionWindlightSettings;
705 return new RegionLightShareData(); 736 string sql = "select * from [regionwindlight] where region_id = @regionID";
737 using (SqlConnection conn = new SqlConnection(m_connectionString))
738 using (SqlCommand cmd = new SqlCommand(sql, conn))
739 {
740 cmd.Parameters.Add(_Database.CreateParameter("@regionID", regionUUID));
741 conn.Open();
742 using (SqlDataReader result = cmd.ExecuteReader())
743 {
744 if (!result.Read())
745 {
746 //No result, so store our default windlight profile and return it
747 nWP.regionID = regionUUID;
748 StoreRegionWindlightSettings(nWP);
749 return nWP;
750 }
751 else
752 {
753 nWP.regionID = DBGuid.FromDB(result["region_id"]);
754 nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]);
755 nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]);
756 nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]);
757 nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]);
758 nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]);
759 nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]);
760 nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]);
761 nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]);
762 nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]);
763 nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]);
764 nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]);
765 nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]);
766 nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]);
767 nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]);
768 nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]);
769 nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]);
770 nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]);
771 UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture);
772 nWP.horizon.X = Convert.ToSingle(result["horizon_r"]);
773 nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]);
774 nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]);
775 nWP.horizon.W = Convert.ToSingle(result["horizon_i"]);
776 nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]);
777 nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]);
778 nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]);
779 nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]);
780 nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]);
781 nWP.hazeDensity = Convert.ToSingle(result["haze_density"]);
782 nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]);
783 nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]);
784 nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]);
785 nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]);
786 nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]);
787 nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]);
788 nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]);
789 nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]);
790 nWP.ambient.X = Convert.ToSingle(result["ambient_r"]);
791 nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]);
792 nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]);
793 nWP.ambient.W = Convert.ToSingle(result["ambient_i"]);
794 nWP.eastAngle = Convert.ToSingle(result["east_angle"]);
795 nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]);
796 nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]);
797 nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]);
798 nWP.starBrightness = Convert.ToSingle(result["star_brightness"]);
799 nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]);
800 nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]);
801 nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]);
802 nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]);
803 nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]);
804 nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]);
805 nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]);
806 nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]);
807 nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]);
808 nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]);
809 nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]);
810 nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]);
811 nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]);
812 nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]);
813 nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]);
814 nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]);
815 nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]);
816 nWP.valid = true;
817 }
818 }
819 }
820 return nWP;
706 } 821 }
822
707 public void RemoveRegionWindlightSettings(UUID regionID) 823 public void RemoveRegionWindlightSettings(UUID regionID)
708 { 824 {
825 string sql = "delete from [regionwindlight] where region_id = @region_id";
826 using (SqlConnection conn = new SqlConnection(m_connectionString))
827 using (SqlCommand cmd = new SqlCommand(sql, conn))
828 {
829 conn.Open();
830 cmd.Parameters.Add(_Database.CreateParameter("@region_id", regionID));
831 cmd.ExecuteNonQuery();
832 }
709 } 833 }
834
710 public void StoreRegionWindlightSettings(RegionLightShareData wl) 835 public void StoreRegionWindlightSettings(RegionLightShareData wl)
711 { 836 {
712 //This connector doesn't support the windlight module yet 837 string sql = "select count (region_id) from regionwindlight where region_id = @region_id";
838 bool exists = false;
839 using (SqlConnection conn = new SqlConnection(m_connectionString))
840 {
841 conn.Open();
842 using (SqlCommand cmd = new SqlCommand(sql, conn))
843 {
844 cmd.Parameters.Add(_Database.CreateParameter("@region_id", wl.regionID));
845 exists = (int)cmd.ExecuteScalar() > 0;
846 }
847 }
848 if (exists)
849 {
850 RemoveRegionWindlightSettings(wl.regionID);
851 }
852
853 // sql insert
854 sql = @"INSERT INTO [regionwindlight]
855 ([region_id]
856 ,[water_color_r]
857 ,[water_color_g]
858 ,[water_color_b]
859 ,[water_fog_density_exponent]
860 ,[underwater_fog_modifier]
861 ,[reflection_wavelet_scale_1]
862 ,[reflection_wavelet_scale_2]
863 ,[reflection_wavelet_scale_3]
864 ,[fresnel_scale]
865 ,[fresnel_offset]
866 ,[refract_scale_above]
867 ,[refract_scale_below]
868 ,[blur_multiplier]
869 ,[big_wave_direction_x]
870 ,[big_wave_direction_y]
871 ,[little_wave_direction_x]
872 ,[little_wave_direction_y]
873 ,[normal_map_texture]
874 ,[horizon_r]
875 ,[horizon_g]
876 ,[horizon_b]
877 ,[horizon_i]
878 ,[haze_horizon]
879 ,[blue_density_r]
880 ,[blue_density_g]
881 ,[blue_density_b]
882 ,[blue_density_i]
883 ,[haze_density]
884 ,[density_multiplier]
885 ,[distance_multiplier]
886 ,[max_altitude]
887 ,[sun_moon_color_r]
888 ,[sun_moon_color_g]
889 ,[sun_moon_color_b]
890 ,[sun_moon_color_i]
891 ,[sun_moon_position]
892 ,[ambient_r]
893 ,[ambient_g]
894 ,[ambient_b]
895 ,[ambient_i]
896 ,[east_angle]
897 ,[sun_glow_focus]
898 ,[sun_glow_size]
899 ,[scene_gamma]
900 ,[star_brightness]
901 ,[cloud_color_r]
902 ,[cloud_color_g]
903 ,[cloud_color_b]
904 ,[cloud_color_i]
905 ,[cloud_x]
906 ,[cloud_y]
907 ,[cloud_density]
908 ,[cloud_coverage]
909 ,[cloud_scale]
910 ,[cloud_detail_x]
911 ,[cloud_detail_y]
912 ,[cloud_detail_density]
913 ,[cloud_scroll_x]
914 ,[cloud_scroll_x_lock]
915 ,[cloud_scroll_y]
916 ,[cloud_scroll_y_lock]
917 ,[draw_classic_clouds])
918 VALUES
919 (@region_id
920 ,@water_color_r
921 ,@water_color_g
922 ,@water_color_b
923 ,@water_fog_density_exponent
924 ,@underwater_fog_modifier
925 ,@reflection_wavelet_scale_1
926 ,@reflection_wavelet_scale_2
927 ,@reflection_wavelet_scale_3
928 ,@fresnel_scale
929 ,@fresnel_offset
930 ,@refract_scale_above
931 ,@refract_scale_below
932 ,@blur_multiplier
933 ,@big_wave_direction_x
934 ,@big_wave_direction_y
935 ,@little_wave_direction_x
936 ,@little_wave_direction_y
937 ,@normal_map_texture
938 ,@horizon_r
939 ,@horizon_g
940 ,@horizon_b
941 ,@horizon_i
942 ,@haze_horizon
943 ,@blue_density_r
944 ,@blue_density_g
945 ,@blue_density_b
946 ,@blue_density_i
947 ,@haze_density
948 ,@density_multiplier
949 ,@distance_multiplier
950 ,@max_altitude
951 ,@sun_moon_color_r
952 ,@sun_moon_color_g
953 ,@sun_moon_color_b
954 ,@sun_moon_color_i
955 ,@sun_moon_position
956 ,@ambient_r
957 ,@ambient_g
958 ,@ambient_b
959 ,@ambient_i
960 ,@east_angle
961 ,@sun_glow_focus
962 ,@sun_glow_size
963 ,@scene_gamma
964 ,@star_brightness
965 ,@cloud_color_r
966 ,@cloud_color_g
967 ,@cloud_color_b
968 ,@cloud_color_i
969 ,@cloud_x
970 ,@cloud_y
971 ,@cloud_density
972 ,@cloud_coverage
973 ,@cloud_scale
974 ,@cloud_detail_x
975 ,@cloud_detail_y
976 ,@cloud_detail_density
977 ,@cloud_scroll_x
978 ,@cloud_scroll_x_lock
979 ,@cloud_scroll_y
980 ,@cloud_scroll_y_lock
981 ,@draw_classic_clouds)";
982 using (SqlConnection conn = new SqlConnection(m_connectionString))
983 {
984 conn.Open();
985 using (SqlCommand cmd = new SqlCommand(sql, conn))
986 {
987 cmd.Parameters.Add(_Database.CreateParameter("region_id", wl.regionID));
988 cmd.Parameters.Add(_Database.CreateParameter("water_color_r", wl.waterColor.X));
989 cmd.Parameters.Add(_Database.CreateParameter("water_color_g", wl.waterColor.Y));
990 cmd.Parameters.Add(_Database.CreateParameter("water_color_b", wl.waterColor.Z));
991 cmd.Parameters.Add(_Database.CreateParameter("water_fog_density_exponent", wl.waterFogDensityExponent));
992 cmd.Parameters.Add(_Database.CreateParameter("underwater_fog_modifier", wl.underwaterFogModifier));
993 cmd.Parameters.Add(_Database.CreateParameter("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X));
994 cmd.Parameters.Add(_Database.CreateParameter("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y));
995 cmd.Parameters.Add(_Database.CreateParameter("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z));
996 cmd.Parameters.Add(_Database.CreateParameter("fresnel_scale", wl.fresnelScale));
997 cmd.Parameters.Add(_Database.CreateParameter("fresnel_offset", wl.fresnelOffset));
998 cmd.Parameters.Add(_Database.CreateParameter("refract_scale_above", wl.refractScaleAbove));
999 cmd.Parameters.Add(_Database.CreateParameter("refract_scale_below", wl.refractScaleBelow));
1000 cmd.Parameters.Add(_Database.CreateParameter("blur_multiplier", wl.blurMultiplier));
1001 cmd.Parameters.Add(_Database.CreateParameter("big_wave_direction_x", wl.bigWaveDirection.X));
1002 cmd.Parameters.Add(_Database.CreateParameter("big_wave_direction_y", wl.bigWaveDirection.Y));
1003 cmd.Parameters.Add(_Database.CreateParameter("little_wave_direction_x", wl.littleWaveDirection.X));
1004 cmd.Parameters.Add(_Database.CreateParameter("little_wave_direction_y", wl.littleWaveDirection.Y));
1005 cmd.Parameters.Add(_Database.CreateParameter("normal_map_texture", wl.normalMapTexture));
1006 cmd.Parameters.Add(_Database.CreateParameter("horizon_r", wl.horizon.X));
1007 cmd.Parameters.Add(_Database.CreateParameter("horizon_g", wl.horizon.Y));
1008 cmd.Parameters.Add(_Database.CreateParameter("horizon_b", wl.horizon.Z));
1009 cmd.Parameters.Add(_Database.CreateParameter("horizon_i", wl.horizon.W));
1010 cmd.Parameters.Add(_Database.CreateParameter("haze_horizon", wl.hazeHorizon));
1011 cmd.Parameters.Add(_Database.CreateParameter("blue_density_r", wl.blueDensity.X));
1012 cmd.Parameters.Add(_Database.CreateParameter("blue_density_g", wl.blueDensity.Y));
1013 cmd.Parameters.Add(_Database.CreateParameter("blue_density_b", wl.blueDensity.Z));
1014 cmd.Parameters.Add(_Database.CreateParameter("blue_density_i", wl.blueDensity.W));
1015 cmd.Parameters.Add(_Database.CreateParameter("haze_density", wl.hazeDensity));
1016 cmd.Parameters.Add(_Database.CreateParameter("density_multiplier", wl.densityMultiplier));
1017 cmd.Parameters.Add(_Database.CreateParameter("distance_multiplier", wl.distanceMultiplier));
1018 cmd.Parameters.Add(_Database.CreateParameter("max_altitude", wl.maxAltitude));
1019 cmd.Parameters.Add(_Database.CreateParameter("sun_moon_color_r", wl.sunMoonColor.X));
1020 cmd.Parameters.Add(_Database.CreateParameter("sun_moon_color_g", wl.sunMoonColor.Y));
1021 cmd.Parameters.Add(_Database.CreateParameter("sun_moon_color_b", wl.sunMoonColor.Z));
1022 cmd.Parameters.Add(_Database.CreateParameter("sun_moon_color_i", wl.sunMoonColor.W));
1023 cmd.Parameters.Add(_Database.CreateParameter("sun_moon_position", wl.sunMoonPosition));
1024 cmd.Parameters.Add(_Database.CreateParameter("ambient_r", wl.ambient.X));
1025 cmd.Parameters.Add(_Database.CreateParameter("ambient_g", wl.ambient.Y));
1026 cmd.Parameters.Add(_Database.CreateParameter("ambient_b", wl.ambient.Z));
1027 cmd.Parameters.Add(_Database.CreateParameter("ambient_i", wl.ambient.W));
1028 cmd.Parameters.Add(_Database.CreateParameter("east_angle", wl.eastAngle));
1029 cmd.Parameters.Add(_Database.CreateParameter("sun_glow_focus", wl.sunGlowFocus));
1030 cmd.Parameters.Add(_Database.CreateParameter("sun_glow_size", wl.sunGlowSize));
1031 cmd.Parameters.Add(_Database.CreateParameter("scene_gamma", wl.sceneGamma));
1032 cmd.Parameters.Add(_Database.CreateParameter("star_brightness", wl.starBrightness));
1033 cmd.Parameters.Add(_Database.CreateParameter("cloud_color_r", wl.cloudColor.X));
1034 cmd.Parameters.Add(_Database.CreateParameter("cloud_color_g", wl.cloudColor.Y));
1035 cmd.Parameters.Add(_Database.CreateParameter("cloud_color_b", wl.cloudColor.Z));
1036 cmd.Parameters.Add(_Database.CreateParameter("cloud_color_i", wl.cloudColor.W));
1037 cmd.Parameters.Add(_Database.CreateParameter("cloud_x", wl.cloudXYDensity.X));
1038 cmd.Parameters.Add(_Database.CreateParameter("cloud_y", wl.cloudXYDensity.Y));
1039 cmd.Parameters.Add(_Database.CreateParameter("cloud_density", wl.cloudXYDensity.Z));
1040 cmd.Parameters.Add(_Database.CreateParameter("cloud_coverage", wl.cloudCoverage));
1041 cmd.Parameters.Add(_Database.CreateParameter("cloud_scale", wl.cloudScale));
1042 cmd.Parameters.Add(_Database.CreateParameter("cloud_detail_x", wl.cloudDetailXYDensity.X));
1043 cmd.Parameters.Add(_Database.CreateParameter("cloud_detail_y", wl.cloudDetailXYDensity.Y));
1044 cmd.Parameters.Add(_Database.CreateParameter("cloud_detail_density", wl.cloudDetailXYDensity.Z));
1045 cmd.Parameters.Add(_Database.CreateParameter("cloud_scroll_x", wl.cloudScrollX));
1046 cmd.Parameters.Add(_Database.CreateParameter("cloud_scroll_x_lock", wl.cloudScrollXLock));
1047 cmd.Parameters.Add(_Database.CreateParameter("cloud_scroll_y", wl.cloudScrollY));
1048 cmd.Parameters.Add(_Database.CreateParameter("cloud_scroll_y_lock", wl.cloudScrollYLock));
1049 cmd.Parameters.Add(_Database.CreateParameter("draw_classic_clouds", wl.drawClassicClouds));
1050
1051 cmd.ExecuteNonQuery();
1052 }
1053 }
1054 #region update
1055 // }
1056 // else
1057 // {
1058 // // sql update
1059 // sql = @"UPDATE [OpenSim].[dbo].[regionwindlight]
1060 // SET [region_id] = @region_id
1061 // ,[water_color_r] = @water_color_r
1062 // ,[water_color_g] = @water_color_g
1063 // ,[water_color_b] = @water_color_b
1064 // ,[water_fog_density_exponent] = @water_fog_density_exponent
1065 // ,[underwater_fog_modifier] = @underwater_fog_modifier
1066 // ,[reflection_wavelet_scale_1] = @reflection_wavelet_scale_1
1067 // ,[reflection_wavelet_scale_2] = @reflection_wavelet_scale_2
1068 // ,[reflection_wavelet_scale_3] = @reflection_wavelet_scale_3
1069 // ,[fresnel_scale] = @fresnel_scale
1070 // ,[fresnel_offset] = @fresnel_offset
1071 // ,[refract_scale_above] = @refract_scale_above
1072 // ,[refract_scale_below] = @refract_scale_below
1073 // ,[blur_multiplier] = @blur_multiplier
1074 // ,[big_wave_direction_x] = @big_wave_direction_x
1075 // ,[big_wave_direction_y] = @big_wave_direction_y
1076 // ,[little_wave_direction_x] = @little_wave_direction_x
1077 // ,[little_wave_direction_y] = @little_wave_direction_y
1078 // ,[normal_map_texture] = @normal_map_texture
1079 // ,[horizon_r] = @horizon_r
1080 // ,[horizon_g] = @horizon_g
1081 // ,[horizon_b] = @horizon_b
1082 // ,[horizon_i] = @horizon_i
1083 // ,[haze_horizon] = @haze_horizon
1084 // ,[blue_density_r] = @blue_density_r
1085 // ,[blue_density_g] = @blue_density_g
1086 // ,[blue_density_b] = @blue_density_b
1087 // ,[blue_density_i] = @blue_density_i
1088 // ,[haze_density] = @haze_density
1089 // ,[density_multiplier] = @density_multiplier
1090 // ,[distance_multiplier] = @distance_multiplier
1091 // ,[max_altitude] = @max_altitude
1092 // ,[sun_moon_color_r] = @sun_moon_color_r
1093 // ,[sun_moon_color_g] = @sun_moon_color_g
1094 // ,[sun_moon_color_b] = @sun_moon_color_b
1095 // ,[sun_moon_color_i] = @sun_moon_color_i
1096 // ,[sun_moon_position] = @sun_moon_position
1097 // ,[ambient_r] = @ambient_r
1098 // ,[ambient_g] = @ambient_g
1099 // ,[ambient_b] = @ambient_b
1100 // ,[ambient_i] = @ambient_i
1101 // ,[east_angle] = @east_angle
1102 // ,[sun_glow_focus] = @sun_glow_focus
1103 // ,[sun_glow_size] = @sun_glow_size
1104 // ,[scene_gamma] = @scene_gamma
1105 // ,[star_brightness] = @star_brightness
1106 // ,[cloud_color_r] = @cloud_color_r
1107 // ,[cloud_color_g] = @cloud_color_g
1108 // ,[cloud_color_b] = @cloud_color_b
1109 // ,[cloud_color_i] = @cloud_color_i
1110 // ,[cloud_x] = @cloud_x
1111 // ,[cloud_y] = @cloud_y
1112 // ,[cloud_density] = @cloud_density
1113 // ,[cloud_coverage] = @cloud_coverage
1114 // ,[cloud_scale] = @cloud_scale
1115 // ,[cloud_detail_x] = @cloud_detail_x
1116 // ,[cloud_detail_y] = @cloud_detail_y
1117 // ,[cloud_detail_density] = @cloud_detail_density
1118 // ,[cloud_scroll_x] = @cloud_scroll_x
1119 // ,[cloud_scroll_x_lock] = @cloud_scroll_x_lock
1120 // ,[cloud_scroll_y] = @cloud_scroll_y
1121 // ,[cloud_scroll_y_lock] = @cloud_scroll_y_lock
1122 // ,[draw_classic_clouds] = @draw_classic_clouds
1123 // WHERE region_id = @region_id";
1124 // using (SqlConnection conn = new SqlConnection(m_connectionString))
1125 // {
1126 // conn.Open();
1127 // using (SqlCommand cmd = new SqlCommand(sql, conn))
1128 // {
1129 // cmd.Parameters.AddWithValue("region_id", wl.regionID);
1130 // cmd.Parameters.AddWithValue("water_color_r", wl.waterColor.X);
1131 // cmd.Parameters.AddWithValue("water_color_g", wl.waterColor.Y);
1132 // cmd.Parameters.AddWithValue("water_color_b", wl.waterColor.Z);
1133 // cmd.Parameters.AddWithValue("water_fog_density_exponent", wl.waterFogDensityExponent);
1134 // cmd.Parameters.AddWithValue("underwater_fog_modifier", wl.underwaterFogModifier);
1135 // cmd.Parameters.AddWithValue("reflection_wavelet_scale_1", wl.reflectionWaveletScale.X);
1136 // cmd.Parameters.AddWithValue("reflection_wavelet_scale_2", wl.reflectionWaveletScale.Y);
1137 // cmd.Parameters.AddWithValue("reflection_wavelet_scale_3", wl.reflectionWaveletScale.Z);
1138 // cmd.Parameters.AddWithValue("fresnel_scale", wl.fresnelScale);
1139 // cmd.Parameters.AddWithValue("fresnel_offset", wl.fresnelOffset);
1140 // cmd.Parameters.AddWithValue("refract_scale_above", wl.refractScaleAbove);
1141 // cmd.Parameters.AddWithValue("refract_scale_below", wl.refractScaleBelow);
1142 // cmd.Parameters.AddWithValue("blur_multiplier", wl.blurMultiplier);
1143 // cmd.Parameters.AddWithValue("big_wave_direction_x", wl.bigWaveDirection.X);
1144 // cmd.Parameters.AddWithValue("big_wave_direction_y", wl.bigWaveDirection.Y);
1145 // cmd.Parameters.AddWithValue("little_wave_direction_x", wl.littleWaveDirection.X);
1146 // cmd.Parameters.AddWithValue("little_wave_direction_y", wl.littleWaveDirection.Y);
1147 // cmd.Parameters.AddWithValue("normal_map_texture", wl.normalMapTexture);
1148 // cmd.Parameters.AddWithValue("horizon_r", wl.horizon.X);
1149 // cmd.Parameters.AddWithValue("horizon_g", wl.horizon.Y);
1150 // cmd.Parameters.AddWithValue("horizon_b", wl.horizon.Z);
1151 // cmd.Parameters.AddWithValue("horizon_i", wl.horizon.W);
1152 // cmd.Parameters.AddWithValue("haze_horizon", wl.hazeHorizon);
1153 // cmd.Parameters.AddWithValue("blue_density_r", wl.blueDensity.X);
1154 // cmd.Parameters.AddWithValue("blue_density_g", wl.blueDensity.Y);
1155 // cmd.Parameters.AddWithValue("blue_density_b", wl.blueDensity.Z);
1156 // cmd.Parameters.AddWithValue("blue_density_i", wl.blueDensity.W);
1157 // cmd.Parameters.AddWithValue("haze_density", wl.hazeDensity);
1158 // cmd.Parameters.AddWithValue("density_multiplier", wl.densityMultiplier);
1159 // cmd.Parameters.AddWithValue("distance_multiplier", wl.distanceMultiplier);
1160 // cmd.Parameters.AddWithValue("max_altitude", wl.maxAltitude);
1161 // cmd.Parameters.AddWithValue("sun_moon_color_r", wl.sunMoonColor.X);
1162 // cmd.Parameters.AddWithValue("sun_moon_color_g", wl.sunMoonColor.Y);
1163 // cmd.Parameters.AddWithValue("sun_moon_color_b", wl.sunMoonColor.Z);
1164 // cmd.Parameters.AddWithValue("sun_moon_color_i", wl.sunMoonColor.W);
1165 // cmd.Parameters.AddWithValue("sun_moon_position", wl.sunMoonPosition);
1166 // cmd.Parameters.AddWithValue("ambient_r", wl.ambient.X);
1167 // cmd.Parameters.AddWithValue("ambient_g", wl.ambient.Y);
1168 // cmd.Parameters.AddWithValue("ambient_b", wl.ambient.Z);
1169 // cmd.Parameters.AddWithValue("ambient_i", wl.ambient.W);
1170 // cmd.Parameters.AddWithValue("east_angle", wl.eastAngle);
1171 // cmd.Parameters.AddWithValue("sun_glow_focus", wl.sunGlowFocus);
1172 // cmd.Parameters.AddWithValue("sun_glow_size", wl.sunGlowSize);
1173 // cmd.Parameters.AddWithValue("scene_gamma", wl.sceneGamma);
1174 // cmd.Parameters.AddWithValue("star_brightness", wl.starBrightness);
1175 // cmd.Parameters.AddWithValue("cloud_color_r", wl.cloudColor.X);
1176 // cmd.Parameters.AddWithValue("cloud_color_g", wl.cloudColor.Y);
1177 // cmd.Parameters.AddWithValue("cloud_color_b", wl.cloudColor.Z);
1178 // cmd.Parameters.AddWithValue("cloud_color_i", wl.cloudColor.W);
1179 // cmd.Parameters.AddWithValue("cloud_x", wl.cloudXYDensity.X);
1180 // cmd.Parameters.AddWithValue("cloud_y", wl.cloudXYDensity.Y);
1181 // cmd.Parameters.AddWithValue("cloud_density", wl.cloudXYDensity.Z);
1182 // cmd.Parameters.AddWithValue("cloud_coverage", wl.cloudCoverage);
1183 // cmd.Parameters.AddWithValue("cloud_scale", wl.cloudScale);
1184 // cmd.Parameters.AddWithValue("cloud_detail_x", wl.cloudDetailXYDensity.X);
1185 // cmd.Parameters.AddWithValue("cloud_detail_y", wl.cloudDetailXYDensity.Y);
1186 // cmd.Parameters.AddWithValue("cloud_detail_density", wl.cloudDetailXYDensity.Z);
1187 // cmd.Parameters.AddWithValue("cloud_scroll_x", wl.cloudScrollX);
1188 // cmd.Parameters.AddWithValue("cloud_scroll_x_lock", wl.cloudScrollXLock);
1189 // cmd.Parameters.AddWithValue("cloud_scroll_y", wl.cloudScrollY);
1190 // cmd.Parameters.AddWithValue("cloud_scroll_y_lock", wl.cloudScrollYLock);
1191 // cmd.Parameters.AddWithValue("draw_classic_clouds", wl.drawClassicClouds);
1192
1193 // cmd.ExecuteNonQuery();
1194 // }
1195 // }
1196 // }
1197 #endregion
713 } 1198 }
714 /// <summary> 1199 /// <summary>
715 /// Loads the settings of a region. 1200 /// Loads the settings of a region.
@@ -1136,7 +1621,7 @@ VALUES
1136 if (Convert.ToInt16(primRow["PassTouches"]) != 0) 1621 if (Convert.ToInt16(primRow["PassTouches"]) != 0)
1137 prim.PassTouches = true; 1622 prim.PassTouches = true;
1138 prim.LinkNum = Convert.ToInt32(primRow["LinkNumber"]); 1623 prim.LinkNum = Convert.ToInt32(primRow["LinkNumber"]);
1139 1624
1140 if (!(primRow["MediaURL"] is System.DBNull)) 1625 if (!(primRow["MediaURL"] is System.DBNull))
1141 prim.MediaUrl = (string)primRow["MediaURL"]; 1626 prim.MediaUrl = (string)primRow["MediaURL"];
1142 1627
@@ -1192,11 +1677,11 @@ VALUES
1192 { 1677 {
1193 } 1678 }
1194 1679
1195 if (!(shapeRow["Media"] is System.DBNull) ) 1680 if (!(shapeRow["Media"] is System.DBNull))
1196 { 1681 {
1197 baseShape.Media = PrimitiveBaseShape.MediaList.FromXml((string)shapeRow["Media"]); 1682 baseShape.Media = PrimitiveBaseShape.MediaList.FromXml((string)shapeRow["Media"]);
1198 } 1683 }
1199 1684
1200 1685
1201 return baseShape; 1686 return baseShape;
1202 } 1687 }
@@ -1576,15 +2061,15 @@ VALUES
1576 parameters.Add(_Database.CreateParameter("ExtraParams", s.ExtraParams)); 2061 parameters.Add(_Database.CreateParameter("ExtraParams", s.ExtraParams));
1577 parameters.Add(_Database.CreateParameter("State", s.State)); 2062 parameters.Add(_Database.CreateParameter("State", s.State));
1578 2063
1579 if(null == s.Media ) 2064 if (null == s.Media)
1580 { 2065 {
1581 parameters.Add(_Database.CreateParameter("Media", DBNull.Value)); 2066 parameters.Add(_Database.CreateParameter("Media", DBNull.Value));
1582 } 2067 }
1583 else 2068 else
1584 { 2069 {
1585 parameters.Add(_Database.CreateParameter("Media", s.Media.ToXml())); 2070 parameters.Add(_Database.CreateParameter("Media", s.Media.ToXml()));
1586 } 2071 }
1587 2072
1588 2073
1589 return parameters.ToArray(); 2074 return parameters.ToArray();
1590 } 2075 }
diff --git a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
index 01689a4..10b0f29 100644
--- a/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLXInventoryData.cs
@@ -66,11 +66,18 @@ namespace OpenSim.Data.MSSQL
66 66
67 public bool StoreFolder(XInventoryFolder folder) 67 public bool StoreFolder(XInventoryFolder folder)
68 { 68 {
69 if (folder.folderName.Length > 64)
70 folder.folderName = folder.folderName.Substring(0, 64);
69 return m_Folders.Store(folder); 71 return m_Folders.Store(folder);
70 } 72 }
71 73
72 public bool StoreItem(XInventoryItem item) 74 public bool StoreItem(XInventoryItem item)
73 { 75 {
76 if (item.inventoryName.Length > 64)
77 item.inventoryName = item.inventoryName.Substring(0, 64);
78 if (item.inventoryDescription.Length > 128)
79 item.inventoryDescription = item.inventoryDescription.Substring(0, 128);
80
74 return m_Items.Store(item); 81 return m_Items.Store(item);
75 } 82 }
76 83
@@ -78,7 +85,6 @@ namespace OpenSim.Data.MSSQL
78 { 85 {
79 return m_Folders.Delete(field, val); 86 return m_Folders.Delete(field, val);
80 } 87 }
81
82 public bool DeleteFolders(string[] fields, string[] vals) 88 public bool DeleteFolders(string[] fields, string[] vals)
83 { 89 {
84 return m_Folders.Delete(fields, vals); 90 return m_Folders.Delete(fields, vals);
@@ -88,12 +94,10 @@ namespace OpenSim.Data.MSSQL
88 { 94 {
89 return m_Items.Delete(field, val); 95 return m_Items.Delete(field, val);
90 } 96 }
91
92 public bool DeleteItems(string[] fields, string[] vals) 97 public bool DeleteItems(string[] fields, string[] vals)
93 { 98 {
94 return m_Items.Delete(fields, vals); 99 return m_Items.Delete(fields, vals);
95 } 100 }
96
97 public bool MoveItem(string id, string newParent) 101 public bool MoveItem(string id, string newParent)
98 { 102 {
99 return m_Items.MoveItem(id, newParent); 103 return m_Items.MoveItem(id, newParent);
@@ -172,5 +176,27 @@ namespace OpenSim.Data.MSSQL
172 176
173 } 177 }
174 } 178 }
179 public override bool Store(XInventoryItem item)
180 {
181 if (!base.Store(item))
182 return false;
183 string sql = "update inventoryfolders set version=version+1 where folderID = @folderID";
184 using (SqlConnection conn = new SqlConnection(m_ConnectionString))
185 using (SqlCommand cmd = new SqlCommand(sql, conn))
186 {
187 conn.Open();
188
189 cmd.Parameters.AddWithValue("@folderID", item.parentFolderID.ToString());
190 try
191 {
192 cmd.ExecuteNonQuery();
193 }
194 catch (Exception e)
195 {
196 return false;
197 }
198 }
199 return true;
200 }
175 } 201 }
176} 202}
diff --git a/OpenSim/Data/MSSQL/Resources/Avatar.migrations b/OpenSim/Data/MSSQL/Resources/Avatar.migrations
index 5364153..61f7b56 100644
--- a/OpenSim/Data/MSSQL/Resources/Avatar.migrations
+++ b/OpenSim/Data/MSSQL/Resources/Avatar.migrations
@@ -37,4 +37,28 @@ EXECUTE sp_rename N'dbo.Tmp_Avatars', N'Avatars', 'OBJECT'
37 37
38COMMIT 38COMMIT
39 39
40:VERSION 3
41
42BEGIN TRANSACTION
43
44CREATE TABLE dbo.Tmp_Avatars
45 (
46 PrincipalID uniqueidentifier NOT NULL,
47 [Name] varchar(32) NOT NULL,
48 Value text NOT NULL DEFAULT '',
49 PRIMARY KEY CLUSTERED
50(
51 [PrincipalID] ASC, [Name] ASC
52)WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
53) ON [PRIMARY]
54 TEXTIMAGE_ON [PRIMARY]
55
56IF EXISTS(SELECT * FROM dbo.Avatars)
57 EXEC('INSERT INTO dbo.Tmp_Avatars (PrincipalID, Name, Value)
58 SELECT PrincipalID, CONVERT(text, Name), Value FROM dbo.Avatars WITH (HOLDLOCK TABLOCKX)')
59
60DROP TABLE dbo.Avatars
61
62EXECUTE sp_rename N'dbo.Tmp_Avatars', N'Avatars', 'OBJECT'
63COMMIT
40 64
diff --git a/OpenSim/Data/MSSQL/Resources/GridUserStore.migrations b/OpenSim/Data/MSSQL/Resources/GridUserStore.migrations
index 7a7cecd..ecd3f4d 100644
--- a/OpenSim/Data/MSSQL/Resources/GridUserStore.migrations
+++ b/OpenSim/Data/MSSQL/Resources/GridUserStore.migrations
@@ -17,3 +17,49 @@ CREATE TABLE "GridUser" (
17) 17)
18 18
19COMMIT 19COMMIT
20
21:VERSION 2 # --------------------------
22
23BEGIN TRANSACTION
24
25CREATE TABLE [GridUser_tmp] (
26 [UserID] VARCHAR(255) NOT NULL,
27 [HomeRegionID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
28 [HomePosition] CHAR(64) NOT NULL DEFAULT '<0,0,0>',
29 [HomeLookAt] CHAR(64) NOT NULL DEFAULT '<0,0,0>',
30 [LastRegionID] uniqueidentifier NOT NULL DEFAULT '00000000-0000-0000-0000-000000000000',
31 [LastPosition] CHAR(64) NOT NULL DEFAULT '<0,0,0>',
32 [LastLookAt] CHAR(64) NOT NULL DEFAULT '<0,0,0>',
33 [Online] CHAR(5) NOT NULL DEFAULT 'false',
34 [Login] CHAR(16) NOT NULL DEFAULT '0',
35 [Logout] CHAR(16) NOT NULL DEFAULT '0',
36
37 PRIMARY KEY CLUSTERED
38 (
39 [UserID] ASC
40 )WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
41 ) ON [PRIMARY]
42
43COMMIT
44
45IF EXISTS(SELECT * FROM dbo.GridUser)
46 EXEC('INSERT INTO dbo.GridUser_tmp ([UserID]
47 ,[HomeRegionID]
48 ,[HomePosition]
49 ,[HomeLookAt]
50 ,[LastRegionID]
51 ,[LastPosition]
52 ,[LastLookAt]
53 ,[Online]
54 ,[Login]
55 ,[Logout])
56 SELECT CONVERT(varchar(36), [HomeRegionID]), [HomePosition] ,[HomeLookAt] , CONVERT(varchar(36),[LastRegionID])
57 ,[LastPosition]
58 ,[LastLookAt]
59 ,[Online]
60 ,[Login]
61 ,[Logout] FROM dbo.GridUser WITH (HOLDLOCK TABLOCKX)')
62
63DROP TABLE dbo.GridUser
64
65EXECUTE sp_rename N'dbo.GridUser_tmp', N'GridUser', 'OBJECT' \ No newline at end of file
diff --git a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations
index 340b63d..3995e6c 100644
--- a/OpenSim/Data/MSSQL/Resources/RegionStore.migrations
+++ b/OpenSim/Data/MSSQL/Resources/RegionStore.migrations
@@ -1003,7 +1003,7 @@ CREATE TABLE "regionwindlight" (
1003 PRIMARY KEY ("region_id") 1003 PRIMARY KEY ("region_id")
1004) 1004)
1005 1005
1006COMMIT TRANSACTION 1006COMMIT
1007 1007
1008:VERSION 26 1008:VERSION 26
1009 1009