Merge branch 'master' into careminster

avinationmerge
Melanie 2010-01-14 01:20:07 +00:00
commit f0152790cf
16 changed files with 125 additions and 48 deletions

View File

@ -200,7 +200,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
#region IGridService #region IGridService
public bool RegisterRegion(UUID scopeID, GridRegion regionInfo) public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
{ {
// Region doesn't exist here. Trying to link remote region // Region doesn't exist here. Trying to link remote region
if (regionInfo.RegionID.Equals(UUID.Zero)) if (regionInfo.RegionID.Equals(UUID.Zero))
@ -215,12 +215,12 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
// Try get the map image // Try get the map image
m_HypergridServiceConnector.GetMapImage(regionInfo); m_HypergridServiceConnector.GetMapImage(regionInfo);
return true; return String.Empty;
} }
else else
{ {
m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")"); m_log.Info("[HGrid]: No such region " + regionInfo.ExternalHostName + ":" + regionInfo.HttpPort + "(" + regionInfo.InternalEndPoint.Port + ")");
return false; return "No such region";
} }
// Note that these remote regions aren't registered in localBackend, so return null, no local listeners // Note that these remote regions aren't registered in localBackend, so return null, no local listeners
} }
@ -469,7 +469,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
} }
// Finally, link it // Finally, link it
if (!RegisterRegion(UUID.Zero, regInfo)) if (RegisterRegion(UUID.Zero, regInfo) != String.Empty)
{ {
m_log.Warn("[HGrid]: Unable to link region"); m_log.Warn("[HGrid]: Unable to link region");
return false; return false;

View File

@ -169,7 +169,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
#region IGridService #region IGridService
public bool RegisterRegion(UUID scopeID, GridRegion regionInfo) public string RegisterRegion(UUID scopeID, GridRegion regionInfo)
{ {
return m_GridService.RegisterRegion(scopeID, regionInfo); return m_GridService.RegisterRegion(scopeID, regionInfo);
} }

View File

@ -135,12 +135,14 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Grid
#region IGridService #region IGridService
public override bool RegisterRegion(UUID scopeID, GridRegion regionInfo) public override string RegisterRegion(UUID scopeID, GridRegion regionInfo)
{ {
if (m_LocalGridService.RegisterRegion(scopeID, regionInfo)) string msg = m_LocalGridService.RegisterRegion(scopeID, regionInfo);
if (msg == String.Empty)
return base.RegisterRegion(scopeID, regionInfo); return base.RegisterRegion(scopeID, regionInfo);
return false; return msg;
} }
public override bool DeregisterRegion(UUID regionID) public override bool DeregisterRegion(UUID regionID)

View File

@ -32,13 +32,29 @@ namespace OpenSim.Region.Framework.Interfaces
{ {
public delegate void ScriptCommand(UUID script, string id, string module, string command, string k); public delegate void ScriptCommand(UUID script, string id, string module, string command, string k);
/// <summary>
/// Interface for communication between OpenSim modules and in-world scripts
/// </summary>
///
/// See OpenSim.Region.ScriptEngine.Shared.Api.MOD_Api.modSendCommand() for information on receiving messages
/// from scripts in OpenSim modules.
public interface IScriptModuleComms public interface IScriptModuleComms
{ {
/// <summary>
/// Modules can subscribe to this event to receive command invocations from in-world scripts
/// </summary>
event ScriptCommand OnScriptCommand; event ScriptCommand OnScriptCommand;
void DispatchReply(UUID script, int code, string text, string k); /// <summary>
/// Send a link_message event to an in-world script
/// </summary>
/// <param name="scriptId"></param>
/// <param name="code"></param>
/// <param name="text"></param>
/// <param name="key"></param>
void DispatchReply(UUID scriptId, int code, string text, string key);
// For use ONLY by the script API // For use ONLY by the script API
void RaiseEvent(UUID script, string id, string module, string command, string k); void RaiseEvent(UUID script, string id, string module, string command, string key);
} }
} }

View File

@ -1589,9 +1589,9 @@ namespace OpenSim.Region.Framework.Scenes
//m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo); //m_sceneGridService.RegisterRegion(m_interregionCommsOut, RegionInfo);
GridRegion region = new GridRegion(RegionInfo); GridRegion region = new GridRegion(RegionInfo);
bool success = GridService.RegisterRegion(RegionInfo.ScopeID, region); string error = GridService.RegisterRegion(RegionInfo.ScopeID, region);
if (!success) if (error != String.Empty)
throw new Exception("Can't register with grid"); throw new Exception(error);
m_sceneGridService.SetScene(this); m_sceneGridService.SetScene(this);
m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo); m_sceneGridService.InformNeighborsThatRegionisUp(RequestModuleInterface<INeighbourService>(), RegionInfo);

View File

@ -220,8 +220,14 @@ namespace OpenSim.Region.OptionalModules.Avatar.Chat
// Fail if fundamental information is still missing // Fail if fundamental information is still missing
if (cs.Server == null || cs.IrcChannel == null || cs.BaseNickname == null || cs.User == null) if (cs.Server == null)
throw new Exception(String.Format("[IRC-Channel-{0}] Invalid configuration for region {1}", cs.idn, rs.Region)); throw new Exception(String.Format("[IRC-Channel-{0}] Invalid configuration for region {1}: server missing", cs.idn, rs.Region));
else if (cs.IrcChannel == null)
throw new Exception(String.Format("[IRC-Channel-{0}] Invalid configuration for region {1}: channel missing", cs.idn, rs.Region));
else if (cs.BaseNickname == null)
throw new Exception(String.Format("[IRC-Channel-{0}] Invalid configuration for region {1}: nick missing", cs.idn, rs.Region));
else if (cs.User == null)
throw new Exception(String.Format("[IRC-Channel-{0}] Invalid configuration for region {1}: user missing", cs.idn, rs.Region));
m_log.InfoFormat("[IRC-Channel-{0}] Configuration for Region {1} is valid", cs.idn, rs.Region); m_log.InfoFormat("[IRC-Channel-{0}] Configuration for Region {1} is valid", cs.idn, rs.Region);
m_log.InfoFormat("[IRC-Channel-{0}] Server = {1}", cs.idn, cs.Server); m_log.InfoFormat("[IRC-Channel-{0}] Server = {1}", cs.idn, cs.Server);

View File

@ -7456,23 +7456,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Integer llGetNumberOfPrims() public LSL_Integer llGetNumberOfPrims()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
ScenePresence[] presences = World.GetScenePresences();
if (presences.Length == 0)
return 0;
int avatarCount = 0; int avatarCount = 0;
for (int i = 0; i < presences.Length; i++) World.ForEachScenePresence(delegate(ScenePresence presence)
{
ScenePresence presence = presences[i];
if (!presence.IsChildAgent && presence.ParentID != 0)
{
if (m_host.ParentGroup.HasChildPrim(presence.ParentID))
{ {
if (!presence.IsChildAgent && presence.ParentID != 0 && m_host.ParentGroup.HasChildPrim(presence.ParentID))
avatarCount++; avatarCount++;
} });
}
}
return m_host.ParentGroup.PrimCount + avatarCount; return m_host.ParentGroup.PrimCount + avatarCount;
} }

