Release 1.0.0 of Mgame launcher.

This commit is contained in:
Ray Koopa 2019-01-13 02:09:04 +01:00
parent 13dee4ecbf
commit c0cab3ecf5
6 changed files with 26 additions and 35 deletions

View File

@ -12,7 +12,7 @@ namespace Syroot.Worms.Mgame.Launcher
public string UserName { get; set; }
public string Password { get; set; }
public uint PasswordKey { get; set; }
public int PasswordKey { get; set; }
public string ExecutablePaths { get; set; } = "DWait.exe;Main.exe";
public string ExecutableArgs { get; set; }

View File

@ -7,6 +7,9 @@ using Microsoft.Extensions.Configuration;
namespace Syroot.Worms.Mgame.Launcher
{
/// <summary>
/// Represents the main class of the application containing the program entry point.
/// </summary>
internal class Program
{
// ---- METHODS (PRIVATE) --------------------------------------------------------------------------------------

Binary file not shown.

Before

Width:  |  Height:  |  Size: 4.2 KiB

After

Width:  |  Height:  |  Size: 15 KiB

View File

@ -2,6 +2,7 @@
<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>
@ -11,8 +12,7 @@
<OutputType>WinExe</OutputType>
<ProductName>Online Worms Launcher</ProductName>
<TargetFrameworks>net461</TargetFrameworks>
<Version>0.5.0</Version>
<ApplicationManifest>app.manifest</ApplicationManifest>
<Version>1.0.0</Version>
</PropertyGroup>
<ItemGroup>
<PackageReference Include="Costura.Fody" Version="3.3.0" />

View File

@ -14,34 +14,29 @@ namespace Syroot.Worms.Mgame
{
// ---- FIELDS -------------------------------------------------------------------------------------------------
private static readonly char[] _invalidUserNameChars = { '=', '&', ' ' };
private string _userName;
private string _passwordString;
// ---- PROPERTIES ---------------------------------------------------------------------------------------------
/// <summary>
/// Gets or sets the name of the publisher providing the launch configuration. Must not exceed 15 characters.
/// </summary>
public string Publisher { get; set; } = "MGAME";
/// <summary>
/// Gets or sets an unknown value. Must not exceed 19 characters.
/// </summary>
public string Unknown { get; set; }
/// <summary>
/// Gets or sets the address of the game server.
/// </summary>
public IPEndPoint ServerEndPoint { get; set; }
/// <summary>
/// Gets or sets the initially entered user name.
/// Gets or sets the initially entered user name. Must not exceed 250 characters.
/// </summary>
public string UserName
{
get => _userName;
set
{
// 251 bytes is the space between "UID=" and the server IP, minus a terminating 0.
if (Encodings.Win949.GetBytes(value).Length > 251)
throw new ArgumentException("User name must not exceed 251 bytes.");
if (value.IndexOfAny(_invalidUserNameChars) != -1)
throw new ArgumentException("User name contains invalid characters.");
_userName = value;
}
}
public string UserName { get; set; }
// ---- METHODS (PUBLIC) ---------------------------------------------------------------------------------------
@ -57,19 +52,12 @@ namespace Syroot.Worms.Mgame
using (BinaryStream stream = new BinaryStream(mappedFile.CreateViewStream(),
encoding: Encodings.Win949, stringCoding: StringCoding.ZeroTerminated))
{
stream.WriteString("MGAME", 16);
stream.Position = 36;
stream.Write(_passwordString);
stream.Position = 66;
stream.Write("UID=", StringCoding.Raw);
stream.Write(Encodings.Win949.GetBytes(UserName));
stream.Position = 322;
stream.Write(ServerEndPoint.Address.ToString());
stream.Position = 352;
stream.Write(ServerEndPoint.Port.ToString());
stream.WriteString(Publisher, 16);
stream.WriteString(Unknown, 20);
stream.WriteString(_passwordString, 30);
stream.WriteString($"UID={UserName}", 256);
stream.WriteString(ServerEndPoint.Address.ToString(), 30);
stream.WriteString(ServerEndPoint.Port.ToString(), 914);
}
return mappedFile;
}
@ -92,9 +80,9 @@ namespace Syroot.Worms.Mgame
/// </summary>
/// <param name="password">The password to store encrypted.</param>
/// <param name="key">The key to encrypt with.</param>
public void SetPassword(string password, uint key = 1000)
public void SetPassword(string password, int key = 1000)
{
_passwordString = $";{PasswordCrypto.Encrypt(password, key)};{key}";
_passwordString = $";{PasswordCrypto.Encrypt(password, (uint)key)};{key}";
}
}
}