aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/Framework/Scenes
diff options
context:
space:
mode:
authorMelanie2010-03-03 02:07:03 +0000
committerMelanie2010-03-03 02:07:03 +0000
commit028a87fe37002e7a0611f66babf1deee46c83804 (patch)
tree387aec499fd60c2012bed8148e6a2ddc847c3d95 /OpenSim/Region/Framework/Scenes
parentRevert "test" (diff)
parentFixes Region.Framework tests. Although these tests don't fail, they need to b... (diff)
downloadopensim-SC_OLD-028a87fe37002e7a0611f66babf1deee46c83804.zip
opensim-SC_OLD-028a87fe37002e7a0611f66babf1deee46c83804.tar.gz
opensim-SC_OLD-028a87fe37002e7a0611f66babf1deee46c83804.tar.bz2
opensim-SC_OLD-028a87fe37002e7a0611f66babf1deee46c83804.tar.xz
Merge branch 'master' into careminster-presence-refactor
This brings careminster on the level of master. To be tested
Diffstat (limited to 'OpenSim/Region/Framework/Scenes')
-rw-r--r--OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs5
-rw-r--r--OpenSim/Region/Framework/Scenes/EventManager.cs199
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs265
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs174
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs77
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs391
-rw-r--r--OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs56
-rw-r--r--OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.Inventory.cs590
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs73
-rw-r--r--OpenSim/Region/Framework/Scenes/Scene.cs661
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneBase.cs15
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs1229
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneGraph.cs43
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneManager.cs4
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs183
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPart.cs342
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs7
-rw-r--r--OpenSim/Region/Framework/Scenes/ScenePresence.cs186
-rw-r--r--OpenSim/Region/Framework/Scenes/SceneViewer.cs1
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs21
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs3
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs14
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs9
-rw-r--r--OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs2
-rw-r--r--OpenSim/Region/Framework/Scenes/UndoState.cs79
28 files changed, 1157 insertions, 3492 deletions
diff --git a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
index e98f0e7..fd7d44f 100644
--- a/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
+++ b/OpenSim/Region/Framework/Scenes/Animation/ScenePresenceAnimator.cs
@@ -385,7 +385,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
385 } 385 }
386 } 386 }
387 387
388 AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation); 388 AssetBase Animasset = new AssetBase(UUID.Random(), "Random Animation", (sbyte)AssetType.Animation, m_scenePresence.UUID.ToString());
389 Animasset.Data = anim.ToBytes(); 389 Animasset.Data = anim.ToBytes();
390 Animasset.Temporary = true; 390 Animasset.Temporary = true;
391 Animasset.Local = true; 391 Animasset.Local = true;
@@ -419,15 +419,12 @@ namespace OpenSim.Region.Framework.Scenes.Animation
419 { 419 {
420 if (m_scenePresence.IsChildAgent) 420 if (m_scenePresence.IsChildAgent)
421 return; 421 return;
422
423 UUID[] animIDs;
424 int[] sequenceNums;
425 UUID[] objectIDs;
426 422
427 m_animations.GetArrays(out animIDs, out sequenceNums, out objectIDs); 423 m_scenePresence.Scene.ForEachScenePresence(
428 424 delegate(ScenePresence SP)
429 m_scenePresence.ControllingClient.SendAnimations( 425 {
430 animIDs, sequenceNums, m_scenePresence.ControllingClient.AgentId, objectIDs); 426 SP.Animator.SendAnimPack();
427 });
431 } 428 }
432 429
433 /// <summary> 430 /// <summary>
diff --git a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
index 9a7863b..c08b961 100644
--- a/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
+++ b/OpenSim/Region/Framework/Scenes/AsyncSceneObjectGroupDeleter.cs
@@ -32,6 +32,7 @@ using System.Timers;
32using log4net; 32using log4net;
33using OpenMetaverse; 33using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Region.Framework.Interfaces;
35 36
36namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
37{ 38{
@@ -137,7 +138,9 @@ namespace OpenSim.Region.Framework.Scenes
137 138
138 try 139 try
139 { 140 {
140 m_scene.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient); 141 IInventoryAccessModule invAccess = m_scene.RequestModuleInterface<IInventoryAccessModule>();
142 if (invAccess != null)
143 invAccess.DeleteToInventory(x.action, x.folderID, x.objectGroup, x.remoteClient);
141 if (x.permissionToDelete) 144 if (x.permissionToDelete)
142 m_scene.DeleteSceneObject(x.objectGroup, false); 145 m_scene.DeleteSceneObject(x.objectGroup, false);
143 } 146 }
diff --git a/OpenSim/Region/Framework/Scenes/EventManager.cs b/OpenSim/Region/Framework/Scenes/EventManager.cs
index 22909bc..3cce53d 100644
--- a/OpenSim/Region/Framework/Scenes/EventManager.cs
+++ b/OpenSim/Region/Framework/Scenes/EventManager.cs
@@ -66,13 +66,16 @@ namespace OpenSim.Region.Framework.Scenes
66 public event OnClientConnectCoreDelegate OnClientConnect; 66 public event OnClientConnectCoreDelegate OnClientConnect;
67 67
68 public delegate void OnNewClientDelegate(IClientAPI client); 68 public delegate void OnNewClientDelegate(IClientAPI client);
69 69
70 /// <summary> 70 /// <summary>
71 /// Deprecated in favour of OnClientConnect. 71 /// Deprecated in favour of OnClientConnect.
72 /// Will be marked Obsolete after IClientCore has 100% of IClientAPI interfaces. 72 /// Will be marked Obsolete after IClientCore has 100% of IClientAPI interfaces.
73 /// </summary> 73 /// </summary>
74 public event OnNewClientDelegate OnNewClient; 74 public event OnNewClientDelegate OnNewClient;
75 75
76 public delegate void OnClientLoginDelegate(IClientAPI client);
77 public event OnClientLoginDelegate OnClientLogin;
78
76 public delegate void OnNewPresenceDelegate(ScenePresence presence); 79 public delegate void OnNewPresenceDelegate(ScenePresence presence);
77 80
78 public event OnNewPresenceDelegate OnNewPresence; 81 public event OnNewPresenceDelegate OnNewPresence;
@@ -213,7 +216,7 @@ namespace OpenSim.Region.Framework.Scenes
213 /// Triggered when an object or attachment enters a scene 216 /// Triggered when an object or attachment enters a scene
214 /// </summary> 217 /// </summary>
215 public event OnIncomingSceneObjectDelegate OnIncomingSceneObject; 218 public event OnIncomingSceneObjectDelegate OnIncomingSceneObject;
216 public delegate void OnIncomingSceneObjectDelegate(SceneObjectGroup so); 219 public delegate void OnIncomingSceneObjectDelegate(SceneObjectGroup so);
217 220
218 public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel); 221 public delegate void NewInventoryItemUploadComplete(UUID avatarID, UUID assetID, string name, int userlevel);
219 222
@@ -417,7 +420,7 @@ namespace OpenSim.Region.Framework.Scenes
417 } 420 }
418 } 421 }
419 } 422 }
420 } 423 }
421 424
422 public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID) 425 public void TriggerGetScriptRunning(IClientAPI controllingClient, UUID objectID, UUID itemID)
423 { 426 {
@@ -437,7 +440,7 @@ namespace OpenSim.Region.Framework.Scenes
437 e.Message, e.StackTrace); 440 e.Message, e.StackTrace);
438 } 441 }
439 } 442 }
440 } 443 }
441 } 444 }
442 445
443 public void TriggerOnScriptChangedEvent(uint localID, uint change) 446 public void TriggerOnScriptChangedEvent(uint localID, uint change)
@@ -458,7 +461,7 @@ namespace OpenSim.Region.Framework.Scenes
458 e.Message, e.StackTrace); 461 e.Message, e.StackTrace);
459 } 462 }
460 } 463 }
461 } 464 }
462 } 465 }
463 466
464 public void TriggerOnClientMovement(ScenePresence avatar) 467 public void TriggerOnClientMovement(ScenePresence avatar)
@@ -479,7 +482,7 @@ namespace OpenSim.Region.Framework.Scenes
479 e.Message, e.StackTrace); 482 e.Message, e.StackTrace);
480 } 483 }
481 } 484 }
482 } 485 }
483 } 486 }
484 487
485 public void TriggerPermissionError(UUID user, string reason) 488 public void TriggerPermissionError(UUID user, string reason)
@@ -500,7 +503,7 @@ namespace OpenSim.Region.Framework.Scenes
500 e.Message, e.StackTrace); 503 e.Message, e.StackTrace);
501 } 504 }
502 } 505 }
503 } 506 }
504 } 507 }
505 508
506 public void TriggerOnPluginConsole(string[] args) 509 public void TriggerOnPluginConsole(string[] args)
@@ -521,7 +524,7 @@ namespace OpenSim.Region.Framework.Scenes
521 e.Message, e.StackTrace); 524 e.Message, e.StackTrace);
522 } 525 }
523 } 526 }
524 } 527 }
525 } 528 }
526 529
527 public void TriggerOnFrame() 530 public void TriggerOnFrame()
@@ -542,11 +545,11 @@ namespace OpenSim.Region.Framework.Scenes
542 e.Message, e.StackTrace); 545 e.Message, e.StackTrace);
543 } 546 }
544 } 547 }
545 } 548 }
546 } 549 }
547 550
548 public void TriggerOnNewClient(IClientAPI client) 551 public void TriggerOnNewClient(IClientAPI client)
549 { 552 {
550 OnNewClientDelegate handlerNewClient = OnNewClient; 553 OnNewClientDelegate handlerNewClient = OnNewClient;
551 if (handlerNewClient != null) 554 if (handlerNewClient != null)
552 { 555 {
@@ -563,10 +566,10 @@ namespace OpenSim.Region.Framework.Scenes
563 e.Message, e.StackTrace); 566 e.Message, e.StackTrace);
564 } 567 }
565 } 568 }
566 } 569 }
567 570
568 if (client is IClientCore) 571 if (client is IClientCore)
569 { 572 {
570 OnClientConnectCoreDelegate handlerClientConnect = OnClientConnect; 573 OnClientConnectCoreDelegate handlerClientConnect = OnClientConnect;
571 if (handlerClientConnect != null) 574 if (handlerClientConnect != null)
572 { 575 {
@@ -583,10 +586,32 @@ namespace OpenSim.Region.Framework.Scenes
583 e.Message, e.StackTrace); 586 e.Message, e.StackTrace);
584 } 587 }
585 } 588 }
586 } 589 }
587 } 590 }
588 } 591 }
589 592
593 public void TriggerOnClientLogin(IClientAPI client)
594 {
595 OnClientLoginDelegate handlerClientLogin = OnClientLogin;
596 if (handlerClientLogin != null)
597 {
598 foreach (OnClientLoginDelegate d in handlerClientLogin.GetInvocationList())
599 {
600 try
601 {
602 d(client);
603 }
604 catch (Exception e)
605 {
606 m_log.ErrorFormat(
607 "[EVENT MANAGER]: Delegate for TriggerOnClientLogin failed - continuing. {0} {1}",
608 e.Message, e.StackTrace);
609 }
610 }
611 }
612
613 }
614
590 public void TriggerOnNewPresence(ScenePresence presence) 615 public void TriggerOnNewPresence(ScenePresence presence)
591 { 616 {
592 OnNewPresenceDelegate handlerNewPresence = OnNewPresence; 617 OnNewPresenceDelegate handlerNewPresence = OnNewPresence;
@@ -605,11 +630,11 @@ namespace OpenSim.Region.Framework.Scenes
605 e.Message, e.StackTrace); 630 e.Message, e.StackTrace);
606 } 631 }
607 } 632 }
608 } 633 }
609 } 634 }
610 635
611 public void TriggerOnRemovePresence(UUID agentId) 636 public void TriggerOnRemovePresence(UUID agentId)
612 { 637 {
613 OnRemovePresenceDelegate handlerRemovePresence = OnRemovePresence; 638 OnRemovePresenceDelegate handlerRemovePresence = OnRemovePresence;
614 if (handlerRemovePresence != null) 639 if (handlerRemovePresence != null)
615 { 640 {
@@ -626,11 +651,11 @@ namespace OpenSim.Region.Framework.Scenes
626 e.Message, e.StackTrace); 651 e.Message, e.StackTrace);
627 } 652 }
628 } 653 }
629 } 654 }
630 } 655 }
631 656
632 public void TriggerOnBackup(IRegionDataStore dstore) 657 public void TriggerOnBackup(IRegionDataStore dstore)
633 { 658 {
634 OnBackupDelegate handlerOnAttach = OnBackup; 659 OnBackupDelegate handlerOnAttach = OnBackup;
635 if (handlerOnAttach != null) 660 if (handlerOnAttach != null)
636 { 661 {
@@ -647,7 +672,7 @@ namespace OpenSim.Region.Framework.Scenes
647 e.Message, e.StackTrace); 672 e.Message, e.StackTrace);
648 } 673 }
649 } 674 }
650 } 675 }
651 } 676 }
652 677
653 public void TriggerParcelPrimCountUpdate() 678 public void TriggerParcelPrimCountUpdate()
@@ -668,7 +693,7 @@ namespace OpenSim.Region.Framework.Scenes
668 e.Message, e.StackTrace); 693 e.Message, e.StackTrace);
669 } 694 }
670 } 695 }
671 } 696 }
672 } 697 }
673 698
674 public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs args) 699 public void TriggerMoneyTransfer(Object sender, MoneyTransferArgs args)
@@ -689,7 +714,7 @@ namespace OpenSim.Region.Framework.Scenes
689 e.Message, e.StackTrace); 714 e.Message, e.StackTrace);
690 } 715 }
691 } 716 }
692 } 717 }
693 } 718 }
694 719
695 public void TriggerTerrainTick() 720 public void TriggerTerrainTick()
@@ -710,7 +735,7 @@ namespace OpenSim.Region.Framework.Scenes
710 e.Message, e.StackTrace); 735 e.Message, e.StackTrace);
711 } 736 }
712 } 737 }
713 } 738 }
714 } 739 }
715 740
716 public void TriggerParcelPrimCountAdd(SceneObjectGroup obj) 741 public void TriggerParcelPrimCountAdd(SceneObjectGroup obj)
@@ -731,7 +756,7 @@ namespace OpenSim.Region.Framework.Scenes
731 e.Message, e.StackTrace); 756 e.Message, e.StackTrace);
732 } 757 }
733 } 758 }
734 } 759 }
735 } 760 }
736 761
737 public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj) 762 public void TriggerObjectBeingRemovedFromScene(SceneObjectGroup obj)
@@ -752,11 +777,11 @@ namespace OpenSim.Region.Framework.Scenes
752 e.Message, e.StackTrace); 777 e.Message, e.StackTrace);
753 } 778 }
754 } 779 }
755 } 780 }
756 } 781 }
757 782
758 public void TriggerShutdown() 783 public void TriggerShutdown()
759 { 784 {
760 OnShutdownDelegate handlerShutdown = OnShutdown; 785 OnShutdownDelegate handlerShutdown = OnShutdown;
761 if (handlerShutdown != null) 786 if (handlerShutdown != null)
762 { 787 {
@@ -773,11 +798,11 @@ namespace OpenSim.Region.Framework.Scenes
773 e.Message, e.StackTrace); 798 e.Message, e.StackTrace);
774 } 799 }
775 } 800 }
776 } 801 }
777 } 802 }
778 803
779 public void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) 804 public void TriggerObjectGrab(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
780 { 805 {
781 ObjectGrabDelegate handlerObjectGrab = OnObjectGrab; 806 ObjectGrabDelegate handlerObjectGrab = OnObjectGrab;
782 if (handlerObjectGrab != null) 807 if (handlerObjectGrab != null)
783 { 808 {
@@ -794,11 +819,11 @@ namespace OpenSim.Region.Framework.Scenes
794 e.Message, e.StackTrace); 819 e.Message, e.StackTrace);
795 } 820 }
796 } 821 }
797 } 822 }
798 } 823 }
799 824
800 public void TriggerObjectGrabbing(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) 825 public void TriggerObjectGrabbing(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
801 { 826 {
802 ObjectGrabDelegate handlerObjectGrabbing = OnObjectGrabbing; 827 ObjectGrabDelegate handlerObjectGrabbing = OnObjectGrabbing;
803 if (handlerObjectGrabbing != null) 828 if (handlerObjectGrabbing != null)
804 { 829 {
@@ -815,11 +840,11 @@ namespace OpenSim.Region.Framework.Scenes
815 e.Message, e.StackTrace); 840 e.Message, e.StackTrace);
816 } 841 }
817 } 842 }
818 } 843 }
819 } 844 }
820 845
821 public void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs) 846 public void TriggerObjectDeGrab(uint localID, uint originalID, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs)
822 { 847 {
823 ObjectDeGrabDelegate handlerObjectDeGrab = OnObjectDeGrab; 848 ObjectDeGrabDelegate handlerObjectDeGrab = OnObjectDeGrab;
824 if (handlerObjectDeGrab != null) 849 if (handlerObjectDeGrab != null)
825 { 850 {
@@ -836,11 +861,11 @@ namespace OpenSim.Region.Framework.Scenes
836 e.Message, e.StackTrace); 861 e.Message, e.StackTrace);
837 } 862 }
838 } 863 }
839 } 864 }
840 } 865 }
841 866
842 public void TriggerScriptReset(uint localID, UUID itemID) 867 public void TriggerScriptReset(uint localID, UUID itemID)
843 { 868 {
844 ScriptResetDelegate handlerScriptReset = OnScriptReset; 869 ScriptResetDelegate handlerScriptReset = OnScriptReset;
845 if (handlerScriptReset != null) 870 if (handlerScriptReset != null)
846 { 871 {
@@ -857,11 +882,11 @@ namespace OpenSim.Region.Framework.Scenes
857 e.Message, e.StackTrace); 882 e.Message, e.StackTrace);
858 } 883 }
859 } 884 }
860 } 885 }
861 } 886 }
862 887
863 public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource) 888 public void TriggerRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource)
864 { 889 {
865 NewRezScript handlerRezScript = OnRezScript; 890 NewRezScript handlerRezScript = OnRezScript;
866 if (handlerRezScript != null) 891 if (handlerRezScript != null)
867 { 892 {
@@ -878,7 +903,7 @@ namespace OpenSim.Region.Framework.Scenes
878 e.Message, e.StackTrace); 903 e.Message, e.StackTrace);
879 } 904 }
880 } 905 }
881 } 906 }
882 } 907 }
883 908
884 public void TriggerStartScript(uint localID, UUID itemID) 909 public void TriggerStartScript(uint localID, UUID itemID)
@@ -899,7 +924,7 @@ namespace OpenSim.Region.Framework.Scenes
899 e.Message, e.StackTrace); 924 e.Message, e.StackTrace);
900 } 925 }
901 } 926 }
902 } 927 }
903 } 928 }
904 929
905 public void TriggerStopScript(uint localID, UUID itemID) 930 public void TriggerStopScript(uint localID, UUID itemID)
@@ -920,11 +945,11 @@ namespace OpenSim.Region.Framework.Scenes
920 e.Message, e.StackTrace); 945 e.Message, e.StackTrace);
921 } 946 }
922 } 947 }
923 } 948 }
924 } 949 }
925 950
926 public void TriggerRemoveScript(uint localID, UUID itemID) 951 public void TriggerRemoveScript(uint localID, UUID itemID)
927 { 952 {
928 RemoveScript handlerRemoveScript = OnRemoveScript; 953 RemoveScript handlerRemoveScript = OnRemoveScript;
929 if (handlerRemoveScript != null) 954 if (handlerRemoveScript != null)
930 { 955 {
@@ -941,7 +966,7 @@ namespace OpenSim.Region.Framework.Scenes
941 e.Message, e.StackTrace); 966 e.Message, e.StackTrace);
942 } 967 }
943 } 968 }
944 } 969 }
945 } 970 }
946 971
947 public bool TriggerGroupMove(UUID groupID, Vector3 delta) 972 public bool TriggerGroupMove(UUID groupID, Vector3 delta)
@@ -1040,7 +1065,7 @@ namespace OpenSim.Region.Framework.Scenes
1040 e.Message, e.StackTrace); 1065 e.Message, e.StackTrace);
1041 } 1066 }
1042 } 1067 }
1043 } 1068 }
1044 } 1069 }
1045 1070
1046 public void TriggerLandObjectAdded(ILandObject newParcel) 1071 public void TriggerLandObjectAdded(ILandObject newParcel)
@@ -1061,7 +1086,7 @@ namespace OpenSim.Region.Framework.Scenes
1061 e.Message, e.StackTrace); 1086 e.Message, e.StackTrace);
1062 } 1087 }
1063 } 1088 }
1064 } 1089 }
1065 } 1090 }
1066 1091
1067 public void TriggerLandObjectRemoved(UUID globalID) 1092 public void TriggerLandObjectRemoved(UUID globalID)
@@ -1082,7 +1107,7 @@ namespace OpenSim.Region.Framework.Scenes
1082 e.Message, e.StackTrace); 1107 e.Message, e.StackTrace);
1083 } 1108 }
1084 } 1109 }
1085 } 1110 }
1086 } 1111 }
1087 1112
1088 public void TriggerLandObjectUpdated(uint localParcelID, ILandObject newParcel) 1113 public void TriggerLandObjectUpdated(uint localParcelID, ILandObject newParcel)
@@ -1108,7 +1133,7 @@ namespace OpenSim.Region.Framework.Scenes
1108 e.Message, e.StackTrace); 1133 e.Message, e.StackTrace);
1109 } 1134 }
1110 } 1135 }
1111 } 1136 }
1112 } 1137 }
1113 1138
1114 public void TriggerIncomingInstantMessage(GridInstantMessage message) 1139 public void TriggerIncomingInstantMessage(GridInstantMessage message)
@@ -1129,7 +1154,7 @@ namespace OpenSim.Region.Framework.Scenes
1129 e.Message, e.StackTrace); 1154 e.Message, e.StackTrace);
1130 } 1155 }
1131 } 1156 }
1132 } 1157 }
1133 } 1158 }
1134 1159
1135 public void TriggerUnhandledInstantMessage(GridInstantMessage message) 1160 public void TriggerUnhandledInstantMessage(GridInstantMessage message)
@@ -1150,7 +1175,7 @@ namespace OpenSim.Region.Framework.Scenes
1150 e.Message, e.StackTrace); 1175 e.Message, e.StackTrace);
1151 } 1176 }
1152 } 1177 }
1153 } 1178 }
1154 } 1179 }
1155 1180
1156 public void TriggerClientClosed(UUID ClientID, Scene scene) 1181 public void TriggerClientClosed(UUID ClientID, Scene scene)
@@ -1171,7 +1196,7 @@ namespace OpenSim.Region.Framework.Scenes
1171 e.Message, e.StackTrace); 1196 e.Message, e.StackTrace);
1172 } 1197 }
1173 } 1198 }
1174 } 1199 }
1175 } 1200 }
1176 1201
1177 public void TriggerOnMakeChildAgent(ScenePresence presence) 1202 public void TriggerOnMakeChildAgent(ScenePresence presence)
@@ -1192,7 +1217,7 @@ namespace OpenSim.Region.Framework.Scenes
1192 e.Message, e.StackTrace); 1217 e.Message, e.StackTrace);
1193 } 1218 }
1194 } 1219 }
1195 } 1220 }
1196 } 1221 }
1197 1222
1198 public void TriggerOnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID user) 1223 public void TriggerOnSendNewWindlightProfileTargeted(RegionMeta7WindlightData wl, UUID user)
@@ -1231,7 +1256,7 @@ namespace OpenSim.Region.Framework.Scenes
1231 e.Message, e.StackTrace); 1256 e.Message, e.StackTrace);
1232 } 1257 }
1233 } 1258 }
1234 } 1259 }
1235 } 1260 }
1236 1261
1237 public void TriggerOnIncomingSceneObject(SceneObjectGroup so) 1262 public void TriggerOnIncomingSceneObject(SceneObjectGroup so)
@@ -1251,12 +1276,12 @@ namespace OpenSim.Region.Framework.Scenes
1251 "[EVENT MANAGER]: Delegate for TriggerOnIncomingSceneObject failed - continuing. {0} {1}", 1276 "[EVENT MANAGER]: Delegate for TriggerOnIncomingSceneObject failed - continuing. {0} {1}",
1252 e.Message, e.StackTrace); 1277 e.Message, e.StackTrace);
1253 } 1278 }
1254 } 1279 }
1255 } 1280 }
1256 } 1281 }
1257 1282
1258 public void TriggerOnRegisterCaps(UUID agentID, Caps caps) 1283 public void TriggerOnRegisterCaps(UUID agentID, Caps caps)
1259 { 1284 {
1260 RegisterCapsEvent handlerRegisterCaps = OnRegisterCaps; 1285 RegisterCapsEvent handlerRegisterCaps = OnRegisterCaps;
1261 if (handlerRegisterCaps != null) 1286 if (handlerRegisterCaps != null)
1262 { 1287 {
@@ -1273,7 +1298,7 @@ namespace OpenSim.Region.Framework.Scenes
1273 e.Message, e.StackTrace); 1298 e.Message, e.StackTrace);
1274 } 1299 }
1275 } 1300 }
1276 } 1301 }
1277 } 1302 }
1278 1303
1279 public void TriggerOnDeregisterCaps(UUID agentID, Caps caps) 1304 public void TriggerOnDeregisterCaps(UUID agentID, Caps caps)
@@ -1294,7 +1319,7 @@ namespace OpenSim.Region.Framework.Scenes
1294 e.Message, e.StackTrace); 1319 e.Message, e.StackTrace);
1295 } 1320 }
1296 } 1321 }
1297 } 1322 }
1298 } 1323 }
1299 1324
1300 public void TriggerOnNewInventoryItemUploadComplete(UUID agentID, UUID AssetID, String AssetName, int userlevel) 1325 public void TriggerOnNewInventoryItemUploadComplete(UUID agentID, UUID AssetID, String AssetName, int userlevel)
@@ -1315,7 +1340,7 @@ namespace OpenSim.Region.Framework.Scenes
1315 e.Message, e.StackTrace); 1340 e.Message, e.StackTrace);
1316 } 1341 }
1317 } 1342 }
1318 } 1343 }
1319 } 1344 }
1320 1345
1321 public void TriggerLandBuy(Object sender, LandBuyArgs args) 1346 public void TriggerLandBuy(Object sender, LandBuyArgs args)
@@ -1336,7 +1361,7 @@ namespace OpenSim.Region.Framework.Scenes
1336 e.Message, e.StackTrace); 1361 e.Message, e.StackTrace);
1337 } 1362 }
1338 } 1363 }
1339 } 1364 }
1340 } 1365 }
1341 1366
1342 public void TriggerValidateLandBuy(Object sender, LandBuyArgs args) 1367 public void TriggerValidateLandBuy(Object sender, LandBuyArgs args)
@@ -1357,11 +1382,11 @@ namespace OpenSim.Region.Framework.Scenes
1357 e.Message, e.StackTrace); 1382 e.Message, e.StackTrace);
1358 } 1383 }
1359 } 1384 }
1360 } 1385 }
1361 } 1386 }
1362 1387
1363 public void TriggerAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 currentpos) 1388 public void TriggerAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 currentpos)
1364 { 1389 {
1365 ScriptAtTargetEvent handlerScriptAtTargetEvent = OnScriptAtTargetEvent; 1390 ScriptAtTargetEvent handlerScriptAtTargetEvent = OnScriptAtTargetEvent;
1366 if (handlerScriptAtTargetEvent != null) 1391 if (handlerScriptAtTargetEvent != null)
1367 { 1392 {
@@ -1378,7 +1403,7 @@ namespace OpenSim.Region.Framework.Scenes
1378 e.Message, e.StackTrace); 1403 e.Message, e.StackTrace);
1379 } 1404 }
1380 } 1405 }
1381 } 1406 }
1382 } 1407 }
1383 1408
1384 public void TriggerNotAtTargetEvent(uint localID) 1409 public void TriggerNotAtTargetEvent(uint localID)
@@ -1399,11 +1424,11 @@ namespace OpenSim.Region.Framework.Scenes
1399 e.Message, e.StackTrace); 1424 e.Message, e.StackTrace);
1400 } 1425 }
1401 } 1426 }
1402 } 1427 }
1403 } 1428 }
1404 1429
1405 public void TriggerAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion currentrot) 1430 public void TriggerAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion currentrot)
1406 { 1431 {
1407 ScriptAtRotTargetEvent handlerScriptAtRotTargetEvent = OnScriptAtRotTargetEvent; 1432 ScriptAtRotTargetEvent handlerScriptAtRotTargetEvent = OnScriptAtRotTargetEvent;
1408 if (handlerScriptAtRotTargetEvent != null) 1433 if (handlerScriptAtRotTargetEvent != null)
1409 { 1434 {
@@ -1420,7 +1445,7 @@ namespace OpenSim.Region.Framework.Scenes
1420 e.Message, e.StackTrace); 1445 e.Message, e.StackTrace);
1421 } 1446 }
1422 } 1447 }
1423 } 1448 }
1424 } 1449 }
1425 1450
1426 public void TriggerNotAtRotTargetEvent(uint localID) 1451 public void TriggerNotAtRotTargetEvent(uint localID)
@@ -1441,7 +1466,7 @@ namespace OpenSim.Region.Framework.Scenes
1441 e.Message, e.StackTrace); 1466 e.Message, e.StackTrace);
1442 } 1467 }
1443 } 1468 }
1444 } 1469 }
1445 } 1470 }
1446 1471
1447 public void TriggerRequestChangeWaterHeight(float height) 1472 public void TriggerRequestChangeWaterHeight(float height)
@@ -1462,7 +1487,7 @@ namespace OpenSim.Region.Framework.Scenes
1462 e.Message, e.StackTrace); 1487 e.Message, e.StackTrace);
1463 } 1488 }
1464 } 1489 }
1465 } 1490 }
1466 } 1491 }
1467 1492
1468 public void TriggerAvatarKill(uint KillerObjectLocalID, ScenePresence DeadAvatar) 1493 public void TriggerAvatarKill(uint KillerObjectLocalID, ScenePresence DeadAvatar)
@@ -1483,7 +1508,7 @@ namespace OpenSim.Region.Framework.Scenes
1483 e.Message, e.StackTrace); 1508 e.Message, e.StackTrace);
1484 } 1509 }
1485 } 1510 }
1486 } 1511 }
1487 } 1512 }
1488 1513
1489 public void TriggerSignificantClientMovement(IClientAPI client) 1514 public void TriggerSignificantClientMovement(IClientAPI client)
@@ -1504,7 +1529,7 @@ namespace OpenSim.Region.Framework.Scenes
1504 e.Message, e.StackTrace); 1529 e.Message, e.StackTrace);
1505 } 1530 }
1506 } 1531 }
1507 } 1532 }
1508 } 1533 }
1509 1534
1510 public void TriggerOnChatFromWorld(Object sender, OSChatMessage chat) 1535 public void TriggerOnChatFromWorld(Object sender, OSChatMessage chat)
@@ -1525,7 +1550,7 @@ namespace OpenSim.Region.Framework.Scenes
1525 e.Message, e.StackTrace); 1550 e.Message, e.StackTrace);
1526 } 1551 }
1527 } 1552 }
1528 } 1553 }
1529 } 1554 }
1530 1555
1531 public void TriggerOnChatFromClient(Object sender, OSChatMessage chat) 1556 public void TriggerOnChatFromClient(Object sender, OSChatMessage chat)
@@ -1546,7 +1571,7 @@ namespace OpenSim.Region.Framework.Scenes
1546 e.Message, e.StackTrace); 1571 e.Message, e.StackTrace);
1547 } 1572 }
1548 } 1573 }
1549 } 1574 }
1550 } 1575 }
1551 1576
1552 public void TriggerOnChatBroadcast(Object sender, OSChatMessage chat) 1577 public void TriggerOnChatBroadcast(Object sender, OSChatMessage chat)
@@ -1567,7 +1592,7 @@ namespace OpenSim.Region.Framework.Scenes
1567 e.Message, e.StackTrace); 1592 e.Message, e.StackTrace);
1568 } 1593 }
1569 } 1594 }
1570 } 1595 }
1571 } 1596 }
1572 1597
1573 internal void TriggerControlEvent(uint p, UUID scriptUUID, UUID avatarID, uint held, uint _changed) 1598 internal void TriggerControlEvent(uint p, UUID scriptUUID, UUID avatarID, uint held, uint _changed)
@@ -1588,7 +1613,7 @@ namespace OpenSim.Region.Framework.Scenes
1588 e.Message, e.StackTrace); 1613 e.Message, e.StackTrace);
1589 } 1614 }
1590 } 1615 }
1591 } 1616 }
1592 } 1617 }
1593 1618
1594 public void TriggerNoticeNoLandDataFromStorage() 1619 public void TriggerNoticeNoLandDataFromStorage()
@@ -1609,7 +1634,7 @@ namespace OpenSim.Region.Framework.Scenes
1609 e.Message, e.StackTrace); 1634 e.Message, e.StackTrace);
1610 } 1635 }
1611 } 1636 }
1612 } 1637 }
1613 } 1638 }
1614 1639
1615 public void TriggerIncomingLandDataFromStorage(List<LandData> landData) 1640 public void TriggerIncomingLandDataFromStorage(List<LandData> landData)
@@ -1630,7 +1655,7 @@ namespace OpenSim.Region.Framework.Scenes
1630 e.Message, e.StackTrace); 1655 e.Message, e.StackTrace);
1631 } 1656 }
1632 } 1657 }
1633 } 1658 }
1634 } 1659 }
1635 1660
1636 public void TriggerSetAllowForcefulBan(bool allow) 1661 public void TriggerSetAllowForcefulBan(bool allow)
@@ -1651,7 +1676,7 @@ namespace OpenSim.Region.Framework.Scenes
1651 e.Message, e.StackTrace); 1676 e.Message, e.StackTrace);
1652 } 1677 }
1653 } 1678 }
1654 } 1679 }
1655 } 1680 }
1656 1681
1657 public void TriggerRequestParcelPrimCountUpdate() 1682 public void TriggerRequestParcelPrimCountUpdate()
@@ -1672,7 +1697,7 @@ namespace OpenSim.Region.Framework.Scenes
1672 e.Message, e.StackTrace); 1697 e.Message, e.StackTrace);
1673 } 1698 }
1674 } 1699 }
1675 } 1700 }
1676 } 1701 }
1677 1702
1678 public void TriggerParcelPrimCountTainted() 1703 public void TriggerParcelPrimCountTainted()
@@ -1693,7 +1718,7 @@ namespace OpenSim.Region.Framework.Scenes
1693 e.Message, e.StackTrace); 1718 e.Message, e.StackTrace);
1694 } 1719 }
1695 } 1720 }
1696 } 1721 }
1697 } 1722 }
1698 1723
1699 // this lets us keep track of nasty script events like timer, etc. 1724 // this lets us keep track of nasty script events like timer, etc.
@@ -1732,7 +1757,7 @@ namespace OpenSim.Region.Framework.Scenes
1732 e.Message, e.StackTrace); 1757 e.Message, e.StackTrace);
1733 } 1758 }
1734 } 1759 }
1735 } 1760 }
1736 } 1761 }
1737 1762
1738 public float GetCurrentTimeAsSunLindenHour() 1763 public float GetCurrentTimeAsSunLindenHour()
@@ -1759,7 +1784,7 @@ namespace OpenSim.Region.Framework.Scenes
1759 } 1784 }
1760 1785
1761 public void TriggerOarFileLoaded(Guid requestId, string message) 1786 public void TriggerOarFileLoaded(Guid requestId, string message)
1762 { 1787 {
1763 OarFileLoaded handlerOarFileLoaded = OnOarFileLoaded; 1788 OarFileLoaded handlerOarFileLoaded = OnOarFileLoaded;
1764 if (handlerOarFileLoaded != null) 1789 if (handlerOarFileLoaded != null)
1765 { 1790 {
@@ -1776,7 +1801,7 @@ namespace OpenSim.Region.Framework.Scenes
1776 e.Message, e.StackTrace); 1801 e.Message, e.StackTrace);
1777 } 1802 }
1778 } 1803 }
1779 } 1804 }
1780 } 1805 }
1781 1806
1782 public void TriggerOarFileSaved(Guid requestId, string message) 1807 public void TriggerOarFileSaved(Guid requestId, string message)
@@ -1797,7 +1822,7 @@ namespace OpenSim.Region.Framework.Scenes
1797 e.Message, e.StackTrace); 1822 e.Message, e.StackTrace);
1798 } 1823 }
1799 } 1824 }
1800 } 1825 }
1801 } 1826 }
1802 1827
1803 public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message) 1828 public void TriggerEmptyScriptCompileQueue(int numScriptsFailed, string message)
@@ -1818,7 +1843,7 @@ namespace OpenSim.Region.Framework.Scenes
1818 e.Message, e.StackTrace); 1843 e.Message, e.StackTrace);
1819 } 1844 }
1820 } 1845 }
1821 } 1846 }
1822 } 1847 }
1823 1848
1824 public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders) 1849 public void TriggerScriptCollidingStart(uint localId, ColliderArgs colliders)
@@ -1839,7 +1864,7 @@ namespace OpenSim.Region.Framework.Scenes
1839 e.Message, e.StackTrace); 1864 e.Message, e.StackTrace);
1840 } 1865 }
1841 } 1866 }
1842 } 1867 }
1843 } 1868 }
1844 1869
1845 public void TriggerScriptColliding(uint localId, ColliderArgs colliders) 1870 public void TriggerScriptColliding(uint localId, ColliderArgs colliders)
@@ -1860,7 +1885,7 @@ namespace OpenSim.Region.Framework.Scenes
1860 e.Message, e.StackTrace); 1885 e.Message, e.StackTrace);
1861 } 1886 }
1862 } 1887 }
1863 } 1888 }
1864 } 1889 }
1865 1890
1866 public void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders) 1891 public void TriggerScriptCollidingEnd(uint localId, ColliderArgs colliders)
@@ -1881,7 +1906,7 @@ namespace OpenSim.Region.Framework.Scenes
1881 e.Message, e.StackTrace); 1906 e.Message, e.StackTrace);
1882 } 1907 }
1883 } 1908 }
1884 } 1909 }
1885 } 1910 }
1886 1911
1887 public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders) 1912 public void TriggerScriptLandCollidingStart(uint localId, ColliderArgs colliders)
@@ -1902,7 +1927,7 @@ namespace OpenSim.Region.Framework.Scenes
1902 e.Message, e.StackTrace); 1927 e.Message, e.StackTrace);
1903 } 1928 }
1904 } 1929 }
1905 } 1930 }
1906 } 1931 }
1907 1932
1908 public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders) 1933 public void TriggerScriptLandColliding(uint localId, ColliderArgs colliders)
@@ -1923,7 +1948,7 @@ namespace OpenSim.Region.Framework.Scenes
1923 e.Message, e.StackTrace); 1948 e.Message, e.StackTrace);
1924 } 1949 }
1925 } 1950 }
1926 } 1951 }
1927 } 1952 }
1928 1953
1929 public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders) 1954 public void TriggerScriptLandCollidingEnd(uint localId, ColliderArgs colliders)
@@ -1944,11 +1969,11 @@ namespace OpenSim.Region.Framework.Scenes
1944 e.Message, e.StackTrace); 1969 e.Message, e.StackTrace);
1945 } 1970 }
1946 } 1971 }
1947 } 1972 }
1948 } 1973 }
1949 1974
1950 public void TriggerSetRootAgentScene(UUID agentID, Scene scene) 1975 public void TriggerSetRootAgentScene(UUID agentID, Scene scene)
1951 { 1976 {
1952 OnSetRootAgentSceneDelegate handlerSetRootAgentScene = OnSetRootAgentScene; 1977 OnSetRootAgentSceneDelegate handlerSetRootAgentScene = OnSetRootAgentScene;
1953 if (handlerSetRootAgentScene != null) 1978 if (handlerSetRootAgentScene != null)
1954 { 1979 {
@@ -1965,7 +1990,7 @@ namespace OpenSim.Region.Framework.Scenes
1965 e.Message, e.StackTrace); 1990 e.Message, e.StackTrace);
1966 } 1991 }
1967 } 1992 }
1968 } 1993 }
1969 } 1994 }
1970 1995
1971 public void TriggerOnRegionUp(GridRegion otherRegion) 1996 public void TriggerOnRegionUp(GridRegion otherRegion)
@@ -1986,7 +2011,7 @@ namespace OpenSim.Region.Framework.Scenes
1986 e.Message, e.StackTrace); 2011 e.Message, e.StackTrace);
1987 } 2012 }
1988 } 2013 }
1989 } 2014 }
1990 } 2015 }
1991 } 2016 }
1992} 2017}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
deleted file mode 100644
index ec50598..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGAssetMapper.cs
+++ /dev/null
@@ -1,265 +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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30using System.Reflection;
31using System.Threading;
32using log4net;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Communications.Cache;
36using OpenSim.Framework.Communications.Clients;
37using OpenSim.Region.Framework.Scenes.Serialization;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Services.Interfaces;
40
41//using HyperGrid.Framework;
42//using OpenSim.Region.Communications.Hypergrid;
43
44namespace OpenSim.Region.Framework.Scenes.Hypergrid
45{
46 public class HGAssetMapper
47 {
48 #region Fields
49 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50
51 // This maps between inventory server urls and inventory server clients
52// private Dictionary<string, InventoryClient> m_inventoryServers = new Dictionary<string, InventoryClient>();
53
54 private Scene m_scene;
55
56 private IHyperAssetService m_hyper;
57 IHyperAssetService HyperlinkAssets
58 {
59 get
60 {
61 if (m_hyper == null)
62 m_hyper = m_scene.RequestModuleInterface<IHyperAssetService>();
63 return m_hyper;
64 }
65 }
66
67 #endregion
68
69 #region Constructor
70
71 public HGAssetMapper(Scene scene)
72 {
73 m_scene = scene;
74 }
75
76 #endregion
77
78 #region Internal functions
79
80// private string UserAssetURL(UUID userID)
81// {
82// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
83// if (uinfo != null)
84// return (uinfo.UserProfile.UserAssetURI == "") ? null : uinfo.UserProfile.UserAssetURI;
85// return null;
86// }
87
88// private string UserInventoryURL(UUID userID)
89// {
90// CachedUserInfo uinfo = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(userID);
91// if (uinfo != null)
92// return (uinfo.UserProfile.UserInventoryURI == "") ? null : uinfo.UserProfile.UserInventoryURI;
93// return null;
94// }
95
96
97 public AssetBase FetchAsset(string url, UUID assetID)
98 {
99 AssetBase asset = m_scene.AssetService.Get(url + "/" + assetID.ToString());
100
101 if (asset != null)
102 {
103 m_log.DebugFormat("[HGScene]: Copied asset {0} from {1} to local asset server. ", asset.ID, url);
104 return asset;
105 }
106 return null;
107 }
108
109 public bool PostAsset(string url, AssetBase asset)
110 {
111 if (asset != null)
112 {
113 // See long comment in AssetCache.AddAsset
114 if (!asset.Temporary || asset.Local)
115 {
116 // We need to copy the asset into a new asset, because
117 // we need to set its ID to be URL+UUID, so that the
118 // HGAssetService dispatches it to the remote grid.
119 // It's not pretty, but the best that can be done while
120 // not having a global naming infrastructure
121 AssetBase asset1 = new AssetBase(asset.FullID, asset.Name, asset.Type);
122 Copy(asset, asset1);
123 try
124 {
125 asset1.ID = url + "/" + asset.ID;
126 }
127 catch
128 {
129 m_log.Warn("[HGScene]: Oops.");
130 }
131
132 m_scene.AssetService.Store(asset1);
133 m_log.DebugFormat("[HGScene]: Posted copy of asset {0} from local asset server to {1}", asset1.ID, url);
134 }
135 return true;
136 }
137 else
138 m_log.Warn("[HGScene]: Tried to post asset to remote server, but asset not in local cache.");
139
140 return false;
141 }
142
143 private void Copy(AssetBase from, AssetBase to)
144 {
145 to.Data = from.Data;
146 to.Description = from.Description;
147 to.FullID = from.FullID;
148 to.ID = from.ID;
149 to.Local = from.Local;
150 to.Name = from.Name;
151 to.Temporary = from.Temporary;
152 to.Type = from.Type;
153
154 }
155
156 // TODO: unused
157 // private void Dump(Dictionary<UUID, bool> lst)
158 // {
159 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
160 // foreach (KeyValuePair<UUID, bool> kvp in lst)
161 // m_log.Debug(" >> " + kvp.Key + " (texture? " + kvp.Value + ")");
162 // m_log.Debug("XXX -------- UUID DUMP ------- XXX");
163 // }
164
165 #endregion
166
167
168 #region Public interface
169
170 public void Get(UUID assetID, UUID ownerID)
171 {
172 // Get the item from the remote asset server onto the local AssetCache
173 // and place an entry in m_assetMap
174
175 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
176 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
177 {
178 m_log.Debug("[HGScene]: Fetching object " + assetID + " from asset server " + userAssetURL);
179 AssetBase asset = FetchAsset(userAssetURL, assetID);
180
181 if (asset != null)
182 {
183 // OK, now fetch the inside.
184 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
185 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, userAssetURL);
186 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
187 foreach (UUID uuid in ids.Keys)
188 FetchAsset(userAssetURL, uuid);
189
190 m_log.DebugFormat("[HGScene]: Successfully fetched asset {0} from asset server {1}", asset.ID, userAssetURL);
191
192 }
193 else
194 m_log.Warn("[HGScene]: Could not fetch asset from remote asset server " + userAssetURL);
195 }
196 else
197 m_log.Debug("[HGScene]: user's asset server is the local region's asset server");
198 }
199
200 //public InventoryItemBase Get(InventoryItemBase item, UUID rootFolder, CachedUserInfo userInfo)
201 //{
202 // InventoryClient invCli = null;
203 // string inventoryURL = UserInventoryURL(item.Owner);
204 // if (!m_inventoryServers.TryGetValue(inventoryURL, out invCli))
205 // {
206 // m_log.Debug("[HGScene]: Starting new InventorytClient for " + inventoryURL);
207 // invCli = new InventoryClient(inventoryURL);
208 // m_inventoryServers.Add(inventoryURL, invCli);
209 // }
210
211 // item = invCli.GetInventoryItem(item);
212 // if (item != null)
213 // {
214 // // Change the folder, stick it in root folder, all items flattened out here in this region cache
215 // item.Folder = rootFolder;
216 // //userInfo.AddItem(item); don't use this, it calls back to the inventory server
217 // lock (userInfo.RootFolder.Items)
218 // {
219 // userInfo.RootFolder.Items[item.ID] = item;
220 // }
221
222 // }
223 // return item;
224 //}
225
226 public void Post(UUID assetID, UUID ownerID)
227 {
228 // Post the item from the local AssetCache onto the remote asset server
229 // and place an entry in m_assetMap
230
231 string userAssetURL = HyperlinkAssets.GetUserAssetServer(ownerID);
232 if ((userAssetURL != string.Empty) && (userAssetURL != HyperlinkAssets.GetSimAssetServer()))
233 {
234 m_log.Debug("[HGScene]: Posting object " + assetID + " to asset server " + userAssetURL);
235 AssetBase asset = m_scene.AssetService.Get(assetID.ToString());
236 if (asset != null)
237 {
238 Dictionary<UUID, int> ids = new Dictionary<UUID, int>();
239 HGUuidGatherer uuidGatherer = new HGUuidGatherer(this, m_scene.AssetService, string.Empty);
240 uuidGatherer.GatherAssetUuids(asset.FullID, (AssetType)asset.Type, ids);
241 foreach (UUID uuid in ids.Keys)
242 {
243 asset = m_scene.AssetService.Get(uuid.ToString());
244 if (asset == null)
245 m_log.DebugFormat("[HGScene]: Could not find asset {0}", uuid);
246 else
247 PostAsset(userAssetURL, asset);
248 }
249
250 // maybe all pieces got there...
251 m_log.DebugFormat("[HGScene]: Successfully posted item {0} to asset server {1}", assetID, userAssetURL);
252
253 }
254 else
255 m_log.DebugFormat("[HGScene]: Something wrong with asset {0}, it could not be found", assetID);
256 }
257 else
258 m_log.Debug("[HGScene]: user's asset server is local region's asset server");
259
260 }
261
262 #endregion
263
264 }
265}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
deleted file mode 100644
index 6f7f34f..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.Inventory.cs
+++ /dev/null
@@ -1,174 +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 OpenSimulator 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
28using System.Reflection;
29using log4net;
30using Nini.Config;
31using OpenMetaverse;
32using OpenSim.Framework;
33using OpenSim.Framework.Communications;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces;
36
37namespace OpenSim.Region.Framework.Scenes.Hypergrid
38{
39 public partial class HGScene : Scene
40 {
41 #region Fields
42 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
43
44 private HGAssetMapper m_assMapper;
45 public HGAssetMapper AssetMapper
46 {
47 get { return m_assMapper; }
48 }
49
50 private IHyperAssetService m_hyper;
51 private IHyperAssetService HyperAssets
52 {
53 get
54 {
55 if (m_hyper == null)
56 m_hyper = RequestModuleInterface<IHyperAssetService>();
57 return m_hyper;
58 }
59 }
60
61 #endregion
62
63 #region Constructors
64
65 public HGScene(RegionInfo regInfo, AgentCircuitManager authen,
66 CommunicationsManager commsMan, SceneCommunicationService sceneGridService,
67 StorageManager storeManager,
68 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
69 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
70 : base(regInfo, authen, commsMan, sceneGridService, storeManager, moduleLoader,
71 dumpAssetsToFile, physicalPrim, SeeIntoRegionFromNeighbor, config, simulatorVersion)
72 {
73 m_log.Info("[HGScene]: Starting HGScene.");
74 m_assMapper = new HGAssetMapper(this);
75
76 EventManager.OnNewInventoryItemUploadComplete += UploadInventoryItem;
77 }
78
79 #endregion
80
81 #region Event handlers
82
83 public void UploadInventoryItem(UUID avatarID, UUID assetID, string name, int userlevel)
84 {
85 CachedUserInfo userInfo = CommsManager.UserProfileCacheService.GetUserDetails(avatarID);
86 if (userInfo != null)
87 {
88 m_assMapper.Post(assetID, avatarID);
89 }
90 }
91
92 #endregion
93
94 #region Overrides of Scene.Inventory methods
95
96 ///
97 /// CapsUpdateInventoryItemAsset
98 ///
99 public override UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
100 {
101 UUID newAssetID = base.CapsUpdateInventoryItemAsset(remoteClient, itemID, data);
102
103 UploadInventoryItem(remoteClient.AgentId, newAssetID, "", 0);
104
105 return newAssetID;
106 }
107
108 ///
109 /// DeleteToInventory
110 ///
111 public override UUID DeleteToInventory(DeRezAction action, UUID folderID, SceneObjectGroup objectGroup, IClientAPI remoteClient)
112 {
113 UUID assetID = base.DeleteToInventory(action, folderID, objectGroup, remoteClient);
114
115 if (!assetID.Equals(UUID.Zero))
116 {
117 UploadInventoryItem(remoteClient.AgentId, assetID, "", 0);
118 }
119 else
120 m_log.Debug("[HGScene]: Scene.Inventory did not create asset");
121
122 return assetID;
123 }
124
125 ///
126 /// RezObject
127 ///
128 public override SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
129 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
130 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
131 {
132 m_log.DebugFormat("[HGScene] RezObject itemID={0} fromTaskID={1}", itemID, fromTaskID);
133
134 //if (fromTaskID.Equals(UUID.Zero))
135 //{
136 InventoryItemBase item = new InventoryItemBase(itemID);
137 item.Owner = remoteClient.AgentId;
138 item = InventoryService.GetItem(item);
139 //if (item == null)
140 //{ // Fetch the item
141 // item = new InventoryItemBase();
142 // item.Owner = remoteClient.AgentId;
143 // item.ID = itemID;
144 // item = m_assMapper.Get(item, userInfo.RootFolder.ID, userInfo);
145 //}
146 if (item != null)
147 {
148 m_assMapper.Get(item.AssetID, remoteClient.AgentId);
149
150 }
151 //}
152
153 // OK, we're done fetching. Pass it up to the default RezObject
154 return base.RezObject(remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
155 RezSelected, RemoveItem, fromTaskID, attachment);
156
157 }
158
159 protected override void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
160 {
161 string userAssetServer = HyperAssets.GetUserAssetServer(sender);
162 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
163 m_assMapper.Get(item.AssetID, sender);
164
165 userAssetServer = HyperAssets.GetUserAssetServer(receiver);
166 if ((userAssetServer != string.Empty) && (userAssetServer != HyperAssets.GetSimAssetServer()))
167 m_assMapper.Post(item.AssetID, receiver);
168 }
169
170 #endregion
171
172 }
173
174}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
deleted file mode 100644
index b1981b6..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGScene.cs
+++ /dev/null
@@ -1,77 +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 OpenSimulator 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
28using OpenMetaverse;
29using OpenSim.Framework;
30using OpenSim.Framework.Communications.Cache;
31using TPFlags = OpenSim.Framework.Constants.TeleportFlags;
32using GridRegion = OpenSim.Services.Interfaces.GridRegion;
33
34namespace OpenSim.Region.Framework.Scenes.Hypergrid
35{
36 public partial class HGScene : Scene
37 {
38 /// <summary>
39 /// Teleport an avatar to their home region
40 /// </summary>
41 /// <param name="agentId"></param>
42 /// <param name="client"></param>
43 public override void TeleportClientHome(UUID agentId, IClientAPI client)
44 {
45 m_log.Debug("[HGScene]: TeleportClientHome " + client.FirstName + " " + client.LastName);
46
47 CachedUserInfo uinfo = CommsManager.UserProfileCacheService.GetUserDetails(agentId);
48 if (uinfo != null)
49 {
50 UserProfileData UserProfile = uinfo.UserProfile;
51
52 if (UserProfile != null)
53 {
54 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID);
55 //if (regionInfo != null)
56 //{
57 // UserProfile.HomeRegionID = regionInfo.RegionID;
58 // //CommsManager.UserService.UpdateUserProfile(UserProfile);
59 //}
60 if (regionInfo == null)
61 {
62 // can't find the Home region: Tell viewer and abort
63 client.SendTeleportFailed("Your home-region could not be found.");
64 return;
65 }
66 RequestTeleportLocation(
67 client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
68 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
69 }
70 }
71 else
72 client.SendTeleportFailed("Sorry! I lost your home-region information.");
73
74 }
75
76 }
77}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
deleted file mode 100644
index 416826c..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGSceneCommunicationService.cs
+++ /dev/null
@@ -1,391 +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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30using System.Net;
31using System.Reflection;
32using System.Threading;
33using log4net;
34using OpenMetaverse;
35using OpenSim.Framework;
36using OpenSim.Framework.Client;
37using OpenSim.Framework.Communications;
38using OpenSim.Framework.Communications.Cache;
39using OpenSim.Framework.Capabilities;
40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Services.Interfaces;
42using GridRegion = OpenSim.Services.Interfaces.GridRegion;
43
44namespace OpenSim.Region.Framework.Scenes.Hypergrid
45{
46 public class HGSceneCommunicationService : SceneCommunicationService
47 {
48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
49
50 private IHyperlinkService m_hg;
51 IHyperlinkService HyperlinkService
52 {
53 get
54 {
55 if (m_hg == null)
56 m_hg = m_scene.RequestModuleInterface<IHyperlinkService>();
57 return m_hg;
58 }
59 }
60
61 public HGSceneCommunicationService(CommunicationsManager commsMan) : base(commsMan)
62 {
63 }
64
65
66 /// <summary>
67 /// Try to teleport an agent to a new region.
68 /// </summary>
69 /// <param name="remoteClient"></param>
70 /// <param name="RegionHandle"></param>
71 /// <param name="position"></param>
72 /// <param name="lookAt"></param>
73 /// <param name="flags"></param>
74 public override void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
75 Vector3 lookAt, uint teleportFlags)
76 {
77 if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
78 return;
79
80 bool destRegionUp = true;
81
82 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
83
84 // Reset animations; the viewer does that in teleports.
85 avatar.Animator.ResetAnimations();
86
87 if (regionHandle == m_regionInfo.RegionHandle)
88 {
89 // Teleport within the same region
90 if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
91 {
92 Vector3 emergencyPos = new Vector3(128, 128, 128);
93
94 m_log.WarnFormat(
95 "[HGSceneCommService]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
96 position, avatar.Name, avatar.UUID, emergencyPos);
97 position = emergencyPos;
98 }
99 // TODO: Get proper AVG Height
100 float localAVHeight = 1.56f;
101
102 float posZLimit = 22;
103
104 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <= (int)Constants.RegionSize)
105 {
106 posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
107 }
108
109 float newPosZ = posZLimit + localAVHeight;
110 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
111 {
112 position.Z = newPosZ;
113 }
114
115 // Only send this if the event queue is null
116 if (eq == null)
117 avatar.ControllingClient.SendTeleportLocationStart();
118
119
120 avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
121 avatar.Teleport(position);
122 }
123 else
124 {
125 uint x = 0, y = 0;
126 Utils.LongToUInts(regionHandle, out x, out y);
127 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
128
129 if (reg != null)
130 {
131
132 uint newRegionX = (uint)(reg.RegionHandle >> 40);
133 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
134 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
135 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
136
137 ///
138 /// Hypergrid mod start
139 ///
140 ///
141 bool isHyperLink = (HyperlinkService.GetHyperlinkRegion(reg.RegionHandle) != null);
142 bool isHomeUser = true;
143 ulong realHandle = regionHandle;
144 CachedUserInfo uinfo = m_commsProvider.UserProfileCacheService.GetUserDetails(avatar.UUID);
145 if (uinfo != null)
146 {
147 isHomeUser = HyperlinkService.IsLocalUser(uinfo.UserProfile.ID);
148 realHandle = m_hg.FindRegionHandle(regionHandle);
149 m_log.Debug("XXX ---- home user? " + isHomeUser + " --- hyperlink? " + isHyperLink + " --- real handle: " + realHandle.ToString());
150 }
151 ///
152 /// Hypergrid mod stop
153 ///
154 ///
155
156 if (eq == null)
157 avatar.ControllingClient.SendTeleportLocationStart();
158
159
160 // Let's do DNS resolution only once in this process, please!
161 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
162 // it's actually doing a lot of work.
163 IPEndPoint endPoint = reg.ExternalEndPoint;
164 if (endPoint.Address == null)
165 {
166 // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
167 destRegionUp = false;
168 }
169
170 if (destRegionUp)
171 {
172 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
173 // both regions
174 if (avatar.ParentID != (uint)0)
175 avatar.StandUp();
176
177 if (!avatar.ValidateAttachments())
178 {
179 avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
180 return;
181 }
182
183 // the avatar.Close below will clear the child region list. We need this below for (possibly)
184 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
185 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
186 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
187 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
188 // once we reach here...
189 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
190
191 string capsPath = String.Empty;
192 AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
193 agentCircuit.BaseFolder = UUID.Zero;
194 agentCircuit.InventoryFolder = UUID.Zero;
195 agentCircuit.startpos = position;
196 agentCircuit.child = true;
197 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
198 {
199 // brand new agent, let's create a new caps seed
200 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
201 }
202
203 string reason = String.Empty;
204
205 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
206 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
207 {
208 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
209 reason));
210 return;
211 }
212
213 // Let's close some agents
214 if (isHyperLink) // close them all except this one
215 {
216 List<ulong> regions = new List<ulong>(avatar.KnownChildRegionHandles);
217 regions.Remove(avatar.Scene.RegionInfo.RegionHandle);
218 SendCloseChildAgentConnections(avatar.UUID, regions);
219 }
220 else // close just a few
221 avatar.CloseChildAgents(newRegionX, newRegionY);
222
223 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY) || isHyperLink)
224 {
225 capsPath
226 = "http://"
227 + reg.ExternalHostName
228 + ":"
229 + reg.HttpPort
230 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
231
232 if (eq != null)
233 {
234 #region IP Translation for NAT
235 IClientIPEndpoint ipepClient;
236 if (avatar.ClientView.TryGet(out ipepClient))
237 {
238 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
239 }
240 #endregion
241
242 eq.EnableSimulator(realHandle, endPoint, avatar.UUID);
243
244 // ES makes the client send a UseCircuitCode message to the destination,
245 // which triggers a bunch of things there.
246 // So let's wait
247 Thread.Sleep(2000);
248
249 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
250 }
251 else
252 {
253 avatar.ControllingClient.InformClientOfNeighbour(realHandle, endPoint);
254 // TODO: make Event Queue disablable!
255 }
256 }
257 else
258 {
259 // child agent already there
260 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
261 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
262 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
263 }
264
265 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
266 // position, false);
267
268 //if (!m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
269 // position, false))
270 //{
271 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
272 // // We should close that agent we just created over at destination...
273 // List<ulong> lst = new List<ulong>();
274 // lst.Add(realHandle);
275 // SendCloseChildAgentAsync(avatar.UUID, lst);
276 // return;
277 //}
278
279 SetInTransit(avatar.UUID);
280 // Let's send a full update of the agent. This is a synchronous call.
281 AgentData agent = new AgentData();
282 avatar.CopyTo(agent);
283 agent.Position = position;
284 agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
285 "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
286
287 m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
288
289 m_log.DebugFormat(
290 "[CAPS]: Sending new CAPS seed url {0} to client {1}", agentCircuit.CapsPath, avatar.UUID);
291
292
293 ///
294 /// Hypergrid mod: realHandle instead of reg.RegionHandle
295 ///
296 ///
297 if (eq != null)
298 {
299 eq.TeleportFinishEvent(realHandle, 13, endPoint,
300 4, teleportFlags, capsPath, avatar.UUID);
301 }
302 else
303 {
304 avatar.ControllingClient.SendRegionTeleport(realHandle, 13, endPoint, 4,
305 teleportFlags, capsPath);
306 }
307 ///
308 /// Hypergrid mod stop
309 ///
310
311
312 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
313 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
314 // that the client contacted the destination before we send the attachments and close things here.
315 if (!WaitForCallback(avatar.UUID))
316 {
317 // Client never contacted destination. Let's restore everything back
318 avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
319
320 ResetFromTransit(avatar.UUID);
321 // Yikes! We should just have a ref to scene here.
322 avatar.Scene.InformClientOfNeighbours(avatar);
323
324 // Finally, kill the agent we just created at the destination.
325 m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
326
327 return;
328 }
329
330 // Can't go back from here
331 if (KiPrimitive != null)
332 {
333 KiPrimitive(avatar.LocalId);
334 }
335
336 avatar.MakeChildAgent();
337
338 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
339 avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
340
341
342 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
343 ///
344 /// Hypergrid mod: extra check for isHyperLink
345 ///
346 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY) || isHyperLink)
347 {
348 Thread.Sleep(5000);
349 avatar.Close();
350 CloseConnection(avatar.UUID);
351 }
352 // if (teleport success) // seems to be always success here
353 // the user may change their profile information in other region,
354 // so the userinfo in UserProfileCache is not reliable any more, delete it
355 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID) || isHyperLink)
356 {
357 m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
358 m_log.DebugFormat(
359 "[HGSceneCommService]: User {0} is going to another region, profile cache removed",
360 avatar.UUID);
361 }
362 }
363 else
364 {
365 avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
366 }
367 }
368 else
369 {
370 // TP to a place that doesn't exist (anymore)
371 // Inform the viewer about that
372 avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
373
374 // and set the map-tile to '(Offline)'
375 uint regX, regY;
376 Utils.LongToUInts(regionHandle, out regX, out regY);
377
378 MapBlockData block = new MapBlockData();
379 block.X = (ushort)(regX / Constants.RegionSize);
380 block.Y = (ushort)(regY / Constants.RegionSize);
381 block.Access = 254; // == not there
382
383 List<MapBlockData> blocks = new List<MapBlockData>();
384 blocks.Add(block);
385 avatar.ControllingClient.SendMapBlock(blocks, 0);
386 }
387 }
388 }
389
390 }
391}
diff --git a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs b/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
deleted file mode 100644
index 5d4e7ac..0000000
--- a/OpenSim/Region/Framework/Scenes/Hypergrid/HGUuidGatherer.cs
+++ /dev/null
@@ -1,56 +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 OpenSimulator 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
28using System;
29using System.Collections.Generic;
30
31using OpenSim.Framework;
32using OpenSim.Services.Interfaces;
33using OpenMetaverse;
34
35namespace OpenSim.Region.Framework.Scenes.Hypergrid
36{
37 public class HGUuidGatherer : UuidGatherer
38 {
39 protected string m_assetServerURL;
40 protected HGAssetMapper m_assetMapper;
41
42 public HGUuidGatherer(HGAssetMapper assMap, IAssetService assetCache, string assetServerURL) : base(assetCache)
43 {
44 m_assetMapper = assMap;
45 m_assetServerURL = assetServerURL;
46 }
47
48 protected override AssetBase GetAsset(UUID uuid)
49 {
50 if (string.Empty == m_assetServerURL)
51 return m_assetCache.Get(uuid.ToString());
52 else
53 return m_assetMapper.FetchAsset(m_assetServerURL, uuid);
54 }
55 }
56}
diff --git a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
index e9660b1..d25d5dd 100644
--- a/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
+++ b/OpenSim/Region/Framework/Scenes/RegionStatsHandler.cs
@@ -36,8 +36,7 @@ using OpenMetaverse;
36using OpenMetaverse.StructuredData; 36using OpenMetaverse.StructuredData;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Services; 39
40using OpenSim.Framework.Communications.Cache;
41using OpenSim.Framework.Console; 40using OpenSim.Framework.Console;
42using OpenSim.Framework.Servers; 41using OpenSim.Framework.Servers;
43using OpenSim.Framework.Servers.HttpServer; 42using OpenSim.Framework.Servers.HttpServer;
diff --git a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
index b2b061e..e458ecf 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.Inventory.cs
@@ -35,7 +35,7 @@ using OpenMetaverse;
35using OpenMetaverse.Packets; 35using OpenMetaverse.Packets;
36using log4net; 36using log4net;
37using OpenSim.Framework; 37using OpenSim.Framework;
38using OpenSim.Framework.Communications.Cache; 38
39using OpenSim.Region.Framework; 39using OpenSim.Region.Framework;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes.Serialization; 41using OpenSim.Region.Framework.Scenes.Serialization;
@@ -101,12 +101,6 @@ namespace OpenSim.Region.Framework.Scenes
101 { 101 {
102 userlevel = 1; 102 userlevel = 1;
103 } 103 }
104 // TODO: remove this cruft once MasterAvatar is fully deprecated
105 //
106 if (m_regInfo.MasterAvatarAssignedUUID == AgentID)
107 {
108 userlevel = 2;
109 }
110 EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel); 104 EventManager.TriggerOnNewInventoryItemUploadComplete(AgentID, item.AssetID, item.Name, userlevel);
111 } 105 }
112 else 106 else
@@ -132,61 +126,6 @@ namespace OpenSim.Region.Framework.Scenes
132 } 126 }
133 127
134 /// <summary> 128 /// <summary>
135 /// Capability originating call to update the asset of an item in an agent's inventory
136 /// </summary>
137 /// <param name="remoteClient"></param>
138 /// <param name="itemID"></param>
139 /// <param name="data"></param>
140 /// <returns></returns>
141 public virtual UUID CapsUpdateInventoryItemAsset(IClientAPI remoteClient, UUID itemID, byte[] data)
142 {
143 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
144 item = InventoryService.GetItem(item);
145
146 if (item != null)
147 {
148 if ((InventoryType)item.InvType == InventoryType.Notecard)
149 {
150 if (!Permissions.CanEditNotecard(itemID, UUID.Zero, remoteClient.AgentId))
151 {
152 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit notecard", false);
153 return UUID.Zero;
154 }
155
156 remoteClient.SendAgentAlertMessage("Notecard saved", false);
157 }
158 else if ((InventoryType)item.InvType == InventoryType.LSL)
159 {
160 if (!Permissions.CanEditScript(itemID, UUID.Zero, remoteClient.AgentId))
161 {
162 remoteClient.SendAgentAlertMessage("Insufficient permissions to edit script", false);
163 return UUID.Zero;
164 }
165
166 remoteClient.SendAgentAlertMessage("Script saved", false);
167 }
168
169 AssetBase asset =
170 CreateAsset(item.Name, item.Description, (sbyte)item.AssetType, data);
171 item.AssetID = asset.FullID;
172 AssetService.Store(asset);
173
174 InventoryService.UpdateItem(item);
175
176 // remoteClient.SendInventoryItemCreateUpdate(item);
177 return (asset.FullID);
178 }
179 else
180 {
181 m_log.ErrorFormat(
182 "[AGENT INVENTORY]: Could not find item {0} for caps inventory update",
183 itemID);
184 }
185
186 return UUID.Zero;
187 }
188
189 /// <summary>
190 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see> 129 /// <see>CapsUpdatedInventoryItemAsset(IClientAPI, UUID, byte[])</see>
191 /// </summary> 130 /// </summary>
192 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data) 131 public UUID CapsUpdateInventoryItemAsset(UUID avatarId, UUID itemID, byte[] data)
@@ -195,7 +134,9 @@ namespace OpenSim.Region.Framework.Scenes
195 134
196 if (TryGetAvatar(avatarId, out avatar)) 135 if (TryGetAvatar(avatarId, out avatar))
197 { 136 {
198 return CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data); 137 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
138 if (invAccess != null)
139 return invAccess.CapsUpdateInventoryItemAsset(avatar.ControllingClient, itemID, data);
199 } 140 }
200 else 141 else
201 { 142 {
@@ -251,7 +192,7 @@ namespace OpenSim.Region.Framework.Scenes
251 return new ArrayList(); 192 return new ArrayList();
252 } 193 }
253 194
254 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data); 195 AssetBase asset = CreateAsset(item.Name, item.Description, (sbyte)AssetType.LSLText, data, remoteClient.AgentId);
255 AssetService.Store(asset); 196 AssetService.Store(asset);
256 197
257 if (isScriptRunning) 198 if (isScriptRunning)
@@ -478,7 +419,11 @@ namespace OpenSim.Region.Framework.Scenes
478 itemCopy.SaleType = item.SaleType; 419 itemCopy.SaleType = item.SaleType;
479 420
480 if (InventoryService.AddItem(itemCopy)) 421 if (InventoryService.AddItem(itemCopy))
481 TransferInventoryAssets(itemCopy, senderId, recipient); 422 {
423 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
424 if (invAccess != null)
425 invAccess.TransferInventoryAssets(itemCopy, senderId, recipient);
426 }
482 427
483 if (!Permissions.BypassPermissions()) 428 if (!Permissions.BypassPermissions())
484 { 429 {
@@ -500,10 +445,6 @@ namespace OpenSim.Region.Framework.Scenes
500 445
501 } 446 }
502 447
503 protected virtual void TransferInventoryAssets(InventoryItemBase item, UUID sender, UUID receiver)
504 {
505 }
506
507 /// <summary> 448 /// <summary>
508 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent 449 /// Give an entire inventory folder from one user to another. The entire contents (including all descendent
509 /// folders) is given. 450 /// folders) is given.
@@ -573,7 +514,9 @@ namespace OpenSim.Region.Framework.Scenes
573 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}", 514 "[AGENT INVENTORY]: CopyInventoryItem received by {0} with oldAgentID {1}, oldItemID {2}, new FolderID {3}, newName {4}",
574 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName); 515 remoteClient.AgentId, oldAgentID, oldItemID, newFolderID, newName);
575 516
576 InventoryItemBase item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(oldItemID); 517 InventoryItemBase item = null;
518 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
519 item = LibraryService.LibraryRootFolder.FindItem(oldItemID);
577 520
578 if (item == null) 521 if (item == null)
579 { 522 {
@@ -627,15 +570,9 @@ namespace OpenSim.Region.Framework.Scenes
627 /// <summary> 570 /// <summary>
628 /// Create a new asset data structure. 571 /// Create a new asset data structure.
629 /// </summary> 572 /// </summary>
630 /// <param name="name"></param> 573 private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data, UUID creatorID)
631 /// <param name="description"></param>
632 /// <param name="invType"></param>
633 /// <param name="assetType"></param>
634 /// <param name="data"></param>
635 /// <returns></returns>
636 private AssetBase CreateAsset(string name, string description, sbyte assetType, byte[] data)
637 { 574 {
638 AssetBase asset = new AssetBase(UUID.Random(), name, assetType); 575 AssetBase asset = new AssetBase(UUID.Random(), name, assetType, creatorID.ToString());
639 asset.Description = description; 576 asset.Description = description;
640 asset.Data = (data == null) ? new byte[1] : data; 577 asset.Data = (data == null) ? new byte[1] : data;
641 578
@@ -745,13 +682,9 @@ namespace OpenSim.Region.Framework.Scenes
745 682
746 if (transactionID == UUID.Zero) 683 if (transactionID == UUID.Zero)
747 { 684 {
748 CachedUserInfo userInfo 685 ScenePresence presence;
749 = CommsManager.UserProfileCacheService.GetUserDetails(remoteClient.AgentId); 686 if (TryGetAvatar(remoteClient.AgentId, out presence))
750
751 if (userInfo != null)
752 { 687 {
753 ScenePresence presence;
754 TryGetAvatar(remoteClient.AgentId, out presence);
755 byte[] data = null; 688 byte[] data = null;
756 689
757 if (invType == (sbyte)InventoryType.Landmark && presence != null) 690 if (invType == (sbyte)InventoryType.Landmark && presence != null)
@@ -765,7 +698,7 @@ namespace OpenSim.Region.Framework.Scenes
765 data = Encoding.ASCII.GetBytes(strdata); 698 data = Encoding.ASCII.GetBytes(strdata);
766 } 699 }
767 700
768 AssetBase asset = CreateAsset(name, description, assetType, data); 701 AssetBase asset = CreateAsset(name, description, assetType, data, remoteClient.AgentId);
769 AssetService.Store(asset); 702 AssetService.Store(asset);
770 703
771 CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate); 704 CreateNewInventoryItem(remoteClient, remoteClient.AgentId.ToString(), folderID, asset.Name, 0, callbackID, asset, invType, nextOwnerMask, creationDate);
@@ -773,7 +706,7 @@ namespace OpenSim.Region.Framework.Scenes
773 else 706 else
774 { 707 {
775 m_log.ErrorFormat( 708 m_log.ErrorFormat(
776 "userInfo for agent uuid {0} unexpectedly null in CreateNewInventoryItem", 709 "ScenePresence for agent uuid {0} unexpectedly not found in CreateNewInventoryItem",
777 remoteClient.AgentId); 710 remoteClient.AgentId);
778 } 711 }
779 } 712 }
@@ -1170,15 +1103,21 @@ namespace OpenSim.Region.Framework.Scenes
1170 1103
1171 private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems) 1104 private void SendInventoryUpdate(IClientAPI client, InventoryFolderBase folder, bool fetchFolders, bool fetchItems)
1172 { 1105 {
1106 if (folder == null)
1107 return;
1108
1173 m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName); 1109 m_log.DebugFormat("[AGENT INVENTORY]: Send Inventory Folder {0} Update to {1} {2}", folder.Name, client.FirstName, client.LastName);
1174 InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID); 1110 InventoryCollection contents = InventoryService.GetFolderContent(client.AgentId, folder.ID);
1175 InventoryFolderBase containingFolder = new InventoryFolderBase(); 1111 InventoryFolderBase containingFolder = new InventoryFolderBase();
1176 containingFolder.ID = folder.ID; 1112 containingFolder.ID = folder.ID;
1177 containingFolder.Owner = client.AgentId; 1113 containingFolder.Owner = client.AgentId;
1178 containingFolder = InventoryService.GetFolder(containingFolder); 1114 containingFolder = InventoryService.GetFolder(containingFolder);
1179 int version = containingFolder.Version; 1115 if (containingFolder != null)
1116 {
1117 int version = containingFolder.Version;
1180 1118
1181 client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems); 1119 client.SendInventoryFolderDetails(client.AgentId, folder.ID, contents.Items, contents.Folders, version, fetchFolders, fetchItems);
1120 }
1182 } 1121 }
1183 1122
1184 /// <summary> 1123 /// <summary>
@@ -1220,9 +1159,9 @@ namespace OpenSim.Region.Framework.Scenes
1220 item = InventoryService.GetItem(item); 1159 item = InventoryService.GetItem(item);
1221 1160
1222 // Try library 1161 // Try library
1223 if (null == item) 1162 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1224 { 1163 {
1225 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1164 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1226 } 1165 }
1227 1166
1228 if (item != null) 1167 if (item != null)
@@ -1289,9 +1228,9 @@ namespace OpenSim.Region.Framework.Scenes
1289 1228
1290 // Try library 1229 // Try library
1291 // XXX clumsy, possibly should be one call 1230 // XXX clumsy, possibly should be one call
1292 if (null == item) 1231 if (null == item && LibraryService != null && LibraryService.LibraryRootFolder != null)
1293 { 1232 {
1294 item = CommsManager.UserProfileCacheService.LibraryRoot.FindItem(itemID); 1233 item = LibraryService.LibraryRootFolder.FindItem(itemID);
1295 } 1234 }
1296 1235
1297 if (item != null) 1236 if (item != null)
@@ -1348,7 +1287,9 @@ namespace OpenSim.Region.Framework.Scenes
1348 itemBase.InvType, part.UUID, remoteClient.AgentId)) 1287 itemBase.InvType, part.UUID, remoteClient.AgentId))
1349 return; 1288 return;
1350 1289
1351 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType, Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}")); 1290 AssetBase asset = CreateAsset(itemBase.Name, itemBase.Description, (sbyte)itemBase.AssetType,
1291 Encoding.ASCII.GetBytes("default\n{\n state_entry()\n {\n llSay(0, \"Script running\");\n }\n}"),
1292 remoteClient.AgentId);
1352 AssetService.Store(asset); 1293 AssetService.Store(asset);
1353 1294
1354 TaskInventoryItem taskItem = new TaskInventoryItem(); 1295 TaskInventoryItem taskItem = new TaskInventoryItem();
@@ -1616,237 +1557,6 @@ namespace OpenSim.Region.Framework.Scenes
1616 } 1557 }
1617 } 1558 }
1618 1559
1619 /// <summary>
1620 /// Delete a scene object from a scene and place in the given avatar's inventory.
1621 /// Returns the UUID of the newly created asset.
1622 /// </summary>
1623 /// <param name="action"></param>
1624 /// <param name="folderID"></param>
1625 /// <param name="objectGroup"></param>
1626 /// <param name="remoteClient"> </param>
1627 public virtual UUID DeleteToInventory(DeRezAction action, UUID folderID,
1628 SceneObjectGroup objectGroup, IClientAPI remoteClient)
1629 {
1630 UUID assetID = UUID.Zero;
1631
1632 Vector3 inventoryStoredPosition = new Vector3
1633 (((objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1634 ? 250
1635 : objectGroup.AbsolutePosition.X)
1636 ,
1637 (objectGroup.AbsolutePosition.X > (int)Constants.RegionSize)
1638 ? 250
1639 : objectGroup.AbsolutePosition.X,
1640 objectGroup.AbsolutePosition.Z);
1641
1642 Vector3 originalPosition = objectGroup.AbsolutePosition;
1643
1644 objectGroup.AbsolutePosition = inventoryStoredPosition;
1645
1646 string sceneObjectXml = SceneObjectSerializer.ToOriginalXmlFormat(objectGroup);
1647
1648 objectGroup.AbsolutePosition = originalPosition;
1649
1650 // Get the user info of the item destination
1651 //
1652 UUID userID = UUID.Zero;
1653
1654 if (action == DeRezAction.Take || action == DeRezAction.TakeCopy ||
1655 action == DeRezAction.SaveToExistingUserInventoryItem)
1656 {
1657 // Take or take copy require a taker
1658 // Saving changes requires a local user
1659 //
1660 if (remoteClient == null)
1661 return UUID.Zero;
1662
1663 userID = remoteClient.AgentId;
1664 }
1665 else
1666 {
1667 // All returns / deletes go to the object owner
1668 //
1669
1670 userID = objectGroup.RootPart.OwnerID;
1671 }
1672
1673 if (userID == UUID.Zero) // Can't proceed
1674 {
1675 return UUID.Zero;
1676 }
1677
1678 // If we're returning someone's item, it goes back to the
1679 // owner's Lost And Found folder.
1680 // Delete is treated like return in this case
1681 // Deleting your own items makes them go to trash
1682 //
1683
1684 InventoryFolderBase folder = null;
1685 InventoryItemBase item = null;
1686
1687 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1688 {
1689 item = new InventoryItemBase(objectGroup.RootPart.FromUserInventoryItemID, userID);
1690 item = InventoryService.GetItem(item);
1691
1692 //item = userInfo.RootFolder.FindItem(
1693 // objectGroup.RootPart.FromUserInventoryItemID);
1694
1695 if (null == item)
1696 {
1697 m_log.DebugFormat(
1698 "[AGENT INVENTORY]: Object {0} {1} scheduled for save to inventory has already been deleted.",
1699 objectGroup.Name, objectGroup.UUID);
1700 return UUID.Zero;
1701 }
1702 }
1703 else
1704 {
1705 // Folder magic
1706 //
1707 if (action == DeRezAction.Delete)
1708 {
1709 // Deleting someone else's item
1710 //
1711
1712
1713 if (remoteClient == null ||
1714 objectGroup.OwnerID != remoteClient.AgentId)
1715 {
1716 // Folder skeleton may not be loaded and we
1717 // have to wait for the inventory to find
1718 // the destination folder
1719 //
1720 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1721 }
1722 else
1723 {
1724 // Assume inventory skeleton was loaded during login
1725 // and all folders can be found
1726 //
1727 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1728 }
1729 }
1730 else if (action == DeRezAction.Return)
1731 {
1732
1733 // Dump to lost + found unconditionally
1734 //
1735 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1736 }
1737
1738 if (folderID == UUID.Zero && folder == null)
1739 {
1740 if (action == DeRezAction.Delete)
1741 {
1742 // Deletes go to trash by default
1743 //
1744 folder = InventoryService.GetFolderForType(userID, AssetType.TrashFolder);
1745 }
1746 else
1747 {
1748 // Catch all. Use lost & found
1749 //
1750
1751 folder = InventoryService.GetFolderForType(userID, AssetType.LostAndFoundFolder);
1752 }
1753 }
1754
1755 if (folder == null) // None of the above
1756 {
1757 //folder = userInfo.RootFolder.FindFolder(folderID);
1758 folder = new InventoryFolderBase(folderID);
1759
1760 if (folder == null) // Nowhere to put it
1761 {
1762 return UUID.Zero;
1763 }
1764 }
1765
1766 item = new InventoryItemBase();
1767 item.CreatorId = objectGroup.RootPart.CreatorID.ToString();
1768 item.ID = UUID.Random();
1769 item.InvType = (int)InventoryType.Object;
1770 item.Folder = folder.ID;
1771 item.Owner = userID;
1772 }
1773
1774 AssetBase asset = CreateAsset(
1775 objectGroup.GetPartName(objectGroup.RootPart.LocalId),
1776 objectGroup.GetPartDescription(objectGroup.RootPart.LocalId),
1777 (sbyte)AssetType.Object,
1778 Utils.StringToBytes(sceneObjectXml));
1779 AssetService.Store(asset);
1780 assetID = asset.FullID;
1781
1782 if (DeRezAction.SaveToExistingUserInventoryItem == action)
1783 {
1784 item.AssetID = asset.FullID;
1785 InventoryService.UpdateItem(item);
1786 }
1787 else
1788 {
1789 item.AssetID = asset.FullID;
1790
1791 if (remoteClient != null && (remoteClient.AgentId != objectGroup.RootPart.OwnerID) && Permissions.PropagatePermissions())
1792 {
1793 uint perms=objectGroup.GetEffectivePermissions();
1794 uint nextPerms=(perms & 7) << 13;
1795 if ((nextPerms & (uint)PermissionMask.Copy) == 0)
1796 perms &= ~(uint)PermissionMask.Copy;
1797 if ((nextPerms & (uint)PermissionMask.Transfer) == 0)
1798 perms &= ~(uint)PermissionMask.Transfer;
1799 if ((nextPerms & (uint)PermissionMask.Modify) == 0)
1800 perms &= ~(uint)PermissionMask.Modify;
1801
1802 item.BasePermissions = perms & objectGroup.RootPart.NextOwnerMask;
1803 item.CurrentPermissions = item.BasePermissions;
1804 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1805 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask & objectGroup.RootPart.NextOwnerMask;
1806 item.GroupPermissions = objectGroup.RootPart.GroupMask & objectGroup.RootPart.NextOwnerMask;
1807 item.CurrentPermissions |= 8; // Slam!
1808 }
1809 else
1810 {
1811 uint ownerPerms = objectGroup.GetEffectivePermissions();
1812 if ((objectGroup.RootPart.OwnerMask & (uint)PermissionMask.Modify) != 0)
1813 ownerPerms |= (uint)PermissionMask.Modify;
1814
1815 item.BasePermissions = ownerPerms;
1816 item.CurrentPermissions = ownerPerms;
1817
1818 item.NextPermissions = objectGroup.RootPart.NextOwnerMask;
1819 item.EveryOnePermissions = objectGroup.RootPart.EveryoneMask;
1820 item.GroupPermissions = objectGroup.RootPart.GroupMask;
1821
1822 item.CurrentPermissions |= 8; // Slam!
1823 }
1824
1825 // TODO: add the new fields (Flags, Sale info, etc)
1826 item.CreationDate = Util.UnixTimeSinceEpoch();
1827 item.Description = asset.Description;
1828 item.Name = asset.Name;
1829 item.AssetType = asset.Type;
1830
1831 InventoryService.AddItem(item);
1832
1833 if (remoteClient != null && item.Owner == remoteClient.AgentId)
1834 {
1835 remoteClient.SendInventoryItemCreateUpdate(item, 0);
1836 }
1837 else
1838 {
1839 ScenePresence notifyUser = GetScenePresence(item.Owner);
1840 if (notifyUser != null)
1841 {
1842 notifyUser.ControllingClient.SendInventoryItemCreateUpdate(item, 0);
1843 }
1844 }
1845 }
1846
1847 return assetID;
1848 }
1849
1850 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID) 1560 public void UpdateKnownItem(IClientAPI remoteClient, SceneObjectGroup grp, UUID itemID, UUID agentID)
1851 { 1561 {
1852 SceneObjectGroup objectGroup = grp; 1562 SceneObjectGroup objectGroup = grp;
@@ -1873,7 +1583,8 @@ namespace OpenSim.Region.Framework.Scenes
1873 objectGroup.GetPartName(objectGroup.LocalId), 1583 objectGroup.GetPartName(objectGroup.LocalId),
1874 objectGroup.GetPartDescription(objectGroup.LocalId), 1584 objectGroup.GetPartDescription(objectGroup.LocalId),
1875 (sbyte)AssetType.Object, 1585 (sbyte)AssetType.Object,
1876 Utils.StringToBytes(sceneObjectXml)); 1586 Utils.StringToBytes(sceneObjectXml),
1587 remoteClient.AgentId);
1877 AssetService.Store(asset); 1588 AssetService.Store(asset);
1878 1589
1879 item.AssetID = asset.FullID; 1590 item.AssetID = asset.FullID;
@@ -1920,7 +1631,8 @@ namespace OpenSim.Region.Framework.Scenes
1920 grp.GetPartName(grp.LocalId), 1631 grp.GetPartName(grp.LocalId),
1921 grp.GetPartDescription(grp.LocalId), 1632 grp.GetPartDescription(grp.LocalId),
1922 (sbyte)AssetType.Object, 1633 (sbyte)AssetType.Object,
1923 Utils.StringToBytes(sceneObjectXml)); 1634 Utils.StringToBytes(sceneObjectXml),
1635 remoteClient.AgentId);
1924 AssetService.Store(asset); 1636 AssetService.Store(asset);
1925 1637
1926 InventoryItemBase item = new InventoryItemBase(); 1638 InventoryItemBase item = new InventoryItemBase();
@@ -1987,225 +1699,11 @@ namespace OpenSim.Region.Framework.Scenes
1987 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 1699 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
1988 bool RezSelected, bool RemoveItem, UUID fromTaskID) 1700 bool RezSelected, bool RemoveItem, UUID fromTaskID)
1989 { 1701 {
1990 RezObject( 1702 IInventoryAccessModule invAccess = RequestModuleInterface<IInventoryAccessModule>();
1991 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection, 1703 if (invAccess != null)
1992 RezSelected, RemoveItem, fromTaskID, false); 1704 invAccess.RezObject(
1993 } 1705 remoteClient, itemID, RayEnd, RayStart, RayTargetID, BypassRayCast, RayEndIsIntersection,
1994 1706 RezSelected, RemoveItem, fromTaskID, false);
1995 /// <summary>
1996 /// Rez an object into the scene from the user's inventory
1997 /// </summary>
1998 /// <param name="remoteClient"></param>
1999 /// <param name="itemID"></param>
2000 /// <param name="RayEnd"></param>
2001 /// <param name="RayStart"></param>
2002 /// <param name="RayTargetID"></param>
2003 /// <param name="BypassRayCast"></param>
2004 /// <param name="RayEndIsIntersection"></param>
2005 /// <param name="RezSelected"></param>
2006 /// <param name="RemoveItem"></param>
2007 /// <param name="fromTaskID"></param>
2008 /// <param name="attachment"></param>
2009 /// <returns>The SceneObjectGroup rezzed or null if rez was unsuccessful.</returns>
2010 public virtual SceneObjectGroup RezObject(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, Vector3 RayStart,
2011 UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
2012 bool RezSelected, bool RemoveItem, UUID fromTaskID, bool attachment)
2013 {
2014 // Work out position details
2015 byte bRayEndIsIntersection = (byte)0;
2016
2017 if (RayEndIsIntersection)
2018 {
2019 bRayEndIsIntersection = (byte)1;
2020 }
2021 else
2022 {
2023 bRayEndIsIntersection = (byte)0;
2024 }
2025
2026 Vector3 scale = new Vector3(0.5f, 0.5f, 0.5f);
2027
2028
2029 Vector3 pos = GetNewRezLocation(
2030 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2031 BypassRayCast, bRayEndIsIntersection,true,scale, false);
2032
2033 // Rez object
2034 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2035 item = InventoryService.GetItem(item);
2036
2037 if (item != null)
2038 {
2039 AssetBase rezAsset = AssetService.Get(item.AssetID.ToString());
2040
2041 if (rezAsset != null)
2042 {
2043 UUID itemId = UUID.Zero;
2044
2045 // If we have permission to copy then link the rezzed object back to the user inventory
2046 // item that it came from. This allows us to enable 'save object to inventory'
2047 if (!Permissions.BypassPermissions())
2048 {
2049 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == (uint)PermissionMask.Copy)
2050 {
2051 itemId = item.ID;
2052 }
2053 }
2054 else
2055 {
2056 // Brave new fullperm world
2057 //
2058 itemId = item.ID;
2059 }
2060
2061 string xmlData = Utils.BytesToString(rezAsset.Data);
2062 SceneObjectGroup group
2063 = SceneObjectSerializer.FromOriginalXmlFormat(itemId, xmlData);
2064
2065 if (!Permissions.CanRezObject(
2066 group.Children.Count, remoteClient.AgentId, pos)
2067 && !attachment)
2068 {
2069 // The client operates in no fail mode. It will
2070 // have already removed the item from the folder
2071 // if it's no copy.
2072 // Put it back if it's not an attachment
2073 //
2074 if (((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0) && (!attachment))
2075 remoteClient.SendBulkUpdateInventory(item);
2076 return null;
2077 }
2078
2079 group.ResetIDs();
2080
2081 if (attachment)
2082 {
2083 group.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
2084 group.RootPart.IsAttachment = true;
2085 }
2086
2087 AddNewSceneObject(group, true);
2088
2089 // m_log.InfoFormat("ray end point for inventory rezz is {0} {1} {2} ", RayEnd.X, RayEnd.Y, RayEnd.Z);
2090 // if attachment we set it's asset id so object updates can reflect that
2091 // if not, we set it's position in world.
2092 if (!attachment)
2093 {
2094 float offsetHeight = 0;
2095 pos = GetNewRezLocation(
2096 RayStart, RayEnd, RayTargetID, Quaternion.Identity,
2097 BypassRayCast, bRayEndIsIntersection, true, group.GetAxisAlignedBoundingBox(out offsetHeight), false);
2098 pos.Z += offsetHeight;
2099 group.AbsolutePosition = pos;
2100 // m_log.InfoFormat("rezx point for inventory rezz is {0} {1} {2} and offsetheight was {3}", pos.X, pos.Y, pos.Z, offsetHeight);
2101
2102 }
2103 else
2104 {
2105 group.SetFromItemID(itemID);
2106 }
2107
2108 SceneObjectPart rootPart = null;
2109 try
2110 {
2111 rootPart = group.GetChildPart(group.UUID);
2112 }
2113 catch (NullReferenceException)
2114 {
2115 string isAttachment = "";
2116
2117 if (attachment)
2118 isAttachment = " Object was an attachment";
2119
2120 m_log.Error("[AGENT INVENTORY]: Error rezzing ItemID: " + itemID + " object has no rootpart." + isAttachment);
2121 }
2122
2123 // Since renaming the item in the inventory does not affect the name stored
2124 // in the serialization, transfer the correct name from the inventory to the
2125 // object itself before we rez.
2126 rootPart.Name = item.Name;
2127 rootPart.Description = item.Description;
2128
2129 List<SceneObjectPart> partList = new List<SceneObjectPart>(group.Children.Values);
2130
2131 group.SetGroup(remoteClient.ActiveGroupId, remoteClient);
2132 if (rootPart.OwnerID != item.Owner)
2133 {
2134 //Need to kill the for sale here
2135 rootPart.ObjectSaleType = 0;
2136 rootPart.SalePrice = 10;
2137
2138 if (Permissions.PropagatePermissions())
2139 {
2140 if ((item.CurrentPermissions & 8) != 0)
2141 {
2142 foreach (SceneObjectPart part in partList)
2143 {
2144 part.EveryoneMask = item.EveryOnePermissions;
2145 part.NextOwnerMask = item.NextPermissions;
2146 part.GroupMask = 0; // DO NOT propagate here
2147 }
2148 }
2149 group.ApplyNextOwnerPermissions();
2150 }
2151 }
2152
2153 foreach (SceneObjectPart part in partList)
2154 {
2155 if (part.OwnerID != item.Owner)
2156 {
2157 part.LastOwnerID = part.OwnerID;
2158 part.OwnerID = item.Owner;
2159 part.Inventory.ChangeInventoryOwner(item.Owner);
2160 }
2161 else if (((item.CurrentPermissions & 8) != 0) && (!attachment)) // Slam!
2162 {
2163 part.EveryoneMask = item.EveryOnePermissions;
2164 part.NextOwnerMask = item.NextPermissions;
2165
2166 part.GroupMask = 0; // DO NOT propagate here
2167 }
2168 }
2169
2170 rootPart.TrimPermissions();
2171
2172 if (!attachment)
2173 {
2174 if (group.RootPart.Shape.PCode == (byte)PCode.Prim)
2175 {
2176 group.ClearPartAttachmentData();
2177 }
2178 }
2179
2180 if (!attachment)
2181 {
2182 // Fire on_rez
2183 group.CreateScriptInstances(0, true, DefaultScriptEngine, 0);
2184
2185 rootPart.ScheduleFullUpdate();
2186 }
2187
2188 if (!Permissions.BypassPermissions())
2189 {
2190 if ((item.CurrentPermissions & (uint)PermissionMask.Copy) == 0)
2191 {
2192 // If this is done on attachments, no
2193 // copy ones will be lost, so avoid it
2194 //
2195 if (!attachment)
2196 {
2197 List<UUID> uuids = new List<UUID>();
2198 uuids.Add(item.ID);
2199 InventoryService.DeleteItems(item.Owner, uuids);
2200 }
2201 }
2202 }
2203
2204 return rootPart.ParentGroup;
2205 }
2206 }
2207
2208 return null;
2209 } 1707 }
2210 1708
2211 /// <summary> 1709 /// <summary>
@@ -2429,7 +1927,7 @@ namespace OpenSim.Region.Framework.Scenes
2429 // XXYY!! 1927 // XXYY!!
2430 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId); 1928 InventoryItemBase item = new InventoryItemBase(itemID, remoteClient.AgentId);
2431 item = InventoryService.GetItem(item); 1929 item = InventoryService.GetItem(item);
2432 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /*att.UUID*/); 1930 presence.Appearance.SetAttachment((int)AttachmentPt, itemID, item.AssetID /* att.UUID */);
2433 1931
2434 if (m_AvatarFactory != null) 1932 if (m_AvatarFactory != null)
2435 { 1933 {
diff --git a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
index ac04dc7..bc10230 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
@@ -32,7 +32,7 @@ using OpenMetaverse;
32using OpenMetaverse.Packets; 32using OpenMetaverse.Packets;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35using OpenSim.Services.Interfaces;
36 36
37namespace OpenSim.Region.Framework.Scenes 37namespace OpenSim.Region.Framework.Scenes
38{ 38{
@@ -371,14 +371,16 @@ namespace OpenSim.Region.Framework.Scenes
371 { 371 {
372 //EventManager.TriggerAvatarPickerRequest(); 372 //EventManager.TriggerAvatarPickerRequest();
373 373
374 List<AvatarPickerAvatar> AvatarResponses = new List<AvatarPickerAvatar>(); 374 List<UserAccount> accounts = UserAccountService.GetUserAccounts(RegionInfo.ScopeID, query);
375 AvatarResponses = m_sceneGridService.GenerateAgentPickerRequestResponse(RequestID, query); 375
376 if (accounts == null)
377 return;
376 378
377 AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply); 379 AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
378 // TODO: don't create new blocks if recycling an old packet 380 // TODO: don't create new blocks if recycling an old packet
379 381
380 AvatarPickerReplyPacket.DataBlock[] searchData = 382 AvatarPickerReplyPacket.DataBlock[] searchData =
381 new AvatarPickerReplyPacket.DataBlock[AvatarResponses.Count]; 383 new AvatarPickerReplyPacket.DataBlock[accounts.Count];
382 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock(); 384 AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
383 385
384 agentData.AgentID = avatarID; 386 agentData.AgentID = avatarID;
@@ -387,16 +389,16 @@ namespace OpenSim.Region.Framework.Scenes
387 //byte[] bytes = new byte[AvatarResponses.Count*32]; 389 //byte[] bytes = new byte[AvatarResponses.Count*32];
388 390
389 int i = 0; 391 int i = 0;
390 foreach (AvatarPickerAvatar item in AvatarResponses) 392 foreach (UserAccount item in accounts)
391 { 393 {
392 UUID translatedIDtem = item.AvatarID; 394 UUID translatedIDtem = item.PrincipalID;
393 searchData[i] = new AvatarPickerReplyPacket.DataBlock(); 395 searchData[i] = new AvatarPickerReplyPacket.DataBlock();
394 searchData[i].AvatarID = translatedIDtem; 396 searchData[i].AvatarID = translatedIDtem;
395 searchData[i].FirstName = Utils.StringToBytes((string) item.firstName); 397 searchData[i].FirstName = Utils.StringToBytes((string) item.FirstName);
396 searchData[i].LastName = Utils.StringToBytes((string) item.lastName); 398 searchData[i].LastName = Utils.StringToBytes((string) item.LastName);
397 i++; 399 i++;
398 } 400 }
399 if (AvatarResponses.Count == 0) 401 if (accounts.Count == 0)
400 { 402 {
401 searchData = new AvatarPickerReplyPacket.DataBlock[0]; 403 searchData = new AvatarPickerReplyPacket.DataBlock[0];
402 } 404 }
@@ -455,7 +457,24 @@ namespace OpenSim.Region.Framework.Scenes
455 } 457 }
456 ); 458 );
457 } 459 }
458 460
461 public void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client)
462 {
463 if (LibraryService != null && (LibraryService.LibraryRootFolder.Owner == uuid))
464 {
465 remote_client.SendNameReply(uuid, "Mr", "OpenSim");
466 }
467 else
468 {
469 string[] names = GetUserNames(uuid);
470 if (names.Length == 2)
471 {
472 remote_client.SendNameReply(uuid, names[0], names[1]);
473 }
474
475 }
476 }
477
459 /// <summary> 478 /// <summary>
460 /// Handle a fetch inventory request from the client 479 /// Handle a fetch inventory request from the client
461 /// </summary> 480 /// </summary>
@@ -464,7 +483,7 @@ namespace OpenSim.Region.Framework.Scenes
464 /// <param name="ownerID"></param> 483 /// <param name="ownerID"></param>
465 public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID) 484 public void HandleFetchInventory(IClientAPI remoteClient, UUID itemID, UUID ownerID)
466 { 485 {
467 if (ownerID == CommsManager.UserProfileCacheService.LibraryRoot.Owner) 486 if (LibraryService != null && LibraryService.LibraryRootFolder != null && ownerID == LibraryService.LibraryRootFolder.Owner)
468 { 487 {
469 //m_log.Debug("request info for library item"); 488 //m_log.Debug("request info for library item");
470 return; 489 return;
@@ -498,13 +517,14 @@ namespace OpenSim.Region.Framework.Scenes
498 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. 517 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
499 // can be handled transparently). 518 // can be handled transparently).
500 InventoryFolderImpl fold = null; 519 InventoryFolderImpl fold = null;
501 if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) 520 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
502 { 521 if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
503 remoteClient.SendInventoryFolderDetails( 522 {
504 fold.Owner, folderID, fold.RequestListOfItems(), 523 remoteClient.SendInventoryFolderDetails(
505 fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems); 524 fold.Owner, folderID, fold.RequestListOfItems(),
506 return; 525 fold.RequestListOfFolders(), fold.Version, fetchFolders, fetchItems);
507 } 526 return;
527 }
508 528
509 // We're going to send the reply async, because there may be 529 // We're going to send the reply async, because there may be
510 // an enormous quantity of packets -- basically the entire inventory! 530 // an enormous quantity of packets -- basically the entire inventory!
@@ -552,15 +572,16 @@ namespace OpenSim.Region.Framework.Scenes
552 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc. 572 // CachedUserInfo so that this class doesn't have to know the details (and so that multiple libraries, etc.
553 // can be handled transparently). 573 // can be handled transparently).
554 InventoryFolderImpl fold; 574 InventoryFolderImpl fold;
555 if ((fold = CommsManager.UserProfileCacheService.LibraryRoot.FindFolder(folderID)) != null) 575 if (LibraryService != null && LibraryService.LibraryRootFolder != null)
556 { 576 if ((fold = LibraryService.LibraryRootFolder.FindFolder(folderID)) != null)
557 version = 0; 577 {
558 InventoryCollection ret = new InventoryCollection(); 578 version = 0;
559 ret.Folders = new List<InventoryFolderBase>(); 579 InventoryCollection ret = new InventoryCollection();
560 ret.Items = fold.RequestListOfItems(); 580 ret.Folders = new List<InventoryFolderBase>();
581 ret.Items = fold.RequestListOfItems();
561 582
562 return ret; 583 return ret;
563 } 584 }
564 585
565 InventoryCollection contents = new InventoryCollection(); 586 InventoryCollection contents = new InventoryCollection();
566 587
diff --git a/OpenSim/Region/Framework/Scenes/Scene.cs b/OpenSim/Region/Framework/Scenes/Scene.cs
index 4d357fd..181b7c5 100644
--- a/OpenSim/Region/Framework/Scenes/Scene.cs
+++ b/OpenSim/Region/Framework/Scenes/Scene.cs
@@ -41,8 +41,7 @@ using OpenMetaverse.Imaging;
41using OpenSim.Framework; 41using OpenSim.Framework;
42using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
43using OpenSim.Framework.Communications; 43using OpenSim.Framework.Communications;
44using OpenSim.Framework.Communications.Cache; 44
45using OpenSim.Framework.Communications.Clients;
46using OpenSim.Framework.Console; 45using OpenSim.Framework.Console;
47using OpenSim.Region.Framework.Interfaces; 46using OpenSim.Region.Framework.Interfaces;
48using OpenSim.Region.Framework.Scenes.Scripting; 47using OpenSim.Region.Framework.Scenes.Scripting;
@@ -141,7 +140,6 @@ namespace OpenSim.Region.Framework.Scenes
141 protected ModuleLoader m_moduleLoader; 140 protected ModuleLoader m_moduleLoader;
142 protected StorageManager m_storageManager; 141 protected StorageManager m_storageManager;
143 protected AgentCircuitManager m_authenticateHandler; 142 protected AgentCircuitManager m_authenticateHandler;
144 public CommunicationsManager CommsManager;
145 143
146 protected SceneCommunicationService m_sceneGridService; 144 protected SceneCommunicationService m_sceneGridService;
147 public bool LoginsDisabled = true; 145 public bool LoginsDisabled = true;
@@ -189,11 +187,11 @@ namespace OpenSim.Region.Framework.Scenes
189 { 187 {
190 m_AuthorizationService = RequestModuleInterface<IAuthorizationService>(); 188 m_AuthorizationService = RequestModuleInterface<IAuthorizationService>();
191 189
192 if (m_AuthorizationService == null) 190 //if (m_AuthorizationService == null)
193 { 191 //{
194 // don't throw an exception if no authorization service is set for the time being 192 // // don't throw an exception if no authorization service is set for the time being
195 m_log.InfoFormat("[SCENE]: No Authorization service is configured"); 193 // m_log.InfoFormat("[SCENE]: No Authorization service is configured");
196 } 194 //}
197 } 195 }
198 196
199 return m_AuthorizationService; 197 return m_AuthorizationService;
@@ -240,6 +238,73 @@ namespace OpenSim.Region.Framework.Scenes
240 } 238 }
241 } 239 }
242 240
241 protected ILibraryService m_LibraryService;
242
243 public ILibraryService LibraryService
244 {
245 get
246 {
247 if (m_LibraryService == null)
248 m_LibraryService = RequestModuleInterface<ILibraryService>();
249
250 return m_LibraryService;
251 }
252 }
253
254 protected ISimulationService m_simulationService;
255 public ISimulationService SimulationService
256 {
257 get
258 {
259 if (m_simulationService == null)
260 m_simulationService = RequestModuleInterface<ISimulationService>();
261 return m_simulationService;
262 }
263 }
264
265 protected IAuthenticationService m_AuthenticationService;
266 public IAuthenticationService AuthenticationService
267 {
268 get
269 {
270 if (m_AuthenticationService == null)
271 m_AuthenticationService = RequestModuleInterface<IAuthenticationService>();
272 return m_AuthenticationService;
273 }
274 }
275
276 protected IPresenceService m_PresenceService;
277 public IPresenceService PresenceService
278 {
279 get
280 {
281 if (m_PresenceService == null)
282 m_PresenceService = RequestModuleInterface<IPresenceService>();
283 return m_PresenceService;
284 }
285 }
286 protected IUserAccountService m_UserAccountService;
287 public IUserAccountService UserAccountService
288 {
289 get
290 {
291 if (m_UserAccountService == null)
292 m_UserAccountService = RequestModuleInterface<IUserAccountService>();
293 return m_UserAccountService;
294 }
295 }
296
297 protected OpenSim.Services.Interfaces.IAvatarService m_AvatarService;
298 public OpenSim.Services.Interfaces.IAvatarService AvatarService
299 {
300 get
301 {
302 if (m_AvatarService == null)
303 m_AvatarService = RequestModuleInterface<IAvatarService>();
304 return m_AvatarService;
305 }
306 }
307
243 protected IXMLRPC m_xmlrpcModule; 308 protected IXMLRPC m_xmlrpcModule;
244 protected IWorldComm m_worldCommModule; 309 protected IWorldComm m_worldCommModule;
245 protected IAvatarFactory m_AvatarFactory; 310 protected IAvatarFactory m_AvatarFactory;
@@ -249,10 +314,8 @@ namespace OpenSim.Region.Framework.Scenes
249 } 314 }
250 protected IConfigSource m_config; 315 protected IConfigSource m_config;
251 protected IRegionSerialiserModule m_serialiser; 316 protected IRegionSerialiserModule m_serialiser;
252 protected IInterregionCommsOut m_interregionCommsOut;
253 protected IInterregionCommsIn m_interregionCommsIn;
254 protected IDialogModule m_dialogModule; 317 protected IDialogModule m_dialogModule;
255 protected ITeleportModule m_teleportModule; 318 protected IEntityTransferModule m_teleportModule;
256 319
257 protected ICapabilitiesModule m_capsModule; 320 protected ICapabilitiesModule m_capsModule;
258 public ICapabilitiesModule CapsModule 321 public ICapabilitiesModule CapsModule
@@ -483,7 +546,7 @@ namespace OpenSim.Region.Framework.Scenes
483 #region Constructors 546 #region Constructors
484 547
485 public Scene(RegionInfo regInfo, AgentCircuitManager authen, 548 public Scene(RegionInfo regInfo, AgentCircuitManager authen,
486 CommunicationsManager commsMan, SceneCommunicationService sceneGridService, 549 SceneCommunicationService sceneGridService,
487 StorageManager storeManager, 550 StorageManager storeManager,
488 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim, 551 ModuleLoader moduleLoader, bool dumpAssetsToFile, bool physicalPrim,
489 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion) 552 bool SeeIntoRegionFromNeighbor, IConfigSource config, string simulatorVersion)
@@ -519,7 +582,6 @@ namespace OpenSim.Region.Framework.Scenes
519 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4); 582 m_lastAllocatedLocalId = (uint)(random.NextDouble() * (double)(uint.MaxValue/2))+(uint)(uint.MaxValue/4);
520 m_moduleLoader = moduleLoader; 583 m_moduleLoader = moduleLoader;
521 m_authenticateHandler = authen; 584 m_authenticateHandler = authen;
522 CommsManager = commsMan;
523 m_sceneGridService = sceneGridService; 585 m_sceneGridService = sceneGridService;
524 m_storageManager = storeManager; 586 m_storageManager = storeManager;
525 m_regInfo = regInfo; 587 m_regInfo = regInfo;
@@ -778,6 +840,36 @@ namespace OpenSim.Region.Framework.Scenes
778 return m_simulatorVersion; 840 return m_simulatorVersion;
779 } 841 }
780 842
843 public string[] GetUserNames(UUID uuid)
844 {
845 string[] returnstring = new string[0];
846
847 UserAccount account = UserAccountService.GetUserAccount(RegionInfo.ScopeID, uuid);
848
849 if (account != null)
850 {
851 returnstring = new string[2];
852 returnstring[0] = account.FirstName;
853 returnstring[1] = account.LastName;
854 }
855
856 return returnstring;
857 }
858
859 public string GetUserName(UUID uuid)
860 {
861 string[] names = GetUserNames(uuid);
862 if (names.Length == 2)
863 {
864 string firstname = names[0];
865 string lastname = names[1];
866
867 return firstname + " " + lastname;
868
869 }
870 return "(hippos)";
871 }
872
781 /// <summary> 873 /// <summary>
782 /// Another region is up. 874 /// Another region is up.
783 /// 875 ///
@@ -811,7 +903,7 @@ namespace OpenSim.Region.Framework.Scenes
811 regInfo.RegionName = otherRegion.RegionName; 903 regInfo.RegionName = otherRegion.RegionName;
812 regInfo.ScopeID = otherRegion.ScopeID; 904 regInfo.ScopeID = otherRegion.ScopeID;
813 regInfo.ExternalHostName = otherRegion.ExternalHostName; 905 regInfo.ExternalHostName = otherRegion.ExternalHostName;
814 906 GridRegion r = new GridRegion(regInfo);
815 try 907 try
816 { 908 {
817 ForEachScenePresence(delegate(ScenePresence agent) 909 ForEachScenePresence(delegate(ScenePresence agent)
@@ -825,7 +917,8 @@ namespace OpenSim.Region.Framework.Scenes
825 List<ulong> old = new List<ulong>(); 917 List<ulong> old = new List<ulong>();
826 old.Add(otherRegion.RegionHandle); 918 old.Add(otherRegion.RegionHandle);
827 agent.DropOldNeighbours(old); 919 agent.DropOldNeighbours(old);
828 InformClientOfNeighbor(agent, regInfo); 920 if (m_teleportModule != null)
921 m_teleportModule.EnableChildAgent(agent, r);
829 } 922 }
830 } 923 }
831 ); 924 );
@@ -985,6 +1078,7 @@ namespace OpenSim.Region.Framework.Scenes
985 { 1078 {
986 foreach (RegionInfo region in m_regionRestartNotifyList) 1079 foreach (RegionInfo region in m_regionRestartNotifyList)
987 { 1080 {
1081 GridRegion r = new GridRegion(region);
988 try 1082 try
989 { 1083 {
990 ForEachScenePresence(delegate(ScenePresence agent) 1084 ForEachScenePresence(delegate(ScenePresence agent)
@@ -992,9 +1086,8 @@ namespace OpenSim.Region.Framework.Scenes
992 // If agent is a root agent. 1086 // If agent is a root agent.
993 if (!agent.IsChildAgent) 1087 if (!agent.IsChildAgent)
994 { 1088 {
995 //agent.ControllingClient.new 1089 if (m_teleportModule != null)
996 //this.CommsManager.InterRegion.InformRegionOfChildAgent(otherRegion.RegionHandle, agent.ControllingClient.RequestClientInfo()); 1090 m_teleportModule.EnableChildAgent(agent, r);
997 InformClientOfNeighbor(agent, region);
998 } 1091 }
999 } 1092 }
1000 ); 1093 );
@@ -1137,11 +1230,9 @@ namespace OpenSim.Region.Framework.Scenes
1137 XferManager = RequestModuleInterface<IXfer>(); 1230 XferManager = RequestModuleInterface<IXfer>();
1138 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>(); 1231 m_AvatarFactory = RequestModuleInterface<IAvatarFactory>();
1139 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>(); 1232 m_serialiser = RequestModuleInterface<IRegionSerialiserModule>();
1140 m_interregionCommsOut = RequestModuleInterface<IInterregionCommsOut>();
1141 m_interregionCommsIn = RequestModuleInterface<IInterregionCommsIn>();
1142 m_dialogModule = RequestModuleInterface<IDialogModule>(); 1233 m_dialogModule = RequestModuleInterface<IDialogModule>();
1143 m_capsModule = RequestModuleInterface<ICapabilitiesModule>(); 1234 m_capsModule = RequestModuleInterface<ICapabilitiesModule>();
1144 m_teleportModule = RequestModuleInterface<ITeleportModule>(); 1235 m_teleportModule = RequestModuleInterface<IEntityTransferModule>();
1145 } 1236 }
1146 1237
1147 #endregion 1238 #endregion
@@ -1591,7 +1682,9 @@ namespace OpenSim.Region.Framework.Scenes
1591 GridRegion region = new GridRegion(RegionInfo); 1682 GridRegion region = new GridRegion(RegionInfo);
1592 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region); 1683 string error = GridService.RegisterRegion(RegionInfo.ScopeID, region);
1593 if (error != String.Empty) 1684 if (error != String.Empty)
1685 {
1594 throw new Exception(error); 1686 throw new Exception(error);
1687 }
1595 1688
1596 m_sceneGridService.SetScene(this); 1689 m_sceneGridService.SetScene(this);
1597 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); 1690 m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);
@@ -1978,7 +2071,6 @@ namespace OpenSim.Region.Framework.Scenes
1978 /// Move the given scene object into a new region depending on which region its absolute position has moved 2071 /// Move the given scene object into a new region depending on which region its absolute position has moved
1979 /// into. 2072 /// into.
1980 /// 2073 ///
1981 /// This method locates the new region handle and offsets the prim position for the new region
1982 /// </summary> 2074 /// </summary>
1983 /// <param name="attemptedPosition">the attempted out of region position of the scene object</param> 2075 /// <param name="attemptedPosition">the attempted out of region position of the scene object</param>
1984 /// <param name="grp">the scene object that we're crossing</param> 2076 /// <param name="grp">the scene object that we're crossing</param>
@@ -2003,185 +2095,25 @@ namespace OpenSim.Region.Framework.Scenes
2003 return; 2095 return;
2004 } 2096 }
2005 2097
2006 int thisx = (int)RegionInfo.RegionLocX; 2098 if (grp.RootPart.RETURN_AT_EDGE)
2007 int thisy = (int)RegionInfo.RegionLocY;
2008 Vector3 EastCross = new Vector3(0.1f,0,0);
2009 Vector3 WestCross = new Vector3(-0.1f, 0, 0);
2010 Vector3 NorthCross = new Vector3(0, 0.1f, 0);
2011 Vector3 SouthCross = new Vector3(0, -0.1f, 0);
2012
2013
2014 // use this if no borders were crossed!
2015 ulong newRegionHandle
2016 = Util.UIntsToLong((uint)((thisx) * Constants.RegionSize),
2017 (uint)((thisy) * Constants.RegionSize));
2018
2019 Vector3 pos = attemptedPosition;
2020
2021 int changeX = 1;
2022 int changeY = 1;
2023
2024 if (TestBorderCross(attemptedPosition + WestCross, Cardinals.W))
2025 {
2026 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2027 {
2028
2029 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2030
2031 if (crossedBorderx.BorderLine.Z > 0)
2032 {
2033 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2034 changeX = (int)(crossedBorderx.BorderLine.Z /(int) Constants.RegionSize);
2035 }
2036 else
2037 pos.X = ((pos.X + Constants.RegionSize));
2038
2039 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2040 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2041
2042 if (crossedBordery.BorderLine.Z > 0)
2043 {
2044 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2045 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2046 }
2047 else
2048 pos.Y = ((pos.Y + Constants.RegionSize));
2049
2050
2051
2052 newRegionHandle
2053 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2054 (uint)((thisy - changeY) * Constants.RegionSize));
2055 // x - 1
2056 // y - 1
2057 }
2058 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2059 {
2060 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2061
2062 if (crossedBorderx.BorderLine.Z > 0)
2063 {
2064 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2065 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
2066 }
2067 else
2068 pos.X = ((pos.X + Constants.RegionSize));
2069
2070
2071 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2072 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2073
2074 if (crossedBordery.BorderLine.Z > 0)
2075 {
2076 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2077 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2078 }
2079 else
2080 pos.Y = ((pos.Y + Constants.RegionSize));
2081
2082 newRegionHandle
2083 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2084 (uint)((thisy + changeY) * Constants.RegionSize));
2085 // x - 1
2086 // y + 1
2087 }
2088 else
2089 {
2090 Border crossedBorderx = GetCrossedBorder(attemptedPosition + WestCross, Cardinals.W);
2091
2092 if (crossedBorderx.BorderLine.Z > 0)
2093 {
2094 pos.X = ((pos.X + crossedBorderx.BorderLine.Z));
2095 changeX = (int)(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize);
2096 }
2097 else
2098 pos.X = ((pos.X + Constants.RegionSize));
2099
2100 newRegionHandle
2101 = Util.UIntsToLong((uint)((thisx - changeX) * Constants.RegionSize),
2102 (uint) (thisy*Constants.RegionSize));
2103 // x - 1
2104 }
2105 }
2106 else if (TestBorderCross(attemptedPosition + EastCross, Cardinals.E))
2107 { 2099 {
2108 if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S)) 2100 // We remove the object here
2109 { 2101 try
2110
2111 pos.X = ((pos.X - Constants.RegionSize));
2112 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2113 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2114
2115 if (crossedBordery.BorderLine.Z > 0)
2116 {
2117 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z));
2118 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2119 }
2120 else
2121 pos.Y = ((pos.Y + Constants.RegionSize));
2122
2123
2124 newRegionHandle
2125 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2126 (uint)((thisy - changeY) * Constants.RegionSize));
2127 // x + 1
2128 // y - 1
2129 }
2130 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2131 {
2132 pos.X = ((pos.X - Constants.RegionSize));
2133 pos.Y = ((pos.Y - Constants.RegionSize));
2134 newRegionHandle
2135 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize),
2136 (uint)((thisy + changeY) * Constants.RegionSize));
2137 // x + 1
2138 // y + 1
2139 }
2140 else
2141 { 2102 {
2142 pos.X = ((pos.X - Constants.RegionSize)); 2103 List<SceneObjectGroup> objects = new List<SceneObjectGroup>();
2143 newRegionHandle 2104 objects.Add(grp);
2144 = Util.UIntsToLong((uint)((thisx + changeX) * Constants.RegionSize), 2105 SceneObjectGroup[] objectsArray = objects.ToArray();
2145 (uint) (thisy*Constants.RegionSize)); 2106 returnObjects(objectsArray, UUID.Zero);
2146 // x + 1
2147 } 2107 }
2148 } 2108 catch (Exception)
2149 else if (TestBorderCross(attemptedPosition + SouthCross, Cardinals.S))
2150 {
2151 Border crossedBordery = GetCrossedBorder(attemptedPosition + SouthCross, Cardinals.S);
2152 //(crossedBorderx.BorderLine.Z / (int)Constants.RegionSize)
2153
2154 if (crossedBordery.BorderLine.Z > 0)
2155 { 2109 {
2156 pos.Y = ((pos.Y + crossedBordery.BorderLine.Z)); 2110 m_log.Warn("[DATABASE]: exception when trying to return the prim that crossed the border.");
2157 changeY = (int)(crossedBordery.BorderLine.Z / (int)Constants.RegionSize);
2158 } 2111 }
2159 else 2112 return;
2160 pos.Y = ((pos.Y + Constants.RegionSize));
2161
2162 newRegionHandle
2163 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy - changeY) * Constants.RegionSize));
2164 // y - 1
2165 }
2166 else if (TestBorderCross(attemptedPosition + NorthCross, Cardinals.N))
2167 {
2168
2169 pos.Y = ((pos.Y - Constants.RegionSize));
2170 newRegionHandle
2171 = Util.UIntsToLong((uint)(thisx * Constants.RegionSize), (uint)((thisy + changeY) * Constants.RegionSize));
2172 // y + 1
2173 } 2113 }
2174 2114
2175 // Offset the positions for the new region across the border 2115 if (m_teleportModule != null)
2176 Vector3 oldGroupPosition = grp.RootPart.GroupPosition; 2116 m_teleportModule.Cross(grp, attemptedPosition, silent);
2177 grp.OffsetForNewRegion(pos);
2178
2179 // If we fail to cross the border, then reset the position of the scene object on that border.
2180 if (!CrossPrimGroupIntoNewRegion(newRegionHandle, grp, silent))
2181 {
2182 grp.OffsetForNewRegion(oldGroupPosition);
2183 grp.ScheduleGroupForFullUpdate();
2184 }
2185 } 2117 }
2186 2118
2187 public Border GetCrossedBorder(Vector3 position, Cardinals gridline) 2119 public Border GetCrossedBorder(Vector3 position, Cardinals gridline)
@@ -2365,75 +2297,6 @@ namespace OpenSim.Region.Framework.Scenes
2365 2297
2366 2298
2367 /// <summary> 2299 /// <summary>
2368 /// Move the given scene object into a new region
2369 /// </summary>
2370 /// <param name="newRegionHandle"></param>
2371 /// <param name="grp">Scene Object Group that we're crossing</param>
2372 /// <returns>
2373 /// true if the crossing itself was successful, false on failure
2374 /// FIMXE: we still return true if the crossing object was not successfully deleted from the originating region
2375 /// </returns>
2376 public bool CrossPrimGroupIntoNewRegion(ulong newRegionHandle, SceneObjectGroup grp, bool silent)
2377 {
2378 //m_log.Debug(" >>> CrossPrimGroupIntoNewRegion <<<");
2379
2380 bool successYN = false;
2381 grp.RootPart.UpdateFlag = 0;
2382 //int primcrossingXMLmethod = 0;
2383
2384 if (newRegionHandle != 0)
2385 {
2386 //string objectState = grp.GetStateSnapshot();
2387
2388 //successYN
2389 // = m_sceneGridService.PrimCrossToNeighboringRegion(
2390 // newRegionHandle, grp.UUID, m_serialiser.SaveGroupToXml2(grp), primcrossingXMLmethod);
2391 //if (successYN && (objectState != "") && m_allowScriptCrossings)
2392 //{
2393 // successYN = m_sceneGridService.PrimCrossToNeighboringRegion(
2394 // newRegionHandle, grp.UUID, objectState, 100);
2395 //}
2396
2397 // And the new channel...
2398 if (m_interregionCommsOut != null)
2399 successYN = m_interregionCommsOut.SendCreateObject(newRegionHandle, grp, true);
2400
2401 if (successYN)
2402 {
2403 // We remove the object here
2404 try
2405 {
2406 DeleteSceneObject(grp, silent);
2407 }
2408 catch (Exception e)
2409 {
2410 m_log.ErrorFormat(
2411 "[INTERREGION]: Exception deleting the old object left behind on a border crossing for {0}, {1}",
2412 grp, e);
2413 }
2414 }
2415 else
2416 {
2417 if (!grp.IsDeleted)
2418 {
2419 if (grp.RootPart.PhysActor != null)
2420 {
2421 grp.RootPart.PhysActor.CrossingFailure();
2422 }
2423 }
2424
2425 m_log.ErrorFormat("[INTERREGION]: Prim crossing failed for {0}", grp);
2426 }
2427 }
2428 else
2429 {
2430 m_log.Error("[INTERREGION]: region handle was unexpectedly 0 in Scene.CrossPrimGroupIntoNewRegion()");
2431 }
2432
2433 return successYN;
2434 }
2435
2436 /// <summary>
2437 /// Called when objects or attachments cross the border between regions. 2300 /// Called when objects or attachments cross the border between regions.
2438 /// </summary> 2301 /// </summary>
2439 /// <param name="sog"></param> 2302 /// <param name="sog"></param>
@@ -2505,6 +2368,9 @@ namespace OpenSim.Region.Framework.Scenes
2505 2368
2506 return false; 2369 return false;
2507 } 2370 }
2371
2372 sceneObject.SetScene(this);
2373
2508 // Force allocation of new LocalId 2374 // Force allocation of new LocalId
2509 // 2375 //
2510 foreach (SceneObjectPart p in sceneObject.Children.Values) 2376 foreach (SceneObjectPart p in sceneObject.Children.Values)
@@ -2545,7 +2411,7 @@ namespace OpenSim.Region.Framework.Scenes
2545 AttachObject( 2411 AttachObject(
2546 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false); 2412 sp.ControllingClient, grp.LocalId, (uint)0, grp.GroupRotation, grp.AbsolutePosition, false);
2547 RootPrim.RemFlag(PrimFlags.TemporaryOnRez); 2413 RootPrim.RemFlag(PrimFlags.TemporaryOnRez);
2548 grp.SendGroupFullUpdate(); 2414 grp.SendGroupFullUpdate();
2549 } 2415 }
2550 else 2416 else
2551 { 2417 {
@@ -2583,6 +2449,8 @@ namespace OpenSim.Region.Framework.Scenes
2583 /// <param name="client"></param> 2449 /// <param name="client"></param>
2584 public override void AddNewClient(IClientAPI client) 2450 public override void AddNewClient(IClientAPI client)
2585 { 2451 {
2452 bool vialogin = false;
2453
2586 m_clientManager.Add(client); 2454 m_clientManager.Add(client);
2587 2455
2588 CheckHeartbeat(); 2456 CheckHeartbeat();
@@ -2617,23 +2485,48 @@ namespace OpenSim.Region.Framework.Scenes
2617 { 2485 {
2618 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode); 2486 AgentCircuitData aCircuit = m_authenticateHandler.GetAgentCircuitData(client.CircuitCode);
2619 2487
2620 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName); 2488 // Do the verification here
2621 /* 2489 System.Net.EndPoint ep = client.GetClientEP();
2622 string logMsg = string.Format("[SCENE]: Adding new {0} agent for {1} in {2}", 2490 if (aCircuit != null)
2623 ((aCircuit.child == true) ? "child" : "root"), client.Name, 2491 {
2624 RegionInfo.RegionName); 2492 if ((aCircuit.teleportFlags & (uint)Constants.TeleportFlags.ViaLogin) != 0)
2625 2493 {
2626 m_log.Debug(logMsg); 2494 m_log.DebugFormat("[Scene]: Incoming client {0} {1} in region {2} via Login", aCircuit.firstname, aCircuit.lastname, RegionInfo.RegionName);
2627 */ 2495 vialogin = true;
2496 IUserAgentVerificationModule userVerification = RequestModuleInterface<IUserAgentVerificationModule>();
2497 if (userVerification != null && ep != null)
2498 {
2499 if (!userVerification.VerifyClient(aCircuit, ep.ToString()))
2500 {
2501 // uh-oh, this is fishy
2502 m_log.WarnFormat("[Scene]: Agent {0} with session {1} connecting with unidentified end point {2}. Refusing service.",
2503 client.AgentId, client.SessionId, ep.ToString());
2504 try
2505 {
2506 client.Close();
2507 }
2508 catch (Exception e)
2509 {
2510 m_log.DebugFormat("[Scene]: Exception while closing aborted client: {0}", e.StackTrace);
2511 }
2512 return;
2513 }
2514 else
2515 m_log.DebugFormat("[Scene]: User Client Verification for {0} {1} returned true", aCircuit.firstname, aCircuit.lastname);
2516 }
2517 }
2518 }
2628 2519
2629 CommsManager.UserProfileCacheService.AddNewUser(client.AgentId); 2520 m_log.Debug("[Scene] Adding new agent " + client.Name + " to scene " + RegionInfo.RegionName);
2630 2521
2631 ScenePresence sp = CreateAndAddScenePresence(client); 2522 ScenePresence sp = CreateAndAddScenePresence(client);
2523 if (aCircuit != null)
2524 sp.Appearance = aCircuit.Appearance;
2632 2525
2633 // HERE!!! Do the initial attachments right here 2526 // HERE!!! Do the initial attachments right here
2634 // first agent upon login is a root agent by design. 2527 // first agent upon login is a root agent by design.
2635 // All other AddNewClient calls find aCircuit.child to be true 2528 // All other AddNewClient calls find aCircuit.child to be true
2636 if (aCircuit == null || aCircuit.child == false) 2529 if (aCircuit == null || (aCircuit != null && aCircuit.child == false))
2637 { 2530 {
2638 sp.IsChildAgent = false; 2531 sp.IsChildAgent = false;
2639 Util.FireAndForget(delegate(object o) { sp.RezAttachments(); }); 2532 Util.FireAndForget(delegate(object o) { sp.RezAttachments(); });
@@ -2642,6 +2535,8 @@ namespace OpenSim.Region.Framework.Scenes
2642 2535
2643 m_LastLogin = Util.EnvironmentTickCount(); 2536 m_LastLogin = Util.EnvironmentTickCount();
2644 EventManager.TriggerOnNewClient(client); 2537 EventManager.TriggerOnNewClient(client);
2538 if (vialogin)
2539 EventManager.TriggerOnClientLogin(client);
2645 } 2540 }
2646 2541
2647 2542
@@ -2711,6 +2606,7 @@ namespace OpenSim.Region.Framework.Scenes
2711 client.OnGrabUpdate += ProcessObjectGrabUpdate; 2606 client.OnGrabUpdate += ProcessObjectGrabUpdate;
2712 client.OnDeGrabObject += ProcessObjectDeGrab; 2607 client.OnDeGrabObject += ProcessObjectDeGrab;
2713 client.OnUndo += m_sceneGraph.HandleUndo; 2608 client.OnUndo += m_sceneGraph.HandleUndo;
2609 client.OnRedo += m_sceneGraph.HandleRedo;
2714 client.OnObjectDescription += m_sceneGraph.PrimDescription; 2610 client.OnObjectDescription += m_sceneGraph.PrimDescription;
2715 client.OnObjectDrop += m_sceneGraph.DropObject; 2611 client.OnObjectDrop += m_sceneGraph.DropObject;
2716 client.OnObjectSaleInfo += ObjectSaleInfo; 2612 client.OnObjectSaleInfo += ObjectSaleInfo;
@@ -2758,7 +2654,6 @@ namespace OpenSim.Region.Framework.Scenes
2758 { 2654 {
2759 client.OnTeleportLocationRequest += RequestTeleportLocation; 2655 client.OnTeleportLocationRequest += RequestTeleportLocation;
2760 client.OnTeleportLandmarkRequest += RequestTeleportLandmark; 2656 client.OnTeleportLandmarkRequest += RequestTeleportLandmark;
2761 client.OnTeleportHomeRequest += TeleportClientHome;
2762 } 2657 }
2763 2658
2764 public virtual void SubscribeToClientScriptEvents(IClientAPI client) 2659 public virtual void SubscribeToClientScriptEvents(IClientAPI client)
@@ -2778,7 +2673,7 @@ namespace OpenSim.Region.Framework.Scenes
2778 2673
2779 public virtual void SubscribeToClientGridEvents(IClientAPI client) 2674 public virtual void SubscribeToClientGridEvents(IClientAPI client)
2780 { 2675 {
2781 client.OnNameFromUUIDRequest += CommsManager.HandleUUIDNameRequest; 2676 client.OnNameFromUUIDRequest += HandleUUIDNameRequest;
2782 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; 2677 client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
2783 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest; 2678 client.OnAvatarPickerRequest += ProcessAvatarPickerRequest;
2784 client.OnSetStartLocationRequest += SetHomeRezPoint; 2679 client.OnSetStartLocationRequest += SetHomeRezPoint;
@@ -2865,6 +2760,7 @@ namespace OpenSim.Region.Framework.Scenes
2865 client.OnGrabObject -= ProcessObjectGrab; 2760 client.OnGrabObject -= ProcessObjectGrab;
2866 client.OnDeGrabObject -= ProcessObjectDeGrab; 2761 client.OnDeGrabObject -= ProcessObjectDeGrab;
2867 client.OnUndo -= m_sceneGraph.HandleUndo; 2762 client.OnUndo -= m_sceneGraph.HandleUndo;
2763 client.OnRedo -= m_sceneGraph.HandleRedo;
2868 client.OnObjectDescription -= m_sceneGraph.PrimDescription; 2764 client.OnObjectDescription -= m_sceneGraph.PrimDescription;
2869 client.OnObjectDrop -= m_sceneGraph.DropObject; 2765 client.OnObjectDrop -= m_sceneGraph.DropObject;
2870 client.OnObjectSaleInfo -= ObjectSaleInfo; 2766 client.OnObjectSaleInfo -= ObjectSaleInfo;
@@ -2913,7 +2809,7 @@ namespace OpenSim.Region.Framework.Scenes
2913 { 2809 {
2914 client.OnTeleportLocationRequest -= RequestTeleportLocation; 2810 client.OnTeleportLocationRequest -= RequestTeleportLocation;
2915 client.OnTeleportLandmarkRequest -= RequestTeleportLandmark; 2811 client.OnTeleportLandmarkRequest -= RequestTeleportLandmark;
2916 client.OnTeleportHomeRequest -= TeleportClientHome; 2812 //client.OnTeleportHomeRequest -= TeleportClientHome;
2917 } 2813 }
2918 2814
2919 public virtual void UnSubscribeToClientScriptEvents(IClientAPI client) 2815 public virtual void UnSubscribeToClientScriptEvents(IClientAPI client)
@@ -2933,7 +2829,7 @@ namespace OpenSim.Region.Framework.Scenes
2933 2829
2934 public virtual void UnSubscribeToClientGridEvents(IClientAPI client) 2830 public virtual void UnSubscribeToClientGridEvents(IClientAPI client)
2935 { 2831 {
2936 client.OnNameFromUUIDRequest -= CommsManager.HandleUUIDNameRequest; 2832 client.OnNameFromUUIDRequest -= HandleUUIDNameRequest;
2937 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; 2833 client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest;
2938 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest; 2834 client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest;
2939 client.OnSetStartLocationRequest -= SetHomeRezPoint; 2835 client.OnSetStartLocationRequest -= SetHomeRezPoint;
@@ -2960,30 +2856,12 @@ namespace OpenSim.Region.Framework.Scenes
2960 /// <param name="client">The IClientAPI for the client</param> 2856 /// <param name="client">The IClientAPI for the client</param>
2961 public virtual void TeleportClientHome(UUID agentId, IClientAPI client) 2857 public virtual void TeleportClientHome(UUID agentId, IClientAPI client)
2962 { 2858 {
2963 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(agentId); 2859 if (m_teleportModule != null)
2964 if (UserProfile != null) 2860 m_teleportModule.TeleportHome(agentId, client);
2861 else
2965 { 2862 {
2966 GridRegion regionInfo = GridService.GetRegionByUUID(UUID.Zero, UserProfile.HomeRegionID); 2863 m_log.DebugFormat("[SCENE]: Unable to teleport user home: no AgentTransferModule is active");
2967 if (regionInfo == null) 2864 client.SendTeleportFailed("Unable to perform teleports on this simulator.");
2968 {
2969 uint x = 0, y = 0;
2970 Utils.LongToUInts(UserProfile.HomeRegion, out x, out y);
2971 regionInfo = GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
2972 if (regionInfo != null) // home region can be away temporarily, too
2973 {
2974 UserProfile.HomeRegionID = regionInfo.RegionID;
2975 CommsManager.UserService.UpdateUserProfile(UserProfile);
2976 }
2977 }
2978 if (regionInfo == null)
2979 {
2980 // can't find the Home region: Tell viewer and abort
2981 client.SendTeleportFailed("Your home-region could not be found.");
2982 return;
2983 }
2984 RequestTeleportLocation(
2985 client, regionInfo.RegionHandle, UserProfile.HomeLocation, UserProfile.HomeLookAt,
2986 (uint)(TPFlags.SetLastToTarget | TPFlags.ViaHome));
2987 } 2865 }
2988 } 2866 }
2989 2867
@@ -3074,7 +2952,7 @@ namespace OpenSim.Region.Framework.Scenes
3074 } 2952 }
3075 2953
3076 /// <summary> 2954 /// <summary>
3077 /// Sets the Home Point. The GridService uses this to know where to put a user when they log-in 2955 /// Sets the Home Point. The LoginService uses this to know where to put a user when they log-in
3078 /// </summary> 2956 /// </summary>
3079 /// <param name="remoteClient"></param> 2957 /// <param name="remoteClient"></param>
3080 /// <param name="regionHandle"></param> 2958 /// <param name="regionHandle"></param>
@@ -3083,27 +2961,11 @@ namespace OpenSim.Region.Framework.Scenes
3083 /// <param name="flags"></param> 2961 /// <param name="flags"></param>
3084 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags) 2962 public virtual void SetHomeRezPoint(IClientAPI remoteClient, ulong regionHandle, Vector3 position, Vector3 lookAt, uint flags)
3085 { 2963 {
3086 UserProfileData UserProfile = CommsManager.UserService.GetUserProfile(remoteClient.AgentId); 2964 if (PresenceService.SetHomeLocation(remoteClient.AgentId.ToString(), RegionInfo.RegionID, position, lookAt))
3087 if (UserProfile != null)
3088 {
3089 // I know I'm ignoring the regionHandle provided by the teleport location request.
3090 // reusing the TeleportLocationRequest delegate, so regionHandle isn't valid
3091 UserProfile.HomeRegionID = RegionInfo.RegionID;
3092 // TODO: The next line can be removed, as soon as only homeRegionID based UserServers are around.
3093 // TODO: The HomeRegion property can be removed then, too
3094 UserProfile.HomeRegion = RegionInfo.RegionHandle;
3095
3096 UserProfile.HomeLocation = position;
3097 UserProfile.HomeLookAt = lookAt;
3098 CommsManager.UserService.UpdateUserProfile(UserProfile);
3099
3100 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot. 2965 // FUBAR ALERT: this needs to be "Home position set." so the viewer saves a home-screenshot.
3101 m_dialogModule.SendAlertToUser(remoteClient, "Home position set."); 2966 m_dialogModule.SendAlertToUser(remoteClient, "Home position set.");
3102 }
3103 else 2967 else
3104 {
3105 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed."); 2968 m_dialogModule.SendAlertToUser(remoteClient, "Set Home request Failed.");
3106 }
3107 } 2969 }
3108 2970
3109 /// <summary> 2971 /// <summary>
@@ -3176,14 +3038,12 @@ namespace OpenSim.Region.Framework.Scenes
3176 m_sceneGraph.removeUserCount(!childagentYN); 3038 m_sceneGraph.removeUserCount(!childagentYN);
3177 CapsModule.RemoveCapsHandler(agentID); 3039 CapsModule.RemoveCapsHandler(agentID);
3178 3040
3179 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID)) 3041 // REFACTORING PROBLEM -- well not really a problem, but just to point out that whatever
3180 { 3042 // this method is doing is HORRIBLE!!!
3181 CommsManager.UserProfileCacheService.RemoveUser(agentID); 3043 avatar.Scene.NeedSceneCacheClear(avatar.UUID);
3182 }
3183 3044
3184 if (!avatar.IsChildAgent) 3045 if (!avatar.IsChildAgent)
3185 { 3046 {
3186 m_sceneGridService.LogOffUser(agentID, RegionInfo.RegionID, RegionInfo.RegionHandle, avatar.AbsolutePosition, avatar.Lookat);
3187 //List<ulong> childknownRegions = new List<ulong>(); 3047 //List<ulong> childknownRegions = new List<ulong>();
3188 //List<ulong> ckn = avatar.KnownChildRegionHandles; 3048 //List<ulong> ckn = avatar.KnownChildRegionHandles;
3189 //for (int i = 0; i < ckn.Count; i++) 3049 //for (int i = 0; i < ckn.Count; i++)
@@ -3238,12 +3098,6 @@ namespace OpenSim.Region.Framework.Scenes
3238 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString()); 3098 m_log.Error("[SCENE] Scene.cs:RemoveClient exception: " + e.ToString());
3239 } 3099 }
3240 3100
3241 // Remove client agent from profile, so new logins will work
3242 if (!childagentYN)
3243 {
3244 m_sceneGridService.ClearUserAgent(agentID);
3245 }
3246
3247 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode); 3101 m_authenticateHandler.RemoveCircuit(avatar.ControllingClient.CircuitCode);
3248 3102
3249 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false)); 3103 //m_log.InfoFormat("[SCENE] Memory pre GC {0}", System.GC.GetTotalMemory(false));
@@ -3317,14 +3171,6 @@ namespace OpenSim.Region.Framework.Scenes
3317 m_sceneGridService.KiPrimitive += SendKillObject; 3171 m_sceneGridService.KiPrimitive += SendKillObject;
3318 m_sceneGridService.OnGetLandData += GetLandData; 3172 m_sceneGridService.OnGetLandData += GetLandData;
3319 3173
3320 if (m_interregionCommsIn != null)
3321 {
3322 m_log.Debug("[SCENE]: Registering with InterregionCommsIn");
3323 m_interregionCommsIn.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
3324 }
3325 else
3326 m_log.Debug("[SCENE]: Unable to register with InterregionCommsIn");
3327
3328 } 3174 }
3329 3175
3330 /// <summary> 3176 /// <summary>
@@ -3342,9 +3188,6 @@ namespace OpenSim.Region.Framework.Scenes
3342 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent; 3188 m_sceneGridService.OnCloseAgentConnection -= IncomingCloseAgent;
3343 m_sceneGridService.OnGetLandData -= GetLandData; 3189 m_sceneGridService.OnGetLandData -= GetLandData;
3344 3190
3345 if (m_interregionCommsIn != null)
3346 m_interregionCommsIn.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
3347
3348 // this does nothing; should be removed 3191 // this does nothing; should be removed
3349 m_sceneGridService.Close(); 3192 m_sceneGridService.Close();
3350 3193
@@ -3401,7 +3244,7 @@ namespace OpenSim.Region.Framework.Scenes
3401 agent.AgentID, agent.circuitcode, teleportFlags); 3244 agent.AgentID, agent.circuitcode, teleportFlags);
3402 3245
3403 reason = String.Empty; 3246 reason = String.Empty;
3404 if (!AuthenticateUser(agent, out reason)) 3247 if (!VerifyUserPresence(agent, out reason))
3405 return false; 3248 return false;
3406 3249
3407 if (!AuthorizeUser(agent, out reason)) 3250 if (!AuthorizeUser(agent, out reason))
@@ -3501,40 +3344,39 @@ namespace OpenSim.Region.Framework.Scenes
3501 */// This is now handled properly in ScenePresence.MakeRootAgent 3344 */// This is now handled properly in ScenePresence.MakeRootAgent
3502 } 3345 }
3503 3346
3347 agent.teleportFlags = teleportFlags;
3504 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent); 3348 m_authenticateHandler.AddNewCircuit(agent.circuitcode, agent);
3505 3349
3506 // rewrite session_id
3507 CachedUserInfo userinfo = CommsManager.UserProfileCacheService.GetUserDetails(agent.AgentID);
3508 if (userinfo != null)
3509 {
3510 userinfo.SessionID = agent.SessionID;
3511 }
3512 else
3513 {
3514 m_log.WarnFormat(
3515 "[CONNECTION BEGIN]: We couldn't find a User Info record for {0}. This is usually an indication that the UUID we're looking up is invalid", agent.AgentID);
3516 }
3517
3518 return true; 3350 return true;
3519 } 3351 }
3520 3352
3521 /// <summary> 3353 /// <summary>
3522 /// Verifies that the user has a session on the Grid 3354 /// Verifies that the user has a presence on the Grid
3523 /// </summary> 3355 /// </summary>
3524 /// <param name="agent">Circuit Data of the Agent we're verifying</param> 3356 /// <param name="agent">Circuit Data of the Agent we're verifying</param>
3525 /// <param name="reason">Outputs the reason for the false response on this string</param> 3357 /// <param name="reason">Outputs the reason for the false response on this string</param>
3526 /// <returns>True if the user has a session on the grid. False if it does not. False will 3358 /// <returns>True if the user has a session on the grid. False if it does not. False will
3527 /// also return a reason.</returns> 3359 /// also return a reason.</returns>
3528 public virtual bool AuthenticateUser(AgentCircuitData agent, out string reason) 3360 public virtual bool VerifyUserPresence(AgentCircuitData agent, out string reason)
3529 { 3361 {
3530 reason = String.Empty; 3362 reason = String.Empty;
3531 3363
3532 bool result = CommsManager.UserService.VerifySession(agent.AgentID, agent.SessionID); 3364 IPresenceService presence = RequestModuleInterface<IPresenceService>();
3533 m_log.Debug("[CONNECTION BEGIN]: User authentication returned " + result); 3365 if (presence == null)
3534 if (!result) 3366 {
3535 reason = String.Format("Failed to authenticate user {0} {1}, access denied.", agent.firstname, agent.lastname); 3367 reason = String.Format("Failed to verify user {0} {1} in region {2}. Presence service does not exist.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3368 return false;
3369 }
3370
3371 OpenSim.Services.Interfaces.PresenceInfo pinfo = presence.GetAgent(agent.SessionID);
3536 3372
3537 return result; 3373 if (pinfo == null || (pinfo != null && pinfo.Online == false))
3374 {
3375 reason = String.Format("Failed to verify user {0} {1}, access denied to region {2}.", agent.firstname, agent.lastname, RegionInfo.RegionName);
3376 return false;
3377 }
3378
3379 return true;
3538 } 3380 }
3539 3381
3540 /// <summary> 3382 /// <summary>
@@ -3735,8 +3577,8 @@ namespace OpenSim.Region.Framework.Scenes
3735 /// <returns>true if we handled it.</returns> 3577 /// <returns>true if we handled it.</returns>
3736 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData) 3578 public virtual bool IncomingChildAgentDataUpdate(AgentData cAgentData)
3737 { 3579 {
3738// m_log.DebugFormat( 3580 m_log.DebugFormat(
3739// "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName); 3581 "[SCENE]: Incoming child agent update for {0} in {1}", cAgentData.AgentID, RegionInfo.RegionName);
3740 3582
3741 // We have to wait until the viewer contacts this region after receiving EAC. 3583 // We have to wait until the viewer contacts this region after receiving EAC.
3742 // That calls AddNewClient, which finally creates the ScenePresence 3584 // That calls AddNewClient, which finally creates the ScenePresence
@@ -3805,16 +3647,6 @@ namespace OpenSim.Region.Framework.Scenes
3805 return false; 3647 return false;
3806 } 3648 }
3807 3649
3808 public virtual bool IncomingReleaseAgent(UUID id)
3809 {
3810 return m_sceneGridService.ReleaseAgent(id);
3811 }
3812
3813 public void SendReleaseAgent(ulong regionHandle, UUID id, string uri)
3814 {
3815 m_interregionCommsOut.SendReleaseAgent(regionHandle, id, uri);
3816 }
3817
3818 /// <summary> 3650 /// <summary>
3819 /// Tell a single agent to disconnect from the region. 3651 /// Tell a single agent to disconnect from the region.
3820 /// </summary> 3652 /// </summary>
@@ -3859,30 +3691,6 @@ namespace OpenSim.Region.Framework.Scenes
3859 } 3691 }
3860 3692
3861 /// <summary> 3693 /// <summary>
3862 /// Tell neighboring regions about this agent
3863 /// When the regions respond with a true value,
3864 /// tell the agents about the region.
3865 ///
3866 /// We have to tell the regions about the agents first otherwise it'll deny them access
3867 ///
3868 /// </summary>
3869 /// <param name="presence"></param>
3870 public void InformClientOfNeighbours(ScenePresence presence)
3871 {
3872 m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
3873 }
3874
3875 /// <summary>
3876 /// Tell a neighboring region about this agent
3877 /// </summary>
3878 /// <param name="presence"></param>
3879 /// <param name="region"></param>
3880 public void InformClientOfNeighbor(ScenePresence presence, RegionInfo region)
3881 {
3882 m_sceneGridService.EnableNeighbourChildAgents(presence, m_neighbours);
3883 }
3884
3885 /// <summary>
3886 /// Tries to teleport agent to other region. 3694 /// Tries to teleport agent to other region.
3887 /// </summary> 3695 /// </summary>
3888 /// <param name="remoteClient"></param> 3696 /// <param name="remoteClient"></param>
@@ -3957,16 +3765,12 @@ namespace OpenSim.Region.Framework.Scenes
3957 } 3765 }
3958 3766
3959 if (m_teleportModule != null) 3767 if (m_teleportModule != null)
3960 { 3768 m_teleportModule.Teleport(sp, regionHandle, position, lookAt, teleportFlags);
3961 m_teleportModule.RequestTeleportToLocation(sp, regionHandle,
3962 position, lookAt, teleportFlags);
3963 }
3964 else 3769 else
3965 { 3770 {
3966 m_sceneGridService.RequestTeleportToLocation(sp, regionHandle, 3771 m_log.DebugFormat("[SCENE]: Unable to perform teleports: no AgentTransferModule is active");
3967 position, lookAt, teleportFlags); 3772 sp.ControllingClient.SendTeleportFailed("Unable to perform teleports on this simulator.");
3968 } 3773 }
3969
3970 } 3774 }
3971 } 3775 }
3972 3776
@@ -3992,7 +3796,12 @@ namespace OpenSim.Region.Framework.Scenes
3992 3796
3993 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying) 3797 public void CrossAgentToNewRegion(ScenePresence agent, bool isFlying)
3994 { 3798 {
3995 m_sceneGridService.CrossAgentToNewRegion(this, agent, isFlying); 3799 if (m_teleportModule != null)
3800 m_teleportModule.Cross(agent, isFlying);
3801 else
3802 {
3803 m_log.DebugFormat("[SCENE]: Unable to cross agent to neighbouring region, because there is no AgentTransferModule");
3804 }
3996 } 3805 }
3997 3806
3998 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence) 3807 public void SendOutChildAgentUpdates(AgentPosition cadu, ScenePresence presence)
@@ -4018,35 +3827,6 @@ namespace OpenSim.Region.Framework.Scenes
4018 objectCapacity = objects; 3827 objectCapacity = objects;
4019 } 3828 }
4020 3829
4021 public List<FriendListItem> GetFriendList(string id)
4022 {
4023 UUID avatarID;
4024 if (!UUID.TryParse(id, out avatarID))
4025 return new List<FriendListItem>();
4026
4027 return CommsManager.GetUserFriendList(avatarID);
4028 }
4029
4030 public Dictionary<UUID, FriendRegionInfo> GetFriendRegionInfos(List<UUID> uuids)
4031 {
4032 return CommsManager.GetFriendRegionInfos(uuids);
4033 }
4034
4035 public virtual void StoreAddFriendship(UUID ownerID, UUID friendID, uint perms)
4036 {
4037 m_sceneGridService.AddNewUserFriend(ownerID, friendID, perms);
4038 }
4039
4040 public virtual void StoreUpdateFriendship(UUID ownerID, UUID friendID, uint perms)
4041 {
4042 m_sceneGridService.UpdateUserFriendPerms(ownerID, friendID, perms);
4043 }
4044
4045 public virtual void StoreRemoveFriendship(UUID ownerID, UUID ExfriendID)
4046 {
4047 m_sceneGridService.RemoveUserFriend(ownerID, ExfriendID);
4048 }
4049
4050 #endregion 3830 #endregion
4051 3831
4052 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set) 3832 public void HandleObjectPermissionsUpdate(IClientAPI controller, UUID agentID, UUID sessionID, byte field, uint localId, uint mask, byte set)
@@ -4638,7 +4418,8 @@ namespace OpenSim.Region.Framework.Scenes
4638 group.GetPartName(localID), 4418 group.GetPartName(localID),
4639 group.GetPartDescription(localID), 4419 group.GetPartDescription(localID),
4640 (sbyte)AssetType.Object, 4420 (sbyte)AssetType.Object,
4641 Utils.StringToBytes(sceneObjectXml)); 4421 Utils.StringToBytes(sceneObjectXml),
4422 group.OwnerID);
4642 AssetService.Store(asset); 4423 AssetService.Store(asset);
4643 4424
4644 InventoryItemBase item = new InventoryItemBase(); 4425 InventoryItemBase item = new InventoryItemBase();
@@ -4962,5 +4743,15 @@ namespace OpenSim.Region.Framework.Scenes
4962 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000) 4743 if (Util.EnvironmentTickCountSubtract(m_lastUpdate) > 2000)
4963 StartTimer(); 4744 StartTimer();
4964 } 4745 }
4746
4747 public override ISceneObject DeserializeObject(string representation)
4748 {
4749 return SceneObjectSerializer.FromXml2Format(representation);
4750 }
4751
4752 public override bool AllowScriptCrossings
4753 {
4754 get { return m_allowScriptCrossings; }
4755 }
4965 } 4756 }
4966} 4757}
diff --git a/OpenSim/Region/Framework/Scenes/SceneBase.cs b/OpenSim/Region/Framework/Scenes/SceneBase.cs
index 1547f9a..4f6e824 100644
--- a/OpenSim/Region/Framework/Scenes/SceneBase.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneBase.cs
@@ -34,7 +34,7 @@ using log4net;
34using Nini.Config; 34using Nini.Config;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Framework.Console; 36using OpenSim.Framework.Console;
37using OpenSim.Framework.Communications.Cache; 37
38using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
39using GridRegion = OpenSim.Services.Interfaces.GridRegion; 39using GridRegion = OpenSim.Services.Interfaces.GridRegion;
40 40
@@ -262,7 +262,7 @@ namespace OpenSim.Region.Framework.Scenes
262 /// Returns a new unallocated local ID 262 /// Returns a new unallocated local ID
263 /// </summary> 263 /// </summary>
264 /// <returns>A brand new local ID</returns> 264 /// <returns>A brand new local ID</returns>
265 protected internal uint AllocateLocalId() 265 public uint AllocateLocalId()
266 { 266 {
267 uint myID; 267 uint myID;
268 268
@@ -510,5 +510,16 @@ namespace OpenSim.Region.Framework.Scenes
510 510
511 MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback); 511 MainConsole.Instance.Commands.AddCommand(modulename, shared, command, shorthelp, longhelp, callback);
512 } 512 }
513
514 public virtual ISceneObject DeserializeObject(string representation)
515 {
516 return null;
517 }
518
519 public virtual bool AllowScriptCrossings
520 {
521 get { return false; }
522 }
523
513 } 524 }
514} 525}
diff --git a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
index 5f84252..8a74d7b 100644
--- a/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneCommunicationService.cs
@@ -36,7 +36,6 @@ using log4net;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Client; 37using OpenSim.Framework.Client;
38using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
39using OpenSim.Framework.Communications.Cache;
40using OpenSim.Framework.Capabilities; 39using OpenSim.Framework.Capabilities;
41using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Services.Interfaces; 41using OpenSim.Services.Interfaces;
@@ -56,8 +55,6 @@ namespace OpenSim.Region.Framework.Scenes
56 { 55 {
57 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
58 57
59 protected CommunicationsManager m_commsProvider;
60 protected IInterregionCommsOut m_interregionCommsOut;
61 protected RegionInfo m_regionInfo; 58 protected RegionInfo m_regionInfo;
62 protected Scene m_scene; 59 protected Scene m_scene;
63 60
@@ -118,17 +115,14 @@ namespace OpenSim.Region.Framework.Scenes
118 115
119 public KiPrimitiveDelegate KiPrimitive; 116 public KiPrimitiveDelegate KiPrimitive;
120 117
121 public SceneCommunicationService(CommunicationsManager commsMan) 118 public SceneCommunicationService()
122 { 119 {
123 m_commsProvider = commsMan;
124 m_agentsInTransit = new List<UUID>();
125 } 120 }
126 121
127 public void SetScene(Scene s) 122 public void SetScene(Scene s)
128 { 123 {
129 m_scene = s; 124 m_scene = s;
130 m_regionInfo = s.RegionInfo; 125 m_regionInfo = s.RegionInfo;
131 m_interregionCommsOut = m_scene.RequestModuleInterface<IInterregionCommsOut>();
132 } 126 }
133 127
134 /// <summary> 128 /// <summary>
@@ -148,377 +142,6 @@ namespace OpenSim.Region.Framework.Scenes
148 { 142 {
149 } 143 }
150 144
151 #region CommsManager Event handlers
152
153 /// <summary>
154 /// A New User will arrive shortly, Informs the scene that there's a new user on the way
155 /// </summary>
156 /// <param name="agent">Data we need to ensure that the agent can connect</param>
157 ///
158 protected void NewUserConnection(AgentCircuitData agent)
159 {
160 handlerExpectUser = OnExpectUser;
161 if (handlerExpectUser != null)
162 {
163 //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: OnExpectUser Fired for User:" + agent.firstname + " " + agent.lastname);
164 handlerExpectUser(agent);
165 }
166 }
167
168 /// <summary>
169 /// The Grid has requested us to log-off the user
170 /// </summary>
171 /// <param name="AgentID">Unique ID of agent to log-off</param>
172 /// <param name="RegionSecret">The secret string that the region establishes with the grid when registering</param>
173 /// <param name="message">The message to send to the user that tells them why they were logged off</param>
174 protected void GridLogOffUser(UUID AgentID, UUID RegionSecret, string message)
175 {
176 handlerLogOffUser = OnLogOffUser;
177 if (handlerLogOffUser != null)
178 {
179 handlerLogOffUser(AgentID, RegionSecret, message);
180 }
181 }
182
183 /// <summary>
184 /// Inform the scene that we've got an update about a child agent that we have
185 /// </summary>
186 /// <param name="cAgentData"></param>
187 /// <returns></returns>
188 protected bool ChildAgentUpdate(ChildAgentDataUpdate cAgentData)
189 {
190 handlerChildAgentUpdate = OnChildAgentUpdate;
191 if (handlerChildAgentUpdate != null)
192 handlerChildAgentUpdate(cAgentData);
193
194 return true;
195 }
196
197
198 protected void AgentCrossing(UUID agentID, Vector3 position, bool isFlying)
199 {
200 handlerAvatarCrossingIntoRegion = OnAvatarCrossingIntoRegion;
201 if (handlerAvatarCrossingIntoRegion != null)
202 {
203 handlerAvatarCrossingIntoRegion(agentID, position, isFlying);
204 }
205 }
206
207 protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical)
208 {
209 handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
210 if (handlerPrimCrossingIntoRegion != null)
211 {
212 handlerPrimCrossingIntoRegion(primID, position, isPhysical);
213 }
214 }
215
216 protected bool CloseConnection(UUID agentID)
217 {
218 m_log.Debug("[INTERREGION]: Incoming Agent Close Request for agent: " + agentID);
219
220 handlerCloseAgentConnection = OnCloseAgentConnection;
221 if (handlerCloseAgentConnection != null)
222 {
223 return handlerCloseAgentConnection(agentID);
224 }
225
226 return false;
227 }
228
229 protected LandData FetchLandData(uint x, uint y)
230 {
231 handlerGetLandData = OnGetLandData;
232 if (handlerGetLandData != null)
233 {
234 return handlerGetLandData(x, y);
235 }
236 return null;
237 }
238
239 #endregion
240
241 #region Inform Client of Neighbours
242
243 private delegate void InformClientOfNeighbourDelegate(
244 ScenePresence avatar, AgentCircuitData a, GridRegion reg, IPEndPoint endPoint, bool newAgent);
245
246 private void InformClientOfNeighbourCompleted(IAsyncResult iar)
247 {
248 InformClientOfNeighbourDelegate icon = (InformClientOfNeighbourDelegate) iar.AsyncState;
249 icon.EndInvoke(iar);
250 }
251
252 /// <summary>
253 /// Async component for informing client of which neighbours exist
254 /// </summary>
255 /// <remarks>
256 /// This needs to run asynchronously, as a network timeout may block the thread for a long while
257 /// </remarks>
258 /// <param name="remoteClient"></param>
259 /// <param name="a"></param>
260 /// <param name="regionHandle"></param>
261 /// <param name="endPoint"></param>
262 private void InformClientOfNeighbourAsync(ScenePresence avatar, AgentCircuitData a, GridRegion reg,
263 IPEndPoint endPoint, bool newAgent)
264 {
265 // Let's wait just a little to give time to originating regions to catch up with closing child agents
266 // after a cross here
267 Thread.Sleep(500);
268
269 uint x, y;
270 Utils.LongToUInts(reg.RegionHandle, out x, out y);
271 x = x / Constants.RegionSize;
272 y = y / Constants.RegionSize;
273 m_log.Info("[INTERGRID]: Starting to inform client about neighbour " + x + ", " + y + "(" + endPoint.ToString() + ")");
274
275 string capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
276 + "/CAPS/" + a.CapsPath + "0000/";
277
278 string reason = String.Empty;
279
280
281 bool regionAccepted = m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, a, 0, out reason);
282
283 if (regionAccepted && newAgent)
284 {
285 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
286 if (eq != null)
287 {
288 #region IP Translation for NAT
289 IClientIPEndpoint ipepClient;
290 if (avatar.ClientView.TryGet(out ipepClient))
291 {
292 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
293 }
294 #endregion
295
296 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
297 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
298 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1} in region {2}",
299 capsPath, avatar.UUID, avatar.Scene.RegionInfo.RegionName);
300 }
301 else
302 {
303 avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
304 // TODO: make Event Queue disablable!
305 }
306
307 m_log.Info("[INTERGRID]: Completed inform client about neighbour " + endPoint.ToString());
308
309 }
310
311 }
312
313 public List<GridRegion> RequestNeighbours(Scene pScene, uint pRegionLocX, uint pRegionLocY)
314 {
315 Border[] northBorders = pScene.NorthBorders.ToArray();
316 Border[] southBorders = pScene.SouthBorders.ToArray();
317 Border[] eastBorders = pScene.EastBorders.ToArray();
318 Border[] westBorders = pScene.WestBorders.ToArray();
319
320 // Legacy one region. Provided for simplicity while testing the all inclusive method in the else statement.
321 if (northBorders.Length <= 1 && southBorders.Length <= 1 && eastBorders.Length <= 1 && westBorders.Length <= 1)
322 {
323 return m_scene.GridService.GetNeighbours(m_regionInfo.ScopeID, m_regionInfo.RegionID);
324 }
325 else
326 {
327 Vector2 extent = Vector2.Zero;
328 for (int i = 0; i < eastBorders.Length; i++)
329 {
330 extent.X = (eastBorders[i].BorderLine.Z > extent.X) ? eastBorders[i].BorderLine.Z : extent.X;
331 }
332 for (int i = 0; i < northBorders.Length; i++)
333 {
334 extent.Y = (northBorders[i].BorderLine.Z > extent.Y) ? northBorders[i].BorderLine.Z : extent.Y;
335 }
336
337 // Loss of fraction on purpose
338 extent.X = ((int)extent.X / (int)Constants.RegionSize) + 1;
339 extent.Y = ((int)extent.Y / (int)Constants.RegionSize) + 1;
340
341 int startX = (int)(pRegionLocX - 1) * (int)Constants.RegionSize;
342 int startY = (int)(pRegionLocY - 1) * (int)Constants.RegionSize;
343
344 int endX = ((int)pRegionLocX + (int)extent.X) * (int)Constants.RegionSize;
345 int endY = ((int)pRegionLocY + (int)extent.Y) * (int)Constants.RegionSize;
346
347 List<GridRegion> neighbours = m_scene.GridService.GetRegionRange(m_regionInfo.ScopeID, startX, endX, startY, endY);
348 neighbours.RemoveAll(delegate(GridRegion r) { return r.RegionID == m_regionInfo.RegionID; });
349
350 return neighbours;
351 }
352 }
353
354 /// <summary>
355 /// This informs all neighboring regions about agent "avatar".
356 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
357 /// </summary>
358 public void EnableNeighbourChildAgents(ScenePresence avatar, List<RegionInfo> lstneighbours)
359 {
360 List<GridRegion> neighbours = new List<GridRegion>();
361
362 if (m_regionInfo != null)
363 {
364 neighbours = RequestNeighbours(avatar.Scene,m_regionInfo.RegionLocX, m_regionInfo.RegionLocY);
365 }
366 else
367 {
368 m_log.Debug("[ENABLENEIGHBOURCHILDAGENTS]: m_regionInfo was null in EnableNeighbourChildAgents, is this a NPC?");
369 }
370
371 /// We need to find the difference between the new regions where there are no child agents
372 /// and the regions where there are already child agents. We only send notification to the former.
373 List<ulong> neighbourHandles = NeighbourHandles(neighbours); // on this region
374 neighbourHandles.Add(avatar.Scene.RegionInfo.RegionHandle); // add this region too
375 List<ulong> previousRegionNeighbourHandles ;
376
377 if (avatar.Scene.CapsModule != null)
378 {
379 previousRegionNeighbourHandles =
380 new List<ulong>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID).Keys);
381 }
382 else
383 {
384 previousRegionNeighbourHandles = new List<ulong>();
385 }
386
387 List<ulong> newRegions = NewNeighbours(neighbourHandles, previousRegionNeighbourHandles);
388 List<ulong> oldRegions = OldNeighbours(neighbourHandles, previousRegionNeighbourHandles);
389
390 //Dump("Current Neighbors", neighbourHandles);
391 //Dump("Previous Neighbours", previousRegionNeighbourHandles);
392 //Dump("New Neighbours", newRegions);
393 //Dump("Old Neighbours", oldRegions);
394
395 /// Update the scene presence's known regions here on this region
396 avatar.DropOldNeighbours(oldRegions);
397
398 /// Collect as many seeds as possible
399 Dictionary<ulong, string> seeds;
400 if (avatar.Scene.CapsModule != null)
401 seeds
402 = new Dictionary<ulong, string>(avatar.Scene.CapsModule.GetChildrenSeeds(avatar.UUID));
403 else
404 seeds = new Dictionary<ulong, string>();
405
406 //m_log.Debug(" !!! No. of seeds: " + seeds.Count);
407 if (!seeds.ContainsKey(avatar.Scene.RegionInfo.RegionHandle))
408 seeds.Add(avatar.Scene.RegionInfo.RegionHandle, avatar.ControllingClient.RequestClientInfo().CapsPath);
409
410 /// Create the necessary child agents
411 List<AgentCircuitData> cagents = new List<AgentCircuitData>();
412 foreach (GridRegion neighbour in neighbours)
413 {
414 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
415 {
416
417 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
418 agent.BaseFolder = UUID.Zero;
419 agent.InventoryFolder = UUID.Zero;
420 agent.startpos = new Vector3(128, 128, 70);
421 agent.child = true;
422
423 if (newRegions.Contains(neighbour.RegionHandle))
424 {
425 agent.CapsPath = CapsUtil.GetRandomCapsObjectPath();
426 avatar.AddNeighbourRegion(neighbour.RegionHandle, agent.CapsPath);
427 seeds.Add(neighbour.RegionHandle, agent.CapsPath);
428 }
429 else
430 agent.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, neighbour.RegionHandle);
431
432 cagents.Add(agent);
433 }
434 }
435
436 /// Update all child agent with everyone's seeds
437 foreach (AgentCircuitData a in cagents)
438 {
439 a.ChildrenCapSeeds = new Dictionary<ulong, string>(seeds);
440 }
441
442 if (avatar.Scene.CapsModule != null)
443 {
444 // These two are the same thing!
445 avatar.Scene.CapsModule.SetChildrenSeed(avatar.UUID, seeds);
446 }
447 avatar.KnownRegions = seeds;
448 //avatar.Scene.DumpChildrenSeeds(avatar.UUID);
449 //avatar.DumpKnownRegions();
450
451 bool newAgent = false;
452 int count = 0;
453 foreach (GridRegion neighbour in neighbours)
454 {
455 // Don't do it if there's already an agent in that region
456 if (newRegions.Contains(neighbour.RegionHandle))
457 newAgent = true;
458 else
459 newAgent = false;
460
461 if (neighbour.RegionHandle != avatar.Scene.RegionInfo.RegionHandle)
462 {
463 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
464 try
465 {
466 d.BeginInvoke(avatar, cagents[count], neighbour, neighbour.ExternalEndPoint, newAgent,
467 InformClientOfNeighbourCompleted,
468 d);
469 }
470
471 catch (ArgumentOutOfRangeException)
472 {
473 m_log.ErrorFormat(
474 "[REGIONINFO]: Neighbour Regions response included the current region in the neighbor list. The following region will not display to the client: {0} for region {1} ({2}, {3}).",
475 neighbour.ExternalHostName,
476 neighbour.RegionHandle,
477 neighbour.RegionLocX,
478 neighbour.RegionLocY);
479 }
480 catch (Exception e)
481 {
482 m_log.ErrorFormat(
483 "[REGIONINFO]: Could not resolve external hostname {0} for region {1} ({2}, {3}). {4}",
484 neighbour.ExternalHostName,
485 neighbour.RegionHandle,
486 neighbour.RegionLocX,
487 neighbour.RegionLocY,
488 e);
489
490 // FIXME: Okay, even though we've failed, we're still going to throw the exception on,
491 // since I don't know what will happen if we just let the client continue
492
493 // XXX: Well, decided to swallow the exception instead for now. Let us see how that goes.
494 // throw e;
495
496 }
497 }
498 count++;
499 }
500 }
501
502 /// <summary>
503 /// This informs a single neighboring region about agent "avatar".
504 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
505 /// </summary>
506 public void InformNeighborChildAgent(ScenePresence avatar, GridRegion region)
507 {
508 AgentCircuitData agent = avatar.ControllingClient.RequestClientInfo();
509 agent.BaseFolder = UUID.Zero;
510 agent.InventoryFolder = UUID.Zero;
511 agent.startpos = new Vector3(128, 128, 70);
512 agent.child = true;
513
514 InformClientOfNeighbourDelegate d = InformClientOfNeighbourAsync;
515 d.BeginInvoke(avatar, agent, region, region.ExternalEndPoint, true,
516 InformClientOfNeighbourCompleted,
517 d);
518 }
519
520 #endregion
521
522 public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle); 145 public delegate void InformNeighbourThatRegionUpDelegate(INeighbourService nService, RegionInfo region, ulong regionhandle);
523 146
524 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar) 147 private void InformNeighborsThatRegionisUpCompleted(IAsyncResult iar)
@@ -550,7 +173,7 @@ namespace OpenSim.Region.Framework.Scenes
550 } 173 }
551 else 174 else
552 { 175 {
553 m_log.WarnFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize); 176 m_log.InfoFormat("[INTERGRID]: Failed to inform neighbour {0}-{1} that I'm here.", x / Constants.RegionSize, y / Constants.RegionSize);
554 } 177 }
555 } 178 }
556 179
@@ -592,7 +215,10 @@ namespace OpenSim.Region.Framework.Scenes
592 try 215 try
593 { 216 {
594 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData); 217 //m_commsProvider.InterRegion.ChildAgentUpdate(regionHandle, cAgentData);
595 m_interregionCommsOut.SendChildAgentUpdate(regionHandle, cAgentData); 218 uint x = 0, y = 0;
219 Utils.LongToUInts(regionHandle, out x, out y);
220 GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
221 m_scene.SimulationService.UpdateAgent(destination, cAgentData);
596 } 222 }
597 catch 223 catch
598 { 224 {
@@ -652,7 +278,10 @@ namespace OpenSim.Region.Framework.Scenes
652 // let's do our best, but there's not much we can do if the neighbour doesn't accept. 278 // let's do our best, but there's not much we can do if the neighbour doesn't accept.
653 279
654 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID); 280 //m_commsProvider.InterRegion.TellRegionToCloseChildConnection(regionHandle, agentID);
655 m_interregionCommsOut.SendCloseAgent(regionHandle, agentID); 281 uint x = 0, y = 0;
282 Utils.LongToUInts(regionHandle, out x, out y);
283 GridRegion destination = m_scene.GridService.GetRegionByPosition(UUID.Zero, (int)x, (int)y);
284 m_scene.SimulationService.CloseAgent(destination, agentID);
656 } 285 }
657 286
658 private void SendCloseChildAgentCompleted(IAsyncResult iar) 287 private void SendCloseChildAgentCompleted(IAsyncResult iar)
@@ -672,848 +301,10 @@ namespace OpenSim.Region.Framework.Scenes
672 } 301 }
673 } 302 }
674 303
675
676 /// <summary>
677 /// Try to teleport an agent to a new region.
678 /// </summary>
679 /// <param name="remoteClient"></param>
680 /// <param name="RegionHandle"></param>
681 /// <param name="position"></param>
682 /// <param name="lookAt"></param>
683 /// <param name="flags"></param>
684 public virtual void RequestTeleportToLocation(ScenePresence avatar, ulong regionHandle, Vector3 position,
685 Vector3 lookAt, uint teleportFlags)
686 {
687 if (!avatar.Scene.Permissions.CanTeleport(avatar.UUID))
688 return;
689
690 bool destRegionUp = true;
691
692 IEventQueue eq = avatar.Scene.RequestModuleInterface<IEventQueue>();
693
694 // Reset animations; the viewer does that in teleports.
695 avatar.Animator.ResetAnimations();
696
697 if (regionHandle == m_regionInfo.RegionHandle)
698 {
699 m_log.DebugFormat(
700 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation {0} within {1}",
701 position, m_regionInfo.RegionName);
702
703 // Teleport within the same region
704 if (IsOutsideRegion(avatar.Scene, position) || position.Z < 0)
705 {
706 Vector3 emergencyPos = new Vector3(128, 128, 128);
707
708 m_log.WarnFormat(
709 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
710 position, avatar.Name, avatar.UUID, emergencyPos);
711 position = emergencyPos;
712 }
713
714 Vector3 currentPos = avatar.AbsolutePosition;
715 ILandObject srcLand = m_scene.LandChannel.GetLandObject(currentPos.X, currentPos.Y);
716 ILandObject destLand = m_scene.LandChannel.GetLandObject(position.X, position.Y);
717 if (srcLand != null && destLand != null && (teleportFlags & (uint)TeleportFlags.ViaLure) == 0 && (teleportFlags & (uint)TeleportFlags.ViaGodlikeLure) == 0)
718 {
719 if (srcLand.LandData.LocalID == destLand.LandData.LocalID)
720 {
721 //TPing within the same parcel. If the landing point is restricted, block the TP.
722 //Don't restrict gods, estate managers, or land owners to the TP point. This behaviour mimics agni.
723 if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID)
724 {
725 //Disabling this behaviour for now pending review. ~CasperW
726
727 //avatar.ControllingClient.SendAgentAlertMessage("Can't TP to the destination; landing point set.", false);
728 //position = currentPos;
729 }
730 }
731 else
732 {
733 //Tping to a different parcel. Respect the landing point on the destination parcel.
734 if (destLand.LandData.LandingType == (byte)1 && destLand.LandData.UserLocation != Vector3.Zero && avatar.GodLevel < 200 && !m_scene.RegionInfo.EstateSettings.IsEstateManager(avatar.UUID) && destLand.LandData.OwnerID != avatar.UUID)
735 {
736 position = destLand.LandData.UserLocation;
737 }
738 }
739 }
740
741 // TODO: Get proper AVG Height
742 float localAVHeight = 1.56f;
743 float posZLimit = 22;
744
745 // TODO: Check other Scene HeightField
746 if (position.X > 0 && position.X <= (int)Constants.RegionSize && position.Y > 0 && position.Y <=(int)Constants.RegionSize)
747 {
748 posZLimit = (float) avatar.Scene.Heightmap[(int) position.X, (int) position.Y];
749 }
750
751 float newPosZ = posZLimit + localAVHeight;
752 if (posZLimit >= (position.Z - (localAVHeight / 2)) && !(Single.IsInfinity(newPosZ) || Single.IsNaN(newPosZ)))
753 {
754 position.Z = newPosZ;
755 }
756
757 // Only send this if the event queue is null
758 if (eq == null)
759 avatar.ControllingClient.SendTeleportLocationStart();
760
761 avatar.ControllingClient.SendLocalTeleport(position, lookAt, teleportFlags);
762 avatar.Teleport(position);
763 }
764 else
765 {
766 uint x = 0, y = 0;
767 Utils.LongToUInts(regionHandle, out x, out y);
768 GridRegion reg = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
769
770 if (reg != null)
771 {
772 m_log.DebugFormat(
773 "[SCENE COMMUNICATION SERVICE]: RequestTeleportToLocation to {0} in {1}",
774 position, reg.RegionName);
775
776 if (eq == null)
777 avatar.ControllingClient.SendTeleportLocationStart();
778
779 // Let's do DNS resolution only once in this process, please!
780 // This may be a costly operation. The reg.ExternalEndPoint field is not a passive field,
781 // it's actually doing a lot of work.
782 IPEndPoint endPoint = reg.ExternalEndPoint;
783 if (endPoint.Address == null)
784 {
785 // Couldn't resolve the name. Can't TP, because the viewer wants IP addresses.
786 destRegionUp = false;
787 }
788
789 if (destRegionUp)
790 {
791 uint newRegionX = (uint)(reg.RegionHandle >> 40);
792 uint newRegionY = (((uint)(reg.RegionHandle)) >> 8);
793 uint oldRegionX = (uint)(m_regionInfo.RegionHandle >> 40);
794 uint oldRegionY = (((uint)(m_regionInfo.RegionHandle)) >> 8);
795
796 // Fixing a bug where teleporting while sitting results in the avatar ending up removed from
797 // both regions
798 if (avatar.ParentID != (uint)0)
799 avatar.StandUp();
800
801 if (!avatar.ValidateAttachments())
802 {
803 avatar.ControllingClient.SendTeleportFailed("Inconsistent attachment state");
804 return;
805 }
806
807 // the avatar.Close below will clear the child region list. We need this below for (possibly)
808 // closing the child agents, so save it here (we need a copy as it is Clear()-ed).
809 //List<ulong> childRegions = new List<ulong>(avatar.GetKnownRegionList());
810 // Compared to ScenePresence.CrossToNewRegion(), there's no obvious code to handle a teleport
811 // failure at this point (unlike a border crossing failure). So perhaps this can never fail
812 // once we reach here...
813 //avatar.Scene.RemoveCapsHandler(avatar.UUID);
814
815 string capsPath = String.Empty;
816 AgentCircuitData agentCircuit = avatar.ControllingClient.RequestClientInfo();
817 agentCircuit.BaseFolder = UUID.Zero;
818 agentCircuit.InventoryFolder = UUID.Zero;
819 agentCircuit.startpos = position;
820 agentCircuit.child = true;
821
822 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
823 {
824 // brand new agent, let's create a new caps seed
825 agentCircuit.CapsPath = CapsUtil.GetRandomCapsObjectPath();
826 }
827
828 string reason = String.Empty;
829
830 // Let's create an agent there if one doesn't exist yet.
831 //if (!m_commsProvider.InterRegion.InformRegionOfChildAgent(reg.RegionHandle, agentCircuit))
832 if (!m_interregionCommsOut.SendCreateChildAgent(reg.RegionHandle, agentCircuit, teleportFlags, out reason))
833 {
834 avatar.ControllingClient.SendTeleportFailed(String.Format("Destination is not accepting teleports: {0}",
835 reason));
836 return;
837 }
838
839 // OK, it got this agent. Let's close some child agents
840 avatar.CloseChildAgents(newRegionX, newRegionY);
841
842 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
843 {
844 #region IP Translation for NAT
845 IClientIPEndpoint ipepClient;
846 if (avatar.ClientView.TryGet(out ipepClient))
847 {
848 capsPath
849 = "http://"
850 + NetworkUtil.GetHostFor(ipepClient.EndPoint, reg.ExternalHostName)
851 + ":"
852 + reg.HttpPort
853 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
854 }
855 else
856 {
857 capsPath
858 = "http://"
859 + reg.ExternalHostName
860 + ":"
861 + reg.HttpPort
862 + CapsUtil.GetCapsSeedPath(agentCircuit.CapsPath);
863 }
864 #endregion
865
866 if (eq != null)
867 {
868 #region IP Translation for NAT
869 // Uses ipepClient above
870 if (avatar.ClientView.TryGet(out ipepClient))
871 {
872 endPoint.Address = NetworkUtil.GetIPFor(ipepClient.EndPoint, endPoint.Address);
873 }
874 #endregion
875
876 eq.EnableSimulator(reg.RegionHandle, endPoint, avatar.UUID);
877
878 // ES makes the client send a UseCircuitCode message to the destination,
879 // which triggers a bunch of things there.
880 // So let's wait
881 Thread.Sleep(2000);
882
883 eq.EstablishAgentCommunication(avatar.UUID, endPoint, capsPath);
884 }
885 else
886 {
887 avatar.ControllingClient.InformClientOfNeighbour(reg.RegionHandle, endPoint);
888 }
889 }
890 else
891 {
892 agentCircuit.CapsPath = avatar.Scene.CapsModule.GetChildSeed(avatar.UUID, reg.RegionHandle);
893 capsPath = "http://" + reg.ExternalHostName + ":" + reg.HttpPort
894 + "/CAPS/" + agentCircuit.CapsPath + "0000/";
895 }
896
897 // Expect avatar crossing is a heavy-duty function at the destination.
898 // That is where MakeRoot is called, which fetches appearance and inventory.
899 // Plus triggers OnMakeRoot, which spawns a series of asynchronous updates.
900 //m_commsProvider.InterRegion.ExpectAvatarCrossing(reg.RegionHandle, avatar.ControllingClient.AgentId,
901 // position, false);
902
903 //{
904 // avatar.ControllingClient.SendTeleportFailed("Problem with destination.");
905 // // We should close that agent we just created over at destination...
906 // List<ulong> lst = new List<ulong>();
907 // lst.Add(reg.RegionHandle);
908 // SendCloseChildAgentAsync(avatar.UUID, lst);
909 // return;
910 //}
911
912 SetInTransit(avatar.UUID);
913 // Let's send a full update of the agent. This is a synchronous call.
914 AgentData agent = new AgentData();
915 avatar.CopyTo(agent);
916 agent.Position = position;
917 agent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
918 "/agent/" + avatar.UUID.ToString() + "/" + avatar.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
919
920 m_interregionCommsOut.SendChildAgentUpdate(reg.RegionHandle, agent);
921
922 m_log.DebugFormat(
923 "[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, avatar.UUID);
924
925
926 if (eq != null)
927 {
928 eq.TeleportFinishEvent(reg.RegionHandle, 13, endPoint,
929 0, teleportFlags, capsPath, avatar.UUID);
930 }
931 else
932 {
933 avatar.ControllingClient.SendRegionTeleport(reg.RegionHandle, 13, endPoint, 4,
934 teleportFlags, capsPath);
935 }
936
937 // TeleportFinish makes the client send CompleteMovementIntoRegion (at the destination), which
938 // trigers a whole shebang of things there, including MakeRoot. So let's wait for confirmation
939 // that the client contacted the destination before we send the attachments and close things here.
940 if (!WaitForCallback(avatar.UUID))
941 {
942 // Client never contacted destination. Let's restore everything back
943 avatar.ControllingClient.SendTeleportFailed("Problems connecting to destination.");
944
945 ResetFromTransit(avatar.UUID);
946
947 // Yikes! We should just have a ref to scene here.
948 avatar.Scene.InformClientOfNeighbours(avatar);
949
950 // Finally, kill the agent we just created at the destination.
951 m_interregionCommsOut.SendCloseAgent(reg.RegionHandle, avatar.UUID);
952
953 return;
954 }
955
956 // Can't go back from here
957 if (KiPrimitive != null)
958 {
959 KiPrimitive(avatar.LocalId);
960 }
961
962 avatar.MakeChildAgent();
963
964 // CrossAttachmentsIntoNewRegion is a synchronous call. We shouldn't need to wait after it
965 avatar.CrossAttachmentsIntoNewRegion(reg.RegionHandle, true);
966
967 // Finally, let's close this previously-known-as-root agent, when the jump is outside the view zone
968
969 if (Util.IsOutsideView(oldRegionX, newRegionX, oldRegionY, newRegionY))
970 {
971 Thread.Sleep(5000);
972 avatar.Close();
973 CloseConnection(avatar.UUID);
974 }
975 else
976 // now we have a child agent in this region.
977 avatar.Reset();
978
979
980 // if (teleport success) // seems to be always success here
981 // the user may change their profile information in other region,
982 // so the userinfo in UserProfileCache is not reliable any more, delete it
983 if (avatar.Scene.NeedSceneCacheClear(avatar.UUID))
984 {
985 m_commsProvider.UserProfileCacheService.RemoveUser(avatar.UUID);
986 m_log.DebugFormat(
987 "[SCENE COMMUNICATION SERVICE]: User {0} is going to another region, profile cache removed",
988 avatar.UUID);
989 }
990 }
991 else
992 {
993 avatar.ControllingClient.SendTeleportFailed("Remote Region appears to be down");
994 }
995 }
996 else
997 {
998 // TP to a place that doesn't exist (anymore)
999 // Inform the viewer about that
1000 avatar.ControllingClient.SendTeleportFailed("The region you tried to teleport to doesn't exist anymore");
1001
1002 // and set the map-tile to '(Offline)'
1003 uint regX, regY;
1004 Utils.LongToUInts(regionHandle, out regX, out regY);
1005
1006 MapBlockData block = new MapBlockData();
1007 block.X = (ushort)(regX / Constants.RegionSize);
1008 block.Y = (ushort)(regY / Constants.RegionSize);
1009 block.Access = 254; // == not there
1010
1011 List<MapBlockData> blocks = new List<MapBlockData>();
1012 blocks.Add(block);
1013 avatar.ControllingClient.SendMapBlock(blocks, 0);
1014 }
1015 }
1016 }
1017
1018 protected bool IsOutsideRegion(Scene s, Vector3 pos)
1019 {
1020
1021 if (s.TestBorderCross(pos,Cardinals.N))
1022 return true;
1023 if (s.TestBorderCross(pos, Cardinals.S))
1024 return true;
1025 if (s.TestBorderCross(pos, Cardinals.E))
1026 return true;
1027 if (s.TestBorderCross(pos, Cardinals.W))
1028 return true;
1029
1030 return false;
1031 }
1032
1033 public bool WaitForCallback(UUID id)
1034 {
1035 int count = 200;
1036 while (m_agentsInTransit.Contains(id) && count-- > 0)
1037 {
1038 //m_log.Debug(" >>> Waiting... " + count);
1039 Thread.Sleep(100);
1040 }
1041
1042 if (count > 0)
1043 return true;
1044 else
1045 return false;
1046 }
1047
1048 public bool ReleaseAgent(UUID id)
1049 {
1050 //m_log.Debug(" >>> ReleaseAgent called <<< ");
1051 return ResetFromTransit(id);
1052 }
1053
1054 public void SetInTransit(UUID id)
1055 {
1056 lock (m_agentsInTransit)
1057 {
1058 if (!m_agentsInTransit.Contains(id))
1059 m_agentsInTransit.Add(id);
1060 }
1061 }
1062
1063 protected bool ResetFromTransit(UUID id)
1064 {
1065 lock (m_agentsInTransit)
1066 {
1067 if (m_agentsInTransit.Contains(id))
1068 {
1069 m_agentsInTransit.Remove(id);
1070 return true;
1071 }
1072 }
1073 return false;
1074 }
1075
1076 private List<ulong> NeighbourHandles(List<GridRegion> neighbours)
1077 {
1078 List<ulong> handles = new List<ulong>();
1079 foreach (GridRegion reg in neighbours)
1080 {
1081 handles.Add(reg.RegionHandle);
1082 }
1083 return handles;
1084 }
1085
1086 private List<ulong> NewNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1087 {
1088 return currentNeighbours.FindAll(delegate(ulong handle) { return !previousNeighbours.Contains(handle); });
1089 }
1090
1091// private List<ulong> CommonNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1092// {
1093// return currentNeighbours.FindAll(delegate(ulong handle) { return previousNeighbours.Contains(handle); });
1094// }
1095
1096 private List<ulong> OldNeighbours(List<ulong> currentNeighbours, List<ulong> previousNeighbours)
1097 {
1098 return previousNeighbours.FindAll(delegate(ulong handle) { return !currentNeighbours.Contains(handle); });
1099 }
1100
1101 public void CrossAgentToNewRegion(Scene scene, ScenePresence agent, bool isFlying)
1102 {
1103 Vector3 pos = agent.AbsolutePosition;
1104 Vector3 newpos = new Vector3(pos.X, pos.Y, pos.Z);
1105 uint neighbourx = m_regionInfo.RegionLocX;
1106 uint neighboury = m_regionInfo.RegionLocY;
1107 const float boundaryDistance = 1.7f;
1108 Vector3 northCross = new Vector3(0,boundaryDistance, 0);
1109 Vector3 southCross = new Vector3(0, -1 * boundaryDistance, 0);
1110 Vector3 eastCross = new Vector3(boundaryDistance, 0, 0);
1111 Vector3 westCross = new Vector3(-1 * boundaryDistance, 0, 0);
1112
1113 // distance to edge that will trigger crossing
1114
1115
1116 // distance into new region to place avatar
1117 const float enterDistance = 0.5f;
1118
1119 if (scene.TestBorderCross(pos + westCross, Cardinals.W))
1120 {
1121 if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1122 {
1123 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1124 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1125 }
1126 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1127 {
1128 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1129 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1130 {
1131 neighboury--;
1132 newpos.Y = Constants.RegionSize - enterDistance;
1133 }
1134 else
1135 {
1136 neighboury = b.TriggerRegionY;
1137 neighbourx = b.TriggerRegionX;
1138
1139 Vector3 newposition = pos;
1140 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1141 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1142 agent.ControllingClient.SendAgentAlertMessage(
1143 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1144 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1145 return;
1146 }
1147 }
1148
1149 Border ba = scene.GetCrossedBorder(pos + westCross, Cardinals.W);
1150 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1151 {
1152 neighbourx--;
1153 newpos.X = Constants.RegionSize - enterDistance;
1154 }
1155 else
1156 {
1157 neighboury = ba.TriggerRegionY;
1158 neighbourx = ba.TriggerRegionX;
1159
1160
1161 Vector3 newposition = pos;
1162 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1163 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1164 agent.ControllingClient.SendAgentAlertMessage(
1165 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1166 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1167
1168
1169 return;
1170 }
1171
1172 }
1173 else if (scene.TestBorderCross(pos + eastCross, Cardinals.E))
1174 {
1175 Border b = scene.GetCrossedBorder(pos + eastCross, Cardinals.E);
1176 neighbourx += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1177 newpos.X = enterDistance;
1178
1179 if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1180 {
1181 Border ba = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1182 if (ba.TriggerRegionX == 0 && ba.TriggerRegionY == 0)
1183 {
1184 neighboury--;
1185 newpos.Y = Constants.RegionSize - enterDistance;
1186 }
1187 else
1188 {
1189 neighboury = ba.TriggerRegionY;
1190 neighbourx = ba.TriggerRegionX;
1191 Vector3 newposition = pos;
1192 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1193 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1194 agent.ControllingClient.SendAgentAlertMessage(
1195 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1196 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1197 return;
1198 }
1199 }
1200 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1201 {
1202 Border c = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1203 neighboury += (uint)(int)(c.BorderLine.Z / (int)Constants.RegionSize);
1204 newpos.Y = enterDistance;
1205 }
1206
1207
1208 }
1209 else if (scene.TestBorderCross(pos + southCross, Cardinals.S))
1210 {
1211 Border b = scene.GetCrossedBorder(pos + southCross, Cardinals.S);
1212 if (b.TriggerRegionX == 0 && b.TriggerRegionY == 0)
1213 {
1214 neighboury--;
1215 newpos.Y = Constants.RegionSize - enterDistance;
1216 }
1217 else
1218 {
1219 neighboury = b.TriggerRegionY;
1220 neighbourx = b.TriggerRegionX;
1221 Vector3 newposition = pos;
1222 newposition.X += (scene.RegionInfo.RegionLocX - neighbourx) * Constants.RegionSize;
1223 newposition.Y += (scene.RegionInfo.RegionLocY - neighboury) * Constants.RegionSize;
1224 agent.ControllingClient.SendAgentAlertMessage(
1225 String.Format("Moving you to region {0},{1}", neighbourx, neighboury), false);
1226 InformClientToInitateTeleportToLocation(agent, neighbourx, neighboury, newposition, scene);
1227 return;
1228 }
1229 }
1230 else if (scene.TestBorderCross(pos + northCross, Cardinals.N))
1231 {
1232
1233 Border b = scene.GetCrossedBorder(pos + northCross, Cardinals.N);
1234 neighboury += (uint)(int)(b.BorderLine.Z / (int)Constants.RegionSize);
1235 newpos.Y = enterDistance;
1236 }
1237
1238 /*
1239
1240 if (pos.X < boundaryDistance) //West
1241 {
1242 neighbourx--;
1243 newpos.X = Constants.RegionSize - enterDistance;
1244 }
1245 else if (pos.X > Constants.RegionSize - boundaryDistance) // East
1246 {
1247 neighbourx++;
1248 newpos.X = enterDistance;
1249 }
1250
1251 if (pos.Y < boundaryDistance) // South
1252 {
1253 neighboury--;
1254 newpos.Y = Constants.RegionSize - enterDistance;
1255 }
1256 else if (pos.Y > Constants.RegionSize - boundaryDistance) // North
1257 {
1258 neighboury++;
1259 newpos.Y = enterDistance;
1260 }
1261 */
1262
1263 CrossAgentToNewRegionDelegate d = CrossAgentToNewRegionAsync;
1264 d.BeginInvoke(agent, newpos, neighbourx, neighboury, isFlying, CrossAgentToNewRegionCompleted, d);
1265 }
1266
1267 public delegate void InformClientToInitateTeleportToLocationDelegate(ScenePresence agent, uint regionX, uint regionY,
1268 Vector3 position,
1269 Scene initiatingScene);
1270
1271 public void InformClientToInitateTeleportToLocation(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
1272 Scene initiatingScene)
1273 {
1274
1275 // This assumes that we know what our neighbors are.
1276
1277 InformClientToInitateTeleportToLocationDelegate d = InformClientToInitiateTeleportToLocationAsync;
1278 d.BeginInvoke(agent,regionX,regionY,position,initiatingScene,
1279 InformClientToInitiateTeleportToLocationCompleted,
1280 d);
1281 }
1282
1283 public void InformClientToInitiateTeleportToLocationAsync(ScenePresence agent, uint regionX, uint regionY, Vector3 position,
1284 Scene initiatingScene)
1285 {
1286 Thread.Sleep(10000);
1287 IMessageTransferModule im = initiatingScene.RequestModuleInterface<IMessageTransferModule>();
1288 if (im != null)
1289 {
1290 UUID gotoLocation = Util.BuildFakeParcelID(
1291 Util.UIntsToLong(
1292 (regionX *
1293 (uint)Constants.RegionSize),
1294 (regionY *
1295 (uint)Constants.RegionSize)),
1296 (uint)(int)position.X,
1297 (uint)(int)position.Y,
1298 (uint)(int)position.Z);
1299 GridInstantMessage m = new GridInstantMessage(initiatingScene, UUID.Zero,
1300 "Region", agent.UUID,
1301 (byte)InstantMessageDialog.GodLikeRequestTeleport, false,
1302 "", gotoLocation, false, new Vector3(127, 0, 0),
1303 new Byte[0]);
1304 im.SendInstantMessage(m, delegate(bool success)
1305 {
1306 m_log.DebugFormat("[CLIENT]: Client Initiating Teleport sending IM success = {0}", success);
1307 });
1308
1309 }
1310 }
1311
1312 private void InformClientToInitiateTeleportToLocationCompleted(IAsyncResult iar)
1313 {
1314 InformClientToInitateTeleportToLocationDelegate icon =
1315 (InformClientToInitateTeleportToLocationDelegate) iar.AsyncState;
1316 icon.EndInvoke(iar);
1317 }
1318
1319 public delegate ScenePresence CrossAgentToNewRegionDelegate(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying);
1320
1321 /// <summary>
1322 /// This Closes child agents on neighboring regions
1323 /// Calls an asynchronous method to do so.. so it doesn't lag the sim.
1324 /// </summary>
1325 protected ScenePresence CrossAgentToNewRegionAsync(ScenePresence agent, Vector3 pos, uint neighbourx, uint neighboury, bool isFlying)
1326 {
1327 m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} to {2}-{3}", agent.Firstname, agent.Lastname, neighbourx, neighboury);
1328
1329 ulong neighbourHandle = Utils.UIntsToLong((uint)(neighbourx * Constants.RegionSize), (uint)(neighboury * Constants.RegionSize));
1330
1331 int x = (int)(neighbourx * Constants.RegionSize), y = (int)(neighboury * Constants.RegionSize);
1332 GridRegion neighbourRegion = m_scene.GridService.GetRegionByPosition(m_scene.RegionInfo.ScopeID, (int)x, (int)y);
1333
1334 if (neighbourRegion != null && agent.ValidateAttachments())
1335 {
1336 pos = pos + (agent.Velocity);
1337
1338 //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
1339 //if (userInfo != null)
1340 //{
1341 // userInfo.DropInventory();
1342 //}
1343 //else
1344 //{
1345 // m_log.WarnFormat("[SCENE COMM]: No cached user info found for {0} {1} on leaving region {2}",
1346 // agent.Name, agent.UUID, agent.Scene.RegionInfo.RegionName);
1347 //}
1348
1349 //bool crossingSuccessful =
1350 // CrossToNeighbouringRegion(neighbourHandle, agent.ControllingClient.AgentId, pos,
1351 //isFlying);
1352
1353 SetInTransit(agent.UUID);
1354 AgentData cAgent = new AgentData();
1355 agent.CopyTo(cAgent);
1356 cAgent.Position = pos;
1357 if (isFlying)
1358 cAgent.ControlFlags |= (uint)AgentManager.ControlFlags.AGENT_CONTROL_FLY;
1359 cAgent.CallbackURI = "http://" + m_regionInfo.ExternalHostName + ":" + m_regionInfo.HttpPort +
1360 "/agent/" + agent.UUID.ToString() + "/" + agent.Scene.RegionInfo.RegionHandle.ToString() + "/release/";
1361
1362 m_interregionCommsOut.SendChildAgentUpdate(neighbourHandle, cAgent);
1363
1364 // Next, let's close the child agent connections that are too far away.
1365 agent.CloseChildAgents(neighbourx, neighboury);
1366
1367 //AgentCircuitData circuitdata = m_controllingClient.RequestClientInfo();
1368 agent.ControllingClient.RequestClientInfo();
1369
1370 //m_log.Debug("BEFORE CROSS");
1371 //Scene.DumpChildrenSeeds(UUID);
1372 //DumpKnownRegions();
1373 string agentcaps;
1374 if (!agent.KnownRegions.TryGetValue(neighbourRegion.RegionHandle, out agentcaps))
1375 {
1376 m_log.ErrorFormat("[SCENE COMM]: No CAPS information for region handle {0}, exiting CrossToNewRegion.",
1377 neighbourRegion.RegionHandle);
1378 return agent;
1379 }
1380 // TODO Should construct this behind a method
1381 string capsPath =
1382 "http://" + neighbourRegion.ExternalHostName + ":" + neighbourRegion.HttpPort
1383 + "/CAPS/" + agentcaps /*circuitdata.CapsPath*/ + "0000/";
1384
1385 m_log.DebugFormat("[CAPS]: Sending new CAPS seed url {0} to client {1}", capsPath, agent.UUID);
1386
1387 IEventQueue eq = agent.Scene.RequestModuleInterface<IEventQueue>();
1388 if (eq != null)
1389 {
1390 eq.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1391 capsPath, agent.UUID, agent.ControllingClient.SessionId);
1392 }
1393 else
1394 {
1395 agent.ControllingClient.CrossRegion(neighbourHandle, pos, agent.Velocity, neighbourRegion.ExternalEndPoint,
1396 capsPath);
1397 }
1398
1399 if (!WaitForCallback(agent.UUID))
1400 {
1401 ResetFromTransit(agent.UUID);
1402
1403 // Yikes! We should just have a ref to scene here.
1404 agent.Scene.InformClientOfNeighbours(agent);
1405
1406 return agent;
1407 }
1408
1409 agent.MakeChildAgent();
1410 // now we have a child agent in this region. Request all interesting data about other (root) agents
1411 agent.SendInitialFullUpdateToAllClients();
1412
1413 agent.CrossAttachmentsIntoNewRegion(neighbourHandle, true);
1414
1415 // m_scene.SendKillObject(m_localId);
1416
1417 agent.Scene.NotifyMyCoarseLocationChange();
1418 // the user may change their profile information in other region,
1419 // so the userinfo in UserProfileCache is not reliable any more, delete it
1420 if (agent.Scene.NeedSceneCacheClear(agent.UUID))
1421 {
1422 agent.Scene.CommsManager.UserProfileCacheService.RemoveUser(agent.UUID);
1423 m_log.DebugFormat(
1424 "[SCENE COMM]: User {0} is going to another region, profile cache removed", agent.UUID);
1425 }
1426 }
1427
1428 //m_log.Debug("AFTER CROSS");
1429 //Scene.DumpChildrenSeeds(UUID);
1430 //DumpKnownRegions();
1431 return agent;
1432 }
1433
1434 private void CrossAgentToNewRegionCompleted(IAsyncResult iar)
1435 {
1436 CrossAgentToNewRegionDelegate icon = (CrossAgentToNewRegionDelegate)iar.AsyncState;
1437 ScenePresence agent = icon.EndInvoke(iar);
1438
1439 // If the cross was successful, this agent is a child agent
1440 if (agent.IsChildAgent)
1441 {
1442 agent.Reset();
1443 }
1444 else // Not successful
1445 {
1446 //CachedUserInfo userInfo = m_commsProvider.UserProfileCacheService.GetUserDetails(agent.UUID);
1447 //if (userInfo != null)
1448 //{
1449 // userInfo.FetchInventory();
1450 //}
1451 agent.RestoreInCurrentScene();
1452 }
1453 // In any case
1454 agent.NotInTransit();
1455
1456 //m_log.DebugFormat("[SCENE COMM]: Crossing agent {0} {1} completed.", agent.Firstname, agent.Lastname);
1457 }
1458
1459
1460 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, Vector3 position, Vector3 lookat)
1461 {
1462 m_commsProvider.LogOffUser(userid, regionid, regionhandle, position, lookat);
1463 }
1464
1465 // deprecated as of 2008-08-27
1466 public void LogOffUser(UUID userid, UUID regionid, ulong regionhandle, float posx, float posy, float posz)
1467 {
1468 m_commsProvider.LogOffUser(userid, regionid, regionhandle, posx, posy, posz);
1469 }
1470
1471 public void ClearUserAgent(UUID avatarID)
1472 {
1473 m_commsProvider.UserService.ClearUserAgent(avatarID);
1474 }
1475
1476 public void AddNewUserFriend(UUID friendlistowner, UUID friend, uint perms)
1477 {
1478 m_commsProvider.AddNewUserFriend(friendlistowner, friend, perms);
1479 }
1480
1481 public void UpdateUserFriendPerms(UUID friendlistowner, UUID friend, uint perms)
1482 {
1483 m_commsProvider.UpdateUserFriendPerms(friendlistowner, friend, perms);
1484 }
1485
1486 public void RemoveUserFriend(UUID friendlistowner, UUID friend)
1487 {
1488 m_commsProvider.RemoveUserFriend(friendlistowner, friend);
1489 }
1490
1491 public List<FriendListItem> GetUserFriendList(UUID friendlistowner)
1492 {
1493 return m_commsProvider.GetUserFriendList(friendlistowner);
1494 }
1495
1496 public List<AvatarPickerAvatar> GenerateAgentPickerRequestResponse(UUID queryID, string query)
1497 {
1498 return m_commsProvider.GenerateAgentPickerRequestResponse(queryID, query);
1499 }
1500
1501 public List<GridRegion> RequestNamedRegions(string name, int maxNumber) 304 public List<GridRegion> RequestNamedRegions(string name, int maxNumber)
1502 { 305 {
1503 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber); 306 return m_scene.GridService.GetRegionsByName(UUID.Zero, name, maxNumber);
1504 } 307 }
1505 308
1506 //private void Dump(string msg, List<ulong> handles)
1507 //{
1508 // m_log.InfoFormat("-------------- HANDLE DUMP ({0}) ---------", msg);
1509 // foreach (ulong handle in handles)
1510 // {
1511 // uint x, y;
1512 // Utils.LongToUInts(handle, out x, out y);
1513 // x = x / Constants.RegionSize;
1514 // y = y / Constants.RegionSize;
1515 // m_log.InfoFormat("({0}, {1})", x, y);
1516 // }
1517 //}
1518 } 309 }
1519} 310}
diff --git a/OpenSim/Region/Framework/Scenes/SceneGraph.cs b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
index 2c66719..928dc97 100644
--- a/OpenSim/Region/Framework/Scenes/SceneGraph.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneGraph.cs
@@ -35,6 +35,7 @@ using log4net;
35using OpenSim.Framework; 35using OpenSim.Framework;
36using OpenSim.Region.Framework.Scenes.Types; 36using OpenSim.Region.Framework.Scenes.Types;
37using OpenSim.Region.Physics.Manager; 37using OpenSim.Region.Physics.Manager;
38using OpenSim.Region.Framework.Interfaces;
38 39
39namespace OpenSim.Region.Framework.Scenes 40namespace OpenSim.Region.Framework.Scenes
40{ 41{
@@ -476,6 +477,15 @@ namespace OpenSim.Region.Framework.Scenes
476 part.Undo(); 477 part.Undo();
477 } 478 }
478 } 479 }
480 protected internal void HandleRedo(IClientAPI remoteClient, UUID primId)
481 {
482 if (primId != UUID.Zero)
483 {
484 SceneObjectPart part = m_parentScene.GetSceneObjectPart(primId);
485 if (part != null)
486 part.Redo();
487 }
488 }
479 489
480 protected internal void HandleObjectGroupUpdate( 490 protected internal void HandleObjectGroupUpdate(
481 IClientAPI remoteClient, UUID GroupID, uint objectLocalID, UUID Garbage) 491 IClientAPI remoteClient, UUID GroupID, uint objectLocalID, UUID Garbage)
@@ -532,33 +542,32 @@ namespace OpenSim.Region.Framework.Scenes
532 /// <returns>The scene object that was attached. Null if the scene object could not be found</returns> 542 /// <returns>The scene object that was attached. Null if the scene object could not be found</returns>
533 public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt) 543 public SceneObjectGroup RezSingleAttachment(IClientAPI remoteClient, UUID itemID, uint AttachmentPt)
534 { 544 {
535 SceneObjectGroup objatt = m_parentScene.RezObject(remoteClient, 545 IInventoryAccessModule invAccess = m_parentScene.RequestModuleInterface<IInventoryAccessModule>();
536 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true, 546 if (invAccess != null)
537 false, false, remoteClient.AgentId, true);
538
539 if (objatt != null)
540 { 547 {
541 bool tainted = false; 548 SceneObjectGroup objatt = invAccess.RezObject(remoteClient,
542 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint()) 549 itemID, Vector3.Zero, Vector3.Zero, UUID.Zero, (byte)1, true,
543 tainted = true; 550 false, false, remoteClient.AgentId, true);
544 551
545 if (AttachObject( 552
546 remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false)) 553 if (objatt != null)
547 { 554 {
555 bool tainted = false;
556 if (AttachmentPt != 0 && AttachmentPt != objatt.GetAttachmentPoint())
557 tainted = true;
558
559 AttachObject(remoteClient, objatt.LocalId, AttachmentPt, Quaternion.Identity, objatt.AbsolutePosition, false);
548 objatt.ScheduleGroupForFullUpdate(); 560 objatt.ScheduleGroupForFullUpdate();
549 if (tainted) 561 if (tainted)
550 objatt.HasGroupChanged = true; 562 objatt.HasGroupChanged = true;
551 563
552 // Fire after attach, so we don't get messy perms dialogs 564 // Fire after attach, so we don't get messy perms dialogs
553 // 3 == AttachedRez 565 // 3 == AttachedRez
554 objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3); 566 objatt.CreateScriptInstances(0, true, m_parentScene.DefaultScriptEngine, 3);
555
556 // Do this last so that event listeners have access to all the effects of the attachment
557 m_parentScene.EventManager.TriggerOnAttach(objatt.LocalId, itemID, remoteClient.AgentId);
558 } 567 }
568 return objatt;
559 } 569 }
560 570 return null;
561 return objatt;
562 } 571 }
563 572
564 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards. 573 // What makes this method odd and unique is it tries to detach using an UUID.... Yay for standards.
@@ -669,7 +678,7 @@ namespace OpenSim.Region.Framework.Scenes
669 // it get cleaned up 678 // it get cleaned up
670 // 679 //
671 group.RootPart.RemFlag(PrimFlags.TemporaryOnRez); 680 group.RootPart.RemFlag(PrimFlags.TemporaryOnRez);
672 group.HasGroupChanged = false; 681 group.HasGroupChanged = false;
673 } 682 }
674 else 683 else
675 { 684 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneManager.cs b/OpenSim/Region/Framework/Scenes/SceneManager.cs
index c2e3370..6395d98 100644
--- a/OpenSim/Region/Framework/Scenes/SceneManager.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneManager.cs
@@ -468,11 +468,11 @@ namespace OpenSim.Region.Framework.Scenes
468 return presences; 468 return presences;
469 } 469 }
470 470
471 public RegionInfo GetRegionInfo(ulong regionHandle) 471 public RegionInfo GetRegionInfo(UUID regionID)
472 { 472 {
473 foreach (Scene scene in m_localScenes) 473 foreach (Scene scene in m_localScenes)
474 { 474 {
475 if (scene.RegionInfo.RegionHandle == regionHandle) 475 if (scene.RegionInfo.RegionID == regionID)
476 { 476 {
477 return scene.RegionInfo; 477 return scene.RegionInfo;
478 } 478 }
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
index 4676a30..2a4e5a2 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
@@ -369,14 +369,22 @@ namespace OpenSim.Region.Framework.Scenes
369 } 369 }
370 370
371 lockPartsForRead(true); 371 lockPartsForRead(true);
372
373 if (RootPart.GetStatusSandbox())
372 { 374 {
373 foreach (SceneObjectPart part in m_parts.Values) 375 if (Util.GetDistanceTo(RootPart.StatusSandboxPos, value) > 10)
374 { 376 {
375 377 RootPart.ScriptSetPhysicsStatus(false);
376 part.GroupPosition = val; 378 Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"),
377 379 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
380 lockPartsForRead(false);
381 return;
378 } 382 }
379 } 383 }
384
385 foreach (SceneObjectPart part in m_parts.Values)
386 part.GroupPosition = val;
387
380 lockPartsForRead(false); 388 lockPartsForRead(false);
381 389
382 //if (m_rootPart.PhysActor != null) 390 //if (m_rootPart.PhysActor != null)
@@ -470,6 +478,34 @@ namespace OpenSim.Region.Framework.Scenes
470 } 478 }
471 } 479 }
472 480
481 private SceneObjectPart m_PlaySoundMasterPrim = null;
482 public SceneObjectPart PlaySoundMasterPrim
483 {
484 get { return m_PlaySoundMasterPrim; }
485 set { m_PlaySoundMasterPrim = value; }
486 }
487
488 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
489 public List<SceneObjectPart> PlaySoundSlavePrims
490 {
491 get { return m_LoopSoundSlavePrims; }
492 set { m_LoopSoundSlavePrims = value; }
493 }
494
495 private SceneObjectPart m_LoopSoundMasterPrim = null;
496 public SceneObjectPart LoopSoundMasterPrim
497 {
498 get { return m_LoopSoundMasterPrim; }
499 set { m_LoopSoundMasterPrim = value; }
500 }
501
502 private List<SceneObjectPart> m_LoopSoundSlavePrims = new List<SceneObjectPart>();
503 public List<SceneObjectPart> LoopSoundSlavePrims
504 {
505 get { return m_LoopSoundSlavePrims; }
506 set { m_LoopSoundSlavePrims = value; }
507 }
508
473 // The UUID for the Region this Object is in. 509 // The UUID for the Region this Object is in.
474 public UUID RegionUUID 510 public UUID RegionUUID
475 { 511 {
@@ -584,7 +620,7 @@ namespace OpenSim.Region.Framework.Scenes
584 620
585 if (m_rootPart.Shape.PCode != 9 || m_rootPart.Shape.State == 0) 621 if (m_rootPart.Shape.PCode != 9 || m_rootPart.Shape.State == 0)
586 m_rootPart.ParentID = 0; 622 m_rootPart.ParentID = 0;
587 if (m_rootPart.LocalId==0) 623 if (m_rootPart.LocalId == 0)
588 m_rootPart.LocalId = m_scene.AllocateLocalId(); 624 m_rootPart.LocalId = m_scene.AllocateLocalId();
589 625
590 // No need to lock here since the object isn't yet in a scene 626 // No need to lock here since the object isn't yet in a scene
@@ -1586,6 +1622,9 @@ namespace OpenSim.Region.Framework.Scenes
1586 /// <param name="part"></param> 1622 /// <param name="part"></param>
1587 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags) 1623 internal void SendPartFullUpdate(IClientAPI remoteClient, SceneObjectPart part, uint clientFlags)
1588 { 1624 {
1625// m_log.DebugFormat(
1626// "[SOG]: Sendinging part full update to {0} for {1} {2}", remoteClient.Name, part.Name, part.LocalId);
1627
1589 if (m_rootPart.UUID == part.UUID) 1628 if (m_rootPart.UUID == part.UUID)
1590 { 1629 {
1591 if (IsAttachment) 1630 if (IsAttachment)
@@ -1898,33 +1937,6 @@ namespace OpenSim.Region.Framework.Scenes
1898 } 1937 }
1899 } 1938 }
1900 1939
1901 public void rotLookAt(Quaternion target, float strength, float damping)
1902 {
1903 SceneObjectPart rootpart = m_rootPart;
1904 if (rootpart != null)
1905 {
1906 if (IsAttachment)
1907 {
1908 /*
1909 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
1910 if (avatar != null)
1911 {
1912 Rotate the Av?
1913 } */
1914 }
1915 else
1916 {
1917 if (rootpart.PhysActor != null)
1918 {
1919 rootpart.PhysActor.APIDTarget = new Quaternion(target.X, target.Y, target.Z, target.W);
1920 rootpart.PhysActor.APIDStrength = strength;
1921 rootpart.PhysActor.APIDDamping = damping;
1922 rootpart.PhysActor.APIDActive = true;
1923 }
1924 }
1925 }
1926 }
1927
1928 public void stopLookAt() 1940 public void stopLookAt()
1929 { 1941 {
1930 SceneObjectPart rootpart = m_rootPart; 1942 SceneObjectPart rootpart = m_rootPart;
@@ -2084,7 +2096,9 @@ namespace OpenSim.Region.Framework.Scenes
2084 2096
2085 foreach (SceneObjectPart part in m_parts.Values) 2097 foreach (SceneObjectPart part in m_parts.Values)
2086 { 2098 {
2087 2099 if (!IsSelected)
2100 part.UpdateLookAt();
2101
2088 part.SendScheduledUpdates(); 2102 part.SendScheduledUpdates();
2089 2103
2090 } 2104 }
@@ -2434,7 +2448,6 @@ namespace OpenSim.Region.Framework.Scenes
2434 2448
2435 AttachToBackup(); 2449 AttachToBackup();
2436 2450
2437
2438 // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the 2451 // Here's the deal, this is ABSOLUTELY CRITICAL so the physics scene gets the update about the
2439 // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and 2452 // position of linkset prims. IF YOU CHANGE THIS, YOU MUST TEST colliding with just linked and
2440 // unmoved prims! 2453 // unmoved prims!
@@ -2449,9 +2462,10 @@ namespace OpenSim.Region.Framework.Scenes
2449 /// an independent SceneObjectGroup. 2462 /// an independent SceneObjectGroup.
2450 /// </summary> 2463 /// </summary>
2451 /// <param name="partID"></param> 2464 /// <param name="partID"></param>
2452 public void DelinkFromGroup(uint partID) 2465 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
2466 public SceneObjectGroup DelinkFromGroup(uint partID)
2453 { 2467 {
2454 DelinkFromGroup(partID, true); 2468 return DelinkFromGroup(partID, true);
2455 } 2469 }
2456 2470
2457 /// <summary> 2471 /// <summary>
@@ -2460,28 +2474,39 @@ namespace OpenSim.Region.Framework.Scenes
2460 /// </summary> 2474 /// </summary>
2461 /// <param name="partID"></param> 2475 /// <param name="partID"></param>
2462 /// <param name="sendEvents"></param> 2476 /// <param name="sendEvents"></param>
2463 public void DelinkFromGroup(uint partID, bool sendEvents) 2477 /// <returns>The object group of the newly delinked prim. Null if part could not be found</returns>
2478 public SceneObjectGroup DelinkFromGroup(uint partID, bool sendEvents)
2464 { 2479 {
2465 SceneObjectPart linkPart = GetChildPart(partID); 2480 SceneObjectPart linkPart = GetChildPart(partID);
2466 2481
2467 if (linkPart != null) 2482 if (linkPart != null)
2468 { 2483 {
2469 DelinkFromGroup(linkPart, sendEvents); 2484 return DelinkFromGroup(linkPart, sendEvents);
2470 } 2485 }
2471 else 2486 else
2472 { 2487 {
2473 m_log.InfoFormat("[SCENE OBJECT GROUP]: " + 2488 m_log.WarnFormat("[SCENE OBJECT GROUP]: " +
2474 "DelinkFromGroup(): Child prim {0} not found in object {1}, {2}", 2489 "DelinkFromGroup(): Child prim {0} not found in object {1}, {2}",
2475 partID, LocalId, UUID); 2490 partID, LocalId, UUID);
2491
2492 return null;
2476 } 2493 }
2477 } 2494 }
2478 2495
2479 public void DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents) 2496 /// <summary>
2497 /// Delink the given prim from this group. The delinked prim is established as
2498 /// an independent SceneObjectGroup.
2499 /// </summary>
2500 /// <param name="partID"></param>
2501 /// <param name="sendEvents"></param>
2502 /// <returns>The object group of the newly delinked prim.</returns>
2503 public SceneObjectGroup DelinkFromGroup(SceneObjectPart linkPart, bool sendEvents)
2480 { 2504 {
2481 linkPart.ClearUndoState();
2482// m_log.DebugFormat( 2505// m_log.DebugFormat(
2483// "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}", 2506// "[SCENE OBJECT GROUP]: Delinking part {0}, {1} from group with root part {2}, {3}",
2484// linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID); 2507// linkPart.Name, linkPart.UUID, RootPart.Name, RootPart.UUID);
2508
2509 linkPart.ClearUndoState();
2485 2510
2486 Quaternion worldRot = linkPart.GetWorldRotation(); 2511 Quaternion worldRot = linkPart.GetWorldRotation();
2487 2512
@@ -2536,6 +2561,8 @@ namespace OpenSim.Region.Framework.Scenes
2536 2561
2537 //HasGroupChanged = true; 2562 //HasGroupChanged = true;
2538 //ScheduleGroupForFullUpdate(); 2563 //ScheduleGroupForFullUpdate();
2564
2565 return objectGroup;
2539 } 2566 }
2540 2567
2541 /// <summary> 2568 /// <summary>
@@ -2574,7 +2601,6 @@ namespace OpenSim.Region.Framework.Scenes
2574 2601
2575 part.LinkNum = linkNum; 2602 part.LinkNum = linkNum;
2576 2603
2577
2578 part.OffsetPosition = part.GroupPosition - AbsolutePosition; 2604 part.OffsetPosition = part.GroupPosition - AbsolutePosition;
2579 2605
2580 Quaternion rootRotation = m_rootPart.RotationOffset; 2606 Quaternion rootRotation = m_rootPart.RotationOffset;
@@ -2604,11 +2630,14 @@ namespace OpenSim.Region.Framework.Scenes
2604 { 2630 {
2605 if (m_rootPart.PhysActor.IsPhysical) 2631 if (m_rootPart.PhysActor.IsPhysical)
2606 { 2632 {
2607 Vector3 llmoveforce = pos - AbsolutePosition; 2633 if (!m_rootPart.BlockGrab)
2608 Vector3 grabforce = llmoveforce; 2634 {
2609 grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass; 2635 Vector3 llmoveforce = pos - AbsolutePosition;
2610 m_rootPart.PhysActor.AddForce(grabforce,true); 2636 Vector3 grabforce = llmoveforce;
2611 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor); 2637 grabforce = (grabforce / 10) * m_rootPart.PhysActor.Mass;
2638 m_rootPart.PhysActor.AddForce(grabforce, true);
2639 m_scene.PhysicsScene.AddPhysicsActorTaint(m_rootPart.PhysActor);
2640 }
2612 } 2641 }
2613 else 2642 else
2614 { 2643 {
@@ -2966,6 +2995,7 @@ namespace OpenSim.Region.Framework.Scenes
2966 SceneObjectPart part = GetChildPart(localID); 2995 SceneObjectPart part = GetChildPart(localID);
2967 if (part != null) 2996 if (part != null)
2968 { 2997 {
2998 part.IgnoreUndoUpdate = true;
2969 if (scale.X > m_scene.m_maxNonphys) 2999 if (scale.X > m_scene.m_maxNonphys)
2970 scale.X = m_scene.m_maxNonphys; 3000 scale.X = m_scene.m_maxNonphys;
2971 if (scale.Y > m_scene.m_maxNonphys) 3001 if (scale.Y > m_scene.m_maxNonphys)
@@ -2993,6 +3023,7 @@ namespace OpenSim.Region.Framework.Scenes
2993 if (obPart.UUID != m_rootPart.UUID) 3023 if (obPart.UUID != m_rootPart.UUID)
2994 { 3024 {
2995 Vector3 oldSize = new Vector3(obPart.Scale); 3025 Vector3 oldSize = new Vector3(obPart.Scale);
3026 obPart.IgnoreUndoUpdate = true;
2996 3027
2997 float f = 1.0f; 3028 float f = 1.0f;
2998 float a = 1.0f; 3029 float a = 1.0f;
@@ -3050,6 +3081,8 @@ namespace OpenSim.Region.Framework.Scenes
3050 y *= a; 3081 y *= a;
3051 z *= a; 3082 z *= a;
3052 } 3083 }
3084 obPart.IgnoreUndoUpdate = false;
3085 obPart.StoreUndoState();
3053 } 3086 }
3054 } 3087 }
3055 } 3088 }
@@ -3066,6 +3099,7 @@ namespace OpenSim.Region.Framework.Scenes
3066 { 3099 {
3067 foreach (SceneObjectPart obPart in m_parts.Values) 3100 foreach (SceneObjectPart obPart in m_parts.Values)
3068 { 3101 {
3102 obPart.IgnoreUndoUpdate = true;
3069 if (obPart.UUID != m_rootPart.UUID) 3103 if (obPart.UUID != m_rootPart.UUID)
3070 { 3104 {
3071 Vector3 currentpos = new Vector3(obPart.OffsetPosition); 3105 Vector3 currentpos = new Vector3(obPart.OffsetPosition);
@@ -3079,6 +3113,8 @@ namespace OpenSim.Region.Framework.Scenes
3079 obPart.Resize(newSize); 3113 obPart.Resize(newSize);
3080 obPart.UpdateOffSet(currentpos); 3114 obPart.UpdateOffSet(currentpos);
3081 } 3115 }
3116 obPart.IgnoreUndoUpdate = false;
3117 obPart.StoreUndoState();
3082 } 3118 }
3083 } 3119 }
3084 lockPartsForRead(false); 3120 lockPartsForRead(false);
@@ -3089,6 +3125,8 @@ namespace OpenSim.Region.Framework.Scenes
3089 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor); 3125 m_scene.PhysicsScene.AddPhysicsActorTaint(part.PhysActor);
3090 } 3126 }
3091 3127
3128 part.IgnoreUndoUpdate = false;
3129 part.StoreUndoState();
3092 HasGroupChanged = true; 3130 HasGroupChanged = true;
3093 ScheduleGroupForTerseUpdate(); 3131 ScheduleGroupForTerseUpdate();
3094 } 3132 }
@@ -3104,13 +3142,26 @@ namespace OpenSim.Region.Framework.Scenes
3104 /// <param name="pos"></param> 3142 /// <param name="pos"></param>
3105 public void UpdateGroupPosition(Vector3 pos) 3143 public void UpdateGroupPosition(Vector3 pos)
3106 { 3144 {
3145 foreach (SceneObjectPart part in Children.Values)
3146 {
3147 part.StoreUndoState();
3148 }
3107 if (m_scene.EventManager.TriggerGroupMove(UUID, pos)) 3149 if (m_scene.EventManager.TriggerGroupMove(UUID, pos))
3108 { 3150 {
3109 if (IsAttachment) 3151 if (IsAttachment)
3110 { 3152 {
3111 m_rootPart.AttachedPos = pos; 3153 m_rootPart.AttachedPos = pos;
3112 } 3154 }
3113 3155 if (RootPart.GetStatusSandbox())
3156 {
3157 if (Util.GetDistanceTo(RootPart.StatusSandboxPos, pos) > 10)
3158 {
3159 RootPart.ScriptSetPhysicsStatus(false);
3160 pos = AbsolutePosition;
3161 Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"),
3162 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, RootPart.AbsolutePosition, Name, UUID, false);
3163 }
3164 }
3114 AbsolutePosition = pos; 3165 AbsolutePosition = pos;
3115 3166
3116 HasGroupChanged = true; 3167 HasGroupChanged = true;
@@ -3129,7 +3180,10 @@ namespace OpenSim.Region.Framework.Scenes
3129 public void UpdateSinglePosition(Vector3 pos, uint localID) 3180 public void UpdateSinglePosition(Vector3 pos, uint localID)
3130 { 3181 {
3131 SceneObjectPart part = GetChildPart(localID); 3182 SceneObjectPart part = GetChildPart(localID);
3132 3183 foreach (SceneObjectPart parts in Children.Values)
3184 {
3185 parts.StoreUndoState();
3186 }
3133 if (part != null) 3187 if (part != null)
3134 { 3188 {
3135 if (part.UUID == m_rootPart.UUID) 3189 if (part.UUID == m_rootPart.UUID)
@@ -3151,6 +3205,10 @@ namespace OpenSim.Region.Framework.Scenes
3151 /// <param name="pos"></param> 3205 /// <param name="pos"></param>
3152 private void UpdateRootPosition(Vector3 pos) 3206 private void UpdateRootPosition(Vector3 pos)
3153 { 3207 {
3208 foreach (SceneObjectPart part in Children.Values)
3209 {
3210 part.StoreUndoState();
3211 }
3154 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); 3212 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z);
3155 Vector3 oldPos = 3213 Vector3 oldPos =
3156 new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, 3214 new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X,
@@ -3195,6 +3253,10 @@ namespace OpenSim.Region.Framework.Scenes
3195 /// <param name="rot"></param> 3253 /// <param name="rot"></param>
3196 public void UpdateGroupRotationR(Quaternion rot) 3254 public void UpdateGroupRotationR(Quaternion rot)
3197 { 3255 {
3256 foreach (SceneObjectPart parts in Children.Values)
3257 {
3258 parts.StoreUndoState();
3259 }
3198 m_rootPart.UpdateRotation(rot); 3260 m_rootPart.UpdateRotation(rot);
3199 3261
3200 PhysicsActor actor = m_rootPart.PhysActor; 3262 PhysicsActor actor = m_rootPart.PhysActor;
@@ -3215,6 +3277,10 @@ namespace OpenSim.Region.Framework.Scenes
3215 /// <param name="rot"></param> 3277 /// <param name="rot"></param>
3216 public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot) 3278 public void UpdateGroupRotationPR(Vector3 pos, Quaternion rot)
3217 { 3279 {
3280 foreach (SceneObjectPart parts in Children.Values)
3281 {
3282 parts.StoreUndoState();
3283 }
3218 m_rootPart.UpdateRotation(rot); 3284 m_rootPart.UpdateRotation(rot);
3219 3285
3220 PhysicsActor actor = m_rootPart.PhysActor; 3286 PhysicsActor actor = m_rootPart.PhysActor;
@@ -3238,6 +3304,10 @@ namespace OpenSim.Region.Framework.Scenes
3238 public void UpdateSingleRotation(Quaternion rot, uint localID) 3304 public void UpdateSingleRotation(Quaternion rot, uint localID)
3239 { 3305 {
3240 SceneObjectPart part = GetChildPart(localID); 3306 SceneObjectPart part = GetChildPart(localID);
3307 foreach (SceneObjectPart parts in Children.Values)
3308 {
3309 parts.StoreUndoState();
3310 }
3241 if (part != null) 3311 if (part != null)
3242 { 3312 {
3243 if (part.UUID == m_rootPart.UUID) 3313 if (part.UUID == m_rootPart.UUID)
@@ -3268,8 +3338,11 @@ namespace OpenSim.Region.Framework.Scenes
3268 } 3338 }
3269 else 3339 else
3270 { 3340 {
3341 part.IgnoreUndoUpdate = true;
3271 part.UpdateRotation(rot); 3342 part.UpdateRotation(rot);
3272 part.OffsetPosition = pos; 3343 part.OffsetPosition = pos;
3344 part.IgnoreUndoUpdate = false;
3345 part.StoreUndoState();
3273 } 3346 }
3274 } 3347 }
3275 } 3348 }
@@ -3283,6 +3356,7 @@ namespace OpenSim.Region.Framework.Scenes
3283 Quaternion axRot = rot; 3356 Quaternion axRot = rot;
3284 Quaternion oldParentRot = m_rootPart.RotationOffset; 3357 Quaternion oldParentRot = m_rootPart.RotationOffset;
3285 3358
3359 m_rootPart.StoreUndoState();
3286 m_rootPart.UpdateRotation(rot); 3360 m_rootPart.UpdateRotation(rot);
3287 if (m_rootPart.PhysActor != null) 3361 if (m_rootPart.PhysActor != null)
3288 { 3362 {
@@ -3296,6 +3370,7 @@ namespace OpenSim.Region.Framework.Scenes
3296 { 3370 {
3297 if (prim.UUID != m_rootPart.UUID) 3371 if (prim.UUID != m_rootPart.UUID)
3298 { 3372 {
3373 prim.IgnoreUndoUpdate = true;
3299 Vector3 axPos = prim.OffsetPosition; 3374 Vector3 axPos = prim.OffsetPosition;
3300 axPos *= oldParentRot; 3375 axPos *= oldParentRot;
3301 axPos *= Quaternion.Inverse(axRot); 3376 axPos *= Quaternion.Inverse(axRot);
@@ -3308,6 +3383,16 @@ namespace OpenSim.Region.Framework.Scenes
3308 } 3383 }
3309 } 3384 }
3310 } 3385 }
3386
3387 foreach (SceneObjectPart childpart in Children.Values)
3388 {
3389 if (childpart != m_rootPart)
3390 {
3391 childpart.IgnoreUndoUpdate = false;
3392 childpart.StoreUndoState();
3393 }
3394 }
3395
3311 lockPartsForRead(false); 3396 lockPartsForRead(false);
3312 3397
3313 m_rootPart.ScheduleTerseUpdate(); 3398 m_rootPart.ScheduleTerseUpdate();
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
index 0d19589..57635f5 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPart.cs
@@ -133,6 +133,18 @@ namespace OpenSim.Region.Framework.Scenes
133 [XmlIgnore] 133 [XmlIgnore]
134 public bool DIE_AT_EDGE; 134 public bool DIE_AT_EDGE;
135 135
136 [XmlIgnore]
137 public bool RETURN_AT_EDGE;
138
139 [XmlIgnore]
140 public bool BlockGrab;
141
142 [XmlIgnore]
143 public bool StatusSandbox;
144
145 [XmlIgnore]
146 public Vector3 StatusSandboxPos;
147
136 // TODO: This needs to be persisted in next XML version update! 148 // TODO: This needs to be persisted in next XML version update!
137 [XmlIgnore] 149 [XmlIgnore]
138 public int[] PayPrice = {-2,-2,-2,-2,-2}; 150 public int[] PayPrice = {-2,-2,-2,-2,-2};
@@ -219,6 +231,15 @@ namespace OpenSim.Region.Framework.Scenes
219 [XmlIgnore] 231 [XmlIgnore]
220 public Quaternion SpinOldOrientation = Quaternion.Identity; 232 public Quaternion SpinOldOrientation = Quaternion.Identity;
221 233
234 [XmlIgnore]
235 public Quaternion m_APIDTarget = Quaternion.Identity;
236
237 [XmlIgnore]
238 public float m_APIDDamp = 0;
239
240 [XmlIgnore]
241 public float m_APIDStrength = 0;
242
222 /// <summary> 243 /// <summary>
223 /// This part's inventory 244 /// This part's inventory
224 /// </summary> 245 /// </summary>
@@ -233,6 +254,9 @@ namespace OpenSim.Region.Framework.Scenes
233 public bool Undoing; 254 public bool Undoing;
234 255
235 [XmlIgnore] 256 [XmlIgnore]
257 public bool IgnoreUndoUpdate = false;
258
259 [XmlIgnore]
236 private PrimFlags LocalFlags; 260 private PrimFlags LocalFlags;
237 [XmlIgnore] 261 [XmlIgnore]
238 private float m_damage = -1.0f; 262 private float m_damage = -1.0f;
@@ -254,6 +278,7 @@ namespace OpenSim.Region.Framework.Scenes
254 private string m_text = String.Empty; 278 private string m_text = String.Empty;
255 private string m_touchName = String.Empty; 279 private string m_touchName = String.Empty;
256 private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5); 280 private readonly UndoStack<UndoState> m_undo = new UndoStack<UndoState>(5);
281 private readonly UndoStack<UndoState> m_redo = new UndoStack<UndoState>(5);
257 private UUID _creatorID; 282 private UUID _creatorID;
258 283
259 private bool m_passTouches; 284 private bool m_passTouches;
@@ -506,6 +531,27 @@ namespace OpenSim.Region.Framework.Scenes
506 } 531 }
507 } 532 }
508 533
534 [XmlIgnore]
535 public Quaternion APIDTarget
536 {
537 get { return m_APIDTarget; }
538 set { m_APIDTarget = value; }
539 }
540
541 [XmlIgnore]
542 public float APIDDamp
543 {
544 get { return m_APIDDamp; }
545 set { m_APIDDamp = value; }
546 }
547
548 [XmlIgnore]
549 public float APIDStrength
550 {
551 get { return m_APIDStrength; }
552 set { m_APIDStrength = value; }
553 }
554
509 public ulong RegionHandle 555 public ulong RegionHandle
510 { 556 {
511 get { return m_regionHandle; } 557 get { return m_regionHandle; }
@@ -517,6 +563,33 @@ namespace OpenSim.Region.Framework.Scenes
517 get { return m_scriptAccessPin; } 563 get { return m_scriptAccessPin; }
518 set { m_scriptAccessPin = (int)value; } 564 set { m_scriptAccessPin = (int)value; }
519 } 565 }
566 private SceneObjectPart m_PlaySoundMasterPrim = null;
567 public SceneObjectPart PlaySoundMasterPrim
568 {
569 get { return m_PlaySoundMasterPrim; }
570 set { m_PlaySoundMasterPrim = value; }
571 }
572
573 private List<SceneObjectPart> m_PlaySoundSlavePrims = new List<SceneObjectPart>();
574 public List<SceneObjectPart> PlaySoundSlavePrims
575 {
576 get { return m_LoopSoundSlavePrims; }
577 set { m_LoopSoundSlavePrims = value; }
578 }
579
580 private SceneObjectPart m_LoopSoundMasterPrim = null;
581 public SceneObjectPart LoopSoundMasterPrim
582 {
583 get { return m_LoopSoundMasterPrim; }
584 set { m_LoopSoundMasterPrim = value; }
585 }
586
587 private List<SceneObjectPart> m_LoopSoundSlavePrims = new List<SceneObjectPart>();
588 public List<SceneObjectPart> LoopSoundSlavePrims
589 {
590 get { return m_LoopSoundSlavePrims; }
591 set { m_LoopSoundSlavePrims = value; }
592 }
520 593
521 public Byte[] TextureAnimation 594 public Byte[] TextureAnimation
522 { 595 {
@@ -576,8 +649,6 @@ namespace OpenSim.Region.Framework.Scenes
576 } 649 }
577 set 650 set
578 { 651 {
579 StoreUndoState();
580
581 m_groupPosition = value; 652 m_groupPosition = value;
582 PhysicsActor actor = PhysActor; 653 PhysicsActor actor = PhysActor;
583 if (actor != null) 654 if (actor != null)
@@ -1403,6 +1474,10 @@ namespace OpenSim.Region.Framework.Scenes
1403 { 1474 {
1404 m_undo.Clear(); 1475 m_undo.Clear();
1405 } 1476 }
1477 lock (m_redo)
1478 {
1479 m_redo.Clear();
1480 }
1406 StoreUndoState(); 1481 StoreUndoState();
1407 } 1482 }
1408 1483
@@ -1713,6 +1788,66 @@ namespace OpenSim.Region.Framework.Scenes
1713 return m_parentGroup.RootPart.DIE_AT_EDGE; 1788 return m_parentGroup.RootPart.DIE_AT_EDGE;
1714 } 1789 }
1715 1790
1791 public bool GetReturnAtEdge()
1792 {
1793 if (m_parentGroup == null)
1794 return false;
1795 if (m_parentGroup.IsDeleted)
1796 return false;
1797
1798 return m_parentGroup.RootPart.RETURN_AT_EDGE;
1799 }
1800
1801 public void SetReturnAtEdge(bool p)
1802 {
1803 if (m_parentGroup == null)
1804 return;
1805 if (m_parentGroup.IsDeleted)
1806 return;
1807
1808 m_parentGroup.RootPart.RETURN_AT_EDGE = p;
1809 }
1810
1811 public bool GetBlockGrab()
1812 {
1813 if (m_parentGroup == null)
1814 return false;
1815 if (m_parentGroup.IsDeleted)
1816 return false;
1817
1818 return m_parentGroup.RootPart.BlockGrab;
1819 }
1820
1821 public void SetBlockGrab(bool p)
1822 {
1823 if (m_parentGroup == null)
1824 return;
1825 if (m_parentGroup.IsDeleted)
1826 return;
1827
1828 m_parentGroup.RootPart.BlockGrab = p;
1829 }
1830
1831 public void SetStatusSandbox(bool p)
1832 {
1833 if (m_parentGroup == null)
1834 return;
1835 if (m_parentGroup.IsDeleted)
1836 return;
1837 StatusSandboxPos = m_parentGroup.RootPart.AbsolutePosition;
1838 m_parentGroup.RootPart.StatusSandbox = p;
1839 }
1840
1841 public bool GetStatusSandbox()
1842 {
1843 if (m_parentGroup == null)
1844 return false;
1845 if (m_parentGroup.IsDeleted)
1846 return false;
1847
1848 return m_parentGroup.RootPart.StatusSandbox;
1849 }
1850
1716 public int GetAxisRotation(int axis) 1851 public int GetAxisRotation(int axis)
1717 { 1852 {
1718 //Cannot use ScriptBaseClass constants as no referance to it currently. 1853 //Cannot use ScriptBaseClass constants as no referance to it currently.
@@ -1924,7 +2059,7 @@ namespace OpenSim.Region.Framework.Scenes
1924 // play the sound. 2059 // play the sound.
1925 if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f) 2060 if (startedColliders.Count > 0 && CollisionSound != UUID.Zero && CollisionSoundVolume > 0.0f)
1926 { 2061 {
1927 SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0); 2062 SendSound(CollisionSound.ToString(), CollisionSoundVolume, true, (byte)0, 0, false, false);
1928 } 2063 }
1929 2064
1930 if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0) 2065 if ((m_parentGroup.RootPart.ScriptEvents & scriptEvents.collision_start) != 0)
@@ -2499,9 +2634,8 @@ namespace OpenSim.Region.Framework.Scenes
2499 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars(); 2634 List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
2500 foreach (ScenePresence p in avatarts) 2635 foreach (ScenePresence p in avatarts)
2501 { 2636 {
2502 // TODO: some filtering by distance of avatar 2637 if (!(Util.GetDistanceTo(p.AbsolutePosition, AbsolutePosition) >= 100))
2503 2638 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
2504 p.ControllingClient.SendPreLoadSound(objectID, objectID, soundID);
2505 } 2639 }
2506 } 2640 }
2507 2641
@@ -2562,7 +2696,38 @@ namespace OpenSim.Region.Framework.Scenes
2562 2696
2563 public void RotLookAt(Quaternion target, float strength, float damping) 2697 public void RotLookAt(Quaternion target, float strength, float damping)
2564 { 2698 {
2565 m_parentGroup.rotLookAt(target, strength, damping); 2699 rotLookAt(target, strength, damping);
2700 }
2701
2702 public void rotLookAt(Quaternion target, float strength, float damping)
2703 {
2704 if (IsAttachment)
2705 {
2706 /*
2707 ScenePresence avatar = m_scene.GetScenePresence(rootpart.AttachedAvatar);
2708 if (avatar != null)
2709 {
2710 Rotate the Av?
2711 } */
2712 }
2713 else
2714 {
2715 APIDDamp = damping;
2716 APIDStrength = strength;
2717 APIDTarget = target;
2718 }
2719 }
2720
2721 public void startLookAt(Quaternion rot, float damp, float strength)
2722 {
2723 APIDDamp = damp;
2724 APIDStrength = strength;
2725 APIDTarget = rot;
2726 }
2727
2728 public void stopLookAt()
2729 {
2730 APIDTarget = Quaternion.Identity;
2566 } 2731 }
2567 2732
2568 /// <summary> 2733 /// <summary>
@@ -2824,7 +2989,7 @@ namespace OpenSim.Region.Framework.Scenes
2824 /// <param name="volume"></param> 2989 /// <param name="volume"></param>
2825 /// <param name="triggered"></param> 2990 /// <param name="triggered"></param>
2826 /// <param name="flags"></param> 2991 /// <param name="flags"></param>
2827 public void SendSound(string sound, double volume, bool triggered, byte flags) 2992 public void SendSound(string sound, double volume, bool triggered, byte flags, float radius, bool useMaster, bool isMaster)
2828 { 2993 {
2829 if (volume > 1) 2994 if (volume > 1)
2830 volume = 1; 2995 volume = 1;
@@ -2859,10 +3024,51 @@ namespace OpenSim.Region.Framework.Scenes
2859 ISoundModule soundModule = m_parentGroup.Scene.RequestModuleInterface<ISoundModule>(); 3024 ISoundModule soundModule = m_parentGroup.Scene.RequestModuleInterface<ISoundModule>();
2860 if (soundModule != null) 3025 if (soundModule != null)
2861 { 3026 {
2862 if (triggered) 3027 if (useMaster)
2863 soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle); 3028 {
3029 if (isMaster)
3030 {
3031 if (triggered)
3032 soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius);
3033 else
3034 soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius);
3035 ParentGroup.PlaySoundMasterPrim = this;
3036 ownerID = this._ownerID;
3037 objectID = this.UUID;
3038 parentID = this.GetRootPartUUID();
3039 position = this.AbsolutePosition; // region local
3040 regionHandle = this.ParentGroup.Scene.RegionInfo.RegionHandle;
3041 if (triggered)
3042 soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius);
3043 else
3044 soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius);
3045 foreach (SceneObjectPart prim in ParentGroup.PlaySoundSlavePrims)
3046 {
3047 ownerID = prim._ownerID;
3048 objectID = prim.UUID;
3049 parentID = prim.GetRootPartUUID();
3050 position = prim.AbsolutePosition; // region local
3051 regionHandle = prim.ParentGroup.Scene.RegionInfo.RegionHandle;
3052 if (triggered)
3053 soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius);
3054 else
3055 soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius);
3056 }
3057 ParentGroup.PlaySoundSlavePrims.Clear();
3058 ParentGroup.PlaySoundMasterPrim = null;
3059 }
3060 else
3061 {
3062 ParentGroup.PlaySoundSlavePrims.Add(this);
3063 }
3064 }
2864 else 3065 else
2865 soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags); 3066 {
3067 if (triggered)
3068 soundModule.TriggerSound(soundID, ownerID, objectID, parentID, volume, position, regionHandle, radius);
3069 else
3070 soundModule.PlayAttachedSound(soundID, ownerID, objectID, volume, position, flags, radius);
3071 }
2866 } 3072 }
2867 } 3073 }
2868 3074
@@ -3181,6 +3387,14 @@ namespace OpenSim.Region.Framework.Scenes
3181 hasProfileCut = hasDimple; // is it the same thing? 3387 hasProfileCut = hasDimple; // is it the same thing?
3182 } 3388 }
3183 3389
3390 public void SetVehicleFlags(int param, bool remove)
3391 {
3392 if (PhysActor != null)
3393 {
3394 PhysActor.VehicleFlags(param, remove);
3395 }
3396 }
3397
3184 public void SetGroup(UUID groupID, IClientAPI client) 3398 public void SetGroup(UUID groupID, IClientAPI client)
3185 { 3399 {
3186 _groupID = groupID; 3400 _groupID = groupID;
@@ -3285,27 +3499,30 @@ namespace OpenSim.Region.Framework.Scenes
3285 { 3499 {
3286 if (!Undoing) 3500 if (!Undoing)
3287 { 3501 {
3288 if (m_parentGroup != null) 3502 if (!IgnoreUndoUpdate)
3289 { 3503 {
3290 lock (m_undo) 3504 if (m_parentGroup != null)
3291 { 3505 {
3292 if (m_undo.Count > 0) 3506 lock (m_undo)
3293 { 3507 {
3294 UndoState last = m_undo.Peek(); 3508 if (m_undo.Count > 0)
3295 if (last != null)
3296 { 3509 {
3297 if (last.Compare(this)) 3510 UndoState last = m_undo.Peek();
3298 return; 3511 if (last != null)
3512 {
3513 if (last.Compare(this))
3514 return;
3515 }
3299 } 3516 }
3300 }
3301 3517
3302 if (m_parentGroup.GetSceneMaxUndo() > 0) 3518 if (m_parentGroup.GetSceneMaxUndo() > 0)
3303 { 3519 {
3304 UndoState nUndo = new UndoState(this); 3520 UndoState nUndo = new UndoState(this);
3305 3521
3306 m_undo.Push(nUndo); 3522 m_undo.Push(nUndo);
3307 } 3523 }
3308 3524
3525 }
3309 } 3526 }
3310 } 3527 }
3311 } 3528 }
@@ -3776,11 +3993,36 @@ namespace OpenSim.Region.Framework.Scenes
3776 lock (m_undo) 3993 lock (m_undo)
3777 { 3994 {
3778 if (m_undo.Count > 0) 3995 if (m_undo.Count > 0)
3996 {
3997 UndoState nUndo = null;
3998 if (m_parentGroup.GetSceneMaxUndo() > 0)
3779 { 3999 {
3780 UndoState goback = m_undo.Pop(); 4000 nUndo = new UndoState(this);
3781 if (goback != null) 4001 }
3782 goback.PlaybackState(this); 4002 UndoState goback = m_undo.Pop();
4003 if (goback != null)
4004 {
4005 goback.PlaybackState(this);
4006 if (nUndo != null)
4007 m_redo.Push(nUndo);
4008 }
4009 }
4010 }
4011 }
4012
4013 public void Redo()
4014 {
4015 lock (m_redo)
4016 {
4017 if (m_parentGroup.GetSceneMaxUndo() > 0)
4018 {
4019 UndoState nUndo = new UndoState(this);
4020
4021 m_undo.Push(nUndo);
3783 } 4022 }
4023 UndoState gofwd = m_redo.Pop();
4024 if (gofwd != null)
4025 gofwd.PlayfwdState(this);
3784 } 4026 }
3785 } 4027 }
3786 4028
@@ -3827,6 +4069,18 @@ namespace OpenSim.Region.Framework.Scenes
3827 (pos.Z != OffsetPosition.Z)) 4069 (pos.Z != OffsetPosition.Z))
3828 { 4070 {
3829 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); 4071 Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z);
4072
4073 if (ParentGroup.RootPart.GetStatusSandbox())
4074 {
4075 if (Util.GetDistanceTo(ParentGroup.RootPart.StatusSandboxPos, newPos) > 10)
4076 {
4077 ParentGroup.RootPart.ScriptSetPhysicsStatus(false);
4078 newPos = OffsetPosition;
4079 ParentGroup.Scene.SimChat(Utils.StringToBytes("Hit Sandbox Limit"),
4080 ChatTypeEnum.DebugChannel, 0x7FFFFFFF, ParentGroup.RootPart.AbsolutePosition, Name, UUID, false);
4081 }
4082 }
4083
3830 OffsetPosition = newPos; 4084 OffsetPosition = newPos;
3831 ScheduleTerseUpdate(); 4085 ScheduleTerseUpdate();
3832 } 4086 }
@@ -4119,7 +4373,6 @@ namespace OpenSim.Region.Framework.Scenes
4119 (rot.Z != RotationOffset.Z) || 4373 (rot.Z != RotationOffset.Z) ||
4120 (rot.W != RotationOffset.W)) 4374 (rot.W != RotationOffset.W))
4121 { 4375 {
4122 //StoreUndoState();
4123 RotationOffset = rot; 4376 RotationOffset = rot;
4124 ParentGroup.HasGroupChanged = true; 4377 ParentGroup.HasGroupChanged = true;
4125 ScheduleTerseUpdate(); 4378 ScheduleTerseUpdate();
@@ -4303,7 +4556,7 @@ namespace OpenSim.Region.Framework.Scenes
4303 else 4556 else
4304 { 4557 {
4305// m_log.DebugFormat( 4558// m_log.DebugFormat(
4306// "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId); 4559// "[SCENE OBJECT PART]: Scheduling part {0} {1} for full update in aggregateScriptEvents()", Name, LocalId);
4307 ScheduleFullUpdate(); 4560 ScheduleFullUpdate();
4308 } 4561 }
4309 } 4562 }
@@ -4421,5 +4674,36 @@ namespace OpenSim.Region.Framework.Scenes
4421 4674
4422 Inventory.ApplyNextOwnerPermissions(); 4675 Inventory.ApplyNextOwnerPermissions();
4423 } 4676 }
4677 public void UpdateLookAt()
4678 {
4679 try
4680 {
4681 if (APIDTarget != Quaternion.Identity)
4682 {
4683 if (Single.IsNaN(APIDTarget.W) == true)
4684 {
4685 APIDTarget = Quaternion.Identity;
4686 return;
4687 }
4688 Quaternion rot = RotationOffset;
4689 Quaternion dir = (rot - APIDTarget);
4690 float speed = ((APIDStrength / APIDDamp) * (float)(Math.PI / 180.0f));
4691 if (dir.Z > speed)
4692 {
4693 rot.Z -= speed;
4694 }
4695 if (dir.Z < -speed)
4696 {
4697 rot.Z += speed;
4698 }
4699 rot.Normalize();
4700 UpdateRotation(rot);
4701 }
4702 }
4703 catch (Exception ex)
4704 {
4705 m_log.Error("[Physics] " + ex);
4706 }
4707 }
4424 } 4708 }
4425} 4709}
diff --git a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
index 3317dd3..013285f 100644
--- a/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneObjectPartInventory.cs
@@ -34,7 +34,6 @@ using System.Reflection;
34using OpenMetaverse; 34using OpenMetaverse;
35using log4net; 35using log4net;
36using OpenSim.Framework; 36using OpenSim.Framework;
37using OpenSim.Framework.Communications.Cache;
38using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes.Scripting; 38using OpenSim.Region.Framework.Scenes.Scripting;
40 39
@@ -318,8 +317,6 @@ namespace OpenSim.Region.Framework.Scenes
318 } 317 }
319 } 318 }
320 319
321 static System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
322
323 private void RestoreSavedScriptState(UUID oldID, UUID newID) 320 private void RestoreSavedScriptState(UUID oldID, UUID newID)
324 { 321 {
325 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>(); 322 IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
@@ -585,7 +582,7 @@ namespace OpenSim.Region.Framework.Scenes
585 m_items.TryGetValue(itemId, out item); 582 m_items.TryGetValue(itemId, out item);
586 m_items.LockItemsForRead(false); 583 m_items.LockItemsForRead(false);
587 return item; 584 return item;
588 } 585 }
589 586
590 /// <summary> 587 /// <summary>
591 /// Get inventory items by name. 588 /// Get inventory items by name.
@@ -594,7 +591,7 @@ namespace OpenSim.Region.Framework.Scenes
594 /// <returns> 591 /// <returns>
595 /// A list of inventory items with that name. 592 /// A list of inventory items with that name.
596 /// If no inventory item has that name then an empty list is returned. 593 /// If no inventory item has that name then an empty list is returned.
597 /// </returns> 594 /// </returns>
598 public IList<TaskInventoryItem> GetInventoryItems(string name) 595 public IList<TaskInventoryItem> GetInventoryItems(string name)
599 { 596 {
600 IList<TaskInventoryItem> items = new List<TaskInventoryItem>(); 597 IList<TaskInventoryItem> items = new List<TaskInventoryItem>();
diff --git a/OpenSim/Region/Framework/Scenes/ScenePresence.cs b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
index 6a2ab02..453523a 100644
--- a/OpenSim/Region/Framework/Scenes/ScenePresence.cs
+++ b/OpenSim/Region/Framework/Scenes/ScenePresence.cs
@@ -33,12 +33,12 @@ using OpenMetaverse;
33using log4net; 33using log4net;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Client; 35using OpenSim.Framework.Client;
36using OpenSim.Framework.Communications.Cache;
37using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes.Animation; 37using OpenSim.Region.Framework.Scenes.Animation;
39using OpenSim.Region.Framework.Scenes.Types; 38using OpenSim.Region.Framework.Scenes.Types;
40using OpenSim.Region.Physics.Manager; 39using OpenSim.Region.Physics.Manager;
41using GridRegion = OpenSim.Services.Interfaces.GridRegion; 40using GridRegion = OpenSim.Services.Interfaces.GridRegion;
41using OpenSim.Services.Interfaces;
42 42
43namespace OpenSim.Region.Framework.Scenes 43namespace OpenSim.Region.Framework.Scenes
44{ 44{
@@ -167,6 +167,8 @@ namespace OpenSim.Region.Framework.Scenes
167 167
168 private Quaternion m_bodyRot= Quaternion.Identity; 168 private Quaternion m_bodyRot= Quaternion.Identity;
169 169
170 private Quaternion m_bodyRotPrevious = Quaternion.Identity;
171
170 private const int LAND_VELOCITYMAG_MAX = 12; 172 private const int LAND_VELOCITYMAG_MAX = 12;
171 173
172 public bool IsRestrictedToRegion; 174 public bool IsRestrictedToRegion;
@@ -233,7 +235,7 @@ namespace OpenSim.Region.Framework.Scenes
233 // Agent's Draw distance. 235 // Agent's Draw distance.
234 protected float m_DrawDistance; 236 protected float m_DrawDistance;
235 237
236 protected AvatarAppearance m_appearance; 238 protected AvatarAppearance m_appearance;
237 239
238 // neighbouring regions we have enabled a child agent in 240 // neighbouring regions we have enabled a child agent in
239 // holds the seed cap for the child agent in that region 241 // holds the seed cap for the child agent in that region
@@ -264,6 +266,8 @@ namespace OpenSim.Region.Framework.Scenes
264 266
265 // For teleports and crossings callbacks 267 // For teleports and crossings callbacks
266 string m_callbackURI; 268 string m_callbackURI;
269 UUID m_originRegionID;
270
267 ulong m_rootRegionHandle; 271 ulong m_rootRegionHandle;
268 272
269 /// <value> 273 /// <value>
@@ -518,6 +522,12 @@ namespace OpenSim.Region.Framework.Scenes
518 set { m_bodyRot = value; } 522 set { m_bodyRot = value; }
519 } 523 }
520 524
525 public Quaternion PreviousRotation
526 {
527 get { return m_bodyRotPrevious; }
528 set { m_bodyRotPrevious = value; }
529 }
530
521 /// <summary> 531 /// <summary>
522 /// If this is true, agent doesn't have a representation in this scene. 532 /// If this is true, agent doesn't have a representation in this scene.
523 /// this is an agent 'looking into' this scene from a nearby scene(region) 533 /// this is an agent 'looking into' this scene from a nearby scene(region)
@@ -650,7 +660,7 @@ namespace OpenSim.Region.Framework.Scenes
650 #region Constructor(s) 660 #region Constructor(s)
651 661
652 public ScenePresence() 662 public ScenePresence()
653 { 663 {
654 m_sendCourseLocationsMethod = SendCoarseLocationsDefault; 664 m_sendCourseLocationsMethod = SendCoarseLocationsDefault;
655 CreateSceneViewer(); 665 CreateSceneViewer();
656 m_animator = new ScenePresenceAnimator(this); 666 m_animator = new ScenePresenceAnimator(this);
@@ -868,6 +878,31 @@ namespace OpenSim.Region.Framework.Scenes
868 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0) 878 if (pos.X < 0 || pos.Y < 0 || pos.Z < 0)
869 { 879 {
870 Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128); 880 Vector3 emergencyPos = new Vector3(((int)Constants.RegionSize * 0.5f), ((int)Constants.RegionSize * 0.5f), 128);
881
882 if (pos.X < 0)
883 {
884 emergencyPos.X = (int)Constants.RegionSize + pos.X;
885 if (!(pos.Y < 0))
886 emergencyPos.Y = pos.Y;
887 if (!(pos.Z < 0))
888 emergencyPos.X = pos.X;
889 }
890 if (pos.Y < 0)
891 {
892 emergencyPos.Y = (int)Constants.RegionSize + pos.Y;
893 if (!(pos.X < 0))
894 emergencyPos.X = pos.X;
895 if (!(pos.Z < 0))
896 emergencyPos.Z = pos.Z;
897 }
898 if (pos.Z < 0)
899 {
900 if (!(pos.X < 0))
901 emergencyPos.X = pos.X;
902 if (!(pos.Y < 0))
903 emergencyPos.Y = pos.Y;
904 //Leave as 128
905 }
871 906
872 m_log.WarnFormat( 907 m_log.WarnFormat(
873 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}", 908 "[SCENE PRESENCE]: MakeRootAgent() was given an illegal position of {0} for avatar {1}, {2}. Substituting {3}",
@@ -1127,8 +1162,10 @@ namespace OpenSim.Region.Framework.Scenes
1127 /// This is called upon a very important packet sent from the client, 1162 /// This is called upon a very important packet sent from the client,
1128 /// so it's client-controlled. Never call this method directly. 1163 /// so it's client-controlled. Never call this method directly.
1129 /// </summary> 1164 /// </summary>
1130 public void CompleteMovement() 1165 public void CompleteMovement(IClientAPI client)
1131 { 1166 {
1167 //m_log.Debug("[SCENE PRESENCE]: CompleteMovement");
1168
1132 Vector3 look = Velocity; 1169 Vector3 look = Velocity;
1133 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0)) 1170 if ((look.X == 0) && (look.Y == 0) && (look.Z == 0))
1134 { 1171 {
@@ -1153,7 +1190,7 @@ namespace OpenSim.Region.Framework.Scenes
1153 if ((m_callbackURI != null) && !m_callbackURI.Equals("")) 1190 if ((m_callbackURI != null) && !m_callbackURI.Equals(""))
1154 { 1191 {
1155 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI); 1192 m_log.DebugFormat("[SCENE PRESENCE]: Releasing agent in URI {0}", m_callbackURI);
1156 Scene.SendReleaseAgent(m_rootRegionHandle, UUID, m_callbackURI); 1193 Scene.SimulationService.ReleaseAgent(m_originRegionID, UUID, m_callbackURI);
1157 m_callbackURI = null; 1194 m_callbackURI = null;
1158 } 1195 }
1159 1196
@@ -1161,6 +1198,21 @@ namespace OpenSim.Region.Framework.Scenes
1161 1198
1162 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look); 1199 m_controllingClient.MoveAgentIntoRegion(m_regionInfo, AbsolutePosition, look);
1163 SendInitialData(); 1200 SendInitialData();
1201
1202 // Create child agents in neighbouring regions
1203 if (!m_isChildAgent)
1204 {
1205 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
1206 if (m_agentTransfer != null)
1207 m_agentTransfer.EnableChildAgents(this);
1208 else
1209 m_log.DebugFormat("[SCENE PRESENCE]: Unable to create child agents in neighbours, because AgentTransferModule is not active");
1210
1211 IFriendsModule friendsModule = m_scene.RequestModuleInterface<IFriendsModule>();
1212 if (friendsModule != null)
1213 friendsModule.SendFriendsOnlineIfNeeded(ControllingClient);
1214 }
1215
1164 } 1216 }
1165 1217
1166 /// <summary> 1218 /// <summary>
@@ -2364,6 +2416,7 @@ namespace OpenSim.Region.Framework.Scenes
2364 { 2416 {
2365 if (m_isChildAgent) 2417 if (m_isChildAgent)
2366 { 2418 {
2419 // WHAT???
2367 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!"); 2420 m_log.Debug("[SCENEPRESENCE]: AddNewMovement() called on child agent, making root agent!");
2368 2421
2369 // we have to reset the user's child agent connections. 2422 // we have to reset the user's child agent connections.
@@ -2387,7 +2440,9 @@ namespace OpenSim.Region.Framework.Scenes
2387 2440
2388 if (m_scene.SceneGridService != null) 2441 if (m_scene.SceneGridService != null)
2389 { 2442 {
2390 m_scene.SceneGridService.EnableNeighbourChildAgents(this, new List<RegionInfo>()); 2443 IEntityTransferModule m_agentTransfer = m_scene.RequestModuleInterface<IEntityTransferModule>();
2444 if (m_agentTransfer != null)
2445 m_agentTransfer.EnableChildAgents(this);
2391 } 2446 }
2392 2447
2393 return; 2448 return;
@@ -2687,14 +2742,9 @@ namespace OpenSim.Region.Framework.Scenes
2687 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId, 2742 m_controllingClient.SendAvatarData(new SendAvatarData(m_regionInfo.RegionHandle, m_firstname, m_lastname, m_grouptitle, m_uuid, LocalId,
2688 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot)); 2743 pos, m_appearance.Texture.GetBytes(), m_parentID, m_bodyRot));
2689 2744
2690 if (!m_isChildAgent)
2691 {
2692 m_scene.InformClientOfNeighbours(this);
2693 }
2694
2695 SendInitialFullUpdateToAllClients(); 2745 SendInitialFullUpdateToAllClients();
2696 SendAppearanceToAllOtherAgents(); 2746 SendAppearanceToAllOtherAgents();
2697 } 2747 }
2698 2748
2699 /// <summary> 2749 /// <summary>
2700 /// Tell the client for this scene presence what items it should be wearing now 2750 /// Tell the client for this scene presence what items it should be wearing now
@@ -2776,14 +2826,19 @@ namespace OpenSim.Region.Framework.Scenes
2776 } 2826 }
2777 } 2827 }
2778 } 2828 }
2829
2779 } 2830 }
2780 2831
2832
2781 #endregion Bake Cache Check 2833 #endregion Bake Cache Check
2782 2834
2783 m_appearance.SetAppearance(textureEntry, visualParams); 2835 m_appearance.SetAppearance(textureEntry, visualParams);
2784 if (m_appearance.AvatarHeight > 0) 2836 if (m_appearance.AvatarHeight > 0)
2785 SetHeight(m_appearance.AvatarHeight); 2837 SetHeight(m_appearance.AvatarHeight);
2786 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2838
2839 // This is not needed, because only the transient data changed
2840 //AvatarData adata = new AvatarData(m_appearance);
2841 //m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2787 2842
2788 SendAppearanceToAllOtherAgents(); 2843 SendAppearanceToAllOtherAgents();
2789 if (!m_startAnimationSet) 2844 if (!m_startAnimationSet)
@@ -2803,7 +2858,8 @@ namespace OpenSim.Region.Framework.Scenes
2803 public void SetWearable(int wearableId, AvatarWearable wearable) 2858 public void SetWearable(int wearableId, AvatarWearable wearable)
2804 { 2859 {
2805 m_appearance.SetWearable(wearableId, wearable); 2860 m_appearance.SetWearable(wearableId, wearable);
2806 m_scene.CommsManager.AvatarService.UpdateUserAppearance(m_controllingClient.AgentId, m_appearance); 2861 AvatarData adata = new AvatarData(m_appearance);
2862 m_scene.AvatarService.SetAvatar(m_controllingClient.AgentId, adata);
2807 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++); 2863 m_controllingClient.SendWearables(m_appearance.Wearables, m_appearance.Serial++);
2808 } 2864 }
2809 2865
@@ -2900,36 +2956,75 @@ namespace OpenSim.Region.Framework.Scenes
2900 { 2956 {
2901 // Checks if where it's headed exists a region 2957 // Checks if where it's headed exists a region
2902 2958
2959 bool needsTransit = false;
2903 if (m_scene.TestBorderCross(pos2, Cardinals.W)) 2960 if (m_scene.TestBorderCross(pos2, Cardinals.W))
2904 { 2961 {
2905 if (m_scene.TestBorderCross(pos2, Cardinals.S)) 2962 if (m_scene.TestBorderCross(pos2, Cardinals.S))
2963 {
2964 needsTransit = true;
2906 neighbor = HaveNeighbor(Cardinals.SW, ref fix); 2965 neighbor = HaveNeighbor(Cardinals.SW, ref fix);
2966 }
2907 else if (m_scene.TestBorderCross(pos2, Cardinals.N)) 2967 else if (m_scene.TestBorderCross(pos2, Cardinals.N))
2968 {
2969 needsTransit = true;
2908 neighbor = HaveNeighbor(Cardinals.NW, ref fix); 2970 neighbor = HaveNeighbor(Cardinals.NW, ref fix);
2971 }
2909 else 2972 else
2973 {
2974 needsTransit = true;
2910 neighbor = HaveNeighbor(Cardinals.W, ref fix); 2975 neighbor = HaveNeighbor(Cardinals.W, ref fix);
2976 }
2911 } 2977 }
2912 else if (m_scene.TestBorderCross(pos2, Cardinals.E)) 2978 else if (m_scene.TestBorderCross(pos2, Cardinals.E))
2913 { 2979 {
2914 if (m_scene.TestBorderCross(pos2, Cardinals.S)) 2980 if (m_scene.TestBorderCross(pos2, Cardinals.S))
2981 {
2982 needsTransit = true;
2915 neighbor = HaveNeighbor(Cardinals.SE, ref fix); 2983 neighbor = HaveNeighbor(Cardinals.SE, ref fix);
2984 }
2916 else if (m_scene.TestBorderCross(pos2, Cardinals.N)) 2985 else if (m_scene.TestBorderCross(pos2, Cardinals.N))
2986 {
2987 needsTransit = true;
2917 neighbor = HaveNeighbor(Cardinals.NE, ref fix); 2988 neighbor = HaveNeighbor(Cardinals.NE, ref fix);
2989 }
2918 else 2990 else
2991 {
2992 needsTransit = true;
2919 neighbor = HaveNeighbor(Cardinals.E, ref fix); 2993 neighbor = HaveNeighbor(Cardinals.E, ref fix);
2994 }
2920 } 2995 }
2921 else if (m_scene.TestBorderCross(pos2, Cardinals.S)) 2996 else if (m_scene.TestBorderCross(pos2, Cardinals.S))
2997 {
2998 needsTransit = true;
2922 neighbor = HaveNeighbor(Cardinals.S, ref fix); 2999 neighbor = HaveNeighbor(Cardinals.S, ref fix);
3000 }
2923 else if (m_scene.TestBorderCross(pos2, Cardinals.N)) 3001 else if (m_scene.TestBorderCross(pos2, Cardinals.N))
3002 {
3003 needsTransit = true;
2924 neighbor = HaveNeighbor(Cardinals.N, ref fix); 3004 neighbor = HaveNeighbor(Cardinals.N, ref fix);
3005 }
3006
2925 3007
2926
2927 // Makes sure avatar does not end up outside region 3008 // Makes sure avatar does not end up outside region
2928 if (neighbor < 0) 3009 if (neighbor <= 0)
2929 AbsolutePosition = new Vector3( 3010 {
2930 AbsolutePosition.X + 3*fix[0], 3011 if (!needsTransit)
2931 AbsolutePosition.Y + 3*fix[1], 3012 {
2932 AbsolutePosition.Z); 3013 if (m_requestedSitTargetUUID == UUID.Zero)
3014 {
3015 Vector3 pos = AbsolutePosition;
3016 if (AbsolutePosition.X < 0)
3017 pos.X += Velocity.X;
3018 else if (AbsolutePosition.X > Constants.RegionSize)
3019 pos.X -= Velocity.X;
3020 if (AbsolutePosition.Y < 0)
3021 pos.Y += Velocity.Y;
3022 else if (AbsolutePosition.Y > Constants.RegionSize)
3023 pos.Y -= Velocity.Y;
3024 AbsolutePosition = pos;
3025 }
3026 }
3027 }
2933 else if (neighbor > 0) 3028 else if (neighbor > 0)
2934 CrossToNewRegion(); 3029 CrossToNewRegion();
2935 } 3030 }
@@ -3087,11 +3182,14 @@ namespace OpenSim.Region.Framework.Scenes
3087 // For now, assign god level 200 to anyone 3182 // For now, assign god level 200 to anyone
3088 // who is granted god powers, but has no god level set. 3183 // who is granted god powers, but has no god level set.
3089 // 3184 //
3090 CachedUserInfo profile = m_scene.CommsManager.UserProfileCacheService.GetUserDetails(agentID); 3185 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, agentID);
3091 if (profile.UserProfile.GodLevel > 0) 3186 if (account != null)
3092 m_godlevel = profile.UserProfile.GodLevel; 3187 {
3093 else 3188 if (account.UserLevel > 0)
3094 m_godlevel = 200; 3189 m_godlevel = account.UserLevel;
3190 else
3191 m_godlevel = 200;
3192 }
3095 } 3193 }
3096 else 3194 else
3097 { 3195 {
@@ -3157,7 +3255,7 @@ namespace OpenSim.Region.Framework.Scenes
3157 public void CopyTo(AgentData cAgent) 3255 public void CopyTo(AgentData cAgent)
3158 { 3256 {
3159 cAgent.AgentID = UUID; 3257 cAgent.AgentID = UUID;
3160 cAgent.RegionHandle = m_rootRegionHandle; 3258 cAgent.RegionID = Scene.RegionInfo.RegionID;
3161 3259
3162 cAgent.Position = AbsolutePosition; 3260 cAgent.Position = AbsolutePosition;
3163 cAgent.Velocity = m_velocity; 3261 cAgent.Velocity = m_velocity;
@@ -3256,7 +3354,7 @@ namespace OpenSim.Region.Framework.Scenes
3256 3354
3257 public void CopyFrom(AgentData cAgent) 3355 public void CopyFrom(AgentData cAgent)
3258 { 3356 {
3259 m_rootRegionHandle = cAgent.RegionHandle; 3357 m_originRegionID = cAgent.RegionID;
3260 3358
3261 m_callbackURI = cAgent.CallbackURI; 3359 m_callbackURI = cAgent.CallbackURI;
3262 3360
@@ -3400,7 +3498,7 @@ namespace OpenSim.Region.Framework.Scenes
3400 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate; 3498 m_physicsActor.OnCollisionUpdate += PhysicsCollisionUpdate;
3401 m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong 3499 m_physicsActor.OnOutOfBounds += OutOfBoundsCall; // Called for PhysicsActors when there's something wrong
3402 m_physicsActor.SubscribeEvents(500); 3500 m_physicsActor.SubscribeEvents(500);
3403 m_physicsActor.LocalID = LocalId; 3501 m_physicsActor.LocalID = LocalId;
3404 } 3502 }
3405 3503
3406 private void OutOfBoundsCall(Vector3 pos) 3504 private void OutOfBoundsCall(Vector3 pos)
@@ -3503,7 +3601,7 @@ namespace OpenSim.Region.Framework.Scenes
3503 } 3601 }
3504 if (m_health <= 0) 3602 if (m_health <= 0)
3505 m_scene.EventManager.TriggerAvatarKill(killerObj, this); 3603 m_scene.EventManager.TriggerAvatarKill(killerObj, this);
3506 } 3604 }
3507 } 3605 }
3508 3606
3509 public void setHealthWithUpdate(float health) 3607 public void setHealthWithUpdate(float health)
@@ -3636,36 +3734,6 @@ namespace OpenSim.Region.Framework.Scenes
3636 } 3734 }
3637 } 3735 }
3638 3736
3639 public bool CrossAttachmentsIntoNewRegion(ulong regionHandle, bool silent)
3640 {
3641 lock (m_attachments)
3642 {
3643 // Validate
3644 foreach (SceneObjectGroup gobj in m_attachments)
3645 {
3646 if (gobj == null || gobj.IsDeleted)
3647 return false;
3648 }
3649
3650 foreach (SceneObjectGroup gobj in m_attachments)
3651 {
3652 // If the prim group is null then something must have happened to it!
3653 if (gobj != null && gobj.RootPart != null)
3654 {
3655 // Set the parent localID to 0 so it transfers over properly.
3656 gobj.RootPart.SetParentLocalId(0);
3657 gobj.AbsolutePosition = gobj.RootPart.AttachedPos;
3658 gobj.RootPart.IsAttachment = false;
3659 //gobj.RootPart.LastOwnerID = gobj.GetFromAssetID();
3660 m_log.DebugFormat("[ATTACHMENT]: Sending attachment {0} to region {1}", gobj.UUID, regionHandle);
3661 m_scene.CrossPrimGroupIntoNewRegion(regionHandle, gobj, silent);
3662 }
3663 }
3664 m_attachments.Clear();
3665
3666 return true;
3667 }
3668 }
3669 3737
3670 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene) 3738 public void initializeScenePresence(IClientAPI client, RegionInfo region, Scene scene)
3671 { 3739 {
diff --git a/OpenSim/Region/Framework/Scenes/SceneViewer.cs b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
index 1cff0eb..4ba4fab 100644
--- a/OpenSim/Region/Framework/Scenes/SceneViewer.cs
+++ b/OpenSim/Region/Framework/Scenes/SceneViewer.cs
@@ -31,7 +31,6 @@ using OpenMetaverse;
31using log4net; 31using log4net;
32using OpenSim.Framework; 32using OpenSim.Framework;
33using OpenSim.Framework.Client; 33using OpenSim.Framework.Client;
34using OpenSim.Framework.Communications.Cache;
35using OpenSim.Region.Framework.Interfaces; 34using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes.Types; 35using OpenSim.Region.Framework.Scenes.Types;
37 36
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
index 0ed00de..b50d4ca 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectBasicTests.cs
@@ -32,8 +32,7 @@ using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common; 37using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 38using OpenSim.Tests.Common.Mock;
@@ -95,16 +94,24 @@ namespace OpenSim.Region.Framework.Scenes.Tests
95 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test. 94 // Turn off the timer on the async sog deleter - we'll crank it by hand for this test.
96 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter; 95 AsyncSceneObjectGroupDeleter sogd = scene.SceneObjectGroupDeleter;
97 sogd.Enabled = false; 96 sogd.Enabled = false;
98 97
99 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene); 98 SceneObjectPart part = SceneSetupHelpers.AddSceneObject(scene);
100 99
101 IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId); 100 try
102 scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero); 101 {
103 102 IClientAPI client = SceneSetupHelpers.AddRootAgent(scene, agentId);
103 scene.DeRezObject(client, part.LocalId, UUID.Zero, DeRezAction.Delete, UUID.Zero);
104 }
105 catch (Exception e)
106 {
107 Console.WriteLine("Exception: " + e.StackTrace);
108 }
104 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId); 109 SceneObjectPart retrievedPart = scene.GetSceneObjectPart(part.LocalId);
110
105 Assert.That(retrievedPart, Is.Not.Null); 111 Assert.That(retrievedPart, Is.Not.Null);
106 112
107 sogd.InventoryDeQueueAndDelete(); 113 sogd.InventoryDeQueueAndDelete();
114
108 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId); 115 SceneObjectPart retrievedPart2 = scene.GetSceneObjectPart(part.LocalId);
109 Assert.That(retrievedPart2, Is.Null); 116 Assert.That(retrievedPart2, Is.Null);
110 } 117 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
index 709cca2..0b7608d 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneObjectLinkingTests.cs
@@ -32,8 +32,7 @@ using NUnit.Framework.SyntaxHelpers;
32using OpenMetaverse; 32using OpenMetaverse;
33using OpenSim.Framework; 33using OpenSim.Framework;
34using OpenSim.Framework.Communications; 34using OpenSim.Framework.Communications;
35using OpenSim.Framework.Communications.Cache; 35
36using OpenSim.Region.Communications.Local;
37using OpenSim.Region.Framework.Scenes; 36using OpenSim.Region.Framework.Scenes;
38using OpenSim.Tests.Common; 37using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 38using OpenSim.Tests.Common.Mock;
diff --git a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
index f00dd66..501207e 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/ScenePresenceTests.cs
@@ -40,8 +40,8 @@ using OpenSim.Framework;
40using OpenSim.Framework.Communications; 40using OpenSim.Framework.Communications;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42using OpenSim.Region.Framework.Interfaces; 42using OpenSim.Region.Framework.Interfaces;
43using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion;
44using OpenSim.Region.CoreModules.World.Serialiser; 43using OpenSim.Region.CoreModules.World.Serialiser;
44using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
45using OpenSim.Tests.Common; 45using OpenSim.Tests.Common;
46using OpenSim.Tests.Common.Mock; 46using OpenSim.Tests.Common.Mock;
47using OpenSim.Tests.Common.Setup; 47using OpenSim.Tests.Common.Setup;
@@ -58,7 +58,6 @@ namespace OpenSim.Region.Framework.Scenes.Tests
58 public UUID agent1, agent2, agent3; 58 public UUID agent1, agent2, agent3;
59 public static Random random; 59 public static Random random;
60 public ulong region1,region2,region3; 60 public ulong region1,region2,region3;
61 public TestCommunicationsManager cm;
62 public AgentCircuitData acd1; 61 public AgentCircuitData acd1;
63 public SceneObjectGroup sog1, sog2, sog3; 62 public SceneObjectGroup sog1, sog2, sog3;
64 public TestClient testclient; 63 public TestClient testclient;
@@ -66,12 +65,11 @@ namespace OpenSim.Region.Framework.Scenes.Tests
66 [TestFixtureSetUp] 65 [TestFixtureSetUp]
67 public void Init() 66 public void Init()
68 { 67 {
69 cm = new TestCommunicationsManager(); 68 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000);
70 scene = SceneSetupHelpers.SetupScene("Neighbour x", UUID.Random(), 1000, 1000, cm); 69 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000);
71 scene2 = SceneSetupHelpers.SetupScene("Neighbour x+1", UUID.Random(), 1001, 1000, cm); 70 scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000);
72 scene3 = SceneSetupHelpers.SetupScene("Neighbour x-1", UUID.Random(), 999, 1000, cm);
73 71
74 ISharedRegionModule interregionComms = new RESTInterregionComms(); 72 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
75 interregionComms.Initialise(new IniConfigSource()); 73 interregionComms.Initialise(new IniConfigSource());
76 interregionComms.PostInitialise(); 74 interregionComms.PostInitialise();
77 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms); 75 SceneSetupHelpers.SetupSceneModules(scene, new IniConfigSource(), interregionComms);
@@ -373,7 +371,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
373 371
374 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross"); 372 Assert.That(presence.HasAttachments(), Is.False, "Presence has attachments before cross");
375 373
376 Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful"); 374 //Assert.That(presence2.CrossAttachmentsIntoNewRegion(region1, true), Is.True, "Cross was not successful");
377 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted"); 375 Assert.That(presence2.HasAttachments(), Is.False, "Presence2 objects were not deleted");
378 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects"); 376 Assert.That(presence.HasAttachments(), Is.True, "Presence has not received new objects");
379 } 377 }
diff --git a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
index 5abbb82..68035ca 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/SceneTests.cs
@@ -141,7 +141,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
141 RegionInfo regionInfo = new RegionInfo(0,0,null,null); 141 RegionInfo regionInfo = new RegionInfo(0,0,null,null);
142 FakeStorageManager storageManager = new FakeStorageManager(); 142 FakeStorageManager storageManager = new FakeStorageManager();
143 143
144 new Scene(regionInfo, null, null, null, storageManager, null, false, false, false, null, null); 144 new Scene(regionInfo, null, null, storageManager, null, false, false, false, null, null);
145 } 145 }
146 } 146 }
147} 147}
diff --git a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
index b46eb8e..cafe48a 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/StandaloneTeleportTests.cs
@@ -34,7 +34,7 @@ using OpenMetaverse;
34using OpenSim.Framework; 34using OpenSim.Framework;
35using OpenSim.Framework.Communications; 35using OpenSim.Framework.Communications;
36using OpenSim.Region.Framework.Interfaces; 36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion; 37using OpenSim.Region.CoreModules.ServiceConnectorsOut.Simulation;
38using OpenSim.Tests.Common; 38using OpenSim.Tests.Common;
39using OpenSim.Tests.Common.Mock; 39using OpenSim.Tests.Common.Mock;
40using OpenSim.Tests.Common.Setup; 40using OpenSim.Tests.Common.Setup;
@@ -113,17 +113,16 @@ namespace OpenSim.Region.Framework.Scenes.Tests
113 113
114 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100"); 114 UUID sceneAId = UUID.Parse("00000000-0000-0000-0000-000000000100");
115 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200"); 115 UUID sceneBId = UUID.Parse("00000000-0000-0000-0000-000000000200");
116 TestCommunicationsManager cm = new TestCommunicationsManager();
117 116
118 // shared module 117 // shared module
119 ISharedRegionModule interregionComms = new RESTInterregionComms(); 118 ISharedRegionModule interregionComms = new LocalSimulationConnectorModule();
120 119
121 120
122 Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, cm, "grid"); 121 Scene sceneB = SceneSetupHelpers.SetupScene("sceneB", sceneBId, 1010, 1010, "grid");
123 SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms); 122 SceneSetupHelpers.SetupSceneModules(sceneB, new IniConfigSource(), interregionComms);
124 sceneB.RegisterRegionWithGrid(); 123 sceneB.RegisterRegionWithGrid();
125 124
126 Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, cm, "grid"); 125 Scene sceneA = SceneSetupHelpers.SetupScene("sceneA", sceneAId, 1000, 1000, "grid");
127 SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms); 126 SceneSetupHelpers.SetupSceneModules(sceneA, new IniConfigSource(), interregionComms);
128 sceneA.RegisterRegionWithGrid(); 127 sceneA.RegisterRegionWithGrid();
129 128
diff --git a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
index a36c4db..6686264 100644
--- a/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
+++ b/OpenSim/Region/Framework/Scenes/Tests/UuidGathererTests.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.Framework.Scenes.Tests
58 TestHelper.InMethod(); 58 TestHelper.InMethod();
59 59
60 UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666"); 60 UUID corruptAssetUuid = UUID.Parse("00000000-0000-0000-0000-000000000666");
61 AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET"); 61 AssetBase corruptAsset = AssetHelpers.CreateAsset(corruptAssetUuid, "CORRUPT ASSET", UUID.Zero);
62 m_assetService.Store(corruptAsset); 62 m_assetService.Store(corruptAsset);
63 63
64 IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>(); 64 IDictionary<UUID, int> foundAssetUuids = new Dictionary<UUID, int>();
diff --git a/OpenSim/Region/Framework/Scenes/UndoState.cs b/OpenSim/Region/Framework/Scenes/UndoState.cs
index 713ff69..55e407e 100644
--- a/OpenSim/Region/Framework/Scenes/UndoState.cs
+++ b/OpenSim/Region/Framework/Scenes/UndoState.cs
@@ -26,6 +26,7 @@
26 */ 26 */
27 27
28using OpenMetaverse; 28using OpenMetaverse;
29using OpenSim.Region.Framework.Interfaces;
29 30
30namespace OpenSim.Region.Framework.Scenes 31namespace OpenSim.Region.Framework.Scenes
31{ 32{
@@ -35,29 +36,21 @@ namespace OpenSim.Region.Framework.Scenes
35 public Vector3 Scale = Vector3.Zero; 36 public Vector3 Scale = Vector3.Zero;
36 public Quaternion Rotation = Quaternion.Identity; 37 public Quaternion Rotation = Quaternion.Identity;
37 38
38 public UndoState(Vector3 pos, Quaternion rot, Vector3 scale)
39 {
40 Position = pos;
41 Rotation = rot;
42 Scale = scale;
43 }
44
45 public UndoState(SceneObjectPart part) 39 public UndoState(SceneObjectPart part)
46 { 40 {
47 if (part != null) 41 if (part != null)
48 { 42 {
49 if (part.ParentID == 0) 43 if (part.ParentID == 0)
50 { 44 {
51 Position = part.AbsolutePosition; 45 Position = part.ParentGroup.AbsolutePosition;
52 Rotation = part.RotationOffset; 46 Rotation = part.RotationOffset;
53 47 Scale = part.Shape.Scale;
54 } 48 }
55 else 49 else
56 { 50 {
57 Position = part.OffsetPosition; 51 Position = part.OffsetPosition;
58 Rotation = part.RotationOffset; 52 Rotation = part.RotationOffset;
59 Scale = part.Shape.Scale; 53 Scale = part.Shape.Scale;
60
61 } 54 }
62 } 55 }
63 } 56 }
@@ -68,7 +61,7 @@ namespace OpenSim.Region.Framework.Scenes
68 { 61 {
69 if (part.ParentID == 0) 62 if (part.ParentID == 0)
70 { 63 {
71 if (Position == part.AbsolutePosition && Rotation == part.RotationOffset) 64 if (Position == part.ParentGroup.AbsolutePosition && Rotation == part.ParentGroup.Rotation)
72 return true; 65 return true;
73 else 66 else
74 return false; 67 return false;
@@ -93,24 +86,78 @@ namespace OpenSim.Region.Framework.Scenes
93 86
94 if (part.ParentID == 0) 87 if (part.ParentID == 0)
95 { 88 {
96 part.ParentGroup.AbsolutePosition = Position; 89 if (Position != Vector3.Zero)
97 part.UpdateRotation(Rotation); 90 part.ParentGroup.AbsolutePosition = Position;
91 part.RotationOffset = Rotation;
92 if (Scale != Vector3.Zero)
93 part.Resize(Scale);
98 part.ParentGroup.ScheduleGroupForTerseUpdate(); 94 part.ParentGroup.ScheduleGroupForTerseUpdate();
99 } 95 }
100 else 96 else
101 { 97 {
102 part.OffsetPosition = Position; 98 if (Position != Vector3.Zero)
99 part.OffsetPosition = Position;
103 part.UpdateRotation(Rotation); 100 part.UpdateRotation(Rotation);
104 part.Resize(Scale); 101 if (Scale != Vector3.Zero)
102 part.Resize(Scale); part.ScheduleTerseUpdate();
103 }
104 part.Undoing = false;
105
106 }
107 }
108 public void PlayfwdState(SceneObjectPart part)
109 {
110 if (part != null)
111 {
112 part.Undoing = true;
113
114 if (part.ParentID == 0)
115 {
116 if (Position != Vector3.Zero)
117 part.ParentGroup.AbsolutePosition = Position;
118 if (Rotation != Quaternion.Identity)
119 part.UpdateRotation(Rotation);
120 if (Scale != Vector3.Zero)
121 part.Resize(Scale);
122 part.ParentGroup.ScheduleGroupForTerseUpdate();
123 }
124 else
125 {
126 if (Position != Vector3.Zero)
127 part.OffsetPosition = Position;
128 if (Rotation != Quaternion.Identity)
129 part.UpdateRotation(Rotation);
130 if (Scale != Vector3.Zero)
131 part.Resize(Scale);
105 part.ScheduleTerseUpdate(); 132 part.ScheduleTerseUpdate();
106 } 133 }
107 part.Undoing = false; 134 part.Undoing = false;
108 135
109 } 136 }
110 } 137 }
138 }
139 public class LandUndoState
140 {
141 public ITerrainModule m_terrainModule;
142 public ITerrainChannel m_terrainChannel;
143
144 public LandUndoState(ITerrainModule terrainModule, ITerrainChannel terrainChannel)
145 {
146 m_terrainModule = terrainModule;
147 m_terrainChannel = terrainChannel;
148 }
149
150 public bool Compare(ITerrainChannel terrainChannel)
151 {
152 if (m_terrainChannel != terrainChannel)
153 return false;
154 else
155 return false;
156 }
111 157
112 public UndoState() 158 public void PlaybackState()
113 { 159 {
160 m_terrainModule.UndoTerrain(m_terrainChannel);
114 } 161 }
115 } 162 }
116} 163}