예제 #1
0
		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!
		}
예제 #2
0
        public void LoadFromFile(RoGrfFile grf, string filepath)
        {
            var info = new FileInfo(filepath);

            Index              = grf.Files.Count;
            Filepath           = Tools.GetGrfPath(filepath);
            Flags              = 3;
            Cycle              = -1;
            LengthUnCompressed = (uint)info.Length;
            State              = ERoGrfFileItemState.Added;
            NewFilepath        = filepath;
            // TODO: load new items into memory?
        }
예제 #3
0
		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);
				}
			}
		}
예제 #4
0
파일: Grf.cs 프로젝트: GodLesZ/svn-dump
		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;
		}
예제 #5
0
		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);
		}
예제 #6
0
        /// <summary>
        /// Writes the binary data and file properties to te streams.
        /// </summary>
        /// <param name="grf"></param>
        /// <param name="writer"></param>
        /// <param name="tableWriter"></param>
        internal void WriteToStream(RoGrfFile grf, BinaryWriter writer, BinaryWriter tableWriter)
        {
            // Skip deleted files
            if (IsDeleted)
            {
                return;
            }

            // Write binary data
            WriteToBinaryTable(grf, writer);

            // Write file properties
            WriteToFileTable(tableWriter);

            // Its saved, so remove updated and new flags
            State &= ~(ERoGrfFileItemState.Added | ERoGrfFileItemState.Updated);
        }
예제 #7
0
파일: frmMain.cs 프로젝트: GodLesZ/svn-dump
		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);
			}
		}
예제 #8
0
		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;
		}
예제 #9
0
파일: Grf.cs 프로젝트: GodLesZ/svn-dump
		private RoGrfFile LoadGrf(string filename) {
			var filepath = Path.Combine("data", filename);
			var grf = new RoGrfFile(filepath);
			return grf;
		}
예제 #10
0
		/// <summary>
		/// Writes the binary data to the stream.
		/// </summary>
		/// <param name="grf"></param>
		/// <param name="writer"></param>
		internal void WriteToBinaryTable(RoGrfFile grf, BinaryWriter writer) {
			// Skip deleted files
			if (IsDeleted) {
				return;
			}

			byte[] buf;

			// Update new offset
			DataOffset = (uint)writer.BaseStream.Position;

			// Either new or changed?
			if (IsUpdated == false && IsAdded == false) {
				// Auto-convert to 0x200 compression (deflate)
				if (grf.Version != 0x200) {
					// #1: Decompress buf and update length
					buf = grf.GetFileData(NameHash, true);
					LengthUnCompressed = (uint)buf.Length;
					// #2: Compress and update length
					buf = Deflate.Compress(buf, true);
					LengthCompressed = (uint)buf.Length;
					LengthCompressedAlign = (uint)buf.Length;
				} else {
					// Get compressed data
					buf = grf.GetFileData(NameHash, false);
				}
			} else {
				// Added or updated files, load data from origin filepath
				if (File.Exists(NewFilepath) == false) {
					throw new Exception("WriteItems(): File of new or updated item not found: " + NewFilepath);
				}

				buf = File.ReadAllBytes(NewFilepath);
				LengthUnCompressed = (uint)buf.Length;
				buf = Deflate.Compress(buf, true);
				LengthCompressed = LengthCompressedAlign = (uint)buf.Length;
			}

			try {
				// Check if the buf is compressed
				if (buf.Length != LengthCompressed && buf.Length != LengthCompressedAlign) {
					// The buf has to be compressed, so decompress it
					byte[] bufUncompressed = Deflate.Decompress(buf);
					// Update length, if decompression seems to be correct
					if (bufUncompressed.Length == 0 || bufUncompressed.Length != LengthUnCompressed) {
						// Narf, corrupt file or something like that
						// Just write it..
						//throw new Exception("WriteItems(): Item " + Filepath + ", DataLen missmatch");
					} else {
						// Decompression was succesfull, so update size
						LengthCompressed = (uint)Deflate.GetCompressedLength(bufUncompressed);
					}
				}

				// Seems like a valid buf, write it
				writer.Write(buf);
			} catch (Exception e) {
				System.Diagnostics.Debug.WriteLine(e);
			}
		}
