From 3c62ce97dbb3e25040d025acda42012ed3dc2edc Mon Sep 17 00:00:00 2001 From: Eduardo Bart Date: Fri, 6 Jan 2012 22:34:40 -0200 Subject: [PATCH] fixes in Settings --- modules/client_entergame/entergame.lua | 2 +- modules/core_lib/settings.lua | 12 +++++++++--- src/framework/luascript/luainterface.cpp | 1 + 3 files changed, 11 insertions(+), 4 deletions(-) diff --git a/modules/client_entergame/entergame.lua b/modules/client_entergame/entergame.lua index 28a5de5c..e42ca1aa 100644 --- a/modules/client_entergame/entergame.lua +++ b/modules/client_entergame/entergame.lua @@ -56,7 +56,7 @@ function EnterGame.create() local account = Settings.get('account') local password = Settings.get('password') local host = Settings.get('host') - local port = Settings.getNumber('port') + local port = Settings.get('port') local autologin = Settings.getBoolean('autologin') enterGame:getChildById('accountNameLineEdit'):setText(account) diff --git a/modules/core_lib/settings.lua b/modules/core_lib/settings.lua index d34e07d1..972b1b94 100644 --- a/modules/core_lib/settings.lua +++ b/modules/core_lib/settings.lua @@ -11,6 +11,8 @@ local function convertSettingValue(value) elseif value.r then return colortostring(value) end + elseif value == nil then + return '' else return tostring(value) end @@ -25,7 +27,12 @@ function Settings.remove(key) end function Settings.set(key, value) - g_configs.set(key, convertSettingValue(value)) + local valuestr = convertSettingValue(value) + if valuestr == '' then + g_configs.remove(key) + else + g_configs.set(key, convertSettingValue(value)) + end end function Settings.setDefault(key, value) @@ -35,8 +42,7 @@ function Settings.setDefault(key, value) end function Settings.get(key, default) - if Settings.exists(key) then - elseif default ~= nil then + if not Settings.exists(key) and default ~= nil then Settings.set(key, default) end return g_configs.get(key) diff --git a/src/framework/luascript/luainterface.cpp b/src/framework/luascript/luainterface.cpp index a57096e7..2460c2fb 100644 --- a/src/framework/luascript/luainterface.cpp +++ b/src/framework/luascript/luainterface.cpp @@ -934,6 +934,7 @@ void LuaInterface::pushBoolean(bool v) void LuaInterface::pushCString(const char* v) { + assert(v); lua_pushstring(L, v); }