Example #1
1
/*
 * SAGA API functions
 */
void file_cpi_impl::sync_get_size (saga::off_t& size_out)
{
    {
        instance_data data(this);
        saga::url file_url(data->location_);
        this->check_if_open ("file_cpi_impl::sync_get_size", file_url);
        if (!::detail::file_islocal(file_url))
        {
            SAGA_OSSTREAM strm;
            strm << "file_cpi_impl::sync_get_size: "
                 "cannot handle remote current file: " << file_url.get_url();
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::adaptors::AdaptorDeclined);
        }
        if (!file_.is_open())
        {
            SAGA_OSSTREAM strm;
            strm << "file_cpi_impl::sync_get_size: "
                 "cannot handle remote file: " << file_url.get_url();
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::adaptors::AdaptorDeclined);
        }
    }

    // position to the end of the file
    {
        mutex_type::scoped_lock lock(mtx_);
        if (file_.eof())
            file_.clear(std::ios::eofbit);
        file_.seekg (0, std::ios::end);
        size_out = file_.tellg ();      // figure out the file size
    }

    // reposition file pointer
    instance_data data (this);
    file_.seekg (data->pointer_, std::ios::beg);
}
Example #2
1
void WorldSession::HandleRaidReadyCheckOpcode(WorldPacket& recvData)
{
    TC_LOG_DEBUG("network", "WORLD: Received MSG_RAID_READY_CHECK");

    Group* group = GetPlayer()->GetGroup();
    if (!group)
        return;

    if (recvData.empty())                                   // request
    {
        /** error handling **/
        if (!group->IsLeader(GetPlayer()->GetGUID()) && !group->IsAssistant(GetPlayer()->GetGUID()))
            return;
        /********************/

        // everything's fine, do it
        WorldPacket data(MSG_RAID_READY_CHECK, 8);
        data << GetPlayer()->GetGUID();
        group->BroadcastPacket(&data, false, -1);

        group->OfflineReadyCheck();
    }
    else                                                    // answer
    {
        uint8 state;
        recvData >> state;

        // everything's fine, do it
        WorldPacket data(MSG_RAID_READY_CHECK_CONFIRM, 9);
        data << uint64(GetPlayer()->GetGUID());
        data << uint8(state);
        group->BroadcastReadyCheck(&data);
    }
}
Example #3
1
/// Only _static_ data send in this packet !!!
void WorldSession::HandleGameObjectQueryOpcode(WorldPacket& recv_data)
{
    uint32 entryID;
    recv_data >> entryID;
    ObjectGuid guid;
    recv_data >> guid;

    const GameObjectInfo* info = ObjectMgr::GetGameObjectInfo(entryID);
    if (info)
    {
        std::string Name;
        std::string IconName;
        std::string CastBarCaption;

        Name = info->name;
        IconName = info->IconName;
        CastBarCaption = info->castBarCaption;

        int loc_idx = GetSessionDbLocaleIndex();
        if (loc_idx >= 0)
        {
            GameObjectLocale const* gl = sObjectMgr.GetGameObjectLocale(entryID);
            if (gl)
            {
                if (gl->Name.size() > size_t(loc_idx) && !gl->Name[loc_idx].empty())
                    Name = gl->Name[loc_idx];
                if (gl->CastBarCaption.size() > size_t(loc_idx) && !gl->CastBarCaption[loc_idx].empty())
                    CastBarCaption = gl->CastBarCaption[loc_idx];
            }
        }
        DETAIL_LOG("WORLD: CMSG_GAMEOBJECT_QUERY '%s' - Entry: %u. ", info->name, entryID);
        WorldPacket data(SMSG_GAMEOBJECT_QUERY_RESPONSE, 150);
        data << uint32(entryID);
        data << uint32(info->type);
        data << uint32(info->displayId);
        data << Name;
        data << uint8(0) << uint8(0) << uint8(0);           // name2, name3, name4
        data << IconName;                                   // 2.0.3, string. Icon name to use instead of default icon for go's (ex: "Attack" makes sword)
        data << CastBarCaption;                             // 2.0.3, string. Text will appear in Cast Bar when using GO (ex: "Collecting")
        data << info->unk1;                                 // 2.0.3, string
        data.append(info->raw.data, 24);
        data << float(info->size);                          // go size
        for (uint32 i = 0; i < 6; ++i)
            data << uint32(info->questItems[i]);            // itemId[6], quest drop
        SendPacket(&data);
        DEBUG_LOG("WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE");
    }
    else
    {
        DEBUG_LOG("WORLD: CMSG_GAMEOBJECT_QUERY - Guid: %s Entry: %u Missing gameobject info!",
                  guid.GetString().c_str(), entryID);
        WorldPacket data(SMSG_GAMEOBJECT_QUERY_RESPONSE, 4);
        data << uint32(entryID | 0x80000000);
        SendPacket(&data);
        DEBUG_LOG("WORLD: Sent SMSG_GAMEOBJECT_QUERY_RESPONSE");
    }
}
Example #4
1
/** Transposes the matrix.
 * @return a reference to the matrix object now containing the transposed matrix
 */
