From c1b3ed4180dea16e2fa77663a7d2bf155595dd60 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Lo=C3=AFc=20Blot?= Date: Sun, 7 May 2017 12:13:15 +0200 Subject: Player attrs: permits to remove an attribute by setting value to nil (#5716) * Player attrs: permits to remove an attribute by setting value to nil When doing player:set_attribute("attr", nil) remove attribute Also remove a useless check on C++ API part (already done by checkplayer) Fix #5709 --- src/content_sao.h | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'src/content_sao.h') diff --git a/src/content_sao.h b/src/content_sao.h index e08795579..0dad54805 100644 --- a/src/content_sao.h +++ b/src/content_sao.h @@ -277,6 +277,16 @@ public: return true; } + inline void removeExtendedAttribute(const std::string &attr) + { + PlayerAttributes::iterator it = m_extra_attributes.find(attr); + if (it == m_extra_attributes.end()) + return; + + m_extra_attributes.erase(it); + m_extended_attributes_modified = true; + } + inline const PlayerAttributes &getExtendedAttributes() { return m_extra_attributes; -- cgit v1.2.3