aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim/Region/ScriptEngine
diff options
context:
space:
mode:
authorJustin Clark-Casey (justincc)2010-03-04 20:08:25 +0000
committerJustin Clark-Casey (justincc)2010-05-20 22:43:05 +0100
commit76238715e3c8f4ba22cdd6dd09a282a0b52bad4d (patch)
tree427ca679e947a1e58a6742fbe044dd4793839c6b /OpenSim/Region/ScriptEngine
parentMake "nant distbin" remove BUILDING.txt (diff)
downloadopensim-SC-76238715e3c8f4ba22cdd6dd09a282a0b52bad4d.zip
opensim-SC-76238715e3c8f4ba22cdd6dd09a282a0b52bad4d.tar.gz
opensim-SC-76238715e3c8f4ba22cdd6dd09a282a0b52bad4d.tar.bz2
opensim-SC-76238715e3c8f4ba22cdd6dd09a282a0b52bad4d.tar.xz
move linden notecard parsing from LSL_Api.cs to SLUtil so that region modules can use it
backport from master
Diffstat (limited to 'OpenSim/Region/ScriptEngine')
-rw-r--r--OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs83
1 files changed, 2 insertions, 81 deletions
diff --git a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
index 3b2c9b1..e4e087f 100644
--- a/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
+++ b/OpenSim/Region/ScriptEngine/Shared/Api/Implementation/LSL_Api.cs
@@ -9784,90 +9784,11 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9784 9784
9785 Notecard nc = new Notecard(); 9785 Notecard nc = new Notecard();
9786 nc.lastRef = DateTime.Now; 9786 nc.lastRef = DateTime.Now;
9787 nc.text = ParseText(text.Replace("\r", "").Split('\n')); 9787 nc.text = SLUtil.ParseNotecardToList(text).ToArray();
9788 m_Notecards[assetID] = nc; 9788 m_Notecards[assetID] = nc;
9789 } 9789 }
9790 } 9790 }
9791 9791
9792 protected static string[] ParseText(string[] input)
9793 {
9794 int idx = 0;
9795 int level = 0;
9796 List<string> output = new List<string>();
9797 string[] words;
9798
9799 while (idx < input.Length)
9800 {
9801 if (input[idx] == "{")
9802 {
9803 level++;
9804 idx++;
9805 continue;
9806 }
9807
9808 if (input[idx]== "}")
9809 {
9810 level--;
9811 idx++;
9812 continue;
9813 }
9814
9815 switch (level)
9816 {
9817 case 0:
9818 words = input[idx].Split(' '); // Linden text ver
9819 // Notecards are created *really* empty. Treat that as "no text" (just like after saving an empty notecard)
9820 if (words.Length < 3)
9821 return new String[0];
9822
9823 int version = int.Parse(words[3]);
9824 if (version != 2)
9825 return new String[0];
9826 break;
9827 case 1:
9828 words = input[idx].Split(' ');
9829 if (words[0] == "LLEmbeddedItems")
9830 break;
9831 if (words[0] == "Text")
9832 {
9833 int len = int.Parse(words[2]);
9834 idx++;
9835
9836 int count = -1;
9837
9838 while (count < len)
9839 {
9840 // int l = input[idx].Length;
9841 string ln = input[idx];
9842
9843 int need = len-count-1;
9844 if (ln.Length > need)
9845 ln = ln.Substring(0, need);
9846
9847 output.Add(ln);
9848 count += ln.Length + 1;
9849 idx++;
9850 }
9851
9852 return output.ToArray();
9853 }
9854 break;
9855 case 2:
9856 words = input[idx].Split(' '); // count
9857 if (words[0] == "count")
9858 {
9859 int c = int.Parse(words[1]);
9860 if (c > 0)
9861 return new String[0];
9862 break;
9863 }
9864 break;
9865 }
9866 idx++;
9867 }
9868 return output.ToArray();
9869 }
9870
9871 public static bool IsCached(UUID assetID) 9792 public static bool IsCached(UUID assetID)
9872 { 9793 {
9873 lock (m_Notecards) 9794 lock (m_Notecards)
@@ -9923,4 +9844,4 @@ namespace OpenSim.Region.ScriptEngine.Shared.Api
9923 } 9844 }
9924 } 9845 }
9925 } 9846 }
9926} 9847} \ No newline at end of file