Merge branch 'master' into careminster

Conflicts:
	OpenSim/Region/CoreModules/World/Estate/EstateManagementModule.cs
	OpenSim/Region/Framework/Scenes/Scene.PacketHandlers.cs
	OpenSim/Region/Framework/Scenes/Scene.cs
avinationmerge
Melanie 2012-03-18 20:44:56 +00:00
commit c7e302864a
48 changed files with 1088 additions and 399 deletions

View File

@ -107,6 +107,7 @@ what it is today.
* M.Igarashi * M.Igarashi
* maimedleech * maimedleech
* Mana Janus * Mana Janus
* MarcelEdward
* Mic Bowman * Mic Bowman
* Michelle Argus * Michelle Argus
* Michael Cortez (The Flotsam Project, http://osflotsam.org/) * Michael Cortez (The Flotsam Project, http://osflotsam.org/)

View File

@ -269,15 +269,19 @@ namespace OpenSim.Framework.Servers
t.Priority, t.Priority,
t.ThreadState); t.ThreadState);
sb.Append(Environment.NewLine); sb.Append("\n");
} }
int workers = 0, ports = 0, maxWorkers = 0, maxPorts = 0; sb.Append("\n");
ThreadPool.GetAvailableThreads(out workers, out ports);
ThreadPool.GetMaxThreads(out maxWorkers, out maxPorts);
sb.Append(Environment.NewLine + "*** ThreadPool threads ***" + Environment.NewLine); // For some reason mono 2.6.7 returns an empty threads set! Not going to confuse people by reporting
sb.Append("workers: " + (maxWorkers - workers) + " (" + maxWorkers + "); ports: " + (maxPorts - ports) + " (" + maxPorts + ")" + Environment.NewLine); // zero active threads.
int totalThreads = Process.GetCurrentProcess().Threads.Count;
if (totalThreads > 0)
sb.AppendFormat("Total threads active: {0}\n\n", totalThreads);
sb.Append("Main threadpool (excluding script engine pools)\n");
sb.Append(Util.GetThreadPoolReport());
return sb.ToString(); return sb.ToString();
} }

View File

@ -26,8 +26,8 @@
*/ */
using System; using System;
using System.Diagnostics;
using System.Text; using System.Text;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
@ -46,8 +46,12 @@ namespace OpenSim.Framework.Statistics
sb.Append(Environment.NewLine); sb.Append(Environment.NewLine);
sb.Append( sb.Append(
string.Format( string.Format(
"Allocated to OpenSim : {0} MB" + Environment.NewLine, "Allocated to OpenSim objects: {0} MB\n",
Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0))); Math.Round(GC.GetTotalMemory(false) / 1024.0 / 1024.0)));
sb.Append(
string.Format(
"Process memory : {0} MB\n",
Math.Round(Process.GetCurrentProcess().WorkingSet64 / 1024.0 / 1024.0)));
return sb.ToString(); return sb.ToString();
} }

View File

