mirror of
https://github.com/mangosfour/server.git
synced 2025-12-15 10:37:02 +00:00
[11743] Fixed auction crash in case missing localization for only some items
Source crash in missing locale strings array size check before access to it in locale structure. Also move repeating code for access to wide used localization string arrays to ObjectMgr functions.
This commit is contained in:
parent
bc171d5f97
commit
3e0cacbdaf
15 changed files with 203 additions and 315 deletions
|
|
@ -286,31 +286,22 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data )
|
|||
|
||||
DETAIL_LOG("STORAGE: Item Query = %u", item);
|
||||
|
||||
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype( item );
|
||||
if( pProto )
|
||||
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(item);
|
||||
if (pProto)
|
||||
{
|
||||
std::string Name = pProto->Name1;
|
||||
std::string Description = pProto->Description;
|
||||
|
||||
int loc_idx = GetSessionDbLocaleIndex();
|
||||
if ( loc_idx >= 0 )
|
||||
{
|
||||
ItemLocale const *il = sObjectMgr.GetItemLocale(pProto->ItemId);
|
||||
if (il)
|
||||
{
|
||||
if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
|
||||
Name = il->Name[loc_idx];
|
||||
if (il->Description.size() > size_t(loc_idx) && !il->Description[loc_idx].empty())
|
||||
Description = il->Description[loc_idx];
|
||||
}
|
||||
}
|
||||
|
||||
std::string name = pProto->Name1;
|
||||
std::string description = pProto->Description;
|
||||
sObjectMgr.GetItemLocaleStrings(pProto->ItemId, loc_idx, &name, &description);
|
||||
|
||||
// guess size
|
||||
WorldPacket data( SMSG_ITEM_QUERY_SINGLE_RESPONSE, 600);
|
||||
data << pProto->ItemId;
|
||||
data << pProto->Class;
|
||||
data << pProto->SubClass;
|
||||
data << int32(pProto->Unk0); // new 2.0.3, not exist in wdb cache?
|
||||
data << Name;
|
||||
data << name;
|
||||
data << uint8(0x00); //pProto->Name2; // blizz not send name there, just uint8(0x00); <-- \0 = empty string = empty name...
|
||||
data << uint8(0x00); //pProto->Name3; // blizz not send name there, just uint8(0x00);
|
||||
data << uint8(0x00); //pProto->Name4; // blizz not send name there, just uint8(0x00);
|
||||
|
|
@ -400,7 +391,7 @@ void WorldSession::HandleItemQuerySingleOpcode( WorldPacket & recv_data )
|
|||
}
|
||||
}
|
||||
data << pProto->Bonding;
|
||||
data << Description;
|
||||
data << description;
|
||||
data << pProto->PageText;
|
||||
data << pProto->LanguageID;
|
||||
data << pProto->PageMaterial;
|
||||
|
|
@ -1078,26 +1069,16 @@ void WorldSession::HandleItemNameQueryOpcode(WorldPacket & recv_data)
|
|||
recv_data.read_skip<uint64>(); // guid
|
||||
|
||||
DEBUG_LOG("WORLD: CMSG_ITEM_NAME_QUERY %u", itemid);
|
||||
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype( itemid );
|
||||
if( pProto )
|
||||
if (ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemid))
|
||||
{
|
||||
std::string Name;
|
||||
Name = pProto->Name1;
|
||||
|
||||
int loc_idx = GetSessionDbLocaleIndex();
|
||||
if (loc_idx >= 0)
|
||||
{
|
||||
ItemLocale const *il = sObjectMgr.GetItemLocale(pProto->ItemId);
|
||||
if (il)
|
||||
{
|
||||
if (il->Name.size() > size_t(loc_idx) && !il->Name[loc_idx].empty())
|
||||
Name = il->Name[loc_idx];
|
||||
}
|
||||
}
|
||||
|
||||
std::string name = pProto->Name1;
|
||||
sObjectMgr.GetItemLocaleStrings(pProto->ItemId, loc_idx, &name);
|
||||
// guess size
|
||||
WorldPacket data(SMSG_ITEM_NAME_QUERY_RESPONSE, (4+10));
|
||||
data << uint32(pProto->ItemId);
|
||||
data << Name;
|
||||
data << name;
|
||||
data << uint32(pProto->InventoryType);
|
||||
SendPacket(&data);
|
||||
return;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue