mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-15 23:20:36 +01:00
Core/DataStores: Implemented WDC2
This commit is contained in:
@@ -18,8 +18,12 @@
|
||||
#include "DB2Meta.h"
|
||||
#include "Errors.h"
|
||||
|
||||
DB2Meta::DB2Meta(int32 indexField, uint32 fieldCount, uint32 layoutHash, char const* types, uint8 const* arraySizes, int32 parentIndexField)
|
||||
: IndexField(indexField), ParentIndexField(parentIndexField), FieldCount(fieldCount), LayoutHash(layoutHash), Types(types), ArraySizes(arraySizes)
|
||||
DB2MetaField::DB2MetaField(DBCFormer type, uint8 arraySize, bool isSigned) : Type(type), ArraySize(arraySize), IsSigned(isSigned)
|
||||
{
|
||||
}
|
||||
|
||||
DB2Meta::DB2Meta(int32 indexField, uint32 fieldCount, uint32 layoutHash, DB2MetaField const* fields, int32 parentIndexField)
|
||||
: IndexField(indexField), ParentIndexField(parentIndexField), FieldCount(fieldCount), LayoutHash(layoutHash), Fields(fields)
|
||||
{
|
||||
}
|
||||
|
||||
@@ -38,9 +42,9 @@ uint32 DB2Meta::GetRecordSize() const
|
||||
uint32 size = 0;
|
||||
for (uint32 i = 0; i < FieldCount; ++i)
|
||||
{
|
||||
for (uint8 j = 0; j < ArraySizes[i]; ++j)
|
||||
for (uint8 j = 0; j < Fields[i].ArraySize; ++j)
|
||||
{
|
||||
switch (Types[i])
|
||||
switch (Fields[i].Type)
|
||||
{
|
||||
case FT_BYTE:
|
||||
size += 1;
|
||||
@@ -56,10 +60,11 @@ uint32 DB2Meta::GetRecordSize() const
|
||||
size += 8;
|
||||
break;
|
||||
case FT_STRING:
|
||||
case FT_STRING_NOT_LOCALIZED:
|
||||
size += sizeof(char*);
|
||||
break;
|
||||
default:
|
||||
ASSERT(false, "Unsupported column type specified %c", Types[i]);
|
||||
ASSERT(false, "Unsupported column type specified %c", Fields[i].Type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -82,9 +87,9 @@ int32 DB2Meta::GetParentIndexFieldOffset() const
|
||||
|
||||
for (int32 i = 0; i < ParentIndexField; ++i)
|
||||
{
|
||||
for (uint8 j = 0; j < ArraySizes[i]; ++j)
|
||||
for (uint8 j = 0; j < Fields[i].ArraySize; ++j)
|
||||
{
|
||||
switch (Types[i])
|
||||
switch (Fields[i].Type)
|
||||
{
|
||||
case FT_BYTE:
|
||||
offset += 1;
|
||||
@@ -100,10 +105,11 @@ int32 DB2Meta::GetParentIndexFieldOffset() const
|
||||
offset += 8;
|
||||
break;
|
||||
case FT_STRING:
|
||||
case FT_STRING_NOT_LOCALIZED:
|
||||
offset += sizeof(char*);
|
||||
break;
|
||||
default:
|
||||
ASSERT(false, "Unsupported column type specified %c", Types[i]);
|
||||
ASSERT(false, "Unsupported column type specified %c", Fields[i].Type);
|
||||
break;
|
||||
}
|
||||
}
|
||||
@@ -119,7 +125,7 @@ uint32 DB2Meta::GetDbIndexField() const
|
||||
|
||||
uint32 index = 0;
|
||||
for (uint32 i = 0; i < FieldCount && i < uint32(IndexField); ++i)
|
||||
index += ArraySizes[i];
|
||||
index += Fields[i].ArraySize;
|
||||
|
||||
return index;
|
||||
}
|
||||
@@ -128,7 +134,7 @@ uint32 DB2Meta::GetDbFieldCount() const
|
||||
{
|
||||
uint32 fields = 0;
|
||||
for (uint32 i = 0; i < FieldCount; ++i)
|
||||
fields += ArraySizes[i];
|
||||
fields += Fields[i].ArraySize;
|
||||
|
||||
if (!HasIndexFieldInData())
|
||||
++fields;
|
||||
@@ -136,7 +142,23 @@ uint32 DB2Meta::GetDbFieldCount() const
|
||||
return fields;
|
||||
}
|
||||
|
||||
DB2FieldMeta::DB2FieldMeta(bool isSigned, DBCFormer type, char const* name)
|
||||
: IsSigned(isSigned), Type(type), Name(name)
|
||||
bool DB2Meta::IsSignedField(uint32 field) const
|
||||
{
|
||||
switch (Fields[field].Type)
|
||||
{
|
||||
case FT_STRING:
|
||||
case FT_STRING_NOT_LOCALIZED:
|
||||
case FT_FLOAT:
|
||||
return false;
|
||||
case FT_INT:
|
||||
case FT_BYTE:
|
||||
case FT_SHORT:
|
||||
case FT_LONG:
|
||||
default:
|
||||
break;
|
||||
}
|
||||
if (field == uint32(IndexField))
|
||||
return false;
|
||||
|
||||
return Fields[field].IsSigned;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user