@ -81,12 +81,15 @@ namespace OpenSim.Framework
private static uint nextXferID = 5000; private static uint nextXferID = 5000;
private static Random randomClass = new Random(); private static Random randomClass = new Random();
// Get a list of invalid file characters (OS dependent) // Get a list of invalid file characters (OS dependent)
private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]"; private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]";
private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]"; private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]";
private static object XferLock = new object(); private static object XferLock = new object();
/// <summary>Thread pool used for Util.FireAndForget if
/// FireAndForgetMethod.SmartThreadPool is used</summary> /// <summary>
/// Thread pool used for Util.FireAndForget if FireAndForgetMethod.SmartThreadPool is used
/// </summary>
private static SmartThreadPool m_ThreadPool; private static SmartThreadPool m_ThreadPool;
// Unix-epoch starts at January 1st 1970, 00:00:00 UTC. And all our times in the server are (or at least should be) in UTC. // Unix-epoch starts at January 1st 1970, 00:00:00 UTC. And all our times in the server are (or at least should be) in UTC.
@ -144,7 +147,6 @@ namespace OpenSim.Framework
return lerp(y, lerp(x, a, b), lerp(x, c, d)); return lerp(y, lerp(x, a, b), lerp(x, c, d));
} }
public static Encoding UTF8 = Encoding.UTF8; public static Encoding UTF8 = Encoding.UTF8;
/// <value> /// <value>
@ -1683,6 +1685,61 @@ namespace OpenSim.Framework
} }
} }
/// <summary>
/// Get a thread pool report.
/// </summary>
/// <returns></returns>
public static string GetThreadPoolReport()
{
string threadPoolUsed = null;
int maxThreads = 0;
int minThreads = 0;
int allocatedThreads = 0;
int inUseThreads = 0;
int waitingCallbacks = 0;
int completionPortThreads = 0;
StringBuilder sb = new StringBuilder();
if (FireAndForgetMethod == FireAndForgetMethod.SmartThreadPool)
{
threadPoolUsed = "SmartThreadPool";
maxThreads = m_ThreadPool.MaxThreads;
minThreads = m_ThreadPool.MinThreads;
inUseThreads = m_ThreadPool.InUseThreads;
allocatedThreads = m_ThreadPool.ActiveThreads;
waitingCallbacks = m_ThreadPool.WaitingCallbacks;
}
else if (
FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem
|| FireAndForgetMethod == FireAndForgetMethod.UnsafeQueueUserWorkItem)
{
threadPoolUsed = "BuiltInThreadPool";
ThreadPool.GetMaxThreads(out maxThreads, out completionPortThreads);
ThreadPool.GetMinThreads(out minThreads, out completionPortThreads);
int availableThreads;
ThreadPool.GetAvailableThreads(out availableThreads, out completionPortThreads);
inUseThreads = maxThreads - availableThreads;
allocatedThreads = -1;
waitingCallbacks = -1;
}
if (threadPoolUsed != null)
{
sb.AppendFormat("Thread pool used : {0}\n", threadPoolUsed);
sb.AppendFormat("Max threads : {0}\n", maxThreads);
sb.AppendFormat("Min threads : {0}\n", minThreads);
sb.AppendFormat("Allocated threads : {0}\n", allocatedThreads < 0 ? "not applicable" : allocatedThreads.ToString());
sb.AppendFormat("In use threads : {0}\n", inUseThreads);
sb.AppendFormat("Work items waiting : {0}\n", waitingCallbacks < 0 ? "not available" : waitingCallbacks.ToString());
}
else
{
sb.AppendFormat("Thread pool not used\n");
}
return sb.ToString();
}
private static object SmartThreadPoolCallback(object o) private static object SmartThreadPoolCallback(object o)
{ {
object[] array = (object[])o; object[] array = (object[])o;

View File

@ -503,7 +503,11 @@ namespace OpenSim
string currentCommand; string currentCommand;
while ((currentCommand = readFile.ReadLine()) != null) while ((currentCommand = readFile.ReadLine()) != null)
{ {
if (currentCommand != String.Empty) currentCommand = currentCommand.Trim();
if (!(currentCommand == ""
|| currentCommand.StartsWith(";")
|| currentCommand.StartsWith("//")
|| currentCommand.StartsWith("#")))
{ {
m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'"); m_log.Info("[COMMANDFILE]: Running '" + currentCommand + "'");
m_console.RunCommand(currentCommand); m_console.RunCommand(currentCommand);

View File

@ -124,15 +124,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
"Archiving", this, "save iar", "Archiving", this, "save iar",
"save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-v|--verbose]", "save iar [-h|--home=<url>] [--noassets] <first> <last> <inventory path> <password> [<IAR path>] [-c|--creators] [-v|--verbose]",
"Save user inventory archive (IAR).", "Save user inventory archive (IAR).",
"<first> is the user's first name." + Environment.NewLine "<first> is the user's first name.\n"
+ "<last> is the user's last name." + Environment.NewLine + "<last> is the user's last name.\n"
+ "<inventory path> is the path inside the user's inventory for the folder/item to be saved." + Environment.NewLine + "<inventory path> is the path inside the user's inventory for the folder/item to be saved.\n"
+ "-h|--home=<url> adds the url of the profile service to the saved user information." + Environment.NewLine
+ "-c|--creators preserves information about foreign creators." + Environment.NewLine
+ "-v|--verbose extra debug messages." + Environment.NewLine
+ "--noassets stops assets being saved to the IAR."
+ "<IAR path> is the filesystem path at which to save the IAR." + "<IAR path> is the filesystem path at which to save the IAR."
+ string.Format(" If this is not given then the filename {0} in the current directory is used", DEFAULT_INV_BACKUP_FILENAME), + string.Format(" If this is not given then the filename {0} in the current directory is used.\n", DEFAULT_INV_BACKUP_FILENAME)
+ "-h|--home=<url> adds the url of the profile service to the saved user information.\n"
+ "-c|--creators preserves information about foreign creators.\n"
+ "-v|--verbose extra debug messages.\n"
+ "--noassets stops assets being saved to the IAR.",
HandleSaveInvConsoleCommand); HandleSaveInvConsoleCommand);
m_aScene = scene; m_aScene = scene;

View File

@ -0,0 +1,123 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using OpenSim.Framework;
using OpenSim.Framework.Console;
using OpenSim.Region.Framework;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors.Hypergrid;
using OpenMetaverse;
using OpenMetaverse.Packets;
using log4net;
using Nini.Config;
namespace OpenSim.Region.CoreModules.Framework.UserManagement
{
public class HGUserManagementModule : UserManagementModule, ISharedRegionModule, IUserManagement
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
#region ISharedRegionModule
public new void Initialise(IConfigSource config)
{
string umanmod = config.Configs["Modules"].GetString("UserManagementModule", base.Name);
if (umanmod == Name)
{
m_Enabled = true;
RegisterConsoleCmds();
m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name);
}
}
public override string Name
{
get { return "HGUserManagementModule"; }
}
#endregion ISharedRegionModule
protected override void AddAdditionalUsers(UUID avatarID, string query, List<UserData> users)
{
string[] words = query.Split(new char[] { ' ' });
for (int i = 0; i < words.Length; i++)
{
if (words[i].Length < 3)
{
if (i != words.Length - 1)
Array.Copy(words, i + 1, words, i, words.Length - i - 1);
Array.Resize(ref words, words.Length - 1);
}
}
if (words.Length == 0 || words.Length > 2)
return;
if (words.Length == 2) // First.Last @foo.com, maybe?
{
bool found = false;
foreach (UserData d in m_UserCache.Values)
{
if (d.LastName.StartsWith("@") &&
(d.FirstName.ToLower().Equals(words[0].ToLower()) ||
d.LastName.ToLower().Equals(words[1].ToLower())))
{
users.Add(d);
found = true;
break;
}
}
if (!found) // This is it! Let's ask the other world
{
// TODO
//UserAgentServiceConnector uasConn = new UserAgentServiceConnector(words[0]);
//uasConn.GetUserInfo(...);
}
}
else
{
foreach (UserData d in m_UserCache.Values)
{
if (d.LastName.StartsWith("@") &&
(d.FirstName.ToLower().StartsWith(query.ToLower()) ||
d.LastName.ToLower().StartsWith(query.ToLower())))
users.Add(d);
}
}
}
}
}

View File

@ -38,12 +38,13 @@ using OpenSim.Services.Interfaces;
using OpenSim.Services.Connectors.Hypergrid; using OpenSim.Services.Connectors.Hypergrid;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.Packets;
using log4net; using log4net;
using Nini.Config; using Nini.Config;
namespace OpenSim.Region.CoreModules.Framework.UserManagement namespace OpenSim.Region.CoreModules.Framework.UserManagement
{ {
class UserData public class UserData
{ {
public UUID Id { get; set; } public UUID Id { get; set; }
public string FirstName { get; set; } public string FirstName { get; set; }
@ -56,36 +57,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private List<Scene> m_Scenes = new List<Scene>(); protected bool m_Enabled;
protected List<Scene> m_Scenes = new List<Scene>();
// The cache // The cache
Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>(); protected Dictionary<UUID, UserData> m_UserCache = new Dictionary<UUID, UserData>();
#region ISharedRegionModule #region ISharedRegionModule
public void Initialise(IConfigSource config) public void Initialise(IConfigSource config)
{ {
//m_Enabled = config.Configs["Modules"].GetBoolean("LibraryModule", m_Enabled); string umanmod = config.Configs["Modules"].GetString("UserManagementModule", Name);
//if (m_Enabled) if (umanmod == Name)
//{ {
// IConfig libConfig = config.Configs["LibraryService"]; m_Enabled = true;
// if (libConfig != null) RegisterConsoleCmds();
// { m_log.DebugFormat("[USER MANAGEMENT MODULE]: {0} is enabled", Name);
// string dllName = libConfig.GetString("LocalServiceModule", string.Empty); }
// m_log.Debug("[LIBRARY MODULE]: Library service dll is " + dllName);
// if (dllName != string.Empty)
// {
// Object[] args = new Object[] { config };
// m_Library = ServerUtils.LoadPlugin<ILibraryService>(dllName, args);
// }
// }
//}
MainConsole.Instance.Commands.AddCommand("Users", true,
"show names",
"show names",
"Show the bindings between user UUIDs and user names",
String.Empty,
HandleShowUsers);
} }
public bool IsSharedModule public bool IsSharedModule
@ -93,9 +81,9 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
get { return true; } get { return true; }
} }
public string Name public virtual string Name
{ {
get { return "UserManagement Module"; } get { return "BasicUserManagementModule"; }
} }
public Type ReplaceableInterface public Type ReplaceableInterface
@ -104,6 +92,8 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
} }
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
{
if (m_Enabled)
{ {
m_Scenes.Add(scene); m_Scenes.Add(scene);
@ -111,12 +101,16 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient); scene.EventManager.OnNewClient += new EventManager.OnNewClientDelegate(EventManager_OnNewClient);
scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded); scene.EventManager.OnPrimsLoaded += new EventManager.PrimsLoaded(EventManager_OnPrimsLoaded);
} }
}
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
{
if (m_Enabled)
{ {
scene.UnregisterModuleInterface<IUserManagement>(this); scene.UnregisterModuleInterface<IUserManagement>(this);
m_Scenes.Remove(scene); m_Scenes.Remove(scene);
} }
}
public void RegionLoaded(Scene s) public void RegionLoaded(Scene s)
{ {
@ -149,7 +143,15 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
void EventManager_OnNewClient(IClientAPI client) void EventManager_OnNewClient(IClientAPI client)
{ {
client.OnConnectionClosed += new Action<IClientAPI>(HandleConnectionClosed);
client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest); client.OnNameFromUUIDRequest += new UUIDNameRequest(HandleUUIDNameRequest);
client.OnAvatarPickerRequest += new AvatarPickerRequest(HandleAvatarPickerRequest);
}
void HandleConnectionClosed(IClientAPI client)
{
client.OnNameFromUUIDRequest -= new UUIDNameRequest(HandleUUIDNameRequest);
client.OnAvatarPickerRequest -= new AvatarPickerRequest(HandleAvatarPickerRequest);
} }
void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client) void HandleUUIDNameRequest(UUID uuid, IClientAPI remote_client)
@ -170,6 +172,78 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
} }
} }
public void HandleAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query)
{
//EventManager.TriggerAvatarPickerRequest();
m_log.DebugFormat("[USER MANAGEMENT MODULE]: HandleAvatarPickerRequest for {0}", query);
List<UserAccount> accs = m_Scenes[0].UserAccountService.GetUserAccounts(m_Scenes[0].RegionInfo.ScopeID, query);
List<UserData> users = new List<UserData>();
if (accs != null)
{
m_log.DebugFormat("[USER MANAGEMENT MODULE]: Found {0} users", accs.Count);
foreach (UserAccount acc in accs)
{
UserData ud = new UserData();
ud.FirstName = acc.FirstName;
ud.LastName = acc.LastName;
ud.Id = acc.PrincipalID;
users.Add(ud);
}
}
AddAdditionalUsers(avatarID, query, users);
AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket)PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
// TODO: don't create new blocks if recycling an old packet
AvatarPickerReplyPacket.DataBlock[] searchData =
new AvatarPickerReplyPacket.DataBlock[users.Count];
AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
agentData.AgentID = avatarID;
agentData.QueryID = RequestID;
replyPacket.AgentData = agentData;
//byte[] bytes = new byte[AvatarResponses.Count*32];
int i = 0;
foreach (UserData item in users)
{
UUID translatedIDtem = item.Id;
searchData[i] = new AvatarPickerReplyPacket.DataBlock();
searchData[i].AvatarID = translatedIDtem;
searchData[i].FirstName = Utils.StringToBytes((string)item.FirstName);
searchData[i].LastName = Utils.StringToBytes((string)item.LastName);
i++;
}
if (users.Count == 0)
{
searchData = new AvatarPickerReplyPacket.DataBlock[0];
}
replyPacket.Data = searchData;
AvatarPickerReplyAgentDataArgs agent_data = new AvatarPickerReplyAgentDataArgs();
agent_data.AgentID = replyPacket.AgentData.AgentID;
agent_data.QueryID = replyPacket.AgentData.QueryID;
List<AvatarPickerReplyDataArgs> data_args = new List<AvatarPickerReplyDataArgs>();
for (i = 0; i < replyPacket.Data.Length; i++)
{
AvatarPickerReplyDataArgs data_arg = new AvatarPickerReplyDataArgs();
data_arg.AvatarID = replyPacket.Data[i].AvatarID;
data_arg.FirstName = replyPacket.Data[i].FirstName;
data_arg.LastName = replyPacket.Data[i].LastName;
data_args.Add(data_arg);
}
client.SendAvatarPickerReply(agent_data, data_args);
}
protected virtual void AddAdditionalUsers(UUID avatarID, string query, List<UserData> users)
{
}
#endregion Event Handlers #endregion Event Handlers
private void CacheCreators(SceneObjectGroup sog) private void CacheCreators(SceneObjectGroup sog)
@ -425,13 +499,23 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
#endregion IUserManagement #endregion IUserManagement
protected void RegisterConsoleCmds()
{
MainConsole.Instance.Commands.AddCommand("Users", true,
"show names",
"show names",
"Show the bindings between user UUIDs and user names",
String.Empty,
HandleShowUsers);
}
private void HandleShowUsers(string module, string[] cmd) private void HandleShowUsers(string module, string[] cmd)
{ {
lock (m_UserCache) lock (m_UserCache)
{ {
if (m_UserCache.Count == 0) if (m_UserCache.Count == 0)
{ {
MainConsole.Instance.Output("No users not found"); MainConsole.Instance.Output("No users found");
return; return;
} }

View File

@ -9,6 +9,7 @@
<Extension path = "/OpenSim/RegionModules"> <Extension path = "/OpenSim/RegionModules">
<RegionModule id="UserManagementModule" type="OpenSim.Region.CoreModules.Framework.UserManagement.UserManagementModule" /> <RegionModule id="UserManagementModule" type="OpenSim.Region.CoreModules.Framework.UserManagement.UserManagementModule" />
<RegionModule id="HGUserManagementModule" type="OpenSim.Region.CoreModules.Framework.UserManagement.HGUserManagementModule" />
<RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" /> <RegionModule id="EntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.EntityTransferModule" />
<RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" /> <RegionModule id="HGEntityTransferModule" type="OpenSim.Region.CoreModules.Framework.EntityTransfer.HGEntityTransferModule" />
<RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.BasicInventoryAccessModule" /> <RegionModule id="InventoryAccessModule" type="OpenSim.Region.CoreModules.Framework.InventoryAccess.BasicInventoryAccessModule" />

View File

@ -0,0 +1,124 @@
/*
* Copyright (c) Contributors, http://opensimulator.org/
* See CONTRIBUTORS.TXT for a full list of copyright holders.
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions are met:
* * Redistributions of source code must retain the above copyright
* notice, this list of conditions and the following disclaimer.
* * Redistributions in binary form must reproduce the above copyright
* notice, this list of conditions and the following disclaimer in the
* documentation and/or other materials provided with the distribution.
* * Neither the name of the OpenSimulator Project nor the
* names of its contributors may be used to endorse or promote products
* derived from this software without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
* EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
* WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
* DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
* LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
using System;
using System.Collections.Generic;
using System.Linq;
using System.Reflection;
using Nini.Config;
using log4net;
using OpenSim.Framework;
using OpenSim.Services.Interfaces;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
using OpenMetaverse;
using GridRegion = OpenSim.Services.Interfaces.GridRegion;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
{
public class AuthorizationService : IAuthorizationService
{
private enum AccessFlags
{
None = 0, /* No restrictions */
DisallowResidents = 1, /* Only gods and managers*/
DisallowForeigners = 2, /* Only local people */
}
private static readonly ILog m_log =
LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType);
private IUserManagement m_UserManagement;
private IGridService m_GridService;
private Scene m_Scene;
AccessFlags m_accessValue = AccessFlags.None;
public AuthorizationService(IConfig config, Scene scene)
{
m_Scene = scene;
m_UserManagement = scene.RequestModuleInterface<IUserManagement>();
m_GridService = scene.GridService;
if (config != null)
{
string accessStr = config.GetString("Region_" + scene.RegionInfo.RegionName.Replace(' ', '_'), String.Empty);
if (accessStr != string.Empty)
{
try
{
m_accessValue = (AccessFlags)Enum.Parse(typeof(AccessFlags), accessStr);
}
catch (ArgumentException)
{
m_log.WarnFormat("[AuthorizationService]: {0} is not a valid access flag", accessStr);
}
}
m_log.DebugFormat("[AuthorizationService]: Region {0} access restrictions: {1}", m_Scene.RegionInfo.RegionName, m_accessValue);
}
}
public bool IsAuthorizedForRegion(
string user, string firstName, string lastName, string regionID, out string message)
{
message = "authorized";
// This should not happen
if (m_Scene.RegionInfo.RegionID.ToString() != regionID)
{
m_log.WarnFormat("[AuthorizationService]: Service for region {0} received request to authorize for region {1}",
m_Scene.RegionInfo.RegionID, regionID);
return true;
}
if (m_accessValue == AccessFlags.None)
return true;
UUID userID = new UUID(user);
bool authorized = true;
if ((m_accessValue & AccessFlags.DisallowForeigners) == AccessFlags.DisallowForeigners)
{
authorized = m_UserManagement.IsLocalGridUser(userID);
if (!authorized)
message = "no foreigner users allowed in this region";
}
if (authorized && (m_accessValue & AccessFlags.DisallowResidents) == AccessFlags.DisallowResidents)
{
authorized = m_Scene.Permissions.IsGod(userID) | m_Scene.Permissions.IsAdministrator(userID);
if (!authorized)
message = "only Admins and Managers allowed in this region";
}
return authorized;
}
}
}

