rm record inheritance, rework esmtool accordingly

This commit is contained in:
greye 2012-09-30 23:34:53 +04:00
parent 1339787863
commit 721324c1db
55 changed files with 932 additions and 735 deletions

View file

@ -1,5 +1,7 @@
set(ESMTOOL set(ESMTOOL
esmtool.cpp esmtool.cpp
record.hpp
record.cpp
) )
source_group(apps\\esmtool FILES ${ESMTOOL}) source_group(apps\\esmtool FILES ${ESMTOOL})

File diff suppressed because it is too large Load diff

568
apps/esmtool/record.cpp Normal file
View file

@ -0,0 +1,568 @@
#include "record.hpp"
#include <iostream>
namespace EsmTool {
RecordBase *
RecordBase::create(int type)
{
RecordBase *record = 0;
switch (type) {
case ESM::REC_ACTI:
{
record = new EsmTool::Record<ESM::Activator>;
break;
}
case ESM::REC_ALCH:
{
record = new EsmTool::Record<ESM::Potion>;
break;
}
case ESM::REC_APPA:
{
record = new EsmTool::Record<ESM::Apparatus>;
break;
}
case ESM::REC_ARMO:
{
record = new EsmTool::Record<ESM::Armor>;
break;
}
case ESM::REC_BODY:
{
record = new EsmTool::Record<ESM::BodyPart>;
break;
}
case ESM::REC_BOOK:
{
record = new EsmTool::Record<ESM::Book>;
break;
}
case ESM::REC_BSGN:
{
record = new EsmTool::Record<ESM::BirthSign>;
break;
}
case ESM::REC_CELL:
{
record = new EsmTool::Record<ESM::Cell>;
break;
}
case ESM::REC_CLAS:
{
record = new EsmTool::Record<ESM::Class>;
break;
}
case ESM::REC_CLOT:
{
record = new EsmTool::Record<ESM::Clothing>;
break;
}
case ESM::REC_CONT:
{
record = new EsmTool::Record<ESM::Container>;
break;
}
case ESM::REC_CREA:
{
record = new EsmTool::Record<ESM::Creature>;
break;
}
case ESM::REC_DIAL:
{
record = new EsmTool::Record<ESM::Dialogue>;
break;
}
case ESM::REC_DOOR:
{
record = new EsmTool::Record<ESM::Door>;
break;
}
case ESM::REC_ENCH:
{
record = new EsmTool::Record<ESM::Enchantment>;
break;
}
case ESM::REC_FACT:
{
record = new EsmTool::Record<ESM::Faction>;
break;
}
case ESM::REC_GLOB:
{
record = new EsmTool::Record<ESM::Global>;
break;
}
case ESM::REC_GMST:
{
record = new EsmTool::Record<ESM::GameSetting>;
break;
}
case ESM::REC_INFO:
{
record = new EsmTool::Record<ESM::DialInfo>;
break;
}
case ESM::REC_INGR:
{
record = new EsmTool::Record<ESM::Ingredient>;
break;
}
case ESM::REC_LAND:
{
record = new EsmTool::Record<ESM::Land>;
break;
}
case ESM::REC_LEVI:
{
record = new EsmTool::Record<ESM::ItemLevList>;
break;
}
case ESM::REC_LEVC:
{
record = new EsmTool::Record<ESM::CreatureLevList>;
break;
}
case ESM::REC_LIGH:
{
record = new EsmTool::Record<ESM::Light>;
break;
}
case ESM::REC_LOCK:
{
record = new EsmTool::Record<ESM::Tool>;
break;
}
case ESM::REC_LTEX:
{
record = new EsmTool::Record<ESM::LandTexture>;
break;
}
case ESM::REC_MISC:
{
record = new EsmTool::Record<ESM::Miscellaneous>;
break;
}
case ESM::REC_MGEF:
{
record = new EsmTool::Record<ESM::MagicEffect>;
break;
}
case ESM::REC_NPC_:
{
record = new EsmTool::Record<ESM::NPC>;
break;
}
case ESM::REC_PGRD:
{
record = new EsmTool::Record<ESM::Pathgrid>;
break;
}
case ESM::REC_PROB:
{
record = new EsmTool::Record<ESM::Probe>;
break;
}
case ESM::REC_RACE:
{
record = new EsmTool::Record<ESM::Race>;
break;
}
case ESM::REC_REGN:
{
record = new EsmTool::Record<ESM::Region>;
break;
}
case ESM::REC_REPA:
{
record = new EsmTool::Record<ESM::Repair>;
break;
}
case ESM::REC_SCPT:
{
record = new EsmTool::Record<ESM::Script>;
break;
}
case ESM::REC_SKIL:
{
record = new EsmTool::Record<ESM::Skill>;
break;
}
case ESM::REC_SNDG:
{
record = new EsmTool::Record<ESM::SoundGenerator>;
break;
}
case ESM::REC_SOUN:
{
record = new EsmTool::Record<ESM::Sound>;
break;
}
case ESM::REC_SPEL:
{
record = new EsmTool::Record<ESM::Spell>;
break;
}
case ESM::REC_STAT:
{
record = new EsmTool::Record<ESM::Static>;
break;
}
case ESM::REC_WEAP:
{
record = new EsmTool::Record<ESM::Weapon>;
break;
}
case ESM::REC_SSCR:
{
record = new EsmTool::Record<ESM::StartScript>;
break;
}
default:
record = 0;
}
if (record) {
record->mType = type;
}
return record;
}
template<>
void Record<ESM::Activator>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Mesh: " << mData.mModel << std::endl;
std::cout << " Script: " << mData.mScript << std::endl;
}
template<>
void Record<ESM::Potion>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
}
template<>
void Record<ESM::Armor>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Mesh: " << mData.mModel << std::endl;
std::cout << " Icon: " << mData.mIcon << std::endl;
std::cout << " Script: " << mData.mScript << std::endl;
std::cout << " Enchantment: " << mData.mEnchant << std::endl;
std::cout << " Type: " << mData.mData.mType << std::endl;
std::cout << " Weight: " << mData.mData.mWeight << std::endl;
}
template<>
void Record<ESM::Apparatus>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
}
template<>
void Record<ESM::BodyPart>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Mesh: " << mData.mModel << std::endl;
}
template<>
void Record<ESM::Book>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Mesh: " << mData.mModel << std::endl;
}
template<>
void Record<ESM::BirthSign>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Texture: " << mData.mTexture << std::endl;
std::cout << " Description: " << mData.mDescription << std::endl;
}
template<>
void Record<ESM::Cell>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Region: " << mData.mRegion << std::endl;
}
template<>
void Record<ESM::Class>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Description: " << mData.mDescription << std::endl;
}
template<>
void Record<ESM::Clothing>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
}
template<>
void Record<ESM::Container>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
}
template<>
void Record<ESM::Creature>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
}
template<>
void Record<ESM::Dialogue>::print()
{
// nothing to print
}
template<>
void Record<ESM::Door>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Mesh: " << mData.mModel << std::endl;
std::cout << " Script: " << mData.mScript << std::endl;
std::cout << " OpenSound: " << mData.mOpenSound << std::endl;
std::cout << " CloseSound: " << mData.mCloseSound << std::endl;
}
template<>
void Record<ESM::Enchantment>::print()
{
// nothing to print
}
template<>
void Record<ESM::Faction>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Attr1: " << mData.mData.mAttribute1 << std::endl;
std::cout << " Attr2: " << mData.mData.mAttribute2 << std::endl;
std::cout << " Hidden: " << mData.mData.mIsHidden << std::endl;
}
template<>
void Record<ESM::Global>::print()
{
// nothing to print
}
template<>
void Record<ESM::GameSetting>::print()
{
std::cout << " Value: ";
switch (mData.mType) {
case ESM::VT_String:
std::cout << "'" << mData.mStr << "' (std::string)";
break;
case ESM::VT_Float:
std::cout << mData.mF << " (float)";
break;
case ESM::VT_Int:
std::cout << mData.mI << " (int)";
break;
default:
std::cout << "unknown type";
}
std::cout << "\n Dirty: " << mData.mDirty << std::endl;
}
template<>
void Record<ESM::DialInfo>::print()
{
std::cout << " Id: " << mData.mId << std::endl;
std::cout << " Text: " << mData.mResponse << std::endl;
}
template<>
void Record<ESM::Ingredient>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Weight: " << mData.mData.mWeight << std::endl;
std::cout << " Value: " << mData.mData.mValue << std::endl;
}
template<>
void Record<ESM::Land>::print()
{
std::cout << " Coords: [" << mData.mX << "," << mData.mY << "]" << std::endl;
}
template<>
void Record<ESM::CreatureLevList>::print()
{
std::cout << " Number of items: " << mData.mList.size() << std::endl;
}
template<>
void Record<ESM::ItemLevList>::print()
{
std::cout << " Number of items: " << mData.mList.size() << std::endl;
}
template<>
void Record<ESM::Light>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Weight: " << mData.mData.mWeight << std::endl;
std::cout << " Value: " << mData.mData.mValue << std::endl;
}
template<>
void Record<ESM::Tool>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Quality: " << mData.mData.mQuality << std::endl;
}
template<>
void Record<ESM::Probe>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Quality: " << mData.mData.mQuality << std::endl;
}
template<>
void Record<ESM::Repair>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Quality: " << mData.mData.mQuality << std::endl;
}
template<>
void Record<ESM::LandTexture>::print()
{
std::cout << " Id: " << mData.mId << std::endl;
std::cout << " Texture: " << mData.mTexture << std::endl;
}
template<>
void Record<ESM::MagicEffect>::print()
{
std::cout << " Index: " << mData.mIndex << std::endl;
const char *text = "Positive";
if (mData.mData.mFlags & ESM::MagicEffect::Negative) {
text = "Negative";
}
std::cout << " " << text << std::endl;
}
template<>
void Record<ESM::Miscellaneous>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Value: " << mData.mData.mValue << std::endl;
}
template<>
void Record<ESM::NPC>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Race: " << mData.mRace << std::endl;
}
template<>
void Record<ESM::Pathgrid>::print()
{
std::cout << " Cell: " << mData.mCell << std::endl;
std::cout << " Point count: " << mData.mPoints.size() << std::endl;
std::cout << " Edge count: " << mData.mEdges.size() << std::endl;
}
template<>
void Record<ESM::Race>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Length: " << mData.mData.mHeight.mMale << "m " << mData.mData.mHeight.mFemale << "f" << std::endl;
}
template<>
void Record<ESM::Region>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
}
template<>
void Record<ESM::Script>::print()
{
std::cout << " Name: " << mData.mData.mName.toString() << std::endl;
}
template<>
void Record<ESM::Skill>::print()
{
std::cout << " ID: " << mData.mIndex << std::endl;
const char *spec = 0;
int specId = mData.mData.mSpecialization;
if (specId == 0) {
spec = "Combat";
} else if (specId == 1) {
spec = "Magic";
} else {
spec = "Stealth";
}
std::cout << " Type: " << spec << std::endl;
}
template<>
void Record<ESM::SoundGenerator>::print()
{
std::cout << " Creature: " << mData.mCreature << std::endl;
std::cout << " Sound: " << mData.mSound << std::endl;
}
template<>
void Record<ESM::Sound>::print()
{
std::cout << " Sound: " << mData.mSound << std::endl;
std::cout << " Volume: " << mData.mData.mVolume << std::endl;
}
template<>
void Record<ESM::Spell>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
}
template<>
void Record<ESM::StartScript>::print()
{
std::cout << "Start script: " << mData.mScript << std::endl;
}
template<>
void Record<ESM::Static>::print()
{
std::cout << " Model: " << mData.mModel << std::endl;
}
template<>
void Record<ESM::Weapon>::print()
{
std::cout << " Name: " << mData.mName << std::endl;
std::cout << " Chop: " << mData.mData.mChop[0] << "-" << mData.mData.mChop[1] << std::endl;
std::cout << " Slash: " << mData.mData.mSlash[0] << "-" << mData.mData.mSlash[1] << std::endl;
std::cout << " Thrust: " << mData.mData.mThrust[0] << "-" << mData.mData.mThrust[1] << std::endl;
std::cout << " Value: " << mData.mData.mValue << std::endl;
}
template<>
void Record<ESM::CellRef>::print()
{
std::cout << " Refnum: " << mData.mRefnum << std::endl;
std::cout << " ID: '" << mData.mRefID << "'\n";
std::cout << " Owner: '" << mData.mOwner << "'\n";
std::cout << " INTV: " << mData.mIntv << " NAM9: " << mData.mIntv << std::endl;
}
} // end namespace

