diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/Environment/Modules/TextureDownloadModule.cs | 42 |
1 files changed, 23 insertions, 19 deletions
diff --git a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs index 0adace1..813be8d 100644 --- a/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs +++ b/OpenSim/Region/Environment/Modules/TextureDownloadModule.cs | |||
@@ -32,6 +32,7 @@ using libsecondlife; | |||
32 | using libsecondlife.Packets; | 32 | using libsecondlife.Packets; |
33 | using Nini.Config; | 33 | using Nini.Config; |
34 | using OpenSim.Framework; | 34 | using OpenSim.Framework; |
35 | using OpenSim.Framework.Console; | ||
35 | using OpenSim.Region.Environment.Interfaces; | 36 | using OpenSim.Region.Environment.Interfaces; |
36 | using OpenSim.Region.Environment.Scenes; | 37 | using OpenSim.Region.Environment.Scenes; |
37 | 38 | ||
@@ -48,7 +49,8 @@ namespace OpenSim.Region.Environment.Modules | |||
48 | 49 | ||
49 | private BlockingQueue<TextureSender> QueueSenders = new BlockingQueue<TextureSender>(); | 50 | private BlockingQueue<TextureSender> QueueSenders = new BlockingQueue<TextureSender>(); |
50 | 51 | ||
51 | private Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices = new Dictionary<LLUUID, UserTextureDownloadService>(); | 52 | private Dictionary<LLUUID, UserTextureDownloadService> m_userTextureServices = |
53 | new Dictionary<LLUUID, UserTextureDownloadService>(); | ||
52 | 54 | ||
53 | private Thread m_thread; | 55 | private Thread m_thread; |
54 | 56 | ||
@@ -72,7 +74,6 @@ namespace OpenSim.Region.Environment.Modules | |||
72 | m_scene = scene; | 74 | m_scene = scene; |
73 | m_scene.EventManager.OnNewClient += NewClient; | 75 | m_scene.EventManager.OnNewClient += NewClient; |
74 | } | 76 | } |
75 | |||
76 | } | 77 | } |
77 | 78 | ||
78 | public void PostInitialise() | 79 | public void PostInitialise() |
@@ -115,7 +116,7 @@ namespace OpenSim.Region.Environment.Modules | |||
115 | 116 | ||
116 | public void TextureRequest(Object sender, TextureRequestArgs e) | 117 | public void TextureRequest(Object sender, TextureRequestArgs e) |
117 | { | 118 | { |
118 | IClientAPI client = (IClientAPI)sender; | 119 | IClientAPI client = (IClientAPI) sender; |
119 | UserTextureDownloadService textureService; | 120 | UserTextureDownloadService textureService; |
120 | if (TryGetUserTextureService(client.AgentId, out textureService)) | 121 | if (TryGetUserTextureService(client.AgentId, out textureService)) |
121 | { | 122 | { |
@@ -175,7 +176,8 @@ namespace OpenSim.Region.Environment.Modules | |||
175 | { | 176 | { |
176 | if (!m_textureSenders.ContainsKey(e.RequestedAssetID)) | 177 | if (!m_textureSenders.ContainsKey(e.RequestedAssetID)) |
177 | { | 178 | { |
178 | TextureSender requestHandler = new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber); | 179 | TextureSender requestHandler = |
180 | new TextureSender(client, e.RequestedAssetID, e.DiscardLevel, e.PacketNumber); | ||
179 | m_textureSenders.Add(e.RequestedAssetID, requestHandler); | 181 | m_textureSenders.Add(e.RequestedAssetID, requestHandler); |
180 | m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback); | 182 | m_scene.AssetCache.GetAsset(e.RequestedAssetID, TextureCallback); |
181 | } | 183 | } |
@@ -183,7 +185,8 @@ namespace OpenSim.Region.Environment.Modules | |||
183 | { | 185 | { |
184 | m_textureSenders[e.RequestedAssetID].UpdateRequest(e.DiscardLevel, e.PacketNumber); | 186 | m_textureSenders[e.RequestedAssetID].UpdateRequest(e.DiscardLevel, e.PacketNumber); |
185 | m_textureSenders[e.RequestedAssetID].counter = 0; | 187 | m_textureSenders[e.RequestedAssetID].counter = 0; |
186 | if ((m_textureSenders[e.RequestedAssetID].ImageLoaded) && (m_textureSenders[e.RequestedAssetID].Sending ==false)) | 188 | if ((m_textureSenders[e.RequestedAssetID].ImageLoaded) && |
189 | (m_textureSenders[e.RequestedAssetID].Sending == false)) | ||
187 | { | 190 | { |
188 | m_textureSenders[e.RequestedAssetID].Sending = true; | 191 | m_textureSenders[e.RequestedAssetID].Sending = true; |
189 | m_sharedSendersQueue.Enqueue(m_textureSenders[e.RequestedAssetID]); | 192 | m_sharedSendersQueue.Enqueue(m_textureSenders[e.RequestedAssetID]); |
@@ -256,7 +259,7 @@ namespace OpenSim.Region.Environment.Modules | |||
256 | { | 259 | { |
257 | m_asset = asset; | 260 | m_asset = asset; |
258 | NumPackets = CalculateNumPackets(asset.Data.Length); | 261 | NumPackets = CalculateNumPackets(asset.Data.Length); |
259 | PacketCounter = (int)StartPacketNumber; | 262 | PacketCounter = (int) StartPacketNumber; |
260 | ImageLoaded = true; | 263 | ImageLoaded = true; |
261 | } | 264 | } |
262 | 265 | ||
@@ -264,14 +267,15 @@ namespace OpenSim.Region.Environment.Modules | |||
264 | { | 267 | { |
265 | RequestedDiscardLevel = discardLevel; | 268 | RequestedDiscardLevel = discardLevel; |
266 | StartPacketNumber = packetNumber; | 269 | StartPacketNumber = packetNumber; |
267 | PacketCounter = (int)StartPacketNumber; | 270 | PacketCounter = (int) StartPacketNumber; |
268 | } | 271 | } |
269 | 272 | ||
270 | public bool SendTexturePacket() | 273 | public bool SendTexturePacket() |
271 | { | 274 | { |
272 | SendPacket(); | 275 | SendPacket(); |
273 | counter++; | 276 | counter++; |
274 | if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets / (RequestedDiscardLevel + 1)))) ) | 277 | if ((NumPackets == 0) || (RequestedDiscardLevel == -1) || (PacketCounter > NumPackets) || |
278 | ((RequestedDiscardLevel > 0) && (counter > 50 + (NumPackets/(RequestedDiscardLevel + 1))))) | ||
275 | { | 279 | { |
276 | return true; | 280 | return true; |
277 | } | 281 | } |
@@ -290,7 +294,7 @@ namespace OpenSim.Region.Environment.Modules | |||
290 | im.Header.Reliable = false; | 294 | im.Header.Reliable = false; |
291 | im.ImageID.Packets = 1; | 295 | im.ImageID.Packets = 1; |
292 | im.ImageID.ID = m_asset.FullID; | 296 | im.ImageID.ID = m_asset.FullID; |
293 | im.ImageID.Size = (uint)m_asset.Data.Length; | 297 | im.ImageID.Size = (uint) m_asset.Data.Length; |
294 | im.ImageData.Data = m_asset.Data; | 298 | im.ImageData.Data = m_asset.Data; |
295 | im.ImageID.Codec = 2; | 299 | im.ImageID.Codec = 2; |
296 | RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); | 300 | RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); |
@@ -300,9 +304,9 @@ namespace OpenSim.Region.Environment.Modules | |||
300 | { | 304 | { |
301 | ImageDataPacket im = new ImageDataPacket(); | 305 | ImageDataPacket im = new ImageDataPacket(); |
302 | im.Header.Reliable = false; | 306 | im.Header.Reliable = false; |
303 | im.ImageID.Packets = (ushort)(NumPackets); | 307 | im.ImageID.Packets = (ushort) (NumPackets); |
304 | im.ImageID.ID = m_asset.FullID; | 308 | im.ImageID.ID = m_asset.FullID; |
305 | im.ImageID.Size = (uint)m_asset.Data.Length; | 309 | im.ImageID.Size = (uint) m_asset.Data.Length; |
306 | im.ImageData.Data = new byte[600]; | 310 | im.ImageData.Data = new byte[600]; |
307 | Array.Copy(m_asset.Data, 0, im.ImageData.Data, 0, 600); | 311 | Array.Copy(m_asset.Data, 0, im.ImageData.Data, 0, 600); |
308 | im.ImageID.Codec = 2; | 312 | im.ImageID.Codec = 2; |
@@ -314,18 +318,20 @@ namespace OpenSim.Region.Environment.Modules | |||
314 | { | 318 | { |
315 | ImagePacketPacket im = new ImagePacketPacket(); | 319 | ImagePacketPacket im = new ImagePacketPacket(); |
316 | im.Header.Reliable = false; | 320 | im.Header.Reliable = false; |
317 | im.ImageID.Packet = (ushort)(PacketCounter); | 321 | im.ImageID.Packet = (ushort) (PacketCounter); |
318 | im.ImageID.ID = m_asset.FullID; | 322 | im.ImageID.ID = m_asset.FullID; |
319 | int size = m_asset.Data.Length - 600 - (1000 * (PacketCounter - 1)); | 323 | int size = m_asset.Data.Length - 600 - (1000*(PacketCounter - 1)); |
320 | if (size > 1000) size = 1000; | 324 | if (size > 1000) size = 1000; |
321 | im.ImageData.Data = new byte[size]; | 325 | im.ImageData.Data = new byte[size]; |
322 | try | 326 | try |
323 | { | 327 | { |
324 | Array.Copy(m_asset.Data, 600 + (1000 * (PacketCounter - 1)), im.ImageData.Data, 0, size); | 328 | Array.Copy(m_asset.Data, 600 + (1000*(PacketCounter - 1)), im.ImageData.Data, 0, size); |
325 | } | 329 | } |
326 | catch (System.ArgumentOutOfRangeException) | 330 | catch (ArgumentOutOfRangeException) |
327 | { | 331 | { |
328 | OpenSim.Framework.Console.MainLog.Instance.Warn("TEXTURE", "Unable to separate texture into multiple packets: Array bounds failure on asset:" + m_asset.FullID.ToString() + "- TextureDownloadModule.cs. line:328"); | 332 | MainLog.Instance.Warn("TEXTURE", |
333 | "Unable to separate texture into multiple packets: Array bounds failure on asset:" + | ||
334 | m_asset.FullID.ToString() + "- TextureDownloadModule.cs. line:328"); | ||
329 | return; | 335 | return; |
330 | } | 336 | } |
331 | RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); | 337 | RequestUser.OutPacket(im, ThrottleOutPacketType.Texture); |
@@ -342,14 +348,12 @@ namespace OpenSim.Region.Environment.Modules | |||
342 | { | 348 | { |
343 | //over 600 bytes so split up file | 349 | //over 600 bytes so split up file |
344 | int restData = (length - 600); | 350 | int restData = (length - 600); |
345 | int restPackets = ((restData + 999) / 1000); | 351 | int restPackets = ((restData + 999)/1000); |
346 | numPackets = restPackets; | 352 | numPackets = restPackets; |
347 | } | 353 | } |
348 | 354 | ||
349 | return numPackets; | 355 | return numPackets; |
350 | } | 356 | } |
351 | } | 357 | } |
352 | |||
353 | |||
354 | } | 358 | } |
355 | } \ No newline at end of file | 359 | } \ No newline at end of file |