Core/Item: Localization items. (#223)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -522,6 +522,9 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player
|
|||||||
|
|
||||||
time_t curTime = sWorld->GetGameTime();
|
time_t curTime = sWorld->GetGameTime();
|
||||||
|
|
||||||
|
int loc_idx = player->GetSession()->GetSessionDbLocaleIndex();
|
||||||
|
int locdbc_idx = player->GetSession()->GetSessionDbcLocale();
|
||||||
|
|
||||||
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
|
for (AuctionEntryMap::const_iterator itr = AuctionsMap.begin(); itr != AuctionsMap.end(); ++itr)
|
||||||
{
|
{
|
||||||
if (AsyncAuctionListingMgr::IsAuctionListingAllowed() == false) // pussywizard: World::Update is waiting for us...
|
if (AsyncAuctionListingMgr::IsAuctionListingAllowed() == false) // pussywizard: World::Update is waiting for us...
|
||||||
@@ -577,6 +580,11 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player
|
|||||||
if (name.empty())
|
if (name.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
|
// local name
|
||||||
|
if (loc_idx >= 0)
|
||||||
|
if (ItemLocale const* il = sObjectMgr->GetItemLocale(proto->ItemId))
|
||||||
|
ObjectMgr::GetLocaleString(il->Name, loc_idx, name);
|
||||||
|
|
||||||
// DO NOT use GetItemEnchantMod(proto->RandomProperty) as it may return a result
|
// DO NOT use GetItemEnchantMod(proto->RandomProperty) as it may return a result
|
||||||
// that matches the search but it may not equal item->GetItemRandomPropertyId()
|
// that matches the search but it may not equal item->GetItemRandomPropertyId()
|
||||||
// used in BuildAuctionInfo() which then causes wrong items to be listed
|
// used in BuildAuctionInfo() which then causes wrong items to be listed
|
||||||
@@ -609,7 +617,7 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player
|
|||||||
// Append the suffix (ie: of the Monkey) to the name using localization
|
// Append the suffix (ie: of the Monkey) to the name using localization
|
||||||
// or default enUS if localization is invalid
|
// or default enUS if localization is invalid
|
||||||
name += ' ';
|
name += ' ';
|
||||||
name += suffix[LOCALE_enUS];
|
name += suffix[locdbc_idx >= 0 ? locdbc_idx : LOCALE_enUS];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -175,6 +175,18 @@ bool ItemChatLink::ValidateName(char* buffer, const char* context)
|
|||||||
|
|
||||||
bool res = (FormatName(LOCALE_enUS, NULL, suffixStrings) == buffer);
|
bool res = (FormatName(LOCALE_enUS, NULL, suffixStrings) == buffer);
|
||||||
|
|
||||||
|
if (!res)
|
||||||
|
{
|
||||||
|
ItemLocale const* il = sObjectMgr->GetItemLocale(_item->ItemId);
|
||||||
|
for (uint8 index = LOCALE_koKR; index < TOTAL_LOCALES; ++index)
|
||||||
|
{
|
||||||
|
if (FormatName(index, il, suffixStrings) == buffer)
|
||||||
|
{
|
||||||
|
res = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
//if (!res)
|
//if (!res)
|
||||||
;//sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item (id: %u) name wasn't found in any localization", context, _item->ItemId);
|
;//sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item (id: %u) name wasn't found in any localization", context, _item->ItemId);
|
||||||
return res;
|
return res;
|
||||||
|
|||||||
@@ -677,18 +677,6 @@ class ObjectMgr
|
|||||||
ItemTemplate const* GetItemTemplate(uint32 entry);
|
ItemTemplate const* GetItemTemplate(uint32 entry);
|
||||||
ItemTemplateContainer const* GetItemTemplateStore() const { return &_itemTemplateStore; }
|
ItemTemplateContainer const* GetItemTemplateStore() const { return &_itemTemplateStore; }
|
||||||
|
|
||||||
ItemLocale const* GetItemLocale(uint32 entry) const
|
|
||||||
{
|
|
||||||
ItemLocaleContainer::const_iterator itr = _itemLocaleStore.find(entry);
|
|
||||||
if (itr == _itemLocaleStore.end()) return NULL;
|
|
||||||
return &itr->second;
|
|
||||||
}
|
|
||||||
ItemSetNameLocale const* GetItemSetNameLocale(uint32 entry) const
|
|
||||||
{
|
|
||||||
ItemSetNameLocaleContainer::const_iterator itr = _itemSetNameLocaleStore.find(entry);
|
|
||||||
if (itr == _itemSetNameLocaleStore.end())return NULL;
|
|
||||||
return &itr->second;
|
|
||||||
}
|
|
||||||
ItemSetNameEntry const* GetItemSetNameEntry(uint32 itemId)
|
ItemSetNameEntry const* GetItemSetNameEntry(uint32 itemId)
|
||||||
{
|
{
|
||||||
ItemSetNameContainer::iterator itr = _itemSetNameStore.find(itemId);
|
ItemSetNameContainer::iterator itr = _itemSetNameStore.find(itemId);
|
||||||
@@ -1062,6 +1050,18 @@ class ObjectMgr
|
|||||||
if (itr == _gameObjectDataStore.end()) return NULL;
|
if (itr == _gameObjectDataStore.end()) return NULL;
|
||||||
return &itr->second;
|
return &itr->second;
|
||||||
}
|
}
|
||||||
|
ItemLocale const* GetItemLocale(uint32 entry) const
|
||||||
|
{
|
||||||
|
ItemLocaleContainer::const_iterator itr = _itemLocaleStore.find(entry);
|
||||||
|
if (itr == _itemLocaleStore.end()) return NULL;
|
||||||
|
return &itr->second;
|
||||||
|
}
|
||||||
|
ItemSetNameLocale const* GetItemSetNameLocale(uint32 entry) const
|
||||||
|
{
|
||||||
|
ItemSetNameLocaleContainer::const_iterator itr = _itemSetNameLocaleStore.find(entry);
|
||||||
|
if (itr == _itemSetNameLocaleStore.end())return NULL;
|
||||||
|
return &itr->second;
|
||||||
|
}
|
||||||
PageTextLocale const* GetPageTextLocale(uint32 entry) const
|
PageTextLocale const* GetPageTextLocale(uint32 entry) const
|
||||||
{
|
{
|
||||||
PageTextLocaleContainer::const_iterator itr = _pageTextLocaleStore.find(entry);
|
PageTextLocaleContainer::const_iterator itr = _pageTextLocaleStore.find(entry);
|
||||||
|
|||||||
@@ -432,13 +432,152 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket & recvData)
|
|||||||
|
|
||||||
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item);
|
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item);
|
||||||
if (pProto)
|
if (pProto)
|
||||||
SendPacket(&pProto->queryData);
|
{
|
||||||
|
std::string Name = pProto->Name1;
|
||||||
|
std::string Description = pProto->Description;
|
||||||
|
|
||||||
|
int loc_idx = GetSessionDbLocaleIndex();
|
||||||
|
if (loc_idx >= 0)
|
||||||
|
{
|
||||||
|
if (ItemLocale const* il = sObjectMgr->GetItemLocale(pProto->ItemId))
|
||||||
|
{
|
||||||
|
ObjectMgr::GetLocaleString(il->Name, loc_idx, Name);
|
||||||
|
ObjectMgr::GetLocaleString(il->Description, loc_idx, Description);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
// guess size
|
||||||
|
WorldPacket queryData(SMSG_ITEM_QUERY_SINGLE_RESPONSE, 600);
|
||||||
|
queryData << pProto->ItemId;
|
||||||
|
queryData << pProto->Class;
|
||||||
|
queryData << pProto->SubClass;
|
||||||
|
queryData << pProto->SoundOverrideSubclass;
|
||||||
|
queryData << Name;
|
||||||
|
queryData << uint8(0x00); //pProto->Name2; // blizz not send name there, just uint8(0x00); <-- \0 = empty string = empty name...
|
||||||
|
queryData << uint8(0x00); //pProto->Name3; // blizz not send name there, just uint8(0x00);
|
||||||
|
queryData << uint8(0x00); //pProto->Name4; // blizz not send name there, just uint8(0x00);
|
||||||
|
queryData << pProto->DisplayInfoID;
|
||||||
|
queryData << pProto->Quality;
|
||||||
|
queryData << pProto->Flags;
|
||||||
|
queryData << pProto->Flags2;
|
||||||
|
queryData << pProto->BuyPrice;
|
||||||
|
queryData << pProto->SellPrice;
|
||||||
|
queryData << pProto->InventoryType;
|
||||||
|
queryData << pProto->AllowableClass;
|
||||||
|
queryData << pProto->AllowableRace;
|
||||||
|
queryData << pProto->ItemLevel;
|
||||||
|
queryData << pProto->RequiredLevel;
|
||||||
|
queryData << pProto->RequiredSkill;
|
||||||
|
queryData << pProto->RequiredSkillRank;
|
||||||
|
queryData << pProto->RequiredSpell;
|
||||||
|
queryData << pProto->RequiredHonorRank;
|
||||||
|
queryData << pProto->RequiredCityRank;
|
||||||
|
queryData << pProto->RequiredReputationFaction;
|
||||||
|
queryData << pProto->RequiredReputationRank;
|
||||||
|
queryData << int32(pProto->MaxCount);
|
||||||
|
queryData << int32(pProto->Stackable);
|
||||||
|
queryData << pProto->ContainerSlots;
|
||||||
|
queryData << pProto->StatsCount; // item stats count
|
||||||
|
for (uint32 i = 0; i < pProto->StatsCount; ++i)
|
||||||
|
{
|
||||||
|
queryData << pProto->ItemStat[i].ItemStatType;
|
||||||
|
queryData << pProto->ItemStat[i].ItemStatValue;
|
||||||
|
}
|
||||||
|
queryData << pProto->ScalingStatDistribution; // scaling stats distribution
|
||||||
|
queryData << pProto->ScalingStatValue; // some kind of flags used to determine stat values column
|
||||||
|
for (int i = 0; i < MAX_ITEM_PROTO_DAMAGES; ++i)
|
||||||
|
{
|
||||||
|
queryData << pProto->Damage[i].DamageMin;
|
||||||
|
queryData << pProto->Damage[i].DamageMax;
|
||||||
|
queryData << pProto->Damage[i].DamageType;
|
||||||
|
}
|
||||||
|
|
||||||
|
// resistances (7)
|
||||||
|
queryData << pProto->Armor;
|
||||||
|
queryData << pProto->HolyRes;
|
||||||
|
queryData << pProto->FireRes;
|
||||||
|
queryData << pProto->NatureRes;
|
||||||
|
queryData << pProto->FrostRes;
|
||||||
|
queryData << pProto->ShadowRes;
|
||||||
|
queryData << pProto->ArcaneRes;
|
||||||
|
|
||||||
|
queryData << pProto->Delay;
|
||||||
|
queryData << pProto->AmmoType;
|
||||||
|
queryData << pProto->RangedModRange;
|
||||||
|
|
||||||
|
for (int s = 0; s < MAX_ITEM_PROTO_SPELLS; ++s)
|
||||||
|
{
|
||||||
|
// send DBC data for cooldowns in same way as it used in Spell::SendSpellCooldown
|
||||||
|
// use `item_template` or if not set then only use spell cooldowns
|
||||||
|
SpellInfo const* spell = sSpellMgr->GetSpellInfo(pProto->Spells[s].SpellId);
|
||||||
|
if (spell)
|
||||||
|
{
|
||||||
|
bool db_data = pProto->Spells[s].SpellCooldown >= 0 || pProto->Spells[s].SpellCategoryCooldown >= 0;
|
||||||
|
|
||||||
|
queryData << pProto->Spells[s].SpellId;
|
||||||
|
queryData << pProto->Spells[s].SpellTrigger;
|
||||||
|
queryData << uint32(-abs(pProto->Spells[s].SpellCharges));
|
||||||
|
|
||||||
|
if (db_data)
|
||||||
|
{
|
||||||
|
queryData << uint32(pProto->Spells[s].SpellCooldown);
|
||||||
|
queryData << uint32(pProto->Spells[s].SpellCategory);
|
||||||
|
queryData << uint32(pProto->Spells[s].SpellCategoryCooldown);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
queryData << uint32(spell->RecoveryTime);
|
||||||
|
queryData << uint32(spell->GetCategory());
|
||||||
|
queryData << uint32(spell->CategoryRecoveryTime);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
queryData << uint32(0);
|
||||||
|
queryData << uint32(0);
|
||||||
|
queryData << uint32(0);
|
||||||
|
queryData << uint32(-1);
|
||||||
|
queryData << uint32(0);
|
||||||
|
queryData << uint32(-1);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
queryData << pProto->Bonding;
|
||||||
|
queryData << Description;
|
||||||
|
queryData << pProto->PageText;
|
||||||
|
queryData << pProto->LanguageID;
|
||||||
|
queryData << pProto->PageMaterial;
|
||||||
|
queryData << pProto->StartQuest;
|
||||||
|
queryData << pProto->LockID;
|
||||||
|
queryData << int32(pProto->Material);
|
||||||
|
queryData << pProto->Sheath;
|
||||||
|
queryData << pProto->RandomProperty;
|
||||||
|
queryData << pProto->RandomSuffix;
|
||||||
|
queryData << pProto->Block;
|
||||||
|
queryData << pProto->ItemSet;
|
||||||
|
queryData << pProto->MaxDurability;
|
||||||
|
queryData << pProto->Area;
|
||||||
|
queryData << pProto->Map; // Added in 1.12.x & 2.0.1 client branch
|
||||||
|
queryData << pProto->BagFamily;
|
||||||
|
queryData << pProto->TotemCategory;
|
||||||
|
for (int s = 0; s < MAX_ITEM_PROTO_SOCKETS; ++s)
|
||||||
|
{
|
||||||
|
queryData << pProto->Socket[s].Color;
|
||||||
|
queryData << pProto->Socket[s].Content;
|
||||||
|
}
|
||||||
|
queryData << pProto->socketBonus;
|
||||||
|
queryData << pProto->GemProperties;
|
||||||
|
queryData << pProto->RequiredDisenchantSkill;
|
||||||
|
queryData << pProto->ArmorDamageModifier;
|
||||||
|
queryData << pProto->Duration; // added in 2.4.2.8209, duration (seconds)
|
||||||
|
queryData << pProto->ItemLimitCategory; // WotLK, ItemLimitCategory
|
||||||
|
queryData << pProto->HolidayId; // Holiday.dbc?
|
||||||
|
SendPacket(&queryData);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_ITEM_QUERY_SINGLE - NO item INFO! (ENTRY: %u)", item);
|
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_ITEM_QUERY_SINGLE - NO item INFO! (ENTRY: %u)", item);
|
||||||
WorldPacket data(SMSG_ITEM_QUERY_SINGLE_RESPONSE, 4);
|
WorldPacket queryData(SMSG_ITEM_QUERY_SINGLE_RESPONSE, 4);
|
||||||
data << uint32(item | 0x80000000);
|
queryData << uint32(item | 0x80000000);
|
||||||
SendPacket(&data);
|
SendPacket(&queryData);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -1053,9 +1192,15 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recvData)
|
|||||||
ItemSetNameEntry const* pName = sObjectMgr->GetItemSetNameEntry(itemid);
|
ItemSetNameEntry const* pName = sObjectMgr->GetItemSetNameEntry(itemid);
|
||||||
if (pName)
|
if (pName)
|
||||||
{
|
{
|
||||||
WorldPacket data(SMSG_ITEM_NAME_QUERY_RESPONSE, (4+pName->name.size()+1+4));
|
std::string Name = pName->name;
|
||||||
|
LocaleConstant loc_idx = GetSessionDbLocaleIndex();
|
||||||
|
if (loc_idx >= 0)
|
||||||
|
if (ItemSetNameLocale const* isnl = sObjectMgr->GetItemSetNameLocale(itemid))
|
||||||
|
ObjectMgr::GetLocaleString(isnl->Name, loc_idx, Name);
|
||||||
|
|
||||||
|
WorldPacket data(SMSG_ITEM_NAME_QUERY_RESPONSE, (4+Name.size()+1+4));
|
||||||
data << uint32(itemid);
|
data << uint32(itemid);
|
||||||
data << pName->name;
|
data << Name;
|
||||||
data << uint32(pName->InventoryType);
|
data << uint32(pName->InventoryType);
|
||||||
SendPacket(&data);
|
SendPacket(&data);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -372,6 +372,38 @@ public:
|
|||||||
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
|
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
|
||||||
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
|
for (ItemTemplateContainer::const_iterator itr = its->begin(); itr != its->end(); ++itr)
|
||||||
{
|
{
|
||||||
|
int localeIndex = handler->GetSessionDbLocaleIndex();
|
||||||
|
if (localeIndex >= 0)
|
||||||
|
{
|
||||||
|
uint8 ulocaleIndex = uint8(localeIndex);
|
||||||
|
if (ItemLocale const* il = sObjectMgr->GetItemLocale(itr->second.ItemId))
|
||||||
|
{
|
||||||
|
if (il->Name.size() > ulocaleIndex && !il->Name[ulocaleIndex].empty())
|
||||||
|
{
|
||||||
|
std::string name = il->Name[ulocaleIndex];
|
||||||
|
|
||||||
|
if (Utf8FitTo(name, wNamePart))
|
||||||
|
{
|
||||||
|
if (maxResults && count++ == maxResults)
|
||||||
|
{
|
||||||
|
handler->PSendSysMessage(LANG_COMMAND_LOOKUP_MAX_RESULTS, maxResults);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (handler->GetSession())
|
||||||
|
handler->PSendSysMessage(LANG_ITEM_LIST_CHAT, itr->second.ItemId, itr->second.ItemId, name.c_str());
|
||||||
|
else
|
||||||
|
handler->PSendSysMessage(LANG_ITEM_LIST_CONSOLE, itr->second.ItemId, name.c_str());
|
||||||
|
|
||||||
|
if (!found)
|
||||||
|
found = true;
|
||||||
|
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
std::string name = itr->second.Name1;
|
std::string name = itr->second.Name1;
|
||||||
if (name.empty())
|
if (name.empty())
|
||||||
continue;
|
continue;
|
||||||
|
|||||||
Reference in New Issue
Block a user