Exported CompressString and UncompressString to Lua
This commit is contained in:
parent
1bcc4abd68
commit
13f81a051d
@ -31,6 +31,7 @@
|
||||
#include "../LineBlockTracer.h"
|
||||
#include "../WorldStorage/SchematicFileSerializer.h"
|
||||
#include "../CompositeChat.h"
|
||||
#include "../StringCompression.h"
|
||||
|
||||
|
||||
|
||||
@ -110,6 +111,40 @@ static int tolua_Clamp(lua_State * tolua_S)
|
||||
|
||||
|
||||
|
||||
static int tolua_CompressString(lua_State * tolua_S)
|
||||
{
|
||||
cLuaState LuaState(tolua_S);
|
||||
const char * ToCompress = tolua_tocppstring(LuaState, 1, 0);
|
||||
int Length = (int)tolua_tonumber(LuaState, 2, 0);
|
||||
int Factor = (int)tolua_tonumber(LuaState, 3, 0);
|
||||
AString res;
|
||||
|
||||
CompressString(ToCompress, Length, res, Factor);
|
||||
LuaState.Push(res);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int tolua_UncompressString(lua_State * tolua_S)
|
||||
{
|
||||
cLuaState LuaState(tolua_S);
|
||||
const char * ToUncompress = tolua_tocppstring(LuaState, 1, 0);
|
||||
int Length = (int)tolua_tonumber(LuaState, 2, 0);
|
||||
int UncompressedSize = (int)tolua_tonumber(LuaState, 3, 0);
|
||||
AString res;
|
||||
|
||||
UncompressString(ToUncompress, Length, res, UncompressedSize);
|
||||
LuaState.Push(res);
|
||||
return 1;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
static int tolua_StringSplit(lua_State * tolua_S)
|
||||
{
|
||||
cLuaState LuaState(tolua_S);
|
||||
@ -3519,6 +3554,8 @@ void ManualBindings::Bind(lua_State * tolua_S)
|
||||
|
||||
// Globals:
|
||||
tolua_function(tolua_S, "Clamp", tolua_Clamp);
|
||||
tolua_function(tolua_S, "CompressString", tolua_CompressString);
|
||||
tolua_function(tolua_S, "UncompressString", tolua_UncompressString);
|
||||
tolua_function(tolua_S, "StringSplit", tolua_StringSplit);
|
||||
tolua_function(tolua_S, "StringSplitAndTrim", tolua_StringSplitAndTrim);
|
||||
tolua_function(tolua_S, "LOG", tolua_LOG);
|
||||
|
Loading…
Reference in New Issue
Block a user