本文整理汇总了C++中Item::Destructor方法的典型用法代码示例。如果您正苦于以下问题:C++ Item::Destructor方法的具体用法?C++ Item::Destructor怎么用?C++ Item::Destructor使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Item
的用法示例。
在下文中一共展示了Item::Destructor方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: GiveRewardsForAchievement
void AchievementInterface::GiveRewardsForAchievement(AchievementEntry * ae)
{
AchievementReward * ar = AchievementRewardStorage.LookupEntry( ae->ID );
if(!ar) return;
// Reward: Item
if( ar->ItemID )
{
// Just use the in-game mail system and mail it to him.
MailMessage msg;
memset(&msg, 0, sizeof(MailMessage));
Item* pItem = objmgr.CreateItem( ar->ItemID, NULL );
if(!pItem) return;
pItem->SaveToDB( INVENTORY_SLOT_NOT_SET, 0, true, NULL );
msg.items.push_back(pItem->GetUInt32Value(OBJECT_FIELD_GUID));
msg.body = "Your reward for completing this achievement is attached below.";
msg.subject = string(ae->name);
msg.sender_guid = m_player->GetGUID();
msg.player_guid = m_player->m_playerInfo->guid;
msg.delivery_time = (uint32)UNIXTIME;
msg.expire_time = 0; // This message NEVER expires.
DEBUG_LOG("AchievementInterface","GiveRewardsForAchievement disabled until properly fixed");
// sMailSystem.DeliverMessage(&msg);
pItem->Destructor();
}
// Reward: Title. We don't yet support titles due to a lack of uint128.
}
示例2: SafeFullRemoveItemFromSlot
bool Container::SafeFullRemoveItemFromSlot(int16 slot)
{
if (slot < 0 || (uint32)slot >= GetProto()->ContainerSlots)
return false;
Item* pItem = m_Slot[slot];
if (pItem == NULL ||pItem == TO_ITEM(this)) return false;
m_Slot[slot] = NULLITEM;
SetUInt64Value(CONTAINER_FIELD_SLOT_1 + slot*2, 0 );
pItem->SetUInt64Value(ITEM_FIELD_CONTAINED, 0);
if(pItem->IsInWorld())
{
pItem->RemoveFromWorld();
}
pItem->DeleteFromDB();
pItem->Destructor();
return true;
}
示例3: Finalize
//.........这里部分代码省略.........
Player* _player = (player) ? _mgr->GetPlayer((uint32)player) : NULL;
if(!player || !_player)
{
/* all passed */
data.Initialize(SMSG_LOOT_ALL_PASSED);
data << _guid << _groupcount << _itemid << _randomsuffixid << _randompropertyid;
set<uint32>::iterator pitr = m_passRolls.begin();
while(_player == NULL && pitr != m_passRolls.end())
_player = _mgr->GetPlayer( (*(pitr++)) );
if( _player != NULL )
{
if(_player->InGroup())
_player->GetGroup()->SendPacketToAll(&data);
else
_player->GetSession()->SendPacket(&data);
}
/* item can now be looted by anyone :) */
pLoot->items.at(_slotid).passed = true;
delete this;
return;
}
pLoot->items.at(_slotid).roll = 0;
data.Initialize(SMSG_LOOT_ROLL_WON);
data << _guid << _slotid << _itemid << _randomsuffixid << _randompropertyid;
data << _player->GetGUID() << uint8(highest) << uint8(hightype);
if(_player->InGroup())
_player->GetGroup()->SendPacketToAll(&data);
else
_player->GetSession()->SendPacket(&data);
ItemPrototype* it = ItemPrototypeStorage.LookupEntry(itemid);
int8 error;
if((error = _player->GetItemInterface()->CanReceiveItem(it, 1, NULL)))
{
_player->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, error);
return;
}
Item* add = _player->GetItemInterface()->FindItemLessMax(itemid, amt, false);
if (!add)
{
SlotResult slotresult = _player->GetItemInterface()->FindFreeInventorySlot(it);
if(!slotresult.Result)
{
_player->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_INVENTORY_FULL);
return;
}
DEBUG_LOG("HandleAutostoreItem","AutoLootItem %u",itemid);
Item* item = objmgr.CreateItem( itemid, _player);
item->SetUInt32Value(ITEM_FIELD_STACK_COUNT,amt);
if(pLoot->items.at(_slotid).iRandomProperty!=NULL)
{
item->SetRandomProperty(pLoot->items.at(_slotid).iRandomProperty->ID);
item->ApplyRandomProperties(false);
}
else if(pLoot->items.at(_slotid).iRandomSuffix != NULL)
{
item->SetRandomSuffix(pLoot->items.at(_slotid).iRandomSuffix->id);
item->ApplyRandomProperties(false);
}
if( _player->GetItemInterface()->SafeAddItem(item,slotresult.ContainerSlot, slotresult.Slot) )
{
_player->GetSession()->SendItemPushResult(item,false,true,true,true,slotresult.ContainerSlot,slotresult.Slot,1);
sQuestMgr.OnPlayerItemPickup(_player,item);
}
else
{
item->Destructor();
}
}
else
{
add->SetCount(add->GetUInt32Value(ITEM_FIELD_STACK_COUNT) + amt);
add->m_isDirty = true;
sQuestMgr.OnPlayerItemPickup(_player,add);
_player->GetSession()->SendItemPushResult(add, false, true, true, false, _player->GetItemInterface()->GetBagSlotByGuid(add->GetGUID()), 0xFFFFFFFF, 1);
}
pLoot->items.at(_slotid).iItemsCount=0;
// this gets sent to all looters
data.Initialize(SMSG_LOOT_REMOVED);
data << uint8(_slotid);
Player* plr;
for(LooterSet::iterator itr = pLoot->looters.begin(); itr != pLoot->looters.end(); itr++)
{
if((plr = _player->GetMapMgr()->GetPlayer(*itr)))
plr->GetSession()->SendPacket(&data);
}
delete this;
}
示例4: HandleCharterBuy
//.........这里部分代码省略.........
if(_player->GetUInt32Value(PLAYER_FIELD_COINAGE) < costs[arena_type] && !sWorld.free_arena_teams)
return; // error message needed here
ItemPrototype * ip = ItemPrototypeStorage.LookupEntry(item_ids[arena_type]);
ASSERT(ip);
SlotResult res = _player->GetItemInterface()->FindFreeInventorySlot(ip);
if(res.Result == 0)
{
_player->GetItemInterface()->BuildInventoryChangeError(NULL, NULL, INV_ERR_INVENTORY_FULL);
return;
}
error = _player->GetItemInterface()->CanReceiveItem(ip,1, NULL);
if(error)
{
_player->GetItemInterface()->BuildInventoryChangeError(NULL,NULL,error);
}
else
{
// Create the item and charter
Item* i = objmgr.CreateItem(item_ids[arena_type], _player);
Charter * c = objmgr.CreateCharter(_player->GetLowGUID(), (CharterTypes)arena_index);
c->GuildName = name;
c->ItemGuid = i->GetGUID();
i->SetUInt32Value(ITEM_FIELD_STACK_COUNT, 1);
i->SetUInt32Value(ITEM_FIELD_FLAGS, 1);
i->SetUInt32Value(ITEM_FIELD_ENCHANTMENT_1_1, c->GetID());
i->SetUInt32Value(ITEM_FIELD_PROPERTY_SEED, 57813883);
if( !_player->GetItemInterface()->AddItemToFreeSlot(i) )
{
c->Destroy();
c = NULL;
i->Destructor();
i = NULL;
return;
}
c->SaveToDB();
SendItemPushResult(i, false, true, false, true, _player->GetItemInterface()->LastSearchItemBagSlot(), _player->GetItemInterface()->LastSearchItemSlot(), 1);
if(!sWorld.free_arena_teams)
_player->ModUnsigned32Value(PLAYER_FIELD_COINAGE, -(int32)costs[arena_type]);
_player->m_playerInfo->charterId[arena_index] = c->GetID();
_player->SaveToDB(false);
}
}
else
{
if( _player->GetUInt32Value(PLAYER_FIELD_COINAGE) < 1000 && !sWorld.free_guild_charters )
{
SendNotification("You don't have enough money.");
return;
}
if(_player->m_playerInfo->charterId[CHARTER_TYPE_GUILD] != 0)
{
SendNotification("You already have a guild charter.");
return;
}
Guild * g = objmgr.GetGuildByGuildName(name);
Charter * c = objmgr.GetCharterByName(name, CHARTER_TYPE_GUILD);
if(g != 0 || c != 0)
{
示例5: HandleGuildBankDepositItem
void WorldSession::HandleGuildBankDepositItem(WorldPacket & recv_data)
{
uint64 guid;
uint8 source_isfrombank;
uint32 wtf;
uint8 wtf2;
uint32 i;
Guild * pGuild = _player->m_playerInfo->guild;
GuildMember * pMember = _player->m_playerInfo->guildMember;
if(pGuild == NULL || pMember == NULL)
return;
recv_data >> guid >> source_isfrombank;
if(source_isfrombank)
{
GuildBankTab * pSourceTab;
GuildBankTab * pDestTab;
Item* pSourceItem;
Item* pDestItem;
uint8 dest_bank;
uint8 dest_bankslot;
uint8 source_bank;
uint8 source_bankslot;
uint8 splitted_count;
/* read packet */
recv_data >> dest_bank;
recv_data >> dest_bankslot;
recv_data >> wtf;
recv_data >> source_bank;
recv_data >> source_bankslot;
recv_data >> wtf;
recv_data >> wtf2;
recv_data >> splitted_count;
/* sanity checks to avoid overflows */
if(source_bankslot >= MAX_GUILD_BANK_SLOTS ||
dest_bankslot >= MAX_GUILD_BANK_SLOTS ||
source_bank >= MAX_GUILD_BANK_TABS ||
dest_bank >= MAX_GUILD_BANK_TABS)
{
return;
}
/* make sure we have permissions */
if(!pMember->pRank->CanPerformBankCommand(GR_RIGHT_GUILD_BANK_DEPOSIT_ITEMS, dest_bank) ||
!pMember->pRank->CanPerformBankCommand(GR_RIGHT_GUILD_BANK_DEPOSIT_ITEMS, source_bank))
return;
/* locate the tabs */
pSourceTab = pGuild->GetBankTab((uint32)source_bank);
pDestTab = pGuild->GetBankTab((uint32)dest_bank);
if(pSourceTab == NULL || pDestTab == NULL)
return;
if(pSourceTab == pDestTab && source_bankslot == dest_bankslot)
return;
pSourceItem = pSourceTab->pSlots[source_bankslot];
pDestItem = pDestTab->pSlots[dest_bankslot];
if(pSourceItem == NULL && pDestItem == NULL)
return;
if(splitted_count)
{
uint32 source_count = pSourceItem->GetUInt32Value( ITEM_FIELD_STACK_COUNT );
if(pDestItem == NULL)
{
if(source_count == splitted_count)
{
// swap
pSourceTab->pSlots[source_bankslot] = pDestItem;
pDestTab->pSlots[dest_bankslot] = pSourceItem;
}
else
{
pSourceItem->ModUnsigned32Value( ITEM_FIELD_STACK_COUNT, -splitted_count );
pDestItem = objmgr.CreateItem(pSourceItem->GetEntry(), NULL);
pDestItem->SetUInt32Value(ITEM_FIELD_STACK_COUNT, splitted_count);
pDestItem->SetUInt32Value(ITEM_FIELD_CREATOR, pSourceItem->GetUInt32Value(ITEM_FIELD_CREATOR));
pDestTab->pSlots[dest_bankslot] = pDestItem;
}
}
else
{
pDestItem->ModUnsigned32Value( ITEM_FIELD_STACK_COUNT, splitted_count );
if(splitted_count != source_count)
pSourceItem->ModUnsigned32Value( ITEM_FIELD_STACK_COUNT, -splitted_count );
else
{
pSourceItem->Destructor();
//.........这里部分代码省略.........
示例6: HandleAcceptTrade
void WorldSession::HandleAcceptTrade(WorldPacket & recv_data)
{
if(!_player->IsInWorld() || _player->mTradeTarget == 0)
return;
uint32 TradeStatus = TRADE_STATUS_ACCEPTED;
Player* pTarget = _player->GetTradeTarget();
if(pTarget == NULL || !pTarget->IsInWorld())
TradeStatus = TRADE_STATUS_PLAYER_NOT_FOUND;
// Tell the other player we're green.
if(pTarget->m_session && pTarget->m_session->GetSocket())
pTarget->m_session->SendTradeStatus(TradeStatus);
_player->mTradeStatus = TradeStatus;
//Both sides accepted? Let's trade!
if(_player->mTradeStatus == TRADE_STATUS_ACCEPTED && pTarget->mTradeStatus == TRADE_STATUS_ACCEPTED)
{
// Ready!
uint32 ItemCount = 0;
uint32 TargetItemCount = 0;
Item* pItem;
// Count items on both sides, check if bags are empty.
for(uint32 Index = 0; Index < 6; ++Index)
{
if(_player->mTradeItems[Index] != NULL)
{
pItem = _player->mTradeItems[Index];
if( pItem != NULL && pItem->IsContainer() && TO_CONTAINER(pItem)->HasItems())
{
sCheatLog.writefromsession(this, "%s involved in bag-trick trade with %s", _player->GetName(),pTarget->GetName());
_player->GetItemInterface()->BuildInventoryChangeError( pItem, NULL, INV_ERR_CANT_TRADE_EQUIP_BAGS);
TradeStatus = TRADE_STATUS_CANCELLED;
break;
}
else
++ItemCount;
}
if(pTarget->mTradeItems[Index] != NULL)
{
pItem = pTarget->mTradeItems[Index];
if( pItem != NULL && pItem->IsContainer() && TO_CONTAINER(pItem)->HasItems() )
{
sCheatLog.writefromsession(this, "%s involved in bag-trick trade with %s.", pTarget->GetName(),_player->GetName());
pTarget->GetItemInterface()->BuildInventoryChangeError( pItem, NULL, INV_ERR_CANT_TRADE_EQUIP_BAGS);
TradeStatus = TRADE_STATUS_CANCELLED;
break;
}
else
++TargetItemCount;
}
}
//Do we have something to trade?
if( ItemCount == 0 && TargetItemCount == 0 && _player->mTradeGold == 0 && pTarget->mTradeGold == 0 )
TradeStatus = TRADE_STATUS_CANCELLED;
//Do we have enough free slots on both sides?
else if((_player->m_ItemInterface->CalculateFreeSlots(NULL) + ItemCount) < TargetItemCount || (pTarget->m_ItemInterface->CalculateFreeSlots(NULL) + TargetItemCount) < ItemCount )
TradeStatus = TRADE_STATUS_CANCELLED;
//Everything still ok?
else if(TradeStatus == TRADE_STATUS_ACCEPTED)
{
uint64 Guid;
//Swapp 6 itemslots (7th will not trade)
for(uint32 Index = 0; Index < 6; ++Index)
{
Guid = _player->mTradeItems[Index] ? _player->mTradeItems[Index]->GetGUID() : 0;
if(Guid != 0)
{
if( _player->mTradeItems[Index]->IsSoulbound())
_player->GetItemInterface()->BuildInventoryChangeError( _player->mTradeItems[Index], NULL, INV_ERR_CANNOT_TRADE_THAT);
else
{
//Remove from player
pItem = _player->m_ItemInterface->SafeRemoveAndRetreiveItemByGuidRemoveStats(Guid, true);
//and add to pTarget
if(pItem != NULL)
{
pItem->SetOwner(pTarget);
if( !pTarget->m_ItemInterface->AddItemToFreeSlot(pItem) )
{
pItem->Destructor();
pItem = NULL;
}
}
if(GetPermissionCount()>0 || pTarget->GetSession()->GetPermissionCount()>0)
sGMLog.writefromsession(this, "trade item %s with %s (soulbound = %d)", _player->mTradeItems[Index]->GetProto()->Name1, pTarget->GetName());
}
}
Guid = pTarget->mTradeItems[Index] ? pTarget->mTradeItems[Index]->GetGUID() : 0;
if(Guid != 0)
{
if( pTarget->mTradeItems[Index]->IsSoulbound())
pTarget->GetItemInterface()->BuildInventoryChangeError( pTarget->mTradeItems[Index], NULL, INV_ERR_CANNOT_TRADE_THAT);
//.........这里部分代码省略.........
示例7: HandleQuestStartCommand
bool ChatHandler::HandleQuestStartCommand(const char * args, WorldSession * m_session)
{
if(!*args) return false;
Player* plr = getSelectedChar(m_session, true);
if(!plr)
{
plr = m_session->GetPlayer();
SystemMessage(m_session, "Auto-targeting self.");
}
uint32 quest_id = atol(args);
std::string recout = "|cff00ff00";
Quest * qst = QuestStorage.LookupEntry(quest_id);
if(qst)
{
if (plr->HasFinishedQuest(quest_id) || plr->HasFinishedDailyQuest(quest_id))
recout += "Player has already completed that quest.";
else
{
QuestLogEntry * IsPlrOnQuest = plr->GetQuestLogForEntry(quest_id);
if (IsPlrOnQuest)
recout += "Player is currently on that quest.";
else
{
int32 open_slot = plr->GetOpenQuestSlot();
if (open_slot == -1)
{
sQuestMgr.SendQuestLogFull(plr);
recout += "Player's quest log is full.";
}
else
{
QuestLogEntry *qle = new QuestLogEntry();
qle->Init(qst, plr, (uint32)open_slot);
qle->UpdatePlayerFields();
CALL_QUESTSCRIPT_EVENT(qle, OnQuestStart)(plr, qle);
// If the quest should give any items on begin, give them the items.
for(uint32 i = 0; i < 4; ++i)
{
if(qst->receive_items[i])
{
Item* item = objmgr.CreateItem( qst->receive_items[i], plr);
if(!plr->GetItemInterface()->AddItemToFreeSlot(item))
{
if(item)
item->Destructor();
}
}
}
if(qst->srcitem && qst->srcitem != qst->receive_items[0])
{
Item* item = objmgr.CreateItem( qst->srcitem, plr);
if(item)
{
item->SetUInt32Value(ITEM_FIELD_STACK_COUNT, qst->srcitemcount ? qst->srcitemcount : 1);
if(!plr->GetItemInterface()->AddItemToFreeSlot(item))
{
if(item)
item->Destructor();
}
}
}
plr->UpdateNearbyGameObjects();
sHookInterface.OnQuestAccept( plr, qst, NULL );
recout += "Quest has been added to the player's quest log.";
}
}
}
}
else
{
recout += "Quest Id [";
recout += args;
recout += "] was not found and unable to add it to the player's quest log.";
}
recout += "\n\n";
SendMultilineMessage(m_session, recout.c_str());
return true;
}
示例8: GivePoints
bool EyeOfTheStorm::GivePoints(uint32 team, uint32 points)
{
if(m_ended || !m_started)
return false;
m_points[team] += points;
if( m_points[team] >= m_resourceRewards[team] )
{
m_resourceRewards[team] += m_resToGainBH;
for(set<Player*>::iterator itx = m_players[team].begin(); itx != m_players[team].end(); ++itx)
{
Player* plr = (*itx);
if(!plr) continue;
(*itx)->m_bgScore.BonusHonor += m_bonusHonor;
HonorHandler::AddHonorPointsToPlayer( plr, m_bonusHonor );
}
}
if( m_points[team] >= 1600 )
{
m_points[team] = 1600;
m_mapMgr->GetStateManager().UpdateWorldState( WORLDSTATE_EOTS_ALLIANCE_VICTORYPOINTS + team, m_points[team] );
m_ended = true;
m_losingteam = (team) ? 0 : 1;
m_nextPvPUpdateTime = 0;
sEventMgr.RemoveEvents(this);
sEventMgr.AddEvent(TO_CBATTLEGROUND(this), &CBattleground::Close, EVENT_BATTLEGROUND_CLOSE, 120000, 1,0);
SendChatMessage( CHAT_MSG_BG_SYSTEM_NEUTRAL, 0, "|cffffff00This battleground will close in 2 minutes.");
/* add the marks of honor to all players */
m_mainLock.Acquire();
for(uint32 i = 0; i < 2; ++i)
{
for(set<Player*>::iterator itr = m_players[i].begin(); itr != m_players[i].end(); ++itr)
{
(*itr)->Root();
if( (*itr)->HasFlag(PLAYER_FLAGS, PLAYER_FLAG_AFK) )
continue;
// create eye of the storm mark of honor
uint32 item_count = (i == m_losingteam) ? 1 : 3;
if( i != m_losingteam )
{
(*itr)->m_bgScore.BonusHonor += 2*m_bonusHonor;
HonorHandler::AddHonorPointsToPlayer( (*itr), 2*m_bonusHonor );
}
else
{
(*itr)->m_bgScore.BonusHonor += m_bonusHonor;
HonorHandler::AddHonorPointsToPlayer( (*itr), m_bonusHonor );
uint32 diff = abs((int32)(m_points[i] - m_points[i ? 0 : 1]));
(*itr)->GetAchievementInterface()->HandleAchievementCriteriaWinBattleground( m_mapMgr->GetMapId(), diff, ((uint32)UNIXTIME - m_startTime) / 1000, TO_CBATTLEGROUND(this));
}
Item* pReward;
SlotResult res;
if( ( pReward = (*itr)->GetItemInterface()->FindItemLessMax(EOTS_MARK_ID, item_count, false) ) == NULL )
{
res = (*itr)->GetItemInterface()->FindFreeInventorySlot( ItemPrototypeStorage.LookupEntry(EOTS_MARK_ID) );
if( !res.Result )
{
(*itr)->BroadcastMessage("Could not add EOTS mark. Make sure you have room in your inventory.");
continue;
}
pReward = objmgr.CreateItem(EOTS_MARK_ID, (*itr));
pReward->SetUInt32Value(ITEM_FIELD_STACK_COUNT, item_count);
pReward->m_isDirty = true;
if( !(*itr)->GetItemInterface()->SafeAddItem(pReward, res.ContainerSlot, res.Slot) )
{
if( !(*itr)->GetItemInterface()->AddItemToFreeSlot(pReward) )
{
pReward->Destructor();
pReward = NULL;
}
}
(*itr)->GetSession()->SendItemPushResult(pReward,true,false,true,false,res.ContainerSlot,res.Slot, item_count);
}
else
{
pReward->m_isDirty = true;
pReward->ModUnsigned32Value(ITEM_FIELD_STACK_COUNT, item_count);
res.ContainerSlot = (*itr)->GetItemInterface()->GetBagSlotByGuid(pReward->GetGUID());
res.Slot = -1;
(*itr)->GetSession()->SendItemPushResult(pReward,true,false,true,true,res.ContainerSlot,res.Slot, item_count);
}
}
}
UpdatePvPData();
m_mainLock.Release();
return true;
}
//.........这里部分代码省略.........