void WorldSession::HandleEquipmentSetUse(WorldPacket& data) { CHECK_INWORLD_RETURN LOG_DEBUG("Received CMSG_EQUIPMENT_SET_USE"); WoWGuid GUID; int8 SrcBagID; uint8 SrcSlotID; uint8 result = 0; for (int8 i = EQUIPMENT_SLOT_START; i < EQUIPMENT_SLOT_END; ++i) { uint64 ItemGUID = 0; GUID.Clear(); data >> GUID; data >> SrcBagID; data >> SrcSlotID; ItemGUID = GUID.GetOldGuid(); // Let's see if we even have this item auto item = _player->GetItemInterface()->GetItemByGUID(ItemGUID); if (item == nullptr) { // Nope we don't probably WPE hack :/ result = 1; continue; } int8 dstslot = i; int8 dstbag = static_cast<int8>(INVALID_BACKPACK_SLOT); // This is the best case, we already have the item equipped if ((SrcBagID == dstbag) && (SrcSlotID == dstslot)) continue; // Let's see if we have an item in the destination slot auto dstslotitem = _player->GetItemInterface()->GetInventoryItem(dstslot); if (dstslotitem == nullptr) { // we have no item equipped in the slot, so let's equip AddItemResult additemresult; int8 EquipError = _player->GetItemInterface()->CanEquipItemInSlot(dstbag, dstslot, item->getItemProperties(), false, false); if (EquipError == INV_ERR_OK) { dstslotitem = _player->GetItemInterface()->SafeRemoveAndRetreiveItemFromSlot(SrcBagID, SrcSlotID, false); additemresult = _player->GetItemInterface()->SafeAddItem(item, dstbag, dstslot); if (additemresult != ADD_ITEM_RESULT_OK) { // We failed for w/e reason, so let's revert auto check = _player->GetItemInterface()->SafeAddItem(item, SrcBagID, SrcSlotID); if (!check) { LOG_ERROR("HandleEquipmentSetUse", "Error while adding item %u to player %s twice", item->getEntry(), _player->GetNameString()); result = 0; } else result = 1; } } else { result = 1; } } else { // There is something equipped so we need to swap if (!_player->GetItemInterface()->SwapItems(INVALID_BACKPACK_SLOT, dstslot, SrcBagID, SrcSlotID)) result = 1; } } _player->SendEquipmentSetUseResult(result); }
/*! Draw a line. @param *context [in] Context @param *surface [out] Surface to draw on it @param *line [in] Innter variable of Pango @param x [in] X location of line @param y [in] Y location of line @param height [in] Height of line @param baseline [in] Rise / sink of line (for super/subscript) */ static void drawLine( SDLPango_Context *context, SDL_Surface *surface, PangoLayoutLine *line, gint x, gint y, gint height, gint baseline) { GSList *tmp_list = line->runs; PangoColor fg_color, bg_color; PangoRectangle logical_rect; PangoRectangle ink_rect; int x_off = 0; while (tmp_list) { SDLPango_Matrix color_matrix = context->color_matrix; PangoUnderline uline = PANGO_UNDERLINE_NONE; gboolean strike, fg_set, bg_set, shape_set; gint rise, risen_y; PangoLayoutRun *run = tmp_list->data; SDL_Rect d_rect; tmp_list = tmp_list->next; getItemProperties(run->item, &uline, &strike, &rise, &fg_color, &fg_set, &bg_color, &bg_set, &shape_set, &ink_rect, &logical_rect); risen_y = y + baseline - PANGO_PIXELS (rise); if(fg_set) { color_matrix.m[0][1] = (Uint8)(fg_color.red >> 8); color_matrix.m[1][1] = (Uint8)(fg_color.green >> 8); color_matrix.m[2][1] = (Uint8)(fg_color.blue >> 8); color_matrix.m[3][1] = 255; if(color_matrix.m[3][0] == 0) { color_matrix.m[0][0] = (Uint8)(fg_color.red >> 8); color_matrix.m[1][0] = (Uint8)(fg_color.green >> 8); color_matrix.m[2][0] = (Uint8)(fg_color.blue >> 8); } } if (bg_set) { color_matrix.m[0][0] = (Uint8)(bg_color.red >> 8); color_matrix.m[1][0] = (Uint8)(bg_color.green >> 8); color_matrix.m[2][0] = (Uint8)(bg_color.blue >> 8); color_matrix.m[3][0] = 255; } if(! shape_set) { if (uline == PANGO_UNDERLINE_NONE) pango_glyph_string_extents (run->glyphs, run->item->analysis.font, NULL, &logical_rect); else pango_glyph_string_extents (run->glyphs, run->item->analysis.font, &ink_rect, &logical_rect); d_rect.w = (Uint16)PANGO_PIXELS(logical_rect.width); d_rect.h = (Uint16)height; d_rect.x = (Uint16)(x + PANGO_PIXELS (x_off)); d_rect.y = (Uint16)(risen_y - baseline); if((! context->tmp_ftbitmap) || d_rect.w + d_rect.x > context->tmp_ftbitmap->width || d_rect.h + d_rect.y > context->tmp_ftbitmap->rows) { freeFTBitmap(context->tmp_ftbitmap); context->tmp_ftbitmap = createFTBitmap(d_rect.w + d_rect.x, d_rect.h + d_rect.y); } drawGlyphString(context, surface, &color_matrix, run->item->analysis.font, run->glyphs, &d_rect, baseline); } switch (uline) { case PANGO_UNDERLINE_NONE: break; case PANGO_UNDERLINE_DOUBLE: drawHLine(surface, &color_matrix, risen_y + 4, x + PANGO_PIXELS (x_off + ink_rect.x), x + PANGO_PIXELS (x_off + ink_rect.x + ink_rect.width)); /* Fall through */ case PANGO_UNDERLINE_SINGLE: drawHLine(surface, &color_matrix, risen_y + 2, x + PANGO_PIXELS (x_off + ink_rect.x), x + PANGO_PIXELS (x_off + ink_rect.x + ink_rect.width)); break; case PANGO_UNDERLINE_ERROR: { int point_x; int counter = 0; int end_x = x + PANGO_PIXELS (x_off + ink_rect.x + ink_rect.width); for (point_x = x + PANGO_PIXELS (x_off + ink_rect.x) - 1; point_x <= end_x; point_x += 2) { if (counter) drawHLine(surface, &color_matrix, risen_y + 2, point_x, MIN (point_x + 1, end_x)); else drawHLine(surface, &color_matrix, risen_y + 3, point_x, MIN (point_x + 1, end_x)); counter = (counter + 1) % 2; } } break; case PANGO_UNDERLINE_LOW: drawHLine(surface, &color_matrix, risen_y + PANGO_PIXELS (ink_rect.y + ink_rect.height), x + PANGO_PIXELS (x_off + ink_rect.x), x + PANGO_PIXELS (x_off + ink_rect.x + ink_rect.width)); break; } if (strike) drawHLine(surface, &color_matrix, risen_y + PANGO_PIXELS (logical_rect.y + logical_rect.height / 2), x + PANGO_PIXELS (x_off + logical_rect.x), x + PANGO_PIXELS (x_off + logical_rect.x + logical_rect.width)); x_off += logical_rect.width; }
void WorldSession::SendRefundInfo(uint64 GUID) { if (!_player || !_player->IsInWorld()) return; auto item = _player->GetItemInterface()->GetItemByGUID(GUID); if (item == nullptr) return; if (item->IsEligibleForRefund()) { std::pair <time_t, uint32> RefundEntry; RefundEntry = _player->GetItemInterface()->LookupRefundable(GUID); if (RefundEntry.first == 0 || RefundEntry.second == 0) return; auto item_extended_cost = sItemExtendedCostStore.LookupEntry(RefundEntry.second); if (item_extended_cost == nullptr) return; ItemProperties const* proto = item->getItemProperties(); item->setFlags(ITEM_FLAG_REFUNDABLE); // //////////////////////////////////////////////////////////////////////////////////////// // As of 3.2.0a the server sends this packet to provide refund info on // an item // // {SERVER} Packet: (0x04B2) UNKNOWN PacketSize = 68 TimeStamp = // 265984265 // E6 EE 09 18 02 00 00 42 00 00 00 00 4B 25 00 00 00 00 00 00 50 50 // 00 00 0A 00 00 00 00 // 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 // 00 00 00 00 00 00 00 // 00 00 00 00 00 00 D3 12 12 00 // // Structure: // uint64 GUID // uint32 price (in copper) // uint32 honor // uint32 arena // uint32 item1 // uint32 item1cnt // uint32 item2 // uint32 item2cnt // uint32 item3 // uint32 item3cnt // uint32 item4 // uint32 item4cnt // uint32 item5 // uint32 item5cnt // uint32 unknown - always seems 0 // uint32 buytime - buytime in total playedtime seconds // // // Remainingtime: // Seems to be in playedtime format // // // //////////////////////////////////////////////////////////////////////////////////////// WorldPacket packet(SMSG_ITEMREFUNDINFO, 68); packet << uint64(GUID); packet << uint32(proto->BuyPrice); packet << uint32(item_extended_cost->honor_points); packet << uint32(item_extended_cost->arena_points); for (uint8 i = 0; i < 5; ++i) { packet << uint32(item_extended_cost->item[i]); packet << uint32(item_extended_cost->count[i]); } packet << uint32(0); // always seems to be 0 uint32* played = _player->GetPlayedtime(); if (played[1] >(RefundEntry.first + 60 * 60 * 2)) packet << uint32(0); else packet << uint32(RefundEntry.first); this->SendPacket(&packet); LOG_DEBUG("Sent SMSG_ITEMREFUNDINFO."); } }