Exemplo n.º 1
0
		public static bool AddFiles(ClientPatch patch) {
			string abPath = Path.GetDirectoryName(System.Windows.Forms.Application.ExecutablePath);

			return UnpackFile(patch.FilePath, abPath);
		}
Exemplo n.º 2
0
		private void HandlePatchFinish(ClientPatch Patch, bool Cancel) {
			UpdateProgressbar(100);
			if (TaskbarManager.IsPlatformSupported) {
				mWin7Taskbar.SetProgressState(TaskbarProgressBarState.NoProgress);
			}

			if (ApplyPatch(Patch) == true) {
				mRegistry.SavePatch(Patch.ID);
				mPatchedFiles.Add(Patch.ID);
			}

			mPatchProgress++;
			ProgressPatches();
		}
Exemplo n.º 3
0
		private bool ApplyPatch(ClientPatch patch) {
			string grfPath;
			bool retVal = true;

			switch (patch.Action) {
				case EPatchAction.PatcherUpdate:
				case EPatchAction.None:
					return true;


				case EPatchAction.PatchReset:
					// Reset registry
					mRegistry.PatchReset(patch.ID);
					// Fake patch count, so no patch will be downloaded after this
					mPatches.Clear();
					// Output 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 the patcher asap
					Close();
					return false;

				case EPatchAction.GrfAdd:
					grfPath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, patch.Target);
					if (grfPath.EndsWith(".grf") == false) {
						grfPath += ".grf";
					}

					try {
						GrfHelper.GrfFromCache(patch.Target, grfPath); // Ensure the GRF got loaded
						GrfHelper.MergeGrf(patch.Target, patch.FilePath);
					} catch (Exception e) {
						retVal = false;
						MessageBox.Show("Failed to apply Patch \"" + patch.Name + "\".\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 the GRF got loaded
						GrfHelper.DeleteFromGrf(patch.Target, patch.Name);
					} catch (Exception e) {
						retVal = false;
						MessageBox.Show("Failed to apply Patch \"" + patch.Name + "\".\nSkip..");
						System.Diagnostics.Debug.WriteLine(e);
					}
					break;

				case EPatchAction.DataAdd:
					if (DataHelper.AddFiles(patch) == false) {
						retVal = false;
						MessageBox.Show("Failed to apply Patch \"" + patch.Name + "\".\nSkip..");
					}
					break;
				case EPatchAction.DataDelete:
					if (DataHelper.DeleteFile(patch.Name) == false) {
						retVal = false;
						MessageBox.Show("Failed to apply Patch \"" + patch.Name + "\".\nSkip..");
					}
					break;
			}

			return retVal;
		}
Exemplo n.º 4
0
		private void HandlePatchProgress(ClientPatch Patch, System.Net.DownloadProgressChangedEventArgs e) {
			UpdateProgressbar(e.ProgressPercentage);
			UpdateStatus("Work on: " + Patch.Displayname + " [ " + e.BytesReceived.GetFileSize() + " / " + e.TotalBytesToReceive.GetFileSize() + " ]");
		}