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

Method load

source/creatureskill/CreatureSkillManager.cpp:59–95  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

57}
58
59CreatureSkill* 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
97void CreatureSkillManager::dispose(const CreatureSkill* skill)
98{

Callers

nothing calls this directly

Calls 2

createCreatureSkillMethod · 0.45
importFromStreamMethod · 0.45

Tested by

no test coverage detected