private bool _tryLoadNPCs(string fileName = null) { try { m_npcs = string.IsNullOrEmpty(fileName) ? new NPCFile() : new NPCFile(fileName); } catch { m_npcs = null; return(false); } return(true); }
private bool _tryLoadNPCs(string fileName = null) { try { m_npcs = string.IsNullOrEmpty(fileName) ? new NPCFile() : new NPCFile(fileName); } catch { m_npcs = null; return false; } return true; }
private static void Main(string[] args) { if (args.Length != 3) { Console.WriteLine("Usage: BatchMap.exe <srcmap|srcdir> <dstmap|dstdir> <pubdir>"); return; } string srcFilePath = args[0]; string dstFilePath = args[1]; string pubFilePath = args[2]; bool singleFileProcess = false; if (srcFilePath.ToLower().EndsWith(".emf") && !dstFilePath.ToLower().EndsWith(".emf")) { Console.WriteLine("Invalid: single map cannot be processed into output directory. Specify destination emf file."); return; } if (dstFilePath.ToLower().EndsWith(".emf") && !srcFilePath.ToLower().EndsWith(".emf")) { Console.WriteLine("Invalid: map directory cannot be processed into single output map. Specify destination output directory."); return; } if (srcFilePath.ToLower().EndsWith(".emf") && dstFilePath.ToLower().EndsWith(".emf")) { singleFileProcess = true; if (!File.Exists(srcFilePath)) { Console.WriteLine("Invalid input: input file does not exist!"); return; } if (File.Exists(dstFilePath)) { char inp; do { Console.Write("Destination file exists. Overwrite? [y/n] "); string input = Console.ReadLine() ?? ""; inp = input.Length > 0 ? input[0] : ' '; } while (inp != 'y' && inp != 'n' && inp != 'Y' && inp != 'N'); if (inp == 'n' || inp == 'N') { Console.WriteLine("Will not overwrite existing file. Exiting."); return; } } } else { if (!Directory.Exists(srcFilePath) || Directory.GetFiles(srcFilePath, "*.emf").Length == 0) { Console.WriteLine("Invalid input: source directory does not exist or is missing maps!"); return; } if (Directory.Exists(dstFilePath) && Directory.GetFiles(dstFilePath, "*.emf").Length > 0) { char inp; do { Console.WriteLine("Destination directory contains emf files. Overwrite? [y/n] "); string input = Console.ReadLine() ?? ""; inp = input.Length > 0 ? input[0] : ' '; } while (inp != 'y' && inp != 'n' && inp != 'Y' && inp != 'N'); if (inp == 'n' || inp == 'N') { Console.WriteLine("Will not overwrite existing files. Exiting."); return; } } else if (!Directory.Exists(dstFilePath)) { Directory.CreateDirectory(dstFilePath); } } try { EIF = new ItemFile(Path.Combine(pubFilePath, "dat001.eif")); ENF = new NPCFile(Path.Combine(pubFilePath, "dtn001.enf")); } catch { Console.WriteLine("Error loading pub files!"); return; } ProcessFiles(srcFilePath, dstFilePath, singleFileProcess); }