Merge branch 'careminster' into tests

avinationmerge
root 2009-11-26 20:41:38 +01:00
commit 2c3f6aaa87
62 changed files with 6449 additions and 1331 deletions

View File

@ -158,6 +158,7 @@ This software uses components from the following developers:
* Nini (http://nini.sourceforge.net/)
* log4net (http://logging.apache.org/log4net/)
* GlynnTucker.Cache (http://gtcache.sourceforge.net/)
* NDesk.Options 0.2.1 (http://www.ndesk.org/Options)
Some plugins are based on Cable Beach
Cable Beach is Copyright (c) 2008 Intel Corporation

View File

@ -213,9 +213,59 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (!m_app.SceneManager.TryGetScene(regionID, out rebootedScene))
throw new Exception("region not found");
int timeout = 30000;
string message;
if (requestData.ContainsKey("restart")
&& ((string)requestData["restart"] == "delayed")
&& requestData.ContainsKey("milliseconds"))
{
timeout = Int32.Parse(requestData["milliseconds"].ToString());
if (timeout < 15000)
{
//It must be at least 15 seconds or we'll cancel the reboot request
timeout = 15000;
}
message
= "Region is restarting in " + ((int)(timeout / 1000)).ToString()
+ " second(s). Please save what you are doing and log out.";
}
else
{
message = "Region is restarting in 30 second(s). Please save what you are doing and log out.";
}
if (requestData.ContainsKey("noticetype")
&& ((string)requestData["noticetype"] == "dialog"))
{
m_app.SceneManager.ForEachScene(
delegate(Scene scene)
{
IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
if (dialogModule != null)
dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
});
}
else
{
if (!requestData.ContainsKey("noticetype")
|| ((string)requestData["noticetype"] != "none"))
{
m_app.SceneManager.ForEachScene(
delegate(Scene scene)
{
IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
if (dialogModule != null)
dialogModule.SendGeneralAlert(message);
});
}
}
responseData["rebooting"] = true;
response.Value = responseData;
rebootedScene.Restart(30);
rebootedScene.Restart(timeout / 1000,false);
}
catch (Exception e)
{
@ -419,6 +469,22 @@ namespace OpenSim.ApplicationPlugins.RemoteController
message = "Region is going down now.";
}
if (requestData.ContainsKey("noticetype")
&& ((string) requestData["noticetype"] == "dialog"))
{
m_app.SceneManager.ForEachScene(
delegate(Scene scene)
{
IDialogModule dialogModule = scene.RequestModuleInterface<IDialogModule>();
if (dialogModule != null)
dialogModule.SendNotificationToUsersInRegion(UUID.Zero, "System", message);
});
}
else
{
if (!requestData.ContainsKey("noticetype")
|| ((string)requestData["noticetype"] != "none"))
{
m_app.SceneManager.ForEachScene(
delegate(Scene scene)
{
@ -426,6 +492,10 @@ namespace OpenSim.ApplicationPlugins.RemoteController
if (dialogModule != null)
dialogModule.SendGeneralAlert(message);
});
}
}
// Perform shutdown
System.Timers.Timer shutdownTimer = new System.Timers.Timer(timeout); // Wait before firing

View File

@ -26,6 +26,7 @@
*/
using System;
using System.IO;
using System.Collections.Generic;
using System.Reflection;
using log4net;
@ -463,6 +464,125 @@ namespace OpenSim.Data.MySQL
}
}
#region Inventory Rollback-via-.sql Support
/// <summary>
/// Not a good SQL escape function, but it'll do the job (if mutilate the data.)
/// Someone may want to write something better here.
/// </summary>
/// <param name="str"></param>
/// <returns></returns>
private static string cheapSQLescape(string str)
{
str = str.Replace("\\", "");
str = str.Replace("'", "");
str = str.Replace("\"", "");
return "'" + str + "'";
}
private static string InventoryItemToSql(InventoryItemBase item)
{
string sql =
"REPLACE /*! INVITEM AT ***$SUBS$*** */ INTO inventoryitems (inventoryID, assetID, assetType, parentFolderID, avatarID, inventoryName"
+ ", inventoryDescription, inventoryNextPermissions, inventoryCurrentPermissions, invType"
+ ", creatorID, inventoryBasePermissions, inventoryEveryOnePermissions, inventoryGroupPermissions, salePrice, saleType"
+ ", creationDate, groupID, groupOwned, flags) VALUES ";
sql +=
"(?inventoryID, ?assetID, ?assetType, ?parentFolderID, ?avatarID, ?inventoryName, ?inventoryDescription"
+ ", ?inventoryNextPermissions, ?inventoryCurrentPermissions, ?invType, ?creatorID"
+ ", ?inventoryBasePermissions, ?inventoryEveryOnePermissions, ?inventoryGroupPermissions, ?salePrice, ?saleType, ?creationDate"
+ ", ?groupID, ?groupOwned, ?flags);\r\n";
string itemName = item.Name;
string itemDesc = item.Description;
sql = sql.Replace("$SUBS$", Util.UnixTimeSinceEpoch().ToString());
sql = sql.Replace("?inventoryID", cheapSQLescape(item.ID.ToString()));
sql = sql.Replace("?assetID", cheapSQLescape(item.AssetID.ToString()));
sql = sql.Replace("?assetType", cheapSQLescape(item.AssetType.ToString()));
sql = sql.Replace("?parentFolderID", cheapSQLescape(item.Folder.ToString()));
sql = sql.Replace("?avatarID", cheapSQLescape(item.Owner.ToString()));
sql = sql.Replace("?inventoryName", cheapSQLescape(itemName));
sql = sql.Replace("?inventoryDescription", cheapSQLescape(itemDesc));
sql = sql.Replace("?inventoryNextPermissions", cheapSQLescape(item.NextPermissions.ToString()));
sql = sql.Replace("?inventoryCurrentPermissions", cheapSQLescape(item.CurrentPermissions.ToString()));
sql = sql.Replace("?invType", cheapSQLescape(item.InvType.ToString()));
sql = sql.Replace("?creatorID", cheapSQLescape(item.CreatorId));
sql = sql.Replace("?inventoryBasePermissions", cheapSQLescape(item.BasePermissions.ToString()));
sql = sql.Replace("?inventoryEveryOnePermissions", cheapSQLescape(item.EveryOnePermissions.ToString()));
sql = sql.Replace("?inventoryGroupPermissions", cheapSQLescape(item.GroupPermissions.ToString()));
sql = sql.Replace("?salePrice", cheapSQLescape(item.SalePrice.ToString()));
sql = sql.Replace("?saleType", cheapSQLescape(unchecked((sbyte)item.SaleType).ToString()));
sql = sql.Replace("?creationDate", cheapSQLescape(item.CreationDate.ToString()));
sql = sql.Replace("?groupID", cheapSQLescape(item.GroupID.ToString()));
sql = sql.Replace("?groupOwned", cheapSQLescape(item.GroupOwned.ToString()));
sql = sql.Replace("?flags", cheapSQLescape(item.Flags.ToString()));
return sql;
}
private static string InventoryFolderToSql(InventoryFolderBase folder)
{
string sql =
"REPLACE /*! INVFOLDER AT ***$SUBS$*** */ INTO inventoryfolders (folderID, agentID, parentFolderID, folderName, type, version) VALUES ";
sql += "(?folderID, ?agentID, ?parentFolderID, ?folderName, ?type, ?version);\r\n";
string folderName = folder.Name;
sql = sql.Replace("$SUBS$", Util.UnixTimeSinceEpoch().ToString());
sql = sql.Replace("?folderID", cheapSQLescape(folder.ID.ToString()));
sql = sql.Replace("?agentID", cheapSQLescape(folder.Owner.ToString()));
sql = sql.Replace("?parentFolderID", cheapSQLescape(folder.ParentID.ToString()));
sql = sql.Replace("?folderName", cheapSQLescape(folderName));
sql = sql.Replace("?type", cheapSQLescape(folder.Type.ToString()));
sql = sql.Replace("?version", cheapSQLescape(folder.Version.ToString()));
return sql;
}
private static string getRollbackFolderDate()
{
return DateTime.UtcNow.Year.ToString() + "-" + DateTime.UtcNow.Month.ToString() + "-" +
DateTime.UtcNow.Day.ToString();
}
private void StoreRollbackItem(UUID ItemID)
{
if(rollbackStore == true)
{
string todaysPath = RollbackGetTodaysPath();
InventoryItemBase imb = getInventoryItem(ItemID);
string sql = InventoryItemToSql(imb);
File.AppendAllText(Path.Combine(todaysPath, imb.Owner.ToString()), sql);
}
}
private void StoreRollbackFolder(UUID FolderID)
{
if (rollbackStore == true)
{
string todaysPath = RollbackGetTodaysPath();
InventoryFolderBase ifb = getInventoryFolder(FolderID);
string sql = InventoryFolderToSql(ifb);
File.AppendAllText(Path.Combine(todaysPath, ifb.Owner.ToString()), sql);
}
}
private string RollbackGetTodaysPath()
{
if (!Directory.Exists(rollbackDir))
Directory.CreateDirectory(rollbackDir);
string todaysPath = Path.Combine(rollbackDir, getRollbackFolderDate());
if (!Directory.Exists(todaysPath))
Directory.CreateDirectory(todaysPath);
return todaysPath;
}
#endregion
/// <summary>
/// Adds a specified item to the database
/// </summary>
@ -549,6 +669,8 @@ namespace OpenSim.Data.MySQL
/// <param name="item">Inventory item to update</param>
public void updateInventoryItem(InventoryItemBase item)
{
StoreRollbackItem(item.ID);
addInventoryItem(item);
}
@ -558,6 +680,8 @@ namespace OpenSim.Data.MySQL
/// <param name="item">The inventory item UUID to delete</param>
public void deleteInventoryItem(UUID itemID)
{
StoreRollbackItem(itemID);
try
{
database.CheckConnection();
@ -634,6 +758,7 @@ namespace OpenSim.Data.MySQL
/// <param name="folder">Folder to update</param>
public void updateInventoryFolder(InventoryFolderBase folder)
{
StoreRollbackFolder(folder.ID);
addInventoryFolder(folder);
}
@ -644,6 +769,8 @@ namespace OpenSim.Data.MySQL
/// <remarks>UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID</remarks>
public void moveInventoryFolder(InventoryFolderBase folder)
{
StoreRollbackFolder(folder.ID);
string sql =
"UPDATE inventoryfolders SET parentFolderID=?parentFolderID WHERE folderID=?folderID";
@ -805,6 +932,8 @@ namespace OpenSim.Data.MySQL
/// <param name="folderID">the folder UUID</param>
protected void deleteOneFolder(UUID folderID)
{
StoreRollbackFolder(folderID);
try
{
database.CheckConnection();
@ -831,6 +960,14 @@ namespace OpenSim.Data.MySQL
/// <param name="folderID">the folder UUID</param>
protected void deleteItemsInFolder(UUID folderID)
{
if (rollbackStore)
{
foreach (InventoryItemBase itemBase in getInventoryInFolder(folderID))
{
StoreRollbackItem(itemBase.ID);
}
}
try
{
database.CheckConnection();
@ -865,17 +1002,34 @@ namespace OpenSim.Data.MySQL
//Delete all sub-folders
foreach (InventoryFolderBase f in subFolders)
{
StoreRollbackFolder(f.ID);
deleteOneFolder(f.ID);
if(rollbackStore)
{
foreach (InventoryItemBase itemBase in getInventoryInFolder(f.ID))
{
StoreRollbackItem(itemBase.ID);
}
}
deleteItemsInFolder(f.ID);
}
}
StoreRollbackFolder(folderID);
//Delete the actual row
deleteOneFolder(folderID);
// Just delete the folder context in OGM
if (opengridmode == false)
{
if (rollbackStore)
{
foreach (InventoryItemBase itemBase in getInventoryInFolder(folderID))
{
StoreRollbackItem(itemBase.ID);
}
}
deleteItemsInFolder(folderID);
}
}

View File

@ -32,7 +32,6 @@ namespace OpenSim.Framework
{
public delegate void ExpectUserDelegate(AgentCircuitData agent);
public delegate bool ExpectPrimDelegate(UUID primID, string objData, int XMLMethod);
public delegate void UpdateNeighbours(List<RegionInfo> neighbours);
@ -55,7 +54,6 @@ namespace OpenSim.Framework
public interface IRegionCommsListener
{
event ExpectUserDelegate OnExpectUser;
event ExpectPrimDelegate OnExpectPrim;
event GenericCall2 OnExpectChildAgent;
event AgentCrossing OnAvatarCrossingIntoRegion;
event PrimCrossing OnPrimCrossingIntoRegion;

View File

@ -38,6 +38,6 @@ namespace OpenSim.Framework
string ExtraToXmlString();
void ExtraFromXmlString(string xmlstr);
string GetStateSnapshot();
void SetState(string xmlstr, UUID regionID);
void SetState(string xmlstr, IScene s);
}
}

View File

@ -43,7 +43,6 @@ namespace OpenSim.Framework
private ChildAgentUpdate handlerChildAgentUpdate = null; // OnChildAgentUpdate;
private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
private GenericCall2 handlerExpectChildAgent = null; // OnExpectChildAgent;
private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser
private UpdateNeighbours handlerNeighboursUpdate = null; // OnNeighboursUpdate;
private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
@ -53,7 +52,6 @@ namespace OpenSim.Framework
#region IRegionCommsListener Members
public event ExpectUserDelegate OnExpectUser;
public event ExpectPrimDelegate OnExpectPrim;
public event GenericCall2 OnExpectChildAgent;
public event AgentCrossing OnAvatarCrossingIntoRegion;
public event PrimCrossing OnPrimCrossingIntoRegion;
@ -95,17 +93,6 @@ namespace OpenSim.Framework
}
public virtual bool TriggerExpectPrim(UUID primID, string objData, int XMLMethod)
{
handlerExpectPrim = OnExpectPrim;
if (handlerExpectPrim != null)
{
handlerExpectPrim(primID, objData, XMLMethod);
return true;
}
return false;
}
public virtual bool TriggerChildAgentUpdate(ChildAgentDataUpdate cAgentData)
{
handlerChildAgentUpdate = OnChildAgentUpdate;
@ -128,18 +115,6 @@ namespace OpenSim.Framework
return false;
}
public virtual bool TriggerExpectPrimCrossing(UUID primID, Vector3 position,
bool isPhysical)
{
handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;
if (handlerPrimCrossingIntoRegion != null)
{
handlerPrimCrossingIntoRegion(primID, position, isPhysical);
return true;
}
return false;
}
public virtual bool TriggerAcknowledgeAgentCrossed(UUID agentID)
{
handlerAcknowledgeAgentCrossed = OnAcknowledgeAgentCrossed;

View File

@ -29,7 +29,7 @@ namespace OpenSim
{
public class VersionInfo
{
private const string VERSION_NUMBER = "0.6.8";
private const string VERSION_NUMBER = "0.6.9-CM";
private const Flavour VERSION_FLAVOUR = Flavour.Dev;
public enum Flavour

View File

@ -27,9 +27,12 @@
using System;
using System.Collections.Generic;
using System.Threading;
using System.Reflection;
using System.Xml;
using System.Xml.Schema;
using System.Xml.Serialization;
using log4net;
using OpenMetaverse;
namespace OpenSim.Framework
@ -45,6 +48,105 @@ namespace OpenSim.Framework
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static XmlSerializer tiiSerializer = new XmlSerializer(typeof (TaskInventoryItem));
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private Thread LockedByThread;
/// <value>
/// An advanced lock for inventory data
/// </value>
private System.Threading.ReaderWriterLockSlim m_itemLock = new System.Threading.ReaderWriterLockSlim();
/// <summary>
/// Are we readlocked by the calling thread?
/// </summary>
public bool IsReadLockedByMe()
{
if (m_itemLock.RecursiveReadCount > 0)
{
return true;
}
else
{
return false;
}
}
/// <summary>
/// Lock our inventory list for reading (many can read, one can write)
/// </summary>
public void LockItemsForRead(bool locked)
{
if (locked)
{
if (m_itemLock.IsWriteLockHeld && LockedByThread != null)
{
if (!LockedByThread.IsAlive)
{
//Locked by dead thread, reset.
m_itemLock = new System.Threading.ReaderWriterLockSlim();
}
}
if (m_itemLock.RecursiveReadCount > 0)
{
m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
m_itemLock.ExitReadLock();
}
if (m_itemLock.RecursiveWriteCount > 0)
{
m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed.");
m_itemLock.ExitWriteLock();
}
while (!m_itemLock.TryEnterReadLock(60000))
{
m_log.Error("Thread lock detected while trying to aquire READ lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
if (m_itemLock.IsWriteLockHeld)
{
m_itemLock = new System.Threading.ReaderWriterLockSlim();
}
}
}
else
{
m_itemLock.ExitReadLock();
}
}
/// <summary>
/// Lock our inventory list for writing (many can read, one can write)
/// </summary>
public void LockItemsForWrite(bool locked)
{
if (locked)
{
//Enter a write lock, wait indefinately for one to open.
if (m_itemLock.RecursiveReadCount > 0)
{
m_log.Error("[TaskInventoryDictionary] Recursive read lock requested. This should not happen and means something needs to be fixed. For now though, it's safe to continue.");
m_itemLock.ExitReadLock();
}
if (m_itemLock.RecursiveWriteCount > 0)
{
m_log.Error("[TaskInventoryDictionary] Recursive write lock requested. This should not happen and means something needs to be fixed.");
m_itemLock.ExitWriteLock();
}
while (!m_itemLock.TryEnterWriteLock(60000))
{
m_log.Error("Thread lock detected while trying to aquire WRITE lock in TaskInventoryDictionary. Locked by thread " + LockedByThread.Name + ". I'm going to try to solve the thread lock automatically to preserve region stability, but this needs to be fixed.");
if (m_itemLock.IsWriteLockHeld)
{
m_itemLock = new System.Threading.ReaderWriterLockSlim();
}
}
LockedByThread = Thread.CurrentThread;
}
else
{
m_itemLock.ExitWriteLock();
}
}
#region ICloneable Members
@ -52,13 +154,12 @@ namespace OpenSim.Framework
{
TaskInventoryDictionary clone = new TaskInventoryDictionary();
lock (this)
{
m_itemLock.EnterReadLock();
foreach (UUID uuid in Keys)
{
clone.Add(uuid, (TaskInventoryItem) this[uuid].Clone());
}
}
m_itemLock.ExitReadLock();
return clone;
}

View File

@ -79,7 +79,8 @@ namespace OpenSim.Framework.Tests
cachedItem.Store(foo);
cache.Store(cacheItemUUID.ToString(), cachedItem);
object citem = cache.Get(cacheItemUUID.ToString());
cache.Get(cacheItemUUID.ToString());
//object citem = cache.Get(cacheItemUUID.ToString());
//Assert.That(citem == null, "Item should not be in Cache because the expiry time was before now");
}
@ -94,7 +95,8 @@ namespace OpenSim.Framework.Tests
cachedItem.Store(foo);
cache.Store(cacheItemUUID.ToString(), cachedItem);
cache.Invalidate(ImmediateExpiryUUID.ToString());
object citem = cache.Get(cacheItemUUID.ToString());
cache.Get(cacheItemUUID.ToString());
//object citem = cache.Get(cacheItemUUID.ToString());
//Assert.That(citem == null, "Item should not be in Cache because we manually invalidated it");
}

View File

@ -990,19 +990,19 @@ namespace OpenSim.Framework
{
string os = String.Empty;
if (Environment.OSVersion.Platform != PlatformID.Unix)
{
os = Environment.OSVersion.ToString();
}
else
{
os = ReadEtcIssue();
}
if (os.Length > 45)
{
os = os.Substring(0, 45);
}
// if (Environment.OSVersion.Platform != PlatformID.Unix)
// {
// os = Environment.OSVersion.ToString();
// }
// else
// {
// os = ReadEtcIssue();
// }
//
// if (os.Length > 45)
// {
// os = os.Substring(0, 45);
// }
return os;
}

View File

@ -42,7 +42,7 @@ namespace OpenSim
{
public class HGCommands
{
private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public static Scene CreateScene(RegionInfo regionInfo, AgentCircuitManager circuitManager, CommunicationsManager m_commsManager,
StorageManager storageManager, ModuleLoader m_moduleLoader, ConfigSettings m_configSettings, OpenSimConfigSource m_config, string m_version)

View File

@ -232,7 +232,7 @@ namespace OpenSim
"Save named prim to XML2", SavePrimsXml2);
m_console.Commands.AddCommand("region", false, "load oar",
"load oar <oar name>",
"load oar [--merge] <oar name>",
"Load a region's data from OAR archive", LoadOar);
m_console.Commands.AddCommand("region", false, "save oar",
@ -1294,14 +1294,7 @@ namespace OpenSim
{
try
{
if (cmdparams.Length > 2)
{
m_sceneManager.LoadArchiveToCurrentScene(cmdparams[2]);
}
else
{
m_sceneManager.LoadArchiveToCurrentScene(DEFAULT_OAR_BACKUP_FILENAME);
}
m_sceneManager.LoadArchiveToCurrentScene(cmdparams);
}
catch (Exception e)
{
@ -1315,14 +1308,7 @@ namespace OpenSim
/// <param name="cmdparams"></param>
protected void SaveOar(string module, string[] cmdparams)
{
if (cmdparams.Length > 2)
{
m_sceneManager.SaveCurrentSceneToArchive(cmdparams[2]);
}
else
{
m_sceneManager.SaveCurrentSceneToArchive(DEFAULT_OAR_BACKUP_FILENAME);
}
m_sceneManager.SaveCurrentSceneToArchive(cmdparams);
}
private static string CombineParams(string[] commandParams, int pos)

View File

@ -75,11 +75,6 @@ namespace OpenSim
/// </value>
protected const string DEFAULT_PRIM_BACKUP_FILENAME = "prim-backup.xml";
/// <value>
/// The file used to load and save an opensimulator archive if no filename has been specified
/// </value>
protected const string DEFAULT_OAR_BACKUP_FILENAME = "region.oar";
public ConfigSettings ConfigurationSettings
{
get { return m_configSettings; }

File diff suppressed because it is too large Load Diff

View File

@ -49,7 +49,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
private int m_shoutdistance = 100;
private int m_whisperdistance = 10;
private List<Scene> m_scenes = new List<Scene>();
private string m_adminPrefix = "";
internal object m_syncy = new object();
internal IConfig m_config;
@ -57,25 +57,26 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
#region ISharedRegionModule Members
public virtual void Initialise(IConfigSource config)
{
m_config = config.Configs["Chat"];
if (null == m_config)
{
m_log.Info("[CHAT]: no config found, plugin disabled");
m_enabled = false;
return;
}
if (!m_config.GetBoolean("enabled", false))
if (!m_config.GetBoolean("enabled", true))
{
m_log.Info("[CHAT]: plugin disabled by configuration");
m_enabled = false;
return;
}
m_enabled = true;
m_whisperdistance = config.Configs["Chat"].GetInt("whisper_distance", m_whisperdistance);
m_saydistance = config.Configs["Chat"].GetInt("say_distance", m_saydistance);
m_shoutdistance = config.Configs["Chat"].GetInt("shout_distance", m_shoutdistance);
m_adminPrefix = config.Configs["Chat"].GetString("admin_prefix", "");
}
public virtual void AddRegion(Scene scene)
@ -185,6 +186,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
protected virtual void DeliverChatToAvatars(ChatSourceType sourceType, OSChatMessage c)
{
string fromName = c.From;
string fromNamePrefix = "";
UUID fromID = UUID.Zero;
string message = c.Message;
IScene scene = c.Scene;
@ -207,7 +209,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
fromPos = avatar.AbsolutePosition;
fromName = avatar.Name;
fromID = c.Sender.AgentId;
if (avatar.GodLevel > 200)
{
fromNamePrefix = m_adminPrefix;
}
break;
case ChatSourceType.Object:
@ -227,7 +232,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
s.ForEachScenePresence(
delegate(ScenePresence presence)
{
TrySendChatMessage(presence, fromPos, regionPos, fromID, fromName, c.Type, message, sourceType);
TrySendChatMessage(presence, fromPos, regionPos, fromID, fromNamePrefix+fromName, c.Type, message, sourceType);
}
);
}
@ -266,8 +271,10 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
}
// m_log.DebugFormat("[CHAT] Broadcast: fromID {0} fromName {1}, cType {2}, sType {3}", fromID, fromName, cType, sourceType);
((Scene)c.Scene).ForEachScenePresence(
if (c.Scene != null)
{
((Scene)c.Scene).ForEachScenePresence
(
delegate(ScenePresence presence)
{
// ignore chat from child agents
@ -284,7 +291,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Chat
client.SendChatMessage(c.Message, (byte)cType, CenterOfRegion, fromName, fromID,
(byte)sourceType, (byte)ChatAudibleLevel.Fully);
});
}
);
}
}

View File

@ -121,6 +121,9 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
byte[] data;
TarArchiveReader.TarEntryType entryType;
try
{
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
{
if (filePath.StartsWith(ArchiveConstants.ASSETS_PATH))
@ -158,8 +161,11 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
}
}
}
}
finally
{
archive.Close();
}
m_log.DebugFormat(
"[INVENTORY ARCHIVER]: Successfully loaded {0} assets with {1} failures",
@ -342,9 +348,17 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
UUID ospResolvedId = OspResolver.ResolveOspa(item.CreatorId, m_scene.CommsManager);
if (UUID.Zero != ospResolvedId)
{
item.CreatorIdAsUuid = ospResolvedId;
// XXX: For now, don't preserve the OSPA in the creator id (which actually gets persisted to the
// database). Instead, replace with the UUID that we found.
item.CreatorId = ospResolvedId.ToString();
}
else
{
item.CreatorIdAsUuid = m_userInfo.UserProfile.ID;
}
item.Owner = m_userInfo.UserProfile.ID;

View File

@ -118,18 +118,18 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
protected void ReceivedAllAssets(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
{
// We're almost done. Just need to write out the control file now
m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
Exception reportedException = null;
bool succeeded = true;
try
{
// We're almost done. Just need to write out the control file now
m_archiveWriter.WriteFile(ArchiveConstants.CONTROL_FILE_PATH, Create0p1ControlFile());
m_log.InfoFormat("[ARCHIVER]: Added control file to archive.");
m_archiveWriter.Close();
}
catch (IOException e)
catch (Exception e)
{
m_saveStream.Close();
reportedException = e;
@ -261,8 +261,21 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
//inventoryItem = m_userInfo.RootFolder.FindItemByPath(m_invPath);
}
if (null == inventoryFolder && null == inventoryItem)
{
// We couldn't find the path indicated
string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath);
m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", errorMessage);
m_module.TriggerInventoryArchiveSaved(
m_id, false, m_userInfo, m_invPath, m_saveStream,
new Exception(errorMessage));
return;
}
m_archiveWriter = new TarArchiveWriter(m_saveStream);
try
{
if (inventoryFolder != null)
{
m_log.DebugFormat(
@ -280,20 +293,15 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
SaveInvItem(inventoryItem, ArchiveConstants.INVENTORY_PATH);
}
else
{
// We couldn't find the path indicated
m_saveStream.Close();
string errorMessage = string.Format("Aborted save. Could not find inventory path {0}", m_invPath);
m_log.ErrorFormat("[INVENTORY ARCHIVER]: {0}", errorMessage);
m_module.TriggerInventoryArchiveSaved(
m_id, false, m_userInfo, m_invPath, m_saveStream,
new Exception(errorMessage));
return;
}
// Don't put all this profile information into the archive right now.
//SaveUsers();
}
catch (Exception)
{
m_archiveWriter.Close();
throw;
}
new AssetsRequest(
new AssetsArchiver(m_archiveWriter), m_assetUuids.Keys,

View File

@ -92,12 +92,12 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
scene.AddCommand(
this, "load iar",
"load iar <first> <last> <inventory path> <password> [<archive path>]",
"Load user inventory archive. EXPERIMENTAL", HandleLoadInvConsoleCommand);
"Load user inventory archive.", HandleLoadInvConsoleCommand);
scene.AddCommand(
this, "save iar",
"save iar <first> <last> <inventory path> <password> [<archive path>]",
"Save user inventory archive. EXPERIMENTAL", HandleSaveInvConsoleCommand);
"Save user inventory archive.", HandleSaveInvConsoleCommand);
m_aScene = scene;
}
@ -280,7 +280,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver
string savePath = (cmdparams.Length > 6 ? cmdparams[6] : DEFAULT_INV_BACKUP_FILENAME);
m_log.InfoFormat(
"[INVENTORY ARCHIVER]: Saving archive {0} from inventory path {1} for {2} {3}",
"[INVENTORY ARCHIVER]: Saving archive {0} using inventory path {1} for {2} {3}",
savePath, invPath, firstName, lastName);
Guid id = Guid.NewGuid();

View File

@ -259,9 +259,16 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Archiver.Tests
= InventoryArchiveUtils.FindItemByPath(scene.InventoryService, userInfo.UserProfile.ID, item1Name);
Assert.That(foundItem1, Is.Not.Null, "Didn't find loaded item 1");
// We have to disable this check since loaded items that did find users via OSPA resolution are now only storing the
// UUID, not the OSPA itself.
// Assert.That(
// foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
// "Loaded item non-uuid creator doesn't match original");
Assert.That(
foundItem1.CreatorId, Is.EqualTo(item1.CreatorId),
foundItem1.CreatorId, Is.EqualTo(userItemCreatorUuid.ToString()),
"Loaded item non-uuid creator doesn't match original");
Assert.That(
foundItem1.CreatorIdAsUuid, Is.EqualTo(userItemCreatorUuid),
"Loaded item uuid creator doesn't match original");

View File

@ -389,7 +389,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Inventory.Transfer
{
// Check if this is ours to handle
//
m_log.Info("OnFridInstantMessage");
//m_log.Info("OnFridInstantMessage");
if (msg.dialog != (byte) InstantMessageDialog.InventoryOffered)
return;

View File

@ -263,8 +263,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
{
// We need to make a local copy of the object
ISceneObject sogClone = sog.CloneForNewScene();
sogClone.SetState(sog.GetStateSnapshot(),
s.RegionInfo.RegionID);
sogClone.SetState(sog.GetStateSnapshot(), s);
return s.IncomingCreateObject(sogClone);
}
else
@ -294,15 +293,15 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
#region Misc
public UUID GetRegionID(ulong regionhandle)
public Scene GetScene(ulong regionhandle)
{
foreach (Scene s in m_sceneList)
{
if (s.RegionInfo.RegionHandle == regionhandle)
return s.RegionInfo.RegionID;
return s;
}
// ? weird. should not happen
return m_sceneList[0].RegionInfo.RegionID;
return m_sceneList[0];
}
public bool IsLocalRegion(ulong regionhandle)

View File

@ -641,7 +641,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
if (args["extra"] != null)
extraStr = args["extra"].AsString();
UUID regionID = m_localBackend.GetRegionID(regionhandle);
IScene s = m_localBackend.GetScene(regionhandle);
SceneObjectGroup sog = null;
try
{
@ -663,7 +663,7 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
{
try
{
sog.SetState(stateXmlStr, regionID);
sog.SetState(stateXmlStr, s);
}
catch (Exception ex)
{
@ -695,8 +695,6 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Interregion
if (args["itemid"] != null)
itemID = args["itemid"].AsUUID();
//UUID regionID = m_localBackend.GetRegionID(regionhandle);
// This is the meaning of PUT object
bool result = m_localBackend.SendCreateObject(regionhandle, userID, itemID);

View File

@ -104,13 +104,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
List<string> serialisedParcels = new List<string>();
string filePath = "NONE";
try
{
TarArchiveReader archive = new TarArchiveReader(m_loadStream);
byte[] data;
TarArchiveReader.TarEntryType entryType;
try
{
while ((data = archive.ReadEntry(out filePath, out entryType)) != null)
{
//m_log.DebugFormat(
@ -152,8 +151,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
}
//m_log.Debug("[ARCHIVER]: Reached end of archive");
archive.Close();
}
catch (Exception e)
{
@ -163,6 +160,10 @@ namespace OpenSim.Region.CoreModules.World.Archiver
m_scene.EventManager.TriggerOarFileLoaded(m_requestId, m_errorMessage);
return;
}
finally
{
archive.Close();
}
m_log.InfoFormat("[ARCHIVER]: Restored {0} assets", successfulAssetRestores);
@ -246,8 +247,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
// Fix ownership/creator of inventory items
// Not doing so results in inventory items
// being no copy/no mod for everyone
lock (part.TaskInventory)
{
part.TaskInventory.LockItemsForRead(true);
TaskInventoryDictionary inv = part.TaskInventory;
foreach (KeyValuePair<UUID, TaskInventoryItem> kvp in inv)
{
@ -260,7 +260,7 @@ namespace OpenSim.Region.CoreModules.World.Archiver
kvp.Value.CreatorID = masterAvatarId;
}
}
}
part.TaskInventory.LockItemsForRead(false);
}
if (m_scene.AddRestoredSceneObject(sceneObject, true, false))

View File

@ -79,6 +79,22 @@ namespace OpenSim.Region.CoreModules.World.Archiver
protected internal void ReceivedAllAssets(
ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
{
try
{
Save(assetsFoundUuids, assetsNotFoundUuids);
}
finally
{
m_archiveWriter.Close();
}
m_log.InfoFormat("[ARCHIVER]: Finished writing out OAR for {0}", m_scene.RegionInfo.RegionName);
m_scene.EventManager.TriggerOarFileSaved(m_requestId, String.Empty);
}
protected internal void Save(ICollection<UUID> assetsFoundUuids, ICollection<UUID> assetsNotFoundUuids)
{
foreach (UUID uuid in assetsNotFoundUuids)
{
@ -143,12 +159,6 @@ namespace OpenSim.Region.CoreModules.World.Archiver
}
m_log.InfoFormat("[ARCHIVER]: Added scene objects to archive.");
m_archiveWriter.Close();
m_log.InfoFormat("[ARCHIVER]: Finished writing out OAR for {0}", m_scene.RegionInfo.RegionName);
m_scene.EventManager.TriggerOarFileSaved(m_requestId, String.Empty);
}
/// <summary>

View File

@ -56,6 +56,12 @@ namespace OpenSim.Region.CoreModules.World.Archiver
/// <summary>
/// Constructor
/// </summary>
/// <param name="scene"></param>
/// <param name="savePath">The path to which to save data.</param>
/// <param name="requestId">The id associated with this request</param>
/// <exception cref="System.IO.IOException">
/// If there was a problem opening a stream for the file specified by the savePath
/// </exception>
public ArchiveWriteRequestPreparation(Scene scene, string savePath, Guid requestId)
{
m_scene = scene;
@ -87,6 +93,16 @@ namespace OpenSim.Region.CoreModules.World.Archiver
List<EntityBase> entities = m_scene.GetEntities();
List<SceneObjectGroup> sceneObjects = new List<SceneObjectGroup>();
/*
foreach (ILandObject lo in m_scene.LandChannel.AllParcels())
{
if (name == lo.LandData.Name)
{
// This is the parcel we want
}
}
*/
// Filter entities so that we only have scene objects.
// FIXME: Would be nicer to have this as a proper list in SceneGraph, since lots of methods
// end up having to do this

View File

@ -26,9 +26,11 @@
*/
using System;
using System.Collections.Generic;
using System.IO;
using System.Reflection;
using log4net;
using NDesk.Options;
using Nini.Config;
using OpenSim.Region.Framework.Interfaces;
using OpenSim.Region.Framework.Scenes;
@ -45,6 +47,11 @@ namespace OpenSim.Region.CoreModules.World.Archiver
private Scene m_scene;
/// <value>
/// The file used to load and save an opensimulator archive if no filename has been specified
/// </value>
protected const string DEFAULT_OAR_BACKUP_FILENAME = "region.oar";
public string Name
{
get { return "RegionArchiverModule"; }
@ -80,6 +87,48 @@ namespace OpenSim.Region.CoreModules.World.Archiver
{
}
/// <summary>
/// Load a whole region from an opensimulator archive.
/// </summary>
/// <param name="cmdparams"></param>
public void HandleLoadOarConsoleCommand(string module, string[] cmdparams)
{
bool mergeOar = false;
OptionSet options = new OptionSet().Add("m|merge", delegate (string v) { mergeOar = v != null; });
List<string> mainParams = options.Parse(cmdparams);
// m_log.DebugFormat("MERGE OAR IS [{0}]", mergeOar);
//
// foreach (string param in mainParams)
// m_log.DebugFormat("GOT PARAM [{0}]", param);
if (mainParams.Count > 2)
{
DearchiveRegion(mainParams[2], mergeOar, Guid.Empty);
}
else
{
DearchiveRegion(DEFAULT_OAR_BACKUP_FILENAME, mergeOar, Guid.Empty);
}
}
/// <summary>
/// Save a region to a file, including all the assets needed to restore it.
/// </summary>
/// <param name="cmdparams"></param>
public void HandleSaveOarConsoleCommand(string module, string[] cmdparams)
{
if (cmdparams.Length > 2)
{
ArchiveRegion(cmdparams[2]);
}
else
{
ArchiveRegion(DEFAULT_OAR_BACKUP_FILENAME);
}
}
public void ArchiveRegion(string savePath)
{
ArchiveRegion(savePath, Guid.Empty);

View File

@ -154,6 +154,7 @@ namespace OpenSim.Region.CoreModules.World.Land
m_landManagementModule.UpdateLandObject(localID, data);
}
}
public void ReturnObjectsInParcel(int localID, uint returnType, UUID[] agentIDs, UUID[] taskIDs, IClientAPI remoteClient)
{
if (m_landManagementModule != null)

View File

@ -67,7 +67,14 @@ namespace OpenSim.Region.CoreModules.World.Land
private const int landArrayMax = ((int)((int)Constants.RegionSize / 4) >= 64) ? (int)((int)Constants.RegionSize / 4) : 64;
#pragma warning restore 0429
/// <value>
/// Local land ids at specified region co-ordinates (region size / 4)
/// </value>
private readonly int[,] m_landIDList = new int[landArrayMax, landArrayMax];
/// <value>
/// Land objects keyed by local id
/// </value>
private readonly Dictionary<int, ILandObject> m_landList = new Dictionary<int, ILandObject>();
private bool m_landPrimCountTainted;
@ -570,6 +577,7 @@ namespace OpenSim.Region.CoreModules.World.Land
if (x_float > Constants.RegionSize || x_float <= 0 || y_float > Constants.RegionSize || y_float <= 0)
return null;
try
{
x = Convert.ToInt32(Math.Floor(Convert.ToDouble(x_float) / 4.0));
@ -584,6 +592,7 @@ namespace OpenSim.Region.CoreModules.World.Land
{
return null;
}
lock (m_landList)
{
// Corner case. If an autoreturn happens during sim startup
@ -603,6 +612,7 @@ namespace OpenSim.Region.CoreModules.World.Land
// they happen every time at border crossings
throw new Exception("Error: Parcel not found at point " + x + ", " + y);
}
lock (m_landIDList)
{
try

View File

@ -184,12 +184,6 @@ namespace OpenSim.Region.Framework.Interfaces
/// <returns></returns>
List<UUID> GetInventoryList();
/// <summary>
/// Get the names of the assemblies associated with scripts in this inventory.
/// </summary>
/// <returns></returns>
string[] GetScriptAssemblies();
/// <summary>
/// Get the xml representing the saved states of scripts in this inventory.
/// </summary>
@ -197,7 +191,5 @@ namespace OpenSim.Region.Framework.Interfaces
/// A <see cref="Dictionary`2"/>
/// </returns>
Dictionary<UUID, string> GetScriptStates();
bool CanBeDeleted();
}
}

View File

@ -33,27 +33,42 @@ namespace OpenSim.Region.Framework.Interfaces
{
public interface ILandChannel
{
List<ILandObject> ParcelsNearPoint(Vector3 position);
/// <summary>
/// Get all parcels
/// </summary>
/// <returns></returns>
List<ILandObject> AllParcels();
/// <summary>
/// Get the land object at the specified point
/// Get the parcel at the specified point
/// </summary>
/// <param name="x">Value between 0 - 256 on the x axis of the point</param>
/// <param name="y">Value between 0 - 256 on the y axis of the point</param>
/// <returns>Land object at the point supplied</returns>
ILandObject GetLandObject(int x, int y);
ILandObject GetLandObject(int localID);
/// <summary>
/// Get the land object at the specified point
/// Get the parcel at the specified point
/// </summary>
/// <param name="x">Value between 0 - 256 on the x axis of the point</param>
/// <param name="y">Value between 0 - 256 on the y axis of the point</param>
/// <returns>Land object at the point supplied</returns>
ILandObject GetLandObject(float x, float y);
/// <summary>
/// Get the parcels near the specified point
/// </summary>
/// <param name="position"></param>
/// <returns></returns>
List<ILandObject> ParcelsNearPoint(Vector3 position);
/// <summary>
/// Get the parcel given the land's local id.
/// </summary>
/// <param name="localID"></param>
/// <returns></returns>
ILandObject GetLandObject(int localID);
bool IsLandPrimCountTainted();
bool IsForcefulBansAllowed();
void UpdateLandObject(int localID, LandData data);

View File

@ -35,6 +35,9 @@ namespace OpenSim.Region.Framework.Interfaces
/// </summary>
public interface IRegionArchiverModule
{
void HandleLoadOarConsoleCommand(string module, string[] cmdparams);
void HandleSaveOarConsoleCommand(string module, string[] cmdparams);
/// <summary>
/// Archive the region to the given path
/// </summary>

View File

@ -34,9 +34,8 @@ namespace OpenSim.Region.Framework.Interfaces
{
string ScriptEngineName { get; }
string GetAssemblyName(UUID itemID);
string GetXMLState(UUID itemID);
bool CanBeDeleted(UUID itemID);
void SetXMLState(UUID itemID, string xml);
bool PostScriptEvent(UUID itemID, string name, Object[] args);
bool PostObjectEvent(UUID itemID, string name, Object[] args);

View File

@ -163,8 +163,8 @@ namespace OpenSim.Region.Framework.Scenes.Animation
// Check control flags
bool heldForward = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_AT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS);
bool heldBack = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_AT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG);
bool heldLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS;
bool heldRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG;
bool heldLeft = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_POS || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS);
bool heldRight = ((controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_LEFT_NEG || (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG) == AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG);
//bool heldTurnLeft = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_LEFT;
//bool heldTurnRight = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT) == AgentManager.ControlFlags.AGENT_CONTROL_TURN_RIGHT;
bool heldUp = (controlFlags & AgentManager.ControlFlags.AGENT_CONTROL_UP_POS) == AgentManager.ControlFlags.AGENT_CONTROL_UP_POS;
@ -252,8 +252,7 @@ namespace OpenSim.Region.Framework.Scenes.Animation
else if (m_movementAnimation == "LAND")
{
float landElapsed = (float)(Environment.TickCount - m_animTickFall) / 1000f;
if (landElapsed <= FALL_DELAY)
if ((m_animTickFall != 0) && (landElapsed <= FALL_DELAY))
return "LAND";
}

View File

@ -131,11 +131,6 @@ namespace OpenSim.Region.Framework.Scenes
if (left > 0)
{
x = m_inventoryDeletes.Dequeue();
if (!x.objectGroup.CanBeDeleted())
{
m_inventoryDeletes.Enqueue(x);
return true;
}
m_log.DebugFormat(
"[SCENE]: Sending object to user's inventory, {0} item(s) remaining.", left);

View File

@ -840,8 +840,12 @@ namespace OpenSim.Region.Framework.Scenes
public void RemoveTaskInventory(IClientAPI remoteClient, UUID itemID, uint localID)
{
SceneObjectPart part = GetSceneObjectPart(localID);
SceneObjectGroup group = part.ParentGroup;
if (group != null)
SceneObjectGroup group = null;
if (part != null)
{
group = part.ParentGroup;
}
if (part != null && group != null)
{
TaskInventoryItem item = group.GetInventoryItem(localID, itemID);
if (item == null)

View File

@ -388,6 +388,11 @@ namespace OpenSim.Region.Framework.Scenes
get { return StatsReporter.getLastReportedSimFPS(); }
}
public float[] SimulatorStats
{
get { return StatsReporter.getLastReportedSimStats(); }
}
public string DefaultScriptEngine
{
get { return m_defaultScriptEngine; }
@ -618,7 +623,7 @@ namespace OpenSim.Region.Framework.Scenes
startupConfig.GetLong("MaximumTimeBeforePersistenceConsidered", DEFAULT_MAX_TIME_FOR_PERSISTENCE);
m_persistAfter *= 10000000;
m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "DotNetEngine");
m_defaultScriptEngine = startupConfig.GetString("DefaultScriptEngine", "XEngine");
IConfig packetConfig = m_config.Configs["PacketPool"];
if (packetConfig != null)
@ -872,6 +877,15 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
/// <param name="seconds">float indicating duration before restart.</param>
public virtual void Restart(float seconds)
{
Restart(seconds, true);
}
/// <summary>
/// Given float seconds, this will restart the region. showDialog will optionally alert the users.
/// </summary>
/// <param name="seconds">float indicating duration before restart.</param>
public virtual void Restart(float seconds, bool showDialog)
{
// notifications are done in 15 second increments
// so .. if the number of seconds is less then 15 seconds, it's not really a restart request
@ -893,8 +907,11 @@ namespace OpenSim.Region.Framework.Scenes
m_restartTimer.Elapsed += new ElapsedEventHandler(RestartTimer_Elapsed);
m_log.Info("[REGION]: Restarting Region in " + (seconds / 60) + " minutes");
m_restartTimer.Start();
if (showDialog)
{
m_dialogModule.SendNotificationToUsersInRegion(
UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in 2 Minutes");
UUID.Random(), String.Empty, RegionInfo.RegionName + ": Restarting in " + (seconds / 60).ToString() + " Minutes");
}
}
}
@ -2381,103 +2398,6 @@ namespace OpenSim.Region.Framework.Scenes
return successYN;
}
/// <summary>
/// Handle a scene object that is crossing into this region from another.
/// NOTE: Unused as of 2009-02-09. Soon to be deleted.
/// </summary>
/// <param name="regionHandle"></param>
/// <param name="primID"></param>
/// <param name="objXMLData"></param>
/// <param name="XMLMethod"></param>
/// <returns></returns>
public bool IncomingInterRegionPrimGroup(UUID primID, string objXMLData, int XMLMethod)
{
if (XMLMethod == 0)
{
m_log.DebugFormat("[INTERREGION]: A new prim {0} arrived from a neighbor", primID);
SceneObjectGroup sceneObject = m_serialiser.DeserializeGroupFromXml2(objXMLData);
if (sceneObject.IsAttachment)
sceneObject.RootPart.ObjectFlags |= (uint)PrimFlags.Phantom;
return AddSceneObject(sceneObject);
}
else if ((XMLMethod == 100) && m_allowScriptCrossings)
{
m_log.Warn("[INTERREGION]: Prim state data arrived from a neighbor");
XmlDocument doc = new XmlDocument();
doc.LoadXml(objXMLData);
XmlNodeList rootL = doc.GetElementsByTagName("ScriptData");
if (rootL.Count == 1)
{
XmlNode rootNode = rootL[0];
if (rootNode != null)
{
XmlNodeList partL = rootNode.ChildNodes;
foreach (XmlNode part in partL)
{
XmlNodeList nodeL = part.ChildNodes;
switch (part.Name)
{
case "Assemblies":
foreach (XmlNode asm in nodeL)
{
string fn = asm.Attributes.GetNamedItem("Filename").Value;
Byte[] filedata = Convert.FromBase64String(asm.InnerText);
string path = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString());
path = Path.Combine(path, fn);
if (!File.Exists(path))
{
FileStream fs = File.Create(path);
fs.Write(filedata, 0, filedata.Length);
fs.Close();
}
}
break;
case "ScriptStates":
foreach (XmlNode st in nodeL)
{
string id = st.Attributes.GetNamedItem("UUID").Value;
UUID uuid = new UUID(id);
XmlNode state = st.ChildNodes[0];
XmlDocument sdoc = new XmlDocument();
XmlNode sxmlnode = sdoc.CreateNode(
XmlNodeType.XmlDeclaration,
"", "");
sdoc.AppendChild(sxmlnode);
XmlNode newnode = sdoc.ImportNode(state, true);
sdoc.AppendChild(newnode);
string spath = Path.Combine("ScriptEngines", RegionInfo.RegionID.ToString());
spath = Path.Combine(spath, uuid.ToString());
FileStream sfs = File.Create(spath + ".state");
ASCIIEncoding enc = new ASCIIEncoding();
Byte[] buf = enc.GetBytes(sdoc.InnerXml);
sfs.Write(buf, 0, buf.Length);
sfs.Close();
}
break;
}
}
}
}
SceneObjectPart RootPrim = GetSceneObjectPart(primID);
RootPrim.ParentGroup.CreateScriptInstances(0, false, DefaultScriptEngine, 1);
return true;
}
return true;
}
public bool IncomingCreateObject(ISceneObject sog)
{
//m_log.Debug(" >>> IncomingCreateObject <<< " + ((SceneObjectGroup)sog).AbsolutePosition + " deleted? " + ((SceneObjectGroup)sog).IsDeleted);
@ -3350,7 +3270,6 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.OnCloseAgentConnection += IncomingCloseAgent;
//m_eventManager.OnRegionUp += OtherRegionUp;
//m_sceneGridService.OnChildAgentUpdate += IncomingChildAgentDataUpdate;
m_sceneGridService.OnExpectPrim += IncomingInterRegionPrimGroup;
//m_sceneGridService.OnRemoveKnownRegionFromAvatar += HandleRemoveKnownRegionsFromAvatar;
m_sceneGridService.OnLogOffUser += HandleLogOffUserFromGrid;
m_sceneGridService.KiPrimitive += SendKillObject;
@ -3374,7 +3293,6 @@ namespace OpenSim.Region.Framework.Scenes
m_sceneGridService.KiPrimitive -= SendKillObject;
m_sceneGridService.OnLogOffUser -= HandleLogOffUserFromGrid;
//m_sceneGridService.OnRemoveKnownRegionFromAvatar -= HandleRemoveKnownRegionsFromAvatar;
m_sceneGridService.OnExpectPrim -= IncomingInterRegionPrimGroup;
//m_sceneGridService.OnChildAgentUpdate -= IncomingChildAgentDataUpdate;
//m_eventManager.OnRegionUp -= OtherRegionUp;
m_sceneGridService.OnExpectUser -= HandleNewUserConnection;

View File

@ -85,7 +85,6 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary>
/// A Prim will arrive shortly
/// </summary>
public event ExpectPrimDelegate OnExpectPrim;
public event CloseAgentConnection OnCloseAgentConnection;
/// <summary>
@ -116,7 +115,6 @@ namespace OpenSim.Region.Framework.Scenes
private AgentCrossing handlerAvatarCrossingIntoRegion = null; // OnAvatarCrossingIntoRegion;
private ExpectUserDelegate handlerExpectUser = null; // OnExpectUser;
private ExpectPrimDelegate handlerExpectPrim = null; // OnExpectPrim;
private CloseAgentConnection handlerCloseAgentConnection = null; // OnCloseAgentConnection;
private PrimCrossing handlerPrimCrossingIntoRegion = null; // OnPrimCrossingIntoRegion;
//private RegionUp handlerRegionUp = null; // OnRegionUp;
@ -147,30 +145,6 @@ namespace OpenSim.Region.Framework.Scenes
/// <exception cref="System.Exception">Thrown if region registration fails.</exception>
public void RegisterRegion(IInterregionCommsOut comms_out, RegionInfo regionInfos)
{
//m_interregionCommsOut = comms_out;
//m_regionInfo = regionInfos;
//m_commsProvider.GridService.gdebugRegionName = regionInfos.RegionName;
//regionCommsHost = m_commsProvider.GridService.RegisterRegion(m_regionInfo);
//if (regionCommsHost != null)
//{
// //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got" + regionCommsHost.ToString());
// regionCommsHost.debugRegionName = regionInfos.RegionName;
// regionCommsHost.OnExpectPrim += IncomingPrimCrossing;
// regionCommsHost.OnExpectUser += NewUserConnection;
// regionCommsHost.OnAvatarCrossingIntoRegion += AgentCrossing;
// regionCommsHost.OnCloseAgentConnection += CloseConnection;
// regionCommsHost.OnRegionUp += newRegionUp;
// regionCommsHost.OnChildAgentUpdate += ChildAgentUpdate;
// regionCommsHost.OnLogOffUser += GridLogOffUser;
// regionCommsHost.OnGetLandData += FetchLandData;
//}
//else
//{
// //m_log.Info("[INTER]: " + debugRegionName + ": SceneCommunicationService: registered with gridservice and got null");
//}
}
/// <summary>
@ -179,31 +153,6 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public void Close()
{
//if (regionCommsHost != null)
//{
// regionCommsHost.OnLogOffUser -= GridLogOffUser;
// regionCommsHost.OnChildAgentUpdate -= ChildAgentUpdate;
// regionCommsHost.OnRegionUp -= newRegionUp;
// regionCommsHost.OnExpectUser -= NewUserConnection;
// regionCommsHost.OnExpectPrim -= IncomingPrimCrossing;
// regionCommsHost.OnAvatarCrossingIntoRegion -= AgentCrossing;
// regionCommsHost.OnCloseAgentConnection -= CloseConnection;
// regionCommsHost.OnGetLandData -= FetchLandData;
// try
// {
// m_commsProvider.GridService.DeregisterRegion(m_regionInfo);
// }
// catch (Exception e)
// {
// m_log.ErrorFormat(
// "[GRID]: Deregistration of region {0} from the grid failed - {1}. Continuing",
// m_regionInfo.RegionName, e);
// }
// regionCommsHost = null;
//}
}
#region CommsManager Event handlers
@ -263,27 +212,6 @@ namespace OpenSim.Region.Framework.Scenes
}
}
/// <summary>
/// We have a new prim from a neighbor
/// </summary>
/// <param name="primID">unique ID for the primative</param>
/// <param name="objXMLData">XML2 encoded data of the primative</param>
/// <param name="XMLMethod">An Int that represents the version of the XMLMethod</param>
/// <returns>True if the prim was accepted, false if it was not</returns>
protected bool IncomingPrimCrossing(UUID primID, String objXMLData, int XMLMethod)
{
handlerExpectPrim = OnExpectPrim;
if (handlerExpectPrim != null)
{
return handlerExpectPrim(primID, objXMLData, XMLMethod);
}
else
{
return false;
}
}
protected void PrimCrossing(UUID primID, Vector3 position, bool isPhysical)
{
handlerPrimCrossingIntoRegion = OnPrimCrossingIntoRegion;

View File

@ -241,24 +241,24 @@ namespace OpenSim.Region.Framework.Scenes
/// Save the current scene to an OpenSimulator archive. This archive will eventually include the prim's assets
/// as well as the details of the prims themselves.
/// </summary>
/// <param name="filename"></param>
public void SaveCurrentSceneToArchive(string filename)
/// <param name="cmdparams"></param>
public void SaveCurrentSceneToArchive(string[] cmdparams)
{
IRegionArchiverModule archiver = CurrentOrFirstScene.RequestModuleInterface<IRegionArchiverModule>();
if (archiver != null)
archiver.ArchiveRegion(filename);
archiver.HandleSaveOarConsoleCommand(string.Empty, cmdparams);
}
/// <summary>
/// Load an OpenSim archive into the current scene. This will load both the shapes of the prims and upload
/// their assets to the asset service.
/// </summary>
/// <param name="filename"></param>
public void LoadArchiveToCurrentScene(string filename)
/// <param name="cmdparams"></param>
public void LoadArchiveToCurrentScene(string[] cmdparams)
{
IRegionArchiverModule archiver = CurrentOrFirstScene.RequestModuleInterface<IRegionArchiverModule>();
if (archiver != null)
archiver.DearchiveRegion(filename);
archiver.HandleLoadOarConsoleCommand(string.Empty, cmdparams);
}
public string SaveCurrentSceneMapToXmlString()

View File

@ -309,26 +309,15 @@ namespace OpenSim.Region.Framework.Scenes
public string GetStateSnapshot()
{
//m_log.Debug(" >>> GetStateSnapshot <<<");
List<string> assemblies = new List<string>();
Dictionary<UUID, string> states = new Dictionary<UUID, string>();
foreach (SceneObjectPart part in m_parts.Values)
{
foreach (string a in part.Inventory.GetScriptAssemblies())
{
if (a != "" && !assemblies.Contains(a))
assemblies.Add(a);
}
foreach (KeyValuePair<UUID, string> s in part.Inventory.GetScriptStates())
{
states[s.Key] = s.Value;
}
}
if (states.Count < 1 || assemblies.Count < 1)
if (states.Count < 1)
return "";
XmlDocument xmldoc = new XmlDocument();
@ -342,104 +331,49 @@ namespace OpenSim.Region.Framework.Scenes
xmldoc.AppendChild(rootElement);
XmlElement wrapper = xmldoc.CreateElement("", "Assemblies",
"");
rootElement.AppendChild(wrapper);
foreach (string assembly in assemblies)
{
string fn = Path.GetFileName(assembly);
if (fn == String.Empty)
continue;
String filedata = String.Empty;
if (File.Exists(assembly+".text"))
{
FileInfo tfi = new FileInfo(assembly+".text");
if (tfi == null)
continue;
Byte[] tdata = new Byte[tfi.Length];
try
{
FileStream tfs = File.Open(assembly+".text", FileMode.Open, FileAccess.Read);
tfs.Read(tdata, 0, tdata.Length);
tfs.Close();
}
catch (Exception e)
{
m_log.DebugFormat("[SOG]: Unable to open script textfile {0}, reason: {1}", assembly+".text", e.Message);
}
filedata = new System.Text.ASCIIEncoding().GetString(tdata);
}
else
{
FileInfo fi = new FileInfo(assembly);
if (fi == null)
continue;
Byte[] data = new Byte[fi.Length];
try
{
FileStream fs = File.Open(assembly, FileMode.Open, FileAccess.Read);
fs.Read(data, 0, data.Length);
fs.Close();
}
catch (Exception e)
{
m_log.DebugFormat("[SOG]: Unable to open script assembly {0}, reason: {1}", assembly, e.Message);
}
filedata = System.Convert.ToBase64String(data);
}
XmlElement assemblyData = xmldoc.CreateElement("", "Assembly", "");
XmlAttribute assemblyName = xmldoc.CreateAttribute("", "Filename", "");
assemblyName.Value = fn;
assemblyData.Attributes.Append(assemblyName);
assemblyData.InnerText = filedata;
wrapper.AppendChild(assemblyData);
}
wrapper = xmldoc.CreateElement("", "ScriptStates",
XmlElement wrapper = xmldoc.CreateElement("", "ScriptStates",
"");
rootElement.AppendChild(wrapper);
foreach (KeyValuePair<UUID, string> state in states)
{
XmlElement stateData = xmldoc.CreateElement("", "State", "");
XmlAttribute stateID = xmldoc.CreateAttribute("", "UUID", "");
stateID.Value = state.Key.ToString();
stateData.Attributes.Append(stateID);
XmlDocument sdoc = new XmlDocument();
sdoc.LoadXml(state.Value);
XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState");
XmlNodeList rootL = sdoc.GetElementsByTagName("State");
XmlNode rootNode = rootL[0];
XmlNode newNode = xmldoc.ImportNode(rootNode, true);
stateData.AppendChild(newNode);
wrapper.AppendChild(stateData);
wrapper.AppendChild(newNode);
}
return xmldoc.InnerXml;
}
public void SetState(string objXMLData, UUID RegionID)
public void SetState(string objXMLData, IScene ins)
{
if (!(ins is Scene))
return;
Scene s = (Scene)ins;
if (objXMLData == String.Empty)
return;
IScriptModule scriptModule = null;
foreach (IScriptModule sm in s.RequestModuleInterfaces<IScriptModule>())
{
if (sm.ScriptEngineName == s.DefaultScriptEngine)
scriptModule = sm;
else if (scriptModule == null)
scriptModule = sm;
}
if (scriptModule == null)
return;
XmlDocument doc = new XmlDocument();
try
{
@ -457,69 +391,23 @@ namespace OpenSim.Region.Framework.Scenes
}
XmlNodeList rootL = doc.GetElementsByTagName("ScriptData");
if (rootL.Count == 1)
if (rootL.Count != 1)
return;
XmlElement rootE = (XmlElement)rootL[0];
XmlNodeList dataL = rootE.GetElementsByTagName("ScriptStates");
if (dataL.Count != 1)
return;
XmlElement dataE = (XmlElement)dataL[0];
foreach (XmlNode n in dataE.ChildNodes)
{
XmlNode rootNode = rootL[0];
if (rootNode != null)
{
XmlNodeList partL = rootNode.ChildNodes;
XmlElement stateE = (XmlElement)n;
UUID itemID = new UUID(stateE.GetAttribute("UUID"));
foreach (XmlNode part in partL)
{
XmlNodeList nodeL = part.ChildNodes;
switch (part.Name)
{
case "Assemblies":
foreach (XmlNode asm in nodeL)
{
string fn = asm.Attributes.GetNamedItem("Filename").Value;
Byte[] filedata = Convert.FromBase64String(asm.InnerText);
string path = Path.Combine("ScriptEngines", RegionID.ToString());
path = Path.Combine(path, fn);
if (!File.Exists(path))
{
FileStream fs = File.Create(path);
fs.Write(filedata, 0, filedata.Length);
fs.Close();
Byte[] textbytes = new System.Text.ASCIIEncoding().GetBytes(asm.InnerText);
fs = File.Create(path+".text");
fs.Write(textbytes, 0, textbytes.Length);
fs.Close();
}
}
break;
case "ScriptStates":
foreach (XmlNode st in nodeL)
{
string id = st.Attributes.GetNamedItem("UUID").Value;
UUID uuid = new UUID(id);
XmlNode state = st.ChildNodes[0];
XmlDocument sdoc = new XmlDocument();
XmlNode sxmlnode = sdoc.CreateNode(
XmlNodeType.XmlDeclaration,
"", "");
sdoc.AppendChild(sxmlnode);
XmlNode newnode = sdoc.ImportNode(state, true);
sdoc.AppendChild(newnode);
string spath = Path.Combine("ScriptEngines", RegionID.ToString());
spath = Path.Combine(spath, uuid.ToString());
FileStream sfs = File.Create(spath + ".state");
System.Text.ASCIIEncoding enc = new System.Text.ASCIIEncoding();
Byte[] buf = enc.GetBytes(sdoc.InnerXml);
sfs.Write(buf, 0, buf.Length);
sfs.Close();
}
break;
}
}
}
scriptModule.SetXMLState(itemID, n.OuterXml);
}
}
}

View File

@ -3380,17 +3380,6 @@ namespace OpenSim.Region.Framework.Scenes
}
#endregion
public bool CanBeDeleted()
{
foreach (SceneObjectPart part in Children.Values)
{
if (!part.CanBeDeleted())
return false;
}
return true;
}
public double GetUpdatePriority(IClientAPI client)
{
switch (Scene.UpdatePrioritizationScheme)

View File

@ -389,12 +389,16 @@ namespace OpenSim.Region.Framework.Scenes
}
/// <value>
/// Access should be via Inventory directly - this property temporarily remains for xml serialization purposes
/// Get the inventory list
/// </value>
public TaskInventoryDictionary TaskInventory
{
get { return m_inventory.Items; }
set { m_inventory.Items = value; }
get {
return m_inventory.Items;
}
set {
m_inventory.Items = value;
}
}
public uint ObjectFlags
@ -2101,8 +2105,8 @@ namespace OpenSim.Region.Framework.Scenes
//Trys to fetch sound id from prim's inventory.
//Prim's inventory doesn't support non script items yet
lock (TaskInventory)
{
TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
{
if (item.Value.Name == sound)
@ -2111,7 +2115,8 @@ namespace OpenSim.Region.Framework.Scenes
break;
}
}
}
TaskInventory.LockItemsForRead(false);
}
List<ScenePresence> avatarts = m_parentGroup.Scene.GetAvatars();
@ -2457,8 +2462,7 @@ namespace OpenSim.Region.Framework.Scenes
if (!UUID.TryParse(sound, out soundID))
{
// search sound file from inventory
lock (TaskInventory)
{
TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> item in TaskInventory)
{
if (item.Value.Name == sound && item.Value.Type == (int)AssetType.Sound)
@ -2467,7 +2471,7 @@ namespace OpenSim.Region.Framework.Scenes
break;
}
}
}
TaskInventory.LockItemsForRead(false);
}
if (soundID == UUID.Zero)
@ -3803,10 +3807,5 @@ namespace OpenSim.Region.Framework.Scenes
Inventory.ApplyNextOwnerPermissions();
}
public bool CanBeDeleted()
{
return Inventory.CanBeDeleted();
}
}
}

View File

@ -80,7 +80,9 @@ namespace OpenSim.Region.Framework.Scenes
/// </value>
protected internal TaskInventoryDictionary Items
{
get { return m_items; }
get {
return m_items;
}
set
{
m_items = value;
@ -116,10 +118,13 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="linkNum">Link number for the part</param>
public void ResetInventoryIDs()
{
lock (Items)
{
m_items.LockItemsForWrite(true);
if (0 == Items.Count)
{
m_items.LockItemsForWrite(false);
return;
}
HasInventoryChanged = true;
m_part.ParentGroup.HasGroupChanged = true;
@ -131,7 +136,7 @@ namespace OpenSim.Region.Framework.Scenes
item.ResetIDs(m_part.UUID);
Items.Add(item.ItemID, item);
}
}
m_items.LockItemsForWrite(false);
}
/// <summary>
@ -140,10 +145,10 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="ownerId"></param>
public void ChangeInventoryOwner(UUID ownerId)
{
lock (Items)
{
m_items.LockItemsForWrite(true);
if (0 == Items.Count)
{
m_items.LockItemsForWrite(false);
return;
}
@ -158,7 +163,7 @@ namespace OpenSim.Region.Framework.Scenes
item.OwnerID = ownerId;
}
}
}
m_items.LockItemsForWrite(false);
}
/// <summary>
@ -167,10 +172,10 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="groupID"></param>
public void ChangeInventoryGroup(UUID groupID)
{
lock (Items)
{
m_items.LockItemsForWrite(true);
if (0 == Items.Count)
{
m_items.LockItemsForWrite(false);
return;
}
@ -184,7 +189,7 @@ namespace OpenSim.Region.Framework.Scenes
item.GroupID = groupID;
}
}
}
m_items.LockItemsForWrite(false);
}
/// <summary>
@ -192,9 +197,10 @@ namespace OpenSim.Region.Framework.Scenes
/// </summary>
public void CreateScriptInstances(int startParam, bool postOnRez, string engine, int stateSource)
{
lock (m_items)
{
foreach (TaskInventoryItem item in Items.Values)
Items.LockItemsForRead(true);
IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
Items.LockItemsForRead(false);
foreach (TaskInventoryItem item in items)
{
if ((int)InventoryType.LSL == item.InvType)
{
@ -202,16 +208,17 @@ namespace OpenSim.Region.Framework.Scenes
}
}
}
}
/// <summary>
/// Stop all the scripts in this prim.
/// </summary>
public void RemoveScriptInstances()
{
lock (Items)
{
foreach (TaskInventoryItem item in Items.Values)
Items.LockItemsForRead(true);
IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
Items.LockItemsForRead(false);
foreach (TaskInventoryItem item in items)
{
if ((int)InventoryType.LSL == item.InvType)
{
@ -219,7 +226,8 @@ namespace OpenSim.Region.Framework.Scenes
m_part.RemoveScriptEvents(item.ItemID);
}
}
}
}
/// <summary>
@ -244,8 +252,10 @@ namespace OpenSim.Region.Framework.Scenes
if (stateSource == 1 && // Prim crossing
m_part.ParentGroup.Scene.m_trustBinaries)
{
m_items.LockItemsForWrite(true);
m_items[item.ItemID].PermsMask = 0;
m_items[item.ItemID].PermsGranter = UUID.Zero;
m_items.LockItemsForWrite(false);
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
m_part.LocalId, item.ItemID, String.Empty, startParam, postOnRez, engine, stateSource);
m_part.ParentGroup.AddActiveScriptCount(1);
@ -266,8 +276,10 @@ namespace OpenSim.Region.Framework.Scenes
{
if (m_part.ParentGroup.m_savedScriptState != null)
RestoreSavedScriptState(item.OldItemID, item.ItemID);
m_items.LockItemsForWrite(true);
m_items[item.ItemID].PermsMask = 0;
m_items[item.ItemID].PermsGranter = UUID.Zero;
m_items.LockItemsForWrite(false);
string script = Utils.BytesToString(asset.Data);
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
@ -302,20 +314,22 @@ namespace OpenSim.Region.Framework.Scenes
/// </param>
public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
{
lock (m_items)
{
m_items.LockItemsForRead(true);
if (m_items.ContainsKey(itemId))
{
CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource);
TaskInventoryItem item = m_items[itemId];
m_items.LockItemsForRead(false);
CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
}
else
{
m_items.LockItemsForRead(false);
m_log.ErrorFormat(
"[PRIM INVENTORY]: " +
"Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2}",
itemId, m_part.Name, m_part.UUID);
}
}
}
/// <summary>
@ -346,11 +360,16 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns></returns>
private bool InventoryContainsName(string name)
{
foreach (TaskInventoryItem item in Items.Values)
m_items.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.Name == name)
{
m_items.LockItemsForRead(false);
return true;
}
}
m_items.LockItemsForRead(false);
return false;
}
@ -392,7 +411,9 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="item"></param>
public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop)
{
m_items.LockItemsForRead(true);
List<TaskInventoryItem> il = new List<TaskInventoryItem>(m_items.Values);
m_items.LockItemsForRead(false);
foreach (TaskInventoryItem i in il)
{
if (i.Name == item.Name)
@ -429,15 +450,14 @@ namespace OpenSim.Region.Framework.Scenes
item.ParentPartID = m_part.UUID;
item.Name = name;
lock (m_items)
{
m_items.LockItemsForWrite(true);
m_items.Add(item.ItemID, item);
m_items.LockItemsForWrite(false);
if (allowedDrop)
m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP);
else
m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
}
m_inventorySerial++;
//m_inventorySerial += 2;
@ -454,14 +474,13 @@ namespace OpenSim.Region.Framework.Scenes
/// <param name="items"></param>
public void RestoreInventoryItems(ICollection<TaskInventoryItem> items)
{
lock (m_items)
{
m_items.LockItemsForWrite(true);
foreach (TaskInventoryItem item in items)
{
m_items.Add(item.ItemID, item);
m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
}
}
m_items.LockItemsForWrite(false);
m_inventorySerial++;
}
@ -474,8 +493,9 @@ namespace OpenSim.Region.Framework.Scenes
public TaskInventoryItem GetInventoryItem(UUID itemId)
{
TaskInventoryItem item;
m_items.LockItemsForRead(true);
m_items.TryGetValue(itemId, out item);
m_items.LockItemsForRead(false);
return item;
}
@ -487,8 +507,8 @@ namespace OpenSim.Region.Framework.Scenes
/// <returns>false if the item did not exist, true if the update occurred successfully</returns>
public bool UpdateInventoryItem(TaskInventoryItem item)
{
lock (m_items)
{
m_items.LockItemsForWrite(true);
if (m_items.ContainsKey(item.ItemID))
{
item.ParentID = m_part.UUID;
@ -515,7 +535,7 @@ namespace OpenSim.Region.Framework.Scenes
HasInventoryChanged = true;
m_part.ParentGroup.HasGroupChanged = true;
m_items.LockItemsForWrite(false);
return true;
}
else
@ -525,7 +545,7 @@ namespace OpenSim.Region.Framework.Scenes
"Tried to retrieve item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
item.ItemID, m_part.Name, m_part.UUID);
}
}
m_items.LockItemsForWrite(false);
return false;
}
@ -538,16 +558,19 @@ namespace OpenSim.Region.Framework.Scenes
/// in this prim's inventory.</returns>
public int RemoveInventoryItem(UUID itemID)
{
lock (m_items)
{
m_items.LockItemsForRead(true);
if (m_items.ContainsKey(itemID))
{
int type = m_items[itemID].InvType;
m_items.LockItemsForRead(false);
if (type == 10) // Script
{
m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID);
}
m_items.LockItemsForWrite(true);
m_items.Remove(itemID);
m_items.LockItemsForWrite(false);
m_inventorySerial++;
m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
@ -555,8 +578,7 @@ namespace OpenSim.Region.Framework.Scenes
m_part.ParentGroup.HasGroupChanged = true;
int scriptcount = 0;
lock (m_items)
{
m_items.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.Type == 10)
@ -564,7 +586,8 @@ namespace OpenSim.Region.Framework.Scenes
scriptcount++;
}
}
}
m_items.LockItemsForRead(false);
if (scriptcount <= 0)
{
@ -582,7 +605,7 @@ namespace OpenSim.Region.Framework.Scenes
"Tried to remove item ID {0} from prim {1}, {2} but the item does not exist in this inventory",
itemID, m_part.Name, m_part.UUID);
}
}
m_items.LockItemsForWrite(false);
return -1;
}
@ -635,8 +658,8 @@ namespace OpenSim.Region.Framework.Scenes
// isn't available (such as drag from prim inventory to agent inventory)
InventoryStringBuilder invString = new InventoryStringBuilder(m_part.UUID, UUID.Zero);
lock (m_items)
{
m_items.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_items.Values)
{
UUID ownerID = item.OwnerID;
@ -680,7 +703,8 @@ namespace OpenSim.Region.Framework.Scenes
invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
invString.AddSectionEnd();
}
}
int count = m_items.Count;
m_items.LockItemsForRead(false);
fileData = Utils.StringToBytes(invString.BuildString);
@ -701,10 +725,9 @@ namespace OpenSim.Region.Framework.Scenes
{
if (HasInventoryChanged)
{
lock (Items)
{
Items.LockItemsForRead(true);
datastore.StorePrimInventory(m_part.UUID, Items.Values);
}
Items.LockItemsForRead(false);
HasInventoryChanged = false;
}
@ -857,36 +880,6 @@ namespace OpenSim.Region.Framework.Scenes
return ret;
}
public string[] GetScriptAssemblies()
{
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
List<string> ret = new List<string>();
if (engines == null) // No engine at all
return new string[0];
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.InvType == (int)InventoryType.LSL)
{
foreach (IScriptModule e in engines)
{
if (e != null)
{
string n = e.GetAssemblyName(item.ItemID);
if (n != String.Empty)
{
if (!ret.Contains(n))
ret.Add(n);
break;
}
}
}
}
}
return ret.ToArray();
}
public Dictionary<UUID, string> GetScriptStates()
{
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
@ -916,30 +909,5 @@ namespace OpenSim.Region.Framework.Scenes
}
return ret;
}
public bool CanBeDeleted()
{
if (!ContainsScripts())
return true;
IScriptModule[] engines = m_part.ParentGroup.Scene.RequestModuleInterfaces<IScriptModule>();
if (engines == null) // No engine at all
return true;
foreach (TaskInventoryItem item in m_items.Values)
{
if (item.InvType == (int)InventoryType.LSL)
{
foreach (IScriptModule e in engines)
{
if (!e.CanBeDeleted(item.ItemID))
return false;
}
}
}
return true;
}
}
}

