public static Task Launch(LauncherOptions options) { return(Task.Run(() => { var serverEndPoint = options.ResolveServerEndpoint().Result; ushort proxyPort = GetProxyPort(); var connectedToServerEvent = new AutoResetEvent(false); Program.ConnectedToServer += (sender, args) => { connectedToServerEvent.Set(); }; var proxyTask = Program.Start(serverEndPoint, proxyPort); if (!connectedToServerEvent.WaitOne(TimeSpan.FromSeconds(30))) { throw new TimeoutException("Server connection timeout."); } switch (options.ClientType) { case UltimaClientType.Classic: ClassicClientLauncher.Launch(options, proxyPort); break; case UltimaClientType.Orion: OrionLauncher.Launch(options, proxyPort); break; } InterProcessCommunication.StartReceiving(); })); }
private void CheckMulFiles(LauncherOptions options) { bool requiresExplicitUltimaPath = false; if (string.IsNullOrEmpty(Files.RootDir)) { console.Info("Cannot find Ultima Online installation."); requiresExplicitUltimaPath = true; } if (!string.IsNullOrEmpty(Files.RootDir) && !Directory.Exists(Files.RootDir)) { console.Info($"Ultima Online installation path {Files.RootDir} doesn't exsist."); requiresExplicitUltimaPath = true; } if (requiresExplicitUltimaPath) { var clientDirectory = Path.GetDirectoryName(options.ClientExePath); console.Info($"Client path is {options.ClientExePath}. Assuming Ultima Online files are in {clientDirectory}."); Files.SetMulPath(clientDirectory); } console.Debug($"Loading mul files from {Files.RootDir}."); }
public Task Launch(LauncherOptions options, InfusionProxy proxy) { return(Task.Run(() => { var launcher = GetLauncher(options); var serverEndPoint = options.ResolveServerEndpoint().Result; ushort proxyPort = options.GetDefaultProxyPort(); CheckMulFiles(options); launcher.Launch(console, proxy, options); InterProcessCommunication.StartReceiving(); })); }
public static void Launch(LauncherOptions options, ushort proxyPort) { LoginConfiguration.SetServerAddress("127.0.0.1", proxyPort); if (!string.IsNullOrEmpty(options.UserName)) { UltimaConfiguration.SetUserName(options.UserName); } if (!string.IsNullOrEmpty(options.Password)) { UltimaConfiguration.SetPassword(options.EncryptPassword()); } string ultimaExecutablePath = options.Classic.ClientExePath; if (!File.Exists(ultimaExecutablePath)) { Program.Console.Error($"File {ultimaExecutablePath} doesn't exist."); Program.Console.Info( "Infusion requires that you use a client without encryption. If your Ultima Online server allows using Third Dawn (3.x) clients, " + "you can download a client without encryption: https://ulozto.cz/!9w2rZmJfmcvA/client306m-patches-zip. \n\n" + @"The zip file contains NoCryptClient.exe. Copy it to your Ultima Online installation folder (typically c:\Program Files\Ultima Online 2D)." + "\n\n" + "You can read more about how to setup Infusion properly: https://github.com/uoinfusion/Infusion/wiki/Getting-started." + "\n"); return; } Program.Console.Info($"Staring {ultimaExecutablePath}"); var info = new ProcessStartInfo(ultimaExecutablePath); var ultimaClientProcess = Process.Start(info); if (ultimaClientProcess == null) { Program.Console.Error($"Cannot start {ultimaExecutablePath}."); return; } Program.SetClientWindowHandle(ultimaClientProcess); }
private ILauncher GetLauncher(LauncherOptions options) { switch (options.ClientType) { case UltimaClientType.Classic: return(new OfficialClientLauncher()); case UltimaClientType.ClassicUO: return(new ClassicUOLauncher()); case UltimaClientType.CrossUO: return(new CrossUOLauncher()); case UltimaClientType.Orion: return(new OrionLauncher()); case UltimaClientType.Generic: return(new GenericLauncher()); default: throw new NotImplementedException(options.ClientType.ToString()); } }
public static void Launch(LauncherOptions options, ushort proxyPort) { var ultimaExecutablePath = options.Orion.ClientExePath; if (!File.Exists(ultimaExecutablePath)) { Program.Console.Error($"File {ultimaExecutablePath} doesn't exist."); Program.Console.Info( "Infusion requires that you use a client without encryption. If your Ultima Online server allows using Third Dawn (3.x) clients, " + "you can download a client without encryption: https://ulozto.cz/!9w2rZmJfmcvA/client306m-patches-zip. \n\n" + @"The zip file contains NoCryptClient.exe. Copy it to your Ultima Online installation folder (typically c:\Program Files\Ultima Online 2D)." + "\n\n" + "You can read more about how to setup Infusion properly: https://github.com/uoinfusion/Infusion/wiki/Getting-started." + "\n"); return; } Program.Console.Info($"Staring {ultimaExecutablePath}"); var account = BitConverter.ToString(System.Text.Encoding.UTF8.GetBytes(options.UserName)).Replace("-", ""); var password = BitConverter.ToString(System.Text.Encoding.UTF8.GetBytes(options.Password)).Replace("-", ""); var info = new ProcessStartInfo(ultimaExecutablePath); info.WorkingDirectory = Path.GetDirectoryName(ultimaExecutablePath); info.Arguments = $"-autologin:0 -savepassword:0 \"-login 127.0.0.1,{proxyPort}\" -account:{account},{password}"; var ultimaClientProcess = Process.Start(info); if (ultimaClientProcess == null) { Program.Console.Error($"Cannot start {ultimaExecutablePath}."); return; } Program.SetClientWindowHandle(ultimaClientProcess); }