aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs148
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs5
2 files changed, 92 insertions, 61 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 9eb35fa..3888a0b 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -337,6 +337,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
337 private AgentUpdateArgs lastarg; 337 private AgentUpdateArgs lastarg;
338 private bool m_IsActive = true; 338 private bool m_IsActive = true;
339 private bool m_IsLoggingOut = false; 339 private bool m_IsLoggingOut = false;
340 private bool m_IsPresenceReady = false;
340 341
341 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); 342 protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
342 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers 343 protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
@@ -360,6 +361,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
360 361
361 private Timer m_propertiesPacketTimer; 362 private Timer m_propertiesPacketTimer;
362 private List<ObjectPropertiesPacket.ObjectDataBlock> m_propertiesBlocks = new List<ObjectPropertiesPacket.ObjectDataBlock>(); 363 private List<ObjectPropertiesPacket.ObjectDataBlock> m_propertiesBlocks = new List<ObjectPropertiesPacket.ObjectDataBlock>();
364 private List<Packet> m_pendingPackets;
363 365
364 #endregion Class Members 366 #endregion Class Members
365 367
@@ -400,6 +402,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
400 get { return m_IsActive; } 402 get { return m_IsActive; }
401 set { m_IsActive = value; } 403 set { m_IsActive = value; }
402 } 404 }
405
403 public bool IsLoggingOut 406 public bool IsLoggingOut
404 { 407 {
405 get { return m_IsLoggingOut; } 408 get { return m_IsLoggingOut; }
@@ -463,18 +466,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP
463 466
464 #region Client Methods 467 #region Client Methods
465 468
469
466 /// <summary> 470 /// <summary>
467 /// Shut down the client view 471 /// Shut down the client view
468 /// </summary> 472 /// </summary>
469 public void Close() 473 public void Close()
470 { 474 {
475 Close(true);
476 }
477
478 /// <summary>
479 /// Shut down the client view
480 /// </summary>
481 public void Close(bool sendStop)
482 {
471 m_log.DebugFormat( 483 m_log.DebugFormat(
472 "[CLIENT]: Close has been called for {0} attached to scene {1}", 484 "[CLIENT]: Close has been called for {0} attached to scene {1}",
473 Name, m_scene.RegionInfo.RegionName); 485 Name, m_scene.RegionInfo.RegionName);
474 486
475 // Send the STOP packet 487 if (sendStop)
476 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator); 488 {
477 OutPacket(disable, ThrottleOutPacketType.Unknown); 489 // Send the STOP packet
490 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
491 OutPacket(disable, ThrottleOutPacketType.Unknown);
492 }
478 493
479 IsActive = false; 494 IsActive = false;
480 495
@@ -1025,6 +1040,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1025 public virtual void SendLayerData(float[] map) 1040 public virtual void SendLayerData(float[] map)
1026 { 1041 {
1027 Util.FireAndForget(DoSendLayerData, map); 1042 Util.FireAndForget(DoSendLayerData, map);
1043
1044 // Send it sync, and async. It's not that much data
1045 // and it improves user experience just so much!
1046 DoSendLayerData(map);
1028 } 1047 }
1029 1048
1030 /// <summary> 1049 /// <summary>
@@ -1037,16 +1056,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1037 1056
1038 try 1057 try
1039 { 1058 {
1040 //for (int y = 0; y < 16; y++) 1059 for (int y = 0; y < 16; y++)
1041 //{ 1060 {
1042 // for (int x = 0; x < 16; x++) 1061 for (int x = 0; x < 16; x+=4)
1043 // { 1062 {
1044 // SendLayerData(x, y, map); 1063 SendLayerPacket(x, y, map);
1045 // } 1064 }
1046 //} 1065 }
1047
1048 // Send LayerData in a spiral pattern. Fun!
1049 SendLayerTopRight(map, 0, 0, 15, 15);
1050 } 1066 }
1051 catch (Exception e) 1067 catch (Exception e)
1052 { 1068 {
@@ -1054,51 +1070,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1054 } 1070 }
1055 } 1071 }
1056 1072
1057 private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2)
1058 {
1059 // Row
1060 for (int i = x1; i <= x2; i++)
1061 SendLayerData(i, y1, map);
1062
1063 // Column
1064 for (int j = y1 + 1; j <= y2; j++)
1065 SendLayerData(x2, j, map);
1066
1067 if (x2 - x1 > 0)
1068 SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
1069 }
1070
1071 void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2)
1072 {
1073 // Row in reverse
1074 for (int i = x2; i >= x1; i--)
1075 SendLayerData(i, y2, map);
1076
1077 // Column in reverse
1078 for (int j = y2 - 1; j >= y1; j--)
1079 SendLayerData(x1, j, map);
1080
1081 if (x2 - x1 > 0)
1082 SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
1083 }
1084
1085 /// <summary> 1073 /// <summary>
1086 /// Sends a set of four patches (x, x+1, ..., x+3) to the client 1074 /// Sends a set of four patches (x, x+1, ..., x+3) to the client
1087 /// </summary> 1075 /// </summary>
1088 /// <param name="map">heightmap</param> 1076 /// <param name="map">heightmap</param>
1089 /// <param name="px">X coordinate for patches 0..12</param> 1077 /// <param name="px">X coordinate for patches 0..12</param>
1090 /// <param name="py">Y coordinate for patches 0..15</param> 1078 /// <param name="py">Y coordinate for patches 0..15</param>
1091 // private void SendLayerPacket(float[] map, int y, int x) 1079 private void SendLayerPacket(int x, int y, float[] map)
1092 // { 1080 {
1093 // int[] patches = new int[4]; 1081 int[] patches = new int[4];
1094 // patches[0] = x + 0 + y * 16; 1082 patches[0] = x + 0 + y * 16;
1095 // patches[1] = x + 1 + y * 16; 1083 patches[1] = x + 1 + y * 16;
1096 // patches[2] = x + 2 + y * 16; 1084 patches[2] = x + 2 + y * 16;
1097 // patches[3] = x + 3 + y * 16; 1085 patches[3] = x + 3 + y * 16;
1098 1086
1099 // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches); 1087 float[] heightmap = (map.Length == 65536) ?
1100 // OutPacket(layerpack, ThrottleOutPacketType.Land); 1088 map :
1101 // } 1089 LLHeightFieldMoronize(map);
1090
1091 try
1092 {
1093 Packet layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
1094 OutPacket(layerpack, ThrottleOutPacketType.Land);
1095 }
1096 catch
1097 {
1098 for (int px = x ; px < x + 4 ; px++)
1099 SendLayerData(px, y, map);
1100 }
1101 }
1102 1102
1103 /// <summary> 1103 /// <summary>
1104 /// Sends a specified patch to a client 1104 /// Sends a specified patch to a client
@@ -1118,7 +1118,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1118 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches); 1118 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
1119 layerpack.Header.Reliable = true; 1119 layerpack.Header.Reliable = true;
1120 1120
1121 OutPacket(layerpack, ThrottleOutPacketType.Land); 1121 OutPacket(layerpack, ThrottleOutPacketType.Task);
1122 } 1122 }
1123 catch (Exception e) 1123 catch (Exception e)
1124 { 1124 {
@@ -3881,6 +3881,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3881 { 3881 {
3882 m_propertiesPacketTimer.Stop(); 3882 m_propertiesPacketTimer.Stop();
3883 3883
3884 if (m_propertiesBlocks.Count == 0)
3885 return;
3886
3884 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count]; 3887 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count];
3885 3888
3886 int index = 0; 3889 int index = 0;
@@ -4872,6 +4875,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4872 (x.CameraLeftAxis != lastarg.CameraLeftAxis) || 4875 (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
4873 (x.CameraUpAxis != lastarg.CameraUpAxis) || 4876 (x.CameraUpAxis != lastarg.CameraUpAxis) ||
4874 (x.ControlFlags != lastarg.ControlFlags) || 4877 (x.ControlFlags != lastarg.ControlFlags) ||
4878 (x.ControlFlags != 0) ||
4875 (x.Far != lastarg.Far) || 4879 (x.Far != lastarg.Far) ||
4876 (x.Flags != lastarg.Flags) || 4880 (x.Flags != lastarg.Flags) ||
4877 (x.State != lastarg.State) || 4881 (x.State != lastarg.State) ||
@@ -5242,7 +5246,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5242 args.Channel = ch; 5246 args.Channel = ch;
5243 args.From = String.Empty; 5247 args.From = String.Empty;
5244 args.Message = Utils.BytesToString(msg); 5248 args.Message = Utils.BytesToString(msg);
5245 args.Type = ChatTypeEnum.Shout; 5249 args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
5246 args.Position = new Vector3(); 5250 args.Position = new Vector3();
5247 args.Scene = Scene; 5251 args.Scene = Scene;
5248 args.Sender = this; 5252 args.Sender = this;
@@ -11160,18 +11164,44 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11160 } 11164 }
11161 11165
11162 /// <summary> 11166 /// <summary>
11167 /// This processes packets which have accumulated while the presence was still in the process of initialising.
11168 /// </summary>
11169 public void ProcessPendingPackets()
11170 {
11171 m_IsPresenceReady = true;
11172 if (m_pendingPackets == null)
11173 return;
11174 foreach (Packet p in m_pendingPackets)
11175 {
11176 ProcessInPacket(p);
11177 }
11178 m_pendingPackets.Clear();
11179 }
11180
11181 /// <summary>
11163 /// Entryway from the client to the simulator. All UDP packets from the client will end up here 11182 /// Entryway from the client to the simulator. All UDP packets from the client will end up here
11164 /// </summary> 11183 /// </summary>
11165 /// <param name="Pack">OpenMetaverse.packet</param> 11184 /// <param name="Pack">OpenMetaverse.packet</param>
11166 public void ProcessInPacket(Packet Pack) 11185 public void ProcessInPacket(Packet Pack)
11167 { 11186 {
11168 if (m_debugPacketLevel >= 255) 11187 if (!m_IsPresenceReady)
11169 m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack.Type); 11188 {
11189 if (m_pendingPackets == null)
11190 {
11191 m_pendingPackets = new List<Packet>();
11192 }
11193 m_pendingPackets.Add(Pack);
11194 }
11195 else
11196 {
11197 if (m_debugPacketLevel >= 255)
11198 m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack.Type);
11170 11199
11171 if (!ProcessPacketMethod(Pack)) 11200 if (!ProcessPacketMethod(Pack))
11172 m_log.Warn("[CLIENT]: unhandled packet " + Pack.Type); 11201 m_log.Warn("[CLIENT]: unhandled packet " + Pack.Type);
11173 11202
11174 PacketPool.Instance.ReturnPacket(Pack); 11203 PacketPool.Instance.ReturnPacket(Pack);
11204 }
11175 } 11205 }
11176 11206
11177 private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) 11207 private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 1b81105..cda461c 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -899,7 +899,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
899 client.OnLogout += LogoutHandler; 899 client.OnLogout += LogoutHandler;
900 900
901 // Start the IClientAPI 901 // Start the IClientAPI
902 client.Start(); 902 // Spin it off so that it doesn't clog up the LLUDPServer
903 Util.FireAndForget(delegate(object o) { client.Start(); });
903 } 904 }
904 else 905 else
905 { 906 {
@@ -915,7 +916,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
915 if (m_scene.TryGetClient(udpClient.AgentID, out client)) 916 if (m_scene.TryGetClient(udpClient.AgentID, out client))
916 { 917 {
917 client.IsLoggingOut = true; 918 client.IsLoggingOut = true;
918 client.Close(); 919 client.Close(false);
919 } 920 }
920 } 921 }
921 922