diff options
Diffstat (limited to 'OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs')
-rw-r--r-- | OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | 156 |
1 files changed, 118 insertions, 38 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs index 8ebcd92..0b0e458 100644 --- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs +++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs | |||
@@ -49,7 +49,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
49 | /// <param name='targetID'></param> | 49 | /// <param name='targetID'></param> |
50 | /// <param name='fromAgent'></param> | 50 | /// <param name='fromAgent'></param> |
51 | /// <param name='broadcast'></param> | 51 | /// <param name='broadcast'></param> |
52 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | 52 | public void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, |
53 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) | 53 | UUID fromID, UUID targetID, bool fromAgent, bool broadcast) |
54 | { | 54 | { |
55 | OSChatMessage args = new OSChatMessage(); | 55 | OSChatMessage args = new OSChatMessage(); |
@@ -60,6 +60,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
60 | args.Position = fromPos; | 60 | args.Position = fromPos; |
61 | args.SenderUUID = fromID; | 61 | args.SenderUUID = fromID; |
62 | args.Scene = this; | 62 | args.Scene = this; |
63 | args.Destination = targetID; | ||
63 | 64 | ||
64 | if (fromAgent) | 65 | if (fromAgent) |
65 | { | 66 | { |
@@ -74,7 +75,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
74 | } | 75 | } |
75 | 76 | ||
76 | args.From = fromName; | 77 | args.From = fromName; |
77 | args.TargetUUID = targetID; | 78 | //args. |
78 | 79 | ||
79 | // m_log.DebugFormat( | 80 | // m_log.DebugFormat( |
80 | // "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}", | 81 | // "[SCENE]: Sending message {0} on channel {1}, type {2} from {3}, broadcast {4}", |
@@ -85,7 +86,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
85 | else | 86 | else |
86 | EventManager.TriggerOnChatFromWorld(this, args); | 87 | EventManager.TriggerOnChatFromWorld(this, args); |
87 | } | 88 | } |
88 | 89 | ||
89 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, | 90 | protected void SimChat(byte[] message, ChatTypeEnum type, int channel, Vector3 fromPos, string fromName, |
90 | UUID fromID, bool fromAgent, bool broadcast) | 91 | UUID fromID, bool fromAgent, bool broadcast) |
91 | { | 92 | { |
@@ -129,19 +130,6 @@ namespace OpenSim.Region.Framework.Scenes | |||
129 | { | 130 | { |
130 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); | 131 | SimChat(message, type, channel, fromPos, fromName, fromID, fromAgent, true); |
131 | } | 132 | } |
132 | /// <summary> | ||
133 | /// | ||
134 | /// </summary> | ||
135 | /// <param name="message"></param> | ||
136 | /// <param name="type"></param> | ||
137 | /// <param name="fromPos"></param> | ||
138 | /// <param name="fromName"></param> | ||
139 | /// <param name="fromAgentID"></param> | ||
140 | /// <param name="targetID"></param> | ||
141 | public void SimChatToAgent(UUID targetID, byte[] message, Vector3 fromPos, string fromName, UUID fromID, bool fromAgent) | ||
142 | { | ||
143 | SimChat(message, ChatTypeEnum.Say, 0, fromPos, fromName, fromID, targetID, fromAgent, false); | ||
144 | } | ||
145 | 133 | ||
146 | /// <summary> | 134 | /// <summary> |
147 | /// | 135 | /// |
@@ -178,27 +166,47 @@ namespace OpenSim.Region.Framework.Scenes | |||
178 | /// <param name="remoteClient"></param> | 166 | /// <param name="remoteClient"></param> |
179 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) | 167 | public void SelectPrim(uint primLocalID, IClientAPI remoteClient) |
180 | { | 168 | { |
169 | /* | ||
170 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | ||
171 | |||
172 | if (null == part) | ||
173 | return; | ||
174 | |||
175 | if (part.IsRoot) | ||
176 | { | ||
177 | SceneObjectGroup sog = part.ParentGroup; | ||
178 | sog.SendPropertiesToClient(remoteClient); | ||
179 | |||
180 | // A prim is only tainted if it's allowed to be edited by the person clicking it. | ||
181 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) | ||
182 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) | ||
183 | { | ||
184 | sog.IsSelected = true; | ||
185 | EventManager.TriggerParcelPrimCountTainted(); | ||
186 | } | ||
187 | } | ||
188 | else | ||
189 | { | ||
190 | part.SendPropertiesToClient(remoteClient); | ||
191 | } | ||
192 | */ | ||
181 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | 193 | SceneObjectPart part = GetSceneObjectPart(primLocalID); |
182 | 194 | ||
183 | if (null == part) | 195 | if (null == part) |
184 | return; | 196 | return; |
185 | 197 | ||
186 | if (part.IsRoot) | 198 | SceneObjectGroup sog = part.ParentGroup; |
187 | { | 199 | if (sog == null) |
188 | SceneObjectGroup sog = part.ParentGroup; | 200 | return; |
189 | sog.SendPropertiesToClient(remoteClient); | ||
190 | sog.IsSelected = true; | ||
191 | 201 | ||
192 | // A prim is only tainted if it's allowed to be edited by the person clicking it. | 202 | part.SendPropertiesToClient(remoteClient); |
193 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) | 203 | |
194 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) | 204 | // A prim is only tainted if it's allowed to be edited by the person clicking it. |
195 | { | 205 | if (Permissions.CanEditObject(sog.UUID, remoteClient.AgentId) |
196 | EventManager.TriggerParcelPrimCountTainted(); | 206 | || Permissions.CanMoveObject(sog.UUID, remoteClient.AgentId)) |
197 | } | ||
198 | } | ||
199 | else | ||
200 | { | 207 | { |
201 | part.SendPropertiesToClient(remoteClient); | 208 | part.IsSelected = true; |
209 | EventManager.TriggerParcelPrimCountTainted(); | ||
202 | } | 210 | } |
203 | } | 211 | } |
204 | 212 | ||
@@ -251,7 +259,7 @@ namespace OpenSim.Region.Framework.Scenes | |||
251 | SceneObjectPart part = GetSceneObjectPart(primLocalID); | 259 | SceneObjectPart part = GetSceneObjectPart(primLocalID); |
252 | if (part == null) | 260 | if (part == null) |
253 | return; | 261 | return; |
254 | 262 | /* | |
255 | // A deselect packet contains all the local prims being deselected. However, since selection is still | 263 | // A deselect packet contains all the local prims being deselected. However, since selection is still |
256 | // group based we only want the root prim to trigger a full update - otherwise on objects with many prims | 264 | // group based we only want the root prim to trigger a full update - otherwise on objects with many prims |
257 | // we end up sending many duplicate ObjectUpdates | 265 | // we end up sending many duplicate ObjectUpdates |
@@ -262,7 +270,9 @@ namespace OpenSim.Region.Framework.Scenes | |||
262 | // handled by group, but by prim. Legacy cruft. | 270 | // handled by group, but by prim. Legacy cruft. |
263 | // TODO: Make selection flagging per prim! | 271 | // TODO: Make selection flagging per prim! |
264 | // | 272 | // |
265 | part.ParentGroup.IsSelected = false; | 273 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) |
274 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
275 | part.ParentGroup.IsSelected = false; | ||
266 | 276 | ||
267 | part.ParentGroup.ScheduleGroupForFullUpdate(); | 277 | part.ParentGroup.ScheduleGroupForFullUpdate(); |
268 | 278 | ||
@@ -279,6 +289,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
279 | part.UUID, remoteClient.AgentId)) | 289 | part.UUID, remoteClient.AgentId)) |
280 | EventManager.TriggerParcelPrimCountTainted(); | 290 | EventManager.TriggerParcelPrimCountTainted(); |
281 | } | 291 | } |
292 | */ | ||
293 | |||
294 | bool oldgprSelect = part.ParentGroup.IsSelected; | ||
295 | |||
296 | // This is wrong, wrong, wrong. Selection should not be | ||
297 | // handled by group, but by prim. Legacy cruft. | ||
298 | // TODO: Make selection flagging per prim! | ||
299 | // | ||
300 | if (Permissions.CanEditObject(part.ParentGroup.UUID, remoteClient.AgentId) | ||
301 | || Permissions.CanMoveObject(part.ParentGroup.UUID, remoteClient.AgentId)) | ||
302 | { | ||
303 | part.IsSelected = false; | ||
304 | if (!part.ParentGroup.IsAttachment && oldgprSelect != part.ParentGroup.IsSelected) | ||
305 | EventManager.TriggerParcelPrimCountTainted(); | ||
306 | } | ||
307 | |||
308 | // restore targetOmega | ||
309 | if (part.AngularVelocity != Vector3.Zero) | ||
310 | part.ScheduleTerseUpdate(); | ||
311 | |||
282 | } | 312 | } |
283 | 313 | ||
284 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, | 314 | public virtual void ProcessMoneyTransferRequest(UUID source, UUID destination, int amount, |
@@ -433,12 +463,26 @@ namespace OpenSim.Region.Framework.Scenes | |||
433 | } | 463 | } |
434 | }); | 464 | }); |
435 | } | 465 | } |
436 | 466 | ||
437 | private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) | 467 | private bool ShouldSendDiscardableEffect(IClientAPI thisClient, ScenePresence other) |
438 | { | 468 | { |
439 | return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; | 469 | return Vector3.Distance(other.CameraPosition, thisClient.SceneAgent.AbsolutePosition) < 10; |
440 | } | 470 | } |
441 | 471 | ||
472 | private class DescendentsRequestData | ||
473 | { | ||
474 | public IClientAPI RemoteClient; | ||
475 | public UUID FolderID; | ||
476 | public UUID OwnerID; | ||
477 | public bool FetchFolders; | ||
478 | public bool FetchItems; | ||
479 | public int SortOrder; | ||
480 | } | ||
481 | |||
482 | private Queue<DescendentsRequestData> m_descendentsRequestQueue = new Queue<DescendentsRequestData>(); | ||
483 | private Object m_descendentsRequestLock = new Object(); | ||
484 | private bool m_descendentsRequestProcessing = false; | ||
485 | |||
442 | /// <summary> | 486 | /// <summary> |
443 | /// Tell the client about the various child items and folders contained in the requested folder. | 487 | /// Tell the client about the various child items and folders contained in the requested folder. |
444 | /// </summary> | 488 | /// </summary> |
@@ -475,11 +519,31 @@ namespace OpenSim.Region.Framework.Scenes | |||
475 | } | 519 | } |
476 | } | 520 | } |
477 | 521 | ||
478 | // We're going to send the reply async, because there may be | 522 | lock (m_descendentsRequestLock) |
479 | // an enormous quantity of packets -- basically the entire inventory! | 523 | { |
480 | // We don't want to block the client thread while all that is happening. | 524 | if (!m_descendentsRequestProcessing) |
481 | SendInventoryDelegate d = SendInventoryAsync; | 525 | { |
482 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | 526 | m_descendentsRequestProcessing = true; |
527 | |||
528 | // We're going to send the reply async, because there may be | ||
529 | // an enormous quantity of packets -- basically the entire inventory! | ||
530 | // We don't want to block the client thread while all that is happening. | ||
531 | SendInventoryDelegate d = SendInventoryAsync; | ||
532 | d.BeginInvoke(remoteClient, folderID, ownerID, fetchFolders, fetchItems, sortOrder, SendInventoryComplete, d); | ||
533 | |||
534 | return; | ||
535 | } | ||
536 | |||
537 | DescendentsRequestData req = new DescendentsRequestData(); | ||
538 | req.RemoteClient = remoteClient; | ||
539 | req.FolderID = folderID; | ||
540 | req.OwnerID = ownerID; | ||
541 | req.FetchFolders = fetchFolders; | ||
542 | req.FetchItems = fetchItems; | ||
543 | req.SortOrder = sortOrder; | ||
544 | |||
545 | m_descendentsRequestQueue.Enqueue(req); | ||
546 | } | ||
483 | } | 547 | } |
484 | 548 | ||
485 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); | 549 | delegate void SendInventoryDelegate(IClientAPI remoteClient, UUID folderID, UUID ownerID, bool fetchFolders, bool fetchItems, int sortOrder); |
@@ -496,12 +560,28 @@ namespace OpenSim.Region.Framework.Scenes | |||
496 | string.Format( | 560 | string.Format( |
497 | "[AGENT INVENTORY]: Error in SendInventoryAsync() for {0} with folder ID {1}. Exception ", e)); | 561 | "[AGENT INVENTORY]: Error in SendInventoryAsync() for {0} with folder ID {1}. Exception ", e)); |
498 | } | 562 | } |
563 | Thread.Sleep(20); | ||
499 | } | 564 | } |
500 | 565 | ||
501 | void SendInventoryComplete(IAsyncResult iar) | 566 | void SendInventoryComplete(IAsyncResult iar) |
502 | { | 567 | { |
503 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; | 568 | SendInventoryDelegate d = (SendInventoryDelegate)iar.AsyncState; |
504 | d.EndInvoke(iar); | 569 | d.EndInvoke(iar); |
570 | |||
571 | lock (m_descendentsRequestLock) | ||
572 | { | ||
573 | if (m_descendentsRequestQueue.Count > 0) | ||
574 | { | ||
575 | DescendentsRequestData req = m_descendentsRequestQueue.Dequeue(); | ||
576 | |||
577 | d = SendInventoryAsync; | ||
578 | d.BeginInvoke(req.RemoteClient, req.FolderID, req.OwnerID, req.FetchFolders, req.FetchItems, req.SortOrder, SendInventoryComplete, d); | ||
579 | |||
580 | return; | ||
581 | } | ||
582 | |||
583 | m_descendentsRequestProcessing = false; | ||
584 | } | ||
505 | } | 585 | } |
506 | 586 | ||
507 | /// <summary> | 587 | /// <summary> |