| 68 | } |
| 69 | |
| 70 | Spell* SpellManager::load(GameMap* gameMap, std::istream& is) |
| 71 | { |
| 72 | if(!is.good()) |
| 73 | return nullptr; |
| 74 | |
| 75 | std::vector<const SpellFactory*>& factories = getFactories(); |
| 76 | std::string nextParam; |
| 77 | OD_ASSERT_TRUE(is >> nextParam); |
| 78 | const SpellFactory* factoryToUse = nullptr; |
| 79 | for(const SpellFactory* factory : factories) |
| 80 | { |
| 81 | if(factory == nullptr) |
| 82 | continue; |
| 83 | |
| 84 | if(factory->getName().compare(nextParam) != 0) |
| 85 | continue; |
| 86 | |
| 87 | factoryToUse = factory; |
| 88 | break; |
| 89 | } |
| 90 | |
| 91 | if(factoryToUse == nullptr) |
| 92 | { |
| 93 | OD_LOG_ERR("Unknown Spell type=" + nextParam); |
| 94 | return nullptr; |
| 95 | } |
| 96 | |
| 97 | Spell* spell = factoryToUse->getSpellFromStream(gameMap, is); |
| 98 | if(!spell->importFromStream(is)) |
| 99 | { |
| 100 | OD_LOG_ERR("Couldn't load creature Spell type=" + nextParam); |
| 101 | delete spell; |
| 102 | return nullptr; |
| 103 | } |
| 104 | |
| 105 | return spell; |
| 106 | } |
| 107 | |
| 108 | void SpellManager::dispose(const Spell* spell) |
| 109 | { |
nothing calls this directly
no test coverage detected