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:
runningnak3d
2011-03-18 09:36:59 -06:00
parent 3384dc3a24
commit 171268a565
3 changed files with 201 additions and 124 deletions
+35 -13
View File
@@ -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;