release 5.19

This commit is contained in:
1415ddfer 2024-05-19 10:43:41 +08:00
parent ff2a27a08d
commit cf7aa467b9
6 changed files with 98 additions and 57 deletions

View File

@ -24,11 +24,11 @@ namespace Zerolauncher.Manager
MessageBox.Show("正在更新游戏数据请等待1-3秒。\n 请检查网络", "错误", MessageBoxButton.OK, MessageBoxImage.Warning);
return true;
}
if (UpDateManager.state)
{
UpDateManager.DoUpdate();
return true;
}
//if (UpDateManager.state)
//{
// UpDateManager.DoUpdate();
// return true;
//}
var key = AccToKey(account);
if (mGame.ContainsKey(key)) { return false; }
if (CacheSha.errorCode != 0) {
@ -136,6 +136,7 @@ namespace Zerolauncher.Manager
mHandle = 0;
process = EngineShell.CheckEngineSafe(gameMode);
process.OutputDataReceived += Handle;
process.ErrorDataReceived += Handle;
process.Exited += Process_Exited;
process.Start();
@ -154,11 +155,11 @@ namespace Zerolauncher.Manager
private void Process_Exited(object? sender, EventArgs e)
{
//Trace.WriteLine(
// $"Exit time : {process.ExitTime}\n" +
// $"Exit code : {process.ExitCode}\n" +
// $"Elapsed time : {Math.Round((process.ExitTime - process.StartTime).TotalMilliseconds)}");
//Trace.WriteLine($"进程已退出:{account.nickName}");
Trace.WriteLine(
$"Exit time : {process.ExitTime}\n" +
$"Exit code : {process.ExitCode}\n" +
$"Elapsed time : {Math.Round((process.ExitTime - process.StartTime).TotalMilliseconds)}");
Trace.WriteLine($"进程已退出:{account.nickName}");
if (gameMode != StaticHandleA.GameMode) return;
if ( restartUrl == null)
{
@ -192,7 +193,7 @@ namespace Zerolauncher.Manager
Task.Run(async delegate
{
if (lines[1] == "True") await Task.Delay(5000);
_ = LoginManager.DoLogin(this);
LoginManager.DoLogin(this);
});
}
else
@ -205,6 +206,7 @@ namespace Zerolauncher.Manager
mHandle = int.Parse(lines[1]);
break;
case StaticHandleC.BrowserDone:
Trace.WriteLine($"尝试让游戏退出:{account.nickName}");
restartUrl = lines[1];
Send(StaticHandleS.CloseGame);
break;
@ -214,6 +216,13 @@ namespace Zerolauncher.Manager
case StaticHandleC.DownloadDone:
UpDateManager.OnDownLoadDone(lines[1]);
break;
case StaticHandleC.TakeVerify:
var args = lines[1].Split(' ');
_ = LoginManager.DoVerify(this, args[0], args[1]);
break;
default:
Trace.WriteLine($"from client:{e.Data}");
break;
}
}
@ -242,45 +251,45 @@ namespace Zerolauncher.Manager
{
bool is_first_luancher = EngineManager.CheckEmpy();
#region
if (mod == StaticHandleA.UpdateMode)
{
if (DataStream.dataStream.ecs.Length > 10)
{
string? now_bit;
using (SHA256 sha256 = SHA256.Create())
{
using (FileStream fileStream = File.OpenRead(engine_file))
{
byte[] hashBytes = sha256.ComputeHash(fileStream);
now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
}
}
if (DataStream.dataStream.ecs != now_bit)
{
Trace.WriteLine("lalalala" + DataStream.dataStream.ecs);
throw new FileReadException("error esu1!");
}
}
}
else if (!is_check && is_first_luancher)
{
string? now_bit;
using (SHA256 sha256 = SHA256.Create())
{
using (FileStream fileStream = File.OpenRead(engine_file))
{
byte[] hashBytes = sha256.ComputeHash(fileStream);
now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
}
}
if (CacheSha.GetE() != now_bit)
{
Trace.WriteLine("lalalala1");
throw new FileReadException("error esu0!");
}
if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); }
is_check = true;
}
//if (mod == StaticHandleA.UpdateMode)
//{
// if (DataStream.dataStream.ecs.Length > 10)
// {
// string? now_bit;
// using (SHA256 sha256 = SHA256.Create())
// {
// using (FileStream fileStream = File.OpenRead(engine_file))
// {
// byte[] hashBytes = sha256.ComputeHash(fileStream);
// now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
// }
// }
// if (DataStream.dataStream.ecs != now_bit)
// {
// Trace.WriteLine("lalalala" + DataStream.dataStream.ecs);
// throw new FileReadException("error esu1!");
// }
// }
//}
//else if (!is_check && is_first_luancher)
//{
// string? now_bit;
// using (SHA256 sha256 = SHA256.Create())
// {
// using (FileStream fileStream = File.OpenRead(engine_file))
// {
// byte[] hashBytes = sha256.ComputeHash(fileStream);
// now_bit = BitConverter.ToString(hashBytes).Replace("-", string.Empty);
// }
// }
// if (CacheSha.GetE() != now_bit)
// {
// Trace.WriteLine("lalalala1");
// throw new FileReadException("error esu0!");
// }
// if (DataStream.dataStream.ecs != now_bit) { DataStream.dataStream.ecs = now_bit; DataStream.write(); }
// is_check = true;
//}
#endregion
var process = new Process
@ -292,8 +301,9 @@ namespace Zerolauncher.Manager
UseShellExecute = false,
CreateNoWindow = true,
RedirectStandardInput = true,
RedirectStandardOutput = true
},
RedirectStandardOutput = true,
RedirectStandardError = true
},
EnableRaisingEvents = true
};
if (needShowTis) needShowTis = false;

