From 5849136526646fade763469389d4b3eb70e01f7a Mon Sep 17 00:00:00 2001 From: Allan Ference Date: Sat, 17 Aug 2013 15:09:10 +0200 Subject: [PATCH] Introduce g_things.findItemTypeByName --- src/client/thingtypemanager.cpp | 8 ++++++++ src/client/thingtypemanager.h | 1 + 2 files changed, 9 insertions(+) diff --git a/src/client/thingtypemanager.cpp b/src/client/thingtypemanager.cpp index 5274874c..d9d5142a 100644 --- a/src/client/thingtypemanager.cpp +++ b/src/client/thingtypemanager.cpp @@ -283,6 +283,14 @@ const ItemTypePtr& ThingTypeManager::findItemTypeByClientId(uint16 id) return m_nullItemType; } +const ItemTypePtr& ThingTypeManager::findItemTypeByName(std::string name) +{ + for(const ItemTypePtr& it : m_itemTypes) + if(it->getName() == name) + return it; + return m_nullItemType; +} + const ThingTypePtr& ThingTypeManager::getThingType(uint16 id, ThingCategory category) { if(category >= ThingLastCategory || id >= m_thingTypes[category].size()) { diff --git a/src/client/thingtypemanager.h b/src/client/thingtypemanager.h index 6b86ef32..d89b0019 100644 --- a/src/client/thingtypemanager.h +++ b/src/client/thingtypemanager.h @@ -43,6 +43,7 @@ public: void addItemType(const ItemTypePtr& itemType); const ItemTypePtr& findItemTypeByClientId(uint16 id); + const ItemTypePtr& findItemTypeByName(std::string name); const ThingTypePtr& getNullThingType() { return m_nullThingType; } const ItemTypePtr& getNullItemType() { return m_nullItemType; }