make 4 byte record type accessable from record struct

actorid
Marc Zinnschlag 11 years ago
parent 6d9ff39390
commit c42e74dadf

@ -1,8 +1,6 @@
#include "saving.hpp"
#include <components/esm/defs.hpp>
#include "../world/data.hpp"
#include "../world/idcollection.hpp"
@ -18,37 +16,37 @@ CSMDoc::Saving::Saving (Document& document)
appendStage (new WriteHeaderStage (mDocument, mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Global> >
(mDocument.getData().getGlobals(), mState, ESM::REC_GLOB));
(mDocument.getData().getGlobals(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::GameSetting> >
(mDocument.getData().getGmsts(), mState, ESM::REC_GMST));
(mDocument.getData().getGmsts(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Skill> >
(mDocument.getData().getSkills(), mState, ESM::REC_SKIL));
(mDocument.getData().getSkills(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Class> >
(mDocument.getData().getClasses(), mState, ESM::REC_CLAS));
(mDocument.getData().getClasses(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Faction> >
(mDocument.getData().getFactions(), mState, ESM::REC_FACT));
(mDocument.getData().getFactions(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Race> >
(mDocument.getData().getRaces(), mState, ESM::REC_RACE));
(mDocument.getData().getRaces(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Sound> >
(mDocument.getData().getSounds(), mState, ESM::REC_SOUN));
(mDocument.getData().getSounds(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Script> >
(mDocument.getData().getScripts(), mState, ESM::REC_SCPT));
(mDocument.getData().getScripts(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Region> >
(mDocument.getData().getRegions(), mState, ESM::REC_REGN));
(mDocument.getData().getRegions(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::BirthSign> >
(mDocument.getData().getBirthsigns(), mState, ESM::REC_BSGN));
(mDocument.getData().getBirthsigns(), mState));
appendStage (new WriteCollectionStage<CSMWorld::IdCollection<ESM::Spell> >
(mDocument.getData().getSpells(), mState, ESM::REC_SPEL));
(mDocument.getData().getSpells(), mState));
appendStage (new CloseSaveStage (mState));

@ -1,8 +1,6 @@
#ifndef CSM_DOC_SAVINGSTAGES_H
#define CSM_DOC_SAVINGSTAGES_H
#include <components/esm/defs.hpp>
#include "stage.hpp"
#include "savingstate.hpp"
@ -52,12 +50,10 @@ namespace CSMDoc
{
const CollectionT& mCollection;
SavingState& mState;
ESM::RecNameInts mRecordType;
public:
WriteCollectionStage (const CollectionT& collection, SavingState& state,
ESM::RecNameInts recordType);
WriteCollectionStage (const CollectionT& collection, SavingState& state);
virtual int setup();
///< \return number of steps
@ -68,8 +64,8 @@ namespace CSMDoc
template<class CollectionT>
WriteCollectionStage<CollectionT>::WriteCollectionStage (const CollectionT& collection,
SavingState& state, ESM::RecNameInts recordType)
: mCollection (collection), mState (state), mRecordType (recordType)
SavingState& state)
: mCollection (collection), mState (state)
{}
template<class CollectionT>
@ -89,7 +85,7 @@ namespace CSMDoc
std::string type;
for (int i=0; i<4; ++i)
/// \todo make endianess agnostic (change ESMWriter interface?)
type += reinterpret_cast<const char *> (&mRecordType)[i];
type += reinterpret_cast<const char *> (&mCollection.getRecord (stage).mModified.sRecordId)[i];
mState.getWriter().startRecord (type);
mState.getWriter().writeHNCString ("NAME", mCollection.getId (stage));

@ -2,9 +2,12 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Activator::sRecordId = REC_ACTI;
void Activator::load(ESMReader &esm)
{
mModel = esm.getHNString("MODL");

@ -11,6 +11,8 @@ class ESMWriter;
struct Activator
{
static unsigned int sRecordId;
std::string mId, mName, mScript, mModel;
void load(ESMReader &esm);

@ -2,9 +2,12 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Potion::sRecordId = REC_ALCH;
void Potion::load(ESMReader &esm)
{
mModel = esm.getHNString("MODL");

@ -17,6 +17,8 @@ class ESMWriter;
struct Potion
{
static unsigned int sRecordId;
struct ALDTstruct
{
float mWeight;

@ -2,9 +2,12 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Apparatus::sRecordId = REC_APPA;
void Apparatus::load(ESMReader &esm)
{
// we will not treat duplicated subrecords as errors here

@ -15,6 +15,8 @@ class ESMWriter;
struct Apparatus
{
static unsigned int sRecordId;
enum AppaType
{
MortarPestle = 0,

@ -2,6 +2,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
@ -28,6 +29,8 @@ void PartReferenceList::save(ESMWriter &esm) const
}
}
unsigned int Armor::sRecordId = REC_ARMO;
void Armor::load(ESMReader &esm)
{
mModel = esm.getHNString("MODL");

@ -61,6 +61,8 @@ struct PartReferenceList
struct Armor
{
static unsigned int sRecordId;
enum Type
{
Helmet = 0,

@ -2,9 +2,12 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int BodyPart::sRecordId = REC_BODY;
void BodyPart::load(ESMReader &esm)
{

@ -11,6 +11,8 @@ class ESMWriter;
struct BodyPart
{
static unsigned int sRecordId;
enum MeshPart
{
MP_Head = 0,

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Book::sRecordId = REC_BOOK;
void Book::load(ESMReader &esm)
{

@ -14,6 +14,8 @@ class ESMWriter;
struct Book
{
static unsigned int sRecordId;
struct BKDTstruct
{
float mWeight;

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int BirthSign::sRecordId = REC_BSGN;
void BirthSign::load(ESMReader &esm)
{

@ -13,6 +13,8 @@ class ESMWriter;
struct BirthSign
{
static unsigned int sRecordId;
std::string mId, mName, mDescription, mTexture;
// List of powers and abilities that come with this birth sign.

@ -7,9 +7,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Cell::sRecordId = REC_CELL;
/// Some overloaded compare operators.
bool operator==(const MovedCellRef& ref, int pRefnum)

@ -16,7 +16,6 @@ namespace MWWorld
namespace ESM
{
class ESMReader;
class ESMWriter;
@ -55,6 +54,8 @@ typedef std::list<CellRef> CellRefTracker;
*/
struct Cell
{
static unsigned int sRecordId;
enum Flags
{
Interior = 0x01, // Interior cell

@ -4,9 +4,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Class::sRecordId = REC_CLAS;
const Class::Specialization Class::sSpecializationIds[3] = {
Class::Combat,

@ -17,6 +17,8 @@ class ESMWriter;
// class
struct Class
{
static unsigned int sRecordId;
enum AutoCalc
{
Weapon = 0x00001,

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Clothing::sRecordId = REC_CLOT;
void Clothing::load(ESMReader &esm)
{

@ -17,6 +17,8 @@ class ESMWriter;
struct Clothing
{
static unsigned int sRecordId;
enum Type
{
Pants = 0,

@ -2,6 +2,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
@ -24,6 +25,8 @@ void InventoryList::save(ESMWriter &esm) const
}
}
unsigned int Container::sRecordId = REC_CONT;
void Container::load(ESMReader &esm)
{
mModel = esm.getHNString("MODL");

@ -32,6 +32,8 @@ struct InventoryList
struct Container
{
static unsigned int sRecordId;
enum Flags
{
Organic = 1, // Objects cannot be placed in this container

@ -2,9 +2,12 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM {
unsigned int Creature::sRecordId = REC_CREA;
void Creature::load(ESMReader &esm)
{
mPersistent = esm.getRecordFlags() & 0x0400;

@ -20,6 +20,8 @@ class ESMWriter;
struct Creature
{
static unsigned int sRecordId;
// Default is 0x48?
enum Flags
{

@ -17,6 +17,8 @@ class ESMWriter;
/// Changes a creature
struct LoadCREC
{
static unsigned int sRecordId;
std::string mId;
void load(ESMReader &esm)

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Dialogue::sRecordId = REC_DIAL;
void Dialogue::load(ESMReader &esm)
{

@ -19,6 +19,8 @@ class ESMWriter;
struct Dialogue
{
static unsigned int sRecordId;
enum Type
{
Topic = 0,

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Door::sRecordId = REC_DOOR;
void Door::load(ESMReader &esm)
{

@ -11,6 +11,8 @@ class ESMWriter;
struct Door
{
static unsigned int sRecordId;
std::string mId, mName, mModel, mScript, mOpenSound, mCloseSound;
void load(ESMReader &esm);

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Enchantment::sRecordId = REC_ENCH;
void Enchantment::load(ESMReader &esm)
{

@ -17,6 +17,8 @@ class ESMWriter;
struct Enchantment
{
static unsigned int sRecordId;
enum Type
{
CastOnce = 0,

@ -4,9 +4,12 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Faction::sRecordId = REC_FACT;
int& Faction::FADTstruct::getSkill (int index, bool ignored)
{
if (index<0 || index>=6)

@ -29,6 +29,8 @@ struct RankData
struct Faction
{
static unsigned int sRecordId;
std::string mId, mName;
struct FADTstruct

@ -1,7 +1,11 @@
#include "loadglob.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Global::sRecordId = REC_GLOB;
void Global::load (ESMReader &esm)
{
mValue.read (esm, ESM::Variant::Format_Global);

@ -17,6 +17,8 @@ class ESMWriter;
struct Global
{
static unsigned int sRecordId;
std::string mId;
Variant mValue;

@ -1,7 +1,11 @@
#include "loadgmst.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int GameSetting::sRecordId = REC_GMST;
void GameSetting::load (ESMReader &esm)
{
mValue.read (esm, ESM::Variant::Format_Gmst);

@ -18,6 +18,8 @@ class ESMWriter;
struct GameSetting
{
static unsigned int sRecordId;
std::string mId;
Variant mValue;

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int DialInfo::sRecordId = REC_INFO;
void DialInfo::load(ESMReader &esm)
{

@ -20,6 +20,8 @@ class ESMWriter;
struct DialInfo
{
static unsigned int sRecordId;
enum Gender
{
Male = 0,

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Ingredient::sRecordId = REC_INGR;
void Ingredient::load(ESMReader &esm)
{

@ -15,6 +15,8 @@ class ESMWriter;
struct Ingredient
{
static unsigned int sRecordId;
struct IRDTstruct
{
float mWeight;

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Land::sRecordId = REC_LAND;
void Land::LandData::save(ESMWriter &esm)
{

@ -17,6 +17,8 @@ class ESMWriter;
struct Land
{
static unsigned int sRecordId;
Land();
~Land();

@ -2,6 +2,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
@ -52,4 +53,8 @@ void LeveledListBase::save(ESMWriter &esm) const
mChanceNone = 0;
mList.clear();
}
unsigned int CreatureLevList::sRecordId = REC_LEVC;
unsigned int ItemLevList::sRecordId = REC_LEVI;
}

@ -59,6 +59,8 @@ struct LeveledListBase
struct CreatureLevList: LeveledListBase
{
static unsigned int sRecordId;
CreatureLevList()
{
mRecName = "CNAM";
@ -67,6 +69,8 @@ struct CreatureLevList: LeveledListBase
struct ItemLevList: LeveledListBase
{
static unsigned int sRecordId;
ItemLevList()
{
mRecName = "INAM";

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Light::sRecordId = REC_LIGH;
void Light::load(ESMReader &esm)
{

@ -16,6 +16,8 @@ class ESMWriter;
struct Light
{
static unsigned int sRecordId;
enum Flags
{
Dynamic = 0x001,

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Lockpick::sRecordId = REC_LOCK;
void Lockpick::load(ESMReader &esm)
{

@ -11,6 +11,8 @@ class ESMWriter;
struct Lockpick
{
static unsigned int sRecordId;
struct Data
{
float mWeight;

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int LandTexture::sRecordId = REC_LTEX;
void LandTexture::load(ESMReader &esm)
{

@ -27,6 +27,8 @@ class ESMWriter;
struct LandTexture
{
static unsigned int sRecordId;
std::string mId, mTexture;
int mIndex;

@ -6,6 +6,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace
{
@ -34,6 +35,7 @@ namespace
namespace ESM
{
unsigned int MagicEffect::sRecordId = REC_MGEF;
void MagicEffect::load(ESMReader &esm)
{

@ -12,6 +12,8 @@ class ESMWriter;
struct MagicEffect
{
static unsigned int sRecordId;
enum Flags
{
TargetSkill = 0x1, // Affects a specific skill, which is specified elsewhere in the effect structure.

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Miscellaneous::sRecordId = REC_MISC;
void Miscellaneous::load(ESMReader &esm)
{

@ -16,6 +16,8 @@ class ESMWriter;
struct Miscellaneous
{
static unsigned int sRecordId;
struct MCDTstruct
{
float mWeight;

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int NPC::sRecordId = REC_NPC_;
void NPC::load(ESMReader &esm)
{

@ -20,6 +20,8 @@ class ESMWriter;
struct NPC
{
static unsigned int sRecordId;
// Services
enum Services
{

@ -78,6 +78,8 @@ class ESMWriter;
struct LoadNPCC
{
static unsigned int sRecordId;
std::string mId;
void load(ESMReader &esm)

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Pathgrid::sRecordId = REC_PGRD;
void Pathgrid::load(ESMReader &esm)
{

@ -15,6 +15,8 @@ class ESMWriter;
*/
struct Pathgrid
{
static unsigned int sRecordId;
struct DATAstruct
{
int mX, mY; // Grid location, matches cell for exterior cells

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Probe::sRecordId = REC_PROB;
void Probe::load(ESMReader &esm)
{

@ -11,6 +11,8 @@ class ESMWriter;
struct Probe
{
static unsigned int sRecordId;
struct Data
{
float mWeight;

@ -2,9 +2,12 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Race::sRecordId = REC_RACE;
int Race::MaleFemale::getValue (bool male) const
{
return male ? mMale : mFemale;

@ -17,6 +17,8 @@ class ESMWriter;
struct Race
{
static unsigned int sRecordId;
struct SkillBonus
{
int mSkill; // SkillEnum

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Region::sRecordId = REC_REGN;
void Region::load(ESMReader &esm)
{

@ -18,6 +18,8 @@ class ESMWriter;
struct Region
{
static unsigned int sRecordId;
#pragma pack(push)
#pragma pack(1)
struct WEATstruct

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Repair::sRecordId = REC_REPA;
void Repair::load(ESMReader &esm)
{

@ -11,6 +11,8 @@ class ESMWriter;
struct Repair
{
static unsigned int sRecordId;
struct Data
{
float mWeight;

@ -2,6 +2,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
@ -12,6 +13,8 @@ struct SCHD
Script::SCHDstruct mData;
};
unsigned int Script::sRecordId = REC_SCPT;
void Script::load(ESMReader &esm)
{
SCHD data;

@ -19,6 +19,8 @@ class ESMWriter;
class Script
{
public:
static unsigned int sRecordId;
struct SCHDstruct
{
/* Script name.

@ -6,6 +6,7 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
@ -126,6 +127,8 @@ namespace ESM
HandToHand
}};
unsigned int Skill::sRecordId = REC_SKIL;
void Skill::load(ESMReader &esm)
{
esm.getHNT(mIndex, "INDX");

@ -19,6 +19,8 @@ class ESMWriter;
struct Skill
{
static unsigned int sRecordId;
std::string mId;
struct SKDTstruct

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int SoundGenerator::sRecordId = REC_SNDG;
void SoundGenerator::load(ESMReader &esm)
{

@ -15,6 +15,8 @@ class ESMWriter;
struct SoundGenerator
{
static unsigned int sRecordId;
enum Type
{
LeftFoot = 0,

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Sound::sRecordId = REC_SOUN;
void Sound::load(ESMReader &esm)
{

@ -16,6 +16,8 @@ struct SOUNstruct
struct Sound
{
static unsigned int sRecordId;
SOUNstruct mData;
std::string mId, mSound;

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Spell::sRecordId = REC_SPEL;
void Spell::load(ESMReader &esm)
{

@ -13,6 +13,8 @@ class ESMWriter;
struct Spell
{
static unsigned int sRecordId;
enum SpellType
{
ST_Spell = 0, // Normal spell, must be cast and costs mana

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int StartScript::sRecordId = REC_SSCR;
void StartScript::load(ESMReader &esm)
{

@ -19,6 +19,8 @@ class ESMWriter;
struct StartScript
{
static unsigned int sRecordId;
std::string mData;
std::string mId, mScript;

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Static::sRecordId = REC_STAT;
void Static::load(ESMReader &esm)
{

@ -22,6 +22,8 @@ class ESMWriter;
struct Static
{
static unsigned int sRecordId;
std::string mId, mModel;
void load(ESMReader &esm);

@ -4,6 +4,7 @@
#include "esmcommon.hpp"
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
void ESM::Header::blank()
{

@ -2,9 +2,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
#include "defs.hpp"
namespace ESM
{
unsigned int Weapon::sRecordId = REC_WEAP;
void Weapon::load(ESMReader &esm)
{

@ -15,6 +15,8 @@ class ESMWriter;
struct Weapon
{
static unsigned int sRecordId;
enum Type
{
ShortBladeOneHand = 0,

Loading…
Cancel
Save