1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-01-21 07:53:53 +00:00
openmw/components/esm3/loadlevlist.hpp

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

98 lines
3 KiB
C++
Raw Normal View History

2012-09-23 18:11:08 +00:00
#ifndef OPENMW_ESM_LEVLISTS_H
#define OPENMW_ESM_LEVLISTS_H
2012-09-17 07:37:50 +00:00
#include <string>
#include <vector>
#include <components/esm/defs.hpp>
#include <components/esm/esmcommon.hpp>
namespace ESM
{
2012-09-30 20:51:54 +00:00
class ESMReader;
class ESMWriter;
/*
* Levelled lists. Since these have identical layout, I only bothered
* to implement it once.
*
* We should later implement the ability to merge levelled lists from
* several files.
*/
struct LevelledListBase
{
2012-09-17 07:37:50 +00:00
int mFlags;
2013-04-07 19:01:02 +00:00
unsigned char mChanceNone; // Chance that none are selected (0-100)
unsigned int mRecordFlags;
2012-09-17 07:37:50 +00:00
std::string mId;
struct LevelItem
2022-09-22 18:26:05 +00:00
{
std::string mId;
2012-09-17 07:37:50 +00:00
short mLevel;
2022-09-22 18:26:05 +00:00
};
std::vector<LevelItem> mList;
void load(ESMReader& esm, NAME recName, bool& isDeleted);
void save(ESMWriter& esm, NAME recName, bool isDeleted) const;
void blank();
///< Set record to default state (does not touch the ID).
};
template <class Base>
struct CustomLevelledListBase : LevelledListBase
{
void load(ESMReader& esm, bool& isDeleted) { LevelledListBase::load(esm, Base::sRecName, isDeleted); }
void save(ESMWriter& esm, bool isDeleted = false) const
2022-09-22 18:26:05 +00:00
{
LevelledListBase::save(esm, Base::sRecName, isDeleted);
2022-09-22 18:26:05 +00:00
}
};
struct CreatureLevList : CustomLevelledListBase<CreatureLevList>
{
/// Record name used to read references.
static constexpr NAME sRecName{ "CNAM" };
static constexpr RecNameInts sRecordId = RecNameInts::REC_LEVC;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "CreatureLevList"; }
2022-09-22 18:26:05 +00:00
enum Flags
2022-09-22 18:26:05 +00:00
{
AllLevels = 0x01 // Calculate from all levels <= player
// level, not just the closest below
// player.
2022-09-22 18:26:05 +00:00
};
};
struct ItemLevList : CustomLevelledListBase<ItemLevList>
2022-09-22 18:26:05 +00:00
{
/// Record name used to read references.
static constexpr NAME sRecName{ "INAM" };
static constexpr RecNameInts sRecordId = RecNameInts::REC_LEVI;
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
static std::string_view getRecordType() { return "ItemLevList"; }
2022-09-22 18:26:05 +00:00
enum Flags
2022-09-22 18:26:05 +00:00
{
Each = 0x01, // 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 levelled
// list.)
AllLevels = 0x02 // Calculate from all levels <= player
// level, not just the closest below
// player.
2022-09-22 18:26:05 +00:00
};
};
}
#endif