View File

@ -39,13 +39,15 @@ using OpenMetaverse;
namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
{ {
public class LocalAuthorizationServicesConnector : ISharedRegionModule, IAuthorizationService public class LocalAuthorizationServicesConnector : INonSharedRegionModule, IAuthorizationService
{ {
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger( LogManager.GetLogger(
MethodBase.GetCurrentMethod().DeclaringType); MethodBase.GetCurrentMethod().DeclaringType);
private IAuthorizationService m_AuthorizationService; private IAuthorizationService m_AuthorizationService;
private Scene m_Scene;
private IConfig m_AuthorizationConfig;
private bool m_Enabled = false; private bool m_Enabled = false;
@ -69,33 +71,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
string name = moduleConfig.GetString("AuthorizationServices", string.Empty); string name = moduleConfig.GetString("AuthorizationServices", string.Empty);
if (name == Name) if (name == Name)
{ {
IConfig authorizationConfig = source.Configs["AuthorizationService"];
if (authorizationConfig == null)
{
m_log.Error("[AUTHORIZATION CONNECTOR]: AuthorizationService missing from OpenSim.ini");
return;
}
string serviceDll = authorizationConfig.GetString("LocalServiceModule",
String.Empty);
if (serviceDll == String.Empty)
{
m_log.Error("[AUTHORIZATION CONNECTOR]: No LocalServiceModule named in section AuthorizationService");
return;
}
Object[] args = new Object[] { source };
m_AuthorizationService =
ServerUtils.LoadPlugin<IAuthorizationService>(serviceDll,
args);
if (m_AuthorizationService == null)
{
m_log.Error("[AUTHORIZATION CONNECTOR]: Can't load authorization service");
return;
}
m_Enabled = true; m_Enabled = true;
m_AuthorizationConfig = source.Configs["AuthorizationService"];
m_log.Info("[AUTHORIZATION CONNECTOR]: Local authorization connector enabled"); m_log.Info("[AUTHORIZATION CONNECTOR]: Local authorization connector enabled");
} }
} }
@ -115,6 +92,9 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
return; return;
scene.RegisterModuleInterface<IAuthorizationService>(this); scene.RegisterModuleInterface<IAuthorizationService>(this);
m_Scene = scene;
scene.EventManager.OnLoginsEnabled += new EventManager.LoginsEnabled(OnLoginsEnabled);
} }
public void RemoveRegion(Scene scene) public void RemoveRegion(Scene scene)
@ -131,9 +111,18 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Authorization
scene.RegionInfo.RegionName); scene.RegionInfo.RegionName);
} }
private void OnLoginsEnabled(string regionName)
{
m_AuthorizationService = new AuthorizationService(m_AuthorizationConfig, m_Scene);
}
public bool IsAuthorizedForRegion( public bool IsAuthorizedForRegion(
string userID, string firstName, string lastName, string regionID, out string message) string userID, string firstName, string lastName, string regionID, out string message)
{ {
message = "";
if (!m_Enabled)
return true;
return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message); return m_AuthorizationService.IsAuthorizedForRegion(userID, firstName, lastName, regionID, out message);
} }
} }

View File

@ -26,8 +26,10 @@
*/ */
using System; using System;
using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Linq;
using System.Reflection; using System.Reflection;
using System.Security; using System.Security;
using System.Timers; using System.Timers;
@ -46,8 +48,6 @@ namespace OpenSim.Region.CoreModules.World.Estate
{ {
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private delegate void LookupUUIDS(List<UUID> uuidLst);
private Timer m_regionChangeTimer = new Timer(); private Timer m_regionChangeTimer = new Timer();
public Scene Scene { get; private set; } public Scene Scene { get; private set; }
public IUserManagement UserManager { get; private set; } public IUserManagement UserManager { get; private set; }
@ -907,38 +907,55 @@ namespace OpenSim.Region.CoreModules.World.Estate
if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false)) if (!Scene.Permissions.CanIssueEstateCommand(remoteClient.AgentId, false))
return; return;
Dictionary<uint, float> SceneData = new Dictionary<uint,float>(); Dictionary<uint, float> sceneData = null;
List<UUID> uuidNameLookupList = new List<UUID>(); List<UUID> uuidNameLookupList = new List<UUID>();
if (reportType == 1) if (reportType == 1)
{ {
SceneData = Scene.PhysicsScene.GetTopColliders(); sceneData = Scene.PhysicsScene.GetTopColliders();
} }
else if (reportType == 0) else if (reportType == 0)
{ {
SceneData = Scene.SceneGraph.GetTopScripts(); IScriptModule scriptModule = Scene.RequestModuleInterface<IScriptModule>();
if (scriptModule != null)
sceneData = scriptModule.GetObjectScriptsExecutionTimes();
} }
List<LandStatReportItem> SceneReport = new List<LandStatReportItem>(); List<LandStatReportItem> SceneReport = new List<LandStatReportItem>();
lock (SceneData) if (sceneData != null)
{ {
foreach (uint obj in SceneData.Keys) var sortedSceneData
= sceneData.Select(
item => new { Measurement = item.Value, Part = Scene.GetSceneObjectPart(item.Key) });
sortedSceneData.OrderBy(item => item.Measurement);
int items = 0;
foreach (var entry in sortedSceneData)
{ {
SceneObjectPart prt = Scene.GetSceneObjectPart(obj); // The object may have been deleted since we received the data.
if (prt != null) if (entry.Part == null)
{ continue;
SceneObjectGroup sog = prt.ParentGroup;
// Don't show scripts that haven't executed or where execution time is below one microsecond in
// order to produce a more readable report.
if (entry.Measurement < 0.001)
continue;
items++;
SceneObjectGroup so = entry.Part.ParentGroup;
LandStatReportItem lsri = new LandStatReportItem(); LandStatReportItem lsri = new LandStatReportItem();
lsri.LocationX = sog.AbsolutePosition.X; lsri.LocationX = so.AbsolutePosition.X;
lsri.LocationY = sog.AbsolutePosition.Y; lsri.LocationY = so.AbsolutePosition.Y;
lsri.LocationZ = sog.AbsolutePosition.Z; lsri.LocationZ = so.AbsolutePosition.Z;
lsri.Score = SceneData[obj]; lsri.Score = entry.Measurement;
lsri.TaskID = sog.UUID; lsri.TaskID = so.UUID;
lsri.TaskLocalID = sog.LocalId; lsri.TaskLocalID = so.LocalId;
lsri.TaskName = sog.GetPartName(obj); lsri.TaskName = entry.Part.Name;
lsri.OwnerName = "waiting"; lsri.OwnerName = UserManager.GetUserName(so.OwnerID);
lock (uuidNameLookupList)
uuidNameLookupList.Add(sog.OwnerID);
if (filter.Length != 0) if (filter.Length != 0)
{ {
@ -952,53 +969,15 @@ namespace OpenSim.Region.CoreModules.World.Estate
} }
SceneReport.Add(lsri); SceneReport.Add(lsri);
}
if (items >= 100)
break;
} }
} }
remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray()); remoteClient.SendLandStatReply(reportType, requestFlags, (uint)SceneReport.Count,SceneReport.ToArray());
if (uuidNameLookupList.Count > 0)
LookupUUID(uuidNameLookupList);
} }
private static void LookupUUIDSCompleted(IAsyncResult iar)
{
LookupUUIDS icon = (LookupUUIDS)iar.AsyncState;
icon.EndInvoke(iar);
}
private void LookupUUID(List<UUID> uuidLst)
{
LookupUUIDS d = LookupUUIDsAsync;
d.BeginInvoke(uuidLst,
LookupUUIDSCompleted,
d);
}
private void LookupUUIDsAsync(List<UUID> uuidLst)
{
UUID[] uuidarr;
lock (uuidLst)
{
uuidarr = uuidLst.ToArray();
}
for (int i = 0; i < uuidarr.Length; i++)
{
// string lookupname = Scene.CommsManager.UUIDNameRequestString(uuidarr[i]);
IUserManagement userManager = Scene.RequestModuleInterface<IUserManagement>();
if (userManager != null)
userManager.GetUserName(uuidarr[i]);
// we drop it. It gets cached though... so we're ready for the next request.
// diva commnent 11/21/2010: uh?!? wft?
// justincc comment 21/01/2011: A side effect of userManager.GetUserName() I presume.
}
}
#endregion #endregion
#region Outgoing Packets #region Outgoing Packets

