mirror of
https://github.com/TrinityCore/TrinityCore.git
synced 2026-01-16 07:30:42 +01:00
Core/Logging: Switch from fmt::sprintf to fmt::format (c++20 standard compatible api)
This commit is contained in:
@@ -511,7 +511,7 @@ char* DB2FileLoaderRegularImpl::AutoProduceStrings(char** indexTable, uint32 ind
|
||||
}
|
||||
}
|
||||
|
||||
TC_LOG_ERROR("", "Attempted to load %s which has locales %s as %s. Check if you placed your localized db2 files in correct directory.", _fileName, str.str().c_str(), localeNames[locale]);
|
||||
TC_LOG_ERROR("", "Attempted to load {} which has locales {} as {}. Check if you placed your localized db2 files in correct directory.", _fileName, str.str(), localeNames[locale]);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1059,7 +1059,7 @@ void DB2FileLoaderSparseImpl::SetAdditionalData(std::vector<uint32> /*idTable*/,
|
||||
char* DB2FileLoaderSparseImpl::AutoProduceData(uint32& indexTableSize, char**& indexTable)
|
||||
{
|
||||
if (_loadInfo->Meta->FieldCount != _header->FieldCount)
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Found unsupported parent index in sparse db2 %s", _fileName));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Found unsupported parent index in sparse db2 {}", _fileName));
|
||||
|
||||
//get struct size and index pos
|
||||
uint32 recordsize = _loadInfo->Meta->GetRecordSize();
|
||||
@@ -1187,7 +1187,7 @@ char* DB2FileLoaderSparseImpl::AutoProduceData(uint32& indexTableSize, char**& i
|
||||
char* DB2FileLoaderSparseImpl::AutoProduceStrings(char** indexTable, uint32 indexTableSize, uint32 locale)
|
||||
{
|
||||
if (_loadInfo->Meta->FieldCount != _header->FieldCount)
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Found unsupported parent index in sparse db2 %s", _fileName));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Found unsupported parent index in sparse db2 {}", _fileName));
|
||||
|
||||
if (!(_header->Locale & (1 << locale)))
|
||||
{
|
||||
@@ -1202,7 +1202,7 @@ char* DB2FileLoaderSparseImpl::AutoProduceStrings(char** indexTable, uint32 inde
|
||||
}
|
||||
}
|
||||
|
||||
TC_LOG_ERROR("", "Attempted to load %s which has locales %s as %s. Check if you placed your localized db2 files in correct directory.", _fileName, str.str().c_str(), localeNames[locale]);
|
||||
TC_LOG_ERROR("", "Attempted to load {} which has locales {} as {}. Check if you placed your localized db2 files in correct directory.", _fileName, str.str(), localeNames[locale]);
|
||||
return nullptr;
|
||||
}
|
||||
|
||||
@@ -1756,27 +1756,27 @@ void DB2FileLoader::LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* lo
|
||||
EndianConvert(_header.SectionCount);
|
||||
|
||||
if (_header.Signature != 0x33434457) //'WDC3'
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Incorrect file signature in %s, expected 'WDC3', got %c%c%c%c", source->GetFileName(),
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Incorrect file signature in {}, expected 'WDC3', got %c%c%c%c", source->GetFileName(),
|
||||
char(_header.Signature & 0xFF), char((_header.Signature >> 8) & 0xFF), char((_header.Signature >> 16) & 0xFF), char((_header.Signature >> 24) & 0xFF)));
|
||||
|
||||
if (loadInfo && _header.LayoutHash != loadInfo->Meta->LayoutHash)
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Incorrect layout hash in %s, expected 0x%08X, got 0x%08X (possibly wrong client version)",
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Incorrect layout hash in {}, expected 0x{:08X}, got 0x{:08X} (possibly wrong client version)",
|
||||
source->GetFileName(), loadInfo->Meta->LayoutHash, _header.LayoutHash));
|
||||
|
||||
if (_header.ParentLookupCount > 1)
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Too many parent lookups in %s, only one is allowed, got %u",
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Too many parent lookups in {}, only one is allowed, got {}",
|
||||
source->GetFileName(), _header.ParentLookupCount));
|
||||
|
||||
if (loadInfo && (_header.TotalFieldCount + (loadInfo->Meta->ParentIndexField >= int32(_header.TotalFieldCount) ? 1 : 0) != loadInfo->Meta->FieldCount))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Incorrect number of fields in %s, expected %u, got %u",
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Incorrect number of fields in {}, expected {}, got {}",
|
||||
source->GetFileName(), loadInfo->Meta->FieldCount, _header.TotalFieldCount + (loadInfo->Meta->ParentIndexField >= int32(_header.TotalFieldCount) ? 1 : 0)));
|
||||
|
||||
if (loadInfo && (_header.ParentLookupCount && loadInfo->Meta->ParentIndexField == -1))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unexpected parent lookup found in %s", source->GetFileName()));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unexpected parent lookup found in {}", source->GetFileName()));
|
||||
|
||||
std::unique_ptr<DB2SectionHeader[]> sections = std::make_unique<DB2SectionHeader[]>(_header.SectionCount);
|
||||
if (_header.SectionCount && !source->Read(sections.get(), sizeof(DB2SectionHeader) * _header.SectionCount))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read section headers from %s", source->GetFileName()));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read section headers from {}", source->GetFileName()));
|
||||
|
||||
uint32 totalCopyTableSize = 0;
|
||||
uint32 totalParentLookupDataSize = 0;
|
||||
@@ -1802,12 +1802,12 @@ void DB2FileLoader::LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* lo
|
||||
totalParentLookupDataSize;
|
||||
|
||||
if (source->GetFileSize() != expectedFileSize)
|
||||
throw DB2FileLoadException(Trinity::StringFormat("%s failed size consistency check, expected " SZFMTD ", got " SZFMTD, expectedFileSize, source->GetFileSize()));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("{} failed size consistency check, expected {}, got {}", source->GetFileName(), expectedFileSize, source->GetFileSize()));
|
||||
}
|
||||
|
||||
std::unique_ptr<DB2FieldEntry[]> fieldData = std::make_unique<DB2FieldEntry[]>(_header.FieldCount);
|
||||
if (!source->Read(fieldData.get(), sizeof(DB2FieldEntry) * _header.FieldCount))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read field information from %s", source->GetFileName()));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read field information from {}", source->GetFileName()));
|
||||
|
||||
std::unique_ptr<DB2ColumnMeta[]> columnMeta;
|
||||
std::unique_ptr<std::unique_ptr<DB2PalletValue[]>[]> palletValues;
|
||||
@@ -1817,14 +1817,14 @@ void DB2FileLoader::LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* lo
|
||||
{
|
||||
columnMeta = std::make_unique<DB2ColumnMeta[]>(_header.TotalFieldCount);
|
||||
if (!source->Read(columnMeta.get(), _header.ColumnMetaSize))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read field metadata from %s", source->GetFileName()));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read field metadata from {}", source->GetFileName()));
|
||||
|
||||
if (loadInfo && loadInfo->Meta->HasIndexFieldInData())
|
||||
{
|
||||
if (columnMeta[loadInfo->Meta->IndexField].CompressionType != DB2ColumnCompression::None
|
||||
&& columnMeta[loadInfo->Meta->IndexField].CompressionType != DB2ColumnCompression::Immediate
|
||||
&& columnMeta[loadInfo->Meta->IndexField].CompressionType != DB2ColumnCompression::SignedImmediate)
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Invalid compression type for index field in %s, expected one of None (0), Immediate (1), SignedImmediate (5), got %u",
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Invalid compression type for index field in {}, expected one of None (0), Immediate (1), SignedImmediate (5), got {}",
|
||||
source->GetFileName(), uint32(columnMeta[loadInfo->Meta->IndexField].CompressionType)));
|
||||
}
|
||||
|
||||
@@ -1836,7 +1836,7 @@ void DB2FileLoader::LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* lo
|
||||
|
||||
palletValues[i] = std::make_unique<DB2PalletValue[]>(columnMeta[i].AdditionalDataSize / sizeof(DB2PalletValue));
|
||||
if (!source->Read(palletValues[i].get(), columnMeta[i].AdditionalDataSize))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read field pallet values from %s for field %u", source->GetFileName(), i));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read field pallet values from {} for field {}", source->GetFileName(), i));
|
||||
}
|
||||
|
||||
palletArrayValues = std::make_unique<std::unique_ptr<DB2PalletValue[]>[]>(_header.TotalFieldCount);
|
||||
@@ -1847,7 +1847,7 @@ void DB2FileLoader::LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* lo
|
||||
|
||||
palletArrayValues[i] = std::make_unique<DB2PalletValue[]>(columnMeta[i].AdditionalDataSize / sizeof(DB2PalletValue));
|
||||
if (!source->Read(palletArrayValues[i].get(), columnMeta[i].AdditionalDataSize))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read field pallet array values from %s for field %u", source->GetFileName(), i));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read field pallet array values from {} for field {}", source->GetFileName(), i));
|
||||
}
|
||||
|
||||
std::unique_ptr<std::unique_ptr<DB2CommonValue[]>[]> commonData = std::make_unique<std::unique_ptr<DB2CommonValue[]>[]>(_header.TotalFieldCount);
|
||||
@@ -1862,7 +1862,7 @@ void DB2FileLoader::LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* lo
|
||||
|
||||
commonData[i] = std::make_unique<DB2CommonValue[]>(columnMeta[i].AdditionalDataSize / sizeof(DB2CommonValue));
|
||||
if (!source->Read(commonData[i].get(), columnMeta[i].AdditionalDataSize))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read field common values from %s for field %u", source->GetFileName(), i));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read field common values from {} for field {}", source->GetFileName(), i));
|
||||
|
||||
uint32 numExtraValuesForField = columnMeta[i].AdditionalDataSize / sizeof(DB2CommonValue);
|
||||
for (uint32 record = 0; record < numExtraValuesForField; ++record)
|
||||
@@ -1921,23 +1921,23 @@ void DB2FileLoader::Load(DB2FileSource* source, DB2FileLoadInfo const* loadInfo)
|
||||
}
|
||||
|
||||
if (!source->SetPosition(section.FileOffset))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to change %s read position for section %u", source->GetFileName(), i));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to change {} read position for section {}", source->GetFileName(), i));
|
||||
|
||||
if (!_impl->LoadTableData(source, i))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read section table data from %s for section %u", source->GetFileName(), i));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read section table data from {} for section {}", source->GetFileName(), i));
|
||||
|
||||
if (!_impl->LoadCatalogData(source, i))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read section catalog data from %s for section %u", source->GetFileName(), i));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read section catalog data from {} for section {}", source->GetFileName(), i));
|
||||
|
||||
if (loadInfo)
|
||||
{
|
||||
if (loadInfo->Meta->HasIndexFieldInData())
|
||||
{
|
||||
if (section.IdTableSize != 0)
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unexpected id table found in %s for section %u", source->GetFileName(), i));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unexpected id table found in {} for section {}", source->GetFileName(), i));
|
||||
}
|
||||
else if (section.IdTableSize != 4 * section.RecordCount)
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unexpected id table size in %s for section %u, expected %u, got %u",
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unexpected id table size in {} for section {}, expected {}, got {}",
|
||||
source->GetFileName(), i, 4 * section.RecordCount, section.IdTableSize));
|
||||
}
|
||||
|
||||
@@ -1946,7 +1946,7 @@ void DB2FileLoader::Load(DB2FileSource* source, DB2FileLoadInfo const* loadInfo)
|
||||
std::size_t idTableSize = idTable.size();
|
||||
idTable.resize(idTableSize + section.IdTableSize / sizeof(uint32));
|
||||
if (!source->Read(&idTable[idTableSize], section.IdTableSize))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read non-inline record ids from %s for section %u", source->GetFileName(), i));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read non-inline record ids from {} for section {}", source->GetFileName(), i));
|
||||
|
||||
// This is a hack fix for broken db2 files that have invalid id tables
|
||||
for (std::size_t i = idTableSize; i < idTable.size(); ++i)
|
||||
@@ -1959,7 +1959,7 @@ void DB2FileLoader::Load(DB2FileSource* source, DB2FileLoadInfo const* loadInfo)
|
||||
std::size_t copyTableSize = copyTable.size();
|
||||
copyTable.resize(copyTableSize + section.CopyTableCount);
|
||||
if (!source->Read(©Table[copyTableSize], section.CopyTableCount * sizeof(DB2RecordCopy)))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read record copies from %s for section %u", source->GetFileName(), i));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read record copies from {} for section {}", source->GetFileName(), i));
|
||||
}
|
||||
|
||||
if (_header.ParentLookupCount)
|
||||
@@ -1969,14 +1969,14 @@ void DB2FileLoader::Load(DB2FileSource* source, DB2FileLoadInfo const* loadInfo)
|
||||
{
|
||||
DB2IndexDataInfo indexInfo;
|
||||
if (!source->Read(&indexInfo, sizeof(DB2IndexDataInfo)))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read parent lookup info from %s for section %u", source->GetFileName(), i));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read parent lookup info from {} for section {}", source->GetFileName(), i));
|
||||
|
||||
if (!indexInfo.NumEntries)
|
||||
continue;
|
||||
|
||||
parentIndexesForSection[j].Entries.resize(indexInfo.NumEntries);
|
||||
if (!source->Read(parentIndexesForSection[j].Entries.data(), sizeof(DB2IndexEntry) * indexInfo.NumEntries))
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read parent lookup content from %s for section %u", source->GetFileName(), i));
|
||||
throw DB2FileLoadException(Trinity::StringFormat("Unable to read parent lookup content from {} for section {}", source->GetFileName(), i));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user