本文整理汇总了C++中CItem::GetRestock方法的典型用法代码示例。如果您正苦于以下问题:C++ CItem::GetRestock方法的具体用法?C++ CItem::GetRestock怎么用?C++ CItem::GetRestock使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类CItem
的用法示例。
在下文中一共展示了CItem::GetRestock方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: restockNPC
//o---------------------------------------------------------------------------o
//| Function : void restockNPC(CChar *i, bool stockAll)
//| Date : Unknown
//| Programmer : UOX3 DevTeam
//o---------------------------------------------------------------------------o
//| Purpose : Restock NPC Vendors
//o---------------------------------------------------------------------------o
void restockNPC(CChar& i, bool stockAll)
{
if (!i.IsShop())
return; // if we aren't a shopkeeper, why bother?
CItem *ci = i.GetItemAtLayer(IL_SELLCONTAINER);
if (ValidateObject(ci))
{
CDataList< CItem * > *ciCont = ci->GetContainsList();
for (CItem *c = ciCont->First(); !ciCont->Finished(); c = ciCont->Next())
if (ValidateObject(c))
{
if (stockAll)
{
c->IncAmount(c->GetRestock());
c->SetRestock(0);
}
else if (c->GetRestock())
{
UI16 stockAmt = UOX_MIN(c->GetRestock(), static_cast<UI16>((c->GetRestock() / 2) + 1));
c->IncAmount(stockAmt);
c->SetRestock(c->GetRestock() - stockAmt);
}
if (cwmWorldState->ServerData()->TradeSystemStatus())
{
CTownRegion *tReg = calcRegionFromXY(i.GetX(), i.GetY(), i.WorldNumber());
Items->StoreItemRandomValue(c, tReg);
}
}
}
}
示例2: Handle
//.........这里部分代码省略.........
CItem *biTemp;
CItem *iMade = NULL;
UI16 j;
for (i = 0; i < itemtotal; ++i)
{
biTemp = bitems[i];
iMade = NULL;
if (biTemp->GetAmount() > amount[i])
{
if (biTemp->isPileable())
{
iMade = Items->DupeItem(tSock, biTemp, amount[i]);
if (iMade != NULL)
{
iMade->SetCont(p);
iMade->PlaceInPack();
boughtItems.push_back(iMade);
}
}
else
{
for (j = 0; j < amount[i]; ++j)
{
iMade = Items->DupeItem(tSock, biTemp, 1);
if (iMade != NULL)
{
iMade->SetCont(p);
iMade->PlaceInPack();
boughtItems.push_back(iMade);
}
}
}
biTemp->IncAmount(-amount[i], true);
biTemp->SetRestock(biTemp->GetRestock() + amount[i]);
}
else
{
switch(layer[i])
{
case 0x1A: // Sell Container
if (biTemp->isPileable())
{
iMade = Items->DupeItem(tSock, biTemp, amount[i]);
if (iMade != NULL)
{
iMade->SetCont(p);
iMade->PlaceInPack();
boughtItems.push_back(iMade);
}
}
else
{
for (j = 0; j < amount[i]; ++j)
{
iMade = Items->DupeItem(tSock, biTemp, 1);
if (iMade != NULL)
{
iMade->SetCont(p);
iMade->PlaceInPack();
boughtItems.push_back(iMade);
}
}
}
biTemp->IncAmount(-amount[i], true);
biTemp->SetRestock(biTemp->GetRestock() + amount[i]);
break;