View File

@ -1987,6 +1987,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return (int)pws; return (int)pws;
} }
public void osSetSpeed(string UUID, float SpeedModifier) public void osSetSpeed(string UUID, float SpeedModifier)
{ {
CheckThreatLevel(ThreatLevel.Moderate, "osSetSpeed"); CheckThreatLevel(ThreatLevel.Moderate, "osSetSpeed");
@ -1994,6 +1995,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence avatar = World.GetScenePresence(new UUID(UUID)); ScenePresence avatar = World.GetScenePresence(new UUID(UUID));
avatar.SpeedModifier = SpeedModifier; avatar.SpeedModifier = SpeedModifier;
} }
public void osKickAvatar(string FirstName,string SurName,string alert) public void osKickAvatar(string FirstName,string SurName,string alert)
{ {
CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar"); CheckThreatLevel(ThreatLevel.Severe, "osKickAvatar");
@ -2014,6 +2016,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
} }
public void osCauseDamage(string avatar, double damage) public void osCauseDamage(string avatar, double damage)
{ {
CheckThreatLevel(ThreatLevel.High, "osCauseDamage"); CheckThreatLevel(ThreatLevel.High, "osCauseDamage");
@ -2041,6 +2044,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
} }
public void osCauseHealing(string avatar, double healing) public void osCauseHealing(string avatar, double healing)
{ {
CheckThreatLevel(ThreatLevel.High, "osCauseHealing"); CheckThreatLevel(ThreatLevel.High, "osCauseHealing");

View File

@ -156,14 +156,14 @@ namespace OpenSim.Server.Handlers.Grid
m_log.DebugFormat("[GRID HANDLER]: exception unpacking region data: {0}", e); m_log.DebugFormat("[GRID HANDLER]: exception unpacking region data: {0}", e);
} }
bool result = false; string result = "Error communicating with grid service";
if (rinfo != null) if (rinfo != null)
result = m_GridService.RegisterRegion(scopeID, rinfo); result = m_GridService.RegisterRegion(scopeID, rinfo);
if (result) if (result == String.Empty)
return SuccessResult(); return SuccessResult();
else else
return FailureResult(); return FailureResult(result);
} }
byte[] Deregister(Dictionary<string, object> request) byte[] Deregister(Dictionary<string, object> request)
@ -431,6 +431,11 @@ namespace OpenSim.Server.Handlers.Grid
} }
private byte[] FailureResult() private byte[] FailureResult()
{
return FailureResult(String.Empty);
}
private byte[] FailureResult(string msg)
{ {
XmlDocument doc = new XmlDocument(); XmlDocument doc = new XmlDocument();
@ -449,6 +454,11 @@ namespace OpenSim.Server.Handlers.Grid
rootElement.AppendChild(result); rootElement.AppendChild(result);
XmlElement message = doc.CreateElement("", "Message", "");
message.AppendChild(doc.CreateTextNode(msg));
rootElement.AppendChild(message);
return DocToBytes(doc); return DocToBytes(doc);
} }

