Advertisement
NonSequitur

Untitled

Feb 2nd, 2016
94
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.98 KB | None | 0 0
  1. void ProtocolSpectator::parseSpectatorSay(NetworkMessage& msg)
  2. {
  3.     SpeakClasses type = (SpeakClasses)msg.getByte();
  4.     uint16_t channelId = 0;
  5.  
  6.     if (type == TALKTYPE_CHANNEL_Y) {
  7.         channelId = msg.get<uint16_t>();
  8.     }
  9.     else {
  10.         return;
  11.     }
  12.  
  13.     const std::string text = msg.getString();
  14.  
  15.     if (text.length() > 255 || channelId != CHANNEL_CAST || !client) {
  16.         return;
  17.     }
  18.  
  19.     if (text.substr(0, 5) == "/nick" && text.length() > 6) {
  20.         std::string newName = text.substr(6);
  21.         if (client) {
  22.             g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::broadcastSpectatorMessage, client, "", (name.empty() ? "spectator" : name) + " changed nick to " + newName)));
  23.         }
  24.         name = newName;
  25.         return;
  26.     }
  27.  
  28.     if (name.empty()) {
  29.         sendChannelMessage("", "You can not talk before choosing a nick with the /nick command.", TALKTYPE_CHANNEL_O, CHANNEL_CAST);
  30.         return;
  31.     }
  32.  
  33.     if (client) {
  34.         g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::broadcastSpectatorMessage, client, name, text)));
  35.     }
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement