public static void ValidateInstallDir() { string filename = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "BlubbRO Patcher.dat"); bool firstStart = File.Exists(filename); if (firstStart == true) { return; } // first install, reset patches RegHelper.PatchReset(0); // write "check file" File.WriteAllLines(filename, new string[1] { filename }); }
private bool ApplyPatch(ClientPatch Patch) { string grfPath; bool retVal = true; switch (Patch.PatchAction) { case EPatchAction.PatcherUpdate: case EPatchAction.None: return(true); case EPatchAction.PatchReset: // reset reg RegHelper.PatchReset(Patch.PatchID); // fake count, so no patch proceed PatchlistHelper.Patches.Clear(); // info MessageBox.Show("Your patches has been reset.\nPlease restart the Patcher to patch again.\n\nThank you.", "Patcher notice", MessageBoxButtons.OK, MessageBoxIcon.Information); // close app Close(); // dont try to update on success return(false); case EPatchAction.GrfAdd: grfPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Patch.Target) + ".grf"; try { GrfHelper.GrfFromCache(Patch.Target, grfPath); // ensure GRF get loaded GrfHelper.MergeGrf(Patch.Target, Patch.FilePath); } catch (Exception e) { retVal = false; MessageBox.Show("Failed to apply Patch \"" + Patch.PatchName + "\".\nSkip.."); System.Diagnostics.Debug.WriteLine(e); } break; case EPatchAction.GrfDelete: grfPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Patch.Target) + ".grf"; try { GrfHelper.GrfFromCache(Patch.Target, grfPath); // ensure GRF get loaded GrfHelper.DeleteFromGrf(Patch.Target, Patch.PatchName); } catch (Exception e) { retVal = false; MessageBox.Show("Failed to apply Patch \"" + Patch.PatchName + "\".\nSkip.."); System.Diagnostics.Debug.WriteLine(e); } break; case EPatchAction.DataAdd: if (DataHelper.AddFiles(Patch.FilePath) == false) { retVal = false; MessageBox.Show("Failed to apply Patch \"" + Patch.PatchName + "\".\nSkip.."); } break; case EPatchAction.DataDelete: if (DataHelper.DeleteFile(Patch.PatchName) == false) { retVal = false; MessageBox.Show("Failed to apply Patch \"" + Patch.PatchName + "\".\nSkip.."); } break; } return(retVal); }