Fixing StyleCop violations.

This commit is contained in:
Ima Mechanique 2013-07-16 17:21:34 +01:00
parent 1265264cc7
commit 73e7084458
2 changed files with 165 additions and 95 deletions

View file

@ -43,19 +43,23 @@
// */ // */
using System; using System;
using System.ComponentModel; using System.ComponentModel;
using System.Diagnostics.CodeAnalysis;
using System.IO; using System.IO;
using System.Reflection; using System.Reflection;
using System.Windows.Forms; using System.Windows.Forms;
namespace LSLEditor namespace LSLEditor
{ {
/// <summary>About dialogue box form.</summary> /// <summary>
/// About dialogue box form.
/// </summary>
public partial class About : Form public partial class About : Form
{ {
/// <summary> /// <summary>
/// Initialises a new instance of the <see cref="About" /> class. /// Initialises a new instance of the <see cref="About" /> class.
/// </summary> /// </summary>
/// <param name="parent">The parent form.</param> /// <param name="parent">The parent form.</param>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1642:ConstructorSummaryDocumentationMustBeginWithStandardText", Justification = "Reviewed.")]
public About(LSLEditorForm parent) public About(LSLEditorForm parent)
{ {
this.InitializeComponent(); this.InitializeComponent();

View file

@ -49,6 +49,10 @@ using System.Text;
namespace LSLEditor namespace LSLEditor
{ {
/// <summary>
/// This part of the SecondLife class contains the LSL function definitions.
/// </summary>
[SuppressMessage("StyleCop.CSharp.DocumentationRules", "SA1600:ElementsMustBeDocumented", Justification = "These are all LSL functions, the documentation is in the LSL Wiki.")]
public partial class SecondLife public partial class SecondLife
{ {
public integer llAbs(integer fValue) public integer llAbs(integer fValue)
@ -100,7 +104,7 @@ namespace LSLEditor
Float fResult = 0.0F; Float fResult = 0.0F;
rotation r = b / a; // calculate the rotation between the two arguments as quaternion rotation r = b / a; // calculate the rotation between the two arguments as quaternion
double s2 = r.s * r.s; // square of the s-element double s2 = r.s * r.s; // square of the s-element
double v2 = r.x * r.x + r.y * r.y + r.z * r.z; // sum of the squares of the v-elements double v2 = (r.x * r.x) + (r.y * r.y) + (r.z * r.z); // sum of the squares of the v-elements
if (s2 < v2) { // compare the s-component to the v-component if (s2 < v2) { // compare the s-component to the v-component
fResult = 2.0 * Math.Acos(Math.Sqrt(s2 / (s2 + v2))); // use arccos if the v-component is dominant fResult = 2.0 * Math.Acos(Math.Sqrt(s2 / (s2 + v2))); // use arccos if the v-component is dominant
@ -202,7 +206,7 @@ namespace LSLEditor
if (s.Length > 3) { if (s.Length > 3) {
data[1] = (byte)((LookupBase64(s, 2) & 0x7) << 6); data[1] = (byte)((LookupBase64(s, 2) & 0x7) << 6);
data[1] |= (byte)(LookupBase64(s, 3)); data[1] |= (byte)LookupBase64(s, 3);
} }
if (s.Length > 5) { if (s.Length > 5) {
@ -212,15 +216,15 @@ namespace LSLEditor
iResult = BitConverter.ToInt32(data, 0); iResult = BitConverter.ToInt32(data, 0);
//0 12 34 56 // 0 12 34 56
//1 78 12 34 // 1 78 12 34
//2 56 78 12 // 2 56 78 12
//3 34 56 78 // 3 34 56 78
//4 12 34 56 // 4 12 34 56
//5 78 12 34 // 5 78 12 34
//6 56 78 12 // 6 56 78 12
//7 34 56 78 // 7 34 56 78
} catch { } catch {
iResult = (new Random()).Next(); iResult = (new Random()).Next();
} }
@ -252,32 +256,36 @@ namespace LSLEditor
string sSource = sString; string sSource = sString;
list lResult = new list(); list lResult = new list();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
int WithinAngelBracket = 0; int intWithinAngelBracket = 0;
for (int intI = 0; intI < sSource.Length; intI++) { for (int intI = 0; intI < sSource.Length; intI++) {
char chrC = sSource[intI]; char chrC = sSource[intI];
if (chrC == '<') if (chrC == '<') {
WithinAngelBracket++; intWithinAngelBracket++;
else if (chrC == '>') } else if (chrC == '>') {
WithinAngelBracket--; intWithinAngelBracket--;
}
if (WithinAngelBracket == 0 && chrC == ',') { if (intWithinAngelBracket == 0 && chrC == ',') {
lResult.Add(sb.ToString()); lResult.Add(sb.ToString());
sb = new StringBuilder(); sb = new StringBuilder();
} else { } else {
sb.Append(sSource[intI]); sb.Append(sSource[intI]);
} }
} }
// dont forget the last one // dont forget the last one
lResult.Add(sb.ToString()); lResult.Add(sb.ToString());
// remove the first space, if any // remove the first space, if any
for (int intI = 0; intI < lResult.Count; intI++) { for (int intI = 0; intI < lResult.Count; intI++) {
string strValue = lResult[intI].ToString(); string strValue = lResult[intI].ToString();
if (strValue == "") if (strValue == "") {
continue; continue;
if (strValue[0] == ' ') }
if (strValue[0] == ' ') {
lResult[intI] = strValue.Substring(1); lResult[intI] = strValue.Substring(1);
} }
}
Verbose(@"llCSV2List(""{0}"")={1}", sSource, lResult.ToVerboseString()); Verbose(@"llCSV2List(""{0}"")={1}", sSource, lResult.ToVerboseString());
@ -377,16 +385,18 @@ namespace LSLEditor
if (CorrectIt(intLength, ref start, ref end)) { if (CorrectIt(intLength, ref start, ref end)) {
if (start <= end) { if (start <= end) {
for (int intI = start; intI <= end; intI++) for (int intI = start; intI <= end; intI++) {
src[intI] = null; src[intI] = null;
} else // excluding }
{ } else { // excluding
for (int intI = 0; intI <= end; intI++) for (int intI = 0; intI <= end; intI++) {
src[intI] = null; src[intI] = null;
for (int intI = start; intI < intLength; intI++) }
for (int intI = start; intI < intLength; intI++) {
src[intI] = null; src[intI] = null;
} }
} }
}
list lResult = new list(); list lResult = new list();
for (int intI = 0; intI < src.Count; intI++) { for (int intI = 0; intI < src.Count; intI++) {
if (src[intI] != null) { if (src[intI] != null) {
@ -410,8 +420,7 @@ namespace LSLEditor
for (int intI = start; intI <= end; intI++) { for (int intI = start; intI <= end; intI++) {
src[intI] = '\0'; src[intI] = '\0';
} }
} else // excluding } else { // excluding
{
for (int intI = 0; intI <= end; intI++) { for (int intI = 0; intI <= end; intI++) {
src[intI] = '\0'; src[intI] = '\0';
} }
@ -616,22 +625,23 @@ namespace LSLEditor
double bw = Math.Cos(v.y); double bw = Math.Cos(v.y);
double cz = Math.Sin(v.z); double cz = Math.Sin(v.z);
double cw = Math.Cos(v.z); double cw = Math.Cos(v.z);
rotation rRotation = new rotation(aw * by * cz + ax * bw * cw, rotation rRotation = new rotation(
aw * by * cw - ax * bw * cz, (aw * by * cz) + (ax * bw * cw),
aw * bw * cz + ax * by * cw, (aw * by * cw) - (ax * bw * cz),
aw * bw * cw - ax * by * cz); (aw * bw * cz) + (ax * by * cw),
(aw * bw * cw) - (ax * by * cz));
Verbose("llEuler2Rot({0})={1}", v, rRotation); Verbose("llEuler2Rot({0})={1}", v, rRotation);
return rRotation; return rRotation;
} }
public void llEvade(key TargetID, list Options) public void llEvade(key kTargetID, list lOptions)
{ {
Verbose("llEvade({0}, {1})", TargetID, Options); Verbose("llEvade({0}, {1})", kTargetID, lOptions);
} }
public void llExecCharacterCmd(integer Command, list Options) public void llExecCharacterCmd(integer iCommand, list lOptions)
{ {
Verbose("llExecCharacterCmd({0}, {1})", Command, Options); Verbose("llExecCharacterCmd({0}, {1})", iCommand, lOptions.ToVerboseString());
} }
public Float llFabs(Float fValue) public Float llFabs(Float fValue)
@ -719,6 +729,7 @@ namespace LSLEditor
// get time // get time
double dblTime = llGetTime(); double dblTime = llGetTime();
Verbose("llGetAndResetTime()=" + dblTime); Verbose("llGetAndResetTime()=" + dblTime);
// reset time // reset time
llResetTime(); llResetTime();
return dblTime; return dblTime;
@ -1447,9 +1458,10 @@ namespace LSLEditor
if (CorrectIt(intLength, ref start, ref end)) { if (CorrectIt(intLength, ref start, ref end)) {
if (start <= end) { if (start <= end) {
for (int intI = start; intI <= end; intI++) for (int intI = start; intI <= end; intI++) {
sResult.Append(src[intI]); sResult.Append(src[intI]);
} else {// excluding }
} else { // excluding
for (int intI = 0; intI <= end; intI++) { for (int intI = 0; intI <= end; intI++) {
sResult.Append(src[intI]); sResult.Append(src[intI]);
} }
@ -1543,7 +1555,7 @@ namespace LSLEditor
public string llGetUsername(key kAvatarID) public string llGetUsername(key kAvatarID)
{ {
//TODO Find a dummy username. // TODO Find a dummy username.
string sUserName = ""; string sUserName = "";
Verbose(@"llGetUsername({0})=""{1}""", kAvatarID, sUserName); Verbose(@"llGetUsername({0})=""{1}""", kAvatarID, sUserName);
return sUserName; return sUserName;
@ -1661,7 +1673,7 @@ namespace LSLEditor
public list llJson2List(string sJSON) public list llJson2List(string sJSON)
{ {
//TODO implement conversion to list // TODO implement conversion to list
list lJSON = new list(); list lJSON = new list();
Verbose("llJson2List({0})={1}", sJSON, lJSON); Verbose("llJson2List({0})={1}", sJSON, lJSON);
return lJSON; return lJSON;
@ -1669,7 +1681,7 @@ namespace LSLEditor
public string llJsonGetValue(string sJSON, list lSpecifiers) public string llJsonGetValue(string sJSON, list lSpecifiers)
{ {
//TODO determine return value from list // TODO determine return value from list
string sReturn = JSON_INVALID; string sReturn = JSON_INVALID;
Verbose("llJsonGetValue({0}, {1})= {2}", sJSON, lSpecifiers, sReturn); Verbose("llJsonGetValue({0}, {1})= {2}", sJSON, lSpecifiers, sReturn);
return sReturn; return sReturn;
@ -1677,7 +1689,7 @@ namespace LSLEditor
public string llJsonSetValue(string sJSON, list lSpecifiers, string sValue) public string llJsonSetValue(string sJSON, list lSpecifiers, string sValue)
{ {
//TODO determine return value // TODO determine return value
string sReturn = JSON_INVALID; string sReturn = JSON_INVALID;
Verbose("llJsonGetValue({0}, {1}, {2})= {3}", sJSON, lSpecifiers, sValue, sReturn); Verbose("llJsonGetValue({0}, {1}, {2})= {3}", sJSON, lSpecifiers, sValue, sReturn);
return sReturn; return sReturn;
@ -1685,7 +1697,7 @@ namespace LSLEditor
public string llJsonValueType(string sJSON, list lSpecifiers) public string llJsonValueType(string sJSON, list lSpecifiers)
{ {
//TODO determine return value // TODO determine return value
string sReturn = JSON_INVALID; string sReturn = JSON_INVALID;
Verbose("llJsonGetValue({0}, {1})= {2}", sJSON, lSpecifiers, sReturn); Verbose("llJsonGetValue({0}, {1})= {2}", sJSON, lSpecifiers, sReturn);
return sReturn; return sReturn;
@ -1715,7 +1727,9 @@ namespace LSLEditor
{ {
StringBuilder sCSV = new StringBuilder(); StringBuilder sCSV = new StringBuilder();
for (int intI = 0; intI < lSource.Count; intI++) { for (int intI = 0; intI < lSource.Count; intI++) {
if (intI > 0) sCSV.Append(", "); if (intI > 0) {
sCSV.Append(", ");
}
sCSV.Append(lSource[intI].ToString()); sCSV.Append(lSource[intI].ToString());
} }
Verbose(@"llList2CSV({0})=""{1}""", lSource.ToVerboseString(), sCSV.ToString()); Verbose(@"llList2CSV({0})=""{1}""", lSource.ToVerboseString(), sCSV.ToString());
@ -1725,7 +1739,9 @@ namespace LSLEditor
public Float llList2Float(list lSource, integer iIndex) public Float llList2Float(list lSource, integer iIndex)
{ {
Float fResult; Float fResult;
if (iIndex < 0) iIndex = lSource.Count + iIndex; if (iIndex < 0) {
iIndex = lSource.Count + iIndex;
}
if (iIndex >= lSource.Count || iIndex < 0) { if (iIndex >= lSource.Count || iIndex < 0) {
fResult = 0.0; fResult = 0.0;
} else { } else {
@ -1738,7 +1754,9 @@ namespace LSLEditor
public integer llList2Integer(list lSrc, integer iIndex) public integer llList2Integer(list lSrc, integer iIndex)
{ {
integer iResult; integer iResult;
if (iIndex < 0) iIndex = lSrc.Count + iIndex; if (iIndex < 0) {
iIndex = lSrc.Count + iIndex;
}
if (iIndex >= lSrc.Count || iIndex < 0) { if (iIndex >= lSrc.Count || iIndex < 0) {
iResult = 0; iResult = 0;
} else { } else {
@ -1750,7 +1768,7 @@ namespace LSLEditor
public string llList2Json(string sType, list lValues) public string llList2Json(string sType, list lValues)
{ {
//TODO determine return value // TODO determine return value
string sReturn = JSON_INVALID; string sReturn = JSON_INVALID;
Verbose(@"llList2Json({0}, {1})=""{2}""", sType, lValues.ToVerboseString(), sReturn); Verbose(@"llList2Json({0}, {1})=""{2}""", sType, lValues.ToVerboseString(), sReturn);
return sReturn; return sReturn;
@ -1759,7 +1777,9 @@ namespace LSLEditor
public key llList2Key(list lSource, integer iIndex) public key llList2Key(list lSource, integer iIndex)
{ {
key kResult; key kResult;
if (iIndex < 0) iIndex = lSource.Count + iIndex; if (iIndex < 0) {
iIndex = lSource.Count + iIndex;
}
if (iIndex >= lSource.Count || iIndex < 0) { if (iIndex >= lSource.Count || iIndex < 0) {
kResult = key.NULL_KEY; kResult = key.NULL_KEY;
} else { } else {
@ -1780,10 +1800,16 @@ namespace LSLEditor
if (CorrectIt(iLength, ref start, ref end)) { if (CorrectIt(iLength, ref start, ref end)) {
if (start <= end) { if (start <= end) {
for (int intI = start; intI <= end; intI++) lResult.Add(lSource[intI]); for (int intI = start; intI <= end; intI++) {
lResult.Add(lSource[intI]);
}
} else { // excluding } else { // excluding
for (int intI = 0; intI <= end; intI++) lResult.Add(lSource[intI]); for (int intI = 0; intI <= end; intI++) {
for (int intI = start; intI < iLength; intI++) lResult.Add(lSource[intI]); lResult.Add(lSource[intI]);
}
for (int intI = start; intI < iLength; intI++) {
lResult.Add(lSource[intI]);
}
} }
} }
@ -1802,10 +1828,16 @@ namespace LSLEditor
if (CorrectIt(iLength, ref intStart, ref intEnd)) { if (CorrectIt(iLength, ref intStart, ref intEnd)) {
if (intStart <= intEnd) { if (intStart <= intEnd) {
for (int intI = intStart; intI <= intEnd; intI++) lTemp.Add(lSource[intI]); for (int intI = intStart; intI <= intEnd; intI++) {
lTemp.Add(lSource[intI]);
}
} else { // excluding } else { // excluding
for (int intI = 0; intI <= intEnd; intI++) lTemp.Add(lSource[intI]); for (int intI = 0; intI <= intEnd; intI++) {
for (int intI = intStart; intI < iLength; intI++) lTemp.Add(lSource[intI]); lTemp.Add(lSource[intI]);
}
for (int intI = intStart; intI < iLength; intI++) {
lTemp.Add(lSource[intI]);
}
} }
} }
list lResult = new list(); list lResult = new list();
@ -1814,9 +1846,13 @@ namespace LSLEditor
sRemark = " ** stride must be > 0 **"; sRemark = " ** stride must be > 0 **";
} else { } else {
if (intStart == 0) { if (intStart == 0) {
for (int intI = 0; intI < lTemp.Count; intI += iStride) lResult.Add(lTemp[intI]); for (int intI = 0; intI < lTemp.Count; intI += iStride) {
lResult.Add(lTemp[intI]);
}
} else { } else {
for (int intI = iStride - 1; intI < lTemp.Count; intI += iStride) lResult.Add(lTemp[intI]); for (int intI = iStride - 1; intI < lTemp.Count; intI += iStride) {
lResult.Add(lTemp[intI]);
}
} }
} }
Verbose(@"llList2ListStrided({0}, {1}, {2}, {3})={4}{5}", lSource.ToVerboseString(), intStart, intEnd, iStride, lResult.ToVerboseString(), sRemark); Verbose(@"llList2ListStrided({0}, {1}, {2}, {3})={4}{5}", lSource.ToVerboseString(), intStart, intEnd, iStride, lResult.ToVerboseString(), sRemark);
@ -1826,7 +1862,9 @@ namespace LSLEditor
public rotation llList2Rot(list lSource, integer iIndex) public rotation llList2Rot(list lSource, integer iIndex)
{ {
rotation rResult; rotation rResult;
if (iIndex < 0) iIndex = lSource.Count + iIndex; if (iIndex < 0) {
iIndex = lSource.Count + iIndex;
}
if (iIndex >= lSource.Count || iIndex < 0) { if (iIndex >= lSource.Count || iIndex < 0) {
rResult = ZERO_ROTATION; rResult = ZERO_ROTATION;
} else { } else {
@ -1843,7 +1881,9 @@ namespace LSLEditor
public String llList2String(list lSource, integer iIndex) public String llList2String(list lSource, integer iIndex)
{ {
String sResult; String sResult;
if (iIndex < 0) iIndex = lSource.Count + iIndex; if (iIndex < 0) {
iIndex = lSource.Count + iIndex;
}
if (iIndex >= lSource.Count || iIndex < 0) { if (iIndex >= lSource.Count || iIndex < 0) {
sResult = ""; sResult = "";
} else { } else {
@ -1856,7 +1896,9 @@ namespace LSLEditor
public vector llList2Vector(list lSource, integer iIndex) public vector llList2Vector(list lSource, integer iIndex)
{ {
vector vResult; vector vResult;
if (iIndex < 0) iIndex = lSource.Count + iIndex; if (iIndex < 0) {
iIndex = lSource.Count + iIndex;
}
if (iIndex >= lSource.Count || iIndex < 0) { if (iIndex >= lSource.Count || iIndex < 0) {
vResult = ZERO_VECTOR; vResult = ZERO_VECTOR;
} else { } else {
@ -1872,9 +1914,15 @@ namespace LSLEditor
public integer llListFindList(list lSource, list lMatch) public integer llListFindList(list lSource, list lMatch)
{ {
if (lSource.Count == 0) return -1; if (lSource.Count == 0) {
if (lMatch.Count == 0) return 0; return -1;
if (lMatch.Count > lSource.Count) return -1; }
if (lMatch.Count == 0) {
return 0;
}
if (lMatch.Count > lSource.Count) {
return -1;
}
int iReturn = -1; int iReturn = -1;
for (int intI = 0; intI <= (lSource.Count - lMatch.Count); intI++) { for (int intI = 0; intI <= (lSource.Count - lMatch.Count); intI++) {
@ -1904,11 +1952,15 @@ namespace LSLEditor
iIndex = lDestination.Count + iIndex; iIndex = lDestination.Count + iIndex;
} }
for (int intI = 0; intI < Math.Min(iIndex, intLength); intI++) lResult.Add(lDestination[intI]); for (int intI = 0; intI < Math.Min(iIndex, intLength); intI++) {
lResult.Add(lDestination[intI]);
}
lResult.AddRange(lSource); lResult.AddRange(lSource);
for (int intI = Math.Max(0, iIndex); intI < intLength; intI++) lResult.Add(lDestination[intI]); for (int intI = Math.Max(0, iIndex); intI < intLength; intI++) {
lResult.Add(lDestination[intI]);
}
Verbose("llListInsertList({0}, {1}, {2})={3}", lDestination.ToVerboseString(), lSource.ToVerboseString(), iIndex, lResult.ToVerboseString()); Verbose("llListInsertList({0}, {1}, {2})={3}", lDestination.ToVerboseString(), lSource.ToVerboseString(), iIndex, lResult.ToVerboseString());
return lResult; return lResult;
@ -1938,12 +1990,18 @@ namespace LSLEditor
list lResult = new list(); list lResult = new list();
if (intStart <= intEnd) { if (intStart <= intEnd) {
for (int intI = 0; intI < intStart; intI++) lResult.Add(lDestination[intI]); for (int intI = 0; intI < intStart; intI++) {
lResult.Add(lDestination[intI]);
}
lResult.AddRange(lSource); lResult.AddRange(lSource);
for (int intI = intEnd + 1; intI < intLength; intI++) lResult.Add(lDestination[intI]); for (int intI = intEnd + 1; intI < intLength; intI++) {
lResult.Add(lDestination[intI]);
}
} else { } else {
// where to add src????? // where to add src?????
for (int intI = intEnd; intI <= intStart; intI++) lResult.Add(lDestination[intI]); for (int intI = intEnd; intI <= intStart; intI++) {
lResult.Add(lDestination[intI]);
}
} }
Verbose("llListReplaceList({0}, {1}, {2}, {3}={4}", lDestination.ToVerboseString(), lSource.ToVerboseString(), intStart, intEnd, lResult.ToVerboseString()); Verbose("llListReplaceList({0}, {1}, {2}, {3}={4}", lDestination.ToVerboseString(), lSource.ToVerboseString(), intStart, intEnd, lResult.ToVerboseString());
return lResult; return lResult;
@ -1989,21 +2047,29 @@ namespace LSLEditor
rmin = double.MaxValue; rmin = double.MaxValue;
rmax = double.MinValue; rmax = double.MinValue;
for (int intI = 0; intI < input.Count; intI++) { for (int intI = 0; intI < input.Count; intI++) {
if (input[intI] < rmin) rmin = input[intI]; if (input[intI] < rmin) {
if (input[intI] > rmax) rmax = input[intI]; rmin = input[intI];
}
if (input[intI] > rmax) {
rmax = input[intI];
}
} }
dResult = rmax - rmin; dResult = rmax - rmin;
break; break;
case LIST_STAT_MIN: case LIST_STAT_MIN:
dResult = double.MaxValue; dResult = double.MaxValue;
for (int intI = 0; intI < input.Count; intI++) { for (int intI = 0; intI < input.Count; intI++) {
if (input[intI] < dResult) dResult = input[intI]; if (input[intI] < dResult) {
dResult = input[intI];
}
} }
break; break;
case LIST_STAT_MAX: case LIST_STAT_MAX:
dResult = double.MinValue; dResult = double.MinValue;
for (int intI = 0; intI < input.Count; intI++) { for (int intI = 0; intI < input.Count; intI++) {
if (input[intI] > dResult) dResult = input[intI]; if (input[intI] > dResult) {
dResult = input[intI];
}
} }
break; break;
case LIST_STAT_MEAN: case LIST_STAT_MEAN:
@ -2015,7 +2081,7 @@ namespace LSLEditor
case LIST_STAT_MEDIAN: case LIST_STAT_MEDIAN:
input.Sort(); input.Sort();
if (Math.Ceiling(input.Count * 0.5) == input.Count * 0.5) { if (Math.Ceiling(input.Count * 0.5) == input.Count * 0.5) {
dResult = (input[(int)(input.Count * 0.5 - 1)] + input[(int)(input.Count * 0.5)]) / 2; dResult = input[(int)((input.Count * 0.5) - 1)] + (input[(int)(input.Count * 0.5)] / 2);
} else { } else {
dResult = input[((int)(Math.Ceiling(input.Count * 0.5))) - 1]; dResult = input[((int)(Math.Ceiling(input.Count * 0.5))) - 1];
} }
@ -2032,8 +2098,8 @@ namespace LSLEditor
for (int intI = 0; intI < input.Count; intI++) { for (int intI = 0; intI < input.Count; intI++) {
dResult += input[intI] * input[intI]; dResult += input[intI] * input[intI];
} }
//double av = GetAverage(input.ToArray()); ////double av = GetAverage(input.ToArray());
//for (int intI = 0; intI < input.Count; intI++) ////for (int intI = 0; intI < input.Count; intI++)
// result += (av - input[intI]) * (av - input[intI]); // result += (av - input[intI]) * (av - input[intI]);
break; break;
case LIST_STAT_NUM_COUNT: case LIST_STAT_NUM_COUNT:
@ -2143,7 +2209,7 @@ namespace LSLEditor
byte[] hash = md5.ComputeHash(Encoding.ASCII.GetBytes(sSource + ":" + iNonce.ToString())); byte[] hash = md5.ComputeHash(Encoding.ASCII.GetBytes(sSource + ":" + iNonce.ToString()));
StringBuilder sbResult = new StringBuilder(); StringBuilder sbResult = new StringBuilder();
foreach (byte hex in hash) { foreach (byte hex in hash) {
sbResult.Append(hex.ToString("x2")); //convert to standard MD5 form sbResult.Append(hex.ToString("x2")); // convert to standard MD5 form
} }
Verbose("llMD5String({0}, {1})={2}", sSource, iNonce, sbResult); Verbose("llMD5String({0}, {1})={2}", sSource, iNonce, sbResult);
return sbResult.ToString(); return sbResult.ToString();
@ -2460,7 +2526,6 @@ namespace LSLEditor
this.host.llRequestPermissions(kAvatarID, iPermissionFlags); this.host.llRequestPermissions(kAvatarID, iPermissionFlags);
} }
//346
public key llRequestSecureURL() public key llRequestSecureURL()
{ {
key kResult = new key(Guid.NewGuid()); key kResult = new key(Guid.NewGuid());
@ -2475,7 +2540,6 @@ namespace LSLEditor
return kResult; return kResult;
} }
//345
public key llRequestURL() public key llRequestURL()
{ {
key kResult = new key(Guid.NewGuid()); key kResult = new key(Guid.NewGuid());
@ -2572,18 +2636,20 @@ namespace LSLEditor
{ {
// http://rpgstats.com/wiki/index.php?title=LibraryRotationFunctions // http://rpgstats.com/wiki/index.php?title=LibraryRotationFunctions
rotation t = new rotation(rRotation.x * rRotation.x, rRotation.y * rRotation.y, rRotation.z * rRotation.z, rRotation.s * rRotation.s); rotation t = new rotation(rRotation.x * rRotation.x, rRotation.y * rRotation.y, rRotation.z * rRotation.z, rRotation.s * rRotation.s);
double m = (t.x + t.y + t.z + t.s); double m = t.x + t.y + t.z + t.s;
vector vEuler = new vector(0, 0, 0); vector vEuler = new vector(0, 0, 0);
if (m != 0) { if (m != 0) {
double n = 2 * (rRotation.y * rRotation.s + rRotation.x * rRotation.z); double n = 2 * ((rRotation.y * rRotation.s) + (rRotation.x * rRotation.z));
double p = m * m - n * n; double p = (m * m) - (n * n);
if (p > 0) { if (p > 0) {
vEuler = new vector(Math.Atan2(2.0 * (rRotation.x * rRotation.s - rRotation.y * rRotation.z), (-t.x - t.y + t.z + t.s)), vEuler = new vector(
Math.Atan2(n, Math.Sqrt(p)), Math.Atan2(2.0 * (rRotation.z * rRotation.s - rRotation.x * rRotation.y), (t.x - t.y - t.z + t.s))); Math.Atan2(2.0 * ((rRotation.x * rRotation.s) - (rRotation.y * rRotation.z)), -t.x - t.y + t.z + t.s),
Math.Atan2(n, Math.Sqrt(p)),
Math.Atan2(2.0 * ((rRotation.z * rRotation.s) - (rRotation.x * rRotation.y)), t.x - t.y - t.z + t.s));
} else if (n > 0) { } else if (n > 0) {
vEuler = new vector(0, PI_BY_TWO, Math.Atan2((rRotation.z * rRotation.s + rRotation.x * rRotation.y), 0.5 - t.x - t.z)); vEuler = new vector(0, PI_BY_TWO, Math.Atan2((rRotation.z * rRotation.s) + (rRotation.x * rRotation.y), 0.5 - t.x - t.z));
} else { } else {
vEuler = new vector(0, -PI_BY_TWO, Math.Atan2((rRotation.z * rRotation.s + rRotation.x * rRotation.y), 0.5 - t.x - t.z)); vEuler = new vector(0, -PI_BY_TWO, Math.Atan2((rRotation.z * rRotation.s) + (rRotation.x * rRotation.y), 0.5 - t.x - t.z));
} }
} }
Verbose("llRot2Euler({0})={1}", rRotation, vEuler); Verbose("llRot2Euler({0})={1}", rRotation, vEuler);
@ -2592,7 +2658,7 @@ namespace LSLEditor
public vector llRot2Fwd(rotation rRotation) public vector llRot2Fwd(rotation rRotation)
{ {
vector v = new vector(1.0 / (rRotation.x * rRotation.x + rRotation.y * rRotation.y + rRotation.z * rRotation.z + rRotation.s * rRotation.s), 0, 0); vector v = new vector(1.0 / ((rRotation.x * rRotation.x) + (rRotation.y * rRotation.y) + (rRotation.z * rRotation.z) + (rRotation.s * rRotation.s)), 0, 0);
vector vResult = v * rRotation; vector vResult = v * rRotation;
Verbose("llRot2Fwd({0})={1}", rRotation, vResult); Verbose("llRot2Fwd({0})={1}", rRotation, vResult);
return vResult; return vResult;
@ -2600,7 +2666,7 @@ namespace LSLEditor
public vector llRot2Left(rotation rRotation) public vector llRot2Left(rotation rRotation)
{ {
vector v = new vector(0, 1.0 / (rRotation.x * rRotation.x + rRotation.y * rRotation.y + rRotation.z * rRotation.z + rRotation.s * rRotation.s), 0); vector v = new vector(0, 1.0 / ((rRotation.x * rRotation.x) + (rRotation.y * rRotation.y) + (rRotation.z * rRotation.z) + (rRotation.s * rRotation.s)), 0);
vector vResult = v * rRotation; vector vResult = v * rRotation;
Verbose("llRot2Left({0})={1}", rRotation, vResult); Verbose("llRot2Left({0})={1}", rRotation, vResult);
return vResult; return vResult;
@ -2608,7 +2674,7 @@ namespace LSLEditor
public vector llRot2Up(rotation rRotation) public vector llRot2Up(rotation rRotation)
{ {
vector v = new vector(0, 0, 1.0 / (rRotation.x * rRotation.x + rRotation.y * rRotation.y + rRotation.z * rRotation.z + rRotation.s * rRotation.s)); vector v = new vector(0, 0, 1.0 / ((rRotation.x * rRotation.x) + (rRotation.y * rRotation.y) + (rRotation.z * rRotation.z) + (rRotation.s * rRotation.s)));
vector vResult = v * rRotation; vector vResult = v * rRotation;
Verbose("llRot2Left({0})={1}", rRotation, vResult); Verbose("llRot2Left({0})={1}", rRotation, vResult);
return vResult; return vResult;
@ -3260,7 +3326,7 @@ namespace LSLEditor
public Float llVecMag(vector vVector) public Float llVecMag(vector vVector)
{ {
double dblValue = Math.Sqrt(vVector.x * vVector.x + vVector.y * vVector.y + vVector.z * vVector.z); double dblValue = Math.Sqrt((vVector.x * vVector.x) + (vVector.y * vVector.y) + (vVector.z * vVector.z));
Verbose("llVecMag({0})={1}", vVector, dblValue); Verbose("llVecMag({0})={1}", vVector, dblValue);
return dblValue; return dblValue;
} }
@ -3318,19 +3384,19 @@ namespace LSLEditor
public String llXorBase64StringsCorrect(String sText1, String sText2) public String llXorBase64StringsCorrect(String sText1, String sText2)
{ {
string S1 = Base64ToString(sText1.ToString()); string strS1 = Base64ToString(sText1.ToString());
string S2 = Base64ToString(sText2.ToString()); string strS2 = Base64ToString(sText2.ToString());
int intLength = S1.Length; int intLength = strS1.Length;
if (S2.Length == 0) { if (strS2.Length == 0) {
S2 = " "; strS2 = " ";
} }
while (S2.Length < intLength) { while (strS2.Length < intLength) {
S2 += S2; strS2 += strS2;
} }
S2 = S2.Substring(0, intLength); strS2 = strS2.Substring(0, intLength);
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
for (int intI = 0; intI < intLength; intI++) { for (int intI = 0; intI < intLength; intI++) {
sb.Append((char)(S1[intI] ^ S2[intI])); sb.Append((char)(strS1[intI] ^ strS2[intI]));
} }
string sResult = StringToBase64(sb.ToString()); string sResult = StringToBase64(sb.ToString());
Verbose(@"llXorBase64StringsCorrect(""{0}"",""{1}"")=""{2}""", sText1, sText2, sResult); Verbose(@"llXorBase64StringsCorrect(""{0}"",""{1}"")=""{2}""", sText1, sText2, sResult);