本文整理汇总了C++中NetworkMessage::Reset方法的典型用法代码示例。如果您正苦于以下问题:C++ NetworkMessage::Reset方法的具体用法?C++ NetworkMessage::Reset怎么用?C++ NetworkMessage::Reset使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类NetworkMessage
的用法示例。
在下文中一共展示了NetworkMessage::Reset方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: substractMoneyContainer
bool Player::substractMoneyContainer(Container *container, unsigned long *money)
{
int goldcoins;
int platcoins;
NetworkMessage msg;
for(int i=0; i<container->size();i++)
{
Item *item = container->getItem(i);
Container* new_container = dynamic_cast<Container*>(item);
if(new_container && *money)
{
substractMoneyContainer(new_container, money);
}
else if(item && *money)
{
switch(item->getID())
{
case ITEM_COINS_GOLD:
//gold coins
msg.Reset();
goldcoins = item->getItemCountOrSubtype();
for(containerLayout::const_iterator cit = getContainers(); cit != getEndContainer(); ++cit) {
if(cit->second == container) {
//remove item
msg.AddByte(0x72);
msg.AddByte(cit->first);
msg.AddByte(i);
}
}
container->removeItem(item);
if(*money >= goldcoins)
{
i--; // If we remove an item from the container then we need substract 1 to the container's main item counter
*money -= goldcoins;
//delete item;
item->releaseThing();
}
else
{
item->setItemCountOrSubtype(goldcoins - *money);
*money = 0;
container->addItem(item);
for(containerLayout::const_iterator cit = getContainers(); cit != getEndContainer(); ++cit) {
if(cit->second == container) {
//add item
msg.AddByte(0x70);
msg.AddByte(cit->first);
msg.AddU16(item->getID());
msg.AddByte(item->getItemCountOrSubtype());
}
}
}
sendNetworkMessage(&msg);
break;
case ITEM_COINS_PLATINUM:
//platinum coins
msg.Reset();
goldcoins = item->getItemCountOrSubtype() * 100;
NetworkMessage msg2;
for(containerLayout::const_iterator cit = getContainers(); cit != getEndContainer(); ++cit) {
if(cit->second == container) {
//remove item
msg.AddByte(0x72);
msg.AddByte(cit->first);
msg.AddByte(i);
}
}
container->removeItem(item);
if(*money >= goldcoins)
{
i--; // If we remove an item from the container then we need substract 1 to the container's main item counter
*money -= goldcoins;
//delete item;
item->releaseThing();
}
else
{
platcoins = (int)((goldcoins - *money)/100);
goldcoins = (int)(goldcoins - *money)%100;
*money = 0;
if(platcoins)
{
item->setItemCountOrSubtype(platcoins);
container->addItem(item);
for(containerLayout::const_iterator cit = getContainers(); cit != getEndContainer(); ++cit) {
if(cit->second == container) {
//add item
msg.AddByte(0x70);
msg.AddByte(cit->first);
msg.AddU16(item->getID());
//.........这里部分代码省略.........