1
0
Fork 0
mirror of https://github.com/OpenMW/openmw.git synced 2025-02-22 22:40:12 +00:00

Merge branch 'Get-Skyrimesm-Loading' into 'master'

Load esm files from vfs

See merge request OpenMW/openmw!2756
This commit is contained in:
psi29a 2023-02-20 21:00:09 +00:00
commit ee41151520
4 changed files with 14 additions and 5 deletions

View file

@ -42,6 +42,7 @@
Bug #7122: Teleportation to underwater should cancel active water walking effect Bug #7122: Teleportation to underwater should cancel active water walking effect
Bug #7163: Myar Aranath: Wheat breaks the GUI Bug #7163: Myar Aranath: Wheat breaks the GUI
Bug #7172: Current music playlist continues playing indefinitely if next playlist is empty Bug #7172: Current music playlist continues playing indefinitely if next playlist is empty
Bug #7243: Get Skyrim.esm loading
Feature #5492: Let rain and snow collide with statics Feature #5492: Let rain and snow collide with statics
Feature #6447: Add LOD support to Object Paging Feature #6447: Add LOD support to Object Paging
Feature #6726: Lua API for creating new objects Feature #6726: Lua API for creating new objects

View file

@ -9,6 +9,9 @@
#include <components/esm4/reader.hpp> #include <components/esm4/reader.hpp>
#include <components/files/conversion.hpp> #include <components/files/conversion.hpp>
#include <components/files/openfile.hpp> #include <components/files/openfile.hpp>
#include <components/resource/resourcesystem.hpp>
#include "../mwbase/environment.hpp"
namespace MWWorld namespace MWWorld
{ {
@ -60,7 +63,8 @@ namespace MWWorld
} }
case ESM::Format::Tes4: case ESM::Format::Tes4:
{ {
ESM4::Reader readerESM4(std::move(stream), filepath); ESM4::Reader readerESM4(
std::move(stream), filepath, MWBase::Environment::get().getResourceSystem()->getVFS());
auto statelessEncoder = mEncoder->getStatelessEncoder(); auto statelessEncoder = mEncoder->getStatelessEncoder();
readerESM4.setEncoder(&statelessEncoder); readerESM4.setEncoder(&statelessEncoder);
mStore.loadESM4(readerESM4); mStore.loadESM4(readerESM4);

View file

@ -74,8 +74,9 @@ namespace ESM4
subRecordHeader.dataSize = 0; subRecordHeader.dataSize = 0;
} }
Reader::Reader(Files::IStreamPtr&& esmStream, const std::filesystem::path& filename) Reader::Reader(Files::IStreamPtr&& esmStream, const std::filesystem::path& filename, VFS::Manager const* vfs)
: mEncoder(nullptr) : mVFS(vfs)
, mEncoder(nullptr)
, mFileSize(0) , mFileSize(0)
, mStream(std::move(esmStream)) , mStream(std::move(esmStream))
{ {
@ -224,7 +225,8 @@ namespace ESM4
sp.type = stringType; sp.type = stringType;
// TODO: possibly check if the resource exists? // TODO: possibly check if the resource exists?
Files::IStreamPtr filestream = Files::openConstrainedFileStream(stringFile); Files::IStreamPtr filestream
= mVFS ? mVFS->get(stringFile.string()) : Files::openConstrainedFileStream(stringFile);
filestream->seekg(0, std::ios::end); filestream->seekg(0, std::ios::end);
std::size_t fileSize = filestream->tellg(); std::size_t fileSize = filestream->tellg();

View file

@ -33,6 +33,7 @@
#include "loadtes4.hpp" #include "loadtes4.hpp"
#include <components/files/istreamptr.hpp> #include <components/files/istreamptr.hpp>
#include <components/vfs/manager.hpp>
namespace ToUTF8 namespace ToUTF8
{ {
@ -83,6 +84,7 @@ namespace ESM4
class Reader class Reader
{ {
VFS::Manager const* mVFS;
Header mHeader; // ESM4 header Header mHeader; // ESM4 header
ReaderContext mCtx; ReaderContext mCtx;
@ -138,7 +140,7 @@ namespace ESM4
const ToUTF8::StatelessUtf8Encoder* encoder, bool hasNull = false); const ToUTF8::StatelessUtf8Encoder* encoder, bool hasNull = false);
public: public:
Reader(Files::IStreamPtr&& esmStream, const std::filesystem::path& filename); Reader(Files::IStreamPtr&& esmStream, const std::filesystem::path& filename, VFS::Manager const* vfs = nullptr);
~Reader(); ~Reader();
void open(const std::filesystem::path& filename); void open(const std::filesystem::path& filename);