diff options
Diffstat (limited to 'AssetManagement.cs')
-rw-r--r-- | AssetManagement.cs | 63 |
1 files changed, 42 insertions, 21 deletions
diff --git a/AssetManagement.cs b/AssetManagement.cs index 07b2b57..ad63733 100644 --- a/AssetManagement.cs +++ b/AssetManagement.cs | |||
@@ -268,17 +268,16 @@ namespace OpenSim | |||
268 | TextureRequest req = new TextureRequest(); | 268 | TextureRequest req = new TextureRequest(); |
269 | req.RequestUser = userInfo; | 269 | req.RequestUser = userInfo; |
270 | req.RequestImage = imageID; | 270 | req.RequestImage = imageID; |
271 | req.image_info = imag; | 271 | req.ImageInfo = imag; |
272 | 272 | ||
273 | if(imag.data.LongLength>1000) //should be bigger or smaller? | 273 | if(imag.data.LongLength>600) //should be bigger or smaller? |
274 | { | 274 | { |
275 | //over 1000 bytes so split up file | 275 | //over 600 bytes so split up file |
276 | req.num_packets = (int)imag.data.LongLength/1000; | 276 | req.NumPackets = 1 + (int)(imag.data.Length-600+999)/1000; |
277 | req.num_packets++; | ||
278 | } | 277 | } |
279 | else | 278 | else |
280 | { | 279 | { |
281 | req.num_packets = 1; | 280 | req.NumPackets = 1; |
282 | } | 281 | } |
283 | 282 | ||
284 | this.TextureRequests.Add(req); | 283 | this.TextureRequests.Add(req); |
@@ -312,32 +311,54 @@ namespace OpenSim | |||
312 | { | 311 | { |
313 | req=(TextureRequest)this.TextureRequests[i]; | 312 | req=(TextureRequest)this.TextureRequests[i]; |
314 | 313 | ||
315 | if(req.packet_counter == 0) | 314 | if(req.PacketCounter == 0) |
316 | { | 315 | { |
317 | //first time for this request so send imagedata packet | 316 | //first time for this request so send imagedata packet |
318 | if(req.num_packets == 1) | 317 | if(req.NumPackets == 1) |
319 | { | 318 | { |
320 | //only one packet so send whole file | 319 | //only one packet so send whole file |
321 | ImageDataPacket im = new ImageDataPacket(); | 320 | ImageDataPacket im = new ImageDataPacket(); |
322 | im.ImageID.Packets = 1; | 321 | im.ImageID.Packets = 1; |
323 | im.ImageID.ID = req.image_info.FullID; | 322 | im.ImageID.ID = req.ImageInfo.FullID; |
324 | im.ImageID.Size = (uint)req.image_info.data.Length; | 323 | im.ImageID.Size = (uint)req.ImageInfo.data.Length; |
325 | im.ImageData.Data = req.image_info.data; | 324 | im.ImageData.Data = req.ImageInfo.data; |
326 | im.ImageID.Codec = 2; | 325 | im.ImageID.Codec = 2; |
327 | _server.SendPacket(im, true, req.RequestUser); | 326 | _server.SendPacket(im, true, req.RequestUser); |
328 | req.packet_counter++; | 327 | req.PacketCounter++; |
329 | req.image_info.last_used = time; | 328 | req.ImageInfo.last_used = time; |
330 | System.Console.WriteLine("sent texture: "+req.image_info.FullID); | 329 | //System.Console.WriteLine("sent texture: "+req.image_info.FullID); |
331 | } | 330 | } |
332 | else | 331 | else |
333 | { | 332 | { |
334 | //more than one packet so split file up | 333 | //more than one packet so split file up |
334 | ImageDataPacket im = new ImageDataPacket(); | ||
335 | im.ImageID.Packets = (ushort)req.NumPackets; | ||
336 | im.ImageID.ID = req.ImageInfo.FullID; | ||
337 | im.ImageID.Size = (uint)req.ImageInfo.data.Length; | ||
338 | im.ImageData.Data = new byte[600]; | ||
339 | Array.Copy(req.ImageInfo.data, 0, im.ImageData.Data, 0, 600); | ||
340 | im.ImageID.Codec = 2; | ||
341 | _server.SendPacket(im, true, req.RequestUser); | ||
342 | req.PacketCounter++; | ||
343 | req.ImageInfo.last_used = time; | ||
344 | //System.Console.WriteLine("sent first packet of texture: | ||
335 | } | 345 | } |
336 | } | 346 | } |
337 | else | 347 | else |
338 | { | 348 | { |
339 | //send imagepacket | 349 | //send imagepacket |
340 | 350 | //more than one packet so split file up | |
351 | ImagePacketPacket im = new ImagePacketPacket(); | ||
352 | im.ImageID.Packet = (ushort)req.PacketCounter; | ||
353 | im.ImageID.ID = req.ImageInfo.FullID; | ||
354 | int size = req.ImageInfo.data.Length - 600 - 1000*(req.PacketCounter - 1); | ||
355 | if(size > 1000) size = 1000; | ||
356 | im.ImageData.Data = new byte[size]; | ||
357 | Array.Copy(req.ImageInfo.data, 600 + 1000*(req.PacketCounter - 1), im.ImageData.Data, 0, size); | ||
358 | _server.SendPacket(im, true, req.RequestUser); | ||
359 | req.PacketCounter++; | ||
360 | req.ImageInfo.last_used = time; | ||
361 | //System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID); | ||
341 | } | 362 | } |
342 | } | 363 | } |
343 | 364 | ||
@@ -345,7 +366,7 @@ namespace OpenSim | |||
345 | for(int i = 0; i < num; i++) | 366 | for(int i = 0; i < num; i++) |
346 | { | 367 | { |
347 | req=(TextureRequest)this.TextureRequests[i]; | 368 | req=(TextureRequest)this.TextureRequests[i]; |
348 | if(req.packet_counter == req.num_packets) | 369 | if(req.PacketCounter == req.NumPackets) |
349 | { | 370 | { |
350 | this.TextureRequests.Remove(req); | 371 | this.TextureRequests.Remove(req); |
351 | } | 372 | } |
@@ -418,10 +439,10 @@ namespace OpenSim | |||
418 | { | 439 | { |
419 | public UserAgentInfo RequestUser; | 440 | public UserAgentInfo RequestUser; |
420 | public LLUUID RequestImage; | 441 | public LLUUID RequestImage; |
421 | public TextureImage image_info; | 442 | public TextureImage ImageInfo; |
422 | public long data_pointer = 0; | 443 | public long DataPointer = 0; |
423 | public int num_packets = 0; | 444 | public int NumPackets = 0; |
424 | public int packet_counter = 0; | 445 | public int PacketCounter = 0; |
425 | 446 | ||
426 | public TextureRequest() | 447 | public TextureRequest() |
427 | { | 448 | { |