diff --git a/src/framework/luafunctions.cpp b/src/framework/luafunctions.cpp index 40059f2ca..dc157e539 100644 --- a/src/framework/luafunctions.cpp +++ b/src/framework/luafunctions.cpp @@ -819,6 +819,7 @@ void Application::registerLuaFunctions() g_lua.bindClassMemberFunction("addU32", &OutputMessage::addU32); g_lua.bindClassMemberFunction("addU64", &OutputMessage::addU64); g_lua.bindClassMemberFunction("addString", &OutputMessage::addString); + g_lua.bindClassMemberFunction("addRawString", &OutputMessage::addRawString); g_lua.bindClassMemberFunction("addPaddingBytes", &OutputMessage::addPaddingBytes); g_lua.bindClassMemberFunction("encryptRsa", &OutputMessage::encryptRsa); g_lua.bindClassMemberFunction("getMessageSize", &OutputMessage::getMessageSize); diff --git a/src/framework/net/outputmessage.cpp b/src/framework/net/outputmessage.cpp index c0e475e13..688491193 100644 --- a/src/framework/net/outputmessage.cpp +++ b/src/framework/net/outputmessage.cpp @@ -89,6 +89,17 @@ void OutputMessage::addString(const std::string& buffer) m_messageSize += len; } +void OutputMessage::addRawString(const std::string& buffer) +{ + int len = buffer.length(); + if (len > MAX_STRING_LENGTH) + throw stdext::exception(stdext::format("string length > %d", MAX_STRING_LENGTH)); + checkWrite(len); + memcpy((char*)(m_buffer + m_writePos), buffer.c_str(), len); + m_writePos += len; + m_messageSize += len; +} + void OutputMessage::addPaddingBytes(int bytes, uint8 byte) { if(bytes <= 0) diff --git a/src/framework/net/outputmessage.h b/src/framework/net/outputmessage.h index 3dcc53312..3a66518a0 100644 --- a/src/framework/net/outputmessage.h +++ b/src/framework/net/outputmessage.h @@ -48,6 +48,7 @@ class OutputMessage : public LuaObject void addU32(uint32 value); void addU64(uint64 value); void addString(const std::string& buffer); + void addRawString(const std::string& buffer); void addPaddingBytes(int bytes, uint8 byte = 0); void encryptRsa();