aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs210
1 files changed, 141 insertions, 69 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index f35691a..0e17496 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 {
@@ -2231,6 +2241,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2231 OutPacket(sound, ThrottleOutPacketType.Task); 2241 OutPacket(sound, ThrottleOutPacketType.Task);
2232 } 2242 }
2233 2243
2244 public void SendTransferAbort(TransferRequestPacket transferRequest)
2245 {
2246 TransferAbortPacket abort = (TransferAbortPacket)PacketPool.Instance.GetPacket(PacketType.TransferAbort);
2247 abort.TransferInfo.TransferID = transferRequest.TransferInfo.TransferID;
2248 abort.TransferInfo.ChannelType = transferRequest.TransferInfo.ChannelType;
2249 m_log.Debug("[Assets] Aborting transfer; asset request failed");
2250 OutPacket(abort, ThrottleOutPacketType.Task);
2251 }
2252
2234 public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain) 2253 public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
2235 { 2254 {
2236 SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger); 2255 SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
@@ -3523,6 +3542,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3523 /// </summary> 3542 /// </summary>
3524 public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) 3543 public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
3525 { 3544 {
3545 if (entity is SceneObjectPart)
3546 {
3547 SceneObjectPart e = (SceneObjectPart)entity;
3548 SceneObjectGroup g = e.ParentGroup;
3549 if (g.RootPart.Shape.State > 30) // HUD
3550 if (g.OwnerID != AgentId)
3551 return; // Don't send updates for other people's HUDs
3552 }
3553
3526 double priority = m_prioritizer.GetUpdatePriority(this, entity); 3554 double priority = m_prioritizer.GetUpdatePriority(this, entity);
3527 3555
3528 lock (m_entityUpdates.SyncRoot) 3556 lock (m_entityUpdates.SyncRoot)
@@ -3543,23 +3571,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3543 EntityUpdate update; 3571 EntityUpdate update;
3544 while (updatesThisCall < maxUpdates && m_entityUpdates.TryDequeue(out update)) 3572 while (updatesThisCall < maxUpdates && m_entityUpdates.TryDequeue(out update))
3545 { 3573 {
3546 // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client 3574 // If we have sent a kill packet for this object
3547 // will never receive an update after a prim kill. Even then, keeping the kill record may be a good 3575 // drop any updates on the floor
3548 // safety measure.
3549 //
3550 // Receiving updates after kills results in undeleteable prims that persist until relog and
3551 // currently occurs because prims can be deleted before all queued updates are sent.
3552 if (m_killRecord.Contains(update.Entity.LocalId))
3553 {
3554// m_log.WarnFormat(
3555// "[CLIENT]: Preventing full update for prim with local id {0} after client for user {1} told it was deleted",
3556// update.Entity.LocalId, Name);
3557 continue;
3558 }
3559
3560 if (update.Entity is SceneObjectPart) 3576 if (update.Entity is SceneObjectPart)
3561 { 3577 {
3562 SceneObjectPart part = (SceneObjectPart)update.Entity; 3578 SceneObjectPart part = (SceneObjectPart)update.Entity;
3579 if (m_killRecord.Contains(part.ParentGroup.RootPart.LocalId))
3580 continue;
3563 3581
3564 if (part.ParentGroup.IsAttachment && m_disableFacelights) 3582 if (part.ParentGroup.IsAttachment && m_disableFacelights)
3565 { 3583 {
@@ -3993,6 +4011,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3993 { 4011 {
3994 m_propertiesPacketTimer.Stop(); 4012 m_propertiesPacketTimer.Stop();
3995 4013
4014 if (m_propertiesBlocks.Count == 0)
4015 return;
4016
3996 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count]; 4017 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count];
3997 4018
3998 int index = 0; 4019 int index = 0;
@@ -4899,6 +4920,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4899 AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false); 4920 AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
4900 AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false); 4921 AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
4901 AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode); 4922 AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
4923 AddLocalPacketHandler(PacketType.CreateNewOutfitAttachments, HandleCreateNewOutfitAttachments);
4902 AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false); 4924 AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
4903 AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents); 4925 AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
4904 AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery); 4926 AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
@@ -4998,6 +5020,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4998 (x.CameraLeftAxis != lastarg.CameraLeftAxis) || 5020 (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
4999 (x.CameraUpAxis != lastarg.CameraUpAxis) || 5021 (x.CameraUpAxis != lastarg.CameraUpAxis) ||
5000 (x.ControlFlags != lastarg.ControlFlags) || 5022 (x.ControlFlags != lastarg.ControlFlags) ||
5023 (x.ControlFlags != 0) ||
5001 (x.Far != lastarg.Far) || 5024 (x.Far != lastarg.Far) ||
5002 (x.Flags != lastarg.Flags) || 5025 (x.Flags != lastarg.Flags) ||
5003 (x.State != lastarg.State) || 5026 (x.State != lastarg.State) ||
@@ -5369,7 +5392,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5369 args.Channel = ch; 5392 args.Channel = ch;
5370 args.From = String.Empty; 5393 args.From = String.Empty;
5371 args.Message = Utils.BytesToString(msg); 5394 args.Message = Utils.BytesToString(msg);
5372 args.Type = ChatTypeEnum.Shout; 5395 args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
5373 args.Position = new Vector3(); 5396 args.Position = new Vector3();
5374 args.Scene = Scene; 5397 args.Scene = Scene;
5375 args.Sender = this; 5398 args.Sender = this;
@@ -9407,6 +9430,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP
9407 { 9430 {
9408 return true; 9431 return true;
9409 } 9432 }
9433
9434 private bool HandleCreateNewOutfitAttachments(IClientAPI sender, Packet Pack)
9435 {
9436 CreateNewOutfitAttachmentsPacket packet = (CreateNewOutfitAttachmentsPacket)Pack;
9437
9438 #region Packet Session and User Check
9439 if (m_checkPackets)
9440 {
9441 if (packet.AgentData.SessionID != SessionId ||
9442 packet.AgentData.AgentID != AgentId)
9443 return true;
9444 }
9445 #endregion
9446 MoveItemsAndLeaveCopy handlerMoveItemsAndLeaveCopy = null;
9447 List<InventoryItemBase> items = new List<InventoryItemBase>();
9448 foreach (CreateNewOutfitAttachmentsPacket.ObjectDataBlock n in packet.ObjectData)
9449 {
9450 InventoryItemBase b = new InventoryItemBase();
9451 b.ID = n.OldItemID;
9452 b.Folder = n.OldFolderID;
9453 items.Add(b);
9454 }
9455
9456 handlerMoveItemsAndLeaveCopy = OnMoveItemsAndLeaveCopy;
9457 if (handlerMoveItemsAndLeaveCopy != null)
9458 {
9459 handlerMoveItemsAndLeaveCopy(this, items, packet.HeaderData.NewFolderID);
9460 }
9461
9462 return true;
9463 }
9410 9464
9411 private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack) 9465 private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
9412 { 9466 {
@@ -11269,6 +11323,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11269 } 11323 }
11270 11324
11271 /// <summary> 11325 /// <summary>
11326 /// This processes packets which have accumulated while the presence was still in the process of initialising.
11327 /// </summary>
11328 public void ProcessPendingPackets()
11329 {
11330 m_IsPresenceReady = true;
11331 if (m_pendingPackets == null)
11332 return;
11333 foreach (Packet p in m_pendingPackets)
11334 {
11335 ProcessInPacket(p);
11336 }
11337 m_pendingPackets.Clear();
11338 }
11339
11340 /// <summary>
11272 /// Entryway from the client to the simulator. All UDP packets from the client will end up here 11341 /// Entryway from the client to the simulator. All UDP packets from the client will end up here
11273 /// </summary> 11342 /// </summary>
11274 /// <param name="Pack">OpenMetaverse.packet</param> 11343 /// <param name="Pack">OpenMetaverse.packet</param>
@@ -11531,7 +11600,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11531 11600
11532// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID); 11601// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID);
11533 11602
11603
11604 //Note, the bool returned from the below function is useless since it is always false.
11534 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); 11605 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
11606
11535 } 11607 }
11536 11608
11537 /// <summary> 11609 /// <summary>