View File

@ -86,7 +86,7 @@ namespace OpenSim.Services.Connectors
#region IGridService #region IGridService
public virtual bool RegisterRegion(UUID scopeID, GridRegion regionInfo) public virtual string RegisterRegion(UUID scopeID, GridRegion regionInfo)
{ {
Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs(); Dictionary<string, object> rinfo = regionInfo.ToKeyValuePairs();
Dictionary<string, object> sendData = new Dictionary<string,object>(); Dictionary<string, object> sendData = new Dictionary<string,object>();
@ -110,11 +110,23 @@ namespace OpenSim.Services.Connectors
Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply); Dictionary<string, object> replyData = ServerUtils.ParseXmlResponse(reply);
if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success")) if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "success"))
return true; {
return String.Empty;
}
else if (replyData.ContainsKey("Result")&& (replyData["Result"].ToString().ToLower() == "failure"))
{
m_log.DebugFormat("[GRID CONNECTOR]: Registration failed: {0}", replyData["Message"].ToString());
return replyData["Message"].ToString();
}
else if (!replyData.ContainsKey("Result")) else if (!replyData.ContainsKey("Result"))
{
m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field"); m_log.DebugFormat("[GRID CONNECTOR]: reply data does not contain result field");
}
else else
{
m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString()); m_log.DebugFormat("[GRID CONNECTOR]: unexpected result {0}", replyData["Result"].ToString());
return "Unexpected result "+replyData["Result"].ToString();
}
} }
else else
@ -125,7 +137,7 @@ namespace OpenSim.Services.Connectors
m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message); m_log.DebugFormat("[GRID CONNECTOR]: Exception when contacting grid server: {0}", e.Message);
} }
return false; return "Error communicating with grid service";
} }
public virtual bool DeregisterRegion(UUID regionID) public virtual bool DeregisterRegion(UUID regionID)

View File

