aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ClientStack/ClientView.API.cs
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/ClientStack/ClientView.API.cs')
-rw-r--r--OpenSim/Region/ClientStack/ClientView.API.cs2360
1 files changed, 1180 insertions, 1180 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.API.cs b/OpenSim/Region/ClientStack/ClientView.API.cs
index 33e34c1..2ac1000 100644
--- a/OpenSim/Region/ClientStack/ClientView.API.cs
+++ b/OpenSim/Region/ClientStack/ClientView.API.cs
@@ -1,1180 +1,1180 @@
1/* 1/*
2* Copyright (c) Contributors, http://www.openmetaverse.org/ 2* Copyright (c) Contributors, http://www.openmetaverse.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.Text; 31using System.Text;
32using Axiom.Math; 32using Axiom.Math;
33using libsecondlife; 33using libsecondlife;
34using libsecondlife.Packets; 34using libsecondlife.Packets;
35using OpenSim.Framework.Console; 35using OpenSim.Framework.Console;
36using OpenSim.Framework.Interfaces; 36using OpenSim.Framework.Interfaces;
37using OpenSim.Framework.Types; 37using OpenSim.Framework.Types;
38using OpenSim.Framework.Data; 38using OpenSim.Framework.Data;
39 39
40namespace OpenSim.Region.ClientStack 40namespace OpenSim.Region.ClientStack
41{ 41{
42 partial class ClientView 42 partial class ClientView
43 { 43 {
44 public event ImprovedInstantMessage OnInstantMessage; 44 public event ImprovedInstantMessage OnInstantMessage;
45 public event ChatFromViewer OnChatFromViewer; 45 public event ChatFromViewer OnChatFromViewer;
46 public event RezObject OnRezObject; 46 public event RezObject OnRezObject;
47 public event GenericCall4 OnDeRezObject; 47 public event GenericCall4 OnDeRezObject;
48 public event ModifyTerrain OnModifyTerrain; 48 public event ModifyTerrain OnModifyTerrain;
49 public event GenericCall OnRegionHandShakeReply; 49 public event GenericCall OnRegionHandShakeReply;
50 public event GenericCall OnRequestWearables; 50 public event GenericCall OnRequestWearables;
51 public event SetAppearance OnSetAppearance; 51 public event SetAppearance OnSetAppearance;
52 public event GenericCall2 OnCompleteMovementToRegion; 52 public event GenericCall2 OnCompleteMovementToRegion;
53 public event UpdateAgent OnAgentUpdate; 53 public event UpdateAgent OnAgentUpdate;
54 public event StartAnim OnStartAnim; 54 public event StartAnim OnStartAnim;
55 public event GenericCall OnRequestAvatarsData; 55 public event GenericCall OnRequestAvatarsData;
56 public event LinkObjects OnLinkObjects; 56 public event LinkObjects OnLinkObjects;
57 public event UpdateVector OnGrapObject; 57 public event UpdateVector OnGrapObject;
58 public event ObjectSelect OnDeGrapObject; 58 public event ObjectSelect OnDeGrapObject;
59 public event ObjectDuplicate OnObjectDuplicate; 59 public event ObjectDuplicate OnObjectDuplicate;
60 public event MoveObject OnGrapUpdate; 60 public event MoveObject OnGrapUpdate;
61 public event AddNewPrim OnAddPrim; 61 public event AddNewPrim OnAddPrim;
62 public event UpdateShape OnUpdatePrimShape; 62 public event UpdateShape OnUpdatePrimShape;
63 public event ObjectSelect OnObjectSelect; 63 public event ObjectSelect OnObjectSelect;
64 public event ObjectDeselect OnObjectDeselect; 64 public event ObjectDeselect OnObjectDeselect;
65 public event GenericCall7 OnObjectDescription; 65 public event GenericCall7 OnObjectDescription;
66 public event GenericCall7 OnObjectName; 66 public event GenericCall7 OnObjectName;
67 public event UpdatePrimFlags OnUpdatePrimFlags; 67 public event UpdatePrimFlags OnUpdatePrimFlags;
68 public event UpdatePrimTexture OnUpdatePrimTexture; 68 public event UpdatePrimTexture OnUpdatePrimTexture;
69 public event UpdateVector OnUpdatePrimGroupPosition; 69 public event UpdateVector OnUpdatePrimGroupPosition;
70 public event UpdateVector OnUpdatePrimSinglePosition; 70 public event UpdateVector OnUpdatePrimSinglePosition;
71 public event UpdatePrimRotation OnUpdatePrimGroupRotation; 71 public event UpdatePrimRotation OnUpdatePrimGroupRotation;
72 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; 72 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
73 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation; 73 public event UpdatePrimGroupRotation OnUpdatePrimGroupMouseRotation;
74 public event UpdateVector OnUpdatePrimScale; 74 public event UpdateVector OnUpdatePrimScale;
75 public event StatusChange OnChildAgentStatus; 75 public event StatusChange OnChildAgentStatus;
76 public event GenericCall2 OnStopMovement; 76 public event GenericCall2 OnStopMovement;
77 public event NewAvatar OnNewAvatar; 77 public event NewAvatar OnNewAvatar;
78 public event GenericCall6 OnRemoveAvatar; 78 public event GenericCall6 OnRemoveAvatar;
79 public event RequestMapBlocks OnRequestMapBlocks; 79 public event RequestMapBlocks OnRequestMapBlocks;
80 public event TeleportLocationRequest OnTeleportLocationRequest; 80 public event TeleportLocationRequest OnTeleportLocationRequest;
81 81
82 public event UUIDNameRequest OnNameFromUUIDRequest; 82 public event UUIDNameRequest OnNameFromUUIDRequest;
83 83
84 public event ParcelPropertiesRequest OnParcelPropertiesRequest; 84 public event ParcelPropertiesRequest OnParcelPropertiesRequest;
85 public event ParcelDivideRequest OnParcelDivideRequest; 85 public event ParcelDivideRequest OnParcelDivideRequest;
86 public event ParcelJoinRequest OnParcelJoinRequest; 86 public event ParcelJoinRequest OnParcelJoinRequest;
87 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest; 87 public event ParcelPropertiesUpdateRequest OnParcelPropertiesUpdateRequest;
88 public event ParcelSelectObjects OnParcelSelectObjects; 88 public event ParcelSelectObjects OnParcelSelectObjects;
89 public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest; 89 public event ParcelObjectOwnerRequest OnParcelObjectOwnerRequest;
90 public event EstateOwnerMessageRequest OnEstateOwnerMessage; 90 public event EstateOwnerMessageRequest OnEstateOwnerMessage;
91 91
92 /// <summary> 92 /// <summary>
93 /// 93 ///
94 /// </summary> 94 /// </summary>
95 public LLVector3 StartPos 95 public LLVector3 StartPos
96 { 96 {
97 get 97 get
98 { 98 {
99 return startpos; 99 return startpos;
100 } 100 }
101 set 101 set
102 { 102 {
103 startpos = value; 103 startpos = value;
104 } 104 }
105 } 105 }
106 106
107 /// <summary> 107 /// <summary>
108 /// 108 ///
109 /// </summary> 109 /// </summary>
110 public LLUUID AgentId 110 public LLUUID AgentId
111 { 111 {
112 get 112 get
113 { 113 {
114 return this.AgentID; 114 return this.AgentID;
115 } 115 }
116 } 116 }
117 117
118 /// <summary> 118 /// <summary>
119 /// 119 ///
120 /// </summary> 120 /// </summary>
121 public string FirstName 121 public string FirstName
122 { 122 {
123 get 123 get
124 { 124 {
125 return this.firstName; 125 return this.firstName;
126 } 126 }
127 127
128 } 128 }
129 129
130 /// <summary> 130 /// <summary>
131 /// 131 ///
132 /// </summary> 132 /// </summary>
133 public string LastName 133 public string LastName
134 { 134 {
135 get 135 get
136 { 136 {
137 return this.lastName; 137 return this.lastName;
138 } 138 }
139 } 139 }
140 140
141 #region World/Avatar to Client 141 #region World/Avatar to Client
142 142
143 /// <summary> 143 /// <summary>
144 /// 144 ///
145 /// </summary> 145 /// </summary>
146 /// <param name="regionInfo"></param> 146 /// <param name="regionInfo"></param>
147 public void SendRegionHandshake(RegionInfo regionInfo) 147 public void SendRegionHandshake(RegionInfo regionInfo)
148 { 148 {
149 Encoding _enc = Encoding.ASCII; 149 Encoding _enc = Encoding.ASCII;
150 RegionHandshakePacket handshake = new RegionHandshakePacket(); 150 RegionHandshakePacket handshake = new RegionHandshakePacket();
151 151
152 handshake.RegionInfo.BillableFactor = regionInfo.estateSettings.billableFactor; 152 handshake.RegionInfo.BillableFactor = regionInfo.estateSettings.billableFactor;
153 handshake.RegionInfo.IsEstateManager = false; 153 handshake.RegionInfo.IsEstateManager = false;
154 handshake.RegionInfo.TerrainHeightRange00 = regionInfo.estateSettings.terrainHeightRange0; 154 handshake.RegionInfo.TerrainHeightRange00 = regionInfo.estateSettings.terrainHeightRange0;
155 handshake.RegionInfo.TerrainHeightRange01 = regionInfo.estateSettings.terrainHeightRange1; 155 handshake.RegionInfo.TerrainHeightRange01 = regionInfo.estateSettings.terrainHeightRange1;
156 handshake.RegionInfo.TerrainHeightRange10 = regionInfo.estateSettings.terrainHeightRange2; 156 handshake.RegionInfo.TerrainHeightRange10 = regionInfo.estateSettings.terrainHeightRange2;
157 handshake.RegionInfo.TerrainHeightRange11 = regionInfo.estateSettings.terrainHeightRange3; 157 handshake.RegionInfo.TerrainHeightRange11 = regionInfo.estateSettings.terrainHeightRange3;
158 handshake.RegionInfo.TerrainStartHeight00 = regionInfo.estateSettings.terrainStartHeight0; 158 handshake.RegionInfo.TerrainStartHeight00 = regionInfo.estateSettings.terrainStartHeight0;
159 handshake.RegionInfo.TerrainStartHeight01 = regionInfo.estateSettings.terrainStartHeight1; 159 handshake.RegionInfo.TerrainStartHeight01 = regionInfo.estateSettings.terrainStartHeight1;
160 handshake.RegionInfo.TerrainStartHeight10 = regionInfo.estateSettings.terrainStartHeight2; 160 handshake.RegionInfo.TerrainStartHeight10 = regionInfo.estateSettings.terrainStartHeight2;
161 handshake.RegionInfo.TerrainStartHeight11 = regionInfo.estateSettings.terrainStartHeight3; 161 handshake.RegionInfo.TerrainStartHeight11 = regionInfo.estateSettings.terrainStartHeight3;
162 handshake.RegionInfo.SimAccess = (byte)regionInfo.estateSettings.simAccess; 162 handshake.RegionInfo.SimAccess = (byte)regionInfo.estateSettings.simAccess;
163 handshake.RegionInfo.WaterHeight = regionInfo.estateSettings.waterHeight; 163 handshake.RegionInfo.WaterHeight = regionInfo.estateSettings.waterHeight;
164 164
165 165
166 handshake.RegionInfo.RegionFlags = (uint)regionInfo.estateSettings.regionFlags; 166 handshake.RegionInfo.RegionFlags = (uint)regionInfo.estateSettings.regionFlags;
167 167
168 handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0"); 168 handshake.RegionInfo.SimName = _enc.GetBytes(regionInfo.RegionName + "\0");
169 handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID; 169 handshake.RegionInfo.SimOwner = regionInfo.MasterAvatarAssignedUUID;
170 handshake.RegionInfo.TerrainBase0 = regionInfo.estateSettings.terrainBase0; 170 handshake.RegionInfo.TerrainBase0 = regionInfo.estateSettings.terrainBase0;
171 handshake.RegionInfo.TerrainBase1 = regionInfo.estateSettings.terrainBase1; 171 handshake.RegionInfo.TerrainBase1 = regionInfo.estateSettings.terrainBase1;
172 handshake.RegionInfo.TerrainBase2 = regionInfo.estateSettings.terrainBase2; 172 handshake.RegionInfo.TerrainBase2 = regionInfo.estateSettings.terrainBase2;
173 handshake.RegionInfo.TerrainBase3 = regionInfo.estateSettings.terrainBase3; 173 handshake.RegionInfo.TerrainBase3 = regionInfo.estateSettings.terrainBase3;
174 handshake.RegionInfo.TerrainDetail0 = regionInfo.estateSettings.terrainDetail0; 174 handshake.RegionInfo.TerrainDetail0 = regionInfo.estateSettings.terrainDetail0;
175 handshake.RegionInfo.TerrainDetail1 = regionInfo.estateSettings.terrainDetail1; 175 handshake.RegionInfo.TerrainDetail1 = regionInfo.estateSettings.terrainDetail1;
176 handshake.RegionInfo.TerrainDetail2 = regionInfo.estateSettings.terrainDetail2; 176 handshake.RegionInfo.TerrainDetail2 = regionInfo.estateSettings.terrainDetail2;
177 handshake.RegionInfo.TerrainDetail3 = regionInfo.estateSettings.terrainDetail3; 177 handshake.RegionInfo.TerrainDetail3 = regionInfo.estateSettings.terrainDetail3;
178 handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting? 178 handshake.RegionInfo.CacheID = LLUUID.Random(); //I guess this is for the client to remember an old setting?
179 179
180 this.OutPacket(handshake); 180 this.OutPacket(handshake);
181 } 181 }
182 182
183 /// <summary> 183 /// <summary>
184 /// 184 ///
185 /// </summary> 185 /// </summary>
186 /// <param name="regInfo"></param> 186 /// <param name="regInfo"></param>
187 public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look) 187 public void MoveAgentIntoRegion(RegionInfo regInfo, LLVector3 pos, LLVector3 look)
188 { 188 {
189 AgentMovementCompletePacket mov = new AgentMovementCompletePacket(); 189 AgentMovementCompletePacket mov = new AgentMovementCompletePacket();
190 mov.AgentData.SessionID = this.SessionID; 190 mov.AgentData.SessionID = this.SessionID;
191 mov.AgentData.AgentID = this.AgentID; 191 mov.AgentData.AgentID = this.AgentID;
192 mov.Data.RegionHandle = regInfo.RegionHandle; 192 mov.Data.RegionHandle = regInfo.RegionHandle;
193 mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this 193 mov.Data.Timestamp = 1172750370; // TODO - dynamicalise this
194 194
195 if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0)) 195 if ((pos.X == 0) && (pos.Y == 0) && (pos.Z == 0))
196 { 196 {
197 mov.Data.Position = this.startpos; 197 mov.Data.Position = this.startpos;
198 } 198 }
199 else 199 else
200 { 200 {
201 mov.Data.Position = pos; 201 mov.Data.Position = pos;
202 } 202 }
203 mov.Data.LookAt = look; 203 mov.Data.LookAt = look;
204 204
205 OutPacket(mov); 205 OutPacket(mov);
206 } 206 }
207 207
208 /// <summary> 208 /// <summary>
209 /// 209 ///
210 /// </summary> 210 /// </summary>
211 /// <param name="message"></param> 211 /// <param name="message"></param>
212 /// <param name="type"></param> 212 /// <param name="type"></param>
213 /// <param name="fromPos"></param> 213 /// <param name="fromPos"></param>
214 /// <param name="fromName"></param> 214 /// <param name="fromName"></param>
215 /// <param name="fromAgentID"></param> 215 /// <param name="fromAgentID"></param>
216 public void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) 216 public void SendChatMessage(string message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
217 { 217 {
218 SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID); 218 SendChatMessage(Helpers.StringToField(message), type, fromPos, fromName, fromAgentID);
219 } 219 }
220 220
221 /// <summary> 221 /// <summary>
222 /// 222 ///
223 /// </summary> 223 /// </summary>
224 /// <param name="message"></param> 224 /// <param name="message"></param>
225 /// <param name="type"></param> 225 /// <param name="type"></param>
226 /// <param name="fromPos"></param> 226 /// <param name="fromPos"></param>
227 /// <param name="fromName"></param> 227 /// <param name="fromName"></param>
228 /// <param name="fromAgentID"></param> 228 /// <param name="fromAgentID"></param>
229 public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID) 229 public void SendChatMessage(byte[] message, byte type, LLVector3 fromPos, string fromName, LLUUID fromAgentID)
230 { 230 {
231 Encoding enc = Encoding.ASCII; 231 Encoding enc = Encoding.ASCII;
232 ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket(); 232 ChatFromSimulatorPacket reply = new ChatFromSimulatorPacket();
233 reply.ChatData.Audible = 1; 233 reply.ChatData.Audible = 1;
234 reply.ChatData.Message = message; 234 reply.ChatData.Message = message;
235 reply.ChatData.ChatType = type; 235 reply.ChatData.ChatType = type;
236 reply.ChatData.SourceType = 1; 236 reply.ChatData.SourceType = 1;
237 reply.ChatData.Position = fromPos; 237 reply.ChatData.Position = fromPos;
238 reply.ChatData.FromName = enc.GetBytes(fromName + "\0"); 238 reply.ChatData.FromName = enc.GetBytes(fromName + "\0");
239 reply.ChatData.OwnerID = fromAgentID; 239 reply.ChatData.OwnerID = fromAgentID;
240 reply.ChatData.SourceID = fromAgentID; 240 reply.ChatData.SourceID = fromAgentID;
241 241
242 this.OutPacket(reply); 242 this.OutPacket(reply);
243 } 243 }
244 244
245 /// <summary> 245 /// <summary>
246 /// 246 ///
247 /// </summary> 247 /// </summary>
248 /// <remarks>TODO</remarks> 248 /// <remarks>TODO</remarks>
249 /// <param name="message"></param> 249 /// <param name="message"></param>
250 /// <param name="target"></param> 250 /// <param name="target"></param>
251 public void SendInstantMessage(string message, LLUUID target, string fromName) 251 public void SendInstantMessage(string message, LLUUID target, string fromName)
252 { 252 {
253 if (message != "typing") 253 if (message != "typing")
254 { 254 {
255 Encoding enc = Encoding.ASCII; 255 Encoding enc = Encoding.ASCII;
256 ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket(); 256 ImprovedInstantMessagePacket msg = new ImprovedInstantMessagePacket();
257 msg.AgentData.AgentID = this.AgentID; 257 msg.AgentData.AgentID = this.AgentID;
258 msg.AgentData.SessionID = this.SessionID; 258 msg.AgentData.SessionID = this.SessionID;
259 msg.MessageBlock.FromAgentName = enc.GetBytes(fromName + " \0"); 259 msg.MessageBlock.FromAgentName = enc.GetBytes(fromName + " \0");
260 msg.MessageBlock.Dialog = 0; 260 msg.MessageBlock.Dialog = 0;
261 msg.MessageBlock.FromGroup = false; 261 msg.MessageBlock.FromGroup = false;
262 msg.MessageBlock.ID = target.Combine(this.SecureSessionID); 262 msg.MessageBlock.ID = target.Combine(this.SecureSessionID);
263 msg.MessageBlock.Offline = 0; 263 msg.MessageBlock.Offline = 0;
264 msg.MessageBlock.ParentEstateID = 0; 264 msg.MessageBlock.ParentEstateID = 0;
265 msg.MessageBlock.Position = new LLVector3(); 265 msg.MessageBlock.Position = new LLVector3();
266 msg.MessageBlock.RegionID = new LLUUID(); 266 msg.MessageBlock.RegionID = new LLUUID();
267 msg.MessageBlock.Timestamp = 0; 267 msg.MessageBlock.Timestamp = 0;
268 msg.MessageBlock.ToAgentID = target; 268 msg.MessageBlock.ToAgentID = target;
269 msg.MessageBlock.Message = enc.GetBytes(message + "\0"); 269 msg.MessageBlock.Message = enc.GetBytes(message + "\0");
270 msg.MessageBlock.BinaryBucket = new byte[0]; 270 msg.MessageBlock.BinaryBucket = new byte[0];
271 271
272 this.OutPacket(msg); 272 this.OutPacket(msg);
273 } 273 }
274 } 274 }
275 275
276 /// <summary> 276 /// <summary>
277 /// Send the region heightmap to the client 277 /// Send the region heightmap to the client
278 /// </summary> 278 /// </summary>
279 /// <param name="map">heightmap</param> 279 /// <param name="map">heightmap</param>
280 public virtual void SendLayerData(float[] map) 280 public virtual void SendLayerData(float[] map)
281 { 281 {
282 try 282 try
283 { 283 {
284 int[] patches = new int[4]; 284 int[] patches = new int[4];
285 285
286 for (int y = 0; y < 16; y++) 286 for (int y = 0; y < 16; y++)
287 { 287 {
288 for (int x = 0; x < 16; x = x + 4) 288 for (int x = 0; x < 16; x = x + 4)
289 { 289 {
290 patches[0] = x + 0 + y * 16; 290 patches[0] = x + 0 + y * 16;
291 patches[1] = x + 1 + y * 16; 291 patches[1] = x + 1 + y * 16;
292 patches[2] = x + 2 + y * 16; 292 patches[2] = x + 2 + y * 16;
293 patches[3] = x + 3 + y * 16; 293 patches[3] = x + 3 + y * 16;
294 294
295 Packet layerpack = TerrainManager.CreateLandPacket(map, patches); 295 Packet layerpack = TerrainManager.CreateLandPacket(map, patches);
296 OutPacket(layerpack); 296 OutPacket(layerpack);
297 } 297 }
298 } 298 }
299 } 299 }
300 catch (Exception e) 300 catch (Exception e)
301 { 301 {
302 MainLog.Instance.Warn("ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString()); 302 MainLog.Instance.Warn("ClientView API.cs: SendLayerData() - Failed with exception " + e.ToString());
303 } 303 }
304 } 304 }
305 305
306 /// <summary> 306 /// <summary>
307 /// Sends a specified patch to a client 307 /// Sends a specified patch to a client
308 /// </summary> 308 /// </summary>
309 /// <param name="px">Patch coordinate (x) 0..16</param> 309 /// <param name="px">Patch coordinate (x) 0..16</param>
310 /// <param name="py">Patch coordinate (y) 0..16</param> 310 /// <param name="py">Patch coordinate (y) 0..16</param>
311 /// <param name="map">heightmap</param> 311 /// <param name="map">heightmap</param>
312 public void SendLayerData(int px, int py, float[] map) 312 public void SendLayerData(int px, int py, float[] map)
313 { 313 {
314 try 314 try
315 { 315 {
316 int[] patches = new int[1]; 316 int[] patches = new int[1];
317 int patchx, patchy; 317 int patchx, patchy;
318 patchx = px / 16; 318 patchx = px / 16;
319 patchy = py / 16; 319 patchy = py / 16;
320 320
321 patches[0] = patchx + 0 + patchy * 16; 321 patches[0] = patchx + 0 + patchy * 16;
322 322
323 Packet layerpack = TerrainManager.CreateLandPacket(map, patches); 323 Packet layerpack = TerrainManager.CreateLandPacket(map, patches);
324 OutPacket(layerpack); 324 OutPacket(layerpack);
325 } 325 }
326 catch (Exception e) 326 catch (Exception e)
327 { 327 {
328 MainLog.Instance.Warn("ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString()); 328 MainLog.Instance.Warn("ClientView API .cs: SendLayerData() - Failed with exception " + e.ToString());
329 } 329 }
330 } 330 }
331 331
332 /// <summary> 332 /// <summary>
333 /// 333 ///
334 /// </summary> 334 /// </summary>
335 /// <param name="neighbourHandle"></param> 335 /// <param name="neighbourHandle"></param>
336 /// <param name="neighbourIP"></param> 336 /// <param name="neighbourIP"></param>
337 /// <param name="neighbourPort"></param> 337 /// <param name="neighbourPort"></param>
338 public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint) 338 public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourEndPoint)
339 { 339 {
340 IPAddress neighbourIP = neighbourEndPoint.Address; 340 IPAddress neighbourIP = neighbourEndPoint.Address;
341 ushort neighbourPort = (ushort)neighbourEndPoint.Port; 341 ushort neighbourPort = (ushort)neighbourEndPoint.Port;
342 342
343 EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket(); 343 EnableSimulatorPacket enablesimpacket = new EnableSimulatorPacket();
344 enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock(); 344 enablesimpacket.SimulatorInfo = new EnableSimulatorPacket.SimulatorInfoBlock();
345 enablesimpacket.SimulatorInfo.Handle = neighbourHandle; 345 enablesimpacket.SimulatorInfo.Handle = neighbourHandle;
346 346
347 byte[] byteIP = neighbourIP.GetAddressBytes(); 347 byte[] byteIP = neighbourIP.GetAddressBytes();
348 enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24; 348 enablesimpacket.SimulatorInfo.IP = (uint)byteIP[3] << 24;
349 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16; 349 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[2] << 16;
350 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8; 350 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[1] << 8;
351 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0]; 351 enablesimpacket.SimulatorInfo.IP += (uint)byteIP[0];
352 enablesimpacket.SimulatorInfo.Port = neighbourPort; 352 enablesimpacket.SimulatorInfo.Port = neighbourPort;
353 OutPacket(enablesimpacket); 353 OutPacket(enablesimpacket);
354 } 354 }
355 355
356 /// <summary> 356 /// <summary>
357 /// 357 ///
358 /// </summary> 358 /// </summary>
359 /// <returns></returns> 359 /// <returns></returns>
360 public AgentCircuitData RequestClientInfo() 360 public AgentCircuitData RequestClientInfo()
361 { 361 {
362 AgentCircuitData agentData = new AgentCircuitData(); 362 AgentCircuitData agentData = new AgentCircuitData();
363 agentData.AgentID = this.AgentId; 363 agentData.AgentID = this.AgentId;
364 agentData.SessionID = this.SessionID; 364 agentData.SessionID = this.SessionID;
365 agentData.SecureSessionID = this.SecureSessionID; 365 agentData.SecureSessionID = this.SecureSessionID;
366 agentData.circuitcode = this.CircuitCode; 366 agentData.circuitcode = this.CircuitCode;
367 agentData.child = false; 367 agentData.child = false;
368 agentData.firstname = this.firstName; 368 agentData.firstname = this.firstName;
369 agentData.lastname = this.lastName; 369 agentData.lastname = this.lastName;
370 370
371 return agentData; 371 return agentData;
372 } 372 }
373 373
374 public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint) 374 public void CrossRegion(ulong newRegionHandle, LLVector3 pos, LLVector3 lookAt, IPEndPoint externalIPEndPoint)
375 { 375 {
376 LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10); 376 LLVector3 look = new LLVector3(lookAt.X * 10, lookAt.Y * 10, lookAt.Z * 10);
377 377
378 CrossedRegionPacket newSimPack = new CrossedRegionPacket(); 378 CrossedRegionPacket newSimPack = new CrossedRegionPacket();
379 newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock(); 379 newSimPack.AgentData = new CrossedRegionPacket.AgentDataBlock();
380 newSimPack.AgentData.AgentID = this.AgentID; 380 newSimPack.AgentData.AgentID = this.AgentID;
381 newSimPack.AgentData.SessionID = this.SessionID; 381 newSimPack.AgentData.SessionID = this.SessionID;
382 newSimPack.Info = new CrossedRegionPacket.InfoBlock(); 382 newSimPack.Info = new CrossedRegionPacket.InfoBlock();
383 newSimPack.Info.Position = pos; 383 newSimPack.Info.Position = pos;
384 newSimPack.Info.LookAt = look; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!! 384 newSimPack.Info.LookAt = look; // new LLVector3(0.0f, 0.0f, 0.0f); // copied from Avatar.cs - SHOULD BE DYNAMIC!!!!!!!!!!
385 newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock(); 385 newSimPack.RegionData = new CrossedRegionPacket.RegionDataBlock();
386 newSimPack.RegionData.RegionHandle = newRegionHandle; 386 newSimPack.RegionData.RegionHandle = newRegionHandle;
387 byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes(); 387 byte[] byteIP = externalIPEndPoint.Address.GetAddressBytes();
388 newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24; 388 newSimPack.RegionData.SimIP = (uint)byteIP[3] << 24;
389 newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16; 389 newSimPack.RegionData.SimIP += (uint)byteIP[2] << 16;
390 newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8; 390 newSimPack.RegionData.SimIP += (uint)byteIP[1] << 8;
391 newSimPack.RegionData.SimIP += (uint)byteIP[0]; 391 newSimPack.RegionData.SimIP += (uint)byteIP[0];
392 newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port; 392 newSimPack.RegionData.SimPort = (ushort)externalIPEndPoint.Port;
393 newSimPack.RegionData.SeedCapability = new byte[0]; 393 newSimPack.RegionData.SeedCapability = new byte[0];
394 394
395 this.OutPacket(newSimPack); 395 this.OutPacket(newSimPack);
396 //this.DowngradeClient(); 396 //this.DowngradeClient();
397 } 397 }
398 398
399 public void SendMapBlock(List<MapBlockData> mapBlocks) 399 public void SendMapBlock(List<MapBlockData> mapBlocks)
400 { 400 {
401 MapBlockReplyPacket mapReply = new MapBlockReplyPacket(); 401 MapBlockReplyPacket mapReply = new MapBlockReplyPacket();
402 mapReply.AgentData.AgentID = this.AgentID; 402 mapReply.AgentData.AgentID = this.AgentID;
403 mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count]; 403 mapReply.Data = new MapBlockReplyPacket.DataBlock[mapBlocks.Count];
404 mapReply.AgentData.Flags = 0; 404 mapReply.AgentData.Flags = 0;
405 405
406 for (int i = 0; i < mapBlocks.Count; i++) 406 for (int i = 0; i < mapBlocks.Count; i++)
407 { 407 {
408 mapReply.Data[i] = new MapBlockReplyPacket.DataBlock(); 408 mapReply.Data[i] = new MapBlockReplyPacket.DataBlock();
409 mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId; 409 mapReply.Data[i].MapImageID = mapBlocks[i].MapImageId;
410 mapReply.Data[i].X = mapBlocks[i].X; 410 mapReply.Data[i].X = mapBlocks[i].X;
411 mapReply.Data[i].Y = mapBlocks[i].Y; 411 mapReply.Data[i].Y = mapBlocks[i].Y;
412 mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight; 412 mapReply.Data[i].WaterHeight = mapBlocks[i].WaterHeight;
413 mapReply.Data[i].Name = Helpers.StringToField(mapBlocks[i].Name); 413 mapReply.Data[i].Name = Helpers.StringToField(mapBlocks[i].Name);
414 mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags; 414 mapReply.Data[i].RegionFlags = mapBlocks[i].RegionFlags;
415 mapReply.Data[i].Access = mapBlocks[i].Access; 415 mapReply.Data[i].Access = mapBlocks[i].Access;
416 mapReply.Data[i].Agents = mapBlocks[i].Agents; 416 mapReply.Data[i].Agents = mapBlocks[i].Agents;
417 } 417 }
418 this.OutPacket(mapReply); 418 this.OutPacket(mapReply);
419 } 419 }
420 420
421 public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags) 421 public void SendLocalTeleport(LLVector3 position, LLVector3 lookAt, uint flags)
422 { 422 {
423 TeleportLocalPacket tpLocal = new TeleportLocalPacket(); 423 TeleportLocalPacket tpLocal = new TeleportLocalPacket();
424 tpLocal.Info.AgentID = this.AgentID; 424 tpLocal.Info.AgentID = this.AgentID;
425 tpLocal.Info.TeleportFlags = flags; 425 tpLocal.Info.TeleportFlags = flags;
426 tpLocal.Info.LocationID = 2; 426 tpLocal.Info.LocationID = 2;
427 tpLocal.Info.LookAt = lookAt; 427 tpLocal.Info.LookAt = lookAt;
428 tpLocal.Info.Position = position; 428 tpLocal.Info.Position = position;
429 OutPacket(tpLocal); 429 OutPacket(tpLocal);
430 } 430 }
431 431
432 public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, uint flags) 432 public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint newRegionEndPoint, uint locationID, uint flags)
433 { 433 {
434 TeleportFinishPacket teleport = new TeleportFinishPacket(); 434 TeleportFinishPacket teleport = new TeleportFinishPacket();
435 teleport.Info.AgentID = this.AgentID; 435 teleport.Info.AgentID = this.AgentID;
436 teleport.Info.RegionHandle = regionHandle; 436 teleport.Info.RegionHandle = regionHandle;
437 teleport.Info.SimAccess = simAccess; 437 teleport.Info.SimAccess = simAccess;
438 teleport.Info.SeedCapability = new byte[0]; 438 teleport.Info.SeedCapability = new byte[0];
439 439
440 IPAddress oIP = newRegionEndPoint.Address; 440 IPAddress oIP = newRegionEndPoint.Address;
441 byte[] byteIP = oIP.GetAddressBytes(); 441 byte[] byteIP = oIP.GetAddressBytes();
442 uint ip = (uint)byteIP[3] << 24; 442 uint ip = (uint)byteIP[3] << 24;
443 ip += (uint)byteIP[2] << 16; 443 ip += (uint)byteIP[2] << 16;
444 ip += (uint)byteIP[1] << 8; 444 ip += (uint)byteIP[1] << 8;
445 ip += (uint)byteIP[0]; 445 ip += (uint)byteIP[0];
446 446
447 teleport.Info.SimIP = ip; 447 teleport.Info.SimIP = ip;
448 teleport.Info.SimPort = (ushort)newRegionEndPoint.Port; 448 teleport.Info.SimPort = (ushort)newRegionEndPoint.Port;
449 teleport.Info.LocationID = 4; 449 teleport.Info.LocationID = 4;
450 teleport.Info.TeleportFlags = 1 << 4; 450 teleport.Info.TeleportFlags = 1 << 4;
451 OutPacket(teleport); 451 OutPacket(teleport);
452 } 452 }
453 453
454 /// <summary> 454 /// <summary>
455 /// 455 ///
456 /// </summary> 456 /// </summary>
457 public void SendTeleportCancel() 457 public void SendTeleportCancel()
458 { 458 {
459 TeleportCancelPacket tpCancel = new TeleportCancelPacket(); 459 TeleportCancelPacket tpCancel = new TeleportCancelPacket();
460 tpCancel.Info.SessionID = this.SessionID; 460 tpCancel.Info.SessionID = this.SessionID;
461 tpCancel.Info.AgentID = this.AgentID; 461 tpCancel.Info.AgentID = this.AgentID;
462 462
463 OutPacket(tpCancel); 463 OutPacket(tpCancel);
464 } 464 }
465 465
466 /// <summary> 466 /// <summary>
467 /// 467 ///
468 /// </summary> 468 /// </summary>
469 public void SendTeleportLocationStart() 469 public void SendTeleportLocationStart()
470 { 470 {
471 TeleportStartPacket tpStart = new TeleportStartPacket(); 471 TeleportStartPacket tpStart = new TeleportStartPacket();
472 tpStart.Info.TeleportFlags = 16; // Teleport via location 472 tpStart.Info.TeleportFlags = 16; // Teleport via location
473 OutPacket(tpStart); 473 OutPacket(tpStart);
474 } 474 }
475 475
476 public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance) 476 public void SendMoneyBalance(LLUUID transaction, bool success, byte[] description, int balance)
477 { 477 {
478 MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket(); 478 MoneyBalanceReplyPacket money = new MoneyBalanceReplyPacket();
479 money.MoneyData.AgentID = this.AgentID; 479 money.MoneyData.AgentID = this.AgentID;
480 money.MoneyData.TransactionID = transaction; 480 money.MoneyData.TransactionID = transaction;
481 money.MoneyData.TransactionSuccess = success; 481 money.MoneyData.TransactionSuccess = success;
482 money.MoneyData.Description = description; 482 money.MoneyData.Description = description;
483 money.MoneyData.MoneyBalance = balance; 483 money.MoneyData.MoneyBalance = balance;
484 OutPacket(money); 484 OutPacket(money);
485 } 485 }
486 486
487 public void SendStartPingCheck(byte seq) 487 public void SendStartPingCheck(byte seq)
488 { 488 {
489 StartPingCheckPacket pc = new StartPingCheckPacket(); 489 StartPingCheckPacket pc = new StartPingCheckPacket();
490 pc.PingID.PingID = seq; 490 pc.PingID.PingID = seq;
491 OutPacket(pc); 491 OutPacket(pc);
492 } 492 }
493 493
494 public void SendKillObject(ulong regionHandle, uint avatarLocalID) 494 public void SendKillObject(ulong regionHandle, uint avatarLocalID)
495 { 495 {
496 KillObjectPacket kill = new KillObjectPacket(); 496 KillObjectPacket kill = new KillObjectPacket();
497 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1]; 497 kill.ObjectData = new KillObjectPacket.ObjectDataBlock[1];
498 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock(); 498 kill.ObjectData[0] = new KillObjectPacket.ObjectDataBlock();
499 kill.ObjectData[0].ID = avatarLocalID; 499 kill.ObjectData[0].ID = avatarLocalID;
500 OutPacket(kill); 500 OutPacket(kill);
501 } 501 }
502 502
503 public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items) 503 public void SendInventoryFolderDetails(LLUUID ownerID, LLUUID folderID, List<InventoryItemBase> items)
504 { 504 {
505 Encoding enc = Encoding.ASCII; 505 Encoding enc = Encoding.ASCII;
506 uint FULL_MASK_PERMISSIONS = 2147483647; 506 uint FULL_MASK_PERMISSIONS = 2147483647;
507 InventoryDescendentsPacket descend = new InventoryDescendentsPacket(); 507 InventoryDescendentsPacket descend = new InventoryDescendentsPacket();
508 descend.AgentData.AgentID = this.AgentId; 508 descend.AgentData.AgentID = this.AgentId;
509 descend.AgentData.OwnerID = ownerID; 509 descend.AgentData.OwnerID = ownerID;
510 descend.AgentData.FolderID = folderID; 510 descend.AgentData.FolderID = folderID;
511 descend.AgentData.Descendents = items.Count; 511 descend.AgentData.Descendents = items.Count;
512 descend.AgentData.Version = 0; 512 descend.AgentData.Version = 0;
513 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count]; 513 descend.ItemData = new InventoryDescendentsPacket.ItemDataBlock[items.Count];
514 int i = 0; 514 int i = 0;
515 foreach (InventoryItemBase item in items) 515 foreach (InventoryItemBase item in items)
516 { 516 {
517 descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock(); 517 descend.ItemData[i] = new InventoryDescendentsPacket.ItemDataBlock();
518 descend.ItemData[i].ItemID = item.inventoryID; 518 descend.ItemData[i].ItemID = item.inventoryID;
519 descend.ItemData[i].AssetID = item.assetID; 519 descend.ItemData[i].AssetID = item.assetID;
520 descend.ItemData[i].CreatorID = item.creatorsID; 520 descend.ItemData[i].CreatorID = item.creatorsID;
521 descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS; 521 descend.ItemData[i].BaseMask = FULL_MASK_PERMISSIONS;
522 descend.ItemData[i].CreationDate = 1000; 522 descend.ItemData[i].CreationDate = 1000;
523 descend.ItemData[i].Description = enc.GetBytes(item.inventoryDescription+ "\0"); 523 descend.ItemData[i].Description = enc.GetBytes(item.inventoryDescription+ "\0");
524 descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS; 524 descend.ItemData[i].EveryoneMask = FULL_MASK_PERMISSIONS;
525 descend.ItemData[i].Flags = 1; 525 descend.ItemData[i].Flags = 1;
526 descend.ItemData[i].FolderID = item.parentFolderID; 526 descend.ItemData[i].FolderID = item.parentFolderID;
527 descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); 527 descend.ItemData[i].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
528 descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS; 528 descend.ItemData[i].GroupMask = FULL_MASK_PERMISSIONS;
529 descend.ItemData[i].InvType = (sbyte)item.type; 529 descend.ItemData[i].InvType = (sbyte)item.type;
530 descend.ItemData[i].Name = enc.GetBytes(item.inventoryName+ "\0"); 530 descend.ItemData[i].Name = enc.GetBytes(item.inventoryName+ "\0");
531 descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS; 531 descend.ItemData[i].NextOwnerMask = FULL_MASK_PERMISSIONS;
532 descend.ItemData[i].OwnerID = item.avatarID; 532 descend.ItemData[i].OwnerID = item.avatarID;
533 descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS; 533 descend.ItemData[i].OwnerMask = FULL_MASK_PERMISSIONS;
534 descend.ItemData[i].SalePrice = 0; 534 descend.ItemData[i].SalePrice = 0;
535 descend.ItemData[i].SaleType = 0; 535 descend.ItemData[i].SaleType = 0;
536 descend.ItemData[i].Type = (sbyte)item.type; 536 descend.ItemData[i].Type = (sbyte)item.type;
537 descend.ItemData[i].CRC = Helpers.InventoryCRC(1000, 0, descend.ItemData[i].InvType, descend.ItemData[i].Type, descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, 100,descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); 537 descend.ItemData[i].CRC = Helpers.InventoryCRC(1000, 0, descend.ItemData[i].InvType, descend.ItemData[i].Type, descend.ItemData[i].AssetID, descend.ItemData[i].GroupID, 100,descend.ItemData[i].OwnerID, descend.ItemData[i].CreatorID, descend.ItemData[i].ItemID, descend.ItemData[i].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
538 538
539 i++; 539 i++;
540 } 540 }
541 541
542 this.OutPacket(descend); 542 this.OutPacket(descend);
543 543
544 } 544 }
545 545
546 public void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item) 546 public void SendInventoryItemDetails(LLUUID ownerID, LLUUID folderID, InventoryItemBase item)
547 { 547 {
548 Encoding enc = Encoding.ASCII; 548 Encoding enc = Encoding.ASCII;
549 uint FULL_MASK_PERMISSIONS = 2147483647; 549 uint FULL_MASK_PERMISSIONS = 2147483647;
550 FetchInventoryReplyPacket inventoryReply = new FetchInventoryReplyPacket(); 550 FetchInventoryReplyPacket inventoryReply = new FetchInventoryReplyPacket();
551 inventoryReply.AgentData.AgentID = this.AgentId; 551 inventoryReply.AgentData.AgentID = this.AgentId;
552 inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1]; 552 inventoryReply.InventoryData = new FetchInventoryReplyPacket.InventoryDataBlock[1];
553 inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock(); 553 inventoryReply.InventoryData[0] = new FetchInventoryReplyPacket.InventoryDataBlock();
554 inventoryReply.InventoryData[0].ItemID = item.inventoryID; 554 inventoryReply.InventoryData[0].ItemID = item.inventoryID;
555 inventoryReply.InventoryData[0].AssetID = item.assetID; 555 inventoryReply.InventoryData[0].AssetID = item.assetID;
556 inventoryReply.InventoryData[0].CreatorID = item.creatorsID; 556 inventoryReply.InventoryData[0].CreatorID = item.creatorsID;
557 inventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS; 557 inventoryReply.InventoryData[0].BaseMask = FULL_MASK_PERMISSIONS;
558 inventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds; 558 inventoryReply.InventoryData[0].CreationDate = (int)(DateTime.UtcNow - new DateTime(1970, 1, 1)).TotalSeconds;
559 inventoryReply.InventoryData[0].Description = enc.GetBytes(item.inventoryDescription + "\0"); 559 inventoryReply.InventoryData[0].Description = enc.GetBytes(item.inventoryDescription + "\0");
560 inventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS; 560 inventoryReply.InventoryData[0].EveryoneMask = FULL_MASK_PERMISSIONS;
561 inventoryReply.InventoryData[0].Flags = 0; 561 inventoryReply.InventoryData[0].Flags = 0;
562 inventoryReply.InventoryData[0].FolderID = item.parentFolderID; 562 inventoryReply.InventoryData[0].FolderID = item.parentFolderID;
563 inventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000"); 563 inventoryReply.InventoryData[0].GroupID = new LLUUID("00000000-0000-0000-0000-000000000000");
564 inventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS; 564 inventoryReply.InventoryData[0].GroupMask = FULL_MASK_PERMISSIONS;
565 inventoryReply.InventoryData[0].InvType = (sbyte)item.type; 565 inventoryReply.InventoryData[0].InvType = (sbyte)item.type;
566 inventoryReply.InventoryData[0].Name = enc.GetBytes(item.inventoryName + "\0"); 566 inventoryReply.InventoryData[0].Name = enc.GetBytes(item.inventoryName + "\0");
567 inventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS; 567 inventoryReply.InventoryData[0].NextOwnerMask = FULL_MASK_PERMISSIONS;
568 inventoryReply.InventoryData[0].OwnerID = item.avatarID; 568 inventoryReply.InventoryData[0].OwnerID = item.avatarID;
569 inventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS; 569 inventoryReply.InventoryData[0].OwnerMask = FULL_MASK_PERMISSIONS;
570 inventoryReply.InventoryData[0].SalePrice = 0; 570 inventoryReply.InventoryData[0].SalePrice = 0;
571 inventoryReply.InventoryData[0].SaleType = 0; 571 inventoryReply.InventoryData[0].SaleType = 0;
572 inventoryReply.InventoryData[0].Type = (sbyte)item.type; 572 inventoryReply.InventoryData[0].Type = (sbyte)item.type;
573 inventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType, inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID, inventoryReply.InventoryData[0].GroupID, 100, inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID, inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS); 573 inventoryReply.InventoryData[0].CRC = Helpers.InventoryCRC(1000, 0, inventoryReply.InventoryData[0].InvType, inventoryReply.InventoryData[0].Type, inventoryReply.InventoryData[0].AssetID, inventoryReply.InventoryData[0].GroupID, 100, inventoryReply.InventoryData[0].OwnerID, inventoryReply.InventoryData[0].CreatorID, inventoryReply.InventoryData[0].ItemID, inventoryReply.InventoryData[0].FolderID, FULL_MASK_PERMISSIONS, 1, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS, FULL_MASK_PERMISSIONS);
574 574
575 this.OutPacket(inventoryReply); 575 this.OutPacket(inventoryReply);
576 } 576 }
577 577
578 #region Appearance/ Wearables Methods 578 #region Appearance/ Wearables Methods
579 579
580 /// <summary> 580 /// <summary>
581 /// 581 ///
582 /// </summary> 582 /// </summary>
583 /// <param name="wearables"></param> 583 /// <param name="wearables"></param>
584 public void SendWearables(AvatarWearable[] wearables) 584 public void SendWearables(AvatarWearable[] wearables)
585 { 585 {
586 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket(); 586 AgentWearablesUpdatePacket aw = new AgentWearablesUpdatePacket();
587 aw.AgentData.AgentID = this.AgentID; 587 aw.AgentData.AgentID = this.AgentID;
588 aw.AgentData.SerialNum = 0; 588 aw.AgentData.SerialNum = 0;
589 aw.AgentData.SessionID = this.SessionID; 589 aw.AgentData.SessionID = this.SessionID;
590 590
591 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13]; 591 aw.WearableData = new AgentWearablesUpdatePacket.WearableDataBlock[13];
592 AgentWearablesUpdatePacket.WearableDataBlock awb; 592 AgentWearablesUpdatePacket.WearableDataBlock awb;
593 for (int i = 0; i < wearables.Length; i++) 593 for (int i = 0; i < wearables.Length; i++)
594 { 594 {
595 awb = new AgentWearablesUpdatePacket.WearableDataBlock(); 595 awb = new AgentWearablesUpdatePacket.WearableDataBlock();
596 awb.WearableType = (byte)i; 596 awb.WearableType = (byte)i;
597 awb.AssetID = wearables[i].AssetID; 597 awb.AssetID = wearables[i].AssetID;
598 awb.ItemID = wearables[i].ItemID; 598 awb.ItemID = wearables[i].ItemID;
599 aw.WearableData[i] = awb; 599 aw.WearableData[i] = awb;
600 } 600 }
601 601
602 this.OutPacket(aw); 602 this.OutPacket(aw);
603 } 603 }
604 604
605 /// <summary> 605 /// <summary>
606 /// 606 ///
607 /// </summary> 607 /// </summary>
608 /// <param name="agentID"></param> 608 /// <param name="agentID"></param>
609 /// <param name="visualParams"></param> 609 /// <param name="visualParams"></param>
610 /// <param name="textureEntry"></param> 610 /// <param name="textureEntry"></param>
611 public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry) 611 public void SendAppearance(LLUUID agentID, byte[] visualParams, byte[] textureEntry)
612 { 612 {
613 AvatarAppearancePacket avp = new AvatarAppearancePacket(); 613 AvatarAppearancePacket avp = new AvatarAppearancePacket();
614 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218]; 614 avp.VisualParam = new AvatarAppearancePacket.VisualParamBlock[218];
615 avp.ObjectData.TextureEntry = textureEntry; 615 avp.ObjectData.TextureEntry = textureEntry;
616 616
617 AvatarAppearancePacket.VisualParamBlock avblock = null; 617 AvatarAppearancePacket.VisualParamBlock avblock = null;
618 for (int i = 0; i < visualParams.Length; i++) 618 for (int i = 0; i < visualParams.Length; i++)
619 { 619 {
620 avblock = new AvatarAppearancePacket.VisualParamBlock(); 620 avblock = new AvatarAppearancePacket.VisualParamBlock();
621 avblock.ParamValue = visualParams[i]; 621 avblock.ParamValue = visualParams[i];
622 avp.VisualParam[i] = avblock; 622 avp.VisualParam[i] = avblock;
623 } 623 }
624 624
625 avp.Sender.IsTrial = false; 625 avp.Sender.IsTrial = false;
626 avp.Sender.ID = agentID; 626 avp.Sender.ID = agentID;
627 OutPacket(avp); 627 OutPacket(avp);
628 } 628 }
629 629
630 public void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId) 630 public void SendAnimation(LLUUID animID, int seq, LLUUID sourceAgentId)
631 { 631 {
632 AvatarAnimationPacket ani = new AvatarAnimationPacket(); 632 AvatarAnimationPacket ani = new AvatarAnimationPacket();
633 ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1]; 633 ani.AnimationSourceList = new AvatarAnimationPacket.AnimationSourceListBlock[1];
634 ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock(); 634 ani.AnimationSourceList[0] = new AvatarAnimationPacket.AnimationSourceListBlock();
635 ani.AnimationSourceList[0].ObjectID = sourceAgentId; 635 ani.AnimationSourceList[0].ObjectID = sourceAgentId;
636 ani.Sender = new AvatarAnimationPacket.SenderBlock(); 636 ani.Sender = new AvatarAnimationPacket.SenderBlock();
637 ani.Sender.ID = sourceAgentId; 637 ani.Sender.ID = sourceAgentId;
638 ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1]; 638 ani.AnimationList = new AvatarAnimationPacket.AnimationListBlock[1];
639 ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock(); 639 ani.AnimationList[0] = new AvatarAnimationPacket.AnimationListBlock();
640 ani.AnimationList[0].AnimID = animID; 640 ani.AnimationList[0].AnimID = animID;
641 ani.AnimationList[0].AnimSequenceID = seq; 641 ani.AnimationList[0].AnimSequenceID = seq;
642 this.OutPacket(ani); 642 this.OutPacket(ani);
643 } 643 }
644 644
645 #endregion 645 #endregion
646 646
647 #region Avatar Packet/data sending Methods 647 #region Avatar Packet/data sending Methods
648 648
649 /// <summary> 649 /// <summary>
650 /// send a objectupdate packet with information about the clients avatar 650 /// send a objectupdate packet with information about the clients avatar
651 /// </summary> 651 /// </summary>
652 /// <param name="regionInfo"></param> 652 /// <param name="regionInfo"></param>
653 /// <param name="firstName"></param> 653 /// <param name="firstName"></param>
654 /// <param name="lastName"></param> 654 /// <param name="lastName"></param>
655 /// <param name="avatarID"></param> 655 /// <param name="avatarID"></param>
656 /// <param name="avatarLocalID"></param> 656 /// <param name="avatarLocalID"></param>
657 /// <param name="Pos"></param> 657 /// <param name="Pos"></param>
658 public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry) 658 public void SendAvatarData(ulong regionHandle, string firstName, string lastName, LLUUID avatarID, uint avatarLocalID, LLVector3 Pos, byte[] textureEntry)
659 { 659 {
660 ObjectUpdatePacket objupdate = new ObjectUpdatePacket(); 660 ObjectUpdatePacket objupdate = new ObjectUpdatePacket();
661 objupdate.RegionData.RegionHandle = regionHandle; 661 objupdate.RegionData.RegionHandle = regionHandle;
662 objupdate.RegionData.TimeDilation = 64096; 662 objupdate.RegionData.TimeDilation = 64096;
663 objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 663 objupdate.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
664 objupdate.ObjectData[0] = this.CreateDefaultAvatarPacket(textureEntry); 664 objupdate.ObjectData[0] = this.CreateDefaultAvatarPacket(textureEntry);
665 665
666 //give this avatar object a local id and assign the user a name 666 //give this avatar object a local id and assign the user a name
667 objupdate.ObjectData[0].ID = avatarLocalID; 667 objupdate.ObjectData[0].ID = avatarLocalID;
668 objupdate.ObjectData[0].FullID = avatarID; 668 objupdate.ObjectData[0].FullID = avatarID;
669 objupdate.ObjectData[0].NameValue = Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName ); 669 objupdate.ObjectData[0].NameValue = Helpers.StringToField("FirstName STRING RW SV " + firstName + "\nLastName STRING RW SV " + lastName );
670 LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z); 670 LLVector3 pos2 = new LLVector3((float)Pos.X, (float)Pos.Y, (float)Pos.Z);
671 byte[] pb = pos2.GetBytes(); 671 byte[] pb = pos2.GetBytes();
672 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length); 672 Array.Copy(pb, 0, objupdate.ObjectData[0].ObjectData, 16, pb.Length);
673 673
674 OutPacket(objupdate); 674 OutPacket(objupdate);
675 675
676 } 676 }
677 677
678 /// <summary> 678 /// <summary>
679 /// 679 ///
680 /// </summary> 680 /// </summary>
681 /// <param name="regionHandle"></param> 681 /// <param name="regionHandle"></param>
682 /// <param name="timeDilation"></param> 682 /// <param name="timeDilation"></param>
683 /// <param name="localID"></param> 683 /// <param name="localID"></param>
684 /// <param name="position"></param> 684 /// <param name="position"></param>
685 /// <param name="velocity"></param> 685 /// <param name="velocity"></param>
686 public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity) 686 public void SendAvatarTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLVector3 velocity)
687 { 687 {
688 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity); 688 ImprovedTerseObjectUpdatePacket.ObjectDataBlock terseBlock = this.CreateAvatarImprovedBlock(localID, position, velocity);
689 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); 689 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
690 terse.RegionData.RegionHandle = regionHandle; 690 terse.RegionData.RegionHandle = regionHandle;
691 terse.RegionData.TimeDilation = timeDilation; 691 terse.RegionData.TimeDilation = timeDilation;
692 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 692 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
693 terse.ObjectData[0] = terseBlock; 693 terse.ObjectData[0] = terseBlock;
694 694
695 this.OutPacket(terse); 695 this.OutPacket(terse);
696 } 696 }
697 697
698 #endregion 698 #endregion
699 699
700 #region Primitive Packet/data Sending Methods 700 #region Primitive Packet/data Sending Methods
701 701
702 /// <summary> 702 /// <summary>
703 /// 703 ///
704 /// </summary> 704 /// </summary>
705 /// <param name="localID"></param> 705 /// <param name="localID"></param>
706 /// <param name="rotation"></param> 706 /// <param name="rotation"></param>
707 /// <param name="attachPoint"></param> 707 /// <param name="attachPoint"></param>
708 public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint) 708 public void AttachObject(uint localID, LLQuaternion rotation, byte attachPoint)
709 { 709 {
710 ObjectAttachPacket attach = new ObjectAttachPacket(); 710 ObjectAttachPacket attach = new ObjectAttachPacket();
711 attach.AgentData.AgentID = this.AgentID; 711 attach.AgentData.AgentID = this.AgentID;
712 attach.AgentData.SessionID = this.SessionID; 712 attach.AgentData.SessionID = this.SessionID;
713 attach.AgentData.AttachmentPoint = attachPoint; 713 attach.AgentData.AttachmentPoint = attachPoint;
714 attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1]; 714 attach.ObjectData = new ObjectAttachPacket.ObjectDataBlock[1];
715 attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock(); 715 attach.ObjectData[0] = new ObjectAttachPacket.ObjectDataBlock();
716 attach.ObjectData[0].ObjectLocalID = localID; 716 attach.ObjectData[0].ObjectLocalID = localID;
717 attach.ObjectData[0].Rotation = rotation; 717 attach.ObjectData[0].Rotation = rotation;
718 718
719 this.OutPacket(attach); 719 this.OutPacket(attach);
720 } 720 }
721 721
722 /// <summary> 722 /// <summary>
723 /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive 723 /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive
724 /// or big changes to a existing primitive. 724 /// or big changes to a existing primitive.
725 /// </summary> 725 /// </summary>
726 /// <param name="regionHandle"></param> 726 /// <param name="regionHandle"></param>
727 /// <param name="timeDilation"></param> 727 /// <param name="timeDilation"></param>
728 /// <param name="localID"></param> 728 /// <param name="localID"></param>
729 /// <param name="primData"></param> 729 /// <param name="primData"></param>
730 /// <param name="pos"></param> 730 /// <param name="pos"></param>
731 /// <param name="rotation"></param> 731 /// <param name="rotation"></param>
732 /// <param name="textureID"></param> 732 /// <param name="textureID"></param>
733 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags) 733 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLQuaternion rotation, LLUUID textureID, uint flags)
734 { 734 {
735 ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); 735 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
736 outPacket.RegionData.RegionHandle = regionHandle; 736 outPacket.RegionData.RegionHandle = regionHandle;
737 outPacket.RegionData.TimeDilation = timeDilation; 737 outPacket.RegionData.TimeDilation = timeDilation;
738 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 738 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
739 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags); 739 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags);
740 outPacket.ObjectData[0].ID = localID; 740 outPacket.ObjectData[0].ID = localID;
741 outPacket.ObjectData[0].FullID = primData.FullID; 741 outPacket.ObjectData[0].FullID = primData.FullID;
742 byte[] pb = pos.GetBytes(); 742 byte[] pb = pos.GetBytes();
743 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); 743 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
744 byte[] rot = rotation.GetBytes(); 744 byte[] rot = rotation.GetBytes();
745 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 48, rot.Length); 745 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 48, rot.Length);
746 OutPacket(outPacket); 746 OutPacket(outPacket);
747 } 747 }
748 748
749 /// <summary> 749 /// <summary>
750 /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive 750 /// Sends a full ObjectUpdatePacket to a client to inform it of a new primitive
751 /// or big changes to a existing primitive. 751 /// or big changes to a existing primitive.
752 /// Uses default rotation 752 /// Uses default rotation
753 /// </summary> 753 /// </summary>
754 /// <param name="primData"></param> 754 /// <param name="primData"></param>
755 /// <param name="pos"></param> 755 /// <param name="pos"></param>
756 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags) 756 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimData primData, LLVector3 pos, LLUUID textureID, uint flags)
757 { 757 {
758 ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); 758 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
759 outPacket.RegionData.RegionHandle = regionHandle; 759 outPacket.RegionData.RegionHandle = regionHandle;
760 outPacket.RegionData.TimeDilation = timeDilation; 760 outPacket.RegionData.TimeDilation = timeDilation;
761 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 761 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
762 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags); 762 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primData, textureID, flags);
763 outPacket.ObjectData[0].ID = localID; 763 outPacket.ObjectData[0].ID = localID;
764 outPacket.ObjectData[0].FullID = primData.FullID; 764 outPacket.ObjectData[0].FullID = primData.FullID;
765 byte[] pb = pos.GetBytes(); 765 byte[] pb = pos.GetBytes();
766 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); 766 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
767 767
768 OutPacket(outPacket); 768 OutPacket(outPacket);
769 } 769 }
770 770
771 771
772 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) 772 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, LLQuaternion rotation, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID)
773 { 773 {
774 ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); 774 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
775 outPacket.RegionData.RegionHandle = regionHandle; 775 outPacket.RegionData.RegionHandle = regionHandle;
776 outPacket.RegionData.TimeDilation = timeDilation; 776 outPacket.RegionData.TimeDilation = timeDilation;
777 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 777 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
778 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags); 778 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags);
779 outPacket.ObjectData[0].ID = localID; 779 outPacket.ObjectData[0].ID = localID;
780 outPacket.ObjectData[0].FullID = objectID; 780 outPacket.ObjectData[0].FullID = objectID;
781 outPacket.ObjectData[0].OwnerID = ownerID; 781 outPacket.ObjectData[0].OwnerID = ownerID;
782 outPacket.ObjectData[0].Text = enc.GetBytes(text); 782 outPacket.ObjectData[0].Text = enc.GetBytes(text);
783 outPacket.ObjectData[0].ParentID = parentID; 783 outPacket.ObjectData[0].ParentID = parentID;
784 byte[] pb = pos.GetBytes(); 784 byte[] pb = pos.GetBytes();
785 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); 785 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
786 byte[] rot = rotation.GetBytes(); 786 byte[] rot = rotation.GetBytes();
787 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 36, rot.Length); 787 Array.Copy(rot, 0, outPacket.ObjectData[0].ObjectData, 36, rot.Length);
788 OutPacket(outPacket); 788 OutPacket(outPacket);
789 } 789 }
790 790
791 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID) 791 public void SendPrimitiveToClient(ulong regionHandle, ushort timeDilation, uint localID, PrimitiveBaseShape primShape, LLVector3 pos, uint flags, LLUUID objectID, LLUUID ownerID, string text, uint parentID)
792 { 792 {
793 ObjectUpdatePacket outPacket = new ObjectUpdatePacket(); 793 ObjectUpdatePacket outPacket = new ObjectUpdatePacket();
794 outPacket.RegionData.RegionHandle = regionHandle; 794 outPacket.RegionData.RegionHandle = regionHandle;
795 outPacket.RegionData.TimeDilation = timeDilation; 795 outPacket.RegionData.TimeDilation = timeDilation;
796 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1]; 796 outPacket.ObjectData = new ObjectUpdatePacket.ObjectDataBlock[1];
797 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags); 797 outPacket.ObjectData[0] = this.CreatePrimUpdateBlock(primShape, flags);
798 outPacket.ObjectData[0].ID = localID; 798 outPacket.ObjectData[0].ID = localID;
799 outPacket.ObjectData[0].FullID = objectID; 799 outPacket.ObjectData[0].FullID = objectID;
800 outPacket.ObjectData[0].OwnerID = ownerID; 800 outPacket.ObjectData[0].OwnerID = ownerID;
801 outPacket.ObjectData[0].Text = enc.GetBytes(text); 801 outPacket.ObjectData[0].Text = enc.GetBytes(text);
802 outPacket.ObjectData[0].ParentID = parentID; 802 outPacket.ObjectData[0].ParentID = parentID;
803 byte[] pb = pos.GetBytes(); 803 byte[] pb = pos.GetBytes();
804 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length); 804 Array.Copy(pb, 0, outPacket.ObjectData[0].ObjectData, 0, pb.Length);
805 805
806 OutPacket(outPacket); 806 OutPacket(outPacket);
807 } 807 }
808 /// <summary> 808 /// <summary>
809 /// 809 ///
810 /// </summary> 810 /// </summary>
811 /// <param name="regionHandle"></param> 811 /// <param name="regionHandle"></param>
812 /// <param name="timeDilation"></param> 812 /// <param name="timeDilation"></param>
813 /// <param name="localID"></param> 813 /// <param name="localID"></param>
814 /// <param name="position"></param> 814 /// <param name="position"></param>
815 /// <param name="rotation"></param> 815 /// <param name="rotation"></param>
816 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation) 816 public void SendPrimTerseUpdate(ulong regionHandle, ushort timeDilation, uint localID, LLVector3 position, LLQuaternion rotation)
817 { 817 {
818 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket(); 818 ImprovedTerseObjectUpdatePacket terse = new ImprovedTerseObjectUpdatePacket();
819 terse.RegionData.RegionHandle = regionHandle; 819 terse.RegionData.RegionHandle = regionHandle;
820 terse.RegionData.TimeDilation = timeDilation; 820 terse.RegionData.TimeDilation = timeDilation;
821 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1]; 821 terse.ObjectData = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock[1];
822 terse.ObjectData[0] = this.CreatePrimImprovedBlock(localID, position, rotation); 822 terse.ObjectData[0] = this.CreatePrimImprovedBlock(localID, position, rotation);
823 823
824 this.OutPacket(terse); 824 this.OutPacket(terse);
825 } 825 }
826 826
827 #endregion 827 #endregion
828 828
829 #endregion 829 #endregion
830 830
831 #region Helper Methods 831 #region Helper Methods
832 832
833 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity) 833 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreateAvatarImprovedBlock(uint localID, LLVector3 pos, LLVector3 velocity)
834 { 834 {
835 byte[] bytes = new byte[60]; 835 byte[] bytes = new byte[60];
836 int i = 0; 836 int i = 0;
837 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); 837 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
838 838
839 dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry; 839 dat.TextureEntry = new byte[0];// AvatarTemplate.TextureEntry;
840 840
841 uint ID = localID; 841 uint ID = localID;
842 842
843 bytes[i++] = (byte)(ID % 256); 843 bytes[i++] = (byte)(ID % 256);
844 bytes[i++] = (byte)((ID >> 8) % 256); 844 bytes[i++] = (byte)((ID >> 8) % 256);
845 bytes[i++] = (byte)((ID >> 16) % 256); 845 bytes[i++] = (byte)((ID >> 16) % 256);
846 bytes[i++] = (byte)((ID >> 24) % 256); 846 bytes[i++] = (byte)((ID >> 24) % 256);
847 bytes[i++] = 0; 847 bytes[i++] = 0;
848 bytes[i++] = 1; 848 bytes[i++] = 1;
849 i += 14; 849 i += 14;
850 bytes[i++] = 128; 850 bytes[i++] = 128;
851 bytes[i++] = 63; 851 bytes[i++] = 63;
852 852
853 byte[] pb = pos.GetBytes(); 853 byte[] pb = pos.GetBytes();
854 Array.Copy(pb, 0, bytes, i, pb.Length); 854 Array.Copy(pb, 0, bytes, i, pb.Length);
855 i += 12; 855 i += 12;
856 ushort InternVelocityX; 856 ushort InternVelocityX;
857 ushort InternVelocityY; 857 ushort InternVelocityY;
858 ushort InternVelocityZ; 858 ushort InternVelocityZ;
859 Vector3 internDirec = new Vector3(0, 0, 0); 859 Vector3 internDirec = new Vector3(0, 0, 0);
860 860
861 internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z); 861 internDirec = new Vector3(velocity.X, velocity.Y, velocity.Z);
862 862
863 internDirec = internDirec / 128.0f; 863 internDirec = internDirec / 128.0f;
864 internDirec.x += 1; 864 internDirec.x += 1;
865 internDirec.y += 1; 865 internDirec.y += 1;
866 internDirec.z += 1; 866 internDirec.z += 1;
867 867
868 InternVelocityX = (ushort)(32768 * internDirec.x); 868 InternVelocityX = (ushort)(32768 * internDirec.x);
869 InternVelocityY = (ushort)(32768 * internDirec.y); 869 InternVelocityY = (ushort)(32768 * internDirec.y);
870 InternVelocityZ = (ushort)(32768 * internDirec.z); 870 InternVelocityZ = (ushort)(32768 * internDirec.z);
871 871
872 ushort ac = 32767; 872 ushort ac = 32767;
873 bytes[i++] = (byte)(InternVelocityX % 256); 873 bytes[i++] = (byte)(InternVelocityX % 256);
874 bytes[i++] = (byte)((InternVelocityX >> 8) % 256); 874 bytes[i++] = (byte)((InternVelocityX >> 8) % 256);
875 bytes[i++] = (byte)(InternVelocityY % 256); 875 bytes[i++] = (byte)(InternVelocityY % 256);
876 bytes[i++] = (byte)((InternVelocityY >> 8) % 256); 876 bytes[i++] = (byte)((InternVelocityY >> 8) % 256);
877 bytes[i++] = (byte)(InternVelocityZ % 256); 877 bytes[i++] = (byte)(InternVelocityZ % 256);
878 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256); 878 bytes[i++] = (byte)((InternVelocityZ >> 8) % 256);
879 879
880 //accel 880 //accel
881 bytes[i++] = (byte)(ac % 256); 881 bytes[i++] = (byte)(ac % 256);
882 bytes[i++] = (byte)((ac >> 8) % 256); 882 bytes[i++] = (byte)((ac >> 8) % 256);
883 bytes[i++] = (byte)(ac % 256); 883 bytes[i++] = (byte)(ac % 256);
884 bytes[i++] = (byte)((ac >> 8) % 256); 884 bytes[i++] = (byte)((ac >> 8) % 256);
885 bytes[i++] = (byte)(ac % 256); 885 bytes[i++] = (byte)(ac % 256);
886 bytes[i++] = (byte)((ac >> 8) % 256); 886 bytes[i++] = (byte)((ac >> 8) % 256);
887 887
888 //rot 888 //rot
889 bytes[i++] = (byte)(ac % 256); 889 bytes[i++] = (byte)(ac % 256);
890 bytes[i++] = (byte)((ac >> 8) % 256); 890 bytes[i++] = (byte)((ac >> 8) % 256);
891 bytes[i++] = (byte)(ac % 256); 891 bytes[i++] = (byte)(ac % 256);
892 bytes[i++] = (byte)((ac >> 8) % 256); 892 bytes[i++] = (byte)((ac >> 8) % 256);
893 bytes[i++] = (byte)(ac % 256); 893 bytes[i++] = (byte)(ac % 256);
894 bytes[i++] = (byte)((ac >> 8) % 256); 894 bytes[i++] = (byte)((ac >> 8) % 256);
895 bytes[i++] = (byte)(ac % 256); 895 bytes[i++] = (byte)(ac % 256);
896 bytes[i++] = (byte)((ac >> 8) % 256); 896 bytes[i++] = (byte)((ac >> 8) % 256);
897 897
898 //rotation vel 898 //rotation vel
899 bytes[i++] = (byte)(ac % 256); 899 bytes[i++] = (byte)(ac % 256);
900 bytes[i++] = (byte)((ac >> 8) % 256); 900 bytes[i++] = (byte)((ac >> 8) % 256);
901 bytes[i++] = (byte)(ac % 256); 901 bytes[i++] = (byte)(ac % 256);
902 bytes[i++] = (byte)((ac >> 8) % 256); 902 bytes[i++] = (byte)((ac >> 8) % 256);
903 bytes[i++] = (byte)(ac % 256); 903 bytes[i++] = (byte)(ac % 256);
904 bytes[i++] = (byte)((ac >> 8) % 256); 904 bytes[i++] = (byte)((ac >> 8) % 256);
905 905
906 dat.Data = bytes; 906 dat.Data = bytes;
907 return (dat); 907 return (dat);
908 } 908 }
909 909
910 /// <summary> 910 /// <summary>
911 /// 911 ///
912 /// </summary> 912 /// </summary>
913 /// <param name="localID"></param> 913 /// <param name="localID"></param>
914 /// <param name="position"></param> 914 /// <param name="position"></param>
915 /// <param name="rotation"></param> 915 /// <param name="rotation"></param>
916 /// <returns></returns> 916 /// <returns></returns>
917 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, LLQuaternion rotation) 917 protected ImprovedTerseObjectUpdatePacket.ObjectDataBlock CreatePrimImprovedBlock(uint localID, LLVector3 position, LLQuaternion rotation)
918 { 918 {
919 uint ID = localID; 919 uint ID = localID;
920 byte[] bytes = new byte[60]; 920 byte[] bytes = new byte[60];
921 921
922 int i = 0; 922 int i = 0;
923 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock(); 923 ImprovedTerseObjectUpdatePacket.ObjectDataBlock dat = new ImprovedTerseObjectUpdatePacket.ObjectDataBlock();
924 dat.TextureEntry = new byte[0]; 924 dat.TextureEntry = new byte[0];
925 bytes[i++] = (byte)(ID % 256); 925 bytes[i++] = (byte)(ID % 256);
926 bytes[i++] = (byte)((ID >> 8) % 256); 926 bytes[i++] = (byte)((ID >> 8) % 256);
927 bytes[i++] = (byte)((ID >> 16) % 256); 927 bytes[i++] = (byte)((ID >> 16) % 256);
928 bytes[i++] = (byte)((ID >> 24) % 256); 928 bytes[i++] = (byte)((ID >> 24) % 256);
929 bytes[i++] = 0; 929 bytes[i++] = 0;
930 bytes[i++] = 0; 930 bytes[i++] = 0;
931 931
932 byte[] pb = position.GetBytes(); 932 byte[] pb = position.GetBytes();
933 Array.Copy(pb, 0, bytes, i, pb.Length); 933 Array.Copy(pb, 0, bytes, i, pb.Length);
934 i += 12; 934 i += 12;
935 ushort ac = 32767; 935 ushort ac = 32767;
936 936
937 //vel 937 //vel
938 bytes[i++] = (byte)(ac % 256); 938 bytes[i++] = (byte)(ac % 256);
939 bytes[i++] = (byte)((ac >> 8) % 256); 939 bytes[i++] = (byte)((ac >> 8) % 256);
940 bytes[i++] = (byte)(ac % 256); 940 bytes[i++] = (byte)(ac % 256);
941 bytes[i++] = (byte)((ac >> 8) % 256); 941 bytes[i++] = (byte)((ac >> 8) % 256);
942 bytes[i++] = (byte)(ac % 256); 942 bytes[i++] = (byte)(ac % 256);
943 bytes[i++] = (byte)((ac >> 8) % 256); 943 bytes[i++] = (byte)((ac >> 8) % 256);
944 944
945 //accel 945 //accel
946 bytes[i++] = (byte)(ac % 256); 946 bytes[i++] = (byte)(ac % 256);
947 bytes[i++] = (byte)((ac >> 8) % 256); 947 bytes[i++] = (byte)((ac >> 8) % 256);
948 bytes[i++] = (byte)(ac % 256); 948 bytes[i++] = (byte)(ac % 256);
949 bytes[i++] = (byte)((ac >> 8) % 256); 949 bytes[i++] = (byte)((ac >> 8) % 256);
950 bytes[i++] = (byte)(ac % 256); 950 bytes[i++] = (byte)(ac % 256);
951 bytes[i++] = (byte)((ac >> 8) % 256); 951 bytes[i++] = (byte)((ac >> 8) % 256);
952 952
953 ushort rw, rx, ry, rz; 953 ushort rw, rx, ry, rz;
954 rw = (ushort)(32768 * (rotation.W + 1)); 954 rw = (ushort)(32768 * (rotation.W + 1));
955 rx = (ushort)(32768 * (rotation.X + 1)); 955 rx = (ushort)(32768 * (rotation.X + 1));
956 ry = (ushort)(32768 * (rotation.Y + 1)); 956 ry = (ushort)(32768 * (rotation.Y + 1));
957 rz = (ushort)(32768 * (rotation.Z + 1)); 957 rz = (ushort)(32768 * (rotation.Z + 1));
958 958
959 //rot 959 //rot
960 bytes[i++] = (byte)(rx % 256); 960 bytes[i++] = (byte)(rx % 256);
961 bytes[i++] = (byte)((rx >> 8) % 256); 961 bytes[i++] = (byte)((rx >> 8) % 256);
962 bytes[i++] = (byte)(ry % 256); 962 bytes[i++] = (byte)(ry % 256);
963 bytes[i++] = (byte)((ry >> 8) % 256); 963 bytes[i++] = (byte)((ry >> 8) % 256);
964 bytes[i++] = (byte)(rz % 256); 964 bytes[i++] = (byte)(rz % 256);
965 bytes[i++] = (byte)((rz >> 8) % 256); 965 bytes[i++] = (byte)((rz >> 8) % 256);
966 bytes[i++] = (byte)(rw % 256); 966 bytes[i++] = (byte)(rw % 256);
967 bytes[i++] = (byte)((rw >> 8) % 256); 967 bytes[i++] = (byte)((rw >> 8) % 256);
968 968
969 //rotation vel 969 //rotation vel
970 bytes[i++] = (byte)(ac % 256); 970 bytes[i++] = (byte)(ac % 256);
971 bytes[i++] = (byte)((ac >> 8) % 256); 971 bytes[i++] = (byte)((ac >> 8) % 256);
972 bytes[i++] = (byte)(ac % 256); 972 bytes[i++] = (byte)(ac % 256);
973 bytes[i++] = (byte)((ac >> 8) % 256); 973 bytes[i++] = (byte)((ac >> 8) % 256);
974 bytes[i++] = (byte)(ac % 256); 974 bytes[i++] = (byte)(ac % 256);
975 bytes[i++] = (byte)((ac >> 8) % 256); 975 bytes[i++] = (byte)((ac >> 8) % 256);
976 976
977 dat.Data = bytes; 977 dat.Data = bytes;
978 return dat; 978 return dat;
979 } 979 }
980 980
981 981
982 /// <summary> 982 /// <summary>
983 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive) 983 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive)
984 /// </summary> 984 /// </summary>
985 /// <param name="primData"></param> 985 /// <param name="primData"></param>
986 /// <returns></returns> 986 /// <returns></returns>
987 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimData primData, LLUUID textureID, uint flags) 987 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimData primData, LLUUID textureID, uint flags)
988 { 988 {
989 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); 989 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
990 this.SetDefaultPrimPacketValues(objupdate); 990 this.SetDefaultPrimPacketValues(objupdate);
991 objupdate.UpdateFlags = flags; 991 objupdate.UpdateFlags = flags;
992 this.SetPrimPacketShapeData(objupdate, primData, textureID); 992 this.SetPrimPacketShapeData(objupdate, primData, textureID);
993 993
994 return objupdate; 994 return objupdate;
995 } 995 }
996 996
997 /// <summary> 997 /// <summary>
998 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive) 998 /// Create the ObjectDataBlock for a ObjectUpdatePacket (for a Primitive)
999 /// </summary> 999 /// </summary>
1000 /// <param name="primData"></param> 1000 /// <param name="primData"></param>
1001 /// <returns></returns> 1001 /// <returns></returns>
1002 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags) 1002 protected ObjectUpdatePacket.ObjectDataBlock CreatePrimUpdateBlock(PrimitiveBaseShape primShape, uint flags)
1003 { 1003 {
1004 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock(); 1004 ObjectUpdatePacket.ObjectDataBlock objupdate = new ObjectUpdatePacket.ObjectDataBlock();
1005 this.SetDefaultPrimPacketValues(objupdate); 1005 this.SetDefaultPrimPacketValues(objupdate);
1006 objupdate.UpdateFlags = flags; 1006 objupdate.UpdateFlags = flags;
1007 this.SetPrimPacketShapeData(objupdate, primShape); 1007 this.SetPrimPacketShapeData(objupdate, primShape);
1008 1008
1009 return objupdate; 1009 return objupdate;
1010 } 1010 }
1011 1011
1012 1012
1013 /// <summary> 1013 /// <summary>
1014 /// Copy the data from a PrimData object to a ObjectUpdatePacket 1014 /// Copy the data from a PrimData object to a ObjectUpdatePacket
1015 /// </summary> 1015 /// </summary>
1016 /// <param name="objectData"></param> 1016 /// <param name="objectData"></param>
1017 /// <param name="primData"></param> 1017 /// <param name="primData"></param>
1018 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimData primData, LLUUID textureID) 1018 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimData primData, LLUUID textureID)
1019 { 1019 {
1020 LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID); 1020 LLObject.TextureEntry ntex = new LLObject.TextureEntry(textureID);
1021 objectData.TextureEntry = ntex.ToBytes(); 1021 objectData.TextureEntry = ntex.ToBytes();
1022 objectData.OwnerID = primData.OwnerID; 1022 objectData.OwnerID = primData.OwnerID;
1023 objectData.ParentID = primData.ParentID; 1023 objectData.ParentID = primData.ParentID;
1024 objectData.PCode = primData.PCode; 1024 objectData.PCode = primData.PCode;
1025 objectData.PathBegin = primData.PathBegin; 1025 objectData.PathBegin = primData.PathBegin;
1026 objectData.PathEnd = primData.PathEnd; 1026 objectData.PathEnd = primData.PathEnd;
1027 objectData.PathScaleX = primData.PathScaleX; 1027 objectData.PathScaleX = primData.PathScaleX;
1028 objectData.PathScaleY = primData.PathScaleY; 1028 objectData.PathScaleY = primData.PathScaleY;
1029 objectData.PathShearX = primData.PathShearX; 1029 objectData.PathShearX = primData.PathShearX;
1030 objectData.PathShearY = primData.PathShearY; 1030 objectData.PathShearY = primData.PathShearY;
1031 objectData.PathSkew = primData.PathSkew; 1031 objectData.PathSkew = primData.PathSkew;
1032 objectData.ProfileBegin = primData.ProfileBegin; 1032 objectData.ProfileBegin = primData.ProfileBegin;
1033 objectData.ProfileEnd = primData.ProfileEnd; 1033 objectData.ProfileEnd = primData.ProfileEnd;
1034 objectData.Scale = primData.Scale; 1034 objectData.Scale = primData.Scale;
1035 objectData.PathCurve = primData.PathCurve; 1035 objectData.PathCurve = primData.PathCurve;
1036 objectData.ProfileCurve = primData.ProfileCurve; 1036 objectData.ProfileCurve = primData.ProfileCurve;
1037 objectData.ProfileHollow = primData.ProfileHollow; 1037 objectData.ProfileHollow = primData.ProfileHollow;
1038 objectData.PathRadiusOffset = primData.PathRadiusOffset; 1038 objectData.PathRadiusOffset = primData.PathRadiusOffset;
1039 objectData.PathRevolutions = primData.PathRevolutions; 1039 objectData.PathRevolutions = primData.PathRevolutions;
1040 objectData.PathTaperX = primData.PathTaperX; 1040 objectData.PathTaperX = primData.PathTaperX;
1041 objectData.PathTaperY = primData.PathTaperY; 1041 objectData.PathTaperY = primData.PathTaperY;
1042 objectData.PathTwist = primData.PathTwist; 1042 objectData.PathTwist = primData.PathTwist;
1043 objectData.PathTwistBegin = primData.PathTwistBegin; 1043 objectData.PathTwistBegin = primData.PathTwistBegin;
1044 } 1044 }
1045 1045
1046 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData) 1046 protected void SetPrimPacketShapeData(ObjectUpdatePacket.ObjectDataBlock objectData, PrimitiveBaseShape primData)
1047 { 1047 {
1048 1048
1049 objectData.TextureEntry = primData.TextureEntry; 1049 objectData.TextureEntry = primData.TextureEntry;
1050 objectData.PCode = primData.PCode; 1050 objectData.PCode = primData.PCode;
1051 objectData.PathBegin = primData.PathBegin; 1051 objectData.PathBegin = primData.PathBegin;
1052 objectData.PathEnd = primData.PathEnd; 1052 objectData.PathEnd = primData.PathEnd;
1053 objectData.PathScaleX = primData.PathScaleX; 1053 objectData.PathScaleX = primData.PathScaleX;
1054 objectData.PathScaleY = primData.PathScaleY; 1054 objectData.PathScaleY = primData.PathScaleY;
1055 objectData.PathShearX = primData.PathShearX; 1055 objectData.PathShearX = primData.PathShearX;
1056 objectData.PathShearY = primData.PathShearY; 1056 objectData.PathShearY = primData.PathShearY;
1057 objectData.PathSkew = primData.PathSkew; 1057 objectData.PathSkew = primData.PathSkew;
1058 objectData.ProfileBegin = primData.ProfileBegin; 1058 objectData.ProfileBegin = primData.ProfileBegin;
1059 objectData.ProfileEnd = primData.ProfileEnd; 1059 objectData.ProfileEnd = primData.ProfileEnd;
1060 objectData.Scale = primData.Scale; 1060 objectData.Scale = primData.Scale;
1061 objectData.PathCurve = primData.PathCurve; 1061 objectData.PathCurve = primData.PathCurve;
1062 objectData.ProfileCurve = primData.ProfileCurve; 1062 objectData.ProfileCurve = primData.ProfileCurve;
1063 objectData.ProfileHollow = primData.ProfileHollow; 1063 objectData.ProfileHollow = primData.ProfileHollow;
1064 objectData.PathRadiusOffset = primData.PathRadiusOffset; 1064 objectData.PathRadiusOffset = primData.PathRadiusOffset;
1065 objectData.PathRevolutions = primData.PathRevolutions; 1065 objectData.PathRevolutions = primData.PathRevolutions;
1066 objectData.PathTaperX = primData.PathTaperX; 1066 objectData.PathTaperX = primData.PathTaperX;
1067 objectData.PathTaperY = primData.PathTaperY; 1067 objectData.PathTaperY = primData.PathTaperY;
1068 objectData.PathTwist = primData.PathTwist; 1068 objectData.PathTwist = primData.PathTwist;
1069 objectData.PathTwistBegin = primData.PathTwistBegin; 1069 objectData.PathTwistBegin = primData.PathTwistBegin;
1070 } 1070 }
1071 1071
1072 /// <summary> 1072 /// <summary>
1073 /// Set some default values in a ObjectUpdatePacket 1073 /// Set some default values in a ObjectUpdatePacket
1074 /// </summary> 1074 /// </summary>
1075 /// <param name="objdata"></param> 1075 /// <param name="objdata"></param>
1076 protected void SetDefaultPrimPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata) 1076 protected void SetDefaultPrimPacketValues(ObjectUpdatePacket.ObjectDataBlock objdata)
1077 { 1077 {
1078 objdata.PSBlock = new byte[0]; 1078 objdata.PSBlock = new byte[0];
1079 objdata.ExtraParams = new byte[1]; 1079 objdata.ExtraParams = new byte[1];
1080 objdata.MediaURL = new byte[0]; 1080 objdata.MediaURL = new byte[0];
1081 objdata.NameValue = new byte[0]; 1081 objdata.NameValue = new byte[0];
1082 objdata.Text = new byte[0]; 1082 objdata.Text = new byte[0];
1083 objdata.TextColor = new byte[4]; 1083 objdata.TextColor = new byte[4];
1084 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); 1084 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
1085 objdata.JointPivot = new LLVector3(0, 0, 0); 1085 objdata.JointPivot = new LLVector3(0, 0, 0);
1086 objdata.Material = 3; 1086 objdata.Material = 3;
1087 objdata.TextureAnim = new byte[0]; 1087 objdata.TextureAnim = new byte[0];
1088 objdata.Sound = LLUUID.Zero; 1088 objdata.Sound = LLUUID.Zero;
1089 objdata.State = 0; 1089 objdata.State = 0;
1090 objdata.Data = new byte[0]; 1090 objdata.Data = new byte[0];
1091 1091
1092 objdata.ObjectData = new byte[60]; 1092 objdata.ObjectData = new byte[60];
1093 objdata.ObjectData[46] = 128; 1093 objdata.ObjectData[46] = 128;
1094 objdata.ObjectData[47] = 63; 1094 objdata.ObjectData[47] = 63;
1095 } 1095 }
1096 1096
1097 1097
1098 /// <summary> 1098 /// <summary>
1099 /// 1099 ///
1100 /// </summary> 1100 /// </summary>
1101 /// <returns></returns> 1101 /// <returns></returns>
1102 protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry) 1102 protected ObjectUpdatePacket.ObjectDataBlock CreateDefaultAvatarPacket(byte[] textureEntry)
1103 { 1103 {
1104 ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i); 1104 ObjectUpdatePacket.ObjectDataBlock objdata = new ObjectUpdatePacket.ObjectDataBlock(); // new libsecondlife.Packets.ObjectUpdatePacket.ObjectDataBlock(data1, ref i);
1105 1105
1106 SetDefaultAvatarPacketValues(ref objdata); 1106 SetDefaultAvatarPacketValues(ref objdata);
1107 objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24); 1107 objdata.UpdateFlags = 61 + (9 << 8) + (130 << 16) + (16 << 24);
1108 objdata.PathCurve = 16; 1108 objdata.PathCurve = 16;
1109 objdata.ProfileCurve = 1; 1109 objdata.ProfileCurve = 1;
1110 objdata.PathScaleX = 100; 1110 objdata.PathScaleX = 100;
1111 objdata.PathScaleY = 100; 1111 objdata.PathScaleY = 100;
1112 objdata.ParentID = 0; 1112 objdata.ParentID = 0;
1113 objdata.OwnerID = LLUUID.Zero; 1113 objdata.OwnerID = LLUUID.Zero;
1114 objdata.Scale = new LLVector3(1, 1, 1); 1114 objdata.Scale = new LLVector3(1, 1, 1);
1115 objdata.PCode = 47; 1115 objdata.PCode = 47;
1116 if (textureEntry != null) 1116 if (textureEntry != null)
1117 { 1117 {
1118 objdata.TextureEntry = textureEntry; 1118 objdata.TextureEntry = textureEntry;
1119 } 1119 }
1120 Encoding enc = Encoding.ASCII; 1120 Encoding enc = Encoding.ASCII;
1121 LLVector3 pos = new LLVector3(objdata.ObjectData, 16); 1121 LLVector3 pos = new LLVector3(objdata.ObjectData, 16);
1122 pos.X = 100f; 1122 pos.X = 100f;
1123 objdata.ID = 8880000; 1123 objdata.ID = 8880000;
1124 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0"); 1124 objdata.NameValue = enc.GetBytes("FirstName STRING RW SV Test \nLastName STRING RW SV User \0");
1125 LLVector3 pos2 = new LLVector3(100f, 100f, 23f); 1125 LLVector3 pos2 = new LLVector3(100f, 100f, 23f);
1126 //objdata.FullID=user.AgentID; 1126 //objdata.FullID=user.AgentID;
1127 byte[] pb = pos.GetBytes(); 1127 byte[] pb = pos.GetBytes();
1128 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length); 1128 Array.Copy(pb, 0, objdata.ObjectData, 16, pb.Length);
1129 1129
1130 return objdata; 1130 return objdata;
1131 } 1131 }
1132 1132
1133 /// <summary> 1133 /// <summary>
1134 /// 1134 ///
1135 /// </summary> 1135 /// </summary>
1136 /// <param name="objdata"></param> 1136 /// <param name="objdata"></param>
1137 protected void SetDefaultAvatarPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata) 1137 protected void SetDefaultAvatarPacketValues(ref ObjectUpdatePacket.ObjectDataBlock objdata)
1138 { 1138 {
1139 objdata.PSBlock = new byte[0]; 1139 objdata.PSBlock = new byte[0];
1140 objdata.ExtraParams = new byte[1]; 1140 objdata.ExtraParams = new byte[1];
1141 objdata.MediaURL = new byte[0]; 1141 objdata.MediaURL = new byte[0];
1142 objdata.NameValue = new byte[0]; 1142 objdata.NameValue = new byte[0];
1143 objdata.Text = new byte[0]; 1143 objdata.Text = new byte[0];
1144 objdata.TextColor = new byte[4]; 1144 objdata.TextColor = new byte[4];
1145 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0); 1145 objdata.JointAxisOrAnchor = new LLVector3(0, 0, 0);
1146 objdata.JointPivot = new LLVector3(0, 0, 0); 1146 objdata.JointPivot = new LLVector3(0, 0, 0);
1147 objdata.Material = 4; 1147 objdata.Material = 4;
1148 objdata.TextureAnim = new byte[0]; 1148 objdata.TextureAnim = new byte[0];
1149 objdata.Sound = LLUUID.Zero; 1149 objdata.Sound = LLUUID.Zero;
1150 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005")); 1150 LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-5005-000000000005"));
1151 objdata.TextureEntry = ntex.ToBytes(); 1151 objdata.TextureEntry = ntex.ToBytes();
1152 objdata.State = 0; 1152 objdata.State = 0;
1153 objdata.Data = new byte[0]; 1153 objdata.Data = new byte[0];
1154 1154
1155 objdata.ObjectData = new byte[76]; 1155 objdata.ObjectData = new byte[76];
1156 objdata.ObjectData[15] = 128; 1156 objdata.ObjectData[15] = 128;
1157 objdata.ObjectData[16] = 63; 1157 objdata.ObjectData[16] = 63;
1158 objdata.ObjectData[56] = 128; 1158 objdata.ObjectData[56] = 128;
1159 objdata.ObjectData[61] = 102; 1159 objdata.ObjectData[61] = 102;
1160 objdata.ObjectData[62] = 40; 1160 objdata.ObjectData[62] = 40;
1161 objdata.ObjectData[63] = 61; 1161 objdata.ObjectData[63] = 61;
1162 objdata.ObjectData[64] = 189; 1162 objdata.ObjectData[64] = 189;
1163 } 1163 }
1164 1164
1165 #endregion 1165 #endregion
1166 1166
1167 public void SendNameReply(LLUUID profileId, string firstname, string lastname) 1167 public void SendNameReply(LLUUID profileId, string firstname, string lastname)
1168 { 1168 {
1169 UUIDNameReplyPacket packet = new UUIDNameReplyPacket(); 1169 UUIDNameReplyPacket packet = new UUIDNameReplyPacket();
1170 1170
1171 packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1]; 1171 packet.UUIDNameBlock = new UUIDNameReplyPacket.UUIDNameBlockBlock[1];
1172 packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock(); 1172 packet.UUIDNameBlock[0] = new UUIDNameReplyPacket.UUIDNameBlockBlock();
1173 packet.UUIDNameBlock[0].ID = profileId; 1173 packet.UUIDNameBlock[0].ID = profileId;
1174 packet.UUIDNameBlock[0].FirstName = Helpers.StringToField( firstname ); 1174 packet.UUIDNameBlock[0].FirstName = Helpers.StringToField( firstname );
1175 packet.UUIDNameBlock[0].LastName = Helpers.StringToField( lastname ); 1175 packet.UUIDNameBlock[0].LastName = Helpers.StringToField( lastname );
1176 1176
1177 OutPacket( packet ); 1177 OutPacket( packet );
1178 } 1178 }
1179 } 1179 }
1180} 1180}