mirror of
https://gitlab.com/OpenMW/openmw.git
synced 2025-05-03 07:17:59 +03:00
implemented local script execution
This commit is contained in:
parent
8e2732c60e
commit
474b412b47
7 changed files with 147 additions and 13 deletions
|
@ -1,8 +1,6 @@
|
|||
|
||||
#include "scriptmanager.hpp"
|
||||
|
||||
#include <components/compiler/scanner.hpp>
|
||||
|
||||
#include <cassert>
|
||||
#include <iostream>
|
||||
#include <sstream>
|
||||
|
@ -11,6 +9,12 @@
|
|||
#include <components/esm/loadscpt.hpp>
|
||||
#include <components/esm_store/store.hpp>
|
||||
|
||||
#include <components/compiler/scanner.hpp>
|
||||
|
||||
#include <components/interpreter/installopcodes.hpp>
|
||||
#include <components/interpreter/interpreter.hpp>
|
||||
|
||||
|
||||
namespace MWScript
|
||||
{
|
||||
ScriptManager::ScriptManager (const ESMS::ESMStore& store, bool verbose,
|
||||
|
@ -70,8 +74,7 @@ namespace MWScript
|
|||
return false;
|
||||
}
|
||||
|
||||
void ScriptManager::run (const std::string& name/*,
|
||||
Interpreter::Context& interpreterContext*/, Locals& locals)
|
||||
void ScriptManager::run (const std::string& name, Interpreter::Context& interpreterContext)
|
||||
{
|
||||
// compile script
|
||||
std::map<std::string, std::vector<Interpreter::Type_Code> >::iterator iter =
|
||||
|
@ -92,7 +95,18 @@ namespace MWScript
|
|||
}
|
||||
|
||||
// execute script
|
||||
|
||||
if (!iter->second.empty())
|
||||
try
|
||||
{
|
||||
Interpreter::Interpreter interpreter (interpreterContext);
|
||||
Interpreter::installOpcodes (interpreter);
|
||||
interpreter.run (&iter->second[0], iter->second.size());
|
||||
}
|
||||
catch (...)
|
||||
{
|
||||
std::cerr << "exeution of script " << name << " failed." << std::endl;
|
||||
iter->second.clear(); // don't execute again.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue