|
|
@ -2,7 +2,6 @@
|
|
|
|
// Created by koncord on 19.03.16.
|
|
|
|
// Created by koncord on 19.03.16.
|
|
|
|
//
|
|
|
|
//
|
|
|
|
|
|
|
|
|
|
|
|
#include <apps/openmw-mp/Script/LangMono/LangMono.hpp>
|
|
|
|
|
|
|
|
#include "Script.hpp"
|
|
|
|
#include "Script.hpp"
|
|
|
|
#include "LangNative/LangNative.hpp"
|
|
|
|
#include "LangNative/LangNative.hpp"
|
|
|
|
|
|
|
|
|
|
|
@ -10,11 +9,28 @@
|
|
|
|
#include "LangLua/LangLua.hpp"
|
|
|
|
#include "LangLua/LangLua.hpp"
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
#ifdef ENABLE_MONO
|
|
|
|
|
|
|
|
#include "LangMono/LangMono.hpp"
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
|
|
|
|
using namespace std;
|
|
|
|
using namespace std;
|
|
|
|
|
|
|
|
|
|
|
|
Script::ScriptList Script::scripts;
|
|
|
|
Script::ScriptList Script::scripts;
|
|
|
|
std::string Script::moddir;
|
|
|
|
std::string Script::moddir;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
inline bool Load(Language *lang, const std::string &path)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
lang->LoadProgram(path.c_str());
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
lang->FreeProgram();
|
|
|
|
|
|
|
|
throw std::runtime_error("Failed to load: " + path);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Script::Script(const char *path)
|
|
|
|
Script::Script(const char *path)
|
|
|
|
{
|
|
|
|
{
|
|
|
|
FILE *file = fopen(path, "rb");
|
|
|
|
FILE *file = fopen(path, "rb");
|
|
|
@ -26,39 +42,43 @@ Script::Script(const char *path)
|
|
|
|
|
|
|
|
|
|
|
|
if (strstr(path, ".dll"))
|
|
|
|
if (strstr(path, ".dll"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
|
|
|
|
#ifdef ENABLE_MONO
|
|
|
|
script_type = SCRIPT_MONO;
|
|
|
|
script_type = SCRIPT_MONO;
|
|
|
|
lang = new LangMono();
|
|
|
|
try
|
|
|
|
}
|
|
|
|
{
|
|
|
|
/*else
|
|
|
|
lang = new LangMono();
|
|
|
|
|
|
|
|
Load(lang, path);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch(...)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#ifdef _WIN32
|
|
|
|
#ifdef _WIN32
|
|
|
|
if (strstr(path, ".dll"))
|
|
|
|
script_type = SCRIPT_CPP;
|
|
|
|
#else
|
|
|
|
lang = new LangNative();
|
|
|
|
if (strstr(path, ".so"))
|
|
|
|
Load(lang, path);
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef ENABLE_MONO
|
|
|
|
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#ifndef _WIN32
|
|
|
|
|
|
|
|
else if (strstr(path, ".so"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
script_type = SCRIPT_CPP;
|
|
|
|
script_type = SCRIPT_CPP;
|
|
|
|
lang = new LangNative();
|
|
|
|
lang = new LangNative();
|
|
|
|
}*/
|
|
|
|
Load(lang, path);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
#if defined (ENABLE_LUA)
|
|
|
|
#if defined (ENABLE_LUA)
|
|
|
|
else if (strstr(path, ".lua") || strstr(path, ".t"))
|
|
|
|
else if (strstr(path, ".lua") || strstr(path, ".t"))
|
|
|
|
{
|
|
|
|
{
|
|
|
|
lang = new LangLua();
|
|
|
|
|
|
|
|
script_type = SCRIPT_LUA;
|
|
|
|
script_type = SCRIPT_LUA;
|
|
|
|
|
|
|
|
lang = new LangLua();
|
|
|
|
|
|
|
|
Load(lang, path);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
else
|
|
|
|
else
|
|
|
|
throw runtime_error("Script type not recognized: " + string(path));
|
|
|
|
throw runtime_error("Script type not recognized: " + string(path));
|
|
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
lang->LoadProgram(path);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
catch (...)
|
|
|
|
|
|
|
|
{
|
|
|
|
|
|
|
|
lang->FreeProgram();
|
|
|
|
|
|
|
|
throw;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|