mirror of
https://github.com/NexusForever/NexusForever
synced 2026-08-14 00:26:05 -04:00
* Update target typing (new type to new()) https://medium.com/swlh/an-introduction-to-the-new-features-in-c-9-305dc8fb74d2 4. Target Typing Improvements * Remove new line * Remove more new lines. * Updated type targed new to var for method variables to be consistent with the rest of the code base. Co-authored-by: Rawaho <rawahodev@gmail.com>
65 lines
2.1 KiB
C#
65 lines
2.1 KiB
C#
using System;
|
|
using System.IO;
|
|
using System.Runtime.InteropServices;
|
|
using Newtonsoft.Json;
|
|
using NexusForever.ClientConnector.Configuration;
|
|
using NexusForever.ClientConnector.Native;
|
|
|
|
namespace NexusForever.ClientConnector
|
|
{
|
|
internal static class Program
|
|
{
|
|
private const string jsonFile = "config.json";
|
|
|
|
[DllImport("kernel32.dll")]
|
|
static extern bool CreateProcess(
|
|
string lpApplicationName,
|
|
string lpCommandLine,
|
|
IntPtr lpProcessAttributes,
|
|
IntPtr lpThreadAttributes,
|
|
bool bInheritHandles,
|
|
uint dwCreationFlags,
|
|
IntPtr lpEnvironment,
|
|
string lpCurrentDirectory,
|
|
ref STARTUPINFO lpStartupInfo,
|
|
out PROCESS_INFORMATION lpProcessInformation
|
|
);
|
|
|
|
public static void Main()
|
|
{
|
|
if (!File.Exists(jsonFile))
|
|
{
|
|
Console.Write("Type in your host name: ");
|
|
string hostName = Console.ReadLine();
|
|
|
|
Console.Write("Type in your language: [en,de]");
|
|
string language = Console.ReadLine();
|
|
|
|
var clientConfig = new ClientConfiguration
|
|
{
|
|
HostName = hostName,
|
|
Language = language
|
|
};
|
|
|
|
File.WriteAllText(jsonFile, JsonConvert.SerializeObject(clientConfig));
|
|
}
|
|
|
|
ConfigurationManager<ClientConfiguration>.Initialise(jsonFile);
|
|
LaunchClient(ConfigurationManager<ClientConfiguration>.Config);
|
|
}
|
|
|
|
private static void LaunchClient(ClientConfiguration config)
|
|
{
|
|
var si = new STARTUPINFO();
|
|
var pi = new PROCESS_INFORMATION();
|
|
|
|
string client = "WildStar64.exe";
|
|
if (!File.Exists(client))
|
|
client = "WildStar32.exe";
|
|
|
|
CreateProcess(client,
|
|
$"/auth {config.HostName} /authNc {config.HostName} /lang {config.Language} /patcher {config.HostName} /SettingsKey WildStar /realmDataCenterId 9",
|
|
IntPtr.Zero, IntPtr.Zero, false, 0, IntPtr.Zero, null, ref si, out pi);
|
|
}
|
|
}
|
|
}
|