25DBCFileLoader::DBCFileLoader() : recordSize(0), recordCount(0), fieldCount(0), stringSize(0), fieldsOffset(nullptr), data(nullptr), stringTable(nullptr) { }
36 FILE* f = fopen(filename,
"rb");
40 if (fread(&header, 4, 1, f) != 1)
48 if (header != 0x43424457)
128 for (
uint32 x = 0; format[x]; ++x)
133 recordsize +=
sizeof(float);
136 recordsize +=
sizeof(
uint32);
139 recordsize +=
sizeof(
char*);
146 recordsize +=
sizeof(
uint32);
149 recordsize +=
sizeof(
uint8);
155 ABORT_MSG(
"Attempted to load DBC files that do not have field types that match what is in the core. Check DBCfmt.h or your DBC files.");
158 ABORT_MSG(
"Unknown field format character in DBCfmt.h");
203 indexTable =
new ptr[maxi];
204 memset(indexTable, 0, maxi *
sizeof(ptr));
212 char* dataTable =
new char[
recordCount * recordsize];
221 indexTable[y] = &dataTable[offset];
229 offset +=
sizeof(float);
238 offset +=
sizeof(
uint8);
241 *((
char**)(&dataTable[offset])) =
nullptr;
242 offset +=
sizeof(
char*);
245 ABORT_MSG(
"Attempted to load DBC files that do not have field types that match what is in the core. Check DBCfmt.h or your DBC files.");
252 ABORT_MSG(
"Unknown field format character in DBCfmt.h");
278 offset +=
sizeof(float);
285 offset +=
sizeof(
uint8);
290 char** slot = (
char**)(&dataTable[offset]);
291 if (!*slot || !**slot)
294 *slot = stringPool + (st - (
char const*)
stringTable);
296 offset +=
sizeof(
char*);
300 ABORT_MSG(
"Attempted to load DBC files that does not have field types that match what is in the core. Check DBCfmt.h or your DBC files.");
307 ABORT_MSG(
"Unknown field format character in DBCfmt.h");
void EndianConvert(T &val)
const char * getString(size_t field) const
uint32 getUInt(size_t field) const
float getFloat(size_t field) const
uint8 getUInt8(size_t field) const
char * AutoProduceStrings(char const *fmt, char *dataTable)
Record getRecord(size_t id)
bool Load(const char *filename, const char *fmt)
unsigned char * stringTable
static uint32 GetFormatRecordSize(const char *format, int32 *index_pos=nullptr)
char * AutoProduceData(char const *fmt, uint32 &count, char **&indexTable)