2012-09-23 18:11:08 +00:00
|
|
|
#ifndef OPENMW_ESM_LEVLISTS_H
|
|
|
|
#define OPENMW_ESM_LEVLISTS_H
|
2010-02-25 18:01:24 +00:00
|
|
|
|
2012-09-17 07:37:50 +00:00
|
|
|
#include <string>
|
|
|
|
#include <vector>
|
|
|
|
|
2011-04-08 13:58:21 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
2010-02-25 18:01:24 +00:00
|
|
|
|
2012-09-30 20:51:54 +00:00
|
|
|
class ESMReader;
|
|
|
|
class ESMWriter;
|
|
|
|
|
2010-02-25 18:01:24 +00:00
|
|
|
/*
|
2015-01-31 23:26:06 +00:00
|
|
|
* Levelled lists. Since these have identical layout, I only bothered
|
2010-02-25 18:01:24 +00:00
|
|
|
* to implement it once.
|
|
|
|
*
|
2015-01-31 23:26:06 +00:00
|
|
|
* We should later implement the ability to merge levelled lists from
|
2013-05-06 12:10:43 +00:00
|
|
|
* several files.
|
2010-02-25 18:01:24 +00:00
|
|
|
*/
|
|
|
|
|
2015-01-31 23:26:06 +00:00
|
|
|
struct LevelledListBase
|
2010-02-25 18:01:24 +00:00
|
|
|
{
|
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)
|
2012-10-07 17:24:47 +00:00
|
|
|
std::string mId;
|
2010-02-25 18:01:24 +00:00
|
|
|
|
2011-04-08 13:58:21 +00:00
|
|
|
// Record name used to read references. Must be set before load() is
|
|
|
|
// called.
|
2012-09-17 07:37:50 +00:00
|
|
|
const char *mRecName;
|
2010-02-25 18:01:24 +00:00
|
|
|
|
2011-04-08 13:58:21 +00:00
|
|
|
struct LevelItem
|
|
|
|
{
|
2012-09-17 07:37:50 +00:00
|
|
|
std::string mId;
|
|
|
|
short mLevel;
|
2011-04-08 13:58:21 +00:00
|
|
|
};
|
2010-02-25 18:01:24 +00:00
|
|
|
|
2012-09-17 07:37:50 +00:00
|
|
|
std::vector<LevelItem> mList;
|
2010-02-25 18:01:24 +00:00
|
|
|
|
2015-07-20 14:23:14 +00:00
|
|
|
void load(ESMReader &esm, bool &isDeleted);
|
|
|
|
void save(ESMWriter &esm, bool isDeleted = false) const;
|
2013-05-06 12:10:43 +00:00
|
|
|
|
|
|
|
void blank();
|
|
|
|
///< Set record to default state (does not touch the ID).
|
2010-02-25 18:01:24 +00:00
|
|
|
};
|
|
|
|
|
2015-01-31 23:26:06 +00:00
|
|
|
struct CreatureLevList: LevelledListBase
|
2011-04-08 13:58:21 +00:00
|
|
|
{
|
2013-09-24 11:17:28 +00:00
|
|
|
static unsigned int sRecordId;
|
2015-06-14 00:31:00 +00:00
|
|
|
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
|
|
|
|
static std::string getRecordType() { return "CreatureLevList"; }
|
2013-09-24 11:17:28 +00:00
|
|
|
|
2014-01-14 06:40:17 +00:00
|
|
|
enum Flags
|
|
|
|
{
|
|
|
|
|
|
|
|
AllLevels = 0x01 // Calculate from all levels <= player
|
|
|
|
// level, not just the closest below
|
|
|
|
// player.
|
|
|
|
};
|
|
|
|
|
2011-04-08 13:58:21 +00:00
|
|
|
CreatureLevList()
|
|
|
|
{
|
2012-09-17 07:37:50 +00:00
|
|
|
mRecName = "CNAM";
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|
|
|
|
};
|
2010-02-25 18:01:24 +00:00
|
|
|
|
2015-01-31 23:26:06 +00:00
|
|
|
struct ItemLevList: LevelledListBase
|
2011-04-08 13:58:21 +00:00
|
|
|
{
|
2013-09-24 11:17:28 +00:00
|
|
|
static unsigned int sRecordId;
|
2015-06-14 00:31:00 +00:00
|
|
|
/// Return a string descriptor for this record type. Currently used for debugging / error logs only.
|
|
|
|
static std::string getRecordType() { return "ItemLevList"; }
|
2013-09-24 11:17:28 +00:00
|
|
|
|
2014-01-14 06:40:17 +00: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-01-31 23:26:06 +00:00
|
|
|
// than one instance of one levelled
|
2014-01-14 06:40:17 +00:00
|
|
|
// list.)
|
|
|
|
AllLevels = 0x02 // Calculate from all levels <= player
|
|
|
|
// level, not just the closest below
|
|
|
|
// player.
|
|
|
|
};
|
|
|
|
|
2011-04-08 13:58:21 +00:00
|
|
|
ItemLevList()
|
|
|
|
{
|
2012-09-17 07:37:50 +00:00
|
|
|
mRecName = "INAM";
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|
|
|
|
};
|
2010-02-25 18:01:24 +00:00
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|