Send max number of characters instead of asserting in case of too long chat messages
authorsapier <Sapier at GMX dot net>
Sun, 11 May 2014 13:39:38 +0000 (15:39 +0200)
committersapier <Sapier at GMX dot net>
Sun, 11 May 2014 13:39:38 +0000 (15:39 +0200)
src/client.cpp

index 871209a17089463ff5ffa9daf97b0cc5d7597ded..6b5072267ed1221ca0db60a45e89f9a6c7ee67f7 100644 (file)
@@ -2082,8 +2082,10 @@ void Client::sendChatMessage(const std::wstring &message)
        
        // Write length
        size_t messagesize = message.size();
-       assert(messagesize <= 0xFFFF);
-       writeU16(buf, (u16) (messagesize & 0xFFFF));
+       if (messagesize > 0xFFFF) {
+               messagesize = 0xFFFF;
+       }
+       writeU16(buf, (u16) messagesize);
        os.write((char*)buf, 2);
        
        // Write string