Allow reading of notecards by asset ID.

Fixes Manthis #3420
0.6.5-rc1
Melanie Thielker 2009-04-18 19:08:35 +00:00
parent 2578db3dfa
commit d285ccb5cf
1 changed files with 111 additions and 55 deletions

View File

@ -9172,23 +9172,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
UUID assetID = UUID.Zero;
if (!UUID.TryParse(name, out assetID))
{
foreach (TaskInventoryItem item in itemsDictionary.Values) foreach (TaskInventoryItem item in itemsDictionary.Values)
{ {
if (item.Type == 7 && item.Name == name) if (item.Type == 7 && item.Name == name)
{ {
UUID tid = AsyncCommands. assetID = item.AssetID;
DataserverPlugin.RegisterRequest(m_localID, break;
m_itemID, item.AssetID.ToString()); }
if (NotecardCache.IsCached(item.AssetID)) }
}
if (assetID == UUID.Zero)
{ {
// => complain loudly, as specified by the LSL docs
ShoutError("Notecard '" + name + "' could not be found.");
}
UUID tid = UUID.Zero;
if (NotecardCache.IsCached(assetID))
{
tid = AsyncCommands.
DataserverPlugin.RegisterRequest(m_localID,
m_itemID, assetID.ToString());
AsyncCommands. AsyncCommands.
DataserverPlugin.DataserverReply(item.AssetID.ToString(), DataserverPlugin.DataserverReply(assetID.ToString(),
NotecardCache.GetLines(item.AssetID).ToString()); NotecardCache.GetLines(assetID).ToString());
// ScriptSleep(100); // ScriptSleep(100);
return tid.ToString(); return tid.ToString();
} }
WithNotecard(item.AssetID, delegate (UUID id, AssetBase a)
WithNotecard(assetID, delegate (UUID id, AssetBase a)
{ {
if (a.Type != 7)
return;
tid = AsyncCommands.
DataserverPlugin.RegisterRequest(m_localID,
m_itemID, assetID.ToString());
System.Text.ASCIIEncoding enc = System.Text.ASCIIEncoding enc =
new System.Text.ASCIIEncoding(); new System.Text.ASCIIEncoding();
string data = enc.GetString(a.Data); string data = enc.GetString(a.Data);
@ -9198,10 +9225,13 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
DataserverPlugin.DataserverReply(id.ToString(), DataserverPlugin.DataserverReply(id.ToString(),
NotecardCache.GetLines(id).ToString()); NotecardCache.GetLines(id).ToString());
}); });
if (tid != UUID.Zero)
{
// ScriptSleep(100); // ScriptSleep(100);
return tid.ToString(); return tid.ToString();
} }
}
// if we got to here, we didn't find the notecard the script was asking for // if we got to here, we didn't find the notecard the script was asking for
// => complain loudly, as specified by the LSL docs // => complain loudly, as specified by the LSL docs
ShoutError("Notecard '" + name + "' could not be found."); ShoutError("Notecard '" + name + "' could not be found.");
@ -9216,25 +9246,50 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone(); TaskInventoryDictionary itemsDictionary = (TaskInventoryDictionary)m_host.TaskInventory.Clone();
UUID assetID = UUID.Zero;
if (!UUID.TryParse(name, out assetID))
{
foreach (TaskInventoryItem item in itemsDictionary.Values) foreach (TaskInventoryItem item in itemsDictionary.Values)
{ {
if (item.Type == 7 && item.Name == name) if (item.Type == 7 && item.Name == name)
{ {
UUID tid = AsyncCommands. assetID = item.AssetID;
DataserverPlugin.RegisterRequest(m_localID, break;
m_itemID, item.AssetID.ToString()); }
}
}
if (NotecardCache.IsCached(item.AssetID)) if (assetID == UUID.Zero)
{ {
// => complain loudly, as specified by the LSL docs
ShoutError("Notecard '" + name + "' could not be found.");
}
UUID tid = UUID.Zero;
if (NotecardCache.IsCached(assetID))
{
tid = AsyncCommands.
DataserverPlugin.RegisterRequest(m_localID,
m_itemID, assetID.ToString());
AsyncCommands. AsyncCommands.
DataserverPlugin.DataserverReply(item.AssetID.ToString(), DataserverPlugin.DataserverReply(assetID.ToString(),
NotecardCache.GetLine(item.AssetID, line, m_notecardLineReadCharsMax)); NotecardCache.GetLine(assetID, line, m_notecardLineReadCharsMax));
// ScriptSleep(100); // ScriptSleep(100);
return tid.ToString(); return tid.ToString();
} }
WithNotecard(item.AssetID, delegate (UUID id, AssetBase a) WithNotecard(assetID, delegate (UUID id, AssetBase a)
{ {
if (a.Type != 7)
return;
tid = AsyncCommands.
DataserverPlugin.RegisterRequest(m_localID,
m_itemID, assetID.ToString());
System.Text.ASCIIEncoding enc = System.Text.ASCIIEncoding enc =
new System.Text.ASCIIEncoding(); new System.Text.ASCIIEncoding();
string data = enc.GetString(a.Data); string data = enc.GetString(a.Data);
@ -9245,10 +9300,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
NotecardCache.GetLine(id, line, m_notecardLineReadCharsMax)); NotecardCache.GetLine(id, line, m_notecardLineReadCharsMax));
}); });
if (tid != UUID.Zero)
{
// ScriptSleep(100); // ScriptSleep(100);
return tid.ToString(); return tid.ToString();
} }
}
// if we got to here, we didn't find the notecard the script was asking for // if we got to here, we didn't find the notecard the script was asking for
// => complain loudly, as specified by the LSL docs // => complain loudly, as specified by the LSL docs