aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack
diff options
context:
space:
mode:
authorAdam Frisby2008-05-02 16:41:08 +0000
committerAdam Frisby2008-05-02 16:41:08 +0000
commit29b8c84ceaaeca80bfa9c0bfc8c31e421e39ef71 (patch)
tree848ce119d9b87bc186c20b08cc604de50a872b31 /OpenSim/Region/ClientStack
parent* Refactored ClientView into LLClientView. Removed all direct references to U... (diff)
downloadopensim-SC_OLD-29b8c84ceaaeca80bfa9c0bfc8c31e421e39ef71.zip
opensim-SC_OLD-29b8c84ceaaeca80bfa9c0bfc8c31e421e39ef71.tar.gz
opensim-SC_OLD-29b8c84ceaaeca80bfa9c0bfc8c31e421e39ef71.tar.bz2
opensim-SC_OLD-29b8c84ceaaeca80bfa9c0bfc8c31e421e39ef71.tar.xz
* Commit 2/3 - Please dont attempt to update to this revision until all 3 are in.
Diffstat (limited to 'OpenSim/Region/ClientStack')
-rw-r--r--OpenSim/Region/ClientStack/IClientNetworkServer.cs11
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientStackNetworkHandler.cs (renamed from OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs)76
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs (renamed from OpenSim/Region/ClientStack/ClientView.cs)9853
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs (renamed from OpenSim/Region/ClientStack/PacketQueue.cs)1064
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs (renamed from OpenSim/Region/ClientStack/PacketServer.cs)299
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs (renamed from OpenSim/Region/ClientStack/PacketThrottle.cs)186
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs (renamed from OpenSim/Region/ClientStack/QueItem.cs)86
-rw-r--r--OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs (renamed from OpenSim/Region/ClientStack/UDPServer.cs)987
-rw-r--r--OpenSim/Region/ClientStack/RegionApplicationBase.cs17
9 files changed, 6301 insertions, 6278 deletions
diff --git a/OpenSim/Region/ClientStack/IClientNetworkServer.cs b/OpenSim/Region/ClientStack/IClientNetworkServer.cs
new file mode 100644
index 0000000..f15404c
--- /dev/null
+++ b/OpenSim/Region/ClientStack/IClientNetworkServer.cs
@@ -0,0 +1,11 @@
1using System.Net.Sockets;
2using OpenSim.Framework;
3
4namespace OpenSim.Region.ClientStack
5{
6 public interface IClientNetworkServer
7 {
8 Socket Server { get; }
9 bool HandlesRegion(Location x);
10 }
11} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientStackNetworkHandler.cs
index fc34866..c1989a5 100644
--- a/OpenSim/Region/ClientStack/ClientStackNetworkHandler.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientStackNetworkHandler.cs
@@ -1,38 +1,38 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Net.Sockets; 28using System.Net.Sockets;
29 29
30namespace OpenSim.Region.ClientStack 30namespace OpenSim.Region.ClientStack.LindenUDP
31{ 31{
32 public interface ClientStackNetworkHandler 32 public interface LLClientStackNetworkHandler
33 { 33 {
34 void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode); // EndPoint packetSender); 34 void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode); // EndPoint packetSender);
35 void RemoveClientCircuit(uint circuitcode); 35 void RemoveClientCircuit(uint circuitcode);
36 void RegisterPacketServer(PacketServer server); 36 void RegisterPacketServer(LLPacketServer server);
37 } 37 }
38} 38} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/ClientView.cs b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
index 010a37f..5d45d99 100644
--- a/OpenSim/Region/ClientStack/ClientView.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLClientView.cs
@@ -1,4926 +1,4927 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Net.Sockets; 31using System.Net.Sockets;
32using System.Reflection; 32using System.Reflection;
33using System.Text; 33using System.Text;
34using System.Threading; 34using System.Threading;
35using System.Timers; 35using System.Timers;
36using Axiom.Math; 36using Axiom.Math;
37using libsecondlife; 37using libsecondlife;
38using libsecondlife.Packets; 38using libsecondlife.Packets;
39using log4net; 39using log4net;
40using OpenSim.Framework; 40using OpenSim.Framework;
41using OpenSim.Framework.Communications.Cache; 41using OpenSim.Framework.Communications.Cache;
42using OpenSim.Region.Environment.Scenes; 42using OpenSim.Region.ClientStack.LindenUDP;
43using Timer=System.Timers.Timer; 43using OpenSim.Region.Environment.Scenes;
44 44using Timer=System.Timers.Timer;
45namespace OpenSim.Region.ClientStack 45
46{ 46namespace OpenSim.Region.ClientStack.LindenUDP
47 public delegate bool PacketMethod(IClientAPI simClient, Packet packet); 47{
48 48 public delegate bool PacketMethod(IClientAPI simClient, Packet packet);
49 /// <summary> 49
50 /// Handles new client connections 50 /// <summary>
51 /// Constructor takes a single Packet and authenticates everything 51 /// Handles new client connections
52 /// </summary> 52 /// Constructor takes a single Packet and authenticates everything
53 public class ClientView : IClientAPI 53 /// </summary>
54 { 54 public class LLClientView : IClientAPI
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 55 {
56 56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
57 // ~ClientView() 57
58 // { 58 // ~ClientView()
59 // m_log.Info("[CLIENTVIEW]: Destructor called"); 59 // {
60 // } 60 // m_log.Info("[CLIENTVIEW]: Destructor called");
61 61 // }
62 /* static variables */ 62
63 public static TerrainManager TerrainManager; 63 /* static variables */
64 64 public static TerrainManager TerrainManager;
65 public delegate bool SynchronizeClientHandler(IScene scene, Packet packet, LLUUID agentID, ThrottleOutPacketType throttlePacketType); 65
66 public static SynchronizeClientHandler SynchronizeClient = null; 66 public delegate bool SynchronizeClientHandler(IScene scene, Packet packet, LLUUID agentID, ThrottleOutPacketType throttlePacketType);
67 /* private variables */ 67 public static SynchronizeClientHandler SynchronizeClient = null;
68 private readonly LLUUID m_sessionId; 68 /* private variables */
69 private LLUUID m_secureSessionId = LLUUID.Zero; 69 private readonly LLUUID m_sessionId;
70 //private AgentAssetUpload UploadAssets; 70 private LLUUID m_secureSessionId = LLUUID.Zero;
71 private int m_debug = 0; 71 //private AgentAssetUpload UploadAssets;
72 private readonly AssetCache m_assetCache; 72 private int m_debug = 0;
73 // private InventoryCache m_inventoryCache; 73 private readonly AssetCache m_assetCache;
74 private int m_cachedTextureSerial = 0; 74 // private InventoryCache m_inventoryCache;
75 private Timer m_clientPingTimer; 75 private int m_cachedTextureSerial = 0;
76 76 private Timer m_clientPingTimer;
77 private bool m_clientBlocked = false; 77
78 78 private bool m_clientBlocked = false;
79 private int m_packetsReceived = 0; 79
80 private int m_lastPacketsReceivedSentToScene = 0; 80 private int m_packetsReceived = 0;
81 private int m_unAckedBytes = 0; 81 private int m_lastPacketsReceivedSentToScene = 0;
82 82 private int m_unAckedBytes = 0;
83 private int m_packetsSent = 0; 83
84 private int m_lastPacketsSentSentToScene = 0; 84 private int m_packetsSent = 0;
85 85 private int m_lastPacketsSentSentToScene = 0;
86 private int m_probesWithNoIngressPackets = 0; 86
87 private int m_lastPacketsReceived = 0; 87 private int m_probesWithNoIngressPackets = 0;
88 private byte[] ZeroOutBuffer = new byte[4096]; 88 private int m_lastPacketsReceived = 0;
89 89 private byte[] ZeroOutBuffer = new byte[4096];
90 private readonly LLUUID m_agentId; 90
91 private readonly uint m_circuitCode; 91 private readonly LLUUID m_agentId;
92 private int m_moneyBalance; 92 private readonly uint m_circuitCode;
93 93 private int m_moneyBalance;
94 private int m_animationSequenceNumber = 1; 94
95 95 private int m_animationSequenceNumber = 1;
96 private byte[] m_channelVersion = Helpers.StringToField("OpenSimulator 0.5"); // Dummy value needed by libSL 96
97 97 private byte[] m_channelVersion = Helpers.StringToField("OpenSimulator 0.5"); // Dummy value needed by libSL
98 /* protected variables */ 98
99 99 /* protected variables */
100 protected static Dictionary<PacketType, PacketMethod> PacketHandlers = 100
101 new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients 101 protected static Dictionary<PacketType, PacketMethod> PacketHandlers =
102 102 new Dictionary<PacketType, PacketMethod>(); //Global/static handlers for all clients
103 protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>(); 103
104 104 protected Dictionary<PacketType, PacketMethod> m_packetHandlers = new Dictionary<PacketType, PacketMethod>();
105 protected IScene m_scene; 105
106 protected AgentCircuitManager m_authenticateSessionsHandler; 106 protected IScene m_scene;
107 107 protected AgentCircuitManager m_authenticateSessionsHandler;
108 protected PacketQueue m_packetQueue; 108
109 109 protected LLPacketQueue m_packetQueue;
110 protected Dictionary<uint, uint> m_pendingAcks = new Dictionary<uint, uint>(); 110
111 protected Dictionary<uint, Packet> m_needAck = new Dictionary<uint, Packet>(); 111 protected Dictionary<uint, uint> m_pendingAcks = new Dictionary<uint, uint>();
112 112 protected Dictionary<uint, Packet> m_needAck = new Dictionary<uint, Packet>();
113 protected Timer m_ackTimer; 113
114 protected uint m_sequence = 0; 114 protected Timer m_ackTimer;
115 protected object m_sequenceLock = new object(); 115 protected uint m_sequence = 0;
116 protected const int MAX_APPENDED_ACKS = 10; 116 protected object m_sequenceLock = new object();
117 protected const int RESEND_TIMEOUT = 4000; 117 protected const int MAX_APPENDED_ACKS = 10;
118 protected const int MAX_SEQUENCE = 0xFFFFFF; 118 protected const int RESEND_TIMEOUT = 4000;
119 protected PacketServer m_networkServer; 119 protected const int MAX_SEQUENCE = 0xFFFFFF;
120 120 protected LLPacketServer m_networkServer;
121 /* public variables */ 121
122 protected string m_firstName; 122 /* public variables */
123 protected string m_lastName; 123 protected string m_firstName;
124 protected Thread m_clientThread; 124 protected string m_lastName;
125 protected LLVector3 m_startpos; 125 protected Thread m_clientThread;
126 protected EndPoint m_userEndPoint; 126 protected LLVector3 m_startpos;
127 protected EndPoint m_proxyEndPoint; 127 protected EndPoint m_userEndPoint;
128 128 protected EndPoint m_proxyEndPoint;
129 /* Instantiated Designated Event Delegates */ 129
130 //- used so we don't create new objects for each incoming packet and then toss it out later */ 130 /* Instantiated Designated Event Delegates */
131 131 //- used so we don't create new objects for each incoming packet and then toss it out later */
132 private RequestAvatarProperties handlerRequestAvatarProperties = null; //OnRequestAvatarProperties; 132
133 private UpdateAvatarProperties handlerUpdateAvatarProperties = null; // OnUpdateAvatarProperties; 133 private RequestAvatarProperties handlerRequestAvatarProperties = null; //OnRequestAvatarProperties;
134 private ChatFromViewer handlerChatFromViewer = null; //OnChatFromViewer; 134 private UpdateAvatarProperties handlerUpdateAvatarProperties = null; // OnUpdateAvatarProperties;
135 private ChatFromViewer handlerChatFromViewer2 = null; //OnChatFromViewer; 135 private ChatFromViewer handlerChatFromViewer = null; //OnChatFromViewer;
136 private ImprovedInstantMessage handlerInstantMessage = null; //OnInstantMessage; 136 private ChatFromViewer handlerChatFromViewer2 = null; //OnChatFromViewer;
137 private FriendActionDelegate handlerApproveFriendRequest = null; //OnApproveFriendRequest; 137 private ImprovedInstantMessage handlerInstantMessage = null; //OnInstantMessage;
138 private FriendshipTermination handlerTerminateFriendship = null; //OnTerminateFriendship; 138 private FriendActionDelegate handlerApproveFriendRequest = null; //OnApproveFriendRequest;
139 private RezObject handlerRezObject = null; //OnRezObject; 139 private FriendshipTermination handlerTerminateFriendship = null; //OnTerminateFriendship;
140 private GenericCall4 handlerDeRezObject = null; //OnDeRezObject; 140 private RezObject handlerRezObject = null; //OnRezObject;
141 private ModifyTerrain handlerModifyTerrain = null; 141 private GenericCall4 handlerDeRezObject = null; //OnDeRezObject;
142 private Action<IClientAPI> handlerRegionHandShakeReply = null; //OnRegionHandShakeReply; 142 private ModifyTerrain handlerModifyTerrain = null;
143 private GenericCall2 handlerRequestWearables = null; //OnRequestWearables; 143 private Action<IClientAPI> handlerRegionHandShakeReply = null; //OnRegionHandShakeReply;
144 private Action<IClientAPI> handlerRequestAvatarsData = null; //OnRequestAvatarsData; 144 private GenericCall2 handlerRequestWearables = null; //OnRequestWearables;
145 private SetAppearance handlerSetAppearance = null; //OnSetAppearance; 145 private Action<IClientAPI> handlerRequestAvatarsData = null; //OnRequestAvatarsData;
146 private AvatarNowWearing handlerAvatarNowWearing = null; //OnAvatarNowWearing; 146 private SetAppearance handlerSetAppearance = null; //OnSetAppearance;
147 private RezSingleAttachmentFromInv handlerRezSingleAttachment = null; //OnRezSingleAttachmentFromInv; 147 private AvatarNowWearing handlerAvatarNowWearing = null; //OnAvatarNowWearing;
148 private UUIDNameRequest handlerDetachAttachmentIntoInv = null; // Detach attachment! 148 private RezSingleAttachmentFromInv handlerRezSingleAttachment = null; //OnRezSingleAttachmentFromInv;
149 private ObjectAttach handlerObjectAttach = null; //OnObjectAttach; 149 private UUIDNameRequest handlerDetachAttachmentIntoInv = null; // Detach attachment!
150 private SetAlwaysRun handlerSetAlwaysRun = null; //OnSetAlwaysRun; 150 private ObjectAttach handlerObjectAttach = null; //OnObjectAttach;
151 private GenericCall2 handlerCompleteMovementToRegion = null; //OnCompleteMovementToRegion; 151 private SetAlwaysRun handlerSetAlwaysRun = null; //OnSetAlwaysRun;
152 private UpdateAgent handlerAgentUpdate = null; //OnAgentUpdate; 152 private GenericCall2 handlerCompleteMovementToRegion = null; //OnCompleteMovementToRegion;
153 private StartAnim handlerStartAnim = null; 153 private UpdateAgent handlerAgentUpdate = null; //OnAgentUpdate;
154 private StopAnim handlerStopAnim = null; 154 private StartAnim handlerStartAnim = null;
155 private AgentRequestSit handlerAgentRequestSit = null; //OnAgentRequestSit; 155 private StopAnim handlerStopAnim = null;
156 private AgentSit handlerAgentSit = null; //OnAgentSit; 156 private AgentRequestSit handlerAgentRequestSit = null; //OnAgentRequestSit;
157 private AvatarPickerRequest handlerAvatarPickerRequest = null; //OnAvatarPickerRequest; 157 private AgentSit handlerAgentSit = null; //OnAgentSit;
158 private FetchInventory handlerAgentDataUpdateRequest = null; //OnAgentDataUpdateRequest; 158 private AvatarPickerRequest handlerAvatarPickerRequest = null; //OnAvatarPickerRequest;
159 private FetchInventory handlerUserInfoRequest = null; //OnUserInfoRequest; 159 private FetchInventory handlerAgentDataUpdateRequest = null; //OnAgentDataUpdateRequest;
160 private TeleportLocationRequest handlerSetStartLocationRequest = null; //OnSetStartLocationRequest; 160 private FetchInventory handlerUserInfoRequest = null; //OnUserInfoRequest;
161 private TeleportLandmarkRequest handlerTeleportLandmarkRequest = null; //OnTeleportLandmarkRequest; 161 private TeleportLocationRequest handlerSetStartLocationRequest = null; //OnSetStartLocationRequest;
162 private LinkObjects handlerLinkObjects = null; //OnLinkObjects; 162 private TeleportLandmarkRequest handlerTeleportLandmarkRequest = null; //OnTeleportLandmarkRequest;
163 private DelinkObjects handlerDelinkObjects = null; //OnDelinkObjects; 163 private LinkObjects handlerLinkObjects = null; //OnLinkObjects;
164 private AddNewPrim handlerAddPrim = null; //OnAddPrim; 164 private DelinkObjects handlerDelinkObjects = null; //OnDelinkObjects;
165 private UpdateShape handlerUpdatePrimShape = null; //null; 165 private AddNewPrim handlerAddPrim = null; //OnAddPrim;
166 private ObjectExtraParams handlerUpdateExtraParams = null; //OnUpdateExtraParams; 166 private UpdateShape handlerUpdatePrimShape = null; //null;
167 private ObjectDuplicate handlerObjectDuplicate = null; 167 private ObjectExtraParams handlerUpdateExtraParams = null; //OnUpdateExtraParams;
168 private ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null; 168 private ObjectDuplicate handlerObjectDuplicate = null;
169 private ObjectSelect handlerObjectSelect = null; 169 private ObjectDuplicateOnRay handlerObjectDuplicateOnRay = null;
170 private ObjectDeselect handlerObjectDeselect = null; 170 private ObjectSelect handlerObjectSelect = null;
171 private ObjectIncludeInSearch handlerObjectIncludeInSearch = null; 171 private ObjectDeselect handlerObjectDeselect = null;
172 private UpdatePrimFlags handlerUpdatePrimFlags = null; //OnUpdatePrimFlags; 172 private ObjectIncludeInSearch handlerObjectIncludeInSearch = null;
173 private UpdatePrimTexture handlerUpdatePrimTexture = null; 173 private UpdatePrimFlags handlerUpdatePrimFlags = null; //OnUpdatePrimFlags;
174 private UpdateVector handlerGrabObject = null; //OnGrabObject; 174 private UpdatePrimTexture handlerUpdatePrimTexture = null;
175 private MoveObject handlerGrabUpdate = null; //OnGrabUpdate; 175 private UpdateVector handlerGrabObject = null; //OnGrabObject;
176 private ObjectSelect handlerDeGrabObject = null; //OnDeGrabObject; 176 private MoveObject handlerGrabUpdate = null; //OnGrabUpdate;
177 private GenericCall7 handlerObjectDescription = null; 177 private ObjectSelect handlerDeGrabObject = null; //OnDeGrabObject;
178 private GenericCall7 handlerObjectName = null; 178 private GenericCall7 handlerObjectDescription = null;
179 private ObjectPermissions handlerObjectPermissions = null; 179 private GenericCall7 handlerObjectName = null;
180 private RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = null; //OnRequestObjectPropertiesFamily; 180 private ObjectPermissions handlerObjectPermissions = null;
181 private TextureRequest handlerTextureRequest = null; 181 private RequestObjectPropertiesFamily handlerRequestObjectPropertiesFamily = null; //OnRequestObjectPropertiesFamily;
182 private UDPAssetUploadRequest handlerAssetUploadRequest = null; //OnAssetUploadRequest; 182 private TextureRequest handlerTextureRequest = null;
183 private RequestXfer handlerRequestXfer = null; //OnRequestXfer; 183 private UDPAssetUploadRequest handlerAssetUploadRequest = null; //OnAssetUploadRequest;
184 private XferReceive handlerXferReceive = null; //OnXferReceive; 184 private RequestXfer handlerRequestXfer = null; //OnRequestXfer;
185 private ConfirmXfer handlerConfirmXfer = null; //OnConfirmXfer; 185 private XferReceive handlerXferReceive = null; //OnXferReceive;
186 private CreateInventoryFolder handlerCreateInventoryFolder = null; //OnCreateNewInventoryFolder; 186 private ConfirmXfer handlerConfirmXfer = null; //OnConfirmXfer;
187 private UpdateInventoryFolder handlerUpdateInventoryFolder = null; 187 private CreateInventoryFolder handlerCreateInventoryFolder = null; //OnCreateNewInventoryFolder;
188 private MoveInventoryFolder handlerMoveInventoryFolder = null; 188 private UpdateInventoryFolder handlerUpdateInventoryFolder = null;
189 private CreateNewInventoryItem handlerCreateNewInventoryItem = null; //OnCreateNewInventoryItem; 189 private MoveInventoryFolder handlerMoveInventoryFolder = null;
190 private FetchInventory handlerFetchInventory = null; 190 private CreateNewInventoryItem handlerCreateNewInventoryItem = null; //OnCreateNewInventoryItem;
191 private FetchInventoryDescendents handlerFetchInventoryDescendents = null; //OnFetchInventoryDescendents; 191 private FetchInventory handlerFetchInventory = null;
192 private PurgeInventoryDescendents handlerPurgeInventoryDescendents = null; //OnPurgeInventoryDescendents; 192 private FetchInventoryDescendents handlerFetchInventoryDescendents = null; //OnFetchInventoryDescendents;
193 private UpdateInventoryItem handlerUpdateInventoryItem = null; 193 private PurgeInventoryDescendents handlerPurgeInventoryDescendents = null; //OnPurgeInventoryDescendents;
194 private CopyInventoryItem handlerCopyInventoryItem = null; 194 private UpdateInventoryItem handlerUpdateInventoryItem = null;
195 private MoveInventoryItem handlerMoveInventoryItem = null; 195 private CopyInventoryItem handlerCopyInventoryItem = null;
196 private RemoveInventoryItem handlerRemoveInventoryItem = null; 196 private MoveInventoryItem handlerMoveInventoryItem = null;
197 private RemoveInventoryFolder handlerRemoveInventoryFolder = null; 197 private RemoveInventoryItem handlerRemoveInventoryItem = null;
198 private RequestTaskInventory handlerRequestTaskInventory = null; //OnRequestTaskInventory; 198 private RemoveInventoryFolder handlerRemoveInventoryFolder = null;
199 private UpdateTaskInventory handlerUpdateTaskInventory = null; //OnUpdateTaskInventory; 199 private RequestTaskInventory handlerRequestTaskInventory = null; //OnRequestTaskInventory;
200 private MoveTaskInventory handlerMoveTaskItem = null; 200 private UpdateTaskInventory handlerUpdateTaskInventory = null; //OnUpdateTaskInventory;
201 private RemoveTaskInventory handlerRemoveTaskItem = null; //OnRemoveTaskItem; 201 private MoveTaskInventory handlerMoveTaskItem = null;
202 private RezScript handlerRezScript = null; //OnRezScript; 202 private RemoveTaskInventory handlerRemoveTaskItem = null; //OnRemoveTaskItem;
203 private RequestMapBlocks handlerRequestMapBlocks = null; //OnRequestMapBlocks; 203 private RezScript handlerRezScript = null; //OnRezScript;
204 private RequestMapName handlerMapNameRequest = null; //OnMapNameRequest; 204 private RequestMapBlocks handlerRequestMapBlocks = null; //OnRequestMapBlocks;
205 private TeleportLocationRequest handlerTeleportLocationRequest = null; //OnTeleportLocationRequest; 205 private RequestMapName handlerMapNameRequest = null; //OnMapNameRequest;
206 private MoneyBalanceRequest handlerMoneyBalanceRequest = null; //OnMoneyBalanceRequest; 206 private TeleportLocationRequest handlerTeleportLocationRequest = null; //OnTeleportLocationRequest;
207 private UUIDNameRequest handlerNameRequest = null; 207 private MoneyBalanceRequest handlerMoneyBalanceRequest = null; //OnMoneyBalanceRequest;
208 private ParcelAccessListRequest handlerParcelAccessListRequest = null; //OnParcelAccessListRequest; 208 private UUIDNameRequest handlerNameRequest = null;
209 private ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = null; //OnParcelAccessListUpdateRequest; 209 private ParcelAccessListRequest handlerParcelAccessListRequest = null; //OnParcelAccessListRequest;
210 private ParcelPropertiesRequest handlerParcelPropertiesRequest = null; //OnParcelPropertiesRequest; 210 private ParcelAccessListUpdateRequest handlerParcelAccessListUpdateRequest = null; //OnParcelAccessListUpdateRequest;
211 private ParcelDivideRequest handlerParcelDivideRequest = null; //OnParcelDivideRequest; 211 private ParcelPropertiesRequest handlerParcelPropertiesRequest = null; //OnParcelPropertiesRequest;
212 private ParcelJoinRequest handlerParcelJoinRequest = null; //OnParcelJoinRequest; 212 private ParcelDivideRequest handlerParcelDivideRequest = null; //OnParcelDivideRequest;
213 private ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = null; //OnParcelPropertiesUpdateRequest; 213 private ParcelJoinRequest handlerParcelJoinRequest = null; //OnParcelJoinRequest;
214 private ParcelSelectObjects handlerParcelSelectObjects = null; //OnParcelSelectObjects; 214 private ParcelPropertiesUpdateRequest handlerParcelPropertiesUpdateRequest = null; //OnParcelPropertiesUpdateRequest;
215 private ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = null; //OnParcelObjectOwnerRequest; 215 private ParcelSelectObjects handlerParcelSelectObjects = null; //OnParcelSelectObjects;
216 private EstateOwnerMessageRequest handlerEstateOwnerMessage = null; //OnEstateOwnerMessage; 216 private ParcelObjectOwnerRequest handlerParcelObjectOwnerRequest = null; //OnParcelObjectOwnerRequest;
217 private RegionInfoRequest handlerRegionInfoRequest = null; //OnRegionInfoRequest; 217 private EstateOwnerMessageRequest handlerEstateOwnerMessage = null; //OnEstateOwnerMessage;
218 private EstateCovenantRequest handlerEstateCovenantRequest = null; //OnEstateCovenantRequest; 218 private RegionInfoRequest handlerRegionInfoRequest = null; //OnRegionInfoRequest;
219 private RequestGodlikePowers handlerReqGodlikePowers = null; //OnRequestGodlikePowers; 219 private EstateCovenantRequest handlerEstateCovenantRequest = null; //OnEstateCovenantRequest;
220 private GodKickUser handlerGodKickUser = null; //OnGodKickUser; 220 private RequestGodlikePowers handlerReqGodlikePowers = null; //OnRequestGodlikePowers;
221 private ViewerEffectEventHandler handlerViewerEffect = null; //OnViewerEffect; 221 private GodKickUser handlerGodKickUser = null; //OnGodKickUser;
222 private Action<IClientAPI> handlerLogout = null; //OnLogout; 222 private ViewerEffectEventHandler handlerViewerEffect = null; //OnViewerEffect;
223 private MoneyTransferRequest handlerMoneyTransferRequest = null; //OnMoneyTransferRequest; 223 private Action<IClientAPI> handlerLogout = null; //OnLogout;
224 private ParcelBuy handlerParcelBuy = null; 224 private MoneyTransferRequest handlerMoneyTransferRequest = null; //OnMoneyTransferRequest;
225 private EconomyDataRequest handlerEconomoyDataRequest = null; 225 private ParcelBuy handlerParcelBuy = null;
226 226 private EconomyDataRequest handlerEconomoyDataRequest = null;
227 private UpdateVector handlerUpdatePrimSinglePosition = null; //OnUpdatePrimSinglePosition; 227
228 private UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = null; //OnUpdatePrimSingleRotation; 228 private UpdateVector handlerUpdatePrimSinglePosition = null; //OnUpdatePrimSinglePosition;
229 private UpdateVector handlerUpdatePrimScale = null; //OnUpdatePrimScale; 229 private UpdatePrimSingleRotation handlerUpdatePrimSingleRotation = null; //OnUpdatePrimSingleRotation;
230 private UpdateVector handlerUpdatePrimGroupScale = null; //OnUpdateGroupScale; 230 private UpdateVector handlerUpdatePrimScale = null; //OnUpdatePrimScale;
231 private UpdateVector handlerUpdateVector = null; //OnUpdatePrimGroupPosition; 231 private UpdateVector handlerUpdatePrimGroupScale = null; //OnUpdateGroupScale;
232 private UpdatePrimRotation handlerUpdatePrimRotation = null; //OnUpdatePrimGroupRotation; 232 private UpdateVector handlerUpdateVector = null; //OnUpdatePrimGroupPosition;
233 private UpdatePrimGroupRotation handlerUpdatePrimGroupRotation = null; //OnUpdatePrimGroupMouseRotation; 233 private UpdatePrimRotation handlerUpdatePrimRotation = null; //OnUpdatePrimGroupRotation;
234 private PacketStats handlerPacketStats = null; // OnPacketStats;# 234 private UpdatePrimGroupRotation handlerUpdatePrimGroupRotation = null; //OnUpdatePrimGroupMouseRotation;
235 private RequestAsset handlerRequestAsset = null; // OnRequestAsset; 235 private PacketStats handlerPacketStats = null; // OnPacketStats;#
236 private UUIDNameRequest handlerTeleportHomeRequest = null; 236 private RequestAsset handlerRequestAsset = null; // OnRequestAsset;
237 237 private UUIDNameRequest handlerTeleportHomeRequest = null;
238 private ScriptAnswer handlerScriptAnswer = null; 238
239 private RequestPayPrice handlerRequestPayPrice = null; 239 private ScriptAnswer handlerScriptAnswer = null;
240 private ObjectDeselect handlerObjectDetach = null; 240 private RequestPayPrice handlerRequestPayPrice = null;
241 private AgentSit handlerOnUndo = null; 241 private ObjectDeselect handlerObjectDetach = null;
242 242 private AgentSit handlerOnUndo = null;
243 /* Properties */ 243
244 244 /* Properties */
245 public LLUUID SecureSessionId 245
246 { 246 public LLUUID SecureSessionId
247 get { return m_secureSessionId; } 247 {
248 } 248 get { return m_secureSessionId; }
249 249 }
250 public IScene Scene 250
251 { 251 public IScene Scene
252 get { return m_scene; } 252 {
253 } 253 get { return m_scene; }
254 254 }
255 public LLUUID SessionId 255
256 { 256 public LLUUID SessionId
257 get { return m_sessionId; } 257 {
258 } 258 get { return m_sessionId; }
259 259 }
260 public LLVector3 StartPos 260
261 { 261 public LLVector3 StartPos
262 get { return m_startpos; } 262 {
263 set { m_startpos = value; } 263 get { return m_startpos; }
264 } 264 set { m_startpos = value; }
265 265 }
266 public LLUUID AgentId 266
267 { 267 public LLUUID AgentId
268 get { return m_agentId; } 268 {
269 } 269 get { return m_agentId; }
270 270 }
271 /// <summary> 271
272 /// This is a utility method used by single states to not duplicate kicks and blue card of death messages. 272 /// <summary>
273 /// </summary> 273 /// This is a utility method used by single states to not duplicate kicks and blue card of death messages.
274 public bool ChildAgentStatus() 274 /// </summary>
275 { 275 public bool ChildAgentStatus()
276 return m_scene.PresenceChildStatus(AgentId); 276 {
277 } 277 return m_scene.PresenceChildStatus(AgentId);
278 278 }
279 /// <summary> 279
280 /// First name of the agent/avatar represented by the client 280 /// <summary>
281 /// </summary> 281 /// First name of the agent/avatar represented by the client
282 public string FirstName 282 /// </summary>
283 { 283 public string FirstName
284 get { return m_firstName; } 284 {
285 } 285 get { return m_firstName; }
286 286 }
287 /// <summary> 287
288 /// Last name of the agent/avatar represented by the client 288 /// <summary>
289 /// </summary> 289 /// Last name of the agent/avatar represented by the client
290 public string LastName 290 /// </summary>
291 { 291 public string LastName
292 get { return m_lastName; } 292 {
293 } 293 get { return m_lastName; }
294 294 }
295 /// <summary> 295
296 /// Full name of the client (first name and last name) 296 /// <summary>
297 /// </summary> 297 /// Full name of the client (first name and last name)
298 public string Name 298 /// </summary>
299 { 299 public string Name
300 get { return FirstName + " " + LastName; } 300 {
301 } 301 get { return FirstName + " " + LastName; }
302 302 }
303 public uint CircuitCode 303
304 { 304 public uint CircuitCode
305 get { return m_circuitCode; } 305 {
306 } 306 get { return m_circuitCode; }
307 307 }
308 public int MoneyBalance 308
309 { 309 public int MoneyBalance
310 get { return m_moneyBalance; } 310 {
311 } 311 get { return m_moneyBalance; }
312 312 }
313 public int NextAnimationSequenceNumber 313
314 { 314 public int NextAnimationSequenceNumber
315 get { return m_animationSequenceNumber++; } 315 {
316 } 316 get { return m_animationSequenceNumber++; }
317 317 }
318 /* METHODS */ 318
319 319 /* METHODS */
320 public ClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, PacketServer packServer, 320
321 AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode, EndPoint proxyEP) 321 public LLClientView(EndPoint remoteEP, IScene scene, AssetCache assetCache, LLPacketServer packServer,
322 { 322 AgentCircuitManager authenSessions, LLUUID agentId, LLUUID sessionId, uint circuitCode, EndPoint proxyEP)
323 m_moneyBalance = 1000; 323 {
324 324 m_moneyBalance = 1000;
325 m_channelVersion = Helpers.StringToField(scene.GetSimulatorVersion()); 325
326 326 m_channelVersion = Helpers.StringToField(scene.GetSimulatorVersion());
327 m_scene = scene; 327
328 m_assetCache = assetCache; 328 m_scene = scene;
329 329 m_assetCache = assetCache;
330 m_networkServer = packServer; 330
331 // m_inventoryCache = inventoryCache; 331 m_networkServer = packServer;
332 m_authenticateSessionsHandler = authenSessions; 332 // m_inventoryCache = inventoryCache;
333 333 m_authenticateSessionsHandler = authenSessions;
334 m_log.Info("[CLIENT]: Started up new client thread to handle incoming request"); 334
335 335 m_log.Info("[CLIENT]: Started up new client thread to handle incoming request");
336 m_agentId = agentId; 336
337 m_sessionId = sessionId; 337 m_agentId = agentId;
338 m_circuitCode = circuitCode; 338 m_sessionId = sessionId;
339 339 m_circuitCode = circuitCode;
340 m_userEndPoint = remoteEP; 340
341 m_proxyEndPoint = proxyEP; 341 m_userEndPoint = remoteEP;
342 342 m_proxyEndPoint = proxyEP;
343 m_startpos = m_authenticateSessionsHandler.GetPosition(circuitCode); 343
344 344 m_startpos = m_authenticateSessionsHandler.GetPosition(circuitCode);
345 // While working on this, the BlockingQueue had me fooled for a bit. 345
346 // The Blocking queue causes the thread to stop until there's something 346 // While working on this, the BlockingQueue had me fooled for a bit.
347 // in it to process. It's an on-purpose threadlock though because 347 // The Blocking queue causes the thread to stop until there's something
348 // without it, the clientloop will suck up all sim resources. 348 // in it to process. It's an on-purpose threadlock though because
349 349 // without it, the clientloop will suck up all sim resources.
350 m_packetQueue = new PacketQueue(agentId); 350
351 351 m_packetQueue = new LLPacketQueue(agentId);
352 RegisterLocalPacketHandlers(); 352
353 353 RegisterLocalPacketHandlers();
354 m_clientThread = new Thread(new ThreadStart(AuthUser)); 354
355 m_clientThread.Name = "ClientThread"; 355 m_clientThread = new Thread(new ThreadStart(AuthUser));
356 m_clientThread.IsBackground = true; 356 m_clientThread.Name = "ClientThread";
357 m_clientThread.Start(); 357 m_clientThread.IsBackground = true;
358 ThreadTracker.Add(m_clientThread); 358 m_clientThread.Start();
359 } 359 ThreadTracker.Add(m_clientThread);
360 360 }
361 public void SetDebug(int newDebug) 361
362 { 362 public void SetDebug(int newDebug)
363 m_debug = newDebug; 363 {
364 } 364 m_debug = newDebug;
365 365 }
366 # region Client Methods 366
367 367 # region Client Methods
368 private void CloseCleanup(bool shutdownCircuit) 368
369 { 369 private void CloseCleanup(bool shutdownCircuit)
370 m_scene.RemoveClient(AgentId); 370 {
371 371 m_scene.RemoveClient(AgentId);
372 //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 372
373 //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true)); 373 //m_log.InfoFormat("[CLIENTVIEW] Memory pre GC {0}", System.GC.GetTotalMemory(false));
374 374 //m_log.InfoFormat("[CLIENTVIEW] Memory post GC {0}", System.GC.GetTotalMemory(true));
375 // Send the STOP packet 375
376 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator); 376 // Send the STOP packet
377 OutPacket(disable, ThrottleOutPacketType.Unknown); 377 DisableSimulatorPacket disable = (DisableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.DisableSimulator);
378 378 OutPacket(disable, ThrottleOutPacketType.Unknown);
379 m_packetQueue.Close(); 379
380 380 m_packetQueue.Close();
381 Thread.Sleep(2000); 381
382 382 Thread.Sleep(2000);
383 383
384 // Shut down timers 384
385 m_ackTimer.Stop(); 385 // Shut down timers
386 m_clientPingTimer.Stop(); 386 m_ackTimer.Stop();
387 387 m_clientPingTimer.Stop();
388 // This is just to give the client a reasonable chance of 388
389 // flushing out all it's packets. There should probably 389 // This is just to give the client a reasonable chance of
390 // be a better mechanism here 390 // flushing out all it's packets. There should probably
391 391 // be a better mechanism here
392 // We can't reach into other scenes and close the connection 392
393 // We need to do this over grid communications 393 // We can't reach into other scenes and close the connection
394 //m_scene.CloseAllAgents(CircuitCode); 394 // We need to do this over grid communications
395 395 //m_scene.CloseAllAgents(CircuitCode);
396 // If we're not shutting down the circuit, then this is the last time we'll go here. 396
397 // If we are shutting down the circuit, the UDP Server will come back here with 397 // If we're not shutting down the circuit, then this is the last time we'll go here.
398 // ShutDownCircuit = false 398 // If we are shutting down the circuit, the UDP Server will come back here with
399 if (!(shutdownCircuit)) 399 // ShutDownCircuit = false
400 { 400 if (!(shutdownCircuit))
401 GC.Collect(); 401 {
402 m_clientThread.Abort(); 402 GC.Collect();
403 } 403 m_clientThread.Abort();
404 } 404 }
405 405 }
406 /// <summary> 406
407 /// Close down the client view. This *must* be the last method called, since the last # 407 /// <summary>
408 /// statement of CloseCleanup() aborts the thread. 408 /// Close down the client view. This *must* be the last method called, since the last #
409 /// </summary> 409 /// statement of CloseCleanup() aborts the thread.
410 /// <param name="shutdownCircuit"></param> 410 /// </summary>
411 public void Close(bool shutdownCircuit) 411 /// <param name="shutdownCircuit"></param>
412 { 412 public void Close(bool shutdownCircuit)
413 // Pull Client out of Region 413 {
414 m_log.Info("[CLIENT]: Close has been called"); 414 // Pull Client out of Region
415 m_packetQueue.Flush(); 415 m_log.Info("[CLIENT]: Close has been called");
416 416 m_packetQueue.Flush();
417 //raiseevent on the packet server to Shutdown the circuit 417
418 if (shutdownCircuit) 418 //raiseevent on the packet server to Shutdown the circuit
419 { 419 if (shutdownCircuit)
420 OnConnectionClosed(this); 420 {
421 } 421 OnConnectionClosed(this);
422 422 }
423 CloseCleanup(shutdownCircuit); 423
424 } 424 CloseCleanup(shutdownCircuit);
425 425 }
426 public void Kick(string message) 426
427 { 427 public void Kick(string message)
428 if (!ChildAgentStatus()) 428 {
429 { 429 if (!ChildAgentStatus())
430 KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser); 430 {
431 kupack.UserInfo.AgentID = AgentId; 431 KickUserPacket kupack = (KickUserPacket)PacketPool.Instance.GetPacket(PacketType.KickUser);
432 kupack.UserInfo.SessionID = SessionId; 432 kupack.UserInfo.AgentID = AgentId;
433 kupack.TargetBlock.TargetIP = (uint)0; 433 kupack.UserInfo.SessionID = SessionId;
434 kupack.TargetBlock.TargetPort = (ushort)0; 434 kupack.TargetBlock.TargetIP = (uint)0;
435 kupack.UserInfo.Reason = Helpers.StringToField(message); 435 kupack.TargetBlock.TargetPort = (ushort)0;
436 OutPacket(kupack, ThrottleOutPacketType.Task); 436 kupack.UserInfo.Reason = Helpers.StringToField(message);
437 } 437 OutPacket(kupack, ThrottleOutPacketType.Task);
438 } 438 }
439 439 }
440 public void Stop() 440
441 { 441 public void Stop()
442 // Shut down timers 442 {
443 m_ackTimer.Stop(); 443 // Shut down timers
444 m_clientPingTimer.Stop(); 444 m_ackTimer.Stop();
445 } 445 m_clientPingTimer.Stop();
446 446 }
447 public void Restart() 447
448 { 448 public void Restart()
449 // re-construct 449 {
450 m_pendingAcks = new Dictionary<uint, uint>(); 450 // re-construct
451 m_needAck = new Dictionary<uint, Packet>(); 451 m_pendingAcks = new Dictionary<uint, uint>();
452 m_sequence += 1000000; 452 m_needAck = new Dictionary<uint, Packet>();
453 453 m_sequence += 1000000;
454 m_ackTimer = new Timer(750); 454
455 m_ackTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); 455 m_ackTimer = new Timer(750);
456 m_ackTimer.Start(); 456 m_ackTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
457 457 m_ackTimer.Start();
458 m_clientPingTimer = new Timer(5000); 458
459 m_clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); 459 m_clientPingTimer = new Timer(5000);
460 m_clientPingTimer.Enabled = true; 460 m_clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity);
461 } 461 m_clientPingTimer.Enabled = true;
462 462 }
463 public void Terminate() 463
464 { 464 public void Terminate()
465 // disable blocking queue 465 {
466 m_packetQueue.Enqueue(null); 466 // disable blocking queue
467 467 m_packetQueue.Enqueue(null);
468 // wait for thread stoped 468
469 m_clientThread.Join(); 469 // wait for thread stoped
470 470 m_clientThread.Join();
471 // delete circuit code 471
472 m_networkServer.CloseClient(this); 472 // delete circuit code
473 } 473 m_networkServer.CloseClient(this);
474 474 }
475 #endregion 475
476 476 #endregion
477 # region Packet Handling 477
478 478 # region Packet Handling
479 public static bool AddPacketHandler(PacketType packetType, PacketMethod handler) 479
480 { 480 public static bool AddPacketHandler(PacketType packetType, PacketMethod handler)
481 bool result = false; 481 {
482 lock (PacketHandlers) 482 bool result = false;
483 { 483 lock (PacketHandlers)
484 if (!PacketHandlers.ContainsKey(packetType)) 484 {
485 { 485 if (!PacketHandlers.ContainsKey(packetType))
486 PacketHandlers.Add(packetType, handler); 486 {
487 result = true; 487 PacketHandlers.Add(packetType, handler);
488 } 488 result = true;
489 } 489 }
490 return result; 490 }
491 } 491 return result;
492 492 }
493 public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler) 493
494 { 494 public bool AddLocalPacketHandler(PacketType packetType, PacketMethod handler)
495 bool result = false; 495 {
496 lock (m_packetHandlers) 496 bool result = false;
497 { 497 lock (m_packetHandlers)
498 if (!m_packetHandlers.ContainsKey(packetType)) 498 {
499 { 499 if (!m_packetHandlers.ContainsKey(packetType))
500 m_packetHandlers.Add(packetType, handler); 500 {
501 result = true; 501 m_packetHandlers.Add(packetType, handler);
502 } 502 result = true;
503 } 503 }
504 return result; 504 }
505 } 505 return result;
506 506 }
507 /// <summary> 507
508 /// Try to process a packet using registered packet handlers 508 /// <summary>
509 /// </summary> 509 /// Try to process a packet using registered packet handlers
510 /// <param name="packet"></param> 510 /// </summary>
511 /// <returns>True if a handler was found which successfully processed the packet.</returns> 511 /// <param name="packet"></param>
512 protected virtual bool ProcessPacketMethod(Packet packet) 512 /// <returns>True if a handler was found which successfully processed the packet.</returns>
513 { 513 protected virtual bool ProcessPacketMethod(Packet packet)
514 bool result = false; 514 {
515 bool found = false; 515 bool result = false;
516 PacketMethod method; 516 bool found = false;
517 if (m_packetHandlers.TryGetValue(packet.Type, out method)) 517 PacketMethod method;
518 { 518 if (m_packetHandlers.TryGetValue(packet.Type, out method))
519 //there is a local handler for this packet type 519 {
520 result = method(this, packet); 520 //there is a local handler for this packet type
521 } 521 result = method(this, packet);
522 else 522 }
523 { 523 else
524 //there is not a local handler so see if there is a Global handler 524 {
525 lock (PacketHandlers) 525 //there is not a local handler so see if there is a Global handler
526 { 526 lock (PacketHandlers)
527 found = PacketHandlers.TryGetValue(packet.Type, out method); 527 {
528 } 528 found = PacketHandlers.TryGetValue(packet.Type, out method);
529 if (found) 529 }
530 { 530 if (found)
531 result = method(this, packet); 531 {
532 } 532 result = method(this, packet);
533 } 533 }
534 return result; 534 }
535 } 535 return result;
536 536 }
537 protected void DebugPacket(string direction, Packet packet) 537
538 { 538 protected void DebugPacket(string direction, Packet packet)
539 if (m_debug > 0) 539 {
540 { 540 if (m_debug > 0)
541 string info = String.Empty; 541 {
542 542 string info = String.Empty;
543 if (m_debug < 255 && packet.Type == PacketType.AgentUpdate) 543
544 return; 544 if (m_debug < 255 && packet.Type == PacketType.AgentUpdate)
545 if (m_debug < 254 && packet.Type == PacketType.ViewerEffect) 545 return;
546 return; 546 if (m_debug < 254 && packet.Type == PacketType.ViewerEffect)
547 if (m_debug < 253 && ( 547 return;
548 packet.Type == PacketType.CompletePingCheck || 548 if (m_debug < 253 && (
549 packet.Type == PacketType.StartPingCheck 549 packet.Type == PacketType.CompletePingCheck ||
550 )) 550 packet.Type == PacketType.StartPingCheck
551 return; 551 ))
552 if (m_debug < 252 && packet.Type == PacketType.PacketAck) 552 return;
553 return; 553 if (m_debug < 252 && packet.Type == PacketType.PacketAck)
554 554 return;
555 if (m_debug > 1) 555
556 { 556 if (m_debug > 1)
557 info = packet.ToString(); 557 {
558 } 558 info = packet.ToString();
559 else 559 }
560 { 560 else
561 info = packet.Type.ToString(); 561 {
562 } 562 info = packet.Type.ToString();
563 Console.WriteLine(m_circuitCode + ":" + direction + ": " + info); 563 }
564 } 564 Console.WriteLine(m_circuitCode + ":" + direction + ": " + info);
565 } 565 }
566 566 }
567 protected virtual void ClientLoop() 567
568 { 568 protected virtual void ClientLoop()
569 m_log.Info("[CLIENT]: Entered loop"); 569 {
570 while (true) 570 m_log.Info("[CLIENT]: Entered loop");
571 { 571 while (true)
572 QueItem nextPacket = m_packetQueue.Dequeue(); 572 {
573 if (nextPacket == null) 573 LLQueItem nextPacket = m_packetQueue.Dequeue();
574 { 574 if (nextPacket == null)
575 break; 575 {
576 } 576 break;
577 if (nextPacket.Incoming) 577 }
578 { 578 if (nextPacket.Incoming)
579 if (nextPacket.Packet.Type != PacketType.AgentUpdate) 579 {
580 { 580 if (nextPacket.Packet.Type != PacketType.AgentUpdate)
581 m_packetsReceived++; 581 {
582 } 582 m_packetsReceived++;
583 DebugPacket("IN", nextPacket.Packet); 583 }
584 ProcessInPacket(nextPacket.Packet); 584 DebugPacket("IN", nextPacket.Packet);
585 } 585 ProcessInPacket(nextPacket.Packet);
586 else 586 }
587 { 587 else
588 DebugPacket("OUT", nextPacket.Packet); 588 {
589 ProcessOutPacket(nextPacket.Packet); 589 DebugPacket("OUT", nextPacket.Packet);
590 } 590 ProcessOutPacket(nextPacket.Packet);
591 } 591 }
592 } 592 }
593 593 }
594 # endregion 594
595 595 # endregion
596 protected void CheckClientConnectivity(object sender, ElapsedEventArgs e) 596
597 { 597 protected void CheckClientConnectivity(object sender, ElapsedEventArgs e)
598 if (m_packetsReceived == m_lastPacketsReceived) 598 {
599 { 599 if (m_packetsReceived == m_lastPacketsReceived)
600 m_probesWithNoIngressPackets++; 600 {
601 if ((m_probesWithNoIngressPackets > 30 && !m_clientBlocked) || (m_probesWithNoIngressPackets > 90 && m_clientBlocked)) 601 m_probesWithNoIngressPackets++;
602 { 602 if ((m_probesWithNoIngressPackets > 30 && !m_clientBlocked) || (m_probesWithNoIngressPackets > 90 && m_clientBlocked))
603 603 {
604 if (OnConnectionClosed != null) 604
605 { 605 if (OnConnectionClosed != null)
606 OnConnectionClosed(this); 606 {
607 } 607 OnConnectionClosed(this);
608 } 608 }
609 else 609 }
610 { 610 else
611 // this will normally trigger at least one packet (ping response) 611 {
612 SendStartPingCheck(0); 612 // this will normally trigger at least one packet (ping response)
613 613 SendStartPingCheck(0);
614 } 614
615 } 615 }
616 else 616 }
617 { 617 else
618 // Something received in the meantime - we can reset the counters 618 {
619 m_probesWithNoIngressPackets = 0; 619 // Something received in the meantime - we can reset the counters
620 m_lastPacketsReceived = m_packetsReceived; 620 m_probesWithNoIngressPackets = 0;
621 621 m_lastPacketsReceived = m_packetsReceived;
622 } 622
623 //SendPacketStats(); 623 }
624 } 624 //SendPacketStats();
625 625 }
626 # region Setup 626
627 627 # region Setup
628 protected virtual void InitNewClient() 628
629 { 629 protected virtual void InitNewClient()
630 //this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache); 630 {
631 631 //this.UploadAssets = new AgentAssetUpload(this, m_assetCache, m_inventoryCache);
632 // Establish our two timers. We could probably get this down to one 632
633 m_ackTimer = new Timer(750); 633 // Establish our two timers. We could probably get this down to one
634 m_ackTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed); 634 m_ackTimer = new Timer(750);
635 m_ackTimer.Start(); 635 m_ackTimer.Elapsed += new ElapsedEventHandler(AckTimer_Elapsed);
636 636 m_ackTimer.Start();
637 m_clientPingTimer = new Timer(5000); 637
638 m_clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity); 638 m_clientPingTimer = new Timer(5000);
639 m_clientPingTimer.Enabled = true; 639 m_clientPingTimer.Elapsed += new ElapsedEventHandler(CheckClientConnectivity);
640 640 m_clientPingTimer.Enabled = true;
641 m_log.Info("[CLIENT]: Adding viewer agent to scene"); 641
642 m_scene.AddNewClient(this, true); 642 m_log.Info("[CLIENT]: Adding viewer agent to scene");
643 } 643 m_scene.AddNewClient(this, true);
644 644 }
645 protected virtual void AuthUser() 645
646 { 646 protected virtual void AuthUser()
647 // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(m_cirpack.m_circuitCode.m_sessionId, m_cirpack.m_circuitCode.ID, m_cirpack.m_circuitCode.Code); 647 {
648 AuthenticateResponse sessionInfo = 648 // AuthenticateResponse sessionInfo = m_gridServer.AuthenticateSession(m_cirpack.m_circuitCode.m_sessionId, m_cirpack.m_circuitCode.ID, m_cirpack.m_circuitCode.Code);
649 m_authenticateSessionsHandler.AuthenticateSession(m_sessionId, m_agentId, 649 AuthenticateResponse sessionInfo =
650 m_circuitCode); 650 m_authenticateSessionsHandler.AuthenticateSession(m_sessionId, m_agentId,
651 if (!sessionInfo.Authorised) 651 m_circuitCode);
652 { 652 if (!sessionInfo.Authorised)
653 //session/circuit not authorised 653 {
654 m_log.Info("[CLIENT]: New user request denied to " + m_userEndPoint.ToString()); 654 //session/circuit not authorised
655 m_packetQueue.Close(); 655 m_log.Info("[CLIENT]: New user request denied to " + m_userEndPoint.ToString());
656 m_clientThread.Abort(); 656 m_packetQueue.Close();
657 } 657 m_clientThread.Abort();
658 else 658 }
659 { 659 else
660 m_log.Info("[CLIENT]: Got authenticated connection from " + m_userEndPoint.ToString()); 660 {
661 //session is authorised 661 m_log.Info("[CLIENT]: Got authenticated connection from " + m_userEndPoint.ToString());
662 m_firstName = sessionInfo.LoginInfo.First; 662 //session is authorised
663 m_lastName = sessionInfo.LoginInfo.Last; 663 m_firstName = sessionInfo.LoginInfo.First;
664 664 m_lastName = sessionInfo.LoginInfo.Last;
665 if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero) 665
666 { 666 if (sessionInfo.LoginInfo.SecureSession != LLUUID.Zero)
667 m_secureSessionId = sessionInfo.LoginInfo.SecureSession; 667 {
668 } 668 m_secureSessionId = sessionInfo.LoginInfo.SecureSession;
669 // This sets up all the timers 669 }
670 InitNewClient(); 670 // This sets up all the timers
671 671 InitNewClient();
672 ClientLoop(); 672
673 } 673 ClientLoop();
674 } 674 }
675 675 }
676 # endregion 676
677 677 # endregion
678 // Previously ClientView.API partial class 678
679 public event Action<IClientAPI> OnLogout; 679 // Previously ClientView.API partial class
680 public event ObjectPermissions OnObjectPermissions; 680 public event Action<IClientAPI> OnLogout;
681 681 public event ObjectPermissions OnObjectPermissions;
682 public event Action<IClientAPI> OnConnectionClosed; 682
683 public event ViewerEffectEventHandler OnViewerEffect; 683 public event Action<IClientAPI> OnConnectionClosed;
684 public event ImprovedInstantMessage OnInstantMessage; 684 public event ViewerEffectEventHandler OnViewerEffect;
685 public event ChatFromViewer OnChatFromViewer; 685 public event ImprovedInstantMessage OnInstantMessage;
686 public event TextureRequest OnRequestTexture; 686 public event ChatFromViewer OnChatFromViewer;
687 public event RezObject OnRezObject; 687 public event TextureRequest OnRequestTexture;
688 public event GenericCall4 OnDeRezObject; 688 public event RezObject OnRezObject;
689 public event ModifyTerrain OnModifyTerrain; 689 public event GenericCall4 OnDeRezObject;
690 public event Action<IClientAPI> OnRegionHandShakeReply; 690 public event ModifyTerrain OnModifyTerrain;
691 public event GenericCall2 OnRequestWearables; 691 public event Action<IClientAPI> OnRegionHandShakeReply;
692 public event SetAppearance OnSetAppearance; 692 public event GenericCall2 OnRequestWearables;
693 public event AvatarNowWearing OnAvatarNowWearing; 693 public event SetAppearance OnSetAppearance;
694 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv; 694 public event AvatarNowWearing OnAvatarNowWearing;
695 public event UUIDNameRequest OnDetachAttachmentIntoInv; 695 public event RezSingleAttachmentFromInv OnRezSingleAttachmentFromInv;
696 public event ObjectAttach OnObjectAttach; 696 public event UUIDNameRequest OnDetachAttachmentIntoInv;
697 public event ObjectDeselect OnObjectDetach; 697 public event ObjectAttach OnObjectAttach;
698 public event GenericCall2 OnCompleteMovementToRegion; 698 public event ObjectDeselect OnObjectDetach;
699 public event UpdateAgent OnAgentUpdate; 699 public event GenericCall2 OnCompleteMovementToRegion;
700 public event AgentRequestSit OnAgentRequestSit; 700 public event UpdateAgent OnAgentUpdate;
701 public event AgentSit OnAgentSit; 701 public event AgentRequestSit OnAgentRequestSit;
702 public event AvatarPickerRequest OnAvatarPickerRequest; 702 public event AgentSit OnAgentSit;
703 public event StartAnim OnStartAnim; 703 public event AvatarPickerRequest OnAvatarPickerRequest;
704 public event StopAnim OnStopAnim; 704 public event StartAnim OnStartAnim;
705 public event Action<IClientAPI> OnRequestAvatarsData; 705 public event StopAnim OnStopAnim;
706 public event LinkObjects OnLinkObjects; 706 public event Action<IClientAPI> OnRequestAvatarsData;
707 public event DelinkObjects OnDelinkObjects; 707 public event LinkObjects OnLinkObjects;
708 public event UpdateVector OnGrabObject; 708 public event DelinkObjects OnDelinkObjects;
709 public event ObjectSelect OnDeGrabObject; 709 public event UpdateVector OnGrabObject;
710 public event ObjectDuplicate OnObjectDuplicate; 710 public event ObjectSelect OnDeGrabObject;
711 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay; 711 public event ObjectDuplicate OnObjectDuplicate;
712 public event MoveObject OnGrabUpdate; 712 public event ObjectDuplicateOnRay OnObjectDuplicateOnRay;
713 public event AddNewPrim OnAddPrim; 713 public event MoveObject OnGrabUpdate;
714 public event RequestGodlikePowers OnRequestGodlikePowers; 714 public event AddNewPrim OnAddPrim;
715 public event GodKickUser OnGodKickUser; 715 public event RequestGodlikePowers OnRequestGodlikePowers;
716 public event ObjectExtraParams OnUpdateExtraParams; 716 public event GodKickUser OnGodKickUser;
717 public event UpdateShape OnUpdatePrimShape; 717 public event ObjectExtraParams OnUpdateExtraParams;
718 public event ObjectSelect OnObjectSelect; 718 public event UpdateShape OnUpdatePrimShape;
719 public event ObjectDeselect OnObjectDeselect; 719 public event ObjectSelect OnObjectSelect;
720 public event GenericCall7 OnObjectDescription; 720 public event ObjectDeselect OnObjectDeselect;
721 public event GenericCall7 OnObjectName; 721 public event GenericCall7 OnObjectDescription;
722 public event ObjectIncludeInSearch OnObjectIncludeInSearch; 722 public event GenericCall7 OnObjectName;
723 public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily; 723 public event ObjectIncludeInSearch OnObjectIncludeInSearch;
724 public event UpdatePrimFlags OnUpdatePrimFlags; 724 public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
725 public event UpdatePrimTexture OnUpdatePrimTexture; 725 public event UpdatePrimFlags OnUpdatePrimFlags;
726 public event UpdateVector OnUpdatePrimGroupPosition; 726 public event UpdatePrimTexture OnUpdatePrimTexture;
727 public event UpdateVector OnUpdatePrimSinglePosition; 727 public event UpdateVector OnUpdatePrimGroupPosition;
728 public event UpdatePrimRotation OnUpdatePrimGroupRotation; 728 public event UpdateVector OnUpdatePrimSinglePosition;
729 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; 729 public event UpdatePrimRotation OnUpdatePrimGroupRotation;
730 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; 730 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
731 public event UpdateVector OnUpdatePrimScale; 731 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
732 public event UpdateVector OnUpdatePrimGroupScale; 732 public event UpdateVector OnUpdatePrimScale;
733 public event StatusChange OnChildAgentStatus; 733 public event UpdateVector OnUpdatePrimGroupScale;
734 public event GenericCall2 OnStopMovement; 734 public event StatusChange OnChildAgentStatus;
735 public event Action<LLUUID> OnRemoveAvatar; 735 public event GenericCall2 OnStopMovement;
736 public event RequestMapBlocks OnRequestMapBlocks; 736 public event Action<LLUUID> OnRemoveAvatar;
737 public event RequestMapName OnMapNameRequest; 737 public event RequestMapBlocks OnRequestMapBlocks;
738 public event TeleportLocationRequest OnTeleportLocationRequest; 738 public event RequestMapName OnMapNameRequest;
739 public event TeleportLandmarkRequest OnTeleportLandmarkRequest; 739 public event TeleportLocationRequest OnTeleportLocationRequest;
740 public event DisconnectUser OnDisconnectUser; 740 public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
741 public event RequestAvatarProperties OnRequestAvatarProperties; 741 public event DisconnectUser OnDisconnectUser;
742 public event SetAlwaysRun OnSetAlwaysRun; 742 public event RequestAvatarProperties OnRequestAvatarProperties;
743 743 public event SetAlwaysRun OnSetAlwaysRun;
744 public event FetchInventory OnAgentDataUpdateRequest; 744
745 public event FetchInventory OnUserInfoRequest; 745 public event FetchInventory OnAgentDataUpdateRequest;
746 public event TeleportLocationRequest OnSetStartLocationRequest; 746 public event FetchInventory OnUserInfoRequest;
747 public event UpdateAvatarProperties OnUpdateAvatarProperties; 747 public event TeleportLocationRequest OnSetStartLocationRequest;
748 748 public event UpdateAvatarProperties OnUpdateAvatarProperties;
749 749
750 public event CreateNewInventoryItem OnCreateNewInventoryItem; 750
751 public event CreateInventoryFolder OnCreateNewInventoryFolder; 751 public event CreateNewInventoryItem OnCreateNewInventoryItem;
752 public event UpdateInventoryFolder OnUpdateInventoryFolder; 752 public event CreateInventoryFolder OnCreateNewInventoryFolder;
753 public event MoveInventoryFolder OnMoveInventoryFolder; 753 public event UpdateInventoryFolder OnUpdateInventoryFolder;
754 public event FetchInventoryDescendents OnFetchInventoryDescendents; 754 public event MoveInventoryFolder OnMoveInventoryFolder;
755 public event PurgeInventoryDescendents OnPurgeInventoryDescendents; 755 public event FetchInventoryDescendents OnFetchInventoryDescendents;
756 public event FetchInventory OnFetchInventory; 756 public event PurgeInventoryDescendents OnPurgeInventoryDescendents;
757 public event RequestTaskInventory OnRequestTaskInventory; 757 public event FetchInventory OnFetchInventory;
758 public event UpdateInventoryItem OnUpdateInventoryItem; 758 public event RequestTaskInventory OnRequestTaskInventory;
759 public event CopyInventoryItem OnCopyInventoryItem; 759 public event UpdateInventoryItem OnUpdateInventoryItem;
760 public event MoveInventoryItem OnMoveInventoryItem; 760 public event CopyInventoryItem OnCopyInventoryItem;
761 public event RemoveInventoryItem OnRemoveInventoryItem; 761 public event MoveInventoryItem OnMoveInventoryItem;
762 public event RemoveInventoryFolder OnRemoveInventoryFolder; 762 public event RemoveInventoryItem OnRemoveInventoryItem;
763 public event UDPAssetUploadRequest OnAssetUploadRequest; 763 public event RemoveInventoryFolder OnRemoveInventoryFolder;
764 public event XferReceive OnXferReceive; 764 public event UDPAssetUploadRequest OnAssetUploadRequest;
765 public event RequestXfer OnRequestXfer; 765 public event XferReceive OnXferReceive;
766 public event ConfirmXfer OnConfirmXfer; 766 public event RequestXfer OnRequestXfer;
767 public event RezScript OnRezScript; 767 public event ConfirmXfer OnConfirmXfer;
768 public event UpdateTaskInventory OnUpdateTaskInventory; 768 public event RezScript OnRezScript;
769 public event MoveTaskInventory OnMoveTaskItem; 769 public event UpdateTaskInventory OnUpdateTaskInventory;
770 public event RemoveTaskInventory OnRemoveTaskItem; 770 public event MoveTaskInventory OnMoveTaskItem;
771 public event RequestAsset OnRequestAsset; 771 public event RemoveTaskInventory OnRemoveTaskItem;
772 772 public event RequestAsset OnRequestAsset;
773 public event UUIDNameRequest OnNameFromUUIDRequest; 773
774 774 public event UUIDNameRequest OnNameFromUUIDRequest;
775 public event ParcelAccessListRequest OnParcelAccessListRequest; 775
776 public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest; 776 public event ParcelAccessListRequest OnParcelAccessListRequest;
777 public event ParcelPropertiesRequest OnParcelPropertiesRequest; 777 public event ParcelAccessListUpdateRequest OnParcelAccessListUpdateRequest;
778 public event ParcelDivideRequest OnParcelDivideRequest; 778 public event ParcelPropertiesRequest OnParcelPropertiesRequest;
779 public event ParcelJoinRequest OnParcelJoinRequest; 779 public event ParcelDivideRequest OnParcelDivideRequest;
780 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; 780 public event ParcelJoinRequest OnParcelJoinRequest;
781 public event ParcelSelectObjects OnParcelSelectObjects; 781 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
782 public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; 782 public event ParcelSelectObjects OnParcelSelectObjects;
783 public event EstateOwnerMessageRequest OnEstateOwnerMessage; 783 public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
784 public event RegionInfoRequest OnRegionInfoRequest; 784 public event EstateOwnerMessageRequest OnEstateOwnerMessage;
785 public event EstateCovenantRequest OnEstateCovenantRequest; 785 public event RegionInfoRequest OnRegionInfoRequest;
786 786 public event EstateCovenantRequest OnEstateCovenantRequest;
787 public event FriendActionDelegate OnApproveFriendRequest; 787
788 public event FriendActionDelegate OnDenyFriendRequest; 788 public event FriendActionDelegate OnApproveFriendRequest;
789 public event FriendshipTermination OnTerminateFriendship; 789 public event FriendActionDelegate OnDenyFriendRequest;
790 790 public event FriendshipTermination OnTerminateFriendship;
791 public event PacketStats OnPacketStats; 791
792 792 public event PacketStats OnPacketStats;
793 public event MoneyTransferRequest OnMoneyTransferRequest; 793
794 public event EconomyDataRequest OnEconomyDataRequest; 794 public event MoneyTransferRequest OnMoneyTransferRequest;
795 795 public event EconomyDataRequest OnEconomyDataRequest;
796 public event MoneyBalanceRequest OnMoneyBalanceRequest; 796
797 public event ParcelBuy OnParcelBuy; 797 public event MoneyBalanceRequest OnMoneyBalanceRequest;
798 798 public event ParcelBuy OnParcelBuy;
799 public event UUIDNameRequest OnTeleportHomeRequest; 799
800 800 public event UUIDNameRequest OnTeleportHomeRequest;
801 public event ScriptAnswer OnScriptAnswer; 801
802 public event RequestPayPrice OnRequestPayPrice; 802 public event ScriptAnswer OnScriptAnswer;
803 public event AgentSit OnUndo; 803 public event RequestPayPrice OnRequestPayPrice;
804 804 public event AgentSit OnUndo;
805 #region Scene/Avatar to Client 805
806 806 #region Scene/Avatar to Client
807 /// <summary> 807
808 /// 808 /// <summary>
809 /// </summary> 809 ///
810 /// <param name="regionInfo"></param> 810 /// </summary>
811 public void SendRegionHandshake(RegionInfo regionInfo) 811 /// <param name="regionInfo"></param>
812 { 812 public void SendRegionHandshake(RegionInfo regionInfo)
813 RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake); 813 {
814 814 RegionHandshakePacket handshake = (RegionHandshakePacket)PacketPool.Instance.GetPacket(PacketType.RegionHandshake);
815 bool estatemanager = false; 815
816 LLUUID[] EstateManagers = regionInfo.EstateSettings.estateManagers; 816 bool estatemanager = false;
817 for (int i = 0; i < EstateManagers.Length; i++) 817 LLUUID[] EstateManagers = regionInfo.EstateSettings.estateManagers;
818 { 818 for (int i = 0; i < EstateManagers.Length; i++)
819 if (EstateManagers[i] == AgentId) 819 {
820 estatemanager = true; 820 if (EstateManagers[i] == AgentId)
821 } 821 estatemanager = true;
822 822 }
823 handshake.RegionInfo.BillableFactor = regionInfo.EstateSettings.billableFactor; 823
824 handshake.RegionInfo.IsEstateManager = estatemanager; 824 handshake.RegionInfo.BillableFactor = regionInfo.EstateSettings.billableFactor;
825 handshake.RegionInfo.TerrainHeightRange00 = regionInfo.EstateSettings.terrainHeightRange0; 825 handshake.RegionInfo.IsEstateManager = estatemanager;
826 handshake.RegionInfo.TerrainHeightRange01 = regionInfo.EstateSettings.terrainHeightRange1; 826 handshake.RegionInfo.TerrainHeightRange00 = regionInfo.EstateSettings.terrainHeightRange0;
827 handshake.RegionInfo.TerrainHeightRange10 = regionInfo.EstateSettings.terrainHeightRange2; 827 handshake.RegionInfo.TerrainHeightRange01 = regionInfo.EstateSettings.terrainHeightRange1;
828 handshake.RegionInfo.TerrainHeightRange11 = regionInfo.EstateSettings.terrainHeightRange3; 828 handshake.RegionInfo.TerrainHeightRange10 = regionInfo.EstateSettings.terrainHeightRange2;
829 handshake.RegionInfo.TerrainStartHeight00 = regionInfo.EstateSettings.terrainStartHeight0; 829 handshake.RegionInfo.TerrainHeightRange11 = regionInfo.EstateSettings.terrainHeightRange3;
830 handshake.RegionInfo.TerrainStartHeight01 = regionInfo.EstateSettings.terrainStartHeight1; 830 handshake.RegionInfo.TerrainStartHeight00 = regionInfo.EstateSettings.terrainStartHeight0;
831 handshake.RegionInfo.TerrainStartHeight10 = regionInfo.EstateSettings.terrainStartHeight2; 831 handshake.RegionInfo.TerrainStartHeight01 = regionInfo.EstateSettings.terrainStartHeight1;
832 handshake.RegionInfo.TerrainStartHeight11 = regionInfo.EstateSettings.terrainStartHeight3; 832 handshake.RegionInfo.TerrainStartHeight10 = regionInfo.EstateSettings.terrainStartHeight2;
833 handshake.RegionInfo.SimAccess = (byte)regionInfo.EstateSettings.simAccess; 833 handshake.RegionInfo.TerrainStartHeight11 = regionInfo.EstateSettings.terrainStartHeight3;
834 handshake.RegionInfo.WaterHeight = regionInfo.EstateSettings.waterHeight; 834 handshake.RegionInfo.SimAccess = (byte)regionInfo.EstateSettings.simAccess;
835 835 handshake.RegionInfo.WaterHeight = regionInfo.EstateSettings.waterHeight;
836 handshake.RegionInfo.RegionFlags = (uint)regionInfo.EstateSettings.regionFlags; 836
837 handshake.RegionInfo.SimName = Helpers.StringToField(regionInfo.RegionName); 837 handshake.RegionInfo.RegionFlags = (uint)regionInfo.EstateSettings.regionFlags;
838 handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID; 838 handshake.RegionInfo.SimName = Helpers.StringToField(regionInfo.RegionName);
839 handshake.RegionInfo.TerrainBase0 = regionInfo.EstateSettings.terrainBase0; 839 handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID;
840 handshake.RegionInfo.TerrainBase1 = regionInfo.EstateSettings.terrainBase1; 840 handshake.RegionInfo.TerrainBase0 = regionInfo.EstateSettings.terrainBase0;
841 handshake.RegionInfo.TerrainBase2 = regionInfo.EstateSettings.terrainBase2; 841 handshake.RegionInfo.TerrainBase1 = regionInfo.EstateSettings.terrainBase1;
842 handshake.RegionInfo.TerrainBase3 = regionInfo.EstateSettings.terrainBase3; 842 handshake.RegionInfo.TerrainBase2 = regionInfo.EstateSettings.terrainBase2;
843 handshake.RegionInfo.TerrainDetail0 = regionInfo.EstateSettings.terrainDetail0; 843 handshake.RegionInfo.TerrainBase3 = regionInfo.EstateSettings.terrainBase3;
844 handshake.RegionInfo.TerrainDetail1 = regionInfo.EstateSettings.terrainDetail1; 844 handshake.RegionInfo.TerrainDetail0 = regionInfo.EstateSettings.terrainDetail0;
845 handshake.RegionInfo.TerrainDetail2 = regionInfo.EstateSettings.terrainDetail2; 845 handshake.RegionInfo.TerrainDetail1 = regionInfo.EstateSettings.terrainDetail1;
846 handshake.RegionInfo.TerrainDetail3 = regionInfo.EstateSettings.terrainDetail3; 846 handshake.RegionInfo.TerrainDetail2 = regionInfo.EstateSettings.terrainDetail2;
847 handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting? 847 handshake.RegionInfo.TerrainDetail3 = regionInfo.EstateSettings.terrainDetail3;
848 848 handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting?
849 OutPacket(handshake, ThrottleOutPacketType.Task); 849
850 } 850 OutPacket(handshake, ThrottleOutPacketType.Task);
851 851 }
852 /// <summary> 852
853 /// 853 /// <summary>
854 /// </summary> 854 ///
855 /// <param name="regInfo"></param> 855 /// </summary>
856 public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) 856 /// <param name="regInfo"></param>
857 { 857 public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look)
858 AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete); 858 {
859 mov.SimData.ChannelVersion = m_channelVersion; 859 AgentMovementCompletePacket mov = (AgentMovementCompletePacket)PacketPool.Instance.GetPacket(PacketType.AgentMovementComplete);
860 mov.AgentData.SessionID = m_sessionId; 860 mov.SimData.ChannelVersion = m_channelVersion;
861 mov.AgentData.AgentID = AgentId; 861 mov.AgentData.SessionID = m_sessionId;
862 mov.Data.RegionHandle = regInfo.RegionHandle; 862 mov.AgentData.AgentID = AgentId;
863 mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this 863 mov.Data.RegionHandle = regInfo.RegionHandle;
864 864 mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this
865 if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0)) 865
866 { 866 if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
867 mov.Data.Position = m_startpos; 867 {
868 } 868 mov.Data.Position = m_startpos;
869 else 869 }
870 { 870 else
871 mov.Data.Position = pos; 871 {
872 } 872 mov.Data.Position = pos;
873 mov.Data.LookAt = look; 873 }
874 874 mov.Data.LookAt = look;
875 // Hack to get this out immediately and skip the throttles 875
876 OutPacket(mov, ThrottleOutPacketType.Unknown); 876 // Hack to get this out immediately and skip the throttles
877 } 877 OutPacket(mov, ThrottleOutPacketType.Unknown);
878 878 }
879 /// <summary> 879
880 /// 880 /// <summary>
881 /// </summary> 881 ///
882 /// <param name="message"></param> 882 /// </summary>
883 /// <param name="type"></param> 883 /// <param name="message"></param>
884 /// <param name="fromPos"></param> 884 /// <param name="type"></param>
885 /// <param name="fromName"></param> 885 /// <param name="fromPos"></param>
886 /// <param name="fromAgentID"></param> 886 /// <param name="fromName"></param>
887 public void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) 887 /// <param name="fromAgentID"></param>
888 { 888 public void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
889 SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID); 889 {
890 } 890 SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID);
891 891 }
892 public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) 892
893 { 893 public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
894 ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator); 894 {
895 reply.ChatData.Audible = 1; 895 ChatFromSimulatorPacket reply = (ChatFromSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.ChatFromSimulator);
896 reply.ChatData.Message = message; 896 reply.ChatData.Audible = 1;
897 reply.ChatData.ChatType = type; 897 reply.ChatData.Message = message;
898 reply.ChatData.SourceType = 1; 898 reply.ChatData.ChatType = type;
899 reply.ChatData.Position = fromPos; 899 reply.ChatData.SourceType = 1;
900 reply.ChatData.FromName = Helpers.StringToField(fromName); 900 reply.ChatData.Position = fromPos;
901 reply.ChatData.OwnerID = fromAgentID; 901 reply.ChatData.FromName = Helpers.StringToField(fromName);
902 reply.ChatData.SourceID = fromAgentID; 902 reply.ChatData.OwnerID = fromAgentID;
903 903 reply.ChatData.SourceID = fromAgentID;
904 OutPacket(reply, ThrottleOutPacketType.Task); 904
905 } 905 OutPacket(reply, ThrottleOutPacketType.Task);
906 906 }
907 /// <summary> 907
908 /// Send an instant message to this client 908 /// <summary>
909 /// </summary> 909 /// Send an instant message to this client
910 /// <param name="message"></param> 910 /// </summary>
911 /// <param name="target"></param> 911 /// <param name="message"></param>
912 public void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, 912 /// <param name="target"></param>
913 LLUUID imSessionID, string fromName, byte dialog, uint timeStamp) 913 public void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent,
914 { 914 LLUUID imSessionID, string fromName, byte dialog, uint timeStamp)
915 SendInstantMessage( 915 {
916 fromAgent, fromAgentSession, message, toAgent, 916 SendInstantMessage(
917 imSessionID, fromName, dialog, timeStamp, new byte[0]); 917 fromAgent, fromAgentSession, message, toAgent,
918 } 918 imSessionID, fromName, dialog, timeStamp, new byte[0]);
919 919 }
920 /// <summary> 920
921 /// Send an instant message to this client 921 /// <summary>
922 /// </summary> 922 /// Send an instant message to this client
923 /// <param name="message"></param> 923 /// </summary>
924 /// <param name="target"></param> 924 /// <param name="message"></param>
925 public void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent, 925 /// <param name="target"></param>
926 LLUUID imSessionID, string fromName, byte dialog, uint timeStamp, 926 public void SendInstantMessage(LLUUID fromAgent, LLUUID fromAgentSession, string message, LLUUID toAgent,
927 byte[] binaryBucket) 927 LLUUID imSessionID, string fromName, byte dialog, uint timeStamp,
928 { 928 byte[] binaryBucket)
929 ImprovedInstantMessagePacket msg 929 {
930 = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage); 930 ImprovedInstantMessagePacket msg
931 931 = (ImprovedInstantMessagePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedInstantMessage);
932 msg.AgentData.AgentID = fromAgent; 932
933 msg.AgentData.SessionID = fromAgentSession; 933 msg.AgentData.AgentID = fromAgent;
934 msg.MessageBlock.FromAgentName = Helpers.StringToField(fromName); 934 msg.AgentData.SessionID = fromAgentSession;
935 msg.MessageBlock.Dialog = dialog; 935 msg.MessageBlock.FromAgentName = Helpers.StringToField(fromName);
936 msg.MessageBlock.FromGroup = false; 936 msg.MessageBlock.Dialog = dialog;
937 msg.MessageBlock.ID = imSessionID; 937 msg.MessageBlock.FromGroup = false;
938 msg.MessageBlock.Offline = 0; 938 msg.MessageBlock.ID = imSessionID;
939 msg.MessageBlock.ParentEstateID = 0; 939 msg.MessageBlock.Offline = 0;
940 msg.MessageBlock.Position = new LLVector3(); 940 msg.MessageBlock.ParentEstateID = 0;
941 msg.MessageBlock.RegionID = LLUUID.Random(); 941 msg.MessageBlock.Position = new LLVector3();
942 msg.MessageBlock.Timestamp = timeStamp; 942 msg.MessageBlock.RegionID = LLUUID.Random();
943 msg.MessageBlock.ToAgentID = toAgent; 943 msg.MessageBlock.Timestamp = timeStamp;
944 msg.MessageBlock.Message = Helpers.StringToField(message); 944 msg.MessageBlock.ToAgentID = toAgent;
945 msg.MessageBlock.BinaryBucket = binaryBucket; 945 msg.MessageBlock.Message = Helpers.StringToField(message);
946 946 msg.MessageBlock.BinaryBucket = binaryBucket;
947 OutPacket(msg, ThrottleOutPacketType.Task); 947
948 } 948 OutPacket(msg, ThrottleOutPacketType.Task);
949 949 }
950 /// <summary> 950
951 /// Send the region heightmap to the client 951 /// <summary>
952 /// </summary> 952 /// Send the region heightmap to the client
953 /// <param name="map">heightmap</param> 953 /// </summary>
954 public virtual void SendLayerData(float[] map) 954 /// <param name="map">heightmap</param>
955 { 955 public virtual void SendLayerData(float[] map)
956 try 956 {
957 { 957 try
958 int[] patches = new int[4]; 958 {
959 959 int[] patches = new int[4];
960 for (int y = 0; y < 16; y++) 960
961 { 961 for (int y = 0; y < 16; y++)
962 for (int x = 0; x < 16; x += 4) 962 {
963 { 963 for (int x = 0; x < 16; x += 4)
964 patches[0] = x + 0 + y * 16; 964 {
965 patches[1] = x + 1 + y * 16; 965 patches[0] = x + 0 + y * 16;
966 patches[2] = x + 2 + y * 16; 966 patches[1] = x + 1 + y * 16;
967 patches[3] = x + 3 + y * 16; 967 patches[2] = x + 2 + y * 16;
968 968 patches[3] = x + 3 + y * 16;
969 Packet layerpack = TerrainManager.CreateLandPacket(map, patches); 969
970 OutPacket(layerpack, ThrottleOutPacketType.Land); 970 Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
971 } 971 OutPacket(layerpack, ThrottleOutPacketType.Land);
972 } 972 }
973 } 973 }
974 catch (Exception e) 974 }
975 { 975 catch (Exception e)
976 m_log.Warn("[client]: " + 976 {
977 "ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); 977 m_log.Warn("[client]: " +
978 } 978 "ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString());
979 } 979 }
980 980 }
981 /// <summary> 981
982 /// Sends a specified patch to a client 982 /// <summary>
983 /// </summary> 983 /// Sends a specified patch to a client
984 /// <param name="px">Patch coordinate (x) 0..16</param> 984 /// </summary>
985 /// <param name="py">Patch coordinate (y) 0..16</param> 985 /// <param name="px">Patch coordinate (x) 0..16</param>
986 /// <param name="map">heightmap</param> 986 /// <param name="py">Patch coordinate (y) 0..16</param>
987 public void SendLayerData(int px, int py, float[] map) 987 /// <param name="map">heightmap</param>
988 { 988 public void SendLayerData(int px, int py, float[] map)
989 try 989 {
990 { 990 try
991 int[] patches = new int[1]; 991 {
992 int patchx, patchy; 992 int[] patches = new int[1];
993 patchx = px; 993 int patchx, patchy;
994 patchy = py; 994 patchx = px;
995 995 patchy = py;
996 patches[0] = patchx + 0 + patchy * 16; 996
997 997 patches[0] = patchx + 0 + patchy * 16;
998 Packet layerpack = TerrainManager.CreateLandPacket(map, patches); 998
999 OutPacket(layerpack, ThrottleOutPacketType.Land); 999 Packet layerpack = LLClientView.TerrainManager.CreateLandPacket(map, patches);
1000 } 1000 OutPacket(layerpack, ThrottleOutPacketType.Land);
1001 catch (Exception e) 1001 }
1002 { 1002 catch (Exception e)
1003 m_log.Warn("[client]: " + 1003 {
1004 "ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString()); 1004 m_log.Warn("[client]: " +
1005 } 1005 "ClientView.API.cs: SendLayerData() - Failed with exception " + e.ToString());
1006 } 1006 }
1007 1007 }
1008 /// <summary> 1008
1009 /// 1009 /// <summary>
1010 /// </summary> 1010 ///
1011 /// <param name="neighbourHandle"></param> 1011 /// </summary>
1012 /// <param name="neighbourIP"></param> 1012 /// <param name="neighbourHandle"></param>
1013 /// <param name="neighbourPort"></param> 1013 /// <param name="neighbourIP"></param>
1014 public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint) 1014 /// <param name="neighbourPort"></param>
1015 { 1015 public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
1016 IPAddress neighbourIP = neighbourEndPoint.Address; 1016 {
1017 ushort neighbourPort = (ushort)neighbourEndPoint.Port; 1017 IPAddress neighbourIP = neighbourEndPoint.Address;
1018 1018 ushort neighbourPort = (ushort)neighbourEndPoint.Port;
1019 EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator); 1019
1020 // TODO: don't create new blocks if recycling an old packet 1020 EnableSimulatorPacket enablesimpacket = (EnableSimulatorPacket)PacketPool.Instance.GetPacket(PacketType.EnableSimulator);
1021 enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); 1021 // TODO: don't create new blocks if recycling an old packet
1022 enablesimpacket.SimulatorInfo.Handle = neighbourHandle; 1022 enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
1023 1023 enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
1024 byte[] byteIP = neighbourIP.GetAddressBytes(); 1024
1025 enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24; 1025 byte[] byteIP = neighbourIP.GetAddressBytes();
1026 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16; 1026 enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
1027 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8; 1027 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
1028 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0]; 1028 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
1029 enablesimpacket.SimulatorInfo.Port = neighbourPort; 1029 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
1030 OutPacket(enablesimpacket, ThrottleOutPacketType.Task); 1030 enablesimpacket.SimulatorInfo.Port = neighbourPort;
1031 } 1031 OutPacket(enablesimpacket, ThrottleOutPacketType.Task);
1032 1032 }
1033 /// <summary> 1033
1034 /// 1034 /// <summary>
1035 /// </summary> 1035 ///
1036 /// <returns></returns> 1036 /// </summary>
1037 public AgentCircuitData RequestClientInfo() 1037 /// <returns></returns>
1038 { 1038 public AgentCircuitData RequestClientInfo()
1039 AgentCircuitData agentData = new AgentCircuitData(); 1039 {
1040 agentData.AgentID = AgentId; 1040 AgentCircuitData agentData = new AgentCircuitData();
1041 agentData.SessionID = m_sessionId; 1041 agentData.AgentID = AgentId;
1042 agentData.SecureSessionID = SecureSessionId; 1042 agentData.SessionID = m_sessionId;
1043 agentData.circuitcode = m_circuitCode; 1043 agentData.SecureSessionID = SecureSessionId;
1044 agentData.child = false; 1044 agentData.circuitcode = m_circuitCode;
1045 agentData.firstname = m_firstName; 1045 agentData.child = false;
1046 agentData.lastname = m_lastName; 1046 agentData.firstname = m_firstName;
1047 agentData.CapsPath = m_scene.GetCapsPath(m_agentId); 1047 agentData.lastname = m_lastName;
1048 return agentData; 1048 agentData.CapsPath = m_scene.GetCapsPath(m_agentId);
1049 } 1049 return agentData;
1050 1050 }
1051 public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint, 1051
1052 string capsURL) 1052 public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint,
1053 { 1053 string capsURL)
1054 LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10); 1054 {
1055 1055 LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
1056 //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion); 1056
1057 CrossedRegionPacket newSimPack = new CrossedRegionPacket(); 1057 //CrossedRegionPacket newSimPack = (CrossedRegionPacket)PacketPool.Instance.GetPacket(PacketType.CrossedRegion);
1058 // TODO: don't create new blocks if recycling an old packet 1058 CrossedRegionPacket newSimPack = new CrossedRegionPacket();
1059 newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); 1059 // TODO: don't create new blocks if recycling an old packet
1060 newSimPack.AgentData.AgentID = AgentId; 1060 newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
1061 newSimPack.AgentData.SessionID = m_sessionId; 1061 newSimPack.AgentData.AgentID = AgentId;
1062 newSimPack.Info = new CrossedRegionPacket.InfoBlock(); 1062 newSimPack.AgentData.SessionID = m_sessionId;
1063 newSimPack.Info.Position = pos; 1063 newSimPack.Info = new CrossedRegionPacket.InfoBlock();
1064 newSimPack.Info.LookAt = look; 1064 newSimPack.Info.Position = pos;
1065 newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock(); 1065 newSimPack.Info.LookAt = look;
1066 newSimPack.RegionData.RegionHandle = newRegionHandle; 1066 newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
1067 byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes(); 1067 newSimPack.RegionData.RegionHandle = newRegionHandle;
1068 newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; 1068 byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
1069 newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; 1069 newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
1070 newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; 1070 newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
1071 newSimPack.RegionData.SimIP += (uint)byteIP[0]; 1071 newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
1072 newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port; 1072 newSimPack.RegionData.SimIP += (uint)byteIP[0];
1073 newSimPack.RegionData.SeedCapability = Helpers.StringToField(capsURL); 1073 newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
1074 1074 newSimPack.RegionData.SeedCapability = Helpers.StringToField(capsURL);
1075 // Hack to get this out immediately and skip throttles 1075
1076 OutPacket(newSimPack, ThrottleOutPacketType.Unknown); 1076 // Hack to get this out immediately and skip throttles
1077 } 1077 OutPacket(newSimPack, ThrottleOutPacketType.Unknown);
1078 1078 }
1079 public void SendMapBlock(List<MapBlockData> mapBlocks) 1079
1080 { 1080 public void SendMapBlock(List<MapBlockData> mapBlocks)
1081 MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply); 1081 {
1082 // TODO: don't create new blocks if recycling an old packet 1082 MapBlockReplyPacket mapReply = (MapBlockReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapBlockReply);
1083 mapReply.AgentData.AgentID = AgentId; 1083 // TODO: don't create new blocks if recycling an old packet
1084 mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count]; 1084 mapReply.AgentData.AgentID = AgentId;
1085 mapReply.AgentData.Flags = 0; 1085 mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count];
1086 1086 mapReply.AgentData.Flags = 0;
1087 for (int i = 0; i < mapBlocks.Count; i++) 1087
1088 { 1088 for (int i = 0; i < mapBlocks.Count; i++)
1089 mapReply.Data[i] = new MapBlockReplyPacket.DataBlock(); 1089 {
1090 mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId; 1090 mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
1091 mapReply.Data[i].X = mapBlocks[i].X; 1091 mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId;
1092 mapReply.Data[i].Y = mapBlocks[i].Y; 1092 mapReply.Data[i].X = mapBlocks[i].X;
1093 mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight; 1093 mapReply.Data[i].Y = mapBlocks[i].Y;
1094 mapReply.Data[i].Name = Helpers.StringToField(mapBlocks[i].Name); 1094 mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight;
1095 mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags; 1095 mapReply.Data[i].Name = Helpers.StringToField(mapBlocks[i].Name);
1096 mapReply.Data[i].Access = mapBlocks[i].Access; 1096 mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags;
1097 mapReply.Data[i].Agents = mapBlocks[i].Agents; 1097 mapReply.Data[i].Access = mapBlocks[i].Access;
1098 } 1098 mapReply.Data[i].Agents = mapBlocks[i].Agents;
1099 OutPacket(mapReply, ThrottleOutPacketType.Land); 1099 }
1100 } 1100 OutPacket(mapReply, ThrottleOutPacketType.Land);
1101 1101 }
1102 public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) 1102
1103 { 1103 public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags)
1104 TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal); 1104 {
1105 tpLocal.Info.AgentID = AgentId; 1105 TeleportLocalPacket tpLocal = (TeleportLocalPacket)PacketPool.Instance.GetPacket(PacketType.TeleportLocal);
1106 tpLocal.Info.TeleportFlags = flags; 1106 tpLocal.Info.AgentID = AgentId;
1107 tpLocal.Info.LocationID = 2; 1107 tpLocal.Info.TeleportFlags = flags;
1108 tpLocal.Info.LookAt = lookAt; 1108 tpLocal.Info.LocationID = 2;
1109 tpLocal.Info.Position = position; 1109 tpLocal.Info.LookAt = lookAt;
1110 1110 tpLocal.Info.Position = position;
1111 // Hack to get this out immediately and skip throttles 1111
1112 OutPacket(tpLocal, ThrottleOutPacketType.Unknown); 1112 // Hack to get this out immediately and skip throttles
1113 } 1113 OutPacket(tpLocal, ThrottleOutPacketType.Unknown);
1114 1114 }
1115 public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, 1115
1116 uint flags, string capsURL) 1116 public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID,
1117 { 1117 uint flags, string capsURL)
1118 //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish); 1118 {
1119 1119 //TeleportFinishPacket teleport = (TeleportFinishPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFinish);
1120 TeleportFinishPacket teleport = new TeleportFinishPacket(); 1120
1121 teleport.Info.AgentID = AgentId; 1121 TeleportFinishPacket teleport = new TeleportFinishPacket();
1122 teleport.Info.RegionHandle = regionHandle; 1122 teleport.Info.AgentID = AgentId;
1123 teleport.Info.SimAccess = simAccess; 1123 teleport.Info.RegionHandle = regionHandle;
1124 1124 teleport.Info.SimAccess = simAccess;
1125 teleport.Info.SeedCapability = Helpers.StringToField(capsURL); 1125
1126 1126 teleport.Info.SeedCapability = Helpers.StringToField(capsURL);
1127 IPAddress oIP = newRegionEndPoint.Address; 1127
1128 byte[] byteIP = oIP.GetAddressBytes(); 1128 IPAddress oIP = newRegionEndPoint.Address;
1129 uint ip = (uint)byteIP[3] << 24; 1129 byte[] byteIP = oIP.GetAddressBytes();
1130 ip += (uint)byteIP[2] << 16; 1130 uint ip = (uint)byteIP[3] << 24;
1131 ip += (uint)byteIP[1] << 8; 1131 ip += (uint)byteIP[2] << 16;
1132 ip += (uint)byteIP[0]; 1132 ip += (uint)byteIP[1] << 8;
1133 1133 ip += (uint)byteIP[0];
1134 teleport.Info.SimIP = ip; 1134
1135 teleport.Info.SimPort = (ushort)newRegionEndPoint.Port; 1135 teleport.Info.SimIP = ip;
1136 teleport.Info.LocationID = 4; 1136 teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
1137 teleport.Info.TeleportFlags = 1 << 4; 1137 teleport.Info.LocationID = 4;
1138 1138 teleport.Info.TeleportFlags = 1 << 4;
1139 // Hack to get this out immediately and skip throttles. 1139
1140 OutPacket(teleport, ThrottleOutPacketType.Unknown); 1140 // Hack to get this out immediately and skip throttles.
1141 } 1141 OutPacket(teleport, ThrottleOutPacketType.Unknown);
1142 1142 }
1143 /// <summary> 1143
1144 /// 1144 /// <summary>
1145 /// </summary> 1145 ///
1146 public void SendTeleportFailed(string reason) 1146 /// </summary>
1147 { 1147 public void SendTeleportFailed(string reason)
1148 TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed); 1148 {
1149 tpFailed.Info.AgentID = AgentId; 1149 TeleportFailedPacket tpFailed = (TeleportFailedPacket)PacketPool.Instance.GetPacket(PacketType.TeleportFailed);
1150 tpFailed.Info.Reason = Helpers.StringToField(reason); 1150 tpFailed.Info.AgentID = AgentId;
1151 1151 tpFailed.Info.Reason = Helpers.StringToField(reason);
1152 // Hack to get this out immediately and skip throttles 1152
1153 OutPacket(tpFailed, ThrottleOutPacketType.Unknown); 1153 // Hack to get this out immediately and skip throttles
1154 } 1154 OutPacket(tpFailed, ThrottleOutPacketType.Unknown);
1155 1155 }
1156 /// <summary> 1156
1157 /// 1157 /// <summary>
1158 /// </summary> 1158 ///
1159 public void SendTeleportLocationStart() 1159 /// </summary>
1160 { 1160 public void SendTeleportLocationStart()
1161 //TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart); 1161 {
1162 TeleportStartPacket tpStart = new TeleportStartPacket(); 1162 //TeleportStartPacket tpStart = (TeleportStartPacket)PacketPool.Instance.GetPacket(PacketType.TeleportStart);
1163 tpStart.Info.TeleportFlags = 16; // Teleport via location 1163 TeleportStartPacket tpStart = new TeleportStartPacket();
1164 1164 tpStart.Info.TeleportFlags = 16; // Teleport via location
1165 // Hack to get this out immediately and skip throttles 1165
1166 OutPacket(tpStart, ThrottleOutPacketType.Unknown); 1166 // Hack to get this out immediately and skip throttles
1167 } 1167 OutPacket(tpStart, ThrottleOutPacketType.Unknown);
1168 1168 }
1169 public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) 1169
1170 { 1170 public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance)
1171 MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply); 1171 {
1172 money.MoneyData.AgentID = AgentId; 1172 MoneyBalanceReplyPacket money = (MoneyBalanceReplyPacket)PacketPool.Instance.GetPacket(PacketType.MoneyBalanceReply);
1173 money.MoneyData.TransactionID = transaction; 1173 money.MoneyData.AgentID = AgentId;
1174 money.MoneyData.TransactionSuccess = success; 1174 money.MoneyData.TransactionID = transaction;
1175 money.MoneyData.Description = description; 1175 money.MoneyData.TransactionSuccess = success;
1176 money.MoneyData.MoneyBalance = balance; 1176 money.MoneyData.Description = description;
1177 OutPacket(money, ThrottleOutPacketType.Task); 1177 money.MoneyData.MoneyBalance = balance;
1178 } 1178 OutPacket(money, ThrottleOutPacketType.Task);
1179 1179 }
1180 public void SendPayPrice(LLUUID objectID, int[] payPrice) 1180
1181 { 1181 public void SendPayPrice(LLUUID objectID, int[] payPrice)
1182 if(payPrice[0] == 0 && 1182 {
1183 payPrice[1] == 0 && 1183 if(payPrice[0] == 0 &&
1184 payPrice[2] == 0 && 1184 payPrice[1] == 0 &&
1185 payPrice[3] == 0 && 1185 payPrice[2] == 0 &&
1186 payPrice[4] == 0) 1186 payPrice[3] == 0 &&
1187 return; 1187 payPrice[4] == 0)
1188 1188 return;
1189 PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply); 1189
1190 payPriceReply.ObjectData.ObjectID = objectID; 1190 PayPriceReplyPacket payPriceReply = (PayPriceReplyPacket)PacketPool.Instance.GetPacket(PacketType.PayPriceReply);
1191 payPriceReply.ObjectData.DefaultPayPrice = payPrice[0]; 1191 payPriceReply.ObjectData.ObjectID = objectID;
1192 1192 payPriceReply.ObjectData.DefaultPayPrice = payPrice[0];
1193 payPriceReply.ButtonData=new PayPriceReplyPacket.ButtonDataBlock[4]; 1193
1194 payPriceReply.ButtonData[0]=new PayPriceReplyPacket.ButtonDataBlock(); 1194 payPriceReply.ButtonData=new PayPriceReplyPacket.ButtonDataBlock[4];
1195 payPriceReply.ButtonData[0].PayButton = payPrice[1]; 1195 payPriceReply.ButtonData[0]=new PayPriceReplyPacket.ButtonDataBlock();
1196 payPriceReply.ButtonData[1]=new PayPriceReplyPacket.ButtonDataBlock(); 1196 payPriceReply.ButtonData[0].PayButton = payPrice[1];
1197 payPriceReply.ButtonData[1].PayButton = payPrice[2]; 1197 payPriceReply.ButtonData[1]=new PayPriceReplyPacket.ButtonDataBlock();
1198 payPriceReply.ButtonData[2]=new PayPriceReplyPacket.ButtonDataBlock(); 1198 payPriceReply.ButtonData[1].PayButton = payPrice[2];
1199 payPriceReply.ButtonData[2].PayButton = payPrice[3]; 1199 payPriceReply.ButtonData[2]=new PayPriceReplyPacket.ButtonDataBlock();
1200 payPriceReply.ButtonData[3]=new PayPriceReplyPacket.ButtonDataBlock(); 1200 payPriceReply.ButtonData[2].PayButton = payPrice[3];
1201 payPriceReply.ButtonData[3].PayButton = payPrice[4]; 1201 payPriceReply.ButtonData[3]=new PayPriceReplyPacket.ButtonDataBlock();
1202 1202 payPriceReply.ButtonData[3].PayButton = payPrice[4];
1203 OutPacket(payPriceReply, ThrottleOutPacketType.Task); 1203
1204 } 1204 OutPacket(payPriceReply, ThrottleOutPacketType.Task);
1205 1205 }
1206 public void SendStartPingCheck(byte seq) 1206
1207 { 1207 public void SendStartPingCheck(byte seq)
1208 StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck); 1208 {
1209 pc.PingID.PingID = seq; 1209 StartPingCheckPacket pc = (StartPingCheckPacket)PacketPool.Instance.GetPacket(PacketType.StartPingCheck);
1210 pc.Header.Reliable = false; 1210 pc.PingID.PingID = seq;
1211 OutPacket(pc, ThrottleOutPacketType.Unknown); 1211 pc.Header.Reliable = false;
1212 } 1212 OutPacket(pc, ThrottleOutPacketType.Unknown);
1213 1213 }
1214 public void SendKillObject(ulong regionHandle, uint localID) 1214
1215 { 1215 public void SendKillObject(ulong regionHandle, uint localID)
1216 KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject); 1216 {
1217 // TODO: don't create new blocks if recycling an old packet 1217 KillObjectPacket kill = (KillObjectPacket)PacketPool.Instance.GetPacket(PacketType.KillObject);
1218 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; 1218 // TODO: don't create new blocks if recycling an old packet
1219 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); 1219 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
1220 kill.ObjectData[0].ID = localID; 1220 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
1221 kill.Header.Reliable = false; 1221 kill.ObjectData[0].ID = localID;
1222 OutPacket(kill, ThrottleOutPacketType.Task); 1222 kill.Header.Reliable = false;
1223 } 1223 OutPacket(kill, ThrottleOutPacketType.Task);
1224 1224 }
1225 /// <summary> 1225
1226 /// Send information about the items contained in a folder to the client. 1226 /// <summary>
1227 /// 1227 /// Send information about the items contained in a folder to the client.
1228 /// XXX This method needs some refactoring loving 1228 ///
1229 /// </summary> 1229 /// XXX This method needs some refactoring loving
1230 /// <param name="ownerID">The owner of the folder</param> 1230 /// </summary>
1231 /// <param name="folderID">The id of the folder</param> 1231 /// <param name="ownerID">The owner of the folder</param>
1232 /// <param name="items">The items contained in the folder identified by folderID</param> 1232 /// <param name="folderID">The id of the folder</param>
1233 /// <param name="fetchFolders">Do we need to send folder information?</param> 1233 /// <param name="items">The items contained in the folder identified by folderID</param>
1234 /// <param name="fetchItems">Do we need to send item information?</param> 1234 /// <param name="fetchFolders">Do we need to send folder information?</param>
1235 public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items, 1235 /// <param name="fetchItems">Do we need to send item information?</param>
1236 List<InventoryFolderBase> folders, 1236 public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items,
1237 bool fetchFolders, bool fetchItems) 1237 List<InventoryFolderBase> folders,
1238 { 1238 bool fetchFolders, bool fetchItems)
1239 // An inventory descendents packet consists of a single agent section and an inventory details 1239 {
1240 // section for each inventory item. The size of each inventory item is approximately 550 bytes. 1240 // An inventory descendents packet consists of a single agent section and an inventory details
1241 // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent 1241 // section for each inventory item. The size of each inventory item is approximately 550 bytes.
1242 // packets containing metadata for in excess of 100 items. But in practice, there may be other 1242 // In theory, UDP has a maximum packet size of 64k, so it should be possible to send descendent
1243 // factors (e.g. firewalls) restraining the maximum UDP packet size. See, 1243 // packets containing metadata for in excess of 100 items. But in practice, there may be other
1244 // 1244 // factors (e.g. firewalls) restraining the maximum UDP packet size. See,
1245 // http://opensimulator.org/mantis/view.php?id=226 1245 //
1246 // 1246 // http://opensimulator.org/mantis/view.php?id=226
1247 // for one example of this kind of thing. In fact, the Linden servers appear to only send about 1247 //
1248 // 6 to 7 items at a time, so let's stick with 6 1248 // for one example of this kind of thing. In fact, the Linden servers appear to only send about
1249 int MAX_ITEMS_PER_PACKET = 6; 1249 // 6 to 7 items at a time, so let's stick with 6
1250 1250 int MAX_ITEMS_PER_PACKET = 6;
1251//Ckrinke This variable is not used, so comment out to remove the warning from the compiler (3-21-08) 1251
1252//Ckrinke uint FULL_MASK_PERMISSIONS = 2147483647; 1252//Ckrinke This variable is not used, so comment out to remove the warning from the compiler (3-21-08)
1253 1253//Ckrinke uint FULL_MASK_PERMISSIONS = 2147483647;
1254 if (fetchItems) 1254
1255 { 1255 if (fetchItems)
1256 InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); 1256 {
1257 1257 InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID);
1258 if (items.Count < MAX_ITEMS_PER_PACKET) 1258
1259 { 1259 if (items.Count < MAX_ITEMS_PER_PACKET)
1260 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; 1260 {
1261 descend.AgentData.Descendents = items.Count; 1261 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count];
1262 } 1262 descend.AgentData.Descendents = items.Count;
1263 else 1263 }
1264 { 1264 else
1265 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET]; 1265 {
1266 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; 1266 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET];
1267 } 1267 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET;
1268 1268 }
1269 // Even if we aren't fetching the folders, we still need to include the folder count 1269
1270 // in the total number of descendents. Failure to do so will cause subtle bugs such 1270 // Even if we aren't fetching the folders, we still need to include the folder count
1271 // as the failure of textures which haven't been expanded in inventory to show up 1271 // in the total number of descendents. Failure to do so will cause subtle bugs such
1272 // in the texture prim edit selection panel. 1272 // as the failure of textures which haven't been expanded in inventory to show up
1273 if (!fetchFolders) 1273 // in the texture prim edit selection panel.
1274 { 1274 if (!fetchFolders)
1275 descend.AgentData.Descendents += folders.Count; 1275 {
1276 } 1276 descend.AgentData.Descendents += folders.Count;
1277 1277 }
1278 int count = 0; 1278
1279 int i = 0; 1279 int count = 0;
1280 foreach (InventoryItemBase item in items) 1280 int i = 0;
1281 { 1281 foreach (InventoryItemBase item in items)
1282 descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); 1282 {
1283 descend.ItemData[i].ItemID = item.ID; 1283 descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock();
1284 descend.ItemData[i].AssetID = item.AssetID; 1284 descend.ItemData[i].ItemID = item.ID;
1285 descend.ItemData[i].CreatorID = item.Creator; 1285 descend.ItemData[i].AssetID = item.AssetID;
1286 descend.ItemData[i].BaseMask = item.BasePermissions; 1286 descend.ItemData[i].CreatorID = item.Creator;
1287 descend.ItemData[i].Description = Helpers.StringToField(item.Description); 1287 descend.ItemData[i].BaseMask = item.BasePermissions;
1288 descend.ItemData[i].EveryoneMask = item.EveryOnePermissions; 1288 descend.ItemData[i].Description = Helpers.StringToField(item.Description);
1289 descend.ItemData[i].OwnerMask = item.CurrentPermissions; 1289 descend.ItemData[i].EveryoneMask = item.EveryOnePermissions;
1290 descend.ItemData[i].FolderID = item.Folder; 1290 descend.ItemData[i].OwnerMask = item.CurrentPermissions;
1291 descend.ItemData[i].InvType = (sbyte)item.InvType; 1291 descend.ItemData[i].FolderID = item.Folder;
1292 descend.ItemData[i].Name = Helpers.StringToField(item.Name); 1292 descend.ItemData[i].InvType = (sbyte)item.InvType;
1293 descend.ItemData[i].NextOwnerMask = item.NextPermissions; 1293 descend.ItemData[i].Name = Helpers.StringToField(item.Name);
1294 descend.ItemData[i].OwnerID = item.Owner; 1294 descend.ItemData[i].NextOwnerMask = item.NextPermissions;
1295 descend.ItemData[i].Type = (sbyte)item.AssetType; 1295 descend.ItemData[i].OwnerID = item.Owner;
1296 1296 descend.ItemData[i].Type = (sbyte)item.AssetType;
1297 //descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); 1297
1298 descend.ItemData[i].GroupID = item.GroupID; 1298 //descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
1299 descend.ItemData[i].GroupOwned = item.GroupOwned; 1299 descend.ItemData[i].GroupID = item.GroupID;
1300 descend.ItemData[i].GroupMask = 0; 1300 descend.ItemData[i].GroupOwned = item.GroupOwned;
1301 descend.ItemData[i].CreationDate = item.CreationDate; 1301 descend.ItemData[i].GroupMask = 0;
1302 descend.ItemData[i].SalePrice = item.SalePrice; 1302 descend.ItemData[i].CreationDate = item.CreationDate;
1303 descend.ItemData[i].SaleType = item.SaleType; 1303 descend.ItemData[i].SalePrice = item.SalePrice;
1304 descend.ItemData[i].Flags = item.Flags; 1304 descend.ItemData[i].SaleType = item.SaleType;
1305 1305 descend.ItemData[i].Flags = item.Flags;
1306 descend.ItemData[i].CRC = 1306
1307 Helpers.InventoryCRC(descend.ItemData[i].CreationDate, descend.ItemData[i].SaleType, 1307 descend.ItemData[i].CRC =
1308 descend.ItemData[i].InvType, descend.ItemData[i].Type, 1308 Helpers.InventoryCRC(descend.ItemData[i].CreationDate, descend.ItemData[i].SaleType,
1309 descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, 1309 descend.ItemData[i].InvType, descend.ItemData[i].Type,
1310 descend.ItemData[i].SalePrice, 1310 descend.ItemData[i].AssetID, descend.ItemData[i].GroupID,
1311 descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, 1311 descend.ItemData[i].SalePrice,
1312 descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, 1312 descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID,
1313 descend.ItemData[i].EveryoneMask, 1313 descend.ItemData[i].ItemID, descend.ItemData[i].FolderID,
1314 descend.ItemData[i].Flags, descend.ItemData[i].OwnerMask, 1314 descend.ItemData[i].EveryoneMask,
1315 descend.ItemData[i].GroupMask, item.CurrentPermissions); 1315 descend.ItemData[i].Flags, descend.ItemData[i].OwnerMask,
1316 1316 descend.ItemData[i].GroupMask, item.CurrentPermissions);
1317 i++; 1317
1318 count++; 1318 i++;
1319 if (i == MAX_ITEMS_PER_PACKET) 1319 count++;
1320 { 1320 if (i == MAX_ITEMS_PER_PACKET)
1321 OutPacket(descend, ThrottleOutPacketType.Asset); 1321 {
1322 1322 OutPacket(descend, ThrottleOutPacketType.Asset);
1323 if ((items.Count - count) > 0) 1323
1324 { 1324 if ((items.Count - count) > 0)
1325 descend = CreateInventoryDescendentsPacket(ownerID, folderID); 1325 {
1326 if ((items.Count - count) < MAX_ITEMS_PER_PACKET) 1326 descend = CreateInventoryDescendentsPacket(ownerID, folderID);
1327 { 1327 if ((items.Count - count) < MAX_ITEMS_PER_PACKET)
1328 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count - count]; 1328 {
1329 descend.AgentData.Descendents = items.Count - count; 1329 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count - count];
1330 } 1330 descend.AgentData.Descendents = items.Count - count;
1331 else 1331 }
1332 { 1332 else
1333 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET]; 1333 {
1334 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; 1334 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[MAX_ITEMS_PER_PACKET];
1335 } 1335 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET;
1336 i = 0; 1336 }
1337 } 1337 i = 0;
1338 } 1338 }
1339 } 1339 }
1340 1340 }
1341 if (i < MAX_ITEMS_PER_PACKET) 1341
1342 { 1342 if (i < MAX_ITEMS_PER_PACKET)
1343 OutPacket(descend, ThrottleOutPacketType.Asset); 1343 {
1344 } 1344 OutPacket(descend, ThrottleOutPacketType.Asset);
1345 } 1345 }
1346 1346 }
1347 //send subfolders 1347
1348 if (fetchFolders) 1348 //send subfolders
1349 { 1349 if (fetchFolders)
1350 InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID); 1350 {
1351 1351 InventoryDescendentsPacket descend = CreateInventoryDescendentsPacket(ownerID, folderID);
1352 if (folders.Count < MAX_ITEMS_PER_PACKET) 1352
1353 { 1353 if (folders.Count < MAX_ITEMS_PER_PACKET)
1354 descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count]; 1354 {
1355 descend.AgentData.Descendents = folders.Count; 1355 descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[folders.Count];
1356 } 1356 descend.AgentData.Descendents = folders.Count;
1357 else 1357 }
1358 { 1358 else
1359 descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; 1359 {
1360 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; 1360 descend.FolderData = new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET];
1361 } 1361 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET;
1362 1362 }
1363 // Not sure if this scenario ever actually occurs, but nonetheless we include the items 1363
1364 // count even if we're not sending item data for the same reasons as above. 1364 // Not sure if this scenario ever actually occurs, but nonetheless we include the items
1365 if (!fetchItems) 1365 // count even if we're not sending item data for the same reasons as above.
1366 { 1366 if (!fetchItems)
1367 descend.AgentData.Descendents += items.Count; 1367 {
1368 } 1368 descend.AgentData.Descendents += items.Count;
1369 1369 }
1370 int i = 0; 1370
1371 int count = 0; 1371 int i = 0;
1372 foreach (InventoryFolderBase folder in folders) 1372 int count = 0;
1373 { 1373 foreach (InventoryFolderBase folder in folders)
1374 descend.FolderData[i] = new InventoryDescendentsPacket.FolderDataBlock(); 1374 {
1375 descend.FolderData[i].FolderID = folder.ID; 1375 descend.FolderData[i] = new InventoryDescendentsPacket.FolderDataBlock();
1376 descend.FolderData[i].Name = Helpers.StringToField(folder.Name); 1376 descend.FolderData[i].FolderID = folder.ID;
1377 descend.FolderData[i].ParentID = folder.ParentID; 1377 descend.FolderData[i].Name = Helpers.StringToField(folder.Name);
1378 descend.FolderData[i].Type = (sbyte) folder.Type; 1378 descend.FolderData[i].ParentID = folder.ParentID;
1379 1379 descend.FolderData[i].Type = (sbyte) folder.Type;
1380 i++; 1380
1381 count++; 1381 i++;
1382 if (i == MAX_ITEMS_PER_PACKET) 1382 count++;
1383 { 1383 if (i == MAX_ITEMS_PER_PACKET)
1384 OutPacket(descend, ThrottleOutPacketType.Asset); 1384 {
1385 1385 OutPacket(descend, ThrottleOutPacketType.Asset);
1386 if ((folders.Count - count) > 0) 1386
1387 { 1387 if ((folders.Count - count) > 0)
1388 descend = CreateInventoryDescendentsPacket(ownerID, folderID); 1388 {
1389 if ((folders.Count - count) < MAX_ITEMS_PER_PACKET) 1389 descend = CreateInventoryDescendentsPacket(ownerID, folderID);
1390 { 1390 if ((folders.Count - count) < MAX_ITEMS_PER_PACKET)
1391 descend.FolderData = 1391 {
1392 new InventoryDescendentsPacket.FolderDataBlock[folders.Count - count]; 1392 descend.FolderData =
1393 descend.AgentData.Descendents = folders.Count - count; 1393 new InventoryDescendentsPacket.FolderDataBlock[folders.Count - count];
1394 } 1394 descend.AgentData.Descendents = folders.Count - count;
1395 else 1395 }
1396 { 1396 else
1397 descend.FolderData = 1397 {
1398 new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET]; 1398 descend.FolderData =
1399 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET; 1399 new InventoryDescendentsPacket.FolderDataBlock[MAX_ITEMS_PER_PACKET];
1400 } 1400 descend.AgentData.Descendents = MAX_ITEMS_PER_PACKET;
1401 i = 0; 1401 }
1402 } 1402 i = 0;
1403 } 1403 }
1404 } 1404 }
1405 1405 }
1406 if (i < MAX_ITEMS_PER_PACKET) 1406
1407 { 1407 if (i < MAX_ITEMS_PER_PACKET)
1408 OutPacket(descend, ThrottleOutPacketType.Asset); 1408 {
1409 } 1409 OutPacket(descend, ThrottleOutPacketType.Asset);
1410 } 1410 }
1411 } 1411 }
1412 1412 }
1413 private InventoryDescendentsPacket CreateInventoryDescendentsPacket(LLUUID ownerID, LLUUID folderID) 1413
1414 { 1414 private InventoryDescendentsPacket CreateInventoryDescendentsPacket(LLUUID ownerID, LLUUID folderID)
1415 InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents); 1415 {
1416 descend.AgentData.AgentID = AgentId; 1416 InventoryDescendentsPacket descend = (InventoryDescendentsPacket)PacketPool.Instance.GetPacket(PacketType.InventoryDescendents);
1417 descend.AgentData.OwnerID = ownerID; 1417 descend.AgentData.AgentID = AgentId;
1418 descend.AgentData.FolderID = folderID; 1418 descend.AgentData.OwnerID = ownerID;
1419 descend.AgentData.Version = 1; 1419 descend.AgentData.FolderID = folderID;
1420 1420 descend.AgentData.Version = 1;
1421 return descend; 1421
1422 } 1422 return descend;
1423 1423 }
1424 public void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item) 1424
1425 { 1425 public void SendInventoryItemDetails(LLUUID ownerID, InventoryItemBase item)
1426 uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All; 1426 {
1427 FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply); 1427 uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
1428 // TODO: don't create new blocks if recycling an old packet 1428 FetchInventoryReplyPacket inventoryReply = (FetchInventoryReplyPacket)PacketPool.Instance.GetPacket(PacketType.FetchInventoryReply);
1429 inventoryReply.AgentData.AgentID = AgentId; 1429 // TODO: don't create new blocks if recycling an old packet
1430 inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; 1430 inventoryReply.AgentData.AgentID = AgentId;
1431 inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); 1431 inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
1432 inventoryReply.InventoryData[0].ItemID = item.ID; 1432 inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
1433 inventoryReply.InventoryData[0].AssetID = item.AssetID; 1433 inventoryReply.InventoryData[0].ItemID = item.ID;
1434 inventoryReply.InventoryData[0].CreatorID = item.Creator; 1434 inventoryReply.InventoryData[0].AssetID = item.AssetID;
1435 inventoryReply.InventoryData[0].BaseMask = item.BasePermissions; 1435 inventoryReply.InventoryData[0].CreatorID = item.Creator;
1436 inventoryReply.InventoryData[0].CreationDate = 1436 inventoryReply.InventoryData[0].BaseMask = item.BasePermissions;
1437 (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; 1437 inventoryReply.InventoryData[0].CreationDate =
1438 inventoryReply.InventoryData[0].Description = Helpers.StringToField(item.Description); 1438 (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
1439 inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions; 1439 inventoryReply.InventoryData[0].Description = Helpers.StringToField(item.Description);
1440 inventoryReply.InventoryData[0].FolderID = item.Folder; 1440 inventoryReply.InventoryData[0].EveryoneMask = item.EveryOnePermissions;
1441 inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType; 1441 inventoryReply.InventoryData[0].FolderID = item.Folder;
1442 inventoryReply.InventoryData[0].Name = Helpers.StringToField(item.Name); 1442 inventoryReply.InventoryData[0].InvType = (sbyte)item.InvType;
1443 inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions; 1443 inventoryReply.InventoryData[0].Name = Helpers.StringToField(item.Name);
1444 inventoryReply.InventoryData[0].OwnerID = item.Owner; 1444 inventoryReply.InventoryData[0].NextOwnerMask = item.NextPermissions;
1445 inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions; 1445 inventoryReply.InventoryData[0].OwnerID = item.Owner;
1446 inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType; 1446 inventoryReply.InventoryData[0].OwnerMask = item.CurrentPermissions;
1447 1447 inventoryReply.InventoryData[0].Type = (sbyte)item.AssetType;
1448 //inventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); 1448
1449 inventoryReply.InventoryData[0].GroupID = item.GroupID; 1449 //inventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
1450 inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned; 1450 inventoryReply.InventoryData[0].GroupID = item.GroupID;
1451 inventoryReply.InventoryData[0].GroupMask = 0; 1451 inventoryReply.InventoryData[0].GroupOwned = item.GroupOwned;
1452 inventoryReply.InventoryData[0].Flags = item.Flags; 1452 inventoryReply.InventoryData[0].GroupMask = 0;
1453 inventoryReply.InventoryData[0].SalePrice = item.SalePrice; 1453 inventoryReply.InventoryData[0].Flags = item.Flags;
1454 inventoryReply.InventoryData[0].SaleType = item.SaleType; 1454 inventoryReply.InventoryData[0].SalePrice = item.SalePrice;
1455 1455 inventoryReply.InventoryData[0].SaleType = item.SaleType;
1456 inventoryReply.InventoryData[0].CRC = 1456
1457 Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType, 1457 inventoryReply.InventoryData[0].CRC =
1458 inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID, 1458 Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType,
1459 inventoryReply.InventoryData[0].GroupID, 100, 1459 inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID,
1460 inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID, 1460 inventoryReply.InventoryData[0].GroupID, 100,
1461 inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID, 1461 inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID,
1462 FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, 1462 inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID,
1463 FULL_MASK_PERMISSIONS); 1463 FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
1464 1464 FULL_MASK_PERMISSIONS);
1465 OutPacket(inventoryReply, ThrottleOutPacketType.Asset); 1465
1466 } 1466 OutPacket(inventoryReply, ThrottleOutPacketType.Asset);
1467 1467 }
1468 /// <see>IClientAPI.SendBulkUpdateInventory(InventoryItemBase)</see> 1468
1469 public void SendBulkUpdateInventory(InventoryItemBase item) 1469 /// <see>IClientAPI.SendBulkUpdateInventory(InventoryItemBase)</see>
1470 { 1470 public void SendBulkUpdateInventory(InventoryItemBase item)
1471 uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All; 1471 {
1472 1472 uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
1473 BulkUpdateInventoryPacket bulkUpdate 1473
1474 = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory); 1474 BulkUpdateInventoryPacket bulkUpdate
1475 1475 = (BulkUpdateInventoryPacket)PacketPool.Instance.GetPacket(PacketType.BulkUpdateInventory);
1476 bulkUpdate.AgentData.AgentID = AgentId; 1476
1477 bulkUpdate.AgentData.TransactionID = LLUUID.Random(); 1477 bulkUpdate.AgentData.AgentID = AgentId;
1478 1478 bulkUpdate.AgentData.TransactionID = LLUUID.Random();
1479 bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1]; 1479
1480 bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock(); 1480 bulkUpdate.FolderData = new BulkUpdateInventoryPacket.FolderDataBlock[1];
1481 bulkUpdate.FolderData[0].FolderID = LLUUID.Zero; 1481 bulkUpdate.FolderData[0] = new BulkUpdateInventoryPacket.FolderDataBlock();
1482 bulkUpdate.FolderData[0].ParentID = LLUUID.Zero; 1482 bulkUpdate.FolderData[0].FolderID = LLUUID.Zero;
1483 bulkUpdate.FolderData[0].Type = -1; 1483 bulkUpdate.FolderData[0].ParentID = LLUUID.Zero;
1484 bulkUpdate.FolderData[0].Name = new byte[0]; 1484 bulkUpdate.FolderData[0].Type = -1;
1485 1485 bulkUpdate.FolderData[0].Name = new byte[0];
1486 bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1]; 1486
1487 bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock(); 1487 bulkUpdate.ItemData = new BulkUpdateInventoryPacket.ItemDataBlock[1];
1488 bulkUpdate.ItemData[0].ItemID = item.ID; 1488 bulkUpdate.ItemData[0] = new BulkUpdateInventoryPacket.ItemDataBlock();
1489 bulkUpdate.ItemData[0].AssetID = item.AssetID; 1489 bulkUpdate.ItemData[0].ItemID = item.ID;
1490 bulkUpdate.ItemData[0].CreatorID = item.Creator; 1490 bulkUpdate.ItemData[0].AssetID = item.AssetID;
1491 bulkUpdate.ItemData[0].BaseMask = item.BasePermissions; 1491 bulkUpdate.ItemData[0].CreatorID = item.Creator;
1492 bulkUpdate.ItemData[0].CreationDate = 1000; 1492 bulkUpdate.ItemData[0].BaseMask = item.BasePermissions;
1493 bulkUpdate.ItemData[0].Description = Helpers.StringToField(item.Description); 1493 bulkUpdate.ItemData[0].CreationDate = 1000;
1494 bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions; 1494 bulkUpdate.ItemData[0].Description = Helpers.StringToField(item.Description);
1495 bulkUpdate.ItemData[0].FolderID = item.Folder; 1495 bulkUpdate.ItemData[0].EveryoneMask = item.EveryOnePermissions;
1496 bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType; 1496 bulkUpdate.ItemData[0].FolderID = item.Folder;
1497 bulkUpdate.ItemData[0].Name = Helpers.StringToField(item.Name); 1497 bulkUpdate.ItemData[0].InvType = (sbyte)item.InvType;
1498 bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions; 1498 bulkUpdate.ItemData[0].Name = Helpers.StringToField(item.Name);
1499 bulkUpdate.ItemData[0].OwnerID = item.Owner; 1499 bulkUpdate.ItemData[0].NextOwnerMask = item.NextPermissions;
1500 bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions; 1500 bulkUpdate.ItemData[0].OwnerID = item.Owner;
1501 bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType; 1501 bulkUpdate.ItemData[0].OwnerMask = item.CurrentPermissions;
1502 1502 bulkUpdate.ItemData[0].Type = (sbyte)item.AssetType;
1503 //bulkUpdate.ItemData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); 1503
1504 bulkUpdate.ItemData[0].GroupID = item.GroupID; 1504 //bulkUpdate.ItemData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
1505 bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned; 1505 bulkUpdate.ItemData[0].GroupID = item.GroupID;
1506 bulkUpdate.ItemData[0].GroupMask = 0; 1506 bulkUpdate.ItemData[0].GroupOwned = item.GroupOwned;
1507 bulkUpdate.ItemData[0].Flags = item.Flags; 1507 bulkUpdate.ItemData[0].GroupMask = 0;
1508 bulkUpdate.ItemData[0].SalePrice = item.SalePrice; 1508 bulkUpdate.ItemData[0].Flags = item.Flags;
1509 bulkUpdate.ItemData[0].SaleType = item.SaleType; 1509 bulkUpdate.ItemData[0].SalePrice = item.SalePrice;
1510 1510 bulkUpdate.ItemData[0].SaleType = item.SaleType;
1511 bulkUpdate.ItemData[0].CRC = 1511
1512 Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType, 1512 bulkUpdate.ItemData[0].CRC =
1513 bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID, 1513 Helpers.InventoryCRC(1000, 0, bulkUpdate.ItemData[0].InvType,
1514 bulkUpdate.ItemData[0].GroupID, 100, 1514 bulkUpdate.ItemData[0].Type, bulkUpdate.ItemData[0].AssetID,
1515 bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID, 1515 bulkUpdate.ItemData[0].GroupID, 100,
1516 bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID, 1516 bulkUpdate.ItemData[0].OwnerID, bulkUpdate.ItemData[0].CreatorID,
1517 FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, 1517 bulkUpdate.ItemData[0].ItemID, bulkUpdate.ItemData[0].FolderID,
1518 FULL_MASK_PERMISSIONS); 1518 FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
1519 1519 FULL_MASK_PERMISSIONS);
1520 OutPacket(bulkUpdate, ThrottleOutPacketType.Asset); 1520
1521 } 1521 OutPacket(bulkUpdate, ThrottleOutPacketType.Asset);
1522 1522 }
1523 /// <see>IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)</see> 1523
1524 public void SendInventoryItemCreateUpdate(InventoryItemBase Item) 1524 /// <see>IClientAPI.SendInventoryItemCreateUpdate(InventoryItemBase)</see>
1525 { 1525 public void SendInventoryItemCreateUpdate(InventoryItemBase Item)
1526 uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All; 1526 {
1527 1527 uint FULL_MASK_PERMISSIONS = (uint)PermissionMask.All;
1528 UpdateCreateInventoryItemPacket InventoryReply 1528
1529 = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket( 1529 UpdateCreateInventoryItemPacket InventoryReply
1530 PacketType.UpdateCreateInventoryItem); 1530 = (UpdateCreateInventoryItemPacket)PacketPool.Instance.GetPacket(
1531 1531 PacketType.UpdateCreateInventoryItem);
1532 // TODO: don't create new blocks if recycling an old packet 1532
1533 InventoryReply.AgentData.AgentID = AgentId; 1533 // TODO: don't create new blocks if recycling an old packet
1534 InventoryReply.AgentData.SimApproved = true; 1534 InventoryReply.AgentData.AgentID = AgentId;
1535 InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1]; 1535 InventoryReply.AgentData.SimApproved = true;
1536 InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock(); 1536 InventoryReply.InventoryData = new UpdateCreateInventoryItemPacket.InventoryDataBlock[1];
1537 InventoryReply.InventoryData[0].ItemID = Item.ID; 1537 InventoryReply.InventoryData[0] = new UpdateCreateInventoryItemPacket.InventoryDataBlock();
1538 InventoryReply.InventoryData[0].AssetID = Item.AssetID; 1538 InventoryReply.InventoryData[0].ItemID = Item.ID;
1539 InventoryReply.InventoryData[0].CreatorID = Item.Creator; 1539 InventoryReply.InventoryData[0].AssetID = Item.AssetID;
1540 InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions; 1540 InventoryReply.InventoryData[0].CreatorID = Item.Creator;
1541 InventoryReply.InventoryData[0].Description = Helpers.StringToField(Item.Description); 1541 InventoryReply.InventoryData[0].BaseMask = Item.BasePermissions;
1542 InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions; 1542 InventoryReply.InventoryData[0].Description = Helpers.StringToField(Item.Description);
1543 InventoryReply.InventoryData[0].FolderID = Item.Folder; 1543 InventoryReply.InventoryData[0].EveryoneMask = Item.EveryOnePermissions;
1544 InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType; 1544 InventoryReply.InventoryData[0].FolderID = Item.Folder;
1545 InventoryReply.InventoryData[0].Name = Helpers.StringToField(Item.Name); 1545 InventoryReply.InventoryData[0].InvType = (sbyte)Item.InvType;
1546 InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions; 1546 InventoryReply.InventoryData[0].Name = Helpers.StringToField(Item.Name);
1547 InventoryReply.InventoryData[0].OwnerID = Item.Owner; 1547 InventoryReply.InventoryData[0].NextOwnerMask = Item.NextPermissions;
1548 InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions; 1548 InventoryReply.InventoryData[0].OwnerID = Item.Owner;
1549 InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType; 1549 InventoryReply.InventoryData[0].OwnerMask = Item.CurrentPermissions;
1550 1550 InventoryReply.InventoryData[0].Type = (sbyte)Item.AssetType;
1551 //InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); 1551
1552 InventoryReply.InventoryData[0].GroupID = Item.GroupID; 1552 //InventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
1553 InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned; 1553 InventoryReply.InventoryData[0].GroupID = Item.GroupID;
1554 InventoryReply.InventoryData[0].GroupMask = 0; 1554 InventoryReply.InventoryData[0].GroupOwned = Item.GroupOwned;
1555 InventoryReply.InventoryData[0].Flags = Item.Flags; 1555 InventoryReply.InventoryData[0].GroupMask = 0;
1556 InventoryReply.InventoryData[0].SalePrice = Item.SalePrice; 1556 InventoryReply.InventoryData[0].Flags = Item.Flags;
1557 InventoryReply.InventoryData[0].SaleType = Item.SaleType; 1557 InventoryReply.InventoryData[0].SalePrice = Item.SalePrice;
1558 1558 InventoryReply.InventoryData[0].SaleType = Item.SaleType;
1559 InventoryReply.InventoryData[0].CRC = 1559
1560 Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType, 1560 InventoryReply.InventoryData[0].CRC =
1561 InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID, 1561 Helpers.InventoryCRC(1000, 0, InventoryReply.InventoryData[0].InvType,
1562 InventoryReply.InventoryData[0].GroupID, 100, 1562 InventoryReply.InventoryData[0].Type, InventoryReply.InventoryData[0].AssetID,
1563 InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID, 1563 InventoryReply.InventoryData[0].GroupID, 100,
1564 InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID, 1564 InventoryReply.InventoryData[0].OwnerID, InventoryReply.InventoryData[0].CreatorID,
1565 FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, 1565 InventoryReply.InventoryData[0].ItemID, InventoryReply.InventoryData[0].FolderID,
1566 FULL_MASK_PERMISSIONS); 1566 FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS,
1567 1567 FULL_MASK_PERMISSIONS);
1568 OutPacket(InventoryReply, ThrottleOutPacketType.Asset); 1568
1569 } 1569 OutPacket(InventoryReply, ThrottleOutPacketType.Asset);
1570 1570 }
1571 public void SendRemoveInventoryItem(LLUUID itemID) 1571
1572 { 1572 public void SendRemoveInventoryItem(LLUUID itemID)
1573 RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem); 1573 {
1574 // TODO: don't create new blocks if recycling an old packet 1574 RemoveInventoryItemPacket remove = (RemoveInventoryItemPacket)PacketPool.Instance.GetPacket(PacketType.RemoveInventoryItem);
1575 remove.AgentData.AgentID = AgentId; 1575 // TODO: don't create new blocks if recycling an old packet
1576 remove.AgentData.SessionID = m_sessionId; 1576 remove.AgentData.AgentID = AgentId;
1577 remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1]; 1577 remove.AgentData.SessionID = m_sessionId;
1578 remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock(); 1578 remove.InventoryData = new RemoveInventoryItemPacket.InventoryDataBlock[1];
1579 remove.InventoryData[0].ItemID = itemID; 1579 remove.InventoryData[0] = new RemoveInventoryItemPacket.InventoryDataBlock();
1580 1580 remove.InventoryData[0].ItemID = itemID;
1581 OutPacket(remove, ThrottleOutPacketType.Asset); 1581
1582 } 1582 OutPacket(remove, ThrottleOutPacketType.Asset);
1583 1583 }
1584 public void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName) 1584
1585 { 1585 public void SendTaskInventory(LLUUID taskID, short serial, byte[] fileName)
1586 ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory); 1586 {
1587 replytask.InventoryData.TaskID = taskID; 1587 ReplyTaskInventoryPacket replytask = (ReplyTaskInventoryPacket)PacketPool.Instance.GetPacket(PacketType.ReplyTaskInventory);
1588 replytask.InventoryData.Serial = serial; 1588 replytask.InventoryData.TaskID = taskID;
1589 replytask.InventoryData.Filename = fileName; 1589 replytask.InventoryData.Serial = serial;
1590 OutPacket(replytask, ThrottleOutPacketType.Asset); 1590 replytask.InventoryData.Filename = fileName;
1591 } 1591 OutPacket(replytask, ThrottleOutPacketType.Asset);
1592 1592 }
1593 public void SendXferPacket(ulong xferID, uint packet, byte[] data) 1593
1594 { 1594 public void SendXferPacket(ulong xferID, uint packet, byte[] data)
1595 SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket); 1595 {
1596 sendXfer.XferID.ID = xferID; 1596 SendXferPacketPacket sendXfer = (SendXferPacketPacket)PacketPool.Instance.GetPacket(PacketType.SendXferPacket);
1597 sendXfer.XferID.Packet = packet; 1597 sendXfer.XferID.ID = xferID;
1598 sendXfer.DataPacket.Data = data; 1598 sendXfer.XferID.Packet = packet;
1599 OutPacket(sendXfer, ThrottleOutPacketType.Task); 1599 sendXfer.DataPacket.Data = data;
1600 } 1600 OutPacket(sendXfer, ThrottleOutPacketType.Task);
1601 1601 }
1602 public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, 1602
1603 int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, 1603 public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit,
1604 int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay, 1604 int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor,
1605 int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent) 1605 int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay,
1606 { 1606 int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
1607 EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData); 1607 {
1608 economyData.Info.EnergyEfficiency = EnergyEfficiency; 1608 EconomyDataPacket economyData = (EconomyDataPacket)PacketPool.Instance.GetPacket(PacketType.EconomyData);
1609 economyData.Info.ObjectCapacity = ObjectCapacity; 1609 economyData.Info.EnergyEfficiency = EnergyEfficiency;
1610 economyData.Info.ObjectCount = ObjectCount; 1610 economyData.Info.ObjectCapacity = ObjectCapacity;
1611 economyData.Info.PriceEnergyUnit = PriceEnergyUnit; 1611 economyData.Info.ObjectCount = ObjectCount;
1612 economyData.Info.PriceGroupCreate = PriceGroupCreate; 1612 economyData.Info.PriceEnergyUnit = PriceEnergyUnit;
1613 economyData.Info.PriceObjectClaim = PriceObjectClaim; 1613 economyData.Info.PriceGroupCreate = PriceGroupCreate;
1614 economyData.Info.PriceObjectRent = PriceObjectRent; 1614 economyData.Info.PriceObjectClaim = PriceObjectClaim;
1615 economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor; 1615 economyData.Info.PriceObjectRent = PriceObjectRent;
1616 economyData.Info.PriceParcelClaim = PriceParcelClaim; 1616 economyData.Info.PriceObjectScaleFactor = PriceObjectScaleFactor;
1617 economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor; 1617 economyData.Info.PriceParcelClaim = PriceParcelClaim;
1618 economyData.Info.PriceParcelRent = PriceParcelRent; 1618 economyData.Info.PriceParcelClaimFactor = PriceParcelClaimFactor;
1619 economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay; 1619 economyData.Info.PriceParcelRent = PriceParcelRent;
1620 economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete; 1620 economyData.Info.PricePublicObjectDecay = PricePublicObjectDecay;
1621 economyData.Info.PriceRentLight = PriceRentLight; 1621 economyData.Info.PricePublicObjectDelete = PricePublicObjectDelete;
1622 economyData.Info.PriceUpload = PriceUpload; 1622 economyData.Info.PriceRentLight = PriceRentLight;
1623 economyData.Info.TeleportMinPrice = TeleportMinPrice; 1623 economyData.Info.PriceUpload = PriceUpload;
1624 economyData.Info.TeleportPriceExponent = TeleportPriceExponent; 1624 economyData.Info.TeleportMinPrice = TeleportMinPrice;
1625 economyData.Header.Reliable = true; 1625 economyData.Info.TeleportPriceExponent = TeleportPriceExponent;
1626 OutPacket(economyData, ThrottleOutPacketType.Unknown); 1626 economyData.Header.Reliable = true;
1627 1627 OutPacket(economyData, ThrottleOutPacketType.Unknown);
1628 } 1628
1629 1629 }
1630 public void SendAvatarPickerReply(AvatarPickerReplyPacket replyPacket) 1630
1631 { 1631 public void SendAvatarPickerReply(AvatarPickerReplyPacket replyPacket)
1632 OutPacket(replyPacket, ThrottleOutPacketType.Task); 1632 {
1633 } 1633 OutPacket(replyPacket, ThrottleOutPacketType.Task);
1634 1634 }
1635 public void SendAgentDataUpdate(LLUUID agentid, LLUUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle) 1635
1636 { 1636 public void SendAgentDataUpdate(LLUUID agentid, LLUUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
1637 AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate); 1637 {
1638 sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid; 1638 AgentDataUpdatePacket sendAgentDataUpdate = (AgentDataUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentDataUpdate);
1639 sendAgentDataUpdate.AgentData.AgentID = agentid; 1639 sendAgentDataUpdate.AgentData.ActiveGroupID = activegroupid;
1640 sendAgentDataUpdate.AgentData.FirstName = Helpers.StringToField(firstname); 1640 sendAgentDataUpdate.AgentData.AgentID = agentid;
1641 sendAgentDataUpdate.AgentData.GroupName = Helpers.StringToField(groupname); 1641 sendAgentDataUpdate.AgentData.FirstName = Helpers.StringToField(firstname);
1642 sendAgentDataUpdate.AgentData.GroupPowers = grouppowers; 1642 sendAgentDataUpdate.AgentData.GroupName = Helpers.StringToField(groupname);
1643 sendAgentDataUpdate.AgentData.GroupTitle = Helpers.StringToField(grouptitle); 1643 sendAgentDataUpdate.AgentData.GroupPowers = grouppowers;
1644 sendAgentDataUpdate.AgentData.LastName = Helpers.StringToField(lastname); 1644 sendAgentDataUpdate.AgentData.GroupTitle = Helpers.StringToField(grouptitle);
1645 OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task); 1645 sendAgentDataUpdate.AgentData.LastName = Helpers.StringToField(lastname);
1646 } 1646 OutPacket(sendAgentDataUpdate, ThrottleOutPacketType.Task);
1647 1647 }
1648 /// <summary> 1648
1649 /// Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief duration 1649 /// <summary>
1650 /// blue information box in the bottom right hand corner. 1650 /// Send an alert message to the client. On the Linden client (tested 1.19.1.4), this pops up a brief duration
1651 /// </summary> 1651 /// blue information box in the bottom right hand corner.
1652 /// <param name="message"></param> 1652 /// </summary>
1653 public void SendAlertMessage(string message) 1653 /// <param name="message"></param>
1654 { 1654 public void SendAlertMessage(string message)
1655 AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage); 1655 {
1656 alertPack.AlertData.Message = Helpers.StringToField(message); 1656 AlertMessagePacket alertPack = (AlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AlertMessage);
1657 OutPacket(alertPack, ThrottleOutPacketType.Task); 1657 alertPack.AlertData.Message = Helpers.StringToField(message);
1658 } 1658 OutPacket(alertPack, ThrottleOutPacketType.Task);
1659 1659 }
1660 /// <summary> 1660
1661 /// Send an agent alert message to the client. 1661 /// <summary>
1662 /// </summary> 1662 /// Send an agent alert message to the client.
1663 /// <param name="message"></param> 1663 /// </summary>
1664 /// <param name="modal">On the linden client, if this true then it displays a one button text box placed in the 1664 /// <param name="message"></param>
1665 /// middle of the window. If false, the message is displayed in a brief duration blue information box (as for 1665 /// <param name="modal">On the linden client, if this true then it displays a one button text box placed in the
1666 /// the AlertMessage packet).</param> 1666 /// middle of the window. If false, the message is displayed in a brief duration blue information box (as for
1667 public void SendAgentAlertMessage(string message, bool modal) 1667 /// the AlertMessage packet).</param>
1668 { 1668 public void SendAgentAlertMessage(string message, bool modal)
1669 AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage); 1669 {
1670 alertPack.AgentData.AgentID = AgentId; 1670 AgentAlertMessagePacket alertPack = (AgentAlertMessagePacket)PacketPool.Instance.GetPacket(PacketType.AgentAlertMessage);
1671 alertPack.AlertData.Message = Helpers.StringToField(message); 1671 alertPack.AgentData.AgentID = AgentId;
1672 alertPack.AlertData.Modal = modal; 1672 alertPack.AlertData.Message = Helpers.StringToField(message);
1673 OutPacket(alertPack, ThrottleOutPacketType.Task); 1673 alertPack.AlertData.Modal = modal;
1674 } 1674 OutPacket(alertPack, ThrottleOutPacketType.Task);
1675 1675 }
1676 public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message, 1676
1677 string url) 1677 public void SendLoadURL(string objectname, LLUUID objectID, LLUUID ownerID, bool groupOwned, string message,
1678 { 1678 string url)
1679 LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL); 1679 {
1680 loadURL.Data.ObjectName = Helpers.StringToField(objectname); 1680 LoadURLPacket loadURL = (LoadURLPacket)PacketPool.Instance.GetPacket(PacketType.LoadURL);
1681 loadURL.Data.ObjectID = objectID; 1681 loadURL.Data.ObjectName = Helpers.StringToField(objectname);
1682 loadURL.Data.OwnerID = ownerID; 1682 loadURL.Data.ObjectID = objectID;
1683 loadURL.Data.OwnerIsGroup = groupOwned; 1683 loadURL.Data.OwnerID = ownerID;
1684 loadURL.Data.Message = Helpers.StringToField(message); 1684 loadURL.Data.OwnerIsGroup = groupOwned;
1685 loadURL.Data.URL = Helpers.StringToField(url); 1685 loadURL.Data.Message = Helpers.StringToField(message);
1686 OutPacket(loadURL, ThrottleOutPacketType.Task); 1686 loadURL.Data.URL = Helpers.StringToField(url);
1687 } 1687 OutPacket(loadURL, ThrottleOutPacketType.Task);
1688 1688 }
1689 public void SendDialog(string objectname, LLUUID objectID, LLUUID ownerID, string msg, LLUUID textureID, int ch, string[] buttonlabels) 1689
1690 { 1690 public void SendDialog(string objectname, LLUUID objectID, LLUUID ownerID, string msg, LLUUID textureID, int ch, string[] buttonlabels)
1691 ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog); 1691 {
1692 dialog.Data.ObjectID = objectID; 1692 ScriptDialogPacket dialog = (ScriptDialogPacket)PacketPool.Instance.GetPacket(PacketType.ScriptDialog);
1693 dialog.Data.ObjectName = Helpers.StringToField(objectname); 1693 dialog.Data.ObjectID = objectID;
1694 dialog.Data.FirstName = Helpers.StringToField(this.FirstName); 1694 dialog.Data.ObjectName = Helpers.StringToField(objectname);
1695 dialog.Data.LastName = Helpers.StringToField(this.LastName); 1695 dialog.Data.FirstName = Helpers.StringToField(this.FirstName);
1696 dialog.Data.Message = Helpers.StringToField(msg); 1696 dialog.Data.LastName = Helpers.StringToField(this.LastName);
1697 dialog.Data.ImageID = textureID; 1697 dialog.Data.Message = Helpers.StringToField(msg);
1698 dialog.Data.ChatChannel = ch; 1698 dialog.Data.ImageID = textureID;
1699 ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length]; 1699 dialog.Data.ChatChannel = ch;
1700 for (int i = 0; i < buttonlabels.Length; i++) 1700 ScriptDialogPacket.ButtonsBlock[] buttons = new ScriptDialogPacket.ButtonsBlock[buttonlabels.Length];
1701 { 1701 for (int i = 0; i < buttonlabels.Length; i++)
1702 buttons[i] = new ScriptDialogPacket.ButtonsBlock(); 1702 {
1703 buttons[i].ButtonLabel = Helpers.StringToField(buttonlabels[i]); 1703 buttons[i] = new ScriptDialogPacket.ButtonsBlock();
1704 } 1704 buttons[i].ButtonLabel = Helpers.StringToField(buttonlabels[i]);
1705 dialog.Buttons = buttons; 1705 }
1706 OutPacket(dialog, ThrottleOutPacketType.Task); 1706 dialog.Buttons = buttons;
1707 } 1707 OutPacket(dialog, ThrottleOutPacketType.Task);
1708 1708 }
1709 public void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID) 1709
1710 { 1710 public void SendPreLoadSound(LLUUID objectID, LLUUID ownerID, LLUUID soundID)
1711 PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound); 1711 {
1712 // TODO: don't create new blocks if recycling an old packet 1712 PreloadSoundPacket preSound = (PreloadSoundPacket)PacketPool.Instance.GetPacket(PacketType.PreloadSound);
1713 preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1]; 1713 // TODO: don't create new blocks if recycling an old packet
1714 preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock(); 1714 preSound.DataBlock = new PreloadSoundPacket.DataBlockBlock[1];
1715 preSound.DataBlock[0].ObjectID = objectID; 1715 preSound.DataBlock[0] = new PreloadSoundPacket.DataBlockBlock();
1716 preSound.DataBlock[0].OwnerID = ownerID; 1716 preSound.DataBlock[0].ObjectID = objectID;
1717 preSound.DataBlock[0].SoundID = soundID; 1717 preSound.DataBlock[0].OwnerID = ownerID;
1718 OutPacket(preSound, ThrottleOutPacketType.Task); 1718 preSound.DataBlock[0].SoundID = soundID;
1719 } 1719 OutPacket(preSound, ThrottleOutPacketType.Task);
1720 1720 }
1721 public void SendPlayAttachedSound(LLUUID soundID, LLUUID objectID, LLUUID ownerID, float gain, byte flags) 1721
1722 { 1722 public void SendPlayAttachedSound(LLUUID soundID, LLUUID objectID, LLUUID ownerID, float gain, byte flags)
1723 AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound); 1723 {
1724 sound.DataBlock.SoundID = soundID; 1724 AttachedSoundPacket sound = (AttachedSoundPacket)PacketPool.Instance.GetPacket(PacketType.AttachedSound);
1725 sound.DataBlock.ObjectID = objectID; 1725 sound.DataBlock.SoundID = soundID;
1726 sound.DataBlock.OwnerID = ownerID; 1726 sound.DataBlock.ObjectID = objectID;
1727 sound.DataBlock.Gain = gain; 1727 sound.DataBlock.OwnerID = ownerID;
1728 sound.DataBlock.Flags = flags; 1728 sound.DataBlock.Gain = gain;
1729 1729 sound.DataBlock.Flags = flags;
1730 OutPacket(sound, ThrottleOutPacketType.Task); 1730
1731 } 1731 OutPacket(sound, ThrottleOutPacketType.Task);
1732 1732 }
1733 public void SendTriggeredSound(LLUUID soundID, LLUUID ownerID, LLUUID objectID, LLUUID parentID, ulong handle, LLVector3 position, float gain) 1733
1734 { 1734 public void SendTriggeredSound(LLUUID soundID, LLUUID ownerID, LLUUID objectID, LLUUID parentID, ulong handle, LLVector3 position, float gain)
1735 SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger); 1735 {
1736 sound.SoundData.SoundID = soundID; 1736 SoundTriggerPacket sound = (SoundTriggerPacket)PacketPool.Instance.GetPacket(PacketType.SoundTrigger);
1737 sound.SoundData.OwnerID = ownerID; 1737 sound.SoundData.SoundID = soundID;
1738 sound.SoundData.ObjectID = objectID; 1738 sound.SoundData.OwnerID = ownerID;
1739 sound.SoundData.ParentID = parentID; 1739 sound.SoundData.ObjectID = objectID;
1740 sound.SoundData.Handle = handle; 1740 sound.SoundData.ParentID = parentID;
1741 sound.SoundData.Position = position; 1741 sound.SoundData.Handle = handle;
1742 sound.SoundData.Gain = gain; 1742 sound.SoundData.Position = position;
1743 1743 sound.SoundData.Gain = gain;
1744 OutPacket(sound, ThrottleOutPacketType.Task); 1744
1745 } 1745 OutPacket(sound, ThrottleOutPacketType.Task);
1746 1746 }
1747 public void SendAttachedSoundGainChange(LLUUID objectID, float gain) 1747
1748 { 1748 public void SendAttachedSoundGainChange(LLUUID objectID, float gain)
1749 AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange); 1749 {
1750 sound.DataBlock.ObjectID = objectID; 1750 AttachedSoundGainChangePacket sound = (AttachedSoundGainChangePacket)PacketPool.Instance.GetPacket(PacketType.AttachedSoundGainChange);
1751 sound.DataBlock.Gain = gain; 1751 sound.DataBlock.ObjectID = objectID;
1752 1752 sound.DataBlock.Gain = gain;
1753 OutPacket(sound, ThrottleOutPacketType.Task); 1753
1754 } 1754 OutPacket(sound, ThrottleOutPacketType.Task);
1755 1755 }
1756 public void SendSunPos(LLVector3 sunPos, LLVector3 sunVel) 1756
1757 { 1757 public void SendSunPos(LLVector3 sunPos, LLVector3 sunVel)
1758 SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage); 1758 {
1759 viewertime.TimeInfo.SunDirection = sunPos; 1759 SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
1760 viewertime.TimeInfo.SunAngVelocity = sunVel; 1760 viewertime.TimeInfo.SunDirection = sunPos;
1761 viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch(); 1761 viewertime.TimeInfo.SunAngVelocity = sunVel;
1762 viewertime.Header.Reliable = false; 1762 viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
1763 OutPacket(viewertime, ThrottleOutPacketType.Task); 1763 viewertime.Header.Reliable = false;
1764 } 1764 OutPacket(viewertime, ThrottleOutPacketType.Task);
1765 1765 }
1766 public void SendViewerTime(int phase) 1766
1767 { 1767 public void SendViewerTime(int phase)
1768 Console.WriteLine("SunPhase: {0}", phase); 1768 {
1769 SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage); 1769 Console.WriteLine("SunPhase: {0}", phase);
1770 //viewertime.TimeInfo.SecPerDay = 86400; 1770 SimulatorViewerTimeMessagePacket viewertime = (SimulatorViewerTimeMessagePacket)PacketPool.Instance.GetPacket(PacketType.SimulatorViewerTimeMessage);
1771 //viewertime.TimeInfo.SecPerYear = 31536000; 1771 //viewertime.TimeInfo.SecPerDay = 86400;
1772 viewertime.TimeInfo.SecPerDay = 1000; 1772 //viewertime.TimeInfo.SecPerYear = 31536000;
1773 viewertime.TimeInfo.SecPerYear = 365000; 1773 viewertime.TimeInfo.SecPerDay = 1000;
1774 viewertime.TimeInfo.SunPhase = 1; 1774 viewertime.TimeInfo.SecPerYear = 365000;
1775 int sunPhase = (phase + 2) / 2; 1775 viewertime.TimeInfo.SunPhase = 1;
1776 if ((sunPhase < 6) || (sunPhase > 36)) 1776 int sunPhase = (phase + 2) / 2;
1777 { 1777 if ((sunPhase < 6) || (sunPhase > 36))
1778 viewertime.TimeInfo.SunDirection = new LLVector3(0f, 0.8f, -0.8f); 1778 {
1779 Console.WriteLine("sending night"); 1779 viewertime.TimeInfo.SunDirection = new LLVector3(0f, 0.8f, -0.8f);
1780 } 1780 Console.WriteLine("sending night");
1781 else 1781 }
1782 { 1782 else
1783 if (sunPhase < 12) 1783 {
1784 { 1784 if (sunPhase < 12)
1785 sunPhase = 12; 1785 {
1786 } 1786 sunPhase = 12;
1787 sunPhase = sunPhase - 12; 1787 }
1788 1788 sunPhase = sunPhase - 12;
1789 float yValue = 0.1f * (sunPhase); 1789
1790 Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue); 1790 float yValue = 0.1f * (sunPhase);
1791 if (yValue > 1.2f) 1791 Console.WriteLine("Computed SunPhase: {0}, yValue: {1}", sunPhase, yValue);
1792 { 1792 if (yValue > 1.2f)
1793 yValue = yValue - 1.2f; 1793 {
1794 } 1794 yValue = yValue - 1.2f;
1795 1795 }
1796 yValue = Util.Clip(yValue, 0, 1); 1796
1797 1797 yValue = Util.Clip(yValue, 0, 1);
1798 if (sunPhase < 14) 1798
1799 { 1799 if (sunPhase < 14)
1800 yValue = 1 - yValue; 1800 {
1801 } 1801 yValue = 1 - yValue;
1802 if (sunPhase < 12) 1802 }
1803 { 1803 if (sunPhase < 12)
1804 yValue *= -1; 1804 {
1805 } 1805 yValue *= -1;
1806 viewertime.TimeInfo.SunDirection = new LLVector3(0f, yValue, 0.3f); 1806 }
1807 Console.WriteLine("sending sun update " + yValue); 1807 viewertime.TimeInfo.SunDirection = new LLVector3(0f, yValue, 0.3f);
1808 } 1808 Console.WriteLine("sending sun update " + yValue);
1809 viewertime.TimeInfo.SunAngVelocity = new LLVector3(0, 0.0f, 10.0f); 1809 }
1810 viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch(); 1810 viewertime.TimeInfo.SunAngVelocity = new LLVector3(0, 0.0f, 10.0f);
1811 viewertime.Header.Reliable = false; 1811 viewertime.TimeInfo.UsecSinceStart = (ulong)Util.UnixTimeSinceEpoch();
1812 OutPacket(viewertime, ThrottleOutPacketType.Task); 1812 viewertime.Header.Reliable = false;
1813 } 1813 OutPacket(viewertime, ThrottleOutPacketType.Task);
1814 1814 }
1815 public void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember, 1815
1816 string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL, 1816 public void SendAvatarProperties(LLUUID avatarID, string aboutText, string bornOn, string charterMember,
1817 LLUUID partnerID) 1817 string flAbout, uint flags, LLUUID flImageID, LLUUID imageID, string profileURL,
1818 { 1818 LLUUID partnerID)
1819 AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply); 1819 {
1820 avatarReply.AgentData.AgentID = AgentId; 1820 AvatarPropertiesReplyPacket avatarReply = (AvatarPropertiesReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPropertiesReply);
1821 avatarReply.AgentData.AvatarID = avatarID; 1821 avatarReply.AgentData.AgentID = AgentId;
1822 if (aboutText != null) 1822 avatarReply.AgentData.AvatarID = avatarID;
1823 avatarReply.PropertiesData.AboutText = Helpers.StringToField(aboutText); 1823 if (aboutText != null)
1824 else 1824 avatarReply.PropertiesData.AboutText = Helpers.StringToField(aboutText);
1825 avatarReply.PropertiesData.AboutText = Helpers.StringToField(""); 1825 else
1826 avatarReply.PropertiesData.BornOn = Helpers.StringToField(bornOn); 1826 avatarReply.PropertiesData.AboutText = Helpers.StringToField("");
1827 avatarReply.PropertiesData.CharterMember = Helpers.StringToField(charterMember); 1827 avatarReply.PropertiesData.BornOn = Helpers.StringToField(bornOn);
1828 if (flAbout != null) 1828 avatarReply.PropertiesData.CharterMember = Helpers.StringToField(charterMember);
1829 avatarReply.PropertiesData.FLAboutText = Helpers.StringToField(flAbout); 1829 if (flAbout != null)
1830 else 1830 avatarReply.PropertiesData.FLAboutText = Helpers.StringToField(flAbout);
1831 avatarReply.PropertiesData.FLAboutText = Helpers.StringToField(""); 1831 else
1832 avatarReply.PropertiesData.Flags = 0; 1832 avatarReply.PropertiesData.FLAboutText = Helpers.StringToField("");
1833 avatarReply.PropertiesData.FLImageID = flImageID; 1833 avatarReply.PropertiesData.Flags = 0;
1834 avatarReply.PropertiesData.ImageID = imageID; 1834 avatarReply.PropertiesData.FLImageID = flImageID;
1835 avatarReply.PropertiesData.ProfileURL = Helpers.StringToField(profileURL); 1835 avatarReply.PropertiesData.ImageID = imageID;
1836 avatarReply.PropertiesData.PartnerID = partnerID; 1836 avatarReply.PropertiesData.ProfileURL = Helpers.StringToField(profileURL);
1837 OutPacket(avatarReply, ThrottleOutPacketType.Task); 1837 avatarReply.PropertiesData.PartnerID = partnerID;
1838 } 1838 OutPacket(avatarReply, ThrottleOutPacketType.Task);
1839 1839 }
1840 #endregion 1840
1841 1841 #endregion
1842 #region Appearance/ Wearables Methods 1842
1843 1843 #region Appearance/ Wearables Methods
1844 /// <summary> 1844
1845 /// 1845 /// <summary>
1846 /// </summary> 1846 ///
1847 /// <param name="wearables"></param> 1847 /// </summary>
1848 public void SendWearables(AvatarWearable[] wearables, int serial) 1848 /// <param name="wearables"></param>
1849 { 1849 public void SendWearables(AvatarWearable[] wearables, int serial)
1850 AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate); 1850 {
1851 aw.AgentData.AgentID = AgentId; 1851 AgentWearablesUpdatePacket aw = (AgentWearablesUpdatePacket)PacketPool.Instance.GetPacket(PacketType.AgentWearablesUpdate);
1852 aw.AgentData.SerialNum = (uint)serial; 1852 aw.AgentData.AgentID = AgentId;
1853 aw.AgentData.SessionID = m_sessionId; 1853 aw.AgentData.SerialNum = (uint)serial;
1854 1854 aw.AgentData.SessionID = m_sessionId;
1855 // TODO: don't create new blocks if recycling an old packet 1855
1856 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; 1856 // TODO: don't create new blocks if recycling an old packet
1857 AgentWearablesUpdatePacket.WearableDataBlock awb; 1857 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
1858 for (int i = 0; i < wearables.Length; i++) 1858 AgentWearablesUpdatePacket.WearableDataBlock awb;
1859 { 1859 for (int i = 0; i < wearables.Length; i++)
1860 awb = new AgentWearablesUpdatePacket.WearableDataBlock(); 1860 {
1861 awb.WearableType = (byte)i; 1861 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
1862 awb.AssetID = wearables[i].AssetID; 1862 awb.WearableType = (byte)i;
1863 awb.ItemID = wearables[i].ItemID; 1863 awb.AssetID = wearables[i].AssetID;
1864 aw.WearableData[i] = awb; 1864 awb.ItemID = wearables[i].ItemID;
1865 } 1865 aw.WearableData[i] = awb;
1866 1866 }
1867 OutPacket(aw, ThrottleOutPacketType.Task); 1867
1868 } 1868 OutPacket(aw, ThrottleOutPacketType.Task);
1869 1869 }
1870 /// <summary> 1870
1871 /// 1871 /// <summary>
1872 /// </summary> 1872 ///
1873 /// <param name="agentID"></param> 1873 /// </summary>
1874 /// <param name="visualParams"></param> 1874 /// <param name="agentID"></param>
1875 /// <param name="textureEntry"></param> 1875 /// <param name="visualParams"></param>
1876 public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry) 1876 /// <param name="textureEntry"></param>
1877 { 1877 public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry)
1878 AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance); 1878 {
1879 // TODO: don't create new blocks if recycling an old packet 1879 AvatarAppearancePacket avp = (AvatarAppearancePacket)PacketPool.Instance.GetPacket(PacketType.AvatarAppearance);
1880 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; 1880 // TODO: don't create new blocks if recycling an old packet
1881 avp.ObjectData.TextureEntry = textureEntry; 1881 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
1882 1882 avp.ObjectData.TextureEntry = textureEntry;
1883 AvatarAppearancePacket.VisualParamBlock avblock = null; 1883
1884 for (int i = 0; i < visualParams.Length; i++) 1884 AvatarAppearancePacket.VisualParamBlock avblock = null;
1885 { 1885 for (int i = 0; i < visualParams.Length; i++)
1886 avblock = new AvatarAppearancePacket.VisualParamBlock(); 1886 {
1887 avblock.ParamValue = visualParams[i]; 1887 avblock = new AvatarAppearancePacket.VisualParamBlock();
1888 avp.VisualParam[i] = avblock; 1888 avblock.ParamValue = visualParams[i];
1889 } 1889 avp.VisualParam[i] = avblock;
1890 1890 }
1891 avp.Sender.IsTrial = false; 1891
1892 avp.Sender.ID = agentID; 1892 avp.Sender.IsTrial = false;
1893 OutPacket(avp, ThrottleOutPacketType.Task); 1893 avp.Sender.ID = agentID;
1894 } 1894 OutPacket(avp, ThrottleOutPacketType.Task);
1895 1895 }
1896 public void SendAnimations(LLUUID[] animations, int[] seqs, LLUUID sourceAgentId) 1896
1897 { 1897 public void SendAnimations(LLUUID[] animations, int[] seqs, LLUUID sourceAgentId)
1898 AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation); 1898 {
1899 // TODO: don't create new blocks if recycling an old packet 1899 AvatarAnimationPacket ani = (AvatarAnimationPacket)PacketPool.Instance.GetPacket(PacketType.AvatarAnimation);
1900 ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; 1900 // TODO: don't create new blocks if recycling an old packet
1901 ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); 1901 ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
1902 ani.AnimationSourceList[0].ObjectID = sourceAgentId; 1902 ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
1903 ani.Sender = new AvatarAnimationPacket.SenderBlock(); 1903 ani.AnimationSourceList[0].ObjectID = sourceAgentId;
1904 ani.Sender.ID = sourceAgentId; 1904 ani.Sender = new AvatarAnimationPacket.SenderBlock();
1905 ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length]; 1905 ani.Sender.ID = sourceAgentId;
1906 1906 ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[animations.Length];
1907 for (int i = 0; i < animations.Length; ++i) 1907
1908 { 1908 for (int i = 0; i < animations.Length; ++i)
1909 ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock(); 1909 {
1910 ani.AnimationList[i].AnimID = animations[i]; 1910 ani.AnimationList[i] = new AvatarAnimationPacket.AnimationListBlock();
1911 ani.AnimationList[i].AnimSequenceID = seqs[i]; 1911 ani.AnimationList[i].AnimID = animations[i];
1912 } 1912 ani.AnimationList[i].AnimSequenceID = seqs[i];
1913 ani.Header.Reliable = false; 1913 }
1914 OutPacket(ani, ThrottleOutPacketType.Task); 1914 ani.Header.Reliable = false;
1915 } 1915 OutPacket(ani, ThrottleOutPacketType.Task);
1916 1916 }
1917 #endregion 1917
1918 1918 #endregion
1919 #region Avatar Packet/data sending Methods 1919
1920 1920 #region Avatar Packet/data sending Methods
1921 /// <summary> 1921
1922 /// send a objectupdate packet with information about the clients avatar 1922 /// <summary>
1923 /// </summary> 1923 /// send a objectupdate packet with information about the clients avatar
1924 /// <param name="regionInfo"></param> 1924 /// </summary>
1925 /// <param name="firstName"></param> 1925 /// <param name="regionInfo"></param>
1926 /// <param name="lastName"></param> 1926 /// <param name="firstName"></param>
1927 /// <param name="avatarID"></param> 1927 /// <param name="lastName"></param>
1928 /// <param name="avatarLocalID"></param> 1928 /// <param name="avatarID"></param>
1929 /// <param name="Pos"></param> 1929 /// <param name="avatarLocalID"></param>
1930 public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, 1930 /// <param name="Pos"></param>
1931 uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID) 1931 public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID,
1932 { 1932 uint avatarLocalID, LLVector3 Pos, byte[] textureEntry, uint parentID)
1933 ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate); 1933 {
1934 // TODO: don't create new blocks if recycling an old packet 1934 ObjectUpdatePacket objupdate = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
1935 objupdate.RegionData.RegionHandle = regionHandle; 1935 // TODO: don't create new blocks if recycling an old packet
1936 objupdate.RegionData.TimeDilation = ushort.MaxValue; 1936 objupdate.RegionData.RegionHandle = regionHandle;
1937 objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 1937 objupdate.RegionData.TimeDilation = ushort.MaxValue;
1938 objupdate.ObjectData[0] = CreateDefaultAvatarPacket(textureEntry); 1938 objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
1939 1939 objupdate.ObjectData[0] = CreateDefaultAvatarPacket(textureEntry);
1940 //give this avatar object a local id and assign the user a name 1940
1941 objupdate.ObjectData[0].ID = avatarLocalID; 1941 //give this avatar object a local id and assign the user a name
1942 objupdate.ObjectData[0].FullID = avatarID; 1942 objupdate.ObjectData[0].ID = avatarLocalID;
1943 objupdate.ObjectData[0].ParentID = parentID; 1943 objupdate.ObjectData[0].FullID = avatarID;
1944 objupdate.ObjectData[0].NameValue = 1944 objupdate.ObjectData[0].ParentID = parentID;
1945 Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName); 1945 objupdate.ObjectData[0].NameValue =
1946 LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z); 1946 Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName);
1947 byte[] pb = pos2.GetBytes(); 1947 LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z);
1948 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); 1948 byte[] pb = pos2.GetBytes();
1949 1949 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
1950 OutPacket(objupdate, ThrottleOutPacketType.Task); 1950
1951 } 1951 OutPacket(objupdate, ThrottleOutPacketType.Task);
1952 1952 }
1953 /// <summary> 1953
1954 /// 1954 /// <summary>
1955 /// </summary> 1955 ///
1956 /// <param name="regionHandle"></param> 1956 /// </summary>
1957 /// <param name="timeDilation"></param> 1957 /// <param name="regionHandle"></param>
1958 /// <param name="localID"></param> 1958 /// <param name="timeDilation"></param>
1959 /// <param name="position"></param> 1959 /// <param name="localID"></param>
1960 /// <param name="velocity"></param> 1960 /// <param name="position"></param>
1961 public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, 1961 /// <param name="velocity"></param>
1962 LLVector3 velocity, LLQuaternion rotation) 1962 public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position,
1963 { 1963 LLVector3 velocity, LLQuaternion rotation)
1964 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = 1964 {
1965 CreateAvatarImprovedBlock(localID, position, velocity, rotation); 1965 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock =
1966 ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate); 1966 CreateAvatarImprovedBlock(localID, position, velocity, rotation);
1967 // TODO: don't create new blocks if recycling an old packet 1967 ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
1968 terse.RegionData.RegionHandle = regionHandle; 1968 // TODO: don't create new blocks if recycling an old packet
1969 terse.RegionData.TimeDilation = timeDilation; 1969 terse.RegionData.RegionHandle = regionHandle;
1970 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 1970 terse.RegionData.TimeDilation = timeDilation;
1971 terse.ObjectData[0] = terseBlock; 1971 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
1972 1972 terse.ObjectData[0] = terseBlock;
1973 terse.Header.Reliable = false; 1973
1974 1974 terse.Header.Reliable = false;
1975 1975
1976 OutPacket(terse, ThrottleOutPacketType.Task); 1976
1977 } 1977 OutPacket(terse, ThrottleOutPacketType.Task);
1978 1978 }
1979 public void SendCoarseLocationUpdate(List<LLVector3> CoarseLocations) 1979
1980 { 1980 public void SendCoarseLocationUpdate(List<LLVector3> CoarseLocations)
1981 CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate); 1981 {
1982 // TODO: don't create new blocks if recycling an old packet 1982 CoarseLocationUpdatePacket loc = (CoarseLocationUpdatePacket)PacketPool.Instance.GetPacket(PacketType.CoarseLocationUpdate);
1983 int total = CoarseLocations.Count; 1983 // TODO: don't create new blocks if recycling an old packet
1984 CoarseLocationUpdatePacket.IndexBlock ib = 1984 int total = CoarseLocations.Count;
1985 new CoarseLocationUpdatePacket.IndexBlock(); 1985 CoarseLocationUpdatePacket.IndexBlock ib =
1986 loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total]; 1986 new CoarseLocationUpdatePacket.IndexBlock();
1987 for (int i = 0; i < total; i++) 1987 loc.Location = new CoarseLocationUpdatePacket.LocationBlock[total];
1988 { 1988 for (int i = 0; i < total; i++)
1989 CoarseLocationUpdatePacket.LocationBlock lb = 1989 {
1990 new CoarseLocationUpdatePacket.LocationBlock(); 1990 CoarseLocationUpdatePacket.LocationBlock lb =
1991 lb.X = (byte)CoarseLocations[i].X; 1991 new CoarseLocationUpdatePacket.LocationBlock();
1992 lb.Y = (byte)CoarseLocations[i].Y; 1992 lb.X = (byte)CoarseLocations[i].X;
1993 lb.Z = (byte)(CoarseLocations[i].Z / 4); 1993 lb.Y = (byte)CoarseLocations[i].Y;
1994 loc.Location[i] = lb; 1994 lb.Z = (byte)(CoarseLocations[i].Z / 4);
1995 } 1995 loc.Location[i] = lb;
1996 ib.You = -1; 1996 }
1997 ib.Prey = -1; 1997 ib.You = -1;
1998 loc.Index = ib; 1998 ib.Prey = -1;
1999 loc.Header.Reliable = false; 1999 loc.Index = ib;
2000 OutPacket(loc, ThrottleOutPacketType.Task); 2000 loc.Header.Reliable = false;
2001 } 2001 OutPacket(loc, ThrottleOutPacketType.Task);
2002 2002 }
2003 #endregion 2003
2004 2004 #endregion
2005 #region Primitive Packet/data Sending Methods 2005
2006 2006 #region Primitive Packet/data Sending Methods
2007 /// <summary> 2007
2008 /// 2008 /// <summary>
2009 /// </summary> 2009 ///
2010 /// <param name="localID"></param> 2010 /// </summary>
2011 /// <param name="rotation"></param> 2011 /// <param name="localID"></param>
2012 /// <param name="attachPoint"></param> 2012 /// <param name="rotation"></param>
2013 public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) 2013 /// <param name="attachPoint"></param>
2014 { 2014 public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint)
2015 2015 {
2016 ObjectAttachPacket attach = (ObjectAttachPacket)PacketPool.Instance.GetPacket(PacketType.ObjectAttach); 2016
2017 Console.WriteLine("Attach object!"); 2017 ObjectAttachPacket attach = (ObjectAttachPacket)PacketPool.Instance.GetPacket(PacketType.ObjectAttach);
2018 // TODO: don't create new blocks if recycling an old packet 2018 Console.WriteLine("Attach object!");
2019 attach.AgentData.AgentID = AgentId; 2019 // TODO: don't create new blocks if recycling an old packet
2020 attach.AgentData.SessionID = m_sessionId; 2020 attach.AgentData.AgentID = AgentId;
2021 attach.AgentData.AttachmentPoint = attachPoint; 2021 attach.AgentData.SessionID = m_sessionId;
2022 attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1]; 2022 attach.AgentData.AttachmentPoint = attachPoint;
2023 attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock(); 2023 attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1];
2024 attach.ObjectData[0].ObjectLocalID = localID; 2024 attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock();
2025 attach.ObjectData[0].Rotation = rotation; 2025 attach.ObjectData[0].ObjectLocalID = localID;
2026 2026 attach.ObjectData[0].Rotation = rotation;
2027 OutPacket(attach, ThrottleOutPacketType.Task); 2027
2028 } 2028 OutPacket(attach, ThrottleOutPacketType.Task);
2029 2029 }
2030 public void SendPrimitiveToClient( 2030
2031 ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, 2031 public void SendPrimitiveToClient(
2032 uint flags, 2032 ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos,
2033 LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem, 2033 uint flags,
2034 LLQuaternion rotation, byte clickAction) 2034 LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem,
2035 { 2035 LLQuaternion rotation, byte clickAction)
2036 byte[] textureanim = new byte[0]; 2036 {
2037 2037 byte[] textureanim = new byte[0];
2038 SendPrimitiveToClient(regionHandle, timeDilation, localID, primShape, pos, flags, 2038
2039 objectID, ownerID, text, color, parentID, particleSystem, 2039 SendPrimitiveToClient(regionHandle, timeDilation, localID, primShape, pos, flags,
2040 rotation, clickAction, textureanim, false,(uint)0, LLUUID.Zero); 2040 objectID, ownerID, text, color, parentID, particleSystem,
2041 } 2041 rotation, clickAction, textureanim, false,(uint)0, LLUUID.Zero);
2042 public void SendPrimitiveToClient( 2042 }
2043 ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, 2043 public void SendPrimitiveToClient(
2044 uint flags, 2044 ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos,
2045 LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem, 2045 uint flags,
2046 LLQuaternion rotation, byte clickAction, byte[] textureanim, bool attachment, uint AttachPoint, LLUUID AssetId) 2046 LLUUID objectID, LLUUID ownerID, string text, byte[] color, uint parentID, byte[] particleSystem,
2047 { 2047 LLQuaternion rotation, byte clickAction, byte[] textureanim, bool attachment, uint AttachPoint, LLUUID AssetId)
2048 ObjectUpdatePacket outPacket = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate); 2048 {
2049 // TODO: don't create new blocks if recycling an old packet 2049 ObjectUpdatePacket outPacket = (ObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ObjectUpdate);
2050 outPacket.RegionData.RegionHandle = regionHandle; 2050 // TODO: don't create new blocks if recycling an old packet
2051 outPacket.RegionData.TimeDilation = timeDilation; 2051 outPacket.RegionData.RegionHandle = regionHandle;
2052 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 2052 outPacket.RegionData.TimeDilation = timeDilation;
2053 2053 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
2054 outPacket.ObjectData[0] = CreatePrimUpdateBlock(primShape, flags); 2054
2055 2055 outPacket.ObjectData[0] = CreatePrimUpdateBlock(primShape, flags);
2056 outPacket.ObjectData[0].ID = localID; 2056
2057 outPacket.ObjectData[0].FullID = objectID; 2057 outPacket.ObjectData[0].ID = localID;
2058 outPacket.ObjectData[0].OwnerID = ownerID; 2058 outPacket.ObjectData[0].FullID = objectID;
2059 2059 outPacket.ObjectData[0].OwnerID = ownerID;
2060 // Anything more than 255 will cause libsecondlife to barf 2060
2061 if (text.Length > 255) 2061 // Anything more than 255 will cause libsecondlife to barf
2062 { 2062 if (text.Length > 255)
2063 text = text.Remove(255); 2063 {
2064 } 2064 text = text.Remove(255);
2065 2065 }
2066 outPacket.ObjectData[0].Text = Helpers.StringToField(text); 2066
2067 2067 outPacket.ObjectData[0].Text = Helpers.StringToField(text);
2068 outPacket.ObjectData[0].TextColor[0] = color[0]; 2068
2069 outPacket.ObjectData[0].TextColor[1] = color[1]; 2069 outPacket.ObjectData[0].TextColor[0] = color[0];
2070 outPacket.ObjectData[0].TextColor[2] = color[2]; 2070 outPacket.ObjectData[0].TextColor[1] = color[1];
2071 outPacket.ObjectData[0].TextColor[3] = color[3]; 2071 outPacket.ObjectData[0].TextColor[2] = color[2];
2072 outPacket.ObjectData[0].ParentID = parentID; 2072 outPacket.ObjectData[0].TextColor[3] = color[3];
2073 outPacket.ObjectData[0].PSBlock = particleSystem; 2073 outPacket.ObjectData[0].ParentID = parentID;
2074 outPacket.ObjectData[0].ClickAction = clickAction; 2074 outPacket.ObjectData[0].PSBlock = particleSystem;
2075 //outPacket.ObjectData[0].Flags = 0; 2075 outPacket.ObjectData[0].ClickAction = clickAction;
2076 2076 //outPacket.ObjectData[0].Flags = 0;
2077 if (attachment) 2077
2078 { 2078 if (attachment)
2079 // Necessary??? 2079 {
2080 outPacket.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 2); 2080 // Necessary???
2081 outPacket.ObjectData[0].JointPivot = new LLVector3(0, 0, 0); 2081 outPacket.ObjectData[0].JointAxisOrAnchor = new LLVector3(0, 0, 2);
2082 2082 outPacket.ObjectData[0].JointPivot = new LLVector3(0, 0, 0);
2083 // Item from inventory??? 2083
2084 outPacket.ObjectData[0].NameValue = 2084 // Item from inventory???
2085 Helpers.StringToField("AttachItemID STRING RW SV " + AssetId.UUID); 2085 outPacket.ObjectData[0].NameValue =
2086 outPacket.ObjectData[0].State = (byte)((AttachPoint % 16) * 16 + (AttachPoint / 16)); 2086 Helpers.StringToField("AttachItemID STRING RW SV " + AssetId.UUID);
2087 } 2087 outPacket.ObjectData[0].State = (byte)((AttachPoint % 16) * 16 + (AttachPoint / 16));
2088 2088 }
2089 // Sound Radius 2089
2090 outPacket.ObjectData[0].Radius = 20; 2090 // Sound Radius
2091 2091 outPacket.ObjectData[0].Radius = 20;
2092 byte[] pb = pos.GetBytes(); 2092
2093 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); 2093 byte[] pb = pos.GetBytes();
2094 2094 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
2095 byte[] rot = rotation.GetBytes(); 2095
2096 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 36, rot.Length); 2096 byte[] rot = rotation.GetBytes();
2097 2097 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 36, rot.Length);
2098 if (textureanim.Length > 0) 2098
2099 { 2099 if (textureanim.Length > 0)
2100 outPacket.ObjectData[0].TextureAnim = textureanim; 2100 {
2101 } 2101 outPacket.ObjectData[0].TextureAnim = textureanim;
2102 2102 }
2103 OutPacket(outPacket, ThrottleOutPacketType.Task); 2103
2104 } 2104 OutPacket(outPacket, ThrottleOutPacketType.Task);
2105 2105 }
2106 /// <summary> 2106
2107 /// 2107 /// <summary>
2108 /// </summary> 2108 ///
2109 /// <param name="regionHandle"></param> 2109 /// </summary>
2110 /// <param name="timeDilation"></param> 2110 /// <param name="regionHandle"></param>
2111 /// <param name="localID"></param> 2111 /// <param name="timeDilation"></param>
2112 /// <param name="position"></param> 2112 /// <param name="localID"></param>
2113 /// <param name="rotation"></param> 2113 /// <param name="position"></param>
2114 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, 2114 /// <param name="rotation"></param>
2115 LLQuaternion rotation, byte state, LLUUID AssetId) 2115 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position,
2116 { 2116 LLQuaternion rotation, byte state, LLUUID AssetId)
2117 LLVector3 velocity = new LLVector3(0f, 0f, 0f); 2117 {
2118 LLVector3 rotationalvelocity = new LLVector3(0f, 0f, 0f); 2118 LLVector3 velocity = new LLVector3(0f, 0f, 0f);
2119 ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate); 2119 LLVector3 rotationalvelocity = new LLVector3(0f, 0f, 0f);
2120 // TODO: don't create new blocks if recycling an old packet 2120 ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
2121 terse.RegionData.RegionHandle = regionHandle; 2121 // TODO: don't create new blocks if recycling an old packet
2122 terse.RegionData.TimeDilation = timeDilation; 2122 terse.RegionData.RegionHandle = regionHandle;
2123 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 2123 terse.RegionData.TimeDilation = timeDilation;
2124 terse.ObjectData[0] = CreatePrimImprovedBlock(localID, position, rotation, velocity, rotationalvelocity, state); // AssetID should fall into here probably somehow... 2124 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
2125 terse.Header.Reliable = false; 2125 terse.ObjectData[0] = CreatePrimImprovedBlock(localID, position, rotation, velocity, rotationalvelocity, state); // AssetID should fall into here probably somehow...
2126 OutPacket(terse, ThrottleOutPacketType.Task); 2126 terse.Header.Reliable = false;
2127 } 2127 OutPacket(terse, ThrottleOutPacketType.Task);
2128 2128 }
2129 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, 2129
2130 LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity) 2130 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position,
2131 { 2131 LLQuaternion rotation, LLVector3 velocity, LLVector3 rotationalvelocity)
2132 ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate); 2132 {
2133 // TODO: don't create new blocks if recycling an old packet 2133 ImprovedTerseObjectUpdatePacket terse = (ImprovedTerseObjectUpdatePacket)PacketPool.Instance.GetPacket(PacketType.ImprovedTerseObjectUpdate);
2134 terse.RegionData.RegionHandle = regionHandle; 2134 // TODO: don't create new blocks if recycling an old packet
2135 terse.RegionData.TimeDilation = timeDilation; 2135 terse.RegionData.RegionHandle = regionHandle;
2136 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 2136 terse.RegionData.TimeDilation = timeDilation;
2137 terse.ObjectData[0] = CreatePrimImprovedBlock(localID, position, rotation, velocity, rotationalvelocity, 0); 2137 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
2138 terse.Header.Reliable = false; 2138 terse.ObjectData[0] = CreatePrimImprovedBlock(localID, position, rotation, velocity, rotationalvelocity, 0);
2139 OutPacket(terse, ThrottleOutPacketType.Task); 2139 terse.Header.Reliable = false;
2140 } 2140 OutPacket(terse, ThrottleOutPacketType.Task);
2141 2141 }
2142 #endregion 2142
2143 2143 #endregion
2144 #region Helper Methods 2144
2145 2145 #region Helper Methods
2146 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, 2146
2147 LLVector3 velocity, 2147 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos,
2148 LLQuaternion rotation) 2148 LLVector3 velocity,
2149 { 2149 LLQuaternion rotation)
2150 byte[] bytes = new byte[60]; 2150 {
2151 int i = 0; 2151 byte[] bytes = new byte[60];
2152 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); 2152 int i = 0;
2153 2153 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
2154 dat.TextureEntry = new byte[0]; // AvatarTemplate.TextureEntry; 2154
2155 2155 dat.TextureEntry = new byte[0]; // AvatarTemplate.TextureEntry;
2156 uint ID = localID; 2156
2157 2157 uint ID = localID;
2158 bytes[i++] = (byte)(ID % 256); 2158
2159 bytes[i++] = (byte)((ID >> 8) % 256); 2159 bytes[i++] = (byte)(ID % 256);
2160 bytes[i++] = (byte)((ID >> 16) % 256); 2160 bytes[i++] = (byte)((ID >> 8) % 256);
2161 bytes[i++] = (byte)((ID >> 24) % 256); 2161 bytes[i++] = (byte)((ID >> 16) % 256);
2162 bytes[i++] = 0; 2162 bytes[i++] = (byte)((ID >> 24) % 256);
2163 bytes[i++] = 1; 2163 bytes[i++] = 0;
2164 i += 14; 2164 bytes[i++] = 1;
2165 bytes[i++] = 128; 2165 i += 14;
2166 bytes[i++] = 63; 2166 bytes[i++] = 128;
2167 2167 bytes[i++] = 63;
2168 byte[] pb = pos.GetBytes(); 2168
2169 Array.Copy(pb, 0, bytes, i, pb.Length); 2169 byte[] pb = pos.GetBytes();
2170 i += 12; 2170 Array.Copy(pb, 0, bytes, i, pb.Length);
2171 ushort InternVelocityX; 2171 i += 12;
2172 ushort InternVelocityY; 2172 ushort InternVelocityX;
2173 ushort InternVelocityZ; 2173 ushort InternVelocityY;
2174 Vector3 internDirec = new Vector3(0, 0, 0); 2174 ushort InternVelocityZ;
2175 2175 Vector3 internDirec = new Vector3(0, 0, 0);
2176 internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z); 2176
2177 2177 internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z);
2178 internDirec = internDirec / 128.0f; 2178
2179 internDirec.x += 1; 2179 internDirec = internDirec / 128.0f;
2180 internDirec.y += 1; 2180 internDirec.x += 1;
2181 internDirec.z += 1; 2181 internDirec.y += 1;
2182 2182 internDirec.z += 1;
2183 InternVelocityX = (ushort)(32768 * internDirec.x); 2183
2184 InternVelocityY = (ushort)(32768 * internDirec.y); 2184 InternVelocityX = (ushort)(32768 * internDirec.x);
2185 InternVelocityZ = (ushort)(32768 * internDirec.z); 2185 InternVelocityY = (ushort)(32768 * internDirec.y);
2186 2186 InternVelocityZ = (ushort)(32768 * internDirec.z);
2187 ushort ac = 32767; 2187
2188 bytes[i++] = (byte)(InternVelocityX % 256); 2188 ushort ac = 32767;
2189 bytes[i++] = (byte)((InternVelocityX >> 8) % 256); 2189 bytes[i++] = (byte)(InternVelocityX % 256);
2190 bytes[i++] = (byte)(InternVelocityY % 256); 2190 bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
2191 bytes[i++] = (byte)((InternVelocityY >> 8) % 256); 2191 bytes[i++] = (byte)(InternVelocityY % 256);
2192 bytes[i++] = (byte)(InternVelocityZ % 256); 2192 bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
2193 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); 2193 bytes[i++] = (byte)(InternVelocityZ % 256);
2194 2194 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
2195 //accel 2195
2196 bytes[i++] = (byte)(ac % 256); 2196 //accel
2197 bytes[i++] = (byte)((ac >> 8) % 256); 2197 bytes[i++] = (byte)(ac % 256);
2198 bytes[i++] = (byte)(ac % 256); 2198 bytes[i++] = (byte)((ac >> 8) % 256);
2199 bytes[i++] = (byte)((ac >> 8) % 256); 2199 bytes[i++] = (byte)(ac % 256);
2200 bytes[i++] = (byte)(ac % 256); 2200 bytes[i++] = (byte)((ac >> 8) % 256);
2201 bytes[i++] = (byte)((ac >> 8) % 256); 2201 bytes[i++] = (byte)(ac % 256);
2202 2202 bytes[i++] = (byte)((ac >> 8) % 256);
2203 //rotation 2203
2204 ushort rw, rx, ry, rz; 2204 //rotation
2205 rw = (ushort)(32768 * (rotation.W + 1)); 2205 ushort rw, rx, ry, rz;
2206 rx = (ushort)(32768 * (rotation.X + 1)); 2206 rw = (ushort)(32768 * (rotation.W + 1));
2207 ry = (ushort)(32768 * (rotation.Y + 1)); 2207 rx = (ushort)(32768 * (rotation.X + 1));
2208 rz = (ushort)(32768 * (rotation.Z + 1)); 2208 ry = (ushort)(32768 * (rotation.Y + 1));
2209 2209 rz = (ushort)(32768 * (rotation.Z + 1));
2210 //rot 2210
2211 bytes[i++] = (byte)(rx % 256); 2211 //rot
2212 bytes[i++] = (byte)((rx >> 8) % 256); 2212 bytes[i++] = (byte)(rx % 256);
2213 bytes[i++] = (byte)(ry % 256); 2213 bytes[i++] = (byte)((rx >> 8) % 256);
2214 bytes[i++] = (byte)((ry >> 8) % 256); 2214 bytes[i++] = (byte)(ry % 256);
2215 bytes[i++] = (byte)(rz % 256); 2215 bytes[i++] = (byte)((ry >> 8) % 256);
2216 bytes[i++] = (byte)((rz >> 8) % 256); 2216 bytes[i++] = (byte)(rz % 256);
2217 bytes[i++] = (byte)(rw % 256); 2217 bytes[i++] = (byte)((rz >> 8) % 256);
2218 bytes[i++] = (byte)((rw >> 8) % 256); 2218 bytes[i++] = (byte)(rw % 256);
2219 2219 bytes[i++] = (byte)((rw >> 8) % 256);
2220 //rotation vel 2220
2221 bytes[i++] = (byte)(ac % 256); 2221 //rotation vel
2222 bytes[i++] = (byte)((ac >> 8) % 256); 2222 bytes[i++] = (byte)(ac % 256);
2223 bytes[i++] = (byte)(ac % 256); 2223 bytes[i++] = (byte)((ac >> 8) % 256);
2224 bytes[i++] = (byte)((ac >> 8) % 256); 2224 bytes[i++] = (byte)(ac % 256);
2225 bytes[i++] = (byte)(ac % 256); 2225 bytes[i++] = (byte)((ac >> 8) % 256);
2226 bytes[i++] = (byte)((ac >> 8) % 256); 2226 bytes[i++] = (byte)(ac % 256);
2227 2227 bytes[i++] = (byte)((ac >> 8) % 256);
2228 dat.Data = bytes; 2228
2229 2229 dat.Data = bytes;
2230 return (dat); 2230
2231 } 2231 return (dat);
2232 2232 }
2233 /// <summary> 2233
2234 /// 2234 /// <summary>
2235 /// </summary> 2235 ///
2236 /// <param name="localID"></param> 2236 /// </summary>
2237 /// <param name="position"></param> 2237 /// <param name="localID"></param>
2238 /// <param name="rotation"></param> 2238 /// <param name="position"></param>
2239 /// <returns></returns> 2239 /// <param name="rotation"></param>
2240 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, 2240 /// <returns></returns>
2241 LLVector3 position, 2241 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID,
2242 LLQuaternion rotation, 2242 LLVector3 position,
2243 LLVector3 velocity, 2243 LLQuaternion rotation,
2244 LLVector3 rotationalvelocity, 2244 LLVector3 velocity,
2245 byte state) 2245 LLVector3 rotationalvelocity,
2246 { 2246 byte state)
2247 uint ID = localID; 2247 {
2248 byte[] bytes = new byte[60]; 2248 uint ID = localID;
2249 2249 byte[] bytes = new byte[60];
2250 int i = 0; 2250
2251 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); 2251 int i = 0;
2252 dat.TextureEntry = new byte[0]; 2252 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
2253 bytes[i++] = (byte)(ID % 256); 2253 dat.TextureEntry = new byte[0];
2254 bytes[i++] = (byte)((ID >> 8) % 256); 2254 bytes[i++] = (byte)(ID % 256);
2255 bytes[i++] = (byte)((ID >> 16) % 256); 2255 bytes[i++] = (byte)((ID >> 8) % 256);
2256 bytes[i++] = (byte)((ID >> 24) % 256); 2256 bytes[i++] = (byte)((ID >> 16) % 256);
2257 bytes[i++] = state; 2257 bytes[i++] = (byte)((ID >> 24) % 256);
2258 bytes[i++] = 0; 2258 bytes[i++] = state;
2259 2259 bytes[i++] = 0;
2260 byte[] pb = position.GetBytes(); 2260
2261 Array.Copy(pb, 0, bytes, i, pb.Length); 2261 byte[] pb = position.GetBytes();
2262 i += 12; 2262 Array.Copy(pb, 0, bytes, i, pb.Length);
2263 ushort ac = 32767; 2263 i += 12;
2264 2264 ushort ac = 32767;
2265 ushort velx, vely, velz; 2265
2266 Vector3 vel = new Vector3(velocity.X, velocity.Y, velocity.Z); 2266 ushort velx, vely, velz;
2267 2267 Vector3 vel = new Vector3(velocity.X, velocity.Y, velocity.Z);
2268 vel = vel / 128.0f; 2268
2269 vel.x += 1; 2269 vel = vel / 128.0f;
2270 vel.y += 1; 2270 vel.x += 1;
2271 vel.z += 1; 2271 vel.y += 1;
2272 //vel 2272 vel.z += 1;
2273 velx = (ushort)(32768 * (vel.x)); 2273 //vel
2274 vely = (ushort)(32768 * (vel.y)); 2274 velx = (ushort)(32768 * (vel.x));
2275 velz = (ushort)(32768 * (vel.z)); 2275 vely = (ushort)(32768 * (vel.y));
2276 2276 velz = (ushort)(32768 * (vel.z));
2277 bytes[i++] = (byte)(velx % 256); 2277
2278 bytes[i++] = (byte)((velx >> 8) % 256); 2278 bytes[i++] = (byte)(velx % 256);
2279 bytes[i++] = (byte)(vely % 256); 2279 bytes[i++] = (byte)((velx >> 8) % 256);
2280 bytes[i++] = (byte)((vely >> 8) % 256); 2280 bytes[i++] = (byte)(vely % 256);
2281 bytes[i++] = (byte)(velz % 256); 2281 bytes[i++] = (byte)((vely >> 8) % 256);
2282 bytes[i++] = (byte)((velz >> 8) % 256); 2282 bytes[i++] = (byte)(velz % 256);
2283 2283 bytes[i++] = (byte)((velz >> 8) % 256);
2284 //accel 2284
2285 bytes[i++] = (byte)(ac % 256); 2285 //accel
2286 bytes[i++] = (byte)((ac >> 8) % 256); 2286 bytes[i++] = (byte)(ac % 256);
2287 bytes[i++] = (byte)(ac % 256); 2287 bytes[i++] = (byte)((ac >> 8) % 256);
2288 bytes[i++] = (byte)((ac >> 8) % 256); 2288 bytes[i++] = (byte)(ac % 256);
2289 bytes[i++] = (byte)(ac % 256); 2289 bytes[i++] = (byte)((ac >> 8) % 256);
2290 bytes[i++] = (byte)((ac >> 8) % 256); 2290 bytes[i++] = (byte)(ac % 256);
2291 2291 bytes[i++] = (byte)((ac >> 8) % 256);
2292 ushort rw, rx, ry, rz; 2292
2293 rw = (ushort)(32768 * (rotation.W + 1)); 2293 ushort rw, rx, ry, rz;
2294 rx = (ushort)(32768 * (rotation.X + 1)); 2294 rw = (ushort)(32768 * (rotation.W + 1));
2295 ry = (ushort)(32768 * (rotation.Y + 1)); 2295 rx = (ushort)(32768 * (rotation.X + 1));
2296 rz = (ushort)(32768 * (rotation.Z + 1)); 2296 ry = (ushort)(32768 * (rotation.Y + 1));
2297 2297 rz = (ushort)(32768 * (rotation.Z + 1));
2298 //rot 2298
2299 bytes[i++] = (byte)(rx % 256); 2299 //rot
2300 bytes[i++] = (byte)((rx >> 8) % 256); 2300 bytes[i++] = (byte)(rx % 256);
2301 bytes[i++] = (byte)(ry % 256); 2301 bytes[i++] = (byte)((rx >> 8) % 256);
2302 bytes[i++] = (byte)((ry >> 8) % 256); 2302 bytes[i++] = (byte)(ry % 256);
2303 bytes[i++] = (byte)(rz % 256); 2303 bytes[i++] = (byte)((ry >> 8) % 256);
2304 bytes[i++] = (byte)((rz >> 8) % 256); 2304 bytes[i++] = (byte)(rz % 256);
2305 bytes[i++] = (byte)(rw % 256); 2305 bytes[i++] = (byte)((rz >> 8) % 256);
2306 bytes[i++] = (byte)((rw >> 8) % 256); 2306 bytes[i++] = (byte)(rw % 256);
2307 2307 bytes[i++] = (byte)((rw >> 8) % 256);
2308 //rotation vel 2308
2309 ushort rvelx, rvely, rvelz; 2309 //rotation vel
2310 Vector3 rvel = new Vector3(rotationalvelocity.X, rotationalvelocity.Y, rotationalvelocity.Z); 2310 ushort rvelx, rvely, rvelz;
2311 2311 Vector3 rvel = new Vector3(rotationalvelocity.X, rotationalvelocity.Y, rotationalvelocity.Z);
2312 rvel = rvel / 128.0f; 2312
2313 rvel.x += 1; 2313 rvel = rvel / 128.0f;
2314 rvel.y += 1; 2314 rvel.x += 1;
2315 rvel.z += 1; 2315 rvel.y += 1;
2316 //vel 2316 rvel.z += 1;
2317 rvelx = (ushort)(32768 * (rvel.x)); 2317 //vel
2318 rvely = (ushort)(32768 * (rvel.y)); 2318 rvelx = (ushort)(32768 * (rvel.x));
2319 rvelz = (ushort)(32768 * (rvel.z)); 2319 rvely = (ushort)(32768 * (rvel.y));
2320 2320 rvelz = (ushort)(32768 * (rvel.z));
2321 bytes[i++] = (byte)(rvelx % 256); 2321
2322 bytes[i++] = (byte)((rvelx >> 8) % 256); 2322 bytes[i++] = (byte)(rvelx % 256);
2323 bytes[i++] = (byte)(rvely % 256); 2323 bytes[i++] = (byte)((rvelx >> 8) % 256);
2324 bytes[i++] = (byte)((rvely >> 8) % 256); 2324 bytes[i++] = (byte)(rvely % 256);
2325 bytes[i++] = (byte)(rvelz % 256); 2325 bytes[i++] = (byte)((rvely >> 8) % 256);
2326 bytes[i++] = (byte)((rvelz >> 8) % 256); 2326 bytes[i++] = (byte)(rvelz % 256);
2327 dat.Data = bytes; 2327 bytes[i++] = (byte)((rvelz >> 8) % 256);
2328 2328 dat.Data = bytes;
2329 2329
2330 return dat; 2330
2331 } 2331 return dat;
2332 2332 }
2333 /// <summary> 2333
2334 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive) 2334 /// <summary>
2335 /// </summary> 2335 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive)
2336 /// <param name="primData"></param> 2336 /// </summary>
2337 /// <returns></returns> 2337 /// <param name="primData"></param>
2338 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags) 2338 /// <returns></returns>
2339 { 2339 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags)
2340 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); 2340 {
2341 SetDefaultPrimPacketValues(objupdate); 2341 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
2342 objupdate.UpdateFlags = flags; 2342 SetDefaultPrimPacketValues(objupdate);
2343 SetPrimPacketShapeData(objupdate, primShape); 2343 objupdate.UpdateFlags = flags;
2344 2344 SetPrimPacketShapeData(objupdate, primShape);
2345 if ((primShape.PCode == (byte)PCode.NewTree) || (primShape.PCode == (byte)PCode.Tree) || (primShape.PCode == (byte)PCode.Grass)) 2345
2346 { 2346 if ((primShape.PCode == (byte)PCode.NewTree) || (primShape.PCode == (byte)PCode.Tree) || (primShape.PCode == (byte)PCode.Grass))
2347 objupdate.Data = new byte[1]; 2347 {
2348 objupdate.Data[0] = primShape.State; 2348 objupdate.Data = new byte[1];
2349 } 2349 objupdate.Data[0] = primShape.State;
2350 return objupdate; 2350 }
2351 } 2351 return objupdate;
2352 2352 }
2353 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData) 2353
2354 { 2354 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData)
2355 objectData.TextureEntry = primData.TextureEntry; 2355 {
2356 objectData.PCode = primData.PCode; 2356 objectData.TextureEntry = primData.TextureEntry;
2357 objectData.State = primData.State; 2357 objectData.PCode = primData.PCode;
2358 objectData.PathBegin = primData.PathBegin; 2358 objectData.State = primData.State;
2359 objectData.PathEnd = primData.PathEnd; 2359 objectData.PathBegin = primData.PathBegin;
2360 objectData.PathScaleX = primData.PathScaleX; 2360 objectData.PathEnd = primData.PathEnd;
2361 objectData.PathScaleY = primData.PathScaleY; 2361 objectData.PathScaleX = primData.PathScaleX;
2362 objectData.PathShearX = primData.PathShearX; 2362 objectData.PathScaleY = primData.PathScaleY;
2363 objectData.PathShearY = primData.PathShearY; 2363 objectData.PathShearX = primData.PathShearX;
2364 objectData.PathSkew = primData.PathSkew; 2364 objectData.PathShearY = primData.PathShearY;
2365 objectData.ProfileBegin = primData.ProfileBegin; 2365 objectData.PathSkew = primData.PathSkew;
2366 objectData.ProfileEnd = primData.ProfileEnd; 2366 objectData.ProfileBegin = primData.ProfileBegin;
2367 objectData.Scale = primData.Scale; 2367 objectData.ProfileEnd = primData.ProfileEnd;
2368 objectData.PathCurve = primData.PathCurve; 2368 objectData.Scale = primData.Scale;
2369 objectData.ProfileCurve = primData.ProfileCurve; 2369 objectData.PathCurve = primData.PathCurve;
2370 objectData.ProfileHollow = primData.ProfileHollow; 2370 objectData.ProfileCurve = primData.ProfileCurve;
2371 objectData.PathRadiusOffset = primData.PathRadiusOffset; 2371 objectData.ProfileHollow = primData.ProfileHollow;
2372 objectData.PathRevolutions = primData.PathRevolutions; 2372 objectData.PathRadiusOffset = primData.PathRadiusOffset;
2373 objectData.PathTaperX = primData.PathTaperX; 2373 objectData.PathRevolutions = primData.PathRevolutions;
2374 objectData.PathTaperY = primData.PathTaperY; 2374 objectData.PathTaperX = primData.PathTaperX;
2375 objectData.PathTwist = primData.PathTwist; 2375 objectData.PathTaperY = primData.PathTaperY;
2376 objectData.PathTwistBegin = primData.PathTwistBegin; 2376 objectData.PathTwist = primData.PathTwist;
2377 objectData.ExtraParams = primData.ExtraParams; 2377 objectData.PathTwistBegin = primData.PathTwistBegin;
2378 } 2378 objectData.ExtraParams = primData.ExtraParams;
2379 2379 }
2380 /// <summary> 2380
2381 /// Set some default values in a ObjectUpdatePacket 2381 /// <summary>
2382 /// </summary> 2382 /// Set some default values in a ObjectUpdatePacket
2383 /// <param name="objdata"></param> 2383 /// </summary>
2384 protected void SetDefaultPrimPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata) 2384 /// <param name="objdata"></param>
2385 { 2385 protected void SetDefaultPrimPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
2386 objdata.PSBlock = new byte[0]; 2386 {
2387 objdata.ExtraParams = new byte[1]; 2387 objdata.PSBlock = new byte[0];
2388 objdata.MediaURL = new byte[0]; 2388 objdata.ExtraParams = new byte[1];
2389 objdata.NameValue = new byte[0]; 2389 objdata.MediaURL = new byte[0];
2390 objdata.Text = new byte[0]; 2390 objdata.NameValue = new byte[0];
2391 objdata.TextColor = new byte[4]; 2391 objdata.Text = new byte[0];
2392 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); 2392 objdata.TextColor = new byte[4];
2393 objdata.JointPivot = new LLVector3(0, 0, 0); 2393 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
2394 objdata.Material = 3; 2394 objdata.JointPivot = new LLVector3(0, 0, 0);
2395 objdata.TextureAnim = new byte[0]; 2395 objdata.Material = 3;
2396 objdata.Sound = LLUUID.Zero; 2396 objdata.TextureAnim = new byte[0];
2397 objdata.State = 0; 2397 objdata.Sound = LLUUID.Zero;
2398 objdata.Data = new byte[0]; 2398 objdata.State = 0;
2399 2399 objdata.Data = new byte[0];
2400 objdata.ObjectData = new byte[60]; 2400
2401 objdata.ObjectData[46] = 128; 2401 objdata.ObjectData = new byte[60];
2402 objdata.ObjectData[47] = 63; 2402 objdata.ObjectData[46] = 128;
2403 } 2403 objdata.ObjectData[47] = 63;
2404 2404 }
2405 2405
2406 /// <summary> 2406
2407 /// 2407 /// <summary>
2408 /// </summary> 2408 ///
2409 /// <returns></returns> 2409 /// </summary>
2410 public ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry) 2410 /// <returns></returns>
2411 { 2411 public ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry)
2412 ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); 2412 {
2413 // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); 2413 ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock();
2414 2414 // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
2415 SetDefaultAvatarPacketValues(ref objdata); 2415
2416 objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24); 2416 SetDefaultAvatarPacketValues(ref objdata);
2417 objdata.PathCurve = 16; 2417 objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24);
2418 objdata.ProfileCurve = 1; 2418 objdata.PathCurve = 16;
2419 objdata.PathScaleX = 100; 2419 objdata.ProfileCurve = 1;
2420 objdata.PathScaleY = 100; 2420 objdata.PathScaleX = 100;
2421 objdata.ParentID = 0; 2421 objdata.PathScaleY = 100;
2422 objdata.OwnerID = LLUUID.Zero; 2422 objdata.ParentID = 0;
2423 objdata.Scale = new LLVector3(1, 1, 1); 2423 objdata.OwnerID = LLUUID.Zero;
2424 objdata.PCode = (byte)PCode.Avatar; 2424 objdata.Scale = new LLVector3(1, 1, 1);
2425 if (textureEntry != null) 2425 objdata.PCode = (byte)PCode.Avatar;
2426 { 2426 if (textureEntry != null)
2427 objdata.TextureEntry = textureEntry; 2427 {
2428 } 2428 objdata.TextureEntry = textureEntry;
2429 LLVector3 pos = new LLVector3(objdata.ObjectData, 16); 2429 }
2430 pos.X = 100f; 2430 LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
2431 objdata.ID = 8880000; 2431 pos.X = 100f;
2432 objdata.NameValue = Helpers.StringToField("FirstName STRING RW SV Test \nLastName STRING RW SV User "); 2432 objdata.ID = 8880000;
2433 //LLVector3 pos2 = new LLVector3(100f, 100f, 23f); 2433 objdata.NameValue = Helpers.StringToField("FirstName STRING RW SV Test \nLastName STRING RW SV User ");
2434 //objdata.FullID=user.AgentId; 2434 //LLVector3 pos2 = new LLVector3(100f, 100f, 23f);
2435 byte[] pb = pos.GetBytes(); 2435 //objdata.FullID=user.AgentId;
2436 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); 2436 byte[] pb = pos.GetBytes();
2437 2437 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
2438 return objdata; 2438
2439 } 2439 return objdata;
2440 2440 }
2441 /// <summary> 2441
2442 /// 2442 /// <summary>
2443 /// </summary> 2443 ///
2444 /// <param name="objdata"></param> 2444 /// </summary>
2445 protected void SetDefaultAvatarPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata) 2445 /// <param name="objdata"></param>
2446 { 2446 protected void SetDefaultAvatarPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata)
2447 objdata.PSBlock = new byte[0]; 2447 {
2448 objdata.ExtraParams = new byte[1]; 2448 objdata.PSBlock = new byte[0];
2449 objdata.MediaURL = new byte[0]; 2449 objdata.ExtraParams = new byte[1];
2450 objdata.NameValue = new byte[0]; 2450 objdata.MediaURL = new byte[0];
2451 objdata.Text = new byte[0]; 2451 objdata.NameValue = new byte[0];
2452 objdata.TextColor = new byte[4]; 2452 objdata.Text = new byte[0];
2453 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); 2453 objdata.TextColor = new byte[4];
2454 objdata.JointPivot = new LLVector3(0, 0, 0); 2454 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
2455 objdata.Material = 4; 2455 objdata.JointPivot = new LLVector3(0, 0, 0);
2456 objdata.TextureAnim = new byte[0]; 2456 objdata.Material = 4;
2457 objdata.Sound = LLUUID.Zero; 2457 objdata.TextureAnim = new byte[0];
2458 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); 2458 objdata.Sound = LLUUID.Zero;
2459 objdata.TextureEntry = ntex.ToBytes(); 2459 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
2460 2460 objdata.TextureEntry = ntex.ToBytes();
2461 objdata.State = 0; 2461
2462 objdata.Data = new byte[0]; 2462 objdata.State = 0;
2463 2463 objdata.Data = new byte[0];
2464 objdata.ObjectData = new byte[76]; 2464
2465 objdata.ObjectData[15] = 128; 2465 objdata.ObjectData = new byte[76];
2466 objdata.ObjectData[16] = 63; 2466 objdata.ObjectData[15] = 128;
2467 objdata.ObjectData[56] = 128; 2467 objdata.ObjectData[16] = 63;
2468 objdata.ObjectData[61] = 102; 2468 objdata.ObjectData[56] = 128;
2469 objdata.ObjectData[62] = 40; 2469 objdata.ObjectData[61] = 102;
2470 objdata.ObjectData[63] = 61; 2470 objdata.ObjectData[62] = 40;
2471 objdata.ObjectData[64] = 189; 2471 objdata.ObjectData[63] = 61;
2472 } 2472 objdata.ObjectData[64] = 189;
2473 2473 }
2474 public void SendNameReply(LLUUID profileId, string firstname, string lastname) 2474
2475 { 2475 public void SendNameReply(LLUUID profileId, string firstname, string lastname)
2476 UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply); 2476 {
2477 // TODO: don't create new blocks if recycling an old packet 2477 UUIDNameReplyPacket packet = (UUIDNameReplyPacket)PacketPool.Instance.GetPacket(PacketType.UUIDNameReply);
2478 packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1]; 2478 // TODO: don't create new blocks if recycling an old packet
2479 packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); 2479 packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
2480 packet.UUIDNameBlock[0].ID = profileId; 2480 packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
2481 packet.UUIDNameBlock[0].FirstName = Helpers.StringToField(firstname); 2481 packet.UUIDNameBlock[0].ID = profileId;
2482 packet.UUIDNameBlock[0].LastName = Helpers.StringToField(lastname); 2482 packet.UUIDNameBlock[0].FirstName = Helpers.StringToField(firstname);
2483 2483 packet.UUIDNameBlock[0].LastName = Helpers.StringToField(lastname);
2484 OutPacket(packet, ThrottleOutPacketType.Task); 2484
2485 } 2485 OutPacket(packet, ThrottleOutPacketType.Task);
2486 2486 }
2487 #endregion 2487
2488 2488 #endregion
2489 protected virtual void RegisterLocalPacketHandlers() 2489
2490 { 2490 protected virtual void RegisterLocalPacketHandlers()
2491 AddLocalPacketHandler(PacketType.LogoutRequest, Logout); 2491 {
2492 AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect); 2492 AddLocalPacketHandler(PacketType.LogoutRequest, Logout);
2493 AddLocalPacketHandler(PacketType.AgentCachedTexture, AgentTextureCached); 2493 AddLocalPacketHandler(PacketType.ViewerEffect, HandleViewerEffect);
2494 AddLocalPacketHandler(PacketType.MultipleObjectUpdate, MultipleObjUpdate); 2494 AddLocalPacketHandler(PacketType.AgentCachedTexture, AgentTextureCached);
2495 AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest); 2495 AddLocalPacketHandler(PacketType.MultipleObjectUpdate, MultipleObjUpdate);
2496 AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest); 2496 AddLocalPacketHandler(PacketType.MoneyTransferRequest, HandleMoneyTransferRequest);
2497 } 2497 AddLocalPacketHandler(PacketType.ParcelBuy, HandleParcelBuyRequest);
2498 2498 }
2499 private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack) 2499
2500 { 2500 private bool HandleMoneyTransferRequest(IClientAPI sender, Packet Pack)
2501 MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack; 2501 {
2502 // validate the agent owns the agentID and sessionID 2502 MoneyTransferRequestPacket money = (MoneyTransferRequestPacket)Pack;
2503 if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId && money.AgentData.SessionID == sender.SessionId) 2503 // validate the agent owns the agentID and sessionID
2504 { 2504 if (money.MoneyData.SourceID == sender.AgentId && money.AgentData.AgentID == sender.AgentId && money.AgentData.SessionID == sender.SessionId)
2505 handlerMoneyTransferRequest = OnMoneyTransferRequest; 2505 {
2506 if (handlerMoneyTransferRequest != null) 2506 handlerMoneyTransferRequest = OnMoneyTransferRequest;
2507 { 2507 if (handlerMoneyTransferRequest != null)
2508 handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID, 2508 {
2509 money.MoneyData.Amount, money.MoneyData.TransactionType, 2509 handlerMoneyTransferRequest(money.MoneyData.SourceID, money.MoneyData.DestID,
2510 Util.FieldToString(money.MoneyData.Description)); 2510 money.MoneyData.Amount, money.MoneyData.TransactionType,
2511 } 2511 Util.FieldToString(money.MoneyData.Description));
2512 2512 }
2513 return true; 2513
2514 } 2514 return true;
2515 else 2515 }
2516 { 2516 else
2517 return false; 2517 {
2518 } 2518 return false;
2519 } 2519 }
2520 2520 }
2521 private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack) 2521
2522 { 2522 private bool HandleParcelBuyRequest(IClientAPI sender, Packet Pack)
2523 ParcelBuyPacket parcel = (ParcelBuyPacket)Pack; 2523 {
2524 if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == this.SessionId) 2524 ParcelBuyPacket parcel = (ParcelBuyPacket)Pack;
2525 { 2525 if (parcel.AgentData.AgentID == AgentId && parcel.AgentData.SessionID == this.SessionId)
2526 handlerParcelBuy = OnParcelBuy; 2526 {
2527 if (handlerParcelBuy != null) 2527 handlerParcelBuy = OnParcelBuy;
2528 { 2528 if (handlerParcelBuy != null)
2529 handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final, parcel.Data.IsGroupOwned, 2529 {
2530 parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area, parcel.ParcelData.Price, 2530 handlerParcelBuy(parcel.AgentData.AgentID, parcel.Data.GroupID, parcel.Data.Final, parcel.Data.IsGroupOwned,
2531 false); 2531 parcel.Data.RemoveContribution, parcel.Data.LocalID, parcel.ParcelData.Area, parcel.ParcelData.Price,
2532 } 2532 false);
2533 return true; 2533 }
2534 2534 return true;
2535 } 2535
2536 else 2536 }
2537 { 2537 else
2538 return false; 2538 {
2539 } 2539 return false;
2540 2540 }
2541 } 2541
2542 2542 }
2543 private bool HandleViewerEffect(IClientAPI sender, Packet Pack) 2543
2544 { 2544 private bool HandleViewerEffect(IClientAPI sender, Packet Pack)
2545 ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; 2545 {
2546 handlerViewerEffect = OnViewerEffect; 2546 ViewerEffectPacket viewer = (ViewerEffectPacket)Pack;
2547 if (handlerViewerEffect != null) 2547 handlerViewerEffect = OnViewerEffect;
2548 { 2548 if (handlerViewerEffect != null)
2549 handlerViewerEffect(sender, viewer.Effect); 2549 {
2550 } 2550 handlerViewerEffect(sender, viewer.Effect);
2551 2551 }
2552 return true; 2552
2553 } 2553 return true;
2554 2554 }
2555 public void SendScriptQuestion(LLUUID taskID, string taskName, string ownerName, LLUUID itemID, int question) 2555
2556 { 2556 public void SendScriptQuestion(LLUUID taskID, string taskName, string ownerName, LLUUID itemID, int question)
2557 ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion); 2557 {
2558 scriptQuestion.Data = new ScriptQuestionPacket.DataBlock(); 2558 ScriptQuestionPacket scriptQuestion = (ScriptQuestionPacket)PacketPool.Instance.GetPacket(PacketType.ScriptQuestion);
2559 // TODO: don't create new blocks if recycling an old packet 2559 scriptQuestion.Data = new ScriptQuestionPacket.DataBlock();
2560 scriptQuestion.Data.TaskID = taskID; 2560 // TODO: don't create new blocks if recycling an old packet
2561 scriptQuestion.Data.ItemID = itemID; 2561 scriptQuestion.Data.TaskID = taskID;
2562 scriptQuestion.Data.Questions = question; 2562 scriptQuestion.Data.ItemID = itemID;
2563 scriptQuestion.Data.ObjectName = Helpers.StringToField(taskName); 2563 scriptQuestion.Data.Questions = question;
2564 scriptQuestion.Data.ObjectOwner = Helpers.StringToField(ownerName); 2564 scriptQuestion.Data.ObjectName = Helpers.StringToField(taskName);
2565 2565 scriptQuestion.Data.ObjectOwner = Helpers.StringToField(ownerName);
2566 OutPacket(scriptQuestion, ThrottleOutPacketType.Task); 2566
2567 } 2567 OutPacket(scriptQuestion, ThrottleOutPacketType.Task);
2568 2568 }
2569 protected virtual bool Logout(IClientAPI client, Packet packet) 2569
2570 { 2570 protected virtual bool Logout(IClientAPI client, Packet packet)
2571 m_log.Info("[CLIENT]: Got a logout request"); 2571 {
2572 2572 m_log.Info("[CLIENT]: Got a logout request");
2573 handlerLogout = OnLogout; 2573
2574 2574 handlerLogout = OnLogout;
2575 if (handlerLogout != null) 2575
2576 { 2576 if (handlerLogout != null)
2577 handlerLogout(client); 2577 {
2578 } 2578 handlerLogout(client);
2579 2579 }
2580 return true; 2580
2581 } 2581 return true;
2582 2582 }
2583 /// <summary> 2583
2584 /// Send a response back to a client when it asks the asset server (via the region server) if it has 2584 /// <summary>
2585 /// its appearance texture cached. 2585 /// Send a response back to a client when it asks the asset server (via the region server) if it has
2586 /// 2586 /// its appearance texture cached.
2587 /// At the moment, we always reply that there is no cached texture. 2587 ///
2588 /// </summary> 2588 /// At the moment, we always reply that there is no cached texture.
2589 /// <param name="simclient"></param> 2589 /// </summary>
2590 /// <param name="packet"></param> 2590 /// <param name="simclient"></param>
2591 /// <returns></returns> 2591 /// <param name="packet"></param>
2592 protected bool AgentTextureCached(IClientAPI simclient, Packet packet) 2592 /// <returns></returns>
2593 { 2593 protected bool AgentTextureCached(IClientAPI simclient, Packet packet)
2594 //Console.WriteLine("texture cached: " + packet.ToString()); 2594 {
2595 AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet; 2595 //Console.WriteLine("texture cached: " + packet.ToString());
2596 AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse); 2596 AgentCachedTexturePacket cachedtex = (AgentCachedTexturePacket)packet;
2597 // TODO: don't create new blocks if recycling an old packet 2597 AgentCachedTextureResponsePacket cachedresp = (AgentCachedTextureResponsePacket)PacketPool.Instance.GetPacket(PacketType.AgentCachedTextureResponse);
2598 cachedresp.AgentData.AgentID = AgentId; 2598 // TODO: don't create new blocks if recycling an old packet
2599 cachedresp.AgentData.SessionID = m_sessionId; 2599 cachedresp.AgentData.AgentID = AgentId;
2600 cachedresp.AgentData.SerialNum = m_cachedTextureSerial; 2600 cachedresp.AgentData.SessionID = m_sessionId;
2601 m_cachedTextureSerial++; 2601 cachedresp.AgentData.SerialNum = m_cachedTextureSerial;
2602 cachedresp.WearableData = 2602 m_cachedTextureSerial++;
2603 new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length]; 2603 cachedresp.WearableData =
2604 2604 new AgentCachedTextureResponsePacket.WearableDataBlock[cachedtex.WearableData.Length];
2605 for (int i = 0; i < cachedtex.WearableData.Length; i++) 2605
2606 { 2606 for (int i = 0; i < cachedtex.WearableData.Length; i++)
2607 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock(); 2607 {
2608 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex; 2608 cachedresp.WearableData[i] = new AgentCachedTextureResponsePacket.WearableDataBlock();
2609 cachedresp.WearableData[i].TextureID = LLUUID.Zero; 2609 cachedresp.WearableData[i].TextureIndex = cachedtex.WearableData[i].TextureIndex;
2610 cachedresp.WearableData[i].HostName = new byte[0]; 2610 cachedresp.WearableData[i].TextureID = LLUUID.Zero;
2611 } 2611 cachedresp.WearableData[i].HostName = new byte[0];
2612 2612 }
2613 // Temporarily throw these packets on to the wind queue, so we can identify whether these 2613
2614 // are somehow the source of the packet bloat. 2614 // Temporarily throw these packets on to the wind queue, so we can identify whether these
2615 OutPacket(cachedresp, ThrottleOutPacketType.Wind); 2615 // are somehow the source of the packet bloat.
2616 return true; 2616 OutPacket(cachedresp, ThrottleOutPacketType.Wind);
2617 } 2617 return true;
2618 2618 }
2619 protected bool MultipleObjUpdate(IClientAPI simClient, Packet packet) 2619
2620 { 2620 protected bool MultipleObjUpdate(IClientAPI simClient, Packet packet)
2621 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet; 2621 {
2622 // Console.WriteLine("new multi update packet " + multipleupdate.ToString()); 2622 MultipleObjectUpdatePacket multipleupdate = (MultipleObjectUpdatePacket)packet;
2623 Scene tScene = (Scene)m_scene; 2623 // Console.WriteLine("new multi update packet " + multipleupdate.ToString());
2624 2624 Scene tScene = (Scene)m_scene;
2625 for (int i = 0; i < multipleupdate.ObjectData.Length; i++) 2625
2626 { 2626 for (int i = 0; i < multipleupdate.ObjectData.Length; i++)
2627 MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i]; 2627 {
2628 2628 MultipleObjectUpdatePacket.ObjectDataBlock block = multipleupdate.ObjectData[i];
2629 // Can't act on Null Data 2629
2630 if (block.Data != null) 2630 // Can't act on Null Data
2631 { 2631 if (block.Data != null)
2632 uint localId = block.ObjectLocalID; 2632 {
2633 SceneObjectPart part = tScene.GetSceneObjectPart(localId); 2633 uint localId = block.ObjectLocalID;
2634 2634 SceneObjectPart part = tScene.GetSceneObjectPart(localId);
2635 if (part == null) 2635
2636 { 2636 if (part == null)
2637 // It's a ghost! tell the client to delete it from view. 2637 {
2638 simClient.SendKillObject(Scene.RegionInfo.RegionHandle, 2638 // It's a ghost! tell the client to delete it from view.
2639 localId); 2639 simClient.SendKillObject(Scene.RegionInfo.RegionHandle,
2640 } 2640 localId);
2641 else 2641 }
2642 { 2642 else
2643 LLUUID partId = part.UUID; 2643 {
2644 UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; 2644 LLUUID partId = part.UUID;
2645 UpdatePrimGroupRotation handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation; 2645 UpdatePrimRotation handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
2646 2646 UpdatePrimGroupRotation handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation;
2647 switch (block.Type) 2647
2648 { 2648 switch (block.Type)
2649 case 1: 2649 {
2650 LLVector3 pos1 = new LLVector3(block.Data, 0); 2650 case 1:
2651 2651 LLVector3 pos1 = new LLVector3(block.Data, 0);
2652 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition; 2652
2653 if (handlerUpdatePrimSinglePosition != null) 2653 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
2654 { 2654 if (handlerUpdatePrimSinglePosition != null)
2655 2655 {
2656 // Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); 2656
2657 handlerUpdatePrimSinglePosition(localId, pos1, this); 2657 // Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
2658 } 2658 handlerUpdatePrimSinglePosition(localId, pos1, this);
2659 break; 2659 }
2660 case 2: 2660 break;
2661 LLQuaternion rot1 = new LLQuaternion(block.Data, 0, true); 2661 case 2:
2662 2662 LLQuaternion rot1 = new LLQuaternion(block.Data, 0, true);
2663 handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation; 2663
2664 if (handlerUpdatePrimSingleRotation != null) 2664 handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation;
2665 { 2665 if (handlerUpdatePrimSingleRotation != null)
2666 2666 {
2667 //Console.WriteLine("new tab rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 2667
2668 handlerUpdatePrimSingleRotation(localId, rot1, this); 2668 //Console.WriteLine("new tab rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
2669 } 2669 handlerUpdatePrimSingleRotation(localId, rot1, this);
2670 break; 2670 }
2671 case 3: 2671 break;
2672 2672 case 3:
2673 LLQuaternion rot2 = new LLQuaternion(block.Data, 12, true); 2673
2674 handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation; 2674 LLQuaternion rot2 = new LLQuaternion(block.Data, 12, true);
2675 if (handlerUpdatePrimSingleRotation != null) 2675 handlerUpdatePrimSingleRotation = OnUpdatePrimSingleRotation;
2676 { 2676 if (handlerUpdatePrimSingleRotation != null)
2677 2677 {
2678 //Console.WriteLine("new mouse rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 2678
2679 handlerUpdatePrimSingleRotation(localId, rot2, this); 2679 //Console.WriteLine("new mouse rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
2680 } 2680 handlerUpdatePrimSingleRotation(localId, rot2, this);
2681 break; 2681 }
2682 case 5: 2682 break;
2683 2683 case 5:
2684 LLVector3 scale1 = new LLVector3(block.Data, 12); 2684
2685 LLVector3 pos11 = new LLVector3(block.Data, 0); 2685 LLVector3 scale1 = new LLVector3(block.Data, 12);
2686 2686 LLVector3 pos11 = new LLVector3(block.Data, 0);
2687 handlerUpdatePrimScale = OnUpdatePrimScale; 2687
2688 if (handlerUpdatePrimScale != null) 2688 handlerUpdatePrimScale = OnUpdatePrimScale;
2689 { 2689 if (handlerUpdatePrimScale != null)
2690 2690 {
2691 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 2691
2692 handlerUpdatePrimScale(localId, scale1, this); 2692 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
2693 2693 handlerUpdatePrimScale(localId, scale1, this);
2694 2694
2695 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition; 2695
2696 if (handlerUpdatePrimSinglePosition != null) 2696 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
2697 { 2697 if (handlerUpdatePrimSinglePosition != null)
2698 handlerUpdatePrimSinglePosition(localId, pos11, this); 2698 {
2699 } 2699 handlerUpdatePrimSinglePosition(localId, pos11, this);
2700 } 2700 }
2701 break; 2701 }
2702 case 9: 2702 break;
2703 LLVector3 pos2 = new LLVector3(block.Data, 0); 2703 case 9:
2704 2704 LLVector3 pos2 = new LLVector3(block.Data, 0);
2705 handlerUpdateVector = OnUpdatePrimGroupPosition; 2705
2706 2706 handlerUpdateVector = OnUpdatePrimGroupPosition;
2707 if (handlerUpdateVector != null) 2707
2708 { 2708 if (handlerUpdateVector != null)
2709 2709 {
2710 handlerUpdateVector(localId, pos2, this); 2710
2711 } 2711 handlerUpdateVector(localId, pos2, this);
2712 break; 2712 }
2713 case 10: 2713 break;
2714 2714 case 10:
2715 LLQuaternion rot3 = new LLQuaternion(block.Data, 0, true); 2715
2716 2716 LLQuaternion rot3 = new LLQuaternion(block.Data, 0, true);
2717 handlerUpdatePrimRotation = OnUpdatePrimGroupRotation; 2717
2718 if (handlerUpdatePrimRotation != null) 2718 handlerUpdatePrimRotation = OnUpdatePrimGroupRotation;
2719 { 2719 if (handlerUpdatePrimRotation != null)
2720 2720 {
2721 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 2721
2722 handlerUpdatePrimRotation(localId, rot3, this); 2722 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
2723 } 2723 handlerUpdatePrimRotation(localId, rot3, this);
2724 break; 2724 }
2725 case 11: 2725 break;
2726 2726 case 11:
2727 LLVector3 pos3 = new LLVector3(block.Data, 0); 2727
2728 LLQuaternion rot4 = new LLQuaternion(block.Data, 12, true); 2728 LLVector3 pos3 = new LLVector3(block.Data, 0);
2729 2729 LLQuaternion rot4 = new LLQuaternion(block.Data, 12, true);
2730 handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation; 2730
2731 if (handlerUpdatePrimGroupRotation != null) 2731 handlerUpdatePrimGroupRotation = OnUpdatePrimGroupMouseRotation;
2732 { 2732 if (handlerUpdatePrimGroupRotation != null)
2733 2733 {
2734 //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z); 2734
2735 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W); 2735 //Console.WriteLine("new rotation position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
2736 handlerUpdatePrimGroupRotation(localId, pos3, rot4, this); 2736 // Console.WriteLine("new rotation is " + rot.X + " , " + rot.Y + " , " + rot.Z + " , " + rot.W);
2737 } 2737 handlerUpdatePrimGroupRotation(localId, pos3, rot4, this);
2738 break; 2738 }
2739 case 13: 2739 break;
2740 2740 case 13:
2741 LLVector3 scale2 = new LLVector3(block.Data, 12); 2741
2742 LLVector3 pos4 = new LLVector3(block.Data, 0); 2742 LLVector3 scale2 = new LLVector3(block.Data, 12);
2743 2743 LLVector3 pos4 = new LLVector3(block.Data, 0);
2744 handlerUpdatePrimScale = OnUpdatePrimScale; 2744
2745 if (handlerUpdatePrimScale != null) 2745 handlerUpdatePrimScale = OnUpdatePrimScale;
2746 { 2746 if (handlerUpdatePrimScale != null)
2747 2747 {
2748 //Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 2748
2749 handlerUpdatePrimScale(localId, scale2, this); 2749 //Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
2750 2750 handlerUpdatePrimScale(localId, scale2, this);
2751 // Change the position based on scale (for bug number 246) 2751
2752 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition; 2752 // Change the position based on scale (for bug number 246)
2753 // Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z); 2753 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
2754 if (handlerUpdatePrimSinglePosition != null) 2754 // Console.WriteLine("new movement position is " + pos.X + " , " + pos.Y + " , " + pos.Z);
2755 { 2755 if (handlerUpdatePrimSinglePosition != null)
2756 handlerUpdatePrimSinglePosition(localId, pos4, this); 2756 {
2757 } 2757 handlerUpdatePrimSinglePosition(localId, pos4, this);
2758 } 2758 }
2759 break; 2759 }
2760 case 29: 2760 break;
2761 LLVector3 scale5 = new LLVector3(block.Data, 12); 2761 case 29:
2762 LLVector3 pos5 = new LLVector3(block.Data, 0); 2762 LLVector3 scale5 = new LLVector3(block.Data, 12);
2763 2763 LLVector3 pos5 = new LLVector3(block.Data, 0);
2764 handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale; 2764
2765 if (handlerUpdatePrimGroupScale != null) 2765 handlerUpdatePrimGroupScale = OnUpdatePrimGroupScale;
2766 { 2766 if (handlerUpdatePrimGroupScale != null)
2767 2767 {
2768 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z ); 2768
2769 handlerUpdatePrimGroupScale(localId, scale5, this); 2769 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z );
2770 handlerUpdateVector = OnUpdatePrimGroupPosition; 2770 handlerUpdatePrimGroupScale(localId, scale5, this);
2771 2771 handlerUpdateVector = OnUpdatePrimGroupPosition;
2772 if (handlerUpdateVector != null) 2772
2773 { 2773 if (handlerUpdateVector != null)
2774 2774 {
2775 handlerUpdateVector(localId, pos5, this); 2775
2776 } 2776 handlerUpdateVector(localId, pos5, this);
2777 } 2777 }
2778 break; 2778 }
2779 case 21: 2779 break;
2780 LLVector3 scale6 = new LLVector3(block.Data, 12); 2780 case 21:
2781 LLVector3 pos6 = new LLVector3(block.Data, 0); 2781 LLVector3 scale6 = new LLVector3(block.Data, 12);
2782 2782 LLVector3 pos6 = new LLVector3(block.Data, 0);
2783 handlerUpdatePrimScale = OnUpdatePrimScale; 2783
2784 if (handlerUpdatePrimScale != null) 2784 handlerUpdatePrimScale = OnUpdatePrimScale;
2785 { 2785 if (handlerUpdatePrimScale != null)
2786 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z); 2786 {
2787 handlerUpdatePrimScale(localId, scale6, this); 2787 // Console.WriteLine("new scale is " + scale.X + " , " + scale.Y + " , " + scale.Z);
2788 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition; 2788 handlerUpdatePrimScale(localId, scale6, this);
2789 if (handlerUpdatePrimSinglePosition != null) 2789 handlerUpdatePrimSinglePosition = OnUpdatePrimSinglePosition;
2790 { 2790 if (handlerUpdatePrimSinglePosition != null)
2791 handlerUpdatePrimSinglePosition(localId, pos6, this); 2791 {
2792 } 2792 handlerUpdatePrimSinglePosition(localId, pos6, this);
2793 } 2793 }
2794 break; 2794 }
2795 } 2795 break;
2796 } 2796 }
2797 } 2797 }
2798 } 2798 }
2799 return true; 2799 }
2800 } 2800 return true;
2801 2801 }
2802 public void RequestMapLayer() 2802
2803 { 2803 public void RequestMapLayer()
2804 //should be getting the map layer from the grid server 2804 {
2805 //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area) 2805 //should be getting the map layer from the grid server
2806 MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply); 2806 //send a layer covering the 800,800 - 1200,1200 area (should be covering the requested area)
2807 // TODO: don't create new blocks if recycling an old packet 2807 MapLayerReplyPacket mapReply = (MapLayerReplyPacket)PacketPool.Instance.GetPacket(PacketType.MapLayerReply);
2808 mapReply.AgentData.AgentID = AgentId; 2808 // TODO: don't create new blocks if recycling an old packet
2809 mapReply.AgentData.Flags = 0; 2809 mapReply.AgentData.AgentID = AgentId;
2810 mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1]; 2810 mapReply.AgentData.Flags = 0;
2811 mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock(); 2811 mapReply.LayerData = new MapLayerReplyPacket.LayerDataBlock[1];
2812 mapReply.LayerData[0].Bottom = 0; 2812 mapReply.LayerData[0] = new MapLayerReplyPacket.LayerDataBlock();
2813 mapReply.LayerData[0].Left = 0; 2813 mapReply.LayerData[0].Bottom = 0;
2814 mapReply.LayerData[0].Top = 30000; 2814 mapReply.LayerData[0].Left = 0;
2815 mapReply.LayerData[0].Right = 30000; 2815 mapReply.LayerData[0].Top = 30000;
2816 mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-1111-9999-000000000006"); 2816 mapReply.LayerData[0].Right = 30000;
2817 OutPacket(mapReply, ThrottleOutPacketType.Land); 2817 mapReply.LayerData[0].ImageID = new LLUUID("00000000-0000-1111-9999-000000000006");
2818 } 2818 OutPacket(mapReply, ThrottleOutPacketType.Land);
2819 2819 }
2820 public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY) 2820
2821 { 2821 public void RequestMapBlocksX(int minX, int minY, int maxX, int maxY)
2822 /* 2822 {
2823 IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY); 2823 /*
2824 MapBlockReplyPacket mbReply = new MapBlockReplyPacket(); 2824 IList simMapProfiles = m_gridServer.RequestMapBlocks(minX, minY, maxX, maxY);
2825 mbReply.AgentData.AgentId = this.AgentId; 2825 MapBlockReplyPacket mbReply = new MapBlockReplyPacket();
2826 int len; 2826 mbReply.AgentData.AgentId = this.AgentId;
2827 if (simMapProfiles == null) 2827 int len;
2828 len = 0; 2828 if (simMapProfiles == null)
2829 else 2829 len = 0;
2830 len = simMapProfiles.Count; 2830 else
2831 2831 len = simMapProfiles.Count;
2832 mbReply.Data = new MapBlockReplyPacket.DataBlock[len]; 2832
2833 int iii; 2833 mbReply.Data = new MapBlockReplyPacket.DataBlock[len];
2834 for (iii = 0; iii < len; iii++) 2834 int iii;
2835 { 2835 for (iii = 0; iii < len; iii++)
2836 Hashtable mp = (Hashtable)simMapProfiles[iii]; 2836 {
2837 mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock(); 2837 Hashtable mp = (Hashtable)simMapProfiles[iii];
2838 mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]); 2838 mbReply.Data[iii] = new MapBlockReplyPacket.DataBlock();
2839 mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]); 2839 mbReply.Data[iii].Name = System.Text.Encoding.UTF8.GetBytes((string)mp["name"]);
2840 mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]); 2840 mbReply.Data[iii].Access = System.Convert.ToByte(mp["access"]);
2841 mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]); 2841 mbReply.Data[iii].Agents = System.Convert.ToByte(mp["agents"]);
2842 mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]); 2842 mbReply.Data[iii].MapImageID = new LLUUID((string)mp["map-image-id"]);
2843 mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]); 2843 mbReply.Data[iii].RegionFlags = System.Convert.ToUInt32(mp["region-flags"]);
2844 mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]); 2844 mbReply.Data[iii].WaterHeight = System.Convert.ToByte(mp["water-height"]);
2845 mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]); 2845 mbReply.Data[iii].X = System.Convert.ToUInt16(mp["x"]);
2846 } 2846 mbReply.Data[iii].Y = System.Convert.ToUInt16(mp["y"]);
2847 this.OutPacket(mbReply, ThrottleOutPacketType.Land); 2847 }
2848 */ 2848 this.OutPacket(mbReply, ThrottleOutPacketType.Land);
2849 } 2849 */
2850 2850 }
2851 public byte[] GetThrottlesPacked(float multiplier) 2851
2852 { 2852 public byte[] GetThrottlesPacked(float multiplier)
2853 return m_packetQueue.GetThrottlesPacked(multiplier); 2853 {
2854 } 2854 return m_packetQueue.GetThrottlesPacked(multiplier);
2855 2855 }
2856 public void SetChildAgentThrottle(byte[] throttles) 2856
2857 { 2857 public void SetChildAgentThrottle(byte[] throttles)
2858 m_packetQueue.SetThrottleFromClient(throttles); 2858 {
2859 } 2859 m_packetQueue.SetThrottleFromClient(throttles);
2860 2860 }
2861 // Previously ClientView.m_packetQueue 2861
2862 2862 // Previously ClientView.m_packetQueue
2863 // A thread safe sequence number allocator. 2863
2864 protected uint NextSeqNum() 2864 // A thread safe sequence number allocator.
2865 { 2865 protected uint NextSeqNum()
2866 // Set the sequence number 2866 {
2867 uint seq = 1; 2867 // Set the sequence number
2868 lock (m_sequenceLock) 2868 uint seq = 1;
2869 { 2869 lock (m_sequenceLock)
2870 if (m_sequence >= MAX_SEQUENCE) 2870 {
2871 { 2871 if (m_sequence >= MAX_SEQUENCE)
2872 m_sequence = 1; 2872 {
2873 } 2873 m_sequence = 1;
2874 else 2874 }
2875 { 2875 else
2876 m_sequence++; 2876 {
2877 } 2877 m_sequence++;
2878 seq = m_sequence; 2878 }
2879 } 2879 seq = m_sequence;
2880 return seq; 2880 }
2881 } 2881 return seq;
2882 2882 }
2883 protected void AddAck(Packet Pack) 2883
2884 { 2884 protected void AddAck(Packet Pack)
2885 lock (m_needAck) 2885 {
2886 { 2886 lock (m_needAck)
2887 if (!m_needAck.ContainsKey(Pack.Header.Sequence)) 2887 {
2888 { 2888 if (!m_needAck.ContainsKey(Pack.Header.Sequence))
2889 try 2889 {
2890 { 2890 try
2891 m_needAck.Add(Pack.Header.Sequence, Pack); 2891 {
2892 m_unAckedBytes += Pack.ToBytes().Length; 2892 m_needAck.Add(Pack.Header.Sequence, Pack);
2893 } 2893 m_unAckedBytes += Pack.ToBytes().Length;
2894 catch (Exception) // HACKY 2894 }
2895 { 2895 catch (Exception) // HACKY
2896 // Ignore 2896 {
2897 // Seems to throw a exception here occasionally 2897 // Ignore
2898 // of 'duplicate key' despite being locked. 2898 // Seems to throw a exception here occasionally
2899 // !?!?!? 2899 // of 'duplicate key' despite being locked.
2900 } 2900 // !?!?!?
2901 } 2901 }
2902 else 2902 }
2903 { 2903 else
2904 // Client.Log("Attempted to add a duplicate sequence number (" + 2904 {
2905 // packet.Header.m_sequence + ") to the m_needAck dictionary for packet type " + 2905 // Client.Log("Attempted to add a duplicate sequence number (" +
2906 // packet.Type.ToString(), Helpers.LogLevel.Warning); 2906 // packet.Header.m_sequence + ") to the m_needAck dictionary for packet type " +
2907 } 2907 // packet.Type.ToString(), Helpers.LogLevel.Warning);
2908 } 2908 }
2909 } 2909 }
2910 2910 }
2911 protected virtual void SetPendingAcks(ref Packet Pack) 2911
2912 { 2912 protected virtual void SetPendingAcks(ref Packet Pack)
2913 // Append any ACKs that need to be sent out to this packet 2913 {
2914 lock (m_pendingAcks) 2914 // Append any ACKs that need to be sent out to this packet
2915 { 2915 lock (m_pendingAcks)
2916 // TODO: If we are over MAX_APPENDED_ACKS we should drain off some of these 2916 {
2917 if (m_pendingAcks.Count > 0 && m_pendingAcks.Count < MAX_APPENDED_ACKS) 2917 // TODO: If we are over MAX_APPENDED_ACKS we should drain off some of these
2918 { 2918 if (m_pendingAcks.Count > 0 && m_pendingAcks.Count < MAX_APPENDED_ACKS)
2919 Pack.Header.AckList = new uint[m_pendingAcks.Count]; 2919 {
2920 int i = 0; 2920 Pack.Header.AckList = new uint[m_pendingAcks.Count];
2921 2921 int i = 0;
2922 foreach (uint ack in m_pendingAcks.Values) 2922
2923 { 2923 foreach (uint ack in m_pendingAcks.Values)
2924 Pack.Header.AckList[i] = ack; 2924 {
2925 i++; 2925 Pack.Header.AckList[i] = ack;
2926 } 2926 i++;
2927 2927 }
2928 m_pendingAcks.Clear(); 2928
2929 Pack.Header.AppendedAcks = true; 2929 m_pendingAcks.Clear();
2930 } 2930 Pack.Header.AppendedAcks = true;
2931 } 2931 }
2932 } 2932 }
2933 2933 }
2934 protected virtual void ProcessOutPacket(Packet Pack) 2934
2935 { 2935 protected virtual void ProcessOutPacket(Packet Pack)
2936 // Keep track of when this packet was sent out 2936 {
2937 Pack.TickCount = System.Environment.TickCount; 2937 // Keep track of when this packet was sent out
2938 2938 Pack.TickCount = System.Environment.TickCount;
2939 if (!Pack.Header.Resent) 2939
2940 { 2940 if (!Pack.Header.Resent)
2941 Pack.Header.Sequence = NextSeqNum(); 2941 {
2942 2942 Pack.Header.Sequence = NextSeqNum();
2943 if (Pack.Header.Reliable) //DIRTY HACK 2943
2944 { 2944 if (Pack.Header.Reliable) //DIRTY HACK
2945 AddAck(Pack); // this adds the need to ack this packet later 2945 {
2946 2946 AddAck(Pack); // this adds the need to ack this packet later
2947 if (Pack.Type != PacketType.PacketAck && Pack.Type != PacketType.LogoutRequest) 2947
2948 { 2948 if (Pack.Type != PacketType.PacketAck && Pack.Type != PacketType.LogoutRequest)
2949 SetPendingAcks(ref Pack); 2949 {
2950 } 2950 SetPendingAcks(ref Pack);
2951 } 2951 }
2952 } 2952 }
2953 2953 }
2954 // Actually make the byte array and send it 2954
2955 try 2955 // Actually make the byte array and send it
2956 { 2956 try
2957 byte[] sendbuffer = Pack.ToBytes(); 2957 {
2958 PacketPool.Instance.ReturnPacket(Pack); 2958 byte[] sendbuffer = Pack.ToBytes();
2959 2959 PacketPool.Instance.ReturnPacket(Pack);
2960 if (Pack.Header.Zerocoded) 2960
2961 { 2961 if (Pack.Header.Zerocoded)
2962 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer); 2962 {
2963 m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode); 2963 int packetsize = Helpers.ZeroEncode(sendbuffer, sendbuffer.Length, ZeroOutBuffer);
2964 } 2964 m_networkServer.SendPacketTo(ZeroOutBuffer, packetsize, SocketFlags.None, m_circuitCode);
2965 else 2965 }
2966 { 2966 else
2967 //Need some extra space in case we need to add proxy information to the message later 2967 {
2968 Buffer.BlockCopy(sendbuffer, 0, ZeroOutBuffer, 0, sendbuffer.Length); 2968 //Need some extra space in case we need to add proxy information to the message later
2969 m_networkServer.SendPacketTo(ZeroOutBuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode); 2969 Buffer.BlockCopy(sendbuffer, 0, ZeroOutBuffer, 0, sendbuffer.Length);
2970 } 2970 m_networkServer.SendPacketTo(ZeroOutBuffer, sendbuffer.Length, SocketFlags.None, m_circuitCode);
2971 } 2971 }
2972 catch (Exception e) 2972 }
2973 { 2973 catch (Exception e)
2974 m_log.Warn("[client]: " + 2974 {
2975 "ClientView.m_packetQueue.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " + 2975 m_log.Warn("[client]: " +
2976 m_userEndPoint.ToString() + " - killing thread"); 2976 "ClientView.m_packetQueue.cs:ProcessOutPacket() - WARNING: Socket exception occurred on connection " +
2977 m_log.Error(e.ToString()); 2977 m_userEndPoint.ToString() + " - killing thread");
2978 Close(true); 2978 m_log.Error(e.ToString());
2979 } 2979 Close(true);
2980 } 2980 }
2981 2981 }
2982 public virtual void InPacket(Packet NewPack) 2982
2983 { 2983 public virtual void InPacket(Packet NewPack)
2984 if (!m_packetProcessingEnabled && NewPack.Type != PacketType.LogoutRequest) 2984 {
2985 { 2985 if (!m_packetProcessingEnabled && NewPack.Type != PacketType.LogoutRequest)
2986 PacketPool.Instance.ReturnPacket(NewPack); 2986 {
2987 return; 2987 PacketPool.Instance.ReturnPacket(NewPack);
2988 } 2988 return;
2989 2989 }
2990 // Handle appended ACKs 2990
2991 if (NewPack != null) 2991 // Handle appended ACKs
2992 { 2992 if (NewPack != null)
2993 if (NewPack.Header.AppendedAcks) 2993 {
2994 { 2994 if (NewPack.Header.AppendedAcks)
2995 lock (m_needAck) 2995 {
2996 { 2996 lock (m_needAck)
2997 foreach (uint ackedPacketId in NewPack.Header.AckList) 2997 {
2998 { 2998 foreach (uint ackedPacketId in NewPack.Header.AckList)
2999 Packet ackedPacket; 2999 {
3000 3000 Packet ackedPacket;
3001 if (m_needAck.TryGetValue(ackedPacketId, out ackedPacket)) 3001
3002 { 3002 if (m_needAck.TryGetValue(ackedPacketId, out ackedPacket))
3003 m_unAckedBytes -= ackedPacket.ToBytes().Length; 3003 {
3004 m_needAck.Remove(ackedPacketId); 3004 m_unAckedBytes -= ackedPacket.ToBytes().Length;
3005 } 3005 m_needAck.Remove(ackedPacketId);
3006 } 3006 }
3007 } 3007 }
3008 } 3008 }
3009 3009 }
3010 // Handle PacketAck packets 3010
3011 if (NewPack.Type == PacketType.PacketAck) 3011 // Handle PacketAck packets
3012 { 3012 if (NewPack.Type == PacketType.PacketAck)
3013 PacketAckPacket ackPacket = (PacketAckPacket)NewPack; 3013 {
3014 3014 PacketAckPacket ackPacket = (PacketAckPacket)NewPack;
3015 lock (m_needAck) 3015
3016 { 3016 lock (m_needAck)
3017 foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets) 3017 {
3018 { 3018 foreach (PacketAckPacket.PacketsBlock block in ackPacket.Packets)
3019 uint ackedPackId = block.ID; 3019 {
3020 Packet ackedPacket; 3020 uint ackedPackId = block.ID;
3021 if (m_needAck.TryGetValue(ackedPackId, out ackedPacket)) 3021 Packet ackedPacket;
3022 { 3022 if (m_needAck.TryGetValue(ackedPackId, out ackedPacket))
3023 m_unAckedBytes -= ackedPacket.ToBytes().Length; 3023 {
3024 m_needAck.Remove(ackedPackId); 3024 m_unAckedBytes -= ackedPacket.ToBytes().Length;
3025 } 3025 m_needAck.Remove(ackedPackId);
3026 } 3026 }
3027 } 3027 }
3028 } 3028 }
3029 else if ((NewPack.Type == PacketType.StartPingCheck)) 3029 }
3030 { 3030 else if ((NewPack.Type == PacketType.StartPingCheck))
3031 //reply to pingcheck 3031 {
3032 StartPingCheckPacket startPing = (StartPingCheckPacket)NewPack; 3032 //reply to pingcheck
3033 CompletePingCheckPacket endPing = (CompletePingCheckPacket)PacketPool.Instance.GetPacket(PacketType.CompletePingCheck); 3033 StartPingCheckPacket startPing = (StartPingCheckPacket)NewPack;
3034 endPing.PingID.PingID = startPing.PingID.PingID; 3034 CompletePingCheckPacket endPing = (CompletePingCheckPacket)PacketPool.Instance.GetPacket(PacketType.CompletePingCheck);
3035 OutPacket(endPing, ThrottleOutPacketType.Task); 3035 endPing.PingID.PingID = startPing.PingID.PingID;
3036 } 3036 OutPacket(endPing, ThrottleOutPacketType.Task);
3037 else 3037 }
3038 { 3038 else
3039 QueItem item = new QueItem(); 3039 {
3040 item.Packet = NewPack; 3040 LLQueItem item = new LLQueItem();
3041 item.Incoming = true; 3041 item.Packet = NewPack;
3042 m_packetQueue.Enqueue(item); 3042 item.Incoming = true;
3043 } 3043 m_packetQueue.Enqueue(item);
3044 } 3044 }
3045 } 3045 }
3046 3046 }
3047 public virtual void OutPacket(Packet NewPack, ThrottleOutPacketType throttlePacketType) 3047
3048 { 3048 public virtual void OutPacket(Packet NewPack, ThrottleOutPacketType throttlePacketType)
3049 if ((SynchronizeClient != null) && (!PacketProcessingEnabled)) 3049 {
3050 { 3050 if ((SynchronizeClient != null) && (!IsActive))
3051 // Sending packet to active client's server. 3051 {
3052 if (SynchronizeClient(m_scene, NewPack, m_agentId, throttlePacketType)) 3052 // Sending packet to active client's server.
3053 { 3053 if (SynchronizeClient(m_scene, NewPack, m_agentId, throttlePacketType))
3054 return; 3054 {
3055 } 3055 return;
3056 } 3056 }
3057 3057 }
3058 QueItem item = new QueItem(); 3058
3059 item.Packet = NewPack; 3059 LLQueItem item = new LLQueItem();
3060 item.Incoming = false; 3060 item.Packet = NewPack;
3061 item.throttleType = throttlePacketType; // Packet throttle type 3061 item.Incoming = false;
3062 m_packetQueue.Enqueue(item); 3062 item.throttleType = throttlePacketType; // Packet throttle type
3063 m_packetsSent++; 3063 m_packetQueue.Enqueue(item);
3064 } 3064 m_packetsSent++;
3065 3065 }
3066 # region Low Level Packet Methods 3066
3067 3067 # region Low Level Packet Methods
3068 protected void ack_pack(Packet Pack) 3068
3069 { 3069 protected void ack_pack(Packet Pack)
3070 if (Pack.Header.Reliable) 3070 {
3071 { 3071 if (Pack.Header.Reliable)
3072 PacketAckPacket ack_it = (PacketAckPacket)PacketPool.Instance.GetPacket(PacketType.PacketAck); 3072 {
3073 // TODO: don't create new blocks if recycling an old packet 3073 PacketAckPacket ack_it = (PacketAckPacket)PacketPool.Instance.GetPacket(PacketType.PacketAck);
3074 ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; 3074 // TODO: don't create new blocks if recycling an old packet
3075 ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); 3075 ack_it.Packets = new PacketAckPacket.PacketsBlock[1];
3076 ack_it.Packets[0].ID = Pack.Header.Sequence; 3076 ack_it.Packets[0] = new PacketAckPacket.PacketsBlock();
3077 ack_it.Header.Reliable = false; 3077 ack_it.Packets[0].ID = Pack.Header.Sequence;
3078 3078 ack_it.Header.Reliable = false;
3079 OutPacket(ack_it, ThrottleOutPacketType.Unknown); 3079
3080 } 3080 OutPacket(ack_it, ThrottleOutPacketType.Unknown);
3081 /* 3081 }
3082 if (Pack.Header.Reliable) 3082 /*
3083 { 3083 if (Pack.Header.Reliable)
3084 lock (m_pendingAcks) 3084 {
3085 { 3085 lock (m_pendingAcks)
3086 uint sequence = (uint)Pack.Header.m_sequence; 3086 {
3087 if (!m_pendingAcks.ContainsKey(sequence)) { m_pendingAcks[sequence] = sequence; } 3087 uint sequence = (uint)Pack.Header.m_sequence;
3088 } 3088 if (!m_pendingAcks.ContainsKey(sequence)) { m_pendingAcks[sequence] = sequence; }
3089 }*/ 3089 }
3090 } 3090 }*/
3091 3091 }
3092 protected void ResendUnacked() 3092
3093 { 3093 protected void ResendUnacked()
3094 int now = System.Environment.TickCount; 3094 {
3095 3095 int now = System.Environment.TickCount;
3096 lock (m_needAck) 3096
3097 { 3097 lock (m_needAck)
3098 foreach (Packet packet in m_needAck.Values) 3098 {
3099 { 3099 foreach (Packet packet in m_needAck.Values)
3100 if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent)) 3100 {
3101 { 3101 if ((now - packet.TickCount > RESEND_TIMEOUT) && (!packet.Header.Resent))
3102 //m_log.Debug("[NETWORK]: Resending " + packet.Type.ToString() + " packet, " + 3102 {
3103 //(now - packet.TickCount) + "ms have passed"); 3103 //m_log.Debug("[NETWORK]: Resending " + packet.Type.ToString() + " packet, " +
3104 3104 //(now - packet.TickCount) + "ms have passed");
3105 packet.Header.Resent = true; 3105
3106 OutPacket(packet, ThrottleOutPacketType.Resend); 3106 packet.Header.Resent = true;
3107 } 3107 OutPacket(packet, ThrottleOutPacketType.Resend);
3108 } 3108 }
3109 } 3109 }
3110 } 3110 }
3111 3111 }
3112 protected void SendAcks() 3112
3113 { 3113 protected void SendAcks()
3114 lock (m_pendingAcks) 3114 {
3115 { 3115 lock (m_pendingAcks)
3116 if (m_pendingAcks.Count > 0) 3116 {
3117 { 3117 if (m_pendingAcks.Count > 0)
3118 if (m_pendingAcks.Count > 250) 3118 {
3119 { 3119 if (m_pendingAcks.Count > 250)
3120 // FIXME: Handle the odd case where we have too many pending ACKs queued up 3120 {
3121 m_log.Info("[NETWORK]: Too many ACKs queued up!"); 3121 // FIXME: Handle the odd case where we have too many pending ACKs queued up
3122 return; 3122 m_log.Info("[NETWORK]: Too many ACKs queued up!");
3123 } 3123 return;
3124 3124 }
3125 //m_log.Info("[NETWORK]: Sending PacketAck"); 3125
3126 3126 //m_log.Info("[NETWORK]: Sending PacketAck");
3127 int i = 0; 3127
3128 PacketAckPacket acks = (PacketAckPacket)PacketPool.Instance.GetPacket(PacketType.PacketAck); 3128 int i = 0;
3129 // TODO: don't create new blocks if recycling an old packet 3129 PacketAckPacket acks = (PacketAckPacket)PacketPool.Instance.GetPacket(PacketType.PacketAck);
3130 acks.Packets = new PacketAckPacket.PacketsBlock[m_pendingAcks.Count]; 3130 // TODO: don't create new blocks if recycling an old packet
3131 3131 acks.Packets = new PacketAckPacket.PacketsBlock[m_pendingAcks.Count];
3132 foreach (uint ack in m_pendingAcks.Values) 3132
3133 { 3133 foreach (uint ack in m_pendingAcks.Values)
3134 acks.Packets[i] = new PacketAckPacket.PacketsBlock(); 3134 {
3135 acks.Packets[i].ID = ack; 3135 acks.Packets[i] = new PacketAckPacket.PacketsBlock();
3136 i++; 3136 acks.Packets[i].ID = ack;
3137 } 3137 i++;
3138 3138 }
3139 acks.Header.Reliable = false; 3139
3140 OutPacket(acks, ThrottleOutPacketType.Unknown); 3140 acks.Header.Reliable = false;
3141 3141 OutPacket(acks, ThrottleOutPacketType.Unknown);
3142 m_pendingAcks.Clear(); 3142
3143 } 3143 m_pendingAcks.Clear();
3144 } 3144 }
3145 } 3145 }
3146 3146 }
3147 protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea) 3147
3148 { 3148 protected void AckTimer_Elapsed(object sender, ElapsedEventArgs ea)
3149 3149 {
3150 SendAcks(); 3150
3151 ResendUnacked(); 3151 SendAcks();
3152 SendPacketStats(); 3152 ResendUnacked();
3153 3153 SendPacketStats();
3154 } 3154
3155 3155 }
3156 protected void SendPacketStats() 3156
3157 { 3157 protected void SendPacketStats()
3158 handlerPacketStats = OnPacketStats; 3158 {
3159 if (handlerPacketStats != null) 3159 handlerPacketStats = OnPacketStats;
3160 { 3160 if (handlerPacketStats != null)
3161 handlerPacketStats(m_packetsReceived - m_lastPacketsReceivedSentToScene, m_packetsSent - m_lastPacketsSentSentToScene, m_unAckedBytes); 3161 {
3162 m_lastPacketsReceivedSentToScene = m_packetsReceived; 3162 handlerPacketStats(m_packetsReceived - m_lastPacketsReceivedSentToScene, m_packetsSent - m_lastPacketsSentSentToScene, m_unAckedBytes);
3163 m_lastPacketsSentSentToScene = m_packetsSent; 3163 m_lastPacketsReceivedSentToScene = m_packetsReceived;
3164 } 3164 m_lastPacketsSentSentToScene = m_packetsSent;
3165 } 3165 }
3166 3166 }
3167 #endregion 3167
3168 3168 #endregion
3169 // Previously ClientView.ProcessPackets 3169
3170 3170 // Previously ClientView.ProcessPackets
3171 public bool AddMoney(int debit) 3171
3172 { 3172 public bool AddMoney(int debit)
3173 if (m_moneyBalance + debit >= 0) 3173 {
3174 { 3174 if (m_moneyBalance + debit >= 0)
3175 m_moneyBalance += debit; 3175 {
3176 SendMoneyBalance(LLUUID.Zero, true, Helpers.StringToField("Poof Poof!"), m_moneyBalance); 3176 m_moneyBalance += debit;
3177 return true; 3177 SendMoneyBalance(LLUUID.Zero, true, Helpers.StringToField("Poof Poof!"), m_moneyBalance);
3178 } 3178 return true;
3179 else 3179 }
3180 { 3180 else
3181 return false; 3181 {
3182 } 3182 return false;
3183 } 3183 }
3184 3184 }
3185 private bool m_packetProcessingEnabled = true; 3185
3186 3186 private bool m_packetProcessingEnabled = true;
3187 public bool PacketProcessingEnabled { 3187
3188 get { return m_packetProcessingEnabled; } 3188 public bool IsActive {
3189 set { m_packetProcessingEnabled = value; } 3189 get { return m_packetProcessingEnabled; }
3190 } 3190 set { m_packetProcessingEnabled = value; }
3191 3191 }
3192 protected void ProcessInPacket(Packet Pack) 3192
3193 { 3193 protected void ProcessInPacket(Packet Pack)
3194 ack_pack(Pack); 3194 {
3195 3195 ack_pack(Pack);
3196 if (ProcessPacketMethod(Pack)) 3196
3197 { 3197 if (ProcessPacketMethod(Pack))
3198 //there is a handler registered that handled this packet type 3198 {
3199 return; 3199 //there is a handler registered that handled this packet type
3200 } 3200 return;
3201 else 3201 }
3202 { 3202 else
3203 switch (Pack.Type) 3203 {
3204 { 3204 switch (Pack.Type)
3205 #region Scene/Avatar 3205 {
3206 3206 #region Scene/Avatar
3207 case PacketType.AvatarPropertiesRequest: 3207
3208 AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack; 3208 case PacketType.AvatarPropertiesRequest:
3209 3209 AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket)Pack;
3210 handlerRequestAvatarProperties = OnRequestAvatarProperties; 3210
3211 if (handlerRequestAvatarProperties != null) 3211 handlerRequestAvatarProperties = OnRequestAvatarProperties;
3212 { 3212 if (handlerRequestAvatarProperties != null)
3213 handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID); 3213 {
3214 } 3214 handlerRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID);
3215 3215 }
3216 break; 3216
3217 case PacketType.ChatFromViewer: 3217 break;
3218 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; 3218 case PacketType.ChatFromViewer:
3219 3219 ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack;
3220 string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname; 3220
3221 byte[] message = inchatpack.ChatData.Message; 3221 string fromName = String.Empty; //ClientAvatar.firstname + " " + ClientAvatar.lastname;
3222 byte type = inchatpack.ChatData.Type; 3222 byte[] message = inchatpack.ChatData.Message;
3223 LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos; 3223 byte type = inchatpack.ChatData.Type;
3224 LLUUID fromAgentID = AgentId; 3224 LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos;
3225 3225 LLUUID fromAgentID = AgentId;
3226 int channel = inchatpack.ChatData.Channel; 3226
3227 3227 int channel = inchatpack.ChatData.Channel;
3228 if (OnChatFromViewer != null) 3228
3229 { 3229 if (OnChatFromViewer != null)
3230 ChatFromViewerArgs args = new ChatFromViewerArgs(); 3230 {
3231 args.Channel = channel; 3231 ChatFromViewerArgs args = new ChatFromViewerArgs();
3232 args.From = fromName; 3232 args.Channel = channel;
3233 args.Message = Helpers.FieldToUTF8String(message); 3233 args.From = fromName;
3234 args.Type = (ChatTypeEnum)type; 3234 args.Message = Helpers.FieldToUTF8String(message);
3235 args.Position = fromPos; 3235 args.Type = (ChatTypeEnum)type;
3236 3236 args.Position = fromPos;
3237 args.Scene = Scene; 3237
3238 args.Sender = this; 3238 args.Scene = Scene;
3239 3239 args.Sender = this;
3240 handlerChatFromViewer = OnChatFromViewer; 3240
3241 if (handlerChatFromViewer != null) 3241 handlerChatFromViewer = OnChatFromViewer;
3242 handlerChatFromViewer(this, args); 3242 if (handlerChatFromViewer != null)
3243 } 3243 handlerChatFromViewer(this, args);
3244 break; 3244 }
3245 case PacketType.AvatarPropertiesUpdate: 3245 break;
3246 AvatarPropertiesUpdatePacket Packet = (AvatarPropertiesUpdatePacket)Pack; 3246 case PacketType.AvatarPropertiesUpdate:
3247 3247 AvatarPropertiesUpdatePacket Packet = (AvatarPropertiesUpdatePacket)Pack;
3248 handlerUpdateAvatarProperties = OnUpdateAvatarProperties; 3248
3249 if (handlerUpdateAvatarProperties != null) 3249 handlerUpdateAvatarProperties = OnUpdateAvatarProperties;
3250 { 3250 if (handlerUpdateAvatarProperties != null)
3251 AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = Packet.PropertiesData; 3251 {
3252 UserProfileData UserProfile = new UserProfileData(); 3252 AvatarPropertiesUpdatePacket.PropertiesDataBlock Properties = Packet.PropertiesData;
3253 UserProfile.ID = AgentId; 3253 UserProfileData UserProfile = new UserProfileData();
3254 UserProfile.AboutText = Helpers.FieldToUTF8String(Properties.AboutText); 3254 UserProfile.ID = AgentId;
3255 UserProfile.FirstLifeAboutText = Helpers.FieldToUTF8String(Properties.FLAboutText); 3255 UserProfile.AboutText = Helpers.FieldToUTF8String(Properties.AboutText);
3256 UserProfile.FirstLifeImage = Properties.FLImageID; 3256 UserProfile.FirstLifeAboutText = Helpers.FieldToUTF8String(Properties.FLAboutText);
3257 UserProfile.Image = Properties.ImageID; 3257 UserProfile.FirstLifeImage = Properties.FLImageID;
3258 3258 UserProfile.Image = Properties.ImageID;
3259 handlerUpdateAvatarProperties(this, UserProfile); 3259
3260 } 3260 handlerUpdateAvatarProperties(this, UserProfile);
3261 break; 3261 }
3262 3262 break;
3263 case PacketType.ScriptDialogReply: 3263
3264 ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack; 3264 case PacketType.ScriptDialogReply:
3265 int ch = rdialog.Data.ChatChannel; 3265 ScriptDialogReplyPacket rdialog = (ScriptDialogReplyPacket)Pack;
3266 byte[] msg = rdialog.Data.ButtonLabel; 3266 int ch = rdialog.Data.ChatChannel;
3267 if (OnChatFromViewer != null) 3267 byte[] msg = rdialog.Data.ButtonLabel;
3268 { 3268 if (OnChatFromViewer != null)
3269 ChatFromViewerArgs args = new ChatFromViewerArgs(); 3269 {
3270 args.Channel = ch; 3270 ChatFromViewerArgs args = new ChatFromViewerArgs();
3271 args.From = String.Empty; 3271 args.Channel = ch;
3272 args.Message = Helpers.FieldToUTF8String(msg); 3272 args.From = String.Empty;
3273 args.Type = ChatTypeEnum.Shout; 3273 args.Message = Helpers.FieldToUTF8String(msg);
3274 args.Position = new LLVector3(); 3274 args.Type = ChatTypeEnum.Shout;
3275 args.Scene = Scene; 3275 args.Position = new LLVector3();
3276 args.Sender = this; 3276 args.Scene = Scene;
3277 handlerChatFromViewer2 = OnChatFromViewer; 3277 args.Sender = this;
3278 if (handlerChatFromViewer2 != null) 3278 handlerChatFromViewer2 = OnChatFromViewer;
3279 handlerChatFromViewer2(this, args); 3279 if (handlerChatFromViewer2 != null)
3280 } 3280 handlerChatFromViewer2(this, args);
3281 3281 }
3282 break; 3282
3283 case PacketType.ImprovedInstantMessage: 3283 break;
3284 ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack; 3284 case PacketType.ImprovedInstantMessage:
3285 string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); 3285 ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack;
3286 string IMmessage = Helpers.FieldToUTF8String(msgpack.MessageBlock.Message); 3286 string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName);
3287 handlerInstantMessage = OnInstantMessage; 3287 string IMmessage = Helpers.FieldToUTF8String(msgpack.MessageBlock.Message);
3288 3288 handlerInstantMessage = OnInstantMessage;
3289 if (handlerInstantMessage != null) 3289
3290 { 3290 if (handlerInstantMessage != null)
3291 handlerInstantMessage(this, msgpack.AgentData.AgentID, msgpack.AgentData.SessionID, 3291 {
3292 msgpack.MessageBlock.ToAgentID, msgpack.MessageBlock.ID, 3292 handlerInstantMessage(this, msgpack.AgentData.AgentID, msgpack.AgentData.SessionID,
3293 msgpack.MessageBlock.Timestamp, IMfromName, IMmessage, 3293 msgpack.MessageBlock.ToAgentID, msgpack.MessageBlock.ID,
3294 msgpack.MessageBlock.Dialog, msgpack.MessageBlock.FromGroup, 3294 msgpack.MessageBlock.Timestamp, IMfromName, IMmessage,
3295 msgpack.MessageBlock.Offline, msgpack.MessageBlock.ParentEstateID, 3295 msgpack.MessageBlock.Dialog, msgpack.MessageBlock.FromGroup,
3296 msgpack.MessageBlock.Position, msgpack.MessageBlock.RegionID, 3296 msgpack.MessageBlock.Offline, msgpack.MessageBlock.ParentEstateID,
3297 msgpack.MessageBlock.BinaryBucket); 3297 msgpack.MessageBlock.Position, msgpack.MessageBlock.RegionID,
3298 } 3298 msgpack.MessageBlock.BinaryBucket);
3299 break; 3299 }
3300 3300 break;
3301 case PacketType.AcceptFriendship: 3301
3302 AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack; 3302 case PacketType.AcceptFriendship:
3303 3303 AcceptFriendshipPacket afriendpack = (AcceptFriendshipPacket)Pack;
3304 // My guess is this is the folder to stick the calling card into 3304
3305 List<LLUUID> callingCardFolders = new List<LLUUID>(); 3305 // My guess is this is the folder to stick the calling card into
3306 3306 List<LLUUID> callingCardFolders = new List<LLUUID>();
3307 LLUUID agentID = afriendpack.AgentData.AgentID; 3307
3308 LLUUID transactionID = afriendpack.TransactionBlock.TransactionID; 3308 LLUUID agentID = afriendpack.AgentData.AgentID;
3309 3309 LLUUID transactionID = afriendpack.TransactionBlock.TransactionID;
3310 for (int fi = 0; fi < afriendpack.FolderData.Length; fi++) 3310
3311 { 3311 for (int fi = 0; fi < afriendpack.FolderData.Length; fi++)
3312 callingCardFolders.Add(afriendpack.FolderData[fi].FolderID); 3312 {
3313 } 3313 callingCardFolders.Add(afriendpack.FolderData[fi].FolderID);
3314 3314 }
3315 handlerApproveFriendRequest = OnApproveFriendRequest; 3315
3316 if (handlerApproveFriendRequest != null) 3316 handlerApproveFriendRequest = OnApproveFriendRequest;
3317 { 3317 if (handlerApproveFriendRequest != null)
3318 handlerApproveFriendRequest(this, agentID, transactionID, callingCardFolders); 3318 {
3319 } 3319 handlerApproveFriendRequest(this, agentID, transactionID, callingCardFolders);
3320 break; 3320 }
3321 case PacketType.TerminateFriendship: 3321 break;
3322 TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack; 3322 case PacketType.TerminateFriendship:
3323 LLUUID listOwnerAgentID = tfriendpack.AgentData.AgentID; 3323 TerminateFriendshipPacket tfriendpack = (TerminateFriendshipPacket)Pack;
3324 LLUUID exFriendID = tfriendpack.ExBlock.OtherID; 3324 LLUUID listOwnerAgentID = tfriendpack.AgentData.AgentID;
3325 3325 LLUUID exFriendID = tfriendpack.ExBlock.OtherID;
3326 handlerTerminateFriendship = OnTerminateFriendship; 3326
3327 if (handlerTerminateFriendship != null) 3327 handlerTerminateFriendship = OnTerminateFriendship;
3328 { 3328 if (handlerTerminateFriendship != null)
3329 handlerTerminateFriendship(this, listOwnerAgentID, exFriendID); 3329 {
3330 } 3330 handlerTerminateFriendship(this, listOwnerAgentID, exFriendID);
3331 break; 3331 }
3332 case PacketType.RezObject: 3332 break;
3333 RezObjectPacket rezPacket = (RezObjectPacket)Pack; 3333 case PacketType.RezObject:
3334 3334 RezObjectPacket rezPacket = (RezObjectPacket)Pack;
3335 handlerRezObject = OnRezObject; 3335
3336 if (handlerRezObject != null) 3336 handlerRezObject = OnRezObject;
3337 { 3337 if (handlerRezObject != null)
3338 //rezPacket.RezData.BypassRaycast; 3338 {
3339 //rezPacket.RezData.RayEnd; 3339 //rezPacket.RezData.BypassRaycast;
3340 //rezPacket.RezData.RayEndIsIntersection; 3340 //rezPacket.RezData.RayEnd;
3341 //rezPacket.RezData.RayStart; 3341 //rezPacket.RezData.RayEndIsIntersection;
3342 //rezPacket.RezData.RayTargetID; 3342 //rezPacket.RezData.RayStart;
3343 //rezPacket.RezData.RemoveItem; 3343 //rezPacket.RezData.RayTargetID;
3344 //rezPacket.RezData.RezSelected; 3344 //rezPacket.RezData.RemoveItem;
3345 //rezPacket.RezData.FromTaskID; 3345 //rezPacket.RezData.RezSelected;
3346 //m_log.Info("[REZData]: " + rezPacket.ToString()); 3346 //rezPacket.RezData.FromTaskID;
3347 3347 //m_log.Info("[REZData]: " + rezPacket.ToString());
3348 handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd, 3348
3349 rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID, 3349 handlerRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd,
3350 rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection, 3350 rezPacket.RezData.RayStart, rezPacket.RezData.RayTargetID,
3351 rezPacket.RezData.EveryoneMask, rezPacket.RezData.GroupMask, 3351 rezPacket.RezData.BypassRaycast, rezPacket.RezData.RayEndIsIntersection,
3352 rezPacket.RezData.NextOwnerMask, rezPacket.RezData.ItemFlags, 3352 rezPacket.RezData.EveryoneMask, rezPacket.RezData.GroupMask,
3353 rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem, 3353 rezPacket.RezData.NextOwnerMask, rezPacket.RezData.ItemFlags,
3354 rezPacket.RezData.FromTaskID); 3354 rezPacket.RezData.RezSelected, rezPacket.RezData.RemoveItem,
3355 } 3355 rezPacket.RezData.FromTaskID);
3356 break; 3356 }
3357 case PacketType.DeRezObject: 3357 break;
3358 handlerDeRezObject = OnDeRezObject; 3358 case PacketType.DeRezObject:
3359 if (handlerDeRezObject != null) 3359 handlerDeRezObject = OnDeRezObject;
3360 { 3360 if (handlerDeRezObject != null)
3361 handlerDeRezObject(Pack, this); 3361 {
3362 } 3362 handlerDeRezObject(Pack, this);
3363 break; 3363 }
3364 case PacketType.ModifyLand: 3364 break;
3365 ModifyLandPacket modify = (ModifyLandPacket)Pack; 3365 case PacketType.ModifyLand:
3366 //m_log.Info("[LAND]: LAND:" + modify.ToString()); 3366 ModifyLandPacket modify = (ModifyLandPacket)Pack;
3367 if (modify.ParcelData.Length > 0) 3367 //m_log.Info("[LAND]: LAND:" + modify.ToString());
3368 { 3368 if (modify.ParcelData.Length > 0)
3369 if (OnModifyTerrain != null) 3369 {
3370 { 3370 if (OnModifyTerrain != null)
3371 for (int i = 0; i < modify.ParcelData.Length; i++) 3371 {
3372 { 3372 for (int i = 0; i < modify.ParcelData.Length; i++)
3373 handlerModifyTerrain = OnModifyTerrain; 3373 {
3374 if (handlerModifyTerrain != null) 3374 handlerModifyTerrain = OnModifyTerrain;
3375 { 3375 if (handlerModifyTerrain != null)
3376 handlerModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, 3376 {
3377 modify.ModifyBlock.BrushSize, 3377 handlerModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds,
3378 modify.ModifyBlock.Action, modify.ParcelData[i].North, 3378 modify.ModifyBlock.BrushSize,
3379 modify.ParcelData[i].West, modify.ParcelData[i].South, 3379 modify.ModifyBlock.Action, modify.ParcelData[i].North,
3380 modify.ParcelData[i].East, this); 3380 modify.ParcelData[i].West, modify.ParcelData[i].South,
3381 } 3381 modify.ParcelData[i].East, this);
3382 } 3382 }
3383 } 3383 }
3384 } 3384 }
3385 3385 }
3386 break; 3386
3387 case PacketType.RegionHandshakeReply: 3387 break;
3388 3388 case PacketType.RegionHandshakeReply:
3389 handlerRegionHandShakeReply = OnRegionHandShakeReply; 3389
3390 if (handlerRegionHandShakeReply != null) 3390 handlerRegionHandShakeReply = OnRegionHandShakeReply;
3391 { 3391 if (handlerRegionHandShakeReply != null)
3392 handlerRegionHandShakeReply(this); 3392 {
3393 } 3393 handlerRegionHandShakeReply(this);
3394 3394 }
3395 break; 3395
3396 case PacketType.AgentWearablesRequest: 3396 break;
3397 handlerRequestWearables = OnRequestWearables; 3397 case PacketType.AgentWearablesRequest:
3398 3398 handlerRequestWearables = OnRequestWearables;
3399 if (handlerRequestWearables != null) 3399
3400 { 3400 if (handlerRequestWearables != null)
3401 handlerRequestWearables(); 3401 {
3402 } 3402 handlerRequestWearables();
3403 3403 }
3404 handlerRequestAvatarsData = OnRequestAvatarsData; 3404
3405 3405 handlerRequestAvatarsData = OnRequestAvatarsData;
3406 if (handlerRequestAvatarsData != null) 3406
3407 { 3407 if (handlerRequestAvatarsData != null)
3408 handlerRequestAvatarsData(this); 3408 {
3409 } 3409 handlerRequestAvatarsData(this);
3410 3410 }
3411 break; 3411
3412 case PacketType.AgentSetAppearance: 3412 break;
3413 AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; 3413 case PacketType.AgentSetAppearance:
3414 3414 AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack;
3415 handlerSetAppearance = OnSetAppearance; 3415
3416 if (handlerSetAppearance != null) 3416 handlerSetAppearance = OnSetAppearance;
3417 { 3417 if (handlerSetAppearance != null)
3418 // Temporarily protect ourselves from the mantis #951 failure. 3418 {
3419 // However, we could do this for several other handlers where a failure isn't terminal 3419 // Temporarily protect ourselves from the mantis #951 failure.
3420 // for the client session anyway, in order to protect ourselves against bad code in plugins 3420 // However, we could do this for several other handlers where a failure isn't terminal
3421 try 3421 // for the client session anyway, in order to protect ourselves against bad code in plugins
3422 { 3422 try
3423 handlerSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam); 3423 {
3424 } 3424 handlerSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam);
3425 catch (Exception e) 3425 }
3426 { 3426 catch (Exception e)
3427 m_log.ErrorFormat( 3427 {
3428 "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}", 3428 m_log.ErrorFormat(
3429 e); 3429 "[CLIENT VIEW]: AgentSetApperance packet handler threw an exception, {0}",
3430 } 3430 e);
3431 } 3431 }
3432 3432 }
3433 break; 3433
3434 case PacketType.AgentIsNowWearing: 3434 break;
3435 if (OnAvatarNowWearing != null) 3435 case PacketType.AgentIsNowWearing:
3436 { 3436 if (OnAvatarNowWearing != null)
3437 AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack; 3437 {
3438 AvatarWearingArgs wearingArgs = new AvatarWearingArgs(); 3438 AgentIsNowWearingPacket nowWearing = (AgentIsNowWearingPacket)Pack;
3439 for (int i = 0; i < nowWearing.WearableData.Length; i++) 3439 AvatarWearingArgs wearingArgs = new AvatarWearingArgs();
3440 { 3440 for (int i = 0; i < nowWearing.WearableData.Length; i++)
3441 AvatarWearingArgs.Wearable wearable = 3441 {
3442 new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID, 3442 AvatarWearingArgs.Wearable wearable =
3443 nowWearing.WearableData[i].WearableType); 3443 new AvatarWearingArgs.Wearable(nowWearing.WearableData[i].ItemID,
3444 wearingArgs.NowWearing.Add(wearable); 3444 nowWearing.WearableData[i].WearableType);
3445 } 3445 wearingArgs.NowWearing.Add(wearable);
3446 3446 }
3447 handlerAvatarNowWearing = OnAvatarNowWearing; 3447
3448 if (handlerAvatarNowWearing != null) 3448 handlerAvatarNowWearing = OnAvatarNowWearing;
3449 { 3449 if (handlerAvatarNowWearing != null)
3450 handlerAvatarNowWearing(this, wearingArgs); 3450 {
3451 } 3451 handlerAvatarNowWearing(this, wearingArgs);
3452 } 3452 }
3453 break; 3453 }
3454 case PacketType.RezSingleAttachmentFromInv: 3454 break;
3455 handlerRezSingleAttachment = OnRezSingleAttachmentFromInv; 3455 case PacketType.RezSingleAttachmentFromInv:
3456 if (handlerRezSingleAttachment != null) 3456 handlerRezSingleAttachment = OnRezSingleAttachmentFromInv;
3457 { 3457 if (handlerRezSingleAttachment != null)
3458 RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack; 3458 {
3459 handlerRezSingleAttachment(this, rez.ObjectData.ItemID, 3459 RezSingleAttachmentFromInvPacket rez = (RezSingleAttachmentFromInvPacket)Pack;
3460 rez.ObjectData.AttachmentPt, rez.ObjectData.ItemFlags, rez.ObjectData.NextOwnerMask); 3460 handlerRezSingleAttachment(this, rez.ObjectData.ItemID,
3461 } 3461 rez.ObjectData.AttachmentPt, rez.ObjectData.ItemFlags, rez.ObjectData.NextOwnerMask);
3462 3462 }
3463 break; 3463
3464 case PacketType.DetachAttachmentIntoInv: 3464 break;
3465 handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv; 3465 case PacketType.DetachAttachmentIntoInv:
3466 if (handlerDetachAttachmentIntoInv != null) 3466 handlerDetachAttachmentIntoInv = OnDetachAttachmentIntoInv;
3467 { 3467 if (handlerDetachAttachmentIntoInv != null)
3468 DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack; 3468 {
3469 3469 DetachAttachmentIntoInvPacket detachtoInv = (DetachAttachmentIntoInvPacket)Pack;
3470 LLUUID itemID = detachtoInv.ObjectData.ItemID; 3470
3471 LLUUID ATTACH_agentID = detachtoInv.ObjectData.AgentID; 3471 LLUUID itemID = detachtoInv.ObjectData.ItemID;
3472 3472 LLUUID ATTACH_agentID = detachtoInv.ObjectData.AgentID;
3473 handlerDetachAttachmentIntoInv(itemID, this); 3473
3474 } 3474 handlerDetachAttachmentIntoInv(itemID, this);
3475 break; 3475 }
3476 case PacketType.ObjectAttach: 3476 break;
3477 if (OnObjectAttach != null) 3477 case PacketType.ObjectAttach:
3478 { 3478 if (OnObjectAttach != null)
3479 ObjectAttachPacket att = (ObjectAttachPacket)Pack; 3479 {
3480 3480 ObjectAttachPacket att = (ObjectAttachPacket)Pack;
3481 handlerObjectAttach = OnObjectAttach; 3481
3482 3482 handlerObjectAttach = OnObjectAttach;
3483 if (handlerObjectAttach != null) 3483
3484 { 3484 if (handlerObjectAttach != null)
3485 if (att.ObjectData.Length > 0) 3485 {
3486 { 3486 if (att.ObjectData.Length > 0)
3487 handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, att.ObjectData[0].Rotation); 3487 {
3488 } 3488 handlerObjectAttach(this, att.ObjectData[0].ObjectLocalID, att.AgentData.AttachmentPoint, att.ObjectData[0].Rotation);
3489 } 3489 }
3490 } 3490 }
3491 3491 }
3492 break; 3492
3493 case PacketType.ObjectDetach: 3493 break;
3494 3494 case PacketType.ObjectDetach:
3495 ObjectDetachPacket dett = (ObjectDetachPacket)Pack; 3495
3496 for (int j = 0; j < dett.ObjectData.Length; j++) 3496 ObjectDetachPacket dett = (ObjectDetachPacket)Pack;
3497 { 3497 for (int j = 0; j < dett.ObjectData.Length; j++)
3498 uint obj = dett.ObjectData[j].ObjectLocalID; 3498 {
3499 handlerObjectDetach = OnObjectDetach; 3499 uint obj = dett.ObjectData[j].ObjectLocalID;
3500 if (handlerObjectDetach != null) 3500 handlerObjectDetach = OnObjectDetach;
3501 { 3501 if (handlerObjectDetach != null)
3502 handlerObjectDetach(obj,this); 3502 {
3503 } 3503 handlerObjectDetach(obj,this);
3504 3504 }
3505 } 3505
3506 3506 }
3507 break; 3507
3508 case PacketType.SetAlwaysRun: 3508 break;
3509 SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; 3509 case PacketType.SetAlwaysRun:
3510 3510 SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack;
3511 handlerSetAlwaysRun = OnSetAlwaysRun; 3511
3512 if (handlerSetAlwaysRun != null) 3512 handlerSetAlwaysRun = OnSetAlwaysRun;
3513 handlerSetAlwaysRun(this, run.AgentData.AlwaysRun); 3513 if (handlerSetAlwaysRun != null)
3514 3514 handlerSetAlwaysRun(this, run.AgentData.AlwaysRun);
3515 break; 3515
3516 case PacketType.CompleteAgentMovement: 3516 break;
3517 handlerCompleteMovementToRegion = OnCompleteMovementToRegion; 3517 case PacketType.CompleteAgentMovement:
3518 if (handlerCompleteMovementToRegion != null) 3518 handlerCompleteMovementToRegion = OnCompleteMovementToRegion;
3519 { 3519 if (handlerCompleteMovementToRegion != null)
3520 handlerCompleteMovementToRegion(); 3520 {
3521 } 3521 handlerCompleteMovementToRegion();
3522 handlerCompleteMovementToRegion = null; 3522 }
3523 3523 handlerCompleteMovementToRegion = null;
3524 break; 3524
3525 case PacketType.AgentUpdate: 3525 break;
3526 if (OnAgentUpdate != null) 3526 case PacketType.AgentUpdate:
3527 { 3527 if (OnAgentUpdate != null)
3528 AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack; 3528 {
3529 3529 AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack;
3530 handlerAgentUpdate = OnAgentUpdate; 3530
3531 if (handlerAgentUpdate != null) 3531 handlerAgentUpdate = OnAgentUpdate;
3532 OnAgentUpdate(this, agenUpdate); 3532 if (handlerAgentUpdate != null)
3533 3533 OnAgentUpdate(this, agenUpdate);
3534 handlerAgentUpdate = null; 3534
3535 //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa); 3535 handlerAgentUpdate = null;
3536 } 3536 //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa);
3537 break; 3537 }
3538 case PacketType.AgentAnimation: 3538 break;
3539 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; 3539 case PacketType.AgentAnimation:
3540 3540 AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack;
3541 handlerStartAnim = null; 3541
3542 handlerStopAnim = null; 3542 handlerStartAnim = null;
3543 3543 handlerStopAnim = null;
3544 for (int i = 0; i < AgentAni.AnimationList.Length; i++) 3544
3545 { 3545 for (int i = 0; i < AgentAni.AnimationList.Length; i++)
3546 if (AgentAni.AnimationList[i].StartAnim) 3546 {
3547 { 3547 if (AgentAni.AnimationList[i].StartAnim)
3548 handlerStartAnim = OnStartAnim; 3548 {
3549 if (handlerStartAnim != null) 3549 handlerStartAnim = OnStartAnim;
3550 { 3550 if (handlerStartAnim != null)
3551 handlerStartAnim(this, AgentAni.AnimationList[i].AnimID); 3551 {
3552 } 3552 handlerStartAnim(this, AgentAni.AnimationList[i].AnimID);
3553 } 3553 }
3554 else 3554 }
3555 { 3555 else
3556 handlerStopAnim = OnStopAnim; 3556 {
3557 if (handlerStopAnim != null) 3557 handlerStopAnim = OnStopAnim;
3558 { 3558 if (handlerStopAnim != null)
3559 handlerStopAnim(this, AgentAni.AnimationList[i].AnimID); 3559 {
3560 } 3560 handlerStopAnim(this, AgentAni.AnimationList[i].AnimID);
3561 } 3561 }
3562 } 3562 }
3563 break; 3563 }
3564 case PacketType.AgentRequestSit: 3564 break;
3565 if (OnAgentRequestSit != null) 3565 case PacketType.AgentRequestSit:
3566 { 3566 if (OnAgentRequestSit != null)
3567 AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack; 3567 {
3568 3568 AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket)Pack;
3569 handlerAgentRequestSit = OnAgentRequestSit; 3569
3570 if (handlerAgentRequestSit != null) 3570 handlerAgentRequestSit = OnAgentRequestSit;
3571 handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID, 3571 if (handlerAgentRequestSit != null)
3572 agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); 3572 handlerAgentRequestSit(this, agentRequestSit.AgentData.AgentID,
3573 } 3573 agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset);
3574 break; 3574 }
3575 case PacketType.AgentSit: 3575 break;
3576 if (OnAgentSit != null) 3576 case PacketType.AgentSit:
3577 { 3577 if (OnAgentSit != null)
3578 AgentSitPacket agentSit = (AgentSitPacket)Pack; 3578 {
3579 3579 AgentSitPacket agentSit = (AgentSitPacket)Pack;
3580 handlerAgentSit = OnAgentSit; 3580
3581 if (handlerAgentSit != null) 3581 handlerAgentSit = OnAgentSit;
3582 { 3582 if (handlerAgentSit != null)
3583 OnAgentSit(this, agentSit.AgentData.AgentID); 3583 {
3584 } 3584 OnAgentSit(this, agentSit.AgentData.AgentID);
3585 } 3585 }
3586 break; 3586 }
3587 case PacketType.AvatarPickerRequest: 3587 break;
3588 AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack; 3588 case PacketType.AvatarPickerRequest:
3589 AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData; 3589 AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack;
3590 AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; 3590 AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData;
3591 //Console.WriteLine("Agent Sends:" + Helpers.FieldToUTF8String(querydata.Name)); 3591 AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data;
3592 3592 //Console.WriteLine("Agent Sends:" + Helpers.FieldToUTF8String(querydata.Name));
3593 handlerAvatarPickerRequest = OnAvatarPickerRequest; 3593
3594 if (handlerAvatarPickerRequest != null) 3594 handlerAvatarPickerRequest = OnAvatarPickerRequest;
3595 { 3595 if (handlerAvatarPickerRequest != null)
3596 handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, 3596 {
3597 Helpers.FieldToUTF8String(querydata.Name)); 3597 handlerAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID,
3598 } 3598 Helpers.FieldToUTF8String(querydata.Name));
3599 break; 3599 }
3600 case PacketType.AgentDataUpdateRequest: 3600 break;
3601 AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack; 3601 case PacketType.AgentDataUpdateRequest:
3602 3602 AgentDataUpdateRequestPacket avRequestDataUpdatePacket = (AgentDataUpdateRequestPacket)Pack;
3603 handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest; 3603
3604 3604 handlerAgentDataUpdateRequest = OnAgentDataUpdateRequest;
3605 if (handlerAgentDataUpdateRequest != null) 3605
3606 { 3606 if (handlerAgentDataUpdateRequest != null)
3607 handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID); 3607 {
3608 } 3608 handlerAgentDataUpdateRequest(this, avRequestDataUpdatePacket.AgentData.AgentID, avRequestDataUpdatePacket.AgentData.SessionID);
3609 3609 }
3610 break; 3610
3611 case PacketType.UserInfoRequest: 3611 break;
3612 UserInfoRequestPacket avUserInfoRequestPacket = (UserInfoRequestPacket)Pack; 3612 case PacketType.UserInfoRequest:
3613 3613 UserInfoRequestPacket avUserInfoRequestPacket = (UserInfoRequestPacket)Pack;
3614 handlerUserInfoRequest = OnUserInfoRequest; 3614
3615 if (handlerUserInfoRequest != null) 3615 handlerUserInfoRequest = OnUserInfoRequest;
3616 { 3616 if (handlerUserInfoRequest != null)
3617 handlerUserInfoRequest(this, avUserInfoRequestPacket.AgentData.AgentID, avUserInfoRequestPacket.AgentData.SessionID); 3617 {
3618 } 3618 handlerUserInfoRequest(this, avUserInfoRequestPacket.AgentData.AgentID, avUserInfoRequestPacket.AgentData.SessionID);
3619 break; 3619 }
3620 3620 break;
3621 case PacketType.SetStartLocationRequest: 3621
3622 SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack; 3622 case PacketType.SetStartLocationRequest:
3623 3623 SetStartLocationRequestPacket avSetStartLocationRequestPacket = (SetStartLocationRequestPacket)Pack;
3624 if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId) 3624
3625 { 3625 if (avSetStartLocationRequestPacket.AgentData.AgentID == AgentId && avSetStartLocationRequestPacket.AgentData.SessionID == SessionId)
3626 handlerSetStartLocationRequest = OnSetStartLocationRequest; 3626 {
3627 if (handlerSetStartLocationRequest != null) 3627 handlerSetStartLocationRequest = OnSetStartLocationRequest;
3628 { 3628 if (handlerSetStartLocationRequest != null)
3629 handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos, 3629 {
3630 avSetStartLocationRequestPacket.StartLocationData.LocationLookAt, 3630 handlerSetStartLocationRequest(this, 0, avSetStartLocationRequestPacket.StartLocationData.LocationPos,
3631 avSetStartLocationRequestPacket.StartLocationData.LocationID); 3631 avSetStartLocationRequestPacket.StartLocationData.LocationLookAt,
3632 } 3632 avSetStartLocationRequestPacket.StartLocationData.LocationID);
3633 } 3633 }
3634 break; 3634 }
3635 3635 break;
3636 case PacketType.AgentThrottle: 3636
3637 AgentThrottlePacket atpack = (AgentThrottlePacket)Pack; 3637 case PacketType.AgentThrottle:
3638 m_packetQueue.SetThrottleFromClient(atpack.Throttle.Throttles); 3638 AgentThrottlePacket atpack = (AgentThrottlePacket)Pack;
3639 break; 3639 m_packetQueue.SetThrottleFromClient(atpack.Throttle.Throttles);
3640 3640 break;
3641 case PacketType.AgentPause: 3641
3642 m_probesWithNoIngressPackets = 0; 3642 case PacketType.AgentPause:
3643 m_clientBlocked = true; 3643 m_probesWithNoIngressPackets = 0;
3644 break; 3644 m_clientBlocked = true;
3645 3645 break;
3646 case PacketType.AgentResume: 3646
3647 m_probesWithNoIngressPackets = 0; 3647 case PacketType.AgentResume:
3648 m_clientBlocked = false; 3648 m_probesWithNoIngressPackets = 0;
3649 SendStartPingCheck(0); 3649 m_clientBlocked = false;
3650 3650 SendStartPingCheck(0);
3651 break; 3651
3652 3652 break;
3653 #endregion 3653
3654 3654 #endregion
3655 #region Objects/m_sceneObjects 3655
3656 3656 #region Objects/m_sceneObjects
3657 case PacketType.ObjectLink: 3657
3658 ObjectLinkPacket link = (ObjectLinkPacket)Pack; 3658 case PacketType.ObjectLink:
3659 uint parentprimid = 0; 3659 ObjectLinkPacket link = (ObjectLinkPacket)Pack;
3660 List<uint> childrenprims = new List<uint>(); 3660 uint parentprimid = 0;
3661 if (link.ObjectData.Length > 1) 3661 List<uint> childrenprims = new List<uint>();
3662 { 3662 if (link.ObjectData.Length > 1)
3663 parentprimid = link.ObjectData[0].ObjectLocalID; 3663 {
3664 3664 parentprimid = link.ObjectData[0].ObjectLocalID;
3665 for (int i = 1; i < link.ObjectData.Length; i++) 3665
3666 { 3666 for (int i = 1; i < link.ObjectData.Length; i++)
3667 childrenprims.Add(link.ObjectData[i].ObjectLocalID); 3667 {
3668 } 3668 childrenprims.Add(link.ObjectData[i].ObjectLocalID);
3669 } 3669 }
3670 handlerLinkObjects = OnLinkObjects; 3670 }
3671 if (handlerLinkObjects != null) 3671 handlerLinkObjects = OnLinkObjects;
3672 { 3672 if (handlerLinkObjects != null)
3673 handlerLinkObjects(this, parentprimid, childrenprims); 3673 {
3674 } 3674 handlerLinkObjects(this, parentprimid, childrenprims);
3675 break; 3675 }
3676 case PacketType.ObjectDelink: 3676 break;
3677 ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack; 3677 case PacketType.ObjectDelink:
3678 3678 ObjectDelinkPacket delink = (ObjectDelinkPacket)Pack;
3679 // It appears the prim at index 0 is not always the root prim (for 3679
3680 // instance, when one prim of a link set has been edited independently 3680 // It appears the prim at index 0 is not always the root prim (for
3681 // of the others). Therefore, we'll pass all the ids onto the delink 3681 // instance, when one prim of a link set has been edited independently
3682 // method for it to decide which is the root. 3682 // of the others). Therefore, we'll pass all the ids onto the delink
3683 List<uint> prims = new List<uint>(); 3683 // method for it to decide which is the root.
3684 for (int i = 0; i < delink.ObjectData.Length; i++) 3684 List<uint> prims = new List<uint>();
3685 { 3685 for (int i = 0; i < delink.ObjectData.Length; i++)
3686 prims.Add(delink.ObjectData[i].ObjectLocalID); 3686 {
3687 } 3687 prims.Add(delink.ObjectData[i].ObjectLocalID);
3688 handlerDelinkObjects = OnDelinkObjects; 3688 }
3689 if (handlerDelinkObjects != null) 3689 handlerDelinkObjects = OnDelinkObjects;
3690 { 3690 if (handlerDelinkObjects != null)
3691 handlerDelinkObjects(prims); 3691 {
3692 } 3692 handlerDelinkObjects(prims);
3693 3693 }
3694 break; 3694
3695 case PacketType.ObjectAdd: 3695 break;
3696 if (OnAddPrim != null) 3696 case PacketType.ObjectAdd:
3697 { 3697 if (OnAddPrim != null)
3698 ObjectAddPacket addPacket = (ObjectAddPacket)Pack; 3698 {
3699 PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket); 3699 ObjectAddPacket addPacket = (ObjectAddPacket)Pack;
3700 // m_log.Info("[REZData]: " + addPacket.ToString()); 3700 PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket);
3701 //BypassRaycast: 1 3701 // m_log.Info("[REZData]: " + addPacket.ToString());
3702 //RayStart: <69.79469, 158.2652, 98.40343> 3702 //BypassRaycast: 1
3703 //RayEnd: <61.97724, 141.995, 92.58341> 3703 //RayStart: <69.79469, 158.2652, 98.40343>
3704 //RayTargetID: 00000000-0000-0000-0000-000000000000 3704 //RayEnd: <61.97724, 141.995, 92.58341>
3705 3705 //RayTargetID: 00000000-0000-0000-0000-000000000000
3706 handlerAddPrim = OnAddPrim; 3706
3707 if (handlerAddPrim != null) 3707 handlerAddPrim = OnAddPrim;
3708 handlerAddPrim(AgentId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection); 3708 if (handlerAddPrim != null)
3709 } 3709 handlerAddPrim(AgentId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape, addPacket.ObjectData.BypassRaycast, addPacket.ObjectData.RayStart, addPacket.ObjectData.RayTargetID, addPacket.ObjectData.RayEndIsIntersection);
3710 break; 3710 }
3711 case PacketType.ObjectShape: 3711 break;
3712 ObjectShapePacket shapePacket = (ObjectShapePacket)Pack; 3712 case PacketType.ObjectShape:
3713 handlerUpdatePrimShape = null; 3713 ObjectShapePacket shapePacket = (ObjectShapePacket)Pack;
3714 for (int i = 0; i < shapePacket.ObjectData.Length; i++) 3714 handlerUpdatePrimShape = null;
3715 { 3715 for (int i = 0; i < shapePacket.ObjectData.Length; i++)
3716 handlerUpdatePrimShape = OnUpdatePrimShape; 3716 {
3717 if (handlerUpdatePrimShape != null) 3717 handlerUpdatePrimShape = OnUpdatePrimShape;
3718 { 3718 if (handlerUpdatePrimShape != null)
3719 handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID, 3719 {
3720 shapePacket.ObjectData[i]); 3720 handlerUpdatePrimShape(m_agentId, shapePacket.ObjectData[i].ObjectLocalID,
3721 } 3721 shapePacket.ObjectData[i]);
3722 } 3722 }
3723 break; 3723 }
3724 case PacketType.ObjectExtraParams: 3724 break;
3725 ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack; 3725 case PacketType.ObjectExtraParams:
3726 3726 ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket)Pack;
3727 handlerUpdateExtraParams = OnUpdateExtraParams; 3727
3728 if (handlerUpdateExtraParams != null) 3728 handlerUpdateExtraParams = OnUpdateExtraParams;
3729 { 3729 if (handlerUpdateExtraParams != null)
3730 handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[0].ObjectLocalID, 3730 {
3731 extraPar.ObjectData[0].ParamType, 3731 handlerUpdateExtraParams(m_agentId, extraPar.ObjectData[0].ObjectLocalID,
3732 extraPar.ObjectData[0].ParamInUse, extraPar.ObjectData[0].ParamData); 3732 extraPar.ObjectData[0].ParamType,
3733 } 3733 extraPar.ObjectData[0].ParamInUse, extraPar.ObjectData[0].ParamData);
3734 break; 3734 }
3735 case PacketType.ObjectDuplicate: 3735 break;
3736 ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack; 3736 case PacketType.ObjectDuplicate:
3737 ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData; 3737 ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack;
3738 3738 ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData;
3739 handlerObjectDuplicate = null; 3739
3740 3740 handlerObjectDuplicate = null;
3741 for (int i = 0; i < dupe.ObjectData.Length; i++) 3741
3742 { 3742 for (int i = 0; i < dupe.ObjectData.Length; i++)
3743 handlerObjectDuplicate = OnObjectDuplicate; 3743 {
3744 if (handlerObjectDuplicate != null) 3744 handlerObjectDuplicate = OnObjectDuplicate;
3745 { 3745 if (handlerObjectDuplicate != null)
3746 handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, 3746 {
3747 dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID, 3747 handlerObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset,
3748 AgentandGroupData.GroupID); 3748 dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID,
3749 } 3749 AgentandGroupData.GroupID);
3750 } 3750 }
3751 3751 }
3752 break; 3752
3753 3753 break;
3754 case PacketType.ObjectSelect: 3754
3755 ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; 3755 case PacketType.ObjectSelect:
3756 3756 ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack;
3757 handlerObjectSelect = null; 3757
3758 3758 handlerObjectSelect = null;
3759 for (int i = 0; i < incomingselect.ObjectData.Length; i++) 3759
3760 { 3760 for (int i = 0; i < incomingselect.ObjectData.Length; i++)
3761 handlerObjectSelect = OnObjectSelect; 3761 {
3762 if (handlerObjectSelect != null) 3762 handlerObjectSelect = OnObjectSelect;
3763 { 3763 if (handlerObjectSelect != null)
3764 handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this); 3764 {
3765 } 3765 handlerObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this);
3766 } 3766 }
3767 break; 3767 }
3768 case PacketType.ObjectDeselect: 3768 break;
3769 ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack; 3769 case PacketType.ObjectDeselect:
3770 3770 ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket)Pack;
3771 handlerObjectDeselect = null; 3771
3772 3772 handlerObjectDeselect = null;
3773 for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) 3773
3774 { 3774 for (int i = 0; i < incomingdeselect.ObjectData.Length; i++)
3775 handlerObjectDeselect = OnObjectDeselect; 3775 {
3776 if (handlerObjectDeselect != null) 3776 handlerObjectDeselect = OnObjectDeselect;
3777 { 3777 if (handlerObjectDeselect != null)
3778 OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this); 3778 {
3779 } 3779 OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this);
3780 } 3780 }
3781 break; 3781 }
3782 case PacketType.ObjectFlagUpdate: 3782 break;
3783 ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; 3783 case PacketType.ObjectFlagUpdate:
3784 3784 ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack;
3785 handlerUpdatePrimFlags = OnUpdatePrimFlags; 3785
3786 3786 handlerUpdatePrimFlags = OnUpdatePrimFlags;
3787 if (handlerUpdatePrimFlags != null) 3787
3788 { 3788 if (handlerUpdatePrimFlags != null)
3789 handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this); 3789 {
3790 } 3790 handlerUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this);
3791 break; 3791 }
3792 case PacketType.ObjectImage: 3792 break;
3793 ObjectImagePacket imagePack = (ObjectImagePacket)Pack; 3793 case PacketType.ObjectImage:
3794 3794 ObjectImagePacket imagePack = (ObjectImagePacket)Pack;
3795 handlerUpdatePrimTexture = null; 3795
3796 for (int i = 0; i < imagePack.ObjectData.Length; i++) 3796 handlerUpdatePrimTexture = null;
3797 { 3797 for (int i = 0; i < imagePack.ObjectData.Length; i++)
3798 handlerUpdatePrimTexture = OnUpdatePrimTexture; 3798 {
3799 if (handlerUpdatePrimTexture != null) 3799 handlerUpdatePrimTexture = OnUpdatePrimTexture;
3800 { 3800 if (handlerUpdatePrimTexture != null)
3801 handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, 3801 {
3802 imagePack.ObjectData[i].TextureEntry, this); 3802 handlerUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID,
3803 } 3803 imagePack.ObjectData[i].TextureEntry, this);
3804 } 3804 }
3805 break; 3805 }
3806 case PacketType.ObjectGrab: 3806 break;
3807 ObjectGrabPacket grab = (ObjectGrabPacket)Pack; 3807 case PacketType.ObjectGrab:
3808 3808 ObjectGrabPacket grab = (ObjectGrabPacket)Pack;
3809 handlerGrabObject = OnGrabObject; 3809
3810 3810 handlerGrabObject = OnGrabObject;
3811 if (handlerGrabObject != null) 3811
3812 { 3812 if (handlerGrabObject != null)
3813 handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this); 3813 {
3814 } 3814 handlerGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this);
3815 break; 3815 }
3816 case PacketType.ObjectGrabUpdate: 3816 break;
3817 ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack; 3817 case PacketType.ObjectGrabUpdate:
3818 3818 ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket)Pack;
3819 handlerGrabUpdate = OnGrabUpdate; 3819
3820 3820 handlerGrabUpdate = OnGrabUpdate;
3821 if (handlerGrabUpdate != null) 3821
3822 { 3822 if (handlerGrabUpdate != null)
3823 handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial, 3823 {
3824 grabUpdate.ObjectData.GrabPosition, this); 3824 handlerGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial,
3825 } 3825 grabUpdate.ObjectData.GrabPosition, this);
3826 break; 3826 }
3827 case PacketType.ObjectDeGrab: 3827 break;
3828 ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack; 3828 case PacketType.ObjectDeGrab:
3829 3829 ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket)Pack;
3830 handlerDeGrabObject = OnDeGrabObject; 3830
3831 if (handlerDeGrabObject != null) 3831 handlerDeGrabObject = OnDeGrabObject;
3832 { 3832 if (handlerDeGrabObject != null)
3833 handlerDeGrabObject(deGrab.ObjectData.LocalID, this); 3833 {
3834 } 3834 handlerDeGrabObject(deGrab.ObjectData.LocalID, this);
3835 break; 3835 }
3836 case PacketType.ObjectDescription: 3836 break;
3837 ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack; 3837 case PacketType.ObjectDescription:
3838 3838 ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack;
3839 handlerObjectDescription = null; 3839
3840 3840 handlerObjectDescription = null;
3841 for (int i = 0; i < objDes.ObjectData.Length; i++) 3841
3842 { 3842 for (int i = 0; i < objDes.ObjectData.Length; i++)
3843 handlerObjectDescription = OnObjectDescription; 3843 {
3844 if (handlerObjectDescription != null) 3844 handlerObjectDescription = OnObjectDescription;
3845 { 3845 if (handlerObjectDescription != null)
3846 handlerObjectDescription(this, objDes.ObjectData[i].LocalID, 3846 {
3847 Util.FieldToString(objDes.ObjectData[i].Description)); 3847 handlerObjectDescription(this, objDes.ObjectData[i].LocalID,
3848 } 3848 Util.FieldToString(objDes.ObjectData[i].Description));
3849 } 3849 }
3850 break; 3850 }
3851 case PacketType.ObjectName: 3851 break;
3852 ObjectNamePacket objName = (ObjectNamePacket)Pack; 3852 case PacketType.ObjectName:
3853 3853 ObjectNamePacket objName = (ObjectNamePacket)Pack;
3854 handlerObjectName = null; 3854
3855 for (int i = 0; i < objName.ObjectData.Length; i++) 3855 handlerObjectName = null;
3856 { 3856 for (int i = 0; i < objName.ObjectData.Length; i++)
3857 handlerObjectName = OnObjectName; 3857 {
3858 if (handlerObjectName != null) 3858 handlerObjectName = OnObjectName;
3859 { 3859 if (handlerObjectName != null)
3860 handlerObjectName(this, objName.ObjectData[i].LocalID, 3860 {
3861 Util.FieldToString(objName.ObjectData[i].Name)); 3861 handlerObjectName(this, objName.ObjectData[i].LocalID,
3862 } 3862 Util.FieldToString(objName.ObjectData[i].Name));
3863 } 3863 }
3864 break; 3864 }
3865 case PacketType.ObjectPermissions: 3865 break;
3866 if (OnObjectPermissions != null) 3866 case PacketType.ObjectPermissions:
3867 { 3867 if (OnObjectPermissions != null)
3868 ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack; 3868 {
3869 3869 ObjectPermissionsPacket newobjPerms = (ObjectPermissionsPacket)Pack;
3870 LLUUID AgentID = newobjPerms.AgentData.AgentID; 3870
3871 LLUUID SessionID = newobjPerms.AgentData.SessionID; 3871 LLUUID AgentID = newobjPerms.AgentData.AgentID;
3872 3872 LLUUID SessionID = newobjPerms.AgentData.SessionID;
3873 handlerObjectPermissions = null; 3873
3874 3874 handlerObjectPermissions = null;
3875 for (int i = 0; i < newobjPerms.ObjectData.Length; i++) 3875
3876 { 3876 for (int i = 0; i < newobjPerms.ObjectData.Length; i++)
3877 ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i]; 3877 {
3878 3878 ObjectPermissionsPacket.ObjectDataBlock permChanges = newobjPerms.ObjectData[i];
3879 byte field = permChanges.Field; 3879
3880 uint localID = permChanges.ObjectLocalID; 3880 byte field = permChanges.Field;
3881 uint mask = permChanges.Mask; 3881 uint localID = permChanges.ObjectLocalID;
3882 byte set = permChanges.Set; 3882 uint mask = permChanges.Mask;
3883 3883 byte set = permChanges.Set;
3884 handlerObjectPermissions = OnObjectPermissions; 3884
3885 3885 handlerObjectPermissions = OnObjectPermissions;
3886 if (handlerObjectPermissions != null) 3886
3887 OnObjectPermissions(this, AgentID, SessionID, field, localID, mask, set); 3887 if (handlerObjectPermissions != null)
3888 } 3888 OnObjectPermissions(this, AgentID, SessionID, field, localID, mask, set);
3889 } 3889 }
3890 3890 }
3891 // Here's our data, 3891
3892 // PermField contains the field the info goes into 3892 // Here's our data,
3893 // PermField determines which mask we're changing 3893 // PermField contains the field the info goes into
3894 // 3894 // PermField determines which mask we're changing
3895 // chmask is the mask of the change 3895 //
3896 // setTF is whether we're adding it or taking it away 3896 // chmask is the mask of the change
3897 // 3897 // setTF is whether we're adding it or taking it away
3898 // objLocalID is the localID of the object. 3898 //
3899 3899 // objLocalID is the localID of the object.
3900 // Unfortunately, we have to pass the event the packet because objData is an array 3900
3901 // That means multiple object perms may be updated in a single packet. 3901 // Unfortunately, we have to pass the event the packet because objData is an array
3902 3902 // That means multiple object perms may be updated in a single packet.
3903 break; 3903
3904 3904 break;
3905 case PacketType.Undo: 3905
3906 UndoPacket undoitem = (UndoPacket)Pack; 3906 case PacketType.Undo:
3907 if (undoitem.ObjectData.Length > 0) 3907 UndoPacket undoitem = (UndoPacket)Pack;
3908 { 3908 if (undoitem.ObjectData.Length > 0)
3909 for (int i = 0; i < undoitem.ObjectData.Length; i++) 3909 {
3910 { 3910 for (int i = 0; i < undoitem.ObjectData.Length; i++)
3911 LLUUID objiD = undoitem.ObjectData[i].ObjectID; 3911 {
3912 handlerOnUndo = OnUndo; 3912 LLUUID objiD = undoitem.ObjectData[i].ObjectID;
3913 if (handlerOnUndo != null) 3913 handlerOnUndo = OnUndo;
3914 { 3914 if (handlerOnUndo != null)
3915 handlerOnUndo(this, objiD); 3915 {
3916 } 3916 handlerOnUndo(this, objiD);
3917 3917 }
3918 } 3918
3919 } 3919 }
3920 break; 3920 }
3921 case PacketType.ObjectDuplicateOnRay: 3921 break;
3922 ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack; 3922 case PacketType.ObjectDuplicateOnRay:
3923 3923 ObjectDuplicateOnRayPacket dupeOnRay = (ObjectDuplicateOnRayPacket)Pack;
3924 handlerObjectDuplicateOnRay = null; 3924
3925 3925 handlerObjectDuplicateOnRay = null;
3926 3926
3927 for (int i = 0; i < dupeOnRay.ObjectData.Length; i++) 3927
3928 { 3928 for (int i = 0; i < dupeOnRay.ObjectData.Length; i++)
3929 handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay; 3929 {
3930 if (handlerObjectDuplicateOnRay != null) 3930 handlerObjectDuplicateOnRay = OnObjectDuplicateOnRay;
3931 { 3931 if (handlerObjectDuplicateOnRay != null)
3932 handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags, 3932 {
3933 dupeOnRay.AgentData.AgentID, dupeOnRay.AgentData.GroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd, 3933 handlerObjectDuplicateOnRay(dupeOnRay.ObjectData[i].ObjectLocalID, dupeOnRay.AgentData.DuplicateFlags,
3934 dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection, 3934 dupeOnRay.AgentData.AgentID, dupeOnRay.AgentData.GroupID, dupeOnRay.AgentData.RayTargetID, dupeOnRay.AgentData.RayEnd,
3935 dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates); 3935 dupeOnRay.AgentData.RayStart, dupeOnRay.AgentData.BypassRaycast, dupeOnRay.AgentData.RayEndIsIntersection,
3936 } 3936 dupeOnRay.AgentData.CopyCenters, dupeOnRay.AgentData.CopyRotates);
3937 } 3937 }
3938 3938 }
3939 break; 3939
3940 case PacketType.RequestObjectPropertiesFamily: 3940 break;
3941 //This powers the little tooltip that appears when you move your mouse over an object 3941 case PacketType.RequestObjectPropertiesFamily:
3942 RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack; 3942 //This powers the little tooltip that appears when you move your mouse over an object
3943 3943 RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack;
3944 RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData; 3944
3945 3945 RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData;
3946 handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily; 3946
3947 3947 handlerRequestObjectPropertiesFamily = OnRequestObjectPropertiesFamily;
3948 if (handlerRequestObjectPropertiesFamily != null) 3948
3949 { 3949 if (handlerRequestObjectPropertiesFamily != null)
3950 handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags, 3950 {
3951 packObjBlock.ObjectID); 3951 handlerRequestObjectPropertiesFamily(this, m_agentId, packObjBlock.RequestFlags,
3952 } 3952 packObjBlock.ObjectID);
3953 3953 }
3954 break; 3954
3955 case PacketType.ObjectIncludeInSearch: 3955 break;
3956 //This lets us set objects to appear in search (stuff like DataSnapshot, etc) 3956 case PacketType.ObjectIncludeInSearch:
3957 ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack; 3957 //This lets us set objects to appear in search (stuff like DataSnapshot, etc)
3958 handlerObjectIncludeInSearch = null; 3958 ObjectIncludeInSearchPacket packInSearch = (ObjectIncludeInSearchPacket)Pack;
3959 3959 handlerObjectIncludeInSearch = null;
3960 foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData) { 3960
3961 bool inSearch = objData.IncludeInSearch; 3961 foreach (ObjectIncludeInSearchPacket.ObjectDataBlock objData in packInSearch.ObjectData) {
3962 uint localID = objData.ObjectLocalID; 3962 bool inSearch = objData.IncludeInSearch;
3963 3963 uint localID = objData.ObjectLocalID;
3964 handlerObjectIncludeInSearch = OnObjectIncludeInSearch; 3964
3965 3965 handlerObjectIncludeInSearch = OnObjectIncludeInSearch;
3966 if (handlerObjectIncludeInSearch != null) { 3966
3967 handlerObjectIncludeInSearch(this, inSearch, localID); 3967 if (handlerObjectIncludeInSearch != null) {
3968 } 3968 handlerObjectIncludeInSearch(this, inSearch, localID);
3969 } 3969 }
3970 break; 3970 }
3971 3971 break;
3972 case PacketType.ScriptAnswerYes: 3972
3973 ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack; 3973 case PacketType.ScriptAnswerYes:
3974 3974 ScriptAnswerYesPacket scriptAnswer = (ScriptAnswerYesPacket)Pack;
3975 handlerScriptAnswer = OnScriptAnswer; 3975
3976 if (handlerScriptAnswer != null) 3976 handlerScriptAnswer = OnScriptAnswer;
3977 { 3977 if (handlerScriptAnswer != null)
3978 handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions); 3978 {
3979 } 3979 handlerScriptAnswer(this, scriptAnswer.Data.TaskID, scriptAnswer.Data.ItemID, scriptAnswer.Data.Questions);
3980 break; 3980 }
3981 3981 break;
3982 #endregion 3982
3983 3983 #endregion
3984 #region Inventory/Asset/Other related packets 3984
3985 3985 #region Inventory/Asset/Other related packets
3986 case PacketType.RequestImage: 3986
3987 RequestImagePacket imageRequest = (RequestImagePacket)Pack; 3987 case PacketType.RequestImage:
3988 //Console.WriteLine("image request: " + Pack.ToString()); 3988 RequestImagePacket imageRequest = (RequestImagePacket)Pack;
3989 3989 //Console.WriteLine("image request: " + Pack.ToString());
3990 handlerTextureRequest = null; 3990
3991 3991 handlerTextureRequest = null;
3992 for (int i = 0; i < imageRequest.RequestImage.Length; i++) 3992
3993 { 3993 for (int i = 0; i < imageRequest.RequestImage.Length; i++)
3994 if (OnRequestTexture != null) 3994 {
3995 { 3995 if (OnRequestTexture != null)
3996 TextureRequestArgs args = new TextureRequestArgs(); 3996 {
3997 args.RequestedAssetID = imageRequest.RequestImage[i].Image; 3997 TextureRequestArgs args = new TextureRequestArgs();
3998 args.DiscardLevel = imageRequest.RequestImage[i].DiscardLevel; 3998 args.RequestedAssetID = imageRequest.RequestImage[i].Image;
3999 args.PacketNumber = imageRequest.RequestImage[i].Packet; 3999 args.DiscardLevel = imageRequest.RequestImage[i].DiscardLevel;
4000 args.Priority = imageRequest.RequestImage[i].DownloadPriority; 4000 args.PacketNumber = imageRequest.RequestImage[i].Packet;
4001 4001 args.Priority = imageRequest.RequestImage[i].DownloadPriority;
4002 handlerTextureRequest = OnRequestTexture; 4002
4003 4003 handlerTextureRequest = OnRequestTexture;
4004 if (handlerTextureRequest != null) 4004
4005 OnRequestTexture(this, args); 4005 if (handlerTextureRequest != null)
4006 } 4006 OnRequestTexture(this, args);
4007 } 4007 }
4008 break; 4008 }
4009 case PacketType.TransferRequest: 4009 break;
4010 //Console.WriteLine("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); 4010 case PacketType.TransferRequest:
4011 TransferRequestPacket transfer = (TransferRequestPacket)Pack; 4011 //Console.WriteLine("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request");
4012 m_assetCache.AddAssetRequest(this, transfer); 4012 TransferRequestPacket transfer = (TransferRequestPacket)Pack;
4013 /* RequestAsset = OnRequestAsset; 4013 m_assetCache.AddAssetRequest(this, transfer);
4014 if (RequestAsset != null) 4014 /* RequestAsset = OnRequestAsset;
4015 { 4015 if (RequestAsset != null)
4016 RequestAsset(this, transfer); 4016 {
4017 }*/ 4017 RequestAsset(this, transfer);
4018 break; 4018 }*/
4019 case PacketType.AssetUploadRequest: 4019 break;
4020 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; 4020 case PacketType.AssetUploadRequest:
4021 // Console.WriteLine("upload request " + Pack.ToString()); 4021 AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack;
4022 // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString()); 4022 // Console.WriteLine("upload request " + Pack.ToString());
4023 LLUUID temp = LLUUID.Combine(request.AssetBlock.TransactionID, SecureSessionId); 4023 // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionId).ToString());
4024 4024 LLUUID temp = LLUUID.Combine(request.AssetBlock.TransactionID, SecureSessionId);
4025 handlerAssetUploadRequest = OnAssetUploadRequest; 4025
4026 4026 handlerAssetUploadRequest = OnAssetUploadRequest;
4027 if (handlerAssetUploadRequest != null) 4027
4028 { 4028 if (handlerAssetUploadRequest != null)
4029 handlerAssetUploadRequest(this, temp, 4029 {
4030 request.AssetBlock.TransactionID, request.AssetBlock.Type, 4030 handlerAssetUploadRequest(this, temp,
4031 request.AssetBlock.AssetData, request.AssetBlock.StoreLocal, 4031 request.AssetBlock.TransactionID, request.AssetBlock.Type,
4032 request.AssetBlock.Tempfile); 4032 request.AssetBlock.AssetData, request.AssetBlock.StoreLocal,
4033 } 4033 request.AssetBlock.Tempfile);
4034 break; 4034 }
4035 case PacketType.RequestXfer: 4035 break;
4036 RequestXferPacket xferReq = (RequestXferPacket)Pack; 4036 case PacketType.RequestXfer:
4037 4037 RequestXferPacket xferReq = (RequestXferPacket)Pack;
4038 handlerRequestXfer = OnRequestXfer; 4038
4039 4039 handlerRequestXfer = OnRequestXfer;
4040 if (handlerRequestXfer != null) 4040
4041 { 4041 if (handlerRequestXfer != null)
4042 handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename)); 4042 {
4043 } 4043 handlerRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename));
4044 break; 4044 }
4045 case PacketType.SendXferPacket: 4045 break;
4046 SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack; 4046 case PacketType.SendXferPacket:
4047 4047 SendXferPacketPacket xferRec = (SendXferPacketPacket)Pack;
4048 handlerXferReceive = OnXferReceive; 4048
4049 if (handlerXferReceive != null) 4049 handlerXferReceive = OnXferReceive;
4050 { 4050 if (handlerXferReceive != null)
4051 handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); 4051 {
4052 } 4052 handlerXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data);
4053 break; 4053 }
4054 case PacketType.ConfirmXferPacket: 4054 break;
4055 ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack; 4055 case PacketType.ConfirmXferPacket:
4056 4056 ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket)Pack;
4057 handlerConfirmXfer = OnConfirmXfer; 4057
4058 if (handlerConfirmXfer != null) 4058 handlerConfirmXfer = OnConfirmXfer;
4059 { 4059 if (handlerConfirmXfer != null)
4060 handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); 4060 {
4061 } 4061 handlerConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet);
4062 break; 4062 }
4063 case PacketType.CreateInventoryFolder: 4063 break;
4064 CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; 4064 case PacketType.CreateInventoryFolder:
4065 4065 CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack;
4066 handlerCreateInventoryFolder = OnCreateNewInventoryFolder; 4066
4067 if (handlerCreateInventoryFolder != null) 4067 handlerCreateInventoryFolder = OnCreateNewInventoryFolder;
4068 { 4068 if (handlerCreateInventoryFolder != null)
4069 handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID, 4069 {
4070 (ushort)invFolder.FolderData.Type, 4070 handlerCreateInventoryFolder(this, invFolder.FolderData.FolderID,
4071 Util.FieldToString(invFolder.FolderData.Name), 4071 (ushort)invFolder.FolderData.Type,
4072 invFolder.FolderData.ParentID); 4072 Util.FieldToString(invFolder.FolderData.Name),
4073 } 4073 invFolder.FolderData.ParentID);
4074 break; 4074 }
4075 case PacketType.UpdateInventoryFolder: 4075 break;
4076 if (OnUpdateInventoryFolder != null) 4076 case PacketType.UpdateInventoryFolder:
4077 { 4077 if (OnUpdateInventoryFolder != null)
4078 UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack; 4078 {
4079 4079 UpdateInventoryFolderPacket invFolderx = (UpdateInventoryFolderPacket)Pack;
4080 handlerUpdateInventoryFolder = null; 4080
4081 4081 handlerUpdateInventoryFolder = null;
4082 for (int i = 0; i < invFolderx.FolderData.Length; i++) 4082
4083 { 4083 for (int i = 0; i < invFolderx.FolderData.Length; i++)
4084 handlerUpdateInventoryFolder = OnUpdateInventoryFolder; 4084 {
4085 if (handlerUpdateInventoryFolder != null) 4085 handlerUpdateInventoryFolder = OnUpdateInventoryFolder;
4086 { 4086 if (handlerUpdateInventoryFolder != null)
4087 OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID, 4087 {
4088 (ushort)invFolderx.FolderData[i].Type, 4088 OnUpdateInventoryFolder(this, invFolderx.FolderData[i].FolderID,
4089 Util.FieldToString(invFolderx.FolderData[i].Name), 4089 (ushort)invFolderx.FolderData[i].Type,
4090 invFolderx.FolderData[i].ParentID); 4090 Util.FieldToString(invFolderx.FolderData[i].Name),
4091 } 4091 invFolderx.FolderData[i].ParentID);
4092 } 4092 }
4093 } 4093 }
4094 break; 4094 }
4095 case PacketType.MoveInventoryFolder: 4095 break;
4096 if (OnMoveInventoryFolder != null) 4096 case PacketType.MoveInventoryFolder:
4097 { 4097 if (OnMoveInventoryFolder != null)
4098 MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack; 4098 {
4099 4099 MoveInventoryFolderPacket invFoldery = (MoveInventoryFolderPacket)Pack;
4100 handlerMoveInventoryFolder = null; 4100
4101 4101 handlerMoveInventoryFolder = null;
4102 for (int i = 0; i < invFoldery.InventoryData.Length; i++) 4102
4103 { 4103 for (int i = 0; i < invFoldery.InventoryData.Length; i++)
4104 handlerMoveInventoryFolder = OnMoveInventoryFolder; 4104 {
4105 if (handlerMoveInventoryFolder != null) 4105 handlerMoveInventoryFolder = OnMoveInventoryFolder;
4106 { 4106 if (handlerMoveInventoryFolder != null)
4107 OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID, 4107 {
4108 invFoldery.InventoryData[i].ParentID); 4108 OnMoveInventoryFolder(this, invFoldery.InventoryData[i].FolderID,
4109 } 4109 invFoldery.InventoryData[i].ParentID);
4110 } 4110 }
4111 } 4111 }
4112 break; 4112 }
4113 case PacketType.CreateInventoryItem: 4113 break;
4114 CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; 4114 case PacketType.CreateInventoryItem:
4115 4115 CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack;
4116 handlerCreateNewInventoryItem = OnCreateNewInventoryItem; 4116
4117 if (handlerCreateNewInventoryItem != null) 4117 handlerCreateNewInventoryItem = OnCreateNewInventoryItem;
4118 { 4118 if (handlerCreateNewInventoryItem != null)
4119 handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, 4119 {
4120 createItem.InventoryBlock.FolderID, 4120 handlerCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID,
4121 createItem.InventoryBlock.CallbackID, 4121 createItem.InventoryBlock.FolderID,
4122 Util.FieldToString(createItem.InventoryBlock.Description), 4122 createItem.InventoryBlock.CallbackID,
4123 Util.FieldToString(createItem.InventoryBlock.Name), 4123 Util.FieldToString(createItem.InventoryBlock.Description),
4124 createItem.InventoryBlock.InvType, 4124 Util.FieldToString(createItem.InventoryBlock.Name),
4125 createItem.InventoryBlock.Type, 4125 createItem.InventoryBlock.InvType,
4126 createItem.InventoryBlock.WearableType, 4126 createItem.InventoryBlock.Type,
4127 createItem.InventoryBlock.NextOwnerMask); 4127 createItem.InventoryBlock.WearableType,
4128 } 4128 createItem.InventoryBlock.NextOwnerMask);
4129 break; 4129 }
4130 case PacketType.FetchInventory: 4130 break;
4131 if (OnFetchInventory != null) 4131 case PacketType.FetchInventory:
4132 { 4132 if (OnFetchInventory != null)
4133 FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack; 4133 {
4134 4134 FetchInventoryPacket FetchInventoryx = (FetchInventoryPacket)Pack;
4135 handlerFetchInventory = null; 4135
4136 4136 handlerFetchInventory = null;
4137 for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++) 4137
4138 { 4138 for (int i = 0; i < FetchInventoryx.InventoryData.Length; i++)
4139 handlerFetchInventory = OnFetchInventory; 4139 {
4140 4140 handlerFetchInventory = OnFetchInventory;
4141 if (handlerFetchInventory != null) 4141
4142 { 4142 if (handlerFetchInventory != null)
4143 OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID, 4143 {
4144 FetchInventoryx.InventoryData[i].OwnerID); 4144 OnFetchInventory(this, FetchInventoryx.InventoryData[i].ItemID,
4145 } 4145 FetchInventoryx.InventoryData[i].OwnerID);
4146 } 4146 }
4147 } 4147 }
4148 break; 4148 }
4149 case PacketType.FetchInventoryDescendents: 4149 break;
4150 FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; 4150 case PacketType.FetchInventoryDescendents:
4151 4151 FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack;
4152 handlerFetchInventoryDescendents = OnFetchInventoryDescendents; 4152
4153 if (handlerFetchInventoryDescendents != null) 4153 handlerFetchInventoryDescendents = OnFetchInventoryDescendents;
4154 { 4154 if (handlerFetchInventoryDescendents != null)
4155 handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, 4155 {
4156 Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems, 4156 handlerFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID,
4157 Fetch.InventoryData.SortOrder); 4157 Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems,
4158 } 4158 Fetch.InventoryData.SortOrder);
4159 break; 4159 }
4160 case PacketType.PurgeInventoryDescendents: 4160 break;
4161 PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack; 4161 case PacketType.PurgeInventoryDescendents:
4162 4162 PurgeInventoryDescendentsPacket Purge = (PurgeInventoryDescendentsPacket)Pack;
4163 handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents; 4163
4164 if (handlerPurgeInventoryDescendents != null) 4164 handlerPurgeInventoryDescendents = OnPurgeInventoryDescendents;
4165 { 4165 if (handlerPurgeInventoryDescendents != null)
4166 handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID); 4166 {
4167 } 4167 handlerPurgeInventoryDescendents(this, Purge.InventoryData.FolderID);
4168 break; 4168 }
4169 case PacketType.UpdateInventoryItem: 4169 break;
4170 UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; 4170 case PacketType.UpdateInventoryItem:
4171 if (OnUpdateInventoryItem != null) 4171 UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack;
4172 { 4172 if (OnUpdateInventoryItem != null)
4173 handlerUpdateInventoryItem = null; 4173 {
4174 for (int i = 0; i < update.InventoryData.Length; i++) 4174 handlerUpdateInventoryItem = null;
4175 { 4175 for (int i = 0; i < update.InventoryData.Length; i++)
4176 handlerUpdateInventoryItem = OnUpdateInventoryItem; 4176 {
4177 4177 handlerUpdateInventoryItem = OnUpdateInventoryItem;
4178 if (handlerUpdateInventoryItem != null) 4178
4179 { 4179 if (handlerUpdateInventoryItem != null)
4180 InventoryItemBase itemUpd = new InventoryItemBase(); 4180 {
4181 itemUpd.ID = update.InventoryData[i].ItemID; 4181 InventoryItemBase itemUpd = new InventoryItemBase();
4182 itemUpd.Name = Util.FieldToString(update.InventoryData[i].Name); 4182 itemUpd.ID = update.InventoryData[i].ItemID;
4183 itemUpd.Description = Util.FieldToString(update.InventoryData[i].Description); 4183 itemUpd.Name = Util.FieldToString(update.InventoryData[i].Name);
4184 itemUpd.GroupID = update.InventoryData[i].GroupID; 4184 itemUpd.Description = Util.FieldToString(update.InventoryData[i].Description);
4185 itemUpd.GroupOwned = update.InventoryData[i].GroupOwned; 4185 itemUpd.GroupID = update.InventoryData[i].GroupID;
4186 itemUpd.NextPermissions = update.InventoryData[i].NextOwnerMask; 4186 itemUpd.GroupOwned = update.InventoryData[i].GroupOwned;
4187 itemUpd.EveryOnePermissions = update.InventoryData[i].EveryoneMask; 4187 itemUpd.NextPermissions = update.InventoryData[i].NextOwnerMask;
4188 itemUpd.CreationDate = update.InventoryData[i].CreationDate; 4188 itemUpd.EveryOnePermissions = update.InventoryData[i].EveryoneMask;
4189 itemUpd.Folder = update.InventoryData[i].FolderID; 4189 itemUpd.CreationDate = update.InventoryData[i].CreationDate;
4190 itemUpd.InvType = update.InventoryData[i].InvType; 4190 itemUpd.Folder = update.InventoryData[i].FolderID;
4191 itemUpd.SalePrice = update.InventoryData[i].SalePrice; 4191 itemUpd.InvType = update.InventoryData[i].InvType;
4192 itemUpd.SaleType = update.InventoryData[i].SaleType; 4192 itemUpd.SalePrice = update.InventoryData[i].SalePrice;
4193 itemUpd.Flags = update.InventoryData[i].Flags; 4193 itemUpd.SaleType = update.InventoryData[i].SaleType;
4194 /* 4194 itemUpd.Flags = update.InventoryData[i].Flags;
4195 OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, 4195 /*
4196 update.InventoryData[i].ItemID, 4196 OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID,
4197 Util.FieldToString(update.InventoryData[i].Name), 4197 update.InventoryData[i].ItemID,
4198 Util.FieldToString(update.InventoryData[i].Description), 4198 Util.FieldToString(update.InventoryData[i].Name),
4199 update.InventoryData[i].NextOwnerMask); 4199 Util.FieldToString(update.InventoryData[i].Description),
4200 */ 4200 update.InventoryData[i].NextOwnerMask);
4201 OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, 4201 */
4202 update.InventoryData[i].ItemID, 4202 OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID,
4203 itemUpd); 4203 update.InventoryData[i].ItemID,
4204 } 4204 itemUpd);
4205 } 4205 }
4206 } 4206 }
4207 //Console.WriteLine(Pack.ToString()); 4207 }
4208 /*for (int i = 0; i < update.InventoryData.Length; i++) 4208 //Console.WriteLine(Pack.ToString());
4209 { 4209 /*for (int i = 0; i < update.InventoryData.Length; i++)
4210 if (update.InventoryData[i].TransactionID != LLUUID.Zero) 4210 {
4211 { 4211 if (update.InventoryData[i].TransactionID != LLUUID.Zero)
4212 AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionId)); 4212 {
4213 if (asset != null) 4213 AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionId));
4214 { 4214 if (asset != null)
4215 // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToString() + " already in cache"); 4215 {
4216 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); 4216 // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToString() + " already in cache");
4217 } 4217 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
4218 else 4218 }
4219 { 4219 else
4220 asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); 4220 {
4221 if (asset != null) 4221 asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID);
4222 { 4222 if (asset != null)
4223 //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToString() + " to cache"); 4223 {
4224 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); 4224 //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToString() + " to cache");
4225 } 4225 m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset);
4226 else 4226 }
4227 { 4227 else
4228 //Console.WriteLine("trying to update inventory item, but asset is null"); 4228 {
4229 } 4229 //Console.WriteLine("trying to update inventory item, but asset is null");
4230 } 4230 }
4231 } 4231 }
4232 else 4232 }
4233 { 4233 else
4234 m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ; 4234 {
4235 } 4235 m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ;
4236 }*/ 4236 }
4237 break; 4237 }*/
4238 case PacketType.CopyInventoryItem: 4238 break;
4239 CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack; 4239 case PacketType.CopyInventoryItem:
4240 4240 CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket)Pack;
4241 handlerCopyInventoryItem = null; 4241
4242 if (OnCopyInventoryItem != null) 4242 handlerCopyInventoryItem = null;
4243 { 4243 if (OnCopyInventoryItem != null)
4244 foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData) 4244 {
4245 { 4245 foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData)
4246 handlerCopyInventoryItem = OnCopyInventoryItem; 4246 {
4247 if (handlerCopyInventoryItem != null) 4247 handlerCopyInventoryItem = OnCopyInventoryItem;
4248 { 4248 if (handlerCopyInventoryItem != null)
4249 handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID, 4249 {
4250 datablock.OldItemID, datablock.NewFolderID, 4250 handlerCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID,
4251 Util.FieldToString(datablock.NewName)); 4251 datablock.OldItemID, datablock.NewFolderID,
4252 } 4252 Util.FieldToString(datablock.NewName));
4253 } 4253 }
4254 } 4254 }
4255 break; 4255 }
4256 case PacketType.MoveInventoryItem: 4256 break;
4257 MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack; 4257 case PacketType.MoveInventoryItem:
4258 if (OnMoveInventoryItem != null) 4258 MoveInventoryItemPacket moveitem = (MoveInventoryItemPacket)Pack;
4259 { 4259 if (OnMoveInventoryItem != null)
4260 handlerMoveInventoryItem = null; 4260 {
4261 foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData) 4261 handlerMoveInventoryItem = null;
4262 { 4262 foreach (MoveInventoryItemPacket.InventoryDataBlock datablock in moveitem.InventoryData)
4263 handlerMoveInventoryItem = OnMoveInventoryItem; 4263 {
4264 if (handlerMoveInventoryItem != null) 4264 handlerMoveInventoryItem = OnMoveInventoryItem;
4265 { 4265 if (handlerMoveInventoryItem != null)
4266 handlerMoveInventoryItem(this, datablock.FolderID, datablock.ItemID, datablock.Length, 4266 {
4267 Util.FieldToString(datablock.NewName)); 4267 handlerMoveInventoryItem(this, datablock.FolderID, datablock.ItemID, datablock.Length,
4268 } 4268 Util.FieldToString(datablock.NewName));
4269 } 4269 }
4270 } 4270 }
4271 break; 4271 }
4272 case PacketType.RemoveInventoryItem: 4272 break;
4273 RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack; 4273 case PacketType.RemoveInventoryItem:
4274 if (OnRemoveInventoryItem != null) 4274 RemoveInventoryItemPacket removeItem = (RemoveInventoryItemPacket)Pack;
4275 { 4275 if (OnRemoveInventoryItem != null)
4276 handlerRemoveInventoryItem = null; 4276 {
4277 foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData) 4277 handlerRemoveInventoryItem = null;
4278 { 4278 foreach (RemoveInventoryItemPacket.InventoryDataBlock datablock in removeItem.InventoryData)
4279 handlerRemoveInventoryItem = OnRemoveInventoryItem; 4279 {
4280 if (handlerRemoveInventoryItem != null) 4280 handlerRemoveInventoryItem = OnRemoveInventoryItem;
4281 { 4281 if (handlerRemoveInventoryItem != null)
4282 handlerRemoveInventoryItem(this, datablock.ItemID); 4282 {
4283 } 4283 handlerRemoveInventoryItem(this, datablock.ItemID);
4284 } 4284 }
4285 } 4285 }
4286 break; 4286 }
4287 case PacketType.RemoveInventoryFolder: 4287 break;
4288 RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack; 4288 case PacketType.RemoveInventoryFolder:
4289 if (OnRemoveInventoryFolder != null) 4289 RemoveInventoryFolderPacket removeFolder = (RemoveInventoryFolderPacket)Pack;
4290 { 4290 if (OnRemoveInventoryFolder != null)
4291 handlerRemoveInventoryFolder = null; 4291 {
4292 foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData) 4292 handlerRemoveInventoryFolder = null;
4293 { 4293 foreach (RemoveInventoryFolderPacket.FolderDataBlock datablock in removeFolder.FolderData)
4294 handlerRemoveInventoryFolder = OnRemoveInventoryFolder; 4294 {
4295 4295 handlerRemoveInventoryFolder = OnRemoveInventoryFolder;
4296 if (handlerRemoveInventoryFolder != null) 4296
4297 { 4297 if (handlerRemoveInventoryFolder != null)
4298 handlerRemoveInventoryFolder(this, datablock.FolderID); 4298 {
4299 } 4299 handlerRemoveInventoryFolder(this, datablock.FolderID);
4300 } 4300 }
4301 } 4301 }
4302 break; 4302 }
4303 case PacketType.RequestTaskInventory: 4303 break;
4304 RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; 4304 case PacketType.RequestTaskInventory:
4305 4305 RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack;
4306 handlerRequestTaskInventory = OnRequestTaskInventory; 4306
4307 if (handlerRequestTaskInventory != null) 4307 handlerRequestTaskInventory = OnRequestTaskInventory;
4308 { 4308 if (handlerRequestTaskInventory != null)
4309 handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID); 4309 {
4310 } 4310 handlerRequestTaskInventory(this, requesttask.InventoryData.LocalID);
4311 break; 4311 }
4312 case PacketType.UpdateTaskInventory: 4312 break;
4313 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; 4313 case PacketType.UpdateTaskInventory:
4314 if (OnUpdateTaskInventory != null) 4314 UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack;
4315 { 4315 if (OnUpdateTaskInventory != null)
4316 if (updatetask.UpdateData.Key == 0) 4316 {
4317 { 4317 if (updatetask.UpdateData.Key == 0)
4318 handlerUpdateTaskInventory = OnUpdateTaskInventory; 4318 {
4319 if (handlerUpdateTaskInventory != null) 4319 handlerUpdateTaskInventory = OnUpdateTaskInventory;
4320 { 4320 if (handlerUpdateTaskInventory != null)
4321 handlerUpdateTaskInventory(this, updatetask.InventoryData.ItemID, 4321 {
4322 updatetask.InventoryData.FolderID, updatetask.UpdateData.LocalID); 4322 handlerUpdateTaskInventory(this, updatetask.InventoryData.ItemID,
4323 } 4323 updatetask.InventoryData.FolderID, updatetask.UpdateData.LocalID);
4324 } 4324 }
4325 } 4325 }
4326 4326 }
4327 break; 4327
4328 4328 break;
4329 case PacketType.RemoveTaskInventory: 4329
4330 4330 case PacketType.RemoveTaskInventory:
4331 RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack; 4331
4332 4332 RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket)Pack;
4333 handlerRemoveTaskItem = OnRemoveTaskItem; 4333
4334 4334 handlerRemoveTaskItem = OnRemoveTaskItem;
4335 if (handlerRemoveTaskItem != null) 4335
4336 { 4336 if (handlerRemoveTaskItem != null)
4337 handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID); 4337 {
4338 } 4338 handlerRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID);
4339 4339 }
4340 break; 4340
4341 4341 break;
4342 case PacketType.MoveTaskInventory: 4342
4343 4343 case PacketType.MoveTaskInventory:
4344 MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack; 4344
4345 4345 MoveTaskInventoryPacket moveTaskInventoryPacket = (MoveTaskInventoryPacket)Pack;
4346 handlerMoveTaskItem = OnMoveTaskItem; 4346
4347 4347 handlerMoveTaskItem = OnMoveTaskItem;
4348 if (handlerMoveTaskItem != null) 4348
4349 { 4349 if (handlerMoveTaskItem != null)
4350 handlerMoveTaskItem( 4350 {
4351 this, moveTaskInventoryPacket.AgentData.FolderID, 4351 handlerMoveTaskItem(
4352 moveTaskInventoryPacket.InventoryData.LocalID, 4352 this, moveTaskInventoryPacket.AgentData.FolderID,
4353 moveTaskInventoryPacket.InventoryData.ItemID); 4353 moveTaskInventoryPacket.InventoryData.LocalID,
4354 } 4354 moveTaskInventoryPacket.InventoryData.ItemID);
4355 4355 }
4356 break; 4356
4357 4357 break;
4358 case PacketType.RezScript: 4358
4359 4359 case PacketType.RezScript:
4360 //Console.WriteLine(Pack.ToString()); 4360
4361 RezScriptPacket rezScriptx = (RezScriptPacket)Pack; 4361 //Console.WriteLine(Pack.ToString());
4362 4362 RezScriptPacket rezScriptx = (RezScriptPacket)Pack;
4363 handlerRezScript = OnRezScript; 4363
4364 4364 handlerRezScript = OnRezScript;
4365 if (handlerRezScript != null) 4365
4366 { 4366 if (handlerRezScript != null)
4367 handlerRezScript(this, rezScriptx.InventoryBlock.ItemID, rezScriptx.UpdateBlock.ObjectLocalID); 4367 {
4368 } 4368 handlerRezScript(this, rezScriptx.InventoryBlock.ItemID, rezScriptx.UpdateBlock.ObjectLocalID);
4369 break; 4369 }
4370 4370 break;
4371 case PacketType.MapLayerRequest: 4371
4372 RequestMapLayer(); 4372 case PacketType.MapLayerRequest:
4373 break; 4373 RequestMapLayer();
4374 case PacketType.MapBlockRequest: 4374 break;
4375 MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; 4375 case PacketType.MapBlockRequest:
4376 4376 MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack;
4377 handlerRequestMapBlocks = OnRequestMapBlocks; 4377
4378 if (handlerRequestMapBlocks != null) 4378 handlerRequestMapBlocks = OnRequestMapBlocks;
4379 { 4379 if (handlerRequestMapBlocks != null)
4380 handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, 4380 {
4381 MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); 4381 handlerRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY,
4382 } 4382 MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY);
4383 break; 4383 }
4384 case PacketType.MapNameRequest: 4384 break;
4385 MapNameRequestPacket map = (MapNameRequestPacket)Pack; 4385 case PacketType.MapNameRequest:
4386 string mapName = UTF8Encoding.UTF8.GetString(map.NameData.Name, 0, 4386 MapNameRequestPacket map = (MapNameRequestPacket)Pack;
4387 map.NameData.Name.Length - 1); 4387 string mapName = UTF8Encoding.UTF8.GetString(map.NameData.Name, 0,
4388 handlerMapNameRequest = OnMapNameRequest; 4388 map.NameData.Name.Length - 1);
4389 if (handlerMapNameRequest != null) 4389 handlerMapNameRequest = OnMapNameRequest;
4390 { 4390 if (handlerMapNameRequest != null)
4391 handlerMapNameRequest(this, mapName); 4391 {
4392 } 4392 handlerMapNameRequest(this, mapName);
4393 break; 4393 }
4394 case PacketType.TeleportLandmarkRequest: 4394 break;
4395 TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; 4395 case PacketType.TeleportLandmarkRequest:
4396 LLUUID lmid = tpReq.Info.LandmarkID; 4396 TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack;
4397 AssetLandmark lm; 4397 LLUUID lmid = tpReq.Info.LandmarkID;
4398 if (lmid != LLUUID.Zero) 4398 AssetLandmark lm;
4399 { 4399 if (lmid != LLUUID.Zero)
4400 AssetBase lma = m_assetCache.GetAsset(lmid, false); 4400 {
4401 4401 AssetBase lma = m_assetCache.GetAsset(lmid, false);
4402 if (lma == null) 4402
4403 { 4403 if (lma == null)
4404 // Failed to find landmark 4404 {
4405 4405 // Failed to find landmark
4406 TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel); 4406
4407 tpCancel.Info.SessionID = tpReq.Info.SessionID; 4407 TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
4408 tpCancel.Info.AgentID = tpReq.Info.AgentID; 4408 tpCancel.Info.SessionID = tpReq.Info.SessionID;
4409 OutPacket(tpCancel, ThrottleOutPacketType.Task); 4409 tpCancel.Info.AgentID = tpReq.Info.AgentID;
4410 } 4410 OutPacket(tpCancel, ThrottleOutPacketType.Task);
4411 4411 }
4412 4412
4413 try 4413
4414 { 4414 try
4415 lm = new AssetLandmark(lma); 4415 {
4416 } 4416 lm = new AssetLandmark(lma);
4417 catch (NullReferenceException) 4417 }
4418 { 4418 catch (NullReferenceException)
4419 // asset not found generates null ref inside the assetlandmark constructor. 4419 {
4420 TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel); 4420 // asset not found generates null ref inside the assetlandmark constructor.
4421 tpCancel.Info.SessionID = tpReq.Info.SessionID; 4421 TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
4422 tpCancel.Info.AgentID = tpReq.Info.AgentID; 4422 tpCancel.Info.SessionID = tpReq.Info.SessionID;
4423 OutPacket(tpCancel, ThrottleOutPacketType.Task); 4423 tpCancel.Info.AgentID = tpReq.Info.AgentID;
4424 break; 4424 OutPacket(tpCancel, ThrottleOutPacketType.Task);
4425 } 4425 break;
4426 } 4426 }
4427 else 4427 }
4428 { 4428 else
4429 4429 {
4430 // Teleport home request 4430
4431 handlerTeleportHomeRequest = OnTeleportHomeRequest; 4431 // Teleport home request
4432 if (handlerTeleportHomeRequest != null) 4432 handlerTeleportHomeRequest = OnTeleportHomeRequest;
4433 { 4433 if (handlerTeleportHomeRequest != null)
4434 handlerTeleportHomeRequest(this.AgentId,this); 4434 {
4435 } 4435 handlerTeleportHomeRequest(this.AgentId,this);
4436 break; 4436 }
4437 } 4437 break;
4438 4438 }
4439 handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest; 4439
4440 if (handlerTeleportLandmarkRequest != null) 4440 handlerTeleportLandmarkRequest = OnTeleportLandmarkRequest;
4441 { 4441 if (handlerTeleportLandmarkRequest != null)
4442 handlerTeleportLandmarkRequest(this, lm.RegionHandle, lm.Position); 4442 {
4443 } 4443 handlerTeleportLandmarkRequest(this, lm.RegionHandle, lm.Position);
4444 else 4444 }
4445 { 4445 else
4446 //no event handler so cancel request 4446 {
4447 4447 //no event handler so cancel request
4448 4448
4449 TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel); 4449
4450 tpCancel.Info.AgentID = tpReq.Info.AgentID; 4450 TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
4451 tpCancel.Info.SessionID = tpReq.Info.SessionID; 4451 tpCancel.Info.AgentID = tpReq.Info.AgentID;
4452 OutPacket(tpCancel, ThrottleOutPacketType.Task); 4452 tpCancel.Info.SessionID = tpReq.Info.SessionID;
4453 4453 OutPacket(tpCancel, ThrottleOutPacketType.Task);
4454 } 4454
4455 break; 4455 }
4456 case PacketType.TeleportLocationRequest: 4456 break;
4457 TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; 4457 case PacketType.TeleportLocationRequest:
4458 // Console.WriteLine(tpLocReq.ToString()); 4458 TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack;
4459 4459 // Console.WriteLine(tpLocReq.ToString());
4460 handlerTeleportLocationRequest = OnTeleportLocationRequest; 4460
4461 if (handlerTeleportLocationRequest != null) 4461 handlerTeleportLocationRequest = OnTeleportLocationRequest;
4462 { 4462 if (handlerTeleportLocationRequest != null)
4463 handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, 4463 {
4464 tpLocReq.Info.LookAt, 16); 4464 handlerTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position,
4465 } 4465 tpLocReq.Info.LookAt, 16);
4466 else 4466 }
4467 { 4467 else
4468 //no event handler so cancel request 4468 {
4469 TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel); 4469 //no event handler so cancel request
4470 tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; 4470 TeleportCancelPacket tpCancel = (TeleportCancelPacket)PacketPool.Instance.GetPacket(PacketType.TeleportCancel);
4471 tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; 4471 tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID;
4472 OutPacket(tpCancel, ThrottleOutPacketType.Task); 4472 tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID;
4473 } 4473 OutPacket(tpCancel, ThrottleOutPacketType.Task);
4474 break; 4474 }
4475 4475 break;
4476 #endregion 4476
4477 4477 #endregion
4478 4478
4479 case PacketType.UUIDNameRequest: 4479
4480 UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; 4480 case PacketType.UUIDNameRequest:
4481 foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) 4481 UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack;
4482 { 4482 foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock)
4483 handlerNameRequest = OnNameFromUUIDRequest; 4483 {
4484 if (handlerNameRequest != null) 4484 handlerNameRequest = OnNameFromUUIDRequest;
4485 { 4485 if (handlerNameRequest != null)
4486 handlerNameRequest(UUIDBlock.ID, this); 4486 {
4487 } 4487 handlerNameRequest(UUIDBlock.ID, this);
4488 } 4488 }
4489 break; 4489 }
4490 4490 break;
4491 #region Parcel related packets 4491
4492 4492 #region Parcel related packets
4493 case PacketType.ParcelAccessListRequest: 4493
4494 ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack; 4494 case PacketType.ParcelAccessListRequest:
4495 4495 ParcelAccessListRequestPacket requestPacket = (ParcelAccessListRequestPacket)Pack;
4496 handlerParcelAccessListRequest = OnParcelAccessListRequest; 4496
4497 4497 handlerParcelAccessListRequest = OnParcelAccessListRequest;
4498 if (handlerParcelAccessListRequest != null) 4498
4499 { 4499 if (handlerParcelAccessListRequest != null)
4500 handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID, 4500 {
4501 requestPacket.Data.Flags, requestPacket.Data.SequenceID, 4501 handlerParcelAccessListRequest(requestPacket.AgentData.AgentID, requestPacket.AgentData.SessionID,
4502 requestPacket.Data.LocalID, this); 4502 requestPacket.Data.Flags, requestPacket.Data.SequenceID,
4503 } 4503 requestPacket.Data.LocalID, this);
4504 break; 4504 }
4505 4505 break;
4506 case PacketType.ParcelAccessListUpdate: 4506
4507 ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack; 4507 case PacketType.ParcelAccessListUpdate:
4508 List<ParcelManager.ParcelAccessEntry> entries = new List<ParcelManager.ParcelAccessEntry>(); 4508 ParcelAccessListUpdatePacket updatePacket = (ParcelAccessListUpdatePacket)Pack;
4509 foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List) 4509 List<ParcelManager.ParcelAccessEntry> entries = new List<ParcelManager.ParcelAccessEntry>();
4510 { 4510 foreach (ParcelAccessListUpdatePacket.ListBlock block in updatePacket.List)
4511 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry(); 4511 {
4512 entry.AgentID = block.ID; 4512 ParcelManager.ParcelAccessEntry entry = new ParcelManager.ParcelAccessEntry();
4513 entry.Flags = (ParcelManager.AccessList)block.Flags; 4513 entry.AgentID = block.ID;
4514 entry.Time = new DateTime(); 4514 entry.Flags = (ParcelManager.AccessList)block.Flags;
4515 entries.Add(entry); 4515 entry.Time = new DateTime();
4516 } 4516 entries.Add(entry);
4517 4517 }
4518 handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest; 4518
4519 if (handlerParcelAccessListUpdateRequest != null) 4519 handlerParcelAccessListUpdateRequest = OnParcelAccessListUpdateRequest;
4520 { 4520 if (handlerParcelAccessListUpdateRequest != null)
4521 handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID, 4521 {
4522 updatePacket.AgentData.SessionID, updatePacket.Data.Flags, 4522 handlerParcelAccessListUpdateRequest(updatePacket.AgentData.AgentID,
4523 updatePacket.Data.LocalID, entries, this); 4523 updatePacket.AgentData.SessionID, updatePacket.Data.Flags,
4524 } 4524 updatePacket.Data.LocalID, entries, this);
4525 break; 4525 }
4526 case PacketType.ParcelPropertiesRequest: 4526 break;
4527 4527 case PacketType.ParcelPropertiesRequest:
4528 ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack; 4528
4529 4529 ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack;
4530 handlerParcelPropertiesRequest = OnParcelPropertiesRequest; 4530
4531 if (handlerParcelPropertiesRequest != null) 4531 handlerParcelPropertiesRequest = OnParcelPropertiesRequest;
4532 { 4532 if (handlerParcelPropertiesRequest != null)
4533 handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), 4533 {
4534 (int)Math.Round(propertiesRequest.ParcelData.South), 4534 handlerParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West),
4535 (int)Math.Round(propertiesRequest.ParcelData.East), 4535 (int)Math.Round(propertiesRequest.ParcelData.South),
4536 (int)Math.Round(propertiesRequest.ParcelData.North), 4536 (int)Math.Round(propertiesRequest.ParcelData.East),
4537 propertiesRequest.ParcelData.SequenceID, 4537 (int)Math.Round(propertiesRequest.ParcelData.North),
4538 propertiesRequest.ParcelData.SnapSelection, this); 4538 propertiesRequest.ParcelData.SequenceID,
4539 } 4539 propertiesRequest.ParcelData.SnapSelection, this);
4540 break; 4540 }
4541 case PacketType.ParcelDivide: 4541 break;
4542 ParcelDividePacket landDivide = (ParcelDividePacket)Pack; 4542 case PacketType.ParcelDivide:
4543 4543 ParcelDividePacket landDivide = (ParcelDividePacket)Pack;
4544 handlerParcelDivideRequest = OnParcelDivideRequest; 4544
4545 if (handlerParcelDivideRequest != null) 4545 handlerParcelDivideRequest = OnParcelDivideRequest;
4546 { 4546 if (handlerParcelDivideRequest != null)
4547 handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West), 4547 {
4548 (int)Math.Round(landDivide.ParcelData.South), 4548 handlerParcelDivideRequest((int)Math.Round(landDivide.ParcelData.West),
4549 (int)Math.Round(landDivide.ParcelData.East), 4549 (int)Math.Round(landDivide.ParcelData.South),
4550 (int)Math.Round(landDivide.ParcelData.North), this); 4550 (int)Math.Round(landDivide.ParcelData.East),
4551 } 4551 (int)Math.Round(landDivide.ParcelData.North), this);
4552 break; 4552 }
4553 case PacketType.ParcelJoin: 4553 break;
4554 ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack; 4554 case PacketType.ParcelJoin:
4555 4555 ParcelJoinPacket landJoin = (ParcelJoinPacket)Pack;
4556 handlerParcelJoinRequest = OnParcelJoinRequest; 4556
4557 4557 handlerParcelJoinRequest = OnParcelJoinRequest;
4558 if (handlerParcelJoinRequest != null) 4558
4559 { 4559 if (handlerParcelJoinRequest != null)
4560 handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West), 4560 {
4561 (int)Math.Round(landJoin.ParcelData.South), 4561 handlerParcelJoinRequest((int)Math.Round(landJoin.ParcelData.West),
4562 (int)Math.Round(landJoin.ParcelData.East), 4562 (int)Math.Round(landJoin.ParcelData.South),
4563 (int)Math.Round(landJoin.ParcelData.North), this); 4563 (int)Math.Round(landJoin.ParcelData.East),
4564 } 4564 (int)Math.Round(landJoin.ParcelData.North), this);
4565 break; 4565 }
4566 case PacketType.ParcelPropertiesUpdate: 4566 break;
4567 ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack; 4567 case PacketType.ParcelPropertiesUpdate:
4568 4568 ParcelPropertiesUpdatePacket parcelPropertiesPacket = (ParcelPropertiesUpdatePacket)Pack;
4569 handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest; 4569
4570 4570 handlerParcelPropertiesUpdateRequest = OnParcelPropertiesUpdateRequest;
4571 if (handlerParcelPropertiesUpdateRequest != null) 4571
4572 { 4572 if (handlerParcelPropertiesUpdateRequest != null)
4573 handlerParcelPropertiesUpdateRequest(parcelPropertiesPacket, this); 4573 {
4574 } 4574 handlerParcelPropertiesUpdateRequest(parcelPropertiesPacket, this);
4575 break; 4575 }
4576 case PacketType.ParcelSelectObjects: 4576 break;
4577 ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack; 4577 case PacketType.ParcelSelectObjects:
4578 4578 ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket)Pack;
4579 handlerParcelSelectObjects = OnParcelSelectObjects; 4579
4580 4580 handlerParcelSelectObjects = OnParcelSelectObjects;
4581 if (handlerParcelSelectObjects != null) 4581
4582 { 4582 if (handlerParcelSelectObjects != null)
4583 handlerParcelSelectObjects(selectPacket.ParcelData.LocalID, 4583 {
4584 Convert.ToInt32(selectPacket.ParcelData.ReturnType), this); 4584 handlerParcelSelectObjects(selectPacket.ParcelData.LocalID,
4585 } 4585 Convert.ToInt32(selectPacket.ParcelData.ReturnType), this);
4586 break; 4586 }
4587 case PacketType.ParcelObjectOwnersRequest: 4587 break;
4588 //Console.WriteLine(Pack.ToString()); 4588 case PacketType.ParcelObjectOwnersRequest:
4589 ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack; 4589 //Console.WriteLine(Pack.ToString());
4590 4590 ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket)Pack;
4591 handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest; 4591
4592 4592 handlerParcelObjectOwnerRequest = OnParcelObjectOwnerRequest;
4593 if (handlerParcelObjectOwnerRequest != null) 4593
4594 { 4594 if (handlerParcelObjectOwnerRequest != null)
4595 handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this); 4595 {
4596 } 4596 handlerParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this);
4597 break; 4597 }
4598 4598 break;
4599 #endregion 4599
4600 4600 #endregion
4601 #region Estate Packets 4601
4602 4602 #region Estate Packets
4603 case PacketType.EstateOwnerMessage: 4603
4604 EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; 4604 case PacketType.EstateOwnerMessage:
4605 4605 EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack;
4606 handlerEstateOwnerMessage = OnEstateOwnerMessage; 4606
4607 4607 handlerEstateOwnerMessage = OnEstateOwnerMessage;
4608 if (handlerEstateOwnerMessage != null) 4608
4609 { 4609 if (handlerEstateOwnerMessage != null)
4610 handlerEstateOwnerMessage(messagePacket, this); 4610 {
4611 } 4611 handlerEstateOwnerMessage(messagePacket, this);
4612 break; 4612 }
4613 case PacketType.RequestRegionInfo: 4613 break;
4614 RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData; 4614 case PacketType.RequestRegionInfo:
4615 4615 RequestRegionInfoPacket.AgentDataBlock mPacket = ((RequestRegionInfoPacket)Pack).AgentData;
4616 handlerRegionInfoRequest = OnRegionInfoRequest; 4616
4617 if (handlerRegionInfoRequest != null) 4617 handlerRegionInfoRequest = OnRegionInfoRequest;
4618 { 4618 if (handlerRegionInfoRequest != null)
4619 handlerRegionInfoRequest(this, mPacket.SessionID); 4619 {
4620 } 4620 handlerRegionInfoRequest(this, mPacket.SessionID);
4621 break; 4621 }
4622 case PacketType.EstateCovenantRequest: 4622 break;
4623 4623 case PacketType.EstateCovenantRequest:
4624 EstateCovenantRequestPacket.AgentDataBlock epack = 4624
4625 ((EstateCovenantRequestPacket)Pack).AgentData; 4625 EstateCovenantRequestPacket.AgentDataBlock epack =
4626 4626 ((EstateCovenantRequestPacket)Pack).AgentData;
4627 handlerEstateCovenantRequest = OnEstateCovenantRequest; 4627
4628 if (handlerEstateCovenantRequest != null) 4628 handlerEstateCovenantRequest = OnEstateCovenantRequest;
4629 { 4629 if (handlerEstateCovenantRequest != null)
4630 handlerEstateCovenantRequest(this, epack.SessionID); 4630 {
4631 } 4631 handlerEstateCovenantRequest(this, epack.SessionID);
4632 break; 4632 }
4633 4633 break;
4634 #endregion 4634
4635 4635 #endregion
4636 #region GodPackets 4636
4637 4637 #region GodPackets
4638 case PacketType.RequestGodlikePowers: 4638
4639 RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack; 4639 case PacketType.RequestGodlikePowers:
4640 RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock; 4640 RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket)Pack;
4641 LLUUID token = rblock.Token; 4641 RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock;
4642 4642 LLUUID token = rblock.Token;
4643 RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; 4643
4644 4644 RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData;
4645 handlerReqGodlikePowers = OnRequestGodlikePowers; 4645
4646 4646 handlerReqGodlikePowers = OnRequestGodlikePowers;
4647 if (handlerReqGodlikePowers != null) 4647
4648 { 4648 if (handlerReqGodlikePowers != null)
4649 handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this); 4649 {
4650 } 4650 handlerReqGodlikePowers(ablock.AgentID, ablock.SessionID, token, rblock.Godlike, this);
4651 4651 }
4652 break; 4652
4653 case PacketType.GodKickUser: 4653 break;
4654 m_log.Warn("[CLIENT]: unhandled GodKickUser packet"); 4654 case PacketType.GodKickUser:
4655 4655 m_log.Warn("[CLIENT]: unhandled GodKickUser packet");
4656 GodKickUserPacket gkupack = (GodKickUserPacket)Pack; 4656
4657 4657 GodKickUserPacket gkupack = (GodKickUserPacket)Pack;
4658 if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID) 4658
4659 { 4659 if (gkupack.UserInfo.GodSessionID == SessionId && AgentId == gkupack.UserInfo.GodID)
4660 handlerGodKickUser = OnGodKickUser; 4660 {
4661 if (handlerGodKickUser != null) 4661 handlerGodKickUser = OnGodKickUser;
4662 { 4662 if (handlerGodKickUser != null)
4663 handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, 4663 {
4664 gkupack.UserInfo.AgentID, (uint)0, gkupack.UserInfo.Reason); 4664 handlerGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID,
4665 } 4665 gkupack.UserInfo.AgentID, (uint)0, gkupack.UserInfo.Reason);
4666 } 4666 }
4667 else 4667 }
4668 { 4668 else
4669 SendAgentAlertMessage("Kick request denied", false); 4669 {
4670 } 4670 SendAgentAlertMessage("Kick request denied", false);
4671 //KickUserPacket kupack = new KickUserPacket(); 4671 }
4672 //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo; 4672 //KickUserPacket kupack = new KickUserPacket();
4673 4673 //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo;
4674 //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID; 4674
4675 //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID; 4675 //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID;
4676 4676 //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID;
4677 //kupack.TargetBlock.TargetIP = (uint)0; 4677
4678 //kupack.TargetBlock.TargetPort = (ushort)0; 4678 //kupack.TargetBlock.TargetIP = (uint)0;
4679 //kupack.UserInfo.Reason = gkupack.UserInfo.Reason; 4679 //kupack.TargetBlock.TargetPort = (ushort)0;
4680 4680 //kupack.UserInfo.Reason = gkupack.UserInfo.Reason;
4681 //OutPacket(kupack, ThrottleOutPacketType.Task); 4681
4682 break; 4682 //OutPacket(kupack, ThrottleOutPacketType.Task);
4683 4683 break;
4684 #endregion 4684
4685 4685 #endregion
4686 #region Economy/Transaction Packets 4686
4687 4687 #region Economy/Transaction Packets
4688 case PacketType.MoneyBalanceRequest: 4688
4689 MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack; 4689 case PacketType.MoneyBalanceRequest:
4690 4690 MoneyBalanceRequestPacket moneybalancerequestpacket = (MoneyBalanceRequestPacket)Pack;
4691 handlerMoneyBalanceRequest = OnMoneyBalanceRequest; 4691
4692 4692 handlerMoneyBalanceRequest = OnMoneyBalanceRequest;
4693 if (handlerMoneyBalanceRequest != null) 4693
4694 { 4694 if (handlerMoneyBalanceRequest != null)
4695 handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID); 4695 {
4696 } 4696 handlerMoneyBalanceRequest(this, moneybalancerequestpacket.AgentData.AgentID, moneybalancerequestpacket.AgentData.SessionID, moneybalancerequestpacket.MoneyData.TransactionID);
4697 4697 }
4698 break; 4698
4699 case PacketType.EconomyDataRequest: 4699 break;
4700 4700 case PacketType.EconomyDataRequest:
4701 handlerEconomoyDataRequest = OnEconomyDataRequest; 4701
4702 if (handlerEconomoyDataRequest != null) 4702 handlerEconomoyDataRequest = OnEconomyDataRequest;
4703 { 4703 if (handlerEconomoyDataRequest != null)
4704 handlerEconomoyDataRequest(AgentId); 4704 {
4705 } 4705 handlerEconomoyDataRequest(AgentId);
4706 // TODO: handle this packet 4706 }
4707 //m_log.Warn("[CLIENT]: unhandled EconomyDataRequest packet"); 4707 // TODO: handle this packet
4708 break; 4708 //m_log.Warn("[CLIENT]: unhandled EconomyDataRequest packet");
4709 case PacketType.RequestPayPrice: 4709 break;
4710 RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack; 4710 case PacketType.RequestPayPrice:
4711 handlerRequestPayPrice = OnRequestPayPrice; 4711 RequestPayPricePacket requestPayPricePacket = (RequestPayPricePacket)Pack;
4712 if (handlerRequestPayPrice != null) 4712 handlerRequestPayPrice = OnRequestPayPrice;
4713 { 4713 if (handlerRequestPayPrice != null)
4714 handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID); 4714 {
4715 } 4715 handlerRequestPayPrice(this, requestPayPricePacket.ObjectData.ObjectID);
4716 break; 4716 }
4717 4717 break;
4718 #endregion 4718
4719 4719 #endregion
4720 #region unimplemented handlers 4720
4721 4721 #region unimplemented handlers
4722 case PacketType.StartPingCheck: 4722
4723 // Send the client the ping response back 4723 case PacketType.StartPingCheck:
4724 // Pass the same PingID in the matching packet 4724 // Send the client the ping response back
4725 // Handled In the packet processing 4725 // Pass the same PingID in the matching packet
4726 //m_log.Debug("[CLIENT]: possibly unhandled StartPingCheck packet"); 4726 // Handled In the packet processing
4727 break; 4727 //m_log.Debug("[CLIENT]: possibly unhandled StartPingCheck packet");
4728 case PacketType.CompletePingCheck: 4728 break;
4729 // TODO: Perhaps this should be processed on the Sim to determine whether or not to drop a dead client 4729 case PacketType.CompletePingCheck:
4730 //m_log.Warn("[CLIENT]: unhandled CompletePingCheck packet"); 4730 // TODO: Perhaps this should be processed on the Sim to determine whether or not to drop a dead client
4731 break; 4731 //m_log.Warn("[CLIENT]: unhandled CompletePingCheck packet");
4732 case PacketType.ObjectScale: 4732 break;
4733 // TODO: handle this packet 4733 case PacketType.ObjectScale:
4734 m_log.Warn("[CLIENT]: unhandled ObjectScale packet"); 4734 // TODO: handle this packet
4735 break; 4735 m_log.Warn("[CLIENT]: unhandled ObjectScale packet");
4736 case PacketType.ViewerStats: 4736 break;
4737 // TODO: handle this packet 4737 case PacketType.ViewerStats:
4738 m_log.Warn("[CLIENT]: unhandled ViewerStats packet"); 4738 // TODO: handle this packet
4739 break; 4739 m_log.Warn("[CLIENT]: unhandled ViewerStats packet");
4740 4740 break;
4741 case PacketType.CreateGroupRequest: 4741
4742 // TODO: handle this packet 4742 case PacketType.CreateGroupRequest:
4743 m_log.Warn("[CLIENT]: unhandled CreateGroupRequest packet"); 4743 // TODO: handle this packet
4744 break; 4744 m_log.Warn("[CLIENT]: unhandled CreateGroupRequest packet");
4745 case PacketType.GenericMessage: 4745 break;
4746 // TODO: handle this packet 4746 case PacketType.GenericMessage:
4747 m_log.Warn("[CLIENT]: unhandled GenericMessage packet"); 4747 // TODO: handle this packet
4748 break; 4748 m_log.Warn("[CLIENT]: unhandled GenericMessage packet");
4749 case PacketType.MapItemRequest: 4749 break;
4750 // TODO: handle this packet 4750 case PacketType.MapItemRequest:
4751 m_log.Warn("[CLIENT]: unhandled MapItemRequest packet"); 4751 // TODO: handle this packet
4752 break; 4752 m_log.Warn("[CLIENT]: unhandled MapItemRequest packet");
4753 case PacketType.TransferAbort: 4753 break;
4754 // TODO: handle this packet 4754 case PacketType.TransferAbort:
4755 m_log.Warn("[CLIENT]: unhandled TransferAbort packet"); 4755 // TODO: handle this packet
4756 break; 4756 m_log.Warn("[CLIENT]: unhandled TransferAbort packet");
4757 case PacketType.MuteListRequest: 4757 break;
4758 // TODO: handle this packet 4758 case PacketType.MuteListRequest:
4759 m_log.Warn("[CLIENT]: unhandled MuteListRequest packet"); 4759 // TODO: handle this packet
4760 break; 4760 m_log.Warn("[CLIENT]: unhandled MuteListRequest packet");
4761 case PacketType.ParcelDwellRequest: 4761 break;
4762 // TODO: handle this packet 4762 case PacketType.ParcelDwellRequest:
4763 m_log.Warn("[CLIENT]: unhandled ParcelDwellRequest packet"); 4763 // TODO: handle this packet
4764 break; 4764 m_log.Warn("[CLIENT]: unhandled ParcelDwellRequest packet");
4765 case PacketType.UseCircuitCode: 4765 break;
4766 // TODO: Don't display this one, we handle it at a lower level 4766 case PacketType.UseCircuitCode:
4767 //m_log.Warn("[CLIENT]: unhandled UseCircuitCode packet"); 4767 // TODO: Don't display this one, we handle it at a lower level
4768 break; 4768 //m_log.Warn("[CLIENT]: unhandled UseCircuitCode packet");
4769 4769 break;
4770 case PacketType.AgentHeightWidth: 4770
4771 // TODO: handle this packet 4771 case PacketType.AgentHeightWidth:
4772 m_log.Warn("[CLIENT]: unhandled AgentHeightWidth packet"); 4772 // TODO: handle this packet
4773 break; 4773 m_log.Warn("[CLIENT]: unhandled AgentHeightWidth packet");
4774 case PacketType.ObjectSpinStop: 4774 break;
4775 // TODO: handle this packet 4775 case PacketType.ObjectSpinStop:
4776 m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet"); 4776 // TODO: handle this packet
4777 break; 4777 m_log.Warn("[CLIENT]: unhandled ObjectSpinStop packet");
4778 case PacketType.SoundTrigger: 4778 break;
4779 // TODO: handle this packet 4779 case PacketType.SoundTrigger:
4780 m_log.Warn("[CLIENT]: unhandled SoundTrigger packet"); 4780 // TODO: handle this packet
4781 break; 4781 m_log.Warn("[CLIENT]: unhandled SoundTrigger packet");
4782 case PacketType.InventoryDescendents: 4782 break;
4783 // TODO: handle this packet 4783 case PacketType.InventoryDescendents:
4784 m_log.Warn("[CLIENT]: unhandled InventoryDescent packet"); 4784 // TODO: handle this packet
4785 break; 4785 m_log.Warn("[CLIENT]: unhandled InventoryDescent packet");
4786 case PacketType.GetScriptRunning: 4786 break;
4787 m_log.Warn("[CLIENT]: unhandled GetScriptRunning packet"); 4787 case PacketType.GetScriptRunning:
4788 break; 4788 m_log.Warn("[CLIENT]: unhandled GetScriptRunning packet");
4789 default: 4789 break;
4790 m_log.Warn("[CLIENT]: unhandled packet " + Pack.ToString()); 4790 default:
4791 break; 4791 m_log.Warn("[CLIENT]: unhandled packet " + Pack.ToString());
4792 4792 break;
4793 #endregion 4793
4794 } 4794 #endregion
4795 } 4795 }
4796 4796 }
4797 PacketPool.Instance.ReturnPacket(Pack); 4797
4798 } 4798 PacketPool.Instance.ReturnPacket(Pack);
4799 4799 }
4800 private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) 4800
4801 { 4801 private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket)
4802 PrimitiveBaseShape shape = new PrimitiveBaseShape(); 4802 {
4803 4803 PrimitiveBaseShape shape = new PrimitiveBaseShape();
4804 shape.PCode = addPacket.ObjectData.PCode; 4804
4805 shape.State = addPacket.ObjectData.State; 4805 shape.PCode = addPacket.ObjectData.PCode;
4806 shape.PathBegin = addPacket.ObjectData.PathBegin; 4806 shape.State = addPacket.ObjectData.State;
4807 shape.PathEnd = addPacket.ObjectData.PathEnd; 4807 shape.PathBegin = addPacket.ObjectData.PathBegin;
4808 shape.PathScaleX = addPacket.ObjectData.PathScaleX; 4808 shape.PathEnd = addPacket.ObjectData.PathEnd;
4809 shape.PathScaleY = addPacket.ObjectData.PathScaleY; 4809 shape.PathScaleX = addPacket.ObjectData.PathScaleX;
4810 shape.PathShearX = addPacket.ObjectData.PathShearX; 4810 shape.PathScaleY = addPacket.ObjectData.PathScaleY;
4811 shape.PathShearY = addPacket.ObjectData.PathShearY; 4811 shape.PathShearX = addPacket.ObjectData.PathShearX;
4812 shape.PathSkew = addPacket.ObjectData.PathSkew; 4812 shape.PathShearY = addPacket.ObjectData.PathShearY;
4813 shape.ProfileBegin = addPacket.ObjectData.ProfileBegin; 4813 shape.PathSkew = addPacket.ObjectData.PathSkew;
4814 shape.ProfileEnd = addPacket.ObjectData.ProfileEnd; 4814 shape.ProfileBegin = addPacket.ObjectData.ProfileBegin;
4815 shape.Scale = addPacket.ObjectData.Scale; 4815 shape.ProfileEnd = addPacket.ObjectData.ProfileEnd;
4816 shape.PathCurve = addPacket.ObjectData.PathCurve; 4816 shape.Scale = addPacket.ObjectData.Scale;
4817 shape.ProfileCurve = addPacket.ObjectData.ProfileCurve; 4817 shape.PathCurve = addPacket.ObjectData.PathCurve;
4818 shape.ProfileHollow = addPacket.ObjectData.ProfileHollow; 4818 shape.ProfileCurve = addPacket.ObjectData.ProfileCurve;
4819 shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; 4819 shape.ProfileHollow = addPacket.ObjectData.ProfileHollow;
4820 shape.PathRevolutions = addPacket.ObjectData.PathRevolutions; 4820 shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset;
4821 shape.PathTaperX = addPacket.ObjectData.PathTaperX; 4821 shape.PathRevolutions = addPacket.ObjectData.PathRevolutions;
4822 shape.PathTaperY = addPacket.ObjectData.PathTaperY; 4822 shape.PathTaperX = addPacket.ObjectData.PathTaperX;
4823 shape.PathTwist = addPacket.ObjectData.PathTwist; 4823 shape.PathTaperY = addPacket.ObjectData.PathTaperY;
4824 shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; 4824 shape.PathTwist = addPacket.ObjectData.PathTwist;
4825 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("89556747-24cb-43ed-920b-47caed15465f")); 4825 shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin;
4826 shape.TextureEntry = ntex.ToBytes(); 4826 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("89556747-24cb-43ed-920b-47caed15465f"));
4827 //shape.Textures = ntex; 4827 shape.TextureEntry = ntex.ToBytes();
4828 return shape; 4828 //shape.Textures = ntex;
4829 } 4829 return shape;
4830 4830 }
4831 public void SendBlueBoxMessage(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message) 4831
4832 { 4832 public void SendBlueBoxMessage(LLUUID FromAvatarID, LLUUID fromSessionID, String FromAvatarName, String Message)
4833 if (!ChildAgentStatus()) 4833 {
4834 SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)1, (uint)Util.UnixTimeSinceEpoch()); 4834 if (!ChildAgentStatus())
4835 4835 SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)1, (uint)Util.UnixTimeSinceEpoch());
4836 //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch()); 4836
4837 } 4837 //SendInstantMessage(FromAvatarID, fromSessionID, Message, AgentId, SessionId, FromAvatarName, (byte)21,(uint) Util.UnixTimeSinceEpoch());
4838 4838 }
4839 public void SendLogoutPacket() 4839
4840 { 4840 public void SendLogoutPacket()
4841 LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply); 4841 {
4842 // TODO: don't create new blocks if recycling an old packet 4842 LogoutReplyPacket logReply = (LogoutReplyPacket)PacketPool.Instance.GetPacket(PacketType.LogoutReply);
4843 logReply.AgentData.AgentID = AgentId; 4843 // TODO: don't create new blocks if recycling an old packet
4844 logReply.AgentData.SessionID = SessionId; 4844 logReply.AgentData.AgentID = AgentId;
4845 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; 4845 logReply.AgentData.SessionID = SessionId;
4846 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); 4846 logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1];
4847 logReply.InventoryData[0].ItemID = LLUUID.Zero; 4847 logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock();
4848 4848 logReply.InventoryData[0].ItemID = LLUUID.Zero;
4849 OutPacket(logReply, ThrottleOutPacketType.Task); 4849
4850 } 4850 OutPacket(logReply, ThrottleOutPacketType.Task);
4851 4851 }
4852 public ClientInfo GetClientInfo() 4852
4853 { 4853 public ClientInfo GetClientInfo()
4854 //MainLog.Instance.Verbose("CLIENT", "GetClientInfo BGN"); 4854 {
4855 4855 //MainLog.Instance.Verbose("CLIENT", "GetClientInfo BGN");
4856 ClientInfo info = new ClientInfo(); 4856
4857 info.userEP = this.m_userEndPoint; 4857 ClientInfo info = new ClientInfo();
4858 info.proxyEP = this.m_proxyEndPoint; 4858 info.userEP = this.m_userEndPoint;
4859 info.agentcircuit = new sAgentCircuitData(RequestClientInfo()); 4859 info.proxyEP = this.m_proxyEndPoint;
4860 4860 info.agentcircuit = new sAgentCircuitData(RequestClientInfo());
4861 info.pendingAcks = m_pendingAcks; 4861
4862 4862 info.pendingAcks = m_pendingAcks;
4863 info.needAck = new Dictionary<uint,byte[]>(); 4863
4864 4864 info.needAck = new Dictionary<uint,byte[]>();
4865 lock (m_needAck) 4865
4866 { 4866 lock (m_needAck)
4867 foreach (uint key in m_needAck.Keys) 4867 {
4868 { 4868 foreach (uint key in m_needAck.Keys)
4869 info.needAck.Add(key, m_needAck[key].ToBytes()); 4869 {
4870 } 4870 info.needAck.Add(key, m_needAck[key].ToBytes());
4871 } 4871 }
4872 4872 }
4873/* pending 4873
4874 QueItem[] queitems = m_packetQueue.GetQueueArray(); 4874/* pending
4875 4875 QueItem[] queitems = m_packetQueue.GetQueueArray();
4876 MainLog.Instance.Verbose("CLIENT", "Queue Count : [{0}]", queitems.Length); 4876
4877 4877 MainLog.Instance.Verbose("CLIENT", "Queue Count : [{0}]", queitems.Length);
4878 for (int i = 0; i < queitems.Length; i++) 4878
4879 { 4879 for (int i = 0; i < queitems.Length; i++)
4880 if (queitems[i].Incoming == false) 4880 {
4881 { 4881 if (queitems[i].Incoming == false)
4882 info.out_packets.Add(queitems[i].Packet.ToBytes()); 4882 {
4883 MainLog.Instance.Verbose("CLIENT", "Add OutPacket [{0}]", queitems[i].Packet.Type.ToString()); 4883 info.out_packets.Add(queitems[i].Packet.ToBytes());
4884 } 4884 MainLog.Instance.Verbose("CLIENT", "Add OutPacket [{0}]", queitems[i].Packet.Type.ToString());
4885 } 4885 }
4886*/ 4886 }
4887 4887*/
4888 info.sequence = m_sequence; 4888
4889 4889 info.sequence = m_sequence;
4890 //MainLog.Instance.Verbose("CLIENT", "GetClientInfo END"); 4890
4891 4891 //MainLog.Instance.Verbose("CLIENT", "GetClientInfo END");
4892 return info; 4892
4893 } 4893 return info;
4894 4894 }
4895 public void SetClientInfo(ClientInfo info) 4895
4896 { 4896 public void SetClientInfo(ClientInfo info)
4897 m_pendingAcks = info.pendingAcks; 4897 {
4898 4898 m_pendingAcks = info.pendingAcks;
4899 m_needAck = new Dictionary<uint,Packet>(); 4899
4900 4900 m_needAck = new Dictionary<uint,Packet>();
4901 Packet packet = null; 4901
4902 int packetEnd = 0; 4902 Packet packet = null;
4903 byte[] zero = new byte[3000]; 4903 int packetEnd = 0;
4904 4904 byte[] zero = new byte[3000];
4905 foreach (uint key in info.needAck.Keys) 4905
4906 { 4906 foreach (uint key in info.needAck.Keys)
4907 byte[] buff = info.needAck[key]; 4907 {
4908 4908 byte[] buff = info.needAck[key];
4909 packetEnd = buff.Length - 1; 4909
4910 4910 packetEnd = buff.Length - 1;
4911 try 4911
4912 { 4912 try
4913 packet = PacketPool.Instance.GetPacket(buff, ref packetEnd, zero); 4913 {
4914 } 4914 packet = PacketPool.Instance.GetPacket(buff, ref packetEnd, zero);
4915 catch (Exception) 4915 }
4916 { 4916 catch (Exception)
4917 //MainLog.Instance.Debug("UDPSERVER", e.ToString()); 4917 {
4918 } 4918 //MainLog.Instance.Debug("UDPSERVER", e.ToString());
4919 4919 }
4920 m_needAck.Add(key, packet); 4920
4921 } 4921 m_needAck.Add(key, packet);
4922 4922 }
4923 m_sequence = info.sequence; 4923
4924 } 4924 m_sequence = info.sequence;
4925 } 4925 }
4926} 4926 }
4927} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/PacketQueue.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
index 7101b4c..5dd1da6 100644
--- a/OpenSim/Region/ClientStack/PacketQueue.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketQueue.cs
@@ -1,532 +1,532 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Threading; 30using System.Threading;
31using System.Timers; 31using System.Timers;
32using libsecondlife; 32using libsecondlife;
33using libsecondlife.Packets; 33using libsecondlife.Packets;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Statistics; 35using OpenSim.Framework.Statistics;
36using OpenSim.Framework.Statistics.Interfaces; 36using OpenSim.Framework.Statistics.Interfaces;
37using Timer=System.Timers.Timer; 37using Timer=System.Timers.Timer;
38 38
39namespace OpenSim.Region.ClientStack 39namespace OpenSim.Region.ClientStack.LindenUDP
40{ 40{
41 public class PacketQueue : IPullStatsProvider 41 public class LLPacketQueue : IPullStatsProvider
42 { 42 {
43 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 43 //private static readonly log4net.ILog m_log = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
44 44
45 private bool m_enabled = true; 45 private bool m_enabled = true;
46 46
47 private BlockingQueue<QueItem> SendQueue; 47 private BlockingQueue<LLQueItem> SendQueue;
48 48
49 private Queue<QueItem> IncomingPacketQueue; 49 private Queue<LLQueItem> IncomingPacketQueue;
50 private Queue<QueItem> OutgoingPacketQueue; 50 private Queue<LLQueItem> OutgoingPacketQueue;
51 private Queue<QueItem> ResendOutgoingPacketQueue; 51 private Queue<LLQueItem> ResendOutgoingPacketQueue;
52 private Queue<QueItem> LandOutgoingPacketQueue; 52 private Queue<LLQueItem> LandOutgoingPacketQueue;
53 private Queue<QueItem> WindOutgoingPacketQueue; 53 private Queue<LLQueItem> WindOutgoingPacketQueue;
54 private Queue<QueItem> CloudOutgoingPacketQueue; 54 private Queue<LLQueItem> CloudOutgoingPacketQueue;
55 private Queue<QueItem> TaskOutgoingPacketQueue; 55 private Queue<LLQueItem> TaskOutgoingPacketQueue;
56 private Queue<QueItem> TextureOutgoingPacketQueue; 56 private Queue<LLQueItem> TextureOutgoingPacketQueue;
57 private Queue<QueItem> AssetOutgoingPacketQueue; 57 private Queue<LLQueItem> AssetOutgoingPacketQueue;
58 58
59 private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>(); 59 private Dictionary<uint, uint> PendingAcks = new Dictionary<uint, uint>();
60 private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>(); 60 private Dictionary<uint, Packet> NeedAck = new Dictionary<uint, Packet>();
61 61
62 // All throttle times and number of bytes are calculated by dividing by this value 62 // All throttle times and number of bytes are calculated by dividing by this value
63 // This value also determines how many times per throttletimems the timer will run 63 // This value also determines how many times per throttletimems the timer will run
64 // If throttleimems is 1000 ms, then the timer will fire every 1000/7 milliseconds 64 // If throttleimems is 1000 ms, then the timer will fire every 1000/7 milliseconds
65 65
66 private int throttleTimeDivisor = 7; 66 private int throttleTimeDivisor = 7;
67 67
68 private int throttletimems = 1000; 68 private int throttletimems = 1000;
69 69
70 private PacketThrottle ResendThrottle; 70 private LLPacketThrottle ResendThrottle;
71 private PacketThrottle LandThrottle; 71 private LLPacketThrottle LandThrottle;
72 private PacketThrottle WindThrottle; 72 private LLPacketThrottle WindThrottle;
73 private PacketThrottle CloudThrottle; 73 private LLPacketThrottle CloudThrottle;
74 private PacketThrottle TaskThrottle; 74 private LLPacketThrottle TaskThrottle;
75 private PacketThrottle AssetThrottle; 75 private LLPacketThrottle AssetThrottle;
76 private PacketThrottle TextureThrottle; 76 private LLPacketThrottle TextureThrottle;
77 private PacketThrottle TotalThrottle; 77 private LLPacketThrottle TotalThrottle;
78 78
79 // private long LastThrottle; 79 // private long LastThrottle;
80 // private long ThrottleInterval; 80 // private long ThrottleInterval;
81 private Timer throttleTimer; 81 private Timer throttleTimer;
82 82
83 private LLUUID m_agentId; 83 private LLUUID m_agentId;
84 84
85 public PacketQueue(LLUUID agentId) 85 public LLPacketQueue(LLUUID agentId)
86 { 86 {
87 // While working on this, the BlockingQueue had me fooled for a bit. 87 // While working on this, the BlockingQueue had me fooled for a bit.
88 // The Blocking queue causes the thread to stop until there's something 88 // The Blocking queue causes the thread to stop until there's something
89 // in it to process. it's an on-purpose threadlock though because 89 // in it to process. it's an on-purpose threadlock though because
90 // without it, the clientloop will suck up all sim resources. 90 // without it, the clientloop will suck up all sim resources.
91 91
92 SendQueue = new BlockingQueue<QueItem>(); 92 SendQueue = new BlockingQueue<LLQueItem>();
93 93
94 IncomingPacketQueue = new Queue<QueItem>(); 94 IncomingPacketQueue = new Queue<LLQueItem>();
95 OutgoingPacketQueue = new Queue<QueItem>(); 95 OutgoingPacketQueue = new Queue<LLQueItem>();
96 ResendOutgoingPacketQueue = new Queue<QueItem>(); 96 ResendOutgoingPacketQueue = new Queue<LLQueItem>();
97 LandOutgoingPacketQueue = new Queue<QueItem>(); 97 LandOutgoingPacketQueue = new Queue<LLQueItem>();
98 WindOutgoingPacketQueue = new Queue<QueItem>(); 98 WindOutgoingPacketQueue = new Queue<LLQueItem>();
99 CloudOutgoingPacketQueue = new Queue<QueItem>(); 99 CloudOutgoingPacketQueue = new Queue<LLQueItem>();
100 TaskOutgoingPacketQueue = new Queue<QueItem>(); 100 TaskOutgoingPacketQueue = new Queue<LLQueItem>();
101 TextureOutgoingPacketQueue = new Queue<QueItem>(); 101 TextureOutgoingPacketQueue = new Queue<LLQueItem>();
102 AssetOutgoingPacketQueue = new Queue<QueItem>(); 102 AssetOutgoingPacketQueue = new Queue<LLQueItem>();
103 103
104 104
105 // Set up the throttle classes (min, max, current) in bytes 105 // Set up the throttle classes (min, max, current) in bytes
106 ResendThrottle = new PacketThrottle(5000, 100000, 16000); 106 ResendThrottle = new LLPacketThrottle(5000, 100000, 16000);
107 LandThrottle = new PacketThrottle(1000, 100000, 2000); 107 LandThrottle = new LLPacketThrottle(1000, 100000, 2000);
108 WindThrottle = new PacketThrottle(1000, 100000, 1000); 108 WindThrottle = new LLPacketThrottle(1000, 100000, 1000);
109 CloudThrottle = new PacketThrottle(1000, 100000, 1000); 109 CloudThrottle = new LLPacketThrottle(1000, 100000, 1000);
110 TaskThrottle = new PacketThrottle(1000, 800000, 3000); 110 TaskThrottle = new LLPacketThrottle(1000, 800000, 3000);
111 AssetThrottle = new PacketThrottle(1000, 800000, 1000); 111 AssetThrottle = new LLPacketThrottle(1000, 800000, 1000);
112 TextureThrottle = new PacketThrottle(1000, 800000, 4000); 112 TextureThrottle = new LLPacketThrottle(1000, 800000, 4000);
113 // Total Throttle trumps all 113 // Total Throttle trumps all
114 // Number of bytes allowed to go out per second. (256kbps per client) 114 // Number of bytes allowed to go out per second. (256kbps per client)
115 TotalThrottle = new PacketThrottle(0, 1500000, 28000); 115 TotalThrottle = new LLPacketThrottle(0, 1500000, 28000);
116 116
117 throttleTimer = new Timer((int) (throttletimems/throttleTimeDivisor)); 117 throttleTimer = new Timer((int) (throttletimems/throttleTimeDivisor));
118 throttleTimer.Elapsed += new ElapsedEventHandler(ThrottleTimerElapsed); 118 throttleTimer.Elapsed += new ElapsedEventHandler(ThrottleTimerElapsed);
119 throttleTimer.Start(); 119 throttleTimer.Start();
120 120
121 // TIMERS needed for this 121 // TIMERS needed for this
122 // LastThrottle = DateTime.Now.Ticks; 122 // LastThrottle = DateTime.Now.Ticks;
123 // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor); 123 // ThrottleInterval = (long)(throttletimems/throttleTimeDivisor);
124 124
125 m_agentId = agentId; 125 m_agentId = agentId;
126 126
127 if (StatsManager.SimExtraStats != null) 127 if (StatsManager.SimExtraStats != null)
128 { 128 {
129 StatsManager.SimExtraStats.RegisterPacketQueueStatsProvider(m_agentId, this); 129 StatsManager.SimExtraStats.RegisterPacketQueueStatsProvider(m_agentId, this);
130 } 130 }
131 } 131 }
132 132
133 /* STANDARD QUEUE MANIPULATION INTERFACES */ 133 /* STANDARD QUEUE MANIPULATION INTERFACES */
134 134
135 135
136 public void Enqueue(QueItem item) 136 public void Enqueue(LLQueItem item)
137 { 137 {
138 if (!m_enabled) 138 if (!m_enabled)
139 { 139 {
140 return; 140 return;
141 } 141 }
142 // We could micro lock, but that will tend to actually 142 // We could micro lock, but that will tend to actually
143 // probably be worse than just synchronizing on SendQueue 143 // probably be worse than just synchronizing on SendQueue
144 144
145 if (item == null) 145 if (item == null)
146 { 146 {
147 SendQueue.Enqueue(item); 147 SendQueue.Enqueue(item);
148 return; 148 return;
149 } 149 }
150 150
151 lock (this) { 151 lock (this) {
152 switch (item.throttleType) 152 switch (item.throttleType)
153 { 153 {
154 case ThrottleOutPacketType.Resend: 154 case ThrottleOutPacketType.Resend:
155 ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item); 155 ThrottleCheck(ref ResendThrottle, ref ResendOutgoingPacketQueue, item);
156 break; 156 break;
157 case ThrottleOutPacketType.Texture: 157 case ThrottleOutPacketType.Texture:
158 ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item); 158 ThrottleCheck(ref TextureThrottle, ref TextureOutgoingPacketQueue, item);
159 break; 159 break;
160 case ThrottleOutPacketType.Task: 160 case ThrottleOutPacketType.Task:
161 ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item); 161 ThrottleCheck(ref TaskThrottle, ref TaskOutgoingPacketQueue, item);
162 break; 162 break;
163 case ThrottleOutPacketType.Land: 163 case ThrottleOutPacketType.Land:
164 ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item); 164 ThrottleCheck(ref LandThrottle, ref LandOutgoingPacketQueue, item);
165 break; 165 break;
166 case ThrottleOutPacketType.Asset: 166 case ThrottleOutPacketType.Asset:
167 ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item); 167 ThrottleCheck(ref AssetThrottle, ref AssetOutgoingPacketQueue, item);
168 break; 168 break;
169 case ThrottleOutPacketType.Cloud: 169 case ThrottleOutPacketType.Cloud:
170 ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item); 170 ThrottleCheck(ref CloudThrottle, ref CloudOutgoingPacketQueue, item);
171 break; 171 break;
172 case ThrottleOutPacketType.Wind: 172 case ThrottleOutPacketType.Wind:
173 ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item); 173 ThrottleCheck(ref WindThrottle, ref WindOutgoingPacketQueue, item);
174 break; 174 break;
175 175
176 default: 176 default:
177 // Acknowledgements and other such stuff should go directly to the blocking Queue 177 // Acknowledgements and other such stuff should go directly to the blocking Queue
178 // Throttling them may and likely 'will' be problematic 178 // Throttling them may and likely 'will' be problematic
179 SendQueue.Enqueue(item); 179 SendQueue.Enqueue(item);
180 break; 180 break;
181 } 181 }
182 } 182 }
183 } 183 }
184 184
185 public QueItem Dequeue() 185 public LLQueItem Dequeue()
186 { 186 {
187 return SendQueue.Dequeue(); 187 return SendQueue.Dequeue();
188 } 188 }
189 189
190 public void Flush() 190 public void Flush()
191 { 191 {
192 lock (this) 192 lock (this)
193 { 193 {
194 while (PacketsWaiting()) 194 while (PacketsWaiting())
195 { 195 {
196 //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up. 196 //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up.
197 if (ResendOutgoingPacketQueue.Count > 0) 197 if (ResendOutgoingPacketQueue.Count > 0)
198 { 198 {
199 SendQueue.Enqueue(ResendOutgoingPacketQueue.Dequeue()); 199 SendQueue.Enqueue(ResendOutgoingPacketQueue.Dequeue());
200 } 200 }
201 if (LandOutgoingPacketQueue.Count > 0) 201 if (LandOutgoingPacketQueue.Count > 0)
202 { 202 {
203 SendQueue.Enqueue(LandOutgoingPacketQueue.Dequeue()); 203 SendQueue.Enqueue(LandOutgoingPacketQueue.Dequeue());
204 } 204 }
205 if (WindOutgoingPacketQueue.Count > 0) 205 if (WindOutgoingPacketQueue.Count > 0)
206 { 206 {
207 SendQueue.Enqueue(WindOutgoingPacketQueue.Dequeue()); 207 SendQueue.Enqueue(WindOutgoingPacketQueue.Dequeue());
208 } 208 }
209 if (CloudOutgoingPacketQueue.Count > 0) 209 if (CloudOutgoingPacketQueue.Count > 0)
210 { 210 {
211 SendQueue.Enqueue(CloudOutgoingPacketQueue.Dequeue()); 211 SendQueue.Enqueue(CloudOutgoingPacketQueue.Dequeue());
212 } 212 }
213 if (TaskOutgoingPacketQueue.Count > 0) 213 if (TaskOutgoingPacketQueue.Count > 0)
214 { 214 {
215 SendQueue.Enqueue(TaskOutgoingPacketQueue.Dequeue()); 215 SendQueue.Enqueue(TaskOutgoingPacketQueue.Dequeue());
216 } 216 }
217 if (TextureOutgoingPacketQueue.Count > 0) 217 if (TextureOutgoingPacketQueue.Count > 0)
218 { 218 {
219 SendQueue.Enqueue(TextureOutgoingPacketQueue.Dequeue()); 219 SendQueue.Enqueue(TextureOutgoingPacketQueue.Dequeue());
220 } 220 }
221 if (AssetOutgoingPacketQueue.Count > 0) 221 if (AssetOutgoingPacketQueue.Count > 0)
222 { 222 {
223 SendQueue.Enqueue(AssetOutgoingPacketQueue.Dequeue()); 223 SendQueue.Enqueue(AssetOutgoingPacketQueue.Dequeue());
224 } 224 }
225 } 225 }
226 // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); 226 // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets");
227 } 227 }
228 } 228 }
229 229
230 public void Close() 230 public void Close()
231 { 231 {
232 Flush(); 232 Flush();
233 233
234 m_enabled = false; 234 m_enabled = false;
235 throttleTimer.Stop(); 235 throttleTimer.Stop();
236 236
237 if (StatsManager.SimExtraStats != null) 237 if (StatsManager.SimExtraStats != null)
238 { 238 {
239 StatsManager.SimExtraStats.DeregisterPacketQueueStatsProvider(m_agentId); 239 StatsManager.SimExtraStats.DeregisterPacketQueueStatsProvider(m_agentId);
240 } 240 }
241 } 241 }
242 242
243 private void ResetCounters() 243 private void ResetCounters()
244 { 244 {
245 ResendThrottle.Reset(); 245 ResendThrottle.Reset();
246 LandThrottle.Reset(); 246 LandThrottle.Reset();
247 WindThrottle.Reset(); 247 WindThrottle.Reset();
248 CloudThrottle.Reset(); 248 CloudThrottle.Reset();
249 TaskThrottle.Reset(); 249 TaskThrottle.Reset();
250 AssetThrottle.Reset(); 250 AssetThrottle.Reset();
251 TextureThrottle.Reset(); 251 TextureThrottle.Reset();
252 TotalThrottle.Reset(); 252 TotalThrottle.Reset();
253 } 253 }
254 254
255 private bool PacketsWaiting() 255 private bool PacketsWaiting()
256 { 256 {
257 return (ResendOutgoingPacketQueue.Count > 0 || 257 return (ResendOutgoingPacketQueue.Count > 0 ||
258 LandOutgoingPacketQueue.Count > 0 || 258 LandOutgoingPacketQueue.Count > 0 ||
259 WindOutgoingPacketQueue.Count > 0 || 259 WindOutgoingPacketQueue.Count > 0 ||
260 CloudOutgoingPacketQueue.Count > 0 || 260 CloudOutgoingPacketQueue.Count > 0 ||
261 TaskOutgoingPacketQueue.Count > 0 || 261 TaskOutgoingPacketQueue.Count > 0 ||
262 AssetOutgoingPacketQueue.Count > 0 || 262 AssetOutgoingPacketQueue.Count > 0 ||
263 TextureOutgoingPacketQueue.Count > 0); 263 TextureOutgoingPacketQueue.Count > 0);
264 } 264 }
265 265
266 public void ProcessThrottle() 266 public void ProcessThrottle()
267 { 267 {
268 // I was considering this.. Will an event fire if the thread it's on is blocked? 268 // I was considering this.. Will an event fire if the thread it's on is blocked?
269 269
270 // Then I figured out.. it doesn't really matter.. because this thread won't be blocked for long 270 // Then I figured out.. it doesn't really matter.. because this thread won't be blocked for long
271 // The General overhead of the UDP protocol gets sent to the queue un-throttled by this 271 // The General overhead of the UDP protocol gets sent to the queue un-throttled by this
272 // so This'll pick up about around the right time. 272 // so This'll pick up about around the right time.
273 273
274 int MaxThrottleLoops = 4550; // 50*7 packets can be dequeued at once. 274 int MaxThrottleLoops = 4550; // 50*7 packets can be dequeued at once.
275 int throttleLoops = 0; 275 int throttleLoops = 0;
276 276
277 // We're going to dequeue all of the saved up packets until 277 // We're going to dequeue all of the saved up packets until
278 // we've hit the throttle limit or there's no more packets to send 278 // we've hit the throttle limit or there's no more packets to send
279 lock (this) 279 lock (this)
280 { 280 {
281 ResetCounters(); 281 ResetCounters();
282 // m_log.Info("[THROTTLE]: Entering Throttle"); 282 // m_log.Info("[THROTTLE]: Entering Throttle");
283 while (TotalThrottle.UnderLimit() && PacketsWaiting() && 283 while (TotalThrottle.UnderLimit() && PacketsWaiting() &&
284 (throttleLoops <= MaxThrottleLoops)) 284 (throttleLoops <= MaxThrottleLoops))
285 { 285 {
286 throttleLoops++; 286 throttleLoops++;
287 //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up. 287 //Now comes the fun part.. we dump all our elements into m_packetQueue that we've saved up.
288 if (ResendThrottle.UnderLimit() && ResendOutgoingPacketQueue.Count > 0) 288 if (ResendThrottle.UnderLimit() && ResendOutgoingPacketQueue.Count > 0)
289 { 289 {
290 QueItem qpack = ResendOutgoingPacketQueue.Dequeue(); 290 LLQueItem qpack = ResendOutgoingPacketQueue.Dequeue();
291 291
292 SendQueue.Enqueue(qpack); 292 SendQueue.Enqueue(qpack);
293 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 293 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
294 ResendThrottle.Add(qpack.Packet.ToBytes().Length); 294 ResendThrottle.Add(qpack.Packet.ToBytes().Length);
295 } 295 }
296 if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0) 296 if (LandThrottle.UnderLimit() && LandOutgoingPacketQueue.Count > 0)
297 { 297 {
298 QueItem qpack = LandOutgoingPacketQueue.Dequeue(); 298 LLQueItem qpack = LandOutgoingPacketQueue.Dequeue();
299 299
300 SendQueue.Enqueue(qpack); 300 SendQueue.Enqueue(qpack);
301 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 301 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
302 LandThrottle.Add(qpack.Packet.ToBytes().Length); 302 LandThrottle.Add(qpack.Packet.ToBytes().Length);
303 } 303 }
304 if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0) 304 if (WindThrottle.UnderLimit() && WindOutgoingPacketQueue.Count > 0)
305 { 305 {
306 QueItem qpack = WindOutgoingPacketQueue.Dequeue(); 306 LLQueItem qpack = WindOutgoingPacketQueue.Dequeue();
307 307
308 SendQueue.Enqueue(qpack); 308 SendQueue.Enqueue(qpack);
309 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 309 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
310 WindThrottle.Add(qpack.Packet.ToBytes().Length); 310 WindThrottle.Add(qpack.Packet.ToBytes().Length);
311 } 311 }
312 if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0) 312 if (CloudThrottle.UnderLimit() && CloudOutgoingPacketQueue.Count > 0)
313 { 313 {
314 QueItem qpack = CloudOutgoingPacketQueue.Dequeue(); 314 LLQueItem qpack = CloudOutgoingPacketQueue.Dequeue();
315 315
316 SendQueue.Enqueue(qpack); 316 SendQueue.Enqueue(qpack);
317 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 317 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
318 CloudThrottle.Add(qpack.Packet.ToBytes().Length); 318 CloudThrottle.Add(qpack.Packet.ToBytes().Length);
319 } 319 }
320 if (TaskThrottle.UnderLimit() && TaskOutgoingPacketQueue.Count > 0) 320 if (TaskThrottle.UnderLimit() && TaskOutgoingPacketQueue.Count > 0)
321 { 321 {
322 QueItem qpack = TaskOutgoingPacketQueue.Dequeue(); 322 LLQueItem qpack = TaskOutgoingPacketQueue.Dequeue();
323 323
324 SendQueue.Enqueue(qpack); 324 SendQueue.Enqueue(qpack);
325 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 325 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
326 TaskThrottle.Add(qpack.Packet.ToBytes().Length); 326 TaskThrottle.Add(qpack.Packet.ToBytes().Length);
327 } 327 }
328 if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0) 328 if (TextureThrottle.UnderLimit() && TextureOutgoingPacketQueue.Count > 0)
329 { 329 {
330 QueItem qpack = TextureOutgoingPacketQueue.Dequeue(); 330 LLQueItem qpack = TextureOutgoingPacketQueue.Dequeue();
331 331
332 SendQueue.Enqueue(qpack); 332 SendQueue.Enqueue(qpack);
333 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 333 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
334 TextureThrottle.Add(qpack.Packet.ToBytes().Length); 334 TextureThrottle.Add(qpack.Packet.ToBytes().Length);
335 } 335 }
336 if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0) 336 if (AssetThrottle.UnderLimit() && AssetOutgoingPacketQueue.Count > 0)
337 { 337 {
338 QueItem qpack = AssetOutgoingPacketQueue.Dequeue(); 338 LLQueItem qpack = AssetOutgoingPacketQueue.Dequeue();
339 339
340 SendQueue.Enqueue(qpack); 340 SendQueue.Enqueue(qpack);
341 TotalThrottle.Add(qpack.Packet.ToBytes().Length); 341 TotalThrottle.Add(qpack.Packet.ToBytes().Length);
342 AssetThrottle.Add(qpack.Packet.ToBytes().Length); 342 AssetThrottle.Add(qpack.Packet.ToBytes().Length);
343 } 343 }
344 } 344 }
345 // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets"); 345 // m_log.Info("[THROTTLE]: Processed " + throttleLoops + " packets");
346 } 346 }
347 } 347 }
348 348
349 private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e) 349 private void ThrottleTimerElapsed(object sender, ElapsedEventArgs e)
350 { 350 {
351 // just to change the signature, and that ProcessThrottle 351 // just to change the signature, and that ProcessThrottle
352 // will be used elsewhere possibly 352 // will be used elsewhere possibly
353 ProcessThrottle(); 353 ProcessThrottle();
354 } 354 }
355 355
356 private void ThrottleCheck(ref PacketThrottle throttle, ref Queue<QueItem> q, QueItem item) 356 private void ThrottleCheck(ref LLPacketThrottle throttle, ref Queue<LLQueItem> q, LLQueItem item)
357 { 357 {
358 // The idea.. is if the packet throttle queues are empty 358 // The idea.. is if the packet throttle queues are empty
359 // and the client is under throttle for the type. Queue 359 // and the client is under throttle for the type. Queue
360 // it up directly. This basically short cuts having to 360 // it up directly. This basically short cuts having to
361 // wait for the timer to fire to put things into the 361 // wait for the timer to fire to put things into the
362 // output queue 362 // output queue
363 363
364 if ((q.Count == 0) && (throttle.UnderLimit())) 364 if ((q.Count == 0) && (throttle.UnderLimit()))
365 { 365 {
366 Monitor.Enter(this); 366 Monitor.Enter(this);
367 throttle.Add(item.Packet.ToBytes().Length); 367 throttle.Add(item.Packet.ToBytes().Length);
368 TotalThrottle.Add(item.Packet.ToBytes().Length); 368 TotalThrottle.Add(item.Packet.ToBytes().Length);
369 SendQueue.Enqueue(item); 369 SendQueue.Enqueue(item);
370 Monitor.Pulse(this); 370 Monitor.Pulse(this);
371 Monitor.Exit(this); 371 Monitor.Exit(this);
372 } 372 }
373 else 373 else
374 { 374 {
375 q.Enqueue(item); 375 q.Enqueue(item);
376 } 376 }
377 } 377 }
378 378
379 379
380 private static int ScaleThrottle(int value, int curmax, int newmax) 380 private static int ScaleThrottle(int value, int curmax, int newmax)
381 { 381 {
382 return (value / curmax) * newmax; 382 return (value / curmax) * newmax;
383 } 383 }
384 384
385 public byte[] GetThrottlesPacked(float multiplier) 385 public byte[] GetThrottlesPacked(float multiplier)
386 { 386 {
387 int singlefloat = 4; 387 int singlefloat = 4;
388 float tResend = ResendThrottle.Throttle*multiplier; 388 float tResend = ResendThrottle.Throttle*multiplier;
389 float tLand = LandThrottle.Throttle*multiplier; 389 float tLand = LandThrottle.Throttle*multiplier;
390 float tWind = WindThrottle.Throttle*multiplier; 390 float tWind = WindThrottle.Throttle*multiplier;
391 float tCloud = CloudThrottle.Throttle*multiplier; 391 float tCloud = CloudThrottle.Throttle*multiplier;
392 float tTask = TaskThrottle.Throttle*multiplier; 392 float tTask = TaskThrottle.Throttle*multiplier;
393 float tTexture = TextureThrottle.Throttle*multiplier; 393 float tTexture = TextureThrottle.Throttle*multiplier;
394 float tAsset = AssetThrottle.Throttle*multiplier; 394 float tAsset = AssetThrottle.Throttle*multiplier;
395 395
396 byte[] throttles = new byte[singlefloat*7]; 396 byte[] throttles = new byte[singlefloat*7];
397 int i = 0; 397 int i = 0;
398 Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat*i, singlefloat); 398 Buffer.BlockCopy(BitConverter.GetBytes(tResend), 0, throttles, singlefloat*i, singlefloat);
399 i++; 399 i++;
400 Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat*i, singlefloat); 400 Buffer.BlockCopy(BitConverter.GetBytes(tLand), 0, throttles, singlefloat*i, singlefloat);
401 i++; 401 i++;
402 Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat*i, singlefloat); 402 Buffer.BlockCopy(BitConverter.GetBytes(tWind), 0, throttles, singlefloat*i, singlefloat);
403 i++; 403 i++;
404 Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat*i, singlefloat); 404 Buffer.BlockCopy(BitConverter.GetBytes(tCloud), 0, throttles, singlefloat*i, singlefloat);
405 i++; 405 i++;
406 Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat*i, singlefloat); 406 Buffer.BlockCopy(BitConverter.GetBytes(tTask), 0, throttles, singlefloat*i, singlefloat);
407 i++; 407 i++;
408 Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat*i, singlefloat); 408 Buffer.BlockCopy(BitConverter.GetBytes(tTexture), 0, throttles, singlefloat*i, singlefloat);
409 i++; 409 i++;
410 Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat*i, singlefloat); 410 Buffer.BlockCopy(BitConverter.GetBytes(tAsset), 0, throttles, singlefloat*i, singlefloat);
411 411
412 return throttles; 412 return throttles;
413 } 413 }
414 414
415 public void SetThrottleFromClient(byte[] throttle) 415 public void SetThrottleFromClient(byte[] throttle)
416 { 416 {
417 int tResend = -1; 417 int tResend = -1;
418 int tLand = -1; 418 int tLand = -1;
419 int tWind = -1; 419 int tWind = -1;
420 int tCloud = -1; 420 int tCloud = -1;
421 int tTask = -1; 421 int tTask = -1;
422 int tTexture = -1; 422 int tTexture = -1;
423 int tAsset = -1; 423 int tAsset = -1;
424 int tall = -1; 424 int tall = -1;
425 int singlefloat = 4; 425 int singlefloat = 4;
426 426
427 //Agent Throttle Block contains 7 single floatingpoint values. 427 //Agent Throttle Block contains 7 single floatingpoint values.
428 int j = 0; 428 int j = 0;
429 429
430 // Some Systems may be big endian... 430 // Some Systems may be big endian...
431 // it might be smart to do this check more often... 431 // it might be smart to do this check more often...
432 if (!BitConverter.IsLittleEndian) 432 if (!BitConverter.IsLittleEndian)
433 for (int i = 0; i < 7; i++) 433 for (int i = 0; i < 7; i++)
434 Array.Reverse(throttle, j + i*singlefloat, singlefloat); 434 Array.Reverse(throttle, j + i*singlefloat, singlefloat);
435 435
436 // values gotten from libsecondlife.org/wiki/Throttle. Thanks MW_ 436 // values gotten from libsecondlife.org/wiki/Throttle. Thanks MW_
437 // bytes 437 // bytes
438 // Convert to integer, since.. the full fp space isn't used. 438 // Convert to integer, since.. the full fp space isn't used.
439 tResend = (int) BitConverter.ToSingle(throttle, j); 439 tResend = (int) BitConverter.ToSingle(throttle, j);
440 j += singlefloat; 440 j += singlefloat;
441 tLand = (int) BitConverter.ToSingle(throttle, j); 441 tLand = (int) BitConverter.ToSingle(throttle, j);
442 j += singlefloat; 442 j += singlefloat;
443 tWind = (int) BitConverter.ToSingle(throttle, j); 443 tWind = (int) BitConverter.ToSingle(throttle, j);
444 j += singlefloat; 444 j += singlefloat;
445 tCloud = (int) BitConverter.ToSingle(throttle, j); 445 tCloud = (int) BitConverter.ToSingle(throttle, j);
446 j += singlefloat; 446 j += singlefloat;
447 tTask = (int) BitConverter.ToSingle(throttle, j); 447 tTask = (int) BitConverter.ToSingle(throttle, j);
448 j += singlefloat; 448 j += singlefloat;
449 tTexture = (int) BitConverter.ToSingle(throttle, j); 449 tTexture = (int) BitConverter.ToSingle(throttle, j);
450 j += singlefloat; 450 j += singlefloat;
451 tAsset = (int) BitConverter.ToSingle(throttle, j); 451 tAsset = (int) BitConverter.ToSingle(throttle, j);
452 452
453 tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset; 453 tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset;
454 /* 454 /*
455 m_log.Info("[CLIENT]: Client AgentThrottle - Got throttle:resendbytes=" + tResend + 455 m_log.Info("[CLIENT]: Client AgentThrottle - Got throttle:resendbytes=" + tResend +
456 " landbytes=" + tLand + 456 " landbytes=" + tLand +
457 " windbytes=" + tWind + 457 " windbytes=" + tWind +
458 " cloudbytes=" + tCloud + 458 " cloudbytes=" + tCloud +
459 " taskbytes=" + tTask + 459 " taskbytes=" + tTask +
460 " texturebytes=" + tTexture + 460 " texturebytes=" + tTexture +
461 " Assetbytes=" + tAsset + 461 " Assetbytes=" + tAsset +
462 " Allbytes=" + tall); 462 " Allbytes=" + tall);
463 */ 463 */
464 464
465 // Total Sanity 465 // Total Sanity
466 // Make sure that the client sent sane total values. 466 // Make sure that the client sent sane total values.
467 467
468 // If the client didn't send acceptable values.... 468 // If the client didn't send acceptable values....
469 // Scale the clients values down until they are acceptable. 469 // Scale the clients values down until they are acceptable.
470 470
471 if (tall <= TotalThrottle.Max) 471 if (tall <= TotalThrottle.Max)
472 { 472 {
473 ResendThrottle.Throttle = tResend; 473 ResendThrottle.Throttle = tResend;
474 LandThrottle.Throttle = tLand; 474 LandThrottle.Throttle = tLand;
475 WindThrottle.Throttle = tWind; 475 WindThrottle.Throttle = tWind;
476 CloudThrottle.Throttle = tCloud; 476 CloudThrottle.Throttle = tCloud;
477 TaskThrottle.Throttle = tTask; 477 TaskThrottle.Throttle = tTask;
478 TextureThrottle.Throttle = tTexture; 478 TextureThrottle.Throttle = tTexture;
479 AssetThrottle.Throttle = tAsset; 479 AssetThrottle.Throttle = tAsset;
480 TotalThrottle.Throttle = tall; 480 TotalThrottle.Throttle = tall;
481 } 481 }
482 else if (tall < 1) 482 else if (tall < 1)
483 { 483 {
484 // client is stupid, penalize him by minning everything 484 // client is stupid, penalize him by minning everything
485 ResendThrottle.Throttle = ResendThrottle.Min; 485 ResendThrottle.Throttle = ResendThrottle.Min;
486 LandThrottle.Throttle = LandThrottle.Min; 486 LandThrottle.Throttle = LandThrottle.Min;
487 WindThrottle.Throttle = WindThrottle.Min; 487 WindThrottle.Throttle = WindThrottle.Min;
488 CloudThrottle.Throttle = CloudThrottle.Min; 488 CloudThrottle.Throttle = CloudThrottle.Min;
489 TaskThrottle.Throttle = TaskThrottle.Min; 489 TaskThrottle.Throttle = TaskThrottle.Min;
490 TextureThrottle.Throttle = TextureThrottle.Min; 490 TextureThrottle.Throttle = TextureThrottle.Min;
491 AssetThrottle.Throttle = AssetThrottle.Min; 491 AssetThrottle.Throttle = AssetThrottle.Min;
492 TotalThrottle.Throttle = TotalThrottle.Min; 492 TotalThrottle.Throttle = TotalThrottle.Min;
493 } 493 }
494 else 494 else
495 { 495 {
496 // we're over so figure out percentages and use those 496 // we're over so figure out percentages and use those
497 ResendThrottle.Throttle = tResend; 497 ResendThrottle.Throttle = tResend;
498 498
499 LandThrottle.Throttle = ScaleThrottle(tLand, tall, TotalThrottle.Max); 499 LandThrottle.Throttle = ScaleThrottle(tLand, tall, TotalThrottle.Max);
500 WindThrottle.Throttle = ScaleThrottle(tWind, tall, TotalThrottle.Max); 500 WindThrottle.Throttle = ScaleThrottle(tWind, tall, TotalThrottle.Max);
501 CloudThrottle.Throttle = ScaleThrottle(tCloud, tall, TotalThrottle.Max); 501 CloudThrottle.Throttle = ScaleThrottle(tCloud, tall, TotalThrottle.Max);
502 TaskThrottle.Throttle = ScaleThrottle(tTask, tall, TotalThrottle.Max); 502 TaskThrottle.Throttle = ScaleThrottle(tTask, tall, TotalThrottle.Max);
503 TextureThrottle.Throttle = ScaleThrottle(tTexture, tall, TotalThrottle.Max); 503 TextureThrottle.Throttle = ScaleThrottle(tTexture, tall, TotalThrottle.Max);
504 AssetThrottle.Throttle = ScaleThrottle(tAsset, tall, TotalThrottle.Max); 504 AssetThrottle.Throttle = ScaleThrottle(tAsset, tall, TotalThrottle.Max);
505 TotalThrottle.Throttle = TotalThrottle.Max; 505 TotalThrottle.Throttle = TotalThrottle.Max;
506 } 506 }
507 // effectively wiggling the slider causes things reset 507 // effectively wiggling the slider causes things reset
508 ResetCounters(); 508 ResetCounters();
509 } 509 }
510 510
511 // See IPullStatsProvider 511 // See IPullStatsProvider
512 public string GetStats() 512 public string GetStats()
513 { 513 {
514 return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}", 514 return string.Format("{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7}",
515 SendQueue.Count(), 515 SendQueue.Count(),
516 IncomingPacketQueue.Count, 516 IncomingPacketQueue.Count,
517 OutgoingPacketQueue.Count, 517 OutgoingPacketQueue.Count,
518 ResendOutgoingPacketQueue.Count, 518 ResendOutgoingPacketQueue.Count,
519 LandOutgoingPacketQueue.Count, 519 LandOutgoingPacketQueue.Count,
520 WindOutgoingPacketQueue.Count, 520 WindOutgoingPacketQueue.Count,
521 CloudOutgoingPacketQueue.Count, 521 CloudOutgoingPacketQueue.Count,
522 TaskOutgoingPacketQueue.Count, 522 TaskOutgoingPacketQueue.Count,
523 TextureOutgoingPacketQueue.Count, 523 TextureOutgoingPacketQueue.Count,
524 AssetOutgoingPacketQueue.Count); 524 AssetOutgoingPacketQueue.Count);
525 } 525 }
526 526
527 public QueItem[] GetQueueArray() 527 public LLQueItem[] GetQueueArray()
528 { 528 {
529 return SendQueue.GetQueueArray(); 529 return SendQueue.GetQueueArray();
530 } 530 }
531 } 531 }
532} 532} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/PacketServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs
index f9e3dc8..48afa84 100644
--- a/OpenSim/Region/ClientStack/PacketServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketServer.cs
@@ -1,149 +1,150 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System.Net; 28using System.Net;
29using System.Net.Sockets; 29using System.Net.Sockets;
30using libsecondlife; 30using libsecondlife;
31using libsecondlife.Packets; 31using libsecondlife.Packets;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Communications.Cache; 33using OpenSim.Framework.Communications.Cache;
34 34using OpenSim.Region.ClientStack.LindenUDP;
35namespace OpenSim.Region.ClientStack 35
36{ 36namespace OpenSim.Region.ClientStack.LindenUDP
37 public class PacketServer 37{
38 { 38 public class LLPacketServer
39 //private static readonly log4net.ILog m_log 39 {
40 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType); 40 //private static readonly log4net.ILog m_log
41 41 // = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
42 private ClientStackNetworkHandler m_networkHandler; 42
43 private IScene m_scene; 43 private LLClientStackNetworkHandler m_networkHandler;
44 44 private IScene m_scene;
45 //private readonly ClientManager m_clientManager = new ClientManager(); 45
46 //public ClientManager ClientManager 46 //private readonly ClientManager m_clientManager = new ClientManager();
47 //{ 47 //public ClientManager ClientManager
48 // get { return m_clientManager; } 48 //{
49 //} 49 // get { return m_clientManager; }
50 50 //}
51 public PacketServer(ClientStackNetworkHandler networkHandler) 51
52 { 52 public LLPacketServer(LLClientStackNetworkHandler networkHandler)
53 m_networkHandler = networkHandler; 53 {
54 m_networkHandler.RegisterPacketServer(this); 54 m_networkHandler = networkHandler;
55 } 55 m_networkHandler.RegisterPacketServer(this);
56 56 }
57 public IScene LocalScene 57
58 { 58 public IScene LocalScene
59 set { m_scene = value; } 59 {
60 } 60 set { m_scene = value; }
61 61 }
62 /// <summary> 62
63 /// 63 /// <summary>
64 /// </summary> 64 ///
65 /// <param name="circuitCode"></param> 65 /// </summary>
66 /// <param name="packet"></param> 66 /// <param name="circuitCode"></param>
67 public virtual void InPacket(uint circuitCode, Packet packet) 67 /// <param name="packet"></param>
68 { 68 public virtual void InPacket(uint circuitCode, Packet packet)
69 m_scene.ClientManager.InPacket(circuitCode, packet); 69 {
70 } 70 m_scene.ClientManager.InPacket(circuitCode, packet);
71 71 }
72 protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack, 72
73 ClientManager clientManager, IScene scene, AssetCache assetCache, 73 protected virtual IClientAPI CreateNewClient(EndPoint remoteEP, UseCircuitCodePacket initialcirpack,
74 PacketServer packServer, AgentCircuitManager authenSessions, 74 ClientManager clientManager, IScene scene, AssetCache assetCache,
75 LLUUID agentId, LLUUID sessionId, uint circuitCode, EndPoint proxyEP) 75 LLPacketServer packServer, AgentCircuitManager authenSessions,
76 { 76 LLUUID agentId, LLUUID sessionId, uint circuitCode, EndPoint proxyEP)
77 return 77 {
78 new ClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode, proxyEP); 78 return
79 } 79 new LLClientView(remoteEP, scene, assetCache, packServer, authenSessions, agentId, sessionId, circuitCode, proxyEP);
80 80 }
81 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache, 81
82 AgentCircuitManager authenticateSessionsClass, EndPoint proxyEP) 82 public virtual bool AddNewClient(EndPoint epSender, UseCircuitCodePacket useCircuit, AssetCache assetCache,
83 { 83 AgentCircuitManager authenticateSessionsClass, EndPoint proxyEP)
84 IClientAPI newuser; 84 {
85 85 IClientAPI newuser;
86 if (m_scene.ClientManager.TryGetClient(useCircuit.CircuitCode.Code, out newuser)) 86
87 { 87 if (m_scene.ClientManager.TryGetClient(useCircuit.CircuitCode.Code, out newuser))
88 return false; 88 {
89 } 89 return false;
90 else 90 }
91 { 91 else
92 newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this, 92 {
93 authenticateSessionsClass, useCircuit.CircuitCode.ID, 93 newuser = CreateNewClient(epSender, useCircuit, m_scene.ClientManager, m_scene, assetCache, this,
94 useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code, proxyEP); 94 authenticateSessionsClass, useCircuit.CircuitCode.ID,
95 95 useCircuit.CircuitCode.SessionID, useCircuit.CircuitCode.Code, proxyEP);
96 m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser); 96
97 97 m_scene.ClientManager.Add(useCircuit.CircuitCode.Code, newuser);
98 newuser.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler; 98
99 newuser.OnLogout += LogoutHandler; 99 newuser.OnViewerEffect += m_scene.ClientManager.ViewerEffectHandler;
100 newuser.OnConnectionClosed += CloseClient; 100 newuser.OnLogout += LogoutHandler;
101 101 newuser.OnConnectionClosed += CloseClient;
102 return true; 102
103 } 103 return true;
104 } 104 }
105 105 }
106 public void LogoutHandler(IClientAPI client) 106
107 { 107 public void LogoutHandler(IClientAPI client)
108 client.SendLogoutPacket(); 108 {
109 109 client.SendLogoutPacket();
110 CloseClient(client); 110
111 } 111 CloseClient(client);
112 112 }
113 /// <summary> 113
114 /// 114 /// <summary>
115 /// </summary> 115 ///
116 /// <param name="buffer"></param> 116 /// </summary>
117 /// <param name="size"></param> 117 /// <param name="buffer"></param>
118 /// <param name="flags"></param> 118 /// <param name="size"></param>
119 /// <param name="circuitcode"></param> 119 /// <param name="flags"></param>
120 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) 120 /// <param name="circuitcode"></param>
121 { 121 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
122 m_networkHandler.SendPacketTo(buffer, size, flags, circuitcode); 122 {
123 } 123 m_networkHandler.SendPacketTo(buffer, size, flags, circuitcode);
124 124 }
125 /// <summary> 125
126 /// 126 /// <summary>
127 /// </summary> 127 ///
128 /// <param name="circuitcode"></param> 128 /// </summary>
129 public virtual void CloseCircuit(uint circuitcode) 129 /// <param name="circuitcode"></param>
130 { 130 public virtual void CloseCircuit(uint circuitcode)
131 m_networkHandler.RemoveClientCircuit(circuitcode); 131 {
132 132 m_networkHandler.RemoveClientCircuit(circuitcode);
133 //m_scene.ClientManager.CloseAllAgents(circuitcode); 133
134 } 134 //m_scene.ClientManager.CloseAllAgents(circuitcode);
135 135 }
136 /// <summary> 136
137 /// Completely close down the given client. 137 /// <summary>
138 /// </summary> 138 /// Completely close down the given client.
139 /// <param name="client"></param> 139 /// </summary>
140 public virtual void CloseClient(IClientAPI client) 140 /// <param name="client"></param>
141 { 141 public virtual void CloseClient(IClientAPI client)
142 //m_log.Info("PacketServer:CloseClient()"); 142 {
143 143 //m_log.Info("PacketServer:CloseClient()");
144 CloseCircuit(client.CircuitCode); 144
145 m_scene.ClientManager.Remove(client.CircuitCode); 145 CloseCircuit(client.CircuitCode);
146 client.Close(false); 146 m_scene.ClientManager.Remove(client.CircuitCode);
147 } 147 client.Close(false);
148 } 148 }
149} 149 }
150} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/PacketThrottle.cs b/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs
index 3d3b659..792429a 100644
--- a/OpenSim/Region/ClientStack/PacketThrottle.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLPacketThrottle.cs
@@ -1,93 +1,93 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28namespace OpenSim.Region.ClientStack 28namespace OpenSim.Region.ClientStack.LindenUDP
29{ 29{
30 public class PacketThrottle 30 public class LLPacketThrottle
31 { 31 {
32 private int max; // max allowable throttle 32 private int max; // max allowable throttle
33 private int min; // min allowable throttle 33 private int min; // min allowable throttle
34 private int throttle; // current throttle setting 34 private int throttle; // current throttle setting
35 private static int divisor = 7; // the throttle time divisor, this probably should factor out 35 private static int divisor = 7; // the throttle time divisor, this probably should factor out
36 private int sent; // current number of bytes sent 36 private int sent; // current number of bytes sent
37 37
38 public PacketThrottle(int Min, int Max, int Throttle) 38 public LLPacketThrottle(int Min, int Max, int Throttle)
39 { 39 {
40 max = Max; 40 max = Max;
41 min = Min; 41 min = Min;
42 throttle = Throttle; 42 throttle = Throttle;
43 sent = 0; 43 sent = 0;
44 } 44 }
45 45
46 public void Reset() 46 public void Reset()
47 { 47 {
48 sent = 0; 48 sent = 0;
49 } 49 }
50 50
51 public bool UnderLimit() 51 public bool UnderLimit()
52 { 52 {
53 return (sent < (throttle/divisor)); 53 return (sent < (throttle/divisor));
54 } 54 }
55 55
56 public int Add(int bytes) 56 public int Add(int bytes)
57 { 57 {
58 sent += bytes; 58 sent += bytes;
59 return sent; 59 return sent;
60 } 60 }
61 61
62 // Properties 62 // Properties
63 public int Max 63 public int Max
64 { 64 {
65 get { return max; } 65 get { return max; }
66 } 66 }
67 67
68 public int Min 68 public int Min
69 { 69 {
70 get { return min; } 70 get { return min; }
71 } 71 }
72 72
73 public int Throttle 73 public int Throttle
74 { 74 {
75 get { return throttle; } 75 get { return throttle; }
76 set 76 set
77 { 77 {
78 if (value > max) 78 if (value > max)
79 { 79 {
80 throttle = max; 80 throttle = max;
81 } 81 }
82 else if (value < min) 82 else if (value < min)
83 { 83 {
84 throttle = min; 84 throttle = min;
85 } 85 }
86 else 86 else
87 { 87 {
88 throttle = value; 88 throttle = value;
89 } 89 }
90 } 90 }
91 } 91 }
92 } 92 }
93} 93} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/QueItem.cs b/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs
index 979aeea..4253378 100644
--- a/OpenSim/Region/ClientStack/QueItem.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLQueItem.cs
@@ -1,43 +1,43 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using libsecondlife.Packets; 28using libsecondlife.Packets;
29using OpenSim.Framework; 29using OpenSim.Framework;
30 30
31namespace OpenSim.Region.ClientStack 31namespace OpenSim.Region.ClientStack.LindenUDP
32{ 32{
33 public class QueItem 33 public class LLQueItem
34 { 34 {
35 public QueItem() 35 public LLQueItem()
36 { 36 {
37 } 37 }
38 38
39 public Packet Packet; 39 public Packet Packet;
40 public bool Incoming; 40 public bool Incoming;
41 public ThrottleOutPacketType throttleType; 41 public ThrottleOutPacketType throttleType;
42 } 42 }
43} 43} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/UDPServer.cs b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
index 7c4c03c..f85dcc2 100644
--- a/OpenSim/Region/ClientStack/UDPServer.cs
+++ b/OpenSim/Region/ClientStack/LindenUDP/LLUDPServer.cs
@@ -1,488 +1,499 @@
1/* 1/*
2 * Copyright (c) Contributors, http://opensimulator.org/ 2 * Copyright (c) Contributors, http://opensimulator.org/
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions are met: 6 * modification, are permitted provided that the following conditions are met:
7 * * Redistributions of source code must retain the above copyright 7 * * Redistributions of source code must retain the above copyright
8 * notice, this list of conditions and the following disclaimer. 8 * notice, this list of conditions and the following disclaimer.
9 * * Redistributions in binary form must reproduce the above copyright 9 * * Redistributions in binary form must reproduce the above copyright
10 * notice, this list of conditions and the following disclaimer in the 10 * notice, this list of conditions and the following disclaimer in the
11 * documentation and/or other materials provided with the distribution. 11 * documentation and/or other materials provided with the distribution.
12 * * Neither the name of the OpenSim Project nor the 12 * * Neither the name of the OpenSim Project nor the
13 * names of its contributors may be used to endorse or promote products 13 * names of its contributors may be used to endorse or promote products
14 * derived from this software without specific prior written permission. 14 * derived from this software without specific prior written permission.
15 * 15 *
16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY 16 * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 17 * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 18 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY 19 * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 20 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 21 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 22 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 23 * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 24 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Net; 30using System.Net;
31using System.Net.Sockets; 31using System.Net.Sockets;
32using System.Reflection; 32using System.Reflection;
33using libsecondlife.Packets; 33using libsecondlife.Packets;
34using log4net; 34using log4net;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Communications.Cache; 36using OpenSim.Framework.Communications.Cache;
37 37using OpenSim.Region.ClientStack.LindenUDP;
38namespace OpenSim.Region.ClientStack 38
39{ 39namespace OpenSim.Region.ClientStack.LindenUDP
40 public class UDPServer : ClientStackNetworkHandler 40{
41 { 41 public class LLUDPServer : LLClientStackNetworkHandler, IClientNetworkServer
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 42 {
43 43 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
44 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>(); 44
45 public Dictionary<uint, EndPoint> clientCircuits_reverse = new Dictionary<uint, EndPoint>(); 45 protected Dictionary<EndPoint, uint> clientCircuits = new Dictionary<EndPoint, uint>();
46 protected Dictionary<uint, EndPoint> proxyCircuits = new Dictionary<uint, EndPoint>(); 46 public Dictionary<uint, EndPoint> clientCircuits_reverse = new Dictionary<uint, EndPoint>();
47 public Socket Server; 47 protected Dictionary<uint, EndPoint> proxyCircuits = new Dictionary<uint, EndPoint>();
48 protected IPEndPoint ServerIncoming; 48 private Socket m_socket;
49 protected byte[] RecvBuffer = new byte[4096]; 49 protected IPEndPoint ServerIncoming;
50 protected byte[] ZeroBuffer = new byte[8192]; 50 protected byte[] RecvBuffer = new byte[4096];
51 protected IPEndPoint ipeSender; 51 protected byte[] ZeroBuffer = new byte[8192];
52 protected EndPoint epSender; 52 protected IPEndPoint ipeSender;
53 protected EndPoint epProxy; 53 protected EndPoint epSender;
54 protected int proxyPortOffset; 54 protected EndPoint epProxy;
55 protected AsyncCallback ReceivedData; 55 protected int proxyPortOffset;
56 protected PacketServer m_packetServer; 56 protected AsyncCallback ReceivedData;
57 protected ulong m_regionHandle; 57 protected LLPacketServer m_packetServer;
58 58 protected Location m_location;
59 protected uint listenPort; 59
60 protected bool Allow_Alternate_Port; 60 protected uint listenPort;
61 protected IPAddress listenIP = IPAddress.Parse("0.0.0.0"); 61 protected bool Allow_Alternate_Port;
62 protected IScene m_localScene; 62 protected IPAddress listenIP = IPAddress.Parse("0.0.0.0");
63 protected AssetCache m_assetCache; 63 protected IScene m_localScene;
64 protected AgentCircuitManager m_authenticateSessionsClass; 64 protected AssetCache m_assetCache;
65 65 protected AgentCircuitManager m_authenticateSessionsClass;
66 public PacketServer PacketServer 66
67 { 67 public LLPacketServer PacketServer
68 get { return m_packetServer; } 68 {
69 set { m_packetServer = value; } 69 get { return m_packetServer; }
70 } 70 set { m_packetServer = value; }
71 71 }
72 public IScene LocalScene 72
73 { 73 public IScene LocalScene
74 set 74 {
75 { 75 set
76 m_localScene = value; 76 {
77 m_packetServer.LocalScene = m_localScene; 77 m_localScene = value;
78 m_regionHandle = m_localScene.RegionInfo.RegionHandle; 78 m_packetServer.LocalScene = m_localScene;
79 } 79 m_location = new Location(m_localScene.RegionInfo.RegionHandle);
80 } 80 }
81 81 }
82 public ulong RegionHandle 82
83 { 83 public ulong RegionHandle
84 get { return m_regionHandle; } 84 {
85 } 85 get { return m_location.RegionHandle; }
86 86 }
87 public UDPServer() 87
88 { 88 Socket IClientNetworkServer.Server
89 } 89 {
90 90 get { return m_socket; }
91 public UDPServer(IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass) 91 }
92 { 92
93 this.proxyPortOffset = proxyPortOffset; 93 public bool HandlesRegion(Location x)
94 listenPort = (uint) (port + proxyPortOffset); 94 {
95 listenIP = _listenIP; 95 return x == m_location;
96 Allow_Alternate_Port = allow_alternate_port; 96 }
97 m_assetCache = assetCache; 97
98 m_authenticateSessionsClass = authenticateClass; 98 public LLUDPServer()
99 CreatePacketServer(); 99 {
100 100 }
101 // Return new port 101
102 // This because in Grid mode it is not really important what port the region listens to as long as it is correctly registered. 102 public LLUDPServer(IPAddress _listenIP, ref uint port, int proxyPortOffset, bool allow_alternate_port, AssetCache assetCache, AgentCircuitManager authenticateClass)
103 // So the option allow_alternate_ports="true" was added to default.xml 103 {
104 port = (uint)(listenPort - proxyPortOffset); 104 this.proxyPortOffset = proxyPortOffset;
105 } 105 listenPort = (uint) (port + proxyPortOffset);
106 106 listenIP = _listenIP;
107 protected virtual void CreatePacketServer() 107 Allow_Alternate_Port = allow_alternate_port;
108 { 108 m_assetCache = assetCache;
109 PacketServer packetServer = new PacketServer(this); 109 m_authenticateSessionsClass = authenticateClass;
110 } 110 CreatePacketServer();
111 111
112 protected virtual void OnReceivedData(IAsyncResult result) 112 // Return new port
113 { 113 // This because in Grid mode it is not really important what port the region listens to as long as it is correctly registered.
114 ipeSender = new IPEndPoint(listenIP, 0); 114 // So the option allow_alternate_ports="true" was added to default.xml
115 epSender = (EndPoint) ipeSender; 115 port = (uint)(listenPort - proxyPortOffset);
116 Packet packet = null; 116 }
117 117
118 int numBytes = 1; 118 protected virtual void CreatePacketServer()
119 119 {
120 try 120 LLPacketServer packetServer = new LLPacketServer(this);
121 { 121 }
122 numBytes = Server.EndReceiveFrom(result, ref epSender); 122
123 } 123 protected virtual void OnReceivedData(IAsyncResult result)
124 catch (SocketException e) 124 {
125 { 125 ipeSender = new IPEndPoint(listenIP, 0);
126 // TODO : Actually only handle those states that we have control over, re-throw everything else, 126 epSender = (EndPoint) ipeSender;
127 // TODO: implement cases as we encounter them. 127 Packet packet = null;
128 //m_log.Error("[UDPSERVER]: Connection Error! - " + e.ToString()); 128
129 switch (e.SocketErrorCode) 129 int numBytes = 1;
130 { 130
131 case SocketError.AlreadyInProgress: 131 try
132 case SocketError.NetworkReset: 132 {
133 case SocketError.ConnectionReset: 133 numBytes = m_socket.EndReceiveFrom(result, ref epSender);
134 try 134 }
135 { 135 catch (SocketException e)
136 CloseEndPoint(epSender); 136 {
137 } 137 // TODO : Actually only handle those states that we have control over, re-throw everything else,
138 catch (Exception a) 138 // TODO: implement cases as we encounter them.
139 { 139 //m_log.Error("[UDPSERVER]: Connection Error! - " + e.ToString());
140 m_log.Info("[UDPSERVER]: " + a.ToString()); 140 switch (e.SocketErrorCode)
141 } 141 {
142 try 142 case SocketError.AlreadyInProgress:
143 { 143 case SocketError.NetworkReset:
144 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, 144 case SocketError.ConnectionReset:
145 ReceivedData, null); 145 try
146 146 {
147 // Ter: For some stupid reason ConnectionReset basically kills our async event structure.. 147 CloseEndPoint(epSender);
148 // so therefore.. we've got to tell the server to BeginReceiveFrom again. 148 }
149 // This will happen over and over until we've gone through all packets 149 catch (Exception a)
150 // sent to and from this particular user. 150 {
151 // Stupid I know.. 151 m_log.Info("[UDPSERVER]: " + a.ToString());
152 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. 152 }
153 } 153 try
154 catch (SocketException) 154 {
155 { 155 m_socket.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender,
156 } 156 ReceivedData, null);
157 break; 157
158 default: 158 // Ter: For some stupid reason ConnectionReset basically kills our async event structure..
159 try 159 // so therefore.. we've got to tell the server to BeginReceiveFrom again.
160 { 160 // This will happen over and over until we've gone through all packets
161 CloseEndPoint(epSender); 161 // sent to and from this particular user.
162 } 162 // Stupid I know..
163 catch (Exception) 163 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method.
164 { 164 }
165 //m_log.Info("[UDPSERVER]" + a.ToString()); 165 catch (SocketException)
166 } 166 {
167 try 167 }
168 { 168 break;
169 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, 169 default:
170 ReceivedData, null); 170 try
171 171 {
172 // Ter: For some stupid reason ConnectionReset basically kills our async event structure.. 172 CloseEndPoint(epSender);
173 // so therefore.. we've got to tell the server to BeginReceiveFrom again. 173 }
174 // This will happen over and over until we've gone through all packets 174 catch (Exception)
175 // sent to and from this particular user. 175 {
176 // Stupid I know.. 176 //m_log.Info("[UDPSERVER]" + a.ToString());
177 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. 177 }
178 } 178 try
179 catch (SocketException e2) 179 {
180 { 180 m_socket.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender,
181 m_log.Error("[UDPSERVER]: " + e2.ToString()); 181 ReceivedData, null);
182 } 182
183 183 // Ter: For some stupid reason ConnectionReset basically kills our async event structure..
184 // Here's some reference code! :D 184 // so therefore.. we've got to tell the server to BeginReceiveFrom again.
185 // Shutdown and restart the UDP listener! hehe 185 // This will happen over and over until we've gone through all packets
186 // Shiny 186 // sent to and from this particular user.
187 187 // Stupid I know..
188 //Server.Shutdown(SocketShutdown.Both); 188 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method.
189 //CloseEndPoint(epSender); 189 }
190 //ServerListener(); 190 catch (SocketException e2)
191 break; 191 {
192 } 192 m_log.Error("[UDPSERVER]: " + e2.ToString());
193 193 }
194 //return; 194
195 } 195 // Here's some reference code! :D
196 catch (ObjectDisposedException e) 196 // Shutdown and restart the UDP listener! hehe
197 { 197 // Shiny
198 m_log.Debug("[UDPSERVER]: " + e.ToString()); 198
199 try 199 //Server.Shutdown(SocketShutdown.Both);
200 { 200 //CloseEndPoint(epSender);
201 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, 201 //ServerListener();
202 ReceivedData, null); 202 break;
203 203 }
204 // Ter: For some stupid reason ConnectionReset basically kills our async event structure.. 204
205 // so therefore.. we've got to tell the server to BeginReceiveFrom again. 205 //return;
206 // This will happen over and over until we've gone through all packets 206 }
207 // sent to and from this particular user. 207 catch (ObjectDisposedException e)
208 // Stupid I know.. 208 {
209 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. 209 m_log.Debug("[UDPSERVER]: " + e.ToString());
210 } 210 try
211 211 {
212 catch (SocketException e2) 212 m_socket.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender,
213 { 213 ReceivedData, null);
214 m_log.Error("[UDPSERVER]: " + e2.ToString()); 214
215 } 215 // Ter: For some stupid reason ConnectionReset basically kills our async event structure..
216 catch (ObjectDisposedException) 216 // so therefore.. we've got to tell the server to BeginReceiveFrom again.
217 { 217 // This will happen over and over until we've gone through all packets
218 } 218 // sent to and from this particular user.
219 //return; 219 // Stupid I know..
220 } 220 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method.
221 221 }
222 //System.Console.WriteLine("UDPServer : recieved message from {0}", epSender.ToString()); 222
223 epProxy = epSender; 223 catch (SocketException e2)
224 if (proxyPortOffset != 0) 224 {
225 { 225 m_log.Error("[UDPSERVER]: " + e2.ToString());
226 epSender = PacketPool.DecodeProxyMessage(RecvBuffer, ref numBytes); 226 }
227 } 227 catch (ObjectDisposedException)
228 228 {
229 int packetEnd = numBytes - 1; 229 }
230 230 //return;
231 try 231 }
232 { 232
233 packet = PacketPool.Instance.GetPacket(RecvBuffer, ref packetEnd, ZeroBuffer); 233 //System.Console.WriteLine("UDPServer : recieved message from {0}", epSender.ToString());
234 } 234 epProxy = epSender;
235 catch (Exception e) 235 if (proxyPortOffset != 0)
236 { 236 {
237 m_log.Debug("[UDPSERVER]: " + e.ToString()); 237 epSender = PacketPool.DecodeProxyMessage(RecvBuffer, ref numBytes);
238 } 238 }
239 239
240 try 240 int packetEnd = numBytes - 1;
241 { 241
242 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 242 try
243 } 243 {
244 catch (SocketException) 244 packet = PacketPool.Instance.GetPacket(RecvBuffer, ref packetEnd, ZeroBuffer);
245 { 245 }
246 try 246 catch (Exception e)
247 { 247 {
248 CloseEndPoint(epSender); 248 m_log.Debug("[UDPSERVER]: " + e.ToString());
249 } 249 }
250 catch (Exception a) 250
251 { 251 try
252 m_log.Info("[UDPSERVER]: " + a.ToString()); 252 {
253 } 253 m_socket.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
254 try 254 }
255 { 255 catch (SocketException)
256 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, 256 {
257 ReceivedData, null); 257 try
258 258 {
259 // Ter: For some stupid reason ConnectionReset basically kills our async event structure.. 259 CloseEndPoint(epSender);
260 // so therefore.. we've got to tell the server to BeginReceiveFrom again. 260 }
261 // This will happen over and over until we've gone through all packets 261 catch (Exception a)
262 // sent to and from this particular user. 262 {
263 // Stupid I know.. 263 m_log.Info("[UDPSERVER]: " + a.ToString());
264 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method. 264 }
265 } 265 try
266 catch (SocketException e5) 266 {
267 { 267 m_socket.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender,
268 m_log.Error("[UDPSERVER]: " + e5.ToString()); 268 ReceivedData, null);
269 } 269
270 } 270 // Ter: For some stupid reason ConnectionReset basically kills our async event structure..
271 catch (ObjectDisposedException) 271 // so therefore.. we've got to tell the server to BeginReceiveFrom again.
272 { 272 // This will happen over and over until we've gone through all packets
273 } 273 // sent to and from this particular user.
274 274 // Stupid I know..
275 if (packet != null) 275 // but Flusing the buffer would be even more stupid... so, we're stuck with this ugly method.
276 { 276 }
277 try 277 catch (SocketException e5)
278 { 278 {
279 // do we already have a circuit for this endpoint 279 m_log.Error("[UDPSERVER]: " + e5.ToString());
280 uint circuit; 280 }
281 281 }
282 bool ret = false; 282 catch (ObjectDisposedException)
283 lock (clientCircuits) 283 {
284 { 284 }
285 ret = clientCircuits.TryGetValue(epSender, out circuit); 285
286 } 286 if (packet != null)
287 if (ret) 287 {
288 { 288 try
289 //if so then send packet to the packetserver 289 {
290 //m_log.Warn("[UDPSERVER]: ALREADY HAVE Circuit!"); 290 // do we already have a circuit for this endpoint
291 m_packetServer.InPacket(circuit, packet); 291 uint circuit;
292 } 292
293 else if (packet.Type == PacketType.UseCircuitCode) 293 bool ret = false;
294 { 294 lock (clientCircuits)
295 // new client 295 {
296 m_log.Debug("[UDPSERVER]: Adding New Client"); 296 ret = clientCircuits.TryGetValue(epSender, out circuit);
297 AddNewClient(packet); 297 }
298 298 if (ret)
299 UseCircuitCodePacket p = (UseCircuitCodePacket)packet; 299 {
300 300 //if so then send packet to the packetserver
301 // Ack the first UseCircuitCode packet 301 //m_log.Warn("[UDPSERVER]: ALREADY HAVE Circuit!");
302 PacketAckPacket ack_it = (PacketAckPacket)PacketPool.Instance.GetPacket(PacketType.PacketAck); 302 m_packetServer.InPacket(circuit, packet);
303 // TODO: don't create new blocks if recycling an old packet 303 }
304 ack_it.Packets = new PacketAckPacket.PacketsBlock[1]; 304 else if (packet.Type == PacketType.UseCircuitCode)
305 ack_it.Packets[0] = new PacketAckPacket.PacketsBlock(); 305 {
306 ack_it.Packets[0].ID = packet.Header.Sequence; 306 // new client
307 ack_it.Header.Reliable = false; 307 m_log.Debug("[UDPSERVER]: Adding New Client");
308 SendPacketTo(ack_it.ToBytes(),ack_it.ToBytes().Length,SocketFlags.None,p.CircuitCode.Code); 308 AddNewClient(packet);
309 } 309
310 else 310 UseCircuitCodePacket p = (UseCircuitCodePacket)packet;
311 { 311
312 // invalid client 312 // Ack the first UseCircuitCode packet
313 //CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now 313 PacketAckPacket ack_it = (PacketAckPacket)PacketPool.Instance.GetPacket(PacketType.PacketAck);
314 //m_log.Warn("[UDPSERVER]: Got a packet from an invalid client - " + packet.ToString()); 314 // TODO: don't create new blocks if recycling an old packet
315 } 315 ack_it.Packets = new PacketAckPacket.PacketsBlock[1];
316 } 316 ack_it.Packets[0] = new PacketAckPacket.PacketsBlock();
317 catch (Exception) 317 ack_it.Packets[0].ID = packet.Header.Sequence;
318 { 318 ack_it.Header.Reliable = false;
319 m_log.Error("[UDPSERVER]: Exception in processing packet."); 319 SendPacketTo(ack_it.ToBytes(),ack_it.ToBytes().Length,SocketFlags.None,p.CircuitCode.Code);
320 m_log.Debug("[UDPSERVER]: Adding New Client"); 320 }
321 try 321 else
322 { 322 {
323 AddNewClient(packet); 323 // invalid client
324 } 324 //CFK: This message seems to have served its usefullness as of 12-15 so I am commenting it out for now
325 catch (Exception e3) 325 //m_log.Warn("[UDPSERVER]: Got a packet from an invalid client - " + packet.ToString());
326 { 326 }
327 m_log.Error("[UDPSERVER]: Adding New Client threw exception " + e3.ToString()); 327 }
328 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, 328 catch (Exception)
329 ReceivedData, null); 329 {
330 } 330 m_log.Error("[UDPSERVER]: Exception in processing packet.");
331 } 331 m_log.Debug("[UDPSERVER]: Adding New Client");
332 } 332 try
333 333 {
334 } 334 AddNewClient(packet);
335 335 }
336 private void CloseEndPoint(EndPoint sender) 336 catch (Exception e3)
337 { 337 {
338 uint circuit; 338 m_log.Error("[UDPSERVER]: Adding New Client threw exception " + e3.ToString());
339 lock (clientCircuits) 339 m_socket.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender,
340 { 340 ReceivedData, null);
341 if (clientCircuits.TryGetValue(sender, out circuit)) 341 }
342 { 342 }
343 m_packetServer.CloseCircuit(circuit); 343 }
344 } 344
345 } 345 }
346 } 346
347 347 private void CloseEndPoint(EndPoint sender)
348 protected virtual void AddNewClient(Packet packet) 348 {
349 { 349 uint circuit;
350 //Slave regions don't accept new clients 350 lock (clientCircuits)
351 if(m_localScene.Region_Status != RegionStatus.SlaveScene) 351 {
352 { 352 if (clientCircuits.TryGetValue(sender, out circuit))
353 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet; 353 {
354 lock (clientCircuits) 354 m_packetServer.CloseCircuit(circuit);
355 { 355 }
356 if (!clientCircuits.ContainsKey(epSender)) 356 }
357 clientCircuits.Add(epSender, useCircuit.CircuitCode.Code); 357 }
358 else 358
359 m_log.Error("[UDPSERVER]: clientCircuits already contans entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); 359 protected virtual void AddNewClient(Packet packet)
360 } 360 {
361 lock (clientCircuits_reverse) 361 //Slave regions don't accept new clients
362 { 362 if(m_localScene.Region_Status != RegionStatus.SlaveScene)
363 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) 363 {
364 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender); 364 UseCircuitCodePacket useCircuit = (UseCircuitCodePacket) packet;
365 else 365 lock (clientCircuits)
366 m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); 366 {
367 } 367 if (!clientCircuits.ContainsKey(epSender))
368 368 clientCircuits.Add(epSender, useCircuit.CircuitCode.Code);
369 lock (proxyCircuits) 369 else
370 { 370 m_log.Error("[UDPSERVER]: clientCircuits already contans entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
371 if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code)) 371 }
372 proxyCircuits.Add(useCircuit.CircuitCode.Code, epProxy); 372 lock (clientCircuits_reverse)
373 else 373 {
374 m_log.Error("[UDPSERVER]: proxyCircuits already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); 374 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code))
375 } 375 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, epSender);
376 376 else
377 PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass, epProxy); 377 m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
378 } 378 }
379 PacketPool.Instance.ReturnPacket(packet); 379
380 } 380 lock (proxyCircuits)
381 381 {
382 public void ServerListener() 382 if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code))
383 { 383 proxyCircuits.Add(useCircuit.CircuitCode.Code, epProxy);
384 uint newPort = listenPort; 384 else
385 m_log.Info("[SERVER]: Opening UDP socket on " + listenIP.ToString() + " " + newPort + "."); 385 m_log.Error("[UDPSERVER]: proxyCircuits already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
386 386 }
387 ServerIncoming = new IPEndPoint(listenIP, (int)newPort); 387
388 Server = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp); 388 PacketServer.AddNewClient(epSender, useCircuit, m_assetCache, m_authenticateSessionsClass, epProxy);
389 Server.Bind(ServerIncoming); 389 }
390 listenPort = newPort; 390 PacketPool.Instance.ReturnPacket(packet);
391 391 }
392 m_log.Info("[SERVER]: UDP socket bound, getting ready to listen"); 392
393 393 public void ServerListener()
394 ipeSender = new IPEndPoint(listenIP, 0); 394 {
395 epSender = (EndPoint)ipeSender; 395 uint newPort = listenPort;
396 ReceivedData = new AsyncCallback(OnReceivedData); 396 m_log.Info("[SERVER]: Opening UDP socket on " + listenIP.ToString() + " " + newPort + ".");
397 Server.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null); 397
398 398 ServerIncoming = new IPEndPoint(listenIP, (int)newPort);
399 m_log.Info("[SERVER]: Listening on port " + newPort); 399 m_socket = new Socket(AddressFamily.InterNetwork, SocketType.Dgram, ProtocolType.Udp);
400 } 400 m_socket.Bind(ServerIncoming);
401 401 listenPort = newPort;
402 public virtual void RegisterPacketServer(PacketServer server) 402
403 { 403 m_log.Info("[SERVER]: UDP socket bound, getting ready to listen");
404 m_packetServer = server; 404
405 } 405 ipeSender = new IPEndPoint(listenIP, 0);
406 406 epSender = (EndPoint)ipeSender;
407 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode) 407 ReceivedData = new AsyncCallback(OnReceivedData);
408 //EndPoint packetSender) 408 m_socket.BeginReceiveFrom(RecvBuffer, 0, RecvBuffer.Length, SocketFlags.None, ref epSender, ReceivedData, null);
409 { 409
410 // find the endpoint for this circuit 410 m_log.Info("[SERVER]: Listening on port " + newPort);
411 EndPoint sendto = null; 411 }
412 lock (clientCircuits_reverse) 412
413 { 413 public virtual void RegisterPacketServer(LLPacketServer server)
414 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) 414 {
415 { 415 m_packetServer = server;
416 //we found the endpoint so send the packet to it 416 }
417 if (proxyPortOffset != 0) 417
418 { 418 public virtual void SendPacketTo(byte[] buffer, int size, SocketFlags flags, uint circuitcode)
419 //MainLog.Instance.Verbose("UDPSERVER", "SendPacketTo proxy " + proxyCircuits[circuitcode].ToString() + ": client " + sendto.ToString()); 419 //EndPoint packetSender)
420 PacketPool.EncodeProxyMessage(buffer, ref size, sendto); 420 {
421 Server.SendTo(buffer, size, flags, proxyCircuits[circuitcode]); 421 // find the endpoint for this circuit
422 } 422 EndPoint sendto = null;
423 else 423 lock (clientCircuits_reverse)
424 { 424 {
425 //MainLog.Instance.Verbose("UDPSERVER", "SendPacketTo : client " + sendto.ToString()); 425 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto))
426 Server.SendTo(buffer, size, flags, sendto); 426 {
427 } 427 //we found the endpoint so send the packet to it
428 } 428 if (proxyPortOffset != 0)
429 } 429 {
430 } 430 //MainLog.Instance.Verbose("UDPSERVER", "SendPacketTo proxy " + proxyCircuits[circuitcode].ToString() + ": client " + sendto.ToString());
431 431 PacketPool.EncodeProxyMessage(buffer, ref size, sendto);
432 public virtual void RemoveClientCircuit(uint circuitcode) 432 m_socket.SendTo(buffer, size, flags, proxyCircuits[circuitcode]);
433 { 433 }
434 EndPoint sendto = null; 434 else
435 lock (clientCircuits_reverse) 435 {
436 { 436 //MainLog.Instance.Verbose("UDPSERVER", "SendPacketTo : client " + sendto.ToString());
437 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto)) 437 m_socket.SendTo(buffer, size, flags, sendto);
438 { 438 }
439 clientCircuits.Remove(sendto); 439 }
440 440 }
441 clientCircuits_reverse.Remove(circuitcode); 441 }
442 proxyCircuits.Remove(circuitcode); 442
443 } 443 public virtual void RemoveClientCircuit(uint circuitcode)
444 } 444 {
445 } 445 EndPoint sendto = null;
446 446 lock (clientCircuits_reverse)
447 public void RestoreClient(AgentCircuitData circuit, EndPoint userEP, EndPoint proxyEP) 447 {
448 { 448 if (clientCircuits_reverse.TryGetValue(circuitcode, out sendto))
449 //MainLog.Instance.Verbose("UDPSERVER", "RestoreClient"); 449 {
450 450 clientCircuits.Remove(sendto);
451 UseCircuitCodePacket useCircuit = new UseCircuitCodePacket(); 451
452 useCircuit.CircuitCode.Code = circuit.circuitcode; 452 clientCircuits_reverse.Remove(circuitcode);
453 useCircuit.CircuitCode.ID = circuit.AgentID; 453 proxyCircuits.Remove(circuitcode);
454 useCircuit.CircuitCode.SessionID = circuit.SessionID; 454 }
455 455 }
456 lock (clientCircuits) 456 }
457 { 457
458 if (!clientCircuits.ContainsKey(userEP)) 458 public void RestoreClient(AgentCircuitData circuit, EndPoint userEP, EndPoint proxyEP)
459 clientCircuits.Add(userEP, useCircuit.CircuitCode.Code); 459 {
460 else 460 //MainLog.Instance.Verbose("UDPSERVER", "RestoreClient");
461 m_log.Error("[UDPSERVER]: clientCircuits already contans entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); 461
462 } 462 UseCircuitCodePacket useCircuit = new UseCircuitCodePacket();
463 lock (clientCircuits_reverse) 463 useCircuit.CircuitCode.Code = circuit.circuitcode;
464 { 464 useCircuit.CircuitCode.ID = circuit.AgentID;
465 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code)) 465 useCircuit.CircuitCode.SessionID = circuit.SessionID;
466 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, userEP); 466
467 else 467 lock (clientCircuits)
468 m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding."); 468 {
469 } 469 if (!clientCircuits.ContainsKey(userEP))
470 470 clientCircuits.Add(userEP, useCircuit.CircuitCode.Code);
471 lock (proxyCircuits) 471 else
472 { 472 m_log.Error("[UDPSERVER]: clientCircuits already contans entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
473 if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code)) 473 }
474 { 474 lock (clientCircuits_reverse)
475 proxyCircuits.Add(useCircuit.CircuitCode.Code, proxyEP); 475 {
476 } 476 if (!clientCircuits_reverse.ContainsKey(useCircuit.CircuitCode.Code))
477 else 477 clientCircuits_reverse.Add(useCircuit.CircuitCode.Code, userEP);
478 { 478 else
479 // re-set proxy endpoint 479 m_log.Error("[UDPSERVER]: clientCurcuits_reverse already contains entry for user " + useCircuit.CircuitCode.Code.ToString() + ". NOT adding.");
480 proxyCircuits.Remove(useCircuit.CircuitCode.Code); 480 }
481 proxyCircuits.Add(useCircuit.CircuitCode.Code, proxyEP); 481
482 } 482 lock (proxyCircuits)
483 } 483 {
484 484 if (!proxyCircuits.ContainsKey(useCircuit.CircuitCode.Code))
485 PacketServer.AddNewClient(userEP, useCircuit, m_assetCache, m_authenticateSessionsClass, proxyEP); 485 {
486 } 486 proxyCircuits.Add(useCircuit.CircuitCode.Code, proxyEP);
487 } 487 }
488} 488 else
489 {
490 // re-set proxy endpoint
491 proxyCircuits.Remove(useCircuit.CircuitCode.Code);
492 proxyCircuits.Add(useCircuit.CircuitCode.Code, proxyEP);
493 }
494 }
495
496 PacketServer.AddNewClient(userEP, useCircuit, m_assetCache, m_authenticateSessionsClass, proxyEP);
497 }
498 }
499} \ No newline at end of file
diff --git a/OpenSim/Region/ClientStack/RegionApplicationBase.cs b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
index becf7ba..1102fb4 100644
--- a/OpenSim/Region/ClientStack/RegionApplicationBase.cs
+++ b/OpenSim/Region/ClientStack/RegionApplicationBase.cs
@@ -34,12 +34,11 @@ using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Servers; 36using OpenSim.Framework.Servers;
37using OpenSim.Region.ClientStack.LindenUDP;
37using OpenSim.Region.Environment; 38using OpenSim.Region.Environment;
38using OpenSim.Region.Environment.Scenes; 39using OpenSim.Region.Environment.Scenes;
39using OpenSim.Region.Physics.Manager; 40using OpenSim.Region.Physics.Manager;
40 41
41//using OpenSim.Framework.Console;
42
43namespace OpenSim.Region.ClientStack 42namespace OpenSim.Region.ClientStack
44{ 43{
45 public abstract class RegionApplicationBase : BaseOpenSimServer 44 public abstract class RegionApplicationBase : BaseOpenSimServer
@@ -75,7 +74,7 @@ namespace OpenSim.Region.ClientStack
75 74
76 public virtual void StartUp() 75 public virtual void StartUp()
77 { 76 {
78 ClientView.TerrainManager = new TerrainManager(new SecondLife()); 77 LLClientView.TerrainManager = new TerrainManager(new SecondLife());
79 78
80 m_storageManager = CreateStorageManager(m_storageConnectionString); 79 m_storageManager = CreateStorageManager(m_storageConnectionString);
81 80
@@ -108,12 +107,12 @@ namespace OpenSim.Region.ClientStack
108 return physicsPluginManager.GetPhysicsScene(engine, meshEngine); 107 return physicsPluginManager.GetPhysicsScene(engine, meshEngine);
109 } 108 }
110 109
111 protected Scene SetupScene(RegionInfo regionInfo, out UDPServer udpServer, bool m_permissions) 110 protected Scene SetupScene(RegionInfo regionInfo, out LLUDPServer udpServer, bool m_permissions)
112 { 111 {
113 return SetupScene(regionInfo, 0, out udpServer, m_permissions); 112 return SetupScene(regionInfo, 0, out udpServer, m_permissions);
114 } 113 }
115 114
116 protected Scene SetupScene(RegionInfo regionInfo, int proxyOffset, out UDPServer udpServer, bool m_permissions) 115 protected Scene SetupScene(RegionInfo regionInfo, int proxyOffset, out LLUDPServer udpServer, bool m_permissions)
117 { 116 {
118 AgentCircuitManager circuitManager = new AgentCircuitManager(); 117 AgentCircuitManager circuitManager = new AgentCircuitManager();
119 IPAddress listenIP = regionInfo.InternalEndPoint.Address; 118 IPAddress listenIP = regionInfo.InternalEndPoint.Address;
@@ -121,7 +120,7 @@ namespace OpenSim.Region.ClientStack
121 // listenIP = IPAddress.Parse("0.0.0.0"); 120 // listenIP = IPAddress.Parse("0.0.0.0");
122 121
123 uint port = (uint) regionInfo.InternalEndPoint.Port; 122 uint port = (uint) regionInfo.InternalEndPoint.Port;
124 udpServer = new UDPServer(listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, m_assetCache, circuitManager); 123 udpServer = new LLUDPServer(listenIP, ref port, proxyOffset, regionInfo.m_allow_alternate_ports, m_assetCache, circuitManager);
125 regionInfo.InternalEndPoint.Port = (int)port; 124 regionInfo.InternalEndPoint.Port = (int)port;
126 125
127 Scene scene = CreateScene(regionInfo, m_storageManager, circuitManager); 126 Scene scene = CreateScene(regionInfo, m_storageManager, circuitManager);
@@ -131,8 +130,8 @@ namespace OpenSim.Region.ClientStack
131 scene.LoadWorldMap(); 130 scene.LoadWorldMap();
132 131
133 //moved to opensimMain as these have to happen after modules are initialised 132 //moved to opensimMain as these have to happen after modules are initialised
134 // scene.CreateTerrainTexture(true); 133 // scene.CreateTerrainTexture(true);
135 // scene.RegisterRegionWithGrid(); 134 // scene.RegisterRegionWithGrid();
136 135
137 scene.PhysicsScene = GetPhysicsScene(); 136 scene.PhysicsScene = GetPhysicsScene();
138 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised()); 137 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
@@ -171,4 +170,4 @@ namespace OpenSim.Region.ClientStack
171 protected abstract Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager, 170 protected abstract Scene CreateScene(RegionInfo regionInfo, StorageManager storageManager,
172 AgentCircuitManager circuitManager); 171 AgentCircuitManager circuitManager);
173 } 172 }
174} 173} \ No newline at end of file