From 66725ad22d7d30fc0b96a457b9ab520f0b35117e Mon Sep 17 00:00:00 2001 From: Mark Vejvoda Date: Wed, 6 Oct 2010 23:40:26 +0000 Subject: [PATCH] - added new commandline parameter: --lua-info --- source/glest_game/main/main.cpp | 11 ++++++++++- source/shared_lib/sources/lua/lua_script.cpp | 4 +++- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/source/glest_game/main/main.cpp b/source/glest_game/main/main.cpp index 57d88aef..2ea6b0b1 100644 --- a/source/glest_game/main/main.cpp +++ b/source/glest_game/main/main.cpp @@ -58,6 +58,7 @@ const char *GAME_ARGS[] = { "--version", "--opengl-info", "--sdl-info", + "--lua-info", "--validate-techtrees", "--validate-factions" @@ -72,6 +73,7 @@ enum GAME_ARG_TYPE { GAME_ARG_VERSION, GAME_ARG_OPENGL_INFO, GAME_ARG_SDL_INFO, + GAME_ARG_LUA_INFO, GAME_ARG_VALIDATE_TECHTREES, GAME_ARG_VALIDATE_FACTIONS }; @@ -479,6 +481,7 @@ void printParameterHelp(const char *argv0, bool foundInvalidArgs) { printf("\n%s\t\t\tdisplays the version string of this program.",GAME_ARGS[GAME_ARG_VERSION]); printf("\n%s\t\t\tdisplays your video driver's OpenGL information.",GAME_ARGS[GAME_ARG_OPENGL_INFO]); printf("\n%s\t\t\tdisplays your SDL version information.",GAME_ARGS[GAME_ARG_SDL_INFO]); + printf("\n%s\t\t\tdisplays your LUA version information.",GAME_ARGS[GAME_ARG_LUA_INFO]); printf("\n%s=x\t\tdisplays a report detailing any known problems related",GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]); printf("\n \t\tto your selected techtrees game data."); printf("\n \t\tWhere x is a comma-delimited list of techtrees to validate."); @@ -517,6 +520,7 @@ int glestMain(int argc, char** argv){ if( hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_OPENGL_INFO]) == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LUA_INFO]) == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VERSION]) == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]) == true || hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == true) { @@ -545,8 +549,13 @@ int glestMain(int argc, char** argv){ print_SDL_version("SDL runtime version", &ver); } + if(hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LUA_INFO]) == true) { + printf("LUA version: %s\n", LUA_RELEASE); + } + if( (hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VERSION]) == true || - hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true) && + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_SDL_INFO]) == true || + hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_LUA_INFO]) == true) && hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_OPENGL_INFO]) == false && hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_TECHTREES]) == false && hasCommandArgument(argc, argv,GAME_ARGS[GAME_ARG_VALIDATE_FACTIONS]) == false) { diff --git a/source/shared_lib/sources/lua/lua_script.cpp b/source/shared_lib/sources/lua/lua_script.cpp index 294ba318..fbeb1366 100644 --- a/source/shared_lib/sources/lua/lua_script.cpp +++ b/source/shared_lib/sources/lua/lua_script.cpp @@ -82,8 +82,10 @@ void LuaScript::loadCode(const string &code, const string &name){ throw runtime_error("Error initializing lua: " + errorToString(errorCode)); } + const char *errMsg = lua_tostring(luaState, -1); + //SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] name [%s], errorCode = %d,\ncode [%s]\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),errorCode,code.c_str()); - SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] name [%s], errorCode = %d\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),errorCode); + SystemFlags::OutputDebug(SystemFlags::debugLUA,"In [%s::%s Line: %d] name [%s], errorCode = %d, errMsg = %s\n",__FILE__,__FUNCTION__,__LINE__,name.c_str(),errorCode,(errMsg != NULL ? errMsg : "")); } void LuaScript::beginCall(const string& functionName){