View File

@ -171,7 +171,7 @@ namespace OpenSim.Region.Framework.Scenes
protected RegionInfo m_regionInfo;
protected ulong crossingFromRegion;
private readonly Vector3[] Dir_Vectors = new Vector3[9];
private readonly Vector3[] Dir_Vectors = new Vector3[11];
private bool m_isNudging = false;
// Position of agent's camera in world (region cordinates)
@ -241,6 +241,8 @@ namespace OpenSim.Region.Framework.Scenes
DIR_CONTROL_FLAG_DOWN = AgentManager.ControlFlags.AGENT_CONTROL_UP_NEG,
DIR_CONTROL_FLAG_FORWARD_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_POS,
DIR_CONTROL_FLAG_BACK_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_AT_NEG,
DIR_CONTROL_FLAG_LEFT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_POS,
DIR_CONTROL_FLAG_RIGHT_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_LEFT_NEG,
DIR_CONTROL_FLAG_DOWN_NUDGE = AgentManager.ControlFlags.AGENT_CONTROL_NUDGE_UP_NEG
}
@ -725,12 +727,14 @@ namespace OpenSim.Region.Framework.Scenes
Dir_Vectors[5] = -Vector3.UnitZ; //DOWN
Dir_Vectors[6] = new Vector3(0.5f, 0f, 0f); //FORWARD_NUDGE
Dir_Vectors[7] = new Vector3(-0.5f, 0f, 0f); //BACK_NUDGE
Dir_Vectors[8] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
Dir_Vectors[8] = new Vector3(0f, 0.5f, 0f); //LEFT_NUDGE
Dir_Vectors[9] = new Vector3(0f, -0.5f, 0f); //RIGHT_NUDGE
Dir_Vectors[10] = new Vector3(0f, 0f, -0.5f); //DOWN_Nudge
}
private Vector3[] GetWalkDirectionVectors()
{
Vector3[] vector = new Vector3[9];
Vector3[] vector = new Vector3[11];
vector[0] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD
vector[1] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK
vector[2] = Vector3.UnitY; //LEFT
@ -739,13 +743,15 @@ namespace OpenSim.Region.Framework.Scenes
vector[5] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN
vector[6] = new Vector3(m_CameraUpAxis.Z, 0f, -m_CameraAtAxis.Z); //FORWARD_NUDGE
vector[7] = new Vector3(-m_CameraUpAxis.Z, 0f, m_CameraAtAxis.Z); //BACK_NUDGE
vector[8] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_Nudge
vector[8] = Vector3.UnitY; //LEFT_NUDGE
vector[9] = -Vector3.UnitY; //RIGHT_NUDGE
vector[10] = new Vector3(-m_CameraAtAxis.Z, 0f, -m_CameraUpAxis.Z); //DOWN_NUDGE
return vector;
}
private bool[] GetDirectionIsNudge()
{
bool[] isNudge = new bool[9];
bool[] isNudge = new bool[11];
isNudge[0] = false; //FORWARD
isNudge[1] = false; //BACK
isNudge[2] = false; //LEFT
@ -754,7 +760,9 @@ namespace OpenSim.Region.Framework.Scenes
isNudge[5] = false; //DOWN
isNudge[6] = true; //FORWARD_NUDGE
isNudge[7] = true; //BACK_NUDGE
isNudge[8] = true; //DOWN_Nudge
isNudge[8] = true; //LEFT_NUDGE
isNudge[9] = true; //RIGHT_NUDGE
isNudge[10] = true; //DOWN_Nudge
return isNudge;
}
@ -1618,10 +1626,9 @@ namespace OpenSim.Region.Framework.Scenes
SceneObjectPart part = m_scene.GetSceneObjectPart(m_parentID);
if (part != null)
{
part.TaskInventory.LockItemsForRead(true);
TaskInventoryDictionary taskIDict = part.TaskInventory;
if (taskIDict != null)
{
lock (taskIDict)
{
foreach (UUID taskID in taskIDict.Keys)
{
@ -1631,8 +1638,7 @@ namespace OpenSim.Region.Framework.Scenes
4); // PERMISSION_TAKE_CONTROLS
}
}
}
part.TaskInventory.LockItemsForRead(false);
// Reset sit target.
if (part.GetAvatarOnSitTarget() == UUID)
part.SetAvatarOnSitTarget(UUID.Zero);

View File

@ -82,6 +82,7 @@ namespace OpenSim.Region.Framework.Scenes
private int m_fps = 0;
// saved last reported value so there is something available for llGetRegionFPS
private float lastReportedSimFPS = 0;
private float[] lastReportedSimStats = new float[21];
private float m_pfps = 0;
private int m_agentUpdates = 0;
@ -260,6 +261,11 @@ namespace OpenSim.Region.Framework.Scenes
sb[20].StatID = (uint)Stats.ScriptLinesPerSecond;
sb[20].StatValue = m_scriptLinesPerSecond / statsUpdateFactor;
for (int i = 0; i < 21; i++)
{
lastReportedSimStats[i] = sb[i].StatValue;
}
SimStats simStats
= new SimStats(
ReportingRegion.RegionLocX, ReportingRegion.RegionLocY, regionFlags, (uint)objectCapacity, rb, sb, m_scene.RegionInfo.originRegionID);
@ -439,6 +445,11 @@ namespace OpenSim.Region.Framework.Scenes
return lastReportedSimFPS;
}
public float[] getLastReportedSimStats()
{
return lastReportedSimStats;
}
public void AddPacketsStats(int inPackets, int outPackets, int unAckedBytes)
{
AddInPackets(inPackets);

View File

@ -62,7 +62,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
public void Initialise(IConfigSource config)
{
m_log.Info("[RegionReady] Initialising");
//m_log.Info("[RegionReady] Initialising");
m_config = config.Configs["RegionReady"];
if (m_config != null)
@ -74,8 +74,8 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
}
}
if (!m_enabled)
m_log.Info("[RegionReady] disabled.");
// if (!m_enabled)
// m_log.Info("[RegionReady] disabled.");
}
public void AddRegion(Scene scene)
@ -92,7 +92,7 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
m_scene.EventManager.OnEmptyScriptCompileQueue += OnEmptyScriptCompileQueue;
m_scene.EventManager.OnOarFileLoaded += OnOarFileLoaded;
m_log.InfoFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName);
m_log.DebugFormat("[RegionReady]: Enabled for region {0}", scene.RegionInfo.RegionName);
}
public void RemoveRegion(Scene scene)
@ -121,7 +121,6 @@ namespace OpenSim.Region.OptionalModules.Scripting.RegionReady
#endregion
void OnEmptyScriptCompileQueue(int numScriptsFailed, string message)
{
if (m_firstEmptyCompileQueue || m_oarFileLoading)

View File

@ -835,7 +835,7 @@ namespace OpenSim.Region.Physics.OdePlugin
// allows us to have different settings
// We only need to test p2 for 'jump crouch purposes'
if (p2 is OdeCharacter)
if (p2 is OdeCharacter && p1.PhysicsActorType == (int)ActorTypes.Prim)
{
// Testing if the collision is at the feet of the avatar

View File

@ -118,6 +118,7 @@ public class RegionCombinerLargeLandChannel : ILandChannel
return regionData.RegionScene.LandChannel.GetLandObject(x - offsetX, y - offsetY);
}
}
ILandObject obj = new LandObject(UUID.Zero, false, RegData.RegionScene);
obj.LandData.Name = "NO LAND";
return obj;

View File

@ -96,7 +96,6 @@ namespace OpenSim.Region.ScriptEngine.Interfaces
UUID GetDetectID(int idx);
void SaveState(string assembly);
void DestroyScriptInstance();
bool CanBeDeleted();
IScriptApi GetApi(string name);

View File

@ -28,6 +28,7 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics; //for [DebuggerNonUserCode]
using System.Runtime.Remoting.Lifetime;
using System.Text;
using System.Threading;
@ -151,6 +152,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
get { return m_ScriptEngine.World; }
}
[DebuggerNonUserCode]
public void state(string newState)
{
m_ScriptEngine.SetState(m_itemID, newState);
@ -160,6 +162,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
/// Reset the named script. The script must be present
/// in the same prim.
/// </summary>
[DebuggerNonUserCode]
public void llResetScript()
{
m_host.AddScriptLPS(1);
@ -272,9 +275,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected UUID InventorySelf()
{
UUID invItemID = new UUID();
lock (m_host.TaskInventory)
bool unlock = false;
if (!m_host.TaskInventory.IsReadLockedByMe())
{
m_host.TaskInventory.LockItemsForRead(true);
unlock = true;
}
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Type == 10 && inv.Value.ItemID == m_itemID)
@ -283,29 +289,34 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
}
}
if (unlock)
{
m_host.TaskInventory.LockItemsForRead(false);
}
return invItemID;
}
protected UUID InventoryKey(string name, int type)
{
m_host.AddScriptLPS(1);
m_host.TaskInventory.LockItemsForRead(true);
lock (m_host.TaskInventory)
{
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == name)
{
m_host.TaskInventory.LockItemsForRead(false);
if (inv.Value.Type != type)
{
return UUID.Zero;
}
return inv.Value.AssetID;
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero;
}
@ -313,16 +324,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == name)
{
m_host.TaskInventory.LockItemsForRead(false);
return inv.Value.AssetID;
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero;
}
@ -1987,6 +2002,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
//KF: Do NOT use this next line if using ODE physics engine. This need a switch based on .ini Phys Engine type
// part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition;
// So, after thinking about this for a bit, the issue with the part.ParentGroup.AbsolutePosition = part.ParentGroup.AbsolutePosition line
// is it isn't compatible with vehicles because it causes the vehicle body to have to be broken down and rebuilt
// It's perfectly okay when the object is not an active physical body though.
// So, part.ParentGroup.ResetChildPrimPhysicsPositions(); does the thing that Kitto is warning against
// but only if the object is not physial and active. This is important for rotating doors.
// without the absoluteposition = absoluteposition happening, the doors do not move in the physics
// scene
if (part.PhysActor != null && !part.PhysActor.IsPhysical)
{
part.ParentGroup.ResetChildPrimPhysicsPositions();
}
}
/// <summary>
@ -2534,12 +2561,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
m_host.TaskInventory.LockItemsForRead(true);
TaskInventoryItem item = m_host.TaskInventory[invItemID];
lock (m_host.TaskInventory)
{
item = m_host.TaskInventory[invItemID];
}
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter == UUID.Zero)
return 0;
@ -2614,6 +2638,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (dist > m_ScriptDistanceFactor * 10.0f)
return;
//Clone is thread-safe
TaskInventoryDictionary partInventory = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in partInventory)
@ -2747,13 +2772,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
TaskInventoryItem item;
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[InventorySelf()];
}
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter != UUID.Zero)
{
@ -2775,13 +2804,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
TaskInventoryItem item;
m_host.TaskInventory.LockItemsForRead(true);
lock (m_host.TaskInventory)
{
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[InventorySelf()];
}
}
m_host.TaskInventory.LockItemsForRead(false);
m_host.AddScriptLPS(1);
@ -2818,14 +2855,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[InventorySelf()];
}
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter != m_host.OwnerID)
return;
@ -2850,13 +2893,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[InventorySelf()];
}
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter != m_host.OwnerID)
return;
@ -3080,14 +3129,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[InventorySelf()];
}
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter == UUID.Zero)
return;
@ -3117,13 +3169,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
if (!m_host.TaskInventory.ContainsKey(InventorySelf()))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[InventorySelf()];
}
m_host.TaskInventory.LockItemsForRead(false);
if (item.PermsGranter == UUID.Zero)
return;
@ -3196,10 +3253,18 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryItem item;
lock (m_host.TaskInventory)
m_host.TaskInventory.LockItemsForRead(true);
if (!m_host.TaskInventory.ContainsKey(invItemID))
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
else
{
item = m_host.TaskInventory[invItemID];
}
m_host.TaskInventory.LockItemsForRead(false);
if (agentID == UUID.Zero || perm == 0) // Releasing permissions
{
@ -3231,11 +3296,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
{
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForWrite(true);
m_host.TaskInventory[invItemID].PermsGranter = agentID;
m_host.TaskInventory[invItemID].PermsMask = perm;
}
m_host.TaskInventory.LockItemsForWrite(false);
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"run_time_permissions", new Object[] {
@ -3255,11 +3319,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((perm & (~implicitPerms)) == 0) // Requested only implicit perms
{
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForWrite(true);
m_host.TaskInventory[invItemID].PermsGranter = agentID;
m_host.TaskInventory[invItemID].PermsMask = perm;
}
m_host.TaskInventory.LockItemsForWrite(false);
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"run_time_permissions", new Object[] {
@ -3280,11 +3343,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!m_waitingForScriptAnswer)
{
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForWrite(true);
m_host.TaskInventory[invItemID].PermsGranter = agentID;
m_host.TaskInventory[invItemID].PermsMask = 0;
}
m_host.TaskInventory.LockItemsForWrite(false);
presence.ControllingClient.OnScriptAnswer += handleScriptAnswer;
m_waitingForScriptAnswer=true;
@ -3319,10 +3381,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if ((answer & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) == 0)
llReleaseControls();
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForWrite(true);
m_host.TaskInventory[invItemID].PermsMask = answer;
}
m_host.TaskInventory.LockItemsForWrite(false);
m_ScriptEngine.PostScriptEvent(m_itemID, new EventParams(
"run_time_permissions", new Object[] {
@ -3334,16 +3397,17 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 10 && item.ItemID == m_itemID)
{
m_host.TaskInventory.LockItemsForRead(false);
return item.PermsGranter.ToString();
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero.ToString();
}
@ -3352,8 +3416,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 10 && item.ItemID == m_itemID)
@ -3361,10 +3425,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
int perms = item.PermsMask;
if (m_automaticLinkPermission)
perms |= ScriptBaseClass.PERMISSION_CHANGE_LINKS;
m_host.TaskInventory.LockItemsForRead(false);
return perms;
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
return 0;
}
@ -3397,10 +3462,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID invItemID = InventorySelf();
TaskInventoryItem item;
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
item = m_host.TaskInventory[invItemID];
}
m_host.TaskInventory.LockItemsForRead(false);
if ((item.PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
&& !m_automaticLinkPermission)
@ -3454,15 +3518,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
UUID invItemID = InventorySelf();
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CHANGE_LINKS) == 0
&& !m_automaticLinkPermission)
{
ShoutError("Script trying to link but PERMISSION_CHANGE_LINKS permission not set!");
m_host.TaskInventory.LockItemsForRead(false);
return;
}
}
m_host.TaskInventory.LockItemsForRead(false);
if (linknum < ScriptBaseClass.LINK_THIS)
return;
@ -3632,8 +3696,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
int count = 0;
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Type == type || type == -1)
@ -3641,8 +3704,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
count = count + 1;
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
return count;
}
@ -3651,8 +3714,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
ArrayList keys = new ArrayList();
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Type == type || type == -1)
@ -3660,7 +3722,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
keys.Add(inv.Value.Name);
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
if (keys.Count == 0)
{
@ -3697,8 +3759,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// move the first object found with this inventory name
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == inventory)
@ -3710,7 +3771,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
if (!found)
{
@ -3755,12 +3816,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
ScriptSleep(3000);
}
[DebuggerNonUserCode]
public void llRemoveInventory(string name)
{
m_host.AddScriptLPS(1);
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Name == name)
@ -3769,10 +3830,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
throw new ScriptDeleteException();
else
m_host.Inventory.RemoveInventoryItem(item.ItemID);
m_host.TaskInventory.LockItemsForRead(false);
return;
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
}
public void llSetText(string text, LSL_Vector color, double alpha)
@ -3861,6 +3924,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
//Clone is thread safe
TaskInventoryDictionary itemDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
foreach (TaskInventoryItem item in itemDictionary.Values)
@ -3951,8 +4015,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID soundId = UUID.Zero;
if (!UUID.TryParse(impact_sound, out soundId))
{
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == (int)AssetType.Sound && item.Name == impact_sound)
@ -3961,7 +4024,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
}
m_host.CollisionSound = soundId;
m_host.CollisionSoundVolume = (float)impact_volume;
@ -4007,6 +4070,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
UUID partItemID;
foreach (SceneObjectPart part in parts)
{
//Clone is thread safe
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)part.TaskInventory.Clone();
foreach (TaskInventoryItem item in itemsDictionary.Values)
@ -4214,8 +4278,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
m_host.AddScriptLPS(1);
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 10 && item.ItemID == m_itemID)
@ -4224,7 +4287,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
break;
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
return result;
}
@ -4482,23 +4545,24 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == name)
{
if ((inv.Value.CurrentPermissions & (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify)) == (uint)(PermissionMask.Copy | PermissionMask.Transfer | PermissionMask.Modify))
{
m_host.TaskInventory.LockItemsForRead(false);
return inv.Value.AssetID.ToString();
}
else
{
m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero.ToString();
}
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero.ToString();
}
@ -5777,6 +5841,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return World.SimulatorFPS;
}
/* particle system rules should be coming into this routine as doubles, that is
rule[0] should be an integer from this list and rule[1] should be the arg
for the same integer. wiki.secondlife.com has most of this mapping, but some
@ -5993,14 +6058,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
protected UUID GetTaskInventoryItem(string name)
{
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == name)
{
m_host.TaskInventory.LockItemsForRead(false);
return inv.Key;
}
}
m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero;
}
@ -6311,8 +6378,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// copy the first script found with this inventory name
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == name)
@ -6326,7 +6392,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
if (!found)
{
@ -8129,12 +8195,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == item)
{
m_host.TaskInventory.LockItemsForRead(false);
switch (mask)
{
case 0:
@ -8150,7 +8216,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
return -1;
}
@ -8165,16 +8231,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == item)
{
m_host.TaskInventory.LockItemsForRead(false);
return inv.Value.CreatorID.ToString();
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
llSay(0, "No item name '" + item + "'");
@ -8698,16 +8764,16 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == name)
{
m_host.TaskInventory.LockItemsForRead(false);
return inv.Value.Type;
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
return -1;
}
@ -8738,17 +8804,20 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (invItemID == UUID.Zero)
return new LSL_Vector();
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
{
m_host.TaskInventory.LockItemsForRead(false);
return new LSL_Vector();
}
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
{
ShoutError("No permissions to track the camera");
m_host.TaskInventory.LockItemsForRead(false);
return new LSL_Vector();
}
}
m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
if (presence != null)
@ -8766,17 +8835,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (invItemID == UUID.Zero)
return new LSL_Rotation();
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
if (m_host.TaskInventory[invItemID].PermsGranter == UUID.Zero)
{
m_host.TaskInventory.LockItemsForRead(false);
return new LSL_Rotation();
}
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_TRACK_CAMERA) == 0)
{
ShoutError("No permissions to track the camera");
m_host.TaskInventory.LockItemsForRead(false);
return new LSL_Rotation();
}
}
m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(m_host.OwnerID);
if (presence != null)
@ -8926,14 +8997,21 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (objectID == UUID.Zero) return;
UUID agentID;
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
// we need the permission first, to know which avatar we want to set the camera for
agentID = m_host.TaskInventory[invItemID].PermsGranter;
if (agentID == UUID.Zero) return;
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
if (agentID == UUID.Zero)
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(agentID);
@ -8983,12 +9061,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
// we need the permission first, to know which avatar we want to clear the camera for
UUID agentID;
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
agentID = m_host.TaskInventory[invItemID].PermsGranter;
if (agentID == UUID.Zero) return;
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0) return;
if (agentID == UUID.Zero)
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
if ((m_host.TaskInventory[invItemID].PermsMask & ScriptBaseClass.PERMISSION_CONTROL_CAMERA) == 0)
{
m_host.TaskInventory.LockItemsForRead(false);
return;
}
m_host.TaskInventory.LockItemsForRead(false);
ScenePresence presence = World.GetScenePresence(agentID);
@ -9445,15 +9530,19 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
internal UUID ScriptByName(string name)
{
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 10 && item.Name == name)
{
m_host.TaskInventory.LockItemsForRead(false);
return item.ItemID;
}
}
m_host.TaskInventory.LockItemsForRead(false);
return UUID.Zero;
}
@ -9494,6 +9583,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
//Clone is thread safe
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
UUID assetID = UUID.Zero;
@ -9556,6 +9646,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
{
m_host.AddScriptLPS(1);
//Clone is thread safe
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
UUID assetID = UUID.Zero;

View File

@ -636,13 +636,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
}
// Teleport functions
public void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
public void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat)
{
// High because there is no security check. High griefer potential
//
CheckThreatLevel(ThreatLevel.High, "osTeleportAgent");
ulong regionHandle = Util.UIntsToLong((regionX * (uint)Constants.RegionSize), (regionY * (uint)Constants.RegionSize));
ulong regionHandle = Util.UIntsToLong(((uint)regionX * (uint)Constants.RegionSize), ((uint)regionY * (uint)Constants.RegionSize));
m_host.AddScriptLPS(1);
UUID agentId = new UUID();
@ -728,8 +728,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (target != null)
{
UUID animID=UUID.Zero;
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == animation)
@ -739,7 +738,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
continue;
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
if (animID == UUID.Zero)
target.Animator.AddAnimation(animation, m_host.UUID);
else
@ -761,8 +760,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (target != null)
{
UUID animID=UUID.Zero;
lock (m_host.TaskInventory)
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (KeyValuePair<UUID, TaskInventoryItem> inv in m_host.TaskInventory)
{
if (inv.Value.Name == animation)
@ -772,7 +770,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
continue;
}
}
}
m_host.TaskInventory.LockItemsForRead(false);
if (animID == UUID.Zero)
target.Animator.RemoveAnimation(animation);
@ -1541,6 +1539,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(name, out assetID))
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == name)
@ -1548,6 +1547,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
assetID = item.AssetID;
}
}
m_host.TaskInventory.LockItemsForRead(false);
}
if (assetID == UUID.Zero)
@ -1594,6 +1594,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(name, out assetID))
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == name)
@ -1601,6 +1602,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
assetID = item.AssetID;
}
}
m_host.TaskInventory.LockItemsForRead(false);
}
if (assetID == UUID.Zero)
@ -1651,6 +1653,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
if (!UUID.TryParse(name, out assetID))
{
m_host.TaskInventory.LockItemsForRead(true);
foreach (TaskInventoryItem item in m_host.TaskInventory.Values)
{
if (item.Type == 7 && item.Name == name)
@ -1658,6 +1661,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
assetID = item.AssetID;
}
}
m_host.TaskInventory.LockItemsForRead(false);
}
if (assetID == UUID.Zero)
@ -1948,5 +1952,27 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
return key.ToString();
}
/// <summary>
/// Return information regarding various simulator statistics (sim fps, physics fps, time
/// dilation, total number of prims, total number of active scripts, script lps, various
/// timing data, packets in/out, etc. Basically much the information that's shown in the
/// client's Statistics Bar (Ctrl-Shift-1)
/// </summary>
/// <returns>List of floats</returns>
public LSL_List osGetRegionStats()
{
CheckThreatLevel(ThreatLevel.Moderate, "osGetRegionStats");
m_host.AddScriptLPS(1);
LSL_List ret = new LSL_List();
float[] stats = World.SimulatorStats;
for (int i = 0; i < 21; i++)
{
ret.Add(new LSL_Float( stats[i] ));
}
return ret;
}
}
}

View File

@ -83,7 +83,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
// Teleport commands
void osTeleportAgent(string agent, string regionName, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
void osTeleportAgent(string agent, uint regionX, uint regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
void osTeleportAgent(string agent, int regionX, int regionY, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
void osTeleportAgent(string agent, LSL_Types.Vector3 position, LSL_Types.Vector3 lookat);
// Animation commands
@ -162,5 +162,6 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api.Interfaces
key osGetMapTexture();
key osGetRegionMapTexture(string regionName);
LSL_List osGetRegionStats();
}
}

View File

@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
using System.Diagnostics; //for [DebuggerNonUserCode]
using System.Reflection;
using System.Runtime.Remoting.Lifetime;
using OpenSim.Region.ScriptEngine.Shared;
@ -131,6 +132,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return (eventFlags);
}
[DebuggerNonUserCode]
public void ExecuteEvent(string state, string FunctionName, object[] args)
{
// IMPORTANT: Types and MemberInfo-derived objects require a LOT of memory.

View File

@ -516,5 +516,28 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
public const string TEXTURE_TRANSPARENT = "8dcd4a48-2d37-4909-9f78-f7a9eb4ef903";
public const string TEXTURE_MEDIA = "8b5fec65-8d8d-9dc5-cda8-8fdf2716e361";
// Constants for osGetRegionStats
public const int STATS_TIME_DILATION = 0;
public const int STATS_SIM_FPS = 1;
public const int STATS_PHYSICS_FPS = 2;
public const int STATS_AGENT_UPDATES = 3;
public const int STATS_ROOT_AGENTS = 4;
public const int STATS_CHILD_AGENTS = 5;
public const int STATS_TOTAL_PRIMS = 6;
public const int STATS_ACTIVE_PRIMS = 7;
public const int STATS_FRAME_MS = 8;
public const int STATS_NET_MS = 9;
public const int STATS_PHYSICS_MS = 10;
public const int STATS_IMAGE_MS = 11;
public const int STATS_OTHER_MS = 12;
public const int STATS_IN_PACKETS_PER_SECOND = 13;
public const int STATS_OUT_PACKETS_PER_SECOND = 14;
public const int STATS_UNACKED_BYTES = 15;
public const int STATS_AGENT_MS = 16;
public const int STATS_PENDING_DOWNLOADS = 17;
public const int STATS_PENDING_UPLOADS = 18;
public const int STATS_ACTIVE_SCRIPTS = 19;
public const int STATS_SCRIPT_LPS = 20;
}
}

View File

@ -201,9 +201,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
m_OSSL_Functions.osTeleportAgent(agent, regionName, position, lookat);
}
public void osTeleportAgent(string agent, long regionX, long regionY, vector position, vector lookat)
public void osTeleportAgent(string agent, int regionX, int regionY, vector position, vector lookat)
{
m_OSSL_Functions.osTeleportAgent(agent, (uint) regionX, (uint) regionY, position, lookat);
m_OSSL_Functions.osTeleportAgent(agent, regionX, regionY, position, lookat);
}
public void osTeleportAgent(string agent, vector position, vector lookat)
@ -632,5 +632,10 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
{
return m_OSSL_Functions.osGetRegionMapTexture(regionName);
}
public LSL_List osGetRegionStats()
{
return m_OSSL_Functions.osGetRegionStats();
}
}
}

View File

@ -33,6 +33,7 @@ using System.Threading;
using System.Reflection;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics; //for [DebuggerNonUserCode]
using OpenSim.Region.ScriptEngine.Interfaces;
using OpenSim.Region.ScriptEngine.Shared;
using OpenSim.Region.ScriptEngine.Shared.Api.Runtime;
@ -90,6 +91,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.ScriptBase
return (int)m_Executor.GetStateEventFlags(state);
}
[DebuggerNonUserCode]
public void ExecuteEvent(string state, string FunctionName, object[] args)
{
m_Executor.ExecuteEvent(state, FunctionName, args);

View File

@ -27,6 +27,7 @@
using System;
using System.IO;
using System.Diagnostics; //for [DebuggerNonUserCode]
using System.Runtime.Remoting;
using System.Runtime.Remoting.Lifetime;
using System.Threading;
@ -237,13 +238,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (part != null)
{
lock (part.TaskInventory)
{
part.TaskInventory.LockItemsForRead(true);
if (part.TaskInventory.ContainsKey(m_ItemID))
{
m_thisScriptTask = part.TaskInventory[m_ItemID];
}
}
part.TaskInventory.LockItemsForRead(false);
}
ApiManager am = new ApiManager();
@ -428,14 +428,15 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{
int permsMask;
UUID permsGranter;
lock (part.TaskInventory)
{
part.TaskInventory.LockItemsForRead(true);
if (!part.TaskInventory.ContainsKey(m_ItemID))
{
part.TaskInventory.LockItemsForRead(false);
return;
}
permsGranter = part.TaskInventory[m_ItemID].PermsGranter;
permsMask = part.TaskInventory[m_ItemID].PermsMask;
}
part.TaskInventory.LockItemsForRead(false);
if ((permsMask & ScriptBaseClass.PERMISSION_TAKE_CONTROLS) != 0)
{
@ -544,6 +545,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
return true;
}
[DebuggerNonUserCode] //Prevents the debugger from farting in this function
public void SetState(string state)
{
if (state == State)
@ -638,11 +640,12 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
/// <returns></returns>
public object EventProcessor()
{
lock (m_Script)
{
EventParams data = null;
lock (m_EventQueue)
{
lock (m_Script)
{
data = (EventParams) m_EventQueue.Dequeue();
if (data == null) // Shouldn't happen
@ -668,6 +671,9 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
if (data.EventName == "collision")
m_CollisionInQueue = false;
}
}
lock(m_Script)
{
//m_log.DebugFormat("[XENGINE]: Processing event {0} for {1}", data.EventName, this);
@ -824,6 +830,7 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
new Object[0], new DetectParams[0]));
}
[DebuggerNonUserCode] //Stops the VS debugger from farting in this function
public void ApiResetScript()
{
// bool running = Running;
@ -1011,10 +1018,5 @@ namespace OpenSim.Region.ScriptEngine.Shared.Instance
{
get { return m_RegionID; }
}
public bool CanBeDeleted()
{
return true;
}
}
}

View File

@ -429,6 +429,11 @@ namespace OpenSim.Region.ScriptEngine.Shared
}
}
public int Size
{
get { return 0; }
}
public object[] Data
{
get {

View File

@ -30,6 +30,7 @@ using System.IO;
using System.Threading;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics; //for [DebuggerNonUserCode]
using System.Security;
using System.Security.Policy;
using System.Reflection;
@ -1119,6 +1120,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return false;
}
[DebuggerNonUserCode]
public void ApiResetScript(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
@ -1170,6 +1172,7 @@ namespace OpenSim.Region.ScriptEngine.XEngine
return UUID.Zero;
}
[DebuggerNonUserCode]
public void SetState(UUID itemID, string newState)
{
IScriptInstance instance = GetInstance(itemID);
@ -1245,34 +1248,219 @@ namespace OpenSim.Region.ScriptEngine.XEngine
}
}
public string GetAssemblyName(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
if (instance == null)
return "";
return instance.GetAssemblyName();
}
public string GetXMLState(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
if (instance == null)
return "";
return instance.GetXMLState();
string xml = instance.GetXMLState();
XmlDocument sdoc = new XmlDocument();
sdoc.LoadXml(xml);
XmlNodeList rootL = sdoc.GetElementsByTagName("ScriptState");
XmlNode rootNode = rootL[0];
// Create <State UUID="xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx">
XmlDocument doc = new XmlDocument();
XmlElement stateData = doc.CreateElement("", "State", "");
XmlAttribute stateID = doc.CreateAttribute("", "UUID", "");
stateID.Value = itemID.ToString();
stateData.Attributes.Append(stateID);
XmlAttribute assetID = doc.CreateAttribute("", "Asset", "");
assetID.Value = instance.AssetID.ToString();
stateData.Attributes.Append(assetID);
doc.AppendChild(stateData);
// Add <ScriptState>...</ScriptState>
XmlNode xmlstate = doc.ImportNode(rootNode, true);
stateData.AppendChild(xmlstate);
string assemName = instance.GetAssemblyName();
string fn = Path.GetFileName(assemName);
string assem = String.Empty;
if (File.Exists(assemName + ".text"))
{
FileInfo tfi = new FileInfo(assemName + ".text");
if (tfi != null)
{
Byte[] tdata = new Byte[tfi.Length];
try
{
FileStream tfs = File.Open(assemName + ".text",
FileMode.Open, FileAccess.Read);
tfs.Read(tdata, 0, tdata.Length);
tfs.Close();
assem = new System.Text.ASCIIEncoding().GetString(tdata);
}
catch (Exception e)
{
m_log.DebugFormat("[XEngine]: Unable to open script textfile {0}, reason: {1}", assemName+".text", e.Message);
}
}
}
else
{
FileInfo fi = new FileInfo(assemName);
if (fi != null)
{
Byte[] data = new Byte[fi.Length];
try
{
FileStream fs = File.Open(assemName, FileMode.Open, FileAccess.Read);
fs.Read(data, 0, data.Length);
fs.Close();
assem = System.Convert.ToBase64String(data);
}
catch (Exception e)
{
m_log.DebugFormat("[XEngine]: Unable to open script assembly {0}, reason: {1}", assemName, e.Message);
}
public bool CanBeDeleted(UUID itemID)
{
IScriptInstance instance = GetInstance(itemID);
if (instance == null)
return true;
}
}
return instance.CanBeDeleted();
string map = String.Empty;
if (File.Exists(fn + ".map"))
{
FileStream mfs = File.Open(fn + ".map", FileMode.Open, FileAccess.Read);
StreamReader msr = new StreamReader(mfs);
map = msr.ReadToEnd();
msr.Close();
mfs.Close();
}
XmlElement assemblyData = doc.CreateElement("", "Assembly", "");
XmlAttribute assemblyName = doc.CreateAttribute("", "Filename", "");
assemblyName.Value = fn;
assemblyData.Attributes.Append(assemblyName);
assemblyData.InnerText = assem;
stateData.AppendChild(assemblyData);
XmlElement mapData = doc.CreateElement("", "LineMap", "");
XmlAttribute mapName = doc.CreateAttribute("", "Filename", "");
mapName.Value = fn + ".map";
mapData.Attributes.Append(mapName);
mapData.InnerText = map;
stateData.AppendChild(mapData);
return doc.InnerXml;
}
private bool ShowScriptSaveResponse(UUID ownerID, UUID assetID, string text, bool compiled)
{
return false;
}
public void SetXMLState(UUID itemID, string xml)
{
if (xml == String.Empty)
return;
XmlDocument doc = new XmlDocument();
try
{
doc.LoadXml(xml);
}
catch (Exception)
{
m_log.Error("[XEngine]: Exception decoding XML data from region transfer");
return;
}
XmlNodeList rootL = doc.GetElementsByTagName("State");
if (rootL.Count < 1)
return;
XmlElement rootE = (XmlElement)rootL[0];
if (rootE.GetAttribute("UUID") != itemID.ToString())
return;
string assetID = rootE.GetAttribute("Asset");
XmlNodeList stateL = rootE.GetElementsByTagName("ScriptState");
if (stateL.Count != 1)
return;
XmlElement stateE = (XmlElement)stateL[0];
if (World.m_trustBinaries)
{
XmlNodeList assemL = rootE.GetElementsByTagName("Assembly");
if (assemL.Count != 1)
return;
XmlElement assemE = (XmlElement)assemL[0];
string fn = assemE.GetAttribute("Filename");
string base64 = assemE.InnerText;
string path = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
path = Path.Combine(path, fn);
if (!File.Exists(path))
{
Byte[] filedata = Convert.FromBase64String(base64);
FileStream fs = File.Create(path);
fs.Write(filedata, 0, filedata.Length);
fs.Close();
fs = File.Create(path + ".text");
StreamWriter sw = new StreamWriter(fs);
sw.Write(base64);
sw.Close();
fs.Close();
}
}
string statepath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
statepath = Path.Combine(statepath, itemID.ToString() + ".state");
FileStream sfs = File.Create(statepath);
StreamWriter ssw = new StreamWriter(sfs);
ssw.Write(stateE.OuterXml);
ssw.Close();
sfs.Close();
XmlNodeList mapL = rootE.GetElementsByTagName("LineMap");
XmlElement mapE = (XmlElement)mapL[0];
string mappath = Path.Combine("ScriptEngines", World.RegionInfo.RegionID.ToString());
mappath = Path.Combine(mappath, mapE.GetAttribute("Filename"));
FileStream mfs = File.Create(mappath);
StreamWriter msw = new StreamWriter(mfs);
msw.Write(mapE.InnerText);
msw.Close();
mfs.Close();
}
}
}

View File

@ -36,7 +36,8 @@ namespace OpenSim.Tools.LSL.Compiler
{
class Program
{
private static Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap;
// Commented out because generated warning since m_positionMap could never be anything other than null
// private static Dictionary<KeyValuePair<int, int>, KeyValuePair<int, int>> m_positionMap;
private static CSharpCodeProvider CScodeProvider = new CSharpCodeProvider();
static void Main(string[] args)
@ -210,16 +211,16 @@ namespace OpenSim.Tools.LSL.Compiler
sfs.Close();
string posmap = String.Empty;
if (m_positionMap != null)
{
foreach (KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> kvp in m_positionMap)
{
KeyValuePair<int, int> k = kvp.Key;
KeyValuePair<int, int> v = kvp.Value;
posmap += String.Format("{0},{1},{2},{3}\n",
k.Key, k.Value, v.Key, v.Value);
}
}
// if (m_positionMap != null)
// {
// foreach (KeyValuePair<KeyValuePair<int, int>, KeyValuePair<int, int>> kvp in m_positionMap)
// {
// KeyValuePair<int, int> k = kvp.Key;
// KeyValuePair<int, int> v = kvp.Value;
// posmap += String.Format("{0},{1},{2},{3}\n",
// k.Key, k.Value, v.Key, v.Value);
// }
// }
buf = enc.GetBytes(posmap);
@ -253,7 +254,8 @@ namespace OpenSim.Tools.LSL.Compiler
private static KeyValuePair<int, int> FindErrorPosition(int line, int col)
{
return FindErrorPosition(line, col, m_positionMap);
//return FindErrorPosition(line, col, m_positionMap);
return FindErrorPosition(line, col, null);
}
private class kvpSorter : IComparer<KeyValuePair<int,int>>

BIN
bin/NDesk.Options.dll Normal file

Binary file not shown.

View File

@ -455,6 +455,9 @@
; Distance in meters that shouts should travel. Default is 100m
shout_distance = 100
; Append a prefix to the god avatar names appearing in chat whilst in god mode
; admin_prefix = "@"
[Messaging]
; Control which region module is used for instant messaging.

View File

@ -1596,6 +1596,7 @@
<Reference name="System.Xml"/>
<Reference name="System.Drawing"/>
<Reference name="System.Web"/>
<Reference name="NDesk.Options"/>
<Reference name="OpenMetaverseTypes.dll"/>
<Reference name="OpenMetaverse.StructuredData.dll"/>
<Reference name="OpenMetaverse.dll"/>
@ -3414,7 +3415,7 @@
</Files>
</Project>
<?include file="addon-modules/*/prebuild.xml" ?>
<?include file="addon-modules/*/prebuild*.xml" ?>
</Solution>