Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- void ProtocolSpectator::parseSpectatorSay(NetworkMessage& msg)
- {
- SpeakClasses type = (SpeakClasses)msg.getByte();
- uint16_t channelId = 0;
- if (type == TALKTYPE_CHANNEL_Y) {
- channelId = msg.get<uint16_t>();
- }
- else {
- return;
- }
- const std::string text = msg.getString();
- if (text.length() > 255 || channelId != CHANNEL_CAST || !client) {
- return;
- }
- if (text.substr(0, 5) == "/nick" && text.length() > 6) {
- std::string newName = text.substr(6);
- if (client) {
- g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::broadcastSpectatorMessage, client, "", (name.empty() ? "spectator" : name) + " changed nick to " + newName)));
- }
- name = newName;
- return;
- }
- if (name.empty()) {
- sendChannelMessage("", "You can not talk before choosing a nick with the /nick command.", TALKTYPE_CHANNEL_O, CHANNEL_CAST);
- return;
- }
- if (client) {
- g_dispatcher.addTask(createTask(std::bind(&ProtocolGame::broadcastSpectatorMessage, client, name, text)));
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement