diff options
author | Charles Krinke | 2008-10-27 00:46:17 +0000 |
---|---|---|
committer | Charles Krinke | 2008-10-27 00:46:17 +0000 |
commit | 8cb889cb0e1a09bee80745b6a6d81641d1c62202 (patch) | |
tree | 3872f75b8201bce8c2c13a200b08e8b24350b5fd /OpenSim/Data/MSSQL/MSSQLRegionData.cs | |
parent | Update CONTRIBUTORS (diff) | |
download | opensim-SC-8cb889cb0e1a09bee80745b6a6d81641d1c62202.zip opensim-SC-8cb889cb0e1a09bee80745b6a6d81641d1c62202.tar.gz opensim-SC-8cb889cb0e1a09bee80745b6a6d81641d1c62202.tar.bz2 opensim-SC-8cb889cb0e1a09bee80745b6a6d81641d1c62202.tar.xz |
Thank you kindly, Ruud Lathrop for a patch that solves:
Primary Key violation when just linked a lot of prims using MSSQL.
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Data/MSSQL/MSSQLRegionData.cs | 337 |
1 files changed, 181 insertions, 156 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLRegionData.cs b/OpenSim/Data/MSSQL/MSSQLRegionData.cs index 4a01ca0..6f4edd1 100644 --- a/OpenSim/Data/MSSQL/MSSQLRegionData.cs +++ b/OpenSim/Data/MSSQL/MSSQLRegionData.cs | |||
@@ -58,9 +58,9 @@ namespace OpenSim.Data.MSSQL | |||
58 | /// <summary> | 58 | /// <summary> |
59 | /// Const for the prim store.. | 59 | /// Const for the prim store.. |
60 | /// </summary> | 60 | /// </summary> |
61 | private const string _PrimSelect = "SELECT * FROM PRIMS WHERE RegionUUID = @RegionUUID AND (SceneGroupID LIKE @SceneGroupID OR UUID IN (@UUID))"; | 61 | private const string _PrimSelect = "SELECT * FROM PRIMS WHERE RegionUUID = @RegionUUID"; //" AND UUID IN (@UUID)"; //SceneGroupID LIKE @SceneGroupID OR |
62 | private const string _ShapeSelect = "SELECT * FROM PRIMSHAPES WHERE UUID in (SELECT UUID FROM PRIMS WHERE RegionUUID = @RegionUUID AND (SceneGroupID LIKE @SceneGroupID OR UUID IN (@UUID)))"; | 62 | private const string _ShapeSelect = "SELECT * FROM PRIMSHAPES WHERE UUID in (SELECT UUID FROM PRIMS WHERE RegionUUID = @RegionUUID)"; // AND UUID IN (@UUID))"; //(SceneGroupID LIKE @SceneGroupID OR |
63 | private const string _ItemsSelect = "SELECT * FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE RegionUUID = @RegionUUID AND (SceneGroupID LIKE @SceneGroupID OR UUID IN (@UUID)))"; | 63 | private const string _ItemsSelect = "SELECT * FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE RegionUUID = @RegionUUID)"; // AND UUID IN (@UUID))"; //(SceneGroupID LIKE @SceneGroupID OR |
64 | 64 | ||
65 | private DataSet _PrimsDataSet; | 65 | private DataSet _PrimsDataSet; |
66 | private SqlDataAdapter _PrimDataAdapter; | 66 | private SqlDataAdapter _PrimDataAdapter; |
@@ -101,8 +101,8 @@ namespace OpenSim.Data.MSSQL | |||
101 | using (SqlCommand primSelectCmd = new SqlCommand(_PrimSelect, connection)) | 101 | using (SqlCommand primSelectCmd = new SqlCommand(_PrimSelect, connection)) |
102 | { | 102 | { |
103 | primSelectCmd.Parameters.AddWithValue("@RegionUUID", ""); | 103 | primSelectCmd.Parameters.AddWithValue("@RegionUUID", ""); |
104 | primSelectCmd.Parameters.AddWithValue("@SceneGroupID", "%"); | 104 | //primSelectCmd.Parameters.AddWithValue("@SceneGroupID", "%"); |
105 | primSelectCmd.Parameters.AddWithValue("@UUID", ""); | 105 | //primSelectCmd.Parameters.AddWithValue("@UUID", ""); |
106 | _PrimDataAdapter = new SqlDataAdapter(primSelectCmd); | 106 | _PrimDataAdapter = new SqlDataAdapter(primSelectCmd); |
107 | 107 | ||
108 | DataTable primDataTable = new DataTable("prims"); | 108 | DataTable primDataTable = new DataTable("prims"); |
@@ -119,8 +119,8 @@ namespace OpenSim.Data.MSSQL | |||
119 | using (SqlCommand shapeSelectCmd = new SqlCommand(_ShapeSelect, connection)) | 119 | using (SqlCommand shapeSelectCmd = new SqlCommand(_ShapeSelect, connection)) |
120 | { | 120 | { |
121 | shapeSelectCmd.Parameters.AddWithValue("@RegionUUID", ""); | 121 | shapeSelectCmd.Parameters.AddWithValue("@RegionUUID", ""); |
122 | shapeSelectCmd.Parameters.AddWithValue("@SceneGroupID", "%"); | 122 | //shapeSelectCmd.Parameters.AddWithValue("@SceneGroupID", "%"); |
123 | shapeSelectCmd.Parameters.AddWithValue("@UUID", ""); | 123 | //shapeSelectCmd.Parameters.AddWithValue("@UUID", ""); |
124 | _ShapeDataAdapter = new SqlDataAdapter(shapeSelectCmd); | 124 | _ShapeDataAdapter = new SqlDataAdapter(shapeSelectCmd); |
125 | 125 | ||
126 | DataTable shapeDataTable = new DataTable("primshapes"); | 126 | DataTable shapeDataTable = new DataTable("primshapes"); |
@@ -137,8 +137,8 @@ namespace OpenSim.Data.MSSQL | |||
137 | using (SqlCommand itemSelectCmd = new SqlCommand(_ItemsSelect, connection)) | 137 | using (SqlCommand itemSelectCmd = new SqlCommand(_ItemsSelect, connection)) |
138 | { | 138 | { |
139 | itemSelectCmd.Parameters.AddWithValue("@RegionUUID", ""); | 139 | itemSelectCmd.Parameters.AddWithValue("@RegionUUID", ""); |
140 | itemSelectCmd.Parameters.AddWithValue("@SceneGroupID", "%"); | 140 | //itemSelectCmd.Parameters.AddWithValue("@SceneGroupID", "%"); |
141 | itemSelectCmd.Parameters.AddWithValue("@UUID", ""); | 141 | //itemSelectCmd.Parameters.AddWithValue("@UUID", ""); |
142 | _ItemsDataAdapter = new SqlDataAdapter(itemSelectCmd); | 142 | _ItemsDataAdapter = new SqlDataAdapter(itemSelectCmd); |
143 | 143 | ||
144 | DataTable itemsDataTable = new DataTable("primitems"); | 144 | DataTable itemsDataTable = new DataTable("primitems"); |
@@ -328,55 +328,60 @@ namespace OpenSim.Data.MSSQL | |||
328 | //Retrieve all values of current region, and current scene/or prims | 328 | //Retrieve all values of current region, and current scene/or prims |
329 | //Build primID's, we use IN so I can select all prims from objgroup | 329 | //Build primID's, we use IN so I can select all prims from objgroup |
330 | string primID = ""; | 330 | string primID = ""; |
331 | foreach (SceneObjectPart prim in obj.Children.Values) | 331 | // foreach (SceneObjectPart prim in obj.Children.Values) |
332 | // { | ||
333 | // primID += prim.UUID + "', '"; | ||
334 | // } | ||
335 | // primID = primID.Remove(primID.LastIndexOf("',")); | ||
336 | |||
337 | lock (_Database) | ||
332 | { | 338 | { |
333 | primID += prim.UUID + "', '"; | 339 | RetrievePrimsDataForRegion(regionUUID, obj.UUID, primID); |
334 | } | ||
335 | primID = primID.Remove(primID.LastIndexOf("',")); | ||
336 | 340 | ||
337 | RetrievePrimsDataForRegion(regionUUID, obj.UUID, primID); | 341 | _Log.InfoFormat("[REGION DB]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count); |
338 | 342 | ||
339 | _Log.InfoFormat("[REGION DB]: Adding/Changing SceneObjectGroup: {0} to region: {1}, object has {2} prims.", obj.UUID, regionUUID, obj.Children.Count); | 343 | DataTable prims = _PrimsDataSet.Tables["prims"]; |
344 | DataTable shapes = _PrimsDataSet.Tables["primshapes"]; | ||
340 | 345 | ||
341 | foreach (SceneObjectPart prim in obj.Children.Values) | 346 | foreach (SceneObjectPart prim in obj.Children.Values) |
342 | { | ||
343 | if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) == 0 | ||
344 | && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 | ||
345 | && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0) | ||
346 | { | 347 | { |
347 | 348 | if ((prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Physics) == 0 | |
348 | DataTable prims = _PrimsDataSet.Tables["prims"]; | 349 | && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.Temporary) == 0 |
349 | DataTable shapes = _PrimsDataSet.Tables["primshapes"]; | 350 | && (prim.GetEffectiveObjectFlags() & (uint)PrimFlags.TemporaryOnRez) == 0) |
350 | |||
351 | DataRow primRow = prims.Rows.Find(prim.UUID.ToString()); | ||
352 | if (primRow == null) | ||
353 | { | ||
354 | primRow = prims.NewRow(); | ||
355 | fillPrimRow(primRow, prim, obj.UUID, regionUUID); | ||
356 | prims.Rows.Add(primRow); | ||
357 | } | ||
358 | else | ||
359 | { | 351 | { |
360 | fillPrimRow(primRow, prim, obj.UUID, regionUUID); | ||
361 | } | ||
362 | 352 | ||
363 | DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString()); | 353 | DataRow primRow = prims.Rows.Find(prim.UUID.ToString()); |
364 | if (shapeRow == null) | 354 | if (primRow == null) |
365 | { | 355 | { |
366 | shapeRow = shapes.NewRow(); | 356 | // _Log.DebugFormat("[REGION DB]: Adding new prim with key: {0}", prim.UUID); |
367 | fillShapeRow(shapeRow, prim); | 357 | primRow = prims.NewRow(); |
368 | shapes.Rows.Add(shapeRow); | 358 | fillPrimRow(primRow, prim, obj.UUID, regionUUID); |
369 | } | 359 | prims.Rows.Add(primRow); |
370 | else | 360 | } |
371 | { | 361 | else |
372 | fillShapeRow(shapeRow, prim); | 362 | { |
363 | // _Log.DebugFormat("[REGION DB]: Changing prim with key: {0}", prim.UUID); | ||
364 | fillPrimRow(primRow, prim, obj.UUID, regionUUID); | ||
365 | } | ||
366 | |||
367 | DataRow shapeRow = shapes.Rows.Find(prim.UUID.ToString()); | ||
368 | if (shapeRow == null) | ||
369 | { | ||
370 | shapeRow = shapes.NewRow(); | ||
371 | fillShapeRow(shapeRow, prim); | ||
372 | shapes.Rows.Add(shapeRow); | ||
373 | } | ||
374 | else | ||
375 | { | ||
376 | fillShapeRow(shapeRow, prim); | ||
377 | } | ||
373 | } | 378 | } |
374 | 379 | ||
375 | } | 380 | } |
376 | } | ||
377 | 381 | ||
378 | //Save changes | 382 | //Save changes |
379 | CommitDataSet(); | 383 | CommitDataSet(); |
384 | } | ||
380 | } | 385 | } |
381 | 386 | ||
382 | /// <summary> | 387 | /// <summary> |
@@ -394,16 +399,19 @@ namespace OpenSim.Data.MSSQL | |||
394 | string sqlPrimItems = string.Format("DELETE FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE SceneGroupID = '{0}')", objectID); | 399 | string sqlPrimItems = string.Format("DELETE FROM PRIMITEMS WHERE primID in (SELECT UUID FROM PRIMS WHERE SceneGroupID = '{0}')", objectID); |
395 | string sqlPrimShapes = string.Format("DELETE FROM PRIMSHAPES WHERE uuid in (SELECT UUID FROM PRIMS WHERE SceneGroupID = '{0}')", objectID); | 400 | string sqlPrimShapes = string.Format("DELETE FROM PRIMSHAPES WHERE uuid in (SELECT UUID FROM PRIMS WHERE SceneGroupID = '{0}')", objectID); |
396 | 401 | ||
397 | //Using the non transaction mode. | 402 | lock (_Database) |
398 | using (AutoClosingSqlCommand cmd = _Database.Query(sqlPrimShapes)) | ||
399 | { | 403 | { |
400 | cmd.ExecuteNonQuery(); | 404 | //Using the non transaction mode. |
405 | using (AutoClosingSqlCommand cmd = _Database.Query(sqlPrimShapes)) | ||
406 | { | ||
407 | cmd.ExecuteNonQuery(); | ||
401 | 408 | ||
402 | cmd.CommandText = sqlPrimItems; | 409 | cmd.CommandText = sqlPrimItems; |
403 | cmd.ExecuteNonQuery(); | 410 | cmd.ExecuteNonQuery(); |
404 | 411 | ||
405 | cmd.CommandText = sqlPrims; | 412 | cmd.CommandText = sqlPrims; |
406 | cmd.ExecuteNonQuery(); | 413 | cmd.ExecuteNonQuery(); |
414 | } | ||
407 | } | 415 | } |
408 | } | 416 | } |
409 | 417 | ||
@@ -921,130 +929,132 @@ VALUES | |||
921 | /// <summary> | 929 | /// <summary> |
922 | /// Builds the prim from a datarecord. | 930 | /// Builds the prim from a datarecord. |
923 | /// </summary> | 931 | /// </summary> |
924 | /// <param name="row">datarecord</param> | 932 | /// <param name="primRow">datarecord</param> |
925 | /// <returns></returns> | 933 | /// <returns></returns> |
926 | private static SceneObjectPart buildPrim(DataRow row) | 934 | private static SceneObjectPart buildPrim(DataRow primRow) |
927 | { | 935 | { |
928 | SceneObjectPart prim = new SceneObjectPart(); | 936 | SceneObjectPart prim = new SceneObjectPart(); |
929 | 937 | ||
930 | prim.UUID = new UUID((String)row["UUID"]); | 938 | prim.UUID = new UUID((String)primRow["UUID"]); |
931 | // explicit conversion of integers is required, which sort | 939 | // explicit conversion of integers is required, which sort |
932 | // of sucks. No idea if there is a shortcut here or not. | 940 | // of sucks. No idea if there is a shortcut here or not. |
933 | prim.ParentID = Convert.ToUInt32(row["ParentID"]); | 941 | prim.ParentID = Convert.ToUInt32(primRow["ParentID"]); |
934 | prim.CreationDate = Convert.ToInt32(row["CreationDate"]); | 942 | prim.CreationDate = Convert.ToInt32(primRow["CreationDate"]); |
935 | prim.Name = (String)row["Name"]; | 943 | prim.Name = (String)primRow["Name"]; |
936 | // various text fields | 944 | // various text fields |
937 | prim.Text = (String)row["Text"]; | 945 | prim.Text = (String)primRow["Text"]; |
938 | prim.Color = Color.FromArgb(Convert.ToInt32(row["ColorA"]), | 946 | prim.Color = Color.FromArgb(Convert.ToInt32(primRow["ColorA"]), |
939 | Convert.ToInt32(row["ColorR"]), | 947 | Convert.ToInt32(primRow["ColorR"]), |
940 | Convert.ToInt32(row["ColorG"]), | 948 | Convert.ToInt32(primRow["ColorG"]), |
941 | Convert.ToInt32(row["ColorB"])); | 949 | Convert.ToInt32(primRow["ColorB"])); |
942 | prim.Description = (String)row["Description"]; | 950 | prim.Description = (String)primRow["Description"]; |
943 | prim.SitName = (String)row["SitName"]; | 951 | prim.SitName = (String)primRow["SitName"]; |
944 | prim.TouchName = (String)row["TouchName"]; | 952 | prim.TouchName = (String)primRow["TouchName"]; |
945 | // permissions | 953 | // permissions |
946 | prim.ObjectFlags = Convert.ToUInt32(row["ObjectFlags"]); | 954 | prim.ObjectFlags = Convert.ToUInt32(primRow["ObjectFlags"]); |
947 | prim.CreatorID = new UUID((String)row["CreatorID"]); | 955 | prim.CreatorID = new UUID((String)primRow["CreatorID"]); |
948 | prim.OwnerID = new UUID((String)row["OwnerID"]); | 956 | prim.OwnerID = new UUID((String)primRow["OwnerID"]); |
949 | prim.GroupID = new UUID((String)row["GroupID"]); | 957 | prim.GroupID = new UUID((String)primRow["GroupID"]); |
950 | prim.LastOwnerID = new UUID((String)row["LastOwnerID"]); | 958 | prim.LastOwnerID = new UUID((String)primRow["LastOwnerID"]); |
951 | prim.OwnerMask = Convert.ToUInt32(row["OwnerMask"]); | 959 | prim.OwnerMask = Convert.ToUInt32(primRow["OwnerMask"]); |
952 | prim.NextOwnerMask = Convert.ToUInt32(row["NextOwnerMask"]); | 960 | prim.NextOwnerMask = Convert.ToUInt32(primRow["NextOwnerMask"]); |
953 | prim.GroupMask = Convert.ToUInt32(row["GroupMask"]); | 961 | prim.GroupMask = Convert.ToUInt32(primRow["GroupMask"]); |
954 | prim.EveryoneMask = Convert.ToUInt32(row["EveryoneMask"]); | 962 | prim.EveryoneMask = Convert.ToUInt32(primRow["EveryoneMask"]); |
955 | prim.BaseMask = Convert.ToUInt32(row["BaseMask"]); | 963 | prim.BaseMask = Convert.ToUInt32(primRow["BaseMask"]); |
956 | // vectors | 964 | // vectors |
957 | prim.OffsetPosition = new Vector3( | 965 | prim.OffsetPosition = new Vector3( |
958 | Convert.ToSingle(row["PositionX"]), | 966 | Convert.ToSingle(primRow["PositionX"]), |
959 | Convert.ToSingle(row["PositionY"]), | 967 | Convert.ToSingle(primRow["PositionY"]), |
960 | Convert.ToSingle(row["PositionZ"])); | 968 | Convert.ToSingle(primRow["PositionZ"])); |
961 | 969 | ||
962 | prim.GroupPosition = new Vector3( | 970 | prim.GroupPosition = new Vector3( |
963 | Convert.ToSingle(row["GroupPositionX"]), | 971 | Convert.ToSingle(primRow["GroupPositionX"]), |
964 | Convert.ToSingle(row["GroupPositionY"]), | 972 | Convert.ToSingle(primRow["GroupPositionY"]), |
965 | Convert.ToSingle(row["GroupPositionZ"])); | 973 | Convert.ToSingle(primRow["GroupPositionZ"])); |
966 | 974 | ||
967 | prim.Velocity = new Vector3( | 975 | prim.Velocity = new Vector3( |
968 | Convert.ToSingle(row["VelocityX"]), | 976 | Convert.ToSingle(primRow["VelocityX"]), |
969 | Convert.ToSingle(row["VelocityY"]), | 977 | Convert.ToSingle(primRow["VelocityY"]), |
970 | Convert.ToSingle(row["VelocityZ"])); | 978 | Convert.ToSingle(primRow["VelocityZ"])); |
971 | 979 | ||
972 | prim.AngularVelocity = new Vector3( | 980 | prim.AngularVelocity = new Vector3( |
973 | Convert.ToSingle(row["AngularVelocityX"]), | 981 | Convert.ToSingle(primRow["AngularVelocityX"]), |
974 | Convert.ToSingle(row["AngularVelocityY"]), | 982 | Convert.ToSingle(primRow["AngularVelocityY"]), |
975 | Convert.ToSingle(row["AngularVelocityZ"])); | 983 | Convert.ToSingle(primRow["AngularVelocityZ"])); |
976 | 984 | ||
977 | prim.Acceleration = new Vector3( | 985 | prim.Acceleration = new Vector3( |
978 | Convert.ToSingle(row["AccelerationX"]), | 986 | Convert.ToSingle(primRow["AccelerationX"]), |
979 | Convert.ToSingle(row["AccelerationY"]), | 987 | Convert.ToSingle(primRow["AccelerationY"]), |
980 | Convert.ToSingle(row["AccelerationZ"])); | 988 | Convert.ToSingle(primRow["AccelerationZ"])); |
981 | 989 | ||
982 | // quaternions | 990 | // quaternions |
983 | prim.RotationOffset = new Quaternion( | 991 | prim.RotationOffset = new Quaternion( |
984 | Convert.ToSingle(row["RotationX"]), | 992 | Convert.ToSingle(primRow["RotationX"]), |
985 | Convert.ToSingle(row["RotationY"]), | 993 | Convert.ToSingle(primRow["RotationY"]), |
986 | Convert.ToSingle(row["RotationZ"]), | 994 | Convert.ToSingle(primRow["RotationZ"]), |
987 | Convert.ToSingle(row["RotationW"])); | 995 | Convert.ToSingle(primRow["RotationW"])); |
988 | 996 | ||
989 | prim.SitTargetPositionLL = new Vector3( | 997 | prim.SitTargetPositionLL = new Vector3( |
990 | Convert.ToSingle(row["SitTargetOffsetX"]), | 998 | Convert.ToSingle(primRow["SitTargetOffsetX"]), |
991 | Convert.ToSingle(row["SitTargetOffsetY"]), | 999 | Convert.ToSingle(primRow["SitTargetOffsetY"]), |
992 | Convert.ToSingle(row["SitTargetOffsetZ"])); | 1000 | Convert.ToSingle(primRow["SitTargetOffsetZ"])); |
993 | 1001 | ||
994 | prim.SitTargetOrientationLL = new Quaternion( | 1002 | prim.SitTargetOrientationLL = new Quaternion( |
995 | Convert.ToSingle(row["SitTargetOrientX"]), | 1003 | Convert.ToSingle(primRow["SitTargetOrientX"]), |
996 | Convert.ToSingle(row["SitTargetOrientY"]), | 1004 | Convert.ToSingle(primRow["SitTargetOrientY"]), |
997 | Convert.ToSingle(row["SitTargetOrientZ"]), | 1005 | Convert.ToSingle(primRow["SitTargetOrientZ"]), |
998 | Convert.ToSingle(row["SitTargetOrientW"])); | 1006 | Convert.ToSingle(primRow["SitTargetOrientW"])); |
999 | 1007 | ||
1000 | prim.PayPrice[0] = Convert.ToInt32(row["PayPrice"]); | 1008 | prim.PayPrice[0] = Convert.ToInt32(primRow["PayPrice"]); |
1001 | prim.PayPrice[1] = Convert.ToInt32(row["PayButton1"]); | 1009 | prim.PayPrice[1] = Convert.ToInt32(primRow["PayButton1"]); |
1002 | prim.PayPrice[2] = Convert.ToInt32(row["PayButton2"]); | 1010 | prim.PayPrice[2] = Convert.ToInt32(primRow["PayButton2"]); |
1003 | prim.PayPrice[3] = Convert.ToInt32(row["PayButton3"]); | 1011 | prim.PayPrice[3] = Convert.ToInt32(primRow["PayButton3"]); |
1004 | prim.PayPrice[4] = Convert.ToInt32(row["PayButton4"]); | 1012 | prim.PayPrice[4] = Convert.ToInt32(primRow["PayButton4"]); |
1005 | 1013 | ||
1006 | prim.Sound = new UUID(row["LoopedSound"].ToString()); | 1014 | prim.Sound = new UUID(primRow["LoopedSound"].ToString()); |
1007 | prim.SoundGain = Convert.ToSingle(row["LoopedSoundGain"]); | 1015 | prim.SoundGain = Convert.ToSingle(primRow["LoopedSoundGain"]); |
1008 | prim.SoundFlags = 1; // If it's persisted at all, it's looped | 1016 | prim.SoundFlags = 1; // If it's persisted at all, it's looped |
1009 | 1017 | ||
1010 | if (!row.IsNull("TextureAnimation") && row["TextureAnimation"] != DBNull.Value) | 1018 | if (!primRow.IsNull("TextureAnimation") && primRow["TextureAnimation"] != DBNull.Value) |
1011 | prim.TextureAnimation = (Byte[])row["TextureAnimation"]; | 1019 | prim.TextureAnimation = (Byte[])primRow["TextureAnimation"]; |
1012 | if (!row.IsNull("ParticleSystem")) | 1020 | if (!primRow.IsNull("ParticleSystem")) |
1013 | prim.ParticleSystem = (Byte[])row["ParticleSystem"]; | 1021 | prim.ParticleSystem = (Byte[])primRow["ParticleSystem"]; |
1014 | 1022 | ||
1015 | prim.RotationalVelocity = new Vector3( | 1023 | prim.RotationalVelocity = new Vector3( |
1016 | Convert.ToSingle(row["OmegaX"]), | 1024 | Convert.ToSingle(primRow["OmegaX"]), |
1017 | Convert.ToSingle(row["OmegaY"]), | 1025 | Convert.ToSingle(primRow["OmegaY"]), |
1018 | Convert.ToSingle(row["OmegaZ"])); | 1026 | Convert.ToSingle(primRow["OmegaZ"])); |
1019 | 1027 | ||
1020 | prim.SetCameraEyeOffset(new Vector3( | 1028 | prim.SetCameraEyeOffset(new Vector3( |
1021 | Convert.ToSingle(row["CameraEyeOffsetX"]), | 1029 | Convert.ToSingle(primRow["CameraEyeOffsetX"]), |
1022 | Convert.ToSingle(row["CameraEyeOffsetY"]), | 1030 | Convert.ToSingle(primRow["CameraEyeOffsetY"]), |
1023 | Convert.ToSingle(row["CameraEyeOffsetZ"]) | 1031 | Convert.ToSingle(primRow["CameraEyeOffsetZ"]) |
1024 | )); | 1032 | )); |
1025 | 1033 | ||
1026 | prim.SetCameraAtOffset(new Vector3( | 1034 | prim.SetCameraAtOffset(new Vector3( |
1027 | Convert.ToSingle(row["CameraAtOffsetX"]), | 1035 | Convert.ToSingle(primRow["CameraAtOffsetX"]), |
1028 | Convert.ToSingle(row["CameraAtOffsetY"]), | 1036 | Convert.ToSingle(primRow["CameraAtOffsetY"]), |
1029 | Convert.ToSingle(row["CameraAtOffsetZ"]) | 1037 | Convert.ToSingle(primRow["CameraAtOffsetZ"]) |
1030 | )); | 1038 | )); |
1031 | 1039 | ||
1032 | if (Convert.ToInt16(row["ForceMouselook"]) != 0) | 1040 | if (Convert.ToInt16(primRow["ForceMouselook"]) != 0) |
1033 | prim.SetForceMouselook(true); | 1041 | prim.SetForceMouselook(true); |
1034 | 1042 | ||
1035 | prim.ScriptAccessPin = Convert.ToInt32(row["ScriptAccessPin"]); | 1043 | prim.ScriptAccessPin = Convert.ToInt32(primRow["ScriptAccessPin"]); |
1036 | 1044 | ||
1037 | if (Convert.ToInt16(row["AllowedDrop"]) != 0) | 1045 | if (Convert.ToInt16(primRow["AllowedDrop"]) != 0) |
1038 | prim.AllowedDrop = true; | 1046 | prim.AllowedDrop = true; |
1039 | 1047 | ||
1040 | if (Convert.ToInt16(row["DieAtEdge"]) != 0) | 1048 | if (Convert.ToInt16(primRow["DieAtEdge"]) != 0) |
1041 | prim.DIE_AT_EDGE = true; | 1049 | prim.DIE_AT_EDGE = true; |
1042 | 1050 | ||
1043 | prim.SalePrice = Convert.ToInt32(row["SalePrice"]); | 1051 | prim.SalePrice = Convert.ToInt32(primRow["SalePrice"]); |
1044 | prim.ObjectSaleType = Convert.ToByte(row["SaleType"]); | 1052 | prim.ObjectSaleType = Convert.ToByte(primRow["SaleType"]); |
1053 | |||
1054 | prim.Material = Convert.ToByte(primRow["Material"]); | ||
1045 | 1055 | ||
1046 | if (!row.IsNull("ClickAction")) | 1056 | if (!primRow.IsNull("ClickAction")) |
1047 | prim.ClickAction = Convert.ToByte(row["ClickAction"]); | 1057 | prim.ClickAction = Convert.ToByte(primRow["ClickAction"]); |
1048 | 1058 | ||
1049 | return prim; | 1059 | return prim; |
1050 | } | 1060 | } |
@@ -1306,6 +1316,10 @@ VALUES | |||
1306 | // the UUID of the root part for this SceneObjectGroup | 1316 | // the UUID of the root part for this SceneObjectGroup |
1307 | // various text fields | 1317 | // various text fields |
1308 | row["Text"] = prim.Text; | 1318 | row["Text"] = prim.Text; |
1319 | row["ColorR"] = prim.Color.R; | ||
1320 | row["ColorG"] = prim.Color.G; | ||
1321 | row["ColorB"] = prim.Color.B; | ||
1322 | row["ColorA"] = prim.Color.A; | ||
1309 | row["Description"] = prim.Description; | 1323 | row["Description"] = prim.Description; |
1310 | row["SitName"] = prim.SitName; | 1324 | row["SitName"] = prim.SitName; |
1311 | row["TouchName"] = prim.TouchName; | 1325 | row["TouchName"] = prim.TouchName; |
@@ -1372,6 +1386,7 @@ VALUES | |||
1372 | } | 1386 | } |
1373 | 1387 | ||
1374 | row["TextureAnimation"] = prim.TextureAnimation; | 1388 | row["TextureAnimation"] = prim.TextureAnimation; |
1389 | row["ParticleSystem"] = prim.ParticleSystem; | ||
1375 | 1390 | ||
1376 | row["OmegaX"] = prim.RotationalVelocity.X; | 1391 | row["OmegaX"] = prim.RotationalVelocity.X; |
1377 | row["OmegaY"] = prim.RotationalVelocity.Y; | 1392 | row["OmegaY"] = prim.RotationalVelocity.Y; |
@@ -1404,6 +1419,11 @@ VALUES | |||
1404 | 1419 | ||
1405 | row["SalePrice"] = prim.SalePrice; | 1420 | row["SalePrice"] = prim.SalePrice; |
1406 | row["SaleType"] = Convert.ToInt16(prim.ObjectSaleType); | 1421 | row["SaleType"] = Convert.ToInt16(prim.ObjectSaleType); |
1422 | |||
1423 | byte clickAction = prim.ClickAction; | ||
1424 | row["ClickAction"] = clickAction; | ||
1425 | |||
1426 | row["Material"] = prim.Material; | ||
1407 | } | 1427 | } |
1408 | 1428 | ||
1409 | /// <summary> | 1429 | /// <summary> |
@@ -1461,31 +1481,33 @@ VALUES | |||
1461 | { | 1481 | { |
1462 | _PrimDataAdapter.SelectCommand.Connection = connection; | 1482 | _PrimDataAdapter.SelectCommand.Connection = connection; |
1463 | _PrimDataAdapter.SelectCommand.Parameters["@RegionUUID"].Value = regionUUID.ToString(); | 1483 | _PrimDataAdapter.SelectCommand.Parameters["@RegionUUID"].Value = regionUUID.ToString(); |
1464 | if (sceneGroupID != UUID.Zero) | 1484 | // if (sceneGroupID != UUID.Zero) |
1465 | _PrimDataAdapter.SelectCommand.Parameters["@SceneGroupID"].Value = sceneGroupID.ToString(); | 1485 | // _PrimDataAdapter.SelectCommand.Parameters["@SceneGroupID"].Value = sceneGroupID.ToString(); |
1466 | else | 1486 | // else |
1467 | _PrimDataAdapter.SelectCommand.Parameters["@SceneGroupID"].Value = "%"; | 1487 | // _PrimDataAdapter.SelectCommand.Parameters["@SceneGroupID"].Value = "%"; |
1468 | _PrimDataAdapter.SelectCommand.Parameters["@UUID"].Value = primID; | 1488 | // _PrimDataAdapter.SelectCommand.Parameters["@UUID"].Value = primID; |
1469 | 1489 | ||
1470 | _PrimDataAdapter.Fill(_PrimsDataSet, "prims"); | 1490 | _PrimDataAdapter.Fill(_PrimsDataSet, "prims"); |
1471 | 1491 | ||
1492 | _Log.Debug("Prim row count: " + _PrimsDataSet.Tables["prims"].Rows.Count); | ||
1493 | |||
1472 | _ShapeDataAdapter.SelectCommand.Connection = connection; | 1494 | _ShapeDataAdapter.SelectCommand.Connection = connection; |
1473 | _ShapeDataAdapter.SelectCommand.Parameters["@RegionUUID"].Value = regionUUID.ToString(); | 1495 | _ShapeDataAdapter.SelectCommand.Parameters["@RegionUUID"].Value = regionUUID.ToString(); |
1474 | if (sceneGroupID != UUID.Zero) | 1496 | // if (sceneGroupID != UUID.Zero) |
1475 | _ShapeDataAdapter.SelectCommand.Parameters["@SceneGroupID"].Value = sceneGroupID.ToString(); | 1497 | // _ShapeDataAdapter.SelectCommand.Parameters["@SceneGroupID"].Value = sceneGroupID.ToString(); |
1476 | else | 1498 | // else |
1477 | _ShapeDataAdapter.SelectCommand.Parameters["@SceneGroupID"].Value = "%"; | 1499 | // _ShapeDataAdapter.SelectCommand.Parameters["@SceneGroupID"].Value = "%"; |
1478 | _ShapeDataAdapter.SelectCommand.Parameters["@UUID"].Value = primID; | 1500 | // _ShapeDataAdapter.SelectCommand.Parameters["@UUID"].Value = primID; |
1479 | 1501 | ||
1480 | _ShapeDataAdapter.Fill(_PrimsDataSet, "primshapes"); | 1502 | _ShapeDataAdapter.Fill(_PrimsDataSet, "primshapes"); |
1481 | 1503 | ||
1482 | _ItemsDataAdapter.SelectCommand.Connection = connection; | 1504 | _ItemsDataAdapter.SelectCommand.Connection = connection; |
1483 | _ItemsDataAdapter.SelectCommand.Parameters["@RegionUUID"].Value = regionUUID.ToString(); | 1505 | _ItemsDataAdapter.SelectCommand.Parameters["@RegionUUID"].Value = regionUUID.ToString(); |
1484 | if (sceneGroupID != UUID.Zero) | 1506 | // if (sceneGroupID != UUID.Zero) |
1485 | _ItemsDataAdapter.SelectCommand.Parameters["@SceneGroupID"].Value = sceneGroupID.ToString(); | 1507 | // _ItemsDataAdapter.SelectCommand.Parameters["@SceneGroupID"].Value = sceneGroupID.ToString(); |
1486 | else | 1508 | // else |
1487 | _ItemsDataAdapter.SelectCommand.Parameters["@SceneGroupID"].Value = "%"; | 1509 | // _ItemsDataAdapter.SelectCommand.Parameters["@SceneGroupID"].Value = "%"; |
1488 | _ItemsDataAdapter.SelectCommand.Parameters["@UUID"].Value = primID; | 1510 | // _ItemsDataAdapter.SelectCommand.Parameters["@UUID"].Value = primID; |
1489 | 1511 | ||
1490 | _ItemsDataAdapter.Fill(_PrimsDataSet, "primitems"); | 1512 | _ItemsDataAdapter.Fill(_PrimsDataSet, "primitems"); |
1491 | } | 1513 | } |
@@ -1496,7 +1518,7 @@ VALUES | |||
1496 | /// </summary> | 1518 | /// </summary> |
1497 | private void CommitDataSet() | 1519 | private void CommitDataSet() |
1498 | { | 1520 | { |
1499 | lock (_PrimsDataSet) | 1521 | try |
1500 | { | 1522 | { |
1501 | using (SqlConnection connection = _Database.DatabaseConnection()) | 1523 | using (SqlConnection connection = _Database.DatabaseConnection()) |
1502 | { | 1524 | { |
@@ -1515,14 +1537,17 @@ VALUES | |||
1515 | _PrimDataAdapter.Update(_PrimsDataSet.Tables["prims"]); | 1537 | _PrimDataAdapter.Update(_PrimsDataSet.Tables["prims"]); |
1516 | _ShapeDataAdapter.Update(_PrimsDataSet.Tables["primshapes"]); | 1538 | _ShapeDataAdapter.Update(_PrimsDataSet.Tables["primshapes"]); |
1517 | _ItemsDataAdapter.Update(_PrimsDataSet.Tables["primitems"]); | 1539 | _ItemsDataAdapter.Update(_PrimsDataSet.Tables["primitems"]); |
1518 | |||
1519 | _PrimsDataSet.AcceptChanges(); | ||
1520 | |||
1521 | _PrimsDataSet.Tables["prims"].Clear(); | ||
1522 | _PrimsDataSet.Tables["primshapes"].Clear(); | ||
1523 | _PrimsDataSet.Tables["primitems"].Clear(); | ||
1524 | } | 1540 | } |
1525 | } | 1541 | } |
1542 | finally | ||
1543 | { | ||
1544 | _PrimsDataSet.AcceptChanges(); | ||
1545 | |||
1546 | _PrimsDataSet.Tables["prims"].Clear(); | ||
1547 | _PrimsDataSet.Tables["primshapes"].Clear(); | ||
1548 | _PrimsDataSet.Tables["primitems"].Clear(); | ||
1549 | |||
1550 | } | ||
1526 | } | 1551 | } |
1527 | 1552 | ||
1528 | /// <summary> | 1553 | /// <summary> |