diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs | 596 |
1 files changed, 596 insertions, 0 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs new file mode 100644 index 0000000..3265898 --- /dev/null +++ b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs | |||
@@ -0,0 +1,596 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://www.openmetaverse.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the OpenSim Project nor the | ||
13 | * names of its contributors may be used to endorse or promote products | ||
14 | * derived from this software without specific prior written permission. | ||
15 | * | ||
16 | * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS AND ANY | ||
17 | * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
18 | * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
19 | * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY | ||
20 | * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
21 | * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
22 | * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | ||
23 | * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
24 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
25 | * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
26 | * | ||
27 | */ | ||
28 | using System; | ||
29 | using System.Collections.Generic; | ||
30 | using System.Text; | ||
31 | using libsecondlife; | ||
32 | using libsecondlife.Packets; | ||
33 | using OpenSim.Framework.Inventory; | ||
34 | using OpenSim.Framework.Types; | ||
35 | using OpenSim.Framework.Utilities; | ||
36 | |||
37 | namespace OpenSim.Region.ClientStack | ||
38 | { | ||
39 | public partial class ClientView | ||
40 | { | ||
41 | protected override void ProcessInPacket(Packet Pack) | ||
42 | { | ||
43 | ack_pack(Pack); | ||
44 | if (debug) | ||
45 | { | ||
46 | if (Pack.Type != PacketType.AgentUpdate) | ||
47 | { | ||
48 | Console.WriteLine(CircuitCode + ":IN: " + Pack.Type.ToString()); | ||
49 | } | ||
50 | } | ||
51 | |||
52 | if (this.ProcessPacketMethod(Pack)) | ||
53 | { | ||
54 | //there is a handler registered that handled this packet type | ||
55 | return; | ||
56 | } | ||
57 | else | ||
58 | { | ||
59 | Encoding _enc = Encoding.ASCII; | ||
60 | |||
61 | switch (Pack.Type) | ||
62 | { | ||
63 | case PacketType.ViewerEffect: | ||
64 | ViewerEffectPacket viewer = (ViewerEffectPacket)Pack; | ||
65 | foreach (ClientView client in m_clientThreads.Values) | ||
66 | { | ||
67 | if (client.AgentID != this.AgentID) | ||
68 | { | ||
69 | viewer.AgentData.AgentID = client.AgentID; | ||
70 | viewer.AgentData.SessionID = client.SessionID; | ||
71 | client.OutPacket(viewer); | ||
72 | } | ||
73 | } | ||
74 | break; | ||
75 | |||
76 | #region World/Avatar | ||
77 | case PacketType.ChatFromViewer: | ||
78 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket)Pack; | ||
79 | if (Util.FieldToString(inchatpack.ChatData.Message) == "") | ||
80 | { | ||
81 | //empty message so don't bother with it | ||
82 | break; | ||
83 | } | ||
84 | string fromName = ""; //ClientAvatar.firstname + " " + ClientAvatar.lastname; | ||
85 | byte[] message = inchatpack.ChatData.Message; | ||
86 | byte type = inchatpack.ChatData.Type; | ||
87 | LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos; | ||
88 | LLUUID fromAgentID = AgentID; | ||
89 | if (OnChatFromViewer != null) | ||
90 | { | ||
91 | this.OnChatFromViewer(message, type, fromPos, fromName, fromAgentID); | ||
92 | } | ||
93 | break; | ||
94 | case PacketType.ImprovedInstantMessage: | ||
95 | ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket)Pack; | ||
96 | |||
97 | string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); | ||
98 | string IMmessage = Util.FieldToString(msgpack.MessageBlock.Message); | ||
99 | |||
100 | if (OnInstantMessage != null) | ||
101 | { | ||
102 | this.OnInstantMessage(msgpack.AgentData.AgentID, msgpack.MessageBlock.ToAgentID, | ||
103 | msgpack.MessageBlock.Timestamp, IMfromName, IMmessage); | ||
104 | } | ||
105 | |||
106 | break; | ||
107 | |||
108 | case PacketType.RezObject: | ||
109 | RezObjectPacket rezPacket = (RezObjectPacket)Pack; | ||
110 | AgentInventory inven = this.m_inventoryCache.GetAgentsInventory(this.AgentID); | ||
111 | if (inven != null) | ||
112 | { | ||
113 | if (inven.InventoryItems.ContainsKey(rezPacket.InventoryData.ItemID)) | ||
114 | { | ||
115 | AssetBase asset = this.m_assetCache.GetAsset(inven.InventoryItems[rezPacket.InventoryData.ItemID].AssetID); | ||
116 | if (asset != null) | ||
117 | { | ||
118 | if (OnRezObject != null) | ||
119 | { | ||
120 | this.OnRezObject(asset, rezPacket.RezData.RayEnd); | ||
121 | this.m_inventoryCache.DeleteInventoryItem(this, rezPacket.InventoryData.ItemID); | ||
122 | } | ||
123 | } | ||
124 | } | ||
125 | } | ||
126 | break; | ||
127 | case PacketType.DeRezObject: | ||
128 | if (OnDeRezObject != null) | ||
129 | { | ||
130 | OnDeRezObject(Pack, this); | ||
131 | } | ||
132 | break; | ||
133 | case PacketType.ModifyLand: | ||
134 | ModifyLandPacket modify = (ModifyLandPacket)Pack; | ||
135 | if (modify.ParcelData.Length > 0) | ||
136 | { | ||
137 | if (OnModifyTerrain != null) | ||
138 | { | ||
139 | OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, modify.ModifyBlock.BrushSize, | ||
140 | modify.ModifyBlock.Action, modify.ParcelData[0].North, modify.ParcelData[0].West); | ||
141 | } | ||
142 | } | ||
143 | break; | ||
144 | case PacketType.RegionHandshakeReply: | ||
145 | if (OnRegionHandShakeReply != null) | ||
146 | { | ||
147 | OnRegionHandShakeReply(this); | ||
148 | } | ||
149 | break; | ||
150 | case PacketType.AgentWearablesRequest: | ||
151 | if (OnRequestWearables != null) | ||
152 | { | ||
153 | OnRequestWearables(this); | ||
154 | } | ||
155 | if (OnRequestAvatarsData != null) | ||
156 | { | ||
157 | OnRequestAvatarsData(this); | ||
158 | } | ||
159 | break; | ||
160 | case PacketType.AgentSetAppearance: | ||
161 | AgentSetAppearancePacket appear = (AgentSetAppearancePacket)Pack; | ||
162 | if (OnSetAppearance != null) | ||
163 | { | ||
164 | OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam); | ||
165 | } | ||
166 | break; | ||
167 | case PacketType.CompleteAgentMovement: | ||
168 | if (OnCompleteMovementToRegion != null) | ||
169 | { | ||
170 | OnCompleteMovementToRegion(); | ||
171 | } | ||
172 | break; | ||
173 | case PacketType.AgentUpdate: | ||
174 | if (OnAgentUpdate != null) | ||
175 | { | ||
176 | AgentUpdatePacket agenUpdate = (AgentUpdatePacket)Pack; | ||
177 | OnAgentUpdate(this, agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotation); | ||
178 | } | ||
179 | break; | ||
180 | case PacketType.AgentAnimation: | ||
181 | if (!m_child) | ||
182 | { | ||
183 | AgentAnimationPacket AgentAni = (AgentAnimationPacket)Pack; | ||
184 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) | ||
185 | { | ||
186 | if (AgentAni.AnimationList[i].StartAnim) | ||
187 | { | ||
188 | if (OnStartAnim != null) | ||
189 | { | ||
190 | OnStartAnim(AgentAni.AnimationList[i].AnimID, 1); | ||
191 | } | ||
192 | } | ||
193 | } | ||
194 | } | ||
195 | break; | ||
196 | |||
197 | #endregion | ||
198 | |||
199 | #region Objects/Prims | ||
200 | case PacketType.ObjectLink: | ||
201 | // OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); | ||
202 | ObjectLinkPacket link = (ObjectLinkPacket)Pack; | ||
203 | uint parentprimid = 0; | ||
204 | List<uint> childrenprims = new List<uint>(); | ||
205 | if (link.ObjectData.Length > 1) | ||
206 | { | ||
207 | parentprimid = link.ObjectData[0].ObjectLocalID; | ||
208 | |||
209 | for (int i = 1; i < link.ObjectData.Length; i++) | ||
210 | { | ||
211 | childrenprims.Add(link.ObjectData[i].ObjectLocalID); | ||
212 | } | ||
213 | } | ||
214 | if (OnLinkObjects != null) | ||
215 | { | ||
216 | OnLinkObjects(parentprimid, childrenprims); | ||
217 | } | ||
218 | break; | ||
219 | case PacketType.ObjectAdd: | ||
220 | if (OnAddPrim != null) | ||
221 | { | ||
222 | OnAddPrim(Pack, this); | ||
223 | } | ||
224 | break; | ||
225 | case PacketType.ObjectShape: | ||
226 | ObjectShapePacket shape = (ObjectShapePacket)Pack; | ||
227 | for (int i = 0; i < shape.ObjectData.Length; i++) | ||
228 | { | ||
229 | if (OnUpdatePrimShape != null) | ||
230 | { | ||
231 | OnUpdatePrimShape(shape.ObjectData[i].ObjectLocalID, shape.ObjectData[i]); | ||
232 | } | ||
233 | } | ||
234 | break; | ||
235 | case PacketType.ObjectDuplicate: | ||
236 | ObjectDuplicatePacket dupe = (ObjectDuplicatePacket)Pack; | ||
237 | for (int i = 0; i < dupe.ObjectData.Length; i++) | ||
238 | { | ||
239 | if (OnObjectDuplicate != null) | ||
240 | { | ||
241 | OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, dupe.SharedData.DuplicateFlags); | ||
242 | } | ||
243 | } | ||
244 | |||
245 | break; | ||
246 | |||
247 | case PacketType.ObjectSelect: | ||
248 | ObjectSelectPacket incomingselect = (ObjectSelectPacket)Pack; | ||
249 | for (int i = 0; i < incomingselect.ObjectData.Length; i++) | ||
250 | { | ||
251 | if (OnObjectSelect != null) | ||
252 | { | ||
253 | OnObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this); | ||
254 | } | ||
255 | } | ||
256 | break; | ||
257 | case PacketType.ObjectFlagUpdate: | ||
258 | ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket)Pack; | ||
259 | if (OnUpdatePrimFlags != null) | ||
260 | { | ||
261 | OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this); | ||
262 | } | ||
263 | break; | ||
264 | case PacketType.ObjectImage: | ||
265 | ObjectImagePacket imagePack = (ObjectImagePacket)Pack; | ||
266 | for (int i = 0; i < imagePack.ObjectData.Length; i++) | ||
267 | { | ||
268 | if (OnUpdatePrimTexture != null) | ||
269 | { | ||
270 | OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, imagePack.ObjectData[i].TextureEntry, this); | ||
271 | } | ||
272 | } | ||
273 | break; | ||
274 | case PacketType.ObjectGrab: | ||
275 | ObjectGrabPacket grap = (ObjectGrabPacket)Pack; | ||
276 | if (OnGrapObject != null) | ||
277 | { | ||
278 | OnGrapObject(grap.ObjectData.LocalID, grap.ObjectData.GrabOffset, this); | ||
279 | } | ||
280 | break; | ||
281 | case PacketType.ObjectGrabUpdate: | ||
282 | ObjectGrabUpdatePacket grapUpdate = (ObjectGrabUpdatePacket)Pack; | ||
283 | if (OnGrapUpdate != null) | ||
284 | { | ||
285 | OnGrapUpdate(grapUpdate.ObjectData.ObjectID, grapUpdate.ObjectData.GrabOffsetInitial, grapUpdate.ObjectData.GrabPosition, this); | ||
286 | } | ||
287 | break; | ||
288 | case PacketType.ObjectDeGrab: | ||
289 | ObjectDeGrabPacket deGrap = (ObjectDeGrabPacket)Pack; | ||
290 | if (OnDeGrapObject != null) | ||
291 | { | ||
292 | OnDeGrapObject(deGrap.ObjectData.LocalID, this); | ||
293 | } | ||
294 | break; | ||
295 | case PacketType.ObjectDescription: | ||
296 | ObjectDescriptionPacket objDes = (ObjectDescriptionPacket)Pack; | ||
297 | for (int i = 0; i < objDes.ObjectData.Length; i++) | ||
298 | { | ||
299 | if (OnObjectDescription != null) | ||
300 | { | ||
301 | OnObjectDescription(objDes.ObjectData[i].LocalID, enc.GetString(objDes.ObjectData[i].Description)); | ||
302 | } | ||
303 | } | ||
304 | break; | ||
305 | case PacketType.ObjectName: | ||
306 | ObjectNamePacket objName = (ObjectNamePacket)Pack; | ||
307 | for (int i = 0; i < objName.ObjectData.Length; i++) | ||
308 | { | ||
309 | if (OnObjectName != null) | ||
310 | { | ||
311 | OnObjectName(objName.ObjectData[i].LocalID, enc.GetString(objName.ObjectData[i].Name)); | ||
312 | } | ||
313 | } | ||
314 | break; | ||
315 | case PacketType.ObjectPermissions: | ||
316 | //Console.WriteLine("permissions set " + Pack.ToString()); | ||
317 | break; | ||
318 | #endregion | ||
319 | |||
320 | #region Inventory/Asset/Other related packets | ||
321 | case PacketType.RequestImage: | ||
322 | RequestImagePacket imageRequest = (RequestImagePacket)Pack; | ||
323 | for (int i = 0; i < imageRequest.RequestImage.Length; i++) | ||
324 | { | ||
325 | m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image); | ||
326 | } | ||
327 | break; | ||
328 | case PacketType.TransferRequest: | ||
329 | //Console.WriteLine("OpenSimClient.cs:ProcessInPacket() - Got transfer request"); | ||
330 | TransferRequestPacket transfer = (TransferRequestPacket)Pack; | ||
331 | m_assetCache.AddAssetRequest(this, transfer); | ||
332 | break; | ||
333 | case PacketType.AssetUploadRequest: | ||
334 | AssetUploadRequestPacket request = (AssetUploadRequestPacket)Pack; | ||
335 | this.UploadAssets.HandleUploadPacket(request, request.AssetBlock.TransactionID.Combine(this.SecureSessionID)); | ||
336 | break; | ||
337 | case PacketType.RequestXfer: | ||
338 | //Console.WriteLine(Pack.ToString()); | ||
339 | break; | ||
340 | case PacketType.SendXferPacket: | ||
341 | this.UploadAssets.HandleXferPacket((SendXferPacketPacket)Pack); | ||
342 | break; | ||
343 | case PacketType.CreateInventoryFolder: | ||
344 | CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket)Pack; | ||
345 | m_inventoryCache.CreateNewInventoryFolder(this, invFolder.FolderData.FolderID, (ushort)invFolder.FolderData.Type, Util.FieldToString(invFolder.FolderData.Name), invFolder.FolderData.ParentID); | ||
346 | //Console.WriteLine(Pack.ToString()); | ||
347 | break; | ||
348 | case PacketType.CreateInventoryItem: | ||
349 | //Console.WriteLine(Pack.ToString()); | ||
350 | CreateInventoryItemPacket createItem = (CreateInventoryItemPacket)Pack; | ||
351 | if (createItem.InventoryBlock.TransactionID != LLUUID.Zero) | ||
352 | { | ||
353 | this.UploadAssets.CreateInventoryItem(createItem); | ||
354 | } | ||
355 | else | ||
356 | { | ||
357 | // Console.Write(Pack.ToString()); | ||
358 | this.CreateInventoryItem(createItem); | ||
359 | } | ||
360 | break; | ||
361 | case PacketType.FetchInventory: | ||
362 | //Console.WriteLine("fetch item packet"); | ||
363 | FetchInventoryPacket FetchInventory = (FetchInventoryPacket)Pack; | ||
364 | m_inventoryCache.FetchInventory(this, FetchInventory); | ||
365 | break; | ||
366 | case PacketType.FetchInventoryDescendents: | ||
367 | FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket)Pack; | ||
368 | m_inventoryCache.FetchInventoryDescendents(this, Fetch); | ||
369 | break; | ||
370 | case PacketType.UpdateInventoryItem: | ||
371 | UpdateInventoryItemPacket update = (UpdateInventoryItemPacket)Pack; | ||
372 | //Console.WriteLine(Pack.ToString()); | ||
373 | for (int i = 0; i < update.InventoryData.Length; i++) | ||
374 | { | ||
375 | if (update.InventoryData[i].TransactionID != LLUUID.Zero) | ||
376 | { | ||
377 | AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); | ||
378 | if (asset != null) | ||
379 | { | ||
380 | // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); | ||
381 | m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); | ||
382 | } | ||
383 | else | ||
384 | { | ||
385 | asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); | ||
386 | if (asset != null) | ||
387 | { | ||
388 | //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache"); | ||
389 | m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); | ||
390 | } | ||
391 | else | ||
392 | { | ||
393 | //Console.WriteLine("trying to update inventory item, but asset is null"); | ||
394 | } | ||
395 | } | ||
396 | } | ||
397 | else | ||
398 | { | ||
399 | m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ; | ||
400 | } | ||
401 | } | ||
402 | break; | ||
403 | case PacketType.RequestTaskInventory: | ||
404 | // Console.WriteLine(Pack.ToString()); | ||
405 | RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket)Pack; | ||
406 | ReplyTaskInventoryPacket replytask = new ReplyTaskInventoryPacket(); | ||
407 | //bool foundent = false; | ||
408 | /* foreach (Entity ent in m_world.Entities.Values) | ||
409 | { | ||
410 | if (ent.localid == requesttask.InventoryData.LocalID) | ||
411 | { | ||
412 | replytask.InventoryData.TaskID = ent.uuid; | ||
413 | replytask.InventoryData.Serial = 0; | ||
414 | replytask.InventoryData.Filename = new byte[0]; | ||
415 | foundent = true; | ||
416 | } | ||
417 | } | ||
418 | if (foundent) | ||
419 | { | ||
420 | this.OutPacket(replytask); | ||
421 | }*/ | ||
422 | break; | ||
423 | case PacketType.UpdateTaskInventory: | ||
424 | // Console.WriteLine(Pack.ToString()); | ||
425 | UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket)Pack; | ||
426 | AgentInventory myinventory = this.m_inventoryCache.GetAgentsInventory(this.AgentID); | ||
427 | /*if (myinventory != null) | ||
428 | { | ||
429 | if (updatetask.UpdateData.Key == 0) | ||
430 | { | ||
431 | if (myinventory.InventoryItems[updatetask.InventoryData.ItemID] != null) | ||
432 | { | ||
433 | if (myinventory.InventoryItems[updatetask.InventoryData.ItemID].Type == 7) | ||
434 | { | ||
435 | LLUUID noteaid = myinventory.InventoryItems[updatetask.InventoryData.ItemID].AssetID; | ||
436 | AssetBase assBase = this.m_assetCache.GetAsset(noteaid); | ||
437 | if (assBase != null) | ||
438 | { | ||
439 | foreach (Entity ent in m_world.Entities.Values) | ||
440 | { | ||
441 | if (ent.localid == updatetask.UpdateData.LocalID) | ||
442 | { | ||
443 | if (ent is OpenSim.world.Primitive) | ||
444 | { | ||
445 | this.m_world.AddScript(ent, Util.FieldToString(assBase.Data)); | ||
446 | } | ||
447 | } | ||
448 | } | ||
449 | } | ||
450 | } | ||
451 | } | ||
452 | } | ||
453 | }*/ | ||
454 | break; | ||
455 | case PacketType.MapLayerRequest: | ||
456 | this.RequestMapLayer(); | ||
457 | break; | ||
458 | case PacketType.MapBlockRequest: | ||
459 | MapBlockRequestPacket MapRequest = (MapBlockRequestPacket)Pack; | ||
460 | if (OnRequestMapBlocks != null) | ||
461 | { | ||
462 | OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); | ||
463 | } | ||
464 | break; | ||
465 | case PacketType.TeleportLandmarkRequest: | ||
466 | TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket)Pack; | ||
467 | |||
468 | TeleportStartPacket tpStart = new TeleportStartPacket(); | ||
469 | tpStart.Info.TeleportFlags = 8; // tp via lm | ||
470 | this.OutPacket(tpStart); | ||
471 | |||
472 | TeleportProgressPacket tpProgress = new TeleportProgressPacket(); | ||
473 | tpProgress.Info.Message = (new ASCIIEncoding()).GetBytes("sending_landmark"); | ||
474 | tpProgress.Info.TeleportFlags = 8; | ||
475 | tpProgress.AgentData.AgentID = tpReq.Info.AgentID; | ||
476 | this.OutPacket(tpProgress); | ||
477 | |||
478 | // Fetch landmark | ||
479 | LLUUID lmid = tpReq.Info.LandmarkID; | ||
480 | AssetBase lma = this.m_assetCache.GetAsset(lmid); | ||
481 | if (lma != null) | ||
482 | { | ||
483 | AssetLandmark lm = new AssetLandmark(lma); | ||
484 | |||
485 | if (lm.RegionID == m_world.RegionInfo.SimUUID) | ||
486 | { | ||
487 | TeleportLocalPacket tpLocal = new TeleportLocalPacket(); | ||
488 | |||
489 | tpLocal.Info.AgentID = tpReq.Info.AgentID; | ||
490 | tpLocal.Info.TeleportFlags = 8; // Teleport via landmark | ||
491 | tpLocal.Info.LocationID = 2; | ||
492 | tpLocal.Info.Position = lm.Position; | ||
493 | OutPacket(tpLocal); | ||
494 | } | ||
495 | else | ||
496 | { | ||
497 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | ||
498 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | ||
499 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | ||
500 | OutPacket(tpCancel); | ||
501 | } | ||
502 | } | ||
503 | else | ||
504 | { | ||
505 | Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented"); | ||
506 | |||
507 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | ||
508 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | ||
509 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | ||
510 | OutPacket(tpCancel); | ||
511 | } | ||
512 | break; | ||
513 | case PacketType.TeleportLocationRequest: | ||
514 | TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket)Pack; | ||
515 | // Console.WriteLine(tpLocReq.ToString()); | ||
516 | |||
517 | if (OnTeleportLocationRequest != null) | ||
518 | { | ||
519 | OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, tpLocReq.Info.LookAt, 16); | ||
520 | } | ||
521 | else | ||
522 | { | ||
523 | //no event handler so cancel request | ||
524 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | ||
525 | tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; | ||
526 | tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; | ||
527 | OutPacket(tpCancel); | ||
528 | } | ||
529 | break; | ||
530 | #endregion | ||
531 | |||
532 | case PacketType.MoneyBalanceRequest: | ||
533 | this.SendMoneyBalance(LLUUID.Zero, true, new byte[0], 1000); | ||
534 | break; | ||
535 | case PacketType.UUIDNameRequest: | ||
536 | UUIDNameRequestPacket incoming = (UUIDNameRequestPacket)Pack; | ||
537 | foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) | ||
538 | { | ||
539 | OnNameFromUUIDRequest(UUIDBlock.ID, this); | ||
540 | } | ||
541 | break; | ||
542 | #region Parcel related packets | ||
543 | case PacketType.ParcelPropertiesRequest: | ||
544 | ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket)Pack; | ||
545 | if (OnParcelPropertiesRequest != null) | ||
546 | { | ||
547 | OnParcelPropertiesRequest((int)Math.Round(propertiesRequest.ParcelData.West), (int)Math.Round(propertiesRequest.ParcelData.South), (int)Math.Round(propertiesRequest.ParcelData.East), (int)Math.Round(propertiesRequest.ParcelData.North), propertiesRequest.ParcelData.SequenceID, propertiesRequest.ParcelData.SnapSelection, this); | ||
548 | } | ||
549 | break; | ||
550 | case PacketType.ParcelDivide: | ||
551 | ParcelDividePacket parcelDivide = (ParcelDividePacket)Pack; | ||
552 | if (OnParcelDivideRequest != null) | ||
553 | { | ||
554 | OnParcelDivideRequest((int)Math.Round(parcelDivide.ParcelData.West), (int)Math.Round(parcelDivide.ParcelData.South), (int)Math.Round(parcelDivide.ParcelData.East), (int)Math.Round(parcelDivide.ParcelData.North), this); | ||
555 | } | ||
556 | break; | ||
557 | case PacketType.ParcelJoin: | ||
558 | ParcelJoinPacket parcelJoin = (ParcelJoinPacket)Pack; | ||
559 | if (OnParcelJoinRequest != null) | ||
560 | { | ||
561 | OnParcelJoinRequest((int)Math.Round(parcelJoin.ParcelData.West), (int)Math.Round(parcelJoin.ParcelData.South), (int)Math.Round(parcelJoin.ParcelData.East), (int)Math.Round(parcelJoin.ParcelData.North), this); | ||
562 | } | ||
563 | break; | ||
564 | case PacketType.ParcelPropertiesUpdate: | ||
565 | ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket)Pack; | ||
566 | if (OnParcelPropertiesUpdateRequest != null) | ||
567 | { | ||
568 | OnParcelPropertiesUpdateRequest(updatePacket, this); | ||
569 | } | ||
570 | break; | ||
571 | #endregion | ||
572 | |||
573 | #region Estate Packets | ||
574 | case PacketType.EstateOwnerMessage: | ||
575 | EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket)Pack; | ||
576 | if (OnEstateOwnerMessage != null) | ||
577 | { | ||
578 | OnEstateOwnerMessage(messagePacket, this); | ||
579 | } | ||
580 | break; | ||
581 | #endregion | ||
582 | |||
583 | #region unimplemented handlers | ||
584 | case PacketType.AgentIsNowWearing: | ||
585 | // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; | ||
586 | //Console.WriteLine(Pack.ToString()); | ||
587 | break; | ||
588 | case PacketType.ObjectScale: | ||
589 | //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); | ||
590 | break; | ||
591 | #endregion | ||
592 | } | ||
593 | } | ||
594 | } | ||
595 | } | ||
596 | } | ||