aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/PacketQueue.cs
diff options
context:
space:
mode:
authorlbsa712007-12-27 21:41:48 +0000
committerlbsa712007-12-27 21:41:48 +0000
commitefd90b56b761219af6425b1c7a2cdd3b6ffb4de2 (patch)
treebf5b897e1e3c13211e3e2fc61d30508b94c928c0 /OpenSim/Region/ClientStack/PacketQueue.cs
parent* removed always true if (diff)
downloadopensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.zip
opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.gz
opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.bz2
opensim-SC-efd90b56b761219af6425b1c7a2cdd3b6ffb4de2.tar.xz
* Optimized usings
* shortened references * Removed redundant 'this' * Normalized EOF
Diffstat (limited to 'OpenSim/Region/ClientStack/PacketQueue.cs')
-rw-r--r--OpenSim/Region/ClientStack/PacketQueue.cs198
1 files changed, 101 insertions, 97 deletions
diff --git a/OpenSim/Region/ClientStack/PacketQueue.cs b/OpenSim/Region/ClientStack/PacketQueue.cs
index 4c9295e..1065f63 100644
--- a/OpenSim/Region/ClientStack/PacketQueue.cs
+++ b/OpenSim/Region/ClientStack/PacketQueue.cs
@@ -27,17 +27,10 @@
27*/ 27*/
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net;
31using System.Net.Sockets;
32using System.Text;
33using System.Threading; 30using System.Threading;
34using System.Timers; 31using System.Timers;
35using Axiom.Math;
36using libsecondlife;
37using libsecondlife.Packets; 32using libsecondlife.Packets;
38using OpenSim.Framework; 33using OpenSim.Framework;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Console;
41using Timer=System.Timers.Timer; 34using Timer=System.Timers.Timer;
42 35
43namespace OpenSim.Region.ClientStack 36namespace OpenSim.Region.ClientStack
@@ -47,7 +40,7 @@ namespace OpenSim.Region.ClientStack
47 private bool m_enabled = true; 40 private bool m_enabled = true;
48 41
49 private BlockingQueue<QueItem> SendQueue; 42 private BlockingQueue<QueItem> SendQueue;
50 43
51 private Queue<QueItem> IncomingPacketQueue; 44 private Queue<QueItem> IncomingPacketQueue;
52 private Queue<QueItem> OutgoingPacketQueue; 45 private Queue<QueItem> OutgoingPacketQueue;
53 private Queue<QueItem> ResendOutgoingPacketQueue; 46 private Queue<QueItem> ResendOutgoingPacketQueue;
@@ -57,7 +50,7 @@ namespace OpenSim.Region.ClientStack
57 private Queue<QueItem> TaskOutgoingPacketQueue; 50 private Queue<QueItem> TaskOutgoingPacketQueue;
58 private Queue<QueItem> TextureOutgoingPacketQueue; 51 private Queue<QueItem> TextureOutgoingPacketQueue;
59 private Queue<QueItem> AssetOutgoingPacketQueue; 52 private Queue<QueItem> AssetOutgoingPacketQueue;
60 53
61 private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); 54 private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
62 private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); 55 private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
63 56
@@ -82,15 +75,15 @@ namespace OpenSim.Region.ClientStack
82 // private long ThrottleInterval; 75 // private long ThrottleInterval;
83 private Timer throttleTimer; 76 private Timer throttleTimer;
84 77
85 public PacketQueue() 78 public PacketQueue()
86 { 79 {
87 // While working on this, the BlockingQueue had me fooled for a bit. 80 // While working on this, the BlockingQueue had me fooled for a bit.
88 // The Blocking queue causes the thread to stop until there's something 81 // The Blocking queue causes the thread to stop until there's something
89 // in it to process. it's an on-purpose threadlock though because 82 // in it to process. it's an on-purpose threadlock though because
90 // without it, the clientloop will suck up all sim resources. 83 // without it, the clientloop will suck up all sim resources.
91 84
92 SendQueue = new BlockingQueue<QueItem>(); 85 SendQueue = new BlockingQueue<QueItem>();
93 86
94 IncomingPacketQueue = new Queue<QueItem>(); 87 IncomingPacketQueue = new Queue<QueItem>();
95 OutgoingPacketQueue = new Queue<QueItem>(); 88 OutgoingPacketQueue = new Queue<QueItem>();
96 ResendOutgoingPacketQueue = new Queue<QueItem>(); 89 ResendOutgoingPacketQueue = new Queue<QueItem>();
@@ -100,7 +93,7 @@ namespace OpenSim.Region.ClientStack
100 TaskOutgoingPacketQueue = new Queue<QueItem>(); 93 TaskOutgoingPacketQueue = new Queue<QueItem>();
101 TextureOutgoingPacketQueue = new Queue<QueItem>(); 94 TextureOutgoingPacketQueue = new Queue<QueItem>();
102 AssetOutgoingPacketQueue = new Queue<QueItem>(); 95 AssetOutgoingPacketQueue = new Queue<QueItem>();
103 96
104 97
105 // Set up the throttle classes (min, max, current) in bytes 98 // Set up the throttle classes (min, max, current) in bytes
106 ResendThrottle = new PacketThrottle(5000, 100000, 50000); 99 ResendThrottle = new PacketThrottle(5000, 100000, 50000);
@@ -114,14 +107,13 @@ namespace OpenSim.Region.ClientStack
114 // Number of bytes allowed to go out per second. (256kbps per client) 107 // Number of bytes allowed to go out per second. (256kbps per client)
115 TotalThrottle = new PacketThrottle(0, 162144, 1536000); 108 TotalThrottle = new PacketThrottle(0, 162144, 1536000);
116 109
117 throttleTimer = new Timer((int)(throttletimems/throttleTimeDivisor)); 110 throttleTimer = new Timer((int) (throttletimems/throttleTimeDivisor));
118 throttleTimer.Elapsed += new ElapsedEventHandler(ThrottleTimerElapsed); 111 throttleTimer.Elapsed += new ElapsedEventHandler(ThrottleTimerElapsed);
119 throttleTimer.Start(); 112 throttleTimer.Start();
120 113
121 // TIMERS needed for this 114 // TIMERS needed for this
122 // LastThrottle = DateTime.Now.Ticks; 115 // LastThrottle = DateTime.Now.Ticks;
123 // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor); 116 // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor);
124
125 } 117 }
126 118
127 /* STANDARD QUEUE MANIPULATION INTERFACES */ 119 /* STANDARD QUEUE MANIPULATION INTERFACES */
@@ -129,44 +121,48 @@ namespace OpenSim.Region.ClientStack
129 121
130 public void Enqueue(QueItem item) 122 public void Enqueue(QueItem item)
131 { 123 {
132 if (!m_enabled) {return;} 124 if (!m_enabled)
125 {
126 return;
127 }
133 // We could micro lock, but that will tend to actually 128 // We could micro lock, but that will tend to actually
134 // probably be worse than just synchronizing on SendQueue 129 // probably be worse than just synchronizing on SendQueue
135 130
136 lock (this) { 131 lock (this)
132 {
137 switch (item.throttleType) 133 switch (item.throttleType)
138 { 134 {
139 case ThrottleOutPacketType.Resend: 135 case ThrottleOutPacketType.Resend:
140 ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item); 136 ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item);
141 break; 137 break;
142 case ThrottleOutPacketType.Texture: 138 case ThrottleOutPacketType.Texture:
143 ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item); 139 ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item);
144 break; 140 break;
145 case ThrottleOutPacketType.Task: 141 case ThrottleOutPacketType.Task:
146 ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item); 142 ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item);
147 break; 143 break;
148 case ThrottleOutPacketType.Land: 144 case ThrottleOutPacketType.Land:
149 ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item); 145 ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item);
150 break; 146 break;
151 case ThrottleOutPacketType.Asset: 147 case ThrottleOutPacketType.Asset:
152 ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item); 148 ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item);
153 break; 149 break;
154 case ThrottleOutPacketType.Cloud: 150 case ThrottleOutPacketType.Cloud:
155 ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item); 151 ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item);
156 break; 152 break;
157 case ThrottleOutPacketType.Wind: 153 case ThrottleOutPacketType.Wind:
158 ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item); 154 ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item);
159 break; 155 break;
160 156
161 default: 157 default:
162 // Acknowledgements and other such stuff should go directly to the blocking Queue 158 // Acknowledgements and other such stuff should go directly to the blocking Queue
163 // Throttling them may and likely 'will' be problematic 159 // Throttling them may and likely 'will' be problematic
164 SendQueue.Enqueue(item); 160 SendQueue.Enqueue(item);
165 break; 161 break;
166 } 162 }
167 } 163 }
168 } 164 }
169 165
170 public QueItem Dequeue() 166 public QueItem Dequeue()
171 { 167 {
172 return SendQueue.Dequeue(); 168 return SendQueue.Dequeue();
@@ -174,7 +170,8 @@ namespace OpenSim.Region.ClientStack
174 170
175 public void Flush() 171 public void Flush()
176 { 172 {
177 lock(this) { 173 lock (this)
174 {
178 while (PacketsWaiting()) 175 while (PacketsWaiting())
179 { 176 {
180 //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up. 177 //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up.
@@ -211,7 +208,7 @@ namespace OpenSim.Region.ClientStack
211 } 208 }
212 } 209 }
213 210
214 public void Close() 211 public void Close()
215 { 212 {
216 m_enabled = false; 213 m_enabled = false;
217 throttleTimer.Stop(); 214 throttleTimer.Stop();
@@ -242,22 +239,22 @@ namespace OpenSim.Region.ClientStack
242 239
243 public void ProcessThrottle() 240 public void ProcessThrottle()
244 { 241 {
245
246 // I was considering this.. Will an event fire if the thread it's on is blocked? 242 // I was considering this.. Will an event fire if the thread it's on is blocked?
247 243
248 // Then I figured out.. it doesn't really matter.. because this thread won't be blocked for long 244 // Then I figured out.. it doesn't really matter.. because this thread won't be blocked for long
249 // The General overhead of the UDP protocol gets sent to the queue un-throttled by this 245 // The General overhead of the UDP protocol gets sent to the queue un-throttled by this
250 // so This'll pick up about around the right time. 246 // so This'll pick up about around the right time.
251 247
252 int MaxThrottleLoops = 4550; // 50*7 packets can be dequeued at once. 248 int MaxThrottleLoops = 4550; // 50*7 packets can be dequeued at once.
253 int throttleLoops = 0; 249 int throttleLoops = 0;
254 250
255 // We're going to dequeue all of the saved up packets until 251 // We're going to dequeue all of the saved up packets until
256 // we've hit the throttle limit or there's no more packets to send 252 // we've hit the throttle limit or there's no more packets to send
257 lock (this) { 253 lock (this)
254 {
258 ResetCounters(); 255 ResetCounters();
259 // MainLog.Instance.Verbose("THROTTLE", "Entering Throttle"); 256 // MainLog.Instance.Verbose("THROTTLE", "Entering Throttle");
260 while (TotalThrottle.UnderLimit() && PacketsWaiting() && 257 while (TotalThrottle.UnderLimit() && PacketsWaiting() &&
261 (throttleLoops <= MaxThrottleLoops)) 258 (throttleLoops <= MaxThrottleLoops))
262 { 259 {
263 throttleLoops++; 260 throttleLoops++;
@@ -265,7 +262,7 @@ namespace OpenSim.Region.ClientStack
265 if (ResendThrottle.UnderLimit() && ResendOutgoingPacketQueue.Count > 0) 262 if (ResendThrottle.UnderLimit() && ResendOutgoingPacketQueue.Count > 0)
266 { 263 {
267 QueItem qpack = ResendOutgoingPacketQueue.Dequeue(); 264 QueItem qpack = ResendOutgoingPacketQueue.Dequeue();
268 265
269 SendQueue.Enqueue(qpack); 266 SendQueue.Enqueue(qpack);
270 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 267 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
271 ResendThrottle.Add(qpack.Packet.ToBytes().Length); 268 ResendThrottle.Add(qpack.Packet.ToBytes().Length);
@@ -273,7 +270,7 @@ namespace OpenSim.Region.ClientStack
273 if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0) 270 if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0)
274 { 271 {
275 QueItem qpack = LandOutgoingPacketQueue.Dequeue(); 272 QueItem qpack = LandOutgoingPacketQueue.Dequeue();
276 273
277 SendQueue.Enqueue(qpack); 274 SendQueue.Enqueue(qpack);
278 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 275 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
279 LandThrottle.Add(qpack.Packet.ToBytes().Length); 276 LandThrottle.Add(qpack.Packet.ToBytes().Length);
@@ -281,7 +278,7 @@ namespace OpenSim.Region.ClientStack
281 if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0) 278 if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0)
282 { 279 {
283 QueItem qpack = WindOutgoingPacketQueue.Dequeue(); 280 QueItem qpack = WindOutgoingPacketQueue.Dequeue();
284 281
285 SendQueue.Enqueue(qpack); 282 SendQueue.Enqueue(qpack);
286 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 283 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
287 WindThrottle.Add(qpack.Packet.ToBytes().Length); 284 WindThrottle.Add(qpack.Packet.ToBytes().Length);
@@ -289,7 +286,7 @@ namespace OpenSim.Region.ClientStack
289 if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0) 286 if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0)
290 { 287 {
291 QueItem qpack = CloudOutgoingPacketQueue.Dequeue(); 288 QueItem qpack = CloudOutgoingPacketQueue.Dequeue();
292 289
293 SendQueue.Enqueue(qpack); 290 SendQueue.Enqueue(qpack);
294 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 291 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
295 CloudThrottle.Add(qpack.Packet.ToBytes().Length); 292 CloudThrottle.Add(qpack.Packet.ToBytes().Length);
@@ -297,7 +294,7 @@ namespace OpenSim.Region.ClientStack
297 if (TaskThrottle.UnderLimit() && TaskOutgoingPacketQueue.Count > 0) 294 if (TaskThrottle.UnderLimit() && TaskOutgoingPacketQueue.Count > 0)
298 { 295 {
299 QueItem qpack = TaskOutgoingPacketQueue.Dequeue(); 296 QueItem qpack = TaskOutgoingPacketQueue.Dequeue();
300 297
301 SendQueue.Enqueue(qpack); 298 SendQueue.Enqueue(qpack);
302 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 299 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
303 TaskThrottle.Add(qpack.Packet.ToBytes().Length); 300 TaskThrottle.Add(qpack.Packet.ToBytes().Length);
@@ -305,7 +302,7 @@ namespace OpenSim.Region.ClientStack
305 if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0) 302 if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0)
306 { 303 {
307 QueItem qpack = TextureOutgoingPacketQueue.Dequeue(); 304 QueItem qpack = TextureOutgoingPacketQueue.Dequeue();
308 305
309 SendQueue.Enqueue(qpack); 306 SendQueue.Enqueue(qpack);
310 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 307 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
311 TextureThrottle.Add(qpack.Packet.ToBytes().Length); 308 TextureThrottle.Add(qpack.Packet.ToBytes().Length);
@@ -313,19 +310,18 @@ namespace OpenSim.Region.ClientStack
313 if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0) 310 if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0)
314 { 311 {
315 QueItem qpack = AssetOutgoingPacketQueue.Dequeue(); 312 QueItem qpack = AssetOutgoingPacketQueue.Dequeue();
316 313
317 SendQueue.Enqueue(qpack); 314 SendQueue.Enqueue(qpack);
318 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 315 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
319 AssetThrottle.Add(qpack.Packet.ToBytes().Length); 316 AssetThrottle.Add(qpack.Packet.ToBytes().Length);
320 } 317 }
321 } 318 }
322 // MainLog.Instance.Verbose("THROTTLE", "Processed " + throttleLoops + " packets"); 319 // MainLog.Instance.Verbose("THROTTLE", "Processed " + throttleLoops + " packets");
323
324 } 320 }
325 } 321 }
326 322
327 private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e) 323 private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e)
328 { 324 {
329 // just to change the signature, and that ProcessThrottle 325 // just to change the signature, and that ProcessThrottle
330 // will be used elsewhere possibly 326 // will be used elsewhere possibly
331 ProcessThrottle(); 327 ProcessThrottle();
@@ -339,7 +335,7 @@ namespace OpenSim.Region.ClientStack
339 // wait for the timer to fire to put things into the 335 // wait for the timer to fire to put things into the
340 // output queue 336 // output queue
341 337
342 if((q.Count == 0) && (throttle.UnderLimit())) 338 if ((q.Count == 0) && (throttle.UnderLimit()))
343 { 339 {
344 Monitor.Enter(this); 340 Monitor.Enter(this);
345 throttle.Add(item.Packet.ToBytes().Length); 341 throttle.Add(item.Packet.ToBytes().Length);
@@ -357,31 +353,39 @@ namespace OpenSim.Region.ClientStack
357 353
358 private int ScaleThrottle(int value, int curmax, int newmax) 354 private int ScaleThrottle(int value, int curmax, int newmax)
359 { 355 {
360 return (int)(((float)value/(float)curmax) * newmax); 356 return (int) (((float) value/(float) curmax)*newmax);
361 } 357 }
358
362 private byte[] GetThrottlesPacked(float multiplier) 359 private byte[] GetThrottlesPacked(float multiplier)
363 { 360 {
364 int singlefloat = 4; 361 int singlefloat = 4;
365 float tResend = ResendThrottle.Throttle * multiplier; 362 float tResend = ResendThrottle.Throttle*multiplier;
366 float tLand = LandThrottle.Throttle * multiplier; 363 float tLand = LandThrottle.Throttle*multiplier;
367 float tWind = WindThrottle.Throttle * multiplier; 364 float tWind = WindThrottle.Throttle*multiplier;
368 float tCloud = CloudThrottle.Throttle * multiplier; 365 float tCloud = CloudThrottle.Throttle*multiplier;
369 float tTask = TaskThrottle.Throttle * multiplier; 366 float tTask = TaskThrottle.Throttle*multiplier;
370 float tTexture = TextureThrottle.Throttle * multiplier; 367 float tTexture = TextureThrottle.Throttle*multiplier;
371 float tAsset = AssetThrottle.Throttle * multiplier; 368 float tAsset = AssetThrottle.Throttle*multiplier;
372 369
373 byte[] throttles = new byte[singlefloat * 7]; 370 byte[] throttles = new byte[singlefloat*7];
374 int i = 0; 371 int i = 0;
375 Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat * i, singlefloat); i++; 372 Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat*i, singlefloat);
376 Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat * i, singlefloat); i++; 373 i++;
377 Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat * i, singlefloat); i++; 374 Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat*i, singlefloat);
378 Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat * i, singlefloat); i++; 375 i++;
379 Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat * i, singlefloat); i++; 376 Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat*i, singlefloat);
380 Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat * i, singlefloat); i++; 377 i++;
381 Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat * i, singlefloat); 378 Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat*i, singlefloat);
379 i++;
380 Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat*i, singlefloat);
381 i++;
382 Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat*i, singlefloat);
383 i++;
384 Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat*i, singlefloat);
382 385
383 return throttles; 386 return throttles;
384 } 387 }
388
385 public void SetThrottleFromClient(byte[] throttle) 389 public void SetThrottleFromClient(byte[] throttle)
386 { 390 {
387 int tResend = -1; 391 int tResend = -1;
@@ -401,25 +405,25 @@ namespace OpenSim.Region.ClientStack
401 // it might be smart to do this check more often... 405 // it might be smart to do this check more often...
402 if (!BitConverter.IsLittleEndian) 406 if (!BitConverter.IsLittleEndian)
403 for (int i = 0; i < 7; i++) 407 for (int i = 0; i < 7; i++)
404 Array.Reverse(throttle, j + i * singlefloat, singlefloat); 408 Array.Reverse(throttle, j + i*singlefloat, singlefloat);
405 409
406 // values gotten from libsecondlife.org/wiki/Throttle. Thanks MW_ 410 // values gotten from libsecondlife.org/wiki/Throttle. Thanks MW_
407 // bytes 411 // bytes
408 // Convert to integer, since.. the full fp space isn't used. 412 // Convert to integer, since.. the full fp space isn't used.
409 tResend = (int)BitConverter.ToSingle(throttle, j); 413 tResend = (int) BitConverter.ToSingle(throttle, j);
410 j += singlefloat; 414 j += singlefloat;
411 tLand = (int)BitConverter.ToSingle(throttle, j); 415 tLand = (int) BitConverter.ToSingle(throttle, j);
412 j += singlefloat; 416 j += singlefloat;
413 tWind = (int)BitConverter.ToSingle(throttle, j); 417 tWind = (int) BitConverter.ToSingle(throttle, j);
414 j += singlefloat; 418 j += singlefloat;
415 tCloud = (int)BitConverter.ToSingle(throttle, j); 419 tCloud = (int) BitConverter.ToSingle(throttle, j);
416 j += singlefloat; 420 j += singlefloat;
417 tTask = (int)BitConverter.ToSingle(throttle, j); 421 tTask = (int) BitConverter.ToSingle(throttle, j);
418 j += singlefloat; 422 j += singlefloat;
419 tTexture = (int)BitConverter.ToSingle(throttle, j); 423 tTexture = (int) BitConverter.ToSingle(throttle, j);
420 j += singlefloat; 424 j += singlefloat;
421 tAsset = (int)BitConverter.ToSingle(throttle, j); 425 tAsset = (int) BitConverter.ToSingle(throttle, j);
422 426
423 tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset; 427 tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset;
424 /* 428 /*
425 MainLog.Instance.Verbose("CLIENT", "Client AgentThrottle - Got throttle:resendbytes=" + tResend + 429 MainLog.Instance.Verbose("CLIENT", "Client AgentThrottle - Got throttle:resendbytes=" + tResend +
@@ -431,13 +435,13 @@ namespace OpenSim.Region.ClientStack
431 " Assetbytes=" + tAsset + 435 " Assetbytes=" + tAsset +
432 " Allbytes=" + tall); 436 " Allbytes=" + tall);
433 */ 437 */
434 438
435 // Total Sanity 439 // Total Sanity
436 // Make sure that the client sent sane total values. 440 // Make sure that the client sent sane total values.
437 441
438 // If the client didn't send acceptable values.... 442 // If the client didn't send acceptable values....
439 // Scale the clients values down until they are acceptable. 443 // Scale the clients values down until they are acceptable.
440 444
441 if (tall <= TotalThrottle.Max) 445 if (tall <= TotalThrottle.Max)
442 { 446 {
443 ResendThrottle.Throttle = tResend; 447 ResendThrottle.Throttle = tResend;
@@ -448,7 +452,7 @@ namespace OpenSim.Region.ClientStack
448 TextureThrottle.Throttle = tTexture; 452 TextureThrottle.Throttle = tTexture;
449 AssetThrottle.Throttle = tAsset; 453 AssetThrottle.Throttle = tAsset;
450 TotalThrottle.Throttle = tall; 454 TotalThrottle.Throttle = tall;
451 } 455 }
452 else if (tall < 1) 456 else if (tall < 1)
453 { 457 {
454 // client is stupid, penalize him by minning everything 458 // client is stupid, penalize him by minning everything
@@ -478,4 +482,4 @@ namespace OpenSim.Region.ClientStack
478 ResetCounters(); 482 ResetCounters();
479 } 483 }
480 } 484 }
481} 485} \ No newline at end of file