minetest-mods / skinsdb

Player skin mod, supporting unified_inventory, sfinv and smart_inventory
27 stars 41 forks source link

Private skin for players with underscore in the name does not work #54

Closed Bastrabun closed 1 year ago

Bastrabun commented 3 years ago

Seems players with underscore in their name cannot find their skins

Repro:

SmallJoker commented 3 years ago

Issue in line 27 https://github.com/minetest-mods/skinsdb/blob/8048cb08f1baa2da9c6b392a9dfdcf8a8e174f8e/skinlist.lua#L26-L28

I wonder whether a regex wouldn't fit better there @bell07 ?

local prefix, name, ext = fn:match("^(%a+)_(%S+)%.(%a+)$")

EDIT: works.

bell07 commented 3 years ago

The current implementation does work as designed. Beside the numbered format player_[playername]_[number].ext the skinsdb supports the named format `player[playername][skinname].ext. There is no check for valid player names. player_first_second_0 is player="first" and skinname="second_0". I see no way to get the decision if it is "first_second" / "0" or "first" / "second_0". But the named format is more important for me because I do not like to create metadata-file for each self-created skin.

EDIT: Only Idea I have is: if the last name part is a number, the playername contains all other parts between "player_" and "number". This way we get the support for numbered skin names for player with in the file name. The named format remain unsupported for such players.

Bastrabun commented 3 years ago

I only named the personal skin _0 because I had seen that somewhere before. You're right, if someone has a skin with an underscore in its name, we're doomed. Since minetest allows underscore in the name, I believe we need to consider people doing so. We could

bell07 commented 3 years ago

use the current naming scheme unless there is a meta file, telling skins db what exactly is which part

This is the way I prefer. In enhanced-player_api fork I already changed the meta-file syntax to key = value so there playername = xyz_xyz is possible. (Ok, after small fix I do now). In skinsdb, maybe we can enhance the meta-file syntax the 4th line is the player name? We need additional line skin_obj:set_meta("playername", data[4]) at Line 59

let [skinname] not have an underscore in them

The underscore in skin name is replaced to spaces. I use the underscores because some scripties still have issues to manage files with spaces in name.

find a different truncator that is not allowed by MT names. This might break naming on many servers that go with the current one

Then all server owners need to rename all files :-(