Merge branch 'master' into careminster

Conflicts:
	OpenSim/Framework/Servers/BaseOpenSimServer.cs
	OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
avinationmerge
Melanie 2013-03-15 23:45:32 +00:00
commit b9146a7922
25 changed files with 474 additions and 339 deletions

View File

@ -155,6 +155,7 @@ what it is today.
* tglion * tglion
* tlaukkan/Tommil (Tommi S. E. Laukkanen, Bubble Cloud) * tlaukkan/Tommil (Tommi S. E. Laukkanen, Bubble Cloud)
* tyre * tyre
* Vegaslon <vegaslon@gmail.com>
* VikingErik * VikingErik
* Vytek * Vytek
* webmage (IBM) * webmage (IBM)

View File

@ -50,6 +50,11 @@ namespace OpenSim.Data.MySQL
get { return GetType().Assembly; } get { return GetType().Assembly; }
} }
/// <summary>
/// Number of days that must pass before we update the access time on an asset when it has been fetched.
/// </summary>
private const int DaysBetweenAccessTimeUpdates = 30;
private bool m_enableCompression = false; private bool m_enableCompression = false;
private string m_connectionString; private string m_connectionString;
private object m_dbLock = new object(); private object m_dbLock = new object();
@ -133,10 +138,10 @@ namespace OpenSim.Data.MySQL
dbcon.Open(); dbcon.Open();
using (MySqlCommand cmd = new MySqlCommand( using (MySqlCommand cmd = new MySqlCommand(
"SELECT name, description, asset_type, local, temporary, asset_flags, creator_id, data FROM xassetsmeta JOIN xassetsdata ON xassetsmeta.hash = xassetsdata.hash WHERE id=?id", "SELECT Name, Description, AccessTime, AssetType, Local, Temporary, AssetFlags, CreatorID, Data FROM XAssetsMeta JOIN XAssetsData ON XAssetsMeta.Hash = XAssetsData.Hash WHERE ID=?ID",
dbcon)) dbcon))
{ {
cmd.Parameters.AddWithValue("?id", assetID.ToString()); cmd.Parameters.AddWithValue("?ID", assetID.ToString());
try try
{ {
@ -144,18 +149,18 @@ namespace OpenSim.Data.MySQL
{ {
if (dbReader.Read()) if (dbReader.Read())
{ {
asset = new AssetBase(assetID, (string)dbReader["name"], (sbyte)dbReader["asset_type"], dbReader["creator_id"].ToString()); asset = new AssetBase(assetID, (string)dbReader["Name"], (sbyte)dbReader["AssetType"], dbReader["CreatorID"].ToString());
asset.Data = (byte[])dbReader["data"]; asset.Data = (byte[])dbReader["Data"];
asset.Description = (string)dbReader["description"]; asset.Description = (string)dbReader["Description"];
string local = dbReader["local"].ToString(); string local = dbReader["Local"].ToString();
if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase)) if (local.Equals("1") || local.Equals("true", StringComparison.InvariantCultureIgnoreCase))
asset.Local = true; asset.Local = true;
else else
asset.Local = false; asset.Local = false;
asset.Temporary = Convert.ToBoolean(dbReader["temporary"]); asset.Temporary = Convert.ToBoolean(dbReader["Temporary"]);
asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); asset.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
if (m_enableCompression) if (m_enableCompression)
{ {
@ -171,12 +176,14 @@ namespace OpenSim.Data.MySQL
// asset.ID, asset.Name, asset.Data.Length, compressedLength); // asset.ID, asset.Name, asset.Data.Length, compressedLength);
} }
} }
UpdateAccessTime(asset.Metadata, (int)dbReader["AccessTime"]);
} }
} }
} }
catch (Exception e) catch (Exception e)
{ {
m_log.Error("[MYSQL XASSET DATA]: MySql failure fetching asset " + assetID + ": " + e.Message); m_log.Error(string.Format("[MYSQL XASSET DATA]: Failure fetching asset {0}", assetID), e);
} }
} }
} }
@ -242,23 +249,23 @@ namespace OpenSim.Data.MySQL
{ {
using (MySqlCommand cmd = using (MySqlCommand cmd =
new MySqlCommand( new MySqlCommand(
"replace INTO xassetsmeta(id, hash, name, description, asset_type, local, temporary, create_time, access_time, asset_flags, creator_id)" + "replace INTO XAssetsMeta(ID, Hash, Name, Description, AssetType, Local, Temporary, CreateTime, AccessTime, AssetFlags, CreatorID)" +
"VALUES(?id, ?hash, ?name, ?description, ?asset_type, ?local, ?temporary, ?create_time, ?access_time, ?asset_flags, ?creator_id)", "VALUES(?ID, ?Hash, ?Name, ?Description, ?AssetType, ?Local, ?Temporary, ?CreateTime, ?AccessTime, ?AssetFlags, ?CreatorID)",
dbcon)) dbcon))
{ {
// create unix epoch time // create unix epoch time
int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow);
cmd.Parameters.AddWithValue("?id", asset.ID); cmd.Parameters.AddWithValue("?ID", asset.ID);
cmd.Parameters.AddWithValue("?hash", hash); cmd.Parameters.AddWithValue("?Hash", hash);
cmd.Parameters.AddWithValue("?name", assetName); cmd.Parameters.AddWithValue("?Name", assetName);
cmd.Parameters.AddWithValue("?description", assetDescription); cmd.Parameters.AddWithValue("?Description", assetDescription);
cmd.Parameters.AddWithValue("?asset_type", asset.Type); cmd.Parameters.AddWithValue("?AssetType", asset.Type);
cmd.Parameters.AddWithValue("?local", asset.Local); cmd.Parameters.AddWithValue("?Local", asset.Local);
cmd.Parameters.AddWithValue("?temporary", asset.Temporary); cmd.Parameters.AddWithValue("?Temporary", asset.Temporary);
cmd.Parameters.AddWithValue("?create_time", now); cmd.Parameters.AddWithValue("?CreateTime", now);
cmd.Parameters.AddWithValue("?access_time", now); cmd.Parameters.AddWithValue("?AccessTime", now);
cmd.Parameters.AddWithValue("?creator_id", asset.Metadata.CreatorID); cmd.Parameters.AddWithValue("?CreatorID", asset.Metadata.CreatorID);
cmd.Parameters.AddWithValue("?asset_flags", (int)asset.Flags); cmd.Parameters.AddWithValue("?AssetFlags", (int)asset.Flags);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
} }
@ -278,11 +285,11 @@ namespace OpenSim.Data.MySQL
{ {
using (MySqlCommand cmd = using (MySqlCommand cmd =
new MySqlCommand( new MySqlCommand(
"INSERT INTO xassetsdata(hash, data) VALUES(?hash, ?data)", "INSERT INTO XAssetsData(Hash, Data) VALUES(?Hash, ?Data)",
dbcon)) dbcon))
{ {
cmd.Parameters.AddWithValue("?hash", hash); cmd.Parameters.AddWithValue("?Hash", hash);
cmd.Parameters.AddWithValue("?data", asset.Data); cmd.Parameters.AddWithValue("?Data", asset.Data);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }
} }
@ -303,41 +310,49 @@ namespace OpenSim.Data.MySQL
} }
} }
// private void UpdateAccessTime(AssetBase asset) /// <summary>
// { /// Updates the access time of the asset if it was accessed above a given threshhold amount of time.
// lock (m_dbLock) /// </summary>
// { /// <remarks>
// using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) /// This gives us some insight into assets which haven't ben accessed for a long period. This is only done
// { /// over the threshold time to avoid excessive database writes as assets are fetched.
// dbcon.Open(); /// </remarks>
// MySqlCommand cmd = /// <param name='asset'></param>
// new MySqlCommand("update assets set access_time=?access_time where id=?id", /// <param name='accessTime'></param>
// dbcon); private void UpdateAccessTime(AssetMetadata assetMetadata, int accessTime)
// {
// // need to ensure we dispose DateTime now = DateTime.UtcNow;
// try
// { if ((now - Utils.UnixTimeToDateTime(accessTime)).TotalDays < DaysBetweenAccessTimeUpdates)
// using (cmd) return;
// {
// // create unix epoch time lock (m_dbLock)
// int now = (int)Utils.DateTimeToUnixTime(DateTime.UtcNow); {
// cmd.Parameters.AddWithValue("?id", asset.ID); using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
// cmd.Parameters.AddWithValue("?access_time", now); {
// cmd.ExecuteNonQuery(); dbcon.Open();
// cmd.Dispose(); MySqlCommand cmd =
// } new MySqlCommand("update XAssetsMeta set AccessTime=?AccessTime where ID=?ID", dbcon);
// }
// catch (Exception e) try
// { {
// m_log.ErrorFormat( using (cmd)
// "[ASSETS DB]: " + {
// "MySql failure updating access_time for asset {0} with name {1}" + Environment.NewLine + e.ToString() // create unix epoch time
// + Environment.NewLine + "Attempting reconnection", asset.FullID, asset.Name); cmd.Parameters.AddWithValue("?ID", assetMetadata.ID);
// } cmd.Parameters.AddWithValue("?AccessTime", (int)Utils.DateTimeToUnixTime(now));
// } cmd.ExecuteNonQuery();
// } }
// }
// } catch (Exception e)
{
m_log.ErrorFormat(
"[XASSET MYSQL DB]: Failure updating access_time for asset {0} with name {1}",
assetMetadata.ID, assetMetadata.Name);
}
}
}
}
/// <summary> /// <summary>
/// We assume we already have the m_dbLock. /// We assume we already have the m_dbLock.
@ -353,9 +368,9 @@ namespace OpenSim.Data.MySQL
bool exists = false; bool exists = false;
using (MySqlCommand cmd = new MySqlCommand("SELECT hash FROM xassetsdata WHERE hash=?hash", dbcon)) using (MySqlCommand cmd = new MySqlCommand("SELECT Hash FROM XAssetsData WHERE Hash=?Hash", dbcon))
{ {
cmd.Parameters.AddWithValue("?hash", hash); cmd.Parameters.AddWithValue("?Hash", hash);
try try
{ {
@ -395,9 +410,9 @@ namespace OpenSim.Data.MySQL
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
using (MySqlCommand cmd = new MySqlCommand("SELECT id FROM xassetsmeta WHERE id=?id", dbcon)) using (MySqlCommand cmd = new MySqlCommand("SELECT ID FROM XAssetsMeta WHERE ID=?ID", dbcon))
{ {
cmd.Parameters.AddWithValue("?id", uuid.ToString()); cmd.Parameters.AddWithValue("?ID", uuid.ToString());
try try
{ {
@ -412,8 +427,7 @@ namespace OpenSim.Data.MySQL
} }
catch (Exception e) catch (Exception e)
{ {
m_log.ErrorFormat( m_log.Error(string.Format("[XASSETS DB]: MySql failure fetching asset {0}", uuid), e);
"[XASSETS DB]: MySql failure fetching asset {0}" + Environment.NewLine + e.ToString(), uuid);
} }
} }
} }
@ -422,6 +436,7 @@ namespace OpenSim.Data.MySQL
return assetExists; return assetExists;
} }
/// <summary> /// <summary>
/// Returns a list of AssetMetadata objects. The list is a subset of /// Returns a list of AssetMetadata objects. The list is a subset of
/// the entire data set offset by <paramref name="start" /> containing /// the entire data set offset by <paramref name="start" /> containing
@ -439,7 +454,7 @@ namespace OpenSim.Data.MySQL
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))
{ {
dbcon.Open(); dbcon.Open();
MySqlCommand cmd = new MySqlCommand("SELECT name,description,asset_type,temporary,id,asset_flags,creator_id FROM xassetsmeta LIMIT ?start, ?count", dbcon); MySqlCommand cmd = new MySqlCommand("SELECT Name, Description, AccessTime, AssetType, Temporary, ID, AssetFlags, CreatorID FROM XAssetsMeta LIMIT ?start, ?count", dbcon);
cmd.Parameters.AddWithValue("?start", start); cmd.Parameters.AddWithValue("?start", start);
cmd.Parameters.AddWithValue("?count", count); cmd.Parameters.AddWithValue("?count", count);
@ -450,17 +465,19 @@ namespace OpenSim.Data.MySQL
while (dbReader.Read()) while (dbReader.Read())
{ {
AssetMetadata metadata = new AssetMetadata(); AssetMetadata metadata = new AssetMetadata();
metadata.Name = (string)dbReader["name"]; metadata.Name = (string)dbReader["Name"];
metadata.Description = (string)dbReader["description"]; metadata.Description = (string)dbReader["Description"];
metadata.Type = (sbyte)dbReader["asset_type"]; metadata.Type = (sbyte)dbReader["AssetType"];
metadata.Temporary = Convert.ToBoolean(dbReader["temporary"]); // Not sure if this is correct. metadata.Temporary = Convert.ToBoolean(dbReader["Temporary"]); // Not sure if this is correct.
metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["asset_flags"]); metadata.Flags = (AssetFlags)Convert.ToInt32(dbReader["AssetFlags"]);
metadata.FullID = DBGuid.FromDB(dbReader["id"]); metadata.FullID = DBGuid.FromDB(dbReader["ID"]);
metadata.CreatorID = dbReader["creator_id"].ToString(); metadata.CreatorID = dbReader["CreatorID"].ToString();
// We'll ignore this for now - it appears unused! // We'll ignore this for now - it appears unused!
// metadata.SHA1 = dbReader["hash"]); // metadata.SHA1 = dbReader["hash"]);
UpdateAccessTime(metadata, (int)dbReader["AccessTime"]);
retList.Add(metadata); retList.Add(metadata);
} }
} }
@ -485,9 +502,9 @@ namespace OpenSim.Data.MySQL
{ {
dbcon.Open(); dbcon.Open();
using (MySqlCommand cmd = new MySqlCommand("delete from xassetsmeta where id=?id", dbcon)) using (MySqlCommand cmd = new MySqlCommand("delete from XAssetsMeta where ID=?ID", dbcon))
{ {
cmd.Parameters.AddWithValue("?id", id); cmd.Parameters.AddWithValue("?ID", id);
cmd.ExecuteNonQuery(); cmd.ExecuteNonQuery();
} }

View File

@ -3,24 +3,24 @@
BEGIN; BEGIN;
CREATE TABLE `xassetsmeta` ( CREATE TABLE `XAssetsMeta` (
`id` char(36) NOT NULL, `ID` char(36) NOT NULL,
`hash` binary(32) NOT NULL, `Hash` binary(32) NOT NULL,
`name` varchar(64) NOT NULL, `Name` varchar(64) NOT NULL,
`description` varchar(64) NOT NULL, `Description` varchar(64) NOT NULL,
`asset_type` tinyint(4) NOT NULL, `AssetType` tinyint(4) NOT NULL,
`local` tinyint(1) NOT NULL, `Local` tinyint(1) NOT NULL,
`temporary` tinyint(1) NOT NULL, `Temporary` tinyint(1) NOT NULL,
`create_time` int(11) NOT NULL, `CreateTime` int(11) NOT NULL,
`access_time` int(11) NOT NULL, `AccessTime` int(11) NOT NULL,
`asset_flags` int(11) NOT NULL, `AssetFlags` int(11) NOT NULL,
`creator_id` varchar(128) NOT NULL, `CreatorID` varchar(128) NOT NULL,
PRIMARY KEY (`id`) PRIMARY KEY (`id`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1';
CREATE TABLE `xassetsdata` ( CREATE TABLE `XAssetsData` (
`hash` binary(32) NOT NULL, `Hash` binary(32) NOT NULL,
`data` longblob NOT NULL, `Data` longblob NOT NULL,
PRIMARY KEY (`hash`) PRIMARY KEY (`hash`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1'; ) ENGINE=InnoDB DEFAULT CHARSET=utf8 COMMENT='Version 1';

View File

@ -55,6 +55,13 @@ namespace OpenSim.Region.Framework.Interfaces
/// <returns>Land object at the point supplied</returns> /// <returns>Land object at the point supplied</returns>
ILandObject GetLandObject(float x, float y); ILandObject GetLandObject(float x, float y);
/// <summary>
/// Get the parcel at the specified point
/// </summary>
/// <param name="position">Vector where x and y components are between 0 and 256. z component is ignored.</param>
/// <returns>Land object at the point supplied</returns>
ILandObject GetLandObject(Vector3 position);
/// <summary> /// <summary>
/// Get the parcels near the specified point /// Get the parcels near the specified point
/// </summary> /// </summary>

View File

@ -189,4 +189,4 @@ namespace OpenSim.Framework.Servers
} }
} }
} }
} }

View File

@ -113,6 +113,26 @@ namespace OpenSim.Framework.Servers
} }
} }
/// <summary>
/// Log information about the circumstances in which we're running (OpenSimulator version number, CLR details,
/// etc.).
/// </summary>
public void LogEnvironmentInformation()
{
// FIXME: This should be done down in ServerBase but we need to sort out and refactor the log4net
// XmlConfigurator calls first accross servers.
m_log.InfoFormat("[SERVER BASE]: Starting in {0}", m_startupDirectory);
m_log.InfoFormat("[SERVER BASE]: OpenSimulator version: {0}", m_version);
// clr version potentially is more confusing than helpful, since it doesn't tell us if we're running under Mono/MS .NET and
// the clr version number doesn't match the project version number under Mono.
//m_log.Info("[STARTUP]: Virtual machine runtime version: " + Environment.Version + Environment.NewLine);
m_log.InfoFormat(
"[SERVER BASE]: Operating system version: {0}, .NET platform {1}, {2}-bit",
Environment.OSVersion, Environment.OSVersion.Platform, Util.Is64BitProcess() ? "64" : "32");
}
public void RegisterCommonAppenders(IConfig startupConfig) public void RegisterCommonAppenders(IConfig startupConfig)
{ {
ILoggerRepository repository = LogManager.GetRepository(); ILoggerRepository repository = LogManager.GetRepository();

View File

@ -159,6 +159,7 @@ namespace OpenSim
MainConsole.Instance = m_console; MainConsole.Instance = m_console;
LogEnvironmentInformation();
RegisterCommonAppenders(Config.Configs["Startup"]); RegisterCommonAppenders(Config.Configs["Startup"]);
RegisterConsoleCommands(); RegisterConsoleCommands();

View File

@ -138,10 +138,6 @@ namespace OpenSim
/// <param name="configSource"></param> /// <param name="configSource"></param>
public OpenSimBase(IConfigSource configSource) : base() public OpenSimBase(IConfigSource configSource) : base()
{ {
// FIXME: This should be done down in ServerBase but we need to sort out and refactor the log4net
// XmlConfigurator calls first accross servers.
m_log.InfoFormat("[SERVER BASE]: Starting in {0}", m_startupDirectory);
LoadConfigSettings(configSource); LoadConfigSettings(configSource);
} }

View File

@ -281,25 +281,12 @@ namespace OpenSim.Region.ClientStack.LindenUDP
m_shouldCollectStats = false; m_shouldCollectStats = false;
if (config != null) if (config != null)
{ {
if (config.Contains("enabled") && config.GetBoolean("enabled")) m_shouldCollectStats = config.GetBoolean("Enabled", false);
{ binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("packet_headers_period_seconds", 300));
if (config.Contains("collect_packet_headers")) binStatsDir = config.GetString("stats_dir", ".");
m_shouldCollectStats = config.GetBoolean("collect_packet_headers"); m_aggregatedBWStats = config.GetBoolean("aggregatedBWStats", false);
if (config.Contains("packet_headers_period_seconds")) }
{ #endregion BinaryStats
binStatsMaxFilesize = TimeSpan.FromSeconds(config.GetInt("region_stats_period_seconds"));
}
if (config.Contains("stats_dir"))
{
binStatsDir = config.GetString("stats_dir");
}
}
else
{
m_shouldCollectStats = false;
}
}
#endregion BinaryStats
m_throttle = new TokenBucket(null, sceneThrottleBps); m_throttle = new TokenBucket(null, sceneThrottleBps);
ThrottleRates = new ThrottleRates(configSource); ThrottleRates = new ThrottleRates(configSource);
@ -1309,8 +1296,34 @@ namespace OpenSim.Region.ClientStack.LindenUDP
static object binStatsLogLock = new object(); static object binStatsLogLock = new object();
static string binStatsDir = ""; static string binStatsDir = "";
//for Aggregated In/Out BW logging
static bool m_aggregatedBWStats = false;
static long m_aggregatedBytesIn = 0;
static long m_aggregatedByestOut = 0;
static object aggBWStatsLock = new object();
public static long AggregatedLLUDPBytesIn
{
get { return m_aggregatedBytesIn; }
}
public static long AggregatedLLUDPBytesOut
{
get {return m_aggregatedByestOut;}
}
public static void LogPacketHeader(bool incoming, uint circuit, byte flags, PacketType packetType, ushort size) public static void LogPacketHeader(bool incoming, uint circuit, byte flags, PacketType packetType, ushort size)
{ {
if (m_aggregatedBWStats)
{
lock (aggBWStatsLock)
{
if (incoming)
m_aggregatedBytesIn += size;
else
m_aggregatedByestOut += size;
}
}
if (!m_shouldCollectStats) return; if (!m_shouldCollectStats) return;
// Binary logging format is TTTTTTTTCCCCFPPPSS, T=Time, C=Circuit, F=Flags, P=PacketType, S=size // Binary logging format is TTTTTTTTCCCCFPPPSS, T=Time, C=Circuit, F=Flags, P=PacketType, S=size

View File

@ -39,7 +39,7 @@ using OpenSim.Region.Framework;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule
{ {
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DAExampleModule")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DAExampleModule")]
public class DAExampleModule : INonSharedRegionModule public class DAExampleModule : INonSharedRegionModule
@ -48,6 +48,8 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
private static readonly bool ENABLED = false; // enable for testing private static readonly bool ENABLED = false; // enable for testing
public const string DANamespace = "DAExample Module";
protected Scene m_scene; protected Scene m_scene;
protected IDialogModule m_dialogMod; protected IDialogModule m_dialogMod;
@ -89,7 +91,7 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
if (sop == null) if (sop == null)
return true; return true;
if (!sop.DynAttrs.TryGetValue(Name, out attrs)) if (!sop.DynAttrs.TryGetValue(DANamespace, out attrs))
attrs = new OSDMap(); attrs = new OSDMap();
OSDInteger newValue; OSDInteger newValue;
@ -104,8 +106,10 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DAExampleModule
attrs["moves"] = newValue; attrs["moves"] = newValue;
sop.DynAttrs[Name] = attrs; sop.DynAttrs[DANamespace] = attrs;
} }
sop.ParentGroup.HasGroupChanged = true;
m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue)); m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue));

View File

@ -36,6 +36,7 @@ using OpenMetaverse.Packets;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Region.Framework; using OpenSim.Region.Framework;
using OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule;
using OpenSim.Region.Framework.Interfaces; using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes; using OpenSim.Region.Framework.Scenes;
@ -50,9 +51,14 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule
public class MyObject public class MyObject
{ {
public int Moves { get; set; } public int Moves { get; set; }
public MyObject(int moves)
{
Moves = moves;
}
} }
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly bool ENABLED = false; // enable for testing private static readonly bool ENABLED = false; // enable for testing
@ -92,7 +98,23 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule
private void OnObjectAddedToScene(SceneObjectGroup so) private void OnObjectAddedToScene(SceneObjectGroup so)
{ {
so.RootPart.DynObjs.Add(Name, new MyObject()); SceneObjectPart rootPart = so.RootPart;
OSDMap attrs;
int movesSoFar = 0;
// Console.WriteLine("Here for {0}", so.Name);
if (rootPart.DynAttrs.TryGetValue(DAExampleModule.DANamespace, out attrs))
{
movesSoFar = attrs["moves"].AsInteger();
m_log.DebugFormat(
"[DO EXAMPLE MODULE]: Found saved moves {0} for {1} in {2}", movesSoFar, so.Name, m_scene.Name);
}
rootPart.DynObjs.Add(Name, new MyObject(movesSoFar));
} }
private bool OnSceneGroupMove(UUID groupId, Vector3 delta) private bool OnSceneGroupMove(UUID groupId, Vector3 delta)

View File

