2012-09-23 22:11:08 +04:00
|
|
|
#ifndef OPENMW_ESM_LEVLISTS_H
|
|
|
|
#define OPENMW_ESM_LEVLISTS_H
|
2010-02-25 19:01:24 +01:00
|
|
|
|
2012-09-17 11:37:50 +04:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2022-01-28 18:40:17 +01:00
|
|
|
#include <components/esm/esmcommon.hpp>
|
2022-02-23 20:06:29 +01:00
|
|
|
#include <components/esm/defs.hpp>
|
2022-01-28 18:40:17 +01:00
|
|
|
|
2011-04-08 17:58:21 +04:00
|
|
|
namespace ESM
|
|
|
|
{
|
2010-02-25 19:01:24 +01:00
|
|
|
|
2012-10-01 00:51:54 +04:00
|
|
|
class ESMReader;
|
|
|
|
class ESMWriter;
|
|
|
|
|
2010-02-25 19:01:24 +01:00
|
|
|
/*
|
2015-02-01 00:26:06 +01:00
|
|
|
* Levelled lists. Since these have identical layout, I only bothered
|
2010-02-25 19:01:24 +01:00
|
|
|
* to implement it once.
|
|
|
|
*
|
2015-02-01 00:26:06 +01:00
|
|
|
* We should later implement the ability to merge levelled lists from
|
2013-05-06 14:10:43 +02:00
|
|
|
* several files.
|
2010-02-25 19:01:24 +01:00
|
|
|
*/
|
|
|
|
|
2015-02-01 00:26:06 +01:00
|
|
|
struct LevelledListBase
|
2010-02-25 19:01:24 +01:00
|
|
|
{
|
2012-09-17 11:37:50 +04:00
|
|
|
int mFlags;
|
2013-04-07 21:01:02 +02:00
|
|
|
unsigned char mChanceNone; // Chance that none are selected (0-100)
|
2021-06-29 23:25:26 +10:00
|
|
|
unsigned int mRecordFlags;
|
2012-10-07 21:24:47 +04:00
|
|
|
std::string mId;
|
2010-02-25 19:01:24 +01:00
|
|
|
|
2011-04-08 17:58:21 +04:00
|
|
|
struct LevelItem
|
|
|
|
{
|
2012-09-17 11:37:50 +04:00
|
|
|
std::string mId;
|
|
|
|
short mLevel;
|
2011-04-08 17:58:21 +04:00
|
|
|
};
|
2010-02-25 19:01:24 +01:00
|
|
|
|
2012-09-17 11:37:50 +04:00
|
|
|
std::vector<LevelItem> mList;
|
2010-02-25 19:01:24 +01:00
|
|
|
|
2022-02-23 20:06:29 +01:00
|
|
|
void load(ESMReader& esm, ESM::NAME recName, bool& isDeleted);
|
|
|
|
void save(ESMWriter& esm, ESM::NAME recName, bool isDeleted) const;
|
2013-05-06 14:10:43 +02:00
|
|
|
|
|
|
|
void blank();
|
|
|
|
///< Set record to default state (does not touch the ID).
|
2010-02-25 19:01:24 +01:00
|
|
|
};
|
|
|
|
|
2022-02-23 20:06:29 +01:00
|
|
|
template <class Base>
|
|
|
|
struct CustomLevelledListBase : LevelledListBase
|
2011-04-08 17:58:21 +04:00
|
|
|
{
|
2022-02-23 20:06:29 +01:00
|
|
|
void load(ESMReader &esm, bool& isDeleted) { LevelledListBase::load(esm, Base::sRecName, isDeleted); }
|
|
|
|
void save(ESMWriter &esm, bool isDeleted = false) const { LevelledListBase::save(esm, Base::sRecName, isDeleted); }
|
|
|
|
};
|
|
|
|
|
|
|
|
struct CreatureLevList : CustomLevelledListBase<CreatureLevList>
|
|
|
|
{
|
|
|
|
/// Record name used to read references.
|
|
|
|
static constexpr ESM::NAME sRecName {"CNAM"};
|
|
|
|
static constexpr RecNameInts sRecordId = RecNameInts::REC_LEVC;
|
2015-06-14 02:31:00 +02:00
|
|
|
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
|
2021-10-12 00:18:23 +02:00
|
|
|
static std::string_view getRecordType() { return "CreatureLevList"; }
|
2013-09-24 13:17:28 +02:00
|
|
|
|
2014-01-14 07:40:17 +01:00
|
|
|
enum Flags
|
|
|
|
{
|
|
|
|
|
|
|
|
AllLevels = 0x01 // Calculate from all levels <= player
|
|
|
|
// level, not just the closest below
|
|
|
|
// player.
|
|
|
|
};
|
2011-04-08 17:58:21 +04:00
|
|
|
};
|
2010-02-25 19:01:24 +01:00
|
|
|
|
2022-02-23 20:06:29 +01:00
|
|
|
struct ItemLevList : CustomLevelledListBase<ItemLevList>
|
2011-04-08 17:58:21 +04:00
|
|
|
{
|
2022-02-23 20:06:29 +01:00
|
|
|
/// Record name used to read references.
|
|
|
|
static constexpr ESM::NAME sRecName {"INAM"};
|
|
|
|
static constexpr RecNameInts sRecordId = RecNameInts::REC_LEVI;
|
2015-06-14 02:31:00 +02:00
|
|
|
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
|
2021-10-12 00:18:23 +02:00
|
|
|
static std::string_view getRecordType() { return "ItemLevList"; }
|
2013-09-24 13:17:28 +02:00
|
|
|
|
2014-01-14 07:40:17 +01:00
|
|
|
enum Flags
|
|
|
|
{
|
|
|
|
|
|
|
|
Each = 0x01, // Select a new item each time this
|
|
|
|
// list is instantiated, instead of
|
|
|
|
// giving several identical items
|
|
|
|
// (used when a container has more
|
2015-02-01 00:26:06 +01:00
|
|
|
// than one instance of one levelled
|
2014-01-14 07:40:17 +01:00
|
|
|
// list.)
|
|
|
|
AllLevels = 0x02 // Calculate from all levels <= player
|
|
|
|
// level, not just the closest below
|
|
|
|
// player.
|
|
|
|
};
|
2011-04-08 17:58:21 +04:00
|
|
|
};
|
2010-02-25 19:01:24 +01:00
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|