Add KSF and other Online Worms specific features. Remove Gen2 namespace as other generations are no longer focused.

This commit is contained in:
Ray Koopa 2018-12-22 00:54:13 +01:00
parent 5541f66a78
commit a1de6d8c89
94 changed files with 741 additions and 227 deletions

View File

@ -1,24 +1,13 @@
# Worms # Worms
The goal of this .NET library is to provide managed language access to game specific file formats of the Worms game series by Team17. This .NET library can access and modify file formats of the following second generation Worms games developed by Team17:
The library is available as a [NuGet package](https://www.nuget.org/packages/Syroot.Worms). * W2: Worms2
* WA: Worms Armageddon
* WWP: Worms World Party
* OW: Online Worms (Asia licensed client)
* PX: ProjectX (Worms Armageddon extension)
Right now, the following file formats are supported: It currently targets the following formats:
## First Generation (2D)
Support for first generation 2D games is planned at a later stage.
| Description | Extension | Games | Load | Save |
|----------------|:---------:|:-------:|:----:|:----:|
| Color Map | WRM | W1 | No | No |
| DIY Terrain | DIY | DC | No | No |
| Monochrome Map | GFT | DC | No | No |
| Mountain Set | MNT | DC | No | No |
| Option Scheme | OPT | DC | No | No |
| Team Container | - | DC | No | No |
## Second Generation (2D)
Formats of the second generation 2D games are mostly focused right now.
| Description | Extension | Games | Load | Save | | Description | Extension | Games | Load | Save |
|-------------------|:---------:|:-----------:|:----:|:----:| |-------------------|:---------:|:-----------:|:----:|:----:|
@ -28,6 +17,7 @@ Formats of the second generation 2D games are mostly focused right now.
| Mission | DAT | W2 | No | No | | Mission | DAT | W2 | No | No |
| Mission | WAM | WA, WWP | No | No | | Mission | WAM | WA, WWP | No | No |
| Generated Map | LEV | WA, WWP | Yes | Yes | | Generated Map | LEV | WA, WWP | Yes | Yes |
| Image Container | KSF | OW | Yes | No |
| Monochrome Map | LEV | W2 | No | No | | Monochrome Map | LEV | W2 | No | No |
| Monochrome Map | BIT | WA, WWP | No | No | | Monochrome Map | BIT | WA, WWP | No | No |
| Palette | PAL | W2, WA, WWP | Yes | Yes | | Palette | PAL | W2, WA, WWP | Yes | Yes |
@ -41,9 +31,11 @@ Formats of the second generation 2D games are mostly focused right now.
| Team Container | WGT | WA | Yes | Yes | | Team Container | WGT | WA | Yes | Yes |
| Team Container | WWP | WWP | Yes | Yes | | Team Container | WWP | WWP | Yes | Yes |
## Third Generation (3D) It also provides the following executable tools:
Third generation file formats used by the 3D games have not yet been looked into.
* Online Worms Launcher: Creates a fake launch configuration to start the game with.
## Support ## Support
The library is available as a [NuGet package](https://www.nuget.org/packages/Syroot.Worms).
You can ask questions and suggest features on Discord aswell. Feel free to [join the Worms channel on the Syroot server](https://discord.gg/r6dz7yh)! You can ask questions and suggest features on Discord aswell. Feel free to [join the Worms channel on the Syroot server](https://discord.gg/r6dz7yh)!

29
src/010_editor/KSF.bt Normal file
View File

@ -0,0 +1,29 @@
//------------------------------------------------
//--- 010 Editor v9.0.1 Binary Template
//
// File: KSF.bt
// Authors: Syroot
// Version: 0.1.0
// Purpose: Parse Online Worms KSF bitmap files.
// Category: Online Worms
// File Mask: *.ksf
// ID Bytes:
// History:
// 0.1.0 2018-12-21 Initial version.
//------------------------------------------------
typedef struct
{
uint offset;
uint halfWidth;
uint halfHeight;
ushort width;
ushort height;
} Image;
LittleEndian();
int numImages;
int lenData;
Image images[numImages];
ubyte data[lenData];

View File

@ -0,0 +1,39 @@
using System;
using System.Diagnostics;
using System.IO;
using System.Net;
namespace Syroot.Worms.OnlineWorms.Launcher
{
internal class Program
{
// ---- CONSTANTS ----------------------------------------------------------------------------------------------
private const string _executableName = "DWait.exe";
private const string _configMapName = "KG1234567890"; // must start with "KG" and have 12 characters.
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
private static void Main(string[] args)
{
try
{
if (!File.Exists(_executableName))
throw new FileNotFoundException($"Could not find game executable \"{Path.GetFullPath(_executableName)}\".");
using (new LaunchConfig
{
ServerEndPoint = new IPEndPoint(IPAddress.Loopback, 17022),
UserName = "Steps"
}.CreateMappedFile(_configMapName))
{
Process.Start(_executableName, _configMapName);
}
}
catch (Exception ex)
{
Console.WriteLine(ex.Message);
}
}
}
}

View File

@ -0,0 +1,8 @@
{
"profiles": {
"Syroot.OnlineWorms.Launcher": {
"commandName": "Project",
"workingDirectory": "C:\\Games\\Online Worms"
}
}
}

View File

@ -0,0 +1,9 @@
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFrameworks>net461;netcoreapp2.1</TargetFrameworks>
</PropertyGroup>
<ItemGroup>
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />
</ItemGroup>
</Project>

View File

@ -1,4 +1,7 @@
using Syroot.Worms.Gen2.Armageddon.ProjectX; using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using Syroot.Worms.OnlineWorms;
namespace Syroot.Worms.Scratchpad namespace Syroot.Worms.Scratchpad
{ {
@ -8,8 +11,47 @@ namespace Syroot.Worms.Scratchpad
private static void Main(string[] args) private static void Main(string[] args)
{ {
Library library = new Library(@"D:\Pictures\loadme.pxl"); ConvertKsfImages();
library.Save(@"D:\Pictures\saved.pxl"); }
private static void ConvertKsfImages()
{
string ksfFolder = @"C:\Games\Online Worms\Ksf";
string palFolder = @"C:\Games\Online Worms\Palette";
string pngFolder = @"D:\Pictures\KSF";
Directory.CreateDirectory(pngFolder);
Palette fallbackPalette = new Palette(Path.Combine(palFolder, "StaticImage.pal"));
foreach (string ksfFilePath in Directory.GetFiles(ksfFolder, "*.ksf"))
{
// Try to find a palette for every KSF, otherwise use fallback palette.
string ksfFileName = Path.GetFileName(ksfFilePath);
string palFilePath = Path.Combine(palFolder, Path.ChangeExtension(ksfFileName, "pal"));
Palette palette = File.Exists(palFilePath) ? new Palette(palFilePath) : fallbackPalette;
// Load the KSF and let it convert the images.
Ksf ksf = new Ksf(ksfFilePath, palette);
// Save the images in the output folder.
string pngKsfFolder = Path.Combine(pngFolder, ksfFileName);
Directory.CreateDirectory(pngKsfFolder);
for (int i = 0; i < ksf.Images.Count; i++)
{
string pngFileName = Path.ChangeExtension((i + 1).ToString(), "png");
Image image = ksf.Images[i];
if (image != null)
image.Save(Path.Combine(pngKsfFolder, pngFileName), ImageFormat.Png);
}
}
}
private static void WriteMemoryManagerBlocks()
{
// Memory manager block allocation simulation.
byte[] buffer = new byte[0x600000];
for (int idx = 0; idx < buffer.Length; idx += 2)
buffer[idx] = (byte)((0x41 * idx - 0x78) | 0x55);
File.WriteAllBytes(@"D:\Pictures\memory.bin", buffer);
} }
} }
} }

View File

@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<OutputType>Exe</OutputType> <OutputType>Exe</OutputType>
<TargetFramework>netcoreapp2</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" /> <ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2; using Syroot.Worms;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2 namespace Syroot.Worms.Test.Gen2

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Armageddon; using Syroot.Worms.Armageddon;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2.Armageddon namespace Syroot.Worms.Test.Gen2.Armageddon

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Armageddon; using Syroot.Worms.Armageddon;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2.Armageddon namespace Syroot.Worms.Test.Gen2.Armageddon

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Armageddon.ProjectX; using Syroot.Worms.Armageddon.ProjectX;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Test.Gen2.Armageddon.ProjectX

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Armageddon.ProjectX; using Syroot.Worms.Armageddon.ProjectX;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Test.Gen2.Armageddon.ProjectX

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Armageddon; using Syroot.Worms.Armageddon;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2.Armageddon namespace Syroot.Worms.Test.Gen2.Armageddon

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Armageddon; using Syroot.Worms.Armageddon;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2.Armageddon namespace Syroot.Worms.Test.Gen2.Armageddon

View File

@ -1,11 +1,11 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2; using Syroot.Worms;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2 namespace Syroot.Worms.Test.Gen2
{ {
/// <summary> /// <summary>
/// Represents a collection of tests for the <see cref="ImageData"/> class. /// Represents a collection of tests for the <see cref="Img"/> class.
/// </summary> /// </summary>
[TestCategory("Gen2")] [TestCategory("Gen2")]
[TestClass] [TestClass]
@ -19,7 +19,7 @@ namespace Syroot.Worms.Test.Gen2
[TestMethod] [TestMethod]
public void LoadImages() public void LoadImages()
{ {
TestHelpers.LoadFiles<ImageData>(Game.All, "*.img"); TestHelpers.LoadFiles<Img>(Game.All, "*.img");
} }
} }
} }