@ -95,6 +95,11 @@ namespace OpenSim.Region.CoreModules.World.Land
return null; return null;
} }
public ILandObject GetLandObject(Vector3 position)
{
return GetLandObject(position.X, position.Y);
}
public ILandObject GetLandObject(int x, int y) public ILandObject GetLandObject(int x, int y)
{ {
if (m_landManagementModule != null) if (m_landManagementModule != null)

View File

@ -140,9 +140,12 @@ public class ServerStats : ISharedRegionModule
} }
#endregion ISharedRegionModule #endregion ISharedRegionModule
private void MakeStat(string pName, string pUnit, string pContainer, Action<Stat> act) private void MakeStat(string pName, string pDesc, string pUnit, string pContainer, Action<Stat> act)
{ {
Stat stat = new Stat(pName, pName, "", pUnit, CategoryServer, pContainer, StatType.Pull, act, StatVerbosity.Info); string desc = pDesc;
if (desc == null)
desc = pName;
Stat stat = new Stat(pName, pName, desc, pUnit, CategoryServer, pContainer, StatType.Pull, act, StatVerbosity.Info);
StatsManager.RegisterStat(stat); StatsManager.RegisterStat(stat);
RegisteredStats.Add(pName, stat); RegisteredStats.Add(pName, stat);
} }
@ -166,16 +169,16 @@ public class ServerStats : ISharedRegionModule
StatsManager.RegisterStat(tempStat); StatsManager.RegisterStat(tempStat);
RegisteredStats.Add(tempName, tempStat); RegisteredStats.Add(tempName, tempStat);
MakeStat("TotalProcessorTime", "sec", ContainerProcessor, MakeStat("TotalProcessorTime", null, "sec", ContainerProcessor,
(s) => { s.Value = Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds; }); (s) => { s.Value = Process.GetCurrentProcess().TotalProcessorTime.TotalSeconds; });
MakeStat("UserProcessorTime", "sec", ContainerProcessor, MakeStat("UserProcessorTime", null, "sec", ContainerProcessor,
(s) => { s.Value = Process.GetCurrentProcess().UserProcessorTime.TotalSeconds; }); (s) => { s.Value = Process.GetCurrentProcess().UserProcessorTime.TotalSeconds; });
MakeStat("PrivilegedProcessorTime", "sec", ContainerProcessor, MakeStat("PrivilegedProcessorTime", null, "sec", ContainerProcessor,
(s) => { s.Value = Process.GetCurrentProcess().PrivilegedProcessorTime.TotalSeconds; }); (s) => { s.Value = Process.GetCurrentProcess().PrivilegedProcessorTime.TotalSeconds; });
MakeStat("Threads", "threads", ContainerProcessor, MakeStat("Threads", null, "threads", ContainerProcessor,
(s) => { s.Value = Process.GetCurrentProcess().Threads.Count; }); (s) => { s.Value = Process.GetCurrentProcess().Threads.Count; });
} }
catch (Exception e) catch (Exception e)
@ -196,8 +199,10 @@ public class ServerStats : ISharedRegionModule
string nicInterfaceType = nic.NetworkInterfaceType.ToString(); string nicInterfaceType = nic.NetworkInterfaceType.ToString();
if (!okInterfaceTypes.Contains(nicInterfaceType)) if (!okInterfaceTypes.Contains(nicInterfaceType))
{ {
m_log.DebugFormat("{0} Not including stats for network interface '{1}' of type '{2}'. To include, add to [Monitoring]NetworkInterfaceTypes='Ethernet,Loopback'", m_log.DebugFormat("{0} Not including stats for network interface '{1}' of type '{2}'.",
LogHeader, nic.Name, nicInterfaceType); LogHeader, nic.Name, nicInterfaceType);
m_log.DebugFormat("{0} To include, add to comma separated list in [Monitoring]NetworkInterfaceTypes={1}",
LogHeader, NetworkInterfaceTypes);
continue; continue;
} }
@ -206,14 +211,15 @@ public class ServerStats : ISharedRegionModule
IPv4InterfaceStatistics nicStats = nic.GetIPv4Statistics(); IPv4InterfaceStatistics nicStats = nic.GetIPv4Statistics();
if (nicStats != null) if (nicStats != null)
{ {
MakeStat("BytesRcvd/" + nic.Name, "KB", ContainerNetwork, MakeStat("BytesRcvd/" + nic.Name, nic.Name, "KB", ContainerNetwork,
(s) => { LookupNic(s, (ns) => { return ns.BytesReceived; }, 1024.0); }); (s) => { LookupNic(s, (ns) => { return ns.BytesReceived; }, 1024.0); });
MakeStat("BytesSent/" + nic.Name, "KB", ContainerNetwork, MakeStat("BytesSent/" + nic.Name, nic.Name, "KB", ContainerNetwork,
(s) => { LookupNic(s, (ns) => { return ns.BytesSent; }, 1024.0); }); (s) => { LookupNic(s, (ns) => { return ns.BytesSent; }, 1024.0); });
MakeStat("TotalBytes/" + nic.Name, "KB", ContainerNetwork, MakeStat("TotalBytes/" + nic.Name, nic.Name, "KB", ContainerNetwork,
(s) => { LookupNic(s, (ns) => { return ns.BytesSent + ns.BytesReceived; }, 1024.0); }); (s) => { LookupNic(s, (ns) => { return ns.BytesSent + ns.BytesReceived; }, 1024.0); });
} }
} }
// TODO: add IPv6 (it may actually happen someday)
} }
} }
catch (Exception e) catch (Exception e)
@ -221,13 +227,13 @@ public class ServerStats : ISharedRegionModule
m_log.ErrorFormat("{0} Exception creating 'Network Interface': {1}", LogHeader, e); m_log.ErrorFormat("{0} Exception creating 'Network Interface': {1}", LogHeader, e);
} }
MakeStat("ProcessMemory", "MB", ContainerMemory, MakeStat("ProcessMemory", null, "MB", ContainerMemory,
(s) => { s.Value = Process.GetCurrentProcess().WorkingSet64 / 1024d / 1024d; }); (s) => { s.Value = Process.GetCurrentProcess().WorkingSet64 / 1024d / 1024d; });
MakeStat("ObjectMemory", "MB", ContainerMemory, MakeStat("ObjectMemory", null, "MB", ContainerMemory,
(s) => { s.Value = GC.GetTotalMemory(false) / 1024d / 1024d; }); (s) => { s.Value = GC.GetTotalMemory(false) / 1024d / 1024d; });
MakeStat("LastMemoryChurn", "MB/sec", ContainerMemory, MakeStat("LastMemoryChurn", null, "MB/sec", ContainerMemory,
(s) => { s.Value = Math.Round(MemoryWatchdog.LastMemoryChurn * 1000d / 1024d / 1024d, 3); }); (s) => { s.Value = Math.Round(MemoryWatchdog.LastMemoryChurn * 1000d / 1024d / 1024d, 3); });
MakeStat("AverageMemoryChurn", "MB/sec", ContainerMemory, MakeStat("AverageMemoryChurn", null, "MB/sec", ContainerMemory,
(s) => { s.Value = Math.Round(MemoryWatchdog.AverageMemoryChurn * 1000d / 1024d / 1024d, 3); }); (s) => { s.Value = Math.Round(MemoryWatchdog.AverageMemoryChurn * 1000d / 1024d / 1024d, 3); });
} }
@ -263,6 +269,8 @@ public class ServerStats : ISharedRegionModule
} }
} }
// Lookup the nic that goes with this stat and set the value by using a fetch action.
// Not sure about closure with delegates inside delegates.
private delegate double GetIPv4StatValue(IPv4InterfaceStatistics interfaceStat); private delegate double GetIPv4StatValue(IPv4InterfaceStatistics interfaceStat);
private void LookupNic(Stat stat, GetIPv4StatValue getter, double factor) private void LookupNic(Stat stat, GetIPv4StatValue getter, double factor)
{ {
@ -275,7 +283,10 @@ public class ServerStats : ISharedRegionModule
{ {
IPv4InterfaceStatistics intrStats = nic.GetIPv4Statistics(); IPv4InterfaceStatistics intrStats = nic.GetIPv4Statistics();
if (intrStats != null) if (intrStats != null)
stat.Value = Math.Round(getter(intrStats) / factor, 3); {
double newVal = Math.Round(getter(intrStats) / factor, 3);
stat.Value = newVal;
}
break; break;
} }
} }

View File

@ -1335,7 +1335,7 @@ namespace OpenSim.Region.Physics.BulletSPlugin
Vector3 unscaledContribVerticalErrorV = vertContributionV; // DEBUG DEBUG Vector3 unscaledContribVerticalErrorV = vertContributionV; // DEBUG DEBUG
vertContributionV /= m_verticalAttractionTimescale; vertContributionV /= m_verticalAttractionTimescale;
VehicleRotationalVelocity += vertContributionV * VehicleOrientation; VehicleRotationalVelocity += vertContributionV;
VDetailLog("{0}, MoveAngular,verticalAttraction,,origRotVW={1},vertError={2},unscaledV={3},eff={4},ts={5},vertContribV={6}", VDetailLog("{0}, MoveAngular,verticalAttraction,,origRotVW={1},vertError={2},unscaledV={3},eff={4},ts={5},vertContribV={6}",
Prim.LocalID, origRotVelW, verticalError, unscaledContribVerticalErrorV, Prim.LocalID, origRotVelW, verticalError, unscaledContribVerticalErrorV,

View File

@ -68,6 +68,11 @@ public class RegionCombinerLargeLandChannel : ILandChannel
RootRegionLandChannel.Clear(setupDefaultParcel); RootRegionLandChannel.Clear(setupDefaultParcel);
} }
public ILandObject GetLandObject(Vector3 position)
{
return GetLandObject(position.X, position.Y);
}
public ILandObject GetLandObject(int x, int y) public ILandObject GetLandObject(int x, int y)
{ {
//m_log.DebugFormat("[BIGLANDTESTINT]: <{0},{1}>", x, y); //m_log.DebugFormat("[BIGLANDTESTINT]: <{0},{1}>", x, y);

View File

@ -371,6 +371,80 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
/// <summary>
/// Get a given link entity from a linkset (linked objects and any sitting avatars).
/// </summary>
/// <remarks>
/// If there are any ScenePresence's in the linkset (i.e. because they are sat upon one of the prims), then
/// these are counted as extra entities that correspond to linknums beyond the number of prims in the linkset.
/// The ScenePresences receive linknums in the order in which they sat.
/// </remarks>
/// <returns>
/// The link entity. null if not found.
/// </returns>
/// <param name='linknum'>
/// Can be either a non-negative integer or ScriptBaseClass.LINK_THIS (-4).
/// If ScriptBaseClass.LINK_THIS then the entity containing the script is returned.
/// If the linkset has one entity and a linknum of zero is given, then the single entity is returned. If any
/// positive integer is given in this case then null is returned.
/// If the linkset has more than one entity and a linknum greater than zero but equal to or less than the number
/// of entities, then the entity which corresponds to that linknum is returned.
/// Otherwise, if a positive linknum is given which is greater than the number of entities in the linkset, then
/// null is returned.
/// </param>
public ISceneEntity GetLinkEntity(int linknum)
{
if (linknum < 0)
{
if (linknum == ScriptBaseClass.LINK_THIS)
return m_host;
else
return null;
}
int actualPrimCount = m_host.ParentGroup.PrimCount;
List<UUID> sittingAvatarIds = m_host.ParentGroup.GetSittingAvatars();
int adjustedPrimCount = actualPrimCount + sittingAvatarIds.Count;
// Special case for a single prim. In this case the linknum is zero. However, this will not match a single
// prim that has any avatars sat upon it (in which case the root prim is link 1).
if (linknum == 0)
{
if (actualPrimCount == 1 && sittingAvatarIds.Count == 0)
return m_host;
return null;
}
// Special case to handle a single prim with sitting avatars. GetLinkPart() would only match zero but
// here we must match 1 (ScriptBaseClass.LINK_ROOT).
else if (linknum == ScriptBaseClass.LINK_ROOT && actualPrimCount == 1)
{
if (sittingAvatarIds.Count > 0)
return m_host.ParentGroup.RootPart;
else
return null;
}
else if (linknum <= adjustedPrimCount)
{
if (linknum <= actualPrimCount)
{
return m_host.ParentGroup.GetLinkNumPart(linknum);
}
else
{
ScenePresence sp = World.GetScenePresence(sittingAvatarIds[linknum - actualPrimCount - 1]);
if (sp != null)
return sp;
else
return null;
}
}
else
{
return null;
}
}
public List<SceneObjectPart> GetLinkParts(int linkType) public List<SceneObjectPart> GetLinkParts(int linkType)
{ {
return GetLinkParts(m_host, linkType); return GetLinkParts(m_host, linkType);
@ -4149,55 +4223,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
if (linknum < 0) ISceneEntity entity = GetLinkEntity(linknum);
{
if (linknum == ScriptBaseClass.LINK_THIS)
return m_host.Name;
else
return ScriptBaseClass.NULL_KEY;
}
int actualPrimCount = m_host.ParentGroup.PrimCount; if (entity != null)
List<UUID> sittingAvatarIds = m_host.ParentGroup.GetSittingAvatars(); return entity.Name;
int adjustedPrimCount = actualPrimCount + sittingAvatarIds.Count;
// Special case for a single prim. In this case the linknum is zero. However, this will not match a single
// prim that has any avatars sat upon it (in which case the root prim is link 1).
if (linknum == 0)
{
if (actualPrimCount == 1 && sittingAvatarIds.Count == 0)
return m_host.Name;
return ScriptBaseClass.NULL_KEY;
}
// Special case to handle a single prim with sitting avatars. GetLinkPart() would only match zero but
// here we must match 1 (ScriptBaseClass.LINK_ROOT).
else if (linknum == 1 && actualPrimCount == 1)
{
if (sittingAvatarIds.Count > 0)
return m_host.ParentGroup.RootPart.Name;
else
return ScriptBaseClass.NULL_KEY;
}
else if (linknum <= adjustedPrimCount)
{
if (linknum <= actualPrimCount)
{
return m_host.ParentGroup.GetLinkNumPart(linknum).Name;
}
else
{
ScenePresence sp = World.GetScenePresence(sittingAvatarIds[linknum - actualPrimCount - 1]);
if (sp != null)
return sp.Name;
else
return ScriptBaseClass.NULL_KEY;
}
}
else else
{
return ScriptBaseClass.NULL_KEY; return ScriptBaseClass.NULL_KEY;
}
} }
public LSL_Integer llGetInventoryNumber(int type) public LSL_Integer llGetInventoryNumber(int type)
@ -4562,8 +4593,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (presence.UserLevel >= 200) return; if (presence.UserLevel >= 200) return;
// agent must be over the owners land // agent must be over the owners land
if (m_host.OwnerID == World.LandChannel.GetLandObject( if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID)
presence.AbsolutePosition.X, presence.AbsolutePosition.Y).LandData.OwnerID)
{ {
if (!World.TeleportClientHome(agentId, presence.ControllingClient)) if (!World.TeleportClientHome(agentId, presence.ControllingClient))
{ {
@ -4579,6 +4609,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
} }
} }
ScriptSleep(5000); ScriptSleep(5000);
} }
@ -4598,10 +4629,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (destination == String.Empty) if (destination == String.Empty)
destination = World.RegionInfo.RegionName; destination = World.RegionInfo.RegionName;
Vector3 pos = presence.AbsolutePosition;
// agent must be over the owners land // agent must be over the owners land
if (m_host.OwnerID == World.LandChannel.GetLandObject(pos.X, pos.Y).LandData.OwnerID) if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID)
{ {
DoLLTeleport(presence, destination, targetPos, targetLookAt); DoLLTeleport(presence, destination, targetPos, targetLookAt);
} }
@ -4631,10 +4660,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// agent must not be a god // agent must not be a god
if (presence.GodLevel >= 200) return; if (presence.GodLevel >= 200) return;
Vector3 pos = presence.AbsolutePosition;
// agent must be over the owners land // agent must be over the owners land
if (m_host.OwnerID == World.LandChannel.GetLandObject(pos.X, pos.Y).LandData.OwnerID) if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID)
{ {
World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation); World.RequestTeleportLocation(presence.ControllingClient, regionHandle, targetPos, targetLookAt, (uint)TeleportFlags.ViaLocation);
} }
@ -4849,7 +4876,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if (pushrestricted) if (pushrestricted)
{ {
ILandObject targetlandObj = World.LandChannel.GetLandObject(PusheePos.X, PusheePos.Y); ILandObject targetlandObj = World.LandChannel.GetLandObject(PusheePos);
// We didn't find the parcel but region is push restricted so assume it is NOT ok // We didn't find the parcel but region is push restricted so assume it is NOT ok
if (targetlandObj == null) if (targetlandObj == null)
@ -4864,7 +4891,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
else else
{ {
ILandObject targetlandObj = World.LandChannel.GetLandObject(PusheePos.X, PusheePos.Y); ILandObject targetlandObj = World.LandChannel.GetLandObject(PusheePos);
if (targetlandObj == null) if (targetlandObj == null)
{ {
// We didn't find the parcel but region isn't push restricted so assume it's ok // We didn't find the parcel but region isn't push restricted so assume it's ok
@ -6146,12 +6173,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
} }
ILandObject land; ILandObject land;
Vector3 pos;
UUID id = UUID.Zero; UUID id = UUID.Zero;
if (parcel || parcelOwned) if (parcel || parcelOwned)
{ {
pos = m_host.ParentGroup.RootPart.GetWorldPosition(); land = World.LandChannel.GetLandObject(m_host.ParentGroup.RootPart.GetWorldPosition());
land = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (land == null) if (land == null)
{ {
id = UUID.Zero; id = UUID.Zero;
@ -6177,8 +6203,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
if (!regionWide) if (!regionWide)
{ {
pos = ssp.AbsolutePosition; land = World.LandChannel.GetLandObject(ssp.AbsolutePosition);
land = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (land != null) if (land != null)
{ {
if (parcelOwned && land.LandData.OwnerID == id || if (parcelOwned && land.LandData.OwnerID == id ||
@ -6308,10 +6333,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence presence = World.GetScenePresence(agentID); ScenePresence presence = World.GetScenePresence(agentID);
if (presence != null) if (presence != null)
{ {
Vector3 pos = presence.AbsolutePosition;
// agent must be over the owners land // agent must be over the owners land
ILandObject land = World.LandChannel.GetLandObject(pos.X, pos.Y); ILandObject land = World.LandChannel.GetLandObject(presence.AbsolutePosition);
if (land == null) if (land == null)
return; return;
@ -6340,9 +6363,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence presence = World.GetScenePresence(key); ScenePresence presence = World.GetScenePresence(key);
if (presence != null) // object is an avatar if (presence != null) // object is an avatar
{ {
Vector3 pos = presence.AbsolutePosition; if (m_host.OwnerID == World.LandChannel.GetLandObject(presence.AbsolutePosition).LandData.OwnerID)
if (m_host.OwnerID == World.LandChannel.GetLandObject(pos.X, pos.Y).LandData.OwnerID)
return 1; return 1;
} }
else // object is not an avatar else // object is not an avatar
@ -6351,9 +6372,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (obj != null) if (obj != null)
{ {
Vector3 pos = obj.AbsolutePosition; if (m_host.OwnerID == World.LandChannel.GetLandObject(obj.AbsolutePosition).LandData.OwnerID)
if (m_host.OwnerID == World.LandChannel.GetLandObject(pos.X, pos.Y).LandData.OwnerID)
return 1; return 1;
} }
} }
@ -6463,10 +6482,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// if the land is group owned and the object is group owned by the same group // if the land is group owned and the object is group owned by the same group
// or // or
// if the object is owned by a person with estate access. // if the object is owned by a person with estate access.
ILandObject parcel = World.LandChannel.GetLandObject(av.AbsolutePosition);
Vector3 pos = av.AbsolutePosition;
ILandObject parcel = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (parcel != null) if (parcel != null)
{ {
if (m_host.OwnerID == parcel.LandData.OwnerID || if (m_host.OwnerID == parcel.LandData.OwnerID ||
@ -7053,9 +7069,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID key; UUID key;
Vector3 pos = m_host.AbsolutePosition; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
ILandObject land = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned))
{ {
int expires = 0; int expires = 0;
@ -8492,8 +8507,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Vector3 pos = m_host.AbsolutePosition; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
ILandObject land = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (land.LandData.OwnerID != m_host.OwnerID) if (land.LandData.OwnerID != m_host.OwnerID)
return; return;
@ -8507,8 +8521,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
Vector3 pos = m_host.AbsolutePosition; ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
ILandObject land = World.LandChannel.GetLandObject(pos.X, pos.Y);
if (land.LandData.OwnerID != m_host.OwnerID) if (land.LandData.OwnerID != m_host.OwnerID)
return String.Empty; return String.Empty;
@ -8717,8 +8730,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public LSL_Vector llGetGeometricCenter() public LSL_Vector llGetGeometricCenter()
{ {
Vector3 tmp = m_host.GetGeometricCenter(); return new LSL_Vector(m_host.GetGeometricCenter());
return new LSL_Vector(tmp.X, tmp.Y, tmp.Z);
} }
public LSL_List llGetPrimitiveParams(LSL_List rules) public LSL_List llGetPrimitiveParams(LSL_List rules)
@ -8825,9 +8837,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break; break;
case (int)ScriptBaseClass.PRIM_SIZE: case (int)ScriptBaseClass.PRIM_SIZE:
res.Add(new LSL_Vector(part.Scale.X, res.Add(new LSL_Vector(part.Scale));
part.Scale.Y,
part.Scale.Z));
break; break;
case (int)ScriptBaseClass.PRIM_ROTATION: case (int)ScriptBaseClass.PRIM_ROTATION:
@ -9188,9 +9198,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
case (int)ScriptBaseClass.PRIM_DESC: case (int)ScriptBaseClass.PRIM_DESC:
res.Add(new LSL_String(part.Description)); res.Add(new LSL_String(part.Description));
break; break;
case (int)ScriptBaseClass.PRIM_ROT_LOCAL:
case (int)ScriptBaseClass.PRIM_ROT_LOCAL: res.Add(new LSL_Rotation(part.RotationOffset));
res.Add(new LSL_Rotation(part.RotationOffset.X, part.RotationOffset.Y, part.RotationOffset.Z, part.RotationOffset.W));
break; break;
case (int)ScriptBaseClass.PRIM_POS_LOCAL: case (int)ScriptBaseClass.PRIM_POS_LOCAL:
@ -10374,7 +10383,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// according to the docs, this command only works if script owner and land owner are the same // according to the docs, this command only works if script owner and land owner are the same
// lets add estate owners and gods, too, and use the generic permission check. // lets add estate owners and gods, too, and use the generic permission check.
ILandObject landObject = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); ILandObject landObject = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, landObject, GroupPowers.ChangeMedia)) return; if (!World.Permissions.CanEditParcelProperties(m_host.OwnerID, landObject, GroupPowers.ChangeMedia)) return;
bool update = false; // send a ParcelMediaUpdate (and possibly change the land's media URL)? bool update = false; // send a ParcelMediaUpdate (and possibly change the land's media URL)?
@ -10697,22 +10706,23 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
if (m_item.PermsGranter == UUID.Zero) if (m_item.PermsGranter == UUID.Zero)
return new LSL_Vector(); return Vector3.Zero;
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
{ {
ShoutError("No permissions to track the camera"); ShoutError("No permissions to track the camera");
return new LSL_Vector(); return Vector3.Zero;
} }
// ScenePresence presence = World.GetScenePresence(m_host.OwnerID); // ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
if (presence != null) if (presence != null)
{ {
LSL_Vector pos = new LSL_Vector(presence.CameraPosition.X, presence.CameraPosition.Y, presence.CameraPosition.Z); LSL_Vector pos = new LSL_Vector(presence.CameraPosition);
return pos; return pos;
} }
return new LSL_Vector();
return Vector3.Zero;
} }
public LSL_Rotation llGetCameraRot() public LSL_Rotation llGetCameraRot()
@ -10720,22 +10730,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
if (m_item.PermsGranter == UUID.Zero) if (m_item.PermsGranter == UUID.Zero)
return new LSL_Rotation(); return Quaternion.Identity;
if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0) if ((m_item.PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
{ {
ShoutError("No permissions to track the camera"); ShoutError("No permissions to track the camera");
return new LSL_Rotation(); return Quaternion.Identity;
} }
// ScenePresence presence = World.GetScenePresence(m_host.OwnerID); // ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
ScenePresence presence = World.GetScenePresence(m_item.PermsGranter); ScenePresence presence = World.GetScenePresence(m_item.PermsGranter);
if (presence != null) if (presence != null)
{ {
return new LSL_Rotation(presence.CameraRotation.X, presence.CameraRotation.Y, presence.CameraRotation.Z, presence.CameraRotation.W); return new LSL_Rotation(presence.CameraRotation);
} }
return new LSL_Rotation(); return Quaternion.Identity;
} }
/// <summary> /// <summary>
@ -10816,7 +10826,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID key; UUID key;
ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned))
{ {
int expires = 0; int expires = 0;
@ -10857,7 +10867,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID key; UUID key;
ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageAllowed)) if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageAllowed))
{ {
if (UUID.TryParse(avatar, out key)) if (UUID.TryParse(avatar, out key))
@ -10884,7 +10894,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
UUID key; UUID key;
ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned)) if (World.Permissions.CanEditParcelProperties(m_host.OwnerID, land, GroupPowers.LandManageBanned))
{ {
if (UUID.TryParse(avatar, out key)) if (UUID.TryParse(avatar, out key))
@ -11250,7 +11260,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llResetLandBanList() public void llResetLandBanList()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData; LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition).LandData;
if (land.OwnerID == m_host.OwnerID) if (land.OwnerID == m_host.OwnerID)
{ {
foreach (LandAccessEntry entry in land.ParcelAccessList) foreach (LandAccessEntry entry in land.ParcelAccessList)
@ -11267,7 +11277,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
public void llResetLandPassList() public void llResetLandPassList()
{ {
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y).LandData; LandData land = World.LandChannel.GetLandObject(m_host.AbsolutePosition).LandData;
if (land.OwnerID == m_host.OwnerID) if (land.OwnerID == m_host.OwnerID)
{ {
foreach (LandAccessEntry entry in land.ParcelAccessList) foreach (LandAccessEntry entry in land.ParcelAccessList)
@ -11967,7 +11977,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
World.ForEachScenePresence(delegate(ScenePresence sp) World.ForEachScenePresence(delegate(ScenePresence sp)
{ {
Vector3 ac = sp.AbsolutePosition - rayStart; Vector3 ac = sp.AbsolutePosition - rayStart;
Vector3 bc = sp.AbsolutePosition - rayEnd; // Vector3 bc = sp.AbsolutePosition - rayEnd;
double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd)); double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd));
@ -12057,7 +12067,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
radius = Math.Abs(maxZ); radius = Math.Abs(maxZ);
radius = radius*1.413f; radius = radius*1.413f;
Vector3 ac = group.AbsolutePosition - rayStart; Vector3 ac = group.AbsolutePosition - rayStart;
Vector3 bc = group.AbsolutePosition - rayEnd; // Vector3 bc = group.AbsolutePosition - rayEnd;
double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd)); double d = Math.Abs(Vector3.Mag(Vector3.Cross(ab, ac)) / Vector3.Distance(rayStart, rayEnd));
@ -12435,7 +12445,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
list.Add(new LSL_Integer(linkNum)); list.Add(new LSL_Integer(linkNum));
if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL) if ((dataFlags & ScriptBaseClass.RC_GET_NORMAL) == ScriptBaseClass.RC_GET_NORMAL)
list.Add(new LSL_Vector(result.Normal.X, result.Normal.Y, result.Normal.Z)); list.Add(new LSL_Vector(result.Normal));
values++; values++;
if (values >= count) if (values >= count)

View File

@ -372,7 +372,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//OSSL only may be used if object is in the same group as the parcel //OSSL only may be used if object is in the same group as the parcel
if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER")) if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_GROUP_MEMBER"))
{ {
ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero) if (land.LandData.GroupID == m_item.GroupID && land.LandData.GroupID != UUID.Zero)
{ {
@ -383,7 +383,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//Only Parcelowners may use the function //Only Parcelowners may use the function
if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_OWNER")) if (m_FunctionPerms[function].AllowedOwnerClasses.Contains("PARCEL_OWNER"))
{ {
ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y); ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
if (land.LandData.OwnerID == ownerID) if (land.LandData.OwnerID == ownerID)
{ {
@ -1511,8 +1511,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
ILandObject land ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
= World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
if (land.LandData.OwnerID != m_host.OwnerID) if (land.LandData.OwnerID != m_host.OwnerID)
return; return;
@ -1528,8 +1527,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1); m_host.AddScriptLPS(1);
ILandObject land ILandObject land = World.LandChannel.GetLandObject(m_host.AbsolutePosition);
= World.LandChannel.GetLandObject(m_host.AbsolutePosition.X, m_host.AbsolutePosition.Y);
if (land.LandData.OwnerID != m_host.OwnerID) if (land.LandData.OwnerID != m_host.OwnerID)
{ {
@ -2578,13 +2576,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScenePresence sp = World.GetScenePresence(npcId); ScenePresence sp = World.GetScenePresence(npcId);
if (sp != null) if (sp != null)
{ return new LSL_Vector(sp.AbsolutePosition);
Vector3 pos = sp.AbsolutePosition;
return new LSL_Vector(pos.X, pos.Y, pos.Z);
}
} }
return new LSL_Vector(0, 0, 0); return Vector3.Zero;
} }
public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos) public void osNpcMoveTo(LSL_Key npc, LSL_Vector pos)
@ -2652,7 +2647,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return new LSL_Rotation(sp.GetWorldRotation()); return new LSL_Rotation(sp.GetWorldRotation());
} }
return new LSL_Rotation(Quaternion.Identity.X, Quaternion.Identity.Y, Quaternion.Identity.Z, Quaternion.Identity.W); return Quaternion.Identity;
} }
public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation) public void osNpcSetRot(LSL_Key npc, LSL_Rotation rotation)
@ -3098,20 +3093,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID avatarId = new UUID(avatar); UUID avatarId = new UUID(avatar);
ScenePresence presence = World.GetScenePresence(avatarId); ScenePresence presence = World.GetScenePresence(avatarId);
Vector3 pos = m_host.GetWorldPosition();
bool result = World.ScriptDanger(m_host.LocalId, new Vector3((float)pos.X, (float)pos.Y, (float)pos.Z)); if (presence != null && World.ScriptDanger(m_host.LocalId, m_host.GetWorldPosition()))
if (result)
{ {
if (presence != null) float health = presence.Health;
{ health += (float)healing;
float health = presence.Health;
health += (float)healing; if (health >= 100)
if (health >= 100) health = 100;
{
health = 100; presence.setHealthWithUpdate(health);
}
presence.setHealthWithUpdate(health);
}
} }
} }
@ -3188,8 +3179,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (avatar != null && avatar.UUID != m_host.OwnerID) if (avatar != null && avatar.UUID != m_host.OwnerID)
{ {
result.Add(new LSL_String(avatar.UUID.ToString())); result.Add(new LSL_String(avatar.UUID.ToString()));
OpenMetaverse.Vector3 ap = avatar.AbsolutePosition; result.Add(new LSL_Vector(avatar.AbsolutePosition));
result.Add(new LSL_Vector(ap.X, ap.Y, ap.Z));
result.Add(new LSL_String(avatar.Name)); result.Add(new LSL_String(avatar.Name));
} }
}); });