예제 #11
0
		/// <summary>
		/// Writes the binary data and file properties to te streams.
		/// </summary>
		/// <param name="grf"></param>
		/// <param name="writer"></param>
		/// <param name="tableWriter"></param>
		internal void WriteToStream(RoGrfFile grf, BinaryWriter writer, BinaryWriter tableWriter) {
			// Skip deleted files
			if (IsDeleted) {
				return;
			}

			// Write binary data
			WriteToBinaryTable(grf, writer);

			// Write file properties
			WriteToFileTable(tableWriter);

			// Its saved, so remove updated and new flags
			State &= ~(ERoGrfFileItemState.Added | ERoGrfFileItemState.Updated);
		}
예제 #12
0
		public void LoadFromFile(RoGrfFile grf, string filepath) {
			var info = new FileInfo(filepath);
			Index = grf.Files.Count;
			Filepath = Tools.GetGrfPath(filepath);
			Flags = 3;
			Cycle = -1;
			LengthUnCompressed = (uint)info.Length;
			State = ERoGrfFileItemState.Added;
			NewFilepath = filepath;
			// TODO: load new items into memory?
		}
예제 #13
0
        /// <summary>
        /// Writes the binary data to the stream.
        /// </summary>
        /// <param name="grf"></param>
        /// <param name="writer"></param>
        internal void WriteToBinaryTable(RoGrfFile grf, BinaryWriter writer)
        {
            // Skip deleted files
            if (IsDeleted)
            {
                return;
            }

            byte[] buf;

            // Update new offset
            DataOffset = (uint)writer.BaseStream.Position;

            // Either new or changed?
            if (IsUpdated == false && IsAdded == false)
            {
                // Auto-convert to 0x200 compression (deflate)
                if (grf.Version != 0x200)
                {
                    // #1: Decompress buf and update length
                    buf = grf.GetFileData(NameHash, true);
                    LengthUnCompressed = (uint)buf.Length;
                    // #2: Compress and update length
                    buf = Deflate.Compress(buf, true);
                    LengthCompressed      = (uint)buf.Length;
                    LengthCompressedAlign = (uint)buf.Length;
                }
                else
                {
                    // Get compressed data
                    buf = grf.GetFileData(NameHash, false);
                }
            }
            else
            {
                // Added or updated files, load data from origin filepath
                if (File.Exists(NewFilepath) == false)
                {
                    throw new Exception("WriteItems(): File of new or updated item not found: " + NewFilepath);
                }

                buf = File.ReadAllBytes(NewFilepath);
                LengthUnCompressed = (uint)buf.Length;
                buf = Deflate.Compress(buf, true);
                LengthCompressed = LengthCompressedAlign = (uint)buf.Length;
            }

            try {
                // Check if the buf is compressed
                if (buf.Length != LengthCompressed && buf.Length != LengthCompressedAlign)
                {
                    // The buf has to be compressed, so decompress it
                    byte[] bufUncompressed = Deflate.Decompress(buf);
                    // Update length, if decompression seems to be correct
                    if (bufUncompressed.Length == 0 || bufUncompressed.Length != LengthUnCompressed)
                    {
                        // Narf, corrupt file or something like that
                        // Just write it..
                        //throw new Exception("WriteItems(): Item " + Filepath + ", DataLen missmatch");
                    }
                    else
                    {
                        // Decompression was succesfull, so update size
                        LengthCompressed = (uint)Deflate.GetCompressedLength(bufUncompressed);
                    }
                }

                // Seems like a valid buf, write it
                writer.Write(buf);
            } catch (Exception e) {
                System.Diagnostics.Debug.WriteLine(e);
            }
        }