Tweaks to assetcache to make texture downloading better (I hope)

afrisby
Brian McBee 2007-08-27 04:20:14 +00:00
parent f6706e6cf8
commit 6e35ff2822
1 changed files with 14 additions and 13 deletions

View File

@ -534,7 +534,7 @@ namespace OpenSim.Framework.Communications.Caches
/// <param name="imageID"></param>
public void AddTextureRequest(IClientAPI userInfo, LLUUID imageID, uint packetNumber)
{
//Console.WriteLine("texture request for " + imageID.ToStringHyphenated());
//Console.WriteLine("texture request for " + imageID.ToStringHyphenated() + " packetnumber= " + packetNumber);
//check to see if texture is in local cache, if not request from asset server
if (!this.AvatarRecievedTextures.ContainsKey(userInfo.AgentId))
{
@ -570,8 +570,9 @@ namespace OpenSim.Framework.Communications.Caches
if (imag.Data.LongLength > 600)
{
//Console.WriteLine("{0}", imag.Data.LongLength);
//over 600 bytes so split up file
req.NumPackets = 1 + (int)(imag.Data.Length - 600) / 1000;
req.NumPackets = 2 + (int)(imag.Data.Length - 601) / 1000;
//Console.WriteLine("texture is " + imag.Data.Length + " which we will send in " +req.NumPackets +" packets");
}
else
@ -698,8 +699,7 @@ namespace OpenSim.Framework.Communications.Caches
{
SendPacket();
counter++;
if ((request.PacketCounter > request.NumPackets) | (counter > 100) | (request.NumPackets == 1))
if ((request.PacketCounter >= request.NumPackets) | counter > 100 | (request.NumPackets == 1))
{
return true;
}
@ -715,7 +715,7 @@ namespace OpenSim.Framework.Communications.Caches
//first time for this request so send imagedata packet
if (req.NumPackets == 1)
{
//only one packet so send whole file
//Console.WriteLine("only one packet so send whole file");
ImageDataPacket im = new ImageDataPacket();
im.Header.Reliable = false;
im.ImageID.Packets = 1;
@ -727,7 +727,7 @@ namespace OpenSim.Framework.Communications.Caches
req.PacketCounter++;
//req.ImageInfo.l= time;
//System.Console.WriteLine("sent texture: " + req.ImageInfo.FullID);
// Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated());
//Console.WriteLine("sending single packet for " + req.ImageInfo.FullID.ToStringHyphenated());
}
else
{
@ -744,7 +744,7 @@ namespace OpenSim.Framework.Communications.Caches
req.PacketCounter++;
//req.ImageInfo.last_used = time;
//System.Console.WriteLine("sent first packet of texture:
//System.Console.WriteLine("sent first packet of texture: " + req.ImageInfo.FullID);
//Console.WriteLine("sending packet 1 for " + req.ImageInfo.FullID.ToStringHyphenated());
}
}
@ -759,12 +759,13 @@ namespace OpenSim.Framework.Communications.Caches
im.ImageID.ID = req.ImageInfo.FullID;
int size = req.ImageInfo.Data.Length - 600 - (1000 * (req.PacketCounter-1));
if (size > 1000) size = 1000;
//Console.WriteLine("length= {0} counter= {1} size= {2}",req.ImageInfo.Data.Length, req.PacketCounter, size);
im.ImageData.Data = new byte[size];
Array.Copy(req.ImageInfo.Data, 600 + (1000 * (req.PacketCounter-1)), im.ImageData.Data, 0, size);
req.RequestUser.OutPacket(im);
req.PacketCounter++;
//req.ImageInfo.last_used = time;
//System.Console.WriteLine("sent a packet of texture: "+req.image_info.FullID);
//System.Console.WriteLine("sent a packet of texture: "+req.ImageInfo.FullID);
}
}