forked from teamnwah/openmw-tes3coop
Some refactoring. Remove unused code
This commit is contained in:
parent
e65ff723ce
commit
5fd48efd28
7 changed files with 173 additions and 260 deletions
|
@ -194,7 +194,7 @@ namespace MWWorld
|
||||||
if (inserted.second)
|
if (inserted.second)
|
||||||
mShared.push_back(&inserted.first->second);
|
mShared.push_back(&inserted.first->second);
|
||||||
|
|
||||||
return RecordId(record.mId, ESM::isRecordDeleted(record));
|
return RecordId(record.mId, record.mIsDeleted);
|
||||||
}
|
}
|
||||||
template<typename T>
|
template<typename T>
|
||||||
void Store<T>::setUp()
|
void Store<T>::setUp()
|
||||||
|
@ -327,7 +327,7 @@ namespace MWWorld
|
||||||
record.load (reader);
|
record.load (reader);
|
||||||
insert (record);
|
insert (record);
|
||||||
|
|
||||||
return RecordId(record.mId, ESM::isRecordDeleted(record));
|
return RecordId(record.mId, record.mIsDeleted);
|
||||||
}
|
}
|
||||||
|
|
||||||
// LandTexture
|
// LandTexture
|
||||||
|
@ -1083,6 +1083,35 @@ namespace MWWorld
|
||||||
|
|
||||||
return RecordId(script.mId);
|
return RecordId(script.mId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// GameSetting
|
||||||
|
// Need to specialize load() and read() methods, because GameSetting can't
|
||||||
|
// be deleted (has no mIsDeleted flag)
|
||||||
|
//=========================================================================
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline RecordId Store<ESM::GameSetting>::load(ESM::ESMReader &reader)
|
||||||
|
{
|
||||||
|
ESM::GameSetting setting;
|
||||||
|
setting.load(reader);
|
||||||
|
Misc::StringUtils::toLower(setting.mId);
|
||||||
|
|
||||||
|
std::pair<typename Static::iterator, bool> inserted = mStatic.insert(std::make_pair(setting.mId, setting));
|
||||||
|
if (inserted.second)
|
||||||
|
mShared.push_back(&inserted.first->second);
|
||||||
|
|
||||||
|
return RecordId(setting.mId);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <>
|
||||||
|
inline RecordId Store<ESM::GameSetting>::read(ESM::ESMReader &reader)
|
||||||
|
{
|
||||||
|
ESM::GameSetting setting;
|
||||||
|
setting.load(reader);
|
||||||
|
insert(setting);
|
||||||
|
|
||||||
|
return RecordId(setting.mId);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
template class MWWorld::Store<ESM::Activator>;
|
template class MWWorld::Store<ESM::Activator>;
|
||||||
|
|
|
@ -3,7 +3,6 @@
|
||||||
#include "esmreader.hpp"
|
#include "esmreader.hpp"
|
||||||
#include "esmwriter.hpp"
|
#include "esmwriter.hpp"
|
||||||
#include "defs.hpp"
|
#include "defs.hpp"
|
||||||
#include "util.hpp"
|
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
|
|
|
@ -12,7 +12,6 @@
|
||||||
#include "esmwriter.hpp"
|
#include "esmwriter.hpp"
|
||||||
#include "defs.hpp"
|
#include "defs.hpp"
|
||||||
#include "cellid.hpp"
|
#include "cellid.hpp"
|
||||||
#include "util.hpp"
|
|
||||||
|
|
||||||
namespace
|
namespace
|
||||||
{
|
{
|
||||||
|
@ -53,171 +52,178 @@ namespace ESM
|
||||||
return ref.mRefNum == refNum;
|
return ref.mRefNum == refNum;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Cell::load(ESMReader &esm, bool saveContext)
|
void Cell::load(ESMReader &esm, bool saveContext)
|
||||||
{
|
|
||||||
loadName(esm);
|
|
||||||
loadData(esm);
|
|
||||||
loadCell(esm, saveContext);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::loadName(ESMReader &esm)
|
|
||||||
{
|
|
||||||
mName = esm.getHNString("NAME");
|
|
||||||
mIsDeleted = readDeleSubRecord(esm);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::loadCell(ESMReader &esm, bool saveContext)
|
|
||||||
{
|
|
||||||
mRefNumCounter = 0;
|
|
||||||
|
|
||||||
if (mData.mFlags & Interior)
|
|
||||||
{
|
{
|
||||||
// Interior cells
|
loadName(esm);
|
||||||
if (esm.isNextSub("INTV"))
|
loadData(esm);
|
||||||
{
|
loadCell(esm, saveContext);
|
||||||
int waterl;
|
}
|
||||||
esm.getHT(waterl);
|
|
||||||
mWater = (float) waterl;
|
|
||||||
mWaterInt = true;
|
|
||||||
}
|
|
||||||
else if (esm.isNextSub("WHGT"))
|
|
||||||
{
|
|
||||||
esm.getHT(mWater);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Quasi-exterior cells have a region (which determines the
|
void Cell::loadName(ESMReader &esm)
|
||||||
// weather), pure interior cells have ambient lighting
|
{
|
||||||
// instead.
|
mName = esm.getHNString("NAME");
|
||||||
if (mData.mFlags & QuasiEx)
|
|
||||||
|
mIsDeleted = false;
|
||||||
|
if (esm.isNextSub("DELE"))
|
||||||
|
{
|
||||||
|
esm.skipHSub();
|
||||||
|
mIsDeleted = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void Cell::loadCell(ESMReader &esm, bool saveContext)
|
||||||
|
{
|
||||||
|
mRefNumCounter = 0;
|
||||||
|
|
||||||
|
if (mData.mFlags & Interior)
|
||||||
|
{
|
||||||
|
// Interior cells
|
||||||
|
if (esm.isNextSub("INTV"))
|
||||||
|
{
|
||||||
|
int waterl;
|
||||||
|
esm.getHT(waterl);
|
||||||
|
mWater = (float) waterl;
|
||||||
|
mWaterInt = true;
|
||||||
|
}
|
||||||
|
else if (esm.isNextSub("WHGT"))
|
||||||
|
{
|
||||||
|
esm.getHT(mWater);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Quasi-exterior cells have a region (which determines the
|
||||||
|
// weather), pure interior cells have ambient lighting
|
||||||
|
// instead.
|
||||||
|
if (mData.mFlags & QuasiEx)
|
||||||
|
mRegion = esm.getHNOString("RGNN");
|
||||||
|
else if (esm.isNextSub("AMBI"))
|
||||||
|
esm.getHT(mAmbi);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// Exterior cells
|
||||||
mRegion = esm.getHNOString("RGNN");
|
mRegion = esm.getHNOString("RGNN");
|
||||||
else if (esm.isNextSub("AMBI"))
|
|
||||||
esm.getHT(mAmbi);
|
mMapColor = 0;
|
||||||
|
esm.getHNOT(mMapColor, "NAM5");
|
||||||
|
}
|
||||||
|
if (esm.isNextSub("NAM0")) {
|
||||||
|
esm.getHT(mRefNumCounter);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (saveContext) {
|
||||||
|
mContextList.push_back(esm.getContext());
|
||||||
|
esm.skipRecord();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
|
||||||
|
void Cell::loadData(ESMReader &esm)
|
||||||
{
|
{
|
||||||
// Exterior cells
|
esm.getHNT(mData, "DATA", 12);
|
||||||
mRegion = esm.getHNOString("RGNN");
|
|
||||||
|
|
||||||
mMapColor = 0;
|
|
||||||
esm.getHNOT(mMapColor, "NAM5");
|
|
||||||
}
|
|
||||||
if (esm.isNextSub("NAM0")) {
|
|
||||||
esm.getHT(mRefNumCounter);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (saveContext) {
|
void Cell::postLoad(ESMReader &esm)
|
||||||
|
{
|
||||||
|
// Save position of the cell references and move on
|
||||||
mContextList.push_back(esm.getContext());
|
mContextList.push_back(esm.getContext());
|
||||||
esm.skipRecord();
|
esm.skipRecord();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::loadData(ESMReader &esm)
|
void Cell::save(ESMWriter &esm) const
|
||||||
{
|
|
||||||
esm.getHNT(mData, "DATA", 12);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::postLoad(ESMReader &esm)
|
|
||||||
{
|
|
||||||
// Save position of the cell references and move on
|
|
||||||
mContextList.push_back(esm.getContext());
|
|
||||||
esm.skipRecord();
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::save(ESMWriter &esm) const
|
|
||||||
{
|
|
||||||
esm.writeHNCString("NAME", mName);
|
|
||||||
if (mIsDeleted)
|
|
||||||
{
|
{
|
||||||
writeDeleSubRecord(esm);
|
esm.writeHNCString("NAME", mName);
|
||||||
}
|
|
||||||
|
|
||||||
esm.writeHNT("DATA", mData, 12);
|
if (mIsDeleted)
|
||||||
if (mData.mFlags & Interior)
|
{
|
||||||
{
|
esm.writeHNCString("DELE", "");
|
||||||
if (mWaterInt) {
|
|
||||||
int water =
|
|
||||||
(mWater >= 0) ? (int) (mWater + 0.5) : (int) (mWater - 0.5);
|
|
||||||
esm.writeHNT("INTV", water);
|
|
||||||
} else {
|
|
||||||
esm.writeHNT("WHGT", mWater);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mData.mFlags & QuasiEx)
|
esm.writeHNT("DATA", mData, 12);
|
||||||
|
if (mData.mFlags & Interior)
|
||||||
|
{
|
||||||
|
if (mWaterInt) {
|
||||||
|
int water =
|
||||||
|
(mWater >= 0) ? (int) (mWater + 0.5) : (int) (mWater - 0.5);
|
||||||
|
esm.writeHNT("INTV", water);
|
||||||
|
} else {
|
||||||
|
esm.writeHNT("WHGT", mWater);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (mData.mFlags & QuasiEx)
|
||||||
|
esm.writeHNOCString("RGNN", mRegion);
|
||||||
|
else
|
||||||
|
esm.writeHNT("AMBI", mAmbi, 16);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
esm.writeHNOCString("RGNN", mRegion);
|
esm.writeHNOCString("RGNN", mRegion);
|
||||||
else
|
if (mMapColor != 0)
|
||||||
esm.writeHNT("AMBI", mAmbi, 16);
|
esm.writeHNT("NAM5", mMapColor);
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
if (mRefNumCounter != 0)
|
||||||
esm.writeHNOCString("RGNN", mRegion);
|
esm.writeHNT("NAM0", mRefNumCounter);
|
||||||
if (mMapColor != 0)
|
|
||||||
esm.writeHNT("NAM5", mMapColor);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (mRefNumCounter != 0 && !mIsDeleted)
|
void Cell::restore(ESMReader &esm, int iCtx) const
|
||||||
esm.writeHNT("NAM0", mRefNumCounter);
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::restore(ESMReader &esm, int iCtx) const
|
|
||||||
{
|
|
||||||
esm.restoreContext(mContextList.at (iCtx));
|
|
||||||
}
|
|
||||||
|
|
||||||
std::string Cell::getDescription() const
|
|
||||||
{
|
|
||||||
if (mData.mFlags & Interior)
|
|
||||||
{
|
{
|
||||||
return mName;
|
esm.restoreContext(mContextList.at (iCtx));
|
||||||
}
|
}
|
||||||
else
|
|
||||||
{
|
|
||||||
std::ostringstream stream;
|
|
||||||
stream << mData.mX << ", " << mData.mY;
|
|
||||||
return stream.str();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
bool Cell::getNextRef(ESMReader &esm, CellRef &ref, bool ignoreMoves, MovedCellRef *mref)
|
std::string Cell::getDescription() const
|
||||||
{
|
|
||||||
// TODO: Try and document reference numbering, I don't think this has been done anywhere else.
|
|
||||||
if (!esm.hasMoreSubs())
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// NOTE: We should not need this check. It is a safety check until we have checked
|
|
||||||
// more plugins, and how they treat these moved references.
|
|
||||||
if (esm.isNextSub("MVRF"))
|
|
||||||
{
|
{
|
||||||
if (ignoreMoves)
|
if (mData.mFlags & Interior)
|
||||||
{
|
{
|
||||||
esm.getHT (mref->mRefNum.mIndex);
|
return mName;
|
||||||
esm.getHNOT (mref->mTarget, "CNDT");
|
|
||||||
adjustRefNum (mref->mRefNum, esm);
|
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// skip rest of cell record (moved references), they are handled elsewhere
|
std::ostringstream stream;
|
||||||
esm.skipRecord(); // skip MVRF, CNDT
|
stream << mData.mX << ", " << mData.mY;
|
||||||
|
return stream.str();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Cell::getNextRef(ESMReader &esm, CellRef &ref, bool ignoreMoves, MovedCellRef *mref)
|
||||||
|
{
|
||||||
|
// TODO: Try and document reference numbering, I don't think this has been done anywhere else.
|
||||||
|
if (!esm.hasMoreSubs())
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
// NOTE: We should not need this check. It is a safety check until we have checked
|
||||||
|
// more plugins, and how they treat these moved references.
|
||||||
|
if (esm.isNextSub("MVRF"))
|
||||||
|
{
|
||||||
|
if (ignoreMoves)
|
||||||
|
{
|
||||||
|
esm.getHT (mref->mRefNum.mIndex);
|
||||||
|
esm.getHNOT (mref->mTarget, "CNDT");
|
||||||
|
adjustRefNum (mref->mRefNum, esm);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
// skip rest of cell record (moved references), they are handled elsewhere
|
||||||
|
esm.skipRecord(); // skip MVRF, CNDT
|
||||||
|
return false;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
ref.load (esm);
|
||||||
|
|
||||||
|
// Identify references belonging to a parent file and adapt the ID accordingly.
|
||||||
|
adjustRefNum (ref.mRefNum, esm);
|
||||||
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ref.load (esm);
|
bool Cell::getNextMVRF(ESMReader &esm, MovedCellRef &mref)
|
||||||
|
{
|
||||||
|
esm.getHT(mref.mRefNum.mIndex);
|
||||||
|
esm.getHNOT(mref.mTarget, "CNDT");
|
||||||
|
|
||||||
// Identify references belonging to a parent file and adapt the ID accordingly.
|
adjustRefNum (mref.mRefNum, esm);
|
||||||
adjustRefNum (ref.mRefNum, esm);
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool Cell::getNextMVRF(ESMReader &esm, MovedCellRef &mref)
|
|
||||||
{
|
|
||||||
esm.getHT(mref.mRefNum.mIndex);
|
|
||||||
esm.getHNOT(mref.mTarget, "CNDT");
|
|
||||||
|
|
||||||
adjustRefNum (mref.mRefNum, esm);
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void Cell::blank()
|
void Cell::blank()
|
||||||
{
|
{
|
||||||
|
|
|
@ -26,6 +26,7 @@ namespace ESM
|
||||||
{
|
{
|
||||||
case ESM::FourCC<'N','A','M','E'>::value:
|
case ESM::FourCC<'N','A','M','E'>::value:
|
||||||
mId = esm.getHString();
|
mId = esm.getHString();
|
||||||
|
hasName = true;
|
||||||
break;
|
break;
|
||||||
case ESM::FourCC<'D','E','L','E'>::value:
|
case ESM::FourCC<'D','E','L','E'>::value:
|
||||||
esm.skipHSub();
|
esm.skipHSub();
|
||||||
|
|
|
@ -26,7 +26,7 @@ namespace ESM
|
||||||
{
|
{
|
||||||
case ESM::FourCC<'N','A','M','E'>::value:
|
case ESM::FourCC<'N','A','M','E'>::value:
|
||||||
mId = esm.getHString();
|
mId = esm.getHString();
|
||||||
hasName = false;
|
hasName = true;
|
||||||
break;
|
break;
|
||||||
case ESM::FourCC<'D','E','L','E'>::value:
|
case ESM::FourCC<'D','E','L','E'>::value:
|
||||||
esm.skipHSub();
|
esm.skipHSub();
|
||||||
|
|
|
@ -1,75 +0,0 @@
|
||||||
#include "util.hpp"
|
|
||||||
|
|
||||||
#include <cstdint>
|
|
||||||
|
|
||||||
namespace ESM
|
|
||||||
{
|
|
||||||
bool readDeleSubRecord(ESMReader &esm)
|
|
||||||
{
|
|
||||||
if (esm.isNextSub("DELE"))
|
|
||||||
{
|
|
||||||
esm.skipHSub();
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
void writeDeleSubRecord(ESMWriter &esm)
|
|
||||||
{
|
|
||||||
esm.writeHNT("DELE", static_cast<int32_t>(0));
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<StartScript>(const StartScript &script)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<Race>(const Race &race)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<GameSetting>(const GameSetting &gmst)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<Skill>(const Skill &skill)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<MagicEffect>(const MagicEffect &mgef)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<Pathgrid>(const Pathgrid &pgrd)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<Land>(const Land &land)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<DebugProfile>(const DebugProfile &profile)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<Filter>(const Filter &filter)
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
}
|
|
|
@ -8,16 +8,6 @@
|
||||||
|
|
||||||
#include "esmreader.hpp"
|
#include "esmreader.hpp"
|
||||||
#include "esmwriter.hpp"
|
#include "esmwriter.hpp"
|
||||||
#include "loadsscr.hpp"
|
|
||||||
#include "loadglob.hpp"
|
|
||||||
#include "loadrace.hpp"
|
|
||||||
#include "loadgmst.hpp"
|
|
||||||
#include "loadskil.hpp"
|
|
||||||
#include "loadmgef.hpp"
|
|
||||||
#include "loadland.hpp"
|
|
||||||
#include "loadpgrd.hpp"
|
|
||||||
#include "debugprofile.hpp"
|
|
||||||
#include "filter.hpp"
|
|
||||||
|
|
||||||
namespace ESM
|
namespace ESM
|
||||||
{
|
{
|
||||||
|
@ -63,43 +53,6 @@ struct Vector3
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
bool readDeleSubRecord(ESMReader &esm);
|
|
||||||
void writeDeleSubRecord(ESMWriter &esm);
|
|
||||||
|
|
||||||
template <class RecordT>
|
|
||||||
bool isRecordDeleted(const RecordT &record)
|
|
||||||
{
|
|
||||||
return record.mIsDeleted;
|
|
||||||
}
|
|
||||||
|
|
||||||
// The following records can't be deleted (for now)
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<StartScript>(const StartScript &script);
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<Race>(const Race &race);
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<GameSetting>(const GameSetting &gmst);
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<Skill>(const Skill &skill);
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<MagicEffect>(const MagicEffect &mgef);
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<Pathgrid>(const Pathgrid &pgrd);
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<Land>(const Land &land);
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<DebugProfile>(const DebugProfile &profile);
|
|
||||||
|
|
||||||
template <>
|
|
||||||
bool isRecordDeleted<Filter>(const Filter &filter);
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
Loading…
Reference in a new issue