@ -46,15 +46,23 @@ namespace OpenSim.Services.GridService
LogManager.GetLogger( LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType); MethodBase.GetCurrentMethod().DeclaringType);
protected bool m_AllowDuplicateNames = false;
public GridService(IConfigSource config) public GridService(IConfigSource config)
: base(config) : base(config)
{ {
m_log.DebugFormat("[GRID SERVICE]: Starting..."); m_log.DebugFormat("[GRID SERVICE]: Starting...");
IConfig gridConfig = config.Configs["GridService"];
if (gridConfig != null)
{
m_AllowDuplicateNames = gridConfig.GetBoolean("AllowDuplicateNames", m_AllowDuplicateNames);
}
} }
#region IGridService #region IGridService
public bool RegisterRegion(UUID scopeID, GridRegion regionInfos) public string RegisterRegion(UUID scopeID, GridRegion regionInfos)
{ {
// This needs better sanity testing. What if regionInfo is registering in // This needs better sanity testing. What if regionInfo is registering in
// overlapping coords? // overlapping coords?
@ -63,7 +71,7 @@ namespace OpenSim.Services.GridService
{ {
m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.", m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register in coordinates {1}, {2} which are already in use in scope {3}.",
regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID); regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY, scopeID);
return false; return "Region overlaps another region";
} }
if ((region != null) && (region.RegionID == regionInfos.RegionID) && if ((region != null) && (region.RegionID == regionInfos.RegionID) &&
((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY))) ((region.posX != regionInfos.RegionLocX) || (region.posY != regionInfos.RegionLocY)))
@ -82,6 +90,23 @@ namespace OpenSim.Services.GridService
} }
} }
if (!m_AllowDuplicateNames)
{
List<RegionData> dupe = m_Database.Get(regionInfos.RegionName, scopeID);
if (dupe != null && dupe.Count > 0)
{
foreach (RegionData d in dupe)
{
if (d.RegionID != regionInfos.RegionID)
{
m_log.WarnFormat("[GRID SERVICE]: Region {0} tried to register duplicate name with ID {1}.",
regionInfos.RegionName, regionInfos.RegionID);
return "Duplicate region name";
}
}
}
}
// Everything is ok, let's register // Everything is ok, let's register
RegionData rdata = RegionInfo2RegionData(regionInfos); RegionData rdata = RegionInfo2RegionData(regionInfos);
rdata.ScopeID = scopeID; rdata.ScopeID = scopeID;
@ -97,7 +122,7 @@ namespace OpenSim.Services.GridService
m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}", m_log.DebugFormat("[GRID SERVICE]: Region {0} ({1}) registered successfully at {2}-{3}",
regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY); regionInfos.RegionName, regionInfos.RegionID, regionInfos.RegionLocX, regionInfos.RegionLocY);
return true; return String.Empty;
} }
public bool DeregisterRegion(UUID regionID) public bool DeregisterRegion(UUID regionID)

View File

@ -42,7 +42,7 @@ namespace OpenSim.Services.Interfaces
/// <param name="regionInfos"> </param> /// <param name="regionInfos"> </param>
/// <returns></returns> /// <returns></returns>
/// <exception cref="System.Exception">Thrown if region registration failed</exception> /// <exception cref="System.Exception">Thrown if region registration failed</exception>
bool RegisterRegion(UUID scopeID, GridRegion regionInfos); string RegisterRegion(UUID scopeID, GridRegion regionInfos);
/// <summary> /// <summary>
/// Deregister a region with the grid service. /// Deregister a region with the grid service.

View File

