aboutsummaryrefslogtreecommitdiff
path: root/src/script/lua_api/l_util.cpp
diff options
context:
space:
mode:
authorsfan5 <sfan5@live.de>2021-09-11 21:06:57 +0200
committerGitHub <noreply@github.com>2021-09-11 21:06:57 +0200
commit75bf9b75caba5fc876f20eabea3fabc142d1b51e (patch)
treec5a584838498760d0cb5e206795ead223d15527b /src/script/lua_api/l_util.cpp
parent766e885a1b1c5afb7a62f11b427b6d135adeab87 (diff)
downloadminetest-75bf9b75caba5fc876f20eabea3fabc142d1b51e.tar.gz
minetest-75bf9b75caba5fc876f20eabea3fabc142d1b51e.tar.bz2
minetest-75bf9b75caba5fc876f20eabea3fabc142d1b51e.zip
Make sure relevant std::stringstreams are set to binary
Diffstat (limited to 'src/script/lua_api/l_util.cpp')
-rw-r--r--src/script/lua_api/l_util.cpp12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/script/lua_api/l_util.cpp b/src/script/lua_api/l_util.cpp
index 9152b5f7f..2405cd90d 100644
--- a/src/script/lua_api/l_util.cpp
+++ b/src/script/lua_api/l_util.cpp
@@ -272,11 +272,11 @@ int ModApiUtil::l_compress(lua_State *L)
const char *data = luaL_checklstring(L, 1, &size);
int level = -1;
- if (!lua_isnone(L, 3) && !lua_isnil(L, 3))
- level = readParam<float>(L, 3);
+ if (!lua_isnoneornil(L, 3))
+ level = readParam<int>(L, 3);
- std::ostringstream os;
- compressZlib(std::string(data, size), os, level);
+ std::ostringstream os(std::ios_base::binary);
+ compressZlib(reinterpret_cast<const u8 *>(data), size, os, level);
std::string out = os.str();
@@ -292,8 +292,8 @@ int ModApiUtil::l_decompress(lua_State *L)
size_t size;
const char *data = luaL_checklstring(L, 1, &size);
- std::istringstream is(std::string(data, size));
- std::ostringstream os;
+ std::istringstream is(std::string(data, size), std::ios_base::binary);
+ std::ostringstream os(std::ios_base::binary);
decompressZlib(is, os);
std::string out = os.str();