From aa07d85591894cb2aa85ca72b7e30a41d57f8ba0 Mon Sep 17 00:00:00 2001 From: Cinder Roxley Date: Sun, 30 Jun 2024 18:10:23 -0500 Subject: [PATCH] Join declaration and assignment --- LibreMetaverse.Tests/TypeTests.cs | 3 +-- LibreMetaverse.Types/Matrix4.cs | 27 +++++++++---------- LibreMetaverse/BVHDecoder.cs | 8 ++---- LibreMetaverse/BitPack.cs | 7 +++-- LibreMetaverse/Imaging/BakeLayer.cs | 11 +++----- Programs/GridProxy/GridProxy.cs | 15 ++++------- Programs/examples/PacketDump/PacketDump.cs | 6 ++--- .../Commands/Inventory/BackupCommand.cs | 4 +-- .../Commands/Inventory/UploadImageCommand.cs | 6 ++--- .../Commands/Prims/ChangePermsCommand.cs | 8 +++--- .../Commands/Prims/ExportCommand.cs | 4 +-- 11 files changed, 36 insertions(+), 63 deletions(-) diff --git a/LibreMetaverse.Tests/TypeTests.cs b/LibreMetaverse.Tests/TypeTests.cs index 3311d8d6..4a327b16 100644 --- a/LibreMetaverse.Tests/TypeTests.cs +++ b/LibreMetaverse.Tests/TypeTests.cs @@ -101,8 +101,7 @@ namespace LibreMetaverse.Tests [Test] public void VectorCasting() { - Dictionary testNumbers; - testNumbers = new Dictionary(); + var testNumbers = new Dictionary(); testNumbers["1.0"] = 1.0; testNumbers["1.1"] = 1.1; testNumbers["1.01"] = 1.01; diff --git a/LibreMetaverse.Types/Matrix4.cs b/LibreMetaverse.Types/Matrix4.cs index 59b7a661..a7586a29 100644 --- a/LibreMetaverse.Types/Matrix4.cs +++ b/LibreMetaverse.Types/Matrix4.cs @@ -185,12 +185,12 @@ namespace OpenMetaverse /// Z euler angle public void GetEulerAngles(out float roll, out float pitch, out float yaw) { - double angleX, angleY, angleZ; - double cx, cy, cz; // cosines + double angleX, angleZ; + double cx, cz; // cosines double sx, sz; // sines - angleY = Math.Asin(Utils.Clamp(M13, -1f, 1f)); - cy = Math.Cos(angleY); + var angleY = Math.Asin(Utils.Clamp(M13, -1f, 1f)); + var cy = Math.Cos(angleY); if (Math.Abs(cy) > 0.005f) { @@ -383,18 +383,15 @@ namespace OpenMetaverse { Matrix4 m; - float a, b, c, d, e, f; - float ad, bd; + var a = (float)Math.Cos(roll); + var b = (float)Math.Sin(roll); + var c = (float)Math.Cos(pitch); + var d = (float)Math.Sin(pitch); + var e = (float)Math.Cos(yaw); + var f = (float)Math.Sin(yaw); - a = (float)Math.Cos(roll); - b = (float)Math.Sin(roll); - c = (float)Math.Cos(pitch); - d = (float)Math.Sin(pitch); - e = (float)Math.Cos(yaw); - f = (float)Math.Sin(yaw); - - ad = a * d; - bd = b * d; + var ad = a * d; + var bd = b * d; m.M11 = c * e; m.M12 = -c * f; diff --git a/LibreMetaverse/BVHDecoder.cs b/LibreMetaverse/BVHDecoder.cs index 97d9ab53..0fbd23de 100644 --- a/LibreMetaverse/BVHDecoder.cs +++ b/LibreMetaverse/BVHDecoder.cs @@ -222,10 +222,6 @@ namespace OpenMetaverse /// The Joint data serialized into the binBVHJoint structure public binBVHJoint readJoint(byte[] data, ref int i) { - - binBVHJointKey[] positions; - binBVHJointKey[] rotations; - binBVHJoint pJoint = new binBVHJoint(); /* @@ -279,7 +275,7 @@ namespace OpenMetaverse rotationkeys = 0; } - rotations = readKeys(data, ref i, rotationkeys, -1.0f, 1.0f); + var rotations = readKeys(data, ref i, rotationkeys, -1.0f, 1.0f); if (!BitConverter.IsLittleEndian) { @@ -297,7 +293,7 @@ namespace OpenMetaverse } // Read in position keyframes - positions = readKeys(data, ref i, positionkeys, -0.5f, 1.5f); + var positions = readKeys(data, ref i, positionkeys, -0.5f, 1.5f); pJoint.rotationkeys = rotations; pJoint.positionkeys = positions; diff --git a/LibreMetaverse/BitPack.cs b/LibreMetaverse/BitPack.cs index 65cb0703..17d6fbdd 100644 --- a/LibreMetaverse/BitPack.cs +++ b/LibreMetaverse/BitPack.cs @@ -129,7 +129,7 @@ namespace OpenMetaverse { int unsignedBits = intBits + fracBits; int totalBits = unsignedBits; - int min, max; + int min; if (isSigned) { @@ -142,7 +142,7 @@ namespace OpenMetaverse min = 0; } - max = 1 << intBits; + var max = 1 << intBits; float fixedVal = Utils.Clamp(data, (float)min, (float)max); if (isSigned) fixedVal += max; @@ -268,7 +268,6 @@ namespace OpenMetaverse public float UnpackFixed(bool signed, int intBits, int fracBits) { int minVal; - int maxVal; int unsignedBits = intBits + fracBits; int totalBits = unsignedBits; float fixedVal; @@ -280,7 +279,7 @@ namespace OpenMetaverse minVal = 1 << intBits; minVal *= -1; } - maxVal = 1 << intBits; + var maxVal = 1 << intBits; if (totalBits <= 8) fixedVal = (float)UnpackByte(); diff --git a/LibreMetaverse/Imaging/BakeLayer.cs b/LibreMetaverse/Imaging/BakeLayer.cs index 4510dd5d..f3778a17 100644 --- a/LibreMetaverse/Imaging/BakeLayer.cs +++ b/LibreMetaverse/Imaging/BakeLayer.cs @@ -440,15 +440,12 @@ namespace OpenMetaverse.Imaging { if (source == null) return false; - bool sourceHasColor; - bool sourceHasAlpha; - bool sourceHasBump; int i = 0; - sourceHasColor = ((source.Channels & ManagedImage.ImageChannels.Color) != 0 && - source.Red != null && source.Green != null && source.Blue != null); - sourceHasAlpha = ((source.Channels & ManagedImage.ImageChannels.Alpha) != 0 && source.Alpha != null); - sourceHasBump = ((source.Channels & ManagedImage.ImageChannels.Bump) != 0 && source.Bump != null); + var sourceHasColor = ((source.Channels & ManagedImage.ImageChannels.Color) != 0 && + source.Red != null && source.Green != null && source.Blue != null); + var sourceHasAlpha = ((source.Channels & ManagedImage.ImageChannels.Alpha) != 0 && source.Alpha != null); + var sourceHasBump = ((source.Channels & ManagedImage.ImageChannels.Bump) != 0 && source.Bump != null); addSourceAlpha = (addSourceAlpha && sourceHasAlpha); diff --git a/Programs/GridProxy/GridProxy.cs b/Programs/GridProxy/GridProxy.cs index c7a4db2e..254e244e 100644 --- a/Programs/GridProxy/GridProxy.cs +++ b/Programs/GridProxy/GridProxy.cs @@ -487,9 +487,6 @@ namespace GridProxy int reqNo; int contentLength = 0; string contentType = ""; - Match match; - string uri; - string meth; Dictionary headers = new Dictionary(); lock (this) @@ -512,7 +509,7 @@ namespace GridProxy if (line == null) throw new Exception("EOF in client HTTP header"); - match = new Regex(@"^(\S+)\s+(\S+)\s+(HTTP/\d\.\d)$").Match(line); + var match = new Regex(@"^(\S+)\s+(\S+)\s+(HTTP/\d\.\d)$").Match(line); if (!match.Success) { @@ -523,8 +520,8 @@ namespace GridProxy return; } - meth = match.Groups[1].Captures[0].ToString(); - uri = match.Groups[2].Captures[0].ToString(); + var meth = match.Groups[1].Captures[0].ToString(); + var uri = match.Groups[2].Captures[0].ToString(); OpenMetaverse.Logger.Log($"[{reqNo}] {meth}:{uri}", Helpers.LogLevel.Debug); @@ -1324,8 +1321,7 @@ namespace GridProxy // pause listening and fetch the packet bool needsZero = false; bool needsCopy = true; - int length; - length = simFacingSocket.EndReceiveFrom(ar, ref remoteEndPoint); + var length = simFacingSocket.EndReceiveFrom(ar, ref remoteEndPoint); if (proxyHandlers.ContainsKey(remoteEndPoint)) { @@ -1333,10 +1329,9 @@ namespace GridProxy SimProxy simProxy = (SimProxy)proxyHandlers[remoteEndPoint]; // interpret the packet according to the SL protocol - Packet packet; int end = length - 1; - packet = Packet.BuildPacket(receiveBuffer, ref end, zeroBuffer); + var packet = Packet.BuildPacket(receiveBuffer, ref end, zeroBuffer); // check for ACKs we're waiting for packet = simProxy.CheckAcks(packet, Direction.Incoming, ref length, ref needsCopy); diff --git a/Programs/examples/PacketDump/PacketDump.cs b/Programs/examples/PacketDump/PacketDump.cs index 1cb536bd..0c90807c 100644 --- a/Programs/examples/PacketDump/PacketDump.cs +++ b/Programs/examples/PacketDump/PacketDump.cs @@ -42,15 +42,13 @@ namespace PacketDump [STAThread] static void Main(string[] args) { - GridClient client; - - if (args.Length != 4) + if (args.Length != 4) { Console.WriteLine("Usage: PacketDump [firstname] [lastname] [password] [seconds (0 for infinite)]"); return; } - client = new GridClient(); + var client = new GridClient(); // Turn off some unnecessary things client.Settings.MULTIPLE_SIMS = false; // Throttle packets that we don't want all the way down diff --git a/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs b/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs index 7cfa03b8..cfb380ec 100644 --- a/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/BackupCommand.cs @@ -210,11 +210,9 @@ namespace OpenMetaverse.TestClient private void bwBackup_DoWork(object sender, DoWorkEventArgs e) { - string[] args; - TextItemsFound = 0; - args = (string[])e.Argument; + var args = (string[])e.Argument; lock (CurrentDownloads) CurrentDownloads.Clear(); diff --git a/Programs/examples/TestClient/Commands/Inventory/UploadImageCommand.cs b/Programs/examples/TestClient/Commands/Inventory/UploadImageCommand.cs index ef4030ff..6a6ba192 100644 --- a/Programs/examples/TestClient/Commands/Inventory/UploadImageCommand.cs +++ b/Programs/examples/TestClient/Commands/Inventory/UploadImageCommand.cs @@ -48,16 +48,14 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { - string inventoryName; uint timeout; - string fileName; if (args.Length != 3) return "Usage: uploadimage [inventoryname] [timeout] [filename]"; TextureID = UUID.Zero; - inventoryName = args[0]; - fileName = args[2]; + var inventoryName = args[0]; + var fileName = args[2]; if (!uint.TryParse(args[1], out timeout)) return "Usage: uploadimage [inventoryname] [timeout] [filename]"; diff --git a/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs b/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs index 20759da9..cd8a9361 100644 --- a/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ChangePermsCommand.cs @@ -25,9 +25,7 @@ namespace OpenMetaverse.TestClient public override string Execute(string[] args, UUID fromAgentID) { UUID rootID; - Primitive rootPrim; - List childPrims; - List localIDs = new List(); + var localIDs = new List(); // Reset class-wide variables PermsSent = false; @@ -62,7 +60,7 @@ namespace OpenMetaverse.TestClient Logger.DebugLog($"Using PermissionMask: {Perms}", Client); // Find the requested prim - rootPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(prim => prim.ID == rootID); + var rootPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find(prim => prim.ID == rootID); if (rootPrim == null) return $"Cannot find requested prim {rootID}"; else @@ -78,7 +76,7 @@ namespace OpenMetaverse.TestClient } // Find all of the child objects linked to this root - childPrims = Client.Network.CurrentSim.ObjectsPrimitives.FindAll(prim => prim.ParentID == rootPrim.LocalID); + var childPrims = Client.Network.CurrentSim.ObjectsPrimitives.FindAll(prim => prim.ParentID == rootPrim.LocalID); // Build a dictionary of primitives for referencing later Objects[rootPrim.ID] = rootPrim; diff --git a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs index b5f2bb84..7e2cc59e 100644 --- a/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs +++ b/Programs/examples/TestClient/Commands/Prims/ExportCommand.cs @@ -61,9 +61,7 @@ namespace OpenMetaverse.TestClient id = SelectedObject; } - Primitive exportPrim; - - exportPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find( + var exportPrim = Client.Network.CurrentSim.ObjectsPrimitives.Find( prim => prim.ID == id );