View File

@ -1664,7 +1664,7 @@ namespace OpenSim.Region.CoreModules.World.Land
{ {
if (e.OwnerID == targetID) if (e.OwnerID == targetID)
{ {
if (e.scriptScore >= 0.01) if (e.ContainsScripts())
{ {
returns.Add(e); returns.Add(e);
} }
@ -1681,7 +1681,7 @@ namespace OpenSim.Region.CoreModules.World.Land
ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y); ILandObject landobject = ((Scene)client.Scene).LandChannel.GetLandObject(e.AbsolutePosition.X, e.AbsolutePosition.Y);
if (landobject.LandData.OwnerID != e.OwnerID) if (landobject.LandData.OwnerID != e.OwnerID)
{ {
if (e.scriptScore >= 0.01) if (e.ContainsScripts())
{ {
returns.Add(e); returns.Add(e);
} }

View File

@ -86,6 +86,8 @@ namespace OpenSim.Region.CoreModules.World.Terrain
private volatile bool m_tainted; private volatile bool m_tainted;
private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5); private readonly Stack<LandUndoState> m_undo = new Stack<LandUndoState>(5);
private String m_InitialTerrain = "pinhead-island";
/// <summary> /// <summary>
/// Human readable list of terrain file extensions that are supported. /// Human readable list of terrain file extensions that are supported.
/// </summary> /// </summary>
@ -109,6 +111,9 @@ namespace OpenSim.Region.CoreModules.World.Terrain
/// <param name="config">Config for the region</param> /// <param name="config">Config for the region</param>
public void Initialise(IConfigSource config) public void Initialise(IConfigSource config)
{ {
IConfig terrainConfig = config.Configs["Terrain"];
if (terrainConfig != null)
m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
} }
public void AddRegion(Scene scene) public void AddRegion(Scene scene)
@ -120,7 +125,7 @@ namespace OpenSim.Region.CoreModules.World.Terrain
{ {
if (m_scene.Heightmap == null) if (m_scene.Heightmap == null)
{ {
m_channel = new TerrainChannel(); m_channel = new TerrainChannel(m_InitialTerrain);
m_scene.Heightmap = m_channel; m_scene.Heightmap = m_channel;
m_revert = new TerrainChannel(); m_revert = new TerrainChannel();
UpdateRevertMap(); UpdateRevertMap();

View File

@ -94,6 +94,22 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
//m_log.DebugFormat("MAP NAME=({0})", mapName); //m_log.DebugFormat("MAP NAME=({0})", mapName);
// Hack to get around the fact that ll V3 now drops the port from the
// map name. See https://jira.secondlife.com/browse/VWR-28570
//
// Caller, use this magic form instead:
// secondlife://http|!!mygrid.com|8002|Region+Name/128/128
// or url encode if possible.
// the hacks we do with this viewer...
//
string mapNameOrig = mapName;
if (mapName.Contains("|"))
mapName = mapName.Replace('|', ':');
if (mapName.Contains("+"))
mapName = mapName.Replace('+', ' ');
if (mapName.Contains("!"))
mapName = mapName.Replace('!', '/');
// try to fetch from GridServer // try to fetch from GridServer
List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20); List<GridRegion> regionInfos = m_scene.GridService.GetRegionsByName(m_scene.RegionInfo.ScopeID, mapName, 20);
// if (regionInfos.Count == 0) // if (regionInfos.Count == 0)
@ -114,6 +130,11 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
data.MapImageId = UUID.Zero; data.MapImageId = UUID.Zero;
else else
data.MapImageId = info.TerrainImage; data.MapImageId = info.TerrainImage;
// ugh! V2-3 is very sensitive about the result being
// exactly the same as the requested name
if (regionInfos.Count == 1)
data.Name = mapNameOrig;
else
data.Name = info.RegionName; data.Name = info.RegionName;
data.RegionFlags = 0; // TODO not used? data.RegionFlags = 0; // TODO not used?
data.WaterHeight = 0; // not used data.WaterHeight = 0; // not used
@ -138,6 +159,17 @@ namespace OpenSim.Region.CoreModules.World.WorldMap
// flags are agent flags sent from the viewer. // flags are agent flags sent from the viewer.
// they have different values depending on different viewers, apparently // they have different values depending on different viewers, apparently
remoteClient.SendMapBlock(blocks, flags); remoteClient.SendMapBlock(blocks, flags);
// send extra user messages for V3
// because the UI is very confusing
// while we don't fix the hard-coded urls
if (flags == 2)
{
if (regionInfos.Count == 0)
remoteClient.SendAgentAlertMessage("No regions found with that name.", true);
else if (regionInfos.Count == 1)
remoteClient.SendAgentAlertMessage("Region found!", false);
}
} }
// private Scene GetClientScene(IClientAPI client) // private Scene GetClientScene(IClientAPI client)

View File

@ -27,6 +27,7 @@
using System; using System;
using System.Collections; using System.Collections;
using System.Collections.Generic;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Region.Framework.Interfaces namespace OpenSim.Region.Framework.Interfaces
@ -76,5 +77,14 @@ namespace OpenSim.Region.Framework.Interfaces
/// Starts the processing threads. /// Starts the processing threads.
/// </summary> /// </summary>
void StartProcessing(); void StartProcessing();
/// <summary>
/// Get the execution times of all scripts in each object.
/// </summary>
/// <returns>
/// A dictionary where the key is the root object ID of a linkset
/// and the value is a representative execution time in milliseconds of all scripts in that linkset.
/// </returns>
Dictionary<uint, float> GetObjectScriptsExecutionTimes();
} }
} }

View File

@ -31,6 +31,7 @@ using OpenMetaverse;
namespace OpenSim.Region.Framework.Interfaces 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);
public delegate object ScriptInvocation(UUID script, object[] parms);
/// <summary> /// <summary>
/// Interface for communication between OpenSim modules and in-world scripts /// Interface for communication between OpenSim modules and in-world scripts
@ -45,6 +46,15 @@ namespace OpenSim.Region.Framework.Interfaces
/// </summary> /// </summary>
event ScriptCommand OnScriptCommand; event ScriptCommand OnScriptCommand;
void RegisterScriptInvocation(string name, ScriptInvocation fn, Type[] csig, Type rsig);
ScriptInvocation LookupScriptInvocation(string fname);
string LookupModInvocation(string fname);
Type[] LookupTypeSignature(string fname);
Type LookupReturnType(string fname);
object InvokeOperation(UUID scriptId, string fname, params object[] parms);
/// <summary> /// <summary>
/// Send a link_message event to an in-world script /// Send a link_message event to an in-world script
/// </summary> /// </summary>

View File

@ -341,62 +341,6 @@ namespace OpenSim.Region.Framework.Scenes
EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg); EventManager.TriggerObjectDeGrab(obj.RootPart.LocalId, part.LocalId, remoteClient, surfaceArg);
} }
public void ProcessAvatarPickerRequest(IClientAPI client, UUID avatarID, UUID RequestID, string query)
{
//EventManager.TriggerAvatarPickerRequest();
List<UserAccount> accounts = UserAccountService.GetUserAccounts(RegionInfo.ScopeID, query);
if (accounts == null)
{
m_log.DebugFormat("[LLCIENT]: ProcessAvatarPickerRequest: returned null result");
return;
}
AvatarPickerReplyPacket replyPacket = (AvatarPickerReplyPacket) PacketPool.Instance.GetPacket(PacketType.AvatarPickerReply);
// TODO: don't create new blocks if recycling an old packet
AvatarPickerReplyPacket.DataBlock[] searchData =
new AvatarPickerReplyPacket.DataBlock[accounts.Count];
AvatarPickerReplyPacket.AgentDataBlock agentData = new AvatarPickerReplyPacket.AgentDataBlock();
agentData.AgentID = avatarID;
agentData.QueryID = RequestID;
replyPacket.AgentData = agentData;
//byte[] bytes = new byte[AvatarResponses.Count*32];
int i = 0;
foreach (UserAccount item in accounts)
{
UUID translatedIDtem = item.PrincipalID;
searchData[i] = new AvatarPickerReplyPacket.DataBlock();
searchData[i].AvatarID = translatedIDtem;
searchData[i].FirstName = Utils.StringToBytes((string) item.FirstName);
searchData[i].LastName = Utils.StringToBytes((string) item.LastName);
i++;
}
if (accounts.Count == 0)
{
searchData = new AvatarPickerReplyPacket.DataBlock[0];
}
replyPacket.Data = searchData;
AvatarPickerReplyAgentDataArgs agent_data = new AvatarPickerReplyAgentDataArgs();
agent_data.AgentID = replyPacket.AgentData.AgentID;
agent_data.QueryID = replyPacket.AgentData.QueryID;
List<AvatarPickerReplyDataArgs> data_args = new List<AvatarPickerReplyDataArgs>();
for (i = 0; i < replyPacket.Data.Length; i++)
{
AvatarPickerReplyDataArgs data_arg = new AvatarPickerReplyDataArgs();
data_arg.AvatarID = replyPacket.Data[i].AvatarID;
data_arg.FirstName = replyPacket.Data[i].FirstName;
data_arg.LastName = replyPacket.Data[i].LastName;
data_args.Add(data_arg);
}
client.SendAvatarPickerReply(agent_data, data_args);
}
public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID, public void ProcessScriptReset(IClientAPI remoteClient, UUID objectID,
UUID itemID) UUID itemID)
{ {

View File

@ -1632,8 +1632,15 @@ namespace OpenSim.Region.Framework.Scenes
double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID); double[,] map = SimulationDataService.LoadTerrain(RegionInfo.RegionID);
if (map == null) if (map == null)
{ {
m_log.Info("[TERRAIN]: No default terrain. Generating a new terrain."); // This should be in the Terrain module, but it isn't because
Heightmap = new TerrainChannel(); // the heightmap is needed _way_ before the modules are initialized...
IConfig terrainConfig = m_config.Configs["Terrain"];
String m_InitialTerrain = "pinhead-island";
if (terrainConfig != null)
m_InitialTerrain = terrainConfig.GetString("InitialTerrain", m_InitialTerrain);
m_log.InfoFormat("[TERRAIN]: No default terrain. Generating a new terrain {0}.", m_InitialTerrain);
Heightmap = new TerrainChannel(m_InitialTerrain);
SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID); SimulationDataService.StoreTerrain(Heightmap.GetDoubles(), RegionInfo.RegionID);
} }
@ -2894,7 +2901,6 @@ namespace OpenSim.Region.Framework.Scenes
{ {
//client.OnNameFromUUIDRequest += HandleUUIDNameRequest; //client.OnNameFromUUIDRequest += HandleUUIDNameRequest;
client.OnMoneyTransferRequest += ProcessMoneyTransferRequest; client.OnMoneyTransferRequest += ProcessMoneyTransferRequest;
client.OnAvatarPickerRequest += ProcessAvatarPickerRequest;
client.OnSetStartLocationRequest += SetHomeRezPoint; client.OnSetStartLocationRequest += SetHomeRezPoint;
client.OnRegionHandleRequest += RegionHandleRequest; client.OnRegionHandleRequest += RegionHandleRequest;
} }
@ -3022,7 +3028,6 @@ namespace OpenSim.Region.Framework.Scenes
{ {
//client.OnNameFromUUIDRequest -= HandleUUIDNameRequest; //client.OnNameFromUUIDRequest -= HandleUUIDNameRequest;
client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest; client.OnMoneyTransferRequest -= ProcessMoneyTransferRequest;
client.OnAvatarPickerRequest -= ProcessAvatarPickerRequest;
client.OnSetStartLocationRequest -= SetHomeRezPoint; client.OnSetStartLocationRequest -= SetHomeRezPoint;
client.OnRegionHandleRequest -= RegionHandleRequest; client.OnRegionHandleRequest -= RegionHandleRequest;
} }
@ -3693,8 +3698,8 @@ namespace OpenSim.Region.Framework.Scenes
if (!AuthorizationService.IsAuthorizedForRegion( if (!AuthorizationService.IsAuthorizedForRegion(
agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason)) agent.AgentID.ToString(), agent.firstname, agent.lastname, RegionInfo.RegionID.ToString(), out reason))
{ {
m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because the user does not have access to the region", m_log.WarnFormat("[CONNECTION BEGIN]: Denied access to: {0} ({1} {2}) at {3} because {4}",
agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName); agent.AgentID, agent.firstname, agent.lastname, RegionInfo.RegionName, reason);
return false; return false;
} }

View File

@ -814,6 +814,7 @@ namespace OpenSim.Region.Framework.Scenes
#endregion #endregion
#region Get Methods #region Get Methods
/// <summary> /// <summary>
/// Get the controlling client for the given avatar, if there is one. /// Get the controlling client for the given avatar, if there is one.
/// ///
@ -1155,36 +1156,6 @@ namespace OpenSim.Region.Framework.Scenes
return Entities.GetEntities(); return Entities.GetEntities();
} }
public Dictionary<uint, float> GetTopScripts()
{
Dictionary<uint, float> topScripts = new Dictionary<uint, float>();
EntityBase[] EntityList = GetEntities();
int limit = 0;
foreach (EntityBase ent in EntityList)
{
if (ent is SceneObjectGroup)
{
SceneObjectGroup grp = (SceneObjectGroup)ent;
if ((grp.RootPart.GetEffectiveObjectFlags() & (uint)PrimFlags.Scripted) != 0)
{
if (grp.scriptScore >= 0.01)
{
topScripts.Add(grp.LocalId, grp.scriptScore);
limit++;
if (limit >= 100)
{
break;
}
}
grp.scriptScore = 0;
}
}
}
return topScripts;
}
#endregion #endregion
#region Other Methods #region Other Methods

View File

@ -293,8 +293,6 @@ namespace OpenSim.Region.Framework.Scenes
get { return RootPart.VolumeDetectActive; } get { return RootPart.VolumeDetectActive; }
} }
public float scriptScore;
private Vector3 lastPhysGroupPos; private Vector3 lastPhysGroupPos;
private Quaternion lastPhysGroupRot; private Quaternion lastPhysGroupRot;
@ -1622,12 +1620,7 @@ namespace OpenSim.Region.Framework.Scenes
public void AddScriptLPS(int count) public void AddScriptLPS(int count)
{ {
if (scriptScore + count >= float.MaxValue - count) m_scene.SceneGraph.AddToScriptLPS(count);
scriptScore = 0;
scriptScore += (float)count;
SceneGraph d = m_scene.SceneGraph;
d.AddToScriptLPS(count);
} }
public void AddActiveScriptCount(int count) public void AddActiveScriptCount(int count)

View File

@ -48,21 +48,18 @@ namespace OpenSim.Region.Framework.Scenes
map = new double[Constants.RegionSize, Constants.RegionSize]; map = new double[Constants.RegionSize, Constants.RegionSize];
taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16]; taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16];
int x; PinHeadIsland();
for (x = 0; x < Constants.RegionSize; x++)
{
int y;
for (y = 0; y < Constants.RegionSize; y++)
{
map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10;
double spherFacA = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 50) * 0.01;
double spherFacB = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 100) * 0.001;
if (map[x, y] < spherFacA)
map[x, y] = spherFacA;
if (map[x, y] < spherFacB)
map[x, y] = spherFacB;
}
} }
public TerrainChannel(String type)
{
map = new double[Constants.RegionSize, Constants.RegionSize];
taint = new bool[Constants.RegionSize / 16, Constants.RegionSize / 16];
if (type.Equals("flat"))
FlatLand();
else
PinHeadIsland();
} }
public TerrainChannel(double[,] import) public TerrainChannel(double[,] import)
@ -238,5 +235,36 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
} }
private void PinHeadIsland()
{
int x;
for (x = 0; x < Constants.RegionSize; x++)
{
int y;
for (y = 0; y < Constants.RegionSize; y++)
{
map[x, y] = TerrainUtil.PerlinNoise2D(x, y, 2, 0.125) * 10;
double spherFacA = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 50) * 0.01;
double spherFacB = TerrainUtil.SphericalFactor(x, y, Constants.RegionSize / 2.0, Constants.RegionSize / 2.0, 100) * 0.001;
if (map[x, y] < spherFacA)
map[x, y] = spherFacA;
if (map[x, y] < spherFacB)
map[x, y] = spherFacB;
}
}
}
private void FlatLand()
{
int x;
for (x = 0; x < Constants.RegionSize; x++)
{
int y;
for (y = 0; y < Constants.RegionSize; y++)
map[x, y] = 21;
}
}
} }
} }

View File

@ -27,6 +27,7 @@
using System; using System;
using System.Reflection; using System.Reflection;
using System.Collections.Generic;
using Nini.Config; using Nini.Config;
using log4net; using log4net;
using OpenSim.Framework; using OpenSim.Framework;
@ -35,7 +36,7 @@ using OpenSim.Region.Framework.Scenes;
using Mono.Addins; using Mono.Addins;
using OpenMetaverse; using OpenMetaverse;
namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms namespace OpenSim.Region.CoreModules.Scripting.ScriptModuleComms
{ {
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "ScriptModuleCommsModule")]
class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms class ScriptModuleCommsModule : INonSharedRegionModule, IScriptModuleComms
@ -43,10 +44,30 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
private static readonly ILog m_log = private static readonly ILog m_log =
LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private IScriptModule m_scriptModule = null; #region ScriptInvocation
protected class ScriptInvocationData
{
public ScriptInvocation ScriptInvocationFn { get; private set; }
public string FunctionName { get; private set; }
public Type[] TypeSignature { get; private set; }
public Type ReturnType { get; private set; }
public ScriptInvocationData(string fname, ScriptInvocation fn, Type[] callsig, Type returnsig)
{
FunctionName = fname;
ScriptInvocationFn = fn;
TypeSignature = callsig;
ReturnType = returnsig;
}
}
private Dictionary<string,ScriptInvocationData> m_scriptInvocation = new Dictionary<string,ScriptInvocationData>();
#endregion
private IScriptModule m_scriptModule = null;
public event ScriptCommand OnScriptCommand; public event ScriptCommand OnScriptCommand;
#region RegionModuleInterface
public void Initialise(IConfigSource config) public void Initialise(IConfigSource config)
{ {
} }
@ -81,6 +102,9 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
public void Close() public void Close()
{ {
} }
#endregion
#region ScriptModuleComms
public void RaiseEvent(UUID script, string id, string module, string command, string k) public void RaiseEvent(UUID script, string id, string module, string command, string k)
{ {
@ -101,5 +125,76 @@ namespace OpenSim.Region.OptionalModules.Scripting.ScriptModuleComms
m_scriptModule.PostScriptEvent(script, "link_message", args); m_scriptModule.PostScriptEvent(script, "link_message", args);
} }
public void RegisterScriptInvocation(string fname, ScriptInvocation fcall, Type[] csig, Type rsig)
{
lock (m_scriptInvocation)
{
m_scriptInvocation[fname] = new ScriptInvocationData(fname,fcall,csig,rsig);
}
}
public string LookupModInvocation(string fname)
{
lock (m_scriptInvocation)
{
ScriptInvocationData sid;
if (m_scriptInvocation.TryGetValue(fname,out sid))
{
if (sid.ReturnType == typeof(string))
return "modInvokeS";
else if (sid.ReturnType == typeof(int))
return "modInvokeI";
else if (sid.ReturnType == typeof(float))
return "modInvokeF";
}
}
return null;
}
public ScriptInvocation LookupScriptInvocation(string fname)
{
lock (m_scriptInvocation)
{
ScriptInvocationData sid;
if (m_scriptInvocation.TryGetValue(fname,out sid))
return sid.ScriptInvocationFn;
}
return null;
}
public Type[] LookupTypeSignature(string fname)
{
lock (m_scriptInvocation)
{
ScriptInvocationData sid;
if (m_scriptInvocation.TryGetValue(fname,out sid))
return sid.TypeSignature;
}
return null;
}
public Type LookupReturnType(string fname)
{
lock (m_scriptInvocation)
{
ScriptInvocationData sid;
if (m_scriptInvocation.TryGetValue(fname,out sid))
return sid.ReturnType;
}
return null;
}
public object InvokeOperation(UUID scriptid, string fname, params object[] parms)
{
ScriptInvocation fn = LookupScriptInvocation(fname);
return fn(scriptid,parms);
}
#endregion
} }
} }

View File

@ -78,12 +78,38 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
/// </summary> /// </summary>
string State { get; set; } string State { get; set; }
/// <summary>
/// Time the script was last started
/// </summary>
DateTime TimeStarted { get; }
/// <summary>
/// Tick the last measurement period was started.
/// </summary>
long MeasurementPeriodTickStart { get; }
/// <summary>
/// Ticks spent executing in the last measurement period.
/// </summary>
long MeasurementPeriodExecutionTime { get; }
IScriptEngine Engine { get; } IScriptEngine Engine { get; }
UUID AppDomain { get; set; } UUID AppDomain { get; set; }
string PrimName { get; } string PrimName { get; }
string ScriptName { get; } string ScriptName { get; }
UUID ItemID { get; } UUID ItemID { get; }
UUID ObjectID { get; } UUID ObjectID { get; }
/// <summary>
/// UUID of the root object for the linkset that the script is in.
/// </summary>
UUID RootObjectID { get; }
/// <summary>
/// Local id of the root object for the linkset that the script is in.
/// </summary>
uint RootLocalID { get; }
uint LocalID { get; } uint LocalID { get; }
UUID AssetID { get; } UUID AssetID { get; }
Queue EventQueue { get; } Queue EventQueue { get; }

View File

@ -116,6 +116,115 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message); wComm.DeliverMessage(ChatTypeEnum.Shout, ScriptBaseClass.DEBUG_CHANNEL, m_host.Name, m_host.UUID, message);
} }
/// <summary>
///
/// </summary>
/// <param name="fname">The name of the function to invoke</param>
/// <param name="fname">List of parameters</param>
/// <returns>string result of the invocation</returns>
public string modInvokeS(string fname, params object[] parms)
{
Type returntype = m_comms.LookupReturnType(fname);
if (returntype != typeof(string))
MODError(String.Format("return type mismatch for {0}",fname));
return (string)modInvoke(fname,parms);
}
public int modInvokeI(string fname, params object[] parms)
{
Type returntype = m_comms.LookupReturnType(fname);
if (returntype != typeof(int))
MODError(String.Format("return type mismatch for {0}",fname));
return (int)modInvoke(fname,parms);
}
public float modInvokeF(string fname, params object[] parms)
{
Type returntype = m_comms.LookupReturnType(fname);
if (returntype != typeof(float))
MODError(String.Format("return type mismatch for {0}",fname));
return (float)modInvoke(fname,parms);
}
/// <summary>
/// Invokes a preregistered function through the ScriptModuleComms class
/// </summary>
/// <param name="fname">The name of the function to invoke</param>
/// <param name="fname">List of parameters</param>
/// <returns>string result of the invocation</returns>
protected object modInvoke(string fname, params object[] parms)
{
if (!m_MODFunctionsEnabled)
{
MODShoutError("Module command functions not enabled");
return "";
}
Type[] signature = m_comms.LookupTypeSignature(fname);
if (signature.Length != parms.Length)
MODError(String.Format("wrong number of parameters to function {0}",fname));
object[] convertedParms = new object[parms.Length];
for (int i = 0; i < parms.Length; i++)
{
if (parms[i] is LSL_String)
{
if (signature[i] != typeof(string))
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
convertedParms[i] = (string)(LSL_String)parms[i];
}
else if (parms[i] is LSL_Integer)
{
if (signature[i] != typeof(int))
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
convertedParms[i] = (int)(LSL_Integer)parms[i];
}
else if (parms[i] is LSL_Float)
{
if (signature[i] != typeof(float))
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
convertedParms[i] = (float)(LSL_Float)parms[i];
}
else if (parms[i] is LSL_Key)
{
if (signature[i] != typeof(string))
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
convertedParms[i] = (string)(LSL_Key)parms[i];
}
else if (parms[i] is LSL_Rotation)
{
if (signature[i] != typeof(string))
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
convertedParms[i] = (string)(LSL_Rotation)parms[i];
}
else if (parms[i] is LSL_Vector)
{
if (signature[i] != typeof(string))
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
convertedParms[i] = (string)(LSL_Vector)parms[i];
}
else
{
if (signature[i] != parms[i].GetType())
MODError(String.Format("parameter type mismatch in {0}; expecting {1}",fname,signature[i].Name));
convertedParms[i] = parms[i];
}
}
return m_comms.InvokeOperation(m_itemID,fname,convertedParms);
}
public string modSendCommand(string module, string command, string k) public string modSendCommand(string module, string command, string k)
{ {
if (!m_MODFunctionsEnabled) if (!m_MODFunctionsEnabled)

View File

@ -3003,5 +3003,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ"); return date.ToString("yyyy-MM-ddTHH:mm:ss.fffffffZ");
} }
/// <summary>
/// Get the description from an inventory item
/// </summary>
/// <param name="inventoryName"></param>
/// <returns>Item description</returns>
public LSL_String osGetInventoryDesc(string item)
{
m_host.AddScriptLPS(1);
lock (m_host.TaskInventory)
{
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == item)
{
return inv.Value.Description.ToString();
}
}
}
return String.Empty;
}
} }
} }

View File

@ -40,6 +40,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
{ {
public interface IMOD_Api public interface IMOD_Api
{ {
// Invocation functions
string modInvokeS(string fname, params object[] parms);
int modInvokeI(string fname, params object[] parms);
float modInvokeF(string fname, params object[] parms);
// vector modInvokeV(string fname, params object[] parms);
// rotation modInvokeV(string fname, params object[] parms);
// key modInvokeK(string fname, params object[] parms);
// list modInvokeL(string fname, params object[] parms);
//Module functions //Module functions
string modSendCommand(string modules, string command, string k); string modSendCommand(string modules, string command, string k);
} }

View File

@ -229,5 +229,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
LSL_List osGetAvatarList(); LSL_List osGetAvatarList();
LSL_String osUnixTimeToTimestamp(long time); LSL_String osUnixTimeToTimestamp(long time);
LSL_String osGetInventoryDesc(string item);
} }
} }

View File

@ -58,6 +58,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_MOD_Functions = (IMOD_Api)api; m_MOD_Functions = (IMOD_Api)api;
} }
public string modInvokeS(string fname, params object[] parms)
{
return m_MOD_Functions.modInvokeS(fname, parms);
}
public int modInvokeI(string fname, params object[] parms)
{
return m_MOD_Functions.modInvokeI(fname, parms);
}
public float modInvokeF(string fname, params object[] parms)
{
return m_MOD_Functions.modInvokeF(fname, parms);
}
public string modSendCommand(string module, string command, string k) public string modSendCommand(string module, string command, string k)
{ {
return m_MOD_Functions.modSendCommand(module, command, k); return m_MOD_Functions.modSendCommand(module, command, k);

View File

@ -863,5 +863,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{ {
return m_OSSL_Functions.osUnixTimeToTimestamp(time); return m_OSSL_Functions.osUnixTimeToTimestamp(time);
} }
public LSL_String osGetInventoryDesc(string item)
{
return m_OSSL_Functions.osGetInventoryDesc(item);
}
} }
} }

View File

@ -32,6 +32,8 @@ using System.Reflection;
using log4net; using log4net;
using Tools; using Tools;
using OpenSim.Region.Framework.Interfaces;
namespace OpenSim.Region.ScriptEngine.Shared.CodeTools namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
{ {
public class CSCodeGenerator : ICodeConverter public class CSCodeGenerator : ICodeConverter
@ -45,12 +47,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
private int m_CSharpLine; // the current line of generated C# code private int m_CSharpLine; // the current line of generated C# code
private int m_CSharpCol; // the current column of generated C# code private int m_CSharpCol; // the current column of generated C# code
private List<string> m_warnings = new List<string>(); private List<string> m_warnings = new List<string>();
private IScriptModuleComms m_comms = null;
/// <summary> /// <summary>
/// Creates an 'empty' CSCodeGenerator instance. /// Creates an 'empty' CSCodeGenerator instance.
/// </summary> /// </summary>
public CSCodeGenerator() public CSCodeGenerator()
{ {
m_comms = null;
ResetCounters();
}
public CSCodeGenerator(IScriptModuleComms comms)
{
m_comms = comms;
ResetCounters(); ResetCounters();
} }
@ -866,7 +876,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
{ {
string retstr = String.Empty; string retstr = String.Empty;
string modinvoke = null;
if (m_comms != null)
modinvoke = m_comms.LookupModInvocation(fc.Id);
if (modinvoke != null)
{
if (fc.kids[0] is ArgumentList)
{
if ((fc.kids[0] as ArgumentList).kids.Count == 0)
retstr += Generate(String.Format("{0}(\"{1}\"",modinvoke,fc.Id), fc);
else
retstr += Generate(String.Format("{0}(\"{1}\",",modinvoke,fc.Id), fc);
}
}
else
{
retstr += Generate(String.Format("{0}(", CheckName(fc.Id)), fc); retstr += Generate(String.Format("{0}(", CheckName(fc.Id)), fc);
}
foreach (SYMBOL kid in fc.kids) foreach (SYMBOL kid in fc.kids)
retstr += GenerateNode(kid); retstr += GenerateNode(kid);

View File

@ -35,6 +35,7 @@ using Microsoft.CSharp;
//using Microsoft.JScript; //using Microsoft.JScript;
using Microsoft.VisualBasic; using Microsoft.VisualBasic;
using log4net; using log4net;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.ScriptEngine.Interfaces; using OpenSim.Region.ScriptEngine.Interfaces;
using OpenMetaverse; using OpenMetaverse;
@ -293,6 +294,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
{ {
// m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script); // m_log.DebugFormat("[Compiler]: Compiling script\n{0}", Script);
IScriptModuleComms comms = m_scriptEngine.World.RequestModuleInterface<IScriptModuleComms>();
linemap = null; linemap = null;
m_warnings.Clear(); m_warnings.Clear();
@ -382,7 +385,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.CodeTools
if (language == enumCompileType.lsl) if (language == enumCompileType.lsl)
{ {
// Its LSL, convert it to C# // Its LSL, convert it to C#
LSL_Converter = (ICodeConverter)new CSCodeGenerator(); LSL_Converter = (ICodeConverter)new CSCodeGenerator(comms);
compileScript = LSL_Converter.Convert(Script); compileScript = LSL_Converter.Convert(Script);
// copy converter warnings into our warnings. // copy converter warnings into our warnings.

View File

@ -165,6 +165,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
public uint LocalID { get; private set; } public uint LocalID { get; private set; }
public UUID RootObjectID { get; private set; }
public uint RootLocalID { get; private set; }
public UUID AssetID { get; private set; } public UUID AssetID { get; private set; }
public Queue EventQueue { get; private set; } public Queue EventQueue { get; private set; }
@ -173,6 +177,14 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
public TaskInventoryItem ScriptTask { get; private set; } public TaskInventoryItem ScriptTask { get; private set; }
public DateTime TimeStarted { get; private set; }
public long MeasurementPeriodTickStart { get; private set; }
public long MeasurementPeriodExecutionTime { get; private set; }
public static readonly long MaxMeasurementPeriod = 30 * TimeSpan.TicksPerMinute;
public void ClearQueue() public void ClearQueue()
{ {
m_TimerQueued = false; m_TimerQueued = false;
@ -191,6 +203,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
Engine = engine; Engine = engine;
LocalID = part.LocalId; LocalID = part.LocalId;
ObjectID = part.UUID; ObjectID = part.UUID;
RootLocalID = part.ParentGroup.LocalId;
RootObjectID = part.ParentGroup.UUID;
ItemID = itemID; ItemID = itemID;
AssetID = assetID; AssetID = assetID;
PrimName = primName; PrimName = primName;
@ -459,6 +473,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
Running = true; Running = true;
TimeStarted = DateTime.Now;
MeasurementPeriodTickStart = Util.EnvironmentTickCount();
MeasurementPeriodExecutionTime = 0;
if (EventQueue.Count > 0) if (EventQueue.Count > 0)
{ {
if (m_CurrentWorkItem == null) if (m_CurrentWorkItem == null)
@ -712,8 +730,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
m_EventStart = DateTime.Now; m_EventStart = DateTime.Now;
m_InEvent = true; m_InEvent = true;
int start = Util.EnvironmentTickCount();
// Reset the measurement period when we reach the end of the current one.
if (start - MeasurementPeriodTickStart > MaxMeasurementPeriod)
MeasurementPeriodTickStart = start;
m_Script.ExecuteEvent(State, data.EventName, data.Params); m_Script.ExecuteEvent(State, data.EventName, data.Params);
MeasurementPeriodExecutionTime += Util.EnvironmentTickCount() - start;
m_InEvent = false; m_InEvent = false;
m_CurrentEvent = String.Empty; m_CurrentEvent = String.Empty;
@ -722,7 +748,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
// This will be the very first event we deliver // This will be the very first event we deliver
// (state_entry) in default state // (state_entry) in default state
// //
SaveState(m_Assembly); SaveState(m_Assembly);
m_SaveState = false; m_SaveState = false;

View File

@ -448,6 +448,11 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene)) if (!(MainConsole.Instance.ConsoleScene == null || MainConsole.Instance.ConsoleScene == m_Scene))
return; return;
MainConsole.Instance.OutputFormat(GetStatusReport());
}
public string GetStatusReport()
{
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName); sb.AppendFormat("Status of XEngine instance for {0}\n", m_Scene.RegionInfo.RegionName);
@ -475,7 +480,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
Listener l = AsyncCommandManager.GetListenerPlugin(this); Listener l = AsyncCommandManager.GetListenerPlugin(this);
sb.AppendFormat("Listeners : {0}\n", l.ListenerCount); sb.AppendFormat("Listeners : {0}\n", l.ListenerCount);
MainConsole.Instance.OutputFormat(sb.ToString()); return sb.ToString();
} }
public void HandleShowScripts(string module, string[] cmdparams) public void HandleShowScripts(string module, string[] cmdparams)
@ -1154,7 +1159,6 @@ namespace OpenSim.Region.ScriptEngine.XEngine
if (!m_PrimObjects[localID].Contains(itemID)) if (!m_PrimObjects[localID].Contains(itemID))
m_PrimObjects[localID].Add(itemID); m_PrimObjects[localID].Add(itemID);
} }
if (!m_Assemblies.ContainsKey(assetID)) if (!m_Assemblies.ContainsKey(assetID))
@ -1981,6 +1985,59 @@ namespace OpenSim.Region.ScriptEngine.XEngine
} }
} }
public Dictionary<uint, float> GetObjectScriptsExecutionTimes()
{
long tickNow = Util.EnvironmentTickCount();
Dictionary<uint, float> topScripts = new Dictionary<uint, float>();
lock (m_Scripts)
{
foreach (IScriptInstance si in m_Scripts.Values)
{
if (!topScripts.ContainsKey(si.LocalID))
topScripts[si.RootLocalID] = 0;
// long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
// float framesElapsed = ticksElapsed / (18.1818 * TimeSpan.TicksPerMillisecond);
// Execution time of the script adjusted by it's measurement period to make scripts started at
// different times comparable.
// float adjustedExecutionTime
// = (float)si.MeasurementPeriodExecutionTime
// / ((float)(tickNow - si.MeasurementPeriodTickStart) / ScriptInstance.MaxMeasurementPeriod)
// / TimeSpan.TicksPerMillisecond;
long ticksElapsed = tickNow - si.MeasurementPeriodTickStart;
// Avoid divide by zerp
if (ticksElapsed == 0)
ticksElapsed = 1;
// Scale execution time to the ideal 55 fps frame time for these reasons.
//
// 1) XEngine does not execute scripts per frame, unlike other script engines. Hence, there is no
// 'script execution time per frame', which is the original purpose of this value.
//
// 2) Giving the raw execution times is misleading since scripts start at different times, making
// it impossible to compare scripts.
//
// 3) Scaling the raw execution time to the time that the script has been running is better but
// is still misleading since a script that has just been rezzed may appear to have been running
// for much longer.
//
// 4) Hence, we scale execution time to an idealised frame time (55 fps). This is also not perfect
// since the figure does not represent actual execution time and very hard running scripts will
// never exceed 18ms (though this is a very high number for script execution so is a warning sign).
float adjustedExecutionTime
= ((float)si.MeasurementPeriodExecutionTime / ticksElapsed) * 18.1818f;
topScripts[si.RootLocalID] += adjustedExecutionTime;
}
}
return topScripts;
}
public void SuspendScript(UUID itemID) public void SuspendScript(UUID itemID)
{ {
// m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID); // m_log.DebugFormat("[XEngine]: Received request to suspend script with ID {0}", itemID);

View File

@ -790,7 +790,9 @@
;# {Enabled} {} {Enable Non Player Character (NPC) facilities} {true false} false ;# {Enabled} {} {Enable Non Player Character (NPC) facilities} {true false} false
; Enabled = false ; Enabled = false
[Terrain]
;# {InitialTerrain} {} {Initial terrain type} {pinhead-island flat} pinhead-island
; InitialTerrain = "pinhead-island"
[Architecture] [Architecture]
;# {Include-Architecture} {} {Choose one of the following architectures} {config-include/Standalone.ini config-include/StandaloneHypergrid.ini config-include/Grid.ini config-include/GridHypergrid.ini config-include/SimianGrid.ini config-include/HyperSimianGrid.ini} config-include/Standalone.ini ;# {Include-Architecture} {} {Choose one of the following architectures} {config-include/Standalone.ini config-include/StandaloneHypergrid.ini config-include/Grid.ini config-include/GridHypergrid.ini config-include/SimianGrid.ini config-include/HyperSimianGrid.ini} config-include/Standalone.ini

View File

@ -1512,6 +1512,9 @@
;; Enable Non Player Character (NPC) facilities ;; Enable Non Player Character (NPC) facilities
Enabled = false Enabled = false
[Terrain]
InitialTerrain = "pinhead-island"
;; ;;
;; If you are using a simian grid frontend you can enable ;; If you are using a simian grid frontend you can enable
;; this module to upload tile images for the mapping fn ;; this module to upload tile images for the mapping fn

View File

@ -66,6 +66,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
; * in turn, reads the asset loader and database connection information ; * in turn, reads the asset loader and database connection information
; * ; *
[AssetService] [AssetService]
StorageProvider = "OpenSim.Data.MySQL.dll:MySQLAssetData"
LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService" LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService"
DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll" DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll"
AssetLoaderArgs = "./assets/AssetSets.xml" AssetLoaderArgs = "./assets/AssetSets.xml"

View File

@ -58,6 +58,7 @@ ServiceConnectors = "8003/OpenSim.Server.Handlers.dll:AssetServiceConnector,8003
; * in turn, reads the asset loader and database connection information ; * in turn, reads the asset loader and database connection information
; * ; *
[AssetService] [AssetService]
StorageProvider = "OpenSim.Data.MySQL.dll:MySQLAssetData"
LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService" LocalServiceModule = "OpenSim.Services.AssetService.dll:AssetService"
DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll" DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll"
AssetLoaderArgs = "./assets/AssetSets.xml" AssetLoaderArgs = "./assets/AssetSets.xml"

View File

@ -1,104 +0,0 @@
// autogenerated by generate_default_lsl.rb
integer touch_count = 0;
default {
touch_start(integer total_number) {
float angle45 = PI/4.0; // 45 degrees
float angle30 = PI/6.0; // 30 degrees
float sqrt2 = llSqrt(2.0);
if((llFabs(-1.5) != 1.5) || (llFabs(10.4) != 10.4)) {
llShout(0, "Houston, we have a big problem! llFabs() does not work! Need it for other tests!");
}
llSetText("This is a text by llSetText", <1,0,0>, 1);
llWhisper(0, "llWhispering a few random numbers between 0 and 100: " + llFrand(100) + "," + llFrand(100) + "," + llFrand(100) + "," + llFrand(100));
llShout(0, "llShouting the unix time: " + llGetUnixTime() + ", and region corner: " + llGetRegionCorner());
llShout(1, "Shouting a random number between 0 and 100 on the channel#1: " + llFrand(100));
if (llAbs(-1) != 1) {
llSay(0, "Assert failed: llAbs(-1) != 1");
}
if (llAbs(10) != 10) {
llSay(0, "Assert failed: llAbs(10) != 10");
}
if (llFabs((llCos(angle45) - sqrt2/2.0) - 0) > 0.000001) {
llSay(0, "Assert failed: (llCos(angle45) - sqrt2/2.0) differs from 0 by more than 0.000001");
llSay(0, " --> The actual result: " + (llCos(angle45) - sqrt2/2.0));
}
if (llFabs((llSin(angle30) - 0.5) - 0) > 0.000001) {
llSay(0, "Assert failed: (llSin(angle30) - 0.5) differs from 0 by more than 0.000001");
llSay(0, " --> The actual result: " + (llSin(angle30) - 0.5));
}
if (llFabs((llAtan2(1, 1)*4 - PI) - 0) > 0.000001) {
llSay(0, "Assert failed: (llAtan2(1, 1)*4 - PI) differs from 0 by more than 0.000001");
llSay(0, " --> The actual result: " + (llAtan2(1, 1)*4 - PI));
}
if (llFabs((llTan(PI)) - 0) > 0.000001) {
llSay(0, "Assert failed: (llTan(PI)) differs from 0 by more than 0.000001");
llSay(0, " --> The actual result: " + (llTan(PI)));
}
if (llFloor(2.4) != 2) {
llSay(0, "Assert failed: llFloor(2.4) != 2");
}
if (llCeil(2.4) != 3) {
llSay(0, "Assert failed: llCeil(2.4) != 3");
}
if (llRound(2.4) != 2) {
llSay(0, "Assert failed: llRound(2.4) != 2");
}
if (llFloor(2.5) != 2) {
llSay(0, "Assert failed: llFloor(2.5) != 2");
}
if (llCeil(2.5) != 3) {
llSay(0, "Assert failed: llCeil(2.5) != 3");
}
if (llRound(2.5) != 3) {
llSay(0, "Assert failed: llRound(2.5) != 3");
}
if (llFloor(2.51) != 2) {
llSay(0, "Assert failed: llFloor(2.51) != 2");
}
if (llCeil(2.51) != 3) {
llSay(0, "Assert failed: llCeil(2.51) != 3");
}
if (llRound(2.51) != 3) {
llSay(0, "Assert failed: llRound(2.51) != 3");
}
if (llFloor(3.49) != 3) {
llSay(0, "Assert failed: llFloor(3.49) != 3");
}
if (llCeil(3.49) != 4) {
llSay(0, "Assert failed: llCeil(3.49) != 4");
}
if (llRound(3.49) != 3) {
llSay(0, "Assert failed: llRound(3.49) != 3");
}
if (llFloor(3.5000001) != 3) {
llSay(0, "Assert failed: llFloor(3.5000001) != 3");
}
if (llCeil(3.5000001) != 4) {
llSay(0, "Assert failed: llCeil(3.5000001) != 4");
}
if (llRound(3.5000001) != 4) {
llSay(0, "Assert failed: llRound(3.5000001) != 4");
}
if (llFloor(3.51) != 3) {
llSay(0, "Assert failed: llFloor(3.51) != 3");
}
if (llCeil(3.51) != 4) {
llSay(0, "Assert failed: llCeil(3.51) != 4");
}
if (llRound(3.51) != 4) {
llSay(0, "Assert failed: llRound(3.51) != 4");
}
if ((llFabs(0-llPow(2, 16))) != 65536) {
llSay(0, "Assert failed: (llFabs(0-llPow(2, 16))) != 65536");
}
if (llMD5String("Hello, Avatar!",0) != "112abd47ceaae1c05a826828650434a6") {
llSay(0, "Assert failed: llMD5String('Hello, Avatar!',0) != '112abd47ceaae1c05a826828650434a6'");
}
if (llModPow(2, 16, 37) != 9) {
llSay(0, "Assert failed: llModPow(2, 16, 37) != 9");
}
touch_count++;
llSay(0, "Object was touched. Touch count: " + touch_count);
}
}

View File

@ -14,6 +14,7 @@
AvatarServices = "RemoteAvatarServicesConnector" AvatarServices = "RemoteAvatarServicesConnector"
NeighbourServices = "RemoteNeighbourServicesConnector" NeighbourServices = "RemoteNeighbourServicesConnector"
AuthenticationServices = "RemoteAuthenticationServicesConnector" AuthenticationServices = "RemoteAuthenticationServicesConnector"
AuthorizationServices = "LocalAuthorizationServicesConnector"
PresenceServices = "RemotePresenceServicesConnector" PresenceServices = "RemotePresenceServicesConnector"
UserAccountServices = "RemoteUserAccountServicesConnector" UserAccountServices = "RemoteUserAccountServicesConnector"
GridUserServices = "RemoteGridUserServicesConnector" GridUserServices = "RemoteGridUserServicesConnector"

View File

@ -146,3 +146,13 @@
[MapImageService] [MapImageService]
MapImageServerURI = "http://mygridserver.com:8003" MapImageServerURI = "http://mygridserver.com:8003"
[AuthorizationService]
; If you have regions with access restrictions
; specify them here using the convention
; Region_<Region_Name> = <flags>
; Valid flags are:
; DisallowForeigners -- HG visitors not allowed
; DisallowResidents -- only Admins and Managers allowed
; Example:
; Region_Test_1 = "DisallowForeigners"

View File

@ -17,6 +17,7 @@
AvatarServices = "RemoteAvatarServicesConnector" AvatarServices = "RemoteAvatarServicesConnector"
NeighbourServices = "RemoteNeighbourServicesConnector" NeighbourServices = "RemoteNeighbourServicesConnector"
AuthenticationServices = "RemoteAuthenticationServicesConnector" AuthenticationServices = "RemoteAuthenticationServicesConnector"
AuthorizationServices = "LocalAuthorizationServicesConnector"
PresenceServices = "RemotePresenceServicesConnector" PresenceServices = "RemotePresenceServicesConnector"
UserAccountServices = "RemoteUserAccountServicesConnector" UserAccountServices = "RemoteUserAccountServicesConnector"
GridUserServices = "RemoteGridUserServicesConnector" GridUserServices = "RemoteGridUserServicesConnector"
@ -26,6 +27,7 @@
LandServices = "RemoteLandServicesConnector" LandServices = "RemoteLandServicesConnector"
FriendsModule = "HGFriendsModule" FriendsModule = "HGFriendsModule"
MapImageService = "MapImageServiceModule" MapImageService = "MapImageServiceModule"
UserManagementModule = "HGUserManagementModule"
LandServiceInConnector = true LandServiceInConnector = true
NeighbourServiceInConnector = true NeighbourServiceInConnector = true

View File

@ -9,6 +9,7 @@
InventoryServices = "LocalInventoryServicesConnector" InventoryServices = "LocalInventoryServicesConnector"
NeighbourServices = "LocalNeighbourServicesConnector" NeighbourServices = "LocalNeighbourServicesConnector"
AuthenticationServices = "LocalAuthenticationServicesConnector" AuthenticationServices = "LocalAuthenticationServicesConnector"
AuthorizationServices = "LocalAuthorizationServicesConnector"
GridServices = "LocalGridServicesConnector" GridServices = "LocalGridServicesConnector"
PresenceServices = "LocalPresenceServicesConnector" PresenceServices = "LocalPresenceServicesConnector"
UserAccountServices = "LocalUserAccountServicesConnector" UserAccountServices = "LocalUserAccountServicesConnector"
@ -47,9 +48,6 @@
[AvatarService] [AvatarService]
LocalServiceModule = "OpenSim.Services.AvatarService.dll:AvatarService" LocalServiceModule = "OpenSim.Services.AvatarService.dll:AvatarService"
[AuthorizationService]
LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService"
[AuthenticationService] [AuthenticationService]
LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"

View File

@ -44,6 +44,7 @@
;AuthorizationServices = "LocalAuthorizationServicesConnector" ;AuthorizationServices = "LocalAuthorizationServicesConnector"
[AssetService] [AssetService]
StorageProvider = "OpenSim.Data.MySQL.dll:MySQLAssetData"
DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll" DefaultAssetLoader = "OpenSim.Framework.AssetLoader.Filesystem.dll"
AssetLoaderArgs = "assets/AssetSets.xml" AssetLoaderArgs = "assets/AssetSets.xml"
@ -231,3 +232,13 @@
[MapImageService] [MapImageService]
; Set this if you want to change the default ; Set this if you want to change the default
; TilesStoragePath = "maptiles" ; TilesStoragePath = "maptiles"
[AuthorizationService]
; If you have regions with access restrictions
; specify them here using the convention
; Region_<Region_Name> = <flags>
; Valid flags are:
; DisallowForeigners -- HG visitors not allowed
; DisallowResidents -- only Admins and Managers allowed
; Example:
; Region_Test_1 = "DisallowForeigners"

View File

@ -12,6 +12,7 @@
InventoryServices = "HGInventoryBroker" InventoryServices = "HGInventoryBroker"
NeighbourServices = "LocalNeighbourServicesConnector" NeighbourServices = "LocalNeighbourServicesConnector"
AuthenticationServices = "LocalAuthenticationServicesConnector" AuthenticationServices = "LocalAuthenticationServicesConnector"
AuthorizationServices = "LocalAuthorizationServicesConnector"
GridServices = "LocalGridServicesConnector" GridServices = "LocalGridServicesConnector"
PresenceServices = "LocalPresenceServicesConnector" PresenceServices = "LocalPresenceServicesConnector"
UserAccountServices = "LocalUserAccountServicesConnector" UserAccountServices = "LocalUserAccountServicesConnector"
@ -22,6 +23,7 @@
EntityTransferModule = "HGEntityTransferModule" EntityTransferModule = "HGEntityTransferModule"
InventoryAccessModule = "HGInventoryAccessModule" InventoryAccessModule = "HGInventoryAccessModule"
FriendsModule = "HGFriendsModule" FriendsModule = "HGFriendsModule"
UserManagementModule = "HGUserManagementModule"
InventoryServiceInConnector = true InventoryServiceInConnector = true
AssetServiceInConnector = true AssetServiceInConnector = true
@ -68,9 +70,6 @@
LibraryName = "OpenSim Library" LibraryName = "OpenSim Library"
DefaultLibrary = "./inventory/Libraries.xml" DefaultLibrary = "./inventory/Libraries.xml"
[AuthorizationService]
LocalServiceModule = "OpenSim.Services.AuthorizationService.dll:AuthorizationService"
[AuthenticationService] [AuthenticationService]
LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService" LocalServiceModule = "OpenSim.Services.AuthenticationService.dll:PasswordAuthenticationService"

View File

@ -1 +1,3 @@
backup ; You can place simulator console commands here to execute when the simulator is shut down
; e.g. show stats
; Lines starting with ; are comments

3
bin/startup_commands.txt Normal file
View File

@ -0,0 +1,3 @@
; You can place region console commands here to execute once the simulator has finished starting up
; e.g. show stats
; Lines start with ; are comments.

View File

@ -1,4 +0,0 @@
terrain load-tile f32 islandterrain_1024x512.raw 512 1024 1000 1000
terrain multiply 0.1
terrain add 5