private static void ProcessAddons(string relativeDir) { //Use the MissionMergeForm to do the work MissionMergeForm form = new MissionMergeForm(); form.ConsoleMode = true; form.DefaultOutputFileName = relativeDir + "mission.lvl"; form.BaseFileName = "base.mission.lvl"; string mission_file = ""; Console.WriteLine("Reading files..."); for (int i = 0; i < 1000; i++) { if (relativeDir == ".\\") { mission_file = String.Format(".\\addon\\{0:000}\\mission.lvl", i); } else { mission_file = String.Format(".\\{0:000}\\mission.lvl", i); } if (File.Exists(mission_file)) { Console.WriteLine("Merging '{0}'...", mission_file); form.AddonMissionFileName = mission_file; form.MergeLevels(); } } Console.WriteLine("Saving..."); string outFile = form.SaveMissionFile(); MessageBox.Show("New mission file saved to:\r\n" + Path.GetFullPath(outFile)); form.Dispose(); }
static int Main(string[] args) { if (args.Length == 0) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new MissionMergeForm()); return(0); } #region process args... string arg = ""; for (int i = 0; i < args.Length; i += 2) { arg = args[i].ToLower(); if ("-h /h /? --help".IndexOf(arg) > -1) { Console.WriteLine(sHelpMsg); return(0); } else if (arg == "-base_mission" && args.Length > i + 1) { sBaseFile = args[i + 1]; } else if (arg == "-addon_missions" && args.Length > i + 1) { sAddonFile = args[i + 1]; } else if (arg == "-output" && args.Length > i + 1) { sOutputFile = args[i + 1]; } } #endregion if (!File.Exists(sBaseFile) || !File.Exists(sAddonFile)) { Console.Error.WriteLine("Both 'base_mission' and 'addon_missions' files must be specified!\n"); Console.Error.WriteLine(sHelpMsg); return(1); } //Use the MissionMergeForm to do our bidding MissionMergeForm form = new MissionMergeForm(); form.ConsoleMode = true; Console.WriteLine("Reading files..."); form.DefaultOutputFileName = sOutputFile; form.BaseFileName = sBaseFile; form.AddonMissionFileName = sAddonFile; Console.WriteLine("Merging..."); form.MergeLevels(); Console.WriteLine("Saving..."); form.SaveMissionFile(); form.Dispose(); return(0); }
/// <summary> Gets the name of the source file that was munged into this data. </summary> public string GetName() { int headChunkLength = -1; string name = ""; long loc1 = -1; long loc = BinSearch.GetLocationOfGivenBytes(mLocation, ASCIIEncoding.ASCII.GetBytes("scr_"), mData, 40); if (loc < 0) { loc1 = BinSearch.GetLocationOfGivenBytes(mLocation, ASCIIEncoding.ASCII.GetBytes("mcfg"), mData, 80); if (loc1 > 0) { headChunkLength = MissionMergeForm.GetLengthAtLocation(loc1 + 4, mData); loc1 = BinSearch.GetLocationOfGivenBytes(loc1 + headChunkLength - 8, ASCIIEncoding.ASCII.GetBytes("scr_"), mData, 80); } } else { loc1 = loc; } if (loc1 > 0) { loc = BinSearch.GetLocationOfGivenBytes(loc1, ASCIIEncoding.ASCII.GetBytes("NAME"), mData, 80); } if (loc > -1) { int nameLen = mData[(int)loc + 4] - 1; // -1 for null byte if (loc > 0) { // NAME + 4 bytes later = 8 name = Encoding.ASCII.GetString(mData, (int)loc + 8, (int)nameLen); } } return(name); }