1
0
Fork 1
mirror of https://github.com/TES3MP/openmw-tes3mp.git synced 2025-01-15 16:19:54 +00:00
openmw-tes3mp/components/esm/loadlevlist.hpp
2012-04-08 11:51:52 +02:00

76 lines
1.6 KiB
C++

#ifndef _ESM_LEVLISTS_H
#define _ESM_LEVLISTS_H
#include "record.hpp"
#include "esm_reader.hpp"
#include "esm_writer.hpp"
namespace ESM
{
/*
* Leveled lists. Since these have identical layout, I only bothered
* to implement it once.
*
* We should later implement the ability to merge leveled lists from
* several files.
*/
struct LeveledListBase : public Record
{
enum Flags
{
AllLevels = 0x01, // Calculate from all levels <= player
// level, not just the closest below
// player.
Each = 0x02 // Select a new item each time this
// list is instantiated, instead of
// giving several identical items
}; // (used when a container has more
// than one instance of one leveled
// list.)
int flags;
unsigned char chanceNone; // Chance that none are selected (0-255?)
// Record name used to read references. Must be set before load() is
// called.
const char *recName;
struct LevelItem
{
std::string id;
short level;
};
std::vector<LevelItem> list;
void load(ESMReader &esm);
void save(ESMWriter &esm);
int getName()
{
if (recName[0] == 'C')
return REC_LEVC;
return REC_LEVI;
}
};
struct CreatureLevList: LeveledListBase
{
CreatureLevList()
{
recName = "CNAM";
}
};
struct ItemLevList: LeveledListBase
{
ItemLevList()
{
recName = "INAM";
}
};
}
#endif