void ChatHandler::processRaw(MessageOut &outMsg, const std::string &line) { size_t pos = line.find(":"); if (pos == std::string::npos) { const int i = atoi(line.c_str()); if (line.length() <= 3) outMsg.writeInt8(static_cast<unsigned char>(i)); else if (line.length() <= 5) outMsg.writeInt16(static_cast<int16_t>(i)); else outMsg.writeInt32(i); } else { const std::string header = line.substr(0, pos); if (header.length() != 1) return; std::string data = line.substr(pos + 1); int i = 0; switch (header[0]) { case '1': case '2': case '4': i = atoi(data.c_str()); break; default: break; } switch (header[0]) { case '1': outMsg.writeInt8(static_cast<unsigned char>(i)); break; case '2': outMsg.writeInt16(static_cast<int16_t>(i)); break; case '4': outMsg.writeInt32(i); break; case 'c': { pos = line.find(","); if (pos != std::string::npos) { const uint16_t x = static_cast<const uint16_t>( atoi(data.substr(0, pos).c_str())); data = data.substr(pos + 1); pos = line.find(","); if (pos == std::string::npos) break; const uint16_t y = static_cast<const uint16_t>( atoi(data.substr(0, pos).c_str())); const int dir = atoi(data.substr(pos + 1).c_str()); outMsg.writeCoordinates(x, y, static_cast<unsigned char>(dir)); } break; } case 't': outMsg.writeString(data, static_cast<int>(data.length())); break; default: break; } } }