Merge branch 'master' into careminster

Conflicts:
	OpenSim/Data/MySQL/MySQLSimulationData.cs
	OpenSim/Region/Framework/Scenes/EventManager.cs
	OpenSim/Region/Framework/Scenes/SceneObjectGroup.cs
avinationmerge
Melanie 2013-06-30 18:27:30 +01:00
commit ffcee82b1d
26 changed files with 514 additions and 269 deletions

View File

@ -58,7 +58,7 @@ where we are today.
= Additional OpenSim Contributors = = Additional OpenSim Contributors =
These folks have contributed code patches to OpenSim to help make it These folks have contributed code patches or content to OpenSimulator to help make it
what it is today. what it is today.
* aduffy70 * aduffy70
@ -163,6 +163,7 @@ what it is today.
* webmage (IBM) * webmage (IBM)
* Xantor * Xantor
* Y. Nitta * Y. Nitta
* YoshikoFazuku
* YZh * YZh
* Zackary Geers aka Kunnis Basiat * Zackary Geers aka Kunnis Basiat
* Zha Ewry * Zha Ewry
@ -215,5 +216,3 @@ In addition, we would like to thank:
* The Mono Project * The Mono Project
* The NANT Developers * The NANT Developers
* Microsoft (.NET, MSSQL-Adapters) * Microsoft (.NET, MSSQL-Adapters)
*x

View File

@ -766,14 +766,17 @@ namespace OpenSim.Groups
remoteClient.SendCreateGroupReply(UUID.Zero, false, "Insufficient funds to create a group."); remoteClient.SendCreateGroupReply(UUID.Zero, false, "Insufficient funds to create a group.");
return UUID.Zero; return UUID.Zero;
} }
money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, MoneyTransactionType.GroupCreate);
} }
string reason = string.Empty; string reason = string.Empty;
UUID groupID = m_groupData.CreateGroup(remoteClient.AgentId, name, charter, showInList, insigniaID, membershipFee, openEnrollment, UUID groupID = m_groupData.CreateGroup(remoteClient.AgentId, name, charter, showInList, insigniaID, membershipFee, openEnrollment,
allowPublish, maturePublish, remoteClient.AgentId, out reason); allowPublish, maturePublish, remoteClient.AgentId, out reason);
if (groupID != UUID.Zero) if (groupID != UUID.Zero)
{ {
if (money != null)
money.ApplyCharge(remoteClient.AgentId, money.GroupCreationCharge, MoneyTransactionType.GroupCreate);
remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly"); remoteClient.SendCreateGroupReply(groupID, true, "Group created successfullly");
// Update the founder with new group information. // Update the founder with new group information.

View File

@ -2100,7 +2100,7 @@ VALUES
parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum)); parameters.Add(_Database.CreateParameter("LinkNumber", prim.LinkNum));
parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl)); parameters.Add(_Database.CreateParameter("MediaURL", prim.MediaUrl));
if (prim.DynAttrs.Count > 0) if (prim.DynAttrs.CountNamespaces > 0)
parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml())); parameters.Add(_Database.CreateParameter("DynAttrs", prim.DynAttrs.ToXml()));
else else
parameters.Add(_Database.CreateParameter("DynAttrs", null)); parameters.Add(_Database.CreateParameter("DynAttrs", null));

View File

@ -1730,7 +1730,7 @@ namespace OpenSim.Data.MySQL
else else
cmd.Parameters.AddWithValue("Vehicle", String.Empty); cmd.Parameters.AddWithValue("Vehicle", String.Empty);
if (prim.DynAttrs.Count > 0) if (prim.DynAttrs.CountNamespaces > 0)
cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml()); cmd.Parameters.AddWithValue("DynAttrs", prim.DynAttrs.ToXml());
else else
cmd.Parameters.AddWithValue("DynAttrs", null); cmd.Parameters.AddWithValue("DynAttrs", null);

View File

@ -199,6 +199,8 @@ namespace OpenSim.Data.MySQL
/// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks> /// <remarks>On failure : Throw an exception and attempt to reconnect to database</remarks>
public void StoreAsset(AssetBase asset) public void StoreAsset(AssetBase asset)
{ {
// m_log.DebugFormat("[XASSETS DB]: Storing asset {0} {1}", asset.Name, asset.ID);
lock (m_dbLock) lock (m_dbLock)
{ {
using (MySqlConnection dbcon = new MySqlConnection(m_connectionString)) using (MySqlConnection dbcon = new MySqlConnection(m_connectionString))

View File

@ -2176,7 +2176,7 @@ namespace OpenSim.Data.SQLite
row["MediaURL"] = prim.MediaUrl; row["MediaURL"] = prim.MediaUrl;
if (prim.DynAttrs.Count > 0) if (prim.DynAttrs.CountNamespaces > 0)
row["DynAttrs"] = prim.DynAttrs.ToXml(); row["DynAttrs"] = prim.DynAttrs.ToXml();
else else
row["DynAttrs"] = null; row["DynAttrs"] = null;

View File

@ -29,10 +29,12 @@ using System;
using System.Collections; using System.Collections;
using System.Collections.Generic; using System.Collections.Generic;
using System.IO; using System.IO;
using System.Reflection;
using System.Text; using System.Text;
using System.Xml; using System.Xml;
using System.Xml.Schema; using System.Xml.Schema;
using System.Xml.Serialization; using System.Xml.Serialization;
using log4net;
using OpenMetaverse; using OpenMetaverse;
using OpenMetaverse.StructuredData; using OpenMetaverse.StructuredData;
@ -48,13 +50,20 @@ namespace OpenSim.Framework
/// within their data store. However, avoid storing large amounts of data because that /// within their data store. However, avoid storing large amounts of data because that
/// would slow down database access. /// would slow down database access.
/// </remarks> /// </remarks>
public class DAMap : IDictionary<string, OSDMap>, IXmlSerializable public class DAMap : IXmlSerializable
{ {
private static readonly int MIN_STORE_NAME_LENGTH = 4; // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
protected OSDMap m_map; private static readonly int MIN_NAMESPACE_LENGTH = 4;
public DAMap() { m_map = new OSDMap(); } private OSDMap m_map = new OSDMap();
// WARNING: this is temporary for experimentation only, it will be removed!!!!
public OSDMap TopLevelMap
{
get { return m_map; }
set { m_map = value; }
}
public XmlSchema GetSchema() { return null; } public XmlSchema GetSchema() { return null; }
@ -64,39 +73,34 @@ namespace OpenSim.Framework
map.ReadXml(rawXml); map.ReadXml(rawXml);
return map; return map;
} }
public void ReadXml(XmlReader reader)
{
ReadXml(reader.ReadInnerXml());
}
public void ReadXml(string rawXml) public void ReadXml(string rawXml)
{ {
// System.Console.WriteLine("Trying to deserialize [{0}]", rawXml); // System.Console.WriteLine("Trying to deserialize [{0}]", rawXml);
lock (this) lock (this)
{
m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml); m_map = (OSDMap)OSDParser.DeserializeLLSDXml(rawXml);
} SanitiseMap(this);
}
// WARNING: this is temporary for experimentation only, it will be removed!!!!
public OSDMap TopLevelMap
{
get { return m_map; }
set { m_map = value; }
}
public void ReadXml(XmlReader reader)
{
ReadXml(reader.ReadInnerXml());
}
public string ToXml()
{
lock (this)
return OSDParser.SerializeLLSDXmlString(m_map);
} }
public void WriteXml(XmlWriter writer) public void WriteXml(XmlWriter writer)
{ {
writer.WriteRaw(ToXml()); writer.WriteRaw(ToXml());
} }
public string ToXml()
{
lock (this)
return OSDParser.SerializeLLSDXmlString(m_map);
}
public void CopyFrom(DAMap other) public void CopyFrom(DAMap other)
{ {
// Deep copy // Deep copy
@ -104,7 +108,7 @@ namespace OpenSim.Framework
string data = null; string data = null;
lock (other) lock (other)
{ {
if (other.Count > 0) if (other.CountNamespaces > 0)
{ {
data = OSDParser.SerializeLLSDXmlString(other.m_map); data = OSDParser.SerializeLLSDXmlString(other.m_map);
} }
@ -120,59 +124,136 @@ namespace OpenSim.Framework
} }
/// <summary> /// <summary>
/// Returns the number of data stores. /// Sanitise the map to remove any namespaces or stores that are not OSDMap.
/// </summary> /// </summary>
public int Count { get { lock (this) { return m_map.Count; } } } /// <param name='map'>
/// </param>
public bool IsReadOnly { get { return false; } } public static void SanitiseMap(DAMap daMap)
/// <summary>
/// Returns the names of the data stores.
/// </summary>
public ICollection<string> Keys { get { lock (this) { return m_map.Keys; } } }
/// <summary>
/// Returns all the data stores.
/// </summary>
public ICollection<OSDMap> Values
{ {
get List<string> keysToRemove = null;
// Hard-coded special case that needs to be removed in the future. Normally, modules themselves should
// handle reading data from old locations
bool osMaterialsMigrationRequired = false;
OSDMap namespacesMap = daMap.m_map;
foreach (string key in namespacesMap.Keys)
{ {
lock (this) // Console.WriteLine("Processing ns {0}", key);
if (!(namespacesMap[key] is OSDMap))
{ {
List<OSDMap> stores = new List<OSDMap>(m_map.Count); if (keysToRemove == null)
foreach (OSD llsd in m_map.Values) keysToRemove = new List<string>();
stores.Add((OSDMap)llsd);
return stores; keysToRemove.Add(key);
} }
} }
if (keysToRemove != null)
{
foreach (string key in keysToRemove)
{
// Console.WriteLine ("Removing bad ns {0}", key);
namespacesMap.Remove(key);
}
}
foreach (OSD nsOsd in namespacesMap.Values)
{
OSDMap nsOsdMap = (OSDMap)nsOsd;
keysToRemove = null;
foreach (string key in nsOsdMap.Keys)
{
if (!(nsOsdMap[key] is OSDMap))
{
if (keysToRemove == null)
keysToRemove = new List<string>();
keysToRemove.Add(key);
}
}
if (keysToRemove != null)
foreach (string key in keysToRemove)
nsOsdMap.Remove(key);
}
} }
/// <summary> /// <summary>
/// Gets or sets one data store. /// Get the number of namespaces
/// </summary> /// </summary>
/// <param name="key">Store name</param> public int CountNamespaces { get { lock (this) { return m_map.Count; } } }
/// <returns></returns>
public OSDMap this[string key] /// <summary>
{ /// Get the number of stores.
get /// </summary>
{ public int CountStores
OSD llsd; {
get
{
int count = 0;
lock (this) lock (this)
{ {
if (m_map.TryGetValue(key, out llsd)) foreach (OSD osdNamespace in m_map)
return (OSDMap)llsd; {
else count += ((OSDMap)osdNamespace).Count;
return null; }
} }
}
return count;
set }
}
/// <summary>
/// Retrieve a Dynamic Attribute store
/// </summary>
/// <param name="ns">namespace for the store - use "OpenSim" for in-core modules</param>
/// <param name="storeName">name of the store within the namespace</param>
/// <returns>an OSDMap representing the stored data, or null if not found</returns>
public OSDMap GetStore(string ns, string storeName)
{
OSD namespaceOsd;
lock (this)
{ {
ValidateKey(key); if (m_map.TryGetValue(ns, out namespaceOsd))
lock (this) {
m_map[key] = value; OSD store;
if (((OSDMap)namespaceOsd).TryGetValue(storeName, out store))
return (OSDMap)store;
}
}
return null;
}
/// <summary>
/// Saves a Dynamic attribute store
/// </summary>
/// <param name="ns">namespace for the store - use "OpenSim" for in-core modules</param>
/// <param name="storeName">name of the store within the namespace</param>
/// <param name="store">an OSDMap representing the data to store</param>
public void SetStore(string ns, string storeName, OSDMap store)
{
ValidateNamespace(ns);
OSDMap nsMap;
lock (this)
{
if (!m_map.ContainsKey(ns))
{
nsMap = new OSDMap();
m_map[ns] = nsMap;
}
nsMap = (OSDMap)m_map[ns];
// m_log.DebugFormat("[DA MAP]: Setting store to {0}:{1}", ns, storeName);
nsMap[storeName] = store;
} }
} }
@ -180,54 +261,46 @@ namespace OpenSim.Framework
/// Validate the key used for storing separate data stores. /// Validate the key used for storing separate data stores.
/// </summary> /// </summary>
/// <param name='key'></param> /// <param name='key'></param>
public static void ValidateKey(string key) public static void ValidateNamespace(string ns)
{ {
if (key.Length < MIN_STORE_NAME_LENGTH) if (ns.Length < MIN_NAMESPACE_LENGTH)
throw new Exception("Minimum store name length is " + MIN_STORE_NAME_LENGTH); throw new Exception("Minimum namespace length is " + MIN_NAMESPACE_LENGTH);
} }
public bool ContainsKey(string key) public bool ContainsStore(string ns, string storeName)
{ {
lock (this) OSD namespaceOsd;
return m_map.ContainsKey(key);
}
public void Add(string key, OSDMap store)
{
ValidateKey(key);
lock (this)
m_map.Add(key, store);
}
public void Add(KeyValuePair<string, OSDMap> kvp)
{
ValidateKey(kvp.Key);
lock (this)
m_map.Add(kvp.Key, kvp.Value);
}
public bool Remove(string key)
{
lock (this)
return m_map.Remove(key);
}
public bool TryGetValue(string key, out OSDMap store)
{
lock (this) lock (this)
{ {
OSD llsd; if (m_map.TryGetValue(ns, out namespaceOsd))
if (m_map.TryGetValue(key, out llsd))
{ {
store = (OSDMap)llsd; return ((OSDMap)namespaceOsd).ContainsKey(storeName);
return true;
}
else
{
store = null;
return false;
} }
} }
return false;
}
public bool TryGetStore(string ns, string storeName, out OSDMap store)
{
OSD namespaceOsd;
lock (this)
{
if (m_map.TryGetValue(ns, out namespaceOsd))
{
OSD storeOsd;
bool result = ((OSDMap)namespaceOsd).TryGetValue(storeName, out storeOsd);
store = (OSDMap)storeOsd;
return result;
}
}
store = null;
return false;
} }
public void Clear() public void Clear()
@ -235,39 +308,25 @@ namespace OpenSim.Framework
lock (this) lock (this)
m_map.Clear(); m_map.Clear();
} }
public bool Contains(KeyValuePair<string, OSDMap> kvp) public bool RemoveStore(string ns, string storeName)
{ {
OSD namespaceOsd;
lock (this) lock (this)
return m_map.ContainsKey(kvp.Key); {
} if (m_map.TryGetValue(ns, out namespaceOsd))
{
OSDMap namespaceOsdMap = (OSDMap)namespaceOsd;
namespaceOsdMap.Remove(storeName);
public void CopyTo(KeyValuePair<string, OSDMap>[] array, int index) // Don't keep empty namespaces around
{ if (namespaceOsdMap.Count <= 0)
throw new NotImplementedException(); m_map.Remove(ns);
} }
}
public bool Remove(KeyValuePair<string, OSDMap> kvp) return false;
{ }
lock (this)
return m_map.Remove(kvp.Key);
}
public System.Collections.IDictionaryEnumerator GetEnumerator()
{
lock (this)
return m_map.GetEnumerator();
}
IEnumerator<KeyValuePair<string, OSDMap>> IEnumerable<KeyValuePair<string, OSDMap>>.GetEnumerator()
{
return null;
}
IEnumerator IEnumerable.GetEnumerator()
{
lock (this)
return m_map.GetEnumerator();
}
} }
} }

View File

@ -42,22 +42,22 @@ namespace OpenSim.Framework
/// This class stores and retrieves dynamic objects. /// This class stores and retrieves dynamic objects.
/// </summary> /// </summary>
/// <remarks> /// <remarks>
/// Experimental - DO NOT USE. /// Experimental - DO NOT USE. Does not yet have namespace support.
/// </remarks> /// </remarks>
public class DOMap public class DOMap
{ {
private IDictionary<string, object> m_map; private IDictionary<string, object> m_map;
public void Add(string key, object dynObj) public void Add(string ns, string objName, object dynObj)
{ {
DAMap.ValidateKey(key); DAMap.ValidateNamespace(ns);
lock (this) lock (this)
{ {
if (m_map == null) if (m_map == null)
m_map = new Dictionary<string, object>(); m_map = new Dictionary<string, object>();
m_map.Add(key, dynObj); m_map.Add(objName, dynObj);
} }
} }

View File

@ -972,11 +972,12 @@ namespace OpenSim.Framework
/// <param name="verb"></param> /// <param name="verb"></param>
/// <param name="requestUrl"></param> /// <param name="requestUrl"></param>
/// <param name="obj"> </param> /// <param name="obj"> </param>
/// <param name="timeoutsecs"> </param>
/// <returns></returns> /// <returns></returns>
/// ///
/// <exception cref="System.Net.WebException">Thrown if we encounter a network issue while posting /// <exception cref="System.Net.WebException">Thrown if we encounter a network issue while posting
/// the request. You'll want to make sure you deal with this as they're not uncommon</exception> /// the request. You'll want to make sure you deal with this as they're not uncommon</exception>
public static string MakeRequest(string verb, string requestUrl, string obj) public static string MakeRequest(string verb, string requestUrl, string obj, int timeoutsecs)
{ {
int reqnum = WebUtil.RequestNumber++; int reqnum = WebUtil.RequestNumber++;
@ -990,6 +991,8 @@ namespace OpenSim.Framework
WebRequest request = WebRequest.Create(requestUrl); WebRequest request = WebRequest.Create(requestUrl);
request.Method = verb; request.Method = verb;
if (timeoutsecs > 0)
request.Timeout = timeoutsecs * 1000;
string respstring = String.Empty; string respstring = String.Empty;
int tickset = Util.EnvironmentTickCountSubtract(tickstart); int tickset = Util.EnvironmentTickCountSubtract(tickstart);
@ -1086,6 +1089,11 @@ namespace OpenSim.Framework
return respstring; return respstring;
} }
public static string MakeRequest(string verb, string requestUrl, string obj)
{
return MakeRequest(verb, requestUrl, obj, -1);
}
} }
public class SynchronousRestObjectRequester public class SynchronousRestObjectRequester

View File

@ -183,6 +183,7 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
if (Util.ParseUniversalUserIdentifier(finfo.Friend, out id, out url, out first, out last, out tmp)) if (Util.ParseUniversalUserIdentifier(finfo.Friend, out id, out url, out first, out last, out tmp))
{ {
IUserManagement uMan = m_Scenes[0].RequestModuleInterface<IUserManagement>(); IUserManagement uMan = m_Scenes[0].RequestModuleInterface<IUserManagement>();
m_log.DebugFormat("[HGFRIENDS MODULE]: caching {0}", finfo.Friend);
uMan.AddUser(id, url + ";" + first + " " + last); uMan.AddUser(id, url + ";" + first + " " + last);
} }
} }
@ -347,31 +348,31 @@ namespace OpenSim.Region.CoreModules.Avatar.Friends
return null; return null;
} }
public override FriendInfo[] GetFriendsFromService(IClientAPI client) // public override FriendInfo[] GetFriendsFromService(IClientAPI client)
{ // {
// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetFriendsFromService for {0}", client.Name); //// m_log.DebugFormat("[HGFRIENDS MODULE]: Entering GetFriendsFromService for {0}", client.Name);
Boolean agentIsLocal = true; // Boolean agentIsLocal = true;
if (UserManagementModule != null) // if (UserManagementModule != null)
agentIsLocal = UserManagementModule.IsLocalGridUser(client.AgentId); // agentIsLocal = UserManagementModule.IsLocalGridUser(client.AgentId);
if (agentIsLocal) // if (agentIsLocal)
return base.GetFriendsFromService(client); // return base.GetFriendsFromService(client);
FriendInfo[] finfos = new FriendInfo[0]; // FriendInfo[] finfos = new FriendInfo[0];
// Foreigner // // Foreigner
AgentCircuitData agentClientCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode); // AgentCircuitData agentClientCircuit = ((Scene)(client.Scene)).AuthenticateHandler.GetAgentCircuitData(client.CircuitCode);
if (agentClientCircuit != null) // if (agentClientCircuit != null)
{ // {
//[XXX] string agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit); // //[XXX] string agentUUI = Util.ProduceUserUniversalIdentifier(agentClientCircuit);
finfos = FriendsService.GetFriends(client.AgentId.ToString()); // finfos = FriendsService.GetFriends(client.AgentId.ToString());
m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, client.AgentId.ToString()); // m_log.DebugFormat("[HGFRIENDS MODULE]: Fetched {0} local friends for visitor {1}", finfos.Length, client.AgentId.ToString());
} // }
// m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting GetFriendsFromService for {0}", client.Name); //// m_log.DebugFormat("[HGFRIENDS MODULE]: Exiting GetFriendsFromService for {0}", client.Name);
return finfos; // return finfos;
} // }
protected override bool StoreRights(UUID agentID, UUID friendID, int rights) protected override bool StoreRights(UUID agentID, UUID friendID, int rights)
{ {

View File

@ -44,11 +44,12 @@ namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule
[Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DAExampleModule")] [Extension(Path = "/OpenSim/RegionModules", NodeName = "RegionModule", Id = "DAExampleModule")]
public class DAExampleModule : INonSharedRegionModule public class DAExampleModule : INonSharedRegionModule
{ {
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
private static readonly bool ENABLED = false; // enable for testing private readonly bool ENABLED = false; // enable for testing
public const string DANamespace = "DAExample Module"; public const string Namespace = "Example";
public const string StoreName = "DA";
protected Scene m_scene; protected Scene m_scene;
protected IDialogModule m_dialogMod; protected IDialogModule m_dialogMod;
@ -65,6 +66,8 @@ namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule
m_scene = scene; m_scene = scene;
m_scene.EventManager.OnSceneGroupMove += OnSceneGroupMove; m_scene.EventManager.OnSceneGroupMove += OnSceneGroupMove;
m_dialogMod = m_scene.RequestModuleInterface<IDialogModule>(); m_dialogMod = m_scene.RequestModuleInterface<IDialogModule>();
m_log.DebugFormat("[DA EXAMPLE MODULE]: Added region {0}", m_scene.Name);
} }
} }
@ -91,7 +94,7 @@ namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule
if (sop == null) if (sop == null)
return true; return true;
if (!sop.DynAttrs.TryGetValue(DANamespace, out attrs)) if (!sop.DynAttrs.TryGetStore(Namespace, StoreName, out attrs))
attrs = new OSDMap(); attrs = new OSDMap();
OSDInteger newValue; OSDInteger newValue;
@ -106,12 +109,14 @@ namespace OpenSim.Region.CoreModules.Framework.DynamicAttributes.DAExampleModule
attrs["moves"] = newValue; attrs["moves"] = newValue;
sop.DynAttrs[DANamespace] = attrs; sop.DynAttrs.SetStore(Namespace, StoreName, attrs);
} }
sop.ParentGroup.HasGroupChanged = true; sop.ParentGroup.HasGroupChanged = true;
m_dialogMod.SendGeneralAlert(string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue)); string msg = string.Format("{0} {1} moved {2} times", sop.Name, sop.UUID, newValue);
m_log.DebugFormat("[DA EXAMPLE MODULE]: {0}", msg);
m_dialogMod.SendGeneralAlert(msg);
return true; return true;
} }

View File

@ -64,8 +64,8 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule
private Scene m_scene; private Scene m_scene;
private IDialogModule m_dialogMod; private IDialogModule m_dialogMod;
public string Name { get { return "DOExample Module"; } } public string Name { get { return "DO"; } }
public Type ReplaceableInterface { get { return null; } } public Type ReplaceableInterface { get { return null; } }
public void Initialise(IConfigSource source) {} public void Initialise(IConfigSource source) {}
@ -106,7 +106,7 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule
// Console.WriteLine("Here for {0}", so.Name); // Console.WriteLine("Here for {0}", so.Name);
if (rootPart.DynAttrs.TryGetValue(DAExampleModule.DANamespace, out attrs)) if (rootPart.DynAttrs.TryGetStore(DAExampleModule.Namespace, DAExampleModule.StoreName, out attrs))
{ {
movesSoFar = attrs["moves"].AsInteger(); movesSoFar = attrs["moves"].AsInteger();
@ -114,7 +114,7 @@ namespace OpenSim.Region.Framework.DynamicAttributes.DOExampleModule
"[DO EXAMPLE MODULE]: Found saved moves {0} for {1} in {2}", movesSoFar, so.Name, m_scene.Name); "[DO EXAMPLE MODULE]: Found saved moves {0} for {1} in {2}", movesSoFar, so.Name, m_scene.Name);
} }
rootPart.DynObjs.Add(Name, new MyObject(movesSoFar)); rootPart.DynObjs.Add(DAExampleModule.Namespace, Name, new MyObject(movesSoFar));
} }
private bool OnSceneGroupMove(UUID groupId, Vector3 delta) private bool OnSceneGroupMove(UUID groupId, Vector3 delta)

View File

@ -320,7 +320,7 @@ namespace OpenSim.Region.CoreModules.Framework.UserManagement
else else
{ {
names[0] = "Unknown"; names[0] = "Unknown";
names[1] = "UserUMMTGUN2"; names[1] = "UserUMMTGUN3";
return false; return false;
} }

View File

@ -196,7 +196,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
Util.FireAndForget(delegate Util.FireAndForget(delegate
{ {
foreach (InventoryItemBase item in items) foreach (InventoryItemBase item in items)
UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); if (!string.IsNullOrEmpty(item.CreatorData))
UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
}); });
} }

View File

@ -204,7 +204,8 @@ namespace OpenSim.Region.CoreModules.ServiceConnectorsOut.Inventory
Util.FireAndForget(delegate Util.FireAndForget(delegate
{ {
foreach (InventoryItemBase item in items) foreach (InventoryItemBase item in items)
UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData); if (!string.IsNullOrEmpty(item.CreatorData))
UserManager.AddUser(item.CreatorIdAsUuid, item.CreatorData);
}); });
} }

View File

@ -144,7 +144,20 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
<Flags>None</Flags> <Flags>None</Flags>
<CollisionSound><Guid>00000000-0000-0000-0000-000000000000</Guid></CollisionSound> <CollisionSound><Guid>00000000-0000-0000-0000-000000000000</Guid></CollisionSound>
<CollisionSoundVolume>0</CollisionSoundVolume> <CollisionSoundVolume>0</CollisionSoundVolume>
<DynAttrs><llsd><map><key>MyStore</key><map><key>the answer</key><integer>42</integer></map></map></llsd></DynAttrs> <DynAttrs>
<llsd>
<map>
<key>MyNamespace</key>
<map>
<key>MyStore</key>
<map>
<key>the answer</key>
<integer>42</integer>
</map>
</map>
</map>
</llsd>
</DynAttrs>
</SceneObjectPart> </SceneObjectPart>
</RootPart> </RootPart>
<OtherParts /> <OtherParts />
@ -333,7 +346,20 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
<EveryoneMask>0</EveryoneMask> <EveryoneMask>0</EveryoneMask>
<NextOwnerMask>2147483647</NextOwnerMask> <NextOwnerMask>2147483647</NextOwnerMask>
<Flags>None</Flags> <Flags>None</Flags>
<DynAttrs><llsd><map><key>MyStore</key><map><key>last words</key><string>Rosebud</string></map></map></llsd></DynAttrs> <DynAttrs>
<llsd>
<map>
<key>MyNamespace</key>
<map>
<key>MyStore</key>
<map>
<key>last words</key>
<string>Rosebud</string>
</map>
</map>
</map>
</llsd>
</DynAttrs>
<SitTargetAvatar><UUID>00000000-0000-0000-0000-000000000000</UUID></SitTargetAvatar> <SitTargetAvatar><UUID>00000000-0000-0000-0000-000000000000</UUID></SitTargetAvatar>
</SceneObjectPart> </SceneObjectPart>
<OtherParts /> <OtherParts />
@ -362,7 +388,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
Assert.That(rootPart.UUID, Is.EqualTo(new UUID("e6a5a05e-e8cc-4816-8701-04165e335790"))); Assert.That(rootPart.UUID, Is.EqualTo(new UUID("e6a5a05e-e8cc-4816-8701-04165e335790")));
Assert.That(rootPart.CreatorID, Is.EqualTo(new UUID("a6dacf01-4636-4bb9-8a97-30609438af9d"))); Assert.That(rootPart.CreatorID, Is.EqualTo(new UUID("a6dacf01-4636-4bb9-8a97-30609438af9d")));
Assert.That(rootPart.Name, Is.EqualTo("PrimMyRide")); Assert.That(rootPart.Name, Is.EqualTo("PrimMyRide"));
OSDMap store = rootPart.DynAttrs["MyStore"]; OSDMap store = rootPart.DynAttrs.GetStore("MyNamespace", "MyStore");
Assert.AreEqual(42, store["the answer"].AsInteger()); Assert.AreEqual(42, store["the answer"].AsInteger());
// TODO: Check other properties // TODO: Check other properties
@ -414,13 +440,14 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
rp.CreatorID = rpCreatorId; rp.CreatorID = rpCreatorId;
rp.Shape = shape; rp.Shape = shape;
string daNamespace = "MyNamespace";
string daStoreName = "MyStore"; string daStoreName = "MyStore";
string daKey = "foo"; string daKey = "foo";
string daValue = "bar"; string daValue = "bar";
OSDMap myStore = new OSDMap(); OSDMap myStore = new OSDMap();
myStore.Add(daKey, daValue); myStore.Add(daKey, daValue);
rp.DynAttrs = new DAMap(); rp.DynAttrs = new DAMap();
rp.DynAttrs[daStoreName] = myStore; rp.DynAttrs.SetStore(daNamespace, daStoreName, myStore);
SceneObjectGroup so = new SceneObjectGroup(rp); SceneObjectGroup so = new SceneObjectGroup(rp);
@ -481,7 +508,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
Assert.That(name, Is.EqualTo(rpName)); Assert.That(name, Is.EqualTo(rpName));
Assert.That(creatorId, Is.EqualTo(rpCreatorId)); Assert.That(creatorId, Is.EqualTo(rpCreatorId));
Assert.NotNull(daMap); Assert.NotNull(daMap);
Assert.AreEqual(daValue, daMap[daStoreName][daKey].AsString()); Assert.AreEqual(daValue, daMap.GetStore(daNamespace, daStoreName)[daKey].AsString());
} }
[Test] [Test]
@ -496,7 +523,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
Assert.That(rootPart.UUID, Is.EqualTo(new UUID("9be68fdd-f740-4a0f-9675-dfbbb536b946"))); Assert.That(rootPart.UUID, Is.EqualTo(new UUID("9be68fdd-f740-4a0f-9675-dfbbb536b946")));
Assert.That(rootPart.CreatorID, Is.EqualTo(new UUID("b46ef588-411e-4a8b-a284-d7dcfe8e74ef"))); Assert.That(rootPart.CreatorID, Is.EqualTo(new UUID("b46ef588-411e-4a8b-a284-d7dcfe8e74ef")));
Assert.That(rootPart.Name, Is.EqualTo("PrimFun")); Assert.That(rootPart.Name, Is.EqualTo("PrimFun"));
OSDMap store = rootPart.DynAttrs["MyStore"]; OSDMap store = rootPart.DynAttrs.GetStore("MyNamespace", "MyStore");
Assert.AreEqual("Rosebud", store["last words"].AsString()); Assert.AreEqual("Rosebud", store["last words"].AsString());
// TODO: Check other properties // TODO: Check other properties
@ -522,13 +549,14 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
rp.CreatorID = rpCreatorId; rp.CreatorID = rpCreatorId;
rp.Shape = shape; rp.Shape = shape;
string daNamespace = "MyNamespace";
string daStoreName = "MyStore"; string daStoreName = "MyStore";
string daKey = "foo"; string daKey = "foo";
string daValue = "bar"; string daValue = "bar";
OSDMap myStore = new OSDMap(); OSDMap myStore = new OSDMap();
myStore.Add(daKey, daValue); myStore.Add(daKey, daValue);
rp.DynAttrs = new DAMap(); rp.DynAttrs = new DAMap();
rp.DynAttrs[daStoreName] = myStore; rp.DynAttrs.SetStore(daNamespace, daStoreName, myStore);
SceneObjectGroup so = new SceneObjectGroup(rp); SceneObjectGroup so = new SceneObjectGroup(rp);
@ -585,7 +613,7 @@ namespace OpenSim.Region.CoreModules.World.Serialiser.Tests
Assert.That(name, Is.EqualTo(rpName)); Assert.That(name, Is.EqualTo(rpName));
Assert.That(creatorId, Is.EqualTo(rpCreatorId)); Assert.That(creatorId, Is.EqualTo(rpCreatorId));
Assert.NotNull(daMap); Assert.NotNull(daMap);
Assert.AreEqual(daValue, daMap[daStoreName][daKey].AsString()); Assert.AreEqual(daValue, daMap.GetStore(daNamespace, daStoreName)[daKey].AsString());
} }
} }
} }

View File