View File

@ -138,17 +138,17 @@ namespace OpenSim.Server.Base
case ExtensionChange.Add: case ExtensionChange.Add:
if (a.AddinFile.Contains(Registry.DefaultAddinsFolder)) if (a.AddinFile.Contains(Registry.DefaultAddinsFolder))
{ {
m_log.InfoFormat("[SERVER]: Adding {0} from registry", a.Name); m_log.InfoFormat("[SERVER UTILS]: Adding {0} from registry", a.Name);
connector.PluginPath = System.IO.Path.Combine(Registry.DefaultAddinsFolder,a.Name.Replace(',', '.')); } connector.PluginPath = System.IO.Path.Combine(Registry.DefaultAddinsFolder,a.Name.Replace(',', '.')); }
else else
{ {
m_log.InfoFormat("[SERVER]: Adding {0} from ./bin", a.Name); m_log.InfoFormat("[SERVER UTILS]: Adding {0} from ./bin", a.Name);
connector.PluginPath = a.AddinFile; connector.PluginPath = a.AddinFile;
} }
LoadPlugin(connector); LoadPlugin(connector);
break; break;
case ExtensionChange.Remove: case ExtensionChange.Remove:
m_log.InfoFormat("[SERVER]: Removing {0}", a.Name); m_log.InfoFormat("[SERVER UTILS]: Removing {0}", a.Name);
UnloadPlugin(connector); UnloadPlugin(connector);
break; break;
} }
@ -166,13 +166,13 @@ namespace OpenSim.Server.Base
} }
else else
{ {
m_log.InfoFormat("[SERVER]: {0} Disabled.", connector.ConfigName); m_log.InfoFormat("[SERVER UTILS]: {0} Disabled.", connector.ConfigName);
} }
} }
private void UnloadPlugin(IRobustConnector connector) private void UnloadPlugin(IRobustConnector connector)
{ {
m_log.InfoFormat("[Server]: Unloading {0}", connector.ConfigName); m_log.InfoFormat("[SERVER UTILS]: Unloading {0}", connector.ConfigName);
connector.Unload(); connector.Unload();
} }
@ -280,7 +280,7 @@ namespace OpenSim.Server.Base
{ {
if (!(e is System.MissingMethodException)) if (!(e is System.MissingMethodException))
{ {
m_log.ErrorFormat("Error loading plugin {0} from {1}. Exception: {2}, {3}", m_log.ErrorFormat("[SERVER UTILS]: Error loading plugin {0} from {1}. Exception: {2}, {3}",
interfaceName, interfaceName,
dllName, dllName,
e.InnerException == null ? e.Message : e.InnerException.Message, e.InnerException == null ? e.Message : e.InnerException.Message,
@ -298,14 +298,14 @@ namespace OpenSim.Server.Base
} }
catch (ReflectionTypeLoadException rtle) catch (ReflectionTypeLoadException rtle)
{ {
m_log.Error(string.Format("Error loading plugin from {0}:\n{1}", dllName, m_log.Error(string.Format("[SERVER UTILS]: Error loading plugin from {0}:\n{1}", dllName,
String.Join("\n", Array.ConvertAll(rtle.LoaderExceptions, e => e.ToString()))), String.Join("\n", Array.ConvertAll(rtle.LoaderExceptions, e => e.ToString()))),
rtle); rtle);
return null; return null;
} }
catch (Exception e) catch (Exception e)
{ {
m_log.Error(string.Format("Error loading plugin from {0}", dllName), e); m_log.Error(string.Format("[SERVER UTILS]: Error loading plugin from {0}", dllName), e);
return null; return null;
} }
} }
@ -517,7 +517,7 @@ namespace OpenSim.Server.Base
public static IConfigSource LoadInitialConfig(string url) public static IConfigSource LoadInitialConfig(string url)
{ {
IConfigSource source = new XmlConfigSource(); IConfigSource source = new XmlConfigSource();
m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", url); m_log.InfoFormat("[SERVER UTILS]: {0} is a http:// URI, fetching ...", url);
// The ini file path is a http URI // The ini file path is a http URI
// Try to read it // Try to read it
@ -529,7 +529,7 @@ namespace OpenSim.Server.Base
} }
catch (Exception e) catch (Exception e)
{ {
m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), url); m_log.FatalFormat("[SERVER UTILS]: Exception reading config from URI {0}\n" + e.ToString(), url);
Environment.Exit(1); Environment.Exit(1);
} }

View File

@ -186,10 +186,7 @@ namespace OpenSim.Server.Base
XmlConfigurator.Configure(); XmlConfigurator.Configure();
} }
// FIXME: This should be done down in ServerBase but we need to sort out and refactor the log4net LogEnvironmentInformation();
// XmlConfigurator calls first accross servers.
m_log.InfoFormat("[SERVER BASE]: Starting in {0}", m_startupDirectory);
RegisterCommonAppenders(startupConfig); RegisterCommonAppenders(startupConfig);
if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty) if (startupConfig.GetString("PIDFile", String.Empty) != String.Empty)

View File

@ -145,7 +145,7 @@ namespace OpenSim.Server
} }
else else
{ {
m_log.InfoFormat("[SERVER]: Failed to load {0}", conn); m_log.ErrorFormat("[SERVER]: Failed to load {0}", conn);
} }
} }

View File

@ -123,46 +123,32 @@ namespace OpenSim.Services.AssetService
public virtual AssetMetadata GetMetadata(string id) public virtual AssetMetadata GetMetadata(string id)
{ {
// m_log.DebugFormat("[ASSET SERVICE]: Get asset metadata for {0}", id); // m_log.DebugFormat("[ASSET SERVICE]: Get asset metadata for {0}", id);
UUID assetID;
if (!UUID.TryParse(id, out assetID)) AssetBase asset = Get(id);
return null;
AssetBase asset = m_Database.GetAsset(assetID);
if (asset != null) if (asset != null)
return asset.Metadata; return asset.Metadata;
else
return null; return null;
} }
public virtual byte[] GetData(string id) public virtual byte[] GetData(string id)
{ {
// m_log.DebugFormat("[ASSET SERVICE]: Get asset data for {0}", id); // m_log.DebugFormat("[ASSET SERVICE]: Get asset data for {0}", id);
UUID assetID;
if (!UUID.TryParse(id, out assetID)) AssetBase asset = Get(id);
if (asset != null)
return asset.Data;
else
return null; return null;
AssetBase asset = m_Database.GetAsset(assetID);
return asset.Data;
} }
public virtual bool Get(string id, Object sender, AssetRetrieved handler) public virtual bool Get(string id, Object sender, AssetRetrieved handler)
{ {
//m_log.DebugFormat("[AssetService]: Get asset async {0}", id); //m_log.DebugFormat("[AssetService]: Get asset async {0}", id);
UUID assetID;
if (!UUID.TryParse(id, out assetID)) handler(id, sender, Get(id));
return false;
AssetBase asset = m_Database.GetAsset(assetID);
//m_log.DebugFormat("[AssetService]: Got asset {0}", asset);
handler(id, sender, asset);
return true; return true;
} }

View File

