Core/Object: Localization objects. (#226)

This commit is contained in:
HeartWell
2016-11-05 22:43:11 +03:00
committed by Shin
parent f54f7ce7dc
commit c8cc99be37
6 changed files with 157456 additions and 16 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -1903,7 +1903,15 @@ void GameObject::EventInform(uint32 eventId)
// overwrite WorldObject function for proper name localization
std::string const& GameObject::GetNameForLocaleIdx(LocaleConstant loc_idx) const
{
{
if (loc_idx != DEFAULT_LOCALE)
{
uint8 uloc_idx = uint8(loc_idx);
if (GameObjectLocale const* cl = sObjectMgr->GetGameObjectLocale(GetEntry()))
if (cl->Name.size() > uloc_idx && !cl->Name[uloc_idx].empty())
return cl->Name[uloc_idx];
}
return GetName();
}

View File

@@ -6439,13 +6439,10 @@ void ObjectMgr::LoadGameObjectLocales()
{
uint32 oldMSTime = getMSTime();
_gameObjectLocaleStore.clear(); // need for reload case
QueryResult result = WorldDatabase.Query("SELECT entry, "
"name_loc1, name_loc2, name_loc3, name_loc4, name_loc5, name_loc6, name_loc7, name_loc8, "
"castbarcaption_loc1, castbarcaption_loc2, castbarcaption_loc3, castbarcaption_loc4, "
"castbarcaption_loc5, castbarcaption_loc6, castbarcaption_loc7, castbarcaption_loc8 FROM locales_gameobject");
_gameObjectLocaleStore.clear(); // need for reload case
// 0 1 2 3
QueryResult result = WorldDatabase.Query("SELECT entry, locale, name, castBarCaption FROM gameobject_template_locale");
if (!result)
return;
@@ -6453,15 +6450,20 @@ void ObjectMgr::LoadGameObjectLocales()
{
Field* fields = result->Fetch();
uint32 entry = fields[0].GetUInt32();
uint32 id = fields[0].GetUInt32();
std::string localeName = fields[1].GetString();
GameObjectLocale& data = _gameObjectLocaleStore[entry];
std::string name = fields[2].GetString();
std::string castBarCaption = fields[3].GetString();
for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
AddLocaleString(fields[i].GetString(), LocaleConstant(i), data.Name);
GameObjectLocale& data = _gameObjectLocaleStore[id];
LocaleConstant locale = GetLocaleByName(localeName);
if (locale == LOCALE_enUS)
continue;
AddLocaleString(name, locale, data.Name);
AddLocaleString(castBarCaption, locale, data.CastBarCaption);
for (uint8 i = 1; i < TOTAL_LOCALES; ++i)
AddLocaleString(fields[i + (TOTAL_LOCALES - 1)].GetString(), LocaleConstant(i), data.CastBarCaption);
} while (result->NextRow());
sLog->outString(">> Loaded %lu gameobject locale strings in %u ms", (unsigned long)_gameObjectLocaleStore.size(), GetMSTimeDiffToNow(oldMSTime));

View File

@@ -1056,6 +1056,12 @@ class ObjectMgr
if (itr == _creatureLocaleStore.end()) return NULL;
return &itr->second;
}
GameObjectLocale const* GetGameObjectLocale(uint32 entry) const
{
GameObjectLocaleContainer::const_iterator itr = _gameObjectLocaleStore.find(entry);
if (itr == _gameObjectLocaleStore.end()) return NULL;
return &itr->second;
}
ItemLocale const* GetItemLocale(uint32 entry) const
{
ItemLocaleContainer::const_iterator itr = _itemLocaleStore.find(entry);

View File

@@ -148,15 +148,31 @@ void WorldSession::HandleGameObjectQueryOpcode(WorldPacket & recvData)
const GameObjectTemplate* info = sObjectMgr->GetGameObjectTemplate(entry);
if (info)
{
std::string Name;
std::string IconName;
std::string CastBarCaption;
Name = info->name;
IconName = info->IconName;
CastBarCaption = info->castBarCaption;
LocaleConstant localeConstant = GetSessionDbLocaleIndex();
if (localeConstant >= LOCALE_enUS)
if (GameObjectLocale const* gameObjectLocale = sObjectMgr->GetGameObjectLocale(entry))
{
ObjectMgr::GetLocaleString(gameObjectLocale->Name, localeConstant, Name);
ObjectMgr::GetLocaleString(gameObjectLocale->CastBarCaption, localeConstant, CastBarCaption);
}
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_GAMEOBJECT_QUERY '%s' - Entry: %u. ", info->name.c_str(), entry);
WorldPacket data (SMSG_GAMEOBJECT_QUERY_RESPONSE, 150);
data << uint32(entry);
data << uint32(info->type);
data << uint32(info->displayId);
data << info->name;
data << Name;
data << uint8(0) << uint8(0) << uint8(0); // name2, name3, name4
data << info->IconName; // 2.0.3, string. Icon name to use instead of default icon for go's (ex: "Attack" makes sword)
data << info->castBarCaption; // 2.0.3, string. Text will appear in Cast Bar when using GO (ex: "Collecting")
data << IconName; // 2.0.3, string. Icon name to use instead of default icon for go's (ex: "Attack" makes sword)
data << CastBarCaption; // 2.0.3, string. Text will appear in Cast Bar when using GO (ex: "Collecting")
data << info->unk1; // 2.0.3, string
data.append(info->raw.data, MAX_GAMEOBJECT_DATA);
data << float(info->size); // go size

View File

@@ -551,6 +551,34 @@ public:
GameObjectTemplateContainer const* gotc = sObjectMgr->GetGameObjectTemplates();
for (GameObjectTemplateContainer::const_iterator itr = gotc->begin(); itr != gotc->end(); ++itr)
{
uint8 localeIndex = handler->GetSessionDbLocaleIndex();
if (GameObjectLocale const* objectLocalte = sObjectMgr->GetGameObjectLocale(itr->second.entry))
{
if (objectLocalte->Name.size() > localeIndex && !objectLocalte->Name[localeIndex].empty())
{
std::string name = objectLocalte->Name[localeIndex];
if (Utf8FitTo(name, wNamePart))
{
if (maxResults && count++ == maxResults)
{
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
return true;
}
if (handler->GetSession())
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CHAT, itr->second.entry, itr->second.entry, name.c_str());
else
handler->PSendSysMessage(LANG_GO_ENTRY_LIST_CONSOLE, itr->second.entry, name.c_str());
if (!found)
found = true;
continue;
}
}
}
std::string name = itr->second.name;
if (name.empty())
continue;