diff --git a/code/nel/src/misc/cdb_manager.cpp b/code/nel/src/misc/cdb_manager.cpp index a13527217..8fc8a6897 100644 --- a/code/nel/src/misc/cdb_manager.cpp +++ b/code/nel/src/misc/cdb_manager.cpp @@ -54,7 +54,7 @@ namespace NLMISC{ } - void CCDBManager::delDbNode( const stlpx_std::string &name ) + void CCDBManager::delDbNode( const std::string &name ) { if( name.empty() ) return; diff --git a/code/ryzom/client/src/commands.cpp b/code/ryzom/client/src/commands.cpp index efdee9bc9..6c804e93d 100644 --- a/code/ryzom/client/src/commands.cpp +++ b/code/ryzom/client/src/commands.cpp @@ -5082,7 +5082,7 @@ NLMISC_COMMAND(luaReload, "reload all .lua script files", "") } else { - pIM->displaySystemInfo(pIM->formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); return false; } } @@ -5109,7 +5109,7 @@ NLMISC_COMMAND(luaScript, "Execute a lua script", "direct_script_code") } else { - pIM->displaySystemInfo(pIM->formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); return false; } } @@ -5130,7 +5130,7 @@ NLMISC_COMMAND(luaInfo, "Dump some information on LUA state", "detaillevel from } else { - pIM->displaySystemInfo(pIM->formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); return false; } } @@ -5142,7 +5142,7 @@ NLMISC_COMMAND(luaObject, "Dump the content of a lua object", " [max CInterfaceManager *pIM= CInterfaceManager::getInstance(); if (!ClientCfg.AllowDebugLua) { - pIM->displaySystemInfo(pIM->formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); return false; } CLuaState *luaState = pIM->getLuaState(); @@ -5189,7 +5189,7 @@ NLMISC_COMMAND(luaGC, "Force a garbage collector of lua", "") } else { - pIM->displaySystemInfo(pIM->formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(LUADebugNotEnabledMsg)); return false; } } diff --git a/code/ryzom/client/src/interface_v3/interface_manager.cpp b/code/ryzom/client/src/interface_v3/interface_manager.cpp index 580b25526..313fc4300 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.cpp +++ b/code/ryzom/client/src/interface_v3/interface_manager.cpp @@ -5747,8 +5747,8 @@ bool CInterfaceManager::executeLuaScript(const std::string &luaScript, bool smal if (sscanf(msg.c_str(), "%s: %s.lua:%d:",exceptionName, filename, &line) == 3) // NB: test not exact here, but should work in 99,9 % of cases { msg = CLuaIHM::createGotoFileButtonTag(filename, line) + msg; - nlwarning(formatLuaErrorNlWarn(msg).c_str()); - displaySystemInfo(formatLuaErrorSysInfo(msg)); + nlwarning(LuaHelperStuff::formatLuaErrorNlWarn(msg).c_str()); + displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(msg)); } else // AJM: handle the other 0.1% of cases { @@ -5767,8 +5767,8 @@ bool CInterfaceManager::executeLuaScript(const std::string &luaScript, bool smal else if (line >= 1 && contextList.size() >= line) msg = error[0]+": \n>>>"+contextList[line-1]+"\nError:"+error[2]+": "+error[3]; } - nlwarning(formatLuaErrorNlWarn(msg).c_str()); - displaySystemInfo(formatLuaErrorSysInfo(msg)); + nlwarning(LuaHelperStuff::formatLuaErrorNlWarn(msg).c_str()); + displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(msg)); } return false; } @@ -5785,7 +5785,7 @@ void CInterfaceManager::reloadAllLuaFileScripts() // if fail to reload a script, display the error code if(!loadLUA(*it, error)) { - displaySystemInfo(formatLuaErrorSysInfo(error)); + displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(error)); } } } @@ -5837,25 +5837,11 @@ std::vector CInterfaceManager::getInGameXMLInterfaceFiles() return ret; } -// *************************************************************************** -void CInterfaceManager::formatLuaStackContext(std::string &stackContext) -{ - stackContext= string("@{FC8A}") + stackContext + "@{FC8F} "; -} -std::string CInterfaceManager::formatLuaErrorNlWarn(const std::string &error) -{ - // Remove color tags (see formatLuaErrorSC()) - std::string ret= error; - strFindReplace(ret, "@{FC8A}", ""); - strFindReplace(ret, "@{FC8F}", ""); - return ret; -} - // *************************************************************************** void CInterfaceManager::dumpLuaString(const std::string &str) { nlinfo(str.c_str()); - displaySystemInfo(formatLuaErrorSysInfo(str)); + displaySystemInfo(LuaHelperStuff::formatLuaErrorSysInfo(str)); } // *************************************************************************** diff --git a/code/ryzom/client/src/interface_v3/interface_manager.h b/code/ryzom/client/src/interface_v3/interface_manager.h index 3a5bccbb0..75a33cc29 100644 --- a/code/ryzom/client/src/interface_v3/interface_manager.h +++ b/code/ryzom/client/src/interface_v3/interface_manager.h @@ -633,11 +633,6 @@ public: class CLuaState *getLuaState() const {return _LuaState;} /// Reload all LUA scripts inserted through void reloadAllLuaFileScripts(); - /// for Debug: append some color TAG, to have a cool display in SystemInfo - std::string formatLuaErrorSysInfo(const std::string &error) {return std::string("@{FC8F}") + error;} - /// for Debug: append/remove some color TAG, to have a cool display in SystemInfo/nlwarning - void formatLuaStackContext(std::string &stackContext); - std::string formatLuaErrorNlWarn(const std::string &error); /// For debug: dump in the sysinfo and nlwarning state of lua. detail range from 0 to 2 (clamped). void dumpLuaState(uint detail); /// For debug: force a garbage collector diff --git a/code/ryzom/client/src/interface_v3/lua_helper.cpp b/code/ryzom/client/src/interface_v3/lua_helper.cpp index 9fa942d41..0299e66cc 100644 --- a/code/ryzom/client/src/interface_v3/lua_helper.cpp +++ b/code/ryzom/client/src/interface_v3/lua_helper.cpp @@ -18,7 +18,7 @@ #include "lua_helper.h" #include "nel/misc/file.h" -#include "interface_manager.h" +//#include "interface_manager.h" #include "../client_cfg.h" #ifdef LUA_NEVRAX_VERSION @@ -45,6 +45,28 @@ using namespace std; using namespace NLMISC; +namespace LuaHelperStuff +{ + void formatLuaStackContext( std::string &stackContext ) + { + stackContext = std::string( "@{FC8A}" ).append( stackContext ).append( "@{FC8F} " ); + } + + std::string formatLuaErrorSysInfo( const std::string &error ) + { + return std::string( "@{FC8F}" ).append( error ); + } + + std::string formatLuaErrorNlWarn( const std::string &error ) + { + // Remove color tags (see formatLuaErrorSC()) + std::string ret = error; + strFindReplace( ret, "@{FC8A}", "" ); + strFindReplace( ret, "@{FC8F}", "" ); + return ret; + } +} + // *************************************************************************** const char *CLuaState::_NELSmallScriptTableName= "NELSmallScriptTable"; uint CLuaStackChecker::_ExceptionContextCounter = 0; @@ -706,12 +728,11 @@ void ELuaWrappedFunctionException::init(CLuaState *ls, const std::string &reason { //H_AUTO(Lua_ELuaWrappedFunctionException_init) // Print first Lua Stack Context - CInterfaceManager *pIM= CInterfaceManager::getInstance(); if(ls) { ls->getStackContext(_Reason, 1); // 1 because 0 is the current C function => return 1 for script called // enclose with cool colors - pIM->formatLuaStackContext(_Reason); + LuaHelperStuff::formatLuaStackContext(_Reason); } // Append the reason diff --git a/code/ryzom/client/src/interface_v3/lua_helper.h b/code/ryzom/client/src/interface_v3/lua_helper.h index e6d50cb9d..71a3efe17 100644 --- a/code/ryzom/client/src/interface_v3/lua_helper.h +++ b/code/ryzom/client/src/interface_v3/lua_helper.h @@ -27,9 +27,16 @@ extern "C" #include "lua_loadlib.h" } - class CLuaState; +namespace LuaHelperStuff +{ + void formatLuaStackContext( std::string &stackContext ); + std::string formatLuaErrorSysInfo( const std::string &error ); + std::string formatLuaErrorNlWarn( const std::string &error ); +} + + // *************************************************************************** /** Helper class to see if a stack is restored at its initial size (or with n return results). * Check that the stack size remains unchanged when the object goes out of scope diff --git a/code/ryzom/client/src/interface_v3/lua_ihm.cpp b/code/ryzom/client/src/interface_v3/lua_ihm.cpp index 08b128b66..ebb374bd9 100644 --- a/code/ryzom/client/src/interface_v3/lua_ihm.cpp +++ b/code/ryzom/client/src/interface_v3/lua_ihm.cpp @@ -1806,7 +1806,7 @@ void CLuaIHM::rawDebugInfo(const std::string &dbg) } else { - NLMISC::InfoLog->displayRawNL(pIM->formatLuaErrorSysInfo(dbg).c_str()); + NLMISC::InfoLog->displayRawNL(LuaHelperStuff::formatLuaErrorSysInfo(dbg).c_str()); } #ifdef LUA_NEVRAX_VERSION if (LuaDebuggerIDE) @@ -1814,7 +1814,7 @@ void CLuaIHM::rawDebugInfo(const std::string &dbg) LuaDebuggerIDE->debugInfo(dbg.c_str()); } #endif - pIM->displaySystemInfo(pIM->formatLuaErrorSysInfo(dbg)); + pIM->displaySystemInfo( LuaHelperStuff::formatLuaErrorSysInfo(dbg)); } } @@ -3564,10 +3564,9 @@ bool CLuaIHM::executeFunctionOnStack(CLuaState &ls, int numArgs, int numRet) int CLuaIHM::breakPoint(CLuaState &ls) { //H_AUTO(Lua_CLuaIHM_breakPoint) - CInterfaceManager *pIM= CInterfaceManager::getInstance(); std::string reason; ls.getStackContext(reason, 1); // 1 because 0 is the current C function => return 1 for script called - pIM->formatLuaStackContext(reason); + LuaHelperStuff::formatLuaStackContext(reason); NLMISC::InfoLog->displayRawNL(reason.c_str()); static volatile bool doAssert = true; if (doAssert) // breakPoint can be discarded in case of looping assert