diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.cs | 3091 |
1 files changed, 3090 insertions, 1 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/ClientView.cs index 28692bb..0933453 100644 --- a/OpenSim/Region/ClientStack/ClientView.cs +++ b/OpenSim/Region/ClientStack/ClientView.cs | |||
@@ -28,9 +28,11 @@ | |||
28 | using System; | 28 | using System; |
29 | using System.Collections.Generic; | 29 | using System.Collections.Generic; |
30 | using System.Net; | 30 | using System.Net; |
31 | using System.Net.Sockets; | ||
31 | using System.Text; | 32 | using System.Text; |
32 | using System.Threading; | 33 | using System.Threading; |
33 | using System.Timers; | 34 | using System.Timers; |
35 | using Axiom.Math; | ||
34 | using libsecondlife; | 36 | using libsecondlife; |
35 | using libsecondlife.Packets; | 37 | using libsecondlife.Packets; |
36 | using OpenSim.Framework; | 38 | using OpenSim.Framework; |
@@ -46,7 +48,7 @@ namespace OpenSim.Region.ClientStack | |||
46 | /// Handles new client connections | 48 | /// Handles new client connections |
47 | /// Constructor takes a single Packet and authenticates everything | 49 | /// Constructor takes a single Packet and authenticates everything |
48 | /// </summary> | 50 | /// </summary> |
49 | public partial class ClientView : IClientAPI | 51 | public class ClientView : IClientAPI |
50 | { | 52 | { |
51 | public static TerrainManager TerrainManager; | 53 | public static TerrainManager TerrainManager; |
52 | 54 | ||
@@ -552,5 +554,3092 @@ namespace OpenSim.Region.ClientStack | |||
552 | { | 554 | { |
553 | ClientThread.Abort(); | 555 | ClientThread.Abort(); |
554 | } | 556 | } |
557 | |||
558 | // Previously ClientView.API partial class | ||
559 | public event Action<IClientAPI> OnLogout; | ||
560 | public event Action<IClientAPI> OnConnectionClosed; | ||
561 | public event ViewerEffectEventHandler OnViewerEffect; | ||
562 | public event ImprovedInstantMessage OnInstantMessage; | ||
563 | public event ChatFromViewer OnChatFromViewer; | ||
564 | public event TextureRequest OnRequestTexture; | ||
565 | public event RezObject OnRezObject; | ||
566 | public event GenericCall4 OnDeRezObject; | ||
567 | public event ModifyTerrain OnModifyTerrain; | ||
568 | public event Action<IClientAPI> OnRegionHandShakeReply; | ||
569 | public event GenericCall2 OnRequestWearables; | ||
570 | public event SetAppearance OnSetAppearance; | ||
571 | public event GenericCall2 OnCompleteMovementToRegion; | ||
572 | public event UpdateAgent OnAgentUpdate; | ||
573 | public event AgentRequestSit OnAgentRequestSit; | ||
574 | public event AgentSit OnAgentSit; | ||
575 | public event AvatarPickerRequest OnAvatarPickerRequest; | ||
576 | public event StartAnim OnStartAnim; | ||
577 | public event Action<IClientAPI> OnRequestAvatarsData; | ||
578 | public event LinkObjects OnLinkObjects; | ||
579 | public event DelinkObjects OnDelinkObjects; | ||
580 | public event UpdateVector OnGrabObject; | ||
581 | public event ObjectSelect OnDeGrabObject; | ||
582 | public event ObjectDuplicate OnObjectDuplicate; | ||
583 | public event MoveObject OnGrabUpdate; | ||
584 | public event AddNewPrim OnAddPrim; | ||
585 | public event RequestGodlikePowers OnRequestGodlikePowers; | ||
586 | public event GodKickUser OnGodKickUser; | ||
587 | public event ObjectExtraParams OnUpdateExtraParams; | ||
588 | public event UpdateShape OnUpdatePrimShape; | ||
589 | public event ObjectSelect OnObjectSelect; | ||
590 | public event ObjectDeselect OnObjectDeselect; | ||
591 | public event GenericCall7 OnObjectDescription; | ||
592 | public event GenericCall7 OnObjectName; | ||
593 | public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily; | ||
594 | public event UpdatePrimFlags OnUpdatePrimFlags; | ||
595 | public event UpdatePrimTexture OnUpdatePrimTexture; | ||
596 | public event UpdateVector OnUpdatePrimGroupPosition; | ||
597 | public event UpdateVector OnUpdatePrimSinglePosition; | ||
598 | public event UpdatePrimRotation OnUpdatePrimGroupRotation; | ||
599 | public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; | ||
600 | public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; | ||
601 | public event UpdateVector OnUpdatePrimScale; | ||
602 | public event StatusChange OnChildAgentStatus; | ||
603 | public event GenericCall2 OnStopMovement; | ||
604 | public event Action<LLUUID> OnRemoveAvatar; | ||
605 | public event RequestMapBlocks OnRequestMapBlocks; | ||
606 | public event RequestMapName OnMapNameRequest; | ||
607 | public event TeleportLocationRequest OnTeleportLocationRequest; | ||
608 | public event DisconnectUser OnDisconnectUser; | ||
609 | public event RequestAvatarProperties OnRequestAvatarProperties; | ||
610 | public event SetAlwaysRun OnSetAlwaysRun; | ||
611 | |||
612 | public event CreateNewInventoryItem OnCreateNewInventoryItem; | ||
613 | public event CreateInventoryFolder OnCreateNewInventoryFolder; | ||
614 | public event FetchInventoryDescendents OnFetchInventoryDescendents; | ||
615 | public event FetchInventory OnFetchInventory; | ||
616 | public event RequestTaskInventory OnRequestTaskInventory; | ||
617 | public event UpdateInventoryItemTransaction OnUpdateInventoryItem; | ||
618 | public event CopyInventoryItem OnCopyInventoryItem; | ||
619 | public event UDPAssetUploadRequest OnAssetUploadRequest; | ||
620 | public event XferReceive OnXferReceive; | ||
621 | public event RequestXfer OnRequestXfer; | ||
622 | public event ConfirmXfer OnConfirmXfer; | ||
623 | public event RezScript OnRezScript; | ||
624 | public event UpdateTaskInventory OnUpdateTaskInventory; | ||
625 | public event RemoveTaskInventory OnRemoveTaskItem; | ||
626 | |||
627 | public event UUIDNameRequest OnNameFromUUIDRequest; | ||
628 | |||
629 | public event ParcelPropertiesRequest OnParcelPropertiesRequest; | ||
630 | public event ParcelDivideRequest OnParcelDivideRequest; | ||
631 | public event ParcelJoinRequest OnParcelJoinRequest; | ||
632 | public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; | ||
633 | public event ParcelSelectObjects OnParcelSelectObjects; | ||
634 | public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; | ||
635 | public event EstateOwnerMessageRequest OnEstateOwnerMessage; | ||
636 | |||
637 | /// <summary> | ||
638 | /// | ||
639 | /// </summary> | ||
640 | public LLVector3 StartPos | ||
641 | { | ||
642 | get { return startpos; } | ||
643 | set { startpos = value; } | ||
644 | } | ||
645 | |||
646 | /// <summary> | ||
647 | /// | ||
648 | /// </summary> | ||
649 | private LLUUID m_agentId; | ||
650 | |||
651 | public LLUUID AgentId | ||
652 | { | ||
653 | get { return m_agentId; } | ||
654 | } | ||
655 | |||
656 | /// <summary> | ||
657 | /// | ||
658 | /// </summary> | ||
659 | public string FirstName | ||
660 | { | ||
661 | get { return firstName; } | ||
662 | } | ||
663 | |||
664 | /// <summary> | ||
665 | /// | ||
666 | /// </summary> | ||
667 | public string LastName | ||
668 | { | ||
669 | get { return lastName; } | ||
670 | } | ||
671 | |||
672 | #region Scene/Avatar to Client | ||
673 | |||
674 | /// <summary> | ||
675 | /// | ||
676 | /// </summary> | ||
677 | /// <param name="regionInfo"></param> | ||
678 | public void SendRegionHandshake(RegionInfo regionInfo) | ||
679 | { | ||
680 | Encoding _enc = Encoding.ASCII; | ||
681 | RegionHandshakePacket handshake = new RegionHandshakePacket(); | ||
682 | |||
683 | handshake.RegionInfo.BillableFactor = regionInfo.EstateSettings.billableFactor; | ||
684 | handshake.RegionInfo.IsEstateManager = false; | ||
685 | handshake.RegionInfo.TerrainHeightRange00 = regionInfo.EstateSettings.terrainHeightRange0; | ||
686 | handshake.RegionInfo.TerrainHeightRange01 = regionInfo.EstateSettings.terrainHeightRange1; | ||
687 | handshake.RegionInfo.TerrainHeightRange10 = regionInfo.EstateSettings.terrainHeightRange2; | ||
688 | handshake.RegionInfo.TerrainHeightRange11 = regionInfo.EstateSettings.terrainHeightRange3; | ||
689 | handshake.RegionInfo.TerrainStartHeight00 = regionInfo.EstateSettings.terrainStartHeight0; | ||
690 | handshake.RegionInfo.TerrainStartHeight01 = regionInfo.EstateSettings.terrainStartHeight1; | ||
691 | handshake.RegionInfo.TerrainStartHeight10 = regionInfo.EstateSettings.terrainStartHeight2; | ||
692 | handshake.RegionInfo.TerrainStartHeight11 = regionInfo.EstateSettings.terrainStartHeight3; | ||
693 | handshake.RegionInfo.SimAccess = (byte) regionInfo.EstateSettings.simAccess; | ||
694 | handshake.RegionInfo.WaterHeight = regionInfo.EstateSettings.waterHeight; | ||
695 | |||
696 | |||
697 | handshake.RegionInfo.RegionFlags = (uint) regionInfo.EstateSettings.regionFlags; | ||
698 | |||
699 | handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0"); | ||
700 | handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID; | ||
701 | handshake.RegionInfo.TerrainBase0 = regionInfo.EstateSettings.terrainBase0; | ||
702 | handshake.RegionInfo.TerrainBase1 = regionInfo.EstateSettings.terrainBase1; | ||
703 | handshake.RegionInfo.TerrainBase2 = regionInfo.EstateSettings.terrainBase2; | ||
704 | handshake.RegionInfo.TerrainBase3 = regionInfo.EstateSettings.terrainBase3; | ||
705 | handshake.RegionInfo.TerrainDetail0 = regionInfo.EstateSettings.terrainDetail0; | ||
706 | handshake.RegionInfo.TerrainDetail1 = regionInfo.EstateSettings.terrainDetail1; | ||
707 | handshake.RegionInfo.TerrainDetail2 = regionInfo.EstateSettings.terrainDetail2; | ||
708 | handshake.RegionInfo.TerrainDetail3 = regionInfo.EstateSettings.terrainDetail3; | ||
709 | handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting? | ||
710 | |||
711 | OutPacket(handshake, ThrottleOutPacketType.Task); | ||
712 | } | ||
713 | |||
714 | /// <summary> | ||
715 | /// | ||
716 | /// </summary> | ||
717 | /// <param name="regInfo"></param> | ||
718 | public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) | ||
719 | { | ||
720 | AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); | ||
721 | mov.AgentData.SessionID = m_sessionId; | ||
722 | mov.AgentData.AgentID = AgentId; | ||
723 | mov.Data.RegionHandle = regInfo.RegionHandle; | ||
724 | mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this | ||
725 | |||
726 | if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0)) | ||
727 | { | ||
728 | mov.Data.Position = startpos; | ||
729 | } | ||
730 | else | ||
731 | { | ||
732 | mov.Data.Position = pos; | ||
733 | } | ||
734 | mov.Data.LookAt = look; | ||
735 | |||
736 | OutPacket(mov, ThrottleOutPacketType.Task); | ||
737 | } | ||
738 | |||
739 | /// <summary> | ||
740 | /// | ||
741 | /// </summary> | ||
742 | /// <param name="message"></param> | ||
743 | /// <param name="type"></param> | ||
744 | /// <param name="fromPos"></param> | ||
745 | /// <param name="fromName"></param> | ||
746 | /// <param name="fromAgentID"></param> | ||
747 | public void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | ||
748 | { | ||
749 | SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID); | ||
750 | } | ||
751 | |||
752 | |||
753 | public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) | ||
754 | { | ||
755 | Encoding enc = Encoding.ASCII; | ||
756 | ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); | ||
757 | reply.ChatData.Audible = 1; | ||
758 | reply.ChatData.Message = message; | ||
759 | reply.ChatData.ChatType = type; | ||
760 | reply.ChatData.SourceType = 1; | ||
761 | reply.ChatData.Position = fromPos; | ||
762 | reply.ChatData.FromName = enc.GetBytes(fromName + "\0"); | ||
763 | reply.ChatData.OwnerID = fromAgentID; | ||
764 | reply.ChatData.SourceID = fromAgentID; | ||
765 | |||
766 | OutPacket(reply, ThrottleOutPacketType.Task); | ||
767 | } | ||
768 | |||
769 | /// <summary> | ||
770 | /// | ||
771 | /// </summary> | ||
772 | /// <remarks>TODO</remarks> | ||
773 | /// <param name="message"></param> | ||
774 | /// <param name="target"></param> | ||
775 | public void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, | ||
776 | LLUUID imSessionID, string fromName, byte dialog, uint timeStamp) | ||
777 | { | ||
778 | Encoding enc = Encoding.ASCII; | ||
779 | Encoding encUTF8 = Encoding.UTF8; | ||
780 | ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket(); | ||
781 | msg.AgentData.AgentID = fromAgent; | ||
782 | msg.AgentData.SessionID = fromAgentSession; | ||
783 | msg.MessageBlock.FromAgentName = enc.GetBytes(fromName + " \0"); | ||
784 | msg.MessageBlock.Dialog = dialog; | ||
785 | msg.MessageBlock.FromGroup = false; | ||
786 | msg.MessageBlock.ID = imSessionID; | ||
787 | msg.MessageBlock.Offline = 0; | ||
788 | msg.MessageBlock.ParentEstateID = 0; | ||
789 | msg.MessageBlock.Position = new LLVector3(); | ||
790 | msg.MessageBlock.RegionID = LLUUID.Random(); | ||
791 | msg.MessageBlock.Timestamp = timeStamp; | ||
792 | msg.MessageBlock.ToAgentID = toAgent; | ||
793 | msg.MessageBlock.Message = encUTF8.GetBytes(message + "\0"); | ||
794 | msg.MessageBlock.BinaryBucket = new byte[0]; | ||
795 | |||
796 | OutPacket(msg, ThrottleOutPacketType.Task); | ||
797 | } | ||
798 | |||
799 | /// <summary> | ||
800 | /// Send the region heightmap to the client | ||
801 | /// </summary> | ||
802 | /// <param name="map">heightmap</param> | ||
803 | public virtual void SendLayerData(float[] map) | ||
804 | { | ||
805 | try | ||
806 | { | ||
807 | int[] patches = new int[4]; | ||
808 | |||
809 | for (int y = 0; y < 16; y++) | ||
810 | { | ||
811 | for (int x = 0; x < 16; x = x + 4) | ||
812 | { | ||
813 | patches[0] = x + 0 + y*16; | ||
814 | patches[1] = x + 1 + y*16; | ||
815 | patches[2] = x + 2 + y*16; | ||
816 | patches[3] = x + 3 + y*16; | ||
817 | |||
818 | Packet layerpack = TerrainManager.CreateLandPacket(map, patches); | ||
819 | OutPacket(layerpack, ThrottleOutPacketType.Land); | ||
820 | } | ||
821 | } | ||
822 | } | ||
823 | catch (Exception e) | ||
824 | { | ||
825 | MainLog.Instance.Warn("client", | ||
826 | "ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); | ||
827 | } | ||
828 | } | ||
829 | |||
830 | /// <summary> | ||
831 | /// Sends a specified patch to a client | ||
832 | /// </summary> | ||
833 | /// <param name="px">Patch coordinate (x) 0..16</param> | ||
834 | /// <param name="py">Patch coordinate (y) 0..16</param> | ||
835 | /// <param name="map">heightmap</param> | ||
836 | public void SendLayerData(int px, int py, float[] map) | ||
837 | { | ||
838 | try | ||
839 | { | ||
840 | int[] patches = new int[1]; | ||
841 | int patchx, patchy; | ||
842 | patchx = px; | ||
843 | patchy = py; | ||
844 | |||
845 | patches[0] = patchx + 0 + patchy*16; | ||
846 | |||
847 | Packet layerpack = TerrainManager.CreateLandPacket(map, patches); | ||
848 | OutPacket(layerpack, ThrottleOutPacketType.Land); | ||
849 | } | ||
850 | catch (Exception e) | ||
851 | { | ||
852 | MainLog.Instance.Warn("client", | ||
853 | "ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); | ||
854 | } | ||
855 | } | ||
856 | |||
857 | /// <summary> | ||
858 | /// | ||
859 | /// </summary> | ||
860 | /// <param name="neighbourHandle"></param> | ||
861 | /// <param name="neighbourIP"></param> | ||
862 | /// <param name="neighbourPort"></param> | ||
863 | public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint) | ||
864 | { | ||
865 | IPAddress neighbourIP = neighbourEndPoint.Address; | ||
866 | ushort neighbourPort = (ushort) neighbourEndPoint.Port; | ||
867 | |||
868 | EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket(); | ||
869 | enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); | ||
870 | enablesimpacket.SimulatorInfo.Handle = neighbourHandle; | ||
871 | |||
872 | byte[] byteIP = neighbourIP.GetAddressBytes(); | ||
873 | enablesimpacket.SimulatorInfo.IP = (uint) byteIP[3] << 24; | ||
874 | enablesimpacket.SimulatorInfo.IP += (uint) byteIP[2] << 16; | ||
875 | enablesimpacket.SimulatorInfo.IP += (uint) byteIP[1] << 8; | ||
876 | enablesimpacket.SimulatorInfo.IP += (uint) byteIP[0]; | ||
877 | enablesimpacket.SimulatorInfo.Port = neighbourPort; | ||
878 | OutPacket(enablesimpacket, ThrottleOutPacketType.Task); | ||
879 | } | ||
880 | |||
881 | /// <summary> | ||
882 | /// | ||
883 | /// </summary> | ||
884 | /// <returns></returns> | ||
885 | public AgentCircuitData RequestClientInfo() | ||
886 | { | ||
887 | AgentCircuitData agentData = new AgentCircuitData(); | ||
888 | agentData.AgentID = AgentId; | ||
889 | agentData.SessionID = m_sessionId; | ||
890 | agentData.SecureSessionID = SecureSessionID; | ||
891 | agentData.circuitcode = m_circuitCode; | ||
892 | agentData.child = false; | ||
893 | agentData.firstname = firstName; | ||
894 | agentData.lastname = lastName; | ||
895 | agentData.CapsPath = ""; | ||
896 | return agentData; | ||
897 | } | ||
898 | |||
899 | public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint, | ||
900 | string capsURL) | ||
901 | { | ||
902 | LLVector3 look = new LLVector3(lookAt.X*10, lookAt.Y*10, lookAt.Z*10); | ||
903 | |||
904 | CrossedRegionPacket newSimPack = new CrossedRegionPacket(); | ||
905 | newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); | ||
906 | newSimPack.AgentData.AgentID = AgentId; | ||
907 | newSimPack.AgentData.SessionID = m_sessionId; | ||
908 | newSimPack.Info = new CrossedRegionPacket.InfoBlock(); | ||
909 | newSimPack.Info.Position = pos; | ||
910 | newSimPack.Info.LookAt = look; | ||
911 | // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! | ||
912 | newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock(); | ||
913 | newSimPack.RegionData.RegionHandle = newRegionHandle; | ||
914 | byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes(); | ||
915 | newSimPack.RegionData.SimIP = (uint) byteIP[3] << 24; | ||
916 | newSimPack.RegionData.SimIP += (uint) byteIP[2] << 16; | ||
917 | newSimPack.RegionData.SimIP += (uint) byteIP[1] << 8; | ||
918 | newSimPack.RegionData.SimIP += (uint) byteIP[0]; | ||
919 | newSimPack.RegionData.SimPort = (ushort) externalIPEndPoint.Port; | ||
920 | //newSimPack.RegionData.SeedCapability = new byte[0]; | ||
921 | newSimPack.RegionData.SeedCapability = Helpers.StringToField(capsURL); | ||
922 | |||
923 | OutPacket(newSimPack, ThrottleOutPacketType.Task); | ||
924 | } | ||
925 | |||
926 | public void SendMapBlock(List<MapBlockData> mapBlocks) | ||
927 | { | ||
928 | MapBlockReplyPacket mapReply = new MapBlockReplyPacket(); | ||
929 | mapReply.AgentData.AgentID = AgentId; | ||
930 | mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count]; | ||
931 | mapReply.AgentData.Flags = 0; | ||
932 | |||
933 | for (int i = 0; i < mapBlocks.Count; i++) | ||
934 | { | ||
935 | mapReply.Data[i] = new MapBlockReplyPacket.DataBlock(); | ||
936 | mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId; | ||
937 | mapReply.Data[i].X = mapBlocks[i].X; | ||
938 | mapReply.Data[i].Y = mapBlocks[i].Y; | ||
939 | mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight; | ||
940 | mapReply.Data[i].Name = Helpers.StringToField(mapBlocks[i].Name); | ||
941 | mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags; | ||
942 | mapReply.Data[i].Access = mapBlocks[i].Access; | ||
943 | mapReply.Data[i].Agents = mapBlocks[i].Agents; | ||
944 | } | ||
945 | OutPacket(mapReply, ThrottleOutPacketType.Land); | ||
946 | } | ||
947 | |||
948 | public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) | ||
949 | { | ||
950 | TeleportLocalPacket tpLocal = new TeleportLocalPacket(); | ||
951 | tpLocal.Info.AgentID = AgentId; | ||
952 | tpLocal.Info.TeleportFlags = flags; | ||
953 | tpLocal.Info.LocationID = 2; | ||
954 | tpLocal.Info.LookAt = lookAt; | ||
955 | tpLocal.Info.Position = position; | ||
956 | OutPacket(tpLocal, ThrottleOutPacketType.Task); | ||
957 | } | ||
958 | |||
959 | public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, | ||
960 | uint flags, string capsURL) | ||
961 | { | ||
962 | TeleportFinishPacket teleport = new TeleportFinishPacket(); | ||
963 | teleport.Info.AgentID = AgentId; | ||
964 | teleport.Info.RegionHandle = regionHandle; | ||
965 | teleport.Info.SimAccess = simAccess; | ||
966 | |||
967 | teleport.Info.SeedCapability = Helpers.StringToField(capsURL); | ||
968 | //teleport.Info.SeedCapability = new byte[0]; | ||
969 | |||
970 | IPAddress oIP = newRegionEndPoint.Address; | ||
971 | byte[] byteIP = oIP.GetAddressBytes(); | ||
972 | uint ip = (uint) byteIP[3] << 24; | ||
973 | ip += (uint) byteIP[2] << 16; | ||
974 | ip += (uint) byteIP[1] << 8; | ||
975 | ip += (uint) byteIP[0]; | ||
976 | |||
977 | teleport.Info.SimIP = ip; | ||
978 | teleport.Info.SimPort = (ushort) newRegionEndPoint.Port; | ||
979 | teleport.Info.LocationID = 4; | ||
980 | teleport.Info.TeleportFlags = 1 << 4; | ||
981 | OutPacket(teleport, ThrottleOutPacketType.Task); | ||
982 | } | ||
983 | |||
984 | /// <summary> | ||
985 | /// | ||
986 | /// </summary> | ||
987 | public void SendTeleportFailed() | ||
988 | { | ||
989 | TeleportFailedPacket tpFailed = new TeleportFailedPacket(); | ||
990 | tpFailed.Info.AgentID = this.AgentId; | ||
991 | tpFailed.Info.Reason = Helpers.StringToField("unknown failure of teleport"); | ||
992 | |||
993 | OutPacket(tpFailed, ThrottleOutPacketType.Task); | ||
994 | } | ||
995 | |||
996 | /// <summary> | ||
997 | /// | ||
998 | /// </summary> | ||
999 | public void SendTeleportLocationStart() | ||
1000 | { | ||
1001 | TeleportStartPacket tpStart = new TeleportStartPacket(); | ||
1002 | tpStart.Info.TeleportFlags = 16; // Teleport via location | ||
1003 | OutPacket(tpStart, ThrottleOutPacketType.Task); | ||
1004 | } | ||
1005 | |||
1006 | public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) | ||
1007 | { | ||
1008 | MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket(); | ||
1009 | money.MoneyData.AgentID = AgentId; | ||
1010 | money.MoneyData.TransactionID = transaction; | ||
1011 | money.MoneyData.TransactionSuccess = success; | ||
1012 | money.MoneyData.Description = description; | ||
1013 | money.MoneyData.MoneyBalance = balance; | ||
1014 | OutPacket(money, ThrottleOutPacketType.Task); | ||
1015 | } | ||
1016 | |||
1017 | public void SendStartPingCheck(byte seq) | ||
1018 | { | ||
1019 | StartPingCheckPacket pc = new StartPingCheckPacket(); | ||
1020 | pc.PingID.PingID = seq; | ||
1021 | pc.Header.Reliable = false; | ||
1022 | OutPacket(pc, ThrottleOutPacketType.Task); | ||
1023 | } | ||
1024 | |||
1025 | public void SendKillObject(ulong regionHandle, uint localID) | ||
1026 | { | ||
1027 | KillObjectPacket kill = new KillObjectPacket(); | ||
1028 | kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; | ||
1029 | kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); | ||
1030 | kill.ObjectData[0].ID = localID; | ||
1031 | OutPacket(kill, ThrottleOutPacketType.Task); | ||
1032 | } | ||
1033 | |||
1034 | public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items) | ||
1035 | { | ||
1036 | Encoding enc = Encoding.ASCII; | ||
1037 | uint FULL_MASK_PERMISSIONS = 2147483647; | ||
1038 | InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); | ||
1039 | |||
1040 | int count = 0; | ||
1041 | if (items.Count < 40) | ||
1042 | { | ||
1043 | descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; | ||
1044 | descend.AgentData.Descendents = items.Count; | ||
1045 | } | ||
1046 | else | ||
1047 | { | ||
1048 | descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[40]; | ||
1049 | descend.AgentData.Descendents = 40; | ||
1050 | } | ||
1051 | int i = 0; | ||
1052 | foreach (InventoryItemBase item in items) | ||
1053 | { | ||
1054 | descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); | ||
1055 | descend.ItemData[i].ItemID = item.inventoryID; | ||
1056 | descend.ItemData[i].AssetID = item.assetID; | ||
1057 | descend.ItemData[i].CreatorID = item.creatorsID; | ||
1058 | descend.ItemData[i].BaseMask = item.inventoryBasePermissions; | ||
1059 | descend.ItemData[i].CreationDate = 1000; | ||
1060 | descend.ItemData[i].Description = enc.GetBytes(item.inventoryDescription + "\0"); | ||
1061 | descend.ItemData[i].EveryoneMask = item.inventoryEveryOnePermissions; | ||
1062 | descend.ItemData[i].Flags = 1; | ||
1063 | descend.ItemData[i].FolderID = item.parentFolderID; | ||
1064 | descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
1065 | descend.ItemData[i].GroupMask = 0; | ||
1066 | descend.ItemData[i].InvType = (sbyte) item.invType; | ||
1067 | descend.ItemData[i].Name = enc.GetBytes(item.inventoryName + "\0"); | ||
1068 | descend.ItemData[i].NextOwnerMask = item.inventoryNextPermissions; | ||
1069 | descend.ItemData[i].OwnerID = item.avatarID; | ||
1070 | descend.ItemData[i].OwnerMask = item.inventoryCurrentPermissions; | ||
1071 | descend.ItemData[i].SalePrice = 0; | ||
1072 | descend.ItemData[i].SaleType = 0; | ||
1073 | descend.ItemData[i].Type = (sbyte) item.assetType; | ||
1074 | descend.ItemData[i].CRC = | ||
1075 | Helpers.InventoryCRC(1000, 0, descend.ItemData[i].InvType, descend.ItemData[i].Type, | ||
1076 | descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, 100, | ||
1077 | descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, | ||
1078 | descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, | ||
1079 | 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); | ||
1080 | |||
1081 | i++; | ||
1082 | count++; | ||
1083 | if (i == 40) | ||
1084 | { | ||
1085 | OutPacket(descend, ThrottleOutPacketType.Asset); | ||
1086 | |||
1087 | if ((items.Count - count) > 0) | ||
1088 | { | ||
1089 | descend = CreateInventoryDescendentsPacket(ownerID, folderID); | ||
1090 | if ((items.Count - count) < 40) | ||
1091 | { | ||
1092 | descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count - count]; | ||
1093 | descend.AgentData.Descendents = items.Count - count; | ||
1094 | } | ||
1095 | else | ||
1096 | { | ||
1097 | descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[40]; | ||
1098 | descend.AgentData.Descendents = 40; | ||
1099 | } | ||
1100 | i = 0; | ||
1101 | } | ||
1102 | } | ||
1103 | } | ||
1104 | |||
1105 | if (i < 40) | ||
1106 | { | ||
1107 | OutPacket(descend, ThrottleOutPacketType.Asset); | ||
1108 | } | ||
1109 | } | ||
1110 | |||
1111 | private InventoryDescendentsPacket CreateInventoryDescendentsPacket(LLUUID ownerID, LLUUID folderID) | ||
1112 | { | ||
1113 | InventoryDescendentsPacket descend = new InventoryDescendentsPacket(); | ||
1114 | descend.AgentData.AgentID = AgentId; | ||
1115 | descend.AgentData.OwnerID = ownerID; | ||
1116 | descend.AgentData.FolderID = folderID; | ||
1117 | descend.AgentData.Version = 0; | ||
1118 | |||
1119 | return descend; | ||
1120 | } | ||
1121 | |||
1122 | public void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item) | ||
1123 | { | ||
1124 | Encoding enc = Encoding.ASCII; | ||
1125 | uint FULL_MASK_PERMISSIONS = 2147483647; | ||
1126 | FetchInventoryReplyPacket inventoryReply = new FetchInventoryReplyPacket(); | ||
1127 | inventoryReply.AgentData.AgentID = AgentId; | ||
1128 | inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; | ||
1129 | inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); | ||
1130 | inventoryReply.InventoryData[0].ItemID = item.inventoryID; | ||
1131 | inventoryReply.InventoryData[0].AssetID = item.assetID; | ||
1132 | inventoryReply.InventoryData[0].CreatorID = item.creatorsID; | ||
1133 | inventoryReply.InventoryData[0].BaseMask = item.inventoryBasePermissions; | ||
1134 | inventoryReply.InventoryData[0].CreationDate = | ||
1135 | (int) (DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; | ||
1136 | inventoryReply.InventoryData[0].Description = enc.GetBytes(item.inventoryDescription + "\0"); | ||
1137 | inventoryReply.InventoryData[0].EveryoneMask = item.inventoryEveryOnePermissions; | ||
1138 | inventoryReply.InventoryData[0].Flags = 0; | ||
1139 | inventoryReply.InventoryData[0].FolderID = item.parentFolderID; | ||
1140 | inventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
1141 | inventoryReply.InventoryData[0].GroupMask = 0; | ||
1142 | inventoryReply.InventoryData[0].InvType = (sbyte) item.invType; | ||
1143 | inventoryReply.InventoryData[0].Name = enc.GetBytes(item.inventoryName + "\0"); | ||
1144 | inventoryReply.InventoryData[0].NextOwnerMask = item.inventoryNextPermissions; | ||
1145 | inventoryReply.InventoryData[0].OwnerID = item.avatarID; | ||
1146 | inventoryReply.InventoryData[0].OwnerMask = item.inventoryCurrentPermissions; | ||
1147 | inventoryReply.InventoryData[0].SalePrice = 0; | ||
1148 | inventoryReply.InventoryData[0].SaleType = 0; | ||
1149 | inventoryReply.InventoryData[0].Type = (sbyte) item.assetType; | ||
1150 | inventoryReply.InventoryData[0].CRC = | ||
1151 | Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType, | ||
1152 | inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID, | ||
1153 | inventoryReply.InventoryData[0].GroupID, 100, | ||
1154 | inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID, | ||
1155 | inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID, | ||
1156 | FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, | ||
1157 | FULL_MASK_PERMISSIONS); | ||
1158 | |||
1159 | OutPacket(inventoryReply, ThrottleOutPacketType.Asset); | ||
1160 | } | ||
1161 | |||
1162 | public void SendInventoryItemUpdate(InventoryItemBase Item) | ||
1163 | { | ||
1164 | Encoding enc = Encoding.ASCII; | ||
1165 | uint FULL_MASK_PERMISSIONS = 2147483647; | ||
1166 | UpdateCreateInventoryItemPacket InventoryReply = new UpdateCreateInventoryItemPacket(); | ||
1167 | InventoryReply.AgentData.AgentID = AgentId; | ||
1168 | InventoryReply.AgentData.SimApproved = true; | ||
1169 | InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1]; | ||
1170 | InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock(); | ||
1171 | InventoryReply.InventoryData[0].ItemID = Item.inventoryID; | ||
1172 | InventoryReply.InventoryData[0].AssetID = Item.assetID; | ||
1173 | InventoryReply.InventoryData[0].CreatorID = Item.creatorsID; | ||
1174 | InventoryReply.InventoryData[0].BaseMask = Item.inventoryBasePermissions; | ||
1175 | InventoryReply.InventoryData[0].CreationDate = 1000; | ||
1176 | InventoryReply.InventoryData[0].Description = enc.GetBytes(Item.inventoryDescription + "\0"); | ||
1177 | InventoryReply.InventoryData[0].EveryoneMask = Item.inventoryEveryOnePermissions; | ||
1178 | InventoryReply.InventoryData[0].Flags = 0; | ||
1179 | InventoryReply.InventoryData[0].FolderID = Item.parentFolderID; | ||
1180 | InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); | ||
1181 | InventoryReply.InventoryData[0].GroupMask = 0; | ||
1182 | InventoryReply.InventoryData[0].InvType = (sbyte) Item.invType; | ||
1183 | InventoryReply.InventoryData[0].Name = enc.GetBytes(Item.inventoryName + "\0"); | ||
1184 | InventoryReply.InventoryData[0].NextOwnerMask = Item.inventoryNextPermissions; | ||
1185 | InventoryReply.InventoryData[0].OwnerID = Item.avatarID; | ||
1186 | InventoryReply.InventoryData[0].OwnerMask = Item.inventoryCurrentPermissions; | ||
1187 | InventoryReply.InventoryData[0].SalePrice = 100; | ||
1188 | InventoryReply.InventoryData[0].SaleType = 0; | ||
1189 | InventoryReply.InventoryData[0].Type = (sbyte) Item.assetType; | ||
1190 | InventoryReply.InventoryData[0].CRC = | ||
1191 | Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, | ||
1192 | InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, | ||
1193 | InventoryReply.InventoryData[0].GroupID, 100, | ||
1194 | InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, | ||
1195 | InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, | ||
1196 | FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, | ||
1197 | FULL_MASK_PERMISSIONS); | ||
1198 | |||
1199 | OutPacket(InventoryReply, ThrottleOutPacketType.Asset); | ||
1200 | } | ||
1201 | |||
1202 | public void SendRemoveInventoryItem(LLUUID itemID) | ||
1203 | { | ||
1204 | RemoveInventoryItemPacket remove = new RemoveInventoryItemPacket(); | ||
1205 | remove.AgentData.AgentID = AgentId; | ||
1206 | remove.AgentData.SessionID = m_sessionId; | ||
1207 | remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1]; | ||
1208 | remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock(); | ||
1209 | remove.InventoryData[0].ItemID = itemID; | ||
1210 | |||
1211 | OutPacket(remove, ThrottleOutPacketType.Asset); | ||
1212 | } | ||
1213 | |||
1214 | public void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName) | ||
1215 | { | ||
1216 | ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket(); | ||
1217 | replytask.InventoryData.TaskID = taskID; | ||
1218 | replytask.InventoryData.Serial = serial; | ||
1219 | replytask.InventoryData.Filename = fileName; | ||
1220 | OutPacket(replytask, ThrottleOutPacketType.Asset); | ||
1221 | } | ||
1222 | |||
1223 | public void SendXferPacket(ulong xferID, uint packet, byte[] data) | ||
1224 | { | ||
1225 | SendXferPacketPacket sendXfer = new SendXferPacketPacket(); | ||
1226 | sendXfer.XferID.ID = xferID; | ||
1227 | sendXfer.XferID.Packet = packet; | ||
1228 | sendXfer.DataPacket.Data = data; | ||
1229 | OutPacket(sendXfer, ThrottleOutPacketType.Task); | ||
1230 | } | ||
1231 | public void SendAvatarPickerReply(AvatarPickerReplyPacket replyPacket) | ||
1232 | { | ||
1233 | OutPacket(replyPacket, ThrottleOutPacketType.Task); | ||
1234 | } | ||
1235 | |||
1236 | /// <summary> | ||
1237 | /// | ||
1238 | /// </summary> | ||
1239 | /// <param name="message"></param> | ||
1240 | public void SendAlertMessage(string message) | ||
1241 | { | ||
1242 | AlertMessagePacket alertPack = new AlertMessagePacket(); | ||
1243 | alertPack.AlertData.Message = Helpers.StringToField(message); | ||
1244 | OutPacket(alertPack, ThrottleOutPacketType.Task); | ||
1245 | } | ||
1246 | |||
1247 | /// <summary> | ||
1248 | /// | ||
1249 | /// </summary> | ||
1250 | /// <param name="message"></param> | ||
1251 | /// <param name="modal"></param> | ||
1252 | public void SendAgentAlertMessage(string message, bool modal) | ||
1253 | { | ||
1254 | AgentAlertMessagePacket alertPack = new AgentAlertMessagePacket(); | ||
1255 | alertPack.AgentData.AgentID = AgentId; | ||
1256 | alertPack.AlertData.Message = Helpers.StringToField(message); | ||
1257 | alertPack.AlertData.Modal = modal; | ||
1258 | OutPacket(alertPack, ThrottleOutPacketType.Task); | ||
1259 | } | ||
1260 | |||
1261 | public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, | ||
1262 | string url) | ||
1263 | { | ||
1264 | LoadURLPacket loadURL = new LoadURLPacket(); | ||
1265 | loadURL.Data.ObjectName = Helpers.StringToField(objectname); | ||
1266 | loadURL.Data.ObjectID = objectID; | ||
1267 | loadURL.Data.OwnerID = ownerID; | ||
1268 | loadURL.Data.OwnerIsGroup = groupOwned; | ||
1269 | loadURL.Data.Message = Helpers.StringToField(message); | ||
1270 | loadURL.Data.URL = Helpers.StringToField(url); | ||
1271 | |||
1272 | OutPacket(loadURL, ThrottleOutPacketType.Task); | ||
1273 | } | ||
1274 | |||
1275 | |||
1276 | public void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID) | ||
1277 | { | ||
1278 | PreloadSoundPacket preSound = new PreloadSoundPacket(); | ||
1279 | preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1]; | ||
1280 | preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock(); | ||
1281 | preSound.DataBlock[0].ObjectID = objectID; | ||
1282 | preSound.DataBlock[0].OwnerID = ownerID; | ||
1283 | preSound.DataBlock[0].SoundID = soundID; | ||
1284 | OutPacket(preSound, ThrottleOutPacketType.Task); | ||
1285 | } | ||
1286 | |||
1287 | public void SendPlayAttachedSound(LLUUID soundID, LLUUID objectID, LLUUID ownerID, float gain, byte flags) | ||
1288 | { | ||
1289 | AttachedSoundPacket sound = new AttachedSoundPacket(); | ||
1290 | sound.DataBlock.SoundID = soundID; | ||
1291 | sound.DataBlock.ObjectID = objectID; | ||
1292 | sound.DataBlock.OwnerID = ownerID; | ||
1293 | sound.DataBlock.Gain = gain; | ||
1294 | sound.DataBlock.Flags = flags; | ||
1295 | |||
1296 | OutPacket(sound, ThrottleOutPacketType.Task); | ||
1297 | } | ||
1298 | |||
1299 | public void SendSunPos(LLVector3 sunPos, LLVector3 sunVel) | ||
1300 | { | ||
1301 | SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket(); | ||
1302 | viewertime.TimeInfo.SunDirection = sunPos; | ||
1303 | viewertime.TimeInfo.SunAngVelocity = sunVel; | ||
1304 | viewertime.TimeInfo.UsecSinceStart = (ulong) Util.UnixTimeSinceEpoch(); | ||
1305 | OutPacket(viewertime, ThrottleOutPacketType.Task); | ||
1306 | } | ||
1307 | |||
1308 | public void SendViewerTime(int phase) | ||
1309 | { | ||
1310 | Console.WriteLine("SunPhase: {0}", phase); | ||
1311 | SimulatorViewerTimeMessagePacket viewertime = new SimulatorViewerTimeMessagePacket(); | ||
1312 | //viewertime.TimeInfo.SecPerDay = 86400; | ||
1313 | // viewertime.TimeInfo.SecPerYear = 31536000; | ||
1314 | viewertime.TimeInfo.SecPerDay = 1000; | ||
1315 | viewertime.TimeInfo.SecPerYear = 365000; | ||
1316 | viewertime.TimeInfo.SunPhase = 1; | ||
1317 | int sunPhase = (phase + 2)/2; | ||
1318 | if ((sunPhase < 6) || (sunPhase > 36)) | ||
1319 | { | ||
1320 | viewertime.TimeInfo.SunDirection = new LLVector3(0f, 0.8f, -0.8f); | ||
1321 | Console.WriteLine("sending night"); | ||
1322 | } | ||
1323 | else | ||
1324 | { | ||
1325 | if (sunPhase < 12) | ||
1326 | { | ||
1327 | sunPhase = 12; | ||
1328 | } | ||
1329 | sunPhase = sunPhase - 12; | ||
1330 | |||
1331 | float yValue = 0.1f*(sunPhase); | ||
1332 | Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue); | ||
1333 | if (yValue > 1.2f) | ||
1334 | { | ||
1335 | yValue = yValue - 1.2f; | ||
1336 | } | ||
1337 | if (yValue > 1) | ||
1338 | { | ||
1339 | yValue = 1; | ||
1340 | } | ||
1341 | if (yValue < 0) | ||
1342 | { | ||
1343 | yValue = 0; | ||
1344 | } | ||
1345 | if (sunPhase < 14) | ||
1346 | { | ||
1347 | yValue = 1 - yValue; | ||
1348 | } | ||
1349 | if (sunPhase < 12) | ||
1350 | { | ||
1351 | yValue *= -1; | ||
1352 | } | ||
1353 | viewertime.TimeInfo.SunDirection = new LLVector3(0f, yValue, 0.3f); | ||
1354 | Console.WriteLine("sending sun update " + yValue); | ||
1355 | } | ||
1356 | viewertime.TimeInfo.SunAngVelocity = new LLVector3(0, 0.0f, 10.0f); | ||
1357 | viewertime.TimeInfo.UsecSinceStart = (ulong) Util.UnixTimeSinceEpoch(); | ||
1358 | OutPacket(viewertime, ThrottleOutPacketType.Task); | ||
1359 | } | ||
1360 | |||
1361 | public void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, | ||
1362 | string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, | ||
1363 | LLUUID partnerID) | ||
1364 | { | ||
1365 | AvatarPropertiesReplyPacket avatarReply = new AvatarPropertiesReplyPacket(); | ||
1366 | avatarReply.AgentData.AgentID = AgentId; | ||
1367 | avatarReply.AgentData.AvatarID = avatarID; | ||
1368 | avatarReply.PropertiesData.AboutText = Helpers.StringToField(aboutText); | ||
1369 | avatarReply.PropertiesData.BornOn = Helpers.StringToField(bornOn); | ||
1370 | avatarReply.PropertiesData.CharterMember = Helpers.StringToField(charterMember); | ||
1371 | avatarReply.PropertiesData.FLAboutText = Helpers.StringToField(flAbout); | ||
1372 | avatarReply.PropertiesData.Flags = 0; | ||
1373 | avatarReply.PropertiesData.FLImageID = flImageID; | ||
1374 | avatarReply.PropertiesData.ImageID = imageID; | ||
1375 | avatarReply.PropertiesData.ProfileURL = Helpers.StringToField(profileURL); | ||
1376 | avatarReply.PropertiesData.PartnerID = partnerID; | ||
1377 | OutPacket(avatarReply, ThrottleOutPacketType.Task); | ||
1378 | } | ||
1379 | |||
1380 | #endregion | ||
1381 | |||
1382 | #region Appearance/ Wearables Methods | ||
1383 | |||
1384 | /// <summary> | ||
1385 | /// | ||
1386 | /// </summary> | ||
1387 | /// <param name="wearables"></param> | ||
1388 | public void SendWearables(AvatarWearable[] wearables, int serial) | ||
1389 | { | ||
1390 | AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); | ||
1391 | aw.AgentData.AgentID = AgentId; | ||
1392 | aw.AgentData.SerialNum = (uint) serial; | ||
1393 | aw.AgentData.SessionID = m_sessionId; | ||
1394 | |||
1395 | aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; | ||
1396 | AgentWearablesUpdatePacket.WearableDataBlock awb; | ||
1397 | for (int i = 0; i < wearables.Length; i++) | ||
1398 | { | ||
1399 | awb = new AgentWearablesUpdatePacket.WearableDataBlock(); | ||
1400 | awb.WearableType = (byte) i; | ||
1401 | awb.AssetID = wearables[i].AssetID; | ||
1402 | awb.ItemID = wearables[i].ItemID; | ||
1403 | aw.WearableData[i] = awb; | ||
1404 | } | ||
1405 | |||
1406 | OutPacket(aw, ThrottleOutPacketType.Task); | ||
1407 | } | ||
1408 | |||
1409 | /// <summary> | ||
1410 | /// | ||
1411 | /// </summary> | ||
1412 | /// <param name="agentID"></param> | ||
1413 | /// <param name="visualParams"></param> | ||
1414 | /// <param name="textureEntry"></param> | ||
1415 | public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry) | ||
1416 | { | ||
1417 | AvatarAppearancePacket avp = new AvatarAppearancePacket(); | ||
1418 | avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; | ||
1419 | avp.ObjectData.TextureEntry = textureEntry; | ||
1420 | |||
1421 | AvatarAppearancePacket.VisualParamBlock avblock = null; | ||
1422 | for (int i = 0; i < visualParams.Length; i++) | ||
1423 | { | ||
1424 | avblock = new AvatarAppearancePacket.VisualParamBlock(); | ||
1425 | avblock.ParamValue = visualParams[i]; | ||
1426 | avp.VisualParam[i] = avblock; | ||
1427 | } | ||
1428 | |||
1429 | avp.Sender.IsTrial = false; | ||
1430 | avp.Sender.ID = agentID; | ||
1431 | OutPacket(avp, ThrottleOutPacketType.Task); | ||
1432 | } | ||
1433 | |||
1434 | public void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) | ||
1435 | { | ||
1436 | AvatarAnimationPacket ani = new AvatarAnimationPacket(); | ||
1437 | ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; | ||
1438 | ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); | ||
1439 | ani.AnimationSourceList[0].ObjectID = sourceAgentId; | ||
1440 | ani.Sender = new AvatarAnimationPacket.SenderBlock(); | ||
1441 | ani.Sender.ID = sourceAgentId; | ||
1442 | ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1]; | ||
1443 | ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); | ||
1444 | ani.AnimationList[0].AnimID = animID; | ||
1445 | ani.AnimationList[0].AnimSequenceID = seq; | ||
1446 | OutPacket(ani, ThrottleOutPacketType.Task); | ||
1447 | } | ||
1448 | |||
1449 | #endregion | ||
1450 | |||
1451 | #region Avatar Packet/data sending Methods | ||
1452 | |||
1453 | /// <summary> | ||
1454 | /// send a objectupdate packet with information about the clients avatar | ||
1455 | /// </summary> | ||
1456 | /// <param name="regionInfo"></param> | ||
1457 | /// <param name="firstName"></param> | ||
1458 | /// <param name="lastName"></param> | ||
1459 | /// <param name="avatarID"></param> | ||
1460 | /// <param name="avatarLocalID"></param> | ||
1461 | /// <param name="Pos"></param> | ||
1462 | public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, | ||
1463 | uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) | ||
1464 | { | ||
1465 | ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); | ||
1466 | objupdate.RegionData.RegionHandle = regionHandle; | ||
1467 | objupdate.RegionData.TimeDilation = 64096; | ||
1468 | objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; | ||
1469 | objupdate.ObjectData[0] = CreateDefaultAvatarPacket(textureEntry); | ||
1470 | |||
1471 | //give this avatar object a local id and assign the user a name | ||
1472 | objupdate.ObjectData[0].ID = avatarLocalID; | ||
1473 | objupdate.ObjectData[0].FullID = avatarID; | ||
1474 | objupdate.ObjectData[0].ParentID = parentID; | ||
1475 | objupdate.ObjectData[0].NameValue = | ||
1476 | Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName); | ||
1477 | LLVector3 pos2 = new LLVector3((float) Pos.X, (float) Pos.Y, (float) Pos.Z); | ||
1478 | byte[] pb = pos2.GetBytes(); | ||
1479 | Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); | ||
1480 | |||
1481 | OutPacket(objupdate, ThrottleOutPacketType.Task); | ||
1482 | } | ||
1483 | |||
1484 | /// <summary> | ||
1485 | /// | ||
1486 | /// </summary> | ||
1487 | /// <param name="regionHandle"></param> | ||
1488 | /// <param name="timeDilation"></param> | ||
1489 | /// <param name="localID"></param> | ||
1490 | /// <param name="position"></param> | ||
1491 | /// <param name="velocity"></param> | ||
1492 | public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, | ||
1493 | LLVector3 velocity, LLQuaternion rotation) | ||
1494 | { | ||
1495 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = | ||
1496 | CreateAvatarImprovedBlock(localID, position, velocity, rotation); | ||
1497 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | ||
1498 | terse.RegionData.RegionHandle = regionHandle; | ||
1499 | terse.RegionData.TimeDilation = timeDilation; | ||
1500 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
1501 | terse.ObjectData[0] = terseBlock; | ||
1502 | |||
1503 | OutPacket(terse, ThrottleOutPacketType.Task); | ||
1504 | } | ||
1505 | |||
1506 | public void SendCoarseLocationUpdate(List<LLVector3> CoarseLocations) | ||
1507 | { | ||
1508 | CoarseLocationUpdatePacket loc = new CoarseLocationUpdatePacket(); | ||
1509 | int total = CoarseLocations.Count; | ||
1510 | CoarseLocationUpdatePacket.IndexBlock ib = | ||
1511 | new CoarseLocationUpdatePacket.IndexBlock(); | ||
1512 | loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total]; | ||
1513 | for (int i = 0; i < total; i++) | ||
1514 | { | ||
1515 | CoarseLocationUpdatePacket.LocationBlock lb = | ||
1516 | new CoarseLocationUpdatePacket.LocationBlock(); | ||
1517 | lb.X = (byte) CoarseLocations[i].X; | ||
1518 | lb.Y = (byte) CoarseLocations[i].Y; | ||
1519 | lb.Z = (byte) (CoarseLocations[i].Z/4); | ||
1520 | loc.Location[i] = lb; | ||
1521 | } | ||
1522 | ib.You = -1; | ||
1523 | ib.Prey = -1; | ||
1524 | loc.Index = ib; | ||
1525 | OutPacket(loc, ThrottleOutPacketType.Task); | ||
1526 | } | ||
1527 | |||
1528 | #endregion | ||
1529 | |||
1530 | #region Primitive Packet/data Sending Methods | ||
1531 | |||
1532 | /// <summary> | ||
1533 | /// | ||
1534 | /// </summary> | ||
1535 | /// <param name="localID"></param> | ||
1536 | /// <param name="rotation"></param> | ||
1537 | /// <param name="attachPoint"></param> | ||
1538 | public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) | ||
1539 | { | ||
1540 | ObjectAttachPacket attach = new ObjectAttachPacket(); | ||
1541 | attach.AgentData.AgentID = AgentId; | ||
1542 | attach.AgentData.SessionID = m_sessionId; | ||
1543 | attach.AgentData.AttachmentPoint = attachPoint; | ||
1544 | attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1]; | ||
1545 | attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock(); | ||
1546 | attach.ObjectData[0].ObjectLocalID = localID; | ||
1547 | attach.ObjectData[0].Rotation = rotation; | ||
1548 | |||
1549 | OutPacket(attach, ThrottleOutPacketType.Task); | ||
1550 | } | ||
1551 | |||
1552 | public void SendPrimitiveToClient( | ||
1553 | ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, | ||
1554 | uint flags, | ||
1555 | LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem, LLQuaternion rotation, byte clickAction) | ||
1556 | { | ||
1557 | ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); | ||
1558 | outPacket.RegionData.RegionHandle = regionHandle; | ||
1559 | outPacket.RegionData.TimeDilation = timeDilation; | ||
1560 | outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; | ||
1561 | |||
1562 | outPacket.ObjectData[0] = CreatePrimUpdateBlock(primShape, flags); | ||
1563 | |||
1564 | outPacket.ObjectData[0].ID = localID; | ||
1565 | outPacket.ObjectData[0].FullID = objectID; | ||
1566 | outPacket.ObjectData[0].OwnerID = ownerID; | ||
1567 | outPacket.ObjectData[0].Text = Helpers.StringToField(text); | ||
1568 | outPacket.ObjectData[0].TextColor[0] = color[0]; | ||
1569 | outPacket.ObjectData[0].TextColor[1] = color[1]; | ||
1570 | outPacket.ObjectData[0].TextColor[2] = color[2]; | ||
1571 | outPacket.ObjectData[0].TextColor[3] = color[3]; | ||
1572 | outPacket.ObjectData[0].ParentID = parentID; | ||
1573 | outPacket.ObjectData[0].PSBlock = particleSystem; | ||
1574 | outPacket.ObjectData[0].ClickAction = clickAction; | ||
1575 | //outPacket.ObjectData[0].Flags = 0; | ||
1576 | outPacket.ObjectData[0].Radius = 20; | ||
1577 | |||
1578 | byte[] pb = pos.GetBytes(); | ||
1579 | Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); | ||
1580 | |||
1581 | byte[] rot = rotation.GetBytes(); | ||
1582 | Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 36, rot.Length); | ||
1583 | |||
1584 | OutPacket(outPacket, ThrottleOutPacketType.Task); | ||
1585 | } | ||
1586 | |||
1587 | /// <summary> | ||
1588 | /// | ||
1589 | /// </summary> | ||
1590 | /// <param name="regionHandle"></param> | ||
1591 | /// <param name="timeDilation"></param> | ||
1592 | /// <param name="localID"></param> | ||
1593 | /// <param name="position"></param> | ||
1594 | /// <param name="rotation"></param> | ||
1595 | public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, | ||
1596 | LLQuaternion rotation) | ||
1597 | { | ||
1598 | LLVector3 velocity = new LLVector3(0f,0f,0f); | ||
1599 | LLVector3 rotationalvelocity = new LLVector3(0f,0f,0f); | ||
1600 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | ||
1601 | terse.RegionData.RegionHandle = regionHandle; | ||
1602 | terse.RegionData.TimeDilation = timeDilation; | ||
1603 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
1604 | terse.ObjectData[0] = CreatePrimImprovedBlock(localID, position, rotation, velocity, rotationalvelocity); | ||
1605 | |||
1606 | OutPacket(terse, ThrottleOutPacketType.Task); | ||
1607 | } | ||
1608 | public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, | ||
1609 | LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity) | ||
1610 | { | ||
1611 | |||
1612 | ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); | ||
1613 | terse.RegionData.RegionHandle = regionHandle; | ||
1614 | terse.RegionData.TimeDilation = timeDilation; | ||
1615 | terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; | ||
1616 | terse.ObjectData[0] = CreatePrimImprovedBlock(localID, position, rotation, velocity, rotationalvelocity); | ||
1617 | |||
1618 | OutPacket(terse, ThrottleOutPacketType.Task); | ||
1619 | } | ||
1620 | |||
1621 | |||
1622 | #endregion | ||
1623 | |||
1624 | #region Helper Methods | ||
1625 | |||
1626 | protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, | ||
1627 | LLVector3 velocity, | ||
1628 | LLQuaternion rotation) | ||
1629 | { | ||
1630 | byte[] bytes = new byte[60]; | ||
1631 | int i = 0; | ||
1632 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | ||
1633 | |||
1634 | dat.TextureEntry = new byte[0]; // AvatarTemplate.TextureEntry; | ||
1635 | |||
1636 | uint ID = localID; | ||
1637 | |||
1638 | bytes[i++] = (byte) (ID%256); | ||
1639 | bytes[i++] = (byte) ((ID >> 8)%256); | ||
1640 | bytes[i++] = (byte) ((ID >> 16)%256); | ||
1641 | bytes[i++] = (byte) ((ID >> 24)%256); | ||
1642 | bytes[i++] = 0; | ||
1643 | bytes[i++] = 1; | ||
1644 | i += 14; | ||
1645 | bytes[i++] = 128; | ||
1646 | bytes[i++] = 63; | ||
1647 | |||
1648 | byte[] pb = pos.GetBytes(); | ||
1649 | Array.Copy(pb, 0, bytes, i, pb.Length); | ||
1650 | i += 12; | ||
1651 | ushort InternVelocityX; | ||
1652 | ushort InternVelocityY; | ||
1653 | ushort InternVelocityZ; | ||
1654 | Vector3 internDirec = new Vector3(0, 0, 0); | ||
1655 | |||
1656 | internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z); | ||
1657 | |||
1658 | internDirec = internDirec/128.0f; | ||
1659 | internDirec.x += 1; | ||
1660 | internDirec.y += 1; | ||
1661 | internDirec.z += 1; | ||
1662 | |||
1663 | InternVelocityX = (ushort) (32768*internDirec.x); | ||
1664 | InternVelocityY = (ushort) (32768*internDirec.y); | ||
1665 | InternVelocityZ = (ushort) (32768*internDirec.z); | ||
1666 | |||
1667 | ushort ac = 32767; | ||
1668 | bytes[i++] = (byte) (InternVelocityX%256); | ||
1669 | bytes[i++] = (byte) ((InternVelocityX >> 8)%256); | ||
1670 | bytes[i++] = (byte) (InternVelocityY%256); | ||
1671 | bytes[i++] = (byte) ((InternVelocityY >> 8)%256); | ||
1672 | bytes[i++] = (byte) (InternVelocityZ%256); | ||
1673 | bytes[i++] = (byte) ((InternVelocityZ >> 8)%256); | ||
1674 | |||
1675 | //accel | ||
1676 | bytes[i++] = (byte) (ac%256); | ||
1677 | bytes[i++] = (byte) ((ac >> 8)%256); | ||
1678 | bytes[i++] = (byte) (ac%256); | ||
1679 | bytes[i++] = (byte) ((ac >> 8)%256); | ||
1680 | bytes[i++] = (byte) (ac%256); | ||
1681 | bytes[i++] = (byte) ((ac >> 8)%256); | ||
1682 | |||
1683 | //rotation | ||
1684 | ushort rw, rx, ry, rz; | ||
1685 | rw = (ushort) (32768*(rotation.W + 1)); | ||
1686 | rx = (ushort) (32768*(rotation.X + 1)); | ||
1687 | ry = (ushort) (32768*(rotation.Y + 1)); | ||
1688 | rz = (ushort) (32768*(rotation.Z + 1)); | ||
1689 | |||
1690 | //rot | ||
1691 | bytes[i++] = (byte) (rx%256); | ||
1692 | bytes[i++] = (byte) ((rx >> 8)%256); | ||
1693 | bytes[i++] = (byte) (ry%256); | ||
1694 | bytes[i++] = (byte) ((ry >> 8)%256); | ||
1695 | bytes[i++] = (byte) (rz%256); | ||
1696 | bytes[i++] = (byte) ((rz >> 8)%256); | ||
1697 | bytes[i++] = (byte) (rw%256); | ||
1698 | bytes[i++] = (byte) ((rw >> 8)%256); | ||
1699 | |||
1700 | //rotation vel | ||
1701 | bytes[i++] = (byte) (ac%256); | ||
1702 | bytes[i++] = (byte) ((ac >> 8)%256); | ||
1703 | bytes[i++] = (byte) (ac%256); | ||
1704 | bytes[i++] = (byte) ((ac >> 8)%256); | ||
1705 | bytes[i++] = (byte) (ac%256); | ||
1706 | bytes[i++] = (byte) ((ac >> 8)%256); | ||
1707 | |||
1708 | dat.Data = bytes; | ||
1709 | |||
1710 | return (dat); | ||
1711 | } | ||
1712 | |||
1713 | /// <summary> | ||
1714 | /// | ||
1715 | /// </summary> | ||
1716 | /// <param name="localID"></param> | ||
1717 | /// <param name="position"></param> | ||
1718 | /// <param name="rotation"></param> | ||
1719 | /// <returns></returns> | ||
1720 | protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, | ||
1721 | LLVector3 position, | ||
1722 | LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity) | ||
1723 | { | ||
1724 | uint ID = localID; | ||
1725 | byte[] bytes = new byte[60]; | ||
1726 | |||
1727 | int i = 0; | ||
1728 | ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); | ||
1729 | dat.TextureEntry = new byte[0]; | ||
1730 | bytes[i++] = (byte) (ID%256); | ||
1731 | bytes[i++] = (byte) ((ID >> 8)%256); | ||
1732 | bytes[i++] = (byte) ((ID >> 16)%256); | ||
1733 | bytes[i++] = (byte) ((ID >> 24)%256); | ||
1734 | bytes[i++] = 0; | ||
1735 | bytes[i++] = 0; | ||
1736 | |||
1737 | byte[] pb = position.GetBytes(); | ||
1738 | Array.Copy(pb, 0, bytes, i, pb.Length); | ||
1739 | i += 12; | ||
1740 | ushort ac = 32767; | ||
1741 | |||
1742 | ushort velx, vely, velz; | ||
1743 | Vector3 vel = new Vector3(velocity.X, velocity.Y, velocity.Z); | ||
1744 | |||
1745 | vel = vel/128.0f; | ||
1746 | vel.x += 1; | ||
1747 | vel.y += 1; | ||
1748 | vel.z += 1; | ||
1749 | //vel | ||
1750 | velx = (ushort)(32768 * (vel.x)); | ||
1751 | vely = (ushort)(32768 * (vel.y)); | ||
1752 | velz = (ushort)(32768 * (vel.z)); | ||
1753 | |||
1754 | bytes[i++] = (byte) (velx % 256); | ||
1755 | bytes[i++] = (byte) ((velx >> 8) % 256); | ||
1756 | bytes[i++] = (byte) (vely % 256); | ||
1757 | bytes[i++] = (byte) ((vely >> 8) % 256); | ||
1758 | bytes[i++] = (byte) (velz % 256); | ||
1759 | bytes[i++] = (byte) ((velz >> 8) % 256); | ||
1760 | |||
1761 | //accel | ||
1762 | bytes[i++] = (byte) (ac%256); | ||
1763 | bytes[i++] = (byte) ((ac >> 8)%256); | ||
1764 | bytes[i++] = (byte) (ac%256); | ||
1765 | bytes[i++] = (byte) ((ac >> 8)%256); | ||
1766 | bytes[i++] = (byte) (ac%256); | ||
1767 | bytes[i++] = (byte) ((ac >> 8)%256); | ||
1768 | |||
1769 | ushort rw, rx, ry, rz; | ||
1770 | rw = (ushort) (32768*(rotation.W + 1)); | ||
1771 | rx = (ushort) (32768*(rotation.X + 1)); | ||
1772 | ry = (ushort) (32768*(rotation.Y + 1)); | ||
1773 | rz = (ushort) (32768*(rotation.Z + 1)); | ||
1774 | |||
1775 | //rot | ||
1776 | bytes[i++] = (byte) (rx%256); | ||
1777 | bytes[i++] = (byte) ((rx >> 8)%256); | ||
1778 | bytes[i++] = (byte) (ry%256); | ||
1779 | bytes[i++] = (byte) ((ry >> 8)%256); | ||
1780 | bytes[i++] = (byte) (rz%256); | ||
1781 | bytes[i++] = (byte) ((rz >> 8)%256); | ||
1782 | bytes[i++] = (byte) (rw%256); | ||
1783 | bytes[i++] = (byte) ((rw >> 8)%256); | ||
1784 | |||
1785 | //rotation vel | ||
1786 | ushort rvelx, rvely, rvelz; | ||
1787 | Vector3 rvel = new Vector3(rotationalvelocity.X, rotationalvelocity.Y, rotationalvelocity.Z); | ||
1788 | |||
1789 | rvel = rvel / 128.0f; | ||
1790 | rvel.x += 1; | ||
1791 | rvel.y += 1; | ||
1792 | rvel.z += 1; | ||
1793 | //vel | ||
1794 | rvelx = (ushort)(32768 * (rvel.x)); | ||
1795 | rvely = (ushort)(32768 * (rvel.y)); | ||
1796 | rvelz = (ushort)(32768 * (rvel.z)); | ||
1797 | |||
1798 | bytes[i++] = (byte)(rvelx % 256); | ||
1799 | bytes[i++] = (byte)((rvelx >> 8) % 256); | ||
1800 | bytes[i++] = (byte)(rvely % 256); | ||
1801 | bytes[i++] = (byte)((rvely >> 8) % 256); | ||
1802 | bytes[i++] = (byte)(rvelz % 256); | ||
1803 | bytes[i++] = (byte)((rvelz >> 8) % 256); | ||
1804 | |||
1805 | dat.Data = bytes; | ||
1806 | return dat; | ||
1807 | } | ||
1808 | |||
1809 | /// <summary> | ||
1810 | /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive) | ||
1811 | /// </summary> | ||
1812 | /// <param name="primData"></param> | ||
1813 | /// <returns></returns> | ||
1814 | protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags) | ||
1815 | { | ||
1816 | ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); | ||
1817 | SetDefaultPrimPacketValues(objupdate); | ||
1818 | objupdate.UpdateFlags = flags; | ||
1819 | SetPrimPacketShapeData(objupdate, primShape); | ||
1820 | |||
1821 | return objupdate; | ||
1822 | } | ||
1823 | |||
1824 | protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData) | ||
1825 | { | ||
1826 | objectData.TextureEntry = primData.TextureEntry; | ||
1827 | objectData.PCode = primData.PCode; | ||
1828 | objectData.PathBegin = primData.PathBegin; | ||
1829 | objectData.PathEnd = primData.PathEnd; | ||
1830 | objectData.PathScaleX = primData.PathScaleX; | ||
1831 | objectData.PathScaleY = primData.PathScaleY; | ||
1832 | objectData.PathShearX = primData.PathShearX; | ||
1833 | objectData.PathShearY = primData.PathShearY; | ||
1834 | objectData.PathSkew = primData.PathSkew; | ||
1835 | objectData.ProfileBegin = primData.ProfileBegin; | ||
1836 | objectData.ProfileEnd = primData.ProfileEnd; | ||
1837 | objectData.Scale = primData.Scale; | ||
1838 | objectData.PathCurve = primData.PathCurve; | ||
1839 | objectData.ProfileCurve = primData.ProfileCurve; | ||
1840 | objectData.ProfileHollow = primData.ProfileHollow; | ||
1841 | objectData.PathRadiusOffset = primData.PathRadiusOffset; | ||
1842 | objectData.PathRevolutions = primData.PathRevolutions; | ||
1843 | objectData.PathTaperX = primData.PathTaperX; | ||
1844 | objectData.PathTaperY = primData.PathTaperY; | ||
1845 | objectData.PathTwist = primData.PathTwist; | ||
1846 | objectData.PathTwistBegin = primData.PathTwistBegin; | ||
1847 | objectData.ExtraParams = primData.ExtraParams; | ||
1848 | } | ||
1849 | |||
1850 | /// <summary> | ||
1851 | /// Set some default values in a ObjectUpdatePacket | ||
1852 | /// </summary> | ||
1853 | /// <param name="objdata"></param> | ||
1854 | protected void SetDefaultPrimPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata) | ||
1855 | { | ||
1856 | objdata.PSBlock = new byte[0]; | ||
1857 | objdata.ExtraParams = new byte[1]; | ||
1858 | objdata.MediaURL = new byte[0]; | ||
1859 | objdata.NameValue = new byte[0]; | ||
1860 | objdata.Text = new byte[0]; | ||
1861 | objdata.TextColor = new byte[4]; | ||
1862 | objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); | ||
1863 | objdata.JointPivot = new LLVector3(0, 0, 0); | ||
1864 | objdata.Material = 3; | ||
1865 | objdata.TextureAnim = new byte[0]; | ||
1866 | objdata.Sound = LLUUID.Zero; | ||
1867 | objdata.State = 0; | ||
1868 | objdata.Data = new byte[0]; | ||
1869 | |||
1870 | objdata.ObjectData = new byte[60]; | ||
1871 | objdata.ObjectData[46] = 128; | ||
1872 | objdata.ObjectData[47] = 63; | ||
1873 | } | ||
1874 | |||
1875 | |||
1876 | /// <summary> | ||
1877 | /// | ||
1878 | /// </summary> | ||
1879 | /// <returns></returns> | ||
1880 | protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry) | ||
1881 | { | ||
1882 | ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); | ||
1883 | // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); | ||
1884 | |||
1885 | SetDefaultAvatarPacketValues(ref objdata); | ||
1886 | objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24); | ||
1887 | objdata.PathCurve = 16; | ||
1888 | objdata.ProfileCurve = 1; | ||
1889 | objdata.PathScaleX = 100; | ||
1890 | objdata.PathScaleY = 100; | ||
1891 | objdata.ParentID = 0; | ||
1892 | objdata.OwnerID = LLUUID.Zero; | ||
1893 | objdata.Scale = new LLVector3(1, 1, 1); | ||
1894 | objdata.PCode = 47; | ||
1895 | if (textureEntry != null) | ||
1896 | { | ||
1897 | objdata.TextureEntry = textureEntry; | ||
1898 | } | ||
1899 | Encoding enc = Encoding.ASCII; | ||
1900 | LLVector3 pos = new LLVector3(objdata.ObjectData, 16); | ||
1901 | pos.X = 100f; | ||
1902 | objdata.ID = 8880000; | ||
1903 | objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); | ||
1904 | //LLVector3 pos2 = new LLVector3(100f, 100f, 23f); | ||
1905 | //objdata.FullID=user.AgentId; | ||
1906 | byte[] pb = pos.GetBytes(); | ||
1907 | Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); | ||
1908 | |||
1909 | return objdata; | ||
1910 | } | ||
1911 | |||
1912 | /// <summary> | ||
1913 | /// | ||
1914 | /// </summary> | ||
1915 | /// <param name="objdata"></param> | ||
1916 | protected void SetDefaultAvatarPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata) | ||
1917 | { | ||
1918 | objdata.PSBlock = new byte[0]; | ||
1919 | objdata.ExtraParams = new byte[1]; | ||
1920 | objdata.MediaURL = new byte[0]; | ||
1921 | objdata.NameValue = new byte[0]; | ||
1922 | objdata.Text = new byte[0]; | ||
1923 | objdata.TextColor = new byte[4]; | ||
1924 | objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); | ||
1925 | objdata.JointPivot = new LLVector3(0, 0, 0); | ||
1926 | objdata.Material = 4; | ||
1927 | objdata.TextureAnim = new byte[0]; | ||
1928 | objdata.Sound = LLUUID.Zero; | ||
1929 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); | ||
1930 | objdata.TextureEntry = ntex.ToBytes(); | ||
1931 | objdata.State = 0; | ||
1932 | objdata.Data = new byte[0]; | ||
1933 | |||
1934 | objdata.ObjectData = new byte[76]; | ||
1935 | objdata.ObjectData[15] = 128; | ||
1936 | objdata.ObjectData[16] = 63; | ||
1937 | objdata.ObjectData[56] = 128; | ||
1938 | objdata.ObjectData[61] = 102; | ||
1939 | objdata.ObjectData[62] = 40; | ||
1940 | objdata.ObjectData[63] = 61; | ||
1941 | objdata.ObjectData[64] = 189; | ||
1942 | } | ||
1943 | |||
1944 | public void SendNameReply(LLUUID profileId, string firstname, string lastname) | ||
1945 | { | ||
1946 | UUIDNameReplyPacket packet = new UUIDNameReplyPacket(); | ||
1947 | |||
1948 | packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1]; | ||
1949 | packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); | ||
1950 | packet.UUIDNameBlock[0].ID = profileId; | ||
1951 | packet.UUIDNameBlock[0].FirstName = Helpers.StringToField(firstname); | ||
1952 | packet.UUIDNameBlock[0].LastName = Helpers.StringToField(lastname); | ||
1953 | |||
1954 | OutPacket(packet, ThrottleOutPacketType.Task); | ||
1955 | } | ||
1956 | |||
1957 | #endregion | ||
1958 | |||
1959 | protected virtual void RegisterLocalPacketHandlers() | ||
1960 | { | ||
1961 | AddLocalPacketHandler(PacketType.LogoutRequest, Logout); | ||
1962 | AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect); | ||
1963 | AddLocalPacketHandler(PacketType.AgentCachedTexture, AgentTextureCached); | ||
1964 | AddLocalPacketHandler(PacketType.MultipleObjectUpdate, MultipleObjUpdate); | ||
1965 | } | ||
1966 | |||
1967 | private bool HandleViewerEffect(IClientAPI sender, Packet Pack) | ||
1968 | { | ||
1969 | ViewerEffectPacket viewer = (ViewerEffectPacket) Pack; | ||
1970 | |||
1971 | if (OnViewerEffect != null) | ||
1972 | { | ||
1973 | OnViewerEffect(sender, viewer.Effect); | ||
1974 | } | ||
1975 | |||
1976 | return true; | ||
1977 | } | ||
1978 | |||
1979 | protected virtual bool Logout(IClientAPI client, Packet packet) | ||
1980 | { | ||
1981 | MainLog.Instance.Verbose("CLIENT", "Got a logout request"); | ||
1982 | |||
1983 | if (OnLogout != null) | ||
1984 | { | ||
1985 | OnLogout(client); | ||
1986 | } | ||
1987 | |||
1988 | return true; | ||
1989 | } | ||
1990 | |||
1991 | protected bool AgentTextureCached(IClientAPI simclient, Packet packet) | ||
1992 | { | ||
1993 | //System.Console.WriteLine("texture cached: " + packet.ToString()); | ||
1994 | AgentCachedTexturePacket chechedtex = (AgentCachedTexturePacket) packet; | ||
1995 | AgentCachedTextureResponsePacket cachedresp = new AgentCachedTextureResponsePacket(); | ||
1996 | cachedresp.AgentData.AgentID = AgentId; | ||
1997 | cachedresp.AgentData.SessionID = m_sessionId; | ||
1998 | cachedresp.AgentData.SerialNum = cachedtextureserial; | ||
1999 | cachedtextureserial++; | ||
2000 | cachedresp.WearableData = | ||
2001 | new AgentCachedTextureResponsePacket.WearableDataBlock[chechedtex.WearableData.Length]; | ||
2002 | for (int i = 0; i < chechedtex.WearableData.Length; i++) | ||
2003 | { | ||
2004 | cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); | ||
2005 | cachedresp.WearableData[i].TextureIndex = chechedtex.WearableData[i].TextureIndex; | ||
2006 | cachedresp.WearableData[i].TextureID = LLUUID.Zero; | ||
2007 | cachedresp.WearableData[i].HostName = new byte[0]; | ||
2008 | } | ||
2009 | OutPacket(cachedresp, ThrottleOutPacketType.Texture); | ||
2010 | return true; | ||
2011 | } | ||
2012 | |||
2013 | protected bool MultipleObjUpdate(IClientAPI simClient, Packet packet) | ||
2014 | { | ||
2015 | MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket) packet; | ||
2016 | // System.Console.WriteLine("new multi update packet " + multipleupdate.ToString()); | ||
2017 | for (int i = 0; i < multipleupdate.ObjectData.Length; i++) | ||
2018 | { | ||
2019 | #region position | ||
2020 | |||
2021 | if (multipleupdate.ObjectData[i].Type == 9) //change position | ||
2022 | { | ||
2023 | if (OnUpdatePrimGroupPosition != null) | ||
2024 | { | ||
2025 | LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); | ||
2026 | OnUpdatePrimGroupPosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); | ||
2027 | } | ||
2028 | } | ||
2029 | else if (multipleupdate.ObjectData[i].Type == 1) //single item of group change position | ||
2030 | { | ||
2031 | if (OnUpdatePrimSinglePosition != null) | ||
2032 | { | ||
2033 | LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); | ||
2034 | // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); | ||
2035 | OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); | ||
2036 | } | ||
2037 | } | ||
2038 | #endregion position | ||
2039 | #region rotation | ||
2040 | |||
2041 | else if (multipleupdate.ObjectData[i].Type == 2) // single item of group rotation from tab | ||
2042 | { | ||
2043 | if (OnUpdatePrimSingleRotation != null) | ||
2044 | { | ||
2045 | LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); | ||
2046 | //System.Console.WriteLine("new tab rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); | ||
2047 | OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); | ||
2048 | } | ||
2049 | } | ||
2050 | else if (multipleupdate.ObjectData[i].Type == 3) // single item of group rotation from mouse | ||
2051 | { | ||
2052 | if (OnUpdatePrimSingleRotation != null) | ||
2053 | { | ||
2054 | LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); | ||
2055 | //System.Console.WriteLine("new mouse rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); | ||
2056 | OnUpdatePrimSingleRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); | ||
2057 | } | ||
2058 | } | ||
2059 | else if (multipleupdate.ObjectData[i].Type == 10) //group rotation from object tab | ||
2060 | { | ||
2061 | if (OnUpdatePrimGroupRotation != null) | ||
2062 | { | ||
2063 | LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 0, true); | ||
2064 | // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); | ||
2065 | OnUpdatePrimGroupRotation(multipleupdate.ObjectData[i].ObjectLocalID, rot, this); | ||
2066 | } | ||
2067 | } | ||
2068 | else if (multipleupdate.ObjectData[i].Type == 11) //group rotation from mouse | ||
2069 | { | ||
2070 | if (OnUpdatePrimGroupMouseRotation != null) | ||
2071 | { | ||
2072 | LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); | ||
2073 | LLQuaternion rot = new LLQuaternion(multipleupdate.ObjectData[i].Data, 12, true); | ||
2074 | //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); | ||
2075 | // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); | ||
2076 | OnUpdatePrimGroupMouseRotation(multipleupdate.ObjectData[i].ObjectLocalID, pos, rot, this); | ||
2077 | } | ||
2078 | } | ||
2079 | #endregion | ||
2080 | #region scale | ||
2081 | |||
2082 | else if (multipleupdate.ObjectData[i].Type == 13) //group scale from object tab | ||
2083 | { | ||
2084 | if (OnUpdatePrimScale != null) | ||
2085 | { | ||
2086 | LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); | ||
2087 | //Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); | ||
2088 | OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); | ||
2089 | |||
2090 | // Change the position based on scale (for bug number 246) | ||
2091 | LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); | ||
2092 | // System.Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); | ||
2093 | OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); | ||
2094 | } | ||
2095 | } | ||
2096 | else if (multipleupdate.ObjectData[i].Type == 29) //group scale from mouse | ||
2097 | { | ||
2098 | if (OnUpdatePrimScale != null) | ||
2099 | { | ||
2100 | LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); | ||
2101 | // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z ); | ||
2102 | OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); | ||
2103 | LLVector3 pos = new LLVector3(multipleupdate.ObjectData[i].Data, 0); | ||
2104 | OnUpdatePrimSinglePosition(multipleupdate.ObjectData[i].ObjectLocalID, pos, this); | ||
2105 | } | ||
2106 | } | ||
2107 | else if (multipleupdate.ObjectData[i].Type == 5) //single prim scale from object tab | ||
2108 | { | ||
2109 | if (OnUpdatePrimScale != null) | ||
2110 | { | ||
2111 | LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); | ||
2112 | // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); | ||
2113 | OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); | ||
2114 | } | ||
2115 | } | ||
2116 | else if (multipleupdate.ObjectData[i].Type == 21) //single prim scale from mouse | ||
2117 | { | ||
2118 | if (OnUpdatePrimScale != null) | ||
2119 | { | ||
2120 | LLVector3 scale = new LLVector3(multipleupdate.ObjectData[i].Data, 12); | ||
2121 | // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); | ||
2122 | OnUpdatePrimScale(multipleupdate.ObjectData[i].ObjectLocalID, scale, this); | ||
2123 | } | ||
2124 | } | ||
2125 | |||
2126 | #endregion | ||
2127 | } | ||
2128 | return true; | ||
2129 | } | ||
2130 | |||
2131 | public void RequestMapLayer() | ||
2132 | { | ||
2133 | //should be getting the map layer from the grid server | ||
2134 | //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area) | ||
2135 | MapLayerReplyPacket mapReply = new MapLayerReplyPacket(); | ||
2136 | mapReply.AgentData.AgentID = AgentId; | ||
2137 | mapReply.AgentData.Flags = 0; | ||
2138 | mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1]; | ||
2139 | mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock(); | ||
2140 | mapReply.LayerData[0].Bottom = 0; | ||
2141 | mapReply.LayerData[0].Left = 0; | ||
2142 | mapReply.LayerData[0].Top = 30000; | ||
2143 | mapReply.LayerData[0].Right = 30000; | ||
2144 | mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-0000-9999-000000000006"); | ||
2145 | OutPacket(mapReply, ThrottleOutPacketType.Land); | ||
2146 | } | ||
2147 | |||
2148 | public void RequestMapBlocks(int minX, int minY, int maxX, int maxY) | ||
2149 | { | ||
2150 | /* | ||
2151 | IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY); | ||
2152 | MapBlockReplyPacket mbReply = new MapBlockReplyPacket(); | ||
2153 | mbReply.AgentData.AgentId = this.AgentId; | ||
2154 | int len; | ||
2155 | if (simMapProfiles == null) | ||
2156 | len = 0; | ||
2157 | else | ||
2158 | len = simMapProfiles.Count; | ||
2159 | |||
2160 | mbReply.Data = new MapBlockReplyPacket.DataBlock[len]; | ||
2161 | int iii; | ||
2162 | for (iii = 0; iii < len; iii++) | ||
2163 | { | ||
2164 | Hashtable mp = (Hashtable)simMapProfiles[iii]; | ||
2165 | mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock(); | ||
2166 | mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]); | ||
2167 | mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]); | ||
2168 | mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]); | ||
2169 | mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]); | ||
2170 | mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]); | ||
2171 | mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]); | ||
2172 | mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]); | ||
2173 | mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]); | ||
2174 | } | ||
2175 | this.OutPacket(mbReply, ThrottleOutPacketType.Land); | ||
2176 | */ | ||
2177 | } | ||
2178 | |||
2179 | // Previously ClientView.PacketQueue | ||
2180 | protected BlockingQueue<QueItem> PacketQueue; | ||
2181 | |||
2182 | protected Queue<QueItem> IncomingPacketQueue; | ||
2183 | protected Queue<QueItem> OutgoingPacketQueue; | ||
2184 | protected Queue<QueItem> ResendOutgoingPacketQueue; | ||
2185 | protected Queue<QueItem> LandOutgoingPacketQueue; | ||
2186 | protected Queue<QueItem> WindOutgoingPacketQueue; | ||
2187 | protected Queue<QueItem> CloudOutgoingPacketQueue; | ||
2188 | protected Queue<QueItem> TaskOutgoingPacketQueue; | ||
2189 | protected Queue<QueItem> TextureOutgoingPacketQueue; | ||
2190 | protected Queue<QueItem> AssetOutgoingPacketQueue; | ||
2191 | |||
2192 | protected Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); | ||
2193 | protected Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); | ||
2194 | |||
2195 | protected Timer AckTimer; | ||
2196 | protected uint Sequence = 0; | ||
2197 | protected object SequenceLock = new object(); | ||
2198 | protected const int MAX_APPENDED_ACKS = 10; | ||
2199 | protected const int RESEND_TIMEOUT = 4000; | ||
2200 | protected const int MAX_SEQUENCE = 0xFFFFFF; | ||
2201 | |||
2202 | private uint m_circuitCode; | ||
2203 | public EndPoint userEP; | ||
2204 | |||
2205 | protected PacketServer m_networkServer; | ||
2206 | |||
2207 | public uint CircuitCode | ||
2208 | { | ||
2209 | get { return m_circuitCode; } | ||
2210 | set { m_circuitCode = value; } | ||
2211 | } | ||
2212 | |||
2213 | protected virtual void ProcessOutPacket(Packet Pack) | ||
2214 | { | ||
2215 | // Keep track of when this packet was sent out | ||
2216 | Pack.TickCount = System.Environment.TickCount; | ||
2217 | |||
2218 | if (!Pack.Header.Resent) | ||
2219 | { | ||
2220 | // Set the sequence number | ||
2221 | lock (SequenceLock) | ||
2222 | { | ||
2223 | if (Sequence >= MAX_SEQUENCE) | ||
2224 | { | ||
2225 | Sequence = 1; | ||
2226 | } | ||
2227 | else | ||
2228 | { | ||
2229 | Sequence++; | ||
2230 | } | ||
2231 | |||
2232 | Pack.Header.Sequence = Sequence; | ||
2233 | } | ||
2234 | |||
2235 | if (Pack.Header.Reliable) //DIRTY HACK | ||
2236 | { | ||
2237 | lock (NeedAck) | ||
2238 | { | ||
2239 | if (!NeedAck.ContainsKey(Pack.Header.Sequence)) | ||
2240 | { | ||
2241 | try | ||
2242 | { | ||
2243 | NeedAck.Add(Pack.Header.Sequence, Pack); | ||
2244 | } | ||
2245 | catch (Exception e) // HACKY | ||
2246 | { | ||
2247 | e.ToString(); | ||
2248 | // Ignore | ||
2249 | // Seems to throw a exception here occasionally | ||
2250 | // of 'duplicate key' despite being locked. | ||
2251 | // !?!?!? | ||
2252 | } | ||
2253 | } | ||
2254 | else | ||
2255 | { | ||
2256 | // Client.Log("Attempted to add a duplicate sequence number (" + | ||
2257 | // packet.Header.Sequence + ") to the NeedAck dictionary for packet type " + | ||
2258 | // packet.Type.ToString(), Helpers.LogLevel.Warning); | ||
2259 | } | ||
2260 | } | ||
2261 | |||
2262 | // Don't append ACKs to resent packets, in case that's what was causing the | ||
2263 | // delivery to fail | ||
2264 | if (!Pack.Header.Resent) | ||
2265 | { | ||
2266 | // Append any ACKs that need to be sent out to this packet | ||
2267 | lock (PendingAcks) | ||
2268 | { | ||
2269 | if (PendingAcks.Count > 0 && PendingAcks.Count < MAX_APPENDED_ACKS && | ||
2270 | Pack.Type != PacketType.PacketAck && | ||
2271 | Pack.Type != PacketType.LogoutRequest) | ||
2272 | { | ||
2273 | Pack.Header.AckList = new uint[PendingAcks.Count]; | ||
2274 | int i = 0; | ||
2275 | |||
2276 | foreach (uint ack in PendingAcks.Values) | ||
2277 | { | ||
2278 | Pack.Header.AckList[i] = ack; | ||
2279 | i++; | ||
2280 | } | ||
2281 | |||
2282 | PendingAcks.Clear(); | ||
2283 | Pack.Header.AppendedAcks = true; | ||
2284 | } | ||
2285 | } | ||
2286 | } | ||
2287 | } | ||
2288 | } | ||
2289 | |||
2290 | byte[] ZeroOutBuffer = new byte[4096]; | ||
2291 | byte[] sendbuffer; | ||
2292 | sendbuffer = Pack.ToBytes(); | ||
2293 | |||
2294 | try | ||
2295 | { | ||
2296 | if (Pack.Header.Zerocoded) | ||
2297 | { | ||
2298 | int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); | ||
2299 | m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode); //userEP); | ||
2300 | } | ||
2301 | else | ||
2302 | { | ||
2303 | m_networkServer.SendPacketTo(sendbuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); | ||
2304 | //userEP); | ||
2305 | } | ||
2306 | } | ||
2307 | catch (Exception e) | ||
2308 | { | ||
2309 | MainLog.Instance.Warn("client", | ||
2310 | "ClientView.PacketQueue.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + | ||
2311 | userEP.ToString() + " - killing thread"); | ||
2312 | MainLog.Instance.Error(e.ToString()); | ||
2313 | KillThread(); | ||
2314 | } | ||
2315 | } | ||
2316 | |||
2317 | public virtual void InPacket(Packet NewPack) | ||
2318 | { | ||
2319 | // Handle appended ACKs | ||
2320 | if (NewPack.Header.AppendedAcks) | ||
2321 | { | ||
2322 | lock (NeedAck) | ||
2323 | { | ||
2324 | foreach (uint ack in NewPack.Header.AckList) | ||
2325 | { | ||
2326 | NeedAck.Remove(ack); | ||
2327 | } | ||
2328 | } | ||
2329 | } | ||
2330 | |||
2331 | // Handle PacketAck packets | ||
2332 | if (NewPack.Type == PacketType.PacketAck) | ||
2333 | { | ||
2334 | PacketAckPacket ackPacket = (PacketAckPacket) NewPack; | ||
2335 | |||
2336 | lock (NeedAck) | ||
2337 | { | ||
2338 | foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) | ||
2339 | { | ||
2340 | NeedAck.Remove(block.ID); | ||
2341 | } | ||
2342 | } | ||
2343 | } | ||
2344 | else if ((NewPack.Type == PacketType.StartPingCheck)) | ||
2345 | { | ||
2346 | //reply to pingcheck | ||
2347 | StartPingCheckPacket startPing = (StartPingCheckPacket) NewPack; | ||
2348 | CompletePingCheckPacket endPing = new CompletePingCheckPacket(); | ||
2349 | endPing.PingID.PingID = startPing.PingID.PingID; | ||
2350 | OutPacket(endPing, ThrottleOutPacketType.Task); | ||
2351 | } | ||
2352 | else | ||
2353 | { | ||
2354 | QueItem item = new QueItem(); | ||
2355 | item.Packet = NewPack; | ||
2356 | item.Incoming = true; | ||
2357 | PacketQueue.Enqueue(item); | ||
2358 | } | ||
2359 | } | ||
2360 | |||
2361 | private void ThrottleCheck(ref int TypeBytesSent, int Throttle, Queue<QueItem> q, QueItem item) | ||
2362 | { | ||
2363 | // The idea.. is if the packet throttle queues are empty | ||
2364 | // and the client is under throttle for the type. Queue | ||
2365 | // it up directly. This basically short cuts having to | ||
2366 | // wait for the timer to fire to put things into the | ||
2367 | // output queue | ||
2368 | |||
2369 | if(q.Count == 0 && TypeBytesSent <= ((int)(Throttle / throttleTimeDivisor))) | ||
2370 | { | ||
2371 | bytesSent += item.Packet.ToBytes().Length; | ||
2372 | TypeBytesSent += item.Packet.ToBytes().Length; | ||
2373 | PacketQueue.Enqueue(item); | ||
2374 | } | ||
2375 | else | ||
2376 | { | ||
2377 | q.Enqueue(item); | ||
2378 | } | ||
2379 | } | ||
2380 | |||
2381 | public virtual void OutPacket(Packet NewPack, ThrottleOutPacketType throttlePacketType) | ||
2382 | { | ||
2383 | QueItem item = new QueItem(); | ||
2384 | item.Packet = NewPack; | ||
2385 | item.Incoming = false; | ||
2386 | item.throttleType = throttlePacketType; // Packet throttle type | ||
2387 | |||
2388 | // The idea.. is if the packet throttle queues are empty and the client is under throttle for the type. | ||
2389 | // Queue it up directly. | ||
2390 | switch (throttlePacketType) | ||
2391 | { | ||
2392 | case ThrottleOutPacketType.Resend: | ||
2393 | ThrottleCheck(ref ResendBytesSent, ResendthrottleOutbound, ResendOutgoingPacketQueue, item); | ||
2394 | break; | ||
2395 | case ThrottleOutPacketType.Texture: | ||
2396 | ThrottleCheck(ref TextureBytesSent, TexturethrottleOutbound, TextureOutgoingPacketQueue, item); | ||
2397 | break; | ||
2398 | case ThrottleOutPacketType.Task: | ||
2399 | ThrottleCheck(ref TaskBytesSent, TaskthrottleOutbound, TaskOutgoingPacketQueue, item); | ||
2400 | break; | ||
2401 | case ThrottleOutPacketType.Land: | ||
2402 | ThrottleCheck(ref LandBytesSent, LandthrottleOutbound, LandOutgoingPacketQueue, item); | ||
2403 | break; | ||
2404 | case ThrottleOutPacketType.Asset: | ||
2405 | ThrottleCheck(ref AssetBytesSent, AssetthrottleOutbound, AssetOutgoingPacketQueue, item); | ||
2406 | break; | ||
2407 | case ThrottleOutPacketType.Cloud: | ||
2408 | ThrottleCheck(ref CloudBytesSent, CloudthrottleOutbound, CloudOutgoingPacketQueue, item); | ||
2409 | break; | ||
2410 | case ThrottleOutPacketType.Wind: | ||
2411 | ThrottleCheck(ref WindBytesSent, WindthrottleOutbound, WindOutgoingPacketQueue, item); | ||
2412 | break; | ||
2413 | |||
2414 | default: | ||
2415 | // Acknowledgements and other such stuff should go directly to the blocking Queue | ||
2416 | // Throttling them may and likely 'will' be problematic | ||
2417 | PacketQueue.Enqueue(item); | ||
2418 | break; | ||
2419 | } | ||
2420 | //OutgoingPacketQueue.Enqueue(item); | ||
2421 | } | ||
2422 | |||
2423 | # region Low Level Packet Methods | ||
2424 | |||
2425 | protected void ack_pack(Packet Pack) | ||
2426 | { | ||
2427 | if (Pack.Header.Reliable) | ||
2428 | { | ||
2429 | PacketAckPacket ack_it = new PacketAckPacket(); | ||
2430 | ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; | ||
2431 | ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); | ||
2432 | ack_it.Packets[0].ID = Pack.Header.Sequence; | ||
2433 | ack_it.Header.Reliable = false; | ||
2434 | |||
2435 | OutPacket(ack_it, ThrottleOutPacketType.Unknown); | ||
2436 | } | ||
2437 | /* | ||
2438 | if (Pack.Header.Reliable) | ||
2439 | { | ||
2440 | lock (PendingAcks) | ||
2441 | { | ||
2442 | uint sequence = (uint)Pack.Header.Sequence; | ||
2443 | if (!PendingAcks.ContainsKey(sequence)) { PendingAcks[sequence] = sequence; } | ||
2444 | } | ||
2445 | }*/ | ||
2446 | } | ||
2447 | |||
2448 | protected void ResendUnacked() | ||
2449 | { | ||
2450 | int now = System.Environment.TickCount; | ||
2451 | |||
2452 | lock (NeedAck) | ||
2453 | { | ||
2454 | foreach (Packet packet in NeedAck.Values) | ||
2455 | { | ||
2456 | if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) | ||
2457 | { | ||
2458 | MainLog.Instance.Verbose("Resending " + packet.Type.ToString() + " packet, " + | ||
2459 | (now - packet.TickCount) + "ms have passed"); | ||
2460 | |||
2461 | packet.Header.Resent = true; | ||
2462 | OutPacket(packet, ThrottleOutPacketType.Resend); | ||
2463 | } | ||
2464 | } | ||
2465 | } | ||
2466 | } | ||
2467 | |||
2468 | protected void SendAcks() | ||
2469 | { | ||
2470 | lock (PendingAcks) | ||
2471 | { | ||
2472 | if (PendingAcks.Count > 0) | ||
2473 | { | ||
2474 | if (PendingAcks.Count > 250) | ||
2475 | { | ||
2476 | // FIXME: Handle the odd case where we have too many pending ACKs queued up | ||
2477 | MainLog.Instance.Verbose("Too many ACKs queued up!"); | ||
2478 | return; | ||
2479 | } | ||
2480 | |||
2481 | //OpenSim.Framework.Console.MainLog.Instance.WriteLine("Sending PacketAck"); | ||
2482 | |||
2483 | |||
2484 | int i = 0; | ||
2485 | PacketAckPacket acks = new PacketAckPacket(); | ||
2486 | acks.Packets = new PacketAckPacket.PacketsBlock[PendingAcks.Count]; | ||
2487 | |||
2488 | foreach (uint ack in PendingAcks.Values) | ||
2489 | { | ||
2490 | acks.Packets[i] = new PacketAckPacket.PacketsBlock(); | ||
2491 | acks.Packets[i].ID = ack; | ||
2492 | i++; | ||
2493 | } | ||
2494 | |||
2495 | acks.Header.Reliable = false; | ||
2496 | OutPacket(acks, ThrottleOutPacketType.Unknown); | ||
2497 | |||
2498 | PendingAcks.Clear(); | ||
2499 | } | ||
2500 | } | ||
2501 | } | ||
2502 | |||
2503 | protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) | ||
2504 | { | ||
2505 | SendAcks(); | ||
2506 | ResendUnacked(); | ||
2507 | } | ||
2508 | |||
2509 | #endregion | ||
2510 | // Previously ClientView.ProcessPackets | ||
2511 | private int m_moneyBalance; | ||
2512 | |||
2513 | public int MoneyBalance | ||
2514 | { | ||
2515 | get { return m_moneyBalance; } | ||
2516 | } | ||
2517 | |||
2518 | public bool AddMoney(int debit) | ||
2519 | { | ||
2520 | if (m_moneyBalance + debit >= 0) | ||
2521 | { | ||
2522 | m_moneyBalance += debit; | ||
2523 | SendMoneyBalance(LLUUID.Zero, true, Helpers.StringToField("Poof Poof!"), m_moneyBalance); | ||
2524 | return true; | ||
2525 | } | ||
2526 | else | ||
2527 | { | ||
2528 | return false; | ||
2529 | } | ||
2530 | } | ||
2531 | |||
2532 | protected void ProcessInPacket(Packet Pack) | ||
2533 | { | ||
2534 | ack_pack(Pack); | ||
2535 | |||
2536 | if (ProcessPacketMethod(Pack)) | ||
2537 | { | ||
2538 | //there is a handler registered that handled this packet type | ||
2539 | return; | ||
2540 | } | ||
2541 | else | ||
2542 | { | ||
2543 | Encoding _enc = Encoding.ASCII; | ||
2544 | |||
2545 | switch (Pack.Type) | ||
2546 | { | ||
2547 | #region Scene/Avatar | ||
2548 | |||
2549 | case PacketType.AvatarPropertiesRequest: | ||
2550 | AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket) Pack; | ||
2551 | if (OnRequestAvatarProperties != null) | ||
2552 | { | ||
2553 | OnRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID); | ||
2554 | } | ||
2555 | break; | ||
2556 | case PacketType.ChatFromViewer: | ||
2557 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket) Pack; | ||
2558 | |||
2559 | string fromName = ""; //ClientAvatar.firstname + " " + ClientAvatar.lastname; | ||
2560 | byte[] message = inchatpack.ChatData.Message; | ||
2561 | byte type = inchatpack.ChatData.Type; | ||
2562 | LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos; | ||
2563 | LLUUID fromAgentID = AgentId; | ||
2564 | |||
2565 | int channel = inchatpack.ChatData.Channel; | ||
2566 | |||
2567 | if (OnChatFromViewer != null) | ||
2568 | { | ||
2569 | ChatFromViewerArgs args = new ChatFromViewerArgs(); | ||
2570 | args.Channel = channel; | ||
2571 | args.From = fromName; | ||
2572 | args.Message = Helpers.FieldToUTF8String(message); | ||
2573 | args.Type = (ChatTypeEnum) type; | ||
2574 | args.Position = fromPos; | ||
2575 | |||
2576 | args.Scene = Scene; | ||
2577 | args.Sender = this; | ||
2578 | |||
2579 | OnChatFromViewer(this, args); | ||
2580 | } | ||
2581 | break; | ||
2582 | case PacketType.ImprovedInstantMessage: | ||
2583 | ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket) Pack; | ||
2584 | string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); | ||
2585 | string IMmessage = Helpers.FieldToUTF8String(msgpack.MessageBlock.Message); | ||
2586 | if (OnInstantMessage != null) | ||
2587 | { | ||
2588 | OnInstantMessage(msgpack.AgentData.AgentID, msgpack.AgentData.SessionID, | ||
2589 | msgpack.MessageBlock.ToAgentID, msgpack.MessageBlock.ID, | ||
2590 | msgpack.MessageBlock.Timestamp, IMfromName, IMmessage, | ||
2591 | msgpack.MessageBlock.Dialog); | ||
2592 | } | ||
2593 | break; | ||
2594 | case PacketType.RezObject: | ||
2595 | RezObjectPacket rezPacket = (RezObjectPacket) Pack; | ||
2596 | if (OnRezObject != null) | ||
2597 | { | ||
2598 | OnRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd); | ||
2599 | } | ||
2600 | break; | ||
2601 | case PacketType.DeRezObject: | ||
2602 | if (OnDeRezObject != null) | ||
2603 | { | ||
2604 | OnDeRezObject(Pack, this); | ||
2605 | } | ||
2606 | break; | ||
2607 | case PacketType.ModifyLand: | ||
2608 | ModifyLandPacket modify = (ModifyLandPacket) Pack; | ||
2609 | if (modify.ParcelData.Length > 0) | ||
2610 | { | ||
2611 | if (OnModifyTerrain != null) | ||
2612 | { | ||
2613 | OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, | ||
2614 | modify.ModifyBlock.BrushSize, | ||
2615 | modify.ModifyBlock.Action, modify.ParcelData[0].North, | ||
2616 | modify.ParcelData[0].West, this); | ||
2617 | } | ||
2618 | } | ||
2619 | break; | ||
2620 | case PacketType.RegionHandshakeReply: | ||
2621 | if (OnRegionHandShakeReply != null) | ||
2622 | { | ||
2623 | OnRegionHandShakeReply(this); | ||
2624 | } | ||
2625 | break; | ||
2626 | case PacketType.AgentWearablesRequest: | ||
2627 | if (OnRequestWearables != null) | ||
2628 | { | ||
2629 | OnRequestWearables( ); | ||
2630 | } | ||
2631 | if (OnRequestAvatarsData != null) | ||
2632 | { | ||
2633 | OnRequestAvatarsData(this); | ||
2634 | } | ||
2635 | break; | ||
2636 | case PacketType.AgentSetAppearance: | ||
2637 | //OpenSim.Framework.Console.MainLog.Instance.Verbose("set appear", Pack.ToString()); | ||
2638 | AgentSetAppearancePacket appear = (AgentSetAppearancePacket) Pack; | ||
2639 | if (OnSetAppearance != null) | ||
2640 | { | ||
2641 | OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam); | ||
2642 | } | ||
2643 | break; | ||
2644 | case PacketType.SetAlwaysRun: | ||
2645 | SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; | ||
2646 | |||
2647 | if (OnSetAlwaysRun != null) | ||
2648 | OnSetAlwaysRun(this,run.AgentData.AlwaysRun); | ||
2649 | |||
2650 | break; | ||
2651 | case PacketType.CompleteAgentMovement: | ||
2652 | if (OnCompleteMovementToRegion != null) | ||
2653 | { | ||
2654 | OnCompleteMovementToRegion(); | ||
2655 | } | ||
2656 | break; | ||
2657 | case PacketType.AgentUpdate: | ||
2658 | if (OnAgentUpdate != null) | ||
2659 | { | ||
2660 | AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack; | ||
2661 | |||
2662 | OnAgentUpdate(this, agenUpdate); //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa); | ||
2663 | } | ||
2664 | break; | ||
2665 | case PacketType.AgentAnimation: | ||
2666 | AgentAnimationPacket AgentAni = (AgentAnimationPacket) Pack; | ||
2667 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) | ||
2668 | { | ||
2669 | if (AgentAni.AnimationList[i].StartAnim) | ||
2670 | { | ||
2671 | if (OnStartAnim != null) | ||
2672 | { | ||
2673 | OnStartAnim(this, AgentAni.AnimationList[i].AnimID, 1); | ||
2674 | } | ||
2675 | } | ||
2676 | } | ||
2677 | break; | ||
2678 | case PacketType.AgentRequestSit: | ||
2679 | if (OnAgentRequestSit != null) | ||
2680 | { | ||
2681 | AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket) Pack; | ||
2682 | OnAgentRequestSit(this, agentRequestSit.AgentData.AgentID, | ||
2683 | agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); | ||
2684 | } | ||
2685 | break; | ||
2686 | case PacketType.AgentSit: | ||
2687 | if (OnAgentSit != null) | ||
2688 | { | ||
2689 | AgentSitPacket agentSit = (AgentSitPacket) Pack; | ||
2690 | OnAgentSit(this, agentSit.AgentData.AgentID); | ||
2691 | } | ||
2692 | break; | ||
2693 | case PacketType.AvatarPickerRequest: | ||
2694 | AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack; | ||
2695 | AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData; | ||
2696 | AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; | ||
2697 | //System.Console.WriteLine("Agent Sends:" + Helpers.FieldToUTF8String(querydata.Name)); | ||
2698 | if (OnAvatarPickerRequest != null) | ||
2699 | { | ||
2700 | OnAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, Helpers.FieldToUTF8String(querydata.Name)); | ||
2701 | } | ||
2702 | break; | ||
2703 | #endregion | ||
2704 | |||
2705 | #region Objects/m_sceneObjects | ||
2706 | |||
2707 | case PacketType.ObjectLink: | ||
2708 | //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); | ||
2709 | ObjectLinkPacket link = (ObjectLinkPacket) Pack; | ||
2710 | uint parentprimid = 0; | ||
2711 | List<uint> childrenprims = new List<uint>(); | ||
2712 | if (link.ObjectData.Length > 1) | ||
2713 | { | ||
2714 | parentprimid = link.ObjectData[0].ObjectLocalID; | ||
2715 | |||
2716 | for (int i = 1; i < link.ObjectData.Length; i++) | ||
2717 | { | ||
2718 | childrenprims.Add(link.ObjectData[i].ObjectLocalID); | ||
2719 | } | ||
2720 | } | ||
2721 | if (OnLinkObjects != null) | ||
2722 | { | ||
2723 | OnLinkObjects(parentprimid, childrenprims); | ||
2724 | } | ||
2725 | break; | ||
2726 | case PacketType.ObjectDelink: | ||
2727 | //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); | ||
2728 | ObjectDelinkPacket delink = (ObjectDelinkPacket) Pack; | ||
2729 | |||
2730 | // It appears the prim at index 0 is not always the root prim (for | ||
2731 | // instance, when one prim of a link set has been edited independently | ||
2732 | // of the others). Therefore, we'll pass all the ids onto the delink | ||
2733 | // method for it to decide which is the root. | ||
2734 | List<uint> prims = new List<uint>(); | ||
2735 | for (int i = 0; i < delink.ObjectData.Length; i++) | ||
2736 | { | ||
2737 | prims.Add(delink.ObjectData[i].ObjectLocalID); | ||
2738 | } | ||
2739 | |||
2740 | if (OnDelinkObjects != null) | ||
2741 | { | ||
2742 | OnDelinkObjects(prims); | ||
2743 | } | ||
2744 | |||
2745 | break; | ||
2746 | case PacketType.ObjectAdd: | ||
2747 | if (OnAddPrim != null) | ||
2748 | { | ||
2749 | ObjectAddPacket addPacket = (ObjectAddPacket) Pack; | ||
2750 | PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket); | ||
2751 | OnAddPrim(AgentId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape); | ||
2752 | } | ||
2753 | break; | ||
2754 | case PacketType.ObjectShape: | ||
2755 | ObjectShapePacket shapePacket = (ObjectShapePacket) Pack; | ||
2756 | for (int i = 0; i < shapePacket.ObjectData.Length; i++) | ||
2757 | { | ||
2758 | if (OnUpdatePrimShape != null) | ||
2759 | { | ||
2760 | OnUpdatePrimShape(shapePacket.ObjectData[i].ObjectLocalID, shapePacket.ObjectData[i]); | ||
2761 | } | ||
2762 | } | ||
2763 | break; | ||
2764 | case PacketType.ObjectExtraParams: | ||
2765 | ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket) Pack; | ||
2766 | if (OnUpdateExtraParams != null) | ||
2767 | { | ||
2768 | OnUpdateExtraParams(extraPar.ObjectData[0].ObjectLocalID, extraPar.ObjectData[0].ParamType, | ||
2769 | extraPar.ObjectData[0].ParamInUse, extraPar.ObjectData[0].ParamData); | ||
2770 | } | ||
2771 | break; | ||
2772 | case PacketType.ObjectDuplicate: | ||
2773 | ObjectDuplicatePacket dupe = (ObjectDuplicatePacket) Pack; | ||
2774 | ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData; | ||
2775 | for (int i = 0; i < dupe.ObjectData.Length; i++) | ||
2776 | { | ||
2777 | if (OnObjectDuplicate != null) | ||
2778 | { | ||
2779 | OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, | ||
2780 | dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID, AgentandGroupData.GroupID); | ||
2781 | } | ||
2782 | } | ||
2783 | |||
2784 | break; | ||
2785 | |||
2786 | case PacketType.ObjectSelect: | ||
2787 | ObjectSelectPacket incomingselect = (ObjectSelectPacket) Pack; | ||
2788 | for (int i = 0; i < incomingselect.ObjectData.Length; i++) | ||
2789 | { | ||
2790 | if (OnObjectSelect != null) | ||
2791 | { | ||
2792 | OnObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this); | ||
2793 | } | ||
2794 | } | ||
2795 | break; | ||
2796 | case PacketType.ObjectDeselect: | ||
2797 | ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket) Pack; | ||
2798 | for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) | ||
2799 | { | ||
2800 | if (OnObjectDeselect != null) | ||
2801 | { | ||
2802 | OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this); | ||
2803 | } | ||
2804 | } | ||
2805 | break; | ||
2806 | case PacketType.ObjectFlagUpdate: | ||
2807 | ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket) Pack; | ||
2808 | if (OnUpdatePrimFlags != null) | ||
2809 | { | ||
2810 | OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this); | ||
2811 | } | ||
2812 | break; | ||
2813 | case PacketType.ObjectImage: | ||
2814 | ObjectImagePacket imagePack = (ObjectImagePacket) Pack; | ||
2815 | for (int i = 0; i < imagePack.ObjectData.Length; i++) | ||
2816 | { | ||
2817 | if (OnUpdatePrimTexture != null) | ||
2818 | { | ||
2819 | OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, | ||
2820 | imagePack.ObjectData[i].TextureEntry, this); | ||
2821 | } | ||
2822 | } | ||
2823 | break; | ||
2824 | case PacketType.ObjectGrab: | ||
2825 | ObjectGrabPacket grab = (ObjectGrabPacket) Pack; | ||
2826 | if (OnGrabObject != null) | ||
2827 | { | ||
2828 | OnGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this); | ||
2829 | } | ||
2830 | break; | ||
2831 | case PacketType.ObjectGrabUpdate: | ||
2832 | ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket) Pack; | ||
2833 | if (OnGrabUpdate != null) | ||
2834 | { | ||
2835 | OnGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial, | ||
2836 | grabUpdate.ObjectData.GrabPosition, this); | ||
2837 | } | ||
2838 | break; | ||
2839 | case PacketType.ObjectDeGrab: | ||
2840 | ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket) Pack; | ||
2841 | if (OnDeGrabObject != null) | ||
2842 | { | ||
2843 | OnDeGrabObject(deGrab.ObjectData.LocalID, this); | ||
2844 | } | ||
2845 | break; | ||
2846 | case PacketType.ObjectDescription: | ||
2847 | ObjectDescriptionPacket objDes = (ObjectDescriptionPacket) Pack; | ||
2848 | for (int i = 0; i < objDes.ObjectData.Length; i++) | ||
2849 | { | ||
2850 | if (OnObjectDescription != null) | ||
2851 | { | ||
2852 | OnObjectDescription(objDes.ObjectData[i].LocalID, | ||
2853 | enc.GetString(objDes.ObjectData[i].Description)); | ||
2854 | } | ||
2855 | } | ||
2856 | break; | ||
2857 | case PacketType.ObjectName: | ||
2858 | ObjectNamePacket objName = (ObjectNamePacket) Pack; | ||
2859 | for (int i = 0; i < objName.ObjectData.Length; i++) | ||
2860 | { | ||
2861 | if (OnObjectName != null) | ||
2862 | { | ||
2863 | OnObjectName(objName.ObjectData[i].LocalID, enc.GetString(objName.ObjectData[i].Name)); | ||
2864 | } | ||
2865 | } | ||
2866 | break; | ||
2867 | case PacketType.ObjectPermissions: | ||
2868 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
2869 | break; | ||
2870 | |||
2871 | case PacketType.RequestObjectPropertiesFamily: | ||
2872 | //This powers the little tooltip that appears when you move your mouse over an object | ||
2873 | RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack; | ||
2874 | |||
2875 | |||
2876 | RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData; | ||
2877 | |||
2878 | if (OnRequestObjectPropertiesFamily != null) | ||
2879 | { | ||
2880 | OnRequestObjectPropertiesFamily(this, this.m_agentId, packObjBlock.RequestFlags, packObjBlock.ObjectID); | ||
2881 | |||
2882 | |||
2883 | } | ||
2884 | |||
2885 | break; | ||
2886 | |||
2887 | #endregion | ||
2888 | |||
2889 | #region Inventory/Asset/Other related packets | ||
2890 | |||
2891 | case PacketType.RequestImage: | ||
2892 | RequestImagePacket imageRequest = (RequestImagePacket) Pack; | ||
2893 | //Console.WriteLine("image request: " + Pack.ToString()); | ||
2894 | for (int i = 0; i < imageRequest.RequestImage.Length; i++) | ||
2895 | { | ||
2896 | // still working on the Texture download module so for now using old method | ||
2897 | // TextureRequestArgs args = new TextureRequestArgs(); | ||
2898 | // args.RequestedAssetID = imageRequest.RequestImage[i].Image; | ||
2899 | // args.DiscardLevel = imageRequest.RequestImage[i].DiscardLevel; | ||
2900 | // args.PacketNumber = imageRequest.RequestImage[i].Packet; | ||
2901 | |||
2902 | // if (OnRequestTexture != null) | ||
2903 | // { | ||
2904 | // OnRequestTexture(this, args); | ||
2905 | // } | ||
2906 | |||
2907 | m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, | ||
2908 | imageRequest.RequestImage[i].Packet, | ||
2909 | imageRequest.RequestImage[i].DiscardLevel); | ||
2910 | } | ||
2911 | break; | ||
2912 | case PacketType.TransferRequest: | ||
2913 | //Console.WriteLine("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); | ||
2914 | TransferRequestPacket transfer = (TransferRequestPacket) Pack; | ||
2915 | m_assetCache.AddAssetRequest(this, transfer); | ||
2916 | break; | ||
2917 | case PacketType.AssetUploadRequest: | ||
2918 | AssetUploadRequestPacket request = (AssetUploadRequestPacket) Pack; | ||
2919 | // Console.WriteLine("upload request " + Pack.ToString()); | ||
2920 | // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionID).ToStringHyphenated()); | ||
2921 | if (OnAssetUploadRequest != null) | ||
2922 | { | ||
2923 | OnAssetUploadRequest(this, request.AssetBlock.TransactionID.Combine(SecureSessionID), | ||
2924 | request.AssetBlock.TransactionID, request.AssetBlock.Type, | ||
2925 | request.AssetBlock.AssetData, request.AssetBlock.StoreLocal); | ||
2926 | } | ||
2927 | break; | ||
2928 | case PacketType.RequestXfer: | ||
2929 | RequestXferPacket xferReq = (RequestXferPacket) Pack; | ||
2930 | if (OnRequestXfer != null) | ||
2931 | { | ||
2932 | OnRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename)); | ||
2933 | } | ||
2934 | break; | ||
2935 | case PacketType.SendXferPacket: | ||
2936 | SendXferPacketPacket xferRec = (SendXferPacketPacket) Pack; | ||
2937 | if (OnXferReceive != null) | ||
2938 | { | ||
2939 | OnXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); | ||
2940 | } | ||
2941 | break; | ||
2942 | case PacketType.ConfirmXferPacket: | ||
2943 | ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket) Pack; | ||
2944 | if (OnConfirmXfer != null) | ||
2945 | { | ||
2946 | OnConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); | ||
2947 | } | ||
2948 | break; | ||
2949 | case PacketType.CreateInventoryFolder: | ||
2950 | if (OnCreateNewInventoryFolder != null) | ||
2951 | { | ||
2952 | CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket) Pack; | ||
2953 | OnCreateNewInventoryFolder(this, invFolder.FolderData.FolderID, | ||
2954 | (ushort) invFolder.FolderData.Type, | ||
2955 | Util.FieldToString(invFolder.FolderData.Name), | ||
2956 | invFolder.FolderData.ParentID); | ||
2957 | } | ||
2958 | break; | ||
2959 | case PacketType.CreateInventoryItem: | ||
2960 | CreateInventoryItemPacket createItem = (CreateInventoryItemPacket) Pack; | ||
2961 | if (OnCreateNewInventoryItem != null) | ||
2962 | { | ||
2963 | OnCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, | ||
2964 | createItem.InventoryBlock.FolderID, | ||
2965 | createItem.InventoryBlock.CallbackID, | ||
2966 | Util.FieldToString(createItem.InventoryBlock.Description), | ||
2967 | Util.FieldToString(createItem.InventoryBlock.Name), | ||
2968 | createItem.InventoryBlock.InvType, | ||
2969 | createItem.InventoryBlock.Type, | ||
2970 | createItem.InventoryBlock.WearableType, | ||
2971 | createItem.InventoryBlock.NextOwnerMask); | ||
2972 | } | ||
2973 | break; | ||
2974 | case PacketType.FetchInventory: | ||
2975 | if (OnFetchInventory != null) | ||
2976 | { | ||
2977 | FetchInventoryPacket FetchInventory = (FetchInventoryPacket) Pack; | ||
2978 | for (int i = 0; i < FetchInventory.InventoryData.Length; i++) | ||
2979 | { | ||
2980 | OnFetchInventory(this, FetchInventory.InventoryData[i].ItemID, | ||
2981 | FetchInventory.InventoryData[i].OwnerID); | ||
2982 | } | ||
2983 | } | ||
2984 | break; | ||
2985 | case PacketType.FetchInventoryDescendents: | ||
2986 | if (OnFetchInventoryDescendents != null) | ||
2987 | { | ||
2988 | FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket) Pack; | ||
2989 | OnFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, | ||
2990 | Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems, | ||
2991 | Fetch.InventoryData.SortOrder); | ||
2992 | } | ||
2993 | break; | ||
2994 | case PacketType.UpdateInventoryItem: | ||
2995 | UpdateInventoryItemPacket update = (UpdateInventoryItemPacket) Pack; | ||
2996 | if (OnUpdateInventoryItem != null) | ||
2997 | { | ||
2998 | for (int i = 0; i < update.InventoryData.Length; i++) | ||
2999 | { | ||
3000 | if (update.InventoryData[i].TransactionID != LLUUID.Zero) | ||
3001 | { | ||
3002 | OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, | ||
3003 | update.InventoryData[i].TransactionID.Combine(SecureSessionID), | ||
3004 | update.InventoryData[i].ItemID); | ||
3005 | } | ||
3006 | } | ||
3007 | } | ||
3008 | //Console.WriteLine(Pack.ToString()); | ||
3009 | /*for (int i = 0; i < update.InventoryData.Length; i++) | ||
3010 | { | ||
3011 | if (update.InventoryData[i].TransactionID != LLUUID.Zero) | ||
3012 | { | ||
3013 | AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); | ||
3014 | if (asset != null) | ||
3015 | { | ||
3016 | // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); | ||
3017 | m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); | ||
3018 | } | ||
3019 | else | ||
3020 | { | ||
3021 | asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); | ||
3022 | if (asset != null) | ||
3023 | { | ||
3024 | //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache"); | ||
3025 | m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); | ||
3026 | } | ||
3027 | else | ||
3028 | { | ||
3029 | //Console.WriteLine("trying to update inventory item, but asset is null"); | ||
3030 | } | ||
3031 | } | ||
3032 | } | ||
3033 | else | ||
3034 | { | ||
3035 | m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ; | ||
3036 | } | ||
3037 | }*/ | ||
3038 | break; | ||
3039 | case PacketType.CopyInventoryItem: | ||
3040 | CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket) Pack; | ||
3041 | if (OnCopyInventoryItem != null) | ||
3042 | { | ||
3043 | foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData) | ||
3044 | { | ||
3045 | OnCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID, datablock.OldItemID, datablock.NewFolderID, Util.FieldToString(datablock.NewName)); | ||
3046 | } | ||
3047 | } | ||
3048 | break; | ||
3049 | case PacketType.RequestTaskInventory: | ||
3050 | RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket) Pack; | ||
3051 | if (OnRequestTaskInventory != null) | ||
3052 | { | ||
3053 | OnRequestTaskInventory(this, requesttask.InventoryData.LocalID); | ||
3054 | } | ||
3055 | break; | ||
3056 | case PacketType.UpdateTaskInventory: | ||
3057 | //Console.WriteLine(Pack.ToString()); | ||
3058 | UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket) Pack; | ||
3059 | if (OnUpdateTaskInventory != null) | ||
3060 | { | ||
3061 | if (updatetask.UpdateData.Key == 0) | ||
3062 | { | ||
3063 | OnUpdateTaskInventory(this, updatetask.InventoryData.ItemID, | ||
3064 | updatetask.InventoryData.FolderID, updatetask.UpdateData.LocalID); | ||
3065 | } | ||
3066 | } | ||
3067 | break; | ||
3068 | case PacketType.RemoveTaskInventory: | ||
3069 | RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket) Pack; | ||
3070 | if (OnRemoveTaskItem != null) | ||
3071 | { | ||
3072 | OnRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID); | ||
3073 | } | ||
3074 | break; | ||
3075 | case PacketType.MoveTaskInventory: | ||
3076 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
3077 | break; | ||
3078 | case PacketType.RezScript: | ||
3079 | //Console.WriteLine(Pack.ToString()); | ||
3080 | RezScriptPacket rezScript = (RezScriptPacket) Pack; | ||
3081 | if (OnRezScript != null) | ||
3082 | { | ||
3083 | OnRezScript(this, rezScript.InventoryBlock.ItemID, rezScript.UpdateBlock.ObjectLocalID); | ||
3084 | } | ||
3085 | break; | ||
3086 | case PacketType.MapLayerRequest: | ||
3087 | RequestMapLayer(); | ||
3088 | break; | ||
3089 | case PacketType.MapBlockRequest: | ||
3090 | MapBlockRequestPacket MapRequest = (MapBlockRequestPacket) Pack; | ||
3091 | if (OnRequestMapBlocks != null) | ||
3092 | { | ||
3093 | OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, | ||
3094 | MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); | ||
3095 | } | ||
3096 | break; | ||
3097 | case PacketType.MapNameRequest: | ||
3098 | MapNameRequestPacket map = (MapNameRequestPacket) Pack; | ||
3099 | string mapName = UTF8Encoding.UTF8.GetString(map.NameData.Name, 0, | ||
3100 | map.NameData.Name.Length - 1); | ||
3101 | if (OnMapNameRequest != null) | ||
3102 | { | ||
3103 | OnMapNameRequest(this, mapName); | ||
3104 | } | ||
3105 | break; | ||
3106 | case PacketType.TeleportLandmarkRequest: | ||
3107 | TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket) Pack; | ||
3108 | |||
3109 | TeleportStartPacket tpStart = new TeleportStartPacket(); | ||
3110 | tpStart.Info.TeleportFlags = 8; // tp via lm | ||
3111 | OutPacket(tpStart, ThrottleOutPacketType.Task); | ||
3112 | |||
3113 | TeleportProgressPacket tpProgress = new TeleportProgressPacket(); | ||
3114 | tpProgress.Info.Message = (new ASCIIEncoding()).GetBytes("sending_landmark"); | ||
3115 | tpProgress.Info.TeleportFlags = 8; | ||
3116 | tpProgress.AgentData.AgentID = tpReq.Info.AgentID; | ||
3117 | OutPacket(tpProgress, ThrottleOutPacketType.Task); | ||
3118 | |||
3119 | // Fetch landmark | ||
3120 | LLUUID lmid = tpReq.Info.LandmarkID; | ||
3121 | AssetBase lma = m_assetCache.GetAsset(lmid); | ||
3122 | if (lma != null) | ||
3123 | { | ||
3124 | AssetLandmark lm = new AssetLandmark(lma); | ||
3125 | |||
3126 | if (lm.RegionID == m_scene.RegionInfo.RegionID) | ||
3127 | { | ||
3128 | TeleportLocalPacket tpLocal = new TeleportLocalPacket(); | ||
3129 | |||
3130 | tpLocal.Info.AgentID = tpReq.Info.AgentID; | ||
3131 | tpLocal.Info.TeleportFlags = 8; // Teleport via landmark | ||
3132 | tpLocal.Info.LocationID = 2; | ||
3133 | tpLocal.Info.Position = lm.Position; | ||
3134 | OutPacket(tpLocal, ThrottleOutPacketType.Task); | ||
3135 | } | ||
3136 | else | ||
3137 | { | ||
3138 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | ||
3139 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | ||
3140 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | ||
3141 | OutPacket(tpCancel, ThrottleOutPacketType.Task); | ||
3142 | } | ||
3143 | } | ||
3144 | else | ||
3145 | { | ||
3146 | Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented"); | ||
3147 | |||
3148 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | ||
3149 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | ||
3150 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | ||
3151 | OutPacket(tpCancel, ThrottleOutPacketType.Task); | ||
3152 | } | ||
3153 | break; | ||
3154 | case PacketType.TeleportLocationRequest: | ||
3155 | TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket) Pack; | ||
3156 | // Console.WriteLine(tpLocReq.ToString()); | ||
3157 | |||
3158 | if (OnTeleportLocationRequest != null) | ||
3159 | { | ||
3160 | OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, | ||
3161 | tpLocReq.Info.LookAt, 16); | ||
3162 | } | ||
3163 | else | ||
3164 | { | ||
3165 | //no event handler so cancel request | ||
3166 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | ||
3167 | tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; | ||
3168 | tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; | ||
3169 | OutPacket(tpCancel, ThrottleOutPacketType.Task); | ||
3170 | } | ||
3171 | break; | ||
3172 | |||
3173 | #endregion | ||
3174 | |||
3175 | case PacketType.MoneyBalanceRequest: | ||
3176 | SendMoneyBalance(LLUUID.Zero, true, new byte[0], MoneyBalance); | ||
3177 | break; | ||
3178 | case PacketType.UUIDNameRequest: | ||
3179 | UUIDNameRequestPacket incoming = (UUIDNameRequestPacket) Pack; | ||
3180 | foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) | ||
3181 | { | ||
3182 | OnNameFromUUIDRequest(UUIDBlock.ID, this); | ||
3183 | } | ||
3184 | break; | ||
3185 | |||
3186 | #region Parcel related packets | ||
3187 | |||
3188 | case PacketType.ParcelPropertiesRequest: | ||
3189 | ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket) Pack; | ||
3190 | if (OnParcelPropertiesRequest != null) | ||
3191 | { | ||
3192 | OnParcelPropertiesRequest((int) Math.Round(propertiesRequest.ParcelData.West), | ||
3193 | (int) Math.Round(propertiesRequest.ParcelData.South), | ||
3194 | (int) Math.Round(propertiesRequest.ParcelData.East), | ||
3195 | (int) Math.Round(propertiesRequest.ParcelData.North), | ||
3196 | propertiesRequest.ParcelData.SequenceID, | ||
3197 | propertiesRequest.ParcelData.SnapSelection, this); | ||
3198 | } | ||
3199 | break; | ||
3200 | case PacketType.ParcelDivide: | ||
3201 | ParcelDividePacket landDivide = (ParcelDividePacket) Pack; | ||
3202 | if (OnParcelDivideRequest != null) | ||
3203 | { | ||
3204 | OnParcelDivideRequest((int) Math.Round(landDivide.ParcelData.West), | ||
3205 | (int) Math.Round(landDivide.ParcelData.South), | ||
3206 | (int) Math.Round(landDivide.ParcelData.East), | ||
3207 | (int) Math.Round(landDivide.ParcelData.North), this); | ||
3208 | } | ||
3209 | break; | ||
3210 | case PacketType.ParcelJoin: | ||
3211 | ParcelJoinPacket landJoin = (ParcelJoinPacket) Pack; | ||
3212 | if (OnParcelJoinRequest != null) | ||
3213 | { | ||
3214 | OnParcelJoinRequest((int) Math.Round(landJoin.ParcelData.West), | ||
3215 | (int) Math.Round(landJoin.ParcelData.South), | ||
3216 | (int) Math.Round(landJoin.ParcelData.East), | ||
3217 | (int) Math.Round(landJoin.ParcelData.North), this); | ||
3218 | } | ||
3219 | break; | ||
3220 | case PacketType.ParcelPropertiesUpdate: | ||
3221 | ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket) Pack; | ||
3222 | if (OnParcelPropertiesUpdateRequest != null) | ||
3223 | { | ||
3224 | OnParcelPropertiesUpdateRequest(updatePacket, this); | ||
3225 | } | ||
3226 | break; | ||
3227 | case PacketType.ParcelSelectObjects: | ||
3228 | ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket) Pack; | ||
3229 | if (OnParcelSelectObjects != null) | ||
3230 | { | ||
3231 | OnParcelSelectObjects(selectPacket.ParcelData.LocalID, | ||
3232 | Convert.ToInt32(selectPacket.ParcelData.ReturnType), this); | ||
3233 | } | ||
3234 | break; | ||
3235 | case PacketType.ParcelObjectOwnersRequest: | ||
3236 | //System.Console.WriteLine(Pack.ToString()); | ||
3237 | ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket) Pack; | ||
3238 | if (OnParcelObjectOwnerRequest != null) | ||
3239 | { | ||
3240 | OnParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this); | ||
3241 | } | ||
3242 | break; | ||
3243 | |||
3244 | #endregion | ||
3245 | |||
3246 | #region Estate Packets | ||
3247 | |||
3248 | case PacketType.EstateOwnerMessage: | ||
3249 | EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket) Pack; | ||
3250 | if (OnEstateOwnerMessage != null) | ||
3251 | { | ||
3252 | OnEstateOwnerMessage(messagePacket, this); | ||
3253 | } | ||
3254 | break; | ||
3255 | |||
3256 | case PacketType.AgentThrottle: | ||
3257 | |||
3258 | //OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
3259 | |||
3260 | AgentThrottlePacket atpack = (AgentThrottlePacket)Pack; | ||
3261 | |||
3262 | byte[] throttle = atpack.Throttle.Throttles; | ||
3263 | int tResend = -1; | ||
3264 | int tLand = -1; | ||
3265 | int tWind = -1; | ||
3266 | int tCloud = -1; | ||
3267 | int tTask = -1; | ||
3268 | int tTexture = -1; | ||
3269 | int tAsset = -1; | ||
3270 | int tall = -1; | ||
3271 | int singlefloat = 4; | ||
3272 | |||
3273 | //Agent Throttle Block contains 7 single floatingpoint values. | ||
3274 | int j = 0; | ||
3275 | |||
3276 | // Some Systems may be big endian... | ||
3277 | // it might be smart to do this check more often... | ||
3278 | if (!BitConverter.IsLittleEndian) | ||
3279 | for (int i = 0; i < 7; i++) | ||
3280 | Array.Reverse(throttle, j + i * singlefloat, singlefloat); | ||
3281 | |||
3282 | // values gotten from libsecondlife.org/wiki/Throttle. Thanks MW_ | ||
3283 | // bytes | ||
3284 | // Convert to integer, since.. the full fp space isn't used. | ||
3285 | tResend = (int)BitConverter.ToSingle(throttle, j); | ||
3286 | j += singlefloat; | ||
3287 | tLand = (int)BitConverter.ToSingle(throttle, j); | ||
3288 | j += singlefloat; | ||
3289 | tWind = (int)BitConverter.ToSingle(throttle, j); | ||
3290 | j += singlefloat; | ||
3291 | tCloud = (int)BitConverter.ToSingle(throttle, j); | ||
3292 | j += singlefloat; | ||
3293 | tTask = (int)BitConverter.ToSingle(throttle, j); | ||
3294 | j += singlefloat; | ||
3295 | tTexture = (int)BitConverter.ToSingle(throttle, j); | ||
3296 | j += singlefloat; | ||
3297 | tAsset = (int)BitConverter.ToSingle(throttle, j); | ||
3298 | |||
3299 | tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset; | ||
3300 | /* | ||
3301 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "Client AgentThrottle - Got throttle:resendbytes=" + tResend + | ||
3302 | " landbytes=" + tLand + | ||
3303 | " windbytes=" + tWind + | ||
3304 | " cloudbytes=" + tCloud + | ||
3305 | " taskbytes=" + tTask + | ||
3306 | " texturebytes=" + tTexture + | ||
3307 | " Assetbytes=" + tAsset + | ||
3308 | " Allbytes=" + tall); | ||
3309 | */ | ||
3310 | |||
3311 | // Total Sanity | ||
3312 | // Make sure that the client sent sane total values. | ||
3313 | |||
3314 | // If the client didn't send acceptable values.... | ||
3315 | // Scale the clients values down until they are acceptable. | ||
3316 | |||
3317 | if (tall <= throttleOutboundMax) | ||
3318 | { | ||
3319 | // Sanity | ||
3320 | // Making sure the client sends sane values | ||
3321 | // This gives us a measure of control of the comms | ||
3322 | // Check Max of Type | ||
3323 | // Then Check Min of type | ||
3324 | |||
3325 | // Resend throttle | ||
3326 | if (tResend <= ResendthrottleMAX) | ||
3327 | ResendthrottleOutbound = tResend; | ||
3328 | |||
3329 | if (tResend < ResendthrottleMin) | ||
3330 | ResendthrottleOutbound = ResendthrottleMin; | ||
3331 | |||
3332 | // Land throttle | ||
3333 | if (tLand <= LandthrottleMax) | ||
3334 | LandthrottleOutbound = tLand; | ||
3335 | |||
3336 | if (tLand < LandthrottleMin) | ||
3337 | LandthrottleOutbound = LandthrottleMin; | ||
3338 | |||
3339 | // Wind throttle | ||
3340 | if (tWind <= WindthrottleMax) | ||
3341 | WindthrottleOutbound = tWind; | ||
3342 | |||
3343 | if (tWind < WindthrottleMin) | ||
3344 | WindthrottleOutbound = WindthrottleMin; | ||
3345 | |||
3346 | // Cloud throttle | ||
3347 | if (tCloud <= CloudthrottleMax) | ||
3348 | CloudthrottleOutbound = tCloud; | ||
3349 | |||
3350 | if (tCloud < CloudthrottleMin) | ||
3351 | CloudthrottleOutbound = CloudthrottleMin; | ||
3352 | |||
3353 | // Task throttle | ||
3354 | if (tTask <= TaskthrottleMax) | ||
3355 | TaskthrottleOutbound = tTask; | ||
3356 | |||
3357 | if (tTask < TaskthrottleMin) | ||
3358 | TaskthrottleOutbound = TaskthrottleMin; | ||
3359 | |||
3360 | // Texture throttle | ||
3361 | if (tTexture <= TexturethrottleMax) | ||
3362 | TexturethrottleOutbound = tTexture; | ||
3363 | |||
3364 | if (tTexture < TexturethrottleMin) | ||
3365 | TexturethrottleOutbound = TexturethrottleMin; | ||
3366 | |||
3367 | //Asset throttle | ||
3368 | if (tAsset <= AssetthrottleMax) | ||
3369 | AssetthrottleOutbound = tAsset; | ||
3370 | |||
3371 | if (tAsset < AssetthrottleMin) | ||
3372 | AssetthrottleOutbound = AssetthrottleMin; | ||
3373 | |||
3374 | /* OpenSim.Framework.Console.MainLog.Instance.Verbose("THROTTLE", "Using:resendbytes=" + ResendthrottleOutbound + | ||
3375 | " landbytes=" + LandthrottleOutbound + | ||
3376 | " windbytes=" + WindthrottleOutbound + | ||
3377 | " cloudbytes=" + CloudthrottleOutbound + | ||
3378 | " taskbytes=" + TaskthrottleOutbound + | ||
3379 | " texturebytes=" + TexturethrottleOutbound + | ||
3380 | " Assetbytes=" + AssetthrottleOutbound + | ||
3381 | " Allbytes=" + tall); | ||
3382 | */ | ||
3383 | } | ||
3384 | else | ||
3385 | { | ||
3386 | // The client didn't send acceptable values.. | ||
3387 | // so it's our job now to turn them into acceptable values | ||
3388 | // We're going to first scale the values down | ||
3389 | // After that we're going to check if the scaled values are sane | ||
3390 | |||
3391 | // We're going to be dividing by a user value.. so make sure | ||
3392 | // we don't get a divide by zero error. | ||
3393 | if (tall > 0) | ||
3394 | { | ||
3395 | // Find out the percentage of all communications | ||
3396 | // the client requests for each type. We'll keep resend at | ||
3397 | // it's client recommended level (won't scale it down) | ||
3398 | // unless it's beyond sane values itself. | ||
3399 | |||
3400 | if (tResend <= ResendthrottleMAX) | ||
3401 | { | ||
3402 | // This is nexted because we only want to re-set the values | ||
3403 | // the packet throttler uses once. | ||
3404 | |||
3405 | if (tResend >= ResendthrottleMin) | ||
3406 | { | ||
3407 | ResendthrottleOutbound = tResend; | ||
3408 | } | ||
3409 | else | ||
3410 | { | ||
3411 | ResendthrottleOutbound = ResendthrottleMin; | ||
3412 | } | ||
3413 | } | ||
3414 | else | ||
3415 | { | ||
3416 | ResendthrottleOutbound = ResendthrottleMAX; | ||
3417 | } | ||
3418 | |||
3419 | |||
3420 | // Getting Percentages of communication for each type of data | ||
3421 | float LandPercent = (float)(tLand / tall); | ||
3422 | float WindPercent = (float)(tWind / tall); | ||
3423 | float CloudPercent = (float)(tCloud / tall); | ||
3424 | float TaskPercent = (float)(tTask / tall); | ||
3425 | float TexturePercent = (float)(tTexture / tall); | ||
3426 | float AssetPercent = (float)(tAsset / tall); | ||
3427 | |||
3428 | // Okay.. now we've got the percentages of total communication. | ||
3429 | // Apply them to a new max total | ||
3430 | |||
3431 | int tLandResult = (int)(LandPercent * throttleOutboundMax); | ||
3432 | int tWindResult = (int)(WindPercent * throttleOutboundMax); | ||
3433 | int tCloudResult = (int)(CloudPercent * throttleOutboundMax); | ||
3434 | int tTaskResult = (int)(TaskPercent * throttleOutboundMax); | ||
3435 | int tTextureResult = (int)(TexturePercent * throttleOutboundMax); | ||
3436 | int tAssetResult = (int)(AssetPercent * throttleOutboundMax); | ||
3437 | |||
3438 | // Now we have to check our scaled values for sanity | ||
3439 | |||
3440 | // Check Max of Type | ||
3441 | // Then Check Min of type | ||
3442 | |||
3443 | // Land throttle | ||
3444 | if (tLandResult <= LandthrottleMax) | ||
3445 | LandthrottleOutbound = tLandResult; | ||
3446 | |||
3447 | if (tLandResult < LandthrottleMin) | ||
3448 | LandthrottleOutbound = LandthrottleMin; | ||
3449 | |||
3450 | // Wind throttle | ||
3451 | if (tWindResult <= WindthrottleMax) | ||
3452 | WindthrottleOutbound = tWindResult; | ||
3453 | |||
3454 | if (tWindResult < WindthrottleMin) | ||
3455 | WindthrottleOutbound = WindthrottleMin; | ||
3456 | |||
3457 | // Cloud throttle | ||
3458 | if (tCloudResult <= CloudthrottleMax) | ||
3459 | CloudthrottleOutbound = tCloudResult; | ||
3460 | |||
3461 | if (tCloudResult < CloudthrottleMin) | ||
3462 | CloudthrottleOutbound = CloudthrottleMin; | ||
3463 | |||
3464 | // Task throttle | ||
3465 | if (tTaskResult <= TaskthrottleMax) | ||
3466 | TaskthrottleOutbound = tTaskResult; | ||
3467 | |||
3468 | if (tTaskResult < TaskthrottleMin) | ||
3469 | TaskthrottleOutbound = TaskthrottleMin; | ||
3470 | |||
3471 | // Texture throttle | ||
3472 | if (tTextureResult <= TexturethrottleMax) | ||
3473 | TexturethrottleOutbound = tTextureResult; | ||
3474 | |||
3475 | if (tTextureResult < TexturethrottleMin) | ||
3476 | TexturethrottleOutbound = TexturethrottleMin; | ||
3477 | |||
3478 | //Asset throttle | ||
3479 | if (tAssetResult <= AssetthrottleMax) | ||
3480 | AssetthrottleOutbound = tAssetResult; | ||
3481 | |||
3482 | if (tAssetResult < AssetthrottleMin) | ||
3483 | AssetthrottleOutbound = AssetthrottleMin; | ||
3484 | |||
3485 | /* OpenSim.Framework.Console.MainLog.Instance.Verbose("THROTTLE", "Using:resendbytes=" + ResendthrottleOutbound + | ||
3486 | " landbytes=" + LandthrottleOutbound + | ||
3487 | " windbytes=" + WindthrottleOutbound + | ||
3488 | " cloudbytes=" + CloudthrottleOutbound + | ||
3489 | " taskbytes=" + TaskthrottleOutbound + | ||
3490 | " texturebytes=" + TexturethrottleOutbound + | ||
3491 | " Assetbytes=" + AssetthrottleOutbound + | ||
3492 | " Allbytes=" + tall); | ||
3493 | */ | ||
3494 | |||
3495 | } | ||
3496 | else | ||
3497 | { | ||
3498 | |||
3499 | // The client sent a stupid value.. | ||
3500 | // We're going to set the throttles to the minimum possible | ||
3501 | ResendthrottleOutbound = ResendthrottleMin; | ||
3502 | LandthrottleOutbound = LandthrottleMin; | ||
3503 | WindthrottleOutbound = WindthrottleMin; | ||
3504 | CloudthrottleOutbound = CloudthrottleMin; | ||
3505 | TaskthrottleOutbound = TaskthrottleMin; | ||
3506 | TexturethrottleOutbound = TexturethrottleMin; | ||
3507 | AssetthrottleOutbound = AssetthrottleMin; | ||
3508 | OpenSim.Framework.Console.MainLog.Instance.Verbose("THROTTLE", "ClientSentBadThrottle Using:resendbytes=" + ResendthrottleOutbound + | ||
3509 | " landbytes=" + LandthrottleOutbound + | ||
3510 | " windbytes=" + WindthrottleOutbound + | ||
3511 | " cloudbytes=" + CloudthrottleOutbound + | ||
3512 | " taskbytes=" + TaskthrottleOutbound + | ||
3513 | " texturebytes=" + TexturethrottleOutbound + | ||
3514 | " Assetbytes=" + AssetthrottleOutbound + | ||
3515 | " Allbytes=" + tall); | ||
3516 | } | ||
3517 | |||
3518 | } | ||
3519 | // Reset Client Throttles | ||
3520 | // This has the effect of 'wiggling the slider | ||
3521 | // causes prim and stuck textures that didn't download to download | ||
3522 | |||
3523 | ResendBytesSent = 0; | ||
3524 | LandBytesSent = 0; | ||
3525 | WindBytesSent = 0; | ||
3526 | CloudBytesSent = 0; | ||
3527 | TaskBytesSent = 0; | ||
3528 | AssetBytesSent = 0; | ||
3529 | TextureBytesSent = 0; | ||
3530 | |||
3531 | //Yay, we've finally handled the agent Throttle packet! | ||
3532 | |||
3533 | |||
3534 | |||
3535 | break; | ||
3536 | |||
3537 | #endregion | ||
3538 | |||
3539 | #region unimplemented handlers | ||
3540 | case PacketType.RequestGodlikePowers: | ||
3541 | RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket) Pack; | ||
3542 | RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock; | ||
3543 | LLUUID token = rblock.Token; | ||
3544 | RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; | ||
3545 | |||
3546 | OnRequestGodlikePowers(ablock.AgentID, ablock.SessionID, token, this); | ||
3547 | |||
3548 | break; | ||
3549 | case PacketType.GodKickUser: | ||
3550 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
3551 | |||
3552 | GodKickUserPacket gkupack = (GodKickUserPacket) Pack; | ||
3553 | |||
3554 | if (gkupack.UserInfo.GodSessionID == SessionId && this.AgentId == gkupack.UserInfo.GodID) | ||
3555 | { | ||
3556 | OnGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, gkupack.UserInfo.AgentID, (uint) 0, gkupack.UserInfo.Reason); | ||
3557 | } | ||
3558 | else | ||
3559 | { | ||
3560 | SendAgentAlertMessage("Kick request denied", false); | ||
3561 | } | ||
3562 | //KickUserPacket kupack = new KickUserPacket(); | ||
3563 | //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo; | ||
3564 | |||
3565 | //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID; | ||
3566 | //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID; | ||
3567 | |||
3568 | //kupack.TargetBlock.TargetIP = (uint)0; | ||
3569 | //kupack.TargetBlock.TargetPort = (ushort)0; | ||
3570 | //kupack.UserInfo.Reason = gkupack.UserInfo.Reason; | ||
3571 | |||
3572 | |||
3573 | //OutPacket(kupack, ThrottleOutPacketType.Task); | ||
3574 | break; | ||
3575 | |||
3576 | case PacketType.StartPingCheck: | ||
3577 | // Send the client the ping response back | ||
3578 | // Pass the same PingID in the matching packet | ||
3579 | // Handled In the packet processing | ||
3580 | OpenSim.Framework.Console.MainLog.Instance.Debug("CLIENT", "possibly unhandled packet " + Pack.ToString()); | ||
3581 | break; | ||
3582 | case PacketType.CompletePingCheck: | ||
3583 | // Parhaps this should be processed on the Sim to determine whether or not to drop a dead client | ||
3584 | // Dumping it to the verbose console until it's handled properly. | ||
3585 | |||
3586 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
3587 | break; | ||
3588 | case PacketType.AgentIsNowWearing: | ||
3589 | // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; | ||
3590 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
3591 | break; | ||
3592 | case PacketType.ObjectScale: | ||
3593 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
3594 | break; | ||
3595 | default: | ||
3596 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
3597 | break; | ||
3598 | |||
3599 | #endregion | ||
3600 | } | ||
3601 | } | ||
3602 | } | ||
3603 | |||
3604 | private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) | ||
3605 | { | ||
3606 | PrimitiveBaseShape shape = new PrimitiveBaseShape(); | ||
3607 | |||
3608 | shape.PCode = addPacket.ObjectData.PCode; | ||
3609 | shape.PathBegin = addPacket.ObjectData.PathBegin; | ||
3610 | shape.PathEnd = addPacket.ObjectData.PathEnd; | ||
3611 | shape.PathScaleX = addPacket.ObjectData.PathScaleX; | ||
3612 | shape.PathScaleY = addPacket.ObjectData.PathScaleY; | ||
3613 | shape.PathShearX = addPacket.ObjectData.PathShearX; | ||
3614 | shape.PathShearY = addPacket.ObjectData.PathShearY; | ||
3615 | shape.PathSkew = addPacket.ObjectData.PathSkew; | ||
3616 | shape.ProfileBegin = addPacket.ObjectData.ProfileBegin; | ||
3617 | shape.ProfileEnd = addPacket.ObjectData.ProfileEnd; | ||
3618 | shape.Scale = addPacket.ObjectData.Scale; | ||
3619 | shape.PathCurve = addPacket.ObjectData.PathCurve; | ||
3620 | shape.ProfileCurve = addPacket.ObjectData.ProfileCurve; | ||
3621 | shape.ProfileHollow = addPacket.ObjectData.ProfileHollow; | ||
3622 | shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; | ||
3623 | shape.PathRevolutions = addPacket.ObjectData.PathRevolutions; | ||
3624 | shape.PathTaperX = addPacket.ObjectData.PathTaperX; | ||
3625 | shape.PathTaperY = addPacket.ObjectData.PathTaperY; | ||
3626 | shape.PathTwist = addPacket.ObjectData.PathTwist; | ||
3627 | shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; | ||
3628 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005")); | ||
3629 | shape.TextureEntry = ntex.ToBytes(); | ||
3630 | return shape; | ||
3631 | } | ||
3632 | |||
3633 | public void SendLogoutPacket() | ||
3634 | { | ||
3635 | LogoutReplyPacket logReply = new LogoutReplyPacket(); | ||
3636 | logReply.AgentData.AgentID = AgentId; | ||
3637 | logReply.AgentData.SessionID = SessionId; | ||
3638 | logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; | ||
3639 | logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); | ||
3640 | logReply.InventoryData[0].ItemID = LLUUID.Zero; | ||
3641 | |||
3642 | OutPacket(logReply, ThrottleOutPacketType.Task); | ||
3643 | } | ||
555 | } | 3644 | } |
556 | } \ No newline at end of file | 3645 | } \ No newline at end of file |