diff options
author | lbsa71 | 2007-10-30 09:05:31 +0000 |
---|---|---|
committer | lbsa71 | 2007-10-30 09:05:31 +0000 |
commit | 67e12b95ea7b68f4904a7484d77ecfd787d16d0c (patch) | |
tree | 20b00d24c8a7617017960432ec044852e3ad5fa9 /OpenSim/Framework/General/AgentInventory.cs | |
parent | * Deleted .user file (diff) | |
download | opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.zip opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.gz opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.bz2 opensim-SC_OLD-67e12b95ea7b68f4904a7484d77ecfd787d16d0c.tar.xz |
* Optimized usings
* Shortened type references
* Removed redundant 'this' qualifier
Diffstat (limited to 'OpenSim/Framework/General/AgentInventory.cs')
-rw-r--r-- | OpenSim/Framework/General/AgentInventory.cs | 71 |
1 files changed, 34 insertions, 37 deletions
diff --git a/OpenSim/Framework/General/AgentInventory.cs b/OpenSim/Framework/General/AgentInventory.cs index cf110cb..7a1174a 100644 --- a/OpenSim/Framework/General/AgentInventory.cs +++ b/OpenSim/Framework/General/AgentInventory.cs | |||
@@ -28,8 +28,6 @@ | |||
28 | using System.Collections.Generic; | 28 | using System.Collections.Generic; |
29 | using libsecondlife; | 29 | using libsecondlife; |
30 | using libsecondlife.Packets; | 30 | using libsecondlife.Packets; |
31 | using OpenSim.Framework; | ||
32 | |||
33 | 31 | ||
34 | namespace OpenSim.Framework | 32 | namespace OpenSim.Framework |
35 | { | 33 | { |
@@ -39,7 +37,7 @@ namespace OpenSim.Framework | |||
39 | public Dictionary<LLUUID, InventoryFolder> InventoryFolders; | 37 | public Dictionary<LLUUID, InventoryFolder> InventoryFolders; |
40 | public Dictionary<LLUUID, InventoryItem> InventoryItems; | 38 | public Dictionary<LLUUID, InventoryItem> InventoryItems; |
41 | public InventoryFolder InventoryRoot; | 39 | public InventoryFolder InventoryRoot; |
42 | public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server | 40 | public int LastCached; //maybe used by opensim app, time this was last stored/compared to user server |
43 | public LLUUID AgentID; | 41 | public LLUUID AgentID; |
44 | public AvatarWearable[] Wearables; | 42 | public AvatarWearable[] Wearables; |
45 | 43 | ||
@@ -47,12 +45,12 @@ namespace OpenSim.Framework | |||
47 | { | 45 | { |
48 | InventoryFolders = new Dictionary<LLUUID, InventoryFolder>(); | 46 | InventoryFolders = new Dictionary<LLUUID, InventoryFolder>(); |
49 | InventoryItems = new Dictionary<LLUUID, InventoryItem>(); | 47 | InventoryItems = new Dictionary<LLUUID, InventoryItem>(); |
50 | this.Initialise(); | 48 | Initialise(); |
51 | } | 49 | } |
52 | 50 | ||
53 | public virtual void Initialise() | 51 | public virtual void Initialise() |
54 | { | 52 | { |
55 | Wearables = new AvatarWearable[13]; | 53 | Wearables = new AvatarWearable[13]; |
56 | for (int i = 0; i < 13; i++) | 54 | for (int i = 0; i < 13; i++) |
57 | { | 55 | { |
58 | Wearables[i] = new AvatarWearable(); | 56 | Wearables[i] = new AvatarWearable(); |
@@ -63,27 +61,27 @@ namespace OpenSim.Framework | |||
63 | { | 61 | { |
64 | InventoryFolder Folder = new InventoryFolder(); | 62 | InventoryFolder Folder = new InventoryFolder(); |
65 | Folder.FolderID = folderID; | 63 | Folder.FolderID = folderID; |
66 | Folder.OwnerID = this.AgentID; | 64 | Folder.OwnerID = AgentID; |
67 | Folder.DefaultType = type; | 65 | Folder.DefaultType = type; |
68 | this.InventoryFolders.Add(Folder.FolderID, Folder); | 66 | InventoryFolders.Add(Folder.FolderID, Folder); |
69 | return (true); | 67 | return (true); |
70 | } | 68 | } |
71 | 69 | ||
72 | public void CreateRootFolder(LLUUID newAgentID, bool createTextures) | 70 | public void CreateRootFolder(LLUUID newAgentID, bool createTextures) |
73 | { | 71 | { |
74 | this.AgentID = newAgentID; | 72 | AgentID = newAgentID; |
75 | InventoryRoot = new InventoryFolder(); | 73 | InventoryRoot = new InventoryFolder(); |
76 | InventoryRoot.FolderID = LLUUID.Random(); | 74 | InventoryRoot.FolderID = LLUUID.Random(); |
77 | InventoryRoot.ParentID = new LLUUID(); | 75 | InventoryRoot.ParentID = new LLUUID(); |
78 | InventoryRoot.Version = 1; | 76 | InventoryRoot.Version = 1; |
79 | InventoryRoot.DefaultType = 8; | 77 | InventoryRoot.DefaultType = 8; |
80 | InventoryRoot.OwnerID = this.AgentID; | 78 | InventoryRoot.OwnerID = AgentID; |
81 | InventoryRoot.FolderName = "My Inventory"; | 79 | InventoryRoot.FolderName = "My Inventory"; |
82 | InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot); | 80 | InventoryFolders.Add(InventoryRoot.FolderID, InventoryRoot); |
83 | InventoryRoot.OwnerID = this.AgentID; | 81 | InventoryRoot.OwnerID = AgentID; |
84 | if (createTextures) | 82 | if (createTextures) |
85 | { | 83 | { |
86 | this.CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID); | 84 | CreateNewFolder(LLUUID.Random(), 0, "Textures", InventoryRoot.FolderID); |
87 | } | 85 | } |
88 | } | 86 | } |
89 | 87 | ||
@@ -91,32 +89,32 @@ namespace OpenSim.Framework | |||
91 | { | 89 | { |
92 | InventoryFolder Folder = new InventoryFolder(); | 90 | InventoryFolder Folder = new InventoryFolder(); |
93 | Folder.FolderID = folderID; | 91 | Folder.FolderID = folderID; |
94 | Folder.OwnerID = this.AgentID; | 92 | Folder.OwnerID = AgentID; |
95 | Folder.DefaultType = type; | 93 | Folder.DefaultType = type; |
96 | Folder.FolderName = folderName; | 94 | Folder.FolderName = folderName; |
97 | this.InventoryFolders.Add(Folder.FolderID, Folder); | 95 | InventoryFolders.Add(Folder.FolderID, Folder); |
98 | return (true); | 96 | return (true); |
99 | } | 97 | } |
100 | 98 | ||
101 | public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parentID) | 99 | public bool CreateNewFolder(LLUUID folderID, ushort type, string folderName, LLUUID parentID) |
102 | { | 100 | { |
103 | if (!this.InventoryFolders.ContainsKey(folderID)) | 101 | if (!InventoryFolders.ContainsKey(folderID)) |
104 | { | 102 | { |
105 | System.Console.WriteLine("creating new folder called " + folderName + " in agents inventory"); | 103 | System.Console.WriteLine("creating new folder called " + folderName + " in agents inventory"); |
106 | InventoryFolder Folder = new InventoryFolder(); | 104 | InventoryFolder Folder = new InventoryFolder(); |
107 | Folder.FolderID = folderID; | 105 | Folder.FolderID = folderID; |
108 | Folder.OwnerID = this.AgentID; | 106 | Folder.OwnerID = AgentID; |
109 | Folder.DefaultType = type; | 107 | Folder.DefaultType = type; |
110 | Folder.FolderName = folderName; | 108 | Folder.FolderName = folderName; |
111 | Folder.ParentID = parentID; | 109 | Folder.ParentID = parentID; |
112 | this.InventoryFolders.Add(Folder.FolderID, Folder); | 110 | InventoryFolders.Add(Folder.FolderID, Folder); |
113 | } | 111 | } |
114 | return (true); | 112 | return (true); |
115 | } | 113 | } |
116 | 114 | ||
117 | public bool HasFolder(LLUUID folderID) | 115 | public bool HasFolder(LLUUID folderID) |
118 | { | 116 | { |
119 | if (this.InventoryFolders.ContainsKey(folderID)) | 117 | if (InventoryFolders.ContainsKey(folderID)) |
120 | { | 118 | { |
121 | return true; | 119 | return true; |
122 | } | 120 | } |
@@ -125,7 +123,7 @@ namespace OpenSim.Framework | |||
125 | 123 | ||
126 | public LLUUID GetFolderID(string folderName) | 124 | public LLUUID GetFolderID(string folderName) |
127 | { | 125 | { |
128 | foreach (InventoryFolder inv in this.InventoryFolders.Values) | 126 | foreach (InventoryFolder inv in InventoryFolders.Values) |
129 | { | 127 | { |
130 | if (inv.FolderName == folderName) | 128 | if (inv.FolderName == folderName) |
131 | { | 129 | { |
@@ -137,11 +135,12 @@ namespace OpenSim.Framework | |||
137 | 135 | ||
138 | public bool UpdateItemAsset(LLUUID itemID, AssetBase asset) | 136 | public bool UpdateItemAsset(LLUUID itemID, AssetBase asset) |
139 | { | 137 | { |
140 | if(this.InventoryItems.ContainsKey(itemID)) | 138 | if (InventoryItems.ContainsKey(itemID)) |
141 | { | 139 | { |
142 | InventoryItem Item = this.InventoryItems[itemID]; | 140 | InventoryItem Item = InventoryItems[itemID]; |
143 | Item.AssetID = asset.FullID; | 141 | Item.AssetID = asset.FullID; |
144 | System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + " so it now is set to asset " + asset.FullID.ToStringHyphenated()); | 142 | System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated() + |
143 | " so it now is set to asset " + asset.FullID.ToStringHyphenated()); | ||
145 | //TODO need to update the rest of the info | 144 | //TODO need to update the rest of the info |
146 | } | 145 | } |
147 | return true; | 146 | return true; |
@@ -150,10 +149,10 @@ namespace OpenSim.Framework | |||
150 | public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet) | 149 | public bool UpdateItemDetails(LLUUID itemID, UpdateInventoryItemPacket.InventoryDataBlock packet) |
151 | { | 150 | { |
152 | System.Console.WriteLine("updating inventory item details"); | 151 | System.Console.WriteLine("updating inventory item details"); |
153 | if (this.InventoryItems.ContainsKey(itemID)) | 152 | if (InventoryItems.ContainsKey(itemID)) |
154 | { | 153 | { |
155 | System.Console.WriteLine("changing name to "+ Util.FieldToString(packet.Name)); | 154 | System.Console.WriteLine("changing name to " + Util.FieldToString(packet.Name)); |
156 | InventoryItem Item = this.InventoryItems[itemID]; | 155 | InventoryItem Item = InventoryItems[itemID]; |
157 | Item.Name = Util.FieldToString(packet.Name); | 156 | Item.Name = Util.FieldToString(packet.Name); |
158 | System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated()); | 157 | System.Console.WriteLine("updated inventory item " + itemID.ToStringHyphenated()); |
159 | //TODO need to update the rest of the info | 158 | //TODO need to update the rest of the info |
@@ -163,7 +162,7 @@ namespace OpenSim.Framework | |||
163 | 162 | ||
164 | public LLUUID AddToInventory(LLUUID folderID, AssetBase asset) | 163 | public LLUUID AddToInventory(LLUUID folderID, AssetBase asset) |
165 | { | 164 | { |
166 | if (this.InventoryFolders.ContainsKey(folderID)) | 165 | if (InventoryFolders.ContainsKey(folderID)) |
167 | { | 166 | { |
168 | LLUUID NewItemID = LLUUID.Random(); | 167 | LLUUID NewItemID = LLUUID.Random(); |
169 | 168 | ||
@@ -176,7 +175,7 @@ namespace OpenSim.Framework | |||
176 | Item.Name = asset.Name; | 175 | Item.Name = asset.Name; |
177 | Item.Description = asset.Description; | 176 | Item.Description = asset.Description; |
178 | Item.InvType = asset.InvType; | 177 | Item.InvType = asset.InvType; |
179 | this.InventoryItems.Add(Item.ItemID, Item); | 178 | InventoryItems.Add(Item.ItemID, Item); |
180 | InventoryFolder Folder = InventoryFolders[Item.FolderID]; | 179 | InventoryFolder Folder = InventoryFolders[Item.FolderID]; |
181 | Folder.Items.Add(Item); | 180 | Folder.Items.Add(Item); |
182 | return (Item.ItemID); | 181 | return (Item.ItemID); |
@@ -190,10 +189,10 @@ namespace OpenSim.Framework | |||
190 | public bool DeleteFromInventory(LLUUID itemID) | 189 | public bool DeleteFromInventory(LLUUID itemID) |
191 | { | 190 | { |
192 | bool res = false; | 191 | bool res = false; |
193 | if (this.InventoryItems.ContainsKey(itemID)) | 192 | if (InventoryItems.ContainsKey(itemID)) |
194 | { | 193 | { |
195 | InventoryItem item = this.InventoryItems[itemID]; | 194 | InventoryItem item = InventoryItems[itemID]; |
196 | this.InventoryItems.Remove(itemID); | 195 | InventoryItems.Remove(itemID); |
197 | foreach (InventoryFolder fold in InventoryFolders.Values) | 196 | foreach (InventoryFolder fold in InventoryFolders.Values) |
198 | { | 197 | { |
199 | if (fold.Items.Contains(item)) | 198 | if (fold.Items.Contains(item)) |
@@ -203,7 +202,6 @@ namespace OpenSim.Framework | |||
203 | } | 202 | } |
204 | } | 203 | } |
205 | res = true; | 204 | res = true; |
206 | |||
207 | } | 205 | } |
208 | return res; | 206 | return res; |
209 | } | 207 | } |
@@ -225,7 +223,6 @@ namespace OpenSim.Framework | |||
225 | Items = new List<InventoryItem>(); | 223 | Items = new List<InventoryItem>(); |
226 | //Subfolders = new List<InventoryFolder>(); | 224 | //Subfolders = new List<InventoryFolder>(); |
227 | } | 225 | } |
228 | |||
229 | } | 226 | } |
230 | 227 | ||
231 | public class InventoryItem | 228 | public class InventoryItem |
@@ -237,12 +234,12 @@ namespace OpenSim.Framework | |||
237 | public LLUUID CreatorID; | 234 | public LLUUID CreatorID; |
238 | public sbyte InvType; | 235 | public sbyte InvType; |
239 | public sbyte Type; | 236 | public sbyte Type; |
240 | public string Name =""; | 237 | public string Name = ""; |
241 | public string Description; | 238 | public string Description; |
242 | 239 | ||
243 | public InventoryItem() | 240 | public InventoryItem() |
244 | { | 241 | { |
245 | this.CreatorID = LLUUID.Zero; | 242 | CreatorID = LLUUID.Zero; |
246 | } | 243 | } |
247 | 244 | ||
248 | public string ExportString() | 245 | public string ExportString() |
@@ -251,11 +248,11 @@ namespace OpenSim.Framework | |||
251 | string result = ""; | 248 | string result = ""; |
252 | result += "\tinv_object\t0\n\t{\n"; | 249 | result += "\tinv_object\t0\n\t{\n"; |
253 | result += "\t\tobj_id\t%s\n"; | 250 | result += "\t\tobj_id\t%s\n"; |
254 | result += "\t\tparent_id\t"+ ItemID.ToString() +"\n"; | 251 | result += "\t\tparent_id\t" + ItemID.ToString() + "\n"; |
255 | result += "\t\ttype\t"+ typ +"\n"; | 252 | result += "\t\ttype\t" + typ + "\n"; |
256 | result += "\t\tname\t" + Name+"|\n"; | 253 | result += "\t\tname\t" + Name + "|\n"; |
257 | result += "\t}\n"; | 254 | result += "\t}\n"; |
258 | return result; | 255 | return result; |
259 | } | 256 | } |
260 | } | 257 | } |
261 | } | 258 | } \ No newline at end of file |