aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs1079
1 files changed, 664 insertions, 415 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 5ee1596..06f1301 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -84,6 +84,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
84 public event ModifyTerrain OnModifyTerrain; 84 public event ModifyTerrain OnModifyTerrain;
85 public event Action<IClientAPI> OnRegionHandShakeReply; 85 public event Action<IClientAPI> OnRegionHandShakeReply;
86 public event GenericCall1 OnRequestWearables; 86 public event GenericCall1 OnRequestWearables;
87 public event CachedTextureRequest OnCachedTextureRequest;
87 public event SetAppearance OnSetAppearance; 88 public event SetAppearance OnSetAppearance;
88 public event AvatarNowWearing OnAvatarNowWearing; 89 public event AvatarNowWearing OnAvatarNowWearing;
89 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; 90 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
@@ -95,6 +96,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
95 public event Action<IClientAPI, bool> OnCompleteMovementToRegion; 96 public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
96 public event UpdateAgent OnPreAgentUpdate; 97 public event UpdateAgent OnPreAgentUpdate;
97 public event UpdateAgent OnAgentUpdate; 98 public event UpdateAgent OnAgentUpdate;
99 public event UpdateAgent OnAgentCameraUpdate;
98 public event AgentRequestSit OnAgentRequestSit; 100 public event AgentRequestSit OnAgentRequestSit;
99 public event AgentSit OnAgentSit; 101 public event AgentSit OnAgentSit;
100 public event AvatarPickerRequest OnAvatarPickerRequest; 102 public event AvatarPickerRequest OnAvatarPickerRequest;
@@ -335,6 +337,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
335 private bool m_VelocityInterpolate = false; 337 private bool m_VelocityInterpolate = false;
336 private const uint MaxTransferBytesPerPacket = 600; 338 private const uint MaxTransferBytesPerPacket = 600;
337 339
340 private volatile bool m_justEditedTerrain = false;
338 341
339 /// <value> 342 /// <value>
340 /// List used in construction of data blocks for an object update packet. This is to stop us having to 343 /// List used in construction of data blocks for an object update packet. This is to stop us having to
@@ -355,7 +358,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
355// protected HashSet<uint> m_attachmentsSent; 358// protected HashSet<uint> m_attachmentsSent;
356 359
357 private bool m_deliverPackets = true; 360 private bool m_deliverPackets = true;
358 private int m_animationSequenceNumber = 1; 361
359 private bool m_SendLogoutPacketWhenClosing = true; 362 private bool m_SendLogoutPacketWhenClosing = true;
360 363
361 /// <summary> 364 /// <summary>
@@ -367,7 +370,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
367 /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods 370 /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods
368 /// cannot retain a reference to it outside of that method. 371 /// cannot retain a reference to it outside of that method.
369 /// </remarks> 372 /// </remarks>
370 private AgentUpdateArgs m_lastAgentUpdateArgs; 373 private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs();
371 374
372 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); 375 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
373 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers 376 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
@@ -416,6 +419,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
416 public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } } 419 public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } }
417 public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); } 420 public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
418 421
422 public int PingTimeMS
423 {
424 get
425 {
426 if (UDPClient != null)
427 return UDPClient.PingTimeMS;
428 return 0;
429 }
430 }
431
419 /// <summary> 432 /// <summary>
420 /// Entity update queues 433 /// Entity update queues
421 /// </summary> 434 /// </summary>
@@ -437,7 +450,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
437 public string Name { get { return FirstName + " " + LastName; } } 450 public string Name { get { return FirstName + " " + LastName; } }
438 451
439 public uint CircuitCode { get { return m_circuitCode; } } 452 public uint CircuitCode { get { return m_circuitCode; } }
440 public int NextAnimationSequenceNumber { get { return m_animationSequenceNumber++; } } 453 public int NextAnimationSequenceNumber
454 {
455 get { return m_udpServer.NextAnimationSequenceNumber; }
456 }
441 457
442 /// <summary> 458 /// <summary>
443 /// As well as it's function in IClientAPI, in LLClientView we are locking on this property in order to 459 /// As well as it's function in IClientAPI, in LLClientView we are locking on this property in order to
@@ -458,6 +474,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
458 set { m_disableFacelights = value; } 474 set { m_disableFacelights = value; }
459 } 475 }
460 476
477
461 public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } } 478 public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
462 479
463 480
@@ -504,6 +521,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
504 m_udpServer = udpServer; 521 m_udpServer = udpServer;
505 m_udpClient = udpClient; 522 m_udpClient = udpClient;
506 m_udpClient.OnQueueEmpty += HandleQueueEmpty; 523 m_udpClient.OnQueueEmpty += HandleQueueEmpty;
524 m_udpClient.HasUpdates += HandleHasUpdates;
507 m_udpClient.OnPacketStats += PopulateStats; 525 m_udpClient.OnPacketStats += PopulateStats;
508 526
509 m_prioritizer = new Prioritizer(m_scene); 527 m_prioritizer = new Prioritizer(m_scene);
@@ -533,7 +551,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
533 // We still perform a force close inside the sync lock since this is intended to attempt close where 551 // We still perform a force close inside the sync lock since this is intended to attempt close where
534 // there is some unidentified connection problem, not where we have issues due to deadlock 552 // there is some unidentified connection problem, not where we have issues due to deadlock
535 if (!IsActive && !force) 553 if (!IsActive && !force)
554 {
555 m_log.DebugFormat(
556 "[CLIENT]: Not attempting to close inactive client {0} in {1} since force flag is not set",
557 Name, m_scene.Name);
558
536 return; 559 return;
560 }
537 561
538 IsActive = false; 562 IsActive = false;
539 CloseWithoutChecks(sendStop); 563 CloseWithoutChecks(sendStop);
@@ -709,12 +733,22 @@ namespace OpenSim.Region.ClientStack.LindenUDP
709 //there is a local handler for this packet type 733 //there is a local handler for this packet type
710 if (pprocessor.Async) 734 if (pprocessor.Async)
711 { 735 {
736 ClientInfo cinfo = UDPClient.GetClientInfo();
737 if (!cinfo.AsyncRequests.ContainsKey(packet.Type.ToString()))
738 cinfo.AsyncRequests[packet.Type.ToString()] = 0;
739 cinfo.AsyncRequests[packet.Type.ToString()]++;
740
712 object obj = new AsyncPacketProcess(this, pprocessor.method, packet); 741 object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
713 Util.FireAndForget(ProcessSpecificPacketAsync, obj); 742 Util.FireAndForget(ProcessSpecificPacketAsync, obj);
714 result = true; 743 result = true;
715 } 744 }
716 else 745 else
717 { 746 {
747 ClientInfo cinfo = UDPClient.GetClientInfo();
748 if (!cinfo.SyncRequests.ContainsKey(packet.Type.ToString()))
749 cinfo.SyncRequests[packet.Type.ToString()] = 0;
750 cinfo.SyncRequests[packet.Type.ToString()]++;
751
718 result = pprocessor.method(this, packet); 752 result = pprocessor.method(this, packet);
719 } 753 }
720 } 754 }
@@ -729,6 +763,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
729 } 763 }
730 if (found) 764 if (found)
731 { 765 {
766 ClientInfo cinfo = UDPClient.GetClientInfo();
767 if (!cinfo.GenericRequests.ContainsKey(packet.Type.ToString()))
768 cinfo.GenericRequests[packet.Type.ToString()] = 0;
769 cinfo.GenericRequests[packet.Type.ToString()]++;
770
732 result = method(this, packet); 771 result = method(this, packet);
733 } 772 }
734 } 773 }
@@ -758,7 +797,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
758 797
759 public virtual void Start() 798 public virtual void Start()
760 { 799 {
761 m_scene.AddNewClient(this, PresenceType.User); 800 m_scene.AddNewAgent(this, PresenceType.User);
762 801
763 RefreshGroupMembership(); 802 RefreshGroupMembership();
764 } 803 }
@@ -820,14 +859,20 @@ namespace OpenSim.Region.ClientStack.LindenUDP
820 handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType); 859 handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
821 handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes; 860 handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
822 861
823 handshake.RegionInfo4 = new RegionHandshakePacket.RegionInfo4Block[0]; 862 handshake.RegionInfo4 = new RegionHandshakePacket.RegionInfo4Block[1];
824// OutPacket(handshake, ThrottleOutPacketType.Task); 863 handshake.RegionInfo4[0] = new RegionHandshakePacket.RegionInfo4Block();
825 // use same as MoveAgentIntoRegion (both should be task ) 864 handshake.RegionInfo4[0].RegionFlagsExtended = args.regionFlags;
865 handshake.RegionInfo4[0].RegionProtocols = 0; // 1 here would indicate that SSB is supported
866
826 OutPacket(handshake, ThrottleOutPacketType.Unknown); 867 OutPacket(handshake, ThrottleOutPacketType.Unknown);
827 } 868 }
828 869
870
829 public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) 871 public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
830 { 872 {
873 m_thisAgentUpdateArgs.CameraAtAxis.X = float.MinValue;
874 m_thisAgentUpdateArgs.ControlFlags = uint.MaxValue;
875
831 AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete); 876 AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
832 mov.SimData.ChannelVersion = m_channelVersion; 877 mov.SimData.ChannelVersion = m_channelVersion;
833 mov.AgentData.SessionID = m_sessionId; 878 mov.AgentData.SessionID = m_sessionId;
@@ -1210,9 +1255,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1210 LLHeightFieldMoronize(map); 1255 LLHeightFieldMoronize(map);
1211 1256
1212 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches); 1257 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
1213 layerpack.Header.Reliable = true; 1258
1259 // When a user edits the terrain, so much data is sent, the data queues up fast and presents a sub optimal editing experience.
1260 // To alleviate this issue, when the user edits the terrain, we start skipping the queues until they're done editing the terrain.
1261 // We also make them unreliable because it's extremely likely that multiple packets will be sent for a terrain patch area
1262 // invalidating previous packets for that area.
1214 1263
1215 OutPacket(layerpack, ThrottleOutPacketType.Task); 1264 // It's possible for an editing user to flood themselves with edited packets but the majority of use cases are such that only a
1265 // tiny percentage of users will be editing the terrain. Other, non-editing users will see the edits much slower.
1266
1267 // One last note on this topic, by the time users are going to be editing the terrain, it's extremely likely that the sim will
1268 // have rezzed already and therefore this is not likely going to cause any additional issues with lost packets, objects or terrain
1269 // patches.
1270
1271 // m_justEditedTerrain is volatile, so test once and duplicate two affected statements so we only have one cache miss.
1272 if (m_justEditedTerrain)
1273 {
1274 layerpack.Header.Reliable = false;
1275 OutPacket(layerpack,
1276 ThrottleOutPacketType.Unknown );
1277 }
1278 else
1279 {
1280 layerpack.Header.Reliable = true;
1281 OutPacket(layerpack,
1282 ThrottleOutPacketType.Task);
1283 }
1216 } 1284 }
1217 catch (Exception e) 1285 catch (Exception e)
1218 { 1286 {
@@ -1405,6 +1473,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1405 1473
1406 mapReply.AgentData.AgentID = AgentId; 1474 mapReply.AgentData.AgentID = AgentId;
1407 mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length]; 1475 mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
1476 mapReply.Size = new MapBlockReplyPacket.SizeBlock[mapBlocks2.Length];
1408 mapReply.AgentData.Flags = flag; 1477 mapReply.AgentData.Flags = flag;
1409 1478
1410 for (int i = 0; i < mapBlocks2.Length; i++) 1479 for (int i = 0; i < mapBlocks2.Length; i++)
@@ -1419,6 +1488,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1419 mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags; 1488 mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
1420 mapReply.Data[i].Access = mapBlocks2[i].Access; 1489 mapReply.Data[i].Access = mapBlocks2[i].Access;
1421 mapReply.Data[i].Agents = mapBlocks2[i].Agents; 1490 mapReply.Data[i].Agents = mapBlocks2[i].Agents;
1491
1492 // TODO: hookup varregion sim size here
1493 mapReply.Size[i] = new MapBlockReplyPacket.SizeBlock();
1494 mapReply.Size[i].SizeX = 256;
1495 mapReply.Size[i].SizeY = 256;
1422 } 1496 }
1423 OutPacket(mapReply, ThrottleOutPacketType.Land); 1497 OutPacket(mapReply, ThrottleOutPacketType.Land);
1424 } 1498 }
@@ -1578,9 +1652,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1578 pc.PingID.OldestUnacked = 0; 1652 pc.PingID.OldestUnacked = 0;
1579 1653
1580 OutPacket(pc, ThrottleOutPacketType.Unknown); 1654 OutPacket(pc, ThrottleOutPacketType.Unknown);
1655 UDPClient.m_lastStartpingTimeMS = Util.EnvironmentTickCount();
1581 } 1656 }
1582 1657
1583 public void SendKillObject(ulong regionHandle, List<uint> localIDs) 1658 public void SendKillObject(List<uint> localIDs)
1584 { 1659 {
1585// foreach (uint id in localIDs) 1660// foreach (uint id in localIDs)
1586// m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, id, regionHandle); 1661// m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, id, regionHandle);
@@ -2594,11 +2669,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2594 { 2669 {
2595 AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket(); 2670 AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
2596 avatarSitResponse.SitObject.ID = TargetID; 2671 avatarSitResponse.SitObject.ID = TargetID;
2597 if (CameraAtOffset != Vector3.Zero) 2672 avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
2598 { 2673 avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
2599 avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
2600 avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
2601 }
2602 avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook; 2674 avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook;
2603 avatarSitResponse.SitTransform.AutoPilot = autopilot; 2675 avatarSitResponse.SitTransform.AutoPilot = autopilot;
2604 avatarSitResponse.SitTransform.SitPosition = OffsetPos; 2676 avatarSitResponse.SitTransform.SitPosition = OffsetPos;
@@ -3630,6 +3702,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3630 avp.Sender.IsTrial = false; 3702 avp.Sender.IsTrial = false;
3631 avp.Sender.ID = agentID; 3703 avp.Sender.ID = agentID;
3632 avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0]; 3704 avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
3705
3706 // this need be use in future
3707 // avp.AppearanceData[0].AppearanceVersion = 0;
3708 // avp.AppearanceData[0].CofVersion = 0;
3709
3633 //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString()); 3710 //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
3634 OutPacket(avp, ThrottleOutPacketType.Task); 3711 OutPacket(avp, ThrottleOutPacketType.Task);
3635 } 3712 }
@@ -3751,8 +3828,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3751 { 3828 {
3752 SceneObjectPart e = (SceneObjectPart)entity; 3829 SceneObjectPart e = (SceneObjectPart)entity;
3753 SceneObjectGroup g = e.ParentGroup; 3830 SceneObjectGroup g = e.ParentGroup;
3754 if (g.RootPart.Shape.State > 30) // HUD 3831 if (g.HasPrivateAttachmentPoint && g.OwnerID != AgentId)
3755 if (g.OwnerID != AgentId)
3756 return; // Don't send updates for other people's HUDs 3832 return; // Don't send updates for other people's HUDs
3757 } 3833 }
3758 3834
@@ -3762,43 +3838,64 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3762 m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation)); 3838 m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation));
3763 } 3839 }
3764 3840
3765 /// <summary> 3841 /* dont use this
3766 /// Requeue an EntityUpdate when it was not acknowledged by the client. 3842 udp packet resent must be done at udp level only
3767 /// We will update the priority and put it in the correct queue, merging update flags 3843 re map from a packet to original updates just doesnt work
3768 /// with any other updates that may be queued for the same entity.
3769 /// The original update time is used for the merged update.
3770 /// </summary>
3771 private void ResendPrimUpdate(EntityUpdate update)
3772 {
3773 // If the update exists in priority queue, it will be updated.
3774 // If it does not exist then it will be added with the current (rather than its original) priority
3775 uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
3776 3844
3777 lock (m_entityUpdates.SyncRoot) 3845 /// <summary>
3778 m_entityUpdates.Enqueue(priority, update); 3846 /// Requeue an EntityUpdate when it was not acknowledged by the client.
3779 } 3847 /// We will update the priority and put it in the correct queue, merging update flags
3848 /// with any other updates that may be queued for the same entity.
3849 /// The original update time is used for the merged update.
3850 /// </summary>
3851 private void ResendPrimUpdate(EntityUpdate update)
3852 {
3853 // If the update exists in priority queue, it will be updated.
3854 // If it does not exist then it will be added with the current (rather than its original) priority
3855 uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
3780 3856
3781 /// <summary> 3857 lock (m_entityUpdates.SyncRoot)
3782 /// Requeue a list of EntityUpdates when they were not acknowledged by the client. 3858 m_entityUpdates.Enqueue(priority, update);
3783 /// We will update the priority and put it in the correct queue, merging update flags 3859 }
3784 /// with any other updates that may be queued for the same entity.
3785 /// The original update time is used for the merged update.
3786 /// </summary>
3787 private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
3788 {
3789 // m_log.WarnFormat("[CLIENT] resending prim updates {0}, packet sequence number {1}", updates[0].UpdateTime, oPacket.SequenceNumber);
3790 3860
3791 // Remove the update packet from the list of packets waiting for acknowledgement
3792 // because we are requeuing the list of updates. They will be resent in new packets
3793 // with the most recent state and priority.
3794 m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
3795 3861
3796 // Count this as a resent packet since we are going to requeue all of the updates contained in it 3862 /// <summary>
3797 Interlocked.Increment(ref m_udpClient.PacketsResent); 3863 /// Requeue a list of EntityUpdates when they were not acknowledged by the client.
3864 /// We will update the priority and put it in the correct queue, merging update flags
3865 /// with any other updates that may be queued for the same entity.
3866 /// The original update time is used for the merged update.
3867 /// </summary>
3868 private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
3869 {
3870 // m_log.WarnFormat("[CLIENT] resending prim updates {0}, packet sequence number {1}", updates[0].UpdateTime, oPacket.SequenceNumber);
3871
3872 // Remove the update packet from the list of packets waiting for acknowledgement
3873 // because we are requeuing the list of updates. They will be resent in new packets
3874 // with the most recent state and priority.
3875 m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
3876
3877 // Count this as a resent packet since we are going to requeue all of the updates contained in it
3878 Interlocked.Increment(ref m_udpClient.PacketsResent);
3879
3880 // We're not going to worry about interlock yet since its not currently critical that this total count
3881 // is 100% correct
3882 m_udpServer.PacketsResentCount++;
3883
3884 foreach (EntityUpdate update in updates)
3885 ResendPrimUpdate(update);
3886 }
3887 */
3888
3889// OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
3890// OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
3891// OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
3892// OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
3893//
3894// OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
3895// OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
3896// OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
3897// OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
3798 3898
3799 foreach (EntityUpdate update in updates)
3800 ResendPrimUpdate(update);
3801 }
3802 3899
3803 private void ProcessEntityUpdates(int maxUpdates) 3900 private void ProcessEntityUpdates(int maxUpdates)
3804 { 3901 {
@@ -3812,6 +3909,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3812 OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>(); 3909 OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
3813 OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>(); 3910 OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
3814 3911
3912// objectUpdateBlocks.Value.Clear();
3913// compressedUpdateBlocks.Value.Clear();
3914// terseUpdateBlocks.Value.Clear();
3915// terseAgentUpdateBlocks.Value.Clear();
3916// objectUpdates.Value.Clear();
3917// compressedUpdates.Value.Clear();
3918// terseUpdates.Value.Clear();
3919// terseAgentUpdates.Value.Clear();
3920
3815 // Check to see if this is a flush 3921 // Check to see if this is a flush
3816 if (maxUpdates <= 0) 3922 if (maxUpdates <= 0)
3817 { 3923 {
@@ -3846,8 +3952,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3846 3952
3847 if (part.ParentGroup.IsAttachment) 3953 if (part.ParentGroup.IsAttachment)
3848 { // Someone else's HUD, why are we getting these? 3954 { // Someone else's HUD, why are we getting these?
3849 if (part.ParentGroup.OwnerID != AgentId && 3955 if (part.ParentGroup.OwnerID != AgentId && part.ParentGroup.HasPrivateAttachmentPoint)
3850 part.ParentGroup.RootPart.Shape.State > 30)
3851 continue; 3956 continue;
3852 ScenePresence sp; 3957 ScenePresence sp;
3853 // Owner is not in the sim, don't update it to 3958 // Owner is not in the sim, don't update it to
@@ -4098,12 +4203,40 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4098 for (int i = 0; i < blocks.Count; i++) 4203 for (int i = 0; i < blocks.Count; i++)
4099 packet.ObjectData[i] = blocks[i]; 4204 packet.ObjectData[i] = blocks[i];
4100 4205
4101 OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); }); 4206// OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
4207 // use default udp retry
4208 OutPacket(packet, ThrottleOutPacketType.Task, true);
4102 } 4209 }
4103 4210
4211
4212
4104 #endregion Packet Sending 4213 #endregion Packet Sending
4214
4105 } 4215 }
4106 4216
4217 // hack.. dont use
4218 public void SendPartFullUpdate(ISceneEntity ent, uint? parentID)
4219 {
4220 if (ent is SceneObjectPart)
4221 {
4222 SceneObjectPart part = (SceneObjectPart)ent;
4223 ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
4224 packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
4225 packet.RegionData.TimeDilation = 1;
4226 packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
4227
4228 ObjectUpdatePacket.ObjectDataBlock blk = CreatePrimUpdateBlock(part, this.m_agentId);
4229 if (parentID.HasValue)
4230 {
4231 blk.ParentID = parentID.Value;
4232 }
4233
4234 packet.ObjectData[0] = blk;
4235
4236 OutPacket(packet, ThrottleOutPacketType.Task, true);
4237 }
4238 }
4239
4107 public void ReprioritizeUpdates() 4240 public void ReprioritizeUpdates()
4108 { 4241 {
4109 lock (m_entityUpdates.SyncRoot) 4242 lock (m_entityUpdates.SyncRoot)
@@ -4140,8 +4273,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4140 4273
4141 void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories) 4274 void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
4142 { 4275 {
4276// if (!m_udpServer.IsRunningOutbound)
4277// return;
4278
4143 if ((categories & ThrottleOutPacketTypeFlags.Task) != 0) 4279 if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
4144 { 4280 {
4281// if (!m_udpServer.IsRunningOutbound)
4282// return;
4283
4145 if (m_maxUpdates == 0 || m_LastQueueFill == 0) 4284 if (m_maxUpdates == 0 || m_LastQueueFill == 0)
4146 { 4285 {
4147 m_maxUpdates = m_udpServer.PrimUpdatesPerCallback; 4286 m_maxUpdates = m_udpServer.PrimUpdatesPerCallback;
@@ -4167,6 +4306,27 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4167 ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit); 4306 ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
4168 } 4307 }
4169 4308
4309 internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories)
4310 {
4311 bool hasUpdates = false;
4312
4313 if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
4314 {
4315 if (m_entityUpdates.Count > 0)
4316 hasUpdates = true;
4317 else if (m_entityProps.Count > 0)
4318 hasUpdates = true;
4319 }
4320
4321 if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
4322 {
4323 if (ImageManager.HasUpdates())
4324 hasUpdates = true;
4325 }
4326
4327 return hasUpdates;
4328 }
4329
4170 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) 4330 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
4171 { 4331 {
4172 AssetUploadCompletePacket newPack = new AssetUploadCompletePacket(); 4332 AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
@@ -4312,6 +4472,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4312 // Count this as a resent packet since we are going to requeue all of the updates contained in it 4472 // Count this as a resent packet since we are going to requeue all of the updates contained in it
4313 Interlocked.Increment(ref m_udpClient.PacketsResent); 4473 Interlocked.Increment(ref m_udpClient.PacketsResent);
4314 4474
4475 // We're not going to worry about interlock yet since its not currently critical that this total count
4476 // is 100% correct
4477 m_udpServer.PacketsResentCount++;
4478
4315 foreach (ObjectPropertyUpdate update in updates) 4479 foreach (ObjectPropertyUpdate update in updates)
4316 ResendPropertyUpdate(update); 4480 ResendPropertyUpdate(update);
4317 } 4481 }
@@ -4499,6 +4663,32 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4499 SceneObjectPart root = sop.ParentGroup.RootPart; 4663 SceneObjectPart root = sop.ParentGroup.RootPart;
4500 4664
4501 block.TouchName = Util.StringToBytes256(root.TouchName); 4665 block.TouchName = Util.StringToBytes256(root.TouchName);
4666
4667 // SL 3.3.4, at least, appears to read this information as a concatenated byte[] stream of UUIDs but
4668 // it's not yet clear whether this is actually used. If this is done in the future then a pre-cached
4669 // copy is really needed since it's less efficient to be constantly recreating this byte array.
4670// using (MemoryStream memStream = new MemoryStream())
4671// {
4672// using (BinaryWriter binWriter = new BinaryWriter(memStream))
4673// {
4674// for (int i = 0; i < sop.GetNumberOfSides(); i++)
4675// {
4676// Primitive.TextureEntryFace teFace = sop.Shape.Textures.FaceTextures[i];
4677//
4678// UUID textureID;
4679//
4680// if (teFace != null)
4681// textureID = teFace.TextureID;
4682// else
4683// textureID = sop.Shape.Textures.DefaultTexture.TextureID;
4684//
4685// binWriter.Write(textureID.GetBytes());
4686// }
4687//
4688// block.TextureID = memStream.ToArray();
4689// }
4690// }
4691
4502 block.TextureID = new byte[0]; // TextureID ??? 4692 block.TextureID = new byte[0]; // TextureID ???
4503 block.SitName = Util.StringToBytes256(root.SitName); 4693 block.SitName = Util.StringToBytes256(root.SitName);
4504 block.OwnerMask = root.OwnerMask; 4694 block.OwnerMask = root.OwnerMask;
@@ -4839,7 +5029,19 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4839 IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>(); 5029 IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
4840 if (eq != null) 5030 if (eq != null)
4841 { 5031 {
4842 eq.ParcelProperties(updateMessage, this.AgentId); 5032 OSD message_body = updateMessage.Serialize();
5033 // Add new fields here until OMV has them
5034 OSDMap bodyMap = (OSDMap)message_body;
5035 OSDArray parcelDataArray = (OSDArray)bodyMap["ParcelData"];
5036 OSDMap parcelData = (OSDMap)parcelDataArray[0];
5037 parcelData["SeeAVs"] = OSD.FromBoolean(landData.SeeAVs);
5038 parcelData["AnyAVSounds"] = OSD.FromBoolean(landData.AnyAVSounds);
5039 parcelData["GroupAVSounds"] = OSD.FromBoolean(landData.GroupAVSounds);
5040 OSDMap message = new OSDMap();
5041 message.Add("message", OSD.FromString("ParcelProperties"));
5042 message.Add("body", message_body);
5043 eq.Enqueue (message, this.AgentId);
5044 //eq.ParcelProperties(updateMessage, this.AgentId);
4843 } 5045 }
4844 else 5046 else
4845 { 5047 {
@@ -4877,7 +5079,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4877 5079
4878 public void SendForceClientSelectObjects(List<uint> ObjectIDs) 5080 public void SendForceClientSelectObjects(List<uint> ObjectIDs)
4879 { 5081 {
4880 m_log.WarnFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count); 5082// m_log.DebugFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count);
4881 5083
4882 bool firstCall = true; 5084 bool firstCall = true;
4883 const int MAX_OBJECTS_PER_PACKET = 251; 5085 const int MAX_OBJECTS_PER_PACKET = 251;
@@ -4997,33 +5199,18 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4997 5199
4998 position = presence.OffsetPosition; 5200 position = presence.OffsetPosition;
4999 rotation = presence.Rotation; 5201 rotation = presence.Rotation;
5000 5202 angularVelocity = presence.AngularVelocity;
5001 if (presence.ParentID != 0) 5203 rotation = presence.Rotation;
5002 {
5003 SceneObjectPart part = m_scene.GetSceneObjectPart(presence.ParentID);
5004 if (part != null && part != part.ParentGroup.RootPart)
5005 {
5006 position = part.OffsetPosition + presence.OffsetPosition * part.RotationOffset;
5007 rotation = part.RotationOffset * presence.Rotation;
5008 }
5009 angularVelocity = Vector3.Zero;
5010 }
5011 else
5012 {
5013 angularVelocity = presence.AngularVelocity;
5014 rotation = presence.Rotation;
5015 }
5016 5204
5017 attachPoint = 0; 5205 attachPoint = 0;
5206// m_log.DebugFormat(
5207// "[LLCLIENTVIEW]: Sending terse update to {0} with position {1} in {2}", Name, presence.OffsetPosition, m_scene.Name);
5208
5209 // attachPoint = presence.State; // Core: commented
5018 collisionPlane = presence.CollisionPlane; 5210 collisionPlane = presence.CollisionPlane;
5019 velocity = presence.Velocity; 5211 velocity = presence.Velocity;
5020 acceleration = Vector3.Zero; 5212 acceleration = Vector3.Zero;
5021 5213
5022 // Interestingly, sending this to non-zero will cause the client's avatar to start moving & accelerating
5023 // in that direction, even though we don't model this on the server. Implementing this in the future
5024 // may improve movement smoothness.
5025// acceleration = new Vector3(1, 0, 0);
5026
5027 if (sendTexture) 5214 if (sendTexture)
5028 textureEntry = presence.Appearance.Texture.GetBytes(); 5215 textureEntry = presence.Appearance.Texture.GetBytes();
5029 else 5216 else
@@ -5034,7 +5221,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5034 SceneObjectPart part = (SceneObjectPart)entity; 5221 SceneObjectPart part = (SceneObjectPart)entity;
5035 5222
5036 attachPoint = part.ParentGroup.AttachmentPoint; 5223 attachPoint = part.ParentGroup.AttachmentPoint;
5037 5224 attachPoint = ((attachPoint % 16) * 16 + (attachPoint / 16));
5038// m_log.DebugFormat( 5225// m_log.DebugFormat(
5039// "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}", 5226// "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
5040// attachPoint, part.Name, part.LocalId, Name); 5227// attachPoint, part.Name, part.LocalId, Name);
@@ -5062,7 +5249,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5062 pos += 4; 5249 pos += 4;
5063 5250
5064 // Avatar/CollisionPlane 5251 // Avatar/CollisionPlane
5065 data[pos++] = (byte)((attachPoint % 16) * 16 + (attachPoint / 16)); ; 5252 data[pos++] = (byte) attachPoint;
5066 if (avatar) 5253 if (avatar)
5067 { 5254 {
5068 data[pos++] = 1; 5255 data[pos++] = 1;
@@ -5132,30 +5319,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5132 Vector3 offsetPosition = data.OffsetPosition; 5319 Vector3 offsetPosition = data.OffsetPosition;
5133 Quaternion rotation = data.Rotation; 5320 Quaternion rotation = data.Rotation;
5134 uint parentID = data.ParentID; 5321 uint parentID = data.ParentID;
5135 5322
5136 if (parentID != 0) 5323// m_log.DebugFormat(
5137 { 5324// "[LLCLIENTVIEW]: Sending full update to {0} with position {1} in {2}", Name, data.OffsetPosition, m_scene.Name);
5138 SceneObjectPart part = m_scene.GetSceneObjectPart(parentID);
5139 if (part != null && part != part.ParentGroup.RootPart)
5140 {
5141 offsetPosition = part.OffsetPosition + data.OffsetPosition * part.RotationOffset;
5142 rotation = part.RotationOffset * data.Rotation;
5143 parentID = part.ParentGroup.RootPart.LocalId;
5144 }
5145 }
5146 5325
5147 byte[] objectData = new byte[76]; 5326 byte[] objectData = new byte[76];
5148 5327
5149 data.CollisionPlane.ToBytes(objectData, 0);
5150 offsetPosition.ToBytes(objectData, 16);
5151 Vector3 velocity = new Vector3(0, 0, 0); 5328 Vector3 velocity = new Vector3(0, 0, 0);
5152 Vector3 acceleration = new Vector3(0, 0, 0); 5329 Vector3 acceleration = new Vector3(0, 0, 0);
5330 rotation.Normalize();
5331 Vector3 vrot = new Vector3(rotation.X, rotation.Y, rotation.Z);
5332
5333 data.CollisionPlane.ToBytes(objectData, 0);
5334 offsetPosition.ToBytes(objectData, 16);
5153 velocity.ToBytes(objectData, 28); 5335 velocity.ToBytes(objectData, 28);
5154 acceleration.ToBytes(objectData, 40); 5336 acceleration.ToBytes(objectData, 40);
5155// data.Velocity.ToBytes(objectData, 28); 5337 vrot.ToBytes(objectData, 52);
5156// data.Acceleration.ToBytes(objectData, 40); 5338 data.AngularVelocity.ToBytes(objectData, 64);
5157 rotation.ToBytes(objectData, 52);
5158 //data.AngularVelocity.ToBytes(objectData, 64);
5159 5339
5160 ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock(); 5340 ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
5161 5341
@@ -5168,7 +5348,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5168 update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " + 5348 update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " +
5169 data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle); 5349 data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle);
5170 update.ObjectData = objectData; 5350 update.ObjectData = objectData;
5171 update.ParentID = parentID; 5351
5352 SceneObjectPart parentPart = data.ParentPart;
5353 if (parentPart != null)
5354 update.ParentID = parentPart.ParentGroup.LocalId;
5355 else
5356 update.ParentID = 0;
5357
5172 update.PathCurve = 16; 5358 update.PathCurve = 16;
5173 update.PathScaleX = 100; 5359 update.PathScaleX = 100;
5174 update.PathScaleY = 100; 5360 update.PathScaleY = 100;
@@ -5205,15 +5391,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5205 data.RelativePosition.ToBytes(objectData, 0); 5391 data.RelativePosition.ToBytes(objectData, 0);
5206 data.Velocity.ToBytes(objectData, 12); 5392 data.Velocity.ToBytes(objectData, 12);
5207 data.Acceleration.ToBytes(objectData, 24); 5393 data.Acceleration.ToBytes(objectData, 24);
5208 try 5394
5209 { 5395 Quaternion rotation = data.RotationOffset;
5210 data.RotationOffset.ToBytes(objectData, 36); 5396 rotation.Normalize();
5211 } 5397 Vector3 vrot = new Vector3(rotation.X, rotation.Y, rotation.Z);
5212 catch (Exception e) 5398 vrot.ToBytes(objectData, 36);
5213 {
5214 m_log.Warn("[LLClientView]: exception converting quaternion to bytes, using Quaternion.Identity. Exception: " + e.ToString());
5215 OpenMetaverse.Quaternion.Identity.ToBytes(objectData, 36);
5216 }
5217 data.AngularVelocity.ToBytes(objectData, 48); 5399 data.AngularVelocity.ToBytes(objectData, 48);
5218 5400
5219 ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock(); 5401 ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
@@ -5387,7 +5569,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5387 AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject); 5569 AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
5388 AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject); 5570 AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
5389 AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand); 5571 AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
5390 AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply); 5572 AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply, false);
5391 AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest); 5573 AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
5392 AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance); 5574 AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
5393 AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing); 5575 AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
@@ -5448,8 +5630,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5448 AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false); 5630 AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
5449 AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false); 5631 AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
5450 AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false); 5632 AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
5451 AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage); 5633 AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage, false);
5452 AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest); 5634 AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest, false);
5453 AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest); 5635 AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
5454 AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer); 5636 AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
5455 AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket); 5637 AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
@@ -5481,7 +5663,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5481 AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel); 5663 AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel);
5482 AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest); 5664 AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
5483 AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false); 5665 AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
5484 AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest); 5666 AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest, false);
5485 AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest); 5667 AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
5486 AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false); 5668 AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
5487 AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false); 5669 AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
@@ -5594,82 +5776,146 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5594 5776
5595 #region Packet Handlers 5777 #region Packet Handlers
5596 5778
5779 public int TotalAgentUpdates { get; set; }
5780
5597 #region Scene/Avatar 5781 #region Scene/Avatar
5598 5782
5599 private bool HandleAgentUpdate(IClientAPI sener, Packet packet) 5783 // Threshold for body rotation to be a significant agent update
5784 // use the abs of cos
5785 private const float QDELTABody = 1.0f - 0.0001f;
5786 private const float QDELTAHead = 1.0f - 0.0001f;
5787 // Threshold for camera rotation to be a significant agent update
5788 private const float VDELTA = 0.01f;
5789
5790 /// <summary>
5791 /// This checks the update significance against the last update made.
5792 /// </summary>
5793 /// <remarks>Can only be called by one thread at a time</remarks>
5794 /// <returns></returns>
5795 /// <param name='x'></param>
5796 public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
5600 { 5797 {
5601 if (OnAgentUpdate != null) 5798 return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x);
5799 }
5800
5801 /// <summary>
5802 /// This checks the movement/state update significance against the last update made.
5803 /// </summary>
5804 /// <remarks>Can only be called by one thread at a time</remarks>
5805 /// <returns></returns>
5806 /// <param name='x'></param>
5807 private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
5808 {
5809 float qdelta1 = Math.Abs(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation));
5810 //qdelta2 = Math.Abs(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation));
5811
5812 bool movementSignificant =
5813 (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
5814 || (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands
5815 || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
5816 || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
5817 || (qdelta1 < QDELTABody) // significant if body rotation above(below cos) threshold
5818 // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
5819 // || (qdelta2 < QDELTAHead) // significant if head rotation above(below cos) threshold
5820 || (x.Far != m_thisAgentUpdateArgs.Far) // significant if far distance changed
5821 ;
5822 //if (movementSignificant)
5823 //{
5824 //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}",
5825 // qdelta1, qdelta2);
5826 //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}",
5827 // x.ControlFlags, x.Flags, x.Far, x.State);
5828 //}
5829 return movementSignificant;
5830 }
5831
5832 /// <summary>
5833 /// This checks the camera update significance against the last update made.
5834 /// </summary>
5835 /// <remarks>Can only be called by one thread at a time</remarks>
5836 /// <returns></returns>
5837 /// <param name='x'></param>
5838 private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
5839 {
5840 float vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis);
5841 float vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter);
5842 float vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis);
5843 float vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
5844
5845 bool cameraSignificant =
5846 (vdelta1 > VDELTA) ||
5847 (vdelta2 > VDELTA) ||
5848 (vdelta3 > VDELTA) ||
5849 (vdelta4 > VDELTA)
5850 ;
5851
5852 //if (cameraSignificant)
5853 //{
5854 //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}",
5855 // x.CameraAtAxis, x.CameraCenter);
5856 //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}",
5857 // x.CameraLeftAxis, x.CameraUpAxis);
5858 //}
5859
5860 return cameraSignificant;
5861 }
5862
5863 private bool HandleAgentUpdate(IClientAPI sender, Packet packet)
5864 {
5865 // We got here, which means that something in agent update was significant
5866
5867 AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
5868 AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
5869
5870 if (x.AgentID != AgentId || x.SessionID != SessionId)
5602 { 5871 {
5603 AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; 5872 PacketPool.Instance.ReturnPacket(packet);
5873 return false;
5874 }
5604 5875
5605 #region Packet Session and User Check 5876 TotalAgentUpdates++;
5606 if (agentUpdate.AgentData.SessionID != SessionId || agentUpdate.AgentData.AgentID != AgentId)
5607 {
5608 PacketPool.Instance.ReturnPacket(packet);
5609 return false;
5610 }
5611 #endregion
5612 5877
5613 bool update = false; 5878 bool movement = CheckAgentMovementUpdateSignificance(x);
5614 AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; 5879 bool camera = CheckAgentCameraUpdateSignificance(x);
5615
5616 if (m_lastAgentUpdateArgs != null)
5617 {
5618 // These should be ordered from most-likely to
5619 // least likely to change. I've made an initial
5620 // guess at that.
5621 update =
5622 (
5623 (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) ||
5624 (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) ||
5625 (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) ||
5626 (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) ||
5627 (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) ||
5628 (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) ||
5629 (x.ControlFlags != 0) ||
5630 (x.Far != m_lastAgentUpdateArgs.Far) ||
5631 (x.Flags != m_lastAgentUpdateArgs.Flags) ||
5632 (x.State != m_lastAgentUpdateArgs.State) ||
5633 (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) ||
5634 (x.SessionID != m_lastAgentUpdateArgs.SessionID) ||
5635 (x.AgentID != m_lastAgentUpdateArgs.AgentID)
5636 );
5637 }
5638 else
5639 {
5640 m_lastAgentUpdateArgs = new AgentUpdateArgs();
5641 update = true;
5642 }
5643 5880
5644 if (update) 5881 // Was there a significant movement/state change?
5645 { 5882 if (movement)
5646// m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); 5883 {
5884 m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
5885 m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
5886 m_thisAgentUpdateArgs.Far = x.Far;
5887 m_thisAgentUpdateArgs.Flags = x.Flags;
5888 m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
5889// m_thisAgentUpdateArgs.SessionID = x.SessionID;
5890 m_thisAgentUpdateArgs.State = x.State;
5647 5891
5648 m_lastAgentUpdateArgs.AgentID = x.AgentID; 5892 UpdateAgent handlerAgentUpdate = OnAgentUpdate;
5649 m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation; 5893 UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
5650 m_lastAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
5651 m_lastAgentUpdateArgs.CameraCenter = x.CameraCenter;
5652 m_lastAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
5653 m_lastAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
5654 m_lastAgentUpdateArgs.ControlFlags = x.ControlFlags;
5655 m_lastAgentUpdateArgs.Far = x.Far;
5656 m_lastAgentUpdateArgs.Flags = x.Flags;
5657 m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation;
5658 m_lastAgentUpdateArgs.SessionID = x.SessionID;
5659 m_lastAgentUpdateArgs.State = x.State;
5660 5894
5661 UpdateAgent handlerAgentUpdate = OnAgentUpdate; 5895 if (handlerPreAgentUpdate != null)
5662 UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; 5896 OnPreAgentUpdate(this, m_thisAgentUpdateArgs);
5663 5897
5664 if (handlerPreAgentUpdate != null) 5898 if (handlerAgentUpdate != null)
5665 OnPreAgentUpdate(this, m_lastAgentUpdateArgs); 5899 OnAgentUpdate(this, m_thisAgentUpdateArgs);
5666 5900
5667 if (handlerAgentUpdate != null) 5901 handlerAgentUpdate = null;
5668 OnAgentUpdate(this, m_lastAgentUpdateArgs); 5902 handlerPreAgentUpdate = null;
5903 }
5669 5904
5670 handlerAgentUpdate = null; 5905 // Was there a significant camera(s) change?
5671 handlerPreAgentUpdate = null; 5906 if (camera)
5672 } 5907 {
5908 m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
5909 m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
5910 m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
5911 m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
5912
5913 UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
5914
5915 if (handlerAgentCameraUpdate != null)
5916 handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs);
5917
5918 handlerAgentCameraUpdate = null;
5673 } 5919 }
5674 5920
5675 PacketPool.Instance.ReturnPacket(packet); 5921 PacketPool.Instance.ReturnPacket(packet);
@@ -6260,6 +6506,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6260 //m_log.Info("[LAND]: LAND:" + modify.ToString()); 6506 //m_log.Info("[LAND]: LAND:" + modify.ToString());
6261 if (modify.ParcelData.Length > 0) 6507 if (modify.ParcelData.Length > 0)
6262 { 6508 {
6509 // Note: the ModifyTerrain event handler sends out updated packets before the end of this event. Therefore,
6510 // a simple boolean value should work and perhaps queue up just a few terrain patch packets at the end of the edit.
6511 m_justEditedTerrain = true; // Prevent terrain packet (Land layer) from being queued, make it unreliable
6263 if (OnModifyTerrain != null) 6512 if (OnModifyTerrain != null)
6264 { 6513 {
6265 for (int i = 0; i < modify.ParcelData.Length; i++) 6514 for (int i = 0; i < modify.ParcelData.Length; i++)
@@ -6275,6 +6524,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6275 } 6524 }
6276 } 6525 }
6277 } 6526 }
6527 m_justEditedTerrain = false; // Queue terrain packet (Land layer) if necessary, make it reliable again
6278 } 6528 }
6279 6529
6280 return true; 6530 return true;
@@ -6343,7 +6593,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6343 6593
6344 WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length]; 6594 WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length];
6345 for (int i=0; i<appear.WearableData.Length;i++) 6595 for (int i=0; i<appear.WearableData.Length;i++)
6346 cacheitems[i] = new WearableCacheItem(){CacheId = appear.WearableData[i].CacheID,TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)}; 6596 cacheitems[i] = new WearableCacheItem(){
6597 CacheId = appear.WearableData[i].CacheID,
6598 TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)
6599 };
6347 6600
6348 6601
6349 6602
@@ -6549,8 +6802,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6549 return true; 6802 return true;
6550 } 6803 }
6551 6804
6552 private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack) 6805 private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
6553 { 6806 {
6807 m_log.DebugFormat("[LLClientView] HandleCompleteAgentMovement");
6808
6554 Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion; 6809 Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
6555 if (handlerCompleteMovementToRegion != null) 6810 if (handlerCompleteMovementToRegion != null)
6556 { 6811 {
@@ -6636,6 +6891,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6636 } 6891 }
6637 #endregion 6892 #endregion
6638 6893
6894 if (SceneAgent.IsChildAgent)
6895 {
6896 SendCantSitBecauseChildAgentResponse();
6897 return true;
6898 }
6899
6639 AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit; 6900 AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
6640 6901
6641 if (handlerAgentRequestSit != null) 6902 if (handlerAgentRequestSit != null)
@@ -6660,6 +6921,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6660 } 6921 }
6661 #endregion 6922 #endregion
6662 6923
6924 if (SceneAgent.IsChildAgent)
6925 {
6926 SendCantSitBecauseChildAgentResponse();
6927 return true;
6928 }
6929
6663 AgentSit handlerAgentSit = OnAgentSit; 6930 AgentSit handlerAgentSit = OnAgentSit;
6664 if (handlerAgentSit != null) 6931 if (handlerAgentSit != null)
6665 { 6932 {
@@ -6669,6 +6936,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
6669 return true; 6936 return true;
6670 } 6937 }
6671 6938
6939 /// <summary>
6940 /// Used when a child agent gets a sit response which should not be fulfilled.
6941 /// </summary>
6942 private void SendCantSitBecauseChildAgentResponse()
6943 {
6944 SendAlertMessage("Try moving closer. Can't sit on object because it is not in the same region as you.");
6945 }
6946
6672 private bool HandleSoundTrigger(IClientAPI sender, Packet Pack) 6947 private bool HandleSoundTrigger(IClientAPI sender, Packet Pack)
6673 { 6948 {
6674 SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack; 6949 SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
@@ -7879,129 +8154,145 @@ namespace OpenSim.Region.ClientStack.LindenUDP
7879 //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); 8154 //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
7880 8155
7881 TransferRequestPacket transfer = (TransferRequestPacket)Pack; 8156 TransferRequestPacket transfer = (TransferRequestPacket)Pack;
7882 //m_log.Debug("Transfer Request: " + transfer.ToString());
7883 // Validate inventory transfers
7884 // Has to be done here, because AssetCache can't do it
7885 //
7886 UUID taskID = UUID.Zero; 8157 UUID taskID = UUID.Zero;
7887 if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem) 8158 if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
7888 { 8159 {
7889 taskID = new UUID(transfer.TransferInfo.Params, 48);
7890 UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
7891 UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
7892
7893// m_log.DebugFormat(
7894// "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
7895// requestID, itemID, taskID, Name);
7896
7897 if (!(((Scene)m_scene).Permissions.BypassPermissions())) 8160 if (!(((Scene)m_scene).Permissions.BypassPermissions()))
7898 { 8161 {
7899 if (taskID != UUID.Zero) // Prim 8162 // We're spawning a thread because the permissions check can block this thread
8163 Util.FireAndForget(delegate
7900 { 8164 {
7901 SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID); 8165 // This requests the asset if needed
8166 HandleSimInventoryTransferRequestWithPermsCheck(sender, transfer);
8167 });
8168 return true;
8169 }
8170 }
8171 else if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate)
8172 {
8173 //TransferRequestPacket does not include covenant uuid?
8174 //get scene covenant uuid
8175 taskID = m_scene.RegionInfo.RegionSettings.Covenant;
8176 }
7902 8177
7903 if (part == null) 8178 // This is non-blocking
7904 { 8179 MakeAssetRequest(transfer, taskID);
7905 m_log.WarnFormat(
7906 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
7907 Name, requestID, itemID, taskID);
7908 return true;
7909 }
7910 8180
7911 TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID); 8181 return true;
7912 if (tii == null) 8182 }
7913 {
7914 m_log.WarnFormat(
7915 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
7916 Name, requestID, itemID, taskID);
7917 return true;
7918 }
7919 8183
7920 if (tii.Type == (int)AssetType.LSLText) 8184 private void HandleSimInventoryTransferRequestWithPermsCheck(IClientAPI sender, TransferRequestPacket transfer)
7921 { 8185 {
7922 if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId)) 8186 UUID taskID = new UUID(transfer.TransferInfo.Params, 48);
7923 return true; 8187 UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
7924 } 8188 UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
7925 else if (tii.Type == (int)AssetType.Notecard)
7926 {
7927 if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
7928 return true;
7929 }
7930 else
7931 {
7932 // TODO: Change this code to allow items other than notecards and scripts to be successfully
7933 // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
7934 if (part.OwnerID != AgentId)
7935 {
7936 m_log.WarnFormat(
7937 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
7938 Name, requestID, itemID, taskID, part.OwnerID);
7939 return true;
7940 }
7941 8189
7942 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0) 8190 //m_log.DebugFormat(
7943 { 8191 // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
7944 m_log.WarnFormat( 8192 // requestID, itemID, taskID, Name);
7945 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
7946 Name, requestID, itemID, taskID);
7947 return true;
7948 }
7949 8193
7950 if (tii.OwnerID != AgentId) 8194 //m_log.Debug("Transfer Request: " + transfer.ToString());
7951 { 8195 // Validate inventory transfers
7952 m_log.WarnFormat( 8196 // Has to be done here, because AssetCache can't do it
7953 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}", 8197 //
7954 Name, requestID, itemID, taskID, tii.OwnerID); 8198 if (taskID != UUID.Zero) // Prim
7955 return true; 8199 {
7956 } 8200 SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
7957 8201
7958 if (( 8202 if (part == null)
7959 tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) 8203 {
7960 != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer)) 8204 m_log.WarnFormat(
7961 { 8205 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
7962 m_log.WarnFormat( 8206 Name, requestID, itemID, taskID);
7963 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer", 8207 return;
7964 Name, requestID, itemID, taskID); 8208 }
7965 return true;
7966 }
7967 8209
7968 if (tii.AssetID != requestID) 8210 TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
7969 { 8211 if (tii == null)
7970 m_log.WarnFormat( 8212 {
7971 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}", 8213 m_log.WarnFormat(
7972 Name, requestID, itemID, taskID, tii.AssetID); 8214 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
7973 return true; 8215 Name, requestID, itemID, taskID);
7974 } 8216 return;
7975 } 8217 }
8218
8219 if (tii.Type == (int)AssetType.LSLText)
8220 {
8221 if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
8222 return;
8223 }
8224 else if (tii.Type == (int)AssetType.Notecard)
8225 {
8226 if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
8227 return;
8228 }
8229 else
8230 {
8231 // TODO: Change this code to allow items other than notecards and scripts to be successfully
8232 // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
8233 if (part.OwnerID != AgentId)
8234 {
8235 m_log.WarnFormat(
8236 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
8237 Name, requestID, itemID, taskID, part.OwnerID);
8238 return;
7976 } 8239 }
7977 else // Agent 8240
8241 if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
7978 { 8242 {
7979 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>(); 8243 m_log.WarnFormat(
7980 if (invAccess != null) 8244 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
7981 { 8245 Name, requestID, itemID, taskID);
7982 if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID)) 8246 return;
7983 return false; 8247 }
7984 } 8248
7985 else 8249 if (tii.OwnerID != AgentId)
7986 { 8250 {
7987 return false; 8251 m_log.WarnFormat(
7988 } 8252 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
8253 Name, requestID, itemID, taskID, tii.OwnerID);
8254 return;
8255 }
8256
8257 if ((
8258 tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
8259 != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
8260 {
8261 m_log.WarnFormat(
8262 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
8263 Name, requestID, itemID, taskID);
8264 return;
8265 }
8266
8267 if (tii.AssetID != requestID)
8268 {
8269 m_log.WarnFormat(
8270 "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
8271 Name, requestID, itemID, taskID, tii.AssetID);
8272 return;
7989 } 8273 }
7990 } 8274 }
7991 } 8275 }
7992 else 8276 else // Agent
7993 if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate) 8277 {
8278 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
8279 if (invAccess != null)
7994 { 8280 {
7995 //TransferRequestPacket does not include covenant uuid? 8281 if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
7996 //get scene covenant uuid 8282 return;
7997 taskID = m_scene.RegionInfo.RegionSettings.Covenant;
7998 } 8283 }
8284 else
8285 {
8286 return;
8287 }
8288 }
7999 8289
8290 // Permissions out of the way, let's request the asset
8000 MakeAssetRequest(transfer, taskID); 8291 MakeAssetRequest(transfer, taskID);
8001 8292
8002 return true;
8003 } 8293 }
8004 8294
8295
8005 private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack) 8296 private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
8006 { 8297 {
8007 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; 8298 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
@@ -11732,8 +12023,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11732 } 12023 }
11733 12024
11734 /// <summary> 12025 /// <summary>
11735 /// Send a response back to a client when it asks the asset server (via the region server) if it has
11736 /// its appearance texture cached.
11737 /// </summary> 12026 /// </summary>
11738 /// <remarks> 12027 /// <remarks>
11739 /// At the moment, we always reply that there is no cached texture. 12028 /// At the moment, we always reply that there is no cached texture.
@@ -11741,6 +12030,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11741 /// <param name="simclient"></param> 12030 /// <param name="simclient"></param>
11742 /// <param name="packet"></param> 12031 /// <param name="packet"></param>
11743 /// <returns></returns> 12032 /// <returns></returns>
12033 // TODO: Convert old handler to use new method
12034 /*protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
12035 {
12036 AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
12037
12038 if (cachedtex.AgentData.SessionID != SessionId)
12039 return false;
12040
12041
12042 List<CachedTextureRequestArg> requestArgs = new List<CachedTextureRequestArg>();
12043
12044 for (int i = 0; i < cachedtex.WearableData.Length; i++)
12045 {
12046 CachedTextureRequestArg arg = new CachedTextureRequestArg();
12047 arg.BakedTextureIndex = cachedtex.WearableData[i].TextureIndex;
12048 arg.WearableHashID = cachedtex.WearableData[i].ID;
12049
12050 requestArgs.Add(arg);
12051 }
12052
12053 CachedTextureRequest handlerCachedTextureRequest = OnCachedTextureRequest;
12054 if (handlerCachedTextureRequest != null)
12055 {
12056 handlerCachedTextureRequest(simclient,cachedtex.AgentData.SerialNum,requestArgs);
12057 }
12058
12059 return true;
12060 }*/
12061
11744 protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet) 12062 protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
11745 { 12063 {
11746 //m_log.Debug("texture cached: " + packet.ToString()); 12064 //m_log.Debug("texture cached: " + packet.ToString());
@@ -11749,156 +12067,105 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11749 12067
11750 if (cachedtex.AgentData.SessionID != SessionId) 12068 if (cachedtex.AgentData.SessionID != SessionId)
11751 return false; 12069 return false;
11752
11753 12070
11754 // TODO: don't create new blocks if recycling an old packet 12071 // TODO: don't create new blocks if recycling an old packet
11755 cachedresp.AgentData.AgentID = AgentId; 12072 cachedresp.AgentData.AgentID = AgentId;
11756 cachedresp.AgentData.SessionID = m_sessionId; 12073 cachedresp.AgentData.SessionID = m_sessionId;
11757 cachedresp.AgentData.SerialNum = m_cachedTextureSerial; 12074 cachedresp.AgentData.SerialNum = cachedtex.AgentData.SerialNum;
11758 m_cachedTextureSerial++;
11759 cachedresp.WearableData = 12075 cachedresp.WearableData =
11760 new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length]; 12076 new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
11761 12077
11762 //IAvatarFactoryModule fac = m_scene.RequestModuleInterface<IAvatarFactoryModule>();
11763 // var item = fac.GetBakedTextureFaces(AgentId);
11764 //WearableCacheItem[] items = fac.GetCachedItems(AgentId);
11765
11766 IAssetService cache = m_scene.AssetService;
11767 IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
11768 //bakedTextureModule = null;
11769 int maxWearablesLoop = cachedtex.WearableData.Length; 12078 int maxWearablesLoop = cachedtex.WearableData.Length;
11770 if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES) 12079 if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES)
11771 maxWearablesLoop = AvatarWearable.MAX_WEARABLES; 12080 maxWearablesLoop = AvatarWearable.MAX_WEARABLES;
11772 12081
11773 if (bakedTextureModule != null && cache != null) 12082 int cacheHits = 0;
11774 {
11775 // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid
11776 12083
11777 WearableCacheItem[] cacheItems = null; 12084 // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid
11778 ScenePresence p = m_scene.GetScenePresence(AgentId);
11779 if (p.Appearance != null)
11780 if (p.Appearance.WearableCacheItems == null || p.Appearance.WearableCacheItemsDirty)
11781 {
11782 try
11783 {
11784 cacheItems = bakedTextureModule.Get(AgentId);
11785 p.Appearance.WearableCacheItems = cacheItems;
11786 p.Appearance.WearableCacheItemsDirty = false;
11787 }
11788 12085
11789 /* 12086 WearableCacheItem[] cacheItems = null;
11790 * The following Catch types DO NOT WORK, it jumps to the General Packet Exception Handler if you don't catch Exception!
11791 *
11792 catch (System.Net.Sockets.SocketException)
11793 {
11794 cacheItems = null;
11795 }
11796 catch (WebException)
11797 {
11798 cacheItems = null;
11799 }
11800 catch (InvalidOperationException)
11801 {
11802 cacheItems = null;
11803 } */
11804 catch (Exception)
11805 {
11806 cacheItems = null;
11807 }
11808
11809 }
11810 else if (p.Appearance.WearableCacheItems != null)
11811 {
11812 cacheItems = p.Appearance.WearableCacheItems;
11813 }
11814 12087
11815 if (cache != null && cacheItems != null) 12088 ScenePresence p = m_scene.GetScenePresence(AgentId);
11816 {
11817 foreach (WearableCacheItem item in cacheItems)
11818 {
11819
11820 if (cache.GetCached(item.TextureID.ToString()) == null)
11821 {
11822 item.TextureAsset.Temporary = true;
11823 cache.Store(item.TextureAsset);
11824 }
11825 12089
12090 if (p != null && p.Appearance != null)
12091 {
12092 cacheItems = p.Appearance.WearableCacheItems;
12093 }
11826 12094
11827 } 12095 if (cacheItems != null)
11828 } 12096 {
11829 12097 for (int i = 0; i < maxWearablesLoop; i++)
11830 if (cacheItems != null)
11831 { 12098 {
11832 12099 int idx = cachedtex.WearableData[i].TextureIndex;
11833 for (int i = 0; i < maxWearablesLoop; i++)
11834 {
11835 WearableCacheItem item =
11836 WearableCacheItem.SearchTextureIndex(cachedtex.WearableData[i].TextureIndex,cacheItems);
11837 12100
11838 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 12101 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11839 cachedresp.WearableData[i].TextureIndex= cachedtex.WearableData[i].TextureIndex; 12102 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
11840 cachedresp.WearableData[i].HostName = new byte[0]; 12103 cachedresp.WearableData[i].HostName = new byte[0];
11841 if (item != null && cachedtex.WearableData[i].ID == item.CacheId) 12104 if (cachedtex.WearableData[i].ID == cacheItems[idx].CacheId)
11842 { 12105 {
11843 12106 cachedresp.WearableData[i].TextureID = cacheItems[idx].TextureID;
11844 cachedresp.WearableData[i].TextureID = item.TextureID; 12107 cacheHits++;
11845 }
11846 else
11847 {
11848 cachedresp.WearableData[i].TextureID = UUID.Zero;
11849 }
11850 } 12108 }
11851 } 12109 else
11852 else
11853 {
11854 for (int i = 0; i < maxWearablesLoop; i++)
11855 { 12110 {
11856 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11857 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
11858 cachedresp.WearableData[i].TextureID = UUID.Zero; 12111 cachedresp.WearableData[i].TextureID = UUID.Zero;
11859 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11860 cachedresp.WearableData[i].HostName = new byte[0];
11861 } 12112 }
11862 } 12113 }
11863 } 12114 }
11864 else 12115 else
11865 { 12116 {
11866 if (cache == null) 12117 for (int i = 0; i < maxWearablesLoop; i++)
11867 { 12118 {
11868 for (int i = 0; i < maxWearablesLoop; i++) 12119 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11869 { 12120 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
11870 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 12121 cachedresp.WearableData[i].TextureID = UUID.Zero;
11871 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; 12122 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11872 cachedresp.WearableData[i].TextureID = UUID.Zero; 12123 cachedresp.WearableData[i].HostName = new byte[0];
11873 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11874 cachedresp.WearableData[i].HostName = new byte[0];
11875 }
11876 } 12124 }
11877 else 12125 }
11878 {
11879 for (int i = 0; i < maxWearablesLoop; i++)
11880 {
11881 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
11882 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
11883
11884 12126
12127 m_log.DebugFormat("texture cached: hits {0}", cacheHits);
11885 12128
11886 if (cache.GetCached(cachedresp.WearableData[i].TextureID.ToString()) == null)
11887 cachedresp.WearableData[i].TextureID = UUID.Zero;
11888 //UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11889 else
11890 cachedresp.WearableData[i].TextureID = UUID.Zero;
11891 // UUID.Parse("8334fb6e-c2f5-46ee-807d-a435f61a8d46");
11892 cachedresp.WearableData[i].HostName = new byte[0];
11893 }
11894 }
11895 }
11896 cachedresp.Header.Zerocoded = true; 12129 cachedresp.Header.Zerocoded = true;
11897 OutPacket(cachedresp, ThrottleOutPacketType.Task); 12130 OutPacket(cachedresp, ThrottleOutPacketType.Task);
11898 12131
11899 return true; 12132 return true;
11900 } 12133 }
11901 12134
12135 /// <summary>
12136 /// Send a response back to a client when it asks the asset server (via the region server) if it has
12137 /// its appearance texture cached.
12138 /// </summary>
12139 /// <param name="avatar"></param>
12140 /// <param name="serial"></param>
12141 /// <param name="cachedTextures"></param>
12142 /// <returns></returns>
12143 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
12144 {
12145 ScenePresence presence = avatar as ScenePresence;
12146 if (presence == null)
12147 return;
12148
12149 AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
12150
12151 // TODO: don't create new blocks if recycling an old packet
12152 cachedresp.AgentData.AgentID = m_agentId;
12153 cachedresp.AgentData.SessionID = m_sessionId;
12154 cachedresp.AgentData.SerialNum = serial;
12155 cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedTextures.Count];
12156
12157 for (int i = 0; i < cachedTextures.Count; i++)
12158 {
12159 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
12160 cachedresp.WearableData[i].TextureIndex = (byte)cachedTextures[i].BakedTextureIndex;
12161 cachedresp.WearableData[i].TextureID = cachedTextures[i].BakedTextureID;
12162 cachedresp.WearableData[i].HostName = new byte[0];
12163 }
12164
12165 cachedresp.Header.Zerocoded = true;
12166 OutPacket(cachedresp, ThrottleOutPacketType.Task);
12167 }
12168
11902 protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet) 12169 protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
11903 { 12170 {
11904 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; 12171 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
@@ -11924,8 +12191,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11924 if (part == null) 12191 if (part == null)
11925 { 12192 {
11926 // It's a ghost! tell the client to delete it from view. 12193 // It's a ghost! tell the client to delete it from view.
11927 simClient.SendKillObject(Scene.RegionInfo.RegionHandle, 12194 simClient.SendKillObject(new List<uint> { localId });
11928 new List<uint> { localId });
11929 } 12195 }
11930 else 12196 else
11931 { 12197 {
@@ -12299,6 +12565,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12299 12565
12300 shape.PCode = addPacket.ObjectData.PCode; 12566 shape.PCode = addPacket.ObjectData.PCode;
12301 shape.State = addPacket.ObjectData.State; 12567 shape.State = addPacket.ObjectData.State;
12568 shape.LastAttachPoint = addPacket.ObjectData.State;
12302 shape.PathBegin = addPacket.ObjectData.PathBegin; 12569 shape.PathBegin = addPacket.ObjectData.PathBegin;
12303 shape.PathEnd = addPacket.ObjectData.PathEnd; 12570 shape.PathEnd = addPacket.ObjectData.PathEnd;
12304 shape.PathScaleX = addPacket.ObjectData.PathScaleX; 12571 shape.PathScaleX = addPacket.ObjectData.PathScaleX;
@@ -12329,7 +12596,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12329 ClientInfo info = m_udpClient.GetClientInfo(); 12596 ClientInfo info = m_udpClient.GetClientInfo();
12330 12597
12331 info.proxyEP = null; 12598 info.proxyEP = null;
12332 info.agentcircuit = RequestClientInfo(); 12599 if (info.agentcircuit == null)
12600 info.agentcircuit = RequestClientInfo();
12333 12601
12334 return info; 12602 return info;
12335 } 12603 }
@@ -12712,11 +12980,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12712 OutPacket(dialog, ThrottleOutPacketType.Task); 12980 OutPacket(dialog, ThrottleOutPacketType.Task);
12713 } 12981 }
12714 12982
12715 public void StopFlying(ISceneEntity p) 12983 public void SendAgentTerseUpdate(ISceneEntity p)
12716 { 12984 {
12717 if (p is ScenePresence) 12985 if (p is ScenePresence)
12718 { 12986 {
12719 ScenePresence presence = p as ScenePresence; 12987// m_log.DebugFormat(
12988// "[LLCLIENTVIEW]: Immediately sending terse agent update for {0} to {1} in {2}",
12989// p.Name, Name, Scene.Name);
12990
12720 // It turns out to get the agent to stop flying, you have to feed it stop flying velocities 12991 // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
12721 // There's no explicit message to send the client to tell it to stop flying.. it relies on the 12992 // There's no explicit message to send the client to tell it to stop flying.. it relies on the
12722 // velocity, collision plane and avatar height 12993 // velocity, collision plane and avatar height
@@ -12724,34 +12995,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
12724 // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air 12995 // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
12725 // when the avatar stands up 12996 // when the avatar stands up
12726 12997
12727 Vector3 pos = presence.AbsolutePosition;
12728
12729 if (presence.Appearance.AvatarHeight != 127.0f)
12730 pos += new Vector3(0f, 0f, (presence.Appearance.AvatarHeight/6f));
12731 else
12732 pos += new Vector3(0f, 0f, (1.56f/6f));
12733
12734 presence.AbsolutePosition = pos;
12735
12736 // attach a suitable collision plane regardless of the actual situation to force the LLClient to land.
12737 // Collision plane below the avatar's position a 6th of the avatar's height is suitable.
12738 // Mind you, that this method doesn't get called if the avatar's velocity magnitude is greater then a
12739 // certain amount.. because the LLClient wouldn't land in that situation anyway.
12740
12741 // why are we still testing for this really old height value default???
12742 if (presence.Appearance.AvatarHeight != 127.0f)
12743 presence.CollisionPlane = new Vector4(0, 0, 0, pos.Z - presence.Appearance.AvatarHeight/6f);
12744 else
12745 presence.CollisionPlane = new Vector4(0, 0, 0, pos.Z - (1.56f/6f));
12746
12747
12748 ImprovedTerseObjectUpdatePacket.ObjectDataBlock block = 12998 ImprovedTerseObjectUpdatePacket.ObjectDataBlock block =
12749 CreateImprovedTerseBlock(p, false); 12999 CreateImprovedTerseBlock(p, false);
12750 13000
12751 const float TIME_DILATION = 1.0f; 13001 const float TIME_DILATION = 1.0f;
12752 ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f); 13002 ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f);
12753 13003
12754
12755 ImprovedTerseObjectUpdatePacket packet 13004 ImprovedTerseObjectUpdatePacket packet
12756 = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket( 13005 = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
12757 PacketType.ImprovedTerseObjectUpdate); 13006 PacketType.ImprovedTerseObjectUpdate);