diff --git a/Download.cs b/Download.cs index 78eaf76..9c6efe4 100644 --- a/Download.cs +++ b/Download.cs @@ -1,5 +1,6 @@ using Downloader; using System.ComponentModel; +using YuukiPS_Launcher.Utils; using YuukiPS_Launcher.Yuuki; namespace YuukiPS_Launcher @@ -32,6 +33,11 @@ private void btDownload_Click(object sender, EventArgs e) return; } + if (File.Exists(set_folder)) + { + Logger.Info("Download", $"File old found {set_folder} remove for redownload?"); + File.Delete(set_folder); + } btDownload.Enabled = false; diff --git a/Game/Genshin/ServerRegionID.cs b/Game/Genshin/ServerRegionID.cs new file mode 100644 index 0000000..1d393a4 --- /dev/null +++ b/Game/Genshin/ServerRegionID.cs @@ -0,0 +1,25 @@ +using Newtonsoft.Json; +using Newtonsoft.Json.Converters; +using System; +using static YuukiPS_Launcher.Game.Genshin.Settings; + +public class ServerRegionIDConverter : StringEnumConverter +{ + public override object? ReadJson(JsonReader reader, Type objectType, object? existingValue, JsonSerializer serializer) + { + if (reader.TokenType == JsonToken.String) + { + string enumText = reader.Value.ToString(); + foreach (ServerRegionID enumValue in Enum.GetValues(typeof(ServerRegionID))) + { + if (enumValue.ToString().Equals(enumText, StringComparison.OrdinalIgnoreCase)) + { + return enumValue; + } + } + // Handle unknown value here + return ServerRegionID.os_usa; // Default value + } + return base.ReadJson(reader, objectType, existingValue, serializer); + } +} diff --git a/Game/Genshin/Settings.cs b/Game/Genshin/Settings.cs index 196cca1..1e0a08c 100644 --- a/Game/Genshin/Settings.cs +++ b/Game/Genshin/Settings.cs @@ -110,12 +110,7 @@ public enum ServerRegionID os_usa = 0, os_euro = 1, os_asia = 2, - os_cht = 3, - // YuukiPS - sg1 = 4, - eu1 = 5, - // make the warn thing to shut the hell up - dev_docker = 6 + os_cht = 3 } public class GeneralDataProp @@ -124,6 +119,7 @@ public class GeneralDataProp public string userLocalDataVersionId { get; set; } = "0.0.1"; public int deviceLanguageType { get; set; } = 1; public int deviceVoiceLanguageType { get; set; } = 2; + [JsonConverter(typeof(ServerRegionIDConverter))] public ServerRegionID? selectedServerName { get; set; } public int localLevelIndex { get; set; } = 0; public string deviceID { get; set; } = ""; diff --git a/Json/GameClient/Patch.cs b/Json/GameClient/Patch.cs index 5817537..40516c4 100644 --- a/Json/GameClient/Patch.cs +++ b/Json/GameClient/Patch.cs @@ -1,48 +1,17 @@ namespace YuukiPS_Launcher.Json.GameClient { - public class Cn - { - public string userassembly { get; set; } - public string metadata { get; set; } - } - - public class KeyFind - { - public string cn { get; set; } - public string os { get; set; } - } - - public class Md5Check - { - public Os os { get; set; } - public Cn cn { get; set; } - } - - public class Md5Vaild - { - public string os { get; set; } - public string cn { get; set; } - } - public class Original { - public string resources { get; set; } - public KeyFind key_find { get; set; } - public Md5Check md5_check { get; set; } - } - - public class Os - { - public string userassembly { get; set; } - public string metadata { get; set; } + public string file { get; set; } + public string location { get; set; } + public string md5 { get; set; } } public class Patched { - public string metode { get; set; } - public string resources { get; set; } - public string key_patch { get; set; } - public Md5Vaild md5_vaild { get; set; } + public string file { get; set; } + public string location { get; set; } + public string md5 { get; set; } } public class Patch @@ -50,8 +19,9 @@ public class Patch public string version { get; set; } = "0.0.0"; public string channel { get; set; } = "Global"; public string release { get; set; } = "Official"; + public string method { get; set; } = "copy"; // rare use public string nosupport { get; set; } = ""; - public Patched? patched { get; set; } - public Original? original { get; set; } + public List patched { get; set; } + public List original { get; set; } } } diff --git a/Json/KeyGS.cs b/Json/KeyGS.cs deleted file mode 100644 index 7c934dc..0000000 --- a/Json/KeyGS.cs +++ /dev/null @@ -1,46 +0,0 @@ -namespace YuukiPS_Launcher.Json -{ - public class MetaData - { - public string key1 { get; set; } - public string key2 { get; set; } - public string version { get; set; } - public string url_os { get; set; } - public string url_cn { get; set; } - public string md5_os { get; set; } - public string md5_cn { get; set; } - public string key2_os { get; set; } - public string key2_cn { get; set; } - public string api_os { get; set; } - public string api_cn { get; set; } - } - - public class Original - { - public MetaData MetaData { get; set; } - public UserAssembly UserAssembly { get; set; } - } - - public class Patched - { - public MetaData MetaData { get; set; } - public UserAssembly UserAssembly { get; set; } - } - - public class KeyGS - { - public Patched Patched { get; set; } - public Original Original { get; set; } - } - - public class UserAssembly - { - public string key1 { get; set; } - public string key2 { get; set; } - public string version { get; set; } - public string url_os { get; set; } - public string url_cn { get; set; } - public string md5_os { get; set; } - public string md5_cn { get; set; } - } -} diff --git a/Json/ServerList.cs b/Json/ServerList.cs deleted file mode 100644 index 6d573ad..0000000 --- a/Json/ServerList.cs +++ /dev/null @@ -1,17 +0,0 @@ -using YuukiPS_Launcher.Yuuki; - -namespace YuukiPS_Launcher.Json -{ - public class ServerList - { - public string time { get; set; } = "123"; - public List list { get; set; } = new List(); - } - - public class DataServer - { - public string name { get; set; } = "YuukiPS"; - public string host { get; set; } = API.WEB_LINK; - public GameType game { get; set; } = GameType.GenshinImpact; - } -} diff --git a/Json/VersionGenshin.cs b/Json/VersionGenshin.cs deleted file mode 100644 index c79fb5c..0000000 --- a/Json/VersionGenshin.cs +++ /dev/null @@ -1,11 +0,0 @@ -namespace YuukiPS_Launcher.Json -{ - public class VersionGenshin - { - public String version; - public String channel; - public String release; - public String metode; - public String md5; - } -} diff --git a/Json/VersionServer.cs b/Json/VersionServer.cs deleted file mode 100644 index d41a147..0000000 --- a/Json/VersionServer.cs +++ /dev/null @@ -1,25 +0,0 @@ -namespace YuukiPS_Launcher.Json -{ - public class VersionServer - { - public int retcode { get; set; } - public Status status { get; set; } = new Status(); - } - - public class Status - { - public int MemoryMax { get; set; } - public int MemoryCurrently { get; set; } - public int MemoryInit { get; set; } - public int MemoryCommitted { get; set; } - public int Thread { get; set; } - public int ThreadTotalStarted { get; set; } - public int ThreadDaemon { get; set; } - public int TotalAccount { get; set; } - public int playerCount { get; set; } - public int maxPlayer { get; set; } - public string DockerGS { get; set; } = "unknown"; - public string Version { get; set; } = "unknown"; - public string runMode { get; set; } = "HYBRID"; - } -} diff --git a/Main.Designer.cs b/Main.Designer.cs index 0c051f8..f8c48e6 100644 --- a/Main.Designer.cs +++ b/Main.Designer.cs @@ -60,7 +60,6 @@ private void InitializeComponent() Get_LA_Version = new Label(); Get_LA_MD5 = new Label(); Get_LA_CH = new Label(); - Get_LA_Metode = new Label(); Get_LA_REL = new Label(); tabPage2 = new TabPage(); tabControl2 = new TabControl(); @@ -86,25 +85,6 @@ private void InitializeComponent() label15 = new Label(); textBox1 = new TextBox(); label14 = new Label(); - tabPage4 = new TabPage(); - TabConfig = new TabControl(); - tabPage5 = new TabPage(); - Set_UA_Folder = new TextBox(); - Set_Metadata_Folder = new TextBox(); - label6 = new Label(); - label4 = new Label(); - Set_LA_GameFile = new TextBox(); - label7 = new Label(); - tabPage3 = new TabPage(); - progressBar1 = new ProgressBar(); - label9 = new Label(); - label3 = new Label(); - txt_statusUpd = new Label(); - btnstartUpdate = new Button(); - groupBox1 = new GroupBox(); - btchooseupdate = new Button(); - tbx_update = new TextBox(); - label1 = new Label(); Set_Version = new Label(); linkDiscord = new LinkLabel(); linkGithub = new LinkLabel(); @@ -126,11 +106,6 @@ private void InitializeComponent() groupBox6.SuspendLayout(); groupBox5.SuspendLayout(); tabPage11.SuspendLayout(); - tabPage4.SuspendLayout(); - TabConfig.SuspendLayout(); - tabPage5.SuspendLayout(); - tabPage3.SuspendLayout(); - groupBox1.SuspendLayout(); SuspendLayout(); // // btStartNormal @@ -175,8 +150,6 @@ private void InitializeComponent() // TabMain.Controls.Add(tabPage1); TabMain.Controls.Add(tabPage2); - TabMain.Controls.Add(tabPage4); - TabMain.Controls.Add(tabPage3); TabMain.Dock = DockStyle.Top; TabMain.Location = new Point(0, 0); TabMain.Name = "TabMain"; @@ -361,7 +334,7 @@ private void InitializeComponent() grExtra.Controls.Add(Enable_SendLog); grExtra.Controls.Add(Extra_Cheat); grExtra.Controls.Add(Enable_RPC); - grExtra.Location = new Point(432, 248); + grExtra.Location = new Point(431, 183); grExtra.Name = "grExtra"; grExtra.Size = new Size(217, 101); grExtra.TabIndex = 12; @@ -418,9 +391,9 @@ private void InitializeComponent() grProxy.Controls.Add(GetProxyPort); grProxy.Controls.Add(CheckProxyEnable); grProxy.Controls.Add(label2); - grProxy.Location = new Point(431, 191); + grProxy.Location = new Point(431, 127); grProxy.Name = "grProxy"; - grProxy.Size = new Size(215, 51); + grProxy.Size = new Size(217, 51); grProxy.TabIndex = 11; grProxy.TabStop = false; grProxy.Text = "Proxy"; @@ -442,11 +415,10 @@ private void InitializeComponent() groupBox3.Controls.Add(Get_LA_Version); groupBox3.Controls.Add(Get_LA_MD5); groupBox3.Controls.Add(Get_LA_CH); - groupBox3.Controls.Add(Get_LA_Metode); groupBox3.Controls.Add(Get_LA_REL); groupBox3.Location = new Point(431, 8); groupBox3.Name = "groupBox3"; - groupBox3.Size = new Size(217, 177); + groupBox3.Size = new Size(217, 114); groupBox3.TabIndex = 8; groupBox3.TabStop = false; groupBox3.Text = "Game"; @@ -465,7 +437,7 @@ private void InitializeComponent() // Get_LA_MD5.AutoSize = true; Get_LA_MD5.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - Get_LA_MD5.Location = new Point(7, 145); + Get_LA_MD5.Location = new Point(6, 82); Get_LA_MD5.Name = "Get_LA_MD5"; Get_LA_MD5.Size = new Size(118, 21); Get_LA_MD5.TabIndex = 7; @@ -475,27 +447,17 @@ private void InitializeComponent() // Get_LA_CH.AutoSize = true; Get_LA_CH.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - Get_LA_CH.Location = new Point(6, 50); + Get_LA_CH.Location = new Point(6, 40); Get_LA_CH.Name = "Get_LA_CH"; Get_LA_CH.Size = new Size(141, 21); Get_LA_CH.TabIndex = 4; Get_LA_CH.Text = "Channel: Unknown"; // - // Get_LA_Metode - // - Get_LA_Metode.AutoSize = true; - Get_LA_Metode.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - Get_LA_Metode.Location = new Point(6, 114); - Get_LA_Metode.Name = "Get_LA_Metode"; - Get_LA_Metode.Size = new Size(141, 21); - Get_LA_Metode.TabIndex = 6; - Get_LA_Metode.Text = "Metode: Unknown"; - // // Get_LA_REL // Get_LA_REL.AutoSize = true; Get_LA_REL.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - Get_LA_REL.Location = new Point(6, 83); + Get_LA_REL.Location = new Point(6, 61); Get_LA_REL.Name = "Get_LA_REL"; Get_LA_REL.Size = new Size(137, 21); Get_LA_REL.TabIndex = 5; @@ -749,204 +711,6 @@ private void InitializeComponent() label14.TabIndex = 0; label14.Text = "Grasscutter Folder:"; // - // tabPage4 - // - tabPage4.Controls.Add(TabConfig); - tabPage4.Location = new Point(4, 24); - tabPage4.Name = "tabPage4"; - tabPage4.Size = new Size(654, 383); - tabPage4.TabIndex = 3; - tabPage4.Text = "Config"; - tabPage4.UseVisualStyleBackColor = true; - // - // TabConfig - // - TabConfig.Controls.Add(tabPage5); - TabConfig.Dock = DockStyle.Fill; - TabConfig.Location = new Point(0, 0); - TabConfig.Name = "TabConfig"; - TabConfig.SelectedIndex = 0; - TabConfig.Size = new Size(654, 383); - TabConfig.TabIndex = 0; - // - // tabPage5 - // - tabPage5.Controls.Add(Set_UA_Folder); - tabPage5.Controls.Add(Set_Metadata_Folder); - tabPage5.Controls.Add(label6); - tabPage5.Controls.Add(label4); - tabPage5.Controls.Add(Set_LA_GameFile); - tabPage5.Controls.Add(label7); - tabPage5.Location = new Point(4, 24); - tabPage5.Name = "tabPage5"; - tabPage5.Padding = new Padding(3); - tabPage5.Size = new Size(646, 355); - tabPage5.TabIndex = 0; - tabPage5.Text = "Launcher"; - tabPage5.UseVisualStyleBackColor = true; - // - // Set_UA_Folder - // - Set_UA_Folder.Location = new Point(195, 89); - Set_UA_Folder.Name = "Set_UA_Folder"; - Set_UA_Folder.ReadOnly = true; - Set_UA_Folder.Size = new Size(219, 23); - Set_UA_Folder.TabIndex = 1; - // - // Set_Metadata_Folder - // - Set_Metadata_Folder.Location = new Point(10, 89); - Set_Metadata_Folder.Name = "Set_Metadata_Folder"; - Set_Metadata_Folder.ReadOnly = true; - Set_Metadata_Folder.Size = new Size(179, 23); - Set_Metadata_Folder.TabIndex = 4; - // - // label6 - // - label6.AutoSize = true; - label6.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - label6.Location = new Point(195, 62); - label6.Name = "label6"; - label6.Size = new Size(160, 21); - label6.TabIndex = 0; - label6.Text = "UserAssembly Folder:"; - // - // label4 - // - label4.AutoSize = true; - label4.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - label4.Location = new Point(10, 62); - label4.Name = "label4"; - label4.Size = new Size(126, 21); - label4.TabIndex = 3; - label4.Text = "Metadata Folder:"; - // - // Set_LA_GameFile - // - Set_LA_GameFile.Location = new Point(10, 36); - Set_LA_GameFile.Name = "Set_LA_GameFile"; - Set_LA_GameFile.ReadOnly = true; - Set_LA_GameFile.Size = new Size(405, 23); - Set_LA_GameFile.TabIndex = 11; - // - // label7 - // - label7.AutoSize = true; - label7.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - label7.Location = new Point(6, 12); - label7.Name = "label7"; - label7.Size = new Size(86, 21); - label7.TabIndex = 10; - label7.Text = "Game files:"; - // - // tabPage3 - // - tabPage3.Controls.Add(progressBar1); - tabPage3.Controls.Add(label9); - tabPage3.Controls.Add(label3); - tabPage3.Controls.Add(txt_statusUpd); - tabPage3.Controls.Add(btnstartUpdate); - tabPage3.Controls.Add(groupBox1); - tabPage3.Location = new Point(4, 24); - tabPage3.Name = "tabPage3"; - tabPage3.Padding = new Padding(3); - tabPage3.Size = new Size(654, 383); - tabPage3.TabIndex = 4; - tabPage3.Text = "Updater"; - tabPage3.UseVisualStyleBackColor = true; - // - // progressBar1 - // - progressBar1.Location = new Point(17, 199); - progressBar1.Maximum = 101; - progressBar1.Name = "progressBar1"; - progressBar1.Size = new Size(600, 34); - progressBar1.TabIndex = 25; - // - // label9 - // - label9.AutoSize = true; - label9.Font = new Font("Segoe UI", 18F, FontStyle.Regular, GraphicsUnit.Point); - label9.Location = new Point(92, 336); - label9.Name = "label9"; - label9.Size = new Size(465, 32); - label9.TabIndex = 24; - label9.Text = "Set again the game folder upon using this"; - label9.TextAlign = ContentAlignment.TopCenter; - // - // label3 - // - label3.AutoSize = true; - label3.Font = new Font("Segoe UI", 18F, FontStyle.Regular, GraphicsUnit.Point); - label3.Location = new Point(56, 253); - label3.Name = "label3"; - label3.Size = new Size(555, 64); - label3.TabIndex = 23; - label3.Text = "Note: Do NOT use this to update GI from a version\r\nlower than 3.5.0 (or 3.5.0) to 3.6.0+"; - label3.TextAlign = ContentAlignment.TopCenter; - // - // txt_statusUpd - // - txt_statusUpd.AutoSize = true; - txt_statusUpd.Font = new Font("Segoe UI", 18F, FontStyle.Regular, GraphicsUnit.Point); - txt_statusUpd.Location = new Point(6, 80); - txt_statusUpd.Name = "txt_statusUpd"; - txt_statusUpd.Size = new Size(176, 32); - txt_statusUpd.TabIndex = 22; - txt_statusUpd.Text = "Status: Waiting."; - // - // btnstartUpdate - // - btnstartUpdate.Font = new Font("Segoe UI", 18F, FontStyle.Regular, GraphicsUnit.Point); - btnstartUpdate.Location = new Point(459, 16); - btnstartUpdate.Name = "btnstartUpdate"; - btnstartUpdate.Size = new Size(158, 49); - btnstartUpdate.TabIndex = 21; - btnstartUpdate.Text = "Start"; - btnstartUpdate.UseVisualStyleBackColor = true; - btnstartUpdate.Click += btnstartUpdate_Click; - // - // groupBox1 - // - groupBox1.Controls.Add(btchooseupdate); - groupBox1.Controls.Add(tbx_update); - groupBox1.Controls.Add(label1); - groupBox1.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - groupBox1.Location = new Point(8, 6); - groupBox1.Name = "groupBox1"; - groupBox1.Size = new Size(420, 59); - groupBox1.TabIndex = 20; - groupBox1.TabStop = false; - groupBox1.Text = "Update Config"; - // - // btchooseupdate - // - btchooseupdate.Location = new Point(331, 16); - btchooseupdate.Name = "btchooseupdate"; - btchooseupdate.Size = new Size(76, 30); - btchooseupdate.TabIndex = 9; - btchooseupdate.Text = "Choose"; - btchooseupdate.UseVisualStyleBackColor = true; - btchooseupdate.Click += btchooseupdate_Click; - // - // tbx_update - // - tbx_update.Location = new Point(117, 17); - tbx_update.Name = "tbx_update"; - tbx_update.ReadOnly = true; - tbx_update.Size = new Size(208, 29); - tbx_update.TabIndex = 1; - // - // label1 - // - label1.AutoSize = true; - label1.Font = new Font("Segoe UI", 12F, FontStyle.Regular, GraphicsUnit.Point); - label1.Location = new Point(9, 25); - label1.Name = "label1"; - label1.Size = new Size(97, 21); - label1.TabIndex = 0; - label1.Text = "Update Path:"; - // // Set_Version // Set_Version.AutoSize = true; @@ -1044,14 +808,6 @@ private void InitializeComponent() groupBox5.ResumeLayout(false); tabPage11.ResumeLayout(false); tabPage11.PerformLayout(); - tabPage4.ResumeLayout(false); - TabConfig.ResumeLayout(false); - tabPage5.ResumeLayout(false); - tabPage5.PerformLayout(); - tabPage3.ResumeLayout(false); - tabPage3.PerformLayout(); - groupBox1.ResumeLayout(false); - groupBox1.PerformLayout(); ResumeLayout(false); PerformLayout(); } @@ -1066,7 +822,6 @@ private void InitializeComponent() private TabPage tabPage1; private TabPage tabPage2; private Button Server_Start; - private TabPage tabPage4; private GroupBox grProxy; private CheckBox CheckProxyEnable; private Label Set_Version; @@ -1074,10 +829,6 @@ private void InitializeComponent() private LinkLabel linkDiscord; private LinkLabel linkGithub; private LinkLabel linkWeb; - private TabControl TabConfig; - private TabPage tabPage5; - private TextBox Set_Metadata_Folder; - private Label label4; private GroupBox grExtra; private CheckBox Extra_Cheat; private CheckBox Enable_RPC; @@ -1086,15 +837,10 @@ private void InitializeComponent() private Button btsave; private GroupBox groupBox3; private Label Get_LA_MD5; - private Label Get_LA_Metode; private Label Get_LA_REL; private Label Get_LA_CH; private Label Get_LA_Version; private Button Set_LA_Select; - private TextBox Set_UA_Folder; - private Label label6; - private TextBox Set_LA_GameFile; - private Label label7; private System.Windows.Forms.Timer CheckGameRun; private System.Windows.Forms.Timer CheckProxyRun; private Label label8; @@ -1128,16 +874,6 @@ private void InitializeComponent() private GroupBox groupBox8; private GroupBox grConfigGameLite; private Button btStartYuukiServer; - private TabPage tabPage3; - private GroupBox groupBox1; - private Button btchooseupdate; - private TextBox tbx_update; - private Label label1; - private Button btnstartUpdate; - private Label txt_statusUpd; - private Label label3; - private Label label9; - private ProgressBar progressBar1; private CheckBox Enable_SendLog; private CheckBox Enable_WipeLoginCache; } diff --git a/Main.cs b/Main.cs index b26ee01..79c584f 100644 --- a/Main.cs +++ b/Main.cs @@ -5,108 +5,32 @@ using YuukiPS_Launcher.Json; using YuukiPS_Launcher.Json.GameClient; using YuukiPS_Launcher.Yuuki; -using ICSharpCode.SharpZipLib.Zip; using YuukiPS_Launcher.Utils; -using System.Net; using System.Security.Cryptography.X509Certificates; +using System.IO; namespace YuukiPS_Launcher { public partial class Main : Form - { - private void WipeLogin() - { - string keyName = "Software\\miHoYo"; // default value to not delete PC system. learned this the hard way!! - string subKeyName = "Genshin Impact"; - - if (GetTypeGame.Text == "GenshinImpact") - { - keyName = "Software\\miHoYo"; - subKeyName = "Genshin Impact"; - } - else if (GetTypeGame.Text == "StarRail") - { - keyName = "Software\\Cognosphere"; - subKeyName = "Star Rail"; - } - - using (RegistryKey key = Registry.CurrentUser.OpenSubKey(keyName, true)) - { - if (key == null) - { - Logger.Warning("Login", subKeyName + " doesn't exist."); - return; - } - else - { - try - { - key.DeleteSubKeyTree(subKeyName); - } - catch (Exception ex) - { - Logger.Warning("Login", subKeyName + " doesn't exist."); - } - Logger.Info("Login", "Wiped login cache!"); - } - } - } - - private string randomString() - { - Random rnd = new(); - - var results = new Dictionary - { - {0, "Hey, I'm YuukiPS Launcher, and I'm a logaholic."}, - {1, "u-uhm how do i give myself all items? 🤓"}, - {2, "9999: Git analysis?\nGit: Skill issue, sir."}, - {3, ":smiley:"}, - {4, "i'm lazy"}, - {5, "makeitmeme.com/join/ATCBQ\n9999: Oh no iplogger ☎️☎️☎️☎️"}, - {6, "Error 404: Motivation not found"}, - {7, "A programmer's favorite hangout spot? The Foo Bar."}, - {8, "I told my computer I needed a break, and it said 'No, you need to update'."}, - {9, "What's iwak???"}, - {10, "I hate [object Object]"}, - {11, "My cat's name :(){:|:&}:; you should type it in your Linux terminal"}, - {12, "I can write the code doesn't mean that I can fix your Microwave"}, - {13, "0.1 + 0.2; // -> 0.30000000000000004"}, - {14, "I've got a really good UDP joke to tell you, but you might not get it..."}, - {15, "Proxy Stop...\nJust kidding"}, - {16, "rm -rf --no-preserve-root /\nRunning..."} - }; - - int rInt = rnd.Next(0, results.Count); - string result = results[rInt]; - - return result; - } - + { // Main Function private Proxy? proxy; private Process? progress; - // Server List - Thread? thServerList = null; - List ListServer = new List { new DataServer() }; - - Json.Config configdata = new Json.Config(); Profile default_profile = new Profile(); // Stats default - public bool notbootyet = true; public string WatchFile = ""; public string WatchCheat = "melon123"; public string HostName = "YuukiPS"; // host name public bool IsGameRun = false; public bool DoneCheck = true; + // Config basic game public string VersionGame = ""; public int GameChannel = 0; - public string GamePatchMetode = ""; - //public int GameType = 1; // 1=GS,2=SR + public string PathfileGame = ""; // Extra Extra.Discord discord = new Extra.Discord(); @@ -114,8 +38,8 @@ private string randomString() // Game public Game.Genshin.Settings? settings_genshin = null; - //KeyGS key; - Patch? get_version = null; + // Patch + Patch? get_patch = null; Logger logger = new Logger(); @@ -134,7 +58,7 @@ private void Main_Load(object sender, EventArgs e) Directory.CreateDirectory(logsFolderPath); - logger.initLogging($"-- {randomString()}\n\nPlatform: {os.Platform}\nPlatform Version: {os.Version}\nService pack: {os.ServicePack}\n\n", logFilePath); + logger.initLogging($"Platform: {os.Platform}\nPlatform Version: {os.Version}\nService pack: {os.ServicePack}\n\n", logFilePath); Logger.Info("Boot", "Loading...."); @@ -159,8 +83,6 @@ private void Main_Load(object sender, EventArgs e) { Logger.Info("Boot", "Discord RPC disable"); } - - notbootyet = false; } private void btload_Click(object? sender, EventArgs e) @@ -377,7 +299,7 @@ public void DoStart() int set_proxy_port = int.Parse(GetProxyPort.Text); // Get Game - var cst_gamefile = Set_LA_GameFile.Text; + var cst_gamefile = PathfileGame; if (String.IsNullOrEmpty(cst_gamefile)) { MessageBox.Show("No game file config found"); @@ -407,27 +329,19 @@ public void DoStart() } else { - if (get_version != null && get_version.nosupport != "") + if (get_patch != null && get_patch.nosupport != "") { - MessageBox.Show(get_version.nosupport, "Game version not supported"); + MessageBox.Show(get_patch.nosupport, "Game version not supported"); Process.Start(new ProcessStartInfo(API.WEB_LINK) { UseShellExecute = true }); return; } } // run patch - var tes = PatchGame(patch, true, GamePatchMetode, GameChannel); - if (!string.IsNullOrEmpty(tes)) + var startPatch = PatchGame(patch); + if (!string.IsNullOrEmpty(startPatch)) { - if (tes.Contains("corrupted")) - { - MessageBox.Show("Looks like you're using an unsupported version, try updating or downgrade game data to latest version", "Game version not supported"); - Process.Start(new ProcessStartInfo(API.WEB_LINK) { UseShellExecute = true }); - } - else - { - MessageBox.Show(tes, "Error Patch"); - } + MessageBox.Show(startPatch, "Error Patch"); return; } } @@ -610,10 +524,6 @@ public bool CheckVersionGame(GameType game_type) } // Path - string PathfileGame; - string PathMetadata; - string PathUA; - if (game_type == GameType.GenshinImpact) { // Pilih Channel @@ -623,8 +533,6 @@ public bool CheckVersionGame(GameType game_type) WatchFile = "YuanShen"; GameChannel = 2; PathfileGame = cn; - PathMetadata = Path.Combine(cst_folder_game, "YuanShen_Data", "Managed", "Metadata"); - PathUA = Path.Combine(cst_folder_game, "YuanShen_Data", "Native"); } else if (File.Exists(os)) { @@ -632,8 +540,6 @@ public bool CheckVersionGame(GameType game_type) WatchFile = "GenshinImpact"; GameChannel = 1; PathfileGame = os; - PathMetadata = Path.Combine(cst_folder_game, "GenshinImpact_Data", "Managed", "Metadata"); - PathUA = Path.Combine(cst_folder_game, "GenshinImpact_Data", "Native"); } else { @@ -649,8 +555,8 @@ public bool CheckVersionGame(GameType game_type) if (settings_genshin != null) { Logger.Info("Game", "Game Text Language: " + settings_genshin.GetGameLanguage()); - Console.WriteLine("Game Voice Language: " + settings_genshin.GetVoiceLanguageID()); - //Console.WriteLine("JSON: " + settings_genshin.GetDataGeneralString()); + Logger.Info("Game", "Game Voice Language: " + settings_genshin.GetVoiceLanguageID()); + Logger.Info("Game", "Game Server: " + settings_genshin.GetRegServerNameID()); } } catch (Exception ex) @@ -665,942 +571,323 @@ public bool CheckVersionGame(GameType game_type) WatchFile = "StarRail"; GameChannel = 1; PathfileGame = os; - PathMetadata = Path.Combine(cst_folder_game, "StarRail_Data", "il2cpp_data", "Metadata"); - PathUA = Path.Combine(cst_folder_game); // maybe GameAssembly? } // Check MD5 Game string Game_LOC_Original_MD5 = Tool.CalculateMD5(PathfileGame); // Check MD5 in Server API - get_version = API.GetMD5Game(Game_LOC_Original_MD5, game_type); - if (get_version == null) + get_patch = API.GetMD5Game(Game_LOC_Original_MD5, game_type); + if (get_patch == null) { //0.0.0 Logger.Error("Game", "No Support Game with MD5: " + Game_LOC_Original_MD5 + " (Send this log to admin)"); return false; } - VersionGame = get_version.version; + VersionGame = get_patch.version; if (VersionGame == "0.0.0") { Logger.Error("Game", "Version not supported: MD5 " + Game_LOC_Original_MD5); - Set_Metadata_Folder.Text = ""; - Set_UA_Folder.Text = ""; - Set_LA_GameFile.Text = ""; - Get_LA_Version.Text = "Version: Unknown"; Get_LA_CH.Text = "Channel: Unknown"; Get_LA_REL.Text = "Release: Unknown"; - Get_LA_Metode.Text = "Metode: Unknown"; Get_LA_MD5.Text = "MD5: Unknown"; return false; } - var get_channel = get_version.channel; - var get_metode = "None"; // no need patch - if (get_version.patched != null) - { - get_metode = get_version.patched.metode; - } - - // Set Folder Patch - Set_Metadata_Folder.Text = PathMetadata; - Set_UA_Folder.Text = PathUA; - Set_LA_GameFile.Text = PathfileGame; + var get_channel = get_patch.channel; // IF ALL OK Set_LA_GameFolder.Text = cst_folder_game; // Set Version - Get_LA_Version.Text = "Version: " + get_version.version; + Get_LA_Version.Text = "Version: " + get_patch.version; Get_LA_CH.Text = "Channel: " + get_channel; - Get_LA_REL.Text = "Release: " + get_version.release; - Get_LA_Metode.Text = "Metode: " + get_metode; - - var md5_ori = "?"; - - // Pilih Metode - if (get_version.original != null) - { - if (get_metode == "Metadata") - { - if (get_channel == "CN") - { - md5_ori = get_version.original.md5_check.cn.metadata; - } - if (get_channel == "OS") - { - md5_ori = get_version.original.md5_check.os.metadata; - } - } - else if (get_metode == "UserAssembly") - { - if (get_channel == "CN") - { - md5_ori = get_version.original.md5_check.cn.userassembly; - } - if (get_channel == "OS") - { - md5_ori = get_version.original.md5_check.os.userassembly; - } - } - } - - Get_LA_MD5.Text = "MD5: " + md5_ori; + Get_LA_REL.Text = "Release: " + get_patch.release; Logger.Info("Game", "Currently using version game " + VersionGame); - - Logger.Info("Game", "Folder PathMetadata: " + PathMetadata); Logger.Info("Game", "File Game: " + PathfileGame); - Logger.Info("Game", "MD5 Game Currently: " + Game_LOC_Original_MD5); - GamePatchMetode = get_metode; + Get_LA_MD5.Text = "MD5: " + Game_LOC_Original_MD5; return true; } - public string PatchGame(bool patchit = true, bool online = true, string metode = "", int ch = 1) + public string PatchGame(bool patchit = true) { - // Check Folder Game - var cst_folder_game = Set_LA_GameFolder.Text; - if (String.IsNullOrEmpty(cst_folder_game)) + // check folder game (root) + var root_folder = Set_LA_GameFolder.Text; + if (String.IsNullOrEmpty(root_folder)) { return "No game folder found (1)"; } - if (!Directory.Exists(cst_folder_game)) + if (!Directory.Exists(root_folder)) { return "No game folder found (2)"; } - if (get_version == null) + // check version + if (get_patch == null) { return "Can't find version, try clicking 'Get Key' in config tab"; - } - - // Check version + } if (VersionGame == "0.0.0") { return "This Game Version is not compatible with this method patch"; } - /* - if (get_version.patched == null) - { - return "Can't find config patch cloud"; - } - - if (get_version.original == null) + if (patchit) { - return "Can't find config original cloud"; + // for patch + if (get_patch.patched != null && get_patch.patched.Any()) + { + foreach (var data in get_patch.patched) + { + var iss = PatchCopy(root_folder, data.file, data.location, data.md5, "patch", get_patch.version); + if (!String.IsNullOrEmpty(iss)) + { + return iss; + } + } + } + else + { + Logger.Info("Patch", "no need for any patch"); + } } - */ - - // API STUFF - var use_metode = ""; - if (get_version.patched != null) + else { - use_metode = get_version.patched.metode; + // for unpatch + if (get_patch.patched != null && get_patch.patched.Any()) + { + foreach (var data in get_patch.patched) + { + var iss = PatchCopy(root_folder, data.file, data.location, data.md5, "unpatch", get_patch.version); + if (!String.IsNullOrEmpty(iss)) + { + return iss; + } + } + } + else + { + Logger.Info("Patch", "no files deleted"); + } + if (get_patch.original != null && get_patch.original.Any()) + { + foreach (var data in get_patch.original) + { + var iss = PatchCopy(root_folder, data.file, data.location, data.md5, "original", get_patch.version); + if (!String.IsNullOrEmpty(iss)) + { + return iss; + } + } + } + else + { + Logger.Info("Patch", "no files restored to original"); + } } - var use_channel = get_version.channel; - - // LOCALHOST - string MD5_UA_API_Original = ""; - string MD5_UA_API_Patched = ""; - string MD5_Metadata_API_Original = ""; - string MD5_Metadata_API_Patched = ""; - string MD5_API_Patched = ""; + return ""; + } - var DL_Patch = ""; - if (get_version.patched != null) + private void Set_LA_Select_Click(object sender, EventArgs e) + { + var Folder_Game_Now = SelectGamePath(); + if (!string.IsNullOrEmpty(Folder_Game_Now)) { - DL_Patch = get_version.patched.resources + "Patch/"; + Set_LA_GameFolder.Text = Folder_Game_Now; + if (!CheckVersionGame(default_profile.game.type)) + { + MessageBox.Show("You have set folder manually but we can't detect this game version yet, maybe because it's not supported yet so please download it on our official website with the currently supported version."); + Process.Start(new ProcessStartInfo(API.WEB_LINK + "/game/" + default_profile.game.type.SEOUrl()) { UseShellExecute = true }); + } } - - var DL_Original = ""; - if (get_version.original != null) + else { - DL_Original = get_version.original.resources; + MessageBox.Show("No game folder found"); } + } - var Original_file_MA = ""; - var Original_file_UA = ""; - - var key_to_patch = ""; - var key_to_find = ""; + public string PatchCopy(string root_folder, string url_file, string file_name, string file_md5, string iscopy, string version) + { + string fileSave = Path.Combine(root_folder, file_name); - if (!String.IsNullOrEmpty(use_metode)) + if (iscopy == "unpatch") { - // Select Metode (via API Cloud) - if (use_channel == "OS") + try { - MD5_UA_API_Original = get_version.original?.md5_check.os.userassembly.ToUpper() ?? string.Empty; - MD5_UA_API_Patched = get_version.patched?.md5_vaild.os.ToUpper() ?? string.Empty; - - MD5_Metadata_API_Original = get_version.original?.md5_check.os.metadata ?? string.Empty; - MD5_Metadata_API_Patched = get_version.patched?.md5_vaild.os.ToUpper() ?? string.Empty; - - key_to_patch = get_version.patched?.key_patch; - key_to_find = get_version.original?.key_find.os; - - Original_file_MA = DL_Original + "GenshinImpact_Data/Managed/Metadata/global-metadata.dat"; - Original_file_UA = DL_Original + "GenshinImpact_Data/Native/UserAssembly.dll"; - MD5_API_Patched = get_version.patched?.md5_vaild.os.ToUpper() ?? string.Empty; - + File.Delete(fileSave); + Logger.Info("Patch", $"File remove {fileSave}"); + return ""; } - else if (use_channel == "CN") + catch (Exception e) { - MD5_UA_API_Original = get_version.original?.md5_check.cn.userassembly.ToUpper() ?? string.Empty; - MD5_UA_API_Patched = get_version.patched?.md5_vaild.cn.ToUpper() ?? string.Empty; + Logger.Error("Patch", $"File remove error {fileSave} > {e.Message}"); + return e.Message; + } + } - MD5_Metadata_API_Original = get_version.original?.md5_check.cn.metadata ?? string.Empty; - MD5_Metadata_API_Patched = get_version.patched?.md5_vaild.cn.ToUpper() ?? string.Empty; + if (File.Exists(fileSave)) + { + var md5_file_raw = Tool.CalculateMD5(fileSave); + if(md5_file_raw == file_md5) + { + Logger.Info("Patch", $"File {fileSave} this already exists and md5 is accurate so no action is needed for {iscopy}"); + return ""; + } + } - key_to_patch = get_version.patched?.key_patch; - key_to_find = get_version.original?.key_find.cn; + var backupPatch = Path.Combine(Config.Modfolder, "i", version, iscopy, file_name); + if (File.Exists(backupPatch)) + { + var md5_file_raw = Tool.CalculateMD5(backupPatch); + if(md5_file_raw == file_md5) + { + Logger.Info("Patch", $"Found backup {iscopy} > {backupPatch} > {fileSave}"); - Original_file_MA = DL_Original + "YuanShen_Data/Managed/Metadata/global-metadata.dat"; - Original_file_UA = DL_Original + "YuanShen_Data/Native/UserAssembly.dll"; - MD5_API_Patched = get_version.patched?.md5_vaild.os.ToUpper() ?? string.Empty; + string saveDir = Path.GetDirectoryName(fileSave); + if (!Directory.Exists(saveDir)) + { + Directory.CreateDirectory(saveDir); + } + File.Copy(backupPatch, fileSave, overwrite: true); + return ""; } else { - return "This Game Version is not compatible with Any Method Patch"; + // skip ? } + } - // >> Make sure MD5 API is not empty << + Logger.Info("Patch", $"Start download {url_file} and save to {fileSave} for {iscopy}"); - if (metode != "RSA") + var CEKDL1 = new Download(url_file, fileSave); + if (CEKDL1.ShowDialog() != DialogResult.OK) + { + return $"Error download ${iscopy} file: {url_file} to {fileSave}"; + } + else + { + var md5_file = Tool.CalculateMD5(fileSave); + if (md5_file == file_md5) { - if (String.IsNullOrEmpty(MD5_UA_API_Patched)) - { - return "Game version is not supported (3)"; - } - if (String.IsNullOrEmpty(MD5_Metadata_API_Patched)) + string backupDir = Path.GetDirectoryName(backupPatch); + if (!Directory.Exists(backupDir)) { - return "Game version is not supported (1)"; + Directory.CreateDirectory(backupDir); } + Logger.Info("Game", $"MD5 Patch File {url_file}: " + md5_file); + File.Copy(fileSave, backupPatch, overwrite: true); } - - if (String.IsNullOrEmpty(MD5_UA_API_Original)) + else { - return "Game version is not supported (4)"; + return $"Error patch file {url_file}, md5 file mismatch {md5_file}"; } - if (String.IsNullOrEmpty(MD5_Metadata_API_Original)) + } + + // OK + return ""; + } + + public void CheckUpdate() + { + Logger.Info("Game", "Check update..."); + var version = Assembly.GetExecutingAssembly().GetName().Version; + string ver = ""; + if (version != null) + { + ver = version.ToString(); + Set_Version.Text = "Version: " + ver; + var GetDataUpdate = API.GetUpdate(); + if (GetDataUpdate != null) { - return "Game version is not supported (2)"; - } + var judul = "New Update: " + GetDataUpdate.name; // is dev or nightly or name update + var name_version = GetDataUpdate.tag_name; // version name + var infobody = GetDataUpdate.body; // info - // >> All << + var version1 = new Version(name_version); + var version2 = new Version(ver); - // Check Folder UA - var cst_folder_UA = Set_UA_Folder.Text; - var cst_folder_Game = Set_LA_GameFolder.Text; + var result = version1.CompareTo(version2); - if (String.IsNullOrEmpty(cst_folder_UA)) - { - return "No UserAssembly folder found (1)"; - } - if (!Directory.Exists(cst_folder_UA)) - { - return "No UserAssembly folder found (2)"; - } - // Check file UserAssembly - string PathfileUA_Currently = Path.Combine(cst_folder_UA, "UserAssembly.dll"); - string PathfileUA_Patched = Path.Combine(cst_folder_UA, "UserAssembly-patched.dll"); - string PathfileUA_Original = Path.Combine(cst_folder_UA, "UserAssembly-original.dll"); - // Check MD5 local (First time) - string MD5_UA_LOC_Currently = Tool.CalculateMD5(PathfileUA_Currently); - string MD5_UA_LOC_Patched = Tool.CalculateMD5(PathfileUA_Patched); - string MD5_UA_LOC_Original = Tool.CalculateMD5(PathfileUA_Original); - - // Check folder Metadata - var cst_folder_metadata = Set_Metadata_Folder.Text; - if (String.IsNullOrEmpty(cst_folder_metadata)) - { - return "No MetaData folder found (1)"; - } - if (!Directory.Exists(cst_folder_metadata)) - { - return "No MetaData folder found (2)"; - } - // Check file MetaData - string PathfileMetadata_Currently = Path.Combine(cst_folder_metadata, "global-metadata.dat"); - string PathfileMetadata_Patched = Path.Combine(cst_folder_metadata, "global-metadata-patched.dat"); - string PathfileMetadata_Original = Path.Combine(cst_folder_metadata, "global-metadata-original.dat"); - // Get MD5 local Metadata (First time) - string MD5_Metadata_LOC_Currently = Tool.CalculateMD5(PathfileMetadata_Currently); - string MD5_Metadata_LOC_Original = Tool.CalculateMD5(PathfileMetadata_Original); - string MD5_Metadata_LOC_Patched = Tool.CalculateMD5(PathfileMetadata_Patched); - - // Two-method verification even when using offline mode - - // >> If UserAssembly is broken << - var download_ua = false; - if (!File.Exists(PathfileUA_Currently)) - { - // Check if found file original - if (File.Exists(PathfileUA_Original)) - { - // Check if API Original same with Original LOC - if (MD5_UA_API_Original == MD5_UA_LOC_Original) - { - try - { - File.Copy(PathfileUA_Original, PathfileUA_Currently, true); - MD5_UA_LOC_Currently = Tool.CalculateMD5(PathfileUA_Currently); - Logger.Info("Game", "We copy PathfileUA_Original to PathfileUA_Currently (UserAssembly) (33)"); - } - catch (Exception) - { - // skip - return "Error copy (1)"; - } - } - else - { - Logger.Info("Game", "Download UserAssembly, because PathfileUA_Original with md5 " + MD5_UA_LOC_Original + " does not match " + MD5_UA_API_Original + " (5)"); - download_ua = true; - } - } - else - { - Logger.Info("Game", "Download UserAssembly, because file PathfileUA_Original was not found"); - download_ua = true; - } - } - else - { - // If file is found and original file doesn't match currently (Make sure current data is really original before patch) - if (MD5_UA_API_Original != MD5_UA_LOC_Currently) + if (result > 0) { - // Check if found file original - if (File.Exists(PathfileUA_Original)) + // versi 1 lebih besar + Set_Version.Text = "Version: " + ver + " (New Update: " + name_version + " )"; + var tes = MessageBox.Show(infobody, judul, MessageBoxButtons.YesNo, MessageBoxIcon.Question); + if (tes == DialogResult.Yes) { - // Check if API Original same with Original LOC - if (MD5_UA_API_Original == MD5_UA_LOC_Original) + var url_dl = ""; + foreach (var file in GetDataUpdate.assets) { - try + if (file.name == "YuukiPSLauncherPC.zip" || file.name == "YuukiPS.zip" || file.name == "update.zip") { - File.Copy(PathfileUA_Original, PathfileUA_Currently, true); - MD5_UA_LOC_Currently = Tool.CalculateMD5(PathfileUA_Currently); - Logger.Info("Game", "We copy PathfileUA_Original to PathfileUA_Currently (UserAssembly) (6)"); + url_dl = file.browser_download_url; + break; } - catch (Exception) + } + if (!string.IsNullOrEmpty(url_dl)) + { + var DL1 = new Download(url_dl, Json.Config.CurrentlyPath + @"\update.zip"); + if (DL1.ShowDialog() == DialogResult.OK) { - // skip - return "Error copy (2)"; + // update + var file_update = Json.Config.CurrentlyPath + @"\update.bat"; + try + { + //buat bat + var w = new StreamWriter(file_update); + w.WriteLine("@echo off"); + + //kill all + w.WriteLine("Taskkill /IM YuukiPS.exe /F"); + //w.WriteLine("Taskkill /IM YuukiPS.vshost.exe /F"); + + // Unzip file + w.WriteLine("echo unzip file..."); + w.WriteLine("tar -xf update.zip"); + + //delete file old + w.WriteLine("echo delete file old"); + w.WriteLine("del update.zip"); + + //start bot + w.WriteLine("echo Update done, start back..."); + w.WriteLine("timeout 5 > NUL"); + w.WriteLine("start YuukiPS.exe"); + w.WriteLine("del Update.bat"); + w.Close(); + //open bat + Process.Start(file_update); + } + catch (Exception ex) + { + MessageBox.Show(ex.Message); + } } } else { - // download if Original file unvaild - Logger.Info("Game", "Download UserAssembly in 'Currently', because 'PathfileUA_Original' it doesn't match " + MD5_UA_API_Original + " with " + MD5_UA_LOC_Original + " (7)"); - download_ua = true; + // update batal } + } - else - { - Logger.Info("Game", "Download UserAssembly in 'Currently' because file PathfileUA_Original not found and it doesn't match " + MD5_UA_API_Original + " with " + MD5_UA_LOC_Currently + " Currently file (8)"); - download_ua = true; - } + } + else if (result < 0) + { + Set_Version.Text = "Version: " + ver + " (latest nightly) (Official: " + name_version + ")"; } else { - Logger.Info("Game", "Skip download UserAssembly, it's up-to-date (4)"); - } - } - // if need download ua - if (download_ua) - { - try - { - if (!patchit) - { - return "Unable to download files " + Original_file_UA + " in a closed game state, please try again or download manual and put it in " + PathfileUA_Currently; - } - var CEKDL1 = new Download(Original_file_UA, PathfileUA_Currently); - if (CEKDL1.ShowDialog() != DialogResult.OK) - { - return "Get Original UserAssembly failed"; - } - else - { - MD5_UA_LOC_Currently = Tool.CalculateMD5(PathfileUA_Currently); - Logger.Info("Game", "Currently UserAssembly: " + MD5_UA_LOC_Currently); - } - } - catch (Exception exx) - { - return "Error Get Original UserAssembly: " + exx.ToString(); - } - } - else - { - Logger.Info("Game", "Currently UserAssembly: " + MD5_UA_LOC_Currently); - } - - // here current file should match so if original file is not found use current file to copy to original file - if (!File.Exists(PathfileUA_Original)) - { - try - { - File.Copy(PathfileUA_Currently, PathfileUA_Original, true); - MD5_UA_LOC_Original = Tool.CalculateMD5(PathfileUA_Original); - Logger.Info("Game", "We copy file in PathfileUA_Currently to PathfileUA_Original files (22)"); - } - catch (Exception) - { - // skip - return "Error copy PathfileUA_Currently to PathfileUA_Original (1)"; - } - } - else - { - // if file found (skip) - } - - - // >> If Metadata is broken << - var download_metadata = false; - if (!File.Exists(PathfileMetadata_Currently)) - { - // Check if found file original - if (File.Exists(PathfileMetadata_Original)) - { - // Check if API Original same with Original LOC - if (MD5_Metadata_API_Original == MD5_Metadata_LOC_Original) - { - try - { - File.Copy(PathfileMetadata_Original, PathfileMetadata_Currently, true); - MD5_Metadata_LOC_Currently = Tool.CalculateMD5(PathfileMetadata_Currently); - Logger.Info("Game", "We copy PathfileMetadata_Original to PathfileMetadata_Currently"); - } - catch (Exception) - { - // skip - return "Error copy PathfileMetadata_Original to PathfileMetadata_Currently (111)"; - } - } - else - { - // file not vaild so download - download_metadata = true; - Logger.Warning("Game", "Download Metadata in Currently,because file Original with md5 " + MD5_Metadata_API_Original + " doesn't match " + MD5_Metadata_LOC_Original + " (5)"); - } - } - else - { - // file not found, so download - download_metadata = true; - Logger.Warning("Game", "Download Metadata, because file PathfileMetadata_Original was not found"); - } - } - else - { - // If file is found and original file doesn't match currently (Make sure current data is really original before patch) - if (MD5_Metadata_API_Original != MD5_Metadata_LOC_Currently) - { - // Check if found file original - if (File.Exists(PathfileMetadata_Original)) - { - // Check if API Original same with Original LOC - if (MD5_Metadata_API_Original == MD5_Metadata_LOC_Original) - { - try - { - File.Copy(PathfileMetadata_Original, PathfileMetadata_Currently, true); - MD5_Metadata_LOC_Currently = Tool.CalculateMD5(PathfileMetadata_Currently); - Logger.Info("Game", "We copy file PathfileMetadata_Original to PathfileMetadata_Currently (6)"); - } - catch (Exception) - { - // skip - return "Error copy PathfileMetadata_Original to PathfileMetadata_Currently (111)"; - } - } - else - { - // file not vaild so download - download_metadata = true; - Logger.Warning("Game", "Download Metadata in Currently, because PathfileMetadata_Original file does not match " + MD5_Metadata_API_Original + " with " + MD5_Metadata_LOC_Original + " (7)"); - } - } - else - { - // file not found, so download - download_metadata = true; - Logger.Warning("Game", "Download Metadata in Currently, because file PathfileMetadata_Original was not found (8)"); - } - } - else - { - Logger.Info("Game", "Skip download Metadata, it's up-to-date (4)"); - } - } - // if need download - if (download_metadata) - { - try - { - if (!patchit) - { - return "Unable to download files " + Original_file_MA + " in a closed game state, please try again or download manual and put it in " + PathfileMetadata_Currently; - } - var CEKDL2 = new Download(Original_file_MA, PathfileMetadata_Currently); - if (CEKDL2.ShowDialog() != DialogResult.OK) - { - return "Get Original Metadata failed"; - } - else - { - MD5_Metadata_LOC_Currently = Tool.CalculateMD5(PathfileMetadata_Currently); - Logger.Info("Game", "Currently Metadata: " + MD5_Metadata_LOC_Currently); - } - } - catch (Exception exx) - { - return "Error Get Original Metadata: " + exx.ToString(); - } - } - else - { - Logger.Info("Game", "Currently Metadata: " + MD5_Metadata_LOC_Currently); - } - // here current file should match so if original file is not found use current file to copy to original file - if (!File.Exists(PathfileMetadata_Original)) - { - try - { - File.Copy(PathfileMetadata_Currently, PathfileMetadata_Original, true); - MD5_Metadata_LOC_Original = Tool.CalculateMD5(PathfileMetadata_Original); - Logger.Info("Game", "We copy file in PathfileMetadata_Currently to PathfileMetadata_Original files (22)"); - } - catch (Exception) - { - return "Error copy PathfileMetadata_Currently to PathfileMetadata_Original (1)"; - } - } - else - { - // if file found (skip) - } - - // >>> Final Tes <<< - - //UA - MD5_UA_LOC_Original = Tool.CalculateMD5(PathfileUA_Original); - MD5_UA_LOC_Currently = Tool.CalculateMD5(PathfileUA_Currently); - if (MD5_UA_API_Original != MD5_UA_LOC_Original && MD5_UA_API_Original != MD5_UA_LOC_Currently) - { - try - { - File.Delete(PathfileUA_Original); - } - catch (Exception) - { - // skip - } - return MD5_UA_LOC_Original + " and " + MD5_UA_LOC_Currently + " value should be " + MD5_UA_API_Original + ", This might happen because file is corrupted, try again or manual update. (g1)"; - } - // Metadata - MD5_Metadata_LOC_Original = Tool.CalculateMD5(PathfileMetadata_Original); - MD5_Metadata_LOC_Currently = Tool.CalculateMD5(PathfileMetadata_Currently); - if (MD5_Metadata_API_Original != MD5_Metadata_LOC_Original && MD5_Metadata_API_Original != MD5_Metadata_LOC_Currently) - { - try - { - File.Delete(PathfileMetadata_Original); - } - catch (Exception) - { - // skip - } - return MD5_Metadata_LOC_Original + " and " + MD5_Metadata_LOC_Currently + " value should be " + MD5_Metadata_API_Original + ", This might happen because file is corrupted, try again or manual update. (g1)"; - } - - // It should be here that all files already verified, unless you want to check other vaild files again. - - if (use_metode == "UserAssembly") - { - // >> UA << - - // debug - //online = false; - - if (online) - { - // If original backup file is not found. - if (!File.Exists(PathfileUA_Original)) - { - return "Why does this pass (1)"; - } - - // If current UA file doesn't exist use UserAssembly-Original.dll - if (!File.Exists(PathfileUA_Currently)) - { - return "Why does this pass (2)"; - } - - if (MD5_UA_API_Original != MD5_UA_LOC_Currently) - { - return "Why does this pass (3)"; - } - else - { - if (patchit) - { - // if current file is original and need patch - - var download_patch = false; - if (!File.Exists(PathfileUA_Patched)) - { - download_patch = true; - } - else - { - // If UA_API_Patches_MD5 (patch file from api) matches UA_LOC_Patched_MD5 (current patch file) - if (MD5_UA_API_Patched != MD5_UA_LOC_Patched) - { - download_patch = true; - } - } - - // If download_patch true, download it - if (download_patch) - { - var DL2 = new Download(DL_Patch + "UserAssembly-patched.dll", PathfileUA_Patched); - if (DL2.ShowDialog() != DialogResult.OK) - { - return "No Found Patch file...."; - } - else - { - MD5_UA_LOC_Patched = Tool.CalculateMD5(PathfileUA_Patched); - } - } - - if (MD5_UA_API_Patched != MD5_UA_LOC_Patched) - { - // Failed because file doesn't match from md5 api - return "(UA) Your version Game is not supported, or it needs latest update or file is corrupted."; - } - else - { - // Patch file - try - { - File.Copy(PathfileUA_Patched, PathfileUA_Currently, true); - MD5_UA_LOC_Currently = Tool.CalculateMD5(PathfileUA_Currently); - - Logger.Info("Game", "Patch PathfileUA_Patched to PathfileUA_Currently done"); - download_patch = false; - } - catch (Exception x) - { - return "Failed Patch: " + x.ToString(); - } - } - } - else - { - // No Patch - Console.WriteLine("Skip, because file is original (x1)"); - } - } - } - else - { - // Offline Mode UserAssembly - if (patchit) - { - // Use PathfileUA_Currently to backup PathfileUA_Original file, but since without md5 api we can't check is original or not. - if (!File.Exists(PathfileUA_Original)) - { - return "Why does this pass (1-1)"; - } - - // Check PathfileMetadata_Currently if no found - if (!File.Exists(PathfileUA_Currently)) - { - return "Why does this pass (1-2)"; - } - - // keep patch - var ManualUA = Game.Genshin.Patch.UserAssembly.Do(PathfileUA_Currently, PathfileUA_Patched, key_to_find!, key_to_patch!); - if (!String.IsNullOrEmpty(ManualUA)) - { - return "Error Patch UserAssembly: " + ManualUA; - } - - // If patch is successful - if (File.Exists(PathfileUA_Patched)) - { - MD5_UA_LOC_Patched = Tool.CalculateMD5(PathfileUA_Patched); - try - { - File.Copy(PathfileUA_Patched, PathfileUA_Currently, true); - MD5_UA_LOC_Currently = Tool.CalculateMD5(PathfileUA_Currently); - Logger.Info("Game", "Patch UserAssembly..."); - } - catch (Exception ex) - { - return "Failed copy PathfileUA_Patched to PathfileUA_Currently: " + ex.ToString(); - } - } - else - { - return "Why does this pass (1-3)"; - } - } - else - { - // No Patch - Logger.Info("Game", "Skip, because file is original (x2)"); - } - } - - Logger.Info("Game", "MD5 UA Currently: " + MD5_UA_LOC_Currently); - Logger.Info("Game", "MD5 UA Original: " + MD5_UA_LOC_Original); - Logger.Info("Game", "MD5 UA Patched: " + MD5_UA_LOC_Patched); - } - else if (metode == "Metadata") - { - return "I'm tired Checking Metadata"; - } - else if (metode == "None") - { - Logger.Info("Game", "Skip patch..."); - } - else if (metode == "RSA") - { - - var fileRSA = cst_folder_Game + "/version.dll"; - var fileRSA_BK = cst_folder_Game + "/version.bk"; - - var fileRSA_Public = cst_folder_Game + "/PublicKey.txt"; - - // TODO: ADD KEY SERVER - File.WriteAllText(fileRSA_Public, "xbbx2m1feHyrQ7jP+8mtDF/pyYLrJWKWAdEv3wZrOtjOZzeLGPzsmkcgncgoRhX4dT+1itSMR9j9m0/OwsH2UoF6U32LxCOQWQD1AMgIZjAkJeJvFTrtn8fMQ1701CkbaLTVIjRMlTw8kNXvNA/A9UatoiDmi4TFG6mrxTKZpIcTInvPEpkK2A7Qsp1E4skFK8jmysy7uRhMaYHtPTsBvxP0zn3lhKB3W+HTqpneewXWHjCDfL7Nbby91jbz5EKPZXWLuhXIvR1Cu4tiruorwXJxmXaP1HQZonytECNU/UOzP6GNLdq0eFDE4b04Wjp396551G99YiFP2nqHVJ5OMQ==AQAB"); - - Logger.Info("Game", "Find file: " + fileRSA); - - var dl_rsa = false; - var RSAMD5 = ""; - - if (patchit) - { - if (File.Exists(fileRSA)) - { - // check if source true - RSAMD5 = Tool.CalculateMD5(fileRSA); - if (RSAMD5 == MD5_API_Patched) - { - // if not found backup rsa key, copy dll to bk - if (!File.Exists(fileRSA_BK)) - { - Logger.Warning("Game", "No found backup file rsa key so copy"); - File.Copy(fileRSA, fileRSA_BK, true); - } - - Logger.Info("Game", "Skip download RSAKEY"); - } - else - { - Logger.Warning("Game", "file not same " + RSAMD5 + " download rsa key " + MD5_API_Patched); - dl_rsa = true; - } - - } - else - { - if (File.Exists(fileRSA_BK)) - { - if (RSAMD5 == MD5_API_Patched) - { - Logger.Info("Game", "found backup file rsa key so copy"); - try - { - File.Copy(fileRSA_BK, fileRSA, true); - } - catch (Exception ex) - { - Console.WriteLine(ex.Message); - return "error1"; - } - } - else - { - Logger.Error("Game", "key rsa not same so just download it"); - dl_rsa = true; - } - } - else - { - Logger.Error("Game", "No found file so just download it"); - dl_rsa = true; - } - } - } - else - { - // remove file - try - { - if (File.Exists(fileRSA)) - { - Logger.Info("Game", "Remove file rsa key"); - File.Delete(fileRSA); - } - } - catch (Exception ex) - { - Logger.Error("Game", ex.Message); - return "error"; - } - } - - if (dl_rsa) - { - var DL2 = new Download(DL_Patch + "RSAPatch.dll", fileRSA); - if (DL2.ShowDialog() != DialogResult.OK) - { - return "No Found Patch file...."; - } - else - { - RSAMD5 = Tool.CalculateMD5(fileRSA); - } - } - - Logger.Info("Game", "RSA MD5: " + RSAMD5); - //return "TODO: "+ DL_Patch; - } - else - { - return "No other method found: " + metode; - } - - } - - return ""; - } - - private void Set_LA_Select_Click(object sender, EventArgs e) - { - var Folder_Game_Now = SelectGamePath(); - if (!string.IsNullOrEmpty(Folder_Game_Now)) - { - Set_LA_GameFolder.Text = Folder_Game_Now; - if (!CheckVersionGame(default_profile.game.type)) - { - MessageBox.Show("You have set folder manually but we can't detect this game version yet, maybe because it's not supported yet so please download it on our official website with the currently supported version."); - Process.Start(new ProcessStartInfo(API.WEB_LINK + "/game/" + default_profile.game.type.SEOUrl()) { UseShellExecute = true }); - } - } - else - { - MessageBox.Show("No game folder found"); - } - } - - public void CheckUpdate() - { - Logger.Info("Game", "Check update..."); - var version = Assembly.GetExecutingAssembly().GetName().Version; - string ver = ""; - if (version != null) - { - ver = version.ToString(); - Set_Version.Text = "Version: " + ver; - var GetDataUpdate = API.GetUpdate(); - if (GetDataUpdate != null) - { - var judul = "New Update: " + GetDataUpdate.name; // is dev or nightly or name update - var name_version = GetDataUpdate.tag_name; // version name - var infobody = GetDataUpdate.body; // info - - var version1 = new Version(name_version); - var version2 = new Version(ver); - - var result = version1.CompareTo(version2); - - if (result > 0) - { - // versi 1 lebih besar - Set_Version.Text = "Version: " + ver + " (New Update: " + name_version + " )"; - var tes = MessageBox.Show(infobody, judul, MessageBoxButtons.YesNo, MessageBoxIcon.Question); - if (tes == DialogResult.Yes) - { - var url_dl = ""; - foreach (var file in GetDataUpdate.assets) - { - if (file.name == "YuukiPSLauncherPC.zip" || file.name == "YuukiPS.zip" || file.name == "update.zip") - { - url_dl = file.browser_download_url; - break; - } - } - if (!string.IsNullOrEmpty(url_dl)) - { - var DL1 = new Download(url_dl, Json.Config.CurrentlyPath + @"\update.zip"); - if (DL1.ShowDialog() == DialogResult.OK) - { - // update - var file_update = Json.Config.CurrentlyPath + @"\update.bat"; - try - { - //buat bat - var w = new StreamWriter(file_update); - w.WriteLine("@echo off"); - - //kill all - w.WriteLine("Taskkill /IM YuukiPS.exe /F"); - //w.WriteLine("Taskkill /IM YuukiPS.vshost.exe /F"); - - // Unzip file - w.WriteLine("echo unzip file..."); - w.WriteLine("tar -xf update.zip"); - - //delete file old - w.WriteLine("echo delete file old"); - w.WriteLine("del update.zip"); - - //start bot - w.WriteLine("echo Update done, start back..."); - w.WriteLine("timeout 5 > NUL"); - w.WriteLine("start YuukiPS.exe"); - w.WriteLine("del Update.bat"); - w.Close(); - //open bat - Process.Start(file_update); - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - } - } - } - else - { - // update batal - } - - } - } - else if (result < 0) - { - Set_Version.Text = "Version: " + ver + " (latest nightly) (Official: " + name_version + ")"; - } - else - { - Set_Version.Text = "Version: " + ver + " (latest public)"; + Set_Version.Text = "Version: " + ver + " (latest public)"; } } } @@ -1709,17 +996,18 @@ private void CheckGameRun_Tick(object sender, EventArgs e) if (!DoneCheck) { Console.WriteLine("Game detected stopped"); + DoneCheck = true; StopGame(); // this shouldn't be necessary but just let it be - var tes = PatchGame(false, true, GamePatchMetode, GameChannel); - if (!string.IsNullOrEmpty(tes)) + + var unpatch = PatchGame(false); + if (!string.IsNullOrEmpty(unpatch)) { - Logger.Info("Game", tes); + Logger.Info("Game", unpatch); } - DoneCheck = true; if (Enable_WipeLoginCache.Checked) { - WipeLogin(); + Tool.WipeLogin(default_profile.game.type); } if (Enable_RPC.Checked) @@ -1938,203 +1226,6 @@ private void Extra_Enable_RPC_CheckedChanged(object sender, EventArgs e) } } - private void btchooseupdate_Click(object sender, EventArgs e) - { - string gpath = Set_LA_GameFolder.Text; - - OpenFileDialog openFileDialog = new OpenFileDialog(); - - if (!string.IsNullOrEmpty(gpath)) - { - openFileDialog.InitialDirectory = gpath; - } - else - { - openFileDialog.InitialDirectory = @"C:\"; - } - - openFileDialog.Filter = "Update Files (*.zip)|*.zip"; - - openFileDialog.Title = "Select an update file (HDIFF)"; - - if (openFileDialog.ShowDialog() == DialogResult.OK) - { - string selectedFileName = openFileDialog.FileName; - - if (!string.IsNullOrEmpty(selectedFileName)) - { - tbx_update.Text = selectedFileName; - string gamePath = Set_LA_GameFile.Text; - } - else - { - MessageBox.Show("Select a valid file!"); - } - } - } - private void ExtractZip(string zipFilePath, string extractionPath, ProgressBar progressBar) - { - try - { - using (var fileStream = new FileStream(zipFilePath, FileMode.Open, FileAccess.Read)) - using (var zipInputStream = new ZipInputStream(fileStream)) - { - long totalSize = fileStream.Length; - long bytesRead = 0; - - ZipEntry entry; - while ((entry = zipInputStream.GetNextEntry()) != null) - { - if (!entry.IsDirectory) - { - string entryFileName = Path.Combine(extractionPath, entry.Name); - string entryDirectory = Path.GetDirectoryName(entryFileName); - - if (!Directory.Exists(entryDirectory)) - { - Directory.CreateDirectory(entryDirectory); - } - - using (var entryStream = new FileStream(entryFileName, FileMode.Create, FileAccess.Write)) - { - byte[] buffer = new byte[4096]; - int count; - while ((count = zipInputStream.Read(buffer, 0, buffer.Length)) > 0) - { - entryStream.Write(buffer, 0, count); - bytesRead += count; - - // this took so much to figure out (i dont know sh*t 'bout math) - int progress = (int)Math.Min(100, ((double)bytesRead / totalSize * 100)); - progressBar.Invoke((MethodInvoker)delegate { progressBar.Value = progress; }); - } - } - } - } - } - - Logger.Info("Hdiff", "Successfully extracted zip"); - } - catch (Exception ex) - { - MessageBox.Show($"Error extracting update file: {ex.Message}", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); - } - } - - - static bool HasContent(string folderPath) - { - string[] files = Directory.GetFiles(folderPath); - if (files.Length > 0) - { - return true; - } - - - string[] subdirectories = Directory.GetDirectories(folderPath); - return subdirectories.Length > 0; - } - - async private void btnstartUpdate_Click(object sender, EventArgs e) - { - if (!string.IsNullOrEmpty(tbx_update.Text)) - { - btnstartUpdate.Enabled = false; - Logger.Info("Hdiff", "Start!"); - txt_statusUpd.Text = "Status: Extracting..."; - string updPath = tbx_update.Text; - string tempPath = Path.Combine(Set_LA_GameFolder.Text, "hdiff_temp"); - - if (!Directory.Exists(tempPath)) - { - Directory.CreateDirectory(Path.Combine(Set_LA_GameFolder.Text, "hdiff_temp")); - } - - if (!HasContent(tempPath)) - { - // run asynchronously this function, to prevent the stupid freezing >:( - await Task.Run(() => ExtractZip(updPath, tempPath, progressBar1)); - } - - - txt_statusUpd.Text = "Status: Analyzing..."; - - string deleteFilesPath = Path.Combine(tempPath, "deletefiles.txt"); - - if (!Path.Exists(deleteFilesPath)) - { - MessageBox.Show("Error: corrupt or invalid update."); - txt_statusUpd.Text = "Status: Error."; - return; - } - - try - { - txt_statusUpd.Text = "Status: Step 1 | Deletion"; - - string[] filesToDelete = File.ReadAllLines(deleteFilesPath); - - foreach (string filePath in filesToDelete) - { - string fullPathToDelete = Path.Combine(Set_LA_GameFolder.Text, filePath); - - if (File.Exists(fullPathToDelete)) - { - File.Delete(fullPathToDelete); - Logger.Info("Hdiff", $"Deleted: {fullPathToDelete}"); - } - else - { - Logger.Info("Hdiff", $"File not found: {fullPathToDelete}"); - } - } - - Logger.Info("Hdiff", "File deletion process completed."); - - txt_statusUpd.Text = "Status: Step 2 | Replacement"; - try - { - string gamePath = Set_LA_GameFolder.Text; - string subdirectoryPath = Path.Combine(gamePath, "hdiff_temp"); - Console.WriteLine(subdirectoryPath); - - string[] subdirectoryFiles = Directory.GetFiles(subdirectoryPath); - - string[] mainDirectoryFiles = Directory.GetFiles(gamePath); - - var commonFiles = subdirectoryFiles.Intersect(mainDirectoryFiles); - - foreach (var commonFile in commonFiles) - { - File.Delete(Path.Combine(gamePath, Path.GetFileName(commonFile))); - } - - foreach (var file in subdirectoryFiles) - { - File.Copy(file, Path.Combine(gamePath, Path.GetFileName(file)), true); - } - - txt_statusUpd.Text = "Status: Complete."; - Logger.Info("Hdiff", "Done replacing."); - progressBar1.Value = 0; - Directory.Delete(subdirectoryPath, true); - } - catch (Exception ex) - { - Logger.Error("Hdiff", $"Error: {ex.Message}"); - progressBar1.Value = 0; - return; - } - - } - catch (Exception ex) - { - MessageBox.Show(ex.Message); - Logger.Error("Hdiff", ex.Message); - } - } - } - private void wipeLoginCacheInfo_Click(object sender, EventArgs e) { MessageBox.Show("This deletes the login cache every time the game closes (logs you out).\nThis is useful if you use the guest account on HSR servers, since you don't have to remember to log out.", "Information.", MessageBoxButtons.OK, MessageBoxIcon.Question); diff --git a/Main.resx b/Main.resx index 3915d8c..ab8a6d3 100644 --- a/Main.resx +++ b/Main.resx @@ -1,7 +1,7 @@