127
apps/esmtool/record.hpp Normal file
View file

@ -0,0 +1,127 @@
#ifndef OPENMW_ESMTOOL_RECORD_H
#define OPENMW_ESMTOOL_RECORD_H
#include <string>
#include <components/esm/records.hpp>
namespace ESM
{
class ESMReader;
class ESMWriter;
}
namespace EsmTool
{
template <class T> class Record;
class RecordBase
{
protected:
std::string mId;
int mFlags;
int mType;
public:
RecordBase () {}
virtual ~RecordBase() {}
const std::string &getId() const {
return mId;
}
void setId(const std::string &id) {
mId = id;
}
int getFlags() const {
return mFlags;
}
void setFlags(int flags) {
mFlags = flags;
}
int getType() const {
return mType;
}
virtual void load(ESM::ESMReader &esm) = 0;
virtual void save(ESM::ESMWriter &esm) = 0;
virtual void print() = 0;
static RecordBase *create(int type);
// just make it a bit shorter
template <class T>
Record<T> *cast() {
return static_cast<Record<T> *>(this);
}
};
template <class T>
class Record : public RecordBase
{
T mData;
public:
T &get() {
return mData;
}
void save(ESM::ESMWriter &esm) {
mData.save(esm);
}
void load(ESM::ESMReader &esm) {
mData.load(esm);
}
void print();
};
template<> void Record<ESM::Activator>::print();
template<> void Record<ESM::Potion>::print();
template<> void Record<ESM::Armor>::print();
template<> void Record<ESM::Apparatus>::print();
template<> void Record<ESM::BodyPart>::print();
template<> void Record<ESM::Book>::print();
template<> void Record<ESM::BirthSign>::print();
template<> void Record<ESM::Cell>::print();
template<> void Record<ESM::Class>::print();
template<> void Record<ESM::Clothing>::print();
template<> void Record<ESM::Container>::print();
template<> void Record<ESM::Creature>::print();
template<> void Record<ESM::Dialogue>::print();
template<> void Record<ESM::Door>::print();
template<> void Record<ESM::Enchantment>::print();
template<> void Record<ESM::Faction>::print();
template<> void Record<ESM::Global>::print();
template<> void Record<ESM::GameSetting>::print();
template<> void Record<ESM::DialInfo>::print();
template<> void Record<ESM::Ingredient>::print();
template<> void Record<ESM::Land>::print();
template<> void Record<ESM::CreatureLevList>::print();
template<> void Record<ESM::ItemLevList>::print();
template<> void Record<ESM::Light>::print();
template<> void Record<ESM::Tool>::print();
template<> void Record<ESM::Probe>::print();
template<> void Record<ESM::Repair>::print();
template<> void Record<ESM::LandTexture>::print();
template<> void Record<ESM::MagicEffect>::print();
template<> void Record<ESM::Miscellaneous>::print();
template<> void Record<ESM::NPC>::print();
template<> void Record<ESM::Pathgrid>::print();
template<> void Record<ESM::Race>::print();
template<> void Record<ESM::Region>::print();
template<> void Record<ESM::Script>::print();
template<> void Record<ESM::Skill>::print();
template<> void Record<ESM::SoundGenerator>::print();
template<> void Record<ESM::Sound>::print();
template<> void Record<ESM::Spell>::print();
template<> void Record<ESM::StartScript>::print();
template<> void Record<ESM::Static>::print();
template<> void Record<ESM::Weapon>::print();
}
#endif

View file

@ -81,7 +81,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Creature> *ref = MWWorld::LiveCellRef<ESM::Creature> *ref =
ptr.get<ESM::Creature>(); ptr.get<ESM::Creature>();
return ref->base->getId(); return ref->base->mId;
} }
void Creature::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Creature::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const

View file

@ -25,7 +25,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::Ingredient> *ref = MWWorld::LiveCellRef<ESM::Ingredient> *ref =
ptr.get<ESM::Ingredient>(); ptr.get<ESM::Ingredient>();
return ref->base->getId(); return ref->base->mId;
} }
void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Ingredient::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const

View file

@ -120,7 +120,7 @@ namespace MWClass
MWWorld::LiveCellRef<ESM::NPC> *ref = MWWorld::LiveCellRef<ESM::NPC> *ref =
ptr.get<ESM::NPC>(); ptr.get<ESM::NPC>();
return ref->base->getId(); return ref->base->mId;
} }
void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const void Npc::insertObjectRendering (const MWWorld::Ptr& ptr, MWRender::RenderingInterface& renderingInterface) const

View file

@ -159,7 +159,7 @@ namespace MWClass
MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPlayer().getPlayer(); MWWorld::Ptr actor = MWBase::Environment::get().getWorld()->getPlayer().getPlayer();
boost::shared_ptr<MWWorld::Action> action ( boost::shared_ptr<MWWorld::Action> action (
new MWWorld::ActionApply (actor, ref->base->getId())); new MWWorld::ActionApply (actor, ref->base->mId));
action->setSound ("Drink"); action->setSound ("Drink");

View file

@ -22,7 +22,7 @@ namespace MWDialogue
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter) iter!=dialogue->mInfo.end(); ++iter)
if (iter->getId() == mInfoId) if (iter->mId == mInfoId)
return iter->mResponse; return iter->mResponse;
throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic); throw std::runtime_error ("unknown info ID " + mInfoId + " for topic " + mTopic);
@ -41,7 +41,7 @@ namespace MWDialogue
iter!=dialogue->mInfo.end(); ++iter) iter!=dialogue->mInfo.end(); ++iter)
if (iter->mData.mDisposition==index) /// \todo cleanup info structure if (iter->mData.mDisposition==index) /// \todo cleanup info structure
{ {
return iter->getId(); return iter->mId;
} }
throw std::runtime_error ("unknown journal index for topic " + topic); throw std::runtime_error ("unknown journal index for topic " + topic);

View file

@ -67,7 +67,7 @@ namespace MWDialogue
for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin()); for (std::vector<ESM::DialInfo>::const_iterator iter (dialogue->mInfo.begin());
iter!=dialogue->mInfo.end(); ++iter) iter!=dialogue->mInfo.end(); ++iter)
if (iter->getId() == entry.mInfoId) if (iter->mId == entry.mInfoId)
{ {
index = iter->mData.mDisposition; /// \todo cleanup info structure index = iter->mData.mDisposition; /// \todo cleanup info structure
break; break;

View file

@ -776,7 +776,7 @@ namespace MWWorld
stream << "$dynamic" << mNextDynamicRecord++; stream << "$dynamic" << mNextDynamicRecord++;
ESM::Potion record2 (record); ESM::Potion record2 (record);
record2.setId(stream.str()); record2.mId = stream.str();
const ESM::Potion *created = const ESM::Potion *created =
&mStore.potions.list.insert (std::make_pair (stream.str(), record2)).first->second; &mStore.potions.list.insert (std::make_pair (stream.str(), record2)).first->second;

View file

@ -6,14 +6,12 @@
namespace ESM namespace ESM
{ {
struct Activator : public Record struct Activator
{ {
std::string mName, mScript, mModel; std::string mName, mScript, mModel;
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_ACTI; }
}; };
} }

View file

@ -12,7 +12,7 @@ namespace ESM
* Alchemy item (potions) * Alchemy item (potions)
*/ */
struct Potion : public Record struct Potion
{ {
struct ALDTstruct struct ALDTstruct
{ {
@ -22,13 +22,11 @@ struct Potion : public Record
}; };
ALDTstruct mData; ALDTstruct mData;
std::string mName, mModel, mIcon, mScript; std::string mId, mName, mModel, mIcon, mScript;
EffectList mEffects; EffectList mEffects;
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
};
int getName() { return REC_ALCH; }
};
} }
#endif #endif

