本文整理汇总了C++中PacketReader::getString方法的典型用法代码示例。如果您正苦于以下问题:C++ PacketReader::getString方法的具体用法?C++ PacketReader::getString怎么用?C++ PacketReader::getString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类PacketReader
的用法示例。
在下文中一共展示了PacketReader::getString方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: whisperPlayer
void WorldServerConnectHandler::whisperPlayer(PacketReader &packet) {
int32_t whisperee = packet.get<int32_t>();
string whisperer = packet.getString();
uint16_t channel = packet.get<int16_t>();
string message = packet.getString();
PlayersPacket::whisperPlayer(PlayerDataProvider::Instance()->getPlayer(whisperee), whisperer, channel, message);
}
示例2: findPlayer
void WorldServerConnectHandler::findPlayer(PacketReader &packet) {
int32_t finder = packet.get<int32_t>();
int16_t channel = packet.get<int16_t>();
string name = packet.getString();
int8_t is = packet.get<int8_t>();
PlayersPacket::findPlayer(PlayerDataProvider::Instance()->getPlayer(finder), name, channel, is);
}
示例3: sendChangeNotice
void AlliancePacket::sendChangeNotice(int32_t allianceid, int32_t playerid, PacketReader &pack) {
PacketCreator packet;
packet.add<int16_t>(IMSG_SYNC);
packet.add<int8_t>(Sync::SyncTypes::Alliance);
packet.add<int8_t>(Sync::Alliance::ChangeNotice);
packet.add<int32_t>(allianceid);
packet.add<int32_t>(playerid);
packet.addString(pack.getString());
ChannelServer::Instance()->sendToWorld(packet);
}
示例4: useScriptedPortal
void Maps::useScriptedPortal(Player *player, PacketReader &packet) {
packet.skipBytes(1);
string portalname = packet.getString();
PortalInfo *portal = getMap(player->getMap())->getPortal(portalname);
if (portal == nullptr) // Exit the function if portal is not found
return;
usePortal(player, portal);
}
示例5: usePortal
void Maps::usePortal(Player *player, PacketReader &packet) {
packet.skipBytes(1);
int32_t opcode = packet.get<int32_t>();
switch (opcode) {
case 0: // Dead
if (player->getStats()->getHp() == 0) {
packet.getString(); // Useless
packet.skipBytes(1); // Useless
bool wheel = packet.getBool();
if (wheel && player->getInventory()->getItemAmount(Items::WheelOfDestiny) <= 0) {
player->acceptDeath(false);
return;
}
Inventory::takeItem(player, Items::WheelOfDestiny, 1);
player->acceptDeath(wheel);
}
break;
case -1: {
string portalname = packet.getString();
Map *tomap = getMap(player->getMap());
if (tomap == nullptr)
return;
PortalInfo *portal = tomap->getPortal(portalname);
if (portal == nullptr) // Exit the function if portal is not found
return;
usePortal(player, portal);
break;
}
default: { // GM Map change (command "/m")
if (player->isGm() && getMap(opcode)) {
player->setMap(opcode);
}
}
}
}
示例6: handlePacket
void AlliancePacket::handlePacket(Player *player, PacketReader &packet) {
switch (packet.get<int8_t>()) {
case 0x01: sendShowInfo(player->getAllianceId(), player->getId()); break;
case 0x02: { // Leave Alliance
if (player->getAllianceId() == 0 || player->getAllianceRank() != 2 || player->getGuildId() == 0 || player->getGuildRank() != 1)
return;
sendChangeGuild(player->getAllianceId(), player->getId(), player->getGuildId(), 2);
break;
}
case 0x03: sendInvitation(player->getAllianceId(), player->getId(), packet.getString()); break;
case 0x04: { // Invite accepted
int32_t guildid = packet.get<int32_t>();
string guildname = packet.getString();
if (player->getAllianceId() != 0 || player->getGuildRank() != 1 || player->getGuildId() == 0)
return;
sendChangeGuild(guildid, player->getId(), player->getGuildId(), 0);
break;
}
case 0x06: { // Expel Guild
int32_t guildid = packet.get<int32_t>();
int32_t allianceid = packet.get<int32_t>();
if (player->getAllianceId() == 0 || player->getAllianceRank() != 1 || player->getAllianceId() != allianceid)
return;
sendChangeGuild(allianceid, player->getId(), guildid, 1);
break;
}
case 0x07: { // Change Alliance Leader
if (player->getAllianceId() == 0 || player->getAllianceRank() != 1 || player->getGuildId() == 0 || player->getGuildRank() > 1)
return;
sendChangeLeader(player->getAllianceId(), player->getId(), packet.get<int32_t>());
break;
}
case 0x08: sendChangeTitles(player->getAllianceId(), player->getId(), packet); break;
case 0x09: sendChangeRank(player->getAllianceId(), player->getId(), packet); break;
case 0x0a: sendChangeNotice(player->getAllianceId(), player->getId(), packet); break;
}
}
示例7: reloadMcdb
void WorldServerConnectHandler::reloadMcdb(PacketReader &packet) {
string args = packet.getString();
if (args == "all") {
ItemDataProvider::Instance()->loadData();
DropDataProvider::Instance()->loadData();
ShopDataProvider::Instance()->loadData();
MobDataProvider::Instance()->loadData();
BeautyDataProvider::Instance()->loadData();
ScriptDataProvider::Instance()->loadData();
SkillDataProvider::Instance()->loadData();
ReactorDataProvider::Instance()->loadData();
QuestDataProvider::Instance()->loadData();
}
else if (args == "items") ItemDataProvider::Instance()->loadData();
else if (args == "drops") DropDataProvider::Instance()->loadData();
else if (args == "shops") ShopDataProvider::Instance()->loadData();
else if (args == "mobs") MobDataProvider::Instance()->loadData();
else if (args == "beauty") BeautyDataProvider::Instance()->loadData();
else if (args == "scripts") ScriptDataProvider::Instance()->loadData();
else if (args == "skills") SkillDataProvider::Instance()->loadData();
else if (args == "reactors") ReactorDataProvider::Instance()->loadData();
else if (args == "quest") QuestDataProvider::Instance()->loadData();
}
示例8: scrollingHeader
void WorldServerConnectHandler::scrollingHeader(PacketReader &packet) {
string message = packet.getString();
ChannelServer::Instance()->setScrollingHeader(message);
}
示例9: tradeHandler
void TradeHandler::tradeHandler(Player *player, PacketReader &packet) {
int8_t subopcode = packet.get<int8_t>();
switch (subopcode) {
case TradeOpcodes::OpenTrade: // This usually comes with 03 00 - no clue why
TradesPacket::sendOpenTrade(player, player, nullptr);
break;
case TradeOpcodes::SendTradeRequest: {
if (player->isTrading()) {
// Most likely hacking
return;
}
int32_t recvid = packet.get<int32_t>();
Player *receiver = PlayerDataProvider::Instance()->getPlayer(recvid);
if (receiver != nullptr) {
if (!receiver->isTrading()) {
TradesPacket::sendTradeRequest(player, receiver, Trades::Instance()->newTrade(player, receiver));
}
else {
TradesPacket::sendTradeMessage(receiver, player, TradesPacket::MessageTypes::DenyTrade, TradesPacket::Messages::DoingSomethingElse);
}
}
break;
}
case TradeOpcodes::DenyRequest: {
int32_t tradeid = packet.get<int32_t>();
ActiveTrade *trade = Trades::Instance()->getTrade(tradeid);
if (trade != nullptr) {
Player *one = trade->getSender();
Player *two = trade->getReceiver();
TradeHandler::removeTrade(tradeid);
TradesPacket::sendTradeMessage(two, one, TradesPacket::MessageTypes::DenyTrade, packet.get<int8_t>());
}
break;
}
case TradeOpcodes::AcceptRequest: {
int32_t tradeid = packet.get<int32_t>();
ActiveTrade *trade = Trades::Instance()->getTrade(tradeid);
if (trade != nullptr) {
Player *one = trade->getSender();
Player *two = trade->getReceiver();
two->setTrading(true);
TradesPacket::sendAddUser(one, two, TradeSlots::Two);
TradesPacket::sendOpenTrade(player, two, one);
Trades::Instance()->stopTimeout(tradeid);
}
else {
// Pool's closed, AIDS
TradesPacket::sendTradeMessage(player, TradesPacket::MessageTypes::ShopEntryMessages, TradesPacket::Messages::RoomAlreadyClosed);
}
break;
}
case TradeOpcodes::Chat: {
// Chat in a trade
ActiveTrade *trade = Trades::Instance()->getTrade(player->getTradeId());
if (trade == nullptr) {
// Hacking
return;
}
Player *one = trade->getSender();
Player *two = trade->getReceiver();
bool blue = (player == two);
string chat = player->getName() + " : " + packet.getString();
TradesPacket::sendTradeChat(one, blue, chat);
if (two != nullptr) {
TradesPacket::sendTradeChat(two, blue, chat);
}
break;
}
case TradeOpcodes::CancelTrade:
TradeHandler::cancelTrade(player);
break;
case TradeOpcodes::AddItem:
case TradeOpcodes::AddMesos:
case TradeOpcodes::AcceptTrade: {
int32_t tradeid = player->getTradeId();
ActiveTrade *trade = Trades::Instance()->getTrade(tradeid);
if (trade == nullptr) {
// Most likely hacking
return;
}
Player *one = trade->getSender();
Player *two = trade->getReceiver();
bool isreceiver = (player == two);
TradeInfo *mod = (isreceiver ? trade->getReceiverTrade() : trade->getSenderTrade());
switch (subopcode) {
case TradeOpcodes::AddItem: {
int8_t inventory = packet.get<int8_t>();
int16_t slot = packet.get<int16_t>();
int16_t amount = packet.get<int16_t>();
uint8_t addslot = packet.get<uint8_t>();
Item *item = player->getInventory()->getItem(inventory, slot);
if (item == nullptr || trade->isItemInSlot(mod, addslot) || item->hasTradeBlock()) {
// Hacking
return;
}
ItemInfo *info = ItemDataProvider::Instance()->getItemInfo(item->getId());
if (info == nullptr || (info->notrade && info->karmascissors && !item->hasKarma()) || (info->notrade && !info->karmascissors) || item->hasLock()) {
// Hacking
return;
}
//.........这里部分代码省略.........
示例10: handleRockTeleport
bool InventoryHandler::handleRockTeleport(Player *player, int32_t itemid, PacketReader &packet) {
if (itemid == Items::SpecialTeleportRock) {
packet.skipBytes(5);
}
int8_t type = InventoryPacket::RockTypes::Regular;
switch (itemid) {
case Items::VipRock: type = InventoryPacket::RockTypes::Vip; break;
case Items::SpecialTeleportRock: type = packet.get<int8_t>(); break;
}
bool used = false;
int8_t mode = packet.get<int8_t>();
int32_t targetmapid = -1;
enum Modes {
PresetMap = 0x00,
Ign = 0x01
};
if (mode == PresetMap) {
targetmapid = packet.get<int32_t>();
if (!player->getInventory()->ensureRockDestination(targetmapid)) {
// Hacking
return false;
}
}
else if (mode == Ign) {
string tname = packet.getString();
Player *target = PlayerDataProvider::Instance()->getPlayer(tname);
if (target != nullptr && target != player) {
targetmapid = target->getMap();
}
else if (target == nullptr) {
InventoryPacket::sendRockError(player, InventoryPacket::RockErrors::DifficultToLocate, type);
}
else if (target == player) {
// Hacking
return false;
}
}
if (targetmapid != -1) {
Map *destination = Maps::getMap(targetmapid);
Map *origin = Maps::getMap(player->getMap());
if (!destination->canVip()) {
InventoryPacket::sendRockError(player, InventoryPacket::RockErrors::CannotGo, type);
}
else if (!origin->canVip()) {
InventoryPacket::sendRockError(player, InventoryPacket::RockErrors::CannotGo, type);
}
else if (player->getMap() == targetmapid) {
InventoryPacket::sendRockError(player, InventoryPacket::RockErrors::AlreadyThere, type);
}
else if (type == InventoryPacket::RockTypes::Regular && destination->getContinent() != origin->getContinent()) {
InventoryPacket::sendRockError(player, InventoryPacket::RockErrors::CannotGo, type);
}
else if (player->getStats()->getLevel() < 7 && origin->getContinent() == 0 && destination->getContinent() != 0) {
InventoryPacket::sendRockError(player, InventoryPacket::RockErrors::NoobsCannotLeaveMapleIsland, type);
}
else {
player->setMap(targetmapid);
used = true;
}
}
if (itemid == Items::SpecialTeleportRock) {
if (used) {
Inventory::takeItem(player, itemid, 1);
}
else {
InventoryPacket::blankUpdate(player);
}
}
return used;
}
示例11: 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);
//.........这里部分代码省略.........
示例12: updateCoupon
void WorldServerConnectHandler::updateCoupon(PacketReader &packet) {
CouponInfo *info = CashDataProvider::Instance()->getCouponInfo(packet.getString());
if (info != nullptr) {
info->used = packet.getBool();
}
}