bool OnGossipHello(Player* player, Creature* creature) { WorldSession* session = player->GetSession(); for (uint8 slot = EQUIPMENT_SLOT_START; slot < EQUIPMENT_SLOT_TABARD; slot++) // EQUIPMENT_SLOT_END { if (Item* newItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, slot)) { if (sTransmogrification->AllowedQuality(newItem->GetTemplate()->Quality)) { if (const char* slotName = GetSlotName(slot, session)) player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TRAINER, slotName, EQUIPMENT_SLOT_END, slot); } } } player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_INTERACT_1, session->GetTrinityString(LANG_OPTION_REMOVE_ALL), EQUIPMENT_SLOT_END+2, 0, session->GetTrinityString(LANG_POPUP_REMOVE_ALL), 0, false); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, session->GetTrinityString(LANG_OPTION_UPDATE_MENU), EQUIPMENT_SLOT_END+1, 0); player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); return true; }
void WorldSession::SendNameQueryOpcodeFromDBCallBack(QueryResult *result, uint32 accountId) { if(!result) return; WorldSession * session = sWorld.FindSession(accountId); if(!session) { delete result; return; } Field *fields = result->Fetch(); uint32 guid = fields[0].GetUInt32(); std::string name = fields[1].GetCppString(); uint8 pRace = 0, pGender = 0, pClass = 0; if(name == "") name = session->GetTrinityString(LANG_NON_EXIST_CHARACTER); else { pRace = fields[2].GetUInt8(); pGender = fields[3].GetUInt8(); pClass = fields[4].GetUInt8(); } // guess size WorldPacket data( SMSG_NAME_QUERY_RESPONSE, (8+1+1+1+1+1+1+10) ); data.appendPackGUID(MAKE_NEW_GUID(guid, 0, HIGHGUID_PLAYER)); data << uint8(0); // added in 3.1 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_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; }
static bool HandleRanksDisplayCommand(ChatHandler* handler, char const* args) { if (*args) return false; WorldSession* session = handler->GetSession(); PreparedStatement* stmt = CharacterDatabase.GetPreparedStatement(CHAR_SEL_RANKS_INFO); stmt->setUInt32(0, GUID_LOPART(handler->GetSession()->GetPlayer()->GetGUID())); PreparedQueryResult result = CharacterDatabase.Query(stmt); if (!result) return false; uint32 team = result->Fetch()[0].GetUInt32(); uint32 rank = result->Fetch()[1].GetUInt32(); uint32 total = result->Fetch()[2].GetUInt32(); uint32 last = result->Fetch()[3].GetUInt32(); uint32 points = floor(10*sqrt((float)total/10)+last); handler->PSendSysMessage(LANG_RANKS_INFO_COMMAND, session->GetTrinityString(LANG_RANKS_NAME+rank+6*(team==67))); handler->PSendSysMessage(LANG_RANKS_INFO_COMMAND+1, last, total); if (rank != 6) handler->PSendSysMessage(LANG_RANKS_INFO_COMMAND+2, points, PvpPointsFloor[rank]); else handler->PSendSysMessage(LANG_RANKS_INFO_COMMAND+3, points); return true; }
bool OnGossipSelect(Player* player, Creature* creature, uint32 sender, uint32 uiAction) { WorldSession* session = player->GetSession(); player->PlayerTalkClass->ClearMenus(); switch(sender) { case EQUIPMENT_SLOT_END: // Show items you can use { if (Item* oldItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, uiAction)) { uint32 lowGUID = player->GetGUIDLow(); _items[lowGUID].clear(); uint32 limit = 0; uint32 price = 0; switch (sTransmogrification->GetRequireGold()) { case 1: { price = (unsigned int)(GetFakePrice(oldItem)*sTransmogrification->GetGoldModifier()); } break; case 2: { price = (unsigned int)sTransmogrification->GetGoldCost(); } break; } char tokenCost[250] = "\n"; if(sTransmogrification->GetRequireToken()) snprintf(tokenCost, 250, "\n\n%u x %s", sTransmogrification->GetTokenAmount(), GetItemName(sObjectMgr->GetItemTemplate(sTransmogrification->GetTokenEntry()), session).c_str()); for (uint8 i = INVENTORY_SLOT_ITEM_START; i < INVENTORY_SLOT_ITEM_END; i++) { if (limit > 30) break; if (Item* newItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, i)) { uint32 display = newItem->GetTemplate()->DisplayInfoID; if (player->SuitableForTransmogrification(oldItem, newItem) == ERR_FAKE_OK) { if (_items[lowGUID].find(display) == _items[lowGUID].end()) { limit++; _items[lowGUID][display] = newItem; player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_INTERACT_1, GetItemName(newItem->GetTemplate(), session), uiAction, display, session->GetTrinityString(LANG_POPUP_TRANSMOGRIFY)+GetItemName(newItem->GetTemplate(), session)+tokenCost, price, false); } } } } for (uint8 i = INVENTORY_SLOT_BAG_START; i < INVENTORY_SLOT_BAG_END; i++) { if (Bag* bag = player->GetBagByPos(i)) { for (uint32 j = 0; j < bag->GetBagSize(); j++) { if (limit > 30) break; if (Item* newItem = player->GetItemByPos(i, j)) { uint32 display = newItem->GetTemplate()->DisplayInfoID; if (player->SuitableForTransmogrification(oldItem, newItem) == ERR_FAKE_OK) { if (_items[lowGUID].find(display) == _items[lowGUID].end()) { limit++; _items[lowGUID][display] = newItem; player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_INTERACT_1, GetItemName(newItem->GetTemplate(), session), uiAction, display, session->GetTrinityString(LANG_POPUP_TRANSMOGRIFY)+GetItemName(newItem->GetTemplate(), session)+tokenCost, price, false); } } } } } } char removeOnePopup[250]; snprintf(removeOnePopup, 250, session->GetTrinityString(LANG_POPUP_REMOVE_ONE), GetSlotName(uiAction, session)); player->ADD_GOSSIP_ITEM_EXTENDED(GOSSIP_ICON_INTERACT_1, session->GetTrinityString(LANG_OPTION_REMOVE_ONE), EQUIPMENT_SLOT_END+3, uiAction, removeOnePopup, 0, false); player->ADD_GOSSIP_ITEM(GOSSIP_ICON_TALK, session->GetTrinityString(LANG_OPTION_BACK), EQUIPMENT_SLOT_END+1, 0); player->SEND_GOSSIP_MENU(DEFAULT_GOSSIP_MESSAGE, creature->GetGUID()); } else OnGossipHello(player, creature); } break; case EQUIPMENT_SLOT_END+1: // Back { OnGossipHello(player, creature); } break; case EQUIPMENT_SLOT_END+2: // Remove Transmogrifications { bool removed = false; for (uint8 Slot = EQUIPMENT_SLOT_START; Slot < EQUIPMENT_SLOT_END; Slot++) { if (Item* newItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, Slot)) { if (newItem->DeleteFakeEntry() && !removed) removed = true; } } if (removed) { session->SendAreaTriggerMessage(session->GetTrinityString(LANG_REM_TRANSMOGRIFICATIONS_ITEMS)); player->PlayDirectSound(3337); } else session->SendNotification(session->GetTrinityString(LANG_ERR_NO_TRANSMOGRIFICATIONS)); OnGossipHello(player, creature); } break; case EQUIPMENT_SLOT_END+3: // Remove Transmogrification from single item { if (Item* newItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, uiAction)) { if (newItem->DeleteFakeEntry()) { session->SendAreaTriggerMessage(session->GetTrinityString(LANG_REM_TRANSMOGRIFICATION_ITEM), GetSlotName(uiAction, session)); player->PlayDirectSound(3337); } else session->SendNotification(session->GetTrinityString(LANG_ERR_NO_TRANSMOGRIFICATION), GetSlotName(uiAction, session)); } OnGossipSelect(player, creature, EQUIPMENT_SLOT_END, uiAction); } break; default: // Transmogrify { uint32 lowGUID = player->GetGUIDLow(); if(!sTransmogrification->GetRequireToken() || player->GetItemCount(sTransmogrification->GetTokenEntry()) >= sTransmogrification->GetTokenAmount()) { if (Item* oldItem = player->GetItemByPos(INVENTORY_SLOT_BAG_0, sender)) { if (_items[lowGUID].find(uiAction) != _items[lowGUID].end() && _items[lowGUID][uiAction]->IsInWorld()) { Item* newItem = _items[lowGUID][uiAction]; if (newItem->GetOwnerGUID() == player->GetGUIDLow() && (newItem->IsInBag() || newItem->GetBagSlot() == INVENTORY_SLOT_BAG_0) && player->SuitableForTransmogrification(oldItem, newItem) == ERR_FAKE_OK) { switch(sTransmogrification->GetRequireGold()) { case 1: { player->ModifyMoney(-1*(uint32)(GetFakePrice(oldItem)*sTransmogrification->GetGoldModifier())); } break; case 2: { player->ModifyMoney(-1*(unsigned int)sTransmogrification->GetGoldCost()); } break; } if(sTransmogrification->GetRequireToken()) player->DestroyItemCount(sTransmogrification->GetTokenEntry(), sTransmogrification->GetTokenAmount(), true); oldItem->SetFakeEntry(newItem->GetEntry()); newItem->SetNotRefundable(player); newItem->SetBinding(true); player->PlayDirectSound(3337); session->SendAreaTriggerMessage(session->GetTrinityString(LANG_ITEM_TRANSMOGRIFIED), GetSlotName(sender, session)); } else session->SendNotification(session->GetTrinityString(LANG_ERR_NO_ITEM_SUITABLE)); } else session->SendNotification(session->GetTrinityString(LANG_ERR_NO_ITEM_EXISTS)); } else session->SendNotification(session->GetTrinityString(LANG_ERR_EQUIP_SLOT_EMPTY)); } else session->SendNotification(session->GetTrinityString(LANG_ERR_NO_TOKEN), GetItemName(sObjectMgr->GetItemTemplate(sTransmogrification->GetTokenEntry()), session).c_str()); _items[lowGUID].clear(); OnGossipSelect(player, creature, EQUIPMENT_SLOT_END, sender); } break; } return true; }