Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Make outputMessage::addRawString available in Lua #1218

Merged
merged 2 commits into from
Sep 14, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/framework/luafunctions.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -818,6 +818,7 @@ void Application::registerLuaFunctions()
g_lua.bindClassMemberFunction<OutputMessage>("addU32", &OutputMessage::addU32);
g_lua.bindClassMemberFunction<OutputMessage>("addU64", &OutputMessage::addU64);
g_lua.bindClassMemberFunction<OutputMessage>("addString", &OutputMessage::addString);
g_lua.bindClassMemberFunction<OutputMessage>("addRawString", &OutputMessage::addRawString);
g_lua.bindClassMemberFunction<OutputMessage>("addPaddingBytes", &OutputMessage::addPaddingBytes);
g_lua.bindClassMemberFunction<OutputMessage>("encryptRsa", &OutputMessage::encryptRsa);
g_lua.bindClassMemberFunction<OutputMessage>("getMessageSize", &OutputMessage::getMessageSize);
Expand Down
11 changes: 11 additions & 0 deletions src/framework/net/outputmessage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down
1 change: 1 addition & 0 deletions src/framework/net/outputmessage.h
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Loading