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.cs217
1 files changed, 157 insertions, 60 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 1d3bdf3..d41df3d 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -154,6 +154,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
154 public event RequestTaskInventory OnRequestTaskInventory; 154 public event RequestTaskInventory OnRequestTaskInventory;
155 public event UpdateInventoryItem OnUpdateInventoryItem; 155 public event UpdateInventoryItem OnUpdateInventoryItem;
156 public event CopyInventoryItem OnCopyInventoryItem; 156 public event CopyInventoryItem OnCopyInventoryItem;
157 public event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy;
157 public event MoveInventoryItem OnMoveInventoryItem; 158 public event MoveInventoryItem OnMoveInventoryItem;
158 public event RemoveInventoryItem OnRemoveInventoryItem; 159 public event RemoveInventoryItem OnRemoveInventoryItem;
159 public event RemoveInventoryFolder OnRemoveInventoryFolder; 160 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; } }
@@ -402,6 +414,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
402 get { return m_IsActive; } 414 get { return m_IsActive; }
403 set { m_IsActive = value; } 415 set { m_IsActive = value; }
404 } 416 }
417
405 public bool IsLoggingOut 418 public bool IsLoggingOut
406 { 419 {
407 get { return m_IsLoggingOut; } 420 get { return m_IsLoggingOut; }
@@ -471,18 +484,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP
471 484
472 #region Client Methods 485 #region Client Methods
473 486
487
474 /// <summary> 488 /// <summary>
475 /// Shut down the client view 489 /// Shut down the client view
476 /// </summary> 490 /// </summary>
477 public void Close() 491 public void Close()
478 { 492 {
493 Close(true);
494 }
495
496 /// <summary>
497 /// Shut down the client view
498 /// </summary>
499 public void Close(bool sendStop)
500 {
479 m_log.DebugFormat( 501 m_log.DebugFormat(
480 "[CLIENT]: Close has been called for {0} attached to scene {1}", 502 "[CLIENT]: Close has been called for {0} attached to scene {1}",
481 Name, m_scene.RegionInfo.RegionName); 503 Name, m_scene.RegionInfo.RegionName);
482 504
483 // Send the STOP packet 505 if (sendStop)
484 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator); 506 {
485 OutPacket(disable, ThrottleOutPacketType.Unknown); 507 // Send the STOP packet
508 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
509 OutPacket(disable, ThrottleOutPacketType.Unknown);
510 }
486 511
487 IsActive = false; 512 IsActive = false;
488 513
@@ -762,7 +787,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
762 reply.ChatData.OwnerID = fromAgentID; 787 reply.ChatData.OwnerID = fromAgentID;
763 reply.ChatData.SourceID = fromAgentID; 788 reply.ChatData.SourceID = fromAgentID;
764 789
765 OutPacket(reply, ThrottleOutPacketType.Task); 790 OutPacket(reply, ThrottleOutPacketType.Unknown);
766 } 791 }
767 792
768 /// <summary> 793 /// <summary>
@@ -1048,6 +1073,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1048 public virtual void SendLayerData(float[] map) 1073 public virtual void SendLayerData(float[] map)
1049 { 1074 {
1050 Util.FireAndForget(DoSendLayerData, map); 1075 Util.FireAndForget(DoSendLayerData, map);
1076
1077 // Send it sync, and async. It's not that much data
1078 // and it improves user experience just so much!
1079 DoSendLayerData(map);
1051 } 1080 }
1052 1081
1053 /// <summary> 1082 /// <summary>
@@ -1060,16 +1089,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1060 1089
1061 try 1090 try
1062 { 1091 {
1063 //for (int y = 0; y < 16; y++) 1092 for (int y = 0; y < 16; y++)
1064 //{ 1093 {
1065 // for (int x = 0; x < 16; x++) 1094 for (int x = 0; x < 16; x+=4)
1066 // { 1095 {
1067 // SendLayerData(x, y, map); 1096 SendLayerPacket(x, y, map);
1068 // } 1097 }
1069 //} 1098 }
1070
1071 // Send LayerData in a spiral pattern. Fun!
1072 SendLayerTopRight(map, 0, 0, 15, 15);
1073 } 1099 }
1074 catch (Exception e) 1100 catch (Exception e)
1075 { 1101 {
@@ -1077,51 +1103,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1077 } 1103 }
1078 } 1104 }
1079 1105
1080 private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2)
1081 {
1082 // Row
1083 for (int i = x1; i <= x2; i++)
1084 SendLayerData(i, y1, map);
1085
1086 // Column
1087 for (int j = y1 + 1; j <= y2; j++)
1088 SendLayerData(x2, j, map);
1089
1090 if (x2 - x1 > 0)
1091 SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
1092 }
1093
1094 void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2)
1095 {
1096 // Row in reverse
1097 for (int i = x2; i >= x1; i--)
1098 SendLayerData(i, y2, map);
1099
1100 // Column in reverse
1101 for (int j = y2 - 1; j >= y1; j--)
1102 SendLayerData(x1, j, map);
1103
1104 if (x2 - x1 > 0)
1105 SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
1106 }
1107
1108 /// <summary> 1106 /// <summary>
1109 /// Sends a set of four patches (x, x+1, ..., x+3) to the client 1107 /// Sends a set of four patches (x, x+1, ..., x+3) to the client
1110 /// </summary> 1108 /// </summary>
1111 /// <param name="map">heightmap</param> 1109 /// <param name="map">heightmap</param>
1112 /// <param name="px">X coordinate for patches 0..12</param> 1110 /// <param name="px">X coordinate for patches 0..12</param>
1113 /// <param name="py">Y coordinate for patches 0..15</param> 1111 /// <param name="py">Y coordinate for patches 0..15</param>
1114 // private void SendLayerPacket(float[] map, int y, int x) 1112 private void SendLayerPacket(int x, int y, float[] map)
1115 // { 1113 {
1116 // int[] patches = new int[4]; 1114 int[] patches = new int[4];
1117 // patches[0] = x + 0 + y * 16; 1115 patches[0] = x + 0 + y * 16;
1118 // patches[1] = x + 1 + y * 16; 1116 patches[1] = x + 1 + y * 16;
1119 // patches[2] = x + 2 + y * 16; 1117 patches[2] = x + 2 + y * 16;
1120 // patches[3] = x + 3 + y * 16; 1118 patches[3] = x + 3 + y * 16;
1121 1119
1122 // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches); 1120 float[] heightmap = (map.Length == 65536) ?
1123 // OutPacket(layerpack, ThrottleOutPacketType.Land); 1121 map :
1124 // } 1122 LLHeightFieldMoronize(map);
1123
1124 try
1125 {
1126 Packet layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
1127 OutPacket(layerpack, ThrottleOutPacketType.Land);
1128 }
1129 catch
1130 {
1131 for (int px = x ; px < x + 4 ; px++)
1132 SendLayerData(px, y, map);
1133 }
1134 }
1125 1135
1126 /// <summary> 1136 /// <summary>
1127 /// Sends a specified patch to a client 1137 /// Sends a specified patch to a client
@@ -1141,7 +1151,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1141 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches); 1151 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
1142 layerpack.Header.Reliable = true; 1152 layerpack.Header.Reliable = true;
1143 1153
1144 OutPacket(layerpack, ThrottleOutPacketType.Land); 1154 OutPacket(layerpack, ThrottleOutPacketType.Task);
1145 } 1155 }
1146 catch (Exception e) 1156 catch (Exception e)
1147 { 1157 {
@@ -2224,6 +2234,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
2224 OutPacket(sound, ThrottleOutPacketType.Task); 2234 OutPacket(sound, ThrottleOutPacketType.Task);
2225 } 2235 }
2226 2236
2237 public void SendTransferAbort(TransferRequestPacket transferRequest)
2238 {
2239 TransferAbortPacket abort = (TransferAbortPacket)PacketPool.Instance.GetPacket(PacketType.TransferAbort);
2240 abort.TransferInfo.TransferID = transferRequest.TransferInfo.TransferID;
2241 abort.TransferInfo.ChannelType = transferRequest.TransferInfo.ChannelType;
2242 m_log.Debug("[Assets] Aborting transfer; asset request failed");
2243 OutPacket(abort, ThrottleOutPacketType.Task);
2244 }
2245
2227 public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain) 2246 public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
2228 { 2247 {
2229 SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger); 2248 SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
@@ -3485,6 +3504,15 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3485 /// </summary> 3504 /// </summary>
3486 public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags) 3505 public void SendPrimUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
3487 { 3506 {
3507 if (entity is SceneObjectPart)
3508 {
3509 SceneObjectPart e = (SceneObjectPart)entity;
3510 SceneObjectGroup g = e.ParentGroup;
3511 if (g.RootPart.Shape.State > 30) // HUD
3512 if (g.OwnerID != AgentId)
3513 return; // Don't send updates for other people's HUDs
3514 }
3515
3488 double priority = m_prioritizer.GetUpdatePriority(this, entity); 3516 double priority = m_prioritizer.GetUpdatePriority(this, entity);
3489 3517
3490 lock (m_entityUpdates.SyncRoot) 3518 lock (m_entityUpdates.SyncRoot)
@@ -3505,9 +3533,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3505 EntityUpdate update; 3533 EntityUpdate update;
3506 while (updatesThisCall < maxUpdates && m_entityUpdates.TryDequeue(out update)) 3534 while (updatesThisCall < maxUpdates && m_entityUpdates.TryDequeue(out update))
3507 { 3535 {
3536 // If we have sent a kill packet for this object
3537 // drop any updates on the floor
3508 if (update.Entity is SceneObjectPart) 3538 if (update.Entity is SceneObjectPart)
3509 { 3539 {
3510 SceneObjectPart part = (SceneObjectPart)update.Entity; 3540 SceneObjectPart part = (SceneObjectPart)update.Entity;
3541 if (m_killRecord.Contains(part.ParentGroup.RootPart.LocalId))
3542 continue;
3511 3543
3512 if (part.ParentGroup.IsAttachment && m_disableFacelights) 3544 if (part.ParentGroup.IsAttachment && m_disableFacelights)
3513 { 3545 {
@@ -3941,6 +3973,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3941 { 3973 {
3942 m_propertiesPacketTimer.Stop(); 3974 m_propertiesPacketTimer.Stop();
3943 3975
3976 if (m_propertiesBlocks.Count == 0)
3977 return;
3978
3944 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count]; 3979 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count];
3945 3980
3946 int index = 0; 3981 int index = 0;
@@ -4840,6 +4875,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4840 AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false); 4875 AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
4841 AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false); 4876 AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
4842 AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode); 4877 AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
4878 AddLocalPacketHandler(PacketType.CreateNewOutfitAttachments, HandleCreateNewOutfitAttachments);
4843 AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false); 4879 AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
4844 AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents); 4880 AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
4845 AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery); 4881 AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
@@ -4939,6 +4975,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4939 (x.CameraLeftAxis != lastarg.CameraLeftAxis) || 4975 (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
4940 (x.CameraUpAxis != lastarg.CameraUpAxis) || 4976 (x.CameraUpAxis != lastarg.CameraUpAxis) ||
4941 (x.ControlFlags != lastarg.ControlFlags) || 4977 (x.ControlFlags != lastarg.ControlFlags) ||
4978 (x.ControlFlags != 0) ||
4942 (x.Far != lastarg.Far) || 4979 (x.Far != lastarg.Far) ||
4943 (x.Flags != lastarg.Flags) || 4980 (x.Flags != lastarg.Flags) ||
4944 (x.State != lastarg.State) || 4981 (x.State != lastarg.State) ||
@@ -5310,7 +5347,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5310 args.Channel = ch; 5347 args.Channel = ch;
5311 args.From = String.Empty; 5348 args.From = String.Empty;
5312 args.Message = Utils.BytesToString(msg); 5349 args.Message = Utils.BytesToString(msg);
5313 args.Type = ChatTypeEnum.Shout; 5350 args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
5314 args.Position = new Vector3(); 5351 args.Position = new Vector3();
5315 args.Scene = Scene; 5352 args.Scene = Scene;
5316 args.Sender = this; 5353 args.Sender = this;
@@ -9348,6 +9385,37 @@ namespace OpenSim.Region.ClientStack.LindenUDP
9348 { 9385 {
9349 return true; 9386 return true;
9350 } 9387 }
9388
9389 private bool HandleCreateNewOutfitAttachments(IClientAPI sender, Packet Pack)
9390 {
9391 CreateNewOutfitAttachmentsPacket packet = (CreateNewOutfitAttachmentsPacket)Pack;
9392
9393 #region Packet Session and User Check
9394 if (m_checkPackets)
9395 {
9396 if (packet.AgentData.SessionID != SessionId ||
9397 packet.AgentData.AgentID != AgentId)
9398 return true;
9399 }
9400 #endregion
9401 MoveItemsAndLeaveCopy handlerMoveItemsAndLeaveCopy = null;
9402 List<InventoryItemBase> items = new List<InventoryItemBase>();
9403 foreach (CreateNewOutfitAttachmentsPacket.ObjectDataBlock n in packet.ObjectData)
9404 {
9405 InventoryItemBase b = new InventoryItemBase();
9406 b.ID = n.OldItemID;
9407 b.Folder = n.OldFolderID;
9408 items.Add(b);
9409 }
9410
9411 handlerMoveItemsAndLeaveCopy = OnMoveItemsAndLeaveCopy;
9412 if (handlerMoveItemsAndLeaveCopy != null)
9413 {
9414 handlerMoveItemsAndLeaveCopy(this, items, packet.HeaderData.NewFolderID);
9415 }
9416
9417 return true;
9418 }
9351 9419
9352 private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack) 9420 private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
9353 { 9421 {
@@ -11191,18 +11259,44 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11191 } 11259 }
11192 11260
11193 /// <summary> 11261 /// <summary>
11262 /// This processes packets which have accumulated while the presence was still in the process of initialising.
11263 /// </summary>
11264 public void ProcessPendingPackets()
11265 {
11266 m_IsPresenceReady = true;
11267 if (m_pendingPackets == null)
11268 return;
11269 foreach (Packet p in m_pendingPackets)
11270 {
11271 ProcessInPacket(p);
11272 }
11273 m_pendingPackets.Clear();
11274 }
11275
11276 /// <summary>
11194 /// Entryway from the client to the simulator. All UDP packets from the client will end up here 11277 /// Entryway from the client to the simulator. All UDP packets from the client will end up here
11195 /// </summary> 11278 /// </summary>
11196 /// <param name="Pack">OpenMetaverse.packet</param> 11279 /// <param name="Pack">OpenMetaverse.packet</param>
11197 public void ProcessInPacket(Packet Pack) 11280 public void ProcessInPacket(Packet Pack)
11198 { 11281 {
11199 if (m_debugPacketLevel >= 255) 11282 if (!m_IsPresenceReady)
11200 m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack.Type); 11283 {
11284 if (m_pendingPackets == null)
11285 {
11286 m_pendingPackets = new List<Packet>();
11287 }
11288 m_pendingPackets.Add(Pack);
11289 }
11290 else
11291 {
11292 if (m_debugPacketLevel >= 255)
11293 m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack.Type);
11201 11294
11202 if (!ProcessPacketMethod(Pack)) 11295 if (!ProcessPacketMethod(Pack))
11203 m_log.Warn("[CLIENT]: unhandled packet " + Pack.Type); 11296 m_log.Warn("[CLIENT]: unhandled packet " + Pack.Type);
11204 11297
11205 PacketPool.Instance.ReturnPacket(Pack); 11298 PacketPool.Instance.ReturnPacket(Pack);
11299 }
11206 } 11300 }
11207 11301
11208 private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) 11302 private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
@@ -11439,7 +11533,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11439 11533
11440// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID); 11534// m_log.DebugFormat("[CLIENT]: {0} requesting asset {1}", Name, requestID);
11441 11535
11536
11537 //Note, the bool returned from the below function is useless since it is always false.
11442 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived); 11538 m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
11539
11443 } 11540 }
11444 11541
11445 /// <summary> 11542 /// <summary>