From 7b171ea2be0e476d7cdc9300b53ba86a9f694161 Mon Sep 17 00:00:00 2001 From: kwolekr Date: Thu, 2 Jul 2015 23:14:30 -0400 Subject: Fix code style from recent commits and add misc. optimizations --- src/script/cpp_api/s_base.cpp | 31 +++++++++++++------------------ 1 file changed, 13 insertions(+), 18 deletions(-) (limited to 'src/script/cpp_api/s_base.cpp') 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:"<= 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<<"\""<getId() == 0){ + if (cobj == NULL || cobj->getId() == 0) { ObjectRef::create(L, cobj); } else { objectrefGet(L, cobj->getId()); -- cgit v1.2.3