本文整理汇总了C++中PacketReader::getBuffer方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketReader::getBuffer方法的具体用法?C++ PacketReader::getBuffer怎么用?C++ PacketReader::getBuffer使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader::getBuffer方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: parseIncomingPacket
// Stored packets
void PlayerDataProvider::parseIncomingPacket(PacketReader &packet) {
int32_t playerid = packet.get<int32_t>();
bool fromCashOrMts = packet.getBool();
size_t psize = packet.getBufferLength();
unsigned char *buf = new unsigned char[psize]; // Prevent the packet memory from being freed by external sources
memcpy(buf, packet.getBuffer(), psize);
m_packets[playerid].reset(new PacketReader(buf, psize));
SyncPacket::playerBuffsTransferred(ChannelServer::Instance()->getWorldConnection(), playerid, fromCashOrMts);
}
示例2: sendToPlayers
void WorldServerConnectHandler::sendToPlayers(PacketReader &packet) {
PlayersPacket::sendToPlayers(packet.getBuffer(), packet.getBufferLength());
}
示例3: monsterControl
void MobHandler::monsterControl(Player *player, PacketReader &packet) {
int32_t mobid = packet.get<int32_t>();
Mob *mob = Maps::getMap(player->getMap())->getMob(mobid);
if (mob == nullptr || mob->getControlStatus() == Mobs::ControlStatus::ControlNone) {
return;
}
int16_t moveid = packet.get<int16_t>();
bool useskill = packet.getBool();
int8_t skill = packet.get<int8_t>();
uint8_t realskill = 0;
uint8_t level = 0;
Pos projectiletarget = packet.getPos();
packet.skipBytes(5); // 1 byte of always 0?, 4 bytes of always 1 or always 0?
Pos spot = packet.getPos();
MovementHandler::parseMovement(mob, packet);
if (useskill && (skill == -1 || skill == 0)) {
if (!(mob->hasStatus(StatusEffects::Mob::Freeze) || mob->hasStatus(StatusEffects::Mob::Stun) || mob->hasStatus(StatusEffects::Mob::ShadowWeb))) {
uint8_t size = mob->getSkillCount();
bool used = false;
if (size) {
bool stop = false;
uint8_t rand = Randomizer::Instance()->randChar(size - 1);
MobSkillInfo *info = MobDataProvider::Instance()->getMobSkill(mob->getMobId(), rand);
realskill = info->skillId;
level = info->level;
MobSkillLevelInfo *mobskill = SkillDataProvider::Instance()->getMobSkill(realskill, level);
switch (realskill) {
case MobSkills::WeaponAttackUp:
case MobSkills::WeaponAttackUpAoe:
stop = mob->hasStatus(StatusEffects::Mob::Watk);
break;
case MobSkills::MagicAttackUp:
case MobSkills::MagicAttackUpAoe:
stop = mob->hasStatus(StatusEffects::Mob::Matk);
break;
case MobSkills::WeaponDefenseUp:
case MobSkills::WeaponDefenseUpAoe:
stop = mob->hasStatus(StatusEffects::Mob::Wdef);
break;
case MobSkills::MagicDefenseUp:
case MobSkills::MagicDefenseUpAoe:
stop = mob->hasStatus(StatusEffects::Mob::Mdef);
break;
case MobSkills::WeaponImmunity:
case MobSkills::MagicImmunity:
case MobSkills::WeaponDamageReflect:
case MobSkills::MagicDamageReflect:
stop = mob->hasImmunity();
break;
case MobSkills::McSpeedUp:
stop = mob->hasStatus(StatusEffects::Mob::Speed);
break;
case MobSkills::Summon: {
int16_t limit = mobskill->limit;
if (limit == 5000) // Custom limit based on number of players on map
limit = 30 + Maps::getMap(mob->getMapId())->getNumPlayers() * 2;
if (mob->getSpawnCount() >= limit)
stop = true;
break;
}
}
if (!stop) {
time_t now = time(0);
time_t ls = mob->getLastSkillUse(realskill);
if (ls == 0 || ((int32_t)(now - ls) > mobskill->interval)) {
mob->setLastSkillUse(realskill, now);
int64_t reqhp = mob->getHp() * 100;
reqhp /= mob->getMaxHp();
if ((uint8_t)(reqhp) <= mobskill->hp) {
if (info->effectAfter == 0) {
handleMobSkill(mob, realskill, level, mobskill);
}
else {
new Timer::Timer(bind(&MobHandler::handleMobSkill, mob, realskill, level, mobskill),
Timer::Id(Timer::Types::MobSkillTimer, mob->getMobId(), mob->getCounter()),
mob->getTimers(), Timer::Time::fromNow(info->effectAfter));
}
used = true;
}
}
}
}
if (!used) {
realskill = 0;
level = 0;
}
}
}
MobsPacket::moveMobResponse(player, mobid, moveid, useskill, mob->getMp(), realskill, level);
packet.reset(19);
MobsPacket::moveMob(player, mobid, useskill, skill, projectiletarget, packet.getBuffer(), packet.getBufferLength());
}
示例4: useCashItem
void InventoryHandler::useCashItem(Player *player, PacketReader &packet) {
packet.get<int8_t>(); // Type
packet.skipBytes(1);
int32_t itemid = packet.get<int32_t>();
if (!player->getInventory()->getItemAmount(itemid)) {
// Hacking
return;
}
bool used = false;
if (GameLogicUtilities::getItemType(itemid) == Items::Types::WeatherCash) {
string message = packet.getString();
if (!player->updateTickCount(packet.get<int32_t>())) {
// Tickcount was the same or less than 100 of the difference.
return;
}
if (message.length() <= 35) {
Map *map = Maps::getMap(player->getMap());
message = player->getName() + " 's message : " + message;
used = map->createWeather(player, false, Items::WeatherTime, itemid, message);
}
}
else if (GameLogicUtilities::getItemType(itemid) == Items::Types::CashPetFood) {
// Pet food.
Pet *pet = player->getPets()->getSummoned(0);
if (pet != nullptr) {
if (pet->getFullness() < Stats::MaxFullness) {
PetsPacket::showAnimation(player, pet, 1);
pet->modifyFullness(Stats::MaxFullness, false);
pet->addCloseness(100); // All cash pet food gives 100 closeness.
used = true;
}
}
}
else {
switch (itemid) {
case Items::TeleportRock:
case Items::TeleportCoke:
case Items::VipRock: // Only occurs when you actually try to move somewhere
used = handleRockTeleport(player, itemid, packet);
break;
case Items::FirstJobSpReset:
case Items::SecondJobSpReset:
case Items::ThirdJobSpReset:
case Items::FourthJobSpReset: {
int32_t toskill = packet.get<int32_t>();
int32_t fromskill = packet.get<int32_t>();
if (!player->getSkills()->addSkillLevel(fromskill, -1, true)) {
// Hacking
return;
}
if (!player->getSkills()->addSkillLevel(toskill, 1, true)) {
// Hacking
return;
}
used = true;
break;
}
case Items::ApReset: {
int32_t tostat = packet.get<int32_t>();
int32_t fromstat = packet.get<int32_t>();
player->getStats()->addStat(tostat, 1, true);
player->getStats()->addStat(fromstat, -1, true);
used = true;
break;
}
case Items::Megaphone: {
string msg = player->getMedalName() + " : " + packet.getString();
InventoryPacket::showMegaphone(player, msg);
used = true;
break;
}
case Items::SuperMegaphone: {
string msg = player->getMedalName() + " : " + packet.getString();
bool whisper = packet.getBool();
InventoryPacket::showSuperMegaphone(player, msg, whisper);
used = true;
break;
}
case Items::DiabloMessenger:
case Items::Cloud9Messenger:
case Items::LoveholicMessenger: {
string msg = packet.getString();
string msg2 = packet.getString();
string msg3 = packet.getString();
string msg4 = packet.getString();
InventoryPacket::showMessenger(player, msg, msg2, msg3, msg4, packet.getBuffer(), packet.getBufferLength(), itemid);
used = true;
break;
}
case Items::ItemMegaphone: {
string msg = player->getMedalName() + " : " + packet.getString();
bool whisper = packet.getBool();
Item *item = nullptr;
if (packet.getBool()) {
int8_t inv = (int8_t) packet.get<int32_t>();
int16_t slot = (int16_t) packet.get<int32_t>();
item = player->getInventory()->getItem(inv, slot);
//.........这里部分代码省略.........
示例5: addBuffer
void PacketCreator::addBuffer(PacketReader &packet) {
addBuffer(packet.getBuffer(), packet.getBufferLength());
}