Forum > Serverside Modding
[QUESTION] VB DBC converter source
(1/2) > >>
Keta:
[center:4nfmo8vn]Hello Modcraft![/center:4nfmo8vn]
I was hoping someone on here might be able to help me with this little project I've begun. Would there by any chance be someone who'd be able to help me in scripting a Visual Basic program to be able to convert DBC data into maybe just lines of numbers, like the DBC -> CSV does. Even if you just have the sourcecode for his program it'd also be nice :) Its just, I don't really know how to approach this, since I don't really understand the structure of the DBC files. I mean, they don't make sense if just changed from .dbc to .txt, and they don't make sense either, if viewed in Hex so... Anyone, please? x)
Thanks Keta
Steff:
You should sgtrat to read more about hex.
- little endian - datatypes - chunked structure
Here is the description of the DBC file format. http://pxr.dk/wowdev/wiki/index.php?title=DBC
Keta:
Yeah I know that, but I still don't understand how I can convert it into text my VB program can read :/ Maybe you could write a C# or C++ code that can do it, and I will try to convert it into VB code? xP ^_^
Thanks Keta
schlumpf:
A quick C++ dbc "viewer", I just wrote for you at work. Note, that I have never tested this except for compiling it after writing (from top to bottom, without being able to correct a previous line due to the behaviour of cat). It should work though. It will first output all strings in the string block, then show the first entry as integer, float and string, if an entry exists.
I wrote a better one at work once which analysed the different column types and print all entries, but I can't find that one right now and am lazy.
--- Code: ---~> cat > dbcview.cpp #include <stdint.h> #include <cassert> #include <cstdio> #include <cstdlib>
struct dbcHeader_t { uint32_t token, records, fields, recSize, stringSize; };
int main(int cnt, char** arg) { assert( cnt == 2 && "argument: filename" ); FILE* file = fopen( arg[1], "r" ); assert( file && "file could not be opened." ); fseek(file, 0, SEEK_END); size_t fsize = ftell(file); fseek(file, 0, SEEK_SET); char* data = new char[fsize]; fread( data, fsize, 1, file); fclose(file);
dbcHeader_t* header = reinterpret_cast<dbcHeader_t*>(data); assert(header->token == 'WDBC'); printf("records: %in", header->records); size_t n = 0; char* stringblock = data + sizeof(dbcHeader_t) + header->recSize * header->records; for( size_t i = 0; i < header->stringSize; ++i) { if( i == 0 || stringblock[i] == '' ) printf("#%i: ", n++ ); else ; // mistake. if(stringblock[i] != '') printf("%c", stringblock[i]); } if(header->records && header->fields) { printf("first entry:n"); char* entry = data + sizeof(dbcHeader_t); printf(" as int: %ldn", *reinterpret_cast<int*>(entry)); printf(" as float: %fn", *reinterpret_cast<float*>(entry)); if(header->stringSize) printf(" as string: %sn", stringblock + *reinterpret_cast<int*>(entry)); } delete[] data; return 0; } ~> clang++ dbcview.cpp -o dbcview ~> ./dbcview dbcview: dbcview.cpp:12: int main(int, char **): Assertion `cnt == 2 && "argument: filename"' failed. ~> touch test && ./dbcview test dbcview: dbcview.cpp:21: int main(int, char **): Assertion `header->token == 'WDBC'' failed. ~>
--- End code ---
Keta:
Alright, thanks a lot Schlumpf! ;D This is gonna help me quite a lot I believe ;) Y U NO WORK AT WORK?! o_o Lol, Im not your boss so I don't really care XD Just felt like adding that ;D
Thanks Keta
Navigation
[0] Message Index
[#] Next page
|