| 156 | } |
| 157 | |
| 158 | Spell* SpellManager::getSpellFromStream(GameMap* gameMap, std::istream& is) |
| 159 | { |
| 160 | SpellType type; |
| 161 | if(!(is >> type)) |
| 162 | return nullptr; |
| 163 | |
| 164 | std::vector<const SpellFactory*>& factories = getFactories(); |
| 165 | uint32_t index = static_cast<uint32_t>(type); |
| 166 | if(index >= factories.size()) |
| 167 | { |
| 168 | OD_LOG_ERR("type=" + Helper::toString(index) + ", factories.size=" + Helper::toString(factories.size())); |
| 169 | return nullptr; |
| 170 | } |
| 171 | |
| 172 | const SpellFactory& factory = *factories[index]; |
| 173 | return factory.getSpellFromStream(gameMap, is); |
| 174 | } |
| 175 | |
| 176 | Spell* SpellManager::getSpellFromPacket(GameMap* gameMap, ODPacket& is) |
| 177 | { |