@ -1026,6 +1026,16 @@ namespace OpenSim.Region.Framework.Scenes
/// </remarks> /// </remarks>
public event TeleportFail OnTeleportFail; public event TeleportFail OnTeleportFail;
// public delegate void GatherUuids(SceneObjectPart sop, IDictionary<UUID, AssetType> assetUuids);
//
// /// <summary>
// /// Triggered when UUIDs referenced by a scene object are being gathered for archiving, hg transfer, etc.
// /// </summary>
// /// <remarks>
// /// The listener should add references to the IDictionary<UUID, AssetType> as appropriate.
// /// </remarks>
// public event GatherUuids OnGatherUuids;
public class MoneyTransferArgs : EventArgs public class MoneyTransferArgs : EventArgs
{ {
public UUID sender; public UUID sender;
@ -3274,5 +3284,26 @@ namespace OpenSim.Region.Framework.Scenes
handler(scenePresence); handler(scenePresence);
} }
} }
// public void TriggerGatherUuids(SceneObjectPart sop, IDictionary<UUID, AssetType> assetUuids)
// {
// GatherUuids handler = OnGatherUuids;
//
// if (handler != null)
// {
// foreach (GatherUuids d in handler.GetInvocationList())
// {
// try
// {
// d(sop, assetUuids);
// }
// catch (Exception e)
// {
// m_log.ErrorFormat("[EVENT MANAGER]: Delegate for TriggerUuidGather failed - continuing {0} - {1}",
// e.Message, e.StackTrace);
// }
// }
// }
// }
} }
} }

View File

