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 3d4269f..a1cd30a 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);
@@ -3517,6 +3536,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3517 /// </summary> 3536 /// </summary>
3518 public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) 3537 public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
3519 { 3538 {
3539 if (entity is SceneObjectPart)
3540 {
3541 SceneObjectPart e = (SceneObjectPart)entity;
3542 SceneObjectGroup g = e.ParentGroup;
3543 if (g.RootPart.Shape.State > 30) // HUD
3544 if (g.OwnerID != AgentId)
3545 return; // Don't send updates for other people's HUDs
3546 }
3547
3520 double priority = m_prioritizer.GetUpdatePriority(this, entity); 3548 double priority = m_prioritizer.GetUpdatePriority(this, entity);
3521 3549
3522 lock (m_entityUpdates.SyncRoot) 3550 lock (m_entityUpdates.SyncRoot)
@@ -3537,23 +3565,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3537 EntityUpdate update; 3565 EntityUpdate update;
3538 while (updatesThisCall < maxUpdates && m_entityUpdates.TryDequeue(out update)) 3566 while (updatesThisCall < maxUpdates && m_entityUpdates.TryDequeue(out update))
3539 { 3567 {
3540 // Please do not remove this unless you can demonstrate on the OpenSim mailing list that a client 3568 // If we have sent a kill packet for this object
3541 // will never receive an update after a prim kill. Even then, keeping the kill record may be a good 3569 // drop any updates on the floor
3542 // safety measure.
3543 //
3544 // Receiving updates after kills results in undeleteable prims that persist until relog and
3545 // currently occurs because prims can be deleted before all queued updates are sent.
3546 if (m_killRecord.Contains(update.Entity.LocalId))
3547 {
3548// m_log.WarnFormat(
3549// "[CLIENT]: Preventing full update for prim with local id {0} after client for user {1} told it was deleted",
3550// update.Entity.LocalId, Name);
3551 continue;
3552 }
3553
3554 if (update.Entity is SceneObjectPart) 3570 if (update.Entity is SceneObjectPart)
3555 { 3571 {
3556 SceneObjectPart part = (SceneObjectPart)update.Entity; 3572 SceneObjectPart part = (SceneObjectPart)update.Entity;
3573 if (m_killRecord.Contains(part.ParentGroup.RootPart.LocalId))
3574 continue;
3557 3575
3558 if (part.ParentGroup.IsAttachment && m_disableFacelights) 3576 if (part.ParentGroup.IsAttachment && m_disableFacelights)
3559 { 3577 {
@@ -3987,6 +4005,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3987 { 4005 {
3988 m_propertiesPacketTimer.Stop(); 4006 m_propertiesPacketTimer.Stop();
3989 4007
4008 if (m_propertiesBlocks.Count == 0)
4009 return;
4010
3990 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count]; 4011 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count];
3991 4012
3992 int index = 0; 4013 int index = 0;
@@ -4893,6 +4914,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4893 AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false); 4914 AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
4894 AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false); 4915 AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
4895 AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode); 4916 AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
4917 AddLocalPacketHandler(PacketType.CreateNewOutfitAttachments, HandleCreateNewOutfitAttachments);
4896 AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false); 4918 AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
4897 AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents); 4919 AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
4898 AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery); 4920 AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
@@ -4992,6 +5014,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4992 (x.CameraLeftAxis != lastarg.CameraLeftAxis) || 5014 (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
4993 (x.CameraUpAxis != lastarg.CameraUpAxis) || 5015 (x.CameraUpAxis != lastarg.CameraUpAxis) ||
4994 (x.ControlFlags != lastarg.ControlFlags) || 5016 (x.ControlFlags != lastarg.ControlFlags) ||
5017 (x.ControlFlags != 0) ||
4995 (x.Far != lastarg.Far) || 5018 (x.Far != lastarg.Far) ||
4996 (x.Flags != lastarg.Flags) || 5019 (x.Flags != lastarg.Flags) ||
4997 (x.State != lastarg.State) || 5020 (x.State != lastarg.State) ||
@@ -5363,7 +5386,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5363 args.Channel = ch; 5386 args.Channel = ch;
5364 args.From = String.Empty; 5387 args.From = String.Empty;
5365 args.Message = Utils.BytesToString(msg); 5388 args.Message = Utils.BytesToString(msg);
5366 args.Type = ChatTypeEnum.Shout; 5389 args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
5367 args.Position = new Vector3(); 5390 args.Position = new Vector3();
5368 args.Scene = Scene; 5391 args.Scene = Scene;
5369 args.Sender = this; 5392 args.Sender = this;
@@ -9401,6 +9424,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP
9401 { 9424 {
9402 return true; 9425 return true;
9403 } 9426 }
9427
9428 private bool HandleCreateNewOutfitAttachments(IClientAPI sender, Packet Pack)
9429 {
9430 CreateNewOutfitAttachmentsPacket packet = (CreateNewOutfitAttachmentsPacket)Pack;
9431
9432 #region Packet Session and User Check
9433 if (m_checkPackets)
9434 {
9435 if (packet.AgentData.SessionID != SessionId ||
9436 packet.AgentData.AgentID != AgentId)
9437 return true;
9438 }
9439 #endregion
9440 MoveItemsAndLeaveCopy handlerMoveItemsAndLeaveCopy = null;
9441 List<InventoryItemBase> items = new List<InventoryItemBase>();
9442 foreach (CreateNewOutfitAttachmentsPacket.ObjectDataBlock n in packet.ObjectData)
9443 {
9444 InventoryItemBase b = new InventoryItemBase();
9445 b.ID = n.OldItemID;
9446 b.Folder = n.OldFolderID;
9447 items.Add(b);
9448 }
9449
9450 handlerMoveItemsAndLeaveCopy = OnMoveItemsAndLeaveCopy;
9451 if (handlerMoveItemsAndLeaveCopy != null)
9452 {
9453 handlerMoveItemsAndLeaveCopy(this, items, packet.HeaderData.NewFolderID);
9454 }
9455
9456 return true;
9457 }
9404 9458
9405 private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack) 9459 private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
9406 { 9460 {
@@ -11264,6 +11318,21 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11264 } 11318 }
11265 11319
11266 /// <summary> 11320 /// <summary>
11321 /// This processes packets which have accumulated while the presence was still in the process of initialising.
11322 /// </summary>
11323 public void ProcessPendingPackets()
11324 {
11325 m_IsPresenceReady = true;
11326 if (m_pendingPackets == null)
11327 return;
11328 foreach (Packet p in m_pendingPackets)
11329 {
11330 ProcessInPacket(p);
11331 }
11332 m_pendingPackets.Clear();
11333 }
11334
11335 /// <summary>
11267 /// Entryway from the client to the simulator. All UDP packets from the client will end up here 11336 /// Entryway from the client to the simulator. All UDP packets from the client will end up here
11268 /// </summary> 11337 /// </summary>
11269 /// <param name="Pack">OpenMetaverse.packet</param> 11338 /// <param name="Pack">OpenMetaverse.packet</param>
@@ -11526,7 +11595,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11526 11595
11527// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID); 11596// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID);
11528 11597
11598
11599 //Note, the bool returned from the below function is useless since it is always false.
11529 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); 11600 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
11601
11530 } 11602 }
11531 11603
11532 /// <summary> 11604 /// <summary>