ManaPlus
Functions | Variables
EAthena::ChatRecv Namespace Reference

Functions

std::string extractChannelFromMessage (std::string &chatMsg)
 
void processChat (Net::MessageIn &msg)
 
void processColorChat (Net::MessageIn &msg)
 
void processChatContinue (std::string chatMsg, const ChatMsgTypeT own)
 
void processWhisper (Net::MessageIn &msg)
 
void processWhisperResponse (Net::MessageIn &msg)
 
void processGmChat (Net::MessageIn &msg)
 
void processGmChat2 (Net::MessageIn &msg)
 
void processChatIgnoreList (Net::MessageIn &msg)
 
void processFormatMessage (Net::MessageIn &msg)
 
void processFormatMessageNumber (Net::MessageIn &msg)
 
void processFormatColor (Net::MessageIn &msg)
 
void processFormatMessageString (Net::MessageIn &msg)
 
void processFormatMessageStringColor (Net::MessageIn &msg)
 
void processFormatMessageSkill (Net::MessageIn &msg)
 
void processChatDisplay (Net::MessageIn &msg)
 
void processChatRoomJoinAck (Net::MessageIn &msg)
 
void processChatRoomLeave (Net::MessageIn &msg)
 
void processJoinChannel (Net::MessageIn &msg)
 
void processWhisperContinue (const std::string &nick, std::string chatMsg)
 
void processBeingChat (Net::MessageIn &msg)
 
void processIgnoreNickAck (Net::MessageIn &msg)
 
void processChatRoomCreateAck (Net::MessageIn &msg)
 
void processChatRoomDestroy (Net::MessageIn &msg)
 
void processChatRoomJoinFailed (Net::MessageIn &msg)
 
void processChatRoomAddMember (Net::MessageIn &msg)
 
void processChatRoomSettings (Net::MessageIn &msg)
 
void processChatRoomRoleChange (Net::MessageIn &msg)
 
void processMVPItem (Net::MessageIn &msg)
 
void processMVPExp (Net::MessageIn &msg)
 
void processMVPNoItem (Net::MessageIn &msg)
 
void processMannerMessage (Net::MessageIn &msg)
 
void processChatSilence (Net::MessageIn &msg)
 
void processChatTalkieBox (Net::MessageIn &msg)
 
void processBattleChatMessage (Net::MessageIn &msg)
 
void processScriptMessage (Net::MessageIn &msg)
 
void processServiceMessageColor (Net::MessageIn &msg)
 

Variables

std::string mChatRoom
 

Function Documentation

◆ extractChannelFromMessage()

std::string EAthena::ChatRecv::extractChannelFromMessage ( std::string &  chatMsg)

Definition at line 263 of file chatrecv.cpp.

264 {
265  std::string msg = chatMsg;
266  std::string channel(GENERAL_CHANNEL);
267  if (findCutFirst(msg, "[ #"))
268  { // found channel message
269  const size_t idx = msg.find(" ] ");
270  if (idx != std::string::npos)
271  {
272  channel = std::string("#").append(msg.substr(0, idx));
273  chatMsg = msg.substr(idx + 3);
274  }
275  }
276  return channel;
277 }
const std::string GENERAL_CHANNEL
Definition: chat.h:29
bool msg(InputEvent &event)
Definition: chat.cpp:39
bool findCutFirst(std::string &str1, const std::string &str2)

References findCutFirst(), GENERAL_CHANNEL, and Actions::msg().

Referenced by processChatContinue().

◆ processBattleChatMessage()

void EAthena::ChatRecv::processBattleChatMessage ( Net::MessageIn msg)

Definition at line 806 of file chatrecv.cpp.

807 {
809  const int sz = msg.readInt16("len") - 24 - 8;
810  msg.readBeingId("account id");
811  msg.readString(24, "nick");
812  msg.readString(sz, "message");
813 }
#define UNIMPLEMENTEDPACKET
Definition: logger.h:56

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processBeingChat()

void EAthena::ChatRecv::processBeingChat ( Net::MessageIn msg)

Definition at line 554 of file chatrecv.cpp.

