public static string GetParsedForm(string rawString, Spell_DBC_Record record, MainWindow mainWindow) { // If a token starts with $ and a number, it references that as a spell id Spell_DBC_Record otherRecord; var match = Regex.Match(rawString, "\\$\\d+"); if (match.Success) { uint otherId; if (!uint.TryParse(match.Value.Substring(1), out otherId)) { Console.WriteLine("Failed to parse other spell id: " + rawString); return(rawString); } otherRecord = SpellDBC.GetRecordById(otherId, mainWindow); int offset = match.Index + match.Value.Length; bool hasPrefix = rawString.StartsWith("$"); rawString = rawString.Substring(match.Index + match.Value.Length); if (hasPrefix) { rawString = "$" + rawString; } foreach (TOKEN_TO_PARSER parser in TOKEN_PARSERS) { rawString = parser.tokenFunc(rawString, otherRecord, mainWindow); } return(rawString); } foreach (TOKEN_TO_PARSER parser in TOKEN_PARSERS) { rawString = parser.tokenFunc(rawString, record, mainWindow); } return(rawString); }
public static DataRow GetRecordById(uint spellId, MainWindow mainWindow) { return(SpellDBC.GetRecordById(spellId, mainWindow)); }
public static Spell_DBC_Record GetRecordById(UInt32 spellId, MainWindow mainWindow) { return(SpellDBC.GetRecordById(spellId, mainWindow)); }
public static string GetParsedForm(string rawString, DataRow row, MainWindow mainWindow) { Spell_DBC_Record record = SpellDBC.GetRowToRecord(row); return(GetParsedForm(rawString, record, mainWindow)); }
static void Main(string[] args) { var path = "D:/WoW Resources/2019_TrinityCore/DBC Temp/SkillLineAbility.dbc"; var spellPath = "D:/WoW Resources/2019_TrinityCore/DBC Temp/Spell.dbc"; var raceClassPath = "D:/WoW Resources/2019_TrinityCore/DBC Temp/SkillRaceClassInfo.dbc"; var exportPath = "D:/WoW Resources/2019_TrinityCore/DBC Temp/Export/SkillLineAbility.dbc"; var exportRaceClassPath = "D:/WoW Resources/2019_TrinityCore/DBC Temp/Export/SkillRaceClassInfo.dbc"; bool useLogFile = true; var logFilePath = "D:/WoW Resources/2019_TrinityCore/DBC Temp/output.txt"; Console.WriteLine($"Processing {path}..."); DBC = new SkillLineAbilityDBC(path, exportPath); Console.WriteLine($"Processing {raceClassPath}..."); RaceClassDBC = new SkillRaceClassInfoDBC(raceClassPath, exportRaceClassPath); Console.WriteLine($"Processing {spellPath}..."); SpellDBC = new SpellDBC(spellPath); Console.WriteLine("Done loading DBC's."); Console.WriteLine("Read entries (R) for classmask or write new data (W)?"); int keyread = AcceptInput(); if (keyread == -1) { return; } if (keyread == 0) { Console.WriteLine("\nInput classmask to read:"); uint classMask = ReadClassMask(); Console.WriteLine("Program output redirected to output.txt"); var ostrm = new FileStream(logFilePath, FileMode.Create, FileAccess.Write); var writer = new StreamWriter(ostrm); Console.SetOut(writer); OutputClassMaskData(classMask); writer.Dispose(); ostrm.Dispose(); } else { Console.WriteLine("\nInput classmask to copy:"); uint readMask = ReadClassMask(); Console.WriteLine("Input classmask to write as instead:"); uint writeMask = ReadClassMask(); Console.WriteLine("Program output redirected to output.txt"); var ostrm = new FileStream(logFilePath, FileMode.OpenOrCreate, FileAccess.Write); var writer = new StreamWriter(ostrm); Console.SetOut(writer); Console.WriteLine($"Reading mask {readMask} and writing a copy as mask {writeMask}..."); Console.WriteLine("Processing SkillLineAbility.dbc..."); var records = DBC.GetAllRecords().Where(record => (((uint)record["ClassMask"]) & readMask) != 0); uint id = DBC.GetAllRecords().Max(record => (uint)record["Id"]); Console.WriteLine($"Read {records.Count()} records. Writing as new class mask {writeMask} starting with id {id}..."); var list = records.ToList(); foreach (var entry in list) { entry["Id"] = ++id; entry["ClassMask"] = writeMask; } DBC.AddNewRecords(list); DBC.SaveChanges(); Console.WriteLine("Done. New max records: " + DBC.GetAllRecords().Max(record => (uint)record["Id"])); Console.WriteLine("Processing SkillRaceClassInfo..."); records = RaceClassDBC.GetAllRecords().Where(record => (((uint)record["classMask"]) & readMask) != 0); id = DBC.GetAllRecords().Max(record => (uint)record["Id"]); Console.WriteLine($"Read {records.Count()} records. Writing as new class mask {writeMask} starting with id {id}..."); var newList = new List <Dictionary <string, object> >(records.Count()); list = records.ToList(); foreach (var entry in list) { var size = entry.Count(); if (size == 0) { continue; } var newRecord = new Dictionary <string, object>(size); using (var enumer = entry.GetEnumerator()) { while (enumer.MoveNext()) { var pair = enumer.Current; newRecord.Add(pair.Key, pair.Value); } newRecord["Id"] = ++id; newRecord["classMask"] = writeMask; } newList.Add(newRecord); } RaceClassDBC.AddNewRecords(newList); RaceClassDBC.SaveChanges(); Console.WriteLine("Done. New max records: " + RaceClassDBC.GetAllRecords().Max(record => (uint)record["Id"])); writer.Dispose(); ostrm.Dispose(); } if (!useLogFile) { Console.WriteLine("Done, press any key to exit..."); Console.ReadKey(); } }