OpenSim
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Events Macros
LLClientView.cs
Go to the documentation of this file.
1 /*
2  * Copyright (c) Contributors, http://opensimulator.org/
3  * See CONTRIBUTORS.TXT for a full list of copyright holders.
4  *
5  * Redistribution and use in source and binary forms, with or without
6  * modification, are permitted provided that the following conditions are met:
7  * * Redistributions of source code must retain the above copyright
8  * notice, this list of conditions and the following disclaimer.
9  * * Redistributions in binary form must reproduce the above copyright
10  * notice, this list of conditions and the following disclaimer in the
11  * documentation and/or other materials provided with the distribution.
12  * * Neither the name of the OpenSimulator Project nor the
13  * names of its contributors may be used to endorse or promote products
14  * derived from this software without specific prior written permission.
15  *
16  * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17  * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18  * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19  * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20  * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21  * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22  * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23  * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24  * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25  * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26  */
27 
28 using System;
29 using System.Collections;
30 using System.Collections.Generic;
31 using System.Net;
32 using System.Reflection;
33 using System.Text;
34 using System.Threading;
35 using System.Timers;
36 using System.Xml;
37 
38 using log4net;
39 using OpenMetaverse;
40 using OpenMetaverse.Packets;
41 using OpenMetaverse.Messages.Linden;
42 using OpenMetaverse.StructuredData;
43 
44 using OpenSim.Framework;
45 using OpenSim.Framework.Client;
46 using OpenSim.Framework.Monitoring;
47 using OpenSim.Region.Framework.Interfaces;
48 using OpenSim.Region.Framework.Scenes;
49 using OpenSim.Services.Interfaces;
53 
54 using System.IO;
56 
57 namespace OpenSim.Region.ClientStack.LindenUDP
58 {
59  public delegate bool PacketMethod(IClientAPI simClient, Packet packet);
60 
66  {
70  public int DebugPacketLevel { get; set; }
71 
72  #region Events
73 
74  public event BinaryGenericMessage OnBinaryGenericMessage;
75  public event Action<IClientAPI> OnLogout;
77  public event Action<IClientAPI> OnConnectionClosed;
81  public event RezObject OnRezObject;
82  public event DeRezObject OnDeRezObject;
85  public event Action<IClientAPI> OnRegionHandShakeReply;
94  public event ObjectDrop OnObjectDrop;
95  public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
97  public event UpdateAgent OnAgentUpdate;
100  public event AgentSit OnAgentSit;
102  public event StartAnim OnStartAnim;
103  public event StopAnim OnStopAnim;
104  public event ChangeAnim OnChangeAnim;
105  public event Action<IClientAPI> OnRequestAvatarsData;
108  public event GrabObject OnGrabObject;
110  public event SpinStart OnSpinStart;
111  public event SpinStop OnSpinStop;
114  public event MoveObject OnGrabUpdate;
115  public event SpinObject OnSpinUpdate;
116  public event AddNewPrim OnAddPrim;
170  public event AbortXfer OnAbortXfer;
172  public event RezScript OnRezScript;
199  public event ParcelBuy OnParcelBuy;
205  public event ObjectBuy OnObjectBuy;
206  public event AgentSit OnUndo;
207  public event AgentSit OnRedo;
208  public event LandUndo OnLandUndo;
235  public event Action<Vector3, bool, bool> OnAutoPilotGo;
251  public event StartLure OnStartLure;
265  public event PickDelete OnPickDelete;
272  public event AgentFOV OnAgentFOV;
294 
295 #pragma warning disable 0067
300  public event Action<UUID> OnRemoveAvatar;
307 #pragma warning restore 0067
308 
309  #endregion Events
310 
311  #region Class Members
312 
313  // LLClientView Only
314  public delegate void BinaryGenericMessage(Object sender, string method, byte[][] args);
315 
317  private const float m_sunPainDaHalfOrbitalCutoff = 4.712388980384689858f;
318 
319  private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
320  private static string LogHeader = "[LLCLIENTVIEW]";
321  protected static Dictionary<PacketType, PacketMethod> PacketHandlers = new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
322 
326  public LLImageManager ImageManager { get; private set; }
327 
328  private readonly LLUDPServer m_udpServer;
329  private readonly LLUDPClient m_udpClient;
330  private readonly UUID m_sessionId;
331  private readonly UUID m_secureSessionId;
332  protected readonly UUID m_agentId;
333  private readonly uint m_circuitCode;
334  private readonly byte[] m_channelVersion = Utils.EmptyBytes;
335  private readonly IGroupsModule m_GroupsModule;
336 
337  private int m_cachedTextureSerial;
338  private PriorityQueue m_entityUpdates;
339  private PriorityQueue m_entityProps;
340  private Prioritizer m_prioritizer;
341  private bool m_disableFacelights = false;
342 
343  private bool m_VelocityInterpolate = false;
344  private const uint MaxTransferBytesPerPacket = 600;
345 
350  protected List<ObjectUpdatePacket.ObjectDataBlock> m_fullUpdateDataBlocksBuilder;
351 
360 // protected HashSet<uint> m_killRecord;
361 
362 // protected HashSet<uint> m_attachmentsSent;
363 
364  private bool m_deliverPackets = true;
365 
366  private bool m_SendLogoutPacketWhenClosing = true;
367 
377  private AgentUpdateArgs m_thisAgentUpdateArgs = new AgentUpdateArgs();
378 
379  protected Dictionary<PacketType, PacketProcessor> m_packetHandlers = new Dictionary<PacketType, PacketProcessor>();
380  protected Dictionary<string, GenericMessage> m_genericPacketHandlers = new Dictionary<string, GenericMessage>(); //PauPaw:Local Generic Message handlers
381  protected Scene m_scene;
382  protected string m_firstName;
383  protected string m_lastName;
385  protected Vector3 m_startpos;
387  protected string m_activeGroupName = String.Empty;
388  protected ulong m_activeGroupPowers;
389  protected Dictionary<UUID, ulong> m_groupPowers = new Dictionary<UUID, ulong>();
390  protected int m_terrainCheckerCount;
391  protected uint m_agentFOVCounter;
392 
394  private const bool m_checkPackets = true;
395 
396  #endregion Class Members
397 
398  #region Properties
399 
400  public LLUDPClient UDPClient { get { return m_udpClient; } }
401  public LLUDPServer UDPServer { get { return m_udpServer; } }
402  public IPEndPoint RemoteEndPoint { get { return m_udpClient.RemoteEndPoint; } }
403  public UUID SecureSessionId { get { return m_secureSessionId; } }
404  public IScene Scene { get { return m_scene; } }
405  public UUID SessionId { get { return m_sessionId; } }
406  public Vector3 StartPos
407  {
408  get { return m_startpos; }
409  set { m_startpos = value; }
410  }
411  public bool DeliverPackets
412  {
413  get { return m_deliverPackets; }
414  set {
415  m_deliverPackets = value;
416  m_udpClient.m_deliverPackets = value;
417  }
418  }
419  public UUID AgentId { get { return m_agentId; } }
420  public ISceneAgent SceneAgent { get; set; }
421  public UUID ActiveGroupId { get { return m_activeGroupID; } private set { m_activeGroupID = value; } }
422  public string ActiveGroupName { get { return m_activeGroupName; } private set { m_activeGroupName = value; } }
423  public ulong ActiveGroupPowers { get { return m_activeGroupPowers; } private set { m_activeGroupPowers = value; } }
424  public bool IsGroupMember(UUID groupID) { return m_groupPowers.ContainsKey(groupID); }
425 
426  public int PingTimeMS
427  {
428  get
429  {
430  if (UDPClient != null)
431  return UDPClient.PingTimeMS;
432  return 0;
433  }
434  }
435 
439  public PriorityQueue EntityUpdateQueue { get { return m_entityUpdates; } }
440 
444  public string FirstName { get { return m_firstName; } }
445 
449  public string LastName { get { return m_lastName; } }
450 
454  public string Name { get { return FirstName + " " + LastName; } }
455 
456  public uint CircuitCode { get { return m_circuitCode; } }
457  public int NextAnimationSequenceNumber
458  {
459  get { return m_udpServer.NextAnimationSequenceNumber; }
460  }
461 
466  public bool IsActive { get; set; }
467 
471  public Object CloseSyncLock { get; private set; }
472 
473  public bool IsLoggingOut { get; set; }
474 
475  public bool DisableFacelights
476  {
477  get { return m_disableFacelights; }
478  set { m_disableFacelights = value; }
479  }
480 
481  public List<uint> SelectedObjects {get; private set;}
482 
483  public bool SendLogoutPacketWhenClosing { set { m_SendLogoutPacketWhenClosing = value; } }
484 
485 
486  #endregion Properties
487 
488 // ~LLClientView()
489 // {
490 // m_log.DebugFormat("{0} Destructor called for {1}, circuit code {2}", LogHeader, Name, CircuitCode);
491 // }
492 
496  public LLClientView(Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo,
497  UUID agentId, UUID sessionId, uint circuitCode)
498  {
499 // DebugPacketLevel = 1;
500 
501  CloseSyncLock = new Object();
502  SelectedObjects = new List<uint>();
503 
504  RegisterInterface<IClientIM>(this);
505  RegisterInterface<IClientInventory>(this);
506  RegisterInterface<IClientChat>(this);
507 
508  m_scene = scene;
509  m_entityUpdates = new PriorityQueue(m_scene.Entities.Count);
510  m_entityProps = new PriorityQueue(m_scene.Entities.Count);
511  m_fullUpdateDataBlocksBuilder = new List<ObjectUpdatePacket.ObjectDataBlock>();
512 // m_killRecord = new HashSet<uint>();
513 // m_attachmentsSent = new HashSet<uint>();
514 
515  m_assetService = m_scene.RequestModuleInterface<IAssetService>();
516  m_GroupsModule = scene.RequestModuleInterface<IGroupsModule>();
517  ImageManager = new LLImageManager(this, m_assetService, Scene.RequestModuleInterface<IJ2KDecoder>());
518  m_channelVersion = Util.StringToBytes256(scene.GetSimulatorVersion());
519  m_agentId = agentId;
520  m_sessionId = sessionId;
521  m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
522  m_circuitCode = circuitCode;
523  m_firstName = sessionInfo.LoginInfo.First;
524  m_lastName = sessionInfo.LoginInfo.Last;
525  m_startpos = sessionInfo.LoginInfo.StartPos;
526 
527  m_udpServer = udpServer;
528  m_udpClient = udpClient;
529  m_udpClient.OnQueueEmpty += HandleQueueEmpty;
530  m_udpClient.HasUpdates += HandleHasUpdates;
531  m_udpClient.OnPacketStats += PopulateStats;
532 
533  m_prioritizer = new Prioritizer(m_scene);
534 
535  RegisterLocalPacketHandlers();
536 
537  IsActive = true;
538  }
539 
540  #region Client Methods
541 
542 
546  public void Close()
547  {
548  Close(true, false);
549  }
550 
551  public void Close(bool sendStop, bool force)
552  {
553  // We lock here to prevent race conditions between two threads calling close simultaneously (e.g.
554  // a simultaneous relog just as a client is being closed out due to no packet ack from the old connection.
555  lock (CloseSyncLock)
556  {
557  // We still perform a force close inside the sync lock since this is intended to attempt close where
558  // there is some unidentified connection problem, not where we have issues due to deadlock
559  if (!IsActive && !force)
560  {
561  m_log.DebugFormat( "{0} Not attempting to close inactive client {1} in {2} since force flag is not set",
562  LogHeader, Name, m_scene.Name);
563 
564  return;
565  }
566 
567  IsActive = false;
568  CloseWithoutChecks(sendStop);
569  }
570  }
571 
581  public void CloseWithoutChecks(bool sendStop)
582  {
583  m_log.DebugFormat(
584  "[CLIENT]: Close has been called for {0} attached to scene {1}",
585  Name, m_scene.RegionInfo.RegionName);
586 
587  if (sendStop)
588  {
589  // Send the STOP packet
590  DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
591  OutPacket(disable, ThrottleOutPacketType.Unknown);
592  }
593 
594  // Shutdown the image manager
595  ImageManager.Close();
596 
597  // Fire the callback for this connection closing
598  if (OnConnectionClosed != null)
599  OnConnectionClosed(this);
600 
601  // Flush all of the packets out of the UDP server for this client
602  if (m_udpServer != null)
603  m_udpServer.Flush(m_udpClient);
604 
605  // Remove ourselves from the scene
606  m_scene.RemoveClient(AgentId, true);
607  SceneAgent = null;
608 
609  // We can't reach into other scenes and close the connection
610  // We need to do this over grid communications
611  //m_scene.CloseAllAgents(CircuitCode);
612 
613  // Disable UDP handling for this client
614  m_udpClient.Shutdown();
615 
616 
617  //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
618  //GC.Collect();
619  //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
620  }
621 
622  public void Kick(string message)
623  {
624  if (!SceneAgent.IsChildAgent)
625  {
626  KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
627  kupack.UserInfo.AgentID = AgentId;
628  kupack.UserInfo.SessionID = SessionId;
629  kupack.TargetBlock.TargetIP = 0;
630  kupack.TargetBlock.TargetPort = 0;
631  kupack.UserInfo.Reason = Util.StringToBytes256(message);
632  OutPacket(kupack, ThrottleOutPacketType.Task);
633  // You must sleep here or users get no message!
634  Thread.Sleep(500);
635  }
636  }
637 
638  public void Stop()
639  {
640 
641  }
642 
643  #endregion Client Methods
644 
645  #region Packet Handling
646 
647  public void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
648  {
649  NetworkStats handlerNetworkStatsUpdate = OnNetworkStatsUpdate;
650  if (handlerNetworkStatsUpdate != null)
651  {
652  handlerNetworkStatsUpdate(inPackets, outPackets, unAckedBytes);
653  }
654  }
655 
656  public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
657  {
658  bool result = false;
659  lock (PacketHandlers)
660  {
661  if (!PacketHandlers.ContainsKey(packetType))
662  {
663  PacketHandlers.Add(packetType, handler);
664  result = true;
665  }
666  }
667  return result;
668  }
669 
680  public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
681  {
682  return AddLocalPacketHandler(packetType, handler, true);
683  }
684 
696  public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
697  {
698  return AddLocalPacketHandler(packetType, handler, doAsync, false);
699  }
700 
719  public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync, bool inEngine)
720  {
721  bool result = false;
722  lock (m_packetHandlers)
723  {
724  if (!m_packetHandlers.ContainsKey(packetType))
725  {
726  m_packetHandlers.Add(
727  packetType, new PacketProcessor() { method = handler, Async = doAsync, InEngine = inEngine });
728  result = true;
729  }
730  }
731 
732  return result;
733  }
734 
735  public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
736  {
737  MethodName = MethodName.ToLower().Trim();
738 
739  bool result = false;
740  lock (m_genericPacketHandlers)
741  {
742  if (!m_genericPacketHandlers.ContainsKey(MethodName))
743  {
744  m_genericPacketHandlers.Add(MethodName, handler);
745  result = true;
746  }
747  }
748  return result;
749  }
750 
756  protected virtual bool ProcessPacketMethod(Packet packet)
757  {
758  bool result = false;
759  PacketProcessor pprocessor;
760  if (m_packetHandlers.TryGetValue(packet.Type, out pprocessor))
761  {
762  ClientInfo cinfo = UDPClient.GetClientInfo();
763 
764  //there is a local handler for this packet type
765  if (pprocessor.Async)
766  {
767  if (!cinfo.AsyncRequests.ContainsKey(packet.Type.ToString()))
768  cinfo.AsyncRequests[packet.Type.ToString()] = 0;
769  cinfo.AsyncRequests[packet.Type.ToString()]++;
770 
771  object obj = new AsyncPacketProcess(this, pprocessor.method, packet);
772 
773  if (pprocessor.InEngine)
774  m_udpServer.IpahEngine.QueueJob(packet.Type.ToString(), () => ProcessSpecificPacketAsync(obj));
775  else
776  Util.FireAndForget(ProcessSpecificPacketAsync, obj, packet.Type.ToString());
777 
778  result = true;
779  }
780  else
781  {
782  if (!cinfo.SyncRequests.ContainsKey(packet.Type.ToString()))
783  cinfo.SyncRequests[packet.Type.ToString()] = 0;
784  cinfo.SyncRequests[packet.Type.ToString()]++;
785 
786  result = pprocessor.method(this, packet);
787  }
788  }
789  else
790  {
791  //there is not a local handler so see if there is a Global handler
792  PacketMethod method = null;
793  bool found;
794  lock (PacketHandlers)
795  {
796  found = PacketHandlers.TryGetValue(packet.Type, out method);
797  }
798  if (found)
799  {
800  ClientInfo cinfo = UDPClient.GetClientInfo();
801  if (!cinfo.GenericRequests.ContainsKey(packet.Type.ToString()))
802  cinfo.GenericRequests[packet.Type.ToString()] = 0;
803  cinfo.GenericRequests[packet.Type.ToString()]++;
804 
805  result = method(this, packet);
806  }
807  }
808  return result;
809  }
810 
811  public void ProcessSpecificPacketAsync(object state)
812  {
813  AsyncPacketProcess packetObject = (AsyncPacketProcess)state;
814 
815  try
816  {
817  packetObject.result = packetObject.Method(packetObject.ClientView, packetObject.Pack);
818  }
819  catch (Exception e)
820  {
821  // Make sure that we see any exception caused by the asynchronous operation.
822  m_log.Error(
823  string.Format(
824  "[LLCLIENTVIEW]: Caught exception while processing {0} for {1} ", packetObject.Pack, Name),
825  e);
826  }
827  }
828 
829  #endregion Packet Handling
830 
831  # region Setup
832 
833  public virtual void Start()
834  {
835  m_scene.AddNewAgent(this, PresenceType.User);
836 
837  RefreshGroupMembership();
838  }
839 
840  # endregion
841 
842  public void ActivateGesture(UUID assetId, UUID gestureId)
843  {
844  }
845 
846  public void DeactivateGesture(UUID assetId, UUID gestureId)
847  {
848  }
849 
850  // Sound
851  public void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
852  {
853  }
854 
855  #region Scene/Avatar to Client
856 
857  public void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
858  {
859  RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
860  handshake.RegionInfo = new RegionHandshakePacket.RegionInfoBlock();
861  handshake.RegionInfo.BillableFactor = args.billableFactor;
862  handshake.RegionInfo.IsEstateManager = args.isEstateManager;
863  handshake.RegionInfo.TerrainHeightRange00 = args.terrainHeightRange0;
864  handshake.RegionInfo.TerrainHeightRange01 = args.terrainHeightRange1;
865  handshake.RegionInfo.TerrainHeightRange10 = args.terrainHeightRange2;
866  handshake.RegionInfo.TerrainHeightRange11 = args.terrainHeightRange3;
867  handshake.RegionInfo.TerrainStartHeight00 = args.terrainStartHeight0;
868  handshake.RegionInfo.TerrainStartHeight01 = args.terrainStartHeight1;
869  handshake.RegionInfo.TerrainStartHeight10 = args.terrainStartHeight2;
870  handshake.RegionInfo.TerrainStartHeight11 = args.terrainStartHeight3;
871  handshake.RegionInfo.SimAccess = args.simAccess;
872  handshake.RegionInfo.WaterHeight = args.waterHeight;
873 
874  handshake.RegionInfo.RegionFlags = args.regionFlags;
875  handshake.RegionInfo.SimName = Util.StringToBytes256(args.regionName);
876  handshake.RegionInfo.SimOwner = args.SimOwner;
877  handshake.RegionInfo.TerrainBase0 = args.terrainBase0;
878  handshake.RegionInfo.TerrainBase1 = args.terrainBase1;
879  handshake.RegionInfo.TerrainBase2 = args.terrainBase2;
880  handshake.RegionInfo.TerrainBase3 = args.terrainBase3;
881  handshake.RegionInfo.TerrainDetail0 = args.terrainDetail0;
882  handshake.RegionInfo.TerrainDetail1 = args.terrainDetail1;
883  handshake.RegionInfo.TerrainDetail2 = args.terrainDetail2;
884  handshake.RegionInfo.TerrainDetail3 = args.terrainDetail3;
885  handshake.RegionInfo.CacheID = UUID.Random(); //I guess this is for the client to remember an old setting?
886  handshake.RegionInfo2 = new RegionHandshakePacket.RegionInfo2Block();
887  handshake.RegionInfo2.RegionID = regionInfo.RegionID;
888 
889  handshake.RegionInfo3 = new RegionHandshakePacket.RegionInfo3Block();
890  handshake.RegionInfo3.CPUClassID = 9;
891  handshake.RegionInfo3.CPURatio = 1;
892 
893  handshake.RegionInfo3.ColoName = Utils.EmptyBytes;
894  handshake.RegionInfo3.ProductName = Util.StringToBytes256(regionInfo.RegionType);
895  handshake.RegionInfo3.ProductSKU = Utils.EmptyBytes;
896 
897  handshake.RegionInfo4 = new RegionHandshakePacket.RegionInfo4Block[1];
898  handshake.RegionInfo4[0] = new RegionHandshakePacket.RegionInfo4Block();
899  handshake.RegionInfo4[0].RegionFlagsExtended = args.regionFlags;
900  handshake.RegionInfo4[0].RegionProtocols = 0; // 1 here would indicate that SSB is supported
901 
902  OutPacket(handshake, ThrottleOutPacketType.Unknown);
903  }
904 
905 
906  public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
907  {
908  m_thisAgentUpdateArgs.CameraAtAxis.X = float.MinValue;
909  m_thisAgentUpdateArgs.ControlFlags = uint.MaxValue;
910 
911  AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
912  mov.SimData.ChannelVersion = m_channelVersion;
913  mov.AgentData.SessionID = m_sessionId;
914  mov.AgentData.AgentID = AgentId;
915  mov.Data.RegionHandle = regInfo.RegionHandle;
916  mov.Data.Timestamp = (uint)Util.UnixTimeSinceEpoch();
917 
918  if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
919  {
920  mov.Data.Position = m_startpos;
921  }
922  else
923  {
924  mov.Data.Position = pos;
925  }
926  mov.Data.LookAt = look;
927 
928  // Hack to get this out immediately and skip the throttles
929  OutPacket(mov, ThrottleOutPacketType.Unknown);
930  }
931 
932  public void SendChatMessage(
933  string message, byte type, Vector3 fromPos, string fromName,
934  UUID fromAgentID, UUID ownerID, byte source, byte audible)
935  {
936  ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
937  reply.ChatData.Audible = audible;
938  reply.ChatData.Message = Util.StringToBytes1024(message);
939  reply.ChatData.ChatType = type;
940  reply.ChatData.SourceType = source;
941  reply.ChatData.Position = fromPos;
942  reply.ChatData.FromName = Util.StringToBytes256(fromName);
943  reply.ChatData.OwnerID = ownerID;
944  reply.ChatData.SourceID = fromAgentID;
945 
946  OutPacket(reply, ThrottleOutPacketType.Unknown);
947  }
948 
952  //
953  // Don't remove transaction ID! Groups and item gives need to set it!
955  {
956  if (((Scene)(m_scene)).Permissions.CanInstantMessage(new UUID(im.fromAgentID), new UUID(im.toAgentID)))
957  {
958  ImprovedInstantMessagePacket msg
959  = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
960 
961  msg.AgentData.AgentID = new UUID(im.fromAgentID);
962  msg.AgentData.SessionID = UUID.Zero;
963  msg.MessageBlock.FromAgentName = Util.StringToBytes256(im.fromAgentName);
964  msg.MessageBlock.Dialog = im.dialog;
965  msg.MessageBlock.FromGroup = im.fromGroup;
966  if (im.imSessionID == UUID.Zero.Guid)
967  msg.MessageBlock.ID = new UUID(im.fromAgentID) ^ new UUID(im.toAgentID);
968  else
969  msg.MessageBlock.ID = new UUID(im.imSessionID);
970  msg.MessageBlock.Offline = im.offline;
971  msg.MessageBlock.ParentEstateID = im.ParentEstateID;
972  msg.MessageBlock.Position = im.Position;
973  msg.MessageBlock.RegionID = new UUID(im.RegionID);
974  msg.MessageBlock.Timestamp = im.timestamp;
975  msg.MessageBlock.ToAgentID = new UUID(im.toAgentID);
976  msg.MessageBlock.Message = Util.StringToBytes1024(im.message);
977  msg.MessageBlock.BinaryBucket = im.binaryBucket;
978 
979  OutPacket(msg, ThrottleOutPacketType.Task);
980  }
981  }
982 
983  public void SendGenericMessage(string method, UUID invoice, List<string> message)
984  {
985  GenericMessagePacket gmp = new GenericMessagePacket();
986 
987  gmp.AgentData.AgentID = AgentId;
988  gmp.AgentData.SessionID = m_sessionId;
989  gmp.AgentData.TransactionID = invoice;
990 
991  gmp.MethodData.Method = Util.StringToBytes256(method);
992  gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
993  int i = 0;
994  foreach (string val in message)
995  {
996  gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
997  gmp.ParamList[i++].Parameter = Util.StringToBytes256(val);
998  }
999 
1000  OutPacket(gmp, ThrottleOutPacketType.Task);
1001  }
1002 
1003  public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
1004  {
1005  GenericMessagePacket gmp = new GenericMessagePacket();
1006 
1007  gmp.AgentData.AgentID = AgentId;
1008  gmp.AgentData.SessionID = m_sessionId;
1009  gmp.AgentData.TransactionID = invoice;
1010 
1011  gmp.MethodData.Method = Util.StringToBytes256(method);
1012  gmp.ParamList = new GenericMessagePacket.ParamListBlock[message.Count];
1013  int i = 0;
1014  foreach (byte[] val in message)
1015  {
1016  gmp.ParamList[i] = new GenericMessagePacket.ParamListBlock();
1017  gmp.ParamList[i++].Parameter = val;
1018  }
1019 
1020  OutPacket(gmp, ThrottleOutPacketType.Task);
1021  }
1022 
1023  public void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
1024  {
1025  int i = 0;
1026  foreach (GroupActiveProposals Proposal in Proposals)
1027  {
1028  GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
1029 
1030  GAPIRP.AgentData.AgentID = AgentId;
1031  GAPIRP.AgentData.GroupID = groupID;
1032  GAPIRP.TransactionData.TransactionID = transactionID;
1033  GAPIRP.TransactionData.TotalNumItems = ((uint)i+1);
1034  GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
1035  GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
1036  ProposalData.VoteCast = Utils.StringToBytes("false");
1037  ProposalData.VoteID = new UUID(Proposal.VoteID);
1038  ProposalData.VoteInitiator = new UUID(Proposal.VoteInitiator);
1039  ProposalData.Majority = (float)Convert.ToInt32(Proposal.Majority);
1040  ProposalData.Quorum = Convert.ToInt32(Proposal.Quorum);
1041  ProposalData.TerseDateID = Utils.StringToBytes(Proposal.TerseDateID);
1042  ProposalData.StartDateTime = Utils.StringToBytes(Proposal.StartDateTime);
1043  ProposalData.EndDateTime = Utils.StringToBytes(Proposal.EndDateTime);
1044  ProposalData.ProposalText = Utils.StringToBytes(Proposal.ProposalText);
1045  ProposalData.AlreadyVoted = false;
1046  GAPIRP.ProposalData[i] = ProposalData;
1047  OutPacket(GAPIRP, ThrottleOutPacketType.Task);
1048  i++;
1049  }
1050  if (Proposals.Length == 0)
1051  {
1052  GroupActiveProposalItemReplyPacket GAPIRP = new GroupActiveProposalItemReplyPacket();
1053 
1054  GAPIRP.AgentData.AgentID = AgentId;
1055  GAPIRP.AgentData.GroupID = groupID;
1056  GAPIRP.TransactionData.TransactionID = transactionID;
1057  GAPIRP.TransactionData.TotalNumItems = 1;
1058  GroupActiveProposalItemReplyPacket.ProposalDataBlock ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock();
1059  GAPIRP.ProposalData = new GroupActiveProposalItemReplyPacket.ProposalDataBlock[1];
1060  ProposalData.VoteCast = Utils.StringToBytes("false");
1061  ProposalData.VoteID = UUID.Zero;
1062  ProposalData.VoteInitiator = UUID.Zero;
1063  ProposalData.Majority = 0;
1064  ProposalData.Quorum = 0;
1065  ProposalData.TerseDateID = Utils.StringToBytes("");
1066  ProposalData.StartDateTime = Utils.StringToBytes("");
1067  ProposalData.EndDateTime = Utils.StringToBytes("");
1068  ProposalData.ProposalText = Utils.StringToBytes("");
1069  ProposalData.AlreadyVoted = false;
1070  GAPIRP.ProposalData[0] = ProposalData;
1071  OutPacket(GAPIRP, ThrottleOutPacketType.Task);
1072  }
1073  }
1074 
1075  public void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
1076  {
1077  int i = 0;
1078  foreach (GroupVoteHistory Vote in Votes)
1079  {
1080  GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
1081 
1082  GVHIRP.AgentData.AgentID = AgentId;
1083  GVHIRP.AgentData.GroupID = groupID;
1084  GVHIRP.TransactionData.TransactionID = transactionID;
1085  GVHIRP.TransactionData.TotalNumItems = ((uint)i+1);
1086  GVHIRP.HistoryItemData.VoteID = new UUID(Vote.VoteID);
1087  GVHIRP.HistoryItemData.VoteInitiator = new UUID(Vote.VoteInitiator);
1088  GVHIRP.HistoryItemData.Majority = (float)Convert.ToInt32(Vote.Majority);
1089  GVHIRP.HistoryItemData.Quorum = Convert.ToInt32(Vote.Quorum);
1090  GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes(Vote.TerseDateID);
1091  GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes(Vote.StartDateTime);
1092  GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes(Vote.EndDateTime);
1093  GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes(Vote.VoteType);
1094  GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes(Vote.VoteResult);
1095  GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes(Vote.ProposalText);
1096  GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
1097  GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
1098  VoteItem.CandidateID = UUID.Zero;
1099  VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
1100  VoteItem.VoteCast = Utils.StringToBytes("Yes");
1101  GVHIRP.VoteItem[i] = VoteItem;
1102  OutPacket(GVHIRP, ThrottleOutPacketType.Task);
1103  i++;
1104  }
1105  if (Votes.Length == 0)
1106  {
1107  GroupVoteHistoryItemReplyPacket GVHIRP = new GroupVoteHistoryItemReplyPacket();
1108 
1109  GVHIRP.AgentData.AgentID = AgentId;
1110  GVHIRP.AgentData.GroupID = groupID;
1111  GVHIRP.TransactionData.TransactionID = transactionID;
1112  GVHIRP.TransactionData.TotalNumItems = 0;
1113  GVHIRP.HistoryItemData.VoteID = UUID.Zero;
1114  GVHIRP.HistoryItemData.VoteInitiator = UUID.Zero;
1115  GVHIRP.HistoryItemData.Majority = 0;
1116  GVHIRP.HistoryItemData.Quorum = 0;
1117  GVHIRP.HistoryItemData.TerseDateID = Utils.StringToBytes("");
1118  GVHIRP.HistoryItemData.StartDateTime = Utils.StringToBytes("");
1119  GVHIRP.HistoryItemData.EndDateTime = Utils.StringToBytes("");
1120  GVHIRP.HistoryItemData.VoteType = Utils.StringToBytes("");
1121  GVHIRP.HistoryItemData.VoteResult = Utils.StringToBytes("");
1122  GVHIRP.HistoryItemData.ProposalText = Utils.StringToBytes("");
1123  GroupVoteHistoryItemReplyPacket.VoteItemBlock VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock();
1124  GVHIRP.VoteItem = new GroupVoteHistoryItemReplyPacket.VoteItemBlock[1];
1125  VoteItem.CandidateID = UUID.Zero;
1126  VoteItem.NumVotes = 0; //TODO: FIX THIS!!!
1127  VoteItem.VoteCast = Utils.StringToBytes("No");
1128  GVHIRP.VoteItem[0] = VoteItem;
1129  OutPacket(GVHIRP, ThrottleOutPacketType.Task);
1130  }
1131  }
1132 
1133  public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
1134  {
1135  GroupAccountDetailsReplyPacket GADRP = new GroupAccountDetailsReplyPacket();
1136  GADRP.AgentData = new GroupAccountDetailsReplyPacket.AgentDataBlock();
1137  GADRP.AgentData.AgentID = sender.AgentId;
1138  GADRP.AgentData.GroupID = groupID;
1139  GADRP.HistoryData = new GroupAccountDetailsReplyPacket.HistoryDataBlock[1];
1140  GroupAccountDetailsReplyPacket.HistoryDataBlock History = new GroupAccountDetailsReplyPacket.HistoryDataBlock();
1141  GADRP.MoneyData = new GroupAccountDetailsReplyPacket.MoneyDataBlock();
1142  GADRP.MoneyData.CurrentInterval = 0;
1143  GADRP.MoneyData.IntervalDays = 7;
1144  GADRP.MoneyData.RequestID = transactionID;
1145  GADRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
1146  History.Amount = amt;
1147  History.Description = Utils.StringToBytes("");
1148  GADRP.HistoryData[0] = History;
1149  OutPacket(GADRP, ThrottleOutPacketType.Task);
1150  }
1151 
1152  public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
1153  {
1154  GroupAccountSummaryReplyPacket GASRP =
1155  (GroupAccountSummaryReplyPacket)PacketPool.Instance.GetPacket(
1156  PacketType.GroupAccountSummaryReply);
1157 
1158  GASRP.AgentData = new GroupAccountSummaryReplyPacket.AgentDataBlock();
1159  GASRP.AgentData.AgentID = sender.AgentId;
1160  GASRP.AgentData.GroupID = groupID;
1161  GASRP.MoneyData = new GroupAccountSummaryReplyPacket.MoneyDataBlock();
1162  GASRP.MoneyData.Balance = (int)moneyAmt;
1163  GASRP.MoneyData.TotalCredits = totalTier;
1164  GASRP.MoneyData.TotalDebits = usedTier;
1165  GASRP.MoneyData.StartDate = new byte[1];
1166  GASRP.MoneyData.CurrentInterval = 1;
1167  GASRP.MoneyData.GroupTaxCurrent = 0;
1168  GASRP.MoneyData.GroupTaxEstimate = 0;
1169  GASRP.MoneyData.IntervalDays = 0;
1170  GASRP.MoneyData.LandTaxCurrent = 0;
1171  GASRP.MoneyData.LandTaxEstimate = 0;
1172  GASRP.MoneyData.LastTaxDate = new byte[1];
1173  GASRP.MoneyData.LightTaxCurrent = 0;
1174  GASRP.MoneyData.TaxDate = new byte[1];
1175  GASRP.MoneyData.RequestID = sender.AgentId;
1176  GASRP.MoneyData.ParcelDirFeeEstimate = 0;
1177  GASRP.MoneyData.ParcelDirFeeCurrent = 0;
1178  GASRP.MoneyData.ObjectTaxEstimate = 0;
1179  GASRP.MoneyData.NonExemptMembers = 0;
1180  GASRP.MoneyData.ObjectTaxCurrent = 0;
1181  GASRP.MoneyData.LightTaxEstimate = 0;
1182  OutPacket(GASRP, ThrottleOutPacketType.Task);
1183  }
1184 
1185  public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
1186  {
1187  GroupAccountTransactionsReplyPacket GATRP =
1188  (GroupAccountTransactionsReplyPacket)PacketPool.Instance.GetPacket(
1189  PacketType.GroupAccountTransactionsReply);
1190 
1191  GATRP.AgentData = new GroupAccountTransactionsReplyPacket.AgentDataBlock();
1192  GATRP.AgentData.AgentID = sender.AgentId;
1193  GATRP.AgentData.GroupID = groupID;
1194  GATRP.MoneyData = new GroupAccountTransactionsReplyPacket.MoneyDataBlock();
1195  GATRP.MoneyData.CurrentInterval = 0;
1196  GATRP.MoneyData.IntervalDays = 7;
1197  GATRP.MoneyData.RequestID = transactionID;
1198  GATRP.MoneyData.StartDate = Utils.StringToBytes(DateTime.Today.ToString());
1199  GATRP.HistoryData = new GroupAccountTransactionsReplyPacket.HistoryDataBlock[1];
1200  GroupAccountTransactionsReplyPacket.HistoryDataBlock History = new GroupAccountTransactionsReplyPacket.HistoryDataBlock();
1201  History.Amount = 0;
1202  History.Item = Utils.StringToBytes("");
1203  History.Time = Utils.StringToBytes("");
1204  History.Type = 0;
1205  History.User = Utils.StringToBytes("");
1206  GATRP.HistoryData[0] = History;
1207  OutPacket(GATRP, ThrottleOutPacketType.Task);
1208  }
1209 
1210 
1211  public virtual bool CanSendLayerData()
1212  {
1213  int n = m_udpClient.GetPacketsQueuedCount(ThrottleOutPacketType.Land);
1214  if ( n > 128)
1215  return false;
1216  return true;
1217  }
1218 
1226  public virtual void SendLayerData(float[] map)
1227  {
1228  Util.FireAndForget(DoSendLayerData, m_scene.Heightmap.GetTerrainData(), "LLClientView.DoSendLayerData");
1229 
1230  // Send it sync, and async. It's not that much data
1231  // and it improves user experience just so much!
1232 // DoSendLayerData(map);
1233  }
1234 
1239  private void DoSendLayerData(object o)
1240  {
1241  TerrainData map = (TerrainData)o;
1242 
1243  try
1244  {
1245  // Send LayerData in typerwriter pattern
1246  //for (int y = 0; y < 16; y++)
1247  //{
1248  // for (int x = 0; x < 16; x++)
1249  // {
1250  // SendLayerData(x, y, map);
1251  // }
1252  //}
1253 
1254  // Send LayerData in a spiral pattern. Fun!
1255  SendLayerTopRight(map, 0, 0, map.SizeX / Constants.TerrainPatchSize - 1, map.SizeY / Constants.TerrainPatchSize - 1);
1256  }
1257  catch (Exception e)
1258  {
1259  m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
1260  }
1261  }
1262 
1263  private void SendLayerTopRight(TerrainData map, int x1, int y1, int x2, int y2)
1264  {
1265  // Row
1266  for (int i = x1; i <= x2; i++)
1267  SendLayerData(i, y1, map);
1268 
1269  // Column
1270  for (int j = y1 + 1; j <= y2; j++)
1271  SendLayerData(x2, j, map);
1272 
1273  if (x2 - x1 > 0 && y2 - y1 > 0)
1274  SendLayerBottomLeft(map, x1, y1 + 1, x2 - 1, y2);
1275  }
1276 
1277  void SendLayerBottomLeft(TerrainData map, int x1, int y1, int x2, int y2)
1278  {
1279  // Row in reverse
1280  for (int i = x2; i >= x1; i--)
1281  SendLayerData(i, y2, map);
1282 
1283  // Column in reverse
1284  for (int j = y2 - 1; j >= y1; j--)
1285  SendLayerData(x1, j, map);
1286 
1287  if (x2 - x1 > 0 && y2 - y1 > 0)
1288  SendLayerTopRight(map, x1 + 1, y1, x2, y2 - 1);
1289  }
1290 
1291 
1292  // Legacy form of invocation that passes around a bare data array.
1293  // Just ignore what was passed and use the real terrain info that is part of the scene.
1294  // As a HORRIBLE kludge in an attempt to not change the definition of IClientAPI,
1295  // there is a special form for specifying multiple terrain patches to send.
1296  // The form is to pass 'px' as negative the number of patches to send and to
1297  // pass the float array as pairs of patch X and Y coordinates. So, passing 'px'
1298  // as -2 and map= [3, 5, 8, 4] would mean to send two terrain heightmap patches
1299  // and the patches to send are <3,5> and <8,4>.
1300  public void SendLayerData(int px, int py, float[] map)
1301  {
1302  if (px >= 0)
1303  {
1304  SendLayerData(px, py, m_scene.Heightmap.GetTerrainData());
1305  }
1306  else
1307  {
1308  int numPatches = -px;
1309  int[] xPatches = new int[numPatches];
1310  int[] yPatches = new int[numPatches];
1311  for (int pp = 0; pp < numPatches; pp++)
1312  {
1313  xPatches[pp] = (int)map[pp * 2];
1314  yPatches[pp] = (int)map[pp * 2 + 1];
1315  }
1316 
1317  // DebugSendingPatches("SendLayerData", xPatches, yPatches);
1318 
1319  SendLayerData(xPatches, yPatches, m_scene.Heightmap.GetTerrainData());
1320  }
1321  }
1322 
1323  private void DebugSendingPatches(string pWho, int[] pX, int[] pY)
1324  {
1325  if (m_log.IsDebugEnabled)
1326  {
1327  int numPatches = pX.Length;
1328  string Xs = "";
1329  string Ys = "";
1330  for (int pp = 0; pp < numPatches; pp++)
1331  {
1332  Xs += String.Format("{0}", (int)pX[pp]) + ",";
1333  Ys += String.Format("{0}", (int)pY[pp]) + ",";
1334  }
1335  m_log.DebugFormat("{0} {1}: numPatches={2}, X={3}, Y={4}", LogHeader, pWho, numPatches, Xs, Ys);
1336  }
1337  }
1338 
1340 
1348  public void SendLayerData(int px, int py, TerrainData terrData)
1349  {
1350  int[] xPatches = new[] { px };
1351  int[] yPatches = new[] { py };
1352  SendLayerData(xPatches, yPatches, terrData);
1353  }
1354 
1355  private void SendLayerData(int[] px, int[] py, TerrainData terrData)
1356  {
1357  try
1358  {
1359  byte landPacketType;
1360  if (terrData.SizeX > Constants.RegionSize || terrData.SizeY > Constants.RegionSize)
1361  landPacketType = (byte)TerrainPatch.LayerType.LandExtended;
1362  else
1363  landPacketType = (byte)TerrainPatch.LayerType.Land;
1364 
1365  List<LayerDataPacket> packets = OpenSimTerrainCompressor.CreateLayerDataPackets(terrData, px, py, landPacketType);
1366  foreach(LayerDataPacket pkt in packets)
1367  OutPacket(pkt, ThrottleOutPacketType.Land);
1368  }
1369  catch (Exception e)
1370  {
1371  m_log.Error("[CLIENT]: SendLayerData() Failed with exception: " + e.Message, e);
1372  }
1373  }
1374 
1379  public virtual void SendWindData(Vector2[] windSpeeds)
1380  {
1381  Util.FireAndForget(DoSendWindData, windSpeeds, "LLClientView.SendWindData");
1382  }
1383 
1388  public virtual void SendCloudData(float[] cloudDensity)
1389  {
1390  Util.FireAndForget(DoSendCloudData, cloudDensity, "LLClientView.SendCloudData");
1391  }
1392 
1397  private void DoSendWindData(object o)
1398  {
1399  Vector2[] windSpeeds = (Vector2[])o;
1400  TerrainPatch[] patches = new TerrainPatch[2];
1401  patches[0] = new TerrainPatch { Data = new float[16 * 16] };
1402  patches[1] = new TerrainPatch { Data = new float[16 * 16] };
1403 
1404  for (int x = 0; x < 16 * 16; x++)
1405  {
1406  patches[0].Data[x] = windSpeeds[x].X;
1407  patches[1].Data[x] = windSpeeds[x].Y;
1408  }
1409 
1410  // neither we or viewers have extended wind
1411  byte layerType = (byte)TerrainPatch.LayerType.Wind;
1412 
1413  LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLayerDataPacketStandardSize(patches, layerType);
1414  layerpack.Header.Zerocoded = true;
1415  OutPacket(layerpack, ThrottleOutPacketType.Wind);
1416  }
1417 
1422  private void DoSendCloudData(object o)
1423  {
1424  float[] cloudCover = (float[])o;
1425  TerrainPatch[] patches = new TerrainPatch[1];
1426  patches[0] = new TerrainPatch();
1427  patches[0].Data = new float[16 * 16];
1428 
1429  for (int y = 0; y < 16; y++)
1430  {
1431  for (int x = 0; x < 16; x++)
1432  {
1433  patches[0].Data[y * 16 + x] = cloudCover[y * 16 + x];
1434  }
1435  }
1436  // neither we or viewers have extended clouds
1437  byte layerType = (byte)TerrainPatch.LayerType.Cloud;
1438 
1439  LayerDataPacket layerpack = OpenSimTerrainCompressor.CreateLayerDataPacketStandardSize(patches, layerType);
1440  layerpack.Header.Zerocoded = true;
1441  OutPacket(layerpack, ThrottleOutPacketType.Cloud);
1442  }
1443 
1447  public virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
1448  {
1449  IPAddress neighbourIP = neighbourEndPoint.Address;
1450  ushort neighbourPort = (ushort)neighbourEndPoint.Port;
1451 
1452  EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
1453  // TODO: don't create new blocks if recycling an old packet
1454  enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
1455  enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
1456 
1457  byte[] byteIP = neighbourIP.GetAddressBytes();
1458  enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
1459  enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
1460  enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
1461  enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
1462  enablesimpacket.SimulatorInfo.Port = neighbourPort;
1463 
1464  enablesimpacket.Header.Reliable = true; // ESP's should be reliable.
1465 
1466  OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
1467  }
1468 
1470  {
1471  AgentCircuitData agentData = new AgentCircuitData();
1472  agentData.AgentID = AgentId;
1473  agentData.SessionID = m_sessionId;
1474  agentData.SecureSessionID = SecureSessionId;
1475  agentData.circuitcode = m_circuitCode;
1476  agentData.child = false;
1477  agentData.firstname = m_firstName;
1478  agentData.lastname = m_lastName;
1479 
1480  ICapabilitiesModule capsModule = m_scene.RequestModuleInterface<ICapabilitiesModule>();
1481 
1482  if (capsModule == null) // can happen when shutting down.
1483  return agentData;
1484 
1485  agentData.CapsPath = capsModule.GetCapsPath(m_agentId);
1486  agentData.ChildrenCapSeeds = new Dictionary<ulong, string>(capsModule.GetChildrenSeeds(m_agentId));
1487 
1488  return agentData;
1489  }
1490 
1491  public virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint,
1492  string capsURL)
1493  {
1494  Vector3 look = new Vector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
1495 
1496  //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
1497  CrossedRegionPacket newSimPack = new CrossedRegionPacket();
1498  // TODO: don't create new blocks if recycling an old packet
1499  newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
1500  newSimPack.AgentData.AgentID = AgentId;
1501  newSimPack.AgentData.SessionID = m_sessionId;
1502  newSimPack.Info = new CrossedRegionPacket.InfoBlock();
1503  newSimPack.Info.Position = pos;
1504  newSimPack.Info.LookAt = look;
1505  newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
1506  newSimPack.RegionData.RegionHandle = newRegionHandle;
1507  byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
1508  newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
1509  newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
1510  newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
1511  newSimPack.RegionData.SimIP += (uint)byteIP[0];
1512  newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
1513  newSimPack.RegionData.SeedCapability = Util.StringToBytes256(capsURL);
1514 
1515  // Hack to get this out immediately and skip throttles
1516  OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
1517  }
1518 
1519  internal void SendMapBlockSplit(List<MapBlockData> mapBlocks, uint flag)
1520  {
1521  MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
1522  // TODO: don't create new blocks if recycling an old packet
1523 
1524  MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
1525 
1526  mapReply.AgentData.AgentID = AgentId;
1527  mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks2.Length];
1528  mapReply.Size = new MapBlockReplyPacket.SizeBlock[mapBlocks2.Length];
1529  mapReply.AgentData.Flags = flag;
1530 
1531  for (int i = 0; i < mapBlocks2.Length; i++)
1532  {
1533  mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
1534  mapReply.Data[i].MapImageID = mapBlocks2[i].MapImageId;
1535  //m_log.Warn(mapBlocks2[i].MapImageId.ToString());
1536  mapReply.Data[i].X = mapBlocks2[i].X;
1537  mapReply.Data[i].Y = mapBlocks2[i].Y;
1538  mapReply.Data[i].WaterHeight = mapBlocks2[i].WaterHeight;
1539  mapReply.Data[i].Name = Utils.StringToBytes(mapBlocks2[i].Name);
1540  mapReply.Data[i].RegionFlags = mapBlocks2[i].RegionFlags;
1541  mapReply.Data[i].Access = mapBlocks2[i].Access;
1542  mapReply.Data[i].Agents = mapBlocks2[i].Agents;
1543 
1544  mapReply.Size[i] = new MapBlockReplyPacket.SizeBlock();
1545  mapReply.Size[i].SizeX = mapBlocks2[i].SizeX;
1546  mapReply.Size[i].SizeY = mapBlocks2[i].SizeY;
1547  }
1548  OutPacket(mapReply, ThrottleOutPacketType.Land);
1549  }
1550 
1551  public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
1552  {
1553  MapBlockData[] mapBlocks2 = mapBlocks.ToArray();
1554 
1555  int maxsend = 10;
1556 
1557  //int packets = Math.Ceiling(mapBlocks2.Length / maxsend);
1558 
1559  List<MapBlockData> sendingBlocks = new List<MapBlockData>();
1560 
1561  for (int i = 0; i < mapBlocks2.Length; i++)
1562  {
1563  sendingBlocks.Add(mapBlocks2[i]);
1564  if (((i + 1) == mapBlocks2.Length) || (((i + 1) % maxsend) == 0))
1565  {
1566  SendMapBlockSplit(sendingBlocks, flag);
1567  sendingBlocks = new List<MapBlockData>();
1568  }
1569  }
1570  }
1571 
1572  public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
1573  {
1574  TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
1575  tpLocal.Info.AgentID = AgentId;
1576  tpLocal.Info.TeleportFlags = flags;
1577  tpLocal.Info.LocationID = 2;
1578  tpLocal.Info.LookAt = lookAt;
1579  tpLocal.Info.Position = position;
1580 
1581  // Hack to get this out immediately and skip throttles
1582  OutPacket(tpLocal, ThrottleOutPacketType.Unknown);
1583  }
1584 
1585  public virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
1586  uint flags, string capsURL)
1587  {
1588  //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
1589 
1590  TeleportFinishPacket teleport = new TeleportFinishPacket();
1591  teleport.Info.AgentID = AgentId;
1592  teleport.Info.RegionHandle = regionHandle;
1593  teleport.Info.SimAccess = simAccess;
1594 
1595  teleport.Info.SeedCapability = Util.StringToBytes256(capsURL);
1596 
1597  IPAddress oIP = newRegionEndPoint.Address;
1598  byte[] byteIP = oIP.GetAddressBytes();
1599  uint ip = (uint)byteIP[3] << 24;
1600  ip += (uint)byteIP[2] << 16;
1601  ip += (uint)byteIP[1] << 8;
1602  ip += (uint)byteIP[0];
1603 
1604  teleport.Info.SimIP = ip;
1605  teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
1606  teleport.Info.LocationID = 4;
1607  teleport.Info.TeleportFlags = 1 << 4;
1608 
1609  // Hack to get this out immediately and skip throttles.
1610  OutPacket(teleport, ThrottleOutPacketType.Unknown);
1611  }
1612 
1616  public void SendTeleportFailed(string reason)
1617  {
1618  TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
1619  tpFailed.Info.AgentID = AgentId;
1620  tpFailed.Info.Reason = Util.StringToBytes256(reason);
1621  tpFailed.AlertInfo = new TeleportFailedPacket.AlertInfoBlock[0];
1622 
1623  // Hack to get this out immediately and skip throttles
1624  OutPacket(tpFailed, ThrottleOutPacketType.Unknown);
1625  }
1626 
1630  public void SendTeleportStart(uint flags)
1631  {
1632  TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
1633  //TeleportStartPacket tpStart = new TeleportStartPacket();
1634  tpStart.Info.TeleportFlags = flags; //16; // Teleport via location
1635 
1636  // Hack to get this out immediately and skip throttles
1637  OutPacket(tpStart, ThrottleOutPacketType.Unknown);
1638  }
1639 
1640  public void SendTeleportProgress(uint flags, string message)
1641  {
1642  TeleportProgressPacket tpProgress = (TeleportProgressPacket)PacketPool.Instance.GetPacket(PacketType.TeleportProgress);
1643  tpProgress.AgentData.AgentID = this.AgentId;
1644  tpProgress.Info.TeleportFlags = flags;
1645  tpProgress.Info.Message = Util.StringToBytes256(message);
1646 
1647  // Hack to get this out immediately and skip throttles
1648  OutPacket(tpProgress, ThrottleOutPacketType.Unknown);
1649  }
1650 
1651  public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item)
1652  {
1653  MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
1654  money.MoneyData.AgentID = AgentId;
1655  money.MoneyData.TransactionID = transaction;
1656  money.MoneyData.TransactionSuccess = success;
1657  money.MoneyData.Description = description;
1658  money.MoneyData.MoneyBalance = balance;
1659  money.TransactionInfo.TransactionType = transactionType;
1660  money.TransactionInfo.SourceID = sourceID;
1661  money.TransactionInfo.IsSourceGroup = sourceIsGroup;
1662  money.TransactionInfo.DestID = destID;
1663  money.TransactionInfo.IsDestGroup = destIsGroup;
1664  money.TransactionInfo.Amount = amount;
1665  money.TransactionInfo.ItemDescription = Util.StringToBytes256(item);
1666 
1667  OutPacket(money, ThrottleOutPacketType.Task);
1668  }
1669 
1670  public void SendPayPrice(UUID objectID, int[] payPrice)
1671  {
1672  if (payPrice[0] == 0 &&
1673  payPrice[1] == 0 &&
1674  payPrice[2] == 0 &&
1675  payPrice[3] == 0 &&
1676  payPrice[4] == 0)
1677  return;
1678 
1679  PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply);
1680  payPriceReply.ObjectData.ObjectID = objectID;
1681  payPriceReply.ObjectData.DefaultPayPrice = payPrice[0];
1682 
1683  payPriceReply.ButtonData = new PayPriceReplyPacket.ButtonDataBlock[4];
1684  payPriceReply.ButtonData[0] = new PayPriceReplyPacket.ButtonDataBlock();
1685  payPriceReply.ButtonData[0].PayButton = payPrice[1];
1686  payPriceReply.ButtonData[1] = new PayPriceReplyPacket.ButtonDataBlock();
1687  payPriceReply.ButtonData[1].PayButton = payPrice[2];
1688  payPriceReply.ButtonData[2] = new PayPriceReplyPacket.ButtonDataBlock();
1689  payPriceReply.ButtonData[2].PayButton = payPrice[3];
1690  payPriceReply.ButtonData[3] = new PayPriceReplyPacket.ButtonDataBlock();
1691  payPriceReply.ButtonData[3].PayButton = payPrice[4];
1692 
1693  OutPacket(payPriceReply, ThrottleOutPacketType.Task);
1694  }
1695 
1696  public void SendStartPingCheck(byte seq)
1697  {
1698  StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
1699  pc.Header.Reliable = false;
1700 
1701  pc.PingID.PingID = seq;
1702  // We *could* get OldestUnacked, but it would hurt performance and not provide any benefit
1703  pc.PingID.OldestUnacked = 0;
1704 
1705  OutPacket(pc, ThrottleOutPacketType.Unknown);
1706  UDPClient.m_lastStartpingTimeMS = Util.EnvironmentTickCount();
1707  }
1708 
1709  public void SendKillObject(List<uint> localIDs)
1710  {
1711  // think we do need this
1712  // foreach (uint id in localIDs)
1713  // m_log.DebugFormat("[CLIENT]: Sending KillObjectPacket to {0} for {1} in {2}", Name, id, regionHandle);
1714 
1715  // remove pending entities
1716  lock (m_entityProps.SyncRoot)
1717  m_entityProps.Remove(localIDs);
1718  lock (m_entityUpdates.SyncRoot)
1719  m_entityUpdates.Remove(localIDs);
1720 
1721  KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
1722  // TODO: don't create new blocks if recycling an old packet
1723  kill.ObjectData = new KillObjectPacket.ObjectDataBlock[localIDs.Count];
1724  for (int i = 0 ; i < localIDs.Count ; i++ )
1725  {
1726  kill.ObjectData[i] = new KillObjectPacket.ObjectDataBlock();
1727  kill.ObjectData[i].ID = localIDs[i];
1728  }
1729  kill.Header.Reliable = true;
1730  kill.Header.Zerocoded = true;
1731 
1732  OutPacket(kill, ThrottleOutPacketType.Task);
1733  }
1734 
1747  public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items,
1748  List<InventoryFolderBase> folders, int version,
1749  bool fetchFolders, bool fetchItems)
1750  {
1751  // An inventory descendents packet consists of a single agent section and an inventory details
1752  // section for each inventory item. The size of each inventory item is approximately 550 bytes.
1753  // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
1754  // packets containing metadata for in excess of 100 items. But in practice, there may be other
1755  // factors (e.g. firewalls) restraining the maximum UDP packet size. See,
1756  //
1757  // http://opensimulator.org/mantis/view.php?id=226
1758  //
1759  // for one example of this kind of thing. In fact, the Linden servers appear to only send about
1760  // 6 to 7 items at a time, so let's stick with 6
1761  int MAX_ITEMS_PER_PACKET = 5;
1762  int MAX_FOLDERS_PER_PACKET = 6;
1763 
1764  int totalItems = fetchItems ? items.Count : 0;
1765  int totalFolders = fetchFolders ? folders.Count : 0;
1766  int itemsSent = 0;
1767  int foldersSent = 0;
1768  int foldersToSend = 0;
1769  int itemsToSend = 0;
1770 
1771  InventoryDescendentsPacket currentPacket = null;
1772 
1773  // Handle empty folders
1774  //
1775  if (totalItems == 0 && totalFolders == 0)
1776  currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, 0, 0);
1777 
1778  // To preserve SL compatibility, we will NOT combine folders and items in one packet
1779  //
1780  while (itemsSent < totalItems || foldersSent < totalFolders)
1781  {
1782  if (currentPacket == null) // Start a new packet
1783  {
1784  foldersToSend = totalFolders - foldersSent;
1785  if (foldersToSend > MAX_FOLDERS_PER_PACKET)
1786  foldersToSend = MAX_FOLDERS_PER_PACKET;
1787 
1788  if (foldersToSend == 0)
1789  {
1790  itemsToSend = totalItems - itemsSent;
1791  if (itemsToSend > MAX_ITEMS_PER_PACKET)
1792  itemsToSend = MAX_ITEMS_PER_PACKET;
1793  }
1794 
1795  currentPacket = CreateInventoryDescendentsPacket(ownerID, folderID, version, items.Count + folders.Count, foldersToSend, itemsToSend);
1796  }
1797 
1798  if (foldersToSend-- > 0)
1799  currentPacket.FolderData[foldersSent % MAX_FOLDERS_PER_PACKET] = CreateFolderDataBlock(folders[foldersSent++]);
1800  else if (itemsToSend-- > 0)
1801  currentPacket.ItemData[itemsSent % MAX_ITEMS_PER_PACKET] = CreateItemDataBlock(items[itemsSent++]);
1802  else
1803  {
1804 // m_log.DebugFormat(
1805 // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
1806  OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
1807  currentPacket = null;
1808  }
1809  }
1810 
1811  if (currentPacket != null)
1812  {
1813 // m_log.DebugFormat(
1814 // "[LLCLIENTVIEW]: Sending inventory folder details packet to {0} for folder {1}", Name, folderID);
1815  OutPacket(currentPacket, ThrottleOutPacketType.Asset, false);
1816  }
1817  }
1818 
1819  private InventoryDescendentsPacket.FolderDataBlock CreateFolderDataBlock(InventoryFolderBase folder)
1820  {
1821  InventoryDescendentsPacket.FolderDataBlock newBlock = new InventoryDescendentsPacket.FolderDataBlock();
1822  newBlock.FolderID = folder.ID;
1823  newBlock.Name = Util.StringToBytes256(folder.Name);
1824  newBlock.ParentID = folder.ParentID;
1825  newBlock.Type = (sbyte)folder.Type;
1826  //if (newBlock.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE)
1827  // newBlock.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE;
1828 
1829  return newBlock;
1830  }
1831 
1832  private InventoryDescendentsPacket.ItemDataBlock CreateItemDataBlock(InventoryItemBase item)
1833  {
1834  InventoryDescendentsPacket.ItemDataBlock newBlock = new InventoryDescendentsPacket.ItemDataBlock();
1835  newBlock.ItemID = item.ID;
1836  newBlock.AssetID = item.AssetID;
1837  newBlock.CreatorID = item.CreatorIdAsUuid;
1838  newBlock.BaseMask = item.BasePermissions;
1839  newBlock.Description = Util.StringToBytes256(item.Description);
1840  newBlock.EveryoneMask = item.EveryOnePermissions;
1841  newBlock.OwnerMask = item.CurrentPermissions;
1842  newBlock.FolderID = item.Folder;
1843  newBlock.InvType = (sbyte)item.InvType;
1844  newBlock.Name = Util.StringToBytes256(item.Name);
1845  newBlock.NextOwnerMask = item.NextPermissions;
1846  newBlock.OwnerID = item.Owner;
1847  newBlock.Type = (sbyte)item.AssetType;
1848 
1849  newBlock.GroupID = item.GroupID;
1850  newBlock.GroupOwned = item.GroupOwned;
1851  newBlock.GroupMask = item.GroupPermissions;
1852  newBlock.CreationDate = item.CreationDate;
1853  newBlock.SalePrice = item.SalePrice;
1854  newBlock.SaleType = item.SaleType;
1855  newBlock.Flags = item.Flags & 0x2000ff;
1856 
1857  newBlock.CRC =
1858  Helpers.InventoryCRC(newBlock.CreationDate, newBlock.SaleType,
1859  newBlock.InvType, newBlock.Type,
1860  newBlock.AssetID, newBlock.GroupID,
1861  newBlock.SalePrice,
1862  newBlock.OwnerID, newBlock.CreatorID,
1863  newBlock.ItemID, newBlock.FolderID,
1864  newBlock.EveryoneMask,
1865  newBlock.Flags, newBlock.OwnerMask,
1866  newBlock.GroupMask, newBlock.NextOwnerMask);
1867 
1868  return newBlock;
1869  }
1870 
1871  private void AddNullFolderBlockToDecendentsPacket(ref InventoryDescendentsPacket packet)
1872  {
1873  packet.FolderData = new InventoryDescendentsPacket.FolderDataBlock[1];
1874  packet.FolderData[0] = new InventoryDescendentsPacket.FolderDataBlock();
1875  packet.FolderData[0].FolderID = UUID.Zero;
1876  packet.FolderData[0].ParentID = UUID.Zero;
1877  packet.FolderData[0].Type = -1;
1878  packet.FolderData[0].Name = new byte[0];
1879  }
1880 
1881  private void AddNullItemBlockToDescendentsPacket(ref InventoryDescendentsPacket packet)
1882  {
1883  packet.ItemData = new InventoryDescendentsPacket.ItemDataBlock[1];
1884  packet.ItemData[0] = new InventoryDescendentsPacket.ItemDataBlock();
1885  packet.ItemData[0].ItemID = UUID.Zero;
1886  packet.ItemData[0].AssetID = UUID.Zero;
1887  packet.ItemData[0].CreatorID = UUID.Zero;
1888  packet.ItemData[0].BaseMask = 0;
1889  packet.ItemData[0].Description = new byte[0];
1890  packet.ItemData[0].EveryoneMask = 0;
1891  packet.ItemData[0].OwnerMask = 0;
1892  packet.ItemData[0].FolderID = UUID.Zero;
1893  packet.ItemData[0].InvType = (sbyte)0;
1894  packet.ItemData[0].Name = new byte[0];
1895  packet.ItemData[0].NextOwnerMask = 0;
1896  packet.ItemData[0].OwnerID = UUID.Zero;
1897  packet.ItemData[0].Type = -1;
1898 
1899  packet.ItemData[0].GroupID = UUID.Zero;
1900  packet.ItemData[0].GroupOwned = false;
1901  packet.ItemData[0].GroupMask = 0;
1902  packet.ItemData[0].CreationDate = 0;
1903  packet.ItemData[0].SalePrice = 0;
1904  packet.ItemData[0].SaleType = 0;
1905  packet.ItemData[0].Flags = 0;
1906 
1907  // No need to add CRC
1908  }
1909 
1910  private InventoryDescendentsPacket CreateInventoryDescendentsPacket(UUID ownerID, UUID folderID, int version, int descendents, int folders, int items)
1911  {
1912  InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
1913  descend.Header.Zerocoded = true;
1914  descend.AgentData.AgentID = AgentId;
1915  descend.AgentData.OwnerID = ownerID;
1916  descend.AgentData.FolderID = folderID;
1917  descend.AgentData.Version = version;
1918  descend.AgentData.Descendents = descendents;
1919 
1920  if (folders > 0)
1921  descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders];
1922  else
1923  AddNullFolderBlockToDecendentsPacket(ref descend);
1924 
1925  if (items > 0)
1926  descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items];
1927  else
1928  AddNullItemBlockToDescendentsPacket(ref descend);
1929 
1930  return descend;
1931  }
1932 
1933  public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
1934  {
1935  // Fudge this value. It's only needed to make the CRC anyway
1936  const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
1937 
1938  FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
1939  // TODO: don't create new blocks if recycling an old packet
1940  inventoryReply.AgentData.AgentID = AgentId;
1941  inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
1942  inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
1943  inventoryReply.InventoryData[0].ItemID = item.ID;
1944  inventoryReply.InventoryData[0].AssetID = item.AssetID;
1945  inventoryReply.InventoryData[0].CreatorID = item.CreatorIdAsUuid;
1946  inventoryReply.InventoryData[0].BaseMask = item.BasePermissions;
1947  inventoryReply.InventoryData[0].CreationDate = item.CreationDate;
1948 
1949  inventoryReply.InventoryData[0].Description = Util.StringToBytes256(item.Description);
1950  inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions;
1951  inventoryReply.InventoryData[0].FolderID = item.Folder;
1952  inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType;
1953  inventoryReply.InventoryData[0].Name = Util.StringToBytes256(item.Name);
1954  inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions;
1955  inventoryReply.InventoryData[0].OwnerID = item.Owner;
1956  inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
1957  inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
1958 
1959  inventoryReply.InventoryData[0].GroupID = item.GroupID;
1960  inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
1961  inventoryReply.InventoryData[0].GroupMask = item.GroupPermissions;
1962  inventoryReply.InventoryData[0].Flags = item.Flags;
1963  inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
1964  inventoryReply.InventoryData[0].SaleType = item.SaleType;
1965 
1966  inventoryReply.InventoryData[0].CRC =
1967  Helpers.InventoryCRC(
1968  1000, 0, inventoryReply.InventoryData[0].InvType,
1969  inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID,
1970  inventoryReply.InventoryData[0].GroupID, 100,
1971  inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID,
1972  inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID,
1973  FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
1974  FULL_MASK_PERMISSIONS);
1975  inventoryReply.Header.Zerocoded = true;
1976  OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
1977  }
1978 
1980  {
1981  // We will use the same transaction id for all the separate packets to be sent out in this update.
1982  UUID transactionId = UUID.Random();
1983 
1984  List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks
1985  = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
1986 
1987  SendBulkUpdateInventoryFolderRecursive(folderBase, ref folderDataBlocks, transactionId);
1988 
1989  if (folderDataBlocks.Count > 0)
1990  {
1991  // We'll end up with some unsent folder blocks if there were some empty folders at the end of the list
1992  // Send these now
1993  BulkUpdateInventoryPacket bulkUpdate
1994  = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
1995  bulkUpdate.Header.Zerocoded = true;
1996 
1997  bulkUpdate.AgentData.AgentID = AgentId;
1998  bulkUpdate.AgentData.TransactionID = transactionId;
1999  bulkUpdate.FolderData = folderDataBlocks.ToArray();
2000  List<BulkUpdateInventoryPacket.ItemDataBlock> foo = new List<BulkUpdateInventoryPacket.ItemDataBlock>();
2001  bulkUpdate.ItemData = foo.ToArray();
2002 
2003  //m_log.Debug("SendBulkUpdateInventory :" + bulkUpdate);
2004  OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
2005  }
2006  }
2007 
2014  private void SendBulkUpdateInventoryFolderRecursive(
2015  InventoryFolderBase folder, ref List<BulkUpdateInventoryPacket.FolderDataBlock> folderDataBlocks,
2016  UUID transactionId)
2017  {
2018  folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
2019 
2020  const int MAX_ITEMS_PER_PACKET = 5;
2021 
2022  IInventoryService invService = m_scene.RequestModuleInterface<IInventoryService>();
2023  // If there are any items then we have to start sending them off in this packet - the next folder will have
2024  // to be in its own bulk update packet. Also, we can only fit 5 items in a packet (at least this was the limit
2025  // being used on the Linden grid at 20081203).
2026  InventoryCollection contents = invService.GetFolderContent(AgentId, folder.ID); // folder.RequestListOfItems();
2027  List<InventoryItemBase> items = contents.Items;
2028  while (items.Count > 0)
2029  {
2030  BulkUpdateInventoryPacket bulkUpdate
2031  = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
2032  bulkUpdate.Header.Zerocoded = true;
2033 
2034  bulkUpdate.AgentData.AgentID = AgentId;
2035  bulkUpdate.AgentData.TransactionID = transactionId;
2036  bulkUpdate.FolderData = folderDataBlocks.ToArray();
2037 
2038  int itemsToSend = (items.Count > MAX_ITEMS_PER_PACKET ? MAX_ITEMS_PER_PACKET : items.Count);
2039  bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[itemsToSend];
2040 
2041  for (int i = 0; i < itemsToSend; i++)
2042  {
2043  // Remove from the end of the list so that we don't incur a performance penalty
2044  bulkUpdate.ItemData[i] = GenerateBulkUpdateItemDataBlock(items[items.Count - 1]);
2045  items.RemoveAt(items.Count - 1);
2046  }
2047 
2048  //m_log.Debug("SendBulkUpdateInventoryRecursive :" + bulkUpdate);
2049  OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
2050 
2051  folderDataBlocks = new List<BulkUpdateInventoryPacket.FolderDataBlock>();
2052 
2053  // If we're going to be sending another items packet then it needs to contain just the folder to which those
2054  // items belong.
2055  if (items.Count > 0)
2056  folderDataBlocks.Add(GenerateBulkUpdateFolderDataBlock(folder));
2057  }
2058 
2059  List<InventoryFolderBase> subFolders = contents.Folders;
2060  foreach (InventoryFolderBase subFolder in subFolders)
2061  {
2062  SendBulkUpdateInventoryFolderRecursive(subFolder, ref folderDataBlocks, transactionId);
2063  }
2064  }
2065 
2071  private BulkUpdateInventoryPacket.FolderDataBlock GenerateBulkUpdateFolderDataBlock(InventoryFolderBase folder)
2072  {
2073  BulkUpdateInventoryPacket.FolderDataBlock folderBlock = new BulkUpdateInventoryPacket.FolderDataBlock();
2074 
2075  folderBlock.FolderID = folder.ID;
2076  folderBlock.ParentID = folder.ParentID;
2077  folderBlock.Type = (sbyte)folder.Type;
2078  // Leaving this here for now, just in case we need to do this for a while
2079  //if (folderBlock.Type == InventoryItemBase.SUITCASE_FOLDER_TYPE)
2080  // folderBlock.Type = InventoryItemBase.SUITCASE_FOLDER_FAKE_TYPE;
2081  folderBlock.Name = Util.StringToBytes256(folder.Name);
2082 
2083  return folderBlock;
2084  }
2085 
2091  private BulkUpdateInventoryPacket.ItemDataBlock GenerateBulkUpdateItemDataBlock(InventoryItemBase item)
2092  {
2093  BulkUpdateInventoryPacket.ItemDataBlock itemBlock = new BulkUpdateInventoryPacket.ItemDataBlock();
2094 
2095  itemBlock.ItemID = item.ID;
2096  itemBlock.AssetID = item.AssetID;
2097  itemBlock.CreatorID = item.CreatorIdAsUuid;
2098  itemBlock.BaseMask = item.BasePermissions;
2099  itemBlock.Description = Util.StringToBytes256(item.Description);
2100  itemBlock.EveryoneMask = item.EveryOnePermissions;
2101  itemBlock.FolderID = item.Folder;
2102  itemBlock.InvType = (sbyte)item.InvType;
2103  itemBlock.Name = Util.StringToBytes256(item.Name);
2104  itemBlock.NextOwnerMask = item.NextPermissions;
2105  itemBlock.OwnerID = item.Owner;
2106  itemBlock.OwnerMask = item.CurrentPermissions;
2107  itemBlock.Type = (sbyte)item.AssetType;
2108  itemBlock.GroupID = item.GroupID;
2109  itemBlock.GroupOwned = item.GroupOwned;
2110  itemBlock.GroupMask = item.GroupPermissions;
2111  itemBlock.Flags = item.Flags & 0x2000ff;
2112  itemBlock.SalePrice = item.SalePrice;
2113  itemBlock.SaleType = item.SaleType;
2114  itemBlock.CreationDate = item.CreationDate;
2115 
2116  itemBlock.CRC =
2117  Helpers.InventoryCRC(
2118  1000, 0, itemBlock.InvType,
2119  itemBlock.Type, itemBlock.AssetID,
2120  itemBlock.GroupID, 100,
2121  itemBlock.OwnerID, itemBlock.CreatorID,
2122  itemBlock.ItemID, itemBlock.FolderID,
2123  (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
2124  (uint)PermissionMask.All);
2125 
2126  return itemBlock;
2127  }
2128 
2130  {
2131  if (node is InventoryItemBase)
2132  SendBulkUpdateInventoryItem((InventoryItemBase)node);
2133  else if (node is InventoryFolderBase)
2134  SendBulkUpdateInventoryFolder((InventoryFolderBase)node);
2135  else if (node != null)
2136  m_log.ErrorFormat("[CLIENT]: {0} sent unknown inventory node named {1}", Name, node.Name);
2137  else
2138  m_log.ErrorFormat("[CLIENT]: {0} sent null inventory node", Name);
2139  }
2140 
2142  {
2143  const uint FULL_MASK_PERMISSIONS = (uint)0x7ffffff;
2144 
2145  BulkUpdateInventoryPacket bulkUpdate
2146  = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
2147 
2148  bulkUpdate.AgentData.AgentID = AgentId;
2149  bulkUpdate.AgentData.TransactionID = UUID.Random();
2150 
2151  bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1];
2152  bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock();
2153  bulkUpdate.FolderData[0].FolderID = UUID.Zero;
2154  bulkUpdate.FolderData[0].ParentID = UUID.Zero;
2155  bulkUpdate.FolderData[0].Type = -1;
2156  bulkUpdate.FolderData[0].Name = new byte[0];
2157 
2158  bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1];
2159  bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock();
2160  bulkUpdate.ItemData[0].ItemID = item.ID;
2161  bulkUpdate.ItemData[0].AssetID = item.AssetID;
2162  bulkUpdate.ItemData[0].CreatorID = item.CreatorIdAsUuid;
2163  bulkUpdate.ItemData[0].BaseMask = item.BasePermissions;
2164  bulkUpdate.ItemData[0].CreationDate = item.CreationDate;
2165  bulkUpdate.ItemData[0].Description = Util.StringToBytes256(item.Description);
2166  bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions;
2167  bulkUpdate.ItemData[0].FolderID = item.Folder;
2168  bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType;
2169  bulkUpdate.ItemData[0].Name = Util.StringToBytes256(item.Name);
2170  bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions;
2171  bulkUpdate.ItemData[0].OwnerID = item.Owner;
2172  bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
2173  bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
2174 
2175  bulkUpdate.ItemData[0].GroupID = item.GroupID;
2176  bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
2177  bulkUpdate.ItemData[0].GroupMask = item.GroupPermissions;
2178  bulkUpdate.ItemData[0].Flags = item.Flags & 0x2000ff;
2179  bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
2180  bulkUpdate.ItemData[0].SaleType = item.SaleType;
2181 
2182  bulkUpdate.ItemData[0].CRC =
2183  Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType,
2184  bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID,
2185  bulkUpdate.ItemData[0].GroupID, 100,
2186  bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID,
2187  bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID,
2188  FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
2189  FULL_MASK_PERMISSIONS);
2190  bulkUpdate.Header.Zerocoded = true;
2191  OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
2192  }
2193 
2194  public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
2195  {
2196  SendInventoryItemCreateUpdate(Item, UUID.Zero, callbackId);
2197  }
2198 
2200  public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId)
2201  {
2202  const uint FULL_MASK_PERMISSIONS = (uint)0x7fffffff;
2203 
2204  UpdateCreateInventoryItemPacket InventoryReply
2205  = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(
2206  PacketType.UpdateCreateInventoryItem);
2207 
2208  // TODO: don't create new blocks if recycling an old packet
2209  InventoryReply.AgentData.AgentID = AgentId;
2210  InventoryReply.AgentData.SimApproved = true;
2211  InventoryReply.AgentData.TransactionID = transactionID;
2212  InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
2213  InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
2214  InventoryReply.InventoryData[0].ItemID = Item.ID;
2215  InventoryReply.InventoryData[0].AssetID = Item.AssetID;
2216  InventoryReply.InventoryData[0].CreatorID = Item.CreatorIdAsUuid;
2217  InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions;
2218  InventoryReply.InventoryData[0].Description = Util.StringToBytes256(Item.Description);
2219  InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions;
2220  InventoryReply.InventoryData[0].FolderID = Item.Folder;
2221  InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType;
2222  InventoryReply.InventoryData[0].Name = Util.StringToBytes256(Item.Name);
2223  InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions;
2224  InventoryReply.InventoryData[0].OwnerID = Item.Owner;
2225  InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
2226  InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
2227  InventoryReply.InventoryData[0].CallbackID = callbackId;
2228 
2229  InventoryReply.InventoryData[0].GroupID = Item.GroupID;
2230  InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
2231  InventoryReply.InventoryData[0].GroupMask = Item.GroupPermissions;
2232  InventoryReply.InventoryData[0].Flags = Item.Flags & 0x2000ff;
2233  InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
2234  InventoryReply.InventoryData[0].SaleType = Item.SaleType;
2235  InventoryReply.InventoryData[0].CreationDate = Item.CreationDate;
2236 
2237  InventoryReply.InventoryData[0].CRC =
2238  Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType,
2239  InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID,
2240  InventoryReply.InventoryData[0].GroupID, 100,
2241  InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID,
2242  InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID,
2243  FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
2244  FULL_MASK_PERMISSIONS);
2245  InventoryReply.Header.Zerocoded = true;
2246  OutPacket(InventoryReply, ThrottleOutPacketType.Asset);
2247  }
2248 
2249  public void SendRemoveInventoryItem(UUID itemID)
2250  {
2251  RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
2252  // TODO: don't create new blocks if recycling an old packet
2253  remove.AgentData.AgentID = AgentId;
2254  remove.AgentData.SessionID = m_sessionId;
2255  remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
2256  remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
2257  remove.InventoryData[0].ItemID = itemID;
2258  remove.Header.Zerocoded = true;
2259  OutPacket(remove, ThrottleOutPacketType.Asset);
2260  }
2261 
2262  public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
2263  {
2264  ScriptControlChangePacket scriptcontrol = (ScriptControlChangePacket)PacketPool.Instance.GetPacket(PacketType.ScriptControlChange);
2265  ScriptControlChangePacket.DataBlock[] data = new ScriptControlChangePacket.DataBlock[1];
2266  ScriptControlChangePacket.DataBlock ddata = new ScriptControlChangePacket.DataBlock();
2267  ddata.Controls = (uint)controls;
2268  ddata.PassToAgent = passToAgent;
2269  ddata.TakeControls = TakeControls;
2270  data[0] = ddata;
2271  scriptcontrol.Data = data;
2272  OutPacket(scriptcontrol, ThrottleOutPacketType.Task);
2273  }
2274 
2275  public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
2276  {
2277  ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
2278  replytask.InventoryData.TaskID = taskID;
2279  replytask.InventoryData.Serial = serial;
2280  replytask.InventoryData.Filename = fileName;
2281  OutPacket(replytask, ThrottleOutPacketType.Task);
2282  }
2283 
2284  public void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory)
2285  {
2286  ThrottleOutPacketType type = ThrottleOutPacketType.Asset;
2287  if (isTaskInventory)
2288  type = ThrottleOutPacketType.Task;
2289 
2290  SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
2291  sendXfer.XferID.ID = xferID;
2292  sendXfer.XferID.Packet = packet;
2293  sendXfer.DataPacket.Data = data;
2294  OutPacket(sendXfer, type);
2295  }
2296 
2297  public void SendAbortXferPacket(ulong xferID)
2298  {
2299  AbortXferPacket xferItem = (AbortXferPacket)PacketPool.Instance.GetPacket(PacketType.AbortXfer);
2300  xferItem.XferID.ID = xferID;
2301  OutPacket(xferItem, ThrottleOutPacketType.Asset);
2302  }
2303 
2304  public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
2305  int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
2306  int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
2307  int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
2308  {
2309  EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData);
2310  economyData.Info.EnergyEfficiency = EnergyEfficiency;
2311  economyData.Info.ObjectCapacity = ObjectCapacity;
2312  economyData.Info.ObjectCount = ObjectCount;
2313  economyData.Info.PriceEnergyUnit = PriceEnergyUnit;
2314  economyData.Info.PriceGroupCreate = PriceGroupCreate;
2315  economyData.Info.PriceObjectClaim = PriceObjectClaim;
2316  economyData.Info.PriceObjectRent = PriceObjectRent;
2317  economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor;
2318  economyData.Info.PriceParcelClaim = PriceParcelClaim;
2319  economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor;
2320  economyData.Info.PriceParcelRent = PriceParcelRent;
2321  economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay;
2322  economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete;
2323  economyData.Info.PriceRentLight = PriceRentLight;
2324  economyData.Info.PriceUpload = PriceUpload;
2325  economyData.Info.TeleportMinPrice = TeleportMinPrice;
2326  economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
2327  economyData.Header.Reliable = true;
2328  OutPacket(economyData, ThrottleOutPacketType.Task);
2329  }
2330 
2331  public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
2332  {
2333  //construct the AvatarPickerReply packet.
2334  AvatarPickerReplyPacket replyPacket = new AvatarPickerReplyPacket();
2335  replyPacket.AgentData.AgentID = AgentData.AgentID;
2336  replyPacket.AgentData.QueryID = AgentData.QueryID;
2337  //int i = 0;
2338  List<AvatarPickerReplyPacket.DataBlock> data_block = new List<AvatarPickerReplyPacket.DataBlock>();
2339  foreach (AvatarPickerReplyDataArgs arg in Data)
2340  {
2341  AvatarPickerReplyPacket.DataBlock db = new AvatarPickerReplyPacket.DataBlock();
2342  db.AvatarID = arg.AvatarID;
2343  db.FirstName = arg.FirstName;
2344  db.LastName = arg.LastName;
2345  data_block.Add(db);
2346  }
2347  replyPacket.Data = data_block.ToArray();
2348  OutPacket(replyPacket, ThrottleOutPacketType.Task);
2349  }
2350 
2351  public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
2352  {
2353  if (agentid == AgentId)
2354  {
2355  ActiveGroupId = activegroupid;
2356  ActiveGroupName = groupname;
2357  ActiveGroupPowers = grouppowers;
2358  }
2359 
2360  AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate);
2361  sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid;
2362  sendAgentDataUpdate.AgentData.AgentID = agentid;
2363  sendAgentDataUpdate.AgentData.FirstName = Util.StringToBytes256(firstname);
2364  sendAgentDataUpdate.AgentData.GroupName = Util.StringToBytes256(groupname);
2365  sendAgentDataUpdate.AgentData.GroupPowers = grouppowers;
2366  sendAgentDataUpdate.AgentData.GroupTitle = Util.StringToBytes256(grouptitle);
2367  sendAgentDataUpdate.AgentData.LastName = Util.StringToBytes256(lastname);
2368  OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task);
2369  }
2370 
2376  public void SendAlertMessage(string message)
2377  {
2378  AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
2379  alertPack.AlertData = new AlertMessagePacket.AlertDataBlock();
2380  alertPack.AlertData.Message = Util.StringToBytes256(message);
2381  alertPack.AlertInfo = new AlertMessagePacket.AlertInfoBlock[0];
2382  OutPacket(alertPack, ThrottleOutPacketType.Task);
2383  }
2384 
2392  public void SendAgentAlertMessage(string message, bool modal)
2393  {
2394  OutPacket(BuildAgentAlertPacket(message, modal), ThrottleOutPacketType.Task);
2395  }
2396 
2403  public AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal)
2404  {
2405  // Prepend a slash to make the message come up in the top right
2406  // again.
2407  // Allow special formats to be sent from aware modules.
2408  if (!modal && !message.StartsWith("ALERT: ") && !message.StartsWith("NOTIFY: ") && message != "Home position set." && message != "You died and have been teleported to your home location")
2409  message = "/" + message;
2410  AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
2411  alertPack.AgentData.AgentID = AgentId;
2412  alertPack.AlertData.Message = Util.StringToBytes256(message);
2413  alertPack.AlertData.Modal = modal;
2414 
2415  return alertPack;
2416  }
2417 
2418  public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message,
2419  string url)
2420  {
2421  LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL);
2422  loadURL.Data.ObjectName = Util.StringToBytes256(objectname);
2423  loadURL.Data.ObjectID = objectID;
2424  loadURL.Data.OwnerID = ownerID;
2425  loadURL.Data.OwnerIsGroup = groupOwned;
2426  loadURL.Data.Message = Util.StringToBytes256(message);
2427  loadURL.Data.URL = Util.StringToBytes256(url);
2428  OutPacket(loadURL, ThrottleOutPacketType.Task);
2429  }
2430 
2431  public void SendDialog(
2432  string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg,
2433  UUID textureID, int ch, string[] buttonlabels)
2434  {
2435  ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
2436  dialog.Data.ObjectID = objectID;
2437  dialog.Data.ObjectName = Util.StringToBytes256(objectname);
2438  // this is the username of the *owner*
2439  dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
2440  dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
2441  dialog.Data.Message = Util.StringToBytes(msg,512);
2442  dialog.Data.ImageID = textureID;
2443  dialog.Data.ChatChannel = ch;
2444  ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length];
2445  for (int i = 0; i < buttonlabels.Length; i++)
2446  {
2447  buttons[i] = new ScriptDialogPacket.ButtonsBlock();
2448  buttons[i].ButtonLabel = Util.StringToBytes(buttonlabels[i],24);
2449  }
2450  dialog.Buttons = buttons;
2451 
2452  dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
2453  dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
2454  dialog.OwnerData[0].OwnerID = ownerID;
2455 
2456  OutPacket(dialog, ThrottleOutPacketType.Task);
2457  }
2458 
2459  public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
2460  {
2461  PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound);
2462  // TODO: don't create new blocks if recycling an old packet
2463  preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
2464  preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
2465  preSound.DataBlock[0].ObjectID = objectID;
2466  preSound.DataBlock[0].OwnerID = ownerID;
2467  preSound.DataBlock[0].SoundID = soundID;
2468  preSound.Header.Zerocoded = true;
2469  OutPacket(preSound, ThrottleOutPacketType.Task);
2470  }
2471 
2472  public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
2473  {
2474  AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound);
2475  sound.DataBlock.SoundID = soundID;
2476  sound.DataBlock.ObjectID = objectID;
2477  sound.DataBlock.OwnerID = ownerID;
2478  sound.DataBlock.Gain = gain;
2479  sound.DataBlock.Flags = flags;
2480 
2481  OutPacket(sound, ThrottleOutPacketType.Task);
2482  }
2483 
2484  public void SendTransferAbort(TransferRequestPacket transferRequest)
2485  {
2486  TransferAbortPacket abort = (TransferAbortPacket)PacketPool.Instance.GetPacket(PacketType.TransferAbort);
2487  abort.TransferInfo.TransferID = transferRequest.TransferInfo.TransferID;
2488  abort.TransferInfo.ChannelType = transferRequest.TransferInfo.ChannelType;
2489  m_log.Debug("[Assets] Aborting transfer; asset request failed");
2490  OutPacket(abort, ThrottleOutPacketType.Task);
2491  }
2492 
2493  public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
2494  {
2495  SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
2496  sound.SoundData.SoundID = soundID;
2497  sound.SoundData.OwnerID = ownerID;
2498  sound.SoundData.ObjectID = objectID;
2499  sound.SoundData.ParentID = parentID;
2500  sound.SoundData.Handle = handle;
2501  sound.SoundData.Position = position;
2502  sound.SoundData.Gain = gain;
2503 
2504  OutPacket(sound, ThrottleOutPacketType.Task);
2505  }
2506 
2507  public void SendAttachedSoundGainChange(UUID objectID, float gain)
2508  {
2509  AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange);
2510  sound.DataBlock.ObjectID = objectID;
2511  sound.DataBlock.Gain = gain;
2512 
2513  OutPacket(sound, ThrottleOutPacketType.Task);
2514  }
2515 
2516  public void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
2517  {
2518  // Viewers based on the Linden viwer code, do wacky things for oribital positions from Midnight to Sunrise
2519  // So adjust for that
2520  // Contributed by: Godfrey
2521 
2522  if (OrbitalPosition > m_sunPainDaHalfOrbitalCutoff) // things get weird from midnight to sunrise
2523  {
2524  OrbitalPosition = (OrbitalPosition - m_sunPainDaHalfOrbitalCutoff) * 0.6666666667f + m_sunPainDaHalfOrbitalCutoff;
2525  }
2526 
2527  SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
2528  viewertime.TimeInfo.SunDirection = Position;
2529  viewertime.TimeInfo.SunAngVelocity = Velocity;
2530 
2531  // Sun module used to add 6 hours to adjust for linden sun hour, adding here
2532  // to prevent existing code from breaking if it assumed that 6 hours were included.
2533  // 21600 == 6 hours * 60 minutes * 60 Seconds
2534  viewertime.TimeInfo.UsecSinceStart = CurrentTime + 21600;
2535 
2536  viewertime.TimeInfo.SecPerDay = SecondsPerSunCycle;
2537  viewertime.TimeInfo.SecPerYear = SecondsPerYear;
2538  viewertime.TimeInfo.SunPhase = OrbitalPosition;
2539  viewertime.Header.Reliable = false;
2540  viewertime.Header.Zerocoded = true;
2541  OutPacket(viewertime, ThrottleOutPacketType.Task);
2542  }
2543 
2544  // Currently Deprecated
2545  public void SendViewerTime(int phase)
2546  {
2547  /*
2548  Console.WriteLine("SunPhase: {0}", phase);
2549  SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
2550  //viewertime.TimeInfo.SecPerDay = 86400;
2551  //viewertime.TimeInfo.SecPerYear = 31536000;
2552  viewertime.TimeInfo.SecPerDay = 1000;
2553  viewertime.TimeInfo.SecPerYear = 365000;
2554  viewertime.TimeInfo.SunPhase = 1;
2555  int sunPhase = (phase + 2) / 2;
2556  if ((sunPhase < 6) || (sunPhase > 36))
2557  {
2558  viewertime.TimeInfo.SunDirection = new Vector3(0f, 0.8f, -0.8f);
2559  Console.WriteLine("sending night");
2560  }
2561  else
2562  {
2563  if (sunPhase < 12)
2564  {
2565  sunPhase = 12;
2566  }
2567  sunPhase = sunPhase - 12;
2568 
2569  float yValue = 0.1f * (sunPhase);
2570  Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue);
2571  if (yValue > 1.2f)
2572  {
2573  yValue = yValue - 1.2f;
2574  }
2575 
2576  yValue = Util.Clip(yValue, 0, 1);
2577 
2578  if (sunPhase < 14)
2579  {
2580  yValue = 1 - yValue;
2581  }
2582  if (sunPhase < 12)
2583  {
2584  yValue *= -1;
2585  }
2586  viewertime.TimeInfo.SunDirection = new Vector3(0f, yValue, 0.3f);
2587  Console.WriteLine("sending sun update " + yValue);
2588  }
2589  viewertime.TimeInfo.SunAngVelocity = new Vector3(0, 0.0f, 10.0f);
2590  viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
2591  viewertime.Header.Reliable = false;
2592  OutPacket(viewertime, ThrottleOutPacketType.Task);
2593  */
2594  }
2595 
2596  public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
2597  {
2598  ViewerEffectPacket packet = (ViewerEffectPacket)PacketPool.Instance.GetPacket(PacketType.ViewerEffect);
2599  packet.Header.Reliable = false;
2600  packet.Header.Zerocoded = true;
2601 
2602  packet.AgentData.AgentID = AgentId;
2603  packet.AgentData.SessionID = SessionId;
2604 
2605  packet.Effect = effectBlocks;
2606 
2607  // OutPacket(packet, ThrottleOutPacketType.State);
2608  OutPacket(packet, ThrottleOutPacketType.Task);
2609  }
2610 
2611  public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember,
2612  string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
2613  UUID partnerID)
2614  {
2615  AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
2616  avatarReply.AgentData.AgentID = AgentId;
2617  avatarReply.AgentData.AvatarID = avatarID;
2618  if (aboutText != null)
2619  avatarReply.PropertiesData.AboutText = Util.StringToBytes1024(aboutText);
2620  else
2621  avatarReply.PropertiesData.AboutText = Utils.EmptyBytes;
2622  avatarReply.PropertiesData.BornOn = Util.StringToBytes256(bornOn);
2623  avatarReply.PropertiesData.CharterMember = charterMember;
2624  if (flAbout != null)
2625  avatarReply.PropertiesData.FLAboutText = Util.StringToBytes256(flAbout);
2626  else
2627  avatarReply.PropertiesData.FLAboutText = Utils.EmptyBytes;
2628  avatarReply.PropertiesData.Flags = flags;
2629  avatarReply.PropertiesData.FLImageID = flImageID;
2630  avatarReply.PropertiesData.ImageID = imageID;
2631  avatarReply.PropertiesData.ProfileURL = Util.StringToBytes256(profileURL);
2632  avatarReply.PropertiesData.PartnerID = partnerID;
2633  OutPacket(avatarReply, ThrottleOutPacketType.Task);
2634  }
2635 
2643  public void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
2644  {
2645  if (!SceneAgent.IsChildAgent)
2646  SendInstantMessage(new GridInstantMessage(null, FromAvatarID, FromAvatarName, AgentId, 1, Message, false, new Vector3()));
2647 
2648  //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
2649  }
2650 
2651  public void SendLogoutPacket()
2652  {
2653  // I know this is a bit of a hack, however there are times when you don't
2654  // want to send this, but still need to do the rest of the shutdown process
2655  // this method gets called from the packet server.. which makes it practically
2656  // impossible to do any other way.
2657 
2658  if (m_SendLogoutPacketWhenClosing)
2659  {
2660  LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
2661  // TODO: don't create new blocks if recycling an old packet
2662  logReply.AgentData.AgentID = AgentId;
2663  logReply.AgentData.SessionID = SessionId;
2664  logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
2665  logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
2666  logReply.InventoryData[0].ItemID = UUID.Zero;
2667 
2668  OutPacket(logReply, ThrottleOutPacketType.Task);
2669  }
2670  }
2671 
2672  public void SendHealth(float health)
2673  {
2674  HealthMessagePacket healthpacket = (HealthMessagePacket)PacketPool.Instance.GetPacket(PacketType.HealthMessage);
2675  healthpacket.HealthData.Health = health;
2676  OutPacket(healthpacket, ThrottleOutPacketType.Task);
2677  }
2678 
2679  public void SendAgentOnline(UUID[] agentIDs)
2680  {
2681  OnlineNotificationPacket onp = new OnlineNotificationPacket();
2682  OnlineNotificationPacket.AgentBlockBlock[] onpb = new OnlineNotificationPacket.AgentBlockBlock[agentIDs.Length];
2683  for (int i = 0; i < agentIDs.Length; i++)
2684  {
2685  OnlineNotificationPacket.AgentBlockBlock onpbl = new OnlineNotificationPacket.AgentBlockBlock();
2686  onpbl.AgentID = agentIDs[i];
2687  onpb[i] = onpbl;
2688  }
2689  onp.AgentBlock = onpb;
2690  onp.Header.Reliable = true;
2691  OutPacket(onp, ThrottleOutPacketType.Task);
2692  }
2693 
2694  public void SendAgentOffline(UUID[] agentIDs)
2695  {
2696  OfflineNotificationPacket offp = new OfflineNotificationPacket();
2697  OfflineNotificationPacket.AgentBlockBlock[] offpb = new OfflineNotificationPacket.AgentBlockBlock[agentIDs.Length];
2698  for (int i = 0; i < agentIDs.Length; i++)
2699  {
2700  OfflineNotificationPacket.AgentBlockBlock onpbl = new OfflineNotificationPacket.AgentBlockBlock();
2701  onpbl.AgentID = agentIDs[i];
2702  offpb[i] = onpbl;
2703  }
2704  offp.AgentBlock = offpb;
2705  offp.Header.Reliable = true;
2706  OutPacket(offp, ThrottleOutPacketType.Task);
2707  }
2708 
2709  public void SendFindAgent(UUID HunterID, UUID PreyID, double GlobalX, double GlobalY)
2710  {
2711  FindAgentPacket fap = new FindAgentPacket();
2712  fap.AgentBlock.Hunter = HunterID;
2713  fap.AgentBlock.Prey = PreyID;
2714  fap.AgentBlock.SpaceIP = 0;
2715 
2716  fap.LocationBlock = new FindAgentPacket.LocationBlockBlock[1];
2717  fap.LocationBlock[0] = new FindAgentPacket.LocationBlockBlock();
2718  fap.LocationBlock[0].GlobalX = GlobalX;
2719  fap.LocationBlock[0].GlobalY = GlobalY;
2720 
2721  OutPacket(fap, ThrottleOutPacketType.Task);
2722  }
2723 
2724  public void SendSitResponse(UUID TargetID, Vector3 OffsetPos,
2725  Quaternion SitOrientation, bool autopilot,
2726  Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
2727  {
2728  AvatarSitResponsePacket avatarSitResponse = new AvatarSitResponsePacket();
2729  avatarSitResponse.SitObject.ID = TargetID;
2730  avatarSitResponse.SitTransform.CameraAtOffset = CameraAtOffset;
2731  avatarSitResponse.SitTransform.CameraEyeOffset = CameraEyeOffset;
2732  avatarSitResponse.SitTransform.ForceMouselook = ForceMouseLook;
2733  avatarSitResponse.SitTransform.AutoPilot = autopilot;
2734  avatarSitResponse.SitTransform.SitPosition = OffsetPos;
2735  avatarSitResponse.SitTransform.SitRotation = SitOrientation;
2736 
2737  OutPacket(avatarSitResponse, ThrottleOutPacketType.Task);
2738  }
2739 
2740  public void SendAdminResponse(UUID Token, uint AdminLevel)
2741  {
2742  GrantGodlikePowersPacket respondPacket = new GrantGodlikePowersPacket();
2743  GrantGodlikePowersPacket.GrantDataBlock gdb = new GrantGodlikePowersPacket.GrantDataBlock();
2744  GrantGodlikePowersPacket.AgentDataBlock adb = new GrantGodlikePowersPacket.AgentDataBlock();
2745 
2746  adb.AgentID = AgentId;
2747  adb.SessionID = SessionId; // More security
2748  gdb.GodLevel = (byte)AdminLevel;
2749  gdb.Token = Token;
2750  //respondPacket.AgentData = (GrantGodlikePowersPacket.AgentDataBlock)ablock;
2751  respondPacket.GrantData = gdb;
2752  respondPacket.AgentData = adb;
2753  OutPacket(respondPacket, ThrottleOutPacketType.Task);
2754  }
2755 
2756  public void SendGroupMembership(GroupMembershipData[] GroupMembership)
2757  {
2758  m_groupPowers.Clear();
2759 
2760  AgentGroupDataUpdatePacket Groupupdate = new AgentGroupDataUpdatePacket();
2761  AgentGroupDataUpdatePacket.GroupDataBlock[] Groups = new AgentGroupDataUpdatePacket.GroupDataBlock[GroupMembership.Length];
2762  for (int i = 0; i < GroupMembership.Length; i++)
2763  {
2764  m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
2765 
2766  AgentGroupDataUpdatePacket.GroupDataBlock Group = new AgentGroupDataUpdatePacket.GroupDataBlock();
2767  Group.AcceptNotices = GroupMembership[i].AcceptNotices;
2768  Group.Contribution = GroupMembership[i].Contribution;
2769  Group.GroupID = GroupMembership[i].GroupID;
2770  Group.GroupInsigniaID = GroupMembership[i].GroupPicture;
2771  Group.GroupName = Util.StringToBytes256(GroupMembership[i].GroupName);
2772  Group.GroupPowers = GroupMembership[i].GroupPowers;
2773  Groups[i] = Group;
2774 
2775 
2776  }
2777  Groupupdate.GroupData = Groups;
2778  Groupupdate.AgentData = new AgentGroupDataUpdatePacket.AgentDataBlock();
2779  Groupupdate.AgentData.AgentID = AgentId;
2780  OutPacket(Groupupdate, ThrottleOutPacketType.Task);
2781 
2782  try
2783  {
2784  IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
2785  if (eq != null)
2786  {
2787  eq.GroupMembership(Groupupdate, this.AgentId);
2788  }
2789  }
2790  catch (Exception ex)
2791  {
2792  m_log.Error("Unable to send group membership data via eventqueue - exception: " + ex.ToString());
2793  m_log.Warn("sending group membership data via UDP");
2794  OutPacket(Groupupdate, ThrottleOutPacketType.Task);
2795  }
2796  }
2797 
2799  {
2800  SceneObjectPart part = (SceneObjectPart)entity;
2801  if (part != null && AgentId != UUID.Zero)
2802  {
2803  try
2804  {
2805  IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
2806  if (eq != null)
2807  {
2808  uint localid = part.LocalId;
2809  byte physshapetype = part.PhysicsShapeType;
2810  float density = part.Density;
2811  float friction = part.Friction;
2812  float bounce = part.Restitution;
2813  float gravmod = part.GravityModifier;
2814 
2815  eq.partPhysicsProperties(localid, physshapetype, density, friction, bounce, gravmod,AgentId);
2816  }
2817  }
2818  catch (Exception ex)
2819  {
2820  m_log.Error("Unable to send part Physics Proprieties - exception: " + ex.ToString());
2821  }
2822  part.UpdatePhysRequired = false;
2823  }
2824  }
2825 
2826 
2827 
2828  public void SendGroupNameReply(UUID groupLLUID, string GroupName)
2829  {
2830  UUIDGroupNameReplyPacket pack = new UUIDGroupNameReplyPacket();
2831  UUIDGroupNameReplyPacket.UUIDNameBlockBlock[] uidnameblock = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock[1];
2832  UUIDGroupNameReplyPacket.UUIDNameBlockBlock uidnamebloc = new UUIDGroupNameReplyPacket.UUIDNameBlockBlock();
2833  uidnamebloc.ID = groupLLUID;
2834  uidnamebloc.GroupName = Util.StringToBytes256(GroupName);
2835  uidnameblock[0] = uidnamebloc;
2836  pack.UUIDNameBlock = uidnameblock;
2837  OutPacket(pack, ThrottleOutPacketType.Task);
2838  }
2839 
2840  public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
2841  {
2842  LandStatReplyPacket lsrp = new LandStatReplyPacket();
2843  // LandStatReplyPacket.RequestDataBlock lsreqdpb = new LandStatReplyPacket.RequestDataBlock();
2844  LandStatReplyPacket.ReportDataBlock[] lsrepdba = new LandStatReplyPacket.ReportDataBlock[lsrpia.Length];
2845  //LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
2846  // lsrepdb.
2847  lsrp.RequestData.ReportType = reportType;
2848  lsrp.RequestData.RequestFlags = requestFlags;
2849  lsrp.RequestData.TotalObjectCount = resultCount;
2850  for (int i = 0; i < lsrpia.Length; i++)
2851  {
2852  LandStatReplyPacket.ReportDataBlock lsrepdb = new LandStatReplyPacket.ReportDataBlock();
2853  lsrepdb.LocationX = lsrpia[i].LocationX;
2854  lsrepdb.LocationY = lsrpia[i].LocationY;
2855  lsrepdb.LocationZ = lsrpia[i].LocationZ;
2856  lsrepdb.Score = lsrpia[i].Score;
2857  lsrepdb.TaskID = lsrpia[i].TaskID;
2858  lsrepdb.TaskLocalID = lsrpia[i].TaskLocalID;
2859  lsrepdb.TaskName = Util.StringToBytes256(lsrpia[i].TaskName);
2860  lsrepdb.OwnerName = Util.StringToBytes256(lsrpia[i].OwnerName);
2861  lsrepdba[i] = lsrepdb;
2862  }
2863  lsrp.ReportData = lsrepdba;
2864  OutPacket(lsrp, ThrottleOutPacketType.Task);
2865  }
2866 
2867  public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
2868  {
2869  ScriptRunningReplyPacket scriptRunningReply = new ScriptRunningReplyPacket();
2870  scriptRunningReply.Script.ObjectID = objectID;
2871  scriptRunningReply.Script.ItemID = itemID;
2872  scriptRunningReply.Script.Running = running;
2873 
2874  OutPacket(scriptRunningReply, ThrottleOutPacketType.Task);
2875  }
2876 
2878  {
2879  if (req.AssetInf.Data == null)
2880  {
2881  m_log.ErrorFormat("{0} Cannot send asset {1} ({2}), asset data is null",
2882  LogHeader, req.AssetInf.ID, req.AssetInf.Metadata.ContentType);
2883  return;
2884  }
2885  int WearableOut = 0;
2886  bool isWearable = false;
2887 
2888  if (req.AssetInf != null)
2889  isWearable =
2890  ((AssetType) req.AssetInf.Type ==
2891  AssetType.Bodypart || (AssetType) req.AssetInf.Type == AssetType.Clothing);
2892 
2893 
2894  //m_log.Debug("sending asset " + req.RequestAssetID + ", iswearable: " + isWearable);
2895 
2896 
2897  //if (isWearable)
2898  // m_log.Debug((AssetType)req.AssetInf.Type);
2899 
2900  TransferInfoPacket Transfer = new TransferInfoPacket();
2901  Transfer.TransferInfo.ChannelType = 2;
2902  Transfer.TransferInfo.Status = 0;
2903  Transfer.TransferInfo.TargetType = 0;
2904  if (req.AssetRequestSource == 2)
2905  {
2906  Transfer.TransferInfo.Params = new byte[20];
2907  Array.Copy(req.RequestAssetID.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
2908  int assType = req.AssetInf.Type;
2909  Array.Copy(Utils.IntToBytes(assType), 0, Transfer.TransferInfo.Params, 16, 4);
2910  }
2911  else if (req.AssetRequestSource == 3)
2912  {
2913  Transfer.TransferInfo.Params = req.Params;
2914  // Transfer.TransferInfo.Params = new byte[100];
2915  //Array.Copy(req.RequestUser.AgentId.GetBytes(), 0, Transfer.TransferInfo.Params, 0, 16);
2916  //Array.Copy(req.RequestUser.SessionId.GetBytes(), 0, Transfer.TransferInfo.Params, 16, 16);
2917  }
2918  Transfer.TransferInfo.Size = req.AssetInf.Data.Length;
2919  Transfer.TransferInfo.TransferID = req.TransferRequestID;
2920  Transfer.Header.Zerocoded = true;
2921  OutPacket(Transfer, isWearable ? ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority : ThrottleOutPacketType.Asset);
2922 
2923  if (req.NumPackets == 1)
2924  {
2925  TransferPacketPacket TransferPacket = new TransferPacketPacket();
2926  TransferPacket.TransferData.Packet = 0;
2927  TransferPacket.TransferData.ChannelType = 2;
2928  TransferPacket.TransferData.TransferID = req.TransferRequestID;
2929  TransferPacket.TransferData.Data = req.AssetInf.Data;
2930  TransferPacket.TransferData.Status = 1;
2931  TransferPacket.Header.Zerocoded = true;
2932  OutPacket(TransferPacket, isWearable ? ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority : ThrottleOutPacketType.Asset);
2933  }
2934  else
2935  {
2936  int processedLength = 0;
2937 // int maxChunkSize = Settings.MAX_PACKET_SIZE - 100;
2938 
2939  int maxChunkSize = (int) MaxTransferBytesPerPacket;
2940  int packetNumber = 0;
2941 
2942  while (processedLength < req.AssetInf.Data.Length)
2943  {
2944  TransferPacketPacket TransferPacket = new TransferPacketPacket();
2945  TransferPacket.TransferData.Packet = packetNumber;
2946  TransferPacket.TransferData.ChannelType = 2;
2947  TransferPacket.TransferData.TransferID = req.TransferRequestID;
2948 
2949  int chunkSize = Math.Min(req.AssetInf.Data.Length - processedLength, maxChunkSize);
2950  byte[] chunk = new byte[chunkSize];
2951  Array.Copy(req.AssetInf.Data, processedLength, chunk, 0, chunk.Length);
2952 
2953  TransferPacket.TransferData.Data = chunk;
2954 
2955  // 0 indicates more packets to come, 1 indicates last packet
2956  if (req.AssetInf.Data.Length - processedLength > maxChunkSize)
2957  {
2958  TransferPacket.TransferData.Status = 0;
2959  }
2960  else
2961  {
2962  TransferPacket.TransferData.Status = 1;
2963  }
2964  TransferPacket.Header.Zerocoded = true;
2965  OutPacket(TransferPacket, isWearable ? ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority : ThrottleOutPacketType.Asset);
2966 
2967  processedLength += chunkSize;
2968  packetNumber++;
2969  }
2970  }
2971  }
2972 
2974  {
2975  TransferInfoPacket Transfer = new TransferInfoPacket();
2976  Transfer.TransferInfo.ChannelType = 2;
2977  Transfer.TransferInfo.Status = -2;
2978  Transfer.TransferInfo.TargetType = 0;
2979  Transfer.TransferInfo.Params = req.Params;
2980  Transfer.TransferInfo.Size = 0;
2981  Transfer.TransferInfo.TransferID = req.TransferRequestID;
2982  Transfer.Header.Zerocoded = true;
2983  OutPacket(Transfer, ThrottleOutPacketType.Asset);
2984  }
2985 
2986  public void SendTexture(AssetBase TextureAsset)
2987  {
2988 
2989  }
2990 
2991  public void SendRegionHandle(UUID regionID, ulong handle)
2992  {
2993  RegionIDAndHandleReplyPacket reply = (RegionIDAndHandleReplyPacket)PacketPool.Instance.GetPacket(PacketType.RegionIDAndHandleReply);
2994  reply.ReplyBlock.RegionID = regionID;
2995  reply.ReplyBlock.RegionHandle = handle;
2996  OutPacket(reply, ThrottleOutPacketType.Land);
2997  }
2998 
2999  public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
3000  {
3001  float dwell = 0.0f;
3002  IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>();
3003  if (dwellModule != null)
3004  dwell = dwellModule.GetDwell(land.GlobalID);
3005  ParcelInfoReplyPacket reply = (ParcelInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelInfoReply);
3006  reply.AgentData.AgentID = m_agentId;
3007  reply.Data.ParcelID = parcelID;
3008  reply.Data.OwnerID = land.OwnerID;
3009  reply.Data.Name = Utils.StringToBytes(land.Name);
3010  if (land != null && land.Description != null && land.Description != String.Empty)
3011  reply.Data.Desc = Utils.StringToBytes(land.Description.Substring(0, land.Description.Length > 254 ? 254: land.Description.Length));
3012  else
3013  reply.Data.Desc = new Byte[0];
3014  reply.Data.ActualArea = land.Area;
3015  reply.Data.BillableArea = land.Area; // TODO: what is this?
3016 
3017  // Bit 0: Mature, bit 7: on sale, other bits: no idea
3018  reply.Data.Flags = (byte)(
3019  (info.AccessLevel > 13 ? (1 << 0) : 0) +
3020  ((land.Flags & (uint)ParcelFlags.ForSale) != 0 ? (1 << 7) : 0));
3021 
3022  Vector3 pos = land.UserLocation;
3023  if (pos.Equals(Vector3.Zero))
3024  {
3025  pos = (land.AABBMax + land.AABBMin) * 0.5f;
3026  }
3027  reply.Data.GlobalX = info.RegionLocX + x;
3028  reply.Data.GlobalY = info.RegionLocY + y;
3029  reply.Data.GlobalZ = pos.Z;
3030  reply.Data.SimName = Utils.StringToBytes(info.RegionName);
3031  reply.Data.SnapshotID = land.SnapshotID;
3032  reply.Data.Dwell = dwell;
3033  reply.Data.SalePrice = land.SalePrice;
3034  reply.Data.AuctionID = (int)land.AuctionID;
3035 
3036  OutPacket(reply, ThrottleOutPacketType.Land);
3037  }
3038 
3039  public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
3040  {
3041  ScriptTeleportRequestPacket packet = (ScriptTeleportRequestPacket)PacketPool.Instance.GetPacket(PacketType.ScriptTeleportRequest);
3042 
3043  packet.Data.ObjectName = Utils.StringToBytes(objName);
3044  packet.Data.SimName = Utils.StringToBytes(simName);
3045  packet.Data.SimPosition = pos;
3046  packet.Data.LookAt = lookAt;
3047 
3048  OutPacket(packet, ThrottleOutPacketType.Task);
3049  }
3050 
3051  public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
3052  {
3053  DirPlacesReplyPacket packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
3054 
3055  packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
3056 
3057  packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
3058  packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
3059 
3060  packet.AgentData.AgentID = AgentId;
3061 
3062  packet.QueryData[0].QueryID = queryID;
3063 
3064  DirPlacesReplyPacket.QueryRepliesBlock[] replies =
3065  new DirPlacesReplyPacket.QueryRepliesBlock[0];
3066  DirPlacesReplyPacket.StatusDataBlock[] status =
3067  new DirPlacesReplyPacket.StatusDataBlock[0];
3068 
3069  packet.QueryReplies = replies;
3070  packet.StatusData = status;
3071 
3072  foreach (DirPlacesReplyData d in data)
3073  {
3074  int idx = replies.Length;
3075  Array.Resize(ref replies, idx + 1);
3076  Array.Resize(ref status, idx + 1);
3077 
3078  replies[idx] = new DirPlacesReplyPacket.QueryRepliesBlock();
3079  status[idx] = new DirPlacesReplyPacket.StatusDataBlock();
3080  replies[idx].ParcelID = d.parcelID;
3081  replies[idx].Name = Utils.StringToBytes(d.name);
3082  replies[idx].ForSale = d.forSale;
3083  replies[idx].Auction = d.auction;
3084  replies[idx].Dwell = d.dwell;
3085  status[idx].Status = d.Status;
3086 
3087  packet.QueryReplies = replies;
3088  packet.StatusData = status;
3089 
3090  if (packet.Length >= 1000)
3091  {
3092  OutPacket(packet, ThrottleOutPacketType.Task);
3093 
3094  packet = (DirPlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPlacesReply);
3095 
3096  packet.AgentData = new DirPlacesReplyPacket.AgentDataBlock();
3097 
3098  packet.QueryData = new DirPlacesReplyPacket.QueryDataBlock[1];
3099  packet.QueryData[0] = new DirPlacesReplyPacket.QueryDataBlock();
3100 
3101  packet.AgentData.AgentID = AgentId;
3102 
3103  packet.QueryData[0].QueryID = queryID;
3104 
3105  replies = new DirPlacesReplyPacket.QueryRepliesBlock[0];
3106  status = new DirPlacesReplyPacket.StatusDataBlock[0];
3107  }
3108  }
3109 
3110  if (replies.Length > 0 || data.Length == 0)
3111  OutPacket(packet, ThrottleOutPacketType.Task);
3112  }
3113 
3114  public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
3115  {
3116  DirPeopleReplyPacket packet = (DirPeopleReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPeopleReply);
3117 
3118  packet.AgentData = new DirPeopleReplyPacket.AgentDataBlock();
3119  packet.AgentData.AgentID = AgentId;
3120 
3121  packet.QueryData = new DirPeopleReplyPacket.QueryDataBlock();
3122  packet.QueryData.QueryID = queryID;
3123 
3124  packet.QueryReplies = new DirPeopleReplyPacket.QueryRepliesBlock[
3125  data.Length];
3126 
3127  int i = 0;
3128  foreach (DirPeopleReplyData d in data)
3129  {
3130  packet.QueryReplies[i] = new DirPeopleReplyPacket.QueryRepliesBlock();
3131  packet.QueryReplies[i].AgentID = d.agentID;
3132  packet.QueryReplies[i].FirstName =
3133  Utils.StringToBytes(d.firstName);
3134  packet.QueryReplies[i].LastName =
3135  Utils.StringToBytes(d.lastName);
3136  packet.QueryReplies[i].Group =
3137  Utils.StringToBytes(d.group);
3138  packet.QueryReplies[i].Online = d.online;
3139  packet.QueryReplies[i].Reputation = d.reputation;
3140  i++;
3141  }
3142 
3143  OutPacket(packet, ThrottleOutPacketType.Task);
3144  }
3145 
3146  public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
3147  {
3148  DirEventsReplyPacket packet = (DirEventsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirEventsReply);
3149 
3150  packet.AgentData = new DirEventsReplyPacket.AgentDataBlock();
3151  packet.AgentData.AgentID = AgentId;
3152 
3153  packet.QueryData = new DirEventsReplyPacket.QueryDataBlock();
3154  packet.QueryData.QueryID = queryID;
3155 
3156  packet.QueryReplies = new DirEventsReplyPacket.QueryRepliesBlock[
3157  data.Length];
3158 
3159  packet.StatusData = new DirEventsReplyPacket.StatusDataBlock[
3160  data.Length];
3161 
3162  int i = 0;
3163  foreach (DirEventsReplyData d in data)
3164  {
3165  packet.QueryReplies[i] = new DirEventsReplyPacket.QueryRepliesBlock();
3166  packet.StatusData[i] = new DirEventsReplyPacket.StatusDataBlock();
3167  packet.QueryReplies[i].OwnerID = d.ownerID;
3168  packet.QueryReplies[i].Name =
3169  Utils.StringToBytes(d.name);
3170  packet.QueryReplies[i].EventID = d.eventID;
3171  packet.QueryReplies[i].Date =
3172  Utils.StringToBytes(d.date);
3173  packet.QueryReplies[i].UnixTime = d.unixTime;
3174  packet.QueryReplies[i].EventFlags = d.eventFlags;
3175  packet.StatusData[i].Status = d.Status;
3176  i++;
3177  }
3178 
3179  OutPacket(packet, ThrottleOutPacketType.Task);
3180  }
3181 
3182  public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
3183  {
3184  DirGroupsReplyPacket packet = (DirGroupsReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirGroupsReply);
3185 
3186  packet.AgentData = new DirGroupsReplyPacket.AgentDataBlock();
3187  packet.AgentData.AgentID = AgentId;
3188 
3189  packet.QueryData = new DirGroupsReplyPacket.QueryDataBlock();
3190  packet.QueryData.QueryID = queryID;
3191 
3192  packet.QueryReplies = new DirGroupsReplyPacket.QueryRepliesBlock[
3193  data.Length];
3194 
3195  int i = 0;
3196  foreach (DirGroupsReplyData d in data)
3197  {
3198  packet.QueryReplies[i] = new DirGroupsReplyPacket.QueryRepliesBlock();
3199  packet.QueryReplies[i].GroupID = d.groupID;
3200  packet.QueryReplies[i].GroupName =
3201  Utils.StringToBytes(d.groupName);
3202  packet.QueryReplies[i].Members = d.members;
3203  packet.QueryReplies[i].SearchOrder = d.searchOrder;
3204  i++;
3205  }
3206 
3207  OutPacket(packet, ThrottleOutPacketType.Task);
3208  }
3209 
3210  public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
3211  {
3212  DirClassifiedReplyPacket packet = (DirClassifiedReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirClassifiedReply);
3213 
3214  packet.AgentData = new DirClassifiedReplyPacket.AgentDataBlock();
3215  packet.AgentData.AgentID = AgentId;
3216 
3217  packet.QueryData = new DirClassifiedReplyPacket.QueryDataBlock();
3218  packet.QueryData.QueryID = queryID;
3219 
3220  packet.QueryReplies = new DirClassifiedReplyPacket.QueryRepliesBlock[
3221  data.Length];
3222  packet.StatusData = new DirClassifiedReplyPacket.StatusDataBlock[
3223  data.Length];
3224 
3225  int i = 0;
3226  foreach (DirClassifiedReplyData d in data)
3227  {
3228  packet.QueryReplies[i] = new DirClassifiedReplyPacket.QueryRepliesBlock();
3229  packet.StatusData[i] = new DirClassifiedReplyPacket.StatusDataBlock();
3230  packet.QueryReplies[i].ClassifiedID = d.classifiedID;
3231  packet.QueryReplies[i].Name =
3232  Utils.StringToBytes(d.name);
3233  packet.QueryReplies[i].ClassifiedFlags = d.classifiedFlags;
3234  packet.QueryReplies[i].CreationDate = d.creationDate;
3235  packet.QueryReplies[i].ExpirationDate = d.expirationDate;
3236  packet.QueryReplies[i].PriceForListing = d.price;
3237  packet.StatusData[i].Status = d.Status;
3238  i++;
3239  }
3240 
3241  OutPacket(packet, ThrottleOutPacketType.Task);
3242  }
3243 
3244  public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
3245  {
3246  DirLandReplyPacket packet = (DirLandReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirLandReply);
3247 
3248  packet.AgentData = new DirLandReplyPacket.AgentDataBlock();
3249  packet.AgentData.AgentID = AgentId;
3250 
3251  packet.QueryData = new DirLandReplyPacket.QueryDataBlock();
3252  packet.QueryData.QueryID = queryID;
3253 
3254  packet.QueryReplies = new DirLandReplyPacket.QueryRepliesBlock[
3255  data.Length];
3256 
3257  int i = 0;
3258  foreach (DirLandReplyData d in data)
3259  {
3260  packet.QueryReplies[i] = new DirLandReplyPacket.QueryRepliesBlock();
3261  packet.QueryReplies[i].ParcelID = d.parcelID;
3262  packet.QueryReplies[i].Name =
3263  Utils.StringToBytes(d.name);
3264  packet.QueryReplies[i].Auction = d.auction;
3265  packet.QueryReplies[i].ForSale = d.forSale;
3266  packet.QueryReplies[i].SalePrice = d.salePrice;
3267  packet.QueryReplies[i].ActualArea = d.actualArea;
3268  i++;
3269  }
3270 
3271  OutPacket(packet, ThrottleOutPacketType.Task);
3272  }
3273 
3274  public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
3275  {
3276  DirPopularReplyPacket packet = (DirPopularReplyPacket)PacketPool.Instance.GetPacket(PacketType.DirPopularReply);
3277 
3278  packet.AgentData = new DirPopularReplyPacket.AgentDataBlock();
3279  packet.AgentData.AgentID = AgentId;
3280 
3281  packet.QueryData = new DirPopularReplyPacket.QueryDataBlock();
3282  packet.QueryData.QueryID = queryID;
3283 
3284  packet.QueryReplies = new DirPopularReplyPacket.QueryRepliesBlock[
3285  data.Length];
3286 
3287  int i = 0;
3288  foreach (DirPopularReplyData d in data)
3289  {
3290  packet.QueryReplies[i] = new DirPopularReplyPacket.QueryRepliesBlock();
3291  packet.QueryReplies[i].ParcelID = d.parcelID;
3292  packet.QueryReplies[i].Name =
3293  Utils.StringToBytes(d.name);
3294  packet.QueryReplies[i].Dwell = d.dwell;
3295  i++;
3296  }
3297 
3298  OutPacket(packet, ThrottleOutPacketType.Task);
3299  }
3300 
3301  public void SendEventInfoReply(EventData data)
3302  {
3303  EventInfoReplyPacket packet = (EventInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.EventInfoReply);
3304 
3305  packet.AgentData = new EventInfoReplyPacket.AgentDataBlock();
3306  packet.AgentData.AgentID = AgentId;
3307 
3308  packet.EventData = new EventInfoReplyPacket.EventDataBlock();
3309  packet.EventData.EventID = data.eventID;
3310  packet.EventData.Creator = Utils.StringToBytes(data.creator);
3311  packet.EventData.Name = Utils.StringToBytes(data.name);
3312  packet.EventData.Category = Utils.StringToBytes(data.category);
3313  packet.EventData.Desc = Utils.StringToBytes(data.description);
3314  packet.EventData.Date = Utils.StringToBytes(data.date);
3315  packet.EventData.DateUTC = data.dateUTC;
3316  packet.EventData.Duration = data.duration;
3317  packet.EventData.Cover = data.cover;
3318  packet.EventData.Amount = data.amount;
3319  packet.EventData.SimName = Utils.StringToBytes(data.simName);
3320  packet.EventData.GlobalPos = new Vector3d(data.globalPos);
3321  packet.EventData.EventFlags = data.eventFlags;
3322 
3323  OutPacket(packet, ThrottleOutPacketType.Task);
3324  }
3325 
3326  public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
3327  {
3328  MapItemReplyPacket mirplk = new MapItemReplyPacket();
3329  mirplk.AgentData.AgentID = AgentId;
3330  mirplk.RequestData.ItemType = mapitemtype;
3331  mirplk.Data = new MapItemReplyPacket.DataBlock[replies.Length];
3332  for (int i = 0; i < replies.Length; i++)
3333  {
3334  MapItemReplyPacket.DataBlock mrdata = new MapItemReplyPacket.DataBlock();
3335  mrdata.X = replies[i].x;
3336  mrdata.Y = replies[i].y;
3337  mrdata.ID = replies[i].id;
3338  mrdata.Extra = replies[i].Extra;
3339  mrdata.Extra2 = replies[i].Extra2;
3340  mrdata.Name = Utils.StringToBytes(replies[i].name);
3341  mirplk.Data[i] = mrdata;
3342  }
3343  //m_log.Debug(mirplk.ToString());
3344  OutPacket(mirplk, ThrottleOutPacketType.Task);
3345 
3346  }
3347 
3348  public void SendOfferCallingCard(UUID srcID, UUID transactionID)
3349  {
3350  // a bit special, as this uses AgentID to store the source instead
3351  // of the destination. The destination (the receiver) goes into destID
3352  OfferCallingCardPacket p = (OfferCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.OfferCallingCard);
3353  p.AgentData.AgentID = srcID;
3354  p.AgentData.SessionID = UUID.Zero;
3355  p.AgentBlock.DestID = AgentId;
3356  p.AgentBlock.TransactionID = transactionID;
3357  OutPacket(p, ThrottleOutPacketType.Task);
3358  }
3359 
3360  public void SendAcceptCallingCard(UUID transactionID)
3361  {
3362  AcceptCallingCardPacket p = (AcceptCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.AcceptCallingCard);
3363  p.AgentData.AgentID = AgentId;
3364  p.AgentData.SessionID = UUID.Zero;
3365  p.FolderData = new AcceptCallingCardPacket.FolderDataBlock[1];
3366  p.FolderData[0] = new AcceptCallingCardPacket.FolderDataBlock();
3367  p.FolderData[0].FolderID = UUID.Zero;
3368  OutPacket(p, ThrottleOutPacketType.Task);
3369  }
3370 
3371  public void SendDeclineCallingCard(UUID transactionID)
3372  {
3373  DeclineCallingCardPacket p = (DeclineCallingCardPacket)PacketPool.Instance.GetPacket(PacketType.DeclineCallingCard);
3374  p.AgentData.AgentID = AgentId;
3375  p.AgentData.SessionID = UUID.Zero;
3376  p.TransactionBlock.TransactionID = transactionID;
3377  OutPacket(p, ThrottleOutPacketType.Task);
3378  }
3379 
3380  public void SendTerminateFriend(UUID exFriendID)
3381  {
3382  TerminateFriendshipPacket p = (TerminateFriendshipPacket)PacketPool.Instance.GetPacket(PacketType.TerminateFriendship);
3383  p.AgentData.AgentID = AgentId;
3384  p.AgentData.SessionID = SessionId;
3385  p.ExBlock.OtherID = exFriendID;
3386  OutPacket(p, ThrottleOutPacketType.Task);
3387  }
3388 
3389  public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
3390  {
3391  OSDMap llsd = new OSDMap(3);
3392  OSDArray AgentData = new OSDArray(1);
3393  OSDMap AgentDataMap = new OSDMap(1);
3394  AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
3395  AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
3396  AgentData.Add(AgentDataMap);
3397  llsd.Add("AgentData", AgentData);
3398  OSDArray GroupData = new OSDArray(data.Length);
3399 // OSDArray NewGroupData = new OSDArray(data.Length);
3400  foreach (GroupMembershipData m in data)
3401  {
3402  OSDMap GroupDataMap = new OSDMap(6);
3403  OSDMap NewGroupDataMap = new OSDMap(1);
3404  GroupDataMap.Add("GroupPowers", OSD.FromULong(m.GroupPowers));
3405  GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
3406  GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
3407  GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
3408  GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
3409  GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
3410 // NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
3411  GroupData.Add(GroupDataMap);
3412 // NewGroupData.Add(NewGroupDataMap);
3413  }
3414  llsd.Add("GroupData", GroupData);
3415  // llsd.Add("NewGroupData", NewGroupData);
3416 
3417  IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
3418  if (eq != null)
3419  {
3420  eq.Enqueue(BuildEvent("AvatarGroupsReply", llsd), this.AgentId);
3421  }
3422  }
3423 
3424  public void SendAgentGroupDataUpdate(UUID avatarID, GroupMembershipData[] data)
3425  {
3426  IEventQueue eq = this.Scene.RequestModuleInterface<IEventQueue>();
3427 
3428  // use UDP if no caps
3429  if (eq == null)
3430  {
3431  SendGroupMembership(data);
3432  }
3433 
3434  OSDMap llsd = new OSDMap(3);
3435  OSDArray AgentData = new OSDArray(1);
3436  OSDMap AgentDataMap = new OSDMap(1);
3437  AgentDataMap.Add("AgentID", OSD.FromUUID(this.AgentId));
3438  AgentDataMap.Add("AvatarID", OSD.FromUUID(avatarID));
3439  AgentData.Add(AgentDataMap);
3440  llsd.Add("AgentData", AgentData);
3441  OSDArray GroupData = new OSDArray(data.Length);
3442  OSDArray NewGroupData = new OSDArray(data.Length);
3443  foreach (GroupMembershipData m in data)
3444  {
3445  OSDMap GroupDataMap = new OSDMap(6);
3446  OSDMap NewGroupDataMap = new OSDMap(1);
3447  GroupDataMap.Add("GroupPowers", OSD.FromULong(m.GroupPowers));
3448  GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(m.AcceptNotices));
3449  GroupDataMap.Add("GroupTitle", OSD.FromString(m.GroupTitle));
3450  GroupDataMap.Add("GroupID", OSD.FromUUID(m.GroupID));
3451  GroupDataMap.Add("GroupName", OSD.FromString(m.GroupName));
3452  GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(m.GroupPicture));
3453  NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(m.ListInProfile));
3454  GroupData.Add(GroupDataMap);
3455  NewGroupData.Add(NewGroupDataMap);
3456  }
3457  llsd.Add("GroupData", GroupData);
3458  llsd.Add("NewGroupData", NewGroupData);
3459 
3460  eq.Enqueue(BuildEvent("AgentGroupDataUpdate", llsd), this.AgentId);
3461  }
3462 
3463  public void SendJoinGroupReply(UUID groupID, bool success)
3464  {
3465  JoinGroupReplyPacket p = (JoinGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.JoinGroupReply);
3466 
3467  p.AgentData = new JoinGroupReplyPacket.AgentDataBlock();
3468  p.AgentData.AgentID = AgentId;
3469 
3470  p.GroupData = new JoinGroupReplyPacket.GroupDataBlock();
3471  p.GroupData.GroupID = groupID;
3472  p.GroupData.Success = success;
3473 
3474  OutPacket(p, ThrottleOutPacketType.Task);
3475  }
3476 
3477  public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
3478  {
3479  EjectGroupMemberReplyPacket p = (EjectGroupMemberReplyPacket)PacketPool.Instance.GetPacket(PacketType.EjectGroupMemberReply);
3480 
3481  p.AgentData = new EjectGroupMemberReplyPacket.AgentDataBlock();
3482  p.AgentData.AgentID = agentID;
3483 
3484  p.GroupData = new EjectGroupMemberReplyPacket.GroupDataBlock();
3485  p.GroupData.GroupID = groupID;
3486 
3487  p.EjectData = new EjectGroupMemberReplyPacket.EjectDataBlock();
3488  p.EjectData.Success = success;
3489 
3490  OutPacket(p, ThrottleOutPacketType.Task);
3491  }
3492 
3493  public void SendLeaveGroupReply(UUID groupID, bool success)
3494  {
3495  LeaveGroupReplyPacket p = (LeaveGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.LeaveGroupReply);
3496 
3497  p.AgentData = new LeaveGroupReplyPacket.AgentDataBlock();
3498  p.AgentData.AgentID = AgentId;
3499 
3500  p.GroupData = new LeaveGroupReplyPacket.GroupDataBlock();
3501  p.GroupData.GroupID = groupID;
3502  p.GroupData.Success = success;
3503 
3504  OutPacket(p, ThrottleOutPacketType.Task);
3505  }
3506 
3507  public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
3508  {
3509  if (classifiedID.Length != name.Length)
3510  return;
3511 
3512  AvatarClassifiedReplyPacket ac =
3513  (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
3514  PacketType.AvatarClassifiedReply);
3515 
3516  ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
3517  ac.AgentData.AgentID = AgentId;
3518  ac.AgentData.TargetID = targetID;
3519 
3520  ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifiedID.Length];
3521  int i;
3522  for (i = 0; i < classifiedID.Length; i++)
3523  {
3524  ac.Data[i].ClassifiedID = classifiedID[i];
3525  ac.Data[i].Name = Utils.StringToBytes(name[i]);
3526  }
3527 
3528  OutPacket(ac, ThrottleOutPacketType.Task);
3529  }
3530 
3531  public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price)
3532  {
3533  ClassifiedInfoReplyPacket cr =
3534  (ClassifiedInfoReplyPacket)PacketPool.Instance.GetPacket(
3535  PacketType.ClassifiedInfoReply);
3536 
3537  cr.AgentData = new ClassifiedInfoReplyPacket.AgentDataBlock();
3538  cr.AgentData.AgentID = AgentId;
3539 
3540  cr.Data = new ClassifiedInfoReplyPacket.DataBlock();
3541  cr.Data.ClassifiedID = classifiedID;
3542  cr.Data.CreatorID = creatorID;
3543  cr.Data.CreationDate = creationDate;
3544  cr.Data.ExpirationDate = expirationDate;
3545  cr.Data.Category = category;
3546  cr.Data.Name = Utils.StringToBytes(name);
3547  cr.Data.Desc = Utils.StringToBytes(description);
3548  cr.Data.ParcelID = parcelID;
3549  cr.Data.ParentEstate = parentEstate;
3550  cr.Data.SnapshotID = snapshotID;
3551  cr.Data.SimName = Utils.StringToBytes(simName);
3552  cr.Data.PosGlobal = new Vector3d(globalPos);
3553  cr.Data.ParcelName = Utils.StringToBytes(parcelName);
3554  cr.Data.ClassifiedFlags = classifiedFlags;
3555  cr.Data.PriceForListing = price;
3556 
3557  OutPacket(cr, ThrottleOutPacketType.Task);
3558  }
3559 
3560  public void SendAgentDropGroup(UUID groupID)
3561  {
3562  AgentDropGroupPacket dg =
3563  (AgentDropGroupPacket)PacketPool.Instance.GetPacket(
3564  PacketType.AgentDropGroup);
3565 
3566  dg.AgentData = new AgentDropGroupPacket.AgentDataBlock();
3567  dg.AgentData.AgentID = AgentId;
3568  dg.AgentData.GroupID = groupID;
3569 
3570  OutPacket(dg, ThrottleOutPacketType.Task);
3571  }
3572 
3573  public void SendAvatarNotesReply(UUID targetID, string text)
3574  {
3575  AvatarNotesReplyPacket an =
3576  (AvatarNotesReplyPacket)PacketPool.Instance.GetPacket(
3577  PacketType.AvatarNotesReply);
3578 
3579  an.AgentData = new AvatarNotesReplyPacket.AgentDataBlock();
3580  an.AgentData.AgentID = AgentId;
3581 
3582  an.Data = new AvatarNotesReplyPacket.DataBlock();
3583  an.Data.TargetID = targetID;
3584  an.Data.Notes = Utils.StringToBytes(text);
3585 
3586  OutPacket(an, ThrottleOutPacketType.Task);
3587  }
3588 
3589  public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
3590  {
3591  AvatarPicksReplyPacket ap =
3592  (AvatarPicksReplyPacket)PacketPool.Instance.GetPacket(
3593  PacketType.AvatarPicksReply);
3594 
3595  ap.AgentData = new AvatarPicksReplyPacket.AgentDataBlock();
3596  ap.AgentData.AgentID = AgentId;
3597  ap.AgentData.TargetID = targetID;
3598 
3599  ap.Data = new AvatarPicksReplyPacket.DataBlock[picks.Count];
3600 
3601  int i = 0;
3602  foreach (KeyValuePair<UUID, string> pick in picks)
3603  {
3604  ap.Data[i] = new AvatarPicksReplyPacket.DataBlock();
3605  ap.Data[i].PickID = pick.Key;
3606  ap.Data[i].PickName = Utils.StringToBytes(pick.Value);
3607  i++;
3608  }
3609 
3610  OutPacket(ap, ThrottleOutPacketType.Task);
3611  }
3612 
3613  public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
3614  {
3615  AvatarClassifiedReplyPacket ac =
3616  (AvatarClassifiedReplyPacket)PacketPool.Instance.GetPacket(
3617  PacketType.AvatarClassifiedReply);
3618 
3619  ac.AgentData = new AvatarClassifiedReplyPacket.AgentDataBlock();
3620  ac.AgentData.AgentID = AgentId;
3621  ac.AgentData.TargetID = targetID;
3622 
3623  ac.Data = new AvatarClassifiedReplyPacket.DataBlock[classifieds.Count];
3624 
3625  int i = 0;
3626  foreach (KeyValuePair<UUID, string> classified in classifieds)
3627  {
3628  ac.Data[i] = new AvatarClassifiedReplyPacket.DataBlock();
3629  ac.Data[i].ClassifiedID = classified.Key;
3630  ac.Data[i].Name = Utils.StringToBytes(classified.Value);
3631  i++;
3632  }
3633 
3634  OutPacket(ac, ThrottleOutPacketType.Task);
3635  }
3636 
3637  public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
3638  {
3639  ParcelDwellReplyPacket pd =
3640  (ParcelDwellReplyPacket)PacketPool.Instance.GetPacket(
3641  PacketType.ParcelDwellReply);
3642 
3643  pd.AgentData = new ParcelDwellReplyPacket.AgentDataBlock();
3644  pd.AgentData.AgentID = AgentId;
3645 
3646  pd.Data = new ParcelDwellReplyPacket.DataBlock();
3647  pd.Data.LocalID = localID;
3648  pd.Data.ParcelID = parcelID;
3649  pd.Data.Dwell = dwell;
3650 
3651  OutPacket(pd, ThrottleOutPacketType.Land);
3652  }
3653 
3654  public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
3655  {
3656  UserInfoReplyPacket ur =
3657  (UserInfoReplyPacket)PacketPool.Instance.GetPacket(
3658  PacketType.UserInfoReply);
3659 
3660  string Visible = "hidden";
3661  if (visible)
3662  Visible = "default";
3663 
3664  ur.AgentData = new UserInfoReplyPacket.AgentDataBlock();
3665  ur.AgentData.AgentID = AgentId;
3666 
3667  ur.UserData = new UserInfoReplyPacket.UserDataBlock();
3668  ur.UserData.IMViaEMail = imViaEmail;
3669  ur.UserData.DirectoryVisibility = Utils.StringToBytes(Visible);
3670  ur.UserData.EMail = Utils.StringToBytes(email);
3671 
3672  OutPacket(ur, ThrottleOutPacketType.Task);
3673  }
3674 
3675  public void SendCreateGroupReply(UUID groupID, bool success, string message)
3676  {
3677  CreateGroupReplyPacket createGroupReply = (CreateGroupReplyPacket)PacketPool.Instance.GetPacket(PacketType.CreateGroupReply);
3678 
3679  createGroupReply.AgentData =
3680  new CreateGroupReplyPacket.AgentDataBlock();
3681  createGroupReply.ReplyData =
3682  new CreateGroupReplyPacket.ReplyDataBlock();
3683 
3684  createGroupReply.AgentData.AgentID = AgentId;
3685  createGroupReply.ReplyData.GroupID = groupID;
3686 
3687  createGroupReply.ReplyData.Success = success;
3688  createGroupReply.ReplyData.Message = Utils.StringToBytes(message);
3689  OutPacket(createGroupReply, ThrottleOutPacketType.Task);
3690  }
3691 
3693  {
3694  UseCachedMuteListPacket useCachedMuteList = (UseCachedMuteListPacket)PacketPool.Instance.GetPacket(PacketType.UseCachedMuteList);
3695 
3696  useCachedMuteList.AgentData = new UseCachedMuteListPacket.AgentDataBlock();
3697  useCachedMuteList.AgentData.AgentID = AgentId;
3698 
3699  OutPacket(useCachedMuteList, ThrottleOutPacketType.Task);
3700  }
3701 
3702  public void SendMuteListUpdate(string filename)
3703  {
3704  MuteListUpdatePacket muteListUpdate = (MuteListUpdatePacket)PacketPool.Instance.GetPacket(PacketType.MuteListUpdate);
3705 
3706  muteListUpdate.MuteData = new MuteListUpdatePacket.MuteDataBlock();
3707  muteListUpdate.MuteData.AgentID = AgentId;
3708  muteListUpdate.MuteData.Filename = Utils.StringToBytes(filename);
3709 
3710  OutPacket(muteListUpdate, ThrottleOutPacketType.Task);
3711  }
3712 
3713  public void SendPickInfoReply(UUID pickID, UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled)
3714  {
3715  PickInfoReplyPacket pickInfoReply = (PickInfoReplyPacket)PacketPool.Instance.GetPacket(PacketType.PickInfoReply);
3716 
3717  pickInfoReply.AgentData = new PickInfoReplyPacket.AgentDataBlock();
3718  pickInfoReply.AgentData.AgentID = AgentId;
3719 
3720  pickInfoReply.Data = new PickInfoReplyPacket.DataBlock();
3721  pickInfoReply.Data.PickID = pickID;
3722  pickInfoReply.Data.CreatorID = creatorID;
3723  pickInfoReply.Data.TopPick = topPick;
3724  pickInfoReply.Data.ParcelID = parcelID;
3725  pickInfoReply.Data.Name = Utils.StringToBytes(name);
3726  pickInfoReply.Data.Desc = Utils.StringToBytes(desc);
3727  pickInfoReply.Data.SnapshotID = snapshotID;
3728  pickInfoReply.Data.User = Utils.StringToBytes(user);
3729  pickInfoReply.Data.OriginalName = Utils.StringToBytes(originalName);
3730  pickInfoReply.Data.SimName = Utils.StringToBytes(simName);
3731  pickInfoReply.Data.PosGlobal = new Vector3d(posGlobal);
3732  pickInfoReply.Data.SortOrder = sortOrder;
3733  pickInfoReply.Data.Enabled = enabled;
3734 
3735  OutPacket(pickInfoReply, ThrottleOutPacketType.Task);
3736  }
3737 
3738  #endregion Scene/Avatar to Client
3739 
3740  // Gesture
3741 
3742  #region Appearance/ Wearables Methods
3743 
3744  public void SendWearables(AvatarWearable[] wearables, int serial)
3745  {
3746  AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
3747  aw.AgentData.AgentID = AgentId;
3748  aw.AgentData.SerialNum = (uint)serial;
3749  aw.AgentData.SessionID = m_sessionId;
3750 
3751  int count = 0;
3752  for (int i = 0; i < wearables.Length; i++)
3753  count += wearables[i].Count;
3754 
3755  // TODO: don't create new blocks if recycling an old packet
3756  aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[count];
3757  AgentWearablesUpdatePacket.WearableDataBlock awb;
3758  int idx = 0;
3759 
3760  for (int i = 0; i < wearables.Length; i++)
3761  {
3762  for (int j = 0; j < wearables[i].Count; j++)
3763  {
3764  awb = new AgentWearablesUpdatePacket.WearableDataBlock();
3765  awb.WearableType = (byte) i;
3766  awb.AssetID = wearables[i][j].AssetID;
3767  awb.ItemID = wearables[i][j].ItemID;
3768  aw.WearableData[idx] = awb;
3769  idx++;
3770 
3771  // m_log.DebugFormat(
3772  // "[APPEARANCE]: Sending wearable item/asset {0} {1} (index {2}) for {3}",
3773  // awb.ItemID, awb.AssetID, i, Name);
3774  }
3775  }
3776 
3777  OutPacket(aw, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
3778  }
3779 
3780  public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
3781  {
3782 // m_log.DebugFormat(
3783 // "[LLCLIENTVIEW]: Sending avatar appearance for {0} with {1} bytes to {2} {3}",
3784 // agentID, textureEntry.Length, Name, AgentId);
3785 
3786  AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
3787  // TODO: don't create new blocks if recycling an old packet
3788  avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[visualParams.Length];
3789  avp.ObjectData.TextureEntry = textureEntry;
3790 
3791  AvatarAppearancePacket.VisualParamBlock avblock = null;
3792  for (int i = 0; i < visualParams.Length; i++)
3793  {
3794  avblock = new AvatarAppearancePacket.VisualParamBlock();
3795  avblock.ParamValue = visualParams[i];
3796  avp.VisualParam[i] = avblock;
3797  }
3798 
3799  avp.Sender.IsTrial = false;
3800  avp.Sender.ID = agentID;
3801  avp.AppearanceData = new AvatarAppearancePacket.AppearanceDataBlock[0];
3802  avp.AppearanceHover = new AvatarAppearancePacket.AppearanceHoverBlock[0];
3803 
3804 // this need be use in future ?
3805 // avp.AppearanceData[0].AppearanceVersion = 0;
3806 // avp.AppearanceData[0].CofVersion = 0;
3807 
3808  //m_log.DebugFormat("[CLIENT]: Sending appearance for {0} to {1}", agentID.ToString(), AgentId.ToString());
3809  OutPacket(avp, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
3810  }
3811 
3812  public void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
3813  {
3814 // m_log.DebugFormat("[LLCLIENTVIEW]: Sending animations for {0} to {1}", sourceAgentId, Name);
3815 
3816  AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
3817  // TODO: don't create new blocks if recycling an old packet
3818  ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[animations.Length];
3819  ani.Sender = new AvatarAnimationPacket.SenderBlock();
3820  ani.Sender.ID = sourceAgentId;
3821  ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
3822  ani.PhysicalAvatarEventList = new AvatarAnimationPacket.PhysicalAvatarEventListBlock[0];
3823 
3824  for (int i = 0; i < animations.Length; ++i)
3825  {
3826  ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock();
3827  ani.AnimationList[i].AnimID = animations[i];
3828  ani.AnimationList[i].AnimSequenceID = seqs[i];
3829 
3830  ani.AnimationSourceList[i] = new AvatarAnimationPacket.AnimationSourceListBlock();
3831  if (objectIDs[i].Equals(sourceAgentId))
3832  ani.AnimationSourceList[i].ObjectID = UUID.Zero;
3833  else
3834  ani.AnimationSourceList[i].ObjectID = objectIDs[i];
3835  }
3836  ani.Header.Reliable = false;
3837  OutPacket(ani, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
3838  }
3839 
3840  #endregion
3841 
3842  #region Avatar Packet/Data Sending Methods
3843 
3848  {
3849 // m_log.DebugFormat(
3850 // "[LLCLIENTVIEW]: Sending immediate object update for avatar {0} {1} to {2} {3}",
3851 // avatar.Name, avatar.UUID, Name, AgentId);
3852 
3853  ScenePresence presence = avatar as ScenePresence;
3854  if (presence == null)
3855  return;
3856 
3857  ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
3858  objupdate.Header.Zerocoded = true;
3859 
3860  objupdate.RegionData.RegionHandle = presence.RegionHandle;
3861 // objupdate.RegionData.TimeDilation = ushort.MaxValue;
3862  objupdate.RegionData.TimeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
3863  objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
3864  objupdate.ObjectData[0] = CreateAvatarUpdateBlock(presence);
3865 
3866  OutPacket(objupdate, ThrottleOutPacketType.Task | ThrottleOutPacketType.HighPriority);
3867 
3868  // We need to record the avatar local id since the root prim of an attachment points to this.
3869 // m_attachmentsSent.Add(avatar.LocalId);
3870  }
3871 
3872  public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
3873  {
3874  // We don't need to update inactive clients.
3875  if (!IsActive)
3876  return;
3877 
3878  CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
3879  loc.Header.Reliable = false;
3880 
3881  // Each packet can only hold around 60 avatar positions and the client clears the mini-map each time
3882  // a CoarseLocationUpdate packet is received. Oh well.
3883  int total = Math.Min(CoarseLocations.Count, 60);
3884 
3885  CoarseLocationUpdatePacket.IndexBlock ib = new CoarseLocationUpdatePacket.IndexBlock();
3886 
3887  loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total];
3888  loc.AgentData = new CoarseLocationUpdatePacket.AgentDataBlock[total];
3889 
3890  int selfindex = -1;
3891  for (int i = 0; i < total; i++)
3892  {
3893  CoarseLocationUpdatePacket.LocationBlock lb =
3894  new CoarseLocationUpdatePacket.LocationBlock();
3895 
3896  lb.X = (byte)CoarseLocations[i].X;
3897  lb.Y = (byte)CoarseLocations[i].Y;
3898 
3899  lb.Z = CoarseLocations[i].Z > 1024 ? (byte)0 : (byte)(CoarseLocations[i].Z * 0.25f);
3900  loc.Location[i] = lb;
3901  loc.AgentData[i] = new CoarseLocationUpdatePacket.AgentDataBlock();
3902  loc.AgentData[i].AgentID = users[i];
3903  if (users[i] == AgentId)
3904  selfindex = i;
3905  }
3906 
3907  ib.You = (short)selfindex;
3908  ib.Prey = -1;
3909  loc.Index = ib;
3910 
3911  OutPacket(loc, ThrottleOutPacketType.Task);
3912  }
3913 
3914  #endregion Avatar Packet/Data Sending Methods
3915 
3916  #region Primitive Packet/Data Sending Methods
3917 
3918 
3923  public void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
3924  {
3925 /*
3926  if (entity.UUID == m_agentId && !updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
3927  {
3928  ImprovedTerseObjectUpdatePacket packet
3929  = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
3930 
3931  packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
3932  packet.RegionData.TimeDilation = Utils.FloatToUInt16(1, 0.0f, 1.0f);
3933  packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
3934  packet.ObjectData[0] = CreateImprovedTerseBlock(entity, false);
3935  OutPacket(packet, ThrottleOutPacketType.Unknown, true);
3936  return;
3937  }
3938 */
3939  if (entity is SceneObjectPart)
3940  {
3941  SceneObjectPart e = (SceneObjectPart)entity;
3942  SceneObjectGroup g = e.ParentGroup;
3943  if (g.HasPrivateAttachmentPoint && g.OwnerID != AgentId)
3944  return; // Don't send updates for other people's HUDs
3945  }
3946 
3947  //double priority = m_prioritizer.GetUpdatePriority(this, entity);
3948  uint priority = m_prioritizer.GetUpdatePriority(this, entity);
3949 
3950  lock (m_entityUpdates.SyncRoot)
3951  m_entityUpdates.Enqueue(priority, new EntityUpdate(entity, updateFlags, m_scene.TimeDilation));
3952  }
3953 
3960  private void ResendPrimUpdate(EntityUpdate update)
3961  {
3962  // If the update exists in priority queue, it will be updated.
3963  // If it does not exist then it will be added with the current (rather than its original) priority
3964  uint priority = m_prioritizer.GetUpdatePriority(this, update.Entity);
3965 
3966  lock (m_entityUpdates.SyncRoot)
3967  m_entityUpdates.Enqueue(priority, update);
3968  }
3969 
3976  private void ResendPrimUpdates(List<EntityUpdate> updates, OutgoingPacket oPacket)
3977  {
3978  // m_log.WarnFormat("[CLIENT] resending prim updates {0}, packet sequence number {1}", updates[0].UpdateTime, oPacket.SequenceNumber);
3979 
3980  // Remove the update packet from the list of packets waiting for acknowledgement
3981  // because we are requeuing the list of updates. They will be resent in new packets
3982  // with the most recent state and priority.
3983  m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
3984 
3985  // Count this as a resent packet since we are going to requeue all of the updates contained in it
3986  Interlocked.Increment(ref m_udpClient.PacketsResent);
3987 
3988  // We're not going to worry about interlock yet since its not currently critical that this total count
3989  // is 100% correct
3990  m_udpServer.PacketsResentCount++;
3991 
3992  foreach (EntityUpdate update in updates)
3993  ResendPrimUpdate(update);
3994  }
3995 
3996  private void ProcessEntityUpdates(int maxUpdates)
3997  {
3998  OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>> objectUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdatePacket.ObjectDataBlock>>();
3999  OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>> compressedUpdateBlocks = new OpenSim.Framework.Lazy<List<ObjectUpdateCompressedPacket.ObjectDataBlock>>();
4000  OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
4001  OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>> terseAgentUpdateBlocks = new OpenSim.Framework.Lazy<List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>>();
4002 
4003  OpenSim.Framework.Lazy<List<EntityUpdate>> objectUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
4004  OpenSim.Framework.Lazy<List<EntityUpdate>> compressedUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
4005  OpenSim.Framework.Lazy<List<EntityUpdate>> terseUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
4006  OpenSim.Framework.Lazy<List<EntityUpdate>> terseAgentUpdates = new OpenSim.Framework.Lazy<List<EntityUpdate>>();
4007 
4008  // Check to see if this is a flush
4009  if (maxUpdates <= 0)
4010  {
4011  maxUpdates = Int32.MaxValue;
4012  }
4013 
4014  int updatesThisCall = 0;
4015 
4016  // We must lock for both manipulating the kill record and sending the packet, in order to avoid a race
4017  // condition where a kill can be processed before an out-of-date update for the same object.
4018 // float avgTimeDilation = 0.0f;
4019  IEntityUpdate iupdate;
4020  Int32 timeinqueue; // this is just debugging code & can be dropped later
4021 
4022  while (updatesThisCall < maxUpdates)
4023  {
4024  lock (m_entityUpdates.SyncRoot)
4025  if (!m_entityUpdates.TryDequeue(out iupdate, out timeinqueue))
4026  break;
4027 
4028  EntityUpdate update = (EntityUpdate)iupdate;
4029 
4030 // avgTimeDilation += update.TimeDilation;
4031 
4032  if (update.Entity is SceneObjectPart)
4033  {
4034  SceneObjectPart part = (SceneObjectPart)update.Entity;
4035 
4036  if (part.ParentGroup.IsDeleted || part.ParentGroup.inTransit)
4037  continue;
4038 
4039  if (part.ParentGroup.IsAttachment)
4040  { // Someone else's HUD, why are we getting these?
4041  if (part.ParentGroup.OwnerID != AgentId && part.ParentGroup.HasPrivateAttachmentPoint)
4042  continue;
4043  ScenePresence sp;
4044  // Owner is not in the sim, don't update it to
4045  // anyone
4046  if (!m_scene.TryGetScenePresence(part.OwnerID, out sp))
4047  continue;
4048 
4049  List<SceneObjectGroup> atts = sp.GetAttachments();
4050  bool found = false;
4051  foreach (SceneObjectGroup att in atts)
4052  {
4053  if (att == part.ParentGroup)
4054  {
4055  found = true;
4056  break;
4057  }
4058  }
4059 
4060  // It's an attachment of a valid avatar, but
4061  // doesn't seem to be attached, skip
4062  if (!found)
4063  continue;
4064 
4065  // On vehicle crossing, the attachments are received
4066  // while the avatar is still a child. Don't send
4067  // updates here because the LocalId has not yet
4068  // been updated and the viewer will derender the
4069  // attachments until the avatar becomes root.
4070  if (sp.IsChildAgent)
4071  continue;
4072 
4073  }
4074 
4075  if (part.ParentGroup.IsAttachment && m_disableFacelights)
4076  {
4077  if (part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.LeftHand &&
4078  part.ParentGroup.RootPart.Shape.State != (byte)AttachmentPoint.RightHand)
4079  {
4080  part.Shape.LightEntry = false;
4081  }
4082 
4083  if (part.Shape != null && (part.Shape.SculptType == (byte)SculptType.Mesh))
4084  {
4085  // Ensure that mesh has at least 8 valid faces
4086  part.Shape.ProfileBegin = 12500;
4087  part.Shape.ProfileEnd = 0;
4088  part.Shape.ProfileHollow = 27500;
4089  }
4090  }
4091 
4092  if (part.Shape != null && (part.Shape.SculptType == (byte)SculptType.Mesh))
4093  {
4094  // Ensure that mesh has at least 8 valid faces
4095  part.Shape.ProfileBegin = 12500;
4096  part.Shape.ProfileEnd = 0;
4097  part.Shape.ProfileHollow = 27500;
4098  }
4099  }
4100  else if (update.Entity is ScenePresence)
4101  {
4102  ScenePresence presence = (ScenePresence)update.Entity;
4103  if (presence.IsDeleted)
4104  continue;
4105  // If ParentUUID is not UUID.Zero and ParentID is 0, this
4106  // avatar is in the process of crossing regions while
4107  // sat on an object. In this state, we don't want any
4108  // updates because they will visually orbit the avatar.
4109  // Update will be forced once crossing is completed anyway.
4110  if (presence.ParentUUID != UUID.Zero && presence.ParentID == 0)
4111  continue;
4112  }
4113 
4114  ++updatesThisCall;
4115 
4116  #region UpdateFlags to packet type conversion
4117 
4118  PrimUpdateFlags updateFlags = (PrimUpdateFlags)update.Flags;
4119 
4120  bool canUseCompressed = true;
4121  bool canUseImproved = true;
4122 
4123  // Compressed object updates only make sense for LL primitives
4124  if (!(update.Entity is SceneObjectPart))
4125  {
4126  canUseCompressed = false;
4127  }
4128 
4129  if (updateFlags.HasFlag(PrimUpdateFlags.FullUpdate))
4130  {
4131  canUseCompressed = false;
4132  canUseImproved = false;
4133  }
4134  else
4135  {
4136  if (updateFlags.HasFlag(PrimUpdateFlags.Velocity) ||
4137  updateFlags.HasFlag(PrimUpdateFlags.Acceleration) ||
4138  updateFlags.HasFlag(PrimUpdateFlags.CollisionPlane) ||
4139  updateFlags.HasFlag(PrimUpdateFlags.Joint))
4140  {
4141  canUseCompressed = false;
4142  }
4143 
4144  if (updateFlags.HasFlag(PrimUpdateFlags.PrimFlags) ||
4145  updateFlags.HasFlag(PrimUpdateFlags.ParentID) ||
4146  updateFlags.HasFlag(PrimUpdateFlags.Scale) ||
4147  updateFlags.HasFlag(PrimUpdateFlags.PrimData) ||
4148  updateFlags.HasFlag(PrimUpdateFlags.Text) ||
4149  updateFlags.HasFlag(PrimUpdateFlags.NameValue) ||
4150  updateFlags.HasFlag(PrimUpdateFlags.ExtraData) ||
4151  updateFlags.HasFlag(PrimUpdateFlags.TextureAnim) ||
4152  updateFlags.HasFlag(PrimUpdateFlags.Sound) ||
4153  updateFlags.HasFlag(PrimUpdateFlags.Particles) ||
4154  updateFlags.HasFlag(PrimUpdateFlags.Material) ||
4155  updateFlags.HasFlag(PrimUpdateFlags.ClickAction) ||
4156  updateFlags.HasFlag(PrimUpdateFlags.MediaURL) ||
4157  updateFlags.HasFlag(PrimUpdateFlags.Joint))
4158  {
4159  canUseImproved = false;
4160  }
4161  }
4162 
4163  #endregion UpdateFlags to packet type conversion
4164 
4165  #region Block Construction
4166 
4167  // TODO: Remove this once we can build compressed updates
4168  canUseCompressed = false;
4169 
4170  if (!canUseImproved && !canUseCompressed)
4171  {
4172  if (update.Entity is ScenePresence)
4173  {
4174  objectUpdateBlocks.Value.Add(CreateAvatarUpdateBlock((ScenePresence)update.Entity));
4175  }
4176  else
4177  {
4178  objectUpdateBlocks.Value.Add(CreatePrimUpdateBlock((SceneObjectPart)update.Entity, this.m_agentId));
4179  }
4180  }
4181  else if (!canUseImproved)
4182  {
4183  compressedUpdateBlocks.Value.Add(CreateCompressedUpdateBlock((SceneObjectPart)update.Entity, updateFlags));
4184  }
4185  else
4186  {
4187  if (update.Entity is ScenePresence)
4188  // ALL presence updates go into a special list
4189  terseAgentUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
4190  else
4191  // Everything else goes here
4192  terseUpdateBlocks.Value.Add(CreateImprovedTerseBlock(update.Entity, updateFlags.HasFlag(PrimUpdateFlags.Textures)));
4193  }
4194 
4195  #endregion Block Construction
4196  }
4197 
4198  #region Packet Sending
4199 
4200 // const float TIME_DILATION = 1.0f;
4201  ushort timeDilation;
4202 // if(updatesThisCall > 0)
4203 // timeDilation = Utils.FloatToUInt16(avgTimeDilation/updatesThisCall, 0.0f, 1.0f);
4204 // else
4205 // timeDilation = ushort.MaxValue; // 1.0;
4206 
4207  timeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
4208 
4209  if (terseAgentUpdateBlocks.IsValueCreated)
4210  {
4211  List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseAgentUpdateBlocks.Value;
4212 
4213  ImprovedTerseObjectUpdatePacket packet
4214  = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
4215  packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
4216  packet.RegionData.TimeDilation = timeDilation;
4217  packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
4218 
4219  for (int i = 0; i < blocks.Count; i++)
4220  packet.ObjectData[i] = blocks[i];
4221 
4222  OutPacket(packet, ThrottleOutPacketType.Unknown, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
4223  }
4224 
4225  if (objectUpdateBlocks.IsValueCreated)
4226  {
4227  List<ObjectUpdatePacket.ObjectDataBlock> blocks = objectUpdateBlocks.Value;
4228 
4229  ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
4230  packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
4231  packet.RegionData.TimeDilation = timeDilation;
4232  packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[blocks.Count];
4233 
4234  for (int i = 0; i < blocks.Count; i++)
4235  packet.ObjectData[i] = blocks[i];
4236 
4237  OutPacket(packet, ThrottleOutPacketType.Task, true);
4238  }
4239 
4240  if (compressedUpdateBlocks.IsValueCreated)
4241  {
4242  List<ObjectUpdateCompressedPacket.ObjectDataBlock> blocks = compressedUpdateBlocks.Value;
4243 
4244  ObjectUpdateCompressedPacket packet = (ObjectUpdateCompressedPacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdateCompressed);
4245  packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
4246  packet.RegionData.TimeDilation = timeDilation;
4247  packet.ObjectData = new ObjectUpdateCompressedPacket.ObjectDataBlock[blocks.Count];
4248 
4249  for (int i = 0; i < blocks.Count; i++)
4250  packet.ObjectData[i] = blocks[i];
4251 
4252  OutPacket(packet, ThrottleOutPacketType.Task, true);
4253  }
4254 
4255  if (terseUpdateBlocks.IsValueCreated)
4256  {
4257  List<ImprovedTerseObjectUpdatePacket.ObjectDataBlock> blocks = terseUpdateBlocks.Value;
4258 
4259  ImprovedTerseObjectUpdatePacket packet
4260  = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
4261  PacketType.ImprovedTerseObjectUpdate);
4262  packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
4263  packet.RegionData.TimeDilation = timeDilation;
4264  packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[blocks.Count];
4265 
4266  for (int i = 0; i < blocks.Count; i++)
4267  packet.ObjectData[i] = blocks[i];
4268 
4269  OutPacket(packet, ThrottleOutPacketType.Task, true, delegate(OutgoingPacket oPacket) { ResendPrimUpdates(terseUpdates.Value, oPacket); });
4270  }
4271 
4272  #endregion Packet Sending
4273  }
4274 
4275  // hack.. dont use
4276  public void SendPartFullUpdate(ISceneEntity ent, uint? parentID)
4277  {
4278  if (ent is SceneObjectPart)
4279  {
4280  SceneObjectPart part = (SceneObjectPart)ent;
4281  ObjectUpdatePacket packet = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
4282  packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
4283  packet.RegionData.TimeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);
4284  packet.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
4285 
4286  ObjectUpdatePacket.ObjectDataBlock blk = CreatePrimUpdateBlock(part, this.m_agentId);
4287  if (parentID.HasValue)
4288  {
4289  blk.ParentID = parentID.Value;
4290  }
4291 
4292  packet.ObjectData[0] = blk;
4293 
4294  OutPacket(packet, ThrottleOutPacketType.Task, true);
4295  }
4296 
4297 // m_log.DebugFormat(
4298 // "[LLCLIENTVIEW]: Sent {0} updates in ProcessEntityUpdates() for {1} {2} in {3}",
4299 // updatesThisCall, Name, SceneAgent.IsChildAgent ? "child" : "root", Scene.Name);
4300 //
4301  }
4302 
4303  public void ReprioritizeUpdates()
4304  {
4305  lock (m_entityUpdates.SyncRoot)
4306  m_entityUpdates.Reprioritize(UpdatePriorityHandler);
4307  }
4308 
4309  private bool UpdatePriorityHandler(ref uint priority, ISceneEntity entity)
4310  {
4311  if (entity != null)
4312  {
4313  priority = m_prioritizer.GetUpdatePriority(this, entity);
4314  return true;
4315  }
4316 
4317  return false;
4318  }
4319 
4320  public void FlushPrimUpdates()
4321  {
4322  m_log.WarnFormat("[CLIENT]: Flushing prim updates to " + m_firstName + " " + m_lastName);
4323 
4324  while (m_entityUpdates.Count > 0)
4325  ProcessEntityUpdates(-1);
4326  }
4327 
4328  #endregion Primitive Packet/Data Sending Methods
4329 
4330  // These are used to implement an adaptive backoff in the number
4331  // of updates converted to packets. Since we don't want packets
4332  // to sit in the queue with old data, only convert enough updates
4333  // to packets that can be sent in 200ms.
4334  private Int32 m_LastQueueFill = 0;
4335  private Int32 m_maxUpdates = 0;
4336 
4337  void HandleQueueEmpty(ThrottleOutPacketTypeFlags categories)
4338  {
4339 // if (!m_udpServer.IsRunningOutbound)
4340 // return;
4341 
4342  if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
4343  {
4344 // if (!m_udpServer.IsRunningOutbound)
4345 // return;
4346 
4347  if (m_maxUpdates == 0 || m_LastQueueFill == 0)
4348  {
4349  m_maxUpdates = m_udpServer.PrimUpdatesPerCallback;
4350  }
4351  else
4352  {
4353  if (Util.EnvironmentTickCountSubtract(m_LastQueueFill) < 200)
4354  m_maxUpdates += 5;
4355  else
4356  m_maxUpdates = m_maxUpdates >> 1;
4357  }
4358  m_maxUpdates = Util.Clamp<Int32>(m_maxUpdates,10,500);
4359  m_LastQueueFill = Util.EnvironmentTickCount();
4360 
4361  if (m_entityUpdates.Count > 0)
4362  ProcessEntityUpdates(m_maxUpdates);
4363 
4364  if (m_entityProps.Count > 0)
4365  ProcessEntityPropertyRequests(m_maxUpdates);
4366  }
4367 
4368  if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
4369  ImageManager.ProcessImageQueue(m_udpServer.TextureSendLimit);
4370  }
4371 
4372  internal bool HandleHasUpdates(ThrottleOutPacketTypeFlags categories)
4373  {
4374  bool hasUpdates = false;
4375 
4376  if ((categories & ThrottleOutPacketTypeFlags.Task) != 0)
4377  {
4378  if (m_entityUpdates.Count > 0)
4379  hasUpdates = true;
4380  else if (m_entityProps.Count > 0)
4381  hasUpdates = true;
4382  }
4383 
4384  if ((categories & ThrottleOutPacketTypeFlags.Texture) != 0)
4385  {
4386  if (ImageManager.HasUpdates())
4387  hasUpdates = true;
4388  }
4389 
4390  return hasUpdates;
4391  }
4392 
4393  public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
4394  {
4395  AssetUploadCompletePacket newPack = new AssetUploadCompletePacket();
4396  newPack.AssetBlock.Type = AssetType;
4397  newPack.AssetBlock.Success = Success;
4398  newPack.AssetBlock.UUID = AssetFullID;
4399  newPack.Header.Zerocoded = true;
4400  OutPacket(newPack, ThrottleOutPacketType.Asset);
4401  }
4402 
4403  public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
4404  {
4405  RequestXferPacket newPack = new RequestXferPacket();
4406  newPack.XferID.ID = XferID;
4407  newPack.XferID.VFileType = AssetType;
4408  newPack.XferID.VFileID = vFileID;
4409  newPack.XferID.FilePath = FilePath;
4410  newPack.XferID.Filename = FileName;
4411  newPack.Header.Zerocoded = true;
4412  OutPacket(newPack, ThrottleOutPacketType.Asset);
4413  }
4414 
4415  public void SendConfirmXfer(ulong xferID, uint PacketID)
4416  {
4417  ConfirmXferPacketPacket newPack = new ConfirmXferPacketPacket();
4418  newPack.XferID.ID = xferID;
4419  newPack.XferID.Packet = PacketID;
4420  newPack.Header.Zerocoded = true;
4421  OutPacket(newPack, ThrottleOutPacketType.Asset);
4422  }
4423 
4424  public void SendInitiateDownload(string simFileName, string clientFileName)
4425  {
4426  InitiateDownloadPacket newPack = new InitiateDownloadPacket();
4427  newPack.AgentData.AgentID = AgentId;
4428  newPack.FileData.SimFilename = Utils.StringToBytes(simFileName);
4429  newPack.FileData.ViewerFilename = Utils.StringToBytes(clientFileName);
4430  OutPacket(newPack, ThrottleOutPacketType.Asset);
4431  }
4432 
4433  public void SendImageFirstPart(
4434  ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
4435  {
4436  ImageDataPacket im = new ImageDataPacket();
4437  im.Header.Reliable = false;
4438  im.ImageID.Packets = numParts;
4439  im.ImageID.ID = ImageUUID;
4440 
4441  if (ImageSize > 0)
4442  im.ImageID.Size = ImageSize;
4443 
4444  im.ImageData.Data = ImageData;
4445  im.ImageID.Codec = imageCodec;
4446  im.Header.Zerocoded = true;
4447  OutPacket(im, ThrottleOutPacketType.Texture);
4448  }
4449 
4450  public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
4451  {
4452  ImagePacketPacket im = new ImagePacketPacket();
4453  im.Header.Reliable = false;
4454  im.ImageID.Packet = partNumber;
4455  im.ImageID.ID = imageUuid;
4456  im.ImageData.Data = imageData;
4457 
4458  OutPacket(im, ThrottleOutPacketType.Texture);
4459  }
4460 
4461  public void SendImageNotFound(UUID imageid)
4462  {
4463  ImageNotInDatabasePacket notFoundPacket
4464  = (ImageNotInDatabasePacket)PacketPool.Instance.GetPacket(PacketType.ImageNotInDatabase);
4465 
4466  notFoundPacket.ImageID.ID = imageid;
4467 
4468  OutPacket(notFoundPacket, ThrottleOutPacketType.Texture);
4469  }
4470 
4472  {
4473  OutPacket(PacketPool.Instance.GetPacket(PacketType.DisableSimulator), ThrottleOutPacketType.Unknown);
4474  }
4475 
4476  public void SendSimStats(SimStats stats)
4477  {
4478  SimStatsPacket pack = new SimStatsPacket();
4479  pack.Region = new SimStatsPacket.RegionBlock();
4480  pack.Region.RegionX = stats.RegionX;
4481  pack.Region.RegionY = stats.RegionY;
4482  pack.Region.RegionFlags = stats.RegionFlags;
4483  pack.Region.ObjectCapacity = stats.ObjectCapacity;
4484  //pack.Region = //stats.RegionBlock;
4485  pack.Stat = stats.StatsBlock;
4486 
4487  pack.Header.Reliable = false;
4488  pack.RegionInfo = new SimStatsPacket.RegionInfoBlock[0];
4489  OutPacket(pack, ThrottleOutPacketType.Task);
4490  }
4491 
4492  private class ObjectPropertyUpdate : IEntityUpdate
4493  {
4494  internal bool SendFamilyProps;
4495  internal bool SendObjectProps;
4496 
4497  public ObjectPropertyUpdate(ISceneEntity entity, uint flags, bool sendfam, bool sendobj)
4498  : base(entity,flags)
4499  {
4500  SendFamilyProps = sendfam;
4501  SendObjectProps = sendobj;
4502  }
4503  public void Update(ObjectPropertyUpdate update)
4504  {
4505  SendFamilyProps = SendFamilyProps || update.SendFamilyProps;
4506  SendObjectProps = SendObjectProps || update.SendObjectProps;
4507  // other properties may need to be updated by base class
4508  base.Update(update);
4509  }
4510  }
4511 
4512  public void SendObjectPropertiesFamilyData(ISceneEntity entity, uint requestFlags)
4513  {
4514  uint priority = 0; // time based ordering only
4515  lock (m_entityProps.SyncRoot)
4516  m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,requestFlags,true,false));
4517  }
4518 
4519  private void ResendPropertyUpdate(ObjectPropertyUpdate update)
4520  {
4521  uint priority = 0;
4522  lock (m_entityProps.SyncRoot)
4523  m_entityProps.Enqueue(priority, update);
4524  }
4525 
4526  private void ResendPropertyUpdates(List<ObjectPropertyUpdate> updates, OutgoingPacket oPacket)
4527  {
4528  // m_log.WarnFormat("[CLIENT] resending object property {0}",updates[0].UpdateTime);
4529 
4530  // Remove the update packet from the list of packets waiting for acknowledgement
4531  // because we are requeuing the list of updates. They will be resent in new packets
4532  // with the most recent state.
4533  m_udpClient.NeedAcks.Remove(oPacket.SequenceNumber);
4534 
4535  // Count this as a resent packet since we are going to requeue all of the updates contained in it
4536  Interlocked.Increment(ref m_udpClient.PacketsResent);
4537 
4538  // We're not going to worry about interlock yet since its not currently critical that this total count
4539  // is 100% correct
4540  m_udpServer.PacketsResentCount++;
4541 
4542  foreach (ObjectPropertyUpdate update in updates)
4543  ResendPropertyUpdate(update);
4544  }
4545 
4547  {
4548  uint priority = 0; // time based ordering only
4549  lock (m_entityProps.SyncRoot)
4550  m_entityProps.Enqueue(priority, new ObjectPropertyUpdate(entity,0,false,true));
4551  }
4552 
4553  private void ProcessEntityPropertyRequests(int maxUpdates)
4554  {
4555  OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>> objectFamilyBlocks =
4556  new OpenSim.Framework.Lazy<List<ObjectPropertiesFamilyPacket.ObjectDataBlock>>();
4557 
4558  OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>> objectPropertiesBlocks =
4559  new OpenSim.Framework.Lazy<List<ObjectPropertiesPacket.ObjectDataBlock>>();
4560 
4561  OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> familyUpdates =
4562  new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
4563 
4564  OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>> propertyUpdates =
4565  new OpenSim.Framework.Lazy<List<ObjectPropertyUpdate>>();
4566 
4567  IEntityUpdate iupdate;
4568  Int32 timeinqueue; // this is just debugging code & can be dropped later
4569 
4570  int updatesThisCall = 0;
4571  while (updatesThisCall < m_maxUpdates)
4572  {
4573  lock (m_entityProps.SyncRoot)
4574  if (!m_entityProps.TryDequeue(out iupdate, out timeinqueue))
4575  break;
4576 
4577  ObjectPropertyUpdate update = (ObjectPropertyUpdate)iupdate;
4578  if (update.SendFamilyProps)
4579  {
4580  if (update.Entity is SceneObjectPart)
4581  {
4582  SceneObjectPart sop = (SceneObjectPart)update.Entity;
4583  ObjectPropertiesFamilyPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesFamilyBlock(sop,update.Flags);
4584  objectFamilyBlocks.Value.Add(objPropDB);
4585  familyUpdates.Value.Add(update);
4586  }
4587  }
4588 
4589  if (update.SendObjectProps)
4590  {
4591  if (update.Entity is SceneObjectPart)
4592  {
4593  SceneObjectPart sop = (SceneObjectPart)update.Entity;
4594  ObjectPropertiesPacket.ObjectDataBlock objPropDB = CreateObjectPropertiesBlock(sop);
4595  objectPropertiesBlocks.Value.Add(objPropDB);
4596  propertyUpdates.Value.Add(update);
4597  }
4598  }
4599 
4600  updatesThisCall++;
4601  }
4602 
4603 
4604  // Int32 ppcnt = 0;
4605  // Int32 pbcnt = 0;
4606 
4607  if (objectPropertiesBlocks.IsValueCreated)
4608  {
4609  List<ObjectPropertiesPacket.ObjectDataBlock> blocks = objectPropertiesBlocks.Value;
4610  List<ObjectPropertyUpdate> updates = propertyUpdates.Value;
4611 
4612  ObjectPropertiesPacket packet = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
4613  packet.ObjectData = new ObjectPropertiesPacket.ObjectDataBlock[blocks.Count];
4614  for (int i = 0; i < blocks.Count; i++)
4615  packet.ObjectData[i] = blocks[i];
4616 
4617  packet.Header.Zerocoded = true;
4618 
4619  // Pass in the delegate so that if this packet needs to be resent, we send the current properties
4620  // of the object rather than the properties when the packet was created
4621  // HACK : Remove intelligent resending until it's fixed in core
4622  //OutPacket(packet, ThrottleOutPacketType.Task, true,
4623  // delegate(OutgoingPacket oPacket)
4624  // {
4625  // ResendPropertyUpdates(updates, oPacket);
4626  // });
4627  OutPacket(packet, ThrottleOutPacketType.Task, true);
4628 
4629  // pbcnt += blocks.Count;
4630  // ppcnt++;
4631  }
4632 
4633  // Int32 fpcnt = 0;
4634  // Int32 fbcnt = 0;
4635 
4636  if (objectFamilyBlocks.IsValueCreated)
4637  {
4638  List<ObjectPropertiesFamilyPacket.ObjectDataBlock> blocks = objectFamilyBlocks.Value;
4639 
4640  // one packet per object block... uggh...
4641  for (int i = 0; i < blocks.Count; i++)
4642  {
4643  ObjectPropertiesFamilyPacket packet =
4644  (ObjectPropertiesFamilyPacket)PacketPool.Instance.GetPacket(PacketType.ObjectPropertiesFamily);
4645 
4646  packet.ObjectData = blocks[i];
4647  packet.Header.Zerocoded = true;
4648 
4649  // Pass in the delegate so that if this packet needs to be resent, we send the current properties
4650  // of the object rather than the properties when the packet was created
4651  List<ObjectPropertyUpdate> updates = new List<ObjectPropertyUpdate>();
4652  updates.Add(familyUpdates.Value[i]);
4653  // HACK : Remove intelligent resending until it's fixed in core
4654  //OutPacket(packet, ThrottleOutPacketType.Task, true,
4655  // delegate(OutgoingPacket oPacket)
4656  // {
4657  // ResendPropertyUpdates(updates, oPacket);
4658  // });
4659  OutPacket(packet, ThrottleOutPacketType.Task, true);
4660 
4661  // fpcnt++;
4662  // fbcnt++;
4663  }
4664 
4665  }
4666 
4667  // m_log.WarnFormat("[PACKETCOUNTS] queued {0} property packets with {1} blocks",ppcnt,pbcnt);
4668  // m_log.WarnFormat("[PACKETCOUNTS] queued {0} family property packets with {1} blocks",fpcnt,fbcnt);
4669  }
4670 
4671  private ObjectPropertiesFamilyPacket.ObjectDataBlock CreateObjectPropertiesFamilyBlock(SceneObjectPart sop, uint requestFlags)
4672  {
4673  ObjectPropertiesFamilyPacket.ObjectDataBlock block = new ObjectPropertiesFamilyPacket.ObjectDataBlock();
4674 
4675  block.RequestFlags = requestFlags;
4676  block.ObjectID = sop.UUID;
4677  if (sop.OwnerID == sop.GroupID)
4678  block.OwnerID = UUID.Zero;
4679  else
4680  block.OwnerID = sop.OwnerID;
4681  block.GroupID = sop.GroupID;
4682  block.BaseMask = sop.BaseMask;
4683  block.OwnerMask = sop.OwnerMask;
4684  block.GroupMask = sop.GroupMask;
4685  block.EveryoneMask = sop.EveryoneMask;
4686  block.NextOwnerMask = sop.NextOwnerMask;
4687 
4688  // TODO: More properties are needed in SceneObjectPart!
4689  block.OwnershipCost = sop.OwnershipCost;
4690  block.SaleType = sop.ObjectSaleType;
4691  block.SalePrice = sop.SalePrice;
4692  block.Category = sop.Category;
4693  block.LastOwnerID = sop.CreatorID; // copied from old SOG call... is this right?
4694  block.Name = Util.StringToBytes256(sop.Name);
4695  block.Description = Util.StringToBytes256(sop.Description);
4696 
4697  return block;
4698  }
4699 
4700  private ObjectPropertiesPacket.ObjectDataBlock CreateObjectPropertiesBlock(SceneObjectPart sop)
4701  {
4702  //ObjectPropertiesPacket proper = (ObjectPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ObjectProperties);
4703  // TODO: don't create new blocks if recycling an old packet
4704 
4705  ObjectPropertiesPacket.ObjectDataBlock block =
4706  new ObjectPropertiesPacket.ObjectDataBlock();
4707 
4708  block.ObjectID = sop.UUID;
4709  block.Name = Util.StringToBytes256(sop.Name);
4710  block.Description = Util.StringToBytes256(sop.Description);
4711 
4712  block.CreationDate = (ulong)sop.CreationDate * 1000000; // viewer wants date in microseconds
4713  block.CreatorID = sop.CreatorID;
4714  block.GroupID = sop.GroupID;
4715  block.LastOwnerID = sop.LastOwnerID;
4716  if (sop.OwnerID == sop.GroupID)
4717  block.OwnerID = UUID.Zero;
4718  else
4719  block.OwnerID = sop.OwnerID;
4720 
4721  block.ItemID = sop.FromUserInventoryItemID;
4722  block.FolderID = UUID.Zero; // sog.FromFolderID ??
4723  block.FromTaskID = UUID.Zero; // ???
4724  block.InventorySerial = (short)sop.InventorySerial;
4725 
4726  SceneObjectPart root = sop.ParentGroup.RootPart;
4727 
4728  block.TouchName = Util.StringToBytes256(root.TouchName);
4729 
4730  // SL 3.3.4, at least, appears to read this information as a concatenated byte[] stream of UUIDs but
4731  // it's not yet clear whether this is actually used. If this is done in the future then a pre-cached
4732  // copy is really needed since it's less efficient to be constantly recreating this byte array.
4733 // using (MemoryStream memStream = new MemoryStream())
4734 // {
4735 // using (BinaryWriter binWriter = new BinaryWriter(memStream))
4736 // {
4737 // for (int i = 0; i < sop.GetNumberOfSides(); i++)
4738 // {
4739 // Primitive.TextureEntryFace teFace = sop.Shape.Textures.FaceTextures[i];
4740 //
4741 // UUID textureID;
4742 //
4743 // if (teFace != null)
4744 // textureID = teFace.TextureID;
4745 // else
4746 // textureID = sop.Shape.Textures.DefaultTexture.TextureID;
4747 //
4748 // binWriter.Write(textureID.GetBytes());
4749 // }
4750 //
4751 // block.TextureID = memStream.ToArray();
4752 // }
4753 // }
4754 
4755  block.TextureID = new byte[0]; // TextureID ???
4756  block.SitName = Util.StringToBytes256(root.SitName);
4757  block.OwnerMask = root.OwnerMask;
4758  block.NextOwnerMask = root.NextOwnerMask;
4759  block.GroupMask = root.GroupMask;
4760  block.EveryoneMask = root.EveryoneMask;
4761  block.BaseMask = root.BaseMask;
4762  block.SaleType = root.ObjectSaleType;
4763  block.SalePrice = root.SalePrice;
4764 
4765  return block;
4766  }
4767 
4768  #region Estate Data Sending Methods
4769 
4770  private static bool convertParamStringToBool(byte[] field)
4771  {
4772  string s = Utils.BytesToString(field);
4773  if (s == "1" || s.ToLower() == "y" || s.ToLower() == "yes" || s.ToLower() == "t" || s.ToLower() == "true")
4774  {
4775  return true;
4776  }
4777  return false;
4778  }
4779 
4780  public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
4781 
4782  {
4783  EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
4784  packet.AgentData.TransactionID = UUID.Random();
4785  packet.AgentData.AgentID = AgentId;
4786  packet.AgentData.SessionID = SessionId;
4787  packet.MethodData.Invoice = invoice;
4788  packet.MethodData.Method = Utils.StringToBytes("setaccess");
4789 
4790  EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + Data.Length];
4791 
4792  for (int i = 0; i < (6 + Data.Length); i++)
4793  {
4794  returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
4795  }
4796  int j = 0;
4797 
4798  returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
4799  returnblock[j].Parameter = Utils.StringToBytes(code.ToString()); j++;
4800  returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
4801  returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
4802  returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
4803  returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
4804 
4805  j = 2; // Agents
4806  if ((code & 2) != 0)
4807  j = 3; // Groups
4808  if ((code & 8) != 0)
4809  j = 5; // Managers
4810 
4811  returnblock[j].Parameter = Utils.StringToBytes(Data.Length.ToString());
4812  j = 6;
4813 
4814  for (int i = 0; i < Data.Length; i++)
4815  {
4816  returnblock[j].Parameter = Data[i].GetBytes(); j++;
4817  }
4818  packet.ParamList = returnblock;
4819  packet.Header.Reliable = true;
4820  OutPacket(packet, ThrottleOutPacketType.Task);
4821  }
4822 
4823  public void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
4824  {
4825  List<UUID> BannedUsers = new List<UUID>();
4826 
4827  for (int i = 0; i < bl.Length; i++)
4828  {
4829  if (bl[i] == null)
4830  continue;
4831  if (bl[i].BannedUserID == UUID.Zero)
4832  continue;
4833  BannedUsers.Add(bl[i].BannedUserID);
4834 
4835  if (BannedUsers.Count >= 50 || (i == (bl.Length - 1) && BannedUsers.Count > 0))
4836  {
4837  EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
4838  packet.AgentData.TransactionID = UUID.Random();
4839  packet.AgentData.AgentID = AgentId;
4840  packet.AgentData.SessionID = SessionId;
4841  packet.MethodData.Invoice = invoice;
4842  packet.MethodData.Method = Utils.StringToBytes("setaccess");
4843 
4844  EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[6 + BannedUsers.Count];
4845 
4846  int j;
4847  for (j = 0; j < (6 + BannedUsers.Count); j++)
4848  {
4849  returnblock[j] = new EstateOwnerMessagePacket.ParamListBlock();
4850  }
4851  j = 0;
4852 
4853  returnblock[j].Parameter = Utils.StringToBytes(estateID.ToString()); j++;
4854  returnblock[j].Parameter = Utils.StringToBytes(((int)Constants.EstateAccessCodex.EstateBans).ToString()); j++;
4855  returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
4856  returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
4857  returnblock[j].Parameter = Utils.StringToBytes(BannedUsers.Count.ToString()); j++;
4858  returnblock[j].Parameter = Utils.StringToBytes("0"); j++;
4859 
4860  foreach (UUID banned in BannedUsers)
4861  {
4862  returnblock[j].Parameter = banned.GetBytes(); j++;
4863  }
4864  packet.ParamList = returnblock;
4865  packet.Header.Reliable = true;
4866  OutPacket(packet, ThrottleOutPacketType.Task);
4867 
4868  BannedUsers.Clear();
4869  }
4870  }
4871 
4872  }
4873 
4875  {
4876  RegionInfoPacket rinfopack = new RegionInfoPacket();
4877  RegionInfoPacket.RegionInfoBlock rinfoblk = new RegionInfoPacket.RegionInfoBlock();
4878  rinfopack.AgentData.AgentID = AgentId;
4879  rinfopack.AgentData.SessionID = SessionId;
4880  rinfoblk.BillableFactor = args.billableFactor;
4881  rinfoblk.EstateID = args.estateID;
4882  rinfoblk.MaxAgents = args.maxAgents;
4883  rinfoblk.ObjectBonusFactor = args.objectBonusFactor;
4884  rinfoblk.ParentEstateID = args.parentEstateID;
4885  rinfoblk.PricePerMeter = args.pricePerMeter;
4886  rinfoblk.RedirectGridX = args.redirectGridX;
4887  rinfoblk.RedirectGridY = args.redirectGridY;
4888  rinfoblk.RegionFlags = args.regionFlags;
4889  rinfoblk.SimAccess = args.simAccess;
4890  rinfoblk.SunHour = args.sunHour;
4891  rinfoblk.TerrainLowerLimit = args.terrainLowerLimit;
4892  rinfoblk.TerrainRaiseLimit = args.terrainRaiseLimit;
4893  rinfoblk.UseEstateSun = args.useEstateSun;
4894  rinfoblk.WaterHeight = args.waterHeight;
4895  rinfoblk.SimName = Utils.StringToBytes(args.simName);
4896 
4897  rinfopack.RegionInfo2 = new RegionInfoPacket.RegionInfo2Block();
4898  rinfopack.RegionInfo2.HardMaxAgents = uint.MaxValue;
4899  rinfopack.RegionInfo2.HardMaxObjects = uint.MaxValue;
4900  rinfopack.RegionInfo2.MaxAgents32 = uint.MaxValue;
4901  rinfopack.RegionInfo2.ProductName = Util.StringToBytes256(args.regionType);
4902  rinfopack.RegionInfo2.ProductSKU = Utils.EmptyBytes;
4903 
4904  rinfopack.HasVariableBlocks = true;
4905  rinfopack.RegionInfo = rinfoblk;
4906  rinfopack.AgentData = new RegionInfoPacket.AgentDataBlock();
4907  rinfopack.AgentData.AgentID = AgentId;
4908  rinfopack.AgentData.SessionID = SessionId;
4909  rinfopack.RegionInfo3 = new RegionInfoPacket.RegionInfo3Block[0];
4910 
4911  OutPacket(rinfopack, ThrottleOutPacketType.Task);
4912  }
4913 
4914  public void SendEstateCovenantInformation(UUID covenant)
4915  {
4916 // m_log.DebugFormat("[LLCLIENTVIEW]: Sending estate covenant asset id of {0} to {1}", covenant, Name);
4917 
4918  EstateCovenantReplyPacket einfopack = new EstateCovenantReplyPacket();
4919  EstateCovenantReplyPacket.DataBlock edata = new EstateCovenantReplyPacket.DataBlock();
4920  edata.CovenantID = covenant;
4921  edata.CovenantTimestamp = (uint) m_scene.RegionInfo.RegionSettings.CovenantChangedDateTime;
4922  edata.EstateOwnerID = m_scene.RegionInfo.EstateSettings.EstateOwner;
4923  edata.EstateName = Utils.StringToBytes(m_scene.RegionInfo.EstateSettings.EstateName);
4924  einfopack.Data = edata;
4925  OutPacket(einfopack, ThrottleOutPacketType.Task);
4926  }
4927 
4929  UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition,
4930  UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
4931  {
4932 // m_log.DebugFormat(
4933 // "[LLCLIENTVIEW]: Sending detailed estate data to {0} with covenant asset id {1}", Name, covenant);
4934 
4935  EstateOwnerMessagePacket packet = new EstateOwnerMessagePacket();
4936  packet.MethodData.Invoice = invoice;
4937  packet.AgentData.TransactionID = UUID.Random();
4938  packet.MethodData.Method = Utils.StringToBytes("estateupdateinfo");
4939  EstateOwnerMessagePacket.ParamListBlock[] returnblock = new EstateOwnerMessagePacket.ParamListBlock[10];
4940 
4941  for (int i = 0; i < 10; i++)
4942  {
4943  returnblock[i] = new EstateOwnerMessagePacket.ParamListBlock();
4944  }
4945 
4946  //Sending Estate Settings
4947  returnblock[0].Parameter = Utils.StringToBytes(estateName);
4948  returnblock[1].Parameter = Utils.StringToBytes(estateOwner.ToString());
4949  returnblock[2].Parameter = Utils.StringToBytes(estateID.ToString());
4950 
4951  returnblock[3].Parameter = Utils.StringToBytes(estateFlags.ToString());
4952  returnblock[4].Parameter = Utils.StringToBytes(sunPosition.ToString());
4953  returnblock[5].Parameter = Utils.StringToBytes(parentEstate.ToString());
4954  returnblock[6].Parameter = Utils.StringToBytes(covenant.ToString());
4955  returnblock[7].Parameter = Utils.StringToBytes(covenantChanged.ToString());
4956  returnblock[8].Parameter = Utils.StringToBytes("1"); // what is this?
4957  returnblock[9].Parameter = Utils.StringToBytes(abuseEmail);
4958 
4959  packet.ParamList = returnblock;
4960  packet.Header.Reliable = false;
4961  //m_log.Debug("[ESTATE]: SIM--->" + packet.ToString());
4962  OutPacket(packet, ThrottleOutPacketType.Task);
4963  }
4964 
4965  public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
4966  {
4967  TelehubInfoPacket packet = (TelehubInfoPacket)PacketPool.Instance.GetPacket(PacketType.TelehubInfo);
4968  packet.TelehubBlock.ObjectID = ObjectID;
4969  packet.TelehubBlock.ObjectName = Utils.StringToBytes(ObjectName);
4970  packet.TelehubBlock.TelehubPos = ObjectPos;
4971  packet.TelehubBlock.TelehubRot = ObjectRot;
4972 
4973  packet.SpawnPointBlock = new TelehubInfoPacket.SpawnPointBlockBlock[SpawnPoint.Count];
4974  for (int n = 0; n < SpawnPoint.Count; n++)
4975  {
4976  packet.SpawnPointBlock[n] = new TelehubInfoPacket.SpawnPointBlockBlock{SpawnPointPos = SpawnPoint[n]};
4977  }
4978 
4979  OutPacket(packet, ThrottleOutPacketType.Task);
4980  }
4981 
4982  #endregion
4983 
4984  #region Land Data Sending Methods
4985 
4986  public void SendLandParcelOverlay(byte[] data, int sequence_id)
4987  {
4988  ParcelOverlayPacket packet = (ParcelOverlayPacket)PacketPool.Instance.GetPacket(PacketType.ParcelOverlay);
4989  packet.ParcelData.Data = data;
4990  packet.ParcelData.SequenceID = sequence_id;
4991  packet.Header.Zerocoded = true;
4992 // OutPacket(packet, ThrottleOutPacketType.Task);
4993  OutPacket(packet, ThrottleOutPacketType.Land);
4994  }
4995 
4996  public void SendLandProperties(
4997  int sequence_id, bool snap_selection, int request_result, ILandObject lo,
4998  float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
4999  {
5000 // m_log.DebugFormat("[LLCLIENTVIEW]: Sending land properties for {0} to {1}", lo.LandData.GlobalID, Name);
5001 
5002  LandData landData = lo.LandData;
5003 
5004  ParcelPropertiesMessage updateMessage = new ParcelPropertiesMessage();
5005 
5006  updateMessage.AABBMax = landData.AABBMax;
5007  updateMessage.AABBMin = landData.AABBMin;
5008  updateMessage.Area = landData.Area;
5009  updateMessage.AuctionID = landData.AuctionID;
5010  updateMessage.AuthBuyerID = landData.AuthBuyerID;
5011  updateMessage.Bitmap = landData.Bitmap;
5012  updateMessage.Desc = landData.Description;
5013  updateMessage.Category = landData.Category;
5014  updateMessage.ClaimDate = Util.ToDateTime(landData.ClaimDate);
5015  updateMessage.ClaimPrice = landData.ClaimPrice;
5016  updateMessage.GroupID = landData.GroupID;
5017  updateMessage.IsGroupOwned = landData.IsGroupOwned;
5018  updateMessage.LandingType = (LandingType) landData.LandingType;
5019  updateMessage.LocalID = landData.LocalID;
5020 
5021  if (landData.Area > 0)
5022  {
5023  updateMessage.MaxPrims = parcelObjectCapacity;
5024  }
5025  else
5026  {
5027  updateMessage.MaxPrims = 0;
5028  }
5029 
5030  updateMessage.MediaAutoScale = Convert.ToBoolean(landData.MediaAutoScale);
5031  updateMessage.MediaID = landData.MediaID;
5032  updateMessage.MediaURL = landData.MediaURL;
5033  updateMessage.MusicURL = landData.MusicURL;
5034  updateMessage.Name = landData.Name;
5035  updateMessage.OtherCleanTime = landData.OtherCleanTime;
5036  updateMessage.OtherCount = 0; //TODO: Unimplemented
5037  updateMessage.OwnerID = landData.OwnerID;
5038  updateMessage.ParcelFlags = (ParcelFlags) landData.Flags;
5039  updateMessage.ParcelPrimBonus = simObjectBonusFactor;
5040  updateMessage.PassHours = landData.PassHours;
5041  updateMessage.PassPrice = landData.PassPrice;
5042  updateMessage.PublicCount = 0; //TODO: Unimplemented
5043 
5044  updateMessage.RegionPushOverride = (regionFlags & (uint)RegionFlags.RestrictPushObject) > 0;
5045  updateMessage.RegionDenyAnonymous = (regionFlags & (uint)RegionFlags.DenyAnonymous) > 0;
5046 
5047  //updateMessage.RegionDenyIdentified = (regionFlags & (uint)RegionFlags.DenyIdentified) > 0;
5048  //updateMessage.RegionDenyTransacted = (regionFlags & (uint)RegionFlags.DenyTransacted) > 0;
5049 
5050  updateMessage.RentPrice = 0;
5051  updateMessage.RequestResult = (ParcelResult) request_result;
5052  updateMessage.SalePrice = landData.SalePrice;
5053  updateMessage.SelfCount = 0; //TODO: Unimplemented
5054  updateMessage.SequenceID = sequence_id;
5055 
5056  if (landData.SimwideArea > 0)
5057  {
5058  int simulatorCapacity = (int)((long)landData.SimwideArea * (long)m_scene.RegionInfo.ObjectCapacity * (long)m_scene.RegionInfo.RegionSettings.ObjectBonus / 65536L);
5059  // Never report more than sim total capacity
5060  if (simulatorCapacity > m_scene.RegionInfo.ObjectCapacity)
5061  simulatorCapacity = m_scene.RegionInfo.ObjectCapacity;
5062  updateMessage.SimWideMaxPrims = simulatorCapacity;
5063  }
5064  else
5065  {
5066  updateMessage.SimWideMaxPrims = 0;
5067  }
5068 
5069  updateMessage.SnapSelection = snap_selection;
5070  updateMessage.SnapshotID = landData.SnapshotID;
5071  updateMessage.Status = (ParcelStatus) landData.Status;
5072  updateMessage.UserLocation = landData.UserLocation;
5073  updateMessage.UserLookAt = landData.UserLookAt;
5074 
5075  updateMessage.MediaType = landData.MediaType;
5076  updateMessage.MediaDesc = landData.MediaDescription;
5077  updateMessage.MediaWidth = landData.MediaWidth;
5078  updateMessage.MediaHeight = landData.MediaHeight;
5079  updateMessage.MediaLoop = landData.MediaLoop;
5080  updateMessage.ObscureMusic = landData.ObscureMusic;
5081  updateMessage.ObscureMedia = landData.ObscureMedia;
5082 
5083  IPrimCounts pc = lo.PrimCounts;
5084  updateMessage.OwnerPrims = pc.Owner;
5085  updateMessage.GroupPrims = pc.Group;
5086  updateMessage.OtherPrims = pc.Others;
5087  updateMessage.SelectedPrims = pc.Selected;
5088  updateMessage.TotalPrims = pc.Total;
5089  updateMessage.SimWideTotalPrims = pc.Simulator;
5090 
5091  try
5092  {
5093  IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
5094  if (eq != null)
5095  {
5096 
5097  OSD message_body = updateMessage.Serialize();
5098  // Add new fields here until OMV has them
5099  OSDMap bodyMap = (OSDMap)message_body;
5100  OSDArray parcelDataArray = (OSDArray)bodyMap["ParcelData"];
5101  OSDMap parcelData = (OSDMap)parcelDataArray[0];
5102  parcelData["SeeAVs"] = OSD.FromBoolean(landData.SeeAVs);
5103  parcelData["AnyAVSounds"] = OSD.FromBoolean(landData.AnyAVSounds);
5104  parcelData["GroupAVSounds"] = OSD.FromBoolean(landData.GroupAVSounds);
5105  OSDMap message = new OSDMap();
5106  message.Add("message", OSD.FromString("ParcelProperties"));
5107  message.Add("body", message_body);
5108 
5109  eq.Enqueue (message, this.AgentId);
5110 
5111 // eq.ParcelProperties(updateMessage, this.AgentId);
5112  }
5113  else
5114  {
5115  m_log.Warn("[LLCLIENTVIEW]: No EQ Interface when sending parcel data.");
5116  }
5117  }
5118  catch (Exception ex)
5119  {
5120  m_log.Error("[LLCLIENTVIEW]: Unable to send parcel data via eventqueue - exception: " + ex.ToString());
5121  }
5122  }
5123 
5124  public void SendLandAccessListData(List<LandAccessEntry> accessList, uint accessFlag, int localLandID)
5125  {
5126  ParcelAccessListReplyPacket replyPacket = (ParcelAccessListReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelAccessListReply);
5127  replyPacket.Data.AgentID = AgentId;
5128  replyPacket.Data.Flags = accessFlag;
5129  replyPacket.Data.LocalID = localLandID;
5130  replyPacket.Data.SequenceID = 0;
5131 
5132  List<ParcelAccessListReplyPacket.ListBlock> list = new List<ParcelAccessListReplyPacket.ListBlock>();
5133  foreach (LandAccessEntry entry in accessList)
5134  {
5135  ParcelAccessListReplyPacket.ListBlock block = new ParcelAccessListReplyPacket.ListBlock();
5136  block.Flags = accessFlag;
5137  block.ID = entry.AgentID;
5138  block.Time = entry.Expires;
5139  list.Add(block);
5140  }
5141 
5142  replyPacket.List = list.ToArray();
5143  replyPacket.Header.Zerocoded = true;
5144  OutPacket(replyPacket, ThrottleOutPacketType.Task);
5145  }
5146 
5147  public void SendForceClientSelectObjects(List<uint> ObjectIDs)
5148  {
5149 // m_log.DebugFormat("[LLCLIENTVIEW] sending select with {0} objects", ObjectIDs.Count);
5150 
5151  bool firstCall = true;
5152  const int MAX_OBJECTS_PER_PACKET = 251;
5153  ForceObjectSelectPacket pack = (ForceObjectSelectPacket)PacketPool.Instance.GetPacket(PacketType.ForceObjectSelect);
5154  ForceObjectSelectPacket.DataBlock[] data;
5155  while (ObjectIDs.Count > 0)
5156  {
5157  if (firstCall)
5158  {
5159  pack._Header.ResetList = true;
5160  firstCall = false;
5161  }
5162  else
5163  {
5164  pack._Header.ResetList = false;
5165  }
5166 
5167  if (ObjectIDs.Count > MAX_OBJECTS_PER_PACKET)
5168  {
5169  data = new ForceObjectSelectPacket.DataBlock[MAX_OBJECTS_PER_PACKET];
5170  }
5171  else
5172  {
5173  data = new ForceObjectSelectPacket.DataBlock[ObjectIDs.Count];
5174  }
5175 
5176  int i;
5177  for (i = 0; i < MAX_OBJECTS_PER_PACKET && ObjectIDs.Count > 0; i++)
5178  {
5179  data[i] = new ForceObjectSelectPacket.DataBlock();
5180  data[i].LocalID = Convert.ToUInt32(ObjectIDs[0]);
5181  ObjectIDs.RemoveAt(0);
5182  }
5183  pack.Data = data;
5184  pack.Header.Zerocoded = true;
5185  OutPacket(pack, ThrottleOutPacketType.Task);
5186  }
5187  }
5188 
5189  public void SendCameraConstraint(Vector4 ConstraintPlane)
5190  {
5191  CameraConstraintPacket cpack = (CameraConstraintPacket)PacketPool.Instance.GetPacket(PacketType.CameraConstraint);
5192  cpack.CameraCollidePlane = new CameraConstraintPacket.CameraCollidePlaneBlock();
5193  cpack.CameraCollidePlane.Plane = ConstraintPlane;
5194  //m_log.DebugFormat("[CLIENTVIEW]: Constraint {0}", ConstraintPlane);
5195  OutPacket(cpack, ThrottleOutPacketType.Task);
5196  }
5197 
5198  public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
5199  {
5200  int notifyCount = ownersAndCount.Count;
5201  ParcelObjectOwnersReplyPacket pack = (ParcelObjectOwnersReplyPacket)PacketPool.Instance.GetPacket(PacketType.ParcelObjectOwnersReply);
5202 
5203  if (notifyCount > 0)
5204  {
5205 // if (notifyCount > 32)
5206 // {
5207 // m_log.InfoFormat(
5208 // "[LAND]: More than {0} avatars own prims on this parcel. Only sending back details of first {0}"
5209 // + " - a developer might want to investigate whether this is a hard limit", 32);
5210 //
5211 // notifyCount = 32;
5212 // }
5213 
5214  ParcelObjectOwnersReplyPacket.DataBlock[] dataBlock
5215  = new ParcelObjectOwnersReplyPacket.DataBlock[notifyCount];
5216 
5217  int num = 0;
5218  foreach (UUID owner in ownersAndCount.Keys)
5219  {
5220  dataBlock[num] = new ParcelObjectOwnersReplyPacket.DataBlock();
5221  dataBlock[num].Count = ownersAndCount[owner];
5222 
5223  if (land.GroupID == owner || groups.Contains(owner))
5224  dataBlock[num].IsGroupOwned = true;
5225 
5226  dataBlock[num].OnlineStatus = true; //TODO: fix me later
5227  dataBlock[num].OwnerID = owner;
5228 
5229  num++;
5230 
5231  if (num >= notifyCount)
5232  {
5233  break;
5234  }
5235  }
5236 
5237  pack.Data = dataBlock;
5238  }
5239  else
5240  {
5241  pack.Data = new ParcelObjectOwnersReplyPacket.DataBlock[0];
5242  }
5243  pack.Header.Zerocoded = true;
5244  this.OutPacket(pack, ThrottleOutPacketType.Task);
5245  }
5246 
5247  #endregion
5248 
5249  #region Helper Methods
5250 
5251  protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
5252  {
5253  #region ScenePresence/SOP Handling
5254 
5255  bool avatar = (entity is ScenePresence);
5256  uint localID = entity.LocalId;
5257  uint attachPoint;
5258  Vector4 collisionPlane;
5259  Vector3 position, velocity, acceleration, angularVelocity;
5260  Quaternion rotation;
5261  byte[] textureEntry;
5262 
5263  if (entity is ScenePresence)
5264  {
5265  ScenePresence presence = (ScenePresence)entity;
5266 
5267  position = presence.OffsetPosition;
5268  rotation = presence.Rotation;
5269  angularVelocity = presence.AngularVelocity;
5270  rotation = presence.Rotation;
5271 
5272  attachPoint = 0;
5273 // m_log.DebugFormat(
5274 // "[LLCLIENTVIEW]: Sending terse update to {0} with position {1} in {2}", Name, presence.OffsetPosition, m_scene.Name);
5275 
5276  // attachPoint = presence.State; // Core: commented
5277  collisionPlane = presence.CollisionPlane;
5278  velocity = presence.Velocity;
5279  acceleration = Vector3.Zero;
5280 
5281  if (sendTexture)
5282  {
5283  textureEntry = presence.Appearance.Texture.GetBytes();
5284  }
5285  else
5286  textureEntry = null;
5287  }
5288  else
5289  {
5290  SceneObjectPart part = (SceneObjectPart)entity;
5291 
5292  attachPoint = part.ParentGroup.AttachmentPoint;
5293  attachPoint = ((attachPoint % 16) * 16 + (attachPoint / 16));
5294 // m_log.DebugFormat(
5295 // "[LLCLIENTVIEW]: Sending attachPoint {0} for {1} {2} to {3}",
5296 // attachPoint, part.Name, part.LocalId, Name);
5297 
5298  collisionPlane = Vector4.Zero;
5299  position = part.RelativePosition;
5300  velocity = part.Velocity;
5301  acceleration = part.Acceleration;
5302  angularVelocity = part.AngularVelocity;
5303  rotation = part.RotationOffset;
5304 
5305  if (sendTexture)
5306  textureEntry = part.Shape.TextureEntry;
5307  else
5308  textureEntry = null;
5309  }
5310 
5311  #endregion ScenePresence/SOP Handling
5312 
5313  int pos = 0;
5314  byte[] data = new byte[(avatar ? 60 : 44)];
5315 
5316  // LocalID
5317  Utils.UIntToBytes(localID, data, pos);
5318  pos += 4;
5319 
5320  // Avatar/CollisionPlane
5321  data[pos++] = (byte) attachPoint;
5322  if (avatar)
5323  {
5324  data[pos++] = 1;
5325 
5326  if (collisionPlane == Vector4.Zero)
5327  collisionPlane = Vector4.UnitW;
5328  //m_log.DebugFormat("CollisionPlane: {0}",collisionPlane);
5329  collisionPlane.ToBytes(data, pos);
5330  pos += 16;
5331  }
5332  else
5333  {
5334  ++pos;
5335  }
5336 
5337  // Position
5338  position.ToBytes(data, pos);
5339  pos += 12;
5340 
5341  // Velocity
5342  Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.X, -128.0f, 128.0f), data, pos); pos += 2;
5343  Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Y, -128.0f, 128.0f), data, pos); pos += 2;
5344  Utils.UInt16ToBytes(Utils.FloatToUInt16(velocity.Z, -128.0f, 128.0f), data, pos); pos += 2;
5345 
5346  // Acceleration
5347  Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.X, -64.0f, 64.0f), data, pos); pos += 2;
5348  Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Y, -64.0f, 64.0f), data, pos); pos += 2;
5349  Utils.UInt16ToBytes(Utils.FloatToUInt16(acceleration.Z, -64.0f, 64.0f), data, pos); pos += 2;
5350 
5351  // Rotation
5352  Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.X, -1.0f, 1.0f), data, pos); pos += 2;
5353  Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Y, -1.0f, 1.0f), data, pos); pos += 2;
5354  Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.Z, -1.0f, 1.0f), data, pos); pos += 2;
5355  Utils.UInt16ToBytes(Utils.FloatToUInt16(rotation.W, -1.0f, 1.0f), data, pos); pos += 2;
5356 
5357  // Angular Velocity
5358  Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.X, -64.0f, 64.0f), data, pos); pos += 2;
5359  Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Y, -64.0f, 64.0f), data, pos); pos += 2;
5360  Utils.UInt16ToBytes(Utils.FloatToUInt16(angularVelocity.Z, -64.0f, 64.0f), data, pos); pos += 2;
5361 
5362  ImprovedTerseObjectUpdatePacket.ObjectDataBlock block
5363  = PacketPool.Instance.GetDataBlock<ImprovedTerseObjectUpdatePacket.ObjectDataBlock>();
5364 
5365  block.Data = data;
5366 
5367  if (textureEntry != null && textureEntry.Length > 0)
5368  {
5369  byte[] teBytesFinal = new byte[textureEntry.Length + 4];
5370 
5371  // Texture Length
5372  Utils.IntToBytes(textureEntry.Length, textureEntry, 0);
5373  // Texture
5374  Buffer.BlockCopy(textureEntry, 0, teBytesFinal, 4, textureEntry.Length);
5375 
5376  block.TextureEntry = teBytesFinal;
5377  }
5378  else
5379  {
5380  block.TextureEntry = Utils.EmptyBytes;
5381  }
5382 
5383  return block;
5384  }
5385 
5386  protected ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data)
5387  {
5388  Vector3 offsetPosition = data.OffsetPosition;
5389  Quaternion rotation = data.Rotation;
5390  uint parentID = data.ParentID;
5391 
5392 // m_log.DebugFormat(
5393 // "[LLCLIENTVIEW]: Sending full update to {0} with pos {1}, vel {2} in {3}", Name, data.OffsetPosition, data.Velocity, m_scene.Name);
5394 
5395  byte[] objectData = new byte[76];
5396 
5397  Vector3 velocity = new Vector3(0, 0, 0);
5398  Vector3 acceleration = new Vector3(0, 0, 0);
5399  rotation.Normalize();
5400 
5401  data.CollisionPlane.ToBytes(objectData, 0);
5402  offsetPosition.ToBytes(objectData, 16);
5403  velocity.ToBytes(objectData, 28);
5404  acceleration.ToBytes(objectData, 40);
5405  rotation.ToBytes(objectData, 52);
5406  data.AngularVelocity.ToBytes(objectData, 64);
5407 
5408  ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
5409 
5410  update.Data = Utils.EmptyBytes;
5411  update.ExtraParams = new byte[1];
5412  update.FullID = data.UUID;
5413  update.ID = data.LocalId;
5414  update.Material = (byte)Material.Flesh;
5415  update.MediaURL = Utils.EmptyBytes;
5416  update.NameValue = Utils.StringToBytes("FirstName STRING RW SV " + data.Firstname + "\nLastName STRING RW SV " +
5417  data.Lastname + "\nTitle STRING RW SV " + data.Grouptitle);
5418  update.ObjectData = objectData;
5419 
5420  SceneObjectPart parentPart = data.ParentPart;
5421  if (parentPart != null)
5422  update.ParentID = parentPart.ParentGroup.LocalId;
5423  else
5424  update.ParentID = 0;
5425 
5426  update.PathCurve = 16;
5427  update.PathScaleX = 100;
5428  update.PathScaleY = 100;
5429  update.PCode = (byte)PCode.Avatar;
5430  update.ProfileCurve = 1;
5431  update.PSBlock = Utils.EmptyBytes;
5432  update.Scale = data.Appearance.AvatarSize;
5433 // update.Scale.Z -= 0.2f;
5434 
5435  update.Text = Utils.EmptyBytes;
5436  update.TextColor = new byte[4];
5437 
5438  // Don't send texture anim for avatars - this has no meaning for them.
5439  update.TextureAnim = Utils.EmptyBytes;
5440 
5441  // Don't send texture entry for avatars here - this is accomplished via the AvatarAppearance packet
5442  update.TextureEntry = Utils.EmptyBytes;
5443 // update.TextureEntry = (data.Appearance.Texture != null) ? data.Appearance.Texture.GetBytes() : Utils.EmptyBytes;
5444 
5445 /* all this flags seem related to prims and not avatars. This allow for wrong viewer side move of a avatar in prim edition mode (anv mantis 854)
5446  update.UpdateFlags = (uint)(
5447  PrimFlags.Physics | PrimFlags.ObjectModify | PrimFlags.ObjectCopy | PrimFlags.ObjectAnyOwner |
5448  PrimFlags.ObjectYouOwner | PrimFlags.ObjectMove | PrimFlags.InventoryEmpty | PrimFlags.ObjectTransfer |
5449  PrimFlags.ObjectOwnerModify);
5450 */
5451  update.UpdateFlags = 0;
5452 
5453  return update;
5454  }
5455 
5456  protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
5457  {
5458  byte[] objectData = new byte[60];
5459  data.RelativePosition.ToBytes(objectData, 0);
5460  data.Velocity.ToBytes(objectData, 12);
5461  data.Acceleration.ToBytes(objectData, 24);
5462 
5463  Quaternion rotation = data.RotationOffset;
5464  rotation.Normalize();
5465  rotation.ToBytes(objectData, 36);
5466  data.AngularVelocity.ToBytes(objectData, 48);
5467 
5468  ObjectUpdatePacket.ObjectDataBlock update = new ObjectUpdatePacket.ObjectDataBlock();
5469  update.ClickAction = (byte)data.ClickAction;
5470  update.CRC = 0;
5471  update.ExtraParams = data.Shape.ExtraParams ?? Utils.EmptyBytes;
5472  update.FullID = data.UUID;
5473  update.ID = data.LocalId;
5474  //update.JointAxisOrAnchor = Vector3.Zero; // These are deprecated
5475  //update.JointPivot = Vector3.Zero;
5476  //update.JointType = 0;
5477  update.Material = data.Material;
5478  update.MediaURL = Utils.EmptyBytes; // FIXME: Support this in OpenSim
5479 /*
5480  if (data.ParentGroup.IsAttachment)
5481  {
5482  update.NameValue
5483  = Util.StringToBytes256(
5484  string.Format("AttachItemID STRING RW SV {0}", data.ParentGroup.FromItemID));
5485 
5486  update.State = (byte)((data.ParentGroup.AttachmentPoint % 16) * 16 + (data.ParentGroup.AttachmentPoint / 16));
5487 
5488 // m_log.DebugFormat(
5489 // "[LLCLIENTVIEW]: Sending NameValue {0} for {1} {2} to {3}",
5490 // Util.UTF8.GetString(update.NameValue), data.Name, data.LocalId, Name);
5491 //
5492 // m_log.DebugFormat(
5493 // "[LLCLIENTVIEW]: Sending state {0} for {1} {2} to {3}",
5494 // update.State, data.Name, data.LocalId, Name);
5495  }
5496  else
5497  {
5498  update.NameValue = Utils.EmptyBytes;
5499 
5500  // The root part state is the canonical state for all parts of the object. The other part states in the
5501  // case for attachments may contain conflicting values that can end up crashing the viewer.
5502  update.State = data.ParentGroup.RootPart.Shape.State;
5503  }
5504 */
5505 
5506  if (data.ParentGroup.IsAttachment)
5507  {
5508  if (data.IsRoot)
5509  {
5510  update.NameValue = Util.StringToBytes256("AttachItemID STRING RW SV " + data.ParentGroup.FromItemID);
5511  }
5512  else
5513  update.NameValue = Utils.EmptyBytes;
5514 
5515  int st = (int)data.ParentGroup.AttachmentPoint;
5516  update.State = (byte)(((st & 0xf0) >> 4) + ((st & 0x0f) << 4)); ;
5517  }
5518  else
5519  {
5520  update.NameValue = Utils.EmptyBytes;
5521  update.State = data.Shape.State; // not sure about this
5522  }
5523 
5524 
5525  update.ObjectData = objectData;
5526  update.ParentID = data.ParentID;
5527  update.PathBegin = data.Shape.PathBegin;
5528  update.PathCurve = data.Shape.PathCurve;
5529  update.PathEnd = data.Shape.PathEnd;
5530  update.PathRadiusOffset = data.Shape.PathRadiusOffset;
5531  update.PathRevolutions = data.Shape.PathRevolutions;
5532  update.PathScaleX = data.Shape.PathScaleX;
5533  update.PathScaleY = data.Shape.PathScaleY;
5534  update.PathShearX = data.Shape.PathShearX;
5535  update.PathShearY = data.Shape.PathShearY;
5536  update.PathSkew = data.Shape.PathSkew;
5537  update.PathTaperX = data.Shape.PathTaperX;
5538  update.PathTaperY = data.Shape.PathTaperY;
5539  update.PathTwist = data.Shape.PathTwist;
5540  update.PathTwistBegin = data.Shape.PathTwistBegin;
5541  update.PCode = data.Shape.PCode;
5542  update.ProfileBegin = data.Shape.ProfileBegin;
5543  update.ProfileCurve = data.Shape.ProfileCurve;
5544  update.ProfileEnd = data.Shape.ProfileEnd;
5545  update.ProfileHollow = data.Shape.ProfileHollow;
5546  update.PSBlock = data.ParticleSystem ?? Utils.EmptyBytes;
5547  update.TextColor = data.GetTextColor().GetBytes(false);
5548  update.TextureAnim = data.TextureAnimation ?? Utils.EmptyBytes;
5549  update.TextureEntry = data.Shape.TextureEntry ?? Utils.EmptyBytes;
5550  update.Scale = data.Shape.Scale;
5551  update.Text = Util.StringToBytes256(data.Text);
5552  update.MediaURL = Util.StringToBytes256(data.MediaUrl);
5553 
5554  #region PrimFlags
5555 
5556  PrimFlags flags = (PrimFlags)m_scene.Permissions.GenerateClientFlags(recipientID, data.UUID);
5557 
5558  // Don't send the CreateSelected flag to everyone
5559  flags &= ~PrimFlags.CreateSelected;
5560 
5561  if (recipientID == data.OwnerID)
5562  {
5563  if (data.CreateSelected)
5564  {
5565  // Only send this flag once, then unset it
5566  flags |= PrimFlags.CreateSelected;
5567  data.CreateSelected = false;
5568  }
5569  }
5570 
5571 // m_log.DebugFormat(
5572 // "[LLCLIENTVIEW]: Constructing client update for part {0} {1} with flags {2}, localId {3}",
5573 // data.Name, update.FullID, flags, update.ID);
5574 
5575  update.UpdateFlags = (uint)flags;
5576 
5577  #endregion PrimFlags
5578 
5579  if (data.Sound != UUID.Zero)
5580  {
5581  update.Sound = data.Sound;
5582  update.OwnerID = data.OwnerID;
5583  update.Gain = (float)data.SoundGain;
5584  update.Radius = (float)data.SoundRadius;
5585  update.Flags = data.SoundFlags;
5586  }
5587 
5588  switch ((PCode)data.Shape.PCode)
5589  {
5590  case PCode.Grass:
5591  case PCode.Tree:
5592  case PCode.NewTree:
5593  update.Data = new byte[] { data.Shape.State };
5594  break;
5595  default:
5596  update.Data = Utils.EmptyBytes;
5597  break;
5598  }
5599 
5600  return update;
5601  }
5602 
5603  protected ObjectUpdateCompressedPacket.ObjectDataBlock CreateCompressedUpdateBlock(SceneObjectPart part, PrimUpdateFlags updateFlags)
5604  {
5605  // TODO: Implement this
5606  return null;
5607  }
5608 
5609  public void SendNameReply(UUID profileId, string firstname, string lastname)
5610  {
5611  UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
5612  // TODO: don't create new blocks if recycling an old packet
5613  packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
5614  packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
5615  packet.UUIDNameBlock[0].ID = profileId;
5616  packet.UUIDNameBlock[0].FirstName = Util.StringToBytes256(firstname);
5617  packet.UUIDNameBlock[0].LastName = Util.StringToBytes256(lastname);
5618 
5619  OutPacket(packet, ThrottleOutPacketType.Task);
5620  }
5621 
5622  public ulong GetGroupPowers(UUID groupID)
5623  {
5624  if (groupID == ActiveGroupId)
5625  return ActiveGroupPowers;
5626 
5627  if (m_groupPowers.ContainsKey(groupID))
5628  return m_groupPowers[groupID];
5629 
5630  return 0;
5631  }
5632 
5633  #endregion
5634 
5638  protected virtual void RegisterLocalPacketHandlers()
5639  {
5640  AddLocalPacketHandler(PacketType.LogoutRequest, HandleLogout);
5641 
5642  // If AgentUpdate is ever handled asynchronously, then we will also need to construct a new AgentUpdateArgs
5643  // for each AgentUpdate packet.
5644  AddLocalPacketHandler(PacketType.AgentUpdate, HandleAgentUpdate, false);
5645 
5646  AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect, false);
5647  AddLocalPacketHandler(PacketType.VelocityInterpolateOff, HandleVelocityInterpolateOff, false);
5648  AddLocalPacketHandler(PacketType.VelocityInterpolateOn, HandleVelocityInterpolateOn, false);
5649  AddLocalPacketHandler(PacketType.AgentCachedTexture, HandleAgentTextureCached, false);
5650  AddLocalPacketHandler(PacketType.MultipleObjectUpdate, HandleMultipleObjUpdate, false);
5651  AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest, false);
5652  AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest, false);
5653  AddLocalPacketHandler(PacketType.UUIDGroupNameRequest, HandleUUIDGroupNameRequest);
5654  AddLocalPacketHandler(PacketType.ObjectGroup, HandleObjectGroupRequest);
5655  AddLocalPacketHandler(PacketType.GenericMessage, HandleGenericMessage, true, true);
5656  AddLocalPacketHandler(PacketType.AvatarPropertiesRequest, HandleAvatarPropertiesRequest, true, true);
5657  AddLocalPacketHandler(PacketType.ChatFromViewer, HandleChatFromViewer);
5658  AddLocalPacketHandler(PacketType.AvatarPropertiesUpdate, HandlerAvatarPropertiesUpdate, true, true);
5659  AddLocalPacketHandler(PacketType.ScriptDialogReply, HandlerScriptDialogReply);
5660  AddLocalPacketHandler(PacketType.ImprovedInstantMessage, HandlerImprovedInstantMessage);
5661  AddLocalPacketHandler(PacketType.AcceptFriendship, HandlerAcceptFriendship);
5662  AddLocalPacketHandler(PacketType.DeclineFriendship, HandlerDeclineFriendship);
5663  AddLocalPacketHandler(PacketType.TerminateFriendship, HandlerTerminateFriendship);
5664  AddLocalPacketHandler(PacketType.RezObject, HandlerRezObject);
5665  AddLocalPacketHandler(PacketType.DeRezObject, HandlerDeRezObject);
5666  AddLocalPacketHandler(PacketType.RezRestoreToWorld, HandlerRezRestoreToWorld);
5667  AddLocalPacketHandler(PacketType.ModifyLand, HandlerModifyLand);
5668  AddLocalPacketHandler(PacketType.RegionHandshakeReply, HandlerRegionHandshakeReply, false);
5669  AddLocalPacketHandler(PacketType.AgentWearablesRequest, HandlerAgentWearablesRequest);
5670  AddLocalPacketHandler(PacketType.AgentSetAppearance, HandlerAgentSetAppearance);
5671  AddLocalPacketHandler(PacketType.AgentIsNowWearing, HandlerAgentIsNowWearing);
5672  AddLocalPacketHandler(PacketType.RezSingleAttachmentFromInv, HandlerRezSingleAttachmentFromInv);
5673  AddLocalPacketHandler(PacketType.RezMultipleAttachmentsFromInv, HandleRezMultipleAttachmentsFromInv);
5674  AddLocalPacketHandler(PacketType.DetachAttachmentIntoInv, HandleDetachAttachmentIntoInv);
5675  AddLocalPacketHandler(PacketType.ObjectAttach, HandleObjectAttach);
5676  AddLocalPacketHandler(PacketType.ObjectDetach, HandleObjectDetach);
5677  AddLocalPacketHandler(PacketType.ObjectDrop, HandleObjectDrop);
5678  AddLocalPacketHandler(PacketType.SetAlwaysRun, HandleSetAlwaysRun, false);
5679  AddLocalPacketHandler(PacketType.CompleteAgentMovement, HandleCompleteAgentMovement);
5680  AddLocalPacketHandler(PacketType.AgentAnimation, HandleAgentAnimation, false);
5681  AddLocalPacketHandler(PacketType.AgentRequestSit, HandleAgentRequestSit);
5682  AddLocalPacketHandler(PacketType.AgentSit, HandleAgentSit);
5683  AddLocalPacketHandler(PacketType.SoundTrigger, HandleSoundTrigger);
5684  AddLocalPacketHandler(PacketType.AvatarPickerRequest, HandleAvatarPickerRequest);
5685  AddLocalPacketHandler(PacketType.AgentDataUpdateRequest, HandleAgentDataUpdateRequest);
5686  AddLocalPacketHandler(PacketType.UserInfoRequest, HandleUserInfoRequest);
5687  AddLocalPacketHandler(PacketType.UpdateUserInfo, HandleUpdateUserInfo);
5688  AddLocalPacketHandler(PacketType.SetStartLocationRequest, HandleSetStartLocationRequest);
5689  AddLocalPacketHandler(PacketType.AgentThrottle, HandleAgentThrottle, false);
5690  AddLocalPacketHandler(PacketType.AgentPause, HandleAgentPause, false);
5691  AddLocalPacketHandler(PacketType.AgentResume, HandleAgentResume, false);
5692  AddLocalPacketHandler(PacketType.ForceScriptControlRelease, HandleForceScriptControlRelease);
5693  AddLocalPacketHandler(PacketType.ObjectLink, HandleObjectLink);
5694  AddLocalPacketHandler(PacketType.ObjectDelink, HandleObjectDelink);
5695  AddLocalPacketHandler(PacketType.ObjectAdd, HandleObjectAdd);
5696  AddLocalPacketHandler(PacketType.ObjectShape, HandleObjectShape);
5697  AddLocalPacketHandler(PacketType.ObjectExtraParams, HandleObjectExtraParams);
5698  AddLocalPacketHandler(PacketType.ObjectDuplicate, HandleObjectDuplicate);
5699  AddLocalPacketHandler(PacketType.RequestMultipleObjects, HandleRequestMultipleObjects);
5700  AddLocalPacketHandler(PacketType.ObjectSelect, HandleObjectSelect);
5701  AddLocalPacketHandler(PacketType.ObjectDeselect, HandleObjectDeselect);
5702  AddLocalPacketHandler(PacketType.ObjectPosition, HandleObjectPosition);
5703  AddLocalPacketHandler(PacketType.ObjectScale, HandleObjectScale);
5704  AddLocalPacketHandler(PacketType.ObjectRotation, HandleObjectRotation);
5705  AddLocalPacketHandler(PacketType.ObjectFlagUpdate, HandleObjectFlagUpdate);
5706 
5707  // Handle ObjectImage (TextureEntry) updates synchronously, since when updating multiple prim faces at once,
5708  // some clients will send out a separate ObjectImage packet for each face
5709  AddLocalPacketHandler(PacketType.ObjectImage, HandleObjectImage, false);
5710 
5711  AddLocalPacketHandler(PacketType.ObjectGrab, HandleObjectGrab, false);
5712  AddLocalPacketHandler(PacketType.ObjectGrabUpdate, HandleObjectGrabUpdate, false);
5713  AddLocalPacketHandler(PacketType.ObjectDeGrab, HandleObjectDeGrab);
5714  AddLocalPacketHandler(PacketType.ObjectSpinStart, HandleObjectSpinStart, false);
5715  AddLocalPacketHandler(PacketType.ObjectSpinUpdate, HandleObjectSpinUpdate, false);
5716  AddLocalPacketHandler(PacketType.ObjectSpinStop, HandleObjectSpinStop, false);
5717  AddLocalPacketHandler(PacketType.ObjectDescription, HandleObjectDescription, false);
5718  AddLocalPacketHandler(PacketType.ObjectName, HandleObjectName, false);
5719  AddLocalPacketHandler(PacketType.ObjectPermissions, HandleObjectPermissions, false);
5720  AddLocalPacketHandler(PacketType.Undo, HandleUndo, false);
5721  AddLocalPacketHandler(PacketType.UndoLand, HandleLandUndo, false);
5722  AddLocalPacketHandler(PacketType.Redo, HandleRedo, false);
5723  AddLocalPacketHandler(PacketType.ObjectDuplicateOnRay, HandleObjectDuplicateOnRay);
5724  AddLocalPacketHandler(PacketType.RequestObjectPropertiesFamily, HandleRequestObjectPropertiesFamily, false);
5725  AddLocalPacketHandler(PacketType.ObjectIncludeInSearch, HandleObjectIncludeInSearch);
5726  AddLocalPacketHandler(PacketType.ScriptAnswerYes, HandleScriptAnswerYes, false);
5727  AddLocalPacketHandler(PacketType.ObjectClickAction, HandleObjectClickAction, false);
5728  AddLocalPacketHandler(PacketType.ObjectMaterial, HandleObjectMaterial, false);
5729  AddLocalPacketHandler(PacketType.RequestImage, HandleRequestImage, false);
5730  AddLocalPacketHandler(PacketType.TransferRequest, HandleTransferRequest, false);
5731  AddLocalPacketHandler(PacketType.AssetUploadRequest, HandleAssetUploadRequest);
5732  AddLocalPacketHandler(PacketType.RequestXfer, HandleRequestXfer);
5733  AddLocalPacketHandler(PacketType.SendXferPacket, HandleSendXferPacket);
5734  AddLocalPacketHandler(PacketType.ConfirmXferPacket, HandleConfirmXferPacket);
5735  AddLocalPacketHandler(PacketType.AbortXfer, HandleAbortXfer);
5736  AddLocalPacketHandler(PacketType.CreateInventoryFolder, HandleCreateInventoryFolder);
5737  AddLocalPacketHandler(PacketType.UpdateInventoryFolder, HandleUpdateInventoryFolder);
5738  AddLocalPacketHandler(PacketType.MoveInventoryFolder, HandleMoveInventoryFolder);
5739  AddLocalPacketHandler(PacketType.CreateInventoryItem, HandleCreateInventoryItem);
5740  AddLocalPacketHandler(PacketType.LinkInventoryItem, HandleLinkInventoryItem);
5741  AddLocalPacketHandler(PacketType.FetchInventory, HandleFetchInventory);
5742  AddLocalPacketHandler(PacketType.FetchInventoryDescendents, HandleFetchInventoryDescendents);
5743  AddLocalPacketHandler(PacketType.PurgeInventoryDescendents, HandlePurgeInventoryDescendents);
5744  AddLocalPacketHandler(PacketType.UpdateInventoryItem, HandleUpdateInventoryItem);
5745  AddLocalPacketHandler(PacketType.CopyInventoryItem, HandleCopyInventoryItem);
5746  AddLocalPacketHandler(PacketType.MoveInventoryItem, HandleMoveInventoryItem);
5747  AddLocalPacketHandler(PacketType.RemoveInventoryItem, HandleRemoveInventoryItem);
5748  AddLocalPacketHandler(PacketType.RemoveInventoryFolder, HandleRemoveInventoryFolder);
5749  AddLocalPacketHandler(PacketType.RemoveInventoryObjects, HandleRemoveInventoryObjects);
5750  AddLocalPacketHandler(PacketType.RequestTaskInventory, HandleRequestTaskInventory);
5751  AddLocalPacketHandler(PacketType.UpdateTaskInventory, HandleUpdateTaskInventory);
5752  AddLocalPacketHandler(PacketType.RemoveTaskInventory, HandleRemoveTaskInventory);
5753  AddLocalPacketHandler(PacketType.MoveTaskInventory, HandleMoveTaskInventory);
5754  AddLocalPacketHandler(PacketType.RezScript, HandleRezScript);
5755  AddLocalPacketHandler(PacketType.MapLayerRequest, HandleMapLayerRequest);
5756  AddLocalPacketHandler(PacketType.MapBlockRequest, HandleMapBlockRequest);
5757  AddLocalPacketHandler(PacketType.MapNameRequest, HandleMapNameRequest);
5758  AddLocalPacketHandler(PacketType.TeleportLandmarkRequest, HandleTeleportLandmarkRequest);
5759  AddLocalPacketHandler(PacketType.TeleportCancel, HandleTeleportCancel);
5760  AddLocalPacketHandler(PacketType.TeleportLocationRequest, HandleTeleportLocationRequest);
5761  AddLocalPacketHandler(PacketType.UUIDNameRequest, HandleUUIDNameRequest, false);
5762  AddLocalPacketHandler(PacketType.RegionHandleRequest, HandleRegionHandleRequest, false);
5763  AddLocalPacketHandler(PacketType.ParcelInfoRequest, HandleParcelInfoRequest);
5764  AddLocalPacketHandler(PacketType.ParcelAccessListRequest, HandleParcelAccessListRequest, false);
5765  AddLocalPacketHandler(PacketType.ParcelAccessListUpdate, HandleParcelAccessListUpdate, false);
5766  AddLocalPacketHandler(PacketType.ParcelPropertiesRequest, HandleParcelPropertiesRequest, false);
5767  AddLocalPacketHandler(PacketType.ParcelDivide, HandleParcelDivide);
5768  AddLocalPacketHandler(PacketType.ParcelJoin, HandleParcelJoin);
5769  AddLocalPacketHandler(PacketType.ParcelPropertiesUpdate, HandleParcelPropertiesUpdate);
5770  AddLocalPacketHandler(PacketType.ParcelSelectObjects, HandleParcelSelectObjects);
5771  AddLocalPacketHandler(PacketType.ParcelObjectOwnersRequest, HandleParcelObjectOwnersRequest);
5772  AddLocalPacketHandler(PacketType.ParcelGodForceOwner, HandleParcelGodForceOwner);
5773  AddLocalPacketHandler(PacketType.ParcelRelease, HandleParcelRelease);
5774  AddLocalPacketHandler(PacketType.ParcelReclaim, HandleParcelReclaim);
5775  AddLocalPacketHandler(PacketType.ParcelReturnObjects, HandleParcelReturnObjects);
5776  AddLocalPacketHandler(PacketType.ParcelSetOtherCleanTime, HandleParcelSetOtherCleanTime);
5777  AddLocalPacketHandler(PacketType.LandStatRequest, HandleLandStatRequest);
5778  AddLocalPacketHandler(PacketType.ParcelDwellRequest, HandleParcelDwellRequest);
5779  AddLocalPacketHandler(PacketType.EstateOwnerMessage, HandleEstateOwnerMessage);
5780  AddLocalPacketHandler(PacketType.RequestRegionInfo, HandleRequestRegionInfo, false);
5781  AddLocalPacketHandler(PacketType.EstateCovenantRequest, HandleEstateCovenantRequest);
5782  AddLocalPacketHandler(PacketType.RequestGodlikePowers, HandleRequestGodlikePowers);
5783  AddLocalPacketHandler(PacketType.GodKickUser, HandleGodKickUser);
5784  AddLocalPacketHandler(PacketType.MoneyBalanceRequest, HandleMoneyBalanceRequest);
5785  AddLocalPacketHandler(PacketType.EconomyDataRequest, HandleEconomyDataRequest);
5786  AddLocalPacketHandler(PacketType.RequestPayPrice, HandleRequestPayPrice);
5787  AddLocalPacketHandler(PacketType.ObjectSaleInfo, HandleObjectSaleInfo);
5788  AddLocalPacketHandler(PacketType.ObjectBuy, HandleObjectBuy);
5789  AddLocalPacketHandler(PacketType.GetScriptRunning, HandleGetScriptRunning);
5790  AddLocalPacketHandler(PacketType.SetScriptRunning, HandleSetScriptRunning);
5791  AddLocalPacketHandler(PacketType.ScriptReset, HandleScriptReset);
5792  AddLocalPacketHandler(PacketType.ActivateGestures, HandleActivateGestures);
5793  AddLocalPacketHandler(PacketType.DeactivateGestures, HandleDeactivateGestures);
5794  AddLocalPacketHandler(PacketType.ObjectOwner, HandleObjectOwner);
5795  AddLocalPacketHandler(PacketType.AgentFOV, HandleAgentFOV, false);
5796  AddLocalPacketHandler(PacketType.ViewerStats, HandleViewerStats);
5797  AddLocalPacketHandler(PacketType.MapItemRequest, HandleMapItemRequest, false);
5798  AddLocalPacketHandler(PacketType.TransferAbort, HandleTransferAbort, false);
5799  AddLocalPacketHandler(PacketType.MuteListRequest, HandleMuteListRequest, false);
5800  AddLocalPacketHandler(PacketType.UseCircuitCode, HandleUseCircuitCode);
5801  AddLocalPacketHandler(PacketType.CreateNewOutfitAttachments, HandleCreateNewOutfitAttachments);
5802  AddLocalPacketHandler(PacketType.AgentHeightWidth, HandleAgentHeightWidth, false);
5803  AddLocalPacketHandler(PacketType.InventoryDescendents, HandleInventoryDescendents);
5804  AddLocalPacketHandler(PacketType.DirPlacesQuery, HandleDirPlacesQuery);
5805  AddLocalPacketHandler(PacketType.DirFindQuery, HandleDirFindQuery);
5806  AddLocalPacketHandler(PacketType.DirLandQuery, HandleDirLandQuery);
5807  AddLocalPacketHandler(PacketType.DirPopularQuery, HandleDirPopularQuery);
5808  AddLocalPacketHandler(PacketType.DirClassifiedQuery, HandleDirClassifiedQuery);
5809  AddLocalPacketHandler(PacketType.EventInfoRequest, HandleEventInfoRequest);
5810  AddLocalPacketHandler(PacketType.OfferCallingCard, HandleOfferCallingCard);
5811  AddLocalPacketHandler(PacketType.AcceptCallingCard, HandleAcceptCallingCard);
5812  AddLocalPacketHandler(PacketType.DeclineCallingCard, HandleDeclineCallingCard);
5813  AddLocalPacketHandler(PacketType.ActivateGroup, HandleActivateGroup);
5814  AddLocalPacketHandler(PacketType.GroupTitlesRequest, HandleGroupTitlesRequest);
5815  AddLocalPacketHandler(PacketType.GroupProfileRequest, HandleGroupProfileRequest);
5816  AddLocalPacketHandler(PacketType.GroupMembersRequest, HandleGroupMembersRequest);
5817  AddLocalPacketHandler(PacketType.GroupRoleDataRequest, HandleGroupRoleDataRequest);
5818  AddLocalPacketHandler(PacketType.GroupRoleMembersRequest, HandleGroupRoleMembersRequest);
5819  AddLocalPacketHandler(PacketType.CreateGroupRequest, HandleCreateGroupRequest);
5820  AddLocalPacketHandler(PacketType.UpdateGroupInfo, HandleUpdateGroupInfo);
5821  AddLocalPacketHandler(PacketType.SetGroupAcceptNotices, HandleSetGroupAcceptNotices);
5822  AddLocalPacketHandler(PacketType.GroupTitleUpdate, HandleGroupTitleUpdate);
5823  AddLocalPacketHandler(PacketType.ParcelDeedToGroup, HandleParcelDeedToGroup);
5824  AddLocalPacketHandler(PacketType.GroupNoticesListRequest, HandleGroupNoticesListRequest);
5825  AddLocalPacketHandler(PacketType.GroupNoticeRequest, HandleGroupNoticeRequest);
5826  AddLocalPacketHandler(PacketType.GroupRoleUpdate, HandleGroupRoleUpdate);
5827  AddLocalPacketHandler(PacketType.GroupRoleChanges, HandleGroupRoleChanges);
5828  AddLocalPacketHandler(PacketType.JoinGroupRequest, HandleJoinGroupRequest);
5829  AddLocalPacketHandler(PacketType.LeaveGroupRequest, HandleLeaveGroupRequest);
5830  AddLocalPacketHandler(PacketType.EjectGroupMemberRequest, HandleEjectGroupMemberRequest);
5831  AddLocalPacketHandler(PacketType.InviteGroupRequest, HandleInviteGroupRequest);
5832  AddLocalPacketHandler(PacketType.StartLure, HandleStartLure);
5833  AddLocalPacketHandler(PacketType.TeleportLureRequest, HandleTeleportLureRequest);
5834  AddLocalPacketHandler(PacketType.ClassifiedInfoRequest, HandleClassifiedInfoRequest);
5835  AddLocalPacketHandler(PacketType.ClassifiedInfoUpdate, HandleClassifiedInfoUpdate);
5836  AddLocalPacketHandler(PacketType.ClassifiedDelete, HandleClassifiedDelete);
5837  AddLocalPacketHandler(PacketType.ClassifiedGodDelete, HandleClassifiedGodDelete);
5838  AddLocalPacketHandler(PacketType.EventGodDelete, HandleEventGodDelete);
5839  AddLocalPacketHandler(PacketType.EventNotificationAddRequest, HandleEventNotificationAddRequest);
5840  AddLocalPacketHandler(PacketType.EventNotificationRemoveRequest, HandleEventNotificationRemoveRequest);
5841  AddLocalPacketHandler(PacketType.RetrieveInstantMessages, HandleRetrieveInstantMessages);
5842  AddLocalPacketHandler(PacketType.PickDelete, HandlePickDelete);
5843  AddLocalPacketHandler(PacketType.PickGodDelete, HandlePickGodDelete);
5844  AddLocalPacketHandler(PacketType.PickInfoUpdate, HandlePickInfoUpdate);
5845  AddLocalPacketHandler(PacketType.AvatarNotesUpdate, HandleAvatarNotesUpdate, true, true);
5846  AddLocalPacketHandler(PacketType.AvatarInterestsUpdate, HandleAvatarInterestsUpdate, true, true);
5847  AddLocalPacketHandler(PacketType.GrantUserRights, HandleGrantUserRights);
5848  AddLocalPacketHandler(PacketType.PlacesQuery, HandlePlacesQuery);
5849  AddLocalPacketHandler(PacketType.UpdateMuteListEntry, HandleUpdateMuteListEntry);
5850  AddLocalPacketHandler(PacketType.RemoveMuteListEntry, HandleRemoveMuteListEntry);
5851  AddLocalPacketHandler(PacketType.UserReport, HandleUserReport);
5852  AddLocalPacketHandler(PacketType.FindAgent, HandleFindAgent);
5853  AddLocalPacketHandler(PacketType.TrackAgent, HandleTrackAgent);
5854  AddLocalPacketHandler(PacketType.GodUpdateRegionInfo, HandleGodUpdateRegionInfoUpdate);
5855  AddLocalPacketHandler(PacketType.GodlikeMessage, HandleGodlikeMessage);
5856  AddLocalPacketHandler(PacketType.StateSave, HandleSaveStatePacket);
5857  AddLocalPacketHandler(PacketType.GroupAccountDetailsRequest, HandleGroupAccountDetailsRequest);
5858  AddLocalPacketHandler(PacketType.GroupAccountSummaryRequest, HandleGroupAccountSummaryRequest);
5859  AddLocalPacketHandler(PacketType.GroupAccountTransactionsRequest, HandleGroupTransactionsDetailsRequest);
5860  AddLocalPacketHandler(PacketType.FreezeUser, HandleFreezeUser);
5861  AddLocalPacketHandler(PacketType.EjectUser, HandleEjectUser);
5862  AddLocalPacketHandler(PacketType.ParcelBuyPass, HandleParcelBuyPass);
5863  AddLocalPacketHandler(PacketType.ParcelGodMarkAsContent, HandleParcelGodMarkAsContent);
5864  AddLocalPacketHandler(PacketType.GroupActiveProposalsRequest, HandleGroupActiveProposalsRequest);
5865  AddLocalPacketHandler(PacketType.GroupVoteHistoryRequest, HandleGroupVoteHistoryRequest);
5866  AddLocalPacketHandler(PacketType.SimWideDeletes, HandleSimWideDeletes);
5867  AddLocalPacketHandler(PacketType.SendPostcard, HandleSendPostcard);
5868  AddLocalPacketHandler(PacketType.ChangeInventoryItemFlags, HandleChangeInventoryItemFlags);
5869 
5870  AddGenericPacketHandler("autopilot", HandleAutopilot);
5871  }
5872 
5873  #region Packet Handlers
5874 
5875  public int TotalAgentUpdates { get; set; }
5876 
5877  #region Scene/Avatar
5878 
5879  // Threshold for body rotation to be a significant agent update
5880  // use the abs of cos
5881  private const float QDELTABody = 1.0f - 0.0001f;
5882  private const float QDELTAHead = 1.0f - 0.0001f;
5883  // Threshold for camera rotation to be a significant agent update
5884  private const float VDELTA = 0.01f;
5885 
5892  public bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
5893  {
5894  return CheckAgentMovementUpdateSignificance(x) || CheckAgentCameraUpdateSignificance(x);
5895  }
5896 
5903  private bool CheckAgentMovementUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
5904  {
5905  float qdelta1 = Math.Abs(Quaternion.Dot(x.BodyRotation, m_thisAgentUpdateArgs.BodyRotation));
5906  //qdelta2 = Math.Abs(Quaternion.Dot(x.HeadRotation, m_thisAgentUpdateArgs.HeadRotation));
5907 
5908  bool movementSignificant =
5909  (x.ControlFlags != m_thisAgentUpdateArgs.ControlFlags) // significant if control flags changed
5910  || (x.ControlFlags != (byte)AgentManager.ControlFlags.NONE) // significant if user supplying any movement update commands
5911  || (x.Flags != m_thisAgentUpdateArgs.Flags) // significant if Flags changed
5912  || (x.State != m_thisAgentUpdateArgs.State) // significant if Stats changed
5913  || (qdelta1 < QDELTABody) // significant if body rotation above(below cos) threshold
5914  // Ignoring head rotation altogether, because it's not being used for anything interesting up the stack
5915  // || (qdelta2 < QDELTAHead) // significant if head rotation above(below cos) threshold
5916  || (Math.Abs(x.Far - m_thisAgentUpdateArgs.Far) >= 32) // significant if far distance changed
5917  ;
5918  //if (movementSignificant)
5919  //{
5920  //m_log.DebugFormat("[LLCLIENTVIEW]: Bod {0} {1}",
5921  // qdelta1, qdelta2);
5922  //m_log.DebugFormat("[LLCLIENTVIEW]: St {0} {1} {2} {3}",
5923  // x.ControlFlags, x.Flags, x.Far, x.State);
5924  //}
5925  return movementSignificant;
5926  }
5927 
5934  private bool CheckAgentCameraUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
5935  {
5936  float vdelta1 = Vector3.Distance(x.CameraAtAxis, m_thisAgentUpdateArgs.CameraAtAxis);
5937  float vdelta2 = Vector3.Distance(x.CameraCenter, m_thisAgentUpdateArgs.CameraCenter);
5938  float vdelta3 = Vector3.Distance(x.CameraLeftAxis, m_thisAgentUpdateArgs.CameraLeftAxis);
5939  float vdelta4 = Vector3.Distance(x.CameraUpAxis, m_thisAgentUpdateArgs.CameraUpAxis);
5940 
5941  bool cameraSignificant =
5942  (vdelta1 > VDELTA) ||
5943  (vdelta2 > VDELTA) ||
5944  (vdelta3 > VDELTA) ||
5945  (vdelta4 > VDELTA)
5946  ;
5947 
5948  //if (cameraSignificant)
5949  //{
5950  //m_log.DebugFormat("[LLCLIENTVIEW]: Cam1 {0} {1}",
5951  // x.CameraAtAxis, x.CameraCenter);
5952  //m_log.DebugFormat("[LLCLIENTVIEW]: Cam2 {0} {1}",
5953  // x.CameraLeftAxis, x.CameraUpAxis);
5954  //}
5955 
5956  return cameraSignificant;
5957  }
5958 
5959  private bool HandleAgentUpdate(IClientAPI sender, Packet packet)
5960  {
5961  // We got here, which means that something in agent update was significant
5962 
5963  AgentUpdatePacket agentUpdate = (AgentUpdatePacket)packet;
5964  AgentUpdatePacket.AgentDataBlock x = agentUpdate.AgentData;
5965 
5966  if (x.AgentID != AgentId || x.SessionID != SessionId)
5967  {
5968  PacketPool.Instance.ReturnPacket(packet);
5969  return false;
5970  }
5971 
5972  TotalAgentUpdates++;
5973 
5974  bool movement = CheckAgentMovementUpdateSignificance(x);
5975  bool camera = CheckAgentCameraUpdateSignificance(x);
5976 
5977  // Was there a significant movement/state change?
5978  if (movement)
5979  {
5980  m_thisAgentUpdateArgs.BodyRotation = x.BodyRotation;
5981  m_thisAgentUpdateArgs.ControlFlags = x.ControlFlags;
5982  m_thisAgentUpdateArgs.Far = x.Far;
5983  m_thisAgentUpdateArgs.Flags = x.Flags;
5984  m_thisAgentUpdateArgs.HeadRotation = x.HeadRotation;
5985 // m_thisAgentUpdateArgs.SessionID = x.SessionID;
5986  m_thisAgentUpdateArgs.State = x.State;
5987 
5988  UpdateAgent handlerAgentUpdate = OnAgentUpdate;
5989  UpdateAgent handlerPreAgentUpdate = OnPreAgentUpdate;
5990 
5991  if (handlerPreAgentUpdate != null)
5992  OnPreAgentUpdate(this, m_thisAgentUpdateArgs);
5993 
5994  if (handlerAgentUpdate != null)
5995  OnAgentUpdate(this, m_thisAgentUpdateArgs);
5996 
5997  handlerAgentUpdate = null;
5998  handlerPreAgentUpdate = null;
5999  }
6000 
6001  // Was there a significant camera(s) change?
6002  if (camera)
6003  {
6004  m_thisAgentUpdateArgs.CameraAtAxis = x.CameraAtAxis;
6005  m_thisAgentUpdateArgs.CameraCenter = x.CameraCenter;
6006  m_thisAgentUpdateArgs.CameraLeftAxis = x.CameraLeftAxis;
6007  m_thisAgentUpdateArgs.CameraUpAxis = x.CameraUpAxis;
6008 
6009  UpdateAgent handlerAgentCameraUpdate = OnAgentCameraUpdate;
6010 
6011  if (handlerAgentCameraUpdate != null)
6012  handlerAgentCameraUpdate(this, m_thisAgentUpdateArgs);
6013 
6014  handlerAgentCameraUpdate = null;
6015  }
6016 
6017  PacketPool.Instance.ReturnPacket(packet);
6018 
6019  return true;
6020  }
6021 
6022  private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
6023  {
6024  MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
6025  // validate the agent owns the agentID and sessionID
6026  if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId &&
6027  money.AgentData.SessionID == sender.SessionId)
6028  {
6029  MoneyTransferRequest handlerMoneyTransferRequest = OnMoneyTransferRequest;
6030  if (handlerMoneyTransferRequest != null)
6031  {
6032  handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
6033  money.MoneyData.Amount, money.MoneyData.TransactionType,
6034  Util.FieldToString(money.MoneyData.Description));
6035  }
6036 
6037  return true;
6038  }
6039 
6040  return false;
6041  }
6042 
6043  private bool HandleParcelGodMarkAsContent(IClientAPI client, Packet Packet)
6044  {
6045  ParcelGodMarkAsContentPacket ParcelGodMarkAsContent =
6046  (ParcelGodMarkAsContentPacket)Packet;
6047 
6048  ParcelGodMark ParcelGodMarkAsContentHandler = OnParcelGodMark;
6049  if (ParcelGodMarkAsContentHandler != null)
6050  {
6051  ParcelGodMarkAsContentHandler(this,
6052  ParcelGodMarkAsContent.AgentData.AgentID,
6053  ParcelGodMarkAsContent.ParcelData.LocalID);
6054  return true;
6055  }
6056  return false;
6057  }
6058 
6059  private bool HandleFreezeUser(IClientAPI client, Packet Packet)
6060  {
6061  FreezeUserPacket FreezeUser = (FreezeUserPacket)Packet;
6062 
6063  FreezeUserUpdate FreezeUserHandler = OnParcelFreezeUser;
6064  if (FreezeUserHandler != null)
6065  {
6066  FreezeUserHandler(this,
6067  FreezeUser.AgentData.AgentID,
6068  FreezeUser.Data.Flags,
6069  FreezeUser.Data.TargetID);
6070  return true;
6071  }
6072  return false;
6073  }
6074 
6075  private bool HandleEjectUser(IClientAPI client, Packet Packet)
6076  {
6077  EjectUserPacket EjectUser =
6078  (EjectUserPacket)Packet;
6079 
6080  EjectUserUpdate EjectUserHandler = OnParcelEjectUser;
6081  if (EjectUserHandler != null)
6082  {
6083  EjectUserHandler(this,
6084  EjectUser.AgentData.AgentID,
6085  EjectUser.Data.Flags,
6086  EjectUser.Data.TargetID);
6087  return true;
6088  }
6089  return false;
6090  }
6091 
6092  private bool HandleParcelBuyPass(IClientAPI client, Packet Packet)
6093  {
6094  ParcelBuyPassPacket ParcelBuyPass =
6095  (ParcelBuyPassPacket)Packet;
6096 
6097  ParcelBuyPass ParcelBuyPassHandler = OnParcelBuyPass;
6098  if (ParcelBuyPassHandler != null)
6099  {
6100  ParcelBuyPassHandler(this,
6101  ParcelBuyPass.AgentData.AgentID,
6102  ParcelBuyPass.ParcelData.LocalID);
6103  return true;
6104  }
6105  return false;
6106  }
6107 
6108  private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack)
6109  {
6110  ParcelBuyPacket parcel = (ParcelBuyPacket)Pack;
6111  if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == SessionId)
6112  {
6113  ParcelBuy handlerParcelBuy = OnParcelBuy;
6114  if (handlerParcelBuy != null)
6115  {
6116  handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final,
6117  parcel.Data.IsGroupOwned,
6118  parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area,
6119  parcel.ParcelData.Price,
6120  false);
6121  }
6122  return true;
6123  }
6124  return false;
6125  }
6126 
6127  private bool HandleUUIDGroupNameRequest(IClientAPI sender, Packet Pack)
6128  {
6129  UUIDGroupNameRequestPacket upack = (UUIDGroupNameRequestPacket)Pack;
6130 
6131 
6132  for (int i = 0; i < upack.UUIDNameBlock.Length; i++)
6133  {
6134  UUIDNameRequest handlerUUIDGroupNameRequest = OnUUIDGroupNameRequest;
6135  if (handlerUUIDGroupNameRequest != null)
6136  {
6137  handlerUUIDGroupNameRequest(upack.UUIDNameBlock[i].ID, this);
6138  }
6139  }
6140 
6141  return true;
6142  }
6143 
6144  public bool HandleGenericMessage(IClientAPI sender, Packet pack)
6145  {
6146  GenericMessagePacket gmpack = (GenericMessagePacket)pack;
6147  if (m_genericPacketHandlers.Count == 0) return false;
6148  if (gmpack.AgentData.SessionID != SessionId) return false;
6149 
6150  GenericMessage handlerGenericMessage = null;
6151 
6152  string method = Util.FieldToString(gmpack.MethodData.Method).ToLower().Trim();
6153 
6154  if (m_genericPacketHandlers.TryGetValue(method, out handlerGenericMessage))
6155  {
6156  List<string> msg = new List<string>();
6157  List<byte[]> msgBytes = new List<byte[]>();
6158 
6159  if (handlerGenericMessage != null)
6160  {
6161  foreach (GenericMessagePacket.ParamListBlock block in gmpack.ParamList)
6162  {
6163  msg.Add(Util.FieldToString(block.Parameter));
6164  msgBytes.Add(block.Parameter);
6165  }
6166  try
6167  {
6168  if (OnBinaryGenericMessage != null)
6169  {
6170  OnBinaryGenericMessage(this, method, msgBytes.ToArray());
6171  }
6172  handlerGenericMessage(sender, method, msg);
6173  return true;
6174  }
6175  catch (Exception e)
6176  {
6177  m_log.ErrorFormat(
6178  "[LLCLIENTVIEW]: Exeception when handling generic message {0}{1}", e.Message, e.StackTrace);
6179  }
6180  }
6181  }
6182 
6183  //m_log.Debug("[LLCLIENTVIEW]: Not handling GenericMessage with method-type of: " + method);
6184  return false;
6185  }
6186 
6187  public bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack)
6188  {
6189  ObjectGroupPacket ogpack = (ObjectGroupPacket)Pack;
6190  if (ogpack.AgentData.SessionID != SessionId) return false;
6191 
6192  RequestObjectPropertiesFamily handlerObjectGroupRequest = OnObjectGroupRequest;
6193  if (handlerObjectGroupRequest != null)
6194  {
6195  for (int i = 0; i < ogpack.ObjectData.Length; i++)
6196  {
6197  handlerObjectGroupRequest(this, ogpack.AgentData.GroupID, ogpack.ObjectData[i].ObjectLocalID, UUID.Zero);
6198  }
6199  }
6200  return true;
6201  }
6202 
6203  private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
6204  {
6205  ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
6206  if (viewer.AgentData.SessionID != SessionId) return false;
6207  ViewerEffectEventHandler handlerViewerEffect = OnViewerEffect;
6208  if (handlerViewerEffect != null)
6209  {
6210  int length = viewer.Effect.Length;
6211  List<ViewerEffectEventHandlerArg> args = new List<ViewerEffectEventHandlerArg>(length);
6212  for (int i = 0; i < length; i++)
6213  {
6214  //copy the effects block arguments into the event handler arg.
6216  argument.AgentID = viewer.Effect[i].AgentID;
6217  argument.Color = viewer.Effect[i].Color;
6218  argument.Duration = viewer.Effect[i].Duration;
6219  argument.ID = viewer.Effect[i].ID;
6220  argument.Type = viewer.Effect[i].Type;
6221  argument.TypeData = viewer.Effect[i].TypeData;
6222  args.Add(argument);
6223  }
6224 
6225  handlerViewerEffect(sender, args);
6226  }
6227 
6228  return true;
6229  }
6230 
6231  private bool HandleVelocityInterpolateOff(IClientAPI sender, Packet Pack)
6232  {
6233  VelocityInterpolateOffPacket p = (VelocityInterpolateOffPacket)Pack;
6234  if (p.AgentData.SessionID != SessionId ||
6235  p.AgentData.AgentID != AgentId)
6236  return true;
6237 
6238  m_VelocityInterpolate = false;
6239  return true;
6240  }
6241 
6242  private bool HandleVelocityInterpolateOn(IClientAPI sender, Packet Pack)
6243  {
6244  VelocityInterpolateOnPacket p = (VelocityInterpolateOnPacket)Pack;
6245  if (p.AgentData.SessionID != SessionId ||
6246  p.AgentData.AgentID != AgentId)
6247  return true;
6248 
6249  m_VelocityInterpolate = true;
6250  return true;
6251  }
6252 
6253 
6254  private bool HandleAvatarPropertiesRequest(IClientAPI sender, Packet Pack)
6255  {
6256  AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
6257 
6258  #region Packet Session and User Check
6259  if (m_checkPackets)
6260  {
6261  if (avatarProperties.AgentData.SessionID != SessionId ||
6262  avatarProperties.AgentData.AgentID != AgentId)
6263  return true;
6264  }
6265  #endregion
6266 
6267  RequestAvatarProperties handlerRequestAvatarProperties = OnRequestAvatarProperties;
6268  if (handlerRequestAvatarProperties != null)
6269  {
6270  handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
6271  }
6272  return true;
6273  }
6274 
6275  private bool HandleChatFromViewer(IClientAPI sender, Packet Pack)
6276  {
6277  ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
6278 
6279  #region Packet Session and User Check
6280  if (m_checkPackets)
6281  {
6282  if (inchatpack.AgentData.SessionID != SessionId ||
6283  inchatpack.AgentData.AgentID != AgentId)
6284  return true;
6285  }
6286  #endregion
6287 
6288  string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
6289  byte[] message = inchatpack.ChatData.Message;
6290  byte type = inchatpack.ChatData.Type;
6291  Vector3 fromPos = new Vector3(); // ClientAvatar.Pos;
6292  // UUID fromAgentID = AgentId;
6293 
6294  int channel = inchatpack.ChatData.Channel;
6295 
6296  if (OnChatFromClient != null)
6297  {
6298  OSChatMessage args = new OSChatMessage();
6299  args.Channel = channel;
6300  args.From = fromName;
6301  args.Message = Utils.BytesToString(message);
6302  args.Type = (ChatTypeEnum)type;
6303  args.Position = fromPos;
6304 
6305  args.Scene = Scene;
6306  args.Sender = this;
6307  args.SenderUUID = this.AgentId;
6308 
6309  ChatMessage handlerChatFromClient = OnChatFromClient;
6310  if (handlerChatFromClient != null)
6311  handlerChatFromClient(this, args);
6312  }
6313  return true;
6314  }
6315 
6316  private bool HandlerAvatarPropertiesUpdate(IClientAPI sender, Packet Pack)
6317  {
6318  AvatarPropertiesUpdatePacket avatarProps = (AvatarPropertiesUpdatePacket)Pack;
6319 
6320  #region Packet Session and User Check
6321  if (m_checkPackets)
6322  {
6323  if (avatarProps.AgentData.SessionID != SessionId ||
6324  avatarProps.AgentData.AgentID != AgentId)
6325  return true;
6326  }
6327  #endregion
6328 
6329  UpdateAvatarProperties handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
6330  if (handlerUpdateAvatarProperties != null)
6331  {
6332  AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = avatarProps.PropertiesData;
6333  UserProfileData UserProfile = new UserProfileData();
6334  UserProfile.ID = AgentId;
6335  UserProfile.AboutText = Utils.BytesToString(Properties.AboutText);
6336  UserProfile.FirstLifeAboutText = Utils.BytesToString(Properties.FLAboutText);
6337  UserProfile.FirstLifeImage = Properties.FLImageID;
6338  UserProfile.Image = Properties.ImageID;
6339  UserProfile.ProfileUrl = Utils.BytesToString(Properties.ProfileURL);
6340  UserProfile.UserFlags &= ~3;
6341  UserProfile.UserFlags |= Properties.AllowPublish ? 1 : 0;
6342  UserProfile.UserFlags |= Properties.MaturePublish ? 2 : 0;
6343 
6344  handlerUpdateAvatarProperties(this, UserProfile);
6345  }
6346  return true;
6347  }
6348 
6349  private bool HandlerScriptDialogReply(IClientAPI sender, Packet Pack)
6350  {
6351  ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
6352 
6353  //m_log.DebugFormat("[CLIENT]: Received ScriptDialogReply from {0}", rdialog.Data.ObjectID);
6354 
6355  #region Packet Session and User Check
6356  if (m_checkPackets)
6357  {
6358  if (rdialog.AgentData.SessionID != SessionId ||
6359  rdialog.AgentData.AgentID != AgentId)
6360  return true;
6361  }
6362  #endregion
6363 
6364  int ch = rdialog.Data.ChatChannel;
6365  byte[] msg = rdialog.Data.ButtonLabel;
6366  if (OnChatFromClient != null)
6367  {
6368  OSChatMessage args = new OSChatMessage();
6369  args.Channel = ch;
6370  args.From = String.Empty;
6371  args.Message = Utils.BytesToString(msg);
6372  args.Type = ChatTypeEnum.Region; //Behaviour in SL is that the response can be heard from any distance
6373  args.Position = new Vector3();
6374  args.Scene = Scene;
6375  args.Sender = this;
6376  ChatMessage handlerChatFromClient2 = OnChatFromClient;
6377  if (handlerChatFromClient2 != null)
6378  handlerChatFromClient2(this, args);
6379  }
6380 
6381  return true;
6382  }
6383 
6384  private bool HandlerImprovedInstantMessage(IClientAPI sender, Packet Pack)
6385  {
6386  ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
6387 
6388  #region Packet Session and User Check
6389  if (m_checkPackets)
6390  {
6391  if (msgpack.AgentData.SessionID != SessionId ||
6392  msgpack.AgentData.AgentID != AgentId)
6393  return true;
6394  }
6395  #endregion
6396 
6397  string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
6398  string IMmessage = Utils.BytesToString(msgpack.MessageBlock.Message);
6399  ImprovedInstantMessage handlerInstantMessage = OnInstantMessage;
6400 
6401  if (handlerInstantMessage != null)
6402  {
6404  msgpack.AgentData.AgentID,
6405  IMfromName,
6406  msgpack.MessageBlock.ToAgentID,
6407  msgpack.MessageBlock.Dialog,
6408  msgpack.MessageBlock.FromGroup,
6409  IMmessage,
6410  msgpack.MessageBlock.ID,
6411  msgpack.MessageBlock.Offline != 0 ? true : false,
6412  msgpack.MessageBlock.Position,
6413  msgpack.MessageBlock.BinaryBucket,
6414  true);
6415 
6416  handlerInstantMessage(this, im);
6417  }
6418  return true;
6419 
6420  }
6421 
6422  private bool HandlerAcceptFriendship(IClientAPI sender, Packet Pack)
6423  {
6424  AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
6425 
6426  #region Packet Session and User Check
6427  if (m_checkPackets)
6428  {
6429  if (afriendpack.AgentData.SessionID != SessionId ||
6430  afriendpack.AgentData.AgentID != AgentId)
6431  return true;
6432  }
6433  #endregion
6434 
6435  // My guess is this is the folder to stick the calling card into
6436  List<UUID> callingCardFolders = new List<UUID>();
6437 
6438  UUID transactionID = afriendpack.TransactionBlock.TransactionID;
6439 
6440  for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
6441  {
6442  callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
6443  }
6444 
6445  FriendActionDelegate handlerApproveFriendRequest = OnApproveFriendRequest;
6446  if (handlerApproveFriendRequest != null)
6447  {
6448  handlerApproveFriendRequest(this, transactionID, callingCardFolders);
6449  }
6450 
6451  return true;
6452  }
6453 
6454  private bool HandlerDeclineFriendship(IClientAPI sender, Packet Pack)
6455  {
6456  DeclineFriendshipPacket dfriendpack = (DeclineFriendshipPacket)Pack;
6457 
6458  #region Packet Session and User Check
6459  if (m_checkPackets)
6460  {
6461  if (dfriendpack.AgentData.SessionID != SessionId ||
6462  dfriendpack.AgentData.AgentID != AgentId)
6463  return true;
6464  }
6465  #endregion
6466 
6467  if (OnDenyFriendRequest != null)
6468  {
6469  OnDenyFriendRequest(this,
6470  dfriendpack.TransactionBlock.TransactionID,
6471  null);
6472  }
6473  return true;
6474  }
6475 
6476  private bool HandlerTerminateFriendship(IClientAPI sender, Packet Pack)
6477  {
6478  TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
6479 
6480  #region Packet Session and User Check
6481  if (m_checkPackets)
6482  {
6483  if (tfriendpack.AgentData.SessionID != SessionId ||
6484  tfriendpack.AgentData.AgentID != AgentId)
6485  return true;
6486  }
6487  #endregion
6488 
6489  UUID exFriendID = tfriendpack.ExBlock.OtherID;
6490  FriendshipTermination TerminateFriendshipHandler = OnTerminateFriendship;
6491  if (TerminateFriendshipHandler != null)
6492  {
6493  TerminateFriendshipHandler(this, exFriendID);
6494  return true;
6495  }
6496 
6497  return false;
6498  }
6499 
6500  private bool HandleFindAgent(IClientAPI client, Packet Packet)
6501  {
6502  FindAgentPacket FindAgent =
6503  (FindAgentPacket)Packet;
6504 
6505  FindAgentUpdate FindAgentHandler = OnFindAgent;
6506  if (FindAgentHandler != null)
6507  {
6508  FindAgentHandler(this,FindAgent.AgentBlock.Hunter,FindAgent.AgentBlock.Prey);
6509  return true;
6510  }
6511  return false;
6512  }
6513 
6514  private bool HandleTrackAgent(IClientAPI client, Packet Packet)
6515  {
6516  TrackAgentPacket TrackAgent =
6517  (TrackAgentPacket)Packet;
6518 
6519  TrackAgentUpdate TrackAgentHandler = OnTrackAgent;
6520  if (TrackAgentHandler != null)
6521  {
6522  TrackAgentHandler(this,
6523  TrackAgent.AgentData.AgentID,
6524  TrackAgent.TargetData.PreyID);
6525  return true;
6526  }
6527  return false;
6528  }
6529 
6530  private bool HandlerRezObject(IClientAPI sender, Packet Pack)
6531  {
6532  RezObjectPacket rezPacket = (RezObjectPacket)Pack;
6533 
6534  #region Packet Session and User Check
6535  if (m_checkPackets)
6536  {
6537  if (rezPacket.AgentData.SessionID != SessionId ||
6538  rezPacket.AgentData.AgentID != AgentId)
6539  return true;
6540  }
6541  #endregion
6542 
6543  RezObject handlerRezObject = OnRezObject;
6544  if (handlerRezObject != null)
6545  {
6546  handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd,
6547  rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
6548  rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
6549  rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
6550  rezPacket.RezData.FromTaskID);
6551  }
6552  return true;
6553  }
6554 
6555  private bool HandlerDeRezObject(IClientAPI sender, Packet Pack)
6556  {
6557  DeRezObjectPacket DeRezPacket = (DeRezObjectPacket)Pack;
6558 
6559  #region Packet Session and User Check
6560  if (m_checkPackets)
6561  {
6562  if (DeRezPacket.AgentData.SessionID != SessionId ||
6563  DeRezPacket.AgentData.AgentID != AgentId)
6564  return true;
6565  }
6566  #endregion
6567 
6568  DeRezObject handlerDeRezObject = OnDeRezObject;
6569  if (handlerDeRezObject != null)
6570  {
6571  List<uint> deRezIDs = new List<uint>();
6572 
6573  foreach (DeRezObjectPacket.ObjectDataBlock data in
6574  DeRezPacket.ObjectData)
6575  {
6576  deRezIDs.Add(data.ObjectLocalID);
6577  }
6578  // It just so happens that the values on the DeRezAction enumerator match the Destination
6579  // values given by a Second Life client
6580  handlerDeRezObject(this, deRezIDs,
6581  DeRezPacket.AgentBlock.GroupID,
6582  (DeRezAction)DeRezPacket.AgentBlock.Destination,
6583  DeRezPacket.AgentBlock.DestinationID);
6584 
6585  }
6586  return true;
6587  }
6588 
6589  private bool HandlerRezRestoreToWorld(IClientAPI sender, Packet Pack)
6590  {
6591  RezRestoreToWorldPacket restore = (RezRestoreToWorldPacket)Pack;
6592 
6593  #region Packet Session and User Check
6594  if (m_checkPackets)
6595  {
6596  if (restore.AgentData.SessionID != SessionId ||
6597  restore.AgentData.AgentID != AgentId)
6598  return true;
6599  }
6600  #endregion
6601 
6602  RezRestoreToWorld handlerRezRestoreToWorld = OnRezRestoreToWorld;
6603  if (handlerRezRestoreToWorld != null)
6604  handlerRezRestoreToWorld(this, restore.InventoryData.ItemID);
6605 
6606  return true;
6607  }
6608 
6609  private bool HandlerModifyLand(IClientAPI sender, Packet Pack)
6610  {
6611  ModifyLandPacket modify = (ModifyLandPacket)Pack;
6612 
6613  #region Packet Session and User Check
6614  if (m_checkPackets)
6615  {
6616  if (modify.AgentData.SessionID != SessionId ||
6617  modify.AgentData.AgentID != AgentId)
6618  return true;
6619  }
6620 
6621  #endregion
6622  //m_log.Info("[LAND]: LAND:" + modify.ToString());
6623  if (modify.ParcelData.Length > 0)
6624  {
6625  // Note: the ModifyTerrain event handler sends out updated packets before the end of this event. Therefore,
6626  // a simple boolean value should work and perhaps queue up just a few terrain patch packets at the end of the edit.
6627  if (OnModifyTerrain != null)
6628  {
6629  for (int i = 0; i < modify.ParcelData.Length; i++)
6630  {
6631  ModifyTerrain handlerModifyTerrain = OnModifyTerrain;
6632  if (handlerModifyTerrain != null)
6633  {
6634  handlerModifyTerrain(AgentId, modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
6635  modify.ModifyBlock.BrushSize,
6636  modify.ModifyBlock.Action, modify.ParcelData[i].North,
6637  modify.ParcelData[i].West, modify.ParcelData[i].South,
6638  modify.ParcelData[i].East, AgentId);
6639  }
6640  }
6641  }
6642  }
6643 
6644  return true;
6645  }
6646 
6647  private bool HandlerRegionHandshakeReply(IClientAPI sender, Packet Pack)
6648  {
6649  Action<IClientAPI> handlerRegionHandShakeReply = OnRegionHandShakeReply;
6650  if (handlerRegionHandShakeReply != null)
6651  {
6652  handlerRegionHandShakeReply(this);
6653  }
6654 
6655  return true;
6656  }
6657 
6658  private bool HandlerAgentWearablesRequest(IClientAPI sender, Packet Pack)
6659  {
6660  GenericCall1 handlerRequestWearables = OnRequestWearables;
6661 
6662  if (handlerRequestWearables != null)
6663  {
6664  handlerRequestWearables(sender);
6665  }
6666 
6667  Action<IClientAPI> handlerRequestAvatarsData = OnRequestAvatarsData;
6668 
6669  if (handlerRequestAvatarsData != null)
6670  {
6671  handlerRequestAvatarsData(this);
6672  }
6673 
6674  return true;
6675  }
6676 
6677  private bool HandlerAgentSetAppearance(IClientAPI sender, Packet Pack)
6678  {
6679  AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
6680 
6681  #region Packet Session and User Check
6682  if (m_checkPackets)
6683  {
6684  if (appear.AgentData.SessionID != SessionId ||
6685  appear.AgentData.AgentID != AgentId)
6686  return true;
6687  }
6688  #endregion
6689 
6690  SetAppearance handlerSetAppearance = OnSetAppearance;
6691  if (handlerSetAppearance != null)
6692  {
6693  // Temporarily protect ourselves from the mantis #951 failure.
6694  // However, we could do this for several other handlers where a failure isn't terminal
6695  // for the client session anyway, in order to protect ourselves against bad code in plugins
6696  Vector3 avSize = appear.AgentData.Size;
6697  try
6698  {
6699  byte[] visualparams = new byte[appear.VisualParam.Length];
6700  for (int i = 0; i < appear.VisualParam.Length; i++)
6701  visualparams[i] = appear.VisualParam[i].ParamValue;
6702  //var b = appear.WearableData[0];
6703 
6704  Primitive.TextureEntry te = null;
6705  if (appear.ObjectData.TextureEntry.Length > 1)
6706  te = new Primitive.TextureEntry(appear.ObjectData.TextureEntry, 0, appear.ObjectData.TextureEntry.Length);
6707 
6708  WearableCacheItem[] cacheitems = new WearableCacheItem[appear.WearableData.Length];
6709  for (int i=0; i<appear.WearableData.Length;i++)
6710  cacheitems[i] = new WearableCacheItem(){
6711  CacheId = appear.WearableData[i].CacheID,
6712  TextureIndex=Convert.ToUInt32(appear.WearableData[i].TextureIndex)
6713  };
6714 
6715 
6716 
6717  handlerSetAppearance(sender, te, visualparams,avSize, cacheitems);
6718  }
6719  catch (Exception e)
6720  {
6721  m_log.ErrorFormat(
6722  "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
6723  e);
6724  }
6725  }
6726 
6727  return true;
6728  }
6729 
6730  private bool HandlerAgentIsNowWearing(IClientAPI sender, Packet Pack)
6731  {
6732  if (OnAvatarNowWearing != null)
6733  {
6734  AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
6735 
6736  #region Packet Session and User Check
6737  if (m_checkPackets)
6738  {
6739  if (nowWearing.AgentData.SessionID != SessionId ||
6740  nowWearing.AgentData.AgentID != AgentId)
6741  return true;
6742  }
6743  #endregion
6744 
6745  AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
6746  for (int i = 0; i < nowWearing.WearableData.Length; i++)
6747  {
6748  //m_log.DebugFormat("[XXX]: Wearable type {0} item {1}", nowWearing.WearableData[i].WearableType, nowWearing.WearableData[i].ItemID);
6749  AvatarWearingArgs.Wearable wearable =
6750  new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
6751  nowWearing.WearableData[i].WearableType);
6752  wearingArgs.NowWearing.Add(wearable);
6753  }
6754 
6755  AvatarNowWearing handlerAvatarNowWearing = OnAvatarNowWearing;
6756  if (handlerAvatarNowWearing != null)
6757  {
6758  handlerAvatarNowWearing(this, wearingArgs);
6759  }
6760  }
6761  return true;
6762  }
6763 
6764  private bool HandlerRezSingleAttachmentFromInv(IClientAPI sender, Packet Pack)
6765  {
6766  RezSingleAttachmentFromInv handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
6767  if (handlerRezSingleAttachment != null)
6768  {
6769  RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
6770 
6771  #region Packet Session and User Check
6772  if (m_checkPackets)
6773  {
6774  if (rez.AgentData.SessionID != SessionId ||
6775  rez.AgentData.AgentID != AgentId)
6776  return true;
6777  }
6778  #endregion
6779 
6780  handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
6781  rez.ObjectData.AttachmentPt);
6782  }
6783 
6784  return true;
6785  }
6786 
6787  private bool HandleRezMultipleAttachmentsFromInv(IClientAPI sender, Packet Pack)
6788  {
6789  RezMultipleAttachmentsFromInv handlerRezMultipleAttachments = OnRezMultipleAttachmentsFromInv;
6790  if (handlerRezMultipleAttachments != null)
6791  {
6792  List<KeyValuePair<UUID, uint>> rezlist = new List<KeyValuePair<UUID, uint>>();
6793  foreach (RezMultipleAttachmentsFromInvPacket.ObjectDataBlock obj in ((RezMultipleAttachmentsFromInvPacket)Pack).ObjectData)
6794  rezlist.Add(new KeyValuePair<UUID, uint>(obj.ItemID, obj.AttachmentPt));
6795  handlerRezMultipleAttachments(this, rezlist);
6796  }
6797 
6798  return true;
6799  }
6800 
6801  private bool HandleDetachAttachmentIntoInv(IClientAPI sender, Packet Pack)
6802  {
6803  UUIDNameRequest handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
6804  if (handlerDetachAttachmentIntoInv != null)
6805  {
6806  DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
6807 
6808  #region Packet Session and User Check
6809  // UNSUPPORTED ON THIS PACKET
6810  #endregion
6811 
6812  UUID itemID = detachtoInv.ObjectData.ItemID;
6813  // UUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
6814 
6815  handlerDetachAttachmentIntoInv(itemID, this);
6816  }
6817  return true;
6818  }
6819 
6820  private bool HandleObjectAttach(IClientAPI sender, Packet Pack)
6821  {
6822  if (OnObjectAttach != null)
6823  {
6824  ObjectAttachPacket att = (ObjectAttachPacket)Pack;
6825 
6826  #region Packet Session and User Check
6827  if (m_checkPackets)
6828  {
6829  if (att.AgentData.SessionID != SessionId ||
6830  att.AgentData.AgentID != AgentId)
6831  return true;
6832  }
6833  #endregion
6834 
6835  ObjectAttach handlerObjectAttach = OnObjectAttach;
6836 
6837  if (handlerObjectAttach != null)
6838  {
6839  if (att.ObjectData.Length > 0)
6840  {
6841  handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, false);
6842  }
6843  }
6844  }
6845  return true;
6846  }
6847 
6848  private bool HandleObjectDetach(IClientAPI sender, Packet Pack)
6849  {
6850  ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
6851 
6852  #region Packet Session and User Check
6853  if (m_checkPackets)
6854  {
6855  if (dett.AgentData.SessionID != SessionId ||
6856  dett.AgentData.AgentID != AgentId)
6857  return true;
6858  }
6859  #endregion
6860 
6861  for (int j = 0; j < dett.ObjectData.Length; j++)
6862  {
6863  uint obj = dett.ObjectData[j].ObjectLocalID;
6864  ObjectDeselect handlerObjectDetach = OnObjectDetach;
6865  if (handlerObjectDetach != null)
6866  {
6867  handlerObjectDetach(obj, this);
6868  }
6869 
6870  }
6871  return true;
6872  }
6873 
6874  private bool HandleObjectDrop(IClientAPI sender, Packet Pack)
6875  {
6876  ObjectDropPacket dropp = (ObjectDropPacket)Pack;
6877 
6878  #region Packet Session and User Check
6879  if (m_checkPackets)
6880  {
6881  if (dropp.AgentData.SessionID != SessionId ||
6882  dropp.AgentData.AgentID != AgentId)
6883  return true;
6884  }
6885  #endregion
6886 
6887  for (int j = 0; j < dropp.ObjectData.Length; j++)
6888  {
6889  uint obj = dropp.ObjectData[j].ObjectLocalID;
6890  ObjectDrop handlerObjectDrop = OnObjectDrop;
6891  if (handlerObjectDrop != null)
6892  {
6893  handlerObjectDrop(obj, this);
6894  }
6895  }
6896  return true;
6897  }
6898 
6899  private bool HandleSetAlwaysRun(IClientAPI sender, Packet Pack)
6900  {
6901  SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
6902 
6903  #region Packet Session and User Check
6904  if (m_checkPackets)
6905  {
6906  if (run.AgentData.SessionID != SessionId ||
6907  run.AgentData.AgentID != AgentId)
6908  return true;
6909  }
6910  #endregion
6911 
6912  SetAlwaysRun handlerSetAlwaysRun = OnSetAlwaysRun;
6913  if (handlerSetAlwaysRun != null)
6914  handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
6915 
6916  return true;
6917  }
6918 
6919  private bool HandleCompleteAgentMovement(IClientAPI sender, Packet Pack)
6920  {
6921  m_log.DebugFormat("[LLClientView] HandleCompleteAgentMovement");
6922 
6923  Action<IClientAPI, bool> handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
6924  if (handlerCompleteMovementToRegion != null)
6925  {
6926  handlerCompleteMovementToRegion(sender, true);
6927  }
6928  else
6929  m_log.Debug("HandleCompleteAgentMovement NULL handler");
6930 
6931  handlerCompleteMovementToRegion = null;
6932 
6933  return true;
6934  }
6935 
6936  private bool HandleAgentAnimation(IClientAPI sender, Packet Pack)
6937  {
6938  AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
6939 
6940  #region Packet Session and User Check
6941  if (m_checkPackets)
6942  {
6943  if (AgentAni.AgentData.SessionID != SessionId ||
6944  AgentAni.AgentData.AgentID != AgentId)
6945  return true;
6946  }
6947  #endregion
6948 /*
6949  StartAnim handlerStartAnim = null;
6950  StopAnim handlerStopAnim = null;
6951 
6952  for (int i = 0; i < AgentAni.AnimationList.Length; i++)
6953  {
6954  if (AgentAni.AnimationList[i].StartAnim)
6955  {
6956  handlerStartAnim = OnStartAnim;
6957  if (handlerStartAnim != null)
6958  {
6959  handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
6960  }
6961  }
6962  else
6963  {
6964  handlerStopAnim = OnStopAnim;
6965  if (handlerStopAnim != null)
6966  {
6967  handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
6968  }
6969  }
6970  }
6971  return true;
6972 */
6973  ChangeAnim handlerChangeAnim = null;
6974 
6975  for (int i = 0; i < AgentAni.AnimationList.Length; i++)
6976  {
6977  handlerChangeAnim = OnChangeAnim;
6978  if (handlerChangeAnim != null)
6979  {
6980  handlerChangeAnim(AgentAni.AnimationList[i].AnimID, AgentAni.AnimationList[i].StartAnim, false);
6981  }
6982  }
6983 
6984  handlerChangeAnim = OnChangeAnim;
6985  if (handlerChangeAnim != null)
6986  {
6987  handlerChangeAnim(UUID.Zero, false, true);
6988  }
6989 
6990  return true;
6991  }
6992 
6993  private bool HandleAgentRequestSit(IClientAPI sender, Packet Pack)
6994  {
6995  if (OnAgentRequestSit != null)
6996  {
6997  AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
6998 
6999  #region Packet Session and User Check
7000  if (m_checkPackets)
7001  {
7002  if (agentRequestSit.AgentData.SessionID != SessionId ||
7003  agentRequestSit.AgentData.AgentID != AgentId)
7004  return true;
7005  }
7006  #endregion
7007 
7008  if (SceneAgent.IsChildAgent)
7009  {
7010  SendCantSitBecauseChildAgentResponse();
7011  return true;
7012  }
7013 
7014  AgentRequestSit handlerAgentRequestSit = OnAgentRequestSit;
7015 
7016  if (handlerAgentRequestSit != null)
7017  handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
7018  agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
7019  }
7020  return true;
7021  }
7022 
7023  private bool HandleAgentSit(IClientAPI sender, Packet Pack)
7024  {
7025  if (OnAgentSit != null)
7026  {
7027  AgentSitPacket agentSit = (AgentSitPacket)Pack;
7028 
7029  #region Packet Session and User Check
7030  if (m_checkPackets)
7031  {
7032  if (agentSit.AgentData.SessionID != SessionId ||
7033  agentSit.AgentData.AgentID != AgentId)
7034  return true;
7035  }
7036  #endregion
7037 
7038  if (SceneAgent.IsChildAgent)
7039  {
7040  SendCantSitBecauseChildAgentResponse();
7041  return true;
7042  }
7043 
7044  AgentSit handlerAgentSit = OnAgentSit;
7045  if (handlerAgentSit != null)
7046  {
7047  OnAgentSit(this, agentSit.AgentData.AgentID);
7048  }
7049  }
7050  return true;
7051  }
7052 
7056  private void SendCantSitBecauseChildAgentResponse()
7057  {
7058  SendAlertMessage("Try moving closer. Can't sit on object because it is not in the same region as you.");
7059  }
7060 
7061  private bool HandleSoundTrigger(IClientAPI sender, Packet Pack)
7062  {
7063  SoundTriggerPacket soundTriggerPacket = (SoundTriggerPacket)Pack;
7064 
7065  #region Packet Session and User Check
7066  if (m_checkPackets)
7067  {
7068  // UNSUPPORTED ON THIS PACKET
7069  }
7070  #endregion
7071 
7072  SoundTrigger handlerSoundTrigger = OnSoundTrigger;
7073  if (handlerSoundTrigger != null)
7074  {
7075  // UUIDS are sent as zeroes by the client, substitute agent's id
7076  handlerSoundTrigger(soundTriggerPacket.SoundData.SoundID, AgentId,
7077  AgentId, AgentId,
7078  soundTriggerPacket.SoundData.Gain, soundTriggerPacket.SoundData.Position,
7079  soundTriggerPacket.SoundData.Handle, 0);
7080 
7081  }
7082  return true;
7083  }
7084 
7085  private bool HandleAvatarPickerRequest(IClientAPI sender, Packet Pack)
7086  {
7087  AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
7088 
7089  #region Packet Session and User Check
7090  if (m_checkPackets)
7091  {
7092  if (avRequestQuery.AgentData.SessionID != SessionId ||
7093  avRequestQuery.AgentData.AgentID != AgentId)
7094  return true;
7095  }
7096  #endregion
7097 
7098  AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
7099  AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
7100  //m_log.Debug("Agent Sends:" + Utils.BytesToString(querydata.Name));
7101 
7102  AvatarPickerRequest handlerAvatarPickerRequest = OnAvatarPickerRequest;
7103  if (handlerAvatarPickerRequest != null)
7104  {
7105  handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
7106  Utils.BytesToString(querydata.Name));
7107  }
7108  return true;
7109  }
7110 
7111  private bool HandleAgentDataUpdateRequest(IClientAPI sender, Packet Pack)
7112  {
7113  AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
7114 
7115  #region Packet Session and User Check
7116  if (m_checkPackets)
7117  {
7118  if (avRequestDataUpdatePacket.AgentData.SessionID != SessionId ||
7119  avRequestDataUpdatePacket.AgentData.AgentID != AgentId)
7120  return true;
7121  }
7122  #endregion
7123 
7124  FetchInventory handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
7125 
7126  if (handlerAgentDataUpdateRequest != null)
7127  {
7128  handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
7129  }
7130 
7131  return true;
7132  }
7133 
7134  private bool HandleUserInfoRequest(IClientAPI sender, Packet Pack)
7135  {
7136  UserInfoRequest handlerUserInfoRequest = OnUserInfoRequest;
7137  if (handlerUserInfoRequest != null)
7138  {
7139  handlerUserInfoRequest(this);
7140  }
7141  else
7142  {
7143  SendUserInfoReply(false, true, "");
7144  }
7145  return true;
7146 
7147  }
7148 
7149  private bool HandleUpdateUserInfo(IClientAPI sender, Packet Pack)
7150  {
7151  UpdateUserInfoPacket updateUserInfo = (UpdateUserInfoPacket)Pack;
7152 
7153  #region Packet Session and User Check
7154  if (m_checkPackets)
7155  {
7156  if (updateUserInfo.AgentData.SessionID != SessionId ||
7157  updateUserInfo.AgentData.AgentID != AgentId)
7158  return true;
7159  }
7160  #endregion
7161 
7162  UpdateUserInfo handlerUpdateUserInfo = OnUpdateUserInfo;
7163  if (handlerUpdateUserInfo != null)
7164  {
7165  bool visible = true;
7166  string DirectoryVisibility =
7167  Utils.BytesToString(updateUserInfo.UserData.DirectoryVisibility);
7168  if (DirectoryVisibility == "hidden")
7169  visible = false;
7170 
7171  handlerUpdateUserInfo(
7172  updateUserInfo.UserData.IMViaEMail,
7173  visible, this);
7174  }
7175  return true;
7176  }
7177 
7178  private bool HandleSetStartLocationRequest(IClientAPI sender, Packet Pack)
7179  {
7180  SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
7181 
7182  #region Packet Session and User Check
7183  if (m_checkPackets)
7184  {
7185  if (avSetStartLocationRequestPacket.AgentData.SessionID != SessionId ||
7186  avSetStartLocationRequestPacket.AgentData.AgentID != AgentId)
7187  return true;
7188  }
7189  #endregion
7190 
7191  if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
7192  {
7193  // Linden Client limitation..
7194  if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f
7195  || avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
7196  {
7197  ScenePresence avatar = null;
7198  if (((Scene)m_scene).TryGetScenePresence(AgentId, out avatar))
7199  {
7200  if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.X == 255.5f)
7201  {
7202  avSetStartLocationRequestPacket.StartLocationData.LocationPos.X = avatar.AbsolutePosition.X;
7203  }
7204  if (avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y == 255.5f)
7205  {
7206  avSetStartLocationRequestPacket.StartLocationData.LocationPos.Y = avatar.AbsolutePosition.Y;
7207  }
7208  }
7209 
7210  }
7211  TeleportLocationRequest handlerSetStartLocationRequest = OnSetStartLocationRequest;
7212  if (handlerSetStartLocationRequest != null)
7213  {
7214  handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
7215  avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
7216  avSetStartLocationRequestPacket.StartLocationData.LocationID);
7217  }
7218  }
7219  return true;
7220  }
7221 
7222  private bool HandleAgentThrottle(IClientAPI sender, Packet Pack)
7223  {
7224  AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
7225 
7226  #region Packet Session and User Check
7227  if (m_checkPackets)
7228  {
7229  if (atpack.AgentData.SessionID != SessionId ||
7230  atpack.AgentData.AgentID != AgentId)
7231  return true;
7232  }
7233  #endregion
7234 
7235  m_udpClient.SetThrottles(atpack.Throttle.Throttles);
7236  GenericCall2 handler = OnUpdateThrottles;
7237  if (handler != null)
7238  {
7239  handler();
7240  }
7241  return true;
7242  }
7243 
7244  private bool HandleAgentPause(IClientAPI sender, Packet Pack)
7245  {
7246  m_udpClient.IsPaused = true;
7247  return true;
7248  }
7249 
7250  private bool HandleAgentResume(IClientAPI sender, Packet Pack)
7251  {
7252  m_udpClient.IsPaused = false;
7253  SendStartPingCheck(m_udpClient.CurrentPingSequence++);
7254  return true;
7255  }
7256 
7257  private bool HandleForceScriptControlRelease(IClientAPI sender, Packet Pack)
7258  {
7259  ForceReleaseControls handlerForceReleaseControls = OnForceReleaseControls;
7260  if (handlerForceReleaseControls != null)
7261  {
7262  handlerForceReleaseControls(this, AgentId);
7263  }
7264  return true;
7265  }
7266 
7267  #endregion Scene/Avatar
7268 
7269  #region Objects/m_sceneObjects
7270 
7271  private bool HandleObjectLink(IClientAPI sender, Packet Pack)
7272  {
7273  ObjectLinkPacket link = (ObjectLinkPacket)Pack;
7274 
7275  #region Packet Session and User Check
7276  if (m_checkPackets)
7277  {
7278  if (link.AgentData.SessionID != SessionId ||
7279  link.AgentData.AgentID != AgentId)
7280  return true;
7281  }
7282  #endregion
7283 
7284  uint parentprimid = 0;
7285  List<uint> childrenprims = new List<uint>();
7286  if (link.ObjectData.Length > 1)
7287  {
7288  parentprimid = link.ObjectData[0].ObjectLocalID;
7289 
7290  for (int i = 1; i < link.ObjectData.Length; i++)
7291  {
7292  childrenprims.Add(link.ObjectData[i].ObjectLocalID);
7293  }
7294  }
7295  LinkObjects handlerLinkObjects = OnLinkObjects;
7296  if (handlerLinkObjects != null)
7297  {
7298  handlerLinkObjects(this, parentprimid, childrenprims);
7299  }
7300  return true;
7301  }
7302 
7303  private bool HandleObjectDelink(IClientAPI sender, Packet Pack)
7304  {
7305  ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
7306 
7307  #region Packet Session and User Check
7308  if (m_checkPackets)
7309  {
7310  if (delink.AgentData.SessionID != SessionId ||
7311  delink.AgentData.AgentID != AgentId)
7312  return true;
7313  }
7314  #endregion
7315 
7316  // It appears the prim at index 0 is not always the root prim (for
7317  // instance, when one prim of a link set has been edited independently
7318  // of the others). Therefore, we'll pass all the ids onto the delink
7319  // method for it to decide which is the root.
7320  List<uint> prims = new List<uint>();
7321  for (int i = 0; i < delink.ObjectData.Length; i++)
7322  {
7323  prims.Add(delink.ObjectData[i].ObjectLocalID);
7324  }
7325  DelinkObjects handlerDelinkObjects = OnDelinkObjects;
7326  if (handlerDelinkObjects != null)
7327  {
7328  handlerDelinkObjects(prims, this);
7329  }
7330 
7331  return true;
7332  }
7333 
7334  private bool HandleObjectAdd(IClientAPI sender, Packet Pack)
7335  {
7336  if (OnAddPrim != null)
7337  {
7338  ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
7339 
7340  #region Packet Session and User Check
7341  if (m_checkPackets)
7342  {
7343  if (addPacket.AgentData.SessionID != SessionId ||
7344  addPacket.AgentData.AgentID != AgentId)
7345  return true;
7346  }
7347  #endregion
7348 
7349  PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
7350  // m_log.Info("[REZData]: " + addPacket.ToString());
7351  //BypassRaycast: 1
7352  //RayStart: <69.79469, 158.2652, 98.40343>
7353  //RayEnd: <61.97724, 141.995, 92.58341>
7354  //RayTargetID: 00000000-0000-0000-0000-000000000000
7355 
7356  //Check to see if adding the prim is allowed; useful for any module wanting to restrict the
7357  //object from rezing initially
7358 
7359  AddNewPrim handlerAddPrim = OnAddPrim;
7360  if (handlerAddPrim != null)
7361  handlerAddPrim(AgentId, ActiveGroupId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
7362  }
7363  return true;
7364  }
7365 
7366  private bool HandleObjectShape(IClientAPI sender, Packet Pack)
7367  {
7368  ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
7369 
7370  #region Packet Session and User Check
7371  if (m_checkPackets)
7372  {
7373  if (shapePacket.AgentData.SessionID != SessionId ||
7374  shapePacket.AgentData.AgentID != AgentId)
7375  return true;
7376  }
7377  #endregion
7378 
7379  UpdateShape handlerUpdatePrimShape = null;
7380  for (int i = 0; i < shapePacket.ObjectData.Length; i++)
7381  {
7382  handlerUpdatePrimShape = OnUpdatePrimShape;
7383  if (handlerUpdatePrimShape != null)
7384  {
7385  UpdateShapeArgs shapeData = new UpdateShapeArgs();
7386  shapeData.ObjectLocalID = shapePacket.ObjectData[i].ObjectLocalID;
7387  shapeData.PathBegin = shapePacket.ObjectData[i].PathBegin;
7388  shapeData.PathCurve = shapePacket.ObjectData[i].PathCurve;
7389  shapeData.PathEnd = shapePacket.ObjectData[i].PathEnd;
7390  shapeData.PathRadiusOffset = shapePacket.ObjectData[i].PathRadiusOffset;
7391  shapeData.PathRevolutions = shapePacket.ObjectData[i].PathRevolutions;
7392  shapeData.PathScaleX = shapePacket.ObjectData[i].PathScaleX;
7393  shapeData.PathScaleY = shapePacket.ObjectData[i].PathScaleY;
7394  shapeData.PathShearX = shapePacket.ObjectData[i].PathShearX;
7395  shapeData.PathShearY = shapePacket.ObjectData[i].PathShearY;
7396  shapeData.PathSkew = shapePacket.ObjectData[i].PathSkew;
7397  shapeData.PathTaperX = shapePacket.ObjectData[i].PathTaperX;
7398  shapeData.PathTaperY = shapePacket.ObjectData[i].PathTaperY;
7399  shapeData.PathTwist = shapePacket.ObjectData[i].PathTwist;
7400  shapeData.PathTwistBegin = shapePacket.ObjectData[i].PathTwistBegin;
7401  shapeData.ProfileBegin = shapePacket.ObjectData[i].ProfileBegin;
7402  shapeData.ProfileCurve = shapePacket.ObjectData[i].ProfileCurve;
7403  shapeData.ProfileEnd = shapePacket.ObjectData[i].ProfileEnd;
7404  shapeData.ProfileHollow = shapePacket.ObjectData[i].ProfileHollow;
7405 
7406  handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
7407  shapeData);
7408  }
7409  }
7410  return true;
7411  }
7412 
7413  private bool HandleObjectExtraParams(IClientAPI sender, Packet Pack)
7414  {
7415  ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
7416 
7417  #region Packet Session and User Check
7418  if (m_checkPackets)
7419  {
7420  if (extraPar.AgentData.SessionID != SessionId ||
7421  extraPar.AgentData.AgentID != AgentId)
7422  return true;
7423  }
7424  #endregion
7425 
7426  ObjectExtraParams handlerUpdateExtraParams = OnUpdateExtraParams;
7427  if (handlerUpdateExtraParams != null)
7428  {
7429  for (int i = 0; i < extraPar.ObjectData.Length; i++)
7430  {
7431  handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[i].ObjectLocalID,
7432  extraPar.ObjectData[i].ParamType,
7433  extraPar.ObjectData[i].ParamInUse, extraPar.ObjectData[i].ParamData);
7434  }
7435  }
7436  return true;
7437  }
7438 
7439  private bool HandleObjectDuplicate(IClientAPI sender, Packet Pack)
7440  {
7441  ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
7442 
7443  #region Packet Session and User Check
7444  if (m_checkPackets)
7445  {
7446  if (dupe.AgentData.SessionID != SessionId ||
7447  dupe.AgentData.AgentID != AgentId)
7448  return true;
7449  }
7450  #endregion
7451 
7452 // ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
7453 
7454  ObjectDuplicate handlerObjectDuplicate = null;
7455 
7456  for (int i = 0; i < dupe.ObjectData.Length; i++)
7457  {
7458  handlerObjectDuplicate = OnObjectDuplicate;
7459  if (handlerObjectDuplicate != null)
7460  {
7461  handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
7462  dupe.SharedData.DuplicateFlags, AgentId,
7463  ActiveGroupId);
7464  }
7465  }
7466 
7467  return true;
7468  }
7469 
7470  private bool HandleRequestMultipleObjects(IClientAPI sender, Packet Pack)
7471  {
7472  RequestMultipleObjectsPacket incomingRequest = (RequestMultipleObjectsPacket)Pack;
7473 
7474  #region Packet Session and User Check
7475  if (m_checkPackets)
7476  {
7477  if (incomingRequest.AgentData.SessionID != SessionId ||
7478  incomingRequest.AgentData.AgentID != AgentId)
7479  return true;
7480  }
7481  #endregion
7482 
7483  ObjectRequest handlerObjectRequest = null;
7484 
7485  for (int i = 0; i < incomingRequest.ObjectData.Length; i++)
7486  {
7487  handlerObjectRequest = OnObjectRequest;
7488  if (handlerObjectRequest != null)
7489  {
7490  handlerObjectRequest(incomingRequest.ObjectData[i].ID, this);
7491  }
7492  }
7493  return true;
7494  }
7495 
7496  private bool HandleObjectSelect(IClientAPI sender, Packet Pack)
7497  {
7498  ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
7499 
7500  #region Packet Session and User Check
7501  if (m_checkPackets)
7502  {
7503  if (incomingselect.AgentData.SessionID != SessionId ||
7504  incomingselect.AgentData.AgentID != AgentId)
7505  return true;
7506  }
7507  #endregion
7508 
7509  ObjectSelect handlerObjectSelect = null;
7510 
7511  for (int i = 0; i < incomingselect.ObjectData.Length; i++)
7512  {
7513  if (!SelectedObjects.Contains(incomingselect.ObjectData[i].ObjectLocalID))
7514  SelectedObjects.Add(incomingselect.ObjectData[i].ObjectLocalID);
7515  handlerObjectSelect = OnObjectSelect;
7516  if (handlerObjectSelect != null)
7517  {
7518  handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
7519  }
7520  }
7521  return true;
7522  }
7523 
7524  private bool HandleObjectDeselect(IClientAPI sender, Packet Pack)
7525  {
7526  ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
7527 
7528  #region Packet Session and User Check
7529  if (m_checkPackets)
7530  {
7531  if (incomingdeselect.AgentData.SessionID != SessionId ||
7532  incomingdeselect.AgentData.AgentID != AgentId)
7533  return true;
7534  }
7535  #endregion
7536 
7537  ObjectDeselect handlerObjectDeselect = null;
7538 
7539  for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
7540  {
7541  if (!SelectedObjects.Contains(incomingdeselect.ObjectData[i].ObjectLocalID))
7542  SelectedObjects.Add(incomingdeselect.ObjectData[i].ObjectLocalID);
7543  handlerObjectDeselect = OnObjectDeselect;
7544  if (handlerObjectDeselect != null)
7545  {
7546  OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
7547  }
7548  }
7549  return true;
7550  }
7551 
7552  private bool HandleObjectPosition(IClientAPI sender, Packet Pack)
7553  {
7554  // DEPRECATED: but till libsecondlife removes it, people will use it
7555  ObjectPositionPacket position = (ObjectPositionPacket)Pack;
7556 
7557  #region Packet Session and User Check
7558  if (m_checkPackets)
7559  {
7560  if (position.AgentData.SessionID != SessionId ||
7561  position.AgentData.AgentID != AgentId)
7562  return true;
7563  }
7564  #endregion
7565 
7566 
7567  for (int i = 0; i < position.ObjectData.Length; i++)
7568  {
7569  UpdateVector handlerUpdateVector = OnUpdatePrimGroupPosition;
7570  if (handlerUpdateVector != null)
7571  handlerUpdateVector(position.ObjectData[i].ObjectLocalID, position.ObjectData[i].Position, this);
7572  }
7573 
7574  return true;
7575  }
7576 
7577  private bool HandleObjectScale(IClientAPI sender, Packet Pack)
7578  {
7579  // DEPRECATED: but till libsecondlife removes it, people will use it
7580  ObjectScalePacket scale = (ObjectScalePacket)Pack;
7581 
7582  #region Packet Session and User Check
7583  if (m_checkPackets)
7584  {
7585  if (scale.AgentData.SessionID != SessionId ||
7586  scale.AgentData.AgentID != AgentId)
7587  return true;
7588  }
7589  #endregion
7590 
7591  for (int i = 0; i < scale.ObjectData.Length; i++)
7592  {
7593  UpdateVector handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
7594  if (handlerUpdatePrimGroupScale != null)
7595  handlerUpdatePrimGroupScale(scale.ObjectData[i].ObjectLocalID, scale.ObjectData[i].Scale, this);
7596  }
7597 
7598  return true;
7599  }
7600 
7601  private bool HandleObjectRotation(IClientAPI sender, Packet Pack)
7602  {
7603  // DEPRECATED: but till libsecondlife removes it, people will use it
7604  ObjectRotationPacket rotation = (ObjectRotationPacket)Pack;
7605 
7606  #region Packet Session and User Check
7607  if (m_checkPackets)
7608  {
7609  if (rotation.AgentData.SessionID != SessionId ||
7610  rotation.AgentData.AgentID != AgentId)
7611  return true;
7612  }
7613  #endregion
7614 
7615  for (int i = 0; i < rotation.ObjectData.Length; i++)
7616  {
7617  UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
7618  if (handlerUpdatePrimRotation != null)
7619  handlerUpdatePrimRotation(rotation.ObjectData[i].ObjectLocalID, rotation.ObjectData[i].Rotation, this);
7620  }
7621 
7622  return true;
7623  }
7624 
7625  private bool HandleObjectFlagUpdate(IClientAPI sender, Packet Pack)
7626  {
7627  ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
7628 
7629  #region Packet Session and User Check
7630  if (m_checkPackets)
7631  {
7632  if (flags.AgentData.SessionID != SessionId ||
7633  flags.AgentData.AgentID != AgentId)
7634  return true;
7635  }
7636  #endregion
7637 
7638  UpdatePrimFlags handlerUpdatePrimFlags = OnUpdatePrimFlags;
7639 
7640  if (handlerUpdatePrimFlags != null)
7641  {
7642 // byte[] data = Pack.ToBytes();
7643  // 46,47,48 are special positions within the packet
7644  // This may change so perhaps we need a better way
7645  // of storing this (OMV.FlagUpdatePacket.UsePhysics,etc?)
7646  /*
7647  bool UsePhysics = (data[46] != 0) ? true : false;
7648  bool IsTemporary = (data[47] != 0) ? true : false;
7649  bool IsPhantom = (data[48] != 0) ? true : false;
7650  handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, this);
7651  */
7652  bool UsePhysics = flags.AgentData.UsePhysics;
7653  bool IsPhantom = flags.AgentData.IsPhantom;
7654  bool IsTemporary = flags.AgentData.IsTemporary;
7655  ObjectFlagUpdatePacket.ExtraPhysicsBlock[] blocks = flags.ExtraPhysics;
7656  ExtraPhysicsData physdata = new ExtraPhysicsData();
7657 
7658  if (blocks == null || blocks.Length == 0)
7659  {
7660  physdata.PhysShapeType = PhysShapeType.invalid;
7661  }
7662  else
7663  {
7664  ObjectFlagUpdatePacket.ExtraPhysicsBlock phsblock = blocks[0];
7665  physdata.PhysShapeType = (PhysShapeType)phsblock.PhysicsShapeType;
7666  physdata.Bounce = phsblock.Restitution;
7667  physdata.Density = phsblock.Density;
7668  physdata.Friction = phsblock.Friction;
7669  physdata.GravitationModifier = phsblock.GravityMultiplier;
7670  }
7671 
7672  handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, UsePhysics, IsTemporary, IsPhantom, physdata, this);
7673  }
7674  return true;
7675  }
7676 
7677  private bool HandleObjectImage(IClientAPI sender, Packet Pack)
7678  {
7679  ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
7680 
7681  UpdatePrimTexture handlerUpdatePrimTexture = null;
7682  for (int i = 0; i < imagePack.ObjectData.Length; i++)
7683  {
7684  handlerUpdatePrimTexture = OnUpdatePrimTexture;
7685  if (handlerUpdatePrimTexture != null)
7686  {
7687  handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID,
7688  imagePack.ObjectData[i].TextureEntry, this);
7689  }
7690  }
7691  return true;
7692  }
7693 
7694  private bool HandleObjectGrab(IClientAPI sender, Packet Pack)
7695  {
7696  ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
7697 
7698  #region Packet Session and User Check
7699  if (m_checkPackets)
7700  {
7701  if (grab.AgentData.SessionID != SessionId ||
7702  grab.AgentData.AgentID != AgentId)
7703  return true;
7704  }
7705  #endregion
7706 
7707  GrabObject handlerGrabObject = OnGrabObject;
7708 
7709  if (handlerGrabObject != null)
7710  {
7711  List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
7712  if ((grab.SurfaceInfo != null) && (grab.SurfaceInfo.Length > 0))
7713  {
7714  foreach (ObjectGrabPacket.SurfaceInfoBlock surfaceInfo in grab.SurfaceInfo)
7715  {
7717  arg.Binormal = surfaceInfo.Binormal;
7718  arg.FaceIndex = surfaceInfo.FaceIndex;
7719  arg.Normal = surfaceInfo.Normal;
7720  arg.Position = surfaceInfo.Position;
7721  arg.STCoord = surfaceInfo.STCoord;
7722  arg.UVCoord = surfaceInfo.UVCoord;
7723  touchArgs.Add(arg);
7724  }
7725  }
7726  handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this, touchArgs);
7727  }
7728  return true;
7729  }
7730 
7731  private bool HandleObjectGrabUpdate(IClientAPI sender, Packet Pack)
7732  {
7733  ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
7734 
7735  #region Packet Session and User Check
7736  if (m_checkPackets)
7737  {
7738  if (grabUpdate.AgentData.SessionID != SessionId ||
7739  grabUpdate.AgentData.AgentID != AgentId)
7740  return true;
7741  }
7742  #endregion
7743 
7744  MoveObject handlerGrabUpdate = OnGrabUpdate;
7745 
7746  if (handlerGrabUpdate != null)
7747  {
7748  List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
7749  if ((grabUpdate.SurfaceInfo != null) && (grabUpdate.SurfaceInfo.Length > 0))
7750  {
7751  foreach (ObjectGrabUpdatePacket.SurfaceInfoBlock surfaceInfo in grabUpdate.SurfaceInfo)
7752  {
7754  arg.Binormal = surfaceInfo.Binormal;
7755  arg.FaceIndex = surfaceInfo.FaceIndex;
7756  arg.Normal = surfaceInfo.Normal;
7757  arg.Position = surfaceInfo.Position;
7758  arg.STCoord = surfaceInfo.STCoord;
7759  arg.UVCoord = surfaceInfo.UVCoord;
7760  touchArgs.Add(arg);
7761  }
7762  }
7763  handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
7764  grabUpdate.ObjectData.GrabPosition, this, touchArgs);
7765  }
7766  return true;
7767  }
7768 
7769  private bool HandleObjectDeGrab(IClientAPI sender, Packet Pack)
7770  {
7771  ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
7772 
7773  #region Packet Session and User Check
7774  if (m_checkPackets)
7775  {
7776  if (deGrab.AgentData.SessionID != SessionId ||
7777  deGrab.AgentData.AgentID != AgentId)
7778  return true;
7779  }
7780  #endregion
7781 
7782  DeGrabObject handlerDeGrabObject = OnDeGrabObject;
7783  if (handlerDeGrabObject != null)
7784  {
7785  List<SurfaceTouchEventArgs> touchArgs = new List<SurfaceTouchEventArgs>();
7786  if ((deGrab.SurfaceInfo != null) && (deGrab.SurfaceInfo.Length > 0))
7787  {
7788  foreach (ObjectDeGrabPacket.SurfaceInfoBlock surfaceInfo in deGrab.SurfaceInfo)
7789  {
7791  arg.Binormal = surfaceInfo.Binormal;
7792  arg.FaceIndex = surfaceInfo.FaceIndex;
7793  arg.Normal = surfaceInfo.Normal;
7794  arg.Position = surfaceInfo.Position;
7795  arg.STCoord = surfaceInfo.STCoord;
7796  arg.UVCoord = surfaceInfo.UVCoord;
7797  touchArgs.Add(arg);
7798  }
7799  }
7800  handlerDeGrabObject(deGrab.ObjectData.LocalID, this, touchArgs);
7801  }
7802  return true;
7803  }
7804 
7805  private bool HandleObjectSpinStart(IClientAPI sender, Packet Pack)
7806  {
7807  //m_log.Warn("[CLIENT]: unhandled ObjectSpinStart packet");
7808  ObjectSpinStartPacket spinStart = (ObjectSpinStartPacket)Pack;
7809 
7810  #region Packet Session and User Check
7811  if (m_checkPackets)
7812  {
7813  if (spinStart.AgentData.SessionID != SessionId ||
7814  spinStart.AgentData.AgentID != AgentId)
7815  return true;
7816  }
7817  #endregion
7818 
7819  SpinStart handlerSpinStart = OnSpinStart;
7820  if (handlerSpinStart != null)
7821  {
7822  handlerSpinStart(spinStart.ObjectData.ObjectID, this);
7823  }
7824  return true;
7825  }
7826 
7827  private bool HandleObjectSpinUpdate(IClientAPI sender, Packet Pack)
7828  {
7829  //m_log.Warn("[CLIENT]: unhandled ObjectSpinUpdate packet");
7830  ObjectSpinUpdatePacket spinUpdate = (ObjectSpinUpdatePacket)Pack;
7831 
7832  #region Packet Session and User Check
7833  if (m_checkPackets)
7834  {
7835  if (spinUpdate.AgentData.SessionID != SessionId ||
7836  spinUpdate.AgentData.AgentID != AgentId)
7837  return true;
7838  }
7839  #endregion
7840 
7841  Vector3 axis;
7842  float angle;
7843  spinUpdate.ObjectData.Rotation.GetAxisAngle(out axis, out angle);
7844  //m_log.Warn("[CLIENT]: ObjectSpinUpdate packet rot axis:" + axis + " angle:" + angle);
7845 
7846  SpinObject handlerSpinUpdate = OnSpinUpdate;
7847  if (handlerSpinUpdate != null)
7848  {
7849  handlerSpinUpdate(spinUpdate.ObjectData.ObjectID, spinUpdate.ObjectData.Rotation, this);
7850  }
7851  return true;
7852  }
7853 
7854  private bool HandleObjectSpinStop(IClientAPI sender, Packet Pack)
7855  {
7856  //m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
7857  ObjectSpinStopPacket spinStop = (ObjectSpinStopPacket)Pack;
7858 
7859  #region Packet Session and User Check
7860  if (m_checkPackets)
7861  {
7862  if (spinStop.AgentData.SessionID != SessionId ||
7863  spinStop.AgentData.AgentID != AgentId)
7864  return true;
7865  }
7866  #endregion
7867 
7868  SpinStop handlerSpinStop = OnSpinStop;
7869  if (handlerSpinStop != null)
7870  {
7871  handlerSpinStop(spinStop.ObjectData.ObjectID, this);
7872  }
7873  return true;
7874  }
7875 
7876  private bool HandleObjectDescription(IClientAPI sender, Packet Pack)
7877  {
7878  ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
7879 
7880  #region Packet Session and User Check
7881  if (m_checkPackets)
7882  {
7883  if (objDes.AgentData.SessionID != SessionId ||
7884  objDes.AgentData.AgentID != AgentId)
7885  return true;
7886  }
7887  #endregion
7888 
7889  GenericCall7 handlerObjectDescription = null;
7890 
7891  for (int i = 0; i < objDes.ObjectData.Length; i++)
7892  {
7893  handlerObjectDescription = OnObjectDescription;
7894  if (handlerObjectDescription != null)
7895  {
7896  handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
7897  Util.FieldToString(objDes.ObjectData[i].Description));
7898  }
7899  }
7900  return true;
7901  }
7902 
7903  private bool HandleObjectName(IClientAPI sender, Packet Pack)
7904  {
7905  ObjectNamePacket objName = (ObjectNamePacket)Pack;
7906 
7907  #region Packet Session and User Check
7908  if (m_checkPackets)
7909  {
7910  if (objName.AgentData.SessionID != SessionId ||
7911  objName.AgentData.AgentID != AgentId)
7912  return true;
7913  }
7914  #endregion
7915 
7916  GenericCall7 handlerObjectName = null;
7917  for (int i = 0; i < objName.ObjectData.Length; i++)
7918  {
7919  handlerObjectName = OnObjectName;
7920  if (handlerObjectName != null)
7921  {
7922  handlerObjectName(this, objName.ObjectData[i].LocalID,
7923  Util.FieldToString(objName.ObjectData[i].Name));
7924  }
7925  }
7926  return true;
7927  }
7928 
7929  private bool HandleObjectPermissions(IClientAPI sender, Packet Pack)
7930  {
7931  if (OnObjectPermissions != null)
7932  {
7933  ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
7934 
7935  #region Packet Session and User Check
7936  if (m_checkPackets)
7937  {
7938  if (newobjPerms.AgentData.SessionID != SessionId ||
7939  newobjPerms.AgentData.AgentID != AgentId)
7940  return true;
7941  }
7942  #endregion
7943 
7944  UUID AgentID = newobjPerms.AgentData.AgentID;
7945  UUID SessionID = newobjPerms.AgentData.SessionID;
7946 
7947  ObjectPermissions handlerObjectPermissions = null;
7948 
7949  for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
7950  {
7951  ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
7952 
7953  byte field = permChanges.Field;
7954  uint localID = permChanges.ObjectLocalID;
7955  uint mask = permChanges.Mask;
7956  byte set = permChanges.Set;
7957 
7958  handlerObjectPermissions = OnObjectPermissions;
7959 
7960  if (handlerObjectPermissions != null)
7961  handlerObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
7962  }
7963  }
7964 
7965  // Here's our data,
7966  // PermField contains the field the info goes into
7967  // PermField determines which mask we're changing
7968  //
7969  // chmask is the mask of the change
7970  // setTF is whether we're adding it or taking it away
7971  //
7972  // objLocalID is the localID of the object.
7973 
7974  // Unfortunately, we have to pass the event the packet because objData is an array
7975  // That means multiple object perms may be updated in a single packet.
7976 
7977  return true;
7978  }
7979 
7980  private bool HandleUndo(IClientAPI sender, Packet Pack)
7981  {
7982  UndoPacket undoitem = (UndoPacket)Pack;
7983 
7984  #region Packet Session and User Check
7985  if (m_checkPackets)
7986  {
7987  if (undoitem.AgentData.SessionID != SessionId ||
7988  undoitem.AgentData.AgentID != AgentId)
7989  return true;
7990  }
7991  #endregion
7992 
7993  if (undoitem.ObjectData.Length > 0)
7994  {
7995  for (int i = 0; i < undoitem.ObjectData.Length; i++)
7996  {
7997  UUID objiD = undoitem.ObjectData[i].ObjectID;
7998  AgentSit handlerOnUndo = OnUndo;
7999  if (handlerOnUndo != null)
8000  {
8001  handlerOnUndo(this, objiD);
8002  }
8003 
8004  }
8005  }
8006  return true;
8007  }
8008 
8009  private bool HandleLandUndo(IClientAPI sender, Packet Pack)
8010  {
8011  UndoLandPacket undolanditem = (UndoLandPacket)Pack;
8012 
8013  #region Packet Session and User Check
8014  if (m_checkPackets)
8015  {
8016  if (undolanditem.AgentData.SessionID != SessionId ||
8017  undolanditem.AgentData.AgentID != AgentId)
8018  return true;
8019  }
8020  #endregion
8021 
8022  LandUndo handlerOnUndo = OnLandUndo;
8023  if (handlerOnUndo != null)
8024  {
8025  handlerOnUndo(this);
8026  }
8027  return true;
8028  }
8029 
8030  private bool HandleRedo(IClientAPI sender, Packet Pack)
8031  {
8032  RedoPacket redoitem = (RedoPacket)Pack;
8033 
8034  #region Packet Session and User Check
8035  if (m_checkPackets)
8036  {
8037  if (redoitem.AgentData.SessionID != SessionId ||
8038  redoitem.AgentData.AgentID != AgentId)
8039  return true;
8040  }
8041  #endregion
8042 
8043  if (redoitem.ObjectData.Length > 0)
8044  {
8045  for (int i = 0; i < redoitem.ObjectData.Length; i++)
8046  {
8047  UUID objiD = redoitem.ObjectData[i].ObjectID;
8048  AgentSit handlerOnRedo = OnRedo;
8049  if (handlerOnRedo != null)
8050  {
8051  handlerOnRedo(this, objiD);
8052  }
8053 
8054  }
8055  }
8056  return true;
8057  }
8058 
8059  private bool HandleObjectDuplicateOnRay(IClientAPI sender, Packet Pack)
8060  {
8061  ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
8062 
8063  #region Packet Session and User Check
8064  if (m_checkPackets)
8065  {
8066  if (dupeOnRay.AgentData.SessionID != SessionId ||
8067  dupeOnRay.AgentData.AgentID != AgentId)
8068  return true;
8069  }
8070  #endregion
8071 
8072  ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
8073 
8074  for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
8075  {
8076  handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
8077  if (handlerObjectDuplicateOnRay != null)
8078  {
8079  handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags,
8080  AgentId, ActiveGroupId, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
8081  dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection,
8082  dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
8083  }
8084  }
8085 
8086  return true;
8087  }
8088 
8089  private bool HandleRequestObjectPropertiesFamily(IClientAPI sender, Packet Pack)
8090  {
8091  //This powers the little tooltip that appears when you move your mouse over an object
8092  RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
8093 
8094  #region Packet Session and User Check
8095  if (m_checkPackets)
8096  {
8097  if (packToolTip.AgentData.SessionID != SessionId ||
8098  packToolTip.AgentData.AgentID != AgentId)
8099  return true;
8100  }
8101  #endregion
8102 
8103  RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
8104 
8105  RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
8106 
8107  if (handlerRequestObjectPropertiesFamily != null)
8108  {
8109  handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
8110  packObjBlock.ObjectID);
8111  }
8112 
8113  return true;
8114  }
8115 
8116  private bool HandleObjectIncludeInSearch(IClientAPI sender, Packet Pack)
8117  {
8118  //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
8119  ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
8120  ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
8121 
8122  #region Packet Session and User Check
8123  if (m_checkPackets)
8124  {
8125  if (packInSearch.AgentData.SessionID != SessionId ||
8126  packInSearch.AgentData.AgentID != AgentId)
8127  return true;
8128  }
8129  #endregion
8130 
8131  foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData)
8132  {
8133  bool inSearch = objData.IncludeInSearch;
8134  uint localID = objData.ObjectLocalID;
8135 
8136  handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
8137 
8138  if (handlerObjectIncludeInSearch != null)
8139  {
8140  handlerObjectIncludeInSearch(this, inSearch, localID);
8141  }
8142  }
8143  return true;
8144  }
8145 
8146  private bool HandleScriptAnswerYes(IClientAPI sender, Packet Pack)
8147  {
8148  ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
8149 
8150  #region Packet Session and User Check
8151  if (m_checkPackets)
8152  {
8153  if (scriptAnswer.AgentData.SessionID != SessionId ||
8154  scriptAnswer.AgentData.AgentID != AgentId)
8155  return true;
8156  }
8157  #endregion
8158 
8159  ScriptAnswer handlerScriptAnswer = OnScriptAnswer;
8160  if (handlerScriptAnswer != null)
8161  {
8162  handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
8163  }
8164  return true;
8165  }
8166 
8167  private bool HandleObjectClickAction(IClientAPI sender, Packet Pack)
8168  {
8169  ObjectClickActionPacket ocpacket = (ObjectClickActionPacket)Pack;
8170 
8171  #region Packet Session and User Check
8172  if (m_checkPackets)
8173  {
8174  if (ocpacket.AgentData.SessionID != SessionId ||
8175  ocpacket.AgentData.AgentID != AgentId)
8176  return true;
8177  }
8178  #endregion
8179 
8180  GenericCall7 handlerObjectClickAction = OnObjectClickAction;
8181  if (handlerObjectClickAction != null)
8182  {
8183  foreach (ObjectClickActionPacket.ObjectDataBlock odata in ocpacket.ObjectData)
8184  {
8185  byte action = odata.ClickAction;
8186  uint localID = odata.ObjectLocalID;
8187  handlerObjectClickAction(this, localID, action.ToString());
8188  }
8189  }
8190  return true;
8191  }
8192 
8193  private bool HandleObjectMaterial(IClientAPI sender, Packet Pack)
8194  {
8195  ObjectMaterialPacket ompacket = (ObjectMaterialPacket)Pack;
8196 
8197  #region Packet Session and User Check
8198  if (m_checkPackets)
8199  {
8200  if (ompacket.AgentData.SessionID != SessionId ||
8201  ompacket.AgentData.AgentID != AgentId)
8202  return true;
8203  }
8204  #endregion
8205 
8206  GenericCall7 handlerObjectMaterial = OnObjectMaterial;
8207  if (handlerObjectMaterial != null)
8208  {
8209  foreach (ObjectMaterialPacket.ObjectDataBlock odata in ompacket.ObjectData)
8210  {
8211  byte material = odata.Material;
8212  uint localID = odata.ObjectLocalID;
8213  handlerObjectMaterial(this, localID, material.ToString());
8214  }
8215  }
8216  return true;
8217  }
8218 
8219  #endregion Objects/m_sceneObjects
8220 
8221  #region Inventory/Asset/Other related packets
8222 
8223  private bool HandleRequestImage(IClientAPI sender, Packet Pack)
8224  {
8225  RequestImagePacket imageRequest = (RequestImagePacket)Pack;
8226  //m_log.Debug("image request: " + Pack.ToString());
8227 
8228  #region Packet Session and User Check
8229  if (m_checkPackets)
8230  {
8231  if (imageRequest.AgentData.SessionID != SessionId ||
8232  imageRequest.AgentData.AgentID != AgentId)
8233  return true;
8234  }
8235  #endregion
8236 
8237  //handlerTextureRequest = null;
8238  for (int i = 0; i < imageRequest.RequestImage.Length; i++)
8239  {
8241 
8242  RequestImagePacket.RequestImageBlock block = imageRequest.RequestImage[i];
8243 
8244  args.RequestedAssetID = block.Image;
8245  args.DiscardLevel = block.DiscardLevel;
8246  args.PacketNumber = block.Packet;
8247  args.Priority = block.DownloadPriority;
8248  args.requestSequence = imageRequest.Header.Sequence;
8249 
8250  // NOTE: This is not a built in part of the LLUDP protocol, but we double the
8251  // priority of avatar textures to get avatars rezzing in faster than the
8252  // surrounding scene
8253  if ((ImageType)block.Type == ImageType.Baked)
8254  args.Priority *= 2.0f;
8255  int wearableout = 0;
8256 
8257  ImageManager.EnqueueReq(args);
8258  }
8259 
8260  return true;
8261  }
8262 
8270  private bool HandleTransferRequest(IClientAPI sender, Packet Pack)
8271  {
8272  //m_log.Debug("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
8273 
8274  TransferRequestPacket transfer = (TransferRequestPacket)Pack;
8275  UUID taskID = UUID.Zero;
8276  if (transfer.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
8277  {
8278  if (!(((Scene)m_scene).Permissions.BypassPermissions()))
8279  {
8280  // We're spawning a thread because the permissions check can block this thread
8281  Util.FireAndForget(delegate
8282  {
8283  // This requests the asset if needed
8284  HandleSimInventoryTransferRequestWithPermsCheck(sender, transfer);
8285  }, null, "LLClientView.HandleTransferRequest");
8286 
8287  return true;
8288  }
8289  }
8290  else if (transfer.TransferInfo.SourceType == (int)SourceType.SimEstate)
8291  {
8292  //TransferRequestPacket does not include covenant uuid?
8293  //get scene covenant uuid
8294  taskID = m_scene.RegionInfo.RegionSettings.Covenant;
8295  }
8296 
8297  // This is non-blocking
8298  MakeAssetRequest(transfer, taskID);
8299 
8300  return true;
8301  }
8302 
8303  private void HandleSimInventoryTransferRequestWithPermsCheck(IClientAPI sender, TransferRequestPacket transfer)
8304  {
8305  UUID taskID = new UUID(transfer.TransferInfo.Params, 48);
8306  UUID itemID = new UUID(transfer.TransferInfo.Params, 64);
8307  UUID requestID = new UUID(transfer.TransferInfo.Params, 80);
8308 
8309  //m_log.DebugFormat(
8310  // "[CLIENT]: Got request for asset {0} from item {1} in prim {2} by {3}",
8311  // requestID, itemID, taskID, Name);
8312 
8313  //m_log.Debug("Transfer Request: " + transfer.ToString());
8314  // Validate inventory transfers
8315  // Has to be done here, because AssetCache can't do it
8316  //
8317  if (taskID != UUID.Zero) // Prim
8318  {
8319  SceneObjectPart part = ((Scene)m_scene).GetSceneObjectPart(taskID);
8320 
8321  if (part == null)
8322  {
8323  m_log.WarnFormat(
8324  "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but prim does not exist",
8325  Name, requestID, itemID, taskID);
8326  return;
8327  }
8328 
8329  TaskInventoryItem tii = part.Inventory.GetInventoryItem(itemID);
8330  if (tii == null)
8331  {
8332  m_log.WarnFormat(
8333  "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item does not exist",
8334  Name, requestID, itemID, taskID);
8335  return;
8336  }
8337 
8338  if (tii.Type == (int)AssetType.LSLText)
8339  {
8340  if (!((Scene)m_scene).Permissions.CanEditScript(itemID, taskID, AgentId))
8341  return;
8342  }
8343  else if (tii.Type == (int)AssetType.Notecard)
8344  {
8345  if (!((Scene)m_scene).Permissions.CanEditNotecard(itemID, taskID, AgentId))
8346  return;
8347  }
8348  else
8349  {
8350  // TODO: Change this code to allow items other than notecards and scripts to be successfully
8351  // shared with group. In fact, this whole block of permissions checking should move to an IPermissionsModule
8352  if (part.OwnerID != AgentId)
8353  {
8354  m_log.WarnFormat(
8355  "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the prim is owned by {4}",
8356  Name, requestID, itemID, taskID, part.OwnerID);
8357  return;
8358  }
8359 
8360  if ((part.OwnerMask & (uint)PermissionMask.Modify) == 0)
8361  {
8362  m_log.WarnFormat(
8363  "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but modify permissions are not set",
8364  Name, requestID, itemID, taskID);
8365  return;
8366  }
8367 
8368  if (tii.OwnerID != AgentId)
8369  {
8370  m_log.WarnFormat(
8371  "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but the item is owned by {4}",
8372  Name, requestID, itemID, taskID, tii.OwnerID);
8373  return;
8374  }
8375 
8376  if ((
8377  tii.CurrentPermissions & ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
8378  != ((uint)PermissionMask.Modify | (uint)PermissionMask.Copy | (uint)PermissionMask.Transfer))
8379  {
8380  m_log.WarnFormat(
8381  "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but item permissions are not modify/copy/transfer",
8382  Name, requestID, itemID, taskID);
8383  return;
8384  }
8385 
8386  if (tii.AssetID != requestID)
8387  {
8388  m_log.WarnFormat(
8389  "[CLIENT]: {0} requested asset {1} from item {2} in prim {3} but this does not match item's asset {4}",
8390  Name, requestID, itemID, taskID, tii.AssetID);
8391  return;
8392  }
8393  }
8394  }
8395  else // Agent
8396  {
8397  IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
8398  if (invAccess != null)
8399  {
8400  if (!invAccess.CanGetAgentInventoryItem(this, itemID, requestID))
8401  return;
8402  }
8403  else
8404  {
8405  return;
8406  }
8407  }
8408 
8409  // Permissions out of the way, let's request the asset
8410  MakeAssetRequest(transfer, taskID);
8411 
8412  }
8413 
8414 
8415  private bool HandleAssetUploadRequest(IClientAPI sender, Packet Pack)
8416  {
8417  AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
8418 
8419  // m_log.Debug("upload request " + request.ToString());
8420  // m_log.Debug("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
8421  UUID temp = UUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
8422 
8423  UDPAssetUploadRequest handlerAssetUploadRequest = OnAssetUploadRequest;
8424 
8425  if (handlerAssetUploadRequest != null)
8426  {
8427  handlerAssetUploadRequest(this, temp,
8428  request.AssetBlock.TransactionID, request.AssetBlock.Type,
8429  request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
8430  request.AssetBlock.Tempfile);
8431  }
8432  return true;
8433  }
8434 
8435  private bool HandleRequestXfer(IClientAPI sender, Packet Pack)
8436  {
8437  RequestXferPacket xferReq = (RequestXferPacket)Pack;
8438 
8439  RequestXfer handlerRequestXfer = OnRequestXfer;
8440 
8441  if (handlerRequestXfer != null)
8442  {
8443  handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
8444  }
8445  return true;
8446  }
8447 
8448  private bool HandleSendXferPacket(IClientAPI sender, Packet Pack)
8449  {
8450  SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
8451 
8452  XferReceive handlerXferReceive = OnXferReceive;
8453  if (handlerXferReceive != null)
8454  {
8455  handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
8456  }
8457  return true;
8458  }
8459 
8460  private bool HandleConfirmXferPacket(IClientAPI sender, Packet Pack)
8461  {
8462  ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
8463 
8464  ConfirmXfer handlerConfirmXfer = OnConfirmXfer;
8465  if (handlerConfirmXfer != null)
8466  {
8467  handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
8468  }
8469  return true;
8470  }
8471 
8472  private bool HandleAbortXfer(IClientAPI sender, Packet Pack)
8473  {
8474  AbortXferPacket abortXfer = (AbortXferPacket)Pack;
8475  AbortXfer handlerAbortXfer = OnAbortXfer;
8476  if (handlerAbortXfer != null)
8477  {
8478  handlerAbortXfer(this, abortXfer.XferID.ID);
8479  }
8480 
8481  return true;
8482  }
8483 
8484  private bool HandleCreateInventoryFolder(IClientAPI sender, Packet Pack)
8485  {
8486  CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
8487 
8488  #region Packet Session and User Check
8489  if (m_checkPackets)
8490  {
8491  if (invFolder.AgentData.SessionID != SessionId ||
8492  invFolder.AgentData.AgentID != AgentId)
8493  return true;
8494  }
8495  #endregion
8496 
8497  CreateInventoryFolder handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
8498  if (handlerCreateInventoryFolder != null)
8499  {
8500  handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
8501  (ushort)invFolder.FolderData.Type,
8502  Util.FieldToString(invFolder.FolderData.Name),
8503  invFolder.FolderData.ParentID);
8504  }
8505  return true;
8506  }
8507 
8508  private bool HandleUpdateInventoryFolder(IClientAPI sender, Packet Pack)
8509  {
8510  if (OnUpdateInventoryFolder != null)
8511  {
8512  UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
8513 
8514  #region Packet Session and User Check
8515  if (m_checkPackets)
8516  {
8517  if (invFolderx.AgentData.SessionID != SessionId ||
8518  invFolderx.AgentData.AgentID != AgentId)
8519  return true;
8520  }
8521  #endregion
8522 
8523  UpdateInventoryFolder handlerUpdateInventoryFolder = null;
8524 
8525  for (int i = 0; i < invFolderx.FolderData.Length; i++)
8526  {
8527  handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
8528  if (handlerUpdateInventoryFolder != null)
8529  {
8530  OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
8531  (ushort)invFolderx.FolderData[i].Type,
8532  Util.FieldToString(invFolderx.FolderData[i].Name),
8533  invFolderx.FolderData[i].ParentID);
8534  }
8535  }
8536  }
8537  return true;
8538  }
8539 
8540  private bool HandleMoveInventoryFolder(IClientAPI sender, Packet Pack)
8541  {
8542  if (OnMoveInventoryFolder != null)
8543  {
8544  MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
8545 
8546  #region Packet Session and User Check
8547  if (m_checkPackets)
8548  {
8549  if (invFoldery.AgentData.SessionID != SessionId ||
8550  invFoldery.AgentData.AgentID != AgentId)
8551  return true;
8552  }
8553  #endregion
8554 
8555  MoveInventoryFolder handlerMoveInventoryFolder = null;
8556 
8557  for (int i = 0; i < invFoldery.InventoryData.Length; i++)
8558  {
8559  handlerMoveInventoryFolder = OnMoveInventoryFolder;
8560  if (handlerMoveInventoryFolder != null)
8561  {
8562  OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
8563  invFoldery.InventoryData[i].ParentID);
8564  }
8565  }
8566  }
8567  return true;
8568  }
8569 
8570  private bool HandleCreateInventoryItem(IClientAPI sender, Packet Pack)
8571  {
8572  CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
8573 
8574  #region Packet Session and User Check
8575  if (m_checkPackets)
8576  {
8577  if (createItem.AgentData.SessionID != SessionId ||
8578  createItem.AgentData.AgentID != AgentId)
8579  return true;
8580  }
8581  #endregion
8582 
8583  CreateNewInventoryItem handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
8584  if (handlerCreateNewInventoryItem != null)
8585  {
8586  handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
8587  createItem.InventoryBlock.FolderID,
8588  createItem.InventoryBlock.CallbackID,
8589  Util.FieldToString(createItem.InventoryBlock.Description),
8590  Util.FieldToString(createItem.InventoryBlock.Name),
8591  createItem.InventoryBlock.InvType,
8592  createItem.InventoryBlock.Type,
8593  createItem.InventoryBlock.WearableType,
8594  createItem.InventoryBlock.NextOwnerMask,
8595  Util.UnixTimeSinceEpoch());
8596  }
8597  return true;
8598  }
8599 
8600  private bool HandleLinkInventoryItem(IClientAPI sender, Packet Pack)
8601  {
8602  LinkInventoryItemPacket createLink = (LinkInventoryItemPacket)Pack;
8603 
8604  #region Packet Session and User Check
8605  if (m_checkPackets)
8606  {
8607  if (createLink.AgentData.SessionID != SessionId ||
8608  createLink.AgentData.AgentID != AgentId)
8609  return true;
8610  }
8611  #endregion
8612 
8613  LinkInventoryItem linkInventoryItem = OnLinkInventoryItem;
8614 
8615  if (linkInventoryItem != null)
8616  {
8617  linkInventoryItem(
8618  this,
8619  createLink.InventoryBlock.TransactionID,
8620  createLink.InventoryBlock.FolderID,
8621  createLink.InventoryBlock.CallbackID,
8622  Util.FieldToString(createLink.InventoryBlock.Description),
8623  Util.FieldToString(createLink.InventoryBlock.Name),
8624  createLink.InventoryBlock.InvType,
8625  createLink.InventoryBlock.Type,
8626  createLink.InventoryBlock.OldItemID);
8627  }
8628 
8629  return true;
8630  }
8631 
8632  private bool HandleFetchInventory(IClientAPI sender, Packet Pack)
8633  {
8634  if (OnFetchInventory != null)
8635  {
8636  FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
8637 
8638  #region Packet Session and User Check
8639  if (m_checkPackets)
8640  {
8641  if (FetchInventoryx.AgentData.SessionID != SessionId ||
8642  FetchInventoryx.AgentData.AgentID != AgentId)
8643  return true;
8644  }
8645  #endregion
8646 
8647  FetchInventory handlerFetchInventory = null;
8648 
8649  for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
8650  {
8651  handlerFetchInventory = OnFetchInventory;
8652 
8653  if (handlerFetchInventory != null)
8654  {
8655  OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
8656  FetchInventoryx.InventoryData[i].OwnerID);
8657  }
8658  }
8659  }
8660  return true;
8661  }
8662 
8663  private bool HandleFetchInventoryDescendents(IClientAPI sender, Packet Pack)
8664  {
8665  FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
8666 
8667  #region Packet Session and User Check
8668  if (m_checkPackets)
8669  {
8670  if (Fetch.AgentData.SessionID != SessionId ||
8671  Fetch.AgentData.AgentID != AgentId)
8672  return true;
8673  }
8674  #endregion
8675 
8676  FetchInventoryDescendents handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
8677  if (handlerFetchInventoryDescendents != null)
8678  {
8679  handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
8680  Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
8681  Fetch.InventoryData.SortOrder);
8682  }
8683  return true;
8684  }
8685 
8686  private bool HandlePurgeInventoryDescendents(IClientAPI sender, Packet Pack)
8687  {
8688  PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
8689 
8690  #region Packet Session and User Check
8691  if (m_checkPackets)
8692  {
8693  if (Purge.AgentData.SessionID != SessionId ||
8694  Purge.AgentData.AgentID != AgentId)
8695  return true;
8696  }
8697  #endregion
8698 
8699  PurgeInventoryDescendents handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
8700  if (handlerPurgeInventoryDescendents != null)
8701  {
8702  handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
8703  }
8704  return true;
8705  }
8706 
8707  private bool HandleUpdateInventoryItem(IClientAPI sender, Packet Pack)
8708  {
8709  UpdateInventoryItemPacket inventoryItemUpdate = (UpdateInventoryItemPacket)Pack;
8710 
8711  #region Packet Session and User Check
8712  if (m_checkPackets)
8713  {
8714  if (inventoryItemUpdate.AgentData.SessionID != SessionId ||
8715  inventoryItemUpdate.AgentData.AgentID != AgentId)
8716  return true;
8717  }
8718  #endregion
8719 
8720  if (OnUpdateInventoryItem != null)
8721  {
8722  UpdateInventoryItem handlerUpdateInventoryItem = null;
8723  for (int i = 0; i < inventoryItemUpdate.InventoryData.Length; i++)
8724  {
8725  handlerUpdateInventoryItem = OnUpdateInventoryItem;
8726 
8727  if (handlerUpdateInventoryItem != null)
8728  {
8729  InventoryItemBase itemUpd = new InventoryItemBase();
8730  itemUpd.ID = inventoryItemUpdate.InventoryData[i].ItemID;
8731  itemUpd.Name = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Name);
8732  itemUpd.Description = Util.FieldToString(inventoryItemUpdate.InventoryData[i].Description);
8733  itemUpd.GroupID = inventoryItemUpdate.InventoryData[i].GroupID;
8734  itemUpd.GroupOwned = inventoryItemUpdate.InventoryData[i].GroupOwned;
8735  itemUpd.GroupPermissions = inventoryItemUpdate.InventoryData[i].GroupMask;
8736  itemUpd.NextPermissions = inventoryItemUpdate.InventoryData[i].NextOwnerMask;
8737  itemUpd.EveryOnePermissions = inventoryItemUpdate.InventoryData[i].EveryoneMask;
8738  itemUpd.CreationDate = inventoryItemUpdate.InventoryData[i].CreationDate;
8739  itemUpd.Folder = inventoryItemUpdate.InventoryData[i].FolderID;
8740  itemUpd.InvType = inventoryItemUpdate.InventoryData[i].InvType;
8741  itemUpd.SalePrice = inventoryItemUpdate.InventoryData[i].SalePrice;
8742  itemUpd.SaleType = inventoryItemUpdate.InventoryData[i].SaleType;
8743  itemUpd.Flags = inventoryItemUpdate.InventoryData[i].Flags;
8744 
8745  OnUpdateInventoryItem(this, inventoryItemUpdate.InventoryData[i].TransactionID,
8746  inventoryItemUpdate.InventoryData[i].ItemID,
8747  itemUpd);
8748  }
8749  }
8750  }
8751  return true;
8752  }
8753 
8754  private bool HandleCopyInventoryItem(IClientAPI sender, Packet Pack)
8755  {
8756  CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
8757 
8758  #region Packet Session and User Check
8759  if (m_checkPackets)
8760  {
8761  if (copyitem.AgentData.SessionID != SessionId ||
8762  copyitem.AgentData.AgentID != AgentId)
8763  return true;
8764  }
8765  #endregion
8766 
8767  CopyInventoryItem handlerCopyInventoryItem = null;
8768  if (OnCopyInventoryItem != null)
8769  {
8770  foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
8771  {
8772  handlerCopyInventoryItem = OnCopyInventoryItem;
8773  if (handlerCopyInventoryItem != null)
8774  {
8775  handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
8776  datablock.OldItemID, datablock.NewFolderID,
8777  Util.FieldToString(datablock.NewName));
8778  }
8779  }
8780  }
8781  return true;
8782  }
8783 
8784  private bool HandleMoveInventoryItem(IClientAPI sender, Packet Pack)
8785  {
8786  MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
8787 
8788  #region Packet Session and User Check
8789  if (m_checkPackets)
8790  {
8791  if (moveitem.AgentData.SessionID != SessionId ||
8792  moveitem.AgentData.AgentID != AgentId)
8793  return true;
8794  }
8795  #endregion
8796 
8797  if (OnMoveInventoryItem != null)
8798  {
8799  MoveInventoryItem handlerMoveInventoryItem = null;
8800  InventoryItemBase itm = null;
8801  List<InventoryItemBase> items = new List<InventoryItemBase>();
8802  foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
8803  {
8804  itm = new InventoryItemBase(datablock.ItemID, AgentId);
8805  itm.Folder = datablock.FolderID;
8806  itm.Name = Util.FieldToString(datablock.NewName);
8807  // weird, comes out as empty string
8808  //m_log.DebugFormat("[XXX] new name: {0}", itm.Name);
8809  items.Add(itm);
8810  }
8811  handlerMoveInventoryItem = OnMoveInventoryItem;
8812  if (handlerMoveInventoryItem != null)
8813  {
8814  handlerMoveInventoryItem(this, items);
8815  }
8816  }
8817  return true;
8818  }
8819 
8820  private bool HandleRemoveInventoryItem(IClientAPI sender, Packet Pack)
8821  {
8822  RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
8823 
8824  #region Packet Session and User Check
8825  if (m_checkPackets)
8826  {
8827  if (removeItem.AgentData.SessionID != SessionId ||
8828  removeItem.AgentData.AgentID != AgentId)
8829  return true;
8830  }
8831  #endregion
8832 
8833  if (OnRemoveInventoryItem != null)
8834  {
8835  RemoveInventoryItem handlerRemoveInventoryItem = null;
8836  List<UUID> uuids = new List<UUID>();
8837  foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
8838  {
8839  uuids.Add(datablock.ItemID);
8840  }
8841  handlerRemoveInventoryItem = OnRemoveInventoryItem;
8842  if (handlerRemoveInventoryItem != null)
8843  {
8844  handlerRemoveInventoryItem(this, uuids);
8845  }
8846 
8847  }
8848  return true;
8849  }
8850 
8851  private bool HandleRemoveInventoryFolder(IClientAPI sender, Packet Pack)
8852  {
8853  RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
8854 
8855  #region Packet Session and User Check
8856  if (m_checkPackets)
8857  {
8858  if (removeFolder.AgentData.SessionID != SessionId ||
8859  removeFolder.AgentData.AgentID != AgentId)
8860  return true;
8861  }
8862  #endregion
8863 
8864  if (OnRemoveInventoryFolder != null)
8865  {
8866  RemoveInventoryFolder handlerRemoveInventoryFolder = null;
8867  List<UUID> uuids = new List<UUID>();
8868  foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
8869  {
8870  uuids.Add(datablock.FolderID);
8871  }
8872  handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
8873  if (handlerRemoveInventoryFolder != null)
8874  {
8875  handlerRemoveInventoryFolder(this, uuids);
8876  }
8877  }
8878  return true;
8879  }
8880 
8881  private bool HandleRemoveInventoryObjects(IClientAPI sender, Packet Pack)
8882  {
8883  RemoveInventoryObjectsPacket removeObject = (RemoveInventoryObjectsPacket)Pack;
8884  #region Packet Session and User Check
8885  if (m_checkPackets)
8886  {
8887  if (removeObject.AgentData.SessionID != SessionId ||
8888  removeObject.AgentData.AgentID != AgentId)
8889  return true;
8890  }
8891  #endregion
8892  if (OnRemoveInventoryFolder != null)
8893  {
8894  RemoveInventoryFolder handlerRemoveInventoryFolder = null;
8895  List<UUID> uuids = new List<UUID>();
8896  foreach (RemoveInventoryObjectsPacket.FolderDataBlock datablock in removeObject.FolderData)
8897  {
8898  uuids.Add(datablock.FolderID);
8899  }
8900  handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
8901  if (handlerRemoveInventoryFolder != null)
8902  {
8903  handlerRemoveInventoryFolder(this, uuids);
8904  }
8905  }
8906 
8907  if (OnRemoveInventoryItem != null)
8908  {
8909  RemoveInventoryItem handlerRemoveInventoryItem = null;
8910  List<UUID> uuids = new List<UUID>();
8911  foreach (RemoveInventoryObjectsPacket.ItemDataBlock datablock in removeObject.ItemData)
8912  {
8913  uuids.Add(datablock.ItemID);
8914  }
8915  handlerRemoveInventoryItem = OnRemoveInventoryItem;
8916  if (handlerRemoveInventoryItem != null)
8917  {
8918  handlerRemoveInventoryItem(this, uuids);
8919  }
8920  }
8921  return true;
8922  }
8923 
8924  private bool HandleRequestTaskInventory(IClientAPI sender, Packet Pack)
8925  {
8926  RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
8927 
8928  #region Packet Session and User Check
8929  if (m_checkPackets)
8930  {
8931  if (requesttask.AgentData.SessionID != SessionId ||
8932  requesttask.AgentData.AgentID != AgentId)
8933  return true;
8934  }
8935  #endregion
8936 
8937  RequestTaskInventory handlerRequestTaskInventory = OnRequestTaskInventory;
8938  if (handlerRequestTaskInventory != null)
8939  {
8940  handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
8941  }
8942  return true;
8943  }
8944 
8945  private bool HandleUpdateTaskInventory(IClientAPI sender, Packet Pack)
8946  {
8947  UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
8948 
8949  #region Packet Session and User Check
8950  if (m_checkPackets)
8951  {
8952  if (updatetask.AgentData.SessionID != SessionId ||
8953  updatetask.AgentData.AgentID != AgentId)
8954  return true;
8955  }
8956  #endregion
8957 
8958  if (OnUpdateTaskInventory != null)
8959  {
8960  if (updatetask.UpdateData.Key == 0)
8961  {
8962  UpdateTaskInventory handlerUpdateTaskInventory = OnUpdateTaskInventory;
8963  if (handlerUpdateTaskInventory != null)
8964  {
8965  TaskInventoryItem newTaskItem = new TaskInventoryItem();
8966  newTaskItem.ItemID = updatetask.InventoryData.ItemID;
8967  newTaskItem.ParentID = updatetask.InventoryData.FolderID;
8968  newTaskItem.CreatorID = updatetask.InventoryData.CreatorID;
8969  newTaskItem.OwnerID = updatetask.InventoryData.OwnerID;
8970  newTaskItem.GroupID = updatetask.InventoryData.GroupID;
8971  newTaskItem.BasePermissions = updatetask.InventoryData.BaseMask;
8972  newTaskItem.CurrentPermissions = updatetask.InventoryData.OwnerMask;
8973  newTaskItem.GroupPermissions = updatetask.InventoryData.GroupMask;
8974  newTaskItem.EveryonePermissions = updatetask.InventoryData.EveryoneMask;
8975  newTaskItem.NextPermissions = updatetask.InventoryData.NextOwnerMask;
8976 
8977  // Unused? Clicking share with group sets GroupPermissions instead, so perhaps this is something
8978  // different
8979  //newTaskItem.GroupOwned=updatetask.InventoryData.GroupOwned;
8980  newTaskItem.Type = updatetask.InventoryData.Type;
8981  newTaskItem.InvType = updatetask.InventoryData.InvType;
8982  newTaskItem.Flags = updatetask.InventoryData.Flags;
8983  //newTaskItem.SaleType=updatetask.InventoryData.SaleType;
8984  //newTaskItem.SalePrice=updatetask.InventoryData.SalePrice;
8985  newTaskItem.Name = Util.FieldToString(updatetask.InventoryData.Name);
8986  newTaskItem.Description = Util.FieldToString(updatetask.InventoryData.Description);
8987  newTaskItem.CreationDate = (uint)updatetask.InventoryData.CreationDate;
8988  handlerUpdateTaskInventory(this, updatetask.InventoryData.TransactionID,
8989  newTaskItem, updatetask.UpdateData.LocalID);
8990  }
8991  }
8992  }
8993 
8994  return true;
8995  }
8996 
8997  private bool HandleRemoveTaskInventory(IClientAPI sender, Packet Pack)
8998  {
8999  RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
9000 
9001  #region Packet Session and User Check
9002  if (m_checkPackets)
9003  {
9004  if (removeTask.AgentData.SessionID != SessionId ||
9005  removeTask.AgentData.AgentID != AgentId)
9006  return true;
9007  }
9008  #endregion
9009 
9010  RemoveTaskInventory handlerRemoveTaskItem = OnRemoveTaskItem;
9011 
9012  if (handlerRemoveTaskItem != null)
9013  {
9014  handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
9015  }
9016 
9017  return true;
9018  }
9019 
9020  private bool HandleMoveTaskInventory(IClientAPI sender, Packet Pack)
9021  {
9022  MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
9023 
9024  #region Packet Session and User Check
9025  if (m_checkPackets)
9026  {
9027  if (moveTaskInventoryPacket.AgentData.SessionID != SessionId ||
9028  moveTaskInventoryPacket.AgentData.AgentID != AgentId)
9029  return true;
9030  }
9031  #endregion
9032 
9033  MoveTaskInventory handlerMoveTaskItem = OnMoveTaskItem;
9034 
9035  if (handlerMoveTaskItem != null)
9036  {
9037  handlerMoveTaskItem(
9038  this, moveTaskInventoryPacket.AgentData.FolderID,
9039  moveTaskInventoryPacket.InventoryData.LocalID,
9040  moveTaskInventoryPacket.InventoryData.ItemID);
9041  }
9042 
9043  return true;
9044  }
9045 
9046  private bool HandleRezScript(IClientAPI sender, Packet Pack)
9047  {
9048  //m_log.Debug(Pack.ToString());
9049  RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
9050 
9051  #region Packet Session and User Check
9052  if (m_checkPackets)
9053  {
9054  if (rezScriptx.AgentData.SessionID != SessionId ||
9055  rezScriptx.AgentData.AgentID != AgentId)
9056  return true;
9057  }
9058  #endregion
9059 
9060  RezScript handlerRezScript = OnRezScript;
9061  InventoryItemBase item = new InventoryItemBase();
9062  item.ID = rezScriptx.InventoryBlock.ItemID;
9063  item.Folder = rezScriptx.InventoryBlock.FolderID;
9064  item.CreatorId = rezScriptx.InventoryBlock.CreatorID.ToString();
9065  item.Owner = rezScriptx.InventoryBlock.OwnerID;
9066  item.BasePermissions = rezScriptx.InventoryBlock.BaseMask;
9067  item.CurrentPermissions = rezScriptx.InventoryBlock.OwnerMask;
9068  item.EveryOnePermissions = rezScriptx.InventoryBlock.EveryoneMask;
9069  item.NextPermissions = rezScriptx.InventoryBlock.NextOwnerMask;
9070  item.GroupPermissions = rezScriptx.InventoryBlock.GroupMask;
9071  item.GroupOwned = rezScriptx.InventoryBlock.GroupOwned;
9072  item.GroupID = rezScriptx.InventoryBlock.GroupID;
9073  item.AssetType = rezScriptx.InventoryBlock.Type;
9074  item.InvType = rezScriptx.InventoryBlock.InvType;
9075  item.Flags = rezScriptx.InventoryBlock.Flags;
9076  item.SaleType = rezScriptx.InventoryBlock.SaleType;
9077  item.SalePrice = rezScriptx.InventoryBlock.SalePrice;
9078  item.Name = Util.FieldToString(rezScriptx.InventoryBlock.Name);
9079  item.Description = Util.FieldToString(rezScriptx.InventoryBlock.Description);
9080  item.CreationDate = rezScriptx.InventoryBlock.CreationDate;
9081 
9082  if (handlerRezScript != null)
9083  {
9084  handlerRezScript(this, item, rezScriptx.InventoryBlock.TransactionID, rezScriptx.UpdateBlock.ObjectLocalID);
9085  }
9086  return true;
9087  }
9088 
9089  private bool HandleMapLayerRequest(IClientAPI sender, Packet Pack)
9090  {
9091  RequestMapLayer();
9092  return true;
9093  }
9094 
9095  private bool HandleMapBlockRequest(IClientAPI sender, Packet Pack)
9096  {
9097  MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
9098 
9099  #region Packet Session and User Check
9100  if (m_checkPackets)
9101  {
9102  if (MapRequest.AgentData.SessionID != SessionId ||
9103  MapRequest.AgentData.AgentID != AgentId)
9104  return true;
9105  }
9106  #endregion
9107 
9108  RequestMapBlocks handlerRequestMapBlocks = OnRequestMapBlocks;
9109  if (handlerRequestMapBlocks != null)
9110  {
9111  handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
9112  MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY, MapRequest.AgentData.Flags);
9113  }
9114  return true;
9115  }
9116 
9117  private bool HandleMapNameRequest(IClientAPI sender, Packet Pack)
9118  {
9119  MapNameRequestPacket map = (MapNameRequestPacket)Pack;
9120 
9121  #region Packet Session and User Check
9122  if (m_checkPackets)
9123  {
9124  if (map.AgentData.SessionID != SessionId ||
9125  map.AgentData.AgentID != AgentId)
9126  return true;
9127  }
9128  #endregion
9129  string mapName = (map.NameData.Name.Length == 0) ? m_scene.RegionInfo.RegionName :
9130  Util.UTF8.GetString(map.NameData.Name, 0, map.NameData.Name.Length - 1);
9131  RequestMapName handlerMapNameRequest = OnMapNameRequest;
9132  if (handlerMapNameRequest != null)
9133  {
9134  handlerMapNameRequest(this, mapName, map.AgentData.Flags);
9135  }
9136  return true;
9137  }
9138 
9139  private bool HandleTeleportLandmarkRequest(IClientAPI sender, Packet Pack)
9140  {
9141  TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
9142 
9143  #region Packet Session and User Check
9144  if (m_checkPackets)
9145  {
9146  if (tpReq.Info.SessionID != SessionId ||
9147  tpReq.Info.AgentID != AgentId)
9148  return true;
9149  }
9150  #endregion
9151 
9152  UUID lmid = tpReq.Info.LandmarkID;
9153  AssetLandmark lm;
9154  if (lmid != UUID.Zero)
9155  {
9156 
9157  //AssetBase lma = m_assetCache.GetAsset(lmid, false);
9158  AssetBase lma = m_assetService.Get(lmid.ToString());
9159 
9160  if (lma == null)
9161  {
9162  // Failed to find landmark
9163 
9164  // Let's try to search in the user's home asset server
9165  lma = FindAssetInUserAssetServer(lmid.ToString());
9166 
9167  if (lma == null)
9168  {
9169  // Really doesn't exist
9170  TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
9171  tpCancel.Info.SessionID = tpReq.Info.SessionID;
9172  tpCancel.Info.AgentID = tpReq.Info.AgentID;
9173  OutPacket(tpCancel, ThrottleOutPacketType.Task);
9174  }
9175  }
9176 
9177  try
9178  {
9179  lm = new AssetLandmark(lma);
9180  }
9181  catch (NullReferenceException)
9182  {
9183  // asset not found generates null ref inside the assetlandmark constructor.
9184  TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
9185  tpCancel.Info.SessionID = tpReq.Info.SessionID;
9186  tpCancel.Info.AgentID = tpReq.Info.AgentID;
9187  OutPacket(tpCancel, ThrottleOutPacketType.Task);
9188  return true;
9189  }
9190  }
9191  else
9192  {
9193  // Teleport home request
9194  UUIDNameRequest handlerTeleportHomeRequest = OnTeleportHomeRequest;
9195  if (handlerTeleportHomeRequest != null)
9196  {
9197  handlerTeleportHomeRequest(AgentId, this);
9198  }
9199  return true;
9200  }
9201 
9202  TeleportLandmarkRequest handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
9203  if (handlerTeleportLandmarkRequest != null)
9204  {
9205  handlerTeleportLandmarkRequest(this, lm);
9206  }
9207  else
9208  {
9209  //no event handler so cancel request
9210  TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
9211  tpCancel.Info.AgentID = tpReq.Info.AgentID;
9212  tpCancel.Info.SessionID = tpReq.Info.SessionID;
9213  OutPacket(tpCancel, ThrottleOutPacketType.Task);
9214 
9215  }
9216  return true;
9217  }
9218 
9219  private bool HandleTeleportCancel(IClientAPI sender, Packet Pack)
9220  {
9221  TeleportCancel handlerTeleportCancel = OnTeleportCancel;
9222  if (handlerTeleportCancel != null)
9223  {
9224  handlerTeleportCancel(this);
9225  }
9226  return true;
9227  }
9228 
9229  private AssetBase FindAssetInUserAssetServer(string id)
9230  {
9231  AgentCircuitData aCircuit = ((Scene)Scene).AuthenticateHandler.GetAgentCircuitData(CircuitCode);
9232  if (aCircuit != null && aCircuit.ServiceURLs != null && aCircuit.ServiceURLs.ContainsKey("AssetServerURI"))
9233  {
9234  string assetServer = aCircuit.ServiceURLs["AssetServerURI"].ToString();
9235  if (!string.IsNullOrEmpty(assetServer))
9236  return ((Scene)Scene).AssetService.Get(assetServer + "/" + id);
9237  }
9238 
9239  return null;
9240  }
9241 
9242  private bool HandleTeleportLocationRequest(IClientAPI sender, Packet Pack)
9243  {
9244  TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
9245  // m_log.Debug(tpLocReq.ToString());
9246 
9247  #region Packet Session and User Check
9248  if (m_checkPackets)
9249  {
9250  if (tpLocReq.AgentData.SessionID != SessionId ||
9251  tpLocReq.AgentData.AgentID != AgentId)
9252  return true;
9253  }
9254  #endregion
9255 
9256  TeleportLocationRequest handlerTeleportLocationRequest = OnTeleportLocationRequest;
9257  if (handlerTeleportLocationRequest != null)
9258  {
9259  // Adjust teleport location to base of a larger region if requested to teleport to a sub-region
9260  uint locX, locY;
9261  Util.RegionHandleToWorldLoc(tpLocReq.Info.RegionHandle, out locX, out locY);
9262  if ((locX >= m_scene.RegionInfo.WorldLocX)
9263  && (locX < (m_scene.RegionInfo.WorldLocX + m_scene.RegionInfo.RegionSizeX))
9264  && (locY >= m_scene.RegionInfo.WorldLocY)
9265  && (locY < (m_scene.RegionInfo.WorldLocY + m_scene.RegionInfo.RegionSizeY)))
9266  {
9267  tpLocReq.Info.RegionHandle = m_scene.RegionInfo.RegionHandle;
9268  tpLocReq.Info.Position.X += locX - m_scene.RegionInfo.WorldLocX;
9269  tpLocReq.Info.Position.Y += locY - m_scene.RegionInfo.WorldLocY;
9270  }
9271 
9272  handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
9273  tpLocReq.Info.LookAt, 16);
9274  }
9275  else
9276  {
9277  //no event handler so cancel request
9278  TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
9279  tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
9280  tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
9281  OutPacket(tpCancel, ThrottleOutPacketType.Task);
9282  }
9283  return true;
9284  }
9285 
9286  #endregion Inventory/Asset/Other related packets
9287 
9288  private bool HandleUUIDNameRequest(IClientAPI sender, Packet Pack)
9289  {
9290  UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
9291 
9292  foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
9293  {
9294  UUIDNameRequest handlerNameRequest = OnNameFromUUIDRequest;
9295  if (handlerNameRequest != null)
9296  {
9297  handlerNameRequest(UUIDBlock.ID, this);
9298  }
9299  }
9300  return true;
9301  }
9302 
9303  #region Parcel related packets
9304 
9305  // acumulate several HandleRegionHandleRequest consecutive overlaping requests
9306  // to be done with minimal resources as possible
9307  // variables temporary here while in test
9308 
9309  Queue<UUID> RegionHandleRequests = new Queue<UUID>();
9310  bool RegionHandleRequestsInService = false;
9311 
9312  private bool HandleRegionHandleRequest(IClientAPI sender, Packet Pack)
9313  {
9314  UUID currentUUID;
9315 
9316  RegionHandleRequest handlerRegionHandleRequest = OnRegionHandleRequest;
9317 
9318  if (handlerRegionHandleRequest == null)
9319  return true;
9320 
9321  RegionHandleRequestPacket rhrPack = (RegionHandleRequestPacket)Pack;
9322 
9323  lock (RegionHandleRequests)
9324  {
9325  if (RegionHandleRequestsInService)
9326  {
9327  // we are already busy doing a previus request
9328  // so enqueue it
9329  RegionHandleRequests.Enqueue(rhrPack.RequestBlock.RegionID);
9330  return true;
9331  }
9332 
9333  // else do it
9334  currentUUID = rhrPack.RequestBlock.RegionID;
9335  RegionHandleRequestsInService = true;
9336  }
9337 
9338  while (true)
9339  {
9340  handlerRegionHandleRequest(this, currentUUID);
9341 
9342  lock (RegionHandleRequests)
9343  {
9344  // exit condition, nothing to do or closed
9345  // current code seems to assume we may loose the handler at anytime,
9346  // so keep checking it
9347  handlerRegionHandleRequest = OnRegionHandleRequest;
9348 
9349  if (RegionHandleRequests.Count == 0 || !IsActive || handlerRegionHandleRequest == null)
9350  {
9351  RegionHandleRequests.Clear();
9352  RegionHandleRequestsInService = false;
9353  return true;
9354  }
9355  currentUUID = RegionHandleRequests.Dequeue();
9356  }
9357  }
9358 
9359  return true; // actually unreached
9360  }
9361 
9362  private bool HandleParcelInfoRequest(IClientAPI sender, Packet Pack)
9363  {
9364  ParcelInfoRequestPacket pirPack = (ParcelInfoRequestPacket)Pack;
9365 
9366  #region Packet Session and User Check
9367  if (m_checkPackets)
9368  {
9369  if (pirPack.AgentData.SessionID != SessionId ||
9370  pirPack.AgentData.AgentID != AgentId)
9371  return true;
9372  }
9373  #endregion
9374 
9375  ParcelInfoRequest handlerParcelInfoRequest = OnParcelInfoRequest;
9376  if (handlerParcelInfoRequest != null)
9377  {
9378  handlerParcelInfoRequest(this, pirPack.Data.ParcelID);
9379  }
9380  return true;
9381  }
9382 
9383  private bool HandleParcelAccessListRequest(IClientAPI sender, Packet Pack)
9384  {
9385  ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
9386 
9387  #region Packet Session and User Check
9388  if (m_checkPackets)
9389  {
9390  if (requestPacket.AgentData.SessionID != SessionId ||
9391  requestPacket.AgentData.AgentID != AgentId)
9392  return true;
9393  }
9394  #endregion
9395 
9396  ParcelAccessListRequest handlerParcelAccessListRequest = OnParcelAccessListRequest;
9397 
9398  if (handlerParcelAccessListRequest != null)
9399  {
9400  handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
9401  requestPacket.Data.Flags, requestPacket.Data.SequenceID,
9402  requestPacket.Data.LocalID, this);
9403  }
9404  return true;
9405  }
9406 
9407  private bool HandleParcelAccessListUpdate(IClientAPI sender, Packet Pack)
9408  {
9409  ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
9410 
9411  #region Packet Session and User Check
9412  if (m_checkPackets)
9413  {
9414  if (updatePacket.AgentData.SessionID != SessionId ||
9415  updatePacket.AgentData.AgentID != AgentId)
9416  return true;
9417  }
9418  #endregion
9419 
9420  List<LandAccessEntry> entries = new List<LandAccessEntry>();
9421  foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
9422  {
9423  LandAccessEntry entry = new LandAccessEntry();
9424  entry.AgentID = block.ID;
9425  entry.Flags = (AccessList)block.Flags;
9426  entry.Expires = block.Time;
9427  entries.Add(entry);
9428  }
9429 
9430  ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
9431  if (handlerParcelAccessListUpdateRequest != null)
9432  {
9433  handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
9434  updatePacket.Data.Flags,
9435  updatePacket.Data.LocalID,
9436  updatePacket.Data.TransactionID,
9437  updatePacket.Data.SequenceID,
9438  updatePacket.Data.Sections,
9439  entries, this);
9440  }
9441  return true;
9442  }
9443 
9444  private bool HandleParcelPropertiesRequest(IClientAPI sender, Packet Pack)
9445  {
9446  ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
9447 
9448  #region Packet Session and User Check
9449  if (m_checkPackets)
9450  {
9451  if (propertiesRequest.AgentData.SessionID != SessionId ||
9452  propertiesRequest.AgentData.AgentID != AgentId)
9453  return true;
9454  }
9455  #endregion
9456 
9457  ParcelPropertiesRequest handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
9458  if (handlerParcelPropertiesRequest != null)
9459  {
9460  handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
9461  (int)Math.Round(propertiesRequest.ParcelData.South),
9462  (int)Math.Round(propertiesRequest.ParcelData.East),
9463  (int)Math.Round(propertiesRequest.ParcelData.North),
9464  propertiesRequest.ParcelData.SequenceID,
9465  propertiesRequest.ParcelData.SnapSelection, this);
9466  }
9467  return true;
9468  }
9469 
9470  private bool HandleParcelDivide(IClientAPI sender, Packet Pack)
9471  {
9472  ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
9473 
9474  #region Packet Session and User Check
9475  if (m_checkPackets)
9476  {
9477  if (landDivide.AgentData.SessionID != SessionId ||
9478  landDivide.AgentData.AgentID != AgentId)
9479  return true;
9480  }
9481  #endregion
9482 
9483  ParcelDivideRequest handlerParcelDivideRequest = OnParcelDivideRequest;
9484  if (handlerParcelDivideRequest != null)
9485  {
9486  handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
9487  (int)Math.Round(landDivide.ParcelData.South),
9488  (int)Math.Round(landDivide.ParcelData.East),
9489  (int)Math.Round(landDivide.ParcelData.North), this);
9490  }
9491  return true;
9492  }
9493 
9494  private bool HandleParcelJoin(IClientAPI sender, Packet Pack)
9495  {
9496  ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
9497 
9498  #region Packet Session and User Check
9499  if (m_checkPackets)
9500  {
9501  if (landJoin.AgentData.SessionID != SessionId ||
9502  landJoin.AgentData.AgentID != AgentId)
9503  return true;
9504  }
9505  #endregion
9506 
9507  ParcelJoinRequest handlerParcelJoinRequest = OnParcelJoinRequest;
9508 
9509  if (handlerParcelJoinRequest != null)
9510  {
9511  handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
9512  (int)Math.Round(landJoin.ParcelData.South),
9513  (int)Math.Round(landJoin.ParcelData.East),
9514  (int)Math.Round(landJoin.ParcelData.North), this);
9515  }
9516  return true;
9517  }
9518 
9519  private bool HandleParcelPropertiesUpdate(IClientAPI sender, Packet Pack)
9520  {
9521  ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
9522 
9523  #region Packet Session and User Check
9524  if (m_checkPackets)
9525  {
9526  if (parcelPropertiesPacket.AgentData.SessionID != SessionId ||
9527  parcelPropertiesPacket.AgentData.AgentID != AgentId)
9528  return true;
9529  }
9530  #endregion
9531 
9532  ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
9533 
9534  if (handlerParcelPropertiesUpdateRequest != null)
9535  {
9536  LandUpdateArgs args = new LandUpdateArgs();
9537 
9538  args.AuthBuyerID = parcelPropertiesPacket.ParcelData.AuthBuyerID;
9539  args.Category = (ParcelCategory)parcelPropertiesPacket.ParcelData.Category;
9540  args.Desc = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Desc);
9541  args.GroupID = parcelPropertiesPacket.ParcelData.GroupID;
9542  args.LandingType = parcelPropertiesPacket.ParcelData.LandingType;
9543  args.MediaAutoScale = parcelPropertiesPacket.ParcelData.MediaAutoScale;
9544  args.MediaID = parcelPropertiesPacket.ParcelData.MediaID;
9545  args.MediaURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MediaURL);
9546  args.MusicURL = Utils.BytesToString(parcelPropertiesPacket.ParcelData.MusicURL);
9547  args.Name = Utils.BytesToString(parcelPropertiesPacket.ParcelData.Name);
9548  args.ParcelFlags = parcelPropertiesPacket.ParcelData.ParcelFlags;
9549  args.PassHours = parcelPropertiesPacket.ParcelData.PassHours;
9550  args.PassPrice = parcelPropertiesPacket.ParcelData.PassPrice;
9551  args.SalePrice = parcelPropertiesPacket.ParcelData.SalePrice;
9552  args.SnapshotID = parcelPropertiesPacket.ParcelData.SnapshotID;
9553  args.UserLocation = parcelPropertiesPacket.ParcelData.UserLocation;
9554  args.UserLookAt = parcelPropertiesPacket.ParcelData.UserLookAt;
9555  handlerParcelPropertiesUpdateRequest(args, parcelPropertiesPacket.ParcelData.LocalID, this);
9556  }
9557  return true;
9558  }
9559 
9560  private bool HandleParcelSelectObjects(IClientAPI sender, Packet Pack)
9561  {
9562  ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
9563 
9564  #region Packet Session and User Check
9565  if (m_checkPackets)
9566  {
9567  if (selectPacket.AgentData.SessionID != SessionId ||
9568  selectPacket.AgentData.AgentID != AgentId)
9569  return true;
9570  }
9571  #endregion
9572 
9573  List<UUID> returnIDs = new List<UUID>();
9574 
9575  foreach (ParcelSelectObjectsPacket.ReturnIDsBlock rb in
9576  selectPacket.ReturnIDs)
9577  {
9578  returnIDs.Add(rb.ReturnID);
9579  }
9580 
9581  ParcelSelectObjects handlerParcelSelectObjects = OnParcelSelectObjects;
9582 
9583  if (handlerParcelSelectObjects != null)
9584  {
9585  handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
9586  Convert.ToInt32(selectPacket.ParcelData.ReturnType), returnIDs, this);
9587  }
9588  return true;
9589  }
9590 
9591  private bool HandleParcelObjectOwnersRequest(IClientAPI sender, Packet Pack)
9592  {
9593  ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
9594 
9595  #region Packet Session and User Check
9596  if (m_checkPackets)
9597  {
9598  if (reqPacket.AgentData.SessionID != SessionId ||
9599  reqPacket.AgentData.AgentID != AgentId)
9600  return true;
9601  }
9602  #endregion
9603 
9604  ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
9605 
9606  if (handlerParcelObjectOwnerRequest != null)
9607  {
9608  handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
9609  }
9610  return true;
9611 
9612  }
9613 
9614  private bool HandleParcelGodForceOwner(IClientAPI sender, Packet Pack)
9615  {
9616  ParcelGodForceOwnerPacket godForceOwnerPacket = (ParcelGodForceOwnerPacket)Pack;
9617 
9618  #region Packet Session and User Check
9619  if (m_checkPackets)
9620  {
9621  if (godForceOwnerPacket.AgentData.SessionID != SessionId ||
9622  godForceOwnerPacket.AgentData.AgentID != AgentId)
9623  return true;
9624  }
9625  #endregion
9626 
9627  ParcelGodForceOwner handlerParcelGodForceOwner = OnParcelGodForceOwner;
9628  if (handlerParcelGodForceOwner != null)
9629  {
9630  handlerParcelGodForceOwner(godForceOwnerPacket.Data.LocalID, godForceOwnerPacket.Data.OwnerID, this);
9631  }
9632  return true;
9633  }
9634 
9635  private bool HandleParcelRelease(IClientAPI sender, Packet Pack)
9636  {
9637  ParcelReleasePacket releasePacket = (ParcelReleasePacket)Pack;
9638 
9639  #region Packet Session and User Check
9640  if (m_checkPackets)
9641  {
9642  if (releasePacket.AgentData.SessionID != SessionId ||
9643  releasePacket.AgentData.AgentID != AgentId)
9644  return true;
9645  }
9646  #endregion
9647 
9648  ParcelAbandonRequest handlerParcelAbandonRequest = OnParcelAbandonRequest;
9649  if (handlerParcelAbandonRequest != null)
9650  {
9651  handlerParcelAbandonRequest(releasePacket.Data.LocalID, this);
9652  }
9653  return true;
9654  }
9655 
9656  private bool HandleParcelReclaim(IClientAPI sender, Packet Pack)
9657  {
9658  ParcelReclaimPacket reclaimPacket = (ParcelReclaimPacket)Pack;
9659 
9660  #region Packet Session and User Check
9661  if (m_checkPackets)
9662  {
9663  if (reclaimPacket.AgentData.SessionID != SessionId ||
9664  reclaimPacket.AgentData.AgentID != AgentId)
9665  return true;
9666  }
9667  #endregion
9668 
9669  ParcelReclaim handlerParcelReclaim = OnParcelReclaim;
9670  if (handlerParcelReclaim != null)
9671  {
9672  handlerParcelReclaim(reclaimPacket.Data.LocalID, this);
9673  }
9674  return true;
9675  }
9676 
9677  private bool HandleParcelReturnObjects(IClientAPI sender, Packet Pack)
9678  {
9679  ParcelReturnObjectsPacket parcelReturnObjects = (ParcelReturnObjectsPacket)Pack;
9680 
9681  #region Packet Session and User Check
9682  if (m_checkPackets)
9683  {
9684  if (parcelReturnObjects.AgentData.SessionID != SessionId ||
9685  parcelReturnObjects.AgentData.AgentID != AgentId)
9686  return true;
9687  }
9688  #endregion
9689 
9690  UUID[] puserselectedOwnerIDs = new UUID[parcelReturnObjects.OwnerIDs.Length];
9691  for (int parceliterator = 0; parceliterator < parcelReturnObjects.OwnerIDs.Length; parceliterator++)
9692  puserselectedOwnerIDs[parceliterator] = parcelReturnObjects.OwnerIDs[parceliterator].OwnerID;
9693 
9694  UUID[] puserselectedTaskIDs = new UUID[parcelReturnObjects.TaskIDs.Length];
9695 
9696  for (int parceliterator = 0; parceliterator < parcelReturnObjects.TaskIDs.Length; parceliterator++)
9697  puserselectedTaskIDs[parceliterator] = parcelReturnObjects.TaskIDs[parceliterator].TaskID;
9698 
9699  ParcelReturnObjectsRequest handlerParcelReturnObjectsRequest = OnParcelReturnObjectsRequest;
9700  if (handlerParcelReturnObjectsRequest != null)
9701  {
9702  handlerParcelReturnObjectsRequest(parcelReturnObjects.ParcelData.LocalID, parcelReturnObjects.ParcelData.ReturnType, puserselectedOwnerIDs, puserselectedTaskIDs, this);
9703 
9704  }
9705  return true;
9706  }
9707 
9708  private bool HandleParcelSetOtherCleanTime(IClientAPI sender, Packet Pack)
9709  {
9710  ParcelSetOtherCleanTimePacket parcelSetOtherCleanTimePacket = (ParcelSetOtherCleanTimePacket)Pack;
9711 
9712  #region Packet Session and User Check
9713  if (m_checkPackets)
9714  {
9715  if (parcelSetOtherCleanTimePacket.AgentData.SessionID != SessionId ||
9716  parcelSetOtherCleanTimePacket.AgentData.AgentID != AgentId)
9717  return true;
9718  }
9719  #endregion
9720 
9721  ParcelSetOtherCleanTime handlerParcelSetOtherCleanTime = OnParcelSetOtherCleanTime;
9722  if (handlerParcelSetOtherCleanTime != null)
9723  {
9724  handlerParcelSetOtherCleanTime(this,
9725  parcelSetOtherCleanTimePacket.ParcelData.LocalID,
9726  parcelSetOtherCleanTimePacket.ParcelData.OtherCleanTime);
9727  }
9728  return true;
9729  }
9730 
9731  private bool HandleLandStatRequest(IClientAPI sender, Packet Pack)
9732  {
9733  LandStatRequestPacket lsrp = (LandStatRequestPacket)Pack;
9734 
9735  #region Packet Session and User Check
9736  if (m_checkPackets)
9737  {
9738  if (lsrp.AgentData.SessionID != SessionId ||
9739  lsrp.AgentData.AgentID != AgentId)
9740  return true;
9741  }
9742  #endregion
9743 
9744  GodLandStatRequest handlerLandStatRequest = OnLandStatRequest;
9745  if (handlerLandStatRequest != null)
9746  {
9747  handlerLandStatRequest(lsrp.RequestData.ParcelLocalID, lsrp.RequestData.ReportType, lsrp.RequestData.RequestFlags, Utils.BytesToString(lsrp.RequestData.Filter), this);
9748  }
9749  return true;
9750  }
9751 
9752  private bool HandleParcelDwellRequest(IClientAPI sender, Packet Pack)
9753  {
9754  ParcelDwellRequestPacket dwellrq =
9755  (ParcelDwellRequestPacket)Pack;
9756 
9757  #region Packet Session and User Check
9758  if (m_checkPackets)
9759  {
9760  if (dwellrq.AgentData.SessionID != SessionId ||
9761  dwellrq.AgentData.AgentID != AgentId)
9762  return true;
9763  }
9764  #endregion
9765 
9766  ParcelDwellRequest handlerParcelDwellRequest = OnParcelDwellRequest;
9767  if (handlerParcelDwellRequest != null)
9768  {
9769  handlerParcelDwellRequest(dwellrq.Data.LocalID, this);
9770  }
9771  return true;
9772  }
9773 
9774  #endregion Parcel related packets
9775 
9776  #region Estate Packets
9777 
9778  private bool HandleEstateOwnerMessage(IClientAPI sender, Packet Pack)
9779  {
9780  EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
9781  // m_log.InfoFormat("[LLCLIENTVIEW]: Packet: {0}", Utils.BytesToString(messagePacket.MethodData.Method));
9782  GodLandStatRequest handlerLandStatRequest;
9783 
9784  #region Packet Session and User Check
9785  if (m_checkPackets)
9786  {
9787  if (messagePacket.AgentData.SessionID != SessionId ||
9788  messagePacket.AgentData.AgentID != AgentId)
9789  return true;
9790  }
9791  #endregion
9792 
9793  string method = Utils.BytesToString(messagePacket.MethodData.Method);
9794 
9795  switch (method)
9796  {
9797  case "getinfo":
9798  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9799  {
9800  OnDetailedEstateDataRequest(this, messagePacket.MethodData.Invoice);
9801  }
9802  return true;
9803  case "setregioninfo":
9804  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9805  {
9806  OnSetEstateFlagsRequest(convertParamStringToBool(messagePacket.ParamList[0].Parameter), convertParamStringToBool(messagePacket.ParamList[1].Parameter),
9807  convertParamStringToBool(messagePacket.ParamList[2].Parameter), !convertParamStringToBool(messagePacket.ParamList[3].Parameter),
9808  Convert.ToInt16(Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[4].Parameter), Culture.NumberFormatInfo)),
9809  (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo),
9810  Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[6].Parameter)),
9811  convertParamStringToBool(messagePacket.ParamList[7].Parameter), convertParamStringToBool(messagePacket.ParamList[8].Parameter));
9812  }
9813  return true;
9814  // case "texturebase":
9815  // if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9816  // {
9817  // foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
9818  // {
9819  // string s = Utils.BytesToString(block.Parameter);
9820  // string[] splitField = s.Split(' ');
9821  // if (splitField.Length == 2)
9822  // {
9823  // UUID tempUUID = new UUID(splitField[1]);
9824  // OnSetEstateTerrainBaseTexture(this, Convert.ToInt16(splitField[0]), tempUUID);
9825  // }
9826  // }
9827  // }
9828  // break;
9829  case "texturedetail":
9830  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9831  {
9832  foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
9833  {
9834  string s = Utils.BytesToString(block.Parameter);
9835  string[] splitField = s.Split(' ');
9836  if (splitField.Length == 2)
9837  {
9838  Int16 corner = Convert.ToInt16(splitField[0]);
9839  UUID textureUUID = new UUID(splitField[1]);
9840 
9841  OnSetEstateTerrainDetailTexture(this, corner, textureUUID);
9842  }
9843  }
9844  }
9845 
9846  return true;
9847  case "textureheights":
9848  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9849  {
9850  foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
9851  {
9852  string s = Utils.BytesToString(block.Parameter);
9853  string[] splitField = s.Split(' ');
9854  if (splitField.Length == 3)
9855  {
9856  Int16 corner = Convert.ToInt16(splitField[0]);
9857  float lowValue = (float)Convert.ToDecimal(splitField[1], Culture.NumberFormatInfo);
9858  float highValue = (float)Convert.ToDecimal(splitField[2], Culture.NumberFormatInfo);
9859 
9860  OnSetEstateTerrainTextureHeights(this, corner, lowValue, highValue);
9861  }
9862  }
9863  }
9864  return true;
9865  case "texturecommit":
9866  OnCommitEstateTerrainTextureRequest(this);
9867  return true;
9868  case "setregionterrain":
9869  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9870  {
9871  if (messagePacket.ParamList.Length != 9)
9872  {
9873  m_log.Error("EstateOwnerMessage: SetRegionTerrain method has a ParamList of invalid length");
9874  }
9875  else
9876  {
9877  try
9878  {
9879  string tmp = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
9880  if (!tmp.Contains(".")) tmp += ".00";
9881  float WaterHeight = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
9882  tmp = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
9883  if (!tmp.Contains(".")) tmp += ".00";
9884  float TerrainRaiseLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
9885  tmp = Utils.BytesToString(messagePacket.ParamList[2].Parameter);
9886  if (!tmp.Contains(".")) tmp += ".00";
9887  float TerrainLowerLimit = (float)Convert.ToDecimal(tmp, Culture.NumberFormatInfo);
9888  bool UseEstateSun = convertParamStringToBool(messagePacket.ParamList[3].Parameter);
9889  bool UseFixedSun = convertParamStringToBool(messagePacket.ParamList[4].Parameter);
9890  float SunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[5].Parameter), Culture.NumberFormatInfo);
9891  bool UseGlobal = convertParamStringToBool(messagePacket.ParamList[6].Parameter);
9892  bool EstateFixedSun = convertParamStringToBool(messagePacket.ParamList[7].Parameter);
9893  float EstateSunHour = (float)Convert.ToDecimal(Utils.BytesToString(messagePacket.ParamList[8].Parameter), Culture.NumberFormatInfo);
9894 
9895  OnSetRegionTerrainSettings(WaterHeight, TerrainRaiseLimit, TerrainLowerLimit, UseEstateSun, UseFixedSun, SunHour, UseGlobal, EstateFixedSun, EstateSunHour);
9896 
9897  }
9898  catch (Exception ex)
9899  {
9900  m_log.Error("EstateOwnerMessage: Exception while setting terrain settings: \n" + messagePacket + "\n" + ex);
9901  }
9902  }
9903  }
9904 
9905  return true;
9906  case "restart":
9907  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9908  {
9909  // There's only 1 block in the estateResetSim.. and that's the number of seconds till restart.
9910  foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
9911  {
9912  float timeSeconds;
9913  Utils.TryParseSingle(Utils.BytesToString(block.Parameter), out timeSeconds);
9914  timeSeconds = (int)timeSeconds;
9915  OnEstateRestartSimRequest(this, (int)timeSeconds);
9916 
9917  }
9918  }
9919  return true;
9920  case "estatechangecovenantid":
9921  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9922  {
9923  foreach (EstateOwnerMessagePacket.ParamListBlock block in messagePacket.ParamList)
9924  {
9925  UUID newCovenantID = new UUID(Utils.BytesToString(block.Parameter));
9926  OnEstateChangeCovenantRequest(this, newCovenantID);
9927  }
9928  }
9929  return true;
9930  case "estateaccessdelta": // Estate access delta manages the banlist and allow list too.
9931  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9932  {
9933  int estateAccessType = Convert.ToInt16(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
9934  OnUpdateEstateAccessDeltaRequest(this, messagePacket.MethodData.Invoice, estateAccessType, new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter)));
9935 
9936  }
9937  return true;
9938  case "simulatormessage":
9939  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9940  {
9941  UUID invoice = messagePacket.MethodData.Invoice;
9942  UUID SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
9943  string SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
9944  string Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
9945  UUID sessionID = messagePacket.AgentData.SessionID;
9946  OnSimulatorBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
9947  }
9948  return true;
9949  case "instantmessage":
9950  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9951  {
9952  if (messagePacket.ParamList.Length < 2)
9953  return true;
9954 
9955  UUID invoice = messagePacket.MethodData.Invoice;
9956  UUID sessionID = messagePacket.AgentData.SessionID;
9957 
9958  UUID SenderID;
9959  string SenderName;
9960  string Message;
9961 
9962  if (messagePacket.ParamList.Length < 5)
9963  {
9964  SenderID = AgentId;
9965  SenderName = Utils.BytesToString(messagePacket.ParamList[0].Parameter);
9966  Message = Utils.BytesToString(messagePacket.ParamList[1].Parameter);
9967  }
9968  else
9969  {
9970  SenderID = new UUID(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
9971  SenderName = Utils.BytesToString(messagePacket.ParamList[3].Parameter);
9972  Message = Utils.BytesToString(messagePacket.ParamList[4].Parameter);
9973  }
9974 
9975  OnEstateBlueBoxMessageRequest(this, invoice, SenderID, sessionID, SenderName, Message);
9976  }
9977  return true;
9978  case "setregiondebug":
9979  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9980  {
9981  UUID invoice = messagePacket.MethodData.Invoice;
9982  UUID SenderID = messagePacket.AgentData.AgentID;
9983  bool scripted = convertParamStringToBool(messagePacket.ParamList[0].Parameter);
9984  bool collisionEvents = convertParamStringToBool(messagePacket.ParamList[1].Parameter);
9985  bool physics = convertParamStringToBool(messagePacket.ParamList[2].Parameter);
9986 
9987  OnEstateDebugRegionRequest(this, invoice, SenderID, scripted, collisionEvents, physics);
9988  }
9989  return true;
9990  case "teleporthomeuser":
9991  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
9992  {
9993  UUID invoice = messagePacket.MethodData.Invoice;
9994  UUID SenderID = messagePacket.AgentData.AgentID;
9995  UUID Prey;
9996 
9997  UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[1].Parameter), out Prey);
9998 
9999  OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
10000  }
10001  return true;
10002  case "teleporthomeallusers":
10003  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
10004  {
10005  UUID invoice = messagePacket.MethodData.Invoice;
10006  UUID SenderID = messagePacket.AgentData.AgentID;
10007  OnEstateTeleportAllUsersHomeRequest(this, invoice, SenderID);
10008  }
10009  return true;
10010  case "colliders":
10011  handlerLandStatRequest = OnLandStatRequest;
10012  if (handlerLandStatRequest != null)
10013  {
10014  handlerLandStatRequest(0, 1, 0, "", this);
10015  }
10016  return true;
10017  case "scripts":
10018  handlerLandStatRequest = OnLandStatRequest;
10019  if (handlerLandStatRequest != null)
10020  {
10021  handlerLandStatRequest(0, 0, 0, "", this);
10022  }
10023  return true;
10024  case "terrain":
10025  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
10026  {
10027  if (messagePacket.ParamList.Length > 0)
10028  {
10029  if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "bake")
10030  {
10031  BakeTerrain handlerBakeTerrain = OnBakeTerrain;
10032  if (handlerBakeTerrain != null)
10033  {
10034  handlerBakeTerrain(this);
10035  }
10036  }
10037  if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "download filename")
10038  {
10039  if (messagePacket.ParamList.Length > 1)
10040  {
10041  RequestTerrain handlerRequestTerrain = OnRequestTerrain;
10042  if (handlerRequestTerrain != null)
10043  {
10044  handlerRequestTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
10045  }
10046  }
10047  }
10048  if (Utils.BytesToString(messagePacket.ParamList[0].Parameter) == "upload filename")
10049  {
10050  if (messagePacket.ParamList.Length > 1)
10051  {
10052  RequestTerrain handlerUploadTerrain = OnUploadTerrain;
10053  if (handlerUploadTerrain != null)
10054  {
10055  handlerUploadTerrain(this, Utils.BytesToString(messagePacket.ParamList[1].Parameter));
10056  }
10057  }
10058  }
10059 
10060  }
10061 
10062 
10063  }
10064  return true;
10065 
10066  case "estatechangeinfo":
10067  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
10068  {
10069  UUID invoice = messagePacket.MethodData.Invoice;
10070  UUID SenderID = messagePacket.AgentData.AgentID;
10071  UInt32 param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
10072  UInt32 param2 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[2].Parameter));
10073 
10074  EstateChangeInfo handlerEstateChangeInfo = OnEstateChangeInfo;
10075  if (handlerEstateChangeInfo != null)
10076  {
10077  handlerEstateChangeInfo(this, invoice, SenderID, param1, param2);
10078  }
10079  }
10080  return true;
10081 
10082  case "telehub":
10083  if (((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
10084  {
10085  UUID invoice = messagePacket.MethodData.Invoice;
10086  UUID SenderID = messagePacket.AgentData.AgentID;
10087  UInt32 param1 = 0u;
10088 
10089  string command = (string)Utils.BytesToString(messagePacket.ParamList[0].Parameter);
10090 
10091  if (command != "info ui")
10092  {
10093  try
10094  {
10095  param1 = Convert.ToUInt32(Utils.BytesToString(messagePacket.ParamList[1].Parameter));
10096  }
10097  catch
10098  {
10099  }
10100  }
10101 
10102  EstateManageTelehub handlerEstateManageTelehub = OnEstateManageTelehub;
10103  if (handlerEstateManageTelehub != null)
10104  {
10105  handlerEstateManageTelehub(this, invoice, SenderID, command, param1);
10106  }
10107  }
10108  return true;
10109 
10110  case "kickestate":
10111 
10112  if(((Scene)m_scene).Permissions.CanIssueEstateCommand(AgentId, false))
10113  {
10114  UUID invoice = messagePacket.MethodData.Invoice;
10115  UUID SenderID = messagePacket.AgentData.AgentID;
10116  UUID Prey;
10117 
10118  UUID.TryParse(Utils.BytesToString(messagePacket.ParamList[0].Parameter), out Prey);
10119 
10120  OnEstateTeleportOneUserHomeRequest(this, invoice, SenderID, Prey);
10121  }
10122  return true;
10123 
10124  default:
10125  m_log.WarnFormat(
10126  "[LLCLIENTVIEW]: EstateOwnerMessage: Unknown method {0} requested for {1} in {2}",
10127  method, Name, Scene.Name);
10128 
10129  for (int i = 0; i < messagePacket.ParamList.Length; i++)
10130  {
10131  EstateOwnerMessagePacket.ParamListBlock block = messagePacket.ParamList[i];
10132  string data = (string)Utils.BytesToString(block.Parameter);
10133  m_log.DebugFormat("[LLCLIENTVIEW]: Param {0}={1}", i, data);
10134  }
10135 
10136  return true;
10137  }
10138 
10139  //int parcelID, uint reportType, uint requestflags, string filter
10140 
10141  //lsrp.RequestData.ParcelLocalID;
10142  //lsrp.RequestData.ReportType; // 1 = colliders, 0 = scripts
10143  //lsrp.RequestData.RequestFlags;
10144  //lsrp.RequestData.Filter;
10145  }
10146 
10147  private bool HandleRequestRegionInfo(IClientAPI sender, Packet Pack)
10148  {
10149  RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
10150 
10151  #region Packet Session and User Check
10152  if (m_checkPackets)
10153  {
10154  if (mPacket.SessionID != SessionId ||
10155  mPacket.AgentID != AgentId)
10156  return true;
10157  }
10158  #endregion
10159 
10160  RegionInfoRequest handlerRegionInfoRequest = OnRegionInfoRequest;
10161  if (handlerRegionInfoRequest != null)
10162  {
10163  handlerRegionInfoRequest(this);
10164  }
10165  return true;
10166  }
10167 
10168  private bool HandleEstateCovenantRequest(IClientAPI sender, Packet Pack)
10169  {
10170 
10171  //EstateCovenantRequestPacket.AgentDataBlock epack =
10172  // ((EstateCovenantRequestPacket)Pack).AgentData;
10173 
10174  EstateCovenantRequest handlerEstateCovenantRequest = OnEstateCovenantRequest;
10175  if (handlerEstateCovenantRequest != null)
10176  {
10177  handlerEstateCovenantRequest(this);
10178  }
10179  return true;
10180 
10181  }
10182 
10183  #endregion Estate Packets
10184 
10185  #region GodPackets
10186 
10187  private bool HandleRequestGodlikePowers(IClientAPI sender, Packet Pack)
10188  {
10189  RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
10190  RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
10191  UUID token = rblock.Token;
10192 
10193  RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
10194 
10195  RequestGodlikePowers handlerReqGodlikePowers = OnRequestGodlikePowers;
10196 
10197  if (handlerReqGodlikePowers != null)
10198  {
10199  handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this);
10200  }
10201 
10202  return true;
10203  }
10204 
10205  private bool HandleGodUpdateRegionInfoUpdate(IClientAPI client, Packet Packet)
10206  {
10207  GodUpdateRegionInfoPacket GodUpdateRegionInfo =
10208  (GodUpdateRegionInfoPacket)Packet;
10209 
10210  GodUpdateRegionInfoUpdate handlerGodUpdateRegionInfo = OnGodUpdateRegionInfoUpdate;
10211  if (handlerGodUpdateRegionInfo != null)
10212  {
10213  handlerGodUpdateRegionInfo(this,
10214  GodUpdateRegionInfo.RegionInfo.BillableFactor,
10215  GodUpdateRegionInfo.RegionInfo.EstateID,
10216  GodUpdateRegionInfo.RegionInfo.RegionFlags,
10217  GodUpdateRegionInfo.RegionInfo.SimName,
10218  GodUpdateRegionInfo.RegionInfo.RedirectGridX,
10219  GodUpdateRegionInfo.RegionInfo.RedirectGridY);
10220  return true;
10221  }
10222  return false;
10223  }
10224 
10225  private bool HandleSimWideDeletes(IClientAPI client, Packet Packet)
10226  {
10227  SimWideDeletesPacket SimWideDeletesRequest =
10228  (SimWideDeletesPacket)Packet;
10229  SimWideDeletesDelegate handlerSimWideDeletesRequest = OnSimWideDeletes;
10230  if (handlerSimWideDeletesRequest != null)
10231  {
10232  handlerSimWideDeletesRequest(this, SimWideDeletesRequest.AgentData.AgentID,(int)SimWideDeletesRequest.DataBlock.Flags,SimWideDeletesRequest.DataBlock.TargetID);
10233  return true;
10234  }
10235  return false;
10236  }
10237 
10238  private bool HandleGodlikeMessage(IClientAPI client, Packet Packet)
10239  {
10240  GodlikeMessagePacket GodlikeMessage =
10241  (GodlikeMessagePacket)Packet;
10242 
10243  GodlikeMessage handlerGodlikeMessage = onGodlikeMessage;
10244  if (handlerGodlikeMessage != null)
10245  {
10246  handlerGodlikeMessage(this,
10247  GodlikeMessage.MethodData.Invoice,
10248  GodlikeMessage.MethodData.Method,
10249  GodlikeMessage.ParamList[0].Parameter);
10250  return true;
10251  }
10252  return false;
10253  }
10254 
10255  private bool HandleSaveStatePacket(IClientAPI client, Packet Packet)
10256  {
10257  StateSavePacket SaveStateMessage =
10258  (StateSavePacket)Packet;
10259  SaveStateHandler handlerSaveStatePacket = OnSaveState;
10260  if (handlerSaveStatePacket != null)
10261  {
10262  handlerSaveStatePacket(this,SaveStateMessage.AgentData.AgentID);
10263  return true;
10264  }
10265  return false;
10266  }
10267 
10268  private bool HandleGodKickUser(IClientAPI sender, Packet Pack)
10269  {
10270  GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
10271 
10272  if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
10273  {
10274  GodKickUser handlerGodKickUser = OnGodKickUser;
10275  if (handlerGodKickUser != null)
10276  {
10277  handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
10278  gkupack.UserInfo.AgentID, gkupack.UserInfo.KickFlags, gkupack.UserInfo.Reason);
10279  }
10280  }
10281  else
10282  {
10283  SendAgentAlertMessage("Kick request denied", false);
10284  }
10285  //KickUserPacket kupack = new KickUserPacket();
10286  //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo;
10287 
10288  //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID;
10289  //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID;
10290 
10291  //kupack.TargetBlock.TargetIP = (uint)0;
10292  //kupack.TargetBlock.TargetPort = (ushort)0;
10293  //kupack.UserInfo.Reason = gkupack.UserInfo.Reason;
10294 
10295  //OutPacket(kupack, ThrottleOutPacketType.Task);
10296  return true;
10297  }
10298  #endregion GodPackets
10299 
10300  #region Economy/Transaction Packets
10301 
10302  private bool HandleMoneyBalanceRequest(IClientAPI sender, Packet Pack)
10303  {
10304  MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
10305 
10306  #region Packet Session and User Check
10307  if (m_checkPackets)
10308  {
10309  if (moneybalancerequestpacket.AgentData.SessionID != SessionId ||
10310  moneybalancerequestpacket.AgentData.AgentID != AgentId)
10311  return true;
10312  }
10313  #endregion
10314 
10315  MoneyBalanceRequest handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
10316 
10317  if (handlerMoneyBalanceRequest != null)
10318  {
10319  handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
10320  }
10321 
10322  return true;
10323  }
10324  private bool HandleEconomyDataRequest(IClientAPI sender, Packet Pack)
10325  {
10326  EconomyDataRequest handlerEconomoyDataRequest = OnEconomyDataRequest;
10327  if (handlerEconomoyDataRequest != null)
10328  {
10329  handlerEconomoyDataRequest(this);
10330  }
10331  return true;
10332  }
10333  private bool HandleRequestPayPrice(IClientAPI sender, Packet Pack)
10334  {
10335  RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
10336 
10337  RequestPayPrice handlerRequestPayPrice = OnRequestPayPrice;
10338  if (handlerRequestPayPrice != null)
10339  {
10340  handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
10341  }
10342  return true;
10343  }
10344  private bool HandleObjectSaleInfo(IClientAPI sender, Packet Pack)
10345  {
10346  ObjectSaleInfoPacket objectSaleInfoPacket = (ObjectSaleInfoPacket)Pack;
10347 
10348  #region Packet Session and User Check
10349  if (m_checkPackets)
10350  {
10351  if (objectSaleInfoPacket.AgentData.SessionID != SessionId ||
10352  objectSaleInfoPacket.AgentData.AgentID != AgentId)
10353  return true;
10354  }
10355  #endregion
10356 
10357  ObjectSaleInfo handlerObjectSaleInfo = OnObjectSaleInfo;
10358  if (handlerObjectSaleInfo != null)
10359  {
10360  foreach (ObjectSaleInfoPacket.ObjectDataBlock d
10361  in objectSaleInfoPacket.ObjectData)
10362  {
10363  handlerObjectSaleInfo(this,
10364  objectSaleInfoPacket.AgentData.AgentID,
10365  objectSaleInfoPacket.AgentData.SessionID,
10366  d.LocalID,
10367  d.SaleType,
10368  d.SalePrice);
10369  }
10370  }
10371  return true;
10372  }
10373  private bool HandleObjectBuy(IClientAPI sender, Packet Pack)
10374  {
10375  ObjectBuyPacket objectBuyPacket = (ObjectBuyPacket)Pack;
10376 
10377  #region Packet Session and User Check
10378  if (m_checkPackets)
10379  {
10380  if (objectBuyPacket.AgentData.SessionID != SessionId ||
10381  objectBuyPacket.AgentData.AgentID != AgentId)
10382  return true;
10383  }
10384  #endregion
10385 
10386  ObjectBuy handlerObjectBuy = OnObjectBuy;
10387 
10388  if (handlerObjectBuy != null)
10389  {
10390  foreach (ObjectBuyPacket.ObjectDataBlock d
10391  in objectBuyPacket.ObjectData)
10392  {
10393  handlerObjectBuy(this,
10394  objectBuyPacket.AgentData.AgentID,
10395  objectBuyPacket.AgentData.SessionID,
10396  objectBuyPacket.AgentData.GroupID,
10397  objectBuyPacket.AgentData.CategoryID,
10398  d.ObjectLocalID,
10399  d.SaleType,
10400  d.SalePrice);
10401  }
10402  }
10403  return true;
10404  }
10405 
10406  #endregion Economy/Transaction Packets
10407 
10408  #region Script Packets
10409  private bool HandleGetScriptRunning(IClientAPI sender, Packet Pack)
10410  {
10411  GetScriptRunningPacket scriptRunning = (GetScriptRunningPacket)Pack;
10412 
10413  GetScriptRunning handlerGetScriptRunning = OnGetScriptRunning;
10414  if (handlerGetScriptRunning != null)
10415  {
10416  handlerGetScriptRunning(this, scriptRunning.Script.ObjectID, scriptRunning.Script.ItemID);
10417  }
10418  return true;
10419  }
10420  private bool HandleSetScriptRunning(IClientAPI sender, Packet Pack)
10421  {
10422  SetScriptRunningPacket setScriptRunning = (SetScriptRunningPacket)Pack;
10423 
10424  #region Packet Session and User Check
10425  if (m_checkPackets)
10426  {
10427  if (setScriptRunning.AgentData.SessionID != SessionId ||
10428  setScriptRunning.AgentData.AgentID != AgentId)
10429  return true;
10430  }
10431  #endregion
10432 
10433  SetScriptRunning handlerSetScriptRunning = OnSetScriptRunning;
10434  if (handlerSetScriptRunning != null)
10435  {
10436  handlerSetScriptRunning(this, setScriptRunning.Script.ObjectID, setScriptRunning.Script.ItemID, setScriptRunning.Script.Running);
10437  }
10438  return true;
10439  }
10440 
10441  private bool HandleScriptReset(IClientAPI sender, Packet Pack)
10442  {
10443  ScriptResetPacket scriptResetPacket = (ScriptResetPacket)Pack;
10444 
10445  #region Packet Session and User Check
10446  if (m_checkPackets)
10447  {
10448  if (scriptResetPacket.AgentData.SessionID != SessionId ||
10449  scriptResetPacket.AgentData.AgentID != AgentId)
10450  return true;
10451  }
10452  #endregion
10453 
10454  ScriptReset handlerScriptReset = OnScriptReset;
10455  if (handlerScriptReset != null)
10456  {
10457  handlerScriptReset(this, scriptResetPacket.Script.ObjectID, scriptResetPacket.Script.ItemID);
10458  }
10459  return true;
10460  }
10461 
10462  #endregion Script Packets
10463 
10464  #region Gesture Managment
10465 
10466  private bool HandleActivateGestures(IClientAPI sender, Packet Pack)
10467  {
10468  ActivateGesturesPacket activateGesturePacket = (ActivateGesturesPacket)Pack;
10469 
10470  #region Packet Session and User Check
10471  if (m_checkPackets)
10472  {
10473  if (activateGesturePacket.AgentData.SessionID != SessionId ||
10474  activateGesturePacket.AgentData.AgentID != AgentId)
10475  return true;
10476  }
10477  #endregion
10478 
10479  ActivateGesture handlerActivateGesture = OnActivateGesture;
10480  if (handlerActivateGesture != null)
10481  {
10482  handlerActivateGesture(this,
10483  activateGesturePacket.Data[0].AssetID,
10484  activateGesturePacket.Data[0].ItemID);
10485  }
10486  else m_log.Error("Null pointer for activateGesture");
10487 
10488  return true;
10489  }
10490  private bool HandleDeactivateGestures(IClientAPI sender, Packet Pack)
10491  {
10492  DeactivateGesturesPacket deactivateGesturePacket = (DeactivateGesturesPacket)Pack;
10493 
10494  #region Packet Session and User Check
10495  if (m_checkPackets)
10496  {
10497  if (deactivateGesturePacket.AgentData.SessionID != SessionId ||
10498  deactivateGesturePacket.AgentData.AgentID != AgentId)
10499  return true;
10500  }
10501  #endregion
10502 
10503  DeactivateGesture handlerDeactivateGesture = OnDeactivateGesture;
10504  if (handlerDeactivateGesture != null)
10505  {
10506  handlerDeactivateGesture(this, deactivateGesturePacket.Data[0].ItemID);
10507  }
10508  return true;
10509  }
10510  private bool HandleObjectOwner(IClientAPI sender, Packet Pack)
10511  {
10512  ObjectOwnerPacket objectOwnerPacket = (ObjectOwnerPacket)Pack;
10513 
10514  #region Packet Session and User Check
10515  if (m_checkPackets)
10516  {
10517  if (objectOwnerPacket.AgentData.SessionID != SessionId ||
10518  objectOwnerPacket.AgentData.AgentID != AgentId)
10519  return true;
10520  }
10521  #endregion
10522 
10523  List<uint> localIDs = new List<uint>();
10524 
10525  foreach (ObjectOwnerPacket.ObjectDataBlock d in objectOwnerPacket.ObjectData)
10526  localIDs.Add(d.ObjectLocalID);
10527 
10528  ObjectOwner handlerObjectOwner = OnObjectOwner;
10529  if (handlerObjectOwner != null)
10530  {
10531  handlerObjectOwner(this, objectOwnerPacket.HeaderData.OwnerID, objectOwnerPacket.HeaderData.GroupID, localIDs);
10532  }
10533  return true;
10534  }
10535 
10536  #endregion Gesture Managment
10537 
10538  private bool HandleAgentFOV(IClientAPI sender, Packet Pack)
10539  {
10540  AgentFOVPacket fovPacket = (AgentFOVPacket)Pack;
10541 
10542  if (fovPacket.FOVBlock.GenCounter > m_agentFOVCounter)
10543  {
10544  m_agentFOVCounter = fovPacket.FOVBlock.GenCounter;
10545  AgentFOV handlerAgentFOV = OnAgentFOV;
10546  if (handlerAgentFOV != null)
10547  {
10548  handlerAgentFOV(this, fovPacket.FOVBlock.VerticalAngle);
10549  }
10550  }
10551  return true;
10552  }
10553 
10554  #region unimplemented handlers
10555 
10556  private bool HandleViewerStats(IClientAPI sender, Packet Pack)
10557  {
10558  // TODO: handle this packet
10559  //m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
10560  return true;
10561  }
10562 
10563  private bool HandleMapItemRequest(IClientAPI sender, Packet Pack)
10564  {
10565  MapItemRequestPacket mirpk = (MapItemRequestPacket)Pack;
10566 
10567  #region Packet Session and User Check
10568  if (m_checkPackets)
10569  {
10570  if (mirpk.AgentData.SessionID != SessionId ||
10571  mirpk.AgentData.AgentID != AgentId)
10572  return true;
10573  }
10574  #endregion
10575 
10576  //m_log.Debug(mirpk.ToString());
10577  MapItemRequest handlerMapItemRequest = OnMapItemRequest;
10578  if (handlerMapItemRequest != null)
10579  {
10580  handlerMapItemRequest(this, mirpk.AgentData.Flags, mirpk.AgentData.EstateID,
10581  mirpk.AgentData.Godlike, mirpk.RequestData.ItemType,
10582  mirpk.RequestData.RegionHandle);
10583 
10584  }
10585  return true;
10586  }
10587 
10588  private bool HandleTransferAbort(IClientAPI sender, Packet Pack)
10589  {
10590  return true;
10591  }
10592 
10593  private bool HandleMuteListRequest(IClientAPI sender, Packet Pack)
10594  {
10595  MuteListRequestPacket muteListRequest =
10596  (MuteListRequestPacket)Pack;
10597 
10598  #region Packet Session and User Check
10599  if (m_checkPackets)
10600  {
10601  if (muteListRequest.AgentData.SessionID != SessionId ||
10602  muteListRequest.AgentData.AgentID != AgentId)
10603  return true;
10604  }
10605  #endregion
10606 
10607  MuteListRequest handlerMuteListRequest = OnMuteListRequest;
10608  if (handlerMuteListRequest != null)
10609  {
10610  handlerMuteListRequest(this, muteListRequest.MuteData.MuteCRC);
10611  }
10612  else
10613  {
10614  SendUseCachedMuteList();
10615  }
10616  return true;
10617  }
10618 
10619  private bool HandleUpdateMuteListEntry(IClientAPI client, Packet Packet)
10620  {
10621  UpdateMuteListEntryPacket UpdateMuteListEntry =
10622  (UpdateMuteListEntryPacket)Packet;
10623  MuteListEntryUpdate handlerUpdateMuteListEntry = OnUpdateMuteListEntry;
10624  if (handlerUpdateMuteListEntry != null)
10625  {
10626  handlerUpdateMuteListEntry(this, UpdateMuteListEntry.MuteData.MuteID,
10627  Utils.BytesToString(UpdateMuteListEntry.MuteData.MuteName),
10628  UpdateMuteListEntry.MuteData.MuteType,
10629  UpdateMuteListEntry.MuteData.MuteFlags);
10630  return true;
10631  }
10632  return false;
10633  }
10634 
10635  private bool HandleRemoveMuteListEntry(IClientAPI client, Packet Packet)
10636  {
10637  RemoveMuteListEntryPacket RemoveMuteListEntry =
10638  (RemoveMuteListEntryPacket)Packet;
10639  MuteListEntryRemove handlerRemoveMuteListEntry = OnRemoveMuteListEntry;
10640  if (handlerRemoveMuteListEntry != null)
10641  {
10642  handlerRemoveMuteListEntry(this,
10643  RemoveMuteListEntry.MuteData.MuteID,
10644  Utils.BytesToString(RemoveMuteListEntry.MuteData.MuteName));
10645  return true;
10646  }
10647  return false;
10648  }
10649 
10650  private bool HandleUserReport(IClientAPI client, Packet Packet)
10651  {
10652  UserReportPacket UserReport =
10653  (UserReportPacket)Packet;
10654 
10655  NewUserReport handlerUserReport = OnUserReport;
10656  if (handlerUserReport != null)
10657  {
10658  handlerUserReport(this,
10659  Utils.BytesToString(UserReport.ReportData.AbuseRegionName),
10660  UserReport.ReportData.AbuserID,
10661  UserReport.ReportData.Category,
10662  UserReport.ReportData.CheckFlags,
10663  Utils.BytesToString(UserReport.ReportData.Details),
10664  UserReport.ReportData.ObjectID,
10665  UserReport.ReportData.Position,
10666  UserReport.ReportData.ReportType,
10667  UserReport.ReportData.ScreenshotID,
10668  Utils.BytesToString(UserReport.ReportData.Summary),
10669  UserReport.AgentData.AgentID);
10670  return true;
10671  }
10672  return false;
10673  }
10674 
10675  private bool HandleSendPostcard(IClientAPI client, Packet packet)
10676  {
10677 // SendPostcardPacket SendPostcard =
10678 // (SendPostcardPacket)packet;
10679  SendPostcard handlerSendPostcard = OnSendPostcard;
10680  if (handlerSendPostcard != null)
10681  {
10682  handlerSendPostcard(this);
10683  return true;
10684  }
10685  return false;
10686  }
10687 
10688  private bool HandleChangeInventoryItemFlags(IClientAPI client, Packet packet)
10689  {
10690  ChangeInventoryItemFlagsPacket ChangeInventoryItemFlags =
10691  (ChangeInventoryItemFlagsPacket)packet;
10692  ChangeInventoryItemFlags handlerChangeInventoryItemFlags = OnChangeInventoryItemFlags;
10693  if (handlerChangeInventoryItemFlags != null)
10694  {
10695  foreach(ChangeInventoryItemFlagsPacket.InventoryDataBlock b in ChangeInventoryItemFlags.InventoryData)
10696  handlerChangeInventoryItemFlags(this, b.ItemID, b.Flags);
10697  return true;
10698  }
10699  return false;
10700  }
10701 
10702  private bool HandleUseCircuitCode(IClientAPI sender, Packet Pack)
10703  {
10704  return true;
10705  }
10706 
10707  private bool HandleCreateNewOutfitAttachments(IClientAPI sender, Packet Pack)
10708  {
10709  CreateNewOutfitAttachmentsPacket packet = (CreateNewOutfitAttachmentsPacket)Pack;
10710 
10711  #region Packet Session and User Check
10712  if (m_checkPackets)
10713  {
10714  if (packet.AgentData.SessionID != SessionId ||
10715  packet.AgentData.AgentID != AgentId)
10716  return true;
10717  }
10718  #endregion
10719  MoveItemsAndLeaveCopy handlerMoveItemsAndLeaveCopy = null;
10720  List<InventoryItemBase> items = new List<InventoryItemBase>();
10721  foreach (CreateNewOutfitAttachmentsPacket.ObjectDataBlock n in packet.ObjectData)
10722  {
10724  b.ID = n.OldItemID;
10725  b.Folder = n.OldFolderID;
10726  items.Add(b);
10727  }
10728 
10729  handlerMoveItemsAndLeaveCopy = OnMoveItemsAndLeaveCopy;
10730  if (handlerMoveItemsAndLeaveCopy != null)
10731  {
10732  handlerMoveItemsAndLeaveCopy(this, items, packet.HeaderData.NewFolderID);
10733  }
10734 
10735  return true;
10736  }
10737 
10738  private bool HandleAgentHeightWidth(IClientAPI sender, Packet Pack)
10739  {
10740  return true;
10741  }
10742 
10743  private bool HandleInventoryDescendents(IClientAPI sender, Packet Pack)
10744  {
10745  return true;
10746  }
10747 
10748  #endregion unimplemented handlers
10749 
10750  #region Dir handlers
10751 
10752  private bool HandleDirPlacesQuery(IClientAPI sender, Packet Pack)
10753  {
10754  DirPlacesQueryPacket dirPlacesQueryPacket = (DirPlacesQueryPacket)Pack;
10755  //m_log.Debug(dirPlacesQueryPacket.ToString());
10756 
10757  #region Packet Session and User Check
10758  if (m_checkPackets)
10759  {
10760  if (dirPlacesQueryPacket.AgentData.SessionID != SessionId ||
10761  dirPlacesQueryPacket.AgentData.AgentID != AgentId)
10762  return true;
10763  }
10764  #endregion
10765 
10766  DirPlacesQuery handlerDirPlacesQuery = OnDirPlacesQuery;
10767  if (handlerDirPlacesQuery != null)
10768  {
10769  handlerDirPlacesQuery(this,
10770  dirPlacesQueryPacket.QueryData.QueryID,
10771  Utils.BytesToString(
10772  dirPlacesQueryPacket.QueryData.QueryText),
10773  (int)dirPlacesQueryPacket.QueryData.QueryFlags,
10774  (int)dirPlacesQueryPacket.QueryData.Category,
10775  Utils.BytesToString(
10776  dirPlacesQueryPacket.QueryData.SimName),
10777  dirPlacesQueryPacket.QueryData.QueryStart);
10778  }
10779  return true;
10780  }
10781 
10782  private bool HandleDirFindQuery(IClientAPI sender, Packet Pack)
10783  {
10784  DirFindQueryPacket dirFindQueryPacket = (DirFindQueryPacket)Pack;
10785 
10786  #region Packet Session and User Check
10787  if (m_checkPackets)
10788  {
10789  if (dirFindQueryPacket.AgentData.SessionID != SessionId ||
10790  dirFindQueryPacket.AgentData.AgentID != AgentId)
10791  return true;
10792  }
10793  #endregion
10794 
10795  DirFindQuery handlerDirFindQuery = OnDirFindQuery;
10796  if (handlerDirFindQuery != null)
10797  {
10798  handlerDirFindQuery(this,
10799  dirFindQueryPacket.QueryData.QueryID,
10800  Utils.BytesToString(
10801  dirFindQueryPacket.QueryData.QueryText).Trim(),
10802  dirFindQueryPacket.QueryData.QueryFlags,
10803  dirFindQueryPacket.QueryData.QueryStart);
10804  }
10805  return true;
10806  }
10807 
10808  private bool HandleDirLandQuery(IClientAPI sender, Packet Pack)
10809  {
10810  DirLandQueryPacket dirLandQueryPacket = (DirLandQueryPacket)Pack;
10811 
10812  #region Packet Session and User Check
10813  if (m_checkPackets)
10814  {
10815  if (dirLandQueryPacket.AgentData.SessionID != SessionId ||
10816  dirLandQueryPacket.AgentData.AgentID != AgentId)
10817  return true;
10818  }
10819  #endregion
10820 
10821  DirLandQuery handlerDirLandQuery = OnDirLandQuery;
10822  if (handlerDirLandQuery != null)
10823  {
10824  handlerDirLandQuery(this,
10825  dirLandQueryPacket.QueryData.QueryID,
10826  dirLandQueryPacket.QueryData.QueryFlags,
10827  dirLandQueryPacket.QueryData.SearchType,
10828  dirLandQueryPacket.QueryData.Price,
10829  dirLandQueryPacket.QueryData.Area,
10830  dirLandQueryPacket.QueryData.QueryStart);
10831  }
10832  return true;
10833  }
10834 
10835  private bool HandleDirPopularQuery(IClientAPI sender, Packet Pack)
10836  {
10837  DirPopularQueryPacket dirPopularQueryPacket = (DirPopularQueryPacket)Pack;
10838 
10839  #region Packet Session and User Check
10840  if (m_checkPackets)
10841  {
10842  if (dirPopularQueryPacket.AgentData.SessionID != SessionId ||
10843  dirPopularQueryPacket.AgentData.AgentID != AgentId)
10844  return true;
10845  }
10846  #endregion
10847 
10848  DirPopularQuery handlerDirPopularQuery = OnDirPopularQuery;
10849  if (handlerDirPopularQuery != null)
10850  {
10851  handlerDirPopularQuery(this,
10852  dirPopularQueryPacket.QueryData.QueryID,
10853  dirPopularQueryPacket.QueryData.QueryFlags);
10854  }
10855  return true;
10856  }
10857 
10858  private bool HandleDirClassifiedQuery(IClientAPI sender, Packet Pack)
10859  {
10860  DirClassifiedQueryPacket dirClassifiedQueryPacket = (DirClassifiedQueryPacket)Pack;
10861 
10862  #region Packet Session and User Check
10863  if (m_checkPackets)
10864  {
10865  if (dirClassifiedQueryPacket.AgentData.SessionID != SessionId ||
10866  dirClassifiedQueryPacket.AgentData.AgentID != AgentId)
10867  return true;
10868  }
10869  #endregion
10870 
10871  DirClassifiedQuery handlerDirClassifiedQuery = OnDirClassifiedQuery;
10872  if (handlerDirClassifiedQuery != null)
10873  {
10874  handlerDirClassifiedQuery(this,
10875  dirClassifiedQueryPacket.QueryData.QueryID,
10876  Utils.BytesToString(
10877  dirClassifiedQueryPacket.QueryData.QueryText),
10878  dirClassifiedQueryPacket.QueryData.QueryFlags,
10879  dirClassifiedQueryPacket.QueryData.Category,
10880  dirClassifiedQueryPacket.QueryData.QueryStart);
10881  }
10882  return true;
10883  }
10884 
10885  private bool HandleEventInfoRequest(IClientAPI sender, Packet Pack)
10886  {
10887  EventInfoRequestPacket eventInfoRequestPacket = (EventInfoRequestPacket)Pack;
10888 
10889  #region Packet Session and User Check
10890  if (m_checkPackets)
10891  {
10892  if (eventInfoRequestPacket.AgentData.SessionID != SessionId ||
10893  eventInfoRequestPacket.AgentData.AgentID != AgentId)
10894  return true;
10895  }
10896  #endregion
10897 
10898  if (OnEventInfoRequest != null)
10899  {
10900  OnEventInfoRequest(this, eventInfoRequestPacket.EventData.EventID);
10901  }
10902  return true;
10903  }
10904 
10905  #endregion
10906 
10907  #region Calling Card
10908 
10909  private bool HandleOfferCallingCard(IClientAPI sender, Packet Pack)
10910  {
10911  OfferCallingCardPacket offerCallingCardPacket = (OfferCallingCardPacket)Pack;
10912 
10913  #region Packet Session and User Check
10914  if (m_checkPackets)
10915  {
10916  if (offerCallingCardPacket.AgentData.SessionID != SessionId ||
10917  offerCallingCardPacket.AgentData.AgentID != AgentId)
10918  return true;
10919  }
10920  #endregion
10921 
10922  if (OnOfferCallingCard != null)
10923  {
10924  OnOfferCallingCard(this,
10925  offerCallingCardPacket.AgentBlock.DestID,
10926  offerCallingCardPacket.AgentBlock.TransactionID);
10927  }
10928  return true;
10929  }
10930 
10931  private bool HandleAcceptCallingCard(IClientAPI sender, Packet Pack)
10932  {
10933  AcceptCallingCardPacket acceptCallingCardPacket = (AcceptCallingCardPacket)Pack;
10934 
10935  #region Packet Session and User Check
10936  if (m_checkPackets)
10937  {
10938  if (acceptCallingCardPacket.AgentData.SessionID != SessionId ||
10939  acceptCallingCardPacket.AgentData.AgentID != AgentId)
10940  return true;
10941  }
10942  #endregion
10943 
10944  // according to http://wiki.secondlife.com/wiki/AcceptCallingCard FolderData should
10945  // contain exactly one entry
10946  if (OnAcceptCallingCard != null && acceptCallingCardPacket.FolderData.Length > 0)
10947  {
10948  OnAcceptCallingCard(this,
10949  acceptCallingCardPacket.TransactionBlock.TransactionID,
10950  acceptCallingCardPacket.FolderData[0].FolderID);
10951  }
10952  return true;
10953  }
10954 
10955  private bool HandleDeclineCallingCard(IClientAPI sender, Packet Pack)
10956  {
10957  DeclineCallingCardPacket declineCallingCardPacket = (DeclineCallingCardPacket)Pack;
10958 
10959  #region Packet Session and User Check
10960  if (m_checkPackets)
10961  {
10962  if (declineCallingCardPacket.AgentData.SessionID != SessionId ||
10963  declineCallingCardPacket.AgentData.AgentID != AgentId)
10964  return true;
10965  }
10966  #endregion
10967 
10968  if (OnDeclineCallingCard != null)
10969  {
10970  OnDeclineCallingCard(this,
10971  declineCallingCardPacket.TransactionBlock.TransactionID);
10972  }
10973  return true;
10974  }
10975 
10976  #endregion Calling Card
10977 
10978  #region Groups
10979 
10980  private bool HandleActivateGroup(IClientAPI sender, Packet Pack)
10981  {
10982  ActivateGroupPacket activateGroupPacket = (ActivateGroupPacket)Pack;
10983 
10984  #region Packet Session and User Check
10985  if (m_checkPackets)
10986  {
10987  if (activateGroupPacket.AgentData.SessionID != SessionId ||
10988  activateGroupPacket.AgentData.AgentID != AgentId)
10989  return true;
10990  }
10991  #endregion
10992 
10993  if (m_GroupsModule != null)
10994  {
10995  m_GroupsModule.ActivateGroup(this, activateGroupPacket.AgentData.GroupID);
10996  m_GroupsModule.SendAgentGroupDataUpdate(this);
10997  }
10998  return true;
10999 
11000  }
11001 
11002  private bool HandleGroupVoteHistoryRequest(IClientAPI client, Packet Packet)
11003  {
11004  GroupVoteHistoryRequestPacket GroupVoteHistoryRequest =
11005  (GroupVoteHistoryRequestPacket)Packet;
11006  GroupVoteHistoryRequest handlerGroupVoteHistoryRequest = OnGroupVoteHistoryRequest;
11007  if (handlerGroupVoteHistoryRequest != null)
11008  {
11009  handlerGroupVoteHistoryRequest(this, GroupVoteHistoryRequest.AgentData.AgentID,GroupVoteHistoryRequest.AgentData.SessionID,GroupVoteHistoryRequest.GroupData.GroupID,GroupVoteHistoryRequest.TransactionData.TransactionID);
11010  return true;
11011  }
11012  return false;
11013  }
11014 
11015  private bool HandleGroupActiveProposalsRequest(IClientAPI client, Packet Packet)
11016  {
11017  GroupActiveProposalsRequestPacket GroupActiveProposalsRequest =
11018  (GroupActiveProposalsRequestPacket)Packet;
11019  GroupActiveProposalsRequest handlerGroupActiveProposalsRequest = OnGroupActiveProposalsRequest;
11020  if (handlerGroupActiveProposalsRequest != null)
11021  {
11022  handlerGroupActiveProposalsRequest(this, GroupActiveProposalsRequest.AgentData.AgentID,GroupActiveProposalsRequest.AgentData.SessionID,GroupActiveProposalsRequest.GroupData.GroupID,GroupActiveProposalsRequest.TransactionData.TransactionID);
11023  return true;
11024  }
11025  return false;
11026  }
11027 
11028  private bool HandleGroupAccountDetailsRequest(IClientAPI client, Packet Packet)
11029  {
11030  GroupAccountDetailsRequestPacket GroupAccountDetailsRequest =
11031  (GroupAccountDetailsRequestPacket)Packet;
11032  GroupAccountDetailsRequest handlerGroupAccountDetailsRequest = OnGroupAccountDetailsRequest;
11033  if (handlerGroupAccountDetailsRequest != null)
11034  {
11035  handlerGroupAccountDetailsRequest(this, GroupAccountDetailsRequest.AgentData.AgentID,GroupAccountDetailsRequest.AgentData.GroupID,GroupAccountDetailsRequest.MoneyData.RequestID,GroupAccountDetailsRequest.AgentData.SessionID);
11036  return true;
11037  }
11038  return false;
11039  }
11040 
11041  private bool HandleGroupAccountSummaryRequest(IClientAPI client, Packet Packet)
11042  {
11043  GroupAccountSummaryRequestPacket GroupAccountSummaryRequest =
11044  (GroupAccountSummaryRequestPacket)Packet;
11045  GroupAccountSummaryRequest handlerGroupAccountSummaryRequest = OnGroupAccountSummaryRequest;
11046  if (handlerGroupAccountSummaryRequest != null)
11047  {
11048  handlerGroupAccountSummaryRequest(this, GroupAccountSummaryRequest.AgentData.AgentID,GroupAccountSummaryRequest.AgentData.GroupID);
11049  return true;
11050  }
11051  return false;
11052  }
11053 
11054  private bool HandleGroupTransactionsDetailsRequest(IClientAPI client, Packet Packet)
11055  {
11056  GroupAccountTransactionsRequestPacket GroupAccountTransactionsRequest =
11057  (GroupAccountTransactionsRequestPacket)Packet;
11058  GroupAccountTransactionsRequest handlerGroupAccountTransactionsRequest = OnGroupAccountTransactionsRequest;
11059  if (handlerGroupAccountTransactionsRequest != null)
11060  {
11061  handlerGroupAccountTransactionsRequest(this, GroupAccountTransactionsRequest.AgentData.AgentID,GroupAccountTransactionsRequest.AgentData.GroupID,GroupAccountTransactionsRequest.MoneyData.RequestID,GroupAccountTransactionsRequest.AgentData.SessionID);
11062  return true;
11063  }
11064  return false;
11065  }
11066 
11067  private bool HandleGroupTitlesRequest(IClientAPI sender, Packet Pack)
11068  {
11069  GroupTitlesRequestPacket groupTitlesRequest =
11070  (GroupTitlesRequestPacket)Pack;
11071 
11072  #region Packet Session and User Check
11073  if (m_checkPackets)
11074  {
11075  if (groupTitlesRequest.AgentData.SessionID != SessionId ||
11076  groupTitlesRequest.AgentData.AgentID != AgentId)
11077  return true;
11078  }
11079  #endregion
11080 
11081  if (m_GroupsModule != null)
11082  {
11083  GroupTitlesReplyPacket groupTitlesReply = (GroupTitlesReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupTitlesReply);
11084 
11085  groupTitlesReply.AgentData =
11086  new GroupTitlesReplyPacket.AgentDataBlock();
11087 
11088  groupTitlesReply.AgentData.AgentID = AgentId;
11089  groupTitlesReply.AgentData.GroupID =
11090  groupTitlesRequest.AgentData.GroupID;
11091 
11092  groupTitlesReply.AgentData.RequestID =
11093  groupTitlesRequest.AgentData.RequestID;
11094 
11095  List<GroupTitlesData> titles =
11096  m_GroupsModule.GroupTitlesRequest(this,
11097  groupTitlesRequest.AgentData.GroupID);
11098 
11099  groupTitlesReply.GroupData =
11100  new GroupTitlesReplyPacket.GroupDataBlock[titles.Count];
11101 
11102  int i = 0;
11103  foreach (GroupTitlesData d in titles)
11104  {
11105  groupTitlesReply.GroupData[i] =
11106  new GroupTitlesReplyPacket.GroupDataBlock();
11107 
11108  groupTitlesReply.GroupData[i].Title =
11109  Util.StringToBytes256(d.Name);
11110  groupTitlesReply.GroupData[i].RoleID =
11111  d.UUID;
11112  groupTitlesReply.GroupData[i].Selected =
11113  d.Selected;
11114  i++;
11115  }
11116 
11117  OutPacket(groupTitlesReply, ThrottleOutPacketType.Task);
11118  }
11119  return true;
11120  }
11121  private bool HandleGroupProfileRequest(IClientAPI sender, Packet Pack)
11122  {
11123  GroupProfileRequestPacket groupProfileRequest =
11124  (GroupProfileRequestPacket)Pack;
11125 
11126  #region Packet Session and User Check
11127  if (m_checkPackets)
11128  {
11129  if (groupProfileRequest.AgentData.SessionID != SessionId ||
11130  groupProfileRequest.AgentData.AgentID != AgentId)
11131  return true;
11132  }
11133  #endregion
11134 
11135  if (m_GroupsModule != null)
11136  {
11137  GroupProfileReplyPacket groupProfileReply = (GroupProfileReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupProfileReply);
11138 
11139  groupProfileReply.AgentData = new GroupProfileReplyPacket.AgentDataBlock();
11140  groupProfileReply.GroupData = new GroupProfileReplyPacket.GroupDataBlock();
11141  groupProfileReply.AgentData.AgentID = AgentId;
11142 
11143  GroupProfileData d = m_GroupsModule.GroupProfileRequest(this,
11144  groupProfileRequest.GroupData.GroupID);
11145 
11146  groupProfileReply.GroupData.GroupID = d.GroupID;
11147  groupProfileReply.GroupData.Name = Util.StringToBytes256(d.Name);
11148  groupProfileReply.GroupData.Charter = Util.StringToBytes1024(d.Charter);
11149  groupProfileReply.GroupData.ShowInList = d.ShowInList;
11150  groupProfileReply.GroupData.MemberTitle = Util.StringToBytes256(d.MemberTitle);
11151  groupProfileReply.GroupData.PowersMask = d.PowersMask;
11152  groupProfileReply.GroupData.InsigniaID = d.InsigniaID;
11153  groupProfileReply.GroupData.FounderID = d.FounderID;
11154  groupProfileReply.GroupData.MembershipFee = d.MembershipFee;
11155  groupProfileReply.GroupData.OpenEnrollment = d.OpenEnrollment;
11156  groupProfileReply.GroupData.Money = d.Money;
11157  groupProfileReply.GroupData.GroupMembershipCount = d.GroupMembershipCount;
11158  groupProfileReply.GroupData.GroupRolesCount = d.GroupRolesCount;
11159  groupProfileReply.GroupData.AllowPublish = d.AllowPublish;
11160  groupProfileReply.GroupData.MaturePublish = d.MaturePublish;
11161  groupProfileReply.GroupData.OwnerRole = d.OwnerRole;
11162 
11163  Scene scene = (Scene)m_scene;
11164  if (scene.Permissions.IsGod(sender.AgentId) && (!sender.IsGroupMember(groupProfileRequest.GroupData.GroupID)))
11165  {
11166  ScenePresence p;
11167  if (scene.TryGetScenePresence(sender.AgentId, out p))
11168  {
11169  if (p.GodLevel >= 200)
11170  {
11171  groupProfileReply.GroupData.OpenEnrollment = true;
11172  groupProfileReply.GroupData.MembershipFee = 0;
11173  }
11174  }
11175  }
11176 
11177  OutPacket(groupProfileReply, ThrottleOutPacketType.Task);
11178  }
11179  return true;
11180  }
11181  private bool HandleGroupMembersRequest(IClientAPI sender, Packet Pack)
11182  {
11183  GroupMembersRequestPacket groupMembersRequestPacket =
11184  (GroupMembersRequestPacket)Pack;
11185 
11186  #region Packet Session and User Check
11187  if (m_checkPackets)
11188  {
11189  if (groupMembersRequestPacket.AgentData.SessionID != SessionId ||
11190  groupMembersRequestPacket.AgentData.AgentID != AgentId)
11191  return true;
11192  }
11193  #endregion
11194 
11195  if (m_GroupsModule != null)
11196  {
11197  List<GroupMembersData> members =
11198  m_GroupsModule.GroupMembersRequest(this, groupMembersRequestPacket.GroupData.GroupID);
11199 
11200  int memberCount = members.Count;
11201 
11202  while (true)
11203  {
11204  int blockCount = members.Count;
11205  if (blockCount > 40)
11206  blockCount = 40;
11207 
11208  GroupMembersReplyPacket groupMembersReply = (GroupMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupMembersReply);
11209 
11210  groupMembersReply.AgentData =
11211  new GroupMembersReplyPacket.AgentDataBlock();
11212  groupMembersReply.GroupData =
11213  new GroupMembersReplyPacket.GroupDataBlock();
11214  groupMembersReply.MemberData =
11215  new GroupMembersReplyPacket.MemberDataBlock[
11216  blockCount];
11217 
11218  groupMembersReply.AgentData.AgentID = AgentId;
11219  groupMembersReply.GroupData.GroupID =
11220  groupMembersRequestPacket.GroupData.GroupID;
11221  groupMembersReply.GroupData.RequestID =
11222  groupMembersRequestPacket.GroupData.RequestID;
11223  groupMembersReply.GroupData.MemberCount = memberCount;
11224 
11225  for (int i = 0; i < blockCount; i++)
11226  {
11227  GroupMembersData m = members[0];
11228  members.RemoveAt(0);
11229 
11230  groupMembersReply.MemberData[i] =
11231  new GroupMembersReplyPacket.MemberDataBlock();
11232  groupMembersReply.MemberData[i].AgentID =
11233  m.AgentID;
11234  groupMembersReply.MemberData[i].Contribution =
11235  m.Contribution;
11236  groupMembersReply.MemberData[i].OnlineStatus =
11237  Util.StringToBytes256(m.OnlineStatus);
11238  groupMembersReply.MemberData[i].AgentPowers =
11239  m.AgentPowers;
11240  groupMembersReply.MemberData[i].Title =
11241  Util.StringToBytes256(m.Title);
11242  groupMembersReply.MemberData[i].IsOwner =
11243  m.IsOwner;
11244  }
11245  OutPacket(groupMembersReply, ThrottleOutPacketType.Task);
11246  if (members.Count == 0)
11247  return true;
11248  }
11249  }
11250  return true;
11251  }
11252  private bool HandleGroupRoleDataRequest(IClientAPI sender, Packet Pack)
11253  {
11254  GroupRoleDataRequestPacket groupRolesRequest =
11255  (GroupRoleDataRequestPacket)Pack;
11256 
11257  #region Packet Session and User Check
11258  if (m_checkPackets)
11259  {
11260  if (groupRolesRequest.AgentData.SessionID != SessionId ||
11261  groupRolesRequest.AgentData.AgentID != AgentId)
11262  return true;
11263  }
11264  #endregion
11265 
11266  if (m_GroupsModule != null)
11267  {
11268  GroupRoleDataReplyPacket groupRolesReply = (GroupRoleDataReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleDataReply);
11269 
11270  groupRolesReply.AgentData =
11271  new GroupRoleDataReplyPacket.AgentDataBlock();
11272 
11273  groupRolesReply.AgentData.AgentID = AgentId;
11274 
11275  groupRolesReply.GroupData =
11276  new GroupRoleDataReplyPacket.GroupDataBlock();
11277 
11278  groupRolesReply.GroupData.GroupID =
11279  groupRolesRequest.GroupData.GroupID;
11280 
11281  groupRolesReply.GroupData.RequestID =
11282  groupRolesRequest.GroupData.RequestID;
11283 
11284  List<GroupRolesData> titles =
11285  m_GroupsModule.GroupRoleDataRequest(this,
11286  groupRolesRequest.GroupData.GroupID);
11287 
11288  groupRolesReply.GroupData.RoleCount =
11289  titles.Count;
11290 
11291  groupRolesReply.RoleData =
11292  new GroupRoleDataReplyPacket.RoleDataBlock[titles.Count];
11293 
11294  int i = 0;
11295  foreach (GroupRolesData d in titles)
11296  {
11297  groupRolesReply.RoleData[i] =
11298  new GroupRoleDataReplyPacket.RoleDataBlock();
11299 
11300  groupRolesReply.RoleData[i].RoleID =
11301  d.RoleID;
11302  groupRolesReply.RoleData[i].Name =
11303  Util.StringToBytes256(d.Name);
11304  groupRolesReply.RoleData[i].Title =
11305  Util.StringToBytes256(d.Title);
11306  groupRolesReply.RoleData[i].Description =
11307  Util.StringToBytes1024(d.Description);
11308  groupRolesReply.RoleData[i].Powers =
11309  d.Powers;
11310  groupRolesReply.RoleData[i].Members =
11311  (uint)d.Members;
11312 
11313  i++;
11314  }
11315 
11316  OutPacket(groupRolesReply, ThrottleOutPacketType.Task);
11317  }
11318  return true;
11319  }
11320 
11321  private bool HandleGroupRoleMembersRequest(IClientAPI sender, Packet Pack)
11322  {
11323  GroupRoleMembersRequestPacket groupRoleMembersRequest =
11324  (GroupRoleMembersRequestPacket)Pack;
11325 
11326  #region Packet Session and User Check
11327  if (m_checkPackets)
11328  {
11329  if (groupRoleMembersRequest.AgentData.SessionID != SessionId ||
11330  groupRoleMembersRequest.AgentData.AgentID != AgentId)
11331  return true;
11332  }
11333  #endregion
11334 
11335  if (m_GroupsModule != null)
11336  {
11337  List<GroupRoleMembersData> mappings =
11338  m_GroupsModule.GroupRoleMembersRequest(this,
11339  groupRoleMembersRequest.GroupData.GroupID);
11340 
11341  int mappingsCount = mappings.Count;
11342 
11343  while (mappings.Count > 0)
11344  {
11345  int pairs = mappings.Count;
11346  if (pairs > 32)
11347  pairs = 32;
11348 
11349  GroupRoleMembersReplyPacket groupRoleMembersReply = (GroupRoleMembersReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupRoleMembersReply);
11350  groupRoleMembersReply.AgentData =
11351  new GroupRoleMembersReplyPacket.AgentDataBlock();
11352  groupRoleMembersReply.AgentData.AgentID =
11353  AgentId;
11354  groupRoleMembersReply.AgentData.GroupID =
11355  groupRoleMembersRequest.GroupData.GroupID;
11356  groupRoleMembersReply.AgentData.RequestID =
11357  groupRoleMembersRequest.GroupData.RequestID;
11358 
11359  groupRoleMembersReply.AgentData.TotalPairs =
11360  (uint)mappingsCount;
11361 
11362  groupRoleMembersReply.MemberData =
11363  new GroupRoleMembersReplyPacket.MemberDataBlock[pairs];
11364 
11365  for (int i = 0; i < pairs; i++)
11366  {
11367  GroupRoleMembersData d = mappings[0];
11368  mappings.RemoveAt(0);
11369 
11370  groupRoleMembersReply.MemberData[i] =
11371  new GroupRoleMembersReplyPacket.MemberDataBlock();
11372 
11373  groupRoleMembersReply.MemberData[i].RoleID =
11374  d.RoleID;
11375  groupRoleMembersReply.MemberData[i].MemberID =
11376  d.MemberID;
11377  }
11378 
11379  OutPacket(groupRoleMembersReply, ThrottleOutPacketType.Task);
11380  }
11381  }
11382  return true;
11383  }
11384  private bool HandleCreateGroupRequest(IClientAPI sender, Packet Pack)
11385  {
11386  CreateGroupRequestPacket createGroupRequest =
11387  (CreateGroupRequestPacket)Pack;
11388 
11389  #region Packet Session and User Check
11390  if (m_checkPackets)
11391  {
11392  if (createGroupRequest.AgentData.SessionID != SessionId ||
11393  createGroupRequest.AgentData.AgentID != AgentId)
11394  return true;
11395  }
11396  #endregion
11397 
11398  if (m_GroupsModule != null)
11399  {
11400  m_GroupsModule.CreateGroup(this,
11401  Utils.BytesToString(createGroupRequest.GroupData.Name),
11402  Utils.BytesToString(createGroupRequest.GroupData.Charter),
11403  createGroupRequest.GroupData.ShowInList,
11404  createGroupRequest.GroupData.InsigniaID,
11405  createGroupRequest.GroupData.MembershipFee,
11406  createGroupRequest.GroupData.OpenEnrollment,
11407  createGroupRequest.GroupData.AllowPublish,
11408  createGroupRequest.GroupData.MaturePublish);
11409  }
11410  return true;
11411  }
11412  private bool HandleUpdateGroupInfo(IClientAPI sender, Packet Pack)
11413  {
11414  UpdateGroupInfoPacket updateGroupInfo =
11415  (UpdateGroupInfoPacket)Pack;
11416 
11417  #region Packet Session and User Check
11418  if (m_checkPackets)
11419  {
11420  if (updateGroupInfo.AgentData.SessionID != SessionId ||
11421  updateGroupInfo.AgentData.AgentID != AgentId)
11422  return true;
11423  }
11424  #endregion
11425 
11426  if (m_GroupsModule != null)
11427  {
11428  m_GroupsModule.UpdateGroupInfo(this,
11429  updateGroupInfo.GroupData.GroupID,
11430  Utils.BytesToString(updateGroupInfo.GroupData.Charter),
11431  updateGroupInfo.GroupData.ShowInList,
11432  updateGroupInfo.GroupData.InsigniaID,
11433  updateGroupInfo.GroupData.MembershipFee,
11434  updateGroupInfo.GroupData.OpenEnrollment,
11435  updateGroupInfo.GroupData.AllowPublish,
11436  updateGroupInfo.GroupData.MaturePublish);
11437  }
11438 
11439  return true;
11440  }
11441  private bool HandleSetGroupAcceptNotices(IClientAPI sender, Packet Pack)
11442  {
11443  SetGroupAcceptNoticesPacket setGroupAcceptNotices =
11444  (SetGroupAcceptNoticesPacket)Pack;
11445 
11446  #region Packet Session and User Check
11447  if (m_checkPackets)
11448  {
11449  if (setGroupAcceptNotices.AgentData.SessionID != SessionId ||
11450  setGroupAcceptNotices.AgentData.AgentID != AgentId)
11451  return true;
11452  }
11453  #endregion
11454 
11455  if (m_GroupsModule != null)
11456  {
11457  m_GroupsModule.SetGroupAcceptNotices(this,
11458  setGroupAcceptNotices.Data.GroupID,
11459  setGroupAcceptNotices.Data.AcceptNotices,
11460  setGroupAcceptNotices.NewData.ListInProfile);
11461  }
11462 
11463  return true;
11464  }
11465  private bool HandleGroupTitleUpdate(IClientAPI sender, Packet Pack)
11466  {
11467  GroupTitleUpdatePacket groupTitleUpdate =
11468  (GroupTitleUpdatePacket)Pack;
11469 
11470  #region Packet Session and User Check
11471  if (m_checkPackets)
11472  {
11473  if (groupTitleUpdate.AgentData.SessionID != SessionId ||
11474  groupTitleUpdate.AgentData.AgentID != AgentId)
11475  return true;
11476  }
11477  #endregion
11478 
11479  if (m_GroupsModule != null)
11480  {
11481  m_GroupsModule.GroupTitleUpdate(this,
11482  groupTitleUpdate.AgentData.GroupID,
11483  groupTitleUpdate.AgentData.TitleRoleID);
11484  }
11485 
11486  return true;
11487  }
11488  private bool HandleParcelDeedToGroup(IClientAPI sender, Packet Pack)
11489  {
11490  ParcelDeedToGroupPacket parcelDeedToGroup = (ParcelDeedToGroupPacket)Pack;
11491  if (m_GroupsModule != null)
11492  {
11493  ParcelDeedToGroup handlerParcelDeedToGroup = OnParcelDeedToGroup;
11494  if (handlerParcelDeedToGroup != null)
11495  {
11496  handlerParcelDeedToGroup(parcelDeedToGroup.Data.LocalID, parcelDeedToGroup.Data.GroupID, this);
11497 
11498  }
11499  }
11500 
11501  return true;
11502  }
11503  private bool HandleGroupNoticesListRequest(IClientAPI sender, Packet Pack)
11504  {
11505  GroupNoticesListRequestPacket groupNoticesListRequest =
11506  (GroupNoticesListRequestPacket)Pack;
11507 
11508  #region Packet Session and User Check
11509  if (m_checkPackets)
11510  {
11511  if (groupNoticesListRequest.AgentData.SessionID != SessionId ||
11512  groupNoticesListRequest.AgentData.AgentID != AgentId)
11513  return true;
11514  }
11515  #endregion
11516 
11517  if (m_GroupsModule != null)
11518  {
11519  GroupNoticeData[] gn =
11520  m_GroupsModule.GroupNoticesListRequest(this,
11521  groupNoticesListRequest.Data.GroupID);
11522 
11523  GroupNoticesListReplyPacket groupNoticesListReply = (GroupNoticesListReplyPacket)PacketPool.Instance.GetPacket(PacketType.GroupNoticesListReply);
11524  groupNoticesListReply.AgentData =
11525  new GroupNoticesListReplyPacket.AgentDataBlock();
11526  groupNoticesListReply.AgentData.AgentID = AgentId;
11527  groupNoticesListReply.AgentData.GroupID = groupNoticesListRequest.Data.GroupID;
11528 
11529  groupNoticesListReply.Data = new GroupNoticesListReplyPacket.DataBlock[gn.Length];
11530 
11531  int i = 0;
11532  foreach (GroupNoticeData g in gn)
11533  {
11534  groupNoticesListReply.Data[i] = new GroupNoticesListReplyPacket.DataBlock();
11535  groupNoticesListReply.Data[i].NoticeID =
11536  g.NoticeID;
11537  groupNoticesListReply.Data[i].Timestamp =
11538  g.Timestamp;
11539  groupNoticesListReply.Data[i].FromName =
11540  Util.StringToBytes256(g.FromName);
11541  groupNoticesListReply.Data[i].Subject =
11542  Util.StringToBytes256(g.Subject);
11543  groupNoticesListReply.Data[i].HasAttachment =
11544  g.HasAttachment;
11545  groupNoticesListReply.Data[i].AssetType =
11546  g.AssetType;
11547  i++;
11548  }
11549 
11550  OutPacket(groupNoticesListReply, ThrottleOutPacketType.Task);
11551  }
11552 
11553  return true;
11554  }
11555  private bool HandleGroupNoticeRequest(IClientAPI sender, Packet Pack)
11556  {
11557  GroupNoticeRequestPacket groupNoticeRequest =
11558  (GroupNoticeRequestPacket)Pack;
11559 
11560  #region Packet Session and User Check
11561  if (m_checkPackets)
11562  {
11563  if (groupNoticeRequest.AgentData.SessionID != SessionId ||
11564  groupNoticeRequest.AgentData.AgentID != AgentId)
11565  return true;
11566  }
11567  #endregion
11568 
11569  if (m_GroupsModule != null)
11570  {
11571  m_GroupsModule.GroupNoticeRequest(this,
11572  groupNoticeRequest.Data.GroupNoticeID);
11573  }
11574  return true;
11575  }
11576  private bool HandleGroupRoleUpdate(IClientAPI sender, Packet Pack)
11577  {
11578  GroupRoleUpdatePacket groupRoleUpdate =
11579  (GroupRoleUpdatePacket)Pack;
11580 
11581  #region Packet Session and User Check
11582  if (m_checkPackets)
11583  {
11584  if (groupRoleUpdate.AgentData.SessionID != SessionId ||
11585  groupRoleUpdate.AgentData.AgentID != AgentId)
11586  return true;
11587  }
11588  #endregion
11589 
11590  if (m_GroupsModule != null)
11591  {
11592  foreach (GroupRoleUpdatePacket.RoleDataBlock d in
11593  groupRoleUpdate.RoleData)
11594  {
11595  m_GroupsModule.GroupRoleUpdate(this,
11596  groupRoleUpdate.AgentData.GroupID,
11597  d.RoleID,
11598  Utils.BytesToString(d.Name),
11599  Utils.BytesToString(d.Description),
11600  Utils.BytesToString(d.Title),
11601  d.Powers,
11602  d.UpdateType);
11603  }
11604  m_GroupsModule.NotifyChange(groupRoleUpdate.AgentData.GroupID);
11605  }
11606  return true;
11607  }
11608  private bool HandleGroupRoleChanges(IClientAPI sender, Packet Pack)
11609  {
11610  GroupRoleChangesPacket groupRoleChanges =
11611  (GroupRoleChangesPacket)Pack;
11612 
11613  #region Packet Session and User Check
11614  if (m_checkPackets)
11615  {
11616  if (groupRoleChanges.AgentData.SessionID != SessionId ||
11617  groupRoleChanges.AgentData.AgentID != AgentId)
11618  return true;
11619  }
11620  #endregion
11621 
11622  if (m_GroupsModule != null)
11623  {
11624  foreach (GroupRoleChangesPacket.RoleChangeBlock d in
11625  groupRoleChanges.RoleChange)
11626  {
11627  m_GroupsModule.GroupRoleChanges(this,
11628  groupRoleChanges.AgentData.GroupID,
11629  d.RoleID,
11630  d.MemberID,
11631  d.Change);
11632  }
11633  m_GroupsModule.NotifyChange(groupRoleChanges.AgentData.GroupID);
11634  }
11635  return true;
11636  }
11637  private bool HandleJoinGroupRequest(IClientAPI sender, Packet Pack)
11638  {
11639  JoinGroupRequestPacket joinGroupRequest =
11640  (JoinGroupRequestPacket)Pack;
11641 
11642  #region Packet Session and User Check
11643  if (m_checkPackets)
11644  {
11645  if (joinGroupRequest.AgentData.SessionID != SessionId ||
11646  joinGroupRequest.AgentData.AgentID != AgentId)
11647  return true;
11648  }
11649  #endregion
11650 
11651  if (m_GroupsModule != null)
11652  {
11653  m_GroupsModule.JoinGroupRequest(this,
11654  joinGroupRequest.GroupData.GroupID);
11655  }
11656  return true;
11657  }
11658  private bool HandleLeaveGroupRequest(IClientAPI sender, Packet Pack)
11659  {
11660  LeaveGroupRequestPacket leaveGroupRequest =
11661  (LeaveGroupRequestPacket)Pack;
11662 
11663  #region Packet Session and User Check
11664  if (m_checkPackets)
11665  {
11666  if (leaveGroupRequest.AgentData.SessionID != SessionId ||
11667  leaveGroupRequest.AgentData.AgentID != AgentId)
11668  return true;
11669  }
11670  #endregion
11671 
11672  if (m_GroupsModule != null)
11673  {
11674  m_GroupsModule.LeaveGroupRequest(this,
11675  leaveGroupRequest.GroupData.GroupID);
11676  }
11677  return true;
11678  }
11679  private bool HandleEjectGroupMemberRequest(IClientAPI sender, Packet Pack)
11680  {
11681  EjectGroupMemberRequestPacket ejectGroupMemberRequest =
11682  (EjectGroupMemberRequestPacket)Pack;
11683 
11684  #region Packet Session and User Check
11685  if (m_checkPackets)
11686  {
11687  if (ejectGroupMemberRequest.AgentData.SessionID != SessionId ||
11688  ejectGroupMemberRequest.AgentData.AgentID != AgentId)
11689  return true;
11690  }
11691  #endregion
11692 
11693  if (m_GroupsModule != null)
11694  {
11695  foreach (EjectGroupMemberRequestPacket.EjectDataBlock e
11696  in ejectGroupMemberRequest.EjectData)
11697  {
11698  m_GroupsModule.EjectGroupMemberRequest(this,
11699  ejectGroupMemberRequest.GroupData.GroupID,
11700  e.EjecteeID);
11701  }
11702  }
11703  return true;
11704  }
11705  private bool HandleInviteGroupRequest(IClientAPI sender, Packet Pack)
11706  {
11707  InviteGroupRequestPacket inviteGroupRequest =
11708  (InviteGroupRequestPacket)Pack;
11709 
11710  #region Packet Session and User Check
11711  if (m_checkPackets)
11712  {
11713  if (inviteGroupRequest.AgentData.SessionID != SessionId ||
11714  inviteGroupRequest.AgentData.AgentID != AgentId)
11715  return true;
11716  }
11717  #endregion
11718 
11719  if (m_GroupsModule != null)
11720  {
11721  foreach (InviteGroupRequestPacket.InviteDataBlock b in
11722  inviteGroupRequest.InviteData)
11723  {
11724  m_GroupsModule.InviteGroupRequest(this,
11725  inviteGroupRequest.GroupData.GroupID,
11726  b.InviteeID,
11727  b.RoleID);
11728  }
11729  }
11730  return true;
11731  }
11732 
11733  #endregion Groups
11734 
11735  private bool HandleStartLure(IClientAPI sender, Packet Pack)
11736  {
11737  StartLurePacket startLureRequest = (StartLurePacket)Pack;
11738 
11739  #region Packet Session and User Check
11740  if (m_checkPackets)
11741  {
11742  if (startLureRequest.AgentData.SessionID != SessionId ||
11743  startLureRequest.AgentData.AgentID != AgentId)
11744  return true;
11745  }
11746  #endregion
11747 
11748  StartLure handlerStartLure = OnStartLure;
11749  if (handlerStartLure != null)
11750  {
11751  for (int i = 0 ; i < startLureRequest.TargetData.Length ; i++)
11752  {
11753  handlerStartLure(startLureRequest.Info.LureType,
11754  Utils.BytesToString(
11755  startLureRequest.Info.Message),
11756  startLureRequest.TargetData[i].TargetID,
11757  this);
11758  }
11759  }
11760  return true;
11761  }
11762  private bool HandleTeleportLureRequest(IClientAPI sender, Packet Pack)
11763  {
11764  TeleportLureRequestPacket teleportLureRequest =
11765  (TeleportLureRequestPacket)Pack;
11766 
11767  #region Packet Session and User Check
11768  if (m_checkPackets)
11769  {
11770  if (teleportLureRequest.Info.SessionID != SessionId ||
11771  teleportLureRequest.Info.AgentID != AgentId)
11772  return true;
11773  }
11774  #endregion
11775 
11776  TeleportLureRequest handlerTeleportLureRequest = OnTeleportLureRequest;
11777  if (handlerTeleportLureRequest != null)
11778  handlerTeleportLureRequest(
11779  teleportLureRequest.Info.LureID,
11780  teleportLureRequest.Info.TeleportFlags,
11781  this);
11782  return true;
11783  }
11784  private bool HandleClassifiedInfoRequest(IClientAPI sender, Packet Pack)
11785  {
11786  ClassifiedInfoRequestPacket classifiedInfoRequest =
11787  (ClassifiedInfoRequestPacket)Pack;
11788 
11789  #region Packet Session and User Check
11790  if (m_checkPackets)
11791  {
11792  if (classifiedInfoRequest.AgentData.SessionID != SessionId ||
11793  classifiedInfoRequest.AgentData.AgentID != AgentId)
11794  return true;
11795  }
11796  #endregion
11797 
11798  ClassifiedInfoRequest handlerClassifiedInfoRequest = OnClassifiedInfoRequest;
11799  if (handlerClassifiedInfoRequest != null)
11800  handlerClassifiedInfoRequest(
11801  classifiedInfoRequest.Data.ClassifiedID,
11802  this);
11803  return true;
11804  }
11805  private bool HandleClassifiedInfoUpdate(IClientAPI sender, Packet Pack)
11806  {
11807  ClassifiedInfoUpdatePacket classifiedInfoUpdate =
11808  (ClassifiedInfoUpdatePacket)Pack;
11809 
11810  #region Packet Session and User Check
11811  if (m_checkPackets)
11812  {
11813  if (classifiedInfoUpdate.AgentData.SessionID != SessionId ||
11814  classifiedInfoUpdate.AgentData.AgentID != AgentId)
11815  return true;
11816  }
11817  #endregion
11818 
11819  ClassifiedInfoUpdate handlerClassifiedInfoUpdate = OnClassifiedInfoUpdate;
11820  if (handlerClassifiedInfoUpdate != null)
11821  handlerClassifiedInfoUpdate(
11822  classifiedInfoUpdate.Data.ClassifiedID,
11823  classifiedInfoUpdate.Data.Category,
11824  Utils.BytesToString(
11825  classifiedInfoUpdate.Data.Name),
11826  Utils.BytesToString(
11827  classifiedInfoUpdate.Data.Desc),
11828  classifiedInfoUpdate.Data.ParcelID,
11829  classifiedInfoUpdate.Data.ParentEstate,
11830  classifiedInfoUpdate.Data.SnapshotID,
11831  new Vector3(
11832  classifiedInfoUpdate.Data.PosGlobal),
11833  classifiedInfoUpdate.Data.ClassifiedFlags,
11834  classifiedInfoUpdate.Data.PriceForListing,
11835  this);
11836  return true;
11837  }
11838  private bool HandleClassifiedDelete(IClientAPI sender, Packet Pack)
11839  {
11840  ClassifiedDeletePacket classifiedDelete =
11841  (ClassifiedDeletePacket)Pack;
11842 
11843  #region Packet Session and User Check
11844  if (m_checkPackets)
11845  {
11846  if (classifiedDelete.AgentData.SessionID != SessionId ||
11847  classifiedDelete.AgentData.AgentID != AgentId)
11848  return true;
11849  }
11850  #endregion
11851 
11852  ClassifiedDelete handlerClassifiedDelete = OnClassifiedDelete;
11853  if (handlerClassifiedDelete != null)
11854  handlerClassifiedDelete(
11855  classifiedDelete.Data.ClassifiedID,
11856  this);
11857  return true;
11858  }
11859  private bool HandleClassifiedGodDelete(IClientAPI sender, Packet Pack)
11860  {
11861  ClassifiedGodDeletePacket classifiedGodDelete =
11862  (ClassifiedGodDeletePacket)Pack;
11863 
11864  #region Packet Session and User Check
11865  if (m_checkPackets)
11866  {
11867  if (classifiedGodDelete.AgentData.SessionID != SessionId ||
11868  classifiedGodDelete.AgentData.AgentID != AgentId)
11869  return true;
11870  }
11871  #endregion
11872 
11873  ClassifiedGodDelete handlerClassifiedGodDelete = OnClassifiedGodDelete;
11874  if (handlerClassifiedGodDelete != null)
11875  handlerClassifiedGodDelete(
11876  classifiedGodDelete.Data.ClassifiedID,
11877  classifiedGodDelete.Data.QueryID,
11878  this);
11879  return true;
11880  }
11881  private bool HandleEventGodDelete(IClientAPI sender, Packet Pack)
11882  {
11883  EventGodDeletePacket eventGodDelete =
11884  (EventGodDeletePacket)Pack;
11885 
11886  #region Packet Session and User Check
11887  if (m_checkPackets)
11888  {
11889  if (eventGodDelete.AgentData.SessionID != SessionId ||
11890  eventGodDelete.AgentData.AgentID != AgentId)
11891  return true;
11892  }
11893  #endregion
11894 
11895  EventGodDelete handlerEventGodDelete = OnEventGodDelete;
11896  if (handlerEventGodDelete != null)
11897  handlerEventGodDelete(
11898  eventGodDelete.EventData.EventID,
11899  eventGodDelete.QueryData.QueryID,
11900  Utils.BytesToString(
11901  eventGodDelete.QueryData.QueryText),
11902  eventGodDelete.QueryData.QueryFlags,
11903  eventGodDelete.QueryData.QueryStart,
11904  this);
11905  return true;
11906  }
11907  private bool HandleEventNotificationAddRequest(IClientAPI sender, Packet Pack)
11908  {
11909  EventNotificationAddRequestPacket eventNotificationAdd =
11910  (EventNotificationAddRequestPacket)Pack;
11911 
11912  #region Packet Session and User Check
11913  if (m_checkPackets)
11914  {
11915  if (eventNotificationAdd.AgentData.SessionID != SessionId ||
11916  eventNotificationAdd.AgentData.AgentID != AgentId)
11917  return true;
11918  }
11919  #endregion
11920 
11921  EventNotificationAddRequest handlerEventNotificationAddRequest = OnEventNotificationAddRequest;
11922  if (handlerEventNotificationAddRequest != null)
11923  handlerEventNotificationAddRequest(
11924  eventNotificationAdd.EventData.EventID, this);
11925  return true;
11926  }
11927  private bool HandleEventNotificationRemoveRequest(IClientAPI sender, Packet Pack)
11928  {
11929  EventNotificationRemoveRequestPacket eventNotificationRemove =
11930  (EventNotificationRemoveRequestPacket)Pack;
11931 
11932  #region Packet Session and User Check
11933  if (m_checkPackets)
11934  {
11935  if (eventNotificationRemove.AgentData.SessionID != SessionId ||
11936  eventNotificationRemove.AgentData.AgentID != AgentId)
11937  return true;
11938  }
11939  #endregion
11940 
11941  EventNotificationRemoveRequest handlerEventNotificationRemoveRequest = OnEventNotificationRemoveRequest;
11942  if (handlerEventNotificationRemoveRequest != null)
11943  handlerEventNotificationRemoveRequest(
11944  eventNotificationRemove.EventData.EventID, this);
11945  return true;
11946  }
11947  private bool HandleRetrieveInstantMessages(IClientAPI sender, Packet Pack)
11948  {
11949  RetrieveInstantMessagesPacket rimpInstantMessagePack = (RetrieveInstantMessagesPacket)Pack;
11950 
11951  #region Packet Session and User Check
11952  if (m_checkPackets)
11953  {
11954  if (rimpInstantMessagePack.AgentData.SessionID != SessionId ||
11955  rimpInstantMessagePack.AgentData.AgentID != AgentId)
11956  return true;
11957  }
11958  #endregion
11959 
11960  RetrieveInstantMessages handlerRetrieveInstantMessages = OnRetrieveInstantMessages;
11961  if (handlerRetrieveInstantMessages != null)
11962  handlerRetrieveInstantMessages(this);
11963  return true;
11964  }
11965  private bool HandlePickDelete(IClientAPI sender, Packet Pack)
11966  {
11967  PickDeletePacket pickDelete =
11968  (PickDeletePacket)Pack;
11969 
11970  #region Packet Session and User Check
11971  if (m_checkPackets)
11972  {
11973  if (pickDelete.AgentData.SessionID != SessionId ||
11974  pickDelete.AgentData.AgentID != AgentId)
11975  return true;
11976  }
11977  #endregion
11978 
11979  PickDelete handlerPickDelete = OnPickDelete;
11980  if (handlerPickDelete != null)
11981  handlerPickDelete(this, pickDelete.Data.PickID);
11982  return true;
11983  }
11984  private bool HandlePickGodDelete(IClientAPI sender, Packet Pack)
11985  {
11986  PickGodDeletePacket pickGodDelete =
11987  (PickGodDeletePacket)Pack;
11988 
11989  #region Packet Session and User Check
11990  if (m_checkPackets)
11991  {
11992  if (pickGodDelete.AgentData.SessionID != SessionId ||
11993  pickGodDelete.AgentData.AgentID != AgentId)
11994  return true;
11995  }
11996  #endregion
11997 
11998  PickGodDelete handlerPickGodDelete = OnPickGodDelete;
11999  if (handlerPickGodDelete != null)
12000  handlerPickGodDelete(this,
12001  pickGodDelete.AgentData.AgentID,
12002  pickGodDelete.Data.PickID,
12003  pickGodDelete.Data.QueryID);
12004  return true;
12005  }
12006  private bool HandlePickInfoUpdate(IClientAPI sender, Packet Pack)
12007  {
12008  PickInfoUpdatePacket pickInfoUpdate =
12009  (PickInfoUpdatePacket)Pack;
12010 
12011  #region Packet Session and User Check
12012  if (m_checkPackets)
12013  {
12014  if (pickInfoUpdate.AgentData.SessionID != SessionId ||
12015  pickInfoUpdate.AgentData.AgentID != AgentId)
12016  return true;
12017  }
12018  #endregion
12019 
12020  PickInfoUpdate handlerPickInfoUpdate = OnPickInfoUpdate;
12021  if (handlerPickInfoUpdate != null)
12022  handlerPickInfoUpdate(this,
12023  pickInfoUpdate.Data.PickID,
12024  pickInfoUpdate.Data.CreatorID,
12025  pickInfoUpdate.Data.TopPick,
12026  Utils.BytesToString(pickInfoUpdate.Data.Name),
12027  Utils.BytesToString(pickInfoUpdate.Data.Desc),
12028  pickInfoUpdate.Data.SnapshotID,
12029  pickInfoUpdate.Data.SortOrder,
12030  pickInfoUpdate.Data.Enabled);
12031  return true;
12032  }
12033  private bool HandleAvatarNotesUpdate(IClientAPI sender, Packet Pack)
12034  {
12035  AvatarNotesUpdatePacket avatarNotesUpdate =
12036  (AvatarNotesUpdatePacket)Pack;
12037 
12038  #region Packet Session and User Check
12039  if (m_checkPackets)
12040  {
12041  if (avatarNotesUpdate.AgentData.SessionID != SessionId ||
12042  avatarNotesUpdate.AgentData.AgentID != AgentId)
12043  return true;
12044  }
12045  #endregion
12046 
12047  AvatarNotesUpdate handlerAvatarNotesUpdate = OnAvatarNotesUpdate;
12048  if (handlerAvatarNotesUpdate != null)
12049  handlerAvatarNotesUpdate(this,
12050  avatarNotesUpdate.Data.TargetID,
12051  Utils.BytesToString(avatarNotesUpdate.Data.Notes));
12052  return true;
12053  }
12054  private bool HandleAvatarInterestsUpdate(IClientAPI sender, Packet Pack)
12055  {
12056  AvatarInterestsUpdatePacket avatarInterestUpdate =
12057  (AvatarInterestsUpdatePacket)Pack;
12058 
12059  #region Packet Session and User Check
12060  if (m_checkPackets)
12061  {
12062  if (avatarInterestUpdate.AgentData.SessionID != SessionId ||
12063  avatarInterestUpdate.AgentData.AgentID != AgentId)
12064  return true;
12065  }
12066  #endregion
12067 
12068  AvatarInterestUpdate handlerAvatarInterestUpdate = OnAvatarInterestUpdate;
12069  if (handlerAvatarInterestUpdate != null)
12070  handlerAvatarInterestUpdate(this,
12071  avatarInterestUpdate.PropertiesData.WantToMask,
12072  Utils.BytesToString(avatarInterestUpdate.PropertiesData.WantToText),
12073  avatarInterestUpdate.PropertiesData.SkillsMask,
12074  Utils.BytesToString(avatarInterestUpdate.PropertiesData.SkillsText),
12075  Utils.BytesToString(avatarInterestUpdate.PropertiesData.LanguagesText));
12076  return true;
12077  }
12078 
12079  private bool HandleGrantUserRights(IClientAPI sender, Packet Pack)
12080  {
12081  GrantUserRightsPacket GrantUserRights =
12082  (GrantUserRightsPacket)Pack;
12083  #region Packet Session and User Check
12084  if (m_checkPackets)
12085  {
12086  if (GrantUserRights.AgentData.SessionID != SessionId ||
12087  GrantUserRights.AgentData.AgentID != AgentId)
12088  return true;
12089  }
12090  #endregion
12091 
12092  GrantUserFriendRights GrantUserRightsHandler = OnGrantUserRights;
12093  if (GrantUserRightsHandler != null)
12094  GrantUserRightsHandler(this,
12095  GrantUserRights.Rights[0].AgentRelated,
12096  GrantUserRights.Rights[0].RelatedRights);
12097 
12098  return true;
12099  }
12100 
12101  private bool HandlePlacesQuery(IClientAPI sender, Packet Pack)
12102  {
12103  PlacesQueryPacket placesQueryPacket =
12104  (PlacesQueryPacket)Pack;
12105 
12106  PlacesQuery handlerPlacesQuery = OnPlacesQuery;
12107 
12108  if (handlerPlacesQuery != null)
12109  handlerPlacesQuery(placesQueryPacket.AgentData.QueryID,
12110  placesQueryPacket.TransactionData.TransactionID,
12111  Utils.BytesToString(
12112  placesQueryPacket.QueryData.QueryText),
12113  placesQueryPacket.QueryData.QueryFlags,
12114  (byte)placesQueryPacket.QueryData.Category,
12115  Utils.BytesToString(
12116  placesQueryPacket.QueryData.SimName),
12117  this);
12118  return true;
12119  }
12120 
12121  #endregion Packet Handlers
12122 
12123  public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
12124  {
12125  ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion);
12126  scriptQuestion.Data = new ScriptQuestionPacket.DataBlock();
12127  // TODO: don't create new blocks if recycling an old packet
12128  scriptQuestion.Data.TaskID = taskID;
12129  scriptQuestion.Data.ItemID = itemID;
12130  scriptQuestion.Data.Questions = question;
12131  scriptQuestion.Data.ObjectName = Util.StringToBytes256(taskName);
12132  scriptQuestion.Data.ObjectOwner = Util.StringToBytes256(ownerName);
12133 
12134  OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
12135  }
12136 
12143  protected virtual bool HandleLogout(IClientAPI client, Packet packet)
12144  {
12145  if (packet.Type == PacketType.LogoutRequest)
12146  {
12147  if (((LogoutRequestPacket)packet).AgentData.SessionID != SessionId) return false;
12148  }
12149 
12150  return Logout(client);
12151  }
12152 
12158  protected virtual bool Logout(IClientAPI client)
12159  {
12160  m_log.InfoFormat("[CLIENT]: Got a logout request for {0} in {1}", Name, Scene.RegionInfo.RegionName);
12161 
12162  Action<IClientAPI> handlerLogout = OnLogout;
12163 
12164  if (handlerLogout != null)
12165  {
12166  handlerLogout(client);
12167  }
12168 
12169  return true;
12170  }
12171 
12180  // TODO: Convert old handler to use new method
12181 /*
12182  protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
12183  {
12184  AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
12185  AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
12186 
12187  if (cachedtex.AgentData.SessionID != SessionId)
12188  return false;
12189 
12190 
12191 
12192  // TODO: don't create new blocks if recycling an old packet
12193  cachedresp.AgentData.AgentID = AgentId;
12194  cachedresp.AgentData.SessionID = m_sessionId;
12195  cachedresp.AgentData.SerialNum = m_cachedTextureSerial;
12196  m_cachedTextureSerial++;
12197  cachedresp.WearableData =
12198  new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
12199 
12200  int maxWearablesLoop = cachedtex.WearableData.Length;
12201  if (maxWearablesLoop > AvatarWearable.MAX_WEARABLES)
12202  maxWearablesLoop = AvatarWearable.MAX_WEARABLES;
12203 
12204  // Find the cached baked textures for this user, if they're available
12205 
12206  IAssetService cache = m_scene.AssetService;
12207  IBakedTextureModule bakedTextureModule = m_scene.RequestModuleInterface<IBakedTextureModule>();
12208 
12209  WearableCacheItem[] cacheItems = null;
12210 
12211  if (bakedTextureModule != null && cache != null)
12212  {
12213  ScenePresence p = m_scene.GetScenePresence(AgentId);
12214  if (p.Appearance != null)
12215  {
12216  if (p.Appearance.WearableCacheItems == null || p.Appearance.WearableCacheItemsDirty)
12217  {
12218  try
12219  {
12220  cacheItems = bakedTextureModule.Get(AgentId);
12221  p.Appearance.WearableCacheItems = cacheItems;
12222  p.Appearance.WearableCacheItemsDirty = false;
12223  }
12224  catch (Exception)
12225  {
12226  cacheItems = null;
12227  }
12228 
12229  }
12230  else if (p.Appearance.WearableCacheItems != null)
12231  {
12232  cacheItems = p.Appearance.WearableCacheItems;
12233  }
12234  }
12235  }
12236 
12237  CachedTextureRequest handlerCachedTextureRequest = OnCachedTextureRequest;
12238  if (handlerCachedTextureRequest != null)
12239  {
12240  handlerCachedTextureRequest(simclient,cachedtex.AgentData.SerialNum,requestArgs);
12241  }
12242 
12243  return true;
12244  }
12245 */
12246 
12247  protected bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
12248  {
12249  //m_log.Debug("texture cached: " + packet.ToString());
12250  AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
12251  AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
12252 
12253  if (cachedtex.AgentData.SessionID != SessionId)
12254  return false;
12255 
12256  // TODO: don't create new blocks if recycling an old packet
12257  cachedresp.AgentData.AgentID = AgentId;
12258  cachedresp.AgentData.SessionID = m_sessionId;
12259  cachedresp.AgentData.SerialNum = cachedtex.AgentData.SerialNum;
12260  cachedresp.WearableData =
12261  new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
12262 
12263  int cacheHits = 0;
12264 
12265  // We need to make sure the asset stored in the bake is available on this server also by it's assetid before we map it to a Cacheid
12266 
12267  WearableCacheItem[] cacheItems = null;
12268 
12269  ScenePresence p = m_scene.GetScenePresence(AgentId);
12270 
12271  if (p != null && p.Appearance != null)
12272  {
12273  cacheItems = p.Appearance.WearableCacheItems;
12274  }
12275 
12276  int maxWearablesLoop = cachedtex.WearableData.Length;
12277  if (maxWearablesLoop > cacheItems.Length)
12278  maxWearablesLoop = cacheItems.Length;
12279 
12280  if (cacheItems != null)
12281  {
12282  for (int i = 0; i < maxWearablesLoop; i++)
12283  {
12284  int idx = cachedtex.WearableData[i].TextureIndex;
12285  cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
12286  cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
12287  cachedresp.WearableData[i].HostName = new byte[0];
12288  if (cachedtex.WearableData[i].ID == cacheItems[idx].CacheId)
12289  {
12290  cachedresp.WearableData[i].TextureID = cacheItems[idx].TextureID;
12291  cacheHits++;
12292  }
12293  else
12294  {
12295  cachedresp.WearableData[i].TextureID = UUID.Zero;
12296  }
12297  }
12298  }
12299  else
12300  {
12301  for (int i = 0; i < maxWearablesLoop; i++)
12302  {
12303  cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
12304  cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
12305  cachedresp.WearableData[i].TextureID = UUID.Zero;
12306  cachedresp.WearableData[i].HostName = new byte[0];
12307  }
12308  }
12309 
12310  //m_log.DebugFormat("texture cached: hits {0}", cacheHits);
12311 
12312  cachedresp.Header.Zerocoded = true;
12313  OutPacket(cachedresp, ThrottleOutPacketType.Task);
12314 
12315  return true;
12316  }
12317 
12326  public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
12327  {
12328  ScenePresence presence = avatar as ScenePresence;
12329  if (presence == null)
12330  return;
12331 
12332  AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
12333 
12334  // TODO: don't create new blocks if recycling an old packet
12335  cachedresp.AgentData.AgentID = m_agentId;
12336  cachedresp.AgentData.SessionID = m_sessionId;
12337  cachedresp.AgentData.SerialNum = serial;
12338  cachedresp.WearableData = new AgentCachedTextureResponsePacket.WearableDataBlock[cachedTextures.Count];
12339 
12340  for (int i = 0; i < cachedTextures.Count; i++)
12341  {
12342  cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
12343  cachedresp.WearableData[i].TextureIndex = (byte)cachedTextures[i].BakedTextureIndex;
12344  cachedresp.WearableData[i].TextureID = cachedTextures[i].BakedTextureID;
12345  cachedresp.WearableData[i].HostName = new byte[0];
12346  }
12347 
12348  cachedresp.Header.Zerocoded = true;
12349  OutPacket(cachedresp, ThrottleOutPacketType.Task);
12350  }
12351 
12352  protected bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
12353  {
12354  MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
12355 
12356  if (multipleupdate.AgentData.SessionID != SessionId)
12357  return false;
12358 
12359 // m_log.DebugFormat(
12360 // "[CLIENT]: Incoming MultipleObjectUpdatePacket contained {0} blocks", multipleupdate.ObjectData.Length);
12361 
12362  Scene tScene = (Scene)m_scene;
12363 
12364  for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
12365  {
12366  MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i];
12367 
12368  // Can't act on Null Data
12369  if (block.Data != null)
12370  {
12371  uint localId = block.ObjectLocalID;
12372  SceneObjectPart part = tScene.GetSceneObjectPart(localId);
12373 
12374  if (part == null)
12375  {
12376  // It's a ghost! tell the client to delete it from view.
12377  simClient.SendKillObject(new List<uint> { localId });
12378  }
12379  else
12380  {
12381  ClientChangeObject updatehandler = onClientChangeObject;
12382 
12383  if (updatehandler != null)
12384  {
12385  ObjectChangeData udata = new ObjectChangeData();
12386 
12387  /*ubit from ll JIRA:
12388  * 0x01 position
12389  * 0x02 rotation
12390  * 0x04 scale
12391 
12392  * 0x08 LINK_SET
12393  * 0x10 UNIFORM for scale
12394  */
12395 
12396  // translate to internal changes
12397  // not all cases .. just the ones older code did
12398 
12399  switch (block.Type)
12400  {
12401  case 1: //change position sp
12402  udata.position = new Vector3(block.Data, 0);
12403 
12404  udata.change = ObjectChangeType.primP;
12405  updatehandler(localId, udata, this);
12406  break;
12407 
12408  case 2: // rotation sp
12409  udata.rotation = new Quaternion(block.Data, 0, true);
12410 
12411  udata.change = ObjectChangeType.primR;
12412  updatehandler(localId, udata, this);
12413  break;
12414 
12415  case 3: // position plus rotation
12416  udata.position = new Vector3(block.Data, 0);
12417  udata.rotation = new Quaternion(block.Data, 12, true);
12418 
12419  udata.change = ObjectChangeType.primPR;
12420  updatehandler(localId, udata, this);
12421  break;
12422 
12423  case 4: // scale sp
12424  udata.scale = new Vector3(block.Data, 0);
12425  udata.change = ObjectChangeType.primS;
12426 
12427  updatehandler(localId, udata, this);
12428  break;
12429 
12430  case 0x14: // uniform scale sp
12431  udata.scale = new Vector3(block.Data, 0);
12432 
12433  udata.change = ObjectChangeType.primUS;
12434  updatehandler(localId, udata, this);
12435  break;
12436 
12437  case 5: // scale and position sp
12438  udata.position = new Vector3(block.Data, 0);
12439  udata.scale = new Vector3(block.Data, 12);
12440 
12441  udata.change = ObjectChangeType.primPS;
12442  updatehandler(localId, udata, this);
12443  break;
12444 
12445  case 0x15: //uniform scale and position
12446  udata.position = new Vector3(block.Data, 0);
12447  udata.scale = new Vector3(block.Data, 12);
12448 
12449  udata.change = ObjectChangeType.primPUS;
12450  updatehandler(localId, udata, this);
12451  break;
12452 
12453  // now group related (bit 4)
12454  case 9: //( 8 + 1 )group position
12455  udata.position = new Vector3(block.Data, 0);
12456 
12457  udata.change = ObjectChangeType.groupP;
12458  updatehandler(localId, udata, this);
12459  break;
12460 
12461  case 0x0A: // (8 + 2) group rotation
12462  udata.rotation = new Quaternion(block.Data, 0, true);
12463 
12464  udata.change = ObjectChangeType.groupR;
12465  updatehandler(localId, udata, this);
12466  break;
12467 
12468  case 0x0B: //( 8 + 2 + 1) group rotation and position
12469  udata.position = new Vector3(block.Data, 0);
12470  udata.rotation = new Quaternion(block.Data, 12, true);
12471 
12472  udata.change = ObjectChangeType.groupPR;
12473  updatehandler(localId, udata, this);
12474  break;
12475 
12476  case 0x0C: // (8 + 4) group scale
12477  // only afects root prim and only sent by viewer editor object tab scaling
12478  // mouse edition only allows uniform scaling
12479  // SL MAY CHANGE THIS in viewers
12480 
12481  udata.scale = new Vector3(block.Data, 0);
12482 
12483  udata.change = ObjectChangeType.groupS;
12484  updatehandler(localId, udata, this);
12485 
12486  break;
12487 
12488  case 0x0D: //(8 + 4 + 1) group scale and position
12489  // exception as above
12490 
12491  udata.position = new Vector3(block.Data, 0);
12492  udata.scale = new Vector3(block.Data, 12);
12493 
12494  udata.change = ObjectChangeType.groupPS;
12495  updatehandler(localId, udata, this);
12496  break;
12497 
12498  case 0x1C: // (0x10 + 8 + 4 ) group scale UNIFORM
12499  udata.scale = new Vector3(block.Data, 0);
12500 
12501  udata.change = ObjectChangeType.groupUS;
12502  updatehandler(localId, udata, this);
12503  break;
12504 
12505  case 0x1D: // (UNIFORM + GROUP + SCALE + POS)
12506  udata.position = new Vector3(block.Data, 0);
12507  udata.scale = new Vector3(block.Data, 12);
12508 
12509  udata.change = ObjectChangeType.groupPUS;
12510  updatehandler(localId, udata, this);
12511  break;
12512 
12513  default:
12514  m_log.Debug("[CLIENT]: MultipleObjUpdate recieved an unknown packet type: " + (block.Type));
12515  break;
12516  }
12517  }
12518 
12519  }
12520  }
12521  }
12522  return true;
12523  }
12524 
12525  public void RequestMapLayer()
12526  {
12527  //should be getting the map layer from the grid server
12528  //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
12529  MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
12530  // TODO: don't create new blocks if recycling an old packet
12531  mapReply.AgentData.AgentID = AgentId;
12532  mapReply.AgentData.Flags = 0;
12533  mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
12534  mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
12535  mapReply.LayerData[0].Bottom = 0;
12536  mapReply.LayerData[0].Left = 0;
12537  mapReply.LayerData[0].Top = 30000;
12538  mapReply.LayerData[0].Right = 30000;
12539  mapReply.LayerData[0].ImageID = new UUID("00000000-0000-1111-9999-000000000006");
12540  mapReply.Header.Zerocoded = true;
12541  OutPacket(mapReply, ThrottleOutPacketType.Land);
12542  }
12543 
12544  public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
12545  {
12546  /*
12547  IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
12548  MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
12549  mbReply.AgentData.AgentId = AgentId;
12550  int len;
12551  if (simMapProfiles == null)
12552  len = 0;
12553  else
12554  len = simMapProfiles.Count;
12555 
12556  mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
12557  int iii;
12558  for (iii = 0; iii < len; iii++)
12559  {
12560  Hashtable mp = (Hashtable)simMapProfiles[iii];
12561  mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
12562  mbReply.Data[iii].Name = Util.UTF8.GetBytes((string)mp["name"]);
12563  mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
12564  mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
12565  mbReply.Data[iii].MapImageID = new UUID((string)mp["map-image-id"]);
12566  mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
12567  mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
12568  mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
12569  mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
12570  }
12571  this.OutPacket(mbReply, ThrottleOutPacketType.Land);
12572  */
12573  }
12574 
12579  public void SetChildAgentThrottle(byte[] throttles)
12580  {
12581  SetChildAgentThrottle(throttles, 1.0f);
12582  }
12583 
12584  public void SetChildAgentThrottle(byte[] throttles,float factor)
12585  {
12586  m_udpClient.SetThrottles(throttles, factor);
12587  GenericCall2 handler = OnUpdateThrottles;
12588  if (handler != null)
12589  {
12590  handler();
12591  }
12592  }
12593 
12598  public void SetAgentThrottleSilent(int throttle, int setting)
12599  {
12600  m_udpClient.ForceThrottleSetting(throttle,setting);
12601  }
12602 
12603  public int GetAgentThrottleSilent(int throttle)
12604  {
12605  return m_udpClient.GetThrottleSetting(throttle);
12606  }
12607 
12613  public byte[] GetThrottlesPacked(float multiplier)
12614  {
12615  return m_udpClient.GetThrottlesPacked(multiplier);
12616  }
12617 
12621  public virtual void InPacket(object NewPack)
12622  {
12623  throw new NotImplementedException();
12624  }
12625 
12631  protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
12632  {
12633  #region BinaryStats
12634  LLUDPServer.LogPacketHeader(false, m_circuitCode, 0, packet.Type, (ushort)packet.Length);
12635  #endregion BinaryStats
12636 
12637  OutPacket(packet, throttlePacketType, true);
12638  }
12639 
12648  protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
12649  {
12650  OutPacket(packet, throttlePacketType, doAutomaticSplitting, null);
12651  }
12652 
12664  protected void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method)
12665  {
12666  if (m_outPacketsToDrop != null)
12667  if (m_outPacketsToDrop.Contains(packet.Type.ToString()))
12668  return;
12669 
12670  if (DebugPacketLevel > 0)
12671  {
12672  bool logPacket = true;
12673 
12674  if (DebugPacketLevel <= 255
12675  && (packet.Type == PacketType.SimStats || packet.Type == PacketType.SimulatorViewerTimeMessage))
12676  logPacket = false;
12677 
12678  if (DebugPacketLevel <= 200
12679  && (packet.Type == PacketType.ImagePacket
12680  || packet.Type == PacketType.ImageData
12681  || packet.Type == PacketType.LayerData
12682  || packet.Type == PacketType.CoarseLocationUpdate))
12683  logPacket = false;
12684 
12685  if (DebugPacketLevel <= 100 && (packet.Type == PacketType.AvatarAnimation || packet.Type == PacketType.ViewerEffect))
12686  logPacket = false;
12687 
12688  if (DebugPacketLevel <= 50
12689  && (packet.Type == PacketType.ImprovedTerseObjectUpdate || packet.Type == PacketType.ObjectUpdate))
12690  logPacket = false;
12691 
12692  if (DebugPacketLevel <= 25 && packet.Type == PacketType.ObjectPropertiesFamily)
12693  logPacket = false;
12694 
12695  if (logPacket)
12696  m_log.DebugFormat(
12697  "[CLIENT]: PACKET OUT to {0} ({1}) in {2} - {3}",
12698  Name, SceneAgent.IsChildAgent ? "child" : "root ", m_scene.RegionInfo.RegionName, packet.Type);
12699  }
12700 
12701  m_udpServer.SendPacket(m_udpClient, packet, throttlePacketType, doAutomaticSplitting, method);
12702  }
12703 
12704  protected void HandleAutopilot(Object sender, string method, List<String> args)
12705  {
12706  float locx = 0;
12707  float locy = 0;
12708  float locz = 0;
12709  uint regionX = 0;
12710  uint regionY = 0;
12711 
12712  Utils.LongToUInts(m_scene.RegionInfo.RegionHandle, out regionX, out regionY);
12713  locx = (float)(Convert.ToDouble(args[0]) - (double)regionX);
12714  locy = (float)(Convert.ToDouble(args[1]) - (double)regionY);
12715  locz = Convert.ToSingle(args[2]);
12716 
12717  Action<Vector3, bool, bool> handlerAutoPilotGo = OnAutoPilotGo;
12718  if (handlerAutoPilotGo != null)
12719  handlerAutoPilotGo(new Vector3(locx, locy, locz), false, false);
12720  }
12721 
12726  public void ProcessInPacket(Packet packet)
12727  {
12728  if (m_inPacketsToDrop != null)
12729  if (m_inPacketsToDrop.Contains(packet.Type.ToString()))
12730  return;
12731 
12732  if (DebugPacketLevel > 0)
12733  {
12734  bool logPacket = true;
12735 
12736  if (DebugPacketLevel <= 255 && packet.Type == PacketType.AgentUpdate)
12737  logPacket = false;
12738 
12739  if (DebugPacketLevel <= 200 && packet.Type == PacketType.RequestImage)
12740  logPacket = false;
12741 
12742  if (DebugPacketLevel <= 100 && (packet.Type == PacketType.ViewerEffect || packet.Type == PacketType.AgentAnimation))
12743  logPacket = false;
12744 
12745  if (DebugPacketLevel <= 25 && packet.Type == PacketType.RequestObjectPropertiesFamily)
12746  logPacket = false;
12747 
12748  if (logPacket)
12749  m_log.DebugFormat(
12750  "[CLIENT]: PACKET IN from {0} ({1}) in {2} - {3}",
12751  Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name, packet.Type);
12752  }
12753 
12754  if (!ProcessPacketMethod(packet))
12755  m_log.WarnFormat(
12756  "[CLIENT]: Unhandled packet {0} from {1} ({2}) in {3}. Ignoring.",
12757  packet.Type, Name, SceneAgent.IsChildAgent ? "child" : "root ", Scene.Name);
12758  }
12759 
12760  private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
12761  {
12762  PrimitiveBaseShape shape = new PrimitiveBaseShape();
12763 
12764  shape.PCode = addPacket.ObjectData.PCode;
12765  shape.State = addPacket.ObjectData.State;
12766  shape.LastAttachPoint = addPacket.ObjectData.State;
12767  shape.PathBegin = addPacket.ObjectData.PathBegin;
12768  shape.PathEnd = addPacket.ObjectData.PathEnd;
12769  shape.PathScaleX = addPacket.ObjectData.PathScaleX;
12770  shape.PathScaleY = addPacket.ObjectData.PathScaleY;
12771  shape.PathShearX = addPacket.ObjectData.PathShearX;
12772  shape.PathShearY = addPacket.ObjectData.PathShearY;
12773  shape.PathSkew = addPacket.ObjectData.PathSkew;
12774  shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
12775  shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
12776  shape.Scale = addPacket.ObjectData.Scale;
12777  shape.PathCurve = addPacket.ObjectData.PathCurve;
12778  shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
12779  shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
12780  shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
12781  shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
12782  shape.PathTaperX = addPacket.ObjectData.PathTaperX;
12783  shape.PathTaperY = addPacket.ObjectData.PathTaperY;
12784  shape.PathTwist = addPacket.ObjectData.PathTwist;
12785  shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
12786  Primitive.TextureEntry ntex = new Primitive.TextureEntry(new UUID("89556747-24cb-43ed-920b-47caed15465f"));
12787  shape.TextureEntry = ntex.GetBytes();
12788  //shape.Textures = ntex;
12789  return shape;
12790  }
12791 
12793  {
12794  ClientInfo info = m_udpClient.GetClientInfo();
12795 
12796  info.proxyEP = null;
12797  if (info.agentcircuit == null)
12798  info.agentcircuit = RequestClientInfo();
12799 
12800  return info;
12801  }
12802 
12803  public void SetClientInfo(ClientInfo info)
12804  {
12805  m_udpClient.SetClientInfo(info);
12806  }
12807 
12808  #region Media Parcel Members
12809 
12810  public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
12811  {
12812  ParcelMediaCommandMessagePacket commandMessagePacket = new ParcelMediaCommandMessagePacket();
12813  commandMessagePacket.CommandBlock.Flags = flags;
12814  commandMessagePacket.CommandBlock.Command = (uint)command;
12815  commandMessagePacket.CommandBlock.Time = time;
12816 
12817  OutPacket(commandMessagePacket, ThrottleOutPacketType.Task);
12818  }
12819 
12820  public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID,
12821  byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight,
12822  byte mediaLoop)
12823  {
12824  ParcelMediaUpdatePacket updatePacket = new ParcelMediaUpdatePacket();
12825  updatePacket.DataBlock.MediaURL = Util.StringToBytes256(mediaUrl);
12826  updatePacket.DataBlock.MediaID = mediaTextureID;
12827  updatePacket.DataBlock.MediaAutoScale = autoScale;
12828 
12829  updatePacket.DataBlockExtended.MediaType = Util.StringToBytes256(mediaType);
12830  updatePacket.DataBlockExtended.MediaDesc = Util.StringToBytes256(mediaDesc);
12831  updatePacket.DataBlockExtended.MediaWidth = mediaWidth;
12832  updatePacket.DataBlockExtended.MediaHeight = mediaHeight;
12833  updatePacket.DataBlockExtended.MediaLoop = mediaLoop;
12834 
12835  OutPacket(updatePacket, ThrottleOutPacketType.Task);
12836  }
12837 
12838  #endregion
12839 
12840  #region Camera
12841 
12842  public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
12843  {
12844  SetFollowCamPropertiesPacket packet = (SetFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.SetFollowCamProperties);
12845  packet.ObjectData.ObjectID = objectID;
12846  SetFollowCamPropertiesPacket.CameraPropertyBlock[] camPropBlock = new SetFollowCamPropertiesPacket.CameraPropertyBlock[parameters.Count];
12847  uint idx = 0;
12848  foreach (KeyValuePair<int, float> pair in parameters)
12849  {
12850  SetFollowCamPropertiesPacket.CameraPropertyBlock block = new SetFollowCamPropertiesPacket.CameraPropertyBlock();
12851  block.Type = pair.Key;
12852  block.Value = pair.Value;
12853 
12854  camPropBlock[idx++] = block;
12855  }
12856  packet.CameraProperty = camPropBlock;
12857  OutPacket(packet, ThrottleOutPacketType.Task);
12858  }
12859 
12860  public void SendClearFollowCamProperties(UUID objectID)
12861  {
12862  ClearFollowCamPropertiesPacket packet = (ClearFollowCamPropertiesPacket)PacketPool.Instance.GetPacket(PacketType.ClearFollowCamProperties);
12863  packet.ObjectData.ObjectID = objectID;
12864  OutPacket(packet, ThrottleOutPacketType.Task);
12865  }
12866 
12867  #endregion
12868 
12869  public void SetClientOption(string option, string value)
12870  {
12871  switch (option)
12872  {
12873  default:
12874  break;
12875  }
12876  }
12877 
12878  public string GetClientOption(string option)
12879  {
12880  switch (option)
12881  {
12882  default:
12883  break;
12884  }
12885  return string.Empty;
12886  }
12887 
12888  #region IClientCore
12889 
12890  private readonly Dictionary<Type, object> m_clientInterfaces = new Dictionary<Type, object>();
12891 
12897  protected void RegisterInterface<T>(T iface)
12898  {
12899  lock (m_clientInterfaces)
12900  {
12901  if (!m_clientInterfaces.ContainsKey(typeof(T)))
12902  {
12903  m_clientInterfaces.Add(typeof(T), iface);
12904  }
12905  }
12906  }
12907 
12908  public bool TryGet<T>(out T iface)
12909  {
12910  if (m_clientInterfaces.ContainsKey(typeof(T)))
12911  {
12912  iface = (T)m_clientInterfaces[typeof(T)];
12913  return true;
12914  }
12915  iface = default(T);
12916  return false;
12917  }
12918 
12919  public T Get<T>()
12920  {
12921  return (T)m_clientInterfaces[typeof(T)];
12922  }
12923 
12924  public void Disconnect(string reason)
12925  {
12926  Kick(reason);
12927  Thread.Sleep(1000);
12928  Disconnect();
12929  }
12930 
12931  public void Disconnect()
12932  {
12933  Close();
12934  }
12935 
12936  #endregion
12937 
12939  {
12940  if (m_GroupsModule != null)
12941  {
12942  GroupMembershipData[] GroupMembership =
12943  m_GroupsModule.GetMembershipData(AgentId);
12944 
12945  m_groupPowers.Clear();
12946 
12947  if (GroupMembership != null)
12948  {
12949  for (int i = 0; i < GroupMembership.Length; i++)
12950  {
12951  m_groupPowers[GroupMembership[i].GroupID] = GroupMembership[i].GroupPowers;
12952  }
12953  }
12954  }
12955  }
12956 
12957  public string Report()
12958  {
12959  return m_udpClient.GetStats();
12960  }
12961 
12962  public string XReport(string uptime, string version)
12963  {
12964  return String.Empty;
12965  }
12966 
12967  public OSDMap OReport(string uptime, string version)
12968  {
12969  return new OSDMap();
12970  }
12971 
12977  protected void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
12978  {
12979  UUID requestID = UUID.Zero;
12980  int sourceType = transferRequest.TransferInfo.SourceType;
12981 
12982  if (sourceType == (int)SourceType.Asset)
12983  {
12984  requestID = new UUID(transferRequest.TransferInfo.Params, 0);
12985  }
12986  else if (sourceType == (int)SourceType.SimInventoryItem)
12987  {
12988  requestID = new UUID(transferRequest.TransferInfo.Params, 80);
12989  }
12990  else if (sourceType == (int)SourceType.SimEstate)
12991  {
12992  requestID = taskID;
12993  }
12994 
12995 // m_log.DebugFormat(
12996 // "[LLCLIENTVIEW]: Received transfer request for {0} in {1} type {2} by {3}",
12997 // requestID, taskID, (SourceType)sourceType, Name);
12998 
12999 
13000  //Note, the bool returned from the below function is useless since it is always false.
13001  m_assetService.Get(requestID.ToString(), transferRequest, AssetReceived);
13002 
13003  }
13004 
13011  protected void AssetReceived(string id, Object sender, AssetBase asset)
13012  {
13013  TransferRequestPacket transferRequest = (TransferRequestPacket)sender;
13014 
13015  UUID requestID = UUID.Zero;
13016  byte source = (byte)SourceType.Asset;
13017 
13019 
13020  if (asset == null)
13021  {
13022  // Try the user's asset server
13023  IInventoryAccessModule inventoryAccessModule = Scene.RequestModuleInterface<IInventoryAccessModule>();
13024 
13025  string assetServerURL = string.Empty;
13026  if (inventoryAccessModule.IsForeignUser(AgentId, out assetServerURL) && !string.IsNullOrEmpty(assetServerURL))
13027  {
13028  if (!assetServerURL.EndsWith("/") && !assetServerURL.EndsWith("="))
13029  assetServerURL = assetServerURL + "/";
13030 
13031  //m_log.DebugFormat("[LLCLIENTVIEW]: asset {0} not found in local storage. Trying user's storage.", assetServerURL + id);
13032  asset = m_scene.AssetService.Get(assetServerURL + id);
13033  }
13034 
13035  if (asset == null)
13036  {
13037  req.AssetInf = null;
13038  req.AssetRequestSource = source;
13039  req.IsTextureRequest = false;
13040  req.NumPackets = 0;
13041  req.Params = transferRequest.TransferInfo.Params;
13042  req.RequestAssetID = requestID;
13043  req.TransferRequestID = transferRequest.TransferInfo.TransferID;
13044 
13045  SendAssetNotFound(req);
13046  return;
13047  }
13048 
13049  }
13050 
13051  if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset)
13052  {
13053  requestID = new UUID(transferRequest.TransferInfo.Params, 0);
13054  }
13055  else if (transferRequest.TransferInfo.SourceType == (int)SourceType.SimInventoryItem)
13056  {
13057  requestID = new UUID(transferRequest.TransferInfo.Params, 80);
13058  source = (byte)SourceType.SimInventoryItem;
13059  //m_log.Debug("asset request " + requestID);
13060  }
13061 
13062  // Scripts cannot be retrieved by direct request
13063  if (transferRequest.TransferInfo.SourceType == (int)SourceType.Asset && asset.Type == 10)
13064  return;
13065 
13066  // The asset is known to exist and is in our cache, so add it to the AssetRequests list
13067  req.AssetInf = asset;
13068  req.AssetRequestSource = source;
13069  req.IsTextureRequest = false;
13070  req.NumPackets = CalculateNumPackets(asset.Data);
13071  req.Params = transferRequest.TransferInfo.Params;
13072  req.RequestAssetID = requestID;
13073  req.TransferRequestID = transferRequest.TransferInfo.TransferID;
13074 
13075  SendAsset(req);
13076  }
13077 
13083  private static int CalculateNumPackets(byte[] data)
13084  {
13085 // const uint m_maxPacketSize = 600;
13086  uint m_maxPacketSize = MaxTransferBytesPerPacket;
13087  int numPackets = 1;
13088 
13089  if (data == null)
13090  return 0;
13091 
13092  if (data.LongLength > m_maxPacketSize)
13093  {
13094  // over max number of bytes so split up file
13095  long restData = data.LongLength - m_maxPacketSize;
13096  int restPackets = (int)((restData + m_maxPacketSize - 1) / m_maxPacketSize);
13097  numPackets += restPackets;
13098  }
13099 
13100  return numPackets;
13101  }
13102 
13103  public void SendRebakeAvatarTextures(UUID textureID)
13104  {
13105  RebakeAvatarTexturesPacket pack =
13106  (RebakeAvatarTexturesPacket)PacketPool.Instance.GetPacket(PacketType.RebakeAvatarTextures);
13107 
13108  pack.TextureData = new RebakeAvatarTexturesPacket.TextureDataBlock();
13109  pack.TextureData.TextureID = textureID;
13110  OutPacket(pack, ThrottleOutPacketType.Task);
13111  }
13112 
13113  public struct PacketProcessor
13114  {
13118  public PacketMethod method { get; set; }
13119 
13123  public bool Async { get; set; }
13124 
13129  public bool InEngine { get; set; }
13130  }
13131 
13132  public class AsyncPacketProcess
13133  {
13134  public bool result = false;
13135  public readonly LLClientView ClientView = null;
13136  public readonly Packet Pack = null;
13137  public readonly PacketMethod Method = null;
13138  public AsyncPacketProcess(LLClientView pClientview, PacketMethod pMethod, Packet pPack)
13139  {
13140  ClientView = pClientview;
13141  Method = pMethod;
13142  Pack = pPack;
13143  }
13144  }
13145 
13146  public static OSD BuildEvent(string eventName, OSD eventBody)
13147  {
13148  OSDMap osdEvent = new OSDMap(2);
13149  osdEvent.Add("message", new OSDString(eventName));
13150  osdEvent.Add("body", eventBody);
13151 
13152  return osdEvent;
13153  }
13154 
13155  public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
13156  {
13157  AvatarInterestsReplyPacket packet = (AvatarInterestsReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarInterestsReply);
13158 
13159  packet.AgentData = new AvatarInterestsReplyPacket.AgentDataBlock();
13160  packet.AgentData.AgentID = AgentId;
13161  packet.AgentData.AvatarID = avatarID;
13162 
13163  packet.PropertiesData = new AvatarInterestsReplyPacket.PropertiesDataBlock();
13164  packet.PropertiesData.WantToMask = wantMask;
13165  packet.PropertiesData.WantToText = Utils.StringToBytes(wantText);
13166  packet.PropertiesData.SkillsMask = skillsMask;
13167  packet.PropertiesData.SkillsText = Utils.StringToBytes(skillsText);
13168  packet.PropertiesData.LanguagesText = Utils.StringToBytes(languages);
13169  OutPacket(packet, ThrottleOutPacketType.Task);
13170  }
13171 
13172  public void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
13173  {
13174  ChangeUserRightsPacket packet = (ChangeUserRightsPacket)PacketPool.Instance.GetPacket(PacketType.ChangeUserRights);
13175 
13176  packet.AgentData = new ChangeUserRightsPacket.AgentDataBlock();
13177  packet.AgentData.AgentID = agentID;
13178 
13179  packet.Rights = new ChangeUserRightsPacket.RightsBlock[1];
13180  packet.Rights[0] = new ChangeUserRightsPacket.RightsBlock();
13181  packet.Rights[0].AgentRelated = friendID;
13182  packet.Rights[0].RelatedRights = rights;
13183 
13184  OutPacket(packet, ThrottleOutPacketType.Task);
13185  }
13186 
13187  public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
13188  {
13189  ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
13190  dialog.Data.ObjectID = objectId;
13191  dialog.Data.ChatChannel = chatChannel;
13192  dialog.Data.ImageID = UUID.Zero;
13193  dialog.Data.ObjectName = Util.StringToBytes256(objectname);
13194  // this is the username of the *owner*
13195  dialog.Data.FirstName = Util.StringToBytes256(ownerFirstName);
13196  dialog.Data.LastName = Util.StringToBytes256(ownerLastName);
13197  dialog.Data.Message = Util.StringToBytes(message,512);
13198 
13199  ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[1];
13200  buttons[0] = new ScriptDialogPacket.ButtonsBlock();
13201  buttons[0].ButtonLabel = Util.StringToBytes256("!!llTextBox!!");
13202  dialog.Buttons = buttons;
13203 
13204  dialog.OwnerData = new ScriptDialogPacket.OwnerDataBlock[1];
13205  dialog.OwnerData[0] = new ScriptDialogPacket.OwnerDataBlock();
13206  dialog.OwnerData[0].OwnerID = ownerID;
13207 
13208  OutPacket(dialog, ThrottleOutPacketType.Task);
13209  }
13210 
13212  {
13213  if (p is ScenePresence)
13214  {
13215 // m_log.DebugFormat(
13216 // "[LLCLIENTVIEW]: Immediately sending terse agent update for {0} to {1} in {2}",
13217 // p.Name, Name, Scene.Name);
13218 
13219  // It turns out to get the agent to stop flying, you have to feed it stop flying velocities
13220  // There's no explicit message to send the client to tell it to stop flying.. it relies on the
13221  // velocity, collision plane and avatar height
13222 
13223  // Add 1/6 the avatar's height to it's position so it doesn't shoot into the air
13224  // when the avatar stands up
13225 
13226  ImprovedTerseObjectUpdatePacket.ObjectDataBlock block =
13227  CreateImprovedTerseBlock(p, false);
13228 
13229 // const float TIME_DILATION = 1.0f;
13230  ushort timeDilation = Utils.FloatToUInt16(m_scene.TimeDilation, 0.0f, 1.0f);;
13231 
13232  ImprovedTerseObjectUpdatePacket packet
13233  = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(
13234  PacketType.ImprovedTerseObjectUpdate);
13235 
13236  packet.RegionData.RegionHandle = m_scene.RegionInfo.RegionHandle;
13237  packet.RegionData.TimeDilation = timeDilation;
13238  packet.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
13239 
13240  packet.ObjectData[0] = block;
13241 
13242  OutPacket(packet, ThrottleOutPacketType.Task, true);
13243  }
13244 
13245  //ControllingClient.SendAvatarTerseUpdate(new SendAvatarTerseData(m_rootRegionHandle, (ushort)(m_scene.TimeDilation * ushort.MaxValue), LocalId,
13246  // AbsolutePosition, Velocity, Vector3.Zero, m_bodyRot, new Vector4(0,0,1,AbsolutePosition.Z - 0.5f), m_uuid, null, GetUpdatePriority(ControllingClient)));
13247  }
13248 
13249  public void SendPlacesReply(UUID queryID, UUID transactionID,
13250  PlacesReplyData[] data)
13251  {
13252  PlacesReplyPacket reply = null;
13253  PlacesReplyPacket.QueryDataBlock[] dataBlocks =
13254  new PlacesReplyPacket.QueryDataBlock[0];
13255 
13256  for (int i = 0 ; i < data.Length ; i++)
13257  {
13258  PlacesReplyPacket.QueryDataBlock block =
13259  new PlacesReplyPacket.QueryDataBlock();
13260 
13261  block.OwnerID = data[i].OwnerID;
13262  block.Name = Util.StringToBytes256(data[i].Name);
13263  block.Desc = Util.StringToBytes1024(data[i].Desc);
13264  block.ActualArea = data[i].ActualArea;
13265  block.BillableArea = data[i].BillableArea;
13266  block.Flags = data[i].Flags;
13267  block.GlobalX = data[i].GlobalX;
13268  block.GlobalY = data[i].GlobalY;
13269  block.GlobalZ = data[i].GlobalZ;
13270  block.SimName = Util.StringToBytes256(data[i].SimName);
13271  block.SnapshotID = data[i].SnapshotID;
13272  block.Dwell = data[i].Dwell;
13273  block.Price = data[i].Price;
13274 
13275  if (reply != null && reply.Length + block.Length > 1400)
13276  {
13277  OutPacket(reply, ThrottleOutPacketType.Task);
13278 
13279  reply = null;
13280  dataBlocks = new PlacesReplyPacket.QueryDataBlock[0];
13281  }
13282 
13283  if (reply == null)
13284  {
13285  reply = (PlacesReplyPacket)PacketPool.Instance.GetPacket(PacketType.PlacesReply);
13286  reply.AgentData = new PlacesReplyPacket.AgentDataBlock();
13287  reply.AgentData.AgentID = AgentId;
13288  reply.AgentData.QueryID = queryID;
13289 
13290  reply.TransactionData = new PlacesReplyPacket.TransactionDataBlock();
13291  reply.TransactionData.TransactionID = transactionID;
13292 
13293  reply.QueryData = dataBlocks;
13294  }
13295 
13296  Array.Resize(ref dataBlocks, dataBlocks.Length + 1);
13297  dataBlocks[dataBlocks.Length - 1] = block;
13298  reply.QueryData = dataBlocks;
13299  }
13300  if (reply != null)
13301  OutPacket(reply, ThrottleOutPacketType.Task);
13302  }
13303 
13304  public void SendRemoveInventoryItems(UUID[] items)
13305  {
13306  IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
13307 
13308  if (eq == null)
13309  {
13310  m_log.DebugFormat("[LLCLIENT]: Null event queue");
13311  return;
13312  }
13313 
13314  OSDMap llsd = new OSDMap(3);
13315 
13316  OSDMap AgentDataMap = new OSDMap(1);
13317  AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
13318  AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
13319 
13320  OSDArray AgentData = new OSDArray(1);
13321  AgentData.Add(AgentDataMap);
13322 
13323  llsd.Add("AgentData", AgentData);
13324 
13325  OSDArray ItemData = new OSDArray();
13326 
13327  foreach (UUID item in items)
13328  {
13329  OSDMap ItemDataMap = new OSDMap(2);
13330  ItemDataMap.Add("ItemID", OSD.FromUUID(item));
13331  ItemDataMap.Add("AgentID", OSD.FromUUID(AgentId));
13332 
13333  ItemData.Add(ItemDataMap);
13334  }
13335 
13336  llsd.Add("InventoryData", ItemData);
13337 
13338  eq.Enqueue(BuildEvent("RemoveInventoryItem",
13339  llsd), AgentId);
13340  }
13341 
13342  public void SendRemoveInventoryFolders(UUID[] folders)
13343  {
13344  IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
13345 
13346  if (eq == null)
13347  {
13348  m_log.DebugFormat("[LLCLIENT]: Null event queue");
13349  return;
13350  }
13351 
13352  OSDMap llsd = new OSDMap(3);
13353 
13354  OSDMap AgentDataMap = new OSDMap(1);
13355  AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
13356  AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
13357 
13358  OSDArray AgentData = new OSDArray(1);
13359  AgentData.Add(AgentDataMap);
13360 
13361  llsd.Add("AgentData", AgentData);
13362 
13363  OSDArray FolderData = new OSDArray();
13364 
13365  foreach (UUID folder in folders)
13366  {
13367  OSDMap FolderDataMap = new OSDMap(2);
13368  FolderDataMap.Add("FolderID", OSD.FromUUID(folder));
13369  FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
13370 
13371  FolderData.Add(FolderDataMap);
13372  }
13373 
13374  llsd.Add("FolderData", FolderData);
13375 
13376  eq.Enqueue(BuildEvent("RemoveInventoryFolder",
13377  llsd), AgentId);
13378  }
13379 
13380  private byte[] EncodeU32(uint val)
13381  {
13382  byte[] ret = BitConverter.GetBytes(val);
13383  if (BitConverter.IsLittleEndian)
13384  Array.Reverse(ret);
13385  return ret;
13386  }
13387 
13389  {
13390  IEventQueue eq = Scene.RequestModuleInterface<IEventQueue>();
13391 
13392  if (eq == null)
13393  {
13394  m_log.DebugFormat("[LLCLIENT]: Null event queue");
13395  return;
13396  }
13397 
13398  OSDMap llsd = new OSDMap(3);
13399 
13400  OSDMap AgentDataMap = new OSDMap(1);
13401  AgentDataMap.Add("AgentID", OSD.FromUUID(AgentId));
13402  AgentDataMap.Add("SessionID", OSD.FromUUID(SessionId));
13403  AgentDataMap.Add("TransactionID", OSD.FromUUID(UUID.Random()));
13404 
13405  OSDArray AgentData = new OSDArray(1);
13406  AgentData.Add(AgentDataMap);
13407 
13408  llsd.Add("AgentData", AgentData);
13409 
13410  OSDArray FolderData = new OSDArray();
13411 
13412  foreach (InventoryFolderBase folder in folders)
13413  {
13414  OSDMap FolderDataMap = new OSDMap(5);
13415  FolderDataMap.Add("FolderID", OSD.FromUUID(folder.ID));
13416  FolderDataMap.Add("AgentID", OSD.FromUUID(AgentId));
13417  FolderDataMap.Add("ParentID", OSD.FromUUID(folder.ParentID));
13418  FolderDataMap.Add("Type", OSD.FromInteger(folder.Type));
13419  FolderDataMap.Add("Name", OSD.FromString(folder.Name));
13420 
13421  FolderData.Add(FolderDataMap);
13422  }
13423 
13424  llsd.Add("FolderData", FolderData);
13425 
13426  OSDArray ItemData = new OSDArray();
13427 
13428  foreach (InventoryItemBase item in items)
13429  {
13430  OSDMap ItemDataMap = new OSDMap();
13431 
13432  ItemDataMap.Add("ItemID", OSD.FromUUID(item.ID));
13433  ItemDataMap.Add("FolderID", OSD.FromUUID(item.Folder));
13434 
13435  ItemDataMap.Add("CreatorID", OSD.FromUUID(item.CreatorIdAsUuid));
13436  ItemDataMap.Add("OwnerID", OSD.FromUUID(item.Owner));
13437  ItemDataMap.Add("GroupID", OSD.FromUUID(item.GroupID));
13438  ItemDataMap.Add("BaseMask", OSD.FromBinary(EncodeU32((uint)item.BasePermissions)));
13439  ItemDataMap.Add("OwnerMask", OSD.FromBinary(EncodeU32((uint)item.CurrentPermissions)));
13440  ItemDataMap.Add("GroupMask", OSD.FromBinary(EncodeU32((uint)item.GroupPermissions)));
13441  ItemDataMap.Add("EveryoneMask", OSD.FromBinary(EncodeU32((uint)item.EveryOnePermissions)));
13442  ItemDataMap.Add("NextOwnerMask", OSD.FromBinary(EncodeU32((uint)item.NextPermissions)));
13443  ItemDataMap.Add("GroupOwned", OSD.FromBoolean(item.GroupOwned));
13444  ItemDataMap.Add("AssetID", OSD.FromUUID(item.AssetID));
13445  ItemDataMap.Add("Type", OSD.FromInteger(item.AssetType));
13446  ItemDataMap.Add("InvType", OSD.FromInteger(item.InvType));
13447  ItemDataMap.Add("Flags", OSD.FromBinary(EncodeU32((uint)item.Flags)));
13448  ItemDataMap.Add("SaleType", OSD.FromInteger((byte)item.SaleType));
13449  ItemDataMap.Add("SalePrice", OSD.FromInteger(item.SalePrice));
13450  ItemDataMap.Add("Name", OSD.FromString(item.Name));
13451  ItemDataMap.Add("Description", OSD.FromString(item.Description));
13452  ItemDataMap.Add("CreationDate", OSD.FromInteger(item.CreationDate));
13453 
13454  ItemDataMap.Add("CRC", OSD.FromBinary(EncodeU32(
13455  Helpers.InventoryCRC(1000, 0, (sbyte)item.InvType,
13456  (sbyte)item.AssetType, item.AssetID,
13457  item.GroupID, 100,
13458  item.Owner, item.CreatorIdAsUuid,
13459  item.ID, item.Folder,
13460  (uint)PermissionMask.All, 1, (uint)PermissionMask.All, (uint)PermissionMask.All,
13461  (uint)PermissionMask.All)
13462  )));
13463  ItemDataMap.Add("CallbackID", 0);
13464 
13465  ItemData.Add(ItemDataMap);
13466  }
13467 
13468  llsd.Add("ItemData", ItemData);
13469 
13470  eq.Enqueue(BuildEvent("BulkUpdateInventory",
13471  llsd), AgentId);
13472  }
13473 
13474  private HashSet<string> m_outPacketsToDrop;
13475 
13476  public bool AddOutPacketToDropSet(string packetName)
13477  {
13478  if (m_outPacketsToDrop == null)
13479  m_outPacketsToDrop = new HashSet<string>();
13480 
13481  return m_outPacketsToDrop.Add(packetName);
13482  }
13483 
13484  public bool RemoveOutPacketFromDropSet(string packetName)
13485  {
13486  if (m_outPacketsToDrop == null)
13487  return false;
13488 
13489  return m_outPacketsToDrop.Remove(packetName);
13490  }
13491 
13492  public HashSet<string> GetOutPacketDropSet()
13493  {
13494  return new HashSet<string>(m_outPacketsToDrop);
13495  }
13496 
13497  private HashSet<string> m_inPacketsToDrop;
13498 
13499  public bool AddInPacketToDropSet(string packetName)
13500  {
13501  if (m_inPacketsToDrop == null)
13502  m_inPacketsToDrop = new HashSet<string>();
13503 
13504  return m_inPacketsToDrop.Add(packetName);
13505  }
13506 
13507  public bool RemoveInPacketFromDropSet(string packetName)
13508  {
13509  if (m_inPacketsToDrop == null)
13510  return false;
13511 
13512  return m_inPacketsToDrop.Remove(packetName);
13513  }
13514 
13515  public HashSet<string> GetInPacketDropSet()
13516  {
13517  return new HashSet<string>(m_inPacketsToDrop);
13518  }
13519  }
13520 }
delegate void ObjectPermissions(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set)
void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
Tell the client that we have created the item it requested.
delegate void RezScript(IClientAPI remoteClient, InventoryItemBase item, UUID transactionID, uint localID)
delegate void ParcelBuyPass(IClientAPI client, UUID agentID, int ParcelLocalID)
delegate void ImprovedInstantMessage(IClientAPI remoteclient, GridInstantMessage im)
Implemented by classes which collect up non-viewer statistical information
delegate void ObjectDrop(uint localID, IClientAPI remoteClient)
void SendAvatarNotesReply(UUID targetID, string text)
void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
Send the first part of a texture. For sufficiently small textures, this may be the only packet...
delegate void TeleportCancel(IClientAPI remoteClient)
void SendNameReply(UUID profileId, string firstname, string lastname)
AgentCircuitData RequestClientInfo()
Return circuit information for this client.
delegate void DirClassifiedQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, uint category, int queryStart)
OpenSim.Framework.PermissionMask PermissionMask
Definition: LLClientView.cs:55
void SendGroupMembership(GroupMembershipData[] GroupMembership)
void SendLandObjectOwners(LandData land, List< UUID > groups, Dictionary< UUID, int > ownersAndCount)
bool IsForeignUser(UUID userID, out string assetServerURL)
delegate void EventInfoRequest(IClientAPI remoteClient, uint eventID)
delegate void NewUserReport(IClientAPI client, string regionName, UUID abuserID, byte catagory, byte checkflags, string details, UUID objectID, Vector3 postion, byte reportType, UUID screenshotID, string Summary, UUID reporter)
void SendLayerData(int px, int py, TerrainData terrData)
delegate void UpdatePrimSingleRotationPosition(uint localID, Quaternion rot, Vector3 pos, IClientAPI remoteClient)
Action< IClientAPI, bool > OnCompleteMovementToRegion
Definition: LLClientView.cs:95
delegate void EjectUserUpdate(IClientAPI client, UUID parcelowner, uint flags, UUID target)
delegate void AbortXfer(IClientAPI remoteClient, ulong xferID)
delegate void UpdatePrimGroupRotation(uint localID, Vector3 pos, Quaternion rot, IClientAPI remoteClient)
byte[] GetThrottlesPacked(float multiplier)
Get the current throttles for this client as a packed byte array
delegate void PurgeInventoryDescendents(IClientAPI remoteClient, UUID folderID)
static NumberFormatInfo NumberFormatInfo
Definition: Culture.cs:39
GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate
bool HasPrivateAttachmentPoint
If this scene object has an attachment point then indicate whether there is a point where attachments...
delegate void RequestAsset(IClientAPI remoteClient, RequestAssetArgs transferRequest)
delegate void RezMultipleAttachmentsFromInv(IClientAPI remoteClient, List< KeyValuePair< UUID, uint >> rezlist)
void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message, string url)
delegate void RemoveInventoryItem(IClientAPI remoteClient, List< UUID > itemIDs)
delegate void UpdatePrimSingleRotation(uint localID, Quaternion rot, IClientAPI remoteClient)
int MediaWidth
Width of parcel media render
Definition: LandData.cs:191
virtual bool ProcessPacketMethod(Packet packet)
Try to process a packet using registered packet handlers
void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data)
void SendSetFollowCamProperties(UUID objectID, SortedDictionary< int, float > parameters)
delegate void GroupAccountSummaryRequest(IClientAPI client, UUID agentID, UUID groupID)
void SendAgentGroupDataUpdate(UUID avatarID, GroupMembershipData[] data)
virtual void InPacket(object NewPack)
Cruft?
void SendGroupActiveProposals(UUID groupID, UUID transactionID, GroupActiveProposals[] Proposals)
delegate void PickInfoUpdate(IClientAPI client, UUID pickID, UUID creatorID, bool topPick, string name, string desc, UUID snapshotID, int sortOrder, bool enabled)
delegate void ScriptAnswer(IClientAPI remoteClient, UUID objectID, UUID itemID, int answer)
void SendDialog(string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels)
Open a dialog box on the client.
delegate void ObjectSaleInfo(IClientAPI remoteClient, UUID agentID, UUID sessionID, uint localID, byte saleType, int salePrice)
OpenMetaverse.StructuredData.OSDArray OSDArray
void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
void SendAvatarDataImmediate(ISceneEntity avatar)
Send an ObjectUpdate packet with information about an avatar
delegate void UpdateTaskInventory(IClientAPI remoteClient, UUID transactionID, TaskInventoryItem item, uint localID)
delegate void UpdatePrimRotation(uint localID, Quaternion rot, IClientAPI remoteClient)
delegate void RequestMapBlocks(IClientAPI remoteClient, int minX, int minY, int maxX, int maxY, uint flag)
bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
delegate void RezRestoreToWorld(IClientAPI remoteClient, UUID itemId)
delegate void GrabObject(uint localID, Vector3 pos, IClientAPI remoteClient, List< SurfaceTouchEventArgs > surfaceArgs)
delegate void CachedTextureRequest(IClientAPI remoteClient, int serial, List< CachedTextureRequestArg > cachedTextureRequest)
void SendGenericMessage(string method, UUID invoice, List< string > message)
Client provided parameters for avatar movement
delegate void RequestTaskInventory(IClientAPI remoteClient, uint localID)
void SendLeaveGroupReply(UUID groupID, bool success)
void SendPartPhysicsProprieties(ISceneEntity entity)
bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
Add a handler for the given packet type.
delegate void RequestPayPrice(IClientAPI remoteClient, UUID objectID)
RezMultipleAttachmentsFromInv OnRezMultipleAttachmentsFromInv
Definition: LLClientView.cs:90
RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv
Definition: LLClientView.cs:89
void SendCachedTextureResponse(ISceneEntity avatar, int serial, List< CachedTextureResponseArg > cachedTextures)
Send a response back to a client when it asks the asset server (via the region server) if it has its ...
int Expires
Definition: LandData.cs:40
delegate void MoveItemsAndLeaveCopy(IClientAPI remoteClient, List< InventoryItemBase > items, UUID destFolder)
delegate void SoundTrigger(UUID soundId, UUID ownerid, UUID objid, UUID parentid, double Gain, Vector3 Position, UInt64 Handle, float radius)
void SendPayPrice(UUID objectID, int[] payPrice)
void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting)
This is the starting point for sending a simulator packet out to the client
void SendMapBlock(List< MapBlockData > mapBlocks, uint flag)
GroupActiveProposalsRequest OnGroupActiveProposalsRequest
delegate void SetRegionTerrainSettings(float waterHeight, float terrainRaiseLimit, float terrainLowerLimit, bool estateSun, bool fixedSun, float sunHour, bool globalSun, bool estateFixed, float estateSunHour)
void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
void SendConfirmXfer(ulong xferID, uint PacketID)
OpenSim.Server.Handlers.Simulation.Utils Utils
virtual void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint externalIPEndPoint, string capsURL)
void SendKillObject(List< uint > localIDs)
Tell the client that an object has been deleted
void SetAgentThrottleSilent(int throttle, int setting)
Sets the throttles from values supplied caller
void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
delegate void ObjectIncludeInSearch(IClientAPI remoteClient, bool IncludeInSearch, uint localID)
delegate void ObjectRequest(uint localID, IClientAPI remoteClient)
delegate void ParcelAbandonRequest(int local_id, IClientAPI remote_client)
delegate void AcceptCallingCard(IClientAPI remoteClient, UUID transactionID, UUID folderID)
delegate void UpdateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort type, string name, UUID parentID)
void SendTeleportProgress(uint flags, string message)
GroupAccountTransactionsRequest OnGroupAccountTransactionsRequest
UpdateEstateAccessDeltaRequest OnUpdateEstateAccessDeltaRequest
delegate void UpdatePrimFlags(uint localID, bool UsePhysics, bool IsTemporary, bool IsPhantom, ExtraPhysicsData PhysData, IClientAPI remoteClient)
void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
Vector3 UserLocation
When teleporting is restricted to a certain point, this is the location that the user will be redirec...
Definition: LandData.cs:674
delegate void RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart, UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, bool RezSelected, bool RemoveItem, UUID fromTaskID)
OpenMetaverse.RegionFlags RegionFlags
Definition: LLClientView.cs:52
void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
delegate void SetEstateFlagsRequest(bool blockTerraform, bool noFly, bool allowDamage, bool blockLandResell, int maxAgents, float objectBonusFactor, int matureLevel, bool restrictPushObject, bool allowParcelChanges)
IPrimCounts PrimCounts
Prim counts for this land object.
Definition: ILandObject.cs:50
ParcelStatus Status
Status of Parcel, Leased, Abandoned, For Sale
Definition: LandData.cs:448
int PassPrice
Price to purchase a Pass to a restricted parcel
Definition: LandData.cs:596
Handles new client connections Constructor takes a single Packet and authenticates everything ...
Definition: LLClientView.cs:65
void PopulateStats(int inPackets, int outPackets, int unAckedBytes)
void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
delegate void ForceReleaseControls(IClientAPI remoteClient, UUID agentID)
delegate void StopAnim(IClientAPI remoteClient, UUID animID)
ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateImprovedTerseBlock(ISceneEntity entity, bool sendTexture)
delegate void EstateChangeCovenantRequest(IClientAPI remoteClient, UUID newCovenantID)
delegate void ClientChangeObject(uint localID, object data, IClientAPI remoteClient)
delegate void SetAlwaysRun(IClientAPI remoteClient, bool SetAlwaysRun)
FetchInventoryDescendents OnFetchInventoryDescendents
delegate void TextureRequest(Object sender, TextureRequestArgs e)
SetEstateTerrainBaseTexture OnSetEstateTerrainBaseTexture
delegate void DelinkObjects(List< uint > primIds, IClientAPI client)
uint RegionSizeY
X dimension of the region.
Definition: RegionInfo.cs:169
OpenMetaverse.StructuredData.OSDMap OSDMap
void SendAgentAlertMessage(string message, bool modal)
Send an agent alert message to the client.
delegate void ClassifiedInfoUpdate(UUID classifiedID, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, Vector3 globalPos, byte classifiedFlags, int price, IClientAPI client)
delegate void AvatarNowWearing(IClientAPI sender, AvatarWearingArgs e)
delegate void FriendshipTermination(IClientAPI remoteClient, UUID ExID)
delegate void GroupActiveProposalsRequest(IClientAPI client, UUID agentID, UUID groupID, UUID transactionID, UUID sessionID)
void SendPickInfoReply(UUID pickID, UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled)
delegate void ActivateGesture(IClientAPI client, UUID gestureid, UUID assetId)
EventNotificationAddRequest OnEventNotificationAddRequest
delegate void ParcelGodForceOwner(int local_id, UUID ownerID, IClientAPI remote_client)
bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync, bool inEngine)
Add a handler for the given packet type.
Vector3 UserLookAt
When teleporting is restricted to a certain point, this is the rotation that the user will be positio...
Definition: LandData.cs:690
A scene object group is conceptually an object in the scene. The object is constituted of SceneObject...
CommitEstateTerrainTextureRequest OnCommitEstateTerrainTextureRequest
void SendOfferCallingCard(UUID srcID, UUID transactionID)
AgentAlertMessagePacket BuildAgentAlertPacket(string message, bool modal)
Construct an agent alert packet
void SendBannedUserList(UUID invoice, EstateBan[] bl, uint estateID)
delegate void TeleportLocationRequest(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
int MediaHeight
Height of parcel media render
Definition: LandData.cs:175
virtual void RegisterLocalPacketHandlers()
This is a different way of processing packets then ProcessInPacket
delegate void UserInfoRequest(IClientAPI client)
Represents an item in a task inventory
void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
Dictionary< string, object > ServiceURLs
sbyte Type
(sbyte) AssetType enum
Definition: AssetBase.cs:198
AsyncPacketProcess(LLClientView pClientview, PacketMethod pMethod, Packet pPack)
Dictionary< string, int > GenericRequests
Definition: ClientInfo.cs:65
delegate void LinkInventoryItem(IClientAPI remoteClient, UUID transActionID, UUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, UUID olditemID)
delegate void EstateTeleportAllUsersHomeRequest(IClientAPI remoteClient, UUID invoice, UUID senderID)
delegate void AgentSit(IClientAPI remoteClient, UUID agentID)
delegate void ParcelObjectOwnerRequest(int local_id, IClientAPI remote_client)
delegate void UpdatePrimTexture(uint localID, byte[] texture, IClientAPI remoteClient)
GroupAccountSummaryRequest OnGroupAccountSummaryRequest
bool ObscureMusic
Whether to obscure parcel music URL
Definition: LandData.cs:143
void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
delegate void DirFindQuery(IClientAPI remoteClient, UUID queryID, string queryText, uint queryFlags, int queryStart)
delegate void ParcelBuy(UUID agentId, UUID groupId, bool final, bool groupOwned, bool removeContribution, int parcelLocalID, int parcelArea, int parcelPrice, bool authenticated)
Definition: LandData.cs:37
bool HandleObjectGroupRequest(IClientAPI sender, Packet Pack)
delegate void MoneyTransferRequest(UUID sourceID, UUID destID, int amount, int transactionType, string description)
delegate void AddNewPrim(UUID ownerID, UUID groupID, Vector3 RayEnd, Quaternion rot, PrimitiveBaseShape shape, byte bypassRaycast, Vector3 RayStart, UUID RayTargetID, byte RayEndIsIntersection)
void SendAttachedSoundGainChange(UUID objectID, float gain)
void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
delegate void ParcelDeedToGroup(int local_id, UUID group_id, IClientAPI remote_client)
delegate void PickGodDelete(IClientAPI client, UUID agentID, UUID pickID, UUID queryID)
void SendAvatarPicksReply(UUID targetID, Dictionary< UUID, string > picks)
void SendSunPos(Vector3 Position, Vector3 Velocity, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
Update the client as to where the sun is currently located.
Action< Vector3, bool, bool > OnAutoPilotGo
int SimwideArea
Number of meters^2 in the Simulator
Definition: LandData.cs:627
delegate void ObjectDuplicate(uint localID, Vector3 offset, uint dupeFlags, UUID AgentID, UUID GroupID)
void SendEntityUpdate(ISceneEntity entity, PrimUpdateFlags updateFlags)
Generate one of the object update packets based on PrimUpdateFlags and broadcast the packet to client...
virtual void SendCloudData(float[] cloudDensity)
Send the cloud matrix to the client
EventNotificationRemoveRequest OnEventNotificationRemoveRequest
void SendTransferAbort(TransferRequestPacket transferRequest)
bool ObscureMedia
Whether to obscure parcel media URL
Definition: LandData.cs:127
delegate void ClassifiedGodDelete(UUID classifiedID, UUID queryID, IClientAPI client)
delegate void GenericCall2()
void Close()
Close down the client view
delegate void FreezeUserUpdate(IClientAPI client, UUID parcelowner, uint flags, UUID target)
Enapsulate statistics for a simulator/scene.
Definition: SimStats.cs:39
void SendGroupAccountingSummary(IClientAPI sender, UUID groupID, uint moneyAmt, int totalTier, int usedTier)
delegate void CopyInventoryItem(IClientAPI remoteClient, uint callbackID, UUID oldAgentID, UUID oldItemID, UUID newFolderID, string newName)
List< ObjectUpdatePacket.ObjectDataBlock > m_fullUpdateDataBlocksBuilder
RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily
delegate void TerrainUnacked(IClientAPI remoteClient, int patchX, int patchY)
delegate void FriendActionDelegate(IClientAPI remoteClient, UUID transactionID, List< UUID > callingCardFolders)
delegate void GenericMessage(Object sender, string method, List< String > args)
EstateTeleportOneUserHomeRequest OnEstateTeleportOneUserHomeRequest
void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
LLClientView(Scene scene, LLUDPServer udpServer, LLUDPClient udpClient, AuthenticateResponse sessionInfo, UUID agentId, UUID sessionId, uint circuitCode)
Constructor
delegate void RequestGodlikePowers(UUID AgentID, UUID SessionID, UUID token, bool GodLike, IClientAPI remote_client)
void DeactivateGesture(UUID assetId, UUID gestureId)
void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
delegate void GenericCall7(IClientAPI remoteClient, uint localID, string message)
delegate void ObjectSelect(uint localID, IClientAPI remoteClient)
System.Timers.Timer Timer
delegate bool PacketMethod(IClientAPI simClient, Packet packet)
delegate void GodUpdateRegionInfoUpdate(IClientAPI client, float BillableFactor, ulong EstateID, ulong RegionFlags, byte[] SimName, int RedirectX, int RedirectY)
ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(SceneObjectPart data, UUID recipientID)
virtual UUID Owner
The agent who's inventory this is contained by
delegate void NetworkStats(int inPackets, int outPackets, int unAckedBytes)
delegate void SaveStateHandler(IClientAPI client, UUID agentID)
virtual void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, uint flags, string capsURL)
EstateTeleportAllUsersHomeRequest OnEstateTeleportAllUsersHomeRequest
delegate void MuteListEntryRemove(IClientAPI client, UUID MuteID, string Name)
void SendWearables(AvatarWearable[] wearables, int serial)
Tell this client what items it should be wearing now
delegate void DeGrabObject(uint localID, IClientAPI remoteClient, List< SurfaceTouchEventArgs > surfaceArgs)
delegate void EstateDebugRegionRequest(IClientAPI remoteClient, UUID invoice, UUID senderID, bool scripted, bool collisionEvents, bool physics)
This class was created to refactor OutPacket out of AssetCache There is a conflict between OpenSim...
delegate void StartAnim(IClientAPI remoteClient, UUID animID)
void SetChildAgentThrottle(byte[] throttles)
Sets the throttles from values supplied by the client
void SendCoarseLocationUpdate(List< UUID > users, List< Vector3 > CoarseLocations)
void SendBlueBoxMessage(UUID FromAvatarID, String FromAvatarName, String Message)
Send the client an Estate message blue box pop-down with a single OK button
void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
void SendBulkUpdateInventoryItem(InventoryItemBase item)
void SendCreateGroupReply(UUID groupID, bool success, string message)
void SendGenericMessage(string method, UUID invoice, List< byte[]> message)
void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
Sent when an agent completes its movement into a region.
Tracks state for a client UDP connection and provides client-specific methods
Definition: LLUDPClient.cs:66
void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
bool CanGetAgentInventoryItem(IClientAPI remoteClient, UUID itemID, UUID requestID)
Does the client have sufficient permissions to retrieve the inventory item?
GroupAccountDetailsRequest OnGroupAccountDetailsRequest
void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
bool IsDeleted
Signals whether this entity was in a scene but has since been removed from it.
Definition: EntityBase.cs:73
Asset class. All Assets are reference by this class or a class derived from this class ...
Definition: AssetBase.cs:49
void SendForceClientSelectObjects(List< uint > ObjectIDs)
void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
delegate void TeleportLureRequest(UUID lureID, uint teleportFlags, IClientAPI client)
delegate void RequestTerrain(IClientAPI remoteClient, string clientFileName)
void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
delegate void ParcelSetOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime)
uint AuctionID
ID of auction (3rd Party Integration) when parcel is being auctioned
Definition: LandData.cs:252
delegate void EventNotificationAddRequest(uint EventID, IClientAPI client)
delegate void ObjectBuy(IClientAPI remoteClient, UUID agentID, UUID sessionID, UUID groupID, UUID categoryID, uint localID, byte saleType, int salePrice)
delegate void EventGodDelete(uint eventID, UUID queryID, string queryText, uint queryFlags, int queryStart, IClientAPI client)
delegate void SimulatorBlueBoxMessageRequest(IClientAPI remoteClient, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
delegate void ParcelJoinRequest(int west, int south, int east, int north, IClientAPI remote_client)
delegate void EstateRestartSimRequest(IClientAPI remoteClient, int secondsTilReboot)
delegate void MoveInventoryFolder(IClientAPI remoteClient, UUID folderID, UUID parentID)
void SendBulkUpdateInventory(InventoryNodeBase node)
Used by the server to inform the client of new inventory items and folders.
delegate void AgentRequestSit(IClientAPI remoteClient, UUID agentID, UUID targetID, Vector3 offset)
Dictionary< string, int > SyncRequests
Definition: ClientInfo.cs:63
delegate void CommitEstateTerrainTextureRequest(IClientAPI remoteClient)
delegate void UpdateAvatarProperties(IClientAPI remoteClient, UserProfileData ProfileData)
void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
Send land properties to the client.
delegate void UpdateEstateAccessDeltaRequest(IClientAPI remote_client, UUID invoice, int estateAccessType, UUID user)
string Report()
Report back collected statistical information.
void SendJoinGroupReply(UUID groupID, bool success)
void AssetReceived(string id, Object sender, AssetBase asset)
When we get a reply back from the asset service in response to a client request, send back the data...
void SendGroupNameReply(UUID groupLLUID, string GroupName)
delegate void MoveObject(UUID objectID, Vector3 offset, Vector3 grapPos, IClientAPI remoteClient, List< SurfaceTouchEventArgs > surfaceArgs)
void SendTeleportFailed(string reason)
Inform the client that a teleport attempt has failed
delegate void ObjectDuplicateOnRay(uint localID, uint dupeFlags, UUID AgentID, UUID GroupID, UUID RayTargetObj, Vector3 RayEnd, Vector3 RayStart, bool BypassRaycast, bool RayEndIsIntersection, bool CopyCenters, bool CopyRotates)
void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
delegate void StatusChange(bool status)
void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
Send the next packet for a series of packets making up a single texture, as established by SendImageF...
delegate void UDPAssetUploadRequest(IClientAPI remoteClient, UUID assetID, UUID transaction, sbyte type, byte[] data, bool storeLocal, bool tempFile)
delegate void MuteListEntryUpdate(IClientAPI client, UUID MuteID, string Name, int type, uint flags)
void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID, byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight, byte mediaLoop)
OpenSim.Region.ScriptEngine.Shared.LSL_Types.Quaternion rotation
Definition: ICM_Api.cs:32
void SendAnimations(UUID[] animations, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
UUID GroupID
Unique ID of the Group that owns
Definition: LandData.cs:342
delegate void EstateTeleportOneUserHomeRequest(IClientAPI remoteClient, UUID invoice, UUID senderID, UUID prey)
RegionFlags
Region flags used internally by OpenSimulator to store installation specific information about region...
Definition: RegionFlags.cs:40
void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory)
delegate void UpdateVector(uint localID, Vector3 pos, IClientAPI remoteClient)
delegate void UpdateShape(UUID agentID, uint localID, UpdateShapeArgs shapeBlock)
delegate void GrantUserFriendRights(IClientAPI client, UUID target, int rights)
void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
delegate void UpdateInventoryItem(IClientAPI remoteClient, UUID transactionID, UUID itemID, InventoryItemBase itemUpd)
An agent in the scene.
Definition: ISceneAgent.cs:39
delegate void ParcelGodMark(IClientAPI client, UUID agentID, int ParcelLocalID)
EstateBlueBoxMessageRequest OnEstateBlueBoxMessageRequest
delegate void DirPlacesQuery(IClientAPI remoteClient, UUID queryID, string queryText, int queryFlags, int category, string simName, int queryStart)
ChatFromViewer Arguments
delegate void GodlikeMessage(IClientAPI client, UUID requester, byte[] Method, byte[] Parameter)
Circuit data for an agent. Connection information shared between regions that accept UDP connections ...
uint AttachmentPoint
Attachment point of this scene object to an avatar.
delegate void DeRezObject(IClientAPI remoteClient, List< uint > localIDs, UUID groupID, DeRezAction action, UUID destinationID)
float PassHours
How long in hours a Pass to the parcel is given
Definition: LandData.cs:581
Inventory Item - contains all the properties associated with an individual inventory piece...
delegate void MuteListRequest(IClientAPI client, uint muteCRC)
RequestObjectPropertiesFamily OnObjectGroupRequest
void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
void SendInitiateDownload(string simFileName, string clientFileName)
void SendSimStats(SimStats stats)
Send statistical information about the sim to the client.
delegate void ScriptReset(IClientAPI remoteClient, UUID objectID, UUID itemID)
bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler, bool doAsync)
Add a handler for the given packet type.
void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price)
delegate void ObjectAttach(IClientAPI remoteClient, uint objectLocalID, uint AttachmentPt, bool silent)
void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType, bool doAutomaticSplitting, UnackedPacketMethod method)
This is the starting point for sending a simulator packet out to the client
void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
delegate void CreateInventoryFolder(IClientAPI remoteClient, UUID folderID, ushort folderType, string folderName, UUID parentID)
bool HandleMultipleObjUpdate(IClientAPI simClient, Packet packet)
UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation
delegate void GroupAccountDetailsRequest(IClientAPI client, UUID agentID, UUID groupID, UUID transactionID, UUID sessionID)
void SendObjectPropertiesFamilyData(ISceneEntity entity, uint requestFlags)
void SendRegionHandle(UUID regionID, ulong handle)
delegate void DetailedEstateDataRequest(IClientAPI remoteClient, UUID invoice)
void SendPartFullUpdate(ISceneEntity ent, uint?parentID)
delegate void MapItemRequest(IClientAPI remoteClient, uint flags, uint EstateID, bool godlike, uint itemtype, ulong regionhandle)
Details of a Parcel of land
Definition: LandData.cs:47
delegate void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
void SendFindAgent(UUID HunterID, UUID PreyID, double GlobalX, double GlobalY)
void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay, int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
delegate void ObjectExtraParams(UUID agentID, uint localID, ushort type, bool inUse, byte[] data)
delegate void ObjectOwner(IClientAPI remoteClient, UUID ownerID, UUID groupID, List< uint > localIDs)
delegate void ParcelReturnObjectsRequest(int local_id, uint return_type, UUID[] agent_ids, UUID[] selected_ids, IClientAPI remote_client)
void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, byte audible)
delegate void EstateChangeInfo(IClientAPI client, UUID invoice, UUID senderID, UInt32 param1, UInt32 param2)
delegate void MoveTaskInventory(IClientAPI remoteClient, UUID folderID, uint localID, UUID itemID)
Information about a particular user known to the userserver
delegate void ParcelPropertiesRequest(int start_x, int start_y, int end_x, int end_y, int sequence_id, bool snap_selection, IClientAPI remote_client)
OpenSim.Framework.AssetLandmark AssetLandmark
Definition: LLClientView.cs:51
void SendGroupAccountingDetails(IClientAPI sender, UUID groupID, UUID transactionID, UUID sessionID, int amt)
delegate void ModifyTerrain(UUID user, float height, float seconds, byte size, byte action, float north, float west, float south, float east, UUID agentId)
OpenMetaverse.StructuredData.OSD OSD
delegate void SendPostcard(IClientAPI client)
delegate void ChangeAnim(UUID animID, bool addOrRemove, bool sendPack)
delegate void UpdateAgent(IClientAPI remoteClient, AgentUpdateArgs agentData)
virtual bool HandleLogout(IClientAPI client, Packet packet)
Handler called when we receive a logout packet.
delegate void GodLandStatRequest(int parcelID, uint reportType, uint requestflags, string filter, IClientAPI remoteClient)
void SendAvatarClassifiedReply(UUID targetID, Dictionary< UUID, string > classifieds)
delegate void ParcelDwellRequest(int localID, IClientAPI client)
The LLUDP server for a region. This handles incoming and outgoing packets for all UDP connections to ...
Definition: LLUDPServer.cs:252
delegate void MoveInventoryItem(IClientAPI remoteClient, List< InventoryItemBase > items)
bool HandleAgentTextureCached(IClientAPI simclient, Packet packet)
delegate void AvatarNotesUpdate(IClientAPI client, UUID targetID, string notes)
delegate void GroupAccountTransactionsRequest(IClientAPI client, UUID agentID, UUID groupID, UUID transactionID, UUID sessionID)
void SendLandAccessListData(List< LandAccessEntry > accessList, uint accessFlag, int localLandID)
delegate void BuyObjectInventory(IClientAPI remoteClient, UUID agentID, UUID sessionID, UUID objectID, UUID itemID, UUID folderID)
PurgeInventoryDescendents OnPurgeInventoryDescendents
delegate void LinkObjects(IClientAPI remoteClient, uint parent, List< uint > children)
delegate void ParcelDivideRequest(int west, int south, int east, int north, IClientAPI remote_client)
ObjectUpdatePacket.ObjectDataBlock CreateAvatarUpdateBlock(ScenePresence data)
void SendBulkUpdateInventoryFolder(InventoryFolderBase folderBase)
void SendImageNotFound(UUID imageid)
Tell the client that the requested texture cannot be found
void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List< Vector3 > SpawnPoint)
delegate void StartLure(byte lureType, string message, UUID targetID, IClientAPI client)
void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
delegate void EconomyDataRequest(IClientAPI client)
delegate void GodKickUser(UUID GodAgentID, UUID GodSessionID, UUID AgentID, uint kickflags, byte[] reason)
byte LandingType
Determines if people are able to teleport where they please on the parcel or if they get constrainted...
Definition: LandData.cs:418
delegate ISceneEntity RezSingleAttachmentFromInv(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
delegate void ParcelReclaim(int local_id, IClientAPI remote_client)
override bool TryGetScenePresence(UUID agentID, out ScenePresence sp)
Try to get a scene presence from the scene
Definition: Scene.cs:5401
void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
AgentCircuitData agentcircuit
Definition: ClientInfo.cs:37
UUID ID
A UUID containing the ID for the inventory node itself
void SendCameraConstraint(Vector4 ConstraintPlane)
delegate void RegionHandleRequest(IClientAPI remoteClient, UUID regionID)
virtual void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
Tell the client that the given neighbour region is ready to receive a child agent.
delegate void EstateBlueBoxMessageRequest(IClientAPI remoteClient, UUID invoice, UUID senderID, UUID sessionID, string senderName, string message)
delegate void SetEstateTerrainDetailTexture(IClientAPI remoteClient, int corner, UUID side)
delegate void SpinStart(UUID objectID, IClientAPI remoteClient)
delegate void DeactivateGesture(IClientAPI client, UUID gestureid)
delegate void ParcelInfoRequest(IClientAPI remoteClient, UUID parcelID)
delegate void SpinObject(UUID objectID, Quaternion rotation, IClientAPI remoteClient)
int Owner
Parcel owner owned prims
Definition: IPrimCounts.cs:37
virtual void Start()
Start processing for this client.
void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
delegate void PlacesQuery(UUID QueryID, UUID TransactionID, string QueryText, uint QueryFlags, byte Category, string SimName, IClientAPI client)
delegate void ClassifiedDelete(UUID classifiedID, IClientAPI client)
System.Timers.Timer Timer
Definition: LLClientView.cs:50
void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId)
IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)
PrimUpdateFlags
Specifies the fields that have been changed when sending a prim or avatar update
Definition: IClientAPI.cs:677
OSDMap OReport(string uptime, string version)
Report back collected statistical information as an OSDMap of key/values
Args to return to a client that queries picker data
void CloseWithoutChecks(bool sendStop)
Closes down the client view without first checking whether it is active.
delegate void RequestMapName(IClientAPI remoteClient, string mapName, uint flags)
delegate void SetEstateTerrainTextureHeights(IClientAPI remoteClient, int corner, float lowVal, float highVal)
delegate void ParcelAccessListUpdateRequest(UUID agentID, uint flags, int landLocalID, UUID transactionID, int sequenceID, int sections, List< LandAccessEntry > entries, IClientAPI remote_client)
void HandleAutopilot(Object sender, string method, List< String > args)
void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List< InventoryItemBase > items, List< InventoryFolderBase > folders, int version, bool fetchFolders, bool fetchItems)
Send information about the items contained in a folder to the client.
delegate void ParcelSelectObjects(int land_local_id, int request_type, List< UUID > returnIDs, IClientAPI remote_client)
delegate void ClassifiedInfoRequest(UUID classifiedID, IClientAPI client)
string MediaDescription
parcel media description
Definition: LandData.cs:721
virtual string Name
The name of the node (64 characters or less)
string XReport(string uptime, string version)
Report back collected statistical information in json
delegate void ConfirmXfer(IClientAPI remoteClient, ulong xferID, uint packetID)
delegate void DeclineCallingCard(IClientAPI remoteClient, UUID transactionID)
void SendRegionHandshake(RegionInfo regionInfo, RegionHandshakeArgs args)
bool HandleGenericMessage(IClientAPI sender, Packet pack)
delegate void EstateManageTelehub(IClientAPI client, UUID invoice, UUID senderID, string cmd, UInt32 param1)
void SendChangeUserRights(UUID agentID, UUID friendID, int rights)
void OutPacket(Packet packet, ThrottleOutPacketType throttlePacketType)
This is the starting point for sending a simulator packet out to the client
void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
delegate void GroupVoteHistoryRequest(IClientAPI client, UUID agentID, UUID groupID, UUID transactionID, UUID sessionID)
void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
Send information about the given agent's appearance to another client.
delegate void GenericCall1(IClientAPI remoteClient)
Common base class for inventory nodes of different types (files, folders, etc.)
void SendLayerData(int px, int py, float[] map)
delegate void RequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID)
delegate void SetEstateTerrainBaseTexture(IClientAPI remoteClient, int corner, UUID side)
delegate void ParcelAccessListRequest(UUID agentID, UUID sessionID, uint flags, int sequenceID, int landLocalID, IClientAPI remote_client)
delegate void BakeTerrain(IClientAPI remoteClient)
delegate void PickDelete(IClientAPI client, UUID pickID)
delegate void OfferCallingCard(IClientAPI remoteClient, UUID destID, UUID transactionID)
delegate void FetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID)
uint Flags
Parcel settings. Access flags, Fly, NoPush, Voice, Scripts allowed, etc. ParcelFlags ...
Definition: LandData.cs:402
delegate void DirPopularQuery(IClientAPI remoteClient, UUID queryID, uint queryFlags)
Packet GetPacket(PacketType type)
Gets a packet of the given type.
Definition: PacketPool.cs:116
void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
delegate void SetScriptRunning(IClientAPI remoteClient, UUID objectID, UUID itemID, bool running)
delegate void FetchInventoryDescendents(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder)
void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
bool MediaLoop
Whether to loop parcel media
Definition: LandData.cs:159
void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item)
static OSD BuildEvent(string eventName, OSD eventBody)
void SetChildAgentThrottle(byte[] throttles, float factor)
delegate void RequestXfer(IClientAPI remoteClient, ulong xferID, string fileName)
EstateChangeCovenantRequest OnEstateChangeCovenantRequest
void ActivateGesture(UUID assetId, UUID gestureId)
void SendInstantMessage(GridInstantMessage im)
Send an instant message to this client
void SendBulkUpdateInventory(InventoryFolderBase[] folders, InventoryItemBase[] items)
delegate void RemoveInventoryFolder(IClientAPI remoteClient, List< UUID > folderIDs)
delegate void LandUndo(IClientAPI remoteClient)
delegate void FindAgentUpdate(IClientAPI client, UUID hunter, UUID target)
delegate void XferReceive(IClientAPI remoteClient, ulong xferID, uint packetID, byte[] data)
void SendAlertMessage(string message)
Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief dur...
delegate void SetAppearance(IClientAPI remoteClient, Primitive.TextureEntry textureEntry, byte[] visualParams, Vector3 AvSize, WearableCacheItem[] CacheItems)
void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
Material
Material type for a primitive
Definition: OdeScene.cs:79
ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest
delegate void UpdateUserInfo(bool imViaEmail, bool visible, IClientAPI client)
void SendAssetNotFound(AssetRequestToClient req)
void ProcessInPacket(Packet packet)
Entryway from the client to the simulator. All UDP packets from the client will end up here ...
delegate void EstateCovenantRequest(IClientAPI remote_client)
delegate void ParcelPropertiesUpdateRequest(LandUpdateArgs args, int local_id, IClientAPI remote_client)
void SendGroupTransactionsSummaryDetails(IClientAPI sender, UUID groupID, UUID transactionID, UUID sessionID, int amt)
void SendLandParcelOverlay(byte[] data, int sequence_id)
DetailedEstateDataRequest OnDetailedEstateDataRequest
void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
delegate void SpinStop(UUID objectID, IClientAPI remoteClient)
ParcelReturnObjectsRequest OnParcelReturnObjectsRequest
bool CheckAgentUpdateSignificance(AgentUpdatePacket.AgentDataBlock x)
This checks the update significance against the last update made.
delegate void ChatMessage(Object sender, OSChatMessage e)
int LocalID
Internal ID of the parcel. Sometimes the client will try to use this value
Definition: LandData.cs:463
void SendGroupVoteHistory(UUID groupID, UUID transactionID, GroupVoteHistory[] Votes)
delegate void RequestObjectPropertiesFamily(IClientAPI remoteClient, UUID AgentID, uint RequestFlags, UUID TaskID)
string Description
Parcel Description
Definition: LandData.cs:387
void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
This class handles UDP texture requests.
void SoundTrigger(UUID soundId, UUID owerid, UUID Objectid, UUID ParentId, float Gain, Vector3 Position, UInt64 Handle)
SetEstateTerrainTextureHeights OnSetEstateTerrainTextureHeights
SetEstateTerrainDetailTexture OnSetEstateTerrainDetailTexture
delegate void AvatarPickerRequest(IClientAPI remoteClient, UUID agentdata, UUID queryID, string UserQuery)
int Area
Area in meters^2 the parcel contains
Definition: LandData.cs:237
delegate void ViewerEffectEventHandler(IClientAPI sender, List< ViewerEffectEventHandlerArg > args)
void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
delegate void RegionInfoRequest(IClientAPI remote_client)
delegate void DirLandQuery(IClientAPI remoteClient, UUID queryID, uint queryFlags, uint searchType, int price, int area, int queryStart)
void SendUserInfoReply(bool imViaEmail, bool visible, string email)
delegate void TrackAgentUpdate(IClientAPI client, UUID hunter, UUID target)
delegate void RetrieveInstantMessages(IClientAPI client)
delegate void AvatarInterestUpdate(IClientAPI client, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages)
void SetClientOption(string option, string value)
void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
delegate void ObjectDeselect(uint localID, IClientAPI remoteClient)
UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition
void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List< AvatarPickerReplyDataArgs > Data)
ObjectUpdateCompressedPacket.ObjectDataBlock CreateCompressedUpdateBlock(SceneObjectPart part, PrimUpdateFlags updateFlags)
virtual void SendWindData(Vector2[] windSpeeds)
Send the wind matrix to the client
delegate void UnackedPacketMethod(OutgoingPacket oPacket)
delegate void TeleportLandmarkRequest(IClientAPI remoteClient, AssetLandmark lm)
ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest
void SendAdminResponse(UUID Token, uint AdminLevel)
delegate void AgentFOV(IClientAPI client, float verticalAngle)
static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
void MakeAssetRequest(TransferRequestPacket transferRequest, UUID taskID)
Make an asset request to the asset service in response to a client request.
Used to serialize a whole inventory for transfer over the network.
SimulatorBlueBoxMessageRequest OnSimulatorBlueBoxMessageRequest
bool IsAttachment
Is this scene object acting as an attachment?
delegate void UUIDNameRequest(UUID id, IClientAPI remote_client)
delegate void GetScriptRunning(IClientAPI remoteClient, UUID objectID, UUID itemID)
delegate void CreateNewInventoryItem(IClientAPI remoteClient, UUID transActionID, UUID folderID, uint callbackID, string description, string name, sbyte invType, sbyte type, byte wearableType, uint nextOwnerMask, int creationDate)
Dictionary< string, int > AsyncRequests
Definition: ClientInfo.cs:64
delegate void EventNotificationRemoveRequest(uint EventID, IClientAPI client)
Holds a reference to the LLUDPClientthis packet is destined for, along with the serialized packet dat...
virtual void SendLayerData(float[] map)
Send the region heightmap to the client This method is only called when not doing intellegent terrain...
delegate void SimWideDeletesDelegate(IClientAPI client, UUID agentID, int flags, UUID targetID)
uint ParentID
If the avatar is sitting, the local ID of the prim that it's sitting on. If not sitting then zero...
delegate void MoneyBalanceRequest(IClientAPI remoteClient, UUID agentID, UUID sessionID, UUID TransactionID)
delegate void ChangeInventoryItemFlags(IClientAPI client, UUID itemID, uint flags)
void Close(bool sendStop, bool force)
Close this client
delegate void DisconnectUser()