View file

@ -9,7 +9,7 @@ namespace ESM
* Alchemist apparatus * Alchemist apparatus
*/ */
struct Apparatus : public Record struct Apparatus
{ {
enum AppaType enum AppaType
{ {
@ -32,8 +32,6 @@ struct Apparatus : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_APPA; }
}; };
} }
#endif #endif

View file

@ -56,7 +56,7 @@ struct PartReferenceList
void save(ESMWriter &esm); void save(ESMWriter &esm);
}; };
struct Armor : public Record struct Armor
{ {
enum Type enum Type
{ {
@ -87,8 +87,6 @@ struct Armor : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_ARMO; }
}; };
} }
#endif #endif

View file

@ -6,7 +6,7 @@
namespace ESM namespace ESM
{ {
struct BodyPart : public Record struct BodyPart
{ {
enum MeshPart enum MeshPart
{ {
@ -53,8 +53,6 @@ struct BodyPart : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_BODY; }
}; };
} }
#endif #endif

View file

@ -9,7 +9,7 @@ namespace ESM
* Books, magic scrolls, notes and so on * Books, magic scrolls, notes and so on
*/ */
struct Book : public Record struct Book
{ {
struct BKDTstruct struct BKDTstruct
{ {
@ -22,8 +22,6 @@ struct Book : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
};
int getName() { return REC_BOOK; }
};
} }
#endif #endif

View file

@ -9,7 +9,7 @@
namespace ESM namespace ESM
{ {
struct BirthSign : public Record struct BirthSign
{ {
std::string mName, mDescription, mTexture; std::string mName, mDescription, mTexture;
@ -18,8 +18,6 @@ struct BirthSign : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_BSGN; }
}; };
} }
#endif #endif

View file

@ -102,6 +102,8 @@ void Cell::load(ESMReader &esm)
{ {
// Exterior cells // Exterior cells
mRegion = esm.getHNOString("RGNN"); mRegion = esm.getHNOString("RGNN");
mMapColor = 0;
esm.getHNOT(mMapColor, "NAM5"); esm.getHNOT(mMapColor, "NAM5");
} }
if (esm.isNextSub("NAM0")) { if (esm.isNextSub("NAM0")) {

View file

@ -87,7 +87,7 @@ public:
(using ESMReader::getContext()) and jumping back into place (using ESMReader::getContext()) and jumping back into place
whenever we need to load a given cell. whenever we need to load a given cell.
*/ */
struct Cell : public Record struct Cell
{ {
enum Flags enum Flags
{ {
@ -128,8 +128,6 @@ struct Cell : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_CELL; }
bool isExterior() const bool isExterior() const
{ {
return !(mData.mFlags & Interior); return !(mData.mFlags & Interior);

View file

@ -13,7 +13,7 @@ namespace ESM
// These flags tells us which items should be auto-calculated for this // These flags tells us which items should be auto-calculated for this
// class // class
struct Class : public Record struct Class
{ {
enum AutoCalc enum AutoCalc
{ {
@ -63,8 +63,6 @@ struct Class : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_CLAS; }
}; };
} }
#endif #endif

View file

@ -13,7 +13,7 @@ namespace ESM
* Clothing * Clothing
*/ */
struct Clothing : public Record struct Clothing
{ {
enum Type enum Type
{ {
@ -44,8 +44,6 @@ struct Clothing : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_CLOT; }
}; };
} }
#endif #endif

View file

@ -28,7 +28,7 @@ struct InventoryList
void save(ESMWriter &esm); void save(ESMWriter &esm);
}; };
struct Container : public Record struct Container
{ {
enum Flags enum Flags
{ {
@ -45,8 +45,6 @@ struct Container : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_CONT; }
}; };
} }
#endif #endif

View file

@ -16,7 +16,7 @@ namespace ESM
* *
*/ */
struct Creature : public Record struct Creature
{ {
// Default is 0x48? // Default is 0x48?
enum Flags enum Flags
@ -69,7 +69,7 @@ struct Creature : public Record
int mFlags; int mFlags;
float mScale; float mScale;
std::string mModel, mName, mScript; std::string mId, mModel, mName, mScript;
std::string mOriginal; // Base creature that this is a modification of std::string mOriginal; // Base creature that this is a modification of
InventoryList mInventory; InventoryList mInventory;
@ -80,8 +80,6 @@ struct Creature : public Record
AIData mAiData; AIData mAiData;
AIPackageList mAiPackage; AIPackageList mAiPackage;
int getName() { return REC_CREA; }
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
}; };

View file

@ -12,7 +12,7 @@ namespace ESM {
*/ */
/// Changes a creature /// Changes a creature
struct LoadCREC : public Record struct LoadCREC
{ {
void load(ESMReader &esm) void load(ESMReader &esm)
{ {
@ -22,12 +22,10 @@ struct LoadCREC : public Record
void save(ESMWriter &esm) void save(ESMWriter &esm)
{ {
} }
int getName() { return REC_CREC; }
}; };
/// Changes an item list / container /// Changes an item list / container
struct LoadCNTC : public Record struct LoadCNTC
{ {
void load(ESMReader &esm) void load(ESMReader &esm)
{ {
@ -37,8 +35,6 @@ struct LoadCNTC : public Record
void save(ESMWriter &esm) void save(ESMWriter &esm)
{ {
} }
int getName() { return REC_CNTC; }
}; };
} }
#endif #endif

View file

@ -14,7 +14,7 @@ namespace ESM
* the INFO records following the DIAL. * the INFO records following the DIAL.
*/ */
struct Dialogue : public Record struct Dialogue
{ {
enum Type enum Type
{ {
@ -26,13 +26,12 @@ struct Dialogue : public Record
Deleted = -1 Deleted = -1
}; };
std::string mId;
char mType; char mType;
std::vector<DialInfo> mInfo; std::vector<DialInfo> mInfo;
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_DIAL; }
}; };
} }
#endif #endif

View file

@ -8,14 +8,12 @@
namespace ESM namespace ESM
{ {
struct Door : public Record struct Door
{ {
std::string mName, mModel, mScript, mOpenSound, mCloseSound; std::string mName, mModel, mScript, mOpenSound, mCloseSound;
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_DOOR; }
}; };
} }
#endif #endif

View file

@ -10,7 +10,7 @@ namespace ESM
* Enchantments * Enchantments
*/ */
struct Enchantment : public Record struct Enchantment
{ {
enum Type enum Type
{ {
@ -34,8 +34,6 @@ struct Enchantment : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_ENCH; }
}; };
} }
#endif #endif

