Review code, update code standards and NuGet packages.

This commit is contained in:
Ray Koopa 2019-09-27 20:13:24 +02:00
parent c5391c3d66
commit e57c593efa
62 changed files with 1765 additions and 2221 deletions

View File

@ -11,31 +11,20 @@ namespace Syroot.Worms.Armageddon.ProjectX
public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute, public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
ByteConverter byteConverter) ByteConverter byteConverter)
{ {
ExplosionAction explosionAction; ExplosionAction explosionAction = instance switch
switch (instance)
{ {
case LauncherStyle launcherStyle: LauncherStyle launcherStyle => launcherStyle.ExplosionAction,
explosionAction = launcherStyle.ExplosionAction; ClusterTarget clusterTarget => clusterTarget.ExplosionAction,
break; _ => throw new NotImplementedException(),
case ClusterTarget clusterTarget: };
explosionAction = clusterTarget.ExplosionAction; return explosionAction switch
break;
default:
throw new NotImplementedException();
}
switch (explosionAction)
{ {
case ExplosionAction.Bounce: ExplosionAction.Bounce => stream.ReadObject<BounceAction>(),
return stream.ReadObject<BounceAction>(); ExplosionAction.Dig => stream.ReadObject<DigAction>(),
case ExplosionAction.Dig: ExplosionAction.Home => stream.ReadObject<HomeAction>(),
return stream.ReadObject<DigAction>(); ExplosionAction.Roam => stream.ReadObject<RoamAction>(),
case ExplosionAction.Home: _ => null,
return stream.ReadObject<HomeAction>(); };
case ExplosionAction.Roam:
return stream.ReadObject<RoamAction>();
}
return null;
} }
public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value, public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,

View File

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

View File

@ -25,28 +25,20 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Scheme"/> class. /// Initializes a new instance of the <see cref="Scheme"/> class.
/// </summary> /// </summary>
public Library() public Library() { }
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Scheme"/> class, loading the data from the given /// Initializes a new instance of the <see cref="Scheme"/> 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 Library(Stream stream) public Library(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Scheme"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="Scheme"/> 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 Library(string fileName) public Library(string fileName) => Load(fileName);
{
Load(fileName);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -59,13 +51,7 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// </summary> /// </summary>
/// <param name="key">The key of the entries to match.</param> /// <param name="key">The key of the entries to match.</param>
/// <returns>All matching entries.</returns> /// <returns>All matching entries.</returns>
public IEnumerable<LibraryItem> this[string key] public IEnumerable<LibraryItem> this[string key] => this.Where(x => x.Key == key);
{
get
{
return this.Where(x => x.Key == key);
}
}
// ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
@ -75,13 +61,11 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the header. // Read the header.
if (reader.ReadInt32() != _signature) if (reader.ReadInt32() != _signature)
{
throw new InvalidDataException("Invalid PXL file signature."); throw new InvalidDataException("Invalid PXL file signature.");
}
Version = reader.Read1Byte(); Version = reader.Read1Byte();
// Read the items. // Read the items.
@ -105,7 +89,6 @@ namespace Syroot.Worms.Armageddon.ProjectX
} }
} }
} }
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -113,11 +96,9 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// <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 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"/>.
@ -125,8 +106,8 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
// Write the header. // Write the header.
writer.Write(_signature); writer.Write(_signature);
writer.Write(Version); writer.Write(Version);
@ -153,7 +134,6 @@ namespace Syroot.Worms.Armageddon.ProjectX
} }
} }
} }
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
@ -161,38 +141,30 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// <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)
{ {
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); Save(stream);
} }
}
/// <summary> /// <summary>
/// Gets all attached files. /// Gets all attached files.
/// </summary> /// </summary>
/// <returns>The enumeration of attached files.</returns> /// <returns>The enumeration of attached files.</returns>
public IEnumerable<byte[]> GetFiles() public IEnumerable<byte[]> GetFiles()
{ => this.Where(x => x.Type == LibraryItemType.File).Select(x => (byte[])x.Value);
return this.Where(x => x.Type == LibraryItemType.File).Select(x => (byte[])x.Value);
}
/// <summary> /// <summary>
/// Gets all attached scripts. /// Gets all attached scripts.
/// </summary> /// </summary>
/// <returns>The enumeration of attached scripts.</returns> /// <returns>The enumeration of attached scripts.</returns>
public IEnumerable<string> GetScripts() public IEnumerable<string> GetScripts()
{ => this.Where(x => x.Type == LibraryItemType.Script).Select(x => (string)x.Value);
return this.Where(x => x.Type == LibraryItemType.Script).Select(x => (string)x.Value);
}
/// <summary> /// <summary>
/// Gets all attached weapons. /// Gets all attached weapons.
/// </summary> /// </summary>
/// <returns>The enumeration of attached weapons.</returns> /// <returns>The enumeration of attached weapons.</returns>
public IEnumerable<Weapon> GetWeapons() public IEnumerable<Weapon> GetWeapons()
{ => this.Where(x => x.Type == LibraryItemType.Weapon).Select(x => (Weapon)x.Value);
return this.Where(x => x.Type == LibraryItemType.Weapon).Select(x => (Weapon)x.Value);
}
} }
/// <summary> /// <summary>
@ -236,29 +208,18 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// </summary> /// </summary>
public object Value public object Value
{ {
get get => _value;
{
return _value;
}
set set
{ {
// Validate the type. // Validate the type.
if (value.GetType() == typeof(byte[])) if (value.GetType() == typeof(byte[]))
{
Type = LibraryItemType.File; Type = LibraryItemType.File;
}
else if (value.GetType() == typeof(string)) else if (value.GetType() == typeof(string))
{
Type = LibraryItemType.Script; Type = LibraryItemType.Script;
}
else if (value.GetType() == typeof(Weapon)) else if (value.GetType() == typeof(Weapon))
{
Type = LibraryItemType.Weapon; Type = LibraryItemType.Weapon;
}
else else
{
throw new ArgumentException("Invalid LibraryItemType.", nameof(value)); throw new ArgumentException("Invalid LibraryItemType.", nameof(value));
}
_value = value; _value = value;
} }
} }

View File

@ -23,28 +23,20 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Scheme"/> class. /// Initializes a new instance of the <see cref="Scheme"/> class.
/// </summary> /// </summary>
public Scheme() public Scheme() { }
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Scheme"/> class, loading the data from the given /// Initializes a new instance of the <see cref="Scheme"/> 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 Scheme(Stream stream) public Scheme(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Scheme"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="Scheme"/> 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 Scheme(string fileName) public Scheme(string fileName) => Load(fileName);
{
Load(fileName);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -72,13 +64,11 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the header. // Read the header.
if (reader.ReadString(_signature.Length) != _signature) if (reader.ReadString(_signature.Length) != _signature)
{
throw new InvalidDataException("Invalid PXS file signature."); throw new InvalidDataException("Invalid PXS file signature.");
}
Version = reader.ReadInt32(); Version = reader.ReadInt32();
// Read the scheme flags. // Read the scheme flags.
@ -88,9 +78,7 @@ namespace Syroot.Worms.Armageddon.ProjectX
int weaponTableCount = reader.ReadInt32(); int weaponTableCount = reader.ReadInt32();
WeaponTables = new List<Weapon[]>(weaponTableCount); WeaponTables = new List<Weapon[]>(weaponTableCount);
for (int i = 0; i < weaponTableCount; i++) for (int i = 0; i < weaponTableCount; i++)
{
WeaponTables.Add(reader.Load<Weapon>(_weaponsPerTable)); WeaponTables.Add(reader.Load<Weapon>(_weaponsPerTable));
}
// Read a placeholder array. // Read a placeholder array.
reader.Seek(sizeof(int)); reader.Seek(sizeof(int));
@ -109,10 +97,8 @@ namespace Syroot.Worms.Armageddon.ProjectX
int scriptsCount = reader.ReadInt32(); int scriptsCount = reader.ReadInt32();
Scripts = new Dictionary<string, string>(scriptsCount); Scripts = new Dictionary<string, string>(scriptsCount);
for (int i = 0; i < scriptsCount; i++) for (int i = 0; i < scriptsCount; i++)
{
Scripts.Add(reader.ReadString(StringCoding.Int32CharCount), Scripts.Add(reader.ReadString(StringCoding.Int32CharCount),
reader.ReadString(StringCoding.Int32CharCount)); reader.ReadString(StringCoding.Int32CharCount));
}
// Read required libraries. // Read required libraries.
int librariesCount = reader.ReadInt32(); int librariesCount = reader.ReadInt32();
@ -126,7 +112,6 @@ namespace Syroot.Worms.Armageddon.ProjectX
GameSchemeName = reader.ReadString(StringCoding.Int32CharCount); GameSchemeName = reader.ReadString(StringCoding.Int32CharCount);
} }
} }
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -134,11 +119,9 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// <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 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"/>.
@ -146,8 +129,8 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
// Write the header. // Write the header.
writer.Write(_signature, StringCoding.Raw); writer.Write(_signature, StringCoding.Raw);
writer.Write(Version); writer.Write(Version);
@ -158,9 +141,7 @@ namespace Syroot.Worms.Armageddon.ProjectX
// Write the weapon tables. // Write the weapon tables.
writer.Write(WeaponTables.Count); writer.Write(WeaponTables.Count);
foreach (Weapon[] weaponTable in WeaponTables) foreach (Weapon[] weaponTable in WeaponTables)
{
writer.Save(weaponTable); writer.Save(weaponTable);
}
// Write a placeholder array. // Write a placeholder array.
writer.Write(0); writer.Write(0);
@ -199,7 +180,6 @@ namespace Syroot.Worms.Armageddon.ProjectX
writer.Write(GameSchemeName, StringCoding.Int32CharCount); writer.Write(GameSchemeName, StringCoding.Int32CharCount);
} }
} }
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
@ -207,10 +187,8 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// <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)
{ {
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); Save(stream);
} }
} }
} }
}

View File

@ -11,24 +11,17 @@ namespace Syroot.Worms.Armageddon.ProjectX
public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute, public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
ByteConverter byteConverter) ByteConverter byteConverter)
{ {
WeaponAirstrikeSubstyle airstrikeSubstyle; WeaponAirstrikeSubstyle airstrikeSubstyle = instance switch
switch (instance)
{ {
case AirstrikeStyle airstrikeStyle: AirstrikeStyle airstrikeStyle => airstrikeStyle.AirstrikeSubstyle,
airstrikeSubstyle = airstrikeStyle.AirstrikeSubstyle; _ => throw new NotImplementedException(),
break; };
default: return airstrikeSubstyle switch
throw new NotImplementedException();
}
switch (airstrikeSubstyle)
{ {
case WeaponAirstrikeSubstyle.Launcher: WeaponAirstrikeSubstyle.Launcher => stream.ReadObject<LauncherStyle>(),
return stream.ReadObject<LauncherStyle>(); WeaponAirstrikeSubstyle.Mines => stream.ReadObject<MineStyle>(),
case WeaponAirstrikeSubstyle.Mines: _ => null,
return stream.ReadObject<MineStyle>(); };
}
return null;
} }
public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value, public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,

View File

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

View File

@ -14,7 +14,7 @@
<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.0</TargetFrameworks> <TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>2.0.0-alpha1</Version> <Version>2.0.0-alpha1</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

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

View File

@ -11,24 +11,17 @@ namespace Syroot.Worms.Armageddon.ProjectX
public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute, public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
ByteConverter byteConverter) ByteConverter byteConverter)
{ {
ExplosionTarget explosionTarget; ExplosionTarget explosionTarget = instance switch
switch (instance)
{ {
case LauncherStyle launcherStyle: LauncherStyle launcherStyle => launcherStyle.ExplosionTarget,
explosionTarget = launcherStyle.ExplosionTarget; _ => throw new NotImplementedException(),
break; };
default: return explosionTarget switch
throw new NotImplementedException();
}
switch (explosionTarget)
{ {
case ExplosionTarget.Clusters: ExplosionTarget.Clusters => stream.ReadObject<ClusterTarget>(),
return stream.ReadObject<ClusterTarget>(); ExplosionTarget.Fire => stream.ReadObject<FireTarget>(),
case ExplosionTarget.Fire: _ => null,
return stream.ReadObject<FireTarget>(); };
}
return null;
} }
public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value, public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,

View File

@ -2,7 +2,6 @@ using System.Diagnostics;
using System.IO; using System.IO;
using System.Text; using System.Text;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core;
using Syroot.Worms.Core.IO; using Syroot.Worms.Core.IO;
namespace Syroot.Worms.Armageddon.ProjectX namespace Syroot.Worms.Armageddon.ProjectX
@ -114,8 +113,8 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the header. // Read the header.
long offset = reader.Position; long offset = reader.Position;
Version = reader.ReadEnum<WeaponVersion>(true); Version = reader.ReadEnum<WeaponVersion>(true);
@ -272,11 +271,8 @@ namespace Syroot.Worms.Armageddon.ProjectX
PickSpriteOverride = reader.ReadBoolean(); PickSpriteOverride = reader.ReadBoolean();
FireSpriteOverride = reader.ReadBoolean(); FireSpriteOverride = reader.ReadBoolean();
if (Version == WeaponVersion.Version_0_8_0) if (Version == WeaponVersion.Version_0_8_0)
{
Utility = reader.ReadBoolean(); Utility = reader.ReadBoolean();
} }
}
}
/// <summary> /// <summary>
/// Saves the data into the given <paramref name="stream"/>. /// Saves the data into the given <paramref name="stream"/>.
@ -284,8 +280,8 @@ namespace Syroot.Worms.Armageddon.ProjectX
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Write the header. // Write the header.
long offset = writer.Position; long offset = writer.Position;
writer.WriteEnum(Version, true); writer.WriteEnum(Version, true);
@ -315,9 +311,7 @@ namespace Syroot.Worms.Armageddon.ProjectX
writer.Write(NotUsed); writer.Write(NotUsed);
writer.WriteEnum(CrosshairAction, true); writer.WriteEnum(CrosshairAction, true);
if (CrosshairAction != WeaponCrosshairAction.None) if (CrosshairAction != WeaponCrosshairAction.None)
{
writer.WriteObject(Style); writer.WriteObject(Style);
}
break; break;
case WeaponActivation.Spacebar: case WeaponActivation.Spacebar:
writer.WriteEnum(SpacebarAction, true); writer.WriteEnum(SpacebarAction, true);
@ -345,9 +339,7 @@ namespace Syroot.Worms.Armageddon.ProjectX
writer.Write(ThrowHerdCount); writer.Write(ThrowHerdCount);
writer.WriteEnum(ThrowAction, true); writer.WriteEnum(ThrowAction, true);
if (ThrowAction != WeaponThrowAction.None) if (ThrowAction != WeaponThrowAction.None)
{
writer.WriteObject(Style); writer.WriteObject(Style);
}
break; break;
} }
@ -385,12 +377,9 @@ namespace Syroot.Worms.Armageddon.ProjectX
writer.Write(PickSpriteOverride); writer.Write(PickSpriteOverride);
writer.Write(FireSpriteOverride); writer.Write(FireSpriteOverride);
if (Version == WeaponVersion.Version_0_8_0) if (Version == WeaponVersion.Version_0_8_0)
{
writer.Write(Utility); writer.Write(Utility);
} }
} }
}
}
public enum WeaponVersion : int public enum WeaponVersion : int
{ {

View File

@ -16,28 +16,20 @@ namespace Syroot.Worms.Armageddon
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="GeneratedMap"/> class. /// Initializes a new instance of the <see cref="GeneratedMap"/> class.
/// </summary> /// </summary>
public GeneratedMap() public GeneratedMap() { }
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="GeneratedMap"/> class, loading the data from the given /// Initializes a new instance of the <see cref="GeneratedMap"/> 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 GeneratedMap(Stream stream) public GeneratedMap(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="GeneratedMap"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="GeneratedMap"/> 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 GeneratedMap(string fileName) public GeneratedMap(string fileName) => Load(fileName);
{
Load(fileName);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -54,11 +46,9 @@ namespace Syroot.Worms.Armageddon
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
Settings = reader.ReadStruct<MapGeneratorSettings>(); Settings = reader.ReadStruct<MapGeneratorSettings>();
} }
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -66,11 +56,9 @@ namespace Syroot.Worms.Armageddon
/// <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 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"/>.
@ -78,11 +66,9 @@ namespace Syroot.Worms.Armageddon
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
writer.WriteStruct(Settings); writer.WriteStruct(Settings);
} }
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
@ -90,10 +76,8 @@ namespace Syroot.Worms.Armageddon
/// <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)
{ {
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); Save(stream);
} }
} }
} }
}

View File

@ -28,19 +28,13 @@ namespace Syroot.Worms.Armageddon
/// <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 LandData(Stream stream) public LandData(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="LandData"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="LandData"/> 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 LandData(string fileName) public LandData(string fileName) => Load(fileName);
{
Load(fileName);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -102,8 +96,8 @@ namespace Syroot.Worms.Armageddon
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the header. // Read the header.
if (reader.ReadInt32() != _signature) if (reader.ReadInt32() != _signature)
throw new InvalidDataException("Invalid LND file signature."); throw new InvalidDataException("Invalid LND file signature.");
@ -127,7 +121,6 @@ namespace Syroot.Worms.Armageddon
LandTexturePath = reader.ReadString(StringCoding.ByteCharCount); LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);
WaterDirPath = reader.ReadString(StringCoding.ByteCharCount); WaterDirPath = reader.ReadString(StringCoding.ByteCharCount);
} }
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -135,7 +128,7 @@ namespace Syroot.Worms.Armageddon
/// <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 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);
} }
@ -145,8 +138,8 @@ namespace Syroot.Worms.Armageddon
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
// Write the header. // Write the header.
writer.Write(_signature); writer.Write(_signature);
uint fileSizeOffset = writer.ReserveOffset(); uint fileSizeOffset = writer.ReserveOffset();
@ -172,7 +165,6 @@ namespace Syroot.Worms.Armageddon
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position); writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
} }
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
@ -180,7 +172,7 @@ namespace Syroot.Worms.Armageddon
/// <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)
{ {
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); Save(stream);
} }
} }

View File

