diff options
author | Pierre-Yves Rollo <dev@pyrollo.com> | 2020-04-25 07:48:04 +0200 |
---|---|---|
committer | GitHub <noreply@github.com> | 2020-04-25 07:48:04 +0200 |
commit | 6cc5c7cbb489a429009e769a958f07da33a9d2ca (patch) | |
tree | a4a499124ac8398136ced6100f03f5062a0d76d5 /src | |
parent | cee3c5e73d7af2a876aa76275234ee76e7cb1bbc (diff) | |
download | minetest-6cc5c7cbb489a429009e769a958f07da33a9d2ca.tar.gz minetest-6cc5c7cbb489a429009e769a958f07da33a9d2ca.tar.bz2 minetest-6cc5c7cbb489a429009e769a958f07da33a9d2ca.zip |
Simplify how parseElement splits element string (#9726)
Diffstat (limited to 'src')
-rw-r--r-- | src/gui/guiFormSpecMenu.cpp | 20 |
1 files changed, 4 insertions, 16 deletions
diff --git a/src/gui/guiFormSpecMenu.cpp b/src/gui/guiFormSpecMenu.cpp index 85ab2eb50..0ed525f97 100644 --- a/src/gui/guiFormSpecMenu.cpp +++ b/src/gui/guiFormSpecMenu.cpp @@ -2668,24 +2668,12 @@ void GUIFormSpecMenu::parseElement(parserData* data, const std::string &element) if (parseVersionDirect(element)) return; - std::vector<std::string> parts = split(element,'['); - - // ugly workaround to keep compatibility - if (parts.size() > 2) { - if (trim(parts[0]) == "image") { - for (unsigned int i=2;i< parts.size(); i++) { - parts[1] += "[" + parts[i]; - } - } - else { return; } - } - - if (parts.size() < 2) { + size_t pos = element.find('['); + if (pos == std::string::npos) return; - } - std::string type = trim(parts[0]); - std::string description = trim(parts[1]); + std::string type = trim(element.substr(0, pos)); + std::string description = element.substr(pos+1); if (type == "container") { parseContainer(data, description); |