summaryrefslogtreecommitdiff
path: root/src/inventory.cpp
diff options
context:
space:
mode:
authorDS <vorunbekannt75@web.de>2020-10-09 20:11:21 +0200
committerGitHub <noreply@github.com>2020-10-09 19:11:21 +0100
commitf3ae45b2b245dd0aeb4a7d9b76afaf078871104c (patch)
treef9b0e27043bbe8f2b16e6f4917f6b9a92f273345 /src/inventory.cpp
parentb2f3f663858e6d2a2174066e425bb6f2edea910b (diff)
downloadminetest-f3ae45b2b245dd0aeb4a7d9b76afaf078871104c.tar.gz
minetest-f3ae45b2b245dd0aeb4a7d9b76afaf078871104c.tar.bz2
minetest-f3ae45b2b245dd0aeb4a7d9b76afaf078871104c.zip
Add a short_description to be used by mods (#8980)
Diffstat (limited to 'src/inventory.cpp')
-rw-r--r--src/inventory.cpp14
1 files changed, 14 insertions, 0 deletions
diff --git a/src/inventory.cpp b/src/inventory.cpp
index cf72cb005..1ef9b13cd 100644
--- a/src/inventory.cpp
+++ b/src/inventory.cpp
@@ -258,6 +258,20 @@ std::string ItemStack::getDescription(IItemDefManager *itemdef) const
return desc.empty() ? name : desc;
}
+std::string ItemStack::getShortDescription(IItemDefManager *itemdef) const
+{
+ std::string desc = metadata.getString("short_description");
+ if (desc.empty())
+ desc = getDefinition(itemdef).short_description;
+ if (!desc.empty())
+ return desc;
+ // no short_description because of old server version or modified builtin
+ // return first line of description
+ std::stringstream sstr(getDescription(itemdef));
+ std::getline(sstr, desc, '\n');
+ return desc;
+}
+
ItemStack ItemStack::addItem(ItemStack newitem, IItemDefManager *itemdef)
{