Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/CoreModules/Framework/InventoryAccess/InventoryAccessModule.cs
	OpenSim/Region/CoreModules/World/Permissions/PermissionsModule.cs
	OpenSim/Region/OptionalModules/Scripting/XmlRpcRouterModule/XmlRpcRouterModule.cs
	OpenSim/Region/OptionalModules/World/NPC/NPCModule.cs
This commit is contained in:
Melanie
2012-11-12 15:46:45 +00:00
17 changed files with 860 additions and 533 deletions

View File

@@ -25,6 +25,7 @@
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Net;
using System.Reflection;
using log4net;
@@ -33,29 +34,65 @@ using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Region.OptionalModules.Agent.InternetRelayClientView.Server;
using Mono.Addins;
namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView
{
public class IRCStackModule : IRegionModule
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "IRCStackModule")]
public class IRCStackModule : INonSharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IRCServer m_server;
private int m_Port;
// private Scene m_scene;
private bool m_Enabled;
#region Implementation of IRegionModule
#region Implementation of INonSharedRegionModule
public void Initialise(Scene scene, IConfigSource source)
public void Initialise(IConfigSource source)
{
if (null != source.Configs["IRCd"] &&
source.Configs["IRCd"].GetBoolean("Enabled",false))
source.Configs["IRCd"].GetBoolean("Enabled", false))
{
int portNo = source.Configs["IRCd"].GetInt("Port",6666);
// m_scene = scene;
m_server = new IRCServer(IPAddress.Parse("0.0.0.0"), portNo, scene);
m_server.OnNewIRCClient += m_server_OnNewIRCClient;
m_Enabled = true;
m_Port = source.Configs["IRCd"].GetInt("Port", 6666);
}
}
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
m_server = new IRCServer(IPAddress.Parse("0.0.0.0"), m_Port, scene);
m_server.OnNewIRCClient += m_server_OnNewIRCClient;
}
public void RegionLoaded(Scene scene)
{
}
public void RemoveRegion(Scene scene)
{
}
public void Close()
{
}
public string Name
{
get { return "IRCClientStackModule"; }
}
public Type ReplaceableInterface
{
get { return null; }
}
#endregion
void m_server_OnNewIRCClient(IRCClientView user)
{
user.OnIRCReady += user_OnIRCReady;
@@ -68,26 +105,5 @@ namespace OpenSim.Region.OptionalModules.Agent.InternetRelayClientView
m_log.Info("[IRCd] Added user to Scene");
}
public void PostInitialise()
{
}
public void Close()
{
}
public string Name
{
get { return "IRCClientStackModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
#endregion
}
}

View File

@@ -43,13 +43,17 @@ using OpenMetaverse;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using Mono.Addins;
namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
{
public class MRMModule : IRegionModule, IMRMModule
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "MRMModule")]
public class MRMModule : INonSharedRegionModule, IMRMModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Scene m_scene;
private bool m_Enabled;
private bool m_Hidden;
private readonly Dictionary<UUID,MRMBase> m_scripts = new Dictionary<UUID, MRMBase>();
@@ -67,7 +71,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
m_extensions[typeof (T)] = instance;
}
public void Initialise(Scene scene, IConfigSource source)
#region INonSharedRegionModule
public void Initialise(IConfigSource source)
{
if (source.Configs["MRM"] != null)
{
@@ -76,23 +82,60 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
if (source.Configs["MRM"].GetBoolean("Enabled", false))
{
m_log.Info("[MRM]: Enabling MRM Module");
m_scene = scene;
// when hidden, we don't listen for client initiated script events
// only making the MRM engine available for region modules
if (!source.Configs["MRM"].GetBoolean("Hidden", false))
{
scene.EventManager.OnRezScript += EventManager_OnRezScript;
scene.EventManager.OnStopScript += EventManager_OnStopScript;
}
scene.EventManager.OnFrame += EventManager_OnFrame;
scene.RegisterModuleInterface<IMRMModule>(this);
m_Enabled = true;
m_Hidden = source.Configs["MRM"].GetBoolean("Hidden", false);
}
}
}
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
m_scene = scene;
// when hidden, we don't listen for client initiated script events
// only making the MRM engine available for region modules
if (!m_Hidden)
{
scene.EventManager.OnRezScript += EventManager_OnRezScript;
scene.EventManager.OnStopScript += EventManager_OnStopScript;
}
scene.EventManager.OnFrame += EventManager_OnFrame;
scene.RegisterModuleInterface<IMRMModule>(this);
}
public void RegionLoaded(Scene scene)
{
}
public void RemoveRegion(Scene scene)
{
}
public void Close()
{
foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts)
{
pair.Value.Stop();
}
}
public string Name
{
get { return "MiniRegionModule"; }
}
public Type ReplaceableInterface
{
get { return null; }
}
#endregion
void EventManager_OnStopScript(uint localID, UUID itemID)
{
if (m_scripts.ContainsKey(itemID))
@@ -293,28 +336,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.Minimodule
mmb.InitMiniModule(world, host, itemID);
}
public void PostInitialise()
{
}
public void Close()
{
foreach (KeyValuePair<UUID, MRMBase> pair in m_scripts)
{
pair.Value.Stop();
}
}
public string Name
{
get { return "MiniRegionModule"; }
}
public bool IsSharedModule
{
get { return false; }
}
/// <summary>
/// Stolen from ScriptEngine Common
/// </summary>

