diff --git a/components/esm/esmreader.cpp b/components/esm/esmreader.cpp index 4e7dce876..7aa8add48 100644 --- a/components/esm/esmreader.cpp +++ b/components/esm/esmreader.cpp @@ -97,13 +97,6 @@ void ESMReader::open(const std::string &file) open (Files::openConstrainedFileStream (file.c_str ()), file); } -int64_t ESMReader::getHNLong(const char *name) -{ - int64_t val; - getHNT(val, name); - return val; -} - std::string ESMReader::getHNOString(const char* name) { if (isNextSub(name)) @@ -215,18 +208,6 @@ void ESMReader::getSubName() mCtx.leftRec -= subNameSize; } -bool ESMReader::isEmptyOrGetName() -{ - if (mCtx.leftRec) - { - const size_t subNameSize = mCtx.subName.data_size(); - getExact(mCtx.subName.rw_data(), subNameSize); - mCtx.leftRec -= subNameSize; - return false; - } - return true; -} - void ESMReader::skipHSub() { getSubHeader(); @@ -343,7 +324,7 @@ std::string ESMReader::getString(int size) mBuffer[s] = 0; // read ESM data - char *ptr = &mBuffer[0]; + char *ptr = mBuffer.data(); getExact(ptr, size); size = strnlen(ptr, size); diff --git a/components/esm/esmreader.hpp b/components/esm/esmreader.hpp index 761756e8f..ba24c79f8 100644 --- a/components/esm/esmreader.hpp +++ b/components/esm/esmreader.hpp @@ -128,8 +128,6 @@ public: getHT(x); } - int64_t getHNLong(const char *name); - // Get data of a given type/size, including subrecord header template void getHT(X &x) @@ -193,9 +191,6 @@ public: // slightly. void getSubName(); - // This is specially optimized for LoadINFO. - bool isEmptyOrGetName(); - // Skip current sub record, including header (but not including // name.) void skipHSub(); diff --git a/components/esm/globalscript.cpp b/components/esm/globalscript.cpp index 239d162f2..016ea4f0c 100644 --- a/components/esm/globalscript.cpp +++ b/components/esm/globalscript.cpp @@ -13,8 +13,7 @@ void ESM::GlobalScript::load (ESMReader &esm) esm.getHNOT (mRunning, "RUN_"); mTargetRef.unset(); - if (esm.peekNextSub("TARG")) - mTargetId = esm.getHNString ("TARG"); + mTargetId = esm.getHNOString ("TARG"); if (esm.peekNextSub("FRMR")) mTargetRef.load(esm, true, "FRMR"); } diff --git a/components/esm/loadtes3.cpp b/components/esm/loadtes3.cpp index d953f1dc2..f5cbcd62f 100644 --- a/components/esm/loadtes3.cpp +++ b/components/esm/loadtes3.cpp @@ -41,7 +41,7 @@ void ESM::Header::load (ESMReader &esm) { MasterData m; m.name = esm.getHString(); - m.size = esm.getHNLong ("DATA"); + esm.getHNT(m.size, "DATA"); mMaster.push_back (m); } @@ -54,14 +54,14 @@ void ESM::Header::load (ESMReader &esm) esm.getSubHeader(); mSCRD.resize(esm.getSubSize()); if (!mSCRD.empty()) - esm.getExact(&mSCRD[0], mSCRD.size()); + esm.getExact(mSCRD.data(), mSCRD.size()); } if (esm.isNextSub("SCRS")) { esm.getSubHeader(); mSCRS.resize(esm.getSubSize()); if (!mSCRS.empty()) - esm.getExact(&mSCRS[0], mSCRS.size()); + esm.getExact(mSCRS.data(), mSCRS.size()); } } @@ -78,10 +78,9 @@ void ESM::Header::save (ESMWriter &esm) esm.writeT(mData.records); esm.endRecord("HEDR"); - for (std::vector::iterator iter = mMaster.begin(); - iter != mMaster.end(); ++iter) + for (const Header::MasterData& data : mMaster) { - esm.writeHNCString ("MAST", iter->name); - esm.writeHNT ("DATA", iter->size); + esm.writeHNCString ("MAST", data.name); + esm.writeHNT ("DATA", data.size); } } diff --git a/components/esm/weatherstate.cpp b/components/esm/weatherstate.cpp index ff2528e58..3d94a445b 100644 --- a/components/esm/weatherstate.cpp +++ b/components/esm/weatherstate.cpp @@ -31,15 +31,15 @@ namespace ESM esm.getHNT(mNextWeather, nextWeatherRecord); esm.getHNT(mQueuedWeather, queuedWeatherRecord); - while(esm.peekNextSub(regionNameRecord)) + while (esm.isNextSub(regionNameRecord)) { - std::string regionID = esm.getHNString(regionNameRecord); + std::string regionID = esm.getHString(); RegionWeatherState region; esm.getHNT(region.mWeather, regionWeatherRecord); - while(esm.peekNextSub(regionChanceRecord)) + while (esm.isNextSub(regionChanceRecord)) { char chance; - esm.getHNT(chance, regionChanceRecord); + esm.getHT(chance); region.mChances.push_back(chance); }