From cb5b7ffd22a7721d7e5d4fc29cfced9916fbc0fe Mon Sep 17 00:00:00 2001 From: j502647092 Date: Mon, 3 Aug 2015 20:44:34 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E6=94=B9=E4=B8=BA=E5=8F=8C=E7=95=8C?= =?UTF-8?q?=E9=9D=A2=20=E4=BC=98=E5=8C=96=E7=99=BB=E5=BD=95=E6=B5=81?= =?UTF-8?q?=E7=A8=8B...?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CTZLauncher/Authentication/Yggdrasil.cs | 17 +- CTZLauncher/CTZAuth/CTZAuth.cs | 49 --- CTZLauncher/CTZAuth/ICTZAuth.cs | 19 - CTZLauncher/CTZLauncher.csproj | 3 +- CTZLauncher/HttpHelper.cs | 10 + CTZLauncher/Launcher/LauncherCoreInternal.cs | 4 +- CTZLauncher/MainWindow.xaml | 114 ++++-- CTZLauncher/MainWindow.xaml.cs | 389 ++++++++++--------- 8 files changed, 301 insertions(+), 304 deletions(-) delete mode 100644 CTZLauncher/CTZAuth/CTZAuth.cs delete mode 100644 CTZLauncher/CTZAuth/ICTZAuth.cs diff --git a/CTZLauncher/Authentication/Yggdrasil.cs b/CTZLauncher/Authentication/Yggdrasil.cs index a9c0a43..4d4e094 100644 --- a/CTZLauncher/Authentication/Yggdrasil.cs +++ b/CTZLauncher/Authentication/Yggdrasil.cs @@ -17,7 +17,7 @@ public class YggdrasilLogin : IAuthenticator { /// - /// 新建正版验证器 + /// 新建正版验证器 /// /// 电子邮件地址 /// 密码 @@ -32,7 +32,7 @@ } /// - /// 新建正版验证器(随机的新ClientToken) + /// 新建正版验证器(随机的新ClientToken) /// /// 电子邮件地址 /// 密码 @@ -42,32 +42,37 @@ } /// - /// 电子邮件地址 + /// 电子邮件地址 /// public string Email { get; private set; } /// - /// 密码 + /// 密码 /// public string Password { get; private set; } /// - /// 是否启用Twitch + /// 是否启用Twitch /// public bool TwitchEnabled { get; private set; } /// + /// 客户端Token /// public Guid ClientToken { get; private set; } /// - /// 返回Yggdrasil验证器类型 + /// 返回Yggdrasil验证器类型 /// public string Type { get { return "KMCCC.Yggdrasil"; } } + /// + /// + /// + /// public AuthenticationInfo Do() { var client = new YggdrasilClient(ClientToken); diff --git a/CTZLauncher/CTZAuth/CTZAuth.cs b/CTZLauncher/CTZAuth/CTZAuth.cs deleted file mode 100644 index 11ff399..0000000 --- a/CTZLauncher/CTZAuth/CTZAuth.cs +++ /dev/null @@ -1,49 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Windows.Threading; -using CityCraft; -namespace CTZLauncher.CTZAuth -{ - class CTZAuth : ICTZAuth - { - HttpHelper http = new HttpHelper(); - string address; - int port; - - CTZAuth(string address,int port = 25565) - { - this.address = address; - this.port = port; - } - - public bool isRegister(string username) - { - return getResult(address + ":" + port + "/isregister?username=" + username); - } - - public bool Register(string username, string password) - { - return getResult(address + ":" + port + "/register?username=" + username + "&password=" + password); - } - - public bool isLogin(string username) - { - return getResult(address + ":" + port + "/islogin?username=" + username); - } - - public bool Login(string username, string password) - { - return getResult(address + ":" + port + "/login?username=" + username + "&password=" + password); - } - - public bool getResult(string url) - { - string result = http.Send(HttpMethod.GET, url); - if (result == "true") - return true; - return false; - } - } -} diff --git a/CTZLauncher/CTZAuth/ICTZAuth.cs b/CTZLauncher/CTZAuth/ICTZAuth.cs deleted file mode 100644 index 29acb70..0000000 --- a/CTZLauncher/CTZAuth/ICTZAuth.cs +++ /dev/null @@ -1,19 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; - -namespace CTZLauncher.CTZAuth -{ - interface ICTZAuth - { - bool isRegister(string username); - - bool Register(string username, string password); - - bool isLogin(string username); - - bool Login(string username, string password); - - } -} diff --git a/CTZLauncher/CTZLauncher.csproj b/CTZLauncher/CTZLauncher.csproj index 1b49e8b..8e2782b 100644 --- a/CTZLauncher/CTZLauncher.csproj +++ b/CTZLauncher/CTZLauncher.csproj @@ -74,8 +74,7 @@ - - + diff --git a/CTZLauncher/HttpHelper.cs b/CTZLauncher/HttpHelper.cs index ce42cf8..cdef5c1 100644 --- a/CTZLauncher/HttpHelper.cs +++ b/CTZLauncher/HttpHelper.cs @@ -63,6 +63,10 @@ namespace CityCraft /// 请求返回的Stream public string Send(HttpMethod method, string url, bool Async = false) { + if (string.IsNullOrEmpty(url)) + { + return string.Empty; + } readyState = HttpReadyState.载入; ParseURL(url); args.Method = method; @@ -142,6 +146,10 @@ namespace CityCraft address = nohttpurl.Substring(0, iIndex); args.Url = nohttpurl.Substring(iIndex); } + else + { + args.Url = "/"; + } iIndex = nohttpurl.IndexOf(@":"); if (iIndex > 0) { @@ -204,6 +212,7 @@ namespace CityCraft { string responseHeader = responseStr.Substring(0, splitindex); string responseBody = responseStr.Substring(splitindex + 4); + //Console.WriteLine(responseHeader); if (responseHeader.StartsWith("HTTP/1.1 400")) { Status = 400; @@ -377,6 +386,7 @@ namespace CityCraft } string header = bulider.ToString(); + //Console.WriteLine(header); return Encoding.Default.GetBytes(header); } #endregion diff --git a/CTZLauncher/Launcher/LauncherCoreInternal.cs b/CTZLauncher/Launcher/LauncherCoreInternal.cs index 2dbcce1..2157a8d 100644 --- a/CTZLauncher/Launcher/LauncherCoreInternal.cs +++ b/CTZLauncher/Launcher/LauncherCoreInternal.cs @@ -32,7 +32,7 @@ args.MainClass = options.Version.MainClass; args.MaxMemory = options.MaxMemory; args.MinMemory = options.MinMemory; - args.NativePath = GameRootPath + options.Version.Id + @"\\" + options.Version.Id + @"-natives"; + args.NativePath = GameRootPath + @"\versions\" + options.Version.Id + @"\" + options.Version.Id + @"-natives"; foreach (var native in options.Version.Natives) { var exp = ZipTools.UnzipFile(this.GetNativePath(native), args.NativePath, native.Options); @@ -58,7 +58,7 @@ args.Tokens.Add("auth_session", authentication.AccessToken.GoString()); args.Tokens.Add("auth_player_name", authentication.DisplayName); args.Tokens.Add("version_name", options.Version.Id); - args.Tokens.Add("game_directory", "."); + args.Tokens.Add("game_directory", GameRootPath + @"\versions\" + options.Version.Id + @"\"); args.Tokens.Add("game_assets", "assets"); args.Tokens.Add("assets_root", "assets"); args.Tokens.Add("assets_index_name", options.Version.Assets); diff --git a/CTZLauncher/MainWindow.xaml b/CTZLauncher/MainWindow.xaml index acb055c..06bcaf1 100644 --- a/CTZLauncher/MainWindow.xaml +++ b/CTZLauncher/MainWindow.xaml @@ -36,14 +36,6 @@ - - @@ -53,14 +45,14 @@