diff options
Diffstat (limited to 'src/script/cpp_api')
-rw-r--r-- | src/script/cpp_api/s_base.cpp | 31 | ||||
-rw-r--r-- | src/script/cpp_api/s_base.h | 3 |
2 files changed, 15 insertions, 19 deletions
diff --git a/src/script/cpp_api/s_base.cpp b/src/script/cpp_api/s_base.cpp index e02a6aa0d..2eb7419b5 100644 --- a/src/script/cpp_api/s_base.cpp +++ b/src/script/cpp_api/s_base.cpp @@ -142,7 +142,7 @@ bool ScriptApiBase::loadScript(const std::string &script_path, std::string *erro if (!ok) { std::string error_msg = lua_tostring(L, -1); if (error) - (*error) = error_msg; + *error = error_msg; errorstream << "========== ERROR FROM LUA ===========" << std::endl << "Failed to load and run script from " << std::endl << script_path << ":" << std::endl << std::endl @@ -157,8 +157,8 @@ bool ScriptApiBase::loadScript(const std::string &script_path, std::string *erro void ScriptApiBase::realityCheck() { int top = lua_gettop(m_luastack); - if(top >= 30){ - dstream<<"Stack is over 30:"<<std::endl; + if (top >= 30) { + dstream << "Stack is over 30:" << std::endl; stackDump(dstream); std::string traceback = script_get_backtrace(m_luastack); throw LuaError("Stack is over 30 (reality check)\n" + traceback); @@ -172,34 +172,29 @@ void ScriptApiBase::scriptError() void ScriptApiBase::stackDump(std::ostream &o) { - int i; int top = lua_gettop(m_luastack); - for (i = 1; i <= top; i++) { /* repeat for each level */ + for (int i = 1; i <= top; i++) { /* repeat for each level */ int t = lua_type(m_luastack, i); switch (t) { - case LUA_TSTRING: /* strings */ - o<<"\""<<lua_tostring(m_luastack, i)<<"\""; + o << "\"" << lua_tostring(m_luastack, i) << "\""; break; - case LUA_TBOOLEAN: /* booleans */ - o<<(lua_toboolean(m_luastack, i) ? "true" : "false"); + o << (lua_toboolean(m_luastack, i) ? "true" : "false"); break; - case LUA_TNUMBER: /* numbers */ { char buf[10]; snprintf(buf, 10, "%g", lua_tonumber(m_luastack, i)); - o<<buf; - break; } - + o << buf; + break; + } default: /* other values */ - o<<lua_typename(m_luastack, t); + o << lua_typename(m_luastack, t); break; - } - o<<" "; + o << " "; } - o<<std::endl; + o << std::endl; } void ScriptApiBase::addObjectReference(ServerActiveObject *cobj) @@ -251,7 +246,7 @@ void ScriptApiBase::removeObjectReference(ServerActiveObject *cobj) void ScriptApiBase::objectrefGetOrCreate(lua_State *L, ServerActiveObject *cobj) { - if(cobj == NULL || cobj->getId() == 0){ + if (cobj == NULL || cobj->getId() == 0) { ObjectRef::create(L, cobj); } else { objectrefGet(L, cobj->getId()); diff --git a/src/script/cpp_api/s_base.h b/src/script/cpp_api/s_base.h index ee2835da2..13076d3d1 100644 --- a/src/script/cpp_api/s_base.h +++ b/src/script/cpp_api/s_base.h @@ -51,7 +51,8 @@ public: ScriptApiBase(); virtual ~ScriptApiBase(); - bool loadMod(const std::string &script_path, const std::string &mod_name, std::string *error=NULL); + bool loadMod(const std::string &script_path, const std::string &mod_name, + std::string *error=NULL); bool loadScript(const std::string &script_path, std::string *error=NULL); /* object */ |