aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs3
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs148
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs5
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs66
4 files changed, 122 insertions, 100 deletions
diff --git a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
index 9869a99..5c17b0e 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/J2KImage.cs
@@ -202,6 +202,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
202 m_stopPacket = TexturePacketCount(); 202 m_stopPacket = TexturePacketCount();
203 } 203 }
204 204
205 //Give them at least two packets, to play nice with some broken viewers (SL also behaves this way)
206 if (m_stopPacket == 1 && Layers[0].End > FIRST_PACKET_SIZE) m_stopPacket++;
207
205 m_currentPacket = StartPacket; 208 m_currentPacket = StartPacket;
206 } 209 }
207 } 210 }
diff --git a/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index a516a54..fe8475a 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
@@ -1040,6 +1055,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1040 public virtual void SendLayerData(float[] map) 1055 public virtual void SendLayerData(float[] map)
1041 { 1056 {
1042 Util.FireAndForget(DoSendLayerData, map); 1057 Util.FireAndForget(DoSendLayerData, map);
1058
1059 // Send it sync, and async. It's not that much data
1060 // and it improves user experience just so much!
1061 DoSendLayerData(map);
1043 } 1062 }
1044 1063
1045 /// <summary> 1064 /// <summary>
@@ -1052,16 +1071,13 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1052 1071
1053 try 1072 try
1054 { 1073 {
1055 //for (int y = 0; y < 16; y++) 1074 for (int y = 0; y < 16; y++)
1056 //{ 1075 {
1057 // for (int x = 0; x < 16; x++) 1076 for (int x = 0; x < 16; x+=4)
1058 // { 1077 {
1059 // SendLayerData(x, y, map); 1078 SendLayerPacket(x, y, map);
1060 // } 1079 }
1061 //} 1080 }
1062
1063 // Send LayerData in a spiral pattern. Fun!
1064 SendLayerTopRight(map, 0, 0, 15, 15);
1065 } 1081 }
1066 catch (Exception e) 1082 catch (Exception e)
1067 { 1083 {
@@ -1069,51 +1085,35 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1069 } 1085 }
1070 } 1086 }
1071 1087
1072 private void SendLayerTopRight(float[] map, int x1, int y1, int x2, int y2)
1073 {
1074 // Row
1075 for (int i = x1; i <= x2; i++)
1076 SendLayerData(i, y1, map);
1077
1078 // Column
1079 for (int j = y1 + 1; j <= y2; j++)
1080 SendLayerData(x2, j, map);
1081
1082 if (x2 - x1 > 0)
1083 SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
1084 }
1085
1086 void SendLayerBottomLeft(float[] map, int x1, int y1, int x2, int y2)
1087 {
1088 // Row in reverse
1089 for (int i = x2; i >= x1; i--)
1090 SendLayerData(i, y2, map);
1091
1092 // Column in reverse
1093 for (int j = y2 - 1; j >= y1; j--)
1094 SendLayerData(x1, j, map);
1095
1096 if (x2 - x1 > 0)
1097 SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
1098 }
1099
1100 /// <summary> 1088 /// <summary>
1101 /// Sends a set of four patches (x, x+1, ..., x+3) to the client 1089 /// Sends a set of four patches (x, x+1, ..., x+3) to the client
1102 /// </summary> 1090 /// </summary>
1103 /// <param name="map">heightmap</param> 1091 /// <param name="map">heightmap</param>
1104 /// <param name="px">X coordinate for patches 0..12</param> 1092 /// <param name="px">X coordinate for patches 0..12</param>
1105 /// <param name="py">Y coordinate for patches 0..15</param> 1093 /// <param name="py">Y coordinate for patches 0..15</param>
1106 // private void SendLayerPacket(float[] map, int y, int x) 1094 private void SendLayerPacket(int x, int y, float[] map)
1107 // { 1095 {
1108 // int[] patches = new int[4]; 1096 int[] patches = new int[4];
1109 // patches[0] = x + 0 + y * 16; 1097 patches[0] = x + 0 + y * 16;
1110 // patches[1] = x + 1 + y * 16; 1098 patches[1] = x + 1 + y * 16;
1111 // patches[2] = x + 2 + y * 16; 1099 patches[2] = x + 2 + y * 16;
1112 // patches[3] = x + 3 + y * 16; 1100 patches[3] = x + 3 + y * 16;
1113 1101
1114 // Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches); 1102 float[] heightmap = (map.Length == 65536) ?
1115 // OutPacket(layerpack, ThrottleOutPacketType.Land); 1103 map :
1116 // } 1104 LLHeightFieldMoronize(map);
1105
1106 try
1107 {
1108 Packet layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
1109 OutPacket(layerpack, ThrottleOutPacketType.Land);
1110 }
1111 catch
1112 {
1113 for (int px = x ; px < x + 4 ; px++)
1114 SendLayerData(px, y, map);
1115 }
1116 }
1117 1117
1118 /// <summary> 1118 /// <summary>
1119 /// Sends a specified patch to a client 1119 /// Sends a specified patch to a client
@@ -1133,7 +1133,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1133 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches); 1133 LayerDataPacket layerpack = TerrainCompressor.CreateLandPacket(heightmap, patches);
1134 layerpack.Header.Reliable = true; 1134 layerpack.Header.Reliable = true;
1135 1135
1136 OutPacket(layerpack, ThrottleOutPacketType.Land); 1136 OutPacket(layerpack, ThrottleOutPacketType.Task);
1137 } 1137 }
1138 catch (Exception e) 1138 catch (Exception e)
1139 { 1139 {
@@ -3896,6 +3896,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3896 { 3896 {
3897 m_propertiesPacketTimer.Stop(); 3897 m_propertiesPacketTimer.Stop();
3898 3898
3899 if (m_propertiesBlocks.Count == 0)
3900 return;
3901
3899 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count]; 3902 proper.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[m_propertiesBlocks.Count];
3900 3903
3901 int index = 0; 3904 int index = 0;
@@ -4887,6 +4890,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4887 (x.CameraLeftAxis != lastarg.CameraLeftAxis) || 4890 (x.CameraLeftAxis != lastarg.CameraLeftAxis) ||
4888 (x.CameraUpAxis != lastarg.CameraUpAxis) || 4891 (x.CameraUpAxis != lastarg.CameraUpAxis) ||
4889 (x.ControlFlags != lastarg.ControlFlags) || 4892 (x.ControlFlags != lastarg.ControlFlags) ||
4893 (x.ControlFlags != 0) ||
4890 (x.Far != lastarg.Far) || 4894 (x.Far != lastarg.Far) ||
4891 (x.Flags != lastarg.Flags) || 4895 (x.Flags != lastarg.Flags) ||
4892 (x.State != lastarg.State) || 4896 (x.State != lastarg.State) ||
@@ -5258,7 +5262,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
5258 args.Channel = ch; 5262 args.Channel = ch;
5259 args.From = String.Empty; 5263 args.From = String.Empty;
5260 args.Message = Utils.BytesToString(msg); 5264 args.Message = Utils.BytesToString(msg);
5261 args.Type = ChatTypeEnum.Shout; 5265 args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
5262 args.Position = new Vector3(); 5266 args.Position = new Vector3();
5263 args.Scene = Scene; 5267 args.Scene = Scene;
5264 args.Sender = this; 5268 args.Sender = this;
@@ -11176,18 +11180,44 @@ namespace OpenSim.Region.ClientStack.LindenUDP
11176 } 11180 }
11177 11181
11178 /// <summary> 11182 /// <summary>
11183 /// This processes packets which have accumulated while the presence was still in the process of initialising.
11184 /// </summary>
11185 public void ProcessPendingPackets()
11186 {
11187 m_IsPresenceReady = true;
11188 if (m_pendingPackets == null)
11189 return;
11190 foreach (Packet p in m_pendingPackets)
11191 {
11192 ProcessInPacket(p);
11193 }
11194 m_pendingPackets.Clear();
11195 }
11196
11197 /// <summary>
11179 /// Entryway from the client to the simulator. All UDP packets from the client will end up here 11198 /// Entryway from the client to the simulator. All UDP packets from the client will end up here
11180 /// </summary> 11199 /// </summary>
11181 /// <param name="Pack">OpenMetaverse.packet</param> 11200 /// <param name="Pack">OpenMetaverse.packet</param>
11182 public void ProcessInPacket(Packet Pack) 11201 public void ProcessInPacket(Packet Pack)
11183 { 11202 {
11184 if (m_debugPacketLevel >= 255) 11203 if (!m_IsPresenceReady)
11185 m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack.Type); 11204 {
11205 if (m_pendingPackets == null)
11206 {
11207 m_pendingPackets = new List<Packet>();
11208 }
11209 m_pendingPackets.Add(Pack);
11210 }
11211 else
11212 {
11213 if (m_debugPacketLevel >= 255)
11214 m_log.DebugFormat("[CLIENT]: Packet IN {0}", Pack.Type);
11186 11215
11187 if (!ProcessPacketMethod(Pack)) 11216 if (!ProcessPacketMethod(Pack))
11188 m_log.Warn("[CLIENT]: unhandled packet " + Pack.Type); 11217 m_log.Warn("[CLIENT]: unhandled packet " + Pack.Type);
11189 11218
11190 PacketPool.Instance.ReturnPacket(Pack); 11219 PacketPool.Instance.ReturnPacket(Pack);
11220 }
11191 } 11221 }
11192 11222
11193 private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) 11223 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
diff --git a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs
index bdbd284..91e3d20 100644
--- a/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/TokenBucket.cs
@@ -133,7 +133,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
133 this.parent = parent; 133 this.parent = parent;
134 MaxBurst = maxBurst; 134 MaxBurst = maxBurst;
135 DripRate = dripRate; 135 DripRate = dripRate;
136 lastDrip = Environment.TickCount & Int32.MaxValue; 136 lastDrip = Environment.TickCount;
137 } 137 }
138 138
139 /// <summary> 139 /// <summary>
@@ -144,40 +144,30 @@ namespace OpenSim.Region.ClientStack.LindenUDP
144 /// the bucket, otherwise false</returns> 144 /// the bucket, otherwise false</returns>
145 public bool RemoveTokens(int amount) 145 public bool RemoveTokens(int amount)
146 { 146 {
147 bool dummy;
148 return RemoveTokens(amount, out dummy);
149 }
150
151 /// <summary>
152 /// Remove a given number of tokens from the bucket
153 /// </summary>
154 /// <param name="amount">Number of tokens to remove from the bucket</param>
155 /// <param name="dripSucceeded">True if tokens were added to the bucket
156 /// during this call, otherwise false</param>
157 /// <returns>True if the requested number of tokens were removed from
158 /// the bucket, otherwise false</returns>
159 public bool RemoveTokens(int amount, out bool dripSucceeded)
160 {
161 if (maxBurst == 0) 147 if (maxBurst == 0)
162 { 148 {
163 dripSucceeded = true;
164 return true; 149 return true;
165 } 150 }
166 151
167 dripSucceeded = Drip(); 152 if (amount > maxBurst)
168
169 if (content - amount >= 0)
170 { 153 {
171 if (parent != null && !parent.RemoveTokens(amount)) 154 throw new Exception("amount " + amount + " exceeds maxBurst " + maxBurst);
172 return false; 155 }
173 156
174 content -= amount; 157 Drip();
175 return true; 158
159 if (content < amount)
160 {
161 return false;
176 } 162 }
177 else 163
164 if (parent != null && !parent.RemoveTokens(amount))
178 { 165 {
179 return false; 166 return false;
180 } 167 }
168
169 content -= amount;
170 return true;
181 } 171 }
182 172
183 /// <summary> 173 /// <summary>
@@ -193,25 +183,23 @@ namespace OpenSim.Region.ClientStack.LindenUDP
193 content = maxBurst; 183 content = maxBurst;
194 return true; 184 return true;
195 } 185 }
196 else
197 {
198 int now = Environment.TickCount & Int32.MaxValue;
199 int deltaMS = now - lastDrip;
200 186
201 if (deltaMS <= 0) 187 int now = Environment.TickCount;
202 { 188 int deltaMS = now - lastDrip;
203 if (deltaMS < 0) 189 lastDrip = now;
204 lastDrip = now;
205 return false;
206 }
207 190
208 int dripAmount = deltaMS * tokensPerMS; 191 if (deltaMS <= 0)
209 192 {
210 content = Math.Min(content + dripAmount, maxBurst); 193 return false;
211 lastDrip = now; 194 }
212 195
213 return true; 196 long dripAmount = (long)deltaMS * (long)tokensPerMS + (long)content;
197 if (dripAmount > maxBurst)
198 {
199 dripAmount = maxBurst;
214 } 200 }
201 content = (int)dripAmount;
202 return true;
215 } 203 }
216 } 204 }
217} 205}