diff --git a/src/Syroot.Worms.Test/Program.cs b/src/Syroot.Worms.Scratchpad/Program.cs
similarity index 72%
rename from src/Syroot.Worms.Test/Program.cs
rename to src/Syroot.Worms.Scratchpad/Program.cs
index 47a845f..a9f18ed 100644
--- a/src/Syroot.Worms.Test/Program.cs
+++ b/src/Syroot.Worms.Scratchpad/Program.cs
@@ -1,10 +1,7 @@
using Syroot.Worms.Gen2.Armageddon.ProjectX;
-namespace Syroot.Worms.Test
+namespace Syroot.Worms.Scratchpad
{
- ///
- /// Represents the main class of the application containing the program entry point.
- ///
internal class Program
{
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
diff --git a/src/Syroot.Worms.Scratchpad/Syroot.Worms.Scratchpad.csproj b/src/Syroot.Worms.Scratchpad/Syroot.Worms.Scratchpad.csproj
new file mode 100644
index 0000000..12e77bc
--- /dev/null
+++ b/src/Syroot.Worms.Scratchpad/Syroot.Worms.Scratchpad.csproj
@@ -0,0 +1,9 @@
+
+
+ Exe
+ netcoreapp2
+
+
+
+
+
\ No newline at end of file
diff --git a/src/Syroot.Worms.UnitTest/Common/TestHelpers.cs b/src/Syroot.Worms.Test/Common/TestHelpers.cs
similarity index 98%
rename from src/Syroot.Worms.UnitTest/Common/TestHelpers.cs
rename to src/Syroot.Worms.Test/Common/TestHelpers.cs
index 64801cb..88e28d0 100644
--- a/src/Syroot.Worms.UnitTest/Common/TestHelpers.cs
+++ b/src/Syroot.Worms.Test/Common/TestHelpers.cs
@@ -5,7 +5,7 @@ using System.IO;
using System.Linq;
using Syroot.Worms.Core;
-namespace Syroot.Worms.UnitTest.Common
+namespace Syroot.Worms.Test.Common
{
///
/// Represents a collection of methods helping in executing tests.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/ArchiveTests.cs b/src/Syroot.Worms.Test/Gen2/ArchiveTests.cs
similarity index 89%
rename from src/Syroot.Worms.UnitTest/Gen2/ArchiveTests.cs
rename to src/Syroot.Worms.Test/Gen2/ArchiveTests.cs
index 3cd6db0..4ab8f54 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/ArchiveTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/ArchiveTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2
+namespace Syroot.Worms.Test.Gen2
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/Armageddon/GeneratedMapTests.cs b/src/Syroot.Worms.Test/Gen2/Armageddon/GeneratedMapTests.cs
similarity index 89%
rename from src/Syroot.Worms.UnitTest/Gen2/Armageddon/GeneratedMapTests.cs
rename to src/Syroot.Worms.Test/Gen2/Armageddon/GeneratedMapTests.cs
index 554dc04..a3674ac 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/Armageddon/GeneratedMapTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/Armageddon/GeneratedMapTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Armageddon;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2.Armageddon
+namespace Syroot.Worms.Test.Gen2.Armageddon
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/Armageddon/LandDataTests.cs b/src/Syroot.Worms.Test/Gen2/Armageddon/LandDataTests.cs
similarity index 89%
rename from src/Syroot.Worms.UnitTest/Gen2/Armageddon/LandDataTests.cs
rename to src/Syroot.Worms.Test/Gen2/Armageddon/LandDataTests.cs
index 8741a71..38d2ec1 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/Armageddon/LandDataTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/Armageddon/LandDataTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Armageddon;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2.Armageddon
+namespace Syroot.Worms.Test.Gen2.Armageddon
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/Armageddon/ProjectX/LibraryTests.cs b/src/Syroot.Worms.Test/Gen2/Armageddon/ProjectX/LibraryTests.cs
similarity index 88%
rename from src/Syroot.Worms.UnitTest/Gen2/Armageddon/ProjectX/LibraryTests.cs
rename to src/Syroot.Worms.Test/Gen2/Armageddon/ProjectX/LibraryTests.cs
index da387d7..ca7ac24 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/Armageddon/ProjectX/LibraryTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/Armageddon/ProjectX/LibraryTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Armageddon.ProjectX;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2.Armageddon.ProjectX
+namespace Syroot.Worms.Test.Gen2.Armageddon.ProjectX
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/Armageddon/ProjectX/SchemeTests.cs b/src/Syroot.Worms.Test/Gen2/Armageddon/ProjectX/SchemeTests.cs
similarity index 87%
rename from src/Syroot.Worms.UnitTest/Gen2/Armageddon/ProjectX/SchemeTests.cs
rename to src/Syroot.Worms.Test/Gen2/Armageddon/ProjectX/SchemeTests.cs
index 18422ff..98de8f7 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/Armageddon/ProjectX/SchemeTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/Armageddon/ProjectX/SchemeTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Armageddon.ProjectX;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2.Armageddon.ProjectX
+namespace Syroot.Worms.Test.Gen2.Armageddon.ProjectX
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/Armageddon/SchemeTests.cs b/src/Syroot.Worms.Test/Gen2/Armageddon/SchemeTests.cs
similarity index 88%
rename from src/Syroot.Worms.UnitTest/Gen2/Armageddon/SchemeTests.cs
rename to src/Syroot.Worms.Test/Gen2/Armageddon/SchemeTests.cs
index 320b025..b11394d 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/Armageddon/SchemeTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/Armageddon/SchemeTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Armageddon;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2.Armageddon
+namespace Syroot.Worms.Test.Gen2.Armageddon
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/Armageddon/TeamContainerTests.cs b/src/Syroot.Worms.Test/Gen2/Armageddon/TeamContainerTests.cs
similarity index 89%
rename from src/Syroot.Worms.UnitTest/Gen2/Armageddon/TeamContainerTests.cs
rename to src/Syroot.Worms.Test/Gen2/Armageddon/TeamContainerTests.cs
index adc7fcf..c9c8c05 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/Armageddon/TeamContainerTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/Armageddon/TeamContainerTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Armageddon;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2.Armageddon
+namespace Syroot.Worms.Test.Gen2.Armageddon
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/ImageTests.cs b/src/Syroot.Worms.Test/Gen2/ImageTests.cs
similarity index 89%
rename from src/Syroot.Worms.UnitTest/Gen2/ImageTests.cs
rename to src/Syroot.Worms.Test/Gen2/ImageTests.cs
index 8d50326..e0c5986 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/ImageTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/ImageTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2
+namespace Syroot.Worms.Test.Gen2
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/PaletteTests.cs b/src/Syroot.Worms.Test/Gen2/PaletteTests.cs
similarity index 92%
rename from src/Syroot.Worms.UnitTest/Gen2/PaletteTests.cs
rename to src/Syroot.Worms.Test/Gen2/PaletteTests.cs
index 6fb2866..6df5086 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/PaletteTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/PaletteTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2
+namespace Syroot.Worms.Test.Gen2
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/WorldParty/LandDataTests.cs b/src/Syroot.Worms.Test/Gen2/WorldParty/LandDataTests.cs
similarity index 89%
rename from src/Syroot.Worms.UnitTest/Gen2/WorldParty/LandDataTests.cs
rename to src/Syroot.Worms.Test/Gen2/WorldParty/LandDataTests.cs
index ebd8bbf..9478072 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/WorldParty/LandDataTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/WorldParty/LandDataTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.WorldParty;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2.WorldParty
+namespace Syroot.Worms.Test.Gen2.WorldParty
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/WorldParty/TeamContainerTests.cs b/src/Syroot.Worms.Test/Gen2/WorldParty/TeamContainerTests.cs
similarity index 89%
rename from src/Syroot.Worms.UnitTest/Gen2/WorldParty/TeamContainerTests.cs
rename to src/Syroot.Worms.Test/Gen2/WorldParty/TeamContainerTests.cs
index 3a2f9d1..d3fbefb 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/WorldParty/TeamContainerTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/WorldParty/TeamContainerTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.WorldParty;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2.WorldParty
+namespace Syroot.Worms.Test.Gen2.WorldParty
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/Worms2/LandDataTests.cs b/src/Syroot.Worms.Test/Gen2/Worms2/LandDataTests.cs
similarity index 89%
rename from src/Syroot.Worms.UnitTest/Gen2/Worms2/LandDataTests.cs
rename to src/Syroot.Worms.Test/Gen2/Worms2/LandDataTests.cs
index 9b1ca23..0e61c3e 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/Worms2/LandDataTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/Worms2/LandDataTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Worms2;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2.Worms2
+namespace Syroot.Worms.Test.Gen2.Worms2
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/Worms2/SchemeOptionsTests.cs b/src/Syroot.Worms.Test/Gen2/Worms2/SchemeOptionsTests.cs
similarity index 89%
rename from src/Syroot.Worms.UnitTest/Gen2/Worms2/SchemeOptionsTests.cs
rename to src/Syroot.Worms.Test/Gen2/Worms2/SchemeOptionsTests.cs
index f2c0786..b6cbb27 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/Worms2/SchemeOptionsTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/Worms2/SchemeOptionsTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Worms2;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2.Worms2
+namespace Syroot.Worms.Test.Gen2.Worms2
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/Worms2/SchemeWeaponsTests.cs b/src/Syroot.Worms.Test/Gen2/Worms2/SchemeWeaponsTests.cs
similarity index 89%
rename from src/Syroot.Worms.UnitTest/Gen2/Worms2/SchemeWeaponsTests.cs
rename to src/Syroot.Worms.Test/Gen2/Worms2/SchemeWeaponsTests.cs
index 5150b00..bfde1d5 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/Worms2/SchemeWeaponsTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/Worms2/SchemeWeaponsTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Worms2;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2.Worms2
+namespace Syroot.Worms.Test.Gen2.Worms2
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.UnitTest/Gen2/Worms2/TeamContainerTests.cs b/src/Syroot.Worms.Test/Gen2/Worms2/TeamContainerTests.cs
similarity index 89%
rename from src/Syroot.Worms.UnitTest/Gen2/Worms2/TeamContainerTests.cs
rename to src/Syroot.Worms.Test/Gen2/Worms2/TeamContainerTests.cs
index 113ae0b..6f907aa 100644
--- a/src/Syroot.Worms.UnitTest/Gen2/Worms2/TeamContainerTests.cs
+++ b/src/Syroot.Worms.Test/Gen2/Worms2/TeamContainerTests.cs
@@ -1,8 +1,8 @@
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Worms2;
-using Syroot.Worms.UnitTest.Common;
+using Syroot.Worms.Test.Common;
-namespace Syroot.Worms.UnitTest.Gen2.Worms2
+namespace Syroot.Worms.Test.Gen2.Worms2
{
///
/// Represents a collection of tests for the class.
diff --git a/src/Syroot.Worms.Test/Syroot.Worms.Test.csproj b/src/Syroot.Worms.Test/Syroot.Worms.Test.csproj
index 2ab1ed5..a10916c 100644
--- a/src/Syroot.Worms.Test/Syroot.Worms.Test.csproj
+++ b/src/Syroot.Worms.Test/Syroot.Worms.Test.csproj
@@ -1,12 +1,12 @@
-
-
- Exe
- netcoreapp1.1
-
-
-
-
-
-
-
\ No newline at end of file
+
+ netcoreapp2
+
+
+
+
+
+
+
+
+
diff --git a/src/Syroot.Worms.UnitTest/Syroot.Worms.UnitTest.csproj b/src/Syroot.Worms.UnitTest/Syroot.Worms.UnitTest.csproj
deleted file mode 100644
index 1c31b05..0000000
--- a/src/Syroot.Worms.UnitTest/Syroot.Worms.UnitTest.csproj
+++ /dev/null
@@ -1,21 +0,0 @@
-
-
-
- netcoreapp1.1
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
diff --git a/src/Syroot.Worms.sln b/src/Syroot.Worms.sln
index ccddfa7..fff63a0 100644
--- a/src/Syroot.Worms.sln
+++ b/src/Syroot.Worms.sln
@@ -3,11 +3,11 @@ Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio 15
VisualStudioVersion = 15.0.26403.7
MinimumVisualStudioVersion = 10.0.40219.1
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Syroot.Worms", "Syroot.Worms\Syroot.Worms.csproj", "{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Syroot.Worms", "Syroot.Worms\Syroot.Worms.csproj", "{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}"
EndProject
-Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "Syroot.Worms.UnitTest", "Syroot.Worms.UnitTest\Syroot.Worms.UnitTest.csproj", "{493816DB-A1A1-4981-9F5F-8044499937B6}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Syroot.Worms.Test", "Syroot.Worms.Test\Syroot.Worms.Test.csproj", "{20ACA971-A9D0-4424-9958-9CEE24F43C9C}"
EndProject
-Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Syroot.Worms.Test", "Syroot.Worms.Test\Syroot.Worms.Test.csproj", "{2D796945-A523-4A22-BDEE-702D6BA36F69}"
+Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Syroot.Worms.Scratchpad", "Syroot.Worms.Scratchpad\Syroot.Worms.Scratchpad.csproj", "{0D7F9DC3-7268-494E-BA1E-6C01525EB9AB}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
@@ -19,16 +19,19 @@ Global
{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}.Debug|Any CPU.Build.0 = Debug|Any CPU
{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}.Release|Any CPU.ActiveCfg = Release|Any CPU
{DD76B6AA-5A5A-4FCD-95AA-9552977525A1}.Release|Any CPU.Build.0 = Release|Any CPU
- {493816DB-A1A1-4981-9F5F-8044499937B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {493816DB-A1A1-4981-9F5F-8044499937B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {493816DB-A1A1-4981-9F5F-8044499937B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {493816DB-A1A1-4981-9F5F-8044499937B6}.Release|Any CPU.Build.0 = Release|Any CPU
- {2D796945-A523-4A22-BDEE-702D6BA36F69}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
- {2D796945-A523-4A22-BDEE-702D6BA36F69}.Debug|Any CPU.Build.0 = Debug|Any CPU
- {2D796945-A523-4A22-BDEE-702D6BA36F69}.Release|Any CPU.ActiveCfg = Release|Any CPU
- {2D796945-A523-4A22-BDEE-702D6BA36F69}.Release|Any CPU.Build.0 = Release|Any CPU
+ {20ACA971-A9D0-4424-9958-9CEE24F43C9C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {20ACA971-A9D0-4424-9958-9CEE24F43C9C}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {20ACA971-A9D0-4424-9958-9CEE24F43C9C}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {20ACA971-A9D0-4424-9958-9CEE24F43C9C}.Release|Any CPU.Build.0 = Release|Any CPU
+ {0D7F9DC3-7268-494E-BA1E-6C01525EB9AB}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
+ {0D7F9DC3-7268-494E-BA1E-6C01525EB9AB}.Debug|Any CPU.Build.0 = Debug|Any CPU
+ {0D7F9DC3-7268-494E-BA1E-6C01525EB9AB}.Release|Any CPU.ActiveCfg = Release|Any CPU
+ {0D7F9DC3-7268-494E-BA1E-6C01525EB9AB}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
+ GlobalSection(ExtensibilityGlobals) = postSolution
+ SolutionGuid = {1CD4EDE2-A5FB-4A58-A850-3506AB7E7B69}
+ EndGlobalSection
EndGlobal
diff --git a/src/Syroot.Worms/Core/BinaryReaderExtensions.cs b/src/Syroot.Worms/Core/BinaryReaderExtensions.cs
deleted file mode 100644
index 97c3579..0000000
--- a/src/Syroot.Worms/Core/BinaryReaderExtensions.cs
+++ /dev/null
@@ -1,114 +0,0 @@
-using System.Diagnostics;
-using System.IO;
-using System.Reflection;
-using System.Runtime.InteropServices;
-using Syroot.BinaryData;
-
-namespace Syroot.Worms.Core
-{
- ///
- /// Represents extension methods for instances.
- ///
- [DebuggerStepThrough]
- internal static class BinaryReaderExtensions
- {
- // ---- METHODS (INTERNAL) -------------------------------------------------------------------------------------
-
- ///
- /// Reads an instance from the current stream.
- ///
- /// The type of the class to instantiate.
- /// The extended .
- /// The instance.
- internal static T Load(this BinaryDataReader self) where T : ILoadable, new()
- {
- T instance = new T();
- instance.Load(self.BaseStream);
- return instance;
- }
-
- ///
- /// Reads instances from the current stream.
- ///
- /// The type of the class to instantiate.
- /// The extended .
- /// The number of instances to read.
- /// The instances.
- internal static T[] Load(this BinaryDataReader self, int count) where T : ILoadable, new()
- {
- T[] instances = new T[count];
- for (int i = 0; i < count; i++)
- {
- instances[i] = Load(self);
- }
- return instances;
- }
-
- ///
- /// Reads a 0-terminated string which is stored in a fixed-size block of bytes.
- ///
- /// The extended .
- /// The number of bytes the fixed-size blocks takes.
- /// The read string.
- internal static string ReadFixedString(this BinaryDataReader self, int length)
- {
- string str = self.ReadString(BinaryStringFormat.ZeroTerminated);
- self.Seek(length - str.Length - 1);
- return str;
- }
-
- ///
- /// Reads 0-terminated strings which are stored in a fixed-size block of
- /// bytes.
- ///
- /// The extended .
- /// The number of values to read.
- /// The number of bytes the fixed-size blocks takes.
- /// The read string.
- internal static string[] ReadFixedStrings(this BinaryDataReader self, int count, int length)
- {
- string[] strings = new string[count];
- for (int i = 0; i < count; i++)
- {
- strings[i] = ReadFixedString(self, length);
- }
- return strings;
- }
-
- ///
- /// Reads a raw byte structure from the current stream and returns it.
- ///
- /// The type of the structure to read.
- /// The extended instance.
- /// The structure of type .
- internal static T ReadStruct(this BinaryReader self) where T : struct
- {
- // Read the raw bytes of the structure.
- byte[] bytes = self.ReadBytes(Marshal.SizeOf());
-
- // Convert them to a structure instance and return it.
- GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
- T instance = Marshal.PtrToStructure(handle.AddrOfPinnedObject());
- handle.Free();
-
- return instance;
- }
-
- ///
- /// Reads raw byte structures from the current stream and returns them.
- ///
- /// The type of the structure to read.
- /// The extended instance.
- /// The number of values to read.
- /// The structures of type .
- internal static T[] ReadStructs(this BinaryReader self, int count) where T : struct
- {
- T[] values = new T[count];
- for (int i = 0; i < count; i++)
- {
- values[i] = ReadStruct(self);
- }
- return values;
- }
- }
-}
diff --git a/src/Syroot.Worms/Core/BinaryStreamExtensions.cs b/src/Syroot.Worms/Core/BinaryStreamExtensions.cs
new file mode 100644
index 0000000..2e0c991
--- /dev/null
+++ b/src/Syroot.Worms/Core/BinaryStreamExtensions.cs
@@ -0,0 +1,221 @@
+using System.Diagnostics;
+using System.IO;
+using System.Runtime.InteropServices;
+using Syroot.BinaryData;
+
+namespace Syroot.Worms.Core
+{
+ ///
+ /// Represents extension methods for instances.
+ ///
+ [DebuggerStepThrough]
+ internal static partial class BinaryStreamExtensions
+ {
+ // ---- METHODS (INTERNAL) -------------------------------------------------------------------------------------
+
+ // ---- Reading ----
+
+ ///
+ /// Reads an instance from the current stream.
+ ///
+ /// The type of the class to instantiate.
+ /// The extended .
+ /// The instance.
+ internal static T Load(this BinaryStream self) where T : ILoadable, new()
+ {
+ T instance = new T();
+ instance.Load(self.BaseStream);
+ return instance;
+ }
+
+ ///
+ /// Reads instances from the current stream.
+ ///
+ /// The type of the class to instantiate.
+ /// The extended .
+ /// The number of instances to read.
+ /// The instances.
+ internal static T[] Load(this BinaryStream self, int count) where T : ILoadable, new()
+ {
+ T[] instances = new T[count];
+ for (int i = 0; i < count; i++)
+ {
+ instances[i] = Load(self);
+ }
+ return instances;
+ }
+
+ ///
+ /// Reads a 0-terminated string which is stored in a fixed-size block of bytes.
+ ///
+ /// The extended .
+ /// The number of bytes the fixed-size blocks takes.
+ /// The read string.
+ internal static string ReadFixedString(this BinaryStream self, int length)
+ {
+ string str = self.ReadString(StringCoding.ZeroTerminated);
+ self.Seek(length - str.Length - 1);
+ return str;
+ }
+
+ ///
+ /// Reads 0-terminated strings which are stored in a fixed-size block of
+ /// bytes.
+ ///
+ /// The extended .
+ /// The number of values to read.
+ /// The number of bytes the fixed-size blocks takes.
+ /// The read string.
+ internal static string[] ReadFixedStrings(this BinaryStream self, int count, int length)
+ {
+ string[] strings = new string[count];
+ for (int i = 0; i < count; i++)
+ {
+ strings[i] = ReadFixedString(self, length);
+ }
+ return strings;
+ }
+
+ ///
+ /// Reads a raw byte structure from the current stream and returns it.
+ ///
+ /// The type of the structure to read.
+ /// The extended instance.
+ /// The structure of type .
+ internal static T ReadStruct(this BinaryStream self) where T : struct
+ {
+ // Read the raw bytes of the structure.
+ byte[] bytes = self.ReadBytes(Marshal.SizeOf());
+
+ // Convert them to a structure instance and return it.
+ GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
+ T instance = Marshal.PtrToStructure(handle.AddrOfPinnedObject());
+ handle.Free();
+
+ return instance;
+ }
+
+ ///
+ /// Reads raw byte structures from the current stream and returns them.
+ ///
+ /// The type of the structure to read.
+ /// The extended instance.
+ /// The number of values to read.
+ /// The structures of type .
+ internal static T[] ReadStructs(this BinaryStream self, int count) where T : struct
+ {
+ T[] values = new T[count];
+ for (int i = 0; i < count; i++)
+ {
+ values[i] = ReadStruct(self);
+ }
+ return values;
+ }
+
+ ///
+ /// Returns the current address of the stream to which a 4-byte placeholder has been written which can be filled
+ /// later.
+ ///
+ /// The extended instance.
+ /// The address at which a 4-byte placeholder has been written to.
+ internal static uint ReserveOffset(this BinaryStream self)
+ {
+ uint offset = (uint)self.Position;
+ self.WriteUInt32(0);
+ return offset;
+ }
+
+ // ---- Writing ----
+
+ ///
+ /// Writes the given instance into the current stream.
+ ///
+ /// The type of the class to write.
+ /// The extended .
+ /// The instance to write into the current stream.
+ internal static void Save(this BinaryStream self, T value) where T : ISaveable
+ {
+ value.Save(self.BaseStream);
+ }
+
+ ///
+ /// Writes the given instances into the current stream.
+ ///
+ /// The type of the class to write.
+ /// The extended .
+ /// The instances to write into the current stream.
+ internal static void Save(this BinaryStream self, T[] values) where T : ISaveable
+ {
+ foreach (T value in values)
+ {
+ Save(self, value);
+ }
+ }
+
+ internal static void SatisfyOffset(this BinaryStream self, uint offset, int value)
+ {
+ using (self.TemporarySeek(offset, SeekOrigin.Begin))
+ self.WriteInt32(value);
+ }
+
+ ///
+ /// Writes the given string into a fixed-size block of bytes and 0-terminates it.
+ ///
+ /// The extended instance.
+ /// The string to write.
+ /// The number of bytes the fixed-size block takes.
+ internal static void Write(this BinaryStream self, string value, int length)
+ {
+ byte[] bytes = self.Encoding.GetBytes(value);
+ self.Write(bytes);
+ self.Write(new byte[length - bytes.Length]);
+ }
+
+ ///
+ /// Writes the given strings into fixed-size blocks of bytes and 0-terminates them.
+ ///
+ /// The extended instance.
+ /// The strings to write.
+ /// The number of bytes a fixed-size block takes.
+ internal static void Write(this BinaryStream self, string[] values, int length)
+ {
+ foreach (string value in values)
+ {
+ Write(self, value, length);
+ }
+ }
+
+ ///
+ /// Writes the bytes of a structure into the current stream.
+ ///
+ /// The type of the structure to read.
+ /// The extended instance.
+ /// The structure to write.
+ internal static void Write(this BinaryStream self, T value) where T : struct
+ {
+ // Get the raw bytes of the structure instance.
+ byte[] bytes = new byte[Marshal.SizeOf()];
+
+ GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
+ Marshal.StructureToPtr(value, handle.AddrOfPinnedObject(), false);
+ handle.Free();
+
+ // Write the bytes to the stream.
+ self.Write(bytes);
+ }
+
+ ///
+ /// Writes the bytes of structures into the current stream.
+ ///
+ /// The type of the structure to read.
+ /// The extended instance.
+ /// The structures to write.
+ internal static void Write(this BinaryStream self, T[] values) where T : struct
+ {
+ foreach (T value in values)
+ {
+ Write(self, value);
+ }
+ }
+ }
+}
diff --git a/src/Syroot.Worms/Core/BinaryWriterExtensions.cs b/src/Syroot.Worms/Core/BinaryWriterExtensions.cs
deleted file mode 100644
index 6c72d9d..0000000
--- a/src/Syroot.Worms/Core/BinaryWriterExtensions.cs
+++ /dev/null
@@ -1,101 +0,0 @@
-using System.Diagnostics;
-using System.IO;
-using System.Runtime.InteropServices;
-using Syroot.BinaryData;
-
-namespace Syroot.Worms.Core
-{
- ///
- /// Represents extension methods for instances.
- ///
- [DebuggerStepThrough]
- internal static class BinaryWriterExtensions
- {
- // ---- METHODS (INTERNAL) -------------------------------------------------------------------------------------
-
- ///
- /// Writes the given instance into the current stream.
- ///
- /// The type of the class to write.
- /// The extended .
- /// The instance to write into the current stream.
- internal static void Save(this BinaryDataWriter self, T value) where T : ISaveable
- {
- value.Save(self.BaseStream);
- }
-
- ///
- /// Writes the given instances into the current stream.
- ///
- /// The type of the class to write.
- /// The extended .
- /// The instances to write into the current stream.
- internal static void Save(this BinaryDataWriter self, T[] values) where T : ISaveable
- {
- foreach (T value in values)
- {
- Save(self, value);
- }
- }
-
- ///
- /// Writes the given string into a fixed-size block of bytes and 0-terminates it.
- ///
- /// The extended instance.
- /// The string to write.
- /// The number of bytes the fixed-size block takes.
- internal static void Write(this BinaryDataWriter self, string value, int length)
- {
- byte[] bytes = self.Encoding.GetBytes(value);
- self.Write(bytes);
- self.Write(new byte[length - bytes.Length]);
- }
-
- ///
- /// Writes the given strings into fixed-size blocks of bytes and 0-terminates them.
- ///
- /// The extended instance.
- /// The strings to write.
- /// The number of bytes a fixed-size block takes.
- internal static void Write(this BinaryDataWriter self, string[] values, int length)
- {
- foreach (string value in values)
- {
- Write(self, value, length);
- }
- }
-
- ///
- /// Writes the bytes of a structure into the current stream.
- ///
- /// The type of the structure to read.
- /// The extended instance.
- /// The structure to write.
- internal static void Write(this BinaryWriter self, T value) where T : struct
- {
- // Get the raw bytes of the structure instance.
- byte[] bytes = new byte[Marshal.SizeOf()];
-
- GCHandle handle = GCHandle.Alloc(bytes, GCHandleType.Pinned);
- Marshal.StructureToPtr(value, handle.AddrOfPinnedObject(), false);
- handle.Free();
-
- // Write the bytes to the stream.
- self.Write(bytes);
- }
-
- ///
- /// Writes the bytes of structures into the current stream.
- ///
- /// The type of the structure to read.
- /// The extended instance.
- /// The structures to write.
- internal static void Write(this BinaryWriter self, T[] values) where T : struct
- {
- foreach (T value in values)
- {
- Write(self, value);
- }
- }
- }
-}
diff --git a/src/Syroot.Worms/Core/RiffFile.cs b/src/Syroot.Worms/Core/RiffFile.cs
index 7a3cfdc..5f3da97 100644
--- a/src/Syroot.Worms/Core/RiffFile.cs
+++ b/src/Syroot.Worms/Core/RiffFile.cs
@@ -40,7 +40,7 @@ namespace Syroot.Worms.Core
/// The to load the RIFF data from.
protected void LoadRiff(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the file header.
if (reader.ReadString(_signature.Length) != _signature)
@@ -78,25 +78,25 @@ namespace Syroot.Worms.Core
/// The to save the RIFF data in.
protected void SaveRiff(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
// Write the header.
- writer.Write(_signature, BinaryStringFormat.NoPrefixOrTermination);
- Offset fileSizeOffset = writer.ReserveOffset();
- writer.Write(_typeData.FileIdentifier, BinaryStringFormat.NoPrefixOrTermination);
+ writer.Write(_signature, StringCoding.Raw);
+ uint fileSizeOffset = writer.ReserveOffset();
+ writer.Write(_typeData.FileIdentifier, StringCoding.Raw);
// Write the chunks.
foreach (KeyValuePair chunkSaver in _typeData.ChunkSavers)
{
- writer.Write(chunkSaver.Key, BinaryStringFormat.NoPrefixOrTermination);
- Offset chunkSizeOffset = writer.ReserveOffset();
+ writer.Write(chunkSaver.Key, StringCoding.Raw);
+ uint chunkSizeOffset = writer.ReserveOffset();
chunkSaver.Value.Invoke(this, new object[] { writer });
- chunkSizeOffset.Satisfy((int)(writer.Position - chunkSizeOffset.Position - 4));
+ writer.SatisfyOffset(chunkSizeOffset, (int)(writer.Position - chunkSizeOffset - 4));
}
- fileSizeOffset.Satisfy((int)writer.Position - 8);
+ writer.SatisfyOffset(fileSizeOffset, (int)(writer.Position - 8));
}
}
@@ -123,7 +123,7 @@ namespace Syroot.Worms.Core
{
ParameterInfo[] parameters = method.GetParameters();
if (parameters.Length == 2
- && parameters[0].ParameterType == typeof(BinaryDataReader)
+ && parameters[0].ParameterType == typeof(BinaryStream)
&& parameters[1].ParameterType == typeof(int))
{
typeData.ChunkLoaders.Add(loadAttribute.Identifier, method);
@@ -135,7 +135,7 @@ namespace Syroot.Worms.Core
{
ParameterInfo[] parameters = method.GetParameters();
if (parameters.Length == 1
- && parameters[0].ParameterType == typeof(BinaryDataWriter))
+ && parameters[0].ParameterType == typeof(BinaryStream))
{
typeData.ChunkSavers.Add(saveAttribute.Identifier, method);
}
diff --git a/src/Syroot.Worms/Gen2/Archive.cs b/src/Syroot.Worms/Gen2/Archive.cs
index f2cf39d..9493f34 100644
--- a/src/Syroot.Worms/Gen2/Archive.cs
+++ b/src/Syroot.Worms/Gen2/Archive.cs
@@ -65,7 +65,7 @@ namespace Syroot.Worms.Gen2
}
Clear();
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
if (reader.ReadInt32() != _signature)
@@ -96,7 +96,7 @@ namespace Syroot.Worms.Gen2
nextEntryOffset = reader.ReadInt32();
int offset = reader.ReadInt32();
int length = reader.ReadInt32();
- string name = reader.ReadString(BinaryStringFormat.ZeroTerminated);
+ string name = reader.ReadString(StringCoding.ZeroTerminated);
using (reader.TemporarySeek(offset, SeekOrigin.Begin))
{
Add(name, reader.ReadBytes(length));
@@ -125,12 +125,12 @@ namespace Syroot.Worms.Gen2
/// The to save the data in.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream))
+ using (BinaryStream writer = new BinaryStream(stream))
{
// Write the header.
writer.Write(_signature);
- Offset fileSizeOffset = writer.ReserveOffset();
- Offset tocOffset = writer.ReserveOffset();
+ uint fileSizeOffset = writer.ReserveOffset();
+ uint tocOffset = writer.ReserveOffset();
// Write the data and build the hash table and file entries.
List[] hashTable = new List[_hashSize];
@@ -155,7 +155,7 @@ namespace Syroot.Worms.Gen2
// Write the hash table and file entries.
int tocStart = (int)writer.Position;
int fileEntryOffset = sizeof(int) + _hashSize * sizeof(int);
- tocOffset.Satisfy(tocStart);
+ writer.SatisfyOffset(tocOffset, tocStart);
writer.Write(_tocSignature);
for (int i = 0; i < _hashSize; i++)
{
@@ -173,14 +173,14 @@ namespace Syroot.Worms.Gen2
for (int j = 0; j < entries.Count; j++)
{
HashTableEntry entry = entries[j];
- Offset nextEntryOffset = writer.ReserveOffset();
+ uint nextEntryOffset = writer.ReserveOffset();
writer.Write(entry.Offset);
writer.Write(entry.Length);
- writer.Write(entry.Name, BinaryStringFormat.ZeroTerminated);
+ writer.Write(entry.Name, StringCoding.ZeroTerminated);
writer.Align(4);
if (j < entries.Count - 1)
{
- nextEntryOffset.Satisfy((int)writer.Position - tocStart);
+ writer.SatisfyOffset(nextEntryOffset, (int)writer.Position - tocStart);
}
}
fileEntryOffset = (int)writer.Position - tocStart;
@@ -188,7 +188,7 @@ namespace Syroot.Worms.Gen2
}
}
- fileSizeOffset.Satisfy(tocStart + fileEntryOffset - 1);
+ writer.SatisfyOffset(fileSizeOffset, tocStart + fileEntryOffset - 1);
}
}
diff --git a/src/Syroot.Worms/Gen2/Armageddon/GeneratedMap.cs b/src/Syroot.Worms/Gen2/Armageddon/GeneratedMap.cs
index 512e0e9..a9b9083 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/GeneratedMap.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/GeneratedMap.cs
@@ -54,7 +54,7 @@ namespace Syroot.Worms.Gen2.Armageddon
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
Settings = reader.ReadStruct();
}
@@ -78,7 +78,7 @@ namespace Syroot.Worms.Gen2.Armageddon
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
writer.Write(Settings);
}
diff --git a/src/Syroot.Worms/Gen2/Armageddon/LandData.cs b/src/Syroot.Worms/Gen2/Armageddon/LandData.cs
index 1af97b0..2cffcec 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/LandData.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/LandData.cs
@@ -104,7 +104,7 @@ namespace Syroot.Worms.Gen2.Armageddon
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
if (reader.ReadInt32() != _signature)
@@ -115,7 +115,7 @@ namespace Syroot.Worms.Gen2.Armageddon
// Read the data.
Size = reader.ReadStruct();
- TopBorder = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ TopBorder = reader.ReadBoolean(BooleanCoding.Dword);
WaterHeight = reader.ReadInt32();
Unknown = reader.ReadInt32();
@@ -128,8 +128,8 @@ namespace Syroot.Worms.Gen2.Armageddon
Background = reader.Load();
// Read the file paths.
- LandTexturePath = reader.ReadString(BinaryStringFormat.ByteLengthPrefix);
- WaterDirPath = reader.ReadString(BinaryStringFormat.ByteLengthPrefix);
+ LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);
+ WaterDirPath = reader.ReadString(StringCoding.ByteCharCount);
}
}
@@ -151,15 +151,15 @@ namespace Syroot.Worms.Gen2.Armageddon
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
// Write the header.
writer.Write(_signature);
- Offset fileSizeOffset = writer.ReserveOffset();
+ uint fileSizeOffset = writer.ReserveOffset();
// Write the data.
writer.Write(Size);
- writer.Write(TopBorder, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(TopBorder, BooleanCoding.Dword);
writer.Write(WaterHeight);
writer.Write(Unknown);
@@ -173,10 +173,10 @@ namespace Syroot.Worms.Gen2.Armageddon
Background.Save(writer.BaseStream);
// Write the file paths.
- writer.Write(LandTexturePath, BinaryStringFormat.ByteLengthPrefix);
- writer.Write(WaterDirPath, BinaryStringFormat.ByteLengthPrefix);
+ writer.Write(LandTexturePath, StringCoding.ByteCharCount);
+ writer.Write(WaterDirPath, StringCoding.ByteCharCount);
- fileSizeOffset.Satisfy();
+ writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
}
}
diff --git a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Actions/ActionConverter.cs b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Actions/ActionConverter.cs
index ee90c29..fe7e417 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Actions/ActionConverter.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Actions/ActionConverter.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX
@@ -7,7 +8,8 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
{
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
- public object Read(BinaryDataReader reader, object instance, BinaryMemberAttribute memberAttribute)
+ public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
+ ByteConverter byteConverter)
{
ExplosionAction explosionAction;
switch (instance)
@@ -25,20 +27,21 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
switch (explosionAction)
{
case ExplosionAction.Bounce:
- return reader.ReadObject();
+ return stream.ReadObject();
case ExplosionAction.Dig:
- return reader.ReadObject();
+ return stream.ReadObject();
case ExplosionAction.Home:
- return reader.ReadObject();
+ return stream.ReadObject();
case ExplosionAction.Roam:
- return reader.ReadObject();
+ return stream.ReadObject();
}
return null;
}
- public void Write(BinaryDataWriter writer, object instance, BinaryMemberAttribute memberAttribute, object value)
+ public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,
+ ByteConverter byteConverter)
{
- writer.WriteObject(value);
+ stream.WriteObject(value);
}
}
}
diff --git a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Actions/RoamAction.cs b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Actions/RoamAction.cs
index bf320c7..780369d 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Actions/RoamAction.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Actions/RoamAction.cs
@@ -28,7 +28,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
public int TerrainOffset { get; set; }
- [BinaryMember(BooleanFormat = BinaryBooleanFormat.NonZeroDword)]
+ [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
public bool Fart { get; set; }
public int DiseasePower { get; set; }
diff --git a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Library.cs b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Library.cs
index f79fbf8..5504cbe 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Library.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Library.cs
@@ -75,14 +75,14 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
if (reader.ReadInt32() != _signature)
{
throw new InvalidDataException("Invalid PXL file signature.");
}
- Version = reader.ReadByte();
+ Version = reader.Read1Byte();
// Read the items.
Clear();
@@ -90,14 +90,14 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
for (int i = 0; i < itemCount; i++)
{
LibraryItemType type = reader.ReadEnum(true);
- string name = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
+ string name = reader.ReadString(StringCoding.Int32CharCount);
switch (type)
{
case LibraryItemType.File:
Add(new LibraryItem(name, reader.ReadBytes(reader.ReadInt32())));
break;
case LibraryItemType.Script:
- Add(new LibraryItem(name, reader.ReadString(BinaryStringFormat.DwordLengthPrefix)));
+ Add(new LibraryItem(name, reader.ReadString(StringCoding.Int32CharCount)));
break;
case LibraryItemType.Weapon:
Add(new LibraryItem(name, reader.Load()));
@@ -125,7 +125,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
// Write the header.
writer.Write(_signature);
@@ -135,8 +135,8 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
writer.Write(Count);
foreach (LibraryItem item in this)
{
- writer.Write(item.Type, true);
- writer.Write(item.Key, BinaryStringFormat.DwordLengthPrefix);
+ writer.WriteEnum(item.Type, true);
+ writer.Write(item.Key, StringCoding.Int32CharCount);
switch (item.Type)
{
case LibraryItemType.File:
@@ -145,7 +145,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
writer.Write(value);
break;
case LibraryItemType.Script:
- writer.Write((string)item.Value, BinaryStringFormat.DwordLengthPrefix);
+ writer.Write((string)item.Value, StringCoding.Int32CharCount);
break;
case LibraryItemType.Weapon:
writer.Save((Weapon)item.Value);
diff --git a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Scheme.cs b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Scheme.cs
index 6fd7ac8..d617e5e 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Scheme.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Scheme.cs
@@ -72,7 +72,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
if (reader.ReadString(_signature.Length) != _signature)
@@ -100,7 +100,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
Files = new Dictionary(filesCount);
for (int i = 0; i < filesCount; i++)
{
- string name = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
+ string name = reader.ReadString(StringCoding.Int32CharCount);
int length = reader.ReadInt32();
Files.Add(name, reader.ReadBytes(length));
}
@@ -110,20 +110,20 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
Scripts = new Dictionary(scriptsCount);
for (int i = 0; i < scriptsCount; i++)
{
- Scripts.Add(reader.ReadString(BinaryStringFormat.DwordLengthPrefix),
- reader.ReadString(BinaryStringFormat.DwordLengthPrefix));
+ Scripts.Add(reader.ReadString(StringCoding.Int32CharCount),
+ reader.ReadString(StringCoding.Int32CharCount));
}
// Read required libraries.
int librariesCount = reader.ReadInt32();
- Libraries = new List(reader.ReadStrings(librariesCount, BinaryStringFormat.DwordLengthPrefix));
+ Libraries = new List(reader.ReadStrings(librariesCount, StringCoding.Int32CharCount));
// Read a possibly attached scheme file.
if (reader.ReadBoolean())
{
reader.Seek(sizeof(int)); // Scheme length not required due to intelligent loading.
GameScheme = reader.Load();
- GameSchemeName = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
+ GameSchemeName = reader.ReadString(StringCoding.Int32CharCount);
}
}
}
@@ -146,10 +146,10 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
// Write the header.
- writer.Write(_signature, BinaryStringFormat.NoPrefixOrTermination);
+ writer.Write(_signature, StringCoding.Raw);
writer.Write(Version);
// Write the scheme flags.
@@ -169,7 +169,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
writer.Write(Files.Count);
foreach (KeyValuePair file in Files)
{
- writer.Write(file.Key, BinaryStringFormat.DwordLengthPrefix);
+ writer.Write(file.Key, StringCoding.Int32CharCount);
writer.Write(file.Value.Length);
writer.Write(file.Value);
}
@@ -178,8 +178,8 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
writer.Write(Scripts.Count);
foreach (KeyValuePair script in Scripts)
{
- writer.Write(script.Key, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(script.Value, BinaryStringFormat.DwordLengthPrefix);
+ writer.Write(script.Key, StringCoding.Int32CharCount);
+ writer.Write(script.Value, StringCoding.Int32CharCount);
}
// Write required libraries.
@@ -196,7 +196,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
schemeBytes = schemeStream.ToArray();
}
writer.Write(schemeBytes.Length);
- writer.Write(GameSchemeName, BinaryStringFormat.DwordLengthPrefix);
+ writer.Write(GameSchemeName, StringCoding.Int32CharCount);
}
}
}
diff --git a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Sound.cs b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Sound.cs
index d7f2e58..6e5d94c 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Sound.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Sound.cs
@@ -6,10 +6,10 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
{
public short SoundIndex;
- [BinaryMember(BooleanFormat = BinaryBooleanFormat.NonZeroWord)]
+ [BinaryMember(BooleanCoding = BooleanCoding.Word)]
public bool RepeatSound;
- [BinaryMember(BooleanFormat = BinaryBooleanFormat.NonZeroDword)]
+ [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
public bool UseExplosionSound;
public int SoundBeforeExplosion;
diff --git a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Styles/AirstrikeSubstyleConverter.cs b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Styles/AirstrikeSubstyleConverter.cs
index eca70b7..3b1c2df 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Styles/AirstrikeSubstyleConverter.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Styles/AirstrikeSubstyleConverter.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX
@@ -7,7 +8,8 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
{
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
- public object Read(BinaryDataReader reader, object instance, BinaryMemberAttribute memberAttribute)
+ public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
+ ByteConverter byteConverter)
{
WeaponAirstrikeSubstyle airstrikeSubstyle;
switch (instance)
@@ -22,16 +24,17 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
switch (airstrikeSubstyle)
{
case WeaponAirstrikeSubstyle.Launcher:
- return reader.ReadObject();
+ return stream.ReadObject();
case WeaponAirstrikeSubstyle.Mines:
- return reader.ReadObject();
+ return stream.ReadObject();
}
return null;
}
- public void Write(BinaryDataWriter writer, object instance, BinaryMemberAttribute memberAttribute, object value)
+ public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,
+ ByteConverter byteConverter)
{
- writer.WriteObject(value);
+ stream.WriteObject(value);
}
}
}
\ No newline at end of file
diff --git a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Styles/FlamethrowerStyle.cs b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Styles/FlamethrowerStyle.cs
index cbc87b1..c71369c 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Styles/FlamethrowerStyle.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Styles/FlamethrowerStyle.cs
@@ -14,7 +14,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
public int FireBurnTime { get; set; }
- [BinaryMember(BooleanFormat = BinaryBooleanFormat.NonZeroDword)]
+ [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
public bool RemainOnTerrain { get; set; }
}
}
\ No newline at end of file
diff --git a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Styles/LauncherStyle.cs b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Styles/LauncherStyle.cs
index 3775c4f..8600380 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Styles/LauncherStyle.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Styles/LauncherStyle.cs
@@ -10,7 +10,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
public int FixedSpeed { get; set; }
- [BinaryMember(BooleanFormat = BinaryBooleanFormat.NonZeroDword)]
+ [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
public bool RunAway { get; set; }
public CollisionFlags Collisions { get; set; }
@@ -41,7 +41,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
public Sound Sound { get; set; }
- [BinaryMember(BooleanFormat = BinaryBooleanFormat.NonZeroDword)]
+ [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
public bool ExplodeOnSpace { get; set; }
public ExplosionAction ExplosionAction { get; set; }
diff --git a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Targets/ClusterTarget.cs b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Targets/ClusterTarget.cs
index 77f5082..b88cd52 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Targets/ClusterTarget.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Targets/ClusterTarget.cs
@@ -44,7 +44,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
public Sound Sound { get; set; }
- [BinaryMember(BooleanFormat = BinaryBooleanFormat.NonZeroDword)]
+ [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
public bool ExplodeOnSpace { get; set; }
public ExplosionAction ExplosionAction { get; set; }
diff --git a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Targets/FireTarget.cs b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Targets/FireTarget.cs
index 67858c1..01e930f 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Targets/FireTarget.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Targets/FireTarget.cs
@@ -12,7 +12,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
public int Time { get; set; }
- [BinaryMember(BooleanFormat = BinaryBooleanFormat.NonZeroDword)]
+ [BinaryMember(BooleanCoding = BooleanCoding.Dword)]
public bool StayBetweenTurns { get; set; }
}
}
diff --git a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Targets/TargetConverter.cs b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Targets/TargetConverter.cs
index 8abd0df..ad4f185 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Targets/TargetConverter.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Targets/TargetConverter.cs
@@ -1,4 +1,5 @@
using System;
+using System.IO;
using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX
@@ -7,7 +8,8 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
{
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
- public object Read(BinaryDataReader reader, object instance, BinaryMemberAttribute memberAttribute)
+ public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
+ ByteConverter byteConverter)
{
ExplosionTarget explosionTarget;
switch (instance)
@@ -22,16 +24,17 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
switch (explosionTarget)
{
case ExplosionTarget.Clusters:
- return reader.ReadObject();
+ return stream.ReadObject();
case ExplosionTarget.Fire:
- return reader.ReadObject();
+ return stream.ReadObject();
}
return null;
}
- public void Write(BinaryDataWriter writer, object instance, BinaryMemberAttribute memberAttribute, object value)
+ public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,
+ ByteConverter byteConverter)
{
- writer.WriteObject(value);
+ stream.WriteObject(value);
}
}
}
diff --git a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Weapon.cs b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Weapon.cs
index b1083c2..1e8efde 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Weapon.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/ProjectX/Weapon.cs
@@ -113,7 +113,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
long offset = reader.Position;
@@ -122,10 +122,10 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
// Read general settings.
TableRow = reader.ReadInt32();
- Remembered = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
- UsableInCavern = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ Remembered = reader.ReadBoolean(BooleanCoding.Dword);
+ UsableInCavern = reader.ReadBoolean(BooleanCoding.Dword);
Shots = reader.ReadInt32();
- ShotEndsTurn = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ ShotEndsTurn = reader.ReadBoolean(BooleanCoding.Dword);
RetreatTime = reader.ReadInt32();
Unknown1 = reader.ReadInt32();
CrateChance = reader.ReadInt32();
@@ -239,34 +239,34 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
// Read additional settings.
reader.Position = offset + 468;
- AmmunitionOverride = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ AmmunitionOverride = reader.ReadBoolean(BooleanCoding.Dword);
Ammunition = reader.ReadInt32();
Unknown3 = reader.ReadInt32();
WeaponSprite = reader.ReadInt32();
- NameLong = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- Name = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- GridImageFile = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- GfxDirectoryFile = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- SpriteNames = reader.ReadStrings(5, BinaryStringFormat.DwordLengthPrefix);
- DelayOverride = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ NameLong = reader.ReadString(StringCoding.Int32CharCount);
+ Name = reader.ReadString(StringCoding.Int32CharCount);
+ GridImageFile = reader.ReadString(StringCoding.Int32CharCount);
+ GfxDirectoryFile = reader.ReadString(StringCoding.Int32CharCount);
+ SpriteNames = reader.ReadStrings(5, StringCoding.Int32CharCount);
+ DelayOverride = reader.ReadBoolean(BooleanCoding.Dword);
Delay = reader.ReadInt32();
UseLibrary = reader.ReadBoolean();
if (UseLibrary)
{
- LibraryName = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- LibraryWeaponName = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
+ LibraryName = reader.ReadString(StringCoding.Int32CharCount);
+ LibraryWeaponName = reader.ReadString(StringCoding.Int32CharCount);
}
- AimSpriteEven = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- AimSpriteUphill = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- AimSpriteDownhill = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- PickSpriteEven = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- PickSpriteUphill = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- PickSpriteDownhill = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- FireSpriteEven = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- FireSpriteUphill = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
- FireSpriteDownhill = reader.ReadString(BinaryStringFormat.DwordLengthPrefix);
+ AimSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
+ AimSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
+ AimSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
+ PickSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
+ PickSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
+ PickSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
+ FireSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
+ FireSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
+ FireSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
AimSpriteOverride = reader.ReadBoolean();
PickSpriteOverride = reader.ReadBoolean();
FireSpriteOverride = reader.ReadBoolean();
@@ -283,19 +283,19 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII, true))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Write the header.
long offset = writer.Position;
- writer.Write(Version, true);
+ writer.WriteEnum(Version, true);
writer.Write(Checksum);
// Write the general settings.
writer.Write(TableRow);
- writer.Write(Remembered, BinaryBooleanFormat.NonZeroDword);
- writer.Write(UsableInCavern, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(Remembered, BooleanCoding.Dword);
+ writer.Write(UsableInCavern, BooleanCoding.Dword);
writer.Write(Shots);
- writer.Write(ShotEndsTurn, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(ShotEndsTurn, BooleanCoding.Dword);
writer.Write(RetreatTime);
writer.Write(Unknown1);
writer.Write(CrateChance);
@@ -303,7 +303,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
writer.Write(Unknown2);
// Write the activation and the corresponding weapon settings.
- writer.Write(Activation, true);
+ writer.WriteEnum(Activation, true);
switch (Activation)
{
case WeaponActivation.Airstrike:
@@ -312,14 +312,14 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
break;
case WeaponActivation.Crosshair:
writer.Write(NotUsed);
- writer.Write(CrosshairAction, true);
+ writer.WriteEnum(CrosshairAction, true);
if (CrosshairAction != WeaponCrosshairAction.None)
{
writer.WriteObject(Style);
}
break;
case WeaponActivation.Spacebar:
- writer.Write(SpacebarAction, true);
+ writer.WriteEnum(SpacebarAction, true);
switch (SpacebarAction)
{
case WeaponSpacebarAction.Armageddon:
@@ -342,7 +342,7 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
break;
case WeaponActivation.Throw:
writer.Write(ThrowHerdCount);
- writer.Write(ThrowAction, true);
+ writer.WriteEnum(ThrowAction, true);
if (ThrowAction != WeaponThrowAction.None)
{
writer.WriteObject(Style);
@@ -352,34 +352,34 @@ namespace Syroot.Worms.Gen2.Armageddon.ProjectX
// Write additional settings.
writer.Position = offset + 468;
- writer.Write(AmmunitionOverride, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(AmmunitionOverride, BooleanCoding.Dword);
writer.Write(Ammunition);
writer.Write(Unknown3);
writer.Write(WeaponSprite);
- writer.Write(NameLong, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(Name, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(GridImageFile, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(GfxDirectoryFile, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(SpriteNames, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(DelayOverride, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(NameLong, StringCoding.Int32CharCount);
+ writer.Write(Name, StringCoding.Int32CharCount);
+ writer.Write(GridImageFile, StringCoding.Int32CharCount);
+ writer.Write(GfxDirectoryFile, StringCoding.Int32CharCount);
+ writer.Write(SpriteNames, StringCoding.Int32CharCount);
+ writer.Write(DelayOverride, BooleanCoding.Dword);
writer.Write(Delay);
writer.Write(UseLibrary);
if (UseLibrary)
{
- writer.Write(LibraryName, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(LibraryWeaponName, BinaryStringFormat.DwordLengthPrefix);
+ writer.Write(LibraryName, StringCoding.Int32CharCount);
+ writer.Write(LibraryWeaponName, StringCoding.Int32CharCount);
}
- writer.Write(AimSpriteEven, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(AimSpriteUphill, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(AimSpriteDownhill, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(PickSpriteEven, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(PickSpriteUphill, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(PickSpriteDownhill, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(FireSpriteEven, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(FireSpriteUphill, BinaryStringFormat.DwordLengthPrefix);
- writer.Write(FireSpriteDownhill, BinaryStringFormat.DwordLengthPrefix);
+ writer.Write(AimSpriteEven, StringCoding.Int32CharCount);
+ writer.Write(AimSpriteUphill, StringCoding.Int32CharCount);
+ writer.Write(AimSpriteDownhill, StringCoding.Int32CharCount);
+ writer.Write(PickSpriteEven, StringCoding.Int32CharCount);
+ writer.Write(PickSpriteUphill, StringCoding.Int32CharCount);
+ writer.Write(PickSpriteDownhill, StringCoding.Int32CharCount);
+ writer.Write(FireSpriteEven, StringCoding.Int32CharCount);
+ writer.Write(FireSpriteUphill, StringCoding.Int32CharCount);
+ writer.Write(FireSpriteDownhill, StringCoding.Int32CharCount);
writer.Write(AimSpriteOverride);
writer.Write(PickSpriteOverride);
writer.Write(FireSpriteOverride);
diff --git a/src/Syroot.Worms/Gen2/Armageddon/Scheme.cs b/src/Syroot.Worms/Gen2/Armageddon/Scheme.cs
index a61f289..f51d6c3 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/Scheme.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/Scheme.cs
@@ -608,7 +608,7 @@ namespace Syroot.Worms.Gen2.Armageddon
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
if (reader.ReadString(_signature.Length) != _signature)
@@ -618,9 +618,9 @@ namespace Syroot.Worms.Gen2.Armageddon
Version = reader.ReadEnum(true);
// Read the options.
- HotSeatDelay = reader.ReadByte();
- RetreatTime = reader.ReadByte();
- RetreatTimeRope = reader.ReadByte();
+ HotSeatDelay = reader.Read1Byte();
+ RetreatTime = reader.Read1Byte();
+ RetreatTimeRope = reader.Read1Byte();
ShowRoundTime = reader.ReadBoolean();
AutomaticReplays = reader.ReadBoolean();
FallDamage = (SchemeFallDamage)(reader.ReadByte() * 50 % 0x100 * 2);
@@ -633,13 +633,13 @@ namespace Syroot.Worms.Gen2.Armageddon
WeaponCrateProbability = reader.ReadSByte();
DonorCards = reader.ReadBoolean();
HealthCrateProbability = reader.ReadSByte();
- HealthCrateEnergy = reader.ReadByte();
+ HealthCrateEnergy = reader.Read1Byte();
UtilityCrateProbability = reader.ReadSByte();
LoadObjectTypesAndCount(reader);
LoadMineDelayConfig(reader);
DudMines = reader.ReadBoolean();
ManualWormPlacement = reader.ReadBoolean();
- WormEnergy = reader.ReadByte();
+ WormEnergy = reader.Read1Byte();
LoadTurnTimeConfig(reader);
LoadRoundTimeConfig(reader);
NumberOfWins = (byte)Math.Max(1, (int)reader.ReadByte());
@@ -698,10 +698,10 @@ namespace Syroot.Worms.Gen2.Armageddon
/// The to respect when storing the settings.
public void Save(Stream stream, SchemeSaveFormat format)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
// Write the header.
- writer.Write(_signature, BinaryStringFormat.NoPrefixOrTermination);
+ writer.Write(_signature, StringCoding.Raw);
writer.Write((byte)Version);
// Write the options.
@@ -712,10 +712,10 @@ namespace Syroot.Worms.Gen2.Armageddon
writer.Write(AutomaticReplays);
writer.Write((byte)((int)FallDamage / 4 * 41 % 0x80));
writer.Write(ArtilleryMode);
- writer.Write(SchemeEditor, false);
- writer.Write(StockpilingMode, true);
- writer.Write(WormSelectMode, true);
- writer.Write(SuddenDeathEvent, true);
+ writer.WriteEnum(SchemeEditor, false);
+ writer.WriteEnum(StockpilingMode, true);
+ writer.WriteEnum(WormSelectMode, true);
+ writer.WriteEnum(SuddenDeathEvent, true);
writer.Write(_mapWaterRiseToRaw[(byte)WaterRiseRate]);
writer.Write(WeaponCrateProbability);
writer.Write(DonorCards);
@@ -780,13 +780,13 @@ namespace Syroot.Worms.Gen2.Armageddon
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
- private void LoadObjectTypesAndCount(BinaryDataReader reader)
+ private void LoadObjectTypesAndCount(BinaryStream reader)
{
// Invalid values default to 8 mines.
ObjectTypes = SchemeObjectType.Mines;
ObjectCount = SchemeObjectCount.Count8;
- byte raw = reader.ReadByte();
+ byte raw = reader.Read1Byte();
if (raw < 12)
{
// WA before 3.6.28.0 and WWP only store object type.
@@ -823,9 +823,9 @@ namespace Syroot.Worms.Gen2.Armageddon
}
}
- private void LoadMineDelayConfig(BinaryDataReader reader)
+ private void LoadMineDelayConfig(BinaryStream reader)
{
- byte raw = reader.ReadByte();
+ byte raw = reader.Read1Byte();
if (raw == 4 || raw > 0x7F)
{
MineDelay = 0;
@@ -838,9 +838,9 @@ namespace Syroot.Worms.Gen2.Armageddon
}
}
- private void LoadTurnTimeConfig(BinaryDataReader reader)
+ private void LoadTurnTimeConfig(BinaryStream reader)
{
- byte raw = reader.ReadByte();
+ byte raw = reader.Read1Byte();
if (raw > 0x7F)
{
TurnTime = 0;
@@ -853,9 +853,9 @@ namespace Syroot.Worms.Gen2.Armageddon
}
}
- private void LoadRoundTimeConfig(BinaryDataReader reader)
+ private void LoadRoundTimeConfig(BinaryStream reader)
{
- byte raw = reader.ReadByte();
+ byte raw = reader.Read1Byte();
if (raw > 0x7F)
{
RoundTimeMinutes = 0;
@@ -933,7 +933,7 @@ namespace Syroot.Worms.Gen2.Armageddon
return Version == SchemeVersion.Extended ? 64 : 45;
}
- private void SaveObjectTypesAndCount(BinaryDataWriter writer, SchemeSaveFormat format)
+ private void SaveObjectTypesAndCount(BinaryStream writer, SchemeSaveFormat format)
{
byte raw = 0;
if (format == SchemeSaveFormat.ExtendedWithObjectCount)
@@ -953,7 +953,7 @@ namespace Syroot.Worms.Gen2.Armageddon
}
// Get the index of the object count and compute the raw value from that.
int index = Array.IndexOf(_objectCounts, (byte)ObjectCount);
- raw = (byte)(index * 4 + (8 + raw));
+ raw = (byte)(index * 4 + 8 + raw);
}
else
{
@@ -974,7 +974,7 @@ namespace Syroot.Worms.Gen2.Armageddon
writer.Write(raw);
}
- private void SaveMineDelayConfig(BinaryDataWriter writer)
+ private void SaveMineDelayConfig(BinaryStream writer)
{
if (MineDelayRandom)
{
@@ -986,7 +986,7 @@ namespace Syroot.Worms.Gen2.Armageddon
}
}
- private void SaveTurnTimeConfig(BinaryDataWriter writer)
+ private void SaveTurnTimeConfig(BinaryStream writer)
{
if (TurnTimeInfinite)
{
@@ -998,7 +998,7 @@ namespace Syroot.Worms.Gen2.Armageddon
}
}
- private void SaveRoundTimeConfig(BinaryDataWriter writer)
+ private void SaveRoundTimeConfig(BinaryStream writer)
{
if (RoundTimeSeconds > 0)
{
diff --git a/src/Syroot.Worms/Gen2/Armageddon/Team.cs b/src/Syroot.Worms/Gen2/Armageddon/Team.cs
index 682531b..f5bd3ba 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/Team.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/Team.cs
@@ -196,15 +196,15 @@ namespace Syroot.Worms.Gen2.Armageddon
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
Name = reader.ReadFixedString(17);
WormNames = reader.ReadFixedStrings(8, 17);
- CpuLevel = reader.ReadByte();
+ CpuLevel = reader.Read1Byte();
SoundBankName = reader.ReadFixedString(0x20);
- SoundBankLocation = reader.ReadByte();
+ SoundBankLocation = reader.Read1Byte();
FanfareName = reader.ReadFixedString(0x20);
- UseCustomFanfare = reader.ReadByte();
+ UseCustomFanfare = reader.Read1Byte();
GraveSprite = reader.ReadSByte();
if (GraveSprite < 0)
@@ -241,13 +241,13 @@ namespace Syroot.Worms.Gen2.Armageddon
Data = reader.ReadBytes(20 * 17)
};
- DeathmatchRank = reader.ReadByte();
+ DeathmatchRank = reader.Read1Byte();
TrainingMissionTimes = reader.ReadInt32s(_trainingMissionCount);
Unknown1 = reader.ReadInt32s(10);
TrainingMissionMedals = reader.ReadBytes(_trainingMissionCount);
Unknown2 = reader.ReadBytes(10);
Unknown3 = reader.ReadInt32s(7);
- Unknown4 = reader.ReadByte();
+ Unknown4 = reader.Read1Byte();
}
}
@@ -257,7 +257,7 @@ namespace Syroot.Worms.Gen2.Armageddon
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII, true))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
writer.Write(Name, 17);
writer.Write(WormNames, 17);
@@ -275,7 +275,7 @@ namespace Syroot.Worms.Gen2.Armageddon
writer.Write(Grave.Data);
}
- writer.Write(TeamWeapon, true);
+ writer.WriteEnum(TeamWeapon, true);
writer.Write(GamesLost);
writer.Write(DeathmatchesLost);
writer.Write(GamesWon);
diff --git a/src/Syroot.Worms/Gen2/Armageddon/TeamContainer.cs b/src/Syroot.Worms/Gen2/Armageddon/TeamContainer.cs
index 38d79d7..9a15a73 100644
--- a/src/Syroot.Worms/Gen2/Armageddon/TeamContainer.cs
+++ b/src/Syroot.Worms/Gen2/Armageddon/TeamContainer.cs
@@ -76,19 +76,19 @@ namespace Syroot.Worms.Gen2.Armageddon
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
- if (reader.ReadString(BinaryStringFormat.ZeroTerminated) != _signature)
+ if (reader.ReadString(StringCoding.ZeroTerminated) != _signature)
{
throw new InvalidDataException("Invalid WGT file signature.");
}
- Version = reader.ReadByte(); // Really version?
+ Version = reader.Read1Byte(); // Really version?
// Read global settings.
- byte teamCount = reader.ReadByte();
+ byte teamCount = reader.Read1Byte();
UnlockedFeatures = reader.ReadEnum(false);
- Unknown = reader.ReadByte();
+ Unknown = reader.Read1Byte();
// Read the teams.
Teams = new List(reader.Load(teamCount));
@@ -113,15 +113,15 @@ namespace Syroot.Worms.Gen2.Armageddon
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
// Write the header.
- writer.Write(_signature, BinaryStringFormat.ZeroTerminated);
+ writer.Write(_signature, StringCoding.ZeroTerminated);
writer.Write(Version);
// Write global settings.
writer.Write((byte)Teams.Count);
- writer.Write(UnlockedFeatures, false);
+ writer.WriteEnum(UnlockedFeatures, false);
writer.Write(Unknown);
// Write the teams.
diff --git a/src/Syroot.Worms/Gen2/ImageData.cs b/src/Syroot.Worms/Gen2/ImageData.cs
index a6189d7..514e36f 100644
--- a/src/Syroot.Worms/Gen2/ImageData.cs
+++ b/src/Syroot.Worms/Gen2/ImageData.cs
@@ -133,7 +133,7 @@ namespace Syroot.Worms.Gen2
/// true to align the data array by 4 bytes.
internal void Load(Stream stream, bool alignData)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
if (reader.ReadInt32() != _signature)
@@ -143,16 +143,16 @@ namespace Syroot.Worms.Gen2
int fileSize = reader.ReadInt32();
// Read an optional string describing the image contents and the bits per pixel.
- BitsPerPixel = reader.ReadByte();
+ BitsPerPixel = reader.Read1Byte();
if (BitsPerPixel == 0)
{
Description = String.Empty;
- BitsPerPixel = reader.ReadByte();
+ BitsPerPixel = reader.Read1Byte();
}
else if (BitsPerPixel > 32)
{
- Description = (char)BitsPerPixel + reader.ReadString(BinaryStringFormat.ZeroTerminated);
- BitsPerPixel = reader.ReadByte();
+ Description = (char)BitsPerPixel + reader.ReadString(StringCoding.ZeroTerminated);
+ BitsPerPixel = reader.Read1Byte();
}
else
{
@@ -170,7 +170,7 @@ namespace Syroot.Worms.Gen2
Palette[0] = Color.Black;
for (int i = 1; i <= colorCount; i++)
{
- Palette[i] = new Color(reader.ReadByte(), reader.ReadByte(), reader.ReadByte());
+ Palette[i] = new Color(reader.Read1Byte(), reader.Read1Byte(), reader.Read1Byte());
}
}
else
@@ -222,16 +222,16 @@ namespace Syroot.Worms.Gen2
/// true to align the data array by 4 bytes.
internal void Save(Stream stream, bool compress, bool alignData)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
// Write the header.
writer.Write(_signature);
- Offset fileSizeOffset = writer.ReserveOffset();
+ uint fileSizeOffset = writer.ReserveOffset();
// Write an optional string describing the image contents and the bits per pixel.
if (Description != null)
{
- writer.Write(Description, BinaryStringFormat.ZeroTerminated);
+ writer.Write(Description, StringCoding.ZeroTerminated);
}
writer.Write(BitsPerPixel);
@@ -245,7 +245,7 @@ namespace Syroot.Worms.Gen2
{
flags |= Flags.Compressed;
}
- writer.Write(flags, true);
+ writer.WriteEnum(flags, true);
// Write the image palette if available. The first color of the palette is implicitly black.
if (Palette != null)
@@ -276,7 +276,7 @@ namespace Syroot.Worms.Gen2
}
writer.Write(data);
- fileSizeOffset.Satisfy();
+ writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
}
}
diff --git a/src/Syroot.Worms/Gen2/Palette.cs b/src/Syroot.Worms/Gen2/Palette.cs
index 307cb42..7555b2a 100644
--- a/src/Syroot.Worms/Gen2/Palette.cs
+++ b/src/Syroot.Worms/Gen2/Palette.cs
@@ -119,7 +119,7 @@ namespace Syroot.Worms.Gen2
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
[RiffChunkLoad("data")]
- private void LoadDataChunk(BinaryDataReader reader, int length)
+ private void LoadDataChunk(BinaryStream reader, int length)
{
// Read the PAL version.
Version = reader.ReadInt16();
@@ -132,31 +132,31 @@ namespace Syroot.Worms.Gen2
Colors = new Color[reader.ReadInt16()];
for (int i = 0; i < Colors.Length; i++)
{
- Colors[i] = new Color(reader.ReadByte(), reader.ReadByte(), reader.ReadByte());
+ Colors[i] = new Color(reader.Read1Byte(), reader.Read1Byte(), reader.Read1Byte());
int alpha = reader.ReadByte(); // Dismiss alpha, as it is not used in WA.
}
}
[RiffChunkLoad("offl")]
- private void LoadOfflChunk(BinaryDataReader reader, int length)
+ private void LoadOfflChunk(BinaryStream reader, int length)
{
OfflData = reader.ReadBytes(length);
}
[RiffChunkLoad("tran")]
- private void LoadTranChunk(BinaryDataReader reader, int length)
+ private void LoadTranChunk(BinaryStream reader, int length)
{
TranData = reader.ReadBytes(length);
}
[RiffChunkLoad("unde")]
- private void LoadUndeChunk(BinaryDataReader reader, int length)
+ private void LoadUndeChunk(BinaryStream reader, int length)
{
UndeData = reader.ReadBytes(length);
}
[RiffChunkSave("data")]
- private void SaveDataChunk(BinaryDataWriter writer)
+ private void SaveDataChunk(BinaryStream writer)
{
// Write the PAL version.
writer.Write(_version);
@@ -174,19 +174,19 @@ namespace Syroot.Worms.Gen2
}
[RiffChunkSave("offl")]
- private void SaveOfflChunk(BinaryDataWriter writer)
+ private void SaveOfflChunk(BinaryStream writer)
{
writer.Write(OfflData);
}
[RiffChunkSave("tran")]
- private void SaveTranChunk(BinaryDataWriter writer)
+ private void SaveTranChunk(BinaryStream writer)
{
writer.Write(TranData);
}
[RiffChunkSave("unde")]
- private void SaveUndeChunk(BinaryDataWriter writer)
+ private void SaveUndeChunk(BinaryStream writer)
{
writer.Write(UndeData);
}
diff --git a/src/Syroot.Worms/Gen2/WorldParty/LandData.cs b/src/Syroot.Worms/Gen2/WorldParty/LandData.cs
index 5f70476..683dec1 100644
--- a/src/Syroot.Worms/Gen2/WorldParty/LandData.cs
+++ b/src/Syroot.Worms/Gen2/WorldParty/LandData.cs
@@ -1,4 +1,3 @@
-using System;
using System.IO;
using System.Text;
using Syroot.BinaryData;
@@ -100,7 +99,7 @@ namespace Syroot.Worms.Gen2.WorldParty
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
if (reader.ReadInt32() != _signature)
@@ -111,7 +110,7 @@ namespace Syroot.Worms.Gen2.WorldParty
// Read the data.
Size = reader.ReadStruct();
- TopBorder = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ TopBorder = reader.ReadBoolean(BooleanCoding.Dword);
WaterHeight = reader.ReadInt32();
// Read the possible object coordinate array.
@@ -123,8 +122,8 @@ namespace Syroot.Worms.Gen2.WorldParty
Background = new ImageData(stream, true);
// Read the file paths.
- LandTexturePath = reader.ReadString(BinaryStringFormat.ByteLengthPrefix);
- WaterDirPath = reader.ReadString(BinaryStringFormat.ByteLengthPrefix);
+ LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);
+ WaterDirPath = reader.ReadString(StringCoding.ByteCharCount);
}
}
@@ -146,15 +145,15 @@ namespace Syroot.Worms.Gen2.WorldParty
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
// Write the header.
writer.Write(_signature);
- Offset fileSizeOffset = writer.ReserveOffset();
+ uint fileSizeOffset = writer.ReserveOffset();
// Write the data.
writer.Write(Size);
- writer.Write(TopBorder, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(TopBorder, BooleanCoding.Dword);
writer.Write(WaterHeight);
// Write the possible object coordinate array.
@@ -167,10 +166,10 @@ namespace Syroot.Worms.Gen2.WorldParty
Background.Save(writer.BaseStream, false, true);
// Write the file paths.
- writer.Write(LandTexturePath, BinaryStringFormat.ByteLengthPrefix);
- writer.Write(WaterDirPath, BinaryStringFormat.ByteLengthPrefix);
+ writer.Write(LandTexturePath, StringCoding.ByteCharCount);
+ writer.Write(WaterDirPath, StringCoding.ByteCharCount);
- fileSizeOffset.Satisfy();
+ writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
}
}
diff --git a/src/Syroot.Worms/Gen2/WorldParty/Team.cs b/src/Syroot.Worms/Gen2/WorldParty/Team.cs
index 2187561..9654138 100644
--- a/src/Syroot.Worms/Gen2/WorldParty/Team.cs
+++ b/src/Syroot.Worms/Gen2/WorldParty/Team.cs
@@ -195,15 +195,15 @@ namespace Syroot.Worms.Gen2.WorldParty
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
Name = reader.ReadFixedString(17);
WormNames = reader.ReadFixedStrings(8, 17);
- CpuLevel = reader.ReadByte();
+ CpuLevel = reader.Read1Byte();
SoundBankName = reader.ReadFixedString(0x20);
- SoundBankLocation = reader.ReadByte();
+ SoundBankLocation = reader.Read1Byte();
FanfareName = reader.ReadFixedString(0x20);
- UseCustomFanfare = reader.ReadByte();
+ UseCustomFanfare = reader.Read1Byte();
GraveSprite = reader.ReadSByte();
if (GraveSprite < 0)
@@ -240,11 +240,11 @@ namespace Syroot.Worms.Gen2.WorldParty
Data = reader.ReadBytes(20 * 17)
};
- Unknown1 = reader.ReadByte();
- DeathmatchRank = reader.ReadByte();
+ Unknown1 = reader.Read1Byte();
+ DeathmatchRank = reader.Read1Byte();
TrainingMissionTimes = reader.ReadInt32s(_trainingMissionCount);
WeaponPoints = reader.ReadBytes(46);
- Fort = reader.ReadByte();
+ Fort = reader.Read1Byte();
Unknown2 = reader.ReadInt32s(7);
}
}
@@ -255,7 +255,7 @@ namespace Syroot.Worms.Gen2.WorldParty
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII, true))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
writer.Write(Name, 17);
writer.Write(WormNames, 17);
@@ -273,7 +273,7 @@ namespace Syroot.Worms.Gen2.WorldParty
writer.Write(Grave.Data);
}
- writer.Write(TeamWeapon, true);
+ writer.WriteEnum(TeamWeapon, true);
writer.Write(GamesLost);
writer.Write(DeathmatchesLost);
writer.Write(GamesWon);
diff --git a/src/Syroot.Worms/Gen2/WorldParty/TeamContainer.cs b/src/Syroot.Worms/Gen2/WorldParty/TeamContainer.cs
index 9233062..de2efe8 100644
--- a/src/Syroot.Worms/Gen2/WorldParty/TeamContainer.cs
+++ b/src/Syroot.Worms/Gen2/WorldParty/TeamContainer.cs
@@ -1,4 +1,3 @@
-using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
@@ -81,19 +80,19 @@ namespace Syroot.Worms.Gen2.WorldParty
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
- if (reader.ReadString(BinaryStringFormat.ZeroTerminated) != _signature)
+ if (reader.ReadString(StringCoding.ZeroTerminated) != _signature)
{
throw new InvalidDataException("Invalid WWP file signature.");
}
- Version = reader.ReadByte(); // Really version?
+ Version = reader.Read1Byte(); // Really version?
// Read global settings.
- byte teamCount = reader.ReadByte();
- Unknown1 = reader.ReadByte();
- Unknown2 = reader.ReadByte();
+ byte teamCount = reader.Read1Byte();
+ Unknown1 = reader.Read1Byte();
+ Unknown2 = reader.Read1Byte();
Unknown3 = reader.ReadBytes(840);
// Read the teams.
@@ -119,10 +118,10 @@ namespace Syroot.Worms.Gen2.WorldParty
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
// Write the header.
- writer.Write(_signature, BinaryStringFormat.ZeroTerminated);
+ writer.Write(_signature, StringCoding.ZeroTerminated);
writer.Write(Version);
// Write global settings.
diff --git a/src/Syroot.Worms/Gen2/Worms2/LandData.cs b/src/Syroot.Worms/Gen2/Worms2/LandData.cs
index 23deb3f..175f99d 100644
--- a/src/Syroot.Worms/Gen2/Worms2/LandData.cs
+++ b/src/Syroot.Worms/Gen2/Worms2/LandData.cs
@@ -104,7 +104,7 @@ namespace Syroot.Worms.Gen2.Worms2
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
if (reader.ReadInt32() != _signature)
@@ -115,7 +115,7 @@ namespace Syroot.Worms.Gen2.Worms2
// Read the data.
Size = reader.ReadStruct();
- TopBorder = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ TopBorder = reader.ReadBoolean(BooleanCoding.Dword);
// Read the possible object coordinate array.
ObjectLocations = reader.ReadStructs(reader.ReadInt32());
@@ -128,8 +128,8 @@ namespace Syroot.Worms.Gen2.Worms2
UnknownImage = reader.Load();
// Read the file paths.
- LandTexturePath = reader.ReadString(BinaryStringFormat.ByteLengthPrefix);
- WaterDirPath = reader.ReadString(BinaryStringFormat.ByteLengthPrefix);
+ LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);
+ WaterDirPath = reader.ReadString(StringCoding.ByteCharCount);
}
}
@@ -151,15 +151,15 @@ namespace Syroot.Worms.Gen2.Worms2
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
// Write the header.
writer.Write(_signature);
- Offset fileSizeOffset = writer.ReserveOffset();
+ uint fileSizeOffset = writer.ReserveOffset();
// Write the data.
writer.Write(Size);
- writer.Write(TopBorder, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(TopBorder, BooleanCoding.Dword);
// Write the possible object coordinate array.
writer.Write(ObjectLocations.Length);
@@ -173,10 +173,10 @@ namespace Syroot.Worms.Gen2.Worms2
UnknownImage.Save(writer.BaseStream);
// Write the file paths.
- writer.Write(LandTexturePath, BinaryStringFormat.ByteLengthPrefix);
- writer.Write(WaterDirPath, BinaryStringFormat.ByteLengthPrefix);
+ writer.Write(LandTexturePath, StringCoding.ByteCharCount);
+ writer.Write(WaterDirPath, StringCoding.ByteCharCount);
- fileSizeOffset.Satisfy();
+ writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
}
}
diff --git a/src/Syroot.Worms/Gen2/Worms2/SchemeOptions.cs b/src/Syroot.Worms/Gen2/Worms2/SchemeOptions.cs
index d56fe03..a438d06 100644
--- a/src/Syroot.Worms/Gen2/Worms2/SchemeOptions.cs
+++ b/src/Syroot.Worms/Gen2/Worms2/SchemeOptions.cs
@@ -221,7 +221,7 @@ namespace Syroot.Worms.Gen2.Worms2
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
if (reader.ReadString(_signature.Length) != _signature)
@@ -236,35 +236,35 @@ namespace Syroot.Worms.Gen2.Worms2
RetreatTimeRope = reader.ReadInt32();
ObjectCount = reader.ReadInt32();
MineDelay = reader.ReadInt32();
- DudMines = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ DudMines = reader.ReadBoolean(BooleanCoding.Dword);
WindPower = reader.ReadInt32();
Friction = reader.ReadInt32();
ReplayRequiredKills = reader.ReadInt32();
ReplayRequiredDamage = reader.ReadInt32();
- AutomaticReplays = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ AutomaticReplays = reader.ReadBoolean(BooleanCoding.Dword);
FallDamage = reader.ReadInt32();
RopeSwings = reader.ReadInt32();
- ShowRoundTime = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ ShowRoundTime = reader.ReadBoolean(BooleanCoding.Dword);
WaterRiseRate = reader.ReadInt32();
- SuddenDeathHealthDrop = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
- IndestructibleBorder = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
- RestrictGirders = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ SuddenDeathHealthDrop = reader.ReadBoolean(BooleanCoding.Dword);
+ IndestructibleBorder = reader.ReadBoolean(BooleanCoding.Dword);
+ RestrictGirders = reader.ReadBoolean(BooleanCoding.Dword);
WormSelectMode = reader.ReadEnum(true);
- ExtendedChatControls = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ ExtendedChatControls = reader.ReadBoolean(BooleanCoding.Dword);
HotSeatDelay = reader.ReadInt32();
- EnableStockpiling = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ EnableStockpiling = reader.ReadBoolean(BooleanCoding.Dword);
CrateProbability = reader.ReadInt32();
CrateIntelligence = reader.ReadInt32();
HealthCrateEnergy = reader.ReadInt32();
- BoobyTraps = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
- EnableSuperWeapons = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ BoobyTraps = reader.ReadBoolean(BooleanCoding.Dword);
+ EnableSuperWeapons = reader.ReadBoolean(BooleanCoding.Dword);
WormEnergy = reader.ReadInt32();
- ArtilleryMode = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
- SuddenDeathDisableWormSelect = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ ArtilleryMode = reader.ReadBoolean(BooleanCoding.Dword);
+ SuddenDeathDisableWormSelect = reader.ReadBoolean(BooleanCoding.Dword);
// The following option does not exist in all schemes.
if (!reader.EndOfStream)
{
- UseOilDrums = reader.ReadBoolean(BinaryBooleanFormat.NonZeroDword);
+ UseOilDrums = reader.ReadBoolean(BooleanCoding.Dword);
}
}
}
@@ -287,10 +287,10 @@ namespace Syroot.Worms.Gen2.Worms2
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
// Write the header.
- writer.Write(_signature, BinaryStringFormat.NoPrefixOrTermination);
+ writer.Write(_signature, StringCoding.Raw);
// Write the options.
writer.Write(RoundTime);
@@ -299,32 +299,32 @@ namespace Syroot.Worms.Gen2.Worms2
writer.Write(RetreatTimeRope);
writer.Write(ObjectCount);
writer.Write(MineDelay);
- writer.Write(DudMines, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(DudMines, BooleanCoding.Dword);
writer.Write(WindPower);
writer.Write(Friction);
writer.Write(ReplayRequiredKills);
writer.Write(ReplayRequiredDamage);
- writer.Write(AutomaticReplays, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(AutomaticReplays, BooleanCoding.Dword);
writer.Write(FallDamage);
writer.Write(RopeSwings);
- writer.Write(ShowRoundTime, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(ShowRoundTime, BooleanCoding.Dword);
writer.Write(WaterRiseRate);
- writer.Write(SuddenDeathHealthDrop, BinaryBooleanFormat.NonZeroDword);
- writer.Write(IndestructibleBorder, BinaryBooleanFormat.NonZeroDword);
- writer.Write(RestrictGirders, BinaryBooleanFormat.NonZeroDword);
- writer.Write(WormSelectMode, true);
- writer.Write(ExtendedChatControls, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(SuddenDeathHealthDrop, BooleanCoding.Dword);
+ writer.Write(IndestructibleBorder, BooleanCoding.Dword);
+ writer.Write(RestrictGirders, BooleanCoding.Dword);
+ writer.WriteEnum(WormSelectMode, true);
+ writer.Write(ExtendedChatControls, BooleanCoding.Dword);
writer.Write(HotSeatDelay);
- writer.Write(EnableStockpiling, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(EnableStockpiling, BooleanCoding.Dword);
writer.Write(CrateProbability);
writer.Write(CrateIntelligence);
writer.Write(HealthCrateEnergy);
- writer.Write(BoobyTraps, BinaryBooleanFormat.NonZeroDword);
- writer.Write(EnableSuperWeapons, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(BoobyTraps, BooleanCoding.Dword);
+ writer.Write(EnableSuperWeapons, BooleanCoding.Dword);
writer.Write(WormEnergy);
- writer.Write(ArtilleryMode, BinaryBooleanFormat.NonZeroDword);
- writer.Write(SuddenDeathDisableWormSelect, BinaryBooleanFormat.NonZeroDword);
- writer.Write(UseOilDrums, BinaryBooleanFormat.NonZeroDword);
+ writer.Write(ArtilleryMode, BooleanCoding.Dword);
+ writer.Write(SuddenDeathDisableWormSelect, BooleanCoding.Dword);
+ writer.Write(UseOilDrums, BooleanCoding.Dword);
}
}
diff --git a/src/Syroot.Worms/Gen2/Worms2/SchemeWeapons.cs b/src/Syroot.Worms/Gen2/Worms2/SchemeWeapons.cs
index 34fd79d..8b3a7a2 100644
--- a/src/Syroot.Worms/Gen2/Worms2/SchemeWeapons.cs
+++ b/src/Syroot.Worms/Gen2/Worms2/SchemeWeapons.cs
@@ -62,11 +62,11 @@ namespace Syroot.Worms.Gen2.Worms2
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
// Read the header.
reader.Seek(_trashLength);
- if (reader.ReadString(BinaryStringFormat.ZeroTerminated) != _signature)
+ if (reader.ReadString(StringCoding.ZeroTerminated) != _signature)
{
throw new InvalidDataException("Invalid WEP file signature.");
}
@@ -98,11 +98,11 @@ namespace Syroot.Worms.Gen2.Worms2
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
// Write the header.
writer.Write(new byte[_trashLength]);
- writer.Write(_signature, BinaryStringFormat.ZeroTerminated);
+ writer.Write(_signature, StringCoding.ZeroTerminated);
// Write the weapon settings.
foreach (SchemeWeaponSetting weapon in Weapons)
diff --git a/src/Syroot.Worms/Gen2/Worms2/Team.cs b/src/Syroot.Worms/Gen2/Worms2/Team.cs
index 7c3b94a..d376667 100644
--- a/src/Syroot.Worms/Gen2/Worms2/Team.cs
+++ b/src/Syroot.Worms/Gen2/Worms2/Team.cs
@@ -1,4 +1,3 @@
-using System;
using System.IO;
using System.Text;
using Syroot.BinaryData;
@@ -110,7 +109,7 @@ namespace Syroot.Worms.Gen2.Worms2
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
Unknown1 = reader.ReadInt16();
Name = reader.ReadFixedString(66);
@@ -162,7 +161,7 @@ namespace Syroot.Worms.Gen2.Worms2
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII, true))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
writer.Write(Unknown1);
writer.Write(Name, 66);
diff --git a/src/Syroot.Worms/Gen2/Worms2/TeamContainer.cs b/src/Syroot.Worms/Gen2/Worms2/TeamContainer.cs
index e184faa..1e371f8 100644
--- a/src/Syroot.Worms/Gen2/Worms2/TeamContainer.cs
+++ b/src/Syroot.Worms/Gen2/Worms2/TeamContainer.cs
@@ -56,7 +56,7 @@ namespace Syroot.Worms.Gen2.Worms2
/// The to load the data from.
public void Load(Stream stream)
{
- using (BinaryDataReader reader = new BinaryDataReader(stream, Encoding.ASCII, true))
+ using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
{
Teams = new List();
while (!reader.EndOfStream)
@@ -84,7 +84,7 @@ namespace Syroot.Worms.Gen2.Worms2
/// The to save the data to.
public void Save(Stream stream)
{
- using (BinaryDataWriter writer = new BinaryDataWriter(stream, Encoding.ASCII))
+ using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
{
foreach (Team team in Teams)
{
diff --git a/src/Syroot.Worms/Syroot.Worms.csproj b/src/Syroot.Worms/Syroot.Worms.csproj
index 606152a..4aa5124 100644
--- a/src/Syroot.Worms/Syroot.Worms.csproj
+++ b/src/Syroot.Worms/Syroot.Worms.csproj
@@ -1,41 +1,24 @@
-
-
- .NET library to load and modify file formats of Team17 Worms games.
- (c) Syroot, licensed under MIT
- Syroot.Worms
- Worms
- Syroot
- 1.0.0-alpha3
-
- Syroot.Worms
- worms;team17
- Initial release.
- https://raw.githubusercontent.com/Syroot/Worms/master/res/Logo.png
- https://github.com/Syroot/Worms
- https://raw.githubusercontent.com/Syroot/Worms/master/LICENSE
- git
- https://github.com/Syroot/Worms
-
- net46;netstandard1.6
-
-
-
-
-
-
-
-
-
-
-
-
- portable
-
-
-
- none
- true
-
-
+
+ Syroot.Worms
+ Worms
+ Syroot
+ (c) Syroot, licensed under MIT
+ .NET library to load and modify file formats of Team17 Worms games.
+ https://raw.githubusercontent.com/Syroot/Worms/master/res/Logo.png
+ Syroot.Worms
+ https://raw.githubusercontent.com/Syroot/Worms/master/LICENSE
+ https://github.com/Syroot/Worms
+ Initial release.
+ worms;team17
+ git
+ https://github.com/Syroot/Worms
+ net461;netstandard2
+ 1.0.0
+
+
+
+
+
+
\ No newline at end of file