aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Data
diff options
context:
space:
mode:
authorCharles Krinke2008-06-11 13:57:32 +0000
committerCharles Krinke2008-06-11 13:57:32 +0000
commitaba396cb329a359a0ff9d5e6596912079bfb3584 (patch)
tree8e8c98a60a73a896b5d43fbe2c9fd132ed32369b /OpenSim/Data
parent* Drop periodic stats logging back down to 60 minutes to reduce console spam. (diff)
downloadopensim-SC_OLD-aba396cb329a359a0ff9d5e6596912079bfb3584.zip
opensim-SC_OLD-aba396cb329a359a0ff9d5e6596912079bfb3584.tar.gz
opensim-SC_OLD-aba396cb329a359a0ff9d5e6596912079bfb3584.tar.bz2
opensim-SC_OLD-aba396cb329a359a0ff9d5e6596912079bfb3584.tar.xz
Mantis#1528. Thank you kindly, Boscata for:
MSSQL Avatar appearance solved. Appearance functions and modified table.
Diffstat (limited to '')
-rw-r--r--OpenSim/Data/MSSQL/MSSQLUserData.cs138
-rw-r--r--OpenSim/Data/MSSQL/Resources/AvatarAppearance.sql59
2 files changed, 168 insertions, 29 deletions
diff --git a/OpenSim/Data/MSSQL/MSSQLUserData.cs b/OpenSim/Data/MSSQL/MSSQLUserData.cs
index aa8c2ed..8714e2b 100644
--- a/OpenSim/Data/MSSQL/MSSQLUserData.cs
+++ b/OpenSim/Data/MSSQL/MSSQLUserData.cs
@@ -749,11 +749,147 @@ namespace OpenSim.Data.MSSQL
749 /// TODO: stubs for now to get us to a compiling state gently 749 /// TODO: stubs for now to get us to a compiling state gently
750 override public AvatarAppearance GetUserAppearance(LLUUID user) 750 override public AvatarAppearance GetUserAppearance(LLUUID user)
751 { 751 {
752 return new AvatarAppearance(); 752// return new AvatarAppearance();
753 try
754 {
755 lock (database)
756 {
757 Dictionary<string, string> param = new Dictionary<string, string>();
758 param["@UUID"] = user.ToString();
759
760 IDbCommand result =
761 database.Query("SELECT * FROM avatarappearance WHERE owner = @UUID", param);
762 IDataReader reader = result.ExecuteReader();
763
764 AvatarAppearance item = null;
765 if (reader.Read())
766 item = readUserAppearance(reader);
767
768 reader.Close();
769 result.Dispose();
770
771 return item;
772 }
773 }
774 catch (Exception e)
775 {
776 database.Reconnect();
777 m_log.Error(e.ToString());
778 }
779 return null;
780 }
781
782 /// <summary>
783 /// Reads a one item from an SQL result
784 /// </summary>
785 /// <param name="reader">The SQL Result</param>
786 /// <returns>the item read</returns>
787 private static AvatarAppearance readUserAppearance(IDataReader reader)
788 {
789 try
790 {
791 AvatarAppearance appearance = new AvatarAppearance();
792
793 appearance.Owner = new LLUUID((string)reader["owner"]);
794 appearance.Serial = Convert.ToInt32(reader["serial"]);
795 appearance.VisualParams = (byte[])reader["visual_params"];
796 appearance.Texture = new LLObject.TextureEntry((byte[])reader["texture"], 0, ((byte[])reader["texture"]).Length);
797 appearance.AvatarHeight = (float)Convert.ToDouble(reader["avatar_height"]);
798 appearance.BodyItem = new LLUUID((string)reader["body_item"]);
799 appearance.BodyAsset = new LLUUID((string)reader["body_asset"]);
800 appearance.SkinItem = new LLUUID((string)reader["skin_item"]);
801 appearance.SkinAsset = new LLUUID((string)reader["skin_asset"]);
802 appearance.HairItem = new LLUUID((string)reader["hair_item"]);
803 appearance.HairAsset = new LLUUID((string)reader["hair_asset"]);
804 appearance.EyesItem = new LLUUID((string)reader["eyes_item"]);
805 appearance.EyesAsset = new LLUUID((string)reader["eyes_asset"]);
806 appearance.ShirtItem = new LLUUID((string)reader["shirt_item"]);
807 appearance.ShirtAsset = new LLUUID((string)reader["shirt_asset"]);
808 appearance.PantsItem = new LLUUID((string)reader["pants_item"]);
809 appearance.PantsAsset = new LLUUID((string)reader["pants_asset"]);
810 appearance.ShoesItem = new LLUUID((string)reader["shoes_item"]);
811 appearance.ShoesAsset = new LLUUID((string)reader["shoes_asset"]);
812 appearance.SocksItem = new LLUUID((string)reader["socks_item"]);
813 appearance.SocksAsset = new LLUUID((string)reader["socks_asset"]);
814 appearance.JacketItem = new LLUUID((string)reader["jacket_item"]);
815 appearance.JacketAsset = new LLUUID((string)reader["jacket_asset"]);
816 appearance.GlovesItem = new LLUUID((string)reader["gloves_item"]);
817 appearance.GlovesAsset = new LLUUID((string)reader["gloves_asset"]);
818 appearance.UnderShirtItem = new LLUUID((string)reader["undershirt_item"]);
819 appearance.UnderShirtAsset = new LLUUID((string)reader["undershirt_asset"]);
820 appearance.UnderPantsItem = new LLUUID((string)reader["underpants_item"]);
821 appearance.UnderPantsAsset = new LLUUID((string)reader["underpants_asset"]);
822 appearance.SkirtItem = new LLUUID((string)reader["skirt_item"]);
823 appearance.SkirtAsset = new LLUUID((string)reader["skirt_asset"]);
824
825 return appearance;
826 }
827 catch (SqlException e)
828 {
829 m_log.Error(e.ToString());
830 }
831
832 return null;
753 } 833 }
754 834
755 override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance) 835 override public void UpdateUserAppearance(LLUUID user, AvatarAppearance appearance)
756 { 836 {
837 string sql = String.Empty;
838 sql += "DELETE FROM avatarappearance WHERE owner=@owner ";
839 sql += "INSERT INTO avatarappearance ";
840 sql += "(owner, serial, visual_params, texture, avatar_height, ";
841 sql += "body_item, body_asset, skin_item, skin_asset, hair_item, hair_asset, eyes_item, eyes_asset, ";
842 sql += "shirt_item, shirt_asset, pants_item, pants_asset, shoes_item, shoes_asset, socks_item, socks_asset, ";
843 sql += "jacket_item, jacket_asset, gloves_item, gloves_asset, undershirt_item, undershirt_asset, underpants_item, underpants_asset, ";
844 sql += "skirt_item, skirt_asset) values (";
845 sql += "@owner, @serial, @visual_params, @texture, @avatar_height, ";
846 sql += "@body_item, @body_asset, @skin_item, @skin_asset, @hair_item, @hair_asset, @eyes_item, @eyes_asset, ";
847 sql += "@shirt_item, @shirt_asset, @pants_item, @pants_asset, @shoes_item, @shoes_asset, @socks_item, @socks_asset, ";
848 sql += "@jacket_item, @jacket_asset, @gloves_item, @gloves_asset, @undershirt_item, @undershirt_asset, @underpants_item, @underpants_asset, ";
849 sql += "@skirt_item, @skirt_asset)";
850
851 SqlCommand cmd = new SqlCommand(sql, database.getConnection());
852 cmd.Parameters.AddWithValue("@owner", appearance.Owner.ToString());
853 cmd.Parameters.AddWithValue("@serial", appearance.Serial);
854 cmd.Parameters.AddWithValue("@visual_params", appearance.VisualParams);
855 cmd.Parameters.AddWithValue("@texture", appearance.Texture.ToBytes());
856 cmd.Parameters.AddWithValue("@avatar_height", appearance.AvatarHeight);
857 cmd.Parameters.AddWithValue("@body_item", appearance.BodyItem.ToString());
858 cmd.Parameters.AddWithValue("@body_asset", appearance.BodyAsset.ToString());
859 cmd.Parameters.AddWithValue("@skin_item", appearance.SkinItem.ToString());
860 cmd.Parameters.AddWithValue("@skin_asset", appearance.SkinAsset.ToString());
861 cmd.Parameters.AddWithValue("@hair_item", appearance.HairItem.ToString());
862 cmd.Parameters.AddWithValue("@hair_asset", appearance.HairAsset.ToString());
863 cmd.Parameters.AddWithValue("@eyes_item", appearance.EyesItem.ToString());
864 cmd.Parameters.AddWithValue("@eyes_asset", appearance.EyesAsset.ToString());
865 cmd.Parameters.AddWithValue("@shirt_item", appearance.ShirtItem.ToString());
866 cmd.Parameters.AddWithValue("@shirt_asset", appearance.ShirtAsset.ToString());
867 cmd.Parameters.AddWithValue("@pants_item", appearance.PantsItem.ToString());
868 cmd.Parameters.AddWithValue("@pants_asset", appearance.PantsAsset.ToString());
869 cmd.Parameters.AddWithValue("@shoes_item", appearance.ShoesItem.ToString());
870 cmd.Parameters.AddWithValue("@shoes_asset", appearance.ShoesAsset.ToString());
871 cmd.Parameters.AddWithValue("@socks_item", appearance.SocksItem.ToString());
872 cmd.Parameters.AddWithValue("@socks_asset", appearance.SocksAsset.ToString());
873 cmd.Parameters.AddWithValue("@jacket_item", appearance.JacketItem.ToString());
874 cmd.Parameters.AddWithValue("@jacket_asset", appearance.JacketAsset.ToString());
875 cmd.Parameters.AddWithValue("@gloves_item", appearance.GlovesItem.ToString());
876 cmd.Parameters.AddWithValue("@gloves_asset", appearance.GlovesAsset.ToString());
877 cmd.Parameters.AddWithValue("@undershirt_item", appearance.UnderShirtItem.ToString());
878 cmd.Parameters.AddWithValue("@undershirt_asset", appearance.UnderShirtAsset.ToString());
879 cmd.Parameters.AddWithValue("@underpants_item", appearance.UnderPantsItem.ToString());
880 cmd.Parameters.AddWithValue("@underpants_asset", appearance.UnderPantsAsset.ToString());
881 cmd.Parameters.AddWithValue("@skirt_item", appearance.SkirtItem.ToString());
882 cmd.Parameters.AddWithValue("@skirt_asset", appearance.SkirtAsset.ToString());
883
884 try
885 {
886 cmd.ExecuteNonQuery();
887 cmd.Dispose();
888 }
889 catch (Exception e)
890 {
891 m_log.Error(e.ToString());
892 }
757 return; 893 return;
758 } 894 }
759 895
diff --git a/OpenSim/Data/MSSQL/Resources/AvatarAppearance.sql b/OpenSim/Data/MSSQL/Resources/AvatarAppearance.sql
index f396005..1639f56 100644
--- a/OpenSim/Data/MSSQL/Resources/AvatarAppearance.sql
+++ b/OpenSim/Data/MSSQL/Resources/AvatarAppearance.sql
@@ -7,37 +7,40 @@ SET QUOTED_IDENTIFIER ON
7SET ANSI_PADDING ON 7SET ANSI_PADDING ON
8 8
9CREATE TABLE [avatarappearance] ( 9CREATE TABLE [avatarappearance] (
10 [UUID] uniqueidentifier NOT NULL, 10 [Owner] [varchar](36) NOT NULL,
11 [Serial] int NOT NULL, 11 [Serial] int NOT NULL,
12 [WearableItem0] uniqueidentifier NOT NULL, 12 [Visual_Params] [image] NOT NULL,
13 [WearableAsset0] uniqueidentifier NOT NULL, 13 [Texture] [image] NOT NULL,
14 [WearableItem1] uniqueidentifier NOT NULL, 14 [Avatar_Height] float NOT NULL,
15 [WearableAsset1] uniqueidentifier NOT NULL, 15 [Body_Item] [varchar](36) NOT NULL,
16 [WearableItem2] uniqueidentifier NOT NULL, 16 [Body_Asset] [varchar](36) NOT NULL,
17 [WearableAsset2] uniqueidentifier NOT NULL, 17 [Skin_Item] [varchar](36) NOT NULL,
18 [WearableItem3] uniqueidentifier NOT NULL, 18 [Skin_Asset] [varchar](36) NOT NULL,
19 [WearableAsset3] uniqueidentifier NOT NULL, 19 [Hair_Item] [varchar](36) NOT NULL,
20 [WearableItem4] uniqueidentifier NOT NULL, 20 [Hair_Asset] [varchar](36) NOT NULL,
21 [WearableAsset4] uniqueidentifier NOT NULL, 21 [Eyes_Item] [varchar](36) NOT NULL,
22 [WearableItem5] uniqueidentifier NOT NULL, 22 [Eyes_Asset] [varchar](36) NOT NULL,
23 [WearableAsset5] uniqueidentifier NOT NULL, 23 [Shirt_Item] [varchar](36) NOT NULL,
24 [WearableItem6] uniqueidentifier NOT NULL, 24 [Shirt_Asset] [varchar](36) NOT NULL,
25 [WearableAsset6] uniqueidentifier NOT NULL, 25 [Pants_Item] [varchar](36) NOT NULL,
26 [WearableItem7] uniqueidentifier NOT NULL, 26 [Pants_Asset] [varchar](36) NOT NULL,
27 [WearableAsset7] uniqueidentifier NOT NULL, 27 [Shoes_Item] [varchar](36) NOT NULL,
28 [WearableItem8] uniqueidentifier NOT NULL, 28 [Shoes_Asset] [varchar](36) NOT NULL,
29 [WearableAsset8] uniqueidentifier NOT NULL, 29 [Socks_Item] [varchar](36) NOT NULL,
30 [WearableItem9] uniqueidentifier NOT NULL, 30 [Socks_Asset] [varchar](36) NOT NULL,
31 [WearableAsset9] uniqueidentifier NOT NULL, 31 [Jacket_Item] [varchar](36) NOT NULL,
32 [WearableItem10] uniqueidentifier NOT NULL, 32 [Jacket_Asset] [varchar](36) NOT NULL,
33 [WearableAsset10] uniqueidentifier NOT NULL, 33 [Gloves_Item] [varchar](36) NOT NULL,
34 [WearableItem11] uniqueidentifier NOT NULL, 34 [Gloves_Asset] [varchar](36) NOT NULL,
35 [WearableAsset11] uniqueidentifier NOT NULL, 35 [Undershirt_Item] [varchar](36) NOT NULL,
36 [WearableItem12] uniqueidentifier NOT NULL, 36 [Undershirt_Asset] [varchar](36) NOT NULL,
37 [WearableAsset12] uniqueidentifier NOT NULL 37 [Underpants_Item] [varchar](36) NOT NULL,
38 [Underpants_Asset] [varchar](36) NOT NULL,
39 [Skirt_Item] [varchar](36) NOT NULL,
40 [Skirt_Asset] [varchar](36) NOT NULL,
38 41
39 PRIMARY KEY CLUSTERED ( 42 PRIMARY KEY CLUSTERED (
40 [UUID] 43 [Owner]
41 ) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY] 44 ) WITH (PAD_INDEX = OFF, STATISTICS_NORECOMPUTE = OFF, IGNORE_DUP_KEY = OFF, ALLOW_ROW_LOCKS = ON, ALLOW_PAGE_LOCKS = ON) ON [PRIMARY]
42) ON [PRIMARY] 45) ON [PRIMARY]
43 46