public static void DeleteFromGrf(string GrfName, string Filename) { RoGrfFile cachedGrf = GrfFromCache(GrfName, ""); string[] searchParts = Filename.Split(':'); int maxDeleteCount = cachedGrf.Files.Count; Filename = "data/" + searchParts[0].Trim(); if (searchParts.Length > 1) { if (int.TryParse(searchParts[1], out maxDeleteCount) == false) { maxDeleteCount = cachedGrf.Files.Count; } } int deleted = 0; string fIndex = null; while ((fIndex = cachedGrf.ContainsFilepart(Filename)) != null) { cachedGrf.DeleteFile(fIndex); if (maxDeleteCount > 0 && ++deleted >= maxDeleteCount) { break; } } }
private static RoGrfFile LoadLocalGrf(string filename) { var filepath = Path.Combine("data", filename); var grf = new RoGrfFile(filepath); return(grf); }
public static void MergeGrf(string GrfName, string Filepath) { RoGrfFile cachedGrf = GrfFromCache(GrfName, ""); RoGrfFile tmpGrf = new RoGrfFile(Filepath); foreach (var grfFile in tmpGrf.Files.Values) { tmpGrf.CacheFileData(grfFile); cachedGrf.AddFile(grfFile); } tmpGrf.Flush(); // close it! }
private void mWorker_DoWork(object sender, DoWorkEventArgs e) { string mobdbPath = @"C:\Users\Jonathan\Desktop\eAthena\db\mob_db.txt"; string skilldbPath = @"C:\Users\Jonathan\Desktop\eAthena\db\skill_db.txt"; string grfPath = @"C:\Program Files\Gravity\Ragnarok_Europe\data.grf"; RoGrfFile grf = new RoGrfFile(grfPath); // Load Mobs mMainForm.MobDB = new MobDBMobList(); mMainForm.MobDB.ReportUpdate += new ReportUpdateHandler(Database_ReportUpdate); if (mMainForm.MobDB.LoadMobList() == false) { if (mMainForm.MobDB.ParseDB(mobdbPath, grf) == false) { MessageBox.Show("Failed to fetch Moblist from file!\nUnable to start without Moblist..", "Failed to fetch Moblist", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); return; } if (mMainForm.MobDB.ExportMobList() == false) { MessageBox.Show("Failed to export Moblist from internal array!\nThe Moblist will be recreated on next startup", "Failed to export Moblist", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } // Load Skills.. mMainForm.SkillDB = new SkillDBSkillList(); mMainForm.SkillDB.ReportUpdate += new ReportUpdateHandler(Database_ReportUpdate); if (mMainForm.SkillDB.LoadSkillList() == false) { if (mMainForm.SkillDB.ParseDB(skilldbPath, grf) == false) { MessageBox.Show("Failed to fetch Skilllist from file!\nUnable to start without Skilllist..", "Failed to fetch Skilllist", MessageBoxButtons.OK, MessageBoxIcon.Error); Close(); return; } if (mMainForm.SkillDB.ExportSkillList() == false) { MessageBox.Show("Failed to export Skilllist from internal array!\nThe Skilllist will be recreated on next startup", "Failed to export Skilllist", MessageBoxButtons.OK, MessageBoxIcon.Warning); } } grf = null; }
public FrmExtract(RoGrfFile grf, string rootDir, ArrayList toExtract) { InitializeComponent(); mWin7Taskbar = TaskbarManager.Instance; mGrfFile = grf; mRootDir = rootDir; mToExtract = toExtract; mWorker = new BackgroundWorker(); mWorker.WorkerReportsProgress = true; mWorker.WorkerSupportsCancellation = true; mWorker.RunWorkerCompleted += new RunWorkerCompletedEventHandler(mWorker_RunWorkerCompleted); mWorker.ProgressChanged += new ProgressChangedEventHandler(mWorker_ProgressChanged); mWorker.DoWork += new DoWorkEventHandler(mWorker_DoWork); }
public bool ParseDB(string skilldbPath, RoGrfFile grf) { Clear(); mSkillsTemp.Clear(); // need 2 files.. // - eAthena's skill_db.txt for delay & usage // - GRF's skilldisplaynametable.txt RoGrfFileItem itemSkillNameTable = grf.GetFileByName("data/skillnametable.txt"); if (itemSkillNameTable == null) { return(false); } byte[] skillNameTableBuf = grf.GetFileData(itemSkillNameTable, true); string skillNameTableString = Encoding.Default.GetString(skillNameTableBuf); string[] skillNameTableLines = skillNameTableString.Split(new string[] { Environment.NewLine }, StringSplitOptions.None); // cleanup mem skillNameTableBuf = null; itemSkillNameTable = null; skillNameTableString = null; if (skillNameTableLines == null || skillNameTableLines.Length == 0 || ParseSkillNameTable(skillNameTableLines) == false) { return(false); } if (ParseSkillDB(skilldbPath, grf) == false) { return(false); } // we got 2 lists.. merge them if (MergeDBs() == false) { return(false); } return(true); }
public void Parse(RoGrfFile grf) { Clear(); RoGrfFileItem item = grf.GetFileByName("data/idnum2itemresnametable.txt"); if (item != null) { Parse(grf.GetFileData(item, true), true); // we need the ID to fetch korea name.. so this is the right place RoGrfFileItem itemDisplay = grf.GetFileByName("data/idnum2itemdisplaynametable.txt"); if (itemDisplay != null) { Parse(grf.GetFileData(itemDisplay, true), false); } } }
public static bool ReadVersion0X200() { bool testResult; RoGrfFile grf = null; try { grf = LoadLocalGrf("talonro-0x200.grf"); testResult = true; } catch { testResult = false; } finally { if (grf != null) { grf.Dispose(); } } return(testResult); }
public static bool ReadBigVersion0X200() { bool testResult; RoGrfFile grf = null; try { grf = new RoGrfFile(@"C:\Games\TalonRO\sdata.grf"); testResult = true; } catch { testResult = false; } finally { if (grf != null) { grf.Dispose(); } } return(testResult); }
private void mWorker_DoWork(object sender, DoWorkEventArgs e) { string filepath = e.Argument.ToString(); string extension = Path.GetExtension(filepath).ToLower(); // GRF? only check filetable if (extension == ".grf" || extension == ".gpf") { RoGrfFile grf = new RoGrfFile(); grf.ReadGrf(filepath, false); // skip files! byte[] buf = grf.FiletableUncompressed; Adler32.Build(buf); // cleanup asap buf = null; grf = null; } else { // other file? check full path Adler32.Build(filepath); } }
public bool ParseDB(string mobdbPath, RoGrfFile grf) { if (File.Exists(mobdbPath) == false) { return(false); } string[] lines = File.ReadAllLines(mobdbPath); for (int i = 0; i < lines.Length; i++) { string line = lines[i].Trim(); if (line.Length == 0 || line.StartsWith("//") == true) { continue; } // ID,Sprite_Name,kROName,iROName,LV,HP,SP,EXP,JEXP,Range1,ATK1,ATK2,DEF,MDEF,STR,AGI,VIT,INT,DEX,LUK,Range2,Range3,Scale,Race,Element,Mode,Speed,aDelay,aMotion,dMotion,MEXP,ExpPer,MVP1id,MVP1per,MVP2id,MVP2per,MVP3id,MVP3per,Drop1id,Drop1per,Drop2id,Drop2per,Drop3id,Drop3per,Drop4id,Drop4per,Drop5id,Drop5per,Drop6id,Drop6per,Drop7id,Drop7per,Drop8id,Drop8per,Drop9id,Drop9per,DropCardid,DropCardper string[] parts = line.Split(new char[] { ',' }, StringSplitOptions.None); if (parts.Length != 58) { continue; } MobDBMob mob = new MobDBMob(); mob.ID = int.Parse(parts[0]); mob.Sprite_Name = parts[1].Trim(); mob.kROName = parts[2].Trim(); mob.iROName = parts[3].Trim(); mob.LV = int.Parse(parts[4]); mob.HP = int.Parse(parts[5]); mob.SP = int.Parse(parts[6]); mob.EXP = int.Parse(parts[7]); mob.JEXP = int.Parse(parts[8]); mob.Range1 = int.Parse(parts[9]); mob.ATK1 = int.Parse(parts[10]); mob.ATK2 = int.Parse(parts[11]); mob.DEF = int.Parse(parts[12]); mob.MDEF = int.Parse(parts[13]); mob.STR = int.Parse(parts[14]); mob.AGI = int.Parse(parts[15]); mob.VIT = int.Parse(parts[16]); mob.INT = int.Parse(parts[17]); mob.DEX = int.Parse(parts[18]); mob.LUK = int.Parse(parts[19]); mob.Range2 = int.Parse(parts[20]); mob.Range3 = int.Parse(parts[21]); mob.Scale = (EScale)int.Parse(parts[22]); mob.Race = (ERace)int.Parse(parts[23]); mob.Element = (EElement)(int.Parse(parts[24]) % 10); mob.ElementLevel = (int.Parse(parts[24]) / 20); mob.Mode = ParsePossibleHex(parts[25]); mob.Speed = int.Parse(parts[26]); mob.aDelay = int.Parse(parts[27]); mob.aMotion = int.Parse(parts[28]); mob.dMotion = int.Parse(parts[29]); mob.MEXP = int.Parse(parts[30]); mob.MExpPer = int.Parse(parts[31]); for (int c = 32; c <= 37; c += 2) { int mvpID = int.Parse(parts[c]); int mvpChance = int.Parse(parts[c + 1]); if (mvpID > 0 && mvpChance > 0) { mob.DropsMvp.Add(new MobDBMobDrop(mvpID, mvpChance)); } } for (int c = 38; c <= 56; c += 2) { int dropID = int.Parse(parts[c]); int dropChance = int.Parse(parts[c + 1]); if (dropID > 0 && dropChance > 0) { mob.Drops.Add(new MobDBMobDrop(dropID, dropChance)); } } if (mob.ImageExists == false) { // Load Image.. // We try to get the sprite name based on eAthena's Sprite_Name field.. RoGrfFileItem grfItem = grf.GetFileByName("data/sprite/¸ó½ºÅÍ/" + mob.Sprite_Name.ToLower() + ".spr"); if (grfItem != null) { grf.CacheFileData(grfItem, true); mob.ExportImage(grfItem); } else { System.Diagnostics.Debug.WriteLine("Mob sprite not found: " + mob.ToString()); } } ReportUpdate("[Mob] " + mob.ToString()); Add(mob); } return(true); }
private bool ParseSkillDB(string skilldbPath, RoGrfFile grf) { ReportUpdate("skill_db.txt"); if (File.Exists(skilldbPath) == false) { return(false); } string[] lines = File.ReadAllLines(skilldbPath); for (int i = 0; i < lines.Length; i++) { string line = lines[i].Trim(); if (line.Length == 0 || line.StartsWith("//") == true) { continue; } string[] parts = line.Split(new char[] { ',' }, StringSplitOptions.None); if (parts.Length != 17) { continue; } //id,range,hit,inf,element,nk,splash,max,list_num,castcancel,cast_defence_rate,inf2,maxcount,skill_type,blow_count,name,description /* * 00: id * range * hit * inf * 04: element * nk * splash * max * list_num * castcancel * cast_defence_rate * inf2 * maxcount * skill_type * blow_count * 15: name * 16: description */ int id = int.Parse(parts[0].Trim()); string grvName = parts[15].Trim(); string eaName = parts[16].Trim(); // Element may be splitted by level // ele_on_lv_1:ele_on_lv_2: .. // in this case, choose first element EElement eaElement; if (parts[4].Contains(':') == true) { string[] eleParts = parts[4].Split(':'); eaElement = (EElement)int.Parse(eleParts[0].Trim()); } else { eaElement = (EElement)int.Parse(parts[4].Trim()); } if (mSkillsTemp.ContainsKey(grvName) == false) { // mh.. mSkillsTemp.Remove(grvName); System.Diagnostics.Debug.WriteLine("Skill not found in skill_db.txt: " + grvName); continue; } // Skip NPC, Item, Cash, All Skills.. if (grvName.StartsWith("NPC_") == true || grvName.StartsWith("ITEM_") == true || grvName.StartsWith("CASH_") == true || grvName.StartsWith("ALL_") == true || grvName.StartsWith("MER_") == true) { mSkillsTemp.Remove(grvName); continue; } if (id >= MAX_SKILL_ID) { mSkillsTemp.Remove(grvName); continue; } mSkillsTemp[grvName].ID = id; mSkillsTemp[grvName].Element = eaElement; mSkillsTemp[grvName].NameEathena = eaName; ReportUpdate("[Skill] " + mSkillsTemp[grvName].ToString()); if (mSkillsTemp[grvName].ImageExists == false) { // Load Image.. // We try to get the sprite name based on eAthena's Sprite_Name field.. RoGrfFileItem grfItem = grf.GetFileByName("data/texture/À¯ÀúÀÎÅÍÆäÀ̽º/item/" + grvName.ToLower() + ".bmp"); if (grfItem != null) { grf.CacheFileData(grfItem, true); mSkillsTemp[grvName].ExportImage(grfItem); } else { Debug.WriteLine("Skill image not found: " + mSkillsTemp[grvName].ToString()); } } } return(true); }