Merge branch 'esm_namespace_qualifiers' into 'master'

Remove ESM:: namespace qualifier in components/esm3/ and tests

See merge request OpenMW/openmw!1769
pull/3226/head
psi29a 3 years ago
commit 9809b873a0

@ -425,7 +425,7 @@ namespace
std::string write(const Variant& variant, const Variant::Format format)
{
std::ostringstream out;
ESM::ESMWriter writer;
ESMWriter writer;
writer.save(out);
variant.write(writer, format);
writer.close();
@ -435,7 +435,7 @@ namespace
Variant read(const Variant::Format format, const std::string& data)
{
Variant result;
ESM::ESMReader reader;
ESMReader reader;
reader.open(std::make_shared<std::istringstream>(data), "");
result.read(reader, format);
return result;
@ -490,7 +490,7 @@ namespace
{
const auto param = GetParam();
std::ostringstream out;
ESM::ESMWriter writer;
ESMWriter writer;
writer.save(out);
ASSERT_THROW(param.mVariant.write(writer, param.mFormat), std::runtime_error);
}

@ -3,9 +3,11 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
namespace ESM
{
namespace
{
void save(ESM::ESMWriter& esm, const std::vector<ESM::ActiveSpells::ActiveSpellParams>& spells, ESM::NAME tag)
void saveImpl(ESMWriter& esm, const std::vector<ActiveSpells::ActiveSpellParams>& spells, NAME tag)
{
for (const auto& params : spells)
{
@ -38,19 +40,19 @@ namespace
}
}
void load(ESM::ESMReader& esm, std::vector<ESM::ActiveSpells::ActiveSpellParams>& spells, ESM::NAME tag)
void loadImpl(ESMReader& esm, std::vector<ActiveSpells::ActiveSpellParams>& spells, NAME tag)
{
int format = esm.getFormat();
while (esm.isNextSub(tag))
{
ESM::ActiveSpells::ActiveSpellParams params;
ActiveSpells::ActiveSpellParams params;
params.mId = esm.getHString();
esm.getHNT (params.mCasterActorId, "CAST");
params.mDisplayName = esm.getHNString ("DISP");
params.mItem.unset();
if (format < 17)
params.mType = ESM::ActiveSpells::Type_Temporary;
params.mType = ActiveSpells::Type_Temporary;
else
{
esm.getHNT (params.mType, "TYPE");
@ -71,7 +73,7 @@ namespace
while (esm.isNextSub("MGEF"))
{
ESM::ActiveEffect effect;
ActiveEffect effect;
esm.getHT(effect.mEffectId);
effect.mArg = -1;
esm.getHNOT(effect.mArg, "ARG_");
@ -94,7 +96,7 @@ namespace
else
esm.getHNT (effect.mTimeLeft, "LEFT");
if (format < 17)
effect.mFlags = ESM::ActiveEffect::Flag_None;
effect.mFlags = ActiveEffect::Flag_None;
else
esm.getHNT (effect.mFlags, "FLAG");
@ -104,19 +106,19 @@ namespace
}
}
}
}
namespace ESM
{
void ActiveSpells::save(ESMWriter &esm) const
{
::save(esm, mSpells, "ID__");
::save(esm, mQueue, "QID_");
saveImpl(esm, mSpells, "ID__");
saveImpl(esm, mQueue, "QID_");
}
void ActiveSpells::load(ESMReader &esm)
{
::load(esm, mSpells, "ID__");
::load(esm, mQueue, "QID_");
loadImpl(esm, mSpells, "ID__");
loadImpl(esm, mQueue, "QID_");
}
}

@ -65,7 +65,7 @@ namespace ESM
case AI_Escort:
case AI_Follow: {
const ESM::NAME name = (it->mType == AI_Escort) ? ESM::NAME("AI_E") : ESM::NAME("AI_F");
const NAME name = (it->mType == AI_Escort) ? NAME("AI_E") : NAME("AI_F");
esm.writeHNT(name, it->mTarget, sizeof(it->mTarget));
esm.writeHNOCString("CNDT", it->mCellName);
break;

@ -22,13 +22,13 @@ namespace ESM
enum AiPackages
{
Ai_Wander = ESM::fourCC("WAND"),
Ai_Travel = ESM::fourCC("TRAV"),
Ai_Escort = ESM::fourCC("ESCO"),
Ai_Follow = ESM::fourCC("FOLL"),
Ai_Activate = ESM::fourCC("ACTI"),
Ai_Combat = ESM::fourCC("COMB"),
Ai_Pursue = ESM::fourCC("PURS")
Ai_Wander = fourCC("WAND"),
Ai_Travel = fourCC("TRAV"),
Ai_Escort = fourCC("ESCO"),
Ai_Follow = fourCC("FOLL"),
Ai_Activate = fourCC("ACTI"),
Ai_Combat = fourCC("COMB"),
Ai_Pursue = fourCC("PURS")
};
@ -67,10 +67,10 @@ namespace ESM
struct AiWander : AiPackage
{
AiWanderData mData;
AiWanderDuration mDurationData; // was ESM::TimeStamp mStartTime
AiWanderDuration mDurationData; // was TimeStamp mStartTime
bool mStoredInitialActorPosition;
ESM::Vector3 mInitialActorPosition;
Vector3 mInitialActorPosition;
/// \todo add more AiWander state

@ -3,9 +3,12 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
const std::string ESM::CellId::sDefaultWorldspace = "sys::default";
namespace ESM
{
const std::string CellId::sDefaultWorldspace = "sys::default";
void ESM::CellId::load (ESMReader &esm)
void CellId::load (ESMReader &esm)
{
mWorldspace = esm.getHNString ("SPAC");
@ -18,7 +21,7 @@ void ESM::CellId::load (ESMReader &esm)
mPaged = false;
}
void ESM::CellId::save (ESMWriter &esm) const
void CellId::save (ESMWriter &esm) const
{
esm.writeHNString ("SPAC", mWorldspace);
@ -26,18 +29,18 @@ void ESM::CellId::save (ESMWriter &esm) const
esm.writeHNT ("CIDX", mIndex, 8);
}
bool ESM::operator== (const CellId& left, const CellId& right)
bool operator== (const CellId& left, const CellId& right)
{
return left.mWorldspace==right.mWorldspace && left.mPaged==right.mPaged &&
(!left.mPaged || (left.mIndex.mX==right.mIndex.mX && left.mIndex.mY==right.mIndex.mY));
}
bool ESM::operator!= (const CellId& left, const CellId& right)
bool operator!= (const CellId& left, const CellId& right)
{
return !(left==right);
}
bool ESM::operator < (const CellId& left, const CellId& right)
bool operator < (const CellId& left, const CellId& right)
{
if (left.mPaged < right.mPaged)
return true;
@ -59,3 +62,5 @@ bool ESM::operator < (const CellId& left, const CellId& right)
return left.mWorldspace < right.mWorldspace;
}
}

@ -63,67 +63,67 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::fourCC("UNAM"):
case fourCC("UNAM"):
getHTOrSkip(cellRef.mReferenceBlocked);
break;
case ESM::fourCC("XSCL"):
case fourCC("XSCL"):
getHTOrSkip(cellRef.mScale);
if constexpr (load)
cellRef.mScale = std::clamp(cellRef.mScale, 0.5f, 2.0f);
break;
case ESM::fourCC("ANAM"):
case fourCC("ANAM"):
getHStringOrSkip(cellRef.mOwner);
break;
case ESM::fourCC("BNAM"):
case fourCC("BNAM"):
getHStringOrSkip(cellRef.mGlobalVariable);
break;
case ESM::fourCC("XSOL"):
case fourCC("XSOL"):
getHStringOrSkip(cellRef.mSoul);
break;
case ESM::fourCC("CNAM"):
case fourCC("CNAM"):
getHStringOrSkip(cellRef.mFaction);
break;
case ESM::fourCC("INDX"):
case fourCC("INDX"):
getHTOrSkip(cellRef.mFactionRank);
break;
case ESM::fourCC("XCHG"):
case fourCC("XCHG"):
getHTOrSkip(cellRef.mEnchantmentCharge);
break;
case ESM::fourCC("INTV"):
case fourCC("INTV"):
getHTOrSkip(cellRef.mChargeInt);
break;
case ESM::fourCC("NAM9"):
case fourCC("NAM9"):
getHTOrSkip(cellRef.mGoldValue);
break;
case ESM::fourCC("DODT"):
case fourCC("DODT"):
getHTOrSkip(cellRef.mDoorDest);
if constexpr (load)
cellRef.mTeleport = true;
break;
case ESM::fourCC("DNAM"):
case fourCC("DNAM"):
getHStringOrSkip(cellRef.mDestCell);
break;
case ESM::fourCC("FLTV"):
case fourCC("FLTV"):
getHTOrSkip(cellRef.mLockLevel);
break;
case ESM::fourCC("KNAM"):
case fourCC("KNAM"):
getHStringOrSkip(cellRef.mKey);
break;
case ESM::fourCC("TNAM"):
case fourCC("TNAM"):
getHStringOrSkip(cellRef.mTrap);
break;
case ESM::fourCC("DATA"):
case fourCC("DATA"):
if constexpr (load)
esm.getHTSized<24>(cellRef.mPos);
else
esm.skipHTSized<24, decltype(cellRef.mPos)>();
break;
case ESM::fourCC("NAM0"):
case fourCC("NAM0"):
{
esm.skipHSub();
break;
}
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
if constexpr (load)
isDeleted = true;
@ -145,9 +145,8 @@ namespace ESM
}
}
}
}
void ESM::RefNum::load(ESMReader& esm, bool wide, ESM::NAME tag)
void RefNum::load(ESMReader& esm, bool wide, NAME tag)
{
if (wide)
esm.getHNTSized<8>(*this, tag);
@ -155,7 +154,7 @@ void ESM::RefNum::load(ESMReader& esm, bool wide, ESM::NAME tag)
esm.getHNT(mIndex, tag);
}
void ESM::RefNum::save(ESMWriter &esm, bool wide, ESM::NAME tag) const
void RefNum::save(ESMWriter &esm, bool wide, NAME tag) const
{
if (wide)
esm.writeHNT (tag, *this, 8);
@ -168,23 +167,23 @@ void ESM::RefNum::save(ESMWriter &esm, bool wide, ESM::NAME tag) const
}
}
void ESM::CellRef::load (ESMReader& esm, bool &isDeleted, bool wideRefNum)
void CellRef::load (ESMReader& esm, bool &isDeleted, bool wideRefNum)
{
loadId(esm, wideRefNum);
loadData(esm, isDeleted);
}
void ESM::CellRef::loadId (ESMReader& esm, bool wideRefNum)
void CellRef::loadId (ESMReader& esm, bool wideRefNum)
{
loadIdImpl<true>(esm, wideRefNum, *this);
}
void ESM::CellRef::loadData(ESMReader &esm, bool &isDeleted)
void CellRef::loadData(ESMReader &esm, bool &isDeleted)
{
loadDataImpl<true>(esm, isDeleted, *this);
}
void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory, bool isDeleted) const
void CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory, bool isDeleted) const
{
mRefNum.save (esm, wideRefNum);
@ -246,7 +245,7 @@ void ESM::CellRef::save (ESMWriter &esm, bool wideRefNum, bool inInventory, bool
esm.writeHNT("DATA", mPos, 24);
}
void ESM::CellRef::blank()
void CellRef::blank()
{
mRefNum.unset();
mRefID.clear();
@ -276,10 +275,12 @@ void ESM::CellRef::blank()
}
}
void ESM::skipLoadCellRef(ESMReader& esm, bool wideRefNum)
void skipLoadCellRef(ESMReader& esm, bool wideRefNum)
{
CellRef cellRef;
loadIdImpl<false>(esm, wideRefNum, cellRef);
bool isDeleted;
loadDataImpl<false>(esm, isDeleted, cellRef);
}
}

@ -19,9 +19,9 @@ namespace ESM
unsigned int mIndex;
int mContentFile;
void load(ESMReader& esm, bool wide = false, ESM::NAME tag = "FRMR");
void load(ESMReader& esm, bool wide = false, NAME tag = "FRMR");
void save(ESMWriter &esm, bool wide = false, ESM::NAME tag = "FRMR") const;
void save(ESMWriter &esm, bool wide = false, NAME tag = "FRMR") const;
inline bool hasContentFile() const { return mContentFile >= 0; }

@ -3,7 +3,10 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
void ESM::CellState::load (ESMReader &esm)
namespace ESM
{
void CellState::load (ESMReader &esm)
{
mWaterLevel = 0;
esm.getHNOT (mWaterLevel, "WLVL");
@ -16,7 +19,7 @@ void ESM::CellState::load (ESMReader &esm)
esm.getHNOT (mLastRespawn, "RESP");
}
void ESM::CellState::save (ESMWriter &esm) const
void CellState::save (ESMWriter &esm) const
{
if (!mId.mPaged)
esm.writeHNT ("WLVL", mWaterLevel);
@ -25,3 +28,5 @@ void ESM::CellState::save (ESMWriter &esm) const
esm.writeHNT ("RESP", mLastRespawn);
}
}

@ -21,7 +21,7 @@ namespace ESM
int mHasFogOfWar; // Do we have fog of war state (0 or 1)? (see fogstate.hpp)
ESM::TimeStamp mLastRespawn;
TimeStamp mLastRespawn;
void load (ESMReader &esm);
void save (ESMWriter &esm) const;

@ -1,15 +1,20 @@
#include "containerstate.hpp"
void ESM::ContainerState::load (ESMReader &esm)
namespace ESM
{
void ContainerState::load (ESMReader &esm)
{
ObjectState::load (esm);
mInventory.load (esm);
}
void ESM::ContainerState::save (ESMWriter &esm, bool inInventory) const
void ContainerState::save (ESMWriter &esm, bool inInventory) const
{
ObjectState::save (esm, inInventory);
mInventory.save (esm);
}
}

@ -3,7 +3,10 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
ESM::ControlsState::ControlsState()
namespace ESM
{
ControlsState::ControlsState()
: mViewSwitchDisabled(false),
mControlsDisabled(false),
mJumpingDisabled(false),
@ -14,7 +17,7 @@ ESM::ControlsState::ControlsState()
{
}
void ESM::ControlsState::load(ESM::ESMReader& esm)
void ControlsState::load(ESMReader& esm)
{
int flags;
esm.getHNT(flags, "CFLG");
@ -28,7 +31,7 @@ void ESM::ControlsState::load(ESM::ESMReader& esm)
mSpellDrawingDisabled = flags & SpellDrawingDisabled;
}
void ESM::ControlsState::save(ESM::ESMWriter& esm) const
void ControlsState::save(ESMWriter& esm) const
{
int flags = 0;
if (mViewSwitchDisabled) flags |= ViewSwitchDisabled;
@ -41,3 +44,5 @@ void ESM::ControlsState::save(ESM::ESMWriter& esm) const
esm.writeHNT("CFLG", flags);
}
}

@ -1,6 +1,9 @@
#include "creaturestate.hpp"
void ESM::CreatureState::load (ESMReader &esm)
namespace ESM
{
void CreatureState::load (ESMReader &esm)
{
ObjectState::load (esm);
@ -12,7 +15,7 @@ void ESM::CreatureState::load (ESMReader &esm)
}
}
void ESM::CreatureState::save (ESMWriter &esm, bool inInventory) const
void CreatureState::save (ESMWriter &esm, bool inInventory) const
{
ObjectState::save (esm, inInventory);
@ -24,8 +27,10 @@ void ESM::CreatureState::save (ESMWriter &esm, bool inInventory) const
}
}
void ESM::CreatureState::blank()
void CreatureState::blank()
{
ObjectState::blank();
mCreatureStats.blank();
}
}

@ -4,7 +4,10 @@
#include <limits>
void ESM::CreatureStats::load (ESMReader &esm)
namespace ESM
{
void CreatureStats::load (ESMReader &esm)
{
bool intFallback = esm.getFormat() < 11;
for (int i=0; i<8; ++i)
@ -174,7 +177,7 @@ void ESM::CreatureStats::load (ESMReader &esm)
}
}
void ESM::CreatureStats::save (ESMWriter &esm) const
void CreatureStats::save (ESMWriter &esm) const
{
for (int i=0; i<8; ++i)
mAttributes[i].save (esm);
@ -259,7 +262,7 @@ void ESM::CreatureStats::save (ESMWriter &esm) const
esm.writeHNT("NOAC", mMissingACDT);
}
void ESM::CreatureStats::blank()
void CreatureStats::blank()
{
mTradeTime.mHour = 0;
mTradeTime.mDay = 0;
@ -287,3 +290,5 @@ void ESM::CreatureStats::blank()
mCorprusSpells.clear();
mMissingACDT = false;
}
}

@ -43,7 +43,7 @@ namespace ESM
std::multimap<int, int> mSummonedCreatures;
std::vector<int> mSummonGraveyard;
ESM::TimeStamp mTradeTime;
TimeStamp mTradeTime;
int mGoldPool;
int mActorId;
//int mHitAttemptActorId;
@ -83,7 +83,7 @@ namespace ESM
bool mRecalcDynamicStats;
int mDrawState;
signed char mDeathAnimation;
ESM::TimeStamp mTimeOfDeath;
TimeStamp mTimeOfDeath;
int mLevel;
bool mMissingACDT;

@ -6,7 +6,7 @@
namespace ESM
{
void CustomMarker::save(ESM::ESMWriter &esm) const
void CustomMarker::save(ESMWriter &esm) const
{
esm.writeHNT("POSX", mWorldX);
esm.writeHNT("POSY", mWorldY);
@ -15,7 +15,7 @@ void CustomMarker::save(ESM::ESMWriter &esm) const
esm.writeHNString("NOTE", mNote);
}
void CustomMarker::load(ESM::ESMReader &esm)
void CustomMarker::load(ESMReader &esm)
{
esm.getHNT(mWorldX, "POSX");
esm.getHNT(mWorldY, "POSY");

@ -12,7 +12,7 @@ struct CustomMarker
float mWorldX;
float mWorldY;
ESM::CellId mCell;
CellId mCell;
std::string mNote;
@ -21,8 +21,8 @@ struct CustomMarker
return mNote == other.mNote && mCell == other.mCell && mWorldX == other.mWorldX && mWorldY == other.mWorldY;
}
void load (ESM::ESMReader& reader);
void save (ESM::ESMWriter& writer) const;
void load (ESMReader& reader);
void save (ESMWriter& writer) const;
};
}

@ -4,9 +4,12 @@
#include "esmwriter.hpp"
#include "components/esm/defs.hpp"
unsigned int ESM::DebugProfile::sRecordId = REC_DBGP;
namespace ESM
{
unsigned int DebugProfile::sRecordId = REC_DBGP;
void ESM::DebugProfile::load (ESMReader& esm, bool &isDeleted)
void DebugProfile::load (ESMReader& esm, bool &isDeleted)
{
isDeleted = false;
mRecordFlags = esm.getRecordFlags();
@ -16,19 +19,19 @@ void ESM::DebugProfile::load (ESMReader& esm, bool &isDeleted)
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
break;
case ESM::fourCC("DESC"):
case fourCC("DESC"):
mDescription = esm.getHString();
break;
case ESM::fourCC("SCRP"):
case fourCC("SCRP"):
mScriptText = esm.getHString();
break;
case ESM::fourCC("FLAG"):
case fourCC("FLAG"):
esm.getHT(mFlags);
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;
@ -39,7 +42,7 @@ void ESM::DebugProfile::load (ESMReader& esm, bool &isDeleted)
}
}
void ESM::DebugProfile::save (ESMWriter& esm, bool isDeleted) const
void DebugProfile::save (ESMWriter& esm, bool isDeleted) const
{
esm.writeHNCString ("NAME", mId);
@ -54,9 +57,11 @@ void ESM::DebugProfile::save (ESMWriter& esm, bool isDeleted) const
esm.writeHNT ("FLAG", mFlags);
}
void ESM::DebugProfile::blank()
void DebugProfile::blank()
{
mDescription.clear();
mScriptText.clear();
mFlags = 0;
}
}

@ -3,7 +3,10 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
void ESM::DialogueState::load (ESMReader &esm)
namespace ESM
{
void DialogueState::load (ESMReader &esm)
{
while (esm.isNextSub ("TOPI"))
mKnownTopics.push_back (esm.getHString());
@ -30,7 +33,7 @@ void ESM::DialogueState::load (ESMReader &esm)
}
}
void ESM::DialogueState::save (ESMWriter &esm) const
void DialogueState::save (ESMWriter &esm) const
{
for (std::vector<std::string>::const_iterator iter (mKnownTopics.begin());
iter!=mKnownTopics.end(); ++iter)
@ -51,3 +54,5 @@ void ESM::DialogueState::save (ESMWriter &esm) const
}
}
}
}

@ -3,7 +3,8 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
namespace ESM {
namespace ESM
{
void EffectList::load(ESMReader &esm)
{

@ -13,7 +13,8 @@
#include "components/esm/esmcommon.hpp"
#include "loadtes3.hpp"
namespace ESM {
namespace ESM
{
class ESMReader
{

@ -86,7 +86,7 @@ namespace ESM
throw std::runtime_error ("Unclosed record remaining");
}
void ESMWriter::startRecord(ESM::NAME name, uint32_t flags)
void ESMWriter::startRecord(NAME name, uint32_t flags)
{
mRecordCount++;
@ -105,10 +105,10 @@ namespace ESM
void ESMWriter::startRecord (uint32_t name, uint32_t flags)
{
startRecord(ESM::NAME(name), flags);
startRecord(NAME(name), flags);
}
void ESMWriter::startSubRecord(ESM::NAME name)
void ESMWriter::startSubRecord(NAME name)
{
// Sub-record hierarchies are not properly supported in ESMReader. This should be fixed later.
assert (mRecords.size() <= 1);
@ -124,7 +124,7 @@ namespace ESM
assert(mRecords.back().size == 0);
}
void ESMWriter::endRecord(ESM::NAME name)
void ESMWriter::endRecord(NAME name)
{
RecordData rec = mRecords.back();
assert(rec.name == name);
@ -142,17 +142,17 @@ namespace ESM
void ESMWriter::endRecord (uint32_t name)
{
endRecord(ESM::NAME(name));
endRecord(NAME(name));
}
void ESMWriter::writeHNString(ESM::NAME name, const std::string& data)
void ESMWriter::writeHNString(NAME name, const std::string& data)
{
startSubRecord(name);
writeHString(data);
endRecord(name);
}
void ESMWriter::writeHNString(ESM::NAME name, const std::string& data, size_t size)
void ESMWriter::writeHNString(NAME name, const std::string& data, size_t size)
{
assert(data.size() <= size);
startSubRecord(name);
@ -196,9 +196,9 @@ namespace ESM
write("\0", 1);
}
void ESMWriter::writeName(ESM::NAME name)
void ESMWriter::writeName(NAME name)
{
write(name.mData, ESM::NAME::sCapacity);
write(name.mData, NAME::sCapacity);
}
void ESMWriter::write(const char* data, size_t size)

@ -13,13 +13,14 @@ namespace ToUTF8
class Utf8Encoder;
}
namespace ESM {
namespace ESM
{
class ESMWriter
{
struct RecordData
{
ESM::NAME name;
NAME name;
std::streampos position;
uint32_t size;
};
@ -30,7 +31,7 @@ class ESMWriter
unsigned int getVersion() const;
// Set various header data (ESM::Header::Data). All of the below functions must be called before writing,
// Set various header data (Header::Data). All of the below functions must be called before writing,
// otherwise this data will be left uninitialized.
void setVersion(unsigned int ver = 0x3fa66666);
void setType(int type);
@ -56,27 +57,27 @@ class ESMWriter
void close();
///< \note Does not close the stream.
void writeHNString(ESM::NAME name, const std::string& data);
void writeHNString(ESM::NAME name, const std::string& data, size_t size);
void writeHNCString(ESM::NAME name, const std::string& data)
void writeHNString(NAME name, const std::string& data);
void writeHNString(NAME name, const std::string& data, size_t size);
void writeHNCString(NAME name, const std::string& data)
{
startSubRecord(name);
writeHCString(data);
endRecord(name);
}
void writeHNOString(ESM::NAME name, const std::string& data)
void writeHNOString(NAME name, const std::string& data)
{
if (!data.empty())
writeHNString(name, data);
}
void writeHNOCString(ESM::NAME name, const std::string& data)
void writeHNOCString(NAME name, const std::string& data)
{
if (!data.empty())
writeHNCString(name, data);
}
template<typename T>
void writeHNT(ESM::NAME name, const T& data)
void writeHNT(NAME name, const T& data)
{
startSubRecord(name);
writeT(data);
@ -84,7 +85,7 @@ class ESMWriter
}
template<typename T, std::size_t size>
void writeHNT(ESM::NAME name, const T (&data)[size])
void writeHNT(NAME name, const T (&data)[size])
{
startSubRecord(name);
writeT(data);
@ -94,15 +95,15 @@ class ESMWriter
// Prevent using writeHNT with strings. This already happened by accident and results in
// state being discarded without any error on writing or reading it. :(
// writeHNString and friends must be used instead.
void writeHNT(ESM::NAME name, const std::string& data) = delete;
void writeHNT(NAME name, const std::string& data) = delete;
void writeT(ESM::NAME data) = delete;
void writeT(NAME data) = delete;
template<typename T, std::size_t size>
void writeHNT(ESM::NAME name, const T (&data)[size], int) = delete;
void writeHNT(NAME name, const T (&data)[size], int) = delete;
template<typename T>
void writeHNT(ESM::NAME name, const T& data, int size)
void writeHNT(NAME name, const T& data, int size)
{
startSubRecord(name);
writeT(data, size);
@ -129,16 +130,16 @@ class ESMWriter
write((char*)&data, size);
}
void startRecord(ESM::NAME name, uint32_t flags = 0);
void startRecord(NAME name, uint32_t flags = 0);
void startRecord(uint32_t name, uint32_t flags = 0);
/// @note Sub-record hierarchies are not properly supported in ESMReader. This should be fixed later.
void startSubRecord(ESM::NAME name);
void endRecord(ESM::NAME name);
void startSubRecord(NAME name);
void endRecord(NAME name);
void endRecord(uint32_t name);
void writeFixedSizeString(const std::string& data, int size);
void writeHString(const std::string& data);
void writeHCString(const std::string& data);
void writeName(ESM::NAME data);
void writeName(NAME data);
void write(const char* data, size_t size);
private:

@ -4,9 +4,12 @@
#include "esmwriter.hpp"
#include "components/esm/defs.hpp"
unsigned int ESM::Filter::sRecordId = REC_FILT;
namespace ESM
{
unsigned int Filter::sRecordId = REC_FILT;
void ESM::Filter::load (ESMReader& esm, bool &isDeleted)
void Filter::load (ESMReader& esm, bool &isDeleted)
{
isDeleted = false;
mRecordFlags = esm.getRecordFlags();
@ -17,16 +20,16 @@ void ESM::Filter::load (ESMReader& esm, bool &isDeleted)
uint32_t name = esm.retSubName().toInt();
switch (name)
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
break;
case ESM::fourCC("FILT"):
case fourCC("FILT"):
mFilter = esm.getHString();
break;
case ESM::fourCC("DESC"):
case fourCC("DESC"):
mDescription = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;
@ -37,7 +40,7 @@ void ESM::Filter::load (ESMReader& esm, bool &isDeleted)
}
}
void ESM::Filter::save (ESMWriter& esm, bool isDeleted) const
void Filter::save (ESMWriter& esm, bool isDeleted) const
{
esm.writeHNCString ("NAME", mId);
@ -51,8 +54,10 @@ void ESM::Filter::save (ESMWriter& esm, bool isDeleted) const
esm.writeHNCString ("DESC", mDescription);
}
void ESM::Filter::blank()
void Filter::blank()
{
mFilter.clear();
mDescription.clear();
}
}

@ -10,6 +10,10 @@
#include "savedgame.hpp"
namespace ESM
{
namespace
{
void convertFogOfWar(std::vector<char>& imageData)
{
if (imageData.empty())
@ -52,7 +56,9 @@ void convertFogOfWar(std::vector<char>& imageData)
imageData = std::vector<char>(str.begin(), str.end());
}
void ESM::FogState::load (ESMReader &esm)
}
void FogState::load (ESMReader &esm)
{
esm.getHNOT(mBounds, "BOUN");
esm.getHNOT(mNorthMarkerAngle, "ANGL");
@ -76,7 +82,7 @@ void ESM::FogState::load (ESMReader &esm)
}
}
void ESM::FogState::save (ESMWriter &esm, bool interiorCell) const
void FogState::save (ESMWriter &esm, bool interiorCell) const
{
if (interiorCell)
{
@ -92,3 +98,5 @@ void ESM::FogState::save (ESMWriter &esm, bool interiorCell) const
esm.endRecord("FTEX");
}
}
}

@ -4,9 +4,12 @@
#include "esmwriter.hpp"
#include "components/esm/defs.hpp"
unsigned int ESM::GlobalMap::sRecordId = ESM::REC_GMAP;
namespace ESM
{
unsigned int GlobalMap::sRecordId = REC_GMAP;
void ESM::GlobalMap::load (ESMReader &esm)
void GlobalMap::load (ESMReader &esm)
{
esm.getHNT(mBounds, "BNDS");
@ -25,7 +28,7 @@ void ESM::GlobalMap::load (ESMReader &esm)
}
}
void ESM::GlobalMap::save (ESMWriter &esm) const
void GlobalMap::save (ESMWriter &esm) const
{
esm.writeHNT("BNDS", mBounds);
@ -41,3 +44,5 @@ void ESM::GlobalMap::save (ESMWriter &esm) const
esm.endRecord("MRK_");
}
}
}

@ -3,7 +3,10 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
void ESM::GlobalScript::load (ESMReader &esm)
namespace ESM
{
void GlobalScript::load (ESMReader &esm)
{
mId = esm.getHNString ("NAME");
@ -18,7 +21,7 @@ void ESM::GlobalScript::load (ESMReader &esm)
mTargetRef.load(esm, true, "FRMR");
}
void ESM::GlobalScript::save (ESMWriter &esm) const
void GlobalScript::save (ESMWriter &esm) const
{
esm.writeHNString ("NAME", mId);
@ -34,3 +37,5 @@ void ESM::GlobalScript::save (ESMWriter &esm) const
mTargetRef.save (esm, true, "FRMR");
}
}
}

@ -5,7 +5,10 @@
#include <components/misc/stringops.hpp>
void ESM::InventoryState::load (ESMReader &esm)
namespace ESM
{
void InventoryState::load (ESMReader &esm)
{
// obsolete
int index = 0;
@ -123,7 +126,7 @@ void ESM::InventoryState::load (ESMReader &esm)
}
}
void ESM::InventoryState::save (ESMWriter &esm) const
void InventoryState::save (ESMWriter &esm) const
{
int itemsCount = static_cast<int>(mItems.size());
if (itemsCount > 0)
@ -170,3 +173,5 @@ void ESM::InventoryState::save (ESMWriter &esm) const
if (mSelectedEnchantItem != -1)
esm.writeHNT ("SELE", mSelectedEnchantItem);
}
}

@ -3,7 +3,10 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
void ESM::JournalEntry::load (ESMReader &esm)
namespace ESM
{
void JournalEntry::load (ESMReader &esm)
{
esm.getHNOT (mType, "JETY");
mTopic = esm.getHNString ("YETO");
@ -20,7 +23,7 @@ void ESM::JournalEntry::load (ESMReader &esm)
mActorName = esm.getHNOString("ACT_");
}
void ESM::JournalEntry::save (ESMWriter &esm) const
void JournalEntry::save (ESMWriter &esm) const
{
esm.writeHNT ("JETY", mType);
esm.writeHNString ("YETO", mTopic);
@ -36,3 +39,5 @@ void ESM::JournalEntry::save (ESMWriter &esm) const
else if (mType==Type_Topic)
esm.writeHNString ("ACT_", mActorName);
}
}

@ -19,20 +19,20 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -22,30 +22,30 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("TEXT"): // not ITEX here for some reason
case fourCC("TEXT"): // not ITEX here for some reason
mIcon = esm.getHString();
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("ALDT"):
case fourCC("ALDT"):
esm.getHTSized<12>(mData);
hasData = true;
break;
case ESM::fourCC("ENAM"):
case fourCC("ENAM"):
mEffects.add(esm);
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -20,27 +20,27 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("AADT"):
case fourCC("AADT"):
esm.getHT(mData);
hasData = true;
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("ITEX"):
case fourCC("ITEX"):
mIcon = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -52,33 +52,33 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("AODT"):
case fourCC("AODT"):
esm.getHTSized<24>(mData);
hasData = true;
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("ITEX"):
case fourCC("ITEX"):
mIcon = esm.getHString();
break;
case ESM::fourCC("ENAM"):
case fourCC("ENAM"):
mEnchant = esm.getHString();
break;
case ESM::fourCC("INDX"):
case fourCC("INDX"):
mParts.add(esm);
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -20,21 +20,21 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mRace = esm.getHString();
break;
case ESM::fourCC("BYDT"):
case fourCC("BYDT"):
esm.getHTSized<4>(mData);
hasData = true;
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -20,33 +20,33 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("BKDT"):
case fourCC("BKDT"):
esm.getHTSized<20>(mData);
hasData = true;
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("ITEX"):
case fourCC("ITEX"):
mIcon = esm.getHString();
break;
case ESM::fourCC("ENAM"):
case fourCC("ENAM"):
mEnchant = esm.getHString();
break;
case ESM::fourCC("TEXT"):
case fourCC("TEXT"):
mText = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -21,23 +21,23 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("TNAM"):
case fourCC("TNAM"):
mTexture = esm.getHString();
break;
case ESM::fourCC("DESC"):
case fourCC("DESC"):
mDescription = esm.getHString();
break;
case ESM::fourCC("NPCS"):
case fourCC("NPCS"):
mPowers.add(esm);
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -14,10 +14,12 @@
#include "components/esm/defs.hpp"
#include "cellid.hpp"
namespace ESM
{
namespace
{
///< Translate 8bit/24bit code (stored in refNum.mIndex) into a proper refNum
void adjustRefNum (ESM::RefNum& refNum, const ESM::ESMReader& reader)
void adjustRefNum (RefNum& refNum, const ESMReader& reader)
{
unsigned int local = (refNum.mIndex & 0xff000000) >> 24;
@ -37,6 +39,7 @@ namespace
}
}
}
}
namespace ESM
{
@ -72,14 +75,14 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mName = esm.getHString();
break;
case ESM::fourCC("DATA"):
case fourCC("DATA"):
esm.getHTSized<12>(mData);
hasData = true;
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;
@ -97,7 +100,7 @@ namespace ESM
if (mCellId.mPaged)
{
mCellId.mWorldspace = ESM::CellId::sDefaultWorldspace;
mCellId.mWorldspace = CellId::sDefaultWorldspace;
mCellId.mIndex.mX = mData.mX;
mCellId.mIndex.mY = mData.mY;
}
@ -119,13 +122,13 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::fourCC("INTV"):
case fourCC("INTV"):
int waterl;
esm.getHT(waterl);
mWater = static_cast<float>(waterl);
mWaterInt = true;
break;
case ESM::fourCC("WHGT"):
case fourCC("WHGT"):
float waterLevel;
esm.getHT(waterLevel);
mWaterInt = false;
@ -138,17 +141,17 @@ namespace ESM
else
mWater = waterLevel;
break;
case ESM::fourCC("AMBI"):
case fourCC("AMBI"):
esm.getHT(mAmbi);
mHasAmbi = true;
break;
case ESM::fourCC("RGNN"):
case fourCC("RGNN"):
mRegion = esm.getHString();
break;
case ESM::fourCC("NAM5"):
case fourCC("NAM5"):
esm.getHT(mMapColor);
break;
case ESM::fourCC("NAM0"):
case fourCC("NAM0"):
esm.getHT(mRefNumCounter);
break;
default:

@ -50,23 +50,23 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("CLDT"):
case fourCC("CLDT"):
esm.getHTSized<60>(mData);
if (mData.mIsPlayable > 1)
esm.fail("Unknown bool value");
hasData = true;
break;
case ESM::fourCC("DESC"):
case fourCC("DESC"):
mDescription = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -22,33 +22,33 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("CTDT"):
case fourCC("CTDT"):
esm.getHTSized<12>(mData);
hasData = true;
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("ITEX"):
case fourCC("ITEX"):
mIcon = esm.getHString();
break;
case ESM::fourCC("ENAM"):
case fourCC("ENAM"):
mEnchant = esm.getHString();
break;
case ESM::fourCC("INDX"):
case fourCC("INDX"):
mParts.add(esm);
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -44,21 +44,21 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("CNDT"):
case fourCC("CNDT"):
esm.getHTSized<4>(mWeight);
hasWeight = true;
break;
case ESM::fourCC("FLAG"):
case fourCC("FLAG"):
esm.getHTSized<4>(mFlags);
if (mFlags & 0xf4)
esm.fail("Unknown flags");
@ -66,13 +66,13 @@ namespace ESM
esm.fail("Flag 8 not set");
hasFlags = true;
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("NPCO"):
case fourCC("NPCO"):
mInventory.add(esm);
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -6,7 +6,8 @@
#include "esmwriter.hpp"
#include "components/esm/defs.hpp"
namespace ESM {
namespace ESM
{
unsigned int Creature::sRecordId = REC_CREA;
@ -33,47 +34,47 @@ namespace ESM {
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("CNAM"):
case fourCC("CNAM"):
mOriginal = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("NPDT"):
case fourCC("NPDT"):
esm.getHTSized<96>(mData);
hasNpdt = true;
break;
case ESM::fourCC("FLAG"):
case fourCC("FLAG"):
int flags;
esm.getHT(flags);
mFlags = flags & 0xFF;
mBloodType = ((flags >> 8) & 0xFF) >> 2;
hasFlags = true;
break;
case ESM::fourCC("XSCL"):
case fourCC("XSCL"):
esm.getHT(mScale);
break;
case ESM::fourCC("NPCO"):
case fourCC("NPCO"):
mInventory.add(esm);
break;
case ESM::fourCC("NPCS"):
case fourCC("NPCS"):
mSpells.add(esm);
break;
case ESM::fourCC("AIDT"):
case fourCC("AIDT"):
esm.getHExact(&mAiData, sizeof(mAiData));
break;
case ESM::fourCC("DODT"):
case ESM::fourCC("DNAM"):
case fourCC("DODT"):
case fourCC("DNAM"):
mTransport.add(esm);
break;
case AI_Wander:
@ -84,11 +85,11 @@ namespace ESM {
case AI_CNDT:
mAiPackage.add(esm);
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;
case ESM::fourCC("INDX"):
case fourCC("INDX"):
// seems to occur only in .ESS files, unsure of purpose
int index;
esm.getHT(index);

@ -30,7 +30,7 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::fourCC("DATA"):
case fourCC("DATA"):
{
esm.getSubHeader();
int size = esm.getSubSize();
@ -44,7 +44,7 @@ namespace ESM
}
break;
}
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
mType = Unknown;
isDeleted = true;
@ -76,7 +76,7 @@ namespace ESM
void Dialogue::readInfo(ESMReader &esm, bool merge)
{
ESM::DialInfo info;
DialInfo info;
bool isDeleted = false;
info.load(esm, isDeleted);

@ -61,7 +61,7 @@ struct Dialogue
/// Read the next info record
/// @param merge Merge with existing list, or just push each record to the end of the list?
void readInfo (ESM::ESMReader& esm, bool merge);
void readInfo (ESMReader& esm, bool merge);
void blank();
///< Set record to default state (does not touch the ID and does not change the type).

@ -19,26 +19,26 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("SNAM"):
case fourCC("SNAM"):
mOpenSound = esm.getHString();
break;
case ESM::fourCC("ANAM"):
case fourCC("ANAM"):
mCloseSound = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -21,18 +21,18 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("ENDT"):
case fourCC("ENDT"):
esm.getHTSized<16>(mData);
hasData = true;
break;
case ESM::fourCC("ENAM"):
case fourCC("ENAM"):
mEffects.add(esm);
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -43,25 +43,25 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("RNAM"):
case fourCC("RNAM"):
if (rankCounter >= 10)
esm.fail("Rank out of range");
mRanks[rankCounter++] = esm.getHString();
break;
case ESM::fourCC("FADT"):
case fourCC("FADT"):
esm.getHTSized<240>(mData);
if (mData.mIsHidden > 1)
esm.fail("Unknown flag!");
hasData = true;
break;
case ESM::fourCC("ANAM"):
case fourCC("ANAM"):
{
std::string faction = esm.getHString();
int reaction;
@ -69,7 +69,7 @@ namespace ESM
mReactions[faction] = reaction;
break;
}
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -45,7 +45,7 @@ struct Faction
RankData mRankData[10];
int mSkills[7]; // IDs of skills this faction require
// Each element will either contain an ESM::Skill index, or -1.
// Each element will either contain an Skill index, or -1.
int mIsHidden; // 1 - hidden from player

@ -22,7 +22,7 @@ namespace ESM
}
else
{
mValue.read (esm, ESM::Variant::Format_Global);
mValue.read (esm, Variant::Format_Global);
}
}
@ -36,13 +36,13 @@ namespace ESM
}
else
{
mValue.write (esm, ESM::Variant::Format_Global);
mValue.write (esm, Variant::Format_Global);
}
}
void Global::blank()
{
mValue.setType (ESM::VT_None);
mValue.setType (VT_None);
}
bool operator== (const Global& left, const Global& right)

@ -14,18 +14,18 @@ namespace ESM
mRecordFlags = esm.getRecordFlags();
mId = esm.getHNString("NAME");
mValue.read (esm, ESM::Variant::Format_Gmst);
mValue.read (esm, Variant::Format_Gmst);
}
void GameSetting::save (ESMWriter &esm, bool /*isDeleted*/) const
{
esm.writeHNCString("NAME", mId);
mValue.write (esm, ESM::Variant::Format_Gmst);
mValue.write (esm, Variant::Format_Gmst);
}
void GameSetting::blank()
{
mValue.setType (ESM::VT_None);
mValue.setType (VT_None);
}
bool operator== (const GameSetting& left, const GameSetting& right)

@ -25,19 +25,19 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::fourCC("DATA"):
case fourCC("DATA"):
esm.getHTSized<12>(mData);
break;
case ESM::fourCC("ONAM"):
case fourCC("ONAM"):
mActor = esm.getHString();
break;
case ESM::fourCC("RNAM"):
case fourCC("RNAM"):
mRace = esm.getHString();
break;
case ESM::fourCC("CNAM"):
case fourCC("CNAM"):
mClass = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
{
mFaction = esm.getHString();
if (mFaction == "FFFF")
@ -46,19 +46,19 @@ namespace ESM
}
break;
}
case ESM::fourCC("ANAM"):
case fourCC("ANAM"):
mCell = esm.getHString();
break;
case ESM::fourCC("DNAM"):
case fourCC("DNAM"):
mPcFaction = esm.getHString();
break;
case ESM::fourCC("SNAM"):
case fourCC("SNAM"):
mSound = esm.getHString();
break;
case ESM::SREC_NAME:
case SREC_NAME:
mResponse = esm.getHString();
break;
case ESM::fourCC("SCVR"):
case fourCC("SCVR"):
{
SelectStruct ss;
ss.mSelectRule = esm.getHString();
@ -66,22 +66,22 @@ namespace ESM
mSelects.push_back(ss);
break;
}
case ESM::fourCC("BNAM"):
case fourCC("BNAM"):
mResultScript = esm.getHString();
break;
case ESM::fourCC("QSTN"):
case fourCC("QSTN"):
mQuestStatus = QS_Name;
esm.skipRecord();
break;
case ESM::fourCC("QSTF"):
case fourCC("QSTF"):
mQuestStatus = QS_Finished;
esm.skipRecord();
break;
case ESM::fourCC("QSTR"):
case fourCC("QSTR"):
mQuestStatus = QS_Restart;
esm.skipRecord();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -20,27 +20,27 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("IRDT"):
case fourCC("IRDT"):
esm.getHTSized<56>(mData);
hasData = true;
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("ITEX"):
case fourCC("ITEX"):
mIcon = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -46,7 +46,7 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::fourCC("INTV"):
case fourCC("INTV"):
esm.getSubHeader();
if (esm.getSubSize() != 8)
esm.fail("Subrecord size is not equal to 8");
@ -54,10 +54,10 @@ namespace ESM
esm.getT<int>(mY);
hasLocation = true;
break;
case ESM::fourCC("DATA"):
case fourCC("DATA"):
esm.getHT(mFlags);
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;
@ -82,23 +82,23 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::fourCC("VNML"):
case fourCC("VNML"):
esm.skipHSub();
mDataTypes |= DATA_VNML;
break;
case ESM::fourCC("VHGT"):
case fourCC("VHGT"):
esm.skipHSub();
mDataTypes |= DATA_VHGT;
break;
case ESM::fourCC("WNAM"):
case fourCC("WNAM"):
esm.getHExact(mWnam, sizeof(mWnam));
mDataTypes |= DATA_WNAM;
break;
case ESM::fourCC("VCLR"):
case fourCC("VCLR"):
esm.skipHSub();
mDataTypes |= DATA_VCLR;
break;
case ESM::fourCC("VTEX"):
case fourCC("VTEX"):
esm.skipHSub();
mDataTypes |= DATA_VTEX;
break;
@ -162,12 +162,12 @@ namespace ESM
signed char wnam[LAND_GLOBAL_MAP_LOD_SIZE];
constexpr float max = std::numeric_limits<signed char>::max();
constexpr float min = std::numeric_limits<signed char>::min();
constexpr float vertMult = static_cast<float>(ESM::Land::LAND_SIZE - 1) / LAND_GLOBAL_MAP_LOD_SIZE_SQRT;
constexpr float vertMult = static_cast<float>(Land::LAND_SIZE - 1) / LAND_GLOBAL_MAP_LOD_SIZE_SQRT;
for (int row = 0; row < LAND_GLOBAL_MAP_LOD_SIZE_SQRT; ++row)
{
for (int col = 0; col < LAND_GLOBAL_MAP_LOD_SIZE_SQRT; ++col)
{
float height = mLandData->mHeights[int(row * vertMult) * ESM::Land::LAND_SIZE + int(col * vertMult)];
float height = mLandData->mHeights[int(row * vertMult) * Land::LAND_SIZE + int(col * vertMult)];
height /= height > 0 ? 128.f : 16.f;
height = std::clamp(height, min, max);
wnam[row * LAND_GLOBAL_MAP_LOD_SIZE_SQRT + col] = static_cast<signed char>(height);
@ -246,7 +246,7 @@ namespace ESM
return;
}
ESM::ESMReader reader;
ESMReader reader;
reader.restoreContext(mContext);
if (reader.isNextSub("VNML")) {
@ -306,7 +306,7 @@ namespace ESM
}
}
bool Land::condLoad(ESM::ESMReader& reader, int flags, int& targetFlags, int dataFlag, void *ptr, unsigned int size) const
bool Land::condLoad(ESMReader& reader, int flags, int& targetFlags, int dataFlag, void *ptr, unsigned int size) const
{
if ((targetFlags & dataFlag) == 0 && (flags & dataFlag) != 0) {
reader.getHExact(ptr, size);

@ -109,7 +109,7 @@ struct Land
// 24-bit normals, these aren't always correct though. Edge and corner normals may be garbage.
VNML mNormals[LAND_NUM_VERTS * 3];
// 2D array of texture indices. An index can be used to look up an ESM::LandTexture,
// 2D array of texture indices. An index can be used to look up an LandTexture,
// but to do so you must subtract 1 from the index first!
// An index of 0 indicates the default texture.
uint16_t mTextures[LAND_NUM_TEXTURES];
@ -179,7 +179,7 @@ struct Land
/// Loads data and marks it as loaded
/// \return true if data is actually loaded from file, false otherwise
/// including the case when data is already loaded
bool condLoad(ESM::ESMReader& reader, int flags, int& targetFlags, int dataFlag, void *ptr, unsigned int size) const;
bool condLoad(ESMReader& reader, int flags, int& targetFlags, int dataFlag, void *ptr, unsigned int size) const;
mutable LandData *mLandData;
};

@ -6,7 +6,7 @@
namespace ESM
{
void LevelledListBase::load(ESMReader& esm, ESM::NAME recName, bool& isDeleted)
void LevelledListBase::load(ESMReader& esm, NAME recName, bool& isDeleted)
{
isDeleted = false;
mRecordFlags = esm.getRecordFlags();
@ -18,17 +18,17 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("DATA"):
case fourCC("DATA"):
esm.getHT(mFlags);
break;
case ESM::fourCC("NNAM"):
case fourCC("NNAM"):
esm.getHT(mChanceNone);
break;
case ESM::fourCC("INDX"):
case fourCC("INDX"):
{
int length = 0;
esm.getHT(length);
@ -50,7 +50,7 @@ namespace ESM
hasList = true;
break;
}
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;
@ -75,7 +75,7 @@ namespace ESM
esm.fail("Missing NAME subrecord");
}
void LevelledListBase::save(ESMWriter& esm, ESM::NAME recName, bool isDeleted) const
void LevelledListBase::save(ESMWriter& esm, NAME recName, bool isDeleted) const
{
esm.writeHNCString("NAME", mId);

@ -36,8 +36,8 @@ struct LevelledListBase
std::vector<LevelItem> mList;
void load(ESMReader& esm, ESM::NAME recName, bool& isDeleted);
void save(ESMWriter& esm, ESM::NAME recName, bool isDeleted) const;
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).
@ -53,7 +53,7 @@ struct CustomLevelledListBase : LevelledListBase
struct CreatureLevList : CustomLevelledListBase<CreatureLevList>
{
/// Record name used to read references.
static constexpr ESM::NAME sRecName {"CNAM"};
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"; }
@ -70,7 +70,7 @@ struct CreatureLevList : CustomLevelledListBase<CreatureLevList>
struct ItemLevList : CustomLevelledListBase<ItemLevList>
{
/// Record name used to read references.
static constexpr ESM::NAME sRecName {"INAM"};
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"; }

@ -20,30 +20,30 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("ITEX"):
case fourCC("ITEX"):
mIcon = esm.getHString();
break;
case ESM::fourCC("LHDT"):
case fourCC("LHDT"):
esm.getHTSized<24>(mData);
hasData = true;
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("SNAM"):
case fourCC("SNAM"):
mSound = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -20,27 +20,27 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("LKDT"):
case fourCC("LKDT"):
esm.getHTSized<16>(mData);
hasData = true;
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("ITEX"):
case fourCC("ITEX"):
mIcon = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -19,18 +19,18 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("INTV"):
case fourCC("INTV"):
esm.getHT(mIndex);
hasIndex = true;
break;
case ESM::fourCC("DATA"):
case fourCC("DATA"):
mTexture = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -6,9 +6,11 @@
#include "esmwriter.hpp"
#include "components/esm/defs.hpp"
namespace ESM
{
namespace
{
static const char *sIds[ESM::MagicEffect::Length] =
static const char *sIds[MagicEffect::Length] =
{
"WaterBreathing",
"SwiftSwim",
@ -181,6 +183,7 @@ namespace
0x11c8, 0x1048, 0x1048, 0x1048, 0x1048, 0x1048, 0x1048
};
}
}
namespace ESM
{
@ -211,37 +214,37 @@ void MagicEffect::load(ESMReader &esm, bool &isDeleted)
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::fourCC("ITEX"):
case fourCC("ITEX"):
mIcon = esm.getHString();
break;
case ESM::fourCC("PTEX"):
case fourCC("PTEX"):
mParticle = esm.getHString();
break;
case ESM::fourCC("BSND"):
case fourCC("BSND"):
mBoltSound = esm.getHString();
break;
case ESM::fourCC("CSND"):
case fourCC("CSND"):
mCastSound = esm.getHString();
break;
case ESM::fourCC("HSND"):
case fourCC("HSND"):
mHitSound = esm.getHString();
break;
case ESM::fourCC("ASND"):
case fourCC("ASND"):
mAreaSound = esm.getHString();
break;
case ESM::fourCC("CVFX"):
case fourCC("CVFX"):
mCasting = esm.getHString();
break;
case ESM::fourCC("BVFX"):
case fourCC("BVFX"):
mBolt = esm.getHString();
break;
case ESM::fourCC("HVFX"):
case fourCC("HVFX"):
mHit = esm.getHString();
break;
case ESM::fourCC("AVFX"):
case fourCC("AVFX"):
mArea = esm.getHString();
break;
case ESM::fourCC("DESC"):
case fourCC("DESC"):
mDescription = esm.getHString();
break;
default:

@ -83,8 +83,8 @@ struct MagicEffect
MEDTstruct mData;
std::string mIcon, mParticle; // Textures
std::string mCasting, mHit, mArea; // ESM::Static
std::string mBolt; // ESM::Weapon
std::string mCasting, mHit, mArea; // Static
std::string mBolt; // Weapon
std::string mCastSound, mBoltSound, mHitSound, mAreaSound; // Sounds
std::string mDescription;

@ -20,27 +20,27 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("MCDT"):
case fourCC("MCDT"):
esm.getHTSized<12>(mData);
hasData = true;
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("ITEX"):
case fourCC("ITEX"):
mIcon = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -28,35 +28,35 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("RNAM"):
case fourCC("RNAM"):
mRace = esm.getHString();
break;
case ESM::fourCC("CNAM"):
case fourCC("CNAM"):
mClass = esm.getHString();
break;
case ESM::fourCC("ANAM"):
case fourCC("ANAM"):
mFaction = esm.getHString();
break;
case ESM::fourCC("BNAM"):
case fourCC("BNAM"):
mHead = esm.getHString();
break;
case ESM::fourCC("KNAM"):
case fourCC("KNAM"):
mHair = esm.getHString();
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("NPDT"):
case fourCC("NPDT"):
hasNpdt = true;
esm.getSubHeader();
if (esm.getSubSize() == 52)
@ -83,24 +83,24 @@ namespace ESM
else
esm.fail("NPC_NPDT must be 12 or 52 bytes long");
break;
case ESM::fourCC("FLAG"):
case fourCC("FLAG"):
hasFlags = true;
int flags;
esm.getHT(flags);
mFlags = flags & 0xFF;
mBloodType = ((flags >> 8) & 0xFF) >> 2;
break;
case ESM::fourCC("NPCS"):
case fourCC("NPCS"):
mSpells.add(esm);
break;
case ESM::fourCC("NPCO"):
case fourCC("NPCO"):
mInventory.add(esm);
break;
case ESM::fourCC("AIDT"):
case fourCC("AIDT"):
esm.getHExact(&mAiData, sizeof(mAiData));
break;
case ESM::fourCC("DODT"):
case ESM::fourCC("DNAM"):
case fourCC("DODT"):
case fourCC("DNAM"):
mTransport.add(esm);
break;
case AI_Wander:
@ -111,7 +111,7 @@ namespace ESM
case AI_CNDT:
mAiPackage.add(esm);
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -11,7 +11,8 @@
#include "loadskil.hpp"
#include "transport.hpp"
namespace ESM {
namespace ESM
{
class ESMReader;
class ESMWriter;

@ -48,14 +48,14 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mCell = esm.getHString();
break;
case ESM::fourCC("DATA"):
case fourCC("DATA"):
esm.getHTSized<12>(mData);
hasData = true;
break;
case ESM::fourCC("PGRP"):
case fourCC("PGRP"):
{
esm.getSubHeader();
int size = esm.getSubSize();
@ -76,7 +76,7 @@ namespace ESM
}
break;
}
case ESM::fourCC("PGRC"):
case fourCC("PGRC"):
{
esm.getSubHeader();
int size = esm.getSubSize();
@ -113,7 +113,7 @@ namespace ESM
}
break;
}
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -20,27 +20,27 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("PBDT"):
case fourCC("PBDT"):
esm.getHTSized<16>(mData);
hasData = true;
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("ITEX"):
case fourCC("ITEX"):
mIcon = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -32,24 +32,24 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("RADT"):
case fourCC("RADT"):
esm.getHTSized<140>(mData);
hasData = true;
break;
case ESM::fourCC("DESC"):
case fourCC("DESC"):
mDescription = esm.getHString();
break;
case ESM::fourCC("NPCS"):
case fourCC("NPCS"):
mPowers.add(esm);
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -19,14 +19,14 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("WEAT"):
case fourCC("WEAT"):
{
esm.getSubHeader();
if (esm.getVer() == VER_12)
@ -55,13 +55,13 @@ namespace ESM
}
break;
}
case ESM::fourCC("BNAM"):
case fourCC("BNAM"):
mSleepList = esm.getHString();
break;
case ESM::fourCC("CNAM"):
case fourCC("CNAM"):
esm.getHT(mMapColor);
break;
case ESM::fourCC("SNAM"):
case fourCC("SNAM"):
{
esm.getSubHeader();
SoundRef sr;
@ -70,7 +70,7 @@ namespace ESM
mSoundList.push_back(sr);
break;
}
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -20,27 +20,27 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("RIDT"):
case fourCC("RIDT"):
esm.getHTSized<16>(mData);
hasData = true;
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("ITEX"):
case fourCC("ITEX"):
mIcon = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -95,7 +95,7 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::fourCC("SCHD"):
case fourCC("SCHD"):
{
esm.getSubHeader();
mId = esm.getString(32);
@ -104,11 +104,11 @@ namespace ESM
hasHeader = true;
break;
}
case ESM::fourCC("SCVR"):
case fourCC("SCVR"):
// list of local variables
loadSCVR(esm);
break;
case ESM::fourCC("SCDT"):
case fourCC("SCDT"):
{
// compiled script
esm.getSubHeader();
@ -127,10 +127,10 @@ namespace ESM
esm.getExact(mScriptData.data(), mScriptData.size());
break;
}
case ESM::fourCC("SCTX"):
case fourCC("SCTX"):
mScriptText = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -139,15 +139,15 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::fourCC("INDX"):
case fourCC("INDX"):
esm.getHT(mIndex);
hasIndex = true;
break;
case ESM::fourCC("SKDT"):
case fourCC("SKDT"):
esm.getHTSized<24>(mData);
hasData = true;
break;
case ESM::fourCC("DESC"):
case fourCC("DESC"):
mDescription = esm.getHString();
break;
default:

@ -6,7 +6,8 @@
#include "components/esm/defs.hpp"
namespace ESM {
namespace ESM
{
class ESMReader;
class ESMWriter;

@ -20,21 +20,21 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("DATA"):
case fourCC("DATA"):
esm.getHTSized<4>(mType);
hasData = true;
break;
case ESM::fourCC("CNAM"):
case fourCC("CNAM"):
mCreature = esm.getHString();
break;
case ESM::fourCC("SNAM"):
case fourCC("SNAM"):
mSound = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -20,18 +20,18 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mSound = esm.getHString();
break;
case ESM::fourCC("DATA"):
case fourCC("DATA"):
esm.getHTSized<3>(mData);
hasData = true;
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -22,23 +22,23 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("SPDT"):
case fourCC("SPDT"):
esm.getHTSized<12>(mData);
hasData = true;
break;
case ESM::fourCC("ENAM"):
case fourCC("ENAM"):
ENAMstruct s;
esm.getHTSized<24>(s);
mEffects.mList.push_back(s);
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -20,15 +20,15 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("DATA"):
case fourCC("DATA"):
mData = esm.getHString();
hasData = true;
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -12,8 +12,8 @@ namespace ESM
{
isDeleted = false;
mRecordFlags = esm.getRecordFlags();
//bool isBlocked = (mRecordFlags & ESM::FLAG_Blocked) != 0;
//bool isPersistent = (mRecordFlags & ESM::FLAG_Persistent) != 0;
//bool isBlocked = (mRecordFlags & FLAG_Blocked) != 0;
//bool isPersistent = (mRecordFlags & FLAG_Persistent) != 0;
bool hasName = false;
while (esm.hasMoreSubs())
@ -21,14 +21,14 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -3,7 +3,8 @@
#include <string>
namespace ESM {
namespace ESM
{
class ESMReader;
class ESMWriter;

@ -5,9 +5,12 @@
#include "esmwriter.hpp"
#include "components/esm/defs.hpp"
void ESM::Header::blank()
namespace ESM
{
mData.version = ESM::VER_13;
void Header::blank()
{
mData.version = VER_13;
mData.type = 0;
mData.author.clear();
mData.desc.clear();
@ -16,7 +19,7 @@ void ESM::Header::blank()
mMaster.clear();
}
void ESM::Header::load (ESMReader &esm)
void Header::load (ESMReader &esm)
{
if (esm.isNextSub ("FORM"))
{
@ -65,7 +68,7 @@ void ESM::Header::load (ESMReader &esm)
}
}
void ESM::Header::save (ESMWriter &esm)
void Header::save (ESMWriter &esm)
{
if (mFormat>0)
esm.writeHNT ("FORM", mFormat);
@ -84,3 +87,5 @@ void ESM::Header::save (ESMWriter &esm)
esm.writeHNT ("DATA", data.size);
}
}
}

@ -20,30 +20,30 @@ namespace ESM
esm.getSubName();
switch (esm.retSubName().toInt())
{
case ESM::SREC_NAME:
case SREC_NAME:
mId = esm.getHString();
hasName = true;
break;
case ESM::fourCC("MODL"):
case fourCC("MODL"):
mModel = esm.getHString();
break;
case ESM::fourCC("FNAM"):
case fourCC("FNAM"):
mName = esm.getHString();
break;
case ESM::fourCC("WPDT"):
case fourCC("WPDT"):
esm.getHTSized<32>(mData);
hasData = true;
break;
case ESM::fourCC("SCRI"):
case fourCC("SCRI"):
mScript = esm.getHString();
break;
case ESM::fourCC("ITEX"):
case fourCC("ITEX"):
mIcon = esm.getHString();
break;
case ESM::fourCC("ENAM"):
case fourCC("ENAM"):
mEnchant = esm.getHString();
break;
case ESM::SREC_DELE:
case SREC_DELE:
esm.skipHSub();
isDeleted = true;
break;

@ -105,7 +105,7 @@ struct WeaponType
std::string mSoundId;
std::string mAttachBone;
std::string mSheathingBone;
ESM::Skill::SkillEnum mSkill;
Skill::SkillEnum mSkill;
Class mWeaponClass;
int mAmmoType;
int mFlags;

@ -3,7 +3,10 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
void ESM::Locals::load (ESMReader &esm)
namespace ESM
{
void Locals::load (ESMReader &esm)
{
while (esm.isNextSub ("LOCA"))
{
@ -16,7 +19,7 @@ void ESM::Locals::load (ESMReader &esm)
}
}
void ESM::Locals::save (ESMWriter &esm) const
void Locals::save (ESMWriter &esm) const
{
for (std::vector<std::pair<std::string, Variant> >::const_iterator iter (mVariables.begin());
iter!=mVariables.end(); ++iter)
@ -25,3 +28,5 @@ void ESM::Locals::save (ESMWriter &esm) const
iter->second.write (esm, Variant::Format_Local);
}
}
}

@ -4,128 +4,128 @@
namespace ESM
{
ESM::BodyPart::MeshPart getMeshPart(ESM::PartReferenceType type)
BodyPart::MeshPart getMeshPart(PartReferenceType type)
{
switch(type)
{
case ESM::PRT_Head:
return ESM::BodyPart::MP_Head;
case ESM::PRT_Hair:
return ESM::BodyPart::MP_Hair;
case ESM::PRT_Neck:
return ESM::BodyPart::MP_Neck;
case ESM::PRT_Cuirass:
return ESM::BodyPart::MP_Chest;
case ESM::PRT_Groin:
return ESM::BodyPart::MP_Groin;
case ESM::PRT_RHand:
return ESM::BodyPart::MP_Hand;
case ESM::PRT_LHand:
return ESM::BodyPart::MP_Hand;
case ESM::PRT_RWrist:
return ESM::BodyPart::MP_Wrist;
case ESM::PRT_LWrist:
return ESM::BodyPart::MP_Wrist;
case ESM::PRT_RForearm:
return ESM::BodyPart::MP_Forearm;
case ESM::PRT_LForearm:
return ESM::BodyPart::MP_Forearm;
case ESM::PRT_RUpperarm:
return ESM::BodyPart::MP_Upperarm;
case ESM::PRT_LUpperarm:
return ESM::BodyPart::MP_Upperarm;
case ESM::PRT_RFoot:
return ESM::BodyPart::MP_Foot;
case ESM::PRT_LFoot:
return ESM::BodyPart::MP_Foot;
case ESM::PRT_RAnkle:
return ESM::BodyPart::MP_Ankle;
case ESM::PRT_LAnkle:
return ESM::BodyPart::MP_Ankle;
case ESM::PRT_RKnee:
return ESM::BodyPart::MP_Knee;
case ESM::PRT_LKnee:
return ESM::BodyPart::MP_Knee;
case ESM::PRT_RLeg:
return ESM::BodyPart::MP_Upperleg;
case ESM::PRT_LLeg:
return ESM::BodyPart::MP_Upperleg;
case ESM::PRT_Tail:
return ESM::BodyPart::MP_Tail;
case PRT_Head:
return BodyPart::MP_Head;
case PRT_Hair:
return BodyPart::MP_Hair;
case PRT_Neck:
return BodyPart::MP_Neck;
case PRT_Cuirass:
return BodyPart::MP_Chest;
case PRT_Groin:
return BodyPart::MP_Groin;
case PRT_RHand:
return BodyPart::MP_Hand;
case PRT_LHand:
return BodyPart::MP_Hand;
case PRT_RWrist:
return BodyPart::MP_Wrist;
case PRT_LWrist:
return BodyPart::MP_Wrist;
case PRT_RForearm:
return BodyPart::MP_Forearm;
case PRT_LForearm:
return BodyPart::MP_Forearm;
case PRT_RUpperarm:
return BodyPart::MP_Upperarm;
case PRT_LUpperarm:
return BodyPart::MP_Upperarm;
case PRT_RFoot:
return BodyPart::MP_Foot;
case PRT_LFoot:
return BodyPart::MP_Foot;
case PRT_RAnkle:
return BodyPart::MP_Ankle;
case PRT_LAnkle:
return BodyPart::MP_Ankle;
case PRT_RKnee:
return BodyPart::MP_Knee;
case PRT_LKnee:
return BodyPart::MP_Knee;
case PRT_RLeg:
return BodyPart::MP_Upperleg;
case PRT_LLeg:
return BodyPart::MP_Upperleg;
case PRT_Tail:
return BodyPart::MP_Tail;
default:
throw std::runtime_error("PartReferenceType " +
std::to_string(type) + " not associated with a mesh part");
}
}
std::string getBoneName(ESM::PartReferenceType type)
std::string getBoneName(PartReferenceType type)
{
switch(type)
{
case ESM::PRT_Head:
case PRT_Head:
return "head";
case ESM::PRT_Hair:
case PRT_Hair:
return "head"; // This is purposeful.
case ESM::PRT_Neck:
case PRT_Neck:
return "neck";
case ESM::PRT_Cuirass:
case PRT_Cuirass:
return "chest";
case ESM::PRT_Groin:
case PRT_Groin:
return "groin";
case ESM::PRT_Skirt:
case PRT_Skirt:
return "groin";
case ESM::PRT_RHand:
case PRT_RHand:
return "right hand";
case ESM::PRT_LHand:
case PRT_LHand:
return "left hand";
case ESM::PRT_RWrist:
case PRT_RWrist:
return "right wrist";
case ESM::PRT_LWrist:
case PRT_LWrist:
return "left wrist";
case ESM::PRT_Shield:
case PRT_Shield:
return "shield bone";
case ESM::PRT_RForearm:
case PRT_RForearm:
return "right forearm";
case ESM::PRT_LForearm:
case PRT_LForearm:
return "left forearm";
case ESM::PRT_RUpperarm:
case PRT_RUpperarm:
return "right upper arm";
case ESM::PRT_LUpperarm:
case PRT_LUpperarm:
return "left upper arm";
case ESM::PRT_RFoot:
case PRT_RFoot:
return "right foot";
case ESM::PRT_LFoot:
case PRT_LFoot:
return "left foot";
case ESM::PRT_RAnkle:
case PRT_RAnkle:
return "right ankle";
case ESM::PRT_LAnkle:
case PRT_LAnkle:
return "left ankle";
case ESM::PRT_RKnee:
case PRT_RKnee:
return "right knee";
case ESM::PRT_LKnee:
case PRT_LKnee:
return "left knee";
case ESM::PRT_RLeg:
case PRT_RLeg:
return "right upper leg";
case ESM::PRT_LLeg:
case PRT_LLeg:
return "left upper leg";
case ESM::PRT_RPauldron:
case PRT_RPauldron:
return "right clavicle";
case ESM::PRT_LPauldron:
case PRT_LPauldron:
return "left clavicle";
case ESM::PRT_Weapon:
case PRT_Weapon:
return "weapon bone";
case ESM::PRT_Tail:
case PRT_Tail:
return "tail";
default:
throw std::runtime_error("unknown PartReferenceType");
}
}
std::string getMeshFilter(ESM::PartReferenceType type)
std::string getMeshFilter(PartReferenceType type)
{
switch(type)
{
case ESM::PRT_Hair:
case PRT_Hair:
return "hair";
default:
return getBoneName(type);

@ -8,9 +8,9 @@
namespace ESM
{
ESM::BodyPart::MeshPart getMeshPart(ESM::PartReferenceType type);
std::string getBoneName(ESM::PartReferenceType type);
std::string getMeshFilter(ESM::PartReferenceType type);
BodyPart::MeshPart getMeshPart(PartReferenceType type);
std::string getBoneName(PartReferenceType type);
std::string getMeshFilter(PartReferenceType type);
}
#endif

@ -1,6 +1,9 @@
#include "npcstate.hpp"
void ESM::NpcState::load (ESMReader &esm)
namespace ESM
{
void NpcState::load (ESMReader &esm)
{
ObjectState::load (esm);
@ -14,7 +17,7 @@ void ESM::NpcState::load (ESMReader &esm)
}
}
void ESM::NpcState::save (ESMWriter &esm, bool inInventory) const
void NpcState::save (ESMWriter &esm, bool inInventory) const
{
ObjectState::save (esm, inInventory);
@ -28,10 +31,12 @@ void ESM::NpcState::save (ESMWriter &esm, bool inInventory) const
}
}
void ESM::NpcState::blank()
void NpcState::blank()
{
ObjectState::blank();
mNpcStats.blank();
mCreatureStats.blank();
mHasCustomState = true;
}
}

@ -5,9 +5,12 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
ESM::NpcStats::Faction::Faction() : mExpelled (false), mRank (-1), mReputation (0) {}
namespace ESM
{
NpcStats::Faction::Faction() : mExpelled (false), mRank (-1), mReputation (0) {}
void ESM::NpcStats::load (ESMReader &esm)
void NpcStats::load (ESMReader &esm)
{
while (esm.isNextSub ("FACT"))
{
@ -41,17 +44,17 @@ void ESM::NpcStats::load (ESMReader &esm)
// we have deprecated werewolf skills, stored interleaved
// Load into one big vector, then remove every 2nd value
mWerewolfDeprecatedData = true;
std::vector<ESM::StatState<float> > skills(mSkills, mSkills + sizeof(mSkills)/sizeof(mSkills[0]));
std::vector<StatState<float> > skills(mSkills, mSkills + sizeof(mSkills)/sizeof(mSkills[0]));
for (int i=0; i<27; ++i)
{
ESM::StatState<float> skill;
StatState<float> skill;
skill.load(esm, intFallback);
skills.push_back(skill);
}
int i=0;
for (std::vector<ESM::StatState<float> >::iterator it = skills.begin(); it != skills.end(); ++i)
for (std::vector<StatState<float> >::iterator it = skills.begin(); it != skills.end(); ++i)
{
if (i%2 == 1)
it = skills.erase(it);
@ -67,7 +70,7 @@ void ESM::NpcStats::load (ESMReader &esm)
esm.getHNOT (hasWerewolfAttributes, "HWAT");
if (hasWerewolfAttributes)
{
ESM::StatState<int> dummy;
StatState<int> dummy;
for (int i=0; i<8; ++i)
dummy.load(esm, intFallback);
mWerewolfDeprecatedData = true;
@ -122,7 +125,7 @@ void ESM::NpcStats::load (ESMReader &esm)
esm.getHNOT (mCrimeId, "CRID");
}
void ESM::NpcStats::save (ESMWriter &esm) const
void NpcStats::save (ESMWriter &esm) const
{
for (std::map<std::string, Faction>::const_iterator iter (mFactions.begin());
iter!=mFactions.end(); ++iter)
@ -191,7 +194,7 @@ void ESM::NpcStats::save (ESMWriter &esm) const
esm.writeHNT ("CRID", mCrimeId);
}
void ESM::NpcStats::blank()
void NpcStats::blank()
{
mWerewolfDeprecatedData = false;
mIsWerewolf = false;
@ -207,3 +210,5 @@ void ESM::NpcStats::blank()
mTimeToStartDrowning = 20;
mCrimeId = -1;
}
}

@ -8,7 +8,10 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
void ESM::ObjectState::load (ESMReader &esm)
namespace ESM
{
void ObjectState::load (ESMReader &esm)
{
mVersion = esm.getFormat();
@ -56,7 +59,7 @@ void ESM::ObjectState::load (ESMReader &esm)
esm.getHNOT (mHasCustomState, "HCUS");
}
void ESM::ObjectState::save (ESMWriter &esm, bool inInventory) const
void ObjectState::save (ESMWriter &esm, bool inInventory) const
{
mRef.save (esm, true, inInventory);
@ -91,7 +94,7 @@ void ESM::ObjectState::save (ESMWriter &esm, bool inInventory) const
esm.writeHNT ("HCUS", false);
}
void ESM::ObjectState::blank()
void ObjectState::blank()
{
mRef.blank();
mHasLocals = 0;
@ -106,74 +109,76 @@ void ESM::ObjectState::blank()
mHasCustomState = true;
}
const ESM::NpcState& ESM::ObjectState::asNpcState() const
const NpcState& ObjectState::asNpcState() const
{
std::stringstream error;
error << "bad cast " << typeid(this).name() << " to NpcState";
throw std::logic_error(error.str());
}
ESM::NpcState& ESM::ObjectState::asNpcState()
NpcState& ObjectState::asNpcState()
{
std::stringstream error;
error << "bad cast " << typeid(this).name() << " to NpcState";
throw std::logic_error(error.str());
}
const ESM::CreatureState& ESM::ObjectState::asCreatureState() const
const CreatureState& ObjectState::asCreatureState() const
{
std::stringstream error;
error << "bad cast " << typeid(this).name() << " to CreatureState";
throw std::logic_error(error.str());
}
ESM::CreatureState& ESM::ObjectState::asCreatureState()
CreatureState& ObjectState::asCreatureState()
{
std::stringstream error;
error << "bad cast " << typeid(this).name() << " to CreatureState";
throw std::logic_error(error.str());
}
const ESM::ContainerState& ESM::ObjectState::asContainerState() const
const ContainerState& ObjectState::asContainerState() const
{
std::stringstream error;
error << "bad cast " << typeid(this).name() << " to ContainerState";
throw std::logic_error(error.str());
}
ESM::ContainerState& ESM::ObjectState::asContainerState()
ContainerState& ObjectState::asContainerState()
{
std::stringstream error;
error << "bad cast " << typeid(this).name() << " to ContainerState";
throw std::logic_error(error.str());
}
const ESM::DoorState& ESM::ObjectState::asDoorState() const
const DoorState& ObjectState::asDoorState() const
{
std::stringstream error;
error << "bad cast " << typeid(this).name() << " to DoorState";
throw std::logic_error(error.str());
}
ESM::DoorState& ESM::ObjectState::asDoorState()
DoorState& ObjectState::asDoorState()
{
std::stringstream error;
error << "bad cast " << typeid(this).name() << " to DoorState";
throw std::logic_error(error.str());
}
const ESM::CreatureLevListState& ESM::ObjectState::asCreatureLevListState() const
const CreatureLevListState& ObjectState::asCreatureLevListState() const
{
std::stringstream error;
error << "bad cast " << typeid(this).name() << " to CreatureLevListState";
throw std::logic_error(error.str());
}
ESM::CreatureLevListState& ESM::ObjectState::asCreatureLevListState()
CreatureLevListState& ObjectState::asCreatureLevListState()
{
std::stringstream error;
error << "bad cast " << typeid(this).name() << " to CreatureLevListState";
throw std::logic_error(error.str());
}
ESM::ObjectState::~ObjectState() {}
ObjectState::~ObjectState() {}
}

@ -31,7 +31,7 @@ namespace ESM
LuaScripts mLuaScripts;
unsigned char mEnabled;
int mCount;
ESM::Position mPosition;
Position mPosition;
unsigned int mFlags;
// Is there any class-specific state following the ObjectState
@ -39,7 +39,7 @@ namespace ESM
unsigned int mVersion;
ESM::AnimationState mAnimationState;
AnimationState mAnimationState;
ObjectState()
: mHasLocals(0), mEnabled(0), mCount(0)

@ -3,7 +3,10 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
void ESM::Player::load (ESMReader &esm)
namespace ESM
{
void Player::load (ESMReader &esm)
{
mObject.mRef.loadId(esm, true);
mObject.load (esm);
@ -50,7 +53,7 @@ void ESM::Player::load (ESMReader &esm)
bool clearModified = esm.getFormat() < 17 && !mObject.mNpcStats.mIsWerewolf;
if (esm.hasMoreSubs())
{
for (int i=0; i<ESM::Attribute::Length; ++i)
for (int i=0; i<Attribute::Length; ++i)
{
StatState<float> attribute;
attribute.load(esm, intFallback);
@ -60,7 +63,7 @@ void ESM::Player::load (ESMReader &esm)
if (mObject.mNpcStats.mIsWerewolf)
mObject.mCreatureStats.mAttributes[i] = attribute;
}
for (int i=0; i<ESM::Skill::Length; ++i)
for (int i=0; i<Skill::Length; ++i)
{
StatState<float> skill;
skill.load(esm, intFallback);
@ -69,7 +72,7 @@ void ESM::Player::load (ESMReader &esm)
mSaveSkills[i] = skill.mBase + skill.mMod - skill.mDamage;
if (mObject.mNpcStats.mIsWerewolf)
{
if(i == ESM::Skill::Acrobatics)
if(i == Skill::Acrobatics)
mSetWerewolfAcrobatics = mObject.mNpcStats.mSkills[i].mBase != skill.mBase;
mObject.mNpcStats.mSkills[i] = skill;
}
@ -84,7 +87,7 @@ void ESM::Player::load (ESMReader &esm)
}
}
void ESM::Player::save (ESMWriter &esm) const
void Player::save (ESMWriter &esm) const
{
mObject.save (esm);
@ -112,3 +115,5 @@ void ESM::Player::save (ESMWriter &esm) const
esm.writeHNT("WWAT", mSaveAttributes);
esm.writeHNT("WWSK", mSaveSkills);
}
}

@ -24,15 +24,15 @@ namespace ESM
float mLastKnownExteriorPosition[3];
unsigned char mHasMark;
bool mSetWerewolfAcrobatics;
ESM::Position mMarkedPosition;
Position mMarkedPosition;
CellId mMarkedCell;
std::string mBirthsign;
int mCurrentCrimeId;
int mPaidCrimeId;
float mSaveAttributes[ESM::Attribute::Length];
float mSaveSkills[ESM::Skill::Length];
float mSaveAttributes[Attribute::Length];
float mSaveSkills[Skill::Length];
typedef std::map<std::string, std::string> PreviousItems; // previous equipped items, needed for bound spells
PreviousItems mPreviousItems;

@ -38,7 +38,7 @@ namespace ESM
mSpellId = esm.getHNString("SPEL");
if (esm.isNextSub("SRCN")) // for backwards compatibility
esm.skipHSub();
ESM::EffectList().load(esm); // for backwards compatibility
EffectList().load(esm); // for backwards compatibility
esm.getHNT (mSpeed, "SPED");
if(esm.getFormat() < 17)
mSlot = 0;

@ -3,16 +3,21 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
void ESM::QuestState::load (ESMReader &esm)
namespace ESM
{
void QuestState::load (ESMReader &esm)
{
mTopic = esm.getHNString ("YETO");
esm.getHNOT (mState, "QSTA");
esm.getHNOT (mFinished, "QFIN");
}
void ESM::QuestState::save (ESMWriter &esm) const
void QuestState::save (ESMWriter &esm) const
{
esm.writeHNString ("YETO", mTopic);
esm.writeHNT ("QSTA", mState);
esm.writeHNT ("QFIN", mFinished);
}
}

@ -3,10 +3,13 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
unsigned int ESM::SavedGame::sRecordId = ESM::REC_SAVE;
int ESM::SavedGame::sCurrentFormat = 21;
namespace ESM
{
unsigned int SavedGame::sRecordId = REC_SAVE;
int SavedGame::sCurrentFormat = 21;
void ESM::SavedGame::load (ESMReader &esm)
void SavedGame::load (ESMReader &esm)
{
mPlayerName = esm.getHNString("PLNA");
esm.getHNOT (mPlayerLevel, "PLLE");
@ -28,7 +31,7 @@ void ESM::SavedGame::load (ESMReader &esm)
esm.getExact(mScreenshot.data(), mScreenshot.size());
}
void ESM::SavedGame::save (ESMWriter &esm) const
void SavedGame::save (ESMWriter &esm) const
{
esm.writeHNString ("PLNA", mPlayerName);
esm.writeHNT ("PLLE", mPlayerLevel);
@ -51,3 +54,5 @@ void ESM::SavedGame::save (ESMWriter &esm) const
esm.write(&mScreenshot[0], mScreenshot.size());
esm.endRecord("SCRN");
}
}

@ -3,7 +3,8 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
namespace ESM {
namespace ESM
{
void SpellList::add(ESMReader &esm)
{

@ -70,7 +70,7 @@ namespace ESM
if (mProgress)
esm.writeHNT("STPR", mProgress);
}
}
template struct ESM::StatState<int>;
template struct ESM::StatState<float>;
template struct StatState<int>;
template struct StatState<float>;
}

@ -15,8 +15,8 @@ namespace ESM
typedef std::map<std::string, std::map<std::pair<std::string, bool>, int> > StolenItemsMap;
StolenItemsMap mStolenItems;
void load(ESM::ESMReader& esm);
void write(ESM::ESMWriter& esm) const;
void load(ESMReader& esm);
void write(ESMWriter& esm) const;
};
}

@ -10,13 +10,13 @@ namespace ESM
void Transport::add(ESMReader &esm)
{
if (esm.retSubName().toInt() == ESM::fourCC("DODT"))
if (esm.retSubName().toInt() == fourCC("DODT"))
{
Dest dodt;
esm.getHExact(&dodt.mPos, 24);
mList.push_back(dodt);
}
else if (esm.retSubName().toInt() == ESM::fourCC("DNAM"))
else if (esm.retSubName().toInt() == fourCC("DNAM"))
{
const std::string name = esm.getHString();
if (mList.empty())

@ -8,12 +8,14 @@
#include "components/esm/defs.hpp"
namespace ESM
{
namespace
{
constexpr uint32_t STRV = ESM::fourCC("STRV");
constexpr uint32_t INTV = ESM::fourCC("INTV");
constexpr uint32_t FLTV = ESM::fourCC("FLTV");
constexpr uint32_t STTV = ESM::fourCC("STTV");
constexpr uint32_t STRV = fourCC("STRV");
constexpr uint32_t INTV = fourCC("INTV");
constexpr uint32_t FLTV = fourCC("FLTV");
constexpr uint32_t STTV = fourCC("STTV");
template <typename T, bool orDefault = false>
struct GetValue
@ -48,22 +50,22 @@ namespace
};
}
const std::string& ESM::Variant::getString() const
const std::string& Variant::getString() const
{
return std::get<std::string>(mData);
}
int ESM::Variant::getInteger() const
int Variant::getInteger() const
{
return std::visit(GetValue<int>{}, mData);
}
float ESM::Variant::getFloat() const
float Variant::getFloat() const
{
return std::visit(GetValue<float>{}, mData);
}
void ESM::Variant::read (ESMReader& esm, Format format)
void Variant::read (ESMReader& esm, Format format)
{
// type
VarType type = VT_Unknown;
@ -152,7 +154,7 @@ void ESM::Variant::read (ESMReader& esm, Format format)
std::visit(ReadESMVariantValue {esm, format, mType}, mData);
}
void ESM::Variant::write (ESMWriter& esm, Format format) const
void Variant::write (ESMWriter& esm, Format format) const
{
if (mType==VT_Unknown)
{
@ -175,7 +177,7 @@ void ESM::Variant::write (ESMWriter& esm, Format format) const
std::visit(WriteESMVariantValue {esm, format, mType}, mData);
}
void ESM::Variant::write (std::ostream& stream) const
void Variant::write (std::ostream& stream) const
{
switch (mType)
{
@ -216,7 +218,7 @@ void ESM::Variant::write (std::ostream& stream) const
}
}
void ESM::Variant::setType (VarType type)
void Variant::setType (VarType type)
{
if (type!=mType)
{
@ -246,28 +248,30 @@ void ESM::Variant::setType (VarType type)
}
}
void ESM::Variant::setString (const std::string& value)
void Variant::setString (const std::string& value)
{
std::get<std::string>(mData) = value;
}
void ESM::Variant::setString (std::string&& value)
void Variant::setString (std::string&& value)
{
std::get<std::string>(mData) = std::move(value);
}
void ESM::Variant::setInteger (int value)
void Variant::setInteger (int value)
{
std::visit(SetValue(value), mData);
}
void ESM::Variant::setFloat (float value)
void Variant::setFloat (float value)
{
std::visit(SetValue(value), mData);
}
std::ostream& ESM::operator<< (std::ostream& stream, const Variant& value)
std::ostream& operator<< (std::ostream& stream, const Variant& value)
{
value.write (stream);
return stream;
}
}

@ -7,7 +7,10 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
void ESM::readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, std::string& out)
namespace ESM
{
void readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, std::string& out)
{
if (type!=VT_String)
throw std::logic_error ("not a string type");
@ -25,7 +28,7 @@ void ESM::readESMVariantValue(ESMReader& esm, Variant::Format format, VarType ty
out = esm.getHString();
}
void ESM::writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, const std::string& in)
void writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, const std::string& in)
{
if (type!=VT_String)
throw std::logic_error ("not a string type");
@ -43,7 +46,7 @@ void ESM::writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType t
esm.writeHNString("STRV", in);
}
void ESM::readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, int& out)
void readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, int& out)
{
if (type!=VT_Short && type!=VT_Long && type!=VT_Int)
throw std::logic_error ("not an integer type");
@ -93,7 +96,7 @@ void ESM::readESMVariantValue(ESMReader& esm, Variant::Format format, VarType ty
}
}
void ESM::writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, int in)
void writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, int in)
{
if (type!=VT_Short && type!=VT_Long && type!=VT_Int)
throw std::logic_error ("not an integer type");
@ -133,7 +136,7 @@ void ESM::writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType t
}
}
void ESM::readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, float& out)
void readESMVariantValue(ESMReader& esm, Variant::Format format, VarType type, float& out)
{
if (type!=VT_Float)
throw std::logic_error ("not a float type");
@ -148,7 +151,7 @@ void ESM::readESMVariantValue(ESMReader& esm, Variant::Format format, VarType ty
}
}
void ESM::writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, float in)
void writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType type, float in)
{
if (type!=VT_Float)
throw std::logic_error ("not a float type");
@ -163,3 +166,5 @@ void ESM::writeESMVariantValue(ESMWriter& esm, Variant::Format format, VarType t
esm.writeHNT("FLTV", in);
}
}
}

@ -3,19 +3,22 @@
#include "esmreader.hpp"
#include "esmwriter.hpp"
namespace ESM
{
namespace
{
constexpr ESM::NAME currentRegionRecord = "CREG";
constexpr ESM::NAME timePassedRecord = "TMPS";
constexpr ESM::NAME fastForwardRecord = "FAST";
constexpr ESM::NAME weatherUpdateTimeRecord = "WUPD";
constexpr ESM::NAME transitionFactorRecord = "TRFC";
constexpr ESM::NAME currentWeatherRecord = "CWTH";
constexpr ESM::NAME nextWeatherRecord = "NWTH";
constexpr ESM::NAME queuedWeatherRecord = "QWTH";
constexpr ESM::NAME regionNameRecord = "RGNN";
constexpr ESM::NAME regionWeatherRecord = "RGNW";
constexpr ESM::NAME regionChanceRecord = "RGNC";
constexpr NAME currentRegionRecord = "CREG";
constexpr NAME timePassedRecord = "TMPS";
constexpr NAME fastForwardRecord = "FAST";
constexpr NAME weatherUpdateTimeRecord = "WUPD";
constexpr NAME transitionFactorRecord = "TRFC";
constexpr NAME currentWeatherRecord = "CWTH";
constexpr NAME nextWeatherRecord = "NWTH";
constexpr NAME queuedWeatherRecord = "QWTH";
constexpr NAME regionNameRecord = "RGNN";
constexpr NAME regionWeatherRecord = "RGNW";
constexpr NAME regionChanceRecord = "RGNC";
}
}
namespace ESM

Loading…
Cancel
Save