Skip to content

Commit

Permalink
Merge branch 'Get-Skyrimesm-Loading' into 'master'
Browse files Browse the repository at this point in the history
Load esm files from vfs

See merge request OpenMW/openmw!2756
  • Loading branch information
psi29a committed Feb 20, 2023
2 parents 67f0d37 + 6e23ad8 commit ee41151
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 5 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,6 +42,7 @@
Bug #7122: Teleportation to underwater should cancel active water walking effect
Bug #7163: Myar Aranath: Wheat breaks the GUI
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 #6447: Add LOD support to Object Paging
Feature #6726: Lua API for creating new objects
Expand Down
6 changes: 5 additions & 1 deletion apps/openmw/mwworld/esmloader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,9 @@
#include <components/esm4/reader.hpp>
#include <components/files/conversion.hpp>
#include <components/files/openfile.hpp>
#include <components/resource/resourcesystem.hpp>

#include "../mwbase/environment.hpp"

namespace MWWorld
{
Expand Down Expand Up @@ -60,7 +63,8 @@ namespace MWWorld
}
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();
readerESM4.setEncoder(&statelessEncoder);
mStore.loadESM4(readerESM4);
Expand Down
8 changes: 5 additions & 3 deletions components/esm4/reader.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,8 +74,9 @@ namespace ESM4
subRecordHeader.dataSize = 0;
}

Reader::Reader(Files::IStreamPtr&& esmStream, const std::filesystem::path& filename)
: mEncoder(nullptr)
Reader::Reader(Files::IStreamPtr&& esmStream, const std::filesystem::path& filename, VFS::Manager const* vfs)
: mVFS(vfs)
, mEncoder(nullptr)
, mFileSize(0)
, mStream(std::move(esmStream))
{
Expand Down Expand Up @@ -224,7 +225,8 @@ namespace ESM4
sp.type = stringType;

// 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);
std::size_t fileSize = filestream->tellg();
Expand Down
4 changes: 3 additions & 1 deletion components/esm4/reader.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,6 +33,7 @@
#include "loadtes4.hpp"

#include <components/files/istreamptr.hpp>
#include <components/vfs/manager.hpp>

namespace ToUTF8
{
Expand Down Expand Up @@ -83,6 +84,7 @@ namespace ESM4

class Reader
{
VFS::Manager const* mVFS;
Header mHeader; // ESM4 header

ReaderContext mCtx;
Expand Down Expand Up @@ -138,7 +140,7 @@ namespace ESM4
const ToUTF8::StatelessUtf8Encoder* encoder, bool hasNull = false);

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();

void open(const std::filesystem::path& filename);
Expand Down

0 comments on commit ee41151

Please sign in to comment.