aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/OpenSim
diff options
context:
space:
mode:
Diffstat (limited to 'OpenSim')
-rw-r--r--OpenSim/Framework/Util.cs17
-rw-r--r--OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs62
2 files changed, 47 insertions, 32 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs
index c5c4ab3..e12d37a 100644
--- a/OpenSim/Framework/Util.cs
+++ b/OpenSim/Framework/Util.cs
@@ -864,11 +864,24 @@ namespace OpenSim.Framework
864 private static byte[] ComputeSHA1Hash(byte[] src) 864 private static byte[] ComputeSHA1Hash(byte[] src)
865 { 865 {
866 byte[] ret; 866 byte[] ret;
867 using(SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider()) 867 using (SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider())
868 ret = SHA1.ComputeHash(src); 868 ret = SHA1.ComputeHash(src);
869 return ret; 869 return ret;
870 } 870 }
871 871
872 public static UUID ComputeSHA1UUID(string src)
873 {
874 return ComputeSHA1UUID(Encoding.Default.GetBytes(src));
875 }
876
877 public static UUID ComputeSHA1UUID(byte[] src)
878 {
879 byte[] ret;
880 using (SHA1CryptoServiceProvider SHA1 = new SHA1CryptoServiceProvider())
881 ret = SHA1.ComputeHash(src);
882 return new UUID(ret, 2);
883 }
884
872 public static int fast_distance2d(int x, int y) 885 public static int fast_distance2d(int x, int y)
873 { 886 {
874 x = Math.Abs(x); 887 x = Math.Abs(x);
diff --git a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs
index a6a4b1c..1c4b538 100644
--- a/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs
+++ b/OpenSim/Region/ClientStack/Linden/Caps/SimulatorFeaturesModule.cs
@@ -77,16 +77,17 @@ namespace OpenSim.Region.ClientStack.Linden
77 private string m_GridName = string.Empty; 77 private string m_GridName = string.Empty;
78 private string m_GridURL = string.Empty; 78 private string m_GridURL = string.Empty;
79 79
80 private bool m_doScriptSyntax;
81 static private object m_scriptSyntaxLock = new object();
80 static private UUID m_scriptSyntaxID = UUID.Zero; 82 static private UUID m_scriptSyntaxID = UUID.Zero;
81 static private string m_scriptSyntaxXML; 83 static private string m_scriptSyntaxXML;
82 private bool m_doScriptSyntax;
83 84
84 #region ISharedRegionModule Members 85 #region ISharedRegionModule Members
85 86
86 public void Initialise(IConfigSource source) 87 public void Initialise(IConfigSource source)
87 { 88 {
88 IConfig config = source.Configs["SimulatorFeatures"]; 89 IConfig config = source.Configs["SimulatorFeatures"];
89 m_doScriptSyntax = false; 90 m_doScriptSyntax = true;
90 if (config != null) 91 if (config != null)
91 { 92 {
92 // 93 //
@@ -330,40 +331,41 @@ namespace OpenSim.Region.ClientStack.Linden
330 331
331 private void ReadScriptSyntax() 332 private void ReadScriptSyntax()
332 { 333 {
333 if(!m_doScriptSyntax || m_scriptSyntaxID != UUID.Zero) 334 lock(m_scriptSyntaxLock)
334 return; 335 {
336 if(!m_doScriptSyntax || m_scriptSyntaxID != UUID.Zero)
337 return;
335 338
336 if(!File.Exists("ScriptSyntax.xml")) 339 if(!File.Exists("ScriptSyntax.xml"))
337 return; 340 return;
338 341
339 try 342 try
340 {
341 using (StreamReader sr = File.OpenText("ScriptSyntax.xml"))
342 { 343 {
343 string version = sr.ReadLine(); 344 using (StreamReader sr = File.OpenText("ScriptSyntax.xml"))
344 if(string.IsNullOrEmpty(version))
345 return;
346 if(!UUID.TryParse(version, out m_scriptSyntaxID))
347 return;
348
349 StringBuilder sb = new StringBuilder(400*1024);
350 string s="";
351 char[] trimc = new char[] {' ','\t', '\n', '\r'};
352 while((s = sr.ReadLine()) != null)
353 { 345 {
354 s = s.Trim(trimc); 346 StringBuilder sb = new StringBuilder(400*1024);
355 if(String.IsNullOrEmpty(s) || s.StartsWith("<--")) 347 sb.Append("<llsd><map><key>llsd-lsl-syntax-version</key><integer>2</integer>");
356 continue; 348
357 sb.Append(s); 349 string s="";
350 char[] trimc = new char[] {' ','\t', '\n', '\r'};
351 while((s = sr.ReadLine()) != null)
352 {
353 s = s.Trim(trimc);
354 if(String.IsNullOrEmpty(s) || s.StartsWith("<!--"))
355 continue;
356 sb.Append(s);
357 }
358 sb.Append("</map></llsd>");
359 m_scriptSyntaxXML = sb.ToString();
360 m_scriptSyntaxID = Util.ComputeSHA1UUID(m_scriptSyntaxXML);
358 } 361 }
359 m_scriptSyntaxXML = sb.ToString();
360 } 362 }
361 } 363 catch
362 catch 364 {
363 { 365 m_log.Error("[SIMULATOR FEATURES MODULE] fail read ScriptSyntax.xml file");
364 m_log.Error("[SIMULATOR FEATURES MODULE] fail read ScriptSyntax.xml file"); 366 m_scriptSyntaxID = UUID.Zero;
365 m_scriptSyntaxID = UUID.Zero; 367 m_scriptSyntaxXML = "";
366 m_scriptSyntaxXML = ""; 368 }
367 } 369 }
368 } 370 }
369 } 371 }