本文整理汇总了C++中InPacket::length方法的典型用法代码示例。如果您正苦于以下问题:C++ InPacket::length方法的具体用法?C++ InPacket::length怎么用?C++ InPacket::length使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类InPacket
的用法示例。
在下文中一共展示了InPacket::length方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle
void RemoveDropHandler::handle(InPacket& recv) const
{
int8_t mode = recv.readbyte();
int32_t oid = recv.readint();
using Gameplay::PhysicsObject;
Optional<PhysicsObject> looter;
if (mode > 1)
{
int32_t cid = recv.readint();
if (recv.length() > 0)
{
recv.readbyte(); // pet
}
else
{
looter = Stage::get().getcharacter(cid)
.transform(&Char::getphobj);
}
AudioPlayer::get().playsound(AudioPlayer::PICKUP);
}
Stage::get().getdrops().removedrop(oid, mode, looter.get());
}
示例2: handle
void ModifyInventoryHandler::handle(InPacket& recv) const
{
recv.read_bool(); // 'updatetick'
Inventory& inventory = Stage::get().getplayer().getinvent();
struct Mod
{
int8_t mode;
Inventory::Type type;
int16_t pos;
int16_t arg;
};
std::vector<Mod> mods;
int8_t size = recv.read_byte();
for (int8_t i = 0; i < size; i++)
{
Mod mod;
mod.mode = recv.read_byte();
mod.type = Inventory::typebyvalue(recv.read_byte());
mod.pos = recv.read_short();
mod.arg = 0;
switch (mod.mode)
{
case 0:
ItemParser::parseitem(recv, mod.type, mod.pos, inventory);
break;
case 1:
mod.arg = recv.read_short();
if (inventory.changecount(mod.type, mod.pos, mod.arg))
mod.mode = 4;
break;
case 2:
mod.arg = recv.read_short();
break;
case 3:
inventory.modify(mod.type, mod.pos, mod.mode, mod.arg, Inventory::MOVE_INTERNAL);
break;
}
mods.push_back(mod);
}
Inventory::Movement move = (recv.length() > 0) ?
Inventory::movementbyvalue(recv.read_byte()) :
Inventory::MOVE_INTERNAL;
for (Mod& mod : mods)
{
if (mod.mode == 2)
{
inventory.modify(mod.type, mod.pos, mod.mode, mod.arg, move);
}
UI::get().with_element<UIShop>([&mod](auto& s) {
s.modify(mod.type);
});
auto eqinvent = UI::get().get_element<UIEquipInventory>();
auto itinvent = UI::get().get_element<UIItemInventory>();
switch (move)
{
case Inventory::MOVE_INTERNAL:
switch (mod.type)
{
case Inventory::EQUIPPED:
if (eqinvent)
eqinvent->modify(mod.pos, mod.mode, mod.arg);
Stage::get().getplayer().changecloth(-mod.pos);
Stage::get().getplayer().changecloth(-mod.arg);
break;
case Inventory::EQUIP:
case Inventory::USE:
case Inventory::SETUP:
case Inventory::ETC:
case Inventory::CASH:
if (itinvent)
itinvent->modify(mod.type, mod.pos, mod.mode, mod.arg);
break;
}
break;
case Inventory::MOVE_EQUIP:
case Inventory::MOVE_UNEQUIP:
if (mod.pos < 0)
{
if (eqinvent)
eqinvent->modify(-mod.pos, 3, 0);
if (itinvent)
itinvent->modify(Inventory::EQUIP, mod.arg, 0, 0);
Stage::get().getplayer().changecloth(-mod.pos);
}
else if (mod.arg < 0)
{
if (eqinvent)
eqinvent->modify(-mod.arg, 0, 0);
//.........这里部分代码省略.........