View File

@@ -32,6 +32,7 @@ using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using Mono.Addins;
using OpenSim.Framework;
using OpenSim.Framework.Communications;
@@ -49,7 +50,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
public string uri;
}
public class XmlRpcGridRouter : IRegionModule, IXmlRpcRouter
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcGridRouter")]
public class XmlRpcGridRouter : INonSharedRegionModule, IXmlRpcRouter
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
@@ -59,9 +61,11 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
private bool m_Enabled = false;
private string m_ServerURI = String.Empty;
public void Initialise(Scene scene, IConfigSource config)
#region INonSharedRegionModule
public void Initialise(IConfigSource config)
{
IConfig startupConfig = config.Configs["Startup"];
IConfig startupConfig = config.Configs["XMLRPC"];
if (startupConfig == null)
return;
@@ -74,14 +78,28 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
m_log.Error("[XMLRPC GRID ROUTER] Module configured but no URI given. Disabling");
return;
}
scene.RegisterModuleInterface<IXmlRpcRouter>(this);
m_Enabled = true;
}
}
public void PostInitialise()
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
scene.RegisterModuleInterface<IXmlRpcRouter>(this);
}
public void RegionLoaded(Scene scene)
{
}
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
scene.UnregisterModuleInterface<IXmlRpcRouter>(this);
}
public void Close()
@@ -93,11 +111,13 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcGridRouterModule
get { return "XmlRpcGridRouterModule"; }
}
public bool IsSharedModule
public Type ReplaceableInterface
{
get { return false; }
get { return null; }
}
#endregion
public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri)
{
if (!m_Channels.ContainsKey(itemID))

View File

@@ -31,6 +31,7 @@ using System.Reflection;
using log4net;
using Nini.Config;
using OpenMetaverse;
using Mono.Addins;
using OpenSim.Framework;
using OpenSim.Region.Framework.Interfaces;
@@ -39,30 +40,44 @@ using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule
{
public class XmlRpcRouter : IRegionModule, IXmlRpcRouter
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "XmlRpcRouter")]
public class XmlRpcRouter : INonSharedRegionModule, IXmlRpcRouter
{
//private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private bool m_enabled = false;
public void Initialise(Scene scene, IConfigSource config)
private bool m_Enabled;
#region INonSharedRegionModule
public void Initialise(IConfigSource config)
{
IConfig startupConfig = config.Configs["XMLRPC"];
if (startupConfig == null)
return;
if (startupConfig.GetString("XmlRpcRouterModule",
"") == "XmlRpcRouterModule")
{
scene.RegisterModuleInterface<IXmlRpcRouter>(this);
m_enabled = true;
}
else
{
m_enabled = false;
}
"XmlRpcRouterModule") == "XmlRpcRouterModule")
m_Enabled = true;
}
public void PostInitialise()
public void AddRegion(Scene scene)
{
if (!m_Enabled)
return;
scene.RegisterModuleInterface<IXmlRpcRouter>(this);
}
public void RegionLoaded(Scene scene)
{
}
public void RemoveRegion(Scene scene)
{
if (!m_Enabled)
return;
scene.UnregisterModuleInterface<IXmlRpcRouter>(this);
}
public void Close()
@@ -74,14 +89,16 @@ namespace OpenSim.Region.OptionalModules.Scripting.XmlRpcRouterModule
get { return "XmlRpcRouterModule"; }
}
public bool IsSharedModule
public Type ReplaceableInterface
{
get { return false; }
get { return null; }
}
#endregion
public void RegisterNewReceiver(IScriptModule scriptEngine, UUID channel, UUID objectID, UUID itemID, string uri)
{
if (m_enabled)
if (m_Enabled)
{
scriptEngine.PostScriptEvent(itemID, "xmlrpc_uri", new Object[] { uri });
}

View File

@@ -29,37 +29,57 @@ using System;
using System.Collections.Generic;
using System.Reflection;
using System.Threading;
using Timer = System.Timers.Timer;
using log4net;
using Nini.Config;
using Mono.Addins;
using OpenMetaverse;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Framework;
using Timer=System.Timers.Timer;
using OpenSim.Services.Interfaces;
namespace OpenSim.Region.OptionalModules.World.NPC
{
public class NPCModule : IRegionModule, INPCModule
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule")]
public class NPCModule : INPCModule, ISharedRegionModule
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly ILog m_log = LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private Dictionary<UUID, NPCAvatar> m_avatars = new Dictionary<UUID, NPCAvatar>();
private Dictionary<UUID, NPCAvatar> m_avatars =
new Dictionary<UUID, NPCAvatar>();
public void Initialise(Scene scene, IConfigSource source)
public bool Enabled { get; private set; }
public void Initialise(IConfigSource source)
{
IConfig config = source.Configs["NPC"];
if (config != null && config.GetBoolean("Enabled", false))
{
Enabled = (config != null && config.GetBoolean("Enabled", false));
}
public void AddRegion(Scene scene)
{
if (Enabled)
scene.RegisterModuleInterface<INPCModule>(this);
}
}
public void RegionLoaded(Scene scene)
{
}
public void PostInitialise()
{
}
public void RemoveRegion(Scene scene)
{
scene.UnregisterModuleInterface<INPCModule>(this);
}
public void Close()
{
}
@@ -69,15 +89,13 @@ namespace OpenSim.Region.OptionalModules.World.NPC
get { return "NPCModule"; }
}
public bool IsSharedModule
{
get { return true; }
}
public Type ReplaceableInterface { get { return null; } }
public bool IsNPC(UUID agentId, Scene scene)
{
// FIXME: This implementation could not just use the ScenePresence.PresenceType (and callers could inspect
// that directly).
// FIXME: This implementation could not just use the
// ScenePresence.PresenceType (and callers could inspect that
// directly).
ScenePresence sp = scene.GetScenePresence(agentId);
if (sp == null || sp.IsChildAgent)
return false;
@@ -86,7 +104,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return m_avatars.ContainsKey(agentId);
}
public bool SetNPCAppearance(UUID agentId, AvatarAppearance appearance, Scene scene)
public bool SetNPCAppearance(UUID agentId,
AvatarAppearance appearance, Scene scene)
{
ScenePresence npc = scene.GetScenePresence(agentId);
if (npc == null || npc.IsChildAgent)
@@ -99,30 +118,30 @@ namespace OpenSim.Region.OptionalModules.World.NPC
// Delete existing npc attachments
scene.AttachmentsModule.DeleteAttachmentsFromScene(npc, false);
// XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet since it doesn't transfer attachments
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
// XXX: We can't just use IAvatarFactoryModule.SetAppearance() yet
// since it doesn't transfer attachments
AvatarAppearance npcAppearance = new AvatarAppearance(appearance,
true);
npc.Appearance = npcAppearance;
// Rez needed npc attachments
scene.AttachmentsModule.RezAttachments(npc);
IAvatarFactoryModule module = scene.RequestModuleInterface<IAvatarFactoryModule>();
IAvatarFactoryModule module =
scene.RequestModuleInterface<IAvatarFactoryModule>();
module.SendAppearance(npc.UUID);
return true;
}
public UUID CreateNPC(
string firstname,
string lastname,
Vector3 position,
UUID owner,
bool senseAsAgent,
Scene scene,
AvatarAppearance appearance)
public UUID CreateNPC(string firstname, string lastname,
Vector3 position, UUID owner, bool senseAsAgent, Scene scene,
AvatarAppearance appearance)
{
NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position, owner, senseAsAgent, scene);
npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0, int.MaxValue);
NPCAvatar npcAvatar = new NPCAvatar(firstname, lastname, position,
owner, senseAsAgent, scene);
npcAvatar.CircuitCode = (uint)Util.RandomClass.Next(0,
int.MaxValue);
// m_log.DebugFormat(
// "[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
acd.lastname = lastname;
acd.ServiceURLs = new Dictionary<string, object>();
AvatarAppearance npcAppearance = new AvatarAppearance(appearance, true);
AvatarAppearance npcAppearance = new AvatarAppearance(appearance,
true);
acd.Appearance = npcAppearance;
// for (int i = 0; i < acd.Appearance.Texture.FaceTextures.Length; i++)
// {
// m_log.DebugFormat(
// "[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
// acd.AgentID, i, acd.Appearance.Texture.FaceTextures[i]);
// }
/*
for (int i = 0;
i < acd.Appearance.Texture.FaceTextures.Length; i++)
{
m_log.DebugFormat(
"[NPC MODULE]: NPC avatar {0} has texture id {1} : {2}",
acd.AgentID, i,
acd.Appearance.Texture.FaceTextures[i]);
}
*/
ManualResetEvent ev = new ManualResetEvent(false);
@@ -170,7 +194,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return npcAvatar.AgentId;
}
public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos, bool noFly, bool landAtTarget, bool running)
public bool MoveToTarget(UUID agentID, Scene scene, Vector3 pos,
bool noFly, bool landAtTarget, bool running)
{
lock (m_avatars)
{
@@ -185,7 +210,7 @@ namespace OpenSim.Region.OptionalModules.World.NPC
sp.MoveToTarget(pos, noFly, landAtTarget);
sp.SetAlwaysRun = running;
return true;
}
}
@@ -258,9 +283,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
ScenePresence sp;
if (scene.TryGetScenePresence(agentID, out sp))
{
sp.HandleAgentRequestSit(m_avatars[agentID], agentID, partID, Vector3.Zero);
// sp.HandleAgentSit(m_avatars[agentID], agentID);
sp.HandleAgentRequestSit(m_avatars[agentID], agentID,
partID, Vector3.Zero);
//sp.HandleAgentSit(m_avatars[agentID], agentID);
return true;
}
}
@@ -269,7 +295,8 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return false;
}
public bool Whisper(UUID agentID, Scene scene, string text, int channel)
public bool Whisper(UUID agentID, Scene scene, string text,
int channel)
{
lock (m_avatars)
{
@@ -344,7 +371,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
NPCAvatar av;
if (m_avatars.TryGetValue(agentID, out av))
{
// m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove", agentID, av.Name);
/*
m_log.DebugFormat("[NPC MODULE]: Found {0} {1} to remove",
agentID, av.Name);
*/
scene.RemoveClient(agentID, false);
m_avatars.Remove(agentID);
@@ -352,8 +382,10 @@ namespace OpenSim.Region.OptionalModules.World.NPC
return true;
}
}
// m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove", agentID);
/*
m_log.DebugFormat("[NPC MODULE]: Could not find {0} to remove",
agentID);
*/
return false;
}