From 45a857b564c8aaefd4f6852c10cfe64bf4852be3 Mon Sep 17 00:00:00 2001 From: kaetemi Date: Fri, 13 Apr 2012 13:59:24 +0200 Subject: [PATCH] Changed: #1459 Reserve functional group controller node names --- .../include/nel/sound/group_controller_root.h | 1 + code/nel/src/sound/group_controller_root.cpp | 16 ++++++++++++++++ 2 files changed, 17 insertions(+) diff --git a/code/nel/include/nel/sound/group_controller_root.h b/code/nel/include/nel/sound/group_controller_root.h index 2cc86f5b3..2081fa28a 100644 --- a/code/nel/include/nel/sound/group_controller_root.h +++ b/code/nel/include/nel/sound/group_controller_root.h @@ -59,6 +59,7 @@ protected: virtual void calculateFinalGain(); virtual void increaseSources(); virtual void decreaseSources(); + static bool isReservedName(const std::string &nodeName); }; /* class CGroupControllerRoot */ diff --git a/code/nel/src/sound/group_controller_root.cpp b/code/nel/src/sound/group_controller_root.cpp index f1344e195..7ba7173e4 100644 --- a/code/nel/src/sound/group_controller_root.cpp +++ b/code/nel/src/sound/group_controller_root.cpp @@ -78,6 +78,18 @@ void CGroupControllerRoot::decreaseSources() --m_NbSourcesInclChild; } +bool CGroupControllerRoot::isReservedName(const std::string &nodeName) +{ + // These node names are reserved, in case these category controllers can be integrated with CDB. + // I do not forsee any functionality for changing environment effect settings for entire categories. + // The nodeName parameter is already lowercase, see CGroupControllerRoot::getGroupController. + if (nodeName == NLSOUND_GROUP_CONTROLLER_ROOT_PATH) return true; // Root node name can only used by root. + if (nodeName == "gain") return true; + if (nodeName == "pitch") return true; + if (nodeName == "enable" || nodeName == "enabled") return true; + return true; +} + CGroupController *CGroupControllerRoot::getGroupController(const std::string &path) { std::vector pathNodes; @@ -91,6 +103,10 @@ CGroupController *CGroupControllerRoot::getGroupController(const std::string &pa { if (!(*it).empty()) { + if (isReservedName(*it)) + { + nlerror("Attempt to use reserved node name '%s' in group controller path '%s'", (*it).c_str(), path.c_str()); + } std::map::iterator found = active->m_Children.find(*it); if (found == active->m_Children.end()) {