Exemplo n.º 1
0
void WorldSession::SendNameCacheOpcodeFromDBCallBack(QueryResult *result, uint32 accountId)
{
    if(!result)
        return;

    WorldSession * session = sWorld.FindSession(accountId);
    if(!session)
    {
        delete result;
        return;
    }

    Field *fields = result->Fetch();
    uint32 lowguid      = fields[0].GetUInt32();
    std::string name = fields[1].GetCppString();
    uint8 pRace = 0, pGender = 0, pClass = 0;
    if(name == "")
        name         = session->GetStrawberryString(LANG_NON_EXIST_CHARACTER);
    else
    {
        pRace        = fields[2].GetUInt8();
        pGender      = fields[3].GetUInt8();
        pClass       = fields[4].GetUInt8();
    }
                                                            // guess size
    WorldPacket data( SMSG_NAME_CACHE, (8+1+1+1+1+1+1+10) );
    data << ObjectGuid(HIGHGUID_PLAYER, lowguid).WriteAsPacked();
    data << uint8(0);                                       // added in 3.1; if > 1, then end of packet
    data << name;
    data << uint8(0);                                       // realm name for cross realm BG usage
    data << uint8(pRace);                                   // race
    data << uint8(pGender);                                 // gender
    data << uint8(pClass);                                  // class

    // if the first declined name field (5) is empty, the rest must be too
    if(sWorld.getConfig(CONFIG_BOOL_DECLINED_NAMES_USED) && fields[5].GetCppString() != "")
    {
        data << uint8(1);                                   // is declined
        for(int i = 5; i < MAX_DECLINED_NAME_CASES+5; ++i)
            data << fields[i].GetCppString();
    }
    else
        data << uint8(0);                                   // is not declined

    session->SendPacket( &data );
    delete result;
}