@ -99,19 +99,13 @@ namespace Syroot.Worms.Armageddon
/// <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 Scheme(Stream stream) public Scheme(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Scheme"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="Scheme"/> 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 Scheme(string fileName) public Scheme(string fileName) => Load(fileName);
{
Load(fileName);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -229,16 +223,11 @@ namespace Syroot.Worms.Armageddon
/// </summary> /// </summary>
public byte MineDelay public byte MineDelay
{ {
get get => _mineDelay;
{
return _mineDelay;
}
set set
{ {
if (value == 4 || value > 0x7F) if (value == 4 || value > 0x7F)
{
throw new ArgumentException("Mine delay must be between 0-127 and not be 4.", nameof(value)); throw new ArgumentException("Mine delay must be between 0-127 and not be 4.", nameof(value));
}
_mineDelay = value; _mineDelay = value;
} }
} }
@ -270,16 +259,11 @@ namespace Syroot.Worms.Armageddon
/// </summary> /// </summary>
public byte TurnTime public byte TurnTime
{ {
get get => _turnTime;
{
return _turnTime;
}
set set
{ {
if (value > 0x7F) if (value > 0x7F)
{
throw new ArgumentException("Turn time must be between 0-127.", nameof(value)); throw new ArgumentException("Turn time must be between 0-127.", nameof(value));
}
_turnTime = value; _turnTime = value;
} }
} }
@ -295,16 +279,11 @@ namespace Syroot.Worms.Armageddon
/// </summary> /// </summary>
public byte RoundTimeMinutes public byte RoundTimeMinutes
{ {
get get => _roundTimeMinutes;
{
return _roundTimeMinutes;
}
set set
{ {
if (value > 0x7F) if (value > 0x7F)
{
throw new ArgumentException("Round time must be between 0-127 minutes.", nameof(value)); throw new ArgumentException("Round time must be between 0-127 minutes.", nameof(value));
}
_roundTimeMinutes = value; _roundTimeMinutes = value;
} }
} }
@ -315,16 +294,11 @@ namespace Syroot.Worms.Armageddon
/// </summary> /// </summary>
public byte RoundTimeSeconds public byte RoundTimeSeconds
{ {
get get => _roundTimeSeconds;
{
return _roundTimeSeconds;
}
set set
{ {
if (value > 0x80) if (value > 0x80)
{
throw new ArgumentException("Round time must be between 0-128 seconds.", nameof(value)); throw new ArgumentException("Round time must be between 0-128 seconds.", nameof(value));
}
_roundTimeSeconds = value; _roundTimeSeconds = value;
} }
} }
@ -334,16 +308,11 @@ namespace Syroot.Worms.Armageddon
/// </summary> /// </summary>
public byte NumberOfWins public byte NumberOfWins
{ {
get get => _numberOfWins;
{
return _numberOfWins;
}
set set
{ {
if (value == 0) if (value == 0)
{
throw new ArgumentException("Number of wins must not be 0.", nameof(value)); throw new ArgumentException("Number of wins must not be 0.", nameof(value));
}
_numberOfWins = value; _numberOfWins = value;
} }
} }
@ -486,10 +455,7 @@ namespace Syroot.Worms.Armageddon
/// </summary> /// </summary>
public sbyte RwGravity public sbyte RwGravity
{ {
get get => _rwGravity;
{
return _rwGravity;
}
set set
{ {
if (value != 0) if (value != 0)
@ -507,10 +473,7 @@ namespace Syroot.Worms.Armageddon
/// </summary> /// </summary>
public sbyte RwGravityConstBlackHole public sbyte RwGravityConstBlackHole
{ {
get get => _rwGravityConstBlackHole;
{
return _rwGravityConstBlackHole;
}
set set
{ {
if (value != 0) if (value != 0)
@ -529,10 +492,7 @@ namespace Syroot.Worms.Armageddon
/// </summary> /// </summary>
public sbyte RwGravityPropBlackHole public sbyte RwGravityPropBlackHole
{ {
get get => _rwGravityPropBlackHole;
{
return _rwGravityPropBlackHole;
}
set set
{ {
if (value != 0) if (value != 0)
@ -550,16 +510,11 @@ namespace Syroot.Worms.Armageddon
/// </summary> /// </summary>
public byte RwKaosMod public byte RwKaosMod
{ {
get get => _rwKaosMod;
{
return _rwKaosMod;
}
set set
{ {
if (value > 0xF) if (value > 0xF)
{
throw new ArgumentException("Kaos mod must not be greater than 15."); throw new ArgumentException("Kaos mod must not be greater than 15.");
}
_rwKaosMod = value; _rwKaosMod = value;
} }
} }
@ -650,13 +605,11 @@ namespace Syroot.Worms.Armageddon
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the header. // Read the header.
if (reader.ReadString(_signature.Length) != _signature) if (reader.ReadString(_signature.Length) != _signature)
{
throw new InvalidDataException("Invalid WSC file signature."); throw new InvalidDataException("Invalid WSC file signature.");
}
Version = reader.ReadEnum<SchemeVersion>(true); Version = reader.ReadEnum<SchemeVersion>(true);
// Read the options. // Read the options.
@ -701,16 +654,13 @@ namespace Syroot.Worms.Armageddon
Weapons = new SchemeWeaponSetting[64]; Weapons = new SchemeWeaponSetting[64];
int weaponCount = GetWeaponCount(); int weaponCount = GetWeaponCount();
for (int i = 0; i < weaponCount; i++) for (int i = 0; i < weaponCount; i++)
{
Weapons[i] = reader.ReadStruct<SchemeWeaponSetting>(); Weapons[i] = reader.ReadStruct<SchemeWeaponSetting>();
}
// Ignore possible unknown WWP trash at the end of the file. // Ignore possible unknown WWP trash at the end of the file.
// Parse the RubberWorm settings. // Parse the RubberWorm settings.
LoadRubberWormSettings(); LoadRubberWormSettings();
} }
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -718,20 +668,15 @@ namespace Syroot.Worms.Armageddon
/// <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 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, SchemeSaveFormat.ExtendedWithObjectCount);
{
Save(stream, SchemeSaveFormat.ExtendedWithObjectCount);
}
/// <summary> /// <summary>
/// Saves the data into the given <paramref name="stream"/> with the specified <paramref name="format"/>. /// Saves the data into the given <paramref name="stream"/> with the specified <paramref name="format"/>.
@ -740,8 +685,8 @@ namespace Syroot.Worms.Armageddon
/// <param name="format">The <see cref="SchemeSaveFormat"/> to respect when storing the settings.</param> /// <param name="format">The <see cref="SchemeSaveFormat"/> to respect when storing the settings.</param>
public void Save(Stream stream, SchemeSaveFormat format) public void Save(Stream stream, SchemeSaveFormat format)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
// Write the header. // Write the header.
writer.Write(_signature, StringCoding.Raw); writer.Write(_signature, StringCoding.Raw);
writer.Write((byte)Version); writer.Write((byte)Version);
@ -790,22 +735,14 @@ namespace Syroot.Worms.Armageddon
// Write the weapon settings. Old versions do not store super weapon settings. // Write the weapon settings. Old versions do not store super weapon settings.
int weaponCount = GetWeaponCount(); int weaponCount = GetWeaponCount();
foreach (SchemeWeaponSetting weapon in Weapons) foreach (SchemeWeaponSetting weapon in Weapons)
{
writer.WriteStruct(weapon); writer.WriteStruct(weapon);
} }
// Ignore possible unknown WWP trash at the end of the file.
}
}
/// <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, SchemeSaveFormat.ExtendedWithObjectCount);
{
Save(fileName, SchemeSaveFormat.ExtendedWithObjectCount);
}
/// <summary> /// <summary>
/// Saves the data in the given file with the specified <paramref name="format"/>. /// Saves the data in the given file with the specified <paramref name="format"/>.
@ -814,11 +751,9 @@ namespace Syroot.Worms.Armageddon
/// <param name="format">The <see cref="SchemeSaveFormat"/> to respect when storing the settings.</param> /// <param name="format">The <see cref="SchemeSaveFormat"/> to respect when storing the settings.</param>
public void Save(string fileName, SchemeSaveFormat format) public void Save(string fileName, SchemeSaveFormat format)
{ {
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, format); Save(stream, format);
} }
}
// ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- // ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
@ -942,14 +877,10 @@ namespace Syroot.Worms.Armageddon
if (mailStrikeProb.GetBit(7)) if (mailStrikeProb.GetBit(7))
{ {
if (mailStrikeProb.GetBit(6)) if (mailStrikeProb.GetBit(6))
{
RwGravityPropBlackHole = mailStrikeProb.DecodeSByte(6); RwGravityPropBlackHole = mailStrikeProb.DecodeSByte(6);
}
else else
{
RwGravityConstBlackHole = mailStrikeProb.DecodeSByte(6); RwGravityConstBlackHole = mailStrikeProb.DecodeSByte(6);
} }
}
else else
{ {
RwGravity = mailStrikeProb.DecodeSByte(7); RwGravity = mailStrikeProb.DecodeSByte(7);
@ -1019,38 +950,26 @@ namespace Syroot.Worms.Armageddon
private void SaveMineDelayConfig(BinaryStream writer) private void SaveMineDelayConfig(BinaryStream writer)
{ {
if (MineDelayRandom) if (MineDelayRandom)
{
writer.Write((byte)4); writer.Write((byte)4);
}
else else
{
writer.Write(MineDelay); writer.Write(MineDelay);
} }
}
private void SaveTurnTimeConfig(BinaryStream writer) private void SaveTurnTimeConfig(BinaryStream writer)
{ {
if (TurnTimeInfinite) if (TurnTimeInfinite)
{
writer.Write((byte)0xFF); writer.Write((byte)0xFF);
}
else else
{
writer.Write(TurnTime); writer.Write(TurnTime);
} }
}
private void SaveRoundTimeConfig(BinaryStream writer) private void SaveRoundTimeConfig(BinaryStream writer)
{ {
if (RoundTimeSeconds > 0) if (RoundTimeSeconds > 0)
{
writer.Write((byte)(0xFF - (RoundTimeSeconds - 1))); writer.Write((byte)(0xFF - (RoundTimeSeconds - 1)));
}
else else
{
writer.Write(RoundTimeMinutes); writer.Write(RoundTimeMinutes);
} }
}
private void SaveRubberWormSettings() private void SaveRubberWormSettings()
{ {

View File

@ -14,7 +14,7 @@
<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.0</TargetFrameworks> <TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>2.0.0-alpha1</Version> <Version>2.0.0-alpha1</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -196,8 +196,8 @@ namespace Syroot.Worms.Armageddon
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
Name = reader.ReadString(17); Name = reader.ReadString(17);
WormNames = reader.ReadStrings(8, 17); WormNames = reader.ReadStrings(8, 17);
CpuLevel = reader.Read1Byte(); CpuLevel = reader.Read1Byte();
@ -249,7 +249,6 @@ namespace Syroot.Worms.Armageddon
Unknown3 = reader.ReadInt32s(7); Unknown3 = reader.ReadInt32s(7);
Unknown4 = reader.Read1Byte(); Unknown4 = reader.Read1Byte();
} }
}
/// <summary> /// <summary>
/// Saves the data into the given <paramref name="stream"/>. /// Saves the data into the given <paramref name="stream"/>.
@ -257,8 +256,8 @@ namespace Syroot.Worms.Armageddon
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
writer.WriteString(Name, 17); writer.WriteString(Name, 17);
writer.WriteStrings(WormNames, 17); writer.WriteStrings(WormNames, 17);
writer.Write(CpuLevel); writer.Write(CpuLevel);
@ -301,7 +300,6 @@ namespace Syroot.Worms.Armageddon
writer.Write(Unknown4); writer.Write(Unknown4);
} }
} }
}
/// <summary> /// <summary>
/// Represents a team's progress in a mission. /// Represents a team's progress in a mission.

View File

@ -22,29 +22,20 @@ namespace Syroot.Worms.Armageddon
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TeamContainer"/> class. /// Initializes a new instance of the <see cref="TeamContainer"/> class.
/// </summary> /// </summary>
public TeamContainer() public TeamContainer() => Teams = new List<Team>();
{
Teams = new List<Team>();
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TeamContainer"/> class, loading the data from the given /// Initializes a new instance of the <see cref="TeamContainer"/> 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 TeamContainer(Stream stream) public TeamContainer(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TeamContainer"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="TeamContainer"/> 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 TeamContainer(string fileName) public TeamContainer(string fileName) => Load(fileName);
{
Load(fileName);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -76,13 +67,11 @@ namespace Syroot.Worms.Armageddon
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the header. // Read the header.
if (reader.ReadString(StringCoding.ZeroTerminated) != _signature) if (reader.ReadString(StringCoding.ZeroTerminated) != _signature)
{
throw new InvalidDataException("Invalid WGT file signature."); throw new InvalidDataException("Invalid WGT file signature.");
}
Version = reader.Read1Byte(); // Really version? Version = reader.Read1Byte(); // Really version?
// Read global settings. // Read global settings.
@ -93,7 +82,6 @@ namespace Syroot.Worms.Armageddon
// Read the teams. // Read the teams.
Teams = new List<Team>(reader.Load<Team>(teamCount)); Teams = new List<Team>(reader.Load<Team>(teamCount));
} }
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -101,11 +89,9 @@ namespace Syroot.Worms.Armageddon
/// <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 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"/>.
@ -113,8 +99,8 @@ namespace Syroot.Worms.Armageddon
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
// Write the header. // Write the header.
writer.Write(_signature, StringCoding.ZeroTerminated); writer.Write(_signature, StringCoding.ZeroTerminated);
writer.Write(Version); writer.Write(Version);
@ -126,11 +112,8 @@ namespace Syroot.Worms.Armageddon
// Write the teams. // Write the teams.
foreach (Team team in Teams) foreach (Team team in Teams)
{
team.Save(writer.BaseStream); team.Save(writer.BaseStream);
} }
}
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
@ -138,12 +121,10 @@ namespace Syroot.Worms.Armageddon
/// <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)
{ {
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); Save(stream);
} }
} }
}
/// <summary> /// <summary>
/// Represents unlockable features of the game. /// Represents unlockable features of the game.

View File

@ -3,13 +3,14 @@ using System.Drawing;
using System.IO; using System.IO;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core; using Syroot.Worms.Core;
using Syroot.Worms.Core.IO;
namespace Syroot.Worms.Mgame namespace Syroot.Worms.Mgame
{ {
/// <summary> /// <summary>
/// Represents an IGD image container. /// Represents an IGD image container.
/// </summary> /// </summary>
public class Igd public class Igd : ILoadableFile
{ {
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------ // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
@ -18,20 +19,14 @@ namespace Syroot.Worms.Mgame
/// <paramref name="fileName"/>. /// <paramref name="fileName"/>.
/// </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 Igd(string fileName) public Igd(string fileName) => Load(fileName);
{
Load(fileName);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Igd"/> class, loading data from the given /// Initializes a new instance of the <see cref="Igd"/> class, loading data from the given
/// <paramref name="stream"/>. /// <paramref name="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 Igd(Stream stream) public Igd(Stream stream) => Load(stream);
{
Load(stream);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -50,7 +45,7 @@ namespace Syroot.Worms.Mgame
/// <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 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);
} }

View File

@ -23,10 +23,7 @@ namespace Syroot.Worms.Mgame
/// </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>
/// <param name="palette">The color palette which is indexed by the image data.</param> /// <param name="palette">The color palette which is indexed by the image data.</param>
public Ksf(string fileName, Palette palette) public Ksf(string fileName, Palette palette) => Load(fileName, palette);
{
Load(fileName, palette);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Ksf"/> class, loading data from the given /// Initializes a new instance of the <see cref="Ksf"/> class, loading data from the given
@ -34,10 +31,7 @@ namespace Syroot.Worms.Mgame
/// </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="palette">The color palette which is indexed by the image data.</param> /// <param name="palette">The color palette which is indexed by the image data.</param>
public Ksf(Stream stream, Palette palette) public Ksf(Stream stream, Palette palette) => Load(stream, palette);
{
Load(stream, palette);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -56,7 +50,7 @@ namespace Syroot.Worms.Mgame
/// <param name="palette">The color palette which is indexed by the image data.</param> /// <param name="palette">The color palette which is indexed by the image data.</param>
public void Load(string fileName, Palette palette) public void Load(string fileName, Palette palette)
{ {
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, palette); Load(stream, palette);
} }
@ -69,7 +63,7 @@ namespace Syroot.Worms.Mgame
public void Load(Stream stream, Palette palette) public void Load(Stream stream, Palette palette)
{ {
int imageCount = stream.ReadInt32(); // Includes terminator. int imageCount = stream.ReadInt32(); // Includes terminator.
int dataSize = stream.ReadInt32(); _ = stream.ReadInt32(); // data size
// Read image headers. Terminating image is of 0 size and data offset at end of data block. // Read image headers. Terminating image is of 0 size and data offset at end of data block.
KsfImage[] images = new KsfImage[imageCount]; KsfImage[] images = new KsfImage[imageCount];

View File

@ -2,13 +2,14 @@
using System.Drawing; using System.Drawing;
using System.IO; using System.IO;
using Syroot.BinaryData; using Syroot.BinaryData;
using Syroot.Worms.Core.IO;
namespace Syroot.Worms.Mgame namespace Syroot.Worms.Mgame
{ {
/// <summary> /// <summary>
/// Represents an LPD layout description file used in Worms World Party Aqua. /// Represents an LPD layout description file used in Worms World Party Aqua.
/// </summary> /// </summary>
public class Lpd public class Lpd : ILoadableFile
{ {
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------ // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
@ -17,20 +18,14 @@ namespace Syroot.Worms.Mgame
/// <paramref name="fileName"/>. /// <paramref name="fileName"/>.
/// </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 Lpd(string fileName) public Lpd(string fileName) => Load(fileName);
{
Load(fileName);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Lpd"/> class, loading data from the given /// Initializes a new instance of the <see cref="Lpd"/> class, loading data from the given
/// <paramref name="stream"/>. /// <paramref name="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 Lpd(Stream stream) public Lpd(Stream stream) => Load(stream);
{
Load(stream);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -47,7 +42,7 @@ namespace Syroot.Worms.Mgame
/// <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 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);
} }

View File

@ -19,17 +19,12 @@ namespace Syroot.Worms.Mgame
{ {
// ---- FIELDS ------------------------------------------------------------------------------------------------- // ---- FIELDS -------------------------------------------------------------------------------------------------
private static int _numBytesTransferred = 0;
private static int _field_4 = 4;
private static int _field_8 = 0; private static int _field_8 = 0;
private static int _field_C = 0;
private static int _field_10 = 0; private static int _field_10 = 0;
private static readonly int[] _bufferDwords = new int[512]; private static readonly int[] _bufferDwords = new int[512];
private static byte[] _buffer = new byte[256]; private static readonly byte[] _buffer = new byte[256];
private static int _bufferCursor = 0; private static int _bufferCursor = 0;
// ---- METHODS (INTERNAL) ------------------------------------------------------------------------------------- // ---- METHODS (INTERNAL) -------------------------------------------------------------------------------------
@ -102,7 +97,6 @@ namespace Syroot.Worms.Mgame
compressor.Shift(shiftValue1, 8); compressor.Shift(shiftValue1, 8);
compressor.Shift(idxDword - 18, 8); compressor.Shift(idxDword - 18, 8);
field_10 = _field_10; field_10 = _field_10;
++_field_C;
_field_10 = idxDword - 3 + field_10; _field_10 = idxDword - 3 + field_10;
} }
else else
@ -110,7 +104,6 @@ namespace Syroot.Worms.Mgame
compressor.Shift(idxDword - 2, 4); compressor.Shift(idxDword - 2, 4);
compressor.Shift(shiftValue1 - 1, 8); compressor.Shift(shiftValue1 - 1, 8);
field_8 = _field_8; field_8 = _field_8;
++_field_4;
_field_8 = idxDword - 2 + field_8; _field_8 = idxDword - 2 + field_8;
} }
idx += idxDword; idx += idxDword;
@ -209,7 +202,6 @@ namespace Syroot.Worms.Mgame
bufferCursor = _bufferCursor; bufferCursor = _bufferCursor;
if (bufferCursor != 0) if (bufferCursor != 0)
{ {
_numBytesTransferred += bufferCursor;
compressor.Compress(false); compressor.Compress(false);
compressor.Shift(_bufferCursor - 1, 8); compressor.Shift(_bufferCursor - 1, 8);
for (i = 0; i < _bufferCursor; ++i) for (i = 0; i < _bufferCursor; ++i)

View File

@ -54,7 +54,7 @@ namespace Syroot.Worms.Mgame
/// <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 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);
} }

View File

@ -37,13 +37,13 @@ namespace Syroot.Worms.Mgame
/// <returns>The encrypted text.</returns> /// <returns>The encrypted text.</returns>
public static string Encrypt(string data, uint key) public static string Encrypt(string data, uint key)
{ {
using (MemoryStream inStream = new MemoryStream(new byte[_bufferSize])) using MemoryStream inStream = new MemoryStream(new byte[_bufferSize]);
{
// Write input into a buffer. Required to loop over the input password end. // Write input into a buffer. Required to loop over the input password end.
inStream.WriteString(data, StringCoding.ZeroTerminated, Encodings.Korean); inStream.WriteString(data, StringCoding.ZeroTerminated, Encodings.Korean);
inStream.Position = 0; inStream.Position = 0;
using (MemoryStream outStream = new MemoryStream(new byte[_bufferSize])) using MemoryStream outStream = new MemoryStream(new byte[_bufferSize]);
{
// Encrypt the contents character by character. // Encrypt the contents character by character.
while (inStream.Position < data.Length) while (inStream.Position < data.Length)
{ {
@ -59,8 +59,6 @@ namespace Syroot.Worms.Mgame
outStream.Position = 0; outStream.Position = 0;
return outStream.ReadString(StringCoding.ZeroTerminated, Encodings.Korean); return outStream.ReadString(StringCoding.ZeroTerminated, Encodings.Korean);
} }
}
}
/// <summary> /// <summary>
/// Decrypts the given <paramref name="data"/> with the specified <paramref name="key"/>. /// Decrypts the given <paramref name="data"/> with the specified <paramref name="key"/>.
@ -70,13 +68,13 @@ namespace Syroot.Worms.Mgame
/// <returns>The decrypted text.</returns> /// <returns>The decrypted text.</returns>
public static string Decrypt(string data, uint key) public static string Decrypt(string data, uint key)
{ {
using (MemoryStream inStream = new MemoryStream(new byte[_bufferSize])) using MemoryStream inStream = new MemoryStream(new byte[_bufferSize]);
{
// Write input into a buffer. Required to loop over the input password end. // Write input into a buffer. Required to loop over the input password end.
inStream.WriteString(data, StringCoding.Raw, Encodings.Korean); inStream.WriteString(data, StringCoding.Raw, Encodings.Korean);
inStream.Position = 0; inStream.Position = 0;
using (MemoryStream outStream = new MemoryStream(new byte[_bufferSize])) using MemoryStream outStream = new MemoryStream(new byte[_bufferSize]);
{
// Decrypt the contents character by character. // Decrypt the contents character by character.
for (int i = 0; i < data.Length; i += 7) for (int i = 0; i < data.Length; i += 7)
{ {
@ -95,8 +93,6 @@ namespace Syroot.Worms.Mgame
outStream.Position = 0; outStream.Position = 0;
return outStream.ReadString(StringCoding.ZeroTerminated, Encodings.Korean); return outStream.ReadString(StringCoding.ZeroTerminated, Encodings.Korean);
} }
}
}
// ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- // ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------

View File

@ -14,7 +14,7 @@
<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.0</TargetFrameworks> <TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>2.0.0-alpha1</Version> <Version>2.0.0-alpha1</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -91,8 +91,8 @@ namespace Syroot.Worms.WorldParty
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the header. // Read the header.
if (reader.ReadInt32() != _signature) if (reader.ReadInt32() != _signature)
throw new InvalidDataException("Invalid LND file signature."); throw new InvalidDataException("Invalid LND file signature.");
@ -115,7 +115,6 @@ namespace Syroot.Worms.WorldParty
LandTexturePath = reader.ReadString(StringCoding.ByteCharCount); LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);
WaterDirPath = reader.ReadString(StringCoding.ByteCharCount); WaterDirPath = reader.ReadString(StringCoding.ByteCharCount);
} }
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -123,7 +122,7 @@ namespace Syroot.Worms.WorldParty
/// <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 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);
} }
@ -133,8 +132,8 @@ namespace Syroot.Worms.WorldParty
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
// Write the header. // Write the header.
writer.Write(_signature); writer.Write(_signature);
uint fileSizeOffset = writer.ReserveOffset(); uint fileSizeOffset = writer.ReserveOffset();
@ -159,7 +158,6 @@ namespace Syroot.Worms.WorldParty
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position); writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
} }
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
@ -167,7 +165,7 @@ namespace Syroot.Worms.WorldParty
/// <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)
{ {
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); Save(stream);
} }
} }

View File

@ -14,7 +14,7 @@
<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.0</TargetFrameworks> <TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>2.0.0-alpha1</Version> <Version>2.0.0-alpha1</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -195,8 +195,8 @@ namespace Syroot.Worms.WorldParty
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
Name = reader.ReadString(17); Name = reader.ReadString(17);
WormNames = reader.ReadStrings(8, 17); WormNames = reader.ReadStrings(8, 17);
CpuLevel = reader.Read1Byte(); CpuLevel = reader.Read1Byte();
@ -247,7 +247,6 @@ namespace Syroot.Worms.WorldParty
Fort = reader.Read1Byte(); Fort = reader.Read1Byte();
Unknown2 = reader.ReadInt32s(7); Unknown2 = reader.ReadInt32s(7);
} }
}
/// <summary> /// <summary>
/// Saves the data into the given <paramref name="stream"/>. /// Saves the data into the given <paramref name="stream"/>.
@ -255,8 +254,8 @@ namespace Syroot.Worms.WorldParty
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
writer.WriteString(Name, 17); writer.WriteString(Name, 17);
writer.WriteStrings(WormNames, 17); writer.WriteStrings(WormNames, 17);
writer.Write(CpuLevel); writer.Write(CpuLevel);
@ -299,7 +298,6 @@ namespace Syroot.Worms.WorldParty
writer.Write(Unknown2); writer.Write(Unknown2);
} }
} }
}
/// <summary> /// <summary>
/// Represents a team's progress in a mission. /// Represents a team's progress in a mission.

View File

@ -21,29 +21,20 @@ namespace Syroot.Worms.WorldParty
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TeamContainer"/> class. /// Initializes a new instance of the <see cref="TeamContainer"/> class.
/// </summary> /// </summary>
public TeamContainer() public TeamContainer() => Teams = new List<Team>();
{
Teams = new List<Team>();
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TeamContainer"/> class, loading the data from the given /// Initializes a new instance of the <see cref="TeamContainer"/> 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 TeamContainer(Stream stream) public TeamContainer(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TeamContainer"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="TeamContainer"/> 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 TeamContainer(string fileName) public TeamContainer(string fileName) => Load(fileName);
{
Load(fileName);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -80,13 +71,11 @@ namespace Syroot.Worms.WorldParty
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the header. // Read the header.
if (reader.ReadString(StringCoding.ZeroTerminated) != _signature) if (reader.ReadString(StringCoding.ZeroTerminated) != _signature)
{
throw new InvalidDataException("Invalid WWP file signature."); throw new InvalidDataException("Invalid WWP file signature.");
}
Version = reader.Read1Byte(); // Really version? Version = reader.Read1Byte(); // Really version?
// Read global settings. // Read global settings.
@ -98,7 +87,6 @@ namespace Syroot.Worms.WorldParty
// Read the teams. // Read the teams.
Teams = new List<Team>(reader.Load<Team>(teamCount)); Teams = new List<Team>(reader.Load<Team>(teamCount));
} }
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -106,11 +94,9 @@ namespace Syroot.Worms.WorldParty
/// <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 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"/>.
@ -118,8 +104,8 @@ namespace Syroot.Worms.WorldParty
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
// Write the header. // Write the header.
writer.Write(_signature, StringCoding.ZeroTerminated); writer.Write(_signature, StringCoding.ZeroTerminated);
writer.Write(Version); writer.Write(Version);
@ -132,11 +118,8 @@ namespace Syroot.Worms.WorldParty
// Write the teams. // Write the teams.
foreach (Team team in Teams) foreach (Team team in Teams)
{
team.Save(writer.BaseStream); team.Save(writer.BaseStream);
} }
}
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
@ -144,10 +127,8 @@ namespace Syroot.Worms.WorldParty
/// <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)
{ {
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); Save(stream);
} }
} }
} }
}

View File

@ -96,8 +96,8 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the header. // Read the header.
if (reader.ReadInt32() != _signature) if (reader.ReadInt32() != _signature)
throw new InvalidDataException("Invalid LND file signature."); throw new InvalidDataException("Invalid LND file signature.");
@ -121,7 +121,6 @@ namespace Syroot.Worms.Worms2
LandTexturePath = reader.ReadString(StringCoding.ByteCharCount); LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);
WaterDirPath = reader.ReadString(StringCoding.ByteCharCount); WaterDirPath = reader.ReadString(StringCoding.ByteCharCount);
} }
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -129,7 +128,7 @@ namespace Syroot.Worms.Worms2
/// <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 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);
} }
@ -139,8 +138,8 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
// Write the header. // Write the header.
writer.Write(_signature); writer.Write(_signature);
uint fileSizeOffset = writer.ReserveOffset(); uint fileSizeOffset = writer.ReserveOffset();
@ -166,7 +165,6 @@ namespace Syroot.Worms.Worms2
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position); writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
} }
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
@ -174,7 +172,7 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
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); Save(stream);
} }
} }

View File

@ -26,7 +26,6 @@ namespace Syroot.Worms.Worms2
Manual = 3 Manual = 3
} }
/// <summary> /// <summary>
/// Represents the weapons in the game. /// Represents the weapons in the game.
/// </summary> /// </summary>

View File

@ -20,28 +20,20 @@ namespace Syroot.Worms.Worms2
/// <summary> /// <summary>
/// Initializs a new instance of the <see cref="SchemeOptions"/> class. /// Initializs a new instance of the <see cref="SchemeOptions"/> class.
/// </summary> /// </summary>
public SchemeOptions() public SchemeOptions() { }
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SchemeOptions"/> class, loading the data from the given /// Initializes a new instance of the <see cref="SchemeOptions"/> 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 SchemeOptions(Stream stream) public SchemeOptions(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SchemeOptions"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="SchemeOptions"/> 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 SchemeOptions(string fileName) public SchemeOptions(string fileName) => Load(fileName);
{
Load(fileName);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -221,13 +213,11 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the header. // Read the header.
if (reader.ReadString(_signature.Length) != _signature) if (reader.ReadString(_signature.Length) != _signature)
{
throw new InvalidDataException("Invalid OPT file signature."); throw new InvalidDataException("Invalid OPT file signature.");
}
// Read the options. // Read the options.
RoundTime = reader.ReadInt32(); RoundTime = reader.ReadInt32();
@ -263,11 +253,8 @@ namespace Syroot.Worms.Worms2
SuddenDeathDisableWormSelect = reader.ReadBoolean(BooleanCoding.Dword); SuddenDeathDisableWormSelect = reader.ReadBoolean(BooleanCoding.Dword);
// The following option does not exist in all schemes. // The following option does not exist in all schemes.
if (!reader.EndOfStream) if (!reader.EndOfStream)
{
UseOilDrums = reader.ReadBoolean(BooleanCoding.Dword); UseOilDrums = reader.ReadBoolean(BooleanCoding.Dword);
} }
}
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -275,11 +262,9 @@ namespace Syroot.Worms.Worms2
/// <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 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"/>.
@ -287,8 +272,8 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
// Write the header. // Write the header.
writer.Write(_signature, StringCoding.Raw); writer.Write(_signature, StringCoding.Raw);
@ -326,7 +311,6 @@ namespace Syroot.Worms.Worms2
writer.Write(SuddenDeathDisableWormSelect, BooleanCoding.Dword); writer.Write(SuddenDeathDisableWormSelect, BooleanCoding.Dword);
writer.Write(UseOilDrums, BooleanCoding.Dword); writer.Write(UseOilDrums, BooleanCoding.Dword);
} }
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
@ -334,10 +318,8 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
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); Save(stream);
} }
} }
} }
}

View File

@ -22,29 +22,20 @@ namespace Syroot.Worms.Worms2
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SchemeWeapons"/> class. /// Initializes a new instance of the <see cref="SchemeWeapons"/> class.
/// </summary> /// </summary>
public SchemeWeapons() public SchemeWeapons() => Weapons = new SchemeWeaponSetting[_weaponCount];
{
Weapons = new SchemeWeaponSetting[_weaponCount];
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SchemeWeapons"/> class, loading the data from the given /// Initializes a new instance of the <see cref="SchemeWeapons"/> 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 SchemeWeapons(Stream stream) public SchemeWeapons(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="SchemeWeapons"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="SchemeWeapons"/> 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 SchemeWeapons(string fileName) public SchemeWeapons(string fileName) => Load(fileName);
{
Load(fileName);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -62,23 +53,18 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the header. // Read the header.
reader.Seek(_trashLength); reader.Seek(_trashLength);
if (reader.ReadString(StringCoding.ZeroTerminated) != _signature) if (reader.ReadString(StringCoding.ZeroTerminated) != _signature)
{
throw new InvalidDataException("Invalid WEP file signature."); throw new InvalidDataException("Invalid WEP file signature.");
}
// Read the weapon settings. // Read the weapon settings.
Weapons = new SchemeWeaponSetting[_weaponCount]; Weapons = new SchemeWeaponSetting[_weaponCount];
for (int i = 0; i < _weaponCount; i++) for (int i = 0; i < _weaponCount; i++)
{
Weapons[i] = reader.ReadStruct<SchemeWeaponSetting>(); Weapons[i] = reader.ReadStruct<SchemeWeaponSetting>();
} }
}
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -86,11 +72,9 @@ namespace Syroot.Worms.Worms2
/// <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 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"/>.
@ -98,19 +82,16 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
// Write the header. // Write the header.
writer.WriteStructs(new byte[_trashLength]); writer.WriteStructs(new byte[_trashLength]);
writer.Write(_signature, StringCoding.ZeroTerminated); writer.Write(_signature, StringCoding.ZeroTerminated);
// Write the weapon settings. // Write the weapon settings.
foreach (SchemeWeaponSetting weapon in Weapons) foreach (SchemeWeaponSetting weapon in Weapons)
{
writer.WriteStruct(weapon); writer.WriteStruct(weapon);
} }
}
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
@ -118,10 +99,8 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
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); Save(stream);
} }
} }
} }
}

View File

@ -14,7 +14,7 @@
<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.0</TargetFrameworks> <TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>2.0.0-alpha1</Version> <Version>2.0.0-alpha1</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>

View File

@ -109,8 +109,7 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
Unknown1 = reader.ReadInt16(); Unknown1 = reader.ReadInt16();
Name = reader.ReadString(66); Name = reader.ReadString(66);
SoundBankName = reader.ReadString(36); SoundBankName = reader.ReadString(36);
@ -153,7 +152,6 @@ namespace Syroot.Worms.Worms2
GamesPlayed = reader.ReadInt32(); GamesPlayed = reader.ReadInt32();
Points = reader.ReadInt32(); Points = reader.ReadInt32();
} }
}
/// <summary> /// <summary>
/// Saves the data into the given <paramref name="stream"/>. /// Saves the data into the given <paramref name="stream"/>.
@ -161,8 +159,7 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
writer.Write(Unknown1); writer.Write(Unknown1);
writer.WriteString(Name, 66); writer.WriteString(Name, 66);
writer.WriteString(SoundBankName, 36); writer.WriteString(SoundBankName, 36);
@ -209,4 +206,3 @@ namespace Syroot.Worms.Worms2
} }
} }
} }
}

View File

@ -17,29 +17,20 @@ namespace Syroot.Worms.Worms2
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TeamContainer"/> class. /// Initializes a new instance of the <see cref="TeamContainer"/> class.
/// </summary> /// </summary>
public TeamContainer() public TeamContainer() => Teams = new List<Team>();
{
Teams = new List<Team>();
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TeamContainer"/> class, loading the data from the given /// Initializes a new instance of the <see cref="TeamContainer"/> 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 TeamContainer(Stream stream) public TeamContainer(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="TeamContainer"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="TeamContainer"/> 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 TeamContainer(string fileName) public TeamContainer(string fileName) => Load(fileName);
{
Load(fileName);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -56,15 +47,11 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
Teams = new List<Team>(); Teams = new List<Team>();
while (!reader.EndOfStream) while (!reader.EndOfStream)
{
Teams.Add(reader.Load<Team>()); Teams.Add(reader.Load<Team>());
} }
}
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -72,11 +59,9 @@ namespace Syroot.Worms.Worms2
/// <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 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"/>.
@ -84,14 +69,10 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
foreach (Team team in Teams) foreach (Team team in Teams)
{
team.Save(writer.BaseStream); team.Save(writer.BaseStream);
} }
}
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
@ -99,10 +80,8 @@ namespace Syroot.Worms.Worms2
/// <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)
{ {
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); Save(stream);
} }
} }
} }
}

View File

@ -28,28 +28,20 @@ namespace Syroot.Worms
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Archive"/> class. /// Initializes a new instance of the <see cref="Archive"/> class.
/// </summary> /// </summary>
public Archive() public Archive() { }
{
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Archive"/> class, loading the data from the given /// Initializes a new instance of the <see cref="Archive"/> 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 Archive(Stream stream) public Archive(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="Archive"/> class, loading the data from the given file. /// Initializes a new instance of the <see cref="Archive"/> 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 Archive(string fileName) public Archive(string fileName) => Load(fileName);
{
Load(fileName);
}
// ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
@ -60,18 +52,14 @@ namespace Syroot.Worms
public void Load(Stream stream) public void Load(Stream stream)
{ {
if (!stream.CanSeek) if (!stream.CanSeek)
{
throw new ArgumentException("Stream requires to be seekable.", nameof(stream)); throw new ArgumentException("Stream requires to be seekable.", nameof(stream));
}
Clear(); Clear();
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the header. // Read the header.
if (reader.ReadInt32() != _signature) if (reader.ReadInt32() != _signature)
{
throw new InvalidDataException("Invalid DIR file signature."); throw new InvalidDataException("Invalid DIR file signature.");
}
int fileSize = reader.ReadInt32(); int fileSize = reader.ReadInt32();
int tocOffset = reader.ReadInt32(); int tocOffset = reader.ReadInt32();
@ -79,9 +67,7 @@ namespace Syroot.Worms
reader.Position = tocOffset; reader.Position = tocOffset;
int tocSignature = reader.ReadInt32(); int tocSignature = reader.ReadInt32();
if (tocSignature != _tocSignature) if (tocSignature != _tocSignature)
{
throw new InvalidDataException("Invalid DIR table of contents signature."); throw new InvalidDataException("Invalid DIR table of contents signature.");
}
// Generate a data dictionary out of the hash table and file entries. // Generate a data dictionary out of the hash table and file entries.
int[] hashTable = reader.ReadInt32s(_hashSize); int[] hashTable = reader.ReadInt32s(_hashSize);
foreach (int entryOffset in hashTable) foreach (int entryOffset in hashTable)
@ -98,14 +84,11 @@ namespace Syroot.Worms
int length = reader.ReadInt32(); int length = reader.ReadInt32();
string name = reader.ReadString(StringCoding.ZeroTerminated); string name = reader.ReadString(StringCoding.ZeroTerminated);
using (reader.TemporarySeek(offset, SeekOrigin.Begin)) using (reader.TemporarySeek(offset, SeekOrigin.Begin))
{
Add(name, reader.ReadBytes(length)); Add(name, reader.ReadBytes(length));
}
} while (nextEntryOffset != 0); } while (nextEntryOffset != 0);
} }
} }
} }
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -113,11 +96,9 @@ namespace Syroot.Worms
/// <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 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"/>.
@ -125,8 +106,8 @@ namespace Syroot.Worms
/// <param name="stream">The <see cref="Stream"/> to save the data in.</param> /// <param name="stream">The <see cref="Stream"/> to save the data in.</param>
public void Save(Stream stream) public void Save(Stream stream)
{ {
using (BinaryStream writer = new BinaryStream(stream)) using BinaryStream writer = new BinaryStream(stream);
{
// Write the header. // Write the header.
writer.Write(_signature); writer.Write(_signature);
uint fileSizeOffset = writer.ReserveOffset(); uint fileSizeOffset = writer.ReserveOffset();
@ -146,9 +127,7 @@ namespace Syroot.Worms
int hash = CalculateHash(item.Key); int hash = CalculateHash(item.Key);
if (hashTable[hash] == null) if (hashTable[hash] == null)
{
hashTable[hash] = new List<HashTableEntry>(); hashTable[hash] = new List<HashTableEntry>();
}
hashTable[hash].Add(entry); hashTable[hash].Add(entry);
} }
@ -179,10 +158,8 @@ namespace Syroot.Worms
writer.Write(entry.Name, StringCoding.ZeroTerminated); writer.Write(entry.Name, StringCoding.ZeroTerminated);
writer.Align(4); writer.Align(4);
if (j < entries.Count - 1) if (j < entries.Count - 1)
{
writer.SatisfyOffset(nextEntryOffset, (int)writer.Position - tocStart); writer.SatisfyOffset(nextEntryOffset, (int)writer.Position - tocStart);
} }
}
fileEntryOffset = (int)writer.Position - tocStart; fileEntryOffset = (int)writer.Position - tocStart;
} }
} }
@ -190,7 +167,6 @@ namespace Syroot.Worms
writer.SatisfyOffset(fileSizeOffset, tocStart + fileEntryOffset - 1); writer.SatisfyOffset(fileSizeOffset, tocStart + fileEntryOffset - 1);
} }
}
/// <summary> /// <summary>
/// Saves the data in the file with the given <paramref name="fileName"/>. /// Saves the data in the file with the given <paramref name="fileName"/>.
@ -198,11 +174,9 @@ namespace Syroot.Worms
/// <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)
{ {
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); Save(stream);
} }
}
// ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- // ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------

View File

@ -5,6 +5,8 @@
/// </summary> /// </summary>
public static class Algebra public static class Algebra
{ {
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
/// <summary> /// <summary>
/// Gets the nearest, bigger <paramref name="multiple"/> of the given <paramref name="value"/>. /// Gets the nearest, bigger <paramref name="multiple"/> of the given <paramref name="value"/>.
/// </summary> /// </summary>

View File

@ -65,9 +65,7 @@ namespace Syroot.Worms.Core
/// <param name="enable"><c>true</c> to enable the bit; otherwise <c>false</c>.</param> /// <param name="enable"><c>true</c> to enable the bit; otherwise <c>false</c>.</param>
/// <returns>The current byte with the bit enabled or disabled.</returns> /// <returns>The current byte with the bit enabled or disabled.</returns>
public static byte SetBit(this byte self, int index, bool enable) public static byte SetBit(this byte self, int index, bool enable)
{ => enable ? EnableBit(self, index) : DisableBit(self, index);
return enable ? EnableBit(self, index) : DisableBit(self, index);
}
/// <summary> /// <summary>
/// Returns the current byte with the bit at the <paramref name="index"/> enabled when it is disabled or /// Returns the current byte with the bit at the <paramref name="index"/> enabled when it is disabled or
@ -77,9 +75,7 @@ namespace Syroot.Worms.Core
/// <param name="index">The 0-based index of the bit to toggle.</param> /// <param name="index">The 0-based index of the bit to toggle.</param>
/// <returns>The current byte with the bit toggled.</returns> /// <returns>The current byte with the bit toggled.</returns>
public static byte ToggleBit(this byte self, int index) public static byte ToggleBit(this byte self, int index)
{ => GetBit(self, index) ? DisableBit(self, index) : EnableBit(self, index);
return GetBit(self, index) ? DisableBit(self, index) : EnableBit(self, index);
}
/// <summary> /// <summary>
/// Returns an <see cref="Byte"/> instance represented by the given number of <paramref name="bits"/>. /// Returns an <see cref="Byte"/> instance represented by the given number of <paramref name="bits"/>.
@ -100,10 +96,7 @@ namespace Syroot.Worms.Core
/// <param name="firstBit">The first bit of the encoded value.</param> /// <param name="firstBit">The first bit of the encoded value.</param>
/// <returns>The decoded <see cref="Byte"/>.</returns> /// <returns>The decoded <see cref="Byte"/>.</returns>
public static byte DecodeByte(this byte self, int bits, int firstBit) public static byte DecodeByte(this byte self, int bits, int firstBit)
{ => (byte)((self >> firstBit) & ((1 << bits) - 1)); // shift to the first bit and keep only required bits
// Shift to the first bit and keep only the required bits.
return (byte)((self >> firstBit) & ((1 << bits) - 1));
}
/// <summary> /// <summary>
/// Returns an <see cref="SByte"/> instance represented by the given number of <paramref name="bits"/>. /// Returns an <see cref="SByte"/> instance represented by the given number of <paramref name="bits"/>.

View File

@ -15,10 +15,7 @@ namespace Syroot.Worms.Core
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------ // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
public DisposableGCHandle(object value, GCHandleType type) public DisposableGCHandle(object value, GCHandleType type) => _handle = GCHandle.Alloc(value, type);
{
_handle = GCHandle.Alloc(value, GCHandleType.Pinned);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -26,18 +23,15 @@ namespace Syroot.Worms.Core
// ---- METHODS (PUBLIC) --------------------------------------------------------------------------------------- // ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
public void Dispose() public void Dispose() => Dispose(true);
{
// Do not change this code. Put cleanup code in Dispose(bool disposing).
Dispose(true);
}
// ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------ // ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------
protected virtual void Dispose(bool disposing) protected virtual void Dispose(bool disposing)
{ {
if (!_disposed) if (_disposed)
{ return;
if (disposing) if (disposing)
{ {
if (_handle.IsAllocated) if (_handle.IsAllocated)
@ -48,4 +42,3 @@ namespace Syroot.Worms.Core
} }
} }
} }
}

View File

@ -22,8 +22,8 @@ namespace Syroot.Worms.Core.Graphics
/// <returns>The <see cref="Bitmap"/> instance.</returns> /// <returns>The <see cref="Bitmap"/> instance.</returns>
public static Bitmap CreateIndexed(Size size, IList<Color> palette, byte[] data) public static Bitmap CreateIndexed(Size size, IList<Color> palette, byte[] data)
{ {
using (DisposableGCHandle dataPin = new DisposableGCHandle(data, GCHandleType.Pinned)) using DisposableGCHandle dataPin = new DisposableGCHandle(data, GCHandleType.Pinned);
{
// Transfer the pixel data, respecting power-of-2 strides. // Transfer the pixel data, respecting power-of-2 strides.
Bitmap bitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format8bppIndexed); Bitmap bitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format8bppIndexed);
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, size.Width, size.Height), BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, size.Width, size.Height),
@ -42,4 +42,3 @@ namespace Syroot.Worms.Core.Graphics
} }
} }
} }
}

View File

