From bc8082b0038776059488421245fe4b10e499364d Mon Sep 17 00:00:00 2001 From: Ima Mechanique Date: Tue, 16 Jul 2013 16:47:13 +0100 Subject: [PATCH] Fixing some StyleCop violations. --- trunk/SecondLife/SecondLifeMain.cs | 211 ++++++++++++++++++++++++++++- 1 file changed, 204 insertions(+), 7 deletions(-) diff --git a/trunk/SecondLife/SecondLifeMain.cs b/trunk/SecondLife/SecondLifeMain.cs index 0233c67..b8a1254 100644 --- a/trunk/SecondLife/SecondLifeMain.cs +++ b/trunk/SecondLife/SecondLifeMain.cs @@ -44,6 +44,7 @@ using System; using System.Collections; using System.Collections.Generic; +using System.Diagnostics.CodeAnalysis; using System.Text; using System.Text.RegularExpressions; @@ -55,13 +56,44 @@ using System.Text.RegularExpressions; namespace LSLEditor { /// - /// Enumeration of Communication Types that the host understands + /// Enumeration of Communication Types that the host understands. /// public enum CommunicationType { - Whisper, Say, Shout, OwnerSay, RegionSay, RegionSayTo + /// + /// Indicates the message can be heard only within 5m. + /// + Whisper, + + /// + /// Indicates the message can be heard only within 20m. + /// + Say, + + /// + /// Indicates the message can be heard only within 100m. + /// + Shout, + + /// + /// Indicates the message can be only heard by the owner any where within the same simulator. + /// + OwnerSay, + + /// + /// Indicates the message can be heard any where within the same simulator. + /// + RegionSay, + + /// + /// Indicates the message can be heard any where within the same simulator, by a specific object. + /// + RegionSayTo } + /// + /// Partial definition of SecondLife class to handle running scripts. + /// public partial class SecondLife { /// @@ -81,7 +113,7 @@ namespace LSLEditor private DateTime dtDateTimeScriptStarted; /// - /// Contains a boolean value indicating wether this object accepts other items to be dropped into it. + /// Contains a boolean value indicating whether this object accepts other items to be dropped into it. /// private bool blnAllowDrop = false; @@ -100,25 +132,63 @@ namespace LSLEditor /// private Float fVolume; + /// + /// Name of the object/prim. + /// private String sObjectName; + + /// + /// URL for parcel's music stream. + /// private String sParcelMusicURL; + + /// + /// Position of object/prim placement in a simulator. + /// private vector vPosition; + + /// + /// Rotation of the object/prim's placement in the simulator. + /// private rotation rRotation; + + /// + /// Local rotation of the prim with respect to the object root. + /// private rotation rRotationlocal; + + /// + /// Scale of the object/prim. + /// private vector vScale; + + /// + /// Text for the "Sit" entry on object menu. + /// private String sSitText; + + /// + /// Radius that sound may be heard around the object/prim. + /// private Float fSoundRadius; + /// + /// Region Coordinates of the simulator's bottom-left corner. + /// private vector vRegionCorner; + /// + /// Parameter passed to the script on startup. + /// private integer iStartParameter; #endregion #region Constructor /// - /// Initialises the class. + /// Initialises a new instance of the class. /// + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1642:ConstructorSummaryDocumentationMustBeginWithStandardText", Justification = "Reviewed.")] public SecondLife() { this.host = null; @@ -141,12 +211,21 @@ namespace LSLEditor #endregion #region Properties + + /// + /// Gets the position of the object within the simulator. + /// + /// Gets the vPosition data member. public vector GetLocalPos { // TODO change this to use a call to llGetLocalPos specifying NOT to be Verbose. After all functions have been changed to allow verbose/silent option. get { return vPosition; } } + /// + /// Gets or sets the SecondLifeHost object. + /// + /// The host property gets/sets the slhHost data member. public SecondLifeHost host { get { return this.slhHost; } @@ -155,6 +234,11 @@ namespace LSLEditor #endregion #region internal routines + /// + /// Outputs messages during execution of the script. + /// + /// The text (with possible placeholders) to be output. + /// Values to be put into corresponding placeholders. private void Verbose(string strLine, params object[] parameters) { if (parameters.Length == 0) { @@ -164,11 +248,21 @@ namespace LSLEditor } } + /// + /// Wrapper to call the SecondLifeHost.Chat method. + /// + /// Channel for message to be sent on. + /// Text of message to send. + /// Type of communication (from CommunicationType enumerator). private void Chat(integer iChannel, string sText, CommunicationType ctHow) { this.host.Chat(this.host, iChannel, this.host.GetObjectName(), this.host.GetKey(), sText, ctHow); } + /// + /// Method to trigger change in script state. + /// + /// Name of state to switch to. public void state(string strStateName) { Verbose("state->" + strStateName); @@ -181,6 +275,13 @@ namespace LSLEditor #region Helper Functions #region List Functions + /// + /// Takes the possibly negative value list indexes and corrects them to be absolute indexes. + /// + /// Length of list. + /// Start index. + /// End index. + /// True, unless an error occurred, then false. private bool CorrectIt(int intLength, ref int intStart, ref int intEnd) { bool bResult = true; @@ -207,6 +308,11 @@ namespace LSLEditor return bResult; } + /// + /// Randomly rearranges the list of items. + /// + /// List to shuffle. + /// The reordered list. public ArrayList RandomShuffle(ArrayList alCollection) { /* We have to copy all items anyway, and there isn't a way to produce the items @@ -230,6 +336,12 @@ namespace LSLEditor return alCollection; } + /// + /// Convert a list into an array of buckets containing Stride elements. + /// + /// List of items. + /// Number of element for each bucket. + /// The list separated into elements of Stride length. private ArrayList List2Buckets(list lSource, int intStride) { ArrayList alBuckets = null; @@ -246,12 +358,18 @@ namespace LSLEditor return alBuckets; } + /// + /// Converts buckets back into a list. + /// + /// Array of buckets. + /// Stride value. + /// The items recombined into a simple list. private list Buckets2List(ArrayList alBuckets, int intStride) { object[] items = new object[alBuckets.Count * intStride]; for (int intI = 0; intI < alBuckets.Count; intI++) { for (int intJ = 0; intJ < intStride; intJ++) { - items[intI * intStride + intJ] = ((object[])alBuckets[intI])[intJ]; + items[(intI * intStride) + intJ] = ((object[])alBuckets[intI])[intJ]; } } return new list(items); @@ -262,17 +380,27 @@ namespace LSLEditor /// private class BucketComparer : IComparer { + /// + /// True/false parameter indicating whether the comparison should be done in ascending or descending order. + /// private integer iAscending; /// - /// Initialises the class. + /// Initialises a new instance of the class. /// /// + [SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1642:ConstructorSummaryDocumentationMustBeginWithStandardText", Justification = "Reviewed.")] public BucketComparer(integer ascending) { this.iAscending = ascending; } + /// + /// Perform the comparison between two objects. + /// + /// First object. + /// Second object. + /// An integer (-1, 0, or 1), indicating whether the first item is less than, same as, or greater than the second. public int Compare(object x, object y) { int iResult = 0; @@ -305,6 +433,15 @@ namespace LSLEditor #endregion #region String Functions + + /// + /// Takes a string and splits it into a list based upon separators (which are not kept) and spacers (which are). + /// + /// The source text. + /// Separators to split on. + /// Spacers to split on. + /// True/false indicating whether nulls are kept in the resulting list. + /// A new list of the split string. private list ParseString(String sSource, list lSeparators, list lSpacers, bool blnKeepNulls) { list lResult = new list(); @@ -358,12 +495,22 @@ namespace LSLEditor return lResult; } + /// + /// Convert string to Base64 representation. + /// + /// Source string. + /// Base64 encoding of the source string. private string StringToBase64(string strText) { byte[] data = Encoding.UTF8.GetBytes(strText); return Convert.ToBase64String(data); } + /// + /// Converts Base64 encoded string back to UTF-8. + /// + /// Base64 encoded string. + /// UTF-8 string. private string Base64ToString(string strText) { byte[] data = Convert.FromBase64String(strText); @@ -374,6 +521,12 @@ namespace LSLEditor return Encoding.UTF8.GetString(data, 0, intLen); } + /// + /// Performs the lookup. + /// + /// String source. + /// Byte within string. + /// The Base64 value of the element. private int LookupBase64(string s, int intIndex) { int intReturn = 0; @@ -390,6 +543,9 @@ namespace LSLEditor return intReturn; } + /// + /// Pre-generated matrix for quicker lookup. + /// ////[SuppressMessage("StyleCop.CSharp.OrderingRules", "SA1204:StaticElementsMustAppearBeforeInstanceElements", Justification = "Stays with other string functions.")] private static readonly int[] FastLookupBase64 = { // 0 1 2 3 4 5 6 7 8 9 A B C D E F @@ -412,11 +568,26 @@ namespace LSLEditor #endregion #region Math Functions + + /// + /// Performs (iA ** iB) % iC. + /// + /// Base value. + /// Exponent value . + /// Modulus value. + /// The calculated result. private integer ModPow1(integer iA, integer iB, integer iC) { return (int)Math.Pow((int)iA, (int)iB & (int)0xffff) % (int)iC; } + /// + /// Performs the llModPow2() function. + /// + /// Value one. + /// Value two. + /// The modulus value. + /// The calculated result. private integer ModPow2(integer iValueX, integer iValueY, integer iModulus) { integer iResult = 0; @@ -439,6 +610,11 @@ namespace LSLEditor } #endregion Math Functions + /// + /// Used by llListStatistics in generating the statistics. + /// + /// List of numbers (mixed types possible) to use. + /// The numbers added together as a Float type. private List GetListOfNumbers(list lInput) { List lResult = new List(); @@ -465,6 +641,11 @@ namespace LSLEditor return lResult; } + /// + /// Calculates the mean of the supplied numbers. + /// + /// Array of numbers. + /// The mean of the supplied numbers as a double type. private double GetAverage(double[] data) { try { @@ -478,6 +659,11 @@ namespace LSLEditor } } + /// + /// Calculates standard deviation. + /// + /// Array of numbers to work with. + /// The standard deviation of the supplied numbers as a double type. public double GetStandardDeviation(double[] dblNumbers) { double dblSum = 0.0, dblSumOfSqrs = 0.0; @@ -490,9 +676,15 @@ namespace LSLEditor return Math.Sqrt(dblTopSum / (dblN * (dblN - 1))); } + /// + /// Performs division, only if both values are non-zero. + /// + /// First number. + /// Second number. + /// The result of the division, or zero if not performed. private double SafeDivide(double dblValue1, double dblValue2) { - double dblResult = 0; + double dblResult = 0.0F; try { if ((dblValue1 != 0) && (dblValue2 != 0)) { dblResult = dblValue1 / dblValue2; @@ -502,6 +694,11 @@ namespace LSLEditor return dblResult; } + /// + /// Takes a hexadecimal representation of a number and coverts it to an integer. + /// + /// Byte to convert. + /// Integer value of the supplied byte. private byte HexToInt(byte b) { byte bResult;