diff options
Diffstat (limited to 'OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs')
-rw-r--r-- | OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs | 1173 |
1 files changed, 0 insertions, 1173 deletions
diff --git a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs b/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs deleted file mode 100644 index f720277..0000000 --- a/OpenSim/Region/ClientStack/ClientView.ProcessPackets.cs +++ /dev/null | |||
@@ -1,1173 +0,0 @@ | |||
1 | /* | ||
2 | * Copyright (c) Contributors, http://opensimulator.org/ | ||
3 | * See CONTRIBUTORS.TXT for a full list of copyright holders. | ||
4 | * | ||
5 | * Redistribution and use in source and binary forms, with or without | ||
6 | * modification, are permitted provided that the following conditions are met: | ||
7 | * * Redistributions of source code must retain the above copyright | ||
8 | * notice, this list of conditions and the following disclaimer. | ||
9 | * * Redistributions in binary form must reproduce the above copyright | ||
10 | * notice, this list of conditions and the following disclaimer in the | ||
11 | * documentation and/or other materials provided with the distribution. | ||
12 | * * Neither the name of the 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; | ||
34 | |||
35 | namespace OpenSim.Region.ClientStack | ||
36 | { | ||
37 | public partial class ClientView | ||
38 | { | ||
39 | private int m_moneyBalance; | ||
40 | |||
41 | public int MoneyBalance | ||
42 | { | ||
43 | get { return m_moneyBalance; } | ||
44 | } | ||
45 | |||
46 | public bool AddMoney(int debit) | ||
47 | { | ||
48 | if (m_moneyBalance + debit >= 0) | ||
49 | { | ||
50 | m_moneyBalance += debit; | ||
51 | SendMoneyBalance(LLUUID.Zero, true, Helpers.StringToField("Poof Poof!"), m_moneyBalance); | ||
52 | return true; | ||
53 | } | ||
54 | else | ||
55 | { | ||
56 | return false; | ||
57 | } | ||
58 | } | ||
59 | |||
60 | protected void ProcessInPacket(Packet Pack) | ||
61 | { | ||
62 | ack_pack(Pack); | ||
63 | |||
64 | if (ProcessPacketMethod(Pack)) | ||
65 | { | ||
66 | //there is a handler registered that handled this packet type | ||
67 | return; | ||
68 | } | ||
69 | else | ||
70 | { | ||
71 | Encoding _enc = Encoding.ASCII; | ||
72 | |||
73 | switch (Pack.Type) | ||
74 | { | ||
75 | #region Scene/Avatar | ||
76 | |||
77 | case PacketType.AvatarPropertiesRequest: | ||
78 | AvatarPropertiesRequestPacket avatarProperties = (AvatarPropertiesRequestPacket) Pack; | ||
79 | if (OnRequestAvatarProperties != null) | ||
80 | { | ||
81 | OnRequestAvatarProperties(this, avatarProperties.AgentData.AvatarID); | ||
82 | } | ||
83 | break; | ||
84 | case PacketType.ChatFromViewer: | ||
85 | ChatFromViewerPacket inchatpack = (ChatFromViewerPacket) Pack; | ||
86 | |||
87 | string fromName = ""; //ClientAvatar.firstname + " " + ClientAvatar.lastname; | ||
88 | byte[] message = inchatpack.ChatData.Message; | ||
89 | byte type = inchatpack.ChatData.Type; | ||
90 | LLVector3 fromPos = new LLVector3(); // ClientAvatar.Pos; | ||
91 | LLUUID fromAgentID = AgentId; | ||
92 | |||
93 | int channel = inchatpack.ChatData.Channel; | ||
94 | |||
95 | if (OnChatFromViewer != null) | ||
96 | { | ||
97 | ChatFromViewerArgs args = new ChatFromViewerArgs(); | ||
98 | args.Channel = channel; | ||
99 | args.From = fromName; | ||
100 | args.Message = Helpers.FieldToUTF8String(message); | ||
101 | args.Type = (ChatTypeEnum) type; | ||
102 | args.Position = fromPos; | ||
103 | |||
104 | args.Scene = Scene; | ||
105 | args.Sender = this; | ||
106 | |||
107 | OnChatFromViewer(this, args); | ||
108 | } | ||
109 | break; | ||
110 | case PacketType.ImprovedInstantMessage: | ||
111 | ImprovedInstantMessagePacket msgpack = (ImprovedInstantMessagePacket) Pack; | ||
112 | string IMfromName = Util.FieldToString(msgpack.MessageBlock.FromAgentName); | ||
113 | string IMmessage = Helpers.FieldToUTF8String(msgpack.MessageBlock.Message); | ||
114 | if (OnInstantMessage != null) | ||
115 | { | ||
116 | OnInstantMessage(msgpack.AgentData.AgentID, msgpack.AgentData.SessionID, | ||
117 | msgpack.MessageBlock.ToAgentID, msgpack.MessageBlock.ID, | ||
118 | msgpack.MessageBlock.Timestamp, IMfromName, IMmessage, | ||
119 | msgpack.MessageBlock.Dialog); | ||
120 | } | ||
121 | break; | ||
122 | case PacketType.RezObject: | ||
123 | RezObjectPacket rezPacket = (RezObjectPacket) Pack; | ||
124 | if (OnRezObject != null) | ||
125 | { | ||
126 | OnRezObject(this, rezPacket.InventoryData.ItemID, rezPacket.RezData.RayEnd); | ||
127 | } | ||
128 | break; | ||
129 | case PacketType.DeRezObject: | ||
130 | if (OnDeRezObject != null) | ||
131 | { | ||
132 | OnDeRezObject(Pack, this); | ||
133 | } | ||
134 | break; | ||
135 | case PacketType.ModifyLand: | ||
136 | ModifyLandPacket modify = (ModifyLandPacket) Pack; | ||
137 | if (modify.ParcelData.Length > 0) | ||
138 | { | ||
139 | if (OnModifyTerrain != null) | ||
140 | { | ||
141 | OnModifyTerrain(modify.ModifyBlock.Height, modify.ModifyBlock.Seconds, | ||
142 | modify.ModifyBlock.BrushSize, | ||
143 | modify.ModifyBlock.Action, modify.ParcelData[0].North, | ||
144 | modify.ParcelData[0].West, this); | ||
145 | } | ||
146 | } | ||
147 | break; | ||
148 | case PacketType.RegionHandshakeReply: | ||
149 | if (OnRegionHandShakeReply != null) | ||
150 | { | ||
151 | OnRegionHandShakeReply(this); | ||
152 | } | ||
153 | break; | ||
154 | case PacketType.AgentWearablesRequest: | ||
155 | if (OnRequestWearables != null) | ||
156 | { | ||
157 | OnRequestWearables( ); | ||
158 | } | ||
159 | if (OnRequestAvatarsData != null) | ||
160 | { | ||
161 | OnRequestAvatarsData(this); | ||
162 | } | ||
163 | break; | ||
164 | case PacketType.AgentSetAppearance: | ||
165 | //OpenSim.Framework.Console.MainLog.Instance.Verbose("set appear", Pack.ToString()); | ||
166 | AgentSetAppearancePacket appear = (AgentSetAppearancePacket) Pack; | ||
167 | if (OnSetAppearance != null) | ||
168 | { | ||
169 | OnSetAppearance(appear.ObjectData.TextureEntry, appear.VisualParam); | ||
170 | } | ||
171 | break; | ||
172 | case PacketType.SetAlwaysRun: | ||
173 | SetAlwaysRunPacket run = (SetAlwaysRunPacket)Pack; | ||
174 | |||
175 | if (OnSetAlwaysRun != null) | ||
176 | OnSetAlwaysRun(this,run.AgentData.AlwaysRun); | ||
177 | |||
178 | break; | ||
179 | case PacketType.CompleteAgentMovement: | ||
180 | if (OnCompleteMovementToRegion != null) | ||
181 | { | ||
182 | OnCompleteMovementToRegion(); | ||
183 | } | ||
184 | break; | ||
185 | case PacketType.AgentUpdate: | ||
186 | if (OnAgentUpdate != null) | ||
187 | { | ||
188 | AgentUpdatePacket agenUpdate = (AgentUpdatePacket) Pack; | ||
189 | |||
190 | OnAgentUpdate(this, agenUpdate); //agenUpdate.AgentData.ControlFlags, agenUpdate.AgentData.BodyRotationa); | ||
191 | } | ||
192 | break; | ||
193 | case PacketType.AgentAnimation: | ||
194 | AgentAnimationPacket AgentAni = (AgentAnimationPacket) Pack; | ||
195 | for (int i = 0; i < AgentAni.AnimationList.Length; i++) | ||
196 | { | ||
197 | if (AgentAni.AnimationList[i].StartAnim) | ||
198 | { | ||
199 | if (OnStartAnim != null) | ||
200 | { | ||
201 | OnStartAnim(this, AgentAni.AnimationList[i].AnimID, 1); | ||
202 | } | ||
203 | } | ||
204 | } | ||
205 | break; | ||
206 | case PacketType.AgentRequestSit: | ||
207 | if (OnAgentRequestSit != null) | ||
208 | { | ||
209 | AgentRequestSitPacket agentRequestSit = (AgentRequestSitPacket) Pack; | ||
210 | OnAgentRequestSit(this, agentRequestSit.AgentData.AgentID, | ||
211 | agentRequestSit.TargetObject.TargetID, agentRequestSit.TargetObject.Offset); | ||
212 | } | ||
213 | break; | ||
214 | case PacketType.AgentSit: | ||
215 | if (OnAgentSit != null) | ||
216 | { | ||
217 | AgentSitPacket agentSit = (AgentSitPacket) Pack; | ||
218 | OnAgentSit(this, agentSit.AgentData.AgentID); | ||
219 | } | ||
220 | break; | ||
221 | case PacketType.AvatarPickerRequest: | ||
222 | AvatarPickerRequestPacket avRequestQuery = (AvatarPickerRequestPacket)Pack; | ||
223 | AvatarPickerRequestPacket.AgentDataBlock Requestdata = avRequestQuery.AgentData; | ||
224 | AvatarPickerRequestPacket.DataBlock querydata = avRequestQuery.Data; | ||
225 | //System.Console.WriteLine("Agent Sends:" + Helpers.FieldToUTF8String(querydata.Name)); | ||
226 | if (OnAvatarPickerRequest != null) | ||
227 | { | ||
228 | OnAvatarPickerRequest(this, Requestdata.AgentID, Requestdata.QueryID, Helpers.FieldToUTF8String(querydata.Name)); | ||
229 | } | ||
230 | break; | ||
231 | #endregion | ||
232 | |||
233 | #region Objects/m_sceneObjects | ||
234 | |||
235 | case PacketType.ObjectLink: | ||
236 | //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); | ||
237 | ObjectLinkPacket link = (ObjectLinkPacket) Pack; | ||
238 | uint parentprimid = 0; | ||
239 | List<uint> childrenprims = new List<uint>(); | ||
240 | if (link.ObjectData.Length > 1) | ||
241 | { | ||
242 | parentprimid = link.ObjectData[0].ObjectLocalID; | ||
243 | |||
244 | for (int i = 1; i < link.ObjectData.Length; i++) | ||
245 | { | ||
246 | childrenprims.Add(link.ObjectData[i].ObjectLocalID); | ||
247 | } | ||
248 | } | ||
249 | if (OnLinkObjects != null) | ||
250 | { | ||
251 | OnLinkObjects(parentprimid, childrenprims); | ||
252 | } | ||
253 | break; | ||
254 | case PacketType.ObjectDelink: | ||
255 | //OpenSim.Framework.Console.MainLog.Instance.Verbose( Pack.ToString()); | ||
256 | ObjectDelinkPacket delink = (ObjectDelinkPacket) Pack; | ||
257 | |||
258 | // It appears the prim at index 0 is not always the root prim (for | ||
259 | // instance, when one prim of a link set has been edited independently | ||
260 | // of the others). Therefore, we'll pass all the ids onto the delink | ||
261 | // method for it to decide which is the root. | ||
262 | List<uint> prims = new List<uint>(); | ||
263 | for (int i = 0; i < delink.ObjectData.Length; i++) | ||
264 | { | ||
265 | prims.Add(delink.ObjectData[i].ObjectLocalID); | ||
266 | } | ||
267 | |||
268 | if (OnDelinkObjects != null) | ||
269 | { | ||
270 | OnDelinkObjects(prims); | ||
271 | } | ||
272 | |||
273 | break; | ||
274 | case PacketType.ObjectAdd: | ||
275 | if (OnAddPrim != null) | ||
276 | { | ||
277 | ObjectAddPacket addPacket = (ObjectAddPacket) Pack; | ||
278 | PrimitiveBaseShape shape = GetShapeFromAddPacket(addPacket); | ||
279 | OnAddPrim(AgentId, addPacket.ObjectData.RayEnd, addPacket.ObjectData.Rotation, shape); | ||
280 | } | ||
281 | break; | ||
282 | case PacketType.ObjectShape: | ||
283 | ObjectShapePacket shapePacket = (ObjectShapePacket) Pack; | ||
284 | for (int i = 0; i < shapePacket.ObjectData.Length; i++) | ||
285 | { | ||
286 | if (OnUpdatePrimShape != null) | ||
287 | { | ||
288 | OnUpdatePrimShape(shapePacket.ObjectData[i].ObjectLocalID, shapePacket.ObjectData[i]); | ||
289 | } | ||
290 | } | ||
291 | break; | ||
292 | case PacketType.ObjectExtraParams: | ||
293 | ObjectExtraParamsPacket extraPar = (ObjectExtraParamsPacket) Pack; | ||
294 | if (OnUpdateExtraParams != null) | ||
295 | { | ||
296 | OnUpdateExtraParams(extraPar.ObjectData[0].ObjectLocalID, extraPar.ObjectData[0].ParamType, | ||
297 | extraPar.ObjectData[0].ParamInUse, extraPar.ObjectData[0].ParamData); | ||
298 | } | ||
299 | break; | ||
300 | case PacketType.ObjectDuplicate: | ||
301 | ObjectDuplicatePacket dupe = (ObjectDuplicatePacket) Pack; | ||
302 | ObjectDuplicatePacket.AgentDataBlock AgentandGroupData = dupe.AgentData; | ||
303 | for (int i = 0; i < dupe.ObjectData.Length; i++) | ||
304 | { | ||
305 | if (OnObjectDuplicate != null) | ||
306 | { | ||
307 | OnObjectDuplicate(dupe.ObjectData[i].ObjectLocalID, dupe.SharedData.Offset, | ||
308 | dupe.SharedData.DuplicateFlags, AgentandGroupData.AgentID, AgentandGroupData.GroupID); | ||
309 | } | ||
310 | } | ||
311 | |||
312 | break; | ||
313 | |||
314 | case PacketType.ObjectSelect: | ||
315 | ObjectSelectPacket incomingselect = (ObjectSelectPacket) Pack; | ||
316 | for (int i = 0; i < incomingselect.ObjectData.Length; i++) | ||
317 | { | ||
318 | if (OnObjectSelect != null) | ||
319 | { | ||
320 | OnObjectSelect(incomingselect.ObjectData[i].ObjectLocalID, this); | ||
321 | } | ||
322 | } | ||
323 | break; | ||
324 | case PacketType.ObjectDeselect: | ||
325 | ObjectDeselectPacket incomingdeselect = (ObjectDeselectPacket) Pack; | ||
326 | for (int i = 0; i < incomingdeselect.ObjectData.Length; i++) | ||
327 | { | ||
328 | if (OnObjectDeselect != null) | ||
329 | { | ||
330 | OnObjectDeselect(incomingdeselect.ObjectData[i].ObjectLocalID, this); | ||
331 | } | ||
332 | } | ||
333 | break; | ||
334 | case PacketType.ObjectFlagUpdate: | ||
335 | ObjectFlagUpdatePacket flags = (ObjectFlagUpdatePacket) Pack; | ||
336 | if (OnUpdatePrimFlags != null) | ||
337 | { | ||
338 | OnUpdatePrimFlags(flags.AgentData.ObjectLocalID, Pack, this); | ||
339 | } | ||
340 | break; | ||
341 | case PacketType.ObjectImage: | ||
342 | ObjectImagePacket imagePack = (ObjectImagePacket) Pack; | ||
343 | for (int i = 0; i < imagePack.ObjectData.Length; i++) | ||
344 | { | ||
345 | if (OnUpdatePrimTexture != null) | ||
346 | { | ||
347 | OnUpdatePrimTexture(imagePack.ObjectData[i].ObjectLocalID, | ||
348 | imagePack.ObjectData[i].TextureEntry, this); | ||
349 | } | ||
350 | } | ||
351 | break; | ||
352 | case PacketType.ObjectGrab: | ||
353 | ObjectGrabPacket grab = (ObjectGrabPacket) Pack; | ||
354 | if (OnGrabObject != null) | ||
355 | { | ||
356 | OnGrabObject(grab.ObjectData.LocalID, grab.ObjectData.GrabOffset, this); | ||
357 | } | ||
358 | break; | ||
359 | case PacketType.ObjectGrabUpdate: | ||
360 | ObjectGrabUpdatePacket grabUpdate = (ObjectGrabUpdatePacket) Pack; | ||
361 | if (OnGrabUpdate != null) | ||
362 | { | ||
363 | OnGrabUpdate(grabUpdate.ObjectData.ObjectID, grabUpdate.ObjectData.GrabOffsetInitial, | ||
364 | grabUpdate.ObjectData.GrabPosition, this); | ||
365 | } | ||
366 | break; | ||
367 | case PacketType.ObjectDeGrab: | ||
368 | ObjectDeGrabPacket deGrab = (ObjectDeGrabPacket) Pack; | ||
369 | if (OnDeGrabObject != null) | ||
370 | { | ||
371 | OnDeGrabObject(deGrab.ObjectData.LocalID, this); | ||
372 | } | ||
373 | break; | ||
374 | case PacketType.ObjectDescription: | ||
375 | ObjectDescriptionPacket objDes = (ObjectDescriptionPacket) Pack; | ||
376 | for (int i = 0; i < objDes.ObjectData.Length; i++) | ||
377 | { | ||
378 | if (OnObjectDescription != null) | ||
379 | { | ||
380 | OnObjectDescription(objDes.ObjectData[i].LocalID, | ||
381 | enc.GetString(objDes.ObjectData[i].Description)); | ||
382 | } | ||
383 | } | ||
384 | break; | ||
385 | case PacketType.ObjectName: | ||
386 | ObjectNamePacket objName = (ObjectNamePacket) Pack; | ||
387 | for (int i = 0; i < objName.ObjectData.Length; i++) | ||
388 | { | ||
389 | if (OnObjectName != null) | ||
390 | { | ||
391 | OnObjectName(objName.ObjectData[i].LocalID, enc.GetString(objName.ObjectData[i].Name)); | ||
392 | } | ||
393 | } | ||
394 | break; | ||
395 | case PacketType.ObjectPermissions: | ||
396 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
397 | break; | ||
398 | |||
399 | case PacketType.RequestObjectPropertiesFamily: | ||
400 | //This powers the little tooltip that appears when you move your mouse over an object | ||
401 | RequestObjectPropertiesFamilyPacket packToolTip = (RequestObjectPropertiesFamilyPacket)Pack; | ||
402 | |||
403 | |||
404 | RequestObjectPropertiesFamilyPacket.ObjectDataBlock packObjBlock = packToolTip.ObjectData; | ||
405 | |||
406 | if (OnRequestObjectPropertiesFamily != null) | ||
407 | { | ||
408 | OnRequestObjectPropertiesFamily(this, this.m_agentId, packObjBlock.RequestFlags, packObjBlock.ObjectID); | ||
409 | |||
410 | |||
411 | } | ||
412 | |||
413 | break; | ||
414 | |||
415 | #endregion | ||
416 | |||
417 | #region Inventory/Asset/Other related packets | ||
418 | |||
419 | case PacketType.RequestImage: | ||
420 | RequestImagePacket imageRequest = (RequestImagePacket) Pack; | ||
421 | //Console.WriteLine("image request: " + Pack.ToString()); | ||
422 | for (int i = 0; i < imageRequest.RequestImage.Length; i++) | ||
423 | { | ||
424 | // still working on the Texture download module so for now using old method | ||
425 | // TextureRequestArgs args = new TextureRequestArgs(); | ||
426 | // args.RequestedAssetID = imageRequest.RequestImage[i].Image; | ||
427 | // args.DiscardLevel = imageRequest.RequestImage[i].DiscardLevel; | ||
428 | // args.PacketNumber = imageRequest.RequestImage[i].Packet; | ||
429 | |||
430 | // if (OnRequestTexture != null) | ||
431 | // { | ||
432 | // OnRequestTexture(this, args); | ||
433 | // } | ||
434 | |||
435 | m_assetCache.AddTextureRequest(this, imageRequest.RequestImage[i].Image, | ||
436 | imageRequest.RequestImage[i].Packet, | ||
437 | imageRequest.RequestImage[i].DiscardLevel); | ||
438 | } | ||
439 | break; | ||
440 | case PacketType.TransferRequest: | ||
441 | //Console.WriteLine("ClientView.ProcessPackets.cs:ProcessInPacket() - Got transfer request"); | ||
442 | TransferRequestPacket transfer = (TransferRequestPacket) Pack; | ||
443 | m_assetCache.AddAssetRequest(this, transfer); | ||
444 | break; | ||
445 | case PacketType.AssetUploadRequest: | ||
446 | AssetUploadRequestPacket request = (AssetUploadRequestPacket) Pack; | ||
447 | // Console.WriteLine("upload request " + Pack.ToString()); | ||
448 | // Console.WriteLine("upload request was for assetid: " + request.AssetBlock.TransactionID.Combine(this.SecureSessionID).ToStringHyphenated()); | ||
449 | if (OnAssetUploadRequest != null) | ||
450 | { | ||
451 | OnAssetUploadRequest(this, request.AssetBlock.TransactionID.Combine(SecureSessionID), | ||
452 | request.AssetBlock.TransactionID, request.AssetBlock.Type, | ||
453 | request.AssetBlock.AssetData, request.AssetBlock.StoreLocal); | ||
454 | } | ||
455 | break; | ||
456 | case PacketType.RequestXfer: | ||
457 | RequestXferPacket xferReq = (RequestXferPacket) Pack; | ||
458 | if (OnRequestXfer != null) | ||
459 | { | ||
460 | OnRequestXfer(this, xferReq.XferID.ID, Util.FieldToString(xferReq.XferID.Filename)); | ||
461 | } | ||
462 | break; | ||
463 | case PacketType.SendXferPacket: | ||
464 | SendXferPacketPacket xferRec = (SendXferPacketPacket) Pack; | ||
465 | if (OnXferReceive != null) | ||
466 | { | ||
467 | OnXferReceive(this, xferRec.XferID.ID, xferRec.XferID.Packet, xferRec.DataPacket.Data); | ||
468 | } | ||
469 | break; | ||
470 | case PacketType.ConfirmXferPacket: | ||
471 | ConfirmXferPacketPacket confirmXfer = (ConfirmXferPacketPacket) Pack; | ||
472 | if (OnConfirmXfer != null) | ||
473 | { | ||
474 | OnConfirmXfer(this, confirmXfer.XferID.ID, confirmXfer.XferID.Packet); | ||
475 | } | ||
476 | break; | ||
477 | case PacketType.CreateInventoryFolder: | ||
478 | if (OnCreateNewInventoryFolder != null) | ||
479 | { | ||
480 | CreateInventoryFolderPacket invFolder = (CreateInventoryFolderPacket) Pack; | ||
481 | OnCreateNewInventoryFolder(this, invFolder.FolderData.FolderID, | ||
482 | (ushort) invFolder.FolderData.Type, | ||
483 | Util.FieldToString(invFolder.FolderData.Name), | ||
484 | invFolder.FolderData.ParentID); | ||
485 | } | ||
486 | break; | ||
487 | case PacketType.CreateInventoryItem: | ||
488 | CreateInventoryItemPacket createItem = (CreateInventoryItemPacket) Pack; | ||
489 | if (OnCreateNewInventoryItem != null) | ||
490 | { | ||
491 | OnCreateNewInventoryItem(this, createItem.InventoryBlock.TransactionID, | ||
492 | createItem.InventoryBlock.FolderID, | ||
493 | createItem.InventoryBlock.CallbackID, | ||
494 | Util.FieldToString(createItem.InventoryBlock.Description), | ||
495 | Util.FieldToString(createItem.InventoryBlock.Name), | ||
496 | createItem.InventoryBlock.InvType, | ||
497 | createItem.InventoryBlock.Type, | ||
498 | createItem.InventoryBlock.WearableType, | ||
499 | createItem.InventoryBlock.NextOwnerMask); | ||
500 | } | ||
501 | break; | ||
502 | case PacketType.FetchInventory: | ||
503 | if (OnFetchInventory != null) | ||
504 | { | ||
505 | FetchInventoryPacket FetchInventory = (FetchInventoryPacket) Pack; | ||
506 | for (int i = 0; i < FetchInventory.InventoryData.Length; i++) | ||
507 | { | ||
508 | OnFetchInventory(this, FetchInventory.InventoryData[i].ItemID, | ||
509 | FetchInventory.InventoryData[i].OwnerID); | ||
510 | } | ||
511 | } | ||
512 | break; | ||
513 | case PacketType.FetchInventoryDescendents: | ||
514 | if (OnFetchInventoryDescendents != null) | ||
515 | { | ||
516 | FetchInventoryDescendentsPacket Fetch = (FetchInventoryDescendentsPacket) Pack; | ||
517 | OnFetchInventoryDescendents(this, Fetch.InventoryData.FolderID, Fetch.InventoryData.OwnerID, | ||
518 | Fetch.InventoryData.FetchFolders, Fetch.InventoryData.FetchItems, | ||
519 | Fetch.InventoryData.SortOrder); | ||
520 | } | ||
521 | break; | ||
522 | case PacketType.UpdateInventoryItem: | ||
523 | UpdateInventoryItemPacket update = (UpdateInventoryItemPacket) Pack; | ||
524 | if (OnUpdateInventoryItem != null) | ||
525 | { | ||
526 | for (int i = 0; i < update.InventoryData.Length; i++) | ||
527 | { | ||
528 | if (update.InventoryData[i].TransactionID != LLUUID.Zero) | ||
529 | { | ||
530 | OnUpdateInventoryItem(this, update.InventoryData[i].TransactionID, | ||
531 | update.InventoryData[i].TransactionID.Combine(SecureSessionID), | ||
532 | update.InventoryData[i].ItemID); | ||
533 | } | ||
534 | } | ||
535 | } | ||
536 | //Console.WriteLine(Pack.ToString()); | ||
537 | /*for (int i = 0; i < update.InventoryData.Length; i++) | ||
538 | { | ||
539 | if (update.InventoryData[i].TransactionID != LLUUID.Zero) | ||
540 | { | ||
541 | AssetBase asset = m_assetCache.GetAsset(update.InventoryData[i].TransactionID.Combine(this.SecureSessionID)); | ||
542 | if (asset != null) | ||
543 | { | ||
544 | // Console.WriteLine("updating inventory item, found asset" + asset.FullID.ToStringHyphenated() + " already in cache"); | ||
545 | m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); | ||
546 | } | ||
547 | else | ||
548 | { | ||
549 | asset = this.UploadAssets.AddUploadToAssetCache(update.InventoryData[i].TransactionID); | ||
550 | if (asset != null) | ||
551 | { | ||
552 | //Console.WriteLine("updating inventory item, adding asset" + asset.FullID.ToStringHyphenated() + " to cache"); | ||
553 | m_inventoryCache.UpdateInventoryItemAsset(this, update.InventoryData[i].ItemID, asset); | ||
554 | } | ||
555 | else | ||
556 | { | ||
557 | //Console.WriteLine("trying to update inventory item, but asset is null"); | ||
558 | } | ||
559 | } | ||
560 | } | ||
561 | else | ||
562 | { | ||
563 | m_inventoryCache.UpdateInventoryItemDetails(this, update.InventoryData[i].ItemID, update.InventoryData[i]); ; | ||
564 | } | ||
565 | }*/ | ||
566 | break; | ||
567 | case PacketType.CopyInventoryItem: | ||
568 | CopyInventoryItemPacket copyitem = (CopyInventoryItemPacket) Pack; | ||
569 | if (OnCopyInventoryItem != null) | ||
570 | { | ||
571 | foreach (CopyInventoryItemPacket.InventoryDataBlock datablock in copyitem.InventoryData) | ||
572 | { | ||
573 | OnCopyInventoryItem(this, datablock.CallbackID, datablock.OldAgentID, datablock.OldItemID, datablock.NewFolderID, Util.FieldToString(datablock.NewName)); | ||
574 | } | ||
575 | } | ||
576 | break; | ||
577 | case PacketType.RequestTaskInventory: | ||
578 | RequestTaskInventoryPacket requesttask = (RequestTaskInventoryPacket) Pack; | ||
579 | if (OnRequestTaskInventory != null) | ||
580 | { | ||
581 | OnRequestTaskInventory(this, requesttask.InventoryData.LocalID); | ||
582 | } | ||
583 | break; | ||
584 | case PacketType.UpdateTaskInventory: | ||
585 | //Console.WriteLine(Pack.ToString()); | ||
586 | UpdateTaskInventoryPacket updatetask = (UpdateTaskInventoryPacket) Pack; | ||
587 | if (OnUpdateTaskInventory != null) | ||
588 | { | ||
589 | if (updatetask.UpdateData.Key == 0) | ||
590 | { | ||
591 | OnUpdateTaskInventory(this, updatetask.InventoryData.ItemID, | ||
592 | updatetask.InventoryData.FolderID, updatetask.UpdateData.LocalID); | ||
593 | } | ||
594 | } | ||
595 | break; | ||
596 | case PacketType.RemoveTaskInventory: | ||
597 | RemoveTaskInventoryPacket removeTask = (RemoveTaskInventoryPacket) Pack; | ||
598 | if (OnRemoveTaskItem != null) | ||
599 | { | ||
600 | OnRemoveTaskItem(this, removeTask.InventoryData.ItemID, removeTask.InventoryData.LocalID); | ||
601 | } | ||
602 | break; | ||
603 | case PacketType.MoveTaskInventory: | ||
604 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
605 | break; | ||
606 | case PacketType.RezScript: | ||
607 | //Console.WriteLine(Pack.ToString()); | ||
608 | RezScriptPacket rezScript = (RezScriptPacket) Pack; | ||
609 | if (OnRezScript != null) | ||
610 | { | ||
611 | OnRezScript(this, rezScript.InventoryBlock.ItemID, rezScript.UpdateBlock.ObjectLocalID); | ||
612 | } | ||
613 | break; | ||
614 | case PacketType.MapLayerRequest: | ||
615 | RequestMapLayer(); | ||
616 | break; | ||
617 | case PacketType.MapBlockRequest: | ||
618 | MapBlockRequestPacket MapRequest = (MapBlockRequestPacket) Pack; | ||
619 | if (OnRequestMapBlocks != null) | ||
620 | { | ||
621 | OnRequestMapBlocks(this, MapRequest.PositionData.MinX, MapRequest.PositionData.MinY, | ||
622 | MapRequest.PositionData.MaxX, MapRequest.PositionData.MaxY); | ||
623 | } | ||
624 | break; | ||
625 | case PacketType.MapNameRequest: | ||
626 | MapNameRequestPacket map = (MapNameRequestPacket) Pack; | ||
627 | string mapName = UTF8Encoding.UTF8.GetString(map.NameData.Name, 0, | ||
628 | map.NameData.Name.Length - 1); | ||
629 | if (OnMapNameRequest != null) | ||
630 | { | ||
631 | OnMapNameRequest(this, mapName); | ||
632 | } | ||
633 | break; | ||
634 | case PacketType.TeleportLandmarkRequest: | ||
635 | TeleportLandmarkRequestPacket tpReq = (TeleportLandmarkRequestPacket) Pack; | ||
636 | |||
637 | TeleportStartPacket tpStart = new TeleportStartPacket(); | ||
638 | tpStart.Info.TeleportFlags = 8; // tp via lm | ||
639 | OutPacket(tpStart, ThrottleOutPacketType.Task); | ||
640 | |||
641 | TeleportProgressPacket tpProgress = new TeleportProgressPacket(); | ||
642 | tpProgress.Info.Message = (new ASCIIEncoding()).GetBytes("sending_landmark"); | ||
643 | tpProgress.Info.TeleportFlags = 8; | ||
644 | tpProgress.AgentData.AgentID = tpReq.Info.AgentID; | ||
645 | OutPacket(tpProgress, ThrottleOutPacketType.Task); | ||
646 | |||
647 | // Fetch landmark | ||
648 | LLUUID lmid = tpReq.Info.LandmarkID; | ||
649 | AssetBase lma = m_assetCache.GetAsset(lmid); | ||
650 | if (lma != null) | ||
651 | { | ||
652 | AssetLandmark lm = new AssetLandmark(lma); | ||
653 | |||
654 | if (lm.RegionID == m_scene.RegionInfo.RegionID) | ||
655 | { | ||
656 | TeleportLocalPacket tpLocal = new TeleportLocalPacket(); | ||
657 | |||
658 | tpLocal.Info.AgentID = tpReq.Info.AgentID; | ||
659 | tpLocal.Info.TeleportFlags = 8; // Teleport via landmark | ||
660 | tpLocal.Info.LocationID = 2; | ||
661 | tpLocal.Info.Position = lm.Position; | ||
662 | OutPacket(tpLocal, ThrottleOutPacketType.Task); | ||
663 | } | ||
664 | else | ||
665 | { | ||
666 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | ||
667 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | ||
668 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | ||
669 | OutPacket(tpCancel, ThrottleOutPacketType.Task); | ||
670 | } | ||
671 | } | ||
672 | else | ||
673 | { | ||
674 | Console.WriteLine("Cancelling Teleport - fetch asset not yet implemented"); | ||
675 | |||
676 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | ||
677 | tpCancel.Info.AgentID = tpReq.Info.AgentID; | ||
678 | tpCancel.Info.SessionID = tpReq.Info.SessionID; | ||
679 | OutPacket(tpCancel, ThrottleOutPacketType.Task); | ||
680 | } | ||
681 | break; | ||
682 | case PacketType.TeleportLocationRequest: | ||
683 | TeleportLocationRequestPacket tpLocReq = (TeleportLocationRequestPacket) Pack; | ||
684 | // Console.WriteLine(tpLocReq.ToString()); | ||
685 | |||
686 | if (OnTeleportLocationRequest != null) | ||
687 | { | ||
688 | OnTeleportLocationRequest(this, tpLocReq.Info.RegionHandle, tpLocReq.Info.Position, | ||
689 | tpLocReq.Info.LookAt, 16); | ||
690 | } | ||
691 | else | ||
692 | { | ||
693 | //no event handler so cancel request | ||
694 | TeleportCancelPacket tpCancel = new TeleportCancelPacket(); | ||
695 | tpCancel.Info.SessionID = tpLocReq.AgentData.SessionID; | ||
696 | tpCancel.Info.AgentID = tpLocReq.AgentData.AgentID; | ||
697 | OutPacket(tpCancel, ThrottleOutPacketType.Task); | ||
698 | } | ||
699 | break; | ||
700 | |||
701 | #endregion | ||
702 | |||
703 | case PacketType.MoneyBalanceRequest: | ||
704 | SendMoneyBalance(LLUUID.Zero, true, new byte[0], MoneyBalance); | ||
705 | break; | ||
706 | case PacketType.UUIDNameRequest: | ||
707 | UUIDNameRequestPacket incoming = (UUIDNameRequestPacket) Pack; | ||
708 | foreach (UUIDNameRequestPacket.UUIDNameBlockBlock UUIDBlock in incoming.UUIDNameBlock) | ||
709 | { | ||
710 | OnNameFromUUIDRequest(UUIDBlock.ID, this); | ||
711 | } | ||
712 | break; | ||
713 | |||
714 | #region Parcel related packets | ||
715 | |||
716 | case PacketType.ParcelPropertiesRequest: | ||
717 | ParcelPropertiesRequestPacket propertiesRequest = (ParcelPropertiesRequestPacket) Pack; | ||
718 | if (OnParcelPropertiesRequest != null) | ||
719 | { | ||
720 | OnParcelPropertiesRequest((int) Math.Round(propertiesRequest.ParcelData.West), | ||
721 | (int) Math.Round(propertiesRequest.ParcelData.South), | ||
722 | (int) Math.Round(propertiesRequest.ParcelData.East), | ||
723 | (int) Math.Round(propertiesRequest.ParcelData.North), | ||
724 | propertiesRequest.ParcelData.SequenceID, | ||
725 | propertiesRequest.ParcelData.SnapSelection, this); | ||
726 | } | ||
727 | break; | ||
728 | case PacketType.ParcelDivide: | ||
729 | ParcelDividePacket landDivide = (ParcelDividePacket) Pack; | ||
730 | if (OnParcelDivideRequest != null) | ||
731 | { | ||
732 | OnParcelDivideRequest((int) Math.Round(landDivide.ParcelData.West), | ||
733 | (int) Math.Round(landDivide.ParcelData.South), | ||
734 | (int) Math.Round(landDivide.ParcelData.East), | ||
735 | (int) Math.Round(landDivide.ParcelData.North), this); | ||
736 | } | ||
737 | break; | ||
738 | case PacketType.ParcelJoin: | ||
739 | ParcelJoinPacket landJoin = (ParcelJoinPacket) Pack; | ||
740 | if (OnParcelJoinRequest != null) | ||
741 | { | ||
742 | OnParcelJoinRequest((int) Math.Round(landJoin.ParcelData.West), | ||
743 | (int) Math.Round(landJoin.ParcelData.South), | ||
744 | (int) Math.Round(landJoin.ParcelData.East), | ||
745 | (int) Math.Round(landJoin.ParcelData.North), this); | ||
746 | } | ||
747 | break; | ||
748 | case PacketType.ParcelPropertiesUpdate: | ||
749 | ParcelPropertiesUpdatePacket updatePacket = (ParcelPropertiesUpdatePacket) Pack; | ||
750 | if (OnParcelPropertiesUpdateRequest != null) | ||
751 | { | ||
752 | OnParcelPropertiesUpdateRequest(updatePacket, this); | ||
753 | } | ||
754 | break; | ||
755 | case PacketType.ParcelSelectObjects: | ||
756 | ParcelSelectObjectsPacket selectPacket = (ParcelSelectObjectsPacket) Pack; | ||
757 | if (OnParcelSelectObjects != null) | ||
758 | { | ||
759 | OnParcelSelectObjects(selectPacket.ParcelData.LocalID, | ||
760 | Convert.ToInt32(selectPacket.ParcelData.ReturnType), this); | ||
761 | } | ||
762 | break; | ||
763 | case PacketType.ParcelObjectOwnersRequest: | ||
764 | //System.Console.WriteLine(Pack.ToString()); | ||
765 | ParcelObjectOwnersRequestPacket reqPacket = (ParcelObjectOwnersRequestPacket) Pack; | ||
766 | if (OnParcelObjectOwnerRequest != null) | ||
767 | { | ||
768 | OnParcelObjectOwnerRequest(reqPacket.ParcelData.LocalID, this); | ||
769 | } | ||
770 | break; | ||
771 | |||
772 | #endregion | ||
773 | |||
774 | #region Estate Packets | ||
775 | |||
776 | case PacketType.EstateOwnerMessage: | ||
777 | EstateOwnerMessagePacket messagePacket = (EstateOwnerMessagePacket) Pack; | ||
778 | if (OnEstateOwnerMessage != null) | ||
779 | { | ||
780 | OnEstateOwnerMessage(messagePacket, this); | ||
781 | } | ||
782 | break; | ||
783 | |||
784 | case PacketType.AgentThrottle: | ||
785 | |||
786 | //OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
787 | |||
788 | AgentThrottlePacket atpack = (AgentThrottlePacket)Pack; | ||
789 | |||
790 | byte[] throttle = atpack.Throttle.Throttles; | ||
791 | int tResend = -1; | ||
792 | int tLand = -1; | ||
793 | int tWind = -1; | ||
794 | int tCloud = -1; | ||
795 | int tTask = -1; | ||
796 | int tTexture = -1; | ||
797 | int tAsset = -1; | ||
798 | int tall = -1; | ||
799 | int singlefloat = 4; | ||
800 | |||
801 | //Agent Throttle Block contains 7 single floatingpoint values. | ||
802 | int j = 0; | ||
803 | |||
804 | // Some Systems may be big endian... | ||
805 | // it might be smart to do this check more often... | ||
806 | if (!BitConverter.IsLittleEndian) | ||
807 | for (int i = 0; i < 7; i++) | ||
808 | Array.Reverse(throttle, j + i * singlefloat, singlefloat); | ||
809 | |||
810 | // values gotten from libsecondlife.org/wiki/Throttle. Thanks MW_ | ||
811 | // bytes | ||
812 | // Convert to integer, since.. the full fp space isn't used. | ||
813 | tResend = (int)BitConverter.ToSingle(throttle, j); | ||
814 | j += singlefloat; | ||
815 | tLand = (int)BitConverter.ToSingle(throttle, j); | ||
816 | j += singlefloat; | ||
817 | tWind = (int)BitConverter.ToSingle(throttle, j); | ||
818 | j += singlefloat; | ||
819 | tCloud = (int)BitConverter.ToSingle(throttle, j); | ||
820 | j += singlefloat; | ||
821 | tTask = (int)BitConverter.ToSingle(throttle, j); | ||
822 | j += singlefloat; | ||
823 | tTexture = (int)BitConverter.ToSingle(throttle, j); | ||
824 | j += singlefloat; | ||
825 | tAsset = (int)BitConverter.ToSingle(throttle, j); | ||
826 | |||
827 | tall = tResend + tLand + tWind + tCloud + tTask + tTexture + tAsset; | ||
828 | /* | ||
829 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "Client AgentThrottle - Got throttle:resendbytes=" + tResend + | ||
830 | " landbytes=" + tLand + | ||
831 | " windbytes=" + tWind + | ||
832 | " cloudbytes=" + tCloud + | ||
833 | " taskbytes=" + tTask + | ||
834 | " texturebytes=" + tTexture + | ||
835 | " Assetbytes=" + tAsset + | ||
836 | " Allbytes=" + tall); | ||
837 | */ | ||
838 | |||
839 | // Total Sanity | ||
840 | // Make sure that the client sent sane total values. | ||
841 | |||
842 | // If the client didn't send acceptable values.... | ||
843 | // Scale the clients values down until they are acceptable. | ||
844 | |||
845 | if (tall <= throttleOutboundMax) | ||
846 | { | ||
847 | // Sanity | ||
848 | // Making sure the client sends sane values | ||
849 | // This gives us a measure of control of the comms | ||
850 | // Check Max of Type | ||
851 | // Then Check Min of type | ||
852 | |||
853 | // Resend throttle | ||
854 | if (tResend <= ResendthrottleMAX) | ||
855 | ResendthrottleOutbound = tResend; | ||
856 | |||
857 | if (tResend < ResendthrottleMin) | ||
858 | ResendthrottleOutbound = ResendthrottleMin; | ||
859 | |||
860 | // Land throttle | ||
861 | if (tLand <= LandthrottleMax) | ||
862 | LandthrottleOutbound = tLand; | ||
863 | |||
864 | if (tLand < LandthrottleMin) | ||
865 | LandthrottleOutbound = LandthrottleMin; | ||
866 | |||
867 | // Wind throttle | ||
868 | if (tWind <= WindthrottleMax) | ||
869 | WindthrottleOutbound = tWind; | ||
870 | |||
871 | if (tWind < WindthrottleMin) | ||
872 | WindthrottleOutbound = WindthrottleMin; | ||
873 | |||
874 | // Cloud throttle | ||
875 | if (tCloud <= CloudthrottleMax) | ||
876 | CloudthrottleOutbound = tCloud; | ||
877 | |||
878 | if (tCloud < CloudthrottleMin) | ||
879 | CloudthrottleOutbound = CloudthrottleMin; | ||
880 | |||
881 | // Task throttle | ||
882 | if (tTask <= TaskthrottleMax) | ||
883 | TaskthrottleOutbound = tTask; | ||
884 | |||
885 | if (tTask < TaskthrottleMin) | ||
886 | TaskthrottleOutbound = TaskthrottleMin; | ||
887 | |||
888 | // Texture throttle | ||
889 | if (tTexture <= TexturethrottleMax) | ||
890 | TexturethrottleOutbound = tTexture; | ||
891 | |||
892 | if (tTexture < TexturethrottleMin) | ||
893 | TexturethrottleOutbound = TexturethrottleMin; | ||
894 | |||
895 | //Asset throttle | ||
896 | if (tAsset <= AssetthrottleMax) | ||
897 | AssetthrottleOutbound = tAsset; | ||
898 | |||
899 | if (tAsset < AssetthrottleMin) | ||
900 | AssetthrottleOutbound = AssetthrottleMin; | ||
901 | |||
902 | /* OpenSim.Framework.Console.MainLog.Instance.Verbose("THROTTLE", "Using:resendbytes=" + ResendthrottleOutbound + | ||
903 | " landbytes=" + LandthrottleOutbound + | ||
904 | " windbytes=" + WindthrottleOutbound + | ||
905 | " cloudbytes=" + CloudthrottleOutbound + | ||
906 | " taskbytes=" + TaskthrottleOutbound + | ||
907 | " texturebytes=" + TexturethrottleOutbound + | ||
908 | " Assetbytes=" + AssetthrottleOutbound + | ||
909 | " Allbytes=" + tall); | ||
910 | */ | ||
911 | } | ||
912 | else | ||
913 | { | ||
914 | // The client didn't send acceptable values.. | ||
915 | // so it's our job now to turn them into acceptable values | ||
916 | // We're going to first scale the values down | ||
917 | // After that we're going to check if the scaled values are sane | ||
918 | |||
919 | // We're going to be dividing by a user value.. so make sure | ||
920 | // we don't get a divide by zero error. | ||
921 | if (tall > 0) | ||
922 | { | ||
923 | // Find out the percentage of all communications | ||
924 | // the client requests for each type. We'll keep resend at | ||
925 | // it's client recommended level (won't scale it down) | ||
926 | // unless it's beyond sane values itself. | ||
927 | |||
928 | if (tResend <= ResendthrottleMAX) | ||
929 | { | ||
930 | // This is nexted because we only want to re-set the values | ||
931 | // the packet throttler uses once. | ||
932 | |||
933 | if (tResend >= ResendthrottleMin) | ||
934 | { | ||
935 | ResendthrottleOutbound = tResend; | ||
936 | } | ||
937 | else | ||
938 | { | ||
939 | ResendthrottleOutbound = ResendthrottleMin; | ||
940 | } | ||
941 | } | ||
942 | else | ||
943 | { | ||
944 | ResendthrottleOutbound = ResendthrottleMAX; | ||
945 | } | ||
946 | |||
947 | |||
948 | // Getting Percentages of communication for each type of data | ||
949 | float LandPercent = (float)(tLand / tall); | ||
950 | float WindPercent = (float)(tWind / tall); | ||
951 | float CloudPercent = (float)(tCloud / tall); | ||
952 | float TaskPercent = (float)(tTask / tall); | ||
953 | float TexturePercent = (float)(tTexture / tall); | ||
954 | float AssetPercent = (float)(tAsset / tall); | ||
955 | |||
956 | // Okay.. now we've got the percentages of total communication. | ||
957 | // Apply them to a new max total | ||
958 | |||
959 | int tLandResult = (int)(LandPercent * throttleOutboundMax); | ||
960 | int tWindResult = (int)(WindPercent * throttleOutboundMax); | ||
961 | int tCloudResult = (int)(CloudPercent * throttleOutboundMax); | ||
962 | int tTaskResult = (int)(TaskPercent * throttleOutboundMax); | ||
963 | int tTextureResult = (int)(TexturePercent * throttleOutboundMax); | ||
964 | int tAssetResult = (int)(AssetPercent * throttleOutboundMax); | ||
965 | |||
966 | // Now we have to check our scaled values for sanity | ||
967 | |||
968 | // Check Max of Type | ||
969 | // Then Check Min of type | ||
970 | |||
971 | // Land throttle | ||
972 | if (tLandResult <= LandthrottleMax) | ||
973 | LandthrottleOutbound = tLandResult; | ||
974 | |||
975 | if (tLandResult < LandthrottleMin) | ||
976 | LandthrottleOutbound = LandthrottleMin; | ||
977 | |||
978 | // Wind throttle | ||
979 | if (tWindResult <= WindthrottleMax) | ||
980 | WindthrottleOutbound = tWindResult; | ||
981 | |||
982 | if (tWindResult < WindthrottleMin) | ||
983 | WindthrottleOutbound = WindthrottleMin; | ||
984 | |||
985 | // Cloud throttle | ||
986 | if (tCloudResult <= CloudthrottleMax) | ||
987 | CloudthrottleOutbound = tCloudResult; | ||
988 | |||
989 | if (tCloudResult < CloudthrottleMin) | ||
990 | CloudthrottleOutbound = CloudthrottleMin; | ||
991 | |||
992 | // Task throttle | ||
993 | if (tTaskResult <= TaskthrottleMax) | ||
994 | TaskthrottleOutbound = tTaskResult; | ||
995 | |||
996 | if (tTaskResult < TaskthrottleMin) | ||
997 | TaskthrottleOutbound = TaskthrottleMin; | ||
998 | |||
999 | // Texture throttle | ||
1000 | if (tTextureResult <= TexturethrottleMax) | ||
1001 | TexturethrottleOutbound = tTextureResult; | ||
1002 | |||
1003 | if (tTextureResult < TexturethrottleMin) | ||
1004 | TexturethrottleOutbound = TexturethrottleMin; | ||
1005 | |||
1006 | //Asset throttle | ||
1007 | if (tAssetResult <= AssetthrottleMax) | ||
1008 | AssetthrottleOutbound = tAssetResult; | ||
1009 | |||
1010 | if (tAssetResult < AssetthrottleMin) | ||
1011 | AssetthrottleOutbound = AssetthrottleMin; | ||
1012 | |||
1013 | /* OpenSim.Framework.Console.MainLog.Instance.Verbose("THROTTLE", "Using:resendbytes=" + ResendthrottleOutbound + | ||
1014 | " landbytes=" + LandthrottleOutbound + | ||
1015 | " windbytes=" + WindthrottleOutbound + | ||
1016 | " cloudbytes=" + CloudthrottleOutbound + | ||
1017 | " taskbytes=" + TaskthrottleOutbound + | ||
1018 | " texturebytes=" + TexturethrottleOutbound + | ||
1019 | " Assetbytes=" + AssetthrottleOutbound + | ||
1020 | " Allbytes=" + tall); | ||
1021 | */ | ||
1022 | |||
1023 | } | ||
1024 | else | ||
1025 | { | ||
1026 | |||
1027 | // The client sent a stupid value.. | ||
1028 | // We're going to set the throttles to the minimum possible | ||
1029 | ResendthrottleOutbound = ResendthrottleMin; | ||
1030 | LandthrottleOutbound = LandthrottleMin; | ||
1031 | WindthrottleOutbound = WindthrottleMin; | ||
1032 | CloudthrottleOutbound = CloudthrottleMin; | ||
1033 | TaskthrottleOutbound = TaskthrottleMin; | ||
1034 | TexturethrottleOutbound = TexturethrottleMin; | ||
1035 | AssetthrottleOutbound = AssetthrottleMin; | ||
1036 | OpenSim.Framework.Console.MainLog.Instance.Verbose("THROTTLE", "ClientSentBadThrottle Using:resendbytes=" + ResendthrottleOutbound + | ||
1037 | " landbytes=" + LandthrottleOutbound + | ||
1038 | " windbytes=" + WindthrottleOutbound + | ||
1039 | " cloudbytes=" + CloudthrottleOutbound + | ||
1040 | " taskbytes=" + TaskthrottleOutbound + | ||
1041 | " texturebytes=" + TexturethrottleOutbound + | ||
1042 | " Assetbytes=" + AssetthrottleOutbound + | ||
1043 | " Allbytes=" + tall); | ||
1044 | } | ||
1045 | |||
1046 | } | ||
1047 | // Reset Client Throttles | ||
1048 | // This has the effect of 'wiggling the slider | ||
1049 | // causes prim and stuck textures that didn't download to download | ||
1050 | |||
1051 | ResendBytesSent = 0; | ||
1052 | LandBytesSent = 0; | ||
1053 | WindBytesSent = 0; | ||
1054 | CloudBytesSent = 0; | ||
1055 | TaskBytesSent = 0; | ||
1056 | AssetBytesSent = 0; | ||
1057 | TextureBytesSent = 0; | ||
1058 | |||
1059 | //Yay, we've finally handled the agent Throttle packet! | ||
1060 | |||
1061 | |||
1062 | |||
1063 | break; | ||
1064 | |||
1065 | #endregion | ||
1066 | |||
1067 | #region unimplemented handlers | ||
1068 | case PacketType.RequestGodlikePowers: | ||
1069 | RequestGodlikePowersPacket rglpPack = (RequestGodlikePowersPacket) Pack; | ||
1070 | RequestGodlikePowersPacket.RequestBlockBlock rblock = rglpPack.RequestBlock; | ||
1071 | LLUUID token = rblock.Token; | ||
1072 | RequestGodlikePowersPacket.AgentDataBlock ablock = rglpPack.AgentData; | ||
1073 | |||
1074 | OnRequestGodlikePowers(ablock.AgentID, ablock.SessionID, token, this); | ||
1075 | |||
1076 | break; | ||
1077 | case PacketType.GodKickUser: | ||
1078 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
1079 | |||
1080 | GodKickUserPacket gkupack = (GodKickUserPacket) Pack; | ||
1081 | |||
1082 | if (gkupack.UserInfo.GodSessionID == SessionId && this.AgentId == gkupack.UserInfo.GodID) | ||
1083 | { | ||
1084 | OnGodKickUser(gkupack.UserInfo.GodID, gkupack.UserInfo.GodSessionID, gkupack.UserInfo.AgentID, (uint) 0, gkupack.UserInfo.Reason); | ||
1085 | } | ||
1086 | else | ||
1087 | { | ||
1088 | SendAgentAlertMessage("Kick request denied", false); | ||
1089 | } | ||
1090 | //KickUserPacket kupack = new KickUserPacket(); | ||
1091 | //KickUserPacket.UserInfoBlock kupackib = kupack.UserInfo; | ||
1092 | |||
1093 | //kupack.UserInfo.AgentID = gkupack.UserInfo.AgentID; | ||
1094 | //kupack.UserInfo.SessionID = gkupack.UserInfo.GodSessionID; | ||
1095 | |||
1096 | //kupack.TargetBlock.TargetIP = (uint)0; | ||
1097 | //kupack.TargetBlock.TargetPort = (ushort)0; | ||
1098 | //kupack.UserInfo.Reason = gkupack.UserInfo.Reason; | ||
1099 | |||
1100 | |||
1101 | //OutPacket(kupack, ThrottleOutPacketType.Task); | ||
1102 | break; | ||
1103 | |||
1104 | case PacketType.StartPingCheck: | ||
1105 | // Send the client the ping response back | ||
1106 | // Pass the same PingID in the matching packet | ||
1107 | // Handled In the packet processing | ||
1108 | OpenSim.Framework.Console.MainLog.Instance.Debug("CLIENT", "possibly unhandled packet " + Pack.ToString()); | ||
1109 | break; | ||
1110 | case PacketType.CompletePingCheck: | ||
1111 | // Parhaps this should be processed on the Sim to determine whether or not to drop a dead client | ||
1112 | // Dumping it to the verbose console until it's handled properly. | ||
1113 | |||
1114 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
1115 | break; | ||
1116 | case PacketType.AgentIsNowWearing: | ||
1117 | // AgentIsNowWearingPacket wear = (AgentIsNowWearingPacket)Pack; | ||
1118 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
1119 | break; | ||
1120 | case PacketType.ObjectScale: | ||
1121 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
1122 | break; | ||
1123 | default: | ||
1124 | OpenSim.Framework.Console.MainLog.Instance.Verbose("CLIENT", "unhandled packet " + Pack.ToString()); | ||
1125 | break; | ||
1126 | |||
1127 | #endregion | ||
1128 | } | ||
1129 | } | ||
1130 | } | ||
1131 | |||
1132 | private static PrimitiveBaseShape GetShapeFromAddPacket(ObjectAddPacket addPacket) | ||
1133 | { | ||
1134 | PrimitiveBaseShape shape = new PrimitiveBaseShape(); | ||
1135 | |||
1136 | shape.PCode = addPacket.ObjectData.PCode; | ||
1137 | shape.PathBegin = addPacket.ObjectData.PathBegin; | ||
1138 | shape.PathEnd = addPacket.ObjectData.PathEnd; | ||
1139 | shape.PathScaleX = addPacket.ObjectData.PathScaleX; | ||
1140 | shape.PathScaleY = addPacket.ObjectData.PathScaleY; | ||
1141 | shape.PathShearX = addPacket.ObjectData.PathShearX; | ||
1142 | shape.PathShearY = addPacket.ObjectData.PathShearY; | ||
1143 | shape.PathSkew = addPacket.ObjectData.PathSkew; | ||
1144 | shape.ProfileBegin = addPacket.ObjectData.ProfileBegin; | ||
1145 | shape.ProfileEnd = addPacket.ObjectData.ProfileEnd; | ||
1146 | shape.Scale = addPacket.ObjectData.Scale; | ||
1147 | shape.PathCurve = addPacket.ObjectData.PathCurve; | ||
1148 | shape.ProfileCurve = addPacket.ObjectData.ProfileCurve; | ||
1149 | shape.ProfileHollow = addPacket.ObjectData.ProfileHollow; | ||
1150 | shape.PathRadiusOffset = addPacket.ObjectData.PathRadiusOffset; | ||
1151 | shape.PathRevolutions = addPacket.ObjectData.PathRevolutions; | ||
1152 | shape.PathTaperX = addPacket.ObjectData.PathTaperX; | ||
1153 | shape.PathTaperY = addPacket.ObjectData.PathTaperY; | ||
1154 | shape.PathTwist = addPacket.ObjectData.PathTwist; | ||
1155 | shape.PathTwistBegin = addPacket.ObjectData.PathTwistBegin; | ||
1156 | LLObject.TextureEntry ntex = new LLObject.TextureEntry(new LLUUID("00000000-0000-0000-9999-000000000005")); | ||
1157 | shape.TextureEntry = ntex.ToBytes(); | ||
1158 | return shape; | ||
1159 | } | ||
1160 | |||
1161 | public void SendLogoutPacket() | ||
1162 | { | ||
1163 | LogoutReplyPacket logReply = new LogoutReplyPacket(); | ||
1164 | logReply.AgentData.AgentID = AgentId; | ||
1165 | logReply.AgentData.SessionID = SessionId; | ||
1166 | logReply.InventoryData = new LogoutReplyPacket.InventoryDataBlock[1]; | ||
1167 | logReply.InventoryData[0] = new LogoutReplyPacket.InventoryDataBlock(); | ||
1168 | logReply.InventoryData[0].ItemID = LLUUID.Zero; | ||
1169 | |||
1170 | OutPacket(logReply, ThrottleOutPacketType.Task); | ||
1171 | } | ||
1172 | } | ||
1173 | } | ||