[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:
VladimirMangos 2011-07-19 00:35:16 +04:00
parent bc171d5f97
commit 3e0cacbdaf
15 changed files with 203 additions and 315 deletions

View file

@ -324,25 +324,18 @@ void WorldSession::SendPetNameQuery(ObjectGuid petguid, uint32 petnumber)
return;
}
std::string name = pet->GetName();
char const* name = pet->GetName();
// creature pets have localization like other creatures
if (!pet->GetOwnerGuid().IsPlayer())
{
int loc_idx = GetSessionDbLocaleIndex();
if (loc_idx >= 0)
{
if (CreatureLocale const *cl = sObjectMgr.GetCreatureLocale(pet->GetEntry()))
{
if (cl->Name.size() > size_t(loc_idx) && !cl->Name[loc_idx].empty())
name = cl->Name[loc_idx];
}
}
sObjectMgr.GetCreatureLocaleStrings(pet->GetEntry(), loc_idx, &name);
}
WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+name.size()+1));
WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4+4+strlen(name)+1));
data << uint32(petnumber);
data << name.c_str();
data << name;
data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP));
if (pet->IsPet() && ((Pet*)pet)->GetDeclinedNames())