summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorHeartWell <heartwell@list.ru>2016-11-04 23:03:48 +0300
committerShin <borzifrancesco@gmail.com>2016-11-04 21:03:48 +0100
commit8088ca220a0766f39811ad7b7bb3354f01799edb (patch)
tree2880e7d4e783927e5f4d1a321eef0e4c4a7ad7aa /src
parentb9aa88ac2b0ceaf315373aff17db2e0d4c42b326 (diff)
Core/Item: Localization items. (#223)
Diffstat (limited to 'src')
-rw-r--r--src/game/AuctionHouse/AuctionHouseMgr.cpp10
-rw-r--r--src/game/Chat/ChatLink.cpp12
-rw-r--r--src/game/Globals/ObjectMgr.h24
-rw-r--r--src/game/Handlers/ItemHandler.cpp157
-rw-r--r--src/scripts/Commands/cs_lookup.cpp32
5 files changed, 216 insertions, 19 deletions
diff --git a/src/game/AuctionHouse/AuctionHouseMgr.cpp b/src/game/AuctionHouse/AuctionHouseMgr.cpp
index 53ab75ab53..9d977d17c1 100644
--- a/src/game/AuctionHouse/AuctionHouseMgr.cpp
+++ b/src/game/AuctionHouse/AuctionHouseMgr.cpp
@@ -522,6 +522,9 @@ bool AuctionHouseObject::BuildListAuctionItems(WorldPacket& data, Player* player
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)
{
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())
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
// that matches the search but it may not equal item->GetItemRandomPropertyId()
// 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
// or default enUS if localization is invalid
name += ' ';
- name += suffix[LOCALE_enUS];
+ name += suffix[locdbc_idx >= 0 ? locdbc_idx : LOCALE_enUS];
}
}
diff --git a/src/game/Chat/ChatLink.cpp b/src/game/Chat/ChatLink.cpp
index 5fa205c2a3..61e6e0e4d8 100644
--- a/src/game/Chat/ChatLink.cpp
+++ b/src/game/Chat/ChatLink.cpp
@@ -175,6 +175,18 @@ bool ItemChatLink::ValidateName(char* buffer, const char* context)
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)
;//sLog->outDebug(LOG_FILTER_CHATSYS, "ChatHandler::isValidChatMessage('%s'): linked item (id: %u) name wasn't found in any localization", context, _item->ItemId);
return res;
diff --git a/src/game/Globals/ObjectMgr.h b/src/game/Globals/ObjectMgr.h
index f940436ec4..f38a431aa9 100644
--- a/src/game/Globals/ObjectMgr.h
+++ b/src/game/Globals/ObjectMgr.h
@@ -677,18 +677,6 @@ class ObjectMgr
ItemTemplate const* GetItemTemplate(uint32 entry);
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)
{
ItemSetNameContainer::iterator itr = _itemSetNameStore.find(itemId);
@@ -1062,6 +1050,18 @@ class ObjectMgr
if (itr == _gameObjectDataStore.end()) return NULL;
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
{
PageTextLocaleContainer::const_iterator itr = _pageTextLocaleStore.find(entry);
diff --git a/src/game/Handlers/ItemHandler.cpp b/src/game/Handlers/ItemHandler.cpp
index ba16792844..7573c4280d 100644
--- a/src/game/Handlers/ItemHandler.cpp
+++ b/src/game/Handlers/ItemHandler.cpp
@@ -432,13 +432,152 @@ void WorldSession::HandleItemQuerySingleOpcode(WorldPacket & recvData)
ItemTemplate const* pProto = sObjectMgr->GetItemTemplate(item);
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
{
;//sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: CMSG_ITEM_QUERY_SINGLE - NO item INFO! (ENTRY: %u)", item);
- WorldPacket data(SMSG_ITEM_QUERY_SINGLE_RESPONSE, 4);
- data << uint32(item | 0x80000000);
- SendPacket(&data);
+ WorldPacket queryData(SMSG_ITEM_QUERY_SINGLE_RESPONSE, 4);
+ queryData << uint32(item | 0x80000000);
+ SendPacket(&queryData);
}
}
@@ -1053,9 +1192,15 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recvData)
ItemSetNameEntry const* pName = sObjectMgr->GetItemSetNameEntry(itemid);
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 << pName->name;
+ data << Name;
data << uint32(pName->InventoryType);
SendPacket(&data);
}
diff --git a/src/scripts/Commands/cs_lookup.cpp b/src/scripts/Commands/cs_lookup.cpp
index ad2e62dbbf..c8f72068d1 100644
--- a/src/scripts/Commands/cs_lookup.cpp
+++ b/src/scripts/Commands/cs_lookup.cpp
@@ -372,6 +372,38 @@ public:
ItemTemplateContainer const* its = sObjectMgr->GetItemTemplateStore();
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;
if (name.empty())
continue;