View File

@ -1,6 +1,8 @@
using Newtonsoft.Json.Linq;
using System.Diagnostics;
using System.Drawing;
using System.Net;
using System.Net.Http;
using Zerolauncher.util;
namespace Zerolauncher.Manager
{
@ -59,7 +61,7 @@ namespace Zerolauncher.Manager
}
public static async Task DoLogin(SingleGame game)
public static void DoLogin(SingleGame game)
{
var client = new HttpClient();
client.DefaultRequestVersion = HttpVersion.Version20;
@ -87,5 +89,26 @@ namespace Zerolauncher.Manager
//}
game.Send($"{StaticHandleS.UseBrowser} {need_web} {game.account.providerId + 4} {ServicesStaticInfo.ServerIds[game.account.serverId]} {game.account.userName} {game.account.userPWD}");
}
public static async Task DoVerify(SingleGame game, string vid, string cookie)
{
var client = new HttpClient();
client.Timeout = TimeSpan.FromSeconds(3);
client.DefaultRequestHeaders.Add("Cookie", cookie);
try
{
var response = await client.GetAsync($"https://www.917play.com.tw/ddt_webserver/verify?{vid}");
var bin = response.Content.ReadAsStream();
if (OnnxManager.onnxVerify == null) OnnxManager.onnxVerify = new OnnxVerify();
var verify = OnnxManager.onnxVerify.RunInference(new Bitmap(bin));
game.Send($"{StaticHandleS.VerifyDone} {verify}");
Trace.WriteLine(verify);
}
catch (Exception ex)
{
Trace.WriteLine($"{StaticHandleS.HintText} 请求验证码时网络发生错误,类型:{ex.GetType().Name},消息:{ex.Message}");
}
}
}
}

View File

@ -10,6 +10,7 @@
public const string GameSa = "f0";
public const string CloseGame = "g0";
public const string UpdateInfo = "h0";
public const string VerifyDone = "i0";
}
class StaticHandleC
@ -21,7 +22,8 @@
public const string GameDone = "0e";
public const string Version = "0f";
public const string DownloadDone = "0g";
}
public const string TakeVerify = "0i";
}
class StaticHandleA
{

View File

@ -67,6 +67,9 @@
</ItemGroup>
<ItemGroup>
<None Update="plugin\model.bin">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>
<None Update="ZeroEngine.exe">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</None>

View File

@ -37,7 +37,6 @@ namespace Zerolauncher.dialog
}
cb_pid.SelectedIndex = 0;
cb_sid.SelectedIndex = 0;
cb_pid.IsEditable = false;
}

View File

@ -7,6 +7,10 @@ using System.Drawing;
namespace Zerolauncher.util
{
public class OnnxManager
{
public static OnnxVerify? onnxVerify;
}
public class OnnxVerify
{
private string _modelPath;
private InferenceSession _session;
@ -19,7 +23,7 @@ namespace Zerolauncher.util
"0", "1", "2", "3", "4", "5", "6", "7", "8", "9"
];
public OnnxManager(string modelPath = "ocr/model.onnx")
public OnnxVerify(string modelPath = "plugin/model.bin")
{
_modelPath = modelPath;
_session = new InferenceSession(_modelPath);