aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/Linden
diff options
context:
space:
mode:
authorUbitUmarov2019-03-10 15:56:14 +0000
committerUbitUmarov2019-03-10 15:56:14 +0000
commit32a03a49fc06edb65cb016b8c69f88e3c595be1d (patch)
tree822a770f0a67b6127fbb13624de710316da72c7b /OpenSim/Region/ClientStack/Linden
parentlludp fix max packet size on ack appends (diff)
downloadopensim-SC-32a03a49fc06edb65cb016b8c69f88e3c595be1d.zip
opensim-SC-32a03a49fc06edb65cb016b8c69f88e3c595be1d.tar.gz
opensim-SC-32a03a49fc06edb65cb016b8c69f88e3c595be1d.tar.bz2
opensim-SC-32a03a49fc06edb65cb016b8c69f88e3c595be1d.tar.xz
lludp: direct encode terrain patchs packets
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs86
1 files changed, 81 insertions, 5 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index ecae8c8..ac041f5 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -1257,6 +1257,16 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1257 SendLayerTopRight(x1 + 1, y1, x2, y2 - 1); 1257 SendLayerTopRight(x1 + 1, y1, x2, y2 - 1);
1258 } 1258 }
1259 1259
1260 static private readonly byte[] TerrainPacketHeader = new byte[] {
1261 Helpers.MSG_RELIABLE, // zero code is not as spec
1262 0, 0, 0, 0, // sequence number
1263 0, // extra
1264 11, // ID (high frequency)
1265 };
1266
1267 private const int END_OF_PATCHES = 97;
1268 private const int STRIDE = 264;
1269
1260 public void SendLayerData(int[] map) 1270 public void SendLayerData(int[] map)
1261 { 1271 {
1262 if(map == null) 1272 if(map == null)
@@ -1264,9 +1274,75 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1264 1274
1265 try 1275 try
1266 { 1276 {
1267 List<LayerDataPacket> packets = OpenSimTerrainCompressor.CreateLayerDataPackets(m_scene.Heightmap.GetTerrainData(), map); 1277 TerrainData terrData = m_scene.Heightmap.GetTerrainData();
1268 foreach (LayerDataPacket pkt in packets) 1278 byte landPacketType = (terrData.SizeX > Constants.RegionSize || terrData.SizeY > Constants.RegionSize) ?
1269 OutPacket(pkt, ThrottleOutPacketType.Land); 1279 (byte)TerrainPatch.LayerType.LandExtended : (byte)TerrainPatch.LayerType.Land;
1280
1281 int numberPatchs = map.Length / 2;
1282
1283 UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint);
1284 byte[] data = buf.Data;
1285
1286 Buffer.BlockCopy(TerrainPacketHeader, 0, data, 0, 7);
1287
1288 data[7] = landPacketType;
1289 //data[8] and data[9] == datablock size to fill later
1290
1291 data[10] = 0; // BitPack needs this on reused packets
1292
1293 // start data
1294 BitPack bitpack = new BitPack(data, 10);
1295 bitpack.PackBits(STRIDE, 16);
1296 bitpack.PackBitsFromByte(16);
1297 bitpack.PackBitsFromByte(landPacketType);
1298
1299 int s;
1300 int datasize = 0;
1301 for (int i = 0; i < numberPatchs; i++)
1302 {
1303 s = 2 * i;
1304 OpenSimTerrainCompressor.CreatePatchFromTerrainData(bitpack, terrData, map[s], map[s + 1]);
1305 if (bitpack.BytePos > 950 && i != numberPatchs - 1)
1306 {
1307 //finish this packet
1308 bitpack.PackBitsFromByte(END_OF_PATCHES);
1309
1310 // fix the datablock lenght
1311 datasize = bitpack.BytePos - 9;
1312 data[8] = (byte)datasize;
1313 data[9] = (byte)(datasize >> 8);
1314
1315 buf.DataLength = bitpack.BytePos + 1;
1316 m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Land, null, false, false);
1317
1318 // start another
1319 buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint);
1320 data = buf.Data;
1321
1322 Buffer.BlockCopy(TerrainPacketHeader, 0, data, 0, 7);
1323
1324 data[7] = landPacketType;
1325 //data[8] and data[9] == datablock size to fill later
1326
1327 data[10] = 0; // BitPack needs this
1328 // start data
1329 bitpack = new BitPack(data, 10);
1330
1331 bitpack.PackBits(STRIDE, 16);
1332 bitpack.PackBitsFromByte(16);
1333 bitpack.PackBitsFromByte(landPacketType);
1334 }
1335 }
1336
1337 bitpack.PackBitsFromByte(END_OF_PATCHES);
1338
1339 datasize = bitpack.BytePos - 9;
1340 data[8] = (byte)datasize;
1341 data[9] = (byte)(datasize >> 8);
1342
1343 buf.DataLength = bitpack.BytePos + 1;
1344 m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Land, null, false, false);
1345
1270 } 1346 }
1271 catch (Exception e) 1347 catch (Exception e)
1272 { 1348 {
@@ -4512,7 +4588,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4512 CreateAvatarUpdateBlock((ScenePresence)eu.Entity, zc); 4588 CreateAvatarUpdateBlock((ScenePresence)eu.Entity, zc);
4513 else 4589 else
4514 CreatePrimUpdateBlock((SceneObjectPart)eu.Entity, mysp, zc); 4590 CreatePrimUpdateBlock((SceneObjectPart)eu.Entity, mysp, zc);
4515 if (zc.Position < LLUDPServer.MTU - 5) 4591 if (zc.Position < LLUDPServer.MAXPAYLOAD)
4516 { 4592 {
4517 tau.Add(eu); 4593 tau.Add(eu);
4518 ++count; 4594 ++count;
@@ -4593,7 +4669,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4593 { 4669 {
4594 lastpos = pos; 4670 lastpos = pos;
4595 CreateImprovedTerseBlock(eu.Entity, buf.Data, ref pos, (eu.Flags & PrimUpdateFlags.Textures) != 0); 4671 CreateImprovedTerseBlock(eu.Entity, buf.Data, ref pos, (eu.Flags & PrimUpdateFlags.Textures) != 0);
4596 if (pos < LLUDPServer.MTU) 4672 if (pos < LLUDPServer.MAXPAYLOAD)
4597 { 4673 {
4598 tau.Add(eu); 4674 tau.Add(eu);
4599 ++count; 4675 ++count;