Category:DBC: Difference between revisions

From wowdev
Jump to navigation Jump to search
m (Reverted edits by Schlumpf (Talk) to last revision by Tharo)
m (Undo revision 4946 by Schlumpf (Talk))
Line 1: Line 1:
The DBC (DataBaseClient) files are clientside databases containing data about Items, NPC's, Enviroment, World etc.
DBC (DataBaseClient) files are clientside databases containing data about items, NPCs, environment, world and a lot more.


Some of the following pages have been retrieved from "http://www.sourcepeek.com/wiki/"
Some of the record type specification pages have been retrieved from [http://www.sourcepeek.com/wiki/] and [http://paste2.org/p/1366912].


==Header==
=Table structure=
This page describes the structure of DBC files. For a list of existing DBC files and their contents see the categories [Category:DBC], [Category:DBC_Vanilla], [Category:DBC_BC], [Category:DBC_WotLK], [Category:DBC_Cataclysm] and [Category:DBC_MoP]. If you add documentation for a file, please add the correct categories (also the build number) as well.


  '''Column Field Type Notes'''
=Structure=
  1 Signature String (4-bytes) string, always 'WDBC'  
  struct dbc_header
2 Records Integer (4-bytes) number of records in the file
  {
  3 Fields Integer (4-bytes) number of fields per record
  uint32_t magic; // always 'WDBC'
  4 Record Size Integer (4-bytes) Fields*FieldSize (FieldSize is usually 4, but not always)  
  uint32_t record_count; // records per file
  5 String Block Size Integer Size of the string block
  uint32_t field_count; // fields per record
  uint32_t record_size; // sum (sizeof (field_type_i)) | 0 <= i < field_count. field_type_i is NOT defined in the files.
  uint32_t string_block_size;
};
template<typename record_type>
  struct dbc_file
  {
  dbc_header header;
  // static_assert (header.record_size == sizeof (record_type));
  record_type records[header.record_count];
  char string_block[header.string_block_size];
  };


==String Block==  
==String Block==
DBC records can contain strings. Strings are not stored in record but in an additional string block. A record contains an offset into that block. Strings are zero terminated (c strings) and might be zero length. A zero length string then only contains one byte being zero.


Unlike the cache files, string data is stored in a block after the records. String data in records contain an offset to the string, starting from the string block. For example: If the address of the string block was 500, and the string value was 50, the address of the string would be at 550. The string block starts with a null character, and all strings are null-terminated.
Thus, if
typedef uint32_t string_offset_type;
struct example_record
{
  uint32_t id;
  string_offset_type name;
};
printing the id and name of record i can be done by
// dbc_file<example_record> file;
printf ("record %u: %u, %s\n", file.records[i].id, file.string_block[file.records[i].name]);
or when going by offsets only:
// const char* file;
uint32_t record_count = *(uint32_t*) (file + 1 * sizeof (uint32_t));
uint32_t record_size = *(uint32_t*) (file + 3 * sizeof (uint32_t));
const char* records = file + 5 * sizeof (uint32_t) /* header */;
const char* string_block = records + record_size * record_count;
printf ("record %u: %u, %s\n", *(uint32_t*)(records + i * record_size /* id */), string_block + *(uint32_t*)(records + i * record_size + sizeof (uint32_t) /* name */));


==Notes==
=Localization=
DBC records can contain localized strings. Localized strings are a set of one string block offset per locale plus a bitmask up to Cataclysm. Beginning with Cataclysm, there only is one field containing only one string offset, thus disallowing providing multiple locales in one file.


* When encountering a string field in a dbc file, it usually consists of an english name field as well as 7 additional fields for different localizations. Following the 8 String* fields is a bitmask field.
The number and order of locale fields can be found at [[Localization]]. The record description might either mark a number of columns per localized field (e.g. 1-16) or treat all the fields as one column.
** see [[Localization]].  
 
* 2.1.1 changes the additional fields to 15.
* Always add the fucking [[rev]]ision infomation about the datas!

Revision as of 10:57, 19 November 2012

DBC (DataBaseClient) files are clientside databases containing data about items, NPCs, environment, world and a lot more.

Some of the record type specification pages have been retrieved from [1] and [2].

Table structure

This page describes the structure of DBC files. For a list of existing DBC files and their contents see the categories [Category:DBC], [Category:DBC_Vanilla], [Category:DBC_BC], [Category:DBC_WotLK], [Category:DBC_Cataclysm] and [Category:DBC_MoP]. If you add documentation for a file, please add the correct categories (also the build number) as well.

Structure

struct dbc_header
{
  uint32_t magic; // always 'WDBC'
  uint32_t record_count; // records per file
  uint32_t field_count; // fields per record
  uint32_t record_size; // sum (sizeof (field_type_i)) | 0 <= i < field_count. field_type_i is NOT defined in the files.
  uint32_t string_block_size;
};

template<typename record_type>
struct dbc_file
{
  dbc_header header;
  // static_assert (header.record_size == sizeof (record_type));
  record_type records[header.record_count];
  char string_block[header.string_block_size];
};

String Block

DBC records can contain strings. Strings are not stored in record but in an additional string block. A record contains an offset into that block. Strings are zero terminated (c strings) and might be zero length. A zero length string then only contains one byte being zero.

Thus, if

typedef uint32_t string_offset_type;
struct example_record
{
  uint32_t id;
  string_offset_type name;
};

printing the id and name of record i can be done by

// dbc_file<example_record> file;
printf ("record %u: %u, %s\n", file.records[i].id, file.string_block[file.records[i].name]);

or when going by offsets only:

// const char* file;
uint32_t record_count = *(uint32_t*) (file + 1 * sizeof (uint32_t));
uint32_t record_size = *(uint32_t*) (file + 3 * sizeof (uint32_t));
const char* records = file + 5 * sizeof (uint32_t) /* header */;
const char* string_block = records + record_size * record_count;
printf ("record %u: %u, %s\n", *(uint32_t*)(records + i * record_size /* id */), string_block + *(uint32_t*)(records + i * record_size + sizeof (uint32_t) /* name */));

Localization

DBC records can contain localized strings. Localized strings are a set of one string block offset per locale plus a bitmask up to Cataclysm. Beginning with Cataclysm, there only is one field containing only one string offset, thus disallowing providing multiple locales in one file.

The number and order of locale fields can be found at Localization. The record description might either mark a number of columns per localized field (e.g. 1-16) or treat all the fields as one column.

Pages in category "DBC"

The following 200 pages are in this category, out of 708 total.

(previous page) (next page)

D

(previous page) (next page)