@ -3810,20 +3810,23 @@ namespace OpenSim.Region.Framework.Scenes
/// <summary> /// <summary>
/// Update just the root prim position in a linkset /// Update just the root prim position in a linkset
/// </summary> /// </summary>
/// <param name="pos"></param> /// <param name="newPos"></param>
public void UpdateRootPosition(Vector3 pos) public void UpdateRootPosition(Vector3 newPos)
{ {
// needs to be called with phys building true // needs to be called with phys building true
Vector3 newPos = new Vector3(pos.X, pos.Y, pos.Z); Vector3 oldPos;
Vector3 oldPos =
new Vector3(AbsolutePosition.X + m_rootPart.OffsetPosition.X, // FIXME: This improves the situation where editing just the root prim of an attached object would send
AbsolutePosition.Y + m_rootPart.OffsetPosition.Y, // all the other parts to oblivion after detach/reattach. However, a problem remains since the root prim
AbsolutePosition.Z + m_rootPart.OffsetPosition.Z); // still ends up in the wrong position on reattach.
if (IsAttachment)
oldPos = RootPart.OffsetPosition;
else
oldPos = AbsolutePosition + RootPart.OffsetPosition;
Vector3 diff = oldPos - newPos; Vector3 diff = oldPos - newPos;
Vector3 axDiff = new Vector3(diff.X, diff.Y, diff.Z);
Quaternion partRotation = m_rootPart.RotationOffset; Quaternion partRotation = m_rootPart.RotationOffset;
axDiff *= Quaternion.Inverse(partRotation); diff *= Quaternion.Inverse(partRotation);
diff = axDiff;
SceneObjectPart[] parts = m_parts.GetArray(); SceneObjectPart[] parts = m_parts.GetArray();
for (int i = 0; i < parts.Length; i++) for (int i = 0; i < parts.Length; i++)

View File

@ -1346,7 +1346,7 @@ namespace OpenSim.Region.Framework.Scenes.Serialization
if (sop.MediaUrl != null) if (sop.MediaUrl != null)
writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString()); writer.WriteElementString("MediaUrl", sop.MediaUrl.ToString());
if (sop.DynAttrs.Count > 0) if (sop.DynAttrs.CountNamespaces > 0)
{ {
writer.WriteStartElement("DynAttrs"); writer.WriteStartElement("DynAttrs");
sop.DynAttrs.WriteXml(writer); sop.DynAttrs.WriteXml(writer);

View File

@ -182,7 +182,12 @@ namespace OpenSim.Region.Framework.Scenes
GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids); GatherAssetUuids(tii.AssetID, (AssetType)tii.Type, assetUuids);
} }
// get any texture UUIDs used for materials such as normal and specular maps // FIXME: We need to make gathering modular but we cannot yet, since gatherers are not guaranteed
// to be called with scene objects that are in a scene (e.g. in the case of hg asset mapping and
// inventory transfer. There needs to be a way for a module to register a method without assuming a
// Scene.EventManager is present.
// part.ParentGroup.Scene.EventManager.TriggerGatherUuids(part, assetUuids);
GatherMaterialsUuids(part, assetUuids); GatherMaterialsUuids(part, assetUuids);
} }
catch (Exception e) catch (Exception e)
@ -208,7 +213,6 @@ namespace OpenSim.Region.Framework.Scenes
// } // }
// } // }
/// <summary> /// <summary>
/// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps
/// </summary> /// </summary>
@ -217,20 +221,27 @@ namespace OpenSim.Region.Framework.Scenes
public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids) public void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids)
{ {
// scan thru the dynAttrs map of this part for any textures used as materials // scan thru the dynAttrs map of this part for any textures used as materials
OSDMap OSMaterials = null; OSD osdMaterials = null;
lock (part.DynAttrs) lock (part.DynAttrs)
{ {
if (part.DynAttrs.ContainsKey("OS:Materials")) if (part.DynAttrs.ContainsStore("OpenSim", "Materials"))
OSMaterials = part.DynAttrs["OS:Materials"]; {
if (OSMaterials != null && OSMaterials.ContainsKey("Materials")) OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials");
if (materialsStore == null)
return;
materialsStore.TryGetValue("Materials", out osdMaterials);
}
if (osdMaterials != null)
{ {
OSD osd = OSMaterials["Materials"];
//m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd)); //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd));
if (osd is OSDArray) if (osdMaterials is OSDArray)
{ {
OSDArray matsArr = osd as OSDArray; OSDArray matsArr = osdMaterials as OSDArray;
foreach (OSDMap matMap in matsArr) foreach (OSDMap matMap in matsArr)
{ {
try try
@ -268,8 +279,7 @@ namespace OpenSim.Region.Framework.Scenes
} }
} }
} }
/// <summary> /// <summary>
/// Get an asset synchronously, potentially using an asynchronous callback. If the /// Get an asset synchronously, potentially using an asynchronous callback. If the
/// asynchronous callback is used, we will wait for it to complete. /// asynchronous callback is used, we will wait for it to complete.

View File

@ -121,9 +121,11 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
return; return;
m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName); m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} ADDED", scene.RegionInfo.RegionName);
m_scene = scene; m_scene = scene;
m_scene.EventManager.OnRegisterCaps += new EventManager.RegisterCapsEvent(OnRegisterCaps); m_scene.EventManager.OnRegisterCaps += OnRegisterCaps;
m_scene.EventManager.OnObjectAddedToScene += new Action<SceneObjectGroup>(EventManager_OnObjectAddedToScene); m_scene.EventManager.OnObjectAddedToScene += EventManager_OnObjectAddedToScene;
// m_scene.EventManager.OnGatherUuids += GatherMaterialsUuids;
} }
void EventManager_OnObjectAddedToScene(SceneObjectGroup obj) void EventManager_OnObjectAddedToScene(SceneObjectGroup obj)
@ -157,6 +159,10 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
if (!m_enabled) if (!m_enabled)
return; return;
m_scene.EventManager.OnRegisterCaps -= OnRegisterCaps;
m_scene.EventManager.OnObjectAddedToScene -= EventManager_OnObjectAddedToScene;
// m_scene.EventManager.OnGatherUuids -= GatherMaterialsUuids;
m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName); m_log.DebugFormat("[MaterialsDemoModule]: REGION {0} REMOVED", scene.RegionInfo.RegionName);
} }
@ -167,18 +173,21 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
OSDMap GetMaterial(UUID id) OSDMap GetMaterial(UUID id)
{ {
OSDMap map = null; OSDMap map = null;
if (m_knownMaterials.ContainsKey(id)) lock (m_knownMaterials)
{ {
map = new OSDMap(); if (m_knownMaterials.ContainsKey(id))
map["ID"] = OSD.FromBinary(id.GetBytes()); {
map["Material"] = m_knownMaterials[id]; map = new OSDMap();
map["ID"] = OSD.FromBinary(id.GetBytes());
map["Material"] = m_knownMaterials[id];
}
} }
return map; return map;
} }
void GetStoredMaterialsForPart(SceneObjectPart part) void GetStoredMaterialsForPart(SceneObjectPart part)
{ {
OSDMap OSMaterials = null; OSD OSMaterials = null;
OSDArray matsArr = null; OSDArray matsArr = null;
if (part.DynAttrs == null) if (part.DynAttrs == null)
@ -188,23 +197,24 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
lock (part.DynAttrs) lock (part.DynAttrs)
{ {
if (part.DynAttrs.ContainsKey("OS:Materials")) if (part.DynAttrs.ContainsStore("OpenSim", "Materials"))
OSMaterials = part.DynAttrs["OS:Materials"];
if (OSMaterials != null && OSMaterials.ContainsKey("Materials"))
{ {
OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials");
OSD osd = OSMaterials["Materials"]; if (materialsStore == null)
if (osd is OSDArray) return;
matsArr = osd as OSDArray;
materialsStore.TryGetValue("Materials", out OSMaterials);
} }
if (OSMaterials != null && OSMaterials is OSDArray)
matsArr = OSMaterials as OSDArray;
else
return;
} }
if (OSMaterials == null)
return;
m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials)); m_log.Info("[MaterialsDemoModule]: OSMaterials: " + OSDParser.SerializeJsonString(OSMaterials));
if (matsArr == null) if (matsArr == null)
{ {
m_log.Info("[MaterialsDemoModule]: matsArr is null :( "); m_log.Info("[MaterialsDemoModule]: matsArr is null :( ");
@ -215,13 +225,13 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
{ {
if (elemOsd != null && elemOsd is OSDMap) if (elemOsd != null && elemOsd is OSDMap)
{ {
OSDMap matMap = elemOsd as OSDMap; OSDMap matMap = elemOsd as OSDMap;
if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material")) if (matMap.ContainsKey("ID") && matMap.ContainsKey("Material"))
{ {
try try
{ {
m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"]; lock (m_knownMaterials)
m_knownMaterials[matMap["ID"].AsUUID()] = (OSDMap)matMap["Material"];
} }
catch (Exception e) catch (Exception e)
{ {
@ -232,7 +242,6 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
} }
} }
void StoreMaterialsForPart(SceneObjectPart part) void StoreMaterialsForPart(SceneObjectPart part)
{ {
try try
@ -246,8 +255,11 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
if (te.DefaultTexture != null) if (te.DefaultTexture != null)
{ {
if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID)) lock (m_knownMaterials)
mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID]; {
if (m_knownMaterials.ContainsKey(te.DefaultTexture.MaterialID))
mats[te.DefaultTexture.MaterialID] = m_knownMaterials[te.DefaultTexture.MaterialID];
}
} }
if (te.FaceTextures != null) if (te.FaceTextures != null)
@ -256,8 +268,11 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
{ {
if (face != null) if (face != null)
{ {
if (m_knownMaterials.ContainsKey(face.MaterialID)) lock (m_knownMaterials)
mats[face.MaterialID] = m_knownMaterials[face.MaterialID]; {
if (m_knownMaterials.ContainsKey(face.MaterialID))
mats[face.MaterialID] = m_knownMaterials[face.MaterialID];
}
} }
} }
} }
@ -277,7 +292,7 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
OSMaterials["Materials"] = matsArr; OSMaterials["Materials"] = matsArr;
lock (part.DynAttrs) lock (part.DynAttrs)
part.DynAttrs["OS:Materials"] = OSMaterials; part.DynAttrs.SetStore("OpenSim", "Materials", OSMaterials);
} }
catch (Exception e) catch (Exception e)
{ {
@ -285,7 +300,6 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
} }
} }
public string RenderMaterialsPostCap(string request, string path, public string RenderMaterialsPostCap(string request, string path,
string param, IOSHttpRequest httpRequest, string param, IOSHttpRequest httpRequest,
IOSHttpResponse httpResponse) IOSHttpResponse httpResponse)
@ -319,18 +333,21 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
try try
{ {
UUID id = new UUID(elem.AsBinary(), 0); UUID id = new UUID(elem.AsBinary(), 0);
if (m_knownMaterials.ContainsKey(id))
{
m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString());
OSDMap matMap = new OSDMap();
matMap["ID"] = OSD.FromBinary(id.GetBytes());
matMap["Material"] = m_knownMaterials[id]; lock (m_knownMaterials)
respArr.Add(matMap); {
if (m_knownMaterials.ContainsKey(id))
{
m_log.Info("[MaterialsDemoModule]: request for known material ID: " + id.ToString());
OSDMap matMap = new OSDMap();
matMap["ID"] = OSD.FromBinary(id.GetBytes());
matMap["Material"] = m_knownMaterials[id];
respArr.Add(matMap);
}
else
m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString());
} }
else
m_log.Info("[MaterialsDemoModule]: request for UNKNOWN material ID: " + id.ToString());
} }
catch (Exception e) catch (Exception e)
{ {
@ -368,7 +385,8 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat)); m_log.Debug("[MaterialsDemoModule]: mat: " + OSDParser.SerializeJsonString(mat));
UUID id = HashOsd(mat); UUID id = HashOsd(mat);
m_knownMaterials[id] = mat; lock (m_knownMaterials)
m_knownMaterials[id] = mat;
var sop = m_scene.GetSceneObjectPart(matLocalID); var sop = m_scene.GetSceneObjectPart(matLocalID);
@ -476,24 +494,22 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
m_log.Debug("[MaterialsDemoModule]: GET cap handler"); m_log.Debug("[MaterialsDemoModule]: GET cap handler");
OSDMap resp = new OSDMap(); OSDMap resp = new OSDMap();
int matsCount = 0; int matsCount = 0;
OSDArray allOsd = new OSDArray(); OSDArray allOsd = new OSDArray();
foreach (KeyValuePair<UUID, OSDMap> kvp in m_knownMaterials) lock (m_knownMaterials)
{ {
OSDMap matMap = new OSDMap(); foreach (KeyValuePair<UUID, OSDMap> kvp in m_knownMaterials)
{
OSDMap matMap = new OSDMap();
matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes()); matMap["ID"] = OSD.FromBinary(kvp.Key.GetBytes());
matMap["Material"] = kvp.Value;
matMap["Material"] = kvp.Value; allOsd.Add(matMap);
allOsd.Add(matMap); matsCount++;
matsCount++; }
} }
resp["Zipped"] = ZCompressOSD(allOsd, false); resp["Zipped"] = ZCompressOSD(allOsd, false);
m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString()); m_log.Debug("[MaterialsDemoModule]: matsCount: " + matsCount.ToString());
@ -575,5 +591,72 @@ namespace OpenSim.Region.OptionalModules.MaterialsDemoModule
output.Flush(); output.Flush();
} }
// FIXME: This code is currently still in UuidGatherer since we cannot use Scene.EventManager as some
// calls to the gatherer are done for objects with no scene.
// /// <summary>
// /// Gather all of the texture asset UUIDs used to reference "Materials" such as normal and specular maps
// /// </summary>
// /// <param name="part"></param>
// /// <param name="assetUuids"></param>
// private void GatherMaterialsUuids(SceneObjectPart part, IDictionary<UUID, AssetType> assetUuids)
// {
// // scan thru the dynAttrs map of this part for any textures used as materials
// OSD osdMaterials = null;
//
// lock (part.DynAttrs)
// {
// if (part.DynAttrs.ContainsStore("OpenSim", "Materials"))
// {
// OSDMap materialsStore = part.DynAttrs.GetStore("OpenSim", "Materials");
// if (materialsStore == null)
// return;
//
// materialsStore.TryGetValue("Materials", out osdMaterials);
// }
//
// if (osdMaterials != null)
// {
// //m_log.Info("[UUID Gatherer]: found Materials: " + OSDParser.SerializeJsonString(osd));
//
// if (osdMaterials is OSDArray)
// {
// OSDArray matsArr = osdMaterials as OSDArray;
// foreach (OSDMap matMap in matsArr)
// {
// try
// {
// if (matMap.ContainsKey("Material"))
// {
// OSDMap mat = matMap["Material"] as OSDMap;
// if (mat.ContainsKey("NormMap"))
// {
// UUID normalMapId = mat["NormMap"].AsUUID();
// if (normalMapId != UUID.Zero)
// {
// assetUuids[normalMapId] = AssetType.Texture;
// //m_log.Info("[UUID Gatherer]: found normal map ID: " + normalMapId.ToString());
// }
// }
// if (mat.ContainsKey("SpecMap"))
// {
// UUID specularMapId = mat["SpecMap"].AsUUID();
// if (specularMapId != UUID.Zero)
// {
// assetUuids[specularMapId] = AssetType.Texture;
// //m_log.Info("[UUID Gatherer]: found specular map ID: " + specularMapId.ToString());
// }
// }
// }
//
// }
// catch (Exception e)
// {
// m_log.Warn("[MaterialsDemoModule]: exception getting materials: " + e.Message);
// }
// }
// }
// }
// }
// }
} }
} }

