diff options
author | aunsane <aunsane@gmail.com> | 2018-08-12 22:55:02 +0300 |
---|---|---|
committer | aunsane <aunsane@gmail.com> | 2018-08-12 23:51:19 +0300 |
commit | af5b577d924b941d85d87280b1b4df37b848e510 (patch) | |
tree | 8aa30099cd386a254e9a2cff811fbe14eccf219f /plugins | |
parent | bd44f4f713e9768251691de07b0ed50f86573965 (diff) |
MirLua: fix cast into m_database + correct error on type mismatch
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/MirLua/src/Modules/m_database.cpp | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/plugins/MirLua/src/Modules/m_database.cpp b/plugins/MirLua/src/Modules/m_database.cpp index 21b87c0274..78cd494517 100644 --- a/plugins/MirLua/src/Modules/m_database.cpp +++ b/plugins/MirLua/src/Modules/m_database.cpp @@ -416,7 +416,7 @@ static int db_DeleteModule(lua_State *L) return 1; } -static int SettingsEnumProc(const char* szSetting, void *lParam) +static int SettingsEnumProc(const char *szSetting, void *lParam) { if (szSetting ) { LIST<char>* p = (LIST<char>*)lParam; @@ -496,6 +496,9 @@ static int db_WriteSetting(lua_State *L) case LUA_TBOOLEAN: dbv.type = DBVT_BYTE; break; + case LUA_TINTEGER: + dbv.type = DBVT_WORD; + break; case LUA_TNUMBER: dbv.type = DBVT_DWORD; break; @@ -517,10 +520,10 @@ static int db_WriteSetting(lua_State *L) case DBVT_BYTE: dbv.bVal = lua_isboolean(L, 4) ? lua_toboolean(L, 4) - : luaL_checknumber(L, 4); + : luaL_checkinteger(L, 4); break; case DBVT_WORD: - dbv.wVal = luaL_checknumber(L, 4); + dbv.wVal = luaL_checkinteger(L, 4); break; case DBVT_DWORD: dbv.dVal = luaL_checknumber(L, 4); @@ -546,8 +549,7 @@ static int db_WriteSetting(lua_State *L) break; } default: - lua_pushboolean(L, false); - return 1; + luaL_argerror(L, 4, luaL_typename(L, 4)); } INT_PTR res = db_set(hContact, szModule, szSetting, &dbv); |