From 633e1ed62cadbdc06592e19bbb1cfaa6fbae72b2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 5 Oct 2012 03:57:35 +0100
Subject: Add missing ConsoleUtil from last commit
---
OpenSim/Framework/Console/ConsoleUtil.cs | 111 +++++++++++++++++++++++++++++++
1 file changed, 111 insertions(+)
create mode 100644 OpenSim/Framework/Console/ConsoleUtil.cs
(limited to 'OpenSim/Framework/Console/ConsoleUtil.cs')
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
new file mode 100644
index 0000000..a254be0
--- /dev/null
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -0,0 +1,111 @@
+/*
+ * Copyright (c) Contributors, http://opensimulator.org/
+ * See CONTRIBUTORS.TXT for a full list of copyright holders.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions are met:
+ * * Redistributions of source code must retain the above copyright
+ * notice, this list of conditions and the following disclaimer.
+ * * Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * * Neither the name of the OpenSimulator Project nor the
+ * names of its contributors may be used to endorse or promote products
+ * derived from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE DEVELOPERS ``AS IS'' AND ANY
+ * EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
+ * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
+ * DISCLAIMED. IN NO EVENT SHALL THE CONTRIBUTORS BE LIABLE FOR ANY
+ * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
+ * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
+ * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
+ */
+
+using System;
+using System.Collections.Generic;
+using System.Linq;
+using System.Reflection;
+using log4net;
+using OpenMetaverse;
+
+public class ConsoleUtil
+{
+ private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ public const string MinRawConsoleVectorValue = "-~";
+ public const string MaxRawConsoleVectorValue = "~";
+
+ public const string VectorSeparator = ",";
+ public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
+
+ ///
+ /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
+ ///
+ /// /param>
+ ///
+ ///
+ public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector)
+ {
+ return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector);
+ }
+
+ ///
+ /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3
+ ///
+ /// /param>
+ ///
+ ///
+ public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector)
+ {
+ return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector);
+ }
+
+ ///
+ /// Convert a vector input from the console to an OpenMetaverse.Vector3
+ ///
+ ///
+ /// A string in the form ,, where there is no space between values.
+ /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value
+ /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40)
+ /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue
+ /// Other than that, component values must be numeric.
+ ///
+ ///
+ ///
+ ///
+ public static bool TryParseConsoleVector(
+ string rawConsoleVector, Func blankComponentFunc, out Vector3 vector)
+ {
+ List components = rawConsoleVector.Split(VectorSeparatorChars).ToList();
+
+ if (components.Count < 1 || components.Count > 3)
+ return false;
+
+ for (int i = components.Count; i < 3; i++)
+ components.Add("");
+
+ List semiDigestedComponents
+ = components.ConvertAll(
+ c =>
+ {
+ if (c == "")
+ return blankComponentFunc.Invoke(c);
+ else if (c == MaxRawConsoleVectorValue)
+ return float.MaxValue.ToString();
+ else if (c == MinRawConsoleVectorValue)
+ return float.MinValue.ToString();
+ else
+ return c;
+ });
+
+ string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray());
+
+ m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector);
+
+ return Vector3.TryParse(semiDigestedConsoleVector, out vector);
+ }
+}
\ No newline at end of file
--
cgit v1.1
From 68859af3f8c610e562351a328a78a987ab7f229d Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Fri, 5 Oct 2012 03:58:52 +0100
Subject: Add Vector3.Zero return on TryParseConsoleVector() which fails on
mono 2.4.3 but not mono 2.10.9
---
OpenSim/Framework/Console/ConsoleUtil.cs | 3 +++
1 file changed, 3 insertions(+)
(limited to 'OpenSim/Framework/Console/ConsoleUtil.cs')
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index a254be0..2612a50 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -83,7 +83,10 @@ public class ConsoleUtil
List components = rawConsoleVector.Split(VectorSeparatorChars).ToList();
if (components.Count < 1 || components.Count > 3)
+ {
+ vector = Vector3.Zero;
return false;
+ }
for (int i = components.Count; i < 3; i++)
components.Add("");
--
cgit v1.1
From efd9791506b00e424bb5f1846b37d79e7638bda2 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 10 Oct 2012 23:30:48 +0100
Subject: Add "delete object pos to " console command.
This allows one to delete objects within a certain volume.
See help on console for more details.
---
OpenSim/Framework/Console/ConsoleUtil.cs | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Framework/Console/ConsoleUtil.cs')
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index 2612a50..a7cf0c0 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -34,7 +34,7 @@ using OpenMetaverse;
public class ConsoleUtil
{
- private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
public const string MinRawConsoleVectorValue = "-~";
public const string MaxRawConsoleVectorValue = "~";
@@ -107,7 +107,7 @@ public class ConsoleUtil
string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray());
- m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector);
+// m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector);
return Vector3.TryParse(semiDigestedConsoleVector, out vector);
}
--
cgit v1.1
From 938fa96b9f5377ef330171232262b4d8aaca0918 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Oct 2012 01:33:21 +0100
Subject: minor: Move co-ordinate related help to object commands to common
ConsoleUtil.CoordHelp
---
OpenSim/Framework/Console/ConsoleUtil.cs | 17 +++++++++++++++++
1 file changed, 17 insertions(+)
(limited to 'OpenSim/Framework/Console/ConsoleUtil.cs')
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index a7cf0c0..027753d 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -36,6 +36,23 @@ public class ConsoleUtil
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+ ///
+ /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section
+ /// rather than in each help summary.
+ ///
+ public const string CoordHelp
+= @"Each component of the coord is comma separated. There must be no spaces between the commas.
+If you don't care about the z component you can simply omit it.
+If you don't care about the x or y components then you can leave them blank (though a comma is still required)
+If you want to specify the maxmimum value of a component then you can use ~ instead of a number
+If you want to specify the minimum value of a component then you can use -~ instead of a number
+e.g.
+delete object pos 20,20,20 to 40,40,40
+delete object pos 20,20 to 40,40
+delete object pos ,20,20 to ,40,40
+delete object pos ,,30 to ,,~
+delete object pos ,,-~ to ,,30";
+
public const string MinRawConsoleVectorValue = "-~";
public const string MaxRawConsoleVectorValue = "~";
--
cgit v1.1
From 73db057fa1dbda7d6dff7de770cef8670b234f84 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Oct 2012 02:05:28 +0100
Subject: Add "dump object uuid" console command. This allows any object in
the scene to be serialized and dumped to XML for debug purposes.
---
OpenSim/Framework/Console/ConsoleUtil.cs | 206 +++++++++++++++++--------------
1 file changed, 115 insertions(+), 91 deletions(-)
(limited to 'OpenSim/Framework/Console/ConsoleUtil.cs')
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index 027753d..5c25ccb 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -32,100 +32,124 @@ using System.Reflection;
using log4net;
using OpenMetaverse;
-public class ConsoleUtil
+namespace OpenSim.Framework.Console
{
-// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
-
- ///
- /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section
- /// rather than in each help summary.
- ///
- public const string CoordHelp
-= @"Each component of the coord is comma separated. There must be no spaces between the commas.
-If you don't care about the z component you can simply omit it.
-If you don't care about the x or y components then you can leave them blank (though a comma is still required)
-If you want to specify the maxmimum value of a component then you can use ~ instead of a number
-If you want to specify the minimum value of a component then you can use -~ instead of a number
-e.g.
-delete object pos 20,20,20 to 40,40,40
-delete object pos 20,20 to 40,40
-delete object pos ,20,20 to ,40,40
-delete object pos ,,30 to ,,~
-delete object pos ,,-~ to ,,30";
-
- public const string MinRawConsoleVectorValue = "-~";
- public const string MaxRawConsoleVectorValue = "~";
-
- public const string VectorSeparator = ",";
- public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
-
- ///
- /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
- ///
- /// /param>
- ///
- ///
- public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector)
+ public class ConsoleUtil
{
- return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector);
- }
-
- ///
- /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3
- ///
- /// /param>
- ///
- ///
- public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector)
- {
- return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector);
- }
-
- ///
- /// Convert a vector input from the console to an OpenMetaverse.Vector3
- ///
- ///
- /// A string in the form ,, where there is no space between values.
- /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value
- /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40)
- /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue
- /// Other than that, component values must be numeric.
- ///
- ///
- ///
- ///
- public static bool TryParseConsoleVector(
- string rawConsoleVector, Func blankComponentFunc, out Vector3 vector)
- {
- List components = rawConsoleVector.Split(VectorSeparatorChars).ToList();
-
- if (components.Count < 1 || components.Count > 3)
+ // private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ ///
+ /// Used by modules to display stock co-ordinate help, though possibly this should be under some general section
+ /// rather than in each help summary.
+ ///
+ public const string CoordHelp
+ = @"Each component of the coord is comma separated. There must be no spaces between the commas.
+ If you don't care about the z component you can simply omit it.
+ If you don't care about the x or y components then you can leave them blank (though a comma is still required)
+ If you want to specify the maxmimum value of a component then you can use ~ instead of a number
+ If you want to specify the minimum value of a component then you can use -~ instead of a number
+ e.g.
+ delete object pos 20,20,20 to 40,40,40
+ delete object pos 20,20 to 40,40
+ delete object pos ,20,20 to ,40,40
+ delete object pos ,,30 to ,,~
+ delete object pos ,,-~ to ,,30";
+
+ public const string MinRawConsoleVectorValue = "-~";
+ public const string MaxRawConsoleVectorValue = "~";
+
+ public const string VectorSeparator = ",";
+ public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
+
+ ///
+ /// Try to parse a console UUID from the console.
+ ///
+ ///
+ /// Will complain to the console if parsing fails.
+ ///
+ ///
+ ///
+ ///
+ ///
+ public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid)
{
- vector = Vector3.Zero;
- return false;
+ if (!UUID.TryParse(rawUuid, out uuid))
+ {
+ console.OutputFormat("{0} is not a valid uuid", rawUuid);
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
+ ///
+ /// /param>
+ ///
+ ///
+ public static bool TryParseConsoleMinVector(string rawConsoleVector, out Vector3 vector)
+ {
+ return TryParseConsoleVector(rawConsoleVector, c => float.MinValue.ToString(), out vector);
+ }
+
+ ///
+ /// Convert a maximum vector input from the console to an OpenMetaverse.Vector3
+ ///
+ /// /param>
+ ///
+ ///
+ public static bool TryParseConsoleMaxVector(string rawConsoleVector, out Vector3 vector)
+ {
+ return TryParseConsoleVector(rawConsoleVector, c => float.MaxValue.ToString(), out vector);
+ }
+
+ ///
+ /// Convert a vector input from the console to an OpenMetaverse.Vector3
+ ///
+ ///
+ /// A string in the form ,, where there is no space between values.
+ /// Any component can be missing (e.g. ,,40). blankComponentFunc is invoked to replace the blank with a suitable value
+ /// Also, if the blank component is at the end, then the comma can be missed off entirely (e.g. 40,30 or 40)
+ /// The strings "~" and "-~" are valid in components. The first substitutes float.MaxValue whilst the second is float.MinValue
+ /// Other than that, component values must be numeric.
+ ///
+ ///
+ ///
+ ///
+ public static bool TryParseConsoleVector(
+ string rawConsoleVector, Func blankComponentFunc, out Vector3 vector)
+ {
+ List components = rawConsoleVector.Split(VectorSeparatorChars).ToList();
+
+ if (components.Count < 1 || components.Count > 3)
+ {
+ vector = Vector3.Zero;
+ return false;
+ }
+
+ for (int i = components.Count; i < 3; i++)
+ components.Add("");
+
+ List semiDigestedComponents
+ = components.ConvertAll(
+ c =>
+ {
+ if (c == "")
+ return blankComponentFunc.Invoke(c);
+ else if (c == MaxRawConsoleVectorValue)
+ return float.MaxValue.ToString();
+ else if (c == MinRawConsoleVectorValue)
+ return float.MinValue.ToString();
+ else
+ return c;
+ });
+
+ string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray());
+
+ // m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector);
+
+ return Vector3.TryParse(semiDigestedConsoleVector, out vector);
}
-
- for (int i = components.Count; i < 3; i++)
- components.Add("");
-
- List semiDigestedComponents
- = components.ConvertAll(
- c =>
- {
- if (c == "")
- return blankComponentFunc.Invoke(c);
- else if (c == MaxRawConsoleVectorValue)
- return float.MaxValue.ToString();
- else if (c == MinRawConsoleVectorValue)
- return float.MinValue.ToString();
- else
- return c;
- });
-
- string semiDigestedConsoleVector = string.Join(VectorSeparator, semiDigestedComponents.ToArray());
-
-// m_log.DebugFormat("[CONSOLE UTIL]: Parsing {0} into OpenMetaverse.Vector3", semiDigestedConsoleVector);
-
- return Vector3.TryParse(semiDigestedConsoleVector, out vector);
}
}
\ No newline at end of file
--
cgit v1.1
From f76dceb90b5a76a7b6a5243c9032996c007c0cf5 Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Oct 2012 03:08:58 +0100
Subject: Get "save oar" and "save iar" to tell you in a more friendly manner
if the filename to save already exists, rather than exception throwing.
Also changes ConsoleUtil.CheckFileExists to CheckFileDoesNotExist() since this is more meaningful in the context, even though it does result in double negatives.
---
OpenSim/Framework/Console/ConsoleUtil.cs | 19 +++++++++++++++++++
1 file changed, 19 insertions(+)
(limited to 'OpenSim/Framework/Console/ConsoleUtil.cs')
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index 5c25ccb..3ebfdf8 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -27,6 +27,7 @@
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Reflection;
using log4net;
@@ -60,6 +61,24 @@ namespace OpenSim.Framework.Console
public const string VectorSeparator = ",";
public static char[] VectorSeparatorChars = VectorSeparator.ToCharArray();
+
+ ///
+ /// Check if the given file path exists.
+ ///
+ /// If not, warning is printed to the given console.
+ /// true if the file does not exist, false otherwise.
+ ///
+ ///
+ public static bool CheckFileDoesNotExist(ICommandConsole console, string path)
+ {
+ if (File.Exists(path))
+ {
+ console.OutputFormat("File {0} already exists. Please move or remove it.", path);
+ return false;
+ }
+
+ return true;
+ }
///
/// Try to parse a console UUID from the console.
--
cgit v1.1
From 81aeecc90723658187668baa49bd168b7b333afb Mon Sep 17 00:00:00 2001
From: Justin Clark-Casey (justincc)
Date: Wed, 24 Oct 2012 04:10:22 +0100
Subject: Allow "show object", "show part", "dump object" and "delete object"
to accept a local ID as well as a UUID.
This means that the sub-commands are now id rather than uuid, e.g. show object id
---
OpenSim/Framework/Console/ConsoleUtil.cs | 58 ++++++++++++++++++++++++++++++--
1 file changed, 56 insertions(+), 2 deletions(-)
(limited to 'OpenSim/Framework/Console/ConsoleUtil.cs')
diff --git a/OpenSim/Framework/Console/ConsoleUtil.cs b/OpenSim/Framework/Console/ConsoleUtil.cs
index 3ebfdf8..16a63e0 100644
--- a/OpenSim/Framework/Console/ConsoleUtil.cs
+++ b/OpenSim/Framework/Console/ConsoleUtil.cs
@@ -38,6 +38,8 @@ namespace OpenSim.Framework.Console
public class ConsoleUtil
{
// private static readonly ILog m_log = LogManager.GetLogger(MethodBase.GetCurrentMethod().DeclaringType);
+
+ public const int LocalIdNotFound = 0;
///
/// Used by modules to display stock co-ordinate help, though possibly this should be under some general section
@@ -87,19 +89,71 @@ namespace OpenSim.Framework.Console
/// Will complain to the console if parsing fails.
///
///
- ///
+ /// If null then no complaint is printed.
///
///
public static bool TryParseConsoleUuid(ICommandConsole console, string rawUuid, out UUID uuid)
{
if (!UUID.TryParse(rawUuid, out uuid))
{
- console.OutputFormat("{0} is not a valid uuid", rawUuid);
+ if (console != null)
+ console.OutputFormat("{0} is not a valid uuid", rawUuid);
+
return false;
}
return true;
}
+
+ public static bool TryParseConsoleLocalId(ICommandConsole console, string rawLocalId, out uint localId)
+ {
+ if (!uint.TryParse(rawLocalId, out localId))
+ {
+ if (console != null)
+ console.OutputFormat("{0} is not a valid local id", localId);
+
+ return false;
+ }
+
+ if (localId == 0)
+ {
+ if (console != null)
+ console.OutputFormat("{0} is not a valid local id - it must be greater than 0", localId);
+
+ return false;
+ }
+
+ return true;
+ }
+
+ ///
+ /// Tries to parse the input as either a UUID or a local ID.
+ ///
+ /// true if parsing succeeded, false otherwise.
+ ///
+ ///
+ ///
+ ///
+ /// Will be set to ConsoleUtil.LocalIdNotFound if parsing result was a UUID or no parse succeeded.
+ ///
+ public static bool TryParseConsoleId(ICommandConsole console, string rawId, out UUID uuid, out uint localId)
+ {
+ if (TryParseConsoleUuid(null, rawId, out uuid))
+ {
+ localId = LocalIdNotFound;
+ return true;
+ }
+
+ if (TryParseConsoleLocalId(null, rawId, out localId))
+ {
+ return true;
+ }
+
+ if (console != null)
+ console.OutputFormat("{0} is not a valid UUID or local id", rawId);
+
+ return false;
+ }
///
/// Convert a minimum vector input from the console to an OpenMetaverse.Vector3
--
cgit v1.1