本文整理汇总了C++中SetSlot函数的典型用法代码示例。如果您正苦于以下问题:C++ SetSlot函数的具体用法?C++ SetSlot怎么用?C++ SetSlot使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了SetSlot函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: SetSlot
void cSlotAreaArmor::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
{
if (ItemCategory::IsHelmet(a_ItemStack.m_ItemType) && GetSlot(0, a_Player)->IsEmpty())
{
if (a_ShouldApply)
{
SetSlot(0, a_Player, a_ItemStack.CopyOne());
}
a_ItemStack.m_ItemCount -= 1;
}
else if (ItemCategory::IsChestPlate(a_ItemStack.m_ItemType) && GetSlot(1, a_Player)->IsEmpty())
{
if (a_ShouldApply)
{
SetSlot(1, a_Player, a_ItemStack.CopyOne());
}
a_ItemStack.m_ItemCount -= 1;
}
else if (ItemCategory::IsLeggings(a_ItemStack.m_ItemType) && GetSlot(2, a_Player)->IsEmpty())
{
if (a_ShouldApply)
{
SetSlot(2, a_Player, a_ItemStack.CopyOne());
}
a_ItemStack.m_ItemCount -= 1;
}
else if (ItemCategory::IsBoots(a_ItemStack.m_ItemType) && GetSlot(3, a_Player)->IsEmpty())
{
if (a_ShouldApply)
{
SetSlot(3, a_Player, a_ItemStack.CopyOne());
}
a_ItemStack.m_ItemCount -= 1;
}
}
示例2: SafeFullRemoveItemFromSlot
void Container::SwapItems(int8 SrcSlot, int8 DstSlot)
{
Item* temp;
if (SrcSlot < 0 || SrcSlot >= (int8)m_itemProto->ContainerSlots)
return;
if (DstSlot < 0 || DstSlot >= (int8)m_itemProto->ContainerSlots)
return;
uint32 destMaxCount = (m_owner->ItemStackCheat) ? 0x7fffffff : ((m_Slot[DstSlot]) ? m_Slot[DstSlot]->GetProto()->MaxCount : 0);
if (m_Slot[DstSlot] && m_Slot[SrcSlot] && m_Slot[DstSlot]->GetEntry() == m_Slot[SrcSlot]->GetEntry() && m_Slot[SrcSlot]->wrapped_item_id == 0 && m_Slot[DstSlot]->wrapped_item_id == 0 && destMaxCount > 1)
{
uint32 total = m_Slot[SrcSlot]->GetStackCount() + m_Slot[DstSlot]->GetStackCount();
m_Slot[DstSlot]->m_isDirty = m_Slot[SrcSlot]->m_isDirty = true;
if (total <= destMaxCount)
{
m_Slot[DstSlot]->ModStackCount(m_Slot[SrcSlot]->GetStackCount());
SafeFullRemoveItemFromSlot(SrcSlot);
return;
}
else
{
if (m_Slot[DstSlot]->GetStackCount() == destMaxCount)
{
}
else
{
int32 delta = destMaxCount - m_Slot[DstSlot]->GetStackCount();
m_Slot[DstSlot]->SetStackCount(destMaxCount);
m_Slot[SrcSlot]->ModStackCount(-delta);
return;
}
}
}
temp = m_Slot[SrcSlot];
m_Slot[SrcSlot] = m_Slot[DstSlot];
m_Slot[DstSlot] = temp;
if (m_Slot[DstSlot])
{
SetSlot(DstSlot, m_Slot[DstSlot]->GetGUID());
m_Slot[DstSlot]->m_isDirty = true;
}
else
{
SetSlot(DstSlot, 0);
}
if (m_Slot[SrcSlot])
{
SetSlot(SrcSlot, m_Slot[SrcSlot]->GetGUID());
m_Slot[SrcSlot]->m_isDirty = true;
}
else
{
SetSlot(SrcSlot, 0);
}
}
示例3: SetSlot
void cSlotAreaAnvil::OnTakeResult(cPlayer & a_Player)
{
if (!a_Player.IsGameModeCreative())
{
a_Player.DeltaExperience(-cPlayer::XpForLevel(m_MaximumCost));
}
SetSlot(0, a_Player, cItem());
if (m_StackSizeToBeUsedInRepair > 0)
{
const cItem * Item = GetSlot(1, a_Player);
if (!Item->IsEmpty() && (Item->m_ItemCount > m_StackSizeToBeUsedInRepair))
{
cItem NewSecondItem(*Item);
NewSecondItem.m_ItemCount -= m_StackSizeToBeUsedInRepair;
m_StackSizeToBeUsedInRepair = 0;
SetSlot(1, a_Player, NewSecondItem);
}
else
{
SetSlot(1, a_Player, cItem());
}
}
else
{
SetSlot(1, a_Player, cItem());
}
m_ParentWindow.SetProperty(0, m_MaximumCost, a_Player);
m_MaximumCost = 0;
((cAnvilWindow*)&m_ParentWindow)->SetRepairedItemName("", NULL);
int PosX, PosY, PosZ;
((cAnvilWindow*)&m_ParentWindow)->GetBlockPos(PosX, PosY, PosZ);
BLOCKTYPE Block;
NIBBLETYPE BlockMeta;
a_Player.GetWorld()->GetBlockTypeMeta(PosX, PosY, PosZ, Block, BlockMeta);
cFastRandom Random;
if (!a_Player.IsGameModeCreative() && (Block == E_BLOCK_ANVIL) && (Random.NextFloat(1.0F) < 0.12F))
{
NIBBLETYPE Orientation = BlockMeta & 0x3;
NIBBLETYPE AnvilDamage = BlockMeta >> 2;
++AnvilDamage;
if (AnvilDamage > 2)
{
// Anvil will break
a_Player.GetWorld()->SetBlock(PosX, PosY, PosZ, E_BLOCK_AIR, (NIBBLETYPE)0);
a_Player.GetWorld()->BroadcastSoundParticleEffect(1020, PosX, PosY, PosZ, 0);
a_Player.CloseWindow(false);
}
else
{
a_Player.GetWorld()->SetBlockMeta(PosX, PosY, PosZ, Orientation | (AnvilDamage << 2));
a_Player.GetWorld()->BroadcastSoundParticleEffect(1021, PosX, PosY, PosZ, 0);
}
}
示例4: Noise
void cItemGrid::GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, size_t a_CountLootProbabs, int a_NumSlots, int a_Seed)
{
// Calculate the total weight:
int TotalProbab = 1;
for (size_t i = 0; i < a_CountLootProbabs; i++)
{
TotalProbab += a_LootProbabs[i].m_Weight;
}
// Pick the loot items:
cNoise Noise(a_Seed);
for (int i = 0; i < a_NumSlots; i++)
{
int Rnd = (Noise.IntNoise1DInt(i) / 7);
int LootRnd = Rnd % TotalProbab;
Rnd >>= 8;
cItem CurrentLoot = cItem(E_ITEM_BOOK, 1, 0); // TODO: enchantment
for (size_t j = 0; j < a_CountLootProbabs; j++)
{
LootRnd -= a_LootProbabs[i].m_Weight;
if (LootRnd < 0)
{
CurrentLoot = a_LootProbabs[i].m_Item;
CurrentLoot.m_ItemCount = a_LootProbabs[i].m_MinAmount + (Rnd % (a_LootProbabs[i].m_MaxAmount - a_LootProbabs[i].m_MinAmount));
Rnd >>= 8;
break;
}
} // for j - a_LootProbabs[]
SetSlot(Rnd % m_NumSlots, CurrentLoot);
} // for i - NumSlots
示例5: SetSlot
bool Container::AddItemToFreeSlot(Item* pItem, uint32* r_slot)
{
uint32 slot;
for (slot = 0; slot < GetProto()->ContainerSlots; slot++)
{
if (!m_Slot[slot])
{
m_Slot[slot] = pItem;
pItem->m_isDirty = true;
pItem->SetContainerGUID(GetGUID());
pItem->SetOwner(m_owner);
SetSlot(uint16(slot), pItem->GetGUID());
if (m_owner->IsInWorld() && !pItem->IsInWorld())
{
pItem->PushToWorld(m_owner->GetMapMgr());
ByteBuffer buf(2500);
uint32 count = pItem->BuildCreateUpdateBlockForPlayer(&buf, m_owner);
m_owner->PushCreationData(&buf, count);
}
if (r_slot)
*r_slot = slot;
#ifdef ENABLE_ACHIEVEMENTS
m_owner->GetAchievementMgr().UpdateAchievementCriteria(ACHIEVEMENT_CRITERIA_TYPE_OWN_ITEM, pItem->GetProto()->ItemId, pItem->GetStackCount(), 0);
#endif
return true;
}
}
return false;
}
示例6: UpdateResult
void cSlotAreaAnvil::ShiftClicked(cPlayer & a_Player, int a_SlotNum, const cItem & a_ClickedItem)
{
if (a_SlotNum != 2)
{
super::ShiftClicked(a_Player, a_SlotNum, a_ClickedItem);
UpdateResult(a_Player);
return;
}
// Make a copy of the slot, distribute it among the other areas, then update the slot to contain the leftover:
cItem Slot(*GetSlot(a_SlotNum, a_Player));
if (Slot.IsEmpty() || !CanTakeResultItem(a_Player))
{
return;
}
m_ParentWindow.DistributeStack(Slot, a_Player, this, true);
if (Slot.IsEmpty())
{
Slot.Empty();
OnTakeResult(a_Player);
}
SetSlot(a_SlotNum, a_Player, Slot);
// Some clients try to guess our actions and not always right (armor slots in 1.2.5), so we fix them:
m_ParentWindow.BroadcastWholeWindow();
}
示例7: SetSlot
bool cBeaconEntity::LoadFromJson(const Json::Value & a_Value)
{
m_PosX = a_Value.get("x", 0).asInt();
m_PosY = a_Value.get("y", 0).asInt();
m_PosZ = a_Value.get("z", 0).asInt();
Json::Value AllSlots = a_Value.get("Slots", 0);
int SlotIdx = 0;
for (Json::Value::iterator itr = AllSlots.begin(); itr != AllSlots.end(); ++itr)
{
cItem Item;
Item.FromJson(*itr);
SetSlot(SlotIdx, Item);
SlotIdx++;
}
m_BeaconLevel = (char)a_Value.get("Level", 0).asInt();
int PrimaryEffect = a_Value.get("PrimaryEffect", 0).asInt();
int SecondaryEffect = a_Value.get("SecondaryEffect", 0).asInt();
if ((PrimaryEffect >= 0) && (PrimaryEffect <= (int)cEntityEffect::effSaturation))
{
m_PrimaryEffect = (cEntityEffect::eType)PrimaryEffect;
}
if ((SecondaryEffect >= 0) && (SecondaryEffect <= (int)cEntityEffect::effSaturation))
{
m_SecondaryEffect = (cEntityEffect::eType)SecondaryEffect;
}
return true;
}
示例8: GetSlot
void cSlotAreaAnvil::DistributeStack(cItem & a_ItemStack, cPlayer & a_Player, bool a_ShouldApply, bool a_KeepEmptySlots)
{
for (int i = 0; i < 2; i++)
{
const cItem * Slot = GetSlot(i, a_Player);
if (!Slot->IsEqual(a_ItemStack) && (!Slot->IsEmpty() || a_KeepEmptySlots))
{
// Different items
continue;
}
int NumFit = ItemHandler(Slot->m_ItemType)->GetMaxStackSize() - Slot->m_ItemCount;
if (NumFit <= 0)
{
// Full stack already
continue;
}
if (NumFit > a_ItemStack.m_ItemCount)
{
NumFit = a_ItemStack.m_ItemCount;
}
if (a_ShouldApply)
{
cItem NewSlot(a_ItemStack);
NewSlot.m_ItemCount = Slot->m_ItemCount + NumFit;
SetSlot(i, a_Player, NewSlot);
}
a_ItemStack.m_ItemCount -= NumFit;
if (a_ItemStack.IsEmpty())
{
UpdateResult(a_Player);
return;
}
} // for i - Slots
UpdateResult(a_Player);
}
示例9: switch
int SimJointSetWidget::qt_metacall(QMetaObject::Call _c, int _id, void **_a)
{
_id = QWidget::qt_metacall(_c, _id, _a);
if (_id < 0)
return _id;
if (_c == QMetaObject::InvokeMetaMethod) {
switch (_id) {
case 0: UpdateODEJoint(); break;
case 1: UpdateList(); break;
case 2: SetSlot(); break;
case 3: NameSlot((*reinterpret_cast< int(*)>(_a[1]))); break;
case 4: PosXSlot((*reinterpret_cast< double(*)>(_a[1]))); break;
case 5: PosYSlot((*reinterpret_cast< double(*)>(_a[1]))); break;
case 6: PosZSlot((*reinterpret_cast< double(*)>(_a[1]))); break;
case 7: ScaleXSlot((*reinterpret_cast< double(*)>(_a[1]))); break;
case 8: ScaleYSlot((*reinterpret_cast< double(*)>(_a[1]))); break;
case 9: ScaleZSlot((*reinterpret_cast< double(*)>(_a[1]))); break;
case 10: RollSlot((*reinterpret_cast< double(*)>(_a[1]))); break;
case 11: PitchSlot((*reinterpret_cast< double(*)>(_a[1]))); break;
case 12: YawSlot((*reinterpret_cast< double(*)>(_a[1]))); break;
case 13: OffsetXSlot((*reinterpret_cast< double(*)>(_a[1]))); break;
case 14: OffsetYSlot((*reinterpret_cast< double(*)>(_a[1]))); break;
case 15: OffsetZSlot((*reinterpret_cast< double(*)>(_a[1]))); break;
case 16: VisibleSlot(); break;
case 17: unVisibleSlot(); break;
case 18: DestroySlot(); break;
default: ;
}
_id -= 19;
}
return _id;
}
示例10: GetNumSlots
bool cSlotArea::CollectItemsToHand(cItem & a_Dragging, cPlayer & a_Player, bool a_CollectFullStacks)
{
int NumSlots = GetNumSlots();
for (int i = 0; i < NumSlots; i++)
{
const cItem & SlotItem = *GetSlot(i, a_Player);
if (!SlotItem.IsEqual(a_Dragging))
{
continue;
}
int ToMove = a_Dragging.GetMaxStackSize() - a_Dragging.m_ItemCount;
if (ToMove > SlotItem.m_ItemCount)
{
ToMove = SlotItem.m_ItemCount;
}
a_Dragging.m_ItemCount += ToMove;
cItem NewSlot(SlotItem);
NewSlot.m_ItemCount -= ToMove;
SetSlot(i, a_Player, NewSlot);
if (!NewSlot.IsEmpty())
{
// There are leftovers in the slot, so a_Dragging must be full
return true;
}
} // for i - Slots[]
// a_Dragging may be full if there were exactly the number of items needed to fill it
return a_Dragging.IsFullStack();
}
示例11: Grid
void cSlotAreaCrafting::UpdateRecipe(cPlayer & a_Player)
{
cCraftingGrid Grid(GetPlayerSlots(a_Player) + 1, m_GridSize, m_GridSize);
cCraftingRecipe & Recipe = GetRecipeForPlayer(a_Player);
cRoot::Get()->GetCraftingRecipes()->GetRecipe(&a_Player, Grid, Recipe);
SetSlot(0, a_Player, Recipe.GetResult());
m_ParentWindow.SendSlot(a_Player, this, 0);
}
示例12: Object
Package::Package(Engine* eng, Type* pkgType, String* n, Package* superPkg)
: Object(eng, pkgType),
name(n),
dotName(0),
superPackage(superPkg)
{
SetName(n);
SetSlot("__package", this, Slot::ATTR_internal | Slot::ATTR_forcewrite);
}
示例13: SummerfaceLabel
StateLabel::StateLabel (bool aLoad) :
SummerfaceLabel(Area(10, 85, 25, 6), ""),
Slot(1),
Load(aLoad)
{
MDFNI_SelectState(1);
Slot = StateStatusInfo ? StateStatusInfo->recently_saved : Slot;
Slot = (Slot < 1 || Slot > 9) ? 1 : Slot;
SetSlot(Slot);
}
示例14: SetSlot
void CInventoryItem::load(IReader &packet)
{
m_eItemPlace = (EItemPlace)packet.r_u8();
m_fCondition = packet.r_float();
SetSlot (packet.r_u8());
if (GetSlot() == 255)
SetSlot (NO_ACTIVE_SLOT);
u8 tmp = packet.r_u8();
if (!tmp)
return;
if (!object().PPhysicsShell()) {
object().setup_physic_shell ();
object().PPhysicsShell()->Disable();
}
object().PHLoadState(packet);
object().PPhysicsShell()->Disable();
}
示例15: Noise
void cItemGrid::GenerateRandomLootWithBooks(const cLootProbab * a_LootProbabs, size_t a_CountLootProbabs, int a_NumSlots, int a_Seed)
{
// Calculate the total weight:
int TotalProbab = 1;
for (size_t i = 0; i < a_CountLootProbabs; i++)
{
TotalProbab += a_LootProbabs[i].m_Weight;
}
// Pick the loot items:
cNoise Noise(a_Seed);
for (int i = 0; i < a_NumSlots; i++)
{
int Rnd = (Noise.IntNoise1DInt(i) / 7);
int LootRnd = Rnd % TotalProbab;
Rnd >>= 8;
cItem CurrentLoot = cItem(E_ITEM_ENCHANTED_BOOK, 1, 0);
// Choose the enchantments
cWeightedEnchantments Enchantments;
cEnchantments::AddItemEnchantmentWeights(Enchantments, E_ITEM_BOOK, 24 + Noise.IntNoise2DInt(a_Seed, TotalProbab) % 7);
int NumEnchantments = Noise.IntNoise3DInt(TotalProbab, Rnd, a_Seed) % 5; // The number of enchantments this book wil get.
for (int j = 0; j <= NumEnchantments; j++)
{
cEnchantments Enchantment = cEnchantments::SelectEnchantmentFromVector(Enchantments, Noise.IntNoise2DInt(NumEnchantments, i));
CurrentLoot.m_Enchantments.Add(Enchantment);
cEnchantments::RemoveEnchantmentWeightFromVector(Enchantments, Enchantment);
cEnchantments::CheckEnchantmentConflictsFromVector(Enchantments, Enchantment);
}
for (size_t j = 0; j < a_CountLootProbabs; j++)
{
LootRnd -= a_LootProbabs[j].m_Weight;
if (LootRnd < 0)
{
CurrentLoot = a_LootProbabs[j].m_Item;
if ((a_LootProbabs[j].m_MaxAmount - a_LootProbabs[j].m_MinAmount) > 0)
{
CurrentLoot.m_ItemCount = static_cast<char>(a_LootProbabs[j].m_MinAmount + (Rnd % (a_LootProbabs[j].m_MaxAmount - a_LootProbabs[j].m_MinAmount)));
}
else
{
CurrentLoot.m_ItemCount = static_cast<char>(a_LootProbabs[j].m_MinAmount);
}
Rnd >>= 8;
break;
}
} // for j - a_LootProbabs[]
SetSlot(Rnd % m_NumSlots, CurrentLoot);
} // for i - NumSlots