From 8cf0298ead2e6d2930fd528ea0fc901d83208ddf Mon Sep 17 00:00:00 2001 From: Alexander Lantsev Date: Sun, 5 Jun 2016 18:08:58 +0000 Subject: MirLua: - GetContactInfo changed params place - reworked MT initialization git-svn-id: http://svn.miranda-ng.org/main/trunk@16921 1316c22d-e87f-b044-9b9b-93d7a3e3ba9c --- plugins/MirLua/src/m_database.cpp | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'plugins/MirLua/src/m_database.cpp') diff --git a/plugins/MirLua/src/m_database.cpp b/plugins/MirLua/src/m_database.cpp index b9482ed7f8..081ba1dd95 100644 --- a/plugins/MirLua/src/m_database.cpp +++ b/plugins/MirLua/src/m_database.cpp @@ -55,12 +55,14 @@ static int db_Contacts(lua_State *L) static int db_GetContactInfo(lua_State *L) { + MCONTACT hContact = luaL_checkinteger(L, 1); + int type = 0; - if (lua_isnumber(L, 1)) - type = lua_tointeger(L, 1); - else if (lua_isstring(L, 1)) + if (lua_isnumber(L, 2)) + type = lua_tointeger(L, 2); + else if (lua_isstring(L, 2)) { - const char *key = luaL_checkstring(L, 1); + const char *key = luaL_checkstring(L, 2); if (mir_strcmpi(key, "FirstName") == 0) type = CNF_FIRSTNAME; @@ -101,10 +103,7 @@ static int db_GetContactInfo(lua_State *L) } } - MCONTACT hContact = luaL_checkinteger(L, 2); - const char *proto = lua_tostring(L, 3); - - ptrT value(Contact_GetInfo(type, hContact, proto)); + ptrT value(Contact_GetInfo(type, hContact)); if (value) lua_pushstring(L, ptrA(mir_utf8encodeT(value))); else @@ -580,7 +579,6 @@ LUAMOD_API int luaopen_m_database(lua_State *L) MT(L, MT_DBCONTACTWRITESETTING) .Field(&DBCONTACTWRITESETTING::szModule, "Module", LUA_TSTRINGA) .Field(&DBCONTACTWRITESETTING::szSetting, "Setting", LUA_TSTRINGA); - lua_pop(L, 1); MT(L, MT_DBEVENTINFO) .Field(&DBEVENTINFO::szModule, "Module", LUA_TSTRINGA) @@ -589,7 +587,6 @@ LUAMOD_API int luaopen_m_database(lua_State *L) .Field(&DBEVENTINFO::flags, "Flags", LUA_TINTEGER) .Field(&DBEVENTINFO::cbBlob, "Length", LUA_TINTEGER) .Field(&DBEVENTINFO::pBlob, "Blob", LUA_TLIGHTUSERDATA); - lua_pop(L, 1); return 1; } -- cgit v1.2.3