| 57 | } |
| 58 | |
| 59 | CreatureSkill* CreatureSkillManager::load(std::istream& is) |
| 60 | { |
| 61 | if(!is.good()) |
| 62 | return nullptr; |
| 63 | |
| 64 | std::vector<const CreatureSkillFactory*>& factories = getFactories(); |
| 65 | std::string nextParam; |
| 66 | OD_ASSERT_TRUE(is >> nextParam); |
| 67 | const CreatureSkillFactory* factoryToUse = nullptr; |
| 68 | for(const CreatureSkillFactory* factory : factories) |
| 69 | { |
| 70 | if(factory == nullptr) |
| 71 | continue; |
| 72 | |
| 73 | if(factory->getCreatureSkillName().compare(nextParam) != 0) |
| 74 | continue; |
| 75 | |
| 76 | factoryToUse = factory; |
| 77 | break; |
| 78 | } |
| 79 | |
| 80 | if(factoryToUse == nullptr) |
| 81 | { |
| 82 | OD_LOG_ERR("Unknown Skill=" + nextParam); |
| 83 | return nullptr; |
| 84 | } |
| 85 | |
| 86 | CreatureSkill* skill = factoryToUse->createCreatureSkill(); |
| 87 | if(!skill->importFromStream(is)) |
| 88 | { |
| 89 | OD_LOG_ERR("Couldn't load creature Skill=" + nextParam); |
| 90 | delete skill; |
| 91 | return nullptr; |
| 92 | } |
| 93 | |
| 94 | return skill; |
| 95 | } |
| 96 | |
| 97 | void CreatureSkillManager::dispose(const CreatureSkill* skill) |
| 98 | { |
nothing calls this directly
no test coverage detected