public DBCFileComparer(string oldFile, string newFile, int testAmount, CellType[] knownColumnStructure) { oldReader = new DBCReader(oldFile); newReader = new DBCReader(newFile); this.knownColumnStructure = knownColumnStructure; this.testAmount = testAmount; }
public static List<string> GenerateListfile() { List<string> files = new List<String>(); string line; // System.IO.StreamReader file = new System.IO.StreamReader(CASC.OpenFile("signaturefile")); if (CASC.FileExists("DBFilesClient\\FileData.dbc")) { DBCReader<FileDataRecord> filedatareader = new DBCReader<FileDataRecord>("DBFilesClient\\FileData.dbc"); for (int i = 0; i < filedatareader.recordCount; i++) { string filename = filedatareader[i].FilePath + filedatareader[i].FileName; if (filename.EndsWith(".wmo", StringComparison.OrdinalIgnoreCase) || filename.EndsWith(".m2", StringComparison.OrdinalIgnoreCase)) { files.Add(filename); } } } if (File.Exists("wow-live-listfile-seed.txt")) { var file = new StreamReader("wow-live-listfile-seed.txt"); while ((line = file.ReadLine()) != null) { if (line.EndsWith(".wmo", StringComparison.OrdinalIgnoreCase) || line.EndsWith(".m2", StringComparison.OrdinalIgnoreCase)) { files.Add(line); } } } List<string> unwantedExtensions = new List<String>(); for (int i = 0; i < 1024; i++) { unwantedExtensions.Add("_" + i.ToString().PadLeft(3, '0') + ".wmo"); unwantedExtensions.Add("_" + i.ToString().PadLeft(3, '0') + ".WMO"); } string[] unwanted = unwantedExtensions.ToArray(); List<string> retlist = new List<string>(); for (int i = 0; i < files.Count(); i++) { if (!files[i].StartsWith("alternate") && !files[i].StartsWith("Camera")) { if (!unwanted.Contains(files[i].Substring(files[i].Length - 8, 8))) { if (!files[i].Contains("LOD")) { retlist.Add(files[i]); } } } } return retlist.Distinct(StringComparer.CurrentCultureIgnoreCase).ToList(); }
private void Load(string filename, int fields_to_skip, Dictionary <int, string> dictionary) { IWowClientDBReader mReader; if (filename.Contains(".dbc")) { mReader = new DBCReader("dbc/" + filename); } else { mReader = new DB2Reader("dbc/" + filename); } for (int i = 0; i < mReader.RecordsCount; ++i) { BinaryReader br = mReader[i]; int id = br.ReadInt32(); for (int j = 0; j < fields_to_skip; ++j) { br.ReadInt32(); } string name = mReader.StringTable[br.ReadInt32()] ?? filename.Replace(".dbc", "") + " " + id; dictionary[id] = name; } }
private string GuessDBCVersion(Dictionary <String, DBCConfig> dbc_config) { foreach (string dbc_version in dbc_config.Keys) { if (!File.Exists(Properties.Settings.Default.DBC + "\\" + dbc_config[dbc_version].offsets[StorageType.Spell].file)) { break; } IWowClientDBReader m_reader; m_reader = new DBCReader(Properties.Settings.Default.DBC + "\\" + dbc_config[dbc_version].offsets[StorageType.Spell].file); BinaryReader br = m_reader[0]; int id = br.ReadInt32(); for (int i = 0; i < dbc_config[dbc_version].offsets[StorageType.Spell].offset; i++) { br.ReadInt32(); } id = br.ReadInt32(); if (m_reader.StringTable.ContainsKey(id) && !String.IsNullOrEmpty(m_reader.StringTable[id])) { return(dbc_version); } } return(null); }
private void buttonOpenDBC_Click(object sender, RoutedEventArgs e) { //init all controls to empty treeView.ItemsSource = null; OpenFileDialog openDBC = new OpenFileDialog(); openDBC.FileName = "DBC File"; openDBC.DefaultExt = ".dbc"; openDBC.Filter = "CAN db files (*.dbc)|*.dbc"; if (openDBC.ShowDialog() == System.Windows.Forms.DialogResult.OK) { ObservableCollection <DbcMessage> AllMsg; dbcParser = new DBCReader(openDBC.FileName); AllMsg = dbcParser.ExtGetAllMessages(); ConfManager.ProjectDBC = openDBC.FileName; ConfManager.AllMessages = AllMsg; ConfManager.SelectedNode = "All"; //binding to controls treeView.ItemsSource = null; treeView.Items.Clear(); treeView.ItemsSource = ConfManager.Messages; } }
public static void WriteRangeEnum() { DBCReader <DistanceEntry, DistanceConverter> ranges = new DBCReader <DistanceEntry, DistanceConverter>( RealmServer.RealmServer.Instance.Configuration.GetDBCFile("SpellRange.dbc")); WriteEnum <DistanceEntry>("Range", "Spells", ranges.Entries.Values, (entry) => { return(true); }, (entry) => { return(entry.Name); }, (entry) => { return(entry.Distance.ToString()); }); }
public Loader() { Contract.Requires(DBC.DBCPath != null); DBC.Vehicle = DBCReader.ReadDBC <VehicleEntry>(DBC.VehicleStrings); DBC.VehicleSeat = DBCReader.ReadDBC <VehicleSeatEntry>(null); DBC.VehicleUIIndicator = DBCReader.ReadDBC <VehicleUIIndicatorEntry>(null); DBC.VehicleUIIndSeat = DBCReader.ReadDBC <VehicleUIIndSeatEntry>(null); SQL.CreatureTemplate = SQLReader.LoadCreatureTemplates(); SQL.SpellClick = SQLReader.LoadSpellClick(); SQL.Accessories = SQLReader.LoadVehicleAccessories(); }
public static bool Initialize() { try { AreaTable = DBCReader.Read <uint, AreaTable>("AreaTable.dbc", "ID"); return(true); } catch (Exception ex) { Console.WriteLine(ex.Message); } return(false); }
public static bool Initialize() { try { AreaTable = DBCReader.Read <uint, AreaTable>("AreaTable.dbc", "ID"); Maps = DBCReader.Read <uint, DBCMap>("Map.dbc", "ID"); return(true); } catch (Exception ex) { Logger.Error(ex.Message); } return(false); }
public static List <DBCMapEntry> GetMapEntries() { var wowRootDir = DBCTool.FindWowDir(null); if (!Directory.Exists(wowRootDir)) { log.Error("Could not find WoW-directory: \"{0}\"", wowRootDir); return(null); } var DBCMapEntryReader = new DBCReader <DBCMapEntry, DBCMapConverter>( RealmServerConfiguration.GetDBCFile("Map.dbc")); return(DBCMapEntryReader.EntryList); }
public DBCLoader() { try { DBCStore.DBC.Spell = DBCReader.ReadDBC <SpellEntry>(DBCStore.DBC.SpellStrings); DBCStore.DBC.Map = DBCReader.ReadDBC <MapEntry>(DBCStore.DBC.MapStrings); DBCStore.DBC.LFGDungeons = DBCReader.ReadDBC <LFGDungeonsEntry>(DBCStore.DBC.LFGDungeonsStrings); DBCStore.DBC.BattlemasterList = DBCReader.ReadDBC <BattlemasterListEntry>(DBCStore.DBC.BattlemasterListStrings); } catch (IOException e) { Console.WriteLine("DBC loading failed at exception {0}. DBC will be disabled.", e.GetType()); Console.WriteLine(e.Message); DBCStore.DBC.Enabled = false; } }
private ObservableCollection <DbcMessage> MergeDBC(DBCReader dbcA, DBCReader dbcB) { ObservableCollection <DbcMessage> mergedMsg = dbcA.GetAllMessages(); foreach (var msg in dbcParserB.GetAllMessages()) { if (dbcParserA.GetAllMessages().Any(p => p.ID == msg.ID)) { //not found in dbcA } else { mergedMsg.Add(msg); } } return(mergedMsg); }
private void MapsTab_Focused(object sender, RoutedEventArgs e) { if (mapsTabLoaded) { return; } var reader = new DBCReader <MapRecord>(@"dbfilesclient\map.dbc"); for (int i = 0; i < reader.recordCount; i++) { MapListBox.Items.Add(new KeyValuePair <int, string>(reader[i].ID, reader[i].Directory)); } MapListBox.DisplayMemberPath = "Value"; mapsTabLoaded = true; }
public void ItemsToDBC() { DBCReader reader = new DBCReader("data/itemheader.dbc"); BinaryWriter writer = new BinaryWriter(File.OpenWrite("Item.dbc")); DBCHeader header = new DBCHeader { DBCmagic = DBCReader.DBCFmtSig, RecordsCount = (uint)items.Count, FieldsCount = (uint)reader.FieldsCount, RecordSize = (uint)reader.RecordSize, StringTableSize = (uint)reader.StringTableSize }; //Write header content writer.Write(DBCReader.DBCFmtSig); writer.Write(header.RecordsCount); writer.Write(header.FieldsCount); writer.Write(header.RecordSize); writer.Write(header.StringTableSize); //Write item struct foreach (var pair in items) { Item item = pair.Value; byte[] buffer = new byte[Marshal.SizeOf(typeof(Item))]; GCHandle handle = GCHandle.Alloc(buffer, GCHandleType.Pinned); Marshal.StructureToPtr(item, handle.AddrOfPinnedObject(), true); writer.Write(buffer, 0, buffer.Length); handle.Free(); } //Write string table foreach (var pair in reader.StringTable) { writer.Write(Encoding.UTF8.GetBytes(pair.Value + "\0")); } writer.Close(); MessageBox.Show("Conversion to DBC complete, please check main folder new Item.dbc file!"); }
/// <summary> /// Load DBC B /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void dbcTarget_Click(object sender, RoutedEventArgs e) { OpenFileDialog openDBC = new OpenFileDialog(); openDBC.FileName = "DBC File"; openDBC.DefaultExt = ".dbc"; openDBC.Filter = "CAN db files (.dbc)|*.dbc"; if (openDBC.ShowDialog() == System.Windows.Forms.DialogResult.OK) { dbcParserB = new DBCReader(openDBC.FileName); DbcComparer.DbcB = dbcParserB.GetAllMessages(); DbcComparer.PathB = openDBC.FileName; //binding to controls treeViewTarget.ItemsSource = null; treeViewTarget.Items.Clear(); treeViewTarget.ItemsSource = DbcComparer.DbcB; } }
public void Initialize() { if (Directory.Exists(@"Data\DBC")) { DBC.Spell = DBCReader.ReadDBC <SpellEntry>(DBC.SpellStrings); DBC.SkillLine = DBCReader.ReadDBC <SkillLineEntry>(DBC.SkillLineStrings); DBC.SpellRange = DBCReader.ReadDBC <SpellRangeEntry>(DBC.SpellRangeStrings); DBC.SpellDuration = DBCReader.ReadDBC <SpellDurationEntry>(null); DBC.SkillLineAbility = DBCReader.ReadDBC <SkillLineAbilityEntry>(null); DBC.SpellRadius = DBCReader.ReadDBC <SpellRadiusEntry>(null); DBC.SpellCastTimes = DBCReader.ReadDBC <SpellCastTimesEntry>(null); Logging.Write(string.Format("Loaded {0} Spells from DBC", DBC.Spell.Count)); Logging.Write(string.Format("Loaded {0} SkillLines from DBC", DBC.SkillLine.Count)); Logging.Write(string.Format("Loaded {0} SpellRanges from DBC", DBC.SpellRange.Count)); Logging.Write(string.Format("Loaded {0} SpellDurations from DBC", DBC.SpellDuration.Count)); Logging.Write(string.Format("Loaded {0} SkillLineAbilitys from DBC", DBC.SkillLineAbility.Count)); Logging.Write(string.Format("Loaded {0} SpellRadiuss from DBC", DBC.SpellRadius.Count)); Logging.Write(string.Format("Loaded {0} SpellCastTimes from DBC", DBC.SpellCastTimes.Count)); } else { Logging.WriteError("DBC Folder doesn't exist!"); } DataMgr.Init(); engine = new Engine(false); engine.States.Add(new CombatState { Priority = int.MaxValue }); engine.States.Sort(); engine.StartEngine(10, "Carlcombat", true); }
private void Load(string filename, Func <BinaryReader, Dictionary <int, string>, string> func) { if (!File.Exists(Properties.Settings.Default.DBC + "\\" + filename)) { return; } IWowClientDBReader m_reader; if (filename.Contains(".dbc")) { m_reader = new DBCReader(Properties.Settings.Default.DBC + "\\" + filename); } else { m_reader = new DB2Reader(Properties.Settings.Default.DBC + "\\" + filename); } for (int i = 0; i < m_reader.RecordsCount; ++i) { BinaryReader br = m_reader[i]; int id = br.ReadInt32(); values[id] = func(br, m_reader.StringTable); } }
public static List<string> GenerateListfile() { //extract signaturefile and extract list of some files from that List<string> files = new List<String>(); /* if (!FileExists("signaturefile")) { new MissingFile("signaturefile"); return files; } */ string line; string[] linesplit; // System.IO.StreamReader file = new System.IO.StreamReader(CASC.OpenFile("signaturefile")); if (CASC.FileExists("DBFilesClient\\FileData.dbc")) { DBCReader<FileDataRecord> filedatareader = new DBCReader<FileDataRecord>("DBFilesClient\\FileData.dbc"); for (int i = 0; i < filedatareader.recordCount; i++) { string filename = filedatareader[i].FilePath + filedatareader[i].FileName; if (filename.EndsWith(".wmo", StringComparison.OrdinalIgnoreCase) || filename.EndsWith(".m2", StringComparison.OrdinalIgnoreCase)) { files.Add(filename); } } } /* while ((line = file.ReadLine()) != null) { linesplit = line.Split(';'); if (linesplit.Count() != 4) { continue; } //filter out junk if (linesplit[3].EndsWith(".wmo", StringComparison.OrdinalIgnoreCase) || linesplit[3].EndsWith(".m2", StringComparison.OrdinalIgnoreCase)) { files.Add(linesplit[3]); } } */ List<string> unwantedExtensions = new List<String>(); for (int i = 0; i < 1024; i++) { unwantedExtensions.Add("_" + i.ToString().PadLeft(3, '0') + ".wmo"); unwantedExtensions.Add("_" + i.ToString().PadLeft(3, '0') + ".WMO"); } string[] unwanted = unwantedExtensions.ToArray(); List<string> retlist = new List<string>(); for (int i = 0; i < files.Count(); i++) { if (!files[i].StartsWith("alternate") && !files[i].StartsWith("Camera")) { if (!unwanted.Contains(files[i].Substring(files[i].Length - 8, 8))) { if (!files[i].Contains("LOD")) { retlist.Add(files[i]); } } } } return retlist.Distinct(StringComparer.CurrentCultureIgnoreCase).ToList(); }
public static void InitTitles() { DBCReader <TitleConverter> dbcReader = new DBCReader <TitleConverter>(RealmServerConfiguration.GetDBCFile("CharTitles.dbc")); }
public void Compare(TextWriter writer) { var newFiles = new HashSet<string>(Directory.GetFiles(newDir, "*.dbc").Select((file) => new FileInfo(file).Name), StringComparer.InvariantCultureIgnoreCase); var oldFiles = new HashSet<string>(Directory.GetFiles(oldDir, "*.dbc").Select((file) => new FileInfo(file).Name), StringComparer.InvariantCultureIgnoreCase); var addedFiles = newFiles.Except(oldFiles); var removedFiles = oldFiles.Except(newFiles); var existingFiles = newFiles.Except(addedFiles); if (addedFiles.Count() > 0) { writer.WriteLine("{0} files have been added:", addedFiles.Count()); foreach (var file in addedFiles) { writer.WriteLine("\t" + new FileInfo(file).Name); var reader = new DBCReader(Path.Combine(newDir, file)); writer.WriteLine("\t\tColumn Count: " + reader.ColumnCount); writer.WriteLine("\t\tRow Count: " + reader.RecordCount); writer.WriteLine("\t\tHas Strings: " + reader.HasStrings); if (reader.IrregularColumnSize) { writer.WriteLine("\t\tColumn Size IRREGULAR!"); } } } if (removedFiles.Count() > 0) { writer.WriteLine("{0} files have been deprecated (not present anymore):", removedFiles.Count()); foreach (var file in addedFiles) { writer.WriteLine("\t" + new FileInfo(file).Name); } } writer.WriteLine(); writer.WriteLine("#######################################"); writer.WriteLine("Changes in files{0}:", maxTestAmount != int.MaxValue ? " - Testing with first " + maxTestAmount + " rows" : ""); writer.WriteLine(); foreach (var file in existingFiles) { var comparer = new DBCFileComparer(Path.Combine(oldDir, file), Path.Combine(newDir, file), maxTestAmount, null); if (comparer.NewReader.IrregularColumnSize) { writer.WriteLine("Skipping {0} (IRREGULAR Column Size)", file); } else if (comparer.NewReader.ColumnCount != comparer.OldReader.ColumnCount && (comparer.NewReader.ColumnCount < 2 || comparer.OldReader.ColumnCount < 2)) { writer.WriteLine("Skipping {0} (Only 1 column or less)", file); } else { comparer.Compare(writer); } } }
static void Main(string[] args) { Console.WriteLine("Initializing CASC.."); CASC.InitCasc(null, @"C:\World of Warcraft", "wow"); Console.WriteLine("CASC initialized!"); var dbcreader = new DBCReader<MapRecord>("DBFilesClient\\Map.dbc"); string mapfilter = "Draenor"; //string mapfilter = null; for (int mi = 0; mi < dbcreader.recordCount; mi++) { string mapname = dbcreader[mi].Directory; if (mapfilter != null) { if (mapname != mapfilter) { continue; } } Console.WriteLine("Creating image for map " + mapname + " (" + dbcreader[mi].Mapname_lang + ")"); if (File.Exists("done/" + mapname + ".png")) { continue; } float lowest = float.MaxValue; float highest = float.MinValue; float lowest_chunkpos = float.MaxValue; float highest_chunkpos = float.MinValue; var min_x = 64; var min_y = 64; var max_x = 0; var max_y = 0; Console.Write("Calculating heights.."); for (int x = 0; x < 63; x++) { for (int y = 0; y < 63; y++) { string filename = "World/Maps/" + mapname + "/" + mapname + "_" + y + "_" + x + ".adt"; if (CASC.FileExists(filename)) { if (x > max_x) { max_x = x; } if (y > max_y) { max_y = y; } if (x < min_x) { min_x = x; } if (y < min_y) { min_y = y; } ADTReader reader = new ADTReader(); reader.LoadADT(filename); for (var i = 0; i < 256; i++) { if (reader.adtfile.chunks[i].header.position.Z < lowest_chunkpos) { lowest_chunkpos = reader.adtfile.chunks[i].header.position.Z; } if (reader.adtfile.chunks[i].header.position.Z > highest_chunkpos) { highest_chunkpos = reader.adtfile.chunks[i].header.position.Z; } for (var j = 0; j < 145; ++j) { //Console.WriteLine(reader.adtfile.chunks[i].vertices.vertices[j]); if (reader.adtfile.chunks[i].vertices.vertices[j] < lowest) { lowest = reader.adtfile.chunks[i].vertices.vertices[j]; } if (reader.adtfile.chunks[i].vertices.vertices[j] > highest) { highest = reader.adtfile.chunks[i].vertices.vertices[j]; } } } } } } Console.Write(" ..done!\n"); Console.WriteLine("Highest: " + highest); Console.WriteLine("Lowest: " + lowest); Console.WriteLine("Highest chunkpos: " + highest_chunkpos); Console.WriteLine("Lowest chunkpos: " + lowest_chunkpos); if (lowest_chunkpos < 0) { highest = highest + (lowest * -1) + highest_chunkpos; lowest = (lowest * -1) + (lowest_chunkpos * -1); } else { highest = highest + (lowest * -1) + highest_chunkpos; lowest = (lowest * -1) + lowest_chunkpos; } Console.WriteLine("Highest post-flip: " + highest); Console.WriteLine("Lowest post-flip: " + lowest); Console.WriteLine("Highest chunkpos post-flip: " + highest_chunkpos); Console.WriteLine("Lowest chunkpos post-flip: " + lowest_chunkpos); Console.Write("Creating images.."); for (int x = 0; x < 63; x++) { for (int y = 0; y < 63; y++) { string filename = "World/Maps/" + mapname + "/" + mapname + "_" + y + "_" + x + ".adt"; if (CASC.FileExists(filename)) { ADTReader reader = new ADTReader(); reader.LoadADT(filename); var fullmap = new Bitmap(144, 144); for (var a = 0; a < 256; a++) { //Console.WriteLine(reader.adtfile.chunks[a].header.indexX + " x " + reader.adtfile.chunks[a].header.indexY); int img_x = 0; int img_y = 0; int counter = 0; for (var i = 0; i < 17; ++i) { for (var j = 0; j < (((i % 2) != 0) ? 8 : 9); ++j) { if (i % 2 == 0) { //only render these //Console.Write("(" + j +" " + i + ")" + counter + " |" ); //int greyness = (int)Math.Round(((reader.adtfile.chunks[a].vertices.vertices[counter] + reader.adtfile.chunks[a].header.position.Z) + lowest) / highest * 255); // if (greyness > 255) { greyness = 255; } //those edge cases where rounding just makes it go over 255 if (reader.adtfile.chunks[a].vertexShading.red != null && reader.adtfile.chunks[a].vertexShading.red[counter] != 127) { fullmap.SetPixel(img_x + (int)(reader.adtfile.chunks[a].header.indexX * 9), img_y + (int)(reader.adtfile.chunks[a].header.indexY * 9), Color.FromArgb(reader.adtfile.chunks[a].vertexShading.blue[counter], reader.adtfile.chunks[a].vertexShading.green[counter], reader.adtfile.chunks[a].vertexShading.red[counter]) ); } else { int greyness = (int)Math.Round(((reader.adtfile.chunks[a].vertices.vertices[counter] + reader.adtfile.chunks[a].header.position.Z) + lowest) / highest * 255); if (greyness > 255 || greyness < 0) { greyness = 255; } fullmap.SetPixel(img_x + (int)(reader.adtfile.chunks[a].header.indexX * 9), img_y + (int)(reader.adtfile.chunks[a].header.indexY * 9), Color.FromArgb(greyness, greyness, greyness)); } img_x++; } counter++; } if (i % 2 == 0) { img_y++; img_x = 0; //Console.Write("\n"); } } } fullmap.Save("Z:/adttest/" + mapname + "_" + y + "_" + x + ".png"); } } } Console.Write(" ..done!\n"); //Time to compile the full image var res_x = (((max_y - min_y) * 144) + 144); var res_y = (((max_x - min_x) * 144) + 144); if (res_x > 0 && res_y > 0) { Console.WriteLine("[" + mapname + "] " + "Creating new image of " + res_x + "x" + res_y); Bitmap bmp = new Bitmap(res_x, res_y); Graphics g = Graphics.FromImage(bmp); for (int cur_x = 0; cur_x < 64; cur_x++) { for (int cur_y = 0; cur_y < 64; cur_y++) { if (File.Exists("Z:/adttest/" + mapname + "_" + cur_x + "_" + cur_y + ".png")) { var bmpreader = new Bitmap("Z:/adttest/" + mapname + "_" + cur_x + "_" + cur_y + ".png"); g.DrawImage(bmpreader, (cur_x - min_x) * 144, (cur_y - min_y) * 144, new Rectangle(0, 0, 144, 144), GraphicsUnit.Pixel); bmpreader.Dispose(); File.Delete("Z:/adttest/" + mapname + "_" + cur_x + "_" + cur_y + ".png"); } } } g.Dispose(); if (!Directory.Exists("done")) { Directory.CreateDirectory("done"); } bmp.Save("done/" + mapname + ".png"); } } }
public static string[] getTexturesByModelFilename(string modelfilename, int flag, int texid = 0) { List<string> filenames = new List<string>(); if (flag == 1) { if (modelfilename.StartsWith("character", StringComparison.CurrentCultureIgnoreCase)) { DBCReader<ChrRaceRecord> reader = new DBCReader<ChrRaceRecord>("DBFilesClient\\ChrRaces.dbc"); int race_id = 1; //Default to human male int gender_id = 0; for (int i = 0; i < reader.recordCount; i++) { if (modelfilename.IndexOf(reader[i].clientFileString, 0, StringComparison.CurrentCultureIgnoreCase) != -1) { race_id = reader[i].ID; if (modelfilename.IndexOf("female", 0, StringComparison.CurrentCultureIgnoreCase) != -1) { gender_id = 1; } else { gender_id = 0; } break; } } DBCReader<CharSectionRecord> secreader = new DBCReader<CharSectionRecord>("DBFilesClient\\CharSections.dbc"); for (int i = 0; i < secreader.recordCount; i++) { if (secreader[i].TextureName_0 == "") { continue; //skip empty shit } int addhd = 0; if (modelfilename.IndexOf("_HD", 0, StringComparison.CurrentCultureIgnoreCase) != -1) { addhd = 5; } if (secreader[i].raceID == race_id && secreader[i].sexID == gender_id) { if (modelfilename.IndexOf("_HD", 0, StringComparison.CurrentCultureIgnoreCase) != -1) { if (secreader[i].baseSection == (0 + addhd) && texid == 1) { filenames.Add(secreader[i].TextureName_0); } } else { if (secreader[i].baseSection == (0 + addhd) && texid == 0) { filenames.Add(secreader[i].TextureName_0); } } } } Console.WriteLine("Detected model as race ID " + race_id + " and gender " + gender_id); Console.WriteLine("[NYI] Type 1 character texture lookups aren't implemented yet"); } else if (modelfilename.StartsWith("creature", StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine("RUNNING TYPE 1 DETECTION"); DBCReader<FileDataRecord> reader = new DBCReader<FileDataRecord>("DBFilesClient\\FileData.dbc"); string[] modelnamearr = modelfilename.Split('\\'); string modelonly = modelnamearr[modelnamearr.Count() - 1]; modelonly = Path.ChangeExtension(modelonly, ".M2"); for (int i = 0; i < reader.recordCount; i++) { if (reader[i].FileName == modelonly) { Console.WriteLine("Found ID in FileData.dbc: " + reader[i].ID); DBCReader<CreatureModelDataRecord> cmdreader = new DBCReader<CreatureModelDataRecord>("DBFilesClient\\CreatureModelData.dbc"); for (int cmdi = 0; cmdi < cmdreader.recordCount; cmdi++) { if (reader[i].ID == cmdreader[cmdi].fileDataID) { Console.WriteLine("Found Creature ID in CreatureModelData.dbc: " + cmdreader[cmdi].ID); DBCReader<CreatureDisplayInfoRecord> cdireader = new DBCReader<CreatureDisplayInfoRecord>("DBFilesClient\\CreatureDisplayInfo.dbc"); for (int cdii = 0; cdii < cdireader.recordCount; cdii++) { if (cdireader[cdii].modelID == cmdreader[cmdi].ID && cdireader[cdii].textureVariation_0 != null) { //filenames.Add(cdireader[cdii].textureVariation_0); filenames.Add(modelfilename.Replace(modelonly, cdireader[cdii].textureVariation_0 + ".blp")); } } } } } } } else if (modelfilename.StartsWith("item", StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine("[NYI] Type 1 item texture lookups aren't implemented yet"); } else { Console.WriteLine("[NYI] Type 1 texture lookups aren't implemented yet (model: " + modelfilename + ")"); } } else if (flag == 11) { DBCReader<FileDataRecord> reader = new DBCReader<FileDataRecord>("DBFilesClient\\FileData.dbc"); string[] modelnamearr = modelfilename.Split('\\'); string modelonly = modelnamearr[modelnamearr.Count() - 1]; modelonly = Path.ChangeExtension(modelonly, ".M2"); for (int i = 0; i < reader.recordCount; i++) { if (reader[i].FileName == modelonly) { Console.WriteLine("Found ID in FileData.dbc: " + reader[i].ID); DBCReader<CreatureModelDataRecord> cmdreader = new DBCReader<CreatureModelDataRecord>("DBFilesClient\\CreatureModelData.dbc"); for (int cmdi = 0; cmdi < cmdreader.recordCount; cmdi++) { if (reader[i].ID == cmdreader[cmdi].fileDataID) { Console.WriteLine("Found Creature ID in CreatureModelData.dbc: " + cmdreader[cmdi].ID); DBCReader<CreatureDisplayInfoRecord> cdireader = new DBCReader<CreatureDisplayInfoRecord>("DBFilesClient\\CreatureDisplayInfo.dbc"); for (int cdii = 0; cdii < cdireader.recordCount; cdii++) { if (cdireader[cdii].modelID == cmdreader[cmdi].ID && cdireader[cdii].textureVariation_0 != null) { filenames.Add(cdireader[cdii].textureVariation_0); } } } } } } } string[] ret = filenames.Distinct().ToArray(); return ret; }
private void MapsTab_Focused(object sender, RoutedEventArgs e) { if (mapsTabLoaded) { return; } var reader = new DBCReader<MapRecord>("DBFilesClient\\Map.dbc"); for(int i = 0; i < reader.recordCount; i++){ MapListBox.Items.Add(new KeyValuePair<int, string>(reader[i].ID, reader[i].Directory)); } MapListBox.DisplayMemberPath = "Value"; mapsTabLoaded = true; }
public void Compare(TextWriter writer) { var newFiles = new HashSet <string>(Directory.GetFiles(newDir, "*.dbc").Select((file) => new FileInfo(file).Name), StringComparer.InvariantCultureIgnoreCase); var oldFiles = new HashSet <string>(Directory.GetFiles(oldDir, "*.dbc").Select((file) => new FileInfo(file).Name), StringComparer.InvariantCultureIgnoreCase); var addedFiles = newFiles.Except(oldFiles); var removedFiles = oldFiles.Except(newFiles); var existingFiles = newFiles.Except(addedFiles); if (addedFiles.Count() > 0) { writer.WriteLine("{0} files have been added:", addedFiles.Count()); foreach (var file in addedFiles) { writer.WriteLine("\t" + new FileInfo(file).Name); var reader = new DBCReader(Path.Combine(newDir, file)); writer.WriteLine("\t\tColumn Count: " + reader.ColumnCount); writer.WriteLine("\t\tRow Count: " + reader.RecordCount); writer.WriteLine("\t\tHas Strings: " + reader.HasStrings); if (reader.IrregularColumnSize) { writer.WriteLine("\t\tColumn Size IRREGULAR!"); } } } if (removedFiles.Count() > 0) { writer.WriteLine("{0} files have been deprecated (not present anymore):", removedFiles.Count()); foreach (var file in addedFiles) { writer.WriteLine("\t" + new FileInfo(file).Name); } } writer.WriteLine(); writer.WriteLine("#######################################"); writer.WriteLine("Changes in files{0}:", maxTestAmount != int.MaxValue ? " - Testing with first " + maxTestAmount + " rows" : ""); writer.WriteLine(); foreach (var file in existingFiles) { var comparer = new DBCFileComparer(Path.Combine(oldDir, file), Path.Combine(newDir, file), maxTestAmount, null); if (comparer.NewReader.IrregularColumnSize) { writer.WriteLine("Skipping {0} (IRREGULAR Column Size)", file); } else if (comparer.NewReader.ColumnCount != comparer.OldReader.ColumnCount && (comparer.NewReader.ColumnCount < 2 || comparer.OldReader.ColumnCount < 2)) { writer.WriteLine("Skipping {0} (Only 1 column or less)", file); } else { comparer.Compare(writer); } } }
public static List <string> GenerateListfile() { List <string> files = new List <String>(); string line; // System.IO.StreamReader file = new System.IO.StreamReader(CASC.OpenFile("signaturefile")); if (CASC.FileExists("DBFilesClient\\FileData.dbc")) { DBCReader <FileDataRecord> filedatareader = new DBCReader <FileDataRecord>("DBFilesClient\\FileData.dbc"); for (int i = 0; i < filedatareader.recordCount; i++) { string filename = filedatareader[i].FilePath + filedatareader[i].FileName; if (filename.EndsWith(".wmo", StringComparison.OrdinalIgnoreCase) || filename.EndsWith(".m2", StringComparison.OrdinalIgnoreCase)) { files.Add(filename); } } } if (File.Exists("wow-live-listfile-seed.txt")) { var file = new StreamReader("wow-live-listfile-seed.txt"); while ((line = file.ReadLine()) != null) { if (line.EndsWith(".wmo", StringComparison.OrdinalIgnoreCase) || line.EndsWith(".m2", StringComparison.OrdinalIgnoreCase)) { files.Add(line); } } } List <string> unwantedExtensions = new List <String>(); for (int i = 0; i < 1024; i++) { unwantedExtensions.Add("_" + i.ToString().PadLeft(3, '0') + ".wmo"); unwantedExtensions.Add("_" + i.ToString().PadLeft(3, '0') + ".WMO"); } string[] unwanted = unwantedExtensions.ToArray(); List <string> retlist = new List <string>(); for (int i = 0; i < files.Count(); i++) { if (!files[i].StartsWith("alternate") && !files[i].StartsWith("Camera")) { if (!unwanted.Contains(files[i].Substring(files[i].Length - 8, 8))) { if (!files[i].Contains("LOD")) { retlist.Add(files[i]); } } } } return(retlist.Distinct(StringComparer.CurrentCultureIgnoreCase).ToList()); }
private void backgroundWorker1_DoWork(object sender, DoWorkEventArgs e) { var file = (string)e.Argument; try { var ext = Path.GetExtension(file).ToUpperInvariant(); if (ext == ".DBC") m_reader = new DBCReader(file); else if (ext == ".DB2") m_reader = new DB2Reader(file); else if (ext == ".ADB") m_reader = new ADBReader(file); else if (ext == ".WDB") m_reader = new WDBReader(file); else throw new InvalidDataException(String.Format("Unknown file type {0}", ext)); } catch (Exception ex) { ShowErrorMessageBox(ex.Message); e.Cancel = true; return; } m_fields = m_definition.GetElementsByTagName("field"); string[] types = new string[m_fields.Count]; for (var j = 0; j < m_fields.Count; ++j) types[j] = m_fields[j].Attributes["type"].Value; // hack for *.adb files (because they don't have FieldsCount) var notADB = !(m_reader is ADBReader); // hack for *.wdb files (because they don't have FieldsCount) var notWDB = !(m_reader is WDBReader); if (GetFieldsCount(m_fields) != m_reader.FieldsCount && notADB && notWDB) { var msg = String.Format(CultureInfo.InvariantCulture, "{0} has invalid definition!\nFields count mismatch: got {1}, expected {2}", Path.GetFileName(file), m_fields.Count, m_reader.FieldsCount); ShowErrorMessageBox(msg); e.Cancel = true; return; } m_dataTable = new DataTable(Path.GetFileName(file)); m_dataTable.Locale = CultureInfo.InvariantCulture; CreateColumns(); // Add columns CreateIndexes(); // Add indexes for (var i = 0; i < m_reader.RecordsCount; ++i) // Add rows { var dataRow = m_dataTable.NewRow(); #region Test //var bytes = m_reader.GetRowAsByteArray(i); //unsafe //{ // fixed (void* b = bytes) // { // IntPtr ptr = new IntPtr(b); // int offset = 0; // for (var j = 0; j < m_fields.Count; ++j) // Add cells // { // switch (types[j]) // { // case "long": // dataRow[j] = *(long*)(ptr + offset); // offset += 8; // break; // case "ulong": // dataRow[j] = *(ulong*)(ptr + offset); // offset += 8; // break; // case "int": // dataRow[j] = *(int*)(ptr + offset); // offset += 4; // break; // case "uint": // dataRow[j] = *(uint*)(ptr + offset); // offset += 4; // break; // case "short": // dataRow[j] = *(short*)(ptr + offset); // offset += 2; // break; // case "ushort": // dataRow[j] = *(ushort*)(ptr + offset); // offset += 2; // break; // case "sbyte": // dataRow[j] = *(sbyte*)(ptr + offset); // offset += 1; // break; // case "byte": // dataRow[j] = *(byte*)(ptr + offset); // offset += 1; // break; // case "float": // dataRow[j] = *(float*)(ptr + offset); // offset += 4; // break; // case "double": // dataRow[j] = *(double*)(ptr + offset); // offset += 8; // break; // case "string": // dataRow[j] = m_reader.StringTable[*(int*)(ptr + offset)]; // offset += 4; // break; // default: // throw new Exception(String.Format("Unknown field type {0}!", m_fields[j].Attributes["type"].Value)); // } // } // } //} #endregion var br = m_reader[i]; for (var j = 0; j < m_fields.Count; ++j) // Add cells { switch (types[j]) { case "long": dataRow[j] = br.ReadInt64(); break; case "ulong": dataRow[j] = br.ReadUInt64(); break; case "int": dataRow[j] = br.ReadInt32(); break; case "uint": dataRow[j] = br.ReadUInt32(); break; case "short": dataRow[j] = br.ReadInt16(); break; case "ushort": dataRow[j] = br.ReadUInt16(); break; case "sbyte": dataRow[j] = br.ReadSByte(); break; case "byte": dataRow[j] = br.ReadByte(); break; case "float": dataRow[j] = br.ReadSingle(); break; case "double": dataRow[j] = br.ReadDouble(); break; case "string": dataRow[j] = m_reader is WDBReader ? br.ReadStringNull() : m_reader.StringTable[br.ReadInt32()]; break; default: throw new ArgumentException(String.Format(CultureInfo.InvariantCulture, "Unknown field type {0}!", types[j])); } } m_dataTable.Rows.Add(dataRow); int percent = (int)((float)m_dataTable.Rows.Count / (float)m_reader.RecordsCount * 100.0f); (sender as BackgroundWorker).ReportProgress(percent); } if (dataGridView1.InvokeRequired) { SetDataViewDelegate d = new SetDataViewDelegate(SetDataSource); Invoke(d, new object[] { m_dataTable.DefaultView }); } else { SetDataSource(m_dataTable.DefaultView); } e.Result = file; }
private static void Main(string[] args) { string mapname = ""; string basedir = ConfigurationManager.AppSettings["basedir"]; bool buildmaps = Boolean.Parse(ConfigurationManager.AppSettings["buildmaps"]); bool buildWMOmaps = Boolean.Parse(ConfigurationManager.AppSettings["buildwmomaps"]); Console.WriteLine("Initializing CASC.."); if(basedir != String.Empty){ CASC.InitCasc(null, basedir); }else{ CASC.InitCasc(null, @"D:\Games\World of Warcraft Public Test", "wow_beta"); // Use beta for now } Console.WriteLine("CASC initialized!"); Console.WriteLine("Current patch: " + CASC.cascHandler.Config.BuildName); if (buildmaps == true) { DBCReader<MapRecord> reader = new DBCReader<MapRecord>("DBFilesClient\\Map.dbc"); for (int i = 0; i < reader.recordCount; i++) { //I used to check if WDT existed, but sometimes minimaps for maps without WDTs slip through the cracks mapname = reader[i].Directory; if (reader[i].expansionID < 6) { Console.WriteLine("Skipping map " + mapname + " WoD and below!"); continue; } var min_x = 64; var min_y = 64; var max_x = 0; var max_y = 0; for (int cur_x = 0; cur_x < 64; cur_x++) { for (int cur_y = 0; cur_y < 64; cur_y++) { if (CASC.FileExists("World\\Minimaps\\" + mapname + "\\map" + cur_x + "_" + cur_y + ".blp")) { if (cur_x > max_x) { max_x = cur_x; } if (cur_y > max_y) { max_y = cur_y; } if (cur_x < min_x) { min_x = cur_x; } if (cur_y < min_y) { min_y = cur_y; } } } } Console.WriteLine("[" + mapname + "] MIN: (" + min_x + " " + min_y + ") MAX: (" + max_x + " " + max_y + ")"); var res_x = (((max_x - min_x) * 256) + 256); var res_y = (((max_y - min_y) * 256) + 256); if (res_x < 0 || res_y < 0) { Console.WriteLine("[" + mapname + "] " + "Skipping map, has no minimap tiles"); continue; } Console.WriteLine("[" + mapname + "] " + "Creating new image of " + res_x + "x" + res_y); Bitmap bmp = new Bitmap(res_x, res_y); Graphics g = Graphics.FromImage(bmp); Font drawFont = new Font("Arial", 16); for (int cur_x = 0; cur_x < 64; cur_x++) { for (int cur_y = 0; cur_y < 64; cur_y++) { if (CASC.FileExists("World\\Minimaps\\" + mapname + "\\map" + cur_x + "_" + cur_y + ".blp")) { var blpreader = new BLPReader(); blpreader.LoadBLP("World\\Minimaps\\" + mapname + "\\map" + cur_x + "_" + cur_y + ".blp"); g.DrawImage(blpreader.bmp, (cur_x - min_x) * 256, (cur_y - min_y) * 256, new Rectangle(0, 0, 256, 256), GraphicsUnit.Pixel); } } } g.Dispose(); if (!Directory.Exists("done")) { Directory.CreateDirectory("done"); } bmp.Save("done/" + mapname + ".png"); // SUPER MINIMAP COMPILER TIME!!!!!!!!!!!!!!! var super_res_x = (((max_x - min_x) * 512) + 512); var super_res_y = (((max_y - min_y) * 512) + 512); if (super_res_x < 0 || super_res_y < 0) { Console.WriteLine("[SUPER " + mapname + "] " + "Skipping map, has no minimap tiles"); continue; } Console.WriteLine("[SUPER " + mapname + "] " + "Creating new image of " + super_res_x + "x" + super_res_y); Bitmap super_bmp = new Bitmap(super_res_x, super_res_y); Graphics super_g = Graphics.FromImage(super_bmp); for (int cur_x = 0; cur_x < 64; cur_x++) { for (int cur_y = 0; cur_y < 64; cur_y++) { if (CASC.FileExists("World\\Minimaps\\" + mapname + "\\map" + cur_x + "_" + cur_y + ".blp")) { var blpreader = new BLPReader(); blpreader.LoadBLP("World\\Minimaps\\" + mapname + "\\map" + cur_x + "_" + cur_y + ".blp"); super_g.DrawImage(blpreader.bmp, (cur_x - min_x) * 512, (cur_y - min_y) * 512, new Rectangle(0, 0, 512, 512), GraphicsUnit.Pixel); } } } super_g.Dispose(); if (!Directory.Exists("done")) { Directory.CreateDirectory("done"); } super_bmp.Save("done/SUPER_" + mapname + ".png"); } } if (buildWMOmaps == true) { //List<string> listfile = CASC.GenerateListfile(); var listfile = File.ReadAllLines(@"listfile.txt"); DBCReader<MapRecord> reader = new DBCReader<MapRecord>("DBFilesClient\\Map.dbc"); string[] unwantedExtensions = new string[513]; for (int i = 0; i < 512; i++) { unwantedExtensions[i] = "_" + i.ToString().PadLeft(3, '0') + ".wmo"; } unwantedExtensions[512] = "LOD1.wmo"; foreach (string s in listfile) { if (!unwantedExtensions.Contains(s.Substring(s.Length - 8, 8))) { if (!s.Contains("LOD") && s.EndsWith(".wmo", StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine(s); WMO wmocompiler = new WMO(); wmocompiler.Compile(s); } } } Console.ReadLine(); } }
private void ListfileWorker_DoWork(object sender, DoWorkEventArgs e) { listfileWorker.ReportProgress(0, "Loading listfile.."); List<string> linelist = new List<string>(); if (CASC.FileExists("dbfilesclient/filedatacomplete.dbc")) { var reader = new DBCReader<FileDataRecord>("dbfilesclient/filedatacomplete.dbc"); if (reader.recordCount > 0) { listfileWorker.ReportProgress(50, "Loading complete listfile.."); for (int i = 0; i < reader.recordCount; i++) { if (CASC.cascHandler.FileExists(reader[i].ID)) { linelist.Add(reader[i].FileName + reader[i].FilePath); } } } } if (linelist.Count() == 0) { // Fall back if (!File.Exists("listfile.txt")) { throw new Exception("Listfile not found. Unable to continue."); } listfileWorker.ReportProgress(50, "Loading listfile from disk.."); foreach(var line in File.ReadAllLines("listfile.txt")) { if (CASC.FileExists(line)) { linelist.Add(line); } } linelist.AddRange(File.ReadAllLines("listfile.txt")); } listfileWorker.ReportProgress(0, "Sorting listfile.."); linelist.Sort(); string[] lines = linelist.ToArray(); for (int i = 0; i < lines.Length; i++) { lines[i] = lines[i].ToLower(); } List<string> unwantedExtensions = new List<String>(); for (int u = 0; u < 512; u++) { unwantedExtensions.Add("_" + u.ToString().PadLeft(3, '0') + ".wmo"); } string[] unwanted = unwantedExtensions.ToArray(); for (int i = 0; i < lines.Count(); i++) { //if (showADT && lines[i].EndsWith(".adt")) //{ // if (!lines[i].EndsWith("obj0.adt") && !lines[i].EndsWith("obj1.adt") && !lines[i].EndsWith("tex0.adt") && !lines[i].EndsWith("tex1.adt") && !lines[i].EndsWith("_lod.adt")) // { // if (!files.Contains(lines[i])) { files.Add(lines[i]); } // } //} if (lines[i].EndsWith(".wmo")) { if (!unwanted.Contains(lines[i].Substring(lines[i].Length - 8, 8)) && !lines[i].EndsWith("lod.wmo")) { models.Add(lines[i]); } } if (lines[i].EndsWith(".m2")) { if (!lines[i].StartsWith("character") && !lines[i].StartsWith("alternate") && !lines[i].StartsWith("camera") && !lines[i].StartsWith("spells")) { models.Add(lines[i]); } } if (i % 100 == 0) { var progress = (i * 100) / lines.Count(); listfileWorker.ReportProgress(progress, "Filtering listfile.."); } } }
public static List<DBCMapEntry> GetMapEntries() { var wowRootDir = DBCTool.FindWowDir(null); if (!Directory.Exists(wowRootDir)) { log.Error("Could not find WoW-directory: \"{0}\"", wowRootDir); return null; } var DBCMapEntryReader = new DBCReader<DBCMapEntry, DBCMapConverter>( RealmServerConfiguration.GetDBCFile("Map.dbc")); return DBCMapEntryReader.EntryList; }
private static void Main(string[] args) { string mapname = ""; string basedir = ConfigurationManager.AppSettings["basedir"]; bool buildmaps = Boolean.Parse(ConfigurationManager.AppSettings["buildmaps"]); bool buildWMOmaps = Boolean.Parse(ConfigurationManager.AppSettings["buildwmomaps"]); Console.WriteLine("Initializing CASC.."); if (basedir != String.Empty) { CASC.InitCasc(null, basedir); } else { CASC.InitCasc(null, @"D:\World of Warcraft Beta", "wow_beta"); // Use beta for now } Console.WriteLine("CASC initialized!"); Console.WriteLine("Current patch: " + CASC.cascHandler.Config.BuildName); if (buildmaps == true) { DB2Reader <MapRecordLegion> reader = new DB2Reader <MapRecordLegion>("DBFilesClient\\Map.db2"); for (int i = 0; i < reader.recordCount; i++) { //I used to check if WDT existed, but sometimes minimaps for maps without WDTs slip through the cracks mapname = reader[i].Directory; // if (reader[i].expansionID < 6) { Console.WriteLine("Skipping map " + mapname + " WoD and below!"); continue; } var min_x = 64; var min_y = 64; var max_x = 0; var max_y = 0; for (int cur_x = 0; cur_x < 64; cur_x++) { for (int cur_y = 0; cur_y < 64; cur_y++) { if (CASC.FileExists("World\\Minimaps\\" + mapname + "\\map" + cur_x + "_" + cur_y + ".blp")) { if (cur_x > max_x) { max_x = cur_x; } if (cur_y > max_y) { max_y = cur_y; } if (cur_x < min_x) { min_x = cur_x; } if (cur_y < min_y) { min_y = cur_y; } } } } Console.WriteLine("[" + mapname + "] MIN: (" + min_x + " " + min_y + ") MAX: (" + max_x + " " + max_y + ")"); var res_x = (((max_x - min_x) * 256) + 256); var res_y = (((max_y - min_y) * 256) + 256); if (res_x < 0 || res_y < 0) { Console.WriteLine("[" + mapname + "] " + "Skipping map, has no minimap tiles"); continue; } Console.WriteLine("[" + mapname + "] " + "Creating new image of " + res_x + "x" + res_y); Bitmap bmp = new Bitmap(res_x, res_y); Graphics g = Graphics.FromImage(bmp); Font drawFont = new Font("Arial", 16); for (int cur_x = 0; cur_x < 64; cur_x++) { for (int cur_y = 0; cur_y < 64; cur_y++) { if (CASC.FileExists("World\\Minimaps\\" + mapname + "\\map" + cur_x + "_" + cur_y + ".blp")) { var blpreader = new BLPReader(); blpreader.LoadBLP("World\\Minimaps\\" + mapname + "\\map" + cur_x + "_" + cur_y + ".blp"); g.DrawImage(blpreader.bmp, (cur_x - min_x) * 256, (cur_y - min_y) * 256, new Rectangle(0, 0, 256, 256), GraphicsUnit.Pixel); } } } g.Dispose(); if (!Directory.Exists("done")) { Directory.CreateDirectory("done"); } bmp.Save("done/" + mapname + ".png"); // SUPER MINIMAP COMPILER TIME!!!!!!!!!!!!!!! /* * var super_res_x = (((max_x - min_x) * 512) + 512); * var super_res_y = (((max_y - min_y) * 512) + 512); * * if (super_res_x < 0 || super_res_y < 0) * { * Console.WriteLine("[SUPER " + mapname + "] " + "Skipping map, has no minimap tiles"); * continue; * } * * Console.WriteLine("[SUPER " + mapname + "] " + "Creating new image of " + super_res_x + "x" + super_res_y); * * Bitmap super_bmp = new Bitmap(super_res_x, super_res_y); * Graphics super_g = Graphics.FromImage(super_bmp); * * for (int cur_x = 0; cur_x < 64; cur_x++) * { * for (int cur_y = 0; cur_y < 64; cur_y++) * { * if (CASC.FileExists("World\\Minimaps\\" + mapname + "\\map" + cur_x + "_" + cur_y + ".blp")) * { * var blpreader = new BLPReader(); * blpreader.LoadBLP("World\\Minimaps\\" + mapname + "\\map" + cur_x + "_" + cur_y + ".blp"); * super_g.DrawImage(blpreader.bmp, (cur_x - min_x) * 512, (cur_y - min_y) * 512, new Rectangle(0, 0, 512, 512), GraphicsUnit.Pixel); * } * } * } * super_g.Dispose(); * if (!Directory.Exists("done")) { Directory.CreateDirectory("done"); } * super_bmp.Save("done/SUPER_" + mapname + ".png"); */ } } if (buildWMOmaps == true) { List <string> linelist = new List <string>(); if (CASC.FileExists("dbfilesclient/filedatacomplete.dbc")) { var dbcreader = new DBCReader <FileDataRecord>("dbfilesclient/filedatacomplete.dbc"); if (dbcreader.recordCount > 0) { for (int i = 0; i < dbcreader.recordCount; i++) { if (CASC.cascHandler.FileExists(dbcreader[i].ID)) { if (dbcreader[i].ID > 1023304) { linelist.Add(dbcreader[i].FileName + dbcreader[i].FilePath); } } } } } DBCReader <MapRecord> reader = new DBCReader <MapRecord>("DBFilesClient\\Map.dbc"); string[] unwantedExtensions = new string[513]; for (int i = 0; i < 512; i++) { unwantedExtensions[i] = "_" + i.ToString().PadLeft(3, '0') + ".wmo"; } unwantedExtensions[512] = "LOD1.wmo"; foreach (string s in linelist) { if (s.Length > 8 && !unwantedExtensions.Contains(s.Substring(s.Length - 8, 8))) { if (!s.Contains("LOD") && s.EndsWith(".wmo", StringComparison.CurrentCultureIgnoreCase)) { Console.WriteLine(s); WMO wmocompiler = new WMO(); wmocompiler.Compile(s); } } } Console.ReadLine(); } }
static void Main(string[] args) { Console.WriteLine("Initializing CASC.."); CASC.InitCasc(null, @"C:\World of Warcraft", "wow"); Console.WriteLine("CASC initialized!"); var dbcreader = new DBCReader <MapRecord>("DBFilesClient\\Map.dbc"); string mapfilter = "Draenor"; //string mapfilter = null; for (int mi = 0; mi < dbcreader.recordCount; mi++) { string mapname = dbcreader[mi].Directory; if (mapfilter != null) { if (mapname != mapfilter) { continue; } } Console.WriteLine("Creating image for map " + mapname + " (" + dbcreader[mi].Mapname_lang + ")"); if (File.Exists("done/" + mapname + ".png")) { continue; } float lowest = float.MaxValue; float highest = float.MinValue; float lowest_chunkpos = float.MaxValue; float highest_chunkpos = float.MinValue; var min_x = 64; var min_y = 64; var max_x = 0; var max_y = 0; Console.Write("Calculating heights.."); for (int x = 0; x < 63; x++) { for (int y = 0; y < 63; y++) { string filename = "World/Maps/" + mapname + "/" + mapname + "_" + y + "_" + x + ".adt"; if (CASC.FileExists(filename)) { if (x > max_x) { max_x = x; } if (y > max_y) { max_y = y; } if (x < min_x) { min_x = x; } if (y < min_y) { min_y = y; } ADTReader reader = new ADTReader(); reader.LoadADT(filename); for (var i = 0; i < 256; i++) { if (reader.adtfile.chunks[i].header.position.Z < lowest_chunkpos) { lowest_chunkpos = reader.adtfile.chunks[i].header.position.Z; } if (reader.adtfile.chunks[i].header.position.Z > highest_chunkpos) { highest_chunkpos = reader.adtfile.chunks[i].header.position.Z; } for (var j = 0; j < 145; ++j) { //Console.WriteLine(reader.adtfile.chunks[i].vertices.vertices[j]); if (reader.adtfile.chunks[i].vertices.vertices[j] < lowest) { lowest = reader.adtfile.chunks[i].vertices.vertices[j]; } if (reader.adtfile.chunks[i].vertices.vertices[j] > highest) { highest = reader.adtfile.chunks[i].vertices.vertices[j]; } } } } } } Console.Write(" ..done!\n"); Console.WriteLine("Highest: " + highest); Console.WriteLine("Lowest: " + lowest); Console.WriteLine("Highest chunkpos: " + highest_chunkpos); Console.WriteLine("Lowest chunkpos: " + lowest_chunkpos); if (lowest_chunkpos < 0) { highest = highest + (lowest * -1) + highest_chunkpos; lowest = (lowest * -1) + (lowest_chunkpos * -1); } else { highest = highest + (lowest * -1) + highest_chunkpos; lowest = (lowest * -1) + lowest_chunkpos; } Console.WriteLine("Highest post-flip: " + highest); Console.WriteLine("Lowest post-flip: " + lowest); Console.WriteLine("Highest chunkpos post-flip: " + highest_chunkpos); Console.WriteLine("Lowest chunkpos post-flip: " + lowest_chunkpos); Console.Write("Creating images.."); for (int x = 0; x < 63; x++) { for (int y = 0; y < 63; y++) { string filename = "World/Maps/" + mapname + "/" + mapname + "_" + y + "_" + x + ".adt"; if (CASC.FileExists(filename)) { ADTReader reader = new ADTReader(); reader.LoadADT(filename); var fullmap = new Bitmap(144, 144); for (var a = 0; a < 256; a++) { //Console.WriteLine(reader.adtfile.chunks[a].header.indexX + " x " + reader.adtfile.chunks[a].header.indexY); int img_x = 0; int img_y = 0; int counter = 0; for (var i = 0; i < 17; ++i) { for (var j = 0; j < (((i % 2) != 0) ? 8 : 9); ++j) { if (i % 2 == 0) { //only render these //Console.Write("(" + j +" " + i + ")" + counter + " |" ); //int greyness = (int)Math.Round(((reader.adtfile.chunks[a].vertices.vertices[counter] + reader.adtfile.chunks[a].header.position.Z) + lowest) / highest * 255); // if (greyness > 255) { greyness = 255; } //those edge cases where rounding just makes it go over 255 if (reader.adtfile.chunks[a].vertexShading.red != null && reader.adtfile.chunks[a].vertexShading.red[counter] != 127) { fullmap.SetPixel(img_x + (int)(reader.adtfile.chunks[a].header.indexX * 9), img_y + (int)(reader.adtfile.chunks[a].header.indexY * 9), Color.FromArgb(reader.adtfile.chunks[a].vertexShading.blue[counter], reader.adtfile.chunks[a].vertexShading.green[counter], reader.adtfile.chunks[a].vertexShading.red[counter]) ); } else { int greyness = (int)Math.Round(((reader.adtfile.chunks[a].vertices.vertices[counter] + reader.adtfile.chunks[a].header.position.Z) + lowest) / highest * 255); if (greyness > 255 || greyness < 0) { greyness = 255; } fullmap.SetPixel(img_x + (int)(reader.adtfile.chunks[a].header.indexX * 9), img_y + (int)(reader.adtfile.chunks[a].header.indexY * 9), Color.FromArgb(greyness, greyness, greyness)); } img_x++; } counter++; } if (i % 2 == 0) { img_y++; img_x = 0; //Console.Write("\n"); } } } fullmap.Save("Z:/adttest/" + mapname + "_" + y + "_" + x + ".png"); } } } Console.Write(" ..done!\n"); //Time to compile the full image var res_x = (((max_y - min_y) * 144) + 144); var res_y = (((max_x - min_x) * 144) + 144); if (res_x > 0 && res_y > 0) { Console.WriteLine("[" + mapname + "] " + "Creating new image of " + res_x + "x" + res_y); Bitmap bmp = new Bitmap(res_x, res_y); Graphics g = Graphics.FromImage(bmp); for (int cur_x = 0; cur_x < 64; cur_x++) { for (int cur_y = 0; cur_y < 64; cur_y++) { if (File.Exists("Z:/adttest/" + mapname + "_" + cur_x + "_" + cur_y + ".png")) { var bmpreader = new Bitmap("Z:/adttest/" + mapname + "_" + cur_x + "_" + cur_y + ".png"); g.DrawImage(bmpreader, (cur_x - min_x) * 144, (cur_y - min_y) * 144, new Rectangle(0, 0, 144, 144), GraphicsUnit.Pixel); bmpreader.Dispose(); File.Delete("Z:/adttest/" + mapname + "_" + cur_x + "_" + cur_y + ".png"); } } } g.Dispose(); if (!Directory.Exists("done")) { Directory.CreateDirectory("done"); } bmp.Save("done/" + mapname + ".png"); } } }
private void worker_DoWork(object sender, DoWorkEventArgs e) { worker.ReportProgress(0, "Loading listfile.."); List <string> linelist = new List <string>(); if (CASC.FileExists("dbfilesclient/filedatacomplete.dbc")) { var reader = new DBCReader <FileDataRecord>("dbfilesclient/filedatacomplete.dbc"); if (reader.recordCount > 0) { worker.ReportProgress(50, "Loading complete listfile.."); for (int i = 0; i < reader.recordCount; i++) { if (CASC.cascHandler.FileExists(reader[i].ID)) { linelist.Add(reader[i].FileName + reader[i].FilePath); } } } } if (linelist.Count() == 0) { // Fall back if (!File.Exists("listfile.txt")) { throw new Exception("Listfile not found. Unable to continue."); } worker.ReportProgress(50, "Loading listfile from disk.."); foreach (var line in File.ReadAllLines("listfile.txt")) { if (CASC.FileExists(line)) { linelist.Add(line); } } } worker.ReportProgress(0, "Sorting listfile.."); linelist.Sort(); string[] lines = linelist.ToArray(); for (int i = 0; i < lines.Length; i++) { lines[i] = lines[i].ToLower(); } List <string> unwantedExtensions = new List <String>(); for (int u = 0; u < 512; u++) { unwantedExtensions.Add("_" + u.ToString().PadLeft(3, '0') + ".wmo"); } string[] unwanted = unwantedExtensions.ToArray(); for (int i = 0; i < lines.Count(); i++) { if (showADT && lines[i].EndsWith(".adt")) { if (!lines[i].EndsWith("obj0.adt") && !lines[i].EndsWith("obj1.adt") && !lines[i].EndsWith("tex0.adt") && !lines[i].EndsWith("tex1.adt") && !lines[i].EndsWith("_lod.adt")) { if (!files.Contains(lines[i])) { files.Add(lines[i]); } } } if (showWMO && lines[i].EndsWith(".wmo")) { if (!unwanted.Contains(lines[i].Substring(lines[i].Length - 8, 8)) && !lines[i].EndsWith("lod.wmo")) { if (!files.Contains(lines[i])) { files.Add(lines[i]); } } } if (showM2 && lines[i].EndsWith(".m2")) { if (!lines[i].StartsWith("alternate") && !lines[i].StartsWith("camera") && !lines[i].StartsWith("spells")) { if (!files.Contains(lines[i])) { files.Add(lines[i]); } } } if (i % 100 == 0) { var progress = (i * 100) / lines.Count(); worker.ReportProgress(progress, "Filtering listfile.."); } } }