luainstance: Fix default parameter for config file setXXX functions

This commit is contained in:
M. Liebmann
2014-09-12 19:43:59 +02:00
parent 7398b43276
commit c49ceac121

View File

@@ -2292,9 +2292,12 @@ int CLuaInstance::LuaConfigFileSetString(lua_State *L)
{ {
CLuaConfigFile *c = LuaConfigFileCheck(L, 1); CLuaConfigFile *c = LuaConfigFileCheck(L, 1);
if (!c) return 0; if (!c) return 0;
int numargs = lua_gettop(L);
const char *key = luaL_checkstring(L, 2); const char *key = luaL_checkstring(L, 2);
const char *val = luaL_checkstring(L, 3); const char *val = "";
if (numargs > 2)
val = luaL_checkstring(L, 3);
c->c->setString(key, val); c->c->setString(key, val);
return 0; return 0;
} }
@@ -2316,9 +2319,12 @@ int CLuaInstance::LuaConfigFileSetInt32(lua_State *L)
{ {
CLuaConfigFile *c = LuaConfigFileCheck(L, 1); CLuaConfigFile *c = LuaConfigFileCheck(L, 1);
if (!c) return 0; if (!c) return 0;
int numargs = lua_gettop(L);
const char *key = luaL_checkstring(L, 2); const char *key = luaL_checkstring(L, 2);
int val = luaL_checkint(L, 3); int val = 0;
if (numargs > 2)
val = luaL_checkint(L, 3);
c->c->setInt32(key, val); c->c->setInt32(key, val);
return 0; return 0;
} }
@@ -2340,9 +2346,12 @@ int CLuaInstance::LuaConfigFileSetBool(lua_State *L)
{ {
CLuaConfigFile *c = LuaConfigFileCheck(L, 1); CLuaConfigFile *c = LuaConfigFileCheck(L, 1);
if (!c) return 0; if (!c) return 0;
int numargs = lua_gettop(L);
const char *key = luaL_checkstring(L, 2); const char *key = luaL_checkstring(L, 2);
bool val = _luaL_checkbool(L, 3); bool val = false;
if (numargs > 2)
val = _luaL_checkbool(L, 3);
c->c->setBool(key, val); c->c->setBool(key, val);
return 0; return 0;
} }