[I]As many guides have stated in the past, rdb normally follow closely to their database (table) counter-part.
So as usual the first 128 bytes of data = date_modified, next 4 bytes = row_count, next 4 bytes = beginning of first row
after the first four bytes of the row (usually id field) you will need to read each column (data_type) in order.
For example:
db_questlink.rdb
date_modified = 128 Bytes [String]
row_count = 4 bytes [Int32]
quest_id = 4 bytes [Int32]
npc_id = 4 bytes [Int32]
flag_start = byte
flag_progress = byte
flag_end = byte
after the first row is read, it will just repeat in the same manner. So put your rdb editor on a read loop, like:
I wrote up an example program to demonstrate:
Main Program:
Code:
using System;
using System.ComponentModel;
using System.IO;
using System.Text;
using Gtk;
namespace test
{
class MainClass
{
BindingList<db_questlink> db_questlinkinfo = new BindingList<db_questlink>();
public string date_modified { get; set; }
public Int32 row_count { get; set; }
public static void Main (string[] args)
{
Application.Init ();
MainWindow win = new MainWindow ();
win.Show ();
Application.Run ();
}
//Replace this with OpenFileDialog (This is just for demonstration)
static string prog_dir = Directory.GetCurrentDirectory(); //This will load files from programs current directory
static string file_dir = Path.Combine(prog_dir, "db_questlink.rdb");
public void read_rdb()
{ //F
using(BinaryReader br = new BinaryReader(File.OpenRead(file_dir)))
{
//First as usual read the rdb header
Byte[] in_date = br.ReadBytes(8);
date_modified = BytesToString (in_date);
row_count = br.ReadInt32();
//Now we begin reading the actual info
db_questlink questlink = new db_questlink();
//While the Reader is Reading
while (br.PeekChar () != -1)
{
questlink.read_rdb(br);
//If response is agreeable add his info to the bindinglist
db_questlinkinfo.Add(questlink);
}
}
}
public static string BytesToString(byte[] b)
{
int num = 0;
string str = "";
for (int i = 0; i < (int)b.Length && b[i] > 0; i++)
{
num++;
}
byte[] numArray = new byte[num];
for (int i = 0; i < num && b[i] > 0; i++) {
numArray [i] = b [i];
}
str = Encoding.GetEncoding ("ASCII").GetString (numArray);
return str;
}
}
}
[/i]
!!!NOTE: I use Linux natively so you should remove "Using Gtk" !!!
db_questlink.cs
Code:
using System;
using System.IO;
namespace test
{
public class db_questlink
{
public Int32 quest_id { get; set; }
public Int32 npc_id { get; set; }
public Byte flag_start { get; set; }
public Byte flag_progress { get; set; }
public Byte flag_end { get; set; }
public void read_rdb(BinaryReader br)
{
this.quest_id = br.ReadInt32();
this.npc_id = br.ReadInt32();
this.flag_start = br.ReadByte();
this.flag_progress = br.ReadByte();
this.flag_end = br.ReadByte();
}
}
}
It is also possible to figure out the structure without the help of it's database counter-part as a reference but very very hard. If you're going to attempt it I'd recommend using structorian.