diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | 139 |
1 files changed, 88 insertions, 51 deletions
diff --git a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs index 62f51d9..7427c59 100644 --- a/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs +++ b/OpenSim/Region/ClientStack/Linden/UDP/LLClientView.cs | |||
@@ -347,7 +347,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
347 | private int m_moneyBalance; | 347 | private int m_moneyBalance; |
348 | private int m_animationSequenceNumber = 1; | 348 | private int m_animationSequenceNumber = 1; |
349 | private bool m_SendLogoutPacketWhenClosing = true; | 349 | private bool m_SendLogoutPacketWhenClosing = true; |
350 | private AgentUpdateArgs lastarg; | 350 | |
351 | /// <summary> | ||
352 | /// We retain a single AgentUpdateArgs so that we can constantly reuse it rather than construct a new one for | ||
353 | /// every single incoming AgentUpdate. Every client sends 10 AgentUpdate UDP messages per second, even if it | ||
354 | /// is doing absolutely nothing. | ||
355 | /// </summary> | ||
356 | /// <remarks> | ||
357 | /// This does mean that agent updates must be processed synchronously, at least for each client, and called methods | ||
358 | /// cannot retain a reference to it outside of that method. | ||
359 | /// </remarks> | ||
360 | private AgentUpdateArgs m_lastAgentUpdateArgs; | ||
351 | 361 | ||
352 | protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); | 362 | protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>(); |
353 | protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers | 363 | protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers |
@@ -3922,7 +3932,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3922 | { | 3932 | { |
3923 | List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value; | 3933 | List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value; |
3924 | 3934 | ||
3925 | ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket(); | 3935 | ImprovedTerseObjectUpdatePacket packet |
3936 | = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate); | ||
3937 | |||
3926 | packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle; | 3938 | packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle; |
3927 | packet.RegionData.TimeDilation = timeDilation; | 3939 | packet.RegionData.TimeDilation = timeDilation; |
3928 | packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count]; | 3940 | packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count]; |
@@ -3967,7 +3979,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
3967 | { | 3979 | { |
3968 | List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value; | 3980 | List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value; |
3969 | 3981 | ||
3970 | ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket(); | 3982 | ImprovedTerseObjectUpdatePacket packet |
3983 | = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket( | ||
3984 | PacketType.ImprovedTerseObjectUpdate); | ||
3985 | |||
3971 | packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle; | 3986 | packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle; |
3972 | packet.RegionData.TimeDilation = timeDilation; | 3987 | packet.RegionData.TimeDilation = timeDilation; |
3973 | packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count]; | 3988 | packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count]; |
@@ -4959,7 +4974,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
4959 | Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2; | 4974 | Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2; |
4960 | Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2; | 4975 | Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2; |
4961 | 4976 | ||
4962 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock block = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | 4977 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock block |
4978 | = PacketPool.Instance.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>(); | ||
4979 | |||
4963 | block.Data = data; | 4980 | block.Data = data; |
4964 | 4981 | ||
4965 | if (textureEntry != null && textureEntry.Length > 0) | 4982 | if (textureEntry != null && textureEntry.Length > 0) |
@@ -5191,7 +5208,11 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5191 | protected virtual void RegisterLocalPacketHandlers() | 5208 | protected virtual void RegisterLocalPacketHandlers() |
5192 | { | 5209 | { |
5193 | AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout); | 5210 | AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout); |
5211 | |||
5212 | // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs | ||
5213 | // for each AgentUpdate packet. | ||
5194 | AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false); | 5214 | AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false); |
5215 | |||
5195 | AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false); | 5216 | AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false); |
5196 | AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false); | 5217 | AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false); |
5197 | AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false); | 5218 | AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false); |
@@ -5418,80 +5439,83 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
5418 | 5439 | ||
5419 | #region Scene/Avatar | 5440 | #region Scene/Avatar |
5420 | 5441 | ||
5421 | private bool HandleAgentUpdate(IClientAPI sener, Packet Pack) | 5442 | private bool HandleAgentUpdate(IClientAPI sener, Packet packet) |
5422 | { | 5443 | { |
5423 | if (OnAgentUpdate != null) | 5444 | if (OnAgentUpdate != null) |
5424 | { | 5445 | { |
5425 | bool update = false; | 5446 | AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet; |
5426 | AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack; | ||
5427 | 5447 | ||
5428 | #region Packet Session and User Check | 5448 | #region Packet Session and User Check |
5429 | if (agenUpdate.AgentData.SessionID != SessionId || agenUpdate.AgentData.AgentID != AgentId) | 5449 | if (agentUpdate.AgentData.SessionID != SessionId || agentUpdate.AgentData.AgentID != AgentId) |
5450 | { | ||
5451 | PacketPool.Instance.ReturnPacket(packet); | ||
5430 | return false; | 5452 | return false; |
5453 | } | ||
5431 | #endregion | 5454 | #endregion |
5432 | 5455 | ||
5433 | AgentUpdatePacket.AgentDataBlock x = agenUpdate.AgentData; | 5456 | bool update = false; |
5434 | 5457 | AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData; | |
5435 | // We can only check when we have something to check | ||
5436 | // against. | ||
5437 | 5458 | ||
5438 | if (lastarg != null) | 5459 | if (m_lastAgentUpdateArgs != null) |
5439 | { | 5460 | { |
5461 | // These should be ordered from most-likely to | ||
5462 | // least likely to change. I've made an initial | ||
5463 | // guess at that. | ||
5440 | update = | 5464 | update = |
5441 | ( | 5465 | ( |
5442 | (x.BodyRotation != lastarg.BodyRotation) || | 5466 | (x.BodyRotation != m_lastAgentUpdateArgs.BodyRotation) || |
5443 | (x.CameraAtAxis != lastarg.CameraAtAxis) || | 5467 | (x.CameraAtAxis != m_lastAgentUpdateArgs.CameraAtAxis) || |
5444 | (x.CameraCenter != lastarg.CameraCenter) || | 5468 | (x.CameraCenter != m_lastAgentUpdateArgs.CameraCenter) || |
5445 | (x.CameraLeftAxis != lastarg.CameraLeftAxis) || | 5469 | (x.CameraLeftAxis != m_lastAgentUpdateArgs.CameraLeftAxis) || |
5446 | (x.CameraUpAxis != lastarg.CameraUpAxis) || | 5470 | (x.CameraUpAxis != m_lastAgentUpdateArgs.CameraUpAxis) || |
5447 | (x.ControlFlags != lastarg.ControlFlags) || | 5471 | (x.ControlFlags != m_lastAgentUpdateArgs.ControlFlags) || |
5448 | (x.Far != lastarg.Far) || | 5472 | (x.Far != m_lastAgentUpdateArgs.Far) || |
5449 | (x.Flags != lastarg.Flags) || | 5473 | (x.Flags != m_lastAgentUpdateArgs.Flags) || |
5450 | (x.State != lastarg.State) || | 5474 | (x.State != m_lastAgentUpdateArgs.State) || |
5451 | (x.HeadRotation != lastarg.HeadRotation) || | 5475 | (x.HeadRotation != m_lastAgentUpdateArgs.HeadRotation) || |
5452 | (x.SessionID != lastarg.SessionID) || | 5476 | (x.SessionID != m_lastAgentUpdateArgs.SessionID) || |
5453 | (x.AgentID != lastarg.AgentID) | 5477 | (x.AgentID != m_lastAgentUpdateArgs.AgentID) |
5454 | ); | 5478 | ); |
5455 | } | 5479 | } |
5456 | else | 5480 | else |
5457 | { | 5481 | { |
5482 | m_lastAgentUpdateArgs = new AgentUpdateArgs(); | ||
5458 | update = true; | 5483 | update = true; |
5459 | } | 5484 | } |
5460 | 5485 | ||
5461 | // These should be ordered from most-likely to | ||
5462 | // least likely to change. I've made an initial | ||
5463 | // guess at that. | ||
5464 | |||
5465 | if (update) | 5486 | if (update) |
5466 | { | 5487 | { |
5467 | // m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); | 5488 | // m_log.DebugFormat("[LLCLIENTVIEW]: Triggered AgentUpdate for {0}", sener.Name); |
5468 | 5489 | ||
5469 | AgentUpdateArgs arg = new AgentUpdateArgs(); | 5490 | m_lastAgentUpdateArgs.AgentID = x.AgentID; |
5470 | arg.AgentID = x.AgentID; | 5491 | m_lastAgentUpdateArgs.BodyRotation = x.BodyRotation; |
5471 | arg.BodyRotation = x.BodyRotation; | 5492 | m_lastAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis; |
5472 | arg.CameraAtAxis = x.CameraAtAxis; | 5493 | m_lastAgentUpdateArgs.CameraCenter = x.CameraCenter; |
5473 | arg.CameraCenter = x.CameraCenter; | 5494 | m_lastAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis; |
5474 | arg.CameraLeftAxis = x.CameraLeftAxis; | 5495 | m_lastAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis; |
5475 | arg.CameraUpAxis = x.CameraUpAxis; | 5496 | m_lastAgentUpdateArgs.ControlFlags = x.ControlFlags; |
5476 | arg.ControlFlags = x.ControlFlags; | 5497 | m_lastAgentUpdateArgs.Far = x.Far; |
5477 | arg.Far = x.Far; | 5498 | m_lastAgentUpdateArgs.Flags = x.Flags; |
5478 | arg.Flags = x.Flags; | 5499 | m_lastAgentUpdateArgs.HeadRotation = x.HeadRotation; |
5479 | arg.HeadRotation = x.HeadRotation; | 5500 | m_lastAgentUpdateArgs.SessionID = x.SessionID; |
5480 | arg.SessionID = x.SessionID; | 5501 | m_lastAgentUpdateArgs.State = x.State; |
5481 | arg.State = x.State; | 5502 | |
5482 | UpdateAgent handlerAgentUpdate = OnAgentUpdate; | 5503 | UpdateAgent handlerAgentUpdate = OnAgentUpdate; |
5483 | UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; | 5504 | UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate; |
5484 | lastarg = arg; // save this set of arguments for nexttime | 5505 | |
5485 | if (handlerPreAgentUpdate != null) | 5506 | if (handlerPreAgentUpdate != null) |
5486 | OnPreAgentUpdate(this, arg); | 5507 | OnPreAgentUpdate(this, m_lastAgentUpdateArgs); |
5508 | |||
5487 | if (handlerAgentUpdate != null) | 5509 | if (handlerAgentUpdate != null) |
5488 | OnAgentUpdate(this, arg); | 5510 | OnAgentUpdate(this, m_lastAgentUpdateArgs); |
5489 | 5511 | ||
5490 | handlerAgentUpdate = null; | 5512 | handlerAgentUpdate = null; |
5491 | handlerPreAgentUpdate = null; | 5513 | handlerPreAgentUpdate = null; |
5492 | } | 5514 | } |
5493 | } | 5515 | } |
5494 | 5516 | ||
5517 | PacketPool.Instance.ReturnPacket(packet); | ||
5518 | |||
5495 | return true; | 5519 | return true; |
5496 | } | 5520 | } |
5497 | 5521 | ||
@@ -9056,7 +9080,9 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9056 | } | 9080 | } |
9057 | #endregion | 9081 | #endregion |
9058 | 9082 | ||
9059 | switch (Utils.BytesToString(messagePacket.MethodData.Method)) | 9083 | string method = Utils.BytesToString(messagePacket.MethodData.Method); |
9084 | |||
9085 | switch (method) | ||
9060 | { | 9086 | { |
9061 | case "getinfo": | 9087 | case "getinfo": |
9062 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) | 9088 | if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false)) |
@@ -9372,7 +9398,17 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
9372 | return true; | 9398 | return true; |
9373 | 9399 | ||
9374 | default: | 9400 | default: |
9375 | m_log.Error("EstateOwnerMessage: Unknown method requested\n" + messagePacket); | 9401 | m_log.WarnFormat( |
9402 | "[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}", | ||
9403 | method, Name, Scene.Name); | ||
9404 | |||
9405 | for (int i = 0; i < messagePacket.ParamList.Length; i++) | ||
9406 | { | ||
9407 | EstateOwnerMessagePacket.ParamListBlock block = messagePacket.ParamList[i]; | ||
9408 | string data = (string)Utils.BytesToString(block.Parameter); | ||
9409 | m_log.DebugFormat("[LLCLIENTVIEW]: Param {0}={1}", i, data); | ||
9410 | } | ||
9411 | |||
9376 | return true; | 9412 | return true; |
9377 | } | 9413 | } |
9378 | 9414 | ||
@@ -11758,7 +11794,7 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11758 | logPacket = false; | 11794 | logPacket = false; |
11759 | 11795 | ||
11760 | if (DebugPacketLevel <= 50 | 11796 | if (DebugPacketLevel <= 50 |
11761 | & (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate)) | 11797 | && (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate)) |
11762 | logPacket = false; | 11798 | logPacket = false; |
11763 | 11799 | ||
11764 | if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily) | 11800 | if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily) |
@@ -11832,8 +11868,6 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
11832 | 11868 | ||
11833 | if (!ProcessPacketMethod(packet)) | 11869 | if (!ProcessPacketMethod(packet)) |
11834 | m_log.Warn("[CLIENT]: unhandled packet " + packet.Type); | 11870 | m_log.Warn("[CLIENT]: unhandled packet " + packet.Type); |
11835 | |||
11836 | PacketPool.Instance.ReturnPacket(packet); | ||
11837 | } | 11871 | } |
11838 | 11872 | ||
11839 | private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) | 11873 | private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) |
@@ -12286,7 +12320,10 @@ namespace OpenSim.Region.ClientStack.LindenUDP | |||
12286 | ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f); | 12320 | ushort timeDilation = Utils.FloatToUInt16(TIME_DILATION, 0.0f, 1.0f); |
12287 | 12321 | ||
12288 | 12322 | ||
12289 | ImprovedTerseObjectUpdatePacket packet = new ImprovedTerseObjectUpdatePacket(); | 12323 | ImprovedTerseObjectUpdatePacket packet |
12324 | = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket( | ||
12325 | PacketType.ImprovedTerseObjectUpdate); | ||
12326 | |||
12290 | packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle; | 12327 | packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle; |
12291 | packet.RegionData.TimeDilation = timeDilation; | 12328 | packet.RegionData.TimeDilation = timeDilation; |
12292 | packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | 12329 | packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; |