mirror of
https://github.com/mangosfour/server.git
synced 2025-12-12 10:37:03 +00:00
[7443] Better error reporting at DBC files extraction in ad.exe. No functionlity chnages in normal work case.
This commit is contained in:
parent
498ab2df07
commit
719991d381
5 changed files with 42 additions and 14 deletions
|
|
@ -9,29 +9,42 @@ DBCFile::DBCFile(const std::string &filename):
|
|||
{
|
||||
|
||||
}
|
||||
void DBCFile::open()
|
||||
bool DBCFile::open()
|
||||
{
|
||||
MPQFile f(filename.c_str());
|
||||
char header[4];
|
||||
unsigned int na,nb,es,ss;
|
||||
|
||||
f.read(header,4); // Number of records
|
||||
assert(header[0]=='W' && header[1]=='D' && header[2]=='B' && header[3] == 'C');
|
||||
f.read(&na,4); // Number of records
|
||||
f.read(&nb,4); // Number of fields
|
||||
f.read(&es,4); // Size of a record
|
||||
f.read(&ss,4); // String size
|
||||
if(f.read(header,4)!=4) // Number of records
|
||||
return false;
|
||||
|
||||
if(header[0]!='W' || header[1]!='D' || header[2]!='B' || header[3]!='C')
|
||||
return false;
|
||||
|
||||
if(f.read(&na,4)!=4) // Number of records
|
||||
return false;
|
||||
if(f.read(&nb,4)!=4) // Number of fields
|
||||
return false;
|
||||
if(f.read(&es,4)!=4) // Size of a record
|
||||
return false;
|
||||
if(f.read(&ss,4)!=4) // String size
|
||||
return false;
|
||||
|
||||
recordSize = es;
|
||||
recordCount = na;
|
||||
fieldCount = nb;
|
||||
stringSize = ss;
|
||||
assert(fieldCount*4 == recordSize);
|
||||
if(fieldCount*4 != recordSize)
|
||||
return false;
|
||||
|
||||
data = new unsigned char[recordSize*recordCount+stringSize];
|
||||
stringTable = data + recordSize*recordCount;
|
||||
f.read(data,recordSize*recordCount+stringSize);
|
||||
|
||||
size_t data_size = recordSize*recordCount+stringSize;
|
||||
if(f.read(data,data_size)!=data_size)
|
||||
return false;
|
||||
f.close();
|
||||
return true;
|
||||
}
|
||||
DBCFile::~DBCFile()
|
||||
{
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue