forked from mirror/openmw-tes3mp
Use Ogre to load ESM data instead of Mangle
This commit is contained in:
parent
a8ebb39883
commit
7734771245
2 changed files with 15 additions and 13 deletions
|
@ -27,7 +27,7 @@ void ESMReader::restoreContext(const ESM_Context &rc)
|
|||
|
||||
void ESMReader::close()
|
||||
{
|
||||
mEsm.reset();
|
||||
mEsm.setNull();
|
||||
mCtx.filename.clear();
|
||||
mCtx.leftFile = 0;
|
||||
mCtx.leftRec = 0;
|
||||
|
@ -37,7 +37,7 @@ void ESMReader::close()
|
|||
mCtx.subName.val = 0;
|
||||
}
|
||||
|
||||
void ESMReader::openRaw(Mangle::Stream::StreamPtr _esm, const std::string &name)
|
||||
void ESMReader::openRaw(Ogre::DataStreamPtr _esm, const std::string &name)
|
||||
{
|
||||
close();
|
||||
mEsm = _esm;
|
||||
|
@ -57,7 +57,7 @@ void ESMReader::openRaw(Mangle::Stream::StreamPtr _esm, const std::string &name)
|
|||
mSpf = SF_Other;
|
||||
}
|
||||
|
||||
void ESMReader::open(Mangle::Stream::StreamPtr _esm, const std::string &name)
|
||||
void ESMReader::open(Ogre::DataStreamPtr _esm, const std::string &name)
|
||||
{
|
||||
openRaw(_esm, name);
|
||||
|
||||
|
@ -107,14 +107,16 @@ void ESMReader::open(Mangle::Stream::StreamPtr _esm, const std::string &name)
|
|||
|
||||
void ESMReader::open(const std::string &file)
|
||||
{
|
||||
using namespace Mangle::Stream;
|
||||
open(StreamPtr(new FileStream(file)), file);
|
||||
std::ifstream *stream = new std::ifstream(file.c_str(), std::ios_base::binary);
|
||||
// Ogre will delete the stream for us
|
||||
open(Ogre::DataStreamPtr(new Ogre::FileStreamDataStream(stream)), file);
|
||||
}
|
||||
|
||||
void ESMReader::openRaw(const std::string &file)
|
||||
{
|
||||
using namespace Mangle::Stream;
|
||||
openRaw(StreamPtr(new FileStream(file)), file);
|
||||
std::ifstream *stream = new std::ifstream(file.c_str(), std::ios_base::binary);
|
||||
// Ogre will delete the stream for us
|
||||
openRaw(Ogre::DataStreamPtr(new Ogre::FileStreamDataStream(stream)), file);
|
||||
}
|
||||
|
||||
int64_t ESMReader::getHNLong(const char *name)
|
||||
|
@ -339,7 +341,7 @@ void ESMReader::fail(const std::string &msg)
|
|||
ss << "\n File: " << mCtx.filename;
|
||||
ss << "\n Record: " << mCtx.recName.toString();
|
||||
ss << "\n Subrecord: " << mCtx.subName.toString();
|
||||
if (mEsm != NULL)
|
||||
if (!mEsm.isNull())
|
||||
ss << "\n Offset: 0x" << hex << mEsm->tell();
|
||||
throw std::runtime_error(ss.str());
|
||||
}
|
||||
|
|
|
@ -11,8 +11,8 @@
|
|||
#include <sstream>
|
||||
#include <stdexcept>
|
||||
|
||||
#include <libs/mangle/stream/stream.hpp>
|
||||
#include <libs/mangle/stream/servers/file_stream.hpp>
|
||||
#include <OgreDataStream.h>
|
||||
|
||||
#include <components/misc/stringops.hpp>
|
||||
|
||||
#include <components/to_utf8/to_utf8.hpp>
|
||||
|
@ -183,11 +183,11 @@ public:
|
|||
|
||||
/// Raw opening. Opens the file and sets everything up but doesn't
|
||||
/// parse the header.
|
||||
void openRaw(Mangle::Stream::StreamPtr _esm, const std::string &name);
|
||||
void openRaw(Ogre::DataStreamPtr _esm, const std::string &name);
|
||||
|
||||
/// Load ES file from a new stream, parses the header. Closes the
|
||||
/// currently open file first, if any.
|
||||
void open(Mangle::Stream::StreamPtr _esm, const std::string &name);
|
||||
void open(Ogre::DataStreamPtr _esm, const std::string &name);
|
||||
|
||||
void open(const std::string &file);
|
||||
|
||||
|
@ -354,7 +354,7 @@ public:
|
|||
void setEncoding(const std::string& encoding);
|
||||
|
||||
private:
|
||||
Mangle::Stream::StreamPtr mEsm;
|
||||
Ogre::DataStreamPtr mEsm;
|
||||
|
||||
ESM_Context mCtx;
|
||||
|
||||
|
|
Loading…
Reference in a new issue