aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/OptionalModules
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim/Region/OptionalModules')
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs352
-rw-r--r--OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs20
-rw-r--r--OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs299
-rw-r--r--OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs32
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs31
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs42
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs43
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs29
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs27
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs58
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs43
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs87
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs20
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs22
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs64
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs183
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs237
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs517
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs7
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs95
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs23
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs86
-rw-r--r--OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs5
-rw-r--r--OpenSim/Region/OptionalModules/DataSnapshot/LandSnapshot.cs13
-rw-r--r--OpenSim/Region/OptionalModules/DataSnapshot/ObjectSnapshot.cs3
-rw-r--r--OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs28
-rw-r--r--OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs32
-rw-r--r--OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs10
-rw-r--r--OpenSim/Region/OptionalModules/Framework/Monitoring/EtcdMonitoringModule.cs195
-rw-r--r--OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs8
-rw-r--r--OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs453
-rwxr-xr-x[-rw-r--r--]OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs18
-rw-r--r--OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs125
-rw-r--r--OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs10
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerClientEventForwarder.cs94
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs139
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerLargeLandChannel.cs201
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerModule.cs880
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerPermissionModule.cs270
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionConnections.cs94
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCourseLocation.cs43
-rw-r--r--OpenSim/Region/OptionalModules/RegionCombinerModule/RegionData.cs40
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs130
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs8
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs78
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs114
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs80
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs16
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs8
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs28
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs36
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs8
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs38
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs8
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs5
-rw-r--r--OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/UserStatistics/Clients_report.cs23
-rw-r--r--OpenSim/Region/OptionalModules/UserStatistics/Default_Report.cs19
-rw-r--r--OpenSim/Region/OptionalModules/UserStatistics/HTMLUtil.cs4
-rw-r--r--OpenSim/Region/OptionalModules/UserStatistics/LogLinesAJAX.cs12
-rw-r--r--OpenSim/Region/OptionalModules/UserStatistics/Prototype_distributor.cs2
-rw-r--r--OpenSim/Region/OptionalModules/UserStatistics/Sessions_Report.cs11
-rw-r--r--OpenSim/Region/OptionalModules/UserStatistics/SimStatsAJAX.cs8
-rw-r--r--OpenSim/Region/OptionalModules/UserStatistics/WebStatsModule.cs40
-rw-r--r--OpenSim/Region/OptionalModules/ViewerSupport/CameraOnlyModeModule.cs7
-rw-r--r--OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs11
-rw-r--r--OpenSim/Region/OptionalModules/ViewerSupport/GodNamesModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/ViewerSupport/SimulatorFeaturesHelper.cs102
-rw-r--r--OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs5
-rw-r--r--OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs791
-rw-r--r--OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs70
-rw-r--r--OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs156
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs181
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs99
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs8
-rw-r--r--OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs122
-rw-r--r--OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs724
85 files changed, 3198 insertions, 4768 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 6fe86b2..469dd67 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -58,6 +58,8 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
58 58
59 public ISceneAgent SceneAgent { get; set; } 59 public ISceneAgent SceneAgent { get; set; }
60 60
61 public int PingTimeMS { get { return 0; } }
62
61 private string m_username; 63 private string m_username;
62 private string m_nick; 64 private string m_nick;
63 65
@@ -66,6 +68,8 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
66 68
67 private bool m_connected = true; 69 private bool m_connected = true;
68 70
71 public List<uint> SelectedObjects {get; private set;}
72
69 public IRCClientView(TcpClient client, Scene scene) 73 public IRCClientView(TcpClient client, Scene scene)
70 { 74 {
71 m_client = client; 75 m_client = client;
@@ -566,18 +570,28 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
566 public UUID ActiveGroupId 570 public UUID ActiveGroupId
567 { 571 {
568 get { return UUID.Zero; } 572 get { return UUID.Zero; }
573 set {}
569 } 574 }
570 575
571 public string ActiveGroupName 576 public string ActiveGroupName
572 { 577 {
573 get { return "IRCd User"; } 578 get { return "IRCd User"; }
579 set {}
574 } 580 }
575 581
576 public ulong ActiveGroupPowers 582 public ulong ActiveGroupPowers
577 { 583 {
578 get { return 0; } 584 get { return 0; }
585 set {}
586 }
587
588 public Dictionary<UUID, ulong> GetGroupPowers()
589 {
590 return new Dictionary<UUID, ulong>();
579 } 591 }
580 592
593 public void SetGroupPowers(Dictionary<UUID, ulong> powers) { }
594
581 public ulong GetGroupPowers(UUID groupID) 595 public ulong GetGroupPowers(UUID groupID)
582 { 596 {
583 return 0; 597 return 0;
@@ -671,6 +685,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
671 public event ObjectDrop OnObjectDrop; 685 public event ObjectDrop OnObjectDrop;
672 public event StartAnim OnStartAnim; 686 public event StartAnim OnStartAnim;
673 public event StopAnim OnStopAnim; 687 public event StopAnim OnStopAnim;
688 public event ChangeAnim OnChangeAnim;
674 public event LinkObjects OnLinkObjects; 689 public event LinkObjects OnLinkObjects;
675 public event DelinkObjects OnDelinkObjects; 690 public event DelinkObjects OnDelinkObjects;
676 public event RequestMapBlocks OnRequestMapBlocks; 691 public event RequestMapBlocks OnRequestMapBlocks;
@@ -682,6 +697,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
682 public event TeleportLandmarkRequest OnTeleportLandmarkRequest; 697 public event TeleportLandmarkRequest OnTeleportLandmarkRequest;
683 public event TeleportCancel OnTeleportCancel; 698 public event TeleportCancel OnTeleportCancel;
684 public event DeRezObject OnDeRezObject; 699 public event DeRezObject OnDeRezObject;
700 public event RezRestoreToWorld OnRezRestoreToWorld;
685 public event Action<IClientAPI> OnRegionHandShakeReply; 701 public event Action<IClientAPI> OnRegionHandShakeReply;
686 public event GenericCall1 OnRequestWearables; 702 public event GenericCall1 OnRequestWearables;
687 public event Action<IClientAPI, bool> OnCompleteMovementToRegion; 703 public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
@@ -717,6 +733,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
717 public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily; 733 public event RequestObjectPropertiesFamily OnRequestObjectPropertiesFamily;
718 public event UpdatePrimFlags OnUpdatePrimFlags; 734 public event UpdatePrimFlags OnUpdatePrimFlags;
719 public event UpdatePrimTexture OnUpdatePrimTexture; 735 public event UpdatePrimTexture OnUpdatePrimTexture;
736 public event ClientChangeObject onClientChangeObject;
720 public event UpdateVector OnUpdatePrimGroupPosition; 737 public event UpdateVector OnUpdatePrimGroupPosition;
721 public event UpdateVector OnUpdatePrimSinglePosition; 738 public event UpdateVector OnUpdatePrimSinglePosition;
722 public event UpdatePrimRotation OnUpdatePrimGroupRotation; 739 public event UpdatePrimRotation OnUpdatePrimGroupRotation;
@@ -821,6 +838,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
821 public event ObjectOwner OnObjectOwner; 838 public event ObjectOwner OnObjectOwner;
822 public event DirPlacesQuery OnDirPlacesQuery; 839 public event DirPlacesQuery OnDirPlacesQuery;
823 public event DirFindQuery OnDirFindQuery; 840 public event DirFindQuery OnDirFindQuery;
841 public event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy;
824 public event DirLandQuery OnDirLandQuery; 842 public event DirLandQuery OnDirLandQuery;
825 public event DirPopularQuery OnDirPopularQuery; 843 public event DirPopularQuery OnDirPopularQuery;
826 public event DirClassifiedQuery OnDirClassifiedQuery; 844 public event DirClassifiedQuery OnDirClassifiedQuery;
@@ -837,7 +855,7 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
837 public event ClassifiedInfoRequest OnClassifiedInfoRequest; 855 public event ClassifiedInfoRequest OnClassifiedInfoRequest;
838 public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; 856 public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
839 public event ClassifiedDelete OnClassifiedDelete; 857 public event ClassifiedDelete OnClassifiedDelete;
840 public event ClassifiedDelete OnClassifiedGodDelete; 858 public event ClassifiedGodDelete OnClassifiedGodDelete;
841 public event EventNotificationAddRequest OnEventNotificationAddRequest; 859 public event EventNotificationAddRequest OnEventNotificationAddRequest;
842 public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; 860 public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
843 public event EventGodDelete OnEventGodDelete; 861 public event EventGodDelete OnEventGodDelete;
@@ -867,10 +885,12 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
867 public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest; 885 public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
868 public event SimWideDeletesDelegate OnSimWideDeletes; 886 public event SimWideDeletesDelegate OnSimWideDeletes;
869 public event SendPostcard OnSendPostcard; 887 public event SendPostcard OnSendPostcard;
888 public event ChangeInventoryItemFlags OnChangeInventoryItemFlags;
870 public event MuteListEntryUpdate OnUpdateMuteListEntry; 889 public event MuteListEntryUpdate OnUpdateMuteListEntry;
871 public event MuteListEntryRemove OnRemoveMuteListEntry; 890 public event MuteListEntryRemove OnRemoveMuteListEntry;
872 public event GodlikeMessage onGodlikeMessage; 891 public event GodlikeMessage onGodlikeMessage;
873 public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; 892 public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
893 public event GenericCall2 OnUpdateThrottles;
874 894
875#pragma warning restore 67 895#pragma warning restore 67
876 896
@@ -878,20 +898,20 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
878 898
879 public void InPacket(object NewPack) 899 public void InPacket(object NewPack)
880 { 900 {
881 901
882 } 902 }
883 903
884 public void ProcessInPacket(Packet NewPack) 904 public void ProcessInPacket(Packet NewPack)
885 { 905 {
886 906
887 } 907 }
888 908
889 public void Close() 909 public void Close()
890 { 910 {
891 Close(false); 911 Close(true, false);
892 } 912 }
893 913
894 public void Close(bool force) 914 public void Close(bool sendStop, bool force)
895 { 915 {
896 Disconnect(); 916 Disconnect();
897 } 917 }
@@ -933,32 +953,32 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
933 953
934 public void SendWearables(AvatarWearable[] wearables, int serial) 954 public void SendWearables(AvatarWearable[] wearables, int serial)
935 { 955 {
936 956
937 } 957 }
938 958
939 public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry) 959 public void SendAppearance(UUID agentID, byte[] visualParams, byte[] textureEntry)
940 { 960 {
941 961
942 } 962 }
943 963
944 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures) 964 public void SendCachedTextureResponse(ISceneEntity avatar, int serial, List<CachedTextureResponseArg> cachedTextures)
945 { 965 {
946 966
947 } 967 }
948 968
949 public void SendStartPingCheck(byte seq) 969 public void SendStartPingCheck(byte seq)
950 { 970 {
951 971
952 } 972 }
953 973
954 public void SendKillObject(List<uint> localID) 974 public void SendKillObject(List<uint> localID)
955 { 975 {
956 976
957 } 977 }
958 978
959 public void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs) 979 public void SendAnimations(UUID[] animID, int[] seqs, UUID sourceAgentId, UUID[] objectIDs)
960 { 980 {
961 981
962 } 982 }
963 983
964 public void SendChatMessage( 984 public void SendChatMessage(
@@ -985,37 +1005,42 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
985 1005
986 public void SendGenericMessage(string method, UUID invoice, List<byte[]> message) 1006 public void SendGenericMessage(string method, UUID invoice, List<byte[]> message)
987 { 1007 {
988 1008
1009 }
1010
1011 public virtual bool CanSendLayerData()
1012 {
1013 return false;
989 } 1014 }
990 1015
991 public void SendLayerData(float[] map) 1016 public void SendLayerData(float[] map)
992 { 1017 {
993 1018
994 } 1019 }
995 1020
996 public void SendLayerData(int px, int py, float[] map) 1021 public void SendLayerData(int px, int py, float[] map)
997 { 1022 {
998 1023
999 } 1024 }
1000 1025
1001 public void SendWindData(Vector2[] windSpeeds) 1026 public void SendWindData(int version, Vector2[] windSpeeds)
1002 { 1027 {
1003 1028
1004 } 1029 }
1005 1030
1006 public void SendCloudData(float[] cloudCover) 1031 public void SendCloudData(int version, float[] cloudCover)
1007 { 1032 {
1008 1033
1009 } 1034 }
1010 1035
1011 public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) 1036 public void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
1012 { 1037 {
1013 1038
1014 } 1039 }
1015 1040
1016 public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint) 1041 public void InformClientOfNeighbour(ulong neighbourHandle, IPEndPoint neighbourExternalEndPoint)
1017 { 1042 {
1018 1043
1019 } 1044 }
1020 1045
1021 public AgentCircuitData RequestClientInfo() 1046 public AgentCircuitData RequestClientInfo()
@@ -1025,32 +1050,32 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1025 1050
1026 public void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL) 1051 public void CrossRegion(ulong newRegionHandle, Vector3 pos, Vector3 lookAt, IPEndPoint newRegionExternalEndPoint, string capsURL)
1027 { 1052 {
1028 1053
1029 } 1054 }
1030 1055
1031 public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag) 1056 public void SendMapBlock(List<MapBlockData> mapBlocks, uint flag)
1032 { 1057 {
1033 1058
1034 } 1059 }
1035 1060
1036 public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags) 1061 public void SendLocalTeleport(Vector3 position, Vector3 lookAt, uint flags)
1037 { 1062 {
1038 1063
1039 } 1064 }
1040 1065
1041 public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL) 1066 public void SendRegionTeleport(ulong regionHandle, byte simAccess, IPEndPoint regionExternalEndPoint, uint locationID, uint flags, string capsURL)
1042 { 1067 {
1043 1068
1044 } 1069 }
1045 1070
1046 public void SendTeleportFailed(string reason) 1071 public void SendTeleportFailed(string reason)
1047 { 1072 {
1048 1073
1049 } 1074 }
1050 1075
1051 public void SendTeleportStart(uint flags) 1076 public void SendTeleportStart(uint flags)
1052 { 1077 {
1053 1078
1054 } 1079 }
1055 1080
1056 public void SendTeleportProgress(uint flags, string message) 1081 public void SendTeleportProgress(uint flags, string message)
@@ -1059,20 +1084,25 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1059 1084
1060 public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item) 1085 public void SendMoneyBalance(UUID transaction, bool success, byte[] description, int balance, int transactionType, UUID sourceID, bool sourceIsGroup, UUID destID, bool destIsGroup, int amount, string item)
1061 { 1086 {
1062 1087
1063 } 1088 }
1064 1089
1065 public void SendPayPrice(UUID objectID, int[] payPrice) 1090 public void SendPayPrice(UUID objectID, int[] payPrice)
1066 { 1091 {
1067 1092
1068 } 1093 }
1069 1094
1070 public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations) 1095 public void SendCoarseLocationUpdate(List<UUID> users, List<Vector3> CoarseLocations)
1071 { 1096 {
1072 1097
1073 } 1098 }
1074 1099
1075 public void SendAvatarDataImmediate(ISceneEntity avatar) 1100 public void SendEntityFullUpdateImmediate(ISceneEntity ent)
1101 {
1102
1103 }
1104
1105 public void SendEntityTerseUpdateImmediate(ISceneEntity ent)
1076 { 1106 {
1077 1107
1078 } 1108 }
@@ -1094,87 +1124,92 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1094 1124
1095 public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, List<InventoryFolderBase> folders, int version, bool fetchFolders, bool fetchItems) 1125 public void SendInventoryFolderDetails(UUID ownerID, UUID folderID, List<InventoryItemBase> items, List<InventoryFolderBase> folders, int version, bool fetchFolders, bool fetchItems)
1096 { 1126 {
1097 1127
1098 } 1128 }
1099 1129
1100 public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item) 1130 public void SendInventoryItemDetails(UUID ownerID, InventoryItemBase item)
1101 { 1131 {
1102 1132
1103 } 1133 }
1104 1134
1105 public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId) 1135 public void SendInventoryItemCreateUpdate(InventoryItemBase Item, uint callbackId)
1106 { 1136 {
1107 1137
1138 }
1139
1140 public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId)
1141 {
1142
1108 } 1143 }
1109 1144
1110 public void SendRemoveInventoryItem(UUID itemID) 1145 public void SendRemoveInventoryItem(UUID itemID)
1111 { 1146 {
1112 1147
1113 } 1148 }
1114 1149
1115 public void SendTakeControls(int controls, bool passToAgent, bool TakeControls) 1150 public void SendTakeControls(int controls, bool passToAgent, bool TakeControls)
1116 { 1151 {
1117 1152
1118 } 1153 }
1119 1154
1120 public void SendTaskInventory(UUID taskID, short serial, byte[] fileName) 1155 public void SendTaskInventory(UUID taskID, short serial, byte[] fileName)
1121 { 1156 {
1122 1157
1123 } 1158 }
1124 1159
1125 public void SendBulkUpdateInventory(InventoryNodeBase node) 1160 public void SendBulkUpdateInventory(InventoryNodeBase node)
1126 { 1161 {
1127 1162
1128 } 1163 }
1129 1164
1130 public void SendXferPacket(ulong xferID, uint packet, byte[] data) 1165 public void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory)
1131 { 1166 {
1132 1167
1133 } 1168 }
1134 1169
1135 public void SendAbortXferPacket(ulong xferID) 1170 public void SendAbortXferPacket(ulong xferID)
1136 { 1171 {
1137 1172
1138 } 1173 }
1139 1174
1140 public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay, int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent) 1175 public void SendEconomyData(float EnergyEfficiency, int ObjectCapacity, int ObjectCount, int PriceEnergyUnit, int PriceGroupCreate, int PriceObjectClaim, float PriceObjectRent, float PriceObjectScaleFactor, int PriceParcelClaim, float PriceParcelClaimFactor, int PriceParcelRent, int PricePublicObjectDecay, int PricePublicObjectDelete, int PriceRentLight, int PriceUpload, int TeleportMinPrice, float TeleportPriceExponent)
1141 { 1176 {
1142 1177
1143 } 1178 }
1144 1179
1145 public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data) 1180 public void SendAvatarPickerReply(AvatarPickerReplyAgentDataArgs AgentData, List<AvatarPickerReplyDataArgs> Data)
1146 { 1181 {
1147 1182
1148 } 1183 }
1149 1184
1150 public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle) 1185 public void SendAgentDataUpdate(UUID agentid, UUID activegroupid, string firstname, string lastname, ulong grouppowers, string groupname, string grouptitle)
1151 { 1186 {
1152 1187
1153 } 1188 }
1154 1189
1155 public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID) 1190 public void SendPreLoadSound(UUID objectID, UUID ownerID, UUID soundID)
1156 { 1191 {
1157 1192
1158 } 1193 }
1159 1194
1160 public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags) 1195 public void SendPlayAttachedSound(UUID soundID, UUID objectID, UUID ownerID, float gain, byte flags)
1161 { 1196 {
1162 1197
1163 } 1198 }
1164 1199
1165 public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain) 1200 public void SendTriggeredSound(UUID soundID, UUID ownerID, UUID objectID, UUID parentID, ulong handle, Vector3 position, float gain)
1166 { 1201 {
1167 1202
1168 } 1203 }
1169 1204
1170 public void SendAttachedSoundGainChange(UUID objectID, float gain) 1205 public void SendAttachedSoundGainChange(UUID objectID, float gain)
1171 { 1206 {
1172 1207
1173 } 1208 }
1174 1209
1175 public void SendNameReply(UUID profileId, string firstname, string lastname) 1210 public void SendNameReply(UUID profileId, string firstname, string lastname)
1176 { 1211 {
1177 1212
1178 } 1213 }
1179 1214
1180 public void SendAlertMessage(string message) 1215 public void SendAlertMessage(string message)
@@ -1184,7 +1219,12 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1184 1219
1185 public void SendAgentAlertMessage(string message, bool modal) 1220 public void SendAgentAlertMessage(string message, bool modal)
1186 { 1221 {
1187 1222
1223 }
1224
1225 public void SendAlertMessage(string message, string info)
1226 {
1227
1188 } 1228 }
1189 1229
1190 public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message, string url) 1230 public void SendLoadURL(string objectname, UUID objectID, UUID ownerID, bool groupOwned, string message, string url)
@@ -1194,77 +1234,77 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1194 1234
1195 public void SendDialog(string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels) 1235 public void SendDialog(string objectname, UUID objectID, UUID ownerID, string ownerFirstName, string ownerLastName, string msg, UUID textureID, int ch, string[] buttonlabels)
1196 { 1236 {
1197 1237
1198 } 1238 }
1199 1239
1200 public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition) 1240 public void SendSunPos(Vector3 sunPos, Vector3 sunVel, ulong CurrentTime, uint SecondsPerSunCycle, uint SecondsPerYear, float OrbitalPosition)
1201 { 1241 {
1202 1242
1203 } 1243 }
1204 1244
1205 public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks) 1245 public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
1206 { 1246 {
1207 1247
1208 } 1248 }
1209 1249
1210 public void SendViewerTime(int phase) 1250 public void SendViewerTime(int phase)
1211 { 1251 {
1212 1252
1213 } 1253 }
1214 1254
1215 public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, byte[] charterMember, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID) 1255 public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, byte[] membershipType, string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, UUID partnerID)
1216 { 1256 {
1217 1257
1218 } 1258 }
1219 1259
1220 public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question) 1260 public void SendScriptQuestion(UUID taskID, string taskName, string ownerName, UUID itemID, int question)
1221 { 1261 {
1222 1262
1223 } 1263 }
1224 1264
1225 public void SendHealth(float health) 1265 public void SendHealth(float health)
1226 { 1266 {
1227 1267
1228 } 1268 }
1229 1269
1230 public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID) 1270 public void SendEstateList(UUID invoice, int code, UUID[] Data, uint estateID)
1231 { 1271 {
1232 1272
1233 } 1273 }
1234 1274
1235 public void SendBannedUserList(UUID invoice, EstateBan[] banlist, uint estateID) 1275 public void SendBannedUserList(UUID invoice, EstateBan[] banlist, uint estateID)
1236 { 1276 {
1237 1277
1238 } 1278 }
1239 1279
1240 public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args) 1280 public void SendRegionInfoToEstateMenu(RegionInfoForEstateMenuArgs args)
1241 { 1281 {
1242 1282
1243 } 1283 }
1244 1284
1245 public void SendEstateCovenantInformation(UUID covenant) 1285 public void SendEstateCovenantInformation(UUID covenant)
1246 { 1286 {
1247 1287
1248 } 1288 }
1249 1289
1250 public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner) 1290 public void SendDetailedEstateData(UUID invoice, string estateName, uint estateID, uint parentEstate, uint estateFlags, uint sunPosition, UUID covenant, uint covenantChanged, string abuseEmail, UUID estateOwner)
1251 { 1291 {
1252 1292
1253 } 1293 }
1254 1294
1255 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags) 1295 public void SendLandProperties(int sequence_id, bool snap_selection, int request_result, ILandObject lo, float simObjectBonusFactor, int parcelObjectCapacity, int simObjectCapacity, uint regionFlags)
1256 { 1296 {
1257 1297
1258 } 1298 }
1259 1299
1260 public void SendLandAccessListData(List<LandAccessEntry> accessList, uint accessFlag, int localLandID) 1300 public void SendLandAccessListData(List<LandAccessEntry> accessList, uint accessFlag, int localLandID)
1261 { 1301 {
1262 1302
1263 } 1303 }
1264 1304
1265 public void SendForceClientSelectObjects(List<uint> objectIDs) 1305 public void SendForceClientSelectObjects(List<uint> objectIDs)
1266 { 1306 {
1267 1307
1268 } 1308 }
1269 1309
1270 public void SendCameraConstraint(Vector4 ConstraintPlane) 1310 public void SendCameraConstraint(Vector4 ConstraintPlane)
@@ -1274,57 +1314,57 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1274 1314
1275 public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount) 1315 public void SendLandObjectOwners(LandData land, List<UUID> groups, Dictionary<UUID, int> ownersAndCount)
1276 { 1316 {
1277 1317
1278 } 1318 }
1279 1319
1280 public void SendLandParcelOverlay(byte[] data, int sequence_id) 1320 public void SendLandParcelOverlay(byte[] data, int sequence_id)
1281 { 1321 {
1282 1322
1283 } 1323 }
1284 1324
1285 public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time) 1325 public void SendParcelMediaCommand(uint flags, ParcelMediaCommandEnum command, float time)
1286 { 1326 {
1287 1327
1288 } 1328 }
1289 1329
1290 public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID, byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight, byte mediaLoop) 1330 public void SendParcelMediaUpdate(string mediaUrl, UUID mediaTextureID, byte autoScale, string mediaType, string mediaDesc, int mediaWidth, int mediaHeight, byte mediaLoop)
1291 { 1331 {
1292 1332
1293 } 1333 }
1294 1334
1295 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) 1335 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
1296 { 1336 {
1297 1337
1298 } 1338 }
1299 1339
1300 public void SendConfirmXfer(ulong xferID, uint PacketID) 1340 public void SendConfirmXfer(ulong xferID, uint PacketID)
1301 { 1341 {
1302 1342
1303 } 1343 }
1304 1344
1305 public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName) 1345 public void SendXferRequest(ulong XferID, short AssetType, UUID vFileID, byte FilePath, byte[] FileName)
1306 { 1346 {
1307 1347
1308 } 1348 }
1309 1349
1310 public void SendInitiateDownload(string simFileName, string clientFileName) 1350 public void SendInitiateDownload(string simFileName, string clientFileName)
1311 { 1351 {
1312 1352
1313 } 1353 }
1314 1354
1315 public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec) 1355 public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
1316 { 1356 {
1317 1357
1318 } 1358 }
1319 1359
1320 public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData) 1360 public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
1321 { 1361 {
1322 1362
1323 } 1363 }
1324 1364
1325 public void SendImageNotFound(UUID imageid) 1365 public void SendImageNotFound(UUID imageid)
1326 { 1366 {
1327 1367
1328 } 1368 }
1329 1369
1330 public void SendShutdownConnectionNotice() 1370 public void SendShutdownConnectionNotice()
@@ -1334,12 +1374,12 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1334 1374
1335 public void SendSimStats(SimStats stats) 1375 public void SendSimStats(SimStats stats)
1336 { 1376 {
1337 1377
1338 } 1378 }
1339 1379
1340 public void SendObjectPropertiesFamilyData(ISceneEntity Entity, uint RequestFlags) 1380 public void SendObjectPropertiesFamilyData(ISceneEntity Entity, uint RequestFlags)
1341 { 1381 {
1342 1382
1343 } 1383 }
1344 1384
1345 public void SendObjectPropertiesReply(ISceneEntity entity) 1385 public void SendObjectPropertiesReply(ISceneEntity entity)
@@ -1348,72 +1388,76 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1348 1388
1349 public void SendAgentOffline(UUID[] agentIDs) 1389 public void SendAgentOffline(UUID[] agentIDs)
1350 { 1390 {
1351 1391
1352 } 1392 }
1353 1393
1354 public void SendAgentOnline(UUID[] agentIDs) 1394 public void SendAgentOnline(UUID[] agentIDs)
1355 { 1395 {
1356 1396
1397 }
1398
1399 public void SendFindAgent(UUID HunterID, UUID PreyID, double GlobalX, double GlobalY)
1400 {
1357 } 1401 }
1358 1402
1359 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) 1403 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
1360 { 1404 {
1361 1405
1362 } 1406 }
1363 1407
1364 public void SendAdminResponse(UUID Token, uint AdminLevel) 1408 public void SendAdminResponse(UUID Token, uint AdminLevel)
1365 { 1409 {
1366 1410
1367 } 1411 }
1368 1412
1369 public void SendGroupMembership(GroupMembershipData[] GroupMembership) 1413 public void SendGroupMembership(GroupMembershipData[] GroupMembership)
1370 { 1414 {
1371 1415
1372 } 1416 }
1373 1417
1374 public void SendGroupNameReply(UUID groupLLUID, string GroupName) 1418 public void SendGroupNameReply(UUID groupLLUID, string GroupName)
1375 { 1419 {
1376 1420
1377 } 1421 }
1378 1422
1379 public void SendJoinGroupReply(UUID groupID, bool success) 1423 public void SendJoinGroupReply(UUID groupID, bool success)
1380 { 1424 {
1381 1425
1382 } 1426 }
1383 1427
1384 public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success) 1428 public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
1385 { 1429 {
1386 1430
1387 } 1431 }
1388 1432
1389 public void SendLeaveGroupReply(UUID groupID, bool success) 1433 public void SendLeaveGroupReply(UUID groupID, bool success)
1390 { 1434 {
1391 1435
1392 } 1436 }
1393 1437
1394 public void SendCreateGroupReply(UUID groupID, bool success, string message) 1438 public void SendCreateGroupReply(UUID groupID, bool success, string message)
1395 { 1439 {
1396 1440
1397 } 1441 }
1398 1442
1399 public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia) 1443 public void SendLandStatReply(uint reportType, uint requestFlags, uint resultCount, LandStatReportItem[] lsrpia)
1400 { 1444 {
1401 1445
1402 } 1446 }
1403 1447
1404 public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running) 1448 public void SendScriptRunningReply(UUID objectID, UUID itemID, bool running)
1405 { 1449 {
1406 1450
1407 } 1451 }
1408 1452
1409 public void SendAsset(AssetRequestToClient req) 1453 public void SendAsset(AssetRequestToClient req)
1410 { 1454 {
1411 1455
1412 } 1456 }
1413 1457
1414 public void SendTexture(AssetBase TextureAsset) 1458 public void SendTexture(AssetBase TextureAsset)
1415 { 1459 {
1416 1460
1417 } 1461 }
1418 1462
1419 public virtual void SetChildAgentThrottle(byte[] throttle) 1463 public virtual void SetChildAgentThrottle(byte[] throttle)
@@ -1421,6 +1465,16 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1421 1465
1422 } 1466 }
1423 1467
1468 public virtual void SetChildAgentThrottle(byte[] throttle,float factor)
1469 {
1470
1471 }
1472
1473 public void SetAgentThrottleSilent(int throttle, int setting)
1474 {
1475
1476
1477 }
1424 public byte[] GetThrottlesPacked(float multiplier) 1478 public byte[] GetThrottlesPacked(float multiplier)
1425 { 1479 {
1426 return new byte[0]; 1480 return new byte[0];
@@ -1449,12 +1503,12 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1449 1503
1450 public void SetClientInfo(ClientInfo info) 1504 public void SetClientInfo(ClientInfo info)
1451 { 1505 {
1452 1506
1453 } 1507 }
1454 1508
1455 public void SetClientOption(string option, string value) 1509 public void SetClientOption(string option, string value)
1456 { 1510 {
1457 1511
1458 } 1512 }
1459 1513
1460 public string GetClientOption(string option) 1514 public string GetClientOption(string option)
@@ -1469,67 +1523,67 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1469 1523
1470 public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters) 1524 public void SendSetFollowCamProperties(UUID objectID, SortedDictionary<int, float> parameters)
1471 { 1525 {
1472 1526
1473 } 1527 }
1474 1528
1475 public void SendClearFollowCamProperties(UUID objectID) 1529 public void SendClearFollowCamProperties(UUID objectID)
1476 { 1530 {
1477 1531
1478 } 1532 }
1479 1533
1480 public void SendRegionHandle(UUID regoinID, ulong handle) 1534 public void SendRegionHandle(UUID regoinID, ulong handle)
1481 { 1535 {
1482 1536
1483 } 1537 }
1484 1538
1485 public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y) 1539 public void SendParcelInfo(RegionInfo info, LandData land, UUID parcelID, uint x, uint y)
1486 { 1540 {
1487 1541
1488 } 1542 }
1489 1543
1490 public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt) 1544 public void SendScriptTeleportRequest(string objName, string simName, Vector3 pos, Vector3 lookAt)
1491 { 1545 {
1492 1546
1493 } 1547 }
1494 1548
1495 public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data) 1549 public void SendDirPlacesReply(UUID queryID, DirPlacesReplyData[] data)
1496 { 1550 {
1497 1551
1498 } 1552 }
1499 1553
1500 public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data) 1554 public void SendDirPeopleReply(UUID queryID, DirPeopleReplyData[] data)
1501 { 1555 {
1502 1556
1503 } 1557 }
1504 1558
1505 public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data) 1559 public void SendDirEventsReply(UUID queryID, DirEventsReplyData[] data)
1506 { 1560 {
1507 1561
1508 } 1562 }
1509 1563
1510 public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data) 1564 public void SendDirGroupsReply(UUID queryID, DirGroupsReplyData[] data)
1511 { 1565 {
1512 1566
1513 } 1567 }
1514 1568
1515 public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data) 1569 public void SendDirClassifiedReply(UUID queryID, DirClassifiedReplyData[] data)
1516 { 1570 {
1517 1571
1518 } 1572 }
1519 1573
1520 public void SendDirLandReply(UUID queryID, DirLandReplyData[] data) 1574 public void SendDirLandReply(UUID queryID, DirLandReplyData[] data)
1521 { 1575 {
1522 1576
1523 } 1577 }
1524 1578
1525 public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data) 1579 public void SendDirPopularReply(UUID queryID, DirPopularReplyData[] data)
1526 { 1580 {
1527 1581
1528 } 1582 }
1529 1583
1530 public void SendEventInfoReply(EventData info) 1584 public void SendEventInfoReply(EventData info)
1531 { 1585 {
1532 1586
1533 } 1587 }
1534 1588
1535 public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint) 1589 public void SendTelehubInfo(UUID ObjectID, string ObjectName, Vector3 ObjectPos, Quaternion ObjectRot, List<Vector3> SpawnPoint)
@@ -1539,72 +1593,93 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1539 1593
1540 public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags) 1594 public void SendMapItemReply(mapItemReply[] replies, uint mapitemtype, uint flags)
1541 { 1595 {
1542 1596
1543 } 1597 }
1544 1598
1545 public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data) 1599 public void SendAvatarGroupsReply(UUID avatarID, GroupMembershipData[] data)
1546 { 1600 {
1547 1601
1602 }
1603
1604 public void SendAgentGroupDataUpdate(UUID avatarID, GroupMembershipData[] data)
1605 {
1606
1548 } 1607 }
1549 1608
1550 public void SendOfferCallingCard(UUID srcID, UUID transactionID) 1609 public void SendOfferCallingCard(UUID srcID, UUID transactionID)
1551 { 1610 {
1552 1611
1553 } 1612 }
1554 1613
1555 public void SendAcceptCallingCard(UUID transactionID) 1614 public void SendAcceptCallingCard(UUID transactionID)
1556 { 1615 {
1557 1616
1558 } 1617 }
1559 1618
1560 public void SendDeclineCallingCard(UUID transactionID) 1619 public void SendDeclineCallingCard(UUID transactionID)
1561 { 1620 {
1562 1621
1563 } 1622 }
1564 1623
1565 public void SendTerminateFriend(UUID exFriendID) 1624 public void SendTerminateFriend(UUID exFriendID)
1566 { 1625 {
1567 1626
1568 } 1627 }
1569 1628
1570 public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name) 1629 public void SendAvatarClassifiedReply(UUID targetID, UUID[] classifiedID, string[] name)
1571 { 1630 {
1572 1631
1573 } 1632 }
1574 1633
1575 public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price) 1634 public void SendClassifiedInfoReply(UUID classifiedID, UUID creatorID, uint creationDate, uint expirationDate, uint category, string name, string description, UUID parcelID, uint parentEstate, UUID snapshotID, string simName, Vector3 globalPos, string parcelName, byte classifiedFlags, int price)
1576 { 1635 {
1577 1636
1578 } 1637 }
1579 1638
1580 public void SendAgentDropGroup(UUID groupID) 1639 public void SendAgentDropGroup(UUID groupID)
1581 { 1640 {
1582 1641
1583 } 1642 }
1584 1643
1585 public void RefreshGroupMembership() 1644 public void RefreshGroupMembership()
1586 { 1645 {
1587 1646
1647 }
1648
1649 public void UpdateGroupMembership(GroupMembershipData[] data)
1650 {
1651
1588 } 1652 }
1589 1653
1654 public void GroupMembershipRemove(UUID GroupID)
1655 {
1656
1657 }
1658
1659 public void GroupMembershipAddReplace(UUID GroupID,ulong GroupPowers)
1660 {
1661
1662 }
1663
1664
1590 public void SendAvatarNotesReply(UUID targetID, string text) 1665 public void SendAvatarNotesReply(UUID targetID, string text)
1591 { 1666 {
1592 1667
1593 } 1668 }
1594 1669
1595 public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks) 1670 public void SendAvatarPicksReply(UUID targetID, Dictionary<UUID, string> picks)
1596 { 1671 {
1597 1672
1598 } 1673 }
1599 1674
1600 public void SendPickInfoReply(UUID pickID, UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled) 1675 public void SendPickInfoReply(UUID pickID, UUID creatorID, bool topPick, UUID parcelID, string name, string desc, UUID snapshotID, string user, string originalName, string simName, Vector3 posGlobal, int sortOrder, bool enabled)
1601 { 1676 {
1602 1677
1603 } 1678 }
1604 1679
1605 public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds) 1680 public void SendAvatarClassifiedReply(UUID targetID, Dictionary<UUID, string> classifieds)
1606 { 1681 {
1607 1682
1608 } 1683 }
1609 1684
1610 public void SendAvatarInterestUpdate(IClientAPI client, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages) 1685 public void SendAvatarInterestUpdate(IClientAPI client, uint wantmask, string wanttext, uint skillsmask, string skillstext, string languages)
@@ -1614,22 +1689,27 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1614 1689
1615 public void SendParcelDwellReply(int localID, UUID parcelID, float dwell) 1690 public void SendParcelDwellReply(int localID, UUID parcelID, float dwell)
1616 { 1691 {
1617 1692
1618 } 1693 }
1619 1694
1620 public void SendUserInfoReply(bool imViaEmail, bool visible, string email) 1695 public void SendUserInfoReply(bool imViaEmail, bool visible, string email)
1621 { 1696 {
1622 1697
1623 } 1698 }
1624 1699
1625 public void SendUseCachedMuteList() 1700 public void SendUseCachedMuteList()
1626 { 1701 {
1627 1702
1703 }
1704
1705 public void SendEmpytMuteList()
1706 {
1707
1628 } 1708 }
1629 1709
1630 public void SendMuteListUpdate(string filename) 1710 public void SendMuteListUpdate(string filename)
1631 { 1711 {
1632 1712
1633 } 1713 }
1634 1714
1635 public bool AddGenericPacketHandler(string MethodName, GenericMessage handler) 1715 public bool AddGenericPacketHandler(string MethodName, GenericMessage handler)
@@ -1646,15 +1726,15 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1646 public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) 1726 public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
1647 { 1727 {
1648 } 1728 }
1649 1729
1650 public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt) 1730 public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
1651 { 1731 {
1652 } 1732 }
1653 1733
1654 public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier) 1734 public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
1655 { 1735 {
1656 } 1736 }
1657 1737
1658 public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt) 1738 public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt)
1659 { 1739 {
1660 } 1740 }
@@ -1678,14 +1758,26 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
1678 public void SendAgentTerseUpdate(ISceneEntity presence) 1758 public void SendAgentTerseUpdate(ISceneEntity presence)
1679 { 1759 {
1680 } 1760 }
1681 1761
1682 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data) 1762 public void SendPlacesReply(UUID queryID, UUID transactionID, PlacesReplyData[] data)
1683 { 1763 {
1684 } 1764 }
1685 1765
1766 public void SendSelectedPartsProprieties(List<ISceneEntity> parts)
1767 {
1768 }
1769
1686 public void SendPartPhysicsProprieties(ISceneEntity entity) 1770 public void SendPartPhysicsProprieties(ISceneEntity entity)
1687 { 1771 {
1688 } 1772 }
1689 1773
1774 public void SendPartFullUpdate(ISceneEntity ent, uint? parentID)
1775 {
1776 }
1777
1778 public int GetAgentThrottleSilent(int throttle)
1779 {
1780 return 0;
1781 }
1690 } 1782 }
1691} 1783}
diff --git a/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs
index c897aa5..e93fcdc 100644
--- a/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs
+++ b/OpenSim/Region/OptionalModules/Agent/TextureSender/J2KDecoderCommandModule.cs
@@ -54,36 +54,36 @@ namespace OpenSim.Region.OptionalModules.Agent.TextureSender
54// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 55
56 private Scene m_scene; 56 private Scene m_scene;
57 57
58 public string Name { get { return "Asset Information Module"; } } 58 public string Name { get { return "Asset Information Module"; } }
59 59
60 public Type ReplaceableInterface { get { return null; } } 60 public Type ReplaceableInterface { get { return null; } }
61 61
62 public void Initialise(IConfigSource source) 62 public void Initialise(IConfigSource source)
63 { 63 {
64// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: INITIALIZED MODULE"); 64// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: INITIALIZED MODULE");
65 } 65 }
66 66
67 public void PostInitialise() 67 public void PostInitialise()
68 { 68 {
69// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: POST INITIALIZED MODULE"); 69// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: POST INITIALIZED MODULE");
70 } 70 }
71 71
72 public void Close() 72 public void Close()
73 { 73 {
74// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: CLOSED MODULE"); 74// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: CLOSED MODULE");
75 } 75 }
76 76
77 public void AddRegion(Scene scene) 77 public void AddRegion(Scene scene)
78 { 78 {
79// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); 79// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
80 } 80 }
81 81
82 public void RemoveRegion(Scene scene) 82 public void RemoveRegion(Scene scene)
83 { 83 {
84// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); 84// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
85 } 85 }
86 86
87 public void RegionLoaded(Scene scene) 87 public void RegionLoaded(Scene scene)
88 { 88 {
89// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); 89// m_log.DebugFormat("[J2K DECODER COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
@@ -117,10 +117,10 @@ namespace OpenSim.Region.OptionalModules.Agent.TextureSender
117 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); 117 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
118 return; 118 return;
119 } 119 }
120 120
121 AssetBase asset = m_scene.AssetService.Get(assetId.ToString()); 121 AssetBase asset = m_scene.AssetService.Get(assetId.ToString());
122 if (asset == null) 122 if (asset == null)
123 { 123 {
124 MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); 124 MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
125 return; 125 return;
126 } 126 }
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
index 08d0fbf..490809e 100644
--- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
@@ -52,48 +52,48 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
52 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")] 52 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "LindenUDPInfoModule")]
53 public class LindenUDPInfoModule : ISharedRegionModule 53 public class LindenUDPInfoModule : ISharedRegionModule
54 { 54 {
55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 55 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
56 56
57 protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>(); 57 protected Dictionary<UUID, Scene> m_scenes = new Dictionary<UUID, Scene>();
58 58
59 public string Name { get { return "Linden UDP Module"; } } 59 public string Name { get { return "Linden UDP Module"; } }
60 60
61 public Type ReplaceableInterface { get { return null; } } 61 public Type ReplaceableInterface { get { return null; } }
62 62
63 public void Initialise(IConfigSource source) 63 public void Initialise(IConfigSource source)
64 { 64 {
65// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: INITIALIZED MODULE"); 65// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: INITIALIZED MODULE");
66 } 66 }
67 67
68 public void PostInitialise() 68 public void PostInitialise()
69 { 69 {
70// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: POST INITIALIZED MODULE"); 70// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: POST INITIALIZED MODULE");
71 } 71 }
72 72
73 public void Close() 73 public void Close()
74 { 74 {
75// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: CLOSED MODULE"); 75// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: CLOSED MODULE");
76 } 76 }
77 77
78 public void AddRegion(Scene scene) 78 public void AddRegion(Scene scene)
79 { 79 {
80// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); 80// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
81 81
82 lock (m_scenes) 82 lock (m_scenes)
83 m_scenes[scene.RegionInfo.RegionID] = scene; 83 m_scenes[scene.RegionInfo.RegionID] = scene;
84 84
85 scene.AddCommand( 85 scene.AddCommand(
86 "Comms", this, "show pqueues", 86 "Comms", this, "show pqueues",
87 "show pqueues [full]", 87 "show pqueues [full]",
88 "Show priority queue data for each client", 88 "Show priority queue data for each client",
89 "Without the 'full' option, only root agents are shown." 89 "Without the 'full' option, only root agents are shown."
90 + " With the 'full' option child agents are also shown.", 90 + " With the 'full' option child agents are also shown.",
91 (mod, cmd) => MainConsole.Instance.Output(GetPQueuesReport(cmd))); 91 (mod, cmd) => MainConsole.Instance.Output(GetPQueuesReport(cmd)));
92 92
93 scene.AddCommand( 93 scene.AddCommand(
94 "Comms", this, "show queues", 94 "Comms", this, "show queues",
95 "show queues [full]", 95 "show queues [full]",
96 "Show queue data for each client", 96 "Show queue data for each client",
97 "Without the 'full' option, only root agents are shown.\n" 97 "Without the 'full' option, only root agents are shown.\n"
98 + "With the 'full' option child agents are also shown.\n\n" 98 + "With the 'full' option child agents are also shown.\n\n"
99 + "Type - Rt is a root (avatar) client whilst cd is a child (neighbour interacting) client.\n" 99 + "Type - Rt is a root (avatar) client whilst cd is a child (neighbour interacting) client.\n"
@@ -116,40 +116,24 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
116 "clear image queues <first-name> <last-name>", 116 "clear image queues <first-name> <last-name>",
117 "Clear the image queues (textures downloaded via UDP) for a particular client.", 117 "Clear the image queues (textures downloaded via UDP) for a particular client.",
118 (mod, cmd) => MainConsole.Instance.Output(HandleImageQueuesClear(cmd))); 118 (mod, cmd) => MainConsole.Instance.Output(HandleImageQueuesClear(cmd)));
119 119
120 scene.AddCommand( 120 scene.AddCommand(
121 "Comms", this, "show throttles", 121 "Comms", this, "show throttles",
122 "show throttles [full]", 122 "show throttles [full]",
123 "Show throttle settings for each client and for the server overall", 123 "Show throttle settings for each client and for the server overall",
124 "Without the 'full' option, only root agents are shown." 124 "Without the 'full' option, only root agents are shown."
125 + " With the 'full' option child agents are also shown.", 125 + " With the 'full' option child agents are also shown.",
126 (mod, cmd) => MainConsole.Instance.Output(GetThrottlesReport(cmd))); 126 (mod, cmd) => MainConsole.Instance.Output(GetThrottlesReport(cmd)));
127
128 scene.AddCommand(
129 "Comms", this, "emergency-monitoring",
130 "emergency-monitoring",
131 "Go on/off emergency monitoring mode",
132 "Go on/off emergency monitoring mode",
133 HandleEmergencyMonitoring);
134
135 scene.AddCommand(
136 "Comms", this, "show client stats",
137 "show client stats [first_name last_name]",
138 "Show client request stats",
139 "Without the 'first_name last_name' option, all clients are shown."
140 + " With the 'first_name last_name' option only a specific client is shown.",
141 (mod, cmd) => MainConsole.Instance.Output(HandleClientStatsReport(cmd)));
142
143 } 127 }
144 128
145 public void RemoveRegion(Scene scene) 129 public void RemoveRegion(Scene scene)
146 { 130 {
147// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); 131// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
148 132
149 lock (m_scenes) 133 lock (m_scenes)
150 m_scenes.Remove(scene.RegionInfo.RegionID); 134 m_scenes.Remove(scene.RegionInfo.RegionID);
151 } 135 }
152 136
153 public void RegionLoaded(Scene scene) 137 public void RegionLoaded(Scene scene)
154 { 138 {
155// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); 139// m_log.DebugFormat("[LINDEN UDP INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
@@ -183,7 +167,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
183 foreach (ScenePresence agent in foundAgents) 167 foreach (ScenePresence agent in foundAgents)
184 { 168 {
185 LLClientView client = agent.ControllingClient as LLClientView; 169 LLClientView client = agent.ControllingClient as LLClientView;
186 170
187 if (client == null) 171 if (client == null)
188 return "This command is only supported for LLClientView"; 172 return "This command is only supported for LLClientView";
189 173
@@ -197,29 +181,11 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
197 return report.ToString(); 181 return report.ToString();
198 } 182 }
199 183
200 protected void HandleEmergencyMonitoring(string module, string[] cmd)
201 {
202 bool mode = true;
203 if (cmd.Length == 1 || (cmd.Length > 1 && cmd[1] == "on"))
204 {
205 mode = true;
206 MainConsole.Instance.Output("Emergency Monitoring ON");
207 }
208 else
209 {
210 mode = false;
211 MainConsole.Instance.Output("Emergency Monitoring OFF");
212 }
213
214 foreach (Scene s in m_scenes.Values)
215 s.EmergencyMonitoring = mode;
216 }
217
218 protected string GetColumnEntry(string entry, int maxLength, int columnPadding) 184 protected string GetColumnEntry(string entry, int maxLength, int columnPadding)
219 { 185 {
220 return string.Format( 186 return string.Format(
221 "{0,-" + maxLength + "}{1,-" + columnPadding + "}", 187 "{0,-" + maxLength + "}{1,-" + columnPadding + "}",
222 entry.Length > maxLength ? entry.Substring(0, maxLength) : entry, 188 entry.Length > maxLength ? entry.Substring(0, maxLength) : entry,
223 ""); 189 "");
224 } 190 }
225 191
@@ -232,29 +198,29 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
232 { 198 {
233 bool showChildren = false; 199 bool showChildren = false;
234 string pname = ""; 200 string pname = "";
235 201
236 if (showParams.Length > 2 && showParams[2] == "full") 202 if (showParams.Length > 2 && showParams[2] == "full")
237 showChildren = true; 203 showChildren = true;
238 else if (showParams.Length > 3) 204 else if (showParams.Length > 3)
239 pname = showParams[2] + " " + showParams[3]; 205 pname = showParams[2] + " " + showParams[3];
240 206
241 StringBuilder report = new StringBuilder(); 207 StringBuilder report = new StringBuilder();
242 208
243 int columnPadding = 2; 209 int columnPadding = 2;
244 int maxNameLength = 18; 210 int maxNameLength = 18;
245 int maxRegionNameLength = 14; 211 int maxRegionNameLength = 14;
246 int maxTypeLength = 4; 212 int maxTypeLength = 4;
247// int totalInfoFieldsLength = maxNameLength + columnPadding + maxRegionNameLength + columnPadding + maxTypeLength + columnPadding; 213// int totalInfoFieldsLength = maxNameLength + columnPadding + maxRegionNameLength + columnPadding + maxTypeLength + columnPadding;
248 214
249 report.Append(GetColumnEntry("User", maxNameLength, columnPadding)); 215 report.Append(GetColumnEntry("User", maxNameLength, columnPadding));
250 report.Append(GetColumnEntry("Region", maxRegionNameLength, columnPadding)); 216 report.Append(GetColumnEntry("Region", maxRegionNameLength, columnPadding));
251 report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); 217 report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding));
252 218
253 report.AppendFormat( 219 report.AppendFormat(
254 "{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7} {10,7} {11,7}\n", 220 "{0,7} {1,7} {2,7} {3,7} {4,7} {5,7} {6,7} {7,7} {8,7} {9,7} {10,7} {11,7}\n",
255 "Pri 0", 221 "Pri 0",
256 "Pri 1", 222 "Pri 1",
257 "Pri 2", 223 "Pri 2",
258 "Pri 3", 224 "Pri 3",
259 "Pri 4", 225 "Pri 4",
260 "Pri 5", 226 "Pri 5",
@@ -277,16 +243,16 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
277 bool isChild = client.SceneAgent.IsChildAgent; 243 bool isChild = client.SceneAgent.IsChildAgent;
278 if (isChild && !showChildren) 244 if (isChild && !showChildren)
279 return; 245 return;
280 246
281 string name = client.Name; 247 string name = client.Name;
282 if (pname != "" && name != pname) 248 if (pname != "" && name != pname)
283 return; 249 return;
284 250
285 string regionName = scene.RegionInfo.RegionName; 251 string regionName = scene.RegionInfo.RegionName;
286 252
287 report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); 253 report.Append(GetColumnEntry(name, maxNameLength, columnPadding));
288 report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); 254 report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding));
289 report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); 255 report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding));
290 report.AppendLine(((LLClientView)client).EntityUpdateQueue.ToString()); 256 report.AppendLine(((LLClientView)client).EntityUpdateQueue.ToString());
291 } 257 }
292 }); 258 });
@@ -331,17 +297,17 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
331 foreach (ScenePresence agent in foundAgents) 297 foreach (ScenePresence agent in foundAgents)
332 { 298 {
333 LLClientView client = agent.ControllingClient as LLClientView; 299 LLClientView client = agent.ControllingClient as LLClientView;
334 300
335 if (client == null) 301 if (client == null)
336 return "This command is only supported for LLClientView"; 302 return "This command is only supported for LLClientView";
337 303
338 J2KImage[] images = client.ImageManager.GetImages(); 304 J2KImage[] images = client.ImageManager.GetImages();
339 305
340 report.AppendFormat( 306 report.AppendFormat(
341 "In region {0} ({1} agent)\n", 307 "In region {0} ({1} agent)\n",
342 agent.Scene.RegionInfo.RegionName, agent.IsChildAgent ? "child" : "root"); 308 agent.Scene.RegionInfo.RegionName, agent.IsChildAgent ? "child" : "root");
343 report.AppendFormat("Images in queue: {0}\n", images.Length); 309 report.AppendFormat("Images in queue: {0}\n", images.Length);
344 310
345 if (images.Length > 0) 311 if (images.Length > 0)
346 { 312 {
347 report.AppendFormat( 313 report.AppendFormat(
@@ -352,7 +318,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
352 "Start Pkt", 318 "Start Pkt",
353 "Has Asset", 319 "Has Asset",
354 "Decoded"); 320 "Decoded");
355 321
356 foreach (J2KImage image in images) 322 foreach (J2KImage image in images)
357 report.AppendFormat( 323 report.AppendFormat(
358 "{0,36} {1,8} {2,10} {3,10} {4,9} {5,7}\n", 324 "{0,36} {1,8} {2,10} {3,10} {4,9} {5,7}\n",
@@ -362,7 +328,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
362 328
363 return report.ToString(); 329 return report.ToString();
364 } 330 }
365 331
366 /// <summary> 332 /// <summary>
367 /// Generate UDP Queue data report for each client 333 /// Generate UDP Queue data report for each client
368 /// </summary> 334 /// </summary>
@@ -372,16 +338,16 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
372 { 338 {
373 bool showChildren = false; 339 bool showChildren = false;
374 string pname = ""; 340 string pname = "";
375 341
376 if (showParams.Length > 2 && showParams[2] == "full") 342 if (showParams.Length > 2 && showParams[2] == "full")
377 showChildren = true; 343 showChildren = true;
378 else if (showParams.Length > 3) 344 else if (showParams.Length > 3)
379 pname = showParams[2] + " " + showParams[3]; 345 pname = showParams[2] + " " + showParams[3];
380 346
381 StringBuilder report = new StringBuilder(); 347 StringBuilder report = new StringBuilder();
382 348
383 int columnPadding = 2; 349 int columnPadding = 2;
384 int maxNameLength = 18; 350 int maxNameLength = 18;
385 int maxRegionNameLength = 14; 351 int maxRegionNameLength = 14;
386 int maxTypeLength = 4; 352 int maxTypeLength = 4;
387 353
@@ -389,11 +355,11 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
389 = maxNameLength + columnPadding 355 = maxNameLength + columnPadding
390 + maxRegionNameLength + columnPadding 356 + maxRegionNameLength + columnPadding
391 + maxTypeLength + columnPadding; 357 + maxTypeLength + columnPadding;
392 358
393 report.Append(GetColumnEntry("User", maxNameLength, columnPadding)); 359 report.Append(GetColumnEntry("User", maxNameLength, columnPadding));
394 report.Append(GetColumnEntry("Region", maxRegionNameLength, columnPadding)); 360 report.Append(GetColumnEntry("Region", maxRegionNameLength, columnPadding));
395 report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); 361 report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding));
396 362
397 report.AppendFormat( 363 report.AppendFormat(
398 "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n", 364 "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n",
399 "Since", 365 "Since",
@@ -408,7 +374,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
408 "Q Pkts", 374 "Q Pkts",
409 "Q Pkts", 375 "Q Pkts",
410 "Q Pkts"); 376 "Q Pkts");
411 377
412 report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); 378 report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", "");
413 report.AppendFormat( 379 report.AppendFormat(
414 "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n", 380 "{0,7} {1,7} {2,7} {3,7} {4,9} {5,7} {6,7} {7,7} {8,7} {9,7} {10,8} {11,7}\n",
@@ -423,8 +389,8 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
423 "Cloud", 389 "Cloud",
424 "Task", 390 "Task",
425 "Texture", 391 "Texture",
426 "Asset"); 392 "Asset");
427 393
428 lock (m_scenes) 394 lock (m_scenes)
429 { 395 {
430 foreach (Scene scene in m_scenes.Values) 396 foreach (Scene scene in m_scenes.Values)
@@ -438,7 +404,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
438 bool isChild = client.SceneAgent.IsChildAgent; 404 bool isChild = client.SceneAgent.IsChildAgent;
439 if (isChild && !showChildren) 405 if (isChild && !showChildren)
440 return; 406 return;
441 407
442 string name = client.Name; 408 string name = client.Name;
443 if (pname != "" && name != pname) 409 if (pname != "" && name != pname)
444 return; 410 return;
@@ -449,7 +415,7 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
449 report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); 415 report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding));
450 report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); 416 report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding));
451 417
452 IStatsCollector stats = (IStatsCollector)client; 418 IStatsCollector stats = (IStatsCollector)client;
453 report.AppendLine(stats.Report()); 419 report.AppendLine(stats.Report());
454 } 420 }
455 }); 421 });
@@ -457,8 +423,8 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
457 } 423 }
458 424
459 return report.ToString(); 425 return report.ToString();
460 } 426 }
461 427
462 /// <summary> 428 /// <summary>
463 /// Show throttle data 429 /// Show throttle data
464 /// </summary> 430 /// </summary>
@@ -468,28 +434,28 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
468 { 434 {
469 bool showChildren = false; 435 bool showChildren = false;
470 string pname = ""; 436 string pname = "";
471 437
472 if (showParams.Length > 2 && showParams[2] == "full") 438 if (showParams.Length > 2 && showParams[2] == "full")
473 showChildren = true; 439 showChildren = true;
474 else if (showParams.Length > 3) 440 else if (showParams.Length > 3)
475 pname = showParams[2] + " " + showParams[3]; 441 pname = showParams[2] + " " + showParams[3];
476 442
477 StringBuilder report = new StringBuilder(); 443 StringBuilder report = new StringBuilder();
478 444
479 int columnPadding = 2; 445 int columnPadding = 2;
480 int maxNameLength = 18; 446 int maxNameLength = 18;
481 int maxRegionNameLength = 14; 447 int maxRegionNameLength = 14;
482 int maxTypeLength = 4; 448 int maxTypeLength = 4;
483 int totalInfoFieldsLength = maxNameLength + columnPadding + maxRegionNameLength + columnPadding + maxTypeLength + columnPadding; 449 int totalInfoFieldsLength = maxNameLength + columnPadding + maxRegionNameLength + columnPadding + maxTypeLength + columnPadding;
484 450
485 report.Append(GetColumnEntry("User", maxNameLength, columnPadding)); 451 report.Append(GetColumnEntry("User", maxNameLength, columnPadding));
486 report.Append(GetColumnEntry("Region", maxRegionNameLength, columnPadding)); 452 report.Append(GetColumnEntry("Region", maxRegionNameLength, columnPadding));
487 report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding)); 453 report.Append(GetColumnEntry("Type", maxTypeLength, columnPadding));
488 454
489 report.AppendFormat( 455 report.AppendFormat(
490 "{0,8} {1,8} {2,7} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7}\n", 456 "{0,8} {1,8} {2,7} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7}\n",
491 "Max", 457 "Max",
492 "Target", 458 "Target",
493 "Actual", 459 "Actual",
494 "Resend", 460 "Resend",
495 "Land", 461 "Land",
@@ -497,8 +463,8 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
497 "Cloud", 463 "Cloud",
498 "Task", 464 "Task",
499 "Texture", 465 "Texture",
500 "Asset"); 466 "Asset");
501 467
502 report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", ""); 468 report.AppendFormat("{0,-" + totalInfoFieldsLength + "}", "");
503 report.AppendFormat( 469 report.AppendFormat(
504 "{0,8} {1,8} {2,7} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7}\n", 470 "{0,8} {1,8} {2,7} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7}\n",
@@ -511,10 +477,10 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
511 "kb/s", 477 "kb/s",
512 "kb/s", 478 "kb/s",
513 "kb/s", 479 "kb/s",
514 "kb/s"); 480 "kb/s");
515 481
516 report.AppendLine(); 482 report.AppendLine();
517 483
518 lock (m_scenes) 484 lock (m_scenes)
519 { 485 {
520 foreach (Scene scene in m_scenes.Values) 486 foreach (Scene scene in m_scenes.Values)
@@ -529,25 +495,25 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
529 bool isChild = client.SceneAgent.IsChildAgent; 495 bool isChild = client.SceneAgent.IsChildAgent;
530 if (isChild && !showChildren) 496 if (isChild && !showChildren)
531 return; 497 return;
532 498
533 string name = client.Name; 499 string name = client.Name;
534 if (pname != "" && name != pname) 500 if (pname != "" && name != pname)
535 return; 501 return;
536 502
537 string regionName = scene.RegionInfo.RegionName; 503 string regionName = scene.RegionInfo.RegionName;
538 504
539 LLUDPClient llUdpClient = llClient.UDPClient; 505 LLUDPClient llUdpClient = llClient.UDPClient;
540 ClientInfo ci = llUdpClient.GetClientInfo(); 506 ClientInfo ci = llUdpClient.GetClientInfo();
541 507
542 report.Append(GetColumnEntry(name, maxNameLength, columnPadding)); 508 report.Append(GetColumnEntry(name, maxNameLength, columnPadding));
543 report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding)); 509 report.Append(GetColumnEntry(regionName, maxRegionNameLength, columnPadding));
544 report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding)); 510 report.Append(GetColumnEntry(isChild ? "Cd" : "Rt", maxTypeLength, columnPadding));
545 511
546 report.AppendFormat( 512 report.AppendFormat(
547 "{0,8} {1,8} {2,7} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7}\n", 513 "{0,8} {1,8} {2,7} {3,8} {4,7} {5,7} {6,7} {7,7} {8,9} {9,7}\n",
548 ci.maxThrottle > 0 ? ((ci.maxThrottle * 8) / 1000).ToString() : "-", 514 ci.maxThrottle > 0 ? ((ci.maxThrottle * 8) / 1000).ToString() : "-",
549 llUdpClient.FlowThrottle.AdaptiveEnabled 515 llUdpClient.FlowThrottle.AdaptiveEnabled
550 ? ((ci.targetThrottle * 8) / 1000).ToString() 516 ? ((ci.targetThrottle * 8) / 1000).ToString()
551 : (llUdpClient.FlowThrottle.TotalDripRequest * 8 / 1000).ToString(), 517 : (llUdpClient.FlowThrottle.TotalDripRequest * 8 / 1000).ToString(),
552 (ci.totalThrottle * 8) / 1000, 518 (ci.totalThrottle * 8) / 1000,
553 (ci.resendThrottle * 8) / 1000, 519 (ci.resendThrottle * 8) / 1000,
@@ -563,107 +529,6 @@ namespace OpenSim.Region.OptionalModules.UDP.Linden
563 } 529 }
564 530
565 return report.ToString(); 531 return report.ToString();
566 }
567
568 /// <summary>
569 /// Show client stats data
570 /// </summary>
571 /// <param name="showParams"></param>
572 /// <returns></returns>
573 protected string HandleClientStatsReport(string[] showParams)
574 {
575 // NOTE: This writes to m_log on purpose. We want to store this information
576 // in case we need to analyze it later.
577 //
578 if (showParams.Length <= 4)
579 {
580 m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}", "Region", "Name", "Root", "Time", "Reqs/min", "AgentUpdates");
581 foreach (Scene scene in m_scenes.Values)
582 {
583 scene.ForEachClient(
584 delegate(IClientAPI client)
585 {
586 if (client is LLClientView)
587 {
588 LLClientView llClient = client as LLClientView;
589 ClientInfo cinfo = llClient.UDPClient.GetClientInfo();
590 int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum();
591 avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1);
592
593 string childAgentStatus;
594
595 if (llClient.SceneAgent != null)
596 childAgentStatus = llClient.SceneAgent.IsChildAgent ? "N" : "Y";
597 else
598 childAgentStatus = "Off!";
599
600 m_log.InfoFormat("[INFO]: {0,-12} {1,-20} {2,-6} {3,-11} {4,-11} {5,-16}",
601 scene.RegionInfo.RegionName, llClient.Name,
602 childAgentStatus,
603 (DateTime.Now - cinfo.StartedTime).Minutes,
604 avg_reqs,
605 string.Format(
606 "{0} ({1:0.00}%)",
607 llClient.TotalAgentUpdates,
608 cinfo.SyncRequests.ContainsKey("AgentUpdate")
609 ? (float)cinfo.SyncRequests["AgentUpdate"] / llClient.TotalAgentUpdates * 100
610 : 0));
611 }
612 });
613 }
614 return string.Empty;
615 }
616
617 string fname = "", lname = "";
618
619 if (showParams.Length > 3)
620 fname = showParams[3];
621 if (showParams.Length > 4)
622 lname = showParams[4];
623
624 foreach (Scene scene in m_scenes.Values)
625 {
626 scene.ForEachClient(
627 delegate(IClientAPI client)
628 {
629 if (client is LLClientView)
630 {
631 LLClientView llClient = client as LLClientView;
632
633 if (llClient.Name == fname + " " + lname)
634 {
635
636 ClientInfo cinfo = llClient.GetClientInfo();
637 AgentCircuitData aCircuit = scene.AuthenticateHandler.GetAgentCircuitData(llClient.CircuitCode);
638 if (aCircuit == null) // create a dummy one
639 aCircuit = new AgentCircuitData();
640
641 if (!llClient.SceneAgent.IsChildAgent)
642 m_log.InfoFormat("[INFO]: {0} # {1} # {2}", llClient.Name, Util.GetViewerName(aCircuit), aCircuit.Id0);
643
644 int avg_reqs = cinfo.AsyncRequests.Values.Sum() + cinfo.GenericRequests.Values.Sum() + cinfo.SyncRequests.Values.Sum();
645 avg_reqs = avg_reqs / ((DateTime.Now - cinfo.StartedTime).Minutes + 1);
646
647 m_log.InfoFormat("[INFO]:");
648 m_log.InfoFormat("[INFO]: {0} # {1} # Time: {2}min # Avg Reqs/min: {3}", scene.RegionInfo.RegionName,
649 (llClient.SceneAgent.IsChildAgent ? "Child" : "Root"), (DateTime.Now - cinfo.StartedTime).Minutes, avg_reqs);
650
651 Dictionary<string, int> sortedDict = (from entry in cinfo.AsyncRequests orderby entry.Value descending select entry)
652 .ToDictionary(pair => pair.Key, pair => pair.Value);
653 PrintRequests("TOP ASYNC", sortedDict, cinfo.AsyncRequests.Values.Sum());
654
655 sortedDict = (from entry in cinfo.SyncRequests orderby entry.Value descending select entry)
656 .ToDictionary(pair => pair.Key, pair => pair.Value);
657 PrintRequests("TOP SYNC", sortedDict, cinfo.SyncRequests.Values.Sum());
658
659 sortedDict = (from entry in cinfo.GenericRequests orderby entry.Value descending select entry)
660 .ToDictionary(pair => pair.Key, pair => pair.Value);
661 PrintRequests("TOP GENERIC", sortedDict, cinfo.GenericRequests.Values.Sum());
662 }
663 }
664 });
665 }
666 return string.Empty;
667 } 532 }
668 533
669 private void PrintRequests(string type, Dictionary<string, int> sortedDict, int sum) 534 private void PrintRequests(string type, Dictionary<string, int> sortedDict, int sum)
diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
index 7639c6c..906e1ee 100644
--- a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
@@ -50,36 +50,36 @@ namespace OpenSim.Region.OptionalModules.Asset
50// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
52 private Scene m_scene; 52 private Scene m_scene;
53 53
54 public string Name { get { return "Asset Information Module"; } } 54 public string Name { get { return "Asset Information Module"; } }
55 55
56 public Type ReplaceableInterface { get { return null; } } 56 public Type ReplaceableInterface { get { return null; } }
57 57
58 public void Initialise(IConfigSource source) 58 public void Initialise(IConfigSource source)
59 { 59 {
60// m_log.DebugFormat("[ASSET INFO MODULE]: INITIALIZED MODULE"); 60// m_log.DebugFormat("[ASSET INFO MODULE]: INITIALIZED MODULE");
61 } 61 }
62 62
63 public void PostInitialise() 63 public void PostInitialise()
64 { 64 {
65// m_log.DebugFormat("[ASSET INFO MODULE]: POST INITIALIZED MODULE"); 65// m_log.DebugFormat("[ASSET INFO MODULE]: POST INITIALIZED MODULE");
66 } 66 }
67 67
68 public void Close() 68 public void Close()
69 { 69 {
70// m_log.DebugFormat("[ASSET INFO MODULE]: CLOSED MODULE"); 70// m_log.DebugFormat("[ASSET INFO MODULE]: CLOSED MODULE");
71 } 71 }
72 72
73 public void AddRegion(Scene scene) 73 public void AddRegion(Scene scene)
74 { 74 {
75// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); 75// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
76 } 76 }
77 77
78 public void RemoveRegion(Scene scene) 78 public void RemoveRegion(Scene scene)
79 { 79 {
80// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); 80// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
81 } 81 }
82 82
83 public void RegionLoaded(Scene scene) 83 public void RegionLoaded(Scene scene)
84 { 84 {
85// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); 85// m_log.DebugFormat("[ASSET INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
@@ -118,27 +118,27 @@ namespace OpenSim.Region.OptionalModules.Asset
118 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId); 118 MainConsole.Instance.OutputFormat("ERROR: {0} is not a valid ID format", rawAssetId);
119 return; 119 return;
120 } 120 }
121 121
122 AssetBase asset = m_scene.AssetService.Get(assetId.ToString()); 122 AssetBase asset = m_scene.AssetService.Get(assetId.ToString());
123 if (asset == null) 123 if (asset == null)
124 { 124 {
125 MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId); 125 MainConsole.Instance.OutputFormat("ERROR: No asset found with ID {0}", assetId);
126 return; 126 return;
127 } 127 }
128 128
129 string fileName = rawAssetId; 129 string fileName = rawAssetId;
130 130
131 if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName)) 131 if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName))
132 return; 132 return;
133 133
134 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) 134 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
135 { 135 {
136 using (BinaryWriter bw = new BinaryWriter(fs)) 136 using (BinaryWriter bw = new BinaryWriter(fs))
137 { 137 {
138 bw.Write(asset.Data); 138 bw.Write(asset.Data);
139 } 139 }
140 } 140 }
141 141
142 MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName); 142 MainConsole.Instance.OutputFormat("Asset dumped to file {0}", fileName);
143 } 143 }
144 144
diff --git a/OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs b/OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs
index 84211a9..0698cec 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Animations/AnimationsCommandModule.cs
@@ -42,6 +42,7 @@ using OpenSim.Region.Framework.Interfaces;
42using OpenSim.Region.Framework.Scenes; 42using OpenSim.Region.Framework.Scenes;
43using OpenSim.Region.Framework.Scenes.Animation; 43using OpenSim.Region.Framework.Scenes.Animation;
44using OpenSim.Services.Interfaces; 44using OpenSim.Services.Interfaces;
45using AnimationSet = OpenSim.Region.Framework.Scenes.Animation.AnimationSet;
45 46
46namespace OpenSim.Region.OptionalModules.Avatar.Animations 47namespace OpenSim.Region.OptionalModules.Avatar.Animations
47{ 48{
@@ -56,41 +57,41 @@ namespace OpenSim.Region.OptionalModules.Avatar.Animations
56 private List<Scene> m_scenes = new List<Scene>(); 57 private List<Scene> m_scenes = new List<Scene>();
57 58
58 public string Name { get { return "Animations Command Module"; } } 59 public string Name { get { return "Animations Command Module"; } }
59 60
60 public Type ReplaceableInterface { get { return null; } } 61 public Type ReplaceableInterface { get { return null; } }
61 62
62 public void Initialise(IConfigSource source) 63 public void Initialise(IConfigSource source)
63 { 64 {
64// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: INITIALIZED MODULE"); 65// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: INITIALIZED MODULE");
65 } 66 }
66 67
67 public void PostInitialise() 68 public void PostInitialise()
68 { 69 {
69// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: POST INITIALIZED MODULE"); 70// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: POST INITIALIZED MODULE");
70 } 71 }
71 72
72 public void Close() 73 public void Close()
73 { 74 {
74// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: CLOSED MODULE"); 75// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: CLOSED MODULE");
75 } 76 }
76 77
77 public void AddRegion(Scene scene) 78 public void AddRegion(Scene scene)
78 { 79 {
79// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); 80// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
80 } 81 }
81 82
82 public void RemoveRegion(Scene scene) 83 public void RemoveRegion(Scene scene)
83 { 84 {
84// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); 85// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
85 86
86 lock (m_scenes) 87 lock (m_scenes)
87 m_scenes.Remove(scene); 88 m_scenes.Remove(scene);
88 } 89 }
89 90
90 public void RegionLoaded(Scene scene) 91 public void RegionLoaded(Scene scene)
91 { 92 {
92// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); 93// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
93 94
94 lock (m_scenes) 95 lock (m_scenes)
95 m_scenes.Add(scene); 96 m_scenes.Add(scene);
96 97
@@ -155,18 +156,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Animations
155 156
156 string cma = spa.CurrentMovementAnimation; 157 string cma = spa.CurrentMovementAnimation;
157 cdl.AddRow( 158 cdl.AddRow(
158 "Current movement anim", 159 "Current movement anim",
159 string.Format("{0}, {1}", DefaultAvatarAnimations.GetDefaultAnimation(cma), cma)); 160 string.Format("{0}, {1}", DefaultAvatarAnimations.GetDefaultAnimation(cma), cma));
160 161
161 UUID defaultAnimId = anims.DefaultAnimation.AnimID; 162 UUID defaultAnimId = anims.DefaultAnimation.AnimID;
162 cdl.AddRow( 163 cdl.AddRow(
163 "Default anim", 164 "Default anim",
164 string.Format("{0}, {1}", defaultAnimId, sp.Animator.GetAnimName(defaultAnimId))); 165 string.Format("{0}, {1}", defaultAnimId, sp.Animator.GetAnimName(defaultAnimId)));
165 166
166 UUID implicitDefaultAnimId = anims.ImplicitDefaultAnimation.AnimID; 167 UUID implicitDefaultAnimId = anims.ImplicitDefaultAnimation.AnimID;
167 cdl.AddRow( 168 cdl.AddRow(
168 "Implicit default anim", 169 "Implicit default anim",
169 string.Format("{0}, {1}", 170 string.Format("{0}, {1}",
170 implicitDefaultAnimId, sp.Animator.GetAnimName(implicitDefaultAnimId))); 171 implicitDefaultAnimId, sp.Animator.GetAnimName(implicitDefaultAnimId)));
171 172
172 cdl.AddToStringBuilder(sb); 173 cdl.AddToStringBuilder(sb);
@@ -197,4 +198,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.Animations
197 sb.Append("\n"); 198 sb.Append("\n");
198 } 199 }
199 } 200 }
200} \ No newline at end of file 201}
diff --git a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
index 2f9bb1e..60ae0cb 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Appearance/AppearanceInfoModule.cs
@@ -54,43 +54,43 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
54 private List<Scene> m_scenes = new List<Scene>(); 54 private List<Scene> m_scenes = new List<Scene>();
55 55
56// private IAvatarFactoryModule m_avatarFactory; 56// private IAvatarFactoryModule m_avatarFactory;
57 57
58 public string Name { get { return "Appearance Information Module"; } } 58 public string Name { get { return "Appearance Information Module"; } }
59 59
60 public Type ReplaceableInterface { get { return null; } } 60 public Type ReplaceableInterface { get { return null; } }
61 61
62 public void Initialise(IConfigSource source) 62 public void Initialise(IConfigSource source)
63 { 63 {
64// m_log.DebugFormat("[APPEARANCE INFO MODULE]: INITIALIZED MODULE"); 64// m_log.DebugFormat("[APPEARANCE INFO MODULE]: INITIALIZED MODULE");
65 } 65 }
66 66
67 public void PostInitialise() 67 public void PostInitialise()
68 { 68 {
69// m_log.DebugFormat("[APPEARANCE INFO MODULE]: POST INITIALIZED MODULE"); 69// m_log.DebugFormat("[APPEARANCE INFO MODULE]: POST INITIALIZED MODULE");
70 } 70 }
71 71
72 public void Close() 72 public void Close()
73 { 73 {
74// m_log.DebugFormat("[APPEARANCE INFO MODULE]: CLOSED MODULE"); 74// m_log.DebugFormat("[APPEARANCE INFO MODULE]: CLOSED MODULE");
75 } 75 }
76 76
77 public void AddRegion(Scene scene) 77 public void AddRegion(Scene scene)
78 { 78 {
79// m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); 79// m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
80 } 80 }
81 81
82 public void RemoveRegion(Scene scene) 82 public void RemoveRegion(Scene scene)
83 { 83 {
84// m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); 84// m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
85 85
86 lock (m_scenes) 86 lock (m_scenes)
87 m_scenes.Remove(scene); 87 m_scenes.Remove(scene);
88 } 88 }
89 89
90 public void RegionLoaded(Scene scene) 90 public void RegionLoaded(Scene scene)
91 { 91 {
92// m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); 92// m_log.DebugFormat("[APPEARANCE INFO MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
93 93
94 lock (m_scenes) 94 lock (m_scenes)
95 m_scenes.Add(scene); 95 m_scenes.Add(scene);
96 96
@@ -99,7 +99,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
99 "show appearance [<first-name> <last-name>]", 99 "show appearance [<first-name> <last-name>]",
100 "Synonym for 'appearance show'", 100 "Synonym for 'appearance show'",
101 HandleShowAppearanceCommand); 101 HandleShowAppearanceCommand);
102 102
103 scene.AddCommand( 103 scene.AddCommand(
104 "Users", this, "appearance show", 104 "Users", this, "appearance show",
105 "appearance show [<first-name> <last-name>]", 105 "appearance show [<first-name> <last-name>]",
@@ -222,7 +222,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
222 } 222 }
223 223
224 lock (m_scenes) 224 lock (m_scenes)
225 { 225 {
226 foreach (Scene scene in m_scenes) 226 foreach (Scene scene in m_scenes)
227 { 227 {
228 if (targetNameSupplied) 228 if (targetNameSupplied)
@@ -344,7 +344,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
344 344
345 if (targetNameSupplied) 345 if (targetNameSupplied)
346 { 346 {
347 lock (m_scenes) 347 lock (m_scenes)
348 { 348 {
349 foreach (Scene scene in m_scenes) 349 foreach (Scene scene in m_scenes)
350 { 350 {
@@ -360,12 +360,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
360 cdt.AddColumn("Name", ConsoleDisplayUtil.UserNameSize); 360 cdt.AddColumn("Name", ConsoleDisplayUtil.UserNameSize);
361 cdt.AddColumn("Wearables", 2); 361 cdt.AddColumn("Wearables", 2);
362 362
363 lock (m_scenes) 363 lock (m_scenes)
364 { 364 {
365 foreach (Scene scene in m_scenes) 365 foreach (Scene scene in m_scenes)
366 { 366 {
367 scene.ForEachRootScenePresence( 367 scene.ForEachRootScenePresence(
368 sp => 368 sp =>
369 { 369 {
370 int count = 0; 370 int count = 0;
371 371
@@ -428,7 +428,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
428 428
429 uuidGatherer.AddForInspection(wi.AssetID); 429 uuidGatherer.AddForInspection(wi.AssetID);
430 uuidGatherer.GatherAll(); 430 uuidGatherer.GatherAll();
431 string[] assetStrings 431 string[] assetStrings
432 = Array.ConvertAll<UUID, string>(uuidGatherer.GatheredUuids.Keys.ToArray(), u => u.ToString()); 432 = Array.ConvertAll<UUID, string>(uuidGatherer.GatheredUuids.Keys.ToArray(), u => u.ToString());
433 433
434 bool[] existChecks = scene.AssetService.AssetsExist(assetStrings); 434 bool[] existChecks = scene.AssetService.AssetsExist(assetStrings);
@@ -438,10 +438,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Appearance
438 cdt.AddColumn("Type", 10); 438 cdt.AddColumn("Type", 10);
439 cdt.AddColumn("UUID", ConsoleDisplayUtil.UuidSize); 439 cdt.AddColumn("UUID", ConsoleDisplayUtil.UuidSize);
440 cdt.AddColumn("Found", 5); 440 cdt.AddColumn("Found", 5);
441 441
442 for (int k = 0; k < existChecks.Length; k++) 442 for (int k = 0; k < existChecks.Length; k++)
443 cdt.AddRow( 443 cdt.AddRow(
444 (AssetType)uuidGatherer.GatheredUuids[new UUID(assetStrings[k])], 444 (AssetType)uuidGatherer.GatheredUuids[new UUID(assetStrings[k])],
445 assetStrings[k], existChecks[k] ? "yes" : "no"); 445 assetStrings[k], existChecks[k] ? "yes" : "no");
446 446
447 sb.Append(cdt.ToString()); 447 sb.Append(cdt.ToString());
diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs
index 0333747..3685041 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs
@@ -55,41 +55,41 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
55// private IAvatarFactoryModule m_avatarFactory; 55// private IAvatarFactoryModule m_avatarFactory;
56 56
57 public string Name { get { return "Attachments Command Module"; } } 57 public string Name { get { return "Attachments Command Module"; } }
58 58
59 public Type ReplaceableInterface { get { return null; } } 59 public Type ReplaceableInterface { get { return null; } }
60 60
61 public void Initialise(IConfigSource source) 61 public void Initialise(IConfigSource source)
62 { 62 {
63// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: INITIALIZED MODULE"); 63// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: INITIALIZED MODULE");
64 } 64 }
65 65
66 public void PostInitialise() 66 public void PostInitialise()
67 { 67 {
68// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: POST INITIALIZED MODULE"); 68// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: POST INITIALIZED MODULE");
69 } 69 }
70 70
71 public void Close() 71 public void Close()
72 { 72 {
73// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: CLOSED MODULE"); 73// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: CLOSED MODULE");
74 } 74 }
75 75
76 public void AddRegion(Scene scene) 76 public void AddRegion(Scene scene)
77 { 77 {
78// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); 78// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
79 } 79 }
80 80
81 public void RemoveRegion(Scene scene) 81 public void RemoveRegion(Scene scene)
82 { 82 {
83// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); 83// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
84 84
85 lock (m_scenes) 85 lock (m_scenes)
86 m_scenes.Remove(scene); 86 m_scenes.Remove(scene);
87 } 87 }
88 88
89 public void RegionLoaded(Scene scene) 89 public void RegionLoaded(Scene scene)
90 { 90 {
91// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); 91// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
92 92
93 lock (m_scenes) 93 lock (m_scenes)
94 m_scenes.Add(scene); 94 m_scenes.Add(scene);
95 95
@@ -144,14 +144,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
144 144
145 private void GetAttachmentsReport(ScenePresence sp, StringBuilder sb) 145 private void GetAttachmentsReport(ScenePresence sp, StringBuilder sb)
146 { 146 {
147 sb.AppendFormat("Attachments for {0}\n", sp.Name); 147 sb.AppendFormat("Attachments for {0}\n\n", sp.Name);
148 148
149 ConsoleDisplayTable ct = new ConsoleDisplayTable() { Indent = 2 }; 149 ConsoleDisplayList ct = new ConsoleDisplayList();
150 ct.Columns.Add(new ConsoleDisplayTableColumn("Attachment Name", 50));
151 ct.Columns.Add(new ConsoleDisplayTableColumn("Local ID", 10));
152 ct.Columns.Add(new ConsoleDisplayTableColumn("Item ID", 36));
153 ct.Columns.Add(new ConsoleDisplayTableColumn("Attach Point", 14));
154 ct.Columns.Add(new ConsoleDisplayTableColumn("Position", 15));
155 150
156// sb.AppendFormat( 151// sb.AppendFormat(
157// " {0,-36} {1,-10} {2,-36} {3,-14} {4,-15}\n", 152// " {0,-36} {1,-10} {2,-36} {3,-14} {4,-15}\n",
@@ -177,17 +172,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
177// attachmentObject.Name, attachmentObject.LocalId, attachmentObject.FromItemID, 172// attachmentObject.Name, attachmentObject.LocalId, attachmentObject.FromItemID,
178// (AttachmentPoint)attachmentObject.AttachmentPoint, attachmentObject.RootPart.AttachedPos); 173// (AttachmentPoint)attachmentObject.AttachmentPoint, attachmentObject.RootPart.AttachedPos);
179 174
180 ct.AddRow( 175 ct.Indent = 2;
181 attachmentObject.Name, 176 ct.AddRow("Attachment Name", attachmentObject.Name);
182 attachmentObject.LocalId, 177 ct.AddRow("Local ID", attachmentObject.LocalId);
183 attachmentObject.FromItemID, 178 ct.AddRow("Item ID", attachmentObject.UUID);
184 ((AttachmentPoint)attachmentObject.AttachmentPoint), 179 ct.AddRow("From Item ID", attachmentObject.FromItemID);
185 attachmentObject.RootPart.AttachedPos); 180 ct.AddRow("Attach Point", ((AttachmentPoint)attachmentObject.AttachmentPoint));
181 ct.AddRow("Position", attachmentObject.RootPart.AttachedPos + "\n\n");
186// } 182// }
187 } 183 }
188 184
189 ct.AddToStringBuilder(sb); 185 ct.AddToStringBuilder(sb);
190 sb.Append("\n");
191 } 186 }
192 } 187 }
193} \ No newline at end of file 188} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
index 535bf67..c3f3851 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
@@ -125,7 +125,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
125 SendConsoleOutput(agentID, "Command parameter error"); 125 SendConsoleOutput(agentID, "Command parameter error");
126 return; 126 return;
127 } 127 }
128 128
129 m_scene.StoreExtraSetting("auto_grant_attach_perms", val); 129 m_scene.StoreExtraSetting("auto_grant_attach_perms", val);
130 130
131 SendConsoleOutput(agentID, String.Format("auto_grant_attach_perms set to {0}", val)); 131 SendConsoleOutput(agentID, String.Format("auto_grant_attach_perms set to {0}", val));
@@ -134,11 +134,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
134 private int llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint) 134 private int llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint)
135 { 135 {
136 SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host); 136 SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host);
137
138 if (hostPart == null) 137 if (hostPart == null)
139 return 0; 138 return 0;
140 139
141 if (hostPart.ParentGroup.IsAttachment) 140 SceneObjectGroup hostgroup = hostPart.ParentGroup;
141
142 if (hostgroup== null || hostgroup.IsAttachment)
142 return 0; 143 return 0;
143 144
144 IAttachmentsModule attachmentsModule = m_scene.RequestModuleInterface<IAttachmentsModule>(); 145 IAttachmentsModule attachmentsModule = m_scene.RequestModuleInterface<IAttachmentsModule>();
@@ -155,33 +156,33 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
155 ScenePresence target; 156 ScenePresence target;
156 if (!m_scene.TryGetScenePresence(item.PermsGranter, out target)) 157 if (!m_scene.TryGetScenePresence(item.PermsGranter, out target))
157 return 0; 158 return 0;
158 159
159 if (target.UUID != hostPart.ParentGroup.OwnerID) 160 if (target.UUID != hostgroup.OwnerID)
160 { 161 {
161 uint effectivePerms = hostPart.ParentGroup.GetEffectivePermissions(); 162 uint effectivePerms = hostgroup.EffectiveOwnerPerms;
162 163
163 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) 164 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
164 return 0; 165 return 0;
165 166
166 hostPart.ParentGroup.SetOwnerId(target.UUID); 167 hostgroup.SetOwner(target.UUID, target.ControllingClient.ActiveGroupId);
167 hostPart.ParentGroup.SetRootPartOwner(hostPart.ParentGroup.RootPart, target.UUID, target.ControllingClient.ActiveGroupId);
168 168
169 if (m_scene.Permissions.PropagatePermissions()) 169 if (m_scene.Permissions.PropagatePermissions())
170 { 170 {
171 foreach (SceneObjectPart child in hostPart.ParentGroup.Parts) 171 foreach (SceneObjectPart child in hostgroup.Parts)
172 { 172 {
173 child.Inventory.ChangeInventoryOwner(target.UUID); 173 child.Inventory.ChangeInventoryOwner(target.UUID);
174 child.TriggerScriptChangedEvent(Changed.OWNER); 174 child.TriggerScriptChangedEvent(Changed.OWNER);
175 child.ApplyNextOwnerPermissions(); 175 child.ApplyNextOwnerPermissions();
176 } 176 }
177 hostgroup.InvalidateEffectivePerms();
177 } 178 }
178 179
179 hostPart.ParentGroup.RootPart.ObjectSaleType = 0; 180 hostgroup.RootPart.ObjectSaleType = 0;
180 hostPart.ParentGroup.RootPart.SalePrice = 10; 181 hostgroup.RootPart.SalePrice = 10;
181 182
182 hostPart.ParentGroup.HasGroupChanged = true; 183 hostgroup.HasGroupChanged = true;
183 hostPart.ParentGroup.RootPart.SendPropertiesToClient(target.ControllingClient); 184 hostgroup.RootPart.SendPropertiesToClient(target.ControllingClient);
184 hostPart.ParentGroup.RootPart.ScheduleFullUpdate(); 185 hostgroup.RootPart.ScheduleFullUpdate();
185 } 186 }
186 187
187 return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, false, true) ? 1 : 0; 188 return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, false, true) ? 1 : 0;
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs
index b5d9fda..27ab32f 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/ChannelState.cs
@@ -38,7 +38,7 @@ using OpenSim.Region.Framework.Scenes;
38namespace OpenSim.Region.OptionalModules.Avatar.Chat 38namespace OpenSim.Region.OptionalModules.Avatar.Chat
39{ 39{
40 40
41 // An instance of this class exists for each unique combination of 41 // An instance of this class exists for each unique combination of
42 // IRC chat interface characteristics, as determined by the supplied 42 // IRC chat interface characteristics, as determined by the supplied
43 // configuration file. 43 // configuration file.
44 44
@@ -48,7 +48,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
48 private static readonly ILog m_log = 48 private static readonly ILog m_log =
49 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
50 50
51 private static Regex arg = new Regex(@"\[[^\[\]]*\]"); 51 private static Regex arg = new Regex(@"(?<!\\)\[[^\[\]]*(?<!\\)\]");
52 private static int _idk_ = 0; 52 private static int _idk_ = 0;
53 private static int DEBUG_CHANNEL = 2147483647; 53 private static int DEBUG_CHANNEL = 2147483647;
54 54
@@ -266,11 +266,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
266 ChannelState cs = p_cs; 266 ChannelState cs = p_cs;
267 267
268 // Check to see if we have an existing server/channel setup that can be used 268 // Check to see if we have an existing server/channel setup that can be used
269 // In the absence of variable substitution this will always resolve to the 269 // In the absence of variable substitution this will always resolve to the
270 // same ChannelState instance, and the table will only contains a single 270 // same ChannelState instance, and the table will only contains a single
271 // entry, so the performance considerations for the existing behavior are 271 // entry, so the performance considerations for the existing behavior are
272 // zero. Only the IRC connector is shared, the ChannelState still contains 272 // zero. Only the IRC connector is shared, the ChannelState still contains
273 // values that, while independent of the IRC connetion, do still distinguish 273 // values that, while independent of the IRC connetion, do still distinguish
274 // this region's behavior. 274 // this region's behavior.
275 275
276 lock (IRCBridgeModule.m_channels) 276 lock (IRCBridgeModule.m_channels)
@@ -335,7 +335,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
335 335
336 } 336 }
337 337
338 // These routines allow differentiating changes to 338 // These routines allow differentiating changes to
339 // the underlying channel state. If necessary, a 339 // the underlying channel state. If necessary, a
340 // new channel state will be created. 340 // new channel state will be created.
341 341
@@ -426,7 +426,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
426 } 426 }
427 427
428 // This level of obsessive matching allows us to produce 428 // This level of obsessive matching allows us to produce
429 // a minimal overhead int he case of a server which does 429 // a minimal overhead int he case of a server which does
430 // need to differentiate IRC at a region level. 430 // need to differentiate IRC at a region level.
431 431
432 private bool IsAPerfectMatchFor(ChannelState cs) 432 private bool IsAPerfectMatchFor(ChannelState cs)
@@ -447,8 +447,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
447 ); 447 );
448 } 448 }
449 449
450 // This function implements the variable substitution mechanism 450 // This function implements the variable substitution mechanism
451 // for the configuration values. Each string read from the 451 // for the configuration values. Each string read from the
452 // configuration file is scanned for '[...]' enclosures. Each 452 // configuration file is scanned for '[...]' enclosures. Each
453 // one that is found is replaced by either a runtime variable 453 // one that is found is replaced by either a runtime variable
454 // (%xxx) or an existing configuration key. When no further 454 // (%xxx) or an existing configuration key. When no further
@@ -499,6 +499,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
499 // m_log.DebugFormat("[IRC-Channel] Parse[2]: {0}", result); 499 // m_log.DebugFormat("[IRC-Channel] Parse[2]: {0}", result);
500 } 500 }
501 501
502 // Now we unescape the literal brackets
503 result = result.Replace(@"\[","[").Replace(@"\]","]");
504
502 // m_log.DebugFormat("[IRC-Channel] Parse[3]: {0}", result); 505 // m_log.DebugFormat("[IRC-Channel] Parse[3]: {0}", result);
503 return result; 506 return result;
504 507
@@ -582,7 +585,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
582 585
583 } 586 }
584 587
585 // This function is lifted from the IRCConnector because it 588 // This function is lifted from the IRCConnector because it
586 // contains information that is not differentiating from an 589 // contains information that is not differentiating from an
587 // IRC point-of-view. 590 // IRC point-of-view.
588 591
@@ -595,7 +598,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
595 { 598 {
596 599
597 // Scan through the set of unique channel configuration for those 600 // Scan through the set of unique channel configuration for those
598 // that belong to this connector. And then forward the message to 601 // that belong to this connector. And then forward the message to
599 // all regions known to those channels. 602 // all regions known to those channels.
600 // Note that this code is responsible for completing some of the 603 // Note that this code is responsible for completing some of the
601 // settings for the inbound OSChatMessage 604 // settings for the inbound OSChatMessage
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
index 351dbfe..d6b6642 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
@@ -79,6 +79,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
79 if (!m_config.GetBoolean("enabled", false)) 79 if (!m_config.GetBoolean("enabled", false))
80 { 80 {
81 // m_log.InfoFormat("[IRC-Bridge] module disabled in configuration"); 81 // m_log.InfoFormat("[IRC-Bridge] module disabled in configuration");
82 m_config = null;
82 return; 83 return;
83 } 84 }
84 85
@@ -104,7 +105,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
104 MainServer.Instance.AddXmlRPCHandler("irc_admin", XmlRpcAdminMethod, false); 105 MainServer.Instance.AddXmlRPCHandler("irc_admin", XmlRpcAdminMethod, false);
105 106
106 m_region = new RegionState(scene, m_config); 107 m_region = new RegionState(scene, m_config);
107 lock (m_regions) m_regions.Add(m_region); 108 lock (m_regions)
109 m_regions.Add(m_region);
108 m_region.Open(); 110 m_region.Open();
109 } 111 }
110 catch (Exception e) 112 catch (Exception e)
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
index 6985371..ffbebe7 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
@@ -97,14 +97,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
97 97
98 // How many regions depend upon this connection 98 // How many regions depend upon this connection
99 // This count is updated by the ChannelState object and reflects the sum 99 // This count is updated by the ChannelState object and reflects the sum
100 // of the region clients associated with the set of associated channel 100 // of the region clients associated with the set of associated channel
101 // state instances. That's why it cannot be managed here. 101 // state instances. That's why it cannot be managed here.
102 102
103 internal int depends = 0; 103 internal int depends = 0;
104 104
105 // This variable counts the number of resets that have been performed 105 // This variable counts the number of resets that have been performed
106 // on the connector. When a listener thread terminates, it checks to 106 // on the connector. When a listener thread terminates, it checks to
107 // see of the reset count has changed before it schedules another 107 // see of the reset count has changed before it schedules another
108 // reset. 108 // reset.
109 109
110 internal int m_resetk = 0; 110 internal int m_resetk = 0;
@@ -270,7 +270,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
270 270
271 public void Close() 271 public void Close()
272 { 272 {
273
274 m_log.InfoFormat("[IRC-Connector-{0}] Closing", idn); 273 m_log.InfoFormat("[IRC-Connector-{0}] Closing", idn);
275 274
276 lock (msyncConnect) 275 lock (msyncConnect)
@@ -295,7 +294,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
295 } 294 }
296 catch (Exception) { } 295 catch (Exception) { }
297 296
298
299 m_connected = false; 297 m_connected = false;
300 298
301 try { m_writer.Close(); } 299 try { m_writer.Close(); }
@@ -308,10 +306,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
308 catch (Exception) { } 306 catch (Exception) { }
309 307
310 } 308 }
311
312 lock (m_connectors) 309 lock (m_connectors)
313 m_connectors.Remove(this); 310 m_connectors.Remove(this);
314
315 } 311 }
316 } 312 }
317 313
@@ -327,25 +323,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
327 323
328 public void Connect() 324 public void Connect()
329 { 325 {
330
331 if (!m_enabled) 326 if (!m_enabled)
332 return; 327 return;
333 328
334 // Delay until next WD cycle if this is too close to the last start attempt 329 // Delay until next WD cycle if this is too close to the last start attempt
335 330 if(_icc_ < ICCD_PERIOD)
336 while (_icc_ < ICCD_PERIOD)
337 return; 331 return;
338 332
339 m_log.DebugFormat("[IRC-Connector-{0}]: Connection request for {1} on {2}:{3}", idn, m_nick, m_server, m_ircChannel); 333 m_log.DebugFormat("[IRC-Connector-{0}]: Connection request for {1} on {2}:{3}", idn, m_nick, m_server, m_ircChannel);
340 334
335 _icc_ = 0;
336
341 lock (msyncConnect) 337 lock (msyncConnect)
342 { 338 {
343
344 _icc_ = 0;
345
346 try 339 try
347 { 340 {
348
349 if (m_connected) return; 341 if (m_connected) return;
350 342
351 m_connected = true; 343 m_connected = true;
@@ -368,11 +360,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
368 m_writer.Flush(); 360 m_writer.Flush();
369 m_writer.WriteLine(m_user); 361 m_writer.WriteLine(m_user);
370 m_writer.Flush(); 362 m_writer.Flush();
371 m_writer.WriteLine(String.Format("JOIN {0}", m_ircChannel));
372 m_writer.Flush();
373
374 m_log.InfoFormat("[IRC-Connector-{0}]: {1} has asked to join {2}", idn, m_nick, m_ircChannel);
375
376 } 363 }
377 catch (Exception e) 364 catch (Exception e)
378 { 365 {
@@ -384,11 +371,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
384 // expires. By leaving them as they are, the connection will be retried 371 // expires. By leaving them as they are, the connection will be retried
385 // when the login timeout expires. Which is preferred. 372 // when the login timeout expires. Which is preferred.
386 } 373 }
387
388 } 374 }
389 375
390 return; 376 return;
391
392 } 377 }
393 378
394 // Reconnect is used to force a re-cycle of the IRC connection. Should generally 379 // Reconnect is used to force a re-cycle of the IRC connection. Should generally
@@ -443,7 +428,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
443 public void PrivMsg(string pattern, string from, string region, string msg) 428 public void PrivMsg(string pattern, string from, string region, string msg)
444 { 429 {
445 430
446 // m_log.DebugFormat("[IRC-Connector-{0}] PrivMsg to IRC from {1}: <{2}>", idn, from, 431 // m_log.DebugFormat("[IRC-Connector-{0}] PrivMsg to IRC from {1}: <{2}>", idn, from,
447 // String.Format(pattern, m_ircChannel, from, region, msg)); 432 // String.Format(pattern, m_ircChannel, from, region, msg));
448 433
449 // One message to the IRC server 434 // One message to the IRC server
@@ -521,11 +506,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
521 c.Message = data["msg"]; 506 c.Message = data["msg"];
522 c.Type = ChatTypeEnum.Region; 507 c.Type = ChatTypeEnum.Region;
523 c.Position = CenterOfRegion; 508 c.Position = CenterOfRegion;
524 c.From = data["nick"]; 509 c.From = data["nick"] + "@IRC";
525 c.Sender = null; 510 c.Sender = null;
526 c.SenderUUID = UUID.Zero; 511 c.SenderUUID = UUID.Zero;
527 512
528 // Is message "\001ACTION foo bar\001"? 513 // Is message "\001ACTION foo bar\001"?
529 // Then change to: "/me foo bar" 514 // Then change to: "/me foo bar"
530 515
531 if ((1 == c.Message[0]) && c.Message.Substring(1).StartsWith("ACTION")) 516 if ((1 == c.Message[0]) && c.Message.Substring(1).StartsWith("ACTION"))
@@ -623,8 +608,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
623 string parms = String.Empty; 608 string parms = String.Empty;
624 609
625 // ":" indicates that a prefix is present 610 // ":" indicates that a prefix is present
626 // There are NEVER more than 17 real 611 // There are NEVER more than 17 real
627 // fields. A parameter that starts with 612 // fields. A parameter that starts with
628 // ":" indicates that the remainder of the 613 // ":" indicates that the remainder of the
629 // line is a single parameter value. 614 // line is a single parameter value.
630 615
@@ -659,6 +644,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
659 version = commArgs[2]; 644 version = commArgs[2];
660 usermod = commArgs[3]; 645 usermod = commArgs[3];
661 chanmod = commArgs[4]; 646 chanmod = commArgs[4];
647
648 m_writer.WriteLine(String.Format("JOIN {0}", m_ircChannel));
649 m_writer.Flush();
650 m_log.InfoFormat("[IRC-Connector-{0}]: sent request to join {1} ", idn, m_ircChannel);
651
662 break; 652 break;
663 case "005": // Server information 653 case "005": // Server information
664 break; 654 break;
@@ -721,11 +711,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
721 case "PONG": 711 case "PONG":
722 break; 712 break;
723 case "JOIN": 713 case "JOIN":
724 if (m_pending) 714
725 {
726 m_log.InfoFormat("[IRC-Connector-{0}] [{1}] Connected", idn, cmd);
727 m_pending = false;
728 }
729 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms); 715 m_log.DebugFormat("[IRC-Connector-{0}] [{1}] parms = <{2}>", idn, cmd, parms);
730 eventIrcJoin(pfx, cmd, parms); 716 eventIrcJoin(pfx, cmd, parms);
731 break; 717 break;
@@ -767,7 +753,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
767 if (IrcChannel.StartsWith(":")) 753 if (IrcChannel.StartsWith(":"))
768 IrcChannel = IrcChannel.Substring(1); 754 IrcChannel = IrcChannel.Substring(1);
769 755
770 m_log.DebugFormat("[IRC-Connector-{0}] Event: IRCJoin {1}:{2}", idn, m_server, m_ircChannel); 756 if(IrcChannel == m_ircChannel)
757 {
758 m_log.InfoFormat("[IRC-Connector-{0}] Joined requested channel {1} at {2}", idn, IrcChannel,m_server);
759 m_pending = false;
760 }
761 else
762 m_log.InfoFormat("[IRC-Connector-{0}] Joined unknown channel {1} at {2}", idn, IrcChannel,m_server);
771 BroadcastSim(IrcUser, "/me joins {0}", IrcChannel); 763 BroadcastSim(IrcUser, "/me joins {0}", IrcChannel);
772 } 764 }
773 765
@@ -881,7 +873,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
881 } 873 }
882 874
883 // Being marked connected is not enough to ping. Socket establishment can sometimes take a long 875 // Being marked connected is not enough to ping. Socket establishment can sometimes take a long
884 // time, in which case the watch dog might try to ping the server before the socket has been 876 // time, in which case the watch dog might try to ping the server before the socket has been
885 // set up, with nasty side-effects. 877 // set up, with nasty side-effects.
886 878
887 else if (_pdk_ == 0) 879 else if (_pdk_ == 0)
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs
index 6ea542c..a3ef83b 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/RegionState.cs
@@ -389,39 +389,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
389 } 389 }
390 390
391 m_log.DebugFormat("[IRC-Region {0}] heard on channel {1} : {2}", Region, msg.Channel, msg.Message); 391 m_log.DebugFormat("[IRC-Region {0}] heard on channel {1} : {2}", Region, msg.Channel, msg.Message);
392 string txt = msg.Message;
393 392
394 if (null != avatar) 393 if (null != avatar && cs.RelayChat && (msg.Channel == 0 || msg.Channel == DEBUG_CHANNEL))
395 { 394 {
396 if ((!cs.RelayChat) || (msg.Channel != 0 && msg.Channel != DEBUG_CHANNEL)) 395 string txt = msg.Message;
397 return; 396 if (txt.StartsWith("/me "))
397 txt = String.Format("{0} {1}", fromName, msg.Message.Substring(4));
398
399 cs.irc.PrivMsg(cs.PrivateMessageFormat, fromName, Region, txt);
400 return;
398 } 401 }
399 else 402
403 if (null == avatar && cs.RelayPrivateChannels && null != cs.AccessPassword &&
404 msg.Channel == cs.RelayChannelOut)
400 { 405 {
401 if (cs.RelayPrivateChannels && msg.Channel == cs.RelayChannelOut) 406 Match m = cs.AccessPasswordRegex.Match(msg.Message);
407 if (null != m)
402 { 408 {
403 if (null != cs.AccessPassword) 409 m_log.DebugFormat("[IRC] relaying message from {0}: {1}", m.Groups["avatar"].ToString(),
404 { 410 m.Groups["message"].ToString());
405 Match m = cs.AccessPasswordRegex.Match(msg.Message); 411 cs.irc.PrivMsg(cs.PrivateMessageFormat, m.Groups["avatar"].ToString(),
406 if (null != m) 412 scene.RegionInfo.RegionName, m.Groups["message"].ToString());
407 {
408 if (m.Groups["avatar"].ToString() != "")
409 fromName = m.Groups["avatar"].ToString();
410 if (m.Groups["message"].ToString() != "")
411 txt = m.Groups["message"].ToString();
412 }
413 }
414 } 413 }
415 fromName = "OBJECT: " + fromName;
416 } 414 }
417
418 if (txt.StartsWith("/me "))
419 txt = String.Format("{0} {1}", fromName, msg.Message.Substring(4));
420 m_log.DebugFormat("[IRC] relaying message from {0}: {1}", fromName, txt);
421 cs.irc.PrivMsg(cs.PrivateMessageFormat, fromName, Region, txt);
422 } 415 }
423 416
424 // This method gives the region an opportunity to interfere with 417 // This method gives the region an opportunity to interfere with
425 // message delivery. For now we just enforce the enable/disable 418 // message delivery. For now we just enforce the enable/disable
426 // flag. 419 // flag.
427 420
@@ -435,7 +428,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
435 } 428 }
436 } 429 }
437 430
438 // This supports any local message traffic that might be needed in 431 // This supports any local message traffic that might be needed in
439 // support of command processing. At present there is none. 432 // support of command processing. At present there is none.
440 433
441 internal void LocalChat(string msg) 434 internal void LocalChat(string msg)
diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
index c48e585..a5dc0ad 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
@@ -53,15 +53,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 55
56 private const int DEBUG_CHANNEL = 2147483647; 56// private const int DEBUG_CHANNEL = 2147483647; use base value
57 57
58 private List<IScene> m_scenes = new List<IScene>(); 58 private new List<IScene> m_scenes = new List<IScene>();
59 private List<IScene> m_conciergedScenes = new List<IScene>(); 59 private List<IScene> m_conciergedScenes = new List<IScene>();
60 60
61 private bool m_replacingChatModule = false; 61 private bool m_replacingChatModule = false;
62 62
63 private IConfig m_config;
64
65 private string m_whoami = "conferencier"; 63 private string m_whoami = "conferencier";
66 private Regex m_regions = null; 64 private Regex m_regions = null;
67 private string m_welcomes = null; 65 private string m_welcomes = null;
@@ -72,63 +70,62 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
72 private string m_brokerURI = String.Empty; 70 private string m_brokerURI = String.Empty;
73 private int m_brokerUpdateTimeout = 300; 71 private int m_brokerUpdateTimeout = 300;
74 72
75 internal object m_syncy = new object(); 73 internal new object m_syncy = new object();
76 74
77 internal bool m_enabled = false; 75 internal new bool m_enabled = false;
78 76
79 #region ISharedRegionModule Members 77 #region ISharedRegionModule Members
80 public override void Initialise(IConfigSource config) 78 public override void Initialise(IConfigSource configSource)
81 { 79 {
82 m_config = config.Configs["Concierge"]; 80 IConfig config = configSource.Configs["Concierge"];
83 81
84 if (null == m_config) 82 if (config == null)
85 return; 83 return;
86 84
87 if (!m_config.GetBoolean("enabled", false)) 85 if (!config.GetBoolean("enabled", false))
88 return; 86 return;
89 87
90 m_enabled = true; 88 m_enabled = true;
91 89
92
93 // check whether ChatModule has been disabled: if yes, 90 // check whether ChatModule has been disabled: if yes,
94 // then we'll "stand in" 91 // then we'll "stand in"
95 try 92 try
96 { 93 {
97 if (config.Configs["Chat"] == null) 94 if (configSource.Configs["Chat"] == null)
98 { 95 {
99 // if Chat module has not been configured it's 96 // if Chat module has not been configured it's
100 // enabled by default, so we are not going to 97 // enabled by default, so we are not going to
101 // replace it. 98 // replace it.
102 m_replacingChatModule = false; 99 m_replacingChatModule = false;
103 } 100 }
104 else 101 else
105 { 102 {
106 m_replacingChatModule = !config.Configs["Chat"].GetBoolean("enabled", true); 103 m_replacingChatModule = !configSource.Configs["Chat"].GetBoolean("enabled", true);
107 } 104 }
108 } 105 }
109 catch (Exception) 106 catch (Exception)
110 { 107 {
111 m_replacingChatModule = false; 108 m_replacingChatModule = false;
112 } 109 }
113 110
114 m_log.InfoFormat("[Concierge] {0} ChatModule", m_replacingChatModule ? "replacing" : "not replacing"); 111 m_log.InfoFormat("[Concierge] {0} ChatModule", m_replacingChatModule ? "replacing" : "not replacing");
115 112
116 // take note of concierge channel and of identity 113 // take note of concierge channel and of identity
117 m_conciergeChannel = config.Configs["Concierge"].GetInt("concierge_channel", m_conciergeChannel); 114 m_conciergeChannel = configSource.Configs["Concierge"].GetInt("concierge_channel", m_conciergeChannel);
118 m_whoami = m_config.GetString("whoami", "conferencier"); 115 m_whoami = config.GetString("whoami", "conferencier");
119 m_welcomes = m_config.GetString("welcomes", m_welcomes); 116 m_welcomes = config.GetString("welcomes", m_welcomes);
120 m_announceEntering = m_config.GetString("announce_entering", m_announceEntering); 117 m_announceEntering = config.GetString("announce_entering", m_announceEntering);
121 m_announceLeaving = m_config.GetString("announce_leaving", m_announceLeaving); 118 m_announceLeaving = config.GetString("announce_leaving", m_announceLeaving);
122 m_xmlRpcPassword = m_config.GetString("password", m_xmlRpcPassword); 119 m_xmlRpcPassword = config.GetString("password", m_xmlRpcPassword);
123 m_brokerURI = m_config.GetString("broker", m_brokerURI); 120 m_brokerURI = config.GetString("broker", m_brokerURI);
124 m_brokerUpdateTimeout = m_config.GetInt("broker_timeout", m_brokerUpdateTimeout); 121 m_brokerUpdateTimeout = config.GetInt("broker_timeout", m_brokerUpdateTimeout);
125 122
126 m_log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", m_whoami); 123 m_log.InfoFormat("[Concierge] reporting as \"{0}\" to our users", m_whoami);
127 124
128 // calculate regions Regex 125 // calculate regions Regex
129 if (m_regions == null) 126 if (m_regions == null)
130 { 127 {
131 string regions = m_config.GetString("regions", String.Empty); 128 string regions = config.GetString("regions", String.Empty);
132 if (!String.IsNullOrEmpty(regions)) 129 if (!String.IsNullOrEmpty(regions))
133 { 130 {
134 m_regions = new Regex(@regions, RegexOptions.Compiled | RegexOptions.IgnoreCase); 131 m_regions = new Regex(@regions, RegexOptions.Compiled | RegexOptions.IgnoreCase);
@@ -136,7 +133,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
136 } 133 }
137 } 134 }
138 135
139
140 public override void AddRegion(Scene scene) 136 public override void AddRegion(Scene scene)
141 { 137 {
142 if (!m_enabled) return; 138 if (!m_enabled) return;
@@ -211,7 +207,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
211 { 207 {
212 } 208 }
213 209
214 new public Type ReplaceableInterface 210 new public Type ReplaceableInterface
215 { 211 {
216 get { return null; } 212 get { return null; }
217 } 213 }
@@ -282,7 +278,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
282 // range of chat to cover the whole 278 // range of chat to cover the whole
283 // region. however, we don't do this for whisper 279 // region. however, we don't do this for whisper
284 // (got to have some privacy) 280 // (got to have some privacy)
285 if (c.Type != ChatTypeEnum.Whisper) 281 if (c.Type != ChatTypeEnum.Whisper)
286 { 282 {
287 base.OnChatBroadcast(sender, c); 283 base.OnChatBroadcast(sender, c);
288 return; 284 return;
@@ -300,17 +296,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
300 { 296 {
301 client.OnLogout += OnClientLoggedOut; 297 client.OnLogout += OnClientLoggedOut;
302 298
303 if (m_replacingChatModule) 299 if (m_replacingChatModule)
304 client.OnChatFromClient += OnChatFromClient; 300 client.OnChatFromClient += OnChatFromClient;
305 } 301 }
306 302
307 303
308 304
309 public void OnClientLoggedOut(IClientAPI client) 305 public void OnClientLoggedOut(IClientAPI client)
310 { 306 {
311 client.OnLogout -= OnClientLoggedOut; 307 client.OnLogout -= OnClientLoggedOut;
312 client.OnConnectionClosed -= OnClientLoggedOut; 308 client.OnConnectionClosed -= OnClientLoggedOut;
313 309
314 if (m_conciergedScenes.Contains(client.Scene)) 310 if (m_conciergedScenes.Contains(client.Scene))
315 { 311 {
316 Scene scene = client.Scene as Scene; 312 Scene scene = client.Scene as Scene;
@@ -328,7 +324,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
328 Scene scene = agent.Scene; 324 Scene scene = agent.Scene;
329 m_log.DebugFormat("[Concierge]: {0} enters {1}", agent.Name, scene.RegionInfo.RegionName); 325 m_log.DebugFormat("[Concierge]: {0} enters {1}", agent.Name, scene.RegionInfo.RegionName);
330 WelcomeAvatar(agent, scene); 326 WelcomeAvatar(agent, scene);
331 AnnounceToAgentsRegion(scene, String.Format(m_announceEntering, agent.Name, 327 AnnounceToAgentsRegion(scene, String.Format(m_announceEntering, agent.Name,
332 scene.RegionInfo.RegionName, scene.GetRootAgentCount())); 328 scene.RegionInfo.RegionName, scene.GetRootAgentCount()));
333 UpdateBroker(scene); 329 UpdateBroker(scene);
334 } 330 }
@@ -341,7 +337,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
341 { 337 {
342 Scene scene = agent.Scene; 338 Scene scene = agent.Scene;
343 m_log.DebugFormat("[Concierge]: {0} leaves {1}", agent.Name, scene.RegionInfo.RegionName); 339 m_log.DebugFormat("[Concierge]: {0} leaves {1}", agent.Name, scene.RegionInfo.RegionName);
344 AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, agent.Name, 340 AnnounceToAgentsRegion(scene, String.Format(m_announceLeaving, agent.Name,
345 scene.RegionInfo.RegionName, scene.GetRootAgentCount())); 341 scene.RegionInfo.RegionName, scene.GetRootAgentCount()));
346 UpdateBroker(scene); 342 UpdateBroker(scene);
347 } 343 }
@@ -378,7 +374,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
378 374
379 scene.ForEachRootScenePresence(delegate(ScenePresence sp) 375 scene.ForEachRootScenePresence(delegate(ScenePresence sp)
380 { 376 {
381 list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID)); 377 list.Append(String.Format(" <avatar name=\"{0}\" uuid=\"{1}\" />\n", sp.Name, sp.UUID));
382 }); 378 });
383 379
384 list.Append("</avatars>"); 380 list.Append("</avatars>");
@@ -441,7 +437,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
441 private void UpdateBrokerDone(IAsyncResult result) 437 private void UpdateBrokerDone(IAsyncResult result)
442 { 438 {
443 BrokerState bs = null; 439 BrokerState bs = null;
444 try 440 try
445 { 441 {
446 bs = result.AsyncState as BrokerState; 442 bs = result.AsyncState as BrokerState;
447 HttpWebRequest updatePost = bs.Poster; 443 HttpWebRequest updatePost = bs.Poster;
@@ -454,19 +450,18 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
454 catch (WebException we) 450 catch (WebException we)
455 { 451 {
456 m_log.ErrorFormat("[Concierge] broker update to {0} failed with status {1}", bs.Uri, we.Status); 452 m_log.ErrorFormat("[Concierge] broker update to {0} failed with status {1}", bs.Uri, we.Status);
457 if (null != we.Response) 453 if (null != we.Response)
458 { 454 {
459 using (HttpWebResponse resp = we.Response as HttpWebResponse) 455 using (HttpWebResponse resp = we.Response as HttpWebResponse)
460 { 456 {
461 m_log.ErrorFormat("[Concierge] response from {0} status code: {1}", bs.Uri, resp.StatusCode); 457 m_log.ErrorFormat("[Concierge] response from {0} status code: {1}", bs.Uri, resp.StatusCode);
462 m_log.ErrorFormat("[Concierge] response from {0} status desc: {1}", bs.Uri, resp.StatusDescription); 458 m_log.ErrorFormat("[Concierge] response from {0} status desc: {1}", bs.Uri, resp.StatusDescription);
463 m_log.ErrorFormat("[Concierge] response from {0} server: {1}", bs.Uri, resp.Server); 459 m_log.ErrorFormat("[Concierge] response from {0} server: {1}", bs.Uri, resp.Server);
464 460
465 if (resp.ContentLength > 0) 461 if (resp.ContentLength > 0)
466 { 462 {
467 StreamReader content = new StreamReader(resp.GetResponseStream()); 463 using(StreamReader content = new StreamReader(resp.GetResponseStream()))
468 m_log.ErrorFormat("[Concierge] response from {0} content: {1}", bs.Uri, content.ReadToEnd()); 464 m_log.ErrorFormat("[Concierge] response from {0} content: {1}", bs.Uri, content.ReadToEnd());
469 content.Close();
470 } 465 }
471 } 466 }
472 } 467 }
@@ -480,12 +475,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
480 // welcome file there: if yes, send it to the agent 475 // welcome file there: if yes, send it to the agent
481 if (!String.IsNullOrEmpty(m_welcomes)) 476 if (!String.IsNullOrEmpty(m_welcomes))
482 { 477 {
483 string[] welcomes = new string[] { 478 string[] welcomes = new string[] {
484 Path.Combine(m_welcomes, agent.Scene.RegionInfo.RegionName), 479 Path.Combine(m_welcomes, agent.Scene.RegionInfo.RegionName),
485 Path.Combine(m_welcomes, "DEFAULT")}; 480 Path.Combine(m_welcomes, "DEFAULT")};
486 foreach (string welcome in welcomes) 481 foreach (string welcome in welcomes)
487 { 482 {
488 if (File.Exists(welcome)) 483 if (File.Exists(welcome))
489 { 484 {
490 try 485 try
491 { 486 {
@@ -504,7 +499,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
504 { 499 {
505 m_log.ErrorFormat("[Concierge]: welcome file {0} is malformed: {1}", welcome, fe); 500 m_log.ErrorFormat("[Concierge]: welcome file {0} is malformed: {1}", welcome, fe);
506 } 501 }
507 } 502 }
508 return; 503 return;
509 } 504 }
510 m_log.DebugFormat("[Concierge]: no welcome message for region {0}", scene.RegionInfo.RegionName); 505 m_log.DebugFormat("[Concierge]: no welcome message for region {0}", scene.RegionInfo.RegionName);
@@ -516,7 +511,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
516 // protected void AnnounceToAgentsRegion(Scene scene, string msg) 511 // protected void AnnounceToAgentsRegion(Scene scene, string msg)
517 // { 512 // {
518 // ScenePresence agent = null; 513 // ScenePresence agent = null;
519 // if ((client.Scene is Scene) && (client.Scene as Scene).TryGetScenePresence(client.AgentId, out agent)) 514 // if ((client.Scene is Scene) && (client.Scene as Scene).TryGetScenePresence(client.AgentId, out agent))
520 // AnnounceToAgentsRegion(agent, msg); 515 // AnnounceToAgentsRegion(agent, msg);
521 // else 516 // else
522 // m_log.DebugFormat("[Concierge]: could not find an agent for client {0}", client.Name); 517 // m_log.DebugFormat("[Concierge]: could not find an agent for client {0}", client.Name);
@@ -591,7 +586,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
591 586
592 string regionName = (string)requestData["region"]; 587 string regionName = (string)requestData["region"];
593 IScene scene = m_scenes.Find(delegate(IScene s) { return s.RegionInfo.RegionName == regionName; }); 588 IScene scene = m_scenes.Find(delegate(IScene s) { return s.RegionInfo.RegionName == regionName; });
594 if (scene == null) 589 if (scene == null)
595 throw new Exception(String.Format("unknown region \"{0}\"", regionName)); 590 throw new Exception(String.Format("unknown region \"{0}\"", regionName));
596 591
597 if (!m_conciergedScenes.Contains(scene)) 592 if (!m_conciergedScenes.Contains(scene))
diff --git a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
index 4e84364..31fc56a 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Friends/FriendsCommandsModule.cs
@@ -61,31 +61,31 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
61 private IPresenceService m_presenceService; 61 private IPresenceService m_presenceService;
62 62
63// private IAvatarFactoryModule m_avatarFactory; 63// private IAvatarFactoryModule m_avatarFactory;
64 64
65 public string Name { get { return "Appearance Information Module"; } } 65 public string Name { get { return "Appearance Information Module"; } }
66 66
67 public Type ReplaceableInterface { get { return null; } } 67 public Type ReplaceableInterface { get { return null; } }
68 68
69 public void Initialise(IConfigSource source) 69 public void Initialise(IConfigSource source)
70 { 70 {
71// m_log.DebugFormat("[FRIENDS COMMAND MODULE]: INITIALIZED MODULE"); 71// m_log.DebugFormat("[FRIENDS COMMAND MODULE]: INITIALIZED MODULE");
72 } 72 }
73 73
74 public void PostInitialise() 74 public void PostInitialise()
75 { 75 {
76// m_log.DebugFormat("[FRIENDS COMMAND MODULE]: POST INITIALIZED MODULE"); 76// m_log.DebugFormat("[FRIENDS COMMAND MODULE]: POST INITIALIZED MODULE");
77 } 77 }
78 78
79 public void Close() 79 public void Close()
80 { 80 {
81// m_log.DebugFormat("[FRIENDS COMMAND MODULE]: CLOSED MODULE"); 81// m_log.DebugFormat("[FRIENDS COMMAND MODULE]: CLOSED MODULE");
82 } 82 }
83 83
84 public void AddRegion(Scene scene) 84 public void AddRegion(Scene scene)
85 { 85 {
86// m_log.DebugFormat("[FRIENDS COMMANDO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); 86// m_log.DebugFormat("[FRIENDS COMMANDO MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
87 } 87 }
88 88
89 public void RemoveRegion(Scene scene) 89 public void RemoveRegion(Scene scene)
90 { 90 {
91// m_log.DebugFormat("[FRIENDS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); 91// m_log.DebugFormat("[FRIENDS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
@@ -107,7 +107,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
107 m_scene.AddCommand( 107 m_scene.AddCommand(
108 "Friends", this, "friends show", 108 "Friends", this, "friends show",
109 "friends show [--cache] <first-name> <last-name>", 109 "friends show [--cache] <first-name> <last-name>",
110 "Show the friends for the given user if they exist.\n", 110 "Show the friends for the given user if they exist.",
111 "The --cache option will show locally cached information for that user.", 111 "The --cache option will show locally cached information for that user.",
112 HandleFriendsShowCommand); 112 HandleFriendsShowCommand);
113 } 113 }
@@ -197,4 +197,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.Friends
197 } 197 }
198 } 198 }
199 } 199 }
200} \ No newline at end of file 200}
diff --git a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs
index 5a6b284..1b5ee04 100644
--- a/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/SitStand/SitStandCommandsModule.cs
@@ -54,34 +54,34 @@ namespace OpenSim.Region.OptionalModules.Avatar.SitStand
54 private Scene m_scene; 54 private Scene m_scene;
55 55
56 public string Name { get { return "SitStand Command Module"; } } 56 public string Name { get { return "SitStand Command Module"; } }
57 57
58 public Type ReplaceableInterface { get { return null; } } 58 public Type ReplaceableInterface { get { return null; } }
59 59
60 public void Initialise(IConfigSource source) 60 public void Initialise(IConfigSource source)
61 { 61 {
62// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: INITIALIZED MODULE"); 62// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: INITIALIZED MODULE");
63 } 63 }
64 64
65 public void PostInitialise() 65 public void PostInitialise()
66 { 66 {
67// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: POST INITIALIZED MODULE"); 67// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: POST INITIALIZED MODULE");
68 } 68 }
69 69
70 public void Close() 70 public void Close()
71 { 71 {
72// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: CLOSED MODULE"); 72// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: CLOSED MODULE");
73 } 73 }
74 74
75 public void AddRegion(Scene scene) 75 public void AddRegion(Scene scene)
76 { 76 {
77// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); 77// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
78 } 78 }
79 79
80 public void RemoveRegion(Scene scene) 80 public void RemoveRegion(Scene scene)
81 { 81 {
82// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); 82// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
83 } 83 }
84 84
85 public void RegionLoaded(Scene scene) 85 public void RegionLoaded(Scene scene)
86 { 86 {
87// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); 87// m_log.DebugFormat("[ANIMATIONS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
@@ -143,7 +143,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.SitStand
143 if (sitPart != null) 143 if (sitPart != null)
144 { 144 {
145 MainConsole.Instance.OutputFormat( 145 MainConsole.Instance.OutputFormat(
146 "Sitting {0} on {1} {2} in {3}", 146 "Sitting {0} on {1} {2} in {3}",
147 sp.Name, sitPart.ParentGroup.Name, sitPart.ParentGroup.UUID, m_scene.Name); 147 sp.Name, sitPart.ParentGroup.Name, sitPart.ParentGroup.UUID, m_scene.Name);
148 148
149 sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, sitPart.UUID, Vector3.Zero); 149 sp.HandleAgentRequestSit(sp.ControllingClient, sp.UUID, sitPart.UUID, Vector3.Zero);
@@ -202,14 +202,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.SitStand
202 202
203 foreach (ScenePresence sp in scenePresences) 203 foreach (ScenePresence sp in scenePresences)
204 { 204 {
205 if (!sp.IsChildAgent && nameRegex.IsMatch(sp.Name)) 205 if (!sp.IsChildAgent && nameRegex.IsMatch(sp.Name))
206 scenePresencesMatched.Add(sp); 206 scenePresencesMatched.Add(sp);
207 } 207 }
208 } 208 }
209 else 209 else
210 { 210 {
211 ScenePresence sp = m_scene.GetScenePresence(firstName, lastName); 211 ScenePresence sp = m_scene.GetScenePresence(firstName, lastName);
212 212
213 if (sp != null && !sp.IsChildAgent) 213 if (sp != null && !sp.IsChildAgent)
214 scenePresencesMatched.Add(sp); 214 scenePresencesMatched.Add(sp);
215 } 215 }
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index 45af212..c6d7fe6 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -143,7 +143,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
143 if (String.IsNullOrEmpty(m_freeSwitchRealm) || 143 if (String.IsNullOrEmpty(m_freeSwitchRealm) ||
144 String.IsNullOrEmpty(m_freeSwitchAPIPrefix)) 144 String.IsNullOrEmpty(m_freeSwitchAPIPrefix))
145 { 145 {
146 m_log.Error("[FreeSwitchVoice]: Freeswitch service mis-configured. Not starting."); 146 m_log.Error("[FreeSwitchVoice]: Freeswitch service mis-configured. Not starting.");
147 return; 147 return;
148 } 148 }
149 149
@@ -168,9 +168,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
168 168
169 MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix), 169 MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_buddy.php", m_freeSwitchAPIPrefix),
170 FreeSwitchSLVoiceBuddyHTTPHandler); 170 FreeSwitchSLVoiceBuddyHTTPHandler);
171 171
172 MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_watcher.php", m_freeSwitchAPIPrefix), 172 MainServer.Instance.AddHTTPHandler(String.Format("{0}/viv_watcher.php", m_freeSwitchAPIPrefix),
173 FreeSwitchSLVoiceWatcherHTTPHandler); 173 FreeSwitchSLVoiceWatcherHTTPHandler);
174 174
175 m_log.InfoFormat("[FreeSwitchVoice]: using FreeSwitch server {0}", m_freeSwitchRealm); 175 m_log.InfoFormat("[FreeSwitchVoice]: using FreeSwitch server {0}", m_freeSwitchRealm);
176 176
@@ -302,7 +302,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
302 public void OnRegisterCaps(Scene scene, UUID agentID, Caps caps) 302 public void OnRegisterCaps(Scene scene, UUID agentID, Caps caps)
303 { 303 {
304 m_log.DebugFormat( 304 m_log.DebugFormat(
305 "[FreeSwitchVoice]: OnRegisterCaps() called with agentID {0} caps {1} in scene {2}", 305 "[FreeSwitchVoice]: OnRegisterCaps() called with agentID {0} caps {1} in scene {2}",
306 agentID, caps, scene.RegionInfo.RegionName); 306 agentID, caps, scene.RegionInfo.RegionName);
307 307
308 string capsBase = "/CAPS/" + caps.CapsObjectPath; 308 string capsBase = "/CAPS/" + caps.CapsObjectPath;
@@ -352,7 +352,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
352 { 352 {
353 m_log.DebugFormat( 353 m_log.DebugFormat(
354 "[FreeSwitchVoice][PROVISIONVOICE]: ProvisionVoiceAccountRequest() request: {0}, path: {1}, param: {2}", request, path, param); 354 "[FreeSwitchVoice][PROVISIONVOICE]: ProvisionVoiceAccountRequest() request: {0}, path: {1}, param: {2}", request, path, param);
355 355
356 ScenePresence avatar = scene.GetScenePresence(agentID); 356 ScenePresence avatar = scene.GetScenePresence(agentID);
357 if (avatar == null) 357 if (avatar == null)
358 { 358 {
@@ -423,9 +423,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
423 UUID agentID, Caps caps) 423 UUID agentID, Caps caps)
424 { 424 {
425 m_log.DebugFormat( 425 m_log.DebugFormat(
426 "[FreeSwitchVoice][PARCELVOICE]: ParcelVoiceInfoRequest() on {0} for {1}", 426 "[FreeSwitchVoice][PARCELVOICE]: ParcelVoiceInfoRequest() on {0} for {1}",
427 scene.RegionInfo.RegionName, agentID); 427 scene.RegionInfo.RegionName, agentID);
428 428
429 ScenePresence avatar = scene.GetScenePresence(agentID); 429 ScenePresence avatar = scene.GetScenePresence(agentID);
430 string avatarName = avatar.Name; 430 string avatarName = avatar.Name;
431 431
@@ -512,7 +512,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
512 512
513 m_log.DebugFormat("[FreeSwitchVoice][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}", 513 m_log.DebugFormat("[FreeSwitchVoice][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}",
514 avatarName, request, path, param); 514 avatarName, request, path, param);
515 515
516 return "<llsd>true</llsd>"; 516 return "<llsd>true</llsd>";
517 } 517 }
518 518
@@ -575,7 +575,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
575 575
576 public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request) 576 public Hashtable FreeSwitchSLVoiceGetPreloginHTTPHandler(Hashtable request)
577 { 577 {
578 m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceGetPreloginHTTPHandler called"); 578// m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceGetPreloginHTTPHandler called");
579 579
580 Hashtable response = new Hashtable(); 580 Hashtable response = new Hashtable();
581 response["content_type"] = "text/xml"; 581 response["content_type"] = "text/xml";
@@ -610,7 +610,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
610 public Hashtable FreeSwitchSLVoiceBuddyHTTPHandler(Hashtable request) 610 public Hashtable FreeSwitchSLVoiceBuddyHTTPHandler(Hashtable request)
611 { 611 {
612 m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceBuddyHTTPHandler called"); 612 m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceBuddyHTTPHandler called");
613 613
614 Hashtable response = new Hashtable(); 614 Hashtable response = new Hashtable();
615 response["int_response_code"] = 200; 615 response["int_response_code"] = 200;
616 response["str_response_string"] = string.Empty; 616 response["str_response_string"] = string.Empty;
@@ -678,16 +678,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
678// Regex normalizeEndLines = new Regex(@"(\r\n|\n)", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); 678// Regex normalizeEndLines = new Regex(@"(\r\n|\n)", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline);
679// 679//
680// m_log.DebugFormat( 680// m_log.DebugFormat(
681// "[FREESWITCH]: FreeSwitchSLVoiceBuddyHTTPHandler() response {0}", 681// "[FREESWITCH]: FreeSwitchSLVoiceBuddyHTTPHandler() response {0}",
682// normalizeEndLines.Replace((string)response["str_response_string"],"")); 682// normalizeEndLines.Replace((string)response["str_response_string"],""));
683 683
684 return response; 684 return response;
685 } 685 }
686 686
687 public Hashtable FreeSwitchSLVoiceWatcherHTTPHandler(Hashtable request) 687 public Hashtable FreeSwitchSLVoiceWatcherHTTPHandler(Hashtable request)
688 { 688 {
689 m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceWatcherHTTPHandler called"); 689 m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceWatcherHTTPHandler called");
690 690
691 Hashtable response = new Hashtable(); 691 Hashtable response = new Hashtable();
692 response["int_response_code"] = 200; 692 response["int_response_code"] = 200;
693 response["content-type"] = "text/xml"; 693 response["content-type"] = "text/xml";
@@ -700,8 +700,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
700 700
701 StringBuilder resp = new StringBuilder(); 701 StringBuilder resp = new StringBuilder();
702 resp.Append("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?><response xmlns=\"http://www.vivox.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation= \"/xsd/buddy_list.xsd\">"); 702 resp.Append("<?xml version=\"1.0\" encoding=\"iso-8859-1\" ?><response xmlns=\"http://www.vivox.com\" xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" xsi:schemaLocation= \"/xsd/buddy_list.xsd\">");
703 703
704 // FIXME: This is enough of a response to stop viewer 2 complaining about a login failure and get voice to work. If we don't 704 // FIXME: This is enough of a response to stop viewer 2 complaining about a login failure and get voice to work. If we don't
705 // give an OK response, then viewer 2 engages in an continuous viv_signin.php, viv_buddy.php, viv_watcher.php loop 705 // give an OK response, then viewer 2 engages in an continuous viv_signin.php, viv_buddy.php, viv_watcher.php loop
706 // Viewer 1 appeared happy to ignore the lack of reply and still works with this reply. 706 // Viewer 1 appeared happy to ignore the lack of reply and still works with this reply.
707 // 707 //
@@ -711,22 +711,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
711 <cookie_name>lib_session</cookie_name> 711 <cookie_name>lib_session</cookie_name>
712 <cookie>{0}</cookie> 712 <cookie>{0}</cookie>
713 <auth_token>{0}</auth_token> 713 <auth_token>{0}</auth_token>
714 <body/></level0></response>", auth_token)); 714 <body/></level0></response>", auth_token));
715 715
716 response["str_response_string"] = resp.ToString(); 716 response["str_response_string"] = resp.ToString();
717 717
718// Regex normalizeEndLines = new Regex(@"(\r\n|\n)", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline); 718// Regex normalizeEndLines = new Regex(@"(\r\n|\n)", RegexOptions.Compiled | RegexOptions.Singleline | RegexOptions.Multiline);
719// 719//
720// m_log.DebugFormat( 720// m_log.DebugFormat(
721// "[FREESWITCH]: FreeSwitchSLVoiceWatcherHTTPHandler() response {0}", 721// "[FREESWITCH]: FreeSwitchSLVoiceWatcherHTTPHandler() response {0}",
722// normalizeEndLines.Replace((string)response["str_response_string"],"")); 722// normalizeEndLines.Replace((string)response["str_response_string"],""));
723 723
724 return response; 724 return response;
725 } 725 }
726 726
727 public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request) 727 public Hashtable FreeSwitchSLVoiceSigninHTTPHandler(Hashtable request)
728 { 728 {
729 m_log.Debug("[FreeSwitchVoice]: FreeSwitchSLVoiceSigninHTTPHandler called"); 729 //m_log.Debug("[FreeSwitchVoice] FreeSwitchSLVoiceSigninHTTPHandler called");
730// string requestbody = (string)request["body"]; 730// string requestbody = (string)request["body"];
731// string uri = (string)request["uri"]; 731// string uri = (string)request["uri"];
732// string contenttype = (string)request["content-type"]; 732// string contenttype = (string)request["content-type"];
@@ -771,10 +771,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
771 </level0> 771 </level0>
772 </response>", userid, pos, avatarName); 772 </response>", userid, pos, avatarName);
773 773
774 response["int_response_code"] = 200; 774 response["int_response_code"] = 200;
775 775
776// m_log.DebugFormat("[FreeSwitchVoice]: Sending FreeSwitchSLVoiceSigninHTTPHandler response"); 776// m_log.DebugFormat("[FreeSwitchVoice]: Sending FreeSwitchSLVoiceSigninHTTPHandler response");
777 777
778 return response; 778 return response;
779 } 779 }
780 780
@@ -859,23 +859,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
859 response["keepalive"] = false; 859 response["keepalive"] = false;
860 response["int_response_code"] = 500; 860 response["int_response_code"] = 500;
861 861
862 Hashtable requestBody = ParseRequestBody((string)request["body"]); 862 Hashtable requestBody = ParseRequestBody((string)request["body"]);
863 863
864 string section = (string) requestBody["section"]; 864 string section = (string) requestBody["section"];
865 865
866 if (section == "directory") 866 if (section == "directory")
867 { 867 {
868 string eventCallingFunction = (string)requestBody["Event-Calling-Function"]; 868 string eventCallingFunction = (string)requestBody["Event-Calling-Function"];
869 m_log.DebugFormat( 869 m_log.DebugFormat(
870 "[FreeSwitchVoice]: Received request for config section directory, event calling function '{0}'", 870 "[FreeSwitchVoice]: Received request for config section directory, event calling function '{0}'",
871 eventCallingFunction); 871 eventCallingFunction);
872 872
873 response = m_FreeswitchService.HandleDirectoryRequest(requestBody); 873 response = m_FreeswitchService.HandleDirectoryRequest(requestBody);
874 } 874 }
875 else if (section == "dialplan") 875 else if (section == "dialplan")
876 { 876 {
877 m_log.DebugFormat("[FreeSwitchVoice]: Received request for config section dialplan"); 877 m_log.DebugFormat("[FreeSwitchVoice]: Received request for config section dialplan");
878 878
879 response = m_FreeswitchService.HandleDialplanRequest(requestBody); 879 response = m_FreeswitchService.HandleDialplanRequest(requestBody);
880 } 880 }
881 else 881 else
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
index dd44564..defaa9c 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
@@ -114,13 +114,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
114 114
115 private static Dictionary<string,string> m_parents = new Dictionary<string,string>(); 115 private static Dictionary<string,string> m_parents = new Dictionary<string,string>();
116 private static bool m_dumpXml; 116 private static bool m_dumpXml;
117 117
118 private IConfig m_config; 118 private IConfig m_config;
119 119
120 private object m_Lock; 120 private object m_Lock;
121 121
122 public void Initialise(IConfigSource config) 122 public void Initialise(IConfigSource config)
123 { 123 {
124 MainConsole.Instance.Commands.AddCommand("vivox", false, "vivox debug", "vivox debug <on>|<off>", "Set vivox debugging", HandleDebug);
124 125
125 m_config = config.Configs["VivoxVoice"]; 126 m_config = config.Configs["VivoxVoice"];
126 127
@@ -152,22 +153,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
152 // Validate against constraints and default if necessary 153 // Validate against constraints and default if necessary
153 if (m_vivoxChannelRollOff < CHAN_ROLL_OFF_MIN || m_vivoxChannelRollOff > CHAN_ROLL_OFF_MAX) 154 if (m_vivoxChannelRollOff < CHAN_ROLL_OFF_MIN || m_vivoxChannelRollOff > CHAN_ROLL_OFF_MAX)
154 { 155 {
155 m_log.WarnFormat("[VivoxVoice] Invalid value for roll off ({0}), reset to {1}.", 156 m_log.WarnFormat("[VivoxVoice] Invalid value for roll off ({0}), reset to {1}.",
156 m_vivoxChannelRollOff, CHAN_ROLL_OFF_DEFAULT); 157 m_vivoxChannelRollOff, CHAN_ROLL_OFF_DEFAULT);
157 m_vivoxChannelRollOff = CHAN_ROLL_OFF_DEFAULT; 158 m_vivoxChannelRollOff = CHAN_ROLL_OFF_DEFAULT;
158 } 159 }
159 160
160 if (m_vivoxChannelMaximumRange < CHAN_MAX_RANGE_MIN || m_vivoxChannelMaximumRange > CHAN_MAX_RANGE_MAX) 161 if (m_vivoxChannelMaximumRange < CHAN_MAX_RANGE_MIN || m_vivoxChannelMaximumRange > CHAN_MAX_RANGE_MAX)
161 { 162 {
162 m_log.WarnFormat("[VivoxVoice] Invalid value for maximum range ({0}), reset to {1}.", 163 m_log.WarnFormat("[VivoxVoice] Invalid value for maximum range ({0}), reset to {1}.",
163 m_vivoxChannelMaximumRange, CHAN_MAX_RANGE_DEFAULT); 164 m_vivoxChannelMaximumRange, CHAN_MAX_RANGE_DEFAULT);
164 m_vivoxChannelMaximumRange = CHAN_MAX_RANGE_DEFAULT; 165 m_vivoxChannelMaximumRange = CHAN_MAX_RANGE_DEFAULT;
165 } 166 }
166 167
167 if (m_vivoxChannelClampingDistance < CHAN_CLAMPING_DISTANCE_MIN || 168 if (m_vivoxChannelClampingDistance < CHAN_CLAMPING_DISTANCE_MIN ||
168 m_vivoxChannelClampingDistance > CHAN_CLAMPING_DISTANCE_MAX) 169 m_vivoxChannelClampingDistance > CHAN_CLAMPING_DISTANCE_MAX)
169 { 170 {
170 m_log.WarnFormat("[VivoxVoice] Invalid value for clamping distance ({0}), reset to {1}.", 171 m_log.WarnFormat("[VivoxVoice] Invalid value for clamping distance ({0}), reset to {1}.",
171 m_vivoxChannelClampingDistance, CHAN_CLAMPING_DISTANCE_DEFAULT); 172 m_vivoxChannelClampingDistance, CHAN_CLAMPING_DISTANCE_DEFAULT);
172 m_vivoxChannelClampingDistance = CHAN_CLAMPING_DISTANCE_DEFAULT; 173 m_vivoxChannelClampingDistance = CHAN_CLAMPING_DISTANCE_DEFAULT;
173 } 174 }
@@ -179,7 +180,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
179 case "presentation" : break; 180 case "presentation" : break;
180 case "auditorium" : break; 181 case "auditorium" : break;
181 default : 182 default :
182 m_log.WarnFormat("[VivoxVoice] Invalid value for channel mode ({0}), reset to {1}.", 183 m_log.WarnFormat("[VivoxVoice] Invalid value for channel mode ({0}), reset to {1}.",
183 m_vivoxChannelMode, CHAN_MODE_DEFAULT); 184 m_vivoxChannelMode, CHAN_MODE_DEFAULT);
184 m_vivoxChannelMode = CHAN_MODE_DEFAULT; 185 m_vivoxChannelMode = CHAN_MODE_DEFAULT;
185 break; 186 break;
@@ -190,7 +191,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
190 case "positional" : break; 191 case "positional" : break;
191 case "channel" : break; 192 case "channel" : break;
192 default : 193 default :
193 m_log.WarnFormat("[VivoxVoice] Invalid value for channel type ({0}), reset to {1}.", 194 m_log.WarnFormat("[VivoxVoice] Invalid value for channel type ({0}), reset to {1}.",
194 m_vivoxChannelType, CHAN_TYPE_DEFAULT); 195 m_vivoxChannelType, CHAN_TYPE_DEFAULT);
195 m_vivoxChannelType = CHAN_TYPE_DEFAULT; 196 m_vivoxChannelType = CHAN_TYPE_DEFAULT;
196 break; 197 break;
@@ -229,7 +230,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
229 230
230 public void AddRegion(Scene scene) 231 public void AddRegion(Scene scene)
231 { 232 {
232 if (m_pluginEnabled) 233 if (m_pluginEnabled)
233 { 234 {
234 lock (vlock) 235 lock (vlock)
235 { 236 {
@@ -237,13 +238,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
237 238
238 string sceneUUID = scene.RegionInfo.RegionID.ToString(); 239 string sceneUUID = scene.RegionInfo.RegionID.ToString();
239 string sceneName = scene.RegionInfo.RegionName; 240 string sceneName = scene.RegionInfo.RegionName;
240 241
241 // Make sure that all local channels are deleted. 242 // Make sure that all local channels are deleted.
242 // So we have to search for the children, and then do an 243 // So we have to search for the children, and then do an
243 // iteration over the set of chidren identified. 244 // iteration over the set of chidren identified.
244 // This assumes that there is just one directory per 245 // This assumes that there is just one directory per
245 // region. 246 // region.
246 247
247 if (VivoxTryGetDirectory(sceneUUID + "D", out channelId)) 248 if (VivoxTryGetDirectory(sceneUUID + "D", out channelId))
248 { 249 {
249 m_log.DebugFormat("[VivoxVoice]: region {0}: uuid {1}: located directory id {2}", 250 m_log.DebugFormat("[VivoxVoice]: region {0}: uuid {1}: located directory id {2}",
@@ -262,7 +263,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
262 { 263 {
263 if (!IsOK(VivoxDeleteChannel(channelId, id))) 264 if (!IsOK(VivoxDeleteChannel(channelId, id)))
264 m_log.WarnFormat("[VivoxVoice] Channel delete failed {0}:{1}:{2}", i, channelId, id); 265 m_log.WarnFormat("[VivoxVoice] Channel delete failed {0}:{1}:{2}", i, channelId, id);
265 } 266 }
266 } 267 }
267 } 268 }
268 } 269 }
@@ -310,7 +311,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
310 311
311 public void RemoveRegion(Scene scene) 312 public void RemoveRegion(Scene scene)
312 { 313 {
313 if (m_pluginEnabled) 314 if (m_pluginEnabled)
314 { 315 {
315 lock (vlock) 316 lock (vlock)
316 { 317 {
@@ -318,7 +319,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
318 319
319 string sceneUUID = scene.RegionInfo.RegionID.ToString(); 320 string sceneUUID = scene.RegionInfo.RegionID.ToString();
320 string sceneName = scene.RegionInfo.RegionName; 321 string sceneName = scene.RegionInfo.RegionName;
321 322
322 // Make sure that all local channels are deleted. 323 // Make sure that all local channels are deleted.
323 // So we have to search for the children, and then do an 324 // So we have to search for the children, and then do an
324 // iteration over the set of chidren identified. 325 // iteration over the set of chidren identified.
@@ -342,7 +343,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
342 { 343 {
343 if (!IsOK(VivoxDeleteChannel(channelId, id))) 344 if (!IsOK(VivoxDeleteChannel(channelId, id)))
344 m_log.WarnFormat("[VivoxVoice] Channel delete failed {0}:{1}:{2}", i, channelId, id); 345 m_log.WarnFormat("[VivoxVoice] Channel delete failed {0}:{1}:{2}", i, channelId, id);
345 } 346 }
346 } 347 }
347 } 348 }
348 } 349 }
@@ -352,7 +353,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
352 353
353 // Remove the channel umbrella entry 354 // Remove the channel umbrella entry
354 355
355 lock (m_parents) 356 lock (m_parents)
356 { 357 {
357 if (m_parents.ContainsKey(sceneUUID)) 358 if (m_parents.ContainsKey(sceneUUID))
358 { 359 {
@@ -374,7 +375,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
374 VivoxLogout(); 375 VivoxLogout();
375 } 376 }
376 377
377 public Type ReplaceableInterface 378 public Type ReplaceableInterface
378 { 379 {
379 get { return null; } 380 get { return null; }
380 } 381 }
@@ -395,11 +396,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
395 // (login, region crossing). We contribute two capabilities to 396 // (login, region crossing). We contribute two capabilities to
396 // the set of capabilities handed back to the client: 397 // the set of capabilities handed back to the client:
397 // ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest. 398 // ProvisionVoiceAccountRequest and ParcelVoiceInfoRequest.
398 // 399 //
399 // ProvisionVoiceAccountRequest allows the client to obtain 400 // ProvisionVoiceAccountRequest allows the client to obtain
400 // the voice account credentials for the avatar it is 401 // the voice account credentials for the avatar it is
401 // controlling (e.g., user name, password, etc). 402 // controlling (e.g., user name, password, etc).
402 // 403 //
403 // ParcelVoiceInfoRequest is invoked whenever the client 404 // ParcelVoiceInfoRequest is invoked whenever the client
404 // changes from one region or parcel to another. 405 // changes from one region or parcel to another.
405 // 406 //
@@ -475,8 +476,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
475 avatarName = avatar.Name; 476 avatarName = avatar.Name;
476 477
477 m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: scene = {0}, agentID = {1}", scene, agentID); 478 m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: scene = {0}, agentID = {1}", scene, agentID);
478 m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}", 479// m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: request: {0}, path: {1}, param: {2}",
479 request, path, param); 480// request, path, param);
480 481
481 XmlElement resp; 482 XmlElement resp;
482 bool retry = false; 483 bool retry = false;
@@ -492,9 +493,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
492 493
493 if (XmlFind(resp, "response.level0.status", out code)) 494 if (XmlFind(resp, "response.level0.status", out code))
494 { 495 {
495 if (code != "OK") 496 if (code != "OK")
496 { 497 {
497 if (XmlFind(resp, "response.level0.body.code", out code)) 498 if (XmlFind(resp, "response.level0.body.code", out code))
498 { 499 {
499 // If the request was recognized, then this should be set to something 500 // If the request was recognized, then this should be set to something
500 switch (code) 501 switch (code)
@@ -529,27 +530,27 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
529 switch (code) 530 switch (code)
530 { 531 {
531 case "201" : // Account expired 532 case "201" : // Account expired
532 m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : expired credentials", 533 m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : expired credentials",
533 avatarName); 534 avatarName);
534 m_adminConnected = false; 535 m_adminConnected = false;
535 retry = DoAdminLogin(); 536 retry = DoAdminLogin();
536 break; 537 break;
537 538
538 case "202" : // Missing credentials 539 case "202" : // Missing credentials
539 m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : missing credentials", 540 m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : missing credentials",
540 avatarName); 541 avatarName);
541 break; 542 break;
542 543
543 case "212" : // Not authorized 544 case "212" : // Not authorized
544 m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : not authorized", 545 m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : not authorized",
545 avatarName); 546 avatarName);
546 break; 547 break;
547 548
548 case "300" : // Required parameter missing 549 case "300" : // Required parameter missing
549 m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : parameter missing", 550 m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : parameter missing",
550 avatarName); 551 avatarName);
551 break; 552 break;
552 553
553 case "400" : // Create failed 554 case "400" : // Create failed
554 m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : create failed", 555 m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Create account information failed : create failed",
555 avatarName); 556 avatarName);
@@ -557,7 +558,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
557 } 558 }
558 } 559 }
559 break; 560 break;
560 561
561 case "404" : // Failed to retrieve account 562 case "404" : // Failed to retrieve account
562 m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : retrieve failed"); 563 m_log.ErrorFormat("[VivoxVoice]: avatar \"{0}\": Get account information failed : retrieve failed");
563 // [AMW] Sleep and retry for a fixed period? Or just abandon? 564 // [AMW] Sleep and retry for a fixed period? Or just abandon?
@@ -574,7 +575,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
574 m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: Get Account Request failed for \"{0}\"", avatarName); 575 m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: Get Account Request failed for \"{0}\"", avatarName);
575 throw new Exception("Unable to execute request"); 576 throw new Exception("Unable to execute request");
576 } 577 }
577 578
578 // Unconditionally change the password on each request 579 // Unconditionally change the password on each request
579 VivoxPassword(agentname, password); 580 VivoxPassword(agentname, password);
580 581
@@ -583,7 +584,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
583 584
584 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse); 585 string r = LLSDHelpers.SerialiseLLSDReply(voiceAccountResponse);
585 586
586 m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r); 587// m_log.DebugFormat("[VivoxVoice][PROVISIONVOICE]: avatar \"{0}\": {1}", avatarName, r);
587 588
588 return r; 589 return r;
589 } 590 }
@@ -612,7 +613,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
612 string avatarName = avatar.Name; 613 string avatarName = avatar.Name;
613 614
614 // - check whether we have a region channel in our cache 615 // - check whether we have a region channel in our cache
615 // - if not: 616 // - if not:
616 // create it and cache it 617 // create it and cache it
617 // - send it to the client 618 // - send it to the client
618 // - send channel_uri: as "sip:regionID@m_sipDomain" 619 // - send channel_uri: as "sip:regionID@m_sipDomain"
@@ -621,7 +622,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
621 LLSDParcelVoiceInfoResponse parcelVoiceInfo; 622 LLSDParcelVoiceInfoResponse parcelVoiceInfo;
622 string channel_uri; 623 string channel_uri;
623 624
624 if (null == scene.LandChannel) 625 if (null == scene.LandChannel)
625 throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available", 626 throw new Exception(String.Format("region \"{0}\": avatar \"{1}\": land data not yet available",
626 scene.RegionInfo.RegionName, avatarName)); 627 scene.RegionInfo.RegionName, avatarName));
627 628
@@ -630,24 +631,28 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
630 // voice, if all do retrieve or obtain the parcel 631 // voice, if all do retrieve or obtain the parcel
631 // voice channel 632 // voice channel
632 LandData land = scene.GetLandData(avatar.AbsolutePosition); 633 LandData land = scene.GetLandData(avatar.AbsolutePosition);
634 if (land == null)
635 {
636 return "<llsd><undef /></llsd>";
637 }
633 638
634 m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", 639// m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}",
635 scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); 640// scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param);
636 // m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: avatar \"{0}\": location: {1} {2} {3}", 641 // m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: avatar \"{0}\": location: {1} {2} {3}",
637 // avatarName, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z); 642 // avatarName, avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y, avatar.AbsolutePosition.Z);
638 643
639 // TODO: EstateSettings don't seem to get propagated... 644 // TODO: EstateSettings don't seem to get propagated...
640 if (!scene.RegionInfo.EstateSettings.AllowVoice) 645 if (!scene.RegionInfo.EstateSettings.AllowVoice)
641 { 646 {
642 m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings", 647 //m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": voice not enabled in estate settings",
643 scene.RegionInfo.RegionName); 648 // scene.RegionInfo.RegionName);
644 channel_uri = String.Empty; 649 channel_uri = String.Empty;
645 } 650 }
646 651
647 if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0) 652 if ((land.Flags & (uint)ParcelFlags.AllowVoiceChat) == 0)
648 { 653 {
649 m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel", 654 //m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": voice not enabled for parcel",
650 scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName); 655 // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName);
651 channel_uri = String.Empty; 656 channel_uri = String.Empty;
652 } 657 }
653 else 658 else
@@ -662,15 +667,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
662 parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds); 667 parcelVoiceInfo = new LLSDParcelVoiceInfoResponse(scene.RegionInfo.RegionName, land.LocalID, creds);
663 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo); 668 string r = LLSDHelpers.SerialiseLLSDReply(parcelVoiceInfo);
664 669
665 m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}", 670// m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": {4}",
666 scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r); 671// scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, r);
667 return r; 672 return r;
668 } 673 }
669 catch (Exception e) 674 catch (Exception e)
670 { 675 {
671 m_log.ErrorFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later", 676 m_log.ErrorFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2}, retry later",
672 scene.RegionInfo.RegionName, avatarName, e.Message); 677 scene.RegionInfo.RegionName, avatarName, e.Message);
673 m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed", 678 m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": avatar \"{1}\": {2} failed",
674 scene.RegionInfo.RegionName, avatarName, e.ToString()); 679 scene.RegionInfo.RegionName, avatarName, e.ToString());
675 680
676 return "<llsd><undef /></llsd>"; 681 return "<llsd><undef /></llsd>";
@@ -690,11 +695,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
690 public string ChatSessionRequest(Scene scene, string request, string path, string param, 695 public string ChatSessionRequest(Scene scene, string request, string path, string param,
691 UUID agentID, Caps caps) 696 UUID agentID, Caps caps)
692 { 697 {
693 ScenePresence avatar = scene.GetScenePresence(agentID); 698// ScenePresence avatar = scene.GetScenePresence(agentID);
694 string avatarName = avatar.Name; 699// string avatarName = avatar.Name;
695 700
696 m_log.DebugFormat("[VivoxVoice][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}", 701// m_log.DebugFormat("[VivoxVoice][CHATSESSION]: avatar \"{0}\": request: {1}, path: {2}, param: {3}",
697 avatarName, request, path, param); 702// avatarName, request, path, param);
698 return "<llsd>true</llsd>"; 703 return "<llsd>true</llsd>";
699 } 704 }
700 705
@@ -716,17 +721,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
716 { 721 {
717 landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name); 722 landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, land.Name);
718 landUUID = land.GlobalID.ToString(); 723 landUUID = land.GlobalID.ToString();
719 m_log.DebugFormat("[VivoxVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", 724 m_log.DebugFormat("[VivoxVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
720 landName, land.LocalID, landUUID); 725 landName, land.LocalID, landUUID);
721 } 726 }
722 else 727 else
723 { 728 {
724 landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName); 729 landName = String.Format("{0}:{1}", scene.RegionInfo.RegionName, scene.RegionInfo.RegionName);
725 landUUID = scene.RegionInfo.RegionID.ToString(); 730 landUUID = scene.RegionInfo.RegionID.ToString();
726 m_log.DebugFormat("[VivoxVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}", 731 m_log.DebugFormat("[VivoxVoice]: Region:Parcel \"{0}\": parcel id {1}: using channel name {2}",
727 landName, land.LocalID, landUUID); 732 landName, land.LocalID, landUUID);
728 } 733 }
729 734
730 lock (vlock) 735 lock (vlock)
731 { 736 {
732 // Added by Adam to help debug channel not availible errors. 737 // Added by Adam to help debug channel not availible errors.
@@ -737,7 +742,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
737 else 742 else
738 throw new Exception("vivox channel uri not available"); 743 throw new Exception("vivox channel uri not available");
739 744
740 m_log.DebugFormat("[VivoxVoice]: Region:Parcel \"{0}\": parent channel id {1}: retrieved parcel channel_uri {2} ", 745 m_log.DebugFormat("[VivoxVoice]: Region:Parcel \"{0}\": parent channel id {1}: retrieved parcel channel_uri {2} ",
741 landName, parentId, channelUri); 746 landName, parentId, channelUri);
742 } 747 }
743 748
@@ -767,6 +772,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
767 return VivoxCall(requrl, false); 772 return VivoxCall(requrl, false);
768 } 773 }
769 774
775
770 private static readonly string m_vivoxGetAccountPath = "http://{0}/api2/viv_get_acct.php?auth_token={1}&user_name={2}"; 776 private static readonly string m_vivoxGetAccountPath = "http://{0}/api2/viv_get_acct.php?auth_token={1}&user_name={2}";
771 777
772 /// <summary> 778 /// <summary>
@@ -779,6 +785,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
779 return VivoxCall(requrl, true); 785 return VivoxCall(requrl, true);
780 } 786 }
781 787
788
782 private static readonly string m_vivoxNewAccountPath = "http://{0}/api2/viv_adm_acct_new.php?username={1}&pwd={2}&auth_token={3}"; 789 private static readonly string m_vivoxNewAccountPath = "http://{0}/api2/viv_adm_acct_new.php?username={1}&pwd={2}&auth_token={3}";
783 790
784 /// <summary> 791 /// <summary>
@@ -793,6 +800,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
793 return VivoxCall(requrl, true); 800 return VivoxCall(requrl, true);
794 } 801 }
795 802
803
796 private static readonly string m_vivoxPasswordPath = "http://{0}/api2/viv_adm_password.php?user_name={1}&new_pwd={2}&auth_token={3}"; 804 private static readonly string m_vivoxPasswordPath = "http://{0}/api2/viv_adm_password.php?user_name={1}&new_pwd={2}&auth_token={3}";
797 805
798 /// <summary> 806 /// <summary>
@@ -804,18 +812,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
804 return VivoxCall(requrl, true); 812 return VivoxCall(requrl, true);
805 } 813 }
806 814
815
807 private static readonly string m_vivoxChannelPath = "http://{0}/api2/viv_chan_mod.php?mode={1}&chan_name={2}&auth_token={3}"; 816 private static readonly string m_vivoxChannelPath = "http://{0}/api2/viv_chan_mod.php?mode={1}&chan_name={2}&auth_token={3}";
808 817
809 /// <summary> 818 /// <summary>
810 /// Create a channel. 819 /// Create a channel.
811 /// Once again, there a multitude of options possible. In the simplest case 820 /// Once again, there a multitude of options possible. In the simplest case
812 /// we specify only the name and get a non-persistent cannel in return. Non 821 /// we specify only the name and get a non-persistent cannel in return. Non
813 /// persistent means that the channel gets deleted if no-one uses it for 822 /// persistent means that the channel gets deleted if no-one uses it for
814 /// 5 hours. To accomodate future requirements, it may be a good idea to 823 /// 5 hours. To accomodate future requirements, it may be a good idea to
815 /// initially create channels under the umbrella of a parent ID based upon 824 /// initially create channels under the umbrella of a parent ID based upon
816 /// the region name. That way we have a context for side channels, if those 825 /// the region name. That way we have a context for side channels, if those
817 /// are required in a later phase. 826 /// are required in a later phase.
818 /// 827 ///
819 /// In this case the call handles parent and description as optional values. 828 /// In this case the call handles parent and description as optional values.
820 /// </summary> 829 /// </summary>
821 private bool VivoxTryCreateChannel(string parent, string channelId, string description, out string channelUri) 830 private bool VivoxTryCreateChannel(string parent, string channelId, string description, out string channelUri)
@@ -837,7 +846,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
837 requrl = String.Format("{0}&chan_dist_model={1}", requrl, m_vivoxChannelDistanceModel); 846 requrl = String.Format("{0}&chan_dist_model={1}", requrl, m_vivoxChannelDistanceModel);
838 requrl = String.Format("{0}&chan_max_range={1}", requrl, m_vivoxChannelMaximumRange); 847 requrl = String.Format("{0}&chan_max_range={1}", requrl, m_vivoxChannelMaximumRange);
839 requrl = String.Format("{0}&chan_clamping_distance={1}", requrl, m_vivoxChannelClampingDistance); 848 requrl = String.Format("{0}&chan_clamping_distance={1}", requrl, m_vivoxChannelClampingDistance);
840 849
841 XmlElement resp = VivoxCall(requrl, true); 850 XmlElement resp = VivoxCall(requrl, true);
842 if (XmlFind(resp, "response.level0.body.chan_uri", out channelUri)) 851 if (XmlFind(resp, "response.level0.body.chan_uri", out channelUri))
843 return true; 852 return true;
@@ -880,7 +889,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
880 889
881 /// <summary> 890 /// <summary>
882 /// Retrieve a channel. 891 /// Retrieve a channel.
883 /// Once again, there a multitude of options possible. In the simplest case 892 /// Once again, there a multitude of options possible. In the simplest case
884 /// we specify only the name and get a non-persistent cannel in return. Non 893 /// we specify only the name and get a non-persistent cannel in return. Non
885 /// persistent means that the channel gets deleted if no-one uses it for 894 /// persistent means that the channel gets deleted if no-one uses it for
886 /// 5 hours. To accomodate future requirements, it may be a good idea to 895 /// 5 hours. To accomodate future requirements, it may be a good idea to
@@ -889,7 +898,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
889 /// are required in a later phase. 898 /// are required in a later phase.
890 /// In this case the call handles parent and description as optional values. 899 /// In this case the call handles parent and description as optional values.
891 /// </summary> 900 /// </summary>
892 private bool VivoxTryGetChannel(string channelParent, string channelName, 901 private bool VivoxTryGetChannel(string channelParent, string channelName,
893 out string channelId, out string channelUri) 902 out string channelId, out string channelUri)
894 { 903 {
895 string count; 904 string count;
@@ -997,7 +1006,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
997 string type; 1006 string type;
998 1007
999 // skip if not a directory 1008 // skip if not a directory
1000 if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.type", i, out type) || 1009 if (!XmlFind(resp, "response.level0.channel-search.channels.channels.level4.type", i, out type) ||
1001 type != "dir") 1010 type != "dir")
1002 continue; 1011 continue;
1003 1012
@@ -1019,7 +1028,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1019 return false; 1028 return false;
1020 } 1029 }
1021 1030
1022 // private static readonly string m_vivoxChannelById = "http://{0}/api2/viv_chan_mod.php?mode={1}&chan_id={2}&auth_token={3}"; 1031 // private static readonly string m_vivoxChannelById = "https://{0}/api2/viv_chan_mod.php?mode={1}&chan_id={2}&auth_token={3}";
1023 1032
1024 // private XmlElement VivoxGetChannelById(string parent, string channelid) 1033 // private XmlElement VivoxGetChannelById(string parent, string channelid)
1025 // { 1034 // {
@@ -1035,7 +1044,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1035 1044
1036 /// <summary> 1045 /// <summary>
1037 /// Delete a channel. 1046 /// Delete a channel.
1038 /// Once again, there a multitude of options possible. In the simplest case 1047 /// Once again, there a multitude of options possible. In the simplest case
1039 /// we specify only the name and get a non-persistent cannel in return. Non 1048 /// we specify only the name and get a non-persistent cannel in return. Non
1040 /// persistent means that the channel gets deleted if no-one uses it for 1049 /// persistent means that the channel gets deleted if no-one uses it for
1041 /// 5 hours. To accomodate future requirements, it may be a good idea to 1050 /// 5 hours. To accomodate future requirements, it may be a good idea to
@@ -1044,6 +1053,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1044 /// are required in a later phase. 1053 /// are required in a later phase.
1045 /// In this case the call handles parent and description as optional values. 1054 /// In this case the call handles parent and description as optional values.
1046 /// </summary> 1055 /// </summary>
1056
1047 private XmlElement VivoxDeleteChannel(string parent, string channelid) 1057 private XmlElement VivoxDeleteChannel(string parent, string channelid)
1048 { 1058 {
1049 string requrl = String.Format(m_vivoxChannelDel, m_vivoxServer, "delete", channelid, m_authToken); 1059 string requrl = String.Format(m_vivoxChannelDel, m_vivoxServer, "delete", channelid, m_authToken);
@@ -1059,6 +1069,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1059 /// <summary> 1069 /// <summary>
1060 /// Return information on channels in the given directory 1070 /// Return information on channels in the given directory
1061 /// </summary> 1071 /// </summary>
1072
1062 private XmlElement VivoxListChildren(string channelid) 1073 private XmlElement VivoxListChildren(string channelid)
1063 { 1074 {
1064 string requrl = String.Format(m_vivoxChannelSearch, m_vivoxServer, channelid, m_authToken); 1075 string requrl = String.Format(m_vivoxChannelSearch, m_vivoxServer, channelid, m_authToken);
@@ -1087,7 +1098,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1087 // return VivoxGetChannelById(null, id); 1098 // return VivoxGetChannelById(null, id);
1088 // } 1099 // }
1089 // } 1100 // }
1090 // } 1101 // }
1091 // } 1102 // }
1092 // } 1103 // }
1093 1104
@@ -1095,12 +1106,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1095 // return VivoxGetChannel(null, Guid.NewGuid().ToString()); 1106 // return VivoxGetChannel(null, Guid.NewGuid().ToString());
1096 1107
1097 // } 1108 // }
1098 1109
1099 /// <summary> 1110 /// <summary>
1100 /// This method handles the WEB side of making a request over the 1111 /// This method handles the WEB side of making a request over the
1101 /// Vivox interface. The returned values are tansferred to a has 1112 /// Vivox interface. The returned values are tansferred to a has
1102 /// table which is returned as the result. 1113 /// table which is returned as the result.
1103 /// The outcome of the call can be determined by examining the 1114 /// The outcome of the call can be determined by examining the
1104 /// status value in the hash table. 1115 /// status value in the hash table.
1105 /// </summary> 1116 /// </summary>
1106 private XmlElement VivoxCall(string requrl, bool admin) 1117 private XmlElement VivoxCall(string requrl, bool admin)
@@ -1114,9 +1125,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1114 return null; 1125 return null;
1115 1126
1116 doc = new XmlDocument(); 1127 doc = new XmlDocument();
1128 doc.XmlResolver = null;
1117 1129
1118 // Let's serialize all calls to Vivox. Most of these are driven by 1130 // Let's serialize all calls to Vivox. Most of these are driven by
1119 // the clients (CAPs), when the user arrives at the region. We don't 1131 // the clients (CAPs), when the user arrives at the region. We don't
1120 // want to issue many simultaneous http requests to Vivox, because mono 1132 // want to issue many simultaneous http requests to Vivox, because mono
1121 // doesn't like that 1133 // doesn't like that
1122 lock (m_Lock) 1134 lock (m_Lock)
@@ -1124,7 +1136,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1124 try 1136 try
1125 { 1137 {
1126 // Otherwise prepare the request 1138 // Otherwise prepare the request
1127 m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl); 1139 //m_log.DebugFormat("[VivoxVoice] Sending request <{0}>", requrl);
1128 1140
1129 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl); 1141 HttpWebRequest req = (HttpWebRequest)WebRequest.Create(requrl);
1130 1142
@@ -1135,7 +1147,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1135 using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse()) 1147 using (HttpWebResponse rsp = (HttpWebResponse)req.GetResponse())
1136 using (Stream s = rsp.GetResponseStream()) 1148 using (Stream s = rsp.GetResponseStream())
1137 using (XmlTextReader rdr = new XmlTextReader(s)) 1149 using (XmlTextReader rdr = new XmlTextReader(s))
1138 doc.Load(rdr); 1150 {
1151 rdr.ProhibitDtd = true;
1152 doc.Load(rdr);
1153 }
1139 } 1154 }
1140 catch (Exception e) 1155 catch (Exception e)
1141 { 1156 {
@@ -1162,7 +1177,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1162 1177
1163 /// <summary> 1178 /// <summary>
1164 /// Login has been factored in this way because it gets called 1179 /// Login has been factored in this way because it gets called
1165 /// from several places in the module, and we want it to work 1180 /// from several places in the module, and we want it to work
1166 /// the same way each time. 1181 /// the same way each time.
1167 /// </summary> 1182 /// </summary>
1168 private bool DoAdminLogin() 1183 private bool DoAdminLogin()
@@ -1177,15 +1192,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1177 XmlElement resp = null; 1192 XmlElement resp = null;
1178 1193
1179 resp = VivoxLogin(m_vivoxAdminUser, m_vivoxAdminPassword); 1194 resp = VivoxLogin(m_vivoxAdminUser, m_vivoxAdminPassword);
1180 1195
1181 if (XmlFind(resp, "response.level0.body.status", out status)) 1196 if (XmlFind(resp, "response.level0.body.status", out status))
1182 { 1197 {
1183 if (status == "Ok") 1198 if (status == "Ok")
1184 { 1199 {
1185 m_log.Info("[VivoxVoice] Admin connection established"); 1200 m_log.Info("[VivoxVoice] Admin connection established");
1186 if (XmlFind(resp, "response.level0.body.auth_token", out m_authToken)) 1201 if (XmlFind(resp, "response.level0.body.auth_token", out m_authToken))
1187 { 1202 {
1188 if (m_dumpXml) m_log.DebugFormat("[VivoxVoice] Auth Token <{0}>", 1203 if (m_dumpXml) m_log.DebugFormat("[VivoxVoice] Auth Token <{0}>",
1189 m_authToken); 1204 m_authToken);
1190 m_adminConnected = true; 1205 m_adminConnected = true;
1191 } 1206 }
@@ -1204,9 +1219,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1204 1219
1205 /// <summary> 1220 /// <summary>
1206 /// The XmlScan routine is provided to aid in the 1221 /// The XmlScan routine is provided to aid in the
1207 /// reverse engineering of incompletely 1222 /// reverse engineering of incompletely
1208 /// documented packets returned by the Vivox 1223 /// documented packets returned by the Vivox
1209 /// voice server. It is only called if the 1224 /// voice server. It is only called if the
1210 /// m_dumpXml switch is set. 1225 /// m_dumpXml switch is set.
1211 /// </summary> 1226 /// </summary>
1212 private void XmlScanl(XmlElement e, int index) 1227 private void XmlScanl(XmlElement e, int index)
@@ -1251,7 +1266,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1251 private bool XmlFind(XmlElement root, string tag, int nth, out string result) 1266 private bool XmlFind(XmlElement root, string tag, int nth, out string result)
1252 { 1267 {
1253 if (root == null || tag == null || tag == String.Empty) 1268 if (root == null || tag == null || tag == String.Empty)
1254 { 1269 {
1255 result = String.Empty; 1270 result = String.Empty;
1256 return false; 1271 return false;
1257 } 1272 }
@@ -1262,7 +1277,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1262 { 1277 {
1263 int nth = 0; 1278 int nth = 0;
1264 if (root == null || tag == null || tag == String.Empty) 1279 if (root == null || tag == null || tag == String.Empty)
1265 { 1280 {
1266 result = String.Empty; 1281 result = String.Empty;
1267 return false; 1282 return false;
1268 } 1283 }
@@ -1273,7 +1288,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1273 /// XmlSearch is initially called by XmlFind, and then 1288 /// XmlSearch is initially called by XmlFind, and then
1274 /// recursively called by itself until the document 1289 /// recursively called by itself until the document
1275 /// supplied to XmlFind is either exhausted or the name hierarchy 1290 /// supplied to XmlFind is either exhausted or the name hierarchy
1276 /// is matched. 1291 /// is matched.
1277 /// 1292 ///
1278 /// If the hierarchy is matched, the value is returned in 1293 /// If the hierarchy is matched, the value is returned in
1279 /// result, and true returned as the function's 1294 /// result, and true returned as the function's
@@ -1287,7 +1302,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1287 result = String.Empty; 1302 result = String.Empty;
1288 return false; 1303 return false;
1289 } 1304 }
1290 1305
1291 if (tags.Length-index == 1) 1306 if (tags.Length-index == 1)
1292 { 1307 {
1293 if (nth == 0) 1308 if (nth == 0)
@@ -1324,5 +1339,21 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
1324 result = String.Empty; 1339 result = String.Empty;
1325 return false; 1340 return false;
1326 } 1341 }
1342
1343 private void HandleDebug(string module, string[] cmd)
1344 {
1345 if (cmd.Length < 3)
1346 {
1347 MainConsole.Instance.Output("Error: missing on/off flag");
1348 return;
1349 }
1350
1351 if (cmd[2] == "on")
1352 m_dumpXml = true;
1353 else if (cmd[2] == "off")
1354 m_dumpXml = false;
1355 else
1356 MainConsole.Instance.Output("Error: only on and off are supported");
1357 }
1327 } 1358 }
1328} 1359}
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
index e1b6abb..8791235 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
@@ -125,7 +125,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
125 { 125 {
126 if (!m_groupMessagingEnabled) 126 if (!m_groupMessagingEnabled)
127 return; 127 return;
128 128
129 scene.RegisterModuleInterface<IGroupsMessagingModule>(this); 129 scene.RegisterModuleInterface<IGroupsMessagingModule>(this);
130 130
131 scene.AddCommand( 131 scene.AddCommand(
@@ -136,7 +136,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
136 "This setting turns on very verbose groups messaging debugging", 136 "This setting turns on very verbose groups messaging debugging",
137 HandleDebugGroupsMessagingVerbose); 137 HandleDebugGroupsMessagingVerbose);
138 } 138 }
139 139
140 public void RegionLoaded(Scene scene) 140 public void RegionLoaded(Scene scene)
141 { 141 {
142 if (!m_groupMessagingEnabled) 142 if (!m_groupMessagingEnabled)
@@ -205,7 +205,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
205 m_msgTransferModule = null; 205 m_msgTransferModule = null;
206 } 206 }
207 207
208 public Type ReplaceableInterface 208 public Type ReplaceableInterface
209 { 209 {
210 get { return null; } 210 get { return null; }
211 } 211 }
@@ -253,7 +253,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
253 { 253 {
254 if (m_debugEnabled) 254 if (m_debugEnabled)
255 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 255 m_log.DebugFormat("[GROUPS-MESSAGING]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
256 256
257 GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null); 257 GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null);
258 258
259 if (groupInfo != null) 259 if (groupInfo != null)
@@ -270,7 +270,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
270 { 270 {
271 SendMessageToGroup(im, groupID, new UUID(im.fromAgentID), null); 271 SendMessageToGroup(im, groupID, new UUID(im.fromAgentID), null);
272 } 272 }
273 273
274 public void SendMessageToGroup( 274 public void SendMessageToGroup(
275 GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func<GroupMembersData, bool> sendCondition) 275 GridInstantMessage im, UUID groupID, UUID sendingAgentForGroupCalls, Func<GroupMembersData, bool> sendCondition)
276 { 276 {
@@ -294,28 +294,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
294 m_usersOnlineCache.Add(groupID, onlineAgents, m_usersOnlineCacheExpirySeconds); 294 m_usersOnlineCache.Add(groupID, onlineAgents, m_usersOnlineCacheExpirySeconds);
295 } 295 }
296 296
297 attemptDeliveryUuidSet 297 attemptDeliveryUuidSet
298 = new HashSet<string>(Array.ConvertAll<PresenceInfo, string>(onlineAgents, pi => pi.UserID)); 298 = new HashSet<string>(Array.ConvertAll<PresenceInfo, string>(onlineAgents, pi => pi.UserID));
299
300 //Array.ForEach<PresenceInfo>(onlineAgents, pi => attemptDeliveryUuidSet.Add(pi.UserID));
301
302 //groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList();
303
304 // if (m_debugEnabled)
305// m_log.DebugFormat(
306// "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members, {2} online",
307// groupID, groupMembersCount, groupMembers.Count());
308 } 299 }
309 else 300 else
310 { 301 {
311 attemptDeliveryUuidSet 302 attemptDeliveryUuidSet
312 = new HashSet<string>(groupMembers.ConvertAll<string>(gmd => gmd.AgentID.ToString())); 303 = new HashSet<string>(groupMembers.ConvertAll<string>(gmd => gmd.AgentID.ToString()));
313 304
314 if (m_debugEnabled) 305 if (m_debugEnabled)
315 m_log.DebugFormat( 306 m_log.DebugFormat(
316 "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members", 307 "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members",
317 groupID, groupMembers.Count); 308 groupID, groupMembers.Count);
318 } 309 }
319 310
320 foreach (GroupMembersData member in groupMembers) 311 foreach (GroupMembersData member in groupMembers)
321 { 312 {
@@ -323,9 +314,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
323 { 314 {
324 if (!sendCondition(member)) 315 if (!sendCondition(member))
325 { 316 {
326 if (m_debugEnabled) 317 if (m_debugEnabled)
327 m_log.DebugFormat( 318 m_log.DebugFormat(
328 "[GROUPS-MESSAGING]: Not sending to {0} as they do not fulfill send condition", 319 "[GROUPS-MESSAGING]: Not sending to {0} as they do not fulfill send condition",
329 member.AgentID); 320 member.AgentID);
330 321
331 continue; 322 continue;
@@ -334,7 +325,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
334 else if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID)) 325 else if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID))
335 { 326 {
336 // Don't deliver messages to people who have dropped this session 327 // Don't deliver messages to people who have dropped this session
337 if (m_debugEnabled) 328 if (m_debugEnabled)
338 m_log.DebugFormat( 329 m_log.DebugFormat(
339 "[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID); 330 "[GROUPS-MESSAGING]: {0} has dropped session, not delivering to them", member.AgentID);
340 331
@@ -369,9 +360,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
369 // If they're not local, forward across the grid 360 // If they're not local, forward across the grid
370 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { }); 361 m_msgTransferModule.SendInstantMessage(msg, delegate(bool success) { });
371 362
372 if (m_debugEnabled) 363 if (m_debugEnabled)
373 m_log.DebugFormat( 364 m_log.DebugFormat(
374 "[GROUPS-MESSAGING]: Delivering to {0} via grid took {1} ms", 365 "[GROUPS-MESSAGING]: Delivering to {0} via grid took {1} ms",
375 member.AgentID, Environment.TickCount - startTick); 366 member.AgentID, Environment.TickCount - startTick);
376 } 367 }
377 else 368 else
@@ -381,21 +372,22 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
381 ProcessMessageFromGroupSession(msg, client); 372 ProcessMessageFromGroupSession(msg, client);
382 373
383 // Deliver locally, directly 374 // Deliver locally, directly
384 if (m_debugEnabled) 375 if (m_debugEnabled)
385 m_log.DebugFormat( 376 m_log.DebugFormat(
386 "[GROUPS-MESSAGING]: Delivering to {0} locally took {1} ms", 377 "[GROUPS-MESSAGING]: Delivering to {0} locally took {1} ms",
387 member.AgentID, Environment.TickCount - startTick); 378 member.AgentID, Environment.TickCount - startTick);
388 } 379 }
389 } 380 }
390 else 381 else if(im.dialog != (byte)InstantMessageDialog.SessionAdd &&
382 im.dialog != (byte)InstantMessageDialog.SessionDrop)
391 { 383 {
392 int startTick = Environment.TickCount; 384 int startTick = Environment.TickCount;
393 385
394 m_msgTransferModule.HandleUndeliverableMessage(msg, delegate(bool success) { }); 386 m_msgTransferModule.HandleUndeliverableMessage(msg, delegate(bool success) { });
395 387
396 if (m_debugEnabled) 388 if (m_debugEnabled)
397 m_log.DebugFormat( 389 m_log.DebugFormat(
398 "[GROUPS-MESSAGING]: Handling undeliverable message for {0} took {1} ms", 390 "[GROUPS-MESSAGING]: Handling undeliverable message for {0} took {1} ms",
399 member.AgentID, Environment.TickCount - startTick); 391 member.AgentID, Environment.TickCount - startTick);
400 } 392 }
401 } 393 }
@@ -405,7 +397,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
405 "[GROUPS-MESSAGING]: Total SendMessageToGroup for group {0} with {1} members, {2} candidates for delivery took {3} ms", 397 "[GROUPS-MESSAGING]: Total SendMessageToGroup for group {0} with {1} members, {2} candidates for delivery took {3} ms",
406 groupID, groupMembersCount, attemptDeliveryUuidSet.Count(), Environment.TickCount - requestStartTick); 398 groupID, groupMembersCount, attemptDeliveryUuidSet.Count(), Environment.TickCount - requestStartTick);
407 } 399 }
408 400
409 #region SimGridEventHandlers 401 #region SimGridEventHandlers
410 402
411 void OnClientLogin(IClientAPI client) 403 void OnClientLogin(IClientAPI client)
@@ -425,7 +417,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
425 // The instant message module will only deliver messages of dialog types: 417 // The instant message module will only deliver messages of dialog types:
426 // MessageFromAgent, StartTyping, StopTyping, MessageFromObject 418 // MessageFromAgent, StartTyping, StopTyping, MessageFromObject
427 // 419 //
428 // Any other message type will not be delivered to a client by the 420 // Any other message type will not be delivered to a client by the
429 // Instant Message Module 421 // Instant Message Module
430 422
431 if (m_debugEnabled) 423 if (m_debugEnabled)
@@ -436,28 +428,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
436 } 428 }
437 429
438 // Incoming message from a group 430 // Incoming message from a group
439 if ((msg.fromGroup == true) && 431 if ((msg.fromGroup == true) &&
440 ((msg.dialog == (byte)InstantMessageDialog.SessionSend) 432 ((msg.dialog == (byte)InstantMessageDialog.SessionSend)
441 || (msg.dialog == (byte)InstantMessageDialog.SessionAdd) 433 || (msg.dialog == (byte)InstantMessageDialog.SessionAdd)
442 || (msg.dialog == (byte)InstantMessageDialog.SessionDrop))) 434 || (msg.dialog == (byte)InstantMessageDialog.SessionDrop)))
443 { 435 {
444 IClientAPI client = null; 436 IClientAPI client = null;
445 437
446 if (msg.dialog == (byte)InstantMessageDialog.SessionSend) 438 client = GetActiveClient(new UUID(msg.toAgentID));
447 {
448 client = GetActiveClient(new UUID(msg.toAgentID));
449 439
450 if (client != null) 440 if (client == null)
451 { 441 {
452 if (m_debugEnabled) 442 m_log.WarnFormat("[GROUPS-MESSAGING]: Received a message over the grid for a client that isn't here: {0}", msg.toAgentID);
453 m_log.DebugFormat("[GROUPS-MESSAGING]: Delivering to {0} locally", client.Name);
454 }
455 else
456 {
457 m_log.WarnFormat("[GROUPS-MESSAGING]: Received a message over the grid for a client that isn't here: {0}", msg.toAgentID);
458 443
459 return; 444 return;
460 }
461 } 445 }
462 446
463 ProcessMessageFromGroupSession(msg, client); 447 ProcessMessageFromGroupSession(msg, client);
@@ -466,83 +450,101 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
466 450
467 private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client) 451 private void ProcessMessageFromGroupSession(GridInstantMessage msg, IClientAPI client)
468 { 452 {
469 if (m_debugEnabled) 453 if (m_debugEnabled)
470 m_log.DebugFormat( 454 m_log.DebugFormat(
471 "[GROUPS-MESSAGING]: Session message from {0} going to agent {1}, sessionID {2}, type {3}", 455 "[GROUPS-MESSAGING]: Session message from {0} going to agent {1}, sessionID {2}, type {3}",
472 msg.fromAgentName, msg.toAgentID, msg.imSessionID, (InstantMessageDialog)msg.dialog); 456 msg.fromAgentName, msg.toAgentID, msg.imSessionID, (InstantMessageDialog)msg.dialog);
473 457
474 UUID AgentID = new UUID(msg.fromAgentID); 458 UUID fromAgentID = new UUID(msg.fromAgentID);
475 UUID GroupID = new UUID(msg.imSessionID); 459 UUID GroupID = new UUID(msg.imSessionID);
460 IEventQueue eq = client.Scene.RequestModuleInterface<IEventQueue>();
476 461
477 switch (msg.dialog) 462 switch (msg.dialog)
478 { 463 {
479 case (byte)InstantMessageDialog.SessionAdd: 464 case (byte)InstantMessageDialog.SessionAdd:
480 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); 465 m_groupData.AgentInvitedToGroupChatSession(fromAgentID, GroupID);
466 if(eq != null)
467 eq.ChatterBoxSessionAgentListUpdates(
468 GroupID
469 , fromAgentID
470 , client.AgentId
471 , false //canVoiceChat
472 , false //isModerator
473 , false //text mute
474 , true // enter
475 );
481 break; 476 break;
482 477
483 case (byte)InstantMessageDialog.SessionDrop: 478 case (byte)InstantMessageDialog.SessionDrop:
484 m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID); 479 m_groupData.AgentDroppedFromGroupChatSession(fromAgentID, GroupID);
480 if(eq != null)
481 eq.ChatterBoxSessionAgentListUpdates(
482 GroupID
483 , fromAgentID
484 , client.AgentId
485 , false //canVoiceChat
486 , false //isModerator
487 , false //text mute
488 , false // leave
489 );
485 break; 490 break;
486 491
487 case (byte)InstantMessageDialog.SessionSend: 492 case (byte)InstantMessageDialog.SessionSend:
488 if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID) 493 if (!m_groupData.hasAgentDroppedGroupChatSession(client.AgentId, GroupID))
489 && !m_groupData.hasAgentBeenInvitedToGroupChatSession(AgentID, GroupID)
490 )
491 { 494 {
492 // Agent not in session and hasn't dropped from session 495 if(!m_groupData.hasAgentBeenInvitedToGroupChatSession(client.AgentId, GroupID))
493 // Add them to the session for now, and Invite them
494 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
495
496 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
497 if (groupInfo != null)
498 { 496 {
499 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
500 497
501 // Force? open the group session dialog??? 498 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
502 // and simultanously deliver the message, so we don't need to do a seperate client.SendInstantMessage(msg); 499 if (groupInfo != null)
503 IEventQueue eq = client.Scene.RequestModuleInterface<IEventQueue>(); 500 {
504 eq.ChatterboxInvitation( 501 if (m_debugEnabled) m_log.DebugFormat("[GROUPS-MESSAGING]: Sending chatterbox invite instant message");
505 GroupID 502
506 , groupInfo.GroupName 503 if(eq != null)
507 , new UUID(msg.fromAgentID) 504 {
508 , msg.message 505 eq.ChatterboxInvitation(
509 , new UUID(msg.toAgentID) 506 GroupID
510 , msg.fromAgentName 507 , groupInfo.GroupName
511 , msg.dialog 508 , fromAgentID
512 , msg.timestamp 509 , msg.message
513 , msg.offline == 1 510 , client.AgentId
514 , (int)msg.ParentEstateID 511 , msg.fromAgentName
515 , msg.Position 512 , msg.dialog
516 , 1 513 , msg.timestamp
517 , new UUID(msg.imSessionID) 514 , msg.offline == 1
518 , msg.fromGroup 515 , (int)msg.ParentEstateID
519 , Utils.StringToBytes(groupInfo.GroupName) 516 , msg.Position
520 ); 517 , 1
521 518 , new UUID(msg.imSessionID)
522 eq.ChatterBoxSessionAgentListUpdates( 519 , msg.fromGroup
523 new UUID(GroupID) 520 , Utils.StringToBytes(groupInfo.GroupName)
524 , new UUID(msg.fromAgentID) 521 );
525 , new UUID(msg.toAgentID) 522 }
526 , false //canVoiceChat 523 }
527 , false //isModerator 524 }
528 , false //text mute 525 else
529 ); 526 {
527 client.SendInstantMessage(msg);
530 } 528 }
531 529
532 break; 530// if (!m_groupData.hasAgentBeenInvitedToGroupChatSession(fromAgentID, GroupID))
533 } 531 {
534 else if (!m_groupData.hasAgentDroppedGroupChatSession(AgentID, GroupID)) 532 m_groupData.AgentInvitedToGroupChatSession(fromAgentID, GroupID);
535 { 533 eq.ChatterBoxSessionAgentListUpdates(
536 // User hasn't dropped, so they're in the session, 534 GroupID
537 // maybe we should deliver it. 535 , fromAgentID
538 client.SendInstantMessage(msg); 536 , client.AgentId
537 , false //canVoiceChat
538 , false //isModerator
539 , false //text mute
540 , true // enter
541 );
542 }
539 } 543 }
540
541 break; 544 break;
542 545
543 default: 546 default:
544 client.SendInstantMessage(msg); 547 client.SendInstantMessage(msg);
545
546 break;; 548 break;;
547 } 549 }
548 } 550 }
@@ -559,41 +561,32 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
559 DebugGridInstantMessage(im); 561 DebugGridInstantMessage(im);
560 } 562 }
561 563
564 UUID GroupID = new UUID(im.imSessionID);
565 UUID AgentID = new UUID(im.fromAgentID);
566
562 // Start group IM session 567 // Start group IM session
563 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart)) 568 if ((im.dialog == (byte)InstantMessageDialog.SessionGroupStart))
564 { 569 {
565 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID); 570 if (m_debugEnabled) m_log.InfoFormat("[GROUPS-MESSAGING]: imSessionID({0}) toAgentID({1})", im.imSessionID, im.toAgentID);
566 571
567 UUID GroupID = new UUID(im.imSessionID);
568 UUID AgentID = new UUID(im.fromAgentID);
569
570 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null); 572 GroupRecord groupInfo = m_groupData.GetGroupRecord(UUID.Zero, GroupID, null);
571 573
572 if (groupInfo != null) 574 if (groupInfo != null)
573 { 575 {
574 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID); 576 m_groupData.AgentInvitedToGroupChatSession(AgentID, GroupID);
575 577
576 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID); 578 ChatterBoxSessionStartReplyViaCaps(remoteClient, groupInfo.GroupName, GroupID);
577 579
578 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>(); 580 // we need to send here a list of known participants.
579 queue.ChatterBoxSessionAgentListUpdates( 581 im.dialog = (byte)InstantMessageDialog.SessionAdd;
580 GroupID 582 SendMessageToGroup(im, GroupID);
581 , AgentID
582 , new UUID(im.toAgentID)
583 , false //canVoiceChat
584 , false //isModerator
585 , false //text mute
586 );
587 } 583 }
588 } 584 }
589 585
590 // Send a message from locally connected client to a group 586 // Send a message from locally connected client to a group
591 if ((im.dialog == (byte)InstantMessageDialog.SessionSend)) 587 if ((im.dialog == (byte)InstantMessageDialog.SessionSend))
592 { 588 {
593 UUID GroupID = new UUID(im.imSessionID); 589 if (m_debugEnabled)
594 UUID AgentID = new UUID(im.fromAgentID);
595
596 if (m_debugEnabled)
597 m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString()); 590 m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString());
598 591
599 //If this agent is sending a message, then they want to be in the session 592 //If this agent is sending a message, then they want to be in the session
@@ -601,6 +594,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
601 594
602 SendMessageToGroup(im, GroupID); 595 SendMessageToGroup(im, GroupID);
603 } 596 }
597
598 if ((im.dialog == (byte)InstantMessageDialog.SessionDrop))
599 {
600 if (m_debugEnabled)
601 m_log.DebugFormat("[GROUPS-MESSAGING]: Send message to session for group {0} with session ID {1}", GroupID, im.imSessionID.ToString());
602
603 m_groupData.AgentDroppedFromGroupChatSession(AgentID, GroupID);
604
605 SendMessageToGroup(im, GroupID);
606 }
604 } 607 }
605 608
606 #endregion 609 #endregion
@@ -656,7 +659,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
656 /// </summary> 659 /// </summary>
657 private IClientAPI GetActiveClient(UUID agentID) 660 private IClientAPI GetActiveClient(UUID agentID)
658 { 661 {
659 if (m_debugEnabled) 662 if (m_debugEnabled)
660 m_log.DebugFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID); 663 m_log.DebugFormat("[GROUPS-MESSAGING]: Looking for local client {0}", agentID);
661 664
662 IClientAPI child = null; 665 IClientAPI child = null;
@@ -669,14 +672,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
669 { 672 {
670 if (!sp.IsChildAgent) 673 if (!sp.IsChildAgent)
671 { 674 {
672 if (m_debugEnabled) 675 if (m_debugEnabled)
673 m_log.DebugFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name); 676 m_log.DebugFormat("[GROUPS-MESSAGING]: Found root agent for client : {0}", sp.ControllingClient.Name);
674 677
675 return sp.ControllingClient; 678 return sp.ControllingClient;
676 } 679 }
677 else 680 else
678 { 681 {
679 if (m_debugEnabled) 682 if (m_debugEnabled)
680 m_log.DebugFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name); 683 m_log.DebugFormat("[GROUPS-MESSAGING]: Found child agent for client : {0}", sp.ControllingClient.Name);
681 684
682 child = sp.ControllingClient; 685 child = sp.ControllingClient;
@@ -687,12 +690,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
687 // If we didn't find a root, then just return whichever child we found, or null if none 690 // If we didn't find a root, then just return whichever child we found, or null if none
688 if (child == null) 691 if (child == null)
689 { 692 {
690 if (m_debugEnabled) 693 if (m_debugEnabled)
691 m_log.DebugFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID); 694 m_log.DebugFormat("[GROUPS-MESSAGING]: Could not find local client for agent : {0}", agentID);
692 } 695 }
693 else 696 else
694 { 697 {
695 if (m_debugEnabled) 698 if (m_debugEnabled)
696 m_log.DebugFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name); 699 m_log.DebugFormat("[GROUPS-MESSAGING]: Returning child agent for client : {0}", child.Name);
697 } 700 }
698 701
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 1565da9..65d50bb 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -50,19 +50,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
50 /// ; To use this module, you must specify the following in your OpenSim.ini 50 /// ; To use this module, you must specify the following in your OpenSim.ini
51 /// [GROUPS] 51 /// [GROUPS]
52 /// Enabled = true 52 /// Enabled = true
53 /// 53 ///
54 /// Module = GroupsModule 54 /// Module = GroupsModule
55 /// NoticesEnabled = true 55 /// NoticesEnabled = true
56 /// DebugEnabled = true 56 /// DebugEnabled = true
57 /// 57 ///
58 /// GroupsServicesConnectorModule = XmlRpcGroupsServicesConnector 58 /// GroupsServicesConnectorModule = XmlRpcGroupsServicesConnector
59 /// XmlRpcServiceURL = http://osflotsam.org/xmlrpc.php 59 /// XmlRpcServiceURL = http://osflotsam.org/xmlrpc.php
60 /// XmlRpcServiceReadKey = 1234 60 /// XmlRpcServiceReadKey = 1234
61 /// XmlRpcServiceWriteKey = 1234 61 /// XmlRpcServiceWriteKey = 1234
62 /// 62 ///
63 /// MessagingModule = GroupsMessagingModule 63 /// MessagingModule = GroupsMessagingModule
64 /// MessagingEnabled = true 64 /// MessagingEnabled = true
65 /// 65 ///
66 /// ; Disables HTTP Keep-Alive for Groups Module HTTP Requests, work around for 66 /// ; Disables HTTP Keep-Alive for Groups Module HTTP Requests, work around for
67 /// ; a problem discovered on some Windows based region servers. Only disable 67 /// ; a problem discovered on some Windows based region servers. Only disable
68 /// ; if you see a large number (dozens) of the following Exceptions: 68 /// ; if you see a large number (dozens) of the following Exceptions:
@@ -79,7 +79,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
79 private IMessageTransferModule m_msgTransferModule; 79 private IMessageTransferModule m_msgTransferModule;
80 80
81 private IGroupsMessagingModule m_groupsMessagingModule; 81 private IGroupsMessagingModule m_groupsMessagingModule;
82 82
83 private IGroupsServicesConnector m_groupData; 83 private IGroupsServicesConnector m_groupData;
84 84
85 // Configuration settings 85 // Configuration settings
@@ -205,10 +205,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
205 } 205 }
206 206
207 scene.EventManager.OnNewClient += OnNewClient; 207 scene.EventManager.OnNewClient += OnNewClient;
208 scene.EventManager.OnMakeRootAgent += OnMakeRoot;
209 scene.EventManager.OnMakeChildAgent += OnMakeChild;
208 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage; 210 scene.EventManager.OnIncomingInstantMessage += OnGridInstantMessage;
209 // The InstantMessageModule itself doesn't do this, 211 scene.EventManager.OnClientClosed += OnClientClosed;
210 // so lets see if things explode if we don't do it
211 // scene.EventManager.OnClientClosed += OnClientClosed;
212 212
213 } 213 }
214 214
@@ -217,6 +217,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
217 if (!m_groupsEnabled) 217 if (!m_groupsEnabled)
218 return; 218 return;
219 219
220 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
221
222 scene.EventManager.OnNewClient -= OnNewClient;
223 scene.EventManager.OnMakeRootAgent -= OnMakeRoot;
224 scene.EventManager.OnMakeChildAgent -= OnMakeChild;
225 scene.EventManager.OnIncomingInstantMessage -= OnGridInstantMessage;
226 scene.EventManager.OnClientClosed -= OnClientClosed;
220 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 227 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
221 228
222 lock (m_sceneList) 229 lock (m_sceneList)
@@ -233,7 +240,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
233 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module."); 240 if (m_debugEnabled) m_log.Debug("[GROUPS]: Shutting down Groups module.");
234 } 241 }
235 242
236 public Type ReplaceableInterface 243 public Type ReplaceableInterface
237 { 244 {
238 get { return null; } 245 get { return null; }
239 } 246 }
@@ -255,84 +262,124 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
255 #endregion 262 #endregion
256 263
257 #region EventHandlers 264 #region EventHandlers
265
266 private void OnMakeRoot(ScenePresence sp)
267 {
268 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
269
270 sp.ControllingClient.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
271 // Used for Notices and Group Invites/Accept/Reject
272 sp.ControllingClient.OnInstantMessage += OnInstantMessage;
273
274 // comented out because some viewers no longer suport it
275 // sp.ControllingClient.AddGenericPacketHandler("avatargroupsrequest", AvatarGroupsRequest);
276
277 // Send out group data update for compatibility.
278 // There might be some problem with the thread we're generating this on but not
279 // doing the update at this time causes problems (Mantis #7920 and #7915)
280 // TODO: move sending this update to a later time in the rootification of the client.
281 if(!sp.haveGroupInformation)
282 SendAgentGroupDataUpdate(sp.ControllingClient, false);
283 }
284
285 private void OnMakeChild(ScenePresence sp)
286 {
287 if (m_debugEnabled) m_log.DebugFormat("[Groups]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
288
289 sp.ControllingClient.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest;
290 sp.ControllingClient.OnInstantMessage -= OnInstantMessage;
291 }
292
258 private void OnNewClient(IClientAPI client) 293 private void OnNewClient(IClientAPI client)
259 { 294 {
260 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 295 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
261 296
262 client.OnUUIDGroupNameRequest += HandleUUIDGroupNameRequest;
263 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest; 297 client.OnAgentDataUpdateRequest += OnAgentDataUpdateRequest;
264 client.OnRequestAvatarProperties += OnRequestAvatarProperties; 298 client.OnRequestAvatarProperties += OnRequestAvatarProperties;
265 299
266 // Used for Notices and Group Invites/Accept/Reject
267 client.OnInstantMessage += OnInstantMessage;
268 300
269 // Send client their groups information.
270 SendAgentGroupDataUpdate(client, client.AgentId);
271 } 301 }
272 302
303/* this should be the right message to ask for other avatars groups
304
305 private void AvatarGroupsRequest(Object sender, string method, List<String> args)
306 {
307 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
308
309 if (!(sender is IClientAPI))
310 return;
311
312 IClientAPI remoteClient = (IClientAPI)sender;
313
314 UUID avatarID;
315 UUID.TryParse(args[0], out avatarID);
316
317 if (avatarID != UUID.Zero)
318 {
319 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
320 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
321 }
322 }
323*/
324
325 // this should not be used to send groups memberships, but some viewers do expect it
326 // it does send unnecessary memberships, when viewers just want other properties information
273 private void OnRequestAvatarProperties(IClientAPI remoteClient, UUID avatarID) 327 private void OnRequestAvatarProperties(IClientAPI remoteClient, UUID avatarID)
274 { 328 {
275 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 329 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
276 330
277 //GroupMembershipData[] avatarGroups = m_groupData.GetAgentGroupMemberships(GetRequestingAgentID(remoteClient), avatarID).ToArray();
278 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID); 331 GroupMembershipData[] avatarGroups = GetProfileListedGroupMemberships(remoteClient, avatarID);
279 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups); 332 remoteClient.SendAvatarGroupsReply(avatarID, avatarGroups);
280 } 333 }
281 334
282 /* 335
283 * This becomes very problematic in a shared module. In a shared module you may have more then one 336 private void OnClientClosed(UUID AgentId, Scene scene)
284 * reference to IClientAPI's, one for 0 or 1 root connections, and 0 or more child connections.
285 * The OnClientClosed event does not provide anything to indicate which one of those should be closed
286 * nor does it provide what scene it was from so that the specific reference can be looked up.
287 * The InstantMessageModule.cs does not currently worry about unregistering the handles,
288 * and it should be an issue, since it's the client that references us not the other way around
289 * , so as long as we don't keep a reference to the client laying around, the client can still be GC'ed
290 private void OnClientClosed(UUID AgentId)
291 { 337 {
292 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 338 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
339 if (scene == null)
340 return;
293 341
294 lock (m_ActiveClients) 342 ScenePresence sp = scene.GetScenePresence(AgentId);
343 IClientAPI client = sp.ControllingClient;
344 if (client != null)
295 { 345 {
296 if (m_ActiveClients.ContainsKey(AgentId)) 346 client.OnAgentDataUpdateRequest -= OnAgentDataUpdateRequest;
347 client.OnRequestAvatarProperties -= OnRequestAvatarProperties;
348 // make child possible not called?
349 client.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest;
350 client.OnInstantMessage -= OnInstantMessage;
351 }
352
353/*
354 lock (m_ActiveClients)
297 { 355 {
298 IClientAPI client = m_ActiveClients[AgentId]; 356 if (m_ActiveClients.ContainsKey(AgentId))
299 client.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest; 357 {
300 client.OnAgentDataUpdateRequest -= OnAgentDataUpdateRequest; 358 IClientAPI client = m_ActiveClients[AgentId];
301 client.OnDirFindQuery -= OnDirFindQuery; 359 client.OnUUIDGroupNameRequest -= HandleUUIDGroupNameRequest;
302 client.OnInstantMessage -= OnInstantMessage; 360 client.OnAgentDataUpdateRequest -= OnAgentDataUpdateRequest;
361 client.OnDirFindQuery -= OnDirFindQuery;
362 client.OnInstantMessage -= OnInstantMessage;
303 363
304 m_ActiveClients.Remove(AgentId); 364 m_ActiveClients.Remove(AgentId);
305 } 365 }
306 else 366 else
307 { 367 {
308 if (m_debugEnabled) m_log.WarnFormat("[GROUPS]: Client closed that wasn't registered here."); 368 if (m_debugEnabled) m_log.WarnFormat("[GROUPS]: Client closed that wasn't registered here.");
369 }
309 } 370 }
310 371*/
311
312 }
313 } 372 }
314 */
315 373
316 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID) 374 private void OnAgentDataUpdateRequest(IClientAPI remoteClient, UUID dataForAgentID, UUID sessionID)
317 { 375 {
318 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 376 // this a private message for own agent only
319 377 if (dataForAgentID != GetRequestingAgentID(remoteClient))
320 UUID activeGroupID = UUID.Zero; 378 return;
321 string activeGroupTitle = string.Empty;
322 string activeGroupName = string.Empty;
323 ulong activeGroupPowers = (ulong)GroupPowers.None;
324
325 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient), dataForAgentID);
326 if (membership != null)
327 {
328 activeGroupID = membership.GroupID;
329 activeGroupTitle = membership.GroupTitle;
330 activeGroupPowers = membership.GroupPowers;
331 }
332
333 SendAgentDataUpdate(remoteClient, dataForAgentID, activeGroupID, activeGroupName, activeGroupPowers, activeGroupTitle);
334 379
335 SendScenePresenceUpdate(dataForAgentID, activeGroupTitle); 380 SendAgentGroupDataUpdate(remoteClient, false);
381 // its a info request not a change, so nothing is sent to others
382 // they do get the group title with the avatar object update on arrivel to a region
336 } 383 }
337 384
338 private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient) 385 private void HandleUUIDGroupNameRequest(UUID GroupID, IClientAPI remoteClient)
@@ -340,7 +387,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
340 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 387 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
341 388
342 string GroupName; 389 string GroupName;
343 390
344 GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null); 391 GroupRecord group = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), GroupID, null);
345 if (group != null) 392 if (group != null)
346 { 393 {
@@ -356,9 +403,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
356 403
357 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im) 404 private void OnInstantMessage(IClientAPI remoteClient, GridInstantMessage im)
358 { 405 {
359 if (m_debugEnabled) 406 if (m_debugEnabled)
360 m_log.DebugFormat( 407 m_log.DebugFormat(
361 "[GROUPS]: {0} called for {1}, message type {2}", 408 "[GROUPS]: {0} called for {1}, message type {2}",
362 System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name, (InstantMessageDialog)im.dialog); 409 System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name, (InstantMessageDialog)im.dialog);
363 410
364 // Group invitations 411 // Group invitations
@@ -403,11 +450,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
403 450
404 OutgoingInstantMessage(msg, inviteInfo.AgentID); 451 OutgoingInstantMessage(msg, inviteInfo.AgentID);
405 452
406 UpdateAllClientsWithGroupInfo(inviteInfo.AgentID); 453 IClientAPI inviteeClient = GetActiveRootClient(inviteInfo.AgentID);
407 454 if(inviteeClient !=null)
408 // TODO: If the inviter is still online, they need an agent dataupdate 455 {
409 // and maybe group membership updates for the invitee 456 SendAgentGroupDataUpdate(inviteeClient,true);
410 457 }
411 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID); 458 m_groupData.RemoveAgentToGroupInvite(GetRequestingAgentID(remoteClient), inviteID);
412 } 459 }
413 460
@@ -459,8 +506,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
459 //variable will be set to null and attachment will 506 //variable will be set to null and attachment will
460 //not be included with the group notice. 507 //not be included with the group notice.
461 Scene scene = (Scene)remoteClient.Scene; 508 Scene scene = (Scene)remoteClient.Scene;
462 item = new InventoryItemBase(itemID, ownerID); 509 item = scene.InventoryService.GetItem(ownerID, itemID);
463 item = scene.InventoryService.GetItem(item);
464 510
465 if (item != null) 511 if (item != null)
466 { 512 {
@@ -523,20 +569,20 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
523 if (targetUser != null) 569 if (targetUser != null)
524 { 570 {
525 m_log.DebugFormat( 571 m_log.DebugFormat(
526 "[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", 572 "[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})",
527 NoticeID, targetUser.FirstName + " " + targetUser.LastName, member.AcceptNotices); 573 NoticeID, targetUser.FirstName + " " + targetUser.LastName, member.AcceptNotices);
528 } 574 }
529 else 575 else
530 { 576 {
531 m_log.DebugFormat( 577 m_log.DebugFormat(
532 "[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})", 578 "[GROUPS]: Prepping group notice {0} for agent: {1} who Accepts Notices ({2})",
533 NoticeID, member.AgentID, member.AcceptNotices); 579 NoticeID, member.AgentID, member.AcceptNotices);
534 } 580 }
535 } 581 }
536 } 582 }
537 } 583 }
538 584
539 GridInstantMessage msg 585 GridInstantMessage msg
540 = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice); 586 = CreateGroupNoticeIM(UUID.Zero, NoticeID, (byte)OpenMetaverse.InstantMessageDialog.GroupNotice);
541 587
542 if (m_groupsMessagingModule != null) 588 if (m_groupsMessagingModule != null)
@@ -553,7 +599,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
553 599
554 UUID noticeID = new UUID(im.imSessionID); 600 UUID noticeID = new UUID(im.imSessionID);
555 601
556 if (m_debugEnabled) 602 if (m_debugEnabled)
557 m_log.DebugFormat("[GROUPS]: Requesting notice {0} for {1}", noticeID, remoteClient.AgentId); 603 m_log.DebugFormat("[GROUPS]: Requesting notice {0} for {1}", noticeID, remoteClient.AgentId);
558 604
559 GroupNoticeInfo notice = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), noticeID); 605 GroupNoticeInfo notice = m_groupData.GetGroupNotice(GetRequestingAgentID(remoteClient), noticeID);
@@ -579,10 +625,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
579 } 625 }
580 else 626 else
581 { 627 {
582 if (m_debugEnabled) 628 if (m_debugEnabled)
583 m_log.DebugFormat( 629 m_log.DebugFormat(
584 "[GROUPS]: Could not find notice {0} for {1} on GroupNoticeInventoryAccepted.", 630 "[GROUPS]: Could not find notice {0} for {1} on GroupNoticeInventoryAccepted.",
585 noticeID, remoteClient.AgentId); 631 noticeID, remoteClient.AgentId);
586 } 632 }
587 } 633 }
588 634
@@ -598,15 +644,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
598 // so we need to send local updates to the agent. 644 // so we need to send local updates to the agent.
599 645
600 UUID ejecteeID = new UUID(im.toAgentID); 646 UUID ejecteeID = new UUID(im.toAgentID);
601 647 im.imSessionID = UUID.Zero.Guid;
602 im.dialog = (byte)InstantMessageDialog.MessageFromAgent; 648 im.dialog = (byte)InstantMessageDialog.MessageFromAgent;
603 OutgoingInstantMessage(im, ejecteeID); 649 OutgoingInstantMessage(im, ejecteeID);
604 650
605 IClientAPI ejectee = GetActiveClient(ejecteeID); 651 IClientAPI ejectee = GetActiveRootClient(ejecteeID);
606 if (ejectee != null) 652 if (ejectee != null)
607 { 653 {
608 UUID groupID = new UUID(im.imSessionID); 654 UUID groupID = new UUID(im.imSessionID);
609 ejectee.SendAgentDropGroup(groupID); 655 ejectee.SendAgentDropGroup(groupID);
656 SendAgentGroupDataUpdate(ejectee,true);
610 } 657 }
611 } 658 }
612 } 659 }
@@ -626,7 +673,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
626 case (byte)InstantMessageDialog.GroupInvitation: 673 case (byte)InstantMessageDialog.GroupInvitation:
627 case (byte)InstantMessageDialog.GroupNotice: 674 case (byte)InstantMessageDialog.GroupNotice:
628 UUID toAgentID = new UUID(msg.toAgentID); 675 UUID toAgentID = new UUID(msg.toAgentID);
629 IClientAPI localClient = GetActiveClient(toAgentID); 676 IClientAPI localClient = GetActiveRootClient(toAgentID);
630 if (localClient != null) 677 if (localClient != null)
631 { 678 {
632 localClient.SendInstantMessage(msg); 679 localClient.SendInstantMessage(msg);
@@ -651,18 +698,16 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
651 { 698 {
652 return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name); 699 return m_groupData.GetGroupRecord(UUID.Zero, UUID.Zero, name);
653 } 700 }
654 701
655 public void ActivateGroup(IClientAPI remoteClient, UUID groupID) 702 public void ActivateGroup(IClientAPI remoteClient, UUID groupID)
656 { 703 {
657 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 704 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
658 705
659 m_groupData.SetAgentActiveGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 706 UUID agentID = GetRequestingAgentID(remoteClient);
707 m_groupData.SetAgentActiveGroup(agentID, agentID, groupID);
660 708
661 // Changing active group changes title, active powers, all kinds of things 709 // llClientView does this
662 // anyone who is in any region that can see this client, should probably be 710 SendAgentGroupDataUpdate(remoteClient, true);
663 // updated with new group info. At a minimum, they should get ScenePresence
664 // updated with new title.
665 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
666 } 711 }
667 712
668 /// <summary> 713 /// <summary>
@@ -672,7 +717,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
672 { 717 {
673 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 718 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
674 719
675
676 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 720 List<GroupRolesData> agentRoles = m_groupData.GetAgentGroupRoles(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
677 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID); 721 GroupMembershipData agentMembership = m_groupData.GetAgentGroupMembership(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID);
678 722
@@ -695,10 +739,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
695 739
696 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID) 740 public List<GroupMembersData> GroupMembersRequest(IClientAPI remoteClient, UUID groupID)
697 { 741 {
698 if (m_debugEnabled) 742 if (m_debugEnabled)
699 m_log.DebugFormat( 743 m_log.DebugFormat(
700 "[GROUPS]: GroupMembersRequest called for {0} from client {1}", groupID, remoteClient.Name); 744 "[GROUPS]: GroupMembersRequest called for {0} from client {1}", groupID, remoteClient.Name);
701 745
702 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID); 746 List<GroupMembersData> data = m_groupData.GetGroupMembers(GetRequestingAgentID(remoteClient), groupID);
703 747
704 if (m_debugEnabled) 748 if (m_debugEnabled)
@@ -710,7 +754,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
710 } 754 }
711 755
712 return data; 756 return data;
713
714 } 757 }
715 758
716 public List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID) 759 public List<GroupRolesData> GroupRoleDataRequest(IClientAPI remoteClient, UUID groupID)
@@ -744,7 +787,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
744 787
745 GroupProfileData profile = new GroupProfileData(); 788 GroupProfileData profile = new GroupProfileData();
746 789
747
748 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null); 790 GroupRecord groupInfo = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
749 if (groupInfo != null) 791 if (groupInfo != null)
750 { 792 {
@@ -770,7 +812,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
770 profile.MemberTitle = memberInfo.GroupTitle; 812 profile.MemberTitle = memberInfo.GroupTitle;
771 profile.PowersMask = memberInfo.GroupPowers; 813 profile.PowersMask = memberInfo.GroupPowers;
772 } 814 }
773 815/*
816 this should save xmlrpc calls, but seems to return wrong GroupMembershipCount and GroupRolesCount
817 UUID agent = GetRequestingAgentID(remoteClient);
818 GroupProfileData profile = m_groupData.GetMemberGroupProfile(agent, groupID, agent);
819*/
774 return profile; 820 return profile;
775 } 821 }
776 822
@@ -783,7 +829,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
783 829
784 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID) 830 public GroupMembershipData GetMembershipData(UUID groupID, UUID agentID)
785 { 831 {
786 if (m_debugEnabled) 832 if (m_debugEnabled)
787 m_log.DebugFormat( 833 m_log.DebugFormat(
788 "[GROUPS]: {0} called with groupID={1}, agentID={2}", 834 "[GROUPS]: {0} called with groupID={1}, agentID={2}",
789 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID); 835 System.Reflection.MethodBase.GetCurrentMethod().Name, groupID, agentID);
@@ -791,6 +837,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
791 return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID); 837 return m_groupData.GetAgentGroupMembership(UUID.Zero, agentID, groupID);
792 } 838 }
793 839
840 public GroupMembershipData GetActiveMembershipData(UUID agentID)
841 {
842 return m_groupData.GetAgentActiveMembership(agentID, agentID);
843 }
844
794 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish) 845 public void UpdateGroupInfo(IClientAPI remoteClient, UUID groupID, string charter, bool showInList, UUID insigniaID, int membershipFee, bool openEnrollment, bool allowPublish, bool maturePublish)
795 { 846 {
796 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 847 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -811,7 +862,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
811 { 862 {
812 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 863 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
813 864
814 if (m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name) != null) 865 GroupRecord groupRecord = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), UUID.Zero, name);
866
867 if (groupRecord != null)
815 { 868 {
816 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists."); 869 remoteClient.SendCreateGroupReply(UUID.Zero, false, "A group with the same name already exists.");
817 return UUID.Zero; 870 return UUID.Zero;
@@ -824,31 +877,31 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
824 877
825 if (avatar != null) 878 if (avatar != null)
826 { 879 {
827 if (avatar.UserLevel < m_levelGroupCreate) 880 if (avatar.GodController.UserLevel < m_levelGroupCreate)
828 { 881 {
829 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got insufficient permissions to create a group."); 882 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have insufficient permissions to create a group.");
830 return UUID.Zero; 883 return UUID.Zero;
831 } 884 }
832 } 885 }
833 886
834 // check funds 887 // check funds
835 // is there is a money module present ? 888 // is there a money module present ?
836 IMoneyModule money = scene.RequestModuleInterface<IMoneyModule>(); 889 IMoneyModule money = scene.RequestModuleInterface<IMoneyModule>();
837 if (money != null) 890 if (money != null && money.GroupCreationCharge > 0)
838 { 891 {
839 // do the transaction, that is if the agent has got sufficient funds 892 // do the transaction, that is if the agent has sufficient funds
840 if (!money.AmountCovered(remoteClient.AgentId, money.GroupCreationCharge)) { 893 if (!money.AmountCovered(remoteClient.AgentId, money.GroupCreationCharge)) {
841 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have got insufficient funds to create a group."); 894 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have insufficient funds to create a group.");
842 return UUID.Zero; 895 return UUID.Zero;
843 } 896 }
844 money.ApplyCharge(GetRequestingAgentID(remoteClient), money.GroupCreationCharge, MoneyTransactionType.GroupCreate); 897 money.ApplyCharge(GetRequestingAgentID(remoteClient), money.GroupCreationCharge, MoneyTransactionType.GroupCreate, name);
845 } 898 }
846 UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient)); 899 UUID groupID = m_groupData.CreateGroup(GetRequestingAgentID(remoteClient), name, charter, showInList, insigniaID, membershipFee, openEnrollment, allowPublish, maturePublish, GetRequestingAgentID(remoteClient));
847 900
848 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); 901 remoteClient.SendCreateGroupReply(groupID, true, "Group created successfully");
849 902
850 // Update the founder with new group information. 903 // Update the founder with new group information.
851 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 904 SendAgentGroupDataUpdate(remoteClient, true);
852 905
853 return groupID; 906 return groupID;
854 } 907 }
@@ -873,7 +926,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
873 if (membership != null) 926 if (membership != null)
874 { 927 {
875 return membership.GroupTitle; 928 return membership.GroupTitle;
876 } 929 }
877 return string.Empty; 930 return string.Empty;
878 } 931 }
879 932
@@ -889,10 +942,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
889 // TODO: Not sure what all is needed here, but if the active group role change is for the group 942 // TODO: Not sure what all is needed here, but if the active group role change is for the group
890 // the client currently has set active, then we need to do a scene presence update too 943 // the client currently has set active, then we need to do a scene presence update too
891 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID) 944 // if (m_groupData.GetAgentActiveMembership(GetRequestingAgentID(remoteClient)).GroupID == GroupID)
892
893 UpdateAllClientsWithGroupInfo(GetRequestingAgentID(remoteClient));
894 }
895 945
946 SendDataUpdate(remoteClient, true);
947 }
896 948
897 public void GroupRoleUpdate(IClientAPI remoteClient, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, byte updateType) 949 public void GroupRoleUpdate(IClientAPI remoteClient, UUID groupID, UUID roleID, string name, string description, string title, ulong powers, byte updateType)
898 { 950 {
@@ -929,7 +981,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
929 } 981 }
930 982
931 // TODO: This update really should send out updates for everyone in the role that just got changed. 983 // TODO: This update really should send out updates for everyone in the role that just got changed.
932 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 984 SendAgentGroupDataUpdate(remoteClient, false);
933 } 985 }
934 986
935 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes) 987 public void GroupRoleChanges(IClientAPI remoteClient, UUID groupID, UUID roleID, UUID memberID, uint changes)
@@ -947,7 +999,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
947 case 1: 999 case 1:
948 // Remove 1000 // Remove
949 m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID); 1001 m_groupData.RemoveAgentFromGroupRole(GetRequestingAgentID(remoteClient), memberID, groupID, roleID);
950 1002
951 break; 1003 break;
952 default: 1004 default:
953 m_log.ErrorFormat("[GROUPS]: {0} does not understand changes == {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, changes); 1005 m_log.ErrorFormat("[GROUPS]: {0} does not understand changes == {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, changes);
@@ -955,7 +1007,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
955 } 1007 }
956 1008
957 // TODO: This update really should send out updates for everyone in the role that just got changed. 1009 // TODO: This update really should send out updates for everyone in the role that just got changed.
958 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 1010 SendAgentGroupDataUpdate(remoteClient, false);
959 } 1011 }
960 1012
961 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID) 1013 public void GroupNoticeRequest(IClientAPI remoteClient, UUID groupNoticeID)
@@ -983,7 +1035,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
983 msg.toAgentID = agentID.Guid; 1035 msg.toAgentID = agentID.Guid;
984 msg.dialog = dialog; 1036 msg.dialog = dialog;
985 msg.fromGroup = true; 1037 msg.fromGroup = true;
986 msg.offline = (byte)0; 1038 msg.offline = (byte)1; // Allow this message to be stored for offline use
987 msg.ParentEstateID = 0; 1039 msg.ParentEstateID = 0;
988 msg.Position = Vector3.Zero; 1040 msg.Position = Vector3.Zero;
989 msg.RegionID = UUID.Zero.Guid; 1041 msg.RegionID = UUID.Zero.Guid;
@@ -1035,14 +1087,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1035 return msg; 1087 return msg;
1036 } 1088 }
1037 1089
1038 public void SendAgentGroupDataUpdate(IClientAPI remoteClient)
1039 {
1040 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1041
1042 // Send agent information about his groups
1043 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
1044 }
1045
1046 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID) 1090 public void JoinGroupRequest(IClientAPI remoteClient, UUID groupID)
1047 { 1091 {
1048 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1092 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -1050,10 +1094,23 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1050 // Should check to see if OpenEnrollment, or if there's an outstanding invitation 1094 // Should check to see if OpenEnrollment, or if there's an outstanding invitation
1051 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero); 1095 m_groupData.AddAgentToGroup(GetRequestingAgentID(remoteClient), GetRequestingAgentID(remoteClient), groupID, UUID.Zero);
1052 1096
1097 // check funds
1098 // is there a money module present ?
1099 GroupRecord groupRecord = m_groupData.GetGroupRecord(GetRequestingAgentID(remoteClient), groupID, null);
1100 IMoneyModule money = remoteClient.Scene.RequestModuleInterface<IMoneyModule>();
1101 if (money != null && groupRecord.MembershipFee > 0)
1102 {
1103 // do the transaction, that is if the agent has sufficient funds
1104 if (!money.AmountCovered(GetRequestingAgentID(remoteClient), groupRecord.MembershipFee)) {
1105 remoteClient.SendCreateGroupReply(UUID.Zero, false, "You have insufficient funds to join the group.");
1106 return;
1107 }
1108 money.ApplyCharge(GetRequestingAgentID(remoteClient), groupRecord.MembershipFee, MoneyTransactionType.GroupJoin, groupRecord.GroupName);
1109 }
1110
1053 remoteClient.SendJoinGroupReply(groupID, true); 1111 remoteClient.SendJoinGroupReply(groupID, true);
1054 1112
1055 // Should this send updates to everyone in the group? 1113 SendAgentGroupDataUpdate(remoteClient, true);
1056 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient));
1057 } 1114 }
1058 1115
1059 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID) 1116 public void LeaveGroupRequest(IClientAPI remoteClient, UUID groupID)
@@ -1068,7 +1125,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1068 1125
1069 // SL sends out notifcations to the group messaging session that the person has left 1126 // SL sends out notifcations to the group messaging session that the person has left
1070 // Should this also update everyone who is in the group? 1127 // Should this also update everyone who is in the group?
1071 SendAgentGroupDataUpdate(remoteClient, GetRequestingAgentID(remoteClient)); 1128 SendAgentGroupDataUpdate(remoteClient, true);
1072 } 1129 }
1073 1130
1074 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID) 1131 public void EjectGroupMemberRequest(IClientAPI remoteClient, UUID groupID, UUID ejecteeID)
@@ -1120,17 +1177,41 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1120 } 1177 }
1121 1178
1122 GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null); 1179 GroupRecord groupInfo = m_groupData.GetGroupRecord(agentID, groupID, null);
1123 1180 if (groupInfo == null)
1124 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(regionInfo.ScopeID, ejecteeID);
1125 if ((groupInfo == null) || (account == null))
1126 {
1127 return; 1181 return;
1128 } 1182
1183
1184 IClientAPI ejecteeClient = GetActiveRootClient(ejecteeID);
1129 1185
1130 // Send Message to Ejectee 1186 // Send Message to Ejectee
1131 GridInstantMessage msg = new GridInstantMessage(); 1187 GridInstantMessage msg = new GridInstantMessage();
1132 1188
1133 msg.imSessionID = UUID.Zero.Guid; 1189 string ejecteeName = "Unknown member";
1190 // if local send a normal message
1191 if(ejecteeClient != null)
1192 {
1193 msg.imSessionID = UUID.Zero.Guid;
1194 msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent;
1195 // also execute and send update
1196 ejecteeClient.SendAgentDropGroup(groupID);
1197 SendAgentGroupDataUpdate(ejecteeClient,true);
1198 ejecteeName = ejecteeClient.Name;
1199 }
1200 else // send
1201 {
1202 // Interop, received special 210 code for ejecting a group member
1203 // this only works within the comms servers domain, and won't work hypergrid
1204 // TODO:FIXME: Use a presence server of some kind to find out where the
1205 // client actually is, and try contacting that region directly to notify them,
1206 // or provide the notification via xmlrpc update queue
1207
1208 msg.imSessionID = groupInfo.GroupID.Guid;
1209 msg.dialog = (byte)210; //interop
1210 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(regionInfo.ScopeID, ejecteeID);
1211 if (account != null)
1212 ejecteeName = account.FirstName + " " + account.LastName;
1213 }
1214
1134 msg.fromAgentID = agentID.Guid; 1215 msg.fromAgentID = agentID.Guid;
1135 // msg.fromAgentID = info.GroupID; 1216 // msg.fromAgentID = info.GroupID;
1136 msg.toAgentID = ejecteeID.Guid; 1217 msg.toAgentID = ejecteeID.Guid;
@@ -1138,7 +1219,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1138 msg.timestamp = 0; 1219 msg.timestamp = 0;
1139 msg.fromAgentName = agentName; 1220 msg.fromAgentName = agentName;
1140 msg.message = string.Format("You have been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName); 1221 msg.message = string.Format("You have been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName);
1141 msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent; 1222//
1142 msg.fromGroup = false; 1223 msg.fromGroup = false;
1143 msg.offline = (byte)0; 1224 msg.offline = (byte)0;
1144 msg.ParentEstateID = 0; 1225 msg.ParentEstateID = 0;
@@ -1148,11 +1229,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1148 OutgoingInstantMessage(msg, ejecteeID); 1229 OutgoingInstantMessage(msg, ejecteeID);
1149 1230
1150 // Message to ejector 1231 // Message to ejector
1151 // Interop, received special 210 code for ejecting a group member
1152 // this only works within the comms servers domain, and won't work hypergrid
1153 // TODO:FIXME: Use a presence server of some kind to find out where the
1154 // client actually is, and try contacting that region directly to notify them,
1155 // or provide the notification via xmlrpc update queue
1156 1232
1157 msg = new GridInstantMessage(); 1233 msg = new GridInstantMessage();
1158 msg.imSessionID = UUID.Zero.Guid; 1234 msg.imSessionID = UUID.Zero.Guid;
@@ -1160,15 +1236,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1160 msg.toAgentID = agentID.Guid; 1236 msg.toAgentID = agentID.Guid;
1161 msg.timestamp = 0; 1237 msg.timestamp = 0;
1162 msg.fromAgentName = agentName; 1238 msg.fromAgentName = agentName;
1163 if (account != null) 1239
1164 { 1240 msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, ejecteeName);
1165 msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, account.FirstName + " " + account.LastName); 1241
1166 } 1242// msg.dialog = (byte)210; //interop
1167 else 1243 msg.dialog = (byte)OpenMetaverse.InstantMessageDialog.MessageFromAgent;
1168 {
1169 msg.message = string.Format("{2} has been ejected from '{1}' by {0}.", agentName, groupInfo.GroupName, "Unknown member");
1170 }
1171 msg.dialog = (byte)210; //interop
1172 msg.fromGroup = false; 1244 msg.fromGroup = false;
1173 msg.offline = (byte)0; 1245 msg.offline = (byte)0;
1174 msg.ParentEstateID = 0; 1246 msg.ParentEstateID = 0;
@@ -1176,11 +1248,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1176 msg.RegionID = regionInfo.RegionID.Guid; 1248 msg.RegionID = regionInfo.RegionID.Guid;
1177 msg.binaryBucket = new byte[0]; 1249 msg.binaryBucket = new byte[0];
1178 OutgoingInstantMessage(msg, agentID); 1250 OutgoingInstantMessage(msg, agentID);
1179
1180
1181 // SL sends out messages to everyone in the group
1182 // Who all should receive updates and what should they be updated with?
1183 UpdateAllClientsWithGroupInfo(ejecteeID);
1184 } 1251 }
1185 1252
1186 public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID) 1253 public void InviteGroupRequest(IClientAPI remoteClient, UUID groupID, UUID invitedAgentID, UUID roleID)
@@ -1275,6 +1342,19 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1275 1342
1276 #region Client/Update Tools 1343 #region Client/Update Tools
1277 1344
1345 private IClientAPI GetActiveRootClient(UUID agentID)
1346 {
1347 foreach (Scene scene in m_sceneList)
1348 {
1349 ScenePresence sp = scene.GetScenePresence(agentID);
1350 if (sp != null && !sp.IsChildAgent && !sp.IsDeleted)
1351 {
1352 return sp.ControllingClient;
1353 }
1354 }
1355 return null;
1356 }
1357
1278 /// <summary> 1358 /// <summary>
1279 /// Try to find an active IClientAPI reference for agentID giving preference to root connections 1359 /// Try to find an active IClientAPI reference for agentID giving preference to root connections
1280 /// </summary> 1360 /// </summary>
@@ -1286,7 +1366,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1286 foreach (Scene scene in m_sceneList) 1366 foreach (Scene scene in m_sceneList)
1287 { 1367 {
1288 ScenePresence sp = scene.GetScenePresence(agentID); 1368 ScenePresence sp = scene.GetScenePresence(agentID);
1289 if (sp != null) 1369 if (sp != null && !sp.IsDeleted)
1290 { 1370 {
1291 if (!sp.IsChildAgent) 1371 if (!sp.IsChildAgent)
1292 { 1372 {
@@ -1303,67 +1383,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1303 return child; 1383 return child;
1304 } 1384 }
1305 1385
1306 /// <summary>
1307 /// Send 'remoteClient' the group membership 'data' for agent 'dataForAgentID'.
1308 /// </summary>
1309 private void SendGroupMembershipInfoViaCaps(IClientAPI remoteClient, UUID dataForAgentID, GroupMembershipData[] data)
1310 {
1311 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1312
1313 OSDArray AgentData = new OSDArray(1);
1314 OSDMap AgentDataMap = new OSDMap(1);
1315 AgentDataMap.Add("AgentID", OSD.FromUUID(dataForAgentID));
1316 AgentData.Add(AgentDataMap);
1317
1318 OSDArray GroupData = new OSDArray(data.Length);
1319 OSDArray NewGroupData = new OSDArray(data.Length);
1320
1321 foreach (GroupMembershipData membership in data)
1322 {
1323 if (GetRequestingAgentID(remoteClient) != dataForAgentID)
1324 {
1325 if (!membership.ListInProfile)
1326 {
1327 // If we're sending group info to remoteclient about another agent,
1328 // filter out groups the other agent doesn't want to share.
1329 continue;
1330 }
1331 }
1332
1333 OSDMap GroupDataMap = new OSDMap(6);
1334 OSDMap NewGroupDataMap = new OSDMap(1);
1335
1336 GroupDataMap.Add("GroupID", OSD.FromUUID(membership.GroupID));
1337 GroupDataMap.Add("GroupPowers", OSD.FromULong(membership.GroupPowers));
1338 GroupDataMap.Add("AcceptNotices", OSD.FromBoolean(membership.AcceptNotices));
1339 GroupDataMap.Add("GroupInsigniaID", OSD.FromUUID(membership.GroupPicture));
1340 GroupDataMap.Add("Contribution", OSD.FromInteger(membership.Contribution));
1341 GroupDataMap.Add("GroupName", OSD.FromString(membership.GroupName));
1342 NewGroupDataMap.Add("ListInProfile", OSD.FromBoolean(membership.ListInProfile));
1343
1344 GroupData.Add(GroupDataMap);
1345 NewGroupData.Add(NewGroupDataMap);
1346 }
1347
1348 OSDMap llDataStruct = new OSDMap(3);
1349 llDataStruct.Add("AgentData", AgentData);
1350 llDataStruct.Add("GroupData", GroupData);
1351 llDataStruct.Add("NewGroupData", NewGroupData);
1352
1353 if (m_debugEnabled)
1354 {
1355 m_log.InfoFormat("[GROUPS]: {0}", OSDParser.SerializeJsonString(llDataStruct));
1356 }
1357
1358 IEventQueue queue = remoteClient.Scene.RequestModuleInterface<IEventQueue>();
1359
1360 if (queue != null)
1361 {
1362 queue.Enqueue(queue.BuildEvent("AgentGroupDataUpdate", llDataStruct), GetRequestingAgentID(remoteClient));
1363 }
1364
1365 }
1366
1367 private void SendScenePresenceUpdate(UUID AgentID, string Title) 1386 private void SendScenePresenceUpdate(UUID AgentID, string Title)
1368 { 1387 {
1369 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Updating scene title for {0} with title: {1}", AgentID, Title); 1388 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: Updating scene title for {0} with title: {1}", AgentID, Title);
@@ -1380,54 +1399,40 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1380 presence.Grouptitle = Title; 1399 presence.Grouptitle = Title;
1381 1400
1382 if (! presence.IsChildAgent) 1401 if (! presence.IsChildAgent)
1383 presence.SendAvatarDataToAllClients(); 1402 presence.SendAvatarDataToAllAgents();
1384 } 1403 }
1385 } 1404 }
1386 } 1405 }
1387 } 1406 }
1388 1407
1389 /// <summary> 1408 public void SendAgentGroupDataUpdate(IClientAPI remoteClient)
1390 /// Send updates to all clients who might be interested in groups data for dataForClientID
1391 /// </summary>
1392 private void UpdateAllClientsWithGroupInfo(UUID dataForClientID)
1393 { 1409 {
1394 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1410 SendAgentGroupDataUpdate(remoteClient, true);
1395
1396 // TODO: Probably isn't nessesary to update every client in every scene.
1397 // Need to examine client updates and do only what's nessesary.
1398 lock (m_sceneList)
1399 {
1400 foreach (Scene scene in m_sceneList)
1401 {
1402 scene.ForEachClient(delegate(IClientAPI client) { SendAgentGroupDataUpdate(client, dataForClientID); });
1403 }
1404 }
1405 } 1411 }
1406 1412
1407 /// <summary> 1413 /// <summary>
1408 /// Update remoteClient with group information about dataForAgentID 1414 /// Tell remoteClient about its agent groups, and optionally send title to others
1409 /// </summary> 1415 /// </summary>
1410 private void SendAgentGroupDataUpdate(IClientAPI remoteClient, UUID dataForAgentID) 1416 private void SendAgentGroupDataUpdate(IClientAPI remoteClient, bool tellOthers)
1411 { 1417 {
1412 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name); 1418 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called for {1}", System.Reflection.MethodBase.GetCurrentMethod().Name, remoteClient.Name);
1413 1419
1420 // NPCs currently don't have a CAPs structure or event queues. There is a strong argument for conveying this information
1421 // to them anyway since it makes writing server-side bots a lot easier, but for now we don't do anything.
1422 if (remoteClient.SceneAgent.PresenceType == PresenceType.Npc)
1423 return;
1424
1414 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff 1425 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff
1415 1426
1416 OnAgentDataUpdateRequest(remoteClient, dataForAgentID, UUID.Zero); 1427 UUID agentID = GetRequestingAgentID(remoteClient);
1417 1428
1418 // Need to send a group membership update to the client 1429 SendDataUpdate(remoteClient, tellOthers);
1419 // UDP version doesn't seem to behave nicely. But we're going to send it out here
1420 // with an empty group membership to hopefully remove groups being displayed due
1421 // to the core Groups Stub
1422 remoteClient.SendGroupMembership(new GroupMembershipData[0]);
1423 1430
1424 GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, dataForAgentID); 1431 GroupMembershipData[] membershipArray = GetProfileListedGroupMemberships(remoteClient, agentID);
1425 SendGroupMembershipInfoViaCaps(remoteClient, dataForAgentID, membershipArray); 1432 remoteClient.UpdateGroupMembership(membershipArray);
1426 remoteClient.SendAvatarGroupsReply(dataForAgentID, membershipArray);
1427 1433
1428 if (remoteClient.AgentId == dataForAgentID) 1434 remoteClient.SendAgentGroupDataUpdate(agentID, membershipArray);
1429 remoteClient.RefreshGroupMembership(); 1435 }
1430 }
1431 1436
1432 /// <summary> 1437 /// <summary>
1433 /// Get a list of groups memberships for the agent that are marked "ListInProfile" 1438 /// Get a list of groups memberships for the agent that are marked "ListInProfile"
@@ -1465,7 +1470,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1465 membershipArray = membershipData.ToArray(); 1470 membershipArray = membershipData.ToArray();
1466 } 1471 }
1467 } 1472 }
1468 1473
1469 if (m_debugEnabled) 1474 if (m_debugEnabled)
1470 { 1475 {
1471 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId); 1476 m_log.InfoFormat("[GROUPS]: Get group membership information for {0} requested by {1}", dataForAgentID, requestingClient.AgentId);
@@ -1478,13 +1483,27 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1478 return membershipArray; 1483 return membershipArray;
1479 } 1484 }
1480 1485
1481 1486 //tell remoteClient about its agent group info, and optionally send title to others
1482 private void SendAgentDataUpdate(IClientAPI remoteClient, UUID dataForAgentID, UUID activeGroupID, string activeGroupName, ulong activeGroupPowers, string activeGroupTitle) 1487 private void SendDataUpdate(IClientAPI remoteClient, bool tellOthers)
1483 { 1488 {
1484 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1489 if (m_debugEnabled) m_log.DebugFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1485 1490
1486 // TODO: All the client update functions need to be reexamined because most do too much and send too much stuff 1491 UUID activeGroupID = UUID.Zero;
1487 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, dataForAgentID); 1492 string activeGroupTitle = string.Empty;
1493 string activeGroupName = string.Empty;
1494 ulong activeGroupPowers = (ulong)GroupPowers.None;
1495
1496 UUID agentID = GetRequestingAgentID(remoteClient);
1497 GroupMembershipData membership = m_groupData.GetAgentActiveMembership(agentID, agentID);
1498 if (membership != null)
1499 {
1500 activeGroupID = membership.GroupID;
1501 activeGroupTitle = membership.GroupTitle;
1502 activeGroupPowers = membership.GroupPowers;
1503 activeGroupName = membership.GroupName;
1504 }
1505
1506 UserAccount account = m_sceneList[0].UserAccountService.GetUserAccount(remoteClient.Scene.RegionInfo.ScopeID, agentID);
1488 string firstname, lastname; 1507 string firstname, lastname;
1489 if (account != null) 1508 if (account != null)
1490 { 1509 {
@@ -1497,9 +1516,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1497 lastname = "Unknown"; 1516 lastname = "Unknown";
1498 } 1517 }
1499 1518
1500 remoteClient.SendAgentDataUpdate(dataForAgentID, activeGroupID, firstname, 1519 remoteClient.SendAgentDataUpdate(agentID, activeGroupID, firstname,
1501 lastname, activeGroupPowers, activeGroupName, 1520 lastname, activeGroupPowers, activeGroupName,
1502 activeGroupTitle); 1521 activeGroupTitle);
1522
1523
1524 if (tellOthers)
1525 SendScenePresenceUpdate(agentID, activeGroupTitle);
1526
1527 ScenePresence sp = (ScenePresence)remoteClient.SceneAgent;
1528 if (sp != null)
1529 sp.Grouptitle = activeGroupTitle;
1503 } 1530 }
1504 1531
1505 #endregion 1532 #endregion
@@ -1510,7 +1537,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1510 { 1537 {
1511 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 1538 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
1512 1539
1513 IClientAPI localClient = GetActiveClient(msgTo); 1540 IClientAPI localClient = GetActiveRootClient(msgTo);
1514 if (localClient != null) 1541 if (localClient != null)
1515 { 1542 {
1516 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: MsgTo ({0}) is local, delivering directly", localClient.Name); 1543 if (m_debugEnabled) m_log.InfoFormat("[GROUPS]: MsgTo ({0}) is local, delivering directly", localClient.Name);
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
index 6b5b40a..08c7096 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/IGroupsServicesConnector.cs
@@ -43,7 +43,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
43 /// <returns></returns> 43 /// <returns></returns>
44 /// <param name='RequestingAgentID'>The UUID of the user making the request.</param> 44 /// <param name='RequestingAgentID'>The UUID of the user making the request.</param>
45 /// <param name='GroupID'> 45 /// <param name='GroupID'>
46 /// The ID of the record to retrieve. 46 /// The ID of the record to retrieve.
47 /// GroupName may be specified instead, in which case this parameter will be UUID.Zero 47 /// GroupName may be specified instead, in which case this parameter will be UUID.Zero
48 /// </param> 48 /// </param>
49 /// <param name='GroupName'> 49 /// <param name='GroupName'>
@@ -51,7 +51,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
51 /// GroupID may be specified instead, in which case this parmeter will be null. 51 /// GroupID may be specified instead, in which case this parmeter will be null.
52 /// </param> 52 /// </param>
53 GroupRecord GetGroupRecord(UUID RequestingAgentID, UUID GroupID, string GroupName); 53 GroupRecord GetGroupRecord(UUID RequestingAgentID, UUID GroupID, string GroupName);
54 54 GroupProfileData GetMemberGroupProfile(UUID requestingAgentID, UUID GroupID, UUID AgentID);
55
55 List<DirGroupsReplyData> FindGroups(UUID RequestingAgentID, string search); 56 List<DirGroupsReplyData> FindGroups(UUID RequestingAgentID, string search);
56 List<GroupMembersData> GetGroupMembers(UUID RequestingAgentID, UUID GroupID); 57 List<GroupMembersData> GetGroupMembers(UUID RequestingAgentID, UUID GroupID);
57 58
@@ -88,7 +89,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
88 /// If the user is a member of the group then the data structure is returned. If not, then null is returned. 89 /// If the user is a member of the group then the data structure is returned. If not, then null is returned.
89 /// </returns> 90 /// </returns>
90 GroupMembershipData GetAgentGroupMembership(UUID RequestingAgentID, UUID AgentID, UUID GroupID); 91 GroupMembershipData GetAgentGroupMembership(UUID RequestingAgentID, UUID AgentID, UUID GroupID);
91 92
92 /// <summary> 93 /// <summary>
93 /// Get information about the groups to which a user belongs. 94 /// Get information about the groups to which a user belongs.
94 /// </summary> 95 /// </summary>
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
index 1cb4747..98c7ed4 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
@@ -48,16 +48,16 @@ using OpenSim.Services.Interfaces;
48/*************************************************************************** 48/***************************************************************************
49 * Simian Data Map 49 * Simian Data Map
50 * =============== 50 * ===============
51 * 51 *
52 * OwnerID -> Type -> Key 52 * OwnerID -> Type -> Key
53 * ----------------------- 53 * -----------------------
54 * 54 *
55 * UserID -> Group -> ActiveGroup 55 * UserID -> Group -> ActiveGroup
56 * + GroupID 56 * + GroupID
57 * 57 *
58 * UserID -> GroupSessionDropped -> GroupID 58 * UserID -> GroupSessionDropped -> GroupID
59 * UserID -> GroupSessionInvited -> GroupID 59 * UserID -> GroupSessionInvited -> GroupID
60 * 60 *
61 * UserID -> GroupMember -> GroupID 61 * UserID -> GroupMember -> GroupID
62 * + SelectedRoleID [UUID] 62 * + SelectedRoleID [UUID]
63 * + AcceptNotices [bool] 63 * + AcceptNotices [bool]
@@ -65,9 +65,9 @@ using OpenSim.Services.Interfaces;
65 * + Contribution [int] 65 * + Contribution [int]
66 * 66 *
67 * UserID -> GroupRole[GroupID] -> RoleID 67 * UserID -> GroupRole[GroupID] -> RoleID
68 * 68 *
69 * 69 *
70 * GroupID -> Group -> GroupName 70 * GroupID -> Group -> GroupName
71 * + Charter 71 * + Charter
72 * + ShowInList 72 * + ShowInList
73 * + InsigniaID 73 * + InsigniaID
@@ -79,17 +79,17 @@ using OpenSim.Services.Interfaces;
79 * + EveryonePowers 79 * + EveryonePowers
80 * + OwnerRoleID 80 * + OwnerRoleID
81 * + OwnersPowers 81 * + OwnersPowers
82 * 82 *
83 * GroupID -> GroupRole -> RoleID 83 * GroupID -> GroupRole -> RoleID
84 * + Name 84 * + Name
85 * + Description 85 * + Description
86 * + Title 86 * + Title
87 * + Powers 87 * + Powers
88 * 88 *
89 * GroupID -> GroupMemberInvite -> InviteID 89 * GroupID -> GroupMemberInvite -> InviteID
90 * + AgentID 90 * + AgentID
91 * + RoleID 91 * + RoleID
92 * 92 *
93 * GroupID -> GroupNotice -> NoticeID 93 * GroupID -> GroupNotice -> NoticeID
94 * + TimeStamp [uint] 94 * + TimeStamp [uint]
95 * + FromName [string] 95 * + FromName [string]
@@ -106,12 +106,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
106 { 106 {
107 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 107 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
108 108
109 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome | 109 public const GroupPowers m_DefaultEveryonePowers = GroupPowers.AllowSetHome |
110 GroupPowers.Accountable | 110 GroupPowers.Accountable |
111 GroupPowers.JoinChat | 111 GroupPowers.JoinChat |
112 GroupPowers.AllowVoiceChat | 112 GroupPowers.AllowVoiceChat |
113 GroupPowers.ReceiveNotices | 113 GroupPowers.ReceiveNotices |
114 GroupPowers.StartProposal | 114 GroupPowers.StartProposal |
115 GroupPowers.VoteOnProposal; 115 GroupPowers.VoteOnProposal;
116 116
117 // Would this be cleaner as (GroupPowers)ulong.MaxValue; 117 // Would this be cleaner as (GroupPowers)ulong.MaxValue;
@@ -168,12 +168,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
168 private bool m_debugEnabled = false; 168 private bool m_debugEnabled = false;
169 169
170 private Dictionary<string, bool> m_pendingRequests = new Dictionary<string,bool>(); 170 private Dictionary<string, bool> m_pendingRequests = new Dictionary<string,bool>();
171 171
172 private ExpiringCache<string, OSDMap> m_memoryCache; 172 private ExpiringCache<string, OSDMap> m_memoryCache;
173 private int m_cacheTimeout = 30; 173 private int m_cacheTimeout = 30;
174 174
175 // private IUserAccountService m_accountService = null; 175 // private IUserAccountService m_accountService = null;
176 176
177 177
178 #region Region Module interfaceBase Members 178 #region Region Module interfaceBase Members
179 179
@@ -229,10 +229,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
229 m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Timeout set to {0}.", m_cacheTimeout); 229 m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] Groups Cache Timeout set to {0}.", m_cacheTimeout);
230 } 230 }
231 231
232 232
233 233
234 m_memoryCache = new ExpiringCache<string,OSDMap>(); 234 m_memoryCache = new ExpiringCache<string,OSDMap>();
235 235
236 236
237 // If we got all the config options we need, lets start'er'up 237 // If we got all the config options we need, lets start'er'up
238 m_connectorEnabled = true; 238 m_connectorEnabled = true;
@@ -244,7 +244,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
244 244
245 public void Close() 245 public void Close()
246 { 246 {
247 m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR]: Closing {0}", this.Name);
248 } 247 }
249 248
250 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 249 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -288,8 +287,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
288 /// <summary> 287 /// <summary>
289 /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role. 288 /// Create a Group, including Everyone and Owners Role, place FounderID in both groups, select Owner as selected role, and newly created group as agent's active role.
290 /// </summary> 289 /// </summary>
291 public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID, 290 public UUID CreateGroup(UUID requestingAgentID, string name, string charter, bool showInList, UUID insigniaID,
292 int membershipFee, bool openEnrollment, bool allowPublish, 291 int membershipFee, bool openEnrollment, bool allowPublish,
293 bool maturePublish, UUID founderID) 292 bool maturePublish, UUID founderID)
294 { 293 {
295 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 294 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -314,7 +313,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
314 { 313 {
315 AddGroupRole(requestingAgentID, GroupID, UUID.Zero, "Everyone", "Members of " + name, "Member of " + name, (ulong)m_DefaultEveryonePowers); 314 AddGroupRole(requestingAgentID, GroupID, UUID.Zero, "Everyone", "Members of " + name, "Member of " + name, (ulong)m_DefaultEveryonePowers);
316 AddGroupRole(requestingAgentID, GroupID, OwnerRoleID, "Owners", "Owners of " + name, "Owner of " + name, (ulong)m_DefaultOwnerPowers); 315 AddGroupRole(requestingAgentID, GroupID, OwnerRoleID, "Owners", "Owners of " + name, "Owner of " + name, (ulong)m_DefaultOwnerPowers);
317 316
318 AddAgentToGroup(requestingAgentID, requestingAgentID, GroupID, OwnerRoleID); 317 AddAgentToGroup(requestingAgentID, requestingAgentID, GroupID, OwnerRoleID);
319 318
320 return GroupID; 319 return GroupID;
@@ -326,8 +325,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
326 } 325 }
327 326
328 327
329 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList, 328 public void UpdateGroup(UUID requestingAgentID, UUID groupID, string charter, bool showInList,
330 UUID insigniaID, int membershipFee, bool openEnrollment, 329 UUID insigniaID, int membershipFee, bool openEnrollment,
331 bool allowPublish, bool maturePublish) 330 bool allowPublish, bool maturePublish)
332 { 331 {
333 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 332 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -351,7 +350,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
351 } 350 }
352 351
353 352
354 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, 353 public void AddGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
355 string title, ulong powers) 354 string title, ulong powers)
356 { 355 {
357 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 356 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -394,7 +393,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
394 } 393 }
395 394
396 395
397 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description, 396 public void UpdateGroupRole(UUID requestingAgentID, UUID groupID, UUID roleID, string name, string description,
398 string title, ulong powers) 397 string title, ulong powers)
399 { 398 {
400 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name); 399 if (m_debugEnabled) m_log.InfoFormat("[SIMIAN-GROUPS-CONNECTOR] {0} called", System.Reflection.MethodBase.GetCurrentMethod().Name);
@@ -435,7 +434,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
435 { 434 {
436 return null; 435 return null;
437 } 436 }
438 } 437 }
439 else if (!string.IsNullOrEmpty(groupName)) 438 else if (!string.IsNullOrEmpty(groupName))
440 { 439 {
441 if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap)) 440 if (!SimianGetFirstGenericEntry("Group", groupName, out groupID, out GroupInfoMap))
@@ -482,7 +481,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
482 { 481 {
483 MemberGroupProfile.Charter = groupProfile["Charter"].AsString(); 482 MemberGroupProfile.Charter = groupProfile["Charter"].AsString();
484 } 483 }
485 484
486 MemberGroupProfile.ShowInList = groupProfile["ShowInList"].AsString() == "1"; 485 MemberGroupProfile.ShowInList = groupProfile["ShowInList"].AsString() == "1";
487 MemberGroupProfile.InsigniaID = groupProfile["InsigniaID"].AsUUID(); 486 MemberGroupProfile.InsigniaID = groupProfile["InsigniaID"].AsUUID();
488 MemberGroupProfile.MembershipFee = groupProfile["MembershipFee"].AsInteger(); 487 MemberGroupProfile.MembershipFee = groupProfile["MembershipFee"].AsInteger();
@@ -490,7 +489,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
490 MemberGroupProfile.AllowPublish = groupProfile["AllowPublish"].AsBoolean(); 489 MemberGroupProfile.AllowPublish = groupProfile["AllowPublish"].AsBoolean();
491 MemberGroupProfile.MaturePublish = groupProfile["MaturePublish"].AsBoolean(); 490 MemberGroupProfile.MaturePublish = groupProfile["MaturePublish"].AsBoolean();
492 MemberGroupProfile.FounderID = groupProfile["FounderID"].AsUUID();; 491 MemberGroupProfile.FounderID = groupProfile["FounderID"].AsUUID();;
493 MemberGroupProfile.OwnerRole = groupProfile["OwnerRoleID"].AsUUID(); 492 MemberGroupProfile.OwnerRole = groupProfile["OwnerRoleID"].AsUUID();
494 493
495 Dictionary<UUID, OSDMap> Members; 494 Dictionary<UUID, OSDMap> Members;
496 if (SimianGetGenericEntries("GroupMember",groupID.ToString(), out Members)) 495 if (SimianGetGenericEntries("GroupMember",groupID.ToString(), out Members))
@@ -547,7 +546,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
547 { 546 {
548 GroupMemberInfo = new OSDMap(); 547 GroupMemberInfo = new OSDMap();
549 } 548 }
550 549
551 GroupMemberInfo["AcceptNotices"] = OSD.FromBoolean(acceptNotices); 550 GroupMemberInfo["AcceptNotices"] = OSD.FromBoolean(acceptNotices);
552 GroupMemberInfo["ListInProfile"] = OSD.FromBoolean(listInProfile); 551 GroupMemberInfo["ListInProfile"] = OSD.FromBoolean(listInProfile);
553 GroupMemberInfo["Contribution"] = OSD.FromInteger(0); 552 GroupMemberInfo["Contribution"] = OSD.FromInteger(0);
@@ -625,7 +624,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
625 // Remove Group Member information for this group 624 // Remove Group Member information for this group
626 SimianRemoveGenericEntry(agentID, "GroupMember", groupID.ToString()); 625 SimianRemoveGenericEntry(agentID, "GroupMember", groupID.ToString());
627 626
628 // By using a Simian Generics Type consisting of a prefix and a groupID, 627 // By using a Simian Generics Type consisting of a prefix and a groupID,
629 // combined with RoleID as key allows us to get a list of roles a particular member 628 // combined with RoleID as key allows us to get a list of roles a particular member
630 // of a group is assigned to. 629 // of a group is assigned to.
631 string GroupRoleMemberType = "GroupRole" + groupID.ToString(); 630 string GroupRoleMemberType = "GroupRole" + groupID.ToString();
@@ -697,7 +696,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
697 { 696 {
698 data.members = 0; 697 data.members = 0;
699 } 698 }
700 699
701 // TODO: sort results? 700 // TODO: sort results?
702 // data.searchOrder = order; 701 // data.searchOrder = order;
703 702
@@ -722,8 +721,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
722 data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean(); 721 data.AcceptNotices = UserGroupMemberInfo["AcceptNotices"].AsBoolean();
723 data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger(); 722 data.Contribution = UserGroupMemberInfo["Contribution"].AsInteger();
724 data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean(); 723 data.ListInProfile = UserGroupMemberInfo["ListInProfile"].AsBoolean();
725 data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID(); 724 data.ActiveRole = UserGroupMemberInfo["SelectedRoleID"].AsUUID();
726 725
727 /////////////////////////////// 726 ///////////////////////////////
728 // Agent Specific Information: 727 // Agent Specific Information:
729 // 728 //
@@ -731,7 +730,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
731 if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup)) 730 if (SimianGetGenericEntry(agentID, "Group", "ActiveGroup", out UserActiveGroup))
732 { 731 {
733 data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID); 732 data.Active = UserActiveGroup["GroupID"].AsUUID().Equals(groupID);
734 } 733 }
735 734
736 /////////////////////////////// 735 ///////////////////////////////
737 // Role Specific Information: 736 // Role Specific Information:
@@ -741,8 +740,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
741 { 740 {
742 data.GroupTitle = GroupRoleInfo["Title"].AsString(); 741 data.GroupTitle = GroupRoleInfo["Title"].AsString();
743 data.GroupPowers = GroupRoleInfo["Powers"].AsULong(); 742 data.GroupPowers = GroupRoleInfo["Powers"].AsULong();
744 } 743 }
745 744
746 /////////////////////////////// 745 ///////////////////////////////
747 // Group Specific Information: 746 // Group Specific Information:
748 // 747 //
@@ -760,7 +759,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
760 data.MembershipFee = GroupInfo["MembershipFee"].AsInteger(); 759 data.MembershipFee = GroupInfo["MembershipFee"].AsInteger();
761 data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean(); 760 data.OpenEnrollment = GroupInfo["OpenEnrollment"].AsBoolean();
762 data.ShowInList = GroupInfo["ShowInList"].AsBoolean(); 761 data.ShowInList = GroupInfo["ShowInList"].AsBoolean();
763 } 762 }
764 } 763 }
765 764
766 return data; 765 return data;
@@ -795,7 +794,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
795 memberships.Add(GetAgentGroupMembership(requestingAgentID, agentID, UUID.Parse(key))); 794 memberships.Add(GetAgentGroupMembership(requestingAgentID, agentID, UUID.Parse(key)));
796 } 795 }
797 } 796 }
798 797
799 return memberships; 798 return memberships;
800 } 799 }
801 800
@@ -1018,7 +1017,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1018 Notice["BinaryBucket"] = OSD.FromBinary(binaryBucket); 1017 Notice["BinaryBucket"] = OSD.FromBinary(binaryBucket);
1019 1018
1020 SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice); 1019 SimianAddGeneric(groupID, "GroupNotice", noticeID.ToString(), Notice);
1021 1020
1022 } 1021 }
1023 #endregion 1022 #endregion
1024 1023
@@ -1251,7 +1250,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1251 { "OwnerID", ownerID.ToString() }, 1250 { "OwnerID", ownerID.ToString() },
1252 { "Type", type } 1251 { "Type", type }
1253 }; 1252 };
1254 1253
1255 1254
1256 1255
1257 OSDMap response = CachedPostRequest(requestArgs); 1256 OSDMap response = CachedPostRequest(requestArgs);
@@ -1358,7 +1357,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1358 || requestArgs["RequestMethod"] == "AddGeneric") 1357 || requestArgs["RequestMethod"] == "AddGeneric")
1359 { 1358 {
1360 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: clearing generics cache"); 1359 m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: clearing generics cache");
1361 1360
1362 // Any and all updates cause the cache to clear 1361 // Any and all updates cause the cache to clear
1363 m_memoryCache.Clear(); 1362 m_memoryCache.Clear();
1364 1363
@@ -1384,14 +1383,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1384 { 1383 {
1385 if (m_memoryCache.TryGetValue(CacheKey, out response)) 1384 if (m_memoryCache.TryGetValue(CacheKey, out response))
1386 return response; 1385 return response;
1387 1386
1388 if (! m_pendingRequests.ContainsKey(CacheKey)) 1387 if (! m_pendingRequests.ContainsKey(CacheKey))
1389 { 1388 {
1390 m_pendingRequests.Add(CacheKey,true); 1389 m_pendingRequests.Add(CacheKey,true);
1391 firstRequest = true; 1390 firstRequest = true;
1392 } 1391 }
1393 } 1392 }
1394 1393
1395 if (firstRequest) 1394 if (firstRequest)
1396 { 1395 {
1397 // if it wasn't in the cache, pass the request to the Simian Grid Services 1396 // if it wasn't in the cache, pass the request to the Simian Grid Services
@@ -1403,7 +1402,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1403 { 1402 {
1404 m_log.ErrorFormat("[SIMIAN GROUPS CONNECTOR]: request failed {0}", CacheKey); 1403 m_log.ErrorFormat("[SIMIAN GROUPS CONNECTOR]: request failed {0}", CacheKey);
1405 } 1404 }
1406 1405
1407 // and cache the response 1406 // and cache the response
1408 lock (m_memoryCache) 1407 lock (m_memoryCache)
1409 { 1408 {
@@ -1421,7 +1420,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1421 // { 1420 // {
1422 // m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: query not in the cache"); 1421 // m_log.WarnFormat("[SIMIAN GROUPS CONNECTOR]: query not in the cache");
1423 // Util.PrintCallStack(); 1422 // Util.PrintCallStack();
1424 1423
1425 // // if it wasn't in the cache, pass the request to the Simian Grid Services 1424 // // if it wasn't in the cache, pass the request to the Simian Grid Services
1426 // response = WebUtil.PostToService(m_groupsServerURI, requestArgs); 1425 // response = WebUtil.PostToService(m_groupsServerURI, requestArgs);
1427 1426
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
index 9a42bac..ccfcd8b 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/Tests/GroupsModuleTests.cs
@@ -74,14 +74,15 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
74 [Test] 74 [Test]
75 public void TestSendAgentGroupDataUpdate() 75 public void TestSendAgentGroupDataUpdate()
76 { 76 {
77/* AgentGroupDataUpdate is udp
77 TestHelpers.InMethod(); 78 TestHelpers.InMethod();
78// TestHelpers.EnableLogging(); 79// TestHelpers.EnableLogging();
79 80
80 TestScene scene = new SceneHelpers().SetupScene(); 81 TestScene scene = new SceneHelpers().SetupScene();
81 IConfigSource configSource = new IniConfigSource(); 82 IConfigSource configSource = new IniConfigSource();
82 IConfig config = configSource.AddConfig("Groups"); 83 IConfig config = configSource.AddConfig("Groups");
83 config.Set("Enabled", true); 84 config.Set("Enabled", true);
84 config.Set("Module", "GroupsModule"); 85 config.Set("Module", "GroupsModule");
85 config.Set("DebugEnabled", true); 86 config.Set("DebugEnabled", true);
86 87
87 GroupsModule gm = new GroupsModule(); 88 GroupsModule gm = new GroupsModule();
@@ -98,6 +99,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
98 99
99 Hashtable eventsResponse = eqgm.GetEvents(UUID.Zero, sp.UUID); 100 Hashtable eventsResponse = eqgm.GetEvents(UUID.Zero, sp.UUID);
100 101
102 if((int)eventsResponse["int_response_code"] != (int)HttpStatusCode.OK)
103 {
104 eventsResponse = eqgm.GetEvents(UUID.Zero, sp.UUID);
105 if((int)eventsResponse["int_response_code"] != (int)HttpStatusCode.OK)
106 eventsResponse = eqgm.GetEvents(UUID.Zero, sp.UUID);
107 }
108
101 Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.OK)); 109 Assert.That((int)eventsResponse["int_response_code"], Is.EqualTo((int)HttpStatusCode.OK));
102 110
103// Console.WriteLine("Response [{0}]", (string)eventsResponse["str_response_string"]); 111// Console.WriteLine("Response [{0}]", (string)eventsResponse["str_response_string"]);
@@ -116,7 +124,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
116 124
117 Assert.That(foundUpdate, Is.True, "Did not find AgentGroupDataUpdate in response"); 125 Assert.That(foundUpdate, Is.True, "Did not find AgentGroupDataUpdate in response");
118 126
119 // TODO: More checking of more actual event data. 127 // TODO: More checking of more actual event data.
128*/
120 } 129 }
121 130
122 [Test] 131 [Test]
@@ -124,7 +133,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
124 { 133 {
125 TestHelpers.InMethod(); 134 TestHelpers.InMethod();
126// TestHelpers.EnableLogging(); 135// TestHelpers.EnableLogging();
127 136
128 TestScene scene = new SceneHelpers().SetupScene(); 137 TestScene scene = new SceneHelpers().SetupScene();
129 138
130 MessageTransferModule mtm = new MessageTransferModule(); 139 MessageTransferModule mtm = new MessageTransferModule();
@@ -135,12 +144,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups.Tests
135 IConfigSource configSource = new IniConfigSource(); 144 IConfigSource configSource = new IniConfigSource();
136 145
137 { 146 {
138 IConfig config = configSource.AddConfig("Messaging"); 147 IConfig config = configSource.AddConfig("Messaging");
139 config.Set("MessageTransferModule", mtm.Name); 148 config.Set("MessageTransferModule", mtm.Name);
140 } 149 }
141 150
142 { 151 {
143 IConfig config = configSource.AddConfig("Groups"); 152 IConfig config = configSource.AddConfig("Groups");
144 config.Set("Enabled", true); 153 config.Set("Enabled", true);
145 config.Set("Module", gm.Name); 154 config.Set("Module", gm.Name);
146 config.Set("DebugEnabled", true); 155 config.Set("DebugEnabled", true);
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index 20555e4..fab7e8c 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -53,17 +53,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
53 53
54 private bool m_debugEnabled = false; 54 private bool m_debugEnabled = false;
55 55
56 public const GroupPowers DefaultEveryonePowers 56 public const GroupPowers DefaultEveryonePowers
57 = GroupPowers.AllowSetHome 57 = GroupPowers.AllowSetHome
58 | GroupPowers.Accountable 58 | GroupPowers.Accountable
59 | GroupPowers.JoinChat 59 | GroupPowers.JoinChat
60 | GroupPowers.AllowVoiceChat 60 | GroupPowers.AllowVoiceChat
61 | GroupPowers.ReceiveNotices 61 | GroupPowers.ReceiveNotices
62 | GroupPowers.StartProposal 62 | GroupPowers.StartProposal
63 | GroupPowers.VoteOnProposal; 63 | GroupPowers.VoteOnProposal;
64 64
65 // Would this be cleaner as (GroupPowers)ulong.MaxValue? 65 // Would this be cleaner as (GroupPowers)ulong.MaxValue?
66 public const GroupPowers DefaultOwnerPowers 66 public const GroupPowers DefaultOwnerPowers
67 = GroupPowers.Accountable 67 = GroupPowers.Accountable
68 | GroupPowers.AllowEditLand 68 | GroupPowers.AllowEditLand
69 | GroupPowers.AllowFly 69 | GroupPowers.AllowFly
@@ -114,7 +114,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
114 114
115 private string m_groupsServerURI = string.Empty; 115 private string m_groupsServerURI = string.Empty;
116 116
117 private bool m_disableKeepAlive = false; 117 private bool m_disableKeepAlive = true;
118 118
119 private string m_groupReadKey = string.Empty; 119 private string m_groupReadKey = string.Empty;
120 private string m_groupWriteKey = string.Empty; 120 private string m_groupWriteKey = string.Empty;
@@ -174,13 +174,13 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
174 return; 174 return;
175 } 175 }
176 176
177 m_disableKeepAlive = groupsConfig.GetBoolean("XmlRpcDisableKeepAlive", false); 177 m_disableKeepAlive = groupsConfig.GetBoolean("XmlRpcDisableKeepAlive", true);
178 178
179 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty); 179 m_groupReadKey = groupsConfig.GetString("XmlRpcServiceReadKey", string.Empty);
180 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty); 180 m_groupWriteKey = groupsConfig.GetString("XmlRpcServiceWriteKey", string.Empty);
181 181
182
183 m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30); 182 m_cacheTimeout = groupsConfig.GetInt("GroupsCacheTimeout", 30);
183
184 if (m_cacheTimeout == 0) 184 if (m_cacheTimeout == 0)
185 { 185 {
186 m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Disabled."); 186 m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: Groups Cache Disabled.");
@@ -200,7 +200,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
200 200
201 public void Close() 201 public void Close()
202 { 202 {
203 m_log.DebugFormat("[XMLRPC-GROUPS-CONNECTOR]: Closing {0}", this.Name);
204 } 203 }
205 204
206 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene) 205 public void AddRegion(OpenSim.Region.Framework.Scenes.Scene scene)
@@ -383,10 +382,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
383 382
384 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, AgentID, GroupID); 383 GroupMembershipData MemberInfo = GetAgentGroupMembership(requestingAgentID, AgentID, GroupID);
385 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData); 384 GroupProfileData MemberGroupProfile = GroupProfileHashtableToGroupProfileData(respData);
386 385 if(MemberInfo != null)
387 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle; 386 {
388 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers; 387 MemberGroupProfile.MemberTitle = MemberInfo.GroupTitle;
389 388 MemberGroupProfile.PowersMask = MemberInfo.GroupPowers;
389 }
390 return MemberGroupProfile; 390 return MemberGroupProfile;
391 } 391 }
392 392
@@ -666,6 +666,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
666 data.ListInProfile = ((string)membership["ListInProfile"]) == "1"; 666 data.ListInProfile = ((string)membership["ListInProfile"]) == "1";
667 data.AgentPowers = ulong.Parse((string)membership["AgentPowers"]); 667 data.AgentPowers = ulong.Parse((string)membership["AgentPowers"]);
668 data.Title = (string)membership["Title"]; 668 data.Title = (string)membership["Title"];
669 if(membership.ContainsKey("OnlineStatus"))
670 data.OnlineStatus = (string)membership["OnlineStatus"];
669 671
670 members.Add(data); 672 members.Add(data);
671 } 673 }
@@ -803,11 +805,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
803 { 805 {
804 if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID)) 806 if (m_groupsAgentsDroppedFromChatSession.ContainsKey(groupID))
805 { 807 {
808 if (m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID))
809 m_groupsAgentsInvitedToChatSession[groupID].Remove(agentID);
810
806 // If not in dropped list, add 811 // If not in dropped list, add
807 if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID)) 812 if (!m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
808 {
809 m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID); 813 m_groupsAgentsDroppedFromChatSession[groupID].Add(agentID);
810 }
811 } 814 }
812 } 815 }
813 816
@@ -818,9 +821,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
818 821
819 // If nessesary, remove from dropped list 822 // If nessesary, remove from dropped list
820 if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID)) 823 if (m_groupsAgentsDroppedFromChatSession[groupID].Contains(agentID))
821 {
822 m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID); 824 m_groupsAgentsDroppedFromChatSession[groupID].Remove(agentID);
823 } 825
826 if (!m_groupsAgentsInvitedToChatSession[groupID].Contains(agentID))
827 m_groupsAgentsInvitedToChatSession[groupID].Add(agentID);
824 } 828 }
825 829
826 private void CreateGroupChatSessionTracking(UUID groupID) 830 private void CreateGroupChatSessionTracking(UUID groupID)
@@ -975,35 +979,42 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
975 979
976 try 980 try
977 { 981 {
978 resp = req.Send(m_groupsServerURI, 10000); 982 resp = req.Send(m_groupsServerURI);
979
980 if ((m_cacheTimeout > 0) && (CacheKey != null))
981 {
982 m_memoryCache.AddOrUpdate(CacheKey, resp, TimeSpan.FromSeconds(m_cacheTimeout));
983 }
984 } 983 }
985 catch (Exception e) 984 catch (Exception e)
986 { 985 {
987 m_log.ErrorFormat( 986 m_log.ErrorFormat(
988 "[XMLRPC-GROUPS-CONNECTOR]: An error has occured while attempting to access the XmlRpcGroups server method {0} at {1}", 987 "[XMLRPC-GROUPS-CONNECTOR]: An error has occured while attempting to access the XmlRpcGroups server method {0} at {1}: {2}",
989 function, m_groupsServerURI); 988 function, m_groupsServerURI, e.Message);
990
991 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}{1}", e.Message, e.StackTrace);
992 989
993 foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None)) 990 if(m_debugEnabled)
994 { 991 {
995 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", ResponseLine); 992 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0}", e.StackTrace);
993
994 foreach (string ResponseLine in req.RequestResponse.Split(new string[] { Environment.NewLine }, StringSplitOptions.None))
995 {
996 m_log.ErrorFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} ", ResponseLine);
997 }
998
999 foreach (string key in param.Keys)
1000 {
1001 m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", key, param[key].ToString());
1002 }
996 } 1003 }
997 1004
998 foreach (string key in param.Keys) 1005 if ((m_cacheTimeout > 0) && (CacheKey != null))
999 { 1006 {
1000 m_log.WarnFormat("[XMLRPC-GROUPS-CONNECTOR]: {0} :: {1}", key, param[key].ToString()); 1007 m_memoryCache.AddOrUpdate(CacheKey, resp, 10.0);
1001 } 1008 }
1002
1003 Hashtable respData = new Hashtable(); 1009 Hashtable respData = new Hashtable();
1004 respData.Add("error", e.ToString()); 1010 respData.Add("error", e.ToString());
1005 return respData; 1011 return respData;
1006 } 1012 }
1013
1014 if ((m_cacheTimeout > 0) && (CacheKey != null))
1015 {
1016 m_memoryCache.AddOrUpdate(CacheKey, resp, 10.0);
1017 }
1007 } 1018 }
1008 1019
1009 if (resp.Value is Hashtable) 1020 if (resp.Value is Hashtable)
@@ -1042,7 +1053,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
1042 private void LogRespDataToConsoleError(UUID requestingAgentID, string function, Hashtable param, Hashtable respData) 1053 private void LogRespDataToConsoleError(UUID requestingAgentID, string function, Hashtable param, Hashtable respData)
1043 { 1054 {
1044 m_log.ErrorFormat( 1055 m_log.ErrorFormat(
1045 "[XMLRPC-GROUPS-CONNECTOR]: Error when calling {0} for {1} with params {2}. Response params are {3}", 1056 "[XMLRPC-GROUPS-CONNECTOR]: Error when calling {0} for {1} with params {2}. Response params are {3}",
1046 function, requestingAgentID, Util.PrettyFormatToSingleLine(param), Util.PrettyFormatToSingleLine(respData)); 1057 function, requestingAgentID, Util.PrettyFormatToSingleLine(param), Util.PrettyFormatToSingleLine(respData));
1047 } 1058 }
1048 1059
@@ -1134,6 +1145,7 @@ namespace Nwc.XmlRpc
1134 request.ContentType = "text/xml"; 1145 request.ContentType = "text/xml";
1135 request.AllowWriteStreamBuffering = true; 1146 request.AllowWriteStreamBuffering = true;
1136 request.KeepAlive = !_disableKeepAlive; 1147 request.KeepAlive = !_disableKeepAlive;
1148 request.Timeout = 30000;
1137 1149
1138 using (Stream stream = request.GetRequestStream()) 1150 using (Stream stream = request.GetRequestStream())
1139 { 1151 {
@@ -1141,7 +1153,7 @@ namespace Nwc.XmlRpc
1141 { 1153 {
1142 _serializer.Serialize(xml, this); 1154 _serializer.Serialize(xml, this);
1143 xml.Flush(); 1155 xml.Flush();
1144 } 1156 }
1145 } 1157 }
1146 1158
1147 XmlRpcResponse resp; 1159 XmlRpcResponse resp;
diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
index 0c3446d..0436f96 100644
--- a/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
+++ b/OpenSim/Region/OptionalModules/DataSnapshot/DataSnapshotManager.cs
@@ -101,7 +101,7 @@ namespace OpenSim.Region.DataSnapshot
101 101
102 public void Initialise(IConfigSource config) 102 public void Initialise(IConfigSource config)
103 { 103 {
104 if (!m_configLoaded) 104 if (!m_configLoaded)
105 { 105 {
106 m_configLoaded = true; 106 m_configLoaded = true;
107 //m_log.Debug("[DATASNAPSHOT]: Loading configuration"); 107 //m_log.Debug("[DATASNAPSHOT]: Loading configuration");
@@ -248,7 +248,7 @@ namespace OpenSim.Region.DataSnapshot
248 m_snapStore.ForceSceneStale(scene); 248 m_snapStore.ForceSceneStale(scene);
249 } 249 }
250 250
251 public void Close() 251 public void Close()
252 { 252 {
253 if (!m_enabled) 253 if (!m_enabled)
254 return; 254 return;
@@ -432,7 +432,6 @@ namespace OpenSim.Region.DataSnapshot
432 m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret); 432 m_log.Info("[DATASNAPSHOT]: data service " + url + " notified. Secret: " + m_Secret);
433 } 433 }
434 } 434 }
435
436 } 435 }
437 #endregion 436 #endregion
438 437
diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/LandSnapshot.cs b/OpenSim/Region/OptionalModules/DataSnapshot/LandSnapshot.cs
index b8c90cd..8e6a30e 100644
--- a/OpenSim/Region/OptionalModules/DataSnapshot/LandSnapshot.cs
+++ b/OpenSim/Region/OptionalModules/DataSnapshot/LandSnapshot.cs
@@ -120,12 +120,15 @@ namespace OpenSim.Region.DataSnapshot.Providers
120 120
121 public XmlNode RequestSnapshotData(XmlDocument nodeFactory) 121 public XmlNode RequestSnapshotData(XmlDocument nodeFactory)
122 { 122 {
123 XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", "");
123 ILandChannel landChannel = m_scene.LandChannel; 124 ILandChannel landChannel = m_scene.LandChannel;
125 if(landChannel == null)
126 return parent;
127
124 List<ILandObject> parcels = landChannel.AllParcels(); 128 List<ILandObject> parcels = landChannel.AllParcels();
125 129
126 IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>(); 130 IDwellModule dwellModule = m_scene.RequestModuleInterface<IDwellModule>();
127 131
128 XmlNode parent = nodeFactory.CreateNode(XmlNodeType.Element, "parceldata", "");
129 if (parcels != null) 132 if (parcels != null)
130 { 133 {
131 134
@@ -140,7 +143,7 @@ namespace OpenSim.Region.DataSnapshot.Providers
140 143
141 LandData parcel = land.LandData; 144 LandData parcel = land.LandData;
142 if (m_parent.ExposureLevel.Equals("all") || 145 if (m_parent.ExposureLevel.Equals("all") ||
143 (m_parent.ExposureLevel.Equals("minimum") && 146 (m_parent.ExposureLevel.Equals("minimum") &&
144 (parcel.Flags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory)) 147 (parcel.Flags & (uint)ParcelFlags.ShowDirectory) == (uint)ParcelFlags.ShowDirectory))
145 { 148 {
146 149
@@ -265,8 +268,12 @@ namespace OpenSim.Region.DataSnapshot.Providers
265 { 268 {
266 XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", ""); 269 XmlNode username = nodeFactory.CreateNode(XmlNodeType.Element, "name", "");
267 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, userOwnerUUID); 270 UserAccount account = m_scene.UserAccountService.GetUserAccount(m_scene.RegionInfo.ScopeID, userOwnerUUID);
268 username.InnerText = account.FirstName + " " + account.LastName; 271 if(account != null)
272 username.InnerText = account.FirstName + " " + account.LastName;
273 else
274 username.InnerText = "UnKnown";
269 userblock.AppendChild(username); 275 userblock.AppendChild(username);
276
270 } 277 }
271 catch (Exception) 278 catch (Exception)
272 { 279 {
diff --git a/OpenSim/Region/OptionalModules/DataSnapshot/ObjectSnapshot.cs b/OpenSim/Region/OptionalModules/DataSnapshot/ObjectSnapshot.cs
index 0bb4044..caca303 100644
--- a/OpenSim/Region/OptionalModules/DataSnapshot/ObjectSnapshot.cs
+++ b/OpenSim/Region/OptionalModules/DataSnapshot/ObjectSnapshot.cs
@@ -83,7 +83,8 @@ namespace OpenSim.Region.DataSnapshot.Providers
83 { this.Stale = true; }; 83 { this.Stale = true; };
84 client.OnObjectPermissions += delegate(IClientAPI controller, UUID agentID, UUID sessionID, 84 client.OnObjectPermissions += delegate(IClientAPI controller, UUID agentID, UUID sessionID,
85 byte field, uint localId, uint mask, byte set) { this.Stale = true; }; 85 byte field, uint localId, uint mask, byte set) { this.Stale = true; };
86 client.OnRezObject += delegate(IClientAPI remoteClient, UUID itemID, Vector3 RayEnd, 86 client.OnRezObject += delegate(IClientAPI remoteClient, UUID itemID, UUID groupID,
87 Vector3 RayEnd,
87 Vector3 RayStart, UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection, 88 Vector3 RayStart, UUID RayTargetID, byte BypassRayCast, bool RayEndIsIntersection,
88 bool RezSelected, 89 bool RezSelected,
89 bool RemoveItem, UUID fromTaskID) { this.Stale = true; }; 90 bool RemoveItem, UUID fromTaskID) { this.Stale = true; };
diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs
index bbf7168..95a2dd6 100644
--- a/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs
+++ b/OpenSim/Region/OptionalModules/Example/BareBonesNonShared/BareBonesNonSharedModule.cs
@@ -46,12 +46,12 @@ namespace OpenSim.Region.OptionalModules.Example.BareBonesNonShared
46 /// </summary> 46 /// </summary>
47 /// <remarks> 47 /// <remarks>
48 /// This module is the simplest possible example of a non-shared region module (a module where each scene/region 48 /// This module is the simplest possible example of a non-shared region module (a module where each scene/region
49 /// in the simulator has its own copy). If anybody wants to create a more complex example in the future then 49 /// in the simulator has its own copy). If anybody wants to create a more complex example in the future then
50 /// please create a separate class. 50 /// please create a separate class.
51 /// 51 ///
52 /// This module is not active by default. If you want to see it in action, 52 /// This module is not active by default. If you want to see it in action,
53 /// then just uncomment the line below starting with [Extension(Path... 53 /// then just uncomment the line below starting with [Extension(Path...
54 /// 54 ///
55 /// When the module is enabled it will print messages when it receives certain events to the screen and the log 55 /// When the module is enabled it will print messages when it receives certain events to the screen and the log
56 /// file. 56 /// file.
57 /// </remarks> 57 /// </remarks>
@@ -59,34 +59,34 @@ namespace OpenSim.Region.OptionalModules.Example.BareBonesNonShared
59 public class BareBonesNonSharedModule : INonSharedRegionModule 59 public class BareBonesNonSharedModule : INonSharedRegionModule
60 { 60 {
61 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 61 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
62 62
63 public string Name { get { return "Bare Bones Non Shared Module"; } } 63 public string Name { get { return "Bare Bones Non Shared Module"; } }
64 64
65 public Type ReplaceableInterface { get { return null; } } 65 public Type ReplaceableInterface { get { return null; } }
66 66
67 public void Initialise(IConfigSource source) 67 public void Initialise(IConfigSource source)
68 { 68 {
69 m_log.DebugFormat("[BARE BONES NON SHARED]: INITIALIZED MODULE"); 69 m_log.DebugFormat("[BARE BONES NON SHARED]: INITIALIZED MODULE");
70 } 70 }
71 71
72 public void Close() 72 public void Close()
73 { 73 {
74 m_log.DebugFormat("[BARE BONES NON SHARED]: CLOSED MODULE"); 74 m_log.DebugFormat("[BARE BONES NON SHARED]: CLOSED MODULE");
75 } 75 }
76 76
77 public void AddRegion(Scene scene) 77 public void AddRegion(Scene scene)
78 { 78 {
79 m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} ADDED", scene.RegionInfo.RegionName); 79 m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} ADDED", scene.RegionInfo.RegionName);
80 } 80 }
81 81
82 public void RemoveRegion(Scene scene) 82 public void RemoveRegion(Scene scene)
83 { 83 {
84 m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} REMOVED", scene.RegionInfo.RegionName); 84 m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
85 } 85 }
86 86
87 public void RegionLoaded(Scene scene) 87 public void RegionLoaded(Scene scene)
88 { 88 {
89 m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} LOADED", scene.RegionInfo.RegionName); 89 m_log.DebugFormat("[BARE BONES NON SHARED]: REGION {0} LOADED", scene.RegionInfo.RegionName);
90 } 90 }
91 } 91 }
92} \ No newline at end of file 92} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
index 46fea3e..1271e3f 100644
--- a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
+++ b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
@@ -46,52 +46,52 @@ namespace OpenSim.Region.OptionalModules.Example.BareBonesShared
46 /// </summary> 46 /// </summary>
47 /// <remarks> 47 /// <remarks>
48 /// This module is the simplest possible example of a shared region module (a module which is shared by every 48 /// This module is the simplest possible example of a shared region module (a module which is shared by every
49 /// scene/region running on the simulator). If anybody wants to create a more complex example in the future then 49 /// scene/region running on the simulator). If anybody wants to create a more complex example in the future then
50 /// please create a separate class. 50 /// please create a separate class.
51 /// 51 ///
52 /// This module is not active by default. If you want to see it in action, 52 /// This module is not active by default. If you want to see it in action,
53 /// then just uncomment the line below starting with [Extension(Path... 53 /// then just uncomment the line below starting with [Extension(Path...
54 /// 54 ///
55 /// When the module is enabled it will print messages when it receives certain events to the screen and the log 55 /// When the module is enabled it will print messages when it receives certain events to the screen and the log
56 /// file. 56 /// file.
57 /// </remarks> 57 /// </remarks>
58 //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesSharedModule")] 58 //[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "BareBonesSharedModule")]
59 public class BareBonesSharedModule : ISharedRegionModule 59 public class BareBonesSharedModule : ISharedRegionModule
60 { 60 {
61 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 61 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
62 62
63 public string Name { get { return "Bare Bones Shared Module"; } } 63 public string Name { get { return "Bare Bones Shared Module"; } }
64 64
65 public Type ReplaceableInterface { get { return null; } } 65 public Type ReplaceableInterface { get { return null; } }
66 66
67 public void Initialise(IConfigSource source) 67 public void Initialise(IConfigSource source)
68 { 68 {
69 m_log.DebugFormat("[BARE BONES SHARED]: INITIALIZED MODULE"); 69 m_log.DebugFormat("[BARE BONES SHARED]: INITIALIZED MODULE");
70 } 70 }
71 71
72 public void PostInitialise() 72 public void PostInitialise()
73 { 73 {
74 m_log.DebugFormat("[BARE BONES SHARED]: POST INITIALIZED MODULE"); 74 m_log.DebugFormat("[BARE BONES SHARED]: POST INITIALIZED MODULE");
75 } 75 }
76 76
77 public void Close() 77 public void Close()
78 { 78 {
79 m_log.DebugFormat("[BARE BONES SHARED]: CLOSED MODULE"); 79 m_log.DebugFormat("[BARE BONES SHARED]: CLOSED MODULE");
80 } 80 }
81 81
82 public void AddRegion(Scene scene) 82 public void AddRegion(Scene scene)
83 { 83 {
84 m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} ADDED", scene.RegionInfo.RegionName); 84 m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} ADDED", scene.RegionInfo.RegionName);
85 } 85 }
86 86
87 public void RemoveRegion(Scene scene) 87 public void RemoveRegion(Scene scene)
88 { 88 {
89 m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} REMOVED", scene.RegionInfo.RegionName); 89 m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
90 } 90 }
91 91
92 public void RegionLoaded(Scene scene) 92 public void RegionLoaded(Scene scene)
93 { 93 {
94 m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} LOADED", scene.RegionInfo.RegionName); 94 m_log.DebugFormat("[BARE BONES SHARED]: REGION {0} LOADED", scene.RegionInfo.RegionName);
95 } 95 }
96 } 96 }
97} \ No newline at end of file 97} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs b/OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs
index 5bf0ed4..0747cc0 100644
--- a/OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs
+++ b/OpenSim/Region/OptionalModules/Example/WebSocketEchoTest/WebSocketEchoModule.cs
@@ -40,7 +40,7 @@ using OpenSim.Framework.Servers.HttpServer;
40 40
41namespace OpenSim.Region.OptionalModules.WebSocketEchoModule 41namespace OpenSim.Region.OptionalModules.WebSocketEchoModule
42{ 42{
43 43
44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebSocketEchoModule")] 44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WebSocketEchoModule")]
45 public class WebSocketEchoModule : ISharedRegionModule 45 public class WebSocketEchoModule : ISharedRegionModule
46 { 46 {
@@ -111,7 +111,7 @@ namespace OpenSim.Region.OptionalModules.WebSocketEchoModule
111 obj.SendPingCheck(); 111 obj.SendPingCheck();
112 } 112 }
113 113
114 114
115 private void HandlerOnOnUpgradeCompleted(object sender, UpgradeCompletedEventArgs completeddata) 115 private void HandlerOnOnUpgradeCompleted(object sender, UpgradeCompletedEventArgs completeddata)
116 { 116 {
117 WebSocketHttpServerHandler obj = sender as WebSocketHttpServerHandler; 117 WebSocketHttpServerHandler obj = sender as WebSocketHttpServerHandler;
@@ -136,14 +136,14 @@ namespace OpenSim.Region.OptionalModules.WebSocketEchoModule
136 obj.Dispose(); 136 obj.Dispose();
137 } 137 }
138 138
139 // Shutting down.. so shut down all sockets. 139 // Shutting down.. so shut down all sockets.
140 // Note.. this should be done outside of an ienumerable if you're also hook to the close event. 140 // Note.. this should be done outside of an ienumerable if you're also hook to the close event.
141 public void Close() 141 public void Close()
142 { 142 {
143 if (!enabled) 143 if (!enabled)
144 return; 144 return;
145 145
146 // We convert this to a for loop so we're not in in an IEnumerable when the close 146 // We convert this to a for loop so we're not in in an IEnumerable when the close
147 //call triggers an event which then removes item from _activeHandlers that we're enumerating 147 //call triggers an event which then removes item from _activeHandlers that we're enumerating
148 WebSocketHttpServerHandler[] items = new WebSocketHttpServerHandler[_activeHandlers.Count]; 148 WebSocketHttpServerHandler[] items = new WebSocketHttpServerHandler[_activeHandlers.Count];
149 _activeHandlers.CopyTo(items); 149 _activeHandlers.CopyTo(items);
diff --git a/OpenSim/Region/OptionalModules/Framework/Monitoring/EtcdMonitoringModule.cs b/OpenSim/Region/OptionalModules/Framework/Monitoring/EtcdMonitoringModule.cs
new file mode 100644
index 0000000..921bbfb
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Framework/Monitoring/EtcdMonitoringModule.cs
@@ -0,0 +1,195 @@
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.Text;
32using log4net;
33using Mono.Addins;
34using Nini.Config;
35using OpenMetaverse;
36using OpenSim.Framework;
37using OpenSim.Framework.Console;
38using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes;
40using netcd;
41using netcd.Serialization;
42using netcd.Advanced;
43using netcd.Advanced.Requests;
44
45namespace OpenSim.Region.OptionalModules.Framework.Monitoring
46{
47 /// <summary>
48 /// Allows to store monitoring data in etcd, a high availability
49 /// name-value store.
50 /// </summary>
51 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "EtcdMonitoringModule")]
52 public class EtcdMonitoringModule : INonSharedRegionModule, IEtcdModule
53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55
56 protected Scene m_scene;
57 protected IEtcdClient m_client;
58 protected bool m_enabled = false;
59 protected string m_etcdBasePath = String.Empty;
60 protected bool m_appendRegionID = true;
61
62 public string Name
63 {
64 get { return "EtcdMonitoringModule"; }
65 }
66
67 public Type ReplaceableInterface
68 {
69 get { return null; }
70 }
71
72 public void Initialise(IConfigSource source)
73 {
74 if (source.Configs["Etcd"] == null)
75 return;
76
77 IConfig etcdConfig = source.Configs["Etcd"];
78
79 string etcdUrls = etcdConfig.GetString("EtcdUrls", String.Empty);
80 if (etcdUrls == String.Empty)
81 return;
82
83 m_etcdBasePath = etcdConfig.GetString("BasePath", m_etcdBasePath);
84 m_appendRegionID = etcdConfig.GetBoolean("AppendRegionID", m_appendRegionID);
85
86 if (!m_etcdBasePath.EndsWith("/"))
87 m_etcdBasePath += "/";
88
89 try
90 {
91 string[] endpoints = etcdUrls.Split(new char[] {','});
92 List<Uri> uris = new List<Uri>();
93 foreach (string endpoint in endpoints)
94 uris.Add(new Uri(endpoint.Trim()));
95
96 m_client = new EtcdClient(uris.ToArray(), new DefaultSerializer(), new DefaultSerializer());
97 }
98 catch (Exception e)
99 {
100 m_log.DebugFormat("[ETCD]: Error initializing connection: " + e.ToString());
101 return;
102 }
103
104 m_log.DebugFormat("[ETCD]: Etcd module configured");
105 m_enabled = true;
106 }
107
108 public void Close()
109 {
110 //m_client = null;
111 m_scene = null;
112 }
113
114 public void AddRegion(Scene scene)
115 {
116 m_scene = scene;
117
118 if (m_enabled)
119 {
120 if (m_appendRegionID)
121 m_etcdBasePath += m_scene.RegionInfo.RegionID.ToString() + "/";
122
123 m_log.DebugFormat("[ETCD]: Using base path {0} for all keys", m_etcdBasePath);
124
125 try
126 {
127 m_client.Advanced.CreateDirectory(new CreateDirectoryRequest() {Key = m_etcdBasePath});
128 }
129 catch (Exception e)
130 {
131 m_log.ErrorFormat("Exception trying to create base path {0}: " + e.ToString(), m_etcdBasePath);
132 }
133
134 scene.RegisterModuleInterface<IEtcdModule>(this);
135 }
136 }
137
138 public void RemoveRegion(Scene scene)
139 {
140 }
141
142 public void RegionLoaded(Scene scene)
143 {
144 }
145
146 public bool Store(string k, string v)
147 {
148 return Store(k, v, 0);
149 }
150
151 public bool Store(string k, string v, int ttl)
152 {
153 Response resp = m_client.Advanced.SetKey(new SetKeyRequest() { Key = m_etcdBasePath + k, Value = v, TimeToLive = ttl });
154
155 if (resp == null)
156 return false;
157
158 if (resp.ErrorCode.HasValue)
159 {
160 m_log.DebugFormat("[ETCD]: Error {0} ({1}) storing {2} => {3}", resp.Cause, (int)resp.ErrorCode, m_etcdBasePath + k, v);
161
162 return false;
163 }
164
165 return true;
166 }
167
168 public string Get(string k)
169 {
170 Response resp = m_client.Advanced.GetKey(new GetKeyRequest() { Key = m_etcdBasePath + k });
171
172 if (resp == null)
173 return String.Empty;
174
175 if (resp.ErrorCode.HasValue)
176 {
177 m_log.DebugFormat("[ETCD]: Error {0} ({1}) getting {2}", resp.Cause, (int)resp.ErrorCode, m_etcdBasePath + k);
178
179 return String.Empty;
180 }
181
182 return resp.Node.Value;
183 }
184
185 public void Delete(string k)
186 {
187 m_client.Advanced.DeleteKey(new DeleteKeyRequest() { Key = m_etcdBasePath + k });
188 }
189
190 public void Watch(string k, Action<string> callback)
191 {
192 m_client.Advanced.WatchKey(new WatchKeyRequest() { Key = m_etcdBasePath + k, Callback = (x) => { callback(x.Node.Value); } });
193 }
194 }
195}
diff --git a/OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs b/OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs
index a25e034..95bb13e 100644
--- a/OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs
+++ b/OpenSim/Region/OptionalModules/Framework/Monitoring/MonitorServicesModule.cs
@@ -48,11 +48,11 @@ namespace OpenSim.Region.OptionalModules.Framework.Monitoring
48 protected Scene m_scene; 48 protected Scene m_scene;
49 49
50// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
52 public string Name { get { return "Services Health Monitoring Module"; } } 52 public string Name { get { return "Services Health Monitoring Module"; } }
53 53
54 public Type ReplaceableInterface { get { return null; } } 54 public Type ReplaceableInterface { get { return null; } }
55 55
56 public void Initialise(IConfigSource source) 56 public void Initialise(IConfigSource source)
57 { 57 {
58 } 58 }
@@ -64,7 +64,7 @@ namespace OpenSim.Region.OptionalModules.Framework.Monitoring
64 public void Close() 64 public void Close()
65 { 65 {
66 } 66 }
67 67
68 public void AddRegion(Scene scene) 68 public void AddRegion(Scene scene)
69 { 69 {
70 if (m_scene == null) 70 if (m_scene == null)
diff --git a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
index e95889d..e8cb052 100644
--- a/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
+++ b/OpenSim/Region/OptionalModules/Materials/MaterialsModule.cs
@@ -59,15 +59,20 @@ namespace OpenSim.Region.OptionalModules.Materials
59 { 59 {
60 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 60 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
61 61
62 public string Name { get { return "MaterialsModule"; } } 62 public string Name { get { return "MaterialsModule"; } }
63 63
64 public Type ReplaceableInterface { get { return null; } } 64 public Type ReplaceableInterface { get { return null; } }
65 65
66 IAssetCache m_cache;
66 private Scene m_scene = null; 67 private Scene m_scene = null;
67 private bool m_enabled = false; 68 private bool m_enabled = false;
68 private int m_maxMaterialsPerTransaction = 50; 69 private int m_maxMaterialsPerTransaction = 50;
69 70
70 public Dictionary<UUID, OSDMap> m_regionMaterials = new Dictionary<UUID, OSDMap>(); 71 public Dictionary<UUID, OSDMap> m_Materials = new Dictionary<UUID, OSDMap>();
72 public Dictionary<UUID, int> m_MaterialsRefCount = new Dictionary<UUID, int>();
73
74 private Dictionary<ulong, AssetBase> m_changes = new Dictionary<ulong, AssetBase>();
75 private Dictionary<ulong, double> m_changesTime = new Dictionary<ulong, double>();
71 76
72 public void Initialise(IConfigSource source) 77 public void Initialise(IConfigSource source)
73 { 78 {
@@ -83,13 +88,13 @@ namespace OpenSim.Region.OptionalModules.Materials
83 if (m_enabled) 88 if (m_enabled)
84 m_log.DebugFormat("[Materials]: Initialized"); 89 m_log.DebugFormat("[Materials]: Initialized");
85 } 90 }
86 91
87 public void Close() 92 public void Close()
88 { 93 {
89 if (!m_enabled) 94 if (!m_enabled)
90 return; 95 return;
91 } 96 }
92 97
93 public void AddRegion(Scene scene) 98 public void AddRegion(Scene scene)
94 { 99 {
95 if (!m_enabled) 100 if (!m_enabled)
@@ -98,6 +103,56 @@ namespace OpenSim.Region.OptionalModules.Materials
98 m_scene = scene; 103 m_scene = scene;
99 m_scene.EventManager.OnRegisterCaps += OnRegisterCaps; 104 m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
100 m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene; 105 m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene;
106 m_scene.EventManager.OnBackup += EventManager_OnBackup;
107 }
108
109 private void EventManager_OnBackup(ISimulationDataService datastore, bool forcedBackup)
110 {
111 List<AssetBase> toStore;
112 List<ulong> hashlist;
113
114
115 lock (m_Materials)
116 {
117 if(m_changes.Count == 0)
118 return;
119
120 if(forcedBackup)
121 {
122 toStore = new List<AssetBase>(m_changes.Values);
123 m_changes.Clear();
124 m_changesTime.Clear();
125 }
126 else
127 {
128 toStore = new List<AssetBase>();
129 hashlist = new List<ulong>();
130 double storetime = Util.GetTimeStampMS() - 60000;
131 foreach(KeyValuePair<ulong,double> kvp in m_changesTime)
132 {
133 if(kvp.Value < storetime)
134 {
135 toStore.Add(m_changes[kvp.Key]);
136 hashlist.Add(kvp.Key);
137 }
138 }
139 foreach(ulong u in hashlist)
140 {
141 m_changesTime.Remove(u);
142 m_changes.Remove(u);
143 }
144 }
145
146 if(toStore.Count > 0)
147 Util.FireAndForget(delegate
148 {
149 foreach(AssetBase a in toStore)
150 {
151 a.Local = false;
152 m_scene.AssetService.Store(a);
153 }
154 });
155 }
101 } 156 }
102 157
103 private void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) 158 private void EventManager_OnObjectAddedToScene(SceneObjectGroup obj)
@@ -111,7 +166,7 @@ namespace OpenSim.Region.OptionalModules.Materials
111 { 166 {
112 string capsBase = "/CAPS/" + caps.CapsObjectPath; 167 string capsBase = "/CAPS/" + caps.CapsObjectPath;
113 168
114 IRequestHandler renderMaterialsPostHandler 169 IRequestHandler renderMaterialsPostHandler
115 = new RestStreamHandler("POST", capsBase + "/", 170 = new RestStreamHandler("POST", capsBase + "/",
116 (request, path, param, httpRequest, httpResponse) 171 (request, path, param, httpRequest, httpResponse)
117 => RenderMaterialsPostCap(request, agentID), 172 => RenderMaterialsPostCap(request, agentID),
@@ -122,7 +177,7 @@ namespace OpenSim.Region.OptionalModules.Materials
122 // and POST handlers, (at least at the time this was originally written), so we first set up a POST 177 // and POST handlers, (at least at the time this was originally written), so we first set up a POST
123 // handler normally and then add a GET handler via MainServer 178 // handler normally and then add a GET handler via MainServer
124 179
125 IRequestHandler renderMaterialsGetHandler 180 IRequestHandler renderMaterialsGetHandler
126 = new RestStreamHandler("GET", capsBase + "/", 181 = new RestStreamHandler("GET", capsBase + "/",
127 (request, path, param, httpRequest, httpResponse) 182 (request, path, param, httpRequest, httpResponse)
128 => RenderMaterialsGetCap(request), 183 => RenderMaterialsGetCap(request),
@@ -130,14 +185,14 @@ namespace OpenSim.Region.OptionalModules.Materials
130 MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler); 185 MainServer.Instance.AddStreamHandler(renderMaterialsGetHandler);
131 186
132 // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well 187 // materials viewer seems to use either POST or PUT, so assign POST handler for PUT as well
133 IRequestHandler renderMaterialsPutHandler 188 IRequestHandler renderMaterialsPutHandler
134 = new RestStreamHandler("PUT", capsBase + "/", 189 = new RestStreamHandler("PUT", capsBase + "/",
135 (request, path, param, httpRequest, httpResponse) 190 (request, path, param, httpRequest, httpResponse)
136 => RenderMaterialsPostCap(request, agentID), 191 => RenderMaterialsPutCap(request, agentID),
137 "RenderMaterials", null); 192 "RenderMaterials", null);
138 MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler); 193 MainServer.Instance.AddStreamHandler(renderMaterialsPutHandler);
139 } 194 }
140 195
141 public void RemoveRegion(Scene scene) 196 public void RemoveRegion(Scene scene)
142 { 197 {
143 if (!m_enabled) 198 if (!m_enabled)
@@ -145,12 +200,14 @@ namespace OpenSim.Region.OptionalModules.Materials
145 200
146 m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps; 201 m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps;
147 m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene; 202 m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene;
148 } 203 m_scene.EventManager.OnBackup -= EventManager_OnBackup;
149 204 }
205
150 public void RegionLoaded(Scene scene) 206 public void RegionLoaded(Scene scene)
151 { 207 {
152 if (!m_enabled) return; 208 if (!m_enabled) return;
153 209
210 m_cache = scene.RequestModuleInterface<IAssetCache>();
154 ISimulatorFeaturesModule featuresModule = scene.RequestModuleInterface<ISimulatorFeaturesModule>(); 211 ISimulatorFeaturesModule featuresModule = scene.RequestModuleInterface<ISimulatorFeaturesModule>();
155 if (featuresModule != null) 212 if (featuresModule != null)
156 featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest; 213 featuresModule.OnSimulatorFeaturesRequest += OnSimulatorFeaturesRequest;
@@ -203,8 +260,17 @@ namespace OpenSim.Region.OptionalModules.Materials
203 { 260 {
204 try 261 try
205 { 262 {
206 lock (m_regionMaterials) 263 lock (m_Materials)
207 m_regionMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; 264 {
265 UUID id = matMap["ID"].AsUUID();
266 if(m_Materials.ContainsKey(id))
267 m_MaterialsRefCount[id]++;
268 else
269 {
270 m_Materials[id] = (OSDMap)matMap["Material"];
271 m_MaterialsRefCount[id] = 1;
272 }
273 }
208 } 274 }
209 catch (Exception e) 275 catch (Exception e)
210 { 276 {
@@ -219,7 +285,7 @@ namespace OpenSim.Region.OptionalModules.Materials
219 /// Find the materials used in the SOP, and add them to 'm_regionMaterials'. 285 /// Find the materials used in the SOP, and add them to 'm_regionMaterials'.
220 /// </summary> 286 /// </summary>
221 private void GetStoredMaterialsInPart(SceneObjectPart part) 287 private void GetStoredMaterialsInPart(SceneObjectPart part)
222 { 288 {
223 if (part.Shape == null) 289 if (part.Shape == null)
224 return; 290 return;
225 291
@@ -233,7 +299,7 @@ namespace OpenSim.Region.OptionalModules.Materials
233 GetStoredMaterialInFace(part, te.DefaultTexture); 299 GetStoredMaterialInFace(part, te.DefaultTexture);
234 else 300 else
235 m_log.WarnFormat( 301 m_log.WarnFormat(
236 "[Materials]: Default texture for part {0} (part of object {1}) in {2} unexpectedly null. Ignoring.", 302 "[Materials]: Default texture for part {0} (part of object {1}) in {2} unexpectedly null. Ignoring.",
237 part.Name, part.ParentGroup.Name, m_scene.Name); 303 part.Name, part.ParentGroup.Name, m_scene.Name);
238 304
239 foreach (Primitive.TextureEntryFace face in te.FaceTextures) 305 foreach (Primitive.TextureEntryFace face in te.FaceTextures)
@@ -252,18 +318,22 @@ namespace OpenSim.Region.OptionalModules.Materials
252 if (id == UUID.Zero) 318 if (id == UUID.Zero)
253 return; 319 return;
254 320
255 lock (m_regionMaterials) 321 lock (m_Materials)
256 { 322 {
257 if (m_regionMaterials.ContainsKey(id)) 323 if (m_Materials.ContainsKey(id))
324 {
325 m_MaterialsRefCount[id]++;
258 return; 326 return;
259 327 }
260 byte[] data = m_scene.AssetService.GetData(id.ToString()); 328
261 if (data == null) 329 AssetBase matAsset = m_scene.AssetService.Get(id.ToString());
330 if (matAsset == null || matAsset.Data == null || matAsset.Data.Length == 0 )
262 { 331 {
263 m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id); 332 //m_log.WarnFormat("[Materials]: Prim \"{0}\" ({1}) contains unknown material ID {2}", part.Name, part.UUID, id);
264 return; 333 return;
265 } 334 }
266 335
336 byte[] data = matAsset.Data;
267 OSDMap mat; 337 OSDMap mat;
268 try 338 try
269 { 339 {
@@ -275,7 +345,8 @@ namespace OpenSim.Region.OptionalModules.Materials
275 return; 345 return;
276 } 346 }
277 347
278 m_regionMaterials[id] = mat; 348 m_Materials[id] = mat;
349 m_MaterialsRefCount[id] = 1;
279 } 350 }
280 } 351 }
281 352
@@ -284,8 +355,6 @@ namespace OpenSim.Region.OptionalModules.Materials
284 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request); 355 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
285 OSDMap resp = new OSDMap(); 356 OSDMap resp = new OSDMap();
286 357
287 OSDMap materialsFromViewer = null;
288
289 OSDArray respArr = new OSDArray(); 358 OSDArray respArr = new OSDArray();
290 359
291 if (req.ContainsKey("Zipped")) 360 if (req.ContainsKey("Zipped"))
@@ -294,154 +363,224 @@ namespace OpenSim.Region.OptionalModules.Materials
294 363
295 byte[] inBytes = req["Zipped"].AsBinary(); 364 byte[] inBytes = req["Zipped"].AsBinary();
296 365
297 try 366 try
298 { 367 {
299 osd = ZDecompressBytesToOsd(inBytes); 368 osd = ZDecompressBytesToOsd(inBytes);
300 369
301 if (osd != null) 370 if (osd != null && osd is OSDArray)
302 { 371 {
303 if (osd is OSDArray) // assume array of MaterialIDs designating requested material entries 372 foreach (OSD elem in (OSDArray)osd)
304 { 373 {
305 foreach (OSD elem in (OSDArray)osd) 374 try
306 { 375 {
307 try 376 UUID id = new UUID(elem.AsBinary(), 0);
308 {
309 UUID id = new UUID(elem.AsBinary(), 0);
310 377
311 lock (m_regionMaterials) 378 lock (m_Materials)
379 {
380 if (m_Materials.ContainsKey(id))
312 { 381 {
313 if (m_regionMaterials.ContainsKey(id)) 382 OSDMap matMap = new OSDMap();
314 { 383 matMap["ID"] = OSD.FromBinary(id.GetBytes());
315 OSDMap matMap = new OSDMap(); 384 matMap["Material"] = m_Materials[id];
316 matMap["ID"] = OSD.FromBinary(id.GetBytes()); 385 respArr.Add(matMap);
317 matMap["Material"] = m_regionMaterials[id]; 386 }
318 respArr.Add(matMap); 387 else
319 } 388 {
320 else 389 m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString());
321 {
322 m_log.Warn("[Materials]: request for unknown material ID: " + id.ToString());
323 390
324 // Theoretically we could try to load the material from the assets service, 391 // Theoretically we could try to load the material from the assets service,
325 // but that shouldn't be necessary because the viewer should only request 392 // but that shouldn't be necessary because the viewer should only request
326 // materials that exist in a prim on the region, and all of these materials 393 // materials that exist in a prim on the region, and all of these materials
327 // are already stored in m_regionMaterials. 394 // are already stored in m_regionMaterials.
328 }
329 } 395 }
330 } 396 }
331 catch (Exception e) 397 }
332 { 398 catch (Exception e)
333 m_log.Error("Error getting materials in response to viewer request", e); 399 {
334 continue; 400 m_log.Error("Error getting materials in response to viewer request", e);
335 } 401 continue;
336 } 402 }
337 } 403 }
338 else if (osd is OSDMap) // request to assign a material 404 }
339 { 405 }
340 materialsFromViewer = osd as OSDMap; 406 catch (Exception e)
407 {
408 m_log.Warn("[Materials]: exception decoding zipped CAP payload ", e);
409 //return "";
410 }
411 }
412
413 resp["Zipped"] = ZCompressOSD(respArr, false);
414 string response = OSDParser.SerializeLLSDXmlString(resp);
415
416 //m_log.Debug("[Materials]: cap request: " + request);
417 //m_log.Debug("[Materials]: cap request (zipped portion): " + ZippedOsdBytesToString(req["Zipped"].AsBinary()));
418 //m_log.Debug("[Materials]: cap response: " + response);
419 return response;
420 }
421
422 public string RenderMaterialsPutCap(string request, UUID agentID)
423 {
424 OSDMap req = (OSDMap)OSDParser.DeserializeLLSDXml(request);
425 OSDMap resp = new OSDMap();
426
427 OSDMap materialsFromViewer = null;
428
429 OSDArray respArr = new OSDArray();
430
431 HashSet<SceneObjectPart> parts = new HashSet<SceneObjectPart>();
432 if (req.ContainsKey("Zipped"))
433 {
434 OSD osd = null;
435
436 byte[] inBytes = req["Zipped"].AsBinary();
341 437
342 if (materialsFromViewer.ContainsKey("FullMaterialsPerFace")) 438 try
439 {
440 osd = ZDecompressBytesToOsd(inBytes);
441
442 if (osd != null && osd is OSDMap)
443 {
444 materialsFromViewer = osd as OSDMap;
445
446 if (materialsFromViewer.ContainsKey("FullMaterialsPerFace"))
447 {
448 OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"];
449 if (matsOsd is OSDArray)
343 { 450 {
344 OSD matsOsd = materialsFromViewer["FullMaterialsPerFace"]; 451 OSDArray matsArr = matsOsd as OSDArray;
345 if (matsOsd is OSDArray)
346 {
347 OSDArray matsArr = matsOsd as OSDArray;
348 452
349 try 453 try
454 {
455 foreach (OSDMap matsMap in matsArr)
350 { 456 {
351 foreach (OSDMap matsMap in matsArr) 457 uint primLocalID = 0;
352 { 458 try {
353 uint primLocalID = 0; 459 primLocalID = matsMap["ID"].AsUInteger();
354 try { 460 }
355 primLocalID = matsMap["ID"].AsUInteger(); 461 catch (Exception e) {
356 } 462 m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message);
357 catch (Exception e) { 463 continue;
358 m_log.Warn("[Materials]: cannot decode \"ID\" from matsMap: " + e.Message); 464 }
359 continue;
360 }
361 465
362 OSDMap mat = null; 466 SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID);
363 try 467 if (sop == null)
364 { 468 {
365 mat = matsMap["Material"] as OSDMap; 469 m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString());
366 } 470 continue;
367 catch (Exception e) 471 }
368 {
369 m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
370 continue;
371 }
372 472
373 SceneObjectPart sop = m_scene.GetSceneObjectPart(primLocalID); 473 if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID))
374 if (sop == null) 474 {
375 { 475 m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID);
376 m_log.WarnFormat("[Materials]: SOP not found for localId: {0}", primLocalID.ToString()); 476 continue;
377 continue; 477 }
378 }
379 478
380 if (!m_scene.Permissions.CanEditObject(sop.UUID, agentID)) 479 OSDMap mat = null;
381 { 480 try
382 m_log.WarnFormat("User {0} can't edit object {1} {2}", agentID, sop.Name, sop.UUID); 481 {
383 continue; 482 mat = matsMap["Material"] as OSDMap;
384 } 483 }
484 catch (Exception e)
485 {
486 m_log.Warn("[Materials]: cannot decode \"Material\" from matsMap: " + e.Message);
487 continue;
488 }
385 489
386 Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length); 490 Primitive.TextureEntry te = new Primitive.TextureEntry(sop.Shape.TextureEntry, 0, sop.Shape.TextureEntry.Length);
387 if (te == null) 491 if (te == null)
388 { 492 {
389 m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID); 493 m_log.WarnFormat("[Materials]: Error in TextureEntry for SOP {0} {1}", sop.Name, sop.UUID);
390 continue; 494 continue;
391 } 495 }
392 496
497 UUID id;
498 if (mat == null)
499 {
500 // This happens then the user removes a material from a prim
501 id = UUID.Zero;
502 }
503 else
504 {
505 id = getNewID(mat);
506 }
393 507
394 UUID id; 508 int face = -1;
395 if (mat == null) 509 UUID oldid = UUID.Zero;
396 { 510 if (matsMap.ContainsKey("Face"))
397 // This happens then the user removes a material from a prim 511 {
398 id = UUID.Zero; 512 face = matsMap["Face"].AsInteger();
399 } 513 Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face);
514 oldid = faceEntry.MaterialID;
515 faceEntry.MaterialID = id;
516 }
517 else
518 {
519 if (te.DefaultTexture == null)
520 m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID);
400 else 521 else
401 { 522 {
402 id = StoreMaterialAsAsset(agentID, mat, sop); 523 oldid = te.DefaultTexture.MaterialID;
524 te.DefaultTexture.MaterialID = id;
403 } 525 }
526 }
404 527
528 //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id);
405 529
406 int face = -1; 530 // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually
531 sop.Shape.TextureEntry = te.GetBytes();
407 532
408 if (matsMap.ContainsKey("Face")) 533 lock(m_Materials)
409 { 534 {
410 face = matsMap["Face"].AsInteger(); 535 if(oldid != UUID.Zero && m_MaterialsRefCount.ContainsKey(oldid))
411 Primitive.TextureEntryFace faceEntry = te.CreateFace((uint)face);
412 faceEntry.MaterialID = id;
413 }
414 else
415 { 536 {
416 if (te.DefaultTexture == null) 537 m_MaterialsRefCount[oldid]--;
417 m_log.WarnFormat("[Materials]: TextureEntry.DefaultTexture is null in {0} {1}", sop.Name, sop.UUID); 538 if(m_MaterialsRefCount[oldid] <= 0)
418 else 539 {
419 te.DefaultTexture.MaterialID = id; 540 m_Materials.Remove(oldid);
541 m_MaterialsRefCount.Remove(oldid);
542 m_cache.Expire(oldid.ToString());
543 }
420 } 544 }
421 545
422 //m_log.DebugFormat("[Materials]: in \"{0}\" {1}, setting material ID for face {2} to {3}", sop.Name, sop.UUID, face, id); 546 if(id != UUID.Zero)
423
424 // We can't use sop.UpdateTextureEntry(te) because it filters, so do it manually
425 sop.Shape.TextureEntry = te.GetBytes();
426
427 if (sop.ParentGroup != null)
428 { 547 {
429 sop.TriggerScriptChangedEvent(Changed.TEXTURE); 548 AssetBase asset = CacheMaterialAsAsset(id, agentID, mat, sop);
430 sop.UpdateFlag = UpdateRequired.FULL; 549 if(asset != null)
431 sop.ParentGroup.HasGroupChanged = true; 550 {
432 sop.ScheduleFullUpdate(); 551 ulong materialHash = (ulong)primLocalID << 32;
552 if(face < 0)
553 materialHash += 0xffffffff;
554 else
555 materialHash +=(ulong)face;
556
557 m_changes[materialHash] = asset;
558 m_changesTime[materialHash] = Util.GetTimeStampMS();
559 }
433 } 560 }
434 } 561 }
562
563 if(!parts.Contains(sop))
564 parts.Add(sop);
435 } 565 }
436 catch (Exception e) 566
567 foreach(SceneObjectPart sop in parts)
437 { 568 {
438 m_log.Warn("[Materials]: exception processing received material ", e); 569 if (sop.ParentGroup != null && !sop.ParentGroup.IsDeleted)
570 {
571 sop.TriggerScriptChangedEvent(Changed.TEXTURE);
572 sop.ScheduleFullUpdate();
573 sop.ParentGroup.HasGroupChanged = true;
574 }
439 } 575 }
440 } 576 }
577 catch (Exception e)
578 {
579 m_log.Warn("[Materials]: exception processing received material ", e);
580 }
441 } 581 }
442 } 582 }
443 } 583 }
444
445 } 584 }
446 catch (Exception e) 585 catch (Exception e)
447 { 586 {
@@ -450,7 +589,6 @@ namespace OpenSim.Region.OptionalModules.Materials
450 } 589 }
451 } 590 }
452 591
453
454 resp["Zipped"] = ZCompressOSD(respArr, false); 592 resp["Zipped"] = ZCompressOSD(respArr, false);
455 string response = OSDParser.SerializeLLSDXmlString(resp); 593 string response = OSDParser.SerializeLLSDXmlString(resp);
456 594
@@ -460,6 +598,40 @@ namespace OpenSim.Region.OptionalModules.Materials
460 return response; 598 return response;
461 } 599 }
462 600
601 private UUID getNewID(OSDMap mat)
602 {
603 // ugly and done twice but keep compatibility for now
604 Byte[] data = System.Text.Encoding.ASCII.GetBytes(OSDParser.SerializeLLSDXmlString(mat));
605 using (var md5 = MD5.Create())
606 return new UUID(md5.ComputeHash(data), 0);
607 }
608
609 private AssetBase CacheMaterialAsAsset(UUID id, UUID agentID, OSDMap mat, SceneObjectPart sop)
610 {
611 AssetBase asset = null;
612 lock (m_Materials)
613 {
614 if (!m_Materials.ContainsKey(id))
615 {
616 m_Materials[id] = mat;
617 m_MaterialsRefCount[id] = 1;
618
619 byte[] data = System.Text.Encoding.ASCII.GetBytes(OSDParser.SerializeLLSDXmlString(mat));
620
621 // This asset might exist already, but it's ok to try to store it again
622 string name = "Material " + ChooseMaterialName(mat, sop);
623 name = name.Substring(0, Math.Min(64, name.Length)).Trim();
624 asset = new AssetBase(id, name, (sbyte)OpenSimAssetType.Material, agentID.ToString());
625 asset.Data = data;
626 asset.Local = true;
627 m_cache.Cache(asset);
628 }
629 else
630 m_MaterialsRefCount[id]++;
631 }
632 return asset;
633 }
634
463 private UUID StoreMaterialAsAsset(UUID agentID, OSDMap mat, SceneObjectPart sop) 635 private UUID StoreMaterialAsAsset(UUID agentID, OSDMap mat, SceneObjectPart sop)
464 { 636 {
465 UUID id; 637 UUID id;
@@ -469,11 +641,12 @@ namespace OpenSim.Region.OptionalModules.Materials
469 using (var md5 = MD5.Create()) 641 using (var md5 = MD5.Create())
470 id = new UUID(md5.ComputeHash(data), 0); 642 id = new UUID(md5.ComputeHash(data), 0);
471 643
472 lock (m_regionMaterials) 644 lock (m_Materials)
473 { 645 {
474 if (!m_regionMaterials.ContainsKey(id)) 646 if (!m_Materials.ContainsKey(id))
475 { 647 {
476 m_regionMaterials[id] = mat; 648 m_Materials[id] = mat;
649 m_MaterialsRefCount[id] = 1;
477 650
478 // This asset might exist already, but it's ok to try to store it again 651 // This asset might exist already, but it's ok to try to store it again
479 string name = "Material " + ChooseMaterialName(mat, sop); 652 string name = "Material " + ChooseMaterialName(mat, sop);
@@ -482,6 +655,8 @@ namespace OpenSim.Region.OptionalModules.Materials
482 asset.Data = data; 655 asset.Data = data;
483 m_scene.AssetService.Store(asset); 656 m_scene.AssetService.Store(asset);
484 } 657 }
658 else
659 m_MaterialsRefCount[id]++;
485 } 660 }
486 return id; 661 return id;
487 } 662 }
@@ -509,7 +684,7 @@ namespace OpenSim.Region.OptionalModules.Materials
509 684
510 if (sop.Name != "Primitive") 685 if (sop.Name != "Primitive")
511 return sop.Name; 686 return sop.Name;
512 687
513 if ((sop.ParentGroup != null) && (sop.ParentGroup.Name != "Primitive")) 688 if ((sop.ParentGroup != null) && (sop.ParentGroup.Name != "Primitive"))
514 return sop.ParentGroup.Name; 689 return sop.ParentGroup.Name;
515 690
@@ -523,9 +698,9 @@ namespace OpenSim.Region.OptionalModules.Materials
523 int matsCount = 0; 698 int matsCount = 0;
524 OSDArray allOsd = new OSDArray(); 699 OSDArray allOsd = new OSDArray();
525 700
526 lock (m_regionMaterials) 701 lock (m_Materials)
527 { 702 {
528 foreach (KeyValuePair<UUID, OSDMap> kvp in m_regionMaterials) 703 foreach (KeyValuePair<UUID, OSDMap> kvp in m_Materials)
529 { 704 {
530 OSDMap matMap = new OSDMap(); 705 OSDMap matMap = new OSDMap();
531 706
@@ -573,7 +748,7 @@ namespace OpenSim.Region.OptionalModules.Materials
573 748
574 using (MemoryStream msSinkCompressed = new MemoryStream()) 749 using (MemoryStream msSinkCompressed = new MemoryStream())
575 { 750 {
576 using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkCompressed, 751 using (Ionic.Zlib.ZlibStream zOut = new Ionic.Zlib.ZlibStream(msSinkCompressed,
577 Ionic.Zlib.CompressionMode.Compress, CompressionLevel.BestCompression, true)) 752 Ionic.Zlib.CompressionMode.Compress, CompressionLevel.BestCompression, true))
578 { 753 {
579 zOut.Write(data, 0, data.Length); 754 zOut.Write(data, 0, data.Length);
diff --git a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
index 1d9179c..bcfb34d 100644..100755
--- a/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
+++ b/OpenSim/Region/OptionalModules/PhysicsParameters/PhysicsParameters.cs
@@ -54,10 +54,10 @@ namespace OpenSim.Region.OptionalModules.PhysicsParameters
54 private static bool m_commandsLoaded = false; 54 private static bool m_commandsLoaded = false;
55 55
56 #region ISharedRegionModule 56 #region ISharedRegionModule
57 public string Name { get { return "Runtime Physics Parameter Module"; } } 57 public string Name { get { return "Runtime Physics Parameter Module"; } }
58 58
59 public Type ReplaceableInterface { get { return null; } } 59 public Type ReplaceableInterface { get { return null; } }
60 60
61 public void Initialise(IConfigSource source) 61 public void Initialise(IConfigSource source)
62 { 62 {
63 // m_log.DebugFormat("{0}: INITIALIZED MODULE", LogHeader); 63 // m_log.DebugFormat("{0}: INITIALIZED MODULE", LogHeader);
@@ -68,29 +68,29 @@ namespace OpenSim.Region.OptionalModules.PhysicsParameters
68 // m_log.DebugFormat("[{0}: POST INITIALIZED MODULE", LogHeader); 68 // m_log.DebugFormat("[{0}: POST INITIALIZED MODULE", LogHeader);
69 InstallInterfaces(); 69 InstallInterfaces();
70 } 70 }
71 71
72 public void Close() 72 public void Close()
73 { 73 {
74 // m_log.DebugFormat("{0}: CLOSED MODULE", LogHeader); 74 // m_log.DebugFormat("{0}: CLOSED MODULE", LogHeader);
75 } 75 }
76 76
77 public void AddRegion(Scene scene) 77 public void AddRegion(Scene scene)
78 { 78 {
79 // m_log.DebugFormat("{0}: REGION {1} ADDED", LogHeader, scene.RegionInfo.RegionName); 79 // m_log.DebugFormat("{0}: REGION {1} ADDED", LogHeader, scene.RegionInfo.RegionName);
80 m_scenes.Add(scene); 80 m_scenes.Add(scene);
81 } 81 }
82 82
83 public void RemoveRegion(Scene scene) 83 public void RemoveRegion(Scene scene)
84 { 84 {
85 // m_log.DebugFormat("{0}: REGION {1} REMOVED", LogHeader, scene.RegionInfo.RegionName); 85 // m_log.DebugFormat("{0}: REGION {1} REMOVED", LogHeader, scene.RegionInfo.RegionName);
86 if (m_scenes.Contains(scene)) 86 if (m_scenes.Contains(scene))
87 m_scenes.Remove(scene); 87 m_scenes.Remove(scene);
88 } 88 }
89 89
90 public void RegionLoaded(Scene scene) 90 public void RegionLoaded(Scene scene)
91 { 91 {
92 // m_log.DebugFormat("{0}: REGION {1} LOADED", LogHeader, scene.RegionInfo.RegionName); 92 // m_log.DebugFormat("{0}: REGION {1} LOADED", LogHeader, scene.RegionInfo.RegionName);
93 } 93 }
94 #endregion INonSharedRegionModule 94 #endregion INonSharedRegionModule
95 95
96 private const string getInvocation = "physics get [<param>|ALL]"; 96 private const string getInvocation = "physics get [<param>|ALL]";
diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
index 395bbf1..61b6d68 100644
--- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
+++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
@@ -52,14 +52,15 @@ namespace OpenSim.Region.OptionalModules
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
53 private bool m_enabled; 53 private bool m_enabled;
54 54
55 public string Name { get { return "PrimLimitsModule"; } } 55 private Scene m_scene;
56 56 public string Name { get { return "PrimLimitsModule"; } }
57
57 public Type ReplaceableInterface { get { return null; } } 58 public Type ReplaceableInterface { get { return null; } }
58 59
59 public void Initialise(IConfigSource config) 60 public void Initialise(IConfigSource config)
60 { 61 {
61 string permissionModules = Util.GetConfigVarFromSections<string>(config, "permissionmodules", 62 string permissionModules = Util.GetConfigVarFromSections<string>(config, "permissionmodules",
62 new string[] { "Startup", "Permissions" }, "DefaultPermissionsModule"); 63 new string[] { "Startup", "Permissions" }, "DefaultPermissionsModule");
63 64
64 List<string> modules = new List<string>(permissionModules.Split(',').Select(m => m.Trim())); 65 List<string> modules = new List<string>(permissionModules.Split(',').Select(m => m.Trim()));
65 66
@@ -69,46 +70,47 @@ namespace OpenSim.Region.OptionalModules
69 m_log.DebugFormat("[PRIM LIMITS]: Initialized module"); 70 m_log.DebugFormat("[PRIM LIMITS]: Initialized module");
70 m_enabled = true; 71 m_enabled = true;
71 } 72 }
72 73
73 public void Close() 74 public void Close()
74 { 75 {
75 } 76 }
76 77
77 public void AddRegion(Scene scene) 78 public void AddRegion(Scene scene)
78 { 79 {
79 if (!m_enabled) 80 if (!m_enabled)
80 {
81 return; 81 return;
82 } 82
83 m_scene = scene;
83 scene.Permissions.OnRezObject += CanRezObject; 84 scene.Permissions.OnRezObject += CanRezObject;
84 scene.Permissions.OnObjectEntry += CanObjectEnter; 85 scene.Permissions.OnObjectEntry += CanObjectEnter;
86 scene.Permissions.OnObjectEnterWithScripts += CanObjectEnterWithScripts;
85 scene.Permissions.OnDuplicateObject += CanDuplicateObject; 87 scene.Permissions.OnDuplicateObject += CanDuplicateObject;
86 88
87 m_log.DebugFormat("[PRIM LIMITS]: Region {0} added", scene.RegionInfo.RegionName); 89 m_log.DebugFormat("[PRIM LIMITS]: Region {0} added", scene.RegionInfo.RegionName);
88 } 90 }
89 91
90 public void RemoveRegion(Scene scene) 92 public void RemoveRegion(Scene scene)
91 { 93 {
92 if (m_enabled) 94 if (!m_enabled)
93 {
94 return; 95 return;
95 }
96 96
97 scene.Permissions.OnRezObject -= CanRezObject; 97 m_scene.Permissions.OnRezObject -= CanRezObject;
98 scene.Permissions.OnObjectEntry -= CanObjectEnter; 98 m_scene.Permissions.OnObjectEntry -= CanObjectEnter;
99 scene.Permissions.OnDuplicateObject -= CanDuplicateObject; 99 scene.Permissions.OnObjectEnterWithScripts -= CanObjectEnterWithScripts;
100 } 100 m_scene.Permissions.OnDuplicateObject -= CanDuplicateObject;
101 101 }
102
102 public void RegionLoaded(Scene scene) 103 public void RegionLoaded(Scene scene)
103 { 104 {
104 m_dialogModule = scene.RequestModuleInterface<IDialogModule>(); 105 m_dialogModule = scene.RequestModuleInterface<IDialogModule>();
105 } 106 }
106 107
107 private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition, Scene scene) 108 private bool CanRezObject(int objectCount, UUID ownerID, Vector3 objectPosition)
108 { 109 {
109 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 110
111 ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
110 112
111 string response = DoCommonChecks(objectCount, ownerID, lo, scene); 113 string response = DoCommonChecks(objectCount, ownerID, lo);
112 114
113 if (response != null) 115 if (response != null)
114 { 116 {
@@ -119,78 +121,99 @@ namespace OpenSim.Region.OptionalModules
119 } 121 }
120 122
121 //OnDuplicateObject 123 //OnDuplicateObject
122 private bool CanDuplicateObject(int objectCount, UUID objectID, UUID ownerID, Scene scene, Vector3 objectPosition) 124 private bool CanDuplicateObject(SceneObjectGroup sog, ScenePresence sp)
123 { 125 {
124 ILandObject lo = scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y); 126 Vector3 objectPosition = sog.AbsolutePosition;
127 ILandObject lo = m_scene.LandChannel.GetLandObject(objectPosition.X, objectPosition.Y);
125 128
126 string response = DoCommonChecks(objectCount, ownerID, lo, scene); 129 string response = DoCommonChecks(sog.PrimCount, sp.UUID, lo);
127 130
128 if (response != null) 131 if (response != null)
129 { 132 {
130 m_dialogModule.SendAlertToUser(ownerID, response); 133 m_dialogModule.SendAlertToUser(sp.UUID, response);
131 return false; 134 return false;
132 } 135 }
133 return true; 136 return true;
134 } 137 }
135 138
136 private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) 139 private bool CanObjectEnter(SceneObjectGroup sog, bool enteringRegion, Vector3 newPoint)
137 { 140 {
138 SceneObjectPart obj = scene.GetSceneObjectPart(objectID); 141 float newX = newPoint.X;
139 Vector3 oldPoint = obj.GroupPosition; 142 float newY = newPoint.Y;
140 int objectCount = obj.ParentGroup.PrimCount; 143 if (newX < -1.0f || newX > (m_scene.RegionInfo.RegionSizeX + 1.0f) ||
141 ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y); 144 newY < -1.0f || newY > (m_scene.RegionInfo.RegionSizeY + 1.0f) )
142 ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y);
143
144 // newParcel will be null only if it outside of our current region. If this is the case, then the
145 // receiving permissions will perform the check.
146 if (newParcel == null)
147 return true; 145 return true;
148 146
149 // The prim hasn't crossed a region boundary so we don't need to worry 147 if (sog == null)
150 // about prim counts here 148 return false;
151 if(oldParcel.Equals(newParcel)) 149
152 { 150 ILandObject newParcel = m_scene.LandChannel.GetLandObject(newX, newY);
151
152 if (newParcel == null)
153 return true; 153 return true;
154 }
155 154
156 // Prim counts are determined by the location of the root prim. if we're 155 if(!enteringRegion)
157 // moving a child prim, just let it pass
158 if(!obj.IsRoot)
159 { 156 {
160 return true; 157 Vector3 oldPoint = sog.AbsolutePosition;
158 ILandObject oldParcel = m_scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
159 if(oldParcel != null && oldParcel.Equals(newParcel))
160 return true;
161 } 161 }
162 162
163 int objectCount = sog.PrimCount;
164
163 // TODO: Add Special Case here for temporary prims 165 // TODO: Add Special Case here for temporary prims
164 166
165 string response = DoCommonChecks(objectCount, obj.OwnerID, newParcel, scene); 167 string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel);
166 168
167 if (response != null) 169 if (response != null)
168 { 170 {
169 m_dialogModule.SendAlertToUser(obj.OwnerID, response); 171 if(m_dialogModule != null)
172 m_dialogModule.SendAlertToUser(sog.OwnerID, response);
170 return false; 173 return false;
171 } 174 }
172 return true; 175 return true;
173 } 176 }
174 177
175 private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo, Scene scene) 178 private bool CanObjectEnterWithScripts(SceneObjectGroup sog, ILandObject newParcel)
179 {
180 if (sog == null)
181 return false;
182
183 if (newParcel == null)
184 return true;
185
186 int objectCount = sog.PrimCount;
187
188 // TODO: Add Special Case here for temporary prims
189
190 string response = DoCommonChecks(objectCount, sog.OwnerID, newParcel);
191
192 if (response != null)
193 return false;
194
195 return true;
196 }
197
198 private string DoCommonChecks(int objectCount, UUID ownerID, ILandObject lo)
176 { 199 {
177 string response = null; 200 string response = null;
178 201
179 int simulatorCapacity = lo.GetSimulatorMaxPrimCount(); 202 int OwnedParcelsCapacity = lo.GetSimulatorMaxPrimCount();
180 if ((objectCount + lo.PrimCounts.Total) > simulatorCapacity) 203 if ((objectCount + lo.PrimCounts.Total) > OwnedParcelsCapacity)
181 { 204 {
182 response = "Unable to rez object because the parcel is too full"; 205 response = "Unable to rez object because the parcel is full";
183 } 206 }
184 else 207 else
185 { 208 {
186 int maxPrimsPerUser = scene.RegionInfo.MaxPrimsPerUser; 209 int maxPrimsPerUser = m_scene.RegionInfo.MaxPrimsPerUser;
187 if (maxPrimsPerUser >= 0) 210 if (maxPrimsPerUser >= 0)
188 { 211 {
189 // per-user prim limit is set 212 // per-user prim limit is set
190 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned) 213 if (ownerID != lo.LandData.OwnerID || lo.LandData.IsGroupOwned)
191 { 214 {
192 // caller is not the sole Parcel owner 215 // caller is not the sole Parcel owner
193 EstateSettings estateSettings = scene.RegionInfo.EstateSettings; 216 EstateSettings estateSettings = m_scene.RegionInfo.EstateSettings;
194 if (ownerID != estateSettings.EstateOwner) 217 if (ownerID != estateSettings.EstateOwner)
195 { 218 {
196 // caller is NOT the Estate owner 219 // caller is NOT the Estate owner
diff --git a/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs b/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs
index dc6ca6f..cbfd2d2 100644
--- a/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs
+++ b/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs
@@ -3,7 +3,7 @@ using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices; 3using System.Runtime.InteropServices;
4using Mono.Addins; 4using Mono.Addins;
5 5
6// General Information about an assembly is controlled through the following 6// General Information about an assembly is controlled through the following
7// set of attributes. Change these attribute values to modify the information 7// set of attributes. Change these attribute values to modify the information
8// associated with an assembly. 8// associated with an assembly.
9[assembly: AssemblyTitle("OpenSim.Region.OptionalModules")] 9[assembly: AssemblyTitle("OpenSim.Region.OptionalModules")]
@@ -15,8 +15,8 @@ using Mono.Addins;
15[assembly: AssemblyTrademark("")] 15[assembly: AssemblyTrademark("")]
16[assembly: AssemblyCulture("")] 16[assembly: AssemblyCulture("")]
17 17
18// Setting ComVisible to false makes the types in this assembly not visible 18// Setting ComVisible to false makes the types in this assembly not visible
19// to COM components. If you need to access a type in this assembly from 19// to COM components. If you need to access a type in this assembly from
20// COM, set the ComVisible attribute to true on that type. 20// COM, set the ComVisible attribute to true on that type.
21[assembly: ComVisible(false)] 21[assembly: ComVisible(false)]
22 22
@@ -26,11 +26,11 @@ using Mono.Addins;
26// Version information for an assembly consists of the following four values: 26// Version information for an assembly consists of the following four values:
27// 27//
28// Major Version 28// Major Version
29// Minor Version 29// Minor Version
30// Build Number 30// Build Number
31// Revision 31// Revision
32// 32//
33[assembly: AssemblyVersion("0.8.3.*")] 33[assembly: AssemblyVersion(OpenSim.VersionInfo.AssemblyVersionNumber)]
34 34
35 35
36[assembly: Addin("OpenSim.Region.OptionalModules", OpenSim.VersionInfo.VersionNumber)] 36[assembly: Addin("OpenSim.Region.OptionalModules", OpenSim.VersionInfo.VersionNumber)]
diff --git a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerClientEventForwarder.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerClientEventForwarder.cs
deleted file mode 100644
index 721d396..0000000
--- a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerClientEventForwarder.cs
+++ /dev/null
@@ -1,94 +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 OpenMetaverse;
31using OpenSim.Region.Framework.Scenes;
32
33namespace OpenSim.Region.RegionCombinerModule
34{
35public class RegionCombinerClientEventForwarder
36 {
37 private Scene m_rootScene;
38 private Dictionary<UUID, Scene> m_virtScene = new Dictionary<UUID, Scene>();
39 private Dictionary<UUID,RegionCombinerIndividualEventForwarder> m_forwarders = new Dictionary<UUID,
40 RegionCombinerIndividualEventForwarder>();
41
42 public RegionCombinerClientEventForwarder(RegionConnections rootScene)
43 {
44 m_rootScene = rootScene.RegionScene;
45 }
46
47 public void AddSceneToEventForwarding(Scene virtualScene)
48 {
49 lock (m_virtScene)
50 {
51 if (m_virtScene.ContainsKey(virtualScene.RegionInfo.originRegionID))
52 {
53 m_virtScene[virtualScene.RegionInfo.originRegionID] = virtualScene;
54 }
55 else
56 {
57 m_virtScene.Add(virtualScene.RegionInfo.originRegionID, virtualScene);
58 }
59 }
60
61 lock (m_forwarders)
62 {
63 // TODO: Fix this to unregister if this happens
64 if (m_forwarders.ContainsKey(virtualScene.RegionInfo.originRegionID))
65 m_forwarders.Remove(virtualScene.RegionInfo.originRegionID);
66
67 RegionCombinerIndividualEventForwarder forwarder =
68 new RegionCombinerIndividualEventForwarder(m_rootScene, virtualScene);
69 m_forwarders.Add(virtualScene.RegionInfo.originRegionID, forwarder);
70
71 virtualScene.EventManager.OnNewClient += forwarder.ClientConnect;
72 virtualScene.EventManager.OnClientClosed += forwarder.ClientClosed;
73 }
74 }
75
76 public void RemoveSceneFromEventForwarding (Scene virtualScene)
77 {
78 lock (m_forwarders)
79 {
80 RegionCombinerIndividualEventForwarder forwarder = m_forwarders[virtualScene.RegionInfo.originRegionID];
81 virtualScene.EventManager.OnNewClient -= forwarder.ClientConnect;
82 virtualScene.EventManager.OnClientClosed -= forwarder.ClientClosed;
83 m_forwarders.Remove(virtualScene.RegionInfo.originRegionID);
84 }
85 lock (m_virtScene)
86 {
87 if (m_virtScene.ContainsKey(virtualScene.RegionInfo.originRegionID))
88 {
89 m_virtScene.Remove(virtualScene.RegionInfo.originRegionID);
90 }
91 }
92 }
93 }
94} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs
deleted file mode 100644
index 83732e2..0000000
--- a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerIndividualEventForwarder.cs
+++ /dev/null
@@ -1,139 +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 OpenMetaverse;
30using OpenSim.Framework;
31using OpenSim.Region.CoreModules.Avatar.Attachments;
32using OpenSim.Region.CoreModules.Avatar.Gods;
33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes;
35
36namespace OpenSim.Region.RegionCombinerModule
37{
38 public class RegionCombinerIndividualEventForwarder
39 {
40 private Scene m_rootScene;
41 private Scene m_virtScene;
42
43 public RegionCombinerIndividualEventForwarder(Scene rootScene, Scene virtScene)
44 {
45 m_rootScene = rootScene;
46 m_virtScene = virtScene;
47 }
48
49 public void ClientConnect(IClientAPI client)
50 {
51 m_virtScene.UnSubscribeToClientPrimEvents(client);
52 m_virtScene.UnSubscribeToClientPrimRezEvents(client);
53 m_virtScene.UnSubscribeToClientInventoryEvents(client);
54 if(m_virtScene.AttachmentsModule != null)
55 ((AttachmentsModule)m_virtScene.AttachmentsModule).UnsubscribeFromClientEvents(client);
56 //m_virtScene.UnSubscribeToClientTeleportEvents(client);
57 m_virtScene.UnSubscribeToClientScriptEvents(client);
58
59 IGodsModule virtGodsModule = m_virtScene.RequestModuleInterface<IGodsModule>();
60 if (virtGodsModule != null)
61 ((GodsModule)virtGodsModule).UnsubscribeFromClientEvents(client);
62
63 m_virtScene.UnSubscribeToClientNetworkEvents(client);
64
65 m_rootScene.SubscribeToClientPrimEvents(client);
66 client.OnAddPrim += LocalAddNewPrim;
67 client.OnRezObject += LocalRezObject;
68
69 m_rootScene.SubscribeToClientInventoryEvents(client);
70 if (m_rootScene.AttachmentsModule != null)
71 ((AttachmentsModule)m_rootScene.AttachmentsModule).SubscribeToClientEvents(client);
72 //m_rootScene.SubscribeToClientTeleportEvents(client);
73 m_rootScene.SubscribeToClientScriptEvents(client);
74
75 IGodsModule rootGodsModule = m_virtScene.RequestModuleInterface<IGodsModule>();
76 if (rootGodsModule != null)
77 ((GodsModule)rootGodsModule).UnsubscribeFromClientEvents(client);
78
79 m_rootScene.SubscribeToClientNetworkEvents(client);
80 }
81
82 public void ClientClosed(UUID clientid, Scene scene)
83 {
84 }
85
86 /// <summary>
87 /// Fixes position based on the region the Rez event came in on
88 /// </summary>
89 /// <param name="remoteclient"></param>
90 /// <param name="itemid"></param>
91 /// <param name="rayend"></param>
92 /// <param name="raystart"></param>
93 /// <param name="raytargetid"></param>
94 /// <param name="bypassraycast"></param>
95 /// <param name="rayendisintersection"></param>
96 /// <param name="rezselected"></param>
97 /// <param name="removeitem"></param>
98 /// <param name="fromtaskid"></param>
99 private void LocalRezObject(IClientAPI remoteclient, UUID itemid, Vector3 rayend, Vector3 raystart,
100 UUID raytargetid, byte bypassraycast, bool rayendisintersection, bool rezselected, bool removeitem,
101 UUID fromtaskid)
102 {
103 int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX;
104 int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY;
105 rayend.X += differenceX * (int)Constants.RegionSize;
106 rayend.Y += differenceY * (int)Constants.RegionSize;
107 raystart.X += differenceX * (int)Constants.RegionSize;
108 raystart.Y += differenceY * (int)Constants.RegionSize;
109
110 m_rootScene.RezObject(remoteclient, itemid, rayend, raystart, raytargetid, bypassraycast,
111 rayendisintersection, rezselected, removeitem, fromtaskid);
112 }
113 /// <summary>
114 /// Fixes position based on the region the AddPrimShape event came in on
115 /// </summary>
116 /// <param name="ownerid"></param>
117 /// <param name="groupid"></param>
118 /// <param name="rayend"></param>
119 /// <param name="rot"></param>
120 /// <param name="shape"></param>
121 /// <param name="bypassraycast"></param>
122 /// <param name="raystart"></param>
123 /// <param name="raytargetid"></param>
124 /// <param name="rayendisintersection"></param>
125 private void LocalAddNewPrim(UUID ownerid, UUID groupid, Vector3 rayend, Quaternion rot,
126 PrimitiveBaseShape shape, byte bypassraycast, Vector3 raystart, UUID raytargetid,
127 byte rayendisintersection)
128 {
129 int differenceX = (int)m_virtScene.RegionInfo.RegionLocX - (int)m_rootScene.RegionInfo.RegionLocX;
130 int differenceY = (int)m_virtScene.RegionInfo.RegionLocY - (int)m_rootScene.RegionInfo.RegionLocY;
131 rayend.X += differenceX * (int)Constants.RegionSize;
132 rayend.Y += differenceY * (int)Constants.RegionSize;
133 raystart.X += differenceX * (int)Constants.RegionSize;
134 raystart.Y += differenceY * (int)Constants.RegionSize;
135 m_rootScene.AddNewPrim(ownerid, groupid, rayend, rot, shape, bypassraycast, raystart, raytargetid,
136 rayendisintersection);
137 }
138 }
139} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerLargeLandChannel.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerLargeLandChannel.cs
deleted file mode 100644
index 4bf2a82..0000000
--- a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerLargeLandChannel.cs
+++ /dev/null
@@ -1,201 +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 log4net;
32using OpenMetaverse;
33using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.CoreModules.World.Land;
36
37namespace OpenSim.Region.RegionCombinerModule
38{
39 public class RegionCombinerLargeLandChannel : ILandChannel
40 {
41// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
42
43 private RegionData RegData;
44 private ILandChannel RootRegionLandChannel;
45 private readonly List<RegionData> RegionConnections;
46
47 #region ILandChannel Members
48
49 public RegionCombinerLargeLandChannel(RegionData regData, ILandChannel rootRegionLandChannel,
50 List<RegionData> regionConnections)
51 {
52 RegData = regData;
53 RootRegionLandChannel = rootRegionLandChannel;
54 RegionConnections = regionConnections;
55 }
56
57 public List<ILandObject> ParcelsNearPoint(Vector3 position)
58 {
59 //m_log.DebugFormat("[LANDPARCELNEARPOINT]: {0}>", position);
60 return RootRegionLandChannel.ParcelsNearPoint(position - RegData.Offset);
61 }
62
63 public List<ILandObject> AllParcels()
64 {
65 return RootRegionLandChannel.AllParcels();
66 }
67
68 public void Clear(bool setupDefaultParcel)
69 {
70 RootRegionLandChannel.Clear(setupDefaultParcel);
71 }
72
73 public ILandObject GetLandObject(Vector3 position)
74 {
75 return GetLandObject(position.X, position.Y);
76 }
77
78 public ILandObject GetLandObject(int x, int y)
79 {
80 return GetLandObject((float)x, (float)y);
81
82// m_log.DebugFormat("[BIGLANDTESTINT]: <{0},{1}>", x, y);
83//
84// if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize)
85// {
86// return RootRegionLandChannel.GetLandObject(x, y);
87// }
88// else
89// {
90// int offsetX = (x / (int)Constants.RegionSize);
91// int offsetY = (y / (int)Constants.RegionSize);
92// offsetX *= (int)Constants.RegionSize;
93// offsetY *= (int)Constants.RegionSize;
94//
95// foreach (RegionData regionData in RegionConnections)
96// {
97// if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY)
98// {
99// m_log.DebugFormat(
100// "[REGION COMBINER LARGE LAND CHANNEL]: Found region {0} at offset {1},{2}",
101// regionData.RegionScene.Name, offsetX, offsetY);
102//
103// return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY);
104// }
105// }
106// //ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene);
107// //obj.LandData.Name = "NO LAND";
108// //return obj;
109// }
110//
111// m_log.DebugFormat("[REGION COMBINER LARGE LAND CHANNEL]: No region found at {0},{1}, returning null", x, y);
112//
113// return null;
114 }
115
116 public ILandObject GetLandObject(int localID)
117 {
118 // XXX: Possibly should be looking in every land channel, not just the root.
119 return RootRegionLandChannel.GetLandObject(localID);
120 }
121
122 public ILandObject GetLandObject(float x, float y)
123 {
124// m_log.DebugFormat("[BIGLANDTESTFLOAT]: <{0},{1}>", x, y);
125
126 if (x > 0 && x <= (int)Constants.RegionSize && y > 0 && y <= (int)Constants.RegionSize)
127 {
128 return RootRegionLandChannel.GetLandObject(x, y);
129 }
130 else
131 {
132 int offsetX = (int)(x/(int) Constants.RegionSize);
133 int offsetY = (int)(y/(int) Constants.RegionSize);
134 offsetX *= (int) Constants.RegionSize;
135 offsetY *= (int) Constants.RegionSize;
136
137 foreach (RegionData regionData in RegionConnections)
138 {
139 if (regionData.Offset.X == offsetX && regionData.Offset.Y == offsetY)
140 {
141// m_log.DebugFormat(
142// "[REGION COMBINER LARGE LAND CHANNEL]: Found region {0} at offset {1},{2}",
143// regionData.RegionScene.Name, offsetX, offsetY);
144
145 return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY);
146 }
147 }
148
149// ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene);
150// obj.LandData.Name = "NO LAND";
151// return obj;
152 }
153
154// m_log.DebugFormat("[REGION COMBINER LARGE LAND CHANNEL]: No region found at {0},{1}, returning null", x, y);
155
156 return null;
157 }
158
159 public bool IsForcefulBansAllowed()
160 {
161 return RootRegionLandChannel.IsForcefulBansAllowed();
162 }
163
164 public void UpdateLandObject(int localID, LandData data)
165 {
166 RootRegionLandChannel.UpdateLandObject(localID, data);
167 }
168
169 public void Join(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
170 {
171 RootRegionLandChannel.Join(start_x, start_y, end_x, end_y, attempting_user_id);
172 }
173
174 public void Subdivide(int start_x, int start_y, int end_x, int end_y, UUID attempting_user_id)
175 {
176 RootRegionLandChannel.Subdivide(start_x, start_y, end_x, end_y, attempting_user_id);
177 }
178
179 public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
180 {
181 RootRegionLandChannel.ReturnObjectsInParcel(localID, returnType, agentIDs, taskIDs, remoteClient);
182 }
183
184 public void setParcelObjectMaxOverride(overrideParcelMaxPrimCountDelegate overrideDel)
185 {
186 RootRegionLandChannel.setParcelObjectMaxOverride(overrideDel);
187 }
188
189 public void setSimulatorObjectMaxOverride(overrideSimulatorMaxPrimCountDelegate overrideDel)
190 {
191 RootRegionLandChannel.setSimulatorObjectMaxOverride(overrideDel);
192 }
193
194 public void SetParcelOtherCleanTime(IClientAPI remoteClient, int localID, int otherCleanTime)
195 {
196 RootRegionLandChannel.SetParcelOtherCleanTime(remoteClient, localID, otherCleanTime);
197 }
198
199 #endregion
200 }
201} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerModule.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerModule.cs
deleted file mode 100644
index 32eead0..0000000
--- a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerModule.cs
+++ /dev/null
@@ -1,880 +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 log4net;
32using Nini.Config;
33using OpenMetaverse;
34using OpenSim.Framework;
35using OpenSim.Framework.Client;
36using OpenSim.Region.Framework.Interfaces;
37using OpenSim.Region.Framework.Scenes;
38using OpenSim.Framework.Console;
39using OpenSim.Region.PhysicsModules.SharedBase;
40using Mono.Addins;
41
42namespace OpenSim.Region.RegionCombinerModule
43{
44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionCombinerModule")]
45 public class RegionCombinerModule : ISharedRegionModule, IRegionCombinerModule
46 {
47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48// private static string LogHeader = "[REGION COMBINER MODULE]";
49
50 public string Name
51 {
52 get { return "RegionCombinerModule"; }
53 }
54
55 public Type ReplaceableInterface
56 {
57 get { return null; }
58 }
59
60 /// <summary>
61 /// Is this module enabled?
62 /// </summary>
63 private bool m_combineContiguousRegions = false;
64
65 /// <summary>
66 /// This holds the root regions for the megaregions.
67 /// </summary>
68 /// <remarks>
69 /// Usually there is only ever one megaregion (and hence only one entry here).
70 /// </remarks>
71 private Dictionary<UUID, RegionConnections> m_regions = new Dictionary<UUID, RegionConnections>();
72
73 /// <summary>
74 /// The scenes that comprise the megaregion.
75 /// </summary>
76 private Dictionary<UUID, Scene> m_startingScenes = new Dictionary<UUID, Scene>();
77
78 public void Initialise(IConfigSource source)
79 {
80 IConfig myConfig = source.Configs["Startup"];
81 m_combineContiguousRegions = myConfig.GetBoolean("CombineContiguousRegions", false);
82 if (m_combineContiguousRegions)
83 m_log.ErrorFormat("[REGION COMBINER MODULE]: THIS MODULE IS BEING MARKED OBSOLETE AND MAY SOON BE REMOVED. PLEASE USE VARREGIONS INSTEAD.");
84
85 MainConsole.Instance.Commands.AddCommand(
86 "RegionCombinerModule", false, "fix-phantoms", "fix-phantoms",
87 "Fixes phantom objects after an import to a megaregion or a change from a megaregion back to normal regions",
88 FixPhantoms);
89 }
90
91 public void Close()
92 {
93 }
94
95 public void AddRegion(Scene scene)
96 {
97 if (m_combineContiguousRegions)
98 scene.RegisterModuleInterface<IRegionCombinerModule>(this);
99 }
100
101 public void RemoveRegion(Scene scene)
102 {
103 lock (m_startingScenes)
104 m_startingScenes.Remove(scene.RegionInfo.originRegionID);
105 }
106
107 public void RegionLoaded(Scene scene)
108 {
109 lock (m_startingScenes)
110 m_startingScenes.Add(scene.RegionInfo.originRegionID, scene);
111
112 if (m_combineContiguousRegions)
113 {
114 RegionLoadedDoWork(scene);
115
116 scene.EventManager.OnNewPresence += NewPresence;
117 }
118 }
119
120 public bool IsRootForMegaregion(UUID regionId)
121 {
122 lock (m_regions)
123 return m_regions.ContainsKey(regionId);
124 }
125
126 public Vector2 GetSizeOfMegaregion(UUID regionId)
127 {
128 lock (m_regions)
129 {
130 if (m_regions.ContainsKey(regionId))
131 {
132 RegionConnections rootConn = m_regions[regionId];
133
134 return new Vector2((float)rootConn.XEnd, (float)rootConn.YEnd);
135 }
136 }
137
138 throw new Exception(string.Format("Region with id {0} not found", regionId));
139 }
140
141 // Test to see if this postiion (relative to the region) is within the area covered
142 // by this megaregion.
143 public bool PositionIsInMegaregion(UUID currentRegion, int xx, int yy)
144 {
145 bool ret = false;
146 if (xx < 0 || yy < 0)
147 return ret;
148
149 foreach (RegionConnections rootRegion in m_regions.Values)
150 {
151 if (currentRegion == rootRegion.RegionId)
152 {
153 // The caller is in the root region so this is an easy test
154 if (xx < rootRegion.XEnd && yy < rootRegion.YEnd)
155 {
156 ret = true;
157 }
158 break;
159 }
160 else
161 {
162 // Maybe the caller is in one of the sub-regions
163 foreach (RegionData childRegion in rootRegion.ConnectedRegions)
164 {
165 if (currentRegion == childRegion.RegionId)
166 {
167 // This is a child. Diddle the offsets and check if in
168 Vector3 positionInMegaregion = childRegion.Offset;
169 positionInMegaregion.X += xx;
170 positionInMegaregion.Y += yy;
171 if (positionInMegaregion.X < rootRegion.XEnd && positionInMegaregion.Y < rootRegion.YEnd)
172 {
173 ret = true;
174 }
175 break;
176 }
177 }
178 }
179 }
180
181 return ret;
182 }
183
184 private void NewPresence(ScenePresence presence)
185 {
186 if (presence.IsChildAgent)
187 {
188 byte[] throttleData;
189
190 try
191 {
192 throttleData = presence.ControllingClient.GetThrottlesPacked(1);
193 }
194 catch (NotImplementedException)
195 {
196 return;
197 }
198
199 if (throttleData == null)
200 return;
201
202 if (throttleData.Length == 0)
203 return;
204
205 if (throttleData.Length != 28)
206 return;
207
208 byte[] adjData;
209 int pos = 0;
210
211 if (!BitConverter.IsLittleEndian)
212 {
213 byte[] newData = new byte[7 * 4];
214 Buffer.BlockCopy(throttleData, 0, newData, 0, 7 * 4);
215
216 for (int i = 0; i < 7; i++)
217 Array.Reverse(newData, i * 4, 4);
218
219 adjData = newData;
220 }
221 else
222 {
223 adjData = throttleData;
224 }
225
226 // 0.125f converts from bits to bytes
227 int resend = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
228 int land = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
229 int wind = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
230 int cloud = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
231 int task = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
232 int texture = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f); pos += 4;
233 int asset = (int)(BitConverter.ToSingle(adjData, pos) * 0.125f);
234 // State is a subcategory of task that we allocate a percentage to
235
236
237 //int total = resend + land + wind + cloud + task + texture + asset;
238
239 byte[] data = new byte[7 * 4];
240 int ii = 0;
241
242 Buffer.BlockCopy(Utils.FloatToBytes(resend), 0, data, ii, 4); ii += 4;
243 Buffer.BlockCopy(Utils.FloatToBytes(land * 50), 0, data, ii, 4); ii += 4;
244 Buffer.BlockCopy(Utils.FloatToBytes(wind), 0, data, ii, 4); ii += 4;
245 Buffer.BlockCopy(Utils.FloatToBytes(cloud), 0, data, ii, 4); ii += 4;
246 Buffer.BlockCopy(Utils.FloatToBytes(task), 0, data, ii, 4); ii += 4;
247 Buffer.BlockCopy(Utils.FloatToBytes(texture), 0, data, ii, 4); ii += 4;
248 Buffer.BlockCopy(Utils.FloatToBytes(asset), 0, data, ii, 4);
249
250 try
251 {
252 presence.ControllingClient.SetChildAgentThrottle(data);
253 }
254 catch (NotImplementedException)
255 {
256 return;
257 }
258 }
259 }
260
261 private void RegionLoadedDoWork(Scene scene)
262 {
263/*
264 // For testing on a single instance
265 if (scene.RegionInfo.RegionLocX == 1004 && scene.RegionInfo.RegionLocY == 1000)
266 return;
267 //
268*/
269
270 RegionConnections newConn = new RegionConnections();
271 newConn.ConnectedRegions = new List<RegionData>();
272 newConn.RegionScene = scene;
273 newConn.RegionLandChannel = scene.LandChannel;
274 newConn.RegionId = scene.RegionInfo.originRegionID;
275 newConn.X = scene.RegionInfo.RegionLocX;
276 newConn.Y = scene.RegionInfo.RegionLocY;
277 newConn.XEnd = scene.RegionInfo.RegionSizeX;
278 newConn.YEnd = scene.RegionInfo.RegionSizeX;
279
280 lock (m_regions)
281 {
282 bool connectedYN = false;
283
284 foreach (RegionConnections rootConn in m_regions.Values)
285 {
286 #region commented
287 /*
288 // If we're one region over +x +y
289 //xxy
290 //xxx
291 //xxx
292 if ((((int)conn.X * (int)Constants.RegionSize) + conn.XEnd
293 == (regionConnections.X * (int)Constants.RegionSize))
294 && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd
295 == (regionConnections.Y * (int)Constants.RegionSize)))
296 {
297 Vector3 offset = Vector3.Zero;
298 offset.X = (((regionConnections.X * (int) Constants.RegionSize)) -
299 ((conn.X * (int) Constants.RegionSize)));
300 offset.Y = (((regionConnections.Y * (int) Constants.RegionSize)) -
301 ((conn.Y * (int) Constants.RegionSize)));
302
303 Vector3 extents = Vector3.Zero;
304 extents.Y = regionConnections.YEnd + conn.YEnd;
305 extents.X = conn.XEnd + conn.XEnd;
306
307 m_log.DebugFormat("Scene: {0} to the northwest of Scene{1}. Offset: {2}. Extents:{3}",
308 conn.RegionScene.RegionInfo.RegionName,
309 regionConnections.RegionScene.RegionInfo.RegionName,
310 offset, extents);
311
312 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents);
313
314 connectedYN = true;
315 break;
316 }
317 */
318
319 /*
320 //If we're one region over x +y
321 //xxx
322 //xxx
323 //xyx
324 if ((((int)conn.X * (int)Constants.RegionSize)
325 == (regionConnections.X * (int)Constants.RegionSize))
326 && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd
327 == (regionConnections.Y * (int)Constants.RegionSize)))
328 {
329 Vector3 offset = Vector3.Zero;
330 offset.X = (((regionConnections.X * (int)Constants.RegionSize)) -
331 ((conn.X * (int)Constants.RegionSize)));
332 offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) -
333 ((conn.Y * (int)Constants.RegionSize)));
334
335 Vector3 extents = Vector3.Zero;
336 extents.Y = regionConnections.YEnd + conn.YEnd;
337 extents.X = conn.XEnd;
338
339 m_log.DebugFormat("Scene: {0} to the north of Scene{1}. Offset: {2}. Extents:{3}",
340 conn.RegionScene.RegionInfo.RegionName,
341 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
342
343 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents);
344 connectedYN = true;
345 break;
346 }
347 */
348
349 /*
350 // If we're one region over -x +y
351 //xxx
352 //xxx
353 //yxx
354 if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd
355 == (regionConnections.X * (int)Constants.RegionSize))
356 && (((int)conn.Y * (int)Constants.RegionSize) - conn.YEnd
357 == (regionConnections.Y * (int)Constants.RegionSize)))
358 {
359 Vector3 offset = Vector3.Zero;
360 offset.X = (((regionConnections.X * (int)Constants.RegionSize)) -
361 ((conn.X * (int)Constants.RegionSize)));
362 offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) -
363 ((conn.Y * (int)Constants.RegionSize)));
364
365 Vector3 extents = Vector3.Zero;
366 extents.Y = regionConnections.YEnd + conn.YEnd;
367 extents.X = conn.XEnd + conn.XEnd;
368
369 m_log.DebugFormat("Scene: {0} to the northeast of Scene. Offset: {2}. Extents:{3}",
370 conn.RegionScene.RegionInfo.RegionName,
371 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
372
373 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents);
374
375
376 connectedYN = true;
377 break;
378 }
379 */
380
381 /*
382 // If we're one region over -x y
383 //xxx
384 //yxx
385 //xxx
386 if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd
387 == (regionConnections.X * (int)Constants.RegionSize))
388 && (((int)conn.Y * (int)Constants.RegionSize)
389 == (regionConnections.Y * (int)Constants.RegionSize)))
390 {
391 Vector3 offset = Vector3.Zero;
392 offset.X = (((regionConnections.X * (int)Constants.RegionSize)) -
393 ((conn.X * (int)Constants.RegionSize)));
394 offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) -
395 ((conn.Y * (int)Constants.RegionSize)));
396
397 Vector3 extents = Vector3.Zero;
398 extents.Y = regionConnections.YEnd;
399 extents.X = conn.XEnd + conn.XEnd;
400
401 m_log.DebugFormat("Scene: {0} to the east of Scene{1} Offset: {2}. Extents:{3}",
402 conn.RegionScene.RegionInfo.RegionName,
403 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
404
405 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents);
406
407 connectedYN = true;
408 break;
409 }
410 */
411
412 /*
413 // If we're one region over -x -y
414 //yxx
415 //xxx
416 //xxx
417 if ((((int)conn.X * (int)Constants.RegionSize) - conn.XEnd
418 == (regionConnections.X * (int)Constants.RegionSize))
419 && (((int)conn.Y * (int)Constants.RegionSize) + conn.YEnd
420 == (regionConnections.Y * (int)Constants.RegionSize)))
421 {
422 Vector3 offset = Vector3.Zero;
423 offset.X = (((regionConnections.X * (int)Constants.RegionSize)) -
424 ((conn.X * (int)Constants.RegionSize)));
425 offset.Y = (((regionConnections.Y * (int)Constants.RegionSize)) -
426 ((conn.Y * (int)Constants.RegionSize)));
427
428 Vector3 extents = Vector3.Zero;
429 extents.Y = regionConnections.YEnd + conn.YEnd;
430 extents.X = conn.XEnd + conn.XEnd;
431
432 m_log.DebugFormat("Scene: {0} to the northeast of Scene{1} Offset: {2}. Extents:{3}",
433 conn.RegionScene.RegionInfo.RegionName,
434 regionConnections.RegionScene.RegionInfo.RegionName, offset, extents);
435
436 scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset, extents);
437
438 connectedYN = true;
439 break;
440 }
441 */
442 #endregion
443
444
445 // Check to see if this new region is adjacent to the root region.
446 // Note that we expect the regions to be combined from the root region outward
447 // thus the requirement for the ordering in the configuration files.
448
449 // If we're one region over +x y (i.e. root region is to the west)
450 //xxx
451 //xxy
452 //xxx
453 if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY >= newConn.PosY)
454 {
455 connectedYN = DoWorkForOneRegionOverPlusXY(rootConn, newConn, scene);
456 break;
457 }
458
459 // If we're one region over x +y (i.e. root region is to the south)
460 //xyx
461 //xxx
462 //xxx
463 if (rootConn.PosX >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY)
464 {
465 connectedYN = DoWorkForOneRegionOverPlusXY(rootConn, newConn, scene);
466 break;
467 }
468
469 // If we're one region over +x +y (i.e. root region is to the south-west)
470 //xxy
471 //xxx
472 //xxx
473 if (rootConn.PosX + rootConn.XEnd >= newConn.PosX && rootConn.PosY + rootConn.YEnd >= newConn.PosY)
474 {
475 connectedYN = DoWorkForOneRegionOverPlusXY(rootConn, newConn, scene);
476 break;
477 }
478 }
479
480 // If !connectYN means that this region is a root region
481 if (!connectedYN)
482 {
483 DoWorkForRootRegion(newConn, scene);
484 }
485 }
486 }
487
488 private bool DoWorkForOneRegionOverPlusXY(RegionConnections rootConn, RegionConnections newConn, Scene scene)
489 {
490 // Offset (in meters) from the base of this region to the base of the root region.
491 Vector3 offset = Vector3.Zero;
492 offset.X = newConn.PosX - rootConn.PosX;
493 offset.Y = newConn.PosY - rootConn.PosY;
494
495 // The new total size of the region (in meters)
496 // We just extend the X and Y dimensions so the extent might temporarily include areas without regions.
497 Vector3 extents = Vector3.Zero;
498 extents.X = Math.Max(rootConn.XEnd, offset.X + newConn.RegionScene.RegionInfo.RegionSizeX);
499 extents.Y = Math.Max(rootConn.YEnd, offset.Y + newConn.RegionScene.RegionInfo.RegionSizeY);
500
501 rootConn.UpdateExtents(extents);
502
503 m_log.DebugFormat(
504 "[REGION COMBINER MODULE]: Root region {0} is to the west of region {1}, Offset: {2}, Extents: {3}",
505 rootConn.RegionScene.RegionInfo.RegionName,
506 newConn.RegionScene.RegionInfo.RegionName, offset, extents);
507
508 RegionData ConnectedRegion = new RegionData();
509 ConnectedRegion.Offset = offset;
510 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID;
511 ConnectedRegion.RegionScene = scene;
512 rootConn.ConnectedRegions.Add(ConnectedRegion);
513
514 // Inform root region Physics about the extents of this region
515 rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents);
516
517 // Inform Child region that it needs to forward it's terrain to the root region
518 scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero);
519
520 // Reset Terrain.. since terrain loads before we get here, we need to load
521 // it again so it loads in the root region
522 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
523
524 // Create a client event forwarder and add this region's events to the root region.
525 if (rootConn.ClientEventForwarder != null)
526 rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene);
527
528 return true;
529 }
530
531 /*
532 * 20140215 radams1: The border stuff was removed and the addition of regions to the mega-regions
533 * was generalized. These functions are not needed for the generalized solution but left for reference.
534 private bool DoWorkForOneRegionOverXPlusY(RegionConnections rootConn, RegionConnections newConn, Scene scene)
535 {
536 Vector3 offset = Vector3.Zero;
537 offset.X = newConn.PosX - rootConn.PosX;
538 offset.Y = newConn.PosY - rootConn.PosY;
539
540 Vector3 extents = Vector3.Zero;
541 extents.Y = newConn.YEnd + rootConn.YEnd;
542 extents.X = rootConn.XEnd;
543 rootConn.UpdateExtents(extents);
544
545 RegionData ConnectedRegion = new RegionData();
546 ConnectedRegion.Offset = offset;
547 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID;
548 ConnectedRegion.RegionScene = scene;
549 rootConn.ConnectedRegions.Add(ConnectedRegion);
550
551 m_log.DebugFormat(
552 "[REGION COMBINER MODULE]: Root region {0} is to the south of region {1}, Offset: {2}, Extents: {3}",
553 rootConn.RegionScene.RegionInfo.RegionName,
554 newConn.RegionScene.RegionInfo.RegionName, offset, extents);
555
556 rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents);
557 scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero);
558
559 // Reset Terrain.. since terrain normally loads first.
560 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
561 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
562 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
563
564 if (rootConn.ClientEventForwarder != null)
565 rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene);
566
567 return true;
568 }
569
570 private bool DoWorkForOneRegionOverPlusXPlusY(RegionConnections rootConn, RegionConnections newConn, Scene scene)
571 {
572 Vector3 offset = Vector3.Zero;
573 offset.X = newConn.PosX - rootConn.PosX;
574 offset.Y = newConn.PosY - rootConn.PosY;
575
576 Vector3 extents = Vector3.Zero;
577
578 // We do not want to inflate the extents for regions strictly to the NE of the root region, since this
579 // would double count regions strictly to the north and east that have already been added.
580// extents.Y = regionConnections.YEnd + conn.YEnd;
581// extents.X = regionConnections.XEnd + conn.XEnd;
582// conn.UpdateExtents(extents);
583
584 extents.Y = rootConn.YEnd;
585 extents.X = rootConn.XEnd;
586
587 RegionData ConnectedRegion = new RegionData();
588 ConnectedRegion.Offset = offset;
589 ConnectedRegion.RegionId = scene.RegionInfo.originRegionID;
590 ConnectedRegion.RegionScene = scene;
591
592 rootConn.ConnectedRegions.Add(ConnectedRegion);
593
594 m_log.DebugFormat(
595 "[REGION COMBINER MODULE]: Region {0} is to the southwest of Scene {1}, Offset: {2}, Extents: {3}",
596 rootConn.RegionScene.RegionInfo.RegionName,
597 newConn.RegionScene.RegionInfo.RegionName, offset, extents);
598
599 rootConn.RegionScene.PhysicsScene.Combine(null, Vector3.Zero, extents);
600 scene.PhysicsScene.Combine(rootConn.RegionScene.PhysicsScene, offset, Vector3.Zero);
601
602 // Reset Terrain.. since terrain normally loads first.
603 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
604 scene.PhysicsScene.SetTerrain(scene.Heightmap.GetFloatsSerialised());
605 //conn.RegionScene.PhysicsScene.SetTerrain(conn.RegionScene.Heightmap.GetFloatsSerialised());
606
607 if (rootConn.ClientEventForwarder != null)
608 rootConn.ClientEventForwarder.AddSceneToEventForwarding(scene);
609
610 return true;
611
612 //scene.PhysicsScene.Combine(conn.RegionScene.PhysicsScene, offset,extents);
613 }
614 */
615
616 private void DoWorkForRootRegion(RegionConnections rootConn, Scene scene)
617 {
618 m_log.DebugFormat("[REGION COMBINER MODULE]: Adding root region {0}", scene.RegionInfo.RegionName);
619
620 RegionData rdata = new RegionData();
621 rdata.Offset = Vector3.Zero;
622 rdata.RegionId = scene.RegionInfo.originRegionID;
623 rdata.RegionScene = scene;
624 // save it's land channel
625 rootConn.RegionLandChannel = scene.LandChannel;
626
627 // Substitue our landchannel
628 RegionCombinerLargeLandChannel lnd = new RegionCombinerLargeLandChannel(rdata, scene.LandChannel,
629 rootConn.ConnectedRegions);
630
631 scene.LandChannel = lnd;
632
633 // Forward the permissions modules of each of the connected regions to the root region
634 lock (m_regions)
635 {
636 foreach (RegionData r in rootConn.ConnectedRegions)
637 {
638 ForwardPermissionRequests(rootConn, r.RegionScene);
639 }
640
641 // Create the root region's Client Event Forwarder
642 rootConn.ClientEventForwarder = new RegionCombinerClientEventForwarder(rootConn);
643
644 // Sets up the CoarseLocationUpdate forwarder for this root region
645 scene.EventManager.OnNewPresence += SetCoarseLocationDelegate;
646
647 // Adds this root region to a dictionary of regions that are connectable
648 m_regions.Add(scene.RegionInfo.originRegionID, rootConn);
649 }
650 }
651
652 private void SetCoarseLocationDelegate(ScenePresence presence)
653 {
654 presence.SetSendCoarseLocationMethod(SendCoarseLocationUpdates);
655 }
656
657 // This delegate was refactored for non-combined regions.
658 // This combined region version will not use the pre-compiled lists of locations and ids
659 private void SendCoarseLocationUpdates(UUID sceneId, ScenePresence presence, List<Vector3> coarseLocations, List<UUID> avatarUUIDs)
660 {
661 RegionConnections connectiondata = null;
662 lock (m_regions)
663 {
664 if (m_regions.ContainsKey(sceneId))
665 connectiondata = m_regions[sceneId];
666 else
667 return;
668 }
669
670 List<Vector3> CoarseLocations = new List<Vector3>();
671 List<UUID> AvatarUUIDs = new List<UUID>();
672
673 connectiondata.RegionScene.ForEachRootScenePresence(delegate(ScenePresence sp)
674 {
675 if (sp.UUID != presence.UUID)
676 {
677 CoarseLocations.Add(sp.AbsolutePosition);
678 AvatarUUIDs.Add(sp.UUID);
679 }
680 });
681
682 DistributeCoarseLocationUpdates(CoarseLocations, AvatarUUIDs, connectiondata, presence);
683 }
684
685 private void DistributeCoarseLocationUpdates(List<Vector3> locations, List<UUID> uuids,
686 RegionConnections connectiondata, ScenePresence rootPresence)
687 {
688 RegionData[] rdata = connectiondata.ConnectedRegions.ToArray();
689 //List<IClientAPI> clients = new List<IClientAPI>();
690 Dictionary<Vector2, RegionCoarseLocationStruct> updates = new Dictionary<Vector2, RegionCoarseLocationStruct>();
691
692 // Root Region entry
693 RegionCoarseLocationStruct rootupdatedata = new RegionCoarseLocationStruct();
694 rootupdatedata.Locations = new List<Vector3>();
695 rootupdatedata.Uuids = new List<UUID>();
696 rootupdatedata.Offset = Vector2.Zero;
697
698 rootupdatedata.UserAPI = rootPresence.ControllingClient;
699
700 if (rootupdatedata.UserAPI != null)
701 updates.Add(Vector2.Zero, rootupdatedata);
702
703 //Each Region needs an entry or we will end up with dead minimap dots
704 foreach (RegionData regiondata in rdata)
705 {
706 Vector2 offset = new Vector2(regiondata.Offset.X, regiondata.Offset.Y);
707 RegionCoarseLocationStruct updatedata = new RegionCoarseLocationStruct();
708 updatedata.Locations = new List<Vector3>();
709 updatedata.Uuids = new List<UUID>();
710 updatedata.Offset = offset;
711
712 if (offset == Vector2.Zero)
713 updatedata.UserAPI = rootPresence.ControllingClient;
714 else
715 updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata);
716
717 if (updatedata.UserAPI != null)
718 updates.Add(offset, updatedata);
719 }
720
721 // go over the locations and assign them to an IClientAPI
722 for (int i = 0; i < locations.Count; i++)
723 //{locations[i]/(int) Constants.RegionSize;
724 {
725 Vector3 pPosition = new Vector3((int)locations[i].X / (int)Constants.RegionSize,
726 (int)locations[i].Y / (int)Constants.RegionSize, locations[i].Z);
727 Vector2 offset = new Vector2(pPosition.X*(int) Constants.RegionSize,
728 pPosition.Y*(int) Constants.RegionSize);
729
730 if (!updates.ContainsKey(offset))
731 {
732 // This shouldn't happen
733 RegionCoarseLocationStruct updatedata = new RegionCoarseLocationStruct();
734 updatedata.Locations = new List<Vector3>();
735 updatedata.Uuids = new List<UUID>();
736 updatedata.Offset = offset;
737
738 if (offset == Vector2.Zero)
739 updatedata.UserAPI = rootPresence.ControllingClient;
740 else
741 updatedata.UserAPI = LocateUsersChildAgentIClientAPI(offset, rootPresence.UUID, rdata);
742
743 updates.Add(offset,updatedata);
744 }
745
746 updates[offset].Locations.Add(locations[i]);
747 updates[offset].Uuids.Add(uuids[i]);
748 }
749
750 // Send out the CoarseLocationupdates from their respective client connection based on where the avatar is
751 foreach (Vector2 offset in updates.Keys)
752 {
753 if (updates[offset].UserAPI != null)
754 {
755 updates[offset].UserAPI.SendCoarseLocationUpdate(updates[offset].Uuids,updates[offset].Locations);
756 }
757 }
758 }
759
760 /// <summary>
761 /// Locates a the Client of a particular region in an Array of RegionData based on offset
762 /// </summary>
763 /// <param name="offset"></param>
764 /// <param name="uUID"></param>
765 /// <param name="rdata"></param>
766 /// <returns>IClientAPI or null</returns>
767 private IClientAPI LocateUsersChildAgentIClientAPI(Vector2 offset, UUID uUID, RegionData[] rdata)
768 {
769 IClientAPI returnclient = null;
770 foreach (RegionData r in rdata)
771 {
772 if (r.Offset.X == offset.X && r.Offset.Y == offset.Y)
773 {
774 return r.RegionScene.SceneGraph.GetControllingClient(uUID);
775 }
776 }
777
778 return returnclient;
779 }
780
781 public void PostInitialise()
782 {
783 }
784
785// /// <summary>
786// /// TODO:
787// /// </summary>
788// /// <param name="rdata"></param>
789// public void UnCombineRegion(RegionData rdata)
790// {
791// lock (m_regions)
792// {
793// if (m_regions.ContainsKey(rdata.RegionId))
794// {
795// // uncombine root region and virtual regions
796// }
797// else
798// {
799// foreach (RegionConnections r in m_regions.Values)
800// {
801// foreach (RegionData rd in r.ConnectedRegions)
802// {
803// if (rd.RegionId == rdata.RegionId)
804// {
805// // uncombine virtual region
806// }
807// }
808// }
809// }
810// }
811// }
812
813 public void ForwardPermissionRequests(RegionConnections BigRegion, Scene VirtualRegion)
814 {
815 if (BigRegion.PermissionModule == null)
816 BigRegion.PermissionModule = new RegionCombinerPermissionModule(BigRegion.RegionScene);
817
818 VirtualRegion.Permissions.OnBypassPermissions += BigRegion.PermissionModule.BypassPermissions;
819 VirtualRegion.Permissions.OnSetBypassPermissions += BigRegion.PermissionModule.SetBypassPermissions;
820 VirtualRegion.Permissions.OnPropagatePermissions += BigRegion.PermissionModule.PropagatePermissions;
821 VirtualRegion.Permissions.OnGenerateClientFlags += BigRegion.PermissionModule.GenerateClientFlags;
822 VirtualRegion.Permissions.OnAbandonParcel += BigRegion.PermissionModule.CanAbandonParcel;
823 VirtualRegion.Permissions.OnReclaimParcel += BigRegion.PermissionModule.CanReclaimParcel;
824 VirtualRegion.Permissions.OnDeedParcel += BigRegion.PermissionModule.CanDeedParcel;
825 VirtualRegion.Permissions.OnDeedObject += BigRegion.PermissionModule.CanDeedObject;
826 VirtualRegion.Permissions.OnIsGod += BigRegion.PermissionModule.IsGod;
827 VirtualRegion.Permissions.OnDuplicateObject += BigRegion.PermissionModule.CanDuplicateObject;
828 VirtualRegion.Permissions.OnDeleteObject += BigRegion.PermissionModule.CanDeleteObject; //MAYBE FULLY IMPLEMENTED
829 VirtualRegion.Permissions.OnEditObject += BigRegion.PermissionModule.CanEditObject; //MAYBE FULLY IMPLEMENTED
830 VirtualRegion.Permissions.OnEditParcelProperties += BigRegion.PermissionModule.CanEditParcelProperties; //MAYBE FULLY IMPLEMENTED
831 VirtualRegion.Permissions.OnInstantMessage += BigRegion.PermissionModule.CanInstantMessage;
832 VirtualRegion.Permissions.OnInventoryTransfer += BigRegion.PermissionModule.CanInventoryTransfer; //NOT YET IMPLEMENTED
833 VirtualRegion.Permissions.OnIssueEstateCommand += BigRegion.PermissionModule.CanIssueEstateCommand; //FULLY IMPLEMENTED
834 VirtualRegion.Permissions.OnMoveObject += BigRegion.PermissionModule.CanMoveObject; //MAYBE FULLY IMPLEMENTED
835 VirtualRegion.Permissions.OnObjectEntry += BigRegion.PermissionModule.CanObjectEntry;
836 VirtualRegion.Permissions.OnReturnObjects += BigRegion.PermissionModule.CanReturnObjects; //NOT YET IMPLEMENTED
837 VirtualRegion.Permissions.OnRezObject += BigRegion.PermissionModule.CanRezObject; //MAYBE FULLY IMPLEMENTED
838 VirtualRegion.Permissions.OnRunConsoleCommand += BigRegion.PermissionModule.CanRunConsoleCommand;
839 VirtualRegion.Permissions.OnRunScript += BigRegion.PermissionModule.CanRunScript; //NOT YET IMPLEMENTED
840 VirtualRegion.Permissions.OnCompileScript += BigRegion.PermissionModule.CanCompileScript;
841 VirtualRegion.Permissions.OnSellParcel += BigRegion.PermissionModule.CanSellParcel;
842 VirtualRegion.Permissions.OnTakeObject += BigRegion.PermissionModule.CanTakeObject;
843 VirtualRegion.Permissions.OnTakeCopyObject += BigRegion.PermissionModule.CanTakeCopyObject;
844 VirtualRegion.Permissions.OnTerraformLand += BigRegion.PermissionModule.CanTerraformLand;
845 VirtualRegion.Permissions.OnLinkObject += BigRegion.PermissionModule.CanLinkObject; //NOT YET IMPLEMENTED
846 VirtualRegion.Permissions.OnDelinkObject += BigRegion.PermissionModule.CanDelinkObject; //NOT YET IMPLEMENTED
847 VirtualRegion.Permissions.OnBuyLand += BigRegion.PermissionModule.CanBuyLand; //NOT YET IMPLEMENTED
848 VirtualRegion.Permissions.OnViewNotecard += BigRegion.PermissionModule.CanViewNotecard; //NOT YET IMPLEMENTED
849 VirtualRegion.Permissions.OnViewScript += BigRegion.PermissionModule.CanViewScript; //NOT YET IMPLEMENTED
850 VirtualRegion.Permissions.OnEditNotecard += BigRegion.PermissionModule.CanEditNotecard; //NOT YET IMPLEMENTED
851 VirtualRegion.Permissions.OnEditScript += BigRegion.PermissionModule.CanEditScript; //NOT YET IMPLEMENTED
852 VirtualRegion.Permissions.OnCreateObjectInventory += BigRegion.PermissionModule.CanCreateObjectInventory; //NOT IMPLEMENTED HERE
853 VirtualRegion.Permissions.OnEditObjectInventory += BigRegion.PermissionModule.CanEditObjectInventory;//MAYBE FULLY IMPLEMENTED
854 VirtualRegion.Permissions.OnCopyObjectInventory += BigRegion.PermissionModule.CanCopyObjectInventory; //NOT YET IMPLEMENTED
855 VirtualRegion.Permissions.OnDeleteObjectInventory += BigRegion.PermissionModule.CanDeleteObjectInventory; //NOT YET IMPLEMENTED
856 VirtualRegion.Permissions.OnResetScript += BigRegion.PermissionModule.CanResetScript;
857 VirtualRegion.Permissions.OnCreateUserInventory += BigRegion.PermissionModule.CanCreateUserInventory; //NOT YET IMPLEMENTED
858 VirtualRegion.Permissions.OnCopyUserInventory += BigRegion.PermissionModule.CanCopyUserInventory; //NOT YET IMPLEMENTED
859 VirtualRegion.Permissions.OnEditUserInventory += BigRegion.PermissionModule.CanEditUserInventory; //NOT YET IMPLEMENTED
860 VirtualRegion.Permissions.OnDeleteUserInventory += BigRegion.PermissionModule.CanDeleteUserInventory; //NOT YET IMPLEMENTED
861 VirtualRegion.Permissions.OnTeleport += BigRegion.PermissionModule.CanTeleport; //NOT YET IMPLEMENTED
862 }
863
864 #region console commands
865
866 public void FixPhantoms(string module, string[] cmdparams)
867 {
868 List<Scene> scenes = new List<Scene>(m_startingScenes.Values);
869
870 foreach (Scene s in scenes)
871 {
872 MainConsole.Instance.OutputFormat("Fixing phantoms for {0}", s.RegionInfo.RegionName);
873
874 s.ForEachSOG(so => so.AbsolutePosition = so.AbsolutePosition);
875 }
876 }
877
878 #endregion
879 }
880}
diff --git a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerPermissionModule.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerPermissionModule.cs
deleted file mode 100644
index 07dd68b..0000000
--- a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCombinerPermissionModule.cs
+++ /dev/null
@@ -1,270 +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 OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Region.Framework.Scenes;
34
35namespace OpenSim.Region.RegionCombinerModule
36{
37 public class RegionCombinerPermissionModule
38 {
39 private Scene m_rootScene;
40
41 public RegionCombinerPermissionModule(Scene RootScene)
42 {
43 m_rootScene = RootScene;
44 }
45
46 #region Permission Override
47
48 public bool BypassPermissions()
49 {
50 return m_rootScene.Permissions.BypassPermissions();
51 }
52
53 public void SetBypassPermissions(bool value)
54 {
55 m_rootScene.Permissions.SetBypassPermissions(value);
56 }
57
58 public bool PropagatePermissions()
59 {
60 return m_rootScene.Permissions.PropagatePermissions();
61 }
62
63 public uint GenerateClientFlags(UUID userid, UUID objectidid)
64 {
65 return m_rootScene.Permissions.GenerateClientFlags(userid,objectidid);
66 }
67
68 public bool CanAbandonParcel(UUID user, ILandObject parcel, Scene scene)
69 {
70 return m_rootScene.Permissions.CanAbandonParcel(user,parcel);
71 }
72
73 public bool CanReclaimParcel(UUID user, ILandObject parcel, Scene scene)
74 {
75 return m_rootScene.Permissions.CanReclaimParcel(user, parcel);
76 }
77
78 public bool CanDeedParcel(UUID user, ILandObject parcel, Scene scene)
79 {
80 return m_rootScene.Permissions.CanDeedParcel(user, parcel);
81 }
82
83 public bool CanDeedObject(UUID user, UUID @group, Scene scene)
84 {
85 return m_rootScene.Permissions.CanDeedObject(user,@group);
86 }
87
88 public bool IsGod(UUID user, Scene requestfromscene)
89 {
90 return m_rootScene.Permissions.IsGod(user);
91 }
92
93 public bool CanDuplicateObject(int objectcount, UUID objectid, UUID owner, Scene scene, Vector3 objectposition)
94 {
95 return m_rootScene.Permissions.CanDuplicateObject(objectcount, objectid, owner, objectposition);
96 }
97
98 public bool CanDeleteObject(UUID objectid, UUID deleter, Scene scene)
99 {
100 return m_rootScene.Permissions.CanDeleteObject(objectid, deleter);
101 }
102
103 public bool CanEditObject(UUID objectid, UUID editorid, Scene scene)
104 {
105 return m_rootScene.Permissions.CanEditObject(objectid, editorid);
106 }
107
108 public bool CanEditParcelProperties(UUID user, ILandObject parcel, GroupPowers g, Scene scene)
109 {
110 return m_rootScene.Permissions.CanEditParcelProperties(user, parcel, g);
111 }
112
113 public bool CanInstantMessage(UUID user, UUID target, Scene startscene)
114 {
115 return m_rootScene.Permissions.CanInstantMessage(user, target);
116 }
117
118 public bool CanInventoryTransfer(UUID user, UUID target, Scene startscene)
119 {
120 return m_rootScene.Permissions.CanInventoryTransfer(user, target);
121 }
122
123 public bool CanIssueEstateCommand(UUID user, Scene requestfromscene, bool ownercommand)
124 {
125 return m_rootScene.Permissions.CanIssueEstateCommand(user, ownercommand);
126 }
127
128 public bool CanMoveObject(UUID objectid, UUID moverid, Scene scene)
129 {
130 return m_rootScene.Permissions.CanMoveObject(objectid, moverid);
131 }
132
133 public bool CanObjectEntry(UUID objectid, bool enteringregion, Vector3 newpoint, Scene scene)
134 {
135 return m_rootScene.Permissions.CanObjectEntry(objectid, enteringregion, newpoint);
136 }
137
138 public bool CanReturnObjects(ILandObject land, UUID user, List<SceneObjectGroup> objects, Scene scene)
139 {
140 return m_rootScene.Permissions.CanReturnObjects(land, user, objects);
141 }
142
143 public bool CanRezObject(int objectcount, UUID owner, Vector3 objectposition, Scene scene)
144 {
145 return m_rootScene.Permissions.CanRezObject(objectcount, owner, objectposition);
146 }
147
148 public bool CanRunConsoleCommand(UUID user, Scene requestfromscene)
149 {
150 return m_rootScene.Permissions.CanRunConsoleCommand(user);
151 }
152
153 public bool CanRunScript(UUID script, UUID objectid, UUID user, Scene scene)
154 {
155 return m_rootScene.Permissions.CanRunScript(script, objectid, user);
156 }
157
158 public bool CanCompileScript(UUID owneruuid, int scripttype, Scene scene)
159 {
160 return m_rootScene.Permissions.CanCompileScript(owneruuid, scripttype);
161 }
162
163 public bool CanSellParcel(UUID user, ILandObject parcel, Scene scene)
164 {
165 return m_rootScene.Permissions.CanSellParcel(user, parcel);
166 }
167
168 public bool CanTakeObject(UUID objectid, UUID stealer, Scene scene)
169 {
170 return m_rootScene.Permissions.CanTakeObject(objectid, stealer);
171 }
172
173 public bool CanTakeCopyObject(UUID objectid, UUID userid, Scene inscene)
174 {
175 return m_rootScene.Permissions.CanTakeObject(objectid, userid);
176 }
177
178 public bool CanTerraformLand(UUID user, Vector3 position, Scene requestfromscene)
179 {
180 return m_rootScene.Permissions.CanTerraformLand(user, position);
181 }
182
183 public bool CanLinkObject(UUID user, UUID objectid)
184 {
185 return m_rootScene.Permissions.CanLinkObject(user, objectid);
186 }
187
188 public bool CanDelinkObject(UUID user, UUID objectid)
189 {
190 return m_rootScene.Permissions.CanDelinkObject(user, objectid);
191 }
192
193 public bool CanBuyLand(UUID user, ILandObject parcel, Scene scene)
194 {
195 return m_rootScene.Permissions.CanBuyLand(user, parcel);
196 }
197
198 public bool CanViewNotecard(UUID script, UUID objectid, UUID user, Scene scene)
199 {
200 return m_rootScene.Permissions.CanViewNotecard(script, objectid, user);
201 }
202
203 public bool CanViewScript(UUID script, UUID objectid, UUID user, Scene scene)
204 {
205 return m_rootScene.Permissions.CanViewScript(script, objectid, user);
206 }
207
208 public bool CanEditNotecard(UUID notecard, UUID objectid, UUID user, Scene scene)
209 {
210 return m_rootScene.Permissions.CanEditNotecard(notecard, objectid, user);
211 }
212
213 public bool CanEditScript(UUID script, UUID objectid, UUID user, Scene scene)
214 {
215 return m_rootScene.Permissions.CanEditScript(script, objectid, user);
216 }
217
218 public bool CanCreateObjectInventory(int invtype, UUID objectid, UUID userid)
219 {
220 return m_rootScene.Permissions.CanCreateObjectInventory(invtype, objectid, userid);
221 }
222
223 public bool CanEditObjectInventory(UUID objectid, UUID editorid, Scene scene)
224 {
225 return m_rootScene.Permissions.CanEditObjectInventory(objectid, editorid);
226 }
227
228 public bool CanCopyObjectInventory(UUID itemid, UUID objectid, UUID userid)
229 {
230 return m_rootScene.Permissions.CanCopyObjectInventory(itemid, objectid, userid);
231 }
232
233 public bool CanDeleteObjectInventory(UUID itemid, UUID objectid, UUID userid)
234 {
235 return m_rootScene.Permissions.CanDeleteObjectInventory(itemid, objectid, userid);
236 }
237
238 public bool CanResetScript(UUID prim, UUID script, UUID user, Scene scene)
239 {
240 return m_rootScene.Permissions.CanResetScript(prim, script, user);
241 }
242
243 public bool CanCreateUserInventory(int invtype, UUID userid)
244 {
245 return m_rootScene.Permissions.CanCreateUserInventory(invtype, userid);
246 }
247
248 public bool CanCopyUserInventory(UUID itemid, UUID userid)
249 {
250 return m_rootScene.Permissions.CanCopyUserInventory(itemid, userid);
251 }
252
253 public bool CanEditUserInventory(UUID itemid, UUID userid)
254 {
255 return m_rootScene.Permissions.CanEditUserInventory(itemid, userid);
256 }
257
258 public bool CanDeleteUserInventory(UUID itemid, UUID userid)
259 {
260 return m_rootScene.Permissions.CanDeleteUserInventory(itemid, userid);
261 }
262
263 public bool CanTeleport(UUID userid, Scene scene)
264 {
265 return m_rootScene.Permissions.CanTeleport(userid);
266 }
267
268 #endregion
269 }
270}
diff --git a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionConnections.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionConnections.cs
deleted file mode 100644
index 62a3a91..0000000
--- a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionConnections.cs
+++ /dev/null
@@ -1,94 +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 OpenMetaverse;
31using OpenSim.Framework;
32using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Region.Framework.Scenes;
34
35namespace OpenSim.Region.RegionCombinerModule
36{
37 public class RegionConnections
38 {
39 /// <summary>
40 /// Root Region ID
41 /// </summary>
42 public UUID RegionId;
43
44 /// <summary>
45 /// Root Region Scene
46 /// </summary>
47 public Scene RegionScene;
48
49 /// <summary>
50 /// LargeLandChannel for combined region
51 /// </summary>
52 public ILandChannel RegionLandChannel;
53
54 /// <summary>
55 /// The x map co-ordinate for this region (where each co-ordinate is a Constants.RegionSize block).
56 /// </summary>
57 public uint X;
58
59 /// <summary>
60 /// The y co-ordinate for this region (where each cor-odinate is a Constants.RegionSize block).
61 /// </summary>
62 public uint Y;
63
64 /// <summary>
65 /// The X meters position of this connection.
66 /// </summary>
67 public uint PosX { get { return Util.RegionToWorldLoc(X); } }
68
69 /// <summary>
70 /// The Y meters co-ordinate of this connection.
71 /// </summary>
72 public uint PosY { get { return Util.RegionToWorldLoc(Y); } }
73
74 /// <summary>
75 /// The size of the megaregion in meters.
76 /// </summary>
77 public uint XEnd;
78
79 /// <summary>
80 /// The size of the megaregion in meters.
81 /// </summary>
82 public uint YEnd;
83
84 public List<RegionData> ConnectedRegions;
85 public RegionCombinerPermissionModule PermissionModule;
86 public RegionCombinerClientEventForwarder ClientEventForwarder;
87
88 public void UpdateExtents(Vector3 extents)
89 {
90 XEnd = (uint)extents.X;
91 YEnd = (uint)extents.Y;
92 }
93 }
94} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCourseLocation.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCourseLocation.cs
deleted file mode 100644
index 224ac99..0000000
--- a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionCourseLocation.cs
+++ /dev/null
@@ -1,43 +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 OpenMetaverse;
31using OpenSim.Framework;
32
33namespace OpenSim.Region.RegionCombinerModule
34{
35
36 struct RegionCoarseLocationStruct
37 {
38 public List<Vector3> Locations;
39 public List<UUID> Uuids;
40 public IClientAPI UserAPI;
41 public Vector2 Offset;
42 }
43} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionData.cs b/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionData.cs
deleted file mode 100644
index 42fca9f..0000000
--- a/OpenSim/Region/OptionalModules/RegionCombinerModule/RegionData.cs
+++ /dev/null
@@ -1,40 +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.Region.Framework.Scenes;
30
31namespace OpenSim.Region.RegionCombinerModule
32{
33 public class RegionData
34 {
35 public UUID RegionId;
36 public Scene RegionScene;
37 // Offset of this region from the base of the root region.
38 public Vector3 Offset;
39 }
40} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
index c38bb3e..9343aab 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStore.cs
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) Contributors 2 * Copyright (c) Contributors
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
@@ -67,7 +67,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
67 67
68 protected List<TakeValueCallbackClass> m_TakeStore; 68 protected List<TakeValueCallbackClass> m_TakeStore;
69 protected List<TakeValueCallbackClass> m_ReadStore; 69 protected List<TakeValueCallbackClass> m_ReadStore;
70 70
71 // add separators for quoted paths and array references 71 // add separators for quoted paths and array references
72 protected static Regex m_ParsePassOne = new Regex("({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])"); 72 protected static Regex m_ParsePassOne = new Regex("({[^}]+}|\\[[0-9]+\\]|\\[\\+\\])");
73 73
@@ -98,10 +98,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
98 /// </summary> 98 /// </summary>
99 // ----------------------------------------------------------------- 99 // -----------------------------------------------------------------
100 public int StringSpace { get; set; } 100 public int StringSpace { get; set; }
101 101
102 // ----------------------------------------------------------------- 102 // -----------------------------------------------------------------
103 /// <summary> 103 /// <summary>
104 /// 104 ///
105 /// </summary> 105 /// </summary>
106 // ----------------------------------------------------------------- 106 // -----------------------------------------------------------------
107 public static bool CanonicalPathExpression(string ipath, out string opath) 107 public static bool CanonicalPathExpression(string ipath, out string opath)
@@ -116,13 +116,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
116 opath = PathExpressionToKey(path); 116 opath = PathExpressionToKey(path);
117 return true; 117 return true;
118 } 118 }
119 119
120 // ----------------------------------------------------------------- 120 // -----------------------------------------------------------------
121 /// <summary> 121 /// <summary>
122 /// 122 ///
123 /// </summary> 123 /// </summary>
124 // ----------------------------------------------------------------- 124 // -----------------------------------------------------------------
125 public JsonStore() 125 public JsonStore()
126 { 126 {
127 StringSpace = 0; 127 StringSpace = 0;
128 m_TakeStore = new List<TakeValueCallbackClass>(); 128 m_TakeStore = new List<TakeValueCallbackClass>();
@@ -132,17 +132,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
132 public JsonStore(string value) : this() 132 public JsonStore(string value) : this()
133 { 133 {
134 // This is going to throw an exception if the value is not 134 // This is going to throw an exception if the value is not
135 // a valid JSON chunk. Calling routines should catch the 135 // a valid JSON chunk. Calling routines should catch the
136 // exception and handle it appropriately 136 // exception and handle it appropriately
137 if (String.IsNullOrEmpty(value)) 137 if (String.IsNullOrEmpty(value))
138 ValueStore = new OSDMap(); 138 ValueStore = new OSDMap();
139 else 139 else
140 ValueStore = OSDParser.DeserializeJson(value); 140 ValueStore = OSDParser.DeserializeJson(value);
141 } 141 }
142 142
143 // ----------------------------------------------------------------- 143 // -----------------------------------------------------------------
144 /// <summary> 144 /// <summary>
145 /// 145 ///
146 /// </summary> 146 /// </summary>
147 // ----------------------------------------------------------------- 147 // -----------------------------------------------------------------
148 public JsonStoreNodeType GetNodeType(string expr) 148 public JsonStoreNodeType GetNodeType(string expr)
@@ -150,27 +150,27 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
150 Stack<string> path; 150 Stack<string> path;
151 if (! ParsePathExpression(expr,out path)) 151 if (! ParsePathExpression(expr,out path))
152 return JsonStoreNodeType.Undefined; 152 return JsonStoreNodeType.Undefined;
153 153
154 OSD result = ProcessPathExpression(ValueStore,path); 154 OSD result = ProcessPathExpression(ValueStore,path);
155 155
156 if (result == null) 156 if (result == null)
157 return JsonStoreNodeType.Undefined; 157 return JsonStoreNodeType.Undefined;
158 158
159 if (result is OSDMap) 159 if (result is OSDMap)
160 return JsonStoreNodeType.Object; 160 return JsonStoreNodeType.Object;
161 161
162 if (result is OSDArray) 162 if (result is OSDArray)
163 return JsonStoreNodeType.Array; 163 return JsonStoreNodeType.Array;
164 164
165 if (OSDBaseType(result.Type)) 165 if (OSDBaseType(result.Type))
166 return JsonStoreNodeType.Value; 166 return JsonStoreNodeType.Value;
167 167
168 return JsonStoreNodeType.Undefined; 168 return JsonStoreNodeType.Undefined;
169 } 169 }
170 170
171 // ----------------------------------------------------------------- 171 // -----------------------------------------------------------------
172 /// <summary> 172 /// <summary>
173 /// 173 ///
174 /// </summary> 174 /// </summary>
175 // ----------------------------------------------------------------- 175 // -----------------------------------------------------------------
176 public JsonStoreValueType GetValueType(string expr) 176 public JsonStoreValueType GetValueType(string expr)
@@ -178,18 +178,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
178 Stack<string> path; 178 Stack<string> path;
179 if (! ParsePathExpression(expr,out path)) 179 if (! ParsePathExpression(expr,out path))
180 return JsonStoreValueType.Undefined; 180 return JsonStoreValueType.Undefined;
181 181
182 OSD result = ProcessPathExpression(ValueStore,path); 182 OSD result = ProcessPathExpression(ValueStore,path);
183 183
184 if (result == null) 184 if (result == null)
185 return JsonStoreValueType.Undefined; 185 return JsonStoreValueType.Undefined;
186 186
187 if (result is OSDMap) 187 if (result is OSDMap)
188 return JsonStoreValueType.Undefined; 188 return JsonStoreValueType.Undefined;
189 189
190 if (result is OSDArray) 190 if (result is OSDArray)
191 return JsonStoreValueType.Undefined; 191 return JsonStoreValueType.Undefined;
192 192
193 if (result is OSDBoolean) 193 if (result is OSDBoolean)
194 return JsonStoreValueType.Boolean; 194 return JsonStoreValueType.Boolean;
195 195
@@ -204,10 +204,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
204 204
205 return JsonStoreValueType.Undefined; 205 return JsonStoreValueType.Undefined;
206 } 206 }
207 207
208 // ----------------------------------------------------------------- 208 // -----------------------------------------------------------------
209 /// <summary> 209 /// <summary>
210 /// 210 ///
211 /// </summary> 211 /// </summary>
212 // ----------------------------------------------------------------- 212 // -----------------------------------------------------------------
213 public int ArrayLength(string expr) 213 public int ArrayLength(string expr)
@@ -228,7 +228,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
228 228
229 // ----------------------------------------------------------------- 229 // -----------------------------------------------------------------
230 /// <summary> 230 /// <summary>
231 /// 231 ///
232 /// </summary> 232 /// </summary>
233 // ----------------------------------------------------------------- 233 // -----------------------------------------------------------------
234 public bool GetValue(string expr, out string value, bool useJson) 234 public bool GetValue(string expr, out string value, bool useJson)
@@ -241,23 +241,23 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
241 } 241 }
242 242
243 OSD result = ProcessPathExpression(ValueStore,path); 243 OSD result = ProcessPathExpression(ValueStore,path);
244 return ConvertOutputValue(result,out value,useJson); 244 return ConvertOutputValue(result,out value,useJson);
245 } 245 }
246 246
247 247
248 // ----------------------------------------------------------------- 248 // -----------------------------------------------------------------
249 /// <summary> 249 /// <summary>
250 /// 250 ///
251 /// </summary> 251 /// </summary>
252 // ----------------------------------------------------------------- 252 // -----------------------------------------------------------------
253 public bool RemoveValue(string expr) 253 public bool RemoveValue(string expr)
254 { 254 {
255 return SetValueFromExpression(expr,null); 255 return SetValueFromExpression(expr,null);
256 } 256 }
257 257
258 // ----------------------------------------------------------------- 258 // -----------------------------------------------------------------
259 /// <summary> 259 /// <summary>
260 /// 260 ///
261 /// </summary> 261 /// </summary>
262 // ----------------------------------------------------------------- 262 // -----------------------------------------------------------------
263 public bool SetValue(string expr, string value, bool useJson) 263 public bool SetValue(string expr, string value, bool useJson)
@@ -272,7 +272,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
272 { 272 {
273 // There doesn't appear to be a good way to determine if the 273 // There doesn't appear to be a good way to determine if the
274 // value is valid Json other than to let the parser crash 274 // value is valid Json other than to let the parser crash
275 try 275 try
276 { 276 {
277 ovalue = OSDParser.DeserializeJson(value); 277 ovalue = OSDParser.DeserializeJson(value);
278 } 278 }
@@ -292,13 +292,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
292 { 292 {
293 ovalue = new OSDString(value); 293 ovalue = new OSDString(value);
294 } 294 }
295 295
296 return SetValueFromExpression(expr,ovalue); 296 return SetValueFromExpression(expr,ovalue);
297 } 297 }
298 298
299 // ----------------------------------------------------------------- 299 // -----------------------------------------------------------------
300 /// <summary> 300 /// <summary>
301 /// 301 ///
302 /// </summary> 302 /// </summary>
303 // ----------------------------------------------------------------- 303 // -----------------------------------------------------------------
304 public bool TakeValue(string expr, bool useJson, TakeValueCallback cback) 304 public bool TakeValue(string expr, bool useJson, TakeValueCallback cback)
@@ -315,7 +315,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
315 m_TakeStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback)); 315 m_TakeStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback));
316 return false; 316 return false;
317 } 317 }
318 318
319 string value = String.Empty; 319 string value = String.Empty;
320 if (! ConvertOutputValue(result,out value,useJson)) 320 if (! ConvertOutputValue(result,out value,useJson))
321 { 321 {
@@ -332,7 +332,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
332 332
333 // ----------------------------------------------------------------- 333 // -----------------------------------------------------------------
334 /// <summary> 334 /// <summary>
335 /// 335 ///
336 /// </summary> 336 /// </summary>
337 // ----------------------------------------------------------------- 337 // -----------------------------------------------------------------
338 public bool ReadValue(string expr, bool useJson, TakeValueCallback cback) 338 public bool ReadValue(string expr, bool useJson, TakeValueCallback cback)
@@ -349,7 +349,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
349 m_ReadStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback)); 349 m_ReadStore.Add(new TakeValueCallbackClass(pexpr,useJson,cback));
350 return false; 350 return false;
351 } 351 }
352 352
353 string value = String.Empty; 353 string value = String.Empty;
354 if (! ConvertOutputValue(result,out value,useJson)) 354 if (! ConvertOutputValue(result,out value,useJson))
355 { 355 {
@@ -362,10 +362,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
362 362
363 return true; 363 return true;
364 } 364 }
365 365
366 // ----------------------------------------------------------------- 366 // -----------------------------------------------------------------
367 /// <summary> 367 /// <summary>
368 /// 368 ///
369 /// </summary> 369 /// </summary>
370 // ----------------------------------------------------------------- 370 // -----------------------------------------------------------------
371 protected bool SetValueFromExpression(string expr, OSD ovalue) 371 protected bool SetValueFromExpression(string expr, OSD ovalue)
@@ -447,7 +447,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
447 Match match = hmatches[0]; 447 Match match = hmatches[0];
448 GroupCollection groups = match.Groups; 448 GroupCollection groups = match.Groups;
449 string hkey = groups[1].Value; 449 string hkey = groups[1].Value;
450 450
451 if (result is OSDMap) 451 if (result is OSDMap)
452 { 452 {
453 // this is the assignment case 453 // this is the assignment case
@@ -456,7 +456,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
456 { 456 {
457 StringSpace -= ComputeSizeOf(hmap[hkey]); 457 StringSpace -= ComputeSizeOf(hmap[hkey]);
458 StringSpace += ComputeSizeOf(ovalue); 458 StringSpace += ComputeSizeOf(ovalue);
459 459
460 hmap[hkey] = ovalue; 460 hmap[hkey] = ovalue;
461 InvokeNextCallback(pexpr + pkey); 461 InvokeNextCallback(pexpr + pkey);
462 return true; 462 return true;
@@ -483,13 +483,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
483 483
484 // ----------------------------------------------------------------- 484 // -----------------------------------------------------------------
485 /// <summary> 485 /// <summary>
486 /// 486 ///
487 /// </summary> 487 /// </summary>
488 // ----------------------------------------------------------------- 488 // -----------------------------------------------------------------
489 protected bool InvokeNextCallback(string pexpr) 489 protected bool InvokeNextCallback(string pexpr)
490 { 490 {
491 // Process all of the reads that match the expression first 491 // Process all of the reads that match the expression first
492 List<TakeValueCallbackClass> reads = 492 List<TakeValueCallbackClass> reads =
493 m_ReadStore.FindAll(delegate(TakeValueCallbackClass tb) { return pexpr.StartsWith(tb.Path); }); 493 m_ReadStore.FindAll(delegate(TakeValueCallbackClass tb) { return pexpr.StartsWith(tb.Path); });
494 494
495 foreach (TakeValueCallbackClass readcb in reads) 495 foreach (TakeValueCallbackClass readcb in reads)
@@ -501,7 +501,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
501 // Process one take next 501 // Process one take next
502 TakeValueCallbackClass takecb = 502 TakeValueCallbackClass takecb =
503 m_TakeStore.Find(delegate(TakeValueCallbackClass tb) { return pexpr.StartsWith(tb.Path); }); 503 m_TakeStore.Find(delegate(TakeValueCallbackClass tb) { return pexpr.StartsWith(tb.Path); });
504 504
505 if (takecb != null) 505 if (takecb != null)
506 { 506 {
507 m_TakeStore.Remove(takecb); 507 m_TakeStore.Remove(takecb);
@@ -525,13 +525,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
525 525
526 // add front and rear separators 526 // add front and rear separators
527 expr = "." + expr + "."; 527 expr = "." + expr + ".";
528 528
529 // add separators for quoted exprs and array references 529 // add separators for quoted exprs and array references
530 expr = m_ParsePassOne.Replace(expr,".$1.",-1,0); 530 expr = m_ParsePassOne.Replace(expr,".$1.",-1,0);
531 531
532 // add quotes to bare identifier 532 // add quotes to bare identifier
533 expr = m_ParsePassThree.Replace(expr,".{$1}",-1,0); 533 expr = m_ParsePassThree.Replace(expr,".{$1}",-1,0);
534 534
535 // remove extra separators 535 // remove extra separators
536 expr = m_ParsePassFour.Replace(expr,".",-1,0); 536 expr = m_ParsePassFour.Replace(expr,".",-1,0);
537 537
@@ -550,7 +550,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
550 550
551 // ----------------------------------------------------------------- 551 // -----------------------------------------------------------------
552 /// <summary> 552 /// <summary>
553 /// 553 ///
554 /// </summary> 554 /// </summary>
555 /// <param>path is a stack where the top level of the path is at the bottom of the stack</param> 555 /// <param>path is a stack where the top level of the path is at the bottom of the stack</param>
556 // ----------------------------------------------------------------- 556 // -----------------------------------------------------------------
@@ -558,13 +558,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
558 { 558 {
559 if (path.Count == 0) 559 if (path.Count == 0)
560 return map; 560 return map;
561 561
562 string pkey = path.Pop(); 562 string pkey = path.Pop();
563 563
564 OSD rmap = ProcessPathExpression(map,path); 564 OSD rmap = ProcessPathExpression(map,path);
565 if (rmap == null) 565 if (rmap == null)
566 return null; 566 return null;
567 567
568 // ---------- Check for an array index ---------- 568 // ---------- Check for an array index ----------
569 MatchCollection amatches = m_SimpleArrayPattern.Matches(pkey,0); 569 MatchCollection amatches = m_SimpleArrayPattern.Matches(pkey,0);
570 570
@@ -582,7 +582,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
582 GroupCollection groups = match.Groups; 582 GroupCollection groups = match.Groups;
583 string akey = groups[1].Value; 583 string akey = groups[1].Value;
584 int aval = Convert.ToInt32(akey); 584 int aval = Convert.ToInt32(akey);
585 585
586 if (aval < amap.Count) 586 if (aval < amap.Count)
587 return (OSD) amap[aval]; 587 return (OSD) amap[aval];
588 588
@@ -599,13 +599,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
599 m_log.WarnFormat("[JsonStore] wrong type for key {2}, expecting {0}, got {1}",OSDType.Map,rmap.Type,pkey); 599 m_log.WarnFormat("[JsonStore] wrong type for key {2}, expecting {0}, got {1}",OSDType.Map,rmap.Type,pkey);
600 return null; 600 return null;
601 } 601 }
602 602
603 OSDMap hmap = rmap as OSDMap; 603 OSDMap hmap = rmap as OSDMap;
604 604
605 Match match = hmatches[0]; 605 Match match = hmatches[0];
606 GroupCollection groups = match.Groups; 606 GroupCollection groups = match.Groups;
607 string hkey = groups[1].Value; 607 string hkey = groups[1].Value;
608 608
609 if (hmap.ContainsKey(hkey)) 609 if (hmap.ContainsKey(hkey))
610 return (OSD) hmap[hkey]; 610 return (OSD) hmap[hkey];
611 611
@@ -619,13 +619,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
619 619
620 // ----------------------------------------------------------------- 620 // -----------------------------------------------------------------
621 /// <summary> 621 /// <summary>
622 /// 622 ///
623 /// </summary> 623 /// </summary>
624 // ----------------------------------------------------------------- 624 // -----------------------------------------------------------------
625 protected static bool ConvertOutputValue(OSD result, out string value, bool useJson) 625 protected static bool ConvertOutputValue(OSD result, out string value, bool useJson)
626 { 626 {
627 value = String.Empty; 627 value = String.Empty;
628 628
629 // If we couldn't process the path 629 // If we couldn't process the path
630 if (result == null) 630 if (result == null)
631 return false; 631 return false;
@@ -646,13 +646,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
646 return true; 646 return true;
647 } 647 }
648 648
649 value = "'" + result.AsString() + "'"; 649 value = "'" + result.AsString() + "'";
650 return true; 650 return true;
651 } 651 }
652 652
653 if (OSDBaseType(result.Type)) 653 if (OSDBaseType(result.Type))
654 { 654 {
655 value = result.AsString(); 655 value = result.AsString();
656 return true; 656 return true;
657 } 657 }
658 658
@@ -661,24 +661,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
661 661
662 // ----------------------------------------------------------------- 662 // -----------------------------------------------------------------
663 /// <summary> 663 /// <summary>
664 /// 664 ///
665 /// </summary> 665 /// </summary>
666 // ----------------------------------------------------------------- 666 // -----------------------------------------------------------------
667 protected static string PathExpressionToKey(Stack<string> path) 667 protected static string PathExpressionToKey(Stack<string> path)
668 { 668 {
669 if (path.Count == 0) 669 if (path.Count == 0)
670 return ""; 670 return "";
671 671
672 string pkey = ""; 672 string pkey = "";
673 foreach (string k in path) 673 foreach (string k in path)
674 pkey = (pkey == "") ? k : (k + "." + pkey); 674 pkey = (pkey == "") ? k : (k + "." + pkey);
675 675
676 return pkey; 676 return pkey;
677 } 677 }
678 678
679 // ----------------------------------------------------------------- 679 // -----------------------------------------------------------------
680 /// <summary> 680 /// <summary>
681 /// 681 ///
682 /// </summary> 682 /// </summary>
683 // ----------------------------------------------------------------- 683 // -----------------------------------------------------------------
684 protected static bool OSDBaseType(OSDType type) 684 protected static bool OSDBaseType(OSDType type)
@@ -705,7 +705,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
705 705
706 // ----------------------------------------------------------------- 706 // -----------------------------------------------------------------
707 /// <summary> 707 /// <summary>
708 /// 708 ///
709 /// </summary> 709 /// </summary>
710 // ----------------------------------------------------------------- 710 // -----------------------------------------------------------------
711 protected static int ComputeSizeOf(OSD value) 711 protected static int ComputeSizeOf(OSD value)
@@ -731,7 +731,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
731 private Scene m_scene; 731 private Scene m_scene;
732 private UUID m_objectID; 732 private UUID m_objectID;
733 733
734 protected override OSD ValueStore 734 protected override OSD ValueStore
735 { 735 {
736 get 736 get
737 { 737 {
@@ -741,7 +741,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
741 // This is bad 741 // This is bad
742 return null; 742 return null;
743 } 743 }
744 744
745 return sop.DynAttrs.TopLevelMap; 745 return sop.DynAttrs.TopLevelMap;
746 } 746 }
747 747
@@ -761,5 +761,5 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
761 StringSpace = ComputeSizeOf(ValueStore); 761 StringSpace = ComputeSizeOf(ValueStore);
762 } 762 }
763 } 763 }
764 764
765} 765}
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs
index d4b19dd..9bf9cb0 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreCommands.cs
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) Contributors 2 * Copyright (c) Contributors
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
@@ -79,7 +79,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
79 // ----------------------------------------------------------------- 79 // -----------------------------------------------------------------
80 public void Initialise(IConfigSource config) 80 public void Initialise(IConfigSource config)
81 { 81 {
82 try 82 try
83 { 83 {
84 if ((m_config = config.Configs["JsonStore"]) == null) 84 if ((m_config = config.Configs["JsonStore"]) == null)
85 { 85 {
@@ -127,7 +127,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
127 if (m_enabled) 127 if (m_enabled)
128 { 128 {
129 m_scene = scene; 129 m_scene = scene;
130 130
131 } 131 }
132 } 132 }
133 133
@@ -143,7 +143,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
143 143
144 // ----------------------------------------------------------------- 144 // -----------------------------------------------------------------
145 /// <summary> 145 /// <summary>
146 /// Called when all modules have been added for a region. This is 146 /// Called when all modules have been added for a region. This is
147 /// where we hook up events 147 /// where we hook up events
148 /// </summary> 148 /// </summary>
149 // ----------------------------------------------------------------- 149 // -----------------------------------------------------------------
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
index 26044f0..ae8341f 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) Contributors 2 * Copyright (c) Contributors
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
@@ -83,7 +83,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
83 // ----------------------------------------------------------------- 83 // -----------------------------------------------------------------
84 public void Initialise(IConfigSource config) 84 public void Initialise(IConfigSource config)
85 { 85 {
86 try 86 try
87 { 87 {
88 if ((m_config = config.Configs["JsonStore"]) == null) 88 if ((m_config = config.Configs["JsonStore"]) == null)
89 { 89 {
@@ -159,7 +159,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
159 159
160 // ----------------------------------------------------------------- 160 // -----------------------------------------------------------------
161 /// <summary> 161 /// <summary>
162 /// Called when all modules have been added for a region. This is 162 /// Called when all modules have been added for a region. This is
163 /// where we hook up events 163 /// where we hook up events
164 /// </summary> 164 /// </summary>
165 // ----------------------------------------------------------------- 165 // -----------------------------------------------------------------
@@ -184,7 +184,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
184#region SceneEvents 184#region SceneEvents
185 // ----------------------------------------------------------------- 185 // -----------------------------------------------------------------
186 /// <summary> 186 /// <summary>
187 /// 187 ///
188 /// </summary> 188 /// </summary>
189 // ----------------------------------------------------------------- 189 // -----------------------------------------------------------------
190 public void EventManagerOnObjectBeingRemovedFromScene(SceneObjectGroup obj) 190 public void EventManagerOnObjectBeingRemovedFromScene(SceneObjectGroup obj)
@@ -196,10 +196,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
196 196
197#region ScriptInvocationInteface 197#region ScriptInvocationInteface
198 198
199 199
200 // ----------------------------------------------------------------- 200 // -----------------------------------------------------------------
201 /// <summary> 201 /// <summary>
202 /// 202 ///
203 /// </summary> 203 /// </summary>
204 // ----------------------------------------------------------------- 204 // -----------------------------------------------------------------
205 public JsonStoreStats GetStoreStats() 205 public JsonStoreStats GetStoreStats()
@@ -210,13 +210,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
210 { 210 {
211 stats.StoreCount = m_JsonValueStore.Count; 211 stats.StoreCount = m_JsonValueStore.Count;
212 } 212 }
213 213
214 return stats; 214 return stats;
215 } 215 }
216 216
217 // ----------------------------------------------------------------- 217 // -----------------------------------------------------------------
218 /// <summary> 218 /// <summary>
219 /// 219 ///
220 /// </summary> 220 /// </summary>
221 // ----------------------------------------------------------------- 221 // -----------------------------------------------------------------
222 public bool AttachObjectStore(UUID objectID) 222 public bool AttachObjectStore(UUID objectID)
@@ -235,17 +235,17 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
235 { 235 {
236 if (m_JsonValueStore.ContainsKey(objectID)) 236 if (m_JsonValueStore.ContainsKey(objectID))
237 return true; 237 return true;
238 238
239 JsonStore map = new JsonObjectStore(m_scene,objectID); 239 JsonStore map = new JsonObjectStore(m_scene,objectID);
240 m_JsonValueStore.Add(objectID,map); 240 m_JsonValueStore.Add(objectID,map);
241 } 241 }
242 242
243 return true; 243 return true;
244 } 244 }
245 245
246 // ----------------------------------------------------------------- 246 // -----------------------------------------------------------------
247 /// <summary> 247 /// <summary>
248 /// 248 ///
249 /// </summary> 249 /// </summary>
250 // ----------------------------------------------------------------- 250 // -----------------------------------------------------------------
251 public bool CreateStore(string value, ref UUID result) 251 public bool CreateStore(string value, ref UUID result)
@@ -254,12 +254,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
254 result = UUID.Random(); 254 result = UUID.Random();
255 255
256 JsonStore map = null; 256 JsonStore map = null;
257 257
258 if (! m_enabled) return false; 258 if (! m_enabled) return false;
259 259
260 260
261 try 261 try
262 { 262 {
263 map = new JsonStore(value); 263 map = new JsonStore(value);
264 } 264 }
265 catch (Exception) 265 catch (Exception)
@@ -270,13 +270,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
270 270
271 lock (m_JsonValueStore) 271 lock (m_JsonValueStore)
272 m_JsonValueStore.Add(result,map); 272 m_JsonValueStore.Add(result,map);
273 273
274 return true; 274 return true;
275 } 275 }
276 276
277 // ----------------------------------------------------------------- 277 // -----------------------------------------------------------------
278 /// <summary> 278 /// <summary>
279 /// 279 ///
280 /// </summary> 280 /// </summary>
281 // ----------------------------------------------------------------- 281 // -----------------------------------------------------------------
282 public bool DestroyStore(UUID storeID) 282 public bool DestroyStore(UUID storeID)
@@ -289,7 +289,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
289 289
290 // ----------------------------------------------------------------- 290 // -----------------------------------------------------------------
291 /// <summary> 291 /// <summary>
292 /// 292 ///
293 /// </summary> 293 /// </summary>
294 // ----------------------------------------------------------------- 294 // -----------------------------------------------------------------
295 public bool TestStore(UUID storeID) 295 public bool TestStore(UUID storeID)
@@ -302,7 +302,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
302 302
303 // ----------------------------------------------------------------- 303 // -----------------------------------------------------------------
304 /// <summary> 304 /// <summary>
305 /// 305 ///
306 /// </summary> 306 /// </summary>
307 // ----------------------------------------------------------------- 307 // -----------------------------------------------------------------
308 public JsonStoreNodeType GetNodeType(UUID storeID, string path) 308 public JsonStoreNodeType GetNodeType(UUID storeID, string path)
@@ -318,7 +318,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
318 return JsonStoreNodeType.Undefined; 318 return JsonStoreNodeType.Undefined;
319 } 319 }
320 } 320 }
321 321
322 try 322 try
323 { 323 {
324 lock (map) 324 lock (map)
@@ -334,7 +334,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
334 334
335 // ----------------------------------------------------------------- 335 // -----------------------------------------------------------------
336 /// <summary> 336 /// <summary>
337 /// 337 ///
338 /// </summary> 338 /// </summary>
339 // ----------------------------------------------------------------- 339 // -----------------------------------------------------------------
340 public JsonStoreValueType GetValueType(UUID storeID, string path) 340 public JsonStoreValueType GetValueType(UUID storeID, string path)
@@ -350,7 +350,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
350 return JsonStoreValueType.Undefined; 350 return JsonStoreValueType.Undefined;
351 } 351 }
352 } 352 }
353 353
354 try 354 try
355 { 355 {
356 lock (map) 356 lock (map)
@@ -366,7 +366,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
366 366
367 // ----------------------------------------------------------------- 367 // -----------------------------------------------------------------
368 /// <summary> 368 /// <summary>
369 /// 369 ///
370 /// </summary> 370 /// </summary>
371 // ----------------------------------------------------------------- 371 // -----------------------------------------------------------------
372 public bool SetValue(UUID storeID, string path, string value, bool useJson) 372 public bool SetValue(UUID storeID, string path, string value, bool useJson)
@@ -382,7 +382,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
382 return false; 382 return false;
383 } 383 }
384 } 384 }
385 385
386 try 386 try
387 { 387 {
388 lock (map) 388 lock (map)
@@ -393,7 +393,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
393 storeID,map.StringSpace,m_maxStringSpace); 393 storeID,map.StringSpace,m_maxStringSpace);
394 return false; 394 return false;
395 } 395 }
396 396
397 return map.SetValue(path,value,useJson); 397 return map.SetValue(path,value,useJson);
398 } 398 }
399 } 399 }
@@ -404,10 +404,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
404 404
405 return false; 405 return false;
406 } 406 }
407 407
408 // ----------------------------------------------------------------- 408 // -----------------------------------------------------------------
409 /// <summary> 409 /// <summary>
410 /// 410 ///
411 /// </summary> 411 /// </summary>
412 // ----------------------------------------------------------------- 412 // -----------------------------------------------------------------
413 public bool RemoveValue(UUID storeID, string path) 413 public bool RemoveValue(UUID storeID, string path)
@@ -423,7 +423,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
423 return false; 423 return false;
424 } 424 }
425 } 425 }
426 426
427 try 427 try
428 { 428 {
429 lock (map) 429 lock (map)
@@ -436,10 +436,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
436 436
437 return false; 437 return false;
438 } 438 }
439 439
440 // ----------------------------------------------------------------- 440 // -----------------------------------------------------------------
441 /// <summary> 441 /// <summary>
442 /// 442 ///
443 /// </summary> 443 /// </summary>
444 // ----------------------------------------------------------------- 444 // -----------------------------------------------------------------
445 public int GetArrayLength(UUID storeID, string path) 445 public int GetArrayLength(UUID storeID, string path)
@@ -464,19 +464,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
464 { 464 {
465 m_log.Error("[JsonStore]: unable to retrieve value", e); 465 m_log.Error("[JsonStore]: unable to retrieve value", e);
466 } 466 }
467 467
468 return -1; 468 return -1;
469 } 469 }
470 470
471 // ----------------------------------------------------------------- 471 // -----------------------------------------------------------------
472 /// <summary> 472 /// <summary>
473 /// 473 ///
474 /// </summary> 474 /// </summary>
475 // ----------------------------------------------------------------- 475 // -----------------------------------------------------------------
476 public bool GetValue(UUID storeID, string path, bool useJson, out string value) 476 public bool GetValue(UUID storeID, string path, bool useJson, out string value)
477 { 477 {
478 value = String.Empty; 478 value = String.Empty;
479 479
480 if (! m_enabled) return false; 480 if (! m_enabled) return false;
481 481
482 JsonStore map = null; 482 JsonStore map = null;
@@ -497,13 +497,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
497 { 497 {
498 m_log.Error("[JsonStore]: unable to retrieve value", e); 498 m_log.Error("[JsonStore]: unable to retrieve value", e);
499 } 499 }
500 500
501 return false; 501 return false;
502 } 502 }
503 503
504 // ----------------------------------------------------------------- 504 // -----------------------------------------------------------------
505 /// <summary> 505 /// <summary>
506 /// 506 ///
507 /// </summary> 507 /// </summary>
508 // ----------------------------------------------------------------- 508 // -----------------------------------------------------------------
509 public void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback) 509 public void TakeValue(UUID storeID, string path, bool useJson, TakeValueCallback cback)
@@ -536,13 +536,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
536 { 536 {
537 m_log.Error("[JsonStore] unable to retrieve value", e); 537 m_log.Error("[JsonStore] unable to retrieve value", e);
538 } 538 }
539 539
540 cback(String.Empty); 540 cback(String.Empty);
541 } 541 }
542 542
543 // ----------------------------------------------------------------- 543 // -----------------------------------------------------------------
544 /// <summary> 544 /// <summary>
545 /// 545 ///
546 /// </summary> 546 /// </summary>
547 // ----------------------------------------------------------------- 547 // -----------------------------------------------------------------
548 public void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback) 548 public void ReadValue(UUID storeID, string path, bool useJson, TakeValueCallback cback)
@@ -575,7 +575,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
575 { 575 {
576 m_log.Error("[JsonStore]: unable to retrieve value", e); 576 m_log.Error("[JsonStore]: unable to retrieve value", e);
577 } 577 }
578 578
579 cback(String.Empty); 579 cback(String.Empty);
580 } 580 }
581 581
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
index 01de21c..fe8d962 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
@@ -1,5 +1,5 @@
1/* 1/*
2 * Copyright (c) Contributors 2 * Copyright (c) Contributors
3 * See CONTRIBUTORS.TXT for a full list of copyright holders. 3 * See CONTRIBUTORS.TXT for a full list of copyright holders.
4 * 4 *
5 * Redistribution and use in source and binary forms, with or without 5 * Redistribution and use in source and binary forms, with or without
@@ -83,7 +83,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
83 // ----------------------------------------------------------------- 83 // -----------------------------------------------------------------
84 public void Initialise(IConfigSource config) 84 public void Initialise(IConfigSource config)
85 { 85 {
86 try 86 try
87 { 87 {
88 if ((m_config = config.Configs["JsonStore"]) == null) 88 if ((m_config = config.Configs["JsonStore"]) == null)
89 { 89 {
@@ -166,7 +166,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
166 166
167 // ----------------------------------------------------------------- 167 // -----------------------------------------------------------------
168 /// <summary> 168 /// <summary>
169 /// Called when all modules have been added for a region. This is 169 /// Called when all modules have been added for a region. This is
170 /// where we hook up events 170 /// where we hook up events
171 /// </summary> 171 /// </summary>
172 // ----------------------------------------------------------------- 172 // -----------------------------------------------------------------
@@ -251,7 +251,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
251#region ScriptInvocationInteface 251#region ScriptInvocationInteface
252 // ----------------------------------------------------------------- 252 // -----------------------------------------------------------------
253 /// <summary> 253 /// <summary>
254 /// 254 ///
255 /// </summary> 255 /// </summary>
256 // ----------------------------------------------------------------- 256 // -----------------------------------------------------------------
257 [ScriptInvocation] 257 [ScriptInvocation]
@@ -260,13 +260,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
260 UUID uuid = UUID.Zero; 260 UUID uuid = UUID.Zero;
261 if (! m_store.AttachObjectStore(hostID)) 261 if (! m_store.AttachObjectStore(hostID))
262 GenerateRuntimeError("Failed to create Json store"); 262 GenerateRuntimeError("Failed to create Json store");
263 263
264 return hostID; 264 return hostID;
265 } 265 }
266 266
267 // ----------------------------------------------------------------- 267 // -----------------------------------------------------------------
268 /// <summary> 268 /// <summary>
269 /// 269 ///
270 /// </summary> 270 /// </summary>
271 // ----------------------------------------------------------------- 271 // -----------------------------------------------------------------
272 [ScriptInvocation] 272 [ScriptInvocation]
@@ -275,12 +275,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
275 UUID uuid = UUID.Zero; 275 UUID uuid = UUID.Zero;
276 if (! m_store.CreateStore(value, ref uuid)) 276 if (! m_store.CreateStore(value, ref uuid))
277 GenerateRuntimeError("Failed to create Json store"); 277 GenerateRuntimeError("Failed to create Json store");
278 278
279 lock (m_scriptStores) 279 lock (m_scriptStores)
280 { 280 {
281 if (! m_scriptStores.ContainsKey(scriptID)) 281 if (! m_scriptStores.ContainsKey(scriptID))
282 m_scriptStores[scriptID] = new HashSet<UUID>(); 282 m_scriptStores[scriptID] = new HashSet<UUID>();
283 283
284 m_scriptStores[scriptID].Add(uuid); 284 m_scriptStores[scriptID].Add(uuid);
285 } 285 }
286 return uuid; 286 return uuid;
@@ -288,7 +288,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
288 288
289 // ----------------------------------------------------------------- 289 // -----------------------------------------------------------------
290 /// <summary> 290 /// <summary>
291 /// 291 ///
292 /// </summary> 292 /// </summary>
293 // ----------------------------------------------------------------- 293 // -----------------------------------------------------------------
294 [ScriptInvocation] 294 [ScriptInvocation]
@@ -305,7 +305,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
305 305
306 // ----------------------------------------------------------------- 306 // -----------------------------------------------------------------
307 /// <summary> 307 /// <summary>
308 /// 308 ///
309 /// </summary> 309 /// </summary>
310 // ----------------------------------------------------------------- 310 // -----------------------------------------------------------------
311 [ScriptInvocation] 311 [ScriptInvocation]
@@ -316,7 +316,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
316 316
317 // ----------------------------------------------------------------- 317 // -----------------------------------------------------------------
318 /// <summary> 318 /// <summary>
319 /// 319 ///
320 /// </summary> 320 /// </summary>
321 // ----------------------------------------------------------------- 321 // -----------------------------------------------------------------
322 [ScriptInvocation] 322 [ScriptInvocation]
@@ -330,7 +330,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
330 330
331 // ----------------------------------------------------------------- 331 // -----------------------------------------------------------------
332 /// <summary> 332 /// <summary>
333 /// 333 ///
334 /// </summary> 334 /// </summary>
335 // ----------------------------------------------------------------- 335 // -----------------------------------------------------------------
336 [ScriptInvocation] 336 [ScriptInvocation]
@@ -341,10 +341,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
341 o => DoJsonReadNotecard(reqID, hostID, scriptID, storeID, path, notecardIdentifier), null, "JsonStoreScriptModule.JsonReadNotecard"); 341 o => DoJsonReadNotecard(reqID, hostID, scriptID, storeID, path, notecardIdentifier), null, "JsonStoreScriptModule.JsonReadNotecard");
342 return reqID; 342 return reqID;
343 } 343 }
344 344
345 // ----------------------------------------------------------------- 345 // -----------------------------------------------------------------
346 /// <summary> 346 /// <summary>
347 /// 347 ///
348 /// </summary> 348 /// </summary>
349 // ----------------------------------------------------------------- 349 // -----------------------------------------------------------------
350 [ScriptInvocation] 350 [ScriptInvocation]
@@ -358,7 +358,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
358 358
359 // ----------------------------------------------------------------- 359 // -----------------------------------------------------------------
360 /// <summary> 360 /// <summary>
361 /// 361 ///
362 /// </summary> 362 /// </summary>
363 // ----------------------------------------------------------------- 363 // -----------------------------------------------------------------
364 [ScriptInvocation] 364 [ScriptInvocation]
@@ -366,7 +366,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
366 { 366 {
367 string ipath = ConvertList2Path(pathlist); 367 string ipath = ConvertList2Path(pathlist);
368 string opath; 368 string opath;
369 369
370 if (JsonStore.CanonicalPathExpression(ipath,out opath)) 370 if (JsonStore.CanonicalPathExpression(ipath,out opath))
371 return opath; 371 return opath;
372 372
@@ -375,10 +375,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
375 // the entire store 375 // the entire store
376 return "**INVALID**"; 376 return "**INVALID**";
377 } 377 }
378 378
379 // ----------------------------------------------------------------- 379 // -----------------------------------------------------------------
380 /// <summary> 380 /// <summary>
381 /// 381 ///
382 /// </summary> 382 /// </summary>
383 // ----------------------------------------------------------------- 383 // -----------------------------------------------------------------
384 [ScriptInvocation] 384 [ScriptInvocation]
@@ -389,7 +389,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
389 389
390 // ----------------------------------------------------------------- 390 // -----------------------------------------------------------------
391 /// <summary> 391 /// <summary>
392 /// 392 ///
393 /// </summary> 393 /// </summary>
394 // ----------------------------------------------------------------- 394 // -----------------------------------------------------------------
395 [ScriptInvocation] 395 [ScriptInvocation]
@@ -400,7 +400,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
400 400
401 // ----------------------------------------------------------------- 401 // -----------------------------------------------------------------
402 /// <summary> 402 /// <summary>
403 /// 403 ///
404 /// </summary> 404 /// </summary>
405 // ----------------------------------------------------------------- 405 // -----------------------------------------------------------------
406 [ScriptInvocation] 406 [ScriptInvocation]
@@ -417,7 +417,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
417 417
418 // ----------------------------------------------------------------- 418 // -----------------------------------------------------------------
419 /// <summary> 419 /// <summary>
420 /// 420 ///
421 /// </summary> 421 /// </summary>
422 // ----------------------------------------------------------------- 422 // -----------------------------------------------------------------
423 [ScriptInvocation] 423 [ScriptInvocation]
@@ -425,10 +425,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
425 { 425 {
426 return m_store.RemoveValue(storeID,path) ? 1 : 0; 426 return m_store.RemoveValue(storeID,path) ? 1 : 0;
427 } 427 }
428 428
429 // ----------------------------------------------------------------- 429 // -----------------------------------------------------------------
430 /// <summary> 430 /// <summary>
431 /// 431 ///
432 /// </summary> 432 /// </summary>
433 // ----------------------------------------------------------------- 433 // -----------------------------------------------------------------
434 [ScriptInvocation] 434 [ScriptInvocation]
@@ -436,10 +436,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
436 { 436 {
437 return m_store.GetArrayLength(storeID,path); 437 return m_store.GetArrayLength(storeID,path);
438 } 438 }
439 439
440 // ----------------------------------------------------------------- 440 // -----------------------------------------------------------------
441 /// <summary> 441 /// <summary>
442 /// 442 ///
443 /// </summary> 443 /// </summary>
444 // ----------------------------------------------------------------- 444 // -----------------------------------------------------------------
445 [ScriptInvocation] 445 [ScriptInvocation]
@@ -457,10 +457,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
457 m_store.GetValue(storeID,path,true, out value); 457 m_store.GetValue(storeID,path,true, out value);
458 return value; 458 return value;
459 } 459 }
460 460
461 // ----------------------------------------------------------------- 461 // -----------------------------------------------------------------
462 /// <summary> 462 /// <summary>
463 /// 463 ///
464 /// </summary> 464 /// </summary>
465 // ----------------------------------------------------------------- 465 // -----------------------------------------------------------------
466 [ScriptInvocation] 466 [ScriptInvocation]
@@ -480,10 +480,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
480 o => DoJsonTakeValue(scriptID,reqID,storeID,path,true), null, "JsonStoreScriptModule.DoJsonTakeValueJson"); 480 o => DoJsonTakeValue(scriptID,reqID,storeID,path,true), null, "JsonStoreScriptModule.DoJsonTakeValueJson");
481 return reqID; 481 return reqID;
482 } 482 }
483 483
484 // ----------------------------------------------------------------- 484 // -----------------------------------------------------------------
485 /// <summary> 485 /// <summary>
486 /// 486 ///
487 /// </summary> 487 /// </summary>
488 // ----------------------------------------------------------------- 488 // -----------------------------------------------------------------
489 [ScriptInvocation] 489 [ScriptInvocation]
@@ -503,12 +503,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
503 o => DoJsonReadValue(scriptID,reqID,storeID,path,true), null, "JsonStoreScriptModule.DoJsonReadValueJson"); 503 o => DoJsonReadValue(scriptID,reqID,storeID,path,true), null, "JsonStoreScriptModule.DoJsonReadValueJson");
504 return reqID; 504 return reqID;
505 } 505 }
506 506
507#endregion 507#endregion
508 508
509 // ----------------------------------------------------------------- 509 // -----------------------------------------------------------------
510 /// <summary> 510 /// <summary>
511 /// 511 ///
512 /// </summary> 512 /// </summary>
513 // ----------------------------------------------------------------- 513 // -----------------------------------------------------------------
514 protected void GenerateRuntimeError(string msg) 514 protected void GenerateRuntimeError(string msg)
@@ -516,10 +516,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
516 m_log.InfoFormat("[JsonStore] runtime error: {0}",msg); 516 m_log.InfoFormat("[JsonStore] runtime error: {0}",msg);
517 throw new Exception("JsonStore Runtime Error: " + msg); 517 throw new Exception("JsonStore Runtime Error: " + msg);
518 } 518 }
519 519
520 // ----------------------------------------------------------------- 520 // -----------------------------------------------------------------
521 /// <summary> 521 /// <summary>
522 /// 522 ///
523 /// </summary> 523 /// </summary>
524 // ----------------------------------------------------------------- 524 // -----------------------------------------------------------------
525 protected void DispatchValue(UUID scriptID, UUID reqID, string value) 525 protected void DispatchValue(UUID scriptID, UUID reqID, string value)
@@ -529,7 +529,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
529 529
530 // ----------------------------------------------------------------- 530 // -----------------------------------------------------------------
531 /// <summary> 531 /// <summary>
532 /// 532 ///
533 /// </summary> 533 /// </summary>
534 // ----------------------------------------------------------------- 534 // -----------------------------------------------------------------
535 private void DoJsonTakeValue(UUID scriptID, UUID reqID, UUID storeID, string path, bool useJson) 535 private void DoJsonTakeValue(UUID scriptID, UUID reqID, UUID storeID, string path, bool useJson)
@@ -543,14 +543,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
543 { 543 {
544 m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString()); 544 m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString());
545 } 545 }
546 546
547 DispatchValue(scriptID,reqID,String.Empty); 547 DispatchValue(scriptID,reqID,String.Empty);
548 } 548 }
549 549
550 550
551 // ----------------------------------------------------------------- 551 // -----------------------------------------------------------------
552 /// <summary> 552 /// <summary>
553 /// 553 ///
554 /// </summary> 554 /// </summary>
555 // ----------------------------------------------------------------- 555 // -----------------------------------------------------------------
556 private void DoJsonReadValue(UUID scriptID, UUID reqID, UUID storeID, string path, bool useJson) 556 private void DoJsonReadValue(UUID scriptID, UUID reqID, UUID storeID, string path, bool useJson)
@@ -564,13 +564,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
564 { 564 {
565 m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString()); 565 m_log.InfoFormat("[JsonStoreScripts]: unable to retrieve value; {0}",e.ToString());
566 } 566 }
567 567
568 DispatchValue(scriptID,reqID,String.Empty); 568 DispatchValue(scriptID,reqID,String.Empty);
569 } 569 }
570 570
571 // ----------------------------------------------------------------- 571 // -----------------------------------------------------------------
572 /// <summary> 572 /// <summary>
573 /// 573 ///
574 /// </summary> 574 /// </summary>
575 // ----------------------------------------------------------------- 575 // -----------------------------------------------------------------
576 private void DoJsonReadNotecard( 576 private void DoJsonReadNotecard(
@@ -580,7 +580,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
580 580
581 if (!UUID.TryParse(notecardIdentifier, out assetID)) 581 if (!UUID.TryParse(notecardIdentifier, out assetID))
582 { 582 {
583 SceneObjectPart part = m_scene.GetSceneObjectPart(hostID); 583 SceneObjectPart part = m_scene.GetSceneObjectPart(hostID);
584 assetID = ScriptUtils.GetAssetIdFromItemName(part, notecardIdentifier, (int)AssetType.Notecard); 584 assetID = ScriptUtils.GetAssetIdFromItemName(part, notecardIdentifier, (int)AssetType.Notecard);
585 } 585 }
586 586
@@ -590,10 +590,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
590 590
591 if (a.Type != (sbyte)AssetType.Notecard) 591 if (a.Type != (sbyte)AssetType.Notecard)
592 GenerateRuntimeError(String.Format("Invalid notecard asset {0}", assetID)); 592 GenerateRuntimeError(String.Format("Invalid notecard asset {0}", assetID));
593 593
594 m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID); 594 m_log.DebugFormat("[JsonStoreScripts]: read notecard in context {0}",storeID);
595 595
596 try 596 try
597 { 597 {
598 string jsondata = SLUtil.ParseNotecardToString(a.Data); 598 string jsondata = SLUtil.ParseNotecardToString(a.Data);
599 int result = m_store.SetValue(storeID, path, jsondata,true) ? 1 : 0; 599 int result = m_store.SetValue(storeID, path, jsondata,true) ? 1 : 0;
@@ -612,10 +612,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
612 GenerateRuntimeError(String.Format("Json parsing failed for {0}", assetID)); 612 GenerateRuntimeError(String.Format("Json parsing failed for {0}", assetID));
613 m_comms.DispatchReply(scriptID, 0, "", reqID.ToString()); 613 m_comms.DispatchReply(scriptID, 0, "", reqID.ToString());
614 } 614 }
615 615
616 // ----------------------------------------------------------------- 616 // -----------------------------------------------------------------
617 /// <summary> 617 /// <summary>
618 /// 618 ///
619 /// </summary> 619 /// </summary>
620 // ----------------------------------------------------------------- 620 // -----------------------------------------------------------------
621 private void DoJsonWriteNotecard(UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, string name) 621 private void DoJsonWriteNotecard(UUID reqID, UUID hostID, UUID scriptID, UUID storeID, string path, string name)
@@ -626,9 +626,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
626 m_comms.DispatchReply(scriptID,0,UUID.Zero.ToString(),reqID.ToString()); 626 m_comms.DispatchReply(scriptID,0,UUID.Zero.ToString(),reqID.ToString());
627 return; 627 return;
628 } 628 }
629 629
630 SceneObjectPart host = m_scene.GetSceneObjectPart(hostID); 630 SceneObjectPart host = m_scene.GetSceneObjectPart(hostID);
631 631
632 // Create new asset 632 // Create new asset
633 UUID assetID = UUID.Random(); 633 UUID assetID = UUID.Random();
634 AssetBase asset = new AssetBase(assetID, name, (sbyte)AssetType.Notecard, host.OwnerID.ToString()); 634 AssetBase asset = new AssetBase(assetID, name, (sbyte)AssetType.Notecard, host.OwnerID.ToString());
@@ -665,7 +665,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
665 taskItem.AssetID = asset.FullID; 665 taskItem.AssetID = asset.FullID;
666 666
667 host.Inventory.AddInventoryItem(taskItem, false); 667 host.Inventory.AddInventoryItem(taskItem, false);
668 668 host.ParentGroup.InvalidateEffectivePerms();
669 m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString()); 669 m_comms.DispatchReply(scriptID,1,assetID.ToString(),reqID.ToString());
670 } 670 }
671 671
@@ -681,7 +681,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
681 for (int i = 0; i < pathlist.Length; i++) 681 for (int i = 0; i < pathlist.Length; i++)
682 { 682 {
683 string token = ""; 683 string token = "";
684 684
685 if (pathlist[i] is string) 685 if (pathlist[i] is string)
686 { 686 {
687 token = pathlist[i].ToString(); 687 token = pathlist[i].ToString();
@@ -699,16 +699,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
699 { 699 {
700 token = "." + pathlist[i].ToString() + "."; 700 token = "." + pathlist[i].ToString() + ".";
701 } 701 }
702 702
703 path += token + "."; 703 path += token + ".";
704 } 704 }
705 705
706 return path; 706 return path;
707 } 707 }
708 708
709 // ----------------------------------------------------------------- 709 // -----------------------------------------------------------------
710 /// <summary> 710 /// <summary>
711 /// 711 ///
712 /// </summary> 712 /// </summary>
713 // ----------------------------------------------------------------- 713 // -----------------------------------------------------------------
714 private void DoJsonRezObject(UUID hostID, UUID scriptID, UUID reqID, string name, Vector3 pos, Vector3 vel, Quaternion rot, string param) 714 private void DoJsonRezObject(UUID hostID, UUID scriptID, UUID reqID, string name, Vector3 pos, Vector3 vel, Quaternion rot, string param)
@@ -728,6 +728,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
728 728
729 // hpos = host.RootPart.GetWorldPosition() 729 // hpos = host.RootPart.GetWorldPosition()
730 // float dist = (float)llVecDist(hpos, pos); 730 // float dist = (float)llVecDist(hpos, pos);
731 // if (dist > m_ScriptDistanceFactor * 10.0f)
732 // return;
731 733
732 TaskInventoryItem item = host.RootPart.Inventory.GetInventoryItem(name); 734 TaskInventoryItem item = host.RootPart.Inventory.GetInventoryItem(name);
733 if (item == null) 735 if (item == null)
@@ -744,8 +746,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
744 746
745 List<SceneObjectGroup> objlist; 747 List<SceneObjectGroup> objlist;
746 List<Vector3> veclist; 748 List<Vector3> veclist;
747 749
748 bool success = host.RootPart.Inventory.GetRezReadySceneObjects(item, out objlist, out veclist); 750 Vector3 bbox = new Vector3();
751 float offsetHeight;
752 bool success = host.RootPart.Inventory.GetRezReadySceneObjects(item, out objlist, out veclist, out bbox, out offsetHeight);
749 if (! success) 753 if (! success)
750 { 754 {
751 GenerateRuntimeError("Failed to create object"); 755 GenerateRuntimeError("Failed to create object");
@@ -779,7 +783,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
779 group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint; 783 group.RootPart.Shape.LastAttachPoint = (byte)group.AttachmentPoint;
780 } 784 }
781 785
782 group.FromPartID = host.RootPart.UUID; 786 group.RezzerID = host.RootPart.UUID;
783 m_scene.AddNewSceneObject(group, true, curpos, rot, vel); 787 m_scene.AddNewSceneObject(group, true, curpos, rot, vel);
784 788
785 UUID storeID = group.UUID; 789 UUID storeID = group.UUID;
@@ -797,7 +801,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
797 801
798 group.ScheduleGroupForFullUpdate(); 802 group.ScheduleGroupForFullUpdate();
799 803
800 // send the reply back to the host object, use the integer param to indicate the number 804 // send the reply back to the host object, use the integer param to indicate the number
801 // of remaining objects 805 // of remaining objects
802 m_comms.DispatchReply(scriptID, objlist.Count-i-1, group.RootPart.UUID.ToString(), reqID.ToString()); 806 m_comms.DispatchReply(scriptID, objlist.Count-i-1, group.RootPart.UUID.ToString(), reqID.ToString());
803 } 807 }
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
index 99a7076..77ee785 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/Tests/JsonStoreScriptModuleTests.cs
@@ -180,7 +180,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
180 TestHelpers.InMethod(); 180 TestHelpers.InMethod();
181// TestHelpers.EnableLogging(); 181// TestHelpers.EnableLogging();
182 182
183 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Two' } }"); 183 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Two' } }");
184 184
185 { 185 {
186 string value = (string)InvokeOp("JsonGetValue", storeId, "Hello.World"); 186 string value = (string)InvokeOp("JsonGetValue", storeId, "Hello.World");
@@ -213,7 +213,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
213 TestHelpers.InMethod(); 213 TestHelpers.InMethod();
214// TestHelpers.EnableLogging(); 214// TestHelpers.EnableLogging();
215 215
216 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Two' } }"); 216 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Two' } }");
217 217
218 { 218 {
219 string value = (string)InvokeOp("JsonGetJson", storeId, "Hello.World"); 219 string value = (string)InvokeOp("JsonGetJson", storeId, "Hello.World");
@@ -246,11 +246,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
246// TestHelpers.InMethod(); 246// TestHelpers.InMethod();
247//// TestHelpers.EnableLogging(); 247//// TestHelpers.EnableLogging();
248// 248//
249// UUID storeId 249// UUID storeId
250// = (UUID)m_smcm.InvokeOperation( 250// = (UUID)m_smcm.InvokeOperation(
251// UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" }); 251// UUID.Zero, UUID.Zero, "JsonCreateStore", new object[] { "{ 'Hello' : 'World' }" });
252// 252//
253// string value 253// string value
254// = (string)m_smcm.InvokeOperation( 254// = (string)m_smcm.InvokeOperation(
255// UUID.Zero, UUID.Zero, "JsonTakeValue", new object[] { storeId, "Hello" }); 255// UUID.Zero, UUID.Zero, "JsonTakeValue", new object[] { storeId, "Hello" });
256// 256//
@@ -271,7 +271,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
271 271
272 // Test remove of node in object pointing to a string 272 // Test remove of node in object pointing to a string
273 { 273 {
274 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }"); 274 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }");
275 275
276 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello"); 276 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello");
277 Assert.That(returnValue, Is.EqualTo(1)); 277 Assert.That(returnValue, Is.EqualTo(1));
@@ -285,7 +285,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
285 285
286 // Test remove of node in object pointing to another object 286 // Test remove of node in object pointing to another object
287 { 287 {
288 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Wally' } }"); 288 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'Wally' } }");
289 289
290 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello"); 290 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello");
291 Assert.That(returnValue, Is.EqualTo(1)); 291 Assert.That(returnValue, Is.EqualTo(1));
@@ -299,7 +299,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
299 299
300 // Test remove of node in an array 300 // Test remove of node in an array
301 { 301 {
302 UUID storeId 302 UUID storeId
303 = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : [ 'value1', 'value2' ] }"); 303 = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : [ 'value1', 'value2' ] }");
304 304
305 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello[0]"); 305 int returnValue = (int)InvokeOp( "JsonRemoveValue", storeId, "Hello[0]");
@@ -320,7 +320,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
320 320
321 // Test remove of non-existing value 321 // Test remove of non-existing value
322 { 322 {
323 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }"); 323 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : 'World' }");
324 324
325 int fakeValueRemove = (int)InvokeOp("JsonRemoveValue", storeId, "Cheese"); 325 int fakeValueRemove = (int)InvokeOp("JsonRemoveValue", storeId, "Cheese");
326 Assert.That(fakeValueRemove, Is.EqualTo(0)); 326 Assert.That(fakeValueRemove, Is.EqualTo(0));
@@ -340,7 +340,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
340// TestHelpers.InMethod(); 340// TestHelpers.InMethod();
341//// TestHelpers.EnableLogging(); 341//// TestHelpers.EnableLogging();
342// 342//
343// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }"); 343// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }");
344// 344//
345// { 345// {
346// int result = (int)InvokeOp("JsonTestPath", storeId, "Hello.World"); 346// int result = (int)InvokeOp("JsonTestPath", storeId, "Hello.World");
@@ -372,7 +372,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
372// TestHelpers.InMethod(); 372// TestHelpers.InMethod();
373//// TestHelpers.EnableLogging(); 373//// TestHelpers.EnableLogging();
374// 374//
375// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }"); 375// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : 'One' } }");
376// 376//
377// { 377// {
378// int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello.World"); 378// int result = (int)InvokeOp("JsonTestPathJson", storeId, "Hello.World");
@@ -437,7 +437,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
437 TestHelpers.InMethod(); 437 TestHelpers.InMethod();
438// TestHelpers.EnableLogging(); 438// TestHelpers.EnableLogging();
439 439
440 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }"); 440 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello' : { 'World' : [ 'one', 2 ] } }");
441 441
442 { 442 {
443 int result = (int)InvokeOp("JsonGetNodeType", storeId, "."); 443 int result = (int)InvokeOp("JsonGetNodeType", storeId, ".");
@@ -509,7 +509,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
509// TestHelpers.EnableLogging(); 509// TestHelpers.EnableLogging();
510 510
511 { 511 {
512 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 512 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
513 513
514 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun", "Times"); 514 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun", "Times");
515 Assert.That(result, Is.EqualTo(1)); 515 Assert.That(result, Is.EqualTo(1));
@@ -520,7 +520,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
520 520
521 // Test setting a key containing periods with delineation 521 // Test setting a key containing periods with delineation
522 { 522 {
523 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 523 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
524 524
525 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times"); 525 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun.Circus}", "Times");
526 Assert.That(result, Is.EqualTo(1)); 526 Assert.That(result, Is.EqualTo(1));
@@ -533,7 +533,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
533 533
534 // Test setting a key containing unbalanced ] without delineation. Expecting failure 534 // Test setting a key containing unbalanced ] without delineation. Expecting failure
535 { 535 {
536 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 536 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
537 537
538 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun]Circus", "Times"); 538 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun]Circus", "Times");
539 Assert.That(result, Is.EqualTo(0)); 539 Assert.That(result, Is.EqualTo(0));
@@ -544,7 +544,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
544 544
545 // Test setting a key containing unbalanced [ without delineation. Expecting failure 545 // Test setting a key containing unbalanced [ without delineation. Expecting failure
546 { 546 {
547 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 547 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
548 548
549 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun[Circus", "Times"); 549 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun[Circus", "Times");
550 Assert.That(result, Is.EqualTo(0)); 550 Assert.That(result, Is.EqualTo(0));
@@ -555,7 +555,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
555 555
556 // Test setting a key containing unbalanced [] without delineation. Expecting failure 556 // Test setting a key containing unbalanced [] without delineation. Expecting failure
557 { 557 {
558 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 558 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
559 559
560 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun[]Circus", "Times"); 560 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun[]Circus", "Times");
561 Assert.That(result, Is.EqualTo(0)); 561 Assert.That(result, Is.EqualTo(0));
@@ -566,7 +566,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
566 566
567 // Test setting a key containing unbalanced ] with delineation 567 // Test setting a key containing unbalanced ] with delineation
568 { 568 {
569 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 569 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
570 570
571 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun]Circus}", "Times"); 571 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun]Circus}", "Times");
572 Assert.That(result, Is.EqualTo(1)); 572 Assert.That(result, Is.EqualTo(1));
@@ -577,7 +577,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
577 577
578 // Test setting a key containing unbalanced [ with delineation 578 // Test setting a key containing unbalanced [ with delineation
579 { 579 {
580 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 580 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
581 581
582 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[Circus}", "Times"); 582 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[Circus}", "Times");
583 Assert.That(result, Is.EqualTo(1)); 583 Assert.That(result, Is.EqualTo(1));
@@ -588,7 +588,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
588 588
589 // Test setting a key containing empty balanced [] with delineation 589 // Test setting a key containing empty balanced [] with delineation
590 { 590 {
591 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 591 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
592 592
593 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[]Circus}", "Times"); 593 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[]Circus}", "Times");
594 Assert.That(result, Is.EqualTo(1)); 594 Assert.That(result, Is.EqualTo(1));
@@ -600,7 +600,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
600// // Commented out as this currently unexpectedly fails. 600// // Commented out as this currently unexpectedly fails.
601// // Test setting a key containing brackets around an integer with delineation 601// // Test setting a key containing brackets around an integer with delineation
602// { 602// {
603// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 603// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
604// 604//
605// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[0]Circus}", "Times"); 605// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun[0]Circus}", "Times");
606// Assert.That(result, Is.EqualTo(1)); 606// Assert.That(result, Is.EqualTo(1));
@@ -610,10 +610,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
610// } 610// }
611 611
612 // *** Test {} *** 612 // *** Test {} ***
613 613
614 // Test setting a key containing unbalanced } without delineation. Expecting failure (?) 614 // Test setting a key containing unbalanced } without delineation. Expecting failure (?)
615 { 615 {
616 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 616 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
617 617
618 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun}Circus", "Times"); 618 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun}Circus", "Times");
619 Assert.That(result, Is.EqualTo(0)); 619 Assert.That(result, Is.EqualTo(0));
@@ -624,7 +624,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
624 624
625 // Test setting a key containing unbalanced { without delineation. Expecting failure (?) 625 // Test setting a key containing unbalanced { without delineation. Expecting failure (?)
626 { 626 {
627 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 627 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
628 628
629 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun{Circus", "Times"); 629 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun{Circus", "Times");
630 Assert.That(result, Is.EqualTo(0)); 630 Assert.That(result, Is.EqualTo(0));
@@ -636,7 +636,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
636// // Commented out as this currently unexpectedly fails. 636// // Commented out as this currently unexpectedly fails.
637// // Test setting a key containing unbalanced } 637// // Test setting a key containing unbalanced }
638// { 638// {
639// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 639// UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
640// 640//
641// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun}Circus}", "Times"); 641// int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun}Circus}", "Times");
642// Assert.That(result, Is.EqualTo(0)); 642// Assert.That(result, Is.EqualTo(0));
@@ -644,7 +644,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
644 644
645 // Test setting a key containing unbalanced { with delineation 645 // Test setting a key containing unbalanced { with delineation
646 { 646 {
647 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 647 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
648 648
649 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun{Circus}", "Times"); 649 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun{Circus}", "Times");
650 Assert.That(result, Is.EqualTo(1)); 650 Assert.That(result, Is.EqualTo(1));
@@ -655,7 +655,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
655 655
656 // Test setting a key containing balanced {} with delineation. This should fail. 656 // Test setting a key containing balanced {} with delineation. This should fail.
657 { 657 {
658 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 658 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
659 659
660 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun{Filled}Circus}", "Times"); 660 int result = (int)InvokeOp("JsonSetValue", storeId, "{Fun{Filled}Circus}", "Times");
661 Assert.That(result, Is.EqualTo(0)); 661 Assert.That(result, Is.EqualTo(0));
@@ -666,7 +666,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
666 666
667 // Test setting to location that does not exist. This should fail. 667 // Test setting to location that does not exist. This should fail.
668 { 668 {
669 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}"); 669 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{}");
670 670
671 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun.Circus", "Times"); 671 int result = (int)InvokeOp("JsonSetValue", storeId, "Fun.Circus", "Times");
672 Assert.That(result, Is.EqualTo(0)); 672 Assert.That(result, Is.EqualTo(0));
@@ -691,7 +691,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
691 691
692 // Single quoted token case 692 // Single quoted token case
693 { 693 {
694 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 694 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
695 695
696 int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "'Times'"); 696 int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "'Times'");
697 Assert.That(result, Is.EqualTo(1)); 697 Assert.That(result, Is.EqualTo(1));
@@ -702,7 +702,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
702 702
703 // Sub-tree case 703 // Sub-tree case
704 { 704 {
705 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 705 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
706 706
707 int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "{ 'Filled' : 'Times' }"); 707 int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "{ 'Filled' : 'Times' }");
708 Assert.That(result, Is.EqualTo(1)); 708 Assert.That(result, Is.EqualTo(1));
@@ -713,7 +713,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
713 713
714 // If setting single strings in JsonSetValueJson, these must be single quoted tokens, not bare strings. 714 // If setting single strings in JsonSetValueJson, these must be single quoted tokens, not bare strings.
715 { 715 {
716 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 716 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
717 717
718 int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "Times"); 718 int result = (int)InvokeOp("JsonSetJson", storeId, "Fun", "Times");
719 Assert.That(result, Is.EqualTo(0)); 719 Assert.That(result, Is.EqualTo(0));
@@ -724,7 +724,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
724 724
725 // Test setting to location that does not exist. This should fail. 725 // Test setting to location that does not exist. This should fail.
726 { 726 {
727 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }"); 727 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ }");
728 728
729 int result = (int)InvokeOp("JsonSetJson", storeId, "Fun.Circus", "'Times'"); 729 int result = (int)InvokeOp("JsonSetJson", storeId, "Fun.Circus", "'Times'");
730 Assert.That(result, Is.EqualTo(0)); 730 Assert.That(result, Is.EqualTo(0));
@@ -757,7 +757,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
757 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1)); 757 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1));
758 m_scene.AddSceneObject(so); 758 m_scene.AddSceneObject(so);
759 759
760 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); 760 UUID storeId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }");
761 761
762 { 762 {
763 string notecardName = "nc1"; 763 string notecardName = "nc1";
@@ -820,14 +820,14 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
820 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1)); 820 SceneObjectGroup so = SceneHelpers.CreateSceneObject(1, TestHelpers.ParseTail(0x1));
821 m_scene.AddSceneObject(so); 821 m_scene.AddSceneObject(so);
822 822
823 UUID creatingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }"); 823 UUID creatingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'Hello':'World' }");
824 824
825 // Write notecard 825 // Write notecard
826 InvokeOpOnHost("JsonWriteNotecard", so.UUID, creatingStoreId, "", notecardName); 826 InvokeOpOnHost("JsonWriteNotecard", so.UUID, creatingStoreId, "", notecardName);
827 827
828 { 828 {
829 // Read notecard 829 // Read notecard
830 UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{}"); 830 UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{}");
831 UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "", notecardName); 831 UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "", notecardName);
832 Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); 832 Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
833 833
@@ -837,10 +837,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
837 837
838 { 838 {
839 // Read notecard to new single component path 839 // Read notecard to new single component path
840 UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{}"); 840 UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{}");
841 UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "make", notecardName); 841 UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "make", notecardName);
842 Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); 842 Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
843 843
844 string value = (string)InvokeOp("JsonGetValue", receivingStoreId, "Hello"); 844 string value = (string)InvokeOp("JsonGetValue", receivingStoreId, "Hello");
845 Assert.That(value, Is.EqualTo("")); 845 Assert.That(value, Is.EqualTo(""));
846 846
@@ -850,7 +850,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
850 850
851 { 851 {
852 // Read notecard to new multi-component path. This should not work. 852 // Read notecard to new multi-component path. This should not work.
853 UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{}"); 853 UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{}");
854 UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "make.it", notecardName); 854 UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "make.it", notecardName);
855 Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); 855 Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
856 856
@@ -863,7 +863,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
863 863
864 { 864 {
865 // Read notecard to existing multi-component path. This should work 865 // Read notecard to existing multi-component path. This should work
866 UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'make' : { 'it' : 'so' } }"); 866 UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'make' : { 'it' : 'so' } }");
867 UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "make.it", notecardName); 867 UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "make.it", notecardName);
868 Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); 868 Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
869 869
@@ -876,7 +876,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore.Tests
876 876
877 { 877 {
878 // Read notecard to invalid path. This should not work. 878 // Read notecard to invalid path. This should not work.
879 UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'make' : { 'it' : 'so' } }"); 879 UUID receivingStoreId = (UUID)InvokeOp("JsonCreateStore", "{ 'make' : { 'it' : 'so' } }");
880 UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "/", notecardName); 880 UUID readNotecardRequestId = (UUID)InvokeOpOnHost("JsonReadNotecard", so.UUID, receivingStoreId, "/", notecardName);
881 Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero)); 881 Assert.That(readNotecardRequestId, Is.Not.EqualTo(UUID.Zero));
882 882
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs
index 1993948..2368a23 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IAvatarAttachment.cs
@@ -33,7 +33,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
33 /// Describes where on the avatar the attachment is located 33 /// Describes where on the avatar the attachment is located
34 /// </value> 34 /// </value>
35 int Location { get ; } 35 int Location { get ; }
36 36
37 //// <value> 37 //// <value>
38 /// Accessor to the rez'ed asset, representing the attachment 38 /// Accessor to the rez'ed asset, representing the attachment
39 /// </value> 39 /// </value>
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs
index a8e545c..d61f52a 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IInventoryItem.cs
@@ -30,7 +30,7 @@ using OpenMetaverse;
30using OpenMetaverse.Assets; 30using OpenMetaverse.Assets;
31 31
32namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 32namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
33{ 33{
34 /// <summary> 34 /// <summary>
35 /// This implements the methods needed to operate on individual inventory items. 35 /// This implements the methods needed to operate on individual inventory items.
36 /// </summary> 36 /// </summary>
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs
index e189489..dc2edd9 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Interfaces/IObject.cs
@@ -60,19 +60,19 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
60 /// <summary> 60 /// <summary>
61 /// Returns whether or not this object is still in the world. 61 /// Returns whether or not this object is still in the world.
62 /// Eg, if you store an IObject reference, however the object 62 /// Eg, if you store an IObject reference, however the object
63 /// is deleted before you use it, it will throw a NullReference 63 /// is deleted before you use it, it will throw a NullReference
64 /// exception. 'Exists' allows you to check the object is still 64 /// exception. 'Exists' allows you to check the object is still
65 /// in play before utilizing it. 65 /// in play before utilizing it.
66 /// </summary> 66 /// </summary>
67 /// <example> 67 /// <example>
68 /// IObject deleteMe = World.Objects[0]; 68 /// IObject deleteMe = World.Objects[0];
69 /// 69 ///
70 /// if (deleteMe.Exists) { 70 /// if (deleteMe.Exists) {
71 /// deleteMe.Say("Hello, I still exist!"); 71 /// deleteMe.Say("Hello, I still exist!");
72 /// } 72 /// }
73 /// 73 ///
74 /// World.Objects.Remove(deleteMe); 74 /// World.Objects.Remove(deleteMe);
75 /// 75 ///
76 /// if (!deleteMe.Exists) { 76 /// if (!deleteMe.Exists) {
77 /// Host.Console.Info("I was deleted"); 77 /// Host.Console.Info("I was deleted");
78 /// } 78 /// }
@@ -81,7 +81,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
81 /// Objects should be near-guarunteed to exist for any event which 81 /// Objects should be near-guarunteed to exist for any event which
82 /// passes them as an argument. Storing an object for a longer period 82 /// passes them as an argument. Storing an object for a longer period
83 /// of time however will limit their reliability. 83 /// of time however will limit their reliability.
84 /// 84 ///
85 /// It is a good practice to use Try/Catch blocks handling for 85 /// It is a good practice to use Try/Catch blocks handling for
86 /// NullReferenceException, when accessing remote objects. 86 /// NullReferenceException, when accessing remote objects.
87 /// </remarks> 87 /// </remarks>
@@ -118,8 +118,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
118 IObject[] Children { get; } 118 IObject[] Children { get; }
119 119
120 /// <summary> 120 /// <summary>
121 /// Returns a list of materials attached to this object. Each may contain unique texture 121 /// Returns a list of materials attached to this object. Each may contain unique texture
122 /// and other visual information. For primitive based objects, this correlates with 122 /// and other visual information. For primitive based objects, this correlates with
123 /// Object Faces. For mesh based objects, this correlates with Materials. 123 /// Object Faces. For mesh based objects, this correlates with Materials.
124 /// </summary> 124 /// </summary>
125 IObjectMaterial[] Materials { get; } 125 IObjectMaterial[] Materials { get; }
@@ -152,7 +152,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
152 String TouchText { get; set; } 152 String TouchText { get; set; }
153 153
154 /// <summary> 154 /// <summary>
155 /// Text to be associated with this object, in the 155 /// Text to be associated with this object, in the
156 /// Second Life(r) viewer, this is shown above the 156 /// Second Life(r) viewer, this is shown above the
157 /// object. 157 /// object.
158 /// </summary> 158 /// </summary>
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs
index bf85cbc..bec8f38 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/InventoryItem.cs
@@ -40,7 +40,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
40 { 40 {
41 TaskInventoryItem m_privateItem; 41 TaskInventoryItem m_privateItem;
42 Scene m_rootScene; 42 Scene m_rootScene;
43 43
44 public InventoryItem(Scene rootScene, TaskInventoryItem internalItem) 44 public InventoryItem(Scene rootScene, TaskInventoryItem internalItem)
45 { 45 {
46 m_rootScene = rootScene; 46 m_rootScene = rootScene;
@@ -77,10 +77,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
77 throw new ApplicationException("[MRM] There is no legal conversion from IInventoryItem to InventoryItem"); 77 throw new ApplicationException("[MRM] There is no legal conversion from IInventoryItem to InventoryItem");
78 } 78 }
79 } 79 }
80 80
81 public int Type { get { return m_privateItem.Type; } } 81 public int Type { get { return m_privateItem.Type; } }
82 public UUID AssetID { get { return m_privateItem.AssetID; } } 82 public UUID AssetID { get { return m_privateItem.AssetID; } }
83 83
84 // This method exposes OpenSim/OpenMetaverse internals and needs to be replaced with a IAsset specific to MRM. 84 // This method exposes OpenSim/OpenMetaverse internals and needs to be replaced with a IAsset specific to MRM.
85 public T RetrieveAsset<T>() where T : OpenMetaverse.Assets.Asset, new() 85 public T RetrieveAsset<T>() where T : OpenMetaverse.Assets.Asset, new()
86 { 86 {
@@ -89,7 +89,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
89 89
90 if ((sbyte)result.AssetType != a.Type) 90 if ((sbyte)result.AssetType != a.Type)
91 throw new ApplicationException("[MRM] The supplied asset class does not match the found asset"); 91 throw new ApplicationException("[MRM] The supplied asset class does not match the found asset");
92 92
93 result.AssetData = a.Data; 93 result.AssetData = a.Data;
94 result.Decode(); 94 result.Decode();
95 return result; 95 return result;
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs
index 73fe8b8..5861486 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MicroScheduler.cs
@@ -35,7 +35,7 @@ using OpenSim.Region.OptionalModules.Scripting.Minimodule.Interfaces;
35 35
36namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 36namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
37{ 37{
38 public class MicroScheduler : System.MarshalByRefObject, IMicrothreader 38 public class MicroScheduler : System.MarshalByRefObject, IMicrothreader
39 { 39 {
40 private readonly List<IEnumerator> m_threads = new List<IEnumerator>(); 40 private readonly List<IEnumerator> m_threads = new List<IEnumerator>();
41 41
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
index 47b9c09..5513cd5 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
@@ -165,7 +165,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
165 get { return GetSOP().Description; } 165 get { return GetSOP().Description; }
166 set 166 set
167 { 167 {
168 if (CanEdit()) 168 if (CanEdit())
169 GetSOP().Description = value; 169 GetSOP().Description = value;
170 } 170 }
171 } 171 }
@@ -192,7 +192,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
192 rets = new IObject[total]; 192 rets = new IObject[total];
193 193
194 int i = 0; 194 int i = 0;
195 195
196 foreach (SceneObjectPart part in my.ParentGroup.Parts) 196 foreach (SceneObjectPart part in my.ParentGroup.Parts)
197 { 197 {
198 rets[i++] = new SOPObject(m_rootScene, part.LocalId, m_security); 198 rets[i++] = new SOPObject(m_rootScene, part.LocalId, m_security);
@@ -273,8 +273,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
273 public Vector3 SitTarget 273 public Vector3 SitTarget
274 { 274 {
275 get { return GetSOP().SitTargetPosition; } 275 get { return GetSOP().SitTargetPosition; }
276 set 276 set
277 { 277 {
278 if (CanEdit()) 278 if (CanEdit())
279 { 279 {
280 GetSOP().SitTargetPosition = value; 280 GetSOP().SitTargetPosition = value;
@@ -285,8 +285,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
285 public string SitTargetText 285 public string SitTargetText
286 { 286 {
287 get { return GetSOP().SitName; } 287 get { return GetSOP().SitName; }
288 set 288 set
289 { 289 {
290 if (CanEdit()) 290 if (CanEdit())
291 { 291 {
292 GetSOP().SitName = value; 292 GetSOP().SitName = value;
@@ -297,7 +297,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
297 public string TouchText 297 public string TouchText
298 { 298 {
299 get { return GetSOP().TouchName; } 299 get { return GetSOP().TouchName; }
300 set 300 set
301 { 301 {
302 if (CanEdit()) 302 if (CanEdit())
303 { 303 {
@@ -309,7 +309,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
309 public string Text 309 public string Text
310 { 310 {
311 get { return GetSOP().Text; } 311 get { return GetSOP().Text; }
312 set 312 set
313 { 313 {
314 if (CanEdit()) 314 if (CanEdit())
315 { 315 {
@@ -382,11 +382,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
382 get { return this; } 382 get { return this; }
383 } 383 }
384 384
385 public IObjectInventory Inventory 385 public IObjectInventory Inventory
386 { 386 {
387 get { return new SOPObjectInventory(m_rootScene, GetSOP().TaskInventory); } 387 get { return new SOPObjectInventory(m_rootScene, GetSOP().TaskInventory); }
388 } 388 }
389 389
390 #region Public Functions 390 #region Public Functions
391 391
392 public void Say(string msg) 392 public void Say(string msg)
@@ -406,7 +406,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
406 SceneObjectPart sop = GetSOP(); 406 SceneObjectPart sop = GetSOP();
407 m_rootScene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Say,channel, sop.AbsolutePosition, sop.Name, sop.UUID, false); 407 m_rootScene.SimChat(Utils.StringToBytes(msg), ChatTypeEnum.Say,channel, sop.AbsolutePosition, sop.Name, sop.UUID, false);
408 } 408 }
409 409
410 public void Dialog(UUID avatar, string message, string[] buttons, int chat_channel) 410 public void Dialog(UUID avatar, string message, string[] buttons, int chat_channel)
411 { 411 {
412 if (!CanEdit()) 412 if (!CanEdit())
@@ -445,9 +445,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
445 dm.SendDialogToUser( 445 dm.SendDialogToUser(
446 avatar, GetSOP().Name, GetSOP().UUID, GetSOP().OwnerID, 446 avatar, GetSOP().Name, GetSOP().UUID, GetSOP().OwnerID,
447 message, new UUID("00000000-0000-2222-3333-100000001000"), chat_channel, buttons); 447 message, new UUID("00000000-0000-2222-3333-100000001000"), chat_channel, buttons);
448 448
449 } 449 }
450 450
451 #endregion 451 #endregion
452 452
453 453
@@ -540,7 +540,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
540 if (hasCut) ret += 2; 540 if (hasCut) ret += 2;
541 if (hasDimple) ret += 2; 541 if (hasDimple) ret += 2;
542 if (hasHollow) 542 if (hasHollow)
543 ret += 1; // GOTCHA: LSL shows 2 additional sides here. 543 ret += 1; // GOTCHA: LSL shows 2 additional sides here.
544 // This has been fixed, but may cause porting issues. 544 // This has been fixed, but may cause porting issues.
545 break; 545 break;
546 case (int) PrimType.Torus: 546 case (int) PrimType.Torus:
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs
index d20f4a4..8c3158c 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObjectInventory.cs
@@ -61,25 +61,25 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object
61 if (!m_publicInventory.ContainsKey(privateItem.ItemID)) 61 if (!m_publicInventory.ContainsKey(privateItem.ItemID))
62 m_publicInventory.Add(privateItem.ItemID, new InventoryItem(m_rootScene, privateItem)); 62 m_publicInventory.Add(privateItem.ItemID, new InventoryItem(m_rootScene, privateItem));
63 } 63 }
64 64
65 #region IDictionary<UUID, IInventoryItem> implementation 65 #region IDictionary<UUID, IInventoryItem> implementation
66 public void Add (UUID key, IInventoryItem value) 66 public void Add (UUID key, IInventoryItem value)
67 { 67 {
68 m_publicInventory.Add(key, value); 68 m_publicInventory.Add(key, value);
69 m_privateInventory.Add(key, InventoryItem.FromInterface(value).ToTaskInventoryItem()); 69 m_privateInventory.Add(key, InventoryItem.FromInterface(value).ToTaskInventoryItem());
70 } 70 }
71 71
72 public bool ContainsKey (UUID key) 72 public bool ContainsKey (UUID key)
73 { 73 {
74 return m_privateInventory.ContainsKey(key); 74 return m_privateInventory.ContainsKey(key);
75 } 75 }
76 76
77 public bool Remove (UUID key) 77 public bool Remove (UUID key)
78 { 78 {
79 m_publicInventory.Remove(key); 79 m_publicInventory.Remove(key);
80 return m_privateInventory.Remove(key); 80 return m_privateInventory.Remove(key);
81 } 81 }
82 82
83 public bool TryGetValue (UUID key, out IInventoryItem value) 83 public bool TryGetValue (UUID key, out IInventoryItem value)
84 { 84 {
85 value = null; 85 value = null;
@@ -89,7 +89,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object
89 { 89 {
90 // wasn't found in the public inventory 90 // wasn't found in the public inventory
91 TaskInventoryItem privateItem; 91 TaskInventoryItem privateItem;
92 92
93 result = m_privateInventory.TryGetValue(key, out privateItem); 93 result = m_privateInventory.TryGetValue(key, out privateItem);
94 if (result) 94 if (result)
95 { 95 {
@@ -98,16 +98,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object
98 } 98 }
99 } else 99 } else
100 return true; 100 return true;
101 101
102 return result; 102 return result;
103 } 103 }
104 104
105 public ICollection<UUID> Keys { 105 public ICollection<UUID> Keys {
106 get { 106 get {
107 return m_privateInventory.Keys; 107 return m_privateInventory.Keys;
108 } 108 }
109 } 109 }
110 110
111 public ICollection<IInventoryItem> Values { 111 public ICollection<IInventoryItem> Values {
112 get { 112 get {
113 SynchronizeDictionaries(); 113 SynchronizeDictionaries();
@@ -139,41 +139,41 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object
139 { 139 {
140 Add(item.Key, item.Value); 140 Add(item.Key, item.Value);
141 } 141 }
142 142
143 public void Clear () 143 public void Clear ()
144 { 144 {
145 m_publicInventory.Clear(); 145 m_publicInventory.Clear();
146 m_privateInventory.Clear(); 146 m_privateInventory.Clear();
147 } 147 }
148 148
149 public bool Contains (KeyValuePair<UUID, IInventoryItem> item) 149 public bool Contains (KeyValuePair<UUID, IInventoryItem> item)
150 { 150 {
151 return m_privateInventory.ContainsKey(item.Key); 151 return m_privateInventory.ContainsKey(item.Key);
152 } 152 }
153 153
154 public void CopyTo (KeyValuePair<UUID, IInventoryItem>[] array, int arrayIndex) 154 public void CopyTo (KeyValuePair<UUID, IInventoryItem>[] array, int arrayIndex)
155 { 155 {
156 throw new NotImplementedException(); 156 throw new NotImplementedException();
157 } 157 }
158 158
159 public bool Remove (KeyValuePair<UUID, IInventoryItem> item) 159 public bool Remove (KeyValuePair<UUID, IInventoryItem> item)
160 { 160 {
161 return Remove(item.Key); 161 return Remove(item.Key);
162 } 162 }
163 163
164 public int Count { 164 public int Count {
165 get { 165 get {
166 return m_privateInventory.Count; 166 return m_privateInventory.Count;
167 } 167 }
168 } 168 }
169 169
170 public bool IsReadOnly { 170 public bool IsReadOnly {
171 get { 171 get {
172 return false; 172 return false;
173 } 173 }
174 } 174 }
175 #endregion 175 #endregion
176 176
177 #region Explicit implementations 177 #region Explicit implementations
178 IInventoryItem System.Collections.Generic.IDictionary<UUID, IInventoryItem>.this[UUID key] 178 IInventoryItem System.Collections.Generic.IDictionary<UUID, IInventoryItem>.this[UUID key]
179 { 179 {
@@ -189,13 +189,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object
189 m_privateInventory[key] = InventoryItem.FromInterface(value).ToTaskInventoryItem(); 189 m_privateInventory[key] = InventoryItem.FromInterface(value).ToTaskInventoryItem();
190 } 190 }
191 } 191 }
192 192
193 void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<UUID, IInventoryItem>>.CopyTo(System.Collections.Generic.KeyValuePair<UUID,IInventoryItem>[] array, int offset) 193 void System.Collections.Generic.ICollection<System.Collections.Generic.KeyValuePair<UUID, IInventoryItem>>.CopyTo(System.Collections.Generic.KeyValuePair<UUID,IInventoryItem>[] array, int offset)
194 { 194 {
195 throw new NotImplementedException(); 195 throw new NotImplementedException();
196 } 196 }
197 #endregion 197 #endregion
198 198
199 public IInventoryItem this[string name] 199 public IInventoryItem this[string name]
200 { 200 {
201 get { 201 get {
@@ -204,7 +204,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule.Object
204 { 204 {
205 if (!m_publicInventory.ContainsKey(i.ItemID)) 205 if (!m_publicInventory.ContainsKey(i.ItemID))
206 m_publicInventory.Add(i.ItemID, new InventoryItem(m_rootScene, i)); 206 m_publicInventory.Add(i.ItemID, new InventoryItem(m_rootScene, i));
207 207
208 return m_publicInventory[i.ItemID]; 208 return m_publicInventory[i.ItemID];
209 } 209 }
210 throw new KeyNotFoundException(); 210 throw new KeyNotFoundException();
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
index d192309..a380f66 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatar.cs
@@ -70,18 +70,18 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
70 get { return GetSP().AbsolutePosition; } 70 get { return GetSP().AbsolutePosition; }
71 set { GetSP().Teleport(value); } 71 set { GetSP().Teleport(value); }
72 } 72 }
73 73
74 public bool IsChildAgent 74 public bool IsChildAgent
75 { 75 {
76 get { return GetSP().IsChildAgent; } 76 get { return GetSP().IsChildAgent; }
77 } 77 }
78 78
79 #region IAvatar implementation 79 #region IAvatar implementation
80 public IAvatarAttachment[] Attachments 80 public IAvatarAttachment[] Attachments
81 { 81 {
82 get { 82 get {
83 List<IAvatarAttachment> attachments = new List<IAvatarAttachment>(); 83 List<IAvatarAttachment> attachments = new List<IAvatarAttachment>();
84 84
85 List<AvatarAttachment> internalAttachments = GetSP().Appearance.GetAttachments(); 85 List<AvatarAttachment> internalAttachments = GetSP().Appearance.GetAttachments();
86 foreach (AvatarAttachment attach in internalAttachments) 86 foreach (AvatarAttachment attach in internalAttachments)
87 { 87 {
@@ -89,7 +89,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
89 new UUID(attach.ItemID), 89 new UUID(attach.ItemID),
90 new UUID(attach.AssetID), m_security)); 90 new UUID(attach.AssetID), m_security));
91 } 91 }
92 92
93 return attachments.ToArray(); 93 return attachments.ToArray();
94 } 94 }
95 } 95 }
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs
index 570459a..bcf6053 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SPAvatarAttachment.cs
@@ -41,7 +41,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
41 private readonly UUID m_assetId; 41 private readonly UUID m_assetId;
42 42
43 private readonly ISecurityCredential m_security; 43 private readonly ISecurityCredential m_security;
44 44
45 public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId, ISecurityCredential security) 45 public SPAvatarAttachment(Scene rootScene, IAvatar self, int location, UUID itemId, UUID assetId, ISecurityCredential security)
46 { 46 {
47 m_rootScene = rootScene; 47 m_rootScene = rootScene;
@@ -51,9 +51,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
51 //m_itemId = itemId; 51 //m_itemId = itemId;
52 m_assetId = assetId; 52 m_assetId = assetId;
53 } 53 }
54 54
55 public int Location { get { return m_location; } } 55 public int Location { get { return m_location; } }
56 56
57 public IObject Asset 57 public IObject Asset
58 { 58 {
59 get 59 get
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs
index 13d0140..724c2a9 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/Test/TestModule.cs
@@ -51,7 +51,7 @@ namespace OpenSim
51 51
52 public void Microthread(IEnumerable thread) 52 public void Microthread(IEnumerable thread)
53 { 53 {
54 54
55 } 55 }
56 56
57 public void RunMicrothread() 57 public void RunMicrothread()
@@ -92,7 +92,7 @@ namespace OpenSim
92 92
93 public override void Stop() 93 public override void Stop()
94 { 94 {
95 95
96 } 96 }
97 } 97 }
98} 98}
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
index f2324d2..36f70d0 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/World.cs
@@ -34,7 +34,7 @@ using OpenSim.Region.OptionalModules.Scripting.Minimodule.WorldX;
34 34
35namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 35namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
36{ 36{
37 public class World : System.MarshalByRefObject, IWorld, IWorldAudio 37 public class World : System.MarshalByRefObject, IWorld, IWorldAudio
38 { 38 {
39 private readonly Scene m_internalScene; 39 private readonly Scene m_internalScene;
40 private readonly ISecurityCredential m_security; 40 private readonly ISecurityCredential m_security;
@@ -149,7 +149,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
149 e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId, m_security); 149 e.Sender = new SOPObject(m_internalScene, ((SceneObjectPart) chat.SenderObject).LocalId, m_security);
150 e.Text = chat.Message; 150 e.Text = chat.Message;
151 e.Channel = chat.Channel; 151 e.Channel = chat.Channel;
152 152
153 _OnChat(this, e); 153 _OnChat(this, e);
154 return; 154 return;
155 } 155 }
@@ -160,7 +160,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
160 e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID, m_security); 160 e.Sender = new SPAvatar(m_internalScene, chat.SenderUUID, m_security);
161 e.Text = chat.Message; 161 e.Text = chat.Message;
162 e.Channel = chat.Channel; 162 e.Channel = chat.Channel;
163 163
164 _OnChat(this, e); 164 _OnChat(this, e);
165 return; 165 return;
166 } 166 }
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index 870c0bb..a1dd711 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -46,7 +46,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionReadyModule")] 46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionReadyModule")]
47 public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule 47 public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule
48 { 48 {
49 private static readonly ILog m_log = 49 private static readonly ILog m_log =
50 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 50 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
51 51
52 private IConfig m_config = null; 52 private IConfig m_config = null;
@@ -57,24 +57,24 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
57 private bool m_enabled = false; 57 private bool m_enabled = false;
58 private bool m_disable_logins; 58 private bool m_disable_logins;
59 private string m_uri = string.Empty; 59 private string m_uri = string.Empty;
60 60
61 Scene m_scene; 61 Scene m_scene;
62 62
63 #region INonSharedRegionModule interface 63 #region INonSharedRegionModule interface
64 64
65 public Type ReplaceableInterface 65 public Type ReplaceableInterface
66 { 66 {
67 get { return null; } 67 get { return null; }
68 } 68 }
69 69
70 public void Initialise(IConfigSource config) 70 public void Initialise(IConfigSource config)
71 { 71 {
72 m_config = config.Configs["RegionReady"]; 72 m_config = config.Configs["RegionReady"];
73 if (m_config != null) 73 if (m_config != null)
74 { 74 {
75 m_enabled = m_config.GetBoolean("enabled", false); 75 m_enabled = m_config.GetBoolean("enabled", false);
76 76
77 if (m_enabled) 77 if (m_enabled)
78 { 78 {
79 m_channelNotify = m_config.GetInt("channel_notify", m_channelNotify); 79 m_channelNotify = m_config.GetInt("channel_notify", m_channelNotify);
80 m_disable_logins = m_config.GetBoolean("login_disable", false); 80 m_disable_logins = m_config.GetBoolean("login_disable", false);
@@ -106,7 +106,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
106 m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue; 106 m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
107 107
108 // This should always show up to the user but should not trigger warn/errors as these messages are 108 // This should always show up to the user but should not trigger warn/errors as these messages are
109 // expected and are not simulator problems. Ideally, there would be a status level in log4net but 109 // expected and are not simulator problems. Ideally, there would be a status level in log4net but
110 // failing that, we will print out to console instead. 110 // failing that, we will print out to console instead.
111 MainConsole.Instance.OutputFormat("Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name); 111 MainConsole.Instance.OutputFormat("Region {0} - LOGINS DISABLED DURING INITIALIZATION.", m_scene.Name);
112 112
@@ -152,12 +152,12 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
152 { 152 {
153 m_log.DebugFormat("[RegionReady]: Script compile queue empty!"); 153 m_log.DebugFormat("[RegionReady]: Script compile queue empty!");
154 154
155 if (m_firstEmptyCompileQueue || m_oarFileLoading) 155 if (m_firstEmptyCompileQueue || m_oarFileLoading)
156 { 156 {
157 OSChatMessage c = new OSChatMessage(); 157 OSChatMessage c = new OSChatMessage();
158 if (m_firstEmptyCompileQueue) 158 if (m_firstEmptyCompileQueue)
159 c.Message = "server_startup,"; 159 c.Message = "server_startup,";
160 else 160 else
161 c.Message = "oar_file_load,"; 161 c.Message = "oar_file_load,";
162 m_firstEmptyCompileQueue = false; 162 m_firstEmptyCompileQueue = false;
163 m_oarFileLoading = false; 163 m_oarFileLoading = false;
@@ -165,7 +165,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
165 m_scene.Backup(false); 165 m_scene.Backup(false);
166 166
167 c.From = "RegionReady"; 167 c.From = "RegionReady";
168 if (m_lastOarLoadedOk) 168 if (m_lastOarLoadedOk)
169 c.Message += "1,"; 169 c.Message += "1,";
170 else 170 else
171 c.Message += "0,"; 171 c.Message += "0,";
@@ -193,7 +193,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
193 { 193 {
194 m_oarFileLoading = true; 194 m_oarFileLoading = true;
195 195
196 if (message==String.Empty) 196 if (message==String.Empty)
197 { 197 {
198 m_lastOarLoadedOk = true; 198 m_lastOarLoadedOk = true;
199 } 199 }
@@ -214,6 +214,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
214 m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue; 214 m_scene.EventManager.OnEmptyScriptCompileQueue -= OnEmptyScriptCompileQueue;
215 m_scene.LoginLock = false; 215 m_scene.LoginLock = false;
216 216
217 GC.Collect();
218 GC.WaitForPendingFinalizers();
219 GC.Collect();
220
217 if (!m_scene.StartDisabled) 221 if (!m_scene.StartDisabled)
218 { 222 {
219 m_scene.LoginsEnabled = true; 223 m_scene.LoginsEnabled = true;
@@ -222,7 +226,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
222 // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString()); 226 // m_scene.RegionInfo.RegionName, m_oarFileLoading.ToString());
223 227
224 // Putting this out to console to make it eye-catching for people who are running OpenSimulator 228 // Putting this out to console to make it eye-catching for people who are running OpenSimulator
225 // without info log messages enabled. Making this a warning is arguably misleading since it isn't a 229 // without info log messages enabled. Making this a warning is arguably misleading since it isn't a
226 // warning, and monitor scripts looking for warn/error/fatal messages will received false positives. 230 // warning, and monitor scripts looking for warn/error/fatal messages will received false positives.
227 // Arguably, log4net needs a status log level (like Apache). 231 // Arguably, log4net needs a status log level (like Apache).
228 MainConsole.Instance.OutputFormat("INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name); 232 MainConsole.Instance.OutputFormat("INITIALIZATION COMPLETE FOR {0} - LOGINS ENABLED", m_scene.Name);
@@ -252,7 +256,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
252// m_scene.EventManager.OnRezScript += OnRezScript; 256// m_scene.EventManager.OnRezScript += OnRezScript;
253// m_oarFileLoading = true; 257// m_oarFileLoading = true;
254// m_firstEmptyCompileQueue = true; 258// m_firstEmptyCompileQueue = true;
255// 259//
256// m_scene.LoginsDisabled = true; 260// m_scene.LoginsDisabled = true;
257// m_scene.LoginLock = true; 261// m_scene.LoginLock = true;
258// if ( m_uri != string.Empty ) 262// if ( m_uri != string.Empty )
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs
index 744d1e3..bf33996 100644
--- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs
@@ -54,7 +54,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
54 public class XmlRpcGridRouter : INonSharedRegionModule, IXmlRpcRouter 54 public class XmlRpcGridRouter : INonSharedRegionModule, IXmlRpcRouter
55 { 55 {
56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
57 57
58 private Dictionary<UUID, UUID> m_Channels = 58 private Dictionary<UUID, UUID> m_Channels =
59 new Dictionary<UUID, UUID>(); 59 new Dictionary<UUID, UUID>();
60 60
@@ -94,7 +94,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
94 { 94 {
95 scriptEngine.OnScriptRemoved += this.ScriptRemoved; 95 scriptEngine.OnScriptRemoved += this.ScriptRemoved;
96 scriptEngine.OnObjectRemoved += this.ObjectRemoved; 96 scriptEngine.OnObjectRemoved += this.ObjectRemoved;
97 97
98 } 98 }
99 } 99 }
100 100
@@ -131,7 +131,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
131 if (!m_Enabled) 131 if (!m_Enabled)
132 return; 132 return;
133 133
134 m_log.InfoFormat("[XMLRPC GRID ROUTER]: New receiver Obj: {0} Ch: {1} ID: {2} URI: {3}", 134 m_log.InfoFormat("[XMLRPC GRID ROUTER]: New receiver Obj: {0} Ch: {1} ID: {2} URI: {3}",
135 objectID.ToString(), channel.ToString(), itemID.ToString(), uri); 135 objectID.ToString(), channel.ToString(), itemID.ToString(), uri);
136 136
137 XmlRpcInfo info = new XmlRpcInfo(); 137 XmlRpcInfo info = new XmlRpcInfo();
@@ -178,7 +178,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
178 { 178 {
179 if(!m_Channels.ContainsKey(itemID)) 179 if(!m_Channels.ContainsKey(itemID))
180 { 180 {
181 m_log.InfoFormat("[XMLRPC GRID ROUTER]: Attempted to unregister non-existing Item: {0}", itemID.ToString()); 181 //m_log.InfoFormat("[XMLRPC GRID ROUTER]: Attempted to unregister non-existing Item: {0}", itemID.ToString());
182 return false; 182 return false;
183 } 183 }
184 184
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs
index 943675e..32549d6 100644
--- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs
@@ -98,7 +98,10 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule
98 98
99 public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) 99 public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri)
100 { 100 {
101 scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] {uri}); 101 if (m_Enabled)
102 {
103 scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] { uri });
104 }
102 } 105 }
103 106
104 public void UnRegisterReceiver(string channelID, UUID itemID) 107 public void UnRegisterReceiver(string channelID, UUID itemID)
diff --git a/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs b/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs
index 78c870a..8654896 100644
--- a/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Freeswitch
44 { 44 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 private static bool m_Enabled = false; 46 private static bool m_Enabled = false;
47 47
48 private IConfigSource m_Config; 48 private IConfigSource m_Config;
49 bool m_Registered = false; 49 bool m_Registered = false;
50 50
@@ -73,7 +73,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Freeswitch
73 { 73 {
74 } 74 }
75 75
76 public Type ReplaceableInterface 76 public Type ReplaceableInterface
77 { 77 {
78 get { return null; } 78 get { return null; }
79 } 79 }
diff --git a/OpenSim/Region/OptionalModules/UserStatistics/Clients_report.cs b/OpenSim/Region/OptionalModules/UserStatistics/Clients_report.cs
index 4a6f7be..d3b97b1 100644
--- a/OpenSim/Region/OptionalModules/UserStatistics/Clients_report.cs
+++ b/OpenSim/Region/OptionalModules/UserStatistics/Clients_report.cs
@@ -97,9 +97,8 @@ namespace OpenSim.Region.UserStatistics
97 sdr.Read(); 97 sdr.Read();
98 totalregions = Convert.ToInt32(sdr["regcnt"]); 98 totalregions = Convert.ToInt32(sdr["regcnt"]);
99 } 99 }
100
101 sdr.Close(); 100 sdr.Close();
102 sdr.Dispose(); 101 cmd.Dispose();
103 102
104 sql = 103 sql =
105 "select client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by client_version order by count(*) desc LIMIT 10;"; 104 "select client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by client_version order by count(*) desc LIMIT 10;";
@@ -116,20 +115,20 @@ namespace OpenSim.Region.UserStatistics
116 udata.fps = Convert.ToSingle(sdr["simfps"]); 115 udata.fps = Convert.ToSingle(sdr["simfps"]);
117 clidata.Add(udata); 116 clidata.Add(udata);
118 totalclients += udata.count; 117 totalclients += udata.count;
119 118
120 } 119 }
121 } 120 }
122 sdr.Close(); 121 sdr.Close();
123 sdr.Dispose(); 122 cmd.Dispose();
124 123
125 if (totalregions > 1) 124 if (totalregions > 1)
126 { 125 {
127 sql = 126 sql =
128 "select region_id, client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by region_id, client_version order by region_id, count(*) desc;"; 127 "select region_id, client_version, count(*) as cnt, avg(avg_sim_fps) as simfps from stats_session_data group by region_id, client_version order by region_id, count(*) desc;";
129 cmd = new SqliteCommand(sql, dbConn); 128 cmd = new SqliteCommand(sql, dbConn);
130 129
131 sdr = cmd.ExecuteReader(); 130 sdr = cmd.ExecuteReader();
132 131
133 if (sdr.HasRows) 132 if (sdr.HasRows)
134 { 133 {
135 while (sdr.Read()) 134 while (sdr.Read())
@@ -143,16 +142,13 @@ namespace OpenSim.Region.UserStatistics
143 } 142 }
144 } 143 }
145 sdr.Close(); 144 sdr.Close();
146 sdr.Dispose(); 145 cmd.Dispose();
147
148
149 } 146 }
150
151 } 147 }
152 148
153 foreach (ClientVersionData cvd in cliRegData) 149 foreach (ClientVersionData cvd in cliRegData)
154 { 150 {
155 151
156 if (regionTotals.ContainsKey(cvd.region_id)) 152 if (regionTotals.ContainsKey(cvd.region_id))
157 { 153 {
158 int regiontotal = (int)regionTotals[cvd.region_id]; 154 int regiontotal = (int)regionTotals[cvd.region_id];
@@ -163,9 +159,6 @@ namespace OpenSim.Region.UserStatistics
163 { 159 {
164 regionTotals.Add(cvd.region_id, cvd.count); 160 regionTotals.Add(cvd.region_id, cvd.count);
165 } 161 }
166
167
168
169 } 162 }
170 163
171 modeldata["ClientData"] = clidata; 164 modeldata["ClientData"] = clidata;
diff --git a/OpenSim/Region/OptionalModules/UserStatistics/Default_Report.cs b/OpenSim/Region/OptionalModules/UserStatistics/Default_Report.cs
index fabe3d4..fcc7cee 100644
--- a/OpenSim/Region/OptionalModules/UserStatistics/Default_Report.cs
+++ b/OpenSim/Region/OptionalModules/UserStatistics/Default_Report.cs
@@ -61,7 +61,7 @@ namespace OpenSim.Region.UserStatistics
61 Hashtable nh = new Hashtable(); 61 Hashtable nh = new Hashtable();
62 nh.Add("hdata", mData); 62 nh.Add("hdata", mData);
63 nh.Add("Reports", pParams["Reports"]); 63 nh.Add("Reports", pParams["Reports"]);
64 64
65 return nh; 65 return nh;
66 } 66 }
67 67
@@ -76,7 +76,7 @@ namespace OpenSim.Region.UserStatistics
76 public string rep_Default_report_view(stats_default_page_values values) 76 public string rep_Default_report_view(stats_default_page_values values)
77 { 77 {
78 78
79 79
80 StringBuilder output = new StringBuilder(); 80 StringBuilder output = new StringBuilder();
81 81
82 82
@@ -105,7 +105,7 @@ TD.align_top { vertical-align: top; }
105</STYLE> 105</STYLE>
106"; 106";
107 HTMLUtil.HtmlHeaders_O(ref output); 107 HTMLUtil.HtmlHeaders_O(ref output);
108 108
109 HTMLUtil.InsertProtoTypeAJAX(ref output); 109 HTMLUtil.InsertProtoTypeAJAX(ref output);
110 string[] ajaxUpdaterDivs = new string[3]; 110 string[] ajaxUpdaterDivs = new string[3];
111 int[] ajaxUpdaterSeconds = new int[3]; 111 int[] ajaxUpdaterSeconds = new int[3];
@@ -124,7 +124,7 @@ TD.align_top { vertical-align: top; }
124 ajaxUpdaterReportFragments[2] = "activelogajax.html"; 124 ajaxUpdaterReportFragments[2] = "activelogajax.html";
125 125
126 HTMLUtil.InsertPeriodicUpdaters(ref output, ajaxUpdaterDivs, ajaxUpdaterSeconds, ajaxUpdaterReportFragments); 126 HTMLUtil.InsertPeriodicUpdaters(ref output, ajaxUpdaterDivs, ajaxUpdaterSeconds, ajaxUpdaterReportFragments);
127 127
128 output.Append(STYLESHEET); 128 output.Append(STYLESHEET);
129 HTMLUtil.HtmlHeaders_C(ref output); 129 HTMLUtil.HtmlHeaders_C(ref output);
130 HTMLUtil.AddReportLinks(ref output, values.stats_reports, ""); 130 HTMLUtil.AddReportLinks(ref output, values.stats_reports, "");
@@ -200,7 +200,7 @@ TD.align_top { vertical-align: top; }
200 return output.ToString(); 200 return output.ToString();
201 } 201 }
202 202
203 203
204 204
205 public stats_default_page_values rep_DefaultReport_data(SqliteConnection db, List<Scene> m_scene) 205 public stats_default_page_values rep_DefaultReport_data(SqliteConnection db, List<Scene> m_scene)
206 { 206 {
@@ -208,8 +208,8 @@ TD.align_top { vertical-align: top; }
208 returnstruct.all_scenes = m_scene.ToArray(); 208 returnstruct.all_scenes = m_scene.ToArray();
209 lock (db) 209 lock (db)
210 { 210 {
211 string SQL = @"SELECT COUNT(DISTINCT agent_id) as agents, COUNT(*) as sessions, AVG(avg_fps) as client_fps, 211 string SQL = @"SELECT COUNT(DISTINCT agent_id) as agents, COUNT(*) as sessions, AVG(avg_fps) as client_fps,
212 AVG(avg_sim_fps) as savg_sim_fps, AVG(avg_ping) as sav_ping, SUM(n_out_kb) as num_in_kb, 212 AVG(avg_sim_fps) as savg_sim_fps, AVG(avg_ping) as sav_ping, SUM(n_out_kb) as num_in_kb,
213 SUM(n_out_pk) as num_in_packets, SUM(n_in_kb) as num_out_kb, SUM(n_in_pk) as num_out_packets, AVG(mem_use) as sav_mem_use 213 SUM(n_out_pk) as num_in_packets, SUM(n_in_kb) as num_out_kb, SUM(n_in_pk) as num_out_packets, AVG(mem_use) as sav_mem_use
214 FROM stats_session_data;"; 214 FROM stats_session_data;";
215 SqliteCommand cmd = new SqliteCommand(SQL, db); 215 SqliteCommand cmd = new SqliteCommand(SQL, db);
@@ -227,7 +227,10 @@ TD.align_top { vertical-align: top; }
227 returnstruct.avg_client_mem_use = Convert.ToSingle(sdr["sav_mem_use"]); 227 returnstruct.avg_client_mem_use = Convert.ToSingle(sdr["sav_mem_use"]);
228 228
229 } 229 }
230 sdr.Close();
231 cmd.Dispose();
230 } 232 }
233
231 return returnstruct; 234 return returnstruct;
232 } 235 }
233 236
@@ -273,5 +276,5 @@ TD.align_top { vertical-align: top; }
273 public Dictionary<UUID, USimStatsData> sim_stat_data; 276 public Dictionary<UUID, USimStatsData> sim_stat_data;
274 public Dictionary<string, IStatsController> stats_reports; 277 public Dictionary<string, IStatsController> stats_reports;
275 } 278 }
276 279
277} 280}
diff --git a/OpenSim/Region/OptionalModules/UserStatistics/HTMLUtil.cs b/OpenSim/Region/OptionalModules/UserStatistics/HTMLUtil.cs
index c07619f..20e045a 100644
--- a/OpenSim/Region/OptionalModules/UserStatistics/HTMLUtil.cs
+++ b/OpenSim/Region/OptionalModules/UserStatistics/HTMLUtil.cs
@@ -95,7 +95,7 @@ namespace OpenSim.Region.UserStatistics
95 { 95 {
96 o.Append("</table>\n"); 96 o.Append("</table>\n");
97 } 97 }
98 98
99 public static void BLOCKQUOTE_O(ref StringBuilder o, string pclass) 99 public static void BLOCKQUOTE_O(ref StringBuilder o, string pclass)
100 { 100 {
101 o.Append("<blockquote"); 101 o.Append("<blockquote");
@@ -199,7 +199,7 @@ namespace OpenSim.Region.UserStatistics
199"); 199");
200 for (int i = 0; i < divID.Length; i++) 200 for (int i = 0; i < divID.Length; i++)
201 { 201 {
202 202
203 o.Append("new updater('"); 203 o.Append("new updater('");
204 o.Append(divID[i]); 204 o.Append(divID[i]);
205 o.Append("', "); 205 o.Append("', ");
diff --git a/OpenSim/Region/OptionalModules/UserStatistics/LogLinesAJAX.cs b/OpenSim/Region/OptionalModules/UserStatistics/LogLinesAJAX.cs
index 4d45b80..3e0f45e 100644
--- a/OpenSim/Region/OptionalModules/UserStatistics/LogLinesAJAX.cs
+++ b/OpenSim/Region/OptionalModules/UserStatistics/LogLinesAJAX.cs
@@ -66,7 +66,7 @@ namespace OpenSim.Region.UserStatistics
66 public string RenderView(Hashtable pModelResult) 66 public string RenderView(Hashtable pModelResult)
67 { 67 {
68 StringBuilder output = new StringBuilder(); 68 StringBuilder output = new StringBuilder();
69 69
70 HTMLUtil.HR(ref output, ""); 70 HTMLUtil.HR(ref output, "");
71 output.Append("<H3>ActiveLog</H3>\n"); 71 output.Append("<H3>ActiveLog</H3>\n");
72 72
@@ -102,13 +102,13 @@ namespace OpenSim.Region.UserStatistics
102 } 102 }
103 } 103 }
104 StringBuilder replaceStr = new StringBuilder(); 104 StringBuilder replaceStr = new StringBuilder();
105 //string titlecolorresults = 105 //string titlecolorresults =
106 106
107 string formatresult = Regex.Replace(TitleColor.Replace(result[i], "$1"), "[^ABCDEFabcdef0-9]", ""); 107 string formatresult = Regex.Replace(TitleColor.Replace(result[i], "$1"), "[^ABCDEFabcdef0-9]", "");
108 if (formatresult.Length > 6) 108 if (formatresult.Length > 6)
109 { 109 {
110 formatresult = formatresult.Substring(0, 6); 110 formatresult = formatresult.Substring(0, 6);
111 111
112 } 112 }
113 for (int j = formatresult.Length; j <= 5; j++) 113 for (int j = formatresult.Length; j <= 5; j++)
114 formatresult += "0"; 114 formatresult += "0";
@@ -116,12 +116,12 @@ namespace OpenSim.Region.UserStatistics
116 replaceStr.Append(formatresult); 116 replaceStr.Append(formatresult);
117 replaceStr.Append("\">$3</font>] $4<br />"); 117 replaceStr.Append("\">$3</font>] $4<br />");
118 string repstr = replaceStr.ToString(); 118 string repstr = replaceStr.ToString();
119 119
120 output.Append(formatopen); 120 output.Append(formatopen);
121 output.Append(webFormat.Replace(result[i], repstr)); 121 output.Append(webFormat.Replace(result[i], repstr));
122 output.Append(formatclose); 122 output.Append(formatclose);
123 } 123 }
124 124
125 125
126 return output.ToString(); 126 return output.ToString();
127 } 127 }
diff --git a/OpenSim/Region/OptionalModules/UserStatistics/Prototype_distributor.cs b/OpenSim/Region/OptionalModules/UserStatistics/Prototype_distributor.cs
index 6f8b2aa..63dc87e 100644
--- a/OpenSim/Region/OptionalModules/UserStatistics/Prototype_distributor.cs
+++ b/OpenSim/Region/OptionalModules/UserStatistics/Prototype_distributor.cs
@@ -44,7 +44,7 @@ namespace OpenSim.Region.UserStatistics
44 jsFileName = "prototype.js"; 44 jsFileName = "prototype.js";
45 } 45 }
46 46
47 public Prototype_distributor(string jsName) 47 public Prototype_distributor(string jsName)
48 { 48 {
49 jsFileName = jsName; 49 jsFileName = jsName;
50 } 50 }
diff --git a/OpenSim/Region/OptionalModules/UserStatistics/Sessions_Report.cs b/OpenSim/Region/OptionalModules/UserStatistics/Sessions_Report.cs
index 0e94912..8d5434f 100644
--- a/OpenSim/Region/OptionalModules/UserStatistics/Sessions_Report.cs
+++ b/OpenSim/Region/OptionalModules/UserStatistics/Sessions_Report.cs
@@ -52,7 +52,7 @@ namespace OpenSim.Region.UserStatistics
52 SqliteConnection dbConn = (SqliteConnection)pParams["DatabaseConnection"]; 52 SqliteConnection dbConn = (SqliteConnection)pParams["DatabaseConnection"];
53 List<SessionList> lstSessions = new List<SessionList>(); 53 List<SessionList> lstSessions = new List<SessionList>();
54 Hashtable requestvars = (Hashtable) pParams["RequestVars"]; 54 Hashtable requestvars = (Hashtable) pParams["RequestVars"];
55 55
56 56
57 string puserUUID = string.Empty; 57 string puserUUID = string.Empty;
58 string clientVersionString = string.Empty; 58 string clientVersionString = string.Empty;
@@ -113,7 +113,7 @@ namespace OpenSim.Region.UserStatistics
113 cmd.Parameters.Add(new SqliteParameter(":client_version", clientVersionString)); 113 cmd.Parameters.Add(new SqliteParameter(":client_version", clientVersionString));
114 114
115 SqliteDataReader sdr = cmd.ExecuteReader(); 115 SqliteDataReader sdr = cmd.ExecuteReader();
116 116
117 if (sdr.HasRows) 117 if (sdr.HasRows)
118 { 118 {
119 UUID userUUID = UUID.Zero; 119 UUID userUUID = UUID.Zero;
@@ -134,7 +134,7 @@ namespace OpenSim.Region.UserStatistics
134 } 134 }
135 135
136 ShortSessionData ssd = new ShortSessionData(); 136 ShortSessionData ssd = new ShortSessionData();
137 137
138 ssd.last_update = Utils.UnixTimeToDateTime((uint)Convert.ToInt32(sdr["last_updated"])); 138 ssd.last_update = Utils.UnixTimeToDateTime((uint)Convert.ToInt32(sdr["last_updated"]));
139 ssd.start_time = Utils.UnixTimeToDateTime((uint)Convert.ToInt32(sdr["start_time"])); 139 ssd.start_time = Utils.UnixTimeToDateTime((uint)Convert.ToInt32(sdr["start_time"]));
140 ssd.session_id = UUID.Parse(sdr["session_id"].ToString()); 140 ssd.session_id = UUID.Parse(sdr["session_id"].ToString());
@@ -145,8 +145,7 @@ namespace OpenSim.Region.UserStatistics
145 } 145 }
146 } 146 }
147 sdr.Close(); 147 sdr.Close();
148 sdr.Dispose(); 148 cmd.Dispose();
149
150 } 149 }
151 modeldata["SessionData"] = lstSessions; 150 modeldata["SessionData"] = lstSessions;
152 return modeldata; 151 return modeldata;
@@ -249,7 +248,7 @@ TD.align_top { vertical-align: top; }
249 output.Append(sesdata.client_version); 248 output.Append(sesdata.client_version);
250 HTMLUtil.TD_C(ref output); 249 HTMLUtil.TD_C(ref output);
251 HTMLUtil.TR_C(ref output); 250 HTMLUtil.TR_C(ref output);
252 251
253 } 252 }
254 HTMLUtil.TR_O(ref output, ""); 253 HTMLUtil.TR_O(ref output, "");
255 HTMLUtil.TD_O(ref output, "align_top", 1, 5); 254 HTMLUtil.TD_O(ref output, "align_top", 1, 5);
diff --git a/OpenSim/Region/OptionalModules/UserStatistics/SimStatsAJAX.cs b/OpenSim/Region/OptionalModules/UserStatistics/SimStatsAJAX.cs
index 06d9e91..513686d 100644
--- a/OpenSim/Region/OptionalModules/UserStatistics/SimStatsAJAX.cs
+++ b/OpenSim/Region/OptionalModules/UserStatistics/SimStatsAJAX.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Region.UserStatistics
50 public Hashtable ProcessModel(Hashtable pParams) 50 public Hashtable ProcessModel(Hashtable pParams)
51 { 51 {
52 List<Scene> m_scene = (List<Scene>)pParams["Scenes"]; 52 List<Scene> m_scene = (List<Scene>)pParams["Scenes"];
53 53
54 Hashtable nh = new Hashtable(); 54 Hashtable nh = new Hashtable();
55 nh.Add("hdata", m_scene); 55 nh.Add("hdata", m_scene);
56 nh.Add("simstats", pParams["SimStats"]); 56 nh.Add("simstats", pParams["SimStats"]);
@@ -207,9 +207,9 @@ namespace OpenSim.Region.UserStatistics
207 HTMLUtil.TD_C(ref output); 207 HTMLUtil.TD_C(ref output);
208 HTMLUtil.TR_C(ref output); 208 HTMLUtil.TR_C(ref output);
209 HTMLUtil.TABLE_C(ref output); 209 HTMLUtil.TABLE_C(ref output);
210 210
211 } 211 }
212 212
213 return output.ToString(); 213 return output.ToString();
214 } 214 }
215 215
@@ -218,7 +218,7 @@ namespace OpenSim.Region.UserStatistics
218 /// <pre> 218 /// <pre>
219 /// {"REGIONNAME": { 219 /// {"REGIONNAME": {
220 /// "region": "REGIONNAME", 220 /// "region": "REGIONNAME",
221 /// "timeDilation": "101", 221 /// "timeDilation": "101",
222 /// ... // the rest of the stat info 222 /// ... // the rest of the stat info
223 /// }, 223 /// },
224 /// ... // entries for each region 224 /// ... // entries for each region
diff --git a/OpenSim/Region/OptionalModules/UserStatistics/WebStatsModule.cs b/OpenSim/Region/OptionalModules/UserStatistics/WebStatsModule.cs
index f6772db..c15b194 100644
--- a/OpenSim/Region/OptionalModules/UserStatistics/WebStatsModule.cs
+++ b/OpenSim/Region/OptionalModules/UserStatistics/WebStatsModule.cs
@@ -57,7 +57,7 @@ namespace OpenSim.Region.UserStatistics
57 { 57 {
58 private static readonly ILog m_log = 58 private static readonly ILog m_log =
59 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 59 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
60 60
61 private static SqliteConnection dbConn; 61 private static SqliteConnection dbConn;
62 62
63 /// <summary> 63 /// <summary>
@@ -67,7 +67,7 @@ namespace OpenSim.Region.UserStatistics
67 67
68 private List<Scene> m_scenes = new List<Scene>(); 68 private List<Scene> m_scenes = new List<Scene>();
69 private Dictionary<string, IStatsController> reports = new Dictionary<string, IStatsController>(); 69 private Dictionary<string, IStatsController> reports = new Dictionary<string, IStatsController>();
70 private Dictionary<UUID, USimStatsData> m_simstatsCounters = new Dictionary<UUID, USimStatsData>(); 70 private Dictionary<UUID, USimStatsData> m_simstatsCounters = new Dictionary<UUID, USimStatsData>();
71 private const int updateStatsMod = 6; 71 private const int updateStatsMod = 6;
72 private int updateLogMod = 1; 72 private int updateLogMod = 1;
73 private volatile int updateLogCounter = 0; 73 private volatile int updateLogCounter = 0;
@@ -96,7 +96,7 @@ namespace OpenSim.Region.UserStatistics
96 96
97 //IConfig startupConfig = config.Configs["Startup"]; 97 //IConfig startupConfig = config.Configs["Startup"];
98 98
99 dbConn = new SqliteConnection("URI=file:../db/LocalUserStatistics.db,version=3"); 99 dbConn = new SqliteConnection("URI=file:LocalUserStatistics.db,version=3");
100 dbConn.Open(); 100 dbConn.Open();
101 CreateTables(dbConn); 101 CreateTables(dbConn);
102 102
@@ -217,7 +217,7 @@ namespace OpenSim.Region.UserStatistics
217 { 217 {
218 m_loglines = readLogLines(10); 218 m_loglines = readLogLines(10);
219 219
220 if (updateLogCounter > 10000) 220 if (updateLogCounter > 10000)
221 updateLogCounter = 1; 221 updateLogCounter = 1;
222 } 222 }
223 223
@@ -228,12 +228,12 @@ namespace OpenSim.Region.UserStatistics
228 ss.ConsumeSimStats(stats); 228 ss.ConsumeSimStats(stats);
229 } 229 }
230 } 230 }
231 } 231 }
232 catch (KeyNotFoundException) 232 catch (KeyNotFoundException)
233 { 233 {
234 } 234 }
235 } 235 }
236 236
237 private Hashtable HandleUnknownCAPSRequest(Hashtable request) 237 private Hashtable HandleUnknownCAPSRequest(Hashtable request)
238 { 238 {
239 //string regpath = request["uri"].ToString(); 239 //string regpath = request["uri"].ToString();
@@ -257,7 +257,7 @@ namespace OpenSim.Region.UserStatistics
257 int response_code = 404; 257 int response_code = 404;
258 string contenttype = "text/html"; 258 string contenttype = "text/html";
259 bool jsonFormatOutput = false; 259 bool jsonFormatOutput = false;
260 260
261 string strOut = string.Empty; 261 string strOut = string.Empty;
262 262
263 // The request patch should be "/SStats/reportName" where 'reportName' 263 // The request patch should be "/SStats/reportName" where 'reportName'
@@ -288,15 +288,15 @@ namespace OpenSim.Region.UserStatistics
288 repParams["SimStats"] = m_simstatsCounters; 288 repParams["SimStats"] = m_simstatsCounters;
289 repParams["LogLines"] = m_loglines; 289 repParams["LogLines"] = m_loglines;
290 repParams["Reports"] = reports; 290 repParams["Reports"] = reports;
291 291
292 concurrencyCounter++; 292 concurrencyCounter++;
293 293
294 if (jsonFormatOutput) 294 if (jsonFormatOutput)
295 { 295 {
296 strOut = rep.RenderJson(rep.ProcessModel(repParams)); 296 strOut = rep.RenderJson(rep.ProcessModel(repParams));
297 contenttype = "text/json"; 297 contenttype = "text/json";
298 } 298 }
299 else 299 else
300 { 300 {
301 strOut = rep.RenderView(rep.ProcessModel(repParams)); 301 strOut = rep.RenderView(rep.ProcessModel(repParams));
302 } 302 }
@@ -312,7 +312,7 @@ namespace OpenSim.Region.UserStatistics
312 } 312 }
313 313
314 concurrencyCounter--; 314 concurrencyCounter--;
315 315
316 response_code = 200; 316 response_code = 200;
317 } 317 }
318 else 318 else
@@ -463,7 +463,7 @@ namespace OpenSim.Region.UserStatistics
463 UUID agentID, Caps caps) 463 UUID agentID, Caps caps)
464 { 464 {
465// m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID); 465// m_log.DebugFormat("[WEB STATS MODULE]: Received viewer starts report from {0}", agentID);
466 466
467 UpdateUserStats(ParseViewerStats(request, agentID), dbConn); 467 UpdateUserStats(ParseViewerStats(request, agentID), dbConn);
468 468
469 return String.Empty; 469 return String.Empty;
@@ -525,7 +525,7 @@ namespace OpenSim.Region.UserStatistics
525 } 525 }
526 } 526 }
527 } 527 }
528 528
529 usd = uid.session_data; 529 usd = uid.session_data;
530 530
531 if (message.Type != OSDType.Map) 531 if (message.Type != OSDType.Map)
@@ -747,16 +747,16 @@ namespace OpenSim.Region.UserStatistics
747 );"; 747 );";
748 748
749 private const string SQL_STATS_TABLE_INSERT = @"INSERT OR REPLACE INTO stats_session_data ( 749 private const string SQL_STATS_TABLE_INSERT = @"INSERT OR REPLACE INTO stats_session_data (
750session_id, agent_id, region_id, last_updated, remote_ip, name_f, name_l, avg_agents_in_view, min_agents_in_view, max_agents_in_view, 750session_id, agent_id, region_id, last_updated, remote_ip, name_f, name_l, avg_agents_in_view, min_agents_in_view, max_agents_in_view,
751mode_agents_in_view, avg_fps, min_fps, max_fps, mode_fps, a_language, mem_use, meters_traveled, avg_ping, min_ping, max_ping, mode_ping, 751mode_agents_in_view, avg_fps, min_fps, max_fps, mode_fps, a_language, mem_use, meters_traveled, avg_ping, min_ping, max_ping, mode_ping,
752regions_visited, run_time, avg_sim_fps, min_sim_fps, max_sim_fps, mode_sim_fps, start_time, client_version, s_cpu, s_gpu, s_os, s_ram, 752regions_visited, run_time, avg_sim_fps, min_sim_fps, max_sim_fps, mode_sim_fps, start_time, client_version, s_cpu, s_gpu, s_os, s_ram,
753d_object_kb, d_texture_kb, d_world_kb, n_in_kb, n_in_pk, n_out_kb, n_out_pk, f_dropped, f_failed_resends, f_invalid, f_off_circuit, 753d_object_kb, d_texture_kb, d_world_kb, n_in_kb, n_in_pk, n_out_kb, n_out_pk, f_dropped, f_failed_resends, f_invalid, f_off_circuit,
754f_resent, f_send_packet 754f_resent, f_send_packet
755) 755)
756VALUES 756VALUES
757( 757(
758:session_id, :agent_id, :region_id, :last_updated, :remote_ip, :name_f, :name_l, :avg_agents_in_view, :min_agents_in_view, :max_agents_in_view, 758:session_id, :agent_id, :region_id, :last_updated, :remote_ip, :name_f, :name_l, :avg_agents_in_view, :min_agents_in_view, :max_agents_in_view,
759:mode_agents_in_view, :avg_fps, :min_fps, :max_fps, :mode_fps, :a_language, :mem_use, :meters_traveled, :avg_ping, :min_ping, :max_ping, :mode_ping, 759:mode_agents_in_view, :avg_fps, :min_fps, :max_fps, :mode_fps, :a_language, :mem_use, :meters_traveled, :avg_ping, :min_ping, :max_ping, :mode_ping,
760:regions_visited, :run_time, :avg_sim_fps, :min_sim_fps, :max_sim_fps, :mode_sim_fps, :start_time, :client_version, :s_cpu, :s_gpu, :s_os, :s_ram, 760:regions_visited, :run_time, :avg_sim_fps, :min_sim_fps, :max_sim_fps, :mode_sim_fps, :start_time, :client_version, :s_cpu, :s_gpu, :s_os, :s_ram,
761:d_object_kb, :d_texture_kb, :d_world_kb, :n_in_kb, :n_in_pk, :n_out_kb, :n_out_pk, :f_dropped, :f_failed_resends, :f_invalid, :f_off_circuit, 761:d_object_kb, :d_texture_kb, :d_world_kb, :n_in_kb, :n_in_pk, :n_out_kb, :n_out_pk, :f_dropped, :f_failed_resends, :f_invalid, :f_off_circuit,
762:f_resent, :f_send_packet 762:f_resent, :f_send_packet
@@ -980,7 +980,7 @@ VALUES
980 980
981 if ((srtArr[srtArr.Length - 1]) == 0 || (srtArr[srtArr.Length - 1]) == 1) 981 if ((srtArr[srtArr.Length - 1]) == 0 || (srtArr[srtArr.Length - 1]) == 1)
982 return 0; 982 return 0;
983 983
984 float freqtest = (float)freq.Length / freq.Rank; 984 float freqtest = (float)freq.Length / freq.Rank;
985 985
986 for (i = 0; i < freqtest; i++) 986 for (i = 0; i < freqtest; i++)
@@ -1116,7 +1116,7 @@ VALUES
1116 public List<float> _sim_fps; 1116 public List<float> _sim_fps;
1117 public List<int> _agents_in_view; 1117 public List<int> _agents_in_view;
1118 } 1118 }
1119 1119
1120 #endregion 1120 #endregion
1121 1121
1122 public class USimStatsData 1122 public class USimStatsData
@@ -1197,7 +1197,7 @@ VALUES
1197 m_pendingDownloads = stats.StatsBlock[17].StatValue; 1197 m_pendingDownloads = stats.StatsBlock[17].StatValue;
1198 m_pendingUploads = stats.StatsBlock[18].StatValue; 1198 m_pendingUploads = stats.StatsBlock[18].StatValue;
1199 m_activeScripts = stats.StatsBlock[19].StatValue; 1199 m_activeScripts = stats.StatsBlock[19].StatValue;
1200 m_scriptLinesPerSecond = stats.StatsBlock[20].StatValue; 1200 m_scriptLinesPerSecond = stats.ExtraStatsBlock[0].StatValue;
1201 } 1201 }
1202 } 1202 }
1203} \ No newline at end of file 1203} \ No newline at end of file
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/CameraOnlyModeModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/CameraOnlyModeModule.cs
index 7ae4223..54f3ab6 100644
--- a/OpenSim/Region/OptionalModules/ViewerSupport/CameraOnlyModeModule.cs
+++ b/OpenSim/Region/OptionalModules/ViewerSupport/CameraOnlyModeModule.cs
@@ -108,8 +108,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
108 { 108 {
109 if (m_Enabled) 109 if (m_Enabled)
110 { 110 {
111 IEntityTransferModule et = m_scene.RequestModuleInterface<IEntityTransferModule>(); 111 m_Helper = new SimulatorFeaturesHelper(scene);
112 m_Helper = new SimulatorFeaturesHelper(scene, et);
113 112
114 ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface<ISimulatorFeaturesModule>(); 113 ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface<ISimulatorFeaturesModule>();
115 if (featuresModule != null) 114 if (featuresModule != null)
@@ -124,7 +123,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
124 private void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features) 123 private void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features)
125 { 124 {
126 m_log.DebugFormat("[CAMERA-ONLY MODE]: OnSimulatorFeaturesRequest in {0}", m_scene.RegionInfo.RegionName); 125 m_log.DebugFormat("[CAMERA-ONLY MODE]: OnSimulatorFeaturesRequest in {0}", m_scene.RegionInfo.RegionName);
127 if (m_Helper.ShouldSend(agentID) && m_Helper.UserLevel(agentID) <= m_UserLevel) 126 if (m_Helper.UserLevel(agentID) <= m_UserLevel)
128 { 127 {
129 OSDMap extrasMap; 128 OSDMap extrasMap;
130 if (features.ContainsKey("OpenSimExtras")) 129 if (features.ContainsKey("OpenSimExtras"))
@@ -162,7 +161,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
162 { 161 {
163 foreach (SceneObjectGroup sog in attachs) 162 foreach (SceneObjectGroup sog in attachs)
164 { 163 {
165 m_log.DebugFormat("[CAMERA-ONLY MODE]: Forcibly detaching attach {0} from {1} in {2}", 164 m_log.DebugFormat("[CAMERA-ONLY MODE]: Forcibly detaching attach {0} from {1} in {2}",
166 sog.Name, sp.Name, m_scene.RegionInfo.RegionName); 165 sog.Name, sp.Name, m_scene.RegionInfo.RegionName);
167 166
168 m_scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, sog); 167 m_scene.AttachmentsModule.DetachSingleAttachmentToInv(sp, sog);
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs
index e76e8f2..ed44a5a 100644
--- a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs
+++ b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicFloaterModule.cs
@@ -134,7 +134,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
134 } 134 }
135 else 135 else
136 { 136 {
137 using (FileStream fs = File.Open(dialogData.XmlName + ".xml", FileMode.Open)) 137 using (FileStream fs = File.Open(dialogData.XmlName + ".xml", FileMode.Open, FileAccess.Read))
138 { 138 {
139 using (StreamReader sr = new StreamReader(fs)) 139 using (StreamReader sr = new StreamReader(fs))
140 xml = sr.ReadToEnd().Replace("\n", ""); 140 xml = sr.ReadToEnd().Replace("\n", "");
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs
index d37369c..9833086 100644
--- a/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs
+++ b/OpenSim/Region/OptionalModules/ViewerSupport/DynamicMenuModule.cs
@@ -131,8 +131,11 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
131 { 131 {
132 foreach (MenuItemData d in m_menuItems[UUID.Zero]) 132 foreach (MenuItemData d in m_menuItems[UUID.Zero])
133 { 133 {
134 if (d.Mode == UserMode.God && (!m_scene.Permissions.IsGod(agentID))) 134 if (!m_scene.Permissions.IsGod(agentID))
135 continue; 135 {
136 if (d.Mode == UserMode.RegionManager && (!m_scene.Permissions.IsAdministrator(agentID)))
137 continue;
138 }
136 139
137 OSDMap loc = null; 140 OSDMap loc = null;
138 switch (d.Location) 141 switch (d.Location)
@@ -156,7 +159,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
156 159
157 if (loc == null) 160 if (loc == null)
158 continue; 161 continue;
159 162
160 loc[d.Title] = OSD.FromString(d.Title); 163 loc[d.Title] = OSD.FromString(d.Title);
161 } 164 }
162 } 165 }
@@ -190,7 +193,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
190 193
191 if (loc == null) 194 if (loc == null)
192 continue; 195 continue;
193 196
194 loc[d.Title] = OSD.FromString(d.Title); 197 loc[d.Title] = OSD.FromString(d.Title);
195 } 198 }
196 } 199 }
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/GodNamesModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/GodNamesModule.cs
index e0537a4..8ed0bb3 100644
--- a/OpenSim/Region/OptionalModules/ViewerSupport/GodNamesModule.cs
+++ b/OpenSim/Region/OptionalModules/ViewerSupport/GodNamesModule.cs
@@ -50,7 +50,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
50 private static List<String> m_lastNames = new List<String>(); 50 private static List<String> m_lastNames = new List<String>();
51 private static List<String> m_fullNames = new List<String>(); 51 private static List<String> m_fullNames = new List<String>();
52 52
53 public void Initialise(IConfigSource config) 53 public void Initialise(IConfigSource config)
54 { 54 {
55 IConfig moduleConfig = config.Configs["GodNames"]; 55 IConfig moduleConfig = config.Configs["GodNames"];
56 56
@@ -133,7 +133,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
133 fnames.Add(name); 133 fnames.Add(name);
134 } 134 }
135 ((OSDMap)namesmap)["full_names"] = fnames; 135 ((OSDMap)namesmap)["full_names"] = fnames;
136 136
137 OSDArray lnames = new OSDArray(); 137 OSDArray lnames = new OSDArray();
138 foreach (string name in m_lastNames) { 138 foreach (string name in m_lastNames) {
139 lnames.Add(name); 139 lnames.Add(name);
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/SimulatorFeaturesHelper.cs b/OpenSim/Region/OptionalModules/ViewerSupport/SimulatorFeaturesHelper.cs
index 2661522..2c2042d 100644
--- a/OpenSim/Region/OptionalModules/ViewerSupport/SimulatorFeaturesHelper.cs
+++ b/OpenSim/Region/OptionalModules/ViewerSupport/SimulatorFeaturesHelper.cs
@@ -49,90 +49,15 @@ using TeleportFlags = OpenSim.Framework.Constants.TeleportFlags;
49 49
50namespace OpenSim.Region.OptionalModules.ViewerSupport 50namespace OpenSim.Region.OptionalModules.ViewerSupport
51{ 51{
52 public class SimulatorFeaturesHelper 52 public class SimulatorFeaturesHelper
53 { 53 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 55
56 private IEntityTransferModule m_TransferModule;
57 private Scene m_scene; 56 private Scene m_scene;
58 57
59 private struct RegionSend { 58 public SimulatorFeaturesHelper(Scene scene)
60 public UUID region;
61 public bool send;
62 };
63 // Using a static cache so that we don't have to perform the time-consuming tests
64 // in ShouldSend on Extra SimFeatures that go on the same response but come from
65 // different modules.
66 // This cached is indexed on the agentID and maps to a list of regions
67 private static ExpiringCache<UUID, List<RegionSend>> m_Cache = new ExpiringCache<UUID, List<RegionSend>>();
68 private const double TIMEOUT = 1.0; // time in cache
69
70 public SimulatorFeaturesHelper(Scene scene, IEntityTransferModule et)
71 { 59 {
72 m_scene = scene; 60 m_scene = scene;
73 m_TransferModule = et;
74 }
75
76 public bool ShouldSend(UUID agentID)
77 {
78 List<RegionSend> rsendlist;
79 RegionSend rsend;
80 if (m_Cache.TryGetValue(agentID, out rsendlist))
81 {
82 rsend = rsendlist.Find(r => r.region == m_scene.RegionInfo.RegionID);
83 if (rsend.region != UUID.Zero) // Found it
84 {
85 return rsend.send;
86 }
87 }
88
89 // Relatively complex logic for deciding whether to send the extra SimFeature or not.
90 // This is because the viewer calls this cap to all sims that it knows about,
91 // including the departing sims and non-neighbors (those that are cached).
92 rsend.region = m_scene.RegionInfo.RegionID;
93 rsend.send = false;
94 IClientAPI client = null;
95 int counter = 200;
96
97 // Let's wait a little to see if we get a client here
98 while (!m_scene.TryGetClient(agentID, out client) && counter-- > 0)
99 Thread.Sleep(50);
100
101 if (client != null)
102 {
103 ScenePresence sp = WaitGetScenePresence(agentID);
104
105 if (sp != null)
106 {
107 // On the receiving region, the call to this cap may arrive before
108 // the agent is root. Make sure we only proceed from here when the agent
109 // has been made root
110 counter = 200;
111 while ((sp.IsInTransit || sp.IsChildAgent) && counter-- > 0)
112 {
113 Thread.Sleep(50);
114 }
115
116 // The viewer calls this cap on the departing sims too. Make sure
117 // that we only proceed after the agent is not in transit anymore.
118 // The agent must be root and not going anywhere
119 if (!sp.IsChildAgent && !m_TransferModule.IsInTransit(agentID))
120 rsend.send = true;
121
122 }
123 }
124 //else
125 // m_log.DebugFormat("[XXX]: client is null");
126
127
128 if (rsendlist == null)
129 {
130 rsendlist = new List<RegionSend>();
131 m_Cache.AddOrUpdate(agentID, rsendlist, TIMEOUT);
132 }
133 rsendlist.Add(rsend);
134
135 return rsend.send;
136 } 61 }
137 62
138 public int UserLevel(UUID agentID) 63 public int UserLevel(UUID agentID)
@@ -144,28 +69,5 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
144 69
145 return level; 70 return level;
146 } 71 }
147
148 protected virtual ScenePresence WaitGetScenePresence(UUID agentID)
149 {
150 int ntimes = 20;
151 ScenePresence sp = null;
152 while ((sp = m_scene.GetScenePresence(agentID)) == null && (ntimes-- > 0))
153 Thread.Sleep(1000);
154
155 if (sp == null)
156 m_log.WarnFormat(
157 "[XXX]: Did not find presence with id {0} in {1} before timeout",
158 agentID, m_scene.RegionInfo.RegionName);
159 else
160 {
161 ntimes = 10;
162 while (sp.IsInTransit && (ntimes-- > 0))
163 Thread.Sleep(1000);
164 }
165
166 return sp;
167 }
168
169 } 72 }
170
171} 73}
diff --git a/OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs b/OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs
index 3fe922d..fa8fc66 100644
--- a/OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs
+++ b/OpenSim/Region/OptionalModules/ViewerSupport/SpecialUIModule.cs
@@ -102,8 +102,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
102 { 102 {
103 if (m_Enabled) 103 if (m_Enabled)
104 { 104 {
105 IEntityTransferModule et = m_scene.RequestModuleInterface<IEntityTransferModule>(); 105 m_Helper = new SimulatorFeaturesHelper(scene);
106 m_Helper = new SimulatorFeaturesHelper(scene, et);
107 106
108 ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface<ISimulatorFeaturesModule>(); 107 ISimulatorFeaturesModule featuresModule = m_scene.RequestModuleInterface<ISimulatorFeaturesModule>();
109 if (featuresModule != null) 108 if (featuresModule != null)
@@ -118,7 +117,7 @@ namespace OpenSim.Region.OptionalModules.ViewerSupport
118 private void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features) 117 private void OnSimulatorFeaturesRequest(UUID agentID, ref OSDMap features)
119 { 118 {
120 m_log.DebugFormat("[SPECIAL UI]: OnSimulatorFeaturesRequest in {0}", m_scene.RegionInfo.RegionName); 119 m_log.DebugFormat("[SPECIAL UI]: OnSimulatorFeaturesRequest in {0}", m_scene.RegionInfo.RegionName);
121 if (m_Helper.ShouldSend(agentID) && m_Helper.UserLevel(agentID) <= m_UserLevel) 120 if (m_Helper.UserLevel(agentID) <= m_UserLevel)
122 { 121 {
123 OSDMap extrasMap; 122 OSDMap extrasMap;
124 OSDMap specialUI = new OSDMap(); 123 OSDMap specialUI = new OSDMap();
diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs
index ceb3332..a14d819 100644
--- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs
+++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs
@@ -59,70 +59,58 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
59 /// </summary> 59 /// </summary>
60 /// <remarks> 60 /// <remarks>
61 /// Config Settings Documentation. 61 /// Config Settings Documentation.
62 /// Each configuration setting can be specified in two places: OpenSim.ini or Regions.ini. 62 /// Configuration setting can be specified in two places: OpenSim.ini and/or Regions.ini.
63 /// If specified in Regions.ini, the settings should be within the region's section name. 63 ///
64 /// If specified in OpenSim.ini, the settings should be within the [AutoBackupModule] section. 64 /// OpenSim.ini only settings section [AutoBackupModule]
65 /// AutoBackupModuleEnabled: True/False. Default: False. If True, use the auto backup module.
66 /// if false module is disable and all rest is ignored
67 /// AutoBackupInterval: Double, non-negative value. Default: 720 (12 hours).
68 /// The number of minutes between each backup attempt.
69 /// AutoBackupDir: String. Default: "." (the current directory).
70 /// A directory (absolute or relative) where backups should be saved.
71 /// AutoBackupKeepFilesForDays remove files older than this number of days. 0 disables
72 ///
73 /// Next can be set on OpenSim.ini, as default, and or per region in Regions.ini
65 /// Region-specific settings take precedence. 74 /// Region-specific settings take precedence.
66 /// 75 ///
67 /// AutoBackupModuleEnabled: True/False. Default: False. If True, use the auto backup module. This setting does not support per-region basis. 76 /// AutoBackup: True/False. Default: False. If True, activate auto backup functionality.
68 /// All other settings under [AutoBackupModule] are ignored if AutoBackupModuleEnabled is false, even per-region settings! 77 /// controls backup per region, with default optionaly set on OpenSim.ini
69 /// AutoBackup: True/False. Default: False. If True, activate auto backup functionality. 78
70 /// This is the only required option for enabling auto-backup; the other options have sane defaults.
71 /// If False for a particular region, the auto-backup module becomes a no-op for the region, and all other AutoBackup* settings are ignored.
72 /// If False globally (the default), only regions that specifically override it in Regions.ini will get AutoBackup functionality.
73 /// AutoBackupInterval: Double, non-negative value. Default: 720 (12 hours).
74 /// The number of minutes between each backup attempt.
75 /// If a negative or zero value is given, it is equivalent to setting AutoBackup = False.
76 /// AutoBackupBusyCheck: True/False. Default: True.
77 /// If True, we will only take an auto-backup if a set of conditions are met.
78 /// These conditions are heuristics to try and avoid taking a backup when the sim is busy.
79 /// AutoBackupSkipAssets 79 /// AutoBackupSkipAssets
80 /// If true, assets are not saved to the oar file. Considerably reduces impact on simulator when backing up. Intended for when assets db is backed up separately 80 /// If true, assets are not saved to the oar file. Considerably reduces impact on simulator when backing up. Intended for when assets db is backed up separately
81 /// AutoBackupKeepFilesForDays 81 /// AutoBackupKeepFilesForDays
82 /// Backup files older than this value (in days) are deleted during the current backup process, 0 will disable this and keep all backup files indefinitely 82 /// Backup files older than this value (in days) are deleted during the current backup process, 0 will disable this and keep all backup files indefinitely
83 /// AutoBackupScript: String. Default: not specified (disabled). 83 /// AutoBackupScript: String. Default: not specified (disabled).
84 /// File path to an executable script or binary to run when an automatic backup is taken. 84 /// File path to an executable script or binary to run when an automatic backup is taken.
85 /// The file should really be (Windows) an .exe or .bat, or (Linux/Mac) a shell script or binary. 85 /// The file should really be (Windows) an .exe or .bat, or (Linux/Mac) a shell script or binary.
86 /// Trying to "run" directories, or things with weird file associations on Win32, might cause unexpected results! 86 /// Trying to "run" directories, or things with weird file associations on Win32, might cause unexpected results!
87 /// argv[1] of the executed file/script will be the file name of the generated OAR. 87 /// argv[1] of the executed file/script will be the file name of the generated OAR.
88 /// If the process can't be spawned for some reason (file not found, no execute permission, etc), write a warning to the console. 88 /// If the process can't be spawned for some reason (file not found, no execute permission, etc), write a warning to the console.
89 /// AutoBackupNaming: string. Default: Time. 89 /// AutoBackupNaming: string. Default: Time.
90 /// One of three strings (case insensitive): 90 /// One of three strings (case insensitive):
91 /// "Time": Current timestamp is appended to file name. An existing file will never be overwritten. 91 /// "Time": Current timestamp is appended to file name. An existing file will never be overwritten.
92 /// "Sequential": A number is appended to the file name. So if RegionName_x.oar exists, we'll save to RegionName_{x+1}.oar next. An existing file will never be overwritten. 92 /// "Sequential": A number is appended to the file name. So if RegionName_x.oar exists, we'll save to RegionName_{x+1}.oar next. An existing file will never be overwritten.
93 /// "Overwrite": Always save to file named "${AutoBackupDir}/RegionName.oar", even if we have to overwrite an existing file. 93 /// "Overwrite": Always save to file named "${AutoBackupDir}/RegionName.oar", even if we have to overwrite an existing file.
94 /// AutoBackupDir: String. Default: "." (the current directory).
95 /// A directory (absolute or relative) where backups should be saved.
96 /// AutoBackupDilationThreshold: float. Default: 0.5. Lower bound on time dilation required for BusyCheck heuristics to pass.
97 /// If the time dilation is below this value, don't take a backup right now.
98 /// AutoBackupAgentThreshold: int. Default: 10. Upper bound on # of agents in region required for BusyCheck heuristics to pass.
99 /// If the number of agents is greater than this value, don't take a backup right now
100 /// Save memory by setting low initial capacities. Minimizes impact in common cases of all regions using same interval, and instances hosting 1 ~ 4 regions.
101 /// Also helps if you don't want AutoBackup at all.
102 /// </remarks> 94 /// </remarks>
103 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AutoBackupModule")] 95 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AutoBackupModule")]
104 public class AutoBackupModule : ISharedRegionModule 96 public class AutoBackupModule : ISharedRegionModule
105 { 97 {
106 private static readonly ILog m_log = 98 private static readonly ILog m_log =
107 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 99 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
108 private readonly Dictionary<Guid, IScene> m_pendingSaves = new Dictionary<Guid, IScene>(1);
109 private readonly AutoBackupModuleState m_defaultState = new AutoBackupModuleState(); 100 private readonly AutoBackupModuleState m_defaultState = new AutoBackupModuleState();
110 private readonly Dictionary<IScene, AutoBackupModuleState> m_states = 101 private readonly Dictionary<IScene, AutoBackupModuleState> m_states =
111 new Dictionary<IScene, AutoBackupModuleState>(1); 102 new Dictionary<IScene, AutoBackupModuleState>(1);
112 private readonly Dictionary<Timer, List<IScene>> m_timerMap =
113 new Dictionary<Timer, List<IScene>>(1);
114 private readonly Dictionary<double, Timer> m_timers = new Dictionary<double, Timer>(1);
115 103
116 private delegate T DefaultGetter<T>(string settingName, T defaultValue); 104 private delegate T DefaultGetter<T>(string settingName, T defaultValue);
117 private bool m_enabled; 105 private bool m_enabled;
118 private ICommandConsole m_console; 106 private ICommandConsole m_console;
119 private List<Scene> m_Scenes = new List<Scene> (); 107 private List<Scene> m_Scenes = new List<Scene> ();
120 108 private Timer m_masterTimer;
121 109 private bool m_busy;
122 /// <summary> 110 private int m_KeepFilesForDays = -1;
123 /// Whether the shared module should be enabled at all. NOT the same as m_Enabled in AutoBackupModuleState! 111 private string m_backupDir;
124 /// </summary> 112 private bool m_doneFirst;
125 private bool m_closed; 113 private double m_baseInterval;
126 114
127 private IConfigSource m_configSource; 115 private IConfigSource m_configSource;
128 116
@@ -159,36 +147,38 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
159 void IRegionModuleBase.Initialise(IConfigSource source) 147 void IRegionModuleBase.Initialise(IConfigSource source)
160 { 148 {
161 // Determine if we have been enabled at all in OpenSim.ini -- this is part and parcel of being an optional module 149 // Determine if we have been enabled at all in OpenSim.ini -- this is part and parcel of being an optional module
162 this.m_configSource = source; 150 m_configSource = source;
163 IConfig moduleConfig = source.Configs["AutoBackupModule"]; 151 IConfig moduleConfig = source.Configs["AutoBackupModule"];
164 if (moduleConfig == null) 152 if (moduleConfig == null)
165 { 153 {
166 this.m_enabled = false; 154 m_enabled = false;
167 return; 155 return;
168 } 156 }
169 else
170 {
171 this.m_enabled = moduleConfig.GetBoolean("AutoBackupModuleEnabled", false);
172 if (this.m_enabled)
173 {
174 m_log.Info("[AUTO BACKUP]: AutoBackupModule enabled");
175 }
176 else
177 {
178 return;
179 }
180 }
181 157
182 Timer defTimer = new Timer(43200000); 158 m_enabled = moduleConfig.GetBoolean("AutoBackupModuleEnabled", false);
183 this.m_defaultState.Timer = defTimer; 159 if(!m_enabled)
184 this.m_timers.Add(43200000, defTimer); 160 return;
185 defTimer.Elapsed += this.HandleElapsed; 161
186 defTimer.AutoReset = true; 162 ParseDefaultConfig(moduleConfig);
187 defTimer.Start(); 163 if(!m_enabled)
164 return;
165
166 m_log.Debug("[AUTO BACKUP]: Default config:");
167 m_log.Debug(m_defaultState.ToString());
168
169 m_log.Info("[AUTO BACKUP]: AutoBackupModule enabled");
170 m_masterTimer = new Timer();
171 m_masterTimer.Interval = m_baseInterval;
172 m_masterTimer.Elapsed += HandleElapsed;
173 m_masterTimer.AutoReset = false;
174
175 m_console = MainConsole.Instance;
188 176
189 AutoBackupModuleState abms = this.ParseConfig(null, true); 177 m_console.Commands.AddCommand (
190 m_log.Debug("[AUTO BACKUP]: Here is the default config:"); 178 "AutoBackup", true, "dooarbackup",
191 m_log.Debug(abms.ToString()); 179 "dooarbackup <regionName> | ALL",
180 "saves the single region <regionName> to a oar or ALL regions in instance to oars, using same settings as AutoBackup. Note it restarts time interval", DoBackup);
181 m_busy = true;
192 } 182 }
193 183
194 /// <summary> 184 /// <summary>
@@ -196,13 +186,11 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
196 /// </summary> 186 /// </summary>
197 void IRegionModuleBase.Close() 187 void IRegionModuleBase.Close()
198 { 188 {
199 if (!this.m_enabled) 189 if (!m_enabled)
200 {
201 return; 190 return;
202 }
203 191
204 // We don't want any timers firing while the sim's coming down; strange things may happen. 192 // We don't want any timers firing while the sim's coming down; strange things may happen.
205 this.StopAllTimers(); 193 m_masterTimer.Dispose();
206 } 194 }
207 195
208 /// <summary> 196 /// <summary>
@@ -211,18 +199,11 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
211 /// <param name="scene"></param> 199 /// <param name="scene"></param>
212 void IRegionModuleBase.AddRegion (Scene scene) 200 void IRegionModuleBase.AddRegion (Scene scene)
213 { 201 {
214 if (!this.m_enabled) { 202 if (!m_enabled)
215 return; 203 return;
216 }
217 lock (m_Scenes) {
218 m_Scenes.Add (scene);
219 }
220 m_console = MainConsole.Instance;
221 204
222 m_console.Commands.AddCommand ( 205 lock (m_Scenes)
223 "AutoBackup", false, "dobackup", 206 m_Scenes.Add (scene);
224 "dobackup",
225 "do backup.", DoBackup);
226 } 207 }
227 208
228 /// <summary> 209 /// <summary>
@@ -231,28 +212,14 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
231 /// <param name="scene">The scene (region) to stop performing AutoBackup on.</param> 212 /// <param name="scene">The scene (region) to stop performing AutoBackup on.</param>
232 void IRegionModuleBase.RemoveRegion(Scene scene) 213 void IRegionModuleBase.RemoveRegion(Scene scene)
233 { 214 {
234 if (!this.m_enabled) 215 if (m_enabled)
235 {
236 return; 216 return;
237 }
238 m_Scenes.Remove (scene);
239 if (this.m_states.ContainsKey(scene))
240 {
241 AutoBackupModuleState abms = this.m_states[scene];
242 217
243 // Remove this scene out of the timer map list 218 lock(m_Scenes)
244 Timer timer = abms.Timer; 219 {
245 List<IScene> list = this.m_timerMap[timer]; 220 if (m_states.ContainsKey(scene))
246 list.Remove(scene); 221 m_states.Remove(scene);
247 222 m_Scenes.Remove(scene);
248 // Shut down the timer if this was the last scene for the timer
249 if (list.Count == 0)
250 {
251 this.m_timerMap.Remove(timer);
252 this.m_timers.Remove(timer.Interval);
253 timer.Close();
254 }
255 this.m_states.Remove(scene);
256 } 223 }
257 } 224 }
258 225
@@ -263,22 +230,29 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
263 /// <param name="scene">The scene to (possibly) perform AutoBackup on.</param> 230 /// <param name="scene">The scene to (possibly) perform AutoBackup on.</param>
264 void IRegionModuleBase.RegionLoaded(Scene scene) 231 void IRegionModuleBase.RegionLoaded(Scene scene)
265 { 232 {
266 if (!this.m_enabled) 233 if (!m_enabled)
267 {
268 return; 234 return;
269 }
270 235
271 // This really ought not to happen, but just in case, let's pretend it didn't... 236 // This really ought not to happen, but just in case, let's pretend it didn't...
272 if (scene == null) 237 if (scene == null)
273 {
274 return; 238 return;
275 }
276 239
277 AutoBackupModuleState abms = this.ParseConfig(scene, false); 240 AutoBackupModuleState abms = ParseConfig(scene);
278 m_log.Debug("[AUTO BACKUP]: Config for " + scene.RegionInfo.RegionName); 241 if(abms == null)
279 m_log.Debug((abms == null ? "DEFAULT" : abms.ToString())); 242 {
243 m_log.Debug("[AUTO BACKUP]: Config for " + scene.RegionInfo.RegionName);
244 m_log.Debug("DEFAULT");
245 abms = new AutoBackupModuleState(m_defaultState);
246 }
247 else
248 {
249 m_log.Debug("[AUTO BACKUP]: Config for " + scene.RegionInfo.RegionName);
250 m_log.Debug(abms.ToString());
251 }
280 252
281 m_states.Add(scene, abms); 253 m_states.Add(scene, abms);
254 m_busy = false;
255 m_masterTimer.Start();
282 } 256 }
283 257
284 /// <summary> 258 /// <summary>
@@ -292,356 +266,174 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
292 266
293 private void DoBackup (string module, string[] args) 267 private void DoBackup (string module, string[] args)
294 { 268 {
295 if (args.Length != 2) { 269 if (!m_enabled)
296 MainConsole.Instance.OutputFormat ("Usage: dobackup <regionname>");
297 return; 270 return;
298 }
299 bool found = false;
300 string name = args [1];
301 lock (m_Scenes) {
302 foreach (Scene s in m_Scenes) {
303 string test = s.Name.ToString ();
304 if (test == name) {
305 found = true;
306 DoRegionBackup (s);
307 }
308 }
309 if (!found) {
310 MainConsole.Instance.OutputFormat ("No such region {0}. Nothing to backup", name);
311 }
312 }
313 }
314 271
315 /// <summary> 272 if (args.Length != 2)
316 /// Set up internal state for a given scene. Fairly complex code.
317 /// When this method returns, we've started auto-backup timers, put members in Dictionaries, and created a State object for this scene.
318 /// </summary>
319 /// <param name="scene">The scene to look at.</param>
320 /// <param name="parseDefault">Whether this call is intended to figure out what we consider the "default" config (applied to all regions unless overridden by per-region settings).</param>
321 /// <returns>An AutoBackupModuleState contains most information you should need to know relevant to auto-backup, as applicable to a single region.</returns>
322 private AutoBackupModuleState ParseConfig(IScene scene, bool parseDefault)
323 {
324 string sRegionName;
325 string sRegionLabel;
326// string prepend;
327 AutoBackupModuleState state;
328
329 if (parseDefault)
330 {
331 sRegionName = null;
332 sRegionLabel = "DEFAULT";
333// prepend = "";
334 state = this.m_defaultState;
335 }
336 else
337 {
338 sRegionName = scene.RegionInfo.RegionName;
339 sRegionLabel = sRegionName;
340// prepend = sRegionName + ".";
341 state = null;
342 }
343
344 // Read the config settings and set variables.
345 IConfig regionConfig = (scene != null ? scene.Config.Configs[sRegionName] : null);
346 IConfig config = this.m_configSource.Configs["AutoBackupModule"];
347 if (config == null)
348 { 273 {
349 // defaultState would be disabled too if the section doesn't exist. 274 MainConsole.Instance.OutputFormat ("Usage: dooarbackup <regionname>");
350 state = this.m_defaultState; 275 return;
351 return state;
352 }
353
354 bool tmpEnabled = ResolveBoolean("AutoBackup", this.m_defaultState.Enabled, config, regionConfig);
355 if (state == null && tmpEnabled != this.m_defaultState.Enabled)
356 //Varies from default state
357 {
358 state = new AutoBackupModuleState();
359 } 276 }
360 277
361 if (state != null) 278 if(m_busy)
362 { 279 {
363 state.Enabled = tmpEnabled; 280 MainConsole.Instance.OutputFormat ("Already doing a backup, please try later");
281 return;
364 } 282 }
365 283
366 // If you don't want AutoBackup, we stop. 284 m_masterTimer.Stop();
367 if ((state == null && !this.m_defaultState.Enabled) || (state != null && !state.Enabled)) 285 m_busy = true;
368 {
369 return state;
370 }
371 else
372 {
373 m_log.Info("[AUTO BACKUP]: Region " + sRegionLabel + " is AutoBackup ENABLED.");
374 }
375 286
376 // Borrow an existing timer if one exists for the same interval; otherwise, make a new one. 287 bool found = false;
377 double interval = 288 string name = args [1];
378 this.ResolveDouble("AutoBackupInterval", this.m_defaultState.IntervalMinutes, 289 Scene[] scenes;
379 config, regionConfig) * 60000.0; 290 lock (m_Scenes)
380 if (state == null && interval != this.m_defaultState.IntervalMinutes * 60000.0) 291 scenes = m_Scenes.ToArray();
381 {
382 state = new AutoBackupModuleState();
383 }
384 292
385 if (this.m_timers.ContainsKey(interval)) 293 if(scenes == null)
386 { 294 return;
387 if (state != null)
388 {
389 state.Timer = this.m_timers[interval];
390 }
391 m_log.Debug("[AUTO BACKUP]: Reusing timer for " + interval + " msec for region " +
392 sRegionLabel);
393 }
394 else
395 {
396 // 0 or negative interval == do nothing.
397 if (interval <= 0.0 && state != null)
398 {
399 state.Enabled = false;
400 return state;
401 }
402 if (state == null)
403 {
404 state = new AutoBackupModuleState();
405 }
406 Timer tim = new Timer(interval);
407 state.Timer = tim;
408 //Milliseconds -> minutes
409 this.m_timers.Add(interval, tim);
410 tim.Elapsed += this.HandleElapsed;
411 tim.AutoReset = true;
412 tim.Start();
413 }
414 295
415 // Add the current region to the list of regions tied to this timer. 296 Scene s;
416 if (scene != null) 297 try
417 { 298 {
418 if (state != null) 299 if(name == "ALL")
419 { 300 {
420 if (this.m_timerMap.ContainsKey(state.Timer)) 301 for(int i = 0; i < scenes.Length; i++)
421 { 302 {
422 this.m_timerMap[state.Timer].Add(scene); 303 s = scenes[i];
423 } 304 DoRegionBackup(s);
424 else 305 if (!m_enabled)
425 { 306 return;
426 List<IScene> scns = new List<IScene>(1);
427 scns.Add(scene);
428 this.m_timerMap.Add(state.Timer, scns);
429 } 307 }
308 return;
430 } 309 }
431 else 310
311 for(int i = 0; i < scenes.Length; i++)
432 { 312 {
433 if (this.m_timerMap.ContainsKey(this.m_defaultState.Timer)) 313 s = scenes[i];
314 if (s.Name == name)
434 { 315 {
435 this.m_timerMap[this.m_defaultState.Timer].Add(scene); 316 found = true;
436 } 317 DoRegionBackup(s);
437 else 318 break;
438 {
439 List<IScene> scns = new List<IScene>(1);
440 scns.Add(scene);
441 this.m_timerMap.Add(this.m_defaultState.Timer, scns);
442 } 319 }
443 } 320 }
444 } 321 }
445 322 catch { }
446 bool tmpBusyCheck = ResolveBoolean("AutoBackupBusyCheck", 323 finally
447 this.m_defaultState.BusyCheck, config, regionConfig);
448 if (state == null && tmpBusyCheck != this.m_defaultState.BusyCheck)
449 { 324 {
450 state = new AutoBackupModuleState(); 325 if (m_enabled)
451 } 326 m_masterTimer.Start();
327 m_busy = false;
328 }
329 if (!found)
330 MainConsole.Instance.OutputFormat ("No such region {0}. Nothing to backup", name);
331 }
452 332
453 if (state != null) 333 private void ParseDefaultConfig(IConfig config)
454 { 334 {
455 state.BusyCheck = tmpBusyCheck;
456 }
457 335
458 // Included Option To Skip Assets 336 m_backupDir = ".";
459 bool tmpSkipAssets = ResolveBoolean("AutoBackupSkipAssets", 337 string backupDir = config.GetString("AutoBackupDir", ".");
460 this.m_defaultState.SkipAssets, config, regionConfig); 338 if (backupDir != ".")
461 if (state == null && tmpSkipAssets != this.m_defaultState.SkipAssets)
462 { 339 {
463 state = new AutoBackupModuleState(); 340 try
341 {
342 DirectoryInfo dirinfo = new DirectoryInfo(backupDir);
343 if (!dirinfo.Exists)
344 dirinfo.Create();
345 }
346 catch (Exception e)
347 {
348 m_enabled = false;
349 m_log.WarnFormat("[AUTO BACKUP]: Error accessing backup folder {0}. Module disabled. {1}",
350 backupDir, e);
351 return;
352 }
464 } 353 }
354 m_backupDir = backupDir;
465 355
466 if (state != null) 356 double interval = config.GetDouble("AutoBackupInterval", 720);
467 { 357 interval *= 60000.0;
468 state.SkipAssets = tmpSkipAssets; 358 m_baseInterval = interval;
469 }
470 359
471 // How long to keep backup files in days, 0 Disables this feature 360 // How long to keep backup files in days, 0 Disables this feature
472 int tmpKeepFilesForDays = ResolveInt("AutoBackupKeepFilesForDays", 361 m_KeepFilesForDays = config.GetInt("AutoBackupKeepFilesForDays",m_KeepFilesForDays);
473 this.m_defaultState.KeepFilesForDays, config, regionConfig);
474 if (state == null && tmpKeepFilesForDays != this.m_defaultState.KeepFilesForDays)
475 {
476 state = new AutoBackupModuleState();
477 }
478 362
479 if (state != null) 363 m_defaultState.Enabled = config.GetBoolean("AutoBackup", m_defaultState.Enabled);
480 { 364
481 state.KeepFilesForDays = tmpKeepFilesForDays; 365 m_defaultState.SkipAssets = config.GetBoolean("AutoBackupSkipAssets",m_defaultState.SkipAssets);
482 }
483 366
484 // Set file naming algorithm 367 // Set file naming algorithm
485 string stmpNamingType = ResolveString("AutoBackupNaming", 368 string stmpNamingType = config.GetString("AutoBackupNaming", m_defaultState.NamingType.ToString());
486 this.m_defaultState.NamingType.ToString(), config, regionConfig);
487 NamingType tmpNamingType; 369 NamingType tmpNamingType;
488 if (stmpNamingType.Equals("Time", StringComparison.CurrentCultureIgnoreCase)) 370 if (stmpNamingType.Equals("Time", StringComparison.CurrentCultureIgnoreCase))
489 {
490 tmpNamingType = NamingType.Time; 371 tmpNamingType = NamingType.Time;
491 }
492 else if (stmpNamingType.Equals("Sequential", StringComparison.CurrentCultureIgnoreCase)) 372 else if (stmpNamingType.Equals("Sequential", StringComparison.CurrentCultureIgnoreCase))
493 {
494 tmpNamingType = NamingType.Sequential; 373 tmpNamingType = NamingType.Sequential;
495 }
496 else if (stmpNamingType.Equals("Overwrite", StringComparison.CurrentCultureIgnoreCase)) 374 else if (stmpNamingType.Equals("Overwrite", StringComparison.CurrentCultureIgnoreCase))
497 {
498 tmpNamingType = NamingType.Overwrite; 375 tmpNamingType = NamingType.Overwrite;
499 }
500 else 376 else
501 { 377 {
502 m_log.Warn("Unknown naming type specified for region " + sRegionLabel + ": " + 378 m_log.Warn("Unknown naming type specified for Default");
503 stmpNamingType);
504 tmpNamingType = NamingType.Time; 379 tmpNamingType = NamingType.Time;
505 } 380 }
381 m_defaultState.NamingType = tmpNamingType;
506 382
507 if (state == null && tmpNamingType != this.m_defaultState.NamingType) 383 m_defaultState.Script = config.GetString("AutoBackupScript", m_defaultState.Script);
508 {
509 state = new AutoBackupModuleState();
510 }
511 384
512 if (state != null) 385 }
513 {
514 state.NamingType = tmpNamingType;
515 }
516 386
517 string tmpScript = ResolveString("AutoBackupScript", 387 /// <summary>
518 this.m_defaultState.Script, config, regionConfig); 388 /// Set up internal state for a given scene. Fairly complex code.
519 if (state == null && tmpScript != this.m_defaultState.Script) 389 /// When this method returns, we've started auto-backup timers, put members in Dictionaries, and created a State object for this scene.
520 { 390 /// </summary>
521 state = new AutoBackupModuleState(); 391 /// <param name="scene">The scene to look at.</param>
522 } 392 /// <param name="parseDefault">Whether this call is intended to figure out what we consider the "default" config (applied to all regions unless overridden by per-region settings).</param>
393 /// <returns>An AutoBackupModuleState contains most information you should need to know relevant to auto-backup, as applicable to a single region.</returns>
394 private AutoBackupModuleState ParseConfig(IScene scene)
395 {
396 if(scene == null)
397 return null;
523 398
524 if (state != null) 399 string sRegionName;
525 { 400 AutoBackupModuleState state = null;
526 state.Script = tmpScript;
527 }
528 401
529 string tmpBackupDir = ResolveString("AutoBackupDir", ".", config, regionConfig); 402 sRegionName = scene.RegionInfo.RegionName;
530 if (state == null && tmpBackupDir != this.m_defaultState.BackupDir)
531 {
532 state = new AutoBackupModuleState();
533 }
534 403
535 if (state != null) 404 // Read the config settings and set variables.
536 { 405 IConfig regionConfig = scene.Config.Configs[sRegionName];
537 state.BackupDir = tmpBackupDir; 406 if (regionConfig == null)
538 // Let's give the user some convenience and auto-mkdir 407 return null;
539 if (state.BackupDir != ".")
540 {
541 try
542 {
543 DirectoryInfo dirinfo = new DirectoryInfo(state.BackupDir);
544 if (!dirinfo.Exists)
545 {
546 dirinfo.Create();
547 }
548 }
549 catch (Exception e)
550 {
551 m_log.Warn(
552 "[AUTO BACKUP]: BAD NEWS. You won't be able to save backups to directory " +
553 state.BackupDir +
554 " because it doesn't exist or there's a permissions issue with it. Here's the exception.",
555 e);
556 }
557 }
558 }
559 408
560 if(state == null) 409 state = new AutoBackupModuleState();
561 return m_defaultState;
562 410
563 return state; 411 state.Enabled = regionConfig.GetBoolean("AutoBackup", m_defaultState.Enabled);
564 }
565 412
566 /// <summary> 413 // Included Option To Skip Assets
567 /// Helper function for ParseConfig. 414 state.SkipAssets = regionConfig.GetBoolean("AutoBackupSkipAssets", m_defaultState.SkipAssets);
568 /// </summary>
569 /// <param name="settingName"></param>
570 /// <param name="defaultValue"></param>
571 /// <param name="global"></param>
572 /// <param name="local"></param>
573 /// <returns></returns>
574 private bool ResolveBoolean(string settingName, bool defaultValue, IConfig global, IConfig local)
575 {
576 if(local != null)
577 {
578 return local.GetBoolean(settingName, global.GetBoolean(settingName, defaultValue));
579 }
580 else
581 {
582 return global.GetBoolean(settingName, defaultValue);
583 }
584 }
585 415
586 /// <summary> 416 // Set file naming algorithm
587 /// Helper function for ParseConfig. 417 string stmpNamingType = regionConfig.GetString("AutoBackupNaming", m_defaultState.NamingType.ToString());
588 /// </summary> 418 NamingType tmpNamingType;
589 /// <param name="settingName"></param> 419 if (stmpNamingType.Equals("Time", StringComparison.CurrentCultureIgnoreCase))
590 /// <param name="defaultValue"></param> 420 tmpNamingType = NamingType.Time;
591 /// <param name="global"></param> 421 else if (stmpNamingType.Equals("Sequential", StringComparison.CurrentCultureIgnoreCase))
592 /// <param name="local"></param> 422 tmpNamingType = NamingType.Sequential;
593 /// <returns></returns> 423 else if (stmpNamingType.Equals("Overwrite", StringComparison.CurrentCultureIgnoreCase))
594 private double ResolveDouble(string settingName, double defaultValue, IConfig global, IConfig local) 424 tmpNamingType = NamingType.Overwrite;
595 {
596 if (local != null)
597 {
598 return local.GetDouble(settingName, global.GetDouble(settingName, defaultValue));
599 }
600 else 425 else
601 { 426 {
602 return global.GetDouble(settingName, defaultValue); 427 m_log.Warn("Unknown naming type specified for region " + sRegionName + ": " +
428 stmpNamingType);
429 tmpNamingType = NamingType.Time;
603 } 430 }
604 } 431 m_defaultState.NamingType = tmpNamingType;
605 432
606 /// <summary> 433 state.Script = regionConfig.GetString("AutoBackupScript", m_defaultState.Script);
607 /// Helper function for ParseConfig. 434 return state;
608 /// </summary>
609 /// <param name="settingName"></param>
610 /// <param name="defaultValue"></param>
611 /// <param name="global"></param>
612 /// <param name="local"></param>
613 /// <returns></returns>
614 private int ResolveInt(string settingName, int defaultValue, IConfig global, IConfig local)
615 {
616 if (local != null)
617 {
618 return local.GetInt(settingName, global.GetInt(settingName, defaultValue));
619 }
620 else
621 {
622 return global.GetInt(settingName, defaultValue);
623 }
624 } 435 }
625 436
626 /// <summary>
627 /// Helper function for ParseConfig.
628 /// </summary>
629 /// <param name="settingName"></param>
630 /// <param name="defaultValue"></param>
631 /// <param name="global"></param>
632 /// <param name="local"></param>
633 /// <returns></returns>
634 private string ResolveString(string settingName, string defaultValue, IConfig global, IConfig local)
635 {
636 if (local != null)
637 {
638 return local.GetString(settingName, global.GetString(settingName, defaultValue));
639 }
640 else
641 {
642 return global.GetString(settingName, defaultValue);
643 }
644 }
645 437
646 /// <summary> 438 /// <summary>
647 /// Called when any auto-backup timer expires. This starts the code path for actually performing a backup. 439 /// Called when any auto-backup timer expires. This starts the code path for actually performing a backup.
@@ -650,63 +442,27 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
650 /// <param name="e"></param> 442 /// <param name="e"></param>
651 private void HandleElapsed(object sender, ElapsedEventArgs e) 443 private void HandleElapsed(object sender, ElapsedEventArgs e)
652 { 444 {
653 // TODO: heuristic thresholds are per-region, so we should probably run heuristics once per region 445 if (!m_enabled || m_busy)
654 // XXX: Running heuristics once per region could add undue performance penalty for something that's supposed to
655 // check whether the region is too busy! Especially on sims with LOTS of regions.
656 // Alternative: make heuristics thresholds global to the module rather than per-region. Less flexible,
657 // but would allow us to be semantically correct while being easier on perf.
658 // Alternative 2: Run heuristics once per unique set of heuristics threshold parameters! Ay yi yi...
659 // Alternative 3: Don't support per-region heuristics at all; just accept them as a global only parameter.
660 // Since this is pretty experimental, I haven't decided which alternative makes the most sense.
661 if (this.m_closed)
662 {
663 return; 446 return;
664 } 447
665 bool heuristicsRun = false; 448 m_busy = true;
666 bool heuristicsPassed = false; 449 if(m_doneFirst && m_KeepFilesForDays > 0)
667 if (!this.m_timerMap.ContainsKey((Timer) sender)) 450 RemoveOldFiles();
451
452 foreach (IScene scene in m_Scenes)
668 { 453 {
669 m_log.Debug("[AUTO BACKUP]: Code-up error: timerMap doesn't contain timer " + sender); 454 if (!m_enabled)
455 return;
456 DoRegionBackup(scene);
670 } 457 }
671 458
672 List<IScene> tmap = this.m_timerMap[(Timer) sender]; 459 if (m_enabled)
673 if (tmap != null && tmap.Count > 0)
674 { 460 {
675 foreach (IScene scene in tmap) 461 m_masterTimer.Start();
676 { 462 m_busy = false;
677 AutoBackupModuleState state = this.m_states[scene];
678 bool heuristics = state.BusyCheck;
679
680 // Fast path: heuristics are on; already ran em; and sim is fine; OR, no heuristics for the region.
681 if ((heuristics && heuristicsRun && heuristicsPassed) || !heuristics)
682 {
683 this.DoRegionBackup(scene);
684 // Heuristics are on; ran but we're too busy -- keep going. Maybe another region will have heuristics off!
685 }
686 else if (heuristicsRun)
687 {
688 m_log.Info("[AUTO BACKUP]: Heuristics: too busy to backup " +
689 scene.RegionInfo.RegionName + " right now.");
690 continue;
691 // Logical Deduction: heuristics are on but haven't been run
692 }
693 else
694 {
695 heuristicsPassed = this.RunHeuristics(scene);
696 heuristicsRun = true;
697 if (!heuristicsPassed)
698 {
699 m_log.Info("[AUTO BACKUP]: Heuristics: too busy to backup " +
700 scene.RegionInfo.RegionName + " right now.");
701 continue;
702 }
703 this.DoRegionBackup(scene);
704 }
705
706 // Remove Old Backups
707 this.RemoveOldFiles(state);
708 }
709 } 463 }
464
465 m_doneFirst = true;
710 } 466 }
711 467
712 /// <summary> 468 /// <summary>
@@ -723,21 +479,29 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
723 return; 479 return;
724 } 480 }
725 481
726 AutoBackupModuleState state = this.m_states[scene]; 482 m_busy = true;
483
484 AutoBackupModuleState state;
485 if(!m_states.TryGetValue(scene, out state))
486 return;
487
488 if(state == null || !state.Enabled)
489 return;
490
727 IRegionArchiverModule iram = scene.RequestModuleInterface<IRegionArchiverModule>(); 491 IRegionArchiverModule iram = scene.RequestModuleInterface<IRegionArchiverModule>();
492 if(iram == null)
493 return;
494
728 string savePath = BuildOarPath(scene.RegionInfo.RegionName, 495 string savePath = BuildOarPath(scene.RegionInfo.RegionName,
729 state.BackupDir, 496 m_backupDir,
730 state.NamingType); 497 state.NamingType);
731 if (savePath == null) 498 if (savePath == null)
732 { 499 {
733 m_log.Warn("[AUTO BACKUP]: savePath is null in HandleElapsed"); 500 m_log.Warn("[AUTO BACKUP]: savePath is null in HandleElapsed");
734 return; 501 return;
735 } 502 }
736 Guid guid = Guid.NewGuid();
737 m_pendingSaves.Add(guid, scene);
738 state.LiveRequests.Add(guid, savePath);
739 ((Scene) scene).EventManager.OnOarFileSaved += new EventManager.OarFileSaved(EventManager_OnOarFileSaved);
740 503
504 Guid guid = Guid.NewGuid();
741 m_log.Info("[AUTO BACKUP]: Backing up region " + scene.RegionInfo.RegionName); 505 m_log.Info("[AUTO BACKUP]: Backing up region " + scene.RegionInfo.RegionName);
742 506
743 // Must pass options, even if dictionary is empty! 507 // Must pass options, even if dictionary is empty!
@@ -747,47 +511,37 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
747 options["noassets"] = true; 511 options["noassets"] = true;
748 512
749 iram.ArchiveRegion(savePath, guid, options); 513 iram.ArchiveRegion(savePath, guid, options);
514 ExecuteScript(state.Script, savePath);
750 } 515 }
751 516
752 // For the given state, remove backup files older than the states KeepFilesForDays property 517 // For the given state, remove backup files older than the states KeepFilesForDays property
753 private void RemoveOldFiles(AutoBackupModuleState state) 518 private void RemoveOldFiles()
754 { 519 {
755 // 0 Means Disabled, Keep Files Indefinitely 520 string[] files;
756 if (state.KeepFilesForDays > 0) 521 try
757 { 522 {
758 string[] files = Directory.GetFiles(state.BackupDir, "*.oar"); 523 files = Directory.GetFiles(m_backupDir, "*.oar");
759 DateTime CuttOffDate = DateTime.Now.AddDays(0 - state.KeepFilesForDays); 524 }
760 525 catch (Exception Ex)
761 foreach (string file in files) 526 {
762 { 527 m_log.Error("[AUTO BACKUP]: Error reading backup folder " + m_backupDir + ": " + Ex.Message);
763 try 528 return;
764 {
765 FileInfo fi = new FileInfo(file);
766 if (fi.CreationTime < CuttOffDate)
767 fi.Delete();
768 }
769 catch (Exception Ex)
770 {
771 m_log.Error("[AUTO BACKUP]: Error deleting old backup file '" + file + "': " + Ex.Message);
772 }
773 }
774 } 529 }
775 }
776 530
777 /// <summary> 531 DateTime CuttOffDate = DateTime.Now.AddDays(-m_KeepFilesForDays);
778 /// Called by the Event Manager when the OnOarFileSaved event is fired. 532
779 /// </summary> 533 foreach (string file in files)
780 /// <param name="guid"></param>
781 /// <param name="message"></param>
782 void EventManager_OnOarFileSaved(Guid guid, string message)
783 {
784 // Ignore if the OAR save is being done by some other part of the system
785 if (m_pendingSaves.ContainsKey(guid))
786 { 534 {
787 AutoBackupModuleState abms = m_states[(m_pendingSaves[guid])]; 535 try
788 ExecuteScript(abms.Script, abms.LiveRequests[guid]); 536 {
789 m_pendingSaves.Remove(guid); 537 FileInfo fi = new FileInfo(file);
790 abms.LiveRequests.Remove(guid); 538 if (fi.CreationTime < CuttOffDate)
539 fi.Delete();
540 }
541 catch (Exception Ex)
542 {
543 m_log.Error("[AUTO BACKUP]: Error deleting old backup file '" + file + "': " + Ex.Message);
544 }
791 } 545 }
792 } 546 }
793 547
@@ -817,63 +571,6 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
817 return output; 571 return output;
818 } 572 }
819 573
820 /// <summary>Return value of true ==> not too busy; false ==> too busy to backup an OAR right now, or error.</summary>
821 private bool RunHeuristics(IScene region)
822 {
823 try
824 {
825 return this.RunTimeDilationHeuristic(region) && this.RunAgentLimitHeuristic(region);
826 }
827 catch (Exception e)
828 {
829 m_log.Warn("[AUTO BACKUP]: Exception in RunHeuristics", e);
830 return false;
831 }
832 }
833
834 /// <summary>
835 /// If the time dilation right at this instant is less than the threshold specified in AutoBackupDilationThreshold (default 0.5),
836 /// then we return false and trip the busy heuristic's "too busy" path (i.e. don't save an OAR).
837 /// AutoBackupDilationThreshold is a _LOWER BOUND_. Lower Time Dilation is bad, so if you go lower than our threshold, it's "too busy".
838 /// </summary>
839 /// <param name="region"></param>
840 /// <returns>Returns true if we're not too busy; false means we've got worse time dilation than the threshold.</returns>
841 private bool RunTimeDilationHeuristic(IScene region)
842 {
843 string regionName = region.RegionInfo.RegionName;
844 return region.TimeDilation >=
845 this.m_configSource.Configs["AutoBackupModule"].GetFloat(
846 regionName + ".AutoBackupDilationThreshold", 0.5f);
847 }
848
849 /// <summary>
850 /// If the root agent count right at this instant is less than the threshold specified in AutoBackupAgentThreshold (default 10),
851 /// then we return false and trip the busy heuristic's "too busy" path (i.e., don't save an OAR).
852 /// AutoBackupAgentThreshold is an _UPPER BOUND_. Higher Agent Count is bad, so if you go higher than our threshold, it's "too busy".
853 /// </summary>
854 /// <param name="region"></param>
855 /// <returns>Returns true if we're not too busy; false means we've got more agents on the sim than the threshold.</returns>
856 private bool RunAgentLimitHeuristic(IScene region)
857 {
858 string regionName = region.RegionInfo.RegionName;
859 try
860 {
861 Scene scene = (Scene) region;
862 // TODO: Why isn't GetRootAgentCount() a method in the IScene interface? Seems generally useful...
863 return scene.GetRootAgentCount() <=
864 this.m_configSource.Configs["AutoBackupModule"].GetInt(
865 regionName + ".AutoBackupAgentThreshold", 10);
866 }
867 catch (InvalidCastException ice)
868 {
869 m_log.Debug(
870 "[AUTO BACKUP]: I NEED MAINTENANCE: IScene is not a Scene; can't get root agent count!",
871 ice);
872 return true;
873 // Non-obstructionist safest answer...
874 }
875 }
876
877 /// <summary> 574 /// <summary>
878 /// Run the script or executable specified by the "AutoBackupScript" config setting. 575 /// Run the script or executable specified by the "AutoBackupScript" config setting.
879 /// Of course this is a security risk if you let anyone modify OpenSim.ini and they want to run some nasty bash script. 576 /// Of course this is a security risk if you let anyone modify OpenSim.ini and they want to run some nasty bash script.
@@ -920,18 +617,6 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
920 } 617 }
921 618
922 /// <summary> 619 /// <summary>
923 /// Quickly stop all timers from firing.
924 /// </summary>
925 private void StopAllTimers()
926 {
927 foreach (Timer t in this.m_timerMap.Keys)
928 {
929 t.Close();
930 }
931 this.m_closed = true;
932 }
933
934 /// <summary>
935 /// Determine the next unique filename by number, for "Sequential" AutoBackupNamingType. 620 /// Determine the next unique filename by number, for "Sequential" AutoBackupNamingType.
936 /// </summary> 621 /// </summary>
937 /// <param name="dirName"></param> 622 /// <param name="dirName"></param>
@@ -1033,5 +718,3 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
1033 } 718 }
1034 } 719 }
1035} 720}
1036
1037
diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs
index ce7c368..fb87677 100644
--- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs
+++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModuleState.cs
@@ -35,29 +35,23 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
35 /// If you use this class in any way outside of AutoBackupModule, you should treat the class as opaque. 35 /// If you use this class in any way outside of AutoBackupModule, you should treat the class as opaque.
36 /// Since it is not part of the framework, you really should not rely upon it outside of the AutoBackupModule implementation. 36 /// Since it is not part of the framework, you really should not rely upon it outside of the AutoBackupModule implementation.
37 /// </summary> 37 /// </summary>
38 /// 38 ///
39 public class AutoBackupModuleState 39 public class AutoBackupModuleState
40 { 40 {
41 private Dictionary<Guid, string> m_liveRequests = null;
42
43 public AutoBackupModuleState() 41 public AutoBackupModuleState()
44 { 42 {
45 this.Enabled = false; 43 Enabled = false;
46 this.BackupDir = "."; 44 SkipAssets = false;
47 this.BusyCheck = true; 45 NamingType = NamingType.Time;
48 this.SkipAssets = false; 46 Script = null;
49 this.Timer = null;
50 this.NamingType = NamingType.Time;
51 this.Script = null;
52 this.KeepFilesForDays = 0;
53 } 47 }
54 48
55 public Dictionary<Guid, string> LiveRequests 49 public AutoBackupModuleState(AutoBackupModuleState copyFrom)
56 { 50 {
57 get { 51 Enabled = copyFrom.Enabled;
58 return this.m_liveRequests ?? 52 SkipAssets = copyFrom.SkipAssets;
59 (this.m_liveRequests = new Dictionary<Guid, string>(1)); 53 NamingType = copyFrom.NamingType;
60 } 54 Script = copyFrom.Script;
61 } 55 }
62 56
63 public bool Enabled 57 public bool Enabled
@@ -66,33 +60,6 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
66 set; 60 set;
67 } 61 }
68 62
69 public System.Timers.Timer Timer
70 {
71 get;
72 set;
73 }
74
75 public double IntervalMinutes
76 {
77 get
78 {
79 if (this.Timer == null)
80 {
81 return -1.0;
82 }
83 else
84 {
85 return this.Timer.Interval / 60000.0;
86 }
87 }
88 }
89
90 public bool BusyCheck
91 {
92 get;
93 set;
94 }
95
96 public bool SkipAssets 63 public bool SkipAssets
97 { 64 {
98 get; 65 get;
@@ -105,36 +72,19 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
105 set; 72 set;
106 } 73 }
107 74
108 public string BackupDir
109 {
110 get;
111 set;
112 }
113
114 public NamingType NamingType 75 public NamingType NamingType
115 { 76 {
116 get; 77 get;
117 set; 78 set;
118 } 79 }
119 80
120 public int KeepFilesForDays
121 {
122 get;
123 set;
124 }
125
126 public new string ToString() 81 public new string ToString()
127 { 82 {
128 string retval = ""; 83 string retval = "";
129
130 retval += "[AUTO BACKUP]: AutoBackup: " + (Enabled ? "ENABLED" : "DISABLED") + "\n"; 84 retval += "[AUTO BACKUP]: AutoBackup: " + (Enabled ? "ENABLED" : "DISABLED") + "\n";
131 retval += "[AUTO BACKUP]: Interval: " + IntervalMinutes + " minutes" + "\n";
132 retval += "[AUTO BACKUP]: Do Busy Check: " + (BusyCheck ? "Yes" : "No") + "\n";
133 retval += "[AUTO BACKUP]: Naming Type: " + NamingType.ToString() + "\n"; 85 retval += "[AUTO BACKUP]: Naming Type: " + NamingType.ToString() + "\n";
134 retval += "[AUTO BACKUP]: Backup Dir: " + BackupDir + "\n";
135 retval += "[AUTO BACKUP]: Script: " + Script + "\n"; 86 retval += "[AUTO BACKUP]: Script: " + Script + "\n";
136 return retval; 87 return retval;
137 } 88 }
138 } 89 }
139} 90}
140
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
index 5f47810..b32a429 100644
--- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
+++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
@@ -65,10 +65,10 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
65 /// </summary> 65 /// </summary>
66 // private UUID EconomyBaseAccount = UUID.Zero; 66 // private UUID EconomyBaseAccount = UUID.Zero;
67 67
68 private float EnergyEfficiency = 0f; 68 private float EnergyEfficiency = 1f;
69 // private ObjectPaid handerOnObjectPaid; 69 // private ObjectPaid handerOnObjectPaid;
70 private bool m_enabled = true; 70 private bool m_enabled = true;
71 private bool m_sellEnabled = false; 71 private bool m_sellEnabled = true;
72 72
73 private IConfigSource m_gConfig; 73 private IConfigSource m_gConfig;
74 74
@@ -85,12 +85,12 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
85 85
86 private int ObjectCount = 0; 86 private int ObjectCount = 0;
87 private int PriceEnergyUnit = 0; 87 private int PriceEnergyUnit = 0;
88 private int PriceGroupCreate = 0; 88 private int PriceGroupCreate = -1;
89 private int PriceObjectClaim = 0; 89 private int PriceObjectClaim = 0;
90 private float PriceObjectRent = 0f; 90 private float PriceObjectRent = 0f;
91 private float PriceObjectScaleFactor = 0f; 91 private float PriceObjectScaleFactor = 10f;
92 private int PriceParcelClaim = 0; 92 private int PriceParcelClaim = 0;
93 private float PriceParcelClaimFactor = 0f; 93 private float PriceParcelClaimFactor = 1f;
94 private int PriceParcelRent = 0; 94 private int PriceParcelRent = 0;
95 private int PricePublicObjectDecay = 0; 95 private int PricePublicObjectDecay = 0;
96 private int PricePublicObjectDelete = 0; 96 private int PricePublicObjectDelete = 0;
@@ -98,7 +98,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
98 private int PriceUpload = 0; 98 private int PriceUpload = 0;
99 private int TeleportMinPrice = 0; 99 private int TeleportMinPrice = 0;
100 100
101 private float TeleportPriceExponent = 0f; 101 private float TeleportPriceExponent = 2f;
102 102
103 103
104 #region IMoneyModule Members 104 #region IMoneyModule Members
@@ -124,13 +124,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
124 public void Initialise(IConfigSource config) 124 public void Initialise(IConfigSource config)
125 { 125 {
126 m_gConfig = config; 126 m_gConfig = config;
127 127 ReadConfigAndPopulate();
128 IConfig startupConfig = m_gConfig.Configs["Startup"];
129 IConfig economyConfig = m_gConfig.Configs["Economy"];
130
131
132 ReadConfigAndPopulate(startupConfig, "Startup");
133 ReadConfigAndPopulate(economyConfig, "Economy");
134 } 128 }
135 129
136 public void AddRegion(Scene scene) 130 public void AddRegion(Scene scene)
@@ -151,13 +145,13 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
151 // to the command line parameters you use to start up your client 145 // to the command line parameters you use to start up your client
152 // This commonly looks like -helperuri http://127.0.0.1:9000/ 146 // This commonly looks like -helperuri http://127.0.0.1:9000/
153 147
154 148
155 // Local Server.. enables functionality only. 149 // Local Server.. enables functionality only.
156 httpServer.AddXmlRPCHandler("getCurrencyQuote", quote_func); 150 httpServer.AddXmlRPCHandler("getCurrencyQuote", quote_func);
157 httpServer.AddXmlRPCHandler("buyCurrency", buy_func); 151 httpServer.AddXmlRPCHandler("buyCurrency", buy_func);
158 httpServer.AddXmlRPCHandler("preflightBuyLandPrep", preflightBuyLandPrep_func); 152 httpServer.AddXmlRPCHandler("preflightBuyLandPrep", preflightBuyLandPrep_func);
159 httpServer.AddXmlRPCHandler("buyLandPrep", landBuy_func); 153 httpServer.AddXmlRPCHandler("buyLandPrep", landBuy_func);
160 154
161 } 155 }
162 156
163 if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle)) 157 if (m_scenel.ContainsKey(scene.RegionInfo.RegionHandle))
@@ -205,13 +199,14 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
205 { 199 {
206 } 200 }
207 201
208 public bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, int amount) 202 public bool ObjectGiveMoney(UUID objectID, UUID fromID, UUID toID, int amount, UUID txn, out string result)
209 { 203 {
204 result = String.Empty;
210 string description = String.Format("Object {0} pays {1}", resolveObjectName(objectID), resolveAgentName(toID)); 205 string description = String.Format("Object {0} pays {1}", resolveObjectName(objectID), resolveAgentName(toID));
211 206
212 bool give_result = doMoneyTransfer(fromID, toID, amount, 2, description); 207 bool give_result = doMoneyTransfer(fromID, toID, amount, 2, description);
213 208
214 209
215 BalanceUpdate(fromID, toID, give_result, description); 210 BalanceUpdate(fromID, toID, give_result, description);
216 211
217 return give_result; 212 return give_result;
@@ -240,35 +235,51 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
240 /// <summary> 235 /// <summary>
241 /// Parse Configuration 236 /// Parse Configuration
242 /// </summary> 237 /// </summary>
243 /// <param name="scene"></param> 238 private void ReadConfigAndPopulate()
244 /// <param name="startupConfig"></param>
245 /// <param name="config"></param>
246 private void ReadConfigAndPopulate(IConfig startupConfig, string config)
247 { 239 {
248 if (config == "Startup" && startupConfig != null) 240 // we are enabled by default
241
242 IConfig startupConfig = m_gConfig.Configs["Startup"];
243
244 if(startupConfig == null) // should not happen
245 return;
246
247 IConfig economyConfig = m_gConfig.Configs["Economy"];
248
249 // economymodule may be at startup or Economy (legacy)
250 string mmodule = startupConfig.GetString("economymodule","");
251 if(String.IsNullOrEmpty(mmodule))
249 { 252 {
250 m_enabled = (startupConfig.GetString("economymodule", "BetaGridLikeMoneyModule") == "BetaGridLikeMoneyModule"); 253 if(economyConfig != null)
254 mmodule = economyConfig.GetString("economymodule","");
251 } 255 }
252 256
253 if (config == "Economy" && startupConfig != null) 257 if(!String.IsNullOrEmpty(mmodule) && mmodule != Name)
254 { 258 {
255 PriceEnergyUnit = startupConfig.GetInt("PriceEnergyUnit", 100); 259 // some other money module selected
256 PriceObjectClaim = startupConfig.GetInt("PriceObjectClaim", 10); 260 m_enabled = false;
257 PricePublicObjectDecay = startupConfig.GetInt("PricePublicObjectDecay", 4); 261 return;
258 PricePublicObjectDelete = startupConfig.GetInt("PricePublicObjectDelete", 4);
259 PriceParcelClaim = startupConfig.GetInt("PriceParcelClaim", 1);
260 PriceParcelClaimFactor = startupConfig.GetFloat("PriceParcelClaimFactor", 1f);
261 PriceUpload = startupConfig.GetInt("PriceUpload", 0);
262 PriceRentLight = startupConfig.GetInt("PriceRentLight", 5);
263 TeleportMinPrice = startupConfig.GetInt("TeleportMinPrice", 2);
264 TeleportPriceExponent = startupConfig.GetFloat("TeleportPriceExponent", 2f);
265 EnergyEfficiency = startupConfig.GetFloat("EnergyEfficiency", 1);
266 PriceObjectRent = startupConfig.GetFloat("PriceObjectRent", 1);
267 PriceObjectScaleFactor = startupConfig.GetFloat("PriceObjectScaleFactor", 10);
268 PriceParcelRent = startupConfig.GetInt("PriceParcelRent", 1);
269 PriceGroupCreate = startupConfig.GetInt("PriceGroupCreate", -1);
270 m_sellEnabled = startupConfig.GetBoolean("SellEnabled", false);
271 } 262 }
263
264 if(economyConfig == null)
265 return;
266
267 PriceEnergyUnit = economyConfig.GetInt("PriceEnergyUnit", 0);
268 PriceObjectClaim = economyConfig.GetInt("PriceObjectClaim", 0);
269 PricePublicObjectDecay = economyConfig.GetInt("PricePublicObjectDecay", 4);
270 PricePublicObjectDelete = economyConfig.GetInt("PricePublicObjectDelete", 0);
271 PriceParcelClaim = economyConfig.GetInt("PriceParcelClaim", 0);
272 PriceParcelClaimFactor = economyConfig.GetFloat("PriceParcelClaimFactor", 1f);
273 PriceUpload = economyConfig.GetInt("PriceUpload", 0);
274 PriceRentLight = economyConfig.GetInt("PriceRentLight", 0);
275 TeleportMinPrice = economyConfig.GetInt("TeleportMinPrice", 0);
276 TeleportPriceExponent = economyConfig.GetFloat("TeleportPriceExponent", 2f);
277 EnergyEfficiency = economyConfig.GetFloat("EnergyEfficiency", 1);
278 PriceObjectRent = economyConfig.GetFloat("PriceObjectRent", 0);
279 PriceObjectScaleFactor = economyConfig.GetFloat("PriceObjectScaleFactor", 10);
280 PriceParcelRent = economyConfig.GetInt("PriceParcelRent", 0);
281 PriceGroupCreate = economyConfig.GetInt("PriceGroupCreate", -1);
282 m_sellEnabled = economyConfig.GetBoolean("SellEnabled", true);
272 } 283 }
273 284
274 private void GetClientFunds(IClientAPI client) 285 private void GetClientFunds(IClientAPI client)
@@ -302,7 +313,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
302 private bool doMoneyTransfer(UUID Sender, UUID Receiver, int amount, int transactiontype, string description) 313 private bool doMoneyTransfer(UUID Sender, UUID Receiver, int amount, int transactiontype, string description)
303 { 314 {
304 bool result = true; 315 bool result = true;
305 316
306 return result; 317 return result;
307 } 318 }
308 319
@@ -376,10 +387,10 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
376 else 387 else
377 { 388 {
378 m_log.ErrorFormat( 389 m_log.ErrorFormat(
379 "[MONEY]: Could not resolve user {0}", 390 "[MONEY]: Could not resolve user {0}",
380 agentID); 391 agentID);
381 } 392 }
382 393
383 return String.Empty; 394 return String.Empty;
384 } 395 }
385 396
@@ -463,7 +474,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
463 Hashtable quoteResponse = new Hashtable(); 474 Hashtable quoteResponse = new Hashtable();
464 XmlRpcResponse returnval = new XmlRpcResponse(); 475 XmlRpcResponse returnval = new XmlRpcResponse();
465 476
466 477
467 Hashtable currencyResponse = new Hashtable(); 478 Hashtable currencyResponse = new Hashtable();
468 currencyResponse.Add("estimatedCost", 0); 479 currencyResponse.Add("estimatedCost", 0);
469 currencyResponse.Add("currencyBuy", amount); 480 currencyResponse.Add("currencyBuy", amount);
@@ -474,7 +485,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
474 485
475 returnval.Value = quoteResponse; 486 returnval.Value = quoteResponse;
476 return returnval; 487 return returnval;
477 488
478 489
479 490
480 } 491 }
@@ -484,7 +495,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
484 // Hashtable requestData = (Hashtable) request.Params[0]; 495 // Hashtable requestData = (Hashtable) request.Params[0];
485 // UUID agentId = UUID.Zero; 496 // UUID agentId = UUID.Zero;
486 // int amount = 0; 497 // int amount = 0;
487 498
488 XmlRpcResponse returnval = new XmlRpcResponse(); 499 XmlRpcResponse returnval = new XmlRpcResponse();
489 Hashtable returnresp = new Hashtable(); 500 Hashtable returnresp = new Hashtable();
490 returnresp.Add("success", true); 501 returnresp.Add("success", true);
@@ -535,7 +546,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
535 546
536 // UUID agentId = UUID.Zero; 547 // UUID agentId = UUID.Zero;
537 // int amount = 0; 548 // int amount = 0;
538 549
539 retparam.Add("success", true); 550 retparam.Add("success", true);
540 ret.Value = retparam; 551 ret.Value = retparam;
541 552
@@ -552,7 +563,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
552 /// <param name="agentID"></param> 563 /// <param name="agentID"></param>
553 private void CheckExistAndRefreshFunds(UUID agentID) 564 private void CheckExistAndRefreshFunds(UUID agentID)
554 { 565 {
555 566
556 } 567 }
557 568
558 /// <summary> 569 /// <summary>
@@ -562,14 +573,14 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
562 /// <returns></returns> 573 /// <returns></returns>
563 private int GetFundsForAgentID(UUID AgentID) 574 private int GetFundsForAgentID(UUID AgentID)
564 { 575 {
565 int returnfunds = 82101; // Set it to the OpenSim version, plus the IG build number. Muahahaha; 576 int returnfunds = 0;
566 577
567 return returnfunds; 578 return returnfunds;
568 } 579 }
569 580
570 // private void SetLocalFundsForAgentID(UUID AgentID, int amount) 581 // private void SetLocalFundsForAgentID(UUID AgentID, int amount)
571 // { 582 // {
572 583
573 // } 584 // }
574 585
575 #endregion 586 #endregion
@@ -688,7 +699,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
688 /// <see cref="OpenSim.Region.Framework.Scenes.EventManager.ClientClosed"/> 699 /// <see cref="OpenSim.Region.Framework.Scenes.EventManager.ClientClosed"/>
689 public void ClientClosed(UUID AgentID, Scene scene) 700 public void ClientClosed(UUID AgentID, Scene scene)
690 { 701 {
691 702
692 } 703 }
693 704
694 /// <summary> 705 /// <summary>
@@ -707,19 +718,19 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
707 718
708 private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e) 719 private void ValidateLandBuy(Object osender, EventManager.LandBuyArgs e)
709 { 720 {
710 721
711 722
712 lock (e) 723 lock (e)
713 { 724 {
714 e.economyValidated = true; 725 e.economyValidated = true;
715 } 726 }
716 727
717 728
718 } 729 }
719 730
720 private void processLandBuy(Object osender, EventManager.LandBuyArgs e) 731 private void processLandBuy(Object osender, EventManager.LandBuyArgs e)
721 { 732 {
722 733
723 } 734 }
724 735
725 /// <summary> 736 /// <summary>
@@ -729,7 +740,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
729 /// <param name="e"></param> 740 /// <param name="e"></param>
730 private void MoneyTransferAction(Object osender, EventManager.MoneyTransferArgs e) 741 private void MoneyTransferAction(Object osender, EventManager.MoneyTransferArgs e)
731 { 742 {
732 743
733 } 744 }
734 745
735 /// <summary> 746 /// <summary>
@@ -738,7 +749,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
738 /// <param name="avatar"></param> 749 /// <param name="avatar"></param>
739 private void MakeChildAgent(ScenePresence avatar) 750 private void MakeChildAgent(ScenePresence avatar)
740 { 751 {
741 752
742 } 753 }
743 754
744 /// <summary> 755 /// <summary>
@@ -747,7 +758,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
747 /// <param name="AgentId"></param> 758 /// <param name="AgentId"></param>
748 private void ClientLoggedOut(UUID AgentId, Scene scene) 759 private void ClientLoggedOut(UUID AgentId, Scene scene)
749 { 760 {
750 761
751 } 762 }
752 763
753 /// <summary> 764 /// <summary>
@@ -767,7 +778,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
767 /// <param name="regionID"></param> 778 /// <param name="regionID"></param>
768 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID) 779 private void AvatarEnteringParcel(ScenePresence avatar, int localLandID, UUID regionID)
769 { 780 {
770 781
771 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString()); 782 //m_log.Info("[FRIEND]: " + avatar.Name + " status:" + (!avatar.IsChildAgent).ToString());
772 } 783 }
773 784
@@ -808,12 +819,12 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
808 819
809 Scene s = LocateSceneClientIn(remoteClient.AgentId); 820 Scene s = LocateSceneClientIn(remoteClient.AgentId);
810 821
811 // Implmenting base sale data checking here so the default OpenSimulator implementation isn't useless 822 // Implmenting base sale data checking here so the default OpenSimulator implementation isn't useless
812 // combined with other implementations. We're actually validating that the client is sending the data 823 // combined with other implementations. We're actually validating that the client is sending the data
813 // that it should. In theory, the client should already know what to send here because it'll see it when it 824 // that it should. In theory, the client should already know what to send here because it'll see it when it
814 // gets the object data. If the data sent by the client doesn't match the object, the viewer probably has an 825 // gets the object data. If the data sent by the client doesn't match the object, the viewer probably has an
815 // old idea of what the object properties are. Viewer developer Hazim informed us that the base module 826 // old idea of what the object properties are. Viewer developer Hazim informed us that the base module
816 // didn't check the client sent data against the object do any. Since the base modules are the 827 // didn't check the client sent data against the object do any. Since the base modules are the
817 // 'crowning glory' examples of good practice.. 828 // 'crowning glory' examples of good practice..
818 829
819 // Validate that the object exists in the scene the user is in 830 // Validate that the object exists in the scene the user is in
@@ -823,15 +834,15 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
823 remoteClient.SendAgentAlertMessage("Unable to buy now. The object was not found.", false); 834 remoteClient.SendAgentAlertMessage("Unable to buy now. The object was not found.", false);
824 return; 835 return;
825 } 836 }
826 837
827 // Validate that the client sent the price that the object is being sold for 838 // Validate that the client sent the price that the object is being sold for
828 if (part.SalePrice != salePrice) 839 if (part.SalePrice != salePrice)
829 { 840 {
830 remoteClient.SendAgentAlertMessage("Cannot buy at this price. Buy Failed. If you continue to get this relog.", false); 841 remoteClient.SendAgentAlertMessage("Cannot buy at this price. Buy Failed. If you continue to get this relog.", false);
831 return; 842 return;
832 } 843 }
833 844
834 // Validate that the client sent the proper sale type the object has set 845 // Validate that the client sent the proper sale type the object has set
835 if (part.ObjectSaleType != saleType) 846 if (part.ObjectSaleType != saleType)
836 { 847 {
837 remoteClient.SendAgentAlertMessage("Cannot buy this way. Buy Failed. If you continue to get this relog.", false); 848 remoteClient.SendAgentAlertMessage("Cannot buy this way. Buy Failed. If you continue to get this relog.", false);
@@ -842,6 +853,15 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
842 if (module != null) 853 if (module != null)
843 module.BuyObject(remoteClient, categoryID, localID, saleType, salePrice); 854 module.BuyObject(remoteClient, categoryID, localID, saleType, salePrice);
844 } 855 }
856
857 public void MoveMoney(UUID fromUser, UUID toUser, int amount, string text)
858 {
859 }
860
861 public bool MoveMoney(UUID fromUser, UUID toUser, int amount, MoneyTransactionType type, string text)
862 {
863 return true;
864 }
845 } 865 }
846 866
847 public enum TransactionType : int 867 public enum TransactionType : int
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index fb644b7..bb23f2f 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -43,9 +43,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
43 public class NPCAvatar : IClientAPI, INPC 43 public class NPCAvatar : IClientAPI, INPC
44 { 44 {
45 public bool SenseAsAgent { get; set; } 45 public bool SenseAsAgent { get; set; }
46 public UUID Owner
47 {
48 get { return m_ownerID;}
49 }
46 50
47 public delegate void ChatToNPC( 51 public delegate void ChatToNPC(
48 string message, byte type, Vector3 fromPos, string fromName, 52 string message, byte type, Vector3 fromPos, string fromName,
49 UUID fromAgentID, UUID ownerID, byte source, byte audible); 53 UUID fromAgentID, UUID ownerID, byte source, byte audible);
50 54
51 /// <summary> 55 /// <summary>
@@ -61,9 +65,14 @@ namespace OpenSim.Region.OptionalModules.World.NPC
61 private readonly string m_firstname; 65 private readonly string m_firstname;
62 private readonly string m_lastname; 66 private readonly string m_lastname;
63 private readonly Vector3 m_startPos; 67 private readonly Vector3 m_startPos;
64 private readonly UUID m_uuid; 68 private UUID m_uuid = UUID.Random();
65 private readonly Scene m_scene; 69 private readonly Scene m_scene;
66 private readonly UUID m_ownerID; 70 private readonly UUID m_ownerID;
71 private UUID m_hostGroupID;
72 private string m_profileAbout = "";
73 private UUID m_profileImage = UUID.Zero;
74 private string m_born;
75 public List<uint> SelectedObjects {get; private set;}
67 76
68 public NPCAvatar( 77 public NPCAvatar(
69 string firstname, string lastname, Vector3 position, UUID ownerID, bool senseAsAgent, Scene scene) 78 string firstname, string lastname, Vector3 position, UUID ownerID, bool senseAsAgent, Scene scene)
@@ -75,6 +84,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
75 m_scene = scene; 84 m_scene = scene;
76 m_ownerID = ownerID; 85 m_ownerID = ownerID;
77 SenseAsAgent = senseAsAgent; 86 SenseAsAgent = senseAsAgent;
87 m_hostGroupID = UUID.Zero;
78 } 88 }
79 89
80 public NPCAvatar( 90 public NPCAvatar(
@@ -87,6 +97,25 @@ namespace OpenSim.Region.OptionalModules.World.NPC
87 m_scene = scene; 97 m_scene = scene;
88 m_ownerID = ownerID; 98 m_ownerID = ownerID;
89 SenseAsAgent = senseAsAgent; 99 SenseAsAgent = senseAsAgent;
100 m_hostGroupID = UUID.Zero;
101 }
102
103 public string profileAbout
104 {
105 get { return m_profileAbout; }
106 set
107 {
108 if(value.Length > 255)
109 m_profileAbout = value.Substring(0,255);
110 else
111 m_profileAbout = value;
112 }
113 }
114
115 public UUID profileImage
116 {
117 get { return m_profileImage; }
118 set { m_profileImage = value; }
90 } 119 }
91 120
92 public IScene Scene 121 public IScene Scene
@@ -94,6 +123,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
94 get { return m_scene; } 123 get { return m_scene; }
95 } 124 }
96 125
126 public int PingTimeMS { get { return 0; } }
127
97 public UUID OwnerID 128 public UUID OwnerID
98 { 129 {
99 get { return m_ownerID; } 130 get { return m_ownerID; }
@@ -187,9 +218,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
187 { 218 {
188 219
189 } 220 }
190 221
191 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos, Quaternion SitOrientation, bool autopilot, 222 public void SendFindAgent(UUID HunterID, UUID PreyID, double GlobalX, double GlobalY)
192 Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook) 223 {
224
225 }
226
227 public void SendSitResponse(UUID TargetID, Vector3 OffsetPos,
228 Quaternion SitOrientation, bool autopilot,
229 Vector3 CameraAtOffset, Vector3 CameraEyeOffset, bool ForceMouseLook)
193 { 230 {
194 231
195 } 232 }
@@ -248,7 +285,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
248#pragma warning disable 67 285#pragma warning disable 67
249 public event Action<IClientAPI> OnLogout; 286 public event Action<IClientAPI> OnLogout;
250 public event ObjectPermissions OnObjectPermissions; 287 public event ObjectPermissions OnObjectPermissions;
251 288 public event MoveItemsAndLeaveCopy OnMoveItemsAndLeaveCopy;
252 public event MoneyTransferRequest OnMoneyTransferRequest; 289 public event MoneyTransferRequest OnMoneyTransferRequest;
253 public event ParcelBuy OnParcelBuy; 290 public event ParcelBuy OnParcelBuy;
254 public event Action<IClientAPI> OnConnectionClosed; 291 public event Action<IClientAPI> OnConnectionClosed;
@@ -268,6 +305,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
268 public event ObjectDrop OnObjectDrop; 305 public event ObjectDrop OnObjectDrop;
269 public event StartAnim OnStartAnim; 306 public event StartAnim OnStartAnim;
270 public event StopAnim OnStopAnim; 307 public event StopAnim OnStopAnim;
308 public event ChangeAnim OnChangeAnim;
271 public event LinkObjects OnLinkObjects; 309 public event LinkObjects OnLinkObjects;
272 public event DelinkObjects OnDelinkObjects; 310 public event DelinkObjects OnDelinkObjects;
273 public event RequestMapBlocks OnRequestMapBlocks; 311 public event RequestMapBlocks OnRequestMapBlocks;
@@ -280,6 +318,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
280 public event SetAlwaysRun OnSetAlwaysRun; 318 public event SetAlwaysRun OnSetAlwaysRun;
281 319
282 public event DeRezObject OnDeRezObject; 320 public event DeRezObject OnDeRezObject;
321 public event RezRestoreToWorld OnRezRestoreToWorld;
283 public event Action<IClientAPI> OnRegionHandShakeReply; 322 public event Action<IClientAPI> OnRegionHandShakeReply;
284 public event GenericCall1 OnRequestWearables; 323 public event GenericCall1 OnRequestWearables;
285 public event Action<IClientAPI, bool> OnCompleteMovementToRegion; 324 public event Action<IClientAPI, bool> OnCompleteMovementToRegion;
@@ -318,6 +357,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
318 public event UpdatePrimTexture OnUpdatePrimTexture; 357 public event UpdatePrimTexture OnUpdatePrimTexture;
319 public event UpdateVector OnUpdatePrimGroupPosition; 358 public event UpdateVector OnUpdatePrimGroupPosition;
320 public event UpdateVector OnUpdatePrimSinglePosition; 359 public event UpdateVector OnUpdatePrimSinglePosition;
360 public event ClientChangeObject onClientChangeObject;
321 public event UpdatePrimRotation OnUpdatePrimGroupRotation; 361 public event UpdatePrimRotation OnUpdatePrimGroupRotation;
322 public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition; 362 public event UpdatePrimSingleRotationPosition OnUpdatePrimSingleRotationPosition;
323 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation; 363 public event UpdatePrimSingleRotation OnUpdatePrimSingleRotation;
@@ -456,7 +496,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
456 public event ClassifiedInfoRequest OnClassifiedInfoRequest; 496 public event ClassifiedInfoRequest OnClassifiedInfoRequest;
457 public event ClassifiedInfoUpdate OnClassifiedInfoUpdate; 497 public event ClassifiedInfoUpdate OnClassifiedInfoUpdate;
458 public event ClassifiedDelete OnClassifiedDelete; 498 public event ClassifiedDelete OnClassifiedDelete;
459 public event ClassifiedDelete OnClassifiedGodDelete; 499 public event ClassifiedGodDelete OnClassifiedGodDelete;
460 500
461 public event EventNotificationAddRequest OnEventNotificationAddRequest; 501 public event EventNotificationAddRequest OnEventNotificationAddRequest;
462 public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest; 502 public event EventNotificationRemoveRequest OnEventNotificationRemoveRequest;
@@ -479,7 +519,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
479 public event AvatarInterestUpdate OnAvatarInterestUpdate; 519 public event AvatarInterestUpdate OnAvatarInterestUpdate;
480 520
481 public event PlacesQuery OnPlacesQuery; 521 public event PlacesQuery OnPlacesQuery;
482 522
483 public event FindAgentUpdate OnFindAgent; 523 public event FindAgentUpdate OnFindAgent;
484 public event TrackAgentUpdate OnTrackAgent; 524 public event TrackAgentUpdate OnTrackAgent;
485 public event NewUserReport OnUserReport; 525 public event NewUserReport OnUserReport;
@@ -495,11 +535,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC
495 public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest; 535 public event GroupVoteHistoryRequest OnGroupVoteHistoryRequest;
496 public event SimWideDeletesDelegate OnSimWideDeletes; 536 public event SimWideDeletesDelegate OnSimWideDeletes;
497 public event SendPostcard OnSendPostcard; 537 public event SendPostcard OnSendPostcard;
538 public event ChangeInventoryItemFlags OnChangeInventoryItemFlags;
498 public event MuteListEntryUpdate OnUpdateMuteListEntry; 539 public event MuteListEntryUpdate OnUpdateMuteListEntry;
499 public event MuteListEntryRemove OnRemoveMuteListEntry; 540 public event MuteListEntryRemove OnRemoveMuteListEntry;
500 public event GodlikeMessage onGodlikeMessage; 541 public event GodlikeMessage onGodlikeMessage;
501 public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate; 542 public event GodUpdateRegionInfoUpdate OnGodUpdateRegionInfoUpdate;
502 543 public event GenericCall2 OnUpdateThrottles;
503#pragma warning restore 67 544#pragma warning restore 67
504 545
505 #endregion 546 #endregion
@@ -522,6 +563,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
522 public virtual UUID AgentId 563 public virtual UUID AgentId
523 { 564 {
524 get { return m_uuid; } 565 get { return m_uuid; }
566 set { m_uuid = value; }
525 } 567 }
526 568
527 public UUID SessionId 569 public UUID SessionId
@@ -562,24 +604,40 @@ namespace OpenSim.Region.OptionalModules.World.NPC
562 } 604 }
563 public UUID ActiveGroupId 605 public UUID ActiveGroupId
564 { 606 {
565 get { return UUID.Zero; } 607 get { return m_hostGroupID; }
608 set { m_hostGroupID = value; }
566 } 609 }
567 610
568 public string ActiveGroupName 611 public string ActiveGroupName
569 { 612 {
570 get { return String.Empty; } 613 get { return String.Empty; }
614 set { }
571 } 615 }
572 616
573 public ulong ActiveGroupPowers 617 public ulong ActiveGroupPowers
574 { 618 {
575 get { return 0; } 619 get { return 0; }
620 set { }
621 }
622
623 public string Born
624 {
625 get { return m_born; }
626 set { m_born = value; }
576 } 627 }
577 628
578 public bool IsGroupMember(UUID groupID) 629 public bool IsGroupMember(UUID groupID)
579 { 630 {
580 return false; 631 return (m_hostGroupID == groupID);
632 }
633
634 public Dictionary<UUID, ulong> GetGroupPowers()
635 {
636 return new Dictionary<UUID, ulong>();
581 } 637 }
582 638
639 public void SetGroupPowers(Dictionary<UUID, ulong> powers) { }
640
583 public ulong GetGroupPowers(UUID groupID) 641 public ulong GetGroupPowers(UUID groupID)
584 { 642 {
585 return 0; 643 return 0;
@@ -627,6 +685,17 @@ namespace OpenSim.Region.OptionalModules.World.NPC
627 public virtual void SetChildAgentThrottle(byte[] throttle) 685 public virtual void SetChildAgentThrottle(byte[] throttle)
628 { 686 {
629 } 687 }
688
689 public virtual void SetChildAgentThrottle(byte[] throttle, float factor)
690 {
691
692 }
693
694 public void SetAgentThrottleSilent(int throttle, int setting)
695 {
696
697
698 }
630 public byte[] GetThrottlesPacked(float multiplier) 699 public byte[] GetThrottlesPacked(float multiplier)
631 { 700 {
632 return new byte[0]; 701 return new byte[0];
@@ -665,6 +734,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
665 734
666 } 735 }
667 736
737 public virtual bool CanSendLayerData()
738 {
739 return false;
740 }
741
668 public virtual void SendLayerData(float[] map) 742 public virtual void SendLayerData(float[] map)
669 { 743 {
670 } 744 }
@@ -676,9 +750,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
676 { 750 {
677 } 751 }
678 752
679 public virtual void SendWindData(Vector2[] windSpeeds) { } 753 public virtual void SendWindData(int version, Vector2[] windSpeeds) { }
680 754
681 public virtual void SendCloudData(float[] cloudCover) { } 755 public virtual void SendCloudData(int version, float[] cloudCover) { }
682 756
683 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look) 757 public virtual void MoveAgentIntoRegion(RegionInfo regInfo, Vector3 pos, Vector3 look)
684 { 758 {
@@ -739,7 +813,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
739 { 813 {
740 } 814 }
741 815
742 public void SendAvatarDataImmediate(ISceneEntity avatar) 816 public void SendEntityFullUpdateImmediate(ISceneEntity avatar)
817 {
818 }
819
820 public void SendEntityTerseUpdateImmediate(ISceneEntity ent)
743 { 821 {
744 } 822 }
745 823
@@ -772,6 +850,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
772 { 850 {
773 } 851 }
774 852
853 public void SendInventoryItemCreateUpdate(InventoryItemBase Item, UUID transactionID, uint callbackId)
854 {
855 }
856
775 public virtual void SendRemoveInventoryItem(UUID itemID) 857 public virtual void SendRemoveInventoryItem(UUID itemID)
776 { 858 {
777 } 859 }
@@ -788,7 +870,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
788 { 870 {
789 } 871 }
790 872
791 public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data) 873 public virtual void SendXferPacket(ulong xferID, uint packet, byte[] data, bool isTaskInventory)
792 { 874 {
793 } 875 }
794 public virtual void SendAbortXferPacket(ulong xferID) 876 public virtual void SendAbortXferPacket(ulong xferID)
@@ -833,6 +915,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
833 { 915 {
834 } 916 }
835 917
918 public void SendAlertMessage(string message, string info)
919 {
920 }
921
836 public void SendSystemAlertMessage(string message) 922 public void SendSystemAlertMessage(string message)
837 { 923 {
838 } 924 }
@@ -849,7 +935,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
849 OnRegionHandShakeReply(this); 935 OnRegionHandShakeReply(this);
850 } 936 }
851 } 937 }
852 938
853 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID) 939 public void SendAssetUploadCompleteMessage(sbyte AssetType, bool Success, UUID AssetFullID)
854 { 940 {
855 } 941 }
@@ -869,7 +955,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
869 public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec) 955 public void SendImageFirstPart(ushort numParts, UUID ImageUUID, uint ImageSize, byte[] ImageData, byte imageCodec)
870 { 956 {
871 } 957 }
872 958
873 public void SendImageNotFound(UUID imageid) 959 public void SendImageNotFound(UUID imageid)
874 { 960 {
875 } 961 }
@@ -877,7 +963,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
877 public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData) 963 public void SendImageNextPart(ushort partNumber, UUID imageUuid, byte[] imageData)
878 { 964 {
879 } 965 }
880 966
881 public void SendShutdownConnectionNotice() 967 public void SendShutdownConnectionNotice()
882 { 968 {
883 } 969 }
@@ -888,7 +974,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
888 974
889 public void SendObjectPropertiesFamilyData(ISceneEntity Entity, uint RequestFlags) 975 public void SendObjectPropertiesFamilyData(ISceneEntity Entity, uint RequestFlags)
890 { 976 {
891 977
892 } 978 }
893 979
894 public void SendObjectPropertiesReply(ISceneEntity entity) 980 public void SendObjectPropertiesReply(ISceneEntity entity)
@@ -902,12 +988,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC
902 public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks) 988 public void SendViewerEffect(ViewerEffectPacket.EffectBlock[] effectBlocks)
903 { 989 {
904 } 990 }
905 991
906 public void SendViewerTime(int phase) 992 public void SendViewerTime(int phase)
907 { 993 {
908 } 994 }
909 995
910 public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] charterMember, 996 public void SendAvatarProperties(UUID avatarID, string aboutText, string bornOn, Byte[] membershipType,
911 string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL, 997 string flAbout, uint flags, UUID flImageID, UUID imageID, string profileURL,
912 UUID partnerID) 998 UUID partnerID)
913 { 999 {
@@ -933,10 +1019,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
933 1019
934 public void Close() 1020 public void Close()
935 { 1021 {
936 Close(false); 1022 Close(true, false);
937 } 1023 }
938 1024
939 public void Close(bool force) 1025 public void Close(bool sendStop, bool force)
940 { 1026 {
941 // Remove ourselves from the scene 1027 // Remove ourselves from the scene
942 m_scene.RemoveClient(AgentId, false); 1028 m_scene.RemoveClient(AgentId, false);
@@ -947,7 +1033,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
947 // We never start the client, so always fail. 1033 // We never start the client, so always fail.
948 throw new NotImplementedException(); 1034 throw new NotImplementedException();
949 } 1035 }
950 1036
951 public void Stop() 1037 public void Stop()
952 { 1038 {
953 } 1039 }
@@ -1142,11 +1228,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
1142 public void SendJoinGroupReply(UUID groupID, bool success) 1228 public void SendJoinGroupReply(UUID groupID, bool success)
1143 { 1229 {
1144 } 1230 }
1145 1231
1146 public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success) 1232 public void SendEjectGroupMemberReply(UUID agentID, UUID groupID, bool success)
1147 { 1233 {
1148 } 1234 }
1149 1235
1150 public void SendLeaveGroupReply(UUID groupID, bool success) 1236 public void SendLeaveGroupReply(UUID groupID, bool success)
1151 { 1237 {
1152 } 1238 }
@@ -1155,6 +1241,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
1155 { 1241 {
1156 } 1242 }
1157 1243
1244 public void SendAgentGroupDataUpdate(UUID avatarID, GroupMembershipData[] data)
1245 {
1246 }
1247
1158 public void SendTerminateFriend(UUID exFriendID) 1248 public void SendTerminateFriend(UUID exFriendID)
1159 { 1249 {
1160 } 1250 }
@@ -1208,10 +1298,26 @@ namespace OpenSim.Region.OptionalModules.World.NPC
1208 { 1298 {
1209 } 1299 }
1210 1300
1301 public void UpdateGroupMembership(GroupMembershipData[] data)
1302 {
1303 }
1304
1305 public void GroupMembershipRemove(UUID GroupID)
1306 {
1307 }
1308
1309 public void GroupMembershipAddReplace(UUID GroupID,ulong GroupPowers)
1310 {
1311 }
1312
1211 public void SendUseCachedMuteList() 1313 public void SendUseCachedMuteList()
1212 { 1314 {
1213 } 1315 }
1214 1316
1317 public void SendEmpytMuteList()
1318 {
1319 }
1320
1215 public void SendMuteListUpdate(string filename) 1321 public void SendMuteListUpdate(string filename)
1216 { 1322 {
1217 } 1323 }
@@ -1220,7 +1326,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
1220 { 1326 {
1221 } 1327 }
1222 #endregion 1328 #endregion
1223 1329
1224 public void SendRebakeAvatarTextures(UUID textureID) 1330 public void SendRebakeAvatarTextures(UUID textureID)
1225 { 1331 {
1226 } 1332 }
@@ -1228,15 +1334,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
1228 public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages) 1334 public void SendAvatarInterestsReply(UUID avatarID, uint wantMask, string wantText, uint skillsMask, string skillsText, string languages)
1229 { 1335 {
1230 } 1336 }
1231 1337
1232 public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt) 1338 public void SendGroupAccountingDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID, int amt)
1233 { 1339 {
1234 } 1340 }
1235 1341
1236 public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier) 1342 public void SendGroupAccountingSummary(IClientAPI sender,UUID groupID, uint moneyAmt, int totalTier, int usedTier)
1237 { 1343 {
1238 } 1344 }
1239 1345
1240 public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt) 1346 public void SendGroupTransactionsSummaryDetails(IClientAPI sender,UUID groupID, UUID transactionID, UUID sessionID,int amt)
1241 { 1347 {
1242 } 1348 }
@@ -1256,7 +1362,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
1256 public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId) 1362 public void SendTextBoxRequest(string message, int chatChannel, string objectname, UUID ownerID, string ownerFirstName, string ownerLastName, UUID objectId)
1257 { 1363 {
1258 } 1364 }
1259 1365
1260 public void SendAgentTerseUpdate(ISceneEntity presence) 1366 public void SendAgentTerseUpdate(ISceneEntity presence)
1261 { 1367 {
1262 } 1368 }
@@ -1265,9 +1371,22 @@ namespace OpenSim.Region.OptionalModules.World.NPC
1265 { 1371 {
1266 } 1372 }
1267 1373
1374 public void SendSelectedPartsProprieties(List<ISceneEntity> parts)
1375 {
1376 }
1377
1268 public void SendPartPhysicsProprieties(ISceneEntity entity) 1378 public void SendPartPhysicsProprieties(ISceneEntity entity)
1269 { 1379 {
1270 } 1380 }
1271 1381
1382 public void SendPartFullUpdate(ISceneEntity ent, uint? parentID)
1383 {
1384 }
1385
1386 public int GetAgentThrottleSilent(int throttle)
1387 {
1388 return 0;
1389 }
1390
1272 } 1391 }
1273} 1392}
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index 3b94dff..ced82e6 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -52,6 +52,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
52 private Dictionary<UUID, NPCAvatar> m_avatars = 52 private Dictionary<UUID, NPCAvatar> m_avatars =
53 new Dictionary<UUID, NPCAvatar>(); 53 new Dictionary<UUID, NPCAvatar>();
54 54
55
56
57 private NPCOptionsFlags m_NPCOptionFlags;
58 public NPCOptionsFlags NPCOptionFlags {get {return m_NPCOptionFlags;}}
59
55 public bool Enabled { get; private set; } 60 public bool Enabled { get; private set; }
56 61
57 public void Initialise(IConfigSource source) 62 public void Initialise(IConfigSource source)
@@ -59,6 +64,21 @@ namespace OpenSim.Region.OptionalModules.World.NPC
59 IConfig config = source.Configs["NPC"]; 64 IConfig config = source.Configs["NPC"];
60 65
61 Enabled = (config != null && config.GetBoolean("Enabled", false)); 66 Enabled = (config != null && config.GetBoolean("Enabled", false));
67 m_NPCOptionFlags = NPCOptionsFlags.None;
68 if(Enabled)
69 {
70 if(config.GetBoolean("AllowNotOwned", true))
71 m_NPCOptionFlags |= NPCOptionsFlags.AllowNotOwned;
72
73 if(config.GetBoolean("AllowSenseAsAvatar", true))
74 m_NPCOptionFlags |= NPCOptionsFlags.AllowSenseAsAvatar;
75
76 if(config.GetBoolean("AllowCloneOtherAvatars", true))
77 m_NPCOptionFlags |= NPCOptionsFlags.AllowCloneOtherAvatars;
78
79 if(config.GetBoolean("NoNPCGroup", true))
80 m_NPCOptionFlags |= NPCOptionsFlags.NoNPCGroup;
81 }
62 } 82 }
63 83
64 public void AddRegion(Scene scene) 84 public void AddRegion(Scene scene)
@@ -137,17 +157,18 @@ namespace OpenSim.Region.OptionalModules.World.NPC
137 } 157 }
138 158
139 public UUID CreateNPC(string firstname, string lastname, 159 public UUID CreateNPC(string firstname, string lastname,
140 Vector3 position, UUID owner, bool senseAsAgent, Scene scene, 160 Vector3 position, UUID owner, bool senseAsAgent, Scene scene,
141 AvatarAppearance appearance) 161 AvatarAppearance appearance)
142 { 162 {
143 return CreateNPC(firstname, lastname, position, UUID.Zero, owner, senseAsAgent, scene, appearance); 163 return CreateNPC(firstname, lastname, position, UUID.Zero, owner, "", UUID.Zero, senseAsAgent, scene, appearance);
144 } 164 }
145 165
146 public UUID CreateNPC(string firstname, string lastname, 166 public UUID CreateNPC(string firstname, string lastname,
147 Vector3 position, UUID agentID, UUID owner, bool senseAsAgent, Scene scene, 167 Vector3 position, UUID agentID, UUID owner, string groupTitle, UUID groupID, bool senseAsAgent, Scene scene,
148 AvatarAppearance appearance) 168 AvatarAppearance appearance)
149 { 169 {
150 NPCAvatar npcAvatar = null; 170 NPCAvatar npcAvatar = null;
171 string born = DateTime.UtcNow.ToString();
151 172
152 try 173 try
153 { 174 {
@@ -167,10 +188,9 @@ namespace OpenSim.Region.OptionalModules.World.NPC
167 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, 188 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0,
168 int.MaxValue); 189 int.MaxValue);
169 190
170 m_log.DebugFormat( 191// m_log.DebugFormat(
171 "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", 192// "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}",
172 firstname, lastname, npcAvatar.AgentId, owner, 193// firstname, lastname, npcAvatar.AgentId, owner, senseAsAgent, position, scene.RegionInfo.RegionName);
173 senseAsAgent, position, scene.RegionInfo.RegionName);
174 194
175 AgentCircuitData acd = new AgentCircuitData(); 195 AgentCircuitData acd = new AgentCircuitData();
176 acd.AgentID = npcAvatar.AgentId; 196 acd.AgentID = npcAvatar.AgentId;
@@ -181,30 +201,44 @@ namespace OpenSim.Region.OptionalModules.World.NPC
181 AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); 201 AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
182 acd.Appearance = npcAppearance; 202 acd.Appearance = npcAppearance;
183 203
184 lock (m_avatars) 204 /*
205 for (int i = 0;
206 i < acd.Appearance.Texture.FaceTextures.Length; i++)
185 { 207 {
186 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, 208 m_log.DebugFormat(
187 acd); 209 "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
188 scene.AddNewAgent(npcAvatar, PresenceType.Npc); 210 acd.AgentID, i,
211 acd.Appearance.Texture.FaceTextures[i]);
212 }
213 */
189 214
190 ScenePresence sp; 215// ManualResetEvent ev = new ManualResetEvent(false);
191 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
192 {
193 sp.CompleteMovement(npcAvatar, false);
194 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
195 m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);
196 216
197 return npcAvatar.AgentId; 217// Util.FireAndForget(delegate(object x) {
198 } 218 lock (m_avatars)
199 else
200 { 219 {
201 m_log.WarnFormat( 220 scene.AuthenticateHandler.AddNewCircuit(npcAvatar.CircuitCode, acd);
202 "[NPC MODULE]: Could not find scene presence for NPC {0} {1}", 221 scene.AddNewAgent(npcAvatar, PresenceType.Npc);
203 sp.Name, sp.UUID);
204 222
205 return UUID.Zero; 223 ScenePresence sp;
224 if (scene.TryGetScenePresence(npcAvatar.AgentId, out sp))
225 {
226 npcAvatar.Born = born;
227 npcAvatar.ActiveGroupId = groupID;
228 sp.CompleteMovement(npcAvatar, false);
229 sp.Grouptitle = groupTitle;
230 m_avatars.Add(npcAvatar.AgentId, npcAvatar);
231// m_log.DebugFormat("[NPC MODULE]: Created NPC {0} {1}", npcAvatar.AgentId, sp.Name);
232 }
206 } 233 }
207 } 234// ev.Set();
235// });
236
237// ev.WaitOne();
238
239// m_log.DebugFormat("[NPC MODULE]: Created NPC with id {0}", npcAvatar.AgentId);
240
241 return npcAvatar.AgentId;
208 } 242 }
209 243
210 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, 244 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos,
@@ -220,6 +254,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC
220 if (sp.IsSatOnObject || sp.SitGround) 254 if (sp.IsSatOnObject || sp.SitGround)
221 return false; 255 return false;
222 256
257// m_log.DebugFormat(
258// "[NPC MODULE]: Moving {0} to {1} in {2}, noFly {3}, landAtTarget {4}",
259// sp.Name, pos, scene.RegionInfo.RegionName,
260// noFly, landAtTarget);
261
223 sp.MoveToTarget(pos, noFly, landAtTarget); 262 sp.MoveToTarget(pos, noFly, landAtTarget);
224 sp.SetAlwaysRun = running; 263 sp.SetAlwaysRun = running;
225 264
@@ -382,6 +421,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
382 { 421 {
383 if (m_avatars.TryGetValue(agentID, out av)) 422 if (m_avatars.TryGetValue(agentID, out av))
384 { 423 {
424 /*
425 m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove",
426 agentID, av.Name);
427 */
385 doRemove = true; 428 doRemove = true;
386 } 429 }
387 } 430 }
@@ -410,9 +453,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
410 { 453 {
411 NPCAvatar av; 454 NPCAvatar av;
412 if (m_avatars.TryGetValue(npcID, out av)) 455 if (m_avatars.TryGetValue(npcID, out av))
456 {
457 if (npcID == callerID)
458 return true;
413 return CheckPermissions(av, callerID); 459 return CheckPermissions(av, callerID);
460 }
414 else 461 else
462 {
415 return false; 463 return false;
464 }
416 } 465 }
417 } 466 }
418 467
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index 77dfd40..9a1ea73 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -112,7 +112,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
112 // ScenePresence.SendInitialData() to reset our entire appearance. 112 // ScenePresence.SendInitialData() to reset our entire appearance.
113 m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId)); 113 m_scene.AssetService.Store(AssetHelpers.CreateNotecardAsset(originalFace8TextureId));
114 114
115 m_afMod.SetAppearance(sp, originalTe, null, null); 115 m_afMod.SetAppearance(sp, originalTe, null, new WearableCacheItem[0] );
116 116
117 UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance); 117 UUID npcId = m_npcMod.CreateNPC("John", "Smith", new Vector3(128, 128, 30), UUID.Zero, true, m_scene, sp.Appearance);
118 118
@@ -209,10 +209,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
209 UserAccountHelpers.CreateUserWithInventory(m_scene, userId); 209 UserAccountHelpers.CreateUserWithInventory(m_scene, userId);
210 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId); 210 ScenePresence sp = SceneHelpers.AddScenePresence(m_scene, userId);
211 211
212 InventoryItemBase att1Item 212 InventoryItemBase att1Item
213 = UserInventoryHelpers.CreateInventoryItem( 213 = UserInventoryHelpers.CreateInventoryItem(
214 m_scene, "att1", TestHelpers.ParseTail(0x2), TestHelpers.ParseTail(0x3), sp.UUID, InventoryType.Object); 214 m_scene, "att1", TestHelpers.ParseTail(0x2), TestHelpers.ParseTail(0x3), sp.UUID, InventoryType.Object);
215 InventoryItemBase att2Item 215 InventoryItemBase att2Item
216 = UserInventoryHelpers.CreateInventoryItem( 216 = UserInventoryHelpers.CreateInventoryItem(
217 m_scene, "att2", TestHelpers.ParseTail(0x12), TestHelpers.ParseTail(0x13), sp.UUID, InventoryType.Object); 217 m_scene, "att2", TestHelpers.ParseTail(0x12), TestHelpers.ParseTail(0x13), sp.UUID, InventoryType.Object);
218 218
@@ -483,4 +483,4 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
483 Assert.That(npc.ParentID, Is.EqualTo(0)); 483 Assert.That(npc.ParentID, Is.EqualTo(0));
484 } 484 }
485 } 485 }
486} \ No newline at end of file 486}
diff --git a/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs
index 0927c4f..7e3bd7f 100644
--- a/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs
+++ b/OpenSim/Region/OptionalModules/World/SceneCommands/SceneCommandsModule.cs
@@ -54,38 +54,38 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
54 private Scene m_scene; 54 private Scene m_scene;
55 55
56 public string Name { get { return "Scene Commands Module"; } } 56 public string Name { get { return "Scene Commands Module"; } }
57 57
58 public Type ReplaceableInterface { get { return null; } } 58 public Type ReplaceableInterface { get { return null; } }
59 59
60 public void Initialise(IConfigSource source) 60 public void Initialise(IConfigSource source)
61 { 61 {
62// m_log.DebugFormat("[SCENE COMMANDS MODULE]: INITIALIZED MODULE"); 62// m_log.DebugFormat("[SCENE COMMANDS MODULE]: INITIALIZED MODULE");
63 } 63 }
64 64
65 public void PostInitialise() 65 public void PostInitialise()
66 { 66 {
67// m_log.DebugFormat("[SCENE COMMANDS MODULE]: POST INITIALIZED MODULE"); 67// m_log.DebugFormat("[SCENE COMMANDS MODULE]: POST INITIALIZED MODULE");
68 } 68 }
69 69
70 public void Close() 70 public void Close()
71 { 71 {
72// m_log.DebugFormat("[SCENE COMMANDS MODULE]: CLOSED MODULE"); 72// m_log.DebugFormat("[SCENE COMMANDS MODULE]: CLOSED MODULE");
73 } 73 }
74 74
75 public void AddRegion(Scene scene) 75 public void AddRegion(Scene scene)
76 { 76 {
77// m_log.DebugFormat("[SCENE COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName); 77// m_log.DebugFormat("[SCENE COMMANDS MODULE]: REGION {0} ADDED", scene.RegionInfo.RegionName);
78 78
79 m_scene = scene; 79 m_scene = scene;
80 80
81 m_scene.RegisterModuleInterface<ISceneCommandsModule>(this); 81 m_scene.RegisterModuleInterface<ISceneCommandsModule>(this);
82 } 82 }
83 83
84 public void RemoveRegion(Scene scene) 84 public void RemoveRegion(Scene scene)
85 { 85 {
86// m_log.DebugFormat("[SCENE COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName); 86// m_log.DebugFormat("[SCENE COMMANDS MODULE]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
87 } 87 }
88 88
89 public void RegionLoaded(Scene scene) 89 public void RegionLoaded(Scene scene)
90 { 90 {
91// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName); 91// m_log.DebugFormat("[ATTACHMENTS COMMAND MODULE]: REGION {0} LOADED", scene.RegionInfo.RegionName);
@@ -96,19 +96,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
96 "List current scene options.", 96 "List current scene options.",
97 "active - if false then main scene update and maintenance loops are suspended.\n" 97 "active - if false then main scene update and maintenance loops are suspended.\n"
98 + "animations - if true then extra animations debug information is logged.\n" 98 + "animations - if true then extra animations debug information is logged.\n"
99 + "appear-refresh - if true then appearance is resent to other avatars every 60 seconds.\n"
100 + "child-repri - how far an avatar must move in meters before we update the position of its child agents in neighbouring regions.\n"
101 + "client-pos-upd - the tolerance before clients are updated with new rotation information for an avatar.\n"
102 + "client-rot-upd - the tolerance before clients are updated with new rotation information for an avatar.\n"
103 + "client-vel-upd - the tolerance before clients are updated with new velocity information for an avatar.\n"
104 + "root-upd-per - if greater than 1, terse updates are only sent to root agents other than the originator on every n updates.\n"
105 + "child-upd-per - if greater than 1, terse updates are only sent to child agents on every n updates.\n"
106 + "collisions - if false then collisions with other objects are turned off.\n" 99 + "collisions - if false then collisions with other objects are turned off.\n"
107 + "pbackup - if false then periodic scene backup is turned off.\n" 100 + "pbackup - if false then periodic scene backup is turned off.\n"
108 + "physics - if false then all physics objects are non-physical.\n" 101 + "physics - if false then all physics objects are non-physical.\n"
109 + "scripting - if false then no scripting operations happen.\n" 102 + "scripting - if false then no scripting operations happen.\n"
110 + "teleport - if true then some extra teleport debug information is logged.\n" 103 + "teleport - if true then some extra teleport debug information is logged.\n"
111 + "update-on-timer - If true then the scene is updated via a timer. If false then a thread with sleep is used.\n"
112 + "updates - if true then any frame which exceeds double the maximum desired frame time is logged.", 104 + "updates - if true then any frame which exceeds double the maximum desired frame time is logged.",
113 HandleDebugSceneGetCommand); 105 HandleDebugSceneGetCommand);
114 106
@@ -118,19 +110,11 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
118 "Turn on scene debugging options.", 110 "Turn on scene debugging options.",
119 "active - if false then main scene update and maintenance loops are suspended.\n" 111 "active - if false then main scene update and maintenance loops are suspended.\n"
120 + "animations - if true then extra animations debug information is logged.\n" 112 + "animations - if true then extra animations debug information is logged.\n"
121 + "appear-refresh - if true then appearance is resent to other avatars every 60 seconds.\n"
122 + "child-repri - how far an avatar must move in meters before we update the position of its child agents in neighbouring regions.\n"
123 + "client-pos-upd - the tolerance before clients are updated with new rotation information for an avatar.\n"
124 + "client-rot-upd - the tolerance before clients are updated with new rotation information for an avatar.\n"
125 + "client-vel-upd - the tolerance before clients are updated with new velocity information for an avatar.\n"
126 + "root-upd-per - if greater than 1, terse updates are only sent to root agents other than the originator on every n updates.\n"
127 + "child-upd-per - if greater than 1, terse updates are only sent to child agents on every n updates.\n"
128 + "collisions - if false then collisions with other objects are turned off.\n" 113 + "collisions - if false then collisions with other objects are turned off.\n"
129 + "pbackup - if false then periodic scene backup is turned off.\n" 114 + "pbackup - if false then periodic scene backup is turned off.\n"
130 + "physics - if false then all physics objects are non-physical.\n" 115 + "physics - if false then all physics objects are non-physical.\n"
131 + "scripting - if false then no scripting operations happen.\n" 116 + "scripting - if false then no scripting operations happen.\n"
132 + "teleport - if true then some extra teleport debug information is logged.\n" 117 + "teleport - if true then some extra teleport debug information is logged.\n"
133 + "update-on-timer - If true then the scene is updated via a timer. If false then a thread with sleep is used.\n"
134 + "updates - if true then any frame which exceeds double the maximum desired frame time is logged.", 118 + "updates - if true then any frame which exceeds double the maximum desired frame time is logged.",
135 HandleDebugSceneSetCommand); 119 HandleDebugSceneSetCommand);
136 } 120 }
@@ -155,18 +139,10 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
155 ConsoleDisplayList cdl = new ConsoleDisplayList(); 139 ConsoleDisplayList cdl = new ConsoleDisplayList();
156 cdl.AddRow("active", m_scene.Active); 140 cdl.AddRow("active", m_scene.Active);
157 cdl.AddRow("animations", m_scene.DebugAnimations); 141 cdl.AddRow("animations", m_scene.DebugAnimations);
158 cdl.AddRow("appear-refresh", m_scene.SendPeriodicAppearanceUpdates);
159 cdl.AddRow("child-repri", m_scene.ChildReprioritizationDistance);
160 cdl.AddRow("client-pos-upd", m_scene.RootPositionUpdateTolerance);
161 cdl.AddRow("client-rot-upd", m_scene.RootRotationUpdateTolerance);
162 cdl.AddRow("client-vel-upd", m_scene.RootVelocityUpdateTolerance);
163 cdl.AddRow("root-upd-per", m_scene.RootTerseUpdatePeriod);
164 cdl.AddRow("child-upd-per", m_scene.ChildTerseUpdatePeriod);
165 cdl.AddRow("pbackup", m_scene.PeriodicBackup); 142 cdl.AddRow("pbackup", m_scene.PeriodicBackup);
166 cdl.AddRow("physics", m_scene.PhysicsEnabled); 143 cdl.AddRow("physics", m_scene.PhysicsEnabled);
167 cdl.AddRow("scripting", m_scene.ScriptsEnabled); 144 cdl.AddRow("scripting", m_scene.ScriptsEnabled);
168 cdl.AddRow("teleport", m_scene.DebugTeleporting); 145 cdl.AddRow("teleport", m_scene.DebugTeleporting);
169 cdl.AddRow("update-on-timer", m_scene.UpdateOnTimer);
170 cdl.AddRow("updates", m_scene.DebugUpdates); 146 cdl.AddRow("updates", m_scene.DebugUpdates);
171 147
172 MainConsole.Instance.OutputFormat("Scene {0} options:", m_scene.Name); 148 MainConsole.Instance.OutputFormat("Scene {0} options:", m_scene.Name);
@@ -210,69 +186,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
210 m_scene.DebugAnimations = active; 186 m_scene.DebugAnimations = active;
211 } 187 }
212 188
213 if (options.ContainsKey("appear-refresh"))
214 {
215 bool newValue;
216
217 // FIXME: This can only come from the console at the moment but might not always be true.
218 if (ConsoleUtil.TryParseConsoleBool(MainConsole.Instance, options["appear-refresh"], out newValue))
219 m_scene.SendPeriodicAppearanceUpdates = newValue;
220 }
221
222 if (options.ContainsKey("child-repri"))
223 {
224 double newValue;
225
226 // FIXME: This can only come from the console at the moment but might not always be true.
227 if (ConsoleUtil.TryParseConsoleDouble(MainConsole.Instance, options["child-repri"], out newValue))
228 m_scene.ChildReprioritizationDistance = newValue;
229 }
230
231 if (options.ContainsKey("client-pos-upd"))
232 {
233 float newValue;
234
235 // FIXME: This can only come from the console at the moment but might not always be true.
236 if (ConsoleUtil.TryParseConsoleFloat(MainConsole.Instance, options["client-pos-upd"], out newValue))
237 m_scene.RootPositionUpdateTolerance = newValue;
238 }
239
240 if (options.ContainsKey("client-rot-upd"))
241 {
242 float newValue;
243
244 // FIXME: This can only come from the console at the moment but might not always be true.
245 if (ConsoleUtil.TryParseConsoleFloat(MainConsole.Instance, options["client-rot-upd"], out newValue))
246 m_scene.RootRotationUpdateTolerance = newValue;
247 }
248
249 if (options.ContainsKey("client-vel-upd"))
250 {
251 float newValue;
252
253 // FIXME: This can only come from the console at the moment but might not always be true.
254 if (ConsoleUtil.TryParseConsoleFloat(MainConsole.Instance, options["client-vel-upd"], out newValue))
255 m_scene.RootVelocityUpdateTolerance = newValue;
256 }
257
258 if (options.ContainsKey("root-upd-per"))
259 {
260 int newValue;
261
262 // FIXME: This can only come from the console at the moment but might not always be true.
263 if (ConsoleUtil.TryParseConsoleNaturalInt(MainConsole.Instance, options["root-upd-per"], out newValue))
264 m_scene.RootTerseUpdatePeriod = newValue;
265 }
266
267 if (options.ContainsKey("child-upd-per"))
268 {
269 int newValue;
270
271 // FIXME: This can only come from the console at the moment but might not always be true.
272 if (ConsoleUtil.TryParseConsoleNaturalInt(MainConsole.Instance, options["child-upd-per"], out newValue))
273 m_scene.ChildTerseUpdatePeriod = newValue;
274 }
275
276 if (options.ContainsKey("pbackup")) 189 if (options.ContainsKey("pbackup"))
277 { 190 {
278 bool active; 191 bool active;
@@ -308,21 +221,6 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
308 m_scene.DebugTeleporting = enableTeleportDebugging; 221 m_scene.DebugTeleporting = enableTeleportDebugging;
309 } 222 }
310 223
311 if (options.ContainsKey("update-on-timer"))
312 {
313 bool enableUpdateOnTimer;
314 if (bool.TryParse(options["update-on-timer"], out enableUpdateOnTimer))
315 {
316 m_scene.UpdateOnTimer = enableUpdateOnTimer;
317 m_scene.Active = false;
318
319 while (m_scene.IsRunning)
320 Thread.Sleep(20);
321
322 m_scene.Active = true;
323 }
324 }
325
326 if (options.ContainsKey("updates")) 224 if (options.ContainsKey("updates"))
327 { 225 {
328 bool enableUpdateDebugging; 226 bool enableUpdateDebugging;
@@ -334,4 +232,4 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
334 } 232 }
335 } 233 }
336 } 234 }
337} \ No newline at end of file 235}
diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
index e4a3382..6e1f8bb 100644
--- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
+++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
@@ -27,8 +27,13 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.IO;
30using System.Reflection; 31using System.Reflection;
31using System.Timers; 32using System.Timers;
33using System.Threading;
34using System.Xml;
35using System.Xml.Serialization;
36
32using OpenMetaverse; 37using OpenMetaverse;
33using log4net; 38using log4net;
34using Mono.Addins; 39using Mono.Addins;
@@ -38,17 +43,15 @@ using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
38using OpenSim.Region.Framework.Interfaces; 43using OpenSim.Region.Framework.Interfaces;
39using OpenSim.Region.Framework.Scenes; 44using OpenSim.Region.Framework.Scenes;
40 45
41using System.Xml; 46using Timer= System.Timers.Timer;
42using System.Xml.Serialization;
43using System.IO;
44 47
45namespace OpenSim.Region.OptionalModules.World.TreePopulator 48namespace OpenSim.Region.OptionalModules.World.TreePopulator
46{ 49{
47 /// <summary> 50 /// <summary>
48 /// Version 2.02 - Still hacky 51 /// Version 2.02 - Still hacky
49 /// </summary> 52 /// </summary>
50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "TreePopulatorModule")] 53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "TreePopulatorModule")]
51 public class TreePopulatorModule : INonSharedRegionModule, ICommandableModule, IVegetationModule 54 public class TreePopulatorModule : INonSharedRegionModule, ICommandableModule
52 { 55 {
53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
54 private readonly Commander m_commander = new Commander("tree"); 57 private readonly Commander m_commander = new Commander("tree");
@@ -60,7 +63,7 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
60 public string m_name; 63 public string m_name;
61 public Boolean m_frozen; 64 public Boolean m_frozen;
62 public Tree m_tree_type; 65 public Tree m_tree_type;
63 public int m_tree_quantity; 66 public int m_tree_quantity;
64 public float m_treeline_low; 67 public float m_treeline_low;
65 public float m_treeline_high; 68 public float m_treeline_high;
66 public Vector3 m_seed_point; 69 public Vector3 m_seed_point;
@@ -78,24 +81,24 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
78 { 81 {
79 } 82 }
80 83
81 public Copse(string fileName, Boolean planted) 84 public Copse(string fileName, Boolean planted)
82 { 85 {
83 Copse cp = (Copse)DeserializeObject(fileName); 86 Copse cp = (Copse)DeserializeObject(fileName);
84 87
85 this.m_name = cp.m_name; 88 m_name = cp.m_name;
86 this.m_frozen = cp.m_frozen; 89 m_frozen = cp.m_frozen;
87 this.m_tree_quantity = cp.m_tree_quantity; 90 m_tree_quantity = cp.m_tree_quantity;
88 this.m_treeline_high = cp.m_treeline_high; 91 m_treeline_high = cp.m_treeline_high;
89 this.m_treeline_low = cp.m_treeline_low; 92 m_treeline_low = cp.m_treeline_low;
90 this.m_range = cp.m_range; 93 m_range = cp.m_range;
91 this.m_tree_type = cp.m_tree_type; 94 m_tree_type = cp.m_tree_type;
92 this.m_seed_point = cp.m_seed_point; 95 m_seed_point = cp.m_seed_point;
93 this.m_initial_scale = cp.m_initial_scale; 96 m_initial_scale = cp.m_initial_scale;
94 this.m_maximum_scale = cp.m_maximum_scale; 97 m_maximum_scale = cp.m_maximum_scale;
95 this.m_initial_scale = cp.m_initial_scale; 98 m_initial_scale = cp.m_initial_scale;
96 this.m_rate = cp.m_rate; 99 m_rate = cp.m_rate;
97 this.m_planted = planted; 100 m_planted = planted;
98 this.m_trees = new List<UUID>(); 101 m_trees = new List<UUID>();
99 } 102 }
100 103
101 public Copse(string copsedef) 104 public Copse(string copsedef)
@@ -103,61 +106,63 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
103 char[] delimiterChars = {':', ';'}; 106 char[] delimiterChars = {':', ';'};
104 string[] field = copsedef.Split(delimiterChars); 107 string[] field = copsedef.Split(delimiterChars);
105 108
106 this.m_name = field[1].Trim(); 109 m_name = field[1].Trim();
107 this.m_frozen = (copsedef[0] == 'F'); 110 m_frozen = (copsedef[0] == 'F');
108 this.m_tree_quantity = int.Parse(field[2]); 111 m_tree_quantity = int.Parse(field[2]);
109 this.m_treeline_high = float.Parse(field[3], Culture.NumberFormatInfo); 112 m_treeline_high = float.Parse(field[3], Culture.NumberFormatInfo);
110 this.m_treeline_low = float.Parse(field[4], Culture.NumberFormatInfo); 113 m_treeline_low = float.Parse(field[4], Culture.NumberFormatInfo);
111 this.m_range = double.Parse(field[5], Culture.NumberFormatInfo); 114 m_range = double.Parse(field[5], Culture.NumberFormatInfo);
112 this.m_tree_type = (Tree) Enum.Parse(typeof(Tree),field[6]); 115 m_tree_type = (Tree) Enum.Parse(typeof(Tree),field[6]);
113 this.m_seed_point = Vector3.Parse(field[7]); 116 m_seed_point = Vector3.Parse(field[7]);
114 this.m_initial_scale = Vector3.Parse(field[8]); 117 m_initial_scale = Vector3.Parse(field[8]);
115 this.m_maximum_scale = Vector3.Parse(field[9]); 118 m_maximum_scale = Vector3.Parse(field[9]);
116 this.m_rate = Vector3.Parse(field[10]); 119 m_rate = Vector3.Parse(field[10]);
117 this.m_planted = true; 120 m_planted = true;
118 this.m_trees = new List<UUID>(); 121 m_trees = new List<UUID>();
119 } 122 }
120 123
121 public Copse(string name, int quantity, float high, float low, double range, Vector3 point, Tree type, Vector3 scale, Vector3 max_scale, Vector3 rate, List<UUID> trees) 124 public Copse(string name, int quantity, float high, float low, double range, Vector3 point, Tree type, Vector3 scale, Vector3 max_scale, Vector3 rate, List<UUID> trees)
122 { 125 {
123 this.m_name = name; 126 m_name = name;
124 this.m_frozen = false; 127 m_frozen = false;
125 this.m_tree_quantity = quantity; 128 m_tree_quantity = quantity;
126 this.m_treeline_high = high; 129 m_treeline_high = high;
127 this.m_treeline_low = low; 130 m_treeline_low = low;
128 this.m_range = range; 131 m_range = range;
129 this.m_tree_type = type; 132 m_tree_type = type;
130 this.m_seed_point = point; 133 m_seed_point = point;
131 this.m_initial_scale = scale; 134 m_initial_scale = scale;
132 this.m_maximum_scale = max_scale; 135 m_maximum_scale = max_scale;
133 this.m_rate = rate; 136 m_rate = rate;
134 this.m_planted = false; 137 m_planted = false;
135 this.m_trees = trees; 138 m_trees = trees;
136 } 139 }
137 140
138 public override string ToString() 141 public override string ToString()
139 { 142 {
140 string frozen = (this.m_frozen ? "F" : "A"); 143 string frozen = (m_frozen ? "F" : "A");
141 144
142 return string.Format("{0}TPM: {1}; {2}; {3:0.0}; {4:0.0}; {5:0.0}; {6}; {7:0.0}; {8:0.0}; {9:0.0}; {10:0.00};", 145 return string.Format("{0}TPM: {1}; {2}; {3:0.0}; {4:0.0}; {5:0.0}; {6}; {7:0.0}; {8:0.0}; {9:0.0}; {10:0.00};",
143 frozen, 146 frozen,
144 this.m_name, 147 m_name,
145 this.m_tree_quantity, 148 m_tree_quantity,
146 this.m_treeline_high, 149 m_treeline_high,
147 this.m_treeline_low, 150 m_treeline_low,
148 this.m_range, 151 m_range,
149 this.m_tree_type, 152 m_tree_type,
150 this.m_seed_point.ToString(), 153 m_seed_point.ToString(),
151 this.m_initial_scale.ToString(), 154 m_initial_scale.ToString(),
152 this.m_maximum_scale.ToString(), 155 m_maximum_scale.ToString(),
153 this.m_rate.ToString()); 156 m_rate.ToString());
154 } 157 }
155 } 158 }
156 159
157 private List<Copse> m_copse; 160 private List<Copse> m_copses = new List<Copse>();
158 161 private object mylock;
159 private double m_update_ms = 1000.0; // msec between updates 162 private double m_update_ms = 1000.0; // msec between updates
160 private bool m_active_trees = false; 163 private bool m_active_trees = false;
164 private bool m_enabled = true; // original default
165 private bool m_allowGrow = true; // original default
161 166
162 Timer CalculateTrees; 167 Timer CalculateTrees;
163 168
@@ -174,51 +179,51 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
174 179
175 public void Initialise(IConfigSource config) 180 public void Initialise(IConfigSource config)
176 { 181 {
177 182 IConfig moduleConfig = config.Configs["Trees"];
178 // ini file settings 183 if (moduleConfig != null)
179 try
180 { 184 {
181 m_active_trees = config.Configs["Trees"].GetBoolean("active_trees", m_active_trees); 185 m_enabled = moduleConfig.GetBoolean("enabled", m_enabled);
182 } 186 m_active_trees = moduleConfig.GetBoolean("active_trees", m_active_trees);
183 catch (Exception) 187 m_allowGrow = moduleConfig.GetBoolean("allowGrow", m_allowGrow);
184 { 188 m_update_ms = moduleConfig.GetDouble("update_rate", m_update_ms);
185 m_log.Debug("[TREES]: ini failure for active_trees - using default");
186 } 189 }
187 190
188 try 191 if(!m_enabled)
189 { 192 return;
190 m_update_ms = config.Configs["Trees"].GetDouble("update_rate", m_update_ms); 193
191 } 194 m_copses = new List<Copse>();
192 catch (Exception) 195 mylock = new object();
193 {
194 m_log.Debug("[TREES]: ini failure for update_rate - using default");
195 }
196 196
197 InstallCommands(); 197 InstallCommands();
198 198
199 m_log.Debug("[TREES]: Initialised tree module"); 199 m_log.Debug("[TREES]: Initialised tree populator module");
200 } 200 }
201 201
202 public void AddRegion(Scene scene) 202 public void AddRegion(Scene scene)
203 { 203 {
204 if(!m_enabled)
205 return;
204 m_scene = scene; 206 m_scene = scene;
205 m_scene.RegisterModuleCommander(m_commander); 207 m_scene.RegisterModuleCommander(m_commander);
206 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole; 208 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
207 209 m_scene.EventManager.OnPrimsLoaded += EventManager_OnPrimsLoaded;
208 } 210 }
209 211
210 public void RemoveRegion(Scene scene) 212 public void RemoveRegion(Scene scene)
211 { 213 {
212 } 214 if(!m_enabled)
215 return;
216 if(m_active_trees && CalculateTrees != null)
217 {
218 CalculateTrees.Dispose();
219 CalculateTrees = null;
220 }
221 m_scene.EventManager.OnPluginConsole -= EventManager_OnPluginConsole;
222 m_scene.EventManager.OnPrimsLoaded -= EventManager_OnPrimsLoaded;
223 }
213 224
214 public void RegionLoaded(Scene scene) 225 public void RegionLoaded(Scene scene)
215 { 226 {
216 ReloadCopse();
217 if (m_copse.Count > 0)
218 m_log.Info("[TREES]: Copse load complete");
219
220 if (m_active_trees)
221 activeizeTreeze(true);
222 } 227 }
223 228
224 public void Close() 229 public void Close()
@@ -240,6 +245,16 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
240 245
241 //-------------------------------------------------------------- 246 //--------------------------------------------------------------
242 247
248 private void EventManager_OnPrimsLoaded(Scene s)
249 {
250 ReloadCopse();
251 if (m_copses.Count > 0)
252 m_log.Info("[TREES]: Copses loaded" );
253
254 if (m_active_trees)
255 activeizeTreeze(true);
256 }
257
243 #region ICommandableModule Members 258 #region ICommandableModule Members
244 259
245 private void HandleTreeActive(Object[] args) 260 private void HandleTreeActive(Object[] args)
@@ -267,25 +282,57 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
267 string copsename = ((string)args[0]).Trim(); 282 string copsename = ((string)args[0]).Trim();
268 Boolean freezeState = (Boolean) args[1]; 283 Boolean freezeState = (Boolean) args[1];
269 284
270 foreach (Copse cp in m_copse) 285 lock(mylock)
271 { 286 {
272 if (cp.m_name == copsename && (!cp.m_frozen && freezeState || cp.m_frozen && !freezeState)) 287 foreach (Copse cp in m_copses)
273 { 288 {
274 cp.m_frozen = freezeState; 289 if (cp.m_name != copsename)
275 foreach (UUID tree in cp.m_trees) 290 continue;
291
292 if(!cp.m_frozen && freezeState || cp.m_frozen && !freezeState)
276 { 293 {
277 SceneObjectPart sop = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart; 294 cp.m_frozen = freezeState;
278 sop.Name = (freezeState ? sop.Name.Replace("ATPM", "FTPM") : sop.Name.Replace("FTPM", "ATPM")); 295 List<UUID> losttrees = new List<UUID>();
279 sop.ParentGroup.HasGroupChanged = true; 296 foreach (UUID tree in cp.m_trees)
280 } 297 {
298 SceneObjectGroup sog = m_scene.GetSceneObjectGroup(tree);
299 if(sog != null && !sog.IsDeleted)
300 {
301 SceneObjectPart sop = sog.RootPart;
302 string name = sop.Name;
303 if(freezeState)
304 {
305 if(name.StartsWith("FTPM"))
306 continue;
307 if(!name.StartsWith("ATPM"))
308 continue;
309 sop.Name = sop.Name.Replace("ATPM", "FTPM");
310 }
311 else
312 {
313 if(name.StartsWith("ATPM"))
314 continue;
315 if(!name.StartsWith("FTPM"))
316 continue;
317 sop.Name = sop.Name.Replace("FTPM", "ATPM");
318 }
319 sop.ParentGroup.HasGroupChanged = true;
320 sog.ScheduleGroupForFullUpdate();
321 }
322 else
323 losttrees.Add(tree);
324 }
325 foreach (UUID tree in losttrees)
326 cp.m_trees.Remove(tree);
281 327
282 m_log.InfoFormat("[TREES]: Activity for copse {0} is frozen {1}", copsename, freezeState); 328 m_log.InfoFormat("[TREES]: Activity for copse {0} is frozen {1}", copsename, freezeState);
283 return; 329 return;
284 } 330 }
285 else if (cp.m_name == copsename && (cp.m_frozen && freezeState || !cp.m_frozen && !freezeState)) 331 else
286 { 332 {
287 m_log.InfoFormat("[TREES]: Copse {0} is already in the requested freeze state", copsename); 333 m_log.InfoFormat("[TREES]: Copse {0} is already in the requested freeze state", copsename);
288 return; 334 return;
335 }
289 } 336 }
290 } 337 }
291 m_log.InfoFormat("[TREES]: Copse {0} was not found - command failed", copsename); 338 m_log.InfoFormat("[TREES]: Copse {0} was not found - command failed", copsename);
@@ -297,17 +344,21 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
297 344
298 m_log.InfoFormat("[TREES]: Loading copse definition...."); 345 m_log.InfoFormat("[TREES]: Loading copse definition....");
299 346
300 copse = new Copse(((string)args[0]), false); 347 lock(mylock)
301 foreach (Copse cp in m_copse)
302 { 348 {
303 if (cp.m_name == copse.m_name) 349 copse = new Copse(((string)args[0]), false);
304 { 350 {
305 m_log.InfoFormat("[TREES]: Copse: {0} is already defined - command failed", copse.m_name); 351 foreach (Copse cp in m_copses)
306 return; 352 {
353 if (cp.m_name == copse.m_name)
354 {
355 m_log.InfoFormat("[TREES]: Copse: {0} is already defined - command failed", copse.m_name);
356 return;
357 }
358 }
307 } 359 }
360 m_copses.Add(copse);
308 } 361 }
309
310 m_copse.Add(copse);
311 m_log.InfoFormat("[TREES]: Loaded copse: {0}", copse.ToString()); 362 m_log.InfoFormat("[TREES]: Loaded copse: {0}", copse.ToString());
312 } 363 }
313 364
@@ -318,20 +369,24 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
318 m_log.InfoFormat("[TREES]: New tree planting for copse {0}", copsename); 369 m_log.InfoFormat("[TREES]: New tree planting for copse {0}", copsename);
319 UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner; 370 UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;
320 371
321 foreach (Copse copse in m_copse) 372 lock(mylock)
322 { 373 {
323 if (copse.m_name == copsename) 374 foreach (Copse copse in m_copses)
324 { 375 {
325 if (!copse.m_planted) 376 if (copse.m_name == copsename)
326 {
327 // The first tree for a copse is created here
328 CreateTree(uuid, copse, copse.m_seed_point);
329 copse.m_planted = true;
330 return;
331 }
332 else
333 { 377 {
334 m_log.InfoFormat("[TREES]: Copse {0} has already been planted", copsename); 378 if (!copse.m_planted)
379 {
380 // The first tree for a copse is created here
381 CreateTree(uuid, copse, copse.m_seed_point, true);
382 copse.m_planted = true;
383 return;
384 }
385 else
386 {
387 m_log.InfoFormat("[TREES]: Copse {0} has already been planted", copsename);
388 return;
389 }
335 } 390 }
336 } 391 }
337 } 392 }
@@ -376,45 +431,49 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
376 string copsename = ((string)args[0]).Trim(); 431 string copsename = ((string)args[0]).Trim();
377 Copse copseIdentity = null; 432 Copse copseIdentity = null;
378 433
379 foreach (Copse cp in m_copse) 434 lock(mylock)
380 { 435 {
381 if (cp.m_name == copsename) 436 foreach (Copse cp in m_copses)
382 { 437 {
383 copseIdentity = cp; 438 if (cp.m_name == copsename)
439 {
440 copseIdentity = cp;
441 }
384 } 442 }
385 }
386 443
387 if (copseIdentity != null) 444 if (copseIdentity != null)
388 {
389 foreach (UUID tree in copseIdentity.m_trees)
390 { 445 {
391 if (m_scene.Entities.ContainsKey(tree)) 446 foreach (UUID tree in copseIdentity.m_trees)
392 {
393 SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
394 // Delete tree and alert clients (not silent)
395 m_scene.DeleteSceneObject(selectedTree.ParentGroup, false);
396 }
397 else
398 { 447 {
399 m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree); 448 if (m_scene.Entities.ContainsKey(tree))
449 {
450 SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
451 // Delete tree and alert clients (not silent)
452 m_scene.DeleteSceneObject(selectedTree.ParentGroup, false);
453 }
454 else
455 {
456 m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree);
457 }
400 } 458 }
459 copseIdentity.m_trees = null;
460 m_copses.Remove(copseIdentity);
461 m_log.InfoFormat("[TREES]: Copse {0} has been removed", copsename);
462 }
463 else
464 {
465 m_log.InfoFormat("[TREES]: Copse {0} was not found - command failed", copsename);
401 } 466 }
402 copseIdentity.m_trees = new List<UUID>();
403 m_copse.Remove(copseIdentity);
404 m_log.InfoFormat("[TREES]: Copse {0} has been removed", copsename);
405 }
406 else
407 {
408 m_log.InfoFormat("[TREES]: Copse {0} was not found - command failed", copsename);
409 } 467 }
410 } 468 }
411 469
412 private void HandleTreeStatistics(Object[] args) 470 private void HandleTreeStatistics(Object[] args)
413 { 471 {
414 m_log.InfoFormat("[TREES]: Activity State: {0}; Update Rate: {1}", m_active_trees, m_update_ms); 472 m_log.InfoFormat("[TREES]: region {0}:", m_scene.Name);
415 foreach (Copse cp in m_copse) 473 m_log.InfoFormat("[TREES]: Activity State: {0}; Update Rate: {1}", m_active_trees, m_update_ms);
474 foreach (Copse cp in m_copses)
416 { 475 {
417 m_log.InfoFormat("[TREES]: Copse {0}; {1} trees; frozen {2}", cp.m_name, cp.m_trees.Count, cp.m_frozen); 476 m_log.InfoFormat("[TREES]: Copse {0}; {1} trees; frozen {2}", cp.m_name, cp.m_trees.Count, cp.m_frozen);
418 } 477 }
419 } 478 }
420 479
@@ -442,7 +501,7 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
442 treeRateCommand.AddArgument("updateRate", "The required update rate (minimum 1000.0)", "Double"); 501 treeRateCommand.AddArgument("updateRate", "The required update rate (minimum 1000.0)", "Double");
443 502
444 Command treeReloadCommand = 503 Command treeReloadCommand =
445 new Command("reload", CommandIntentions.COMMAND_HAZARDOUS, HandleTreeReload, "Reload copse definitions from the in-scene trees"); 504 new Command("reload", CommandIntentions.COMMAND_HAZARDOUS, HandleTreeReload, "Reload copses from the in-scene trees");
446 505
447 Command treeRemoveCommand = 506 Command treeRemoveCommand =
448 new Command("remove", CommandIntentions.COMMAND_HAZARDOUS, HandleTreeRemove, "Remove a copse definition and all its in-scene trees"); 507 new Command("remove", CommandIntentions.COMMAND_HAZARDOUS, HandleTreeRemove, "Remove a copse definition and all its in-scene trees");
@@ -499,34 +558,17 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
499 treeShape.Scale = scale; 558 treeShape.Scale = scale;
500 treeShape.State = (byte)treeType; 559 treeShape.State = (byte)treeType;
501 560
502 return m_scene.AddNewPrim(uuid, groupID, position, rotation, treeShape); 561 SceneObjectGroup sog = new SceneObjectGroup(uuid, position, rotation, treeShape);
503 } 562 SceneObjectPart rootPart = sog.RootPart;
504
505 #endregion
506
507 #region IEntityCreator Members
508
509 protected static readonly PCode[] creationCapabilities = new PCode[] { PCode.NewTree, PCode.Tree };
510 public PCode[] CreationCapabilities { get { return creationCapabilities; } }
511
512 public SceneObjectGroup CreateEntity(
513 UUID ownerID, UUID groupID, Vector3 pos, Quaternion rot, PrimitiveBaseShape shape)
514 {
515 if (Array.IndexOf(creationCapabilities, (PCode)shape.PCode) < 0)
516 {
517 m_log.DebugFormat("[VEGETATION]: PCode {0} not handled by {1}", shape.PCode, Name);
518 return null;
519 }
520
521 SceneObjectGroup sceneObject = new SceneObjectGroup(ownerID, pos, rot, shape);
522 SceneObjectPart rootPart = sceneObject.GetPart(sceneObject.UUID);
523 563
524 rootPart.AddFlag(PrimFlags.Phantom); 564 rootPart.AddFlag(PrimFlags.Phantom);
525 565
526 m_scene.AddNewSceneObject(sceneObject, true); 566 sog.SetGroup(groupID, null);
527 sceneObject.SetGroup(groupID, null); 567 m_scene.AddNewSceneObject(sog, true, false);
528 568 sog.IsSelected = false;
529 return sceneObject; 569 rootPart.IsSelected = false;
570 sog.InvalidateEffectivePerms();
571 return sog;
530 } 572 }
531 573
532 #endregion 574 #endregion
@@ -569,26 +611,27 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
569 611
570 private void ReloadCopse() 612 private void ReloadCopse()
571 { 613 {
572 m_copse = new List<Copse>(); 614 m_copses = new List<Copse>();
573 615
574 EntityBase[] objs = m_scene.GetEntities(); 616 List<SceneObjectGroup> grps = m_scene.GetSceneObjectGroups();
575 foreach (EntityBase obj in objs) 617 foreach (SceneObjectGroup grp in grps)
576 { 618 {
577 if (obj is SceneObjectGroup) 619 if(grp.RootPart.Shape.PCode != (byte)PCode.NewTree && grp.RootPart.Shape.PCode != (byte)PCode.Tree)
578 { 620 continue;
579 SceneObjectGroup grp = (SceneObjectGroup)obj;
580 621
581 if (grp.Name.Length > 5 && (grp.Name.Substring(0, 5) == "ATPM:" || grp.Name.Substring(0, 5) == "FTPM:")) 622 if (grp.Name.Length > 5 && (grp.Name.Substring(0, 5) == "ATPM:" || grp.Name.Substring(0, 5) == "FTPM:"))
623 {
624 // Create a new copse definition or add uuid to an existing definition
625 try
582 { 626 {
583 // Create a new copse definition or add uuid to an existing definition 627 Boolean copsefound = false;
584 try 628 Copse grpcopse = new Copse(grp.Name);
585 {
586 Boolean copsefound = false;
587 Copse copse = new Copse(grp.Name);
588 629
589 foreach (Copse cp in m_copse) 630 lock(mylock)
631 {
632 foreach (Copse cp in m_copses)
590 { 633 {
591 if (cp.m_name == copse.m_name) 634 if (cp.m_name == grpcopse.m_name)
592 { 635 {
593 copsefound = true; 636 copsefound = true;
594 cp.m_trees.Add(grp.UUID); 637 cp.m_trees.Add(grp.UUID);
@@ -598,15 +641,15 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
598 641
599 if (!copsefound) 642 if (!copsefound)
600 { 643 {
601 m_log.InfoFormat("[TREES]: Found copse {0}", grp.Name); 644 m_log.InfoFormat("[TREES]: adding copse {0}", grpcopse.m_name);
602 m_copse.Add(copse); 645 grpcopse.m_trees.Add(grp.UUID);
603 copse.m_trees.Add(grp.UUID); 646 m_copses.Add(grpcopse);
604 } 647 }
605 } 648 }
606 catch 649 }
607 { 650 catch
608 m_log.InfoFormat("[TREES]: Ill formed copse definition {0} - ignoring", grp.Name); 651 {
609 } 652 m_log.InfoFormat("[TREES]: Ill formed copse definition {0} - ignoring", grp.Name);
610 } 653 }
611 } 654 }
612 } 655 }
@@ -617,166 +660,265 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
617 { 660 {
618 if (activeYN) 661 if (activeYN)
619 { 662 {
620 CalculateTrees = new Timer(m_update_ms); 663 if(CalculateTrees == null)
664 CalculateTrees = new Timer(m_update_ms);
621 CalculateTrees.Elapsed += CalculateTrees_Elapsed; 665 CalculateTrees.Elapsed += CalculateTrees_Elapsed;
666 CalculateTrees.AutoReset = false;
622 CalculateTrees.Start(); 667 CalculateTrees.Start();
623 } 668 }
624 else 669 else
625 { 670 {
626 CalculateTrees.Stop(); 671 CalculateTrees.Stop();
627 } 672 }
628 } 673 }
629 674
630 private void growTrees() 675 private void growTrees()
631 { 676 {
632 foreach (Copse copse in m_copse) 677 if(!m_allowGrow)
678 return;
679
680 foreach (Copse copse in m_copses)
633 { 681 {
634 if (!copse.m_frozen) 682 if (copse.m_frozen)
683 continue;
684
685 if(copse.m_trees.Count == 0)
686 continue;
687
688 float maxscale = copse.m_maximum_scale.Z;
689 float ratescale = 1.0f;
690 List<UUID> losttrees = new List<UUID>();
691 foreach (UUID tree in copse.m_trees)
635 { 692 {
636 foreach (UUID tree in copse.m_trees) 693 SceneObjectGroup sog = m_scene.GetSceneObjectGroup(tree);
637 {
638 if (m_scene.Entities.ContainsKey(tree))
639 {
640 SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
641 694
642 if (s_tree.Scale.X < copse.m_maximum_scale.X && s_tree.Scale.Y < copse.m_maximum_scale.Y && s_tree.Scale.Z < copse.m_maximum_scale.Z) 695 if (sog != null && !sog.IsDeleted)
643 { 696 {
644 s_tree.Scale += copse.m_rate; 697 SceneObjectPart s_tree = sog.RootPart;
645 s_tree.ParentGroup.HasGroupChanged = true; 698 if (s_tree.Scale.Z < maxscale)
646 s_tree.ScheduleFullUpdate();
647 }
648 }
649 else
650 { 699 {
651 m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree); 700 ratescale = (float)Util.RandomClass.NextDouble();
701 if(ratescale < 0.2f)
702 ratescale = 0.2f;
703 s_tree.Scale += copse.m_rate * ratescale;
704 sog.HasGroupChanged = true;
705 s_tree.ScheduleFullUpdate();
652 } 706 }
653 } 707 }
708 else
709 losttrees.Add(tree);
654 } 710 }
711
712 foreach (UUID tree in losttrees)
713 copse.m_trees.Remove(tree);
655 } 714 }
656 } 715 }
657 716
658 private void seedTrees() 717 private void seedTrees()
659 { 718 {
660 foreach (Copse copse in m_copse) 719 foreach (Copse copse in m_copses)
661 { 720 {
662 if (!copse.m_frozen) 721 if (copse.m_frozen)
722 continue;
723
724 if(copse.m_trees.Count == 0)
725 return;
726
727 bool low = copse.m_trees.Count < (int)(copse.m_tree_quantity * 0.8f);
728
729 if (!low && Util.RandomClass.NextDouble() < 0.75)
730 return;
731
732 int maxbirths = (int)(copse.m_tree_quantity) - copse.m_trees.Count;
733 if(maxbirths <= 1)
734 return;
735
736 if(maxbirths > 20)
737 maxbirths = 20;
738
739 float minscale = 0;
740 if(!low && m_allowGrow)
741 minscale = copse.m_maximum_scale.Z * 0.75f;;
742
743 int i = 0;
744 UUID[] current = copse.m_trees.ToArray();
745 while(--maxbirths > 0)
663 { 746 {
664 foreach (UUID tree in copse.m_trees) 747 if(current.Length > 1)
748 i = Util.RandomClass.Next(current.Length -1);
749
750 UUID tree = current[i];
751 SceneObjectGroup sog = m_scene.GetSceneObjectGroup(tree);
752
753 if (sog != null && !sog.IsDeleted)
665 { 754 {
666 if (m_scene.Entities.ContainsKey(tree)) 755 SceneObjectPart s_tree = sog.RootPart;
667 {
668 SceneObjectPart s_tree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
669 756
670 if (copse.m_trees.Count < copse.m_tree_quantity) 757 // Tree has grown enough to seed if it has grown by at least 25% of seeded to full grown height
671 { 758 if (s_tree.Scale.Z > minscale)
672 // Tree has grown enough to seed if it has grown by at least 25% of seeded to full grown height 759 SpawnChild(copse, s_tree, true);
673 if (s_tree.Scale.Z > copse.m_initial_scale.Z + (copse.m_maximum_scale.Z - copse.m_initial_scale.Z) / 4.0)
674 {
675 if (Util.RandomClass.NextDouble() > 0.75)
676 {
677 SpawnChild(copse, s_tree);
678 }
679 }
680 }
681 }
682 else
683 {
684 m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree);
685 }
686 } 760 }
687 } 761 else if(copse.m_trees.Contains(tree))
762 copse.m_trees.Remove(tree);
763 }
688 } 764 }
689 } 765 }
690 766
691 private void killTrees() 767 private void killTrees()
692 { 768 {
693 foreach (Copse copse in m_copse) 769 foreach (Copse copse in m_copses)
694 { 770 {
695 if (!copse.m_frozen && copse.m_trees.Count >= copse.m_tree_quantity) 771 if (copse.m_frozen)
696 { 772 continue;
697 foreach (UUID tree in copse.m_trees)
698 {
699 double killLikelyhood = 0.0;
700 773
701 if (m_scene.Entities.ContainsKey(tree)) 774 if (Util.RandomClass.NextDouble() < 0.25)
702 { 775 return;
703 SceneObjectPart selectedTree = ((SceneObjectGroup)m_scene.Entities[tree]).RootPart;
704 double selectedTreeScale = Math.Sqrt(Math.Pow(selectedTree.Scale.X, 2) +
705 Math.Pow(selectedTree.Scale.Y, 2) +
706 Math.Pow(selectedTree.Scale.Z, 2));
707
708 foreach (UUID picktree in copse.m_trees)
709 {
710 if (picktree != tree)
711 {
712 SceneObjectPart pickedTree = ((SceneObjectGroup)m_scene.Entities[picktree]).RootPart;
713
714 double pickedTreeScale = Math.Sqrt(Math.Pow(pickedTree.Scale.X, 2) +
715 Math.Pow(pickedTree.Scale.Y, 2) +
716 Math.Pow(pickedTree.Scale.Z, 2));
717 776
718 double pickedTreeDistance = Vector3.Distance(pickedTree.AbsolutePosition, selectedTree.AbsolutePosition); 777 int maxbdeaths = copse.m_trees.Count - (int)(copse.m_tree_quantity * .98f) ;
778 if(maxbdeaths < 1)
779 return;
719 780
720 killLikelyhood += (selectedTreeScale / (pickedTreeScale * pickedTreeDistance)) * 0.1; 781 float odds;
721 } 782 float scale = 1.0f / copse.m_maximum_scale.Z;
722 }
723 783
724 if (Util.RandomClass.NextDouble() < killLikelyhood) 784 int ntries = maxbdeaths * 4;
725 { 785 while(ntries-- > 0 )
726 // Delete tree and alert clients (not silent) 786 {
727 m_scene.DeleteSceneObject(selectedTree.ParentGroup, false); 787 int next = 0;
728 copse.m_trees.Remove(selectedTree.ParentGroup.UUID); 788 if (copse.m_trees.Count > 1)
729 break; 789 next = Util.RandomClass.Next(copse.m_trees.Count - 1);
730 } 790 UUID tree = copse.m_trees[next];
791 SceneObjectGroup sog = m_scene.GetSceneObjectGroup(tree);
792 if (sog != null && !sog.IsDeleted)
793 {
794 if(m_allowGrow)
795 {
796 odds = sog.RootPart.Scale.Z * scale;
797 odds = odds * odds * odds;
798 odds *= (float)Util.RandomClass.NextDouble();
731 } 799 }
732 else 800 else
733 { 801 {
734 m_log.DebugFormat("[TREES]: Tree not in scene {0}", tree); 802 odds = (float)Util.RandomClass.NextDouble();
803 odds = odds * odds * odds;
735 } 804 }
805
806 if(odds > 0.9f)
807 {
808 m_scene.DeleteSceneObject(sog, false);
809 if(maxbdeaths <= 0)
810 break;
811 }
812 }
813 else
814 {
815 copse.m_trees.Remove(tree);
816 if(copse.m_trees.Count - (int)(copse.m_tree_quantity * .98f) <= 0 )
817 break;
736 } 818 }
737 } 819 }
738 } 820 }
739 } 821 }
740 822
741 private void SpawnChild(Copse copse, SceneObjectPart s_tree) 823 private void SpawnChild(Copse copse, SceneObjectPart s_tree, bool low)
742 { 824 {
743 Vector3 position = new Vector3(); 825 Vector3 position = new Vector3();
744 826
745 double randX = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); 827 float randX = copse.m_maximum_scale.X * 1.25f;
746 double randY = ((Util.RandomClass.NextDouble() * 2.0) - 1.0) * (s_tree.Scale.X * 3); 828 float randY = copse.m_maximum_scale.Y * 1.25f;
747 829
830 float r = (float)Util.RandomClass.NextDouble();
831 randX *= 2.0f * r - 1.0f;
748 position.X = s_tree.AbsolutePosition.X + (float)randX; 832 position.X = s_tree.AbsolutePosition.X + (float)randX;
833
834 r = (float)Util.RandomClass.NextDouble();
835 randY *= 2.0f * r - 1.0f;
749 position.Y = s_tree.AbsolutePosition.Y + (float)randY; 836 position.Y = s_tree.AbsolutePosition.Y + (float)randY;
750 837
751 if (position.X <= (m_scene.RegionInfo.RegionSizeX - 1) && position.X >= 0 && 838 if (position.X > (m_scene.RegionInfo.RegionSizeX - 1) || position.X <= 0 ||
752 position.Y <= (m_scene.RegionInfo.RegionSizeY - 1) && position.Y >= 0 && 839 position.Y > (m_scene.RegionInfo.RegionSizeY - 1) || position.Y <= 0)
753 Util.GetDistanceTo(position, copse.m_seed_point) <= copse.m_range) 840 return;
754 {
755 UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;
756 841
757 CreateTree(uuid, copse, position); 842 randX = position.X - copse.m_seed_point.X;
758 } 843 randX *= randX;
844 randY = position.Y - copse.m_seed_point.Y;
845 randY *= randY;
846 randX += randY;
847
848 if(randX > copse.m_range * copse.m_range)
849 return;
850
851 UUID uuid = m_scene.RegionInfo.EstateSettings.EstateOwner;
852 CreateTree(uuid, copse, position, low);
759 } 853 }
760 854
761 private void CreateTree(UUID uuid, Copse copse, Vector3 position) 855 private void CreateTree(UUID uuid, Copse copse, Vector3 position, bool randomScale)
762 { 856 {
763
764 position.Z = (float)m_scene.Heightmap[(int)position.X, (int)position.Y]; 857 position.Z = (float)m_scene.Heightmap[(int)position.X, (int)position.Y];
765 if (position.Z >= copse.m_treeline_low && position.Z <= copse.m_treeline_high) 858 if (position.Z < copse.m_treeline_low || position.Z > copse.m_treeline_high)
766 { 859 return;
767 SceneObjectGroup tree = AddTree(uuid, UUID.Zero, copse.m_initial_scale, Quaternion.Identity, position, copse.m_tree_type, false);
768 860
769 tree.Name = copse.ToString(); 861 Vector3 scale = copse.m_initial_scale;
770 copse.m_trees.Add(tree.UUID); 862 if(randomScale)
771 tree.SendGroupFullUpdate(); 863 {
864 try
865 {
866 float t;
867 float r = (float)Util.RandomClass.NextDouble();
868 r *= (float)Util.RandomClass.NextDouble();
869 r *= (float)Util.RandomClass.NextDouble();
870
871 t = copse.m_maximum_scale.X / copse.m_initial_scale.X;
872 if(t < 1.0)
873 t = 1 / t;
874 t = t * r + 1.0f;
875 scale.X *= t;
876
877 t = copse.m_maximum_scale.Y / copse.m_initial_scale.Y;
878 if(t < 1.0)
879 t = 1 / t;
880 t = t * r + 1.0f;
881 scale.Y *= t;
882
883 t = copse.m_maximum_scale.Z / copse.m_initial_scale.Z;
884 if(t < 1.0)
885 t = 1 / t;
886 t = t * r + 1.0f;
887 scale.Z *= t;
888 }
889 catch
890 {
891 scale = copse.m_initial_scale;
892 }
772 } 893 }
894
895 SceneObjectGroup tree = AddTree(uuid, UUID.Zero, scale, Quaternion.Identity, position, copse.m_tree_type, false);
896 tree.Name = copse.ToString();
897 copse.m_trees.Add(tree.UUID);
898 tree.RootPart.ScheduleFullUpdate();
773 } 899 }
774 900
775 private void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e) 901 private void CalculateTrees_Elapsed(object sender, ElapsedEventArgs e)
776 { 902 {
777 growTrees(); 903 if(!m_scene.IsRunning)
778 seedTrees(); 904 return;
779 killTrees(); 905
906 if(Monitor.TryEnter(mylock))
907 {
908 try
909 {
910 if(m_scene.LoginsEnabled )
911 {
912 growTrees();
913 seedTrees();
914 killTrees();
915 }
916 }
917 catch { }
918 if(CalculateTrees != null)
919 CalculateTrees.Start();
920 Monitor.Exit(mylock);
921 }
780 } 922 }
781 } 923 }
782} 924}