本文整理汇总了C++中net::MessageIn::readString方法的典型用法代码示例。如果您正苦于以下问题:C++ MessageIn::readString方法的具体用法?C++ MessageIn::readString怎么用?C++ MessageIn::readString使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类net::MessageIn
的用法示例。
在下文中一共展示了MessageIn::readString方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: processReadMail
void MailRecv::processReadMail(Net::MessageIn &msg)
{
const int sz = msg.readInt16("len") - 101;
MailMessage *const mail = new MailMessage;
mail->id = msg.readInt32("message id");
mail->title = msg.readString(40, "title");
mail->sender = msg.readString(24, "sender name");
msg.readInt32("unused");
mail->money = msg.readInt32("money");
mail->itemAmount = msg.readInt32("item amount");
mail->itemId = msg.readInt16("item id");
mail->itemType = msg.readInt16("item type");
mail->itemIdentify = msg.readUInt8("identify");
mail->itemAttribute = msg.readUInt8("attribute");
mail->itemRefine = msg.readUInt8("refine");
for (int f = 0; f < maxCards; f ++)
mail->card[f] = msg.readUInt16("card");
const int msgLen = msg.readUInt8("msg len");
if (msgLen != sz)
logger->log("error: wrong message size");
mail->text = msg.readString(sz, "message");
msg.readUInt8("zero");
mail->strTime = timeToStr(mail->time);
mailWindow->showMessage(mail);
}
示例2: processPartyMemberInfo
void PartyRecv::processPartyMemberInfo(Net::MessageIn &msg)
{
const BeingId id = msg.readBeingId("account id");
const bool leader = msg.readInt32("leader") == 0U;
const int x = msg.readInt16("x");
const int y = msg.readInt16("y");
const bool online = msg.readInt8("online") == 0U;
msg.readString(24, "party name");
const std::string nick = msg.readString(24, "player name");
const std::string map = msg.readString(16, "map name");
msg.readInt8("party.item&1");
msg.readInt8("party.item&2");
if (!Ea::taParty)
return;
PartyMember *const member = Ea::taParty->addMember(id, nick);
if (member)
{
if (partyTab && member->getOnline() != online)
partyTab->showOnline(nick, fromBool(online, Online));
member->setLeader(leader);
member->setOnline(online);
member->setMap(map);
member->setX(x);
member->setY(y);
}
}
示例3: processGuildLeave
void GuildRecv::processGuildLeave(Net::MessageIn &msg)
{
const std::string nick = msg.readString(24, "nick");
msg.readString(40, "message");
if (taGuild != nullptr)
taGuild->removeMember(nick);
if (localPlayer == nullptr)
return;
if (nick == localPlayer->getName())
{
if (taGuild != nullptr)
{
taGuild->removeFromMembers();
taGuild->clearMembers();
localPlayer->removeGuild(taGuild->getId());
}
NotifyManager::notify(NotifyTypes::GUILD_LEFT);
delete2(guildTab)
if ((socialWindow != nullptr) && (taGuild != nullptr))
socialWindow->removeTab(taGuild);
if (actorManager != nullptr)
actorManager->updatePlayerColors();
}
else
{
示例4: processAuctionResults
void AuctionRecv::processAuctionResults(Net::MessageIn &msg)
{
UNIMPLEMENTEDPACKET;
msg.readInt16("len");
msg.readInt32("pages");
const int itemCount = msg.readInt32("items count");
for (int f = 0; f < itemCount; f ++)
{
msg.readInt32("auction id");
msg.readString(24, "seller name");
msg.readInt16("item id"); // here item always 16 bit
msg.readInt32("auction type");
msg.readInt16("item amount"); // always 1
msg.readUInt8("identify");
msg.readUInt8("attribute");
msg.readUInt8("refine");
for (int d = 0; d < maxCards; d ++)
msg.readUInt16("card"); // here item always 16 bit
msg.readInt32("price");
msg.readInt32("buy now");
msg.readString(24, "buyer name");
msg.readInt32("timestamp");
// +++ need use ItemColorManager for color
}
}
示例5: handleMessage
void NpcHandler::handleMessage(Net::MessageIn &msg)
{
if (msg.getId() == SMSG_NPC_CHOICE || msg.getId() == SMSG_NPC_MESSAGE)
{
msg.readInt16(); // length
}
int npcId = msg.readInt32();
Event *event = 0;
switch (msg.getId())
{
case SMSG_NPC_CHOICE:
event = new Event(Event::Menu);
event->setInt("id", npcId);
parseMenu(event, msg.readString(msg.getLength() - 8));
event->trigger(Event::NpcChannel);
break;
case SMSG_NPC_MESSAGE:
event = new Event(Event::Message);
event->setInt("id", npcId);
event->setString("text", msg.readString(msg.getLength() - 8));
event->trigger(Event::NpcChannel);
break;
case SMSG_NPC_CLOSE:
// Show the close button
event = new Event(Event::Close);
event->setInt("id", npcId);
event->trigger(Event::NpcChannel);
break;
case SMSG_NPC_NEXT:
// Show the next button
event = new Event(Event::Next);
event->setInt("id", npcId);
event->trigger(Event::NpcChannel);
break;
case SMSG_NPC_INT_INPUT:
// Request for an integer
event = new Event(Event::IntegerInput);
event->setInt("id", npcId);
event->trigger(Event::NpcChannel);
break;
case SMSG_NPC_STR_INPUT:
// Request for a string
event = new Event(Event::StringInput);
event->setInt("id", npcId);
event->trigger(Event::NpcChannel);
break;
}
delete event;
if (local_player->getCurrentAction() != Being::SIT)
local_player->setAction(Being::STAND);
}
示例6: handleEnterChannelResponse
void ChatHandler::handleEnterChannelResponse(Net::MessageIn &msg)
{
if(msg.readInt8() == ERRMSG_OK)
{
short channelId = msg.readInt16();
std::string channelName = msg.readString();
std::string announcement = msg.readString();
Channel *channel = new Channel(channelId, channelName, announcement);
channelManager->addChannel(channel);
ChatTab *tab = channel->getTab();
tab->chatLog(strprintf(_("Topic: %s"), announcement.c_str()), BY_CHANNEL);
std::string user;
std::string userModes;
tab->chatLog(_("Players in this channel:"), BY_CHANNEL);
while(msg.getUnreadLength())
{
user = msg.readString();
if (user == "")
return;
userModes = msg.readString();
if (userModes.find('o') != std::string::npos)
{
user = "@" + user;
}
tab->chatLog(user, BY_CHANNEL);
}
}
else
{
localChatTab->chatLog(_("Error joining channel."), BY_SERVER);
}
}
示例7: handleBeingEnterMessage
void BeingHandler::handleBeingEnterMessage(Net::MessageIn &msg)
{
int type = msg.readInt8();
int id = msg.readInt16();
Being::Action action = (Being::Action)msg.readInt8();
int px = msg.readInt16();
int py = msg.readInt16();
BeingDirection direction = (BeingDirection)msg.readInt8();
Being *being;
if (!Game::instance()->getCurrentMap()->containsPixel(px, py))
{
logger->log("Warning: Received GPMSG_BEING_ENTER for being id %i "
"with position outside the map boundaries "
"(x = %i, y = %i)", id, px, py);
return;
}
switch (type)
{
case OBJECT_CHARACTER:
{
std::string name = msg.readString();
if (player_node->getName() == name)
{
being = player_node;
being->setId(id);
}
else
{
being = actorSpriteManager->createBeing(id,
ActorSprite::PLAYER, 0);
being->setName(name);
}
int hs = msg.readInt8(), hc = msg.readInt8();
being->setSprite(SPRITE_HAIR, hs * -1, ColorDB::get(hc));
being->setGender(msg.readInt8() == GENDER_MALE ?
GENDER_MALE : GENDER_FEMALE);
handleLooks(being, msg);
} break;
case OBJECT_MONSTER:
case OBJECT_NPC:
{
int subtype = msg.readInt16();
being = actorSpriteManager->createBeing(id, type == OBJECT_MONSTER
? ActorSprite::MONSTER : ActorSprite::NPC, subtype);
std::string name = msg.readString();
if (name.length() > 0) being->setName(name);
} break;
default:
return;
}
being->setPosition(px, py);
being->setDestination(px, py);
being->setDirection(direction);
being->setAction(action);
}
示例8: handlePrivateMessage
void ChatHandler::handlePrivateMessage(Net::MessageIn &msg)
{
std::string userNick = msg.readString();
std::string chatMsg = msg.readString();
chatWindow->whisper(userNick, chatMsg);
}
示例9: processAskForChild
void FamilyRecv::processAskForChild(Net::MessageIn &msg)
{
if (!localPlayer)
{
mParent1 = msg.readBeingId("account id who ask");
mParent2 = msg.readBeingId("acoount id for other parent");
msg.readString(24, "name who ask");
return;
}
mParent1 = msg.readBeingId("account id who ask");
mParent2 = msg.readBeingId("acoount id for other parent");
const std::string name1 = msg.readString(24, "name who ask");
const Party *const party = localPlayer->getParty();
if (party)
{
const PartyMember *const member = party->getMember(mParent2);
if (member)
{
const std::string name2 = member->getName();
CREATEWIDGETV(confirmDlg, ConfirmDialog,
// TRANSLATORS: adopt child message
_("Request parents"),
// TRANSLATORS: adopt child message
strprintf(_("Do you accept %s and %s as parents?"),
name1.c_str(), name2.c_str()),
SOUND_REQUEST,
false);
confirmDlg->addActionListener(&listener);
}
}
}
示例10: processPartyMove
void PartyHandler::processPartyMove(Net::MessageIn &msg)
{
int id = msg.readInt32(); // id
PartyMember *m = nullptr;
if (Ea::taParty)
m = Ea::taParty->getMember(id);
if (m)
{
msg.skip(4); // 0
m->setX(msg.readInt16()); // x
m->setY(msg.readInt16()); // y
m->setOnline(msg.readInt8()); // online (if 0)
msg.readString(24); // party
msg.readString(24); // nick
m->setMap(msg.readString(16)); // map
}
else
{
msg.skip(4); // 0
msg.readInt16(); // x
msg.readInt16(); // y
msg.readInt8(); // online (if 0)
msg.readString(24); // party
msg.readString(24); // nick
msg.readString(16); // map
}
}
示例11: handleChatMessage
void ChatHandler::handleChatMessage(Net::MessageIn &msg)
{
short channelId = msg.readInt16();
std::string userNick = msg.readString();
std::string chatMsg = msg.readString();
Channel *channel = channelManager->findById(channelId);
channel->getTab()->chatLog(userNick, chatMsg);
}
示例12: processNewMail
void MailHandler::processNewMail(Net::MessageIn &msg)
{
msg.readInt32("message id");
const std::string subj = msg.readString(40, "title");
const std::string sender = msg.readString(24, "sender name");
NotifyManager::notify(NotifyTypes::NEW_MAIL,
strprintf(_("You have new mail from %s with subject %s"),
sender.c_str(), subj.c_str()));
mailHandler->refresh();
}
示例13: processGuildNotice
void GuildHandler::processGuildNotice(Net::MessageIn &msg)
{
const std::string msg1 = msg.readString(60, "msg1");
const std::string msg2 = msg.readString(120, "msg2");
if (guildTab)
{
guildTab->chatLog(msg1, ChatMsgType::BY_SERVER);
guildTab->chatLog(msg2, ChatMsgType::BY_SERVER);
}
}
示例14: processGuildNotice
void GuildHandler::processGuildNotice(Net::MessageIn &msg) const
{
const std::string msg1 = msg.readString(60); // Mes1
const std::string msg2 = msg.readString(120); // Mes2
if (guildTab)
{
guildTab->chatLog(msg1, BY_SERVER);
guildTab->chatLog(msg2, BY_SERVER);
}
}
示例15: processGuildBasicInfo
void GuildHandler::processGuildBasicInfo(Net::MessageIn &msg)
{
const int guildId = msg.readInt32("guild id");
const int level = msg.readInt32("guild level");
const int members = msg.readInt32("connect member");
const int maxMembers = msg.readInt32("max member");
const int avgLevel = msg.readInt32("average level");
const int exp = msg.readInt32("exp");
const int nextExp = msg.readInt32("next exp");
msg.skip(12, "unused");
const int emblem = msg.readInt32("emblem id");
std::string name = msg.readString(24, "guild name");
std::string master = msg.readString(24, "master name");
std::string castle = msg.readString(16, "castles");
msg.readInt32("unused");
if (guildTab && showBasicInfo)
{
showBasicInfo = false;
// TRANSLATORS: guild info message
guildTab->chatLog(strprintf(_("Guild name: %s"),
name.c_str()), ChatMsgType::BY_SERVER);
// TRANSLATORS: guild info message
guildTab->chatLog(strprintf(_("Guild master: %s"),
master.c_str()), ChatMsgType::BY_SERVER);
// TRANSLATORS: guild info message
guildTab->chatLog(strprintf(_("Guild level: %d"), level),
ChatMsgType::BY_SERVER);
// TRANSLATORS: guild info message
guildTab->chatLog(strprintf(_("Online members: %d"),
members), ChatMsgType::BY_SERVER);
// TRANSLATORS: guild info message
guildTab->chatLog(strprintf(_("Max members: %d"),
maxMembers), ChatMsgType::BY_SERVER);
// TRANSLATORS: guild info message
guildTab->chatLog(strprintf(_("Average level: %d"),
avgLevel), ChatMsgType::BY_SERVER);
// TRANSLATORS: guild info message
guildTab->chatLog(strprintf(_("Guild exp: %d"), exp),
ChatMsgType::BY_SERVER);
// TRANSLATORS: guild info message
guildTab->chatLog(strprintf(_("Guild next exp: %d"),
nextExp), ChatMsgType::BY_SERVER);
// TRANSLATORS: guild info message
guildTab->chatLog(strprintf(_("Guild castle: %s"),
castle.c_str()), ChatMsgType::BY_SERVER);
}
Guild *const g = Guild::getGuild(static_cast<int16_t>(guildId));
if (!g)
return;
g->setName(name);
g->setEmblemId(emblem);
}