2011-04-08 13:58:21 +00:00
|
|
|
#include "loadregn.hpp"
|
|
|
|
|
2012-09-23 18:41:41 +00:00
|
|
|
#include "esmreader.hpp"
|
|
|
|
#include "esmwriter.hpp"
|
2013-09-24 11:17:28 +00:00
|
|
|
#include "defs.hpp"
|
2012-09-17 07:37:50 +00:00
|
|
|
|
2011-04-08 13:58:21 +00:00
|
|
|
namespace ESM
|
|
|
|
{
|
2013-09-24 11:17:28 +00:00
|
|
|
unsigned int Region::sRecordId = REC_REGN;
|
2011-04-08 13:58:21 +00:00
|
|
|
|
|
|
|
void Region::load(ESMReader &esm)
|
|
|
|
{
|
2014-04-13 11:23:50 +00:00
|
|
|
mName = esm.getHNOString("FNAM");
|
2011-04-08 13:58:21 +00:00
|
|
|
|
2014-06-03 20:49:37 +00:00
|
|
|
esm.getSubNameIs("WEAT");
|
|
|
|
esm.getSubHeader();
|
2011-04-08 13:58:21 +00:00
|
|
|
if (esm.getVer() == VER_12)
|
2014-06-03 20:49:37 +00:00
|
|
|
{
|
|
|
|
mData.mA = 0;
|
|
|
|
mData.mB = 0;
|
|
|
|
esm.getExact(&mData, sizeof(mData) - 2);
|
|
|
|
}
|
2011-04-08 13:58:21 +00:00
|
|
|
else if (esm.getVer() == VER_13)
|
2014-06-03 20:49:37 +00:00
|
|
|
{
|
|
|
|
// May include the additional two bytes (but not necessarily)
|
|
|
|
if (esm.getSubSize() == sizeof(mData))
|
|
|
|
esm.getExact(&mData, sizeof(mData));
|
|
|
|
else
|
|
|
|
{
|
|
|
|
mData.mA = 0;
|
|
|
|
mData.mB = 0;
|
|
|
|
esm.getExact(&mData, sizeof(mData)-2);
|
|
|
|
}
|
|
|
|
}
|
2011-04-08 13:58:21 +00:00
|
|
|
else
|
|
|
|
esm.fail("Don't know what to do in this version");
|
|
|
|
|
2012-09-17 07:37:50 +00:00
|
|
|
mSleepList = esm.getHNOString("BNAM");
|
2011-04-08 13:58:21 +00:00
|
|
|
|
2012-09-17 07:37:50 +00:00
|
|
|
esm.getHNT(mMapColor, "CNAM");
|
2011-04-08 13:58:21 +00:00
|
|
|
|
2014-09-20 11:32:32 +00:00
|
|
|
mSoundList.clear();
|
2011-04-08 13:58:21 +00:00
|
|
|
while (esm.hasMoreSubs())
|
|
|
|
{
|
|
|
|
SoundRef sr;
|
|
|
|
esm.getHNT(sr, "SNAM", 33);
|
2012-09-17 07:37:50 +00:00
|
|
|
mSoundList.push_back(sr);
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|
|
|
|
}
|
2013-09-16 10:32:35 +00:00
|
|
|
void Region::save(ESMWriter &esm) const
|
2012-04-06 19:04:30 +00:00
|
|
|
{
|
2014-04-13 11:23:50 +00:00
|
|
|
esm.writeHNOCString("FNAM", mName);
|
2013-04-07 14:32:06 +00:00
|
|
|
|
2012-04-08 15:04:52 +00:00
|
|
|
if (esm.getVersion() == VER_12)
|
2012-09-17 07:37:50 +00:00
|
|
|
esm.writeHNT("WEAT", mData, sizeof(mData) - 2);
|
2012-04-08 15:04:52 +00:00
|
|
|
else
|
2012-09-17 07:37:50 +00:00
|
|
|
esm.writeHNT("WEAT", mData);
|
2013-04-07 14:32:06 +00:00
|
|
|
|
2012-09-17 07:37:50 +00:00
|
|
|
esm.writeHNOCString("BNAM", mSleepList);
|
2013-04-07 14:32:06 +00:00
|
|
|
|
2012-09-17 07:37:50 +00:00
|
|
|
esm.writeHNT("CNAM", mMapColor);
|
2013-09-16 10:32:35 +00:00
|
|
|
for (std::vector<SoundRef>::const_iterator it = mSoundList.begin(); it != mSoundList.end(); ++it)
|
2012-04-06 19:04:30 +00:00
|
|
|
{
|
|
|
|
esm.writeHNT<SoundRef>("SNAM", *it);
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-04-07 14:32:06 +00:00
|
|
|
void Region::blank()
|
|
|
|
{
|
|
|
|
mName.clear();
|
|
|
|
|
|
|
|
mData.mClear = mData.mCloudy = mData.mFoggy = mData.mOvercast = mData.mRain =
|
|
|
|
mData.mThunder = mData.mAsh, mData.mBlight = mData.mA = mData.mB = 0;
|
|
|
|
|
|
|
|
mMapColor = 0;
|
|
|
|
|
|
|
|
mName.clear();
|
|
|
|
mSleepList.clear();
|
|
|
|
mSoundList.clear();
|
|
|
|
}
|
2011-04-08 13:58:21 +00:00
|
|
|
}
|