diff options
Diffstat (limited to '')
-rw-r--r-- | OpenSim/Framework/Util.cs | 65 |
1 files changed, 32 insertions, 33 deletions
diff --git a/OpenSim/Framework/Util.cs b/OpenSim/Framework/Util.cs index 8114957..0943626 100644 --- a/OpenSim/Framework/Util.cs +++ b/OpenSim/Framework/Util.cs | |||
@@ -45,18 +45,17 @@ namespace OpenSim.Framework | |||
45 | { | 45 | { |
46 | public class Util | 46 | public class Util |
47 | { | 47 | { |
48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); | 48 | private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType); |
49 | |||
50 | private static Random randomClass = new Random(); | ||
51 | private static uint nextXferID = 5000; | ||
52 | private static object XferLock = new object(); | ||
53 | 49 | ||
54 | // Get a list of invalid path characters (OS dependent) | 50 | private static uint nextXferID = 5000; |
55 | private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]"; | 51 | private static Random randomClass = new Random(); |
56 | // Get a list of invalid file characters (OS dependent) | 52 | // Get a list of invalid file characters (OS dependent) |
57 | private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]"; | 53 | private static string regexInvalidFileChars = "[" + new String(Path.GetInvalidFileNameChars()) + "]"; |
54 | private static string regexInvalidPathChars = "[" + new String(Path.GetInvalidPathChars()) + "]"; | ||
55 | private static object XferLock = new object(); | ||
58 | 56 | ||
59 | #region Vector Equasions | 57 | #region Vector Equasions |
58 | |||
60 | /// <summary> | 59 | /// <summary> |
61 | /// Get the distance between two 3d vectors | 60 | /// Get the distance between two 3d vectors |
62 | /// </summary> | 61 | /// </summary> |
@@ -92,7 +91,7 @@ namespace OpenSim.Framework | |||
92 | if (IsZeroVector(a)) | 91 | if (IsZeroVector(a)) |
93 | throw new ArgumentException("Vector paramater cannot be a zero vector."); | 92 | throw new ArgumentException("Vector paramater cannot be a zero vector."); |
94 | 93 | ||
95 | float Mag = (float)GetMagnitude(a); | 94 | float Mag = (float) GetMagnitude(a); |
96 | return new LLVector3(a.X / Mag, a.Y / Mag, a.Z / Mag); | 95 | return new LLVector3(a.X / Mag, a.Y / Mag, a.Z / Mag); |
97 | } | 96 | } |
98 | 97 | ||
@@ -112,9 +111,8 @@ namespace OpenSim.Framework | |||
112 | 111 | ||
113 | # endregion | 112 | # endregion |
114 | 113 | ||
115 | public static ulong UIntsToLong(uint X, uint Y) | 114 | public Util() |
116 | { | 115 | { |
117 | return Helpers.UIntsToLong(X, Y); | ||
118 | } | 116 | } |
119 | 117 | ||
120 | public static Random RandomClass | 118 | public static Random RandomClass |
@@ -122,6 +120,11 @@ namespace OpenSim.Framework | |||
122 | get { return randomClass; } | 120 | get { return randomClass; } |
123 | } | 121 | } |
124 | 122 | ||
123 | public static ulong UIntsToLong(uint X, uint Y) | ||
124 | { | ||
125 | return Helpers.UIntsToLong(X, Y); | ||
126 | } | ||
127 | |||
125 | public static uint GetNextXferID() | 128 | public static uint GetNextXferID() |
126 | { | 129 | { |
127 | uint id = 0; | 130 | uint id = 0; |
@@ -133,10 +136,6 @@ namespace OpenSim.Framework | |||
133 | return id; | 136 | return id; |
134 | } | 137 | } |
135 | 138 | ||
136 | public Util() | ||
137 | { | ||
138 | } | ||
139 | |||
140 | public static string GetFileName(string file) | 139 | public static string GetFileName(string file) |
141 | { | 140 | { |
142 | // Return just the filename on UNIX platforms | 141 | // Return just the filename on UNIX platforms |
@@ -199,7 +198,7 @@ namespace OpenSim.Framework | |||
199 | public static int ToUnixTime(DateTime stamp) | 198 | public static int ToUnixTime(DateTime stamp) |
200 | { | 199 | { |
201 | TimeSpan t = (stamp.ToUniversalTime() - Convert.ToDateTime("1/1/1970 8:00:00 AM")); | 200 | TimeSpan t = (stamp.ToUniversalTime() - Convert.ToDateTime("1/1/1970 8:00:00 AM")); |
202 | return (int)t.TotalSeconds; | 201 | return (int) t.TotalSeconds; |
203 | } | 202 | } |
204 | 203 | ||
205 | public static DateTime ToDateTime(ulong seconds) | 204 | public static DateTime ToDateTime(ulong seconds) |
@@ -309,7 +308,7 @@ namespace OpenSim.Framework | |||
309 | for (int j = 0; j < 16 && (i + j) < bytes.Length; j++) | 308 | for (int j = 0; j < 16 && (i + j) < bytes.Length; j++) |
310 | { | 309 | { |
311 | if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E) | 310 | if (bytes[i + j] >= 0x20 && bytes[i + j] < 0x7E) |
312 | output.Append((char)bytes[i + j]); | 311 | output.Append((char) bytes[i + j]); |
313 | else | 312 | else |
314 | output.Append("."); | 313 | output.Append("."); |
315 | } | 314 | } |
@@ -332,7 +331,7 @@ namespace OpenSim.Framework | |||
332 | return ipa; | 331 | return ipa; |
333 | 332 | ||
334 | IPAddress[] hosts = null; | 333 | IPAddress[] hosts = null; |
335 | 334 | ||
336 | // Not an IP, lookup required | 335 | // Not an IP, lookup required |
337 | try | 336 | try |
338 | { | 337 | { |
@@ -341,7 +340,7 @@ namespace OpenSim.Framework | |||
341 | catch (Exception e) | 340 | catch (Exception e) |
342 | { | 341 | { |
343 | m_log.ErrorFormat("[UTIL]: An error occurred while resolving {0}, {1}", dnsAddress, e); | 342 | m_log.ErrorFormat("[UTIL]: An error occurred while resolving {0}, {1}", dnsAddress, e); |
344 | 343 | ||
345 | // Still going to throw the exception on for now, since this was what was happening in the first place | 344 | // Still going to throw the exception on for now, since this was what was happening in the first place |
346 | throw e; | 345 | throw e; |
347 | } | 346 | } |
@@ -397,7 +396,8 @@ namespace OpenSim.Framework | |||
397 | /// <returns>safe filename</returns> | 396 | /// <returns>safe filename</returns> |
398 | public static string safeFileName(string filename) | 397 | public static string safeFileName(string filename) |
399 | { | 398 | { |
400 | return Regex.Replace(filename, @regexInvalidFileChars, string.Empty); ; | 399 | return Regex.Replace(filename, @regexInvalidFileChars, string.Empty); |
400 | ; | ||
401 | } | 401 | } |
402 | 402 | ||
403 | // | 403 | // |
@@ -454,10 +454,10 @@ namespace OpenSim.Framework | |||
454 | 454 | ||
455 | public static void AddDataRowToConfig(IConfigSource config, DataRow row) | 455 | public static void AddDataRowToConfig(IConfigSource config, DataRow row) |
456 | { | 456 | { |
457 | config.Configs.Add((string)row[0]); | 457 | config.Configs.Add((string) row[0]); |
458 | for (int i = 0; i < row.Table.Columns.Count; i++) | 458 | for (int i = 0; i < row.Table.Columns.Count; i++) |
459 | { | 459 | { |
460 | config.Configs[(string)row[0]].Set(row.Table.Columns[i].ColumnName, row[i]); | 460 | config.Configs[(string) row[0]].Set(row.Table.Columns[i].ColumnName, row[i]); |
461 | } | 461 | } |
462 | } | 462 | } |
463 | 463 | ||
@@ -594,19 +594,19 @@ namespace OpenSim.Framework | |||
594 | returnstring[2] = "127"; | 594 | returnstring[2] = "127"; |
595 | returnstring[3] = "0"; | 595 | returnstring[3] = "0"; |
596 | // This is the crappy way of doing it. | 596 | // This is the crappy way of doing it. |
597 | 597 | ||
598 | if (startLocationRequest.Contains(":") && startLocationRequest.Contains("&")) | 598 | if (startLocationRequest.Contains(":") && startLocationRequest.Contains("&")) |
599 | { | 599 | { |
600 | //System.Console.WriteLine("StartLocationRequest Contains proper elements"); | 600 | //System.Console.WriteLine("StartLocationRequest Contains proper elements"); |
601 | 601 | ||
602 | string[] splitstr = startLocationRequest.Split(':');//,2,StringSplitOptions.RemoveEmptyEntries); | 602 | string[] splitstr = startLocationRequest.Split(':'); //,2,StringSplitOptions.RemoveEmptyEntries); |
603 | 603 | ||
604 | //System.Console.WriteLine("Found " + splitstr.GetLength(0) + " elements in 1st split result"); | 604 | //System.Console.WriteLine("Found " + splitstr.GetLength(0) + " elements in 1st split result"); |
605 | 605 | ||
606 | if (splitstr.GetLength(0) == 2) | 606 | if (splitstr.GetLength(0) == 2) |
607 | { | 607 | { |
608 | string[] splitstr2 = splitstr[1].Split('&');//, 4, StringSplitOptions.RemoveEmptyEntries); | 608 | string[] splitstr2 = splitstr[1].Split('&'); //, 4, StringSplitOptions.RemoveEmptyEntries); |
609 | 609 | ||
610 | //System.Console.WriteLine("Found " + splitstr2.GetLength(0) + " elements in 2nd split result"); | 610 | //System.Console.WriteLine("Found " + splitstr2.GetLength(0) + " elements in 2nd split result"); |
611 | 611 | ||
612 | int len = Math.Min(splitstr2.GetLength(0), 4); | 612 | int len = Math.Min(splitstr2.GetLength(0), 4); |
@@ -622,17 +622,16 @@ namespace OpenSim.Framework | |||
622 | } | 622 | } |
623 | return returnstring; | 623 | return returnstring; |
624 | } | 624 | } |
625 | 625 | ||
626 | static public XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args) | 626 | public static XmlRpcResponse XmlRpcCommand(string url, string methodName, params object[] args) |
627 | { | 627 | { |
628 | return SendXmlRpcCommand(url, methodName, args); | 628 | return SendXmlRpcCommand(url, methodName, args); |
629 | } | 629 | } |
630 | 630 | ||
631 | static public XmlRpcResponse SendXmlRpcCommand(string url, string methodName, object[] args) | 631 | public static XmlRpcResponse SendXmlRpcCommand(string url, string methodName, object[] args) |
632 | { | 632 | { |
633 | XmlRpcRequest client = new XmlRpcRequest(methodName, args); | 633 | XmlRpcRequest client = new XmlRpcRequest(methodName, args); |
634 | return client.Send(url, 6000); | 634 | return client.Send(url, 6000); |
635 | } | 635 | } |
636 | |||
637 | } | 636 | } |
638 | } | 637 | } \ No newline at end of file |