diff --git a/apps/openmw/mwworld/esmloader.cpp b/apps/openmw/mwworld/esmloader.cpp index e586a4c204..0be90c65f0 100644 --- a/apps/openmw/mwworld/esmloader.cpp +++ b/apps/openmw/mwworld/esmloader.cpp @@ -64,11 +64,12 @@ namespace MWWorld } case ESM::Format::Tes4: { - ESM4::Reader readerESM4(std::move(stream), filepath, - MWBase::Environment::get().getResourceSystem()->getVFS(), mReaders.getStatelessEncoder()); - readerESM4.setModIndex(index); - readerESM4.updateModIndices(mNameToIndex); - mStore.loadESM4(readerESM4); + ESM4::Reader reader(std::move(stream), filepath, + MWBase::Environment::get().getResourceSystem()->getVFS(), + mEncoder != nullptr ? &mEncoder->getStatelessEncoder() : nullptr); + reader.setModIndex(index); + reader.updateModIndices(mNameToIndex); + mStore.loadESM4(reader); break; } } diff --git a/apps/openmw/mwworld/worldimp.cpp b/apps/openmw/mwworld/worldimp.cpp index c6282c6f5a..a265ff0a76 100644 --- a/apps/openmw/mwworld/worldimp.cpp +++ b/apps/openmw/mwworld/worldimp.cpp @@ -274,8 +274,6 @@ namespace MWWorld const std::vector& groundcoverFiles, ToUTF8::Utf8Encoder* encoder, Loading::Listener* listener) { mContentFiles = contentFiles; - if (encoder) - mReaders.setStatelessEncoder(encoder->getStatelessEncoder()); mESMVersions.resize(mContentFiles.size(), -1); loadContentFiles(fileCollections, contentFiles, encoder, listener); diff --git a/components/esm3/readerscache.hpp b/components/esm3/readerscache.hpp index 94bee206ec..5d8c2afcbd 100644 --- a/components/esm3/readerscache.hpp +++ b/components/esm3/readerscache.hpp @@ -9,8 +9,6 @@ #include #include -#include - namespace ESM { class ReadersCache @@ -57,23 +55,13 @@ namespace ESM BusyItem get(std::size_t index); - void setStatelessEncoder(const ToUTF8::StatelessUtf8Encoder& statelessEncoderPtr) - { - mStatelessEncoder.emplace(statelessEncoderPtr); - } - - const ToUTF8::StatelessUtf8Encoder* getStatelessEncoder() - { - return mStatelessEncoder.has_value() ? &mStatelessEncoder.value() : nullptr; - } - private: const std::size_t mCapacity; std::map::iterator> mIndex; std::list mBusyItems; std::list mFreeItems; std::list mClosedItems; - std::optional mStatelessEncoder; + inline void closeExtraReaders(); inline void releaseItem(std::list::iterator it) noexcept;