Skip to content

Commit

Permalink
Merge pull request azerothcore#1 from AlvinZhu/Playerbot
Browse files Browse the repository at this point in the history
Force playerbots locale enUS and Fix multi-language DBC loading
  • Loading branch information
liyunfan1223 committed Dec 28, 2023
2 parents 452584a + 608ff29 commit 68c8fad
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 7 deletions.
4 changes: 2 additions & 2 deletions src/server/game/Server/WorldSession.h
Original file line number Diff line number Diff line change
Expand Up @@ -516,8 +516,8 @@ class WorldSession
time_t m_muteTime;

// Locales
LocaleConstant GetSessionDbcLocale() const { return m_sessionDbcLocale; }
LocaleConstant GetSessionDbLocaleIndex() const { return m_sessionDbLocaleIndex; }
LocaleConstant GetSessionDbcLocale() const { return _isBot? LOCALE_enUS : m_sessionDbcLocale; }
LocaleConstant GetSessionDbLocaleIndex() const { return _isBot? LOCALE_enUS : m_sessionDbLocaleIndex; }
char const* GetAcoreString(uint32 entry) const;

uint32 GetLatency() const { return m_latency; }
Expand Down
17 changes: 12 additions & 5 deletions src/server/shared/DataStores/DBCDatabaseLoader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -28,8 +28,7 @@ DBCDatabaseLoader::DBCDatabaseLoader(char const* tableName, char const* dbcForma
_stringPool(stringPool)
{
// Get sql index position
int32 indexPos = -1;
_recordSize = DBCFileLoader::GetFormatRecordSize(_dbcFormat, &indexPos);
_recordSize = DBCFileLoader::GetFormatRecordSize(_dbcFormat, &_sqlIndexPos);

ASSERT(_recordSize);
}
Expand Down Expand Up @@ -71,11 +70,11 @@ char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable)
{
Field* fields = result->Fetch();
uint32 indexValue = fields[_sqlIndexPos].Get<uint32>();
char* dataValue = indexTable[indexValue];
char* oldDataValue = indexTable[indexValue];

// If exist in DBC file override from DB
newIndexes[newRecords] = indexValue;
dataValue = &dataTable[newRecords++ * _recordSize];
char* dataValue = &dataTable[newRecords++ * _recordSize];

uint32 dataOffset = 0;
uint32 sqlColumnNumber = 0;
Expand All @@ -99,7 +98,15 @@ char* DBCDatabaseLoader::Load(uint32& records, char**& indexTable)
dataOffset += sizeof(uint8);
break;
case FT_STRING:
*reinterpret_cast<char**>(&dataValue[dataOffset]) = CloneStringToPool(fields[sqlColumnNumber].Get<std::string>());
// not override string if new string is empty
if (fields[sqlColumnNumber].Get<std::string>().empty() && oldDataValue)
{
*reinterpret_cast<char**>(&dataValue[dataOffset]) = *reinterpret_cast<char**>(&oldDataValue[dataOffset]);
}
else
{
*reinterpret_cast<char**>(&dataValue[dataOffset]) = CloneStringToPool(fields[sqlColumnNumber].Get<std::string>());
}
dataOffset += sizeof(char*);
break;
case FT_SORT:
Expand Down

0 comments on commit 68c8fad

Please sign in to comment.