mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 09:35:28 +00:00
load skill and magic effect records
This commit is contained in:
parent
814d721e33
commit
0414d7f862
@ -32,6 +32,7 @@ struct Skill
|
|||||||
|
|
||||||
void load(ESMReader &esm)
|
void load(ESMReader &esm)
|
||||||
{
|
{
|
||||||
|
esm.getHNT(index, "INDX");
|
||||||
esm.getHNT(data, "SKDT", 24);
|
esm.getHNT(data, "SKDT", 24);
|
||||||
description = esm.getHNOString("DESC");
|
description = esm.getHNOString("DESC");
|
||||||
}
|
}
|
||||||
|
@ -308,12 +308,53 @@ namespace ESMS
|
|||||||
int getSize() { return list.size(); }
|
int getSize() { return list.size(); }
|
||||||
};
|
};
|
||||||
|
|
||||||
|
template <typename X>
|
||||||
|
struct IndexListT
|
||||||
|
{
|
||||||
|
typedef std::map<int, X> MapType;
|
||||||
|
|
||||||
|
MapType list;
|
||||||
|
|
||||||
|
void load(ESMReader &esm)
|
||||||
|
{
|
||||||
|
X ref;
|
||||||
|
ref.load (esm);
|
||||||
|
int index = ref.index;
|
||||||
|
list[index] = ref;
|
||||||
|
}
|
||||||
|
|
||||||
|
int getSize()
|
||||||
|
{
|
||||||
|
return list.size();
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the given object ID, or return NULL if not found.
|
||||||
|
const X* search (int id) const
|
||||||
|
{
|
||||||
|
if (list.find (id) == list.end())
|
||||||
|
return NULL;
|
||||||
|
|
||||||
|
return &list.find(id)->second;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Find the given object ID (throws an exception if not found)
|
||||||
|
const X* find (int id) const
|
||||||
|
{
|
||||||
|
const X *object = search (id);
|
||||||
|
|
||||||
|
if (!object)
|
||||||
|
{
|
||||||
|
std::ostringstream error;
|
||||||
|
error << "object " << id << " not found";
|
||||||
|
throw std::runtime_error (error.str());
|
||||||
|
}
|
||||||
|
|
||||||
|
return object;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
/* We need special lists for:
|
/* We need special lists for:
|
||||||
|
|
||||||
Magic effects
|
|
||||||
Skills
|
|
||||||
Dialog / Info combo
|
|
||||||
Scripts
|
|
||||||
Land
|
Land
|
||||||
Path grids
|
Path grids
|
||||||
Land textures
|
Land textures
|
||||||
|
@ -46,15 +46,21 @@ void ESMStore::load(ESMReader &esm)
|
|||||||
{
|
{
|
||||||
std::cerr << "error: info record without dialog" << std::endl;
|
std::cerr << "error: info record without dialog" << std::endl;
|
||||||
esm.skipRecord();
|
esm.skipRecord();
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
else if (n.val==ESM::REC_MGEF)
|
||||||
|
{
|
||||||
|
magicEffects.load (esm);
|
||||||
|
}
|
||||||
|
else if (n.val==ESM::REC_SKIL)
|
||||||
|
{
|
||||||
|
skills.load (esm);
|
||||||
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// Not found (this would be an error later)
|
// Not found (this would be an error later)
|
||||||
esm.skipRecord();
|
esm.skipRecord();
|
||||||
missing.insert(n.toString());
|
missing.insert(n.toString());
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -71,9 +71,9 @@ namespace ESMS
|
|||||||
RecIDListT<GameSetting> gameSettings;
|
RecIDListT<GameSetting> gameSettings;
|
||||||
//RecListT<Land> lands;
|
//RecListT<Land> lands;
|
||||||
//RecListT<LandTexture> landTexts;
|
//RecListT<LandTexture> landTexts;
|
||||||
//RecListT<MagicEffect> magicEffects;
|
IndexListT<MagicEffect> magicEffects;
|
||||||
ScriptListT<Script> scripts;
|
ScriptListT<Script> scripts;
|
||||||
//RecListT<Skill> skills;
|
IndexListT<Skill> skills;
|
||||||
//RecListT<PathGrid> pathgrids;
|
//RecListT<PathGrid> pathgrids;
|
||||||
|
|
||||||
// Lookup of all IDs. Makes looking up references faster. Just
|
// Lookup of all IDs. Makes looking up references faster. Just
|
||||||
@ -118,7 +118,6 @@ namespace ESMS
|
|||||||
recLists[REC_LIGH] = &lights;
|
recLists[REC_LIGH] = &lights;
|
||||||
recLists[REC_LOCK] = &lockpicks;
|
recLists[REC_LOCK] = &lockpicks;
|
||||||
//recLists[REC_LTEX] = &landTexts;
|
//recLists[REC_LTEX] = &landTexts;
|
||||||
//recLists[REC_MGEF] = &magicEffects;
|
|
||||||
recLists[REC_MISC] = &miscItems;
|
recLists[REC_MISC] = &miscItems;
|
||||||
recLists[REC_NPC_] = &npcs;
|
recLists[REC_NPC_] = &npcs;
|
||||||
recLists[REC_NPCC] = &npcChange;
|
recLists[REC_NPCC] = &npcChange;
|
||||||
@ -128,7 +127,6 @@ namespace ESMS
|
|||||||
recLists[REC_REGN] = ®ions;
|
recLists[REC_REGN] = ®ions;
|
||||||
recLists[REC_REPA] = &repairs;
|
recLists[REC_REPA] = &repairs;
|
||||||
recLists[REC_SCPT] = &scripts;
|
recLists[REC_SCPT] = &scripts;
|
||||||
//recLists[REC_SKIL] = &skills;
|
|
||||||
recLists[REC_SNDG] = &soundGens;
|
recLists[REC_SNDG] = &soundGens;
|
||||||
recLists[REC_SOUN] = &sounds;
|
recLists[REC_SOUN] = &sounds;
|
||||||
recLists[REC_SPEL] = &spells;
|
recLists[REC_SPEL] = &spells;
|
||||||
|
Loading…
x
Reference in New Issue
Block a user