-
Member
DBC StringTable
I'm currently writing a small dbc lib using the .NET framework.
Reading and writing works fine for dbcs like Item.dbc which doesn't contains any strings.
But if I want to write a file like CharTitles.dbc I'll get some problems with strings.
This is the Write method, which creates the file
Code:
public void Write(IEnumerable<IDBCEntry> entries, Dictionary<int, string> stringTable, int fieldsCount, int recordSize)
{
using (var writer = new BinaryWriter(new FileStream(this.DestinationPath, FileMode.OpenOrCreate), Encoding.UTF8))
{
writer.Write(DBCWriter.DBCFileSignature);
writer.Write(entries.Count());
writer.Write(fieldsCount);
writer.Write(recordSize);
writer.Write(stringTable.Count());
foreach (var entry in entries)
{
entry.Write(writer, stringTable);
}
if (stringTable.Count() > 0)
{
foreach (var str in stringTable.Values)
{
writer.Write(str);
}
}
else
{
writer.Write((char)0x00);
}
writer.Flush();
writer.Close();
}
}
The implementation of IDBCEntry contains a method called "Write". This method writes the row data into the stream like
Code:
public void Write(BinaryWriter writer, Dictionary<int, string> stringTable)
{
writer.Write(this.Id);
writer.Write(this.ConditionId);
....
If I open the new file now, the string columns just displaying the reference id to the string table.
I guess this is because I write just an integer into this field but how can I write a reference to a string table row?
Thanks in advance!
-
This doesn't answer your question directly but I have to do a lot of DBC manipulation for my spell editor, e.g: https://github.com/stoneharry/Spell-...BC/SpellDBC.cs
-
Post Thanks / Like - 2 Thanks
Ket,
Monkeyx3 (2 members gave Thanks to stoneharry for this useful post)
-
Member
Thanks you! Your post really helped me.
I wrote the position of the string as reference for the field but I have to write the position in the byte array.