diff options
author | lbsa71 | 2007-11-23 13:21:39 +0000 |
---|---|---|
committer | lbsa71 | 2007-11-23 13:21:39 +0000 |
commit | fb2588b409069a1c24b55bb547d1a06eec2f0440 (patch) | |
tree | 686540041ed676382d3fa6d5f1c2188ca0e81161 /OpenSim/Framework/Communications/Cache | |
parent | * added some functions for use in raytracing. They're kind of crappy now, so... (diff) | |
download | opensim-SC_OLD-fb2588b409069a1c24b55bb547d1a06eec2f0440.zip opensim-SC_OLD-fb2588b409069a1c24b55bb547d1a06eec2f0440.tar.gz opensim-SC_OLD-fb2588b409069a1c24b55bb547d1a06eec2f0440.tar.bz2 opensim-SC_OLD-fb2588b409069a1c24b55bb547d1a06eec2f0440.tar.xz |
* Refactored NumPackets calculation
Diffstat (limited to 'OpenSim/Framework/Communications/Cache')
-rw-r--r-- | OpenSim/Framework/Communications/Cache/AssetCache.cs | 41 |
1 files changed, 21 insertions, 20 deletions
diff --git a/OpenSim/Framework/Communications/Cache/AssetCache.cs b/OpenSim/Framework/Communications/Cache/AssetCache.cs index edca142..cb8b9f6 100644 --- a/OpenSim/Framework/Communications/Cache/AssetCache.cs +++ b/OpenSim/Framework/Communications/Cache/AssetCache.cs | |||
@@ -333,15 +333,9 @@ namespace OpenSim.Framework.Communications.Cache | |||
333 | { | 333 | { |
334 | AssetRequest req = RequestedTextures[image.FullID]; | 334 | AssetRequest req = RequestedTextures[image.FullID]; |
335 | req.ImageInfo = image; | 335 | req.ImageInfo = image; |
336 | if (image.Data.LongLength > 600) | 336 | |
337 | { | 337 | req.NumPackets = CalculateNumPackets(image.Data.Length); |
338 | //over 600 bytes so split up file | 338 | |
339 | req.NumPackets = 2 + (int) (image.Data.Length - 601)/1000; | ||
340 | } | ||
341 | else | ||
342 | { | ||
343 | req.NumPackets = 1; | ||
344 | } | ||
345 | RequestedTextures.Remove(image.FullID); | 339 | RequestedTextures.Remove(image.FullID); |
346 | TextureRequests.Add(req); | 340 | TextureRequests.Add(req); |
347 | } | 341 | } |
@@ -625,24 +619,31 @@ namespace OpenSim.Framework.Communications.Cache | |||
625 | req.ImageInfo = imag; | 619 | req.ImageInfo = imag; |
626 | req.DiscardLevel = discard; | 620 | req.DiscardLevel = discard; |
627 | 621 | ||
628 | if (imag.Data.LongLength > 600) | 622 | req.NumPackets = CalculateNumPackets(imag.Data.Length); |
629 | { | 623 | |
630 | //Console.WriteLine("{0}", imag.Data.LongLength); | ||
631 | //over 600 bytes so split up file | ||
632 | req.NumPackets = 2 + (int) (imag.Data.Length - 601)/1000; | ||
633 | //Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets"); | ||
634 | } | ||
635 | else | ||
636 | { | ||
637 | req.NumPackets = 1; | ||
638 | } | ||
639 | if (packetNumber != 0) | 624 | if (packetNumber != 0) |
640 | { | 625 | { |
641 | req.PacketCounter = (int) packetNumber; | 626 | req.PacketCounter = (int) packetNumber; |
642 | } | 627 | } |
628 | |||
643 | TextureRequests.Add(req); | 629 | TextureRequests.Add(req); |
644 | } | 630 | } |
645 | 631 | ||
632 | private int CalculateNumPackets(int length) | ||
633 | { | ||
634 | int numPackets = 1; | ||
635 | |||
636 | if (length > 600) | ||
637 | { | ||
638 | //over 600 bytes so split up file | ||
639 | int restData = (length - 600); | ||
640 | int restPackets = ((restData+999)/1000); | ||
641 | numPackets = 1 + restPackets; | ||
642 | } | ||
643 | |||
644 | return numPackets; | ||
645 | } | ||
646 | |||
646 | #endregion | 647 | #endregion |
647 | 648 | ||
648 | public class AssetRequest | 649 | public class AssetRequest |