summaryrefslogtreecommitdiff
path: root/src/script/cpp_api
diff options
context:
space:
mode:
authorShadowNinja <shadowninja@minetest.net>2014-04-27 17:55:49 -0400
committerShadowNinja <shadowninja@minetest.net>2014-05-07 17:14:23 -0400
commit1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528 (patch)
tree8c1e2c708f567656684e89faee4f7c8e6c5ec673 /src/script/cpp_api
parentfef2729fd0945601e6772780514ee55fec35b068 (diff)
downloadminetest-1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528.tar.gz
minetest-1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528.tar.bz2
minetest-1cd512913e4d4ad1fb43d4b6e3d7971bb6c67528.zip
Organize builtin into subdirectories
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r--src/script/cpp_api/s_async.cpp14
-rw-r--r--src/script/cpp_api/s_base.cpp20
2 files changed, 12 insertions, 22 deletions
diff --git a/src/script/cpp_api/s_async.cpp b/src/script/cpp_api/s_async.cpp
index 4feed3e56..64260fb3a 100644
--- a/src/script/cpp_api/s_async.cpp
+++ b/src/script/cpp_api/s_async.cpp
@@ -26,6 +26,7 @@ extern "C" {
#include "lualib.h"
}
+#include "server.h"
#include "s_async.h"
#include "log.h"
#include "filesys.h"
@@ -233,9 +234,9 @@ AsyncWorkerThread::AsyncWorkerThread(AsyncEngine* jobDispatcher,
lua_pushstring(L, DIR_DELIM);
lua_setglobal(L, "DIR_DELIM");
- lua_pushstring(L,
- (porting::path_share + DIR_DELIM + "builtin").c_str());
- lua_setglobal(L, "SCRIPTDIR");
+ // Push builtin initialization type
+ lua_pushstring(L, "async");
+ lua_setglobal(L, "INIT");
jobDispatcher->prepareEnvironment(L, top);
}
@@ -258,17 +259,16 @@ void* AsyncWorkerThread::Thread()
porting::setThreadName((std::string("AsyncWorkTh_") + number).c_str());
- std::string asyncscript = porting::path_share + DIR_DELIM + "builtin"
- + DIR_DELIM + "async_env.lua";
+ lua_State *L = getStack();
- if (!loadScript(asyncscript)) {
+ std::string script = getServer()->getBuiltinLuaPath() + DIR_DELIM + "init.lua";
+ if (!loadScript(script)) {
errorstream
<< "AsyncWorkderThread execution of async base environment failed!"
<< std::endl;
abort();
}
- lua_State *L = getStack();
// Main loop
while (!StopRequested()) {
// Wait for job
diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp
index 774b3f51d..1a172fd31 100644
--- a/src/script/cpp_api/s_base.cpp
+++ b/src/script/cpp_api/s_base.cpp
@@ -88,9 +88,9 @@ ScriptApiBase::ScriptApiBase()
lua_pop(m_luastack, 1);
#endif
- m_server = 0;
- m_environment = 0;
- m_guiengine = 0;
+ m_server = NULL;
+ m_environment = NULL;
+ m_guiengine = NULL;
}
ScriptApiBase::~ScriptApiBase()
@@ -103,24 +103,14 @@ bool ScriptApiBase::loadMod(const std::string &scriptpath,
{
ModNameStorer modnamestorer(getStack(), modname);
- if(!string_allowed(modname, MODNAME_ALLOWED_CHARS)){
+ if (!string_allowed(modname, MODNAME_ALLOWED_CHARS)) {
errorstream<<"Error loading mod \""<<modname
<<"\": modname does not follow naming conventions: "
<<"Only chararacters [a-z0-9_] are allowed."<<std::endl;
return false;
}
- bool success = false;
-
- try{
- success = loadScript(scriptpath);
- }
- catch(LuaError &e){
- errorstream<<"Error loading mod \""<<modname
- <<"\": "<<e.what()<<std::endl;
- }
-
- return success;
+ return loadScript(scriptpath);
}
bool ScriptApiBase::loadScript(const std::string &scriptpath)