View File

@ -119,16 +119,14 @@ namespace OpenSim.Server.Handlers.Asset
if (asset == null || asset.Data.Length == 0) if (asset == null || asset.Data.Length == 0)
{ {
MainConsole.Instance.Output("Asset not found"); MainConsole.Instance.OutputFormat("Could not find asset with ID {0}", args[2]);
return; return;
} }
m_AssetService.Delete(args[2]); if (!m_AssetService.Delete(asset.ID))
MainConsole.Instance.OutputFormat("ERROR: Could not delete asset {0} {1}", asset.ID, asset.Name);
//MainConsole.Instance.Output("Asset deleted"); else
// TODO: Implement this MainConsole.Instance.OutputFormat("Deleted asset {0} {1}", asset.ID, asset.Name);
MainConsole.Instance.Output("Asset deletion not supported by database");
} }
void HandleDumpAsset(string module, string[] args) void HandleDumpAsset(string module, string[] args)

View File

@ -205,15 +205,16 @@ namespace OpenSim.Services.AssetService
if (!UUID.TryParse(id, out assetID)) if (!UUID.TryParse(id, out assetID))
return false; return false;
// Don't bother deleting from a chained asset service. This isn't a big deal since deleting happens if (HasChainedAssetService)
// very rarely. m_ChainedAssetService.Delete(id);
return m_Database.Delete(id); return m_Database.Delete(id);
} }
private void MigrateFromChainedService(AssetBase asset) private void MigrateFromChainedService(AssetBase asset)
{ {
Util.FireAndForget(o => { Store(asset); m_ChainedAssetService.Delete(asset.ID); }); Store(asset);
m_ChainedAssetService.Delete(asset.ID);
} }
} }
} }

View File

@ -277,7 +277,7 @@ namespace OpenSim.Services.Connectors.Hypergrid
{ {
reply = SynchronousRestFormsRequester.MakeRequest("POST", reply = SynchronousRestFormsRequester.MakeRequest("POST",
uri, uri,
ServerUtils.BuildQueryString(sendData)); ServerUtils.BuildQueryString(sendData), 15);
} }
catch (Exception e) catch (Exception e)
{ {

Binary file not shown.

View File

@ -746,4 +746,16 @@
<Key Name="assetType" Value="0" /> <Key Name="assetType" Value="0" />
<Key Name="fileName" Value="735198cf-6ea0-2550-e222-21d3c6a341ae.j2c" /> <Key Name="fileName" Value="735198cf-6ea0-2550-e222-21d3c6a341ae.j2c" />
</Section> </Section>
<!--
Texture expected by viewers for properly displaying stars in the night sky
Name derives from label in viewer code
-->
<Section Name="IMG_BLOOM1 Texture">
<Key Name="assetID" Value="3c59f7fe-9dc8-47f9-8aaf-a9dd1fbc3bef"/>
<Key Name="name" Value="IMG_BLOOM1 Texture"/>
<Key Name="assetType" Value="0" />
<Key Name="fileName" Value="IMG_BLOOM1.jp2" />
</Section>
</Nini> </Nini>