aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
authorUbitUmarov2019-03-16 14:30:53 +0000
committerUbitUmarov2019-03-16 14:30:53 +0000
commitd8f9a007f4aa8e445baefc4210b3e454f006caca (patch)
tree05d727ed01267cfcaf0cb97deb05e2e4fc95e2f4 /OpenSim
parentlludp direct encode mapblockreply. Not bc its a high volume packet, but bc it... (diff)
downloadopensim-SC-d8f9a007f4aa8e445baefc4210b3e454f006caca.zip
opensim-SC-d8f9a007f4aa8e445baefc4210b3e454f006caca.tar.gz
opensim-SC-d8f9a007f4aa8e445baefc4210b3e454f006caca.tar.bz2
opensim-SC-d8f9a007f4aa8e445baefc4210b3e454f006caca.tar.xz
bug fix on mapblockreply; direct encode mapitemreply just because..
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs118
1 files changed, 85 insertions, 33 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index f2ebe2a..83128d2 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -1561,17 +1561,97 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1561 OutPacket(newSimPack, ThrottleOutPacketType.Unknown); 1561 OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
1562 } 1562 }
1563 1563
1564 static private readonly byte[] MapBlockItemHeader = new byte[] {
1565 Helpers.MSG_RELIABLE,
1566 0, 0, 0, 0, // sequence number
1567 0, // extra
1568 0xff, 0xff, 1, 155 // ID 411 (low frequency bigendian)
1569 };
1570
1571 public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
1572 {
1573 UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint);
1574 byte[] data = buf.Data;
1575
1576 //setup header and agentinfo block
1577 Buffer.BlockCopy(MapBlockItemHeader, 0, data, 0, 10);
1578 AgentId.ToBytes(data, 10); // 26
1579 Utils.UIntToBytesSafepos(flags, data, 26); // 30
1580
1581 //RequestData block
1582 Utils.UIntToBytesSafepos(mapitemtype, data, 30); // 34
1583
1584 int countpos = 34;
1585 int pos = 35;
1586 int lastpos = 0;
1587
1588 int capacity = LLUDPServer.MAXPAYLOAD - pos;
1589
1590 int count = 0;
1591
1592 mapItemReply mr;
1593 for (int k = 0; k < replies.Length; ++k)
1594 {
1595 lastpos = pos;
1596 mr = replies[k];
1597
1598 Utils.UIntToBytesSafepos(mr.x, data, pos); pos += 4;
1599 Utils.UIntToBytesSafepos(mr.y, data, pos); pos += 4;
1600 mr.id.ToBytes(data, pos); pos += 16;
1601 Utils.IntToBytesSafepos(mr.Extra, data, pos); pos += 4;
1602 Utils.IntToBytesSafepos(mr.Extra2, data, pos); pos += 4;
1603 byte[] itemName = Util.StringToBytes256(mr.name);
1604 data[pos++] = (byte)itemName.Length;
1605 if (itemName.Length > 0)
1606 Buffer.BlockCopy(itemName, 0, data, pos, itemName.Length); pos += itemName.Length;
1607
1608 if (pos < capacity)
1609 ++count;
1610 else
1611 {
1612 // prepare next packet
1613 UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint);
1614 Buffer.BlockCopy(data, 0, newbuf.Data, 0, 34);
1615
1616 // copy the block we already did
1617 int alreadyDone = pos - lastpos;
1618 Buffer.BlockCopy(data, lastpos, newbuf.Data, 35, alreadyDone); // 34 is datablock size
1619
1620 // finish current
1621 data[countpos] = (byte)count;
1622
1623 buf.DataLength = lastpos;
1624 // send it
1625 m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Land, null, false, false);
1626
1627 buf = newbuf;
1628 data = buf.Data;
1629 pos = alreadyDone + 35;
1630 capacity = LLUDPServer.MAXPAYLOAD - pos;
1631
1632 count = 1;
1633 }
1634 }
1635
1636 if (count > 0)
1637 {
1638 data[countpos] = (byte)count;
1639
1640 buf.DataLength = pos;
1641 m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Land, null, false, false);
1642 }
1643 }
1644
1564 static private readonly byte[] MapBlockReplyHeader = new byte[] { 1645 static private readonly byte[] MapBlockReplyHeader = new byte[] {
1565 Helpers.MSG_RELIABLE, 1646 Helpers.MSG_RELIABLE,
1566 0, 0, 0, 0, // sequence number 1647 0, 0, 0, 0, // sequence number
1567 0, // extra 1648 0, // extra
1568 0xff, 0xff, 1, 153 // ID 409 (bigendian low frequency) 1649 0xff, 0xff, 1, 153 // ID 409 (low frequency bigendian)
1569 }; 1650 };
1570 1651
1571 public void SendMapBlock(List<MapBlockData> mapBlocks, uint flags) 1652 public void SendMapBlock(List<MapBlockData> mapBlocks, uint flags)
1572 { 1653 {
1573 int blocks = mapBlocks.Count; 1654 ushort[] sizes = new ushort[2 * mapBlocks.Count];
1574 ushort[] sizes = new ushort[2 * blocks];
1575 bool needSizes = false; 1655 bool needSizes = false;
1576 int sizesptr = 0; 1656 int sizesptr = 0;
1577 1657
@@ -1606,7 +1686,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1606 int capacity = LLUDPServer.MAXPAYLOAD - pos; 1686 int capacity = LLUDPServer.MAXPAYLOAD - pos;
1607 1687
1608 count = 0; 1688 count = 0;
1609 byte[] regionName = null;
1610 1689
1611 foreach (MapBlockData md in mapBlocks) 1690 foreach (MapBlockData md in mapBlocks)
1612 { 1691 {
@@ -1614,7 +1693,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1614 1693
1615 Utils.UInt16ToBytes(md.X, data, pos); pos += 2; 1694 Utils.UInt16ToBytes(md.X, data, pos); pos += 2;
1616 Utils.UInt16ToBytes(md.Y, data, pos); pos += 2; 1695 Utils.UInt16ToBytes(md.Y, data, pos); pos += 2;
1617 regionName = Util.StringToBytes256(md.Name); 1696 byte[] regionName = Util.StringToBytes256(md.Name);
1618 data[pos++] = (byte)regionName.Length; 1697 data[pos++] = (byte)regionName.Length;
1619 if(regionName.Length > 0) 1698 if(regionName.Length > 0)
1620 Buffer.BlockCopy(regionName, 0, data, pos, regionName.Length); pos += regionName.Length; 1699 Buffer.BlockCopy(regionName, 0, data, pos, regionName.Length); pos += regionName.Length;
@@ -1628,15 +1707,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1628 capacity -= 4; // 2 shorts per entry 1707 capacity -= 4; // 2 shorts per entry
1629 1708
1630 if(pos < capacity) 1709 if(pos < capacity)
1631 {
1632 ++count; 1710 ++count;
1633 --blocks;
1634 }
1635 else 1711 else
1636 { 1712 {
1637 // prepare next packet 1713 // prepare next packet
1638 UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint); 1714 UDPPacketBuffer newbuf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint);
1639 Buffer.BlockCopy(MapBlockReplyHeader, 0, newbuf.Data, 0, 30); 1715 Buffer.BlockCopy(data, 0, newbuf.Data, 0, 30);
1640 1716
1641 // copy the block we already did 1717 // copy the block we already did
1642 int alreadyDone = pos - lastpos; 1718 int alreadyDone = pos - lastpos;
@@ -1668,10 +1744,8 @@ namespace OpenSim.Region.ClientStack.LindenUDP
1668 capacity -= 4; // 2 shorts per entry 1744 capacity -= 4; // 2 shorts per entry
1669 1745
1670 count = 1; 1746 count = 1;
1671 --blocks;
1672 } 1747 }
1673 } 1748 }
1674 regionName = null;
1675 1749
1676 if (count > 0) 1750 if (count > 0)
1677 { 1751 {
@@ -3477,28 +3551,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP
3477 OutPacket(packet, ThrottleOutPacketType.Task); 3551 OutPacket(packet, ThrottleOutPacketType.Task);
3478 } 3552 }
3479 3553
3480 public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
3481 {
3482 MapItemReplyPacket mirplk = new MapItemReplyPacket();
3483 mirplk.AgentData.AgentID = AgentId;
3484 mirplk.RequestData.ItemType = mapitemtype;
3485 mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
3486 for (int i = 0; i < replies.Length; i++)
3487 {
3488 MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
3489 mrdata.X = replies[i].x;
3490 mrdata.Y = replies[i].y;
3491 mrdata.ID = replies[i].id;
3492 mrdata.Extra = replies[i].Extra;
3493 mrdata.Extra2 = replies[i].Extra2;
3494 mrdata.Name = Utils.StringToBytes(replies[i].name);
3495 mirplk.Data[i] = mrdata;
3496 }
3497 //m_log.Debug(mirplk.ToString());
3498 OutPacket(mirplk, ThrottleOutPacketType.Task);
3499
3500 }
3501
3502 public void SendOfferCallingCard(UUID srcID, UUID transactionID) 3554 public void SendOfferCallingCard(UUID srcID, UUID transactionID)
3503 { 3555 {
3504 // a bit special, as this uses AgentID to store the source instead 3556 // a bit special, as this uses AgentID to store the source instead