View File

@ -1,11 +1,11 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2; using Syroot.Worms;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2 namespace Syroot.Worms.Test.Gen2
{ {
/// <summary> /// <summary>
/// Represents a collection of tests for the <see cref="Palette"/> class. /// Represents a collection of tests for the <see cref="RiffPalette"/> class.
/// </summary> /// </summary>
[TestCategory("Gen2")] [TestCategory("Gen2")]
[TestClass] [TestClass]
@ -19,7 +19,7 @@ namespace Syroot.Worms.Test.Gen2
[TestMethod] [TestMethod]
public void LoadPalettes() public void LoadPalettes()
{ {
TestHelpers.LoadFiles<Palette>(Game.Gen2, "*.pal", new string[] TestHelpers.LoadFiles<RiffPalette>(Game.Gen2, "*.pal", new string[]
{ {
"wwp.pal", // Contains 4 bytes of trash after the data chunk. "wwp.pal", // Contains 4 bytes of trash after the data chunk.
"wwpmaped.pal" // Contains 4 bytes of trash after the data chunk. "wwpmaped.pal" // Contains 4 bytes of trash after the data chunk.

View File

@ -1,6 +1,6 @@
<Project Sdk="Microsoft.NET.Sdk"> <Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup> <PropertyGroup>
<TargetFramework>netcoreapp2</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.0.0" />

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.WorldParty; using Syroot.Worms.WorldParty;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2.WorldParty namespace Syroot.Worms.Test.Gen2.WorldParty

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.WorldParty; using Syroot.Worms.WorldParty;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2.WorldParty namespace Syroot.Worms.Test.Gen2.WorldParty

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Worms2; using Syroot.Worms.Worms2;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2.Worms2 namespace Syroot.Worms.Test.Gen2.Worms2

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Worms2; using Syroot.Worms.Worms2;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2.Worms2 namespace Syroot.Worms.Test.Gen2.Worms2

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Worms2; using Syroot.Worms.Worms2;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2.Worms2 namespace Syroot.Worms.Test.Gen2.Worms2

View File

@ -1,5 +1,5 @@
using Microsoft.VisualStudio.TestTools.UnitTesting; using Microsoft.VisualStudio.TestTools.UnitTesting;
using Syroot.Worms.Gen2.Worms2; using Syroot.Worms.Worms2;
using Syroot.Worms.Test.Common; using Syroot.Worms.Test.Common;
namespace Syroot.Worms.Test.Gen2.Worms2 namespace Syroot.Worms.Test.Gen2.Worms2

View File

@ -9,6 +9,8 @@ Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Syroot.Worms.Test", "Syroot
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Syroot.Worms.Scratchpad", "Syroot.Worms.Scratchpad\Syroot.Worms.Scratchpad.csproj", "{0D7F9DC3-7268-494E-BA1E-6C01525EB9AB}" Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Syroot.Worms.Scratchpad", "Syroot.Worms.Scratchpad\Syroot.Worms.Scratchpad.csproj", "{0D7F9DC3-7268-494E-BA1E-6C01525EB9AB}"
EndProject EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "Syroot.Worms.OnlineWorms.Launcher", "Syroot.Worms.OnlineWorms.Launcher\Syroot.Worms.OnlineWorms.Launcher.csproj", "{510EE83E-9C52-40FD-AC7E-C4981EBF4182}"
EndProject
Global Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU Debug|Any CPU = Debug|Any CPU
@ -27,6 +29,10 @@ Global
{0D7F9DC3-7268-494E-BA1E-6C01525EB9AB}.Debug|Any CPU.Build.0 = 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.ActiveCfg = Release|Any CPU
{0D7F9DC3-7268-494E-BA1E-6C01525EB9AB}.Release|Any CPU.Build.0 = Release|Any CPU {0D7F9DC3-7268-494E-BA1E-6C01525EB9AB}.Release|Any CPU.Build.0 = Release|Any CPU
{510EE83E-9C52-40FD-AC7E-C4981EBF4182}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{510EE83E-9C52-40FD-AC7E-C4981EBF4182}.Debug|Any CPU.Build.0 = Debug|Any CPU
{510EE83E-9C52-40FD-AC7E-C4981EBF4182}.Release|Any CPU.ActiveCfg = Release|Any CPU
{510EE83E-9C52-40FD-AC7E-C4981EBF4182}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection EndGlobalSection
GlobalSection(SolutionProperties) = preSolution GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE HideSolutionNode = FALSE

View File

@ -5,7 +5,7 @@ using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2 namespace Syroot.Worms
{ {
/// <summary> /// <summary>
/// Represents a directory of files stored in a DIR file, mostly used to store graphics files. Due to the nowadays /// Represents a directory of files stored in a DIR file, mostly used to store graphics files. Due to the nowadays

View File

@ -3,7 +3,7 @@ using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Armageddon namespace Syroot.Worms.Armageddon
{ {
/// <summary> /// <summary>
/// Represents <see cref="MapGeneratorSettings"/> stored in a LEV file. /// Represents <see cref="MapGeneratorSettings"/> stored in a LEV file.

View File

@ -4,7 +4,7 @@ using Syroot.BinaryData;
using Syroot.Maths; using Syroot.Maths;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Armageddon namespace Syroot.Worms.Armageddon
{ {
/// <summary> /// <summary>
/// Represents map configuration stored by the land generator in LAND.DAT files. /// Represents map configuration stored by the land generator in LAND.DAT files.
@ -74,17 +74,17 @@ namespace Syroot.Worms.Gen2.Armageddon
/// <summary> /// <summary>
/// Gets or sets the visual foreground image. /// Gets or sets the visual foreground image.
/// </summary> /// </summary>
public ImageData Foreground { get; set; } public Img Foreground { get; set; }
/// <summary> /// <summary>
/// Gets or sets the collision mask of the landscape. /// Gets or sets the collision mask of the landscape.
/// </summary> /// </summary>
public ImageData CollisionMask { get; set; } public Img CollisionMask { get; set; }
/// <summary> /// <summary>
/// Gets or sets the visual background image. /// Gets or sets the visual background image.
/// </summary> /// </summary>
public ImageData Background { get; set; } public Img Background { get; set; }
/// <summary> /// <summary>
/// Gets or sets the path to the land image file. /// Gets or sets the path to the land image file.
@ -123,9 +123,9 @@ namespace Syroot.Worms.Gen2.Armageddon
ObjectLocations = reader.ReadStructs<Vector2>(reader.ReadInt32()); ObjectLocations = reader.ReadStructs<Vector2>(reader.ReadInt32());
// Read the image data. // Read the image data.
Foreground = reader.Load<ImageData>(); Foreground = reader.Load<Img>();
CollisionMask = reader.Load<ImageData>(); CollisionMask = reader.Load<Img>();
Background = reader.Load<ImageData>(); Background = reader.Load<Img>();
// Read the file paths. // Read the file paths.
LandTexturePath = reader.ReadString(StringCoding.ByteCharCount); LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);

View File

@ -1,6 +1,6 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Syroot.Worms.Gen2.Armageddon namespace Syroot.Worms.Armageddon
{ {
/// <summary> /// <summary>
/// Represents the required configuration for the land generator to create a map. This structure appears in LEV /// Represents the required configuration for the land generator to create a map. This structure appears in LEV

View File

@ -2,7 +2,7 @@ using System;
using System.IO; using System.IO;
using Syroot.BinaryData; using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
internal class ActionConverter : IBinaryConverter internal class ActionConverter : IBinaryConverter
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class BounceAction : IAction public class BounceAction : IAction
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class DigAction : IAction public class DigAction : IAction
{ {

View File

@ -1,6 +1,6 @@
using Syroot.BinaryData; using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class HomeAction : IAction public class HomeAction : IAction
{ {

View File

@ -0,0 +1,6 @@
namespace Syroot.Worms.Armageddon.ProjectX
{
public interface IAction
{
}
}

View File

@ -1,6 +1,6 @@
using Syroot.BinaryData; using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class RoamAction : IAction public class RoamAction : IAction
{ {

View File

@ -1,7 +1,7 @@
using System; using System;
using Syroot.BinaryData; using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
[Flags] [Flags]
public enum CollisionFlags : int public enum CollisionFlags : int

View File

@ -7,7 +7,7 @@ using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
/// <summary> /// <summary>
/// Represents a library stored in a PXL file which contains reusable weapons, files and scripts. /// Represents a library stored in a PXL file which contains reusable weapons, files and scripts.

View File

@ -1,6 +1,6 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public struct Mine public struct Mine
{ {

View File

@ -4,7 +4,7 @@ using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
/// <summary> /// <summary>
/// Represents a scheme stored in a PXS file which contains game settings, weapon tables, required libraries and /// Represents a scheme stored in a PXS file which contains game settings, weapon tables, required libraries and

View File

@ -1,6 +1,6 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
/// <summary> /// <summary>
/// Represents global Project X scheme flags affecting general game behavior. /// Represents global Project X scheme flags affecting general game behavior.

View File

@ -1,6 +1,6 @@
using Syroot.BinaryData; using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public struct Sound public struct Sound
{ {

View File

@ -1,6 +1,6 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public struct Sprite public struct Sprite
{ {

View File

@ -1,6 +1,6 @@
using Syroot.BinaryData; using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class AirstrikeStyle : IStyle public class AirstrikeStyle : IStyle
{ {

View File

@ -2,7 +2,7 @@ using System;
using System.IO; using System.IO;
using Syroot.BinaryData; using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class AirstrikeSubstyleConverter : IBinaryConverter public class AirstrikeSubstyleConverter : IBinaryConverter
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class BaseballBatStyle : IStyle public class BaseballBatStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class BattleAxeStyle : IStyle public class BattleAxeStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class BlowtorchStyle : IStyle public class BlowtorchStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class BowStyle : IStyle public class BowStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class CanisterStyle : IStyle public class CanisterStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class DragonballStyle : IStyle public class DragonballStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class FirepunchStyle : IStyle public class FirepunchStyle : IStyle
{ {

View File

@ -1,6 +1,6 @@
using Syroot.BinaryData; using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class FlamethrowerStyle : IStyle public class FlamethrowerStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class GunStyle : IStyle public class GunStyle : IStyle
{ {

View File

@ -0,0 +1,6 @@
namespace Syroot.Worms.Armageddon.ProjectX
{
public interface IStyle
{
}
}

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class JetpackStyle : IStyle public class JetpackStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class KamikazeStyle : IStyle public class KamikazeStyle : IStyle
{ {

View File

@ -1,6 +1,6 @@
using Syroot.BinaryData; using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class LauncherStyle : IStyle public class LauncherStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class MineStyle : IStyle public class MineStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class NinjaRopeStyle : IStyle public class NinjaRopeStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class NuclearTestStyle : IStyle public class NuclearTestStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class ParachuteStyle : IStyle public class ParachuteStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class PneumaticDrillStyle : IStyle public class PneumaticDrillStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class ProdStyle : IStyle public class ProdStyle : IStyle
{ {

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class SuicideBomberStyle : IStyle public class SuicideBomberStyle : IStyle
{ {

View File

@ -1,6 +1,6 @@
using Syroot.BinaryData; using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class ClusterTarget : ITarget public class ClusterTarget : ITarget
{ {

View File

@ -1,6 +1,6 @@
using Syroot.BinaryData; using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
public class FireTarget : ITarget public class FireTarget : ITarget
{ {

View File

@ -0,0 +1,6 @@
namespace Syroot.Worms.Armageddon.ProjectX
{
public interface ITarget
{
}
}

View File

@ -2,7 +2,7 @@ using System;
using System.IO; using System.IO;
using Syroot.BinaryData; using Syroot.BinaryData;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
internal class TargetConverter : IBinaryConverter internal class TargetConverter : IBinaryConverter
{ {

View File

@ -4,7 +4,7 @@ using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
{ {
[DebuggerDisplay("Weapon Name={Name}")] [DebuggerDisplay("Weapon Name={Name}")]
public class Weapon : ILoadable, ISaveable public class Weapon : ILoadable, ISaveable

View File

@ -5,7 +5,7 @@ using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Armageddon namespace Syroot.Worms.Armageddon
{ {
/// <summary> /// <summary>
/// Represents a scheme stored in a WSC file which contains game settings and armory configuration, including /// Represents a scheme stored in a WSC file which contains game settings and armory configuration, including

View File

@ -1,6 +1,6 @@
using System; using System;
namespace Syroot.Worms.Gen2.Armageddon namespace Syroot.Worms.Armageddon
{ {
/// <summary> /// <summary>
/// Represents the known versions of scheme file formats. /// Represents the known versions of scheme file formats.

View File

@ -1,7 +1,7 @@
using System.Diagnostics; using System.Diagnostics;
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Syroot.Worms.Gen2.Armageddon namespace Syroot.Worms.Armageddon
{ {
/// <summary> /// <summary>
/// Represents the configuration of a weapon. /// Represents the configuration of a weapon.

View File

@ -5,7 +5,7 @@ using Syroot.BinaryData;
using Syroot.Maths; using Syroot.Maths;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Armageddon namespace Syroot.Worms.Armageddon
{ {
/// <summary> /// <summary>
/// Represents a team stored in a <see cref="TeamContainer"/> file. /// Represents a team stored in a <see cref="TeamContainer"/> file.
@ -67,7 +67,7 @@ namespace Syroot.Worms.Gen2.Armageddon
/// (<c>true</c>) or the player's countries' fanfare should be played (<c>false</c>). /// (<c>true</c>) or the player's countries' fanfare should be played (<c>false</c>).
/// </summary> /// </summary>
public byte UseCustomFanfare { get; set; } public byte UseCustomFanfare { get; set; }
/// <summary> /// <summary>
/// Gets or sets the sprite index of the team grave, -1 being a custom bitmap grave. /// Gets or sets the sprite index of the team grave, -1 being a custom bitmap grave.
/// </summary> /// </summary>
@ -107,7 +107,7 @@ namespace Syroot.Worms.Gen2.Armageddon
/// Gets or sets the number of deathmatch games won. /// Gets or sets the number of deathmatch games won.
/// </summary> /// </summary>
public int DeathmatchesWon { get; set; } public int DeathmatchesWon { get; set; }
/// <summary> /// <summary>
/// Gets or sets the number of games drawn. /// Gets or sets the number of games drawn.
/// </summary> /// </summary>

View File

@ -5,7 +5,7 @@ using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Armageddon namespace Syroot.Worms.Armageddon
{ {
/// <summary> /// <summary>
/// Represents the list of teams and unlocked game features stored in WGT files. /// Represents the list of teams and unlocked game features stored in WGT files.

View File

@ -0,0 +1,51 @@
using System;
using System.Runtime.InteropServices;
namespace Syroot.Worms.Core
{
/// <summary>
/// Represents a disposable <see cref="GCHandle"/>.
/// </summary>
internal class DisposableGCHandle : IDisposable
{
// ---- FIELDS -------------------------------------------------------------------------------------------------
private readonly GCHandle _handle;
private bool _disposed;
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
public DisposableGCHandle(object value, GCHandleType type)
{
_handle = GCHandle.Alloc(value, GCHandleType.Pinned);
}
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
public IntPtr AddrOfPinnedObject => _handle.AddrOfPinnedObject();
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
public void Dispose()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing).
Dispose(true);
}
// ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
if (_handle.IsAllocated)
_handle.Free();
}
_disposed = true;
}
}
}
}

View File

@ -1,6 +0,0 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX
{
public interface IAction
{
}
}

View File

@ -1,6 +0,0 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX
{
public interface IStyle
{
}
}

View File

@ -1,6 +0,0 @@
namespace Syroot.Worms.Gen2.Armageddon.ProjectX
{
public interface ITarget
{
}
}

View File

@ -5,13 +5,13 @@ using Syroot.BinaryData;
using Syroot.Maths; using Syroot.Maths;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2 namespace Syroot.Worms
{ {
/// <summary> /// <summary>
/// Represents a (palettized) graphical image stored in an IMG file, possibly compressed. /// Represents a (palettized) graphical image stored in an IMG file, possibly compressed.
/// Used by W2, WA and WWP. S. https://worms2d.info/Image_file. /// Used by W2, WA and WWP. S. https://worms2d.info/Image_file.
/// </summary> /// </summary>
public class ImageData : BitmapData, ILoadableFile, ISaveableFile public class Img : BitmapData, ILoadableFile, ISaveableFile
{ {
// ---- CONSTANTS ---------------------------------------------------------------------------------------------- // ---- CONSTANTS ----------------------------------------------------------------------------------------------
@ -20,41 +20,30 @@ namespace Syroot.Worms.Gen2
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------ // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ImageData"/> class. /// Initializes a new instance of the <see cref="Img"/> class.
/// </summary> /// </summary>
public ImageData() public Img() { }
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ImageData"/> class, loading the data from the given /// Initializes a new instance of the <see cref="Img"/> class, loading the data from the given
/// <see cref="Stream"/>. /// <see cref="Stream"/>.
/// </summary> /// </summary>
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param> /// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
public ImageData(Stream stream) public Img(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ImageData"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="Img"/> class, loading the data from the given file.
/// </summary> /// </summary>
/// <param name="fileName">The name of the file to load the data from.</param> /// <param name="fileName">The name of the file to load the data from.</param>
public ImageData(string fileName) public Img(string fileName) => Load(fileName);
{
Load(fileName);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="ImageData"/> class, loading the data from the given /// Initializes a new instance of the <see cref="Img"/> class, loading the data from the given
/// <see cref="Stream"/>. The data block can be aligned to a 4-bte boundary. /// <see cref="Stream"/>. The data block can be aligned to a 4-bte boundary.
/// </summary> /// </summary>
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param> /// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
/// <param name="alignData"><c>true</c> to align the data array by 4 bytes.</param> /// <param name="alignData"><c>true</c> to align the data array by 4 bytes.</param>
internal ImageData(Stream stream, bool alignData) internal Img(Stream stream, bool alignData) => Load(stream, alignData);
{
Load(stream, alignData);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -62,17 +51,14 @@ namespace Syroot.Worms.Gen2
/// Gets an optional description of the image contents. /// Gets an optional description of the image contents.
/// </summary> /// </summary>
public string Description { get; private set; } public string Description { get; private set; }
// ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
/// <summary> /// <summary>
/// Loads the data from the given <see cref="Stream"/>. /// Loads the data from the given <see cref="Stream"/>.
/// </summary> /// </summary>
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param> /// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
public void Load(Stream stream) public void Load(Stream stream) => Load(stream, false);
{
Load(stream, false);
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -81,48 +67,34 @@ namespace Syroot.Worms.Gen2
public void Load(string fileName) public void Load(string fileName)
{ {
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
{
Load(stream); Load(stream);
}
} }
/// <summary> /// <summary>
/// Saves the data into the given <paramref name="stream"/>. /// Saves the data into the given <paramref name="stream"/>.
/// </summary> /// </summary>
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param> /// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
public void Save(Stream stream) public void Save(Stream stream) => Save(stream, false, false);
{
Save(stream, false, false);
}
/// <summary> /// <summary>
/// Saves the optionally compressed data into the given <paramref name="stream"/>. /// Saves the optionally compressed data into the given <paramref name="stream"/>.
/// </summary> /// </summary>
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param> /// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
/// <param name="compress"><c>true</c> to compress image data.</param> /// <param name="compress"><c>true</c> to compress image data.</param>
public void Save(Stream stream, bool compress) public void Save(Stream stream, bool compress) => Save(stream, compress, false);
{
Save(stream, compress, false);
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
/// </summary> /// </summary>
/// <param name="fileName">The name of the file to save the data in.</param> /// <param name="fileName">The name of the file to save the data in.</param>
public void Save(string fileName) public void Save(string fileName) => Save(fileName, false, false);
{
Save(fileName, false, false);
}
/// <summary> /// <summary>
/// Saves the optionally compressed data in the given file. /// Saves the optionally compressed data in the given file.
/// </summary> /// </summary>
/// <param name="fileName">The name of the file to save the data in.</param> /// <param name="fileName">The name of the file to save the data in.</param>
/// <param name="compress"><c>true</c> to compress image data.</param> /// <param name="compress"><c>true</c> to compress image data.</param>
public void Save(string fileName, bool compress) public void Save(string fileName, bool compress) => Save(fileName, compress, false);
{
Save(fileName, compress, false);
}
// ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- // ---- METHODS (INTERNAL) -------------------------------------------------------------------------------------
@ -137,9 +109,7 @@ namespace Syroot.Worms.Gen2
{ {
// Read the header. // Read the header.
if (reader.ReadInt32() != _signature) if (reader.ReadInt32() != _signature)
{
throw new InvalidDataException("Invalid IMG file signature."); throw new InvalidDataException("Invalid IMG file signature.");
}
int fileSize = reader.ReadInt32(); int fileSize = reader.ReadInt32();
// Read an optional string describing the image contents and the bits per pixel. // Read an optional string describing the image contents and the bits per pixel.
@ -169,9 +139,7 @@ namespace Syroot.Worms.Gen2
Palette = new Color[colorCount + 1]; Palette = new Color[colorCount + 1];
Palette[0] = Color.Black; Palette[0] = Color.Black;
for (int i = 1; i <= colorCount; i++) for (int i = 1; i <= colorCount; i++)
{
Palette[i] = new Color(reader.Read1Byte(), reader.Read1Byte(), reader.Read1Byte()); Palette[i] = new Color(reader.Read1Byte(), reader.Read1Byte(), reader.Read1Byte());
}
} }
else else
{ {
@ -183,18 +151,12 @@ namespace Syroot.Worms.Gen2
// Read the data byte array, which might be compressed or aligned. // Read the data byte array, which might be compressed or aligned.
if (alignData) if (alignData)
{
reader.Align(4); reader.Align(4);
}
byte[] data = new byte[Size.X * Size.Y * BitsPerPixel / 8]; byte[] data = new byte[Size.X * Size.Y * BitsPerPixel / 8];
if (flags.HasFlag(Flags.Compressed)) if (flags.HasFlag(Flags.Compressed))
{
Team17Compression.Decompress(reader.BaseStream, data); Team17Compression.Decompress(reader.BaseStream, data);
}
else else
{
data = reader.ReadBytes(data.Length); data = reader.ReadBytes(data.Length);
}
Data = data; Data = data;
} }
@ -208,9 +170,7 @@ namespace Syroot.Worms.Gen2
internal void Load(string fileName, bool alignData) internal void Load(string fileName, bool alignData)
{ {
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read)) using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
{
Load(stream); Load(stream);
}
} }
/// <summary> /// <summary>
@ -230,21 +190,15 @@ namespace Syroot.Worms.Gen2
// Write an optional string describing the image contents and the bits per pixel. // Write an optional string describing the image contents and the bits per pixel.
if (Description != null) if (Description != null)
{
writer.Write(Description, StringCoding.ZeroTerminated); writer.Write(Description, StringCoding.ZeroTerminated);
}
writer.Write(BitsPerPixel); writer.Write(BitsPerPixel);
// Write image flags describing the format and availability of the following contents. // Write image flags describing the format and availability of the following contents.
Flags flags = Flags.None; Flags flags = Flags.None;
if (Palette != null) if (Palette != null)
{
flags |= Flags.Palettized; flags |= Flags.Palettized;
}
if (compress) if (compress)
{
flags |= Flags.Compressed; flags |= Flags.Compressed;
}
writer.WriteEnum(flags, true); writer.WriteEnum(flags, true);
// Write the image palette if available. The first color of the palette is implicitly black. // Write the image palette if available. The first color of the palette is implicitly black.
@ -266,14 +220,10 @@ namespace Syroot.Worms.Gen2
// Write the data byte array, which might be compressed or aligned. // Write the data byte array, which might be compressed or aligned.
if (alignData) if (alignData)
{
writer.Align(4); writer.Align(4);
}
byte[] data = Data; byte[] data = Data;
if (compress) if (compress)
{
data = Team17Compression.Compress(data); data = Team17Compression.Compress(data);
}
writer.Write(data); writer.Write(data);
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position); writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
@ -289,11 +239,9 @@ namespace Syroot.Worms.Gen2
internal void Save(string fileName, bool compress, bool alignData) internal void Save(string fileName, bool compress, bool alignData)
{ {
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None)) using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
{
Save(stream, compress, alignData); Save(stream, compress, alignData);
}
} }
// ---- ENUMERATIONS ------------------------------------------------------------------------------------------- // ---- ENUMERATIONS -------------------------------------------------------------------------------------------
[Flags] [Flags]

View File

@ -0,0 +1,229 @@
using System;
using System.Collections;
using System.Collections.Generic;
using System.Drawing;
using System.Drawing.Imaging;
using System.IO;
using System.Runtime.InteropServices;
using Syroot.BinaryData;
using Syroot.Worms.Core;
namespace Syroot.Worms.OnlineWorms
{
/// <summary>
/// Represents a KSF image container.
/// </summary>
public class Ksf : IDisposable
{
// ---- FIELDS -------------------------------------------------------------------------------------------------
private bool _disposed;
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="Ksf"/> class, loading data from the file with the given
/// <paramref name="fileName"/> and the colors in the provided <paramref name="palette"/>.
/// </summary>
/// <param name="fileName">The name of the file to load the data from.</param>
/// <param name="palette">The color palette which is indexed by the image data.</param>
public Ksf(string fileName, Palette palette)
{
Load(fileName, palette);
}
/// <summary>
/// Initializes a new instance of the <see cref="Ksf"/> class, loading data from the given
/// <paramref name="stream"/> and the colors in the provided <paramref name="palette"/>.
/// </summary>
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
/// <param name="palette">The color palette which is indexed by the image data.</param>
public Ksf(Stream stream, Palette palette)
{
Load(stream, palette);
}
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the list of converted <see cref="Image"/> instances stored in this KSF.
/// </summary>
public KsfImageList Images { get; } = new KsfImageList();
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
/// <summary>
/// Loads the data from the file with the given <paramref name="fileName"/> and the colors in the provided
/// <paramref name="palette"/>.
/// </summary>
/// <param name="fileName">The name of the file to load the data from.</param>
/// <param name="palette">The color palette which is indexed by the image data.</param>
public void Load(string fileName, Palette palette)
{
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
Load(stream, palette);
}
/// <summary>
/// Loads the data from the given <paramref name="stream"/> and the colors in the provided
/// <paramref name="palette"/>.
/// </summary>
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
/// <param name="palette">The color palette which is indexed by the image data.</param>
public void Load(Stream stream, Palette palette)
{
int imageCount = stream.ReadInt32(); // Includes terminator.
int dataSize = stream.ReadInt32();
// Read image headers. Terminating image is of 0 size and data offset at end of data block.
ImageHeader[] headers = new ImageHeader[imageCount];
for (int i = 0; i < imageCount; i++)
{
headers[i] = new ImageHeader
{
Offset = stream.ReadInt32(),
HalfWidth = stream.ReadInt32(),
HalfHeight = stream.ReadInt32(),
Width = stream.ReadInt16(),
Height = stream.ReadInt16()
};
}
// Convert images.
long dataStart = stream.Position;
for (int i = 0; i < imageCount - 1; i++)
{
ImageHeader header = headers[i];
stream.Position = dataStart + header.Offset;
int imageDataLength = headers[i + 1].Offset - header.Offset;
Images.AddWithoutClone(ConvertImage(header, stream.ReadBytes(imageDataLength), palette));
}
}
/// <summary>
/// Releases all resources used by this instance.
/// </summary>
public void Dispose()
{
// Do not change this code. Put cleanup code in Dispose(bool disposing).
Dispose(true);
}
// ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------
/// <summary>
/// Releases all resources used by this instance.
/// </summary>
/// <param name="disposing"><see langword="true"/> to release managed resources.</param>
protected virtual void Dispose(bool disposing)
{
if (!_disposed)
{
if (disposing)
{
foreach (Image image in Images)
image.Dispose();
}
_disposed = true;
}
}
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
private Image ConvertImage(ImageHeader header, byte[] data, Palette palette)
{
if (header.Width == 0)
return null;
using (DisposableGCHandle dataPin = new DisposableGCHandle(data, GCHandleType.Pinned))
{
// Transfer the pixel data, respecting power-of-2 strides.
Bitmap bitmap = new Bitmap(header.Width, header.Height, PixelFormat.Format8bppIndexed);
System.Drawing.Imaging.BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, header.Width, header.Height),
ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
for (int y = 0; y < header.Height; y++)
Marshal.Copy(data, y * header.Width, bitmapData.Scan0 + y * bitmapData.Stride, header.Width);
bitmap.UnlockBits(bitmapData);
// Transfer the palette.
ColorPalette bitmapPalette = bitmap.Palette;
for (int i = 0; i < Palette.ColorCount; i++)
bitmapPalette.Entries[i] = palette.Colors[i];
bitmap.Palette = bitmapPalette;
return bitmap;
}
}
// ---- CLASSES, STRUCTS & ENUMS -------------------------------------------------------------------------------
[StructLayout(LayoutKind.Sequential)]
private struct ImageHeader
{
internal int Offset;
internal int HalfWidth;
internal int HalfHeight;
internal short Width;
internal short Height;
}
/// <summary>
/// Represents a list of <see cref="Image"/> instances which are cloned before being added to the list.
/// </summary>
public class KsfImageList : IList<Image>
{
private List<Image> _list;
internal KsfImageList()
{
_list = new List<Image>();
}
public int Count => _list.Count;
public bool IsReadOnly => false;
public Image this[int index]
{
get => _list[index];
set
{
_list[index].Dispose();
_list[index] = (Image)value?.Clone();
}
}
public void Add(Image item) => _list.Add((Image)item?.Clone());
internal void AddWithoutClone(Image item) => _list.Add(item);
public void Clear()
{
foreach (Image image in _list)
image.Dispose();
_list.Clear();
}
public bool Contains(Image item) => _list.Contains(item);
public void CopyTo(Image[] array, int arrayIndex) => _list.CopyTo(array, arrayIndex);
public IEnumerator<Image> GetEnumerator() => _list.GetEnumerator();
public int IndexOf(Image item) => _list.IndexOf(item);
public void Insert(int index, Image item) => _list.Insert(index, (Image)item?.Clone());
public bool Remove(Image item)
{
bool result = _list.Remove(item);
if (result)
item.Dispose();
return result;
}
public void RemoveAt(int index)
{
Image image = _list[index];
_list.RemoveAt(index);
image.Dispose();
}
IEnumerator IEnumerable.GetEnumerator() => _list.GetEnumerator();
}
}
}

View File

@ -0,0 +1,85 @@
using System;
using System.IO;
using System.IO.MemoryMappedFiles;
using System.Net;
using System.Text;
using Syroot.BinaryData;
namespace Syroot.Worms.OnlineWorms
{
/// <summary>
/// Represents the memory mapped file passed to the game executable, configuring the server address.
/// </summary>
public class LaunchConfig
{
// ---- FIELDS -------------------------------------------------------------------------------------------------
private static readonly Encoding _win949Encoding;
private static readonly char[] _invalidUserNameChars = { '=', '&', ' ' };
private string _userName;
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
static LaunchConfig()
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
_win949Encoding = Encoding.GetEncoding(949);
}
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the address of the game server.
/// </summary>
public IPEndPoint ServerEndPoint { get; set; }
/// <summary>
/// Gets or sets the initially entered user name.
/// </summary>
public string UserName
{
get => _userName;
set
{
// 251 bytes is the space between "UID=" and the server IP, minus a terminating 0.
if (_win949Encoding.GetBytes(value).Length > 251)
throw new ArgumentException("User name must not exceed 251 bytes.");
if (value.IndexOfAny(_invalidUserNameChars) != -1)
throw new ArgumentException("User name contains invalid characters.");
_userName = value;
}
}
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
/// <summary>
/// Creates a <see cref="MemoryMappedFile"/> which is then read by the game client.
/// </summary>
/// <param name="mapName">The name under which the game client can access the mapping.</param>
/// <returns>The <see cref="MemoryMappedFile"/>.</returns>
public MemoryMappedFile CreateMappedFile(string mapName)
{
MemoryMappedFile mappedFile = MemoryMappedFile.CreateNew(mapName, 1266,
MemoryMappedFileAccess.ReadWrite, MemoryMappedFileOptions.None, HandleInheritability.Inheritable);
using (BinaryStream stream = new BinaryStream(mappedFile.CreateViewStream(),
encoding: _win949Encoding, stringCoding: StringCoding.ZeroTerminated))
{
stream.Write("Online Worms Config File");
stream.Position = 36;
stream.Write(";Unknown;0");
stream.Position = 66;
stream.Write("UID=", StringCoding.Raw);
stream.Write(_win949Encoding.GetBytes(UserName));
stream.Position = 322;
stream.Write(ServerEndPoint.Address.ToString());
stream.Position = 352;
stream.Write(ServerEndPoint.Port.ToString());
}
return mappedFile;
}
}
}

View File

@ -0,0 +1,74 @@
using System.Drawing;
using System.IO;
using Syroot.BinaryData;
namespace Syroot.Worms.OnlineWorms
{
/// <summary>
/// Represents a PAL color palette.
/// </summary>
public class Palette
{
// ---- CONSTANTS ----------------------------------------------------------------------------------------------
/// <summary>
/// The number of colors stored in a palette.
/// </summary>
public const int ColorCount = 256;
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
/// <summary>
/// Initializes a new instance of the <see cref="Palette"/> class, loading data from the file with the given
/// <paramref name="fileName"/>.
/// </summary>
/// <param name="fileName">The name of the file to load the data from.</param>
public Palette(string fileName)
{
Load(fileName);
}
/// <summary>
/// Initializes a new instance of the <see cref="Palette"/> class, loading data from the given
/// <paramref name="stream"/>.
/// </summary>
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
public Palette(Stream stream)
{
Load(stream);
}
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
/// <summary>
/// Gets the array of 256 colors stored in this palette.
/// </summary>
public Color[] Colors { get; } = new Color[ColorCount];
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
/// <summary>
/// Loads the data from the file with the given <paramref name="fileName"/>.
/// </summary>
/// <param name="fileName">The name of the file to load the data from.</param>
public void Load(string fileName)
{
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
Load(stream);
}
/// <summary>
/// Loads the data from the given <paramref name="stream"/>.
/// </summary>
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
public void Load(Stream stream)
{
byte[] data = stream.ReadBytes(ColorCount * 3);
for (int i = 0; i < ColorCount; i++)
{
int offset = i * 3;
Colors[i] = Color.FromArgb(data[offset], data[offset + 1], data[offset + 2]);
}
}
}
}

View File

@ -3,14 +3,14 @@ using Syroot.BinaryData;
using Syroot.Maths; using Syroot.Maths;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2 namespace Syroot.Worms
{ {
/// <summary> /// <summary>
/// Represents a color palette stored in PAL files, following the RIFF format. It is used to index colors in images. /// Represents a color palette stored in PAL files, following the RIFF format. It is used to index colors in images.
/// Used by WA and WWP. S. http://worms2d.info/Palette_file. /// Used by WA and WWP. S. http://worms2d.info/Palette_file.
/// </summary> /// </summary>
[RiffFile("PAL ")] [RiffFile("PAL ")]
public class Palette : RiffFile, ILoadableFile, ISaveableFile public class RiffPalette : RiffFile, ILoadableFile, ISaveableFile
{ {
// ---- CONSTANTS ---------------------------------------------------------------------------------------------- // ---- CONSTANTS ----------------------------------------------------------------------------------------------
@ -19,28 +19,28 @@ namespace Syroot.Worms.Gen2
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------ // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Palette"/> class. /// Initializes a new instance of the <see cref="RiffPalette"/> class.
/// </summary> /// </summary>
public Palette() public RiffPalette()
{ {
Version = _version; Version = _version;
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Palette"/> class, loading the data from the given /// Initializes a new instance of the <see cref="RiffPalette"/> class, loading the data from the given
/// <see cref="Stream"/>. /// <see cref="Stream"/>.
/// </summary> /// </summary>
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param> /// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
public Palette(Stream stream) public RiffPalette(Stream stream)
{ {
Load(stream); Load(stream);
} }
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Palette"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="RiffPalette"/> class, loading the data from the given file.
/// </summary> /// </summary>
/// <param name="fileName">The name of the file to load the data from.</param> /// <param name="fileName">The name of the file to load the data from.</param>
public Palette(string fileName) public RiffPalette(string fileName)
{ {
Load(fileName); Load(fileName);
} }
@ -115,7 +115,7 @@ namespace Syroot.Worms.Gen2
Save(stream); Save(stream);
} }
} }
// ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- // ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
[RiffChunkLoad("data")] [RiffChunkLoad("data")]

View File

@ -14,12 +14,14 @@
<PackageTags>worms;team17</PackageTags> <PackageTags>worms;team17</PackageTags>
<RepositoryType>git</RepositoryType> <RepositoryType>git</RepositoryType>
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl> <RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
<TargetFrameworks>net461;netstandard2</TargetFrameworks> <TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
<Version>1.0.1</Version> <Version>2.0.0-alpha1</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Syroot.BinaryData.Serialization" Version="5.0.0" /> <PackageReference Include="Syroot.BinaryData.Serialization" Version="5.0.0" />
<PackageReference Include="Syroot.Maths" Version="1.5.1" /> <PackageReference Include="Syroot.Maths" Version="1.5.3" />
<PackageReference Include="Syroot.BinaryData" Version="5.0.0" /> <PackageReference Include="Syroot.BinaryData" Version="5.0.0" />
<PackageReference Include="System.Drawing.Common" Version="4.5.1" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -4,7 +4,7 @@ using Syroot.BinaryData;
using Syroot.Maths; using Syroot.Maths;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.WorldParty namespace Syroot.Worms.WorldParty
{ {
/// <summary> /// <summary>
/// Represents map configuration stored by the land generator in LAND.DAT files. /// Represents map configuration stored by the land generator in LAND.DAT files.
@ -69,17 +69,17 @@ namespace Syroot.Worms.Gen2.WorldParty
/// <summary> /// <summary>
/// Gets or sets the visual foreground image. /// Gets or sets the visual foreground image.
/// </summary> /// </summary>
public ImageData Foreground { get; set; } public Img Foreground { get; set; }
/// <summary> /// <summary>
/// Gets or sets the collision mask of the landscape. /// Gets or sets the collision mask of the landscape.
/// </summary> /// </summary>
public ImageData CollisionMask { get; set; } public Img CollisionMask { get; set; }
/// <summary> /// <summary>
/// Gets or sets the visual background image. /// Gets or sets the visual background image.
/// </summary> /// </summary>
public ImageData Background { get; set; } public Img Background { get; set; }
/// <summary> /// <summary>
/// Gets or sets the path to the land image file. /// Gets or sets the path to the land image file.
@ -117,9 +117,9 @@ namespace Syroot.Worms.Gen2.WorldParty
ObjectLocations = reader.ReadStructs<Vector2>(reader.ReadInt32()); ObjectLocations = reader.ReadStructs<Vector2>(reader.ReadInt32());
// Read the image data. // Read the image data.
Foreground = new ImageData(stream, true); Foreground = new Img(stream, true);
CollisionMask = new ImageData(stream, true); CollisionMask = new Img(stream, true);
Background = new ImageData(stream, true); Background = new Img(stream, true);
// Read the file paths. // Read the file paths.
LandTexturePath = reader.ReadString(StringCoding.ByteCharCount); LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);

View File

@ -5,7 +5,7 @@ using Syroot.BinaryData;
using Syroot.Maths; using Syroot.Maths;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.WorldParty namespace Syroot.Worms.WorldParty
{ {
/// <summary> /// <summary>
/// Represents a team stored in a <see cref="TeamContainer"/> file. /// Represents a team stored in a <see cref="TeamContainer"/> file.
@ -65,7 +65,7 @@ namespace Syroot.Worms.Gen2.WorldParty
/// (<c>true</c>) or the player's countries' fanfare should be played (<c>false</c>). /// (<c>true</c>) or the player's countries' fanfare should be played (<c>false</c>).
/// </summary> /// </summary>
public byte UseCustomFanfare { get; set; } public byte UseCustomFanfare { get; set; }
/// <summary> /// <summary>
/// Gets or sets the sprite index of the team grave, -1 being a custom bitmap grave. /// Gets or sets the sprite index of the team grave, -1 being a custom bitmap grave.
/// </summary> /// </summary>
@ -105,7 +105,7 @@ namespace Syroot.Worms.Gen2.WorldParty
/// Gets or sets the number of deathmatch games won. /// Gets or sets the number of deathmatch games won.
/// </summary> /// </summary>
public int DeathmatchesWon { get; set; } public int DeathmatchesWon { get; set; }
/// <summary> /// <summary>
/// Gets or sets the number of games drawn. /// Gets or sets the number of games drawn.
/// </summary> /// </summary>
@ -150,7 +150,7 @@ namespace Syroot.Worms.Gen2.WorldParty
/// Gets or sets the bitmap of the team flag. /// Gets or sets the bitmap of the team flag.
/// </summary> /// </summary>
public BitmapData Flag { get; set; } public BitmapData Flag { get; set; }
/// <summary> /// <summary>
/// Gets or sets an unknown value. /// Gets or sets an unknown value.
/// </summary> /// </summary>
@ -217,7 +217,7 @@ namespace Syroot.Worms.Gen2.WorldParty
Data = reader.ReadBytes(24 * 32) Data = reader.ReadBytes(24 * 32)
}; };
} }
TeamWeapon = reader.ReadEnum<TeamWeapon>(true); TeamWeapon = reader.ReadEnum<TeamWeapon>(true);
GamesLost = reader.ReadInt32(); GamesLost = reader.ReadInt32();
DeathmatchesLost = reader.ReadInt32(); DeathmatchesLost = reader.ReadInt32();
@ -317,7 +317,7 @@ namespace Syroot.Worms.Gen2.WorldParty
/// </summary> /// </summary>
public int Medal; public int Medal;
} }
/// <summary> /// <summary>
/// Represents the special weapon of a team. /// Represents the special weapon of a team.
/// </summary> /// </summary>

View File

@ -4,7 +4,7 @@ using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.WorldParty namespace Syroot.Worms.WorldParty
{ {
/// <summary> /// <summary>
/// Represents the list of teams and unlocked game features stored in WGT files. /// Represents the list of teams and unlocked game features stored in WGT files.

View File

@ -4,7 +4,7 @@ using Syroot.BinaryData;
using Syroot.Maths; using Syroot.Maths;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Worms2 namespace Syroot.Worms.Worms2
{ {
/// <summary> /// <summary>
/// Represents map configuration stored by the land generator in LAND.DAT files. /// Represents map configuration stored by the land generator in LAND.DAT files.
@ -69,22 +69,22 @@ namespace Syroot.Worms.Gen2.Worms2
/// <summary> /// <summary>
/// Gets or sets the visual foreground image. /// Gets or sets the visual foreground image.
/// </summary> /// </summary>
public ImageData Foreground { get; set; } public Img Foreground { get; set; }
/// <summary> /// <summary>
/// Gets or sets the collision mask of the landscape. /// Gets or sets the collision mask of the landscape.
/// </summary> /// </summary>
public ImageData CollisionMask { get; set; } public Img CollisionMask { get; set; }
/// <summary> /// <summary>
/// Gets or sets the visual background image. /// Gets or sets the visual background image.
/// </summary> /// </summary>
public ImageData Background { get; set; } public Img Background { get; set; }
/// <summary> /// <summary>
/// Gets or sets an image of unknown use. /// Gets or sets an image of unknown use.
/// </summary> /// </summary>
public ImageData UnknownImage { get; set; } public Img UnknownImage { get; set; }
/// <summary> /// <summary>
/// Gets or sets the path to the land image file. /// Gets or sets the path to the land image file.
@ -122,10 +122,10 @@ namespace Syroot.Worms.Gen2.Worms2
Unknown = reader.ReadInt32(); Unknown = reader.ReadInt32();
// Read the image data. // Read the image data.
Foreground = reader.Load<ImageData>(); Foreground = reader.Load<Img>();
CollisionMask = reader.Load<ImageData>(); CollisionMask = reader.Load<Img>();
Background = reader.Load<ImageData>(); Background = reader.Load<Img>();
UnknownImage = reader.Load<ImageData>(); UnknownImage = reader.Load<Img>();
// Read the file paths. // Read the file paths.
LandTexturePath = reader.ReadString(StringCoding.ByteCharCount); LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);

View File

@ -1,4 +1,4 @@
namespace Syroot.Worms.Gen2.Worms2 namespace Syroot.Worms.Worms2
{ {
/// <summary> /// <summary>
/// Represents the method to determine the next turn's worm. /// Represents the method to determine the next turn's worm.

View File

@ -3,7 +3,7 @@ using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Worms2 namespace Syroot.Worms.Worms2
{ {
/// <summary> /// <summary>
/// Represents scheme options stored in an OPT file which contains game settings. /// Represents scheme options stored in an OPT file which contains game settings.

View File

@ -1,6 +1,6 @@
using System.Runtime.InteropServices; using System.Runtime.InteropServices;
namespace Syroot.Worms.Gen2.Worms2 namespace Syroot.Worms.Worms2
{ {
/// <summary> /// <summary>
/// Represents the configuration of a weapon. /// Represents the configuration of a weapon.

View File

@ -3,7 +3,7 @@ using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Worms2 namespace Syroot.Worms.Worms2
{ {
/// <summary> /// <summary>
/// Represents scheme weapons stored in an WEP file which contains armory configuration. /// Represents scheme weapons stored in an WEP file which contains armory configuration.

View File

@ -3,7 +3,7 @@ using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Worms2 namespace Syroot.Worms.Worms2
{ {
/// <summary> /// <summary>
/// Represents a team stored in a <see cref="TeamContainer"/> file. /// Represents a team stored in a <see cref="TeamContainer"/> file.

View File

@ -4,7 +4,7 @@ using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
namespace Syroot.Worms.Gen2.Worms2 namespace Syroot.Worms.Worms2
{ {
/// <summary> /// <summary>
/// Represents the list of teams stored in ST1 files. /// Represents the list of teams stored in ST1 files.