From 0c8b1efaa9005de1d101ebab5e66117edfaec3b2 Mon Sep 17 00:00:00 2001 From: Lyssa Date: Mon, 7 Apr 2025 19:19:24 +0400 Subject: Minor fixups --- LibTSforge/PhysicalStore/Common.cs | 4 +-- LibTSforge/PhysicalStore/PhysicalStoreModern.cs | 48 +++++++++++++------------ LibTSforge/PhysicalStore/PhysicalStoreVista.cs | 4 +-- LibTSforge/PhysicalStore/PhysicalStoreWin7.cs | 4 +-- LibTSforge/PhysicalStore/VariableBag.cs | 3 +- 5 files changed, 33 insertions(+), 30 deletions(-) (limited to 'LibTSforge/PhysicalStore') diff --git a/LibTSforge/PhysicalStore/Common.cs b/LibTSforge/PhysicalStore/Common.cs index d0ad4fe..aef77f8 100644 --- a/LibTSforge/PhysicalStore/Common.cs +++ b/LibTSforge/PhysicalStore/Common.cs @@ -4,9 +4,9 @@ namespace LibTSforge.PhysicalStore public enum BlockType : uint { - NONE, + NONE, // unused NAMED, - ATTRIBUTE, + ATTRIBUTE, //unused TIMER } diff --git a/LibTSforge/PhysicalStore/PhysicalStoreModern.cs b/LibTSforge/PhysicalStore/PhysicalStoreModern.cs index 9d8bb73..b76852a 100644 --- a/LibTSforge/PhysicalStore/PhysicalStoreModern.cs +++ b/LibTSforge/PhysicalStore/PhysicalStoreModern.cs @@ -3,7 +3,7 @@ namespace LibTSforge.PhysicalStore using System; using System.Collections.Generic; using System.IO; - using LibTSforge.Crypto; + using Crypto; public class ModernBlock { @@ -93,7 +93,7 @@ namespace LibTSforge.PhysicalStore public sealed class PhysicalStoreModern : IPhysicalStore { - private byte[] PreHeaderBytes = new byte[] { }; + private byte[] PreHeaderBytes = { }; private readonly Dictionary> Data = new Dictionary>(); private readonly FileStream TSFile; private readonly PSVersion Version; @@ -281,40 +281,44 @@ namespace LibTSforge.PhysicalStore public void DeleteBlock(string key, string value) { - if (Data.ContainsKey(key)) + if (!Data.ContainsKey(key)) { - List blocks = Data[key]; + return; + } - foreach (ModernBlock block in blocks) + List blocks = Data[key]; + + foreach (ModernBlock block in blocks) + { + if (block.ValueAsStr == value) { - if (block.ValueAsStr == value) - { - blocks.Remove(block); - break; - } + blocks.Remove(block); + break; } - - Data[key] = blocks; } + + Data[key] = blocks; } public void DeleteBlock(string key, uint value) { - if (Data.ContainsKey(key)) + if (!Data.ContainsKey(key)) { - List blocks = Data[key]; + return; + } - foreach (ModernBlock block in blocks) + List blocks = Data[key]; + + foreach (ModernBlock block in blocks) + { + if (block.ValueAsInt == value) { - if (block.ValueAsInt == value) - { - blocks.Remove(block); - break; - } + blocks.Remove(block); + break; } - - Data[key] = blocks; } + + Data[key] = blocks; } public PhysicalStoreModern(string tsPath, bool production, PSVersion version) diff --git a/LibTSforge/PhysicalStore/PhysicalStoreVista.cs b/LibTSforge/PhysicalStore/PhysicalStoreVista.cs index 809be77..5251914 100644 --- a/LibTSforge/PhysicalStore/PhysicalStoreVista.cs +++ b/LibTSforge/PhysicalStore/PhysicalStoreVista.cs @@ -3,7 +3,7 @@ namespace LibTSforge.PhysicalStore using System; using System.Collections.Generic; using System.IO; - using LibTSforge.Crypto; + using Crypto; public class VistaBlock { @@ -88,7 +88,7 @@ namespace LibTSforge.PhysicalStore public sealed class PhysicalStoreVista : IPhysicalStore { - private byte[] PreHeaderBytes = new byte[] { }; + private byte[] PreHeaderBytes = { }; private readonly List Blocks = new List(); private readonly FileStream TSPrimary; private readonly FileStream TSSecondary; diff --git a/LibTSforge/PhysicalStore/PhysicalStoreWin7.cs b/LibTSforge/PhysicalStore/PhysicalStoreWin7.cs index d03bf9a..006c8df 100644 --- a/LibTSforge/PhysicalStore/PhysicalStoreWin7.cs +++ b/LibTSforge/PhysicalStore/PhysicalStoreWin7.cs @@ -3,7 +3,7 @@ namespace LibTSforge.PhysicalStore using System; using System.Collections.Generic; using System.IO; - using LibTSforge.Crypto; + using Crypto; public class Win7Block { @@ -105,7 +105,7 @@ namespace LibTSforge.PhysicalStore public sealed class PhysicalStoreWin7 : IPhysicalStore { - private byte[] PreHeaderBytes = new byte[] { }; + private byte[] PreHeaderBytes = { }; private readonly List Blocks = new List(); private readonly FileStream TSPrimary; private readonly FileStream TSSecondary; diff --git a/LibTSforge/PhysicalStore/VariableBag.cs b/LibTSforge/PhysicalStore/VariableBag.cs index ebe413f..bca0e32 100644 --- a/LibTSforge/PhysicalStore/VariableBag.cs +++ b/LibTSforge/PhysicalStore/VariableBag.cs @@ -74,7 +74,6 @@ namespace LibTSforge.PhysicalStore public override void Decode(BinaryReader reader) { uint type = reader.ReadUInt32(); - uint unk_zero = reader.ReadUInt32(); uint lenName = reader.ReadUInt32(); uint lenVal = reader.ReadUInt32(); uint crc = reader.ReadUInt32(); @@ -156,7 +155,7 @@ namespace LibTSforge.PhysicalStore public List Blocks = new List(); private readonly PSVersion Version; - public void Deserialize(byte[] data) + private void Deserialize(byte[] data) { int len = data.Length; -- cgit v1.2.3