1
0
mirror of https://github.com/luanti-org/luanti.git synced 2025-10-14 09:05:19 +02:00

Make sure relevant std::stringstreams are set to binary

This commit is contained in:
sfan5
2021-09-11 21:06:57 +02:00
committed by GitHub
parent 766e885a1b
commit 75bf9b75ca
17 changed files with 54 additions and 66 deletions

View File

@@ -752,9 +752,7 @@ int ModApiMapgen::l_get_mapgen_params(lua_State *L)
lua_setfield(L, -2, "mgname");
settingsmgr->getMapSetting("seed", &value);
std::istringstream ss(value);
u64 seed;
ss >> seed;
u64 seed = from_string<u64>(value);
lua_pushinteger(L, seed);
lua_setfield(L, -2, "seed");

View File

@@ -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();