@ -39,8 +39,7 @@ using OpenMetaverse;
namespace OpenSim.Services.AssetService namespace OpenSim.Services.AssetService
{ {
/// <summary> /// <summary>
/// This will be developed into a de-duplicating asset service. /// A de-duplicating asset service.
/// XXX: Currently it's a just a copy of the existing AssetService. so please don't attempt to use it.
/// </summary> /// </summary>
public class XAssetService : XAssetServiceBase, IAssetService public class XAssetService : XAssetServiceBase, IAssetService
{ {
@ -48,7 +47,9 @@ namespace OpenSim.Services.AssetService
protected static XAssetService m_RootInstance; protected static XAssetService m_RootInstance;
public XAssetService(IConfigSource config) : base(config) public XAssetService(IConfigSource config) : this(config, "AssetService") {}
public XAssetService(IConfigSource config, string configName) : base(config, configName)
{ {
if (m_RootInstance == null) if (m_RootInstance == null)
{ {
@ -56,22 +57,21 @@ namespace OpenSim.Services.AssetService
if (m_AssetLoader != null) if (m_AssetLoader != null)
{ {
IConfig assetConfig = config.Configs["AssetService"]; IConfig assetConfig = config.Configs[configName];
if (assetConfig == null) if (assetConfig == null)
throw new Exception("No AssetService configuration"); throw new Exception("No AssetService configuration");
string loaderArgs = assetConfig.GetString("AssetLoaderArgs", string loaderArgs = assetConfig.GetString("AssetLoaderArgs", String.Empty);
String.Empty);
bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true); bool assetLoaderEnabled = assetConfig.GetBoolean("AssetLoaderEnabled", true);
if (assetLoaderEnabled) if (assetLoaderEnabled && !HasChainedAssetService)
{ {
m_log.DebugFormat("[XASSET SERVICE]: Loading default asset set from {0}", loaderArgs); m_log.DebugFormat("[XASSET SERVICE]: Loading default asset set from {0}", loaderArgs);
m_AssetLoader.ForEachDefaultXmlAsset( m_AssetLoader.ForEachDefaultXmlAsset(
loaderArgs, loaderArgs,
delegate(AssetBase a) a =>
{ {
AssetBase existingAsset = Get(a.ID); AssetBase existingAsset = Get(a.ID);
// AssetMetadata existingMetadata = GetMetadata(a.ID); // AssetMetadata existingMetadata = GetMetadata(a.ID);
@ -103,7 +103,23 @@ namespace OpenSim.Services.AssetService
try try
{ {
return m_Database.GetAsset(assetID); AssetBase asset = m_Database.GetAsset(assetID);
if (asset != null)
{
return asset;
}
else if (HasChainedAssetService)
{
asset = m_ChainedAssetService.Get(id);
if (asset != null)
MigrateFromChainedService(asset);
return asset;
}
return null;
} }
catch (Exception e) catch (Exception e)
{ {
@ -120,30 +136,25 @@ namespace OpenSim.Services.AssetService
public virtual AssetMetadata GetMetadata(string id) public virtual AssetMetadata GetMetadata(string id)
{ {
// m_log.DebugFormat("[XASSET SERVICE]: Get asset metadata for {0}", id); // m_log.DebugFormat("[XASSET SERVICE]: Get asset metadata for {0}", id);
UUID assetID;
if (!UUID.TryParse(id, out assetID)) AssetBase asset = Get(id);
return null;
AssetBase asset = m_Database.GetAsset(assetID);
if (asset != null) if (asset != null)
return asset.Metadata; return asset.Metadata;
else
return null; return null;
} }
public virtual byte[] GetData(string id) public virtual byte[] GetData(string id)
{ {
// m_log.DebugFormat("[XASSET SERVICE]: Get asset data for {0}", id); // m_log.DebugFormat("[XASSET SERVICE]: Get asset data for {0}", id);
UUID assetID; AssetBase asset = Get(id);
if (!UUID.TryParse(id, out assetID)) if (asset != null)
return asset.Data;
else
return null; return null;
AssetBase asset = m_Database.GetAsset(assetID);
return asset.Data;
} }
public virtual bool Get(string id, Object sender, AssetRetrieved handler) public virtual bool Get(string id, Object sender, AssetRetrieved handler)
@ -155,7 +166,7 @@ namespace OpenSim.Services.AssetService
if (!UUID.TryParse(id, out assetID)) if (!UUID.TryParse(id, out assetID))
return false; return false;
AssetBase asset = m_Database.GetAsset(assetID); AssetBase asset = Get(id);
//m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset); //m_log.DebugFormat("[XASSET SERVICE]: Got asset {0}", asset);
@ -194,7 +205,15 @@ namespace OpenSim.Services.AssetService
if (!UUID.TryParse(id, out assetID)) if (!UUID.TryParse(id, out assetID))
return false; return false;
// Don't bother deleting from a chained asset service. This isn't a big deal since deleting happens
// very rarely.
return m_Database.Delete(id); return m_Database.Delete(id);
} }
private void MigrateFromChainedService(AssetBase asset)
{
Util.FireAndForget(o => { Store(asset); m_ChainedAssetService.Delete(asset.ID); });
}
} }
} }

View File

@ -27,9 +27,11 @@
using System; using System;
using System.Reflection; using System.Reflection;
using log4net;
using Nini.Config; using Nini.Config;
using OpenSim.Framework; using OpenSim.Framework;
using OpenSim.Data; using OpenSim.Data;
using OpenSim.Server.Base;
using OpenSim.Services.Interfaces; using OpenSim.Services.Interfaces;
using OpenSim.Services.Base; using OpenSim.Services.Base;
@ -37,10 +39,15 @@ namespace OpenSim.Services.AssetService
{ {
public class XAssetServiceBase : ServiceBase public class XAssetServiceBase : ServiceBase
{ {
protected IXAssetDataPlugin m_Database = null; private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected IAssetLoader m_AssetLoader = null;
public XAssetServiceBase(IConfigSource config) : base(config) protected IXAssetDataPlugin m_Database;
protected IAssetLoader m_AssetLoader;
protected IAssetService m_ChainedAssetService;
protected bool HasChainedAssetService { get { return m_ChainedAssetService != null; } }
public XAssetServiceBase(IConfigSource config, string configName) : base(config)
{ {
string dllName = String.Empty; string dllName = String.Empty;
string connString = String.Empty; string connString = String.Empty;
@ -48,7 +55,7 @@ namespace OpenSim.Services.AssetService
// //
// Try reading the [AssetService] section first, if it exists // Try reading the [AssetService] section first, if it exists
// //
IConfig assetConfig = config.Configs["AssetService"]; IConfig assetConfig = config.Configs[configName];
if (assetConfig != null) if (assetConfig != null)
{ {
dllName = assetConfig.GetString("StorageProvider", dllName); dllName = assetConfig.GetString("StorageProvider", dllName);
@ -77,17 +84,35 @@ namespace OpenSim.Services.AssetService
if (m_Database == null) if (m_Database == null)
throw new Exception("Could not find a storage interface in the given module"); throw new Exception("Could not find a storage interface in the given module");
string chainedAssetServiceDesignator = assetConfig.GetString("ChainedServiceModule", null);
if (chainedAssetServiceDesignator != null)
{
m_log.InfoFormat(
"[XASSET SERVICE BASE]: Loading chained asset service from {0}", chainedAssetServiceDesignator);
Object[] args = new Object[] { config, configName };
m_ChainedAssetService = ServerUtils.LoadPlugin<IAssetService>(chainedAssetServiceDesignator, args);
if (!HasChainedAssetService)
throw new Exception(
String.Format("Failed to load ChainedAssetService from {0}", chainedAssetServiceDesignator));
}
m_Database.Initialise(connString); m_Database.Initialise(connString);
string loaderName = assetConfig.GetString("DefaultAssetLoader", if (HasChainedAssetService)
String.Empty);
if (loaderName != String.Empty)
{ {
m_AssetLoader = LoadPlugin<IAssetLoader>(loaderName); string loaderName = assetConfig.GetString("DefaultAssetLoader",
String.Empty);
if (m_AssetLoader == null) if (loaderName != String.Empty)
throw new Exception("Asset loader could not be loaded"); {
m_AssetLoader = LoadPlugin<IAssetLoader>(loaderName);
if (m_AssetLoader == null)
throw new Exception("Asset loader could not be loaded");
}
} }
} }
} }

View File

@ -81,6 +81,11 @@ namespace OpenSim.Tests.Common.Mock
return obj; return obj;
} }
public ILandObject GetLandObject(Vector3 position)
{
return GetLandObject(position.X, position.Y);
}
public ILandObject GetLandObject(int x, int y) public ILandObject GetLandObject(int x, int y)
{ {
return GetNoLand(); return GetNoLand();

View File

@ -1019,6 +1019,7 @@
<Reference name="OpenSim.Framework"/> <Reference name="OpenSim.Framework"/>
<Reference name="OpenSim.Framework.Console"/> <Reference name="OpenSim.Framework.Console"/>
<Reference name="OpenSim.Framework.Servers.HttpServer"/> <Reference name="OpenSim.Framework.Servers.HttpServer"/>
<Reference name="OpenSim.Server.Base"/>
<Reference name="OpenSim.Services.Interfaces"/> <Reference name="OpenSim.Services.Interfaces"/>
<Reference name="OpenSim.Services.Base"/> <Reference name="OpenSim.Services.Base"/>
<Reference name="OpenSim.Services.Connectors"/> <Reference name="OpenSim.Services.Connectors"/>