mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-01-26 18:35:20 +00:00
Use unique_ptr to manage scripts context and encoder lifetime
This commit is contained in:
parent
8047a2138e
commit
68caff9c7b
@ -429,7 +429,6 @@ bool OMW::Engine::frame(float frametime)
|
||||
OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
||||
: mWindow(nullptr)
|
||||
, mEncoding(ToUTF8::WINDOWS_1252)
|
||||
, mEncoder(nullptr)
|
||||
, mScreenCaptureOperation(nullptr)
|
||||
, mSelectDepthFormatOperation(new SceneUtil::SelectDepthFormatOperation())
|
||||
, mSelectColorFormatOperation(new SceneUtil::Color::SelectColorFormatOperation())
|
||||
@ -444,7 +443,6 @@ OMW::Engine::Engine(Files::ConfigurationManager& configurationManager)
|
||||
, mGrab(true)
|
||||
, mExportFonts(false)
|
||||
, mRandomSeed(0)
|
||||
, mScriptContext (nullptr)
|
||||
, mFSStrict (false)
|
||||
, mScriptBlacklistUse (true)
|
||||
, mNewGame (false)
|
||||
@ -480,7 +478,6 @@ OMW::Engine::~Engine()
|
||||
mStateManager = nullptr;
|
||||
mLuaManager = nullptr;
|
||||
|
||||
delete mScriptContext;
|
||||
mScriptContext = nullptr;
|
||||
|
||||
mWorkQueue = nullptr;
|
||||
@ -489,7 +486,6 @@ OMW::Engine::~Engine()
|
||||
|
||||
mResourceSystem.reset();
|
||||
|
||||
delete mEncoder;
|
||||
mEncoder = nullptr;
|
||||
|
||||
if (mWindow)
|
||||
@ -833,7 +829,7 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||
|
||||
// Create the world
|
||||
mWorld = std::make_unique<MWWorld::World>(mViewer, rootNode, mResourceSystem.get(), mWorkQueue.get(),
|
||||
mFileCollections, mContentFiles, mGroundcoverFiles, mEncoder, mActivationDistanceOverride, mCellName,
|
||||
mFileCollections, mContentFiles, mGroundcoverFiles, mEncoder.get(), mActivationDistanceOverride, mCellName,
|
||||
mStartupScript, mResDir.string(), mCfgMgr.getUserDataPath().string());
|
||||
mWorld->setupPlayer();
|
||||
mWorld->setRandomSeed(mRandomSeed);
|
||||
@ -843,14 +839,14 @@ void OMW::Engine::prepareEngine (Settings::Manager & settings)
|
||||
mWindowManager->initUI();
|
||||
|
||||
//Load translation data
|
||||
mTranslationDataStorage.setEncoder(mEncoder);
|
||||
mTranslationDataStorage.setEncoder(mEncoder.get());
|
||||
for (size_t i = 0; i < mContentFiles.size(); i++)
|
||||
mTranslationDataStorage.loadTranslationData(mFileCollections, mContentFiles[i]);
|
||||
|
||||
Compiler::registerExtensions (mExtensions);
|
||||
|
||||
// Create script system
|
||||
mScriptContext = new MWScript::CompilerContext (MWScript::CompilerContext::Type_Full);
|
||||
mScriptContext = std::make_unique<MWScript::CompilerContext>(MWScript::CompilerContext::Type_Full);
|
||||
mScriptContext->setExtensions (&mExtensions);
|
||||
|
||||
mScriptManager = std::make_unique<MWScript::ScriptManager>(mWorld->getStore(), *mScriptContext, mWarningsMode,
|
||||
@ -993,7 +989,7 @@ void OMW::Engine::go()
|
||||
MWClass::registerClasses();
|
||||
|
||||
// Create encoder
|
||||
mEncoder = new ToUTF8::Utf8Encoder(mEncoding);
|
||||
mEncoder = std::make_unique<ToUTF8::Utf8Encoder>(mEncoding);
|
||||
|
||||
// Setup viewer
|
||||
mViewer = new osgViewer::Viewer;
|
||||
|
@ -132,7 +132,7 @@ namespace OMW
|
||||
std::unique_ptr<MWLua::LuaManager> mLuaManager;
|
||||
MWBase::Environment mEnvironment;
|
||||
ToUTF8::FromType mEncoding;
|
||||
ToUTF8::Utf8Encoder* mEncoder;
|
||||
std::unique_ptr<ToUTF8::Utf8Encoder> mEncoder;
|
||||
Files::PathContainer mDataDirs;
|
||||
std::vector<std::string> mArchives;
|
||||
boost::filesystem::path mResDir;
|
||||
@ -164,7 +164,7 @@ namespace OMW
|
||||
unsigned int mRandomSeed;
|
||||
|
||||
Compiler::Extensions mExtensions;
|
||||
Compiler::Context *mScriptContext;
|
||||
std::unique_ptr<Compiler::Context> mScriptContext;
|
||||
|
||||
Files::Collections mFileCollections;
|
||||
bool mFSStrict;
|
||||
|
Loading…
x
Reference in New Issue
Block a user