@ -63,27 +63,28 @@ namespace OpenSim.Tests.Clients.GridClient
GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000); GridRegion r3 = CreateRegion("Test Region 3", 1005, 1000);
Console.WriteLine("[GRID CLIENT]: *** Registering region 1"); Console.WriteLine("[GRID CLIENT]: *** Registering region 1");
bool success = m_Connector.RegisterRegion(UUID.Zero, r1); string msg = m_Connector.RegisterRegion(UUID.Zero, r1);
if (success) if (msg == String.Empty)
Console.WriteLine("[GRID CLIENT]: Successfully registered region 1"); Console.WriteLine("[GRID CLIENT]: Successfully registered region 1");
else else
Console.WriteLine("[GRID CLIENT]: region 1 failed to register"); Console.WriteLine("[GRID CLIENT]: region 1 failed to register");
Console.WriteLine("[GRID CLIENT]: *** Registering region 2"); Console.WriteLine("[GRID CLIENT]: *** Registering region 2");
success = m_Connector.RegisterRegion(UUID.Zero, r2); msg = m_Connector.RegisterRegion(UUID.Zero, r2);
if (success) if (msg == String.Empty)
Console.WriteLine("[GRID CLIENT]: Successfully registered region 2"); Console.WriteLine("[GRID CLIENT]: Successfully registered region 2");
else else
Console.WriteLine("[GRID CLIENT]: region 2 failed to register"); Console.WriteLine("[GRID CLIENT]: region 2 failed to register");
Console.WriteLine("[GRID CLIENT]: *** Registering region 3"); Console.WriteLine("[GRID CLIENT]: *** Registering region 3");
success = m_Connector.RegisterRegion(UUID.Zero, r3); msg = m_Connector.RegisterRegion(UUID.Zero, r3);
if (success) if (msg == String.Empty)
Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
else else
Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); Console.WriteLine("[GRID CLIENT]: region 3 failed to register");
bool success;
Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3"); Console.WriteLine("[GRID CLIENT]: *** Deregistering region 3");
success = m_Connector.DeregisterRegion(r3.RegionID); success = m_Connector.DeregisterRegion(r3.RegionID);
if (success) if (success)
@ -91,8 +92,8 @@ namespace OpenSim.Tests.Clients.GridClient
else else
Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister"); Console.WriteLine("[GRID CLIENT]: region 3 failed to deregister");
Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again"); Console.WriteLine("[GRID CLIENT]: *** Registering region 3 again");
success = m_Connector.RegisterRegion(UUID.Zero, r3); msg = m_Connector.RegisterRegion(UUID.Zero, r3);
if (success) if (msg == String.Empty)
Console.WriteLine("[GRID CLIENT]: Successfully registered region 3"); Console.WriteLine("[GRID CLIENT]: Successfully registered region 3");
else else
Console.WriteLine("[GRID CLIENT]: region 3 failed to register"); Console.WriteLine("[GRID CLIENT]: region 3 failed to register");

View File

@ -3,3 +3,7 @@ In this directory you can place addon modules for OpenSim
Each module should be in it's own tree and the root of the tree Each module should be in it's own tree and the root of the tree
should contain a file named "prebuild.xml", which will be included in the should contain a file named "prebuild.xml", which will be included in the
main prebuild file. main prebuild file.
The prebuild.xml should only contain <Project> and associated child tags.
The <?xml>, <Prebuild>, <Solution> and <Configuration> tags should not be
included since the add-on modules prebuild.xml will be inserted directly into the main prebuild.xml

View File

@ -80,3 +80,4 @@ LocalServiceModule = "OpenSim.Services.GridService.dll:GridService"
StorageProvider = "OpenSim.Data.MySQL.dll:MySqlRegionData" StorageProvider = "OpenSim.Data.MySQL.dll:MySqlRegionData"
ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=grid;" ConnectionString = "Data Source=localhost;Database=opensim;User ID=opensim;Password=grid;"
Realm = "regions" Realm = "regions"
; AllowDuplicateNames = "True"

View File

@ -485,6 +485,8 @@
; OfflineMessageURL = http://yourserver/Offline.php ; OfflineMessageURL = http://yourserver/Offline.php
; MuteListModule = MuteListModule ; MuteListModule = MuteListModule
; MuteListURL = http://yourserver/Mute.php ; MuteListURL = http://yourserver/Mute.php
; Control whether group messages are forwarded to offline users. Default is true.
; ForwardOfflineGroupMessages = true ; ForwardOfflineGroupMessages = true
@ -996,6 +998,11 @@
; Compile debug info (line numbers) into the script assemblies ; Compile debug info (line numbers) into the script assemblies
CompileWithDebugInformation = true CompileWithDebugInformation = true
; Allow the user of mod* functions. This allows a script to pass messages
; to a region module via the modSendCommand() function
; Default is false
AllowMODFunctions = false
; Allow the use of os* functions (some are dangerous) ; Allow the use of os* functions (some are dangerous)
AllowOSFunctions = false AllowOSFunctions = false