Introduce g_things.findItemTypeByName

This commit is contained in:
Allan Ference 2013-08-17 15:09:10 +02:00
parent 0451fd6b58
commit 5849136526
2 changed files with 9 additions and 0 deletions

View File

@ -283,6 +283,14 @@ const ItemTypePtr& ThingTypeManager::findItemTypeByClientId(uint16 id)
return m_nullItemType; 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) const ThingTypePtr& ThingTypeManager::getThingType(uint16 id, ThingCategory category)
{ {
if(category >= ThingLastCategory || id >= m_thingTypes[category].size()) { if(category >= ThingLastCategory || id >= m_thingTypes[category].size()) {

View File

@ -43,6 +43,7 @@ public:
void addItemType(const ItemTypePtr& itemType); void addItemType(const ItemTypePtr& itemType);
const ItemTypePtr& findItemTypeByClientId(uint16 id); const ItemTypePtr& findItemTypeByClientId(uint16 id);
const ItemTypePtr& findItemTypeByName(std::string name);
const ThingTypePtr& getNullThingType() { return m_nullThingType; } const ThingTypePtr& getNullThingType() { return m_nullThingType; }
const ItemTypePtr& getNullItemType() { return m_nullItemType; } const ItemTypePtr& getNullItemType() { return m_nullItemType; }