1
0
Fork 0
mirror of https://github.com/luanti-org/luanti.git synced 2025-06-27 16:36:03 +00:00

MetaData: restore undocumented set_string behaviour (#14396)

This commit is contained in:
SmallJoker 2024-02-25 16:03:05 +01:00 committed by GitHub
parent b4be483d3e
commit fa1d80b53b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
2 changed files with 33 additions and 2 deletions

View file

@ -115,7 +115,13 @@ int MetaDataRef::l_set_string(lua_State *L)
MetaDataRef *ref = checkAnyMetadata(L, 1);
std::string name = luaL_checkstring(L, 2);
auto str = readParam<std::string_view>(L, 3);
std::string_view str;
if (!lua_isnoneornil(L, 3)) {
str = readParam<std::string_view>(L, 3);
} else {
log_deprecated(L, "Value passed to set_string is nil. This behaviour is"
" undocumented and will result in an error in the future.", 1, true);
}
IMetadata *meta = ref->getmeta(!str.empty());
if (meta != NULL && meta->setString(name, str))