From 8742d36a0673a1e48daa12431209f43aedffd955 Mon Sep 17 00:00:00 2001 From: SoftCoder Date: Mon, 30 Dec 2013 17:12:49 -0800 Subject: [PATCH] - do not save empty lua tables --- source/shared_lib/sources/lua/lua_script.cpp | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/source/shared_lib/sources/lua/lua_script.cpp b/source/shared_lib/sources/lua/lua_script.cpp index 3079602f4..41b9ca350 100644 --- a/source/shared_lib/sources/lua/lua_script.cpp +++ b/source/shared_lib/sources/lua/lua_script.cpp @@ -294,8 +294,12 @@ void LuaScript::saveGame(XmlNode *rootNode) { break; case LUA_TTABLE: { + + int tableItemCount = 0; if(LuaScript::debugModeEnabled == true) printf("================ LUA TABLE DETECTED - START =================\n"); for (lua_pushnil(L); lua_next(L, -2) ;) { + tableItemCount++; + if(LuaScript::debugModeEnabled == true) printf("LUA TABLE loop A\n"); int tableKeyType = lua_type(L, -2); @@ -363,6 +367,11 @@ void LuaScript::saveGame(XmlNode *rootNode) { lua_pop(L, 1); } } + if(tableItemCount < 1) { + if(LuaScript::debugModeEnabled == true) printf("Skipping lua table tableItemCount = %d\n",tableItemCount); + + skipTable = true; + } if(LuaScript::debugModeEnabled == true) printf("---------------------------- LUA TABLE DETECTED - END ----------------------------\n"); } break;