Merge branch '0.7-post-fixes' of ssh://opensimulator.org/var/git/opensim into 0.7-post-fixes
commit
79d33418f0
|
@ -118,20 +118,20 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <param name="linkNum">Link number for the part</param>
|
||||
public void ResetInventoryIDs()
|
||||
{
|
||||
lock (Items)
|
||||
lock (m_items)
|
||||
{
|
||||
if (0 == Items.Count)
|
||||
if (0 == m_items.Count)
|
||||
return;
|
||||
|
||||
HasInventoryChanged = true;
|
||||
m_part.ParentGroup.HasGroupChanged = true;
|
||||
IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
|
||||
Items.Clear();
|
||||
IList<TaskInventoryItem> items = GetInventoryItems();
|
||||
m_items.Clear();
|
||||
|
||||
foreach (TaskInventoryItem item in items)
|
||||
{
|
||||
item.ResetIDs(m_part.UUID);
|
||||
Items.Add(item.ItemID, item);
|
||||
m_items.Add(item.ItemID, item);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -148,17 +148,17 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
HasInventoryChanged = true;
|
||||
m_part.ParentGroup.HasGroupChanged = true;
|
||||
IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
|
||||
foreach (TaskInventoryItem item in items)
|
||||
HasInventoryChanged = true;
|
||||
m_part.ParentGroup.HasGroupChanged = true;
|
||||
List<TaskInventoryItem> items = GetInventoryItems();
|
||||
foreach (TaskInventoryItem item in items)
|
||||
{
|
||||
if (ownerId != item.OwnerID)
|
||||
{
|
||||
if (ownerId != item.OwnerID)
|
||||
{
|
||||
item.LastOwnerID = item.OwnerID;
|
||||
item.OwnerID = ownerId;
|
||||
}
|
||||
item.LastOwnerID = item.OwnerID;
|
||||
item.OwnerID = ownerId;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -175,17 +175,15 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
HasInventoryChanged = true;
|
||||
m_part.ParentGroup.HasGroupChanged = true;
|
||||
IList<TaskInventoryItem> items = new List<TaskInventoryItem>(Items.Values);
|
||||
foreach (TaskInventoryItem item in items)
|
||||
{
|
||||
if (groupID != item.GroupID)
|
||||
{
|
||||
item.GroupID = groupID;
|
||||
}
|
||||
}
|
||||
HasInventoryChanged = true;
|
||||
m_part.ParentGroup.HasGroupChanged = true;
|
||||
List<TaskInventoryItem> items = GetInventoryItems();
|
||||
foreach (TaskInventoryItem item in items)
|
||||
{
|
||||
if (groupID != item.GroupID)
|
||||
item.GroupID = groupID;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -194,17 +192,9 @@ 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)
|
||||
{
|
||||
if ((int)InventoryType.LSL == item.InvType)
|
||||
{
|
||||
CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
|
||||
Thread.Sleep(10); // workaround for Mono cpu utilization > 100% bug
|
||||
}
|
||||
}
|
||||
}
|
||||
List<TaskInventoryItem> scripts = GetInventoryScripts();
|
||||
foreach (TaskInventoryItem item in scripts)
|
||||
CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
|
||||
}
|
||||
|
||||
public ArrayList GetScriptErrors(UUID itemID)
|
||||
|
@ -237,16 +227,9 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// </param>
|
||||
public void RemoveScriptInstances(bool sceneObjectBeingDeleted)
|
||||
{
|
||||
lock (Items)
|
||||
{
|
||||
foreach (TaskInventoryItem item in Items.Values)
|
||||
{
|
||||
if ((int)InventoryType.LSL == item.InvType)
|
||||
{
|
||||
RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
|
||||
}
|
||||
}
|
||||
}
|
||||
List<TaskInventoryItem> scripts = GetInventoryScripts();
|
||||
foreach (TaskInventoryItem item in scripts)
|
||||
RemoveScriptInstance(item.ItemID, sceneObjectBeingDeleted);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -259,7 +242,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
// m_log.InfoFormat(
|
||||
// "[PRIM INVENTORY]: " +
|
||||
// "Starting script {0}, {1} in prim {2}, {3}",
|
||||
// item.Name, item.ItemID, m_part.Name, m_part.UUID);
|
||||
// item.Name, item.ItemID, Name, UUID);
|
||||
|
||||
if (!m_part.ParentGroup.Scene.Permissions.CanRunScript(item.ItemID, m_part.UUID, item.OwnerID))
|
||||
return;
|
||||
|
@ -295,20 +278,20 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
}
|
||||
else
|
||||
{
|
||||
if (m_part.ParentGroup.m_savedScriptState != null)
|
||||
RestoreSavedScriptState(item.OldItemID, item.ItemID);
|
||||
|
||||
lock (m_items)
|
||||
{
|
||||
if (m_part.ParentGroup.m_savedScriptState != null)
|
||||
RestoreSavedScriptState(item.OldItemID, item.ItemID);
|
||||
|
||||
m_items[item.ItemID].PermsMask = 0;
|
||||
m_items[item.ItemID].PermsGranter = UUID.Zero;
|
||||
|
||||
string script = Utils.BytesToString(asset.Data);
|
||||
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
|
||||
m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
|
||||
m_part.ParentGroup.AddActiveScriptCount(1);
|
||||
m_part.ScheduleFullUpdate();
|
||||
}
|
||||
|
||||
string script = Utils.BytesToString(asset.Data);
|
||||
m_part.ParentGroup.Scene.EventManager.TriggerRezScript(
|
||||
m_part.LocalId, item.ItemID, script, startParam, postOnRez, engine, stateSource);
|
||||
m_part.ParentGroup.AddActiveScriptCount(1);
|
||||
m_part.ScheduleFullUpdate();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -376,21 +359,15 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// </param>
|
||||
public void CreateScriptInstance(UUID itemId, int startParam, bool postOnRez, string engine, int stateSource)
|
||||
{
|
||||
lock (m_items)
|
||||
{
|
||||
if (m_items.ContainsKey(itemId))
|
||||
{
|
||||
CreateScriptInstance(m_items[itemId], startParam, postOnRez, engine, stateSource);
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIM INVENTORY]: " +
|
||||
"Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
|
||||
itemId, m_part.Name, m_part.UUID,
|
||||
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
|
||||
}
|
||||
}
|
||||
TaskInventoryItem item = GetInventoryItem(itemId);
|
||||
if (item != null)
|
||||
CreateScriptInstance(item, startParam, postOnRez, engine, stateSource);
|
||||
else
|
||||
m_log.ErrorFormat(
|
||||
"[PRIM INVENTORY]: " +
|
||||
"Couldn't start script with ID {0} since it couldn't be found for prim {1}, {2} at {3} in {4}",
|
||||
itemId, m_part.Name, m_part.UUID,
|
||||
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -431,16 +408,18 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
/// <summary>
|
||||
/// Check if the inventory holds an item with a given name.
|
||||
/// This method assumes that the task inventory is already locked.
|
||||
/// </summary>
|
||||
/// <param name="name"></param>
|
||||
/// <returns></returns>
|
||||
private bool InventoryContainsName(string name)
|
||||
{
|
||||
foreach (TaskInventoryItem item in Items.Values)
|
||||
lock (m_items)
|
||||
{
|
||||
if (item.Name == name)
|
||||
return true;
|
||||
foreach (TaskInventoryItem item in m_items.Values)
|
||||
{
|
||||
if (item.Name == name)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
@ -483,12 +462,7 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// <param name="item"></param>
|
||||
public void AddInventoryItemExclusive(TaskInventoryItem item, bool allowedDrop)
|
||||
{
|
||||
List<TaskInventoryItem> il;
|
||||
|
||||
lock (m_items)
|
||||
{
|
||||
il = new List<TaskInventoryItem>(m_items.Values);
|
||||
}
|
||||
List<TaskInventoryItem> il = GetInventoryItems();
|
||||
|
||||
foreach (TaskInventoryItem i in il)
|
||||
{
|
||||
|
@ -528,14 +502,12 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
item.GroupID = m_part.GroupID;
|
||||
|
||||
lock (m_items)
|
||||
{
|
||||
m_items.Add(item.ItemID, item);
|
||||
|
||||
if (allowedDrop)
|
||||
m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP);
|
||||
else
|
||||
m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
|
||||
}
|
||||
if (allowedDrop)
|
||||
m_part.TriggerScriptChangedEvent(Changed.ALLOWED_DROP);
|
||||
else
|
||||
m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
|
||||
|
||||
m_inventorySerial++;
|
||||
//m_inventorySerial += 2;
|
||||
|
@ -559,9 +531,8 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
m_items.Add(item.ItemID, item);
|
||||
// m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
|
||||
}
|
||||
m_inventorySerial++;
|
||||
}
|
||||
|
||||
m_inventorySerial++;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -616,45 +587,44 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
public bool UpdateInventoryItem(TaskInventoryItem item, bool fireScriptEvents)
|
||||
{
|
||||
lock(m_items)
|
||||
TaskInventoryItem it = GetInventoryItem(item.ItemID);
|
||||
if (it != null)
|
||||
{
|
||||
if (m_items.ContainsKey(item.ItemID))
|
||||
{
|
||||
if (m_items.ContainsKey(item.ItemID))
|
||||
{
|
||||
item.ParentID = m_part.UUID;
|
||||
item.ParentPartID = m_part.UUID;
|
||||
item.Flags = m_items[item.ItemID].Flags;
|
||||
item.ParentID = m_part.UUID;
|
||||
item.ParentPartID = m_part.UUID;
|
||||
item.Flags = m_items[item.ItemID].Flags;
|
||||
|
||||
// If group permissions have been set on, check that the groupID is up to date in case it has
|
||||
// changed since permissions were last set.
|
||||
if (item.GroupPermissions != (uint)PermissionMask.None)
|
||||
item.GroupID = m_part.GroupID;
|
||||
// If group permissions have been set on, check that the groupID is up to date in case it has
|
||||
// changed since permissions were last set.
|
||||
if (item.GroupPermissions != (uint)PermissionMask.None)
|
||||
item.GroupID = m_part.GroupID;
|
||||
|
||||
if (item.AssetID == UUID.Zero)
|
||||
{
|
||||
item.AssetID = m_items[item.ItemID].AssetID;
|
||||
}
|
||||
m_items[item.ItemID] = item;
|
||||
m_inventorySerial++;
|
||||
if (fireScriptEvents)
|
||||
m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
|
||||
HasInventoryChanged = true;
|
||||
m_part.ParentGroup.HasGroupChanged = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIM INVENTORY]: " +
|
||||
"Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory",
|
||||
item.ItemID, m_part.Name, m_part.UUID,
|
||||
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
|
||||
}
|
||||
if (item.AssetID == UUID.Zero)
|
||||
item.AssetID = it.AssetID;
|
||||
|
||||
lock (m_items)
|
||||
{
|
||||
m_items[item.ItemID] = item;
|
||||
m_inventorySerial++;
|
||||
}
|
||||
return false;
|
||||
|
||||
if (fireScriptEvents)
|
||||
m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
|
||||
|
||||
HasInventoryChanged = true;
|
||||
m_part.ParentGroup.HasGroupChanged = true;
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIM INVENTORY]: " +
|
||||
"Tried to retrieve item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory",
|
||||
item.ItemID, m_part.Name, m_part.UUID,
|
||||
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
|
||||
}
|
||||
return false;
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -665,52 +635,37 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
/// in this prim's inventory.</returns>
|
||||
public int RemoveInventoryItem(UUID itemID)
|
||||
{
|
||||
lock (m_items)
|
||||
TaskInventoryItem item = GetInventoryItem(itemID);
|
||||
if (item != null)
|
||||
{
|
||||
if (m_items.ContainsKey(itemID))
|
||||
int type = m_items[itemID].InvType;
|
||||
if (type == 10) // Script
|
||||
{
|
||||
int type = m_items[itemID].InvType;
|
||||
if (type == 10) // Script
|
||||
{
|
||||
m_part.RemoveScriptEvents(itemID);
|
||||
m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID);
|
||||
}
|
||||
m_items.Remove(itemID);
|
||||
m_inventorySerial++;
|
||||
m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
|
||||
|
||||
HasInventoryChanged = true;
|
||||
m_part.ParentGroup.HasGroupChanged = true;
|
||||
|
||||
int scriptcount = 0;
|
||||
lock (m_items)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_items.Values)
|
||||
{
|
||||
if (item.Type == 10)
|
||||
{
|
||||
scriptcount++;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (scriptcount <= 0)
|
||||
{
|
||||
m_part.RemFlag(PrimFlags.Scripted);
|
||||
}
|
||||
|
||||
m_part.ScheduleFullUpdate();
|
||||
|
||||
return type;
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIM INVENTORY]: " +
|
||||
"Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory",
|
||||
itemID, m_part.Name, m_part.UUID,
|
||||
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
|
||||
m_part.RemoveScriptEvents(itemID);
|
||||
m_part.ParentGroup.Scene.EventManager.TriggerRemoveScript(m_part.LocalId, itemID);
|
||||
}
|
||||
m_items.Remove(itemID);
|
||||
m_inventorySerial++;
|
||||
m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
|
||||
|
||||
HasInventoryChanged = true;
|
||||
m_part.ParentGroup.HasGroupChanged = true;
|
||||
|
||||
if (!ContainsScripts())
|
||||
m_part.RemFlag(PrimFlags.Scripted);
|
||||
|
||||
m_part.ScheduleFullUpdate();
|
||||
|
||||
return type;
|
||||
|
||||
}
|
||||
else
|
||||
{
|
||||
m_log.ErrorFormat(
|
||||
"[PRIM INVENTORY]: " +
|
||||
"Tried to remove item ID {0} from prim {1}, {2} at {3} in {4} but the item does not exist in this inventory",
|
||||
itemID, m_part.Name, m_part.UUID,
|
||||
m_part.AbsolutePosition, m_part.ParentGroup.Scene.RegionInfo.RegionName);
|
||||
}
|
||||
|
||||
return -1;
|
||||
|
@ -764,52 +719,50 @@ 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)
|
||||
List<TaskInventoryItem> items = GetInventoryItems();
|
||||
foreach (TaskInventoryItem item in items)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_items.Values)
|
||||
{
|
||||
UUID ownerID = item.OwnerID;
|
||||
uint everyoneMask = 0;
|
||||
uint baseMask = item.BasePermissions;
|
||||
uint ownerMask = item.CurrentPermissions;
|
||||
uint groupMask = item.GroupPermissions;
|
||||
UUID ownerID = item.OwnerID;
|
||||
uint everyoneMask = 0;
|
||||
uint baseMask = item.BasePermissions;
|
||||
uint ownerMask = item.CurrentPermissions;
|
||||
uint groupMask = item.GroupPermissions;
|
||||
|
||||
invString.AddItemStart();
|
||||
invString.AddNameValueLine("item_id", item.ItemID.ToString());
|
||||
invString.AddNameValueLine("parent_id", m_part.UUID.ToString());
|
||||
invString.AddItemStart();
|
||||
invString.AddNameValueLine("item_id", item.ItemID.ToString());
|
||||
invString.AddNameValueLine("parent_id", m_part.UUID.ToString());
|
||||
|
||||
invString.AddPermissionsStart();
|
||||
invString.AddPermissionsStart();
|
||||
|
||||
invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
|
||||
invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
|
||||
invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask));
|
||||
invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
|
||||
invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));
|
||||
invString.AddNameValueLine("base_mask", Utils.UIntToHexString(baseMask));
|
||||
invString.AddNameValueLine("owner_mask", Utils.UIntToHexString(ownerMask));
|
||||
invString.AddNameValueLine("group_mask", Utils.UIntToHexString(groupMask));
|
||||
invString.AddNameValueLine("everyone_mask", Utils.UIntToHexString(everyoneMask));
|
||||
invString.AddNameValueLine("next_owner_mask", Utils.UIntToHexString(item.NextPermissions));
|
||||
|
||||
invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
|
||||
invString.AddNameValueLine("owner_id", ownerID.ToString());
|
||||
invString.AddNameValueLine("creator_id", item.CreatorID.ToString());
|
||||
invString.AddNameValueLine("owner_id", ownerID.ToString());
|
||||
|
||||
invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
|
||||
invString.AddNameValueLine("last_owner_id", item.LastOwnerID.ToString());
|
||||
|
||||
invString.AddNameValueLine("group_id", item.GroupID.ToString());
|
||||
invString.AddSectionEnd();
|
||||
invString.AddNameValueLine("group_id", item.GroupID.ToString());
|
||||
invString.AddSectionEnd();
|
||||
|
||||
invString.AddNameValueLine("asset_id", item.AssetID.ToString());
|
||||
invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
|
||||
invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
|
||||
invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));
|
||||
invString.AddNameValueLine("asset_id", item.AssetID.ToString());
|
||||
invString.AddNameValueLine("type", TaskInventoryItem.Types[item.Type]);
|
||||
invString.AddNameValueLine("inv_type", TaskInventoryItem.InvTypes[item.InvType]);
|
||||
invString.AddNameValueLine("flags", Utils.UIntToHexString(item.Flags));
|
||||
|
||||
invString.AddSaleStart();
|
||||
invString.AddNameValueLine("sale_type", "not");
|
||||
invString.AddNameValueLine("sale_price", "0");
|
||||
invString.AddSectionEnd();
|
||||
invString.AddSaleStart();
|
||||
invString.AddNameValueLine("sale_type", "not");
|
||||
invString.AddNameValueLine("sale_price", "0");
|
||||
invString.AddSectionEnd();
|
||||
|
||||
invString.AddNameValueLine("name", item.Name + "|");
|
||||
invString.AddNameValueLine("desc", item.Description + "|");
|
||||
invString.AddNameValueLine("name", item.Name + "|");
|
||||
invString.AddNameValueLine("desc", item.Description + "|");
|
||||
|
||||
invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
|
||||
invString.AddSectionEnd();
|
||||
}
|
||||
invString.AddNameValueLine("creation_date", item.CreationDate.ToString());
|
||||
invString.AddSectionEnd();
|
||||
}
|
||||
|
||||
fileData = Utils.StringToBytes(invString.BuildString);
|
||||
|
@ -831,12 +784,10 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
{
|
||||
if (HasInventoryChanged)
|
||||
{
|
||||
lock (Items)
|
||||
{
|
||||
datastore.StorePrimInventory(m_part.UUID, Items.Values);
|
||||
}
|
||||
|
||||
HasInventoryChanged = false;
|
||||
List<TaskInventoryItem> items = GetInventoryItems();
|
||||
datastore.StorePrimInventory(m_part.UUID, items);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1002,6 +953,30 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<TaskInventoryItem> GetInventoryItems()
|
||||
{
|
||||
List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
|
||||
|
||||
lock (m_items)
|
||||
ret = new List<TaskInventoryItem>(m_items.Values);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public List<TaskInventoryItem> GetInventoryScripts()
|
||||
{
|
||||
List<TaskInventoryItem> ret = new List<TaskInventoryItem>();
|
||||
|
||||
lock (m_items)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_items.Values)
|
||||
if (item.InvType == (int)InventoryType.LSL)
|
||||
ret.Add(item);
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public Dictionary<UUID, string> GetScriptStates()
|
||||
{
|
||||
|
@ -1011,24 +986,20 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (engines == null) // No engine at all
|
||||
return ret;
|
||||
|
||||
lock (m_items)
|
||||
List<TaskInventoryItem> scripts = GetInventoryScripts();
|
||||
|
||||
foreach (TaskInventoryItem item in scripts)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_items.Values)
|
||||
foreach (IScriptModule e in engines)
|
||||
{
|
||||
if (item.InvType == (int)InventoryType.LSL)
|
||||
if (e != null)
|
||||
{
|
||||
foreach (IScriptModule e in engines)
|
||||
string n = e.GetXMLState(item.ItemID);
|
||||
if (n != String.Empty)
|
||||
{
|
||||
if (e != null)
|
||||
{
|
||||
string n = e.GetXMLState(item.ItemID);
|
||||
if (n != String.Empty)
|
||||
{
|
||||
if (!ret.ContainsKey(item.ItemID))
|
||||
ret[item.ItemID] = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!ret.ContainsKey(item.ItemID))
|
||||
ret[item.ItemID] = n;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1043,25 +1014,22 @@ namespace OpenSim.Region.Framework.Scenes
|
|||
if (engines == null)
|
||||
return;
|
||||
|
||||
lock (m_items)
|
||||
List<TaskInventoryItem> scripts = GetInventoryScripts();
|
||||
|
||||
foreach (TaskInventoryItem item in scripts)
|
||||
{
|
||||
foreach (TaskInventoryItem item in m_items.Values)
|
||||
foreach (IScriptModule engine in engines)
|
||||
{
|
||||
if (item.InvType == (int)InventoryType.LSL)
|
||||
if (engine != null)
|
||||
{
|
||||
foreach (IScriptModule engine in engines)
|
||||
{
|
||||
if (engine != null)
|
||||
{
|
||||
if (item.OwnerChanged)
|
||||
engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
|
||||
item.OwnerChanged = false;
|
||||
engine.ResumeScript(item.ItemID);
|
||||
}
|
||||
}
|
||||
if (item.OwnerChanged)
|
||||
engine.PostScriptEvent(item.ItemID, "changed", new Object[] { (int)Changed.OWNER });
|
||||
item.OwnerChanged = false;
|
||||
engine.ResumeScript(item.ItemID);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -465,22 +465,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
|
||||
//Now we start getting into quaternions which means sin/cos, matrices and vectors. ckrinke
|
||||
|
||||
// Utility function for llRot2Euler
|
||||
|
||||
// normalize an angle between -PI and PI (-180 to +180 degrees)
|
||||
protected double NormalizeAngle(double angle)
|
||||
{
|
||||
if (angle > -Math.PI && angle < Math.PI)
|
||||
return angle;
|
||||
|
||||
int numPis = (int)(Math.PI / angle);
|
||||
double remainder = angle - Math.PI * numPis;
|
||||
if (numPis % 2 == 1)
|
||||
return Math.PI - angle;
|
||||
return remainder;
|
||||
}
|
||||
|
||||
// Old implementation of llRot2Euler, now normalized
|
||||
// Old implementation of llRot2Euler. Normalization not required as Atan2 function will
|
||||
// only return values >= -PI (-180 degrees) and <= PI (180 degrees).
|
||||
|
||||
public LSL_Vector llRot2Euler(LSL_Rotation r)
|
||||
{
|
||||
|
@ -492,13 +478,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
double n = 2 * (r.y * r.s + r.x * r.z);
|
||||
double p = m * m - n * n;
|
||||
if (p > 0)
|
||||
return new LSL_Vector(NormalizeAngle(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s))),
|
||||
NormalizeAngle(Math.Atan2(n, Math.Sqrt(p))),
|
||||
NormalizeAngle(Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s))));
|
||||
return new LSL_Vector(Math.Atan2(2.0 * (r.x * r.s - r.y * r.z), (-t.x - t.y + t.z + t.s)),
|
||||
Math.Atan2(n, Math.Sqrt(p)),
|
||||
Math.Atan2(2.0 * (r.z * r.s - r.x * r.y), (t.x - t.y - t.z + t.s)));
|
||||
else if (n > 0)
|
||||
return new LSL_Vector(0.0, Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
|
||||
return new LSL_Vector(0.0, Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z));
|
||||
else
|
||||
return new LSL_Vector(0.0, -Math.PI * 0.5, NormalizeAngle(Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z)));
|
||||
return new LSL_Vector(0.0, -Math.PI * 0.5, Math.Atan2((r.z * r.s + r.x * r.y), 0.5 - t.x - t.z));
|
||||
}
|
||||
|
||||
/* From wiki:
|
||||
|
@ -5874,6 +5860,8 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
PSYS_PART_MAX_AGE = 7,
|
||||
PSYS_SRC_ACCEL = 8,
|
||||
PSYS_SRC_PATTERN = 9,
|
||||
PSYS_SRC_INNERANGLE = 10,
|
||||
PSYS_SRC_OUTERANGLE = 11,
|
||||
PSYS_SRC_TEXTURE = 12,
|
||||
PSYS_SRC_BURST_RATE = 13,
|
||||
PSYS_SRC_BURST_PART_COUNT = 15,
|
||||
|
@ -6006,6 +5994,22 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
prules.Pattern = (Primitive.ParticleSystem.SourcePattern)tmpi;
|
||||
break;
|
||||
|
||||
// PSYS_SRC_INNERANGLE and PSYS_SRC_ANGLE_BEGIN use the same variables. The
|
||||
// PSYS_SRC_OUTERANGLE and PSYS_SRC_ANGLE_END also use the same variable. The
|
||||
// client tells the difference between the two by looking at the 0x02 bit in
|
||||
// the PartFlags variable.
|
||||
case (int)ScriptBaseClass.PSYS_SRC_INNERANGLE:
|
||||
tempf = (float)rules.GetLSLFloatItem(i + 1);
|
||||
prules.InnerAngle = (float)tempf;
|
||||
prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off.
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PSYS_SRC_OUTERANGLE:
|
||||
tempf = (float)rules.GetLSLFloatItem(i + 1);
|
||||
prules.OuterAngle = (float)tempf;
|
||||
prules.PartFlags &= 0xFFFFFFFD; // Make sure new angle format is off.
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PSYS_SRC_TEXTURE:
|
||||
prules.Texture = KeyOrName(rules.GetLSLStringItem(i + 1));
|
||||
break;
|
||||
|
@ -6062,11 +6066,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
|||
case (int)ScriptBaseClass.PSYS_SRC_ANGLE_BEGIN:
|
||||
tempf = (float)rules.GetLSLFloatItem(i + 1);
|
||||
prules.InnerAngle = (float)tempf;
|
||||
prules.PartFlags |= 0x02; // Set new angle format.
|
||||
break;
|
||||
|
||||
case (int)ScriptBaseClass.PSYS_SRC_ANGLE_END:
|
||||
tempf = (float)rules.GetLSLFloatItem(i + 1);
|
||||
prules.OuterAngle = (float)tempf;
|
||||
prules.PartFlags |= 0x02; // Set new angle format.
|
||||
break;
|
||||
}
|
||||
|
||||
|
|
|
@ -701,9 +701,9 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
}
|
||||
}
|
||||
|
||||
ScriptInstance instance = null;
|
||||
lock (m_Scripts)
|
||||
{
|
||||
ScriptInstance instance = null;
|
||||
// Create the object record
|
||||
|
||||
if ((!m_Scripts.ContainsKey(itemID)) ||
|
||||
|
@ -786,28 +786,29 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
|
||||
m_Scripts[itemID] = instance;
|
||||
}
|
||||
|
||||
lock (m_PrimObjects)
|
||||
{
|
||||
if (!m_PrimObjects.ContainsKey(localID))
|
||||
m_PrimObjects[localID] = new List<UUID>();
|
||||
|
||||
if (!m_PrimObjects[localID].Contains(itemID))
|
||||
m_PrimObjects[localID].Add(itemID);
|
||||
|
||||
}
|
||||
|
||||
if (!m_Assemblies.ContainsKey(assetID))
|
||||
m_Assemblies[assetID] = assembly;
|
||||
|
||||
lock (m_AddingAssemblies)
|
||||
{
|
||||
m_AddingAssemblies[assembly]--;
|
||||
}
|
||||
|
||||
if (instance!=null)
|
||||
instance.Init();
|
||||
}
|
||||
|
||||
lock (m_PrimObjects)
|
||||
{
|
||||
if (!m_PrimObjects.ContainsKey(localID))
|
||||
m_PrimObjects[localID] = new List<UUID>();
|
||||
|
||||
if (!m_PrimObjects[localID].Contains(itemID))
|
||||
m_PrimObjects[localID].Add(itemID);
|
||||
|
||||
}
|
||||
|
||||
if (!m_Assemblies.ContainsKey(assetID))
|
||||
m_Assemblies[assetID] = assembly;
|
||||
|
||||
lock (m_AddingAssemblies)
|
||||
{
|
||||
m_AddingAssemblies[assembly]--;
|
||||
}
|
||||
|
||||
if (instance != null)
|
||||
instance.Init();
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
@ -820,60 +821,60 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
m_CompileDict.Remove(itemID);
|
||||
}
|
||||
|
||||
IScriptInstance instance = null;
|
||||
|
||||
lock (m_Scripts)
|
||||
{
|
||||
// Do we even have it?
|
||||
if (!m_Scripts.ContainsKey(itemID))
|
||||
return;
|
||||
|
||||
IScriptInstance instance=m_Scripts[itemID];
|
||||
instance=m_Scripts[itemID];
|
||||
m_Scripts.Remove(itemID);
|
||||
}
|
||||
|
||||
instance.ClearQueue();
|
||||
instance.Stop(0);
|
||||
|
||||
instance.ClearQueue();
|
||||
instance.Stop(0);
|
||||
// bool objectRemoved = false;
|
||||
|
||||
lock (m_PrimObjects)
|
||||
lock (m_PrimObjects)
|
||||
{
|
||||
// Remove the script from it's prim
|
||||
if (m_PrimObjects.ContainsKey(localID))
|
||||
{
|
||||
// Remove the script from it's prim
|
||||
if (m_PrimObjects.ContainsKey(localID))
|
||||
{
|
||||
// Remove inventory item record
|
||||
if (m_PrimObjects[localID].Contains(itemID))
|
||||
m_PrimObjects[localID].Remove(itemID);
|
||||
// Remove inventory item record
|
||||
if (m_PrimObjects[localID].Contains(itemID))
|
||||
m_PrimObjects[localID].Remove(itemID);
|
||||
|
||||
// If there are no more scripts, remove prim
|
||||
if (m_PrimObjects[localID].Count == 0)
|
||||
{
|
||||
m_PrimObjects.Remove(localID);
|
||||
// If there are no more scripts, remove prim
|
||||
if (m_PrimObjects[localID].Count == 0)
|
||||
{
|
||||
m_PrimObjects.Remove(localID);
|
||||
// objectRemoved = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
instance.RemoveState();
|
||||
instance.DestroyScriptInstance();
|
||||
|
||||
m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
|
||||
if (m_DomainScripts[instance.AppDomain].Count == 0)
|
||||
{
|
||||
m_DomainScripts.Remove(instance.AppDomain);
|
||||
UnloadAppDomain(instance.AppDomain);
|
||||
}
|
||||
|
||||
instance = null;
|
||||
|
||||
ObjectRemoved handlerObjectRemoved = OnObjectRemoved;
|
||||
if (handlerObjectRemoved != null)
|
||||
{
|
||||
SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
|
||||
handlerObjectRemoved(part.UUID);
|
||||
}
|
||||
|
||||
CleanAssemblies();
|
||||
}
|
||||
|
||||
instance.RemoveState();
|
||||
instance.DestroyScriptInstance();
|
||||
|
||||
m_DomainScripts[instance.AppDomain].Remove(instance.ItemID);
|
||||
if (m_DomainScripts[instance.AppDomain].Count == 0)
|
||||
{
|
||||
m_DomainScripts.Remove(instance.AppDomain);
|
||||
UnloadAppDomain(instance.AppDomain);
|
||||
}
|
||||
|
||||
instance = null;
|
||||
|
||||
ObjectRemoved handlerObjectRemoved = OnObjectRemoved;
|
||||
if (handlerObjectRemoved != null)
|
||||
{
|
||||
SceneObjectPart part = m_Scene.GetSceneObjectPart(localID);
|
||||
handlerObjectRemoved(part.UUID);
|
||||
}
|
||||
|
||||
|
||||
ScriptRemoved handlerScriptRemoved = OnScriptRemoved;
|
||||
if (handlerScriptRemoved != null)
|
||||
handlerScriptRemoved(itemID);
|
||||
|
@ -1007,26 +1008,33 @@ namespace OpenSim.Region.ScriptEngine.XEngine
|
|||
public bool PostObjectEvent(uint localID, EventParams p)
|
||||
{
|
||||
bool result = false;
|
||||
|
||||
List<UUID> uuids = null;
|
||||
|
||||
lock (m_PrimObjects)
|
||||
{
|
||||
if (!m_PrimObjects.ContainsKey(localID))
|
||||
return false;
|
||||
|
||||
|
||||
foreach (UUID itemID in m_PrimObjects[localID])
|
||||
uuids = m_PrimObjects[localID];
|
||||
}
|
||||
|
||||
foreach (UUID itemID in uuids)
|
||||
{
|
||||
IScriptInstance instance = null;
|
||||
try
|
||||
{
|
||||
if (m_Scripts.ContainsKey(itemID))
|
||||
{
|
||||
IScriptInstance instance = m_Scripts[itemID];
|
||||
if (instance != null)
|
||||
{
|
||||
instance.PostEvent(p);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
instance = m_Scripts[itemID];
|
||||
}
|
||||
catch { /* ignore race conditions */ }
|
||||
|
||||
if (instance != null)
|
||||
{
|
||||
instance.PostEvent(p);
|
||||
result = true;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue