diff options
author | Himbeer <himbeer@disroot.org> | 2024-08-23 11:46:19 +0200 |
---|---|---|
committer | Himbeer <himbeer@disroot.org> | 2024-08-23 11:46:19 +0200 |
commit | 53d8cfd7d042c45ccc78f82d3c4b3f2fc8272c7f (patch) | |
tree | 7f91b1a95c5e72d11aab978ee614d5e973674f63 /formspec.go | |
parent | efeceb162b2fd45994bf09023eea065519b6b89b (diff) |
Update to Minetest 5.9
Closes #148.
Diffstat (limited to 'formspec.go')
-rw-r--r-- | formspec.go | 27 |
1 files changed, 6 insertions, 21 deletions
diff --git a/formspec.go b/formspec.go index 08cfa38..a465143 100644 --- a/formspec.go +++ b/formspec.go @@ -2,31 +2,16 @@ package proxy import ( "regexp" - "strings" ) -var itemName = regexp.MustCompile("(item_image\\[[0-9.]+,[0-9.]+;[0-9.]+,[0-9]+;)([a-zA-Z0-9-_.: ]+)(\\])") -var itemButtonName = regexp.MustCompile("(item_image_button\\[[0-9.]+,[0-9.]+;[0-9.]+,[0-9.]+;)([a-zA-Z0-9-_.: ]+)(;[a-zA-Z0-9-_.: ]+;[^\\[\\]]*\\])") -var textureName = regexp.MustCompile("[a-zA-Z0-9-_.]*\\.[a-zA-Z-_.]+") +var itemName = regexp.MustCompile("(item_image\\[[0-9.-]+,[0-9.-]+;[0-9.-]+,[0-9.-]+;)([a-zA-Z0-9-_.: ]+)(\\])") +var itemButtonName = regexp.MustCompile("(item_image_button\\[[0-9.-]+,[0-9.-]+;[0-9.-]+,[0-9.-]+;)([a-zA-Z0-9-_.: ]+)(;[a-zA-Z0-9-_.: ]+;[^\\[\\]]*\\])") +var textureName = regexp.MustCompile("([a-zA-Z0-9-_.]+\\.[a-zA-Z-_.]+)") func (sc *ServerConn) prependFormspec(fs *string) { - subs := disallowedChars.Split(*fs, -1) - seps := disallowedChars.FindAllString(*fs, -1) - - for i, sub := range subs { - if textureName.MatchString(sub) && !strings.Contains(sub, " ") { - prepend(sc.mediaPool, &subs[i]) - } - } - - *fs = "" - for i, sub := range subs { - *fs += sub - if i < len(seps) { - *fs += seps[i] - } - } - + *fs = ReplaceAllStringSubmatchFunc(textureName, *fs, func(groups []string) string { + return sc.mediaPool + "_" + groups[1] + }) *fs = ReplaceAllStringSubmatchFunc(itemName, *fs, func(groups []string) string { return groups[1] + sc.name + "_" + groups[2] + groups[3] }) |