Matrix &
Matrix::transpose()
{
#ifdef HAVE_OPENCV
    if (m_num_cols == m_num_rows)
    {
        CvMat cvmat = cvMat(m_num_rows, m_num_cols, CV_32FC1, m_data);
        cvTranspose(&cvmat, &cvmat);

        return *this;
    }
#endif
    if (m_num_cols == m_num_rows) // Perform a in-place transpose
    {
        for (unsigned int row = 0; row < m_num_rows - 1; ++row)
        {
            for (unsigned int col = row + 1; col < m_num_cols; ++col)
            {
                float &a = data(row, col);
                float &b = data(col, row);
                float t = a;
                a = b;
                b = t;
            }
        }
    }
    else // Could not find a in-place transpose, so we use a temporary data array
    {
        float *new_data = (float*) malloc(sizeof(float) * m_num_elements);
        float *cur = new_data;

        for (unsigned int col = 0; col < m_num_cols; ++col)
        {
            for (unsigned int row = 0; row < m_num_rows; ++row)
            {
                *cur++ = data(row, col);
            }
        }

        unsigned int cols = m_num_cols;
        m_num_cols = m_num_rows;
        m_num_rows = cols;

        if (m_own_memory)
        {
            free(m_data);
            m_data = new_data;
        }
        else
        {
            for (unsigned int i = 0; i < m_num_elements; ++i) m_data[i] = new_data[i];
            free(new_data);
        }
    }

    return *this;
}
Example #5
1
bool Q3CString::setExpand(uint index, char c)
{
    uint oldlen = length();
    if (index >= oldlen) {
        resize(index+1);
        if (index > oldlen)
            memset(data() + oldlen, ' ', index - oldlen);
    }
    *(data() + index) = c;
    return true;
}
Example #6
1
/// Only _static_ data send in this packet !!!
void WorldSession::HandleCreatureQueryOpcode(WorldPacket& recv_data)
{
    uint32 entry;
    recv_data >> entry;
    ObjectGuid guid;
    recv_data >> guid;

    CreatureInfo const* ci = ObjectMgr::GetCreatureTemplate(entry);
    if (ci)
    {
        int loc_idx = GetSessionDbLocaleIndex();

        char const* name = ci->Name;
        char const* subName = ci->SubName;
        sObjectMgr.GetCreatureLocaleStrings(entry, loc_idx, &name, &subName);

        DETAIL_LOG("WORLD: CMSG_CREATURE_QUERY '%s' - Entry: %u.", ci->Name, entry);
        // guess size
        WorldPacket data(SMSG_CREATURE_QUERY_RESPONSE, 100);
        data << uint32(entry);                              // creature entry
        data << name;
        data << uint8(0) << uint8(0) << uint8(0);           // name2, name3, name4, always empty
        data << subName;
        data << ci->IconName;                               // "Directions" for guard, string for Icons 2.3.0
        data << uint32(ci->CreatureTypeFlags);              // flags
        data << uint32(ci->CreatureType);                   // CreatureType.dbc
        data << uint32(ci->Family);                         // CreatureFamily.dbc
        data << uint32(ci->Rank);                           // Creature Rank (elite, boss, etc)
        data << uint32(ci->KillCredit[0]);                  // new in 3.1, kill credit
        data << uint32(ci->KillCredit[1]);                  // new in 3.1, kill credit

        for (int i = 0; i < MAX_CREATURE_MODEL; ++i)
            data << uint32(ci->ModelId[i]);

        data << float(ci->HealthMultiplier);                // health multiplier
        data << float(ci->PowerMultiplier);                 // power multiplier
        data << uint8(ci->RacialLeader);
        for (uint32 i = 0; i < 6; ++i)
            data << uint32(ci->QuestItems[i]);              // itemId[6], quest drop
        data << uint32(ci->MovementTemplateId);             // CreatureMovementInfo.dbc
        SendPacket(&data);
        DEBUG_LOG("WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE");
    }
    else
    {
        DEBUG_LOG("WORLD: CMSG_CREATURE_QUERY - Guid: %s Entry: %u NO CREATURE INFO!",
                  guid.GetString().c_str(), entry);
        WorldPacket data(SMSG_CREATURE_QUERY_RESPONSE, 4);
        data << uint32(entry | 0x80000000);
        SendPacket(&data);
        DEBUG_LOG("WORLD: Sent SMSG_CREATURE_QUERY_RESPONSE");
    }
}
Example #7
1
void WorldSession::HandleMoveKnockBackAck( WorldPacket & recv_data )
{
    DEBUG_LOG("CMSG_MOVE_KNOCK_BACK_ACK");

    Unit *mover = _player->GetMover();
    Player *plMover = mover->GetTypeId() == TYPEID_PLAYER ? (Player*)mover : NULL;

    // ignore, waiting processing in WorldSession::HandleMoveWorldportAckOpcode and WorldSession::HandleMoveTeleportAck
    if(plMover && plMover->IsBeingTeleported())
    {
        recv_data.rpos(recv_data.wpos());                   // prevent warnings spam
        return;
    }

    ObjectGuid guid;
    MovementInfo movementInfo;

    recv_data >> guid.ReadAsPacked();
    recv_data >> Unused<uint32>();                          // knockback packets counter
    recv_data >> movementInfo;

    if (!VerifyMovementInfo(movementInfo, guid))
        return;

    HandleMoverRelocation(movementInfo);

    WorldPacket data(MSG_MOVE_KNOCK_BACK, recv_data.size() + 15);
    data << mover->GetPackGUID();
    data << movementInfo;
    data << movementInfo.GetJumpInfo().sinAngle;
    data << movementInfo.GetJumpInfo().cosAngle;
    data << movementInfo.GetJumpInfo().xyspeed;
    data << movementInfo.GetJumpInfo().velocity;
    mover->SendMessageToSetExcept(&data, _player);
}
Example #8
1
void WorldSession::SendQueryTimeResponse()
{
    WorldPacket data(SMSG_QUERY_TIME_RESPONSE, 4 + 4);
    data << uint32(time(nullptr));
    data << uint32(sWorld.GetNextDailyQuestsResetTime() - time(nullptr));
    SendPacket(&data);
}
Example #9
1
/** Matrix multiplication operator.
 * (Matrix)a.operator*((Matrix)b) computes a * b;
 * i.e., the 2nd matrix is right-multiplied to the 1st matrix
 * @param rhs the right-hand-side matrix
 * @return the product of the two matrices (a * b)
 */
Matrix
Matrix::operator*(const Matrix &rhs) const
{
    if (m_num_cols != rhs.m_num_rows)
    {
        throw fawkes::Exception("Matrix::operator*(...): Dimension mismatch: a %d x %d matrix can't be multiplied "
                                "with a %d x %d matrix.\n",
                                m_num_rows, m_num_cols, rhs.num_rows(), rhs.num_cols());
    }

    unsigned int res_rows = m_num_rows;
    unsigned int res_cols = rhs.m_num_cols;

    Matrix res(res_rows, res_cols);

    for (unsigned int r = 0; r < res_rows; ++r)
    {
        for (unsigned int c = 0; c < res_cols; ++c)
        {
            float t = 0.0f;

            for (unsigned int i = 0; i < m_num_cols; ++i)
            {
                t += data(r, i) * rhs.data(i, c);
            }

            res.data(r, c) = t;
        }
    }

    return res;
}
Example #10
1
void file_cpi_impl::sync_remove (saga::impl::void_t & ret, int flags)
{

    {
        instance_data data(this);
        saga::url file_url(data->location_);
        this->check_if_open ("file_cpi_impl::sync_remove", file_url);
        if (!::detail::file_islocal(file_url))
        {
            SAGA_OSSTREAM strm;
            strm << "file_cpi_impl::sync_remove: "
                 "cannot handle remote current file: " << file_url.get_url();
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::adaptors::AdaptorDeclined);
        }
    }

    // first make sure this file is closed
    {
        mutex_type::scoped_lock lock(mtx_);
        if (file_.is_open())
            file_.close();
    }

    // remove the file
    base_type::sync_remove(ret, flags);
}
Example #11
1
void ReputationMgr::SendInitialReputations()
{
    WorldPacket data(SMSG_INITIALIZE_FACTIONS, (4 + 128 * 5));
    data << uint32(0x00000080);

    RepListID a = 0;

    for (FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
    {
        // fill in absent fields
        for (; a != itr->first; ++a)
        {
            data << uint8(0x00);
            data << uint32(0x00000000);
        }

        // fill in encountered data
        data << uint8(itr->second.Flags);
        data << uint32(itr->second.Standing);

        itr->second.needSend = false;

        ++a;
    }

    // fill in absent fields
    for (; a != 128; ++a)
    {
        data << uint8(0x00);
        data << uint32(0x00000000);
    }

    m_player->SendDirectMessage(&data);
}
Example #12
0
void WorldSession::HandleCorpseQueryOpcode(WorldPacket& /*recv_data*/)
{
    DETAIL_LOG("WORLD: Received opcode MSG_CORPSE_QUERY");

    Corpse* corpse = GetPlayer()->GetCorpse();

    if (!corpse)
    {
        WorldPacket data(MSG_CORPSE_QUERY, 1);
        data << uint8(0);                                   // corpse not found
        SendPacket(&data);
        return;
    }

    uint32 corpsemapid = corpse->GetMapId();
    float x = corpse->GetPositionX();
    float y = corpse->GetPositionY();
    float z = corpse->GetPositionZ();
    int32 mapid = corpsemapid;

    // if corpse at different map
    if (corpsemapid != _player->GetMapId())
    {
        // search entrance map for proper show entrance
        if (MapEntry const* corpseMapEntry = sMapStore.LookupEntry(corpsemapid))
        {
            if (corpseMapEntry->IsDungeon() && corpseMapEntry->ghost_entrance_map >= 0)
            {
                // if corpse map have entrance
                if (TerrainInfo const* entranceMap = sTerrainMgr.LoadTerrain(corpseMapEntry->ghost_entrance_map))
                {
                    mapid = corpseMapEntry->ghost_entrance_map;
                    x = corpseMapEntry->ghost_entrance_x;
                    y = corpseMapEntry->ghost_entrance_y;
                    z = entranceMap->GetHeightStatic(x, y, MAX_HEIGHT);
                }
            }
        }
    }

    WorldPacket data(MSG_CORPSE_QUERY, 1 + (6 * 4));
    data << uint8(1);                                       // corpse found
    data << int32(mapid);
    data << float(x);
    data << float(y);
    data << float(z);
    data << uint32(corpsemapid);
    data << uint32(0);                                      // unknown
    SendPacket(&data);
}
void QGLTextureGlyphCache::createTextureData(int width, int height)
{
    QGLContext *ctx = const_cast<QGLContext *>(QGLContext::currentContext());
    if (ctx == 0) {
        qWarning("QGLTextureGlyphCache::createTextureData: Called with no context");
        return;
    }

    // create in QImageTextureGlyphCache baseclass is meant to be called
    // only to create the initial image and does not preserve the content,
    // so we don't call when this function is called from resize.
    if (ctx->d_ptr->workaround_brokenFBOReadBack && image().isNull())
        QImageTextureGlyphCache::createTextureData(width, height);

    // Make the lower glyph texture size 16 x 16.
    if (width < 16)
        width = 16;
    if (height < 16)
        height = 16;

    if (m_textureResource && !m_textureResource->m_texture)
        delete m_textureResource;

    if (!m_textureResource)
        m_textureResource = new QGLGlyphTexture(ctx);

    glGenTextures(1, &m_textureResource->m_texture);
    glBindTexture(GL_TEXTURE_2D, m_textureResource->m_texture);

    m_textureResource->m_width = width;
    m_textureResource->m_height = height;

    if (m_type == QFontEngineGlyphCache::Raster_RGBMask) {
        QVarLengthArray<uchar> data(width * height * 4);
        for (int i = 0; i < data.size(); ++i)
            data[i] = 0;
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_RGBA, GL_UNSIGNED_BYTE, &data[0]);
    } else {
        QVarLengthArray<uchar> data(width * height);
        for (int i = 0; i < data.size(); ++i)
            data[i] = 0;
        glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]);
    }

    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_CLAMP_TO_EDGE);
    glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_CLAMP_TO_EDGE);
    m_filterMode = Nearest;
}
Example #14
0
void WorldSession::HandleCorpseQueryOpcode(WorldPacket & /*recv_data*/)
{
    sLog.outDetail("WORLD: Received MSG_CORPSE_QUERY");

    Corpse *corpse = GetPlayer()->GetCorpse();

    if(!corpse)
    {
        WorldPacket data(MSG_CORPSE_QUERY, 1);
        data << uint8(0);                                   // corpse not found
        SendPacket(&data);
        return;
    }

    int32 mapid = corpse->GetMapId();
    float x = corpse->GetPositionX();
    float y = corpse->GetPositionY();
    float z = corpse->GetPositionZ();
    int32 corpsemapid = mapid;

    // if corpse at different map
    if(mapid != _player->GetMapId())
    {
        // search entrance map for proper show entrance
        if(MapEntry const* corpseMapEntry = sMapStore.LookupEntry(mapid))
        {
            if(corpseMapEntry->IsDungeon() && corpseMapEntry->entrance_map >= 0)
            {
                // if corpse map have entrance
                if(Map const* entranceMap = MapManager::Instance().CreateBaseMap(corpseMapEntry->entrance_map))
                {
                    mapid = corpseMapEntry->entrance_map;
                    x = corpseMapEntry->entrance_x;
                    y = corpseMapEntry->entrance_y;
                    z = entranceMap->GetHeight(x, y, MAX_HEIGHT);
                }
            }
        }
    }

    WorldPacket data(MSG_CORPSE_QUERY, 1+(6*4));
    data << uint8(1);                                       // corpse found
    data << int32(mapid);
    data << float(x);
    data << float(y);
    data << float(z);
    data << int32(corpsemapid);
    data << uint32(0);                                      // unknown
    SendPacket(&data);
}
Example #15
0
void file_cpi_impl::sync_seek (saga::off_t & out,
                               saga::off_t   offset,
                               saga::filesystem::seek_mode whence)
{
    {
        instance_data data(this);
        saga::url file_url(data->location_);
        this->check_if_open ("file_cpi_impl::sync_seek", file_url);
        if (!::detail::file_islocal(file_url))
        {
            SAGA_OSSTREAM strm;
            strm << "file_cpi_impl::sync_seek: "
                 "cannot handle remote current file: " << file_url.get_url();
            SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm), saga::adaptors::AdaptorDeclined);
        }
    }

    /* set position of get pointer */
    mutex_type::scoped_lock lock(mtx_);

    switch ( (saga::filesystem::seek_mode) whence )
    {
    case saga::filesystem::Start:
        file_.seekg (offset, std::ios::beg);
        break;
    case saga::filesystem::Current:
        file_.seekg (offset, std::ios::cur);
        break;
    case saga::filesystem::End:
        file_.seekg (offset, std::ios::end);
        break;
    default:
    {
        // wasn't able to seek
        SAGA_OSSTREAM strm;
        strm << "file_cpi_impl::seek: bogus seek mode: " << (int) whence;
        SAGA_ADAPTOR_THROW(SAGA_OSSTREAM_GETSTRING(strm),
                           saga::BadParameter);
    }
    break;
    }

    {
        instance_data data (this);
        data->pointer_ = file_.tellg ();
        out = data->pointer_;
    }
}
Example #16
0
void GmTicket::SendResponse(WorldSession* session) const
{
    WorldPacket data(SMSG_GMRESPONSE_RECEIVED);
    data << uint32(1);          // responseID
    data << uint32(_id);        // ticketID
    data << _message.c_str();

    size_t len = _response.size();
    char const* s = _response.c_str();

    for (int i = 0; i < 4; i++)
    {
        if (len)
        {
            size_t writeLen = std::min<size_t>(len, 3999);
            data.append(s, writeLen);

            len -= writeLen;
            s += writeLen;
        }

        data << uint8(0);
    }

    session->SendPacket(&data);
}
Example #17
0
void WorldSession::SendLfgUpdate(bool isGroup, LfgUpdateType updateType, uint32 id)
{
    WorldPacket data(isGroup ? SMSG_LFG_UPDATE_PARTY : SMSG_LFG_UPDATE_PLAYER, 0);
    data << uint8(updateType);

    uint8 extra = updateType == LFG_UPDATE_JOIN ? 1 : 0;
    data << uint8(extra);

    if (extra)
    {
        data << uint8(0);
        data << uint8(0);
        data << uint8(0);

        if (isGroup)
        {
            data << uint8(0);
            for (uint32 i = 0; i < 3; ++i)
                data << uint8(0);
        }

        uint8 count = 1;
        data << uint8(count);
        for (uint32 i = 0; i < count; ++i)
            data << uint32(id);
        data << "";
    }
    SendPacket(&data);
}
Example #18
0
void WorldSession::HandleTalentWipeConfirmOpcode( WorldPacket & recv_data )
{
    DETAIL_LOG("MSG_TALENT_WIPE_CONFIRM");
    ObjectGuid guid;
    recv_data >> guid;

    Creature *unit = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_TRAINER);
    if (!unit)
    {
        DEBUG_LOG( "WORLD: HandleTalentWipeConfirmOpcode - %s not found or you can't interact with him.", guid.GetString().c_str());
        return;
    }

    // remove fake death
    if (GetPlayer()->hasUnitState(UNIT_STAT_DIED))
        GetPlayer()->RemoveSpellsCausingAura(SPELL_AURA_FEIGN_DEATH);

    if (!(_player->resetTalents()))
    {
        WorldPacket data( MSG_TALENT_WIPE_CONFIRM, 8+4);    //you have not any talent
        data << uint64(0);
        data << uint32(0);
        SendPacket( &data );
        return;
    }

    unit->CastSpell(_player, 14867, true);                  //spell: "Untalent Visual Effect"
}
Example #19
0
void WorldSession::HandleQueryTimeOpcode( WorldPacket & /*recv_data*/ )
{
    WorldPacket data( SMSG_QUERY_TIME_RESPONSE, 4+4 );
    data << (uint32)time(NULL);
    data << (uint32)0;
    SendPacket( &data );
}
Example #20
0
void WorldSession::SendPetNameQuery(ObjectGuid petguid, uint32 petnumber)
{
    Creature* pet = _player->GetMap()->GetAnyTypeCreature(petguid);
    if (!pet || !pet->GetCharmInfo() || pet->GetCharmInfo()->GetPetNumber() != petnumber)
        return;

    char const* name = pet->GetName();

    // creature pets have localization like other creatures
    if (!pet->GetOwnerGuid().IsPlayer())
    {
        int loc_idx = GetSessionDbLocaleIndex();
        sObjectMgr.GetCreatureLocaleStrings(pet->GetEntry(), loc_idx, &name);
    }

    WorldPacket data(SMSG_PET_NAME_QUERY_RESPONSE, (4 + 4 + strlen(name) + 1));
    data << uint32(petnumber);
    data << name;
    data << uint32(pet->GetUInt32Value(UNIT_FIELD_PET_NAME_TIMESTAMP));

    if (pet->IsPet() && ((Pet*)pet)->GetDeclinedNames())
    {
        data << uint8(1);
        for (int i = 0; i < MAX_DECLINED_NAME_CASES; ++i)
            data << ((Pet*)pet)->GetDeclinedNames()->name[i];
    }
    else
        data << uint8(0);

    _player->GetSession()->SendPacket(&data);
}
Example #21
0
/** Multiply the matrix with given vector.
 * @param v a vector
 * @return the result of the matrix-vector multiplication
 */
Vector
Matrix::operator*(const Vector &v) const
{
    unsigned int cols = v.size();

    if (m_num_cols != cols)
    {
        throw fawkes::Exception("Matrix::operator*(...): Dimension mismatch: a %d x %d matrix can't be multiplied "
                                "with a vector of length %d.\n", num_rows(), num_cols(), cols);
    }

    Vector res(m_num_rows);
    const float *vector_data = v.data_ptr();

    for (unsigned int r = 0; r < num_rows(); ++r)
    {
        float row_result = 0.f;

        for (unsigned int c = 0; c < cols; ++c)
        {
            row_result += data(r, c) * vector_data[c];
        }
        res[r] = row_result;
    }

    return res;
}
//call this method when player bids, creates, or deletes auction
void WorldSession::SendAuctionCommandResult(AuctionEntry* auction, uint32 action, uint32 errorCode, uint32 bidError)
{
    WorldPacket data(SMSG_AUCTION_COMMAND_RESULT);
    data << uint32(auction ? auction->Id : 0);
    data << uint32(action);
    data << uint32(errorCode);

    switch (errorCode)
    {
    case ERR_AUCTION_OK:
        if (action == AUCTION_PLACE_BID)
            data << uint64(auction->bid ? auction->GetAuctionOutBid() : 0);
        break;
    case ERR_AUCTION_INVENTORY:
        data << uint32(bidError);
        break;
    case ERR_AUCTION_HIGHER_BID:
        data << uint64(auction->bidder);
        data << uint64(auction->bid);
        data << uint64(auction->bid ? auction->GetAuctionOutBid() : 0);
        break;
    }

    SendPacket(&data);
}
//this void sends player info about his auctions
void WorldSession::HandleAuctionListOwnerItems(WorldPacket& recvData)
{
    sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: Received CMSG_AUCTION_LIST_OWNER_ITEMS");

    uint32 listfrom;
    uint64 guid;

    recvData >> guid;
    recvData >> listfrom;                                  // not used in fact (this list not have page control in client)

    Creature* creature = GetPlayer()->GetNPCIfCanInteractWith(guid, UNIT_NPC_FLAG_AUCTIONEER);
    if (!creature)
    {
        sLog->outDebug(LOG_FILTER_NETWORKIO, "WORLD: HandleAuctionListOwnerItems - Unit (GUID: %u) not found or you can't interact with him.", uint32(GUID_LOPART(guid)));
        return;
    }

    // remove fake death
    if (GetPlayer()->HasUnitState(UNIT_STATE_DIED))
        GetPlayer()->RemoveAurasByType(SPELL_AURA_FEIGN_DEATH);

    AuctionHouseObject* auctionHouse = sAuctionMgr->GetAuctionsMap(creature->getFaction());

    WorldPacket data(SMSG_AUCTION_OWNER_LIST_RESULT, (4+4+4));
    data << uint32(0);                                     // amount place holder

    uint32 count = 0;
    uint32 totalcount = 0;

    auctionHouse->BuildListOwnerItems(data, _player, count, totalcount);
    data.put<uint32>(0, count);
    data << uint32(totalcount);
    data << uint32(0);
    SendPacket(&data);
}
Example #24
0
void WorldSession::HandleGMTicketCreateOpcode(WorldPacket & recvData)
{
    // Don't accept tickets if the ticket queue is disabled. (Ticket UI is greyed out but not fully dependable)
    if (sTicketMgr->GetStatus() == GMTICKET_QUEUE_STATUS_DISABLED)
        return;

    if (GetPlayer()->getLevel() < sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ))
    {
        SendNotification(GetTrinityString(LANG_TICKET_REQ), sWorld->getIntConfig(CONFIG_TICKET_LEVEL_REQ));
        return;
    }

    GMTicketResponse response = GMTICKET_RESPONSE_CREATE_ERROR;
    // Player must not have ticket
    if (!sTicketMgr->GetTicketByPlayer(GetPlayer()->GetGUID()))
    {
        GmTicket* ticket = new GmTicket(GetPlayer(), recvData);
        sTicketMgr->AddTicket(ticket);
        sTicketMgr->UpdateLastChange();

        sWorld->SendGMText(LANG_COMMAND_TICKETNEW, GetPlayer()->GetName(), ticket->GetId());

        response = GMTICKET_RESPONSE_CREATE_SUCCESS;
    }

    WorldPacket data(SMSG_GM_TICKET_CREATE, 4);
    data << uint32(response);
    SendPacket(&data);
}
Example #25
0
void ReputationMgr::SendState(FactionState const* faction, bool anyRankIncreased)
{
    uint32 count = 1;

    WorldPacket data(SMSG_SET_FACTION_STANDING, 17);
    data << float(0);                                       // refer-a-friend bonus reputation
    data << uint8(anyRankIncreased ? 1 : 0);                // display visual effect

    size_t p_count = data.wpos();
    data << uint32(count);                                  // placeholder

    data << uint32(faction->ReputationListID);
    data << uint32(faction->Standing);

    for (FactionStateList::iterator itr = m_factions.begin(); itr != m_factions.end(); ++itr)
    {
        FactionState &subFaction = itr->second;
        if (subFaction.needSend)
        {
            subFaction.needSend = false;
            if (subFaction.ReputationListID != faction->ReputationListID)
            {
                data << uint32(subFaction.ReputationListID);
                data << uint32(subFaction.Standing);

                ++count;
            }
        }
    }

    data.put<uint32>(p_count, count);
    m_player->SendDirectMessage(&data);
}
Example #26
0
void WorldSession::HandleRandomRollOpcode(WorldPacket& recv_data)
{
    uint32 minimum, maximum, roll;
    recv_data >> minimum;
    recv_data >> maximum;

    /** error handling **/
    if(minimum > maximum || maximum > 10000)                // < 32768 for urand call
        return;
    /********************/

    // everything is fine, do it
    roll = urand(minimum, maximum);

    //DEBUG_LOG("ROLL: MIN: %u, MAX: %u, ROLL: %u", minimum, maximum, roll);

    WorldPacket data(MSG_RANDOM_ROLL, 4+4+4+8);
    data << uint32(minimum);
    data << uint32(maximum);
    data << uint32(roll);
    data << uint64(GetPlayer()->GetGUID());
    if(GetPlayer()->GetGroup())
        GetPlayer()->GetGroup()->BroadcastPacket(&data, false);
    else
        SendPacket(&data);
}
Example #27
0
void Database::changeVersion(const String& oldVersion, const String& newVersion,
                             PassRefPtr<SQLTransactionCallback> callback, PassRefPtr<SQLTransactionErrorCallback> errorCallback,
                             PassRefPtr<VoidCallback> successCallback)
{
    ChangeVersionData data(oldVersion, newVersion);
    runTransaction(callback, errorCallback, successCallback, false, &data);
}
void QGLTextureGlyphCache::createTextureData(int width, int height)
{
    // create in QImageTextureGlyphCache baseclass is meant to be called
    // only to create the initial image and does not preserve the content,
    // so we don't call when this function is called from resize.
    if (ctx->d_ptr->workaround_brokenFBOReadBack && image().isNull())
        QImageTextureGlyphCache::createTextureData(width, height);

    // Make the lower glyph texture size 16 x 16.
    if (width < 16)
        width = 16;
    if (height < 16)
        height = 16;

    glGenTextures(1, &m_texture);
    glBindTexture(GL_TEXTURE_2D, m_texture);

    m_width = width;
    m_height = height;

    QVarLengthArray<uchar> data(width * height);
    for (int i = 0; i < data.size(); ++i)
        data[i] = 0;

    if (m_type == QFontEngineGlyphCache::Raster_RGBMask)
        glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]);
    else
        glTexImage2D(GL_TEXTURE_2D, 0, GL_ALPHA, width, height, 0, GL_ALPHA, GL_UNSIGNED_BYTE, &data[0]);

    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
    glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);
}
Example #29
0
/**
 * @param filename palette file name
 */
bool Palette::save(const QString& filename)
{
    QDir dir = QFileInfo(filename).absoluteDir();
    if(!dir.exists()) {
        if(!dir.mkpath(".")) {
            qWarning() << "Couldn't create missing directory:" << dir;
            return false;
        }
    }

    QFile data(filename);
    if (data.open(QFile::WriteOnly | QFile::Truncate)) {
        QTextStream out(&data);
        out << "GIMP Palette\n";
        out << "Name: " << _name << "\n";
        out << "Columns: " << _columns << "\n";
        out << "#\n";
        for(const PaletteColor c : _colors) {
            out << c.color.red() << ' ' << c.color.green() << ' ' << c.color.blue() << '\t' << c.name << '\n';
        }
        return true;

    } else {
        qWarning() << filename << data.errorString();
        return false;
    }
}
Example #30
0
void WorldSession::SendTutorialsData()
{
    WorldPacket data(SMSG_TUTORIAL_FLAGS, 4 * MAX_ACCOUNT_TUTORIAL_VALUES);
    for (uint8 i = 0; i < MAX_ACCOUNT_TUTORIAL_VALUES; ++i)
        data << m_Tutorials[i];
    SendPacket(&data);
}