From 0d006ce6d1bcf1ecb78b432c2e03726ddf958d22 Mon Sep 17 00:00:00 2001 From: hongliang Date: Thu, 30 Oct 2014 17:07:37 +0800 Subject: [PATCH 1/2] overrided addSearchPath() by Runtime.cpp should support second argument as CCFileUtils.cpp does. --- .../runtime-src/Classes/runtime/Runtime.cpp | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp b/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp index 8fc0205fb2..279ecc3399 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp @@ -1071,24 +1071,30 @@ int lua_cocos2dx_runtime_addSearchPath(lua_State* tolua_S) #endif argc = lua_gettop(tolua_S)-1; - if (argc == 1) + if (argc == 1 || argc == 2) { std::string arg0; + bool arg1; ok &= luaval_to_std_string(tolua_S, 2,&arg0); + + if (argc == 2) { + ok &= luaval_to_boolean(tolua_S, 3, &arg1); + } + if(!ok) return 0; std::string originPath = arg0; if (!FileUtils::getInstance()->isAbsolutePath(originPath)) arg0 = g_resourcePath + originPath; - cobj->addSearchPath(arg0); + cobj->addSearchPath(arg0, arg1); if (!FileUtils::getInstance()->isAbsolutePath(originPath)) #if(CC_TARGET_PLATFORM == CC_PLATFORM_MAC || CC_TARGET_PLATFORM == CC_PLATFORM_WIN32) - cobj->addSearchPath(g_projectPath + originPath); + cobj->addSearchPath(g_projectPath + originPath, arg1); #endif #if(CC_TARGET_PLATFORM == CC_PLATFORM_IOS) - cobj->addSearchPath(originPath); + cobj->addSearchPath(originPath, arg1); #endif return 0; } From adb221babe7c2dd604a849161e92ebdf0fd0b2a7 Mon Sep 17 00:00:00 2001 From: hongliang Date: Fri, 31 Oct 2014 15:23:46 +0800 Subject: [PATCH 2/2] init arg1 as false for safety --- .../frameworks/runtime-src/Classes/runtime/Runtime.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp b/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp index 279ecc3399..856dbec457 100644 --- a/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp +++ b/templates/lua-template-runtime/frameworks/runtime-src/Classes/runtime/Runtime.cpp @@ -1074,7 +1074,7 @@ int lua_cocos2dx_runtime_addSearchPath(lua_State* tolua_S) if (argc == 1 || argc == 2) { std::string arg0; - bool arg1; + bool arg1 = false; ok &= luaval_to_std_string(tolua_S, 2,&arg0);