本文整理汇总了C++中ItemInst::Clear方法的典型用法代码示例。如果您正苦于以下问题:C++ ItemInst::Clear方法的具体用法?C++ ItemInst::Clear怎么用?C++ ItemInst::Clear使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类ItemInst
的用法示例。
在下文中一共展示了ItemInst::Clear方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: HandleAugmentation
//.........这里部分代码省略.........
else if (!container->GetItem(0)->IsAugmentable() && container->GetItem(1)->IsAugmentable())
{
tobe_auged = container->GetItem(1);
auged_with = container->GetItem(0);
}
else
{
// Either 2 augmentable items found or none found
// This should never occur due to client restrictions, but prevent in case of a hack
user->Message(13, "Error: Must be 1 augmentable item in the sealer");
return;
}
}
else
{
// This happens if the augment button is clicked more than once quickly while augmenting
if (!container->GetItem(0))
{
user->Message(13, "Error: No item in slot 0 of sealer");
}
if (!container->GetItem(1))
{
user->Message(13, "Error: No item in slot 1 of sealer");
}
return;
}
bool deleteItems = false;
ItemInst *itemOneToPush = NULL, *itemTwoToPush = NULL;
// Adding augment
if (in_augment->augment_slot == -1)
{
if (((slot=tobe_auged->AvailableAugmentSlot(auged_with->GetAugmentType()))!=-1) && (tobe_auged->AvailableWearSlot(auged_with->GetItem()->Slots)))
{
tobe_auged->PutAugment(slot,*auged_with);
itemOneToPush = tobe_auged->Clone();
deleteItems = true;
}
else
{
user->Message(13, "Error: No available slot for augment");
}
}
else
{
ItemInst *old_aug=NULL;
const uint32 id=auged_with->GetID();
if (id==40408 || id==40409 || id==40410)
tobe_auged->DeleteAugment(in_augment->augment_slot);
else
old_aug=tobe_auged->RemoveAugment(in_augment->augment_slot);
itemOneToPush = tobe_auged->Clone();
if (old_aug)
itemTwoToPush = old_aug->Clone();
deleteItems = true;
}
if (deleteItems)
{
if (worldo)
{
container->Clear();
EQApplicationPacket* outapp = new EQApplicationPacket(OP_ClearObject, sizeof(ClearObject_Struct));
ClearObject_Struct *cos = (ClearObject_Struct *)outapp->pBuffer;
cos->Clear = 1;
user->QueuePacket(outapp);
safe_delete(outapp);
database.DeleteWorldContainer(worldo->m_id, zone->GetZoneID());
}
else
{
// Delete items in our inventory container...
for (uint8 i=0; i<10; i++)
{
const ItemInst* inst = container->GetItem(i);
if (inst)
{
user->DeleteItemInInventory(Inventory::CalcSlotId(in_augment->container_slot,i),0,true);
}
}
// Explicitly mark container as cleared.
container->Clear();
}
}
// Must push items after the items in inventory are deleted - necessary due to lore items...
if (itemOneToPush)
{
user->PushItemOnCursor(*itemOneToPush,true);
}
if (itemTwoToPush)
{
user->PushItemOnCursor(*itemTwoToPush,true);
}
}
示例2: HandleCombine
//.........这里部分代码省略.........
// Character hasn't learnt the recipe yet.
// must_learn:
// bit 1 (0x01): recipe can't be experimented
// bit 2 (0x02): can try to experiment but not useable for auto-combine until learnt
// bit 5 (0x10): no learn message, use unlisted flag to prevent it showing up on search
// bit 6 (0x20): unlisted recipe flag
if ((spec.must_learn&0xF) == 1 && !spec.has_learnt) {
// Made up message for the client. Just giving a DNC is the other option.
user->Message(4, "You need to learn how to combine these first.");
EQApplicationPacket* outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return;
}
// Character does not have the required skill.
if(spec.skill_needed > 0 && user->GetSkill(spec.tradeskill) < spec.skill_needed ) {
// Notify client.
user->Message(4, "You are not skilled enough.");
EQApplicationPacket* outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
return;
}
//changing from a switch to string of if's since we don't need to iterate through all of the skills in the SkillType enum
if (spec.tradeskill == ALCHEMY) {
if (user_pp.class_ != SHAMAN) {
user->Message(13, "This tradeskill can only be performed by a shaman.");
return;
}
else if (user_pp.level < MIN_LEVEL_ALCHEMY) {
user->Message(13, "You cannot perform alchemy until you reach level %i.", MIN_LEVEL_ALCHEMY);
return;
}
}
else if (spec.tradeskill == TINKERING) {
if (user_pp.race != GNOME) {
user->Message(13, "Only gnomes can tinker.");
return;
}
}
else if (spec.tradeskill == MAKE_POISON) {
if (user_pp.class_ != ROGUE) {
user->Message(13, "Only rogues can mix poisons.");
return;
}
}
// Send acknowledgement packets to client
EQApplicationPacket* outapp = new EQApplicationPacket(OP_TradeSkillCombine, 0);
user->QueuePacket(outapp);
safe_delete(outapp);
//now clean out the containers.
if(worldcontainer){
container->Clear();
outapp = new EQApplicationPacket(OP_ClearObject, sizeof(ClearObject_Struct));
ClearObject_Struct *cos = (ClearObject_Struct *)outapp->pBuffer;
cos->Clear = 1;
user->QueuePacket(outapp);
safe_delete(outapp);
database.DeleteWorldContainer(worldo->m_id, zone->GetZoneID());
} else{
for (uint8 i=0; i<10; i++){
const ItemInst* inst = container->GetItem(i);
if (inst) {
user->DeleteItemInInventory(Inventory::CalcSlotId(in_combine->container_slot,i),0,true);
}
}
container->Clear();
}
//do the check and send results...
bool success = user->TradeskillExecute(&spec);
// Learn new recipe message
// Update Made count
if (success) {
if (!spec.has_learnt && ((spec.must_learn&0x10) != 0x10)) {
user->Message_StringID(4, TRADESKILL_LEARN_RECIPE, spec.name.c_str());
}
database.UpdateRecipeMadecount(spec.recipe_id, user->CharacterID(), spec.madecount+1);
}
// Replace the container on success if required.
//
if(success && spec.replace_container) {
if(worldcontainer){
//should report this error, but we dont have the recipe ID, so its not very useful
LogFile->write(EQEMuLog::Error, "Replace container combine executed in a world container.");
}
else
user->DeleteItemInInventory(in_combine->container_slot, 0, true);
}
if (success)
parse->EventPlayer(EVENT_COMBINE_SUCCESS, user, spec.name.c_str(), spec.recipe_id);
else
parse->EventPlayer(EVENT_COMBINE_FAILURE, user, spec.name.c_str(), spec.recipe_id);
}