aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
diff options
context:
space:
mode:
Diffstat (limited to '')
-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 9cdc80b..3dea40c 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;
@@ -336,11 +337,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
336// protected HashSet<uint> m_attachmentsSent; 337// protected HashSet<uint> m_attachmentsSent;
337 338
338 private int m_moneyBalance; 339 private int m_moneyBalance;
340 private bool m_deliverPackets = true;
339 private int m_animationSequenceNumber = 1; 341 private int m_animationSequenceNumber = 1;
340 private bool m_SendLogoutPacketWhenClosing = true; 342 private bool m_SendLogoutPacketWhenClosing = true;
341 private AgentUpdateArgs lastarg; 343 private AgentUpdateArgs lastarg;
342 private bool m_IsActive = true; 344 private bool m_IsActive = true;
343 private bool m_IsLoggingOut = false; 345 private bool m_IsLoggingOut = false;
346 private bool m_IsPresenceReady = false;
344 347
345 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); 348 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
346 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers 349 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
@@ -363,6 +366,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
363 366
364 private Timer m_propertiesPacketTimer; 367 private Timer m_propertiesPacketTimer;
365 private List<ObjectPropertiesPacket.ObjectDataBlock> m_propertiesBlocks = new List<ObjectPropertiesPacket.ObjectDataBlock>(); 368 private List<ObjectPropertiesPacket.ObjectDataBlock> m_propertiesBlocks = new List<ObjectPropertiesPacket.ObjectDataBlock>();
369 private List<Packet> m_pendingPackets;
366 370
367 #endregion Class Members 371 #endregion Class Members
368 372
@@ -378,6 +382,14 @@ namespace OpenSim.Region.ClientStack.LindenUDP
378 get { return m_startpos; } 382 get { return m_startpos; }
379 set { m_startpos = value; } 383 set { m_startpos = value; }
380 } 384 }
385 public bool DeliverPackets
386 {
387 get { return m_deliverPackets; }
388 set {
389 m_deliverPackets = value;
390 m_udpClient.m_deliverPackets = value;
391 }
392 }
381 public UUID AgentId { get { return m_agentId; } } 393 public UUID AgentId { get { return m_agentId; } }
382 public UUID ActiveGroupId { get { return m_activeGroupID; } } 394 public UUID ActiveGroupId { get { return m_activeGroupID; } }
383 public string ActiveGroupName { get { return m_activeGroupName; } } 395 public string ActiveGroupName { get { return m_activeGroupName; } }
@@ -407,6 +419,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
407 get { return m_IsActive; } 419 get { return m_IsActive; }
408 set { m_IsActive = value; } 420 set { m_IsActive = value; }
409 } 421 }
422
410 public bool IsLoggingOut 423 public bool IsLoggingOut
411 { 424 {
412 get { return m_IsLoggingOut; } 425 get { return m_IsLoggingOut; }
@@ -476,18 +489,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP
476 489
477 #region Client Methods 490 #region Client Methods
478 491
492
479 /// <summary> 493 /// <summary>
480 /// Shut down the client view 494 /// Shut down the client view
481 /// </summary> 495 /// </summary>
482 public void Close() 496 public void Close()
483 { 497 {
498 Close(true);
499 }
500
501 /// <summary>
502 /// Shut down the client view
503 /// </summary>
504 public void Close(bool sendStop)
505 {
484 m_log.DebugFormat( 506 m_log.DebugFormat(
485 "[CLIENT]: Close has been called for {0} attached to scene {1}", 507 "[CLIENT]: Close has been called for {0} attached to scene {1}",
486 Name, m_scene.RegionInfo.RegionName); 508 Name, m_scene.RegionInfo.RegionName);
487 509
488 // Send the STOP packet 510 if (sendStop)
489 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator); 511 {
490 OutPacket(disable, ThrottleOutPacketType.Unknown); 512 // Send the STOP packet
513 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
514 OutPacket(disable, ThrottleOutPacketType.Unknown);
515 }
491 516
492 IsActive = false; 517 IsActive = false;
493 518
@@ -767,7 +792,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
767 reply.ChatData.OwnerID = fromAgentID; 792 reply.ChatData.OwnerID = fromAgentID;
768 reply.ChatData.SourceID = fromAgentID; 793 reply.ChatData.SourceID = fromAgentID;
769 794
770 OutPacket(reply, ThrottleOutPacketType.Task); 795 OutPacket(reply, ThrottleOutPacketType.Unknown);
771 } 796 }
772 797
773 /// <summary> 798 /// <summary>
@@ -1053,6 +1078,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1053 public virtual void SendLayerData(float[] map) 1078 public virtual void SendLayerData(float[] map)
1054 { 1079 {
1055 Util.FireAndForget(DoSendLayerData, map); 1080 Util.FireAndForget(DoSendLayerData, map);
1081
1082 // Send it sync, and async. It's not that much data
1083 // and it improves user experience just so much!
1084 DoSendLayerData(map);
1056 } 1085 }
1057 1086
1058 /// <summary> 1087 /// <summary>
@@ -1065,16 +1094,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1065 1094
1066 try 1095 try
1067 { 1096 {
1068 //for (int y = 0; y < 16; y++) 1097 for (int y = 0; y < 16; y++)
1069 //{ 1098 {
1070 // for (int x = 0; x < 16; x++) 1099 for (int x = 0; x < 16; x+=4)
1071 // { 1100 {
1072 // SendLayerData(x, y, map); 1101 SendLayerPacket(x, y, map);
1073 // } 1102 }
1074 //} 1103 }
1075
1076 // Send LayerData in a spiral pattern. Fun!
1077 SendLayerTopRight(map, 0, 0, 15, 15);
1078 } 1104 }
1079 catch (Exception e) 1105 catch (Exception e)
1080 { 1106 {
@@ -1082,51 +1108,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1082 } 1108 }
1083 } 1109 }
1084 1110
1085 private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2)
1086 {
1087 // Row
1088 for (int i = x1; i <= x2; i++)
1089 SendLayerData(i, y1, map);
1090
1091 // Column
1092 for (int j = y1 + 1; j <= y2; j++)
1093 SendLayerData(x2, j, map);
1094
1095 if (x2 - x1 > 0)
1096 SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
1097 }
1098
1099 void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2)
1100 {
1101 // Row in reverse
1102 for (int i = x2; i >= x1; i--)
1103 SendLayerData(i, y2, map);
1104
1105 // Column in reverse
1106 for (int j = y2 - 1; j >= y1; j--)
1107 SendLayerData(x1, j, map);
1108
1109 if (x2 - x1 > 0)
1110 SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
1111 }
1112
1113 /// <summary> 1111 /// <summary>
1114 /// Sends a set of four patches (x, x+1, ..., x+3) to the client 1112 /// Sends a set of four patches (x, x+1, ..., x+3) to the client
1115 /// </summary> 1113 /// </summary>
1116 /// <param name="map">heightmap</param> 1114 /// <param name="map">heightmap</param>
1117 /// <param name="px">X coordinate for patches 0..12</param> 1115 /// <param name="px">X coordinate for patches 0..12</param>
1118 /// <param name="py">Y coordinate for patches 0..15</param> 1116 /// <param name="py">Y coordinate for patches 0..15</param>
1119 // private void SendLayerPacket(float[] map, int y, int x) 1117 private void SendLayerPacket(int x, int y, float[] map)
1120 // { 1118 {
1121 // int[] patches = new int[4]; 1119 int[] patches = new int[4];
1122 // patches[0] = x + 0 + y * 16; 1120 patches[0] = x + 0 + y * 16;
1123 // patches[1] = x + 1 + y * 16; 1121 patches[1] = x + 1 + y * 16;
1124 // patches[2] = x + 2 + y * 16; 1122 patches[2] = x + 2 + y * 16;
1125 // patches[3] = x + 3 + y * 16; 1123 patches[3] = x + 3 + y * 16;
1126 1124
1127 // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches); 1125 float[] heightmap = (map.Length == 65536) ?
1128 // OutPacket(layerpack, ThrottleOutPacketType.Land); 1126 map :
1129 // } 1127 LLHeightFieldMoronize(map);
1128
1129 try
1130 {
1131 Packet layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
1132 OutPacket(layerpack, ThrottleOutPacketType.Land);
1133 }
1134 catch
1135 {
1136 for (int px = x ; px < x + 4 ; px++)
1137 SendLayerData(px, y, map);
1138 }
1139 }
1130 1140
1131 /// <summary> 1141 /// <summary>
1132 /// Sends a specified patch to a client 1142 /// Sends a specified patch to a client
@@ -1146,7 +1156,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1146 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches); 1156 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
1147 layerpack.Header.Reliable = true; 1157 layerpack.Header.Reliable = true;
1148 1158
1149 OutPacket(layerpack, ThrottleOutPacketType.Land); 1159 OutPacket(layerpack, ThrottleOutPacketType.Task);
1150 } 1160 }
1151 catch (Exception e) 1161 catch (Exception e)
1152 { 1162 {
@@ -2229,6 +2239,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2229 OutPacket(sound, ThrottleOutPacketType.Task); 2239 OutPacket(sound, ThrottleOutPacketType.Task);
2230 } 2240 }
2231 2241
2242 public void SendTransferAbort(TransferRequestPacket transferRequest)
2243 {
2244 TransferAbortPacket abort = (TransferAbortPacket)PacketPool.Instance.GetPacket(PacketType.TransferAbort);
2245 abort.TransferInfo.TransferID = transferRequest.TransferInfo.TransferID;
2246 abort.TransferInfo.ChannelType = transferRequest.TransferInfo.ChannelType;
2247 m_log.Debug("[Assets] Aborting transfer; asset request failed");
2248 OutPacket(abort, ThrottleOutPacketType.Task);
2249 }
2250
2232 public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain) 2251 public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
2233 { 2252 {
2234 SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger); 2253 SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
@@ -3521,6 +3540,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3521 /// </summary> 3540 /// </summary>
3522 public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) 3541 public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
3523 { 3542 {
3543 if (entity is SceneObjectPart)
3544 {
3545 SceneObjectPart e = (SceneObjectPart)entity;
3546 SceneObjectGroup g = e.ParentGroup;
3547 if (g.RootPart.Shape.State > 30) // HUD
3548 if (g.OwnerID != AgentId)
3549 return; // Don't send updates for other people's HUDs
3550 }
3551
3524 double priority = m_prioritizer.GetUpdatePriority(this, entity); 3552 double priority = m_prioritizer.GetUpdatePriority(this, entity);
3525 3553
3526 lock (m_entityUpdates.SyncRoot) 3554 lock (m_entityUpdates.SyncRoot)
@@ -3541,23 +3569,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3541 EntityUpdate update; 3569 EntityUpdate update;
3542 while (updatesThisCall < maxUpdates && m_entityUpdates.TryDequeue(out update)) 3570 while (updatesThisCall < maxUpdates && m_entityUpdates.TryDequeue(out update))
3543 { 3571 {
3544 // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client 3572 // If we have sent a kill packet for this object
3545 // will never receive an update after a prim kill. Even then, keeping the kill record may be a good 3573 // drop any updates on the floor
3546 // safety measure.
3547 //
3548 // Receiving updates after kills results in undeleteable prims that persist until relog and
3549 // currently occurs because prims can be deleted before all queued updates are sent.
3550 if (m_killRecord.Contains(update.Entity.LocalId))
3551 {
3552// m_log.WarnFormat(
3553// "[CLIENT]: Preventing full update for prim with local id {0} after client for user {1} told it was deleted",
3554// update.Entity.LocalId, Name);
3555 continue;
3556 }
3557
3558 if (update.Entity is SceneObjectPart) 3574 if (update.Entity is SceneObjectPart)
3559 { 3575 {
3560 SceneObjectPart part = (SceneObjectPart)update.Entity; 3576 SceneObjectPart part = (SceneObjectPart)update.Entity;
3577 if (m_killRecord.Contains(part.ParentGroup.RootPart.LocalId))
3578 continue;
3561 3579
3562 if (part.ParentGroup.IsAttachment && m_disableFacelights) 3580 if (part.ParentGroup.IsAttachment && m_disableFacelights)
3563 { 3581 {
@@ -3991,6 +4009,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3991 { 4009 {
3992 m_propertiesPacketTimer.Stop(); 4010 m_propertiesPacketTimer.Stop();
3993 4011
4012 if (m_propertiesBlocks.Count == 0)
4013 return;
4014
3994 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count]; 4015 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count];
3995 4016
3996 int index = 0; 4017 int index = 0;
@@ -4897,6 +4918,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4897 AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false); 4918 AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
4898 AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false); 4919 AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
4899 AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode); 4920 AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
4921 AddLocalPacketHandler(PacketType.CreateNewOutfitAttachments, HandleCreateNewOutfitAttachments);
4900 AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false); 4922 AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
4901 AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents); 4923 AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
4902 AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery); 4924 AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
@@ -4996,6 +5018,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4996 (x.CameraLeftAxis != lastarg.CameraLeftAxis) || 5018 (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
4997 (x.CameraUpAxis != lastarg.CameraUpAxis) || 5019 (x.CameraUpAxis != lastarg.CameraUpAxis) ||
4998 (x.ControlFlags != lastarg.ControlFlags) || 5020 (x.ControlFlags != lastarg.ControlFlags) ||
5021 (x.ControlFlags != 0) ||
4999 (x.Far != lastarg.Far) || 5022 (x.Far != lastarg.Far) ||
5000 (x.Flags != lastarg.Flags) || 5023 (x.Flags != lastarg.Flags) ||
5001 (x.State != lastarg.State) || 5024 (x.State != lastarg.State) ||
@@ -5367,7 +5390,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5367 args.Channel = ch; 5390 args.Channel = ch;
5368 args.From = String.Empty; 5391 args.From = String.Empty;
5369 args.Message = Utils.BytesToString(msg); 5392 args.Message = Utils.BytesToString(msg);
5370 args.Type = ChatTypeEnum.Shout; 5393 args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
5371 args.Position = new Vector3(); 5394 args.Position = new Vector3();
5372 args.Scene = Scene; 5395 args.Scene = Scene;
5373 args.Sender = this; 5396 args.Sender = this;
@@ -9405,6 +9428,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP
9405 { 9428 {
9406 return true; 9429 return true;
9407 } 9430 }
9431
9432 private bool HandleCreateNewOutfitAttachments(IClientAPI sender, Packet Pack)
9433 {
9434 CreateNewOutfitAttachmentsPacket packet = (CreateNewOutfitAttachmentsPacket)Pack;
9435
9436 #region Packet Session and User Check
9437 if (m_checkPackets)
9438 {
9439 if (packet.AgentData.SessionID != SessionId ||
9440 packet.AgentData.AgentID != AgentId)
9441 return true;
9442 }
9443 #endregion
9444 MoveItemsAndLeaveCopy handlerMoveItemsAndLeaveCopy = null;
9445 List<InventoryItemBase> items = new List<InventoryItemBase>();
9446 foreach (CreateNewOutfitAttachmentsPacket.ObjectDataBlock n in packet.ObjectData)
9447 {
9448 InventoryItemBase b = new InventoryItemBase();
9449 b.ID = n.OldItemID;
9450 b.Folder = n.OldFolderID;
9451 items.Add(b);
9452 }
9453
9454 handlerMoveItemsAndLeaveCopy = OnMoveItemsAndLeaveCopy;
9455 if (handlerMoveItemsAndLeaveCopy != null)
9456 {
9457 handlerMoveItemsAndLeaveCopy(this, items, packet.HeaderData.NewFolderID);
9458 }
9459
9460 return true;
9461 }
9408 9462
9409 private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack) 9463 private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
9410 { 9464 {
@@ -11268,6 +11322,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11268 } 11322 }
11269 11323
11270 /// <summary> 11324 /// <summary>
11325 /// This processes packets which have accumulated while the presence was still in the process of initialising.
11326 /// </summary>
11327 public void ProcessPendingPackets()
11328 {
11329 m_IsPresenceReady = true;
11330 if (m_pendingPackets == null)
11331 return;
11332 foreach (Packet p in m_pendingPackets)
11333 {
11334 ProcessInPacket(p);
11335 }
11336 m_pendingPackets.Clear();
11337 }
11338
11339 /// <summary>
11271 /// Entryway from the client to the simulator. All UDP packets from the client will end up here 11340 /// Entryway from the client to the simulator. All UDP packets from the client will end up here
11272 /// </summary> 11341 /// </summary>
11273 /// <param name="Pack">OpenMetaverse.packet</param> 11342 /// <param name="Pack">OpenMetaverse.packet</param>
@@ -11530,7 +11599,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11530 11599
11531// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID); 11600// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID);
11532 11601
11602
11603 //Note, the bool returned from the below function is useless since it is always false.
11533 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); 11604 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
11605
11534 } 11606 }
11535 11607
11536 /// <summary> 11608 /// <summary>