diff --git a/LibreMetaverse.Rendering.Meshmerizer/MeshmerizerR.cs b/LibreMetaverse.Rendering.Meshmerizer/MeshmerizerR.cs index 5056b63c..82fbbb85 100644 --- a/LibreMetaverse.Rendering.Meshmerizer/MeshmerizerR.cs +++ b/LibreMetaverse.Rendering.Meshmerizer/MeshmerizerR.cs @@ -266,7 +266,7 @@ namespace OpenMetaverse.Rendering SculptMesh newMesh = new SculptMesh(scupltTexture, smSculptType, mesherLod, true, prim.Sculpt.Mirror, prim.Sculpt.Invert); - int numPrimFaces = 1; // a scuplty has only one face + const int numPrimFaces = 1; // a scuplty has only one face // copy the vertex information into IRendering structures FacetedMesh omvrmesh = new FacetedMesh diff --git a/LibreMetaverse/AppearanceManager.cs b/LibreMetaverse/AppearanceManager.cs index 3c454603..58572788 100644 --- a/LibreMetaverse/AppearanceManager.cs +++ b/LibreMetaverse/AppearanceManager.cs @@ -2335,7 +2335,7 @@ namespace OpenMetaverse #region Agent Size // Takes into account the Shoe Heel/Platform offsets but not the HeadSize offset. Seems to work. - double agentSizeBase = 1.706; + const double agentSizeBase = 1.706; // The calculation for the HeadSize scalar may be incorrect, but it seems to work double agentHeight = agentSizeBase + (agentSizeVPLegLength * .1918) + (agentSizeVPHipLength * .0375) + diff --git a/LibreMetaverse/Assets/Archiving/ArchiveConstants.cs b/LibreMetaverse/Assets/Archiving/ArchiveConstants.cs index 24a5a764..440ca738 100644 --- a/LibreMetaverse/Assets/Archiving/ArchiveConstants.cs +++ b/LibreMetaverse/Assets/Archiving/ArchiveConstants.cs @@ -36,27 +36,27 @@ namespace OpenMetaverse.Assets /// /// The location of the archive control file /// - public static readonly string CONTROL_FILE_PATH = "archive.xml"; + public const string CONTROL_FILE_PATH = "archive.xml"; /// /// Path for the assets held in an archive /// - public static readonly string ASSETS_PATH = "assets/"; + public const string ASSETS_PATH = "assets/"; /// /// Path for the prims file /// - public static readonly string OBJECTS_PATH = "objects/"; + public const string OBJECTS_PATH = "objects/"; /// /// Path for terrains. Technically these may be assets, but I think it's quite nice to split them out. /// - public static readonly string TERRAINS_PATH = "terrains/"; + public const string TERRAINS_PATH = "terrains/"; /// /// Path for region settings. /// - public static readonly string SETTINGS_PATH = "settings/"; + public const string SETTINGS_PATH = "settings/"; /// /// Path for region settings. @@ -66,7 +66,7 @@ namespace OpenMetaverse.Assets /// /// The character the separates the uuid from extension information in an archived asset filename /// - public static readonly string ASSET_EXTENSION_SEPARATOR = "_"; + public const string ASSET_EXTENSION_SEPARATOR = "_"; /// /// Extensions used for asset types in the archive diff --git a/LibreMetaverse/Assets/AssetTypes/AssetLandmark.cs b/LibreMetaverse/Assets/AssetTypes/AssetLandmark.cs index b37186de..41a0dfab 100644 --- a/LibreMetaverse/Assets/AssetTypes/AssetLandmark.cs +++ b/LibreMetaverse/Assets/AssetTypes/AssetLandmark.cs @@ -75,7 +75,7 @@ namespace OpenMetaverse.Assets if (text.ToLower().Contains("landmark version 2")) { RegionID = new UUID(text.Substring(text.IndexOf("region_id", StringComparison.Ordinal) + 10, 36)); - string vecDelim = " "; + const string vecDelim = " "; string[] vecStrings = text.Substring(text.IndexOf("local_pos", StringComparison.Ordinal) + 10).Split(vecDelim.ToCharArray()); if (vecStrings.Length == 3) { diff --git a/LibreMetaverse/Assets/AssetTypes/AssetSound.cs b/LibreMetaverse/Assets/AssetTypes/AssetSound.cs index f86ea5b3..c4d0969c 100644 --- a/LibreMetaverse/Assets/AssetTypes/AssetSound.cs +++ b/LibreMetaverse/Assets/AssetTypes/AssetSound.cs @@ -81,7 +81,7 @@ namespace OpenMetaverse.Assets int numOutputSamples = (int)(pcmDuraton * outputSampleRate); //Ensure that samble buffer is aligned to write chunk size - numOutputSamples = (numOutputSamples / WriteBufferSize) * WriteBufferSize; + numOutputSamples = (numOutputSamples / WRITE_BUFFER_SIZE) * WRITE_BUFFER_SIZE; float[][] outSamples = new float[outputChannels][]; @@ -127,7 +127,8 @@ namespace OpenMetaverse.Assets return pcmValue / 32768f; } - private static readonly int WriteBufferSize = 512; + private const int WRITE_BUFFER_SIZE = 512; + private static byte[] GenerateFile(float[][] floatSamples, int sampleRate, int channels) { MemoryStream outputData = new MemoryStream(); @@ -166,7 +167,7 @@ namespace OpenMetaverse.Assets // ========================================================= var processingState = ProcessingState.Create(info); - for (int readIndex = 0; readIndex <= floatSamples[0].Length; readIndex += WriteBufferSize) + for (int readIndex = 0; readIndex <= floatSamples[0].Length; readIndex += WRITE_BUFFER_SIZE) { if (readIndex == floatSamples[0].Length) { @@ -174,7 +175,7 @@ namespace OpenMetaverse.Assets } else { - processingState.WriteData(floatSamples, WriteBufferSize, readIndex); + processingState.WriteData(floatSamples, WRITE_BUFFER_SIZE, readIndex); } while (!oggStream.Finished && processingState.PacketOut(out OggPacket packet)) diff --git a/LibreMetaverse/BVHDecoder.cs b/LibreMetaverse/BVHDecoder.cs index 863c31dd..e3f344d9 100644 --- a/LibreMetaverse/BVHDecoder.cs +++ b/LibreMetaverse/BVHDecoder.cs @@ -174,15 +174,14 @@ namespace OpenMetaverse /// a string public string ReadBytesUntilNull(byte[] data, ref int i) { - char nterm = '\0'; // Null terminator int endpos = i; int startpos = i; // Find the null character - for (int j = i; j < data.Length; j++) + for (var j = i; j < data.Length; j++) { char spot = Convert.ToChar(data[j]); - if (spot == nterm) + if (spot == '\n') { endpos = j; break; diff --git a/LibreMetaverse/ImportExport/ColladalLoader.cs b/LibreMetaverse/ImportExport/ColladalLoader.cs index f6d357c4..cac6fe66 100644 --- a/LibreMetaverse/ImportExport/ColladalLoader.cs +++ b/LibreMetaverse/ImportExport/ColladalLoader.cs @@ -709,7 +709,7 @@ namespace OpenMetaverse.ImportExport p = triangles.p }; - string str = "3 "; + const string str = "3 "; System.Text.StringBuilder builder = new System.Text.StringBuilder(str.Length * (int)poly.count); for (int i = 0; i < (int)poly.count; i++) builder.Append(str); poly.vcount = builder.ToString(); diff --git a/LibreMetaverse/InventoryManager.cs b/LibreMetaverse/InventoryManager.cs index f2a6f136..aaf82a84 100644 --- a/LibreMetaverse/InventoryManager.cs +++ b/LibreMetaverse/InventoryManager.cs @@ -128,7 +128,7 @@ namespace OpenMetaverse public static readonly UUID MAGIC_ID = new UUID("3c115e51-04f4-523c-9fa6-98aff1034730"); /// Maximum items allowed to give - public static readonly int MAX_GIVE_ITEMS = 66; // viewer code says 66, but 42 in the notification + public const int MAX_GIVE_ITEMS = 66; // viewer code says 66, but 42 in the notification protected struct InventorySearch { diff --git a/Programs/GridProxy/GridProxy.cs b/Programs/GridProxy/GridProxy.cs index 3f6a14b2..f140f32c 100644 --- a/Programs/GridProxy/GridProxy.cs +++ b/Programs/GridProxy/GridProxy.cs @@ -913,7 +913,7 @@ namespace GridProxy if (!KnownCaps.ContainsKey(val)) { CapsDataFormat resFmt = BinaryResponseCaps.Contains(key) ? CapsDataFormat.Binary : CapsDataFormat.OSD; - CapsDataFormat reqFmt = CapsDataFormat.OSD; + const CapsDataFormat reqFmt = CapsDataFormat.OSD; CapInfo newCap = new CapInfo(val, capReq.Info.Sim, key, reqFmt, resFmt); newCap.AddDelegate(new CapsDelegate(KnownCapDelegate)); lock (this) { KnownCaps[val] = newCap; } diff --git a/Programs/examples/TestClient/ClientManager.cs b/Programs/examples/TestClient/ClientManager.cs index 9e5e3dd7..81ba906b 100644 --- a/Programs/examples/TestClient/ClientManager.cs +++ b/Programs/examples/TestClient/ClientManager.cs @@ -102,7 +102,7 @@ namespace OpenMetaverse.TestClient { if (args[3].IndexOf('/') >= 0) { - char sep = '/'; + const char sep = '/'; string[] startbits = args[3].Split(sep); try { diff --git a/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs b/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs index 7aa40686..07460247 100644 --- a/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs +++ b/Programs/examples/TestClient/Commands/Agent/PlayAnimationCommand.cs @@ -16,11 +16,11 @@ namespace OpenMetaverse.TestClient private string Usage() { - string usage = "Usage:\n" + - "\tplay list - list the built in animations\n" + - "\tplay show - show any currently playing animations\n" + - "\tplay UUID - play an animation asset\n" + - "\tplay ANIMATION - where ANIMATION is one of the values returned from \"play list\"\n"; + const string usage = "Usage:\n" + + "\tplay list - list the built in animations\n" + + "\tplay show - show any currently playing animations\n" + + "\tplay UUID - play an animation asset\n" + + "\tplay ANIMATION - where ANIMATION is one of the values returned from \"play list\"\n"; return usage; } diff --git a/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs b/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs index 0dbe4006..11340f82 100644 --- a/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/GiveItemCommand.cs @@ -28,7 +28,6 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell Manager = Client.Inventory; Inventory = Manager.Store; string ret = ""; - string nl = "\n"; string target = args.Aggregate(string.Empty, (current, t) => current + t + " "); target = target.TrimEnd(); @@ -37,24 +36,21 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell // WARNING: Uses local copy of inventory contents, need to download them first. List contents = Inventory.GetContents(Client.CurrentDirectory); bool found = false; - foreach (InventoryBase b in contents) + foreach (var b in contents.Where(b => inventoryName == b.Name || inventoryName == b.UUID.ToString())) { - if (inventoryName == b.Name || inventoryName == b.UUID.ToString()) + found = true; + if (b is InventoryItem item) { - found = true; - if (b is InventoryItem item) - { - Manager.GiveItem(item.UUID, item.Name, item.AssetType, dest, true); - ret += "Gave " + item.Name + " (" + item.AssetType + ")" + nl; - } - else - { - ret += "Unable to give folder " + b.Name + nl; - } + Manager.GiveItem(item.UUID, item.Name, item.AssetType, dest, true); + ret += "Gave " + item.Name + " (" + item.AssetType + ")" + '\n'; + } + else + { + ret += "Unable to give folder " + b.Name + '\n'; } } if (!found) - ret += "No inventory item named " + inventoryName + " found." + nl; + ret += "No inventory item named " + inventoryName + " found." + '\n'; return ret; } diff --git a/Programs/examples/TestClient/Commands/Inventory/ListContentsCommand.cs b/Programs/examples/TestClient/Commands/Inventory/ListContentsCommand.cs index 433fc88f..7c042628 100644 --- a/Programs/examples/TestClient/Commands/Inventory/ListContentsCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/ListContentsCommand.cs @@ -23,7 +23,6 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell // WARNING: Uses local copy of inventory contents, need to download them first. List contents = Inventory.GetContents(Client.CurrentDirectory); string displayString = ""; - string nl = "\n"; // New line character // Pretty simple, just print out the contents. foreach (InventoryBase b in contents) { @@ -49,7 +48,7 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell displayString += PermMaskString(item.Permissions.EveryoneMask); displayString += " " + item.UUID; displayString += " " + item.Name; - displayString += nl; + displayString += '\n'; displayString += " AssetID: " + item.AssetUUID; } } @@ -57,7 +56,7 @@ namespace OpenMetaverse.TestClient.Commands.Inventory.Shell { displayString += b.Name; } - displayString += nl; + displayString += '\n'; } return displayString; } diff --git a/Programs/examples/TestClient/Program.cs b/Programs/examples/TestClient/Program.cs index dea3cf76..2cc85672 100644 --- a/Programs/examples/TestClient/Program.cs +++ b/Programs/examples/TestClient/Program.cs @@ -113,7 +113,7 @@ namespace OpenMetaverse.TestClient if (tokens.Length >= 4) // Optional starting position { - char sep = '/'; + const char sep = '/'; string[] startbits = tokens[3].Split(sep); account.StartLocation = NetworkManager.StartLocation(startbits[0], int.Parse(startbits[1]), @@ -164,7 +164,7 @@ namespace OpenMetaverse.TestClient if (arguments["startpos"] != null) { - char sep = '/'; + const char sep = '/'; string[] startbits = arguments["startpos"].Split(sep); a.StartLocation = NetworkManager.StartLocation(startbits[0], int.Parse(startbits[1]), int.Parse(startbits[2]), int.Parse(startbits[3]));