mirror of
https://gitlab.com/Syroot/Worms.git
synced 2025-01-13 07:18:00 +03:00
Review code, update code standards and NuGet packages.
This commit is contained in:
parent
c5391c3d66
commit
e57c593efa
@ -11,31 +11,20 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
|
||||
ByteConverter byteConverter)
|
||||
{
|
||||
ExplosionAction explosionAction;
|
||||
switch (instance)
|
||||
ExplosionAction explosionAction = instance switch
|
||||
{
|
||||
case LauncherStyle launcherStyle:
|
||||
explosionAction = launcherStyle.ExplosionAction;
|
||||
break;
|
||||
case ClusterTarget clusterTarget:
|
||||
explosionAction = clusterTarget.ExplosionAction;
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
switch (explosionAction)
|
||||
LauncherStyle launcherStyle => launcherStyle.ExplosionAction,
|
||||
ClusterTarget clusterTarget => clusterTarget.ExplosionAction,
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
return explosionAction switch
|
||||
{
|
||||
case ExplosionAction.Bounce:
|
||||
return stream.ReadObject<BounceAction>();
|
||||
case ExplosionAction.Dig:
|
||||
return stream.ReadObject<DigAction>();
|
||||
case ExplosionAction.Home:
|
||||
return stream.ReadObject<HomeAction>();
|
||||
case ExplosionAction.Roam:
|
||||
return stream.ReadObject<RoamAction>();
|
||||
}
|
||||
return null;
|
||||
ExplosionAction.Bounce => stream.ReadObject<BounceAction>(),
|
||||
ExplosionAction.Dig => stream.ReadObject<DigAction>(),
|
||||
ExplosionAction.Home => stream.ReadObject<HomeAction>(),
|
||||
ExplosionAction.Roam => stream.ReadObject<RoamAction>(),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,
|
||||
|
@ -1,6 +1,4 @@
|
||||
namespace Syroot.Worms.Armageddon.ProjectX
|
||||
{
|
||||
public interface IAction
|
||||
{
|
||||
}
|
||||
public interface IAction { }
|
||||
}
|
||||
|
@ -25,28 +25,20 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Scheme"/> class.
|
||||
/// </summary>
|
||||
public Library()
|
||||
{
|
||||
}
|
||||
public Library() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Scheme"/> class, loading the data from the given
|
||||
/// <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public Library(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public Library(Stream stream) => Load(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Scheme"/> class, loading the data from the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public Library(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public Library(string fileName) => Load(fileName);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -59,13 +51,7 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// </summary>
|
||||
/// <param name="key">The key of the entries to match.</param>
|
||||
/// <returns>All matching entries.</returns>
|
||||
public IEnumerable<LibraryItem> this[string key]
|
||||
{
|
||||
get
|
||||
{
|
||||
return this.Where(x => x.Key == key);
|
||||
}
|
||||
}
|
||||
public IEnumerable<LibraryItem> this[string key] => this.Where(x => x.Key == key);
|
||||
|
||||
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
||||
|
||||
@ -75,34 +61,31 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
// Read the header.
|
||||
if (reader.ReadInt32() != _signature)
|
||||
{
|
||||
throw new InvalidDataException("Invalid PXL file signature.");
|
||||
}
|
||||
Version = reader.Read1Byte();
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
|
||||
// Read the items.
|
||||
Clear();
|
||||
int itemCount = reader.ReadInt32();
|
||||
for (int i = 0; i < itemCount; i++)
|
||||
// Read the header.
|
||||
if (reader.ReadInt32() != _signature)
|
||||
throw new InvalidDataException("Invalid PXL file signature.");
|
||||
Version = reader.Read1Byte();
|
||||
|
||||
// Read the items.
|
||||
Clear();
|
||||
int itemCount = reader.ReadInt32();
|
||||
for (int i = 0; i < itemCount; i++)
|
||||
{
|
||||
LibraryItemType type = reader.ReadEnum<LibraryItemType>(true);
|
||||
string name = reader.ReadString(StringCoding.Int32CharCount);
|
||||
switch (type)
|
||||
{
|
||||
LibraryItemType type = reader.ReadEnum<LibraryItemType>(true);
|
||||
string name = reader.ReadString(StringCoding.Int32CharCount);
|
||||
switch (type)
|
||||
{
|
||||
case LibraryItemType.File:
|
||||
Add(new LibraryItem(name, reader.ReadBytes(reader.ReadInt32())));
|
||||
break;
|
||||
case LibraryItemType.Script:
|
||||
Add(new LibraryItem(name, reader.ReadString(StringCoding.Int32CharCount)));
|
||||
break;
|
||||
case LibraryItemType.Weapon:
|
||||
Add(new LibraryItem(name, reader.Load<Weapon>()));
|
||||
break;
|
||||
}
|
||||
case LibraryItemType.File:
|
||||
Add(new LibraryItem(name, reader.ReadBytes(reader.ReadInt32())));
|
||||
break;
|
||||
case LibraryItemType.Script:
|
||||
Add(new LibraryItem(name, reader.ReadString(StringCoding.Int32CharCount)));
|
||||
break;
|
||||
case LibraryItemType.Weapon:
|
||||
Add(new LibraryItem(name, reader.Load<Weapon>()));
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,10 +96,8 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -125,32 +106,31 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
|
||||
{
|
||||
// Write the header.
|
||||
writer.Write(_signature);
|
||||
writer.Write(Version);
|
||||
using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
|
||||
|
||||
// Write the items.
|
||||
writer.Write(Count);
|
||||
foreach (LibraryItem item in this)
|
||||
// Write the header.
|
||||
writer.Write(_signature);
|
||||
writer.Write(Version);
|
||||
|
||||
// Write the items.
|
||||
writer.Write(Count);
|
||||
foreach (LibraryItem item in this)
|
||||
{
|
||||
writer.WriteEnum(item.Type, true);
|
||||
writer.Write(item.Key, StringCoding.Int32CharCount);
|
||||
switch (item.Type)
|
||||
{
|
||||
writer.WriteEnum(item.Type, true);
|
||||
writer.Write(item.Key, StringCoding.Int32CharCount);
|
||||
switch (item.Type)
|
||||
{
|
||||
case LibraryItemType.File:
|
||||
byte[] value = (byte[])item.Value;
|
||||
writer.Write(value.Length);
|
||||
writer.WriteStructs(value);
|
||||
break;
|
||||
case LibraryItemType.Script:
|
||||
writer.Write((string)item.Value, StringCoding.Int32CharCount);
|
||||
break;
|
||||
case LibraryItemType.Weapon:
|
||||
writer.Save((Weapon)item.Value);
|
||||
break;
|
||||
}
|
||||
case LibraryItemType.File:
|
||||
byte[] value = (byte[])item.Value;
|
||||
writer.Write(value.Length);
|
||||
writer.WriteStructs(value);
|
||||
break;
|
||||
case LibraryItemType.Script:
|
||||
writer.Write((string)item.Value, StringCoding.Int32CharCount);
|
||||
break;
|
||||
case LibraryItemType.Weapon:
|
||||
writer.Save((Weapon)item.Value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -161,10 +141,8 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
Save(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -172,27 +150,21 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// </summary>
|
||||
/// <returns>The enumeration of attached files.</returns>
|
||||
public IEnumerable<byte[]> GetFiles()
|
||||
{
|
||||
return this.Where(x => x.Type == LibraryItemType.File).Select(x => (byte[])x.Value);
|
||||
}
|
||||
=> this.Where(x => x.Type == LibraryItemType.File).Select(x => (byte[])x.Value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all attached scripts.
|
||||
/// </summary>
|
||||
/// <returns>The enumeration of attached scripts.</returns>
|
||||
public IEnumerable<string> GetScripts()
|
||||
{
|
||||
return this.Where(x => x.Type == LibraryItemType.Script).Select(x => (string)x.Value);
|
||||
}
|
||||
=> this.Where(x => x.Type == LibraryItemType.Script).Select(x => (string)x.Value);
|
||||
|
||||
/// <summary>
|
||||
/// Gets all attached weapons.
|
||||
/// </summary>
|
||||
/// <returns>The enumeration of attached weapons.</returns>
|
||||
public IEnumerable<Weapon> GetWeapons()
|
||||
{
|
||||
return this.Where(x => x.Type == LibraryItemType.Weapon).Select(x => (Weapon)x.Value);
|
||||
}
|
||||
=> this.Where(x => x.Type == LibraryItemType.Weapon).Select(x => (Weapon)x.Value);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -236,29 +208,18 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// </summary>
|
||||
public object Value
|
||||
{
|
||||
get
|
||||
{
|
||||
return _value;
|
||||
}
|
||||
get => _value;
|
||||
set
|
||||
{
|
||||
// Validate the type.
|
||||
if (value.GetType() == typeof(byte[]))
|
||||
{
|
||||
Type = LibraryItemType.File;
|
||||
}
|
||||
else if (value.GetType() == typeof(string))
|
||||
{
|
||||
Type = LibraryItemType.Script;
|
||||
}
|
||||
else if (value.GetType() == typeof(Weapon))
|
||||
{
|
||||
Type = LibraryItemType.Weapon;
|
||||
}
|
||||
else
|
||||
{
|
||||
throw new ArgumentException("Invalid LibraryItemType.", nameof(value));
|
||||
}
|
||||
_value = value;
|
||||
}
|
||||
}
|
||||
|
@ -23,28 +23,20 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Scheme"/> class.
|
||||
/// </summary>
|
||||
public Scheme()
|
||||
{
|
||||
}
|
||||
public Scheme() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Scheme"/> class, loading the data from the given
|
||||
/// <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public Scheme(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public Scheme(Stream stream) => Load(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Scheme"/> class, loading the data from the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public Scheme(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public Scheme(string fileName) => Load(fileName);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -72,59 +64,52 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
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.
|
||||
if (reader.ReadString(_signature.Length) != _signature)
|
||||
throw new InvalidDataException("Invalid PXS file signature.");
|
||||
Version = reader.ReadInt32();
|
||||
|
||||
// Read the scheme flags.
|
||||
Flags = reader.ReadStruct<SchemeFlags>();
|
||||
|
||||
// Read the weapon tables.
|
||||
int weaponTableCount = reader.ReadInt32();
|
||||
WeaponTables = new List<Weapon[]>(weaponTableCount);
|
||||
for (int i = 0; i < weaponTableCount; i++)
|
||||
WeaponTables.Add(reader.Load<Weapon>(_weaponsPerTable));
|
||||
|
||||
// Read a placeholder array.
|
||||
reader.Seek(sizeof(int));
|
||||
|
||||
// Read attached files.
|
||||
int filesCount = reader.ReadInt32();
|
||||
Files = new Dictionary<string, byte[]>(filesCount);
|
||||
for (int i = 0; i < filesCount; i++)
|
||||
{
|
||||
// Read the header.
|
||||
if (reader.ReadString(_signature.Length) != _signature)
|
||||
{
|
||||
throw new InvalidDataException("Invalid PXS file signature.");
|
||||
}
|
||||
Version = reader.ReadInt32();
|
||||
string name = reader.ReadString(StringCoding.Int32CharCount);
|
||||
int length = reader.ReadInt32();
|
||||
Files.Add(name, reader.ReadBytes(length));
|
||||
}
|
||||
|
||||
// Read the scheme flags.
|
||||
Flags = reader.ReadStruct<SchemeFlags>();
|
||||
// Read attached scripts.
|
||||
int scriptsCount = reader.ReadInt32();
|
||||
Scripts = new Dictionary<string, string>(scriptsCount);
|
||||
for (int i = 0; i < scriptsCount; i++)
|
||||
Scripts.Add(reader.ReadString(StringCoding.Int32CharCount),
|
||||
reader.ReadString(StringCoding.Int32CharCount));
|
||||
|
||||
// Read the weapon tables.
|
||||
int weaponTableCount = reader.ReadInt32();
|
||||
WeaponTables = new List<Weapon[]>(weaponTableCount);
|
||||
for (int i = 0; i < weaponTableCount; i++)
|
||||
{
|
||||
WeaponTables.Add(reader.Load<Weapon>(_weaponsPerTable));
|
||||
}
|
||||
// Read required libraries.
|
||||
int librariesCount = reader.ReadInt32();
|
||||
Libraries = new List<string>(reader.ReadStrings(librariesCount, StringCoding.Int32CharCount));
|
||||
|
||||
// Read a placeholder array.
|
||||
reader.Seek(sizeof(int));
|
||||
|
||||
// Read attached files.
|
||||
int filesCount = reader.ReadInt32();
|
||||
Files = new Dictionary<string, byte[]>(filesCount);
|
||||
for (int i = 0; i < filesCount; i++)
|
||||
{
|
||||
string name = reader.ReadString(StringCoding.Int32CharCount);
|
||||
int length = reader.ReadInt32();
|
||||
Files.Add(name, reader.ReadBytes(length));
|
||||
}
|
||||
|
||||
// Read attached scripts.
|
||||
int scriptsCount = reader.ReadInt32();
|
||||
Scripts = new Dictionary<string, string>(scriptsCount);
|
||||
for (int i = 0; i < scriptsCount; i++)
|
||||
{
|
||||
Scripts.Add(reader.ReadString(StringCoding.Int32CharCount),
|
||||
reader.ReadString(StringCoding.Int32CharCount));
|
||||
}
|
||||
|
||||
// Read required libraries.
|
||||
int librariesCount = reader.ReadInt32();
|
||||
Libraries = new List<string>(reader.ReadStrings(librariesCount, StringCoding.Int32CharCount));
|
||||
|
||||
// Read a possibly attached scheme file.
|
||||
if (reader.ReadBoolean())
|
||||
{
|
||||
reader.Seek(sizeof(int)); // Scheme length not required due to intelligent loading.
|
||||
GameScheme = reader.Load<Armageddon.Scheme>();
|
||||
GameSchemeName = reader.ReadString(StringCoding.Int32CharCount);
|
||||
}
|
||||
// Read a possibly attached scheme file.
|
||||
if (reader.ReadBoolean())
|
||||
{
|
||||
reader.Seek(sizeof(int)); // Scheme length not required due to intelligent loading.
|
||||
GameScheme = reader.Load<Armageddon.Scheme>();
|
||||
GameSchemeName = reader.ReadString(StringCoding.Int32CharCount);
|
||||
}
|
||||
}
|
||||
|
||||
@ -134,10 +119,8 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -146,58 +129,55 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
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.
|
||||
writer.Write(_signature, StringCoding.Raw);
|
||||
writer.Write(Version);
|
||||
|
||||
// Write the scheme flags.
|
||||
writer.WriteStruct(Flags);
|
||||
|
||||
// Write the weapon tables.
|
||||
writer.Write(WeaponTables.Count);
|
||||
foreach (Weapon[] weaponTable in WeaponTables)
|
||||
writer.Save(weaponTable);
|
||||
|
||||
// Write a placeholder array.
|
||||
writer.Write(0);
|
||||
|
||||
// Write attached files.
|
||||
writer.Write(Files.Count);
|
||||
foreach (KeyValuePair<string, byte[]> file in Files)
|
||||
{
|
||||
// Write the header.
|
||||
writer.Write(_signature, StringCoding.Raw);
|
||||
writer.Write(Version);
|
||||
writer.Write(file.Key, StringCoding.Int32CharCount);
|
||||
writer.Write(file.Value.Length);
|
||||
writer.WriteStructs(file.Value);
|
||||
}
|
||||
|
||||
// Write the scheme flags.
|
||||
writer.WriteStruct(Flags);
|
||||
// Write attached scripts.
|
||||
writer.Write(Scripts.Count);
|
||||
foreach (KeyValuePair<string, string> script in Scripts)
|
||||
{
|
||||
writer.Write(script.Key, StringCoding.Int32CharCount);
|
||||
writer.Write(script.Value, StringCoding.Int32CharCount);
|
||||
}
|
||||
|
||||
// Write the weapon tables.
|
||||
writer.Write(WeaponTables.Count);
|
||||
foreach (Weapon[] weaponTable in WeaponTables)
|
||||
// Write required libraries.
|
||||
writer.Write(Libraries.Count);
|
||||
writer.Write(Libraries);
|
||||
|
||||
// Write a possibly attached scheme file.
|
||||
if (GameScheme != null)
|
||||
{
|
||||
byte[] schemeBytes;
|
||||
using (MemoryStream schemeStream = new MemoryStream())
|
||||
{
|
||||
writer.Save(weaponTable);
|
||||
}
|
||||
|
||||
// Write a placeholder array.
|
||||
writer.Write(0);
|
||||
|
||||
// Write attached files.
|
||||
writer.Write(Files.Count);
|
||||
foreach (KeyValuePair<string, byte[]> file in Files)
|
||||
{
|
||||
writer.Write(file.Key, StringCoding.Int32CharCount);
|
||||
writer.Write(file.Value.Length);
|
||||
writer.WriteStructs(file.Value);
|
||||
}
|
||||
|
||||
// Write attached scripts.
|
||||
writer.Write(Scripts.Count);
|
||||
foreach (KeyValuePair<string, string> script in Scripts)
|
||||
{
|
||||
writer.Write(script.Key, StringCoding.Int32CharCount);
|
||||
writer.Write(script.Value, StringCoding.Int32CharCount);
|
||||
}
|
||||
|
||||
// Write required libraries.
|
||||
writer.Write(Libraries.Count);
|
||||
writer.Write(Libraries);
|
||||
|
||||
// Write a possibly attached scheme file.
|
||||
if (GameScheme != null)
|
||||
{
|
||||
byte[] schemeBytes;
|
||||
using (MemoryStream schemeStream = new MemoryStream())
|
||||
{
|
||||
GameScheme.Save(schemeStream);
|
||||
schemeBytes = schemeStream.ToArray();
|
||||
}
|
||||
writer.Write(schemeBytes.Length);
|
||||
writer.Write(GameSchemeName, StringCoding.Int32CharCount);
|
||||
GameScheme.Save(schemeStream);
|
||||
schemeBytes = schemeStream.ToArray();
|
||||
}
|
||||
writer.Write(schemeBytes.Length);
|
||||
writer.Write(GameSchemeName, StringCoding.Int32CharCount);
|
||||
}
|
||||
}
|
||||
|
||||
@ -207,10 +187,8 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
Save(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -7,28 +7,21 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
public class AirstrikeSubstyleConverter : IBinaryConverter
|
||||
{
|
||||
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
||||
|
||||
|
||||
public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
|
||||
ByteConverter byteConverter)
|
||||
{
|
||||
WeaponAirstrikeSubstyle airstrikeSubstyle;
|
||||
switch (instance)
|
||||
WeaponAirstrikeSubstyle airstrikeSubstyle = instance switch
|
||||
{
|
||||
case AirstrikeStyle airstrikeStyle:
|
||||
airstrikeSubstyle = airstrikeStyle.AirstrikeSubstyle;
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
switch (airstrikeSubstyle)
|
||||
AirstrikeStyle airstrikeStyle => airstrikeStyle.AirstrikeSubstyle,
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
return airstrikeSubstyle switch
|
||||
{
|
||||
case WeaponAirstrikeSubstyle.Launcher:
|
||||
return stream.ReadObject<LauncherStyle>();
|
||||
case WeaponAirstrikeSubstyle.Mines:
|
||||
return stream.ReadObject<MineStyle>();
|
||||
}
|
||||
return null;
|
||||
WeaponAirstrikeSubstyle.Launcher => stream.ReadObject<LauncherStyle>(),
|
||||
WeaponAirstrikeSubstyle.Mines => stream.ReadObject<MineStyle>(),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,
|
||||
|
@ -1,6 +1,4 @@
|
||||
namespace Syroot.Worms.Armageddon.ProjectX
|
||||
{
|
||||
public interface IStyle
|
||||
{
|
||||
}
|
||||
public interface IStyle { }
|
||||
}
|
||||
|
@ -1,24 +1,24 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Syroot.Worms.Armageddon-ProjectX</AssemblyName>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>.NET library for loading and modifying files of Worms Armageddon ProjectX.</Description>
|
||||
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageIconUrl>https://gitlab.com/Syroot/Worms/raw/master/res/icon.png</PackageIconUrl>
|
||||
<PackageId>Syroot.Worms.Armageddon.ProjectX</PackageId>
|
||||
<PackageLicenseUrl>https://gitlab.com/Syroot/Worms/raw/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://gitlab.com/Syroot/Worms</PackageProjectUrl>
|
||||
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
|
||||
<PackageTags>worms;team17</PackageTags>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
|
||||
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
|
||||
<Version>2.0.0-alpha1</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Syroot.Worms.Armageddon\Syroot.Worms.Armageddon.csproj" />
|
||||
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Syroot.Worms.Armageddon-ProjectX</AssemblyName>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>.NET library for loading and modifying files of Worms Armageddon ProjectX.</Description>
|
||||
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageIconUrl>https://gitlab.com/Syroot/Worms/raw/master/res/icon.png</PackageIconUrl>
|
||||
<PackageId>Syroot.Worms.Armageddon.ProjectX</PackageId>
|
||||
<PackageLicenseUrl>https://gitlab.com/Syroot/Worms/raw/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://gitlab.com/Syroot/Worms</PackageProjectUrl>
|
||||
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
|
||||
<PackageTags>worms;team17</PackageTags>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
|
||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||
<Version>2.0.0-alpha1</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Syroot.Worms.Armageddon\Syroot.Worms.Armageddon.csproj" />
|
||||
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,6 +1,4 @@
|
||||
namespace Syroot.Worms.Armageddon.ProjectX
|
||||
{
|
||||
public interface ITarget
|
||||
{
|
||||
}
|
||||
public interface ITarget { }
|
||||
}
|
||||
|
@ -11,24 +11,17 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
public object Read(Stream stream, object instance, BinaryMemberAttribute memberAttribute,
|
||||
ByteConverter byteConverter)
|
||||
{
|
||||
ExplosionTarget explosionTarget;
|
||||
switch (instance)
|
||||
ExplosionTarget explosionTarget = instance switch
|
||||
{
|
||||
case LauncherStyle launcherStyle:
|
||||
explosionTarget = launcherStyle.ExplosionTarget;
|
||||
break;
|
||||
default:
|
||||
throw new NotImplementedException();
|
||||
}
|
||||
|
||||
switch (explosionTarget)
|
||||
LauncherStyle launcherStyle => launcherStyle.ExplosionTarget,
|
||||
_ => throw new NotImplementedException(),
|
||||
};
|
||||
return explosionTarget switch
|
||||
{
|
||||
case ExplosionTarget.Clusters:
|
||||
return stream.ReadObject<ClusterTarget>();
|
||||
case ExplosionTarget.Fire:
|
||||
return stream.ReadObject<FireTarget>();
|
||||
}
|
||||
return null;
|
||||
ExplosionTarget.Clusters => stream.ReadObject<ClusterTarget>(),
|
||||
ExplosionTarget.Fire => stream.ReadObject<FireTarget>(),
|
||||
_ => null,
|
||||
};
|
||||
}
|
||||
|
||||
public void Write(Stream stream, object instance, BinaryMemberAttribute memberAttribute, object value,
|
||||
|
@ -2,7 +2,6 @@ using System.Diagnostics;
|
||||
using System.IO;
|
||||
using System.Text;
|
||||
using Syroot.BinaryData;
|
||||
using Syroot.Worms.Core;
|
||||
using Syroot.Worms.Core.IO;
|
||||
|
||||
namespace Syroot.Worms.Armageddon.ProjectX
|
||||
@ -114,168 +113,165 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
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.
|
||||
long offset = reader.Position;
|
||||
Version = reader.ReadEnum<WeaponVersion>(true);
|
||||
Checksum = reader.ReadInt64();
|
||||
|
||||
// Read general settings.
|
||||
TableRow = reader.ReadInt32();
|
||||
Remembered = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
UsableInCavern = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
Shots = reader.ReadInt32();
|
||||
ShotEndsTurn = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
RetreatTime = reader.ReadInt32();
|
||||
Unknown1 = reader.ReadInt32();
|
||||
CrateChance = reader.ReadInt32();
|
||||
CrateCount = reader.ReadInt32();
|
||||
Unknown2 = reader.ReadInt32();
|
||||
|
||||
// Read the activation and the corresponding weapon settings.
|
||||
Activation = reader.ReadEnum<WeaponActivation>(false);
|
||||
switch (Activation)
|
||||
{
|
||||
// Read the header.
|
||||
long offset = reader.Position;
|
||||
Version = reader.ReadEnum<WeaponVersion>(true);
|
||||
Checksum = reader.ReadInt64();
|
||||
|
||||
// Read general settings.
|
||||
TableRow = reader.ReadInt32();
|
||||
Remembered = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
UsableInCavern = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
Shots = reader.ReadInt32();
|
||||
ShotEndsTurn = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
RetreatTime = reader.ReadInt32();
|
||||
Unknown1 = reader.ReadInt32();
|
||||
CrateChance = reader.ReadInt32();
|
||||
CrateCount = reader.ReadInt32();
|
||||
Unknown2 = reader.ReadInt32();
|
||||
|
||||
// Read the activation and the corresponding weapon settings.
|
||||
Activation = reader.ReadEnum<WeaponActivation>(false);
|
||||
switch (Activation)
|
||||
{
|
||||
case WeaponActivation.Airstrike:
|
||||
AirstrikeSubtype = reader.ReadInt32();
|
||||
Style = reader.ReadObject<AirstrikeStyle>();
|
||||
break;
|
||||
case WeaponActivation.Crosshair:
|
||||
NotUsed = reader.ReadInt32();
|
||||
CrosshairAction = reader.ReadEnum<WeaponCrosshairAction>(false);
|
||||
switch (CrosshairAction)
|
||||
{
|
||||
case WeaponCrosshairAction.Bow:
|
||||
Style = reader.ReadObject<BowStyle>();
|
||||
break;
|
||||
case WeaponCrosshairAction.Flamethrower:
|
||||
Style = reader.ReadObject<FlamethrowerStyle>();
|
||||
break;
|
||||
case WeaponCrosshairAction.Gun:
|
||||
Style = reader.ReadObject<GunStyle>();
|
||||
break;
|
||||
case WeaponCrosshairAction.Launcher:
|
||||
Style = reader.ReadObject<LauncherStyle>();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WeaponActivation.Spacebar:
|
||||
SpacebarAction = reader.ReadEnum<WeaponSpacebarAction>(false);
|
||||
switch (SpacebarAction)
|
||||
{
|
||||
case WeaponSpacebarAction.Armageddon:
|
||||
Style = reader.ReadObject<LauncherStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.BaseballBat:
|
||||
Style = reader.ReadObject<BaseballBatStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.BattleAxe:
|
||||
Style = reader.ReadObject<BattleAxeStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Blowtorch:
|
||||
Style = reader.ReadObject<BlowtorchStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Dragonball:
|
||||
Style = reader.ReadObject<DragonballStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Firepunch:
|
||||
Style = reader.ReadObject<FirepunchStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Jetpack:
|
||||
Style = reader.ReadObject<JetpackStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Kamikaze:
|
||||
Style = reader.ReadObject<KamikazeStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.NinjaRope:
|
||||
Style = reader.ReadObject<NinjaRopeStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.NuclearTest:
|
||||
Style = reader.ReadObject<NuclearTestStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Parachute:
|
||||
Style = reader.ReadObject<ParachuteStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.PneumaticDrill:
|
||||
Style = reader.ReadObject<PneumaticDrillStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Prod:
|
||||
Style = reader.ReadObject<ProdStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.SuicideBomber:
|
||||
Style = reader.ReadObject<SuicideBomberStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Bungee:
|
||||
case WeaponSpacebarAction.Earthquake:
|
||||
case WeaponSpacebarAction.Freeze:
|
||||
case WeaponSpacebarAction.Girder:
|
||||
case WeaponSpacebarAction.ScalesOfJustice:
|
||||
case WeaponSpacebarAction.SelectWorm:
|
||||
case WeaponSpacebarAction.SkipGo:
|
||||
case WeaponSpacebarAction.Surrender:
|
||||
case WeaponSpacebarAction.Teleport:
|
||||
case WeaponSpacebarAction.Utility:
|
||||
Style = null;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WeaponActivation.Throw:
|
||||
ThrowHerdCount = reader.ReadInt32();
|
||||
ThrowAction = reader.ReadEnum<WeaponThrowAction>(false);
|
||||
switch (ThrowAction)
|
||||
{
|
||||
case WeaponThrowAction.Canister:
|
||||
Style = reader.ReadObject<CanisterStyle>();
|
||||
break;
|
||||
case WeaponThrowAction.Launcher:
|
||||
Style = reader.ReadObject<LauncherStyle>();
|
||||
break;
|
||||
case WeaponThrowAction.Mine:
|
||||
Style = reader.ReadObject<MineStyle>();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Read additional settings.
|
||||
reader.Position = offset + 468;
|
||||
AmmunitionOverride = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
Ammunition = reader.ReadInt32();
|
||||
Unknown3 = reader.ReadInt32();
|
||||
WeaponSprite = reader.ReadInt32();
|
||||
NameLong = reader.ReadString(StringCoding.Int32CharCount);
|
||||
Name = reader.ReadString(StringCoding.Int32CharCount);
|
||||
GridImageFile = reader.ReadString(StringCoding.Int32CharCount);
|
||||
GfxDirectoryFile = reader.ReadString(StringCoding.Int32CharCount);
|
||||
SpriteNames = reader.ReadStrings(5, StringCoding.Int32CharCount);
|
||||
DelayOverride = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
Delay = reader.ReadInt32();
|
||||
|
||||
UseLibrary = reader.ReadBoolean();
|
||||
if (UseLibrary)
|
||||
{
|
||||
LibraryName = reader.ReadString(StringCoding.Int32CharCount);
|
||||
LibraryWeaponName = reader.ReadString(StringCoding.Int32CharCount);
|
||||
}
|
||||
|
||||
AimSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
|
||||
AimSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
|
||||
AimSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
|
||||
PickSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
|
||||
PickSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
|
||||
PickSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
|
||||
FireSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
|
||||
FireSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
|
||||
FireSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
|
||||
AimSpriteOverride = reader.ReadBoolean();
|
||||
PickSpriteOverride = reader.ReadBoolean();
|
||||
FireSpriteOverride = reader.ReadBoolean();
|
||||
if (Version == WeaponVersion.Version_0_8_0)
|
||||
{
|
||||
Utility = reader.ReadBoolean();
|
||||
}
|
||||
case WeaponActivation.Airstrike:
|
||||
AirstrikeSubtype = reader.ReadInt32();
|
||||
Style = reader.ReadObject<AirstrikeStyle>();
|
||||
break;
|
||||
case WeaponActivation.Crosshair:
|
||||
NotUsed = reader.ReadInt32();
|
||||
CrosshairAction = reader.ReadEnum<WeaponCrosshairAction>(false);
|
||||
switch (CrosshairAction)
|
||||
{
|
||||
case WeaponCrosshairAction.Bow:
|
||||
Style = reader.ReadObject<BowStyle>();
|
||||
break;
|
||||
case WeaponCrosshairAction.Flamethrower:
|
||||
Style = reader.ReadObject<FlamethrowerStyle>();
|
||||
break;
|
||||
case WeaponCrosshairAction.Gun:
|
||||
Style = reader.ReadObject<GunStyle>();
|
||||
break;
|
||||
case WeaponCrosshairAction.Launcher:
|
||||
Style = reader.ReadObject<LauncherStyle>();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WeaponActivation.Spacebar:
|
||||
SpacebarAction = reader.ReadEnum<WeaponSpacebarAction>(false);
|
||||
switch (SpacebarAction)
|
||||
{
|
||||
case WeaponSpacebarAction.Armageddon:
|
||||
Style = reader.ReadObject<LauncherStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.BaseballBat:
|
||||
Style = reader.ReadObject<BaseballBatStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.BattleAxe:
|
||||
Style = reader.ReadObject<BattleAxeStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Blowtorch:
|
||||
Style = reader.ReadObject<BlowtorchStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Dragonball:
|
||||
Style = reader.ReadObject<DragonballStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Firepunch:
|
||||
Style = reader.ReadObject<FirepunchStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Jetpack:
|
||||
Style = reader.ReadObject<JetpackStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Kamikaze:
|
||||
Style = reader.ReadObject<KamikazeStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.NinjaRope:
|
||||
Style = reader.ReadObject<NinjaRopeStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.NuclearTest:
|
||||
Style = reader.ReadObject<NuclearTestStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Parachute:
|
||||
Style = reader.ReadObject<ParachuteStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.PneumaticDrill:
|
||||
Style = reader.ReadObject<PneumaticDrillStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Prod:
|
||||
Style = reader.ReadObject<ProdStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.SuicideBomber:
|
||||
Style = reader.ReadObject<SuicideBomberStyle>();
|
||||
break;
|
||||
case WeaponSpacebarAction.Bungee:
|
||||
case WeaponSpacebarAction.Earthquake:
|
||||
case WeaponSpacebarAction.Freeze:
|
||||
case WeaponSpacebarAction.Girder:
|
||||
case WeaponSpacebarAction.ScalesOfJustice:
|
||||
case WeaponSpacebarAction.SelectWorm:
|
||||
case WeaponSpacebarAction.SkipGo:
|
||||
case WeaponSpacebarAction.Surrender:
|
||||
case WeaponSpacebarAction.Teleport:
|
||||
case WeaponSpacebarAction.Utility:
|
||||
Style = null;
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WeaponActivation.Throw:
|
||||
ThrowHerdCount = reader.ReadInt32();
|
||||
ThrowAction = reader.ReadEnum<WeaponThrowAction>(false);
|
||||
switch (ThrowAction)
|
||||
{
|
||||
case WeaponThrowAction.Canister:
|
||||
Style = reader.ReadObject<CanisterStyle>();
|
||||
break;
|
||||
case WeaponThrowAction.Launcher:
|
||||
Style = reader.ReadObject<LauncherStyle>();
|
||||
break;
|
||||
case WeaponThrowAction.Mine:
|
||||
Style = reader.ReadObject<MineStyle>();
|
||||
break;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Read additional settings.
|
||||
reader.Position = offset + 468;
|
||||
AmmunitionOverride = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
Ammunition = reader.ReadInt32();
|
||||
Unknown3 = reader.ReadInt32();
|
||||
WeaponSprite = reader.ReadInt32();
|
||||
NameLong = reader.ReadString(StringCoding.Int32CharCount);
|
||||
Name = reader.ReadString(StringCoding.Int32CharCount);
|
||||
GridImageFile = reader.ReadString(StringCoding.Int32CharCount);
|
||||
GfxDirectoryFile = reader.ReadString(StringCoding.Int32CharCount);
|
||||
SpriteNames = reader.ReadStrings(5, StringCoding.Int32CharCount);
|
||||
DelayOverride = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
Delay = reader.ReadInt32();
|
||||
|
||||
UseLibrary = reader.ReadBoolean();
|
||||
if (UseLibrary)
|
||||
{
|
||||
LibraryName = reader.ReadString(StringCoding.Int32CharCount);
|
||||
LibraryWeaponName = reader.ReadString(StringCoding.Int32CharCount);
|
||||
}
|
||||
|
||||
AimSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
|
||||
AimSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
|
||||
AimSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
|
||||
PickSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
|
||||
PickSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
|
||||
PickSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
|
||||
FireSpriteEven = reader.ReadString(StringCoding.Int32CharCount);
|
||||
FireSpriteUphill = reader.ReadString(StringCoding.Int32CharCount);
|
||||
FireSpriteDownhill = reader.ReadString(StringCoding.Int32CharCount);
|
||||
AimSpriteOverride = reader.ReadBoolean();
|
||||
PickSpriteOverride = reader.ReadBoolean();
|
||||
FireSpriteOverride = reader.ReadBoolean();
|
||||
if (Version == WeaponVersion.Version_0_8_0)
|
||||
Utility = reader.ReadBoolean();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -284,111 +280,104 @@ namespace Syroot.Worms.Armageddon.ProjectX
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
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.
|
||||
long offset = writer.Position;
|
||||
writer.WriteEnum(Version, true);
|
||||
writer.Write(Checksum);
|
||||
|
||||
// Write the general settings.
|
||||
writer.Write(TableRow);
|
||||
writer.Write(Remembered, BooleanCoding.Dword);
|
||||
writer.Write(UsableInCavern, BooleanCoding.Dword);
|
||||
writer.Write(Shots);
|
||||
writer.Write(ShotEndsTurn, BooleanCoding.Dword);
|
||||
writer.Write(RetreatTime);
|
||||
writer.Write(Unknown1);
|
||||
writer.Write(CrateChance);
|
||||
writer.Write(CrateCount);
|
||||
writer.Write(Unknown2);
|
||||
|
||||
// Write the activation and the corresponding weapon settings.
|
||||
writer.WriteEnum(Activation, true);
|
||||
switch (Activation)
|
||||
{
|
||||
// Write the header.
|
||||
long offset = writer.Position;
|
||||
writer.WriteEnum(Version, true);
|
||||
writer.Write(Checksum);
|
||||
|
||||
// Write the general settings.
|
||||
writer.Write(TableRow);
|
||||
writer.Write(Remembered, BooleanCoding.Dword);
|
||||
writer.Write(UsableInCavern, BooleanCoding.Dword);
|
||||
writer.Write(Shots);
|
||||
writer.Write(ShotEndsTurn, BooleanCoding.Dword);
|
||||
writer.Write(RetreatTime);
|
||||
writer.Write(Unknown1);
|
||||
writer.Write(CrateChance);
|
||||
writer.Write(CrateCount);
|
||||
writer.Write(Unknown2);
|
||||
|
||||
// Write the activation and the corresponding weapon settings.
|
||||
writer.WriteEnum(Activation, true);
|
||||
switch (Activation)
|
||||
{
|
||||
case WeaponActivation.Airstrike:
|
||||
writer.Write(AirstrikeSubtype);
|
||||
case WeaponActivation.Airstrike:
|
||||
writer.Write(AirstrikeSubtype);
|
||||
writer.WriteObject(Style);
|
||||
break;
|
||||
case WeaponActivation.Crosshair:
|
||||
writer.Write(NotUsed);
|
||||
writer.WriteEnum(CrosshairAction, true);
|
||||
if (CrosshairAction != WeaponCrosshairAction.None)
|
||||
writer.WriteObject(Style);
|
||||
break;
|
||||
case WeaponActivation.Crosshair:
|
||||
writer.Write(NotUsed);
|
||||
writer.WriteEnum(CrosshairAction, true);
|
||||
if (CrosshairAction != WeaponCrosshairAction.None)
|
||||
{
|
||||
break;
|
||||
case WeaponActivation.Spacebar:
|
||||
writer.WriteEnum(SpacebarAction, true);
|
||||
switch (SpacebarAction)
|
||||
{
|
||||
case WeaponSpacebarAction.Armageddon:
|
||||
case WeaponSpacebarAction.BaseballBat:
|
||||
case WeaponSpacebarAction.BattleAxe:
|
||||
case WeaponSpacebarAction.Blowtorch:
|
||||
case WeaponSpacebarAction.Dragonball:
|
||||
case WeaponSpacebarAction.Firepunch:
|
||||
case WeaponSpacebarAction.Jetpack:
|
||||
case WeaponSpacebarAction.Kamikaze:
|
||||
case WeaponSpacebarAction.NinjaRope:
|
||||
case WeaponSpacebarAction.NuclearTest:
|
||||
case WeaponSpacebarAction.Parachute:
|
||||
case WeaponSpacebarAction.PneumaticDrill:
|
||||
case WeaponSpacebarAction.Prod:
|
||||
case WeaponSpacebarAction.SuicideBomber:
|
||||
writer.WriteObject(Style);
|
||||
}
|
||||
break;
|
||||
case WeaponActivation.Spacebar:
|
||||
writer.WriteEnum(SpacebarAction, true);
|
||||
switch (SpacebarAction)
|
||||
{
|
||||
case WeaponSpacebarAction.Armageddon:
|
||||
case WeaponSpacebarAction.BaseballBat:
|
||||
case WeaponSpacebarAction.BattleAxe:
|
||||
case WeaponSpacebarAction.Blowtorch:
|
||||
case WeaponSpacebarAction.Dragonball:
|
||||
case WeaponSpacebarAction.Firepunch:
|
||||
case WeaponSpacebarAction.Jetpack:
|
||||
case WeaponSpacebarAction.Kamikaze:
|
||||
case WeaponSpacebarAction.NinjaRope:
|
||||
case WeaponSpacebarAction.NuclearTest:
|
||||
case WeaponSpacebarAction.Parachute:
|
||||
case WeaponSpacebarAction.PneumaticDrill:
|
||||
case WeaponSpacebarAction.Prod:
|
||||
case WeaponSpacebarAction.SuicideBomber:
|
||||
writer.WriteObject(Style);
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WeaponActivation.Throw:
|
||||
writer.Write(ThrowHerdCount);
|
||||
writer.WriteEnum(ThrowAction, true);
|
||||
if (ThrowAction != WeaponThrowAction.None)
|
||||
{
|
||||
writer.WriteObject(Style);
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
// Write additional settings.
|
||||
writer.Position = offset + 468;
|
||||
writer.Write(AmmunitionOverride, BooleanCoding.Dword);
|
||||
writer.Write(Ammunition);
|
||||
writer.Write(Unknown3);
|
||||
writer.Write(WeaponSprite);
|
||||
writer.Write(NameLong, StringCoding.Int32CharCount);
|
||||
writer.Write(Name, StringCoding.Int32CharCount);
|
||||
writer.Write(GridImageFile, StringCoding.Int32CharCount);
|
||||
writer.Write(GfxDirectoryFile, StringCoding.Int32CharCount);
|
||||
writer.Write(SpriteNames, StringCoding.Int32CharCount);
|
||||
writer.Write(DelayOverride, BooleanCoding.Dword);
|
||||
writer.Write(Delay);
|
||||
|
||||
writer.Write(UseLibrary);
|
||||
if (UseLibrary)
|
||||
{
|
||||
writer.Write(LibraryName, StringCoding.Int32CharCount);
|
||||
writer.Write(LibraryWeaponName, StringCoding.Int32CharCount);
|
||||
}
|
||||
|
||||
writer.Write(AimSpriteEven, StringCoding.Int32CharCount);
|
||||
writer.Write(AimSpriteUphill, StringCoding.Int32CharCount);
|
||||
writer.Write(AimSpriteDownhill, StringCoding.Int32CharCount);
|
||||
writer.Write(PickSpriteEven, StringCoding.Int32CharCount);
|
||||
writer.Write(PickSpriteUphill, StringCoding.Int32CharCount);
|
||||
writer.Write(PickSpriteDownhill, StringCoding.Int32CharCount);
|
||||
writer.Write(FireSpriteEven, StringCoding.Int32CharCount);
|
||||
writer.Write(FireSpriteUphill, StringCoding.Int32CharCount);
|
||||
writer.Write(FireSpriteDownhill, StringCoding.Int32CharCount);
|
||||
writer.Write(AimSpriteOverride);
|
||||
writer.Write(PickSpriteOverride);
|
||||
writer.Write(FireSpriteOverride);
|
||||
if (Version == WeaponVersion.Version_0_8_0)
|
||||
{
|
||||
writer.Write(Utility);
|
||||
}
|
||||
break;
|
||||
}
|
||||
break;
|
||||
case WeaponActivation.Throw:
|
||||
writer.Write(ThrowHerdCount);
|
||||
writer.WriteEnum(ThrowAction, true);
|
||||
if (ThrowAction != WeaponThrowAction.None)
|
||||
writer.WriteObject(Style);
|
||||
break;
|
||||
}
|
||||
|
||||
// Write additional settings.
|
||||
writer.Position = offset + 468;
|
||||
writer.Write(AmmunitionOverride, BooleanCoding.Dword);
|
||||
writer.Write(Ammunition);
|
||||
writer.Write(Unknown3);
|
||||
writer.Write(WeaponSprite);
|
||||
writer.Write(NameLong, StringCoding.Int32CharCount);
|
||||
writer.Write(Name, StringCoding.Int32CharCount);
|
||||
writer.Write(GridImageFile, StringCoding.Int32CharCount);
|
||||
writer.Write(GfxDirectoryFile, StringCoding.Int32CharCount);
|
||||
writer.Write(SpriteNames, StringCoding.Int32CharCount);
|
||||
writer.Write(DelayOverride, BooleanCoding.Dword);
|
||||
writer.Write(Delay);
|
||||
|
||||
writer.Write(UseLibrary);
|
||||
if (UseLibrary)
|
||||
{
|
||||
writer.Write(LibraryName, StringCoding.Int32CharCount);
|
||||
writer.Write(LibraryWeaponName, StringCoding.Int32CharCount);
|
||||
}
|
||||
|
||||
writer.Write(AimSpriteEven, StringCoding.Int32CharCount);
|
||||
writer.Write(AimSpriteUphill, StringCoding.Int32CharCount);
|
||||
writer.Write(AimSpriteDownhill, StringCoding.Int32CharCount);
|
||||
writer.Write(PickSpriteEven, StringCoding.Int32CharCount);
|
||||
writer.Write(PickSpriteUphill, StringCoding.Int32CharCount);
|
||||
writer.Write(PickSpriteDownhill, StringCoding.Int32CharCount);
|
||||
writer.Write(FireSpriteEven, StringCoding.Int32CharCount);
|
||||
writer.Write(FireSpriteUphill, StringCoding.Int32CharCount);
|
||||
writer.Write(FireSpriteDownhill, StringCoding.Int32CharCount);
|
||||
writer.Write(AimSpriteOverride);
|
||||
writer.Write(PickSpriteOverride);
|
||||
writer.Write(FireSpriteOverride);
|
||||
if (Version == WeaponVersion.Version_0_8_0)
|
||||
writer.Write(Utility);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -16,28 +16,20 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GeneratedMap"/> class.
|
||||
/// </summary>
|
||||
public GeneratedMap()
|
||||
{
|
||||
}
|
||||
public GeneratedMap() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GeneratedMap"/> class, loading the data from the given
|
||||
/// <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public GeneratedMap(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public GeneratedMap(Stream stream) => Load(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="GeneratedMap"/> class, loading the data from the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public GeneratedMap(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public GeneratedMap(string fileName) => Load(fileName);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -54,10 +46,8 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
Settings = reader.ReadStruct<MapGeneratorSettings>();
|
||||
}
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
Settings = reader.ReadStruct<MapGeneratorSettings>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -66,10 +56,8 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -78,10 +66,8 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
|
||||
{
|
||||
writer.WriteStruct(Settings);
|
||||
}
|
||||
using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
|
||||
writer.WriteStruct(Settings);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -90,10 +76,8 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
Save(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,19 +28,13 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public LandData(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public LandData(Stream stream) => Load(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="LandData"/> class, loading the data from the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public LandData(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public LandData(string fileName) => Load(fileName);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -102,31 +96,30 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
// Read the header.
|
||||
if (reader.ReadInt32() != _signature)
|
||||
throw new InvalidDataException("Invalid LND file signature.");
|
||||
int fileSize = reader.ReadInt32();
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
|
||||
// Read the data.
|
||||
Size = reader.ReadStruct<Size>();
|
||||
TopBorder = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
WaterHeight = reader.ReadInt32();
|
||||
Unknown = reader.ReadInt32();
|
||||
// Read the header.
|
||||
if (reader.ReadInt32() != _signature)
|
||||
throw new InvalidDataException("Invalid LND file signature.");
|
||||
int fileSize = reader.ReadInt32();
|
||||
|
||||
// Read the possible object coordinate array.
|
||||
ObjectLocations = reader.ReadStructs<Point>(reader.ReadInt32());
|
||||
// Read the data.
|
||||
Size = reader.ReadStruct<Size>();
|
||||
TopBorder = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
WaterHeight = reader.ReadInt32();
|
||||
Unknown = reader.ReadInt32();
|
||||
|
||||
// Read the image data.
|
||||
Foreground = reader.Load<Img>();
|
||||
CollisionMask = reader.Load<Img>();
|
||||
Background = reader.Load<Img>();
|
||||
// Read the possible object coordinate array.
|
||||
ObjectLocations = reader.ReadStructs<Point>(reader.ReadInt32());
|
||||
|
||||
// Read the file paths.
|
||||
LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);
|
||||
WaterDirPath = reader.ReadString(StringCoding.ByteCharCount);
|
||||
}
|
||||
// Read the image data.
|
||||
Foreground = reader.Load<Img>();
|
||||
CollisionMask = reader.Load<Img>();
|
||||
Background = reader.Load<Img>();
|
||||
|
||||
// Read the file paths.
|
||||
LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);
|
||||
WaterDirPath = reader.ReadString(StringCoding.ByteCharCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -135,8 +128,8 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
Load(stream);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -145,33 +138,32 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
|
||||
{
|
||||
// Write the header.
|
||||
writer.Write(_signature);
|
||||
uint fileSizeOffset = writer.ReserveOffset();
|
||||
using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
|
||||
|
||||
// Write the data.
|
||||
writer.WriteStruct(Size);
|
||||
writer.Write(TopBorder, BooleanCoding.Dword);
|
||||
writer.Write(WaterHeight);
|
||||
writer.Write(Unknown);
|
||||
// Write the header.
|
||||
writer.Write(_signature);
|
||||
uint fileSizeOffset = writer.ReserveOffset();
|
||||
|
||||
// Write the possible object coordinate array.
|
||||
writer.Write(ObjectLocations.Length);
|
||||
writer.WriteStructs(ObjectLocations);
|
||||
// Write the data.
|
||||
writer.WriteStruct(Size);
|
||||
writer.Write(TopBorder, BooleanCoding.Dword);
|
||||
writer.Write(WaterHeight);
|
||||
writer.Write(Unknown);
|
||||
|
||||
// Write the image data.
|
||||
Foreground.Save(writer.BaseStream);
|
||||
CollisionMask.Save(writer.BaseStream);
|
||||
Background.Save(writer.BaseStream);
|
||||
// Write the possible object coordinate array.
|
||||
writer.Write(ObjectLocations.Length);
|
||||
writer.WriteStructs(ObjectLocations);
|
||||
|
||||
// Write the file paths.
|
||||
writer.Write(LandTexturePath, StringCoding.ByteCharCount);
|
||||
writer.Write(WaterDirPath, StringCoding.ByteCharCount);
|
||||
// Write the image data.
|
||||
Foreground.Save(writer.BaseStream);
|
||||
CollisionMask.Save(writer.BaseStream);
|
||||
Background.Save(writer.BaseStream);
|
||||
|
||||
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
|
||||
}
|
||||
// Write the file paths.
|
||||
writer.Write(LandTexturePath, StringCoding.ByteCharCount);
|
||||
writer.Write(WaterDirPath, StringCoding.ByteCharCount);
|
||||
|
||||
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -180,8 +172,8 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
Save(stream);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -99,19 +99,13 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public Scheme(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public Scheme(Stream stream) => Load(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Scheme"/> class, loading the data from the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public Scheme(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public Scheme(string fileName) => Load(fileName);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -229,16 +223,11 @@ namespace Syroot.Worms.Armageddon
|
||||
/// </summary>
|
||||
public byte MineDelay
|
||||
{
|
||||
get
|
||||
{
|
||||
return _mineDelay;
|
||||
}
|
||||
get => _mineDelay;
|
||||
set
|
||||
{
|
||||
if (value == 4 || value > 0x7F)
|
||||
{
|
||||
throw new ArgumentException("Mine delay must be between 0-127 and not be 4.", nameof(value));
|
||||
}
|
||||
_mineDelay = value;
|
||||
}
|
||||
}
|
||||
@ -270,16 +259,11 @@ namespace Syroot.Worms.Armageddon
|
||||
/// </summary>
|
||||
public byte TurnTime
|
||||
{
|
||||
get
|
||||
{
|
||||
return _turnTime;
|
||||
}
|
||||
get => _turnTime;
|
||||
set
|
||||
{
|
||||
if (value > 0x7F)
|
||||
{
|
||||
throw new ArgumentException("Turn time must be between 0-127.", nameof(value));
|
||||
}
|
||||
_turnTime = value;
|
||||
}
|
||||
}
|
||||
@ -295,16 +279,11 @@ namespace Syroot.Worms.Armageddon
|
||||
/// </summary>
|
||||
public byte RoundTimeMinutes
|
||||
{
|
||||
get
|
||||
{
|
||||
return _roundTimeMinutes;
|
||||
}
|
||||
get => _roundTimeMinutes;
|
||||
set
|
||||
{
|
||||
if (value > 0x7F)
|
||||
{
|
||||
throw new ArgumentException("Round time must be between 0-127 minutes.", nameof(value));
|
||||
}
|
||||
_roundTimeMinutes = value;
|
||||
}
|
||||
}
|
||||
@ -315,16 +294,11 @@ namespace Syroot.Worms.Armageddon
|
||||
/// </summary>
|
||||
public byte RoundTimeSeconds
|
||||
{
|
||||
get
|
||||
{
|
||||
return _roundTimeSeconds;
|
||||
}
|
||||
get => _roundTimeSeconds;
|
||||
set
|
||||
{
|
||||
if (value > 0x80)
|
||||
{
|
||||
throw new ArgumentException("Round time must be between 0-128 seconds.", nameof(value));
|
||||
}
|
||||
_roundTimeSeconds = value;
|
||||
}
|
||||
}
|
||||
@ -334,16 +308,11 @@ namespace Syroot.Worms.Armageddon
|
||||
/// </summary>
|
||||
public byte NumberOfWins
|
||||
{
|
||||
get
|
||||
{
|
||||
return _numberOfWins;
|
||||
}
|
||||
get => _numberOfWins;
|
||||
set
|
||||
{
|
||||
if (value == 0)
|
||||
{
|
||||
throw new ArgumentException("Number of wins must not be 0.", nameof(value));
|
||||
}
|
||||
_numberOfWins = value;
|
||||
}
|
||||
}
|
||||
@ -486,10 +455,7 @@ namespace Syroot.Worms.Armageddon
|
||||
/// </summary>
|
||||
public sbyte RwGravity
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rwGravity;
|
||||
}
|
||||
get => _rwGravity;
|
||||
set
|
||||
{
|
||||
if (value != 0)
|
||||
@ -507,10 +473,7 @@ namespace Syroot.Worms.Armageddon
|
||||
/// </summary>
|
||||
public sbyte RwGravityConstBlackHole
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rwGravityConstBlackHole;
|
||||
}
|
||||
get => _rwGravityConstBlackHole;
|
||||
set
|
||||
{
|
||||
if (value != 0)
|
||||
@ -529,10 +492,7 @@ namespace Syroot.Worms.Armageddon
|
||||
/// </summary>
|
||||
public sbyte RwGravityPropBlackHole
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rwGravityPropBlackHole;
|
||||
}
|
||||
get => _rwGravityPropBlackHole;
|
||||
set
|
||||
{
|
||||
if (value != 0)
|
||||
@ -550,16 +510,11 @@ namespace Syroot.Worms.Armageddon
|
||||
/// </summary>
|
||||
public byte RwKaosMod
|
||||
{
|
||||
get
|
||||
{
|
||||
return _rwKaosMod;
|
||||
}
|
||||
get => _rwKaosMod;
|
||||
set
|
||||
{
|
||||
if (value > 0xF)
|
||||
{
|
||||
throw new ArgumentException("Kaos mod must not be greater than 15.");
|
||||
}
|
||||
_rwKaosMod = value;
|
||||
}
|
||||
}
|
||||
@ -650,66 +605,61 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
// Read the header.
|
||||
if (reader.ReadString(_signature.Length) != _signature)
|
||||
{
|
||||
throw new InvalidDataException("Invalid WSC file signature.");
|
||||
}
|
||||
Version = reader.ReadEnum<SchemeVersion>(true);
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
|
||||
// Read the options.
|
||||
HotSeatDelay = reader.Read1Byte();
|
||||
RetreatTime = reader.Read1Byte();
|
||||
RetreatTimeRope = reader.Read1Byte();
|
||||
ShowRoundTime = reader.ReadBoolean();
|
||||
AutomaticReplays = reader.ReadBoolean();
|
||||
FallDamage = (SchemeFallDamage)(reader.ReadByte() * 50 % 0x100 * 2);
|
||||
ArtilleryMode = reader.ReadBoolean();
|
||||
SchemeEditor = reader.ReadEnum<SchemeEditor>(false);
|
||||
StockpilingMode = reader.ReadEnum<SchemeStockpiling>(true);
|
||||
WormSelectMode = reader.ReadEnum<SchemeWormSelect>(true);
|
||||
SuddenDeathEvent = reader.ReadEnum<SchemeSuddenDeathEvent>(true);
|
||||
WaterRiseRate = (SchemeWaterRise)(Math.Pow(reader.ReadByte(), 2) * 5 % 0x100);
|
||||
WeaponCrateProbability = reader.ReadSByte();
|
||||
DonorCards = reader.ReadBoolean();
|
||||
HealthCrateProbability = reader.ReadSByte();
|
||||
HealthCrateEnergy = reader.Read1Byte();
|
||||
UtilityCrateProbability = reader.ReadSByte();
|
||||
LoadObjectTypesAndCount(reader);
|
||||
LoadMineDelayConfig(reader);
|
||||
DudMines = reader.ReadBoolean();
|
||||
ManualWormPlacement = reader.ReadBoolean();
|
||||
WormEnergy = reader.Read1Byte();
|
||||
LoadTurnTimeConfig(reader);
|
||||
LoadRoundTimeConfig(reader);
|
||||
NumberOfWins = (byte)Math.Max(1, reader.ReadByte());
|
||||
Blood = reader.ReadBoolean();
|
||||
AquaSheep = reader.ReadBoolean();
|
||||
SheepHeaven = reader.ReadBoolean();
|
||||
GodWorms = reader.ReadBoolean();
|
||||
IndestructibleLand = reader.ReadBoolean();
|
||||
UpgradedGrenade = reader.ReadBoolean();
|
||||
UpgradedShotgun = reader.ReadBoolean();
|
||||
UpgradedCluster = reader.ReadBoolean();
|
||||
UpgradedLongbow = reader.ReadBoolean();
|
||||
EnableTeamWeapons = reader.ReadBoolean();
|
||||
EnableSuperWeapons = reader.ReadBoolean();
|
||||
// Read the header.
|
||||
if (reader.ReadString(_signature.Length) != _signature)
|
||||
throw new InvalidDataException("Invalid WSC file signature.");
|
||||
Version = reader.ReadEnum<SchemeVersion>(true);
|
||||
|
||||
// Read the weapon settings. Old versions do not store super weapon settings.
|
||||
Weapons = new SchemeWeaponSetting[64];
|
||||
int weaponCount = GetWeaponCount();
|
||||
for (int i = 0; i < weaponCount; i++)
|
||||
{
|
||||
Weapons[i] = reader.ReadStruct<SchemeWeaponSetting>();
|
||||
}
|
||||
// Read the options.
|
||||
HotSeatDelay = reader.Read1Byte();
|
||||
RetreatTime = reader.Read1Byte();
|
||||
RetreatTimeRope = reader.Read1Byte();
|
||||
ShowRoundTime = reader.ReadBoolean();
|
||||
AutomaticReplays = reader.ReadBoolean();
|
||||
FallDamage = (SchemeFallDamage)(reader.ReadByte() * 50 % 0x100 * 2);
|
||||
ArtilleryMode = reader.ReadBoolean();
|
||||
SchemeEditor = reader.ReadEnum<SchemeEditor>(false);
|
||||
StockpilingMode = reader.ReadEnum<SchemeStockpiling>(true);
|
||||
WormSelectMode = reader.ReadEnum<SchemeWormSelect>(true);
|
||||
SuddenDeathEvent = reader.ReadEnum<SchemeSuddenDeathEvent>(true);
|
||||
WaterRiseRate = (SchemeWaterRise)(Math.Pow(reader.ReadByte(), 2) * 5 % 0x100);
|
||||
WeaponCrateProbability = reader.ReadSByte();
|
||||
DonorCards = reader.ReadBoolean();
|
||||
HealthCrateProbability = reader.ReadSByte();
|
||||
HealthCrateEnergy = reader.Read1Byte();
|
||||
UtilityCrateProbability = reader.ReadSByte();
|
||||
LoadObjectTypesAndCount(reader);
|
||||
LoadMineDelayConfig(reader);
|
||||
DudMines = reader.ReadBoolean();
|
||||
ManualWormPlacement = reader.ReadBoolean();
|
||||
WormEnergy = reader.Read1Byte();
|
||||
LoadTurnTimeConfig(reader);
|
||||
LoadRoundTimeConfig(reader);
|
||||
NumberOfWins = (byte)Math.Max(1, reader.ReadByte());
|
||||
Blood = reader.ReadBoolean();
|
||||
AquaSheep = reader.ReadBoolean();
|
||||
SheepHeaven = reader.ReadBoolean();
|
||||
GodWorms = reader.ReadBoolean();
|
||||
IndestructibleLand = reader.ReadBoolean();
|
||||
UpgradedGrenade = reader.ReadBoolean();
|
||||
UpgradedShotgun = reader.ReadBoolean();
|
||||
UpgradedCluster = reader.ReadBoolean();
|
||||
UpgradedLongbow = reader.ReadBoolean();
|
||||
EnableTeamWeapons = reader.ReadBoolean();
|
||||
EnableSuperWeapons = reader.ReadBoolean();
|
||||
|
||||
// Ignore possible unknown WWP trash at the end of the file.
|
||||
// Read the weapon settings. Old versions do not store super weapon settings.
|
||||
Weapons = new SchemeWeaponSetting[64];
|
||||
int weaponCount = GetWeaponCount();
|
||||
for (int i = 0; i < weaponCount; i++)
|
||||
Weapons[i] = reader.ReadStruct<SchemeWeaponSetting>();
|
||||
|
||||
// Parse the RubberWorm settings.
|
||||
LoadRubberWormSettings();
|
||||
}
|
||||
// Ignore possible unknown WWP trash at the end of the file.
|
||||
|
||||
// Parse the RubberWorm settings.
|
||||
LoadRubberWormSettings();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -718,20 +668,15 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the data into the given <paramref name="stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
Save(stream, SchemeSaveFormat.ExtendedWithObjectCount);
|
||||
}
|
||||
public void Save(Stream stream) => Save(stream, SchemeSaveFormat.ExtendedWithObjectCount);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the data into the given <paramref name="stream"/> with the specified <paramref name="format"/>.
|
||||
@ -740,72 +685,64 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="format">The <see cref="SchemeSaveFormat"/> to respect when storing the settings.</param>
|
||||
public void Save(Stream stream, SchemeSaveFormat format)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
|
||||
{
|
||||
// Write the header.
|
||||
writer.Write(_signature, StringCoding.Raw);
|
||||
writer.Write((byte)Version);
|
||||
using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
|
||||
|
||||
// Write the options.
|
||||
writer.Write(HotSeatDelay);
|
||||
writer.Write(RetreatTime);
|
||||
writer.Write(RetreatTimeRope);
|
||||
writer.Write(ShowRoundTime);
|
||||
writer.Write(AutomaticReplays);
|
||||
writer.Write((byte)((int)FallDamage / 4 * 41 % 0x80));
|
||||
writer.Write(ArtilleryMode);
|
||||
writer.WriteEnum(SchemeEditor, false);
|
||||
writer.WriteEnum(StockpilingMode, true);
|
||||
writer.WriteEnum(WormSelectMode, true);
|
||||
writer.WriteEnum(SuddenDeathEvent, true);
|
||||
writer.Write(_mapWaterRiseToRaw[(byte)WaterRiseRate]);
|
||||
writer.Write(WeaponCrateProbability);
|
||||
writer.Write(DonorCards);
|
||||
writer.Write(HealthCrateProbability);
|
||||
writer.Write(HealthCrateEnergy);
|
||||
writer.Write(UtilityCrateProbability);
|
||||
SaveObjectTypesAndCount(writer, format);
|
||||
SaveMineDelayConfig(writer);
|
||||
writer.Write(DudMines);
|
||||
writer.Write(ManualWormPlacement);
|
||||
writer.Write(WormEnergy);
|
||||
SaveTurnTimeConfig(writer);
|
||||
SaveRoundTimeConfig(writer);
|
||||
writer.Write(NumberOfWins);
|
||||
writer.Write(Blood);
|
||||
writer.Write(AquaSheep);
|
||||
writer.Write(SheepHeaven);
|
||||
writer.Write(GodWorms);
|
||||
writer.Write(IndestructibleLand);
|
||||
writer.Write(UpgradedGrenade);
|
||||
writer.Write(UpgradedShotgun);
|
||||
writer.Write(UpgradedCluster);
|
||||
writer.Write(UpgradedLongbow);
|
||||
writer.Write(EnableTeamWeapons);
|
||||
writer.Write(EnableSuperWeapons);
|
||||
// Write the header.
|
||||
writer.Write(_signature, StringCoding.Raw);
|
||||
writer.Write((byte)Version);
|
||||
|
||||
// Transfer the RubberWorm settings to unused weapon configuration.
|
||||
SaveRubberWormSettings();
|
||||
// Write the options.
|
||||
writer.Write(HotSeatDelay);
|
||||
writer.Write(RetreatTime);
|
||||
writer.Write(RetreatTimeRope);
|
||||
writer.Write(ShowRoundTime);
|
||||
writer.Write(AutomaticReplays);
|
||||
writer.Write((byte)((int)FallDamage / 4 * 41 % 0x80));
|
||||
writer.Write(ArtilleryMode);
|
||||
writer.WriteEnum(SchemeEditor, false);
|
||||
writer.WriteEnum(StockpilingMode, true);
|
||||
writer.WriteEnum(WormSelectMode, true);
|
||||
writer.WriteEnum(SuddenDeathEvent, true);
|
||||
writer.Write(_mapWaterRiseToRaw[(byte)WaterRiseRate]);
|
||||
writer.Write(WeaponCrateProbability);
|
||||
writer.Write(DonorCards);
|
||||
writer.Write(HealthCrateProbability);
|
||||
writer.Write(HealthCrateEnergy);
|
||||
writer.Write(UtilityCrateProbability);
|
||||
SaveObjectTypesAndCount(writer, format);
|
||||
SaveMineDelayConfig(writer);
|
||||
writer.Write(DudMines);
|
||||
writer.Write(ManualWormPlacement);
|
||||
writer.Write(WormEnergy);
|
||||
SaveTurnTimeConfig(writer);
|
||||
SaveRoundTimeConfig(writer);
|
||||
writer.Write(NumberOfWins);
|
||||
writer.Write(Blood);
|
||||
writer.Write(AquaSheep);
|
||||
writer.Write(SheepHeaven);
|
||||
writer.Write(GodWorms);
|
||||
writer.Write(IndestructibleLand);
|
||||
writer.Write(UpgradedGrenade);
|
||||
writer.Write(UpgradedShotgun);
|
||||
writer.Write(UpgradedCluster);
|
||||
writer.Write(UpgradedLongbow);
|
||||
writer.Write(EnableTeamWeapons);
|
||||
writer.Write(EnableSuperWeapons);
|
||||
|
||||
// Write the weapon settings. Old versions do not store super weapon settings.
|
||||
int weaponCount = GetWeaponCount();
|
||||
foreach (SchemeWeaponSetting weapon in Weapons)
|
||||
{
|
||||
writer.WriteStruct(weapon);
|
||||
}
|
||||
// Transfer the RubberWorm settings to unused weapon configuration.
|
||||
SaveRubberWormSettings();
|
||||
|
||||
// Ignore possible unknown WWP trash at the end of the file.
|
||||
}
|
||||
// Write the weapon settings. Old versions do not store super weapon settings.
|
||||
int weaponCount = GetWeaponCount();
|
||||
foreach (SchemeWeaponSetting weapon in Weapons)
|
||||
writer.WriteStruct(weapon);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the data in the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
Save(fileName, SchemeSaveFormat.ExtendedWithObjectCount);
|
||||
}
|
||||
public void Save(string fileName) => Save(fileName, SchemeSaveFormat.ExtendedWithObjectCount);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the data in the given file with the specified <paramref name="format"/>.
|
||||
@ -814,10 +751,8 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="format">The <see cref="SchemeSaveFormat"/> to respect when storing the settings.</param>
|
||||
public void Save(string fileName, SchemeSaveFormat format)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
Save(stream, format);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream, format);
|
||||
}
|
||||
|
||||
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
|
||||
@ -942,13 +877,9 @@ namespace Syroot.Worms.Armageddon
|
||||
if (mailStrikeProb.GetBit(7))
|
||||
{
|
||||
if (mailStrikeProb.GetBit(6))
|
||||
{
|
||||
RwGravityPropBlackHole = mailStrikeProb.DecodeSByte(6);
|
||||
}
|
||||
else
|
||||
{
|
||||
RwGravityConstBlackHole = mailStrikeProb.DecodeSByte(6);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1019,37 +950,25 @@ namespace Syroot.Worms.Armageddon
|
||||
private void SaveMineDelayConfig(BinaryStream writer)
|
||||
{
|
||||
if (MineDelayRandom)
|
||||
{
|
||||
writer.Write((byte)4);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(MineDelay);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveTurnTimeConfig(BinaryStream writer)
|
||||
{
|
||||
if (TurnTimeInfinite)
|
||||
{
|
||||
writer.Write((byte)0xFF);
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(TurnTime);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveRoundTimeConfig(BinaryStream writer)
|
||||
{
|
||||
if (RoundTimeSeconds > 0)
|
||||
{
|
||||
writer.Write((byte)(0xFF - (RoundTimeSeconds - 1)));
|
||||
}
|
||||
else
|
||||
{
|
||||
writer.Write(RoundTimeMinutes);
|
||||
}
|
||||
}
|
||||
|
||||
private void SaveRubberWormSettings()
|
||||
|
@ -1,23 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Syroot.Worms.Armageddon</AssemblyName>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>.NET library for loading and modifying files of Team17's Worms Armageddon.</Description>
|
||||
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageIconUrl>https://gitlab.com/Syroot/Worms/raw/master/res/icon.png</PackageIconUrl>
|
||||
<PackageId>Syroot.Worms.Armageddon</PackageId>
|
||||
<PackageLicenseUrl>https://gitlab.com/Syroot/Worms/raw/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://gitlab.com/Syroot/Worms</PackageProjectUrl>
|
||||
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
|
||||
<PackageTags>worms;team17</PackageTags>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
|
||||
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
|
||||
<Version>2.0.0-alpha1</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Syroot.Worms.Armageddon</AssemblyName>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>.NET library for loading and modifying files of Team17's Worms Armageddon.</Description>
|
||||
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageIconUrl>https://gitlab.com/Syroot/Worms/raw/master/res/icon.png</PackageIconUrl>
|
||||
<PackageId>Syroot.Worms.Armageddon</PackageId>
|
||||
<PackageLicenseUrl>https://gitlab.com/Syroot/Worms/raw/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://gitlab.com/Syroot/Worms</PackageProjectUrl>
|
||||
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
|
||||
<PackageTags>worms;team17</PackageTags>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
|
||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||
<Version>2.0.0-alpha1</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -196,59 +196,58 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
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);
|
||||
WormNames = reader.ReadStrings(8, 17);
|
||||
CpuLevel = reader.Read1Byte();
|
||||
SoundBankName = reader.ReadString(0x20);
|
||||
SoundBankLocation = reader.Read1Byte();
|
||||
FanfareName = reader.ReadString(0x20);
|
||||
UseCustomFanfare = reader.Read1Byte();
|
||||
|
||||
GraveSprite = reader.ReadSByte();
|
||||
if (GraveSprite < 0)
|
||||
{
|
||||
Name = reader.ReadString(17);
|
||||
WormNames = reader.ReadStrings(8, 17);
|
||||
CpuLevel = reader.Read1Byte();
|
||||
SoundBankName = reader.ReadString(0x20);
|
||||
SoundBankLocation = reader.Read1Byte();
|
||||
FanfareName = reader.ReadString(0x20);
|
||||
UseCustomFanfare = reader.Read1Byte();
|
||||
|
||||
GraveSprite = reader.ReadSByte();
|
||||
if (GraveSprite < 0)
|
||||
{
|
||||
GraveFileName = reader.ReadString(0x20);
|
||||
Grave = new RawBitmap()
|
||||
{
|
||||
BitsPerPixel = 8,
|
||||
Size = new Size(24, 32),
|
||||
Palette = reader.ReadStructs<Color>(256),
|
||||
Data = reader.ReadBytes(24 * 32)
|
||||
};
|
||||
}
|
||||
|
||||
TeamWeapon = reader.ReadEnum<TeamWeapon>(true);
|
||||
GamesLost = reader.ReadInt32();
|
||||
DeathmatchesLost = reader.ReadInt32();
|
||||
GamesWon = reader.ReadInt32();
|
||||
DeathmatchesWon = reader.ReadInt32();
|
||||
GamesDrawn = reader.ReadInt32();
|
||||
DeathmatchesDrawn = reader.ReadInt32();
|
||||
Kills = reader.ReadInt32();
|
||||
DeathmatchKills = reader.ReadInt32();
|
||||
Deaths = reader.ReadInt32();
|
||||
DeathmatchDeaths = reader.ReadInt32();
|
||||
MissionStatuses = reader.ReadStructs<TeamMissionStatus>(_missionCount);
|
||||
|
||||
FlagFileName = reader.ReadString(0x20);
|
||||
Flag = new RawBitmap()
|
||||
GraveFileName = reader.ReadString(0x20);
|
||||
Grave = new RawBitmap()
|
||||
{
|
||||
BitsPerPixel = 8,
|
||||
Size = new Size(20, 17),
|
||||
Size = new Size(24, 32),
|
||||
Palette = reader.ReadStructs<Color>(256),
|
||||
Data = reader.ReadBytes(20 * 17)
|
||||
Data = reader.ReadBytes(24 * 32)
|
||||
};
|
||||
|
||||
DeathmatchRank = reader.Read1Byte();
|
||||
TrainingMissionTimes = reader.ReadInt32s(_trainingMissionCount);
|
||||
Unknown1 = reader.ReadInt32s(10);
|
||||
TrainingMissionMedals = reader.ReadBytes(_trainingMissionCount);
|
||||
Unknown2 = reader.ReadBytes(10);
|
||||
Unknown3 = reader.ReadInt32s(7);
|
||||
Unknown4 = reader.Read1Byte();
|
||||
}
|
||||
|
||||
TeamWeapon = reader.ReadEnum<TeamWeapon>(true);
|
||||
GamesLost = reader.ReadInt32();
|
||||
DeathmatchesLost = reader.ReadInt32();
|
||||
GamesWon = reader.ReadInt32();
|
||||
DeathmatchesWon = reader.ReadInt32();
|
||||
GamesDrawn = reader.ReadInt32();
|
||||
DeathmatchesDrawn = reader.ReadInt32();
|
||||
Kills = reader.ReadInt32();
|
||||
DeathmatchKills = reader.ReadInt32();
|
||||
Deaths = reader.ReadInt32();
|
||||
DeathmatchDeaths = reader.ReadInt32();
|
||||
MissionStatuses = reader.ReadStructs<TeamMissionStatus>(_missionCount);
|
||||
|
||||
FlagFileName = reader.ReadString(0x20);
|
||||
Flag = new RawBitmap()
|
||||
{
|
||||
BitsPerPixel = 8,
|
||||
Size = new Size(20, 17),
|
||||
Palette = reader.ReadStructs<Color>(256),
|
||||
Data = reader.ReadBytes(20 * 17)
|
||||
};
|
||||
|
||||
DeathmatchRank = reader.Read1Byte();
|
||||
TrainingMissionTimes = reader.ReadInt32s(_trainingMissionCount);
|
||||
Unknown1 = reader.ReadInt32s(10);
|
||||
TrainingMissionMedals = reader.ReadBytes(_trainingMissionCount);
|
||||
Unknown2 = reader.ReadBytes(10);
|
||||
Unknown3 = reader.ReadInt32s(7);
|
||||
Unknown4 = reader.Read1Byte();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -257,49 +256,48 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
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.WriteStrings(WormNames, 17);
|
||||
writer.Write(CpuLevel);
|
||||
writer.WriteString(SoundBankName, 0x20);
|
||||
writer.Write(SoundBankLocation);
|
||||
writer.WriteString(FanfareName, 0x20);
|
||||
writer.Write(UseCustomFanfare);
|
||||
|
||||
writer.Write(GraveSprite);
|
||||
if (GraveSprite < 0)
|
||||
{
|
||||
writer.WriteString(Name, 17);
|
||||
writer.WriteStrings(WormNames, 17);
|
||||
writer.Write(CpuLevel);
|
||||
writer.WriteString(SoundBankName, 0x20);
|
||||
writer.Write(SoundBankLocation);
|
||||
writer.WriteString(FanfareName, 0x20);
|
||||
writer.Write(UseCustomFanfare);
|
||||
|
||||
writer.Write(GraveSprite);
|
||||
if (GraveSprite < 0)
|
||||
{
|
||||
writer.WriteString(GraveFileName, 0x20);
|
||||
writer.WriteStructs(Grave.Palette);
|
||||
writer.Write(Grave.Data);
|
||||
}
|
||||
|
||||
writer.WriteEnum(TeamWeapon, true);
|
||||
writer.Write(GamesLost);
|
||||
writer.Write(DeathmatchesLost);
|
||||
writer.Write(GamesWon);
|
||||
writer.Write(DeathmatchesWon);
|
||||
writer.Write(GamesDrawn);
|
||||
writer.Write(DeathmatchesDrawn);
|
||||
writer.Write(Kills);
|
||||
writer.Write(DeathmatchKills);
|
||||
writer.Write(Deaths);
|
||||
writer.Write(DeathmatchDeaths);
|
||||
writer.WriteStructs(MissionStatuses);
|
||||
|
||||
writer.WriteString(FlagFileName, 0x20);
|
||||
writer.WriteStructs(Flag.Palette);
|
||||
writer.Write(Flag.Data);
|
||||
|
||||
writer.Write(DeathmatchRank);
|
||||
writer.Write(TrainingMissionTimes);
|
||||
writer.Write(Unknown1);
|
||||
writer.Write(TrainingMissionMedals);
|
||||
writer.Write(Unknown2);
|
||||
writer.Write(Unknown3);
|
||||
writer.Write(Unknown4);
|
||||
writer.WriteString(GraveFileName, 0x20);
|
||||
writer.WriteStructs(Grave.Palette);
|
||||
writer.Write(Grave.Data);
|
||||
}
|
||||
|
||||
writer.WriteEnum(TeamWeapon, true);
|
||||
writer.Write(GamesLost);
|
||||
writer.Write(DeathmatchesLost);
|
||||
writer.Write(GamesWon);
|
||||
writer.Write(DeathmatchesWon);
|
||||
writer.Write(GamesDrawn);
|
||||
writer.Write(DeathmatchesDrawn);
|
||||
writer.Write(Kills);
|
||||
writer.Write(DeathmatchKills);
|
||||
writer.Write(Deaths);
|
||||
writer.Write(DeathmatchDeaths);
|
||||
writer.WriteStructs(MissionStatuses);
|
||||
|
||||
writer.WriteString(FlagFileName, 0x20);
|
||||
writer.WriteStructs(Flag.Palette);
|
||||
writer.Write(Flag.Data);
|
||||
|
||||
writer.Write(DeathmatchRank);
|
||||
writer.Write(TrainingMissionTimes);
|
||||
writer.Write(Unknown1);
|
||||
writer.Write(TrainingMissionMedals);
|
||||
writer.Write(Unknown2);
|
||||
writer.Write(Unknown3);
|
||||
writer.Write(Unknown4);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -22,29 +22,20 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TeamContainer"/> class.
|
||||
/// </summary>
|
||||
public TeamContainer()
|
||||
{
|
||||
Teams = new List<Team>();
|
||||
}
|
||||
public TeamContainer() => Teams = new List<Team>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TeamContainer"/> class, loading the data from the given
|
||||
/// <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public TeamContainer(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public TeamContainer(Stream stream) => Load(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TeamContainer"/> class, loading the data from the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public TeamContainer(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public TeamContainer(string fileName) => Load(fileName);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -76,23 +67,20 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
// Read the header.
|
||||
if (reader.ReadString(StringCoding.ZeroTerminated) != _signature)
|
||||
{
|
||||
throw new InvalidDataException("Invalid WGT file signature.");
|
||||
}
|
||||
Version = reader.Read1Byte(); // Really version?
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
|
||||
// Read global settings.
|
||||
byte teamCount = reader.Read1Byte();
|
||||
UnlockedFeatures = reader.ReadEnum<UnlockedFeatures>(false);
|
||||
Unknown = reader.Read1Byte();
|
||||
// Read the header.
|
||||
if (reader.ReadString(StringCoding.ZeroTerminated) != _signature)
|
||||
throw new InvalidDataException("Invalid WGT file signature.");
|
||||
Version = reader.Read1Byte(); // Really version?
|
||||
|
||||
// Read the teams.
|
||||
Teams = new List<Team>(reader.Load<Team>(teamCount));
|
||||
}
|
||||
// Read global settings.
|
||||
byte teamCount = reader.Read1Byte();
|
||||
UnlockedFeatures = reader.ReadEnum<UnlockedFeatures>(false);
|
||||
Unknown = reader.Read1Byte();
|
||||
|
||||
// Read the teams.
|
||||
Teams = new List<Team>(reader.Load<Team>(teamCount));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -101,10 +89,8 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -113,23 +99,20 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
|
||||
{
|
||||
// Write the header.
|
||||
writer.Write(_signature, StringCoding.ZeroTerminated);
|
||||
writer.Write(Version);
|
||||
using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
|
||||
|
||||
// Write global settings.
|
||||
writer.Write((byte)Teams.Count);
|
||||
writer.WriteEnum(UnlockedFeatures, false);
|
||||
writer.Write(Unknown);
|
||||
// Write the header.
|
||||
writer.Write(_signature, StringCoding.ZeroTerminated);
|
||||
writer.Write(Version);
|
||||
|
||||
// Write the teams.
|
||||
foreach (Team team in Teams)
|
||||
{
|
||||
team.Save(writer.BaseStream);
|
||||
}
|
||||
}
|
||||
// Write global settings.
|
||||
writer.Write((byte)Teams.Count);
|
||||
writer.WriteEnum(UnlockedFeatures, false);
|
||||
writer.Write(Unknown);
|
||||
|
||||
// Write the teams.
|
||||
foreach (Team team in Teams)
|
||||
team.Save(writer.BaseStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -138,10 +121,8 @@ namespace Syroot.Worms.Armageddon
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
Save(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -3,13 +3,14 @@ using System.Drawing;
|
||||
using System.IO;
|
||||
using Syroot.BinaryData;
|
||||
using Syroot.Worms.Core;
|
||||
using Syroot.Worms.Core.IO;
|
||||
|
||||
namespace Syroot.Worms.Mgame
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an IGD image container.
|
||||
/// </summary>
|
||||
public class Igd
|
||||
public class Igd : ILoadableFile
|
||||
{
|
||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||
|
||||
@ -18,20 +19,14 @@ namespace Syroot.Worms.Mgame
|
||||
/// <paramref name="fileName"/>.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public Igd(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public Igd(string fileName) => Load(fileName);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Igd"/> class, loading data from the given
|
||||
/// <paramref name="stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public Igd(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public Igd(Stream stream) => Load(stream);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -50,8 +45,8 @@ namespace Syroot.Worms.Mgame
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
Load(stream);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -23,10 +23,7 @@ namespace Syroot.Worms.Mgame
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
/// <param name="palette">The color palette which is indexed by the image data.</param>
|
||||
public Ksf(string fileName, Palette palette)
|
||||
{
|
||||
Load(fileName, palette);
|
||||
}
|
||||
public Ksf(string fileName, Palette palette) => Load(fileName, palette);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Ksf"/> class, loading data from the given
|
||||
@ -34,10 +31,7 @@ namespace Syroot.Worms.Mgame
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
/// <param name="palette">The color palette which is indexed by the image data.</param>
|
||||
public Ksf(Stream stream, Palette palette)
|
||||
{
|
||||
Load(stream, palette);
|
||||
}
|
||||
public Ksf(Stream stream, Palette palette) => Load(stream, palette);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -56,8 +50,8 @@ namespace Syroot.Worms.Mgame
|
||||
/// <param name="palette">The color palette which is indexed by the image data.</param>
|
||||
public void Load(string fileName, Palette palette)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
Load(stream, palette);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream, palette);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -69,7 +63,7 @@ namespace Syroot.Worms.Mgame
|
||||
public void Load(Stream stream, Palette palette)
|
||||
{
|
||||
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.
|
||||
KsfImage[] images = new KsfImage[imageCount];
|
||||
|
@ -2,13 +2,14 @@
|
||||
using System.Drawing;
|
||||
using System.IO;
|
||||
using Syroot.BinaryData;
|
||||
using Syroot.Worms.Core.IO;
|
||||
|
||||
namespace Syroot.Worms.Mgame
|
||||
{
|
||||
/// <summary>
|
||||
/// Represents an LPD layout description file used in Worms World Party Aqua.
|
||||
/// </summary>
|
||||
public class Lpd
|
||||
public class Lpd : ILoadableFile
|
||||
{
|
||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||
|
||||
@ -17,20 +18,14 @@ namespace Syroot.Worms.Mgame
|
||||
/// <paramref name="fileName"/>.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public Lpd(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public Lpd(string fileName) => Load(fileName);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Lpd"/> class, loading data from the given
|
||||
/// <paramref name="stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public Lpd(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public Lpd(Stream stream) => Load(stream);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -47,8 +42,8 @@ namespace Syroot.Worms.Mgame
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
Load(stream);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -19,17 +19,12 @@ namespace Syroot.Worms.Mgame
|
||||
{
|
||||
// ---- FIELDS -------------------------------------------------------------------------------------------------
|
||||
|
||||
private static int _numBytesTransferred = 0;
|
||||
|
||||
private static int _field_4 = 4;
|
||||
private static int _field_8 = 0;
|
||||
|
||||
private static int _field_C = 0;
|
||||
private static int _field_10 = 0;
|
||||
|
||||
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;
|
||||
|
||||
// ---- METHODS (INTERNAL) -------------------------------------------------------------------------------------
|
||||
@ -102,7 +97,6 @@ namespace Syroot.Worms.Mgame
|
||||
compressor.Shift(shiftValue1, 8);
|
||||
compressor.Shift(idxDword - 18, 8);
|
||||
field_10 = _field_10;
|
||||
++_field_C;
|
||||
_field_10 = idxDword - 3 + field_10;
|
||||
}
|
||||
else
|
||||
@ -110,7 +104,6 @@ namespace Syroot.Worms.Mgame
|
||||
compressor.Shift(idxDword - 2, 4);
|
||||
compressor.Shift(shiftValue1 - 1, 8);
|
||||
field_8 = _field_8;
|
||||
++_field_4;
|
||||
_field_8 = idxDword - 2 + field_8;
|
||||
}
|
||||
idx += idxDword;
|
||||
@ -209,7 +202,6 @@ namespace Syroot.Worms.Mgame
|
||||
bufferCursor = _bufferCursor;
|
||||
if (bufferCursor != 0)
|
||||
{
|
||||
_numBytesTransferred += bufferCursor;
|
||||
compressor.Compress(false);
|
||||
compressor.Shift(_bufferCursor - 1, 8);
|
||||
for (i = 0; i < _bufferCursor; ++i)
|
||||
|
@ -54,8 +54,8 @@ namespace Syroot.Worms.Mgame
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
Load(stream);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -37,29 +37,27 @@ namespace Syroot.Worms.Mgame
|
||||
/// <returns>The encrypted text.</returns>
|
||||
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.
|
||||
inStream.WriteString(data, StringCoding.ZeroTerminated, Encodings.Korean);
|
||||
inStream.Position = 0;
|
||||
using MemoryStream outStream = new MemoryStream(new byte[_bufferSize]);
|
||||
|
||||
// Encrypt the contents character by character.
|
||||
while (inStream.Position < data.Length)
|
||||
{
|
||||
// Write input into a buffer. Required to loop over the input password end.
|
||||
inStream.WriteString(data, StringCoding.ZeroTerminated, Encodings.Korean);
|
||||
inStream.Position = 0;
|
||||
using (MemoryStream outStream = new MemoryStream(new byte[_bufferSize]))
|
||||
// Begin a new dword value at every 7th index.
|
||||
uint dword = TransformDword(inStream.ReadUInt32() + key, true);
|
||||
for (int j = 0; j < 7; j++)
|
||||
{
|
||||
// Encrypt the contents character by character.
|
||||
while (inStream.Position < data.Length)
|
||||
{
|
||||
// Begin a new dword value at every 7th index.
|
||||
uint dword = TransformDword(inStream.ReadUInt32() + key, true);
|
||||
for (int j = 0; j < 7; j++)
|
||||
{
|
||||
outStream.WriteByte((byte)_encryptCharacters[(int)(dword % _encryptCharacters.Length)]);
|
||||
dword /= (uint)_encryptCharacters.Length;
|
||||
}
|
||||
}
|
||||
// Return the encrypted password as a zero-terminated ASCII string.
|
||||
outStream.Position = 0;
|
||||
return outStream.ReadString(StringCoding.ZeroTerminated, Encodings.Korean);
|
||||
outStream.WriteByte((byte)_encryptCharacters[(int)(dword % _encryptCharacters.Length)]);
|
||||
dword /= (uint)_encryptCharacters.Length;
|
||||
}
|
||||
}
|
||||
// Return the encrypted password as a zero-terminated ASCII string.
|
||||
outStream.Position = 0;
|
||||
return outStream.ReadString(StringCoding.ZeroTerminated, Encodings.Korean);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -70,32 +68,30 @@ namespace Syroot.Worms.Mgame
|
||||
/// <returns>The decrypted text.</returns>
|
||||
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.
|
||||
inStream.WriteString(data, StringCoding.Raw, Encodings.Korean);
|
||||
inStream.Position = 0;
|
||||
using MemoryStream outStream = new MemoryStream(new byte[_bufferSize]);
|
||||
|
||||
// Decrypt the contents character by character.
|
||||
for (int i = 0; i < data.Length; i += 7)
|
||||
{
|
||||
// Write input into a buffer. Required to loop over the input password end.
|
||||
inStream.WriteString(data, StringCoding.Raw, Encodings.Korean);
|
||||
inStream.Position = 0;
|
||||
using (MemoryStream outStream = new MemoryStream(new byte[_bufferSize]))
|
||||
uint dword = 0;
|
||||
for (int j = 0; j < 7; j++)
|
||||
{
|
||||
// Decrypt the contents character by character.
|
||||
for (int i = 0; i < data.Length; i += 7)
|
||||
{
|
||||
uint dword = 0;
|
||||
for (int j = 0; j < 7; j++)
|
||||
{
|
||||
byte b = inStream.Read1Byte();
|
||||
uint op1 = (uint)Math.Pow(_encryptCharacters.Length, j);
|
||||
uint op2 = (uint)(b < '0' || b > '9' ? b - '7' : b - '0');
|
||||
dword += op1 * op2;
|
||||
}
|
||||
// Finalize a new dword value at every 7th index.
|
||||
outStream.WriteUInt32(TransformDword(dword, false) - key);
|
||||
}
|
||||
// Return the decrypted password as a zero-terminated ASCII string.
|
||||
outStream.Position = 0;
|
||||
return outStream.ReadString(StringCoding.ZeroTerminated, Encodings.Korean);
|
||||
byte b = inStream.Read1Byte();
|
||||
uint op1 = (uint)Math.Pow(_encryptCharacters.Length, j);
|
||||
uint op2 = (uint)(b < '0' || b > '9' ? b - '7' : b - '0');
|
||||
dword += op1 * op2;
|
||||
}
|
||||
// Finalize a new dword value at every 7th index.
|
||||
outStream.WriteUInt32(TransformDword(dword, false) - key);
|
||||
}
|
||||
// Return the decrypted password as a zero-terminated ASCII string.
|
||||
outStream.Position = 0;
|
||||
return outStream.ReadString(StringCoding.ZeroTerminated, Encodings.Korean);
|
||||
}
|
||||
|
||||
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
|
||||
|
@ -1,23 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Syroot.Worms.Mgame</AssemblyName>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>.NET library for loading and modifying files of Mgame Worms clients.</Description>
|
||||
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageIconUrl>https://gitlab.com/Syroot/Worms/raw/master/res/icon.png</PackageIconUrl>
|
||||
<PackageId>Syroot.Worms.Mgame</PackageId>
|
||||
<PackageLicenseUrl>https://gitlab.com/Syroot/Worms/raw/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://gitlab.com/Syroot/Worms</PackageProjectUrl>
|
||||
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
|
||||
<PackageTags>worms;team17</PackageTags>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
|
||||
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
|
||||
<Version>2.0.0-alpha1</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Syroot.Worms.Mgame</AssemblyName>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>.NET library for loading and modifying files of Mgame Worms clients.</Description>
|
||||
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageIconUrl>https://gitlab.com/Syroot/Worms/raw/master/res/icon.png</PackageIconUrl>
|
||||
<PackageId>Syroot.Worms.Mgame</PackageId>
|
||||
<PackageLicenseUrl>https://gitlab.com/Syroot/Worms/raw/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://gitlab.com/Syroot/Worms</PackageProjectUrl>
|
||||
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
|
||||
<PackageTags>worms;team17</PackageTags>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
|
||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||
<Version>2.0.0-alpha1</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -91,30 +91,29 @@ namespace Syroot.Worms.WorldParty
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
// Read the header.
|
||||
if (reader.ReadInt32() != _signature)
|
||||
throw new InvalidDataException("Invalid LND file signature.");
|
||||
int fileSize = reader.ReadInt32();
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
|
||||
// Read the data.
|
||||
Size = reader.ReadStruct<Size>();
|
||||
TopBorder = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
WaterHeight = reader.ReadInt32();
|
||||
// Read the header.
|
||||
if (reader.ReadInt32() != _signature)
|
||||
throw new InvalidDataException("Invalid LND file signature.");
|
||||
int fileSize = reader.ReadInt32();
|
||||
|
||||
// Read the possible object coordinate array.
|
||||
ObjectLocations = reader.ReadStructs<Point>(reader.ReadInt32());
|
||||
// Read the data.
|
||||
Size = reader.ReadStruct<Size>();
|
||||
TopBorder = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
WaterHeight = reader.ReadInt32();
|
||||
|
||||
// Read the image data.
|
||||
Foreground = new Img(stream, true);
|
||||
CollisionMask = new Img(stream, true);
|
||||
Background = new Img(stream, true);
|
||||
// Read the possible object coordinate array.
|
||||
ObjectLocations = reader.ReadStructs<Point>(reader.ReadInt32());
|
||||
|
||||
// Read the file paths.
|
||||
LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);
|
||||
WaterDirPath = reader.ReadString(StringCoding.ByteCharCount);
|
||||
}
|
||||
// Read the image data.
|
||||
Foreground = new Img(stream, true);
|
||||
CollisionMask = new Img(stream, true);
|
||||
Background = new Img(stream, true);
|
||||
|
||||
// Read the file paths.
|
||||
LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);
|
||||
WaterDirPath = reader.ReadString(StringCoding.ByteCharCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -123,8 +122,8 @@ namespace Syroot.Worms.WorldParty
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
Load(stream);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -133,32 +132,31 @@ namespace Syroot.Worms.WorldParty
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
|
||||
{
|
||||
// Write the header.
|
||||
writer.Write(_signature);
|
||||
uint fileSizeOffset = writer.ReserveOffset();
|
||||
using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
|
||||
|
||||
// Write the data.
|
||||
writer.WriteStruct(Size);
|
||||
writer.Write(TopBorder, BooleanCoding.Dword);
|
||||
writer.Write(WaterHeight);
|
||||
// Write the header.
|
||||
writer.Write(_signature);
|
||||
uint fileSizeOffset = writer.ReserveOffset();
|
||||
|
||||
// Write the possible object coordinate array.
|
||||
writer.Write(ObjectLocations.Length);
|
||||
writer.WriteStructs(ObjectLocations);
|
||||
// Write the data.
|
||||
writer.WriteStruct(Size);
|
||||
writer.Write(TopBorder, BooleanCoding.Dword);
|
||||
writer.Write(WaterHeight);
|
||||
|
||||
// Write the image data.
|
||||
Foreground.Save(writer.BaseStream, false, true);
|
||||
CollisionMask.Save(writer.BaseStream, false, true);
|
||||
Background.Save(writer.BaseStream, false, true);
|
||||
// Write the possible object coordinate array.
|
||||
writer.Write(ObjectLocations.Length);
|
||||
writer.WriteStructs(ObjectLocations);
|
||||
|
||||
// Write the file paths.
|
||||
writer.Write(LandTexturePath, StringCoding.ByteCharCount);
|
||||
writer.Write(WaterDirPath, StringCoding.ByteCharCount);
|
||||
// Write the image data.
|
||||
Foreground.Save(writer.BaseStream, false, true);
|
||||
CollisionMask.Save(writer.BaseStream, false, true);
|
||||
Background.Save(writer.BaseStream, false, true);
|
||||
|
||||
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
|
||||
}
|
||||
// Write the file paths.
|
||||
writer.Write(LandTexturePath, StringCoding.ByteCharCount);
|
||||
writer.Write(WaterDirPath, StringCoding.ByteCharCount);
|
||||
|
||||
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -167,8 +165,8 @@ namespace Syroot.Worms.WorldParty
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
Save(stream);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Syroot.Worms.WorldParty</AssemblyName>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>.NET library for loading and modifying files of Team17's Worms World Party.</Description>
|
||||
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageIconUrl>https://gitlab.com/Syroot/Worms/raw/master/res/icon.png</PackageIconUrl>
|
||||
<PackageId>Syroot.Worms.WorldParty</PackageId>
|
||||
<PackageLicenseUrl>https://gitlab.com/Syroot/Worms/raw/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://gitlab.com/Syroot/Worms</PackageProjectUrl>
|
||||
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
|
||||
<PackageTags>worms;team17</PackageTags>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
|
||||
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
|
||||
<Version>2.0.0-alpha1</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Syroot.Worms.WorldParty</AssemblyName>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>.NET library for loading and modifying files of Team17's Worms World Party.</Description>
|
||||
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageIconUrl>https://gitlab.com/Syroot/Worms/raw/master/res/icon.png</PackageIconUrl>
|
||||
<PackageId>Syroot.Worms.WorldParty</PackageId>
|
||||
<PackageLicenseUrl>https://gitlab.com/Syroot/Worms/raw/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://gitlab.com/Syroot/Worms</PackageProjectUrl>
|
||||
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
|
||||
<PackageTags>worms;team17</PackageTags>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
|
||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||
<Version>2.0.0-alpha1</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -195,58 +195,57 @@ namespace Syroot.Worms.WorldParty
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
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);
|
||||
WormNames = reader.ReadStrings(8, 17);
|
||||
CpuLevel = reader.Read1Byte();
|
||||
SoundBankName = reader.ReadString(0x20);
|
||||
SoundBankLocation = reader.Read1Byte();
|
||||
FanfareName = reader.ReadString(0x20);
|
||||
UseCustomFanfare = reader.Read1Byte();
|
||||
|
||||
GraveSprite = reader.ReadSByte();
|
||||
if (GraveSprite < 0)
|
||||
{
|
||||
Name = reader.ReadString(17);
|
||||
WormNames = reader.ReadStrings(8, 17);
|
||||
CpuLevel = reader.Read1Byte();
|
||||
SoundBankName = reader.ReadString(0x20);
|
||||
SoundBankLocation = reader.Read1Byte();
|
||||
FanfareName = reader.ReadString(0x20);
|
||||
UseCustomFanfare = reader.Read1Byte();
|
||||
|
||||
GraveSprite = reader.ReadSByte();
|
||||
if (GraveSprite < 0)
|
||||
{
|
||||
GraveFileName = reader.ReadString(0x20);
|
||||
Grave = new RawBitmap()
|
||||
{
|
||||
BitsPerPixel = 8,
|
||||
Size = new Size(24, 32),
|
||||
Palette = reader.ReadStructs<Color>(256),
|
||||
Data = reader.ReadBytes(24 * 32)
|
||||
};
|
||||
}
|
||||
|
||||
TeamWeapon = reader.ReadEnum<TeamWeapon>(true);
|
||||
GamesLost = reader.ReadInt32();
|
||||
DeathmatchesLost = reader.ReadInt32();
|
||||
GamesWon = reader.ReadInt32();
|
||||
DeathmatchesWon = reader.ReadInt32();
|
||||
GamesDrawn = reader.ReadInt32();
|
||||
DeathmatchesDrawn = reader.ReadInt32();
|
||||
Kills = reader.ReadInt32();
|
||||
DeathmatchKills = reader.ReadInt32();
|
||||
Deaths = reader.ReadInt32();
|
||||
DeathmatchDeaths = reader.ReadInt32();
|
||||
MissionStatuses = reader.ReadStructs<TeamMissionStatus>(_missionCount);
|
||||
|
||||
FlagFileName = reader.ReadString(0x20);
|
||||
Flag = new RawBitmap()
|
||||
GraveFileName = reader.ReadString(0x20);
|
||||
Grave = new RawBitmap()
|
||||
{
|
||||
BitsPerPixel = 8,
|
||||
Size = new Size(20, 17),
|
||||
Size = new Size(24, 32),
|
||||
Palette = reader.ReadStructs<Color>(256),
|
||||
Data = reader.ReadBytes(20 * 17)
|
||||
Data = reader.ReadBytes(24 * 32)
|
||||
};
|
||||
|
||||
Unknown1 = reader.Read1Byte();
|
||||
DeathmatchRank = reader.Read1Byte();
|
||||
TrainingMissionTimes = reader.ReadInt32s(_trainingMissionCount);
|
||||
WeaponPoints = reader.ReadBytes(46);
|
||||
Fort = reader.Read1Byte();
|
||||
Unknown2 = reader.ReadInt32s(7);
|
||||
}
|
||||
|
||||
TeamWeapon = reader.ReadEnum<TeamWeapon>(true);
|
||||
GamesLost = reader.ReadInt32();
|
||||
DeathmatchesLost = reader.ReadInt32();
|
||||
GamesWon = reader.ReadInt32();
|
||||
DeathmatchesWon = reader.ReadInt32();
|
||||
GamesDrawn = reader.ReadInt32();
|
||||
DeathmatchesDrawn = reader.ReadInt32();
|
||||
Kills = reader.ReadInt32();
|
||||
DeathmatchKills = reader.ReadInt32();
|
||||
Deaths = reader.ReadInt32();
|
||||
DeathmatchDeaths = reader.ReadInt32();
|
||||
MissionStatuses = reader.ReadStructs<TeamMissionStatus>(_missionCount);
|
||||
|
||||
FlagFileName = reader.ReadString(0x20);
|
||||
Flag = new RawBitmap()
|
||||
{
|
||||
BitsPerPixel = 8,
|
||||
Size = new Size(20, 17),
|
||||
Palette = reader.ReadStructs<Color>(256),
|
||||
Data = reader.ReadBytes(20 * 17)
|
||||
};
|
||||
|
||||
Unknown1 = reader.Read1Byte();
|
||||
DeathmatchRank = reader.Read1Byte();
|
||||
TrainingMissionTimes = reader.ReadInt32s(_trainingMissionCount);
|
||||
WeaponPoints = reader.ReadBytes(46);
|
||||
Fort = reader.Read1Byte();
|
||||
Unknown2 = reader.ReadInt32s(7);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -255,49 +254,48 @@ namespace Syroot.Worms.WorldParty
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
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.WriteStrings(WormNames, 17);
|
||||
writer.Write(CpuLevel);
|
||||
writer.WriteString(SoundBankName, 0x20);
|
||||
writer.Write(SoundBankLocation);
|
||||
writer.WriteString(FanfareName, 0x20);
|
||||
writer.Write(UseCustomFanfare);
|
||||
|
||||
writer.Write(GraveSprite);
|
||||
if (GraveSprite < 0)
|
||||
{
|
||||
writer.WriteString(Name, 17);
|
||||
writer.WriteStrings(WormNames, 17);
|
||||
writer.Write(CpuLevel);
|
||||
writer.WriteString(SoundBankName, 0x20);
|
||||
writer.Write(SoundBankLocation);
|
||||
writer.WriteString(FanfareName, 0x20);
|
||||
writer.Write(UseCustomFanfare);
|
||||
|
||||
writer.Write(GraveSprite);
|
||||
if (GraveSprite < 0)
|
||||
{
|
||||
writer.WriteString(GraveFileName, 0x20);
|
||||
writer.WriteStructs(Grave.Palette);
|
||||
writer.WriteStructs(Grave.Data);
|
||||
}
|
||||
|
||||
writer.WriteEnum(TeamWeapon, true);
|
||||
writer.Write(GamesLost);
|
||||
writer.Write(DeathmatchesLost);
|
||||
writer.Write(GamesWon);
|
||||
writer.Write(DeathmatchesWon);
|
||||
writer.Write(GamesDrawn);
|
||||
writer.Write(DeathmatchesDrawn);
|
||||
writer.Write(Kills);
|
||||
writer.Write(DeathmatchKills);
|
||||
writer.Write(Deaths);
|
||||
writer.Write(DeathmatchDeaths);
|
||||
writer.WriteStructs(MissionStatuses);
|
||||
|
||||
writer.WriteString(FlagFileName, 0x20);
|
||||
writer.WriteStructs(Flag.Palette);
|
||||
writer.WriteStructs(Flag.Data);
|
||||
|
||||
writer.Write(Unknown1);
|
||||
writer.Write(DeathmatchRank);
|
||||
writer.Write(TrainingMissionTimes);
|
||||
writer.Write(UnknownTrainingMissionTime);
|
||||
writer.WriteStructs(WeaponPoints);
|
||||
writer.Write(Fort);
|
||||
writer.Write(Unknown2);
|
||||
writer.WriteString(GraveFileName, 0x20);
|
||||
writer.WriteStructs(Grave.Palette);
|
||||
writer.WriteStructs(Grave.Data);
|
||||
}
|
||||
|
||||
writer.WriteEnum(TeamWeapon, true);
|
||||
writer.Write(GamesLost);
|
||||
writer.Write(DeathmatchesLost);
|
||||
writer.Write(GamesWon);
|
||||
writer.Write(DeathmatchesWon);
|
||||
writer.Write(GamesDrawn);
|
||||
writer.Write(DeathmatchesDrawn);
|
||||
writer.Write(Kills);
|
||||
writer.Write(DeathmatchKills);
|
||||
writer.Write(Deaths);
|
||||
writer.Write(DeathmatchDeaths);
|
||||
writer.WriteStructs(MissionStatuses);
|
||||
|
||||
writer.WriteString(FlagFileName, 0x20);
|
||||
writer.WriteStructs(Flag.Palette);
|
||||
writer.WriteStructs(Flag.Data);
|
||||
|
||||
writer.Write(Unknown1);
|
||||
writer.Write(DeathmatchRank);
|
||||
writer.Write(TrainingMissionTimes);
|
||||
writer.Write(UnknownTrainingMissionTime);
|
||||
writer.WriteStructs(WeaponPoints);
|
||||
writer.Write(Fort);
|
||||
writer.Write(Unknown2);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -21,29 +21,20 @@ namespace Syroot.Worms.WorldParty
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TeamContainer"/> class.
|
||||
/// </summary>
|
||||
public TeamContainer()
|
||||
{
|
||||
Teams = new List<Team>();
|
||||
}
|
||||
public TeamContainer() => Teams = new List<Team>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TeamContainer"/> class, loading the data from the given
|
||||
/// <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public TeamContainer(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public TeamContainer(Stream stream) => Load(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TeamContainer"/> class, loading the data from the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public TeamContainer(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public TeamContainer(string fileName) => Load(fileName);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -80,24 +71,21 @@ namespace Syroot.Worms.WorldParty
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
// Read the header.
|
||||
if (reader.ReadString(StringCoding.ZeroTerminated) != _signature)
|
||||
{
|
||||
throw new InvalidDataException("Invalid WWP file signature.");
|
||||
}
|
||||
Version = reader.Read1Byte(); // Really version?
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
|
||||
// Read global settings.
|
||||
byte teamCount = reader.Read1Byte();
|
||||
Unknown1 = reader.Read1Byte();
|
||||
Unknown2 = reader.Read1Byte();
|
||||
Unknown3 = reader.ReadBytes(840);
|
||||
// Read the header.
|
||||
if (reader.ReadString(StringCoding.ZeroTerminated) != _signature)
|
||||
throw new InvalidDataException("Invalid WWP file signature.");
|
||||
Version = reader.Read1Byte(); // Really version?
|
||||
|
||||
// Read the teams.
|
||||
Teams = new List<Team>(reader.Load<Team>(teamCount));
|
||||
}
|
||||
// Read global settings.
|
||||
byte teamCount = reader.Read1Byte();
|
||||
Unknown1 = reader.Read1Byte();
|
||||
Unknown2 = reader.Read1Byte();
|
||||
Unknown3 = reader.ReadBytes(840);
|
||||
|
||||
// Read the teams.
|
||||
Teams = new List<Team>(reader.Load<Team>(teamCount));
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -106,10 +94,8 @@ namespace Syroot.Worms.WorldParty
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -118,24 +104,21 @@ namespace Syroot.Worms.WorldParty
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
|
||||
{
|
||||
// Write the header.
|
||||
writer.Write(_signature, StringCoding.ZeroTerminated);
|
||||
writer.Write(Version);
|
||||
using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
|
||||
|
||||
// Write global settings.
|
||||
writer.Write((byte)Teams.Count);
|
||||
writer.Write(Unknown1);
|
||||
writer.Write(Unknown2);
|
||||
writer.WriteStructs(Unknown3);
|
||||
// Write the header.
|
||||
writer.Write(_signature, StringCoding.ZeroTerminated);
|
||||
writer.Write(Version);
|
||||
|
||||
// Write the teams.
|
||||
foreach (Team team in Teams)
|
||||
{
|
||||
team.Save(writer.BaseStream);
|
||||
}
|
||||
}
|
||||
// Write global settings.
|
||||
writer.Write((byte)Teams.Count);
|
||||
writer.Write(Unknown1);
|
||||
writer.Write(Unknown2);
|
||||
writer.WriteStructs(Unknown3);
|
||||
|
||||
// Write the teams.
|
||||
foreach (Team team in Teams)
|
||||
team.Save(writer.BaseStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -144,10 +127,8 @@ namespace Syroot.Worms.WorldParty
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
Save(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -96,31 +96,30 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
// Read the header.
|
||||
if (reader.ReadInt32() != _signature)
|
||||
throw new InvalidDataException("Invalid LND file signature.");
|
||||
int fileSize = reader.ReadInt32();
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
|
||||
// Read the data.
|
||||
Size = reader.ReadStruct<Size>();
|
||||
TopBorder = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
// Read the header.
|
||||
if (reader.ReadInt32() != _signature)
|
||||
throw new InvalidDataException("Invalid LND file signature.");
|
||||
int fileSize = reader.ReadInt32();
|
||||
|
||||
// Read the possible object coordinate array.
|
||||
ObjectLocations = reader.ReadStructs<Point>(reader.ReadInt32());
|
||||
Unknown = reader.ReadInt32();
|
||||
// Read the data.
|
||||
Size = reader.ReadStruct<Size>();
|
||||
TopBorder = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
|
||||
// Read the image data.
|
||||
Foreground = reader.Load<Img>();
|
||||
CollisionMask = reader.Load<Img>();
|
||||
Background = reader.Load<Img>();
|
||||
UnknownImage = reader.Load<Img>();
|
||||
// Read the possible object coordinate array.
|
||||
ObjectLocations = reader.ReadStructs<Point>(reader.ReadInt32());
|
||||
Unknown = reader.ReadInt32();
|
||||
|
||||
// Read the file paths.
|
||||
LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);
|
||||
WaterDirPath = reader.ReadString(StringCoding.ByteCharCount);
|
||||
}
|
||||
// Read the image data.
|
||||
Foreground = reader.Load<Img>();
|
||||
CollisionMask = reader.Load<Img>();
|
||||
Background = reader.Load<Img>();
|
||||
UnknownImage = reader.Load<Img>();
|
||||
|
||||
// Read the file paths.
|
||||
LandTexturePath = reader.ReadString(StringCoding.ByteCharCount);
|
||||
WaterDirPath = reader.ReadString(StringCoding.ByteCharCount);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -129,8 +128,8 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
Load(stream);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -139,33 +138,32 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
|
||||
{
|
||||
// Write the header.
|
||||
writer.Write(_signature);
|
||||
uint fileSizeOffset = writer.ReserveOffset();
|
||||
using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
|
||||
|
||||
// Write the data.
|
||||
writer.WriteStruct(Size);
|
||||
writer.Write(TopBorder, BooleanCoding.Dword);
|
||||
// Write the header.
|
||||
writer.Write(_signature);
|
||||
uint fileSizeOffset = writer.ReserveOffset();
|
||||
|
||||
// Write the possible object coordinate array.
|
||||
writer.Write(ObjectLocations.Length);
|
||||
writer.WriteStructs(ObjectLocations);
|
||||
writer.Write(Unknown);
|
||||
// Write the data.
|
||||
writer.WriteStruct(Size);
|
||||
writer.Write(TopBorder, BooleanCoding.Dword);
|
||||
|
||||
// Write the image data.
|
||||
Foreground.Save(writer.BaseStream);
|
||||
CollisionMask.Save(writer.BaseStream);
|
||||
Background.Save(writer.BaseStream);
|
||||
UnknownImage.Save(writer.BaseStream);
|
||||
// Write the possible object coordinate array.
|
||||
writer.Write(ObjectLocations.Length);
|
||||
writer.WriteStructs(ObjectLocations);
|
||||
writer.Write(Unknown);
|
||||
|
||||
// Write the file paths.
|
||||
writer.Write(LandTexturePath, StringCoding.ByteCharCount);
|
||||
writer.Write(WaterDirPath, StringCoding.ByteCharCount);
|
||||
// Write the image data.
|
||||
Foreground.Save(writer.BaseStream);
|
||||
CollisionMask.Save(writer.BaseStream);
|
||||
Background.Save(writer.BaseStream);
|
||||
UnknownImage.Save(writer.BaseStream);
|
||||
|
||||
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
|
||||
}
|
||||
// Write the file paths.
|
||||
writer.Write(LandTexturePath, StringCoding.ByteCharCount);
|
||||
writer.Write(WaterDirPath, StringCoding.ByteCharCount);
|
||||
|
||||
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -174,8 +172,8 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
Save(stream);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ namespace Syroot.Worms.Worms2
|
||||
Manual = 3
|
||||
}
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// Represents the weapons in the game.
|
||||
/// </summary>
|
||||
@ -136,7 +135,7 @@ namespace Syroot.Worms.Worms2
|
||||
/// The Napalm Strike weapon.
|
||||
/// </summary>
|
||||
NapalmStrike,
|
||||
|
||||
|
||||
/// <summary>
|
||||
/// The Mail Strike weapon.
|
||||
/// </summary>
|
||||
|
@ -20,28 +20,20 @@ namespace Syroot.Worms.Worms2
|
||||
/// <summary>
|
||||
/// Initializs a new instance of the <see cref="SchemeOptions"/> class.
|
||||
/// </summary>
|
||||
public SchemeOptions()
|
||||
{
|
||||
}
|
||||
public SchemeOptions() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SchemeOptions"/> class, loading the data from the given
|
||||
/// <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public SchemeOptions(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public SchemeOptions(Stream stream) => Load(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SchemeOptions"/> class, loading the data from the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public SchemeOptions(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public SchemeOptions(string fileName) => Load(fileName);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -221,52 +213,47 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
// Read the header.
|
||||
if (reader.ReadString(_signature.Length) != _signature)
|
||||
{
|
||||
throw new InvalidDataException("Invalid OPT file signature.");
|
||||
}
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
|
||||
// Read the options.
|
||||
RoundTime = reader.ReadInt32();
|
||||
TurnTime = reader.ReadInt32();
|
||||
RetreatTime = reader.ReadInt32();
|
||||
RetreatTimeRope = reader.ReadInt32();
|
||||
ObjectCount = reader.ReadInt32();
|
||||
MineDelay = reader.ReadInt32();
|
||||
DudMines = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
WindPower = reader.ReadInt32();
|
||||
Friction = reader.ReadInt32();
|
||||
ReplayRequiredKills = reader.ReadInt32();
|
||||
ReplayRequiredDamage = reader.ReadInt32();
|
||||
AutomaticReplays = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
FallDamage = reader.ReadInt32();
|
||||
RopeSwings = reader.ReadInt32();
|
||||
ShowRoundTime = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
WaterRiseRate = reader.ReadInt32();
|
||||
SuddenDeathHealthDrop = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
IndestructibleBorder = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
RestrictGirders = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
WormSelectMode = reader.ReadEnum<SchemeWormSelect>(true);
|
||||
ExtendedChatControls = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
HotSeatDelay = reader.ReadInt32();
|
||||
EnableStockpiling = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
CrateProbability = reader.ReadInt32();
|
||||
CrateIntelligence = reader.ReadInt32();
|
||||
HealthCrateEnergy = reader.ReadInt32();
|
||||
BoobyTraps = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
EnableSuperWeapons = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
WormEnergy = reader.ReadInt32();
|
||||
ArtilleryMode = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
SuddenDeathDisableWormSelect = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
// The following option does not exist in all schemes.
|
||||
if (!reader.EndOfStream)
|
||||
{
|
||||
UseOilDrums = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
}
|
||||
}
|
||||
// Read the header.
|
||||
if (reader.ReadString(_signature.Length) != _signature)
|
||||
throw new InvalidDataException("Invalid OPT file signature.");
|
||||
|
||||
// Read the options.
|
||||
RoundTime = reader.ReadInt32();
|
||||
TurnTime = reader.ReadInt32();
|
||||
RetreatTime = reader.ReadInt32();
|
||||
RetreatTimeRope = reader.ReadInt32();
|
||||
ObjectCount = reader.ReadInt32();
|
||||
MineDelay = reader.ReadInt32();
|
||||
DudMines = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
WindPower = reader.ReadInt32();
|
||||
Friction = reader.ReadInt32();
|
||||
ReplayRequiredKills = reader.ReadInt32();
|
||||
ReplayRequiredDamage = reader.ReadInt32();
|
||||
AutomaticReplays = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
FallDamage = reader.ReadInt32();
|
||||
RopeSwings = reader.ReadInt32();
|
||||
ShowRoundTime = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
WaterRiseRate = reader.ReadInt32();
|
||||
SuddenDeathHealthDrop = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
IndestructibleBorder = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
RestrictGirders = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
WormSelectMode = reader.ReadEnum<SchemeWormSelect>(true);
|
||||
ExtendedChatControls = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
HotSeatDelay = reader.ReadInt32();
|
||||
EnableStockpiling = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
CrateProbability = reader.ReadInt32();
|
||||
CrateIntelligence = reader.ReadInt32();
|
||||
HealthCrateEnergy = reader.ReadInt32();
|
||||
BoobyTraps = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
EnableSuperWeapons = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
WormEnergy = reader.ReadInt32();
|
||||
ArtilleryMode = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
SuddenDeathDisableWormSelect = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
// The following option does not exist in all schemes.
|
||||
if (!reader.EndOfStream)
|
||||
UseOilDrums = reader.ReadBoolean(BooleanCoding.Dword);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -275,10 +262,8 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -287,45 +272,44 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
|
||||
{
|
||||
// Write the header.
|
||||
writer.Write(_signature, StringCoding.Raw);
|
||||
using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
|
||||
|
||||
// Write the options.
|
||||
writer.Write(RoundTime);
|
||||
writer.Write(TurnTime);
|
||||
writer.Write(RetreatTime);
|
||||
writer.Write(RetreatTimeRope);
|
||||
writer.Write(ObjectCount);
|
||||
writer.Write(MineDelay);
|
||||
writer.Write(DudMines, BooleanCoding.Dword);
|
||||
writer.Write(WindPower);
|
||||
writer.Write(Friction);
|
||||
writer.Write(ReplayRequiredKills);
|
||||
writer.Write(ReplayRequiredDamage);
|
||||
writer.Write(AutomaticReplays, BooleanCoding.Dword);
|
||||
writer.Write(FallDamage);
|
||||
writer.Write(RopeSwings);
|
||||
writer.Write(ShowRoundTime, BooleanCoding.Dword);
|
||||
writer.Write(WaterRiseRate);
|
||||
writer.Write(SuddenDeathHealthDrop, BooleanCoding.Dword);
|
||||
writer.Write(IndestructibleBorder, BooleanCoding.Dword);
|
||||
writer.Write(RestrictGirders, BooleanCoding.Dword);
|
||||
writer.WriteEnum(WormSelectMode, true);
|
||||
writer.Write(ExtendedChatControls, BooleanCoding.Dword);
|
||||
writer.Write(HotSeatDelay);
|
||||
writer.Write(EnableStockpiling, BooleanCoding.Dword);
|
||||
writer.Write(CrateProbability);
|
||||
writer.Write(CrateIntelligence);
|
||||
writer.Write(HealthCrateEnergy);
|
||||
writer.Write(BoobyTraps, BooleanCoding.Dword);
|
||||
writer.Write(EnableSuperWeapons, BooleanCoding.Dword);
|
||||
writer.Write(WormEnergy);
|
||||
writer.Write(ArtilleryMode, BooleanCoding.Dword);
|
||||
writer.Write(SuddenDeathDisableWormSelect, BooleanCoding.Dword);
|
||||
writer.Write(UseOilDrums, BooleanCoding.Dword);
|
||||
}
|
||||
// Write the header.
|
||||
writer.Write(_signature, StringCoding.Raw);
|
||||
|
||||
// Write the options.
|
||||
writer.Write(RoundTime);
|
||||
writer.Write(TurnTime);
|
||||
writer.Write(RetreatTime);
|
||||
writer.Write(RetreatTimeRope);
|
||||
writer.Write(ObjectCount);
|
||||
writer.Write(MineDelay);
|
||||
writer.Write(DudMines, BooleanCoding.Dword);
|
||||
writer.Write(WindPower);
|
||||
writer.Write(Friction);
|
||||
writer.Write(ReplayRequiredKills);
|
||||
writer.Write(ReplayRequiredDamage);
|
||||
writer.Write(AutomaticReplays, BooleanCoding.Dword);
|
||||
writer.Write(FallDamage);
|
||||
writer.Write(RopeSwings);
|
||||
writer.Write(ShowRoundTime, BooleanCoding.Dword);
|
||||
writer.Write(WaterRiseRate);
|
||||
writer.Write(SuddenDeathHealthDrop, BooleanCoding.Dword);
|
||||
writer.Write(IndestructibleBorder, BooleanCoding.Dword);
|
||||
writer.Write(RestrictGirders, BooleanCoding.Dword);
|
||||
writer.WriteEnum(WormSelectMode, true);
|
||||
writer.Write(ExtendedChatControls, BooleanCoding.Dword);
|
||||
writer.Write(HotSeatDelay);
|
||||
writer.Write(EnableStockpiling, BooleanCoding.Dword);
|
||||
writer.Write(CrateProbability);
|
||||
writer.Write(CrateIntelligence);
|
||||
writer.Write(HealthCrateEnergy);
|
||||
writer.Write(BoobyTraps, BooleanCoding.Dword);
|
||||
writer.Write(EnableSuperWeapons, BooleanCoding.Dword);
|
||||
writer.Write(WormEnergy);
|
||||
writer.Write(ArtilleryMode, BooleanCoding.Dword);
|
||||
writer.Write(SuddenDeathDisableWormSelect, BooleanCoding.Dword);
|
||||
writer.Write(UseOilDrums, BooleanCoding.Dword);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -334,10 +318,8 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
Save(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,29 +22,20 @@ namespace Syroot.Worms.Worms2
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SchemeWeapons"/> class.
|
||||
/// </summary>
|
||||
public SchemeWeapons()
|
||||
{
|
||||
Weapons = new SchemeWeaponSetting[_weaponCount];
|
||||
}
|
||||
public SchemeWeapons() => Weapons = new SchemeWeaponSetting[_weaponCount];
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SchemeWeapons"/> class, loading the data from the given
|
||||
/// <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public SchemeWeapons(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public SchemeWeapons(Stream stream) => Load(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="SchemeWeapons"/> class, loading the data from the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public SchemeWeapons(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public SchemeWeapons(string fileName) => Load(fileName);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -62,22 +53,17 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
// Read the header.
|
||||
reader.Seek(_trashLength);
|
||||
if (reader.ReadString(StringCoding.ZeroTerminated) != _signature)
|
||||
{
|
||||
throw new InvalidDataException("Invalid WEP file signature.");
|
||||
}
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
|
||||
// Read the weapon settings.
|
||||
Weapons = new SchemeWeaponSetting[_weaponCount];
|
||||
for (int i = 0; i < _weaponCount; i++)
|
||||
{
|
||||
Weapons[i] = reader.ReadStruct<SchemeWeaponSetting>();
|
||||
}
|
||||
}
|
||||
// Read the header.
|
||||
reader.Seek(_trashLength);
|
||||
if (reader.ReadString(StringCoding.ZeroTerminated) != _signature)
|
||||
throw new InvalidDataException("Invalid WEP file signature.");
|
||||
|
||||
// Read the weapon settings.
|
||||
Weapons = new SchemeWeaponSetting[_weaponCount];
|
||||
for (int i = 0; i < _weaponCount; i++)
|
||||
Weapons[i] = reader.ReadStruct<SchemeWeaponSetting>();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -86,10 +72,8 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -98,18 +82,15 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
|
||||
{
|
||||
// Write the header.
|
||||
writer.WriteStructs(new byte[_trashLength]);
|
||||
writer.Write(_signature, StringCoding.ZeroTerminated);
|
||||
using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
|
||||
|
||||
// Write the weapon settings.
|
||||
foreach (SchemeWeaponSetting weapon in Weapons)
|
||||
{
|
||||
writer.WriteStruct(weapon);
|
||||
}
|
||||
}
|
||||
// Write the header.
|
||||
writer.WriteStructs(new byte[_trashLength]);
|
||||
writer.Write(_signature, StringCoding.ZeroTerminated);
|
||||
|
||||
// Write the weapon settings.
|
||||
foreach (SchemeWeaponSetting weapon in Weapons)
|
||||
writer.WriteStruct(weapon);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -118,10 +99,8 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
Save(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1,23 +1,23 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Syroot.Worms.Worms2</AssemblyName>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>.NET library for loading and modifying files of Team17's Worms 2.</Description>
|
||||
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageIconUrl>https://gitlab.com/Syroot/Worms/raw/master/res/icon.png</PackageIconUrl>
|
||||
<PackageId>Syroot.Worms.Worms2</PackageId>
|
||||
<PackageLicenseUrl>https://gitlab.com/Syroot/Worms/raw/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://gitlab.com/Syroot/Worms</PackageProjectUrl>
|
||||
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
|
||||
<PackageTags>worms;team17</PackageTags>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
|
||||
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
|
||||
<Version>2.0.0-alpha1</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Syroot.Worms.Worms2</AssemblyName>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>.NET library for loading and modifying files of Team17's Worms 2.</Description>
|
||||
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageIconUrl>https://gitlab.com/Syroot/Worms/raw/master/res/icon.png</PackageIconUrl>
|
||||
<PackageId>Syroot.Worms.Worms2</PackageId>
|
||||
<PackageLicenseUrl>https://gitlab.com/Syroot/Worms/raw/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://gitlab.com/Syroot/Worms</PackageProjectUrl>
|
||||
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
|
||||
<PackageTags>worms;team17</PackageTags>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
|
||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||
<Version>2.0.0-alpha1</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -109,50 +109,48 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
Unknown1 = reader.ReadInt16();
|
||||
Name = reader.ReadString(66);
|
||||
SoundBankName = reader.ReadString(36);
|
||||
WormNames = reader.ReadStrings(8, 20);
|
||||
Unknown2 = reader.ReadInt32();
|
||||
Unknown3 = reader.ReadInt32();
|
||||
Unknown4 = reader.ReadInt32();
|
||||
Unknown5 = reader.ReadInt32();
|
||||
Unknown6 = reader.ReadInt32();
|
||||
Unknown7 = reader.ReadInt32();
|
||||
Unknown8 = reader.ReadInt32();
|
||||
Unknown9 = reader.ReadInt32();
|
||||
Unknown10 = reader.ReadInt32();
|
||||
Unknown11 = reader.ReadInt32();
|
||||
Unknown12 = reader.ReadInt32();
|
||||
Unknown13 = reader.ReadInt32();
|
||||
Unknown14 = reader.ReadInt32();
|
||||
Unknown15 = reader.ReadInt32();
|
||||
Unknown16 = reader.ReadInt32();
|
||||
Unknown17 = reader.ReadInt32();
|
||||
Unknown18 = reader.ReadInt32();
|
||||
Unknown19 = reader.ReadInt32();
|
||||
Unknown20 = reader.ReadInt32();
|
||||
Unknown21 = reader.ReadInt32();
|
||||
Unknown22 = reader.ReadInt32();
|
||||
Unknown23 = reader.ReadInt32();
|
||||
Unknown24 = reader.ReadInt32();
|
||||
Unknown25 = reader.ReadInt32();
|
||||
GamesLost = reader.ReadInt32();
|
||||
GamesWon = reader.ReadInt32();
|
||||
Unknown26 = reader.ReadInt32();
|
||||
Unknown27 = reader.ReadInt32();
|
||||
Kills = reader.ReadInt32();
|
||||
Deaths = reader.ReadInt32();
|
||||
CpuLevel = reader.ReadInt32();
|
||||
Unknown28 = reader.ReadInt32();
|
||||
Unknown29 = reader.ReadInt32();
|
||||
Unknown30 = reader.ReadInt32();
|
||||
Difference = reader.ReadInt32();
|
||||
GamesPlayed = reader.ReadInt32();
|
||||
Points = reader.ReadInt32();
|
||||
}
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
Unknown1 = reader.ReadInt16();
|
||||
Name = reader.ReadString(66);
|
||||
SoundBankName = reader.ReadString(36);
|
||||
WormNames = reader.ReadStrings(8, 20);
|
||||
Unknown2 = reader.ReadInt32();
|
||||
Unknown3 = reader.ReadInt32();
|
||||
Unknown4 = reader.ReadInt32();
|
||||
Unknown5 = reader.ReadInt32();
|
||||
Unknown6 = reader.ReadInt32();
|
||||
Unknown7 = reader.ReadInt32();
|
||||
Unknown8 = reader.ReadInt32();
|
||||
Unknown9 = reader.ReadInt32();
|
||||
Unknown10 = reader.ReadInt32();
|
||||
Unknown11 = reader.ReadInt32();
|
||||
Unknown12 = reader.ReadInt32();
|
||||
Unknown13 = reader.ReadInt32();
|
||||
Unknown14 = reader.ReadInt32();
|
||||
Unknown15 = reader.ReadInt32();
|
||||
Unknown16 = reader.ReadInt32();
|
||||
Unknown17 = reader.ReadInt32();
|
||||
Unknown18 = reader.ReadInt32();
|
||||
Unknown19 = reader.ReadInt32();
|
||||
Unknown20 = reader.ReadInt32();
|
||||
Unknown21 = reader.ReadInt32();
|
||||
Unknown22 = reader.ReadInt32();
|
||||
Unknown23 = reader.ReadInt32();
|
||||
Unknown24 = reader.ReadInt32();
|
||||
Unknown25 = reader.ReadInt32();
|
||||
GamesLost = reader.ReadInt32();
|
||||
GamesWon = reader.ReadInt32();
|
||||
Unknown26 = reader.ReadInt32();
|
||||
Unknown27 = reader.ReadInt32();
|
||||
Kills = reader.ReadInt32();
|
||||
Deaths = reader.ReadInt32();
|
||||
CpuLevel = reader.ReadInt32();
|
||||
Unknown28 = reader.ReadInt32();
|
||||
Unknown29 = reader.ReadInt32();
|
||||
Unknown30 = reader.ReadInt32();
|
||||
Difference = reader.ReadInt32();
|
||||
GamesPlayed = reader.ReadInt32();
|
||||
Points = reader.ReadInt32();
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -161,52 +159,50 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
writer.Write(Unknown1);
|
||||
writer.WriteString(Name, 66);
|
||||
writer.WriteString(SoundBankName, 36);
|
||||
writer.WriteStrings(WormNames, 20);
|
||||
writer.Write(Unknown2);
|
||||
writer.Write(Unknown3);
|
||||
writer.Write(Unknown4);
|
||||
writer.Write(Unknown5);
|
||||
writer.Write(Unknown6);
|
||||
writer.Write(Unknown7);
|
||||
writer.Write(Unknown8);
|
||||
writer.Write(Unknown9);
|
||||
writer.Write(Unknown10);
|
||||
writer.Write(Unknown11);
|
||||
writer.Write(Unknown12);
|
||||
writer.Write(Unknown13);
|
||||
writer.Write(Unknown14);
|
||||
writer.Write(Unknown15);
|
||||
writer.Write(Unknown16);
|
||||
writer.Write(Unknown17);
|
||||
writer.Write(Unknown18);
|
||||
writer.Write(Unknown19);
|
||||
writer.Write(Unknown20);
|
||||
writer.Write(Unknown21);
|
||||
writer.Write(Unknown22);
|
||||
writer.Write(Unknown23);
|
||||
writer.Write(Unknown24);
|
||||
writer.Write(Unknown25);
|
||||
writer.Write(GamesLost);
|
||||
writer.Write(GamesWon);
|
||||
writer.Write(Unknown26);
|
||||
writer.Write(Unknown27);
|
||||
writer.Write(Kills);
|
||||
writer.Write(Deaths);
|
||||
writer.Write(CpuLevel);
|
||||
writer.Write(Unknown28);
|
||||
writer.Write(Unknown29);
|
||||
writer.Write(Unknown30);
|
||||
writer.Write(Kills);
|
||||
writer.Write(Deaths);
|
||||
writer.Write(Difference);
|
||||
writer.Write(GamesPlayed);
|
||||
writer.Write(Points);
|
||||
}
|
||||
using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
writer.Write(Unknown1);
|
||||
writer.WriteString(Name, 66);
|
||||
writer.WriteString(SoundBankName, 36);
|
||||
writer.WriteStrings(WormNames, 20);
|
||||
writer.Write(Unknown2);
|
||||
writer.Write(Unknown3);
|
||||
writer.Write(Unknown4);
|
||||
writer.Write(Unknown5);
|
||||
writer.Write(Unknown6);
|
||||
writer.Write(Unknown7);
|
||||
writer.Write(Unknown8);
|
||||
writer.Write(Unknown9);
|
||||
writer.Write(Unknown10);
|
||||
writer.Write(Unknown11);
|
||||
writer.Write(Unknown12);
|
||||
writer.Write(Unknown13);
|
||||
writer.Write(Unknown14);
|
||||
writer.Write(Unknown15);
|
||||
writer.Write(Unknown16);
|
||||
writer.Write(Unknown17);
|
||||
writer.Write(Unknown18);
|
||||
writer.Write(Unknown19);
|
||||
writer.Write(Unknown20);
|
||||
writer.Write(Unknown21);
|
||||
writer.Write(Unknown22);
|
||||
writer.Write(Unknown23);
|
||||
writer.Write(Unknown24);
|
||||
writer.Write(Unknown25);
|
||||
writer.Write(GamesLost);
|
||||
writer.Write(GamesWon);
|
||||
writer.Write(Unknown26);
|
||||
writer.Write(Unknown27);
|
||||
writer.Write(Kills);
|
||||
writer.Write(Deaths);
|
||||
writer.Write(CpuLevel);
|
||||
writer.Write(Unknown28);
|
||||
writer.Write(Unknown29);
|
||||
writer.Write(Unknown30);
|
||||
writer.Write(Kills);
|
||||
writer.Write(Deaths);
|
||||
writer.Write(Difference);
|
||||
writer.Write(GamesPlayed);
|
||||
writer.Write(Points);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -17,29 +17,20 @@ namespace Syroot.Worms.Worms2
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TeamContainer"/> class.
|
||||
/// </summary>
|
||||
public TeamContainer()
|
||||
{
|
||||
Teams = new List<Team>();
|
||||
}
|
||||
public TeamContainer() => Teams = new List<Team>();
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TeamContainer"/> class, loading the data from the given
|
||||
/// <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public TeamContainer(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public TeamContainer(Stream stream) => Load(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="TeamContainer"/> class, loading the data from the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public TeamContainer(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public TeamContainer(string fileName) => Load(fileName);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -56,14 +47,10 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
Teams = new List<Team>();
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
Teams.Add(reader.Load<Team>());
|
||||
}
|
||||
}
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
Teams = new List<Team>();
|
||||
while (!reader.EndOfStream)
|
||||
Teams.Add(reader.Load<Team>());
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -72,10 +59,8 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -84,13 +69,9 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII))
|
||||
{
|
||||
foreach (Team team in Teams)
|
||||
{
|
||||
team.Save(writer.BaseStream);
|
||||
}
|
||||
}
|
||||
using BinaryStream writer = new BinaryStream(stream, encoding: Encoding.ASCII);
|
||||
foreach (Team team in Teams)
|
||||
team.Save(writer.BaseStream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -99,10 +80,8 @@ namespace Syroot.Worms.Worms2
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
Save(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -28,28 +28,20 @@ namespace Syroot.Worms
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Archive"/> class.
|
||||
/// </summary>
|
||||
public Archive()
|
||||
{
|
||||
}
|
||||
public Archive() { }
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Archive"/> class, loading the data from the given
|
||||
/// <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public Archive(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public Archive(Stream stream) => Load(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="Archive"/> class, loading the data from the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public Archive(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public Archive(string fileName) => Load(fileName);
|
||||
|
||||
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
||||
|
||||
@ -60,49 +52,40 @@ namespace Syroot.Worms
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
if (!stream.CanSeek)
|
||||
{
|
||||
throw new ArgumentException("Stream requires to be seekable.", nameof(stream));
|
||||
}
|
||||
|
||||
Clear();
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
// Read the header.
|
||||
if (reader.ReadInt32() != _signature)
|
||||
{
|
||||
throw new InvalidDataException("Invalid DIR file signature.");
|
||||
}
|
||||
int fileSize = reader.ReadInt32();
|
||||
int tocOffset = reader.ReadInt32();
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
|
||||
// Read the table of contents.
|
||||
reader.Position = tocOffset;
|
||||
int tocSignature = reader.ReadInt32();
|
||||
if (tocSignature != _tocSignature)
|
||||
// Read the header.
|
||||
if (reader.ReadInt32() != _signature)
|
||||
throw new InvalidDataException("Invalid DIR file signature.");
|
||||
int fileSize = reader.ReadInt32();
|
||||
int tocOffset = reader.ReadInt32();
|
||||
|
||||
// Read the table of contents.
|
||||
reader.Position = tocOffset;
|
||||
int tocSignature = reader.ReadInt32();
|
||||
if (tocSignature != _tocSignature)
|
||||
throw new InvalidDataException("Invalid DIR table of contents signature.");
|
||||
// Generate a data dictionary out of the hash table and file entries.
|
||||
int[] hashTable = reader.ReadInt32s(_hashSize);
|
||||
foreach (int entryOffset in hashTable)
|
||||
{
|
||||
// If the hash is not 0, it points to a list of files which have a hash being the hash table index.
|
||||
if (entryOffset > 0)
|
||||
{
|
||||
throw new InvalidDataException("Invalid DIR table of contents signature.");
|
||||
}
|
||||
// Generate a data dictionary out of the hash table and file entries.
|
||||
int[] hashTable = reader.ReadInt32s(_hashSize);
|
||||
foreach (int entryOffset in hashTable)
|
||||
{
|
||||
// If the hash is not 0, it points to a list of files which have a hash being the hash table index.
|
||||
if (entryOffset > 0)
|
||||
int nextEntryOffset = entryOffset;
|
||||
do
|
||||
{
|
||||
int nextEntryOffset = entryOffset;
|
||||
do
|
||||
{
|
||||
reader.Position = tocOffset + nextEntryOffset;
|
||||
nextEntryOffset = reader.ReadInt32();
|
||||
int offset = reader.ReadInt32();
|
||||
int length = reader.ReadInt32();
|
||||
string name = reader.ReadString(StringCoding.ZeroTerminated);
|
||||
using (reader.TemporarySeek(offset, SeekOrigin.Begin))
|
||||
{
|
||||
Add(name, reader.ReadBytes(length));
|
||||
}
|
||||
} while (nextEntryOffset != 0);
|
||||
}
|
||||
reader.Position = tocOffset + nextEntryOffset;
|
||||
nextEntryOffset = reader.ReadInt32();
|
||||
int offset = reader.ReadInt32();
|
||||
int length = reader.ReadInt32();
|
||||
string name = reader.ReadString(StringCoding.ZeroTerminated);
|
||||
using (reader.TemporarySeek(offset, SeekOrigin.Begin))
|
||||
Add(name, reader.ReadBytes(length));
|
||||
} while (nextEntryOffset != 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -113,10 +96,8 @@ namespace Syroot.Worms
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -125,71 +106,66 @@ namespace Syroot.Worms
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data in.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
using (BinaryStream writer = new BinaryStream(stream))
|
||||
using BinaryStream writer = new BinaryStream(stream);
|
||||
|
||||
// Write the header.
|
||||
writer.Write(_signature);
|
||||
uint fileSizeOffset = writer.ReserveOffset();
|
||||
uint tocOffset = writer.ReserveOffset();
|
||||
|
||||
// Write the data and build the hash table and file entries.
|
||||
List<HashTableEntry>[] hashTable = new List<HashTableEntry>[_hashSize];
|
||||
foreach (KeyValuePair<string, byte[]> item in this)
|
||||
{
|
||||
// Write the header.
|
||||
writer.Write(_signature);
|
||||
uint fileSizeOffset = writer.ReserveOffset();
|
||||
uint tocOffset = writer.ReserveOffset();
|
||||
|
||||
// Write the data and build the hash table and file entries.
|
||||
List<HashTableEntry>[] hashTable = new List<HashTableEntry>[_hashSize];
|
||||
foreach (KeyValuePair<string, byte[]> item in this)
|
||||
HashTableEntry entry = new HashTableEntry()
|
||||
{
|
||||
HashTableEntry entry = new HashTableEntry()
|
||||
{
|
||||
Name = item.Key,
|
||||
Offset = (int)writer.Position,
|
||||
Length = item.Value.Length
|
||||
};
|
||||
writer.WriteStructs(item.Value);
|
||||
Name = item.Key,
|
||||
Offset = (int)writer.Position,
|
||||
Length = item.Value.Length
|
||||
};
|
||||
writer.WriteStructs(item.Value);
|
||||
|
||||
int hash = CalculateHash(item.Key);
|
||||
if (hashTable[hash] == null)
|
||||
{
|
||||
hashTable[hash] = new List<HashTableEntry>();
|
||||
}
|
||||
hashTable[hash].Add(entry);
|
||||
}
|
||||
|
||||
// Write the hash table and file entries.
|
||||
int tocStart = (int)writer.Position;
|
||||
int fileEntryOffset = sizeof(int) + _hashSize * sizeof(int);
|
||||
writer.SatisfyOffset(tocOffset, tocStart);
|
||||
writer.Write(_tocSignature);
|
||||
for (int i = 0; i < _hashSize; i++)
|
||||
{
|
||||
List<HashTableEntry> entries = hashTable[i];
|
||||
if (entries == null)
|
||||
{
|
||||
writer.Write(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write the entries resolving to the current hash.
|
||||
writer.Write(fileEntryOffset);
|
||||
using (writer.TemporarySeek(tocStart + fileEntryOffset, SeekOrigin.Begin))
|
||||
{
|
||||
for (int j = 0; j < entries.Count; j++)
|
||||
{
|
||||
HashTableEntry entry = entries[j];
|
||||
uint nextEntryOffset = writer.ReserveOffset();
|
||||
writer.Write(entry.Offset);
|
||||
writer.Write(entry.Length);
|
||||
writer.Write(entry.Name, StringCoding.ZeroTerminated);
|
||||
writer.Align(4);
|
||||
if (j < entries.Count - 1)
|
||||
{
|
||||
writer.SatisfyOffset(nextEntryOffset, (int)writer.Position - tocStart);
|
||||
}
|
||||
}
|
||||
fileEntryOffset = (int)writer.Position - tocStart;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writer.SatisfyOffset(fileSizeOffset, tocStart + fileEntryOffset - 1);
|
||||
int hash = CalculateHash(item.Key);
|
||||
if (hashTable[hash] == null)
|
||||
hashTable[hash] = new List<HashTableEntry>();
|
||||
hashTable[hash].Add(entry);
|
||||
}
|
||||
|
||||
// Write the hash table and file entries.
|
||||
int tocStart = (int)writer.Position;
|
||||
int fileEntryOffset = sizeof(int) + _hashSize * sizeof(int);
|
||||
writer.SatisfyOffset(tocOffset, tocStart);
|
||||
writer.Write(_tocSignature);
|
||||
for (int i = 0; i < _hashSize; i++)
|
||||
{
|
||||
List<HashTableEntry> entries = hashTable[i];
|
||||
if (entries == null)
|
||||
{
|
||||
writer.Write(0);
|
||||
}
|
||||
else
|
||||
{
|
||||
// Write the entries resolving to the current hash.
|
||||
writer.Write(fileEntryOffset);
|
||||
using (writer.TemporarySeek(tocStart + fileEntryOffset, SeekOrigin.Begin))
|
||||
{
|
||||
for (int j = 0; j < entries.Count; j++)
|
||||
{
|
||||
HashTableEntry entry = entries[j];
|
||||
uint nextEntryOffset = writer.ReserveOffset();
|
||||
writer.Write(entry.Offset);
|
||||
writer.Write(entry.Length);
|
||||
writer.Write(entry.Name, StringCoding.ZeroTerminated);
|
||||
writer.Align(4);
|
||||
if (j < entries.Count - 1)
|
||||
writer.SatisfyOffset(nextEntryOffset, (int)writer.Position - tocStart);
|
||||
}
|
||||
fileEntryOffset = (int)writer.Position - tocStart;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
writer.SatisfyOffset(fileSizeOffset, tocStart + fileEntryOffset - 1);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -198,10 +174,8 @@ namespace Syroot.Worms
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
Save(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
|
||||
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
|
||||
|
@ -5,6 +5,8 @@
|
||||
/// </summary>
|
||||
public static class Algebra
|
||||
{
|
||||
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// Gets the nearest, bigger <paramref name="multiple"/> of the given <paramref name="value"/>.
|
||||
/// </summary>
|
||||
|
@ -65,9 +65,7 @@ namespace Syroot.Worms.Core
|
||||
/// <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>
|
||||
public static byte SetBit(this byte self, int index, bool enable)
|
||||
{
|
||||
return enable ? EnableBit(self, index) : DisableBit(self, index);
|
||||
}
|
||||
=> enable ? EnableBit(self, index) : DisableBit(self, index);
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
/// <returns>The current byte with the bit toggled.</returns>
|
||||
public static byte ToggleBit(this byte self, int index)
|
||||
{
|
||||
return GetBit(self, index) ? DisableBit(self, index) : EnableBit(self, index);
|
||||
}
|
||||
=> GetBit(self, index) ? DisableBit(self, index) : EnableBit(self, index);
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
/// <returns>The decoded <see cref="Byte"/>.</returns>
|
||||
public static byte DecodeByte(this byte self, int bits, int firstBit)
|
||||
{
|
||||
// Shift to the first bit and keep only the required bits.
|
||||
return (byte)((self >> firstBit) & ((1 << bits) - 1));
|
||||
}
|
||||
=> (byte)((self >> firstBit) & ((1 << bits) - 1)); // shift to the first bit and keep only required bits
|
||||
|
||||
/// <summary>
|
||||
/// Returns an <see cref="SByte"/> instance represented by the given number of <paramref name="bits"/>.
|
||||
|
@ -15,10 +15,7 @@ namespace Syroot.Worms.Core
|
||||
|
||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||
|
||||
public DisposableGCHandle(object value, GCHandleType type)
|
||||
{
|
||||
_handle = GCHandle.Alloc(value, GCHandleType.Pinned);
|
||||
}
|
||||
public DisposableGCHandle(object value, GCHandleType type) => _handle = GCHandle.Alloc(value, type);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -26,26 +23,22 @@ namespace Syroot.Worms.Core
|
||||
|
||||
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
|
||||
|
||||
public void Dispose()
|
||||
{
|
||||
// Do not change this code. Put cleanup code in Dispose(bool disposing).
|
||||
Dispose(true);
|
||||
}
|
||||
public void Dispose() => Dispose(true);
|
||||
|
||||
// ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------
|
||||
|
||||
protected virtual void Dispose(bool disposing)
|
||||
{
|
||||
if (!_disposed)
|
||||
{
|
||||
if (disposing)
|
||||
{
|
||||
if (_handle.IsAllocated)
|
||||
_handle.Free();
|
||||
}
|
||||
if (_disposed)
|
||||
return;
|
||||
|
||||
_disposed = true;
|
||||
if (disposing)
|
||||
{
|
||||
if (_handle.IsAllocated)
|
||||
_handle.Free();
|
||||
}
|
||||
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -22,24 +22,23 @@ namespace Syroot.Worms.Core.Graphics
|
||||
/// <returns>The <see cref="Bitmap"/> instance.</returns>
|
||||
public static Bitmap CreateIndexed(Size size, IList<Color> palette, byte[] data)
|
||||
{
|
||||
using (DisposableGCHandle dataPin = new DisposableGCHandle(data, GCHandleType.Pinned))
|
||||
{
|
||||
// Transfer the pixel data, respecting power-of-2 strides.
|
||||
Bitmap bitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format8bppIndexed);
|
||||
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, size.Width, size.Height),
|
||||
ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
|
||||
for (int y = 0; y < size.Height; y++)
|
||||
Marshal.Copy(data, y * size.Width, bitmapData.Scan0 + y * bitmapData.Stride, size.Width);
|
||||
bitmap.UnlockBits(bitmapData);
|
||||
using DisposableGCHandle dataPin = new DisposableGCHandle(data, GCHandleType.Pinned);
|
||||
|
||||
// Transfer the palette.
|
||||
ColorPalette bitmapPalette = bitmap.Palette;
|
||||
for (int i = 0; i < palette.Count; i++)
|
||||
bitmapPalette.Entries[i] = palette[i];
|
||||
bitmap.Palette = bitmapPalette;
|
||||
// Transfer the pixel data, respecting power-of-2 strides.
|
||||
Bitmap bitmap = new Bitmap(size.Width, size.Height, PixelFormat.Format8bppIndexed);
|
||||
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, size.Width, size.Height),
|
||||
ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
|
||||
for (int y = 0; y < size.Height; y++)
|
||||
Marshal.Copy(data, y * size.Width, bitmapData.Scan0 + y * bitmapData.Stride, size.Width);
|
||||
bitmap.UnlockBits(bitmapData);
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
// Transfer the palette.
|
||||
ColorPalette bitmapPalette = bitmap.Palette;
|
||||
for (int i = 0; i < palette.Count; i++)
|
||||
bitmapPalette.Entries[i] = palette[i];
|
||||
bitmap.Palette = bitmapPalette;
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,24 +41,23 @@ namespace Syroot.Worms
|
||||
/// <returns>The <see cref="Bitmap"/> created from the raw data.</returns>
|
||||
public Bitmap ToBitmap()
|
||||
{
|
||||
using (DisposableGCHandle dataPin = new DisposableGCHandle(Data, GCHandleType.Pinned))
|
||||
{
|
||||
// Transfer the pixel data, respecting power-of-2 strides.
|
||||
Bitmap bitmap = new Bitmap(Size.Width, Size.Height, PixelFormat.Format8bppIndexed);
|
||||
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, Size.Width, Size.Height),
|
||||
ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
|
||||
for (int y = 0; y < Size.Height; y++)
|
||||
Marshal.Copy(Data, y * Size.Width, bitmapData.Scan0 + y * bitmapData.Stride, Size.Width);
|
||||
bitmap.UnlockBits(bitmapData);
|
||||
using DisposableGCHandle dataPin = new DisposableGCHandle(Data, GCHandleType.Pinned);
|
||||
|
||||
// Transfer the palette.
|
||||
ColorPalette bitmapPalette = bitmap.Palette;
|
||||
for (int i = 0; i < Palette.Count; i++)
|
||||
bitmapPalette.Entries[i] = Palette[i];
|
||||
bitmap.Palette = bitmapPalette;
|
||||
// Transfer the pixel data, respecting power-of-2 strides.
|
||||
Bitmap bitmap = new Bitmap(Size.Width, Size.Height, PixelFormat.Format8bppIndexed);
|
||||
BitmapData bitmapData = bitmap.LockBits(new Rectangle(0, 0, Size.Width, Size.Height),
|
||||
ImageLockMode.WriteOnly, PixelFormat.Format8bppIndexed);
|
||||
for (int y = 0; y < Size.Height; y++)
|
||||
Marshal.Copy(Data, y * Size.Width, bitmapData.Scan0 + y * bitmapData.Stride, Size.Width);
|
||||
bitmap.UnlockBits(bitmapData);
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
// Transfer the palette.
|
||||
ColorPalette bitmapPalette = bitmap.Palette;
|
||||
for (int i = 0; i < Palette.Count; i++)
|
||||
bitmapPalette.Entries[i] = Palette[i];
|
||||
bitmap.Palette = bitmapPalette;
|
||||
|
||||
return bitmap;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -87,11 +87,9 @@ namespace Syroot.Worms.Core.IO
|
||||
byte[] bytes = self.ReadBytes(Marshal.SizeOf<T>());
|
||||
|
||||
// Convert them to a structure instance and return it.
|
||||
using (DisposableGCHandle handle = new DisposableGCHandle(bytes, GCHandleType.Pinned))
|
||||
{
|
||||
T instance = Marshal.PtrToStructure<T>(handle.AddrOfPinnedObject);
|
||||
return instance;
|
||||
}
|
||||
using DisposableGCHandle handle = new DisposableGCHandle(bytes, GCHandleType.Pinned);
|
||||
T instance = Marshal.PtrToStructure<T>(handle.AddrOfPinnedObject);
|
||||
return instance;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -16,10 +16,7 @@ namespace Syroot.Worms.Core.Riff
|
||||
/// <paramref name="identifier"/>.
|
||||
/// </summary>
|
||||
/// <param name="identifier">The chunk identifier required to invoke this method for loading it.</param>
|
||||
internal RiffChunkLoadAttribute(string identifier)
|
||||
{
|
||||
Identifier = identifier;
|
||||
}
|
||||
internal RiffChunkLoadAttribute(string identifier) => Identifier = identifier;
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -16,10 +16,7 @@ namespace Syroot.Worms.Core.Riff
|
||||
/// <paramref name="identifier"/>.
|
||||
/// </summary>
|
||||
/// <param name="identifier">The chunk identifier saved in the file.</param>
|
||||
internal RiffChunkSaveAttribute(string identifier)
|
||||
{
|
||||
Identifier = identifier;
|
||||
}
|
||||
internal RiffChunkSaveAttribute(string identifier) => Identifier = identifier;
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -21,17 +21,14 @@ namespace Syroot.Worms.Core.Riff
|
||||
|
||||
private static readonly Dictionary<Type, TypeData> _typeDataCache = new Dictionary<Type, TypeData>();
|
||||
|
||||
private TypeData _typeData;
|
||||
private readonly TypeData _typeData;
|
||||
|
||||
// ---- CONSTRUCTORS & DESTRUCTOR ------------------------------------------------------------------------------
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RiffFile"/> class.
|
||||
/// </summary>
|
||||
protected RiffFile()
|
||||
{
|
||||
_typeData = GetTypeData();
|
||||
}
|
||||
protected RiffFile() => _typeData = GetTypeData();
|
||||
|
||||
// ---- METHODS (PROTECTED) ------------------------------------------------------------------------------------
|
||||
|
||||
@ -41,35 +38,26 @@ namespace Syroot.Worms.Core.Riff
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the RIFF data from.</param>
|
||||
protected void LoadRiff(Stream stream)
|
||||
{
|
||||
using (BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true))
|
||||
{
|
||||
// Read the file header.
|
||||
if (reader.ReadString(_signature.Length) != _signature)
|
||||
{
|
||||
throw new InvalidDataException("Invalid RIFF file signature.");
|
||||
}
|
||||
int fileSize = reader.ReadInt32();
|
||||
string fileIdentifier = reader.ReadString(4);
|
||||
if (fileIdentifier != _typeData.FileIdentifier)
|
||||
{
|
||||
throw new InvalidDataException("Invalid RIFF file identifier.");
|
||||
}
|
||||
using BinaryStream reader = new BinaryStream(stream, encoding: Encoding.ASCII, leaveOpen: true);
|
||||
|
||||
// Read the chunks.
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
string chunkIdentifier = reader.ReadString(4);
|
||||
int chunkLength = reader.ReadInt32();
|
||||
// Invoke a loader method if matching the identifier or skip the chunk.
|
||||
if (_typeData.ChunkLoaders.TryGetValue(chunkIdentifier, out MethodInfo loader))
|
||||
{
|
||||
loader.Invoke(this, new object[] { reader, chunkLength });
|
||||
}
|
||||
else
|
||||
{
|
||||
reader.Seek(chunkLength);
|
||||
}
|
||||
}
|
||||
// Read the file header.
|
||||
if (reader.ReadString(_signature.Length) != _signature)
|
||||
throw new InvalidDataException("Invalid RIFF file signature.");
|
||||
int fileSize = reader.ReadInt32();
|
||||
string fileIdentifier = reader.ReadString(4);
|
||||
if (fileIdentifier != _typeData.FileIdentifier)
|
||||
throw new InvalidDataException("Invalid RIFF file identifier.");
|
||||
|
||||
// Read the chunks.
|
||||
while (!reader.EndOfStream)
|
||||
{
|
||||
string chunkIdentifier = reader.ReadString(4);
|
||||
int chunkLength = reader.ReadInt32();
|
||||
// Invoke a loader method if matching the identifier or skip the chunk.
|
||||
if (_typeData.ChunkLoaders.TryGetValue(chunkIdentifier, out MethodInfo loader))
|
||||
loader.Invoke(this, new object[] { reader, chunkLength });
|
||||
else
|
||||
reader.Seek(chunkLength);
|
||||
}
|
||||
}
|
||||
|
||||
@ -79,26 +67,25 @@ namespace Syroot.Worms.Core.Riff
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the RIFF data in.</param>
|
||||
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.
|
||||
writer.Write(_signature, StringCoding.Raw);
|
||||
uint fileSizeOffset = writer.ReserveOffset();
|
||||
writer.Write(_typeData.FileIdentifier, StringCoding.Raw);
|
||||
|
||||
// Write the chunks.
|
||||
foreach (KeyValuePair<string, MethodInfo> chunkSaver in _typeData.ChunkSavers)
|
||||
{
|
||||
// Write the header.
|
||||
writer.Write(_signature, StringCoding.Raw);
|
||||
uint fileSizeOffset = writer.ReserveOffset();
|
||||
writer.Write(_typeData.FileIdentifier, StringCoding.Raw);
|
||||
writer.Write(chunkSaver.Key, StringCoding.Raw);
|
||||
uint chunkSizeOffset = writer.ReserveOffset();
|
||||
|
||||
// Write the chunks.
|
||||
foreach (KeyValuePair<string, MethodInfo> chunkSaver in _typeData.ChunkSavers)
|
||||
{
|
||||
writer.Write(chunkSaver.Key, StringCoding.Raw);
|
||||
uint chunkSizeOffset = writer.ReserveOffset();
|
||||
chunkSaver.Value.Invoke(this, new object[] { writer });
|
||||
|
||||
chunkSaver.Value.Invoke(this, new object[] { writer });
|
||||
|
||||
writer.SatisfyOffset(chunkSizeOffset, (int)(writer.Position - chunkSizeOffset - 4));
|
||||
}
|
||||
|
||||
writer.SatisfyOffset(fileSizeOffset, (int)(writer.Position - 8));
|
||||
writer.SatisfyOffset(chunkSizeOffset, (int)(writer.Position - chunkSizeOffset - 4));
|
||||
}
|
||||
|
||||
writer.SatisfyOffset(fileSizeOffset, (int)(writer.Position - 8));
|
||||
}
|
||||
|
||||
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
|
||||
@ -135,11 +122,8 @@ namespace Syroot.Worms.Core.Riff
|
||||
if (saveAttribute != null)
|
||||
{
|
||||
ParameterInfo[] parameters = method.GetParameters();
|
||||
if (parameters.Length == 1
|
||||
&& parameters[0].ParameterType == typeof(BinaryStream))
|
||||
{
|
||||
if (parameters.Length == 1 && parameters[0].ParameterType == typeof(BinaryStream))
|
||||
typeData.ChunkSavers.Add(saveAttribute.Identifier, method);
|
||||
}
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
@ -15,10 +15,7 @@ namespace Syroot.Worms.Core.Riff
|
||||
/// <paramref name="identifier"/>.
|
||||
/// </summary>
|
||||
/// <param name="identifier">The file identifier in the RIFF file header which will be validated.</param>
|
||||
internal RiffFileAttribute(string identifier)
|
||||
{
|
||||
Identifier = identifier;
|
||||
}
|
||||
internal RiffFileAttribute(string identifier) => Identifier = identifier;
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -18,9 +18,7 @@ namespace Syroot.Worms.Core
|
||||
/// <param name="bytes">The data to compress.</param>
|
||||
/// <returns>The compressed data.</returns>
|
||||
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>
|
||||
/// Decompresses the data available in the given <paramref name="stream"/> into the provided
|
||||
|
@ -67,8 +67,8 @@ namespace Syroot.Worms
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
Load(stream);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -78,61 +78,60 @@ namespace Syroot.Worms
|
||||
/// <param name="alignData"><c>true</c> to align the data array by 4 bytes.</param>
|
||||
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.
|
||||
if (reader.ReadInt32() != _signature)
|
||||
throw new InvalidDataException("Invalid IMG file signature.");
|
||||
int fileSize = reader.ReadInt32();
|
||||
|
||||
// Read an optional string describing the image contents and the bits per pixel.
|
||||
BitsPerPixel = reader.Read1Byte();
|
||||
if (BitsPerPixel == 0)
|
||||
{
|
||||
// Read the header.
|
||||
if (reader.ReadInt32() != _signature)
|
||||
throw new InvalidDataException("Invalid IMG file signature.");
|
||||
int fileSize = reader.ReadInt32();
|
||||
|
||||
// Read an optional string describing the image contents and the bits per pixel.
|
||||
Description = String.Empty;
|
||||
BitsPerPixel = reader.Read1Byte();
|
||||
if (BitsPerPixel == 0)
|
||||
{
|
||||
Description = String.Empty;
|
||||
BitsPerPixel = reader.Read1Byte();
|
||||
}
|
||||
else if (BitsPerPixel > 32)
|
||||
{
|
||||
Description = (char)BitsPerPixel + reader.ReadString(StringCoding.ZeroTerminated);
|
||||
BitsPerPixel = reader.Read1Byte();
|
||||
}
|
||||
else
|
||||
{
|
||||
Description = null;
|
||||
}
|
||||
|
||||
// Read image flags describing the format and availability of the following contents.
|
||||
Flags flags = (Flags)reader.ReadByte();
|
||||
|
||||
// Read the image palette if available. The first color of the palette is implicitly black.
|
||||
if (flags.HasFlag(Flags.Palettized))
|
||||
{
|
||||
int colorCount = reader.ReadInt16();
|
||||
Palette = new Color[colorCount + 1];
|
||||
Palette[0] = Color.Black;
|
||||
for (int i = 1; i <= colorCount; i++)
|
||||
Palette[i] = Color.FromArgb(reader.Read1Byte(), reader.Read1Byte(), reader.Read1Byte());
|
||||
}
|
||||
else
|
||||
{
|
||||
Palette = null;
|
||||
}
|
||||
|
||||
// Read the image size.
|
||||
Size = new Size(reader.ReadInt16(), reader.ReadInt16());
|
||||
|
||||
// Read the data byte array, which might be compressed or aligned.
|
||||
if (alignData)
|
||||
reader.Align(4);
|
||||
byte[] data = new byte[Size.Width * Size.Height * BitsPerPixel / 8];
|
||||
if (flags.HasFlag(Flags.Compressed))
|
||||
Team17Compression.Decompress(reader.BaseStream, data);
|
||||
else
|
||||
data = reader.ReadBytes(data.Length);
|
||||
|
||||
Data = data;
|
||||
}
|
||||
else if (BitsPerPixel > 32)
|
||||
{
|
||||
Description = (char)BitsPerPixel + reader.ReadString(StringCoding.ZeroTerminated);
|
||||
BitsPerPixel = reader.Read1Byte();
|
||||
}
|
||||
else
|
||||
{
|
||||
Description = null;
|
||||
}
|
||||
|
||||
// Read image flags describing the format and availability of the following contents.
|
||||
Flags flags = (Flags)reader.ReadByte();
|
||||
|
||||
// Read the image palette if available. The first color of the palette is implicitly black.
|
||||
if (flags.HasFlag(Flags.Palettized))
|
||||
{
|
||||
int colorCount = reader.ReadInt16();
|
||||
Palette = new Color[colorCount + 1];
|
||||
Palette[0] = Color.Black;
|
||||
for (int i = 1; i <= colorCount; i++)
|
||||
Palette[i] = Color.FromArgb(reader.Read1Byte(), reader.Read1Byte(), reader.Read1Byte());
|
||||
}
|
||||
else
|
||||
{
|
||||
Palette = null;
|
||||
}
|
||||
|
||||
// Read the image size.
|
||||
Size = new Size(reader.ReadInt16(), reader.ReadInt16());
|
||||
|
||||
// Read the data byte array, which might be compressed or aligned.
|
||||
if (alignData)
|
||||
reader.Align(4);
|
||||
byte[] data = new byte[Size.Width * Size.Height * BitsPerPixel / 8];
|
||||
if (flags.HasFlag(Flags.Compressed))
|
||||
Team17Compression.Decompress(reader.BaseStream, data);
|
||||
else
|
||||
data = reader.ReadBytes(data.Length);
|
||||
|
||||
Data = data;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -142,8 +141,8 @@ namespace Syroot.Worms
|
||||
/// <param name="alignData"><c>true</c> to align the data array by 4 bytes.</param>
|
||||
public void Load(string fileName, bool alignData)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
Load(stream);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream, alignData);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -181,52 +180,51 @@ namespace Syroot.Worms
|
||||
/// <param name="alignData"><c>true</c> to align the data array by 4 bytes.</param>
|
||||
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.
|
||||
writer.Write(_signature);
|
||||
uint fileSizeOffset = writer.ReserveOffset();
|
||||
|
||||
// Write an optional string describing the image contents and the bits per pixel.
|
||||
if (Description != null)
|
||||
writer.Write(Description, StringCoding.ZeroTerminated);
|
||||
writer.Write(BitsPerPixel);
|
||||
|
||||
// Write image flags describing the format and availability of the following contents.
|
||||
Flags flags = Flags.None;
|
||||
if (Palette != null)
|
||||
flags |= Flags.Palettized;
|
||||
if (compress)
|
||||
flags |= Flags.Compressed;
|
||||
writer.WriteEnum(flags, true);
|
||||
|
||||
// Write the image palette if available. The first color of the palette is implicitly black.
|
||||
if (Palette != null)
|
||||
{
|
||||
// Write the header.
|
||||
writer.Write(_signature);
|
||||
uint fileSizeOffset = writer.ReserveOffset();
|
||||
|
||||
// Write an optional string describing the image contents and the bits per pixel.
|
||||
if (Description != null)
|
||||
writer.Write(Description, StringCoding.ZeroTerminated);
|
||||
writer.Write(BitsPerPixel);
|
||||
|
||||
// Write image flags describing the format and availability of the following contents.
|
||||
Flags flags = Flags.None;
|
||||
if (Palette != null)
|
||||
flags |= Flags.Palettized;
|
||||
if (compress)
|
||||
flags |= Flags.Compressed;
|
||||
writer.WriteEnum(flags, true);
|
||||
|
||||
// Write the image palette if available. The first color of the palette is implicitly black.
|
||||
if (Palette != null)
|
||||
writer.Write((short)(Palette.Count - 1));
|
||||
for (int i = 1; i < Palette.Count; i++)
|
||||
{
|
||||
writer.Write((short)(Palette.Count - 1));
|
||||
for (int i = 1; i < Palette.Count; i++)
|
||||
{
|
||||
Color color = Palette[i];
|
||||
writer.Write(color.R);
|
||||
writer.Write(color.G);
|
||||
writer.Write(color.B);
|
||||
}
|
||||
Color color = Palette[i];
|
||||
writer.Write(color.R);
|
||||
writer.Write(color.G);
|
||||
writer.Write(color.B);
|
||||
}
|
||||
|
||||
// Write the image size.
|
||||
writer.Write((short)Size.Width);
|
||||
writer.Write((short)Size.Height);
|
||||
|
||||
// Write the data byte array, which might be compressed or aligned.
|
||||
if (alignData)
|
||||
writer.Align(4);
|
||||
byte[] data = Data;
|
||||
if (compress)
|
||||
data = Team17Compression.Compress(data);
|
||||
writer.WriteStructs(data);
|
||||
|
||||
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
|
||||
}
|
||||
|
||||
// Write the image size.
|
||||
writer.Write((short)Size.Width);
|
||||
writer.Write((short)Size.Height);
|
||||
|
||||
// Write the data byte array, which might be compressed or aligned.
|
||||
if (alignData)
|
||||
writer.Align(4);
|
||||
byte[] data = Data;
|
||||
if (compress)
|
||||
data = Team17Compression.Compress(data);
|
||||
writer.WriteStructs(data);
|
||||
|
||||
writer.SatisfyOffset(fileSizeOffset, (int)writer.Position);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
@ -237,8 +235,8 @@ namespace Syroot.Worms
|
||||
/// <param name="alignData"><c>true</c> to align the data array by 4 bytes.</param>
|
||||
public void Save(string fileName, bool compress, bool alignData)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
Save(stream, compress, alignData);
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream, compress, alignData);
|
||||
}
|
||||
|
||||
// ---- ENUMERATIONS -------------------------------------------------------------------------------------------
|
||||
|
@ -23,29 +23,20 @@ namespace Syroot.Worms
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RiffPalette"/> class.
|
||||
/// </summary>
|
||||
public RiffPalette()
|
||||
{
|
||||
Version = _version;
|
||||
}
|
||||
public RiffPalette() => Version = _version;
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RiffPalette"/> class, loading the data from the given
|
||||
/// <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public RiffPalette(Stream stream)
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
public RiffPalette(Stream stream) => Load(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Initializes a new instance of the <see cref="RiffPalette"/> class, loading the data from the given file.
|
||||
/// </summary>
|
||||
/// <param name="fileName">The name of the file to load the data from.</param>
|
||||
public RiffPalette(string fileName)
|
||||
{
|
||||
Load(fileName);
|
||||
}
|
||||
public RiffPalette(string fileName) => Load(fileName);
|
||||
|
||||
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
|
||||
|
||||
@ -80,10 +71,7 @@ namespace Syroot.Worms
|
||||
/// Loads the data from the given <see cref="Stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to load the data from.</param>
|
||||
public void Load(Stream stream)
|
||||
{
|
||||
LoadRiff(stream);
|
||||
}
|
||||
public void Load(Stream stream) => LoadRiff(stream);
|
||||
|
||||
/// <summary>
|
||||
/// 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>
|
||||
public void Load(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read))
|
||||
{
|
||||
Load(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Open, FileAccess.Read, FileShare.Read);
|
||||
Load(stream);
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Saves the data into the given <paramref name="stream"/>.
|
||||
/// </summary>
|
||||
/// <param name="stream">The <see cref="Stream"/> to save the data to.</param>
|
||||
public void Save(Stream stream)
|
||||
{
|
||||
SaveRiff(stream);
|
||||
}
|
||||
public void Save(Stream stream) => SaveRiff(stream);
|
||||
|
||||
/// <summary>
|
||||
/// Saves the data in the given file.
|
||||
@ -112,10 +95,8 @@ namespace Syroot.Worms
|
||||
/// <param name="fileName">The name of the file to save the data in.</param>
|
||||
public void Save(string fileName)
|
||||
{
|
||||
using (FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None))
|
||||
{
|
||||
Save(stream);
|
||||
}
|
||||
using FileStream stream = new FileStream(fileName, FileMode.Create, FileAccess.Write, FileShare.None);
|
||||
Save(stream);
|
||||
}
|
||||
|
||||
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
|
||||
@ -126,36 +107,25 @@ namespace Syroot.Worms
|
||||
// Read the PAL version.
|
||||
Version = reader.ReadInt16();
|
||||
if (Version != _version)
|
||||
{
|
||||
throw new InvalidDataException("Unknown PAL version.");
|
||||
}
|
||||
|
||||
// Read the colors.
|
||||
Colors = new Color[reader.ReadInt16()];
|
||||
for (int i = 0; i < Colors.Length; i++)
|
||||
{
|
||||
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")]
|
||||
private void LoadOfflChunk(BinaryStream reader, int length)
|
||||
{
|
||||
OfflData = reader.ReadBytes(length);
|
||||
}
|
||||
private void LoadOfflChunk(BinaryStream reader, int length) => OfflData = reader.ReadBytes(length);
|
||||
|
||||
[RiffChunkLoad("tran")]
|
||||
private void LoadTranChunk(BinaryStream reader, int length)
|
||||
{
|
||||
TranData = reader.ReadBytes(length);
|
||||
}
|
||||
private void LoadTranChunk(BinaryStream reader, int length) => TranData = reader.ReadBytes(length);
|
||||
|
||||
[RiffChunkLoad("unde")]
|
||||
private void LoadUndeChunk(BinaryStream reader, int length)
|
||||
{
|
||||
UndeData = reader.ReadBytes(length);
|
||||
}
|
||||
private void LoadUndeChunk(BinaryStream reader, int length) => UndeData = reader.ReadBytes(length);
|
||||
|
||||
[RiffChunkSave("data")]
|
||||
private void SaveDataChunk(BinaryStream writer)
|
||||
@ -176,21 +146,12 @@ namespace Syroot.Worms
|
||||
}
|
||||
|
||||
[RiffChunkSave("offl")]
|
||||
private void SaveOfflChunk(BinaryStream writer)
|
||||
{
|
||||
writer.WriteStructs(OfflData);
|
||||
}
|
||||
private void SaveOfflChunk(BinaryStream writer) => writer.WriteStructs(OfflData);
|
||||
|
||||
[RiffChunkSave("tran")]
|
||||
private void SaveTranChunk(BinaryStream writer)
|
||||
{
|
||||
writer.WriteStructs(TranData);
|
||||
}
|
||||
private void SaveTranChunk(BinaryStream writer) => writer.WriteStructs(TranData);
|
||||
|
||||
[RiffChunkSave("unde")]
|
||||
private void SaveUndeChunk(BinaryStream writer)
|
||||
{
|
||||
writer.WriteStructs(UndeData);
|
||||
}
|
||||
private void SaveUndeChunk(BinaryStream writer) => writer.WriteStructs(UndeData);
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,26 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Syroot.Worms</AssemblyName>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>.NET library for loading and modifying files of Team17 Worms games.</Description>
|
||||
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageIconUrl>https://gitlab.com/Syroot/Worms/raw/master/res/icon.png</PackageIconUrl>
|
||||
<PackageId>Syroot.Worms</PackageId>
|
||||
<PackageLicenseUrl>https://gitlab.com/Syroot/Worms/raw/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://gitlab.com/Syroot/Worms</PackageProjectUrl>
|
||||
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
|
||||
<PackageTags>worms;team17</PackageTags>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
|
||||
<TargetFrameworks>net461;netstandard2.0</TargetFrameworks>
|
||||
<Version>2.0.0-alpha1</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Syroot.BinaryData.Serialization" Version="5.0.0" />
|
||||
<PackageReference Include="Syroot.BinaryData" Version="5.1.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="4.5.1" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<AssemblyName>Syroot.Worms</AssemblyName>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<Description>.NET library for loading and modifying files of Team17 Worms games.</Description>
|
||||
<GenerateDocumentationFile Condition="'$(Configuration)'=='Release'">true</GenerateDocumentationFile>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<PackageIconUrl>https://gitlab.com/Syroot/Worms/raw/master/res/icon.png</PackageIconUrl>
|
||||
<PackageId>Syroot.Worms</PackageId>
|
||||
<PackageLicenseUrl>https://gitlab.com/Syroot/Worms/raw/master/LICENSE</PackageLicenseUrl>
|
||||
<PackageProjectUrl>https://gitlab.com/Syroot/Worms</PackageProjectUrl>
|
||||
<PackageReleaseNotes>Initial release.</PackageReleaseNotes>
|
||||
<PackageTags>worms;team17</PackageTags>
|
||||
<RepositoryType>git</RepositoryType>
|
||||
<RepositoryUrl>https://gitlab.com/Syroot/Worms</RepositoryUrl>
|
||||
<TargetFrameworks>netstandard2.0</TargetFrameworks>
|
||||
<Version>2.0.0</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Syroot.BinaryData.Serialization" Version="5.2.0" />
|
||||
<PackageReference Include="Syroot.BinaryData" Version="5.2.0" />
|
||||
<PackageReference Include="System.Drawing.Common" Version="4.6.0" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.6.0" />
|
||||
</ItemGroup>
|
||||
</Project>
|
@ -1,13 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Armageddon.ProjectX\Syroot.Worms.Armageddon.ProjectX.csproj" />
|
||||
<ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Armageddon.ProjectX\Syroot.Worms.Armageddon.ProjectX.csproj" />
|
||||
<ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -1,13 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Armageddon\Syroot.Worms.Armageddon.csproj" />
|
||||
<ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Armageddon\Syroot.Worms.Armageddon.csproj" />
|
||||
<ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -1,12 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.3.2" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.3.2" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -1,12 +1,12 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -1,13 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.WorldParty\Syroot.Worms.WorldParty.csproj" />
|
||||
<ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.WorldParty\Syroot.Worms.WorldParty.csproj" />
|
||||
<ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -1,13 +1,13 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="15.9.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="1.4.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="1.4.0" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Worms2\Syroot.Worms.Worms2.csproj" />
|
||||
<ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
<IsPackable>false</IsPackable>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.NET.Test.Sdk" Version="16.3.0" />
|
||||
<PackageReference Include="MSTest.TestAdapter" Version="2.0.0" />
|
||||
<PackageReference Include="MSTest.TestFramework" Version="2.0.0" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Worms2\Syroot.Worms.Worms2.csproj" />
|
||||
<ProjectReference Include="..\Syroot.Worms.Test\Syroot.Worms.Test.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -33,8 +33,8 @@ namespace Syroot.Worms.Mgame.GameServer
|
||||
// Retrieve external IP if not yet done and given IP is invalid.
|
||||
if (_ipAddress == null && (IP == null || !IPAddress.TryParse(IP, out _ipAddress)))
|
||||
{
|
||||
using (WebClient webClient = new WebClient())
|
||||
_ipAddress = IPAddress.Parse(webClient.DownloadString("https://ip.syroot.com"));
|
||||
using WebClient webClient = new WebClient();
|
||||
_ipAddress = IPAddress.Parse(webClient.DownloadString("https://ip.syroot.com"));
|
||||
}
|
||||
return _ipAddress;
|
||||
}
|
||||
|
@ -91,6 +91,7 @@ namespace Syroot.Worms.Mgame.GameServer.Packets
|
||||
{
|
||||
if (disposing)
|
||||
TcpClient.Dispose();
|
||||
_tcpStream.Dispose();
|
||||
_disposed = true;
|
||||
}
|
||||
}
|
||||
@ -102,10 +103,8 @@ namespace Syroot.Worms.Mgame.GameServer.Packets
|
||||
{
|
||||
// Let each packet format try to serialize the data.
|
||||
foreach (IPacketFormat format in _packetFormatPipe)
|
||||
{
|
||||
if (format.TrySave(_tcpStream, packet))
|
||||
return;
|
||||
}
|
||||
throw new NotImplementedException("Cannot send unhandled packet format.");
|
||||
}
|
||||
catch (IOException) { } // A network error appeared, and communication should end.
|
||||
|
@ -9,7 +9,7 @@ namespace Syroot.Worms.Mgame.GameServer
|
||||
{
|
||||
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
|
||||
|
||||
private static void Main(string[] args)
|
||||
private static void Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
|
@ -1,21 +1,21 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AssemblyName>Server</AssemblyName>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" />
|
||||
<PackageReference Include="Syroot.BinaryData.Memory" Version="5.2.0-alpha1" />
|
||||
<PackageReference Include="System.Text.Encoding.CodePages" Version="4.5.1" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
<None Update="ServerConfig.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<AssemblyName>Server</AssemblyName>
|
||||
<LangVersion>latest</LangVersion>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFrameworks>netcoreapp2.1</TargetFrameworks>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="3.0.0" />
|
||||
<PackageReference Include="Syroot.BinaryData.Memory" Version="5.2.2" />
|
||||
<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\Syroot.Worms.csproj" />
|
||||
<None Update="ServerConfig.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -14,7 +14,7 @@ namespace Syroot.Worms.Mgame.Launcher
|
||||
{
|
||||
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------
|
||||
|
||||
private static void Main(string[] args)
|
||||
private static void Main()
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -36,23 +36,25 @@ namespace Syroot.Worms.Mgame.Launcher
|
||||
using (launchConfig.CreateMappedFile(config.MappingName))
|
||||
{
|
||||
// Create and run the process.
|
||||
NativeProcess process = CreateProcess(executablePath,
|
||||
using (NativeProcess process = CreateProcess(executablePath,
|
||||
String.Join(" ", config.MappingName, config.ExecutableArgs).TrimEnd(),
|
||||
config.StartSuspended);
|
||||
if (config.StartSuspended)
|
||||
config.StartSuspended))
|
||||
{
|
||||
if (ShowMessage(MessageBoxIcon.Information,
|
||||
"Game process has been created and is paused. Click OK to resume or Cancel to kill it.",
|
||||
MessageBoxButtons.OKCancel) == DialogResult.OK)
|
||||
if (config.StartSuspended)
|
||||
{
|
||||
process.Resume();
|
||||
}
|
||||
else
|
||||
{
|
||||
process.Terminate();
|
||||
if (ShowMessage(MessageBoxIcon.Information,
|
||||
"Game process has been created and is paused. Click OK to resume or Cancel to kill it.",
|
||||
MessageBoxButtons.OKCancel) == DialogResult.OK)
|
||||
{
|
||||
process.Resume();
|
||||
}
|
||||
else
|
||||
{
|
||||
process.Terminate();
|
||||
}
|
||||
}
|
||||
process.WaitForExit();
|
||||
}
|
||||
process.WaitForExit();
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
|
@ -1,29 +1,29 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<ApplicationIcon>Resources\Icon.ico</ApplicationIcon>
|
||||
<ApplicationManifest>Resources\app.manifest</ApplicationManifest>
|
||||
<AssemblyName>Launcher</AssemblyName>
|
||||
<AssemblyTitle>Mgame Worms Launcher</AssemblyTitle>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<DebugType Condition="'$(Configuration)'=='Release'">None</DebugType>
|
||||
<Description>Game launcher for Mgame Worms games</Description>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<ProductName>Online Worms Launcher</ProductName>
|
||||
<TargetFrameworks>net461</TargetFrameworks>
|
||||
<Version>1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Costura.Fody" Version="3.3.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="2.2.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="2.2.0" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<None Update="LauncherConfig.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<AppendTargetFrameworkToOutputPath>false</AppendTargetFrameworkToOutputPath>
|
||||
<ApplicationIcon>Resources\Icon.ico</ApplicationIcon>
|
||||
<ApplicationManifest>Resources\app.manifest</ApplicationManifest>
|
||||
<AssemblyName>Launcher</AssemblyName>
|
||||
<AssemblyTitle>Mgame Worms Launcher</AssemblyTitle>
|
||||
<Authors>Syroot</Authors>
|
||||
<Copyright>(c) Syroot, licensed under MIT</Copyright>
|
||||
<DebugType Condition="'$(Configuration)'=='Release'">None</DebugType>
|
||||
<Description>Game launcher for Mgame Worms games</Description>
|
||||
<OutputType>WinExe</OutputType>
|
||||
<ProductName>Online Worms Launcher</ProductName>
|
||||
<TargetFrameworks>net461</TargetFrameworks>
|
||||
<Version>1.0.0</Version>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Costura.Fody" Version="4.1.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration" Version="3.0.0" />
|
||||
<PackageReference Include="Microsoft.Extensions.Configuration.Json" Version="3.0.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\Syroot.Worms.csproj" />
|
||||
<Reference Include="System.Windows.Forms" />
|
||||
<None Update="LauncherConfig.json">
|
||||
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
|
||||
</None>
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
|
@ -1,15 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<PackageReference Include="Syroot.BinaryData" Version="5.1.0" />
|
||||
<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.Mgame\Syroot.Worms.Mgame.csproj" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.WorldParty\Syroot.Worms.WorldParty.csproj" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Worms2\Syroot.Worms.Worms2.csproj" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>netcoreapp2.1</TargetFramework>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<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\Syroot.Worms.Armageddon.csproj" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Mgame\Syroot.Worms.Mgame.csproj" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.WorldParty\Syroot.Worms.WorldParty.csproj" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms.Worms2\Syroot.Worms.Worms2.csproj" />
|
||||
<ProjectReference Include="..\..\library\Syroot.Worms\Syroot.Worms.csproj" />
|
||||
</ItemGroup>
|
||||
</Project>
|
Loading…
x
Reference in New Issue
Block a user