aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs3
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs251
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs10
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs27
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs66
5 files changed, 232 insertions, 125 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
index e9e2dca..9dd6663 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
@@ -202,6 +202,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
202 m_stopPacket = TexturePacketCount(); 202 m_stopPacket = TexturePacketCount();
203 } 203 }
204 204
205 //Give them at least two packets, to play nice with some broken viewers (SL also behaves this way)
206 if (m_stopPacket == 1 && Layers[0].End > FIRST_PACKET_SIZE) m_stopPacket++;
207
205 m_currentPacket = StartPacket; 208 m_currentPacket = StartPacket;
206 } 209 }
207 } 210 }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 48d5a12..fff4300 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -155,6 +155,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
155 public event RequestTaskInventory OnRequestTaskInventory; 155 public event RequestTaskInventory OnRequestTaskInventory;
156 public event UpdateInventoryItem OnUpdateInventoryItem; 156 public event UpdateInventoryItem OnUpdateInventoryItem;
157 public event CopyInventoryItem OnCopyInventoryItem; 157 public event CopyInventoryItem OnCopyInventoryItem;
158 public event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy;
158 public event MoveInventoryItem OnMoveInventoryItem; 159 public event MoveInventoryItem OnMoveInventoryItem;
159 public event RemoveInventoryItem OnRemoveInventoryItem; 160 public event RemoveInventoryItem OnRemoveInventoryItem;
160 public event RemoveInventoryFolder OnRemoveInventoryFolder; 161 public event RemoveInventoryFolder OnRemoveInventoryFolder;
@@ -335,11 +336,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
335// protected HashSet<uint> m_attachmentsSent; 336// protected HashSet<uint> m_attachmentsSent;
336 337
337 private int m_moneyBalance; 338 private int m_moneyBalance;
339 private bool m_deliverPackets = true;
338 private int m_animationSequenceNumber = 1; 340 private int m_animationSequenceNumber = 1;
339 private bool m_SendLogoutPacketWhenClosing = true; 341 private bool m_SendLogoutPacketWhenClosing = true;
340 private AgentUpdateArgs lastarg; 342 private AgentUpdateArgs lastarg;
341 private bool m_IsActive = true; 343 private bool m_IsActive = true;
342 private bool m_IsLoggingOut = false; 344 private bool m_IsLoggingOut = false;
345 private bool m_IsPresenceReady = false;
343 346
344 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); 347 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
345 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers 348 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
@@ -362,6 +365,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
362 365
363 private Timer m_propertiesPacketTimer; 366 private Timer m_propertiesPacketTimer;
364 private List<ObjectPropertiesPacket.ObjectDataBlock> m_propertiesBlocks = new List<ObjectPropertiesPacket.ObjectDataBlock>(); 367 private List<ObjectPropertiesPacket.ObjectDataBlock> m_propertiesBlocks = new List<ObjectPropertiesPacket.ObjectDataBlock>();
368 private List<Packet> m_pendingPackets;
365 369
366 #endregion Class Members 370 #endregion Class Members
367 371
@@ -377,6 +381,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
377 get { return m_startpos; } 381 get { return m_startpos; }
378 set { m_startpos = value; } 382 set { m_startpos = value; }
379 } 383 }
384 public bool DeliverPackets
385 {
386 get { return m_deliverPackets; }
387 set {
388 m_deliverPackets = value;
389 m_udpClient.m_deliverPackets = value;
390 }
391 }
380 public UUID AgentId { get { return m_agentId; } } 392 public UUID AgentId { get { return m_agentId; } }
381 public UUID ActiveGroupId { get { return m_activeGroupID; } } 393 public UUID ActiveGroupId { get { return m_activeGroupID; } }
382 public string ActiveGroupName { get { return m_activeGroupName; } } 394 public string ActiveGroupName { get { return m_activeGroupName; } }
@@ -406,6 +418,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
406 get { return m_IsActive; } 418 get { return m_IsActive; }
407 set { m_IsActive = value; } 419 set { m_IsActive = value; }
408 } 420 }
421
409 public bool IsLoggingOut 422 public bool IsLoggingOut
410 { 423 {
411 get { return m_IsLoggingOut; } 424 get { return m_IsLoggingOut; }
@@ -475,18 +488,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP
475 488
476 #region Client Methods 489 #region Client Methods
477 490
491
478 /// <summary> 492 /// <summary>
479 /// Shut down the client view 493 /// Shut down the client view
480 /// </summary> 494 /// </summary>
481 public void Close() 495 public void Close()
482 { 496 {
497 Close(true);
498 }
499
500 /// <summary>
501 /// Shut down the client view
502 /// </summary>
503 public void Close(bool sendStop)
504 {
483 m_log.DebugFormat( 505 m_log.DebugFormat(
484 "[CLIENT]: Close has been called for {0} attached to scene {1}", 506 "[CLIENT]: Close has been called for {0} attached to scene {1}",
485 Name, m_scene.RegionInfo.RegionName); 507 Name, m_scene.RegionInfo.RegionName);
486 508
487 // Send the STOP packet 509 if (sendStop)
488 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator); 510 {
489 OutPacket(disable, ThrottleOutPacketType.Unknown); 511 // Send the STOP packet
512 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
513 OutPacket(disable, ThrottleOutPacketType.Unknown);
514 }
490 515
491 IsActive = false; 516 IsActive = false;
492 517
@@ -766,7 +791,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
766 reply.ChatData.OwnerID = fromAgentID; 791 reply.ChatData.OwnerID = fromAgentID;
767 reply.ChatData.SourceID = fromAgentID; 792 reply.ChatData.SourceID = fromAgentID;
768 793
769 OutPacket(reply, ThrottleOutPacketType.Task); 794 OutPacket(reply, ThrottleOutPacketType.Unknown);
770 } 795 }
771 796
772 /// <summary> 797 /// <summary>
@@ -1052,6 +1077,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1052 public virtual void SendLayerData(float[] map) 1077 public virtual void SendLayerData(float[] map)
1053 { 1078 {
1054 Util.FireAndForget(DoSendLayerData, map); 1079 Util.FireAndForget(DoSendLayerData, map);
1080
1081 // Send it sync, and async. It's not that much data
1082 // and it improves user experience just so much!
1083 DoSendLayerData(map);
1055 } 1084 }
1056 1085
1057 /// <summary> 1086 /// <summary>
@@ -1064,16 +1093,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1064 1093
1065 try 1094 try
1066 { 1095 {
1067 //for (int y = 0; y < 16; y++) 1096 for (int y = 0; y < 16; y++)
1068 //{ 1097 {
1069 // for (int x = 0; x < 16; x++) 1098 for (int x = 0; x < 16; x+=4)
1070 // { 1099 {
1071 // SendLayerData(x, y, map); 1100 SendLayerPacket(x, y, map);
1072 // } 1101 }
1073 //} 1102 }
1074
1075 // Send LayerData in a spiral pattern. Fun!
1076 SendLayerTopRight(map, 0, 0, 15, 15);
1077 } 1103 }
1078 catch (Exception e) 1104 catch (Exception e)
1079 { 1105 {
@@ -1081,51 +1107,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1081 } 1107 }
1082 } 1108 }
1083 1109
1084 private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2)
1085 {
1086 // Row
1087 for (int i = x1; i <= x2; i++)
1088 SendLayerData(i, y1, map);
1089
1090 // Column
1091 for (int j = y1 + 1; j <= y2; j++)
1092 SendLayerData(x2, j, map);
1093
1094 if (x2 - x1 > 0)
1095 SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
1096 }
1097
1098 void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2)
1099 {
1100 // Row in reverse
1101 for (int i = x2; i >= x1; i--)
1102 SendLayerData(i, y2, map);
1103
1104 // Column in reverse
1105 for (int j = y2 - 1; j >= y1; j--)
1106 SendLayerData(x1, j, map);
1107
1108 if (x2 - x1 > 0)
1109 SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
1110 }
1111
1112 /// <summary> 1110 /// <summary>
1113 /// Sends a set of four patches (x, x+1, ..., x+3) to the client 1111 /// Sends a set of four patches (x, x+1, ..., x+3) to the client
1114 /// </summary> 1112 /// </summary>
1115 /// <param name="map">heightmap</param> 1113 /// <param name="map">heightmap</param>
1116 /// <param name="px">X coordinate for patches 0..12</param> 1114 /// <param name="px">X coordinate for patches 0..12</param>
1117 /// <param name="py">Y coordinate for patches 0..15</param> 1115 /// <param name="py">Y coordinate for patches 0..15</param>
1118 // private void SendLayerPacket(float[] map, int y, int x) 1116 private void SendLayerPacket(int x, int y, float[] map)
1119 // { 1117 {
1120 // int[] patches = new int[4]; 1118 int[] patches = new int[4];
1121 // patches[0] = x + 0 + y * 16; 1119 patches[0] = x + 0 + y * 16;
1122 // patches[1] = x + 1 + y * 16; 1120 patches[1] = x + 1 + y * 16;
1123 // patches[2] = x + 2 + y * 16; 1121 patches[2] = x + 2 + y * 16;
1124 // patches[3] = x + 3 + y * 16; 1122 patches[3] = x + 3 + y * 16;
1125 1123
1126 // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches); 1124 float[] heightmap = (map.Length == 65536) ?
1127 // OutPacket(layerpack, ThrottleOutPacketType.Land); 1125 map :
1128 // } 1126 LLHeightFieldMoronize(map);
1127
1128 try
1129 {
1130 Packet layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
1131 OutPacket(layerpack, ThrottleOutPacketType.Land);
1132 }
1133 catch
1134 {
1135 for (int px = x ; px < x + 4 ; px++)
1136 SendLayerData(px, y, map);
1137 }
1138 }
1129 1139
1130 /// <summary> 1140 /// <summary>
1131 /// Sends a specified patch to a client 1141 /// Sends a specified patch to a client
@@ -1145,7 +1155,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1145 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches); 1155 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
1146 layerpack.Header.Reliable = true; 1156 layerpack.Header.Reliable = true;
1147 1157
1148 OutPacket(layerpack, ThrottleOutPacketType.Land); 1158 OutPacket(layerpack, ThrottleOutPacketType.Task);
1149 } 1159 }
1150 catch (Exception e) 1160 catch (Exception e)
1151 { 1161 {
@@ -1506,35 +1516,46 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1506 OutPacket(pc, ThrottleOutPacketType.Unknown); 1516 OutPacket(pc, ThrottleOutPacketType.Unknown);
1507 } 1517 }
1508 1518
1509 public void SendKillObject(ulong regionHandle, uint localID) 1519 public void SendKillObject(ulong regionHandle, List<uint> localIDs)
1510 { 1520 {
1511// m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle); 1521// m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, localID, regionHandle);
1512 1522
1513 KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject); 1523 KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
1514 // TODO: don't create new blocks if recycling an old packet 1524 // TODO: don't create new blocks if recycling an old packet
1515 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; 1525 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[localIDs.Count];
1516 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); 1526 for (int i = 0 ; i < localIDs.Count ; i++ )
1517 kill.ObjectData[0].ID = localID; 1527 {
1528 kill.ObjectData[i] = new KillObjectPacket.ObjectDataBlock();
1529 kill.ObjectData[i].ID = localIDs[i];
1530 }
1518 kill.Header.Reliable = true; 1531 kill.Header.Reliable = true;
1519 kill.Header.Zerocoded = true; 1532 kill.Header.Zerocoded = true;
1520 1533
1521 if (m_scene.GetScenePresence(localID) == null) 1534 if (localIDs.Count == 1)
1522 { 1535 {
1523 lock (m_entityUpdates.SyncRoot) 1536 if (m_scene.GetScenePresence(localIDs[0]) != null)
1524 { 1537 {
1525 m_killRecord.Add(localID); 1538 OutPacket(kill, ThrottleOutPacketType.State);
1526 1539 return;
1527 // The throttle queue used here must match that being used for updates. Otherwise, there is a
1528 // chance that a kill packet put on a separate queue will be sent to the client before an existing
1529 // update packet on another queue. Receiving updates after kills results in unowned and undeletable
1530 // scene objects in a viewer until that viewer is relogged in.
1531 OutPacket(kill, ThrottleOutPacketType.Task);
1532 } 1540 }
1541 m_killRecord.Add(localIDs[0]);
1533 } 1542 }
1534 else 1543 else
1535 { 1544 {
1536 OutPacket(kill, ThrottleOutPacketType.State); 1545 lock (m_entityUpdates.SyncRoot)
1546 {
1547 foreach (uint localID in localIDs)
1548 m_killRecord.Add(localID);
1549 }
1537 } 1550 }
1551
1552 // The throttle queue used here must match that being used for
1553 // updates. Otherwise, there is a chance that a kill packet put
1554 // on a separate queue will be sent to the client before an
1555 // existing update packet on another queue. Receiving updates
1556 // after kills results in unowned and undeletable
1557 // scene objects in a viewer until that viewer is relogged in.
1558 OutPacket(kill, ThrottleOutPacketType.Task);
1538 } 1559 }
1539 1560
1540 /// <summary> 1561 /// <summary>
@@ -2240,6 +2261,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2240 OutPacket(sound, ThrottleOutPacketType.Task); 2261 OutPacket(sound, ThrottleOutPacketType.Task);
2241 } 2262 }
2242 2263
2264 public void SendTransferAbort(TransferRequestPacket transferRequest)
2265 {
2266 TransferAbortPacket abort = (TransferAbortPacket)PacketPool.Instance.GetPacket(PacketType.TransferAbort);
2267 abort.TransferInfo.TransferID = transferRequest.TransferInfo.TransferID;
2268 abort.TransferInfo.ChannelType = transferRequest.TransferInfo.ChannelType;
2269 m_log.Debug("[Assets] Aborting transfer; asset request failed");
2270 OutPacket(abort, ThrottleOutPacketType.Task);
2271 }
2272
2243 public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain) 2273 public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
2244 { 2274 {
2245 SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger); 2275 SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
@@ -3532,6 +3562,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3532 /// </summary> 3562 /// </summary>
3533 public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) 3563 public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
3534 { 3564 {
3565 if (entity is SceneObjectPart)
3566 {
3567 SceneObjectPart e = (SceneObjectPart)entity;
3568 SceneObjectGroup g = e.ParentGroup;
3569 if (g.RootPart.Shape.State > 30) // HUD
3570 if (g.OwnerID != AgentId)
3571 return; // Don't send updates for other people's HUDs
3572 }
3573
3535 double priority = m_prioritizer.GetUpdatePriority(this, entity); 3574 double priority = m_prioritizer.GetUpdatePriority(this, entity);
3536 3575
3537 lock (m_entityUpdates.SyncRoot) 3576 lock (m_entityUpdates.SyncRoot)
@@ -3552,23 +3591,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3552 EntityUpdate update; 3591 EntityUpdate update;
3553 while (updatesThisCall < maxUpdates && m_entityUpdates.TryDequeue(out update)) 3592 while (updatesThisCall < maxUpdates && m_entityUpdates.TryDequeue(out update))
3554 { 3593 {
3555 // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client 3594 // If we have sent a kill packet for this object
3556 // will never receive an update after a prim kill. Even then, keeping the kill record may be a good 3595 // drop any updates on the floor
3557 // safety measure.
3558 //
3559 // Receiving updates after kills results in undeleteable prims that persist until relog and
3560 // currently occurs because prims can be deleted before all queued updates are sent.
3561 if (m_killRecord.Contains(update.Entity.LocalId))
3562 {
3563// m_log.WarnFormat(
3564// "[CLIENT]: Preventing full update for prim with local id {0} after client for user {1} told it was deleted",
3565// update.Entity.LocalId, Name);
3566 continue;
3567 }
3568
3569 if (update.Entity is SceneObjectPart) 3596 if (update.Entity is SceneObjectPart)
3570 { 3597 {
3571 SceneObjectPart part = (SceneObjectPart)update.Entity; 3598 SceneObjectPart part = (SceneObjectPart)update.Entity;
3599 if (m_killRecord.Contains(part.ParentGroup.RootPart.LocalId))
3600 continue;
3572 3601
3573 if (part.ParentGroup.IsAttachment && m_disableFacelights) 3602 if (part.ParentGroup.IsAttachment && m_disableFacelights)
3574 { 3603 {
@@ -4002,6 +4031,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4002 { 4031 {
4003 m_propertiesPacketTimer.Stop(); 4032 m_propertiesPacketTimer.Stop();
4004 4033
4034 if (m_propertiesBlocks.Count == 0)
4035 return;
4036
4005 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count]; 4037 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count];
4006 4038
4007 int index = 0; 4039 int index = 0;
@@ -4908,6 +4940,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4908 AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false); 4940 AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
4909 AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false); 4941 AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
4910 AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode); 4942 AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
4943 AddLocalPacketHandler(PacketType.CreateNewOutfitAttachments, HandleCreateNewOutfitAttachments);
4911 AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false); 4944 AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
4912 AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents); 4945 AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
4913 AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery); 4946 AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
@@ -5007,6 +5040,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5007 (x.CameraLeftAxis != lastarg.CameraLeftAxis) || 5040 (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
5008 (x.CameraUpAxis != lastarg.CameraUpAxis) || 5041 (x.CameraUpAxis != lastarg.CameraUpAxis) ||
5009 (x.ControlFlags != lastarg.ControlFlags) || 5042 (x.ControlFlags != lastarg.ControlFlags) ||
5043 (x.ControlFlags != 0) ||
5010 (x.Far != lastarg.Far) || 5044 (x.Far != lastarg.Far) ||
5011 (x.Flags != lastarg.Flags) || 5045 (x.Flags != lastarg.Flags) ||
5012 (x.State != lastarg.State) || 5046 (x.State != lastarg.State) ||
@@ -5380,7 +5414,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5380 args.Channel = ch; 5414 args.Channel = ch;
5381 args.From = String.Empty; 5415 args.From = String.Empty;
5382 args.Message = Utils.BytesToString(msg); 5416 args.Message = Utils.BytesToString(msg);
5383 args.Type = ChatTypeEnum.Shout; 5417 args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
5384 args.Position = new Vector3(); 5418 args.Position = new Vector3();
5385 args.Scene = Scene; 5419 args.Scene = Scene;
5386 args.Sender = this; 5420 args.Sender = this;
@@ -9418,6 +9452,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP
9418 { 9452 {
9419 return true; 9453 return true;
9420 } 9454 }
9455
9456 private bool HandleCreateNewOutfitAttachments(IClientAPI sender, Packet Pack)
9457 {
9458 CreateNewOutfitAttachmentsPacket packet = (CreateNewOutfitAttachmentsPacket)Pack;
9459
9460 #region Packet Session and User Check
9461 if (m_checkPackets)
9462 {
9463 if (packet.AgentData.SessionID != SessionId ||
9464 packet.AgentData.AgentID != AgentId)
9465 return true;
9466 }
9467 #endregion
9468 MoveItemsAndLeaveCopy handlerMoveItemsAndLeaveCopy = null;
9469 List<InventoryItemBase> items = new List<InventoryItemBase>();
9470 foreach (CreateNewOutfitAttachmentsPacket.ObjectDataBlock n in packet.ObjectData)
9471 {
9472 InventoryItemBase b = new InventoryItemBase();
9473 b.ID = n.OldItemID;
9474 b.Folder = n.OldFolderID;
9475 items.Add(b);
9476 }
9477
9478 handlerMoveItemsAndLeaveCopy = OnMoveItemsAndLeaveCopy;
9479 if (handlerMoveItemsAndLeaveCopy != null)
9480 {
9481 handlerMoveItemsAndLeaveCopy(this, items, packet.HeaderData.NewFolderID);
9482 }
9483
9484 return true;
9485 }
9421 9486
9422 private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack) 9487 private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
9423 { 9488 {
@@ -10915,7 +10980,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
10915 { 10980 {
10916 // It's a ghost! tell the client to delete it from view. 10981 // It's a ghost! tell the client to delete it from view.
10917 simClient.SendKillObject(Scene.RegionInfo.RegionHandle, 10982 simClient.SendKillObject(Scene.RegionInfo.RegionHandle,
10918 localId); 10983 new List<uint>() { localId });
10919 } 10984 }
10920 else 10985 else
10921 { 10986 {
@@ -11280,6 +11345,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11280 } 11345 }
11281 11346
11282 /// <summary> 11347 /// <summary>
11348 /// This processes packets which have accumulated while the presence was still in the process of initialising.
11349 /// </summary>
11350 public void ProcessPendingPackets()
11351 {
11352 m_IsPresenceReady = true;
11353 if (m_pendingPackets == null)
11354 return;
11355 foreach (Packet p in m_pendingPackets)
11356 {
11357 ProcessInPacket(p);
11358 }
11359 m_pendingPackets.Clear();
11360 }
11361
11362 /// <summary>
11283 /// Entryway from the client to the simulator. All UDP packets from the client will end up here 11363 /// Entryway from the client to the simulator. All UDP packets from the client will end up here
11284 /// </summary> 11364 /// </summary>
11285 /// <param name="Pack">OpenMetaverse.packet</param> 11365 /// <param name="Pack">OpenMetaverse.packet</param>
@@ -11542,7 +11622,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11542 11622
11543// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID); 11623// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID);
11544 11624
11625
11626 //Note, the bool returned from the below function is useless since it is always false.
11545 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); 11627 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
11628
11546 } 11629 }
11547 11630
11548 /// <summary> 11631 /// <summary>
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
index ca5a7bd..a4738ff 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPClient.cs
@@ -149,6 +149,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
149 149
150 private int m_defaultRTO = 3000; 150 private int m_defaultRTO = 3000;
151 private int m_maxRTO = 60000; 151 private int m_maxRTO = 60000;
152 public bool m_deliverPackets = true;
152 153
153 /// <summary> 154 /// <summary>
154 /// Default constructor 155 /// Default constructor
@@ -389,6 +390,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
389 if (category >= 0 && category < m_packetOutboxes.Length) 390 if (category >= 0 && category < m_packetOutboxes.Length)
390 { 391 {
391 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category]; 392 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue = m_packetOutboxes[category];
393
394 if (m_deliverPackets == false)
395 {
396 queue.Enqueue(packet);
397 return true;
398 }
399
392 TokenBucket bucket = m_throttleCategories[category]; 400 TokenBucket bucket = m_throttleCategories[category];
393 401
394 if (bucket.RemoveTokens(packet.Buffer.DataLength)) 402 if (bucket.RemoveTokens(packet.Buffer.DataLength))
@@ -425,6 +433,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
425 /// <returns>True if any packets were sent, otherwise false</returns> 433 /// <returns>True if any packets were sent, otherwise false</returns>
426 public bool DequeueOutgoing() 434 public bool DequeueOutgoing()
427 { 435 {
436 if (m_deliverPackets == false) return false;
437
428 OutgoingPacket packet; 438 OutgoingPacket packet;
429 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue; 439 OpenSim.Framework.LocklessQueue<OutgoingPacket> queue;
430 TokenBucket bucket; 440 TokenBucket bucket;
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index cb298fd..e2cda6d 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -912,7 +912,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP
912 client.DisableFacelights = m_disableFacelights; 912 client.DisableFacelights = m_disableFacelights;
913 913
914 // Start the IClientAPI 914 // Start the IClientAPI
915 client.Start(); 915 // Spin it off so that it doesn't clog up the LLUDPServer
916
917 //First, and very importantly:
918 //
919 //Set our DeliverPackets flag in the client to *false*
920 //this will prevent us from missing important messages
921 //before the modules are bound
922 client.DeliverPackets = false;
923 client.DisableFacelights = m_disableFacelights;
924
925 Util.FireAndForget(
926 delegate
927 {
928 try
929 {
930 client.Start();
931 }
932 finally
933 {
934 //Now, release the hounds. er, packets.
935 client.DeliverPackets = true;
936 }
937 }
938 );
916 } 939 }
917 else 940 else
918 { 941 {
@@ -928,7 +951,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
928 if (m_scene.TryGetClient(udpClient.AgentID, out client)) 951 if (m_scene.TryGetClient(udpClient.AgentID, out client))
929 { 952 {
930 client.IsLoggingOut = true; 953 client.IsLoggingOut = true;
931 client.Close(); 954 client.Close(false);
932 } 955 }
933 } 956 }
934 957
diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs
index bdbd284..91e3d20 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs
@@ -133,7 +133,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
133 this.parent = parent; 133 this.parent = parent;
134 MaxBurst = maxBurst; 134 MaxBurst = maxBurst;
135 DripRate = dripRate; 135 DripRate = dripRate;
136 lastDrip = Environment.TickCount & Int32.MaxValue; 136 lastDrip = Environment.TickCount;
137 } 137 }
138 138
139 /// <summary> 139 /// <summary>
@@ -144,40 +144,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP
144 /// the bucket, otherwise false</returns> 144 /// the bucket, otherwise false</returns>
145 public bool RemoveTokens(int amount) 145 public bool RemoveTokens(int amount)
146 { 146 {
147 bool dummy;
148 return RemoveTokens(amount, out dummy);
149 }
150
151 /// <summary>
152 /// Remove a given number of tokens from the bucket
153 /// </summary>
154 /// <param name="amount">Number of tokens to remove from the bucket</param>
155 /// <param name="dripSucceeded">True if tokens were added to the bucket
156 /// during this call, otherwise false</param>
157 /// <returns>True if the requested number of tokens were removed from
158 /// the bucket, otherwise false</returns>
159 public bool RemoveTokens(int amount, out bool dripSucceeded)
160 {
161 if (maxBurst == 0) 147 if (maxBurst == 0)
162 { 148 {
163 dripSucceeded = true;
164 return true; 149 return true;
165 } 150 }
166 151
167 dripSucceeded = Drip(); 152 if (amount > maxBurst)
168
169 if (content - amount >= 0)
170 { 153 {
171 if (parent != null && !parent.RemoveTokens(amount)) 154 throw new Exception("amount " + amount + " exceeds maxBurst " + maxBurst);
172 return false; 155 }
173 156
174 content -= amount; 157 Drip();
175 return true; 158
159 if (content < amount)
160 {
161 return false;
176 } 162 }
177 else 163
164 if (parent != null && !parent.RemoveTokens(amount))
178 { 165 {
179 return false; 166 return false;
180 } 167 }
168
169 content -= amount;
170 return true;
181 } 171 }
182 172
183 /// <summary> 173 /// <summary>
@@ -193,25 +183,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
193 content = maxBurst; 183 content = maxBurst;
194 return true; 184 return true;
195 } 185 }
196 else
197 {
198 int now = Environment.TickCount & Int32.MaxValue;
199 int deltaMS = now - lastDrip;
200 186
201 if (deltaMS <= 0) 187 int now = Environment.TickCount;
202 { 188 int deltaMS = now - lastDrip;
203 if (deltaMS < 0) 189 lastDrip = now;
204 lastDrip = now;
205 return false;
206 }
207 190
208 int dripAmount = deltaMS * tokensPerMS; 191 if (deltaMS <= 0)
209 192 {
210 content = Math.Min(content + dripAmount, maxBurst); 193 return false;
211 lastDrip = now; 194 }
212 195
213 return true; 196 long dripAmount = (long)deltaMS * (long)tokensPerMS + (long)content;
197 if (dripAmount > maxBurst)
198 {
199 dripAmount = maxBurst;
214 } 200 }
201 content = (int)dripAmount;
202 return true;
215 } 203 }
216 } 204 }
217} 205}