diff options
author | Justin Clark-Casey (justincc) | 2012-08-31 00:33:06 +0100 |
---|---|---|
committer | Justin Clark-Casey (justincc) | 2012-08-31 00:33:06 +0100 |
commit | 3bd3f448a2d5b64b267427a0f8f820109338a7bb (patch) | |
tree | a8a170ff5a31651c8e3fd207e92168b50c7b6796 | |
parent | Do Windlight storage and removal calls in MySQL under m_dbLock, as is done wi... (diff) | |
download | opensim-SC_OLD-3bd3f448a2d5b64b267427a0f8f820109338a7bb.zip opensim-SC_OLD-3bd3f448a2d5b64b267427a0f8f820109338a7bb.tar.gz opensim-SC_OLD-3bd3f448a2d5b64b267427a0f8f820109338a7bb.tar.bz2 opensim-SC_OLD-3bd3f448a2d5b64b267427a0f8f820109338a7bb.tar.xz |
Also do other MySQL region settings related calls under m_dbLock, in common with other calls.
-rw-r--r-- | OpenSim/Data/MySQL/MySQLSimulationData.cs | 247 |
1 files changed, 130 insertions, 117 deletions
diff --git a/OpenSim/Data/MySQL/MySQLSimulationData.cs b/OpenSim/Data/MySQL/MySQLSimulationData.cs index a021590..d562783 100644 --- a/OpenSim/Data/MySQL/MySQLSimulationData.cs +++ b/OpenSim/Data/MySQL/MySQLSimulationData.cs | |||
@@ -719,95 +719,99 @@ namespace OpenSim.Data.MySQL | |||
719 | RegionLightShareData nWP = new RegionLightShareData(); | 719 | RegionLightShareData nWP = new RegionLightShareData(); |
720 | nWP.OnSave += StoreRegionWindlightSettings; | 720 | nWP.OnSave += StoreRegionWindlightSettings; |
721 | 721 | ||
722 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 722 | lock (m_dbLock) |
723 | { | 723 | { |
724 | dbcon.Open(); | 724 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
725 | |||
726 | string command = "select * from `regionwindlight` where region_id = ?regionID"; | ||
727 | |||
728 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
729 | { | 725 | { |
730 | cmd.Connection = dbcon; | 726 | dbcon.Open(); |
731 | 727 | ||
732 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); | 728 | string command = "select * from `regionwindlight` where region_id = ?regionID"; |
733 | 729 | ||
734 | IDataReader result = ExecuteReader(cmd); | 730 | using (MySqlCommand cmd = new MySqlCommand(command)) |
735 | if (!result.Read()) | ||
736 | { | ||
737 | //No result, so store our default windlight profile and return it | ||
738 | nWP.regionID = regionUUID; | ||
739 | StoreRegionWindlightSettings(nWP); | ||
740 | return nWP; | ||
741 | } | ||
742 | else | ||
743 | { | 731 | { |
744 | nWP.regionID = DBGuid.FromDB(result["region_id"]); | 732 | cmd.Connection = dbcon; |
745 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); | 733 | |
746 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); | 734 | cmd.Parameters.AddWithValue("?regionID", regionUUID.ToString()); |
747 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); | 735 | |
748 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); | 736 | IDataReader result = ExecuteReader(cmd); |
749 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); | 737 | if (!result.Read()) |
750 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); | 738 | { |
751 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); | 739 | //No result, so store our default windlight profile and return it |
752 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); | 740 | nWP.regionID = regionUUID; |
753 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); | 741 | StoreRegionWindlightSettings(nWP); |
754 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); | 742 | return nWP; |
755 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); | 743 | } |
756 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); | 744 | else |
757 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); | 745 | { |
758 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); | 746 | nWP.regionID = DBGuid.FromDB(result["region_id"]); |
759 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); | 747 | nWP.waterColor.X = Convert.ToSingle(result["water_color_r"]); |
760 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); | 748 | nWP.waterColor.Y = Convert.ToSingle(result["water_color_g"]); |
761 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); | 749 | nWP.waterColor.Z = Convert.ToSingle(result["water_color_b"]); |
762 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); | 750 | nWP.waterFogDensityExponent = Convert.ToSingle(result["water_fog_density_exponent"]); |
763 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); | 751 | nWP.underwaterFogModifier = Convert.ToSingle(result["underwater_fog_modifier"]); |
764 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); | 752 | nWP.reflectionWaveletScale.X = Convert.ToSingle(result["reflection_wavelet_scale_1"]); |
765 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); | 753 | nWP.reflectionWaveletScale.Y = Convert.ToSingle(result["reflection_wavelet_scale_2"]); |
766 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); | 754 | nWP.reflectionWaveletScale.Z = Convert.ToSingle(result["reflection_wavelet_scale_3"]); |
767 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); | 755 | nWP.fresnelScale = Convert.ToSingle(result["fresnel_scale"]); |
768 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); | 756 | nWP.fresnelOffset = Convert.ToSingle(result["fresnel_offset"]); |
769 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); | 757 | nWP.refractScaleAbove = Convert.ToSingle(result["refract_scale_above"]); |
770 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); | 758 | nWP.refractScaleBelow = Convert.ToSingle(result["refract_scale_below"]); |
771 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); | 759 | nWP.blurMultiplier = Convert.ToSingle(result["blur_multiplier"]); |
772 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); | 760 | nWP.bigWaveDirection.X = Convert.ToSingle(result["big_wave_direction_x"]); |
773 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); | 761 | nWP.bigWaveDirection.Y = Convert.ToSingle(result["big_wave_direction_y"]); |
774 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); | 762 | nWP.littleWaveDirection.X = Convert.ToSingle(result["little_wave_direction_x"]); |
775 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); | 763 | nWP.littleWaveDirection.Y = Convert.ToSingle(result["little_wave_direction_y"]); |
776 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); | 764 | UUID.TryParse(result["normal_map_texture"].ToString(), out nWP.normalMapTexture); |
777 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); | 765 | nWP.horizon.X = Convert.ToSingle(result["horizon_r"]); |
778 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); | 766 | nWP.horizon.Y = Convert.ToSingle(result["horizon_g"]); |
779 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); | 767 | nWP.horizon.Z = Convert.ToSingle(result["horizon_b"]); |
780 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); | 768 | nWP.horizon.W = Convert.ToSingle(result["horizon_i"]); |
781 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); | 769 | nWP.hazeHorizon = Convert.ToSingle(result["haze_horizon"]); |
782 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); | 770 | nWP.blueDensity.X = Convert.ToSingle(result["blue_density_r"]); |
783 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); | 771 | nWP.blueDensity.Y = Convert.ToSingle(result["blue_density_g"]); |
784 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); | 772 | nWP.blueDensity.Z = Convert.ToSingle(result["blue_density_b"]); |
785 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); | 773 | nWP.blueDensity.W = Convert.ToSingle(result["blue_density_i"]); |
786 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); | 774 | nWP.hazeDensity = Convert.ToSingle(result["haze_density"]); |
787 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); | 775 | nWP.densityMultiplier = Convert.ToSingle(result["density_multiplier"]); |
788 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); | 776 | nWP.distanceMultiplier = Convert.ToSingle(result["distance_multiplier"]); |
789 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); | 777 | nWP.maxAltitude = Convert.ToUInt16(result["max_altitude"]); |
790 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); | 778 | nWP.sunMoonColor.X = Convert.ToSingle(result["sun_moon_color_r"]); |
791 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); | 779 | nWP.sunMoonColor.Y = Convert.ToSingle(result["sun_moon_color_g"]); |
792 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); | 780 | nWP.sunMoonColor.Z = Convert.ToSingle(result["sun_moon_color_b"]); |
793 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); | 781 | nWP.sunMoonColor.W = Convert.ToSingle(result["sun_moon_color_i"]); |
794 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); | 782 | nWP.sunMoonPosition = Convert.ToSingle(result["sun_moon_position"]); |
795 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); | 783 | nWP.ambient.X = Convert.ToSingle(result["ambient_r"]); |
796 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); | 784 | nWP.ambient.Y = Convert.ToSingle(result["ambient_g"]); |
797 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); | 785 | nWP.ambient.Z = Convert.ToSingle(result["ambient_b"]); |
798 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); | 786 | nWP.ambient.W = Convert.ToSingle(result["ambient_i"]); |
799 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); | 787 | nWP.eastAngle = Convert.ToSingle(result["east_angle"]); |
800 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); | 788 | nWP.sunGlowFocus = Convert.ToSingle(result["sun_glow_focus"]); |
801 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); | 789 | nWP.sunGlowSize = Convert.ToSingle(result["sun_glow_size"]); |
802 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); | 790 | nWP.sceneGamma = Convert.ToSingle(result["scene_gamma"]); |
803 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); | 791 | nWP.starBrightness = Convert.ToSingle(result["star_brightness"]); |
804 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); | 792 | nWP.cloudColor.X = Convert.ToSingle(result["cloud_color_r"]); |
805 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); | 793 | nWP.cloudColor.Y = Convert.ToSingle(result["cloud_color_g"]); |
806 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); | 794 | nWP.cloudColor.Z = Convert.ToSingle(result["cloud_color_b"]); |
807 | nWP.valid = true; | 795 | nWP.cloudColor.W = Convert.ToSingle(result["cloud_color_i"]); |
796 | nWP.cloudXYDensity.X = Convert.ToSingle(result["cloud_x"]); | ||
797 | nWP.cloudXYDensity.Y = Convert.ToSingle(result["cloud_y"]); | ||
798 | nWP.cloudXYDensity.Z = Convert.ToSingle(result["cloud_density"]); | ||
799 | nWP.cloudCoverage = Convert.ToSingle(result["cloud_coverage"]); | ||
800 | nWP.cloudScale = Convert.ToSingle(result["cloud_scale"]); | ||
801 | nWP.cloudDetailXYDensity.X = Convert.ToSingle(result["cloud_detail_x"]); | ||
802 | nWP.cloudDetailXYDensity.Y = Convert.ToSingle(result["cloud_detail_y"]); | ||
803 | nWP.cloudDetailXYDensity.Z = Convert.ToSingle(result["cloud_detail_density"]); | ||
804 | nWP.cloudScrollX = Convert.ToSingle(result["cloud_scroll_x"]); | ||
805 | nWP.cloudScrollXLock = Convert.ToBoolean(result["cloud_scroll_x_lock"]); | ||
806 | nWP.cloudScrollY = Convert.ToSingle(result["cloud_scroll_y"]); | ||
807 | nWP.cloudScrollYLock = Convert.ToBoolean(result["cloud_scroll_y_lock"]); | ||
808 | nWP.drawClassicClouds = Convert.ToBoolean(result["draw_classic_clouds"]); | ||
809 | nWP.valid = true; | ||
810 | } | ||
808 | } | 811 | } |
809 | } | 812 | } |
810 | } | 813 | } |
814 | |||
811 | return nWP; | 815 | return nWP; |
812 | } | 816 | } |
813 | 817 | ||
@@ -978,26 +982,29 @@ namespace OpenSim.Data.MySQL | |||
978 | #region RegionEnvironmentSettings | 982 | #region RegionEnvironmentSettings |
979 | public string LoadRegionEnvironmentSettings(UUID regionUUID) | 983 | public string LoadRegionEnvironmentSettings(UUID regionUUID) |
980 | { | 984 | { |
981 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 985 | lock (m_dbLock) |
982 | { | 986 | { |
983 | dbcon.Open(); | 987 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
984 | |||
985 | string command = "select * from `regionenvironment` where region_id = ?region_id"; | ||
986 | |||
987 | using (MySqlCommand cmd = new MySqlCommand(command)) | ||
988 | { | 988 | { |
989 | cmd.Connection = dbcon; | 989 | dbcon.Open(); |
990 | 990 | ||
991 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | 991 | string command = "select * from `regionenvironment` where region_id = ?region_id"; |
992 | 992 | ||
993 | IDataReader result = ExecuteReader(cmd); | 993 | using (MySqlCommand cmd = new MySqlCommand(command)) |
994 | if (!result.Read()) | ||
995 | { | ||
996 | return String.Empty; | ||
997 | } | ||
998 | else | ||
999 | { | 994 | { |
1000 | return Convert.ToString(result["llsd_settings"]); | 995 | cmd.Connection = dbcon; |
996 | |||
997 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | ||
998 | |||
999 | IDataReader result = ExecuteReader(cmd); | ||
1000 | if (!result.Read()) | ||
1001 | { | ||
1002 | return String.Empty; | ||
1003 | } | ||
1004 | else | ||
1005 | { | ||
1006 | return Convert.ToString(result["llsd_settings"]); | ||
1007 | } | ||
1001 | } | 1008 | } |
1002 | } | 1009 | } |
1003 | } | 1010 | } |
@@ -1005,33 +1012,39 @@ namespace OpenSim.Data.MySQL | |||
1005 | 1012 | ||
1006 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) | 1013 | public void StoreRegionEnvironmentSettings(UUID regionUUID, string settings) |
1007 | { | 1014 | { |
1008 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1015 | lock (m_dbLock) |
1009 | { | 1016 | { |
1010 | dbcon.Open(); | 1017 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1011 | |||
1012 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1013 | { | 1018 | { |
1014 | cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; | 1019 | dbcon.Open(); |
1015 | 1020 | ||
1016 | cmd.Parameters.AddWithValue("region_id", regionUUID); | 1021 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1017 | cmd.Parameters.AddWithValue("llsd_settings", settings); | 1022 | { |
1018 | 1023 | cmd.CommandText = "REPLACE INTO `regionenvironment` (`region_id`, `llsd_settings`) VALUES (?region_id, ?llsd_settings)"; | |
1019 | ExecuteNonQuery(cmd); | 1024 | |
1025 | cmd.Parameters.AddWithValue("region_id", regionUUID); | ||
1026 | cmd.Parameters.AddWithValue("llsd_settings", settings); | ||
1027 | |||
1028 | ExecuteNonQuery(cmd); | ||
1029 | } | ||
1020 | } | 1030 | } |
1021 | } | 1031 | } |
1022 | } | 1032 | } |
1023 | 1033 | ||
1024 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) | 1034 | public void RemoveRegionEnvironmentSettings(UUID regionUUID) |
1025 | { | 1035 | { |
1026 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) | 1036 | lock (m_dbLock) |
1027 | { | 1037 | { |
1028 | dbcon.Open(); | 1038 | using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) |
1029 | |||
1030 | using (MySqlCommand cmd = dbcon.CreateCommand()) | ||
1031 | { | 1039 | { |
1032 | cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; | 1040 | dbcon.Open(); |
1033 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | 1041 | |
1034 | ExecuteNonQuery(cmd); | 1042 | using (MySqlCommand cmd = dbcon.CreateCommand()) |
1043 | { | ||
1044 | cmd.CommandText = "delete from `regionenvironment` where region_id = ?region_id"; | ||
1045 | cmd.Parameters.AddWithValue("?region_id", regionUUID.ToString()); | ||
1046 | ExecuteNonQuery(cmd); | ||
1047 | } | ||
1035 | } | 1048 | } |
1036 | } | 1049 | } |
1037 | } | 1050 | } |