mirror of
https://github.com/araxiaonline/TrinityCore.git
synced 2026-06-20 06:59:46 -04:00
Core: Some optimizations
- Declare some functions const - Fix some mem leak - Fix some resource leak - Remove unused variables and functions - Remove duplicate functions - Reduce the scope of some variables - Remove unused file --HG-- branch : trunk
This commit is contained in:
@@ -41,31 +41,50 @@ bool DBCFileLoader::Load(const char *filename, const char *fmt)
|
||||
if (!f)
|
||||
return false;
|
||||
|
||||
if (fread(&header,4,1,f)!=1) // Number of records
|
||||
if (fread(&header,4,1,f) != 1) // Number of records
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
EndianConvert(header);
|
||||
|
||||
if (header!=0x43424457)
|
||||
return false; //'WDBC'
|
||||
|
||||
if (fread(&recordCount,4,1,f)!=1) // Number of records
|
||||
if (header != 0x43424457) //'WDBC'
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (fread(&recordCount,4,1,f) != 1) // Number of records
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
EndianConvert(recordCount);
|
||||
|
||||
if (fread(&fieldCount,4,1,f)!=1) // Number of fields
|
||||
if (fread(&fieldCount,4,1,f) != 1) // Number of fields
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
EndianConvert(fieldCount);
|
||||
|
||||
if (fread(&recordSize,4,1,f)!=1) // Size of a record
|
||||
if (fread(&recordSize,4,1,f) != 1) // Size of a record
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
EndianConvert(recordSize);
|
||||
|
||||
if (fread(&stringSize,4,1,f)!=1) // String size
|
||||
if (fread(&stringSize,4,1,f) != 1) // String size
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
EndianConvert(stringSize);
|
||||
|
||||
@@ -83,8 +102,11 @@ bool DBCFileLoader::Load(const char *filename, const char *fmt)
|
||||
data = new unsigned char[recordSize*recordCount+stringSize];
|
||||
stringTable = data + recordSize*recordCount;
|
||||
|
||||
if (fread(data,recordSize*recordCount+stringSize,1,f)!=1)
|
||||
if (fread(data,recordSize*recordCount+stringSize,1,f) != 1)
|
||||
{
|
||||
fclose(f);
|
||||
return false;
|
||||
}
|
||||
|
||||
fclose(f);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user