View file

@ -26,9 +26,9 @@ struct RankData
int mFactReaction; // Reaction from faction members int mFactReaction; // Reaction from faction members
}; };
struct Faction : public Record struct Faction
{ {
std::string mName; std::string mId, mName;
struct FADTstruct struct FADTstruct
{ {
@ -57,8 +57,6 @@ struct Faction : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_FACT; }
}; };
} }
#endif #endif

View file

@ -11,15 +11,13 @@ namespace ESM
* Global script variables * Global script variables
*/ */
struct Global : public Record struct Global
{ {
unsigned mValue; unsigned mValue;
VarType mType; VarType mType;
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_GLOB; }
}; };
} }
#endif #endif

View file

@ -13,8 +13,9 @@ namespace ESM
* *
*/ */
struct GameSetting : public Record struct GameSetting
{ {
std::string mId;
// One of these is used depending on the variable type // One of these is used depending on the variable type
std::string mStr; std::string mStr;
int mI; int mI;
@ -93,8 +94,6 @@ struct GameSetting : public Record
///< Throwns an exception if GMST is not of type string. ///< Throwns an exception if GMST is not of type string.
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_GMST; }
}; };
} }
#endif #endif

View file

@ -8,7 +8,7 @@ namespace ESM
void DialInfo::load(ESMReader &esm) void DialInfo::load(ESMReader &esm)
{ {
mSelfId = esm.getHNString("INAM"); mId = esm.getHNString("INAM");
mPrev = esm.getHNString("PNAM"); mPrev = esm.getHNString("PNAM");
mNext = esm.getHNString("NNAM"); mNext = esm.getHNString("NNAM");
@ -127,7 +127,7 @@ void DialInfo::load(ESMReader &esm)
else else
esm.fail( esm.fail(
"Don't know what to do with " + subName.toString() "Don't know what to do with " + subName.toString()
+ " in INFO " + mSelfId); + " in INFO " + mId);
if (mQuestStatus != QS_None) if (mQuestStatus != QS_None)
// Skip rest of record // Skip rest of record
@ -136,7 +136,7 @@ void DialInfo::load(ESMReader &esm)
void DialInfo::save(ESMWriter &esm) void DialInfo::save(ESMWriter &esm)
{ {
esm.writeHNCString("INAM", mSelfId); esm.writeHNCString("INAM", mId);
esm.writeHNCString("PNAM", mPrev); esm.writeHNCString("PNAM", mPrev);
esm.writeHNCString("NNAM", mNext); esm.writeHNCString("NNAM", mNext);
esm.writeHNT("DATA", mData, 12); esm.writeHNT("DATA", mData, 12);

View file

@ -17,7 +17,7 @@ namespace ESM
* and form a linked list of dialogue items. * and form a linked list of dialogue items.
*/ */
struct DialInfo : public Record struct DialInfo
{ {
enum Gender enum Gender
{ {
@ -61,7 +61,7 @@ struct DialInfo : public Record
std::vector<SelectStruct> mSelects; std::vector<SelectStruct> mSelects;
// Id of this, previous and next INFO items // Id of this, previous and next INFO items
std::string mSelfId, mPrev, mNext; std::string mId, mPrev, mNext;
// Various references used in determining when to select this item. // Various references used in determining when to select this item.
std::string mActor, mRace, mClass, mNpcFaction, mPcFaction, mCell; std::string mActor, mRace, mClass, mNpcFaction, mPcFaction, mCell;
@ -102,8 +102,6 @@ struct DialInfo : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_INFO; }
}; };
/* /*

View file

@ -11,7 +11,7 @@ namespace ESM
* Alchemy ingredient * Alchemy ingredient
*/ */
struct Ingredient : public Record struct Ingredient
{ {
struct IRDTstruct struct IRDTstruct
{ {
@ -23,12 +23,10 @@ struct Ingredient : public Record
}; };
IRDTstruct mData; IRDTstruct mData;
std::string mName, mModel, mIcon, mScript; std::string mId, mName, mModel, mIcon, mScript;
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_INGR; }
}; };
} }
#endif #endif

View file

@ -12,7 +12,7 @@ namespace ESM
* Landscape data. * Landscape data.
*/ */
struct Land : public Record struct Land
{ {
Land(); Land();
~Land(); ~Land();
@ -92,8 +92,6 @@ struct Land : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_LAND; }
/** /**
* Actually loads data * Actually loads data
*/ */

View file

@ -17,7 +17,7 @@ namespace ESM
* several files. * several files.
*/ */
struct LeveledListBase : public Record struct LeveledListBase
{ {
enum Flags enum Flags
{ {
@ -47,14 +47,6 @@ struct LeveledListBase : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName()
{
if (mRecName[0] == 'C')
return REC_LEVC;
return REC_LEVI;
}
}; };
struct CreatureLevList: LeveledListBase struct CreatureLevList: LeveledListBase

View file

@ -13,7 +13,7 @@ namespace ESM
* and torches. * and torches.
*/ */
struct Light : public Record struct Light
{ {
enum Flags enum Flags
{ {
@ -44,8 +44,6 @@ struct Light : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_LIGH; }
}; };
} }
#endif #endif

View file

@ -11,7 +11,7 @@ namespace ESM
* items (REPA). These have nearly identical data structures. * items (REPA). These have nearly identical data structures.
*/ */
struct Tool : public Record struct Tool
{ {
enum Type enum Type
{ {
@ -37,16 +37,6 @@ struct Tool : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName()
{
if (mType == Type_Probe)
return REC_PROB;
else if (mType == Type_Repair)
return REC_REPA;
else
return REC_LOCK;
}
}; };
struct Probe: Tool struct Probe: Tool

View file

@ -24,15 +24,13 @@ namespace ESM
* texture, and see if it affects the game. * texture, and see if it affects the game.
*/ */
struct LandTexture : public Record struct LandTexture
{ {
std::string mTexture; std::string mId, mTexture;
int mIndex; int mIndex;
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_LTEX; }
}; };
} }
#endif #endif

View file

@ -8,7 +8,7 @@
namespace ESM namespace ESM
{ {
struct MagicEffect : public Record struct MagicEffect
{ {
enum Flags enum Flags
{ {
@ -50,8 +50,6 @@ struct MagicEffect : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_MGEF; }
}; };
} }
#endif #endif

View file

@ -13,7 +13,7 @@ namespace ESM
* carried, bought and sold. It also includes keys. * carried, bought and sold. It also includes keys.
*/ */
struct Miscellaneous : public Record struct Miscellaneous
{ {
struct MCDTstruct struct MCDTstruct
{ {
@ -29,8 +29,6 @@ struct Miscellaneous : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_MISC; }
}; };
} }
#endif #endif

View file

@ -15,7 +15,7 @@ namespace ESM {
* NPC definition * NPC definition
*/ */
struct NPC : public Record struct NPC
{ {
// Services // Services
enum Services enum Services
@ -106,7 +106,7 @@ struct NPC : public Record
std::vector<Dest> mTransport; std::vector<Dest> mTransport;
AIPackageList mAiPackage; AIPackageList mAiPackage;
std::string mName, mModel, mRace, mClass, mFaction, mScript; std::string mId, mName, mModel, mRace, mClass, mFaction, mScript;
// body parts // body parts
std::string mHair, mHead; std::string mHair, mHead;
@ -114,8 +114,6 @@ struct NPC : public Record
// Implementation moved to load_impl.cpp // Implementation moved to load_impl.cpp
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_NPC_; }
}; };
} }
#endif #endif

View file

@ -73,7 +73,7 @@ namespace ESM {
* will be harder than reading it. * will be harder than reading it.
*/ */
struct LoadNPCC : public Record struct LoadNPCC
{ {
void load(ESMReader &esm) void load(ESMReader &esm)
{ {
@ -82,8 +82,6 @@ struct LoadNPCC : public Record
void save(ESMWriter &esm) void save(ESMWriter &esm)
{ {
} }
int getName() { return REC_NPCC; }
}; };
} }
#endif #endif

View file

@ -12,7 +12,7 @@ namespace ESM
/* /*
* Path grid. * Path grid.
*/ */
struct Pathgrid : public Record struct Pathgrid
{ {
struct DATAstruct struct DATAstruct
{ {
@ -46,8 +46,6 @@ struct Pathgrid : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_PGRD; }
}; };
} }
#endif #endif

View file

@ -12,7 +12,7 @@ namespace ESM
* Race definition * Race definition
*/ */
struct Race : public Record struct Race
{ {
struct SkillBonus struct SkillBonus
{ {
@ -66,8 +66,6 @@ struct Race : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_RACE; }
}; };
} }

View file

@ -14,7 +14,7 @@ namespace ESM
* Region data * Region data
*/ */
struct Region : public Record struct Region
{ {
#pragma pack(push) #pragma pack(push)
#pragma pack(1) #pragma pack(1)
@ -46,8 +46,6 @@ struct Region : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_REGN; }
}; };
} }
#endif #endif

View file

@ -14,7 +14,7 @@ namespace ESM
* Script definitions * Script definitions
*/ */
class Script : public Record class Script
{ {
public: public:
struct SCHDstruct struct SCHDstruct
@ -55,8 +55,6 @@ public:
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_SCPT; }
}; };
} }
#endif #endif

View file

@ -15,7 +15,7 @@ namespace ESM {
* *
*/ */
struct Skill : public Record struct Skill
{ {
struct SKDTstruct struct SKDTstruct
{ {
@ -71,8 +71,6 @@ struct Skill : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_SKIL; }
}; };
} }
#endif #endif

View file

@ -12,7 +12,7 @@ namespace ESM
* Sound generator. This describes the sounds a creature make. * Sound generator. This describes the sounds a creature make.
*/ */
struct SoundGenerator : public Record struct SoundGenerator
{ {
enum Type enum Type
{ {
@ -33,8 +33,6 @@ struct SoundGenerator : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_SNDG; }
}; };
} }
#endif #endif

View file

@ -13,15 +13,13 @@ struct SOUNstruct
unsigned char mVolume, mMinRange, mMaxRange; unsigned char mVolume, mMinRange, mMaxRange;
}; };
struct Sound : public Record struct Sound
{ {
SOUNstruct mData; SOUNstruct mData;
std::string mSound; std::string mSound;
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_SOUN; }
}; };
} }
#endif #endif

View file

@ -9,7 +9,7 @@
namespace ESM namespace ESM
{ {
struct Spell : public Record struct Spell
{ {
enum SpellType enum SpellType
{ {
@ -41,8 +41,6 @@ struct Spell : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_SPEL; }
}; };
} }
#endif #endif

View file

@ -16,7 +16,7 @@ namespace ESM
reference. reference.
*/ */
struct StartScript : public Record struct StartScript
{ {
std::string mData; std::string mData;
std::string mScript; std::string mScript;
@ -24,8 +24,6 @@ struct StartScript : public Record
// Load a record and add it to the list // Load a record and add it to the list
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_SSCR; }
}; };
} }

View file

@ -19,14 +19,12 @@ namespace ESM {
* you decode the CELL blocks, if you want to test this hypothesis. * you decode the CELL blocks, if you want to test this hypothesis.
*/ */
struct Static : public Record struct Static
{ {
std::string mModel; std::string mModel;
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_STAT; }
}; };
} }
#endif #endif

View file

@ -12,7 +12,7 @@ namespace ESM
* Weapon definition * Weapon definition
*/ */
struct Weapon : public Record struct Weapon
{ {
enum Type enum Type
{ {
@ -59,8 +59,6 @@ struct Weapon : public Record
void load(ESMReader &esm); void load(ESMReader &esm);
void save(ESMWriter &esm); void save(ESMWriter &esm);
int getName() { return REC_WEAP; }
}; };
} }
#endif #endif

View file

@ -173,7 +173,7 @@ namespace ESMS
void load(ESMReader &esm, const std::string &id) void load(ESMReader &esm, const std::string &id)
{ {
std::string id2 = toLower (id); std::string id2 = toLower (id);
list[id2].setId(id2); list[id2].mId = id2;
list[id2].load(esm); list[id2].load(esm);
} }
@ -226,7 +226,7 @@ namespace ESMS
std::string id2 = toLower (id); std::string id2 = toLower (id);
X& ref = list[id2]; X& ref = list[id2];
ref.setId(id); ref.mId = id;
ref.load(esm); ref.load(esm);
} }
@ -293,7 +293,7 @@ namespace ESMS
{ {
LandTexture lt; LandTexture lt;
lt.load(esm); lt.load(esm);
lt.setId(id); lt.mId = id;
// Make sure we have room for the structure // Make sure we have room for the structure
if(lt.mIndex + 1 > (int)ltex.size()) if(lt.mIndex + 1 > (int)ltex.size())