diff --git a/CTZLauncher/Authentication/CTZAuthenticator.cs b/CTZLauncher/Authentication/CTZAuthenticator.cs index c93c7e0..51cae68 100644 --- a/CTZLauncher/Authentication/CTZAuthenticator.cs +++ b/CTZLauncher/Authentication/CTZAuthenticator.cs @@ -69,12 +69,17 @@ namespace KMCCC.Authentication public string getServerList() { string sl = http.Send(HttpMethod.GET, Address + ":" + Port + "/serverlist"); - return sl.Replace("\0",""); + if (string.IsNullOrEmpty(sl)) + throw new ArgumentNullException("服务器返回了空的字符串或网络连接异常!"); + return sl; } public bool getResult(string url) { - return http.Send(HttpMethod.GET, url).Contains("true") ? true : false; + string result = http.Send(HttpMethod.GET, url); + if (string.IsNullOrEmpty(result)) + throw new ArgumentNullException("服务器返回了空的字符串或网络连接异常!"); + return result.Contains("true") ? true : false; } } } diff --git a/CTZLauncher/HttpHelper.cs b/CTZLauncher/HttpHelper.cs index 8ab0c22..38380e5 100644 --- a/CTZLauncher/HttpHelper.cs +++ b/CTZLauncher/HttpHelper.cs @@ -187,7 +187,14 @@ namespace CityCraft int iNumber = socket.Receive(buffer, buffer.Length, SocketFlags.None); while (iNumber > 0)//使用了Connection: Close 所以判断长度为0 时停止接受 { - responseBytes.AddRange(new List(buffer));//添加数据到List + if (iNumber < 1024) + { + byte[] shotbuffer = new byte[iNumber]; + Array.Copy(buffer, shotbuffer, iNumber); + responseBytes.AddRange(new List(shotbuffer));//添加数据到List + } + else + responseBytes.AddRange(new List(buffer));//添加数据到List iNumber = socket.Receive(buffer, buffer.Length, SocketFlags.None);//继续接收数据 } responseByte = responseBytes.ToArray(); diff --git a/CTZLauncher/Launcher/LaunchMode.cs b/CTZLauncher/Launcher/LaunchMode.cs index 036d21f..f71c51e 100644 --- a/CTZLauncher/Launcher/LaunchMode.cs +++ b/CTZLauncher/Launcher/LaunchMode.cs @@ -43,7 +43,7 @@ { public override bool Operate(LauncherCore core, MinecraftLaunchArguments args) { - args.Tokens["game_directory"] = String.Format(@".\versions\{0}\", args.Version.Id); + args.Tokens["game_directory"] = String.Format(@".minecraft\versions\{0}\", args.Version.Id); return true; } } diff --git a/CTZLauncher/Launcher/LauncherCore.cs b/CTZLauncher/Launcher/LauncherCore.cs index 46a70a9..67087dc 100644 --- a/CTZLauncher/Launcher/LauncherCore.cs +++ b/CTZLauncher/Launcher/LauncherCore.cs @@ -109,15 +109,20 @@ } /// - /// 游戏退出事件 + /// 游戏退出事件 /// public event Action GameExit; /// - /// 游戏Log事件 + /// 游戏Log事件 /// public event Action GameLog; - } + + /// + /// 游戏启动事件 + /// + public event Action GameStart; + } /// /// 启动器核心选项 diff --git a/CTZLauncher/Launcher/LauncherCoreInternal.cs b/CTZLauncher/Launcher/LauncherCoreInternal.cs index 2157a8d..4cf42dd 100644 --- a/CTZLauncher/Launcher/LauncherCoreInternal.cs +++ b/CTZLauncher/Launcher/LauncherCoreInternal.cs @@ -66,7 +66,7 @@ args.Tokens.Add("user_properties", authentication.Properties); args.Tokens.Add("user_type", authentication.UserType); - args.AdvencedArguments = new List { "-Dfml.ignoreInvalidMinecraftCertificates=true -Dfml.ignorePatchDiscrepancies=true" }; + args.AdvencedArguments = new List { "-Dfml.ignoreInvalidMinecraftCertificates=true", "-Dfml.ignorePatchDiscrepancies=true" }; args.Authentication = authentication; args.Version = options.Version; @@ -139,6 +139,7 @@ }) }; handle.Work(); + Start(handle, handle.GetTile()); Task.Factory.StartNew(handle.Process.WaitForExit).ContinueWith(t => Exit(handle, handle.Process.ExitCode)); return new LaunchResult { Success = true, Handle = handle }; } @@ -212,6 +213,14 @@ } } + internal void Start(LaunchHandle handle, string title) + { + if (GameStart != null) + { + GameStart(handle, title); + } + } + #endregion } } \ No newline at end of file diff --git a/CTZLauncher/MainWindow.xaml b/CTZLauncher/MainWindow.xaml index 7c9ac99..311d266 100644 --- a/CTZLauncher/MainWindow.xaml +++ b/CTZLauncher/MainWindow.xaml @@ -116,36 +116,36 @@