1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-08-11 17:51:04 +00:00

Enable dynamic_add_media to take the file data instead of a path

This commit is contained in:
sfan5 2024-01-23 21:15:09 +01:00
parent c90ebad46b
commit d4b107e2e8
8 changed files with 167 additions and 67 deletions

View file

@ -483,6 +483,17 @@ bool check_field_or_nil(lua_State *L, int index, int type, const char *fieldname
bool getstringfield(lua_State *L, int table,
const char *fieldname, std::string &result)
{
std::string_view sv;
if (getstringfield(L, table, fieldname, sv)) {
result = sv;
return true;
}
return false;
}
bool getstringfield(lua_State *L, int table,
const char *fieldname, std::string_view &result)
{
lua_getfield(L, table, fieldname);
bool got = false;
@ -491,7 +502,7 @@ bool getstringfield(lua_State *L, int table,
size_t len = 0;
const char *ptr = lua_tolstring(L, -1, &len);
if (ptr) {
result.assign(ptr, len);
result = std::string_view(ptr, len);
got = true;
}
}