diff options
38 files changed, 333 insertions, 380 deletions
diff --git a/src/common/Common.h b/src/common/Common.h index e97288996f8..732583da0de 100644 --- a/src/common/Common.h +++ b/src/common/Common.h @@ -103,8 +103,13 @@ TC_COMMON_API LocaleConstant GetLocaleByName(std::string const& name); #pragma pack(push, 1) -struct TC_COMMON_API LocalizedString +struct LocalizedString { + constexpr char const* operator[](LocaleConstant locale) const + { + return Str[locale]; + } + char const* Str[TOTAL_LOCALES]; }; diff --git a/src/common/DataStores/DB2FileLoader.cpp b/src/common/DataStores/DB2FileLoader.cpp index 46c3f3d6b9c..f7cdd8ff35c 100644 --- a/src/common/DataStores/DB2FileLoader.cpp +++ b/src/common/DataStores/DB2FileLoader.cpp @@ -17,7 +17,6 @@ #include "DB2FileLoader.h" #include "ByteConverter.h" -#include "Common.h" #include "DB2Meta.h" #include "Errors.h" #include "Log.h" @@ -112,10 +111,6 @@ DB2FieldMeta::DB2FieldMeta(bool isSigned, DBCFormer type, char const* name) { } -DB2FileLoadInfo::DB2FileLoadInfo() : Fields(nullptr), FieldCount(0), Meta(nullptr) -{ -} - DB2FileLoadInfo::DB2FileLoadInfo(DB2FieldMeta const* fields, std::size_t fieldCount, DB2Meta const* meta) : Fields(fields), FieldCount(fieldCount), Meta(meta) { @@ -382,7 +377,7 @@ DB2FileLoaderRegularImpl::~DB2FileLoaderRegularImpl() static char const* const nullStr = ""; -char* DB2FileLoaderRegularImpl::AutoProduceData(uint32& records, char**& indexTable, std::vector<char*>& stringPool) +char* DB2FileLoaderRegularImpl::AutoProduceData(uint32& records, char**& indexTable, std::vector<char*>& /*stringPool*/) { //get struct size and index pos uint32 recordsize = _loadInfo->Meta->GetRecordSize(); @@ -397,27 +392,8 @@ char* DB2FileLoaderRegularImpl::AutoProduceData(uint32& records, char**& indexTa char* dataTable = new char[(_header->RecordCount + _copyTable.size()) * recordsize]; - // we store flat holders pool as single memory block - std::size_t stringFields = _loadInfo->GetStringFieldCount(false); - std::size_t localizedStringFields = _loadInfo->GetStringFieldCount(true); - - // each string field at load have array of string for each locale - std::size_t stringHoldersRecordPoolSize = localizedStringFields * sizeof(LocalizedString) + (stringFields - localizedStringFields) * sizeof(char*); - char* stringHoldersPool = nullptr; - if (stringFields) - { - std::size_t stringHoldersPoolSize = stringHoldersRecordPoolSize * _header->RecordCount; - - stringHoldersPool = new char[stringHoldersPoolSize]; - stringPool.push_back(stringHoldersPool); - - // DB2 strings expected to have at least empty string - for (std::size_t i = 0; i < stringHoldersPoolSize / sizeof(char*); ++i) - ((char const**)stringHoldersPool)[i] = nullStr; - } - uint32 offset = 0; - uint32 y = 0; + uint32 recordIndex = 0; for (uint32 section = 0; section < _header->SectionCount; ++section) { @@ -425,17 +401,17 @@ char* DB2FileLoaderRegularImpl::AutoProduceData(uint32& records, char**& indexTa if (sectionHeader.TactId) { offset += recordsize * sectionHeader.RecordCount; - y += sectionHeader.RecordCount; + recordIndex += sectionHeader.RecordCount; continue; } - for (uint32 sr = 0; sr < sectionHeader.RecordCount; ++sr, ++y) + for (uint32 sr = 0; sr < sectionHeader.RecordCount; ++sr, ++recordIndex) { - unsigned char const* rawRecord = GetRawRecordData(y, §ion); + unsigned char const* rawRecord = GetRawRecordData(recordIndex, §ion); if (!rawRecord) continue; - uint32 indexVal = RecordGetId(rawRecord, y); + uint32 indexVal = RecordGetId(rawRecord, recordIndex); indexTable[indexVal] = &dataTable[offset]; @@ -447,8 +423,6 @@ char* DB2FileLoaderRegularImpl::AutoProduceData(uint32& records, char**& indexTa ++fieldIndex; } - uint32 stringFieldOffset = 0; - for (uint32 x = 0; x < _header->FieldCount; ++x) { for (uint32 z = 0; z < _loadInfo->Meta->Fields[x].ArraySize; ++z) @@ -476,19 +450,15 @@ char* DB2FileLoaderRegularImpl::AutoProduceData(uint32& records, char**& indexTa offset += 8; break; case FT_STRING: - case FT_STRING_NOT_LOCALIZED: - { - // init db2 string field slots by pointers to string holders - char const*** slot = (char const***)(&dataTable[offset]); - *slot = (char const**)(&stringHoldersPool[stringHoldersRecordPoolSize * y + stringFieldOffset]); - if (_loadInfo->TypesString[fieldIndex] == FT_STRING) - stringFieldOffset += sizeof(LocalizedString); - else - stringFieldOffset += sizeof(char*); + for (char const*& localeStr : ((LocalizedString*)(&dataTable[offset]))->Str) + localeStr = nullStr; + offset += sizeof(LocalizedString); + break; + case FT_STRING_NOT_LOCALIZED: + *(char const**)(&dataTable[offset]) = nullStr; offset += sizeof(char*); break; - } default: ASSERT(false, "Unknown format character '%c' found in %s meta for field %s", _loadInfo->TypesString[fieldIndex], _fileName, _loadInfo->Fields[fieldIndex].Name); @@ -607,22 +577,13 @@ char* DB2FileLoaderRegularImpl::AutoProduceStrings(char** indexTable, uint32 ind break; case FT_STRING: { - // fill only not filled entries - LocalizedString* db2str = *(LocalizedString * *)(&recordData[offset]); - if (db2str->Str[locale] == nullStr) - { - char const* st = RecordGetString(rawRecord, x, z); - db2str->Str[locale] = stringPool + (st - (char const*)_stringTable); - } - - offset += sizeof(char*); + ((LocalizedString*)(&recordData[offset]))->Str[locale] = stringPool + (RecordGetString(rawRecord, x, z) - (char const*)_stringTable); + offset += sizeof(LocalizedString); break; } case FT_STRING_NOT_LOCALIZED: { - char** db2str = (char**)(&recordData[offset]); - char const* st = RecordGetString(rawRecord, x, z); - *db2str = stringPool + (st - (char const*)_stringTable); + *((char**)(&recordData[offset])) = stringPool + (RecordGetString(rawRecord, x, z) - (char const*)_stringTable); offset += sizeof(char*); break; } @@ -685,7 +646,7 @@ void DB2FileLoaderRegularImpl::FillParentLookup(char* dataTable) else { // in data block, must fit - ASSERT(parentId <= 0xFFFF, "ParentId value %u does not fit into uint16 field (%s in %s)", + ASSERT(parentId <= std::numeric_limits<uint16>::max(), "ParentId value %u does not fit into uint16 field (%s in %s)", parentId, _loadInfo->Fields[_loadInfo->GetFieldIndexByMetaIndex(_loadInfo->Meta->ParentIndexField)].Name, _fileName); *reinterpret_cast<uint16*>(&recordData[parentIdOffset]) = parentId; } @@ -701,7 +662,7 @@ void DB2FileLoaderRegularImpl::FillParentLookup(char* dataTable) else { // in data block, must fit - ASSERT(parentId <= 0xFF, "ParentId value %u does not fit into uint8 field (%s in %s)", + ASSERT(parentId <= std::numeric_limits<uint8>::max(), "ParentId value %u does not fit into uint8 field (%s in %s)", parentId, _loadInfo->Fields[_loadInfo->GetFieldIndexByMetaIndex(_loadInfo->Meta->ParentIndexField)].Name, _fileName); *reinterpret_cast<uint8*>(&recordData[parentIdOffset]) = parentId; } @@ -1076,24 +1037,19 @@ char* DB2FileLoaderSparseImpl::AutoProduceData(uint32& maxId, char**& indexTable memset(indexTable, 0, maxId * sizeof(index_entry_t)); char* dataTable = new char[(records + _copyTable.size()) * recordsize]; + memset(dataTable, 0, (records + _copyTable.size()) * recordsize); - // we store flat holders pool as single memory block std::size_t stringFields = _loadInfo->GetStringFieldCount(false); std::size_t localizedStringFields = _loadInfo->GetStringFieldCount(true); - // each string field at load have array of string for each locale - std::size_t stringHoldersRecordPoolSize = localizedStringFields * sizeof(LocalizedString) + (stringFields - localizedStringFields) * sizeof(char*); - std::size_t stringHoldersPoolSize = stringHoldersRecordPoolSize * records; - - char* stringHoldersPool = new char[stringHoldersPoolSize]; - stringPool.push_back(stringHoldersPool); + std::size_t stringsInRecordSize = (stringFields - localizedStringFields) * sizeof(char*); + std::size_t localizedStringsInRecordSize = localizedStringFields * sizeof(LocalizedString); - // DB2 strings expected to have at least empty string - for (std::size_t i = 0; i < stringHoldersPoolSize / sizeof(char*); ++i) - ((char const**)stringHoldersPool)[i] = nullStr; + // string table size is "total size of all records" - RecordCount * "size of record without strings" + std::size_t stringTableSize = _totalRecordSize - (records * ((recordsize - (!_loadInfo->Meta->HasIndexFieldInData() ? 4 : 0)) - stringsInRecordSize - localizedStringsInRecordSize)); - char* stringTable = new char[_totalRecordSize - records * ((recordsize - (!_loadInfo->Meta->HasIndexFieldInData() ? 4 : 0)) - stringFields * sizeof(char*))]; - memset(stringTable, 0, _totalRecordSize - records * ((recordsize - (!_loadInfo->Meta->HasIndexFieldInData() ? 4 : 0)) - stringFields * sizeof(char*))); + char* stringTable = new char[stringTableSize]; + memset(stringTable, 0, stringTableSize); stringPool.push_back(stringTable); char* stringPtr = stringTable; @@ -1128,7 +1084,6 @@ char* DB2FileLoaderSparseImpl::AutoProduceData(uint32& maxId, char**& indexTable ++fieldIndex; } - uint32 stringFieldOffset = 0; for (uint32 x = 0; x < _header->FieldCount; ++x) { for (uint32 z = 0; z < _loadInfo->Meta->Fields[x].ArraySize; ++z) @@ -1157,25 +1112,25 @@ char* DB2FileLoaderSparseImpl::AutoProduceData(uint32& maxId, char**& indexTable break; case FT_STRING: { - LocalizedString** slot = (LocalizedString * *)(&dataTable[offset]); - *slot = (LocalizedString*)(&stringHoldersPool[stringHoldersRecordPoolSize * recordNum + stringFieldOffset]); + LocalizedString* slot = (LocalizedString*)(&dataTable[offset]); for (uint32 locale = 0; locale < TOTAL_LOCALES; ++locale) + { + slot->Str[locale] = nullStr; if (_header->Locale & (1 << locale)) - (*slot)->Str[locale] = stringPtr; + slot->Str[locale] = stringPtr; + } + strcpy(stringPtr, RecordGetString(rawRecord, x, z)); stringPtr += strlen(stringPtr) + 1; - stringFieldOffset += sizeof(LocalizedString); - offset += sizeof(LocalizedString*); + offset += sizeof(LocalizedString); break; } case FT_STRING_NOT_LOCALIZED: { - char const*** slot = (char const***)(&dataTable[offset]); - *slot = (char const**)(&stringHoldersPool[stringHoldersRecordPoolSize * recordNum + stringFieldOffset]); - **slot = stringPtr; + char const** slot = (char const**)(&dataTable[offset]); + *slot = stringPtr; strcpy(stringPtr, RecordGetString(rawRecord, x, z)); stringPtr += strlen(stringPtr) + 1; - stringFieldOffset += sizeof(char*); offset += sizeof(char*); break; } @@ -1246,9 +1201,17 @@ char* DB2FileLoaderSparseImpl::AutoProduceStrings(char** indexTable, uint32 inde uint32 records = _catalog.size(); uint32 recordsize = _loadInfo->Meta->GetRecordSize(); - std::size_t stringFields = _loadInfo->GetStringFieldCount(true); - char* stringTable = new char[_totalRecordSize - records * ((recordsize - (!_loadInfo->Meta->HasIndexFieldInData() ? 4 : 0)) - stringFields * sizeof(char*))]; - memset(stringTable, 0, _totalRecordSize - records * ((recordsize - (!_loadInfo->Meta->HasIndexFieldInData() ? 4 : 0)) - stringFields * sizeof(char*))); + std::size_t stringFields = _loadInfo->GetStringFieldCount(false); + std::size_t localizedStringFields = _loadInfo->GetStringFieldCount(true); + + std::size_t stringsInRecordSize = (stringFields - localizedStringFields) * sizeof(char*); + std::size_t localizedStringsInRecordSize = localizedStringFields * sizeof(LocalizedString); + + // string table size is "total size of all records" - RecordCount * "size of record without strings" + std::size_t stringTableSize = _totalRecordSize - (records * ((recordsize - (!_loadInfo->Meta->HasIndexFieldInData() ? 4 : 0)) - stringsInRecordSize - localizedStringsInRecordSize)); + + char* stringTable = new char[stringTableSize]; + memset(stringTable, 0, stringTableSize); char* stringPtr = stringTable; uint32 y = 0; @@ -1305,11 +1268,11 @@ char* DB2FileLoaderSparseImpl::AutoProduceStrings(char** indexTable, uint32 inde break; case FT_STRING: { - LocalizedString* db2str = *(LocalizedString * *)(&recordData[offset]); + LocalizedString* db2str = (LocalizedString*)(&recordData[offset]); db2str->Str[locale] = stringPtr; strcpy(stringPtr, RecordGetString(rawRecord, x, z)); stringPtr += strlen(stringPtr) + 1; - offset += sizeof(char*); + offset += sizeof(LocalizedString); break; } case FT_STRING_NOT_LOCALIZED: @@ -1999,7 +1962,7 @@ char* DB2FileLoader::AutoProduceData(uint32& count, char**& indexTable, std::vec return _impl->AutoProduceData(count, indexTable, stringPool); } -char* DB2FileLoader::AutoProduceStrings(char** indexTable, uint32 indexTableSize, uint32 locale) +char* DB2FileLoader::AutoProduceStrings(char** indexTable, uint32 indexTableSize, LocaleConstant locale) { return _impl->AutoProduceStrings(indexTable, indexTableSize, locale); } diff --git a/src/common/DataStores/DB2FileLoader.h b/src/common/DataStores/DB2FileLoader.h index 70b6afc2081..768f9c53cef 100644 --- a/src/common/DataStores/DB2FileLoader.h +++ b/src/common/DataStores/DB2FileLoader.h @@ -18,7 +18,7 @@ #ifndef DB2_FILE_LOADER_H #define DB2_FILE_LOADER_H -#include "Define.h" +#include "Common.h" #include <string> #include <vector> @@ -77,7 +77,6 @@ struct TC_COMMON_API DB2FieldMeta struct TC_COMMON_API DB2FileLoadInfo { - DB2FileLoadInfo(); DB2FileLoadInfo(DB2FieldMeta const* fields, std::size_t fieldCount, DB2Meta const* meta); uint32 GetStringFieldCount(bool localizedOnly) const; @@ -174,7 +173,7 @@ public: bool LoadHeaders(DB2FileSource* source, DB2FileLoadInfo const* loadInfo); bool Load(DB2FileSource* source, DB2FileLoadInfo const* loadInfo); char* AutoProduceData(uint32& count, char**& indexTable, std::vector<char*>& stringPool); - char* AutoProduceStrings(char** indexTable, uint32 indexTableSize, uint32 locale); + char* AutoProduceStrings(char** indexTable, uint32 indexTableSize, LocaleConstant locale); void AutoProduceRecordCopies(uint32 records, char** indexTable, char* dataTable); uint32 GetCols() const { return _header.TotalFieldCount; } diff --git a/src/common/DataStores/DB2Meta.cpp b/src/common/DataStores/DB2Meta.cpp index b0e6a7f75e0..b08c67c37ef 100644 --- a/src/common/DataStores/DB2Meta.cpp +++ b/src/common/DataStores/DB2Meta.cpp @@ -16,6 +16,7 @@ */ #include "DB2Meta.h" +#include "Common.h" #include "Errors.h" DB2MetaField::DB2MetaField(DBCFormer type, uint8 arraySize, bool isSigned) : Type(type), ArraySize(arraySize), IsSigned(isSigned) @@ -66,6 +67,8 @@ uint32 DB2Meta::GetRecordSize() const size += 8; break; case FT_STRING: + size += sizeof(LocalizedString); + break; case FT_STRING_NOT_LOCALIZED: size += sizeof(char*); break; @@ -115,6 +118,8 @@ uint32 DB2Meta::GetIndexFieldOffset() const offset += 8; break; case FT_STRING: + offset += sizeof(LocalizedString); + break; case FT_STRING_NOT_LOCALIZED: offset += sizeof(char*); break; @@ -157,6 +162,8 @@ int32 DB2Meta::GetParentIndexFieldOffset() const offset += 8; break; case FT_STRING: + offset += sizeof(LocalizedString); + break; case FT_STRING_NOT_LOCALIZED: offset += sizeof(char*); break; diff --git a/src/server/game/Battlegrounds/Battleground.cpp b/src/server/game/Battlegrounds/Battleground.cpp index 02fcaa0ab25..d77211b44ff 100644 --- a/src/server/game/Battlegrounds/Battleground.cpp +++ b/src/server/game/Battlegrounds/Battleground.cpp @@ -1871,7 +1871,7 @@ bool Battleground::CheckAchievementCriteriaMeet(uint32 criteriaId, Player const* char const* Battleground::GetName() const { - return _battlegroundTemplate->BattlemasterEntry->Name->Str[sWorld->GetDefaultDbcLocale()]; + return _battlegroundTemplate->BattlemasterEntry->Name[sWorld->GetDefaultDbcLocale()]; } BattlegroundTypeId Battleground::GetTypeID(bool getRandom) const diff --git a/src/server/game/Chat/Channels/Channel.cpp b/src/server/game/Chat/Channels/Channel.cpp index 66980d78565..c620a739d45 100644 --- a/src/server/game/Chat/Channels/Channel.cpp +++ b/src/server/game/Chat/Channels/Channel.cpp @@ -123,12 +123,12 @@ void Channel::GetChannelName(std::string& channelName, uint32 channelId, LocaleC if (!(channelEntry->Flags & CHANNEL_DBC_FLAG_GLOBAL)) { if (channelEntry->Flags & CHANNEL_DBC_FLAG_CITY_ONLY) - channelName = Trinity::StringFormat(channelEntry->Name->Str[locale], sObjectMgr->GetTrinityString(LANG_CHANNEL_CITY, locale)); + channelName = Trinity::StringFormat(channelEntry->Name[locale], sObjectMgr->GetTrinityString(LANG_CHANNEL_CITY, locale)); else - channelName = Trinity::StringFormat(channelEntry->Name->Str[locale], ASSERT_NOTNULL(zoneEntry)->AreaName->Str[locale]); + channelName = Trinity::StringFormat(channelEntry->Name[locale], ASSERT_NOTNULL(zoneEntry)->AreaName[locale]); } else - channelName = channelEntry->Name->Str[locale]; + channelName = channelEntry->Name[locale]; } } diff --git a/src/server/game/Chat/Chat.cpp b/src/server/game/Chat/Chat.cpp index 2d18d2d035c..b50e7703f91 100644 --- a/src/server/game/Chat/Chat.cpp +++ b/src/server/game/Chat/Chat.cpp @@ -327,10 +327,10 @@ bool ChatHandler::ExecuteCommandInTable(std::vector<ChatCommand> const& table, c std::string zoneName = "Unknown"; if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId)) { - int32 locale = GetSessionDbcLocale(); - areaName = area->AreaName->Str[locale]; + LocaleConstant locale = GetSessionDbcLocale(); + areaName = area->AreaName[locale]; if (AreaTableEntry const* zone = sAreaTableStore.LookupEntry(area->ParentAreaID)) - zoneName = zone->AreaName->Str[locale]; + zoneName = zone->AreaName[locale]; } sLog->outCommand(m_session->GetAccountId(), "Command: %s [Player: %s (%s) (Account: %u) X: %f Y: %f Z: %f Map: %u (%s) Area: %u (%s) Zone: %s Selected: %s (%s)]", diff --git a/src/server/game/Chat/ChatLink.cpp b/src/server/game/Chat/ChatLink.cpp index d9f28c0b987..5e17714555c 100644 --- a/src/server/game/Chat/ChatLink.cpp +++ b/src/server/game/Chat/ChatLink.cpp @@ -496,10 +496,10 @@ bool SpellChatLink::ValidateName(char* buffer, char const* context) return false; } - for (uint8 i = 0; i < TOTAL_LOCALES; ++i) + for (LocaleConstant i = LOCALE_enUS; i < TOTAL_LOCALES; i = LocaleConstant(i + 1)) { - uint32 skillLineNameLength = strlen(skillLine->DisplayName->Str[i]); - if (skillLineNameLength > 0 && strncmp(skillLine->DisplayName->Str[i], buffer, skillLineNameLength) == 0) + uint32 skillLineNameLength = strlen(skillLine->DisplayName[i]); + if (skillLineNameLength > 0 && strncmp(skillLine->DisplayName[i], buffer, skillLineNameLength) == 0) { // found the prefix, remove it to perform spellname validation below // -2 = strlen(": ") @@ -567,12 +567,12 @@ bool AchievementChatLink::ValidateName(char* buffer, char const* context) { ChatLink::ValidateName(buffer, context); - for (uint8 locale = LOCALE_enUS; locale < TOTAL_LOCALES; ++locale) + for (LocaleConstant locale = LOCALE_enUS; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1)) { if (locale == LOCALE_none) continue; - if (strcmp(_achievement->Title->Str[locale], buffer) == 0) + if (strcmp(_achievement->Title[locale], buffer) == 0) return true; } diff --git a/src/server/game/DataStores/DB2Stores.cpp b/src/server/game/DataStores/DB2Stores.cpp index 3adc0394627..85caeccd077 100644 --- a/src/server/game/DataStores/DB2Stores.cpp +++ b/src/server/game/DataStores/DB2Stores.cpp @@ -439,7 +439,7 @@ template<typename T> constexpr std::size_t GetCppRecordSize(DB2Storage<T> const&) { return sizeof(T); } void LoadDB2(uint32& availableDb2Locales, std::vector<std::string>& errlist, StorageMap& stores, DB2StorageBase* storage, std::string const& db2Path, - uint32 defaultLocale, std::size_t cppRecordSize) + LocaleConstant defaultLocale, std::size_t cppRecordSize) { // validate structure DB2LoadInfo const* loadInfo = storage->GetLoadInfo(); @@ -480,7 +480,7 @@ void LoadDB2(uint32& availableDb2Locales, std::vector<std::string>& errlist, Sto if (defaultLocale != LOCALE_enUS) storage->LoadStringsFromDB(defaultLocale); - for (uint32 i = 0; i < TOTAL_LOCALES; ++i) + for (LocaleConstant i = LOCALE_enUS; i < TOTAL_LOCALES; i = LocaleConstant(i + 1)) { if (defaultLocale == i || i == LOCALE_none) continue; @@ -517,7 +517,7 @@ DB2Manager& DB2Manager::Instance() return instance; } -void DB2Manager::LoadStores(std::string const& dataPath, uint32 defaultLocale) +void DB2Manager::LoadStores(std::string const& dataPath, LocaleConstant defaultLocale) { uint32 oldMSTime = getMSTime(); @@ -1579,18 +1579,18 @@ uint32 DB2Manager::GetRequiredAzeriteLevelForAzeritePowerTier(uint32 azeriteUnlo char const* DB2Manager::GetBroadcastTextValue(BroadcastTextEntry const* broadcastText, LocaleConstant locale /*= DEFAULT_LOCALE*/, uint8 gender /*= GENDER_MALE*/, bool forceGender /*= false*/) { - if ((gender == GENDER_FEMALE || gender == GENDER_NONE) && (forceGender || broadcastText->Text1->Str[DEFAULT_LOCALE][0] != '\0')) + if ((gender == GENDER_FEMALE || gender == GENDER_NONE) && (forceGender || broadcastText->Text1[DEFAULT_LOCALE][0] != '\0')) { - if (broadcastText->Text1->Str[locale][0] != '\0') - return broadcastText->Text1->Str[locale]; + if (broadcastText->Text1[locale][0] != '\0') + return broadcastText->Text1[locale]; - return broadcastText->Text1->Str[DEFAULT_LOCALE]; + return broadcastText->Text1[DEFAULT_LOCALE]; } - if (broadcastText->Text->Str[locale][0] != '\0') - return broadcastText->Text->Str[locale]; + if (broadcastText->Text[locale][0] != '\0') + return broadcastText->Text[locale]; - return broadcastText->Text->Str[DEFAULT_LOCALE]; + return broadcastText->Text[DEFAULT_LOCALE]; } bool DB2Manager::HasCharacterFacialHairStyle(uint8 race, uint8 gender, uint8 variationId) const @@ -1628,10 +1628,10 @@ char const* DB2Manager::GetClassName(uint8 class_, LocaleConstant locale /*= DEF if (!classEntry) return ""; - if (classEntry->Name->Str[locale][0] != '\0') - return classEntry->Name->Str[locale]; + if (classEntry->Name[locale][0] != '\0') + return classEntry->Name[locale]; - return classEntry->Name->Str[DEFAULT_LOCALE]; + return classEntry->Name[DEFAULT_LOCALE]; } uint32 DB2Manager::GetPowerIndexByClass(Powers power, uint32 classId) const @@ -1645,10 +1645,10 @@ char const* DB2Manager::GetChrRaceName(uint8 race, LocaleConstant locale /*= DEF if (!raceEntry) return ""; - if (raceEntry->Name->Str[locale][0] != '\0') - return raceEntry->Name->Str[locale]; + if (raceEntry->Name[locale][0] != '\0') + return raceEntry->Name[locale]; - return raceEntry->Name->Str[DEFAULT_LOCALE]; + return raceEntry->Name[DEFAULT_LOCALE]; } ChrSpecializationEntry const* DB2Manager::GetChrSpecializationByIndex(uint32 class_, uint32 index) const @@ -1665,7 +1665,7 @@ ChrSpecializationEntry const* DB2Manager::GetDefaultChrSpecializationForClass(ui return nullptr; } -char const* DB2Manager::GetCreatureFamilyPetName(uint32 petfamily, uint32 locale) +char const* DB2Manager::GetCreatureFamilyPetName(uint32 petfamily, LocaleConstant locale) { if (!petfamily) return nullptr; @@ -1674,7 +1674,7 @@ char const* DB2Manager::GetCreatureFamilyPetName(uint32 petfamily, uint32 locale if (!petFamily) return nullptr; - return petFamily->Name->Str[locale][0] != '\0' ? petFamily->Name->Str[locale] : nullptr; + return petFamily->Name[locale][0] != '\0' ? petFamily->Name[locale] : nullptr; } enum class CurveInterpolationMode : uint8 diff --git a/src/server/game/DataStores/DB2Stores.h b/src/server/game/DataStores/DB2Stores.h index 7d60c184a9d..d33ba31ceac 100644 --- a/src/server/game/DataStores/DB2Stores.h +++ b/src/server/game/DataStores/DB2Stores.h @@ -275,7 +275,7 @@ public: static DB2Manager& Instance(); - void LoadStores(std::string const& dataPath, uint32 defaultLocale); + void LoadStores(std::string const& dataPath, LocaleConstant defaultLocale); DB2StorageBase const* GetStorage(uint32 type) const; void LoadHotfixData(); @@ -307,7 +307,7 @@ public: static char const* GetChrRaceName(uint8 race, LocaleConstant locale = DEFAULT_LOCALE); ChrSpecializationEntry const* GetChrSpecializationByIndex(uint32 class_, uint32 index) const; ChrSpecializationEntry const* GetDefaultChrSpecializationForClass(uint32 class_) const; - static char const* GetCreatureFamilyPetName(uint32 petfamily, uint32 locale); + static char const* GetCreatureFamilyPetName(uint32 petfamily, LocaleConstant locale); float GetCurveValueAt(uint32 curveId, float x) const; EmotesTextSoundEntry const* GetTextSoundEmoteFor(uint32 emote, uint8 race, uint8 gender, uint8 class_) const; float EvaluateExpectedStat(ExpectedStatType stat, uint32 level, int32 expansion, uint32 contentTuningId, Classes unitClass) const; diff --git a/src/server/game/DataStores/DB2Structure.h b/src/server/game/DataStores/DB2Structure.h index 329903c5e56..859540f7563 100644 --- a/src/server/game/DataStores/DB2Structure.h +++ b/src/server/game/DataStores/DB2Structure.h @@ -18,20 +18,18 @@ #ifndef TRINITY_DB2STRUCTURE_H #define TRINITY_DB2STRUCTURE_H -#include "Define.h" +#include "Common.h" #include "DBCEnums.h" #include "RaceMask.h" #include "Util.h" #pragma pack(push, 1) -struct LocalizedString; - struct AchievementEntry { - LocalizedString* Description; - LocalizedString* Title; - LocalizedString* Reward; + LocalizedString Description; + LocalizedString Title; + LocalizedString Reward; uint32 ID; int16 InstanceID; // -1 = none int8 Faction; // -1 = all, 0 = horde, 1 = alliance @@ -75,7 +73,7 @@ struct AreaTableEntry { uint32 ID; char const* ZoneName; - LocalizedString* AreaName; + LocalizedString AreaName; uint16 ContinentID; uint16 ParentAreaID; int16 AreaBit; @@ -138,7 +136,7 @@ struct ArmorLocationEntry struct ArtifactEntry { - LocalizedString* Name; + LocalizedString Name; uint32 ID; uint16 UiTextureKitID; int32 UiNameColor; @@ -153,7 +151,7 @@ struct ArtifactEntry struct ArtifactAppearanceEntry { - LocalizedString* Name; + LocalizedString Name; uint32 ID; uint16 ArtifactAppearanceSetID; uint8 DisplayIndex; @@ -173,8 +171,8 @@ struct ArtifactAppearanceEntry struct ArtifactAppearanceSetEntry { - LocalizedString* Name; - LocalizedString* Description; + LocalizedString Name; + LocalizedString Description; uint32 ID; uint8 DisplayIndex; uint16 UiCameraID; @@ -254,7 +252,7 @@ struct ArtifactUnlockEntry struct AuctionHouseEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; uint16 FactionID; // id of faction.dbc for player factions associated with city uint8 DepositRate; uint8 ConsignmentRate; @@ -270,8 +268,8 @@ struct AzeriteEmpoweredItemEntry struct AzeriteEssenceEntry { - LocalizedString* Name; - LocalizedString* Description; + LocalizedString Name; + LocalizedString Description; uint32 ID; int32 SpecSetID; }; @@ -279,8 +277,8 @@ struct AzeriteEssenceEntry struct AzeriteEssencePowerEntry { uint32 ID; - LocalizedString* SourceAlliance; - LocalizedString* SourceHorde; + LocalizedString SourceAlliance; + LocalizedString SourceHorde; int32 AzeriteEssenceID; uint8 Tier; int32 MajorPowerDescription; @@ -378,8 +376,8 @@ struct BannedAddonsEntry struct BarberShopStyleEntry { - LocalizedString* DisplayName; - LocalizedString* Description; + LocalizedString DisplayName; + LocalizedString Description; uint32 ID; uint8 Type; // value 0 -> hair, value 2 -> facialhair float CostModifier; @@ -405,8 +403,8 @@ struct BattlePetBreedStateEntry struct BattlePetSpeciesEntry { - LocalizedString* Description; - LocalizedString* SourceText; + LocalizedString Description; + LocalizedString SourceText; uint32 ID; int32 CreatureID; int32 SummonSpellID; @@ -429,10 +427,10 @@ struct BattlePetSpeciesStateEntry struct BattlemasterListEntry { uint32 ID; - LocalizedString* Name; - LocalizedString* GameType; - LocalizedString* ShortDescription; - LocalizedString* LongDescription; + LocalizedString Name; + LocalizedString GameType; + LocalizedString ShortDescription; + LocalizedString LongDescription; int8 InstanceType; int8 MinLevel; int8 MaxLevel; @@ -452,8 +450,8 @@ struct BattlemasterListEntry struct BroadcastTextEntry { - LocalizedString* Text; - LocalizedString* Text1; + LocalizedString Text; + LocalizedString Text1; uint32 ID; uint8 LanguageID; int32 ConditionID; @@ -521,8 +519,8 @@ struct CharStartOutfitEntry struct CharTitlesEntry { uint32 ID; - LocalizedString* Name; - LocalizedString* Name1; + LocalizedString Name; + LocalizedString Name1; int16 MaskID; int8 Flags; }; @@ -530,18 +528,18 @@ struct CharTitlesEntry struct ChatChannelsEntry { uint32 ID; - LocalizedString* Name; - LocalizedString* Shortcut; + LocalizedString Name; + LocalizedString Shortcut; int32 Flags; int8 FactionGroup; }; struct ChrClassesEntry { - LocalizedString* Name; + LocalizedString Name; char const* Filename; - LocalizedString* NameMale; - LocalizedString* NameFemale; + LocalizedString NameMale; + LocalizedString NameFemale; char const* PetNameToken; uint32 ID; uint32 CreateScreenFileDataID; @@ -572,10 +570,10 @@ struct ChrRacesEntry { char const* ClientPrefix; char const* ClientFileString; - LocalizedString* Name; - LocalizedString* NameFemale; - LocalizedString* NameLowercase; - LocalizedString* NameFemaleLowercase; + LocalizedString Name; + LocalizedString NameFemale; + LocalizedString NameLowercase; + LocalizedString NameFemaleLowercase; uint32 ID; int32 Flags; uint32 MaleDisplayId; @@ -623,9 +621,9 @@ struct ChrRacesEntry struct ChrSpecializationEntry { - LocalizedString* Name; - LocalizedString* FemaleName; - LocalizedString* Description; + LocalizedString Name; + LocalizedString FemaleName; + LocalizedString Description; uint32 ID; int8 ClassID; int8 OrderIndex; @@ -747,7 +745,7 @@ struct CreatureDisplayInfoExtraEntry struct CreatureFamilyEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; float MinScale; int8 MinScaleLevel; float MaxScale; @@ -797,7 +795,7 @@ struct CreatureModelDataEntry struct CreatureTypeEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; uint8 Flags; }; @@ -954,7 +952,7 @@ struct CriteriaEntry struct CriteriaTreeEntry { uint32 ID; - LocalizedString* Description; + LocalizedString Description; uint32 Parent; uint32 Amount; int8 Operator; @@ -966,8 +964,8 @@ struct CriteriaTreeEntry struct CurrencyTypesEntry { uint32 ID; - LocalizedString* Name; - LocalizedString* Description; + LocalizedString Name; + LocalizedString Description; uint8 CategoryID; int32 InventoryIconFileID; uint32 SpellWeight; @@ -1027,7 +1025,7 @@ struct DestructibleModelDataEntry struct DifficultyEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; uint8 InstanceType; uint8 OrderIndex; int8 OldEnumValue; @@ -1044,7 +1042,7 @@ struct DifficultyEntry struct DungeonEncounterEntry { - LocalizedString* Name; + LocalizedString Name; uint32 ID; int16 MapID; int8 DifficultyID; @@ -1134,8 +1132,8 @@ struct ExpectedStatModEntry struct FactionEntry { Trinity::RaceMask<int64> ReputationRaceMask[4]; - LocalizedString* Name; - LocalizedString* Description; + LocalizedString Name; + LocalizedString Description; uint32 ID; int16 ReputationIndex; uint16 ParentFactionID; @@ -1227,7 +1225,7 @@ struct GameObjectDisplayInfoEntry struct GameObjectsEntry { - LocalizedString* Name; + LocalizedString Name; DBCPosition3D Pos; float Rot[4]; uint32 ID; @@ -1243,8 +1241,8 @@ struct GameObjectsEntry struct GarrAbilityEntry { - LocalizedString* Name; - LocalizedString* Description; + LocalizedString Name; + LocalizedString Description; uint32 ID; uint8 GarrAbilityCategoryID; uint8 GarrFollowerTypeID; @@ -1256,10 +1254,10 @@ struct GarrAbilityEntry struct GarrBuildingEntry { uint32 ID; - LocalizedString* HordeName; - LocalizedString* AllianceName; - LocalizedString* Description; - LocalizedString* Tooltip; + LocalizedString HordeName; + LocalizedString AllianceName; + LocalizedString Description; + LocalizedString Tooltip; uint8 GarrTypeID; uint8 BuildingType; int32 HordeGameObjectID; @@ -1293,9 +1291,9 @@ struct GarrBuildingPlotInstEntry struct GarrClassSpecEntry { - LocalizedString* ClassSpec; - LocalizedString* ClassSpecMale; - LocalizedString* ClassSpecFemale; + LocalizedString ClassSpec; + LocalizedString ClassSpecMale; + LocalizedString ClassSpecFemale; uint32 ID; uint16 UiTextureAtlasMemberID; uint16 GarrFollItemSetID; @@ -1305,9 +1303,9 @@ struct GarrClassSpecEntry struct GarrFollowerEntry { - LocalizedString* HordeSourceText; - LocalizedString* AllianceSourceText; - LocalizedString* TitleName; + LocalizedString HordeSourceText; + LocalizedString AllianceSourceText; + LocalizedString TitleName; uint32 ID; uint8 GarrTypeID; uint8 GarrFollowerTypeID; @@ -1460,7 +1458,7 @@ struct GuildPerkSpellsEntry struct HeirloomEntry { - LocalizedString* SourceText; + LocalizedString SourceText; uint32 ID; int32 ItemID; int32 LegacyUpgradedItemID; @@ -1567,7 +1565,7 @@ struct ItemArmorTotalEntry struct ItemBagFamilyEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; }; struct ItemBonusEntry @@ -1624,7 +1622,7 @@ struct ItemChildEquipmentEntry struct ItemClassEntry { uint32 ID; - LocalizedString* ClassName; + LocalizedString ClassName; int8 ClassID; float PriceModifier; uint8 Flags; @@ -1741,7 +1739,7 @@ struct ItemLevelSelectorQualitySetEntry struct ItemLimitCategoryEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; uint8 Quantity; uint8 Flags; }; @@ -1767,7 +1765,7 @@ struct ItemModifiedAppearanceEntry struct ItemNameDescriptionEntry { uint32 ID; - LocalizedString* Description; + LocalizedString Description; int32 Color; }; @@ -1782,7 +1780,7 @@ struct ItemPriceBaseEntry struct ItemSearchNameEntry { Trinity::RaceMask<int64> AllowableRace; - LocalizedString* Display; + LocalizedString Display; uint32 ID; uint8 OverallQualityID; uint8 ExpansionID; @@ -1802,7 +1800,7 @@ struct ItemSearchNameEntry struct ItemSetEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; uint32 SetFlags; uint32 RequiredSkill; uint16 RequiredSkillRank; @@ -1822,11 +1820,11 @@ struct ItemSparseEntry { uint32 ID; Trinity::RaceMask<int64> AllowableRace; - LocalizedString* Description; - LocalizedString* Display3; - LocalizedString* Display2; - LocalizedString* Display1; - LocalizedString* Display; + LocalizedString Description; + LocalizedString Display3; + LocalizedString Display2; + LocalizedString Display1; + LocalizedString Display; float DmgVariance; uint32 DurationInInventory; float QualityModifier; @@ -1921,8 +1919,8 @@ struct KeychainEntry struct LFGDungeonsEntry { uint32 ID; - LocalizedString* Name; - LocalizedString* Description; + LocalizedString Name; + LocalizedString Description; uint8 MinLevel; uint16 MaxLevel; uint8 TypeID; @@ -2009,18 +2007,18 @@ struct LockEntry struct MailTemplateEntry { uint32 ID; - LocalizedString* Body; + LocalizedString Body; }; struct MapEntry { uint32 ID; char const* Directory; - LocalizedString* MapName; - LocalizedString* MapDescription0; // Horde - LocalizedString* MapDescription1; // Alliance - LocalizedString* PvpShortDescription; - LocalizedString* PvpLongDescription; + LocalizedString MapName; + LocalizedString MapDescription0; // Horde + LocalizedString MapDescription1; // Alliance + LocalizedString PvpShortDescription; + LocalizedString PvpLongDescription; DBCPosition2D Corpse; // entrance coordinates in ghost mode (in most cases = normal entrance) uint8 MapType; int8 InstanceType; @@ -2074,7 +2072,7 @@ struct MapEntry struct MapDifficultyEntry { uint32 ID; - LocalizedString* Message; // m_message_lang (text showed when transfer to map failed) + LocalizedString Message; // m_message_lang (text showed when transfer to map failed) int32 DifficultyID; int32 LockID; int8 ResetInterval; @@ -2109,9 +2107,9 @@ struct ModifierTreeEntry struct MountEntry { - LocalizedString* Name; - LocalizedString* SourceText; - LocalizedString* Description; + LocalizedString Name; + LocalizedString SourceText; + LocalizedString Description; uint32 ID; uint16 MountTypeID; uint16 Flags; @@ -2226,7 +2224,7 @@ struct PhaseXPhaseGroupEntry struct PlayerConditionEntry { Trinity::RaceMask<int64> RaceMask; - LocalizedString* FailureDescription; + LocalizedString FailureDescription; uint32 ID; uint16 MinLevel; uint16 MaxLevel; @@ -2338,7 +2336,7 @@ struct PowerTypeEntry struct PrestigeLevelInfoEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; int32 PrestigeLevel; int32 BadgeTextureFileDataID; uint8 Flags; @@ -2368,7 +2366,7 @@ struct PVPItemEntry struct PvpTalentEntry { - LocalizedString* Description; + LocalizedString Description; uint32 ID; int32 SpecID; int32 SpellID; @@ -2418,7 +2416,7 @@ struct QuestPackageItemEntry struct QuestSortEntry { uint32 ID; - LocalizedString* SortName; + LocalizedString SortName; int8 UiOrderIndex; }; @@ -2482,7 +2480,7 @@ struct ScalingStatDistributionEntry struct ScenarioEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; uint16 AreaTableID; uint8 Type; uint8 Flags; @@ -2492,8 +2490,8 @@ struct ScenarioEntry struct ScenarioStepEntry { uint32 ID; - LocalizedString* Description; - LocalizedString* Title; + LocalizedString Description; + LocalizedString Title; uint16 ScenarioID; uint32 Criteriatreeid; uint16 RewardQuestID; @@ -2540,10 +2538,10 @@ struct SceneScriptTextEntry struct SkillLineEntry { - LocalizedString* DisplayName; - LocalizedString* AlternateVerb; - LocalizedString* Description; - LocalizedString* HordeDisplayName; + LocalizedString DisplayName; + LocalizedString AlternateVerb; + LocalizedString Description; + LocalizedString HordeDisplayName; char const* OverrideSourceInfoDisplayName; uint32 ID; int8 CategoryID; @@ -2608,7 +2606,7 @@ struct SoundKitEntry struct SpecializationSpellsEntry { - LocalizedString* Description; + LocalizedString Description; uint32 ID; uint16 SpecID; int32 SpellID; @@ -2688,7 +2686,7 @@ struct SpellCategoriesEntry struct SpellCategoryEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; int8 Flags; uint8 UsesPerWeek; int8 MaxCharges; @@ -2768,7 +2766,7 @@ struct SpellEquippedItemsEntry struct SpellFocusObjectEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; }; struct SpellInterruptsEntry @@ -2786,8 +2784,8 @@ struct SpellInterruptsEntry struct SpellItemEnchantmentEntry { uint32 ID; - LocalizedString* Name; - LocalizedString* HordeName; + LocalizedString Name; + LocalizedString HordeName; uint32 EffectArg[MAX_ITEM_ENCHANTMENT_EFFECTS]; float EffectScalingPoints[MAX_ITEM_ENCHANTMENT_EFFECTS]; uint32 TransmogPlayerConditionID; @@ -2859,7 +2857,7 @@ struct SpellMiscEntry struct SpellNameEntry { uint32 ID; // SpellID - LocalizedString* Name; + LocalizedString Name; }; struct SpellPowerEntry @@ -2916,8 +2914,8 @@ struct SpellRadiusEntry struct SpellRangeEntry { uint32 ID; - LocalizedString* DisplayName; - LocalizedString* DisplayNameShort; + LocalizedString DisplayName; + LocalizedString DisplayNameShort; uint8 Flags; float RangeMin[2]; float RangeMax[2]; @@ -2957,7 +2955,7 @@ struct SpellShapeshiftEntry struct SpellShapeshiftFormEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; int8 CreatureType; int32 Flags; int32 AttackIconFileID; @@ -3040,7 +3038,7 @@ struct TactKeyEntry struct TalentEntry { uint32 ID; - LocalizedString* Description; + LocalizedString Description; uint8 TierID; uint8 Flags; uint8 ColumnIndex; @@ -3053,7 +3051,7 @@ struct TalentEntry struct TaxiNodesEntry { - LocalizedString* Name; + LocalizedString Name; DBCPosition3D Pos; DBCPosition2D MapOffset; DBCPosition2D FlightMapOffset; @@ -3094,14 +3092,14 @@ struct TaxiPathNodeEntry struct TotemCategoryEntry { uint32 ID; - LocalizedString* Name; + LocalizedString Name; uint8 TotemCategoryType; int32 TotemCategoryMask; }; struct ToyEntry { - LocalizedString* SourceText; + LocalizedString SourceText; uint32 ID; int32 ItemID; uint8 Flags; @@ -3116,7 +3114,7 @@ struct TransmogHolidayEntry struct TransmogSetEntry { - LocalizedString* Name; + LocalizedString Name; uint32 ID; int32 ClassMask; uint32 TrackingQuestID; @@ -3133,7 +3131,7 @@ struct TransmogSetEntry struct TransmogSetGroupEntry { - LocalizedString* Name; + LocalizedString Name; uint32 ID; }; @@ -3164,7 +3162,7 @@ struct TransportRotationEntry struct UiMapEntry { - LocalizedString* Name; + LocalizedString Name; uint32 ID; int32 ParentUiMapID; int32 Flags; @@ -3217,10 +3215,10 @@ struct UiMapXMapArtEntry struct UnitPowerBarEntry { uint32 ID; - LocalizedString* Name; - LocalizedString* Cost; - LocalizedString* OutOfError; - LocalizedString* ToolTip; + LocalizedString Name; + LocalizedString Cost; + LocalizedString OutOfError; + LocalizedString ToolTip; uint32 MinPower; uint32 MaxPower; uint32 StartPower; @@ -3343,7 +3341,7 @@ struct VehicleSeatEntry struct WMOAreaTableEntry { - LocalizedString* AreaName; + LocalizedString AreaName; uint32 ID; uint16 WmoID; // used in root WMO uint8 NameSetID; // used in adt file diff --git a/src/server/game/DungeonFinding/LFGMgr.cpp b/src/server/game/DungeonFinding/LFGMgr.cpp index 72299af8e40..a85252c4806 100644 --- a/src/server/game/DungeonFinding/LFGMgr.cpp +++ b/src/server/game/DungeonFinding/LFGMgr.cpp @@ -49,7 +49,7 @@ requiredItemLevel(0) { } -LFGDungeonData::LFGDungeonData(LFGDungeonsEntry const* dbc) : id(dbc->ID), name(dbc->Name->Str[sWorld->GetDefaultDbcLocale()]), map(dbc->MapID), +LFGDungeonData::LFGDungeonData(LFGDungeonsEntry const* dbc) : id(dbc->ID), name(dbc->Name[sWorld->GetDefaultDbcLocale()]), map(dbc->MapID), type(uint8(dbc->TypeID)), expansion(uint8(dbc->ExpansionLevel)), group(uint8(dbc->GroupID)), minlevel(uint8(dbc->MinLevel)), maxlevel(uint8(dbc->MaxLevel)), difficulty(Difficulty(dbc->DifficultyID)), seasonal((dbc->Flags[0] & LFG_FLAG_SEASONAL) != 0), x(0.0f), y(0.0f), z(0.0f), o(0.0f), diff --git a/src/server/game/Entities/Item/Item.cpp b/src/server/game/Entities/Item/Item.cpp index 913d51d1f22..a2a98314834 100644 --- a/src/server/game/Entities/Item/Item.cpp +++ b/src/server/game/Entities/Item/Item.cpp @@ -503,7 +503,7 @@ std::string Item::GetNameForLocaleIdx(LocaleConstant locale) const { ItemTemplate const* itemTemplate = GetTemplate(); if (ItemNameDescriptionEntry const* suffix = sItemNameDescriptionStore.LookupEntry(_bonusData.Suffix)) - return Trinity::StringFormat("%s %s", itemTemplate->GetName(locale), suffix->Description->Str[locale]); + return Trinity::StringFormat("%s %s", itemTemplate->GetName(locale), suffix->Description[locale]); return itemTemplate->GetName(locale); } diff --git a/src/server/game/Entities/Item/ItemTemplate.cpp b/src/server/game/Entities/Item/ItemTemplate.cpp index 003382a2630..b43ff8d31c8 100644 --- a/src/server/game/Entities/Item/ItemTemplate.cpp +++ b/src/server/game/Entities/Item/ItemTemplate.cpp @@ -45,10 +45,10 @@ int32 const SocketColorToGemTypeMask[19] = char const* ItemTemplate::GetName(LocaleConstant locale) const { - if (!strlen(ExtendedData->Display->Str[locale])) + if (!strlen(ExtendedData->Display[locale])) return GetDefaultLocaleName(); - return ExtendedData->Display->Str[locale]; + return ExtendedData->Display[locale]; } @@ -112,7 +112,7 @@ uint32 ItemTemplate::GetSkill() const char const* ItemTemplate::GetDefaultLocaleName() const { - return ExtendedData->Display->Str[sWorld->GetDefaultDbcLocale()]; + return ExtendedData->Display[sWorld->GetDefaultDbcLocale()]; } uint32 ItemTemplate::GetArmor(uint32 itemLevel) const diff --git a/src/server/game/Entities/Pet/Pet.cpp b/src/server/game/Entities/Pet/Pet.cpp index bb6d87b2072..04349d64a9a 100644 --- a/src/server/game/Entities/Pet/Pet.cpp +++ b/src/server/game/Entities/Pet/Pet.cpp @@ -718,7 +718,7 @@ bool Pet::CreateBaseAtCreature(Creature* creature) SetDisplayId(creature->GetDisplayId()); if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family)) - SetName(cFamily->Name->Str[GetOwner()->GetSession()->GetSessionDbcLocale()]); + SetName(cFamily->Name[GetOwner()->GetSession()->GetSessionDbcLocale()]); else SetName(creature->GetNameForLocaleIdx(sObjectMgr->GetDBCLocaleIndex())); @@ -731,7 +731,7 @@ bool Pet::CreateBaseAtCreatureInfo(CreatureTemplate const* cinfo, Unit* owner) return false; if (CreatureFamilyEntry const* cFamily = sCreatureFamilyStore.LookupEntry(cinfo->family)) - SetName(cFamily->Name->Str[GetOwner()->GetSession()->GetSessionDbcLocale()]); + SetName(cFamily->Name[GetOwner()->GetSession()->GetSessionDbcLocale()]); Relocate(owner->GetPositionX(), owner->GetPositionY(), owner->GetPositionZ(), owner->GetOrientation()); diff --git a/src/server/game/Entities/Player/Player.cpp b/src/server/game/Entities/Player/Player.cpp index 6ed5ecd5dbd..22336c85617 100644 --- a/src/server/game/Entities/Player/Player.cpp +++ b/src/server/game/Entities/Player/Player.cpp @@ -19796,7 +19796,7 @@ void Player::_LoadBoundInstances(PreparedQueryResult result) bool deleteInstance = false; MapEntry const* mapEntry = sMapStore.LookupEntry(mapId); - std::string mapname = mapEntry ? mapEntry->MapName->Str[sWorld->GetDefaultDbcLocale()] : "Unknown"; + std::string mapname = mapEntry ? mapEntry->MapName[sWorld->GetDefaultDbcLocale()] : "Unknown"; if (!mapEntry || !mapEntry->IsDungeon()) { @@ -20116,7 +20116,7 @@ bool Player::Satisfy(AccessRequirement const* ar, uint32 target_map, bool report { if (missingQuest && !ar->questFailedText.empty()) ChatHandler(GetSession()).PSendSysMessage("%s", ar->questFailedText.c_str()); - else if (mapDiff->Message->Str[sWorld->GetDefaultDbcLocale()][0] != '\0') // if (missingAchievement) covered by this case + else if (mapDiff->Message[sWorld->GetDefaultDbcLocale()][0] != '\0') // if (missingAchievement) covered by this case SendTransferAborted(target_map, TRANSFER_ABORT_DIFFICULTY, target_difficulty); else if (missingItem) GetSession()->SendNotification(GetSession()->GetTrinityString(LANG_LEVEL_MINREQUIRED_AND_ITEM), LevelMin, ASSERT_NOTNULL(sObjectMgr->GetItemTemplate(missingItem))->GetName(GetSession()->GetSessionDbcLocale())); @@ -28088,9 +28088,9 @@ std::string Player::GetMapAreaAndZoneString() const std::string zoneName = "Unknown"; if (AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId)) { - areaName = area->AreaName->Str[GetSession()->GetSessionDbcLocale()]; + areaName = area->AreaName[GetSession()->GetSessionDbcLocale()]; if (AreaTableEntry const* zone = sAreaTableStore.LookupEntry(area->ParentAreaID)) - zoneName = zone->AreaName->Str[GetSession()->GetSessionDbcLocale()]; + zoneName = zone->AreaName[GetSession()->GetSessionDbcLocale()]; } std::ostringstream str; diff --git a/src/server/game/Globals/ObjectMgr.cpp b/src/server/game/Globals/ObjectMgr.cpp index c616ee11270..2fb6dfa2f51 100644 --- a/src/server/game/Globals/ObjectMgr.cpp +++ b/src/server/game/Globals/ObjectMgr.cpp @@ -5636,7 +5636,7 @@ void ObjectMgr::LoadInstanceEncounters() if (lastEncounterDungeon && !sLFGMgr->GetLFGDungeonEntry(lastEncounterDungeon)) { TC_LOG_ERROR("sql.sql", "Table `instance_encounters` has an encounter %u (%s) marked as final for invalid dungeon id %u, skipped!", - entry, dungeonEncounter->Name->Str[sWorld->GetDefaultDbcLocale()], lastEncounterDungeon); + entry, dungeonEncounter->Name[sWorld->GetDefaultDbcLocale()], lastEncounterDungeon); continue; } @@ -5646,7 +5646,7 @@ void ObjectMgr::LoadInstanceEncounters() if (itr != dungeonLastBosses.end()) { TC_LOG_ERROR("sql.sql", "Table `instance_encounters` specified encounter %u (%s) as last encounter but %u (%s) is already marked as one, skipped!", - entry, dungeonEncounter->Name->Str[sWorld->GetDefaultDbcLocale()], itr->second.first, itr->second.second->Name->Str[sWorld->GetDefaultDbcLocale()]); + entry, dungeonEncounter->Name[sWorld->GetDefaultDbcLocale()], itr->second.first, itr->second.second->Name[sWorld->GetDefaultDbcLocale()]); continue; } @@ -5661,7 +5661,7 @@ void ObjectMgr::LoadInstanceEncounters() if (!creatureInfo) { TC_LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid creature (entry %u) linked to the encounter %u (%s), skipped!", - creditEntry, entry, dungeonEncounter->Name->Str[sWorld->GetDefaultDbcLocale()]); + creditEntry, entry, dungeonEncounter->Name[sWorld->GetDefaultDbcLocale()]); continue; } const_cast<CreatureTemplate*>(creatureInfo)->flags_extra |= CREATURE_FLAG_EXTRA_DUNGEON_BOSS; @@ -5679,13 +5679,13 @@ void ObjectMgr::LoadInstanceEncounters() if (!sSpellMgr->GetSpellInfo(creditEntry, DIFFICULTY_NONE)) { TC_LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid spell (entry %u) linked to the encounter %u (%s), skipped!", - creditEntry, entry, dungeonEncounter->Name->Str[sWorld->GetDefaultDbcLocale()]); + creditEntry, entry, dungeonEncounter->Name[sWorld->GetDefaultDbcLocale()]); continue; } break; default: TC_LOG_ERROR("sql.sql", "Table `instance_encounters` has an invalid credit type (%u) for encounter %u (%s), skipped!", - creditType, entry, dungeonEncounter->Name->Str[sWorld->GetDefaultDbcLocale()]); + creditType, entry, dungeonEncounter->Name[sWorld->GetDefaultDbcLocale()]); continue; } @@ -7025,7 +7025,7 @@ void ObjectMgr::LoadGameObjectTemplate() go.entry = db2go->ID; go.type = db2go->TypeID; go.displayId = db2go->DisplayID; - go.name = db2go->Name->Str[sWorld->GetDefaultDbcLocale()]; + go.name = db2go->Name[sWorld->GetDefaultDbcLocale()]; go.size = db2go->Scale; memset(go.raw.data, 0, sizeof(go.raw.data)); memcpy(go.raw.data, db2go->PropValue, std::min(sizeof(db2go->PropValue), sizeof(go.raw.data))); diff --git a/src/server/game/Handlers/MailHandler.cpp b/src/server/game/Handlers/MailHandler.cpp index 56eb085e78c..6232934b161 100644 --- a/src/server/game/Handlers/MailHandler.cpp +++ b/src/server/game/Handlers/MailHandler.cpp @@ -623,7 +623,7 @@ void WorldSession::HandleMailCreateTextItem(WorldPackets::Mail::MailCreateTextIt { MailTemplateEntry const* mailTemplateEntry = sMailTemplateStore.LookupEntry(m->mailTemplateId); ASSERT(mailTemplateEntry); - bodyItem->SetText(mailTemplateEntry->Body->Str[GetSessionDbcLocale()]); + bodyItem->SetText(mailTemplateEntry->Body[GetSessionDbcLocale()]); } else bodyItem->SetText(m->body); diff --git a/src/server/game/Handlers/MiscHandler.cpp b/src/server/game/Handlers/MiscHandler.cpp index 11b838d090e..ed0061a0ee9 100644 --- a/src/server/game/Handlers/MiscHandler.cpp +++ b/src/server/game/Handlers/MiscHandler.cpp @@ -189,7 +189,7 @@ void WorldSession::HandleWhoOpcode(WorldPackets::Who::WhoRequestPkt& whoRequest) { std::string aName; if (AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(target.GetZoneId())) - aName = areaEntry->AreaName->Str[GetSessionDbcLocale()]; + aName = areaEntry->AreaName[GetSessionDbcLocale()]; bool show = false; for (size_t i = 0; i < wWords.size(); ++i) @@ -564,7 +564,7 @@ void WorldSession::HandleAreaTriggerOpcode(WorldPackets::AreaTrigger::AreaTrigge case Map::CANNOT_ENTER_INSTANCE_BIND_MISMATCH: if (MapEntry const* entry = sMapStore.LookupEntry(at->target_mapId)) { - char const* mapName = entry->MapName->Str[player->GetSession()->GetSessionDbcLocale()]; + char const* mapName = entry->MapName[player->GetSession()->GetSessionDbcLocale()]; TC_LOG_DEBUG("maps", "MAP: Player '%s' cannot enter instance map '%s' because their permanent bind is incompatible with their group's", player->GetName().c_str(), mapName); // is there a special opcode for this? // @todo figure out how to get player localized difficulty string (e.g. "10 player", "Heroic" etc) diff --git a/src/server/game/Instances/InstanceSaveMgr.cpp b/src/server/game/Instances/InstanceSaveMgr.cpp index fdeee7535a1..f04ae452c0b 100644 --- a/src/server/game/Instances/InstanceSaveMgr.cpp +++ b/src/server/game/Instances/InstanceSaveMgr.cpp @@ -651,7 +651,7 @@ void InstanceSaveManager::_ResetOrWarnAll(uint32 mapid, Difficulty difficulty, b MapEntry const* mapEntry = sMapStore.LookupEntry(mapid); if (!mapEntry->Instanceable()) return; - TC_LOG_DEBUG("misc", "InstanceSaveManager::ResetOrWarnAll: Processing map %s (%u) on difficulty %u (warn? %u)", mapEntry->MapName->Str[sWorld->GetDefaultDbcLocale()], mapid, uint8(difficulty), warn); + TC_LOG_DEBUG("misc", "InstanceSaveManager::ResetOrWarnAll: Processing map %s (%u) on difficulty %u (warn? %u)", mapEntry->MapName[sWorld->GetDefaultDbcLocale()], mapid, uint8(difficulty), warn); time_t now = time(NULL); diff --git a/src/server/game/Instances/InstanceScript.cpp b/src/server/game/Instances/InstanceScript.cpp index 4f124dd9567..a5589e3750f 100644 --- a/src/server/game/Instances/InstanceScript.cpp +++ b/src/server/game/Instances/InstanceScript.cpp @@ -733,7 +733,7 @@ void InstanceScript::UpdateEncounterState(EncounterCreditType type, uint32 credi { dungeonId = encounter->lastEncounterDungeon; TC_LOG_DEBUG("lfg", "UpdateEncounterState: Instance %s (instanceId %u) completed encounter %s. Credit Dungeon: %u", - instance->GetMapName(), instance->GetInstanceId(), encounter->dbcEntry->Name->Str[sWorld->GetDefaultDbcLocale()], dungeonId); + instance->GetMapName(), instance->GetInstanceId(), encounter->dbcEntry->Name[sWorld->GetDefaultDbcLocale()], dungeonId); break; } } diff --git a/src/server/game/Maps/Map.cpp b/src/server/game/Maps/Map.cpp index 1406014504f..a76fa61851d 100644 --- a/src/server/game/Maps/Map.cpp +++ b/src/server/game/Maps/Map.cpp @@ -2963,7 +2963,7 @@ bool Map::CheckGridIntegrity(Creature* c, bool moved) const char const* Map::GetMapName() const { - return i_mapEntry ? i_mapEntry->MapName->Str[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0"; + return i_mapEntry ? i_mapEntry->MapName[sWorld->GetDefaultDbcLocale()] : "UNNAMEDMAP\x0"; } void Map::SendInitSelf(Player* player) diff --git a/src/server/game/Maps/MapManager.cpp b/src/server/game/Maps/MapManager.cpp index e01d2dc05b6..6a441a21f9f 100644 --- a/src/server/game/Maps/MapManager.cpp +++ b/src/server/game/Maps/MapManager.cpp @@ -173,7 +173,7 @@ Map::EnterState MapManager::PlayerCannotEnter(uint32 mapid, Player* player, bool if (player->IsGameMaster()) return Map::CAN_ENTER; - char const* mapName = entry->MapName->Str[sWorld->GetDefaultDbcLocale()]; + char const* mapName = entry->MapName[sWorld->GetDefaultDbcLocale()]; Group* group = player->GetGroup(); if (entry->IsRaid() && entry->Expansion() >= sWorld->getIntConfig(CONFIG_EXPANSION)) // can only enter in a raid group but raids from old expansion don't need a group diff --git a/src/server/game/Maps/TransportMgr.h b/src/server/game/Maps/TransportMgr.h index c5478070ab5..49f1b2b0083 100644 --- a/src/server/game/Maps/TransportMgr.h +++ b/src/server/game/Maps/TransportMgr.h @@ -102,7 +102,7 @@ typedef std::map<uint32, TransportAnimation> TransportAnimationContainer; class TC_GAME_API TransportMgr { - friend void DB2Manager::LoadStores(std::string const&, uint32); + friend void DB2Manager::LoadStores(std::string const&, LocaleConstant); public: static TransportMgr* instance(); diff --git a/src/server/game/Spells/SpellInfo.cpp b/src/server/game/Spells/SpellInfo.cpp index fe9d12f8248..4296753a1d9 100644 --- a/src/server/game/Spells/SpellInfo.cpp +++ b/src/server/game/Spells/SpellInfo.cpp @@ -1083,7 +1083,7 @@ SpellInfo::SpellInfo(SpellNameEntry const* spellName, ::Difficulty difficulty, S } _effects.shrink_to_fit(); - SpellName = spellName->Name; + SpellName = &spellName->Name; // SpellMiscEntry SpellMiscEntry const* _misc = data.Misc; diff --git a/src/server/scripts/Commands/cs_character.cpp b/src/server/scripts/Commands/cs_character.cpp index 9f43772a430..8d46abfa58e 100644 --- a/src/server/scripts/Commands/cs_character.cpp +++ b/src/server/scripts/Commands/cs_character.cpp @@ -279,7 +279,7 @@ public: if (titleInfo && target->HasTitle(titleInfo)) { - std::string name = (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[handler->GetSessionDbcLocale()]; + std::string name = (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[handler->GetSessionDbcLocale()]; if (name.empty()) continue; @@ -647,7 +647,7 @@ public: { FactionState const& faction = itr->second; FactionEntry const* factionEntry = sFactionStore.LookupEntry(faction.ID); - char const* factionName = factionEntry ? factionEntry->Name->Str[loc] : "#Not found#"; + char const* factionName = factionEntry ? factionEntry->Name[loc] : "#Not found#"; ReputationRank rank = target->GetReputationMgr().GetRank(factionEntry); std::string rankName = handler->GetTrinityString(ReputationRankStrIndex[rank]); std::ostringstream ss; diff --git a/src/server/scripts/Commands/cs_go.cpp b/src/server/scripts/Commands/cs_go.cpp index bfc3c8956dd..53efc8bf5b4 100644 --- a/src/server/scripts/Commands/cs_go.cpp +++ b/src/server/scripts/Commands/cs_go.cpp @@ -510,7 +510,7 @@ public: if (map->Instanceable()) { - handler->PSendSysMessage(LANG_INVALID_ZONE_MAP, areaId, areaEntry->AreaName->Str[handler->GetSessionDbcLocale()], map->GetId(), map->GetMapName()); + handler->PSendSysMessage(LANG_INVALID_ZONE_MAP, areaId, areaEntry->AreaName[handler->GetSessionDbcLocale()], map->GetId(), map->GetMapName()); handler->SetSentErrorMessage(true); return false; } diff --git a/src/server/scripts/Commands/cs_group.cpp b/src/server/scripts/Commands/cs_group.cpp index f6866734a7c..284f50942c4 100644 --- a/src/server/scripts/Commands/cs_group.cpp +++ b/src/server/scripts/Commands/cs_group.cpp @@ -361,7 +361,7 @@ public: { AreaTableEntry const* zone = sAreaTableStore.LookupEntry(area->ParentAreaID); if (zone) - zoneName = zone->AreaName->Str[handler->GetSessionDbcLocale()]; + zoneName = zone->AreaName[handler->GetSessionDbcLocale()]; } } else diff --git a/src/server/scripts/Commands/cs_learn.cpp b/src/server/scripts/Commands/cs_learn.cpp index 1de918cbc81..a9c9db0c816 100644 --- a/src/server/scripts/Commands/cs_learn.cpp +++ b/src/server/scripts/Commands/cs_learn.cpp @@ -370,20 +370,20 @@ public: !skillInfo->CanLink) // only prof with recipes have set continue; - int locale = handler->GetSessionDbcLocale(); - name = skillInfo->DisplayName->Str[locale]; + LocaleConstant locale = handler->GetSessionDbcLocale(); + name = skillInfo->DisplayName[locale]; if (name.empty()) continue; if (!Utf8FitTo(name, namePart)) { - locale = 0; - for (; locale < TOTAL_LOCALES; ++locale) + locale = LOCALE_enUS; + for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1)) { if (locale == handler->GetSessionDbcLocale()) continue; - name = skillInfo->DisplayName->Str[locale]; + name = skillInfo->DisplayName[locale]; if (name.empty()) continue; diff --git a/src/server/scripts/Commands/cs_lookup.cpp b/src/server/scripts/Commands/cs_lookup.cpp index 7db339d63c6..6c16d7e6005 100644 --- a/src/server/scripts/Commands/cs_lookup.cpp +++ b/src/server/scripts/Commands/cs_lookup.cpp @@ -108,20 +108,20 @@ public: AreaTableEntry const* areaEntry = sAreaTableStore.LookupEntry(i); if (areaEntry) { - int32 locale = handler->GetSessionDbcLocale(); - std::string name = areaEntry->AreaName->Str[locale]; + LocaleConstant locale = handler->GetSessionDbcLocale(); + std::string name = areaEntry->AreaName[locale]; if (name.empty()) continue; if (!Utf8FitTo(name, wNamePart)) { - locale = 0; - for (; locale < TOTAL_LOCALES; ++locale) + locale = LOCALE_enUS; + for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1)) { if (locale == handler->GetSessionDbcLocale()) continue; - name = areaEntry->AreaName->Str[locale]; + name = areaEntry->AreaName[locale]; if (name.empty()) continue; @@ -320,20 +320,20 @@ public: { FactionState const* factionState = target ? target->GetReputationMgr().GetState(factionEntry) : NULL; - int locale = handler->GetSessionDbcLocale(); - std::string name = factionEntry->Name->Str[locale]; + LocaleConstant locale = handler->GetSessionDbcLocale(); + std::string name = factionEntry->Name[locale]; if (name.empty()) continue; if (!Utf8FitTo(name, wNamePart)) { - locale = 0; - for (; locale < TOTAL_LOCALES; ++locale) + locale = LOCALE_enUS; + for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1)) { if (locale == handler->GetSessionDbcLocale()) continue; - name = factionEntry->Name->Str[locale]; + name = factionEntry->Name[locale]; if (name.empty()) continue; @@ -468,20 +468,20 @@ public: ItemSetEntry const* set = sItemSetStore.LookupEntry(id); if (set) { - int32 locale = handler->GetSessionDbcLocale(); - std::string name = set->Name->Str[locale]; + LocaleConstant locale = handler->GetSessionDbcLocale(); + std::string name = set->Name[locale]; if (name.empty()) continue; if (!Utf8FitTo(name, wNamePart)) { - locale = 0; - for (; locale < TOTAL_LOCALES; ++locale) + locale = LOCALE_enUS; + for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1)) { if (locale == handler->GetSessionDbcLocale()) continue; - name = set->Name->Str[locale]; + name = set->Name[locale]; if (name.empty()) continue; @@ -757,20 +757,20 @@ public: SkillLineEntry const* skillInfo = sSkillLineStore.LookupEntry(id); if (skillInfo) { - int locale = handler->GetSessionDbcLocale(); - std::string name = skillInfo->DisplayName->Str[locale]; + LocaleConstant locale = handler->GetSessionDbcLocale(); + std::string name = skillInfo->DisplayName[locale]; if (name.empty()) continue; if (!Utf8FitTo(name, wNamePart)) { - locale = 0; - for (; locale < TOTAL_LOCALES; ++locale) + locale = LOCALE_enUS; + for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1)) { if (locale == handler->GetSessionDbcLocale()) continue; - name = skillInfo->DisplayName->Str[locale]; + name = skillInfo->DisplayName[locale]; if (name.empty()) continue; @@ -844,15 +844,15 @@ public: { if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(spellName->ID, DIFFICULTY_NONE)) { - int locale = handler->GetSessionDbcLocale(); + LocaleConstant locale = handler->GetSessionDbcLocale(); std::string name = spellInfo->SpellName->Str[locale]; if (name.empty()) continue; if (!Utf8FitTo(name, wNamePart)) { - locale = 0; - for (; locale < TOTAL_LOCALES; ++locale) + locale = LOCALE_enUS; + for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1)) { if (locale == handler->GetSessionDbcLocale()) continue; @@ -939,7 +939,7 @@ public: if (SpellInfo const* spellInfo = sSpellMgr->GetSpellInfo(id, DIFFICULTY_NONE)) { - int locale = handler->GetSessionDbcLocale(); + LocaleConstant locale = handler->GetSessionDbcLocale(); std::string name = spellInfo->SpellName->Str[locale]; if (name.empty()) { @@ -1014,12 +1014,12 @@ public: bool found = false; uint32 count = 0; uint32 maxResults = sWorld->getIntConfig(CONFIG_MAX_RESULTS_LOOKUP_COMMANDS); - int32 locale = handler->GetSessionDbcLocale(); + LocaleConstant locale = handler->GetSessionDbcLocale(); // Search in TaxiNodes.dbc for (TaxiNodesEntry const* nodeEntry : sTaxiNodesStore) { - std::string name = nodeEntry->Name->Str[locale]; + std::string name = nodeEntry->Name[locale]; if (name.empty()) continue; @@ -1141,21 +1141,21 @@ public: if (target && target->getGender() != gender) continue; - int32 locale = handler->GetSessionDbcLocale(); - std::string name = (gender == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[locale]; + LocaleConstant locale = handler->GetSessionDbcLocale(); + std::string name = (gender == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[locale]; if (name.empty()) continue; if (!Utf8FitTo(name, wNamePart)) { - locale = 0; - for (; locale < TOTAL_LOCALES; ++locale) + locale = LOCALE_enUS; + for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1)) { if (locale == handler->GetSessionDbcLocale()) continue; - name = (gender == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[locale]; + name = (gender == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[locale]; if (name.empty()) continue; @@ -1218,20 +1218,20 @@ public: { if (MapEntry const* mapInfo = sMapStore.LookupEntry(id)) { - int32 locale = handler->GetSessionDbcLocale(); - std::string name = mapInfo->MapName->Str[locale]; + LocaleConstant locale = handler->GetSessionDbcLocale(); + std::string name = mapInfo->MapName[locale]; if (name.empty()) continue; if (!Utf8FitTo(name, wNamePart) && handler->GetSession()) { - locale = 0; - for (; locale < TOTAL_LOCALES; ++locale) + locale = LOCALE_enUS; + for (; locale < TOTAL_LOCALES; locale = LocaleConstant(locale + 1)) { if (locale == handler->GetSessionDbcLocale()) continue; - name = mapInfo->MapName->Str[locale]; + name = mapInfo->MapName[locale]; if (name.empty()) continue; diff --git a/src/server/scripts/Commands/cs_message.cpp b/src/server/scripts/Commands/cs_message.cpp index 1a889ec1122..cccbd6a37fa 100644 --- a/src/server/scripts/Commands/cs_message.cpp +++ b/src/server/scripts/Commands/cs_message.cpp @@ -83,7 +83,7 @@ public: if (!channelEntry) continue; - if (strstr(channelEntry->Name->Str[handler->GetSessionDbcLocale()], channelStr)) + if (strstr(channelEntry->Name[handler->GetSessionDbcLocale()], channelStr)) { channelId = i; break; @@ -97,7 +97,7 @@ public: if (!entry) continue; - if (strstr(entry->AreaName->Str[handler->GetSessionDbcLocale()], channelStr)) + if (strstr(entry->AreaName[handler->GetSessionDbcLocale()], channelStr)) { zoneEntry = entry; break; diff --git a/src/server/scripts/Commands/cs_misc.cpp b/src/server/scripts/Commands/cs_misc.cpp index 2a5f821e8d7..f2b012c4b17 100644 --- a/src/server/scripts/Commands/cs_misc.cpp +++ b/src/server/scripts/Commands/cs_misc.cpp @@ -285,9 +285,9 @@ public: char const* unknown = handler->GetTrinityString(LANG_UNKNOWN); handler->PSendSysMessage(LANG_MAP_POSITION, - mapId, (mapEntry ? mapEntry->MapName->Str[handler->GetSessionDbcLocale()] : unknown), - zoneId, (zoneEntry ? zoneEntry->AreaName->Str[handler->GetSessionDbcLocale()] : unknown), - areaId, (areaEntry ? areaEntry->AreaName->Str[handler->GetSessionDbcLocale()] : unknown), + mapId, (mapEntry ? mapEntry->MapName[handler->GetSessionDbcLocale()] : unknown), + zoneId, (zoneEntry ? zoneEntry->AreaName[handler->GetSessionDbcLocale()] : unknown), + areaId, (areaEntry ? areaEntry->AreaName[handler->GetSessionDbcLocale()] : unknown), object->GetPositionX(), object->GetPositionY(), object->GetPositionZ(), object->GetOrientation()); if (Transport* transport = object->GetTransport()) handler->PSendSysMessage(LANG_TRANSPORT_POSITION, @@ -1269,8 +1269,8 @@ public: std::string itemName = itemNameStr+1; auto itr = std::find_if(sItemSparseStore.begin(), sItemSparseStore.end(), [&itemName](ItemSparseEntry const* sparse) { - for (uint32 i = 0; i < TOTAL_LOCALES; ++i) - if (itemName == sparse->Display->Str[i]) + for (LocaleConstant i = LOCALE_enUS; i < TOTAL_LOCALES; i = LocaleConstant(i + 1)) + if (itemName == sparse->Display[i]) return true; return false; }); @@ -1549,7 +1549,7 @@ public: // add the skill to the player's book with step 1 (which is the first rank, in most cases something // like 'Apprentice <skill>'. target->SetSkill(skill, targetHasSkill ? target->GetSkillStep(skill) : 1, level, max); - handler->PSendSysMessage(LANG_SET_SKILL, skill, skillLine->DisplayName->Str[handler->GetSessionDbcLocale()], handler->GetNameLink(target).c_str(), level, max); + handler->PSendSysMessage(LANG_SET_SKILL, skill, skillLine->DisplayName[handler->GetSessionDbcLocale()], handler->GetNameLink(target).c_str(), level, max); return true; } @@ -1887,15 +1887,15 @@ public: AreaTableEntry const* area = sAreaTableStore.LookupEntry(areaId); if (area) { - areaName = area->AreaName->Str[handler->GetSessionDbcLocale()]; + areaName = area->AreaName[handler->GetSessionDbcLocale()]; AreaTableEntry const* zone = sAreaTableStore.LookupEntry(area->ParentAreaID); if (zone) - zoneName = zone->AreaName->Str[handler->GetSessionDbcLocale()]; + zoneName = zone->AreaName[handler->GetSessionDbcLocale()]; } if (target) - handler->PSendSysMessage(LANG_PINFO_CHR_MAP, map->MapName->Str[handler->GetSessionDbcLocale()], + handler->PSendSysMessage(LANG_PINFO_CHR_MAP, map->MapName[handler->GetSessionDbcLocale()], (!zoneName.empty() ? zoneName.c_str() : handler->GetTrinityString(LANG_UNKNOWN)), (!areaName.empty() ? areaName.c_str() : handler->GetTrinityString(LANG_UNKNOWN))); diff --git a/src/server/scripts/Commands/cs_modify.cpp b/src/server/scripts/Commands/cs_modify.cpp index 83ac3e43b4f..17a4c71b5cf 100644 --- a/src/server/scripts/Commands/cs_modify.cpp +++ b/src/server/scripts/Commands/cs_modify.cpp @@ -742,14 +742,14 @@ public: if (factionEntry->ReputationIndex < 0) { - handler->PSendSysMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->Name->Str[handler->GetSessionDbcLocale()], factionId); + handler->PSendSysMessage(LANG_COMMAND_FACTION_NOREP_ERROR, factionEntry->Name[handler->GetSessionDbcLocale()], factionId); handler->SetSentErrorMessage(true); return false; } target->GetReputationMgr().SetOneFactionReputation(factionEntry, amount, false); target->GetReputationMgr().SendState(target->GetReputationMgr().GetState(factionEntry)); - handler->PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->Name->Str[handler->GetSessionDbcLocale()], factionId, + handler->PSendSysMessage(LANG_COMMAND_MODIFY_REP, factionEntry->Name[handler->GetSessionDbcLocale()], factionId, handler->GetNameLink(target).c_str(), target->GetReputationMgr().GetReputation(factionEntry)); return true; } diff --git a/src/server/scripts/Commands/cs_titles.cpp b/src/server/scripts/Commands/cs_titles.cpp index f60d36cbccc..40c367838cb 100644 --- a/src/server/scripts/Commands/cs_titles.cpp +++ b/src/server/scripts/Commands/cs_titles.cpp @@ -96,7 +96,7 @@ public: target->SetChosenTitle(titleInfo->MaskID); handler->PSendSysMessage(LANG_TITLE_CURRENT_RES, id, - (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[handler->GetSessionDbcLocale()], + (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[handler->GetSessionDbcLocale()], tNameLink.c_str()); return true; } @@ -139,7 +139,7 @@ public: std::string tNameLink = handler->GetNameLink(target); std::string titleNameStr = Trinity::StringFormat( - (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[handler->GetSessionDbcLocale()], + (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[handler->GetSessionDbcLocale()], target->GetName().c_str() ); @@ -189,7 +189,7 @@ public: std::string tNameLink = handler->GetNameLink(target); std::string titleNameStr = Trinity::StringFormat( - (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)->Str[handler->GetSessionDbcLocale()], + (target->getGender() == GENDER_MALE ? titleInfo->Name : titleInfo->Name1)[handler->GetSessionDbcLocale()], target->GetName().c_str() ); diff --git a/src/server/shared/DataStores/DB2DatabaseLoader.cpp b/src/server/shared/DataStores/DB2DatabaseLoader.cpp index 9386f7726bf..3c46fb66506 100644 --- a/src/server/shared/DataStores/DB2DatabaseLoader.cpp +++ b/src/server/shared/DataStores/DB2DatabaseLoader.cpp @@ -22,10 +22,6 @@ #include "Errors.h" #include "Log.h" -DB2LoadInfo::DB2LoadInfo() : DB2FileLoadInfo(), Statement(MAX_HOTFIXDATABASE_STATEMENTS) -{ -} - DB2LoadInfo::DB2LoadInfo(DB2FieldMeta const* fields, std::size_t fieldCount, DB2Meta const* meta, HotfixDatabaseStatements statement) : DB2FileLoadInfo(fields, fieldCount, meta), Statement(statement) { @@ -84,6 +80,7 @@ char* DB2DatabaseLoader::Load(bool custom, uint32& records, char**& indexTable, } char* tempDataTable = new char[result->GetRowCount() * recordSize]; + memset(tempDataTable, 0, result->GetRowCount() * recordSize); uint32* newIndexes = new uint32[result->GetRowCount()]; if (stringFields) stringPool.reserve(std::max(stringPool.capacity(), stringPool.size() + stringFields * result->GetRowCount() + 1)); @@ -95,9 +92,9 @@ char* DB2DatabaseLoader::Load(bool custom, uint32& records, char**& indexTable, { Field* fields = result->Fetch(); uint32 offset = 0; - uint32 stringFieldOffset = 0; uint32 indexValue = fields[indexField].GetUInt32(); + bool isNew = false; // Attempt to overwrite existing data char* dataValue = indexTable[indexValue]; @@ -105,6 +102,7 @@ char* DB2DatabaseLoader::Load(bool custom, uint32& records, char**& indexTable, { newIndexes[newRecords] = indexValue; dataValue = &tempDataTable[newRecords++ * recordSize]; + isNew = true; } uint32 f = 0; @@ -143,29 +141,28 @@ char* DB2DatabaseLoader::Load(bool custom, uint32& records, char**& indexTable, break; case FT_STRING: { - LocalizedString** slot = (LocalizedString**)(&dataValue[offset]); - *slot = (LocalizedString*)(&stringHolders[stringHoldersRecordPoolSize * rec + stringFieldOffset]); - ASSERT(*slot); + LocalizedString* slot = (LocalizedString*)(&dataValue[offset]); + if (isNew) + for (char const*& localeStr : slot->Str) + localeStr = nullStr; // Value in database in main table field must be for enUS locale - if (char* str = AddString(&(*slot)->Str[LOCALE_enUS], fields[f].GetString())) + if (char* str = AddString(&slot->Str[LOCALE_enUS], fields[f].GetString())) stringPool.push_back(str); - stringFieldOffset += sizeof(LocalizedString); - offset += sizeof(char*); + offset += sizeof(LocalizedString); break; } case FT_STRING_NOT_LOCALIZED: { char const** slot = (char const**)(&dataValue[offset]); - *slot = (char*)(&stringHolders[stringHoldersRecordPoolSize * rec + stringFieldOffset]); - ASSERT(*slot); // Value in database in main table field must be for enUS locale if (char* str = AddString(slot, fields[f].GetString())) stringPool.push_back(str); + else + *slot = nullStr; - stringFieldOffset += sizeof(char*); offset += sizeof(char*); break; } @@ -205,7 +202,7 @@ char* DB2DatabaseLoader::Load(bool custom, uint32& records, char**& indexTable, return dataTable; } -void DB2DatabaseLoader::LoadStrings(bool custom, uint32 locale, uint32 records, char** indexTable, std::vector<char*>& stringPool) +void DB2DatabaseLoader::LoadStrings(bool custom, LocaleConstant locale, uint32 records, char** indexTable, std::vector<char*>& stringPool) { HotfixDatabasePreparedStatement* stmt = HotfixDatabase.GetPreparedStatement(HotfixDatabaseStatements(_loadInfo->Statement + 2)); stmt->setBool(0, !custom); @@ -265,13 +262,12 @@ void DB2DatabaseLoader::LoadStrings(bool custom, uint32 locale, uint32 records, case FT_STRING: { // fill only not filled entries - LocalizedString* db2str = *(LocalizedString**)(&dataValue[offset]); - if (db2str->Str[locale] == nullStr) - if (char* str = AddString(&db2str->Str[locale], fields[1 + stringFieldNumInRecord].GetString())) - stringPool.push_back(str); + LocalizedString* db2str = (LocalizedString*)(&dataValue[offset]); + if (char* str = AddString(&db2str->Str[locale], fields[1 + stringFieldNumInRecord].GetString())) + stringPool.push_back(str); ++stringFieldNumInRecord; - offset += sizeof(LocalizedString*); + offset += sizeof(LocalizedString); break; } case FT_STRING_NOT_LOCALIZED: @@ -298,16 +294,6 @@ char* DB2DatabaseLoader::AddString(char const** holder, std::string const& value { if (!value.empty()) { - std::size_t existingLength = strlen(*holder); - if (existingLength >= value.length()) - { - // Reuse existing storage if there is enough space - char* str = const_cast<char*>(*holder); - memcpy(str, value.c_str(), value.length()); - str[value.length()] = '\0'; - return nullptr; - } - char* str = new char[value.length() + 1]; memcpy(str, value.c_str(), value.length()); str[value.length()] = '\0'; diff --git a/src/server/shared/DataStores/DB2DatabaseLoader.h b/src/server/shared/DataStores/DB2DatabaseLoader.h index 7038bbcb770..a8389e7cde7 100644 --- a/src/server/shared/DataStores/DB2DatabaseLoader.h +++ b/src/server/shared/DataStores/DB2DatabaseLoader.h @@ -26,7 +26,6 @@ enum HotfixDatabaseStatements : uint32; struct TC_SHARED_API DB2LoadInfo : public DB2FileLoadInfo { - DB2LoadInfo(); DB2LoadInfo(DB2FieldMeta const* fields, std::size_t fieldCount, DB2Meta const* meta, HotfixDatabaseStatements statement); HotfixDatabaseStatements Statement; @@ -38,7 +37,7 @@ public: DB2DatabaseLoader(std::string const& storageName, DB2LoadInfo const* loadInfo) : _storageName(storageName), _loadInfo(loadInfo) { } char* Load(bool custom, uint32& records, char**& indexTable, char*& stringHolders, std::vector<char*>& stringPool); - void LoadStrings(bool custom, uint32 locale, uint32 records, char** indexTable, std::vector<char*>& stringPool); + void LoadStrings(bool custom, LocaleConstant locale, uint32 records, char** indexTable, std::vector<char*>& stringPool); static char* AddString(char const** holder, std::string const& value); private: diff --git a/src/server/shared/DataStores/DB2Store.cpp b/src/server/shared/DataStores/DB2Store.cpp index 8445f4177bb..0c99462ec5d 100644 --- a/src/server/shared/DataStores/DB2Store.cpp +++ b/src/server/shared/DataStores/DB2Store.cpp @@ -35,7 +35,7 @@ DB2StorageBase::~DB2StorageBase() delete[] strings; } -void DB2StorageBase::WriteRecordData(char const* entry, uint32 locale, ByteBuffer& buffer) const +void DB2StorageBase::WriteRecordData(char const* entry, LocaleConstant locale, ByteBuffer& buffer) const { if (!_loadInfo->Meta->HasIndexFieldInData()) entry += 4; @@ -68,12 +68,8 @@ void DB2StorageBase::WriteRecordData(char const* entry, uint32 locale, ByteBuffe break; case FT_STRING: { - LocalizedString* locStr = *(LocalizedString**)entry; - if (locStr->Str[locale][0] == '\0') - locale = 0; - - buffer << locStr->Str[locale]; - entry += sizeof(LocalizedString*); + buffer << (*(LocalizedString*)entry)[locale]; + entry += sizeof(LocalizedString); break; } case FT_STRING_NOT_LOCALIZED: @@ -87,7 +83,7 @@ void DB2StorageBase::WriteRecordData(char const* entry, uint32 locale, ByteBuffe } } -bool DB2StorageBase::Load(std::string const& path, uint32 locale, char**& indexTable) +bool DB2StorageBase::Load(std::string const& path, LocaleConstant locale, char**& indexTable) { indexTable = nullptr; DB2FileLoader db2; @@ -114,7 +110,7 @@ bool DB2StorageBase::Load(std::string const& path, uint32 locale, char**& indexT return indexTable != nullptr; } -bool DB2StorageBase::LoadStringsFrom(std::string const& path, uint32 locale, char** indexTable) +bool DB2StorageBase::LoadStringsFrom(std::string const& path, LocaleConstant locale, char** indexTable) { // DB2 must be already loaded using Load if (!indexTable) @@ -151,7 +147,7 @@ void DB2StorageBase::LoadFromDB(char**& indexTable) _stringPool.shrink_to_fit(); } -void DB2StorageBase::LoadStringsFromDB(uint32 locale, char** indexTable) +void DB2StorageBase::LoadStringsFromDB(LocaleConstant locale, char** indexTable) { if (!_loadInfo->GetStringFieldCount(true)) return; diff --git a/src/server/shared/DataStores/DB2Store.h b/src/server/shared/DataStores/DB2Store.h index 3c479aa3d0c..c670d418b13 100644 --- a/src/server/shared/DataStores/DB2Store.h +++ b/src/server/shared/DataStores/DB2Store.h @@ -37,24 +37,24 @@ public: uint32 GetLayoutHash() const { return _layoutHash; } virtual bool HasRecord(uint32 id) const = 0; - virtual void WriteRecord(uint32 id, uint32 locale, ByteBuffer& buffer) const = 0; + virtual void WriteRecord(uint32 id, LocaleConstant locale, ByteBuffer& buffer) const = 0; virtual void EraseRecord(uint32 id) = 0; std::string const& GetFileName() const { return _fileName; } uint32 GetFieldCount() const { return _fieldCount; } DB2LoadInfo const* GetLoadInfo() const { return _loadInfo; } - virtual bool Load(std::string const& path, uint32 locale) = 0; - virtual bool LoadStringsFrom(std::string const& path, uint32 locale) = 0; + virtual bool Load(std::string const& path, LocaleConstant locale) = 0; + virtual bool LoadStringsFrom(std::string const& path, LocaleConstant locale) = 0; virtual void LoadFromDB() = 0; - virtual void LoadStringsFromDB(uint32 locale) = 0; + virtual void LoadStringsFromDB(LocaleConstant locale) = 0; protected: - void WriteRecordData(char const* entry, uint32 locale, ByteBuffer& buffer) const; - bool Load(std::string const& path, uint32 locale, char**& indexTable); - bool LoadStringsFrom(std::string const& path, uint32 locale, char** indexTable); + void WriteRecordData(char const* entry, LocaleConstant locale, ByteBuffer& buffer) const; + bool Load(std::string const& path, LocaleConstant locale, char**& indexTable); + bool LoadStringsFrom(std::string const& path, LocaleConstant locale, char** indexTable); void LoadFromDB(char**& indexTable); - void LoadStringsFromDB(uint32 locale, char** indexTable); + void LoadStringsFromDB(LocaleConstant locale, char** indexTable); uint32 _tableHash; uint32 _layoutHash; @@ -73,7 +73,7 @@ class DB2Storage : public DB2StorageBase static_assert(std::is_standard_layout<T>::value, "T in DB2Storage must have standard layout."); public: - typedef DBStorageIterator<T> iterator; + using iterator = DBStorageIterator<T>; DB2Storage(char const* fileName, DB2LoadInfo const* loadInfo) : DB2StorageBase(fileName, loadInfo) { @@ -86,7 +86,7 @@ public: } bool HasRecord(uint32 id) const override { return id < _indexTableSize && _indexTable.AsT[id] != nullptr; } - void WriteRecord(uint32 id, uint32 locale, ByteBuffer& buffer) const override + void WriteRecord(uint32 id, LocaleConstant locale, ByteBuffer& buffer) const override { WriteRecordData(reinterpret_cast<char const*>(AssertEntry(id)), locale, buffer); } @@ -98,12 +98,12 @@ public: T const* operator[](uint32 id) const { return LookupEntry(id); } uint32 GetNumRows() const { return _indexTableSize; } - bool Load(std::string const& path, uint32 locale) override + bool Load(std::string const& path, LocaleConstant locale) override { return DB2StorageBase::Load(path, locale, _indexTable.AsChar); } - bool LoadStringsFrom(std::string const& path, uint32 locale) override + bool LoadStringsFrom(std::string const& path, LocaleConstant locale) override { return DB2StorageBase::LoadStringsFrom(path, locale, _indexTable.AsChar); } @@ -113,7 +113,7 @@ public: DB2StorageBase::LoadFromDB(_indexTable.AsChar); } - void LoadStringsFromDB(uint32 locale) override + void LoadStringsFromDB(LocaleConstant locale) override { DB2StorageBase::LoadStringsFromDB(locale, _indexTable.AsChar); } |