MCPcopy Create free account
hub / github.com/OpenDungeons/OpenDungeons / load

Method load

source/spells/SpellManager.cpp:70–106  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

68}
69
70Spell* 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
108void SpellManager::dispose(const Spell* spell)
109{

Callers

nothing calls this directly

Calls 2

getSpellFromStreamMethod · 0.45
importFromStreamMethod · 0.45

Tested by

no test coverage detected