aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region
diff options
context:
space:
mode:
authorUbitUmarov2019-03-16 17:44:34 +0000
committerUbitUmarov2019-03-16 17:44:34 +0000
commit2ff5b322bec0242af40cf956e9de1622894e17f6 (patch)
treedd34d6a710712b8f2f009ae086012ca98f9b4465 /OpenSim/Region
parentlludp: direct encode rest of send terseupdates (diff)
downloadopensim-SC-2ff5b322bec0242af40cf956e9de1622894e17f6.zip
opensim-SC-2ff5b322bec0242af40cf956e9de1622894e17f6.tar.gz
opensim-SC-2ff5b322bec0242af40cf956e9de1622894e17f6.tar.bz2
opensim-SC-2ff5b322bec0242af40cf956e9de1622894e17f6.tar.xz
lludp: direct encode CoarseLocationUpdate
Diffstat (limited to 'OpenSim/Region')
-rw-r--r--OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs65
1 files changed, 40 insertions, 25 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
index 2b7a7ed..9d5a7ba 100644
--- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
+++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs
@@ -4180,46 +4180,61 @@ namespace OpenSim.Region.ClientStack.LindenUDP
4180 m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task, null, false, true); 4180 m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task, null, false, true);
4181 } 4181 }
4182 4182
4183 static private readonly byte[] CoarseLocationUpdateHeader = new byte[] {
4184 0, // no acks plz
4185 0, 0, 0, 0, // sequence number
4186 0, // extra
4187 0xff, 6 // ID 6 (medium frequency)
4188 };
4189
4183 public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations) 4190 public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
4184 { 4191 {
4185 // We don't need to update inactive clients. 4192 // We don't need to update inactive clients.
4186 if (!IsActive) 4193 if (!IsActive)
4187 return; 4194 return;
4188 4195
4189 CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate); 4196 int totalLocations = Math.Min(CoarseLocations.Count, 60);
4190 loc.Header.Reliable = false; 4197 int totalAgents = Math.Min(users.Count, 60);
4198 if(totalAgents > totalLocations)
4199 totalAgents = totalLocations;
4191 4200
4192 // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time 4201 int selfindex = -1;
4193 // a CoarseLocationUpdate packet is received. Oh well. 4202 int preyindex = -1;
4194 int total = Math.Min(CoarseLocations.Count, 60);
4195 4203
4196 CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock(); 4204 UDPPacketBuffer buf = m_udpServer.GetNewUDPBuffer(m_udpClient.RemoteEndPoint);
4205 Buffer.BlockCopy(CoarseLocationUpdateHeader, 0, buf.Data, 0, 8);
4206 byte[] data = buf.Data;
4197 4207
4198 loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total]; 4208 data[8] = (byte)totalLocations;
4199 loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total]; 4209 int pos = 9;
4200 4210
4201 int selfindex = -1; 4211 for (int i = 0; i < totalLocations; ++i)
4202 for (int i = 0; i < total; i++)
4203 { 4212 {
4204 CoarseLocationUpdatePacket.LocationBlock lb = 4213 data[pos++] = (byte)CoarseLocations[i].X;
4205 new CoarseLocationUpdatePacket.LocationBlock(); 4214 data[pos++] = (byte)CoarseLocations[i].Y;
4215 data[pos++] = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f);
4216
4217 if (i < totalAgents)
4218 {
4219 if (users[i] == AgentId)
4220 selfindex = i;
4221 //if (users[i] == PreyId)
4222 // preyindex = -1;
4223 }
4224 }
4206 4225
4207 lb.X = (byte)CoarseLocations[i].X; 4226 Utils.Int16ToBytes((short)selfindex, data, pos); pos += 2;
4208 lb.Y = (byte)CoarseLocations[i].Y; 4227 Utils.Int16ToBytes((short)preyindex, data, pos); pos += 2;
4209 4228
4210 lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f); 4229 data[pos++] = (byte)totalAgents;
4211 loc.Location[i] = lb; 4230 for (int i = 0; i < totalAgents; ++i)
4212 loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock(); 4231 {
4213 loc.AgentData[i].AgentID = users[i]; 4232 users[i].ToBytes(data, pos);
4214 if (users[i] == AgentId) 4233 pos += 16;
4215 selfindex = i;
4216 } 4234 }
4217 4235
4218 ib.You = (short)selfindex; 4236 buf.DataLength = pos;
4219 ib.Prey = -1; 4237 m_udpServer.SendUDPPacket(m_udpClient, buf, ThrottleOutPacketType.Task, null, false, false);
4220 loc.Index = ib;
4221
4222 OutPacket(loc, ThrottleOutPacketType.Task);
4223 } 4238 }
4224 4239
4225 #endregion Avatar Packet/Data Sending Methods 4240 #endregion Avatar Packet/Data Sending Methods