diff options
author | MW | 2007-02-03 21:09:54 +0000 |
---|---|---|
committer | MW | 2007-02-03 21:09:54 +0000 |
commit | dc2316de9c7a7168263e7a367b4c69189f9bc232 (patch) | |
tree | 57b639a77d585f5ded98f283d24a02617faf5b1a /AssetManagement.cs | |
parent | (no commit message) (diff) | |
download | opensim-SC_OLD-dc2316de9c7a7168263e7a367b4c69189f9bc232.zip opensim-SC_OLD-dc2316de9c7a7168263e7a367b4c69189f9bc232.tar.gz opensim-SC_OLD-dc2316de9c7a7168263e7a367b4c69189f9bc232.tar.bz2 opensim-SC_OLD-dc2316de9c7a7168263e7a367b4c69189f9bc232.tar.xz |
Basic Inventory support and clean up
Diffstat (limited to '')
-rw-r--r-- | AssetManagement.cs | 95 |
1 files changed, 41 insertions, 54 deletions
diff --git a/AssetManagement.cs b/AssetManagement.cs index adc8bd5..a43a969 100644 --- a/AssetManagement.cs +++ b/AssetManagement.cs | |||
@@ -72,14 +72,14 @@ namespace OpenSim | |||
72 | AssetInfo Asset=new AssetInfo(); | 72 | AssetInfo Asset=new AssetInfo(); |
73 | Asset.filename="base_shape.dat"; | 73 | Asset.filename="base_shape.dat"; |
74 | Asset.Full_ID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); | 74 | Asset.Full_ID=new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73"); |
75 | this.LoadAsset(Asset); | 75 | this.LoadAsset(Asset, false); |
76 | this.Assets.Add(Asset.Full_ID,Asset); | 76 | this.Assets.Add(Asset.Full_ID, Asset); |
77 | 77 | ||
78 | Asset=new AssetInfo(); | 78 | Asset=new AssetInfo(); |
79 | Asset.filename="base_skin.dat"; | 79 | Asset.filename="base_skin.dat"; |
80 | Asset.Full_ID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); | 80 | Asset.Full_ID=new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49"); |
81 | this.LoadAsset(Asset); | 81 | this.LoadAsset(Asset, false); |
82 | this.Assets.Add(Asset.Full_ID,Asset); | 82 | this.Assets.Add(Asset.Full_ID, Asset); |
83 | 83 | ||
84 | //our test images | 84 | //our test images |
85 | //Change these filenames to images you want to use. | 85 | //Change these filenames to images you want to use. |
@@ -87,20 +87,20 @@ namespace OpenSim | |||
87 | Image.filename="testpic2.jp2"; | 87 | Image.filename="testpic2.jp2"; |
88 | Image.Full_ID=new LLUUID("00000000-0000-0000-5005-000000000005"); | 88 | Image.Full_ID=new LLUUID("00000000-0000-0000-5005-000000000005"); |
89 | Image.Name="test Texture"; | 89 | Image.Name="test Texture"; |
90 | this.LoadImage(Image); | 90 | this.LoadAsset(Image, true); |
91 | this.Textures.Add(Image.Full_ID,Image); | 91 | this.Textures.Add(Image.Full_ID, Image); |
92 | 92 | ||
93 | Image=new TextureImage(); | 93 | Image=new TextureImage(); |
94 | Image.filename="map_base.jp2"; | 94 | Image.filename="map_base.jp2"; |
95 | Image.Full_ID=new LLUUID("00000000-0000-0000-7007-000000000006"); | 95 | Image.Full_ID=new LLUUID("00000000-0000-0000-7007-000000000006"); |
96 | this.LoadImage(Image); | 96 | this.LoadAsset(Image, true); |
97 | this.Textures.Add(Image.Full_ID,Image); | 97 | this.Textures.Add(Image.Full_ID, Image); |
98 | 98 | ||
99 | Image=new TextureImage(); | 99 | Image=new TextureImage(); |
100 | Image.filename="map1.jp2"; | 100 | Image.filename="map1.jp2"; |
101 | Image.Full_ID=new LLUUID("00000000-0000-0000-7009-000000000008"); | 101 | Image.Full_ID=new LLUUID("00000000-0000-0000-7009-000000000008"); |
102 | this.LoadImage(Image); | 102 | this.LoadAsset(Image, true); |
103 | this.Textures.Add(Image.Full_ID,Image); | 103 | this.Textures.Add(Image.Full_ID, Image); |
104 | } | 104 | } |
105 | 105 | ||
106 | /// <summary> | 106 | /// <summary> |
@@ -129,7 +129,7 @@ namespace OpenSim | |||
129 | Transfer.TransferInfo.Size=info.data.Length; | 129 | Transfer.TransferInfo.Size=info.data.Length; |
130 | Transfer.TransferInfo.TransferID=TransferRequest.TransferInfo.TransferID; | 130 | Transfer.TransferInfo.TransferID=TransferRequest.TransferInfo.TransferID; |
131 | 131 | ||
132 | server.SendPacket(Transfer,true,UserInfo); | 132 | server.SendPacket(Transfer, true, UserInfo); |
133 | 133 | ||
134 | TransferPacketPacket TransferPacket=new TransferPacketPacket(); | 134 | TransferPacketPacket TransferPacket=new TransferPacketPacket(); |
135 | TransferPacket.TransferData.Packet=0; | 135 | TransferPacket.TransferData.Packet=0; |
@@ -148,16 +148,16 @@ namespace OpenSim | |||
148 | TransferPacket.TransferData.ChannelType=2; | 148 | TransferPacket.TransferData.ChannelType=2; |
149 | TransferPacket.TransferData.TransferID=TransferRequest.TransferInfo.TransferID; | 149 | TransferPacket.TransferData.TransferID=TransferRequest.TransferInfo.TransferID; |
150 | byte[] chunk1=new byte[(info.data.Length-1000)]; | 150 | byte[] chunk1=new byte[(info.data.Length-1000)]; |
151 | Array.Copy(info.data,1000,chunk1,0,chunk1.Length); | 151 | Array.Copy(info.data, 1000, chunk1, 0, chunk1.Length); |
152 | TransferPacket.TransferData.Data=chunk1; | 152 | TransferPacket.TransferData.Data=chunk1; |
153 | TransferPacket.TransferData.Status=1; | 153 | TransferPacket.TransferData.Status=1; |
154 | server.SendPacket(TransferPacket,true,UserInfo); | 154 | server.SendPacket(TransferPacket, true, UserInfo); |
155 | } | 155 | } |
156 | else | 156 | else |
157 | { | 157 | { |
158 | TransferPacket.TransferData.Status=1; //last packet? so set to 1 | 158 | TransferPacket.TransferData.Status=1; //last packet? so set to 1 |
159 | TransferPacket.TransferData.Data=info.data; | 159 | TransferPacket.TransferData.Data=info.data; |
160 | server.SendPacket(TransferPacket,true,UserInfo); | 160 | server.SendPacket(TransferPacket, true, UserInfo); |
161 | } | 161 | } |
162 | 162 | ||
163 | } | 163 | } |
@@ -166,12 +166,12 @@ namespace OpenSim | |||
166 | { | 166 | { |
167 | //Create Folders | 167 | //Create Folders |
168 | LLUUID BaseFolder=Avata.BaseFolder; | 168 | LLUUID BaseFolder=Avata.BaseFolder; |
169 | InventoryManager.CreateNewFolder(UserInfo,Avata.InventoryFolder); | 169 | InventoryManager.CreateNewFolder(UserInfo, Avata.InventoryFolder); |
170 | InventoryManager.CreateNewFolder(UserInfo, BaseFolder); | 170 | InventoryManager.CreateNewFolder(UserInfo, BaseFolder); |
171 | 171 | ||
172 | //Give a copy of default shape | 172 | //Give a copy of default shape |
173 | AssetInfo Base=this.Assets[new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73")]; | 173 | AssetInfo Base=this.Assets[new LLUUID("66c41e39-38f9-f75a-024e-585989bfab73")]; |
174 | AssetInfo Shape=this.CloneAsset(UserInfo.AgentID,Base); | 174 | AssetInfo Shape=this.CloneAsset(UserInfo.AgentID, Base); |
175 | 175 | ||
176 | Shape.filename=""; | 176 | Shape.filename=""; |
177 | Shape.Name="Default Shape"; | 177 | Shape.Name="Default Shape"; |
@@ -180,15 +180,15 @@ namespace OpenSim | |||
180 | Shape.Type=libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY; | 180 | Shape.Type=libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY; |
181 | 181 | ||
182 | byte[] Agentid=enc.GetBytes(UserInfo.AgentID.ToStringHyphenated()); | 182 | byte[] Agentid=enc.GetBytes(UserInfo.AgentID.ToStringHyphenated()); |
183 | Array.Copy(Agentid,0,Shape.data,294,Agentid.Length); | 183 | Array.Copy(Agentid, 0, Shape.data, 294, Agentid.Length); |
184 | this.Assets.Add(Shape.Full_ID,Shape); | 184 | this.Assets.Add(Shape.Full_ID, Shape); |
185 | 185 | ||
186 | Avata.Wearables[0].ItemID=InventoryManager.AddToInventory(UserInfo,BaseFolder,Shape); | 186 | Avata.Wearables[0].ItemID=InventoryManager.AddToInventory(UserInfo, BaseFolder, Shape); |
187 | Avata.Wearables[0].AssetID=Shape.Full_ID; | 187 | Avata.Wearables[0].AssetID=Shape.Full_ID; |
188 | 188 | ||
189 | //Give copy of default skin | 189 | //Give copy of default skin |
190 | Base=this.Assets[new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49")]; | 190 | Base=this.Assets[new LLUUID("e0ee49b5a4184df8d3c9a65361fe7f49")]; |
191 | AssetInfo Skin=this.CloneAsset(UserInfo.AgentID,Base); | 191 | AssetInfo Skin=this.CloneAsset(UserInfo.AgentID, Base); |
192 | 192 | ||
193 | Skin.filename=""; | 193 | Skin.filename=""; |
194 | Skin.Name="Default Skin"; | 194 | Skin.Name="Default Skin"; |
@@ -197,25 +197,33 @@ namespace OpenSim | |||
197 | Skin.Type=libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY; | 197 | Skin.Type=libsecondlife.AssetSystem.Asset.ASSET_TYPE_WEARABLE_BODY; |
198 | 198 | ||
199 | Array.Copy(Agentid,0,Skin.data,238,Agentid.Length); | 199 | Array.Copy(Agentid,0,Skin.data,238,Agentid.Length); |
200 | this.Assets.Add(Skin.Full_ID,Skin); | 200 | this.Assets.Add(Skin.Full_ID, Skin); |
201 | 201 | ||
202 | Avata.Wearables[1].ItemID=InventoryManager.AddToInventory(UserInfo,BaseFolder,Skin); | 202 | Avata.Wearables[1].ItemID=InventoryManager.AddToInventory(UserInfo, BaseFolder, Skin); |
203 | Avata.Wearables[1].AssetID=Skin.Full_ID; | 203 | Avata.Wearables[1].AssetID=Skin.Full_ID; |
204 | 204 | ||
205 | //give a copy of test texture | 205 | //give a copy of test texture |
206 | TextureImage Texture=this.CloneImage(UserInfo.AgentID,Textures[new LLUUID("00000000-0000-0000-5005-000000000005")]); | 206 | TextureImage Texture=this.CloneImage(UserInfo.AgentID,Textures[new LLUUID("00000000-0000-0000-5005-000000000005")]); |
207 | this.Textures.Add(Texture.Full_ID,Texture); | 207 | this.Textures.Add(Texture.Full_ID, Texture); |
208 | InventoryManager.AddToInventory(UserInfo,BaseFolder,Texture); | 208 | InventoryManager.AddToInventory(UserInfo, BaseFolder, Texture); |
209 | 209 | ||
210 | } | 210 | } |
211 | 211 | ||
212 | 212 | ||
213 | private void LoadAsset(AssetInfo info) | 213 | private void LoadAsset(AssetBase info, bool Image) |
214 | { | 214 | { |
215 | //should request Asset from storage manager | 215 | //should request Asset from storage manager |
216 | //but for now read from file | 216 | //but for now read from file |
217 | 217 | string folder; | |
218 | string data_path = System.AppDomain.CurrentDomain.BaseDirectory + @"\assets\"; | 218 | if(Image) |
219 | { | ||
220 | folder=@"\textures\"; | ||
221 | } | ||
222 | else | ||
223 | { | ||
224 | folder=@"\assets\"; | ||
225 | } | ||
226 | string data_path = System.AppDomain.CurrentDomain.BaseDirectory + folder; | ||
219 | string filename=data_path+@info.filename; | 227 | string filename=data_path+@info.filename; |
220 | FileInfo fInfo = new FileInfo(filename); | 228 | FileInfo fInfo = new FileInfo(filename); |
221 | 229 | ||
@@ -228,7 +236,7 @@ namespace OpenSim | |||
228 | br.Close(); | 236 | br.Close(); |
229 | fStream.Close(); | 237 | fStream.Close(); |
230 | info.data=idata; | 238 | info.data=idata; |
231 | info.loaded=true; | 239 | //info.loaded=true; |
232 | } | 240 | } |
233 | 241 | ||
234 | public AssetInfo CloneAsset(LLUUID NewOwner, AssetInfo SourceAsset) | 242 | public AssetInfo CloneAsset(LLUUID NewOwner, AssetInfo SourceAsset) |
@@ -252,7 +260,7 @@ namespace OpenSim | |||
252 | //not found image so send back image not in data base message | 260 | //not found image so send back image not in data base message |
253 | ImageNotInDatabasePacket im_not=new ImageNotInDatabasePacket(); | 261 | ImageNotInDatabasePacket im_not=new ImageNotInDatabasePacket(); |
254 | im_not.ImageID.ID=image_id; | 262 | im_not.ImageID.ID=image_id; |
255 | server.SendPacket(im_not,true,user); | 263 | server.SendPacket(im_not, true, user); |
256 | return; | 264 | return; |
257 | } | 265 | } |
258 | TextureImage imag=this.Textures[image_id]; | 266 | TextureImage imag=this.Textures[image_id]; |
@@ -348,27 +356,6 @@ namespace OpenSim | |||
348 | 356 | ||
349 | } | 357 | } |
350 | 358 | ||
351 | private void LoadImage(TextureImage im) | ||
352 | { | ||
353 | //should request Image from StorageManager | ||
354 | //but for now read from file | ||
355 | |||
356 | string data_path=System.AppDomain.CurrentDomain.BaseDirectory + @"\textures\"; | ||
357 | string filename=data_path+@im.filename; | ||
358 | FileInfo fInfo = new FileInfo(filename); | ||
359 | |||
360 | long numBytes = fInfo.Length; | ||
361 | |||
362 | FileStream fStream = new FileStream(filename, FileMode.Open, FileAccess.Read); | ||
363 | byte[] idata=new byte[numBytes]; | ||
364 | BinaryReader br = new BinaryReader(fStream); | ||
365 | idata= br.ReadBytes((int)numBytes); | ||
366 | br.Close(); | ||
367 | fStream.Close(); | ||
368 | im.data=idata; | ||
369 | im.loaded=true; | ||
370 | } | ||
371 | |||
372 | public TextureImage CloneImage(LLUUID NewOwner,TextureImage Source) | 359 | public TextureImage CloneImage(LLUUID NewOwner,TextureImage Source) |
373 | { | 360 | { |
374 | TextureImage NewImage=new TextureImage(); | 361 | TextureImage NewImage=new TextureImage(); |
@@ -401,7 +388,6 @@ namespace OpenSim | |||
401 | { | 388 | { |
402 | //public byte[] data; | 389 | //public byte[] data; |
403 | //public LLUUID Full_ID; | 390 | //public LLUUID Full_ID; |
404 | public string filename; | ||
405 | public bool loaded; | 391 | public bool loaded; |
406 | public ulong last_used; //need to add a tick/time counter and keep record | 392 | public ulong last_used; //need to add a tick/time counter and keep record |
407 | // of how often images are requested to unload unused ones. | 393 | // of how often images are requested to unload unused ones. |
@@ -420,13 +406,14 @@ namespace OpenSim | |||
420 | public sbyte InvType; | 406 | public sbyte InvType; |
421 | public string Name; | 407 | public string Name; |
422 | public string Description; | 408 | public string Description; |
409 | public string filename; | ||
423 | 410 | ||
424 | public AssetBase() | 411 | public AssetBase() |
425 | { | 412 | { |
426 | 413 | ||
427 | } | 414 | } |
428 | } | 415 | } |
429 | public class TextureRequest | 416 | public class TextureRequest |
430 | { | 417 | { |
431 | public User_Agent_info RequestUser; | 418 | public User_Agent_info RequestUser; |
432 | public LLUUID RequestImage; | 419 | public LLUUID RequestImage; |
@@ -442,13 +429,13 @@ namespace OpenSim | |||
442 | } | 429 | } |
443 | public class TextureImage: AssetBase | 430 | public class TextureImage: AssetBase |
444 | { | 431 | { |
432 | //any need for this class now most has been moved into AssetBase? | ||
445 | //public byte[] data; | 433 | //public byte[] data; |
446 | //public LLUUID Full_ID; | 434 | //public LLUUID Full_ID; |
447 | //public string name; | 435 | //public string name; |
448 | public string filename; | ||
449 | public bool loaded; | 436 | public bool loaded; |
450 | public ulong last_used; //need to add a tick/time counter and keep record | 437 | public ulong last_used; //need to add a tick/time counter and keep record |
451 | // of how often images are requested to unload unused ones. | 438 | // of how often images are requested to unload unused ones. |
452 | 439 | ||
453 | public TextureImage() | 440 | public TextureImage() |
454 | { | 441 | { |