Core/Storage: Add some sanity checks and better define some SQL and DBC
storage format field types. * Also LOTS of whitespace cleanup * Some Trinity code style applied * Some if / else if -> switch / case * Original ideal for patch by Vinolentus
This commit is contained in:
@@ -45,22 +45,44 @@ SQLStorage sInstanceTemplate(InstanceTemplatesrcfmt, InstanceTemplatedstfmt, "ma
|
||||
|
||||
void SQLStorage::Free ()
|
||||
{
|
||||
uint32 offset=0;
|
||||
for (uint32 x=0; x<iNumFields; x++)
|
||||
if (dst_format[x]==FT_STRING)
|
||||
uint32 offset = 0;
|
||||
for (uint32 x = 0; x < iNumFields; ++x)
|
||||
{
|
||||
switch(dst_format[x])
|
||||
{
|
||||
for (uint32 y=0; y<MaxEntry; y++)
|
||||
if(pIndex[y])
|
||||
delete [] *(char**)((char*)(pIndex[y])+offset);
|
||||
case FT_BYTE:
|
||||
offset += sizeof(char);
|
||||
break;
|
||||
case FT_FLOAT:
|
||||
offset += sizeof(float);
|
||||
break;
|
||||
case FT_LOGIC:
|
||||
offset += sizeof(bool);
|
||||
break;
|
||||
case FT_INT:
|
||||
offset += sizeof(uint32);
|
||||
break;
|
||||
case FT_STRING:
|
||||
{
|
||||
for (uint32 y = 0; y < MaxEntry; ++y)
|
||||
if (pIndex[y])
|
||||
delete [] *(char**)((char*)(pIndex[y])+offset);
|
||||
|
||||
offset += sizeof(char*);
|
||||
offset += sizeof(char*);
|
||||
break;
|
||||
}
|
||||
case FT_NA:
|
||||
case FT_NA_BYTE:
|
||||
break;
|
||||
case FT_IND:
|
||||
case FT_SORT:
|
||||
assert(false && "SQL storage has a field type that does not match what is in the core. Check SQLStorage.cpp or your database.");
|
||||
break;
|
||||
default:
|
||||
assert(false && "Unknown field format character in SQLStorage.cpp");
|
||||
break;
|
||||
}
|
||||
else if (dst_format[x]==FT_LOGIC)
|
||||
offset += sizeof(bool);
|
||||
else if (dst_format[x]==FT_BYTE)
|
||||
offset += sizeof(char);
|
||||
else
|
||||
offset += 4;
|
||||
}
|
||||
|
||||
delete [] pIndex;
|
||||
delete [] data;
|
||||
|
||||
Reference in New Issue
Block a user