555 {
556  if (actorManager == nullptr)
557  return;
558 
559  BLOCK_START("ChatRecv::processBeingChat")
560  const int chatMsgLength = msg.readInt16("len") - 8;
561  Being *const being = actorManager->findBeing(msg.readBeingId("being id"));
562 
563  if (chatMsgLength <= 0)
564  {
565  BLOCK_END("ChatRecv::processBeingChat")
566  return;
567  }
568 
569  std::string chatMsg = msg.readRawString(chatMsgLength, "message");
570 
571  if ((being != nullptr) && being->getType() == ActorType::Player)
572  being->setTalkTime();
573 
574  const size_t pos = chatMsg.find(" : ", 0);
575  std::string sender_name = ((pos == std::string::npos)
576  ? "" : chatMsg.substr(0, pos));
577 
578  if ((being != nullptr) && sender_name != being->getName()
579  && being->getType() == ActorType::Player)
580  {
581  if (!being->getName().empty())
582  sender_name = being->getName();
583  }
584  else
585  {
586  chatMsg.erase(0, pos + 3);
587  }
588 
589  trim(chatMsg);
590 
591  bool allow(true);
592  // We use getIgnorePlayer instead of ignoringPlayer here
593  // because ignorePlayer' side effects are triggered
594  // right below for Being::IGNORE_SPEECH_FLOAT.
595  if ((playerRelations.checkPermissionSilently(sender_name,
596  PlayerRelation::SPEECH_LOG) != 0U) && (chatWindow != nullptr))
597  {
598  allow = chatWindow->resortChatLog(
599  removeColors(sender_name).append(" : ").append(chatMsg),
604  }
605 
606  if (allow &&
607  being != nullptr &&
608  playerRelations.hasPermission(sender_name,
610  {
611  being->setSpeech(chatMsg);
612  }
613  BLOCK_END("ChatRecv::processBeingChat")
614 }
ActorManager * actorManager
ChatWindow * chatWindow
Definition: chatwindow.cpp:94
Definition: being.h:96
bool resortChatLog(std::string line, ChatMsgTypeT own, const std::string &channel, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
bool hasPermission(const Being *const being, const unsigned int flags) const
unsigned int checkPermissionSilently(const std::string &player_name, const unsigned int flags) const
if(!vert) return
const bool IgnoreRecord_false
Definition: ignorerecord.h:30
static Being * findBeing(const std::string &name, const bool npc)
Definition: actions.cpp:212
bool find(const std::string &key)
std::string trim(std::string const &str)
const std::string & getName(const int id)
Definition: groupdb.cpp:344
#define BLOCK_END(name)
Definition: perfomance.h:80
#define BLOCK_START(name)
Definition: perfomance.h:79
PlayerRelationsManager playerRelations
std::string removeColors(std::string msg)
static const unsigned int SPEECH_FLOAT
static const unsigned int SPEECH_LOG
const bool TryRemoveColors_true

References actorManager, BLOCK_END, BLOCK_START, ChatMsgType::BY_OTHER, chatWindow, PlayerRelationsManager::checkPermissionSilently(), ActorManager::findBeing(), GENERAL_CHANNEL, Being::getName(), Being::getType(), PlayerRelationsManager::hasPermission(), IgnoreRecord_false, Actions::msg(), ActorType::Player, playerRelations, removeColors(), ChatWindow::resortChatLog(), Being::setSpeech(), Being::setTalkTime(), PlayerRelation::SPEECH_FLOAT, PlayerRelation::SPEECH_LOG, Catch::trim(), and TryRemoveColors_true.

◆ processChat()

void EAthena::ChatRecv::processChat ( Net::MessageIn msg)

Definition at line 111 of file chatrecv.cpp.

112 {
113  BLOCK_START("ChatRecv::processChat")
114  const int chatMsgLength = msg.readInt16("len") - 4;
115  if (chatMsgLength <= 0)
116  {
117  BLOCK_END("ChatRecv::processChat")
118  return;
119  }
120 
121  processChatContinue(msg.readRawString(chatMsgLength, "message"),
123 }
void processChatContinue(std::string chatMsg, const ChatMsgTypeT own)
Definition: chatrecv.cpp:279

References BLOCK_END, BLOCK_START, ChatMsgType::BY_PLAYER, Actions::msg(), and processChatContinue().

◆ processChatContinue()

void EAthena::ChatRecv::processChatContinue ( std::string  chatMsg,
const ChatMsgTypeT  own 
)

Definition at line 279 of file chatrecv.cpp.

281 {
282  const std::string channel = extractChannelFromMessage(chatMsg);
283  bool allow(true);
284  if (chatWindow != nullptr)
285  {
286  allow = chatWindow->resortChatLog(chatMsg,
287  own,
288  channel,
291  }
292 
293  const size_t pos = chatMsg.find(" : ", 0);
294  if (pos != std::string::npos)
295  chatMsg.erase(0, pos + 3);
296 
297  trim(chatMsg);
298 
299  if (localPlayer != nullptr)
300  {
301  if (((chatWindow != nullptr) || Ea::ChatRecv::mShowMotd) && allow)
302  localPlayer->setSpeech(chatMsg);
303  }
304  BLOCK_END("ChatRecv::processChat")
305 }
void setSpeech(const std::string &text)
Definition: being.cpp:572
LocalPlayer * localPlayer
std::string extractChannelFromMessage(std::string &chatMsg)
Definition: chatrecv.cpp:263
bool mShowMotd
Definition: chatrecv.cpp:52

References BLOCK_END, chatWindow, extractChannelFromMessage(), IgnoreRecord_false, localPlayer, Ea::ChatRecv::mShowMotd, ChatWindow::resortChatLog(), Being::setSpeech(), Catch::trim(), and TryRemoveColors_true.

Referenced by processChat(), TmwAthena::ChatRecv::processChat(), processColorChat(), processFormatColor(), processFormatMessage(), processFormatMessageNumber(), processFormatMessageSkill(), processFormatMessageString(), and processFormatMessageStringColor().

◆ processChatDisplay()

void EAthena::ChatRecv::processChatDisplay ( Net::MessageIn msg)

Definition at line 403 of file chatrecv.cpp.

404 {
405  if (actorManager == nullptr)
406  return;
407  const int len = msg.readInt16("len") - 17;
408  ChatObject *const obj = new ChatObject;
409  obj->ownerId = msg.readBeingId("owner account id");
410  obj->chatId = msg.readInt32("chat id");
411  obj->maxUsers = msg.readInt16("max users");
412  obj->currentUsers = msg.readInt16("current users");
413  obj->type = msg.readUInt8("type");
414  obj->title = msg.readString(len, "title");
415  obj->update();
416 
417  Being *const dstBeing = actorManager->findBeing(obj->ownerId);
418  if (dstBeing != nullptr)
419  dstBeing->setChat(obj);
420 }
Being * findBeing(const BeingId id) const
void setChat(ChatObject *const obj)
Definition: being.cpp:5322
std::string title
Definition: chatobject.h:51
uint16_t maxUsers
Definition: chatobject.h:48
int chatId
Definition: chatobject.h:47
void update()
Definition: chatobject.cpp:49
uint8_t type
Definition: chatobject.h:50
BeingId ownerId
Definition: chatobject.h:46
uint16_t currentUsers
Definition: chatobject.h:49

References actorManager, ChatObject::chatId, ChatObject::currentUsers, ActorManager::findBeing(), ChatObject::maxUsers, Actions::msg(), ChatObject::ownerId, Being::setChat(), ChatObject::title, ChatObject::type, and ChatObject::update().

◆ processChatIgnoreList()

void EAthena::ChatRecv::processChatIgnoreList ( Net::MessageIn msg)

Definition at line 394 of file chatrecv.cpp.

395 {
397  // +++ need put it in some object or window
398  const int count = (msg.readInt16("len") - 4) / 24;
399  for (int f = 0; f < count; f ++)
400  msg.readString(24, "nick");
401 }

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processChatRoomAddMember()

void EAthena::ChatRecv::processChatRoomAddMember ( Net::MessageIn msg)

Definition at line 691 of file chatrecv.cpp.

692 {
693  msg.readInt16("users");
694  const std::string name = msg.readString(24, "name");
695  if (localChatTab == nullptr)
696  return;
698 }
ChatTab * localChatTab
Definition: chattab.cpp:62
void notify(const unsigned int message)

References localChatTab, Actions::msg(), NotifyManager::notify(), and NotifyTypes::ROOM_JOINED.

◆ processChatRoomCreateAck()

void EAthena::ChatRecv::processChatRoomCreateAck ( Net::MessageIn msg)

Definition at line 616 of file chatrecv.cpp.

617 {
618  const int result = msg.readUInt8("flag");
619  switch (result)
620  {
621  case 0:
622  {
624  chatWindow->joinRoom(true);
625  ChatObject *const obj = new ChatObject;
626  obj->ownerId = localPlayer->getId();
627  obj->chatId = 0;
628  obj->maxUsers = 1000;
629  obj->currentUsers = 1;
630  obj->type = 1;
631  obj->title = mChatRoom;
632  obj->update();
633  localPlayer->setChat(obj);
634  break;
635  }
636  case 1:
638  break;
639  case 2:
641  break;
642  default:
643  UNIMPLEMENTEDPACKETFIELD(result);
644  break;
645  }
646  mChatRoom.clear();
647 }
BeingId getId() const
Definition: actorsprite.h:64
void joinRoom(const bool isJoin)
#define UNIMPLEMENTEDPACKETFIELD(field)
Definition: logger.h:59
std::string mChatRoom
Definition: chatrecv.cpp:61
@ ROOM_LIMIT_EXCEEDED
Definition: notifytypes.h:152
@ ROOM_ALREADY_EXISTS
Definition: notifytypes.h:153
void setRoomName(const std::string &name)
Definition: playerinfo.cpp:638

References ChatObject::chatId, chatWindow, ChatObject::currentUsers, ActorSprite::getId(), ChatWindow::joinRoom(), localPlayer, ChatObject::maxUsers, mChatRoom, Actions::msg(), NotifyManager::notify(), ChatObject::ownerId, NotifyTypes::ROOM_ALREADY_EXISTS, NotifyTypes::ROOM_LIMIT_EXCEEDED, Being::setChat(), PlayerInfo::setRoomName(), ChatObject::title, ChatObject::type, UNIMPLEMENTEDPACKETFIELD, and ChatObject::update().

◆ processChatRoomDestroy()

void EAthena::ChatRecv::processChatRoomDestroy ( Net::MessageIn msg)

Definition at line 649 of file chatrecv.cpp.

650 {
651  const int chatId = msg.readInt32("chat id");
652  if (actorManager == nullptr)
653  return;
654  actorManager->removeRoom(chatId);
655 }
void removeRoom(const int chatId)

References actorManager, Actions::msg(), and ActorManager::removeRoom().

◆ processChatRoomJoinAck()

void EAthena::ChatRecv::processChatRoomJoinAck ( Net::MessageIn msg)

Definition at line 422 of file chatrecv.cpp.

423 {
424  const int count = (msg.readInt16("len") - 8) / 28;
425  const int id = msg.readInt32("chat id");
426 
427  // +++ ignore chat members for now
428  for (int f = 0; f < count; f ++)
429  {
430  msg.readInt32("role");
431  msg.readString(24, "name");
432  }
433 
434  const ChatObject *const oldChat = ChatObject::findById(id);
435 
436  if (oldChat != nullptr)
437  PlayerInfo::setRoomName(oldChat->title);
438  else
439  PlayerInfo::setRoomName(std::string());
440  chatWindow->joinRoom(true);
441  ChatObject *const obj = new ChatObject;
442  if (oldChat != nullptr)
443  {
444  obj->ownerId = oldChat->ownerId;
445  obj->chatId = oldChat->chatId;
446  obj->maxUsers = oldChat->maxUsers;
447  obj->currentUsers = oldChat->currentUsers;
448  obj->type = oldChat->type;
449  obj->title = oldChat->title;
450 // obj->update();
451  }
452  localPlayer->setChat(obj);
453 }
static ChatObject * findById(const int id)
Definition: chatobject.cpp:64

References ChatObject::chatId, chatWindow, ChatObject::currentUsers, ChatObject::findById(), ChatWindow::joinRoom(), localPlayer, ChatObject::maxUsers, Actions::msg(), ChatObject::ownerId, Being::setChat(), PlayerInfo::setRoomName(), ChatObject::title, and ChatObject::type.

◆ processChatRoomJoinFailed()

void EAthena::ChatRecv::processChatRoomJoinFailed ( Net::MessageIn msg)

Definition at line 657 of file chatrecv.cpp.

658 {
659  const int result = msg.readUInt8("flag");
660  switch (result)
661  {
662  case 0:
664  break;
665  case 1:
667  break;
668  case 2:
670  break;
671  case 3:
672  break;
673  case 4:
675  break;
676  case 5:
678  break;
679  case 6:
681  break;
682  case 7:
684  break;
685  default:
686  UNIMPLEMENTEDPACKETFIELD(result);
687  break;
688  }
689 }
@ ROOM_ERROR_HIGH_LEVEL
Definition: notifytypes.h:163
@ ROOM_ERROR_LOW_LEVEL
Definition: notifytypes.h:162
@ ROOM_ERROR_WRONG_PASSWORD
Definition: notifytypes.h:159

References Actions::msg(), NotifyManager::notify(), NotifyTypes::ROOM_ERROR_FULL, NotifyTypes::ROOM_ERROR_HIGH_LEVEL, NotifyTypes::ROOM_ERROR_KICKED, NotifyTypes::ROOM_ERROR_LOW_LEVEL, NotifyTypes::ROOM_ERROR_RACE, NotifyTypes::ROOM_ERROR_WRONG_PASSWORD, NotifyTypes::ROOM_ERROR_ZENY, and UNIMPLEMENTEDPACKETFIELD.

◆ processChatRoomLeave()

void EAthena::ChatRecv::processChatRoomLeave ( Net::MessageIn msg)

Definition at line 455 of file chatrecv.cpp.

456 {
457  if (actorManager == nullptr)
458  return;
459  msg.readInt16("users");
460  const std::string name = msg.readString(24, "name");
461  const int status = msg.readUInt8("flag"); // 0 - left, 1 - kicked
462  switch (status)
463  {
464  case 0:
466  break;
467  case 1:
469  break;
470  default:
471  UNIMPLEMENTEDPACKETFIELD(status);
472  break;
473  }
474  if ((localPlayer != nullptr) && name == localPlayer->getName())
475  {
476  if (chatWindow != nullptr)
477  chatWindow->joinRoom(false);
478  PlayerInfo::setRoomName(std::string());
479  if (localPlayer != nullptr)
480  localPlayer->setChat(nullptr);
481  }
482  else
483  {
484  Being *const being = actorManager->findBeingByName(
485  name, ActorType::Player);
486  if (being != nullptr)
487  being->setChat(nullptr);
488  }
489 }
Being * findBeingByName(const std::string &name, const ActorTypeT type) const
const std::string & getName() const
Definition: being.h:232

References actorManager, chatWindow, ActorManager::findBeingByName(), Being::getName(), ChatWindow::joinRoom(), localPlayer, Actions::msg(), NotifyManager::notify(), ActorType::Player, NotifyTypes::ROOM_KICKED, NotifyTypes::ROOM_LEAVE, Being::setChat(), PlayerInfo::setRoomName(), and UNIMPLEMENTEDPACKETFIELD.

◆ processChatRoomRoleChange()

void EAthena::ChatRecv::processChatRoomRoleChange ( Net::MessageIn msg)

Definition at line 726 of file chatrecv.cpp.

727 {
728  const int role = msg.readInt32("role");
729  const std::string name = msg.readString(24, "name");
730  switch (role)
731  {
732  case 0:
734  break;
735  case 1:
736  // dont show normal role
737  break;
738  default:
740  break;
741  }
742 }

References Actions::msg(), NotifyManager::notify(), NotifyTypes::ROOM_ROLE_OWNER, and UNIMPLEMENTEDPACKETFIELD.

◆ processChatRoomSettings()

void EAthena::ChatRecv::processChatRoomSettings ( Net::MessageIn msg)

Definition at line 700 of file chatrecv.cpp.

701 {
702  const int sz = msg.readInt16("len") - 17;
703  const BeingId ownerId = msg.readBeingId("owner id");
704  const int chatId = msg.readInt32("chat id");
705  const uint16_t limit = msg.readInt16("limit");
706  msg.readInt16("users");
707  const uint8_t type = msg.readUInt8("type");
708  const std::string &title = msg.readString(sz, "title");
709  ChatObject *const chat = localPlayer->getChat();
710  if ((chat != nullptr) && chat->chatId == chatId)
711  {
712  chat->ownerId = ownerId;
713  chat->maxUsers = limit;
714  chat->type = type;
715  if (chat->title != title)
716  {
717  chat->title = title;
718  if (actorManager != nullptr)
719  actorManager->updateRoom(chat);
720  if (chatWindow != nullptr)
721  chatWindow->joinRoom(true);
722  }
723  }
724 }
int BeingId
Definition: beingid.h:30
void updateRoom(const ChatObject *const newChat)
ChatObject * getChat() const
Definition: being.h:999

References actorManager, ChatObject::chatId, chatWindow, Being::getChat(), ChatWindow::joinRoom(), localPlayer, ChatObject::maxUsers, Actions::msg(), ChatObject::ownerId, ChatObject::title, ChatObject::type, and ActorManager::updateRoom().

◆ processChatSilence()

void EAthena::ChatRecv::processChatSilence ( Net::MessageIn msg)

Definition at line 777 of file chatrecv.cpp.

778 {
779  const int result = msg.readUInt8("type");
780  const std::string name = msg.readString(24, "gm name");
781 
782  switch (result)
783  {
784  case 0:
786  break;
787  case 1:
789  break;
790  default:
791  UNIMPLEMENTEDPACKETFIELD(result);
792  break;
793  }
794 }
@ MANNER_POSITIVE_POINTS
Definition: notifytypes.h:150
@ MANNER_NEGATIVE_POINTS
Definition: notifytypes.h:151

References NotifyTypes::MANNER_NEGATIVE_POINTS, NotifyTypes::MANNER_POSITIVE_POINTS, Actions::msg(), NotifyManager::notify(), and UNIMPLEMENTEDPACKETFIELD.

◆ processChatTalkieBox()

void EAthena::ChatRecv::processChatTalkieBox ( Net::MessageIn msg)

Definition at line 796 of file chatrecv.cpp.

797 {
798  msg.readBeingId("being id");
799  const std::string message = msg.readString(80, "message");
800  localChatTab->chatLog(message,
804 }
void chatLog(std::string line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
Definition: chattab.cpp:111

References ChatMsgType::BY_SERVER, ChatTab::chatLog(), IgnoreRecord_false, localChatTab, Actions::msg(), and TryRemoveColors_true.

◆ processColorChat()

void EAthena::ChatRecv::processColorChat ( Net::MessageIn msg)

Definition at line 223 of file chatrecv.cpp.

224 {
225  BLOCK_START("ChatRecv::processChat")
226  int chatMsgLength = msg.readInt16("len") - 4;
227  msg.readInt32("unused");
228  msg.readInt32("chat color");
229  chatMsgLength -= 8;
230  if (chatMsgLength <= 0)
231  {
232  BLOCK_END("ChatRecv::processChat")
233  return;
234  }
235 
236  std::string message = msg.readRawString(chatMsgLength, "message");
237  std::string msg2 = message;
238  if (findCutFirst(msg2, "You're now in the '#") && findCutLast(msg2, "'"))
239  {
240  const size_t idx = msg2.find("' channel for '");
241  if (idx != std::string::npos && (chatWindow != nullptr))
242  {
243  chatWindow->addChannelTab(std::string("#").append(
244  msg2.substr(0, idx)), false);
245  return;
246  }
247  }
248  else
249  {
250  const std::string nick = Ea::ChatRecv::getLastWhisperNick();
251  if (nick.size() > 1 && nick[0] == '#')
252  {
253  if (message == strprintf("[ %s ] %s : \302\202\302",
254  nick.c_str(), localPlayer->getName().c_str()))
255  {
256  Ea::ChatRecv::mSentWhispers.pop();
257  }
258  }
259  }
260  processChatContinue(message, ChatMsgType::BY_UNKNOWN);
261 }
bool msg2(InputEvent &event)
Definition: chat.cpp:41

References ChatWindow::addChannelTab(), BLOCK_END, BLOCK_START, ChatMsgType::BY_UNKNOWN, chatWindow, findCutFirst(), findCutLast(), Ea::ChatRecv::getLastWhisperNick(), Being::getName(), localPlayer, Ea::ChatRecv::mSentWhispers, Actions::msg(), Actions::msg2(), processChatContinue(), and strprintf().

◆ processFormatColor()

void EAthena::ChatRecv::processFormatColor ( Net::MessageIn msg)

Definition at line 179 of file chatrecv.cpp.

180 {
181  const int msgId = msg.readInt16("msg id");
182  msg.readInt32("color");
183  // +++ here need load message from configuration file
184  const std::string chatMsg = strprintf(
185  "Message #%d", msgId);
187 }
std::string strprintf(const char *const format,...)

References ChatMsgType::BY_SERVER, Actions::msg(), processChatContinue(), and strprintf().

◆ processFormatMessage()

void EAthena::ChatRecv::processFormatMessage ( Net::MessageIn msg)

Definition at line 125 of file chatrecv.cpp.

126 {
127  const int msgId = msg.readInt16("msg id");
128  // +++ here need load message from configuration file
129  std::string chatMsg;
130  if (msgId >= 1266 && msgId <= 1269)
131  {
133  return;
134  }
135  switch (msgId)
136  {
137  case 1334:
138  // TRANSLATORS: error message
139  chatMsg = _("Can't cast skill in this area.");
140  break;
141  case 1335:
142  // TRANSLATORS: error message
143  chatMsg = _("Can't use item in this area.");
144  break;
145  case 1773:
146  // TRANSLATORS: error message
147  chatMsg = _("Can't equip. Wrong level.");
148  break;
149  case 1774:
150  // TRANSLATORS: error message
151  chatMsg = _("Can't use. Wrong level.");
152  break;
153  case 1923:
154  // TRANSLATORS: error message
155  chatMsg = _("Work in progress."); // busy with npc
156  break;
157  default:
158  chatMsg = strprintf("Message #%d", msgId);
159  break;
160  }
162 }
#define _(s)
Definition: gettext.h:35
void handleMercenaryMessage(const int cmd)

References _, ChatMsgType::BY_SERVER, EAthena::MercenaryRecv::handleMercenaryMessage(), Actions::msg(), processChatContinue(), and strprintf().

◆ processFormatMessageNumber()

void EAthena::ChatRecv::processFormatMessageNumber ( Net::MessageIn msg)

Definition at line 164 of file chatrecv.cpp.

165 {
166  const int msgId = msg.readInt16("msg id");
167  const int value = msg.readInt32("value");
168  if (msgId == 1862)
169  {
171  return;
172  }
173  // +++ here need load message from configuration file
174  const std::string chatMsg = strprintf(
175  "Message #%d, value: %d", msgId, value);
177 }

References ChatMsgType::BY_SERVER, Actions::msg(), NotifyManager::notify(), processChatContinue(), strprintf(), and NotifyTypes::USE_ITEM_WAIT.

◆ processFormatMessageSkill()

void EAthena::ChatRecv::processFormatMessageSkill ( Net::MessageIn msg)

Definition at line 213 of file chatrecv.cpp.

214 {
215  const int skillId = msg.readInt16("skill id");
216  const int msgId = msg.readInt32("msg id");
217  // +++ here need load message from configuration file
218  const std::string chatMsg = strprintf(
219  "Message #%d, skill: %d", msgId, skillId);
221 }

References ChatMsgType::BY_SERVER, Actions::msg(), processChatContinue(), and strprintf().

◆ processFormatMessageString()

void EAthena::ChatRecv::processFormatMessageString ( Net::MessageIn msg)

Definition at line 189 of file chatrecv.cpp.

190 {
191  const int strLen = msg.readInt16("len") - 6;
192  const int msgId = msg.readInt16("msg id");
193  const std::string message = msg.readString(strLen, "value");
194  // +++ here need load message from configuration file
195  const std::string chatMsg = strprintf(
196  "Message #%d, value: %s", msgId, message.c_str());
198 }

References ChatMsgType::BY_SERVER, Actions::msg(), processChatContinue(), and strprintf().

◆ processFormatMessageStringColor()

void EAthena::ChatRecv::processFormatMessageStringColor ( Net::MessageIn msg)

Definition at line 200 of file chatrecv.cpp.

201 {
202  const int strLen = msg.readInt16("len") - 10;
203  const int msgId = msg.readInt16("msg id");
204  if (packetVersion >= 20160406)
205  msg.readInt32("color");
206  const std::string message = msg.readString(strLen, "value");
207  // +++ here need load message from configuration file
208  const std::string chatMsg = strprintf(
209  "Message #%d, value: %s", msgId, message.c_str());
211 }
int packetVersion
Definition: client.cpp:125

References ChatMsgType::BY_SERVER, Actions::msg(), packetVersion, processChatContinue(), and strprintf().

◆ processGmChat()

void EAthena::ChatRecv::processGmChat ( Net::MessageIn msg)

Definition at line 307 of file chatrecv.cpp.

308 {
309  BLOCK_START("ChatRecv::processChat")
310  const int chatMsgLength = msg.readInt16("len") - 4;
311  if (chatMsgLength <= 0)
312  {
313  BLOCK_END("ChatRecv::processChat")
314  return;
315  }
316 
317  std::string chatMsg = msg.readRawString(chatMsgLength, "message");
318  // remove non persistend "colors" from server.
319  if (!findCutFirst(chatMsg, "ssss"))
320  findCutFirst(chatMsg, "eulb");
321 
322  if (chatWindow != nullptr)
323  chatWindow->addGlobalMessage(chatMsg);
324  BLOCK_END("ChatRecv::processChat")
325 }
void processChat(Net::MessageIn &msg)
Definition: chatrecv.cpp:111

References ChatWindow::addGlobalMessage(), BLOCK_END, BLOCK_START, chatWindow, findCutFirst(), and Actions::msg().

◆ processGmChat2()

void EAthena::ChatRecv::processGmChat2 ( Net::MessageIn msg)

Definition at line 327 of file chatrecv.cpp.

328 {
329  const int chatMsgLength = msg.readInt16("len") - 16;
330  msg.readInt32("font color");
331  msg.readInt16("font type");
332  msg.readInt16("font size");
333  msg.readInt16("font align");
334  msg.readInt16("font y");
335  if (chatWindow != nullptr)
336  {
337  const std::string chatMsg = msg.readRawString(chatMsgLength,
338  "message");
339  chatWindow->addGlobalMessage(chatMsg);
340  }
341  else
342  {
343  msg.readRawString(chatMsgLength, "message");
344  }
345 }
void addGlobalMessage(const std::string &line)

References ChatWindow::addGlobalMessage(), chatWindow, and Actions::msg().

◆ processIgnoreNickAck()

void EAthena::ChatRecv::processIgnoreNickAck ( Net::MessageIn msg)

Definition at line 64 of file chatrecv.cpp.

65 {
66  const int type = msg.readUInt8("type");
67  const int flag = msg.readUInt8("flag");
68  switch (type)
69  {
70  case 0:
71  switch (flag)
72  {
73  case 0:
75  break;
76  case 1:
78  break;
79  case 2:
81  break;
82  default:
84  break;
85  }
86  break;
87  case 1:
88  switch (flag)
89  {
90  case 0:
93  break;
94  case 1:
97  break;
98  default:
101  break;
102  }
103  break;
104 
105  default:
107  break;
108  }
109 }
@ IGNORE_PLAYER_SUCCESS
Definition: notifytypes.h:200
@ IGNORE_PLAYER_FAILURE
Definition: notifytypes.h:201
@ UNIGNORE_PLAYER_UNKNOWN
Definition: notifytypes.h:206
@ IGNORE_PLAYER_TYPE_UNKNOWN
Definition: notifytypes.h:207
@ UNIGNORE_PLAYER_SUCCESS
Definition: notifytypes.h:204
@ IGNORE_PLAYER_TOO_MANY
Definition: notifytypes.h:202
@ IGNORE_PLAYER_UNKNOWN
Definition: notifytypes.h:203
@ UNIGNORE_PLAYER_FAILURE
Definition: notifytypes.h:205

References NotifyTypes::IGNORE_PLAYER_FAILURE, NotifyTypes::IGNORE_PLAYER_SUCCESS, NotifyTypes::IGNORE_PLAYER_TOO_MANY, NotifyTypes::IGNORE_PLAYER_TYPE_UNKNOWN, NotifyTypes::IGNORE_PLAYER_UNKNOWN, Actions::msg(), NotifyManager::notify(), NotifyTypes::UNIGNORE_PLAYER_FAILURE, NotifyTypes::UNIGNORE_PLAYER_SUCCESS, and NotifyTypes::UNIGNORE_PLAYER_UNKNOWN.

◆ processJoinChannel()

void EAthena::ChatRecv::processJoinChannel ( Net::MessageIn msg)

Definition at line 491 of file chatrecv.cpp.

492 {
493  if (chatWindow == nullptr)
494  return;
495 
496  const std::string channel = msg.readString(24, "channel name");
497  const int flag = msg.readUInt8("flag");
498 
499  if (channel.size() < 2)
500  return;
501  switch (flag)
502  {
503  case 0:
504  default:
505  chatWindow->channelChatLog(channel,
506  // TRANSLATORS: chat message
507  strprintf(_("Can't open channel. Channel "
508  "%s is not exists."), channel.c_str()),
512  break;
513 
514  case 1:
515  case 2:
516  chatWindow->addChannelTab(std::string("#").append(
517  channel.substr(1)), false);
518  break;
519  }
520 }
void channelChatLog(const std::string &channel, const std::string &line, ChatMsgTypeT own, const IgnoreRecord ignoreRecord, const TryRemoveColors tryRemoveColors)
ChatTab * addChannelTab(const std::string &name, const bool switchTo)
const bool TryRemoveColors_false

References _, ChatWindow::addChannelTab(), ChatMsgType::BY_SERVER, ChatWindow::channelChatLog(), chatWindow, IgnoreRecord_false, Actions::msg(), strprintf(), and TryRemoveColors_false.

◆ processMannerMessage()

void EAthena::ChatRecv::processMannerMessage ( Net::MessageIn msg)

Definition at line 761 of file chatrecv.cpp.

762 {
763  const int result = msg.readInt32("type");
764  switch (result)
765  {
766  case 0:
768  break;
769  case 5:
770  break;
771  default:
772  UNIMPLEMENTEDPACKETFIELD(result);
773  break;
774  }
775 }

References NotifyTypes::MANNER_CHANGED, Actions::msg(), NotifyManager::notify(), and UNIMPLEMENTEDPACKETFIELD.

◆ processMVPExp()

void EAthena::ChatRecv::processMVPExp ( Net::MessageIn msg)

Definition at line 750 of file chatrecv.cpp.

751 {
753  msg.readInt32("exp");
754 }

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processMVPItem()

void EAthena::ChatRecv::processMVPItem ( Net::MessageIn msg)

Definition at line 744 of file chatrecv.cpp.

745 {
747  msg.readItemId("item id");
748 }

References Actions::msg(), and UNIMPLEMENTEDPACKET.

◆ processMVPNoItem()

void EAthena::ChatRecv::processMVPNoItem ( Net::MessageIn msg)

Definition at line 756 of file chatrecv.cpp.

757 {
759 }

References UNIMPLEMENTEDPACKET.

◆ processScriptMessage()

void EAthena::ChatRecv::processScriptMessage ( Net::MessageIn msg)

Definition at line 815 of file chatrecv.cpp.

816 {
817  const int sz = msg.readInt16("len") - 8;
818  msg.readBeingId("being id");
819  const std::string message = msg.readString(sz, "message");
820  localChatTab->chatLog(message,
824 }

References ChatMsgType::BY_SERVER, ChatTab::chatLog(), IgnoreRecord_false, localChatTab, Actions::msg(), and TryRemoveColors_true.

◆ processServiceMessageColor()

void EAthena::ChatRecv::processServiceMessageColor ( Net::MessageIn msg)

Definition at line 826 of file chatrecv.cpp.

827 {
828  const int sz = msg.readInt16("len") - 8;
829  msg.readInt32("color");
830  const std::string message = msg.readString(sz, "message");
831  localChatTab->chatLog(message,
835 }

References ChatMsgType::BY_SERVER, ChatTab::chatLog(), IgnoreRecord_false, localChatTab, Actions::msg(), and TryRemoveColors_true.

◆ processWhisper()

void EAthena::ChatRecv::processWhisper ( Net::MessageIn msg)

Definition at line 347 of file chatrecv.cpp.

348 {
349  BLOCK_START("ChatRecv::processWhisper")
350  int packetLen = 28;
351  if (msg.getVersion() >= 20091104)
352  packetLen += 4;
353  const int chatMsgLength = msg.readInt16("len") - packetLen;
354  std::string nick = msg.readString(24, "nick");
355  if (msg.getVersion() >= 20091104)
356  msg.readInt32("admin flag");
357 
358  if (chatMsgLength <= 0)
359  {
360  BLOCK_END("ChatRecv::processWhisper")
361  return;
362  }
363 
364  processWhisperContinue(nick, msg.readString(chatMsgLength, "message"));
365 }
void processWhisperContinue(const std::string &nick, std::string chatMsg)
Definition: chatrecv.cpp:522

References BLOCK_END, BLOCK_START, Actions::msg(), and processWhisperContinue().

◆ processWhisperContinue()

void EAthena::ChatRecv::processWhisperContinue ( const std::string &  nick,
std::string  chatMsg 
)

Definition at line 522 of file chatrecv.cpp.

524 {
525  // ignoring future whisper messages
526  if (chatMsg.find("\302\202G") == 0 || chatMsg.find("\302\202A") == 0)
527  {
528  BLOCK_END("ChatRecv::processWhisper")
529  return;
530  }
531  // remove first unicode space if this is may be whisper command.
532  if (chatMsg.find("\302\202!") == 0)
533  chatMsg = chatMsg.substr(2);
534 
535  if (nick != "Server")
536  {
538  {
539  chatWindow->addWhisper(nick,
540  chatMsg,
542  }
543  }
544  else if (localChatTab != nullptr)
545  {
546  localChatTab->chatLog(chatMsg,
550  }
551  BLOCK_END("ChatRecv::processWhisper")
552 }
void addWhisper(const std::string &nick, const std::string &mes, const ChatMsgTypeT own)
static const unsigned int WHISPER

References ChatWindow::addWhisper(), BLOCK_END, ChatMsgType::BY_OTHER, ChatMsgType::BY_SERVER, ChatTab::chatLog(), chatWindow, PlayerRelationsManager::hasPermission(), IgnoreRecord_false, localChatTab, playerRelations, TryRemoveColors_true, and PlayerRelation::WHISPER.

Referenced by processWhisper(), and TmwAthena::ChatRecv::processWhisper().

◆ processWhisperResponse()

void EAthena::ChatRecv::processWhisperResponse ( Net::MessageIn msg)

Definition at line 367 of file chatrecv.cpp.

368 {
369  BLOCK_START("ChatRecv::processWhisperResponse")
370 
371  const uint8_t type = msg.readUInt8("response");
372  if (msg.getVersion() >= 20131223)
373  msg.readBeingId("being id");
374  if (type == 1 && (chatWindow != nullptr))
375  {
376  const std::string nick = Ea::ChatRecv::getLastWhisperNick();
377  if (nick.size() > 1 && nick[0] == '#')
378  {
380  // TRANSLATORS: chat message
381  strprintf(_("Message could not be sent, channel "
382  "%s is not exists."), nick.c_str()),
388  return;
389  }
390  }
392 }
void processWhisperResponseContinue(Net::MessageIn &msg, const uint8_t type)
Definition: chatrecv.cpp:81
std::string getLastWhisperNick()
Definition: chatrecv.cpp:71
WhisperQueue mSentWhispers
Definition: chatrecv.cpp:49
std::string empty
Definition: podict.cpp:26

References _, BLOCK_START, ChatMsgType::BY_SERVER, ChatWindow::channelChatLog(), chatWindow, empty, Ea::ChatRecv::getLastWhisperNick(), IgnoreRecord_false, Ea::ChatRecv::mSentWhispers, Actions::msg(), Ea::ChatRecv::processWhisperResponseContinue(), strprintf(), and TryRemoveColors_false.

Variable Documentation

◆ mChatRoom

std::string EAthena::ChatRecv::mChatRoom

Definition at line 61 of file chatrecv.cpp.

Referenced by EAthena::ChatHandler::createChatRoom(), and processChatRoomCreateAck().