mirror of
https://github.com/luanti-org/luanti.git
synced 2025-06-27 16:36:03 +00:00
Add minetest.is_valid_player_name
utility
This commit is contained in:
parent
44db47e64a
commit
d3ca269c79
7 changed files with 32 additions and 15 deletions
|
@ -859,12 +859,8 @@ int ObjectRef::l_set_observers(lua_State *L)
|
|||
lua_pushnil(L);
|
||||
while (lua_next(L, 2) != 0) {
|
||||
std::string name = readParam<std::string>(L, -2);
|
||||
if (name.empty())
|
||||
throw LuaError("Observer name is empty");
|
||||
if (name.size() > PLAYERNAME_SIZE)
|
||||
throw LuaError("Observer name is too long");
|
||||
if (!string_allowed(name, PLAYERNAME_ALLOWED_CHARS))
|
||||
throw LuaError("Observer name contains invalid characters");
|
||||
if (!is_valid_player_name(name))
|
||||
throw LuaError("Observer name is not a valid player name");
|
||||
if (!lua_toboolean(L, -1)) // falsy value?
|
||||
throw LuaError("Values in the `observers` table need to be true");
|
||||
observer_names.insert(std::move(name));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue