本文整理汇总了C++中InPacket类的典型用法代码示例。如果您正苦于以下问题:C++ InPacket类的具体用法?C++ InPacket怎么用?C++ InPacket使用的例子?那么, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了InPacket类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: handle
void ServerIPHandler::handle(InPacket& recv) const
{
recv.skip(2);
// Read the ipv4 adress in a string.
std::string addrstr;
for (int i = 0; i < 4; i++)
{
uint8_t num = static_cast<uint8_t>(recv.read_byte());
addrstr.append(std::to_string(num));
if (i < 3)
{
addrstr.push_back('.');
}
}
// Read the port adress in a string.
std::string portstr = std::to_string(recv.read_short());
int32_t cid = recv.read_int();
// Attempt to reconnect to the server and if successfull, login to the game.
Session::get().reconnect(addrstr.c_str(), portstr.c_str());
PlayerLoginPacket(cid).dispatch();
}
示例2: parseworlds
void Login::parseworlds(InPacket& recv)
{
int8_t worldid = recv.readbyte();
if (worldid != -1)
{
World world;
world.wid = worldid;
world.name = recv.readascii();
world.flag = recv.readbyte();
world.message = recv.readascii();
recv.skip(5);
world.channelcount = recv.readbyte();
for (uint8_t i = 0; i < world.channelcount; i++)
{
recv.readascii();
recv.skip(4);
world.chloads.push_back(recv.readbyte());
recv.skip(2);
}
worlds.push_back(world);
}
}
示例3:
Ladder::Ladder(InPacket& recv)
{
x = recv.readshort();
y1 = recv.readshort();
y2 = recv.readshort();
ladder = recv.readbool();
}
示例4: handle
void DeleteCharResponseHandler::handle(InPacket& recv) const
{
// Read the character id and if deletion was successfull (pic was correct).
int32_t cid = recv.read_int();
uint8_t state = recv.read_byte();
// Extract information from the state byte.
if (state)
{
UILoginNotice::Message message;
switch (state)
{
case 10:
message = UILoginNotice::BIRTHDAY_INCORRECT;
break;
case 20:
message = UILoginNotice::SECOND_PASSWORD_INCORRECT;
break;
default:
message = UILoginNotice::UNKNOWN_ERROR;
}
UI::get().emplace<UILoginNotice>(message);
}
else
{
if (auto charselect = UI::get().get_element<UICharSelect>())
charselect->remove_char(cid);
}
UI::get().enable();
}
示例5: handle
void BuffHandler::handle(InPacket& recv) const
{
int64_t firstmask = recv.read_long();
int64_t secondmask = recv.read_long();
switch (secondmask)
{
case Buff::BATTLESHIP:
handlebuff(recv, Buff::BATTLESHIP);
return;
}
for (Buff::Stat stat : Buff::FIRST_BUFFS)
{
if (firstmask & stat)
{
handlebuff(recv, stat);
}
}
for (Buff::Stat stat : Buff::SECOND_BUFFS)
{
if (secondmask & stat)
{
handlebuff(recv, stat);
}
}
Stage::get().getplayer().recalcstats(false);
}
示例6: handle
void KillMobHandler::handle(InPacket& recv) const
{
int32_t oid = recv.readint();
int8_t animation = recv.readbyte();
Stage::get().getmobs().killmob(oid, animation);
}
示例7: Packet
InPacket::InPacket(const InPacket &rhs)
: Packet(rhs)
{
bodyLength = rhs.getLength();
decryptedBuf = (unsigned char*)malloc(bodyLength * sizeof(unsigned char));
memcpy(decryptedBuf, rhs.getBody(), bodyLength);
}
示例8: parse_world
World LoginParser::parse_world(InPacket& recv)
{
int8_t wid = recv.read_byte();
if (wid == -1)
return{ {}, {}, {}, 0, 0, wid };
std::string name = recv.read_string();
uint8_t flag = recv.read_byte();
std::string message = recv.read_string();
recv.skip(5);
std::vector<int32_t> chloads;
uint8_t channelcount = recv.read_byte();
for (uint8_t i = 0; i < channelcount; ++i)
{
recv.read_string(); // channel name
chloads.push_back(recv.read_int());
recv.skip(1);
recv.skip(2);
}
recv.skip(2);
return{ name, message, chloads, channelcount, flag, wid };
}
示例9: change_map
void SetfieldHandler::change_map(InPacket& recv, int32_t) const
{
recv.skip(3);
int32_t mapid = recv.read_int();
int8_t portalid = recv.read_byte();
stagetransition(portalid, mapid);
}
示例10: if
Footholdtree::Footholdtree(InPacket& recv)
{
int16_t leftw = 30000;
int16_t rightw = -30000;
int16_t botb = -30000;
int16_t topb = 30000;
uint16_t numbase = recv.readshort();
for (uint16_t i = 0; i < numbase; i++)
{
uint8_t layer = recv.readbyte();
uint16_t nummid = recv.readshort();
for (uint16_t j = 0; j < nummid; j++)
{
uint16_t numlast = recv.readshort();
for (uint16_t k = 0; k < numlast; k++)
{
Foothold foothold = Foothold(recv, layer);
if (foothold.getl() < leftw)
{
leftw = foothold.getl();
}
else if (foothold.getr() > rightw)
{
rightw = foothold.getr();
}
if (foothold.getb() > botb)
{
botb = foothold.getb();
}
else if (foothold.gett() < topb)
{
topb = foothold.gett();
}
uint16_t id = foothold.getid();
footholds[id] = foothold;
if (abs(foothold.getslope()) < 0.5)
{
int16_t start = foothold.getl();
int16_t end = foothold.getr();
for (int16_t i = start; i <= end; i++)
{
footholdsbyx.insert(std::make_pair(i, id));
}
}
}
}
}
walls = Range<int16_t>(leftw + 25, rightw - 25);
borders = Range<int16_t>(topb - 400, botb + 400);
}
示例11: parseareainfo
void SetfieldHandler::parseareainfo(InPacket& recv) const
{
std::map<int16_t, std::string> areainfo;
int16_t arsize = recv.read_short();
for (int16_t i = 0; i < arsize; i++)
{
int16_t area = recv.read_short();
areainfo[area] = recv.read_string();
}
}
示例12: parsecharlist
void Login::parsecharlist(InPacket& recv)
{
size_t numchars = recv.readbyte();
for (size_t i = 0; i < numchars; i++)
{
addcharentry(recv);
}
account.pic = recv.readbyte();
account.slots = static_cast<int8_t>(recv.readint());
}
示例13: handlebuff
void ApplyBuffHandler::handlebuff(InPacket& recv, Buffstat::Value bs) const
{
int16_t value = recv.readshort();
int32_t skillid = recv.readint();
int32_t duration = recv.readint();
Buff buff = Buff(bs, value, skillid, duration);
Stage::get().getplayer().givebuff(buff);
UI::get().withelement(UIElement::BUFFLIST, &UIBuffList::addbuff, skillid, duration);
}
示例14: handle
void UpdateskillsHandler::handle(InPacket& recv) const
{
recv.skip(3);
int32_t skillid = recv.readint();
int32_t level = recv.readint();
int32_t masterlevel = recv.readint();
int64_t expire = recv.readlong();
Stage::get().getplayer().getskills().setskill(skillid, level, masterlevel, expire);
}
示例15: handlebuff
void ApplyBuffHandler::handlebuff(InPacket& recv, Buff::Stat bs) const
{
int16_t value = recv.read_short();
int32_t skillid = recv.read_int();
int32_t duration = recv.read_int();
Stage::get().getplayer().givebuff({ bs, value, skillid, duration });
UI::get().with_element<UIBuffList>([&skillid, &duration](auto& bl) {
bl.add_buff(skillid, duration);
});
}