示例#1
0
        static ExitCode UnlockBlamTools(params string[] args)
        {
            if (args.Length < 5)
            {
                Console.WriteLine("error: invalid command argument count");
                return(ExitCode.InvalidArgsCount);
            }

            BlamVersion version = BlamVersion.Unknown;

            switch (args[0])
            {
            case "Halo1_CE":        version = BlamVersion.Halo1_CE; break;

            case "Halo2_PC":        version = BlamVersion.Halo2_PC; break;

            default:
                Console.WriteLine("error: unsupported engine version - {0}", version.ToString());
                return(ExitCode.InvalidArgs);
            }
            ;

            Console.WriteLine("Applying {0} modifications...", "CheApe");
            DumpArguments(1, args);

            Exception exception = null;

            OpenSauceIDE.CheApeInterface.UnlockToolsBase unlocker = null;
            switch (version)
            {
            case BlamVersion.Halo1_CE:
                try                                     { unlocker = new OpenSauceIDE.CheApeInterface.UnlockH1(args[4], args[1], args[2], args[3]); }
                catch (Exception ex) { exception = ex; }
                break;

            case BlamVersion.Halo2_PC:
                try                                     { unlocker = new OpenSauceIDE.CheApeInterface.UnlockH2(args[4], args[1], args[2], args[3]); }
                catch (Exception ex) { exception = ex; }
                break;
            }

            if (unlocker != null)             // If the unlocker api was initialized OK, run the unlocking operations
            {
                try
                {
                    unlocker.Unlock(false);
                    unlocker.Close();
                }
                catch (Exception ex)    { exception = ex; }
            }

            if (exception != null)
            {
                Console.WriteLine("error: an exception occurred when attempting to apply the {0} modifications", "CheApe");
                Console.WriteLine();
                Console.WriteLine("exception details:");
                if (exception.Message != null)
                {
                    Console.WriteLine(exception.Message);
                }
                Console.WriteLine(exception.StackTrace);
                Console.WriteLine();
            }

            ExitCode exit_code = ExitCode.Success;
            string   msg;

            if (exception == null)
            {
                msg = "CheApe successfully applied!";
            }
            else if (unlocker.EncounteredInvalidExe)
            {
                msg       = "CheApe couldn't be applied to some or all of the exes. Check the debug log for more details";
                exit_code = ExitCode.InvalidInput;
            }
            else
            {
                msg       = "There was an error while trying to apply CheApe. Validate that you selected copies of the original tools and try again.";
                exit_code = ExitCode.Failure;
            }

            Console.WriteLine(msg);

            return(exit_code);
        }
示例#2
0
		static ExitCode UnlockBlamTools(params string[] args)
		{
			if (args.Length < 5)
			{
				Console.WriteLine("error: invalid command argument count");
				return ExitCode.InvalidArgsCount;
			}

			BlamVersion version = BlamVersion.Unknown;
			switch (args[0])
			{
				case "Halo1_CE":	version = BlamVersion.Halo1_CE;	break;
                case "Halo2_PC":	version = BlamVersion.Halo2_PC;	break;
				default:
					Console.WriteLine("error: unsupported engine version - {0}", version.ToString());
					return ExitCode.InvalidArgs;
			};

			Console.WriteLine("Applying {0} modifications...", "CheApe");
			DumpArguments(1, args);

			Exception exception = null;
			OpenSauceIDE.CheApeInterface.UnlockToolsBase unlocker = null;
			switch (version)
			{
				case BlamVersion.Halo1_CE:
					try					{ unlocker = new OpenSauceIDE.CheApeInterface.UnlockH1(args[4], args[1], args[2], args[3]); }
					catch (Exception ex){ exception = ex; }
					break;
				case BlamVersion.Halo2_PC:
					try					{ unlocker = new OpenSauceIDE.CheApeInterface.UnlockH2(args[4], args[1], args[2], args[3]); }
					catch (Exception ex){ exception = ex; }
					break;
			}

			if (unlocker != null) // If the unlocker api was initialized OK, run the unlocking operations
			{
				try
				{
					unlocker.Unlock(false);
					unlocker.Close();
				}
				catch (Exception ex)	{ exception = ex; }
			}

			if (exception != null)
			{
				Console.WriteLine("error: an exception occurred when attempting to apply the {0} modifications", "CheApe");
				Console.WriteLine();
				Console.WriteLine("exception details:");
				if(exception.Message != null) Console.WriteLine(exception.Message);
				Console.WriteLine(exception.StackTrace);
				Console.WriteLine();
			}

			ExitCode exit_code = ExitCode.Success;
			string msg;
			if (exception == null)
				msg = "CheApe successfully applied!";
			else if (unlocker.EncounteredInvalidExe)
			{
				msg = "CheApe couldn't be applied to some or all of the exes. Check the debug log for more details";
				exit_code = ExitCode.InvalidInput;
			}
			else
			{
				msg = "There was an error while trying to apply CheApe. Validate that you selected copies of the original tools and try again.";
				exit_code = ExitCode.Failure;
			}

			Console.WriteLine(msg);

			return exit_code;
		}