@ -41,8 +41,8 @@ namespace Syroot.Worms
/// <returns>The <see cref="Bitmap"/> created from the raw data.</returns> /// <returns>The <see cref="Bitmap"/> created from the raw data.</returns>
public Bitmap ToBitmap() public Bitmap ToBitmap()
{ {
using (DisposableGCHandle dataPin = new DisposableGCHandle(Data, GCHandleType.Pinned)) using DisposableGCHandle dataPin = new DisposableGCHandle(Data, GCHandleType.Pinned);
{
// Transfer the pixel data, respecting power-of-2 strides. // Transfer the pixel data, respecting power-of-2 strides.
Bitmap bitmap = new Bitmap(Size.Width, Size.Height, PixelFormat.Format8bppIndexed); Bitmap bitmap = new Bitmap(Size.Width, Size.Height, PixelFormat.Format8bppIndexed);
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, Size.Width, Size.Height), BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, Size.Width, Size.Height),
@ -61,4 +61,3 @@ namespace Syroot.Worms
} }
} }
} }
}

View File

@ -87,12 +87,10 @@ namespace Syroot.Worms.Core.IO
byte[] bytes = self.ReadBytes(Marshal.SizeOf<T>()); byte[] bytes = self.ReadBytes(Marshal.SizeOf<T>());
// Convert them to a structure instance and return it. // Convert them to a structure instance and return it.
using (DisposableGCHandle handle = new DisposableGCHandle(bytes, GCHandleType.Pinned)) using DisposableGCHandle handle = new DisposableGCHandle(bytes, GCHandleType.Pinned);
{
T instance = Marshal.PtrToStructure<T>(handle.AddrOfPinnedObject); T instance = Marshal.PtrToStructure<T>(handle.AddrOfPinnedObject);
return instance; return instance;
} }
}
/// <summary> /// <summary>
/// Reads raw byte structures from the current stream and returns them. /// Reads raw byte structures from the current stream and returns them.

View File

@ -16,10 +16,7 @@ namespace Syroot.Worms.Core.Riff
/// <paramref name="identifier"/>. /// <paramref name="identifier"/>.
/// </summary> /// </summary>
/// <param name="identifier">The chunk identifier required to invoke this method for loading it.</param> /// <param name="identifier">The chunk identifier required to invoke this method for loading it.</param>
internal RiffChunkLoadAttribute(string identifier) internal RiffChunkLoadAttribute(string identifier) => Identifier = identifier;
{
Identifier = identifier;
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------

View File

@ -16,10 +16,7 @@ namespace Syroot.Worms.Core.Riff
/// <paramref name="identifier"/>. /// <paramref name="identifier"/>.
/// </summary> /// </summary>
/// <param name="identifier">The chunk identifier saved in the file.</param> /// <param name="identifier">The chunk identifier saved in the file.</param>
internal RiffChunkSaveAttribute(string identifier) internal RiffChunkSaveAttribute(string identifier) => Identifier = identifier;
{
Identifier = identifier;
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------

View File

@ -21,17 +21,14 @@ namespace Syroot.Worms.Core.Riff
private static readonly Dictionary<Type, TypeData> _typeDataCache = new Dictionary<Type, TypeData>(); private static readonly Dictionary<Type, TypeData> _typeDataCache = new Dictionary<Type, TypeData>();
private TypeData _typeData; private readonly TypeData _typeData;
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------ // ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="RiffFile"/> class. /// Initializes a new instance of the <see cref="RiffFile"/> class.
/// </summary> /// </summary>
protected RiffFile() protected RiffFile() => _typeData = GetTypeData();
{
_typeData = GetTypeData();
}
// ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------ // ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------
@ -41,19 +38,15 @@ namespace Syroot.Worms.Core.Riff
/// <param name="stream">The <see cref="Stream"/> to load the RIFF data from.</param> /// <param name="stream">The <see cref="Stream"/> to load the RIFF data from.</param>
protected void LoadRiff(Stream stream) protected void LoadRiff(Stream stream)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// Read the file header. // Read the file header.
if (reader.ReadString(_signature.Length) != _signature) if (reader.ReadString(_signature.Length) != _signature)
{
throw new InvalidDataException("Invalid RIFF file signature."); throw new InvalidDataException("Invalid RIFF file signature.");
}
int fileSize = reader.ReadInt32(); int fileSize = reader.ReadInt32();
string fileIdentifier = reader.ReadString(4); string fileIdentifier = reader.ReadString(4);
if (fileIdentifier != _typeData.FileIdentifier) if (fileIdentifier != _typeData.FileIdentifier)
{
throw new InvalidDataException("Invalid RIFF file identifier."); throw new InvalidDataException("Invalid RIFF file identifier.");
}
// Read the chunks. // Read the chunks.
while (!reader.EndOfStream) while (!reader.EndOfStream)
@ -62,16 +55,11 @@ namespace Syroot.Worms.Core.Riff
int chunkLength = reader.ReadInt32(); int chunkLength = reader.ReadInt32();
// Invoke a loader method if matching the identifier or skip the chunk. // Invoke a loader method if matching the identifier or skip the chunk.
if (_typeData.ChunkLoaders.TryGetValue(chunkIdentifier, out MethodInfo loader)) if (_typeData.ChunkLoaders.TryGetValue(chunkIdentifier, out MethodInfo loader))
{
loader.Invoke(this, new object[] { reader, chunkLength }); loader.Invoke(this, new object[] { reader, chunkLength });
}
else else
{
reader.Seek(chunkLength); reader.Seek(chunkLength);
} }
} }
}
}
/// <summary> /// <summary>
/// Saves the RIFF data in the given <paramref name="stream"/>. /// Saves the RIFF data in the given <paramref name="stream"/>.
@ -79,8 +67,8 @@ namespace Syroot.Worms.Core.Riff
/// <param name="stream">The <see cref="Stream"/> to save the RIFF data in.</param> /// <param name="stream">The <see cref="Stream"/> to save the RIFF data in.</param>
protected void SaveRiff(Stream stream) protected void SaveRiff(Stream stream)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
// Write the header. // Write the header.
writer.Write(_signature, StringCoding.Raw); writer.Write(_signature, StringCoding.Raw);
uint fileSizeOffset = writer.ReserveOffset(); uint fileSizeOffset = writer.ReserveOffset();
@ -99,7 +87,6 @@ namespace Syroot.Worms.Core.Riff
writer.SatisfyOffset(fileSizeOffset, (int)(writer.Position - 8)); writer.SatisfyOffset(fileSizeOffset, (int)(writer.Position - 8));
} }
}
// ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- // ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
@ -135,11 +122,8 @@ namespace Syroot.Worms.Core.Riff
if (saveAttribute != null) if (saveAttribute != null)
{ {
ParameterInfo[] parameters = method.GetParameters(); ParameterInfo[] parameters = method.GetParameters();
if (parameters.Length == 1 if (parameters.Length == 1 && parameters[0].ParameterType == typeof(BinaryStream))
&& parameters[0].ParameterType == typeof(BinaryStream))
{
typeData.ChunkSavers.Add(saveAttribute.Identifier, method); typeData.ChunkSavers.Add(saveAttribute.Identifier, method);
}
continue; continue;
} }
} }

View File

@ -15,10 +15,7 @@ namespace Syroot.Worms.Core.Riff
/// <paramref name="identifier"/>. /// <paramref name="identifier"/>.
/// </summary> /// </summary>
/// <param name="identifier">The file identifier in the RIFF file header which will be validated.</param> /// <param name="identifier">The file identifier in the RIFF file header which will be validated.</param>
internal RiffFileAttribute(string identifier) internal RiffFileAttribute(string identifier) => Identifier = identifier;
{
Identifier = identifier;
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------

View File

@ -18,9 +18,7 @@ namespace Syroot.Worms.Core
/// <param name="bytes">The data to compress.</param> /// <param name="bytes">The data to compress.</param>
/// <returns>The compressed data.</returns> /// <returns>The compressed data.</returns>
internal static byte[] Compress(byte[] bytes) internal static byte[] Compress(byte[] bytes)
{ => throw new NotImplementedException("Compressing data has not been implemented yet.");
throw new NotImplementedException("Compressing data has not been implemented yet.");
}
/// <summary> /// <summary>
/// Decompresses the data available in the given <paramref name="stream"/> into the provided /// Decompresses the data available in the given <paramref name="stream"/> into the provided

View File

@ -67,7 +67,7 @@ namespace Syroot.Worms
/// <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 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);
} }
@ -78,8 +78,8 @@ namespace Syroot.Worms
/// <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>
public void Load(Stream stream, bool alignData) public void Load(Stream stream, bool alignData)
{ {
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true)) using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
{
// 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.");
@ -133,7 +133,6 @@ namespace Syroot.Worms
Data = data; Data = data;
} }
}
/// <summary> /// <summary>
/// Loads the data from the given file. The data block can be aligned to a 4-bte boundary. /// Loads the data from the given file. The data block can be aligned to a 4-bte boundary.
@ -142,8 +141,8 @@ namespace Syroot.Worms
/// <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>
public void Load(string fileName, bool alignData) public 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, alignData);
} }
/// <summary> /// <summary>
@ -181,8 +180,8 @@ namespace Syroot.Worms
/// <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>
public void Save(Stream stream, bool compress, bool alignData) public void Save(Stream stream, bool compress, bool alignData)
{ {
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII)) using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
{
// Write the header. // Write the header.
writer.Write(_signature); writer.Write(_signature);
uint fileSizeOffset = writer.ReserveOffset(); uint fileSizeOffset = writer.ReserveOffset();
@ -227,7 +226,6 @@ namespace Syroot.Worms
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position); writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
} }
}
/// <summary> /// <summary>
/// Saves the optionally compressed data in the given file. The data block can be aligned to a 4-byte boundary. /// Saves the optionally compressed data in the given file. The data block can be aligned to a 4-byte boundary.
@ -237,7 +235,7 @@ namespace Syroot.Worms
/// <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>
public void Save(string fileName, bool compress, bool alignData) public 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);
} }

View File

@ -23,29 +23,20 @@ namespace Syroot.Worms
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="RiffPalette"/> class. /// Initializes a new instance of the <see cref="RiffPalette"/> class.
/// </summary> /// </summary>
public RiffPalette() public RiffPalette() => Version = _version;
{
Version = _version;
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="RiffPalette"/> 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 RiffPalette(Stream stream) public RiffPalette(Stream stream) => Load(stream);
{
Load(stream);
}
/// <summary> /// <summary>
/// Initializes a new instance of the <see cref="RiffPalette"/> 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 RiffPalette(string fileName) public RiffPalette(string fileName) => Load(fileName);
{
Load(fileName);
}
// ---- PROPERTIES --------------------------------------------------------------------------------------------- // ---- PROPERTIES ---------------------------------------------------------------------------------------------
@ -80,10 +71,7 @@ namespace Syroot.Worms
/// 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) => LoadRiff(stream);
{
LoadRiff(stream);
}
/// <summary> /// <summary>
/// Loads the data from the given file. /// Loads the data from the given file.
@ -91,20 +79,15 @@ namespace Syroot.Worms
/// <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 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) => SaveRiff(stream);
{
SaveRiff(stream);
}
/// <summary> /// <summary>
/// Saves the data in the given file. /// Saves the data in the given file.
@ -112,11 +95,9 @@ namespace Syroot.Worms
/// <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)
{ {
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); Save(stream);
} }
}
// ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- // ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
@ -126,36 +107,25 @@ namespace Syroot.Worms
// Read the PAL version. // Read the PAL version.
Version = reader.ReadInt16(); Version = reader.ReadInt16();
if (Version != _version) if (Version != _version)
{
throw new InvalidDataException("Unknown PAL version."); throw new InvalidDataException("Unknown PAL version.");
}
// Read the colors. // Read the colors.
Colors = new Color[reader.ReadInt16()]; Colors = new Color[reader.ReadInt16()];
for (int i = 0; i < Colors.Length; i++) for (int i = 0; i < Colors.Length; i++)
{ {
Colors[i] = Color.FromArgb(reader.Read1Byte(), reader.Read1Byte(), reader.Read1Byte()); Colors[i] = Color.FromArgb(reader.Read1Byte(), reader.Read1Byte(), reader.Read1Byte());
int alpha = reader.ReadByte(); // Dismiss alpha, as it is not used in WA. _ = reader.ReadByte(); // Dismiss alpha, as it is not used in WA.
} }
} }
[RiffChunkLoad("offl")] [RiffChunkLoad("offl")]
private void LoadOfflChunk(BinaryStream reader, int length) private void LoadOfflChunk(BinaryStream reader, int length) => OfflData = reader.ReadBytes(length);
{
OfflData = reader.ReadBytes(length);
}
[RiffChunkLoad("tran")] [RiffChunkLoad("tran")]
private void LoadTranChunk(BinaryStream reader, int length) private void LoadTranChunk(BinaryStream reader, int length) => TranData = reader.ReadBytes(length);
{
TranData = reader.ReadBytes(length);
}
[RiffChunkLoad("unde")] [RiffChunkLoad("unde")]
private void LoadUndeChunk(BinaryStream reader, int length) private void LoadUndeChunk(BinaryStream reader, int length) => UndeData = reader.ReadBytes(length);
{
UndeData = reader.ReadBytes(length);
}
[RiffChunkSave("data")] [RiffChunkSave("data")]
private void SaveDataChunk(BinaryStream writer) private void SaveDataChunk(BinaryStream writer)
@ -176,21 +146,12 @@ namespace Syroot.Worms
} }
[RiffChunkSave("offl")] [RiffChunkSave("offl")]
private void SaveOfflChunk(BinaryStream writer) private void SaveOfflChunk(BinaryStream writer) => writer.WriteStructs(OfflData);
{
writer.WriteStructs(OfflData);
}
[RiffChunkSave("tran")] [RiffChunkSave("tran")]
private void SaveTranChunk(BinaryStream writer) private void SaveTranChunk(BinaryStream writer) => writer.WriteStructs(TranData);
{
writer.WriteStructs(TranData);
}
[RiffChunkSave("unde")] [RiffChunkSave("unde")]
private void SaveUndeChunk(BinaryStream writer) private void SaveUndeChunk(BinaryStream writer) => writer.WriteStructs(UndeData);
{
writer.WriteStructs(UndeData);
}
} }
} }

View File

@ -14,13 +14,13 @@
<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.0</TargetFrameworks> <TargetFrameworks>netstandard2.0</TargetFrameworks>
<Version>2.0.0-alpha1</Version> <Version>2.0.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Syroot.BinaryData.Serialization" Version="5.0.0" /> <PackageReference Include="Syroot.BinaryData.Serialization" Version="5.2.0" />
<PackageReference Include="Syroot.BinaryData" Version="5.1.0" /> <PackageReference Include="Syroot.BinaryData" Version="5.2.0" />
<PackageReference Include="System.Drawing.Common" Version="4.5.1" /> <PackageReference Include="System.Drawing.Common" Version="4.6.0" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" /> <PackageReference Include="System.Text.Encoding.CodePages" Version="4.6.0" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -4,9 +4,9 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" /> <PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" /> <PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<ProjectReference Include="..\..\library\Syroot.Worms.Armageddon.ProjectX\Syroot.Worms.Armageddon.ProjectX.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms.Armageddon.ProjectX\Syroot.Worms.Armageddon.ProjectX.csproj" />
<ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" /> <ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -4,9 +4,9 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" /> <PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" /> <PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<ProjectReference Include="..\..\library\Syroot.Worms.Armageddon\Syroot.Worms.Armageddon.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms.Armageddon\Syroot.Worms.Armageddon.csproj" />
<ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" /> <ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -4,9 +4,9 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" /> <PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" /> <PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -4,9 +4,9 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" /> <PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" /> <PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<ProjectReference Include="..\..\library\Syroot.Worms\Syroot.Worms.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms\Syroot.Worms.csproj" />
</ItemGroup> </ItemGroup>
</Project> </Project>

View File

@ -4,9 +4,9 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" /> <PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" /> <PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<ProjectReference Include="..\..\library\Syroot.Worms.WorldParty\Syroot.Worms.WorldParty.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms.WorldParty\Syroot.Worms.WorldParty.csproj" />
<ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" /> <ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -4,9 +4,9 @@
<IsPackable>false</IsPackable> <IsPackable>false</IsPackable>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" /> <PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" /> <PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" /> <PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
<ProjectReference Include="..\..\library\Syroot.Worms.Worms2\Syroot.Worms.Worms2.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms.Worms2\Syroot.Worms.Worms2.csproj" />
<ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" /> <ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" />
</ItemGroup> </ItemGroup>

View File

@ -33,7 +33,7 @@ namespace Syroot.Worms.Mgame.GameServer
// Retrieve external IP if not yet done and given IP is invalid. // Retrieve external IP if not yet done and given IP is invalid.
if (_ipAddress == null && (IP == null || !IPAddress.TryParse(IP, out _ipAddress))) if (_ipAddress == null && (IP == null || !IPAddress.TryParse(IP, out _ipAddress)))
{ {
using (WebClient webClient = new WebClient()) using WebClient webClient = new WebClient();
_ipAddress = IPAddress.Parse(webClient.DownloadString("https://ip.syroot.com")); _ipAddress = IPAddress.Parse(webClient.DownloadString("https://ip.syroot.com"));
} }
return _ipAddress; return _ipAddress;

View File

@ -91,6 +91,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets
{ {
if (disposing) if (disposing)
TcpClient.Dispose(); TcpClient.Dispose();
_tcpStream.Dispose();
_disposed = true; _disposed = true;
} }
} }
@ -102,10 +103,8 @@ namespace Syroot.Worms.Mgame.GameServer.Packets
{ {
// Let each packet format try to serialize the data. // Let each packet format try to serialize the data.
foreach (IPacketFormat format in _packetFormatPipe) foreach (IPacketFormat format in _packetFormatPipe)
{
if (format.TrySave(_tcpStream, packet)) if (format.TrySave(_tcpStream, packet))
return; return;
}
throw new NotImplementedException("Cannot send unhandled packet format."); throw new NotImplementedException("Cannot send unhandled packet format.");
} }
catch (IOException) { } // A network error appeared, and communication should end. catch (IOException) { } // A network error appeared, and communication should end.

View File

@ -9,7 +9,7 @@ namespace Syroot.Worms.Mgame.GameServer
{ {
// ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- // ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
private static void Main(string[] args) private static void Main()
{ {
try try
{ {

View File

@ -7,11 +7,11 @@
<TargetFrameworks>netcoreapp2.1</TargetFrameworks> <TargetFrameworks>netcoreapp2.1</TargetFrameworks>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.0.0" />
<PackageReference Include="Syroot.BinaryData.Memory" Version="5.2.0-alpha1" /> <PackageReference Include="Syroot.BinaryData.Memory" Version="5.2.2" />
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" /> <PackageReference Include="System.Text.Encoding.CodePages" Version="4.6.0" />
<ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" />
<ProjectReference Include="..\..\library\Syroot.Worms\Syroot.Worms.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms\Syroot.Worms.csproj" />
<None Update="ServerConfig.json"> <None Update="ServerConfig.json">

View File

@ -14,7 +14,7 @@ namespace Syroot.Worms.Mgame.Launcher
{ {
// ---- METHODS (PRIVATE) -------------------------------------------------------------------------------------- // ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
private static void Main(string[] args) private static void Main()
{ {
try try
{ {
@ -36,9 +36,10 @@ namespace Syroot.Worms.Mgame.Launcher
using (launchConfig.CreateMappedFile(config.MappingName)) using (launchConfig.CreateMappedFile(config.MappingName))
{ {
// Create and run the process. // Create and run the process.
NativeProcess process = CreateProcess(executablePath, using (NativeProcess process = CreateProcess(executablePath,
String.Join(" ", config.MappingName, config.ExecutableArgs).TrimEnd(), String.Join(" ", config.MappingName, config.ExecutableArgs).TrimEnd(),
config.StartSuspended); config.StartSuspended))
{
if (config.StartSuspended) if (config.StartSuspended)
{ {
if (ShowMessage(MessageBoxIcon.Information, if (ShowMessage(MessageBoxIcon.Information,
@ -55,6 +56,7 @@ namespace Syroot.Worms.Mgame.Launcher
process.WaitForExit(); process.WaitForExit();
} }
} }
}
catch (Exception ex) catch (Exception ex)
{ {
ShowMessage(MessageBoxIcon.Error, ex.Message, MessageBoxButtons.OK); ShowMessage(MessageBoxIcon.Error, ex.Message, MessageBoxButtons.OK);

View File

@ -15,10 +15,10 @@
<Version>1.0.0</Version> <Version>1.0.0</Version>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Costura.Fody" Version="3.3.0" /> <PackageReference Include="Costura.Fody" Version="4.1.0" />
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" /> <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.0.0" />
<ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" />
<ProjectReference Include="..\..\library\Syroot.Worms\Syroot.Worms.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms\Syroot.Worms.csproj" />
<Reference Include="System.Windows.Forms" /> <Reference Include="System.Windows.Forms" />

View File

@ -4,7 +4,7 @@
<TargetFramework>netcoreapp2.1</TargetFramework> <TargetFramework>netcoreapp2.1</TargetFramework>
</PropertyGroup> </PropertyGroup>
<ItemGroup> <ItemGroup>
<PackageReference Include="Syroot.BinaryData" Version="5.1.0" /> <PackageReference Include="Syroot.BinaryData" Version="5.2.0" />
<ProjectReference Include="..\..\library\Syroot.Worms.Armageddon.ProjectX\Syroot.Worms.Armageddon.ProjectX.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms.Armageddon.ProjectX\Syroot.Worms.Armageddon.ProjectX.csproj" />
<ProjectReference Include="..\..\library\Syroot.Worms.Armageddon\Syroot.Worms.Armageddon.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms.Armageddon\Syroot.Worms.Armageddon.csproj" />
<ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" /> <ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" />