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/IRCStackModule.cs54
-rw-r--r--OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs7
-rw-r--r--OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs3
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs18
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs6
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs7
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs88
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs33
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs3
-rw-r--r--OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs32
-rw-r--r--OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs37
-rw-r--r--OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml18
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs16
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs91
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs7
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs4
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs324
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs36
-rw-r--r--OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs49
-rw-r--r--OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs2
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs18
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs124
-rw-r--r--OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs11
-rw-r--r--OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs33
-rw-r--r--OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs2
35 files changed, 499 insertions, 552 deletions
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs
index cfe1278..406b715 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/IRCStackModule.cs
@@ -25,6 +25,7 @@
25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 25 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
26 */ 26 */
27 27
28using System;
28using System.Net; 29using System.Net;
29using System.Reflection; 30using System.Reflection;
30using log4net; 31using log4net;
@@ -33,49 +34,51 @@ using OpenSim.Region.Framework.Interfaces;
33using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
34using OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server; 35using OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server;
35 36
37using Mono.Addins;
38
36namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView 39namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView
37{ 40{
38 public class IRCStackModule : IRegionModule 41 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "IRCStackModule")]
42 public class IRCStackModule : INonSharedRegionModule
39 { 43 {
40 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 44 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
41 45
42 private IRCServer m_server; 46 private IRCServer m_server;
47 private int m_Port;
43// private Scene m_scene; 48// private Scene m_scene;
49 private bool m_Enabled;
44 50
45 #region Implementation of IRegionModule 51 #region Implementation of INonSharedRegionModule
46 52
47 public void Initialise(Scene scene, IConfigSource source) 53 public void Initialise(IConfigSource source)
48 { 54 {
49 if (null != source.Configs["IRCd"] && 55 if (null != source.Configs["IRCd"] &&
50 source.Configs["IRCd"].GetBoolean("Enabled",false)) 56 source.Configs["IRCd"].GetBoolean("Enabled", false))
51 { 57 {
52 int portNo = source.Configs["IRCd"].GetInt("Port",6666); 58 m_Enabled = true;
53// m_scene = scene; 59 m_Port = source.Configs["IRCd"].GetInt("Port", 6666);
54 m_server = new IRCServer(IPAddress.Parse("0.0.0.0"), portNo, scene);
55 m_server.OnNewIRCClient += m_server_OnNewIRCClient;
56 } 60 }
57 } 61 }
58 62
59 void m_server_OnNewIRCClient(IRCClientView user) 63 public void AddRegion(Scene scene)
60 { 64 {
61 user.OnIRCReady += user_OnIRCReady; 65 if (!m_Enabled)
66 return;
67
68 m_server = new IRCServer(IPAddress.Parse("0.0.0.0"), m_Port, scene);
69 m_server.OnNewIRCClient += m_server_OnNewIRCClient;
62 } 70 }
63 71
64 void user_OnIRCReady(IRCClientView cv) 72 public void RegionLoaded(Scene scene)
65 { 73 {
66 m_log.Info("[IRCd] Adding user...");
67 cv.Start();
68 m_log.Info("[IRCd] Added user to Scene");
69 } 74 }
70 75
71 public void PostInitialise() 76 public void RemoveRegion(Scene scene)
72 { 77 {
73
74 } 78 }
75 79
76 public void Close() 80 public void Close()
77 { 81 {
78
79 } 82 }
80 83
81 public string Name 84 public string Name
@@ -83,11 +86,24 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView
83 get { return "IRCClientStackModule"; } 86 get { return "IRCClientStackModule"; }
84 } 87 }
85 88
86 public bool IsSharedModule 89 public Type ReplaceableInterface
87 { 90 {
88 get { return false; } 91 get { return null; }
89 } 92 }
90 93
91 #endregion 94 #endregion
95
96 void m_server_OnNewIRCClient(IRCClientView user)
97 {
98 user.OnIRCReady += user_OnIRCReady;
99 }
100
101 void user_OnIRCReady(IRCClientView cv)
102 {
103 m_log.Info("[IRCd] Adding user...");
104 cv.Start();
105 m_log.Info("[IRCd] Added user to Scene");
106 }
107
92 } 108 }
93} 109}
diff --git a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
index 28b8293..254eeb4 100644
--- a/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
+++ b/OpenSim/Region/OptionalModules/Agent/InternetRelayClientView/Server/IRCClientView.cs
@@ -891,10 +891,10 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
891 891
892 public void Close() 892 public void Close()
893 { 893 {
894 Close(true); 894 Close(true, false);
895 } 895 }
896 896
897 public void Close(bool sendStop) 897 public void Close(bool sendStop, bool force)
898 { 898 {
899 Disconnect(); 899 Disconnect();
900 } 900 }
@@ -959,7 +959,8 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server
959 959
960 } 960 }
961 961
962 public void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, byte source, byte audible) 962 public void SendChatMessage(
963 string message, byte type, Vector3 fromPos, string fromName, UUID fromAgentID, UUID ownerID, byte source, byte audible)
963 { 964 {
964 if (audible > 0 && message.Length > 0) 965 if (audible > 0 && message.Length > 0)
965 IRC_SendChannelPrivmsg(fromName, message); 966 IRC_SendChannelPrivmsg(fromName, message);
diff --git a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
index 5fe5948..992f38e 100644
--- a/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Agent/UDP/Linden/LindenUDPInfoModule.cs
@@ -40,7 +40,7 @@ using OpenSim.Region.ClientStack.LindenUDP;
40using OpenSim.Region.Framework.Interfaces; 40using OpenSim.Region.Framework.Interfaces;
41using OpenSim.Region.Framework.Scenes; 41using OpenSim.Region.Framework.Scenes;
42 42
43namespace OpenSim.Region.CoreModules.UDP.Linden 43namespace OpenSim.Region.OptionalModules.UDP.Linden
44{ 44{
45 /// <summary> 45 /// <summary>
46 /// A module that just holds commands for inspecting the current state of the Linden UDP stack. 46 /// A module that just holds commands for inspecting the current state of the Linden UDP stack.
diff --git a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
index 41ec14f..7639c6c 100644
--- a/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
+++ b/OpenSim/Region/OptionalModules/Asset/AssetInfoModule.cs
@@ -127,6 +127,9 @@ namespace OpenSim.Region.OptionalModules.Asset
127 } 127 }
128 128
129 string fileName = rawAssetId; 129 string fileName = rawAssetId;
130
131 if (!ConsoleUtil.CheckFileDoesNotExist(MainConsole.Instance, fileName))
132 return;
130 133
131 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew)) 134 using (FileStream fs = new FileStream(fileName, FileMode.CreateNew))
132 { 135 {
diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs
index d68aabc..68bcb4a 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/AttachmentsCommandModule.cs
@@ -146,7 +146,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
146 sb.AppendFormat("Attachments for {0}\n", sp.Name); 146 sb.AppendFormat("Attachments for {0}\n", sp.Name);
147 147
148 ConsoleDisplayTable ct = new ConsoleDisplayTable() { Indent = 2 }; 148 ConsoleDisplayTable ct = new ConsoleDisplayTable() { Indent = 2 };
149 ct.Columns.Add(new ConsoleDisplayTableColumn("Attachment Name", 36)); 149 ct.Columns.Add(new ConsoleDisplayTableColumn("Attachment Name", 50));
150 ct.Columns.Add(new ConsoleDisplayTableColumn("Local ID", 10)); 150 ct.Columns.Add(new ConsoleDisplayTableColumn("Local ID", 10));
151 ct.Columns.Add(new ConsoleDisplayTableColumn("Item ID", 36)); 151 ct.Columns.Add(new ConsoleDisplayTableColumn("Item ID", 36));
152 ct.Columns.Add(new ConsoleDisplayTableColumn("Attach Point", 14)); 152 ct.Columns.Add(new ConsoleDisplayTableColumn("Attach Point", 14));
diff --git a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
index 31d0034..17971e3 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Attachments/TempAttachmentsModule.cs
@@ -130,37 +130,37 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
130 SendConsoleOutput(agentID, String.Format("auto_grant_attach_perms set to {0}", val)); 130 SendConsoleOutput(agentID, String.Format("auto_grant_attach_perms set to {0}", val));
131 } 131 }
132 132
133 private void llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint) 133 private int llAttachToAvatarTemp(UUID host, UUID script, int attachmentPoint)
134 { 134 {
135 SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host); 135 SceneObjectPart hostPart = m_scene.GetSceneObjectPart(host);
136 136
137 if (hostPart == null) 137 if (hostPart == null)
138 return; 138 return 0;
139 139
140 if (hostPart.ParentGroup.IsAttachment) 140 if (hostPart.ParentGroup.IsAttachment)
141 return; 141 return 0;
142 142
143 IAttachmentsModule attachmentsModule = m_scene.RequestModuleInterface<IAttachmentsModule>(); 143 IAttachmentsModule attachmentsModule = m_scene.RequestModuleInterface<IAttachmentsModule>();
144 if (attachmentsModule == null) 144 if (attachmentsModule == null)
145 return; 145 return 0;
146 146
147 TaskInventoryItem item = hostPart.Inventory.GetInventoryItem(script); 147 TaskInventoryItem item = hostPart.Inventory.GetInventoryItem(script);
148 if (item == null) 148 if (item == null)
149 return; 149 return 0;
150 150
151 if ((item.PermsMask & 32) == 0) // PERMISSION_ATTACH 151 if ((item.PermsMask & 32) == 0) // PERMISSION_ATTACH
152 return; 152 return 0;
153 153
154 ScenePresence target; 154 ScenePresence target;
155 if (!m_scene.TryGetScenePresence(item.PermsGranter, out target)) 155 if (!m_scene.TryGetScenePresence(item.PermsGranter, out target))
156 return; 156 return 0;
157 157
158 if (target.UUID != hostPart.ParentGroup.OwnerID) 158 if (target.UUID != hostPart.ParentGroup.OwnerID)
159 { 159 {
160 uint effectivePerms = hostPart.ParentGroup.GetEffectivePermissions(); 160 uint effectivePerms = hostPart.ParentGroup.GetEffectivePermissions();
161 161
162 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0) 162 if ((effectivePerms & (uint)PermissionMask.Transfer) == 0)
163 return; 163 return 0;
164 164
165 hostPart.ParentGroup.SetOwnerId(target.UUID); 165 hostPart.ParentGroup.SetOwnerId(target.UUID);
166 hostPart.ParentGroup.SetRootPartOwner(hostPart.ParentGroup.RootPart, target.UUID, target.ControllingClient.ActiveGroupId); 166 hostPart.ParentGroup.SetRootPartOwner(hostPart.ParentGroup.RootPart, target.UUID, target.ControllingClient.ActiveGroupId);
@@ -183,7 +183,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Attachments
183 hostPart.ParentGroup.RootPart.ScheduleFullUpdate(); 183 hostPart.ParentGroup.RootPart.ScheduleFullUpdate();
184 } 184 }
185 185
186 attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, true, true); 186 return attachmentsModule.AttachObject(target, hostPart.ParentGroup, (uint)attachmentPoint, false, true, true) ? 1 : 0;
187 } 187 }
188 } 188 }
189} 189}
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
index 913d934..2e1d03d 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCBridgeModule.cs
@@ -31,6 +31,7 @@ using System.Collections.Generic;
31using System.Net; 31using System.Net;
32using System.Reflection; 32using System.Reflection;
33using log4net; 33using log4net;
34using Mono.Addins;
34using Nini.Config; 35using Nini.Config;
35using Nwc.XmlRpc; 36using Nwc.XmlRpc;
36using OpenSim.Framework; 37using OpenSim.Framework;
@@ -40,6 +41,7 @@ using OpenSim.Region.Framework.Scenes;
40 41
41namespace OpenSim.Region.OptionalModules.Avatar.Chat 42namespace OpenSim.Region.OptionalModules.Avatar.Chat
42{ 43{
44 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "IRCBridgeModule")]
43 public class IRCBridgeModule : INonSharedRegionModule 45 public class IRCBridgeModule : INonSharedRegionModule
44 { 46 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 47 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
diff --git a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
index ca956fb..a014798 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Chat/IRCConnector.cs
@@ -231,12 +231,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
231 if (m_server == null || m_baseNick == null || m_ircChannel == null || m_user == null) 231 if (m_server == null || m_baseNick == null || m_ircChannel == null || m_user == null)
232 throw new Exception("Invalid connector configuration"); 232 throw new Exception("Invalid connector configuration");
233 233
234 // Generate an initial nickname if randomizing is enabled 234 // Generate an initial nickname
235 235
236 if (m_randomizeNick) 236 if (m_randomizeNick)
237 {
238 m_nick = m_baseNick + Util.RandomClass.Next(1, 99); 237 m_nick = m_baseNick + Util.RandomClass.Next(1, 99);
239 } 238 else
239 m_nick = m_baseNick;
240 240
241 m_log.InfoFormat("[IRC-Connector-{0}]: Initialization complete", idn); 241 m_log.InfoFormat("[IRC-Connector-{0}]: Initialization complete", idn);
242 242
diff --git a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
index e22618d..018357a 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Concierge/ConciergeModule.cs
@@ -36,6 +36,7 @@ using System.Text;
36using System.Text.RegularExpressions; 36using System.Text.RegularExpressions;
37using System.Threading; 37using System.Threading;
38using log4net; 38using log4net;
39using Mono.Addins;
39using Nini.Config; 40using Nini.Config;
40using Nwc.XmlRpc; 41using Nwc.XmlRpc;
41using OpenMetaverse; 42using OpenMetaverse;
@@ -47,6 +48,7 @@ using OpenSim.Region.CoreModules.Avatar.Chat;
47 48
48namespace OpenSim.Region.OptionalModules.Avatar.Concierge 49namespace OpenSim.Region.OptionalModules.Avatar.Concierge
49{ 50{
51 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ConciergeModule")]
50 public class ConciergeModule : ChatModule, ISharedRegionModule 52 public class ConciergeModule : ChatModule, ISharedRegionModule
51 { 53 {
52 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -546,8 +548,9 @@ namespace OpenSim.Region.OptionalModules.Avatar.Concierge
546 c.SenderUUID = UUID.Zero; 548 c.SenderUUID = UUID.Zero;
547 c.Scene = agent.Scene; 549 c.Scene = agent.Scene;
548 550
549 agent.ControllingClient.SendChatMessage(msg, (byte) ChatTypeEnum.Say, PosOfGod, m_whoami, UUID.Zero, 551 agent.ControllingClient.SendChatMessage(
550 (byte)ChatSourceType.Object, (byte)ChatAudibleLevel.Fully); 552 msg, (byte) ChatTypeEnum.Say, PosOfGod, m_whoami, UUID.Zero, UUID.Zero,
553 (byte)ChatSourceType.Object, (byte)ChatAudibleLevel.Fully);
551 } 554 }
552 555
553 private static void checkStringParameters(XmlRpcRequest request, string[] param) 556 private static void checkStringParameters(XmlRpcRequest request, string[] param)
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
index 7b20446..f292a75 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/FreeSwitchVoice/FreeSwitchVoiceModule.cs
@@ -447,7 +447,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.FreeSwitchVoice
447 // settings allow voice, then whether parcel allows 447 // settings allow voice, then whether parcel allows
448 // voice, if all do retrieve or obtain the parcel 448 // voice, if all do retrieve or obtain the parcel
449 // voice channel 449 // voice channel
450 LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 450 LandData land = scene.GetLandData(avatar.AbsolutePosition);
451 451
452 //m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", 452 //m_log.DebugFormat("[FreeSwitchVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}",
453 // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); 453 // scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param);
diff --git a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
index a30a38d..7da1de6 100644
--- a/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/Voice/VivoxVoice/VivoxVoiceModule.cs
@@ -36,6 +36,7 @@ using System.Reflection;
36using System.Threading; 36using System.Threading;
37using OpenMetaverse; 37using OpenMetaverse;
38using log4net; 38using log4net;
39using Mono.Addins;
39using Nini.Config; 40using Nini.Config;
40using Nwc.XmlRpc; 41using Nwc.XmlRpc;
41using OpenSim.Framework; 42using OpenSim.Framework;
@@ -49,6 +50,7 @@ using Caps = OpenSim.Framework.Capabilities.Caps;
49 50
50namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice 51namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
51{ 52{
53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "VivoxVoiceModule")]
52 public class VivoxVoiceModule : ISharedRegionModule 54 public class VivoxVoiceModule : ISharedRegionModule
53 { 55 {
54 56
@@ -623,7 +625,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice
623 // settings allow voice, then whether parcel allows 625 // settings allow voice, then whether parcel allows
624 // voice, if all do retrieve or obtain the parcel 626 // voice, if all do retrieve or obtain the parcel
625 // voice channel 627 // voice channel
626 LandData land = scene.GetLandData(avatar.AbsolutePosition.X, avatar.AbsolutePosition.Y); 628 LandData land = scene.GetLandData(avatar.AbsolutePosition);
627 629
628// m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}", 630// m_log.DebugFormat("[VivoxVoice][PARCELVOICE]: region \"{0}\": Parcel \"{1}\" ({2}): avatar \"{3}\": request: {4}, path: {5}, param: {6}",
629// scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param); 631// scene.RegionInfo.RegionName, land.Name, land.LocalID, avatarName, request, path, param);
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
index 10b83e6..2802e2f 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsMessagingModule.cs
@@ -27,6 +27,7 @@
27 27
28using System; 28using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Linq;
30using System.Reflection; 31using System.Reflection;
31using log4net; 32using log4net;
32using Mono.Addins; 33using Mono.Addins;
@@ -36,15 +37,18 @@ using OpenMetaverse.StructuredData;
36using OpenSim.Framework; 37using OpenSim.Framework;
37using OpenSim.Region.Framework.Interfaces; 38using OpenSim.Region.Framework.Interfaces;
38using OpenSim.Region.Framework.Scenes; 39using OpenSim.Region.Framework.Scenes;
40using OpenSim.Services.Interfaces;
41using PresenceInfo = OpenSim.Services.Interfaces.PresenceInfo;
39 42
40namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups 43namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
41{ 44{
42 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 45 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsMessagingModule")]
43 public class GroupsMessagingModule : ISharedRegionModule, IGroupsMessagingModule 46 public class GroupsMessagingModule : ISharedRegionModule, IGroupsMessagingModule
44 { 47 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 48 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
46 49
47 private List<Scene> m_sceneList = new List<Scene>(); 50 private List<Scene> m_sceneList = new List<Scene>();
51 private IPresenceService m_presenceService;
48 52
49 private IMessageTransferModule m_msgTransferModule = null; 53 private IMessageTransferModule m_msgTransferModule = null;
50 54
@@ -54,7 +58,28 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
54 private bool m_groupMessagingEnabled = false; 58 private bool m_groupMessagingEnabled = false;
55 private bool m_debugEnabled = true; 59 private bool m_debugEnabled = true;
56 60
57 #region IRegionModuleBase Members 61 /// <summary>
62 /// If enabled, module only tries to send group IMs to online users by querying cached presence information.
63 /// </summary>
64 private bool m_messageOnlineAgentsOnly;
65
66 /// <summary>
67 /// Cache for online users.
68 /// </summary>
69 /// <remarks>
70 /// Group ID is key, presence information for online members is value.
71 /// Will only be non-null if m_messageOnlineAgentsOnly = true
72 /// We cache here so that group messages don't constantly have to re-request the online user list to avoid
73 /// attempted expensive sending of messages to offline users.
74 /// The tradeoff is that a user that comes online will not receive messages consistently from all other users
75 /// until caches have updated.
76 /// Therefore, we set the cache expiry to just 20 seconds.
77 /// </remarks>
78 private ExpiringCache<UUID, PresenceInfo[]> m_usersOnlineCache;
79
80 private int m_usersOnlineCacheExpirySeconds = 20;
81
82 #region Region Module interfaceBase Members
58 83
59 public void Initialise(IConfigSource config) 84 public void Initialise(IConfigSource config)
60 { 85 {
@@ -83,10 +108,17 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
83 return; 108 return;
84 } 109 }
85 110
111 m_messageOnlineAgentsOnly = groupsConfig.GetBoolean("MessageOnlineUsersOnly", false);
112
113 if (m_messageOnlineAgentsOnly)
114 m_usersOnlineCache = new ExpiringCache<UUID, PresenceInfo[]>();
115
86 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true); 116 m_debugEnabled = groupsConfig.GetBoolean("DebugEnabled", true);
87 } 117 }
88 118
89 m_log.Info("[GROUPS-MESSAGING]: GroupsMessagingModule starting up"); 119 m_log.InfoFormat(
120 "[GROUPS-MESSAGING]: GroupsMessagingModule enabled with MessageOnlineOnly = {0}, DebugEnabled = {1}",
121 m_messageOnlineAgentsOnly, m_debugEnabled);
90 } 122 }
91 123
92 public void AddRegion(Scene scene) 124 public void AddRegion(Scene scene)
@@ -126,6 +158,8 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
126 return; 158 return;
127 } 159 }
128 160
161 if (m_presenceService == null)
162 m_presenceService = scene.PresenceService;
129 163
130 m_sceneList.Add(scene); 164 m_sceneList.Add(scene);
131 165
@@ -207,12 +241,42 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
207 public void SendMessageToGroup(GridInstantMessage im, UUID groupID) 241 public void SendMessageToGroup(GridInstantMessage im, UUID groupID)
208 { 242 {
209 List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(new UUID(im.fromAgentID), groupID); 243 List<GroupMembersData> groupMembers = m_groupData.GetGroupMembers(new UUID(im.fromAgentID), groupID);
210 244 int groupMembersCount = groupMembers.Count;
211 if (m_debugEnabled) 245
212 m_log.DebugFormat( 246 if (m_messageOnlineAgentsOnly)
213 "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members", 247 {
214 groupID, groupMembers.Count); 248 string[] t1 = groupMembers.ConvertAll<string>(gmd => gmd.AgentID.ToString()).ToArray();
215 249
250 // We cache in order not to overwhlem the presence service on large grids with many groups. This does
251 // mean that members coming online will not see all group members until after m_usersOnlineCacheExpirySeconds has elapsed.
252 // (assuming this is the same across all grid simulators).
253 PresenceInfo[] onlineAgents;
254 if (!m_usersOnlineCache.TryGetValue(groupID, out onlineAgents))
255 {
256 onlineAgents = m_presenceService.GetAgents(t1);
257 m_usersOnlineCache.Add(groupID, onlineAgents, m_usersOnlineCacheExpirySeconds);
258 }
259
260 HashSet<string> onlineAgentsUuidSet = new HashSet<string>();
261 Array.ForEach<PresenceInfo>(onlineAgents, pi => onlineAgentsUuidSet.Add(pi.UserID));
262
263 groupMembers = groupMembers.Where(gmd => onlineAgentsUuidSet.Contains(gmd.AgentID.ToString())).ToList();
264
265 // if (m_debugEnabled)
266// m_log.DebugFormat(
267// "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members, {2} online",
268// groupID, groupMembersCount, groupMembers.Count());
269 }
270 else
271 {
272 if (m_debugEnabled)
273 m_log.DebugFormat(
274 "[GROUPS-MESSAGING]: SendMessageToGroup called for group {0} with {1} visible members",
275 groupID, groupMembers.Count);
276 }
277
278 int requestStartTick = Environment.TickCount;
279
216 foreach (GroupMembersData member in groupMembers) 280 foreach (GroupMembersData member in groupMembers)
217 { 281 {
218 if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID)) 282 if (m_groupData.hasAgentDroppedGroupChatSession(member.AgentID, groupID))
@@ -254,6 +318,12 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
254 ProcessMessageFromGroupSession(msg); 318 ProcessMessageFromGroupSession(msg);
255 } 319 }
256 } 320 }
321
322 // Temporary for assessing how long it still takes to send messages to large online groups.
323 if (m_messageOnlineAgentsOnly)
324 m_log.DebugFormat(
325 "[GROUPS-MESSAGING]: SendMessageToGroup for group {0} with {1} visible members, {2} online took {3}ms",
326 groupID, groupMembersCount, groupMembers.Count(), Environment.TickCount - requestStartTick);
257 } 327 }
258 328
259 #region SimGridEventHandlers 329 #region SimGridEventHandlers
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
index 65bd26c..ae0ad02 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/GroupsModule.cs
@@ -43,7 +43,7 @@ using DirFindFlags = OpenMetaverse.DirectoryManager.DirFindFlags;
43 43
44namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups 44namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
45{ 45{
46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "GroupsModule")]
47 public class GroupsModule : ISharedRegionModule, IGroupsModule 47 public class GroupsModule : ISharedRegionModule, IGroupsModule
48 { 48 {
49 /// <summary> 49 /// <summary>
@@ -86,7 +86,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
86 private bool m_debugEnabled = false; 86 private bool m_debugEnabled = false;
87 private int m_levelGroupCreate = 0; 87 private int m_levelGroupCreate = 0;
88 88
89 #region IRegionModuleBase Members 89 #region Region Module interfaceBase Members
90 90
91 public void Initialise(IConfigSource config) 91 public void Initialise(IConfigSource config)
92 { 92 {
@@ -123,7 +123,36 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
123 public void AddRegion(Scene scene) 123 public void AddRegion(Scene scene)
124 { 124 {
125 if (m_groupsEnabled) 125 if (m_groupsEnabled)
126 {
126 scene.RegisterModuleInterface<IGroupsModule>(this); 127 scene.RegisterModuleInterface<IGroupsModule>(this);
128 scene.AddCommand(
129 "debug",
130 this,
131 "debug groups verbose",
132 "debug groups verbose <true|false>",
133 "This setting turns on very verbose groups debugging",
134 HandleDebugGroupsVerbose);
135 }
136 }
137
138 private void HandleDebugGroupsVerbose(object modules, string[] args)
139 {
140 if (args.Length < 4)
141 {
142 MainConsole.Instance.Output("Usage: debug groups verbose <true|false>");
143 return;
144 }
145
146 bool verbose = false;
147 if (!bool.TryParse(args[3], out verbose))
148 {
149 MainConsole.Instance.Output("Usage: debug groups verbose <true|false>");
150 return;
151 }
152
153 m_debugEnabled = verbose;
154
155 MainConsole.Instance.OutputFormat("{0} verbose logging set to {1}", Name, m_debugEnabled);
127 } 156 }
128 157
129 public void RegionLoaded(Scene scene) 158 public void RegionLoaded(Scene scene)
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
index 5d57f70..7bae8f7 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/SimianGroupsServicesConnectorModule.cs
@@ -102,7 +102,7 @@ using OpenSim.Services.Interfaces;
102 102
103namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups 103namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
104{ 104{
105 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 105 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SimianGroupsServicesConnectorModule")]
106 public class SimianGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector 106 public class SimianGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
107 { 107 {
108 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 108 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -176,7 +176,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
176 // private IUserAccountService m_accountService = null; 176 // private IUserAccountService m_accountService = null;
177 177
178 178
179 #region IRegionModuleBase Members 179 #region Region Module interfaceBase Members
180 180
181 public string Name 181 public string Name
182 { 182 {
diff --git a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
index d412cd1..d0c3ea5 100644
--- a/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/Avatar/XmlRpcGroups/XmlRpcGroupsServicesConnectorModule.cs
@@ -47,7 +47,7 @@ using OpenSim.Services.Interfaces;
47 47
48namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups 48namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
49{ 49{
50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcGroupsServicesConnectorModule")]
51 public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector 51 public class XmlRpcGroupsServicesConnectorModule : ISharedRegionModule, IGroupsServicesConnector
52 { 52 {
53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -83,7 +83,7 @@ namespace OpenSim.Region.OptionalModules.Avatar.XmlRpcGroups
83 private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>(); 83 private Dictionary<UUID, List<UUID>> m_groupsAgentsDroppedFromChatSession = new Dictionary<UUID, List<UUID>>();
84 private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>(); 84 private Dictionary<UUID, List<UUID>> m_groupsAgentsInvitedToChatSession = new Dictionary<UUID, List<UUID>>();
85 85
86 #region IRegionModuleBase Members 86 #region Region Module interfaceBase Members
87 87
88 public string Name 88 public string Name
89 { 89 {
diff --git a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
index dddea3e..781fe95 100644
--- a/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
+++ b/OpenSim/Region/OptionalModules/Example/BareBonesShared/BareBonesSharedModule.cs
@@ -33,9 +33,6 @@ using Nini.Config;
33using OpenSim.Region.Framework.Interfaces; 33using OpenSim.Region.Framework.Interfaces;
34using OpenSim.Region.Framework.Scenes; 34using OpenSim.Region.Framework.Scenes;
35 35
36[assembly: Addin("BareBonesSharedModule", "0.1")]
37[assembly: AddinDependency("OpenSim", "0.5")]
38
39namespace OpenSim.Region.OptionalModules.Example.BareBonesShared 36namespace OpenSim.Region.OptionalModules.Example.BareBonesShared
40{ 37{
41 /// <summary> 38 /// <summary>
diff --git a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
index 59ff9b8..39cabb5 100644
--- a/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
+++ b/OpenSim/Region/OptionalModules/PrimLimitsModule/PrimLimitsModule.cs
@@ -121,34 +121,40 @@ namespace OpenSim.Region.OptionalModules
121 121
122 private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene) 122 private bool CanObjectEnter(UUID objectID, bool enteringRegion, Vector3 newPoint, Scene scene)
123 { 123 {
124 if ((newPoint.X > 257f || newPoint.X < -1f || newPoint.Y > 257f || newPoint.Y < -1f)) 124 if (newPoint.X < -1f || newPoint.X > (float)(Constants.RegionSize + 1) ||
125 newPoint.Y < -1f || newPoint.Y > (float)(Constants.RegionSize + 1))
125 return true; 126 return true;
126 127
127 SceneObjectPart obj = scene.GetSceneObjectPart(objectID); 128 SceneObjectPart obj = scene.GetSceneObjectPart(objectID);
128 Vector3 oldPoint = obj.GroupPosition; 129
129 int objectCount = obj.ParentGroup.PrimCount; 130 if (obj == null)
130 ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y); 131 return false;
132
133 // Prim counts are determined by the location of the root prim. if we're
134 // moving a child prim, just let it pass
135 if (!obj.IsRoot)
136 {
137 return true;
138 }
139
131 ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y); 140 ILandObject newParcel = scene.LandChannel.GetLandObject(newPoint.X, newPoint.Y);
132 141
133 if (newParcel == null) 142 if (newParcel == null)
134 return true; 143 return true;
135 144
136 int usedPrims = newParcel.PrimCounts.Total; 145 Vector3 oldPoint = obj.GroupPosition;
137 int simulatorCapacity = newParcel.GetSimulatorMaxPrimCount(); 146 ILandObject oldParcel = scene.LandChannel.GetLandObject(oldPoint.X, oldPoint.Y);
138 147
139 // The prim hasn't crossed a region boundry so we don't need to worry 148 // The prim hasn't crossed a region boundry so we don't need to worry
140 // about prim counts here 149 // about prim counts here
141 if(oldParcel.Equals(newParcel)) 150 if(oldParcel != null && oldParcel.Equals(newParcel))
142 { 151 {
143 return true; 152 return true;
144 } 153 }
145 154
146 // Prim counts are determined by the location of the root prim. if we're 155 int objectCount = obj.ParentGroup.PrimCount;
147 // moving a child prim, just let it pass 156 int usedPrims = newParcel.PrimCounts.Total;
148 if(!obj.IsRoot) 157 int simulatorCapacity = newParcel.GetSimulatorMaxPrimCount();
149 {
150 return true;
151 }
152 158
153 // TODO: Add Special Case here for temporary prims 159 // TODO: Add Special Case here for temporary prims
154 160
diff --git a/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs b/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs
new file mode 100644
index 0000000..217b2d5
--- /dev/null
+++ b/OpenSim/Region/OptionalModules/Properties/AssemblyInfo.cs
@@ -0,0 +1,37 @@
1using System.Reflection;
2using System.Runtime.CompilerServices;
3using System.Runtime.InteropServices;
4using Mono.Addins;
5
6// General Information about an assembly is controlled through the following
7// set of attributes. Change these attribute values to modify the information
8// associated with an assembly.
9[assembly: AssemblyTitle("OpenSim.Region.OptionalModules")]
10[assembly: AssemblyDescription("Optional modules for OpenSim")]
11[assembly: AssemblyConfiguration("")]
12[assembly: AssemblyCompany("")]
13[assembly: AssemblyProduct("OpenSim.Region.OptionalModules.Properties")]
14[assembly: AssemblyCopyright("Copyright © 2012")]
15[assembly: AssemblyTrademark("")]
16[assembly: AssemblyCulture("")]
17
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
20// COM, set the ComVisible attribute to true on that type.
21[assembly: ComVisible(false)]
22
23// The following GUID is for the ID of the typelib if this project is exposed to COM
24[assembly: Guid("84a3082d-3011-4c13-835c-c7d93f97ac79")]
25
26// Version information for an assembly consists of the following four values:
27//
28// Major Version
29// Minor Version
30// Build Number
31// Revision
32//
33[assembly: AssemblyVersion("0.7.5.*")]
34[assembly: AssemblyFileVersion("1.0.0.0")]
35
36[assembly: Addin("OpenSim.Region.OptionalModules", "0.1")]
37[assembly: AddinDependency("OpenSim", "0.5")]
diff --git a/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml b/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml
deleted file mode 100644
index 8691343..0000000
--- a/OpenSim/Region/OptionalModules/Resources/OptionalModules.addin.xml
+++ /dev/null
@@ -1,18 +0,0 @@
1<Addin id="OpenSim.Region.OptionalModules" version="0.2">
2 <Runtime>
3 <Import assembly="OpenSim.Region.OptionalModules.dll"/>
4 </Runtime>
5
6 <Dependencies>
7 <Addin id="OpenSim" version="0.5" />
8 </Dependencies>
9
10 <Extension path = "/OpenSim/RegionModules">
11 <RegionModule id="RegionReady" type="OpenSim.Region.OptionalModules.Scripting.RegionReady.RegionReadyModule" />
12 <RegionModule id="IRCBridge" type="OpenSim.Region.OptionalModules.Avatar.Chat.IRCBridgeModule" />
13 <RegionModule id="Concierge" type="OpenSim.Region.OptionalModules.Avatar.Concierge.ConciergeModule" />
14 <RegionModule id="VivoxVoice" type="OpenSim.Region.OptionalModules.Avatar.Voice.VivoxVoice.VivoxVoiceModule" />
15 <RegionModule id="WorldViewModule" type="OpenSim.Region.OptionalModules.World.WorldView.WorldViewModule" />
16 <RegionModule id="AutoBackupModule" type="OpenSim.Region.OptionalModules.World.AutoBackup.AutoBackupModule" />
17 </Extension>
18</Addin>
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
index 311531c..e68764a 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreModule.cs
@@ -59,7 +59,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
59 private Dictionary<UUID,JsonStore> m_JsonValueStore; 59 private Dictionary<UUID,JsonStore> m_JsonValueStore;
60 private UUID m_sharedStore; 60 private UUID m_sharedStore;
61 61
62#region IRegionModule Members 62#region Region Module interface
63 63
64 // ----------------------------------------------------------------- 64 // -----------------------------------------------------------------
65 /// <summary> 65 /// <summary>
@@ -175,14 +175,15 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
175 /// 175 ///
176 /// </summary> 176 /// </summary>
177 // ----------------------------------------------------------------- 177 // -----------------------------------------------------------------
178 public bool CreateStore(string value, out UUID result) 178 public bool CreateStore(string value, ref UUID result)
179 { 179 {
180 result = UUID.Zero; 180 if (result == UUID.Zero)
181 result = UUID.Random();
182
183 JsonStore map = null;
181 184
182 if (! m_enabled) return false; 185 if (! m_enabled) return false;
183 186
184 UUID uuid = UUID.Random();
185 JsonStore map = null;
186 187
187 try 188 try
188 { 189 {
@@ -195,9 +196,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
195 } 196 }
196 197
197 lock (m_JsonValueStore) 198 lock (m_JsonValueStore)
198 m_JsonValueStore.Add(uuid,map); 199 m_JsonValueStore.Add(result,map);
199 200
200 result = uuid;
201 return true; 201 return true;
202 } 202 }
203 203
@@ -231,7 +231,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
231 if (! m_JsonValueStore.TryGetValue(storeID,out map)) 231 if (! m_JsonValueStore.TryGetValue(storeID,out map))
232 { 232 {
233 m_log.InfoFormat("[JsonStore] Missing store {0}",storeID); 233 m_log.InfoFormat("[JsonStore] Missing store {0}",storeID);
234 return true; 234 return false;
235 } 235 }
236 } 236 }
237 237
diff --git a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
index eaba816..0c175ca 100644
--- a/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/JsonStore/JsonStoreScriptModule.cs
@@ -58,7 +58,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
58 private IScriptModuleComms m_comms; 58 private IScriptModuleComms m_comms;
59 private IJsonStoreModule m_store; 59 private IJsonStoreModule m_store;
60 60
61#region IRegionModule Members 61#region Region Module interface
62 62
63 // ----------------------------------------------------------------- 63 // -----------------------------------------------------------------
64 /// <summary> 64 /// <summary>
@@ -227,7 +227,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.JsonStore
227 protected UUID JsonCreateStore(UUID hostID, UUID scriptID, string value) 227 protected UUID JsonCreateStore(UUID hostID, UUID scriptID, string value)
228 { 228 {
229 UUID uuid = UUID.Zero; 229 UUID uuid = UUID.Zero;
230 if (! m_store.CreateStore(value, out uuid)) 230 if (! m_store.CreateStore(value, ref uuid))
231 GenerateRuntimeError("Failed to create Json store"); 231 GenerateRuntimeError("Failed to create Json store");
232 232
233 return uuid; 233 return uuid;
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
index 03481d2..6fb28e2 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/MRMModule.cs
@@ -43,13 +43,17 @@ using OpenMetaverse;
43using OpenSim.Framework; 43using OpenSim.Framework;
44using OpenSim.Region.Framework.Interfaces; 44using OpenSim.Region.Framework.Interfaces;
45using OpenSim.Region.Framework.Scenes; 45using OpenSim.Region.Framework.Scenes;
46using Mono.Addins;
46 47
47namespace OpenSim.Region.OptionalModules.Scripting.Minimodule 48namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
48{ 49{
49 public class MRMModule : IRegionModule, IMRMModule 50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MRMModule")]
51 public class MRMModule : INonSharedRegionModule, IMRMModule
50 { 52 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 private Scene m_scene; 54 private Scene m_scene;
55 private bool m_Enabled;
56 private bool m_Hidden;
53 57
54 private readonly Dictionary<UUID,MRMBase> m_scripts = new Dictionary<UUID, MRMBase>(); 58 private readonly Dictionary<UUID,MRMBase> m_scripts = new Dictionary<UUID, MRMBase>();
55 59
@@ -67,7 +71,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
67 m_extensions[typeof (T)] = instance; 71 m_extensions[typeof (T)] = instance;
68 } 72 }
69 73
70 public void Initialise(Scene scene, IConfigSource source) 74 #region INonSharedRegionModule
75
76 public void Initialise(IConfigSource source)
71 { 77 {
72 if (source.Configs["MRM"] != null) 78 if (source.Configs["MRM"] != null)
73 { 79 {
@@ -76,23 +82,60 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
76 if (source.Configs["MRM"].GetBoolean("Enabled", false)) 82 if (source.Configs["MRM"].GetBoolean("Enabled", false))
77 { 83 {
78 m_log.Info("[MRM]: Enabling MRM Module"); 84 m_log.Info("[MRM]: Enabling MRM Module");
79 m_scene = scene; 85 m_Enabled = true;
86 m_Hidden = source.Configs["MRM"].GetBoolean("Hidden", false);
87 }
88 }
89 }
80 90
81 // when hidden, we don't listen for client initiated script events 91 public void AddRegion(Scene scene)
82 // only making the MRM engine available for region modules 92 {
83 if (!source.Configs["MRM"].GetBoolean("Hidden", false)) 93 if (!m_Enabled)
84 { 94 return;
85 scene.EventManager.OnRezScript += EventManager_OnRezScript;
86 scene.EventManager.OnStopScript += EventManager_OnStopScript;
87 }
88 95
89 scene.EventManager.OnFrame += EventManager_OnFrame; 96 m_scene = scene;
90 97
91 scene.RegisterModuleInterface<IMRMModule>(this); 98 // when hidden, we don't listen for client initiated script events
92 } 99 // only making the MRM engine available for region modules
100 if (!m_Hidden)
101 {
102 scene.EventManager.OnRezScript += EventManager_OnRezScript;
103 scene.EventManager.OnStopScript += EventManager_OnStopScript;
93 } 104 }
105
106 scene.EventManager.OnFrame += EventManager_OnFrame;
107
108 scene.RegisterModuleInterface<IMRMModule>(this);
109 }
110
111 public void RegionLoaded(Scene scene)
112 {
94 } 113 }
95 114
115 public void RemoveRegion(Scene scene)
116 {
117 }
118
119 public void Close()
120 {
121 foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts)
122 {
123 pair.Value.Stop();
124 }
125 }
126
127 public string Name
128 {
129 get { return "MiniRegionModule"; }
130 }
131
132 public Type ReplaceableInterface
133 {
134 get { return null; }
135 }
136
137 #endregion
138
96 void EventManager_OnStopScript(uint localID, UUID itemID) 139 void EventManager_OnStopScript(uint localID, UUID itemID)
97 { 140 {
98 if (m_scripts.ContainsKey(itemID)) 141 if (m_scripts.ContainsKey(itemID))
@@ -293,28 +336,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
293 mmb.InitMiniModule(world, host, itemID); 336 mmb.InitMiniModule(world, host, itemID);
294 } 337 }
295 338
296 public void PostInitialise()
297 {
298 }
299
300 public void Close()
301 {
302 foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts)
303 {
304 pair.Value.Stop();
305 }
306 }
307
308 public string Name
309 {
310 get { return "MiniRegionModule"; }
311 }
312
313 public bool IsSharedModule
314 {
315 get { return false; }
316 }
317
318 /// <summary> 339 /// <summary>
319 /// Stolen from ScriptEngine Common 340 /// Stolen from ScriptEngine Common
320 /// </summary> 341 /// </summary>
diff --git a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
index aa23fee..5ed1514 100644
--- a/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/Minimodule/SOPObject.cs
@@ -821,8 +821,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
821 { 821 {
822 if (!CanEdit()) 822 if (!CanEdit())
823 return; 823 return;
824 824 ISoundModule module = m_rootScene.RequestModuleInterface<ISoundModule>();
825 GetSOP().SendSound(asset.ToString(), volume, true, 0, 0, false, false); 825 if (module != null)
826 {
827 module.SendSound(GetSOP().UUID, asset, volume, true, 0, 0, false, false);
828 }
826 } 829 }
827 830
828 #endregion 831 #endregion
diff --git a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
index fff3a32..c550c44 100644
--- a/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/RegionReadyModule/RegionReadyModule.cs
@@ -32,6 +32,7 @@ using System.Net;
32using System.IO; 32using System.IO;
33using System.Text; 33using System.Text;
34using log4net; 34using log4net;
35using Mono.Addins;
35using Nini.Config; 36using Nini.Config;
36using OpenMetaverse; 37using OpenMetaverse;
37using OpenMetaverse.StructuredData; 38using OpenMetaverse.StructuredData;
@@ -42,6 +43,7 @@ using OpenSim.Services.Interfaces;
42 43
43namespace OpenSim.Region.OptionalModules.Scripting.RegionReady 44namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
44{ 45{
46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "RegionReadyModule")]
45 public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule 47 public class RegionReadyModule : IRegionReadyModule, INonSharedRegionModule
46 { 48 {
47 private static readonly ILog m_log = 49 private static readonly ILog m_log =
@@ -181,7 +183,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
181 } 183 }
182 } 184 }
183 185
184 void OnOarFileLoaded(Guid requestId, string message) 186 void OnOarFileLoaded(Guid requestId, List<UUID> loadedScenes, string message)
185 { 187 {
186 m_oarFileLoading = true; 188 m_oarFileLoading = true;
187 189
diff --git a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs b/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
deleted file mode 100644
index c5c96a9..0000000
--- a/OpenSim/Region/OptionalModules/Scripting/ScriptModuleComms/ScriptModuleCommsModule.cs
+++ /dev/null
@@ -1,324 +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.Reflection;
30using System.Collections.Generic;
31using Nini.Config;
32using log4net;
33using OpenSim.Framework;
34using OpenSim.Region.Framework.Interfaces;
35using OpenSim.Region.Framework.Scenes;
36using Mono.Addins;
37using OpenMetaverse;
38using System.Linq;
39using System.Linq.Expressions;
40
41namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
42{
43 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")]
44 class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms
45 {
46 private static readonly ILog m_log =
47 LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
48
49 private Dictionary<string,object> m_constants = new Dictionary<string,object>();
50
51#region ScriptInvocation
52 protected class ScriptInvocationData
53 {
54 public Delegate ScriptInvocationDelegate { get; private set; }
55 public string FunctionName { get; private set; }
56 public Type[] TypeSignature { get; private set; }
57 public Type ReturnType { get; private set; }
58
59 public ScriptInvocationData(string fname, Delegate fn, Type[] callsig, Type returnsig)
60 {
61 FunctionName = fname;
62 ScriptInvocationDelegate = fn;
63 TypeSignature = callsig;
64 ReturnType = returnsig;
65 }
66 }
67
68 private Dictionary<string,ScriptInvocationData> m_scriptInvocation = new Dictionary<string,ScriptInvocationData>();
69#endregion
70
71 private IScriptModule m_scriptModule = null;
72 public event ScriptCommand OnScriptCommand;
73
74#region RegionModuleInterface
75 public void Initialise(IConfigSource config)
76 {
77 }
78
79 public void AddRegion(Scene scene)
80 {
81 scene.RegisterModuleInterface<IScriptModuleComms>(this);
82 }
83
84 public void RemoveRegion(Scene scene)
85 {
86 }
87
88 public void RegionLoaded(Scene scene)
89 {
90 m_scriptModule = scene.RequestModuleInterface<IScriptModule>();
91
92 if (m_scriptModule != null)
93 m_log.Info("[MODULE COMMANDS]: Script engine found, module active");
94 }
95
96 public string Name
97 {
98 get { return "ScriptModuleCommsModule"; }
99 }
100
101 public Type ReplaceableInterface
102 {
103 get { return null; }
104 }
105
106 public void Close()
107 {
108 }
109#endregion
110
111#region ScriptModuleComms
112
113 public void RaiseEvent(UUID script, string id, string module, string command, string k)
114 {
115 ScriptCommand c = OnScriptCommand;
116
117 if (c == null)
118 return;
119
120 c(script, id, module, command, k);
121 }
122
123 public void DispatchReply(UUID script, int code, string text, string k)
124 {
125 if (m_scriptModule == null)
126 return;
127
128 Object[] args = new Object[] {-1, code, text, k};
129
130 m_scriptModule.PostScriptEvent(script, "link_message", args);
131 }
132
133 public void RegisterScriptInvocation(object target, string meth)
134 {
135 MethodInfo mi = target.GetType().GetMethod(meth,
136 BindingFlags.NonPublic | BindingFlags.Public | BindingFlags.Instance);
137 if (mi == null)
138 {
139 m_log.WarnFormat("[MODULE COMMANDS] Failed to register method {0}",meth);
140 return;
141 }
142
143 RegisterScriptInvocation(target, mi);
144 }
145
146 public void RegisterScriptInvocation(object target, string[] meth)
147 {
148 foreach (string m in meth)
149 RegisterScriptInvocation(target, m);
150 }
151
152 public void RegisterScriptInvocation(object target, MethodInfo mi)
153 {
154 m_log.DebugFormat("[MODULE COMMANDS] Register method {0} from type {1}", mi.Name, target.GetType().Name);
155
156 Type delegateType;
157 var typeArgs = mi.GetParameters()
158 .Select(p => p.ParameterType)
159 .ToList();
160
161 if (mi.ReturnType == typeof(void))
162 {
163 delegateType = Expression.GetActionType(typeArgs.ToArray());
164 }
165 else
166 {
167 typeArgs.Add(mi.ReturnType);
168 delegateType = Expression.GetFuncType(typeArgs.ToArray());
169 }
170
171 Delegate fcall = Delegate.CreateDelegate(delegateType, target, mi);
172
173 lock (m_scriptInvocation)
174 {
175 ParameterInfo[] parameters = fcall.Method.GetParameters ();
176 if (parameters.Length < 2) // Must have two UUID params
177 return;
178
179 // Hide the first two parameters
180 Type[] parmTypes = new Type[parameters.Length - 2];
181 for (int i = 2 ; i < parameters.Length ; i++)
182 parmTypes[i - 2] = parameters[i].ParameterType;
183 m_scriptInvocation[fcall.Method.Name] = new ScriptInvocationData(fcall.Method.Name, fcall, parmTypes, fcall.Method.ReturnType);
184 }
185 }
186
187 public Delegate[] GetScriptInvocationList()
188 {
189 List<Delegate> ret = new List<Delegate>();
190
191 lock (m_scriptInvocation)
192 {
193 foreach (ScriptInvocationData d in m_scriptInvocation.Values)
194 ret.Add(d.ScriptInvocationDelegate);
195 }
196 return ret.ToArray();
197 }
198
199 public string LookupModInvocation(string fname)
200 {
201 lock (m_scriptInvocation)
202 {
203 ScriptInvocationData sid;
204 if (m_scriptInvocation.TryGetValue(fname,out sid))
205 {
206 if (sid.ReturnType == typeof(string))
207 return "modInvokeS";
208 else if (sid.ReturnType == typeof(int))
209 return "modInvokeI";
210 else if (sid.ReturnType == typeof(float))
211 return "modInvokeF";
212 else if (sid.ReturnType == typeof(UUID))
213 return "modInvokeK";
214 else if (sid.ReturnType == typeof(OpenMetaverse.Vector3))
215 return "modInvokeV";
216 else if (sid.ReturnType == typeof(OpenMetaverse.Quaternion))
217 return "modInvokeR";
218 else if (sid.ReturnType == typeof(object[]))
219 return "modInvokeL";
220
221 m_log.WarnFormat("[MODULE COMMANDS] failed to find match for {0} with return type {1}",fname,sid.ReturnType.Name);
222 }
223 }
224
225 return null;
226 }
227
228 public Delegate LookupScriptInvocation(string fname)
229 {
230 lock (m_scriptInvocation)
231 {
232 ScriptInvocationData sid;
233 if (m_scriptInvocation.TryGetValue(fname,out sid))
234 return sid.ScriptInvocationDelegate;
235 }
236
237 return null;
238 }
239
240 public Type[] LookupTypeSignature(string fname)
241 {
242 lock (m_scriptInvocation)
243 {
244 ScriptInvocationData sid;
245 if (m_scriptInvocation.TryGetValue(fname,out sid))
246 return sid.TypeSignature;
247 }
248
249 return null;
250 }
251
252 public Type LookupReturnType(string fname)
253 {
254 lock (m_scriptInvocation)
255 {
256 ScriptInvocationData sid;
257 if (m_scriptInvocation.TryGetValue(fname,out sid))
258 return sid.ReturnType;
259 }
260
261 return null;
262 }
263
264 public object InvokeOperation(UUID hostid, UUID scriptid, string fname, params object[] parms)
265 {
266 List<object> olist = new List<object>();
267 olist.Add(hostid);
268 olist.Add(scriptid);
269 foreach (object o in parms)
270 olist.Add(o);
271 Delegate fn = LookupScriptInvocation(fname);
272 return fn.DynamicInvoke(olist.ToArray());
273 }
274
275 /// <summary>
276 /// Operation to for a region module to register a constant to be used
277 /// by the script engine
278 /// </summary>
279 public void RegisterConstant(string cname, object value)
280 {
281 m_log.DebugFormat("[MODULE COMMANDS] register constant <{0}> with value {1}",cname,value.ToString());
282 lock (m_constants)
283 {
284 m_constants.Add(cname,value);
285 }
286 }
287
288 /// <summary>
289 /// Operation to check for a registered constant
290 /// </summary>
291 public object LookupModConstant(string cname)
292 {
293 // m_log.DebugFormat("[MODULE COMMANDS] lookup constant <{0}>",cname);
294
295 lock (m_constants)
296 {
297 object value = null;
298 if (m_constants.TryGetValue(cname,out value))
299 return value;
300 }
301
302 return null;
303 }
304
305 /// <summary>
306 /// Get all registered constants
307 /// </summary>
308 public Dictionary<string, object> GetConstants()
309 {
310 Dictionary<string, object> ret = new Dictionary<string, object>();
311
312 lock (m_constants)
313 {
314 foreach (KeyValuePair<string, object> kvp in m_constants)
315 ret[kvp.Key] = kvp.Value;
316 }
317
318 return ret;
319 }
320
321#endregion
322
323 }
324}
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs
index 2187449..6120a81 100644
--- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcGridRouterModule.cs
@@ -32,6 +32,7 @@ using System.Reflection;
32using log4net; 32using log4net;
33using Nini.Config; 33using Nini.Config;
34using OpenMetaverse; 34using OpenMetaverse;
35using Mono.Addins;
35 36
36using OpenSim.Framework; 37using OpenSim.Framework;
37using OpenSim.Framework.Communications; 38using OpenSim.Framework.Communications;
@@ -49,7 +50,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
49 public string uri; 50 public string uri;
50 } 51 }
51 52
52 public class XmlRpcGridRouter : IRegionModule, IXmlRpcRouter 53 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcGridRouter")]
54 public class XmlRpcGridRouter : INonSharedRegionModule, IXmlRpcRouter
53 { 55 {
54 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 56 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
55 57
@@ -59,9 +61,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
59 private bool m_Enabled = false; 61 private bool m_Enabled = false;
60 private string m_ServerURI = String.Empty; 62 private string m_ServerURI = String.Empty;
61 63
62 public void Initialise(Scene scene, IConfigSource config) 64 #region INonSharedRegionModule
65
66 public void Initialise(IConfigSource config)
63 { 67 {
64 IConfig startupConfig = config.Configs["Startup"]; 68 IConfig startupConfig = config.Configs["XMLRPC"];
65 if (startupConfig == null) 69 if (startupConfig == null)
66 return; 70 return;
67 71
@@ -74,16 +78,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
74 m_log.Error("[XMLRPC GRID ROUTER] Module configured but no URI given. Disabling"); 78 m_log.Error("[XMLRPC GRID ROUTER] Module configured but no URI given. Disabling");
75 return; 79 return;
76 } 80 }
77
78 scene.RegisterModuleInterface<IXmlRpcRouter>(this);
79 m_Enabled = true; 81 m_Enabled = true;
80 } 82 }
81 } 83 }
82 84
83 public void PostInitialise() 85 public void AddRegion(Scene scene)
86 {
87 if (!m_Enabled)
88 return;
89
90 scene.RegisterModuleInterface<IXmlRpcRouter>(this);
91 }
92
93 public void RegionLoaded(Scene scene)
84 { 94 {
85 } 95 }
86 96
97 public void RemoveRegion(Scene scene)
98 {
99 if (!m_Enabled)
100 return;
101
102 scene.UnregisterModuleInterface<IXmlRpcRouter>(this);
103 }
104
87 public void Close() 105 public void Close()
88 { 106 {
89 } 107 }
@@ -93,11 +111,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
93 get { return "XmlRpcGridRouterModule"; } 111 get { return "XmlRpcGridRouterModule"; }
94 } 112 }
95 113
96 public bool IsSharedModule 114 public Type ReplaceableInterface
97 { 115 {
98 get { return false; } 116 get { return null; }
99 } 117 }
100 118
119 #endregion
120
101 public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri) 121 public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri)
102 { 122 {
103 if (!m_Channels.ContainsKey(itemID)) 123 if (!m_Channels.ContainsKey(itemID))
diff --git a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs
index 11c87f8..4bde52a 100644
--- a/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs
+++ b/OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs
@@ -31,6 +31,7 @@ using System.Reflection;
31using log4net; 31using log4net;
32using Nini.Config; 32using Nini.Config;
33using OpenMetaverse; 33using OpenMetaverse;
34using Mono.Addins;
34 35
35using OpenSim.Framework; 36using OpenSim.Framework;
36using OpenSim.Region.Framework.Interfaces; 37using OpenSim.Region.Framework.Interfaces;
@@ -39,32 +40,46 @@ using OpenSim.Region.Framework.Scenes;
39 40
40namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule 41namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule
41{ 42{
42 public class XmlRpcRouter : IRegionModule, IXmlRpcRouter 43 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcRouter")]
44 public class XmlRpcRouter : INonSharedRegionModule, IXmlRpcRouter
43 { 45 {
44 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 46 //private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
45 private bool m_enabled = false; 47
46 public void Initialise(Scene scene, IConfigSource config) 48 private bool m_Enabled;
49
50 #region INonSharedRegionModule
51
52 public void Initialise(IConfigSource config)
47 { 53 {
48 IConfig startupConfig = config.Configs["XMLRPC"]; 54 IConfig startupConfig = config.Configs["XMLRPC"];
49 if (startupConfig == null) 55 if (startupConfig == null)
50 return; 56 return;
51 57
52 if (startupConfig.GetString("XmlRpcRouterModule", 58 if (startupConfig.GetString("XmlRpcRouterModule",
53 "") == "XmlRpcRouterModule") 59 "XmlRpcRouterModule") == "XmlRpcRouterModule")
54 { 60 m_Enabled = true;
55 scene.RegisterModuleInterface<IXmlRpcRouter>(this); 61 }
56 m_enabled = true; 62
57 } 63 public void AddRegion(Scene scene)
58 else 64 {
59 { 65 if (!m_Enabled)
60 m_enabled = false; 66 return;
61 } 67
68 scene.RegisterModuleInterface<IXmlRpcRouter>(this);
62 } 69 }
63 70
64 public void PostInitialise() 71 public void RegionLoaded(Scene scene)
65 { 72 {
66 } 73 }
67 74
75 public void RemoveRegion(Scene scene)
76 {
77 if (!m_Enabled)
78 return;
79
80 scene.UnregisterModuleInterface<IXmlRpcRouter>(this);
81 }
82
68 public void Close() 83 public void Close()
69 { 84 {
70 } 85 }
@@ -74,14 +89,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule
74 get { return "XmlRpcRouterModule"; } 89 get { return "XmlRpcRouterModule"; }
75 } 90 }
76 91
77 public bool IsSharedModule 92 public Type ReplaceableInterface
78 { 93 {
79 get { return false; } 94 get { return null; }
80 } 95 }
81 96
97 #endregion
98
82 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)
83 { 100 {
84 if (m_enabled) 101 if (m_Enabled)
85 { 102 {
86 scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] { uri }); 103 scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] { uri });
87 } 104 }
diff --git a/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs b/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs
index 74c5139..78c870a 100644
--- a/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs
+++ b/OpenSim/Region/OptionalModules/ServiceConnectorsIn/Freeswitch/FreeswitchServiceInConnectorModule.cs
@@ -48,7 +48,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsIn.Freeswitch
48 private IConfigSource m_Config; 48 private IConfigSource m_Config;
49 bool m_Registered = false; 49 bool m_Registered = false;
50 50
51 #region IRegionModule interface 51 #region Region Module interface
52 52
53 public void Initialise(IConfigSource config) 53 public void Initialise(IConfigSource config)
54 { 54 {
diff --git a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs
index ec9f157..1d35c54 100644
--- a/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs
+++ b/OpenSim/Region/OptionalModules/World/AutoBackup/AutoBackupModule.cs
@@ -33,6 +33,7 @@ using System.Reflection;
33using System.Timers; 33using System.Timers;
34using System.Text.RegularExpressions; 34using System.Text.RegularExpressions;
35using log4net; 35using log4net;
36using Mono.Addins;
36using Nini.Config; 37using Nini.Config;
37using OpenSim.Framework; 38using OpenSim.Framework;
38using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
@@ -95,6 +96,7 @@ namespace OpenSim.Region.OptionalModules.World.AutoBackup
95 /// Save memory by setting low initial capacities. Minimizes impact in common cases of all regions using same interval, and instances hosting 1 ~ 4 regions. 96 /// Save memory by setting low initial capacities. Minimizes impact in common cases of all regions using same interval, and instances hosting 1 ~ 4 regions.
96 /// Also helps if you don't want AutoBackup at all. 97 /// Also helps if you don't want AutoBackup at all.
97 /// </remarks> 98 /// </remarks>
99 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "AutoBackupModule")]
98 public class AutoBackupModule : ISharedRegionModule 100 public class AutoBackupModule : ISharedRegionModule
99 { 101 {
100 private static readonly ILog m_log = 102 private static readonly ILog m_log =
diff --git a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
index d206f69..c0d1355 100644
--- a/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
+++ b/OpenSim/Region/OptionalModules/World/MoneyModule/SampleMoneyModule.cs
@@ -55,7 +55,7 @@ namespace OpenSim.Region.OptionalModules.World.MoneyModule
55 /// 55 ///
56 /// </summary> 56 /// </summary>
57 57
58 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")] 58 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "SampleMoneyModule")]
59 public class SampleMoneyModule : IMoneyModule, ISharedRegionModule 59 public class SampleMoneyModule : IMoneyModule, 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);
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
index 6c8e2fc..3a03101 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCAvatar.cs
@@ -148,7 +148,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
148 OnInstantMessage(this, new GridInstantMessage(m_scene, 148 OnInstantMessage(this, new GridInstantMessage(m_scene,
149 m_uuid, m_firstname + " " + m_lastname, 149 m_uuid, m_firstname + " " + m_lastname,
150 target, 0, false, message, 150 target, 0, false, message,
151 UUID.Zero, false, Position, new byte[0])); 151 UUID.Zero, false, Position, new byte[0], true));
152 } 152 }
153 153
154 public void SendAgentOffline(UUID[] agentIDs) 154 public void SendAgentOffline(UUID[] agentIDs)
@@ -607,13 +607,15 @@ namespace OpenSim.Region.OptionalModules.World.NPC
607 { 607 {
608 } 608 }
609 609
610 public virtual void SendChatMessage(string message, byte type, Vector3 fromPos, string fromName, 610 public virtual void SendChatMessage(
611 UUID fromAgentID, byte source, byte audible) 611 string message, byte type, Vector3 fromPos, string fromName,
612 UUID fromAgentID, UUID ownerID, byte source, byte audible)
612 { 613 {
613 } 614 }
614 615
615 public virtual void SendChatMessage(byte[] message, byte type, Vector3 fromPos, string fromName, 616 public virtual void SendChatMessage(
616 UUID fromAgentID, byte source, byte audible) 617 byte[] message, byte type, Vector3 fromPos, string fromName,
618 UUID fromAgentID, UUID ownerID, byte source, byte audible)
617 { 619 {
618 } 620 }
619 621
@@ -909,11 +911,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
909 911
910 public void Close() 912 public void Close()
911 { 913 {
912 Close(true); 914 Close(true, false);
913 } 915 }
914 916
915 public void Close(bool sendStop) 917 public void Close(bool sendStop, bool force)
916 { 918 {
919 // Remove ourselves from the scene
920 m_scene.RemoveClient(AgentId, false);
917 } 921 }
918 922
919 public void Start() 923 public void Start()
diff --git a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
index f16927c..8c9c006 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
@@ -29,37 +29,57 @@ using System;
29using System.Collections.Generic; 29using System.Collections.Generic;
30using System.Reflection; 30using System.Reflection;
31using System.Threading; 31using System.Threading;
32using Timer = System.Timers.Timer;
33
32using log4net; 34using log4net;
33using Nini.Config; 35using Nini.Config;
36using Mono.Addins;
34using OpenMetaverse; 37using OpenMetaverse;
38
35using OpenSim.Region.Framework.Interfaces; 39using OpenSim.Region.Framework.Interfaces;
36using OpenSim.Region.Framework.Scenes; 40using OpenSim.Region.Framework.Scenes;
37using OpenSim.Framework; 41using OpenSim.Framework;
38using Timer=System.Timers.Timer;
39using OpenSim.Services.Interfaces; 42using OpenSim.Services.Interfaces;
40 43
41namespace OpenSim.Region.OptionalModules.World.NPC 44namespace OpenSim.Region.OptionalModules.World.NPC
42{ 45{
43 public class NPCModule : IRegionModule, INPCModule 46 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "NPCModule")]
47 public class NPCModule : INPCModule, ISharedRegionModule
44 { 48 {
45 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 49 private static readonly ILog m_log = LogManager.GetLogger(
50 MethodBase.GetCurrentMethod().DeclaringType);
51
52 private Dictionary<UUID, NPCAvatar> m_avatars =
53 new Dictionary<UUID, NPCAvatar>();
46 54
47 private Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>(); 55 public bool Enabled { get; private set; }
48 56
49 public void Initialise(Scene scene, IConfigSource source) 57 public void Initialise(IConfigSource source)
50 { 58 {
51 IConfig config = source.Configs["NPC"]; 59 IConfig config = source.Configs["NPC"];
52 60
53 if (config != null && config.GetBoolean("Enabled", false)) 61 Enabled = (config != null && config.GetBoolean("Enabled", false));
54 { 62 }
63
64 public void AddRegion(Scene scene)
65 {
66 if (Enabled)
55 scene.RegisterModuleInterface<INPCModule>(this); 67 scene.RegisterModuleInterface<INPCModule>(this);
56 } 68 }
69
70 public void RegionLoaded(Scene scene)
71 {
57 } 72 }
58 73
59 public void PostInitialise() 74 public void PostInitialise()
60 { 75 {
61 } 76 }
62 77
78 public void RemoveRegion(Scene scene)
79 {
80 scene.UnregisterModuleInterface<INPCModule>(this);
81 }
82
63 public void Close() 83 public void Close()
64 { 84 {
65 } 85 }
@@ -69,15 +89,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
69 get { return "NPCModule"; } 89 get { return "NPCModule"; }
70 } 90 }
71 91
72 public bool IsSharedModule 92 public Type ReplaceableInterface { get { return null; } }
73 {
74 get { return true; }
75 }
76 93
77 public bool IsNPC(UUID agentId, Scene scene) 94 public bool IsNPC(UUID agentId, Scene scene)
78 { 95 {
79 // FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect 96 // FIXME: This implementation could not just use the
80 // that directly). 97 // ScenePresence.PresenceType (and callers could inspect that
98 // directly).
81 ScenePresence sp = scene.GetScenePresence(agentId); 99 ScenePresence sp = scene.GetScenePresence(agentId);
82 if (sp == null || sp.IsChildAgent) 100 if (sp == null || sp.IsChildAgent)
83 return false; 101 return false;
@@ -86,7 +104,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
86 return m_avatars.ContainsKey(agentId); 104 return m_avatars.ContainsKey(agentId);
87 } 105 }
88 106
89 public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene) 107 public bool SetNPCAppearance(UUID agentId,
108 AvatarAppearance appearance, Scene scene)
90 { 109 {
91 ScenePresence npc = scene.GetScenePresence(agentId); 110 ScenePresence npc = scene.GetScenePresence(agentId);
92 if (npc == null || npc.IsChildAgent) 111 if (npc == null || npc.IsChildAgent)
@@ -99,30 +118,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC
99 // Delete existing npc attachments 118 // Delete existing npc attachments
100 scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false); 119 scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false);
101 120
102 // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments 121 // XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet
103 AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); 122 // since it doesn't transfer attachments
123 AvatarAppearance npcAppearance = new AvatarAppearance(appearance,
124 true);
104 npc.Appearance = npcAppearance; 125 npc.Appearance = npcAppearance;
105 126
106 // Rez needed npc attachments 127 // Rez needed npc attachments
107 scene.AttachmentsModule.RezAttachments(npc); 128 scene.AttachmentsModule.RezAttachments(npc);
108 129
109 IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>(); 130 IAvatarFactoryModule module =
131 scene.RequestModuleInterface<IAvatarFactoryModule>();
110 module.SendAppearance(npc.UUID); 132 module.SendAppearance(npc.UUID);
111 133
112 return true; 134 return true;
113 } 135 }
114 136
115 public UUID CreateNPC( 137 public UUID CreateNPC(string firstname, string lastname,
116 string firstname, 138 Vector3 position, UUID owner, bool senseAsAgent, Scene scene,
117 string lastname, 139 AvatarAppearance appearance)
118 Vector3 position,
119 UUID owner,
120 bool senseAsAgent,
121 Scene scene,
122 AvatarAppearance appearance)
123 { 140 {
124 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene); 141 NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position,
125 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue); 142 owner, senseAsAgent, scene);
143 npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0,
144 int.MaxValue);
126 145
127// m_log.DebugFormat( 146// m_log.DebugFormat(
128// "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}", 147// "[NPC MODULE]: Creating NPC {0} {1} {2}, owner={3}, senseAsAgent={4} at {5} in {6}",
@@ -134,15 +153,20 @@ namespace OpenSim.Region.OptionalModules.World.NPC
134 acd.lastname = lastname; 153 acd.lastname = lastname;
135 acd.ServiceURLs = new Dictionary<string, object>(); 154 acd.ServiceURLs = new Dictionary<string, object>();
136 155
137 AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true); 156 AvatarAppearance npcAppearance = new AvatarAppearance(appearance,
157 true);
138 acd.Appearance = npcAppearance; 158 acd.Appearance = npcAppearance;
139 159
140// for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++) 160 /*
141// { 161 for (int i = 0;
142// m_log.DebugFormat( 162 i < acd.Appearance.Texture.FaceTextures.Length; i++)
143// "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}", 163 {
144// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]); 164 m_log.DebugFormat(
145// } 165 "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
166 acd.AgentID, i,
167 acd.Appearance.Texture.FaceTextures[i]);
168 }
169 */
146 170
147 ManualResetEvent ev = new ManualResetEvent(false); 171 ManualResetEvent ev = new ManualResetEvent(false);
148 172
@@ -170,7 +194,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
170 return npcAvatar.AgentId; 194 return npcAvatar.AgentId;
171 } 195 }
172 196
173 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running) 197 public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos,
198 bool noFly, bool landAtTarget, bool running)
174 { 199 {
175 lock (m_avatars) 200 lock (m_avatars)
176 { 201 {
@@ -185,7 +210,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
185 210
186 sp.MoveToTarget(pos, noFly, landAtTarget); 211 sp.MoveToTarget(pos, noFly, landAtTarget);
187 sp.SetAlwaysRun = running; 212 sp.SetAlwaysRun = running;
188 213
189 return true; 214 return true;
190 } 215 }
191 } 216 }
@@ -258,9 +283,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
258 ScenePresence sp; 283 ScenePresence sp;
259 if (scene.TryGetScenePresence(agentID, out sp)) 284 if (scene.TryGetScenePresence(agentID, out sp))
260 { 285 {
261 sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero); 286 sp.HandleAgentRequestSit(m_avatars[agentID], agentID,
262 // sp.HandleAgentSit(m_avatars[agentID], agentID); 287 partID, Vector3.Zero);
263 288 //sp.HandleAgentSit(m_avatars[agentID], agentID);
289
264 return true; 290 return true;
265 } 291 }
266 } 292 }
@@ -269,7 +295,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
269 return false; 295 return false;
270 } 296 }
271 297
272 public bool Whisper(UUID agentID, Scene scene, string text, int channel) 298 public bool Whisper(UUID agentID, Scene scene, string text,
299 int channel)
273 { 300 {
274 lock (m_avatars) 301 lock (m_avatars)
275 { 302 {
@@ -344,7 +371,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
344 NPCAvatar av; 371 NPCAvatar av;
345 if (m_avatars.TryGetValue(agentID, out av)) 372 if (m_avatars.TryGetValue(agentID, out av))
346 { 373 {
347// m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", agentID, av.Name); 374 /*
375 m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove",
376 agentID, av.Name);
377 */
348 scene.RemoveClient(agentID, false); 378 scene.RemoveClient(agentID, false);
349 m_avatars.Remove(agentID); 379 m_avatars.Remove(agentID);
350 380
@@ -352,8 +382,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
352 return true; 382 return true;
353 } 383 }
354 } 384 }
355 385 /*
356// m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove", agentID); 386 m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove",
387 agentID);
388 */
357 return false; 389 return false;
358 } 390 }
359 391
diff --git a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
index 9179966..52ed846 100644
--- a/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
+++ b/OpenSim/Region/OptionalModules/World/NPC/Tests/NPCModuleTests.cs
@@ -117,6 +117,12 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
117 Assert.That(npc, Is.Not.Null); 117 Assert.That(npc, Is.Not.Null);
118 Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId)); 118 Assert.That(npc.Appearance.Texture.FaceTextures[8].TextureID, Is.EqualTo(originalFace8TextureId));
119 Assert.That(m_umMod.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname))); 119 Assert.That(m_umMod.GetUserName(npc.UUID), Is.EqualTo(string.Format("{0} {1}", npc.Firstname, npc.Lastname)));
120
121 IClientAPI client;
122 Assert.That(m_scene.TryGetClient(npcId, out client), Is.True);
123
124 // Have to account for both SP and NPC.
125 Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(2));
120 } 126 }
121 127
122 [Test] 128 [Test]
@@ -136,6 +142,11 @@ namespace OpenSim.Region.OptionalModules.World.NPC.Tests
136 ScenePresence deletedNpc = m_scene.GetScenePresence(npcId); 142 ScenePresence deletedNpc = m_scene.GetScenePresence(npcId);
137 143
138 Assert.That(deletedNpc, Is.Null); 144 Assert.That(deletedNpc, Is.Null);
145 IClientAPI client;
146 Assert.That(m_scene.TryGetClient(npcId, out client), Is.False);
147
148 // Have to account for SP still present.
149 Assert.That(m_scene.AuthenticateHandler.GetAgentCircuits().Count, Is.EqualTo(1));
139 } 150 }
140 151
141 [Test] 152 [Test]
diff --git a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
index 51b0592..8144870 100644
--- a/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
+++ b/OpenSim/Region/OptionalModules/World/TreePopulator/TreePopulatorModule.cs
@@ -31,6 +31,7 @@ using System.Reflection;
31using System.Timers; 31using System.Timers;
32using OpenMetaverse; 32using OpenMetaverse;
33using log4net; 33using log4net;
34using Mono.Addins;
34using Nini.Config; 35using Nini.Config;
35using OpenSim.Framework; 36using OpenSim.Framework;
36using OpenSim.Region.CoreModules.Framework.InterfaceCommander; 37using OpenSim.Region.CoreModules.Framework.InterfaceCommander;
@@ -46,7 +47,8 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
46 /// <summary> 47 /// <summary>
47 /// Version 2.02 - Still hacky 48 /// Version 2.02 - Still hacky
48 /// </summary> 49 /// </summary>
49 public class TreePopulatorModule : IRegionModule, ICommandableModule, IVegetationModule 50 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "TreePopulatorModule")]
51 public class TreePopulatorModule : INonSharedRegionModule, ICommandableModule, IVegetationModule
50 { 52 {
51 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); 53 private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
52 private readonly Commander m_commander = new Commander("tree"); 54 private readonly Commander m_commander = new Commander("tree");
@@ -168,15 +170,11 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
168 170
169 #endregion 171 #endregion
170 172
171 #region IRegionModule Members 173 #region Region Module interface
172 174
173 public void Initialise(Scene scene, IConfigSource config) 175 public void Initialise(IConfigSource config)
174 { 176 {
175 177
176 m_scene = scene;
177 m_scene.RegisterModuleInterface<IRegionModule>(this);
178 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
179
180 // ini file settings 178 // ini file settings
181 try 179 try
182 { 180 {
@@ -201,7 +199,19 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
201 m_log.Debug("[TREES]: Initialised tree module"); 199 m_log.Debug("[TREES]: Initialised tree module");
202 } 200 }
203 201
204 public void PostInitialise() 202 public void AddRegion(Scene scene)
203 {
204 m_scene = scene;
205 m_scene.RegisterModuleCommander(m_commander);
206 m_scene.EventManager.OnPluginConsole += EventManager_OnPluginConsole;
207
208 }
209
210 public void RemoveRegion(Scene scene)
211 {
212 }
213
214 public void RegionLoaded(Scene scene)
205 { 215 {
206 ReloadCopse(); 216 ReloadCopse();
207 if (m_copse.Count > 0) 217 if (m_copse.Count > 0)
@@ -220,11 +230,12 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
220 get { return "TreePopulatorModule"; } 230 get { return "TreePopulatorModule"; }
221 } 231 }
222 232
223 public bool IsSharedModule 233 public Type ReplaceableInterface
224 { 234 {
225 get { return false; } 235 get { return null; }
226 } 236 }
227 237
238
228 #endregion 239 #endregion
229 240
230 //-------------------------------------------------------------- 241 //--------------------------------------------------------------
@@ -448,8 +459,6 @@ namespace OpenSim.Region.OptionalModules.World.TreePopulator
448 m_commander.RegisterCommand("reload", treeReloadCommand); 459 m_commander.RegisterCommand("reload", treeReloadCommand);
449 m_commander.RegisterCommand("remove", treeRemoveCommand); 460 m_commander.RegisterCommand("remove", treeRemoveCommand);
450 m_commander.RegisterCommand("statistics", treeStatisticsCommand); 461 m_commander.RegisterCommand("statistics", treeStatisticsCommand);
451
452 m_scene.RegisterModuleCommander(m_commander);
453 } 462 }
454 463
455 /// <summary> 464 /// <summary>
diff --git a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs
index 1aee39a..baf55c3 100644
--- a/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs
+++ b/OpenSim/Region/OptionalModules/World/WorldView/WorldViewModule.cs
@@ -32,6 +32,7 @@ using System.Drawing.Imaging;
32using System.Reflection; 32using System.Reflection;
33using System.IO; 33using System.IO;
34using log4net; 34using log4net;
35using Mono.Addins;
35using Nini.Config; 36using Nini.Config;
36using OpenMetaverse; 37using OpenMetaverse;
37using OpenMetaverse.Imaging; 38using OpenMetaverse.Imaging;
@@ -45,6 +46,7 @@ using OpenSim.Services.Interfaces;
45 46
46namespace OpenSim.Region.OptionalModules.World.WorldView 47namespace OpenSim.Region.OptionalModules.World.WorldView
47{ 48{
49 [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "WorldViewModule")]
48 public class WorldViewModule : INonSharedRegionModule 50 public class WorldViewModule : INonSharedRegionModule
49 { 51 {
50 private static readonly ILog m_log = 52 private static readonly ILog m_log =