本文整理汇总了C++中ItemPosCountVec::empty方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemPosCountVec::empty方法的具体用法?C++ ItemPosCountVec::empty怎么用?C++ ItemPosCountVec::empty使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemPosCountVec
的用法示例。
在下文中一共展示了ItemPosCountVec::empty方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: OnGossipHello
bool OnGossipHello(Player* pPlayer, Creature* /*pCreature*/)
{
if( pPlayer->IsActiveQuest( QUEST_A_MEETING_WITH_THE_MAGISTER ) && pPlayer->GetQuestStatus( QUEST_A_MEETING_WITH_THE_MAGISTER ) != QUEST_STATUS_COMPLETE )
{
ItemPosCountVec dest;
uint32 count = 1, no_space_count = 0;
uint8 msg = pPlayer->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, ITEM_QUEST, count, &no_space_count );
if( msg == EQUIP_ERR_ITEM_NOT_FOUND ) {
sLog->outErrorDb( "[src/server/scripts/Northrend/dalaran.cpp] Item (Entry %u) not exist in `item_template`.", ITEM_QUEST );
return false;
}
if( msg != EQUIP_ERR_OK ) // convert to possible store amount
count -= no_space_count;
if( count != 0 && !dest.empty( ) ) // can add some
if( Item* item = pPlayer->StoreNewItem( dest, ITEM_QUEST, true, 0 ) )
pPlayer->SendNewItem( item, count, true, false );
}
if( pPlayer->GetQuestStatus( QUEST_AN_AUDIENCE_WITH_THE_ARCANIST ) == QUEST_STATUS_COMPLETE )
{
if( pPlayer->HasAura( SPELL_SILVER_COVENANT_DISGUISE_F ) )
pPlayer->RemoveAurasDueToSpell( SPELL_SILVER_COVENANT_DISGUISE_F );
if( pPlayer->HasAura( SPELL_SILVER_COVENANT_DISGUISE_M ) )
pPlayer->RemoveAurasDueToSpell( SPELL_SILVER_COVENANT_DISGUISE_M );
}
return false;
}
示例2: RewardMark
void BattleGround::RewardMark(Player *plr,uint32 count)
{
// 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
if(plr->GetDummyAura(SPELL_AURA_PLAYER_INACTIVE))
return;
BattleGroundMarks mark;
bool IsSpell;
switch(GetTypeID())
{
case BATTLEGROUND_AV:
IsSpell = true;
if(count == ITEM_WINNER_COUNT)
mark = SPELL_AV_MARK_WINNER;
else
mark = SPELL_AV_MARK_LOSER;
break;
case BATTLEGROUND_WS:
IsSpell = true;
if(count == ITEM_WINNER_COUNT)
mark = SPELL_WS_MARK_WINNER;
else
mark = SPELL_WS_MARK_LOSER;
break;
case BATTLEGROUND_AB:
IsSpell = true;
if(count == ITEM_WINNER_COUNT)
mark = SPELL_AB_MARK_WINNER;
else
mark = SPELL_AB_MARK_LOSER;
break;/*
case BATTLEGROUND_EY:
IsSpell = false;
mark = ITEM_EY_MARK_OF_HONOR;
break;*/
default:
return;
}
if(IsSpell)
plr->CastSpell(plr, mark, true);
else if ( objmgr.GetItemPrototype( mark ) )
{
ItemPosCountVec dest;
uint32 no_space_count = 0;
uint8 msg = plr->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest, mark, count, &no_space_count );
if( msg != EQUIP_ERR_OK ) // convert to possible store amount
count -= no_space_count;
if( count != 0 && !dest.empty()) // can add some
if(Item* item = plr->StoreNewItem( dest, mark, true, 0))
plr->SendNewItem(item,count,false,true);
if(no_space_count > 0)
SendRewardMarkByMail(plr,mark,no_space_count);
}
}
示例3: AddItemChoixS
void AddItemChoixS(Player *player, uint32 item_id, int choix) {
uint32 noSpaceForCount = 0;
ItemPosCountVec dest;
InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item_id, 1, &noSpaceForCount);
if (msg != EQUIP_ERR_OK)
if (dest.empty()) {
ChatHandler(player->GetSession()).PSendSysMessage("Vous n'avez plus de place.");
return; }
if (Item* item = player->StoreNewItem(dest, item_id, true, ChoixS(item_id, choix)))
player->SendNewItem(item, 1, true, false);
return; }
示例4: RewardItem
void BattleGround::RewardItem(Player* plr, uint32 item_id, uint32 count)
{
ItemPosCountVec dest;
uint32 no_space_count = 0;
uint8 msg = plr->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, item_id, count, &no_space_count);
if (msg == EQUIP_ERR_ITEM_NOT_FOUND)
{
sLog.outErrorDb("Battleground reward item (Entry %u) not exist in `item_template`.", item_id);
return;
}
if (msg != EQUIP_ERR_OK) // convert to possible store amount
count -= no_space_count;
if (count != 0 && !dest.empty()) // can add some
if (Item* item = plr->StoreNewItem(dest, item_id, true, 0))
plr->SendNewItem(item, count, true, false);
if (no_space_count > 0)
SendRewardMarkByMail(plr, item_id, no_space_count);
}
示例5: RewardMarkOfHonor
void BattlefieldWG::RewardMarkOfHonor(Player* player, uint32 count)
{
// 'Inactive' this aura prevents the player from gaining honor points and battleground tokens
if (count == 0)
return;
ItemPosCountVec dest;
uint32 no_space_count = 0;
uint8 msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, WG_MARK_OF_HONOR, count, &no_space_count);
if (msg == EQUIP_ERR_ITEM_NOT_FOUND)
{
return;
}
if (msg != EQUIP_ERR_OK) // convert to possible store amount
count -= no_space_count;
if (count != 0 && !dest.empty()) // can add some
if (Item * item = player->StoreNewItem(dest, WG_MARK_OF_HONOR, true, 0))
player->SendNewItem(item, count, true, false);
}
示例6: HandleAddRPItemCommand
static bool HandleAddRPItemCommand(ChatHandler* handler, char const* args)
{
if (!*args)
return false;
uint32 itemId = 0;
if (args[0] == '[') // [name] manual form
{
char* citemName = strtok((char*)args, "]");
if (citemName && citemName[0])
{
std::string itemName = citemName+1;
WorldDatabase.EscapeString(itemName);
QueryResult result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE entry>200000 AND name = '%s'", itemName.c_str());
if (!result)
{
handler->PSendSysMessage(LANG_COMMAND_COULDNOTFIND, citemName+1);
handler->SetSentErrorMessage(true);
return false;
}
itemId = result->Fetch()->GetUInt16();
}
else
return false;
}
else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r
{
char* cId = handler->extractKeyFromLink((char*)args,"Hitem");
if (!cId)
return false;
itemId = atol(cId);
}
if (itemId <200000)
{
handler->PSendSysMessage(LANG_COMMAND_RPITEMTOOLOW, itemId);
handler->SetSentErrorMessage(true);
return false;
}
char* ccount = strtok(NULL, " ");
int32 count = 1;
if (ccount)
count = strtol(ccount, NULL, 10);
if (count == 0)
count = 1;
Player* pl = handler->GetSession()->GetPlayer();
ItemPrototype const *pProto = sObjectMgr->GetItemPrototype(itemId);
if (!pProto)
{
handler->PSendSysMessage(LANG_COMMAND_RPITEMIDINVALID, itemId);
handler->SetSentErrorMessage(true);
return false;
}
//Subtract
if (count < 0)
{
pl->DestroyItemCount(itemId, -count, true, false);
handler->PSendSysMessage(LANG_REMOVERPITEM, itemId, -count, handler->GetNameLink(pl).c_str());
return true;
}
//Adding items
uint32 noSpaceForCount = 0;
// check space and find places
ItemPosCountVec dest;
uint8 msg = pl->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
if (msg != EQUIP_ERR_OK) // convert to possible store amount
count -= noSpaceForCount;
if (count == 0 || dest.empty()) // can't add any
{
handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
handler->SetSentErrorMessage(true);
return false;
}
Item* item = pl->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
if (count > 0 && item)
{
pl->SendNewItem(item,count,false,true);
}
if (noSpaceForCount > 0)
handler->PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
return true;
}
示例7: HandleCustomSpell
bool OPvPCapturePointNA::HandleCustomSpell(Player* player, uint32 spellId, GameObject* /*go*/)
{
std::vector<uint32> nodes;
nodes.resize(2);
bool retval = false;
switch (spellId)
{
case NA_SPELL_FLY_NORTH:
nodes[0] = FlightPathStartNodes[NA_ROOST_N];
nodes[1] = FlightPathEndNodes[NA_ROOST_N];
player->ActivateTaxiPathTo(nodes);
player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP);
player->UpdatePvP(true, true);
retval = true;
break;
case NA_SPELL_FLY_SOUTH:
nodes[0] = FlightPathStartNodes[NA_ROOST_S];
nodes[1] = FlightPathEndNodes[NA_ROOST_S];
player->ActivateTaxiPathTo(nodes);
player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP);
player->UpdatePvP(true, true);
retval = true;
break;
case NA_SPELL_FLY_WEST:
nodes[0] = FlightPathStartNodes[NA_ROOST_W];
nodes[1] = FlightPathEndNodes[NA_ROOST_W];
player->ActivateTaxiPathTo(nodes);
player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP);
player->UpdatePvP(true, true);
retval = true;
break;
case NA_SPELL_FLY_EAST:
nodes[0] = FlightPathStartNodes[NA_ROOST_E];
nodes[1] = FlightPathEndNodes[NA_ROOST_E];
player->ActivateTaxiPathTo(nodes);
player->SetFlag(PLAYER_FLAGS, PLAYER_FLAGS_IN_PVP);
player->UpdatePvP(true, true);
retval = true;
break;
default:
break;
}
if (retval)
{
//Adding items
uint32 noSpaceForCount = 0;
// check space and find places
ItemPosCountVec dest;
int32 count = 10;
uint32 itemid = 24538;
// bomb id count
InventoryResult msg = player->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemid, count, &noSpaceForCount);
if (msg != EQUIP_ERR_OK) // convert to possible store amount
count -= noSpaceForCount;
if (count == 0 || dest.empty()) // can't add any
{
return true;
}
Item* item = player->StoreNewItem(dest, itemid, true);
if (count > 0 && item)
{
player->SendNewItem(item, count, true, false);
}
return true;
}
return false;
}
示例8: HandleBoutiqueItemCommand
static bool HandleBoutiqueItemCommand(ChatHandler *handler, const char *args) {
uint32 achatId = (uint32)atol(args);
if (!achatId) {
handler->PSendSysMessage(11007, handler->GetSession()->GetPlayerName().c_str());
return false;
}
const char* reqcount = "SELECT nom, itemId, recup, quantite FROM boutique_achat WHERE accountId = '%u' AND id='%u'";
QueryResult resultcount = LoginDatabase.PQuery(reqcount, handler->GetSession()->GetAccountId(), achatId);
if (!resultcount) {
//Cet achat n'existe pas, ne vous est pas attribue ou n'est pas disponible sur ce serveur.
handler->PSendSysMessage(11008);
return true;
}
Field* fieldscount = resultcount->Fetch();
//Vous avez déjà attribué cet achat à un de vos personnages
if (fieldscount[2].GetInt32()!=0) {
const char* reqperso = "SELECT count(*), name FROM characters WHERE guid='%u'";
QueryResult resultperso = CharacterDatabase.PQuery(reqperso, fieldscount[2].GetInt32());
Field* fieldperso = resultperso->Fetch();
handler->PSendSysMessage(11014, fieldperso[1].GetCString());
}
uint32 itemId = fieldscount[1].GetInt32();
const char* qmask = "SELECT 1 FROM boutique_produit WHERE realmMask & '%u' != 0 and itemId = '%u'";
QueryResult reqmask = LoginDatabase.PQuery(qmask, (1<<(realmID-1)), itemId);
if (!reqmask) {
//Ce produit ou service n'est pas disponible pour ce royaume.
handler->PSendSysMessage(11018);
return true;
}
ItemTemplate const *tmp = sObjectMgr->GetItemTemplate(itemId);
if (!tmp) {
handler->PSendSysMessage(11011); //Cet objet n'existe pas. Veuillez contacter un MJ et lui d�©crire le probl�¨me
return false;
}
//Adding items
uint32 noSpaceForCount = 0;
Player* plTarget = handler->GetSession()->GetPlayer();
Player* pl = plTarget;
uint32 count = fieldscount[3].GetInt32();
// check space and find places
ItemPosCountVec dest;
uint8 msg = plTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
if (msg != EQUIP_ERR_OK) // convert to possible store amount
count -= noSpaceForCount;
if (count == 0 || dest.empty()) // can't add any
{
handler->PSendSysMessage(11015);
handler->SetSentErrorMessage(true);
return false;
}
Item* item = plTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
for (ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr) {
if (Item* item1 = pl->GetItemByPos(itr->pos)) {
item1->SetBinding(true);
}
}
if (count > 0 && item)
{
plTarget->SendNewItem(item,count,true,false);
const char* requpdate = "UPDATE boutique_achat SET realmID = '%u', recup='%u' WHERE id='%u'";
LoginDatabase.PExecute(requpdate, realmID, (uint32)handler->GetSession()->GetPlayer()->GetGUIDLow(), achatId);
handler->PSendSysMessage(11013, fieldscount[0].GetCString());
}
if (noSpaceForCount > 0)
handler->PSendSysMessage(11015);
plTarget->SaveToDB();
return true;
}
示例9: SendDefaultMenu_custom_npc_tokenvendor
void SendDefaultMenu_custom_npc_tokenvendor(Player* pPlayer, Creature* pCreature, uint32 uiAction)
{
uint32 itemBoj = 29434; // Badge of Justice
uint32 itemId2 = 23162; // 36 bag slot, I suppose ? (Darkiss)
uint32 noSpaceForCount = 0;
int32 count = 0;
int32 count2 = 1;
Item* item = NULL;
ItemPosCountVec dest;
ItemPosCountVec dest2;
uint8 msg = pPlayer->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemBoj, 0);
uint8 msg2 = pPlayer->CanStoreNewItem( NULL_BAG, NULL_SLOT, dest2, 23162, 1);
// Not allowed to use in combat
if (pPlayer->isInCombat())
{
pPlayer->CLOSE_GOSSIP_MENU();
pCreature->MonsterSay("You are in combat", LANG_UNIVERSAL, NULL);
return;
}
switch(uiAction)
{
case 2000:
if(pPlayer->HasItemCount(itemBoj, 25 , true))
{
pPlayer->CLOSE_GOSSIP_MENU();
pPlayer->DestroyItemCount(itemBoj, 25, true);
pPlayer->ModifyMoney(+100000);
pCreature->MonsterWhisper("You have just exchanged 25 BOJ to 10 Gold!", pPlayer->GetGUID());
}
else
{
pPlayer->CLOSE_GOSSIP_MENU();
pCreature->MonsterSay("You don't have enough tokens!", LANG_UNIVERSAL, NULL);
}
break;
case 3000:
if(pPlayer->HasItemCount(itemBoj, 40, true))
{
pPlayer->CLOSE_GOSSIP_MENU();
pPlayer->DestroyItemCount(itemBoj, 40, true);
pPlayer->GiveLevel(pPlayer->getLevel() + 1);
pCreature->MonsterWhisper("You have just exchanged 40 BOJ for one level!", pPlayer->GetGUID());
}
else
{
pPlayer->CLOSE_GOSSIP_MENU();
pCreature->MonsterSay("You don't have enough tokens!", LANG_UNIVERSAL, NULL);
}
break;
case 4000:
if(pPlayer->HasItemCount(itemBoj, 20, true))
{
if( msg != EQUIP_ERR_OK )
count2 -= noSpaceForCount;
if( count2 == 0 || dest.empty())
{
pPlayer->CLOSE_GOSSIP_MENU();
pCreature->MonsterWhisper("Error: Item count set to 0. Please inform a GM about this error.", pPlayer->GetGUID());
}
item = pPlayer->StoreNewItem( dest2, itemId2, true, Item::GenerateItemRandomPropertyId(itemId2));
if(count2 > 0 && item)
{
pPlayer->CLOSE_GOSSIP_MENU();
pPlayer->SendNewItem(item,count2,false,true);
pPlayer->DestroyItemCount(itemBoj, 20, true);
}
if(noSpaceForCount > 0)
{
pPlayer->CLOSE_GOSSIP_MENU();
pCreature->MonsterWhisper("You don't have enough free inventory slots", pPlayer->GetGUID());
}
}
else
{
pPlayer->CLOSE_GOSSIP_MENU();
pCreature->MonsterSay("You don't have enough tokens", LANG_UNIVERSAL, NULL);
}
break;
case 5000:
pPlayer->ADD_GOSSIP_ITEM(5,"Arcane Brilliance",GOSSIP_SENDER_MAIN,5001);
pPlayer->ADD_GOSSIP_ITEM(5,"Greater Blessing of Kings",GOSSIP_SENDER_MAIN,5002);
pPlayer->ADD_GOSSIP_ITEM(5,"Gift of the Wild",GOSSIP_SENDER_MAIN,5003);
pPlayer->ADD_GOSSIP_ITEM(5,"Dalaran Brilliance",GOSSIP_SENDER_MAIN,5004);
pPlayer->ADD_GOSSIP_ITEM(5,"Greater Blessing of Might",GOSSIP_SENDER_MAIN,5005);
pPlayer->ADD_GOSSIP_ITEM(5,"Greater Blessing of Sanctuary",GOSSIP_SENDER_MAIN,5006);
pPlayer->ADD_GOSSIP_ITEM(5,"Greater Blessing of Wisdom",GOSSIP_SENDER_MAIN,5007);
pPlayer->ADD_GOSSIP_ITEM(5,"Prayer of Fortitude",GOSSIP_SENDER_MAIN,5008);
pPlayer->ADD_GOSSIP_ITEM(5,"Prayer of Shadow Protection",GOSSIP_SENDER_MAIN,5009);
pPlayer->ADD_GOSSIP_ITEM(5,"Prayer of Spirit",GOSSIP_SENDER_MAIN,5010);
//.........这里部分代码省略.........
示例10: HandleMarkCommand
// Mysteria Star
bool ChatHandler::HandleMarkCommand(char* args)
{
uint32 itemId = 38186;
int32 count;
// ak nieje parameter, pocet je defaultne 1
if (!*args)
count = 1;
else
count = strtol(args, NULL, 10);
// ak je vlozena hodnota chybna, vrati 0
if (count == 0)
return false;
// Ziskanie targetu hraca
Player* pl = m_session->GetPlayer();
Player* plTarget = getSelectedPlayer();
// Ak nieje target, da Eventerovi samotnemu.
//TODO: ma to vobec vyznam?
if (!plTarget)
plTarget = pl;
// Sprava do Logu (len pri detajlnom log-ovani)
sLog.outDetail(GetMangosString(LANG_ADDITEM), itemId, count);
// Snaha vytvorit objekt (malo by sa podarit ale aj motyka vystreli...)
ItemPrototype const *pProto = ObjectMgr::GetItemPrototype(itemId);
if (!pProto)
{
PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId);
SetSentErrorMessage(true);
return false;
}
// odobratie itemu (zaporny pocet)
if (count < 0)
{
if (!plTarget->HasItemCount(itemId, -count, false)) // itemId, count, inBankAlso
{
ChatHandler(pl->GetSession()).PSendSysMessage("You do not have enough Mysteria Star!");
pl->GetSession()->SendNotification("You do not have enough Mysteria Star!");
return false;
}
plTarget->DestroyItemCount(itemId, -count, true, false);
PSendSysMessage(LANG_REMOVEITEM, itemId, -count, GetNameLink(plTarget).c_str());
return true;
}
// Pridanie itemu
uint32 noSpaceForCount = 0;
// kontrola miesta v bagu a najdenie miesta
ItemPosCountVec dest;
uint8 msg = plTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
if (msg != EQUIP_ERR_OK) // convert to possible store amount
count -= noSpaceForCount;
if (count == 0 || dest.empty()) // can't add any
{
PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
SetSentErrorMessage(true);
return false;
}
Item* item = plTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
// Odstranenie bindovania ak gm si da item sam aby ho mohol tradeovat
//
// TODO ma to vyznam?
/*
if(pl==plTarget)
for(ItemPosCountVec::const_iterator itr = dest.begin(); itr != dest.end(); ++itr)
if(Item* item1 = pl->GetItemByPos(itr->pos))
item1->SetBinding( false );
*/
// Pridanie itemu
if (count > 0 && item)
{
pl->SendNewItem(item, count, false, true);
if (pl != plTarget)
plTarget->SendNewItem(item, count, true, false);
}
// Chyba pri nedostatku miesta
if (noSpaceForCount > 0)
PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
return true;
}
示例11: HandleAddItemToAllCommand
bool ChatHandler::HandleAddItemToAllCommand(char* args)
{
if (!*args)
return false;
uint32 itemId = 0;
// Vyextrahovanie mena itemu
if (args[0] == '[') // [name] manual form
{
char* citemName = citemName = strtok((char*)args, "]");
if (citemName && citemName[0])
{
std::string itemName = citemName + 1;
WorldDatabase.escape_string(itemName);
QueryResult *result = WorldDatabase.PQuery("SELECT entry FROM item_template WHERE name = '%s'", itemName.c_str());
if (!result)
{
PSendSysMessage(LANG_COMMAND_COULDNOTFIND, citemName + 1);
SetSentErrorMessage(true);
return false;
}
itemId = result->Fetch()->GetUInt16();
delete result;
}
else
return false;
}
else // item_id or [name] Shift-click form |color|Hitem:item_id:0:0:0|h[name]|h|r
{
char* cId = ExtractKeyFromLink(&args, "Hitem");
if (!cId)
return false;
itemId = atol(cId);
}
// Ziskanie poctu itemov (nepovinny parameter, defaultne 1)
char* ccount = strtok(NULL, " ");
int32 countproto = 1;
if (ccount)
countproto = strtol(ccount, NULL, 10);
if (countproto == 0)
countproto = 1;
//Odrstranenie itemov sa nepovoluje
if (countproto < 0)
{
// TODO bodol by aj vypis
return false;
}
// Ziskanie typu itemu
ItemPrototype const *pProto = sObjectMgr.GetItemPrototype(itemId);
if (!pProto)
{
PSendSysMessage(LANG_COMMAND_ITEMIDINVALID, itemId);
SetSentErrorMessage(true);
return false;
}
Player* pl = m_session->GetPlayer();
// Prechod vsetkymi hracmi servra
HashMapHolder<Player>::MapType& m = ObjectAccessor::Instance().GetPlayers();
for (HashMapHolder<Player>::MapType::iterator itr = m.begin(); itr != m.end(); ++itr)
{
int32 count = countproto;
Player* plTarget = itr->second;
//Adding items
uint32 noSpaceForCount = 0;
// check space and find places
ItemPosCountVec dest;
uint8 msg = plTarget->CanStoreNewItem(NULL_BAG, NULL_SLOT, dest, itemId, count, &noSpaceForCount);
if (msg != EQUIP_ERR_OK) // convert to possible store amount
count -= noSpaceForCount;
if (count == 0 || dest.empty()) // can't add any
{
PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
SetSentErrorMessage(true);
continue;
}
Item* item = plTarget->StoreNewItem(dest, itemId, true, Item::GenerateItemRandomPropertyId(itemId));
if (count > 0 && item)
{
pl->SendNewItem(item, count, false, true);
if (pl != plTarget)
plTarget->SendNewItem(item, count, true, false);
}
if (noSpaceForCount > 0)
PSendSysMessage(LANG_ITEM_CANNOT_CREATE, itemId, noSpaceForCount);
}
//.........这里部分代码省略.........
示例12: sendRewards
//.........这里部分代码省略.........
}
else
{
Item * item = plr->StoreNewItem(pos,misc[i],true);
plr->SendNewItem(item,1,true,false);
}
}
}
break;
case REWARD_TYPE_MULTIITEM:
{
for(int i = 0; i < REWARD_SIZE; i = i + 2)
{
uint32 itemid = misc[i];
uint32 itemcount = misc[i+1];
if(itemid == 0 || itemcount == 0)
continue;
ItemTemplate const * proto = sObjectMgr->GetItemTemplate(itemid);
if(!proto)
{
code = 3;
break;
}
ItemPosCountVec pos;
uint32 extra = 0;
uint32 addcount = itemcount;
uint8 r = plr->CanStoreNewItem(NULL_BAG,NULL_SLOT,pos,itemid,itemcount,&extra);
if(r != EQUIP_ERR_OK)
addcount = itemcount - extra;
if(addcount == 0 || pos.empty())
{
MailSender sender(MAIL_NORMAL,plr->GetGUIDLow(),MAIL_STATIONERY_VAL);
MailReceiver mailrecv(plr);
MailDraft draft("Reward Delivery","Here is your reward.");
Item * item = Item::CreateItem(itemid,itemcount);
item->SaveToDB(trans);
draft.AddItem(item);
draft.SendMailTo(trans,mailrecv,sender);
item = plr->StoreNewItem(pos,itemid,true);
plr->SendNewItem(item,addcount,true,false);
code = 1;
}
else if(addcount != itemcount)
{
//some can't be sent, send the rest by mail
MailSender sender(MAIL_NORMAL,plr->GetGUIDLow(),MAIL_STATIONERY_VAL);
MailReceiver mailrecv(plr);
MailDraft draft("Reward Delivery","Here is your reward.");
Item * item = Item::CreateItem(itemid,itemcount - addcount);
item->SaveToDB(trans);
draft.AddItem(item);
draft.SendMailTo(trans,mailrecv,sender);
item = plr->StoreNewItem(pos,itemid,true);
plr->SendNewItem(item,addcount,true,false);
code = 4;
}
else if(addcount == itemcount)
{
//dont need to do anything but add
plr->StoreNewItem(pos,itemid,true);