mirror of https://github.com/OpenMW/openmw.git
Simplify material file pointer acrobatics
parent
023c0f7a46
commit
78eda530ac
@ -1,33 +0,0 @@
|
||||
#include "reader.hpp"
|
||||
|
||||
#include <array>
|
||||
#include <stdexcept>
|
||||
#include <string>
|
||||
|
||||
#include "stream.hpp"
|
||||
|
||||
namespace Bgsm
|
||||
{
|
||||
void Reader::parse(Files::IStreamPtr&& inputStream)
|
||||
{
|
||||
BGSMStream stream(std::move(inputStream));
|
||||
|
||||
std::array<char, 4> signature;
|
||||
stream.readArray(signature);
|
||||
std::string shaderType(signature.data(), 4);
|
||||
if (shaderType == "BGEM")
|
||||
{
|
||||
mFile = std::make_unique<BGEMFile>();
|
||||
mFile->mShaderType = Bgsm::ShaderType::Effect;
|
||||
}
|
||||
else if (shaderType == "BGSM")
|
||||
{
|
||||
mFile = std::make_unique<BGSMFile>();
|
||||
mFile->mShaderType = Bgsm::ShaderType::Lighting;
|
||||
}
|
||||
else
|
||||
throw std::runtime_error("Invalid material file");
|
||||
|
||||
mFile->read(stream);
|
||||
}
|
||||
}
|
@ -1,22 +0,0 @@
|
||||
#ifndef OPENMW_COMPONENTS_BGSM_READER_HPP
|
||||
#define OPENMW_COMPONENTS_BGSM_READER_HPP
|
||||
|
||||
#include <memory>
|
||||
|
||||
#include <components/files/istreamptr.hpp>
|
||||
|
||||
#include "file.hpp"
|
||||
|
||||
namespace Bgsm
|
||||
{
|
||||
class Reader
|
||||
{
|
||||
std::unique_ptr<MaterialFile> mFile;
|
||||
|
||||
public:
|
||||
void parse(Files::IStreamPtr&& stream);
|
||||
|
||||
std::unique_ptr<MaterialFile> getFile() { return std::move(mFile); }
|
||||
};
|
||||
}
|
||||
#endif
|
Loading…
Reference in New Issue