move linden notecard parsing from LSL_Api.cs to SLUtil so that region modules can use it
backport from master0.6.9-post-fixes
parent
009b15c436
commit
76238715e3
|
@ -0,0 +1,282 @@
|
||||||
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using OpenMetaverse;
|
||||||
|
|
||||||
|
namespace OpenSim.Framework
|
||||||
|
{
|
||||||
|
public static class SLUtil
|
||||||
|
{
|
||||||
|
#region SL / file extension / content-type conversions
|
||||||
|
|
||||||
|
public static string SLAssetTypeToContentType(int assetType)
|
||||||
|
{
|
||||||
|
switch ((AssetType)assetType)
|
||||||
|
{
|
||||||
|
case AssetType.Texture:
|
||||||
|
return "image/x-j2c";
|
||||||
|
case AssetType.Sound:
|
||||||
|
return "application/ogg";
|
||||||
|
case AssetType.CallingCard:
|
||||||
|
return "application/vnd.ll.callingcard";
|
||||||
|
case AssetType.Landmark:
|
||||||
|
return "application/vnd.ll.landmark";
|
||||||
|
case AssetType.Clothing:
|
||||||
|
return "application/vnd.ll.clothing";
|
||||||
|
case AssetType.Object:
|
||||||
|
return "application/vnd.ll.primitive";
|
||||||
|
case AssetType.Notecard:
|
||||||
|
return "application/vnd.ll.notecard";
|
||||||
|
case AssetType.Folder:
|
||||||
|
return "application/vnd.ll.folder";
|
||||||
|
case AssetType.RootFolder:
|
||||||
|
return "application/vnd.ll.rootfolder";
|
||||||
|
case AssetType.LSLText:
|
||||||
|
return "application/vnd.ll.lsltext";
|
||||||
|
case AssetType.LSLBytecode:
|
||||||
|
return "application/vnd.ll.lslbyte";
|
||||||
|
case AssetType.TextureTGA:
|
||||||
|
case AssetType.ImageTGA:
|
||||||
|
return "image/tga";
|
||||||
|
case AssetType.Bodypart:
|
||||||
|
return "application/vnd.ll.bodypart";
|
||||||
|
case AssetType.TrashFolder:
|
||||||
|
return "application/vnd.ll.trashfolder";
|
||||||
|
case AssetType.SnapshotFolder:
|
||||||
|
return "application/vnd.ll.snapshotfolder";
|
||||||
|
case AssetType.LostAndFoundFolder:
|
||||||
|
return "application/vnd.ll.lostandfoundfolder";
|
||||||
|
case AssetType.SoundWAV:
|
||||||
|
return "audio/x-wav";
|
||||||
|
case AssetType.ImageJPEG:
|
||||||
|
return "image/jpeg";
|
||||||
|
case AssetType.Animation:
|
||||||
|
return "application/vnd.ll.animation";
|
||||||
|
case AssetType.Gesture:
|
||||||
|
return "application/vnd.ll.gesture";
|
||||||
|
case AssetType.Simstate:
|
||||||
|
return "application/x-metaverse-simstate";
|
||||||
|
case AssetType.Unknown:
|
||||||
|
default:
|
||||||
|
return "application/octet-stream";
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static sbyte ContentTypeToSLAssetType(string contentType)
|
||||||
|
{
|
||||||
|
switch (contentType)
|
||||||
|
{
|
||||||
|
case "image/x-j2c":
|
||||||
|
case "image/jp2":
|
||||||
|
return (sbyte)AssetType.Texture;
|
||||||
|
case "application/ogg":
|
||||||
|
return (sbyte)AssetType.Sound;
|
||||||
|
case "application/vnd.ll.callingcard":
|
||||||
|
case "application/x-metaverse-callingcard":
|
||||||
|
return (sbyte)AssetType.CallingCard;
|
||||||
|
case "application/vnd.ll.landmark":
|
||||||
|
case "application/x-metaverse-landmark":
|
||||||
|
return (sbyte)AssetType.Landmark;
|
||||||
|
case "application/vnd.ll.clothing":
|
||||||
|
case "application/x-metaverse-clothing":
|
||||||
|
return (sbyte)AssetType.Clothing;
|
||||||
|
case "application/vnd.ll.primitive":
|
||||||
|
case "application/x-metaverse-primitive":
|
||||||
|
return (sbyte)AssetType.Object;
|
||||||
|
case "application/vnd.ll.notecard":
|
||||||
|
case "application/x-metaverse-notecard":
|
||||||
|
return (sbyte)AssetType.Notecard;
|
||||||
|
case "application/vnd.ll.folder":
|
||||||
|
return (sbyte)AssetType.Folder;
|
||||||
|
case "application/vnd.ll.rootfolder":
|
||||||
|
return (sbyte)AssetType.RootFolder;
|
||||||
|
case "application/vnd.ll.lsltext":
|
||||||
|
case "application/x-metaverse-lsl":
|
||||||
|
return (sbyte)AssetType.LSLText;
|
||||||
|
case "application/vnd.ll.lslbyte":
|
||||||
|
case "application/x-metaverse-lso":
|
||||||
|
return (sbyte)AssetType.LSLBytecode;
|
||||||
|
case "image/tga":
|
||||||
|
// Note that AssetType.TextureTGA will be converted to AssetType.ImageTGA
|
||||||
|
return (sbyte)AssetType.ImageTGA;
|
||||||
|
case "application/vnd.ll.bodypart":
|
||||||
|
case "application/x-metaverse-bodypart":
|
||||||
|
return (sbyte)AssetType.Bodypart;
|
||||||
|
case "application/vnd.ll.trashfolder":
|
||||||
|
return (sbyte)AssetType.TrashFolder;
|
||||||
|
case "application/vnd.ll.snapshotfolder":
|
||||||
|
return (sbyte)AssetType.SnapshotFolder;
|
||||||
|
case "application/vnd.ll.lostandfoundfolder":
|
||||||
|
return (sbyte)AssetType.LostAndFoundFolder;
|
||||||
|
case "audio/x-wav":
|
||||||
|
return (sbyte)AssetType.SoundWAV;
|
||||||
|
case "image/jpeg":
|
||||||
|
return (sbyte)AssetType.ImageJPEG;
|
||||||
|
case "application/vnd.ll.animation":
|
||||||
|
case "application/x-metaverse-animation":
|
||||||
|
return (sbyte)AssetType.Animation;
|
||||||
|
case "application/vnd.ll.gesture":
|
||||||
|
case "application/x-metaverse-gesture":
|
||||||
|
return (sbyte)AssetType.Gesture;
|
||||||
|
case "application/x-metaverse-simstate":
|
||||||
|
return (sbyte)AssetType.Simstate;
|
||||||
|
case "application/octet-stream":
|
||||||
|
default:
|
||||||
|
return (sbyte)AssetType.Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static sbyte ContentTypeToSLInvType(string contentType)
|
||||||
|
{
|
||||||
|
switch (contentType)
|
||||||
|
{
|
||||||
|
case "image/x-j2c":
|
||||||
|
case "image/jp2":
|
||||||
|
case "image/tga":
|
||||||
|
case "image/jpeg":
|
||||||
|
return (sbyte)InventoryType.Texture;
|
||||||
|
case "application/ogg":
|
||||||
|
case "audio/x-wav":
|
||||||
|
return (sbyte)InventoryType.Sound;
|
||||||
|
case "application/vnd.ll.callingcard":
|
||||||
|
case "application/x-metaverse-callingcard":
|
||||||
|
return (sbyte)InventoryType.CallingCard;
|
||||||
|
case "application/vnd.ll.landmark":
|
||||||
|
case "application/x-metaverse-landmark":
|
||||||
|
return (sbyte)InventoryType.Landmark;
|
||||||
|
case "application/vnd.ll.clothing":
|
||||||
|
case "application/x-metaverse-clothing":
|
||||||
|
case "application/vnd.ll.bodypart":
|
||||||
|
case "application/x-metaverse-bodypart":
|
||||||
|
return (sbyte)InventoryType.Wearable;
|
||||||
|
case "application/vnd.ll.primitive":
|
||||||
|
case "application/x-metaverse-primitive":
|
||||||
|
return (sbyte)InventoryType.Object;
|
||||||
|
case "application/vnd.ll.notecard":
|
||||||
|
case "application/x-metaverse-notecard":
|
||||||
|
return (sbyte)InventoryType.Notecard;
|
||||||
|
case "application/vnd.ll.folder":
|
||||||
|
return (sbyte)InventoryType.Folder;
|
||||||
|
case "application/vnd.ll.rootfolder":
|
||||||
|
return (sbyte)InventoryType.RootCategory;
|
||||||
|
case "application/vnd.ll.lsltext":
|
||||||
|
case "application/x-metaverse-lsl":
|
||||||
|
case "application/vnd.ll.lslbyte":
|
||||||
|
case "application/x-metaverse-lso":
|
||||||
|
return (sbyte)InventoryType.LSL;
|
||||||
|
case "application/vnd.ll.trashfolder":
|
||||||
|
case "application/vnd.ll.snapshotfolder":
|
||||||
|
case "application/vnd.ll.lostandfoundfolder":
|
||||||
|
return (sbyte)InventoryType.Folder;
|
||||||
|
case "application/vnd.ll.animation":
|
||||||
|
case "application/x-metaverse-animation":
|
||||||
|
return (sbyte)InventoryType.Animation;
|
||||||
|
case "application/vnd.ll.gesture":
|
||||||
|
case "application/x-metaverse-gesture":
|
||||||
|
return (sbyte)InventoryType.Gesture;
|
||||||
|
case "application/x-metaverse-simstate":
|
||||||
|
return (sbyte)InventoryType.Snapshot;
|
||||||
|
case "application/octet-stream":
|
||||||
|
default:
|
||||||
|
return (sbyte)InventoryType.Unknown;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
#endregion SL / file extension / content-type conversions
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parse a notecard in Linden format to a string of ordinary text.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rawInput"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static string ParseNotecardToString(string rawInput)
|
||||||
|
{
|
||||||
|
return string.Join("\n", ParseNotecardToList(rawInput).ToArray());
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Parse a notecard in Linden format to a list of ordinary lines.
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="rawInput"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
public static List<string> ParseNotecardToList(string rawInput)
|
||||||
|
{
|
||||||
|
string[] input = rawInput.Replace("\r", "").Split('\n');
|
||||||
|
int idx = 0;
|
||||||
|
int level = 0;
|
||||||
|
List<string> output = new List<string>();
|
||||||
|
string[] words;
|
||||||
|
|
||||||
|
while (idx < input.Length)
|
||||||
|
{
|
||||||
|
if (input[idx] == "{")
|
||||||
|
{
|
||||||
|
level++;
|
||||||
|
idx++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (input[idx]== "}")
|
||||||
|
{
|
||||||
|
level--;
|
||||||
|
idx++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (level)
|
||||||
|
{
|
||||||
|
case 0:
|
||||||
|
words = input[idx].Split(' '); // Linden text ver
|
||||||
|
// Notecards are created *really* empty. Treat that as "no text" (just like after saving an empty notecard)
|
||||||
|
if (words.Length < 3)
|
||||||
|
return output;
|
||||||
|
|
||||||
|
int version = int.Parse(words[3]);
|
||||||
|
if (version != 2)
|
||||||
|
return output;
|
||||||
|
break;
|
||||||
|
case 1:
|
||||||
|
words = input[idx].Split(' ');
|
||||||
|
if (words[0] == "LLEmbeddedItems")
|
||||||
|
break;
|
||||||
|
if (words[0] == "Text")
|
||||||
|
{
|
||||||
|
int len = int.Parse(words[2]);
|
||||||
|
idx++;
|
||||||
|
|
||||||
|
int count = -1;
|
||||||
|
|
||||||
|
while (count < len)
|
||||||
|
{
|
||||||
|
// int l = input[idx].Length;
|
||||||
|
string ln = input[idx];
|
||||||
|
|
||||||
|
int need = len-count-1;
|
||||||
|
if (ln.Length > need)
|
||||||
|
ln = ln.Substring(0, need);
|
||||||
|
|
||||||
|
output.Add(ln);
|
||||||
|
count += ln.Length + 1;
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case 2:
|
||||||
|
words = input[idx].Split(' '); // count
|
||||||
|
if (words[0] == "count")
|
||||||
|
{
|
||||||
|
int c = int.Parse(words[1]);
|
||||||
|
if (c > 0)
|
||||||
|
return output;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
idx++;
|
||||||
|
}
|
||||||
|
|
||||||
|
return output;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -164,12 +164,12 @@ namespace OpenSim
|
||||||
m_config.Source = new IniConfigSource();
|
m_config.Source = new IniConfigSource();
|
||||||
m_config.Source.Merge(DefaultConfig());
|
m_config.Source.Merge(DefaultConfig());
|
||||||
|
|
||||||
m_log.Info("[CONFIG] Reading configuration settings");
|
m_log.Info("[CONFIG]: Reading configuration settings");
|
||||||
|
|
||||||
if (sources.Count == 0)
|
if (sources.Count == 0)
|
||||||
{
|
{
|
||||||
m_log.FatalFormat("[CONFIG] Could not load any configuration");
|
m_log.FatalFormat("[CONFIG]: Could not load any configuration");
|
||||||
m_log.FatalFormat("[CONFIG] Did you copy the OpenSim.ini.example file to OpenSim.ini?");
|
m_log.FatalFormat("[CONFIG]: Did you copy the OpenSim.ini.example file to OpenSim.ini?");
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -182,8 +182,8 @@ namespace OpenSim
|
||||||
|
|
||||||
if (!iniFileExists)
|
if (!iniFileExists)
|
||||||
{
|
{
|
||||||
m_log.FatalFormat("[CONFIG] Could not load any configuration");
|
m_log.FatalFormat("[CONFIG]: Could not load any configuration");
|
||||||
m_log.FatalFormat("[CONFIG] Configuration exists, but there was an error loading it!");
|
m_log.FatalFormat("[CONFIG]: Configuration exists, but there was an error loading it!");
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -257,20 +257,17 @@ namespace OpenSim
|
||||||
|
|
||||||
if (!IsUri(iniPath))
|
if (!IsUri(iniPath))
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[CONFIG] Reading configuration file {0}",
|
m_log.InfoFormat("[CONFIG]: Reading configuration file {0}", Path.GetFullPath(iniPath));
|
||||||
Path.GetFullPath(iniPath));
|
|
||||||
|
|
||||||
m_config.Source.Merge(new IniConfigSource(iniPath));
|
m_config.Source.Merge(new IniConfigSource(iniPath));
|
||||||
success = true;
|
success = true;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
m_log.InfoFormat("[CONFIG] {0} is a http:// URI, fetching ...",
|
m_log.InfoFormat("[CONFIG]: {0} is a http:// URI, fetching ...", iniPath);
|
||||||
iniPath);
|
|
||||||
|
|
||||||
// The ini file path is a http URI
|
// The ini file path is a http URI
|
||||||
// Try to read it
|
// Try to read it
|
||||||
//
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
XmlReader r = XmlReader.Create(iniPath);
|
XmlReader r = XmlReader.Create(iniPath);
|
||||||
|
@ -281,7 +278,7 @@ namespace OpenSim
|
||||||
}
|
}
|
||||||
catch (Exception e)
|
catch (Exception e)
|
||||||
{
|
{
|
||||||
m_log.FatalFormat("[CONFIG] Exception reading config from URI {0}\n" + e.ToString(), iniPath);
|
m_log.FatalFormat("[CONFIG]: Exception reading config from URI {0}\n" + e.ToString(), iniPath);
|
||||||
Environment.Exit(1);
|
Environment.Exit(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -107,21 +107,24 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
public event OnSetRootAgentSceneDelegate OnSetRootAgentScene;
|
public event OnSetRootAgentSceneDelegate OnSetRootAgentScene;
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Called when an object is touched/grabbed.
|
/// Fired when an object is touched/grabbed.
|
||||||
/// </summary>
|
/// </summary>
|
||||||
/// The originalID is the local ID of the part that was actually touched. The localID itself is always that of
|
/// The originalID is the local ID of the part that was actually touched. The localID itself is always that of
|
||||||
/// the root part.
|
/// the root part.
|
||||||
public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
|
|
||||||
public event ObjectGrabDelegate OnObjectGrab;
|
public event ObjectGrabDelegate OnObjectGrab;
|
||||||
|
public delegate void ObjectGrabDelegate(uint localID, uint originalID, Vector3 offsetPos, IClientAPI remoteClient, SurfaceTouchEventArgs surfaceArgs);
|
||||||
|
|
||||||
public event ObjectGrabDelegate OnObjectGrabbing;
|
public event ObjectGrabDelegate OnObjectGrabbing;
|
||||||
public event ObjectDeGrabDelegate OnObjectDeGrab;
|
public event ObjectDeGrabDelegate OnObjectDeGrab;
|
||||||
public event ScriptResetDelegate OnScriptReset;
|
public event ScriptResetDelegate OnScriptReset;
|
||||||
|
|
||||||
public event OnPermissionErrorDelegate OnPermissionError;
|
public event OnPermissionErrorDelegate OnPermissionError;
|
||||||
|
|
||||||
public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource);
|
/// <summary>
|
||||||
|
/// Fired when a new script is created.
|
||||||
|
/// </summary>
|
||||||
public event NewRezScript OnRezScript;
|
public event NewRezScript OnRezScript;
|
||||||
|
public delegate void NewRezScript(uint localID, UUID itemID, string script, int startParam, bool postOnRez, string engine, int stateSource);
|
||||||
|
|
||||||
public delegate void RemoveScript(uint localID, UUID itemID);
|
public delegate void RemoveScript(uint localID, UUID itemID);
|
||||||
public event RemoveScript OnRemoveScript;
|
public event RemoveScript OnRemoveScript;
|
||||||
|
@ -163,38 +166,35 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
|
|
||||||
public delegate void ClientClosed(UUID clientID, Scene scene);
|
public delegate void ClientClosed(UUID clientID, Scene scene);
|
||||||
|
|
||||||
public event ClientClosed OnClientClosed;
|
public event ClientClosed OnClientClosed;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This is fired when a scene object property that a script might be interested in (such as color, scale or
|
||||||
|
/// inventory) changes. Only enough information is sent for the LSL changed event
|
||||||
|
/// (see http://lslwiki.net/lslwiki/wakka.php?wakka=changed)
|
||||||
|
/// </summary>
|
||||||
|
public event ScriptChangedEvent OnScriptChangedEvent;
|
||||||
public delegate void ScriptChangedEvent(uint localID, uint change);
|
public delegate void ScriptChangedEvent(uint localID, uint change);
|
||||||
|
|
||||||
public event ScriptChangedEvent OnScriptChangedEvent;
|
|
||||||
|
|
||||||
public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed);
|
public delegate void ScriptControlEvent(uint localID, UUID item, UUID avatarID, uint held, uint changed);
|
||||||
|
|
||||||
public event ScriptControlEvent OnScriptControlEvent;
|
public event ScriptControlEvent OnScriptControlEvent;
|
||||||
|
|
||||||
public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos);
|
public delegate void ScriptAtTargetEvent(uint localID, uint handle, Vector3 targetpos, Vector3 atpos);
|
||||||
|
|
||||||
public event ScriptAtTargetEvent OnScriptAtTargetEvent;
|
public event ScriptAtTargetEvent OnScriptAtTargetEvent;
|
||||||
|
|
||||||
public delegate void ScriptNotAtTargetEvent(uint localID);
|
public delegate void ScriptNotAtTargetEvent(uint localID);
|
||||||
|
|
||||||
public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent;
|
public event ScriptNotAtTargetEvent OnScriptNotAtTargetEvent;
|
||||||
|
|
||||||
public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot);
|
public delegate void ScriptAtRotTargetEvent(uint localID, uint handle, Quaternion targetrot, Quaternion atrot);
|
||||||
|
|
||||||
public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent;
|
public event ScriptAtRotTargetEvent OnScriptAtRotTargetEvent;
|
||||||
|
|
||||||
public delegate void ScriptNotAtRotTargetEvent(uint localID);
|
public delegate void ScriptNotAtRotTargetEvent(uint localID);
|
||||||
|
|
||||||
public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent;
|
public event ScriptNotAtRotTargetEvent OnScriptNotAtRotTargetEvent;
|
||||||
|
|
||||||
public delegate void ScriptColliding(uint localID, ColliderArgs colliders);
|
public delegate void ScriptColliding(uint localID, ColliderArgs colliders);
|
||||||
|
|
||||||
public event ScriptColliding OnScriptColliderStart;
|
public event ScriptColliding OnScriptColliderStart;
|
||||||
public event ScriptColliding OnScriptColliding;
|
public event ScriptColliding OnScriptColliding;
|
||||||
public event ScriptColliding OnScriptCollidingEnd;
|
public event ScriptColliding OnScriptCollidingEnd;
|
||||||
|
|
||||||
public event ScriptColliding OnScriptLandColliderStart;
|
public event ScriptColliding OnScriptLandColliderStart;
|
||||||
public event ScriptColliding OnScriptLandColliding;
|
public event ScriptColliding OnScriptLandColliding;
|
||||||
public event ScriptColliding OnScriptLandColliderEnd;
|
public event ScriptColliding OnScriptLandColliderEnd;
|
||||||
|
|
|
@ -638,7 +638,6 @@ namespace OpenSim.Region.Framework.Scenes
|
||||||
m_items[item.ItemID] = item;
|
m_items[item.ItemID] = item;
|
||||||
m_inventorySerial++;
|
m_inventorySerial++;
|
||||||
m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
|
m_part.TriggerScriptChangedEvent(Changed.INVENTORY);
|
||||||
|
|
||||||
HasInventoryChanged = true;
|
HasInventoryChanged = true;
|
||||||
m_part.ParentGroup.HasGroupChanged = true;
|
m_part.ParentGroup.HasGroupChanged = true;
|
||||||
|
|
||||||
|
|
|
@ -9784,90 +9784,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
|
|
||||||
Notecard nc = new Notecard();
|
Notecard nc = new Notecard();
|
||||||
nc.lastRef = DateTime.Now;
|
nc.lastRef = DateTime.Now;
|
||||||
nc.text = ParseText(text.Replace("\r", "").Split('\n'));
|
nc.text = SLUtil.ParseNotecardToList(text).ToArray();
|
||||||
m_Notecards[assetID] = nc;
|
m_Notecards[assetID] = nc;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected static string[] ParseText(string[] input)
|
|
||||||
{
|
|
||||||
int idx = 0;
|
|
||||||
int level = 0;
|
|
||||||
List<string> output = new List<string>();
|
|
||||||
string[] words;
|
|
||||||
|
|
||||||
while (idx < input.Length)
|
|
||||||
{
|
|
||||||
if (input[idx] == "{")
|
|
||||||
{
|
|
||||||
level++;
|
|
||||||
idx++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (input[idx]== "}")
|
|
||||||
{
|
|
||||||
level--;
|
|
||||||
idx++;
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (level)
|
|
||||||
{
|
|
||||||
case 0:
|
|
||||||
words = input[idx].Split(' '); // Linden text ver
|
|
||||||
// Notecards are created *really* empty. Treat that as "no text" (just like after saving an empty notecard)
|
|
||||||
if (words.Length < 3)
|
|
||||||
return new String[0];
|
|
||||||
|
|
||||||
int version = int.Parse(words[3]);
|
|
||||||
if (version != 2)
|
|
||||||
return new String[0];
|
|
||||||
break;
|
|
||||||
case 1:
|
|
||||||
words = input[idx].Split(' ');
|
|
||||||
if (words[0] == "LLEmbeddedItems")
|
|
||||||
break;
|
|
||||||
if (words[0] == "Text")
|
|
||||||
{
|
|
||||||
int len = int.Parse(words[2]);
|
|
||||||
idx++;
|
|
||||||
|
|
||||||
int count = -1;
|
|
||||||
|
|
||||||
while (count < len)
|
|
||||||
{
|
|
||||||
// int l = input[idx].Length;
|
|
||||||
string ln = input[idx];
|
|
||||||
|
|
||||||
int need = len-count-1;
|
|
||||||
if (ln.Length > need)
|
|
||||||
ln = ln.Substring(0, need);
|
|
||||||
|
|
||||||
output.Add(ln);
|
|
||||||
count += ln.Length + 1;
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
|
|
||||||
return output.ToArray();
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case 2:
|
|
||||||
words = input[idx].Split(' '); // count
|
|
||||||
if (words[0] == "count")
|
|
||||||
{
|
|
||||||
int c = int.Parse(words[1]);
|
|
||||||
if (c > 0)
|
|
||||||
return new String[0];
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
idx++;
|
|
||||||
}
|
|
||||||
return output.ToArray();
|
|
||||||
}
|
|
||||||
|
|
||||||
public static bool IsCached(UUID assetID)
|
public static bool IsCached(UUID assetID)
|
||||||
{
|
{
|
||||||
lock (m_Notecards)
|
lock (m_Notecards)
|
||||||
|
@ -9923,4 +9844,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
Loading…
Reference in New Issue