mirror of https://github.com/OpenTTD/OpenTTD
Codechange: Keep Squirrel engine in unique_ptr.
parent
9339b8270c
commit
149445c79e
|
@ -32,7 +32,7 @@ void AIScannerInfo::Initialize()
|
||||||
{
|
{
|
||||||
ScriptScanner::Initialize("AIScanner");
|
ScriptScanner::Initialize("AIScanner");
|
||||||
|
|
||||||
ScriptAllocatorScope alloc_scope(this->engine);
|
ScriptAllocatorScope alloc_scope(this->engine.get());
|
||||||
|
|
||||||
/* Create the dummy AI */
|
/* Create the dummy AI */
|
||||||
this->main_script = "%_dummy";
|
this->main_script = "%_dummy";
|
||||||
|
|
|
@ -44,10 +44,7 @@ bool ScriptScanner::AddFile(const std::string &filename, size_t, const std::stri
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
ScriptScanner::ScriptScanner() :
|
ScriptScanner::ScriptScanner() = default;
|
||||||
engine(nullptr)
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
||||||
void ScriptScanner::ResetEngine()
|
void ScriptScanner::ResetEngine()
|
||||||
{
|
{
|
||||||
|
@ -58,7 +55,7 @@ void ScriptScanner::ResetEngine()
|
||||||
|
|
||||||
void ScriptScanner::Initialize(std::string_view name)
|
void ScriptScanner::Initialize(std::string_view name)
|
||||||
{
|
{
|
||||||
this->engine = new Squirrel(name);
|
this->engine = std::make_unique<Squirrel>(name);
|
||||||
|
|
||||||
this->RescanDir();
|
this->RescanDir();
|
||||||
|
|
||||||
|
@ -68,8 +65,6 @@ void ScriptScanner::Initialize(std::string_view name)
|
||||||
ScriptScanner::~ScriptScanner()
|
ScriptScanner::~ScriptScanner()
|
||||||
{
|
{
|
||||||
this->Reset();
|
this->Reset();
|
||||||
|
|
||||||
delete this->engine;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void ScriptScanner::RescanDir()
|
void ScriptScanner::RescanDir()
|
||||||
|
|
|
@ -26,7 +26,7 @@ public:
|
||||||
/**
|
/**
|
||||||
* Get the engine of the main squirrel handler (it indexes all available scripts).
|
* Get the engine of the main squirrel handler (it indexes all available scripts).
|
||||||
*/
|
*/
|
||||||
class Squirrel *GetEngine() { return this->engine; }
|
class Squirrel *GetEngine() { return this->engine.get(); }
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the current main script the ScanDir is currently tracking.
|
* Get the current main script the ScanDir is currently tracking.
|
||||||
|
@ -84,7 +84,7 @@ public:
|
||||||
void RescanDir();
|
void RescanDir();
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
class Squirrel *engine; ///< The engine we're scanning with.
|
std::unique_ptr<class Squirrel> engine; ///< The engine we're scanning with.
|
||||||
std::string main_script; ///< The full path of the script.
|
std::string main_script; ///< The full path of the script.
|
||||||
std::string tar_file; ///< If, which tar file the script was in.
|
std::string tar_file; ///< If, which tar file the script was in.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue