mirror of
https://github.com/edubart/otclient.git
synced 2026-01-17 11:01:30 +01:00
add lua flexibility for protocol
* use shared_ptr for InputMessage and OutputMessage and bind them * allow sending network messages from lua * implement extended opcode * use own OS type for otclient to allow server side detection * fixes in input event bot protection * move RSA to input/output network messages * allow to capture opcodes before GameProtocol parsing with the event GameProtocol.onOpcode * fixes in lua std::string pop/push to allow byte buffering
This commit is contained in:
@@ -610,7 +610,7 @@ void LuaInterface::createLuaState()
|
||||
|
||||
// load lua standard libraries
|
||||
luaL_openlibs(L);
|
||||
|
||||
|
||||
// load bit32 lib for bitwise operations
|
||||
luaopen_bit32(L);
|
||||
|
||||
@@ -998,6 +998,11 @@ void LuaInterface::pushCString(const char* v)
|
||||
lua_pushstring(L, v);
|
||||
}
|
||||
|
||||
void LuaInterface::pushString(const std::string& v)
|
||||
{
|
||||
lua_pushlstring(L, v.c_str(), v.length());
|
||||
}
|
||||
|
||||
void LuaInterface::pushLightUserdata(void* p)
|
||||
{
|
||||
lua_pushlightuserdata(L, p);
|
||||
@@ -1121,9 +1126,10 @@ std::string LuaInterface::toString(int index)
|
||||
{
|
||||
assert(hasIndex(index));
|
||||
std::string str;
|
||||
const char *c_str = lua_tostring(L, index);
|
||||
if(c_str)
|
||||
str = c_str;
|
||||
size_t len;
|
||||
const char *c_str = lua_tolstring(L, index, &len);
|
||||
if(c_str && len > 0)
|
||||
str.assign(c_str, len);
|
||||
return str;
|
||||
}
|
||||
|
||||
|
||||
@@ -269,7 +269,7 @@ public:
|
||||
void pushNumber(double v);
|
||||
void pushBoolean(bool v);
|
||||
void pushCString(const char* v);
|
||||
void pushString(const std::string& v) { pushCString(v.c_str()); }
|
||||
void pushString(const std::string& v);
|
||||
void pushLightUserdata(void* p);
|
||||
void pushThread();
|
||||
void pushValue(int index = -1);
|